From 2d1b4c3bdf9aee611241cb387c29879da33b5081 Mon Sep 17 00:00:00 2001 From: amirroth Date: Thu, 5 Dec 2024 14:50:19 -0500 Subject: [PATCH 1/3] Initial commit, pre develop merge. --- src/EnergyPlus/AirLoopHVACDOAS.cc | 15 +- src/EnergyPlus/AirLoopHVACDOAS.hh | 6 +- src/EnergyPlus/AirTerminalUnit.hh | 3 +- .../include/AirflowNetwork/Elements.hpp | 27 +- .../include/AirflowNetwork/Solver.hpp | 12 +- src/EnergyPlus/AirflowNetwork/src/Solver.cpp | 242 +- .../Autosizing/BaseSizerWithFanHeatInputs.hh | 4 + .../Autosizing/BaseSizerWithScalableInputs.hh | 4 + .../Autosizing/SystemAirFlowSizing.hh | 4 + src/EnergyPlus/BaseboardElectric.cc | 116 +- src/EnergyPlus/BaseboardElectric.hh | 8 +- src/EnergyPlus/BaseboardRadiator.cc | 136 +- src/EnergyPlus/BaseboardRadiator.hh | 6 +- src/EnergyPlus/BoilerSteam.hh | 4 + src/EnergyPlus/Boilers.hh | 4 + src/EnergyPlus/BranchInputManager.hh | 4 + src/EnergyPlus/CTElectricGenerator.hh | 4 + src/EnergyPlus/ChilledCeilingPanelSimple.cc | 228 +- src/EnergyPlus/ChilledCeilingPanelSimple.hh | 11 +- src/EnergyPlus/ChillerAbsorption.hh | 4 + src/EnergyPlus/ChillerElectricASHRAE205.cc | 66 +- src/EnergyPlus/ChillerElectricASHRAE205.hh | 6 +- src/EnergyPlus/ChillerElectricEIR.cc | 384 +- src/EnergyPlus/ChillerElectricEIR.hh | 10 +- src/EnergyPlus/ChillerExhaustAbsorption.hh | 4 + src/EnergyPlus/ChillerGasAbsorption.hh | 4 + src/EnergyPlus/ChillerIndirectAbsorption.hh | 4 + src/EnergyPlus/ChillerReformulatedEIR.cc | 337 +- src/EnergyPlus/ChillerReformulatedEIR.hh | 8 +- src/EnergyPlus/Coils/CoilCoolingDX.cc | 18 +- src/EnergyPlus/Coils/CoilCoolingDX.hh | 8 +- .../Coils/CoilCoolingDXCurveFitPerformance.cc | 23 +- .../Coils/CoilCoolingDXCurveFitPerformance.hh | 3 +- src/EnergyPlus/CondenserLoopTowers.cc | 591 +- src/EnergyPlus/CondenserLoopTowers.hh | 10 +- src/EnergyPlus/Construction.hh | 6 +- src/EnergyPlus/ConvectionCoefficients.cc | 235 +- src/EnergyPlus/ConvectionCoefficients.hh | 21 +- src/EnergyPlus/CoolTower.cc | 146 +- src/EnergyPlus/CoolTower.hh | 9 +- src/EnergyPlus/CostEstimateManager.hh | 4 + src/EnergyPlus/CrossVentMgr.cc | 4 +- src/EnergyPlus/CrossVentMgr.hh | 4 + src/EnergyPlus/CurveManager.hh | 4 + src/EnergyPlus/DElightManagerF.cc | 8 +- src/EnergyPlus/DXCoils.cc | 239 +- src/EnergyPlus/DXCoils.hh | 15 +- src/EnergyPlus/DXFEarClipping.hh | 4 + src/EnergyPlus/Data/BaseData.hh | 1 + src/EnergyPlus/Data/EnergyPlusData.cc | 271 +- src/EnergyPlus/Data/EnergyPlusData.hh | 6 +- src/EnergyPlus/DataAirLoop.hh | 6 +- src/EnergyPlus/DataAirSystems.hh | 4 + src/EnergyPlus/DataBSDFWindow.hh | 4 + src/EnergyPlus/DataBranchAirLoopPlant.hh | 4 + src/EnergyPlus/DataBranchNodeConnections.hh | 4 + src/EnergyPlus/DataContaminantBalance.hh | 87 +- src/EnergyPlus/DataConvergParams.hh | 4 + src/EnergyPlus/DataDaylighting.hh | 6 +- src/EnergyPlus/DataDaylightingDevices.hh | 4 + src/EnergyPlus/DataDefineEquip.hh | 4 + src/EnergyPlus/DataEnvironment.hh | 11 +- src/EnergyPlus/DataErrorTracking.hh | 4 + src/EnergyPlus/DataGenerators.hh | 9 +- src/EnergyPlus/DataGlobalConstants.hh | 21 +- src/EnergyPlus/DataGlobals.hh | 8 +- src/EnergyPlus/DataHVACControllers.hh | 4 + src/EnergyPlus/DataHVACGlobals.hh | 17 +- src/EnergyPlus/DataHeatBalFanSys.hh | 25 +- src/EnergyPlus/DataHeatBalSurface.hh | 4 + src/EnergyPlus/DataHeatBalance.hh | 76 +- src/EnergyPlus/DataIPShortCuts.hh | 4 + src/EnergyPlus/DataLoopNode.hh | 13 +- src/EnergyPlus/DataMoistureBalance.hh | 4 + src/EnergyPlus/DataMoistureBalanceEMPD.hh | 4 + src/EnergyPlus/DataOutputs.hh | 4 + src/EnergyPlus/DataPhotovoltaics.hh | 8 +- src/EnergyPlus/DataReportingFlags.hh | 4 + src/EnergyPlus/DataRoomAirModel.hh | 19 +- src/EnergyPlus/DataRuntimeLanguage.hh | 9 +- src/EnergyPlus/DataShadowingCombinations.hh | 4 + src/EnergyPlus/DataSizing.cc | 20 +- src/EnergyPlus/DataSizing.hh | 21 +- src/EnergyPlus/DataStringGlobals.hh | 4 + src/EnergyPlus/DataSurfaceColors.hh | 4 + src/EnergyPlus/DataSurfaceLists.hh | 4 + src/EnergyPlus/DataSurfaces.cc | 42 +- src/EnergyPlus/DataSurfaces.hh | 95 +- src/EnergyPlus/DataSystemVariables.hh | 4 + src/EnergyPlus/DataTimings.hh | 4 + src/EnergyPlus/DataViewFactorInformation.hh | 4 + src/EnergyPlus/DataWater.hh | 28 +- src/EnergyPlus/DataWindowEquivalentLayer.hh | 4 + src/EnergyPlus/DataZoneControls.hh | 90 +- src/EnergyPlus/DataZoneEnergyDemands.hh | 4 + src/EnergyPlus/DataZoneEquipment.cc | 77 +- src/EnergyPlus/DataZoneEquipment.hh | 12 +- src/EnergyPlus/DaylightingDevices.cc | 24 +- src/EnergyPlus/DaylightingDevices.hh | 4 + src/EnergyPlus/DaylightingManager.cc | 473 +- src/EnergyPlus/DaylightingManager.hh | 8 +- src/EnergyPlus/DemandManager.cc | 419 +- src/EnergyPlus/DemandManager.hh | 17 +- src/EnergyPlus/DesiccantDehumidifiers.cc | 41 +- src/EnergyPlus/DesiccantDehumidifiers.hh | 8 +- src/EnergyPlus/DisplacementVentMgr.cc | 5 +- src/EnergyPlus/DisplacementVentMgr.hh | 4 + src/EnergyPlus/DualDuct.cc | 85 +- src/EnergyPlus/DualDuct.hh | 9 +- src/EnergyPlus/EMSManager.cc | 15 +- src/EnergyPlus/EMSManager.hh | 6 +- src/EnergyPlus/EarthTube.cc | 258 +- src/EnergyPlus/EarthTube.hh | 7 +- src/EnergyPlus/EcoRoofManager.cc | 32 +- src/EnergyPlus/EcoRoofManager.hh | 4 + src/EnergyPlus/EconomicLifeCycleCost.hh | 4 + src/EnergyPlus/EconomicTariff.cc | 590 +- src/EnergyPlus/EconomicTariff.hh | 24 +- src/EnergyPlus/ElectricBaseboardRadiator.cc | 177 +- src/EnergyPlus/ElectricBaseboardRadiator.hh | 6 +- src/EnergyPlus/ElectricPowerServiceManager.cc | 999 ++-- src/EnergyPlus/ElectricPowerServiceManager.hh | 23 +- src/EnergyPlus/EvaporativeCoolers.cc | 122 +- src/EnergyPlus/EvaporativeCoolers.hh | 16 +- src/EnergyPlus/EvaporativeFluidCoolers.cc | 33 +- src/EnergyPlus/EvaporativeFluidCoolers.hh | 6 +- src/EnergyPlus/ExhaustAirSystemManager.cc | 122 +- src/EnergyPlus/ExhaustAirSystemManager.hh | 20 +- src/EnergyPlus/ExteriorEnergyUse.cc | 289 +- src/EnergyPlus/ExteriorEnergyUse.hh | 13 +- src/EnergyPlus/ExternalInterface.cc | 877 +-- src/EnergyPlus/ExternalInterface.hh | 4 + src/EnergyPlus/FanCoilUnits.cc | 106 +- src/EnergyPlus/FanCoilUnits.hh | 16 +- src/EnergyPlus/Fans.cc | 123 +- src/EnergyPlus/Fans.hh | 12 +- src/EnergyPlus/FaultsManager.cc | 137 +- src/EnergyPlus/FaultsManager.hh | 10 +- src/EnergyPlus/FluidCoolers.hh | 4 + src/EnergyPlus/FluidProperties.cc | 850 ++- src/EnergyPlus/FluidProperties.hh | 24 +- src/EnergyPlus/FuelCellElectricGenerator.cc | 32 +- src/EnergyPlus/FuelCellElectricGenerator.hh | 8 +- src/EnergyPlus/Furnaces.cc | 209 +- src/EnergyPlus/Furnaces.hh | 12 +- src/EnergyPlus/General.hh | 4 + src/EnergyPlus/GeneralRoutines.cc | 6 +- src/EnergyPlus/GeneralRoutines.hh | 8 +- src/EnergyPlus/GeneratorDynamicsManager.cc | 58 +- src/EnergyPlus/GeneratorFuelSupply.cc | 14 +- src/EnergyPlus/GeneratorFuelSupply.hh | 4 + src/EnergyPlus/GlobalNames.hh | 4 + src/EnergyPlus/GroundHeatExchangers.cc | 16 +- src/EnergyPlus/GroundHeatExchangers.hh | 4 + .../FiniteDifferenceGroundTemperatureModel.cc | 10 +- .../GroundTemperatureModelManager.hh | 4 + .../KusudaAchenbachGroundTemperatureModel.cc | 12 +- .../SiteBuildingSurfaceGroundTemperatures.cc | 2 +- .../SiteDeepGroundTemperatures.cc | 2 +- .../SiteFCFactorMethodGroundTemperatures.cc | 2 +- .../SiteShallowGroundTemperatures.cc | 2 +- .../XingGroundTemperatureModel.cc | 4 +- src/EnergyPlus/HVACControllers.cc | 4 +- src/EnergyPlus/HVACControllers.hh | 4 + src/EnergyPlus/HVACCooledBeam.cc | 30 +- src/EnergyPlus/HVACCooledBeam.hh | 10 +- src/EnergyPlus/HVACDXHeatPumpSystem.cc | 28 +- src/EnergyPlus/HVACDXHeatPumpSystem.hh | 8 +- src/EnergyPlus/HVACDuct.hh | 4 + src/EnergyPlus/HVACFourPipeBeam.cc | 78 +- src/EnergyPlus/HVACFourPipeBeam.hh | 10 +- src/EnergyPlus/HVACHXAssistedCoolingCoil.hh | 4 + src/EnergyPlus/HVACInterfaceManager.hh | 4 + src/EnergyPlus/HVACManager.cc | 56 +- src/EnergyPlus/HVACManager.hh | 4 + src/EnergyPlus/HVACMultiSpeedHeatPump.cc | 83 +- src/EnergyPlus/HVACMultiSpeedHeatPump.hh | 14 +- src/EnergyPlus/HVACSingleDuctInduc.cc | 30 +- src/EnergyPlus/HVACSingleDuctInduc.hh | 9 +- src/EnergyPlus/HVACSizingSimulationManager.cc | 4 +- src/EnergyPlus/HVACSizingSimulationManager.hh | 4 + src/EnergyPlus/HVACStandAloneERV.cc | 28 +- src/EnergyPlus/HVACStandAloneERV.hh | 18 +- .../HVACSystemRootFindingAlgorithm.hh | 4 + src/EnergyPlus/HVACUnitaryBypassVAV.cc | 64 +- src/EnergyPlus/HVACUnitaryBypassVAV.hh | 12 +- src/EnergyPlus/HVACVariableRefrigerantFlow.cc | 228 +- src/EnergyPlus/HVACVariableRefrigerantFlow.hh | 26 +- src/EnergyPlus/HWBaseboardRadiator.cc | 23 +- src/EnergyPlus/HWBaseboardRadiator.hh | 6 +- src/EnergyPlus/HeatBalFiniteDiffManager.cc | 6 +- src/EnergyPlus/HeatBalFiniteDiffManager.hh | 4 + src/EnergyPlus/HeatBalanceAirManager.cc | 1556 ++--- src/EnergyPlus/HeatBalanceAirManager.hh | 4 + src/EnergyPlus/HeatBalanceHAMTManager.cc | 12 +- src/EnergyPlus/HeatBalanceHAMTManager.hh | 4 + src/EnergyPlus/HeatBalanceIntRadExchange.hh | 4 + .../HeatBalanceInternalHeatGains.hh | 4 + src/EnergyPlus/HeatBalanceKivaManager.cc | 78 +- src/EnergyPlus/HeatBalanceManager.cc | 367 +- src/EnergyPlus/HeatBalanceManager.hh | 4 + src/EnergyPlus/HeatBalanceSurfaceManager.cc | 87 +- src/EnergyPlus/HeatBalanceSurfaceManager.hh | 4 + src/EnergyPlus/HeatPumpWaterToWaterCOOLING.hh | 4 + src/EnergyPlus/HeatPumpWaterToWaterHEATING.hh | 4 + src/EnergyPlus/HeatPumpWaterToWaterSimple.hh | 4 + src/EnergyPlus/HeatRecovery.cc | 68 +- src/EnergyPlus/HeatRecovery.hh | 6 +- src/EnergyPlus/HeatingCoils.cc | 150 +- src/EnergyPlus/HeatingCoils.hh | 15 +- src/EnergyPlus/HighTempRadiantSystem.cc | 37 +- src/EnergyPlus/HighTempRadiantSystem.hh | 14 +- src/EnergyPlus/Humidifiers.cc | 53 +- src/EnergyPlus/Humidifiers.hh | 9 +- src/EnergyPlus/HybridEvapCoolingModel.cc | 30 +- src/EnergyPlus/HybridEvapCoolingModel.hh | 11 +- src/EnergyPlus/HybridModel.cc | 224 +- src/EnergyPlus/HybridModel.hh | 81 +- .../HybridUnitaryAirConditioners.cc | 61 +- .../HybridUnitaryAirConditioners.hh | 4 + src/EnergyPlus/ICEngineElectricGenerator.hh | 4 + src/EnergyPlus/IceThermalStorage.cc | 25 +- src/EnergyPlus/IceThermalStorage.hh | 12 +- src/EnergyPlus/IndoorGreen.cc | 225 +- src/EnergyPlus/IndoorGreen.hh | 11 +- .../InputProcessing/InputProcessor.hh | 4 + src/EnergyPlus/IntegratedHeatPump.hh | 4 + src/EnergyPlus/InternalHeatGains.cc | 1215 +--- src/EnergyPlus/InternalHeatGains.hh | 4 + src/EnergyPlus/LowTempRadiantSystem.cc | 299 +- src/EnergyPlus/LowTempRadiantSystem.hh | 52 +- src/EnergyPlus/Material.cc | 127 +- src/EnergyPlus/Material.hh | 9 +- src/EnergyPlus/MatrixDataManager.hh | 4 + src/EnergyPlus/MicroCHPElectricGenerator.cc | 22 +- src/EnergyPlus/MicroCHPElectricGenerator.hh | 8 +- .../MicroturbineElectricGenerator.hh | 4 + src/EnergyPlus/MixedAir.cc | 129 +- src/EnergyPlus/MixedAir.hh | 24 +- src/EnergyPlus/MixerComponent.hh | 4 + src/EnergyPlus/MoistureBalanceEMPDManager.cc | 3 +- src/EnergyPlus/MoistureBalanceEMPDManager.hh | 4 + src/EnergyPlus/MundtSimMgr.cc | 4 +- src/EnergyPlus/MundtSimMgr.hh | 4 + src/EnergyPlus/NodeInputManager.cc | 65 +- src/EnergyPlus/NodeInputManager.hh | 12 +- src/EnergyPlus/OutAirNodeManager.cc | 73 +- src/EnergyPlus/OutAirNodeManager.hh | 4 + src/EnergyPlus/OutdoorAirUnit.cc | 152 +- src/EnergyPlus/OutdoorAirUnit.hh | 35 +- src/EnergyPlus/OutputProcessor.cc | 175 +- src/EnergyPlus/OutputProcessor.hh | 10 +- src/EnergyPlus/OutputReportPredefined.hh | 4 + src/EnergyPlus/OutputReportTabular.cc | 339 +- src/EnergyPlus/OutputReportTabular.hh | 11 +- src/EnergyPlus/OutputReportTabularAnnual.cc | 11 +- src/EnergyPlus/OutputReportTabularAnnual.hh | 18 +- src/EnergyPlus/OutputReports.cc | 16 +- src/EnergyPlus/OutputReports.hh | 4 + src/EnergyPlus/OutsideEnergySources.cc | 41 +- src/EnergyPlus/OutsideEnergySources.hh | 6 +- src/EnergyPlus/PVWatts.cc | 4 +- src/EnergyPlus/PackagedThermalStorageCoil.cc | 68 +- src/EnergyPlus/PackagedThermalStorageCoil.hh | 14 +- .../PhaseChangeModeling/HysteresisModel.cc | 9 +- .../PhaseChangeModeling/HysteresisModel.hh | 4 + .../PhotovoltaicThermalCollectors.cc | 56 +- .../PhotovoltaicThermalCollectors.hh | 8 +- src/EnergyPlus/Photovoltaics.cc | 30 +- src/EnergyPlus/Photovoltaics.hh | 4 + src/EnergyPlus/PipeHeatTransfer.cc | 35 +- src/EnergyPlus/PipeHeatTransfer.hh | 14 +- src/EnergyPlus/Pipes.hh | 4 + src/EnergyPlus/Plant/DataPlant.hh | 4 + src/EnergyPlus/Plant/EquipAndOperations.hh | 6 +- src/EnergyPlus/Plant/PlantManager.cc | 8 +- src/EnergyPlus/Plant/PlantManager.hh | 4 + src/EnergyPlus/PlantCentralGSHP.cc | 62 +- src/EnergyPlus/PlantCentralGSHP.hh | 14 +- src/EnergyPlus/PlantChillers.cc | 121 +- src/EnergyPlus/PlantChillers.hh | 12 +- .../PlantComponentTemperatureSources.cc | 18 +- .../PlantComponentTemperatureSources.hh | 9 +- src/EnergyPlus/PlantCondLoopOperation.cc | 74 +- src/EnergyPlus/PlantCondLoopOperation.hh | 4 + .../PlantHeatExchangerFluidToFluid.cc | 19 +- .../PlantHeatExchangerFluidToFluid.hh | 8 +- src/EnergyPlus/PlantLoadProfile.cc | 34 +- src/EnergyPlus/PlantLoadProfile.hh | 10 +- src/EnergyPlus/PlantLoopHeatPumpEIR.cc | 4 +- src/EnergyPlus/PlantLoopHeatPumpEIR.hh | 8 + src/EnergyPlus/PlantPipingSystemsManager.cc | 12 +- src/EnergyPlus/PlantPipingSystemsManager.hh | 4 + src/EnergyPlus/PlantPressureSystem.hh | 4 + src/EnergyPlus/PlantUtilities.hh | 4 + src/EnergyPlus/PlantValves.hh | 4 + src/EnergyPlus/PluginManager.cc | 2 +- src/EnergyPlus/PluginManager.hh | 4 + src/EnergyPlus/PollutionModule.cc | 72 +- src/EnergyPlus/PollutionModule.hh | 10 +- src/EnergyPlus/PondGroundHeatExchanger.cc | 10 +- src/EnergyPlus/PondGroundHeatExchanger.hh | 4 + src/EnergyPlus/PoweredInductionUnits.cc | 42 +- src/EnergyPlus/PoweredInductionUnits.hh | 13 +- src/EnergyPlus/PsychCacheData.hh | 4 + src/EnergyPlus/Psychrometrics.hh | 6 +- src/EnergyPlus/Pumps.cc | 151 +- src/EnergyPlus/Pumps.hh | 16 +- src/EnergyPlus/PurchasedAirManager.cc | 85 +- src/EnergyPlus/PurchasedAirManager.hh | 21 +- src/EnergyPlus/RefrigeratedCase.cc | 943 +-- src/EnergyPlus/RefrigeratedCase.hh | 54 +- src/EnergyPlus/ReportCoilSelection.cc | 4 +- src/EnergyPlus/ReportCoilSelection.hh | 4 + src/EnergyPlus/ResultsFramework.hh | 4 + src/EnergyPlus/ReturnAirPathManager.hh | 4 + src/EnergyPlus/RoomAirModelAirflowNetwork.cc | 6 +- src/EnergyPlus/RoomAirModelAirflowNetwork.hh | 4 + src/EnergyPlus/RoomAirModelManager.cc | 34 +- src/EnergyPlus/RoomAirModelUserTempPattern.cc | 5 +- src/EnergyPlus/RoomAirModelUserTempPattern.hh | 4 + src/EnergyPlus/RuntimeLanguageProcessor.cc | 10 +- src/EnergyPlus/RuntimeLanguageProcessor.hh | 4 + src/EnergyPlus/SQLiteProcedures.cc | 41 +- src/EnergyPlus/SQLiteProcedures.hh | 58 +- src/EnergyPlus/ScheduleManager.cc | 5133 +++++++---------- src/EnergyPlus/ScheduleManager.hh | 515 +- src/EnergyPlus/SetPointManager.cc | 91 +- src/EnergyPlus/SetPointManager.hh | 27 +- src/EnergyPlus/SimAirServingZones.cc | 10 +- src/EnergyPlus/SimAirServingZones.hh | 4 + src/EnergyPlus/SimulationManager.cc | 79 +- src/EnergyPlus/SimulationManager.hh | 5 + src/EnergyPlus/SingleDuct.cc | 1535 +++-- src/EnergyPlus/SingleDuct.hh | 18 +- src/EnergyPlus/SizingAnalysisObjects.cc | 6 +- src/EnergyPlus/SizingManager.cc | 220 +- src/EnergyPlus/SizingManager.hh | 4 + src/EnergyPlus/SolarCollectors.cc | 18 +- src/EnergyPlus/SolarCollectors.hh | 4 + src/EnergyPlus/SolarReflectionManager.cc | 1 - src/EnergyPlus/SolarReflectionManager.hh | 4 + src/EnergyPlus/SolarShading.cc | 129 +- src/EnergyPlus/SolarShading.hh | 4 + src/EnergyPlus/SplitterComponent.hh | 4 + src/EnergyPlus/StandardRatings.cc | 2 +- src/EnergyPlus/SteamBaseboardRadiator.cc | 39 +- src/EnergyPlus/SteamBaseboardRadiator.hh | 9 +- src/EnergyPlus/SteamCoils.cc | 28 +- src/EnergyPlus/SteamCoils.hh | 17 +- src/EnergyPlus/SurfaceGeometry.cc | 2854 +++++---- src/EnergyPlus/SurfaceGeometry.hh | 6 +- src/EnergyPlus/SurfaceGroundHeatExchanger.hh | 4 + src/EnergyPlus/SwimmingPool.cc | 99 +- src/EnergyPlus/SwimmingPool.hh | 28 +- src/EnergyPlus/SystemAvailabilityManager.cc | 504 +- src/EnergyPlus/SystemAvailabilityManager.hh | 44 +- src/EnergyPlus/SystemReports.cc | 1 - src/EnergyPlus/SystemReports.hh | 4 + src/EnergyPlus/TARCOGCommon.hh | 4 + src/EnergyPlus/TARCOGGasses90.hh | 4 + src/EnergyPlus/TARCOGMain.hh | 4 + src/EnergyPlus/TARCOGOutput.hh | 4 + src/EnergyPlus/TarcogShading.cc | 4 +- src/EnergyPlus/TarcogShading.hh | 4 + src/EnergyPlus/ThermalChimney.cc | 27 +- src/EnergyPlus/ThermalChimney.hh | 9 +- src/EnergyPlus/ThermalComfort.cc | 87 +- src/EnergyPlus/ThermalComfort.hh | 4 + src/EnergyPlus/ThermalEN673Calc.cc | 4 +- src/EnergyPlus/ThermalISO15099Calc.cc | 4 +- src/EnergyPlus/ThermalISO15099Calc.hh | 4 + src/EnergyPlus/TranspiredCollector.cc | 51 +- src/EnergyPlus/TranspiredCollector.hh | 12 +- src/EnergyPlus/UFADManager.cc | 4 +- src/EnergyPlus/UFADManager.hh | 4 + src/EnergyPlus/UnitHeater.cc | 75 +- src/EnergyPlus/UnitHeater.hh | 13 +- src/EnergyPlus/UnitVentilator.cc | 154 +- src/EnergyPlus/UnitVentilator.hh | 20 +- src/EnergyPlus/UnitarySystem.cc | 220 +- src/EnergyPlus/UnitarySystem.hh | 16 +- src/EnergyPlus/UserDefinedComponents.hh | 4 + src/EnergyPlus/UtilityRoutines.cc | 118 +- src/EnergyPlus/UtilityRoutines.hh | 50 +- src/EnergyPlus/VariableSpeedCoils.cc | 20 +- src/EnergyPlus/VariableSpeedCoils.hh | 8 +- src/EnergyPlus/Vectors.cc | 4 +- src/EnergyPlus/Vectors.hh | 4 + src/EnergyPlus/VentilatedSlab.cc | 262 +- src/EnergyPlus/VentilatedSlab.hh | 48 +- src/EnergyPlus/WaterCoils.cc | 80 +- src/EnergyPlus/WaterCoils.hh | 19 +- src/EnergyPlus/WaterManager.cc | 163 +- src/EnergyPlus/WaterManager.hh | 4 + src/EnergyPlus/WaterThermalTanks.cc | 657 +-- src/EnergyPlus/WaterThermalTanks.hh | 62 +- src/EnergyPlus/WaterToAirHeatPump.hh | 4 + src/EnergyPlus/WaterToAirHeatPumpSimple.hh | 4 + src/EnergyPlus/WaterUse.cc | 188 +- src/EnergyPlus/WaterUse.hh | 20 +- src/EnergyPlus/WeatherManager.cc | 443 +- src/EnergyPlus/WeatherManager.hh | 27 +- src/EnergyPlus/WindTurbine.cc | 37 +- src/EnergyPlus/WindTurbine.hh | 7 +- src/EnergyPlus/WindowAC.cc | 44 +- src/EnergyPlus/WindowAC.hh | 14 +- src/EnergyPlus/WindowComplexManager.cc | 53 +- src/EnergyPlus/WindowComplexManager.hh | 4 + src/EnergyPlus/WindowEquivalentLayer.cc | 41 +- src/EnergyPlus/WindowEquivalentLayer.hh | 4 + src/EnergyPlus/WindowManager.cc | 24 +- src/EnergyPlus/WindowManager.hh | 4 + src/EnergyPlus/WindowManagerExteriorData.cc | 4 +- src/EnergyPlus/WindowManagerExteriorData.hh | 4 + .../WindowManagerExteriorThermal.cc | 2 +- src/EnergyPlus/ZoneAirLoopEquipmentManager.hh | 4 + .../ZoneContaminantPredictorCorrector.cc | 972 +--- .../ZoneContaminantPredictorCorrector.hh | 4 + src/EnergyPlus/ZoneDehumidifier.cc | 70 +- src/EnergyPlus/ZoneDehumidifier.hh | 6 +- src/EnergyPlus/ZoneEquipmentManager.cc | 293 +- src/EnergyPlus/ZoneEquipmentManager.hh | 4 + src/EnergyPlus/ZonePlenum.hh | 4 + src/EnergyPlus/ZoneTempPredictorCorrector.cc | 4563 +++++++-------- src/EnergyPlus/ZoneTempPredictorCorrector.hh | 47 +- src/EnergyPlus/api/EnergyPlusPgm.cc | 2 +- src/EnergyPlus/api/datatransfer.cc | 116 +- tst/EnergyPlus/unit/AdvancedAFN.unit.cc | 14 +- tst/EnergyPlus/unit/AirLoopHVACDOAS.unit.cc | 31 +- .../unit/AirTerminalSingleDuct.unit.cc | 129 +- ...alSingleDuctConstantVolumeNoReheat.unit.cc | 65 +- .../unit/AirTerminalSingleDuctMixer.unit.cc | 193 +- .../AirTerminalSingleDuctPIUReheat.unit.cc | 13 +- .../unit/AirflowNetworkComponents.unit.cc | 34 +- .../unit/AirflowNetworkConditions.unit.cc | 21 +- .../unit/AirflowNetworkHVAC.unit.cc | 235 +- .../unit/Autosizing/BaseClassSizing.unit.cc | 16 +- .../Autosizing/CoolingAirFlowSizing.unit.cc | 4 +- .../Autosizing/CoolingCapacitySizing.unit.cc | 2 + .../Autosizing/HeatingAirFlowSizing.unit.cc | 4 +- .../Autosizing/HeatingCapacitySizing.unit.cc | 2 + .../Autosizing/SystemAirFlowSizing.unit.cc | 4 +- .../WaterHeatingCoilUASizing.unit.cc | 4 +- tst/EnergyPlus/unit/BaseboardElectric.unit.cc | 2 + tst/EnergyPlus/unit/BaseboardRadiator.unit.cc | 38 +- tst/EnergyPlus/unit/BoilerHotWater.unit.cc | 9 +- tst/EnergyPlus/unit/BoilerSteam.unit.cc | 30 +- .../unit/BranchNodeConnections.unit.cc | 6 +- tst/EnergyPlus/unit/ChillerAbsorption.unit.cc | 11 +- .../unit/ChillerConstantCOP.unit.cc | 13 +- tst/EnergyPlus/unit/ChillerElectric.unit.cc | 16 +- .../unit/ChillerElectricEIR.unit.cc | 25 +- .../unit/ChillerExhaustAbsorption.unit.cc | 9 + .../unit/ChillerGasAbsorption.unit.cc | 7 +- .../unit/ChillerReformulatedEIR.unit.cc | 9 +- .../unit/Coils/CoilCoolingDX.unit.cc | 14 +- ...CoilCoolingDXCurveFitOperatingMode.unit.cc | 4 + .../CoilCoolingDXCurveFitPerformance.unit.cc | 2 + .../unit/CondenserLoopTowers.unit.cc | 159 +- .../unit/ConvectionCoefficients.unit.cc | 42 +- tst/EnergyPlus/unit/CoolTower.unit.cc | 3 + tst/EnergyPlus/unit/DElightManager.unit.cc | 16 +- .../unit/DOASEffectOnZoneSizing.unit.cc | 25 +- tst/EnergyPlus/unit/DXCoils.unit.cc | 119 +- tst/EnergyPlus/unit/DataHeatBalance.unit.cc | 25 +- tst/EnergyPlus/unit/DataSizing.unit.cc | 10 +- tst/EnergyPlus/unit/DataSurfaces.unit.cc | 74 +- tst/EnergyPlus/unit/DataZoneEquipment.unit.cc | 32 +- .../unit/DaylightingManager.unit.cc | 130 +- tst/EnergyPlus/unit/DemandResponse.unit.cc | 15 +- .../unit/DesiccantDehumidifiers.unit.cc | 12 +- tst/EnergyPlus/unit/DualDuct.unit.cc | 46 +- tst/EnergyPlus/unit/EMSManager.unit.cc | 122 +- tst/EnergyPlus/unit/EcoRoofManager.unit.cc | 4 + tst/EnergyPlus/unit/EconomicTariff.unit.cc | 51 +- .../unit/ElectricBaseboardRadiator.unit.cc | 68 +- .../unit/ElectricPowerServiceManager.unit.cc | 175 +- .../unit/EquipAndOperations.unit.cc | 6 +- .../unit/EvaporativeCoolers.unit.cc | 21 +- .../unit/EvaporativeFluidCoolers.unit.cc | 6 +- tst/EnergyPlus/unit/ExhaustSystem.unit.cc | 15 +- tst/EnergyPlus/unit/ExteriorEnergyUse.unit.cc | 14 +- tst/EnergyPlus/unit/FanCoilUnits.unit.cc | 184 +- tst/EnergyPlus/unit/Fans.unit.cc | 12 +- tst/EnergyPlus/unit/FaultsManager.unit.cc | 56 +- ...teDifferenceGroundTemperatureModel.unit.cc | 2 +- .../unit/Fixtures/EnergyPlusFixture.cc | 13 +- tst/EnergyPlus/unit/FluidCoolers.unit.cc | 11 +- tst/EnergyPlus/unit/FluidProperties.unit.cc | 8 +- .../unit/FuelCellElectricGenerator.unit.cc | 17 +- tst/EnergyPlus/unit/Furnaces.unit.cc | 9 +- .../unit/GroundHeatExchangers.unit.cc | 57 +- tst/EnergyPlus/unit/HVACControllers.unit.cc | 22 +- tst/EnergyPlus/unit/HVACCooledBeam.unit.cc | 7 +- .../unit/HVACDXHeatPumpSystem.unit.cc | 2 + tst/EnergyPlus/unit/HVACDXSystem.unit.cc | 37 +- tst/EnergyPlus/unit/HVACFan.unit.cc | 18 + tst/EnergyPlus/unit/HVACFourPipeBeam.unit.cc | 84 +- .../unit/HVACHXAssistedCoolingCoil.unit.cc | 10 +- .../unit/HVACInterfaceManager.unit.cc | 2 +- tst/EnergyPlus/unit/HVACManager.unit.cc | 12 +- .../unit/HVACMultiSpeedHeatPump.unit.cc | 20 +- .../unit/HVACSizingSimulationManager.unit.cc | 48 +- tst/EnergyPlus/unit/HVACStandaloneERV.unit.cc | 17 +- .../unit/HVACUnitaryBypassVAV.unit.cc | 23 +- .../unit/HVACVariableRefrigerantFlow.unit.cc | 258 +- .../unit/HWBaseboardRadiator.unit.cc | 13 +- .../unit/HeatBalFiniteDiffManager.unit.cc | 2 +- .../unit/HeatBalanceAirManager.unit.cc | 23 +- .../unit/HeatBalanceKivaManager.unit.cc | 24 +- .../unit/HeatBalanceManager.unit.cc | 77 +- .../unit/HeatBalanceMovableInsulation.unit.cc | 29 +- .../unit/HeatBalanceSurfaceManager.unit.cc | 290 +- .../unit/HeatPumpWaterToWaterSimple.unit.cc | 10 +- tst/EnergyPlus/unit/HeatRecovery.unit.cc | 19 +- tst/EnergyPlus/unit/HeatingCoils.unit.cc | 13 +- .../unit/HighTempRadiantSystem.unit.cc | 8 +- tst/EnergyPlus/unit/Humidifiers.unit.cc | 24 +- tst/EnergyPlus/unit/HybridModel.unit.cc | 399 +- tst/EnergyPlus/unit/ICSCollector.unit.cc | 2 +- tst/EnergyPlus/unit/IndoorGreen.unit.cc | 15 +- tst/EnergyPlus/unit/InternalHeatGains.unit.cc | 139 +- .../unit/LowTempRadiantSystem.unit.cc | 126 +- tst/EnergyPlus/unit/Material.unit.cc | 11 +- .../unit/MicroCHPElectricGenerator.unit.cc | 2 + tst/EnergyPlus/unit/MixedAir.unit.cc | 208 +- tst/EnergyPlus/unit/OutAirNodeManager.unit.cc | 6 +- tst/EnergyPlus/unit/OutdoorAirUnit.unit.cc | 39 +- tst/EnergyPlus/unit/OutputFiles.unit.cc | 2 + tst/EnergyPlus/unit/OutputProcessor.unit.cc | 164 +- .../unit/OutputReportTabular.unit.cc | 175 +- .../unit/OutputReportTabularAnnual.unit.cc | 21 +- tst/EnergyPlus/unit/OutputReports.unit.cc | 4 +- .../unit/OutsideEnergySources.unit.cc | 2 + tst/EnergyPlus/unit/PVWatts.unit.cc | 10 +- .../unit/PackagedTerminalHeatPump.unit.cc | 109 +- .../PhotovoltaicThermalCollectors.unit.cc | 3 + tst/EnergyPlus/unit/PlantCentralGSHP.unit.cc | 6 +- .../PlantComponentTemperatureSources.unit.cc | 7 +- .../unit/PlantCondLoopOperation.unit.cc | 2 + .../PlantHeatExchangerFluidToFluid.unit.cc | 43 +- tst/EnergyPlus/unit/PlantLoadProfile.unit.cc | 28 +- .../unit/PlantLoopHeatPumpEIR.unit.cc | 115 +- tst/EnergyPlus/unit/PlantManager.unit.cc | 6 +- tst/EnergyPlus/unit/PlantUtilities.unit.cc | 6 +- .../unit/PoweredInductionUnits.unit.cc | 115 +- tst/EnergyPlus/unit/Psychrometrics.unit.cc | 28 +- tst/EnergyPlus/unit/Pumps.unit.cc | 19 + .../unit/PurchasedAirManager.unit.cc | 36 +- tst/EnergyPlus/unit/RefrigeratedCase.unit.cc | 15 +- .../unit/RoomAirflowNetwork.unit.cc | 13 +- tst/EnergyPlus/unit/RunPeriod.unit.cc | 17 +- tst/EnergyPlus/unit/SQLite.unit.cc | 69 +- tst/EnergyPlus/unit/SZVAVModel.unit.cc | 30 +- tst/EnergyPlus/unit/ScheduleManager.unit.cc | 972 ++-- tst/EnergyPlus/unit/SecondaryDXCoils.unit.cc | 8 +- tst/EnergyPlus/unit/SetPointManager.unit.cc | 78 +- .../unit/SimAirServingZones.unit.cc | 24 +- tst/EnergyPlus/unit/SimulationManager.unit.cc | 24 +- tst/EnergyPlus/unit/SingleDuct.unit.cc | 69 +- .../unit/SizeWaterHeatingCoil.unit.cc | 33 +- .../unit/SizingAnalysisObjects.unit.cc | 4 +- tst/EnergyPlus/unit/SizingManager.unit.cc | 16 +- tst/EnergyPlus/unit/SolarShading.unit.cc | 299 +- tst/EnergyPlus/unit/StandardRatings.unit.cc | 71 +- tst/EnergyPlus/unit/SurfaceGeometry.unit.cc | 143 +- .../unit/SystemAvailabilityManager.unit.cc | 109 +- tst/EnergyPlus/unit/ThermalChimney.unit.cc | 6 +- tst/EnergyPlus/unit/ThermalComfort.unit.cc | 72 +- .../unit/TranspiredCollector.unit.cc | 14 +- tst/EnergyPlus/unit/UnitHeater.unit.cc | 18 +- .../unit/UnitaryHybridAirConditioner.unit.cc | 39 +- tst/EnergyPlus/unit/UnitarySystem.unit.cc | 555 +- tst/EnergyPlus/unit/VAVDefMinMaxFlow.unit.cc | 35 +- tst/EnergyPlus/unit/VentilatedSlab.unit.cc | 7 +- tst/EnergyPlus/unit/WaterCoils.unit.cc | 37 +- tst/EnergyPlus/unit/WaterManager.unit.cc | 17 +- tst/EnergyPlus/unit/WaterThermalTanks.unit.cc | 144 +- .../unit/WaterToAirHeatPump.unit.cc | 3 +- .../unit/WaterToAirHeatPumpSimple.unit.cc | 8 +- tst/EnergyPlus/unit/WaterUse.unit.cc | 46 +- tst/EnergyPlus/unit/WeatherManager.unit.cc | 91 +- tst/EnergyPlus/unit/WindTurbine.unit.cc | 1 + tst/EnergyPlus/unit/WindowAC.unit.cc | 7 +- .../unit/WindowEquivalentLayer.unit.cc | 1 - tst/EnergyPlus/unit/WindowManager.unit.cc | 45 +- .../unit/WindowManagerExteriorThermal.unit.cc | 7 +- .../ZoneContaminantPredictorCorrector.unit.cc | 37 +- .../unit/ZoneEquipmentManager.unit.cc | 213 +- .../unit/ZoneHVACEvaporativeCooler.unit.cc | 28 +- .../unit/ZoneTempPredictorCorrector.unit.cc | 394 +- 592 files changed, 22465 insertions(+), 27250 deletions(-) diff --git a/src/EnergyPlus/AirLoopHVACDOAS.cc b/src/EnergyPlus/AirLoopHVACDOAS.cc index b382733e760..29894d377c8 100644 --- a/src/EnergyPlus/AirLoopHVACDOAS.cc +++ b/src/EnergyPlus/AirLoopHVACDOAS.cc @@ -440,7 +440,7 @@ namespace AirLoopHVACDOAS { void AirLoopDOAS::getAirLoopDOASInput(EnergyPlusData &state) { - + constexpr std::string_view routineName = "AirLoopDOAS::getAirLoopDOASInput"; std::string const cCurrentModuleObject = "AirLoopHVAC:DedicatedOutdoorAirSystem"; auto const instances = state.dataInputProcessing->inputProcessor->epJSON.find(cCurrentModuleObject); @@ -457,6 +457,8 @@ namespace AirLoopHVACDOAS { ++AirLoopDOASNum; AirLoopDOAS thisDOAS; + ErrorObjectHeader eoh{routineName, cCurrentModuleObject, thisObjectName}; + thisDOAS.Name = Util::makeUPPER(thisObjectName); // get OA and avail num thisDOAS.OASystemName = Util::makeUPPER(fields.at("airloophvac_outdoorairsystem_name").get()); @@ -758,12 +760,9 @@ namespace AirLoopHVACDOAS { } thisDOAS.AvailManagerSchedName = Util::makeUPPER(fields.at("availability_schedule_name").get()); - thisDOAS.m_AvailManagerSchedPtr = ScheduleManager::GetScheduleIndex(state, thisDOAS.AvailManagerSchedName); - if (thisDOAS.m_AvailManagerSchedPtr == 0) { - cFieldName = "Availability Schedule Name"; - ShowSevereError( - state, - format("{}, \"{}\" {} not found: {}", cCurrentModuleObject, thisDOAS.Name, cFieldName, thisDOAS.AvailManagerSchedName)); + + if ((thisDOAS.m_AvailManagerSched = Sched::GetSchedule(state, thisDOAS.AvailManagerSchedName)) == nullptr) { + ShowSevereItemNotFound(state, eoh, "Availability Schedule Name", thisDOAS.AvailManagerSchedName); errorsFound = true; } @@ -948,7 +947,7 @@ namespace AirLoopHVACDOAS { this->SumMassFlowRate += state.dataLoopNodes->Node(NodeNum).MassFlowRate; } - SchAvailValue = ScheduleManager::GetCurrentScheduleValue(state, this->m_AvailManagerSchedPtr); + SchAvailValue = this->m_AvailManagerSched->getCurrentVal(); if (SchAvailValue < 1.0) { this->SumMassFlowRate = 0.0; } diff --git a/src/EnergyPlus/AirLoopHVACDOAS.hh b/src/EnergyPlus/AirLoopHVACDOAS.hh index bc6130404de..b792206f941 100644 --- a/src/EnergyPlus/AirLoopHVACDOAS.hh +++ b/src/EnergyPlus/AirLoopHVACDOAS.hh @@ -117,7 +117,7 @@ namespace AirLoopHVACDOAS { int m_AirLoopDOASNum = 0; int m_OASystemNum = 0; - int m_AvailManagerSchedPtr = 0; + Sched::Schedule *m_AvailManagerSched = nullptr; int m_AirLoopMixerIndex = -1; int m_AirLoopSplitterIndex = -1; int NumOfAirLoops = 0; @@ -184,6 +184,10 @@ struct AirLoopHVACDOASData : BaseGlobalStruct std::vector airloopMixer; std::vector airloopSplitter; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/AirTerminalUnit.hh b/src/EnergyPlus/AirTerminalUnit.hh index 9574686c6fa..328b29f3f7c 100644 --- a/src/EnergyPlus/AirTerminalUnit.hh +++ b/src/EnergyPlus/AirTerminalUnit.hh @@ -54,6 +54,7 @@ // EnergyPlus Headers #include #include +#include namespace EnergyPlus { @@ -108,7 +109,7 @@ protected: // Data std::string name; // name of unit std::string unitType; // type of unit = e.g. AirTerminal:SingleDuct:ConstantVolume:FourPipeBeam int aDUNum = 0; // index of this unit in the corresponding air distribution unit structure - int airAvailSchedNum = 0; // index to schedule for pimary air availability + Sched::Schedule *airAvailSched = nullptr; // schedule for pimary air availability bool airAvailable = false; // true if primary air is available Real64 vDotDesignPrimAir = 0.0; // Design primary air volume flow rate m3/s (autosizable) bool vDotDesignPrimAirWasAutosized = false; // true if user input for design air flow was autsized on input diff --git a/src/EnergyPlus/AirflowNetwork/include/AirflowNetwork/Elements.hpp b/src/EnergyPlus/AirflowNetwork/include/AirflowNetwork/Elements.hpp index 42679bf6f5f..4a73204ad3c 100644 --- a/src/EnergyPlus/AirflowNetwork/include/AirflowNetwork/Elements.hpp +++ b/src/EnergyPlus/AirflowNetwork/include/AirflowNetwork/Elements.hpp @@ -51,6 +51,7 @@ #include "AirflowNetwork/Properties.hpp" #include #include +#include namespace EnergyPlus { @@ -260,10 +261,10 @@ namespace AirflowNetwork { Real64 UpValueEnth; // Upper Value on Inside/Outside Temperature Difference for // Modulating the Venting Open Factor with Enthalpic control int ZoneNum; // Zone number associated with ZoneName - int VentSchNum; // Zone ventilation schedule number associated with ventilation schedule name + Sched::Schedule *ventSched = nullptr; // Zone ventilation schedule number associated with ventilation schedule name int VentCtrNum; // Ventilation control mode number: 1 "Temperature", 2 "ENTHALPIC", 3 "CONSTANT", 4 "NOVENT" std::string VentingSchName; // Name of ventilation temperature control schedule - int VentingSchNum; // Ventilation schedule number + Sched::Schedule *ventingSched = nullptr; // Ventilation schedule number std::string SingleSidedCpType; // Type of calculation method for single sided wind pressure coefficients Real64 BuildWidth; // The width of the building along the facade that contains this zone. int ASH55PeopleInd; // Index of people object with ASH55 comfort calcs for ventilation control @@ -275,7 +276,7 @@ namespace AirflowNetwork { // Default Constructor MultizoneZoneProp() : VentControl("NoVent"), Height(0.0), OpenFactor(1.0), LowValueTemp(0.0), UpValueTemp(100.0), LowValueEnth(0.0), UpValueEnth(300000.0), - ZoneNum(0), VentSchNum(0), VentCtrNum(VentControlType::None), VentingSchNum(0), SingleSidedCpType("STANDARD"), BuildWidth(10.0), + ZoneNum(0), VentCtrNum(VentControlType::None), SingleSidedCpType("STANDARD"), BuildWidth(10.0), ASH55PeopleInd(0), CEN15251PeopleInd(0), OccupantVentilationControlNum(0), RAFNNodeNum(0) { } @@ -309,9 +310,9 @@ namespace AirflowNetwork { Real64 UpValueEnth; // Upper Value on Inside/Outside Temperature Difference for // Modulating the Venting Open Factor with Enthalpic control std::string VentingSchName; // Name of ventilation temperature control schedule - int VentSchNum; // Zone ventilation schedule number associated with ventilation schedule name + Sched::Schedule *ventSched = nullptr; // Zone ventilation schedule number associated with ventilation schedule name VentControlType VentSurfCtrNum; // Ventilation control mode number: 1 "Temperature", 2 "ENTHALPIC", 3 "CONSTANT", 4 "NOVENT" - int VentingSchNum; // Ventilation schedule number + Sched::Schedule *ventingSched = nullptr; // Ventilation schedule number int ZonePtr; // Pointer to inside face zone bool IndVentControl; // Individual surface venting control int ExtLargeOpeningErrCount; // Exterior large opening error count during HVAC system operation @@ -340,7 +341,7 @@ namespace AirflowNetwork { MultizoneSurfaceProp() : Factor(0.0), SurfNum(0), NodeNums{{0, 0}}, OpenFactor(0.0), OpenFactorLast(0.0), EMSOpenFactorActuated(false), EMSOpenFactor(0.0), Height(0.0), Width(0.0), CHeight(0.0), VentControl("ZONELEVEL"), ModulateFactor(0.0), LowValueTemp(0.0), UpValueTemp(100.0), - LowValueEnth(0.0), UpValueEnth(300000.0), VentSchNum(0), VentSurfCtrNum(VentControlType::None), VentingSchNum(0), ZonePtr(0), + LowValueEnth(0.0), UpValueEnth(300000.0), VentSurfCtrNum(VentControlType::None), ZonePtr(0), IndVentControl(false), ExtLargeOpeningErrCount(0), ExtLargeOpeningErrIndex(0), OpenFactorErrCount(0), OpenFactorErrIndex(0), Multiplier(1.0), HybridVentClose(false), HybridCtrlGlobal(false), HybridCtrlMaster(false), WindModifier(1.0), OccupantVentilationControlNum(0), OpeningStatus(OpenStatus::FreeOperation), PrevOpeningstatus(OpenStatus::FreeOperation), @@ -753,7 +754,7 @@ namespace AirflowNetwork { { // Members Real64 FlowRate; // mass flow rate - int SchedPtr; // Schedule pointer + Sched::Schedule *sched = nullptr; // Schedule pointer Real64 FlowCoef; // Air Mass Flow Coefficient [kg/s at 1Pa] Real64 FlowExpo; // Air Mass Flow exponent [dimensionless] Real64 StandardT; // Standard temperature for crack data @@ -766,7 +767,7 @@ namespace AirflowNetwork { // Default Constructor ZoneExhaustFan() - : FlowRate(0.0), SchedPtr(0), FlowCoef(0.0), FlowExpo(0.0), StandardT(0.0), StandardP(0.0), StandardW(0.0), InletNode(0), OutletNode(0), + : FlowRate(0.0), FlowCoef(0.0), FlowExpo(0.0), StandardT(0.0), StandardP(0.0), StandardW(0.0), InletNode(0), OutletNode(0), EPlusZoneNum(0), PressCtrlNum(0) { } @@ -1397,8 +1398,8 @@ namespace AirflowNetwork { std::string ControlObjectType; // The control type to be used for pressure control std::string ControlObjectName; // Corresponding control type name int ControlTypeSet; // Control type set to be used for pressure control - int AvailSchedPtr; // Availability schedule pointer - int PresSetpointSchedPtr; // Pressure setpoint schedule pointer + Sched::Schedule *availSched = nullptr; // Availability schedule pointer + Sched::Schedule *presSetpointSched = nullptr; // Pressure setpoint schedule pointer int AirLoopNum; // Air loop number int OANodeNum; // outdoor air node number bool bypass; // Can not perform pressure control as true @@ -1406,7 +1407,7 @@ namespace AirflowNetwork { // Default Constructor PressureControllerProp() - : ZoneNum(0), AFNNodeNum(0), ControlTypeSet(0), AvailSchedPtr(0), PresSetpointSchedPtr(0), AirLoopNum(0), OANodeNum(0), bypass(false), + : ZoneNum(0), AFNNodeNum(0), ControlTypeSet(0), AirLoopNum(0), OANodeNum(0), bypass(false), PresCtrlMassRate(0.0) { } @@ -1415,7 +1416,7 @@ namespace AirflowNetwork { struct OutdoorAirFan : public AirflowElement // OA fan component { // Members - int SchedPtr; // Schedule pointer + Sched::Schedule *sched = nullptr; // Schedule pointer Real64 FlowCoef; // Air Mass Flow Coefficient [kg/s at 1Pa] Real64 FlowExpo; // Air Mass Flow exponent [dimensionless] Real64 StandardT; // Standard temperature for crack data [C] @@ -1428,7 +1429,7 @@ namespace AirflowNetwork { // Default Constructor OutdoorAirFan() - : SchedPtr(0), FlowCoef(0.0), FlowExpo(0.0), StandardT(0.0), StandardP(0.0), StandardW(0.0), InletNode(0), OutletNode(0), OAMixerNum(0), + : FlowCoef(0.0), FlowExpo(0.0), StandardT(0.0), StandardP(0.0), StandardW(0.0), InletNode(0), OutletNode(0), OAMixerNum(0), PressCtrlNum(0) { } diff --git a/src/EnergyPlus/AirflowNetwork/include/AirflowNetwork/Solver.hpp b/src/EnergyPlus/AirflowNetwork/include/AirflowNetwork/Solver.hpp index b3f013708e8..50e01ce91a7 100644 --- a/src/EnergyPlus/AirflowNetwork/include/AirflowNetwork/Solver.hpp +++ b/src/EnergyPlus/AirflowNetwork/include/AirflowNetwork/Solver.hpp @@ -136,8 +136,8 @@ namespace AirflowNetwork { std::string ComfortHighTempCurveName; // Thermal Comfort High Temperature Curve Name int ComfortLowTempCurveNum; // Thermal Comfort Low Temperature Curve number int ComfortHighTempCurveNum; // Thermal Comfort high Temperature Curve number - int OpeningProbSchNum; // Opening probability schedule pointer - int ClosingProbSchNum; // Closing probability schedule pointer + Sched::Schedule *openingProbSched = nullptr; // Opening probability schedule pointer + Sched::Schedule *closingProbSched = nullptr; // Closing probability schedule pointer Real64 ComfortBouPoint; // Thermal Comfort Temperature Boundary Point bool OccupancyCheck; // Occupancy check std::string OpeningProbSchName; // Opening probability schedule name @@ -147,8 +147,8 @@ namespace AirflowNetwork { // Default Constructor OccupantVentilationControlProp() - : MinOpeningTime(0.0), MinClosingTime(0.0), ComfortLowTempCurveNum(0), ComfortHighTempCurveNum(0), OpeningProbSchNum(0), - ClosingProbSchNum(0), ComfortBouPoint(10.0), OccupancyCheck(false), MaxPPD(10.0), MinTimeControlOnly(false) + : MinOpeningTime(0.0), MinClosingTime(0.0), ComfortLowTempCurveNum(0), ComfortHighTempCurveNum(0), + ComfortBouPoint(10.0), OccupancyCheck(false), MaxPPD(10.0), MinTimeControlOnly(false) { } @@ -539,6 +539,10 @@ namespace AirflowNetwork { Array1D DisSysCompReliefAirData; Array1D AirflowNetworkLinkageViewFactorData; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/AirflowNetwork/src/Solver.cpp b/src/EnergyPlus/AirflowNetwork/src/Solver.cpp index bafc6e46b22..f7100fba27c 100644 --- a/src/EnergyPlus/AirflowNetwork/src/Solver.cpp +++ b/src/EnergyPlus/AirflowNetwork/src/Solver.cpp @@ -144,8 +144,6 @@ namespace AirflowNetwork { using Psychrometrics::PsyCpAirFnW; using Psychrometrics::PsyHFnTdbW; using Psychrometrics::PsyRhoAirFnPbTdbW; - using ScheduleManager::GetCurrentScheduleValue; - using ScheduleManager::GetScheduleIndex; Solver::Solver(EnergyPlusData &state) : m_state(state), properties(state) { @@ -1879,8 +1877,8 @@ namespace AirflowNetwork { } if (!lAlphaBlanks(5)) { OccupantVentilationControl(i).OpeningProbSchName = Alphas(5); // a schedule name for opening probability - OccupantVentilationControl(i).OpeningProbSchNum = GetScheduleIndex(m_state, OccupantVentilationControl(i).OpeningProbSchName); - if (OccupantVentilationControl(i).OpeningProbSchNum == 0) { + OccupantVentilationControl(i).openingProbSched = Sched::GetSchedule(m_state, OccupantVentilationControl(i).OpeningProbSchName); + if (OccupantVentilationControl(i).openingProbSched == nullptr) { ShowSevereError(m_state, format(RoutineName) + CurrentModuleObject + " object, " + cAlphaFields(5) + " not found = " + OccupantVentilationControl(i).OpeningProbSchName); @@ -1890,8 +1888,8 @@ namespace AirflowNetwork { } if (!lAlphaBlanks(6)) { OccupantVentilationControl(i).ClosingProbSchName = Alphas(6); // a schedule name for closing probability - OccupantVentilationControl(i).ClosingProbSchNum = GetScheduleIndex(m_state, OccupantVentilationControl(i).ClosingProbSchName); - if (OccupantVentilationControl(i).OpeningProbSchNum == 0) { + OccupantVentilationControl(i).closingProbSched = Sched::GetSchedule(m_state, OccupantVentilationControl(i).ClosingProbSchName); + if (OccupantVentilationControl(i).closingProbSched == nullptr) { ShowSevereError(m_state, format(RoutineName) + CurrentModuleObject + " object, " + cAlphaFields(6) + " not found = " + OccupantVentilationControl(i).ClosingProbSchName); @@ -2301,7 +2299,10 @@ namespace AirflowNetwork { lAlphaBlanks, cAlphaFields, cNumericFields); - MultizoneZoneData(i).ZoneName = Alphas(1); // Name of Associated EnergyPlus Thermal Zone + + ErrorObjectHeader eoh{RoutineName, CurrentModuleObject, Alphas(1)}; + + MultizoneZoneData(i).ZoneName = Alphas(1); // Name of Associated EnergyPlus Thermal Zone if (!lAlphaBlanks(2)) MultizoneZoneData(i).VentControl = Alphas(2); // Ventilation Control Mode: "Temperature", "Enthalpy", // "ASHRAE55ADAPTIVE", "CEN15251AdaptiveComfort, // "Constant", or "NoVent" @@ -2343,18 +2344,14 @@ namespace AirflowNetwork { if (MultizoneZoneData(i).VentCtrNum < NumOfVentCtrTypes) { if (NumAlphas >= 4 && (!lAlphaBlanks(4))) { MultizoneZoneData(i).VentingSchName = Alphas(4); - MultizoneZoneData(i).VentingSchNum = GetScheduleIndex(m_state, MultizoneZoneData(i).VentingSchName); - if (MultizoneZoneData(i).VentingSchNum == 0) { - ShowSevereError(m_state, - format(RoutineName) + CurrentModuleObject + " object, " + cAlphaFields(4) + - " not found = " + MultizoneZoneData(i).VentingSchName); - ShowContinueError(m_state, "..for specified " + cAlphaFields(1) + " = " + Alphas(1)); + if ((MultizoneZoneData(i).ventingSched = Sched::GetSchedule(m_state, MultizoneZoneData(i).VentingSchName)) == nullptr) { + ShowSevereItemNotFound(m_state, eoh, cAlphaFields(4), Alphas(4)); ErrorsFound = true; } } } else { MultizoneZoneData(i).VentingSchName = std::string(); - MultizoneZoneData(i).VentingSchNum = 0; + MultizoneZoneData(i).ventingSched = Sched::GetScheduleAlwaysOff(m_state); } } } else { @@ -2368,10 +2365,11 @@ namespace AirflowNetwork { // ==> Zone data validation for (int i = 1; i <= AirflowNetworkNumOfZones; ++i) { // Zone name validation + ErrorObjectHeader eoh{RoutineName, CurrentModuleObject, MultizoneZoneData(i).ZoneName}; + MultizoneZoneData(i).ZoneNum = Util::FindItemInList(MultizoneZoneData(i).ZoneName, Zone); if (MultizoneZoneData(i).ZoneNum == 0) { - ShowSevereError(m_state, format(RoutineName) + CurrentModuleObject + " object, invalid " + cAlphaFields(1) + " given."); - ShowContinueError(m_state, "..invalid " + cAlphaFields(1) + " = \"" + MultizoneZoneData(i).ZoneName + "\""); + ShowSevereItemNotFound(m_state, eoh, "Zone Name", MultizoneZoneData(i).ZoneName); ErrorsFound = true; } else { AirflowNetworkZoneFlag(MultizoneZoneData(i).ZoneNum) = true; @@ -2385,40 +2383,23 @@ namespace AirflowNetwork { ShowContinueError(m_state, ".. in " + cAlphaFields(1) + " = \"" + MultizoneZoneData(i).ZoneName + "\""); ErrorsFound = true; } - if (Util::SameString(MultizoneZoneData(i).VentControl, "Temperature") || Util::SameString(MultizoneZoneData(i).VentControl, "Enthalpy")) { + + if (Util::SameString(MultizoneZoneData(i).VentControl, "Temperature") || + Util::SameString(MultizoneZoneData(i).VentControl, "Enthalpy")) { // Already converted this to an enum, why compare strings? // .or. & // Util::SameString(MultizoneZoneData(i)%VentControl,'ASHRAE55Adaptive') .or. & // Util::SameString(MultizoneZoneData(i)%VentControl,'CEN15251Adaptive')) then - MultizoneZoneData(i).VentSchNum = GetScheduleIndex(m_state, MultizoneZoneData(i).VentSchName); - if (MultizoneZoneData(i).VentSchName == std::string()) { - ShowSevereError(m_state, - format(RoutineName) + CurrentModuleObject + " object, No " + cAlphaFields(3) + - " was found, but is required when " + cAlphaFields(2) + " is Temperature or Enthalpy."); - ShowContinueError(m_state, - "..for " + cAlphaFields(1) + " = \"" + MultizoneZoneData(i).ZoneName + "\", with " + cAlphaFields(2) + " = \"" + - MultizoneZoneData(i).VentControl + "\""); + if (MultizoneZoneData(i).VentSchName.empty()) { + ShowSevereEmptyField(m_state, eoh, cAlphaFields(3), cAlphaFields(2), Alphas(2)); ErrorsFound = true; - } else if (MultizoneZoneData(i).VentSchNum == 0) { - ShowSevereError(m_state, - format(RoutineName) + CurrentModuleObject + " object, invalid " + cAlphaFields(3) + ", required when " + - cAlphaFields(2) + " is Temperature or Enthalpy."); - ShowContinueError(m_state, ".." + cAlphaFields(3) + " in error = " + MultizoneZoneData(i).VentSchName); - ShowContinueError(m_state, - "..for " + cAlphaFields(1) + " = \"" + MultizoneZoneData(i).ZoneName + "\", with " + cAlphaFields(2) + " = \"" + - MultizoneZoneData(i).VentControl + "\""); + } else if ((MultizoneZoneData(i).ventSched = Sched::GetSchedule(m_state, MultizoneZoneData(i).VentSchName)) == nullptr) { + ShowSevereItemNotFound(m_state, eoh, cAlphaFields(3), Alphas(3)); ErrorsFound = true; } } else { - MultizoneZoneData(i).VentSchNum = GetScheduleIndex(m_state, MultizoneZoneData(i).VentSchName); - if (MultizoneZoneData(i).VentSchNum > 0) { - ShowWarningError(m_state, - format(RoutineName) + CurrentModuleObject + " object, " + cAlphaFields(3) + " not required, when " + - cAlphaFields(2) + " is neither Temperature nor Enthalpy."); - ShowContinueError(m_state, ".." + cAlphaFields(3) + " specified = " + MultizoneZoneData(i).VentSchName); - ShowContinueError(m_state, - "..for " + cAlphaFields(1) + " = \"" + MultizoneZoneData(i).ZoneName + "\", with " + cAlphaFields(2) + " = \"" + - MultizoneZoneData(i).VentControl + "\""); - MultizoneZoneData(i).VentSchNum = 0; + MultizoneZoneData(i).ventSched = Sched::GetScheduleAlwaysOff(m_state); + if (!MultizoneZoneData(i).VentSchName.empty()) { + ShowWarningNonEmptyField(m_state, eoh, cAlphaFields(3), cAlphaFields(2), Alphas(2)); MultizoneZoneData(i).VentSchName = std::string(); } } @@ -3190,7 +3171,10 @@ namespace AirflowNetwork { CurrentModuleObject = "AirflowNetwork:MultiZone:Surface"; for (int i = 1; i <= AirflowNetworkNumOfSurfaces; ++i) { if (MultizoneSurfaceData(i).SurfNum == 0) continue; - bool has_Opening{false}; + bool has_Opening{false}; // Why use array constructor? + + ErrorObjectHeader eoh{RoutineName, CurrentModuleObject, MultizoneSurfaceData(i).SurfName}; + // This is terrible, should not do it this way auto afe = elements.find(MultizoneSurfaceData(i).OpeningName); if (afe != elements.end()) { @@ -3215,42 +3199,27 @@ namespace AirflowNetwork { MultizoneSurfaceData(i).VentSurfCtrNum = VentControlType::Const; MultizoneSurfaceData(i).IndVentControl = true; } - if (!MultizoneSurfaceData(i).VentingSchName.empty()) { - MultizoneSurfaceData(i).VentingSchNum = GetScheduleIndex(m_state, MultizoneSurfaceData(i).VentingSchName); - if (MultizoneSurfaceData(i).VentingSchNum == 0) { - ShowSevereError( - m_state, format(RoutineName) + CurrentModuleObject + "=\"" + MultizoneSurfaceData(i).SurfName + "\", invalid schedule."); - ShowContinueError(m_state, "Venting Schedule not found=\"" + MultizoneSurfaceData(i).VentingSchName + "\"."); - ErrorsFound = true; - } else if (m_state.dataSurface->Surface(MultizoneSurfaceData(i).SurfNum).IsAirBoundarySurf) { - ShowWarningError(m_state, - format(RoutineName) + CurrentModuleObject + "=\"" + MultizoneSurfaceData(i).SurfName + - "\" is an air boundary surface."); - ShowContinueError(m_state, "Venting Availability Schedule will be ignored, venting is always available."); - MultizoneSurfaceData(i).VentingSchName = ""; - MultizoneSurfaceData(i).VentingSchNum = 0; - } - } else { + + if (MultizoneSurfaceData(i).VentingSchName.empty()) { + MultizoneSurfaceData(i).ventingSched = Sched::GetScheduleAlwaysOff(m_state); + } else if ((MultizoneSurfaceData(i).ventingSched = Sched::GetSchedule(m_state, MultizoneSurfaceData(i).VentingSchName)) == nullptr) { + ShowSevereItemNotFound(m_state, eoh, "Venting Schedule", MultizoneSurfaceData(i).VentingSchName); + ErrorsFound = true; + } else if (m_state.dataSurface->Surface(MultizoneSurfaceData(i).SurfNum).IsAirBoundarySurf) { + ShowWarningNonEmptyField(m_state, eoh, "Venting Availbility Schedule"); + ShowContinueError(m_state, "Venting is always available for air-boundary surfaces."); + MultizoneSurfaceData(i).ventingSched = Sched::GetScheduleAlwaysOn(m_state); MultizoneSurfaceData(i).VentingSchName = ""; - MultizoneSurfaceData(i).VentingSchNum = 0; } + switch (MultizoneSurfaceData(i).VentSurfCtrNum) { case VentControlType::Temp: case VentControlType::AdjTemp: { - MultizoneSurfaceData(i).VentSchNum = GetScheduleIndex(m_state, MultizoneSurfaceData(i).VentSchName); - if (MultizoneSurfaceData(i).VentSchName == std::string()) { - ShowSevereError(m_state, - format(RoutineName) + CurrentModuleObject + - " object, No Ventilation Schedule was found, but is required when ventilation control is " - "Temperature."); - ShowContinueError(m_state, "..for Surface = \"" + MultizoneSurfaceData(i).SurfName + "\""); + if (MultizoneSurfaceData(i).VentSchName.empty()) { + ShowSevereEmptyField(m_state, eoh, "Ventilation Schedule", "Ventinlation Control", "Temperature"); ErrorsFound = true; - } else if (MultizoneSurfaceData(i).VentSchNum == 0) { - ShowSevereError(m_state, - format(RoutineName) + CurrentModuleObject + - " object, Invalid Ventilation Schedule, required when ventilation control is Temperature."); - ShowContinueError(m_state, "..Schedule name in error = " + MultizoneSurfaceData(i).VentSchName); - ShowContinueError(m_state, "..for Surface = \"" + MultizoneSurfaceData(i).SurfName + "\""); + } else if ((MultizoneSurfaceData(i).ventSched = Sched::GetSchedule(m_state, MultizoneSurfaceData(i).VentSchName)) == nullptr) { + ShowSevereItemNotFound(m_state, eoh, "Ventilation Schedule", MultizoneSurfaceData(i).VentSchName); ErrorsFound = true; } if (MultizoneSurfaceData(i).LowValueTemp < 0.0) { @@ -3278,19 +3247,11 @@ namespace AirflowNetwork { } break; case VentControlType::Enth: case VentControlType::AdjEnth: { - MultizoneSurfaceData(i).VentSchNum = GetScheduleIndex(m_state, MultizoneSurfaceData(i).VentSchName); - if (MultizoneSurfaceData(i).VentSchName == std::string()) { - ShowSevereError(m_state, - format(RoutineName) + CurrentModuleObject + - " object, No Ventilation Schedule was found, but is required when ventilation control is Enthalpy."); - ShowContinueError(m_state, "..for Surface = \"" + MultizoneSurfaceData(i).SurfName + "\""); + if (MultizoneSurfaceData(i).VentSchName.empty()) { + ShowSevereEmptyField(m_state, eoh, "Ventilation Schedule", "Ventilation Control", "Enthalpy"); ErrorsFound = true; - } else if (MultizoneSurfaceData(i).VentSchNum == 0) { - ShowSevereError(m_state, - format(RoutineName) + CurrentModuleObject + - " object, Invalid Ventilation Schedule, required when ventilation control is Enthalpy."); - ShowContinueError(m_state, "..Schedule name in error = " + MultizoneSurfaceData(i).VentSchName); - ShowContinueError(m_state, "..for Surface = \"" + MultizoneSurfaceData(i).SurfName + "\""); + } else if ((MultizoneSurfaceData(i).ventSched = Sched::GetSchedule(m_state, MultizoneSurfaceData(i).VentSchName)) == nullptr) { + ShowSevereItemNotFound(m_state, eoh, "Ventilation Schedule", MultizoneSurfaceData(i).VentSchName); ErrorsFound = true; } if (MultizoneSurfaceData(i).LowValueEnth < 0.0) { @@ -3322,7 +3283,7 @@ namespace AirflowNetwork { case VentControlType::CEN15251: case VentControlType::NoVent: case VentControlType::ZoneLevel: { - MultizoneSurfaceData(i).VentSchNum = 0; + MultizoneSurfaceData(i).ventSched = nullptr; MultizoneSurfaceData(i).VentSchName = ""; } break; default: @@ -4076,6 +4037,9 @@ namespace AirflowNetwork { lAlphaBlanks, cAlphaFields, cNumericFields); + + ErrorObjectHeader eoh{RoutineName, CurrentModuleObject, Alphas(1)}; + PressureControllerData(i).Name = Alphas(1); // Object Name PressureControllerData(i).ZoneName = Alphas(2); // Zone name PressureControllerData(i).ZoneNum = Util::FindItemInList(Alphas(2), Zone); @@ -4138,21 +4102,14 @@ namespace AirflowNetwork { } if (lAlphaBlanks(5)) { - PressureControllerData(i).AvailSchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - PressureControllerData(i).AvailSchedPtr = GetScheduleIndex(m_state, Alphas(5)); - if (PressureControllerData(i).AvailSchedPtr == 0) { - ShowSevereError(m_state, - CurrentModuleObject + ", \"" + PressureControllerData(i).Name + "\" " + cAlphaFields(5) + - " not found: " + Alphas(5)); - ErrorsFound = true; - } + PressureControllerData(i).availSched = Sched::GetScheduleAlwaysOn(m_state); + } else if ((PressureControllerData(i).availSched = Sched::GetSchedule(m_state, Alphas(5))) == nullptr) { + ShowSevereItemNotFound(m_state, eoh, cAlphaFields(5), Alphas(5)); + ErrorsFound = true; } - PressureControllerData(i).PresSetpointSchedPtr = GetScheduleIndex(m_state, Alphas(6)); - if (PressureControllerData(i).PresSetpointSchedPtr == 0) { - ShowSevereError(m_state, - CurrentModuleObject + ", \"" + PressureControllerData(i).Name + "\" " + cAlphaFields(6) + - " not found: " + Alphas(6)); + + if ((PressureControllerData(i).presSetpointSched = Sched::GetSchedule(m_state, Alphas(6))) == nullptr) { + ShowSevereItemNotFound(m_state, eoh, cAlphaFields(6), Alphas(6)); ErrorsFound = true; } } @@ -6501,15 +6458,13 @@ namespace AirflowNetwork { PressureSetFlag = 0; if (NumOfPressureControllers == 1) { - if (PressureControllerData(1).AvailSchedPtr == ScheduleManager::ScheduleAlwaysOn) { + if (PressureControllerData(1).availSched == nullptr) { + PressureSetFlag = PressureControllerData(1).ControlTypeSet; + } else if (PressureControllerData(1).availSched->getCurrentVal() > 0.0) { PressureSetFlag = PressureControllerData(1).ControlTypeSet; - } else { - if (GetCurrentScheduleValue(m_state, PressureControllerData(1).AvailSchedPtr) > 0.0) { - PressureSetFlag = PressureControllerData(1).ControlTypeSet; - } } if (PressureSetFlag > 0) { - PressureSet = GetCurrentScheduleValue(m_state, PressureControllerData(1).PresSetpointSchedPtr); + PressureSet = PressureControllerData(1).presSetpointSched->getCurrentVal(); } } @@ -6939,7 +6894,7 @@ namespace AirflowNetwork { // Wind-pressure coefficients for vertical facades, low-rise building if (Util::SameString(simulation_control.BldgType, "LowRise") && FacadeNum <= 4) { - IncRad = IncAng * Constant::DegToRadians; + IncRad = IncAng * Constant::DegToRad; Real64 const cos_IncRad_over_2(std::cos(IncRad / 2.0)); vals[windDirNum - 1] = 0.6 * std::log(1.248 - 0.703 * std::sin(IncRad / 2.0) - 1.175 * pow_2(std::sin(IncRad)) + 0.131 * pow_3(std::sin(2.0 * IncRad * SideRatioFac)) + 0.769 * cos_IncRad_over_2 + @@ -7015,7 +6970,7 @@ namespace AirflowNetwork { DelAng = mod(IncAng, 10.0); WtAng = 1.0 - DelAng / 10.0; // Wind-pressure coefficients for vertical facades, low-rise building - IncRad = IncAng * Constant::DegToRadians; + IncRad = IncAng * Constant::DegToRad; valsByFacade[FacadeNum - 1][windDirNum - 1] = 0.6 * std::log(1.248 - 0.703 * std::sin(IncRad / 2.0) - 1.175 * pow_2(std::sin(IncRad)) + 0.131 * pow_3(std::sin(2.0 * IncRad * SideRatioFac)) + 0.769 * std::cos(IncRad / 2.0) + @@ -7212,7 +7167,7 @@ namespace AirflowNetwork { Real64 Pr = properties.prandtl_number(Pamb, (Ts + Tamb) / 2, Wamb); Real64 KinVisc = properties.kinematic_viscosity(Pamb, (Ts + Tamb) / 2, Wamb); Real64 Beta = 2.0 / ((Tamb + Constant::Kelvin) + (Ts + Constant::Kelvin)); - Real64 Gr = Constant::GravityConstant * Beta * std::abs(Ts - Tamb) * pow_3(Dh) / pow_2(KinVisc); + Real64 Gr = Constant::Gravity * Beta * std::abs(Ts - Tamb) * pow_3(Dh) / pow_2(KinVisc); Real64 Ra = Gr * Pr; Real64 Nu_free(0); @@ -7505,7 +7460,7 @@ namespace AirflowNetwork { int SurfNum = VFObj.LinkageSurfaceData(j).SurfaceNum; Real64 ZoneSurfaceArea = m_state.dataSurface->Surface(SurfNum).Area; m_state.dataHeatBalFanSys->QRadSurfAFNDuct(SurfNum) += VFObj.LinkageSurfaceData(j).SurfaceRadLoad * TimeStepSys * - Constant::SecInHour / + Constant::rSecsInHour / ZoneSurfaceArea; // Energy to each surface per unit area [J/m2] VFObj.QRad += VFObj.LinkageSurfaceData(j).SurfaceRadLoad; // Total radiant load from all surfaces for this system timestep [W] } @@ -8574,7 +8529,7 @@ namespace AirflowNetwork { onceSurfFlag.dimension(AirflowNetworkNumOfLinks, false); onetime = true; } - ReportingConstant = TimeStepSys * Constant::SecInHour; + ReportingConstant = TimeStepSys * Constant::rSecsInHour; m_state.dataHeatBal->ZoneTotalExfiltrationHeatLoss = 0.0; @@ -9876,9 +9831,6 @@ namespace AirflowNetwork { // Determines the venting opening factor for an exterior or interior window or door // as determined by the venting control method. - // Using/Aliasing - using ScheduleManager::GetCurrentScheduleValue; - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: Real64 VentTemp; // Venting temperature (C) Real64 ZoneAirEnthalpy; // Enthalpy of zone air (J/kg) @@ -9927,10 +9879,10 @@ namespace AirflowNetwork { // Note in the following that individual venting control for a window/door takes // precedence over zone-level control if (MultizoneSurfaceData(i).IndVentControl) { - VentTemp = GetCurrentScheduleValue(m_state, MultizoneSurfaceData(i).VentSchNum); + VentTemp = MultizoneSurfaceData(i).ventSched->getCurrentVal(); VentCtrlNum = MultizoneSurfaceData(i).VentSurfCtrNum; - if (MultizoneSurfaceData(i).VentingSchNum > 0) { - VentingSchVal = GetCurrentScheduleValue(m_state, MultizoneSurfaceData(i).VentingSchNum); + if (MultizoneSurfaceData(i).ventingSched != nullptr) { + VentingSchVal = MultizoneSurfaceData(i).ventingSched->getCurrentVal(); if (VentingSchVal <= 0.0) { VentingAllowed = false; m_state.dataSurface->SurfWinVentingAvailabilityRep(SurfNum) = 0.0; @@ -9938,10 +9890,10 @@ namespace AirflowNetwork { } } else { // Zone level only by Gu on Nov. 8, 2005 - VentTemp = GetCurrentScheduleValue(m_state, MultizoneZoneData(IZ).VentSchNum); + VentTemp = MultizoneZoneData(IZ).ventSched->getCurrentVal(); VentCtrlNum = MultizoneZoneData(IZ).VentCtrNum; - if (MultizoneZoneData(IZ).VentingSchNum > 0) { - VentingSchVal = GetCurrentScheduleValue(m_state, MultizoneZoneData(IZ).VentingSchNum); + if (MultizoneZoneData(IZ).ventingSched != nullptr) { + VentingSchVal = MultizoneZoneData(IZ).ventingSched->getCurrentVal(); if (VentingSchVal <= 0.0) { VentingAllowed = false; m_state.dataSurface->SurfWinVentingAvailabilityRep(SurfNum) = 0.0; @@ -11282,8 +11234,8 @@ namespace AirflowNetwork { auto &hybridVentMgr = m_state.dataAvail->HybridVentData(SysAvailNum); int AirLoopNum = hybridVentMgr.AirLoopNum; ventCtrlStatus = hybridVentMgr.ctrlStatus; - if (hybridVentMgr.ANCtrlStatus > 0) { - ControlType = static_cast(GetCurrentScheduleValue(m_state, hybridVentMgr.ANCtrlStatus)); + if (hybridVentMgr.afnControlTypeSched != nullptr) { + ControlType = static_cast(hybridVentMgr.afnControlTypeSched->getCurrentVal()); } bool Found = false; // Logical to indicate whether a master surface is found or not int ActualZoneNum = 0; @@ -11721,7 +11673,7 @@ namespace AirflowNetwork { Real64 CpAir = PsyCpAirFnW(thisZoneHB.airHumRat); Real64 RhoAir = PsyRhoAirFnPbTdbW(m_state, m_state.dataEnvrn->OutBaroPress, thisZoneHB.MAT, thisZoneHB.airHumRat); - Real64 InfilVolume = ((exchangeData(ZoneNum).SumMCp + exchangeData(ZoneNum).SumMVCp) / CpAir / RhoAir) * TimeStepSys * Constant::SecInHour; + Real64 InfilVolume = ((exchangeData(ZoneNum).SumMCp + exchangeData(ZoneNum).SumMVCp) / CpAir / RhoAir) * TimeStepSys * Constant::rSecsInHour; Real64 ACH = InfilVolume / (TimeStepSys * m_state.dataHeatBal->Zone(ZoneNum).Volume); return ACH; @@ -12849,6 +12801,7 @@ namespace AirflowNetwork { Real64 SchValue; Real64 RandomValue; auto &thisZoneHB = state.dataZoneTempPredictorCorrector->zoneHeatBalance(ZoneNum); + auto &zoneTstatSetpt = state.dataHeatBalFanSys->zoneTstatSetpts(ZoneNum); if (TimeCloseDuration < MinClosingTime) { return false; @@ -12860,32 +12813,35 @@ namespace AirflowNetwork { } switch (state.dataHeatBalFanSys->TempControlType(ZoneNum)) { - case HVAC::ThermostatType::SingleHeating: - if (thisZoneHB.MAT <= state.dataHeatBalFanSys->ZoneThermostatSetPointLo(ZoneNum)) { + case HVAC::SetptType::SingleHeat: { + if (thisZoneHB.MAT <= zoneTstatSetpt.setptLo) { return false; } - break; - case HVAC::ThermostatType::SingleCooling: - if (thisZoneHB.MAT >= state.dataHeatBalFanSys->ZoneThermostatSetPointHi(ZoneNum)) { + } break; + + case HVAC::SetptType::SingleCool: { + if (thisZoneHB.MAT >= zoneTstatSetpt.setptHi) { return false; } - break; - case HVAC::ThermostatType::SingleHeatCool: + } break; + case HVAC::SetptType::SingleHeatCool: { return false; - case HVAC::ThermostatType::DualSetPointWithDeadBand: - if (thisZoneHB.MAT < state.dataHeatBalFanSys->ZoneThermostatSetPointLo(ZoneNum) || - thisZoneHB.MAT > state.dataHeatBalFanSys->ZoneThermostatSetPointHi(ZoneNum)) { + } break; + + case HVAC::SetptType::DualHeatCool: { + if (thisZoneHB.MAT < zoneTstatSetpt.setptLo || thisZoneHB.MAT > zoneTstatSetpt.setptHi) { return false; } - break; - default: - break; - } + } break; + + default: { + } break; + } // switch - if (OpeningProbSchNum == 0) { + if (openingProbSched == nullptr) { return true; } else { - SchValue = GetCurrentScheduleValue(state, OpeningProbSchNum); + SchValue = openingProbSched->getCurrentVal(); RandomValue = Real64(rand()) / RAND_MAX; if (SchValue > RandomValue) { return true; @@ -12904,10 +12860,10 @@ namespace AirflowNetwork { if (TimeOpenDuration < MinOpeningTime) { return false; } - if (ClosingProbSchNum == 0) { + if (closingProbSched == nullptr) { return true; } else { - SchValue = GetCurrentScheduleValue(state, ClosingProbSchNum); + SchValue = closingProbSched->getCurrentVal(); RandomValue = Real64(rand()) / RAND_MAX; if (SchValue > RandomValue) { return true; @@ -13399,7 +13355,7 @@ namespace AirflowNetwork { // na auto &NetworkNumOfNodes = ActualNumOfNodes; - auto &NetworkNumOfLinks = ActualNumOfLinks; + // auto &NetworkNumOfLinks = ActualNumOfLinks; // Argument array dimensioning (these used to be arguments, need to also test newAU and newIK) EP_SIZE_CHECK(IK, NetworkNumOfNodes + 1); diff --git a/src/EnergyPlus/Autosizing/BaseSizerWithFanHeatInputs.hh b/src/EnergyPlus/Autosizing/BaseSizerWithFanHeatInputs.hh index 0d5ba3bebe7..a37632a2b77 100644 --- a/src/EnergyPlus/Autosizing/BaseSizerWithFanHeatInputs.hh +++ b/src/EnergyPlus/Autosizing/BaseSizerWithFanHeatInputs.hh @@ -106,6 +106,10 @@ struct BaseSizerWithFanHeatInputs : BaseSizer struct BaseSizerWithFanHeatInputsData : BaseGlobalStruct { + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/Autosizing/BaseSizerWithScalableInputs.hh b/src/EnergyPlus/Autosizing/BaseSizerWithScalableInputs.hh index 60f04c8bb3a..3d169f82259 100644 --- a/src/EnergyPlus/Autosizing/BaseSizerWithScalableInputs.hh +++ b/src/EnergyPlus/Autosizing/BaseSizerWithScalableInputs.hh @@ -136,6 +136,10 @@ struct BaseSizerWithScalableInputs : BaseSizerWithFanHeatInputs struct BaseSizerWithScalableInputsData : BaseGlobalStruct { + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/Autosizing/SystemAirFlowSizing.hh b/src/EnergyPlus/Autosizing/SystemAirFlowSizing.hh index b27c61667e2..890480f8558 100644 --- a/src/EnergyPlus/Autosizing/SystemAirFlowSizing.hh +++ b/src/EnergyPlus/Autosizing/SystemAirFlowSizing.hh @@ -73,6 +73,10 @@ struct SystemAirFlowSizer : BaseSizerWithScalableInputs struct SystemAirFlowSizerData : BaseGlobalStruct { + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/BaseboardElectric.cc b/src/EnergyPlus/BaseboardElectric.cc index e6b1b408712..aee131672ed 100644 --- a/src/EnergyPlus/BaseboardElectric.cc +++ b/src/EnergyPlus/BaseboardElectric.cc @@ -76,11 +76,8 @@ namespace BaseboardElectric { // DATE WRITTEN Nov 2001 // RE-ENGINEERED na - // Use statements for access to subroutines in other modules - using namespace ScheduleManager; - // MODULE PARAMETER DEFINITIONS - const char *cCMO_BBRadiator_Electric = "ZoneHVAC:Baseboard:Convective:Electric"; + constexpr std::string_view cCMO_BBRadiator_Electric = "ZoneHVAC:Baseboard:Convective:Electric"; constexpr Real64 SimpConvAirFlowSpeed(0.5); // m/s void SimElectricBaseboard(EnergyPlusData &state, std::string const &EquipName, int const ControlledZoneNum, Real64 &PowerMet, int &CompIndex) @@ -171,12 +168,15 @@ namespace BaseboardElectric { // SUBROUTINE PARAMETER DEFINITIONS: static constexpr std::string_view RoutineName("GetBaseboardInput: "); // include trailing blank space + static constexpr std::string_view routineName = "GetBaseboardInput"; int constexpr iHeatCAPMAlphaNum(3); // get input index to baseboard heating capacity sizing method int constexpr iHeatDesignCapacityNumericNum(1); // get input index to baseboard heating capacity int constexpr iHeatCapacityPerFloorAreaNumericNum(2); // get input index to baseboard heating capacity per floor area sizing int constexpr iHeatFracOfAutosizedCapacityNumericNum( 3); // get input index to baseboard heating capacity sizing as fraction of autosized heating capacity + auto &s_ipsc = state.dataIPShortCut; + auto &baseboard = state.dataBaseboardElectric; std::string_view cCurrentModuleObject = cCMO_BBRadiator_Electric; @@ -195,137 +195,129 @@ namespace BaseboardElectric { state.dataInputProcessing->inputProcessor->getObjectItem(state, cCurrentModuleObject, ConvElecBBNum, - state.dataIPShortCut->cAlphaArgs, + s_ipsc->cAlphaArgs, NumAlphas, - state.dataIPShortCut->rNumericArgs, + s_ipsc->rNumericArgs, NumNums, IOStat, - state.dataIPShortCut->lNumericFieldBlanks, - state.dataIPShortCut->lAlphaFieldBlanks, - state.dataIPShortCut->cAlphaFieldNames, - state.dataIPShortCut->cNumericFieldNames); + s_ipsc->lNumericFieldBlanks, + s_ipsc->lAlphaFieldBlanks, + s_ipsc->cAlphaFieldNames, + s_ipsc->cNumericFieldNames); baseboard->baseboards(ConvElecBBNum).FieldNames.allocate(NumNums); baseboard->baseboards(ConvElecBBNum).FieldNames = ""; - baseboard->baseboards(ConvElecBBNum).FieldNames = state.dataIPShortCut->cNumericFieldNames; + baseboard->baseboards(ConvElecBBNum).FieldNames = s_ipsc->cNumericFieldNames; + ErrorObjectHeader eoh{routineName, cCurrentModuleObject, s_ipsc->cAlphaArgs(1)}; + // ErrorsFound will be set to True if problem was found, left untouched otherwise VerifyUniqueBaseboardName( - state, cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1), ErrorsFound, format("{} Name", cCurrentModuleObject)); + state, cCurrentModuleObject, s_ipsc->cAlphaArgs(1), ErrorsFound, format("{} Name", cCurrentModuleObject)); ++BaseboardNum; auto &thisBaseboard = baseboard->baseboards(BaseboardNum); - thisBaseboard.EquipName = state.dataIPShortCut->cAlphaArgs(1); // name of this baseboard + thisBaseboard.EquipName = s_ipsc->cAlphaArgs(1); // name of this baseboard thisBaseboard.EquipType = Util::makeUPPER(cCurrentModuleObject); // the type of baseboard-rename change - thisBaseboard.Schedule = state.dataIPShortCut->cAlphaArgs(2); - if (state.dataIPShortCut->lAlphaFieldBlanks(2)) { - thisBaseboard.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - thisBaseboard.SchedPtr = GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(2)); - if (thisBaseboard.SchedPtr == 0) { - ShowSevereError(state, - format("{}{}: invalid {} entered ={} for {}= {}", - RoutineName, - cCurrentModuleObject, - state.dataIPShortCut->cAlphaFieldNames(2), - state.dataIPShortCut->cAlphaArgs(2), - state.dataIPShortCut->cAlphaFieldNames(1), - state.dataIPShortCut->cAlphaArgs(1))); - ErrorsFound = true; - } + thisBaseboard.Schedule = s_ipsc->cAlphaArgs(2); + if (s_ipsc->lAlphaFieldBlanks(2)) { + thisBaseboard.sched = Sched::GetScheduleAlwaysOn(state); + } else if ((thisBaseboard.sched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2)); + ErrorsFound = true; } // get inlet node number - thisBaseboard.BaseboardEfficiency = state.dataIPShortCut->rNumericArgs(4); + thisBaseboard.BaseboardEfficiency = s_ipsc->rNumericArgs(4); // Determine baseboard electric heating design capacity sizing method - if (Util::SameString(state.dataIPShortCut->cAlphaArgs(iHeatCAPMAlphaNum), "HeatingDesignCapacity")) { + if (Util::SameString(s_ipsc->cAlphaArgs(iHeatCAPMAlphaNum), "HeatingDesignCapacity")) { thisBaseboard.HeatingCapMethod = HeatingDesignCapacity; - if (!state.dataIPShortCut->lNumericFieldBlanks(iHeatDesignCapacityNumericNum)) { - thisBaseboard.ScaledHeatingCapacity = state.dataIPShortCut->rNumericArgs(iHeatDesignCapacityNumericNum); + if (!s_ipsc->lNumericFieldBlanks(iHeatDesignCapacityNumericNum)) { + thisBaseboard.ScaledHeatingCapacity = s_ipsc->rNumericArgs(iHeatDesignCapacityNumericNum); if (thisBaseboard.ScaledHeatingCapacity < 0.0 && thisBaseboard.ScaledHeatingCapacity != AutoSize) { ShowSevereError(state, format("{} = {}", cCurrentModuleObject, thisBaseboard.EquipName)); ShowContinueError(state, format("Illegal {} = {:.7T}", - state.dataIPShortCut->cNumericFieldNames(iHeatDesignCapacityNumericNum), - state.dataIPShortCut->rNumericArgs(iHeatDesignCapacityNumericNum))); + s_ipsc->cNumericFieldNames(iHeatDesignCapacityNumericNum), + s_ipsc->rNumericArgs(iHeatDesignCapacityNumericNum))); ErrorsFound = true; } } else { ShowSevereError(state, format("{} = {}", cCurrentModuleObject, thisBaseboard.EquipName)); ShowContinueError(state, format("Input for {} = {}", - state.dataIPShortCut->cAlphaFieldNames(iHeatCAPMAlphaNum), - state.dataIPShortCut->cAlphaArgs(iHeatCAPMAlphaNum))); + s_ipsc->cAlphaFieldNames(iHeatCAPMAlphaNum), + s_ipsc->cAlphaArgs(iHeatCAPMAlphaNum))); ShowContinueError( - state, format("Blank field not allowed for {}", state.dataIPShortCut->cNumericFieldNames(iHeatDesignCapacityNumericNum))); + state, format("Blank field not allowed for {}", s_ipsc->cNumericFieldNames(iHeatDesignCapacityNumericNum))); ErrorsFound = true; } - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(iHeatCAPMAlphaNum), "CapacityPerFloorArea")) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(iHeatCAPMAlphaNum), "CapacityPerFloorArea")) { thisBaseboard.HeatingCapMethod = CapacityPerFloorArea; - if (!state.dataIPShortCut->lNumericFieldBlanks(iHeatCapacityPerFloorAreaNumericNum)) { - thisBaseboard.ScaledHeatingCapacity = state.dataIPShortCut->rNumericArgs(iHeatCapacityPerFloorAreaNumericNum); + if (!s_ipsc->lNumericFieldBlanks(iHeatCapacityPerFloorAreaNumericNum)) { + thisBaseboard.ScaledHeatingCapacity = s_ipsc->rNumericArgs(iHeatCapacityPerFloorAreaNumericNum); if (thisBaseboard.ScaledHeatingCapacity <= 0.0) { ShowSevereError(state, format("{} = {}", cCurrentModuleObject, thisBaseboard.EquipName)); ShowContinueError(state, format("Input for {} = {}", - state.dataIPShortCut->cAlphaFieldNames(iHeatCAPMAlphaNum), - state.dataIPShortCut->cAlphaArgs(iHeatCAPMAlphaNum))); + s_ipsc->cAlphaFieldNames(iHeatCAPMAlphaNum), + s_ipsc->cAlphaArgs(iHeatCAPMAlphaNum))); ShowContinueError(state, format("Illegal {} = {:.7T}", - state.dataIPShortCut->cNumericFieldNames(iHeatCapacityPerFloorAreaNumericNum), - state.dataIPShortCut->rNumericArgs(iHeatCapacityPerFloorAreaNumericNum))); + s_ipsc->cNumericFieldNames(iHeatCapacityPerFloorAreaNumericNum), + s_ipsc->rNumericArgs(iHeatCapacityPerFloorAreaNumericNum))); ErrorsFound = true; } else if (thisBaseboard.ScaledHeatingCapacity == AutoSize) { ShowSevereError(state, format("{} = {}", cCurrentModuleObject, thisBaseboard.EquipName)); ShowContinueError(state, format("Input for {} = {}", - state.dataIPShortCut->cAlphaFieldNames(iHeatCAPMAlphaNum), - state.dataIPShortCut->cAlphaArgs(iHeatCAPMAlphaNum))); + s_ipsc->cAlphaFieldNames(iHeatCAPMAlphaNum), + s_ipsc->cAlphaArgs(iHeatCAPMAlphaNum))); ShowContinueError( state, - format("Illegal {} = AutoSize", state.dataIPShortCut->cNumericFieldNames(iHeatCapacityPerFloorAreaNumericNum))); + format("Illegal {} = AutoSize", s_ipsc->cNumericFieldNames(iHeatCapacityPerFloorAreaNumericNum))); ErrorsFound = true; } } else { ShowSevereError(state, format("{} = {}", cCurrentModuleObject, thisBaseboard.EquipName)); ShowContinueError(state, format("Input for {} = {}", - state.dataIPShortCut->cAlphaFieldNames(iHeatCAPMAlphaNum), - state.dataIPShortCut->cAlphaArgs(iHeatCAPMAlphaNum))); + s_ipsc->cAlphaFieldNames(iHeatCAPMAlphaNum), + s_ipsc->cAlphaArgs(iHeatCAPMAlphaNum))); ShowContinueError( state, - format("Blank field not allowed for {}", state.dataIPShortCut->cNumericFieldNames(iHeatCapacityPerFloorAreaNumericNum))); + format("Blank field not allowed for {}", s_ipsc->cNumericFieldNames(iHeatCapacityPerFloorAreaNumericNum))); ErrorsFound = true; } - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(iHeatCAPMAlphaNum), "FractionOfAutosizedHeatingCapacity")) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(iHeatCAPMAlphaNum), "FractionOfAutosizedHeatingCapacity")) { thisBaseboard.HeatingCapMethod = FractionOfAutosizedHeatingCapacity; - if (!state.dataIPShortCut->lNumericFieldBlanks(iHeatFracOfAutosizedCapacityNumericNum)) { - thisBaseboard.ScaledHeatingCapacity = state.dataIPShortCut->rNumericArgs(iHeatFracOfAutosizedCapacityNumericNum); + if (!s_ipsc->lNumericFieldBlanks(iHeatFracOfAutosizedCapacityNumericNum)) { + thisBaseboard.ScaledHeatingCapacity = s_ipsc->rNumericArgs(iHeatFracOfAutosizedCapacityNumericNum); if (thisBaseboard.ScaledHeatingCapacity < 0.0) { ShowSevereError(state, format("{} = {}", cCurrentModuleObject, thisBaseboard.EquipName)); ShowContinueError(state, format("Illegal {} = {:.7T}", - state.dataIPShortCut->cNumericFieldNames(iHeatFracOfAutosizedCapacityNumericNum), - state.dataIPShortCut->rNumericArgs(iHeatFracOfAutosizedCapacityNumericNum))); + s_ipsc->cNumericFieldNames(iHeatFracOfAutosizedCapacityNumericNum), + s_ipsc->rNumericArgs(iHeatFracOfAutosizedCapacityNumericNum))); ErrorsFound = true; } } else { ShowSevereError(state, format("{} = {}", cCurrentModuleObject, thisBaseboard.EquipName)); ShowContinueError(state, format("Input for {} = {}", - state.dataIPShortCut->cAlphaFieldNames(iHeatCAPMAlphaNum), - state.dataIPShortCut->cAlphaArgs(iHeatCAPMAlphaNum))); + s_ipsc->cAlphaFieldNames(iHeatCAPMAlphaNum), + s_ipsc->cAlphaArgs(iHeatCAPMAlphaNum))); ShowContinueError(state, format("Blank field not allowed for {}", - state.dataIPShortCut->cNumericFieldNames(iHeatFracOfAutosizedCapacityNumericNum))); + s_ipsc->cNumericFieldNames(iHeatFracOfAutosizedCapacityNumericNum))); ErrorsFound = true; } } else { ShowSevereError(state, format("{} = {}", cCurrentModuleObject, thisBaseboard.EquipName)); ShowContinueError(state, format("Illegal {} = {}", - state.dataIPShortCut->cAlphaFieldNames(iHeatCAPMAlphaNum), - state.dataIPShortCut->cAlphaArgs(iHeatCAPMAlphaNum))); + s_ipsc->cAlphaFieldNames(iHeatCAPMAlphaNum), + s_ipsc->cAlphaArgs(iHeatCAPMAlphaNum))); ErrorsFound = true; } @@ -515,7 +507,7 @@ namespace BaseboardElectric { // thermal loss that could be accounted for with this efficiency input. Real64 Effic = baseboard.BaseboardEfficiency; - if (GetCurrentScheduleValue(state, baseboard.SchedPtr) > 0.0 && LoadMet >= HVAC::SmallLoad) { + if (baseboard.sched->getCurrentVal() > 0.0 && LoadMet >= HVAC::SmallLoad) { // if the load exceeds the capacity than the capacity is set to the BB limit. if (LoadMet > baseboard.NominalCapacity) { diff --git a/src/EnergyPlus/BaseboardElectric.hh b/src/EnergyPlus/BaseboardElectric.hh index 0c1491f6def..a76586c6eff 100644 --- a/src/EnergyPlus/BaseboardElectric.hh +++ b/src/EnergyPlus/BaseboardElectric.hh @@ -56,6 +56,8 @@ #include #include #include +#include + namespace EnergyPlus { @@ -69,7 +71,7 @@ namespace BaseboardElectric { std::string EquipName; std::string EquipType; std::string Schedule; - int SchedPtr = 0; + Sched::Schedule *sched = nullptr; Real64 NominalCapacity = 0.0; Real64 BaseboardEfficiency = 0.0; Real64 AirInletTemp = 0.0; @@ -105,6 +107,10 @@ struct BaseboardElectricData : BaseGlobalStruct bool getInputFlag = true; EPVector baseboards; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/BaseboardRadiator.cc b/src/EnergyPlus/BaseboardRadiator.cc index 62ee9c5446a..a61d790461f 100644 --- a/src/EnergyPlus/BaseboardRadiator.cc +++ b/src/EnergyPlus/BaseboardRadiator.cc @@ -94,7 +94,6 @@ namespace BaseboardRadiator { using HVAC::SmallLoad; // Use statements for access to subroutines in other modules - using namespace ScheduleManager; using FluidProperties::GetDensityGlycol; using FluidProperties::GetSpecificHeatGlycol; using Psychrometrics::PsyCpAirFnW; @@ -226,16 +225,17 @@ namespace BaseboardRadiator { // SUBROUTINE PARAMETER DEFINITIONS: static constexpr std::string_view RoutineName = "GetBaseboardInput: "; // include trailing blank space + static constexpr std::string_view routineName = "GetBaseboardInput"; int constexpr iHeatCAPMAlphaNum = 5; // get input index to water baseboard Radiator system heating capacity sizing method int constexpr iHeatDesignCapacityNumericNum = 1; // get input index to water baseboard Radiator system electric heating capacity int constexpr iHeatCapacityPerFloorAreaNumericNum = 2; // index to baseboard Radiator system electric heating capacity per floor area sizing int constexpr iHeatFracOfAutosizedCapacityNumericNum = 3; // index to baseboard heating capacity fraction of autosized heating capacity - auto &cCurrentModuleObject = state.dataIPShortCut->cCurrentModuleObject; + auto &s_ipsc = state.dataIPShortCut; - cCurrentModuleObject = cCMO_BBRadiator_Water; + s_ipsc->cCurrentModuleObject = cCMO_BBRadiator_Water; - int NumConvHWBaseboards = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); + int NumConvHWBaseboards = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, s_ipsc->cCurrentModuleObject); // Calculate total number of baseboard units @@ -249,61 +249,53 @@ namespace BaseboardRadiator { int IOStat = 0; state.dataInputProcessing->inputProcessor->getObjectItem(state, - cCurrentModuleObject, + s_ipsc->cCurrentModuleObject, ConvHWBaseboardNum, - state.dataIPShortCut->cAlphaArgs, + s_ipsc->cAlphaArgs, NumAlphas, - state.dataIPShortCut->rNumericArgs, + s_ipsc->rNumericArgs, NumNums, IOStat, - state.dataIPShortCut->lNumericFieldBlanks, - state.dataIPShortCut->lAlphaFieldBlanks, - state.dataIPShortCut->cAlphaFieldNames, - state.dataIPShortCut->cNumericFieldNames); + s_ipsc->lNumericFieldBlanks, + s_ipsc->lAlphaFieldBlanks, + s_ipsc->cAlphaFieldNames, + s_ipsc->cNumericFieldNames); + ErrorObjectHeader eoh{routineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)}; + auto &thisBaseboard = state.dataBaseboardRadiator->baseboards(ConvHWBaseboardNum); thisBaseboard.FieldNames.allocate(NumNums); - thisBaseboard.FieldNames = state.dataIPShortCut->cNumericFieldNames; + thisBaseboard.FieldNames = s_ipsc->cNumericFieldNames; // ErrorsFound will be set to True if problem was found, left untouched otherwise VerifyUniqueBaseboardName( - state, cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1), ErrorsFound, cCurrentModuleObject + " Name"); + state, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1), ErrorsFound, s_ipsc->cCurrentModuleObject + " Name"); - thisBaseboard.EquipID = state.dataIPShortCut->cAlphaArgs(1); // name of this baseboard + thisBaseboard.EquipID = s_ipsc->cAlphaArgs(1); // name of this baseboard thisBaseboard.EquipType = DataPlant::PlantEquipmentType::Baseboard_Conv_Water; - thisBaseboard.Schedule = state.dataIPShortCut->cAlphaArgs(2); - if (state.dataIPShortCut->lAlphaFieldBlanks(2)) { - thisBaseboard.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - thisBaseboard.SchedPtr = GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(2)); - if (thisBaseboard.SchedPtr == 0) { - ShowSevereError(state, - format("{}{}: invalid {} entered ={} for {}={}", - RoutineName, - cCurrentModuleObject, - state.dataIPShortCut->cAlphaFieldNames(2), - state.dataIPShortCut->cAlphaArgs(2), - state.dataIPShortCut->cAlphaFieldNames(1), - state.dataIPShortCut->cAlphaArgs(1))); - ErrorsFound = true; - } + thisBaseboard.Schedule = s_ipsc->cAlphaArgs(2); + if (s_ipsc->lAlphaFieldBlanks(2)) { + thisBaseboard.sched = Sched::GetScheduleAlwaysOn(state); + } else if ((thisBaseboard.sched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2)); + ErrorsFound = true; } // get inlet node number thisBaseboard.WaterInletNode = GetOnlySingleNode(state, - state.dataIPShortCut->cAlphaArgs(3), + s_ipsc->cAlphaArgs(3), ErrorsFound, DataLoopNode::ConnectionObjectType::ZoneHVACBaseboardConvectiveWater, - state.dataIPShortCut->cAlphaArgs(1), + s_ipsc->cAlphaArgs(1), DataLoopNode::NodeFluidType::Water, DataLoopNode::ConnectionType::Inlet, NodeInputManager::CompFluidStream::Primary, ObjectIsNotParent); // get outlet node number thisBaseboard.WaterOutletNode = GetOnlySingleNode(state, - state.dataIPShortCut->cAlphaArgs(4), + s_ipsc->cAlphaArgs(4), ErrorsFound, DataLoopNode::ConnectionObjectType::ZoneHVACBaseboardConvectiveWater, - state.dataIPShortCut->cAlphaArgs(1), + s_ipsc->cAlphaArgs(1), DataLoopNode::NodeFluidType::Water, DataLoopNode::ConnectionType::Outlet, NodeInputManager::CompFluidStream::Primary, @@ -311,106 +303,106 @@ namespace BaseboardRadiator { TestCompSet(state, cCMO_BBRadiator_Water, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaArgs(3), - state.dataIPShortCut->cAlphaArgs(4), + s_ipsc->cAlphaArgs(1), + s_ipsc->cAlphaArgs(3), + s_ipsc->cAlphaArgs(4), "Hot Water Nodes"); // Determine steam baseboard radiator system heating design capacity sizing method - if (Util::SameString(state.dataIPShortCut->cAlphaArgs(iHeatCAPMAlphaNum), "HeatingDesignCapacity")) { + if (Util::SameString(s_ipsc->cAlphaArgs(iHeatCAPMAlphaNum), "HeatingDesignCapacity")) { thisBaseboard.HeatingCapMethod = HeatingDesignCapacity; - if (!state.dataIPShortCut->lNumericFieldBlanks(iHeatDesignCapacityNumericNum)) { - thisBaseboard.ScaledHeatingCapacity = state.dataIPShortCut->rNumericArgs(iHeatDesignCapacityNumericNum); + if (!s_ipsc->lNumericFieldBlanks(iHeatDesignCapacityNumericNum)) { + thisBaseboard.ScaledHeatingCapacity = s_ipsc->rNumericArgs(iHeatDesignCapacityNumericNum); if (thisBaseboard.ScaledHeatingCapacity < 0.0 && thisBaseboard.ScaledHeatingCapacity != AutoSize) { ShowSevereError(state, format("{} = {}", cCMO_BBRadiator_Water, thisBaseboard.EquipID)); ShowContinueError(state, format("Illegal {} = {:.7T}", - state.dataIPShortCut->cNumericFieldNames(iHeatDesignCapacityNumericNum), - state.dataIPShortCut->rNumericArgs(iHeatDesignCapacityNumericNum))); + s_ipsc->cNumericFieldNames(iHeatDesignCapacityNumericNum), + s_ipsc->rNumericArgs(iHeatDesignCapacityNumericNum))); ErrorsFound = true; } } else { ShowSevereError(state, format("{} = {}", cCMO_BBRadiator_Water, thisBaseboard.EquipID)); ShowContinueError(state, format("Input for {} = {}", - state.dataIPShortCut->cAlphaFieldNames(iHeatCAPMAlphaNum), - state.dataIPShortCut->cAlphaArgs(iHeatCAPMAlphaNum))); + s_ipsc->cAlphaFieldNames(iHeatCAPMAlphaNum), + s_ipsc->cAlphaArgs(iHeatCAPMAlphaNum))); ShowContinueError( - state, format("Blank field not allowed for {}", state.dataIPShortCut->cNumericFieldNames(iHeatDesignCapacityNumericNum))); + state, format("Blank field not allowed for {}", s_ipsc->cNumericFieldNames(iHeatDesignCapacityNumericNum))); ErrorsFound = true; } - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(iHeatCAPMAlphaNum), "CapacityPerFloorArea")) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(iHeatCAPMAlphaNum), "CapacityPerFloorArea")) { thisBaseboard.HeatingCapMethod = CapacityPerFloorArea; - if (!state.dataIPShortCut->lNumericFieldBlanks(iHeatCapacityPerFloorAreaNumericNum)) { - thisBaseboard.ScaledHeatingCapacity = state.dataIPShortCut->rNumericArgs(iHeatCapacityPerFloorAreaNumericNum); + if (!s_ipsc->lNumericFieldBlanks(iHeatCapacityPerFloorAreaNumericNum)) { + thisBaseboard.ScaledHeatingCapacity = s_ipsc->rNumericArgs(iHeatCapacityPerFloorAreaNumericNum); if (thisBaseboard.ScaledHeatingCapacity <= 0.0) { ShowSevereError(state, format("{} = {}", cCMO_BBRadiator_Water, thisBaseboard.EquipID)); ShowContinueError(state, format("Input for {} = {}", - state.dataIPShortCut->cAlphaFieldNames(iHeatCAPMAlphaNum), - state.dataIPShortCut->cAlphaArgs(iHeatCAPMAlphaNum))); + s_ipsc->cAlphaFieldNames(iHeatCAPMAlphaNum), + s_ipsc->cAlphaArgs(iHeatCAPMAlphaNum))); ShowContinueError(state, format("Illegal {} = {:.7T}", - state.dataIPShortCut->cNumericFieldNames(iHeatCapacityPerFloorAreaNumericNum), - state.dataIPShortCut->rNumericArgs(iHeatCapacityPerFloorAreaNumericNum))); + s_ipsc->cNumericFieldNames(iHeatCapacityPerFloorAreaNumericNum), + s_ipsc->rNumericArgs(iHeatCapacityPerFloorAreaNumericNum))); ErrorsFound = true; } else if (thisBaseboard.ScaledHeatingCapacity == AutoSize) { ShowSevereError(state, format("{} = {}", cCMO_BBRadiator_Water, thisBaseboard.EquipID)); ShowContinueError(state, format("Input for {} = {}", - state.dataIPShortCut->cAlphaFieldNames(iHeatCAPMAlphaNum), - state.dataIPShortCut->cAlphaArgs(iHeatCAPMAlphaNum))); + s_ipsc->cAlphaFieldNames(iHeatCAPMAlphaNum), + s_ipsc->cAlphaArgs(iHeatCAPMAlphaNum))); ShowContinueError( state, - format("Illegal {} = Autosize", state.dataIPShortCut->cNumericFieldNames(iHeatCapacityPerFloorAreaNumericNum))); + format("Illegal {} = Autosize", s_ipsc->cNumericFieldNames(iHeatCapacityPerFloorAreaNumericNum))); ErrorsFound = true; } } else { ShowSevereError(state, format("{} = {}", cCMO_BBRadiator_Water, thisBaseboard.EquipID)); ShowContinueError(state, format("Input for {} = {}", - state.dataIPShortCut->cAlphaFieldNames(iHeatCAPMAlphaNum), - state.dataIPShortCut->cAlphaArgs(iHeatCAPMAlphaNum))); + s_ipsc->cAlphaFieldNames(iHeatCAPMAlphaNum), + s_ipsc->cAlphaArgs(iHeatCAPMAlphaNum))); ShowContinueError( state, - format("Blank field not allowed for {}", state.dataIPShortCut->cNumericFieldNames(iHeatCapacityPerFloorAreaNumericNum))); + format("Blank field not allowed for {}", s_ipsc->cNumericFieldNames(iHeatCapacityPerFloorAreaNumericNum))); ErrorsFound = true; } - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(iHeatCAPMAlphaNum), "FractionOfAutosizedHeatingCapacity")) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(iHeatCAPMAlphaNum), "FractionOfAutosizedHeatingCapacity")) { thisBaseboard.HeatingCapMethod = FractionOfAutosizedHeatingCapacity; - if (!state.dataIPShortCut->lNumericFieldBlanks(iHeatFracOfAutosizedCapacityNumericNum)) { - thisBaseboard.ScaledHeatingCapacity = state.dataIPShortCut->rNumericArgs(iHeatFracOfAutosizedCapacityNumericNum); + if (!s_ipsc->lNumericFieldBlanks(iHeatFracOfAutosizedCapacityNumericNum)) { + thisBaseboard.ScaledHeatingCapacity = s_ipsc->rNumericArgs(iHeatFracOfAutosizedCapacityNumericNum); if (thisBaseboard.ScaledHeatingCapacity < 0.0) { ShowSevereError(state, format("{} = {}", cCMO_BBRadiator_Water, thisBaseboard.EquipID)); ShowContinueError(state, format("Illegal {} = {:.7T}", - state.dataIPShortCut->cNumericFieldNames(iHeatFracOfAutosizedCapacityNumericNum), - state.dataIPShortCut->rNumericArgs(iHeatFracOfAutosizedCapacityNumericNum))); + s_ipsc->cNumericFieldNames(iHeatFracOfAutosizedCapacityNumericNum), + s_ipsc->rNumericArgs(iHeatFracOfAutosizedCapacityNumericNum))); ErrorsFound = true; } } else { ShowSevereError(state, format("{} = {}", cCMO_BBRadiator_Water, thisBaseboard.EquipID)); ShowContinueError(state, format("Input for {} = {}", - state.dataIPShortCut->cAlphaFieldNames(iHeatCAPMAlphaNum), - state.dataIPShortCut->cAlphaArgs(iHeatCAPMAlphaNum))); + s_ipsc->cAlphaFieldNames(iHeatCAPMAlphaNum), + s_ipsc->cAlphaArgs(iHeatCAPMAlphaNum))); ShowContinueError(state, format("Blank field not allowed for {}", - state.dataIPShortCut->cNumericFieldNames(iHeatFracOfAutosizedCapacityNumericNum))); + s_ipsc->cNumericFieldNames(iHeatFracOfAutosizedCapacityNumericNum))); ErrorsFound = true; } } else { ShowSevereError(state, format("{} = {}", cCMO_BBRadiator_Water, thisBaseboard.EquipID)); ShowContinueError(state, format("Illegal {} = {}", - state.dataIPShortCut->cAlphaFieldNames(iHeatCAPMAlphaNum), - state.dataIPShortCut->cAlphaArgs(iHeatCAPMAlphaNum))); + s_ipsc->cAlphaFieldNames(iHeatCAPMAlphaNum), + s_ipsc->cAlphaArgs(iHeatCAPMAlphaNum))); ErrorsFound = true; } - thisBaseboard.UA = state.dataIPShortCut->rNumericArgs(4); - thisBaseboard.WaterVolFlowRateMax = state.dataIPShortCut->rNumericArgs(5); - thisBaseboard.Offset = state.dataIPShortCut->rNumericArgs(6); + thisBaseboard.UA = s_ipsc->rNumericArgs(4); + thisBaseboard.WaterVolFlowRateMax = s_ipsc->rNumericArgs(5); + thisBaseboard.Offset = s_ipsc->rNumericArgs(6); // Set default convergence tolerance if (thisBaseboard.Offset <= 0.0) { thisBaseboard.Offset = 0.001; @@ -1019,7 +1011,7 @@ namespace BaseboardRadiator { CapacitanceAir = CpAir * AirMassFlowRate; if (QZnReq > SmallLoad && (!state.dataZoneEnergyDemand->CurDeadBandOrSetback(ZoneNum) || baseboard->baseboards(BaseboardNum).MySizeFlag) && - (GetCurrentScheduleValue(state, baseboard->baseboards(BaseboardNum).SchedPtr) > 0 || baseboard->baseboards(BaseboardNum).MySizeFlag) && + (baseboard->baseboards(BaseboardNum).sched->getCurrentVal() > 0 || baseboard->baseboards(BaseboardNum).MySizeFlag) && (WaterMassFlowRate > 0.0)) { CapacitanceWater = CpWater * WaterMassFlowRate; CapacitanceMax = max(CapacitanceAir, CapacitanceWater); diff --git a/src/EnergyPlus/BaseboardRadiator.hh b/src/EnergyPlus/BaseboardRadiator.hh index a21a326e044..08f073f08f6 100644 --- a/src/EnergyPlus/BaseboardRadiator.hh +++ b/src/EnergyPlus/BaseboardRadiator.hh @@ -69,7 +69,7 @@ namespace BaseboardRadiator { // Members std::string EquipID; std::string Schedule; - int SchedPtr = 0; + Sched::Schedule *sched = nullptr; DataPlant::PlantEquipmentType EquipType = DataPlant::PlantEquipmentType::Invalid; int ZonePtr = 0; int WaterInletNode = 0; @@ -126,6 +126,10 @@ struct BaseboardRadiatorData : BaseGlobalStruct bool getInputFlag = true; EPVector baseboards; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/BoilerSteam.hh b/src/EnergyPlus/BoilerSteam.hh index 406fb74a0ae..411d7e82a36 100644 --- a/src/EnergyPlus/BoilerSteam.hh +++ b/src/EnergyPlus/BoilerSteam.hh @@ -162,6 +162,10 @@ struct BoilerSteamData : BaseGlobalStruct bool getSteamBoilerInput = true; Array1D Boiler; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/Boilers.hh b/src/EnergyPlus/Boilers.hh index 873c67c634a..2cb9d26a47e 100644 --- a/src/EnergyPlus/Boilers.hh +++ b/src/EnergyPlus/Boilers.hh @@ -189,6 +189,10 @@ struct BoilersData : BaseGlobalStruct bool getBoilerInputFlag = true; Array1D Boiler; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/BranchInputManager.hh b/src/EnergyPlus/BranchInputManager.hh index 5b7c5e7b33d..10506addc9b 100644 --- a/src/EnergyPlus/BranchInputManager.hh +++ b/src/EnergyPlus/BranchInputManager.hh @@ -317,6 +317,10 @@ struct BranchInputManagerData : BaseGlobalStruct Array1D Mixers; // Mixer Data for each Mixer Array1D BComponents; // Component data to be returned + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/CTElectricGenerator.hh b/src/EnergyPlus/CTElectricGenerator.hh index f6ab8913a29..f8ed0a378fd 100644 --- a/src/EnergyPlus/CTElectricGenerator.hh +++ b/src/EnergyPlus/CTElectricGenerator.hh @@ -155,6 +155,10 @@ struct CTElectricGeneratorData : BaseGlobalStruct bool getCTInputFlag = true; Array1D CTGenerator; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/ChilledCeilingPanelSimple.cc b/src/EnergyPlus/ChilledCeilingPanelSimple.cc index 811b5aead15..bbc2320608c 100644 --- a/src/EnergyPlus/ChilledCeilingPanelSimple.cc +++ b/src/EnergyPlus/ChilledCeilingPanelSimple.cc @@ -218,6 +218,7 @@ void GetCoolingPanelInput(EnergyPlusData &state) // SUBROUTINE PARAMETER DEFINITIONS: static constexpr std::string_view RoutineName("GetCoolingPanelInput:"); + static constexpr std::string_view routineName = "GetCoolingPanelInput"; Real64 constexpr MaxFraction(1.0); Real64 constexpr MinFraction(0.0); Real64 constexpr MaxWaterTempAvg(30.0); // Maximum limit of average water temperature in degree C @@ -246,6 +247,7 @@ void GetCoolingPanelInput(EnergyPlusData &state) bool ErrorsFound(false); // If errors detected in input int NumCoolingPanels = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCMO_CoolingPanel_Simple); + auto &s_ipsc = state.dataIPShortCut; // Count total number of baseboard units state.dataChilledCeilingPanelSimple->CoolingPanel.allocate(NumCoolingPanels); @@ -256,59 +258,52 @@ void GetCoolingPanelInput(EnergyPlusData &state) state.dataInputProcessing->inputProcessor->getObjectItem(state, cCMO_CoolingPanel_Simple, CoolingPanelNum, - state.dataIPShortCut->cAlphaArgs, + s_ipsc->cAlphaArgs, NumAlphas, - state.dataIPShortCut->rNumericArgs, + s_ipsc->rNumericArgs, NumNumbers, IOStat, - state.dataIPShortCut->lNumericFieldBlanks, - state.dataIPShortCut->lAlphaFieldBlanks, - state.dataIPShortCut->cAlphaFieldNames, - state.dataIPShortCut->cNumericFieldNames); + s_ipsc->lNumericFieldBlanks, + s_ipsc->lAlphaFieldBlanks, + s_ipsc->cAlphaFieldNames, + s_ipsc->cNumericFieldNames); + ErrorObjectHeader eoh{routineName, cCMO_CoolingPanel_Simple, s_ipsc->cAlphaArgs(1)}; + state.dataChilledCeilingPanelSimple->CoolingPanel(CoolingPanelNum).FieldNames.allocate(NumNumbers); state.dataChilledCeilingPanelSimple->CoolingPanel(CoolingPanelNum).FieldNames = ""; - state.dataChilledCeilingPanelSimple->CoolingPanel(CoolingPanelNum).FieldNames = state.dataIPShortCut->cNumericFieldNames; + state.dataChilledCeilingPanelSimple->CoolingPanel(CoolingPanelNum).FieldNames = s_ipsc->cNumericFieldNames; if (CoolingPanelNum > 1) { for (int CoolPanelNumI = 2; CoolPanelNumI <= NumCoolingPanels; ++CoolPanelNumI) { - if (state.dataIPShortCut->cAlphaArgs(1) == state.dataChilledCeilingPanelSimple->CoolingPanel(CoolPanelNumI).Name) { + if (s_ipsc->cAlphaArgs(1) == state.dataChilledCeilingPanelSimple->CoolingPanel(CoolPanelNumI).Name) { ErrorsFound = true; ShowSevereError(state, - format("{} is used as a name for more than one simple COOLING PANEL.", state.dataIPShortCut->cAlphaArgs(1))); + format("{} is used as a name for more than one simple COOLING PANEL.", s_ipsc->cAlphaArgs(1))); ShowContinueError(state, "This is not allowed."); } } } auto &thisCP(state.dataChilledCeilingPanelSimple->CoolingPanel(CoolingPanelNum)); - thisCP.Name = state.dataIPShortCut->cAlphaArgs(1); // Name of this simple cooling panel + thisCP.Name = s_ipsc->cAlphaArgs(1); // Name of this simple cooling panel thisCP.EquipType = DataPlant::PlantEquipmentType::CoolingPanel_Simple; //'ZoneHVAC:CoolingPanel:RadiantConvective:Water' // Get schedule - thisCP.Schedule = state.dataIPShortCut->cAlphaArgs(2); - if (state.dataIPShortCut->lAlphaFieldBlanks(2)) { - thisCP.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - thisCP.SchedPtr = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(2)); - if (thisCP.SchedPtr == 0) { - ShowSevereError(state, - format("{}{}=\"{}\", {}=\"{}\" not found.", - RoutineName, - cCMO_CoolingPanel_Simple, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaFieldNames(2), - state.dataIPShortCut->cAlphaArgs(2))); - ErrorsFound = true; - } + thisCP.Schedule = s_ipsc->cAlphaArgs(2); + if (s_ipsc->lAlphaFieldBlanks(2)) { + thisCP.sched = Sched::GetScheduleAlwaysOn(state); + } else if ((thisCP.sched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2)); + ErrorsFound = true; } // Get inlet node number thisCP.WaterInletNode = NodeInputManager::GetOnlySingleNode(state, - state.dataIPShortCut->cAlphaArgs(3), + s_ipsc->cAlphaArgs(3), ErrorsFound, DataLoopNode::ConnectionObjectType::ZoneHVACCoolingPanelRadiantConvectiveWater, - state.dataIPShortCut->cAlphaArgs(1), + s_ipsc->cAlphaArgs(1), DataLoopNode::NodeFluidType::Water, DataLoopNode::ConnectionType::Inlet, NodeInputManager::CompFluidStream::Primary, @@ -316,29 +311,29 @@ void GetCoolingPanelInput(EnergyPlusData &state) // Get outlet node number thisCP.WaterOutletNode = NodeInputManager::GetOnlySingleNode(state, - state.dataIPShortCut->cAlphaArgs(4), + s_ipsc->cAlphaArgs(4), ErrorsFound, DataLoopNode::ConnectionObjectType::ZoneHVACCoolingPanelRadiantConvectiveWater, - state.dataIPShortCut->cAlphaArgs(1), + s_ipsc->cAlphaArgs(1), DataLoopNode::NodeFluidType::Water, DataLoopNode::ConnectionType::Outlet, NodeInputManager::CompFluidStream::Primary, DataLoopNode::ObjectIsNotParent); BranchNodeConnections::TestCompSet(state, cCMO_CoolingPanel_Simple, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaArgs(3), - state.dataIPShortCut->cAlphaArgs(4), + s_ipsc->cAlphaArgs(1), + s_ipsc->cAlphaArgs(3), + s_ipsc->cAlphaArgs(4), "Chilled Water Nodes"); - thisCP.RatedWaterTemp = state.dataIPShortCut->rNumericArgs(1); + thisCP.RatedWaterTemp = s_ipsc->rNumericArgs(1); if (thisCP.RatedWaterTemp > MaxWaterTempAvg + 0.001) { ShowWarningError(state, format("{}{}=\"{}\", {} was higher than the allowable maximum.", RoutineName, cCMO_CoolingPanel_Simple, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cNumericFieldNames(1))); + s_ipsc->cAlphaArgs(1), + s_ipsc->cNumericFieldNames(1))); ShowContinueError(state, format("...reset to maximum value=[{:.2R}].", MaxWaterTempAvg)); thisCP.RatedWaterTemp = MaxWaterTempAvg; } else if (thisCP.RatedWaterTemp < MinWaterTempAvg - 0.001) { @@ -346,20 +341,20 @@ void GetCoolingPanelInput(EnergyPlusData &state) format("{}{}=\"{}\", {} was lower than the allowable minimum.", RoutineName, cCMO_CoolingPanel_Simple, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cNumericFieldNames(1))); + s_ipsc->cAlphaArgs(1), + s_ipsc->cNumericFieldNames(1))); ShowContinueError(state, format("...reset to minimum value=[{:.2R}].", MinWaterTempAvg)); thisCP.RatedWaterTemp = MinWaterTempAvg; } - thisCP.RatedZoneAirTemp = state.dataIPShortCut->rNumericArgs(2); + thisCP.RatedZoneAirTemp = s_ipsc->rNumericArgs(2); if (thisCP.RatedZoneAirTemp > MaxWaterTempAvg + 0.001) { ShowWarningError(state, format("{}{}=\"{}\", {} was higher than the allowable maximum.", RoutineName, cCMO_CoolingPanel_Simple, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cNumericFieldNames(2))); + s_ipsc->cAlphaArgs(1), + s_ipsc->cNumericFieldNames(2))); ShowContinueError(state, format("...reset to maximum value=[{:.2R}].", MaxWaterTempAvg)); thisCP.RatedZoneAirTemp = MaxWaterTempAvg; } else if (thisCP.RatedZoneAirTemp < MinWaterTempAvg - 0.001) { @@ -367,97 +362,97 @@ void GetCoolingPanelInput(EnergyPlusData &state) format("{}{}=\"{}\", {} was lower than the allowable minimum.", RoutineName, cCMO_CoolingPanel_Simple, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cNumericFieldNames(2))); + s_ipsc->cAlphaArgs(1), + s_ipsc->cNumericFieldNames(2))); ShowContinueError(state, format("...reset to minimum value=[{:.2R}].", MinWaterTempAvg)); thisCP.RatedZoneAirTemp = MinWaterTempAvg; } - thisCP.RatedWaterFlowRate = state.dataIPShortCut->rNumericArgs(3); + thisCP.RatedWaterFlowRate = s_ipsc->rNumericArgs(3); if (thisCP.RatedWaterFlowRate < 0.00001 || thisCP.RatedWaterFlowRate > 10.0) { ShowWarningError(state, format("{}{}=\"{}\", {} is an invalid Standard Water mass flow rate.", RoutineName, cCMO_CoolingPanel_Simple, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cNumericFieldNames(2))); + s_ipsc->cAlphaArgs(1), + s_ipsc->cNumericFieldNames(2))); ShowContinueError(state, format("...reset to a default value=[{:.1R}].", WaterMassFlowDefault)); thisCP.RatedWaterFlowRate = WaterMassFlowDefault; } - if (Util::SameString(state.dataIPShortCut->cAlphaArgs(5), "CoolingDesignCapacity")) { + if (Util::SameString(s_ipsc->cAlphaArgs(5), "CoolingDesignCapacity")) { thisCP.CoolingCapMethod = DataSizing::CoolingDesignCapacity; - if (!state.dataIPShortCut->lNumericFieldBlanks(4)) { - thisCP.ScaledCoolingCapacity = state.dataIPShortCut->rNumericArgs(4); + if (!s_ipsc->lNumericFieldBlanks(4)) { + thisCP.ScaledCoolingCapacity = s_ipsc->rNumericArgs(4); if (thisCP.ScaledCoolingCapacity < 0.0 && thisCP.ScaledCoolingCapacity != DataSizing::AutoSize) { ShowSevereError(state, format("{} = {}", cCMO_CoolingPanel_Simple, thisCP.Name)); ShowContinueError( - state, format("Illegal {} = {:.7T}", state.dataIPShortCut->cNumericFieldNames(4), state.dataIPShortCut->rNumericArgs(4))); + state, format("Illegal {} = {:.7T}", s_ipsc->cNumericFieldNames(4), s_ipsc->rNumericArgs(4))); ErrorsFound = true; } } else { - if ((!state.dataIPShortCut->lAlphaFieldBlanks(6)) || (!state.dataIPShortCut->lAlphaFieldBlanks(7))) { + if ((!s_ipsc->lAlphaFieldBlanks(6)) || (!s_ipsc->lAlphaFieldBlanks(7))) { ShowSevereError(state, format("{} = {}", cCMO_CoolingPanel_Simple, thisCP.Name)); ShowContinueError(state, - format("Input for {} = {}", state.dataIPShortCut->cAlphaFieldNames(5), state.dataIPShortCut->cAlphaArgs(5))); - ShowContinueError(state, format("Blank field not allowed for {}", state.dataIPShortCut->cNumericFieldNames(4))); + format("Input for {} = {}", s_ipsc->cAlphaFieldNames(5), s_ipsc->cAlphaArgs(5))); + ShowContinueError(state, format("Blank field not allowed for {}", s_ipsc->cNumericFieldNames(4))); ErrorsFound = true; } } - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(5), "CapacityPerFloorArea")) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(5), "CapacityPerFloorArea")) { thisCP.CoolingCapMethod = DataSizing::CapacityPerFloorArea; - if (!state.dataIPShortCut->lNumericFieldBlanks(5)) { - thisCP.ScaledCoolingCapacity = state.dataIPShortCut->rNumericArgs(5); + if (!s_ipsc->lNumericFieldBlanks(5)) { + thisCP.ScaledCoolingCapacity = s_ipsc->rNumericArgs(5); if (thisCP.ScaledCoolingCapacity < 0.0) { ShowSevereError(state, format("{} = {}", cCMO_CoolingPanel_Simple, thisCP.Name)); ShowContinueError(state, - format("Input for {} = {}", state.dataIPShortCut->cAlphaFieldNames(5), state.dataIPShortCut->cAlphaArgs(5))); + format("Input for {} = {}", s_ipsc->cAlphaFieldNames(5), s_ipsc->cAlphaArgs(5))); ShowContinueError( - state, format("Illegal {} = {:.7T}", state.dataIPShortCut->cNumericFieldNames(5), state.dataIPShortCut->rNumericArgs(5))); + state, format("Illegal {} = {:.7T}", s_ipsc->cNumericFieldNames(5), s_ipsc->rNumericArgs(5))); ErrorsFound = true; } else if (thisCP.ScaledCoolingCapacity == DataSizing::AutoSize) { ShowSevereError(state, format("{} = {}", cCMO_CoolingPanel_Simple, thisCP.Name)); ShowContinueError(state, - format("Input for {} = {}", state.dataIPShortCut->cAlphaFieldNames(5), state.dataIPShortCut->cAlphaArgs(5))); - ShowContinueError(state, format("Illegal {} = Autosize", state.dataIPShortCut->cNumericFieldNames(5))); + format("Input for {} = {}", s_ipsc->cAlphaFieldNames(5), s_ipsc->cAlphaArgs(5))); + ShowContinueError(state, format("Illegal {} = Autosize", s_ipsc->cNumericFieldNames(5))); ErrorsFound = true; } } else { ShowSevereError(state, format("{} = {}", cCMO_CoolingPanel_Simple, thisCP.Name)); - ShowContinueError(state, format("Input for {} = {}", state.dataIPShortCut->cAlphaFieldNames(5), state.dataIPShortCut->cAlphaArgs(5))); - ShowContinueError(state, format("Blank field not allowed for {}", state.dataIPShortCut->cNumericFieldNames(5))); + ShowContinueError(state, format("Input for {} = {}", s_ipsc->cAlphaFieldNames(5), s_ipsc->cAlphaArgs(5))); + ShowContinueError(state, format("Blank field not allowed for {}", s_ipsc->cNumericFieldNames(5))); ErrorsFound = true; } - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(5), "FractionOfAutosizedCoolingCapacity")) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(5), "FractionOfAutosizedCoolingCapacity")) { thisCP.CoolingCapMethod = DataSizing::FractionOfAutosizedCoolingCapacity; - if (!state.dataIPShortCut->lNumericFieldBlanks(6)) { - thisCP.ScaledCoolingCapacity = state.dataIPShortCut->rNumericArgs(6); + if (!s_ipsc->lNumericFieldBlanks(6)) { + thisCP.ScaledCoolingCapacity = s_ipsc->rNumericArgs(6); if (thisCP.ScaledCoolingCapacity < 0.0) { ShowSevereError(state, format("{} = {}", cCMO_CoolingPanel_Simple, thisCP.Name)); ShowContinueError( - state, format("Illegal {} = {:.7T}", state.dataIPShortCut->cNumericFieldNames(6), state.dataIPShortCut->rNumericArgs(6))); + state, format("Illegal {} = {:.7T}", s_ipsc->cNumericFieldNames(6), s_ipsc->rNumericArgs(6))); ErrorsFound = true; } } else { ShowSevereError(state, format("{} = {}", cCMO_CoolingPanel_Simple, thisCP.Name)); - ShowContinueError(state, format("Input for {} = {}", state.dataIPShortCut->cAlphaFieldNames(5), state.dataIPShortCut->cAlphaArgs(5))); - ShowContinueError(state, format("Blank field not allowed for {}", state.dataIPShortCut->cNumericFieldNames(6))); + ShowContinueError(state, format("Input for {} = {}", s_ipsc->cAlphaFieldNames(5), s_ipsc->cAlphaArgs(5))); + ShowContinueError(state, format("Blank field not allowed for {}", s_ipsc->cNumericFieldNames(6))); ErrorsFound = true; } } else { ShowSevereError(state, format("{} = {}", cCMO_CoolingPanel_Simple, thisCP.Name)); - ShowContinueError(state, format("Illegal {} = {}", state.dataIPShortCut->cAlphaFieldNames(5), state.dataIPShortCut->cAlphaArgs(5))); + ShowContinueError(state, format("Illegal {} = {}", s_ipsc->cAlphaFieldNames(5), s_ipsc->cAlphaArgs(5))); ErrorsFound = true; } - thisCP.WaterVolFlowRateMax = state.dataIPShortCut->rNumericArgs(7); + thisCP.WaterVolFlowRateMax = s_ipsc->rNumericArgs(7); if ((thisCP.WaterVolFlowRateMax <= MinWaterFlowRate) && thisCP.WaterVolFlowRateMax != DataSizing::AutoSize) { ShowWarningError(state, format("{}{}=\"{}\", {} was less than the allowable minimum.", RoutineName, cCMO_CoolingPanel_Simple, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cNumericFieldNames(7))); + s_ipsc->cAlphaArgs(1), + s_ipsc->cNumericFieldNames(7))); ShowContinueError(state, format("...reset to minimum value=[{:.2R}].", MinWaterFlowRate)); thisCP.WaterVolFlowRateMax = MinWaterFlowRate; } else if (thisCP.WaterVolFlowRateMax > MaxWaterFlowRate) { @@ -465,69 +460,67 @@ void GetCoolingPanelInput(EnergyPlusData &state) format("{}{}=\"{}\", {} was higher than the allowable maximum.", RoutineName, cCMO_CoolingPanel_Simple, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cNumericFieldNames(7))); + s_ipsc->cAlphaArgs(1), + s_ipsc->cNumericFieldNames(7))); ShowContinueError(state, format("...reset to maximum value=[{:.2R}].", MaxWaterFlowRate)); thisCP.WaterVolFlowRateMax = MaxWaterFlowRate; } // Process the temperature control type - if (Util::SameString(state.dataIPShortCut->cAlphaArgs(6), MeanAirTemperature)) { + if (Util::SameString(s_ipsc->cAlphaArgs(6), MeanAirTemperature)) { thisCP.controlType = ClgPanelCtrlType::MAT; - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(6), MeanRadiantTemperature)) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(6), MeanRadiantTemperature)) { thisCP.controlType = ClgPanelCtrlType::MRT; - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(6), OperativeTemperature)) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(6), OperativeTemperature)) { thisCP.controlType = ClgPanelCtrlType::Operative; - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(6), OutsideAirDryBulbTemperature)) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(6), OutsideAirDryBulbTemperature)) { thisCP.controlType = ClgPanelCtrlType::ODB; - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(6), OutsideAirWetBulbTemperature)) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(6), OutsideAirWetBulbTemperature)) { thisCP.controlType = ClgPanelCtrlType::OWB; - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(6), ZoneTotalLoad)) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(6), ZoneTotalLoad)) { thisCP.controlType = ClgPanelCtrlType::ZoneTotalLoad; - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(6), ZoneConvectiveLoad)) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(6), ZoneConvectiveLoad)) { thisCP.controlType = ClgPanelCtrlType::ZoneConvectiveLoad; } else { - ShowWarningError(state, format("Invalid {} ={}", state.dataIPShortCut->cAlphaFieldNames(6), state.dataIPShortCut->cAlphaArgs(6))); - ShowContinueError(state, format("Occurs in {} = {}", RoutineName, state.dataIPShortCut->cAlphaArgs(1))); + ShowWarningError(state, format("Invalid {} ={}", s_ipsc->cAlphaFieldNames(6), s_ipsc->cAlphaArgs(6))); + ShowContinueError(state, format("Occurs in {} = {}", RoutineName, s_ipsc->cAlphaArgs(1))); ShowContinueError(state, "Control reset to MAT control for this Simple Cooling Panel."); thisCP.controlType = ClgPanelCtrlType::MAT; } - thisCP.ColdThrottlRange = state.dataIPShortCut->rNumericArgs(8); + thisCP.ColdThrottlRange = s_ipsc->rNumericArgs(8); if (thisCP.ColdThrottlRange < MinThrottlingRange) { ShowWarningError(state, format("{}Cooling throttling range too small, reset to 0.5", cCMO_CoolingPanel_Simple)); ShowContinueError(state, format("Occurs in Cooling Panel={}", thisCP.Name)); thisCP.ColdThrottlRange = MinThrottlingRange; } - thisCP.ColdSetptSched = state.dataIPShortCut->cAlphaArgs(7); - thisCP.ColdSetptSchedPtr = ScheduleManager::GetScheduleIndex(state, thisCP.ColdSetptSched); - if ((thisCP.ColdSetptSchedPtr == 0) && (!state.dataIPShortCut->lAlphaFieldBlanks(7))) { - ShowSevereError(state, format("{} not found: {}", state.dataIPShortCut->cAlphaFieldNames(7), thisCP.ColdSetptSched)); - ShowContinueError(state, format("Occurs in {} = {}", RoutineName, state.dataIPShortCut->cAlphaArgs(1))); + thisCP.ColdSetptSchedName = s_ipsc->cAlphaArgs(7); + if ((thisCP.coldSetptSched = Sched::GetSchedule(state, thisCP.ColdSetptSchedName)) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(7), s_ipsc->cAlphaArgs(7)); ErrorsFound = true; } - if (Util::SameString(state.dataIPShortCut->cAlphaArgs(8), Off)) { + if (Util::SameString(s_ipsc->cAlphaArgs(8), Off)) { thisCP.CondCtrlType = CondCtrl::NONE; - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(8), SimpleOff)) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(8), SimpleOff)) { thisCP.CondCtrlType = CondCtrl::SIMPLEOFF; - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(8), VariableOff)) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(8), VariableOff)) { thisCP.CondCtrlType = CondCtrl::VARIEDOFF; } else { thisCP.CondCtrlType = CondCtrl::SIMPLEOFF; } - thisCP.CondDewPtDeltaT = state.dataIPShortCut->rNumericArgs(9); + thisCP.CondDewPtDeltaT = s_ipsc->rNumericArgs(9); - thisCP.FracRadiant = state.dataIPShortCut->rNumericArgs(10); + thisCP.FracRadiant = s_ipsc->rNumericArgs(10); if (thisCP.FracRadiant < MinFraction) { ShowWarningError(state, format("{}{}=\"{}\", {} was lower than the allowable minimum.", RoutineName, cCMO_CoolingPanel_Simple, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cNumericFieldNames(10))); + s_ipsc->cAlphaArgs(1), + s_ipsc->cNumericFieldNames(10))); ShowContinueError(state, format("...reset to minimum value=[{:.2R}].", MinFraction)); thisCP.FracRadiant = MinFraction; } @@ -536,8 +529,8 @@ void GetCoolingPanelInput(EnergyPlusData &state) format("{}{}=\"{}\", {} was higher than the allowable maximum.", RoutineName, cCMO_CoolingPanel_Simple, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cNumericFieldNames(10))); + s_ipsc->cAlphaArgs(1), + s_ipsc->cNumericFieldNames(10))); ShowContinueError(state, format("...reset to maximum value=[{:.2R}].", MaxFraction)); thisCP.FracRadiant = MaxFraction; } @@ -548,21 +541,21 @@ void GetCoolingPanelInput(EnergyPlusData &state) format("{}{}=\"{}\", Fraction Radiant was higher than the allowable maximum.", RoutineName, cCMO_CoolingPanel_Simple, - state.dataIPShortCut->cAlphaArgs(1))); + s_ipsc->cAlphaArgs(1))); thisCP.FracRadiant = MaxFraction; thisCP.FracConvect = 0.0; } else { thisCP.FracConvect = 1.0 - thisCP.FracRadiant; } - thisCP.FracDistribPerson = state.dataIPShortCut->rNumericArgs(11); + thisCP.FracDistribPerson = s_ipsc->rNumericArgs(11); if (thisCP.FracDistribPerson < MinFraction) { ShowWarningError(state, format("{}{}=\"{}\", {} was lower than the allowable minimum.", RoutineName, cCMO_CoolingPanel_Simple, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cNumericFieldNames(11))); + s_ipsc->cAlphaArgs(1), + s_ipsc->cNumericFieldNames(11))); ShowContinueError(state, format("...reset to minimum value=[{:.3R}].", MinFraction)); thisCP.FracDistribPerson = MinFraction; } @@ -571,8 +564,8 @@ void GetCoolingPanelInput(EnergyPlusData &state) format("{}{}=\"{}\", {} was higher than the allowable maximum.", RoutineName, cCMO_CoolingPanel_Simple, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cNumericFieldNames(11))); + s_ipsc->cAlphaArgs(1), + s_ipsc->cNumericFieldNames(11))); ShowContinueError(state, format("...reset to maximum value=[{:.3R}].", MaxFraction)); thisCP.FracDistribPerson = MaxFraction; } @@ -583,7 +576,7 @@ void GetCoolingPanelInput(EnergyPlusData &state) format("{}{}=\"{}\", the number of surface/radiant fraction groups entered was less than the allowable minimum.", RoutineName, cCMO_CoolingPanel_Simple, - state.dataIPShortCut->cAlphaArgs(1))); + s_ipsc->cAlphaArgs(1))); ShowContinueError(state, format("...the minimum that must be entered=[{}].", MinDistribSurfaces)); ErrorsFound = true; thisCP.TotSurfToDistrib = 0; // error @@ -613,17 +606,17 @@ void GetCoolingPanelInput(EnergyPlusData &state) Real64 AllFracsSummed = thisCP.FracDistribPerson; for (SurfNum = 1; SurfNum <= thisCP.TotSurfToDistrib; ++SurfNum) { - thisCP.SurfaceName(SurfNum) = state.dataIPShortCut->cAlphaArgs(SurfNum + 8); + thisCP.SurfaceName(SurfNum) = s_ipsc->cAlphaArgs(SurfNum + 8); thisCP.SurfacePtr(SurfNum) = HeatBalanceIntRadExchange::GetRadiantSystemSurface( state, cCMO_CoolingPanel_Simple, thisCP.Name, thisCP.ZonePtr, thisCP.SurfaceName(SurfNum), ErrorsFound); - thisCP.FracDistribToSurf(SurfNum) = state.dataIPShortCut->rNumericArgs(SurfNum + 11); + thisCP.FracDistribToSurf(SurfNum) = s_ipsc->rNumericArgs(SurfNum + 11); if (thisCP.FracDistribToSurf(SurfNum) > MaxFraction) { ShowWarningError(state, format("{}{}=\"{}\", {}was greater than the allowable maximum.", RoutineName, cCMO_CoolingPanel_Simple, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cNumericFieldNames(SurfNum + 8))); + s_ipsc->cAlphaArgs(1), + s_ipsc->cNumericFieldNames(SurfNum + 8))); ShowContinueError(state, format("...reset to maximum value=[{:.2R}].", MaxFraction)); thisCP.TotSurfToDistrib = MaxFraction; } @@ -632,8 +625,8 @@ void GetCoolingPanelInput(EnergyPlusData &state) format("{}{}=\"{}\", {}was less than the allowable minimum.", RoutineName, cCMO_CoolingPanel_Simple, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cNumericFieldNames(SurfNum + 8))); + s_ipsc->cAlphaArgs(1), + s_ipsc->cNumericFieldNames(SurfNum + 8))); ShowContinueError(state, format("...reset to maximum value=[{:.2R}].", MinFraction)); thisCP.TotSurfToDistrib = MinFraction; } @@ -650,7 +643,7 @@ void GetCoolingPanelInput(EnergyPlusData &state) format("{}{}=\"{}\", Summed radiant fractions for people + surface groups > 1.0", RoutineName, cCMO_CoolingPanel_Simple, - state.dataIPShortCut->cAlphaArgs(1))); + s_ipsc->cAlphaArgs(1))); ErrorsFound = true; } if ((AllFracsSummed < (MaxFraction - 0.01)) && @@ -659,7 +652,7 @@ void GetCoolingPanelInput(EnergyPlusData &state) format("{}{}=\"{}\", Summed radiant fractions for people + surface groups < 1.0", RoutineName, cCMO_CoolingPanel_Simple, - state.dataIPShortCut->cAlphaArgs(1))); + s_ipsc->cAlphaArgs(1))); ShowContinueError(state, "This would result in some of the radiant energy delivered by the high temp radiant heater being lost."); ShowContinueError(state, format("The sum of all radiation fractions to surfaces = {:.5T}", (AllFracsSummed - thisCP.FracDistribPerson))); ShowContinueError(state, format("The radiant fraction to people = {:.5T}", thisCP.FracDistribPerson)); @@ -671,7 +664,7 @@ void GetCoolingPanelInput(EnergyPlusData &state) ShowContinueError(state, format("Please check and correct this so that all radiant energy is accounted for in {} = {}", cCMO_CoolingPanel_Simple, - state.dataIPShortCut->cAlphaArgs(1))); + s_ipsc->cAlphaArgs(1))); ErrorsFound = true; } } @@ -1214,11 +1207,8 @@ void CoolingPanelParams::CalcCoolingPanel(EnergyPlusData &state, int const Cooli Real64 waterMassFlowRateMax = this->WaterMassFlowRateMax; Real64 Xr = this->FracRadiant; - if (ScheduleManager::GetCurrentScheduleValue(state, this->SchedPtr) > 0) { - CoolingPanelOn = true; - } else { - CoolingPanelOn = false; - } + CoolingPanelOn = this->sched->getCurrentVal() > 0; + // Calculate the "zone" temperature for determining the output of the cooling panel auto &thisZoneHB = state.dataZoneTempPredictorCorrector->zoneHeatBalance(ZoneNum); Real64 Tzone = Xr * thisZoneHB.MRT + ((1.0 - Xr) * thisZoneHB.MAT); @@ -1350,7 +1340,7 @@ void CoolingPanelParams::CalcCoolingPanel(EnergyPlusData &state, int const Cooli ControlTemp = this->getCoolingPanelControlTemp(state, ZoneNum); - SetPointTemp = ScheduleManager::GetCurrentScheduleValue(state, this->ColdSetptSchedPtr); + SetPointTemp = this->coldSetptSched->getCurrentVal(); OffTempCool = SetPointTemp - 0.5 * this->ColdThrottlRange; FullOnTempCool = SetPointTemp + 0.5 * this->ColdThrottlRange; diff --git a/src/EnergyPlus/ChilledCeilingPanelSimple.hh b/src/EnergyPlus/ChilledCeilingPanelSimple.hh index 8da0fdf65be..9a859dbca37 100644 --- a/src/EnergyPlus/ChilledCeilingPanelSimple.hh +++ b/src/EnergyPlus/ChilledCeilingPanelSimple.hh @@ -57,6 +57,7 @@ #include #include #include +#include namespace EnergyPlus { @@ -98,15 +99,15 @@ namespace CoolingPanelSimple { Array1D_string SurfaceName; Array1D_int SurfacePtr; int ZonePtr = 0; - int SchedPtr = 0; + Sched::Schedule *sched = nullptr; int WaterInletNode = 0; int WaterOutletNode = 0; int TotSurfToDistrib = 0; int ControlCompTypeNum = 0; int CompErrIndex = 0; ClgPanelCtrlType controlType = ClgPanelCtrlType::Invalid; - std::string ColdSetptSched; - int ColdSetptSchedPtr = 0; + std::string ColdSetptSchedName; + Sched::Schedule *coldSetptSched = nullptr; CondCtrl CondCtrlType = CondCtrl::NONE; Real64 CondDewPtDeltaT = 0.0; int CondErrIndex = 0; @@ -188,6 +189,10 @@ struct ChilledCeilingPanelSimpleData : BaseGlobalStruct bool GetInputFlag = true; Array1D CoolingPanel; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/ChillerAbsorption.hh b/src/EnergyPlus/ChillerAbsorption.hh index f0d6982fa2d..87a1329780a 100644 --- a/src/EnergyPlus/ChillerAbsorption.hh +++ b/src/EnergyPlus/ChillerAbsorption.hh @@ -200,6 +200,10 @@ struct ChillerAbsorberData : BaseGlobalStruct bool getInput = true; Array1D absorptionChillers; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/ChillerElectricASHRAE205.cc b/src/EnergyPlus/ChillerElectricASHRAE205.cc index 77786d58266..11ba018ab30 100644 --- a/src/EnergyPlus/ChillerElectricASHRAE205.cc +++ b/src/EnergyPlus/ChillerElectricASHRAE205.cc @@ -103,15 +103,18 @@ std::map InterpMethods = // NOLINT(cert void getChillerASHRAE205Input(EnergyPlusData &state) { static constexpr std::string_view RoutineName("getChillerASHRAE205Input: "); // include trailing blank space + static constexpr std::string_view routineName = "getChillerASHRAE205Input"; using namespace tk205; RSInstanceFactory::register_factory("RS0001", std::make_shared()); bool ErrorsFound{false}; + auto &s_ip = state.dataInputProcessing->inputProcessor; + auto &s_ipsc = state.dataIPShortCut; + state.dataIPShortCut->cCurrentModuleObject = ChillerElectricASHRAE205::ASHRAE205ChillerSpecs::ObjectType; - auto &ip = state.dataInputProcessing->inputProcessor; - int numElectric205Chillers = ip->getNumObjectsFound(state, state.dataIPShortCut->cCurrentModuleObject); + int numElectric205Chillers = s_ip->getNumObjectsFound(state, state.dataIPShortCut->cCurrentModuleObject); if (numElectric205Chillers <= 0) { ShowSevereError(state, format("No {} equipment specified in input file", state.dataIPShortCut->cCurrentModuleObject)); @@ -120,12 +123,16 @@ void getChillerASHRAE205Input(EnergyPlusData &state) state.dataChillerElectricASHRAE205->Electric205Chiller.allocate(numElectric205Chillers); - auto const &ChillerInstances = ip->epJSON.find(state.dataIPShortCut->cCurrentModuleObject).value(); + auto const &ChillerInstances = s_ip->epJSON.find(state.dataIPShortCut->cCurrentModuleObject).value(); int ChillerNum{0}; - auto const &objectSchemaProps = ip->getObjectSchemaProps(state, state.dataIPShortCut->cCurrentModuleObject); + auto const &objectSchemaProps = s_ip->getObjectSchemaProps(state, state.dataIPShortCut->cCurrentModuleObject); + for (auto &instance : ChillerInstances.items()) { auto const &fields = instance.value(); std::string const &thisObjectName = instance.key(); + + ErrorObjectHeader eoh{routineName, s_ipsc->cCurrentModuleObject, thisObjectName}; + GlobalNames::VerifyUniqueChillerName( state, state.dataIPShortCut->cCurrentModuleObject, thisObjectName, ErrorsFound, state.dataIPShortCut->cCurrentModuleObject + " Name"); @@ -133,9 +140,9 @@ void getChillerASHRAE205Input(EnergyPlusData &state) auto &thisChiller = state.dataChillerElectricASHRAE205->Electric205Chiller(ChillerNum); thisChiller.Name = Util::makeUPPER(thisObjectName); - ip->markObjectAsUsed(state.dataIPShortCut->cCurrentModuleObject, thisObjectName); + s_ip->markObjectAsUsed(state.dataIPShortCut->cCurrentModuleObject, thisObjectName); - std::string const rep_file_name = ip->getAlphaFieldValue(fields, objectSchemaProps, "representation_file_name"); + std::string const rep_file_name = s_ip->getAlphaFieldValue(fields, objectSchemaProps, "representation_file_name"); fs::path rep_file_path = DataSystemVariables::CheckForActualFilePath(state, fs::path(rep_file_name), std::string(RoutineName)); if (rep_file_path.empty()) { ErrorsFound = true; @@ -155,7 +162,7 @@ void getChillerASHRAE205Input(EnergyPlusData &state) thisChiller.Representation->performance.performance_map_cooling.get_logger()->set_message_context(&thisChiller.LoggerContext); thisChiller.Representation->performance.performance_map_standby.get_logger()->set_message_context(&thisChiller.LoggerContext); thisChiller.InterpolationType = - InterpMethods[Util::makeUPPER(ip->getAlphaFieldValue(fields, objectSchemaProps, "performance_interpolation_method"))]; + InterpMethods[Util::makeUPPER(s_ip->getAlphaFieldValue(fields, objectSchemaProps, "performance_interpolation_method"))]; const auto &compressorSequence = thisChiller.Representation->performance.performance_map_cooling.grid_variables.compressor_sequence_number; // minmax_element is sound but perhaps overkill; as sequence numbers are required by A205 to be in ascending order @@ -181,8 +188,8 @@ void getChillerASHRAE205Input(EnergyPlusData &state) // ErrorsFound = true; // } - std::string const evap_inlet_node_name = ip->getAlphaFieldValue(fields, objectSchemaProps, "chilled_water_inlet_node_name"); - std::string const evap_outlet_node_name = ip->getAlphaFieldValue(fields, objectSchemaProps, "chilled_water_outlet_node_name"); + std::string const evap_inlet_node_name = s_ip->getAlphaFieldValue(fields, objectSchemaProps, "chilled_water_inlet_node_name"); + std::string const evap_outlet_node_name = s_ip->getAlphaFieldValue(fields, objectSchemaProps, "chilled_water_outlet_node_name"); if (evap_inlet_node_name.empty() || evap_outlet_node_name.empty()) { ShowSevereError(state, format("{}{}=\"{}\"", std::string{RoutineName}, state.dataIPShortCut->cCurrentModuleObject, thisChiller.Name)); ShowContinueError(state, "Evaporator Inlet or Outlet Node Name is blank."); @@ -211,8 +218,8 @@ void getChillerASHRAE205Input(EnergyPlusData &state) thisChiller.CondenserType = DataPlant::CondenserType::WaterCooled; - std::string const cond_inlet_node_name = ip->getAlphaFieldValue(fields, objectSchemaProps, "condenser_inlet_node_name"); - std::string const cond_outlet_node_name = ip->getAlphaFieldValue(fields, objectSchemaProps, "condenser_outlet_node_name"); + std::string const cond_inlet_node_name = s_ip->getAlphaFieldValue(fields, objectSchemaProps, "condenser_inlet_node_name"); + std::string const cond_outlet_node_name = s_ip->getAlphaFieldValue(fields, objectSchemaProps, "condenser_outlet_node_name"); if (cond_inlet_node_name.empty() || cond_outlet_node_name.empty()) { ShowSevereError(state, format("{}{}=\"{}\"", std::string{RoutineName}, state.dataIPShortCut->cCurrentModuleObject, thisChiller.Name)); ShowContinueError(state, "Condenser Inlet or Outlet Node Name is blank."); @@ -246,7 +253,7 @@ void getChillerASHRAE205Input(EnergyPlusData &state) "Condenser Water Nodes"); thisChiller.FlowMode = static_cast( - getEnumValue(DataPlant::FlowModeNamesUC, ip->getAlphaFieldValue(fields, objectSchemaProps, "chiller_flow_mode"))); + getEnumValue(DataPlant::FlowModeNamesUC, s_ip->getAlphaFieldValue(fields, objectSchemaProps, "chiller_flow_mode"))); if (thisChiller.FlowMode == DataPlant::FlowMode::Invalid) { ShowSevereError(state, format("{}{}=\"{}\"", std::string{RoutineName}, state.dataIPShortCut->cCurrentModuleObject, thisObjectName)); @@ -281,24 +288,19 @@ void getChillerASHRAE205Input(EnergyPlusData &state) } thisChiller.AmbientTempType = static_cast( - getEnumValue(AmbientTempNamesUC, Util::makeUPPER(ip->getAlphaFieldValue(fields, objectSchemaProps, "ambient_temperature_indicator")))); + getEnumValue(AmbientTempNamesUC, Util::makeUPPER(s_ip->getAlphaFieldValue(fields, objectSchemaProps, "ambient_temperature_indicator")))); switch (thisChiller.AmbientTempType) { case AmbientTempIndicator::Schedule: { - std::string const ambient_temp_schedule = ip->getAlphaFieldValue(fields, objectSchemaProps, "ambient_temperature_schedule"); - thisChiller.AmbientTempSchedule = ScheduleManager::GetScheduleIndex(state, ambient_temp_schedule); - if (thisChiller.AmbientTempSchedule == 0) { - ShowSevereError(state, - format("{} = {}: Ambient Temperature Schedule not found = {}", - state.dataIPShortCut->cCurrentModuleObject, - thisObjectName, - ambient_temp_schedule)); + std::string const ambient_temp_schedule = s_ip->getAlphaFieldValue(fields, objectSchemaProps, "ambient_temperature_schedule"); + if ((thisChiller.ambientTempSched = Sched::GetSchedule(state, ambient_temp_schedule)) == nullptr) { + ShowSevereItemNotFound(state, eoh, "Ambient Temperature Schedule", ambient_temp_schedule); ErrorsFound = true; } break; } case AmbientTempIndicator::TempZone: { - std::string const ambient_temp_zone_name = ip->getAlphaFieldValue(fields, objectSchemaProps, "ambient_temperature_zone_name"); + std::string const ambient_temp_zone_name = s_ip->getAlphaFieldValue(fields, objectSchemaProps, "ambient_temperature_zone_name"); thisChiller.AmbientTempZone = Util::FindItemInList(ambient_temp_zone_name, state.dataHeatBal->Zone); if (thisChiller.AmbientTempZone == 0) { ShowSevereError(state, @@ -318,7 +320,7 @@ void getChillerASHRAE205Input(EnergyPlusData &state) } case AmbientTempIndicator::OutsideAir: { std::string const ambient_temp_outdoor_node = - ip->getAlphaFieldValue(fields, objectSchemaProps, "ambient_temperature_outdoor_air_node_name"); + s_ip->getAlphaFieldValue(fields, objectSchemaProps, "ambient_temperature_outdoor_air_node_name"); thisChiller.AmbientTempOutsideAirNode = NodeInputManager::GetOnlySingleNode(state, ambient_temp_outdoor_node, ErrorsFound, @@ -350,15 +352,15 @@ void getChillerASHRAE205Input(EnergyPlusData &state) format("{} = {}: Invalid Ambient Temperature Indicator entered={}", state.dataIPShortCut->cCurrentModuleObject, thisObjectName, - ip->getAlphaFieldValue(fields, objectSchemaProps, "ambient_temperature_indicator"))); + s_ip->getAlphaFieldValue(fields, objectSchemaProps, "ambient_temperature_indicator"))); ShowContinueError(state, " Valid entries are SCHEDULE, ZONE, and OUTDOORS."); ErrorsFound = true; break; } } // end Ambient temperature - std::string const oil_cooler_inlet_node = ip->getAlphaFieldValue(fields, objectSchemaProps, "oil_cooler_inlet_node_name"); - std::string const oil_cooler_outlet_node = ip->getAlphaFieldValue(fields, objectSchemaProps, "oil_cooler_outlet_node_name"); + std::string const oil_cooler_inlet_node = s_ip->getAlphaFieldValue(fields, objectSchemaProps, "oil_cooler_inlet_node_name"); + std::string const oil_cooler_outlet_node = s_ip->getAlphaFieldValue(fields, objectSchemaProps, "oil_cooler_outlet_node_name"); if (!oil_cooler_inlet_node.empty() && !oil_cooler_outlet_node.empty()) { thisChiller.OilCoolerInletNode = NodeInputManager::GetOnlySingleNode(state, oil_cooler_inlet_node, @@ -385,8 +387,8 @@ void getChillerASHRAE205Input(EnergyPlusData &state) oil_cooler_outlet_node, "Oil Cooler Water Nodes"); } - std::string const aux_heat_inlet_node = ip->getAlphaFieldValue(fields, objectSchemaProps, "auxiliary_inlet_node_name"); - std::string const aux_heat_outlet_node = ip->getAlphaFieldValue(fields, objectSchemaProps, "auxiliary_outlet_node_name"); + std::string const aux_heat_inlet_node = s_ip->getAlphaFieldValue(fields, objectSchemaProps, "auxiliary_inlet_node_name"); + std::string const aux_heat_outlet_node = s_ip->getAlphaFieldValue(fields, objectSchemaProps, "auxiliary_outlet_node_name"); if (!aux_heat_inlet_node.empty() && !aux_heat_outlet_node.empty()) { thisChiller.AuxiliaryHeatInletNode = NodeInputManager::GetOnlySingleNode(state, @@ -424,7 +426,7 @@ void getChillerASHRAE205Input(EnergyPlusData &state) } if (fields.count("end_use_subcategory")) { - thisChiller.EndUseSubcategory = ip->getAlphaFieldValue(fields, objectSchemaProps, "end_use_subcategory"); + thisChiller.EndUseSubcategory = s_ip->getAlphaFieldValue(fields, objectSchemaProps, "end_use_subcategory"); } else { thisChiller.EndUseSubcategory = "General"; } @@ -579,7 +581,7 @@ void ASHRAE205ChillerSpecs::initialize(EnergyPlusData &state, bool const RunFlag switch (this->AmbientTempType) { case AmbientTempIndicator::Schedule: { - this->AmbientTemp = ScheduleManager::GetCurrentScheduleValue(state, this->AmbientTempSchedule); + this->AmbientTemp = this->ambientTempSched->getCurrentVal(); break; } case AmbientTempIndicator::TempZone: { @@ -675,8 +677,8 @@ void ASHRAE205ChillerSpecs::initialize(EnergyPlusData &state, bool const RunFlag // check if inlet limit active and if exceeded. bool HeatRecRunFlag = RunFlag; - if (this->HeatRecInletLimitSchedNum > 0) { - Real64 HeatRecHighInletLimit = ScheduleManager::GetCurrentScheduleValue(state, this->HeatRecInletLimitSchedNum); + if (this->heatRecInletLimitSched != nullptr) { + Real64 HeatRecHighInletLimit = this->heatRecInletLimitSched->getCurrentVal(); if (state.dataLoopNodes->Node(this->HeatRecInletNodeNum).Temp > HeatRecHighInletLimit) { // shut down heat recovery HeatRecRunFlag = false; } else { diff --git a/src/EnergyPlus/ChillerElectricASHRAE205.hh b/src/EnergyPlus/ChillerElectricASHRAE205.hh index d9672a179f0..770c195f67b 100644 --- a/src/EnergyPlus/ChillerElectricASHRAE205.hh +++ b/src/EnergyPlus/ChillerElectricASHRAE205.hh @@ -100,7 +100,7 @@ namespace ChillerElectricASHRAE205 { Real64 AuxiliaryEnergy{0}; AmbientTempIndicator AmbientTempType{AmbientTempIndicator::Invalid}; - int AmbientTempSchedule{0}; // Schedule index pointer + Sched::Schedule *ambientTempSched = nullptr; int AmbientTempZone{0}; // Number of ambient zone around tank int AmbientTempOutsideAirNode{0}; // Number of outside air node Real64 AmbientTemp{0}; @@ -150,6 +150,10 @@ struct ChillerElectricASHRAE205Data : BaseGlobalStruct bool getInputFlag = true; Array1D Electric205Chiller; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/ChillerElectricEIR.cc b/src/EnergyPlus/ChillerElectricEIR.cc index 4ffc4585300..c3bf642fc0c 100644 --- a/src/EnergyPlus/ChillerElectricEIR.cc +++ b/src/EnergyPlus/ChillerElectricEIR.cc @@ -221,14 +221,17 @@ void GetElectricEIRChillerInput(EnergyPlusData &state) // This routine will get the input required by the Electric EIR Chiller model. static constexpr std::string_view RoutineName("GetElectricEIRChillerInput: "); // include trailing blank space + static constexpr std::string_view routineName = "GetElectricEIRChillerInput"; // include trailing blank space bool ErrorsFound(false); // True when input errors are found - state.dataIPShortCut->cCurrentModuleObject = "Chiller:Electric:EIR"; - int NumElectricEIRChillers = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, state.dataIPShortCut->cCurrentModuleObject); + auto &s_ipsc = state.dataIPShortCut; + + s_ipsc->cCurrentModuleObject = "Chiller:Electric:EIR"; + int NumElectricEIRChillers = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, s_ipsc->cCurrentModuleObject); if (NumElectricEIRChillers <= 0) { - ShowSevereError(state, format("No {} equipment specified in input file", state.dataIPShortCut->cCurrentModuleObject)); + ShowSevereError(state, format("No {} equipment specified in input file", s_ipsc->cCurrentModuleObject)); ErrorsFound = true; } @@ -241,87 +244,89 @@ void GetElectricEIRChillerInput(EnergyPlusData &state) int NumNums = 0; // Number of elements in the numeric array int IOStat = 0; // IO Status when calling get input subroutine state.dataInputProcessing->inputProcessor->getObjectItem(state, - state.dataIPShortCut->cCurrentModuleObject, + s_ipsc->cCurrentModuleObject, EIRChillerNum, - state.dataIPShortCut->cAlphaArgs, + s_ipsc->cAlphaArgs, NumAlphas, - state.dataIPShortCut->rNumericArgs, + s_ipsc->rNumericArgs, NumNums, IOStat, - state.dataIPShortCut->lNumericFieldBlanks, - state.dataIPShortCut->lAlphaFieldBlanks, - state.dataIPShortCut->cAlphaFieldNames, - state.dataIPShortCut->cNumericFieldNames); + s_ipsc->lNumericFieldBlanks, + s_ipsc->lAlphaFieldBlanks, + s_ipsc->cAlphaFieldNames, + s_ipsc->cNumericFieldNames); + ErrorObjectHeader eoh{routineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)}; + // ErrorsFound will be set to True if problem was found, left untouched otherwise GlobalNames::VerifyUniqueChillerName(state, - state.dataIPShortCut->cCurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), + s_ipsc->cCurrentModuleObject, + s_ipsc->cAlphaArgs(1), ErrorsFound, - state.dataIPShortCut->cCurrentModuleObject + " Name"); + s_ipsc->cCurrentModuleObject + " Name"); auto &thisChiller = state.dataChillerElectricEIR->ElectricEIRChiller(EIRChillerNum); - thisChiller.Name = state.dataIPShortCut->cAlphaArgs(1); + thisChiller.Name = s_ipsc->cAlphaArgs(1); // Performance curves - thisChiller.ChillerCapFTIndex = Curve::GetCurveIndex(state, state.dataIPShortCut->cAlphaArgs(2)); + thisChiller.ChillerCapFTIndex = Curve::GetCurveIndex(state, s_ipsc->cAlphaArgs(2)); if (thisChiller.ChillerCapFTIndex == 0) { ShowSevereError(state, - format("{}{} \"{}\"", RoutineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("Invalid {}={}", state.dataIPShortCut->cAlphaFieldNames(2), state.dataIPShortCut->cAlphaArgs(2))); + format("{}{} \"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); + ShowContinueError(state, format("Invalid {}={}", s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2))); ErrorsFound = true; } - thisChiller.ChillerEIRFTIndex = Curve::GetCurveIndex(state, state.dataIPShortCut->cAlphaArgs(3)); + thisChiller.ChillerEIRFTIndex = Curve::GetCurveIndex(state, s_ipsc->cAlphaArgs(3)); if (thisChiller.ChillerEIRFTIndex == 0) { ShowSevereError(state, - format("{}{}=\"{}\"", RoutineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("Invalid {}={}", state.dataIPShortCut->cAlphaFieldNames(3), state.dataIPShortCut->cAlphaArgs(3))); + format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); + ShowContinueError(state, format("Invalid {}={}", s_ipsc->cAlphaFieldNames(3), s_ipsc->cAlphaArgs(3))); ErrorsFound = true; } - thisChiller.ChillerEIRFPLRIndex = Curve::GetCurveIndex(state, state.dataIPShortCut->cAlphaArgs(4)); + thisChiller.ChillerEIRFPLRIndex = Curve::GetCurveIndex(state, s_ipsc->cAlphaArgs(4)); if (thisChiller.ChillerEIRFPLRIndex == 0) { ShowSevereError(state, - format("{}{}=\"{}\"", RoutineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("Invalid {}={}", state.dataIPShortCut->cAlphaFieldNames(4), state.dataIPShortCut->cAlphaArgs(4))); + format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); + ShowContinueError(state, format("Invalid {}={}", s_ipsc->cAlphaFieldNames(4), s_ipsc->cAlphaArgs(4))); ErrorsFound = true; } thisChiller.EvapInletNodeNum = NodeInputManager::GetOnlySingleNode(state, - state.dataIPShortCut->cAlphaArgs(5), + s_ipsc->cAlphaArgs(5), ErrorsFound, DataLoopNode::ConnectionObjectType::ChillerElectricEIR, - state.dataIPShortCut->cAlphaArgs(1), + s_ipsc->cAlphaArgs(1), DataLoopNode::NodeFluidType::Water, DataLoopNode::ConnectionType::Inlet, NodeInputManager::CompFluidStream::Primary, DataLoopNode::ObjectIsNotParent); thisChiller.EvapOutletNodeNum = NodeInputManager::GetOnlySingleNode(state, - state.dataIPShortCut->cAlphaArgs(6), + s_ipsc->cAlphaArgs(6), ErrorsFound, DataLoopNode::ConnectionObjectType::ChillerElectricEIR, - state.dataIPShortCut->cAlphaArgs(1), + s_ipsc->cAlphaArgs(1), DataLoopNode::NodeFluidType::Water, DataLoopNode::ConnectionType::Outlet, NodeInputManager::CompFluidStream::Primary, DataLoopNode::ObjectIsNotParent); BranchNodeConnections::TestCompSet(state, - state.dataIPShortCut->cCurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaArgs(5), - state.dataIPShortCut->cAlphaArgs(6), + s_ipsc->cCurrentModuleObject, + s_ipsc->cAlphaArgs(1), + s_ipsc->cAlphaArgs(5), + s_ipsc->cAlphaArgs(6), "Chilled Water Nodes"); - if (Util::SameString(state.dataIPShortCut->cAlphaArgs(9), "WaterCooled")) { + if (Util::SameString(s_ipsc->cAlphaArgs(9), "WaterCooled")) { thisChiller.CondenserType = DataPlant::CondenserType::WaterCooled; - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(9), "AirCooled")) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(9), "AirCooled")) { thisChiller.CondenserType = DataPlant::CondenserType::AirCooled; - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(9), "EvaporativelyCooled")) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(9), "EvaporativelyCooled")) { thisChiller.CondenserType = DataPlant::CondenserType::EvapCooled; } else { - ShowSevereError(state, format("{}{}: {}", RoutineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("Invalid {}={}", state.dataIPShortCut->cAlphaFieldNames(9), state.dataIPShortCut->cAlphaArgs(9))); + ShowSevereError(state, format("{}{}: {}", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); + ShowContinueError(state, format("Invalid {}={}", s_ipsc->cAlphaFieldNames(9), s_ipsc->cAlphaArgs(9))); ShowContinueError(state, "Valid entries are AirCooled, WaterCooled, or EvaporativelyCooled"); ErrorsFound = true; } @@ -330,26 +335,26 @@ void GetElectricEIRChillerInput(EnergyPlusData &state) // Connection not required for air or evap cooled condenser // If the condenser inlet is blank for air cooled and evap cooled condensers then supply a generic name // since it is not used elsewhere for connection - if (state.dataIPShortCut->lAlphaFieldBlanks(7)) { - if (len(state.dataIPShortCut->cAlphaArgs(1)) < Constant::MaxNameLength - 25) { // protect against long name leading to > 100 chars - state.dataIPShortCut->cAlphaArgs(7) = state.dataIPShortCut->cAlphaArgs(1) + " INLET NODE FOR CONDENSER"; + if (s_ipsc->lAlphaFieldBlanks(7)) { + if (len(s_ipsc->cAlphaArgs(1)) < Constant::MaxNameLength - 25) { // protect against long name leading to > 100 chars + s_ipsc->cAlphaArgs(7) = s_ipsc->cAlphaArgs(1) + " INLET NODE FOR CONDENSER"; } else { - state.dataIPShortCut->cAlphaArgs(7) = state.dataIPShortCut->cAlphaArgs(1).substr(0, 75) + " INLET NODE FOR CONDENSER"; + s_ipsc->cAlphaArgs(7) = s_ipsc->cAlphaArgs(1).substr(0, 75) + " INLET NODE FOR CONDENSER"; } } - if (state.dataIPShortCut->lAlphaFieldBlanks(8)) { - if (len(state.dataIPShortCut->cAlphaArgs(1)) < Constant::MaxNameLength - 26) { // protect against long name leading to > 100 chars - state.dataIPShortCut->cAlphaArgs(8) = state.dataIPShortCut->cAlphaArgs(1) + " OUTLET NODE FOR CONDENSER"; + if (s_ipsc->lAlphaFieldBlanks(8)) { + if (len(s_ipsc->cAlphaArgs(1)) < Constant::MaxNameLength - 26) { // protect against long name leading to > 100 chars + s_ipsc->cAlphaArgs(8) = s_ipsc->cAlphaArgs(1) + " OUTLET NODE FOR CONDENSER"; } else { - state.dataIPShortCut->cAlphaArgs(8) = state.dataIPShortCut->cAlphaArgs(1).substr(0, 74) + " OUTLET NODE FOR CONDENSER"; + s_ipsc->cAlphaArgs(8) = s_ipsc->cAlphaArgs(1).substr(0, 74) + " OUTLET NODE FOR CONDENSER"; } } thisChiller.CondInletNodeNum = NodeInputManager::GetOnlySingleNode(state, - state.dataIPShortCut->cAlphaArgs(7), + s_ipsc->cAlphaArgs(7), ErrorsFound, DataLoopNode::ConnectionObjectType::ChillerElectricEIR, - state.dataIPShortCut->cAlphaArgs(1), + s_ipsc->cAlphaArgs(1), DataLoopNode::NodeFluidType::Air, DataLoopNode::ConnectionType::OutsideAirReference, NodeInputManager::CompFluidStream::Secondary, @@ -358,15 +363,15 @@ void GetElectricEIRChillerInput(EnergyPlusData &state) OutAirNodeManager::CheckAndAddAirNodeNumber(state, thisChiller.CondInletNodeNum, Okay); if (!Okay) { ShowWarningError(state, - format("{}{}=\"{}\"", RoutineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("Adding OutdoorAir:Node={}", state.dataIPShortCut->cAlphaArgs(7))); + format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); + ShowContinueError(state, format("Adding OutdoorAir:Node={}", s_ipsc->cAlphaArgs(7))); } thisChiller.CondOutletNodeNum = NodeInputManager::GetOnlySingleNode(state, - state.dataIPShortCut->cAlphaArgs(8), + s_ipsc->cAlphaArgs(8), ErrorsFound, DataLoopNode::ConnectionObjectType::ChillerElectricEIR, - state.dataIPShortCut->cAlphaArgs(1), + s_ipsc->cAlphaArgs(1), DataLoopNode::NodeFluidType::Air, DataLoopNode::ConnectionType::Outlet, NodeInputManager::CompFluidStream::Secondary, @@ -374,222 +379,222 @@ void GetElectricEIRChillerInput(EnergyPlusData &state) } else if (thisChiller.CondenserType == DataPlant::CondenserType::WaterCooled) { // Condenser inlet node name is necessary for water-cooled condenser - if (state.dataIPShortCut->lAlphaFieldBlanks(7) || state.dataIPShortCut->lAlphaFieldBlanks(8)) { + if (s_ipsc->lAlphaFieldBlanks(7) || s_ipsc->lAlphaFieldBlanks(8)) { ShowSevereError(state, - format("{}{}=\"{}\"", RoutineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); + format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); ShowContinueError(state, "Condenser Inlet or Outlet Node Name is blank."); ErrorsFound = true; } thisChiller.CondInletNodeNum = NodeInputManager::GetOnlySingleNode(state, - state.dataIPShortCut->cAlphaArgs(7), + s_ipsc->cAlphaArgs(7), ErrorsFound, DataLoopNode::ConnectionObjectType::ChillerElectricEIR, - state.dataIPShortCut->cAlphaArgs(1), + s_ipsc->cAlphaArgs(1), DataLoopNode::NodeFluidType::Water, DataLoopNode::ConnectionType::Inlet, NodeInputManager::CompFluidStream::Secondary, DataLoopNode::ObjectIsNotParent); thisChiller.CondOutletNodeNum = NodeInputManager::GetOnlySingleNode(state, - state.dataIPShortCut->cAlphaArgs(8), + s_ipsc->cAlphaArgs(8), ErrorsFound, DataLoopNode::ConnectionObjectType::ChillerElectricEIR, - state.dataIPShortCut->cAlphaArgs(1), + s_ipsc->cAlphaArgs(1), DataLoopNode::NodeFluidType::Water, DataLoopNode::ConnectionType::Outlet, NodeInputManager::CompFluidStream::Secondary, DataLoopNode::ObjectIsNotParent); BranchNodeConnections::TestCompSet(state, - state.dataIPShortCut->cCurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaArgs(7), - state.dataIPShortCut->cAlphaArgs(8), + s_ipsc->cCurrentModuleObject, + s_ipsc->cAlphaArgs(1), + s_ipsc->cAlphaArgs(7), + s_ipsc->cAlphaArgs(8), "Condenser Water Nodes"); } else { // Condenser inlet node name is necessary (never should reach this part of code) - if (state.dataIPShortCut->lAlphaFieldBlanks(7) || state.dataIPShortCut->lAlphaFieldBlanks(8)) { + if (s_ipsc->lAlphaFieldBlanks(7) || s_ipsc->lAlphaFieldBlanks(8)) { ShowSevereError(state, - format("{}{}=\"{}\"", RoutineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); + format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); ShowContinueError(state, "Condenser Inlet or Outlet Node Name is blank."); ErrorsFound = true; } thisChiller.CondInletNodeNum = NodeInputManager::GetOnlySingleNode(state, - state.dataIPShortCut->cAlphaArgs(7), + s_ipsc->cAlphaArgs(7), ErrorsFound, DataLoopNode::ConnectionObjectType::ChillerElectricEIR, - state.dataIPShortCut->cAlphaArgs(1), + s_ipsc->cAlphaArgs(1), DataLoopNode::NodeFluidType::Blank, DataLoopNode::ConnectionType::Inlet, NodeInputManager::CompFluidStream::Secondary, DataLoopNode::ObjectIsNotParent); thisChiller.CondOutletNodeNum = NodeInputManager::GetOnlySingleNode(state, - state.dataIPShortCut->cAlphaArgs(8), + s_ipsc->cAlphaArgs(8), ErrorsFound, DataLoopNode::ConnectionObjectType::ChillerElectricEIR, - state.dataIPShortCut->cAlphaArgs(1), + s_ipsc->cAlphaArgs(1), DataLoopNode::NodeFluidType::Blank, DataLoopNode::ConnectionType::Outlet, NodeInputManager::CompFluidStream::Secondary, DataLoopNode::ObjectIsNotParent); BranchNodeConnections::TestCompSet(state, - state.dataIPShortCut->cCurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaArgs(7), - state.dataIPShortCut->cAlphaArgs(8), + s_ipsc->cCurrentModuleObject, + s_ipsc->cAlphaArgs(1), + s_ipsc->cAlphaArgs(7), + s_ipsc->cAlphaArgs(8), "Condenser (unknown?) Nodes"); } - thisChiller.FlowMode = static_cast(getEnumValue(DataPlant::FlowModeNamesUC, state.dataIPShortCut->cAlphaArgs(10))); + thisChiller.FlowMode = static_cast(getEnumValue(DataPlant::FlowModeNamesUC, s_ipsc->cAlphaArgs(10))); if (thisChiller.FlowMode == DataPlant::FlowMode::Invalid) { ShowSevereError(state, - format("{}{}=\"{}\",", RoutineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("Invalid {}={}", state.dataIPShortCut->cAlphaFieldNames(10), state.dataIPShortCut->cAlphaArgs(10))); + format("{}{}=\"{}\",", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); + ShowContinueError(state, format("Invalid {}={}", s_ipsc->cAlphaFieldNames(10), s_ipsc->cAlphaArgs(10))); ShowContinueError(state, "Available choices are ConstantFlow, NotModulated, or LeavingSetpointModulated"); ShowContinueError(state, "Flow mode NotModulated is assumed and the simulation continues."); thisChiller.FlowMode = DataPlant::FlowMode::NotModulated; }; // Chiller rated performance data - thisChiller.RefCap = state.dataIPShortCut->rNumericArgs(1); + thisChiller.RefCap = s_ipsc->rNumericArgs(1); if (thisChiller.RefCap == DataSizing::AutoSize) { thisChiller.RefCapWasAutoSized = true; } - if (state.dataIPShortCut->rNumericArgs(1) == 0.0) { + if (s_ipsc->rNumericArgs(1) == 0.0) { ShowSevereError(state, - format("{}{}=\"{}\"", RoutineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("Invalid {}={:.2R}", state.dataIPShortCut->cNumericFieldNames(1), state.dataIPShortCut->rNumericArgs(1))); + format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); + ShowContinueError(state, format("Invalid {}={:.2R}", s_ipsc->cNumericFieldNames(1), s_ipsc->rNumericArgs(1))); ErrorsFound = true; } - thisChiller.RefCOP = state.dataIPShortCut->rNumericArgs(2); - if (state.dataIPShortCut->rNumericArgs(2) == 0.0) { + thisChiller.RefCOP = s_ipsc->rNumericArgs(2); + if (s_ipsc->rNumericArgs(2) == 0.0) { ShowSevereError(state, - format("{}{}=\"{}\"", RoutineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("Invalid {}={:.2R}", state.dataIPShortCut->cNumericFieldNames(2), state.dataIPShortCut->rNumericArgs(2))); + format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); + ShowContinueError(state, format("Invalid {}={:.2R}", s_ipsc->cNumericFieldNames(2), s_ipsc->rNumericArgs(2))); ErrorsFound = true; } - thisChiller.TempRefEvapOut = state.dataIPShortCut->rNumericArgs(3); - thisChiller.TempRefCondIn = state.dataIPShortCut->rNumericArgs(4); - thisChiller.EvapVolFlowRate = state.dataIPShortCut->rNumericArgs(5); + thisChiller.TempRefEvapOut = s_ipsc->rNumericArgs(3); + thisChiller.TempRefCondIn = s_ipsc->rNumericArgs(4); + thisChiller.EvapVolFlowRate = s_ipsc->rNumericArgs(5); if (thisChiller.EvapVolFlowRate == DataSizing::AutoSize) { thisChiller.EvapVolFlowRateWasAutoSized = true; } - thisChiller.CondVolFlowRate = state.dataIPShortCut->rNumericArgs(6); + thisChiller.CondVolFlowRate = s_ipsc->rNumericArgs(6); if (thisChiller.CondVolFlowRate == DataSizing::AutoSize) { thisChiller.CondVolFlowRateWasAutoSized = true; } - thisChiller.MinPartLoadRat = state.dataIPShortCut->rNumericArgs(7); - thisChiller.MaxPartLoadRat = state.dataIPShortCut->rNumericArgs(8); - thisChiller.OptPartLoadRat = state.dataIPShortCut->rNumericArgs(9); - thisChiller.MinUnloadRat = state.dataIPShortCut->rNumericArgs(10); - thisChiller.SizFac = state.dataIPShortCut->rNumericArgs(15); + thisChiller.MinPartLoadRat = s_ipsc->rNumericArgs(7); + thisChiller.MaxPartLoadRat = s_ipsc->rNumericArgs(8); + thisChiller.OptPartLoadRat = s_ipsc->rNumericArgs(9); + thisChiller.MinUnloadRat = s_ipsc->rNumericArgs(10); + thisChiller.SizFac = s_ipsc->rNumericArgs(15); if (thisChiller.SizFac <= 0.0) thisChiller.SizFac = 1.0; if (thisChiller.MinPartLoadRat > thisChiller.MaxPartLoadRat) { ShowSevereError(state, - format("{}{}=\"{}\"", RoutineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); + format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); ShowContinueError(state, format("{} [{:.3R}] > {} [{:.3R}]", - state.dataIPShortCut->cNumericFieldNames(7), - state.dataIPShortCut->rNumericArgs(7), - state.dataIPShortCut->cNumericFieldNames(8), - state.dataIPShortCut->rNumericArgs(8))); + s_ipsc->cNumericFieldNames(7), + s_ipsc->rNumericArgs(7), + s_ipsc->cNumericFieldNames(8), + s_ipsc->rNumericArgs(8))); ShowContinueError(state, "Minimum part load ratio must be less than or equal to the maximum part load ratio "); ErrorsFound = true; } if (thisChiller.MinUnloadRat < thisChiller.MinPartLoadRat || thisChiller.MinUnloadRat > thisChiller.MaxPartLoadRat) { ShowSevereError(state, - format("{}{}=\"{}\"", RoutineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("{} = {:.3R}", state.dataIPShortCut->cNumericFieldNames(10), state.dataIPShortCut->rNumericArgs(10))); + format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); + ShowContinueError(state, format("{} = {:.3R}", s_ipsc->cNumericFieldNames(10), s_ipsc->rNumericArgs(10))); ShowContinueError(state, format("{} must be greater than or equal to the {}", - state.dataIPShortCut->cNumericFieldNames(10), - state.dataIPShortCut->cNumericFieldNames(7))); + s_ipsc->cNumericFieldNames(10), + s_ipsc->cNumericFieldNames(7))); ShowContinueError(state, format("{} must be less than or equal to the {}", - state.dataIPShortCut->cNumericFieldNames(10), - state.dataIPShortCut->cNumericFieldNames(8))); + s_ipsc->cNumericFieldNames(10), + s_ipsc->cNumericFieldNames(8))); ErrorsFound = true; } if (thisChiller.OptPartLoadRat < thisChiller.MinPartLoadRat || thisChiller.OptPartLoadRat > thisChiller.MaxPartLoadRat) { ShowSevereError(state, - format("{}{}=\"{}\"", RoutineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("{} = {:.3R}", state.dataIPShortCut->cNumericFieldNames(9), state.dataIPShortCut->rNumericArgs(9))); + format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); + ShowContinueError(state, format("{} = {:.3R}", s_ipsc->cNumericFieldNames(9), s_ipsc->rNumericArgs(9))); ShowContinueError(state, format("{} must be greater than or equal to the {}", - state.dataIPShortCut->cNumericFieldNames(9), - state.dataIPShortCut->cNumericFieldNames(7))); + s_ipsc->cNumericFieldNames(9), + s_ipsc->cNumericFieldNames(7))); ShowContinueError(state, format("{} must be less than or equal to the {}", - state.dataIPShortCut->cNumericFieldNames(9), - state.dataIPShortCut->cNumericFieldNames(8))); + s_ipsc->cNumericFieldNames(9), + s_ipsc->cNumericFieldNames(8))); ErrorsFound = true; } - thisChiller.CondenserFanPowerRatio = state.dataIPShortCut->rNumericArgs(11); - thisChiller.CompPowerToCondenserFrac = state.dataIPShortCut->rNumericArgs(12); + thisChiller.CondenserFanPowerRatio = s_ipsc->rNumericArgs(11); + thisChiller.CompPowerToCondenserFrac = s_ipsc->rNumericArgs(12); if (thisChiller.CompPowerToCondenserFrac < 0.0 || thisChiller.CompPowerToCondenserFrac > 1.0) { ShowSevereError(state, - format("{}{}=\"{}\"", RoutineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("{} = {:.3R}", state.dataIPShortCut->cNumericFieldNames(12), state.dataIPShortCut->rNumericArgs(12))); - ShowContinueError(state, format("{} must be greater than or equal to zero", state.dataIPShortCut->cNumericFieldNames(12))); - ShowContinueError(state, format("{} must be less than or equal to one", state.dataIPShortCut->cNumericFieldNames(12))); + format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); + ShowContinueError(state, format("{} = {:.3R}", s_ipsc->cNumericFieldNames(12), s_ipsc->rNumericArgs(12))); + ShowContinueError(state, format("{} must be greater than or equal to zero", s_ipsc->cNumericFieldNames(12))); + ShowContinueError(state, format("{} must be less than or equal to one", s_ipsc->cNumericFieldNames(12))); ErrorsFound = true; } - thisChiller.TempLowLimitEvapOut = state.dataIPShortCut->rNumericArgs(13); + thisChiller.TempLowLimitEvapOut = s_ipsc->rNumericArgs(13); // These are the heat recovery inputs - thisChiller.DesignHeatRecVolFlowRate = state.dataIPShortCut->rNumericArgs(14); + thisChiller.DesignHeatRecVolFlowRate = s_ipsc->rNumericArgs(14); if (thisChiller.DesignHeatRecVolFlowRate == DataSizing::AutoSize) { thisChiller.DesignHeatRecVolFlowRateWasAutoSized = true; } if ((thisChiller.DesignHeatRecVolFlowRate > 0.0) || (thisChiller.DesignHeatRecVolFlowRate == DataSizing::AutoSize)) { thisChiller.HeatRecActive = true; thisChiller.HeatRecInletNodeNum = NodeInputManager::GetOnlySingleNode(state, - state.dataIPShortCut->cAlphaArgs(11), + s_ipsc->cAlphaArgs(11), ErrorsFound, DataLoopNode::ConnectionObjectType::ChillerElectricEIR, - state.dataIPShortCut->cAlphaArgs(1), + s_ipsc->cAlphaArgs(1), DataLoopNode::NodeFluidType::Water, DataLoopNode::ConnectionType::Inlet, NodeInputManager::CompFluidStream::Tertiary, DataLoopNode::ObjectIsNotParent); if (thisChiller.HeatRecInletNodeNum == 0) { ShowSevereError(state, - format("{}{}=\"{}\"", RoutineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("Invalid {}={}", state.dataIPShortCut->cAlphaFieldNames(11), state.dataIPShortCut->cAlphaArgs(11))); + format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); + ShowContinueError(state, format("Invalid {}={}", s_ipsc->cAlphaFieldNames(11), s_ipsc->cAlphaArgs(11))); ErrorsFound = true; } thisChiller.HeatRecOutletNodeNum = NodeInputManager::GetOnlySingleNode(state, - state.dataIPShortCut->cAlphaArgs(12), + s_ipsc->cAlphaArgs(12), ErrorsFound, DataLoopNode::ConnectionObjectType::ChillerElectricEIR, - state.dataIPShortCut->cAlphaArgs(1), + s_ipsc->cAlphaArgs(1), DataLoopNode::NodeFluidType::Water, DataLoopNode::ConnectionType::Outlet, NodeInputManager::CompFluidStream::Tertiary, DataLoopNode::ObjectIsNotParent); if (thisChiller.HeatRecOutletNodeNum == 0) { ShowSevereError(state, - format("{}{}=\"{}\"", RoutineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("Invalid {}={}", state.dataIPShortCut->cAlphaFieldNames(12), state.dataIPShortCut->cAlphaArgs(12))); + format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); + ShowContinueError(state, format("Invalid {}={}", s_ipsc->cAlphaFieldNames(12), s_ipsc->cAlphaArgs(12))); ErrorsFound = true; } BranchNodeConnections::TestCompSet(state, - state.dataIPShortCut->cCurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaArgs(11), - state.dataIPShortCut->cAlphaArgs(12), + s_ipsc->cCurrentModuleObject, + s_ipsc->cAlphaArgs(1), + s_ipsc->cAlphaArgs(11), + s_ipsc->cAlphaArgs(12), "Heat Recovery Nodes"); // store heat recovery volume flow for plant sizing if (thisChiller.DesignHeatRecVolFlowRate > 0.0) { @@ -597,8 +602,8 @@ void GetElectricEIRChillerInput(EnergyPlusData &state) thisChiller.DesignHeatRecVolFlowRate); // CR 6953 } if (NumNums > 17) { - if (!state.dataIPShortCut->lNumericFieldBlanks(18)) { - thisChiller.HeatRecCapacityFraction = state.dataIPShortCut->rNumericArgs(18); + if (!s_ipsc->lNumericFieldBlanks(18)) { + thisChiller.HeatRecCapacityFraction = s_ipsc->rNumericArgs(18); } else { thisChiller.HeatRecCapacityFraction = 1.0; } @@ -606,31 +611,20 @@ void GetElectricEIRChillerInput(EnergyPlusData &state) thisChiller.HeatRecCapacityFraction = 1.0; } - if (NumAlphas > 13) { - if (!state.dataIPShortCut->lAlphaFieldBlanks(14)) { - thisChiller.HeatRecInletLimitSchedNum = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(14)); - if (thisChiller.HeatRecInletLimitSchedNum == 0) { - ShowSevereError( - state, - format("{}{}=\"{}\"", RoutineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, - format("Invalid {}={}", state.dataIPShortCut->cAlphaFieldNames(14), state.dataIPShortCut->cAlphaArgs(14))); - ErrorsFound = true; - } - } else { - thisChiller.HeatRecInletLimitSchedNum = 0; + if (NumAlphas > 13 && !s_ipsc->lAlphaFieldBlanks(14)) { + if ((thisChiller.heatRecInletLimitSched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(14))) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(14), s_ipsc->cAlphaArgs(14)); + ErrorsFound = true; } - } else { - thisChiller.HeatRecInletLimitSchedNum = 0; - } + } if (NumAlphas > 14) { - if (!state.dataIPShortCut->lAlphaFieldBlanks(15)) { + if (!s_ipsc->lAlphaFieldBlanks(15)) { thisChiller.HeatRecSetPointNodeNum = NodeInputManager::GetOnlySingleNode(state, - state.dataIPShortCut->cAlphaArgs(15), + s_ipsc->cAlphaArgs(15), ErrorsFound, DataLoopNode::ConnectionObjectType::ChillerElectricEIR, - state.dataIPShortCut->cAlphaArgs(1), + s_ipsc->cAlphaArgs(1), DataLoopNode::NodeFluidType::Water, DataLoopNode::ConnectionType::Sensor, NodeInputManager::CompFluidStream::Primary, @@ -647,9 +641,9 @@ void GetElectricEIRChillerInput(EnergyPlusData &state) thisChiller.DesignHeatRecMassFlowRate = 0.0; thisChiller.HeatRecInletNodeNum = 0; thisChiller.HeatRecOutletNodeNum = 0; - if (!state.dataIPShortCut->lAlphaFieldBlanks(11) || !state.dataIPShortCut->lAlphaFieldBlanks(12)) { + if (!s_ipsc->lAlphaFieldBlanks(11) || !s_ipsc->lAlphaFieldBlanks(12)) { ShowWarningError(state, - format("{}{}=\"{}\"", RoutineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); + format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); ShowContinueError(state, "Since Reference Heat Reclaim Volume Flow Rate = 0.0, heat recovery is inactive."); ShowContinueError(state, "However, node names were specified for heat recovery inlet or outlet nodes."); } @@ -657,45 +651,41 @@ void GetElectricEIRChillerInput(EnergyPlusData &state) if (NumAlphas > 16) { thisChiller.CondenserFlowControl = static_cast( - getEnumValue(DataPlant::CondenserFlowControlNamesUC, state.dataIPShortCut->cAlphaArgs(17))); + getEnumValue(DataPlant::CondenserFlowControlNamesUC, s_ipsc->cAlphaArgs(17))); } else { thisChiller.CondenserFlowControl = DataPlant::CondenserFlowControl::ConstantFlow; } if (thisChiller.CondenserFlowControl == DataPlant::CondenserFlowControl::Invalid) { ShowSevereError(state, - format("{}{}=\"{}\",", RoutineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("Invalid {}={}", state.dataIPShortCut->cAlphaFieldNames(17), state.dataIPShortCut->cAlphaArgs(17))); + format("{}{}=\"{}\",", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); + ShowContinueError(state, format("Invalid {}={}", s_ipsc->cAlphaFieldNames(17), s_ipsc->cAlphaArgs(17))); ShowContinueError(state, "Available choices are ConstantFlow, ModulatedChillerPLR, ModulatedLoopPLR, or ModulatedDeltaTemperature"); ShowContinueError(state, "Flow mode ConstantFlow is assumed and the simulation continues."); thisChiller.CondenserFlowControl = DataPlant::CondenserFlowControl::ConstantFlow; }; if (NumAlphas > 17) { - thisChiller.ChillerCondLoopFlowFLoopPLRIndex = Curve::GetCurveIndex(state, state.dataIPShortCut->cAlphaArgs(18)); + thisChiller.ChillerCondLoopFlowFLoopPLRIndex = Curve::GetCurveIndex(state, s_ipsc->cAlphaArgs(18)); } if ((thisChiller.ChillerCondLoopFlowFLoopPLRIndex == 0) && (thisChiller.CondenserFlowControl == DataPlant::CondenserFlowControl::ModulatedLoopPLR)) { ShowSevereError(state, - format("{}{} \"{}\"", RoutineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("Invalid {}={}", state.dataIPShortCut->cAlphaFieldNames(18), state.dataIPShortCut->cAlphaArgs(18))); + format("{}{} \"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); + ShowContinueError(state, format("Invalid {}={}", s_ipsc->cAlphaFieldNames(18), s_ipsc->cAlphaArgs(18))); ErrorsFound = true; } - if (NumAlphas > 18) { - if (!state.dataIPShortCut->lAlphaFieldBlanks(19)) { - thisChiller.CondDTScheduleNum = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(19)); - } + if (NumAlphas > 18 && !s_ipsc->lAlphaFieldBlanks(19)) { + thisChiller.condDTSched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(19)); } - if (thisChiller.CondDTScheduleNum == 0 && thisChiller.CondenserFlowControl == DataPlant::CondenserFlowControl::ModulatedDeltaTemperature) { - ShowSevereError(state, - format("{}{}=\"{}\"", RoutineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("Invalid {}={}", state.dataIPShortCut->cAlphaFieldNames(19), state.dataIPShortCut->cAlphaArgs(19))); + if (thisChiller.condDTSched == nullptr && thisChiller.CondenserFlowControl == DataPlant::CondenserFlowControl::ModulatedDeltaTemperature) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(19), s_ipsc->cAlphaArgs(19)); ErrorsFound = true; } if (NumNums > 18) { - thisChiller.MinCondFlowRatio = state.dataIPShortCut->rNumericArgs(19); + thisChiller.MinCondFlowRatio = s_ipsc->rNumericArgs(19); } // Check the CAP-FT, EIR-FT, and PLR curves and warn user if different from 1.0 by more than +-10% @@ -703,7 +693,7 @@ void GetElectricEIRChillerInput(EnergyPlusData &state) Real64 CurveVal = Curve::CurveValue(state, thisChiller.ChillerCapFTIndex, thisChiller.TempRefEvapOut, thisChiller.TempRefCondIn); if (CurveVal > 1.10 || CurveVal < 0.90) { ShowWarningError(state, - format("{}{}=\"{}\"", RoutineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); + format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); ShowContinueError( state, "Capacity ratio as a function of temperature curve output is not equal to 1.0 (+ or - 10%) at reference conditions."); ShowContinueError(state, format("Curve output at reference conditions = {:.3T}", CurveVal)); @@ -714,7 +704,7 @@ void GetElectricEIRChillerInput(EnergyPlusData &state) Real64 CurveVal = Curve::CurveValue(state, thisChiller.ChillerEIRFTIndex, thisChiller.TempRefEvapOut, thisChiller.TempRefCondIn); if (CurveVal > 1.10 || CurveVal < 0.90) { ShowWarningError(state, - format("{}{}=\"{}\"", RoutineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); + format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); ShowContinueError( state, "Energy input ratio as a function of temperature curve output is not equal to 1.0 (+ or - 10%) at reference conditions."); ShowContinueError(state, format("Curve output at reference conditions = {:.3T}", CurveVal)); @@ -726,7 +716,7 @@ void GetElectricEIRChillerInput(EnergyPlusData &state) if (CurveVal > 1.10 || CurveVal < 0.90) { ShowWarningError(state, - format("{}{}=\"{}\"", RoutineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); + format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); ShowContinueError( state, "Energy input ratio as a function of part-load ratio curve output is not equal to 1.0 (+ or - 10%) at reference conditions."); @@ -744,7 +734,7 @@ void GetElectricEIRChillerInput(EnergyPlusData &state) } if (FoundNegValue) { ShowSevereError(state, - format("{}{}=\"{}\"", RoutineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); + format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); ShowContinueError(state, "Energy input ratio as a function of part-load ratio curve shows negative values."); ShowContinueError(state, "EIR as a function of PLR curve output at various part-load ratios shown below:"); ShowContinueError(state, "PLR = 0.00 0.10 0.20 0.30 0.40 0.50 0.60 0.70 0.80 0.90 1.00"); @@ -753,15 +743,15 @@ void GetElectricEIRChillerInput(EnergyPlusData &state) } } // Basin heater power as a function of temperature must be greater than or equal to 0 - thisChiller.BasinHeaterPowerFTempDiff = state.dataIPShortCut->rNumericArgs(16); - if (state.dataIPShortCut->rNumericArgs(16) < 0.0) { + thisChiller.BasinHeaterPowerFTempDiff = s_ipsc->rNumericArgs(16); + if (s_ipsc->rNumericArgs(16) < 0.0) { ShowSevereError(state, - format("{}{}=\"{}\"", RoutineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("{} must be >= 0", state.dataIPShortCut->cNumericFieldNames(16))); + format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); + ShowContinueError(state, format("{} must be >= 0", s_ipsc->cNumericFieldNames(16))); ErrorsFound = true; } - thisChiller.BasinHeaterSetPointTemp = state.dataIPShortCut->rNumericArgs(17); + thisChiller.BasinHeaterSetPointTemp = s_ipsc->rNumericArgs(17); if (thisChiller.BasinHeaterPowerFTempDiff > 0.0) { if (NumNums < 17) { @@ -769,41 +759,37 @@ void GetElectricEIRChillerInput(EnergyPlusData &state) } if (thisChiller.BasinHeaterSetPointTemp < 2.0) { ShowWarningError(state, - format("{}{} \"{}\"", RoutineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("{} is less than 2 deg C. Freezing could occur.", state.dataIPShortCut->cNumericFieldNames(17))); + format("{}{} \"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); + ShowContinueError(state, format("{} is less than 2 deg C. Freezing could occur.", s_ipsc->cNumericFieldNames(17))); } } - if (!state.dataIPShortCut->lAlphaFieldBlanks(13)) { - thisChiller.BasinHeaterSchedulePtr = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(13)); - if (thisChiller.BasinHeaterSchedulePtr == 0) { - ShowWarningError(state, - format("{}{}=\"{}\"", RoutineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowWarningError(state, - format("{} \"{}\" was not found. Basin heater operation will not be modeled and the simulation continues", - state.dataIPShortCut->cAlphaFieldNames(13), - state.dataIPShortCut->cAlphaArgs(13))); + if (!s_ipsc->lAlphaFieldBlanks(13)) { + if ((thisChiller.basinHeaterSched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(13))) == nullptr) { + ShowWarningItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(13), s_ipsc->cAlphaArgs(13), + "Basin heater operation will not be modeled and the simulation continues"); + } } if (NumAlphas > 15) { - thisChiller.EndUseSubcategory = state.dataIPShortCut->cAlphaArgs(16); + thisChiller.EndUseSubcategory = s_ipsc->cAlphaArgs(16); } else { thisChiller.EndUseSubcategory = "General"; } - if (!state.dataIPShortCut->lAlphaFieldBlanks(20)) { - thisChiller.thermosiphonTempCurveIndex = Curve::GetCurveIndex(state, Util::makeUPPER(state.dataIPShortCut->cAlphaArgs(20))); + if (!s_ipsc->lAlphaFieldBlanks(20)) { + thisChiller.thermosiphonTempCurveIndex = Curve::GetCurveIndex(state, Util::makeUPPER(s_ipsc->cAlphaArgs(20))); if (thisChiller.thermosiphonTempCurveIndex == 0) { - ShowSevereError(state, format("{}{}=\"{}\"", RoutineName, state.dataIPShortCut->cCurrentModuleObject, thisChiller.Name)); - ShowContinueError(state, format("Invalid {} = {}", state.dataIPShortCut->cAlphaFieldNames(20), state.dataIPShortCut->cAlphaArgs(20))); + ShowSevereError(state, format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, thisChiller.Name)); + ShowContinueError(state, format("Invalid {} = {}", s_ipsc->cAlphaFieldNames(20), s_ipsc->cAlphaArgs(20))); ErrorsFound = true; } } - thisChiller.thermosiphonMinTempDiff = state.dataIPShortCut->rNumericArgs(20); + thisChiller.thermosiphonMinTempDiff = s_ipsc->rNumericArgs(20); } if (ErrorsFound) { - ShowFatalError(state, format("Errors found in processing input for {}", state.dataIPShortCut->cCurrentModuleObject)); + ShowFatalError(state, format("Errors found in processing input for {}", s_ipsc->cCurrentModuleObject)); } } @@ -1877,7 +1863,7 @@ void ElectricEIRChillerSpecs::calculate(EnergyPlusData &state, Real64 &MyLoad, b } if (this->CondenserType == DataPlant::CondenserType::EvapCooled) { CalcBasinHeaterPower( - state, this->BasinHeaterPowerFTempDiff, this->BasinHeaterSchedulePtr, this->BasinHeaterSetPointTemp, this->BasinHeaterPower); + state, this->BasinHeaterPowerFTempDiff, this->basinHeaterSched, this->BasinHeaterSetPointTemp, this->BasinHeaterPower); } this->PrintMessage = false; return; @@ -2190,7 +2176,7 @@ void ElectricEIRChillerSpecs::calculate(EnergyPlusData &state, Real64 &MyLoad, b MyLoad = 0.0; if (this->CondenserType == DataPlant::CondenserType::EvapCooled) { CalcBasinHeaterPower( - state, this->BasinHeaterPowerFTempDiff, this->BasinHeaterSchedulePtr, this->BasinHeaterSetPointTemp, this->BasinHeaterPower); + state, this->BasinHeaterPowerFTempDiff, this->basinHeaterSched, this->BasinHeaterSetPointTemp, this->BasinHeaterPower); } this->PrintMessage = false; return; @@ -2303,7 +2289,7 @@ void ElectricEIRChillerSpecs::calculate(EnergyPlusData &state, Real64 &MyLoad, b } if (this->QEvaporator == 0.0 && this->CondenserType == DataPlant::CondenserType::EvapCooled) { CalcBasinHeaterPower( - state, this->BasinHeaterPowerFTempDiff, this->BasinHeaterSchedulePtr, this->BasinHeaterSetPointTemp, this->BasinHeaterPower); + state, this->BasinHeaterPowerFTempDiff, this->basinHeaterSched, this->BasinHeaterSetPointTemp, this->BasinHeaterPower); } this->ChillerEIRFT = Curve::CurveValue(state, this->ChillerEIRFTIndex, this->EvapOutletTemp, AvgCondSinkTemp); @@ -2409,8 +2395,8 @@ void ElectricEIRChillerSpecs::calculate(EnergyPlusData &state, Real64 &MyLoad, b state.dataPlnt->PlantLoop(this->CWPlantLoc.loopNum).FluidIndex, RoutineName); Real64 condDT = 0.0; - if (this->CondDTScheduleNum > 0) { - condDT = ScheduleManager::GetCurrentScheduleValue(state, this->CondDTScheduleNum); + if (this->condDTSched != nullptr) { + condDT = this->condDTSched->getCurrentVal(); } this->CondMassFlowRate = this->QCondenser / (CpCond * condDT); } break; @@ -2552,8 +2538,8 @@ void ElectricEIRChillerSpecs::calcHeatRecovery(EnergyPlusData &state, } // check if limit on inlet is present and exceeded. - if (this->HeatRecInletLimitSchedNum > 0) { - Real64 HeatRecHighInletLimit = ScheduleManager::GetCurrentScheduleValue(state, this->HeatRecInletLimitSchedNum); + if (this->heatRecInletLimitSched != nullptr) { + Real64 HeatRecHighInletLimit = this->heatRecInletLimitSched->getCurrentVal(); if (heatRecInletTemp > HeatRecHighInletLimit) { // shut down heat recovery QHeatRec = 0.0; } diff --git a/src/EnergyPlus/ChillerElectricEIR.hh b/src/EnergyPlus/ChillerElectricEIR.hh index 83df4f2cef8..0d60120e08d 100644 --- a/src/EnergyPlus/ChillerElectricEIR.hh +++ b/src/EnergyPlus/ChillerElectricEIR.hh @@ -117,7 +117,7 @@ namespace ChillerElectricEIR { Real64 HeatRecCapacityFraction = 0.0; // user input for heat recovery capacity fraction [] Real64 HeatRecMaxCapacityLimit = 0.0; // Capacity limit for Heat recovery, one time calc [W] int HeatRecSetPointNodeNum = 0; // index for system node with the heat recover leaving setpoint - int HeatRecInletLimitSchedNum = 0; // index for schedule for the inlet high limit for heat recovery operation + Sched::Schedule *heatRecInletLimitSched = nullptr; // schedule for the inlet high limit for heat recovery operation int ChillerCapFTIndex = 0; // Index for the total cooling capacity modifier curve // (function of leaving chilled water temperature and // entering condenser fluid temperature) @@ -138,7 +138,7 @@ namespace ChillerElectricEIR { PlantLocation CWPlantLoc; // chilled water plant loop component index PlantLocation CDPlantLoc; // condenser water plant loop component index PlantLocation HRPlantLoc; // heat recovery water plant loop component index - int BasinHeaterSchedulePtr = 0; // Pointer to basin heater schedule + Sched::Schedule *basinHeaterSched = nullptr; // basin heater schedule int CondMassFlowIndex = 0; std::string MsgBuffer1; // - buffer to print warning messages on following time step std::string MsgBuffer2; // - buffer to print warning messages on following time step @@ -190,7 +190,7 @@ namespace ChillerElectricEIR { bool IPLVFlag = true; int ChillerCondLoopFlowFLoopPLRIndex = 0; // Condenser loop flow rate fraction function of loop PLR int CondDT = 0; // Temperature difference across condenser - int CondDTScheduleNum = 0; // Temperature difference across condenser schedule index + Sched::Schedule *condDTSched = nullptr; // Temperature difference across condenser schedule Real64 MinCondFlowRatio = 0.2; // Minimum condenser flow fraction DataBranchAirLoopPlant::ControlType EquipFlowCtrl = DataBranchAirLoopPlant::ControlType::Invalid; Real64 VSBranchPumpMinLimitMassFlowCond = 0.0; @@ -252,6 +252,10 @@ struct ChillerElectricEIRData : BaseGlobalStruct bool getInputFlag = true; Array1D ElectricEIRChiller; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/ChillerExhaustAbsorption.hh b/src/EnergyPlus/ChillerExhaustAbsorption.hh index 2fd35a83631..5670d87e417 100644 --- a/src/EnergyPlus/ChillerExhaustAbsorption.hh +++ b/src/EnergyPlus/ChillerExhaustAbsorption.hh @@ -222,6 +222,10 @@ struct ChillerExhaustAbsorptionData : BaseGlobalStruct bool Sim_GetInput = true; Array1D ExhaustAbsorber; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/ChillerGasAbsorption.hh b/src/EnergyPlus/ChillerGasAbsorption.hh index 82b23f2cfa4..a7040529ad0 100644 --- a/src/EnergyPlus/ChillerGasAbsorption.hh +++ b/src/EnergyPlus/ChillerGasAbsorption.hh @@ -222,6 +222,10 @@ struct ChillerGasAbsorptionData : BaseGlobalStruct bool getGasAbsorberInputs = true; Array1D GasAbsorber; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/ChillerIndirectAbsorption.hh b/src/EnergyPlus/ChillerIndirectAbsorption.hh index b3136eab293..db329bc6754 100644 --- a/src/EnergyPlus/ChillerIndirectAbsorption.hh +++ b/src/EnergyPlus/ChillerIndirectAbsorption.hh @@ -214,6 +214,10 @@ struct ChillerIndirectAbsoprtionData : BaseGlobalStruct bool GetInput = true; Array1D IndirectAbsorber; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/ChillerReformulatedEIR.cc b/src/EnergyPlus/ChillerReformulatedEIR.cc index d1922a404c9..192511d4a92 100644 --- a/src/EnergyPlus/ChillerReformulatedEIR.cc +++ b/src/EnergyPlus/ChillerReformulatedEIR.cc @@ -221,14 +221,17 @@ void GetElecReformEIRChillerInput(EnergyPlusData &state) // This routine will get the input required by the Reformulated Electric EIR Chiller model static constexpr std::string_view RoutineName("GetElecReformEIRChillerInput: "); // include trailing blank space + static constexpr std::string_view routineName = "GetElecReformEIRChillerInput"; bool ErrorsFound(false); // True when input errors found - state.dataIPShortCut->cCurrentModuleObject = "Chiller:Electric:ReformulatedEIR"; - int NumElecReformEIRChillers = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, state.dataIPShortCut->cCurrentModuleObject); + auto &s_ipsc = state.dataIPShortCut; + + s_ipsc->cCurrentModuleObject = "Chiller:Electric:ReformulatedEIR"; + int NumElecReformEIRChillers = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, s_ipsc->cCurrentModuleObject); if (NumElecReformEIRChillers <= 0) { - ShowSevereError(state, format("No {} equipment specified in input file", state.dataIPShortCut->cCurrentModuleObject)); + ShowSevereError(state, format("No {} equipment specified in input file", s_ipsc->cCurrentModuleObject)); ErrorsFound = true; } @@ -241,60 +244,62 @@ void GetElecReformEIRChillerInput(EnergyPlusData &state) int NumNums = 0; // Number of elements in the numeric array int IOStat = 0; // IO Status when calling get input subroutine state.dataInputProcessing->inputProcessor->getObjectItem(state, - state.dataIPShortCut->cCurrentModuleObject, + s_ipsc->cCurrentModuleObject, EIRChillerNum, - state.dataIPShortCut->cAlphaArgs, + s_ipsc->cAlphaArgs, NumAlphas, - state.dataIPShortCut->rNumericArgs, + s_ipsc->rNumericArgs, NumNums, IOStat, - state.dataIPShortCut->lNumericFieldBlanks, - state.dataIPShortCut->lAlphaFieldBlanks, - state.dataIPShortCut->cAlphaFieldNames, - state.dataIPShortCut->cNumericFieldNames); + s_ipsc->lNumericFieldBlanks, + s_ipsc->lAlphaFieldBlanks, + s_ipsc->cAlphaFieldNames, + s_ipsc->cNumericFieldNames); + ErrorObjectHeader eoh{routineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)}; + // ErrorsFound will be set to True if problem was found, left untouched otherwise GlobalNames::VerifyUniqueChillerName(state, - state.dataIPShortCut->cCurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), + s_ipsc->cCurrentModuleObject, + s_ipsc->cAlphaArgs(1), ErrorsFound, - state.dataIPShortCut->cCurrentModuleObject + " Name"); + s_ipsc->cCurrentModuleObject + " Name"); auto &thisChiller = state.dataChillerReformulatedEIR->ElecReformEIRChiller(EIRChillerNum); - thisChiller.Name = state.dataIPShortCut->cAlphaArgs(1); + thisChiller.Name = s_ipsc->cAlphaArgs(1); // Performance curves - thisChiller.ChillerCapFTIndex = Curve::GetCurveIndex(state, state.dataIPShortCut->cAlphaArgs(2)); - thisChiller.CAPFTName = state.dataIPShortCut->cAlphaArgs(2); + thisChiller.ChillerCapFTIndex = Curve::GetCurveIndex(state, s_ipsc->cAlphaArgs(2)); + thisChiller.CAPFTName = s_ipsc->cAlphaArgs(2); if (thisChiller.ChillerCapFTIndex == 0) { ShowSevereError(state, - format("{}{}=\"{}\"", RoutineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("Invalid {}={}", state.dataIPShortCut->cAlphaFieldNames(2), state.dataIPShortCut->cAlphaArgs(2))); + format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); + ShowContinueError(state, format("Invalid {}={}", s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2))); ErrorsFound = true; } - thisChiller.ChillerEIRFTIndex = Curve::GetCurveIndex(state, state.dataIPShortCut->cAlphaArgs(3)); - thisChiller.EIRFTName = state.dataIPShortCut->cAlphaArgs(3); + thisChiller.ChillerEIRFTIndex = Curve::GetCurveIndex(state, s_ipsc->cAlphaArgs(3)); + thisChiller.EIRFTName = s_ipsc->cAlphaArgs(3); if (thisChiller.ChillerEIRFTIndex == 0) { ShowSevereError(state, - format("{}{}=\"{}\"", RoutineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("Invalid {}={}", state.dataIPShortCut->cAlphaFieldNames(3), state.dataIPShortCut->cAlphaArgs(3))); + format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); + ShowContinueError(state, format("Invalid {}={}", s_ipsc->cAlphaFieldNames(3), s_ipsc->cAlphaArgs(3))); ErrorsFound = true; } // The default type of part-load curve is: LeavingCondenserWaterTemperature std::string PartLoadCurveType; // Part load curve type - if (state.dataIPShortCut->lAlphaFieldBlanks(4)) { + if (s_ipsc->lAlphaFieldBlanks(4)) { PartLoadCurveType = "LeavingCondenserWaterTemperature"; } else { - PartLoadCurveType = state.dataIPShortCut->cAlphaArgs(4); + PartLoadCurveType = s_ipsc->cAlphaArgs(4); } - thisChiller.EIRFPLRName = state.dataIPShortCut->cAlphaArgs(5); - thisChiller.ChillerEIRFPLRIndex = Curve::GetCurveIndex(state, state.dataIPShortCut->cAlphaArgs(5)); + thisChiller.EIRFPLRName = s_ipsc->cAlphaArgs(5); + thisChiller.ChillerEIRFPLRIndex = Curve::GetCurveIndex(state, s_ipsc->cAlphaArgs(5)); if (thisChiller.ChillerEIRFPLRIndex == 0) { ShowSevereError(state, - format("{}{}=\"{}\"", RoutineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("Invalid {}={}", state.dataIPShortCut->cAlphaFieldNames(5), state.dataIPShortCut->cAlphaArgs(5))); + format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); + ShowContinueError(state, format("Invalid {}={}", s_ipsc->cAlphaFieldNames(5), s_ipsc->cAlphaArgs(5))); ErrorsFound = true; } @@ -306,103 +311,103 @@ void GetElecReformEIRChillerInput(EnergyPlusData &state) thisChiller.PartLoadCurveType = PLR::Lift; } else { ShowSevereError(state, - format("{}{}=\"{}\"", RoutineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); + format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); ShowContinueError(state, format("Invalid {}={} for {}={}", - state.dataIPShortCut->cAlphaFieldNames(5), - state.dataIPShortCut->cAlphaArgs(5), - state.dataIPShortCut->cAlphaFieldNames(4), - state.dataIPShortCut->cAlphaArgs(4))); + s_ipsc->cAlphaFieldNames(5), + s_ipsc->cAlphaArgs(5), + s_ipsc->cAlphaFieldNames(4), + s_ipsc->cAlphaArgs(4))); ErrorsFound = true; } // Chilled water inlet/outlet node names are necessary - if (state.dataIPShortCut->lAlphaFieldBlanks(6)) { + if (s_ipsc->lAlphaFieldBlanks(6)) { ShowSevereError(state, - format("{}{}=\"{}\"", RoutineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("{} is blank.", state.dataIPShortCut->cAlphaFieldNames(6))); + format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); + ShowContinueError(state, format("{} is blank.", s_ipsc->cAlphaFieldNames(6))); ErrorsFound = true; } - if (state.dataIPShortCut->lAlphaFieldBlanks(7)) { + if (s_ipsc->lAlphaFieldBlanks(7)) { ShowSevereError(state, - format("{}{}=\"{}\"", RoutineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("{} is blank.", state.dataIPShortCut->cAlphaFieldNames(7))); + format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); + ShowContinueError(state, format("{} is blank.", s_ipsc->cAlphaFieldNames(7))); ErrorsFound = true; } thisChiller.EvapInletNodeNum = NodeInputManager::GetOnlySingleNode(state, - state.dataIPShortCut->cAlphaArgs(6), + s_ipsc->cAlphaArgs(6), ErrorsFound, DataLoopNode::ConnectionObjectType::ChillerElectricReformulatedEIR, - state.dataIPShortCut->cAlphaArgs(1), + s_ipsc->cAlphaArgs(1), DataLoopNode::NodeFluidType::Water, DataLoopNode::ConnectionType::Inlet, NodeInputManager::CompFluidStream::Primary, DataLoopNode::ObjectIsNotParent); thisChiller.EvapOutletNodeNum = NodeInputManager::GetOnlySingleNode(state, - state.dataIPShortCut->cAlphaArgs(7), + s_ipsc->cAlphaArgs(7), ErrorsFound, DataLoopNode::ConnectionObjectType::ChillerElectricReformulatedEIR, - state.dataIPShortCut->cAlphaArgs(1), + s_ipsc->cAlphaArgs(1), DataLoopNode::NodeFluidType::Water, DataLoopNode::ConnectionType::Outlet, NodeInputManager::CompFluidStream::Primary, DataLoopNode::ObjectIsNotParent); BranchNodeConnections::TestCompSet(state, - state.dataIPShortCut->cCurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaArgs(6), - state.dataIPShortCut->cAlphaArgs(7), + s_ipsc->cCurrentModuleObject, + s_ipsc->cAlphaArgs(1), + s_ipsc->cAlphaArgs(6), + s_ipsc->cAlphaArgs(7), "Chilled Water Nodes"); thisChiller.CondenserType = DataPlant::CondenserType::WaterCooled; // Condenser inlet/outlet node names are necessary - if (state.dataIPShortCut->lAlphaFieldBlanks(8)) { + if (s_ipsc->lAlphaFieldBlanks(8)) { ShowSevereError(state, - format("{}{}=\"{}\"", RoutineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("{} is blank.", state.dataIPShortCut->cAlphaFieldNames(8))); + format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); + ShowContinueError(state, format("{} is blank.", s_ipsc->cAlphaFieldNames(8))); ErrorsFound = true; } - if (state.dataIPShortCut->lAlphaFieldBlanks(9)) { + if (s_ipsc->lAlphaFieldBlanks(9)) { ShowSevereError(state, - format("{}{}=\"{}\"", RoutineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("{} is blank.", state.dataIPShortCut->cAlphaFieldNames(9))); + format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); + ShowContinueError(state, format("{} is blank.", s_ipsc->cAlphaFieldNames(9))); ErrorsFound = true; } thisChiller.CondInletNodeNum = NodeInputManager::GetOnlySingleNode(state, - state.dataIPShortCut->cAlphaArgs(8), + s_ipsc->cAlphaArgs(8), ErrorsFound, DataLoopNode::ConnectionObjectType::ChillerElectricReformulatedEIR, - state.dataIPShortCut->cAlphaArgs(1), + s_ipsc->cAlphaArgs(1), DataLoopNode::NodeFluidType::Water, DataLoopNode::ConnectionType::Inlet, NodeInputManager::CompFluidStream::Secondary, DataLoopNode::ObjectIsNotParent); thisChiller.CondOutletNodeNum = NodeInputManager::GetOnlySingleNode(state, - state.dataIPShortCut->cAlphaArgs(9), + s_ipsc->cAlphaArgs(9), ErrorsFound, DataLoopNode::ConnectionObjectType::ChillerElectricReformulatedEIR, - state.dataIPShortCut->cAlphaArgs(1), + s_ipsc->cAlphaArgs(1), DataLoopNode::NodeFluidType::Water, DataLoopNode::ConnectionType::Outlet, NodeInputManager::CompFluidStream::Secondary, DataLoopNode::ObjectIsNotParent); BranchNodeConnections::TestCompSet(state, - state.dataIPShortCut->cCurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaArgs(8), - state.dataIPShortCut->cAlphaArgs(9), + s_ipsc->cCurrentModuleObject, + s_ipsc->cAlphaArgs(1), + s_ipsc->cAlphaArgs(8), + s_ipsc->cAlphaArgs(9), "Condenser Water Nodes"); { - thisChiller.FlowMode = static_cast(getEnumValue(DataPlant::FlowModeNamesUC, state.dataIPShortCut->cAlphaArgs(10))); + thisChiller.FlowMode = static_cast(getEnumValue(DataPlant::FlowModeNamesUC, s_ipsc->cAlphaArgs(10))); if (thisChiller.FlowMode == DataPlant::FlowMode::Invalid) { ShowSevereError(state, - format("{}{}=\"{}\",", RoutineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("Invalid {}={}", state.dataIPShortCut->cAlphaFieldNames(10), state.dataIPShortCut->cAlphaArgs(10))); + format("{}{}=\"{}\",", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); + ShowContinueError(state, format("Invalid {}={}", s_ipsc->cAlphaFieldNames(10), s_ipsc->cAlphaArgs(10))); ShowContinueError(state, "Available choices are ConstantFlow, NotModulated, or LeavingSetpointModulated"); ShowContinueError(state, "Flow mode NotModulated is assumed and the simulation continues."); thisChiller.FlowMode = DataPlant::FlowMode::NotModulated; @@ -410,162 +415,162 @@ void GetElecReformEIRChillerInput(EnergyPlusData &state) } // Chiller rated performance data - thisChiller.RefCap = state.dataIPShortCut->rNumericArgs(1); + thisChiller.RefCap = s_ipsc->rNumericArgs(1); if (thisChiller.RefCap == DataSizing::AutoSize) { thisChiller.RefCapWasAutoSized = true; } - if (state.dataIPShortCut->rNumericArgs(1) == 0.0) { + if (s_ipsc->rNumericArgs(1) == 0.0) { ShowSevereError(state, - format("{}{}=\"{}\"", RoutineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("Invalid {}={:.2R}", state.dataIPShortCut->cNumericFieldNames(1), state.dataIPShortCut->rNumericArgs(1))); + format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); + ShowContinueError(state, format("Invalid {}={:.2R}", s_ipsc->cNumericFieldNames(1), s_ipsc->rNumericArgs(1))); ErrorsFound = true; } - thisChiller.RefCOP = state.dataIPShortCut->rNumericArgs(2); - if (state.dataIPShortCut->rNumericArgs(2) == 0.0) { + thisChiller.RefCOP = s_ipsc->rNumericArgs(2); + if (s_ipsc->rNumericArgs(2) == 0.0) { ShowSevereError(state, - format("{}{}=\"{}\"", RoutineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("Invalid {}={:.2R}", state.dataIPShortCut->cNumericFieldNames(2), state.dataIPShortCut->rNumericArgs(2))); + format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); + ShowContinueError(state, format("Invalid {}={:.2R}", s_ipsc->cNumericFieldNames(2), s_ipsc->rNumericArgs(2))); ErrorsFound = true; } - thisChiller.TempRefEvapOut = state.dataIPShortCut->rNumericArgs(3); - thisChiller.TempRefCondOut = state.dataIPShortCut->rNumericArgs(4); + thisChiller.TempRefEvapOut = s_ipsc->rNumericArgs(3); + thisChiller.TempRefCondOut = s_ipsc->rNumericArgs(4); if (thisChiller.TempRefEvapOut >= thisChiller.TempRefCondOut) { ShowSevereError(state, - format("{}{}=\"{}\"", RoutineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); + format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); ShowContinueError(state, format("{} [{:.2R}] >= {} [{:.2R}]", - state.dataIPShortCut->cNumericFieldNames(3), - state.dataIPShortCut->rNumericArgs(3), - state.dataIPShortCut->cNumericFieldNames(4), - state.dataIPShortCut->rNumericArgs(4))); + s_ipsc->cNumericFieldNames(3), + s_ipsc->rNumericArgs(3), + s_ipsc->cNumericFieldNames(4), + s_ipsc->rNumericArgs(4))); ShowContinueError(state, "Reference Leaving Chilled Water Temperature must be less than Reference Leaving Condenser Water Temperature "); ErrorsFound = true; } - thisChiller.EvapVolFlowRate = state.dataIPShortCut->rNumericArgs(5); + thisChiller.EvapVolFlowRate = s_ipsc->rNumericArgs(5); if (thisChiller.EvapVolFlowRate == DataSizing::AutoSize) { thisChiller.EvapVolFlowRateWasAutoSized = true; } - thisChiller.CondVolFlowRate = state.dataIPShortCut->rNumericArgs(6); + thisChiller.CondVolFlowRate = s_ipsc->rNumericArgs(6); if (thisChiller.CondVolFlowRate == DataSizing::AutoSize) { thisChiller.CondVolFlowRateWasAutoSized = true; } - thisChiller.MinPartLoadRat = state.dataIPShortCut->rNumericArgs(7); - thisChiller.MaxPartLoadRat = state.dataIPShortCut->rNumericArgs(8); - thisChiller.OptPartLoadRat = state.dataIPShortCut->rNumericArgs(9); - thisChiller.MinUnloadRat = state.dataIPShortCut->rNumericArgs(10); - thisChiller.SizFac = state.dataIPShortCut->rNumericArgs(14); + thisChiller.MinPartLoadRat = s_ipsc->rNumericArgs(7); + thisChiller.MaxPartLoadRat = s_ipsc->rNumericArgs(8); + thisChiller.OptPartLoadRat = s_ipsc->rNumericArgs(9); + thisChiller.MinUnloadRat = s_ipsc->rNumericArgs(10); + thisChiller.SizFac = s_ipsc->rNumericArgs(14); if (thisChiller.SizFac <= 0.0) thisChiller.SizFac = 1.0; if (thisChiller.MinPartLoadRat > thisChiller.MaxPartLoadRat) { ShowSevereError(state, - format("{}{}=\"{}\"", RoutineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); + format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); ShowContinueError(state, format("{} [{:.3R}] > {} [{:.3R}]", - state.dataIPShortCut->cNumericFieldNames(7), - state.dataIPShortCut->rNumericArgs(7), - state.dataIPShortCut->cNumericFieldNames(8), - state.dataIPShortCut->rNumericArgs(8))); + s_ipsc->cNumericFieldNames(7), + s_ipsc->rNumericArgs(7), + s_ipsc->cNumericFieldNames(8), + s_ipsc->rNumericArgs(8))); ShowContinueError(state, "Minimum part load ratio must be less than or equal to the maximum part load ratio "); ErrorsFound = true; } if (thisChiller.MinUnloadRat < thisChiller.MinPartLoadRat || thisChiller.MinUnloadRat > thisChiller.MaxPartLoadRat) { ShowSevereError(state, - format("{}{}=\"{}\"", RoutineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("{} = {:.3R}", state.dataIPShortCut->cNumericFieldNames(10), state.dataIPShortCut->rNumericArgs(10))); + format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); + ShowContinueError(state, format("{} = {:.3R}", s_ipsc->cNumericFieldNames(10), s_ipsc->rNumericArgs(10))); ShowContinueError(state, format("{} must be greater than or equal to the {}", - state.dataIPShortCut->cNumericFieldNames(10), - state.dataIPShortCut->cNumericFieldNames(7))); + s_ipsc->cNumericFieldNames(10), + s_ipsc->cNumericFieldNames(7))); ShowContinueError(state, format("{} must be less than or equal to the {}", - state.dataIPShortCut->cNumericFieldNames(10), - state.dataIPShortCut->cNumericFieldNames(8))); + s_ipsc->cNumericFieldNames(10), + s_ipsc->cNumericFieldNames(8))); ErrorsFound = true; } if (thisChiller.OptPartLoadRat < thisChiller.MinPartLoadRat || thisChiller.OptPartLoadRat > thisChiller.MaxPartLoadRat) { ShowSevereError(state, - format("{}{}=\"{}\"", RoutineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("{} = {:.3R}", state.dataIPShortCut->cNumericFieldNames(9), state.dataIPShortCut->rNumericArgs(9))); + format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); + ShowContinueError(state, format("{} = {:.3R}", s_ipsc->cNumericFieldNames(9), s_ipsc->rNumericArgs(9))); ShowContinueError(state, format("{} must be greater than or equal to the {}", - state.dataIPShortCut->cNumericFieldNames(9), - state.dataIPShortCut->cNumericFieldNames(7))); + s_ipsc->cNumericFieldNames(9), + s_ipsc->cNumericFieldNames(7))); ShowContinueError(state, format("{} must be less than or equal to the {}", - state.dataIPShortCut->cNumericFieldNames(9), - state.dataIPShortCut->cNumericFieldNames(8))); + s_ipsc->cNumericFieldNames(9), + s_ipsc->cNumericFieldNames(8))); ErrorsFound = true; } - thisChiller.CompPowerToCondenserFrac = state.dataIPShortCut->rNumericArgs(11); + thisChiller.CompPowerToCondenserFrac = s_ipsc->rNumericArgs(11); if (thisChiller.CompPowerToCondenserFrac < 0.0 || thisChiller.CompPowerToCondenserFrac > 1.0) { ShowSevereError(state, - format("{}{}=\"{}\"", RoutineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("{} = {:.3R}", state.dataIPShortCut->cNumericFieldNames(11), state.dataIPShortCut->rNumericArgs(11))); - ShowContinueError(state, format("{} must be greater than or equal to zero", state.dataIPShortCut->cNumericFieldNames(11))); - ShowContinueError(state, format("{} must be less than or equal to one", state.dataIPShortCut->cNumericFieldNames(11))); + format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); + ShowContinueError(state, format("{} = {:.3R}", s_ipsc->cNumericFieldNames(11), s_ipsc->rNumericArgs(11))); + ShowContinueError(state, format("{} must be greater than or equal to zero", s_ipsc->cNumericFieldNames(11))); + ShowContinueError(state, format("{} must be less than or equal to one", s_ipsc->cNumericFieldNames(11))); ErrorsFound = true; } - thisChiller.TempLowLimitEvapOut = state.dataIPShortCut->rNumericArgs(12); + thisChiller.TempLowLimitEvapOut = s_ipsc->rNumericArgs(12); // These are the optional heat recovery inputs - thisChiller.DesignHeatRecVolFlowRate = state.dataIPShortCut->rNumericArgs(13); + thisChiller.DesignHeatRecVolFlowRate = s_ipsc->rNumericArgs(13); if (thisChiller.DesignHeatRecVolFlowRate == DataSizing::AutoSize) { thisChiller.DesignHeatRecVolFlowRateWasAutoSized = true; } if ((thisChiller.DesignHeatRecVolFlowRate > 0.0) || (thisChiller.DesignHeatRecVolFlowRate == DataSizing::AutoSize)) { thisChiller.HeatRecActive = true; thisChiller.HeatRecInletNodeNum = NodeInputManager::GetOnlySingleNode(state, - state.dataIPShortCut->cAlphaArgs(11), + s_ipsc->cAlphaArgs(11), ErrorsFound, DataLoopNode::ConnectionObjectType::ChillerElectricReformulatedEIR, - state.dataIPShortCut->cAlphaArgs(1), + s_ipsc->cAlphaArgs(1), DataLoopNode::NodeFluidType::Water, DataLoopNode::ConnectionType::Inlet, NodeInputManager::CompFluidStream::Tertiary, DataLoopNode::ObjectIsNotParent); if (thisChiller.HeatRecInletNodeNum == 0) { ShowSevereError(state, - format("{}{}=\"{}\"", RoutineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("Invalid {}={}", state.dataIPShortCut->cAlphaFieldNames(11), state.dataIPShortCut->cAlphaArgs(11))); + format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); + ShowContinueError(state, format("Invalid {}={}", s_ipsc->cAlphaFieldNames(11), s_ipsc->cAlphaArgs(11))); ErrorsFound = true; } thisChiller.HeatRecOutletNodeNum = NodeInputManager::GetOnlySingleNode(state, - state.dataIPShortCut->cAlphaArgs(12), + s_ipsc->cAlphaArgs(12), ErrorsFound, DataLoopNode::ConnectionObjectType::ChillerElectricReformulatedEIR, - state.dataIPShortCut->cAlphaArgs(1), + s_ipsc->cAlphaArgs(1), DataLoopNode::NodeFluidType::Water, DataLoopNode::ConnectionType::Outlet, NodeInputManager::CompFluidStream::Tertiary, DataLoopNode::ObjectIsNotParent); if (thisChiller.HeatRecOutletNodeNum == 0) { ShowSevereError(state, - format("{}{}=\"{}\"", RoutineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("Invalid {}={}", state.dataIPShortCut->cAlphaFieldNames(12), state.dataIPShortCut->cAlphaArgs(12))); + format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); + ShowContinueError(state, format("Invalid {}={}", s_ipsc->cAlphaFieldNames(12), s_ipsc->cAlphaArgs(12))); ErrorsFound = true; } BranchNodeConnections::TestCompSet(state, - state.dataIPShortCut->cCurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaArgs(11), - state.dataIPShortCut->cAlphaArgs(12), + s_ipsc->cCurrentModuleObject, + s_ipsc->cAlphaArgs(1), + s_ipsc->cAlphaArgs(11), + s_ipsc->cAlphaArgs(12), "Heat Recovery Nodes"); if (thisChiller.DesignHeatRecVolFlowRate > 0.0) { PlantUtilities::RegisterPlantCompDesignFlow(state, thisChiller.HeatRecInletNodeNum, thisChiller.DesignHeatRecVolFlowRate); } if (NumNums > 14) { - if (!state.dataIPShortCut->lNumericFieldBlanks(15)) { - thisChiller.HeatRecCapacityFraction = state.dataIPShortCut->rNumericArgs(15); + if (!s_ipsc->lNumericFieldBlanks(15)) { + thisChiller.HeatRecCapacityFraction = s_ipsc->rNumericArgs(15); } else { thisChiller.HeatRecCapacityFraction = 1.0; } @@ -573,32 +578,21 @@ void GetElecReformEIRChillerInput(EnergyPlusData &state) thisChiller.HeatRecCapacityFraction = 1.0; } - if (NumAlphas > 12) { - if (!state.dataIPShortCut->lAlphaFieldBlanks(13)) { - thisChiller.HeatRecInletLimitSchedNum = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(13)); - if (thisChiller.HeatRecInletLimitSchedNum == 0) { - ShowSevereError( - state, - format("{}{}=\"{}\"", RoutineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, - format("Invalid {}={}", state.dataIPShortCut->cAlphaFieldNames(13), state.dataIPShortCut->cAlphaArgs(13))); - ErrorsFound = true; - } - } else { - thisChiller.HeatRecInletLimitSchedNum = 0; + if (NumAlphas > 12 && !s_ipsc->lAlphaFieldBlanks(13)) { + if ((thisChiller.heatRecInletLimitSched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(13))) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(13), s_ipsc->cAlphaArgs(13)); + ErrorsFound = true; } - } else { - thisChiller.HeatRecInletLimitSchedNum = 0; } if (NumAlphas > 13) { - if (!state.dataIPShortCut->lAlphaFieldBlanks(14)) { + if (!s_ipsc->lAlphaFieldBlanks(14)) { thisChiller.HeatRecSetPointNodeNum = NodeInputManager::GetOnlySingleNode(state, - state.dataIPShortCut->cAlphaArgs(14), + s_ipsc->cAlphaArgs(14), ErrorsFound, DataLoopNode::ConnectionObjectType::ChillerElectricReformulatedEIR, - state.dataIPShortCut->cAlphaArgs(1), + s_ipsc->cAlphaArgs(1), DataLoopNode::NodeFluidType::Water, DataLoopNode::ConnectionType::Sensor, NodeInputManager::CompFluidStream::Primary, @@ -615,75 +609,71 @@ void GetElecReformEIRChillerInput(EnergyPlusData &state) thisChiller.DesignHeatRecMassFlowRate = 0.0; thisChiller.HeatRecInletNodeNum = 0; thisChiller.HeatRecOutletNodeNum = 0; - if ((!state.dataIPShortCut->lAlphaFieldBlanks(11)) || (!state.dataIPShortCut->lAlphaFieldBlanks(12))) { + if ((!s_ipsc->lAlphaFieldBlanks(11)) || (!s_ipsc->lAlphaFieldBlanks(12))) { ShowWarningError(state, - format("{}{}=\"{}\"", RoutineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); + format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); ShowWarningError(state, "Since Reference Heat Reclaim Volume Flow Rate = 0.0, heat recovery is inactive."); ShowContinueError(state, "However, node names were specified for heat recovery inlet or outlet nodes."); } } if (NumAlphas > 14) { - thisChiller.EndUseSubcategory = state.dataIPShortCut->cAlphaArgs(15); + thisChiller.EndUseSubcategory = s_ipsc->cAlphaArgs(15); } else { thisChiller.EndUseSubcategory = "General"; } if (NumAlphas > 15) { thisChiller.CondenserFlowControl = static_cast( - getEnumValue(DataPlant::CondenserFlowControlNamesUC, state.dataIPShortCut->cAlphaArgs(16))); + getEnumValue(DataPlant::CondenserFlowControlNamesUC, s_ipsc->cAlphaArgs(16))); } else { thisChiller.CondenserFlowControl = DataPlant::CondenserFlowControl::ConstantFlow; } if (thisChiller.CondenserFlowControl == DataPlant::CondenserFlowControl::Invalid) { ShowSevereError(state, - format("{}{}=\"{}\",", RoutineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("Invalid {}={}", state.dataIPShortCut->cAlphaFieldNames(16), state.dataIPShortCut->cAlphaArgs(16))); + format("{}{}=\"{}\",", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); + ShowContinueError(state, format("Invalid {}={}", s_ipsc->cAlphaFieldNames(16), s_ipsc->cAlphaArgs(16))); ShowContinueError(state, "Available choices are ConstantFlow, ModulatedChillerPLR, ModulatedLoopPLR, or ModulatedDeltaTemperature"); thisChiller.CondenserFlowControl = DataPlant::CondenserFlowControl::ConstantFlow; ErrorsFound = true; }; if (NumAlphas > 16) { - thisChiller.ChillerCondLoopFlowFLoopPLRIndex = Curve::GetCurveIndex(state, state.dataIPShortCut->cAlphaArgs(17)); + thisChiller.ChillerCondLoopFlowFLoopPLRIndex = Curve::GetCurveIndex(state, s_ipsc->cAlphaArgs(17)); } if ((thisChiller.ChillerCondLoopFlowFLoopPLRIndex == 0) && (thisChiller.CondenserFlowControl == DataPlant::CondenserFlowControl::ModulatedLoopPLR)) { ShowSevereError(state, - format("{}{} \"{}\"", RoutineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("Invalid {}={}", state.dataIPShortCut->cAlphaFieldNames(17), state.dataIPShortCut->cAlphaArgs(17))); + format("{}{} \"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); + ShowContinueError(state, format("Invalid {}={}", s_ipsc->cAlphaFieldNames(17), s_ipsc->cAlphaArgs(17))); ErrorsFound = true; } - if (NumAlphas > 17) { - if (!state.dataIPShortCut->lAlphaFieldBlanks(18)) { - thisChiller.CondDTScheduleNum = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(18)); - } + if (NumAlphas > 17 && !s_ipsc->lAlphaFieldBlanks(18)) { + thisChiller.condDTSched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(18)); } - if (thisChiller.CondDTScheduleNum == 0 && thisChiller.CondenserFlowControl == DataPlant::CondenserFlowControl::ModulatedDeltaTemperature) { - ShowSevereError(state, - format("{}{}=\"{}\"", RoutineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("Invalid {}={}", state.dataIPShortCut->cAlphaFieldNames(18), state.dataIPShortCut->cAlphaArgs(18))); + if (thisChiller.condDTSched == nullptr && thisChiller.CondenserFlowControl == DataPlant::CondenserFlowControl::ModulatedDeltaTemperature) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(18), s_ipsc->cAlphaArgs(18)); ErrorsFound = true; } if (NumNums > 15) { - thisChiller.MinCondFlowRatio = state.dataIPShortCut->rNumericArgs(16); + thisChiller.MinCondFlowRatio = s_ipsc->rNumericArgs(16); } - if (!state.dataIPShortCut->lAlphaFieldBlanks(19)) { - thisChiller.thermosiphonTempCurveIndex = Curve::GetCurveIndex(state, Util::makeUPPER(state.dataIPShortCut->cAlphaArgs(19))); + if (!s_ipsc->lAlphaFieldBlanks(19)) { + thisChiller.thermosiphonTempCurveIndex = Curve::GetCurveIndex(state, Util::makeUPPER(s_ipsc->cAlphaArgs(19))); if (thisChiller.thermosiphonTempCurveIndex == 0) { - ShowSevereError(state, format("{}{}=\"{}\"", RoutineName, state.dataIPShortCut->cCurrentModuleObject, thisChiller.Name)); - ShowContinueError(state, format("Invalid {} = {}", state.dataIPShortCut->cAlphaFieldNames(19), state.dataIPShortCut->cAlphaArgs(19))); + ShowSevereError(state, format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, thisChiller.Name)); + ShowContinueError(state, format("Invalid {} = {}", s_ipsc->cAlphaFieldNames(19), s_ipsc->cAlphaArgs(19))); ErrorsFound = true; } } - thisChiller.thermosiphonMinTempDiff = state.dataIPShortCut->rNumericArgs(17); + thisChiller.thermosiphonMinTempDiff = s_ipsc->rNumericArgs(17); } if (ErrorsFound) { - ShowFatalError(state, format("Errors found in processing input for {}", state.dataIPShortCut->cCurrentModuleObject)); + ShowFatalError(state, format("Errors found in processing input for {}", s_ipsc->cCurrentModuleObject)); } } @@ -1133,8 +1123,8 @@ void ReformulatedEIRChillerSpecs::initialize(EnergyPlusData &state, bool const R // check if inlet limit active and if exceeded. bool HeatRecRunFlag = RunFlag; - if (this->HeatRecInletLimitSchedNum > 0) { - Real64 HeatRecHighInletLimit = ScheduleManager::GetCurrentScheduleValue(state, this->HeatRecInletLimitSchedNum); + if (this->heatRecInletLimitSched != nullptr) { + Real64 HeatRecHighInletLimit = this->heatRecInletLimitSched->getCurrentVal(); if (state.dataLoopNodes->Node(this->HeatRecInletNodeNum).Temp > HeatRecHighInletLimit) { // shut down heat recovery HeatRecRunFlag = false; } else { @@ -1961,8 +1951,8 @@ void ReformulatedEIRChillerSpecs::calcHeatRecovery(EnergyPlusData &state, } // check if limit on inlet is present and exceeded. - if (this->HeatRecInletLimitSchedNum > 0) { - Real64 HeatRecHighInletLimit = ScheduleManager::GetCurrentScheduleValue(state, this->HeatRecInletLimitSchedNum); + if (this->heatRecInletLimitSched != nullptr) { + Real64 HeatRecHighInletLimit = this->heatRecInletLimitSched->getCurrentVal(); if (heatRecInletTemp > HeatRecHighInletLimit) { // shut down heat recovery QHeatRec = 0.0; } @@ -2550,12 +2540,11 @@ void ReformulatedEIRChillerSpecs::calculate(EnergyPlusData &state, Real64 &MyLoa this->CondInletTemp, state.dataPlnt->PlantLoop(this->CWPlantLoc.loopNum).FluidIndex, RoutineName); - Real64 condDT = 0.0; - if (this->CondDTScheduleNum > 0) { - condDT = ScheduleManager::GetCurrentScheduleValue(state, this->CondDTScheduleNum); - } + + Real64 condDT = (this->condDTSched != nullptr) ? this->condDTSched->getCurrentVal() : 0.0; this->CondMassFlowRate = this->QCondenser / (CpCond * condDT); } break; + default: { this->CondMassFlowRate = this->CondMassFlowRateMax; } break; diff --git a/src/EnergyPlus/ChillerReformulatedEIR.hh b/src/EnergyPlus/ChillerReformulatedEIR.hh index 58077b2c478..3400ae75947 100644 --- a/src/EnergyPlus/ChillerReformulatedEIR.hh +++ b/src/EnergyPlus/ChillerReformulatedEIR.hh @@ -123,7 +123,7 @@ namespace ChillerReformulatedEIR { Real64 HeatRecCapacityFraction = 0.0; // user input for heat recovery capacity fraction [] Real64 HeatRecMaxCapacityLimit = 0.0; // Capacity limit for Heat recovery, one time calc [W] int HeatRecSetPointNodeNum = 0; // index for system node with the heat recover leaving setpoint - int HeatRecInletLimitSchedNum = 0; // index for schedule for the inlet high limit for heat recovery operation + Sched::Schedule *heatRecInletLimitSched = nullptr; // index for schedule for the inlet high limit for heat recovery operation int ChillerCapFTIndex = 0; // Index for the total cooling capacity modifier curve // (function of leaving evaporator and condenser water temperatures) int ChillerEIRFTIndex = 0; // Index for the energy input ratio modifier curve @@ -214,7 +214,7 @@ namespace ChillerReformulatedEIR { Real64 HeatRecMassFlow = 0.0; // Heat reclaim mass flow rate [kg/s] int ChillerCondLoopFlowFLoopPLRIndex = 0; // Condenser loop flow rate fraction function of loop PLR int CondDT = 0; // Temperature difference across condenser - int CondDTScheduleNum = 0; // Temperature difference across condenser schedule index + Sched::Schedule *condDTSched = nullptr; // Temperature difference across condenser schedule Real64 MinCondFlowRatio = 0.2; // Minimum condenser flow fraction DataBranchAirLoopPlant::ControlType EquipFlowCtrl = DataBranchAirLoopPlant::ControlType::Invalid; Real64 VSBranchPumpMinLimitMassFlowCond = 0.0; @@ -273,6 +273,10 @@ struct ChillerReformulatedEIRData : BaseGlobalStruct bool GetInputREIR = true; Array1D ElecReformEIRChiller; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/Coils/CoilCoolingDX.cc b/src/EnergyPlus/Coils/CoilCoolingDX.cc index 6ce7bef2a44..0eb352b634e 100644 --- a/src/EnergyPlus/Coils/CoilCoolingDX.cc +++ b/src/EnergyPlus/Coils/CoilCoolingDX.cc @@ -129,7 +129,10 @@ void CoilCoolingDX::getInput(EnergyPlusData &state) void CoilCoolingDX::instantiateFromInputSpec(EnergyPlusData &state, const CoilCoolingDXInputSpecification &input_data) { - static constexpr std::string_view routineName("CoilCoolingDX::instantiateFromInputSpec: "); + static constexpr std::string_view routineName = "CoilCoolingDX::instantiateFromInputSpec"; + + ErrorObjectHeader eoh{routineName, "CoilCoolingDX", input_data.name}; + this->original_input_specs = input_data; bool errorsFound = false; this->name = input_data.name; @@ -207,14 +210,9 @@ void CoilCoolingDX::instantiateFromInputSpec(EnergyPlusData &state, const CoilCo } if (input_data.availability_schedule_name.empty()) { - this->availScheduleIndex = ScheduleManager::ScheduleAlwaysOn; - } else { - this->availScheduleIndex = ScheduleManager::GetScheduleIndex(state, input_data.availability_schedule_name); - } - - if (this->availScheduleIndex == 0) { - ShowSevereError(state, std::string{routineName} + state.dataCoilCooingDX->coilCoolingDXObjectName + "=\"" + this->name + "\", invalid"); - ShowContinueError(state, "...Availability Schedule Name=\"" + input_data.availability_schedule_name + "\"."); + this->availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((this->availSched = Sched::GetSchedule(state, input_data.availability_schedule_name)) == nullptr) { + ShowSevereItemNotFound(state, eoh, "Availability Schedule Name", input_data.availability_schedule_name); errorsFound = true; } @@ -697,7 +695,7 @@ void CoilCoolingDX::simulate(EnergyPlusData &state, CoilCoolingDX::passThroughNodeData(evapInletNode, evapOutletNode); // calculate energy conversion factor - Real64 reportingConstant = state.dataHVACGlobal->TimeStepSys * Constant::SecInHour; + Real64 reportingConstant = state.dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; // update condensate collection tank if (this->condensateTankIndex > 0) { diff --git a/src/EnergyPlus/Coils/CoilCoolingDX.hh b/src/EnergyPlus/Coils/CoilCoolingDX.hh index fd680a177ae..fb2f7646f95 100644 --- a/src/EnergyPlus/Coils/CoilCoolingDX.hh +++ b/src/EnergyPlus/Coils/CoilCoolingDX.hh @@ -55,6 +55,7 @@ #include #include #include +#include namespace EnergyPlus { @@ -115,7 +116,7 @@ struct CoilCoolingDX bool myOneTimeInitFlag = true; int evapInletNodeIndex = 0; int evapOutletNodeIndex = 0; - int availScheduleIndex = 0; + Sched::Schedule *availSched = nullptr; int condInletNodeIndex = 0; int condOutletNodeIndex = 0; CoilCoolingDXCurveFitPerformance performance; @@ -181,6 +182,11 @@ struct CoilCoolingDXData : BaseGlobalStruct bool coilCoolingDXGetInputFlag = true; std::string const coilCoolingDXObjectName = "Coil:Cooling:DX"; bool stillNeedToReportStandardRatings = true; // standard ratings flag for all coils to report at the same time + + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/Coils/CoilCoolingDXCurveFitPerformance.cc b/src/EnergyPlus/Coils/CoilCoolingDXCurveFitPerformance.cc index 67ab205d590..b6c0d9d79a8 100644 --- a/src/EnergyPlus/Coils/CoilCoolingDXCurveFitPerformance.cc +++ b/src/EnergyPlus/Coils/CoilCoolingDXCurveFitPerformance.cc @@ -66,7 +66,10 @@ using namespace EnergyPlus; void CoilCoolingDXCurveFitPerformance::instantiateFromInputSpec(EnergyPlus::EnergyPlusData &state, const CoilCoolingDXCurveFitPerformanceInputSpecification &input_data) { - static constexpr std::string_view routineName("CoilCoolingDXCurveFitOperatingMode::instantiateFromInputSpec: "); + static constexpr std::string_view routineName = "CoilCoolingDXCurveFitOperatingMode::instantiateFromInputSpec"; + + ErrorObjectHeader eoh{routineName, this->object_name, input_data.name}; + bool errorsFound(false); this->original_input_specs = input_data; this->name = input_data.name; @@ -75,6 +78,7 @@ void CoilCoolingDXCurveFitPerformance::instantiateFromInputSpec(EnergyPlus::Ener this->crankcaseHeaterCap = input_data.crankcase_heater_capacity; this->normalMode = CoilCoolingDXCurveFitOperatingMode(state, input_data.base_operating_mode_name); this->normalMode.oneTimeInit(state); // oneTimeInit does not need to be delayed in this use case + if (Util::SameString(input_data.capacity_control, "CONTINUOUS")) { this->capControlMethod = CapControlMethod::CONTINUOUS; } else if (Util::SameString(input_data.capacity_control, "DISCRETE")) { @@ -88,14 +92,9 @@ void CoilCoolingDXCurveFitPerformance::instantiateFromInputSpec(EnergyPlus::Ener this->evapCondBasinHeatCap = input_data.basin_heater_capacity; this->evapCondBasinHeatSetpoint = input_data.basin_heater_setpoint_temperature; if (input_data.basin_heater_operating_schedule_name.empty()) { - this->evapCondBasinHeatSchedulIndex = ScheduleManager::ScheduleAlwaysOn; - } else { - this->evapCondBasinHeatSchedulIndex = ScheduleManager::GetScheduleIndex(state, input_data.basin_heater_operating_schedule_name); - } - if (this->evapCondBasinHeatSchedulIndex == 0) { - ShowSevereError(state, std::string{routineName} + this->object_name + "=\"" + this->name + "\", invalid"); - ShowContinueError( - state, "...Evaporative Condenser Basin Heater Operating Schedule Name=\"" + input_data.basin_heater_operating_schedule_name + "\"."); + this->evapCondBasinHeatSched = Sched::GetScheduleAlwaysOn(state); + } else if ((this->evapCondBasinHeatSched = Sched::GetSchedule(state, input_data.basin_heater_operating_schedule_name)) == nullptr) { + ShowSevereItemNotFound(state, eoh, "Evaporative Condenser Basin Heater Operating Schedule Name", input_data.basin_heater_operating_schedule_name); errorsFound = true; } @@ -215,7 +214,7 @@ void CoilCoolingDXCurveFitPerformance::simulate(EnergyPlus::EnergyPlusData &stat Real64 LoadSHR) { static constexpr std::string_view RoutineName = "CoilCoolingDXCurveFitPerformance::simulate"; - Real64 reportingConstant = state.dataHVACGlobal->TimeStepSys * Constant::SecInHour; + Real64 reportingConstant = state.dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; this->recoveredEnergyRate = 0.0; this->NormalSHR = 0.0; @@ -363,8 +362,8 @@ void CoilCoolingDXCurveFitPerformance::simulate(EnergyPlus::EnergyPlusData &stat this->crankcaseHeaterElectricityConsumption = this->crankcaseHeaterPower * reportingConstant; // basin heater - if (this->evapCondBasinHeatSchedulIndex > 0) { - Real64 currentBasinHeaterAvail = ScheduleManager::GetCurrentScheduleValue(state, this->evapCondBasinHeatSchedulIndex); + if (this->evapCondBasinHeatSched != nullptr) { + Real64 currentBasinHeaterAvail = this->evapCondBasinHeatSched->getCurrentVal(); if (this->evapCondBasinHeatCap > 0.0 && currentBasinHeaterAvail > 0.0) { this->basinHeaterPower = max(0.0, this->evapCondBasinHeatCap * (this->evapCondBasinHeatSetpoint - state.dataEnvrn->OutDryBulbTemp)); } diff --git a/src/EnergyPlus/Coils/CoilCoolingDXCurveFitPerformance.hh b/src/EnergyPlus/Coils/CoilCoolingDXCurveFitPerformance.hh index 2f1b5a4ce27..e332090a620 100644 --- a/src/EnergyPlus/Coils/CoilCoolingDXCurveFitPerformance.hh +++ b/src/EnergyPlus/Coils/CoilCoolingDXCurveFitPerformance.hh @@ -55,6 +55,7 @@ #include #include #include +#include #include namespace EnergyPlus { @@ -138,7 +139,7 @@ struct CoilCoolingDXCurveFitPerformance Real64 evapCondBasinHeatCap = 0.0; Real64 evapCondBasinHeatSetpoint = 0.0; - int evapCondBasinHeatSchedulIndex = 0; + Sched::Schedule *evapCondBasinHeatSched = nullptr; Real64 basinHeaterElectricityConsumption = 0.0; Real64 basinHeaterPower = 0.0; Real64 powerUse = 0.0; diff --git a/src/EnergyPlus/CondenserLoopTowers.cc b/src/EnergyPlus/CondenserLoopTowers.cc index a99dee14c4c..7289fd987a4 100644 --- a/src/EnergyPlus/CondenserLoopTowers.cc +++ b/src/EnergyPlus/CondenserLoopTowers.cc @@ -200,9 +200,8 @@ namespace CondenserLoopTowers { // METHODOLOGY EMPLOYED: // Uses "Get" routines to read in the data. - // SUBROUTINE PARAMETER DEFINITIONS: - static constexpr std::string_view OutputFormat("{:5.2F}"); - + static constexpr std::string_view routineName = "GetTowerInput"; + // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int TowerNum; // Tower number, reference counter for towers data array int NumVSCoolToolsModelCoeffs = 0; // Number of CoolTools VS cooling tower coefficient objects @@ -227,11 +226,14 @@ namespace CondenserLoopTowers { constexpr std::array(Blowdown::Num)> BlowDownNamesUC = {"CONCENTRATIONRATIO", "SCHEDULEDRATE"}; constexpr std::array(CellCtrl::Num)> CellCtrlNamesUC = {"MINIMALCELL", "MAXIMALCELL"}; + auto const &s_ip = state.dataInputProcessing->inputProcessor; + auto &s_ipsc = state.dataIPShortCut; + // Get number of all cooling towers specified in the input data file (idf) - int NumSingleSpeedTowers = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCoolingTower_SingleSpeed); - int NumTwoSpeedTowers = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCoolingTower_TwoSpeed); - int NumVariableSpeedTowers = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCoolingTower_VariableSpeed); - int NumVSMerkelTowers = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCoolingTower_VariableSpeedMerkel); + int NumSingleSpeedTowers = s_ip->getNumObjectsFound(state, cCoolingTower_SingleSpeed); + int NumTwoSpeedTowers = s_ip->getNumObjectsFound(state, cCoolingTower_TwoSpeed); + int NumVariableSpeedTowers = s_ip->getNumObjectsFound(state, cCoolingTower_VariableSpeed); + int NumVSMerkelTowers = s_ip->getNumObjectsFound(state, cCoolingTower_VariableSpeedMerkel); int NumSimpleTowers = NumSingleSpeedTowers + NumTwoSpeedTowers + NumVariableSpeedTowers + NumVSMerkelTowers; if (NumSimpleTowers <= 0) @@ -249,18 +251,16 @@ namespace CondenserLoopTowers { // Allocate variable-speed tower structure with data specific to this type if (NumVariableSpeedTowers > 0) { // Allow users to input model coefficients other than default - NumVSCoolToolsModelCoeffs = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "CoolingTowerPerformance:CoolTools"); - NumVSYorkCalcModelCoeffs = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "CoolingTowerPerformance:YorkCalc"); + NumVSCoolToolsModelCoeffs = s_ip->getNumObjectsFound(state, "CoolingTowerPerformance:CoolTools"); + NumVSYorkCalcModelCoeffs = s_ip->getNumObjectsFound(state, "CoolingTowerPerformance:YorkCalc"); } - std::string &cCurrentModuleObject = state.dataIPShortCut->cCurrentModuleObject; - // Load data structures with cooling tower input data - cCurrentModuleObject = cCoolingTower_SingleSpeed; + s_ipsc->cCurrentModuleObject = cCoolingTower_SingleSpeed; for (int SingleSpeedTowerNumber = 1; SingleSpeedTowerNumber <= NumSingleSpeedTowers; ++SingleSpeedTowerNumber) { TowerNum = SingleSpeedTowerNumber; - state.dataInputProcessing->inputProcessor->getObjectItem(state, - cCurrentModuleObject, + s_ip->getObjectItem(state, + s_ipsc->cCurrentModuleObject, SingleSpeedTowerNumber, AlphArray, NumAlphas, @@ -268,11 +268,15 @@ namespace CondenserLoopTowers { NumNums, IOStat, _, - state.dataIPShortCut->lAlphaFieldBlanks, - state.dataIPShortCut->cAlphaFieldNames, - state.dataIPShortCut->cNumericFieldNames); + s_ipsc->lAlphaFieldBlanks, + s_ipsc->cAlphaFieldNames, + s_ipsc->cNumericFieldNames); + + + ErrorObjectHeader eoh{routineName, s_ipsc->cCurrentModuleObject, AlphArray(1)}; + GlobalNames::VerifyUniqueInterObjectName( - state, UniqueSimpleTowerNames, AlphArray(1), cCurrentModuleObject, state.dataIPShortCut->cAlphaFieldNames(1), ErrorsFound); + state, UniqueSimpleTowerNames, AlphArray(1), s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaFieldNames(1), ErrorsFound); auto &tower = state.dataCondenserLoopTowers->towers(TowerNum); tower.Name = AlphArray(1); tower.TowerType = DataPlant::PlantEquipmentType::CoolingTower_SingleSpd; @@ -295,7 +299,7 @@ namespace CondenserLoopTowers { DataLoopNode::ConnectionType::Outlet, NodeInputManager::CompFluidStream::Primary, DataLoopNode::ObjectIsNotParent); - BranchNodeConnections::TestCompSet(state, cCurrentModuleObject, tower.Name, AlphArray(2), AlphArray(3), "Chilled Water Nodes"); + BranchNodeConnections::TestCompSet(state, s_ipsc->cCurrentModuleObject, tower.Name, AlphArray(2), AlphArray(3), "Chilled Water Nodes"); tower.DesignWaterFlowRate = NumArray(1); if (tower.DesignWaterFlowRate == DataSizing::AutoSize) { tower.DesignWaterFlowRateWasAutoSized = true; @@ -335,8 +339,7 @@ namespace CondenserLoopTowers { if (NumAlphas >= 4) { tower.PerformanceInputMethod_Num = static_cast(getEnumValue(PIMNamesUC, Util::makeUPPER(AlphArray(4)))); if (tower.PerformanceInputMethod_Num == PIM::Invalid) { - ShowSevereError(state, format("{}={}", cCurrentModuleObject, AlphArray(1))); - ShowContinueError(state, format("Invalid, {} = {}", state.dataIPShortCut->cAlphaFieldNames(4), AlphArray(4))); + ShowSevereInvalidKey(state, eoh, s_ipsc->cAlphaFieldNames(4), AlphArray(4)); ErrorsFound = true; } } else { @@ -370,9 +373,7 @@ namespace CondenserLoopTowers { // Basin heater power as a function of temperature must be greater than or equal to 0 tower.BasinHeaterPowerFTempDiff = NumArray(17); if (NumArray(17) < 0.0) { - ShowSevereError( - state, - format("{}, \"{}\" basin heater power as a function of temperature difference must be >= 0", cCurrentModuleObject, tower.Name)); + ShowSevereCustom(state, eoh, "Basin heater power as a function of temperature difference must be >= 0"); ErrorsFound = true; } @@ -383,23 +384,15 @@ namespace CondenserLoopTowers { tower.BasinHeaterSetPointTemp = 2.0; } if (tower.BasinHeaterSetPointTemp < 2.0) { - ShowWarningError(state, - format("{}:\"{}\", {} is less than 2 deg C. Freezing could occur.", - cCurrentModuleObject, - tower.Name, - state.dataIPShortCut->cNumericFieldNames(18))); + ShowWarningCustom(state, eoh, format("{} is less than 2 deg C. Freezing could occur.", s_ipsc->cNumericFieldNames(18))); } } if (!AlphArray(5).empty()) { - tower.BasinHeaterSchedulePtr = ScheduleManager::GetScheduleIndex(state, AlphArray(5)); - if (tower.BasinHeaterSchedulePtr == 0) { - ShowWarningError(state, - format("{}, \"{}\" basin heater schedule name \"{}\" was not found. Basin heater operation will not be modeled " - "and the simulation continues", - cCurrentModuleObject, - tower.Name, - AlphArray(5))); + if ((tower.basinHeaterSched = Sched::GetSchedule(state, AlphArray(5))) == nullptr) { + ShowWarningItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(5), AlphArray(5), + "Basin heater operation will not be modeled and the simulation continues"); + } } @@ -413,24 +406,24 @@ namespace CondenserLoopTowers { if (tower.SizFac <= 0.0) tower.SizFac = 1.0; tower.BlowdownMode = static_cast(getEnumValue(BlowDownNamesUC, Util::makeUPPER(AlphArray(7)))); - tower.SchedIDBlowdown = ScheduleManager::GetScheduleIndex(state, AlphArray(8)); - if ((tower.SchedIDBlowdown == 0) && (tower.BlowdownMode == Blowdown::Schedule)) { - ShowSevereError(state, format("Invalid, {} = \"{}\"", state.dataIPShortCut->cAlphaFieldNames(8), AlphArray(8))); - ShowContinueError(state, format("Entered in {} = \"{}\"", cCoolingTower_SingleSpeed, tower.Name)); - ErrorsFound = true; + if (tower.BlowdownMode == Blowdown::Schedule) { + if ((tower.blowdownSched = Sched::GetSchedule(state, AlphArray(8))) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(8), AlphArray(8)); + ErrorsFound = true; + } } if (AlphArray(9).empty()) { tower.SuppliedByWaterSystem = false; } else { // water from storage tank WaterManager::SetupTankDemandComponent( - state, AlphArray(1), cCurrentModuleObject, AlphArray(9), ErrorsFound, tower.WaterTankID, tower.WaterTankDemandARRID); + state, AlphArray(1), s_ipsc->cCurrentModuleObject, AlphArray(9), ErrorsFound, tower.WaterTankID, tower.WaterTankDemandARRID); tower.SuppliedByWaterSystem = true; } // outdoor air inlet node - if (state.dataIPShortCut->lAlphaFieldBlanks(10)) { + if (s_ipsc->lAlphaFieldBlanks(10)) { tower.OutdoorAirInletNodeNum = 0; } else { tower.OutdoorAirInletNodeNum = NodeInputManager::GetOnlySingleNode(state, @@ -443,28 +436,19 @@ namespace CondenserLoopTowers { NodeInputManager::CompFluidStream::Primary, DataLoopNode::ObjectIsNotParent); if (!OutAirNodeManager::CheckOutAirNodeNumber(state, tower.OutdoorAirInletNodeNum)) { - ShowSevereError(state, - format("{}, \"{}\" Outdoor Air Inlet Node Name not valid Outdoor Air Node= {}", - cCurrentModuleObject, - tower.Name, - AlphArray(10))); - ShowContinueError(state, "...does not appear in an OutdoorAir:NodeList or as an OutdoorAir:Node."); + ShowSevereCustom(state, eoh, format("Outdoor Air Inlet Node Name not valid Outdoor Air Node= {}" + "does not appear in an OutdoorAir:NodeList or as an OutdoorAir:Node.", + AlphArray(10))); ErrorsFound = true; } } // fluid bypass for single speed tower - if (state.dataIPShortCut->lAlphaFieldBlanks(11) || AlphArray(11).empty()) { + if (s_ipsc->lAlphaFieldBlanks(11) || AlphArray(11).empty()) { tower.CapacityControl = CapacityCtrl::FanCycling; // FanCycling - } else { - tower.CapacityControl = static_cast(getEnumValue(CapacityCtrlNamesUC, Util::makeUPPER(AlphArray(11)))); - if (tower.CapacityControl == CapacityCtrl::Invalid) { - tower.CapacityControl = CapacityCtrl::FanCycling; - ShowWarningError(state, - format("{}, \"{}\" The Capacity Control is not specified correctly. The default Fan Cycling is used.", - cCurrentModuleObject, - tower.Name)); - } + } else if ((tower.CapacityControl = static_cast(getEnumValue(CapacityCtrlNamesUC, AlphArray(11)))) == CapacityCtrl::Invalid) { + tower.CapacityControl = CapacityCtrl::FanCycling; + ShowWarningInvalidKey(state, eoh, s_ipsc->cAlphaFieldNames(11), AlphArray(11), "The default Fan Cycling is used."); } // added for multi-cell @@ -485,115 +469,73 @@ namespace CondenserLoopTowers { } // cell control for single speed tower - if (!state.dataIPShortCut->lAlphaFieldBlanks(12)) { + if (!s_ipsc->lAlphaFieldBlanks(12)) { tower.cellCtrl = static_cast(getEnumValue(CellCtrlNamesUC, Util::makeUPPER(AlphArray(12)))); } // High speed air flow rate must be greater than free convection air flow rate. // Can't tell yet if autosized, check later in initialize. if (tower.HighSpeedAirFlowRate <= tower.FreeConvAirFlowRate && tower.HighSpeedAirFlowRate != DataSizing::AutoSize) { - ShowSevereError( - state, - format("{} \"{}\". Free convection air flow rate must be less than the design air flow rate.", cCurrentModuleObject, tower.Name)); + ShowSevereCustom(state, eoh, "Free convection air flow rate must be less than the design air flow rate."); ErrorsFound = true; } // Check various inputs if Performance Input Method = "UA and Design Water Flow Rate" if (tower.PerformanceInputMethod_Num == PIM::UFactor) { if (tower.DesignWaterFlowRate == 0.0) { - ShowSevereError(state, - format("{} \"{}\". Tower performance input method requires a design water flow rate greater than zero.", - cCurrentModuleObject, - tower.Name)); + ShowSevereCustom(state, eoh, "Tower performance input method requires a design water flow rate greater than zero."); ErrorsFound = true; } if (tower.HighSpeedTowerUA <= tower.FreeConvTowerUA && tower.HighSpeedTowerUA != DataSizing::AutoSize) { - ShowSevereError(state, - format("{} \"{}\". Free convection UA must be less than the design tower UA.", cCurrentModuleObject, tower.Name)); + ShowSevereCustom(state, eoh, "Free convection UA must be less than the design tower UA."); ErrorsFound = true; } if (tower.FreeConvTowerUA > 0.0 && tower.FreeConvAirFlowRate == 0.0) { - ShowSevereError( - state, - format("{} \"{}\". Free convection air flow rate must be greater than zero when free convection UA is greater than zero.", - cCurrentModuleObject, - tower.Name)); + ShowSevereCustom(state, eoh, "Free convection air flow rate must be greater than zero when free convection UA is greater than zero."); ErrorsFound = true; } } else if (tower.PerformanceInputMethod_Num == PIM::NominalCapacity) { if (tower.TowerNominalCapacity == 0.0) { - ShowSevereError( - state, - format("{} \"{}\". Tower performance input method requires valid nominal capacity.", cCurrentModuleObject, tower.Name)); + ShowSevereCustom(state, eoh, "Tower performance input method requires valid nominal capacity."); ErrorsFound = true; } if (tower.DesignWaterFlowRate != 0.0) { if (tower.DesignWaterFlowRate > 0.0) { - ShowWarningError(state, - format("{} \"{}\". Nominal capacity input method and design water flow rate have been specified.", - cCurrentModuleObject, - tower.Name)); + ShowWarningCustom(state, eoh, "Nominal capacity input method and design water flow rate have been specified."); } else { - ShowSevereError( - state, - format("{} \"{}\". Nominal capacity input method has been specified and design water flow rate is being autosized.", - cCurrentModuleObject, - tower.Name)); + ShowSevereCustom(state, eoh, "Nominal capacity input method has been specified and design water flow rate is being autosized."); } ShowContinueError(state, "Design water flow rate will be set according to nominal tower capacity."); } if (tower.HighSpeedTowerUA != 0.0) { if (tower.HighSpeedTowerUA > 0.0) { - ShowWarningError( - state, - format("{} \"{}\". Nominal tower capacity and design tower UA have been specified.", cCurrentModuleObject, tower.Name)); + ShowWarningCustom(state, eoh, "Nominal tower capacity and design tower UA have been specified."); } else { - ShowSevereError(state, - format("{} \"{}\". Nominal tower capacity has been specified and design tower UA is being autosized.", - cCurrentModuleObject, - tower.Name)); + ShowSevereCustom(state, eoh, "Nominal tower capacity has been specified and design tower UA is being autosized."); } ShowContinueError(state, "Design tower UA will be set according to nominal tower capacity."); } if (tower.FreeConvTowerUA != 0.0) { if (tower.FreeConvTowerUA > 0.0) { - ShowWarningError(state, - format("{} \"{}\". Nominal capacity input method and free convection UA have been specified.", - cCurrentModuleObject, - tower.Name)); + ShowWarningCustom(state, eoh, "Nominal capacity input method and free convection UA have been specified."); } else { - ShowSevereError( - state, - format("{} \"{}\". Nominal capacity input method has been specified and free convection UA is being autosized.", - cCurrentModuleObject, - tower.Name)); + ShowSevereCustom(state, eoh, "Nominal capacity input method has been specified and free convection UA is being autosized."); } ShowContinueError(state, "Free convection UA will be set according to nominal tower capacity."); } if (tower.TowerFreeConvNomCap >= tower.TowerNominalCapacity) { - ShowSevereError(state, - format("{} \"{}\". Free convection nominal capacity must be less than the nominal (design) tower capacity.", - cCurrentModuleObject, - tower.Name)); + ShowSevereCustom(state, eoh, "Free convection nominal capacity must be less than the nominal (design) tower capacity."); ErrorsFound = true; } if (tower.TowerFreeConvNomCap > 0.0 && tower.FreeConvAirFlowRate == 0.0) { - ShowSevereError( - state, - format("{} \"{}\". Free convection air flow must be greater than zero when tower free convection capacity is specified.", - cCurrentModuleObject, - tower.Name)); + ShowSevereCustom(state, eoh, "Free convection air flow must be greater than zero when tower free convection capacity is specified."); ErrorsFound = true; } } else { // Tower performance input method is not specified as a valid "choice" - ShowSevereError(state, - format("{} \"{}{}", - cCurrentModuleObject, - tower.Name, - ". Tower Performance Input Method must be \"UFactorTimesAreaAndDesignWaterFlowRate\" or \"NominalCapacity\"")); - ShowContinueError(state, format("Tower Performanace Input Method currently specified as: {}", AlphArray(4))); + ShowSevereInvalidKey(state, eoh, s_ipsc->cAlphaFieldNames(4), AlphArray(4)); ErrorsFound = true; } + if (NumAlphas > 12) { tower.EndUseSubcategory = AlphArray(13); } else { @@ -601,11 +543,11 @@ namespace CondenserLoopTowers { } } // End Single-Speed Tower Loop - cCurrentModuleObject = cCoolingTower_TwoSpeed; + s_ipsc->cCurrentModuleObject = cCoolingTower_TwoSpeed; for (int TwoSpeedTowerNumber = 1; TwoSpeedTowerNumber <= NumTwoSpeedTowers; ++TwoSpeedTowerNumber) { TowerNum = NumSingleSpeedTowers + TwoSpeedTowerNumber; - state.dataInputProcessing->inputProcessor->getObjectItem(state, - cCurrentModuleObject, + s_ip->getObjectItem(state, + s_ipsc->cCurrentModuleObject, TwoSpeedTowerNumber, AlphArray, NumAlphas, @@ -613,11 +555,14 @@ namespace CondenserLoopTowers { NumNums, IOStat, _, - state.dataIPShortCut->lAlphaFieldBlanks, - state.dataIPShortCut->cAlphaFieldNames, - state.dataIPShortCut->cNumericFieldNames); + s_ipsc->lAlphaFieldBlanks, + s_ipsc->cAlphaFieldNames, + s_ipsc->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, s_ipsc->cCurrentModuleObject, AlphArray(1)}; + GlobalNames::VerifyUniqueInterObjectName( - state, UniqueSimpleTowerNames, AlphArray(1), cCurrentModuleObject, state.dataIPShortCut->cAlphaFieldNames(1), ErrorsFound); + state, UniqueSimpleTowerNames, AlphArray(1), s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaFieldNames(1), ErrorsFound); auto &tower = state.dataCondenserLoopTowers->towers(TowerNum); tower.Name = AlphArray(1); @@ -641,7 +586,7 @@ namespace CondenserLoopTowers { DataLoopNode::ConnectionType::Outlet, NodeInputManager::CompFluidStream::Primary, DataLoopNode::ObjectIsNotParent); - BranchNodeConnections::TestCompSet(state, cCurrentModuleObject, AlphArray(1), AlphArray(2), AlphArray(3), "Chilled Water Nodes"); + BranchNodeConnections::TestCompSet(state, s_ipsc->cCurrentModuleObject, AlphArray(1), AlphArray(2), AlphArray(3), "Chilled Water Nodes"); if (NumAlphas >= 4) { tower.PerformanceInputMethod_Num = static_cast(getEnumValue(PIMNamesUC, Util::makeUPPER(AlphArray(4)))); @@ -731,9 +676,7 @@ namespace CondenserLoopTowers { // Basin heater power as a function of temperature must be greater than or equal to 0 tower.BasinHeaterPowerFTempDiff = NumArray(25); if (NumArray(25) < 0.0) { - ShowSevereError( - state, - format("{}, \"{}\" basin heater power as a function of temperature difference must be >= 0", cCurrentModuleObject, tower.Name)); + ShowSevereCustom(state, eoh, "Basin heater power as a function of temperature difference must be >= 0"); ErrorsFound = true; } @@ -743,23 +686,14 @@ namespace CondenserLoopTowers { tower.BasinHeaterSetPointTemp = 2.0; } if (tower.BasinHeaterSetPointTemp < 2.0) { - ShowWarningError(state, - format("{}:\"{}\", {} is less than 2 deg C. Freezing could occur.", - cCurrentModuleObject, - tower.Name, - state.dataIPShortCut->cNumericFieldNames(26))); + ShowWarningCustom(state, eoh, format("{} is less than 2 deg C. Freezing could occur.", s_ipsc->cNumericFieldNames(26))); } } if (!AlphArray(5).empty()) { - tower.BasinHeaterSchedulePtr = ScheduleManager::GetScheduleIndex(state, AlphArray(5)); - if (tower.BasinHeaterSchedulePtr == 0) { - ShowWarningError(state, - format("{}, \"{}\" basin heater schedule name \"{}\" was not found. Basin heater operation will not be modeled " - "and the simulation continues", - cCurrentModuleObject, - tower.Name, - AlphArray(5))); + if ((tower.basinHeaterSched = Sched::GetSchedule(state, AlphArray(5))) == nullptr) { + ShowWarningItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(5), AlphArray(5), + "Basin heater operation will not be modeled and the simulation continues"); } } @@ -772,11 +706,11 @@ namespace CondenserLoopTowers { if (tower.SizFac <= 0.0) tower.SizFac = 1.0; tower.BlowdownMode = static_cast(getEnumValue(BlowDownNamesUC, Util::makeUPPER(AlphArray(7)))); - tower.SchedIDBlowdown = ScheduleManager::GetScheduleIndex(state, AlphArray(8)); - if ((tower.SchedIDBlowdown == 0) && (tower.BlowdownMode == Blowdown::Schedule)) { - ShowSevereError(state, format("Invalid, {} = \"{}\"", state.dataIPShortCut->cAlphaFieldNames(8), AlphArray(8))); - ShowContinueError(state, format("Entered in {} = \"{}\"", cCoolingTower_TwoSpeed, tower.Name)); - ErrorsFound = true; + if (tower.BlowdownMode == Blowdown::Schedule) { + if ((tower.blowdownSched = Sched::GetSchedule(state, AlphArray(8))) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(8), AlphArray(8)); + ErrorsFound = true; + } } // added for multi-cell @@ -797,20 +731,20 @@ namespace CondenserLoopTowers { } // cell control for two speed tower - if (!state.dataIPShortCut->lAlphaFieldBlanks(11)) { + if (!s_ipsc->lAlphaFieldBlanks(11)) { tower.cellCtrl = static_cast(getEnumValue(CellCtrlNamesUC, Util::makeUPPER(AlphArray(11)))); } - if (state.dataIPShortCut->lAlphaFieldBlanks(9)) { + if (s_ipsc->lAlphaFieldBlanks(9)) { tower.SuppliedByWaterSystem = false; } else { // water from storage tank WaterManager::SetupTankDemandComponent( - state, AlphArray(1), cCurrentModuleObject, AlphArray(9), ErrorsFound, tower.WaterTankID, tower.WaterTankDemandARRID); + state, AlphArray(1), s_ipsc->cCurrentModuleObject, AlphArray(9), ErrorsFound, tower.WaterTankID, tower.WaterTankDemandARRID); tower.SuppliedByWaterSystem = true; } // outdoor air inlet node - if (state.dataIPShortCut->lAlphaFieldBlanks(10)) { + if (s_ipsc->lAlphaFieldBlanks(10)) { tower.OutdoorAirInletNodeNum = 0; } else { tower.OutdoorAirInletNodeNum = NodeInputManager::GetOnlySingleNode(state, @@ -823,12 +757,7 @@ namespace CondenserLoopTowers { NodeInputManager::CompFluidStream::Primary, DataLoopNode::ObjectIsNotParent); if (!OutAirNodeManager::CheckOutAirNodeNumber(state, tower.OutdoorAirInletNodeNum)) { - ShowSevereError(state, - format("{}, \"{}\" Outdoor Air Inlet Node Name not valid Outdoor Air Node= {}", - cCurrentModuleObject, - tower.Name, - AlphArray(10))); - ShowContinueError(state, "...does not appear in an OutdoorAir:NodeList or as an OutdoorAir:Node."); + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(10), AlphArray(10)); ErrorsFound = true; } } @@ -838,7 +767,7 @@ namespace CondenserLoopTowers { if (tower.HighSpeedAirFlowRate <= tower.LowSpeedAirFlowRate && tower.HighSpeedAirFlowRate != DataSizing::AutoSize) { ShowSevereError( state, - format("{} \"{}\". Low speed air flow rate must be less than the high speed air flow rate.", cCurrentModuleObject, tower.Name)); + format("{} \"{}\". Low speed air flow rate must be less than the high speed air flow rate.", s_ipsc->cCurrentModuleObject, tower.Name)); ErrorsFound = true; } // Low speed air flow rate must be greater than free convection air flow rate. @@ -846,7 +775,7 @@ namespace CondenserLoopTowers { if (tower.LowSpeedAirFlowRate <= tower.FreeConvAirFlowRate && tower.LowSpeedAirFlowRate != DataSizing::AutoSize) { ShowSevereError(state, format("{} \"{}\". Free convection air flow rate must be less than the low speed air flow rate.", - cCurrentModuleObject, + s_ipsc->cCurrentModuleObject, tower.Name)); ErrorsFound = true; } @@ -856,21 +785,21 @@ namespace CondenserLoopTowers { if (tower.DesignWaterFlowRate == 0.0) { ShowSevereError(state, format("{} \"{}\". Tower performance input method requires a design water flow rate greater than zero.", - cCurrentModuleObject, + s_ipsc->cCurrentModuleObject, tower.Name)); ErrorsFound = true; } if (tower.HighSpeedTowerUA <= tower.LowSpeedTowerUA && tower.HighSpeedTowerUA != DataSizing::AutoSize) { ShowSevereError(state, format("{} \"{}\". Tower UA at low fan speed must be less than the tower UA at high fan speed.", - cCurrentModuleObject, + s_ipsc->cCurrentModuleObject, tower.Name)); ErrorsFound = true; } if (tower.LowSpeedTowerUA <= tower.FreeConvTowerUA && tower.LowSpeedTowerUA != DataSizing::AutoSize) { ShowSevereError(state, format("{} \"{}\". Tower UA at free convection air flow rate must be less than the tower UA at low fan speed.", - cCurrentModuleObject, + s_ipsc->cCurrentModuleObject, tower.Name)); ErrorsFound = true; } @@ -878,7 +807,7 @@ namespace CondenserLoopTowers { ShowSevereError( state, format("{} \"{}\". Free convection air flow rate must be greater than zero when free convection UA is greater than zero.", - cCurrentModuleObject, + s_ipsc->cCurrentModuleObject, tower.Name)); ErrorsFound = true; } @@ -886,14 +815,14 @@ namespace CondenserLoopTowers { if (tower.TowerNominalCapacity == 0.0) { ShowSevereError(state, format("{} \"{}\". Tower performance input method requires valid high-speed nominal capacity.", - cCurrentModuleObject, + s_ipsc->cCurrentModuleObject, tower.Name)); ErrorsFound = true; } if (tower.TowerLowSpeedNomCap == 0.0) { ShowSevereError(state, format("{} \"{}\". Tower performance input method requires valid low-speed nominal capacity.", - cCurrentModuleObject, + s_ipsc->cCurrentModuleObject, tower.Name)); ErrorsFound = true; } @@ -901,13 +830,13 @@ namespace CondenserLoopTowers { if (tower.DesignWaterFlowRate > 0.0) { ShowWarningError(state, format("{} \"{}\". Nominal capacity input method and design water flow rate have been specified.", - cCurrentModuleObject, + s_ipsc->cCurrentModuleObject, tower.Name)); } else { ShowSevereError( state, format("{} \"{}\". Nominal capacity input method has been specified and design water flow rate is being autosized.", - cCurrentModuleObject, + s_ipsc->cCurrentModuleObject, tower.Name)); } ShowContinueError(state, "Design water flow rate will be set according to nominal tower capacity."); @@ -916,13 +845,13 @@ namespace CondenserLoopTowers { if (tower.HighSpeedTowerUA > 0.0) { ShowWarningError(state, format("{} \"{}\". Nominal capacity input method and tower UA at high fan speed have been specified.", - cCurrentModuleObject, + s_ipsc->cCurrentModuleObject, tower.Name)); } else { ShowSevereError( state, format("{} \"{}\". Nominal capacity input method has been specified and tower UA at high fan speed is being autosized.", - cCurrentModuleObject, + s_ipsc->cCurrentModuleObject, tower.Name)); } ShowContinueError(state, "Tower UA at high fan speed will be set according to nominal tower capacity."); @@ -931,13 +860,13 @@ namespace CondenserLoopTowers { if (tower.LowSpeedTowerUA > 0.0) { ShowWarningError(state, format("{} \"{}\". Nominal capacity input method and tower UA at low fan speed have been specified.", - cCurrentModuleObject, + s_ipsc->cCurrentModuleObject, tower.Name)); } else { ShowSevereError( state, format("{} \"{}\". Nominal capacity input method has been specified and tower UA at low fan speed is being autosized.", - cCurrentModuleObject, + s_ipsc->cCurrentModuleObject, tower.Name)); } ShowContinueError(state, "Tower UA at low fan speed will be set according to nominal tower capacity."); @@ -946,13 +875,13 @@ namespace CondenserLoopTowers { if (tower.FreeConvTowerUA > 0.0) { ShowWarningError(state, format("{} \"{}\". Nominal capacity input method and free convection UA have been specified.", - cCurrentModuleObject, + s_ipsc->cCurrentModuleObject, tower.Name)); } else { ShowSevereError( state, format("{} \"{}\". Nominal capacity input method has been specified and free convection UA is being autosized.", - cCurrentModuleObject, + s_ipsc->cCurrentModuleObject, tower.Name)); } ShowContinueError(state, "Free convection UA will be set according to nominal tower capacity."); @@ -960,7 +889,7 @@ namespace CondenserLoopTowers { if (tower.TowerLowSpeedNomCap >= tower.TowerNominalCapacity) { ShowSevereError(state, format("{} \"{}\". Low-speed nominal capacity must be less than the high-speed nominal capacity.", - cCurrentModuleObject, + s_ipsc->cCurrentModuleObject, tower.Name)); ErrorsFound = true; } @@ -968,29 +897,20 @@ namespace CondenserLoopTowers { if (tower.TowerFreeConvNomCap >= tower.TowerLowSpeedNomCap) { ShowSevereError(state, format("{} \"{}\". Free convection nominal capacity must be less than the low-speed nominal capacity.", - cCurrentModuleObject, + s_ipsc->cCurrentModuleObject, tower.Name)); ErrorsFound = true; } } if (tower.TowerFreeConvNomCap > 0.0 && tower.FreeConvAirFlowRate == 0.0) { - ShowSevereError( - state, - format("{} \"{}\". Free convection air flow must be greater than zero when tower free convection capacity is specified.", - cCurrentModuleObject, - tower.Name)); + ShowSevereCustom(state, eoh, "Free convection air flow must be greater than zero when tower free convection capacity is specified."); ErrorsFound = true; } } else { // Tower performance input method is not specified as a valid "choice" - ShowSevereError( - state, - format("{} \"{}{}", - cCurrentModuleObject, - tower.Name, - R"(". Tower Performance Input Method must be "UFactorTimesAreaAndDesignWaterFlowRate" or "NominalCapacity".)")); - ShowContinueError(state, format("Tower Performanace Input Method currently specified as: {}", AlphArray(4))); + ShowSevereInvalidKey(state, eoh, s_ipsc->cAlphaFieldNames(4), AlphArray(4)); ErrorsFound = true; } + if (NumAlphas > 11) { tower.EndUseSubcategory = AlphArray(12); } else { @@ -998,11 +918,11 @@ namespace CondenserLoopTowers { } } // End Two-Speed Tower Loop - cCurrentModuleObject = cCoolingTower_VariableSpeed; + s_ipsc->cCurrentModuleObject = cCoolingTower_VariableSpeed; for (int VariableSpeedTowerNumber = 1; VariableSpeedTowerNumber <= NumVariableSpeedTowers; ++VariableSpeedTowerNumber) { TowerNum = NumSingleSpeedTowers + NumTwoSpeedTowers + VariableSpeedTowerNumber; - state.dataInputProcessing->inputProcessor->getObjectItem(state, - cCurrentModuleObject, + s_ip->getObjectItem(state, + s_ipsc->cCurrentModuleObject, VariableSpeedTowerNumber, AlphArray, NumAlphas, @@ -1010,11 +930,12 @@ namespace CondenserLoopTowers { NumNums, IOStat, _, - state.dataIPShortCut->lAlphaFieldBlanks, - state.dataIPShortCut->cAlphaFieldNames, - state.dataIPShortCut->cNumericFieldNames); + s_ipsc->lAlphaFieldBlanks, + s_ipsc->cAlphaFieldNames, + s_ipsc->cNumericFieldNames); + ErrorObjectHeader eoh{routineName, s_ipsc->cCurrentModuleObject, AlphArray(1)}; GlobalNames::VerifyUniqueInterObjectName( - state, UniqueSimpleTowerNames, AlphArray(1), cCurrentModuleObject, state.dataIPShortCut->cAlphaFieldNames(1), ErrorsFound); + state, UniqueSimpleTowerNames, AlphArray(1), s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaFieldNames(1), ErrorsFound); auto &tower = state.dataCondenserLoopTowers->towers(TowerNum); tower.VSTower = VariableSpeedTowerNumber; @@ -1038,40 +959,31 @@ namespace CondenserLoopTowers { DataLoopNode::ConnectionType::Outlet, NodeInputManager::CompFluidStream::Primary, DataLoopNode::ObjectIsNotParent); - BranchNodeConnections::TestCompSet(state, cCurrentModuleObject, AlphArray(1), AlphArray(2), AlphArray(3), "Chilled Water Nodes"); + BranchNodeConnections::TestCompSet(state, s_ipsc->cCurrentModuleObject, AlphArray(1), AlphArray(2), AlphArray(3), "Chilled Water Nodes"); if ((Util::SameString(AlphArray(4), "CoolToolsUserDefined") || Util::SameString(AlphArray(4), "YorkCalcUserDefined")) && - state.dataIPShortCut->lAlphaFieldBlanks(5)) { - ShowSevereError(state, - format("{}, \"{}\" a {} must be specified when {} is specified as CoolToolsUserDefined or YorkCalcUserDefined", - cCurrentModuleObject, - tower.Name, - state.dataIPShortCut->cAlphaFieldNames(5), - state.dataIPShortCut->cAlphaFieldNames(4))); + s_ipsc->lAlphaFieldBlanks(5)) { + ShowSevereCustom(state, eoh, + format("A {} must be specified when {} is specified as CoolToolsUserDefined or YorkCalcUserDefined", + s_ipsc->cAlphaFieldNames(5), + s_ipsc->cAlphaFieldNames(4))); ErrorsFound = true; } else if ((Util::SameString(AlphArray(4), "CoolToolsCrossFlow") || Util::SameString(AlphArray(4), "YorkCalc")) && - !state.dataIPShortCut->lAlphaFieldBlanks(5)) { - ShowWarningError(state, - format("{}, \"{}\" a Tower Model Coefficient Name is specified and the Tower Model Type is not specified as " - "CoolToolsUserDefined or YorkCalcUserDefined. The CoolingTowerPerformance:CoolTools " - "(orCoolingTowerPerformance:YorkCalc) data object will not be used.", - cCurrentModuleObject, - tower.Name)); + !s_ipsc->lAlphaFieldBlanks(5)) { + ShowWarningCustom(state, eoh, "A Tower Model Coefficient Name is specified and the Tower Model Type is not specified as " + "CoolToolsUserDefined or YorkCalcUserDefined. The CoolingTowerPerformance:CoolTools " + "(orCoolingTowerPerformance:YorkCalc) data object will not be used."); } else { tower.ModelCoeffObjectName = AlphArray(5); } - if (!state.dataIPShortCut->lAlphaFieldBlanks(6)) { + if (!s_ipsc->lAlphaFieldBlanks(6)) { tower.FanPowerfAirFlowCurve = Curve::GetCurveIndex(state, AlphArray(6)); if (tower.FanPowerfAirFlowCurve == 0) { - ShowWarningError( - state, - format( - "{}, \"{}\" the Fan Power Ratio as a function of Air Flow Rate Ratio Curve Name specified as {} was not found. Fan Power " - "as a function of Air Flow Rate Ratio will default to Fan Power = (Air Flow Rate Ratio)^3 and the simulation continues.", - cCurrentModuleObject, - tower.Name, - AlphArray(6))); + ShowWarningCustom(state, eoh, + format("The Fan Power Ratio as a function of Air Flow Rate Ratio Curve Name specified as {} was not found." + "Fan Power as a function of Air Flow Rate Ratio will default to Fan Power = (Air Flow Rate Ratio)^3." + "The simulation continues.", AlphArray(6))); } } @@ -1174,8 +1086,8 @@ namespace CondenserLoopTowers { tower.TowerModelType = ModelType::CoolToolsUserDefined; // Nested Get-input routines below. Should pull out of here and read in beforehand. for (VSModelCoeffNum = 1; VSModelCoeffNum <= NumVSCoolToolsModelCoeffs; ++VSModelCoeffNum) { - state.dataInputProcessing->inputProcessor->getObjectItem( - state, "CoolingTowerPerformance:CoolTools", VSModelCoeffNum, AlphArray2, NumAlphas2, NumArray2, NumNums2, IOStat); + s_ip->getObjectItem(state, "CoolingTowerPerformance:CoolTools", VSModelCoeffNum, AlphArray2, NumAlphas2, NumArray2, NumNums2, IOStat); + if (!Util::SameString(AlphArray2(1), tower.ModelCoeffObjectName)) continue; vstower.FoundModelCoeff = true; // verify the correct number of coefficients for the CoolTools model @@ -1215,7 +1127,7 @@ namespace CondenserLoopTowers { tower.TowerModelType = ModelType::YorkCalcUserDefined; // Nested Get-input routines below. Should pull out of here and read in beforehand. for (VSModelCoeffNum = 1; VSModelCoeffNum <= NumVSYorkCalcModelCoeffs; ++VSModelCoeffNum) { - state.dataInputProcessing->inputProcessor->getObjectItem( + s_ip->getObjectItem( state, "CoolingTowerPerformance:YorkCalc", VSModelCoeffNum, AlphArray2, NumAlphas2, NumArray2, NumNums2, IOStat); if (!Util::SameString(AlphArray2(1), tower.ModelCoeffObjectName)) continue; vstower.FoundModelCoeff = true; @@ -1249,15 +1161,13 @@ namespace CondenserLoopTowers { if (!vstower.FoundModelCoeff) { ShowSevereError(state, format("{} \"{}\". User defined name for variable speed cooling tower model coefficients object not found = {}", - cCurrentModuleObject, + s_ipsc->cCurrentModuleObject, tower.Name, tower.ModelCoeffObjectName)); ErrorsFound = true; } } else { - ShowSevereError(state, format("{} \"{}\". Illegal Tower Model Type = {}", cCurrentModuleObject, tower.Name, AlphArray(5))); - ShowContinueError(state, - R"( Tower Model Type must be "CoolToolsCrossFlow", "YorkCalc", "CoolToolsUserDefined", or "YorkCalcUserDefined.)"); + ShowSevereInvalidKey(state, eoh, s_ipsc->cAlphaFieldNames(5), AlphArray(5)); ErrorsFound = true; } @@ -1265,83 +1175,53 @@ namespace CondenserLoopTowers { // check user defined minimums to be greater than 0 if (vstower.MinApproachTemp < 0.0) { - ShowSevereError(state, format("{} \"{}\". User defined minimum approach temperature must be > 0", cCurrentModuleObject, tower.Name)); + ShowSevereCustom(state, eoh, "User defined minimum approach temperature must be > 0"); ErrorsFound = true; } if (vstower.MinRangeTemp < 0.0) { - ShowSevereError(state, format("{} \"{}\". User defined minimum range temperature must be > 0", cCurrentModuleObject, tower.Name)); + ShowSevereCustom(state, eoh, "User defined minimum range temperature must be > 0"); ErrorsFound = true; } if (vstower.MinWaterFlowRatio < 0.0) { - ShowSevereError(state, format("{} \"{}\". User defined minimum water flow rate ratio must be > 0", cCurrentModuleObject, tower.Name)); + ShowSevereCustom(state, eoh, "User defined minimum water flow rate ratio must be > 0"); ErrorsFound = true; } // check that the user defined maximums are greater than the minimums if (vstower.MaxApproachTemp < vstower.MinApproachTemp) { - ShowSevereError(state, - format("{} \"{}\". User defined maximum approach temperature must be > the minimum approach temperature", - cCurrentModuleObject, - tower.Name)); + ShowSevereCustom(state, eoh, "User defined maximum approach temperature must be > the minimum approach temperature"); ErrorsFound = true; } if (vstower.MaxRangeTemp < vstower.MinRangeTemp) { - ShowSevereError(state, - format("{} \"{}\". User defined maximum range temperature must be > the minimum range temperature", - cCurrentModuleObject, - tower.Name)); + ShowSevereCustom(state, eoh, "User defined maximum range temperature must be > the minimum range temperature"); ErrorsFound = true; } if (vstower.MaxWaterFlowRatio < vstower.MinWaterFlowRatio) { - ShowSevereError(state, - format("{} \"{}\". User defined maximum water flow rate ratio must be > the minimum water flow rate ratio", - cCurrentModuleObject, - tower.Name)); + ShowSevereCustom(state, eoh, "User defined maximum water flow rate ratio must be > the minimum water flow rate ratio"); ErrorsFound = true; } tower.DesignInletWB = NumArray(1); if (NumArray(1) < vstower.MinInletAirWBTemp || NumArray(1) > vstower.MaxInletAirWBTemp) { - ShowSevereError(state, - cCurrentModuleObject.append(", \"") - .append(tower.Name) - .append("\" the design inlet air wet-bulb temperature of ") - .append(format(OutputFormat, tower.DesignInletWB)) - .append(" must be within the model limits of ") - .append(format(OutputFormat, vstower.MinInletAirWBTemp)) - .append(" and ") - .append(format(OutputFormat, vstower.MaxInletAirWBTemp)) - .append(" degrees C")); + ShowSevereCustom(state, eoh, format("The design inlet air wet-bulb temperature of {:5.2F}" + "must be within the model limits of {:5.2F} and {:5.2F} degrees C", + tower.DesignInletWB, vstower.MinInletAirWBTemp, vstower.MaxInletAirWBTemp)); ErrorsFound = true; } tower.DesignApproach = NumArray(2); if (NumArray(2) < vstower.MinApproachTemp || NumArray(2) > vstower.MaxApproachTemp) { - ShowSevereError(state, - cCurrentModuleObject.append(", \"") - .append(tower.Name) - .append("\" the design approach temperature of ") - .append(format(OutputFormat, tower.DesignApproach)) - .append(" must be within the model limits of ") - .append(format(OutputFormat, vstower.MinApproachTemp)) - .append(" and ") - .append(format(OutputFormat, vstower.MaxApproachTemp)) - .append(" degrees C")); + ShowSevereCustom(state, eoh, format("The design approach temperature of {:5.2F}" + "must be within the model limits of {:5.2F} and {:5.2F} degrees C", + tower.DesignApproach, vstower.MinApproachTemp, vstower.MaxApproachTemp)); ErrorsFound = true; } tower.DesignRange = NumArray(3); if (NumArray(3) < vstower.MinRangeTemp || NumArray(3) > vstower.MaxRangeTemp) { - ShowSevereError(state, - cCurrentModuleObject.append(", \"") - .append(tower.Name) - .append("\" the design range temperature of ") - .append(format(OutputFormat, tower.DesignRange)) - .append(" must be within the model limits of ") - .append(format(OutputFormat, vstower.MinRangeTemp)) - .append(" and ") - .append(format(OutputFormat, vstower.MaxRangeTemp)) - .append(" degrees C")); + ShowSevereCustom(state, eoh, format("The design range temperature of {:5.2F}" + "must be within the model limits of {:5.2F} and {:5.2F} degrees C", + tower.DesignRange, vstower.MinRangeTemp, vstower.MaxRangeTemp)); ErrorsFound = true; } @@ -1350,7 +1230,7 @@ namespace CondenserLoopTowers { tower.DesignWaterFlowRateWasAutoSized = true; } if (NumArray(4) <= 0.0 && NumArray(4) != DataSizing::AutoSize) { - ShowSevereError(state, format("{}, \"{}\" design water flow rate must be > 0", cCurrentModuleObject, tower.Name)); + ShowSevereCustom(state, eoh, "Design water flow rate must be > 0"); ErrorsFound = true; } @@ -1359,7 +1239,7 @@ namespace CondenserLoopTowers { tower.HighSpeedAirFlowRateWasAutoSized = true; } if (NumArray(5) <= 0.0 && NumArray(5) != DataSizing::AutoSize) { - ShowSevereError(state, format("{}, \"{}\" design air flow rate must be > 0", cCurrentModuleObject, tower.Name)); + ShowSevereCustom(state, eoh, "Design air flow rate must be > 0"); ErrorsFound = true; } @@ -1368,7 +1248,7 @@ namespace CondenserLoopTowers { tower.HighSpeedFanPowerWasAutoSized = true; } if (NumArray(6) <= 0.0 && NumArray(6) != DataSizing::AutoSize) { - ShowSevereError(state, format("{}, \"{}\" design fan power must be > 0", cCurrentModuleObject, tower.Name)); + ShowSevereCustom(state, eoh, "Design fan power must be > 0"); ErrorsFound = true; } @@ -1376,27 +1256,21 @@ namespace CondenserLoopTowers { tower.MinimumVSAirFlowFrac = NumArray(7); tower.MinimumVSAirFlowFrac = NumArray(7); if (NumArray(7) < 0.2 || NumArray(7) > 0.5) { - ShowSevereError(state, - format("{}, \"{}\" minimum VS air flow rate ratio must be >= 0.2 and <= 0.5", cCurrentModuleObject, tower.Name)); + ShowSevereCustom(state, eoh, "Minimum VS air flow rate ratio must be >= 0.2 and <= 0.5"); ErrorsFound = true; } // fraction of tower capacity in free convection regime must be >= to 0 and <= 0.2 tower.FreeConvectionCapacityFraction = NumArray(8); if (NumArray(8) < 0.0 || NumArray(8) > 0.2) { - ShowSevereError(state, - format("{}, \"{}\" fraction of tower capacity in free convection regime must be >= 0 and <= 0.2", - cCurrentModuleObject, - tower.Name)); + ShowSevereCustom(state, eoh, "Fraction of tower capacity in free convection regime must be >= 0 and <= 0.2"); ErrorsFound = true; } // Basin heater power as a function of temperature must be greater than or equal to 0 tower.BasinHeaterPowerFTempDiff = NumArray(9); if (NumArray(9) < 0.0) { - ShowSevereError( - state, - format("{}, \"{}\" basin heater power as a function of temperature difference must be >= 0", cCurrentModuleObject, tower.Name)); + ShowSevereCustom(state, eoh, "Basin heater power as a function of temperature difference must be >= 0"); ErrorsFound = true; } @@ -1406,11 +1280,7 @@ namespace CondenserLoopTowers { tower.BasinHeaterSetPointTemp = 2.0; } if (tower.BasinHeaterSetPointTemp < 2.0) { - ShowWarningError(state, - format("{}:\"{}\", {} is less than 2 deg C. Freezing could occur.", - cCurrentModuleObject, - tower.Name, - state.dataIPShortCut->cNumericFieldNames(10))); + ShowWarningCustom(state, eoh, format("{} is less than 2 deg C. Freezing could occur.", s_ipsc->cNumericFieldNames(10))); } } @@ -1419,14 +1289,10 @@ namespace CondenserLoopTowers { tower.PerformanceInputMethod_Num = PIM::UFactor; if (!AlphArray(7).empty()) { - tower.BasinHeaterSchedulePtr = ScheduleManager::GetScheduleIndex(state, AlphArray(7)); - if (tower.BasinHeaterSchedulePtr == 0) { - ShowWarningError(state, - format("{}, \"{}\" basin heater schedule name \"{}\" was not found. Basin heater operation will not be modeled " - "and the simulation continues", - cCurrentModuleObject, - tower.Name, - AlphArray(7))); + if ((tower.basinHeaterSched = Sched::GetSchedule(state, AlphArray(7))) == nullptr) { + ShowWarningItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(7), AlphArray(7), + "Basin heater operation will not be modeled and the simulation continues."); + } } @@ -1439,11 +1305,11 @@ namespace CondenserLoopTowers { if (tower.SizFac <= 0.0) tower.SizFac = 1.0; tower.BlowdownMode = static_cast(getEnumValue(BlowDownNamesUC, Util::makeUPPER(AlphArray(9)))); - tower.SchedIDBlowdown = ScheduleManager::GetScheduleIndex(state, AlphArray(10)); - if ((tower.SchedIDBlowdown == 0) && (tower.BlowdownMode == Blowdown::Schedule)) { - ShowSevereError(state, format("Invalid, {} = \"{}\"", state.dataIPShortCut->cAlphaFieldNames(10), AlphArray(10))); - ShowContinueError(state, format("Entered in {} = \"{}\"", cCoolingTower_VariableSpeed, tower.Name)); - ErrorsFound = true; + if (tower.BlowdownMode == Blowdown::Schedule) { + if ((tower.blowdownSched = Sched::GetSchedule(state, AlphArray(10))) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(10), AlphArray(10)); + ErrorsFound = true; + } } // added for multi-cell @@ -1464,20 +1330,20 @@ namespace CondenserLoopTowers { } // cell control for variable speed tower - if (!state.dataIPShortCut->lAlphaFieldBlanks(13)) { + if (!s_ipsc->lAlphaFieldBlanks(13)) { tower.cellCtrl = static_cast(getEnumValue(CellCtrlNamesUC, Util::makeUPPER(AlphArray(13)))); } - if (state.dataIPShortCut->lAlphaFieldBlanks(11)) { + if (s_ipsc->lAlphaFieldBlanks(11)) { tower.SuppliedByWaterSystem = false; } else { // water from storage tank WaterManager::SetupTankDemandComponent( - state, AlphArray(1), cCurrentModuleObject, AlphArray(11), ErrorsFound, tower.WaterTankID, tower.WaterTankDemandARRID); + state, AlphArray(1), s_ipsc->cCurrentModuleObject, AlphArray(11), ErrorsFound, tower.WaterTankID, tower.WaterTankDemandARRID); tower.SuppliedByWaterSystem = true; } // outdoor air inlet node - if (state.dataIPShortCut->lAlphaFieldBlanks(12)) { + if (s_ipsc->lAlphaFieldBlanks(12)) { tower.OutdoorAirInletNodeNum = 0; } else { tower.OutdoorAirInletNodeNum = NodeInputManager::GetOnlySingleNode(state, @@ -1490,12 +1356,7 @@ namespace CondenserLoopTowers { NodeInputManager::CompFluidStream::Primary, DataLoopNode::ObjectIsNotParent); if (!OutAirNodeManager::CheckOutAirNodeNumber(state, tower.OutdoorAirInletNodeNum)) { - ShowSevereError(state, - format("{}, \"{}\" Outdoor Air Inlet Node Name not valid Outdoor Air Node= {}", - cCurrentModuleObject, - tower.Name, - AlphArray(12))); - ShowContinueError(state, "...does not appear in an OutdoorAir:NodeList or as an OutdoorAir:Node."); + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(12), AlphArray(12)); ErrorsFound = true; } } @@ -1507,23 +1368,25 @@ namespace CondenserLoopTowers { } // End Variable-Speed Tower Loop - cCurrentModuleObject = cCoolingTower_VariableSpeedMerkel; + s_ipsc->cCurrentModuleObject = cCoolingTower_VariableSpeedMerkel; for (int MerkelVSTowerNum = 1; MerkelVSTowerNum <= NumVSMerkelTowers; ++MerkelVSTowerNum) { TowerNum = NumSingleSpeedTowers + NumTwoSpeedTowers + NumVariableSpeedTowers + MerkelVSTowerNum; - state.dataInputProcessing->inputProcessor->getObjectItem(state, - cCurrentModuleObject, + s_ip->getObjectItem(state, + s_ipsc->cCurrentModuleObject, MerkelVSTowerNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat, - state.dataIPShortCut->lNumericFieldBlanks, - state.dataIPShortCut->lAlphaFieldBlanks, - state.dataIPShortCut->cAlphaFieldNames, - state.dataIPShortCut->cNumericFieldNames); + s_ipsc->lNumericFieldBlanks, + s_ipsc->lAlphaFieldBlanks, + s_ipsc->cAlphaFieldNames, + s_ipsc->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, s_ipsc->cCurrentModuleObject, AlphArray(1)}; GlobalNames::VerifyUniqueInterObjectName( - state, UniqueSimpleTowerNames, AlphArray(1), cCurrentModuleObject, state.dataIPShortCut->cAlphaFieldNames(1), ErrorsFound); + state, UniqueSimpleTowerNames, AlphArray(1), s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaFieldNames(1), ErrorsFound); auto &tower = state.dataCondenserLoopTowers->towers(TowerNum); tower.Name = AlphArray(1); tower.TowerType = DataPlant::PlantEquipmentType::CoolingTower_VarSpdMerkel; @@ -1545,23 +1408,20 @@ namespace CondenserLoopTowers { DataLoopNode::ConnectionType::Outlet, NodeInputManager::CompFluidStream::Primary, DataLoopNode::ObjectIsNotParent); - BranchNodeConnections::TestCompSet(state, cCurrentModuleObject, AlphArray(1), AlphArray(2), AlphArray(3), "Chilled Water Nodes"); + BranchNodeConnections::TestCompSet(state, s_ipsc->cCurrentModuleObject, AlphArray(1), AlphArray(2), AlphArray(3), "Chilled Water Nodes"); if (Util::SameString(AlphArray(4), "UFactorTimesAreaAndDesignWaterFlowRate")) { tower.PerformanceInputMethod_Num = PIM::UFactor; } else if (Util::SameString(AlphArray(4), "NominalCapacity")) { tower.PerformanceInputMethod_Num = PIM::NominalCapacity; } else { - ShowSevereError(state, format("{}={}", cCurrentModuleObject, AlphArray(1))); - ShowContinueError(state, format("Invalid, {} = {}", state.dataIPShortCut->cAlphaFieldNames(4), AlphArray(4))); + ShowSevereInvalidKey(state, eoh, s_ipsc->cAlphaFieldNames(4), AlphArray(4)); ErrorsFound = true; } tower.FanPowerfAirFlowCurve = Curve::GetCurveIndex(state, AlphArray(5)); if (tower.FanPowerfAirFlowCurve == 0) { - ShowSevereError(state, format("{}={}", cCurrentModuleObject, AlphArray(1))); - ShowContinueError(state, format("Invalid {}={}", state.dataIPShortCut->cAlphaFieldNames(5), AlphArray(5))); - ShowContinueError(state, "Curve name not found."); + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(5), AlphArray(5)); ErrorsFound = true; } @@ -1584,7 +1444,7 @@ namespace CondenserLoopTowers { if (tower.HighSpeedAirFlowRate == DataSizing::AutoSize) { tower.HighSpeedAirFlowRateWasAutoSized = true; } - tower.DefaultedDesignAirFlowScalingFactor = state.dataIPShortCut->lNumericFieldBlanks(8); + tower.DefaultedDesignAirFlowScalingFactor = s_ipsc->lNumericFieldBlanks(8); tower.DesignAirFlowPerUnitNomCap = NumArray(8); tower.MinimumVSAirFlowFrac = NumArray(9); tower.HighSpeedFanPower = NumArray(10); @@ -1609,25 +1469,19 @@ namespace CondenserLoopTowers { tower.UAModFuncAirFlowRatioCurvePtr = Curve::GetCurveIndex(state, AlphArray(6)); if (tower.UAModFuncAirFlowRatioCurvePtr == 0) { - ShowSevereError(state, format("{}={}", cCurrentModuleObject, AlphArray(1))); - ShowContinueError(state, format("Invalid {}={}", state.dataIPShortCut->cAlphaFieldNames(6), AlphArray(6))); - ShowContinueError(state, "Curve name not found."); + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(6), AlphArray(6)); ErrorsFound = true; } tower.UAModFuncWetBulbDiffCurvePtr = Curve::GetCurveIndex(state, AlphArray(7)); if (tower.UAModFuncWetBulbDiffCurvePtr == 0) { - ShowSevereError(state, format("{}={}", cCurrentModuleObject, AlphArray(1))); - ShowContinueError(state, format("Invalid {}={}", state.dataIPShortCut->cAlphaFieldNames(7), AlphArray(7))); - ShowContinueError(state, "Curve name not found."); + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(7), AlphArray(7)); ErrorsFound = true; } tower.UAModFuncWaterFlowRatioCurvePtr = Curve::GetCurveIndex(state, AlphArray(8)); if (tower.UAModFuncWaterFlowRatioCurvePtr == 0) { - ShowSevereError(state, format("{}={}", cCurrentModuleObject, AlphArray(1))); - ShowContinueError(state, format("Invalid {}={}", state.dataIPShortCut->cAlphaFieldNames(8), AlphArray(8))); - ShowContinueError(state, "Curve name not found."); + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(8), AlphArray(8)); ErrorsFound = true; } // cooling tower design inlet conditions @@ -1657,9 +1511,7 @@ namespace CondenserLoopTowers { // Basin heater power as a function of temperature must be greater than or equal to 0 tower.BasinHeaterPowerFTempDiff = NumArray(21); if (NumArray(21) < 0.0) { - ShowSevereError( - state, - format("{}, \"{}\" basin heater power as a function of temperature difference must be >= 0", cCurrentModuleObject, tower.Name)); + ShowSevereCustom(state, eoh, "Basin heater power as a function of temperature difference must be >= 0"); ErrorsFound = true; } @@ -1669,23 +1521,15 @@ namespace CondenserLoopTowers { tower.BasinHeaterSetPointTemp = 2.0; } if (tower.BasinHeaterSetPointTemp < 2.0) { - ShowWarningError(state, - format("{}:\"{}\", {} is less than 2 deg C. Freezing could occur.", - cCurrentModuleObject, - tower.Name, - state.dataIPShortCut->cNumericFieldNames(22))); + ShowWarningCustom(state, eoh, format("{} is less than 2 deg C. Freezing could occur.", s_ipsc->cNumericFieldNames(22))); } } if (!AlphArray(9).empty()) { - tower.BasinHeaterSchedulePtr = ScheduleManager::GetScheduleIndex(state, AlphArray(9)); - if (tower.BasinHeaterSchedulePtr == 0) { - ShowWarningError(state, - format("{}, \"{}\" basin heater schedule name \"{}\" was not found. Basin heater operation will not be modeled " - "and the simulation continues", - cCurrentModuleObject, - tower.Name, - AlphArray(9))); + if ((tower.basinHeaterSched = Sched::GetSchedule(state, AlphArray(9))) == nullptr) { + ShowWarningItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(9), AlphArray(9), + "Basin heater operation will not be modeled and the simulation continues"); + } } @@ -1698,11 +1542,11 @@ namespace CondenserLoopTowers { if (tower.SizFac <= 0.0) tower.SizFac = 1.0; tower.BlowdownMode = static_cast(getEnumValue(BlowDownNamesUC, Util::makeUPPER(AlphArray(11)))); - tower.SchedIDBlowdown = ScheduleManager::GetScheduleIndex(state, AlphArray(12)); - if ((tower.SchedIDBlowdown == 0) && (tower.BlowdownMode == Blowdown::Schedule)) { - ShowSevereError(state, format("Invalid, {} = \"{}\"", state.dataIPShortCut->cAlphaFieldNames(12), AlphArray(12))); - ShowContinueError(state, format("Entered in {} = \"{}\"", cCoolingTower_VariableSpeedMerkel, tower.Name)); - ErrorsFound = true; + if (tower.BlowdownMode == Blowdown::Schedule) { + if ((tower.blowdownSched = Sched::GetSchedule(state, AlphArray(12))) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(12), AlphArray(12)); + ErrorsFound = true; + } } // added for multi-cell @@ -1723,20 +1567,20 @@ namespace CondenserLoopTowers { } tower.TowerMassFlowRateMultiplier = tower.MaxFracFlowRate; // cell control for variable speed Merkel tower - if (!state.dataIPShortCut->lAlphaFieldBlanks(15)) { + if (!s_ipsc->lAlphaFieldBlanks(15)) { tower.cellCtrl = static_cast(getEnumValue(CellCtrlNamesUC, Util::makeUPPER(AlphArray(15)))); } - if (state.dataIPShortCut->lAlphaFieldBlanks(13)) { + if (s_ipsc->lAlphaFieldBlanks(13)) { tower.SuppliedByWaterSystem = false; } else { // water from storage tank WaterManager::SetupTankDemandComponent( - state, AlphArray(1), cCurrentModuleObject, AlphArray(13), ErrorsFound, tower.WaterTankID, tower.WaterTankDemandARRID); + state, AlphArray(1), s_ipsc->cCurrentModuleObject, AlphArray(13), ErrorsFound, tower.WaterTankID, tower.WaterTankDemandARRID); tower.SuppliedByWaterSystem = true; } // outdoor air inlet node - if (state.dataIPShortCut->lAlphaFieldBlanks(14)) { + if (s_ipsc->lAlphaFieldBlanks(14)) { tower.OutdoorAirInletNodeNum = 0; } else { tower.OutdoorAirInletNodeNum = @@ -1750,12 +1594,7 @@ namespace CondenserLoopTowers { NodeInputManager::CompFluidStream::Primary, DataLoopNode::ObjectIsNotParent); if (!OutAirNodeManager::CheckOutAirNodeNumber(state, tower.OutdoorAirInletNodeNum)) { - ShowSevereError(state, - format("{}, \"{}\" Outdoor Air Inlet Node Name not valid Outdoor Air Node= {}", - cCurrentModuleObject, - tower.Name, - AlphArray(14))); - ShowContinueError(state, "...does not appear in an OutdoorAir:NodeList or as an OutdoorAir:Node."); + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(14), AlphArray(14)); ErrorsFound = true; } } @@ -5511,12 +5350,12 @@ namespace CondenserLoopTowers { this->airFlowRateRatio = 0.0; this->Qactual = 0.0; CalcBasinHeaterPower( - state, this->BasinHeaterPowerFTempDiff, this->BasinHeaterSchedulePtr, this->BasinHeaterSetPointTemp, this->BasinHeaterPower); + state, this->BasinHeaterPowerFTempDiff, this->basinHeaterSched, this->BasinHeaterSetPointTemp, this->BasinHeaterPower); return; } else if (this->WaterMassFlowRate <= DataBranchAirLoopPlant::MassFlowTolerance || (MyLoad > HVAC::SmallLoad)) { // for multiple cells, we assume that it's a common basin CalcBasinHeaterPower( - state, this->BasinHeaterPowerFTempDiff, this->BasinHeaterSchedulePtr, this->BasinHeaterSetPointTemp, this->BasinHeaterPower); + state, this->BasinHeaterPowerFTempDiff, this->basinHeaterSched, this->BasinHeaterSetPointTemp, this->BasinHeaterPower); return; } @@ -5535,7 +5374,7 @@ namespace CondenserLoopTowers { this->airFlowRateRatio = 0.0; this->Qactual = FreeConvQdot; CalcBasinHeaterPower( - state, this->BasinHeaterPowerFTempDiff, this->BasinHeaterSchedulePtr, this->BasinHeaterSetPointTemp, this->BasinHeaterPower); + state, this->BasinHeaterPowerFTempDiff, this->basinHeaterSched, this->BasinHeaterSetPointTemp, this->BasinHeaterPower); return; } @@ -5575,7 +5414,7 @@ namespace CondenserLoopTowers { } this->Qactual = FullSpeedFanQdot; CalcBasinHeaterPower( - state, this->BasinHeaterPowerFTempDiff, this->BasinHeaterSchedulePtr, this->BasinHeaterSetPointTemp, this->BasinHeaterPower); + state, this->BasinHeaterPowerFTempDiff, this->basinHeaterSched, this->BasinHeaterSetPointTemp, this->BasinHeaterPower); // now calculate fan power FanPowerAdjustFac = Curve::CurveValue(state, this->FanPowerfAirFlowCurve, this->airFlowRateRatio); this->FanPower = this->HighSpeedFanPower * FanPowerAdjustFac * this->NumCellOn / this->NumCell; @@ -5595,7 +5434,7 @@ namespace CondenserLoopTowers { if (std::abs(MyLoad) <= MinSpeedFanQdot) { // min fan speed already exceeds load) this->Qactual = MinSpeedFanQdot; CalcBasinHeaterPower( - state, this->BasinHeaterPowerFTempDiff, this->BasinHeaterSchedulePtr, this->BasinHeaterSetPointTemp, this->BasinHeaterPower); + state, this->BasinHeaterPowerFTempDiff, this->basinHeaterSched, this->BasinHeaterSetPointTemp, this->BasinHeaterPower); // now calculate fan power FanPowerAdjustFac = Curve::CurveValue(state, this->FanPowerfAirFlowCurve, this->airFlowRateRatio); this->FanPower = this->HighSpeedFanPower * FanPowerAdjustFac * this->NumCellOn / this->NumCell; @@ -5672,7 +5511,7 @@ namespace CondenserLoopTowers { this->OutletWaterTemp = this->calculateSimpleTowerOutletTemp(state, WaterMassFlowRatePerCell, AirFlowRatePerCell, UAadjustedPerCell); this->Qactual = this->WaterMassFlowRate * CpWater * (state.dataLoopNodes->Node(this->WaterInletNodeNum).Temp - this->OutletWaterTemp); CalcBasinHeaterPower( - state, this->BasinHeaterPowerFTempDiff, this->BasinHeaterSchedulePtr, this->BasinHeaterSetPointTemp, this->BasinHeaterPower); + state, this->BasinHeaterPowerFTempDiff, this->basinHeaterSched, this->BasinHeaterSetPointTemp, this->BasinHeaterPower); // now calculate fan power FanPowerAdjustFac = Curve::CurveValue(state, this->FanPowerfAirFlowCurve, this->airFlowRateRatio); @@ -6271,11 +6110,7 @@ namespace CondenserLoopTowers { Real64 BlowDownVdot(0.0); if (this->BlowdownMode == Blowdown::Schedule) { // Amount of water lost due to blow down (purging contaminants from tower basin) - if (this->SchedIDBlowdown > 0) { - BlowDownVdot = ScheduleManager::GetCurrentScheduleValue(state, this->SchedIDBlowdown); - } else { - BlowDownVdot = 0.0; - } + BlowDownVdot = (this->blowdownSched != nullptr) ? this->blowdownSched->getCurrentVal() : 0.0; } else if (this->BlowdownMode == Blowdown::Concentration) { if (this->ConcentrationRatio > 2.0) { // protect divide by zero BlowDownVdot = EvapVdot / (this->ConcentrationRatio - 1) - driftVdot; @@ -6464,12 +6299,12 @@ namespace CondenserLoopTowers { this->WaterMassFlowRate = 0.0; PlantUtilities::SetComponentFlowRate(state, this->WaterMassFlowRate, this->WaterInletNodeNum, this->WaterOutletNodeNum, this->plantLoc); CalcBasinHeaterPower( - state, this->BasinHeaterPowerFTempDiff, this->BasinHeaterSchedulePtr, this->BasinHeaterSetPointTemp, this->BasinHeaterPower); + state, this->BasinHeaterPowerFTempDiff, this->basinHeaterSched, this->BasinHeaterSetPointTemp, this->BasinHeaterPower); returnFlagSet = true; } else if (this->WaterMassFlowRate <= DataBranchAirLoopPlant::MassFlowTolerance) { // for multiple cells, we assume that it's a common basin CalcBasinHeaterPower( - state, this->BasinHeaterPowerFTempDiff, this->BasinHeaterSchedulePtr, this->BasinHeaterSetPointTemp, this->BasinHeaterPower); + state, this->BasinHeaterPowerFTempDiff, this->basinHeaterSched, this->BasinHeaterSetPointTemp, this->BasinHeaterPower); returnFlagSet = true; } } diff --git a/src/EnergyPlus/CondenserLoopTowers.hh b/src/EnergyPlus/CondenserLoopTowers.hh index 16170e121cf..0a7d63f156e 100644 --- a/src/EnergyPlus/CondenserLoopTowers.hh +++ b/src/EnergyPlus/CondenserLoopTowers.hh @@ -197,8 +197,8 @@ namespace CondenserLoopTowers { ModelType TowerModelType = ModelType::Invalid; // Type of empirical model (1=CoolTools) int VSTower = 0; // Index to a variable speed tower (otherwise = 0) int FanPowerfAirFlowCurve = 0; // Index to fan power correlation curve for VS Towers - int BlowDownSchedulePtr = 0; // Pointer to blow down schedule - int BasinHeaterSchedulePtr = 0; // Pointer to basin heater schedule + Sched::Schedule *blowDownSched = nullptr; // Pointer to blow down schedule + Sched::Schedule *basinHeaterSched = nullptr; // Pointer to basin heater schedule int HighMassFlowErrorCount = 0; // Counter when mass flow rate is > Design*TowerMassFlowRateMultiplier int HighMassFlowErrorIndex = 0; // Index for high mass flow recurring error message int OutletWaterTempErrorCount = 0; // Counter when outlet water temperature is < minimum allowed temperature @@ -229,7 +229,7 @@ namespace CondenserLoopTowers { Real64 DriftLossFraction = 0.008; // default value is 0.008% Blowdown BlowdownMode = Blowdown::Concentration; // sets how tower water blowdown is modeled Real64 ConcentrationRatio = 3.0; // ratio of solids in blowdown vs make up water - int SchedIDBlowdown = 0; // index "pointer" to schedule of blowdown in [m3/s] + Sched::Schedule *blowdownSched = nullptr; // index "pointer" to schedule of blowdown in [m3/s] bool SuppliedByWaterSystem = false; int WaterTankID = 0; // index "pointer" to WaterStorage structure int WaterTankDemandARRID = 0; // index "pointer" to demand array inside WaterStorage structure @@ -441,6 +441,10 @@ struct CondenserLoopTowersData : BaseGlobalStruct bool GetInput = true; Array1D towers; // dimension to number of machines + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/Construction.hh b/src/EnergyPlus/Construction.hh index 1c95c7b513a..2caa060c584 100644 --- a/src/EnergyPlus/Construction.hh +++ b/src/EnergyPlus/Construction.hh @@ -301,7 +301,7 @@ namespace Construction { bool TypeIsAirBoundary = false; // true for Construction:AirBoundary bool TypeIsAirBoundaryMixing = false; // true for Construction:AirBoundary with SimpleMixing for air exchange Real64 AirBoundaryACH = 0.0; // Air boundary simple mixing air changes per hour [1/hr] - int AirBoundaryMixingSched = 0; // Air boundary simple mixing schedule index + Sched::Schedule *airBoundaryMixingSched = nullptr; // Air boundary simple mixing schedule index int rcmax = 0; // Total number of nodes in the construct (<= MaxTotNodes) Array2D AExp; // Exponential of AMat @@ -367,6 +367,10 @@ struct ConstructionData : BaseGlobalStruct Array1D Construct; Array1D_int LayerPoint = Array1D(Construction::MaxLayersInConstruct, 0); + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/ConvectionCoefficients.cc b/src/EnergyPlus/ConvectionCoefficients.cc index bf22d31a84c..752906c1012 100644 --- a/src/EnergyPlus/ConvectionCoefficients.cc +++ b/src/EnergyPlus/ConvectionCoefficients.cc @@ -434,9 +434,8 @@ void InitExtConvCoeff(EnergyPlusData &state, if (surface.SurfHasSurroundingSurfProperty) { int SrdSurfsNum = surface.SurfSurroundingSurfacesNum; - if (state.dataSurface->SurroundingSurfsProperty(SrdSurfsNum).SkyTempSchNum != 0) { - TSky = ScheduleManager::GetCurrentScheduleValue(state, state.dataSurface->SurroundingSurfsProperty(SrdSurfsNum).SkyTempSchNum) + - Constant::Kelvin; + if (state.dataSurface->SurroundingSurfsProperty(SrdSurfsNum).skyTempSched != nullptr) { + TSky = state.dataSurface->SurroundingSurfsProperty(SrdSurfsNum).skyTempSched->getCurrentVal() + Constant::Kelvin; } HSrdSurf = SurroundingSurfacesRadCoeffAverage(state, SurfNum, TSurf, AbsExt); } @@ -1090,27 +1089,25 @@ void GetUserConvCoeffs(EnergyPlusData &state) userExtConvModel.SurfaceName = Alphas(1); userExtConvModel.WhichSurface = surfNum; userExtConvModel.overrideType = OverrideType::Schedule; - userExtConvModel.ScheduleIndex = ScheduleManager::GetScheduleIndex(state, Alphas(Ptr + 2)); - if (userExtConvModel.ScheduleIndex == 0) { + if ((userExtConvModel.sched = Sched::GetSchedule(state, Alphas(Ptr + 2))) == nullptr) { ShowSevereItemNotFound(state, eoh, ipsc->cAlphaFieldNames(Ptr + 2), Alphas(Ptr + 2)); ErrorsFound = true; - } else if (!ScheduleManager::CheckScheduleValueMinMax(state, - userExtConvModel.ScheduleIndex, - ScheduleManager::Clusivity::Inclusive, - state.dataHeatBal->LowHConvLimit, // >= - ScheduleManager::Clusivity::Inclusive, - state.dataHeatBal->HighHConvLimit)) { // <= - ShowSevereScheduleOutOfRange(state, - eoh, - ipsc->cAlphaFieldNames(Ptr + 2), - Alphas(Ptr + 2), - state.dataHeatBal->LowHConvLimit, - state.dataHeatBal->HighHConvLimit, - "Limits are set (or default) in HeatBalanceAlgorithm object."); + } else if (!userExtConvModel.sched->checkMinMaxVals(state, + Clusive::In, + state.dataHeatBal->LowHConvLimit, + Clusive::In, + state.dataHeatBal->HighHConvLimit)) { + Sched::ShowSevereBadMinMax(state, + eoh, + ipsc->cAlphaFieldNames(Ptr + 2), + Alphas(Ptr + 2), + Clusive::In, + state.dataHeatBal->LowHConvLimit, + Clusive::In, + state.dataHeatBal->HighHConvLimit, + "Limits are set (or default) in HeatBalanceAlgorithm object."); ErrorsFound = true; - } else { - userExtConvModel.ScheduleName = Alphas(Ptr + 2); - } + } ApplyExtConvValue(state, surfNum, hcExt, state.dataSurface->TotUserExtConvModels); } break; @@ -1197,13 +1194,15 @@ void GetUserConvCoeffs(EnergyPlusData &state) userIntConvModel.SurfaceName = Alphas(1); userIntConvModel.WhichSurface = surfNum; if (Numbers(NumField) < state.dataHeatBal->LowHConvLimit || Numbers(NumField) > state.dataHeatBal->HighHConvLimit) { - ShowSevereValueOutOfRange(state, - eoh, - ipsc->cNumericFieldNames(NumField), - Numbers(NumField), - state.dataHeatBal->LowHConvLimit, - state.dataHeatBal->HighHConvLimit, - "Limits are set (or default) in HeatBalanceAlgorithm object."); + ShowSevereBadMinMax(state, + eoh, + ipsc->cNumericFieldNames(NumField), + Numbers(NumField), + Clusive::In, + state.dataHeatBal->LowHConvLimit, + Clusive::In, + state.dataHeatBal->HighHConvLimit, + "Limits are set (or default) in HeatBalanceAlgorithm object."); ErrorsFound = true; } userIntConvModel.overrideType = OverrideType::Value; @@ -1225,27 +1224,25 @@ void GetUserConvCoeffs(EnergyPlusData &state) userIntConvModel.SurfaceName = Alphas(1); userIntConvModel.WhichSurface = surfNum; userIntConvModel.overrideType = OverrideType::Schedule; - userIntConvModel.ScheduleIndex = ScheduleManager::GetScheduleIndex(state, Alphas(Ptr + 2)); - if (userIntConvModel.ScheduleIndex == 0) { + if ((userIntConvModel.sched = Sched::GetSchedule(state, Alphas(Ptr + 2))) == nullptr) { ShowSevereItemNotFound(state, eoh, ipsc->cAlphaFieldNames(Ptr + 2), Alphas(Ptr + 2)); ErrorsFound = true; - } else if (!ScheduleManager::CheckScheduleValueMinMax(state, - userIntConvModel.ScheduleIndex, - ScheduleManager::Clusivity::Inclusive, - state.dataHeatBal->LowHConvLimit, - ScheduleManager::Clusivity::Inclusive, - state.dataHeatBal->HighHConvLimit)) { - ShowSevereScheduleOutOfRange(state, - eoh, - ipsc->cAlphaFieldNames(Ptr + 2), - Alphas(Ptr + 2), - state.dataHeatBal->LowHConvLimit, - state.dataHeatBal->HighHConvLimit, - "Limits are set (or default) in HeatBalanceAlgorithm object."); + } else if (!userIntConvModel.sched->checkMinMaxVals(state, + Clusive::In, + state.dataHeatBal->LowHConvLimit, + Clusive::In, + state.dataHeatBal->HighHConvLimit)) { + Sched::ShowSevereBadMinMax(state, + eoh, + ipsc->cAlphaFieldNames(Ptr + 2), + Alphas(Ptr + 2), + Clusive::In, + state.dataHeatBal->LowHConvLimit, + Clusive::In, + state.dataHeatBal->HighHConvLimit, + "Limits are set (or default) in HeatBalanceAlgorithm object."); ErrorsFound = true; - } else { - userIntConvModel.ScheduleName = Alphas(Ptr + 2); - } + } ApplyIntConvValue(state, surfNum, hcInt, state.dataSurface->TotUserIntConvModels); } break; @@ -1332,13 +1329,14 @@ void GetUserConvCoeffs(EnergyPlusData &state) userExtConvModel.SurfaceName = Alphas(Ptr); userExtConvModel.WhichSurface = -999; if (Numbers(NumField) < state.dataHeatBal->LowHConvLimit || Numbers(NumField) > state.dataHeatBal->HighHConvLimit) { - ShowSevereValueOutOfRange(state, - eoh, - ipsc->cNumericFieldNames(NumField), - Numbers(NumField), - state.dataHeatBal->LowHConvLimit, - state.dataHeatBal->HighHConvLimit, - "Limits are set (or default) in HeatBalanceAlgorithm object."); + ShowSevereBadMinMax(state, + eoh, + ipsc->cNumericFieldNames(NumField), + Numbers(NumField), + Clusive::In, + state.dataHeatBal->LowHConvLimit, + Clusive::In, state.dataHeatBal->HighHConvLimit, + "Limits are set (or default) in HeatBalanceAlgorithm object."); ErrorsFound = true; } userExtConvModel.overrideType = OverrideType::Value; @@ -1360,27 +1358,21 @@ void GetUserConvCoeffs(EnergyPlusData &state) userExtConvModel.SurfaceName = Alphas(Ptr); userExtConvModel.WhichSurface = -999; userExtConvModel.overrideType = OverrideType::Schedule; - userExtConvModel.ScheduleIndex = ScheduleManager::GetScheduleIndex(state, Alphas(Ptr + 2)); - if (userExtConvModel.ScheduleIndex == 0) { + if ((userExtConvModel.sched = Sched::GetSchedule(state, Alphas(Ptr + 2))) == nullptr) { ShowSevereItemNotFound(state, eoh, ipsc->cAlphaFieldNames(Ptr + 2), Alphas(Ptr + 2)); ErrorsFound = true; - } else if (!ScheduleManager::CheckScheduleValueMinMax(state, - userExtConvModel.ScheduleIndex, - ScheduleManager::Clusivity::Inclusive, - state.dataHeatBal->LowHConvLimit, // >= - ScheduleManager::Clusivity::Inclusive, - state.dataHeatBal->HighHConvLimit)) { // <= - ShowSevereScheduleOutOfRange(state, - eoh, - ipsc->cAlphaFieldNames(Ptr + 2), - Alphas(Ptr + 2), - state.dataHeatBal->LowHConvLimit, - state.dataHeatBal->HighHConvLimit, - "Limits are set (or default) in HeatBalanceAlgorithm object."); + } else if (!userExtConvModel.sched->checkMinMaxVals(state, Clusive::In, state.dataHeatBal->LowHConvLimit, Clusive::In, state.dataHeatBal->HighHConvLimit)) { + Sched::ShowSevereBadMinMax(state, + eoh, + ipsc->cAlphaFieldNames(Ptr + 2), + Alphas(Ptr + 2), + Clusive::In, + state.dataHeatBal->LowHConvLimit, + Clusive::In, + state.dataHeatBal->HighHConvLimit, + "Limits are set (or default) in HeatBalanceAlgorithm object."); ErrorsFound = true; - } else { - userExtConvModel.ScheduleName = Alphas(Ptr + 2); - } + } ApplyExtConvValueMulti(state, surfaceFilter, hcExt, state.dataSurface->TotUserExtConvModels); } break; @@ -1449,13 +1441,15 @@ void GetUserConvCoeffs(EnergyPlusData &state) userIntConvModel.SurfaceName = Alphas(Ptr); userIntConvModel.WhichSurface = -999; if (Numbers(NumField) < state.dataHeatBal->LowHConvLimit || Numbers(NumField) > state.dataHeatBal->HighHConvLimit) { - ShowSevereValueOutOfRange(state, - eoh, - ipsc->cNumericFieldNames(NumField), - Numbers(NumField), - state.dataHeatBal->LowHConvLimit, - state.dataHeatBal->HighHConvLimit, - "Limits are set (or default) in HeatBalanceAlgorithm object."); + ShowSevereBadMinMax(state, + eoh, + ipsc->cNumericFieldNames(NumField), + Numbers(NumField), + Clusive::In, + state.dataHeatBal->LowHConvLimit, + Clusive::In, + state.dataHeatBal->HighHConvLimit, + "Limits are set (or default) in HeatBalanceAlgorithm object."); ErrorsFound = true; } userIntConvModel.overrideType = OverrideType::Value; @@ -1477,27 +1471,25 @@ void GetUserConvCoeffs(EnergyPlusData &state) userIntConvModel.SurfaceName = Alphas(Ptr); userIntConvModel.WhichSurface = -999; userIntConvModel.overrideType = OverrideType::Schedule; - userIntConvModel.ScheduleIndex = ScheduleManager::GetScheduleIndex(state, Alphas(Ptr + 2)); - if (userIntConvModel.ScheduleIndex == 0) { + if ((userIntConvModel.sched = Sched::GetSchedule(state, Alphas(Ptr + 2))) == nullptr) { ShowSevereItemNotFound(state, eoh, ipsc->cAlphaFieldNames(Ptr + 2), Alphas(Ptr + 2)); ErrorsFound = true; - } else if (!ScheduleManager::CheckScheduleValueMinMax(state, - userIntConvModel.ScheduleIndex, - ScheduleManager::Clusivity::Inclusive, - state.dataHeatBal->LowHConvLimit, // >= - ScheduleManager::Clusivity::Inclusive, - state.dataHeatBal->HighHConvLimit)) { // <= - ShowSevereScheduleOutOfRange(state, - eoh, - ipsc->cAlphaFieldNames(Ptr + 2), - Alphas(Ptr + 2), - state.dataHeatBal->LowHConvLimit, - state.dataHeatBal->HighHConvLimit, - "Limits are set (or default) in HeatBalanceAlgorithm object."); + } else if (!userIntConvModel.sched->checkMinMaxVals(state, + Clusive::In, + state.dataHeatBal->LowHConvLimit, // >= + Clusive::In, + state.dataHeatBal->HighHConvLimit)) { // <= + Sched::ShowSevereBadMinMax(state, + eoh, + ipsc->cAlphaFieldNames(Ptr + 2), + Alphas(Ptr + 2), + Clusive::In, + state.dataHeatBal->LowHConvLimit, + Clusive::In, + state.dataHeatBal->HighHConvLimit, + "Limits are set (or default) in HeatBalanceAlgorithm object."); ErrorsFound = true; - } else { - userIntConvModel.ScheduleName = Alphas(Ptr + 2); - } + } ApplyIntConvValueMulti(state, surfaceFilter, hcInt, state.dataSurface->TotUserIntConvModels); } break; @@ -2027,7 +2019,7 @@ Real64 CalcZoneSystemACH(EnergyPlusData &state, int const ZoneNum) Real64 ZoneVolFlowRate = CalcZoneSystemVolFlowRate(state, ZoneNum); // Calculate ACH - return ZoneVolFlowRate / ZoneVolume * Constant::SecInHour; + return ZoneVolFlowRate / ZoneVolume * Constant::rSecsInHour; } } @@ -2239,7 +2231,7 @@ void CalcCeilingDiffuserInletCorr(EnergyPlusData &state, ACH = 0.0; } else { // Calculate ACH (AR: can we please stop with these unparenthesized multiple divides? / / ) - ACH = ZoneMassFlowRate / AirDensity / ZoneVolume * Constant::SecInHour; + ACH = ZoneMassFlowRate / AirDensity / ZoneVolume * Constant::rSecsInHour; // Limit ACH to range of correlation ACH = min(ACH, MaxACH); ACH = max(ACH, 0.0); @@ -2433,7 +2425,7 @@ Real64 CalcNusselt(EnergyPlusData &state, auto const &surface = state.dataSurface->Surface(SurfNum); Real64 tilt = surface.Tilt; - Real64 tiltr = tilt * Constant::DegToRadians; + Real64 tiltr = tilt * Constant::DegToRad; Real64 costilt = surface.CosTilt; Real64 sintilt = surface.SinTilt; Real64 ra = gr * pr; // Rayleigh number @@ -2509,7 +2501,7 @@ Real64 SetExtConvCoeff(EnergyPlusData &state, int const SurfNum) // Surface Numb } break; case OverrideType::Schedule: { - HExt = ScheduleManager::GetCurrentScheduleValue(state, userExtConvModel.ScheduleIndex); + HExt = userExtConvModel.sched->getCurrentVal(); // Need to check for validity if (surface.ExtBoundCond == DataSurfaces::KivaFoundation) { state.dataSurfaceGeometry->kivaManager.surfaceConvMap[SurfNum].f = KIVA_HF_ZERO; @@ -2573,7 +2565,7 @@ Real64 SetIntConvCoeff(EnergyPlusData &state, int const SurfNum) // Surface Numb } break; case OverrideType::Schedule: { - HInt = ScheduleManager::GetCurrentScheduleValue(state, userIntConvModel.ScheduleIndex); + HInt = userIntConvModel.sched->getCurrentVal(); // Need to check for validity if (surface.ExtBoundCond == DataSurfaces::KivaFoundation) { state.dataSurfaceGeometry->kivaManager.surfaceConvMap[SurfNum].in = KIVA_CONST_CONV(HInt); @@ -4666,7 +4658,7 @@ Real64 CalcUserDefinedIntHcModel(EnergyPlusData &state, int const SurfNum, int c auto const &zoneNode = state.dataLoopNodes->Node(zone.SystemZoneNodeNumber); Real64 AirDensity = Psychrometrics::PsyRhoAirFnPbTdbW( state, state.dataEnvrn->OutBaroPress, zoneNode.Temp, Psychrometrics::PsyWFnTdpPb(state, zoneNode.Temp, state.dataEnvrn->OutBaroPress)); - AirChangeRate = (zoneNode.MassFlowRate * Constant::SecInHour) / (AirDensity * zone.Volume); + AirChangeRate = (zoneNode.MassFlowRate * Constant::rSecsInHour) / (AirDensity * zone.Volume); auto const &zoneEquipConfig = state.dataZoneEquip->ZoneEquipConfig(surface.Zone); if (zoneEquipConfig.EquipListIndex > 0) { @@ -4777,12 +4769,12 @@ Real64 CalcUserDefinedExtHcModel(EnergyPlusData &state, int const SurfNum, int c case RefWind::ParallelComp: // WindSpeed , WindDir, surface Azimuth Theta = CalcWindSurfaceTheta(state.dataEnvrn->WindDir, surface.Azimuth); - ThetaRad = Theta * Constant::DegToRadians; + ThetaRad = Theta * Constant::DegToRad; break; case RefWind::ParallelCompAtZ: // Surface WindSpeed , Surface WindDir, surface Azimuth Theta = CalcWindSurfaceTheta(state.dataSurface->SurfOutWindDir(SurfNum), surface.Azimuth); - ThetaRad = Theta * Constant::DegToRadians; + ThetaRad = Theta * Constant::DegToRad; windVel = std::cos(ThetaRad) * state.dataSurface->SurfOutWindSpeed(SurfNum); break; default: @@ -6381,7 +6373,7 @@ Real64 CalcASTMC1340ConvCoeff(EnergyPlusData &state, int const SurfNum, Real64 c Real64 Nuf; // Nusselt number for forced convection Real64 Grc; // Critical Grashof number - constexpr Real64 g = Constant::GravityConstant; // Acceleration of gravity, m/s2 + constexpr Real64 g = Constant::Gravity; // Acceleration of gravity, m/s2 auto const &surface = state.dataSurface->Surface(SurfNum); @@ -6431,7 +6423,7 @@ Real64 CalcASTMC1340ConvCoeff(EnergyPlusData &state, int const SurfNum, Real64 c if (Tilt < 2) { Nun = 0.58 * std::pow(Ra, 0.2); } else { - Nun = 0.56 * std::pow(Ra * (std::sin(Tilt * Constant::DegToRadians)), 0.25); + Nun = 0.56 * std::pow(Ra * (std::sin(Tilt * Constant::DegToRad)), 0.25); } } else { // heat flow up if (Tilt < 15) { @@ -6445,7 +6437,7 @@ Real64 CalcASTMC1340ConvCoeff(EnergyPlusData &state, int const SurfNum, Real64 c Nun = 0.56 * std::pow(Ra * (std::sin(Tilt * 3.14159 / 180)), 0.25); } else { Nun = 0.14 * (std::pow(Ra, Constant::OneThird) - std::pow(Grc * Pr, Constant::OneThird)) + - 0.56 * std::pow(Grc * Pr * (std::sin(Tilt * Constant::DegToRadians)), 0.25); + 0.56 * std::pow(Grc * Pr * (std::sin(Tilt * Constant::DegToRad)), 0.25); } } } else if (Tilt == 180) { // Horizontal surface: Floor @@ -6461,7 +6453,7 @@ Real64 CalcASTMC1340ConvCoeff(EnergyPlusData &state, int const SurfNum, Real64 c if (Tilt > 178) { Nun = 0.58 * std::pow(Ra, 0.2); } else { - Nun = 0.56 * std::pow(Ra * (std::sin(Tilt * Constant::DegToRadians)), 0.25); + Nun = 0.56 * std::pow(Ra * (std::sin(Tilt * Constant::DegToRad)), 0.25); } } else { // heat flow up if (Tilt > 165) { @@ -6472,10 +6464,10 @@ Real64 CalcASTMC1340ConvCoeff(EnergyPlusData &state, int const SurfNum, Real64 c Grc = 5000000000; } if ((Ra / Pr) <= Grc) { - Nun = 0.56 * std::pow(Ra * (std::sin(Tilt * Constant::DegToRadians)), 0.25); + Nun = 0.56 * std::pow(Ra * (std::sin(Tilt * Constant::DegToRad)), 0.25); } else { Nun = 0.14 * (std::pow(Ra, Constant::OneThird) - std::pow(Grc * Pr, Constant::OneThird)) + - 0.56 * std::pow(Grc * Pr * (std::sin(Tilt * Constant::DegToRadians)), 0.25); + 0.56 * std::pow(Grc * Pr * (std::sin(Tilt * Constant::DegToRad)), 0.25); } } } else { // Vertical wall (Tilt = 90) @@ -6516,29 +6508,6 @@ SurfOrientation GetSurfConvOrientation(Real64 const Tilt) } } -void ShowSevereValueOutOfRange( - EnergyPlusData &state, ErrorObjectHeader const &eoh, std::string_view fieldName, Real64 fieldVal, Real64 lo, Real64 hi, std::string const &msg) -{ - ShowSevereError(state, format("{}: {} = {} out of range value", eoh.routineName, eoh.objectType, eoh.objectName)); - ShowContinueError(state, format("{} = [{:.5R}] is out-of-range", fieldName, fieldVal)); - ShowContinueError(state, format("Low/high limits = [>={:.9R}, <={:.1R}].", lo, hi)); - if (!msg.empty()) ShowContinueError(state, msg); -} - -void ShowSevereScheduleOutOfRange(EnergyPlusData &state, - ErrorObjectHeader const &eoh, - std::string_view fieldName, - std::string_view fieldVal, - Real64 lo, - Real64 hi, - std::string const &msg) -{ - ShowSevereError(state, format("{}: {} = {} out of range value", eoh.routineName, eoh.objectType, eoh.objectName)); - ShowContinueError(state, format("{} = {} contains an out-of-range value", fieldName, fieldVal)); - ShowContinueError(state, format("Low/high limits = [>={:.9R}, <={:.1R}].", lo, hi)); - if (!msg.empty()) ShowContinueError(state, msg); -} - Real64 SurroundingSurfacesRadCoeffAverage(EnergyPlusData &state, int const SurfNum, Real64 const TSurfK, Real64 const AbsExt) { // compute exterior surfaces LW radiation transfer coefficient to surrounding surfaces diff --git a/src/EnergyPlus/ConvectionCoefficients.hh b/src/EnergyPlus/ConvectionCoefficients.hh index db063217f72..a3bb759c0f3 100644 --- a/src/EnergyPlus/ConvectionCoefficients.hh +++ b/src/EnergyPlus/ConvectionCoefficients.hh @@ -743,23 +743,6 @@ namespace Convect { CalcASTMC1340ConvCoeff(EnergyPlusData &state, int const SurfNum, Real64 const Tsurf, Real64 const Tair, Real64 const Vair, Real64 const Tilt); SurfOrientation GetSurfConvOrientation(Real64 const Tilt); - - void ShowSevereValueOutOfRange(EnergyPlusData &state, - ErrorObjectHeader const &eoh, - std::string_view fieldName, - Real64 fieldVal, - Real64 lo, - Real64 hi, - std::string const &msg); - - void ShowSevereScheduleOutOfRange(EnergyPlusData &state, - ErrorObjectHeader const &eoh, - std::string_view fieldName, - std::string_view fieldVal, - Real64 lo, - Real64 hi, - std::string const &msg); - } // namespace Convect struct ConvectionCoefficientsData : BaseGlobalStruct @@ -808,6 +791,10 @@ struct ConvectionCoefficientsData : BaseGlobalStruct Array1D hcIntUserCurve; Array1D hcExtUserCurve; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/CoolTower.cc b/src/EnergyPlus/CoolTower.cc index b0d46af320f..e56469e1209 100644 --- a/src/EnergyPlus/CoolTower.cc +++ b/src/EnergyPlus/CoolTower.cc @@ -131,6 +131,8 @@ namespace CoolTower { // and stores it in the Cooltower data structure. // SUBROUTINE PARAMETER DEFINITIONS: + static constexpr std::string_view routineName = "GetCoolTower"; + static std::string const CurrentModuleObject("ZoneCoolTower:Shower"); Real64 constexpr MaximumWaterFlowRate(0.016667); // Maximum limit of water flow rate in m3/s (1000 l/min) Real64 constexpr MinimumWaterFlowRate(0.0); // Minimum limit of water flow rate @@ -165,6 +167,8 @@ namespace CoolTower { auto &Zone(state.dataHeatBal->Zone); + auto &s_ipsc = state.dataIPShortCut; + int NumCoolTowers = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject); state.dataCoolTower->CoolTowerSys.allocate(NumCoolTowers); @@ -175,46 +179,44 @@ namespace CoolTower { state.dataInputProcessing->inputProcessor->getObjectItem(state, CurrentModuleObject, CoolTowerNum, - state.dataIPShortCut->cAlphaArgs, + s_ipsc->cAlphaArgs, NumAlphas, - state.dataIPShortCut->rNumericArgs, + s_ipsc->rNumericArgs, NumNumbers, IOStat, lNumericBlanks, lAlphaBlanks, cAlphaFields, cNumericFields); - state.dataCoolTower->CoolTowerSys(CoolTowerNum).Name = state.dataIPShortCut->cAlphaArgs(1); // Name of cooltower - state.dataCoolTower->CoolTowerSys(CoolTowerNum).Schedule = state.dataIPShortCut->cAlphaArgs(2); // Get schedule + + ErrorObjectHeader eoh{routineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)}; + + state.dataCoolTower->CoolTowerSys(CoolTowerNum).Name = s_ipsc->cAlphaArgs(1); // Name of cooltower + state.dataCoolTower->CoolTowerSys(CoolTowerNum).Schedule = s_ipsc->cAlphaArgs(2); // Get schedule if (lAlphaBlanks(2)) { - state.dataCoolTower->CoolTowerSys(CoolTowerNum).SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - state.dataCoolTower->CoolTowerSys(CoolTowerNum).SchedPtr = - ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(2)); - if (state.dataCoolTower->CoolTowerSys(CoolTowerNum).SchedPtr == 0) { - ShowSevereError(state, format("{}=\"{}\" invalid data", CurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("Invalid-Schedule not found {}=\"{}\".", cAlphaFields(2), state.dataIPShortCut->cAlphaArgs(2))); - ErrorsFound = true; - } + state.dataCoolTower->CoolTowerSys(CoolTowerNum).sched = Sched::GetScheduleAlwaysOn(state); + } else if ((state.dataCoolTower->CoolTowerSys(CoolTowerNum).sched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(2), s_ipsc->cAlphaArgs(2)); + ErrorsFound = true; } - state.dataCoolTower->CoolTowerSys(CoolTowerNum).ZonePtr = Util::FindItemInList(state.dataIPShortCut->cAlphaArgs(3), Zone); + state.dataCoolTower->CoolTowerSys(CoolTowerNum).ZonePtr = Util::FindItemInList(s_ipsc->cAlphaArgs(3), Zone); state.dataCoolTower->CoolTowerSys(CoolTowerNum).spacePtr = - Util::FindItemInList(state.dataIPShortCut->cAlphaArgs(3), state.dataHeatBal->space); + Util::FindItemInList(s_ipsc->cAlphaArgs(3), state.dataHeatBal->space); if ((state.dataCoolTower->CoolTowerSys(CoolTowerNum).ZonePtr == 0) && (state.dataCoolTower->CoolTowerSys(CoolTowerNum).spacePtr == 0)) { if (lAlphaBlanks(3)) { ShowSevereError(state, format("{}=\"{}\" invalid {} is required but input is blank.", CurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), + s_ipsc->cAlphaArgs(1), cAlphaFields(3))); } else { ShowSevereError(state, format("{}=\"{}\" invalid {}=\"{}\" not found.", CurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), + s_ipsc->cAlphaArgs(1), cAlphaFields(3), - state.dataIPShortCut->cAlphaArgs(3))); + s_ipsc->cAlphaArgs(3))); } ErrorsFound = true; } else if (state.dataCoolTower->CoolTowerSys(CoolTowerNum).ZonePtr == 0) { @@ -222,7 +224,7 @@ namespace CoolTower { state.dataHeatBal->space(state.dataCoolTower->CoolTowerSys(CoolTowerNum).spacePtr).zoneNum; } - state.dataCoolTower->CoolTowerSys(CoolTowerNum).CoolTWaterSupplyName = state.dataIPShortCut->cAlphaArgs(4); // Name of water storage tank + state.dataCoolTower->CoolTowerSys(CoolTowerNum).CoolTWaterSupplyName = s_ipsc->cAlphaArgs(4); // Name of water storage tank if (lAlphaBlanks(4)) { state.dataCoolTower->CoolTowerSys(CoolTowerNum).CoolTWaterSupplyMode = WaterSupplyMode::FromMains; } else if (state.dataCoolTower->CoolTowerSys(CoolTowerNum).CoolTWaterSupplyMode == WaterSupplyMode::FromTank) { @@ -237,47 +239,32 @@ namespace CoolTower { { state.dataCoolTower->CoolTowerSys(CoolTowerNum).FlowCtrlType = - static_cast(getEnumValue(FlowCtrlNamesUC, state.dataIPShortCut->cAlphaArgs(5))); // Type of flow control + static_cast(getEnumValue(FlowCtrlNamesUC, s_ipsc->cAlphaArgs(5))); // Type of flow control if (state.dataCoolTower->CoolTowerSys(CoolTowerNum).FlowCtrlType == FlowCtrl::Invalid) { ShowSevereError(state, format("{}=\"{}\" invalid {}=\"{}\".", CurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), + s_ipsc->cAlphaArgs(1), cAlphaFields(5), - state.dataIPShortCut->cAlphaArgs(5))); + s_ipsc->cAlphaArgs(5))); ErrorsFound = true; } } - state.dataCoolTower->CoolTowerSys(CoolTowerNum).PumpSchedPtr = - ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(6)); - if (state.dataCoolTower->CoolTowerSys(CoolTowerNum).PumpSchedPtr == 0) { - if (lAlphaBlanks(6)) { - ShowSevereError(state, - format("{}=\"{}\" invalid {} is required but input is blank.", - CurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), - cAlphaFields(6))); - } else { - ShowSevereError(state, - format("{}=\"{}\" invalid {}=\"{}\" not found.", - CurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), - cAlphaFields(6), - state.dataIPShortCut->cAlphaArgs(6))); - } + if ((state.dataCoolTower->CoolTowerSys(CoolTowerNum).pumpSched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(6))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(6), s_ipsc->cAlphaArgs(6)); ErrorsFound = true; } - state.dataCoolTower->CoolTowerSys(CoolTowerNum).MaxWaterFlowRate = state.dataIPShortCut->rNumericArgs(1); // Maximum limit of water supply + state.dataCoolTower->CoolTowerSys(CoolTowerNum).MaxWaterFlowRate = s_ipsc->rNumericArgs(1); // Maximum limit of water supply if (state.dataCoolTower->CoolTowerSys(CoolTowerNum).MaxWaterFlowRate > MaximumWaterFlowRate) { state.dataCoolTower->CoolTowerSys(CoolTowerNum).MaxWaterFlowRate = MaximumWaterFlowRate; ShowWarningError(state, format("{}=\"{}\" invalid {}=[{:.2R}].", CurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), + s_ipsc->cAlphaArgs(1), cNumericFields(1), - state.dataIPShortCut->rNumericArgs(1))); + s_ipsc->rNumericArgs(1))); ShowContinueError(state, format("...Maximum Allowable=[{:.2R}].", MaximumWaterFlowRate)); } if (state.dataCoolTower->CoolTowerSys(CoolTowerNum).MaxWaterFlowRate < MinimumWaterFlowRate) { @@ -285,21 +272,21 @@ namespace CoolTower { ShowWarningError(state, format("{}=\"{}\" invalid {}=[{:.2R}].", CurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), + s_ipsc->cAlphaArgs(1), cNumericFields(1), - state.dataIPShortCut->rNumericArgs(1))); + s_ipsc->rNumericArgs(1))); ShowContinueError(state, format("...Minimum Allowable=[{:.2R}].", MinimumWaterFlowRate)); } - state.dataCoolTower->CoolTowerSys(CoolTowerNum).TowerHeight = state.dataIPShortCut->rNumericArgs(2); // Get effctive tower height + state.dataCoolTower->CoolTowerSys(CoolTowerNum).TowerHeight = s_ipsc->rNumericArgs(2); // Get effctive tower height if (state.dataCoolTower->CoolTowerSys(CoolTowerNum).TowerHeight > MaxHeight) { state.dataCoolTower->CoolTowerSys(CoolTowerNum).TowerHeight = MaxHeight; ShowWarningError(state, format("{}=\"{}\" invalid {}=[{:.2R}].", CurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), + s_ipsc->cAlphaArgs(1), cNumericFields(2), - state.dataIPShortCut->rNumericArgs(2))); + s_ipsc->rNumericArgs(2))); ShowContinueError(state, format("...Maximum Allowable=[{:.2R}].", MaxHeight)); } if (state.dataCoolTower->CoolTowerSys(CoolTowerNum).TowerHeight < MinHeight) { @@ -307,21 +294,21 @@ namespace CoolTower { ShowWarningError(state, format("{}=\"{}\" invalid {}=[{:.2R}].", CurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), + s_ipsc->cAlphaArgs(1), cNumericFields(2), - state.dataIPShortCut->rNumericArgs(2))); + s_ipsc->rNumericArgs(2))); ShowContinueError(state, format("...Minimum Allowable=[{:.2R}].", MinHeight)); } - state.dataCoolTower->CoolTowerSys(CoolTowerNum).OutletArea = state.dataIPShortCut->rNumericArgs(3); // Get outlet area + state.dataCoolTower->CoolTowerSys(CoolTowerNum).OutletArea = s_ipsc->rNumericArgs(3); // Get outlet area if (state.dataCoolTower->CoolTowerSys(CoolTowerNum).OutletArea > MaxValue) { state.dataCoolTower->CoolTowerSys(CoolTowerNum).OutletArea = MaxValue; ShowWarningError(state, format("{}=\"{}\" invalid {}=[{:.2R}].", CurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), + s_ipsc->cAlphaArgs(1), cNumericFields(3), - state.dataIPShortCut->rNumericArgs(3))); + s_ipsc->rNumericArgs(3))); ShowContinueError(state, format("...Maximum Allowable=[{:.2R}].", MaxValue)); } if (state.dataCoolTower->CoolTowerSys(CoolTowerNum).OutletArea < MinValue) { @@ -329,22 +316,22 @@ namespace CoolTower { ShowWarningError(state, format("{}=\"{}\" invalid {}=[{:.2R}].", CurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), + s_ipsc->cAlphaArgs(1), cNumericFields(3), - state.dataIPShortCut->rNumericArgs(3))); + s_ipsc->rNumericArgs(3))); ShowContinueError(state, format("...Minimum Allowable=[{:.2R}].", MinValue)); } state.dataCoolTower->CoolTowerSys(CoolTowerNum).MaxAirVolFlowRate = - state.dataIPShortCut->rNumericArgs(4); // Maximum limit of air flow to the space + s_ipsc->rNumericArgs(4); // Maximum limit of air flow to the space if (state.dataCoolTower->CoolTowerSys(CoolTowerNum).MaxAirVolFlowRate > MaxValue) { state.dataCoolTower->CoolTowerSys(CoolTowerNum).MaxAirVolFlowRate = MaxValue; ShowWarningError(state, format("{}=\"{}\" invalid {}=[{:.2R}].", CurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), + s_ipsc->cAlphaArgs(1), cNumericFields(4), - state.dataIPShortCut->rNumericArgs(4))); + s_ipsc->rNumericArgs(4))); ShowContinueError(state, format("...Maximum Allowable=[{:.2R}].", MaxValue)); } if (state.dataCoolTower->CoolTowerSys(CoolTowerNum).MaxAirVolFlowRate < MinValue) { @@ -352,22 +339,22 @@ namespace CoolTower { ShowWarningError(state, format("{}=\"{}\" invalid {}=[{:.2R}].", CurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), + s_ipsc->cAlphaArgs(1), cNumericFields(4), - state.dataIPShortCut->rNumericArgs(4))); + s_ipsc->rNumericArgs(4))); ShowContinueError(state, format("...Minimum Allowable=[{:.2R}].", MinValue)); } state.dataCoolTower->CoolTowerSys(CoolTowerNum).MinZoneTemp = - state.dataIPShortCut->rNumericArgs(5); // Get minimum temp limit which gets this cooltower off + s_ipsc->rNumericArgs(5); // Get minimum temp limit which gets this cooltower off if (state.dataCoolTower->CoolTowerSys(CoolTowerNum).MinZoneTemp > MaxValue) { state.dataCoolTower->CoolTowerSys(CoolTowerNum).MinZoneTemp = MaxValue; ShowWarningError(state, format("{}=\"{}\" invalid {}=[{:.2R}].", CurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), + s_ipsc->cAlphaArgs(1), cNumericFields(5), - state.dataIPShortCut->rNumericArgs(5))); + s_ipsc->rNumericArgs(5))); ShowContinueError(state, format("...Maximum Allowable=[{:.2R}].", MaxValue)); } if (state.dataCoolTower->CoolTowerSys(CoolTowerNum).MinZoneTemp < MinValue) { @@ -375,21 +362,21 @@ namespace CoolTower { ShowWarningError(state, format("{}=\"{}\" invalid {}=[{:.2R}].", CurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), + s_ipsc->cAlphaArgs(1), cNumericFields(5), - state.dataIPShortCut->rNumericArgs(5))); + s_ipsc->rNumericArgs(5))); ShowContinueError(state, format("...Minimum Allowable=[{:.2R}].", MinValue)); } - state.dataCoolTower->CoolTowerSys(CoolTowerNum).FracWaterLoss = state.dataIPShortCut->rNumericArgs(6); // Fraction of water loss + state.dataCoolTower->CoolTowerSys(CoolTowerNum).FracWaterLoss = s_ipsc->rNumericArgs(6); // Fraction of water loss if (state.dataCoolTower->CoolTowerSys(CoolTowerNum).FracWaterLoss > MaxFrac) { state.dataCoolTower->CoolTowerSys(CoolTowerNum).FracWaterLoss = MaxFrac; ShowWarningError(state, format("{}=\"{}\" invalid {}=[{:.2R}].", CurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), + s_ipsc->cAlphaArgs(1), cNumericFields(6), - state.dataIPShortCut->rNumericArgs(6))); + s_ipsc->rNumericArgs(6))); ShowContinueError(state, format("...Maximum Allowable=[{:.2R}].", MaxFrac)); } if (state.dataCoolTower->CoolTowerSys(CoolTowerNum).FracWaterLoss < MinFrac) { @@ -397,21 +384,21 @@ namespace CoolTower { ShowWarningError(state, format("{}=\"{}\" invalid {}=[{:.2R}].", CurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), + s_ipsc->cAlphaArgs(1), cNumericFields(6), - state.dataIPShortCut->rNumericArgs(6))); + s_ipsc->rNumericArgs(6))); ShowContinueError(state, format("...Minimum Allowable=[{:.2R}].", MinFrac)); } - state.dataCoolTower->CoolTowerSys(CoolTowerNum).FracFlowSched = state.dataIPShortCut->rNumericArgs(7); // Fraction of loss of air flow + state.dataCoolTower->CoolTowerSys(CoolTowerNum).FracFlowSched = s_ipsc->rNumericArgs(7); // Fraction of loss of air flow if (state.dataCoolTower->CoolTowerSys(CoolTowerNum).FracFlowSched > MaxFrac) { state.dataCoolTower->CoolTowerSys(CoolTowerNum).FracFlowSched = MaxFrac; ShowWarningError(state, format("{}=\"{}\" invalid {}=[{:.2R}].", CurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), + s_ipsc->cAlphaArgs(1), cNumericFields(7), - state.dataIPShortCut->rNumericArgs(7))); + s_ipsc->rNumericArgs(7))); ShowContinueError(state, format("...Maximum Allowable=[{:.2R}].", MaxFrac)); } if (state.dataCoolTower->CoolTowerSys(CoolTowerNum).FracFlowSched < MinFrac) { @@ -419,13 +406,13 @@ namespace CoolTower { ShowWarningError(state, format("{}=\"{}\" invalid {}=[{:.5R}].", CurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), + s_ipsc->cAlphaArgs(1), cNumericFields(7), - state.dataIPShortCut->rNumericArgs(7))); + s_ipsc->rNumericArgs(7))); ShowContinueError(state, format("...Minimum Allowable=[{:.2R}].", MinFrac)); } - state.dataCoolTower->CoolTowerSys(CoolTowerNum).RatedPumpPower = state.dataIPShortCut->rNumericArgs(8); // Get rated pump power + state.dataCoolTower->CoolTowerSys(CoolTowerNum).RatedPumpPower = s_ipsc->rNumericArgs(8); // Get rated pump power } cAlphaArgs.deallocate(); @@ -637,7 +624,8 @@ namespace CoolTower { thisSpaceHB.MCPC = 0.0; thisSpaceHB.CTMFL = 0.0; } - if (ScheduleManager::GetCurrentScheduleValue(state, state.dataCoolTower->CoolTowerSys(CoolTowerNum).SchedPtr) > 0.0) { + + if (state.dataCoolTower->CoolTowerSys(CoolTowerNum).sched->getCurrentVal() > 0.0) { // check component operation if (state.dataEnvrn->WindSpeed < MinWindSpeed || state.dataEnvrn->WindSpeed > MaxWindSpeed) continue; if (state.dataZoneTempPredictorCorrector->zoneHeatBalance(ZoneNum).MAT < state.dataCoolTower->CoolTowerSys(CoolTowerNum).MinZoneTemp) @@ -695,8 +683,8 @@ namespace CoolTower { } // Determine pump power - if (ScheduleManager::GetCurrentScheduleValue(state, state.dataCoolTower->CoolTowerSys(CoolTowerNum).PumpSchedPtr) > 0) { - PumpPartLoadRat = ScheduleManager::GetCurrentScheduleValue(state, state.dataCoolTower->CoolTowerSys(CoolTowerNum).PumpSchedPtr); + if (state.dataCoolTower->CoolTowerSys(CoolTowerNum).pumpSched->getCurrentVal() > 0) { + PumpPartLoadRat = state.dataCoolTower->CoolTowerSys(CoolTowerNum).pumpSched->getCurrentVal(); } else { PumpPartLoadRat = 1.0; } @@ -715,7 +703,7 @@ namespace CoolTower { AirSpecHeat = Psychrometrics::PsyCpAirFnW(OutletHumRat); AirDensity = Psychrometrics::PsyRhoAirFnPbTdbW(state, state.dataEnvrn->OutBaroPress, OutletTemp, OutletHumRat); // Outlet air density CVF_ZoneNum = state.dataCoolTower->CoolTowerSys(CoolTowerNum).ActualAirVolFlowRate * - ScheduleManager::GetCurrentScheduleValue(state, state.dataCoolTower->CoolTowerSys(CoolTowerNum).SchedPtr); + state.dataCoolTower->CoolTowerSys(CoolTowerNum).sched->getCurrentVal(); Real64 thisMCPC = CVF_ZoneNum * AirDensity * AirSpecHeat; Real64 thisMCPTC = thisMCPC * OutletTemp; Real64 thisCTMFL = thisMCPC / AirSpecHeat; diff --git a/src/EnergyPlus/CoolTower.hh b/src/EnergyPlus/CoolTower.hh index 4da1b7a67f8..947bf43feed 100644 --- a/src/EnergyPlus/CoolTower.hh +++ b/src/EnergyPlus/CoolTower.hh @@ -55,6 +55,7 @@ #include #include #include +#include namespace EnergyPlus { @@ -85,10 +86,10 @@ namespace CoolTower { std::string Name; // The component name std::string CompType; // Type of component std::string Schedule; // Available schedule - int SchedPtr = 0; // Index to schedule + Sched::Schedule *sched = nullptr; // schedule int ZonePtr = 0; // Index to zone int spacePtr = 0; // Index to space (if applicable) - int PumpSchedPtr = 0; // Index to schedule for water pump + Sched::Schedule *pumpSched = nullptr; // Index to schedule for water pump FlowCtrl FlowCtrlType = FlowCtrl::Invalid; // Type of cooltower operation WaterSupplyMode CoolTWaterSupplyMode = WaterSupplyMode::FromMains; // Type of water source std::string CoolTWaterSupplyName; // Name of water source @@ -145,6 +146,10 @@ struct CoolTowerData : BaseGlobalStruct bool GetInputFlag = true; Array1D CoolTowerSys; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/CostEstimateManager.hh b/src/EnergyPlus/CostEstimateManager.hh index 4d82595fd08..fccd1eac87e 100644 --- a/src/EnergyPlus/CostEstimateManager.hh +++ b/src/EnergyPlus/CostEstimateManager.hh @@ -189,6 +189,10 @@ struct CostEstimateManagerData : BaseGlobalStruct Array1D monetaryUnit; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/CrossVentMgr.cc b/src/EnergyPlus/CrossVentMgr.cc index 55762137b66..25f0e246a27 100644 --- a/src/EnergyPlus/CrossVentMgr.cc +++ b/src/EnergyPlus/CrossVentMgr.cc @@ -387,7 +387,7 @@ namespace RoomAir { // Check if wind direction is within +/- 90 degrees of the outward normal of the dominant surface SurfNorm = thisSurface.Azimuth; - CosPhi = std::cos((state.dataEnvrn->WindDir - SurfNorm) * Constant::DegToRadians); + CosPhi = std::cos((state.dataEnvrn->WindDir - SurfNorm) * Constant::DegToRad); if (CosPhi <= 0) { state.dataRoomAir->AirModel(ZoneNum).SimAirModel = false; auto flows(state.dataRoomAir->CrossVentJetRecFlows(_, ZoneNum)); // This is an array slice, need to get rid of this (THIS_AUTO_OK) @@ -736,7 +736,7 @@ namespace RoomAir { for (int Ctd = 1; Ctd <= state.dataRoomAir->TotCrossVent; ++Ctd) { if (ZoneNum == state.dataRoomAir->ZoneCrossVent(Ctd).ZonePtr) { - GainsFrac = ScheduleManager::GetCurrentScheduleValue(state, state.dataRoomAir->ZoneCrossVent(Ctd).SchedGainsPtr); + GainsFrac = state.dataRoomAir->ZoneCrossVent(Ctd).gainsSched->getCurrentVal(); } } diff --git a/src/EnergyPlus/CrossVentMgr.hh b/src/EnergyPlus/CrossVentMgr.hh index d05afc87e2d..936e893914e 100644 --- a/src/EnergyPlus/CrossVentMgr.hh +++ b/src/EnergyPlus/CrossVentMgr.hh @@ -81,6 +81,10 @@ struct CrossVentMgrData : BaseGlobalStruct bool InitUCSDCV_MyOneTimeFlag = true; Array1D_bool InitUCSDCV_MyEnvrnFlag; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/CurveManager.hh b/src/EnergyPlus/CurveManager.hh index 79e20bdbfde..a40732e9874 100644 --- a/src/EnergyPlus/CurveManager.hh +++ b/src/EnergyPlus/CurveManager.hh @@ -469,6 +469,10 @@ struct CurveManagerData : BaseGlobalStruct this->PerfCurve.push_back(new EnergyPlus::Curve::Curve); } + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/DElightManagerF.cc b/src/EnergyPlus/DElightManagerF.cc index 44c6e41837d..0c0926870a7 100644 --- a/src/EnergyPlus/DElightManagerF.cc +++ b/src/EnergyPlus/DElightManagerF.cc @@ -233,8 +233,8 @@ namespace DElightManagerF { state.dataEnvrn->TimeZoneNumber); // Calc cos and sin of Building Relative North values for later use in transforming Reference Point coordinates - CosBldgRelNorth = std::cos(-state.dataHeatBal->BuildingAzimuth * Constant::DegToRadians); - SinBldgRelNorth = std::sin(-state.dataHeatBal->BuildingAzimuth * Constant::DegToRadians); + CosBldgRelNorth = std::cos(-state.dataHeatBal->BuildingAzimuth * Constant::DegToRad); + SinBldgRelNorth = std::sin(-state.dataHeatBal->BuildingAzimuth * Constant::DegToRad); // Loop through the Daylighting:Controls objects that use DElight checking for a host Zone for (auto &znDayl : state.dataDayltg->daylightControl) { @@ -309,8 +309,8 @@ namespace DElightManagerF { znDayl.DElightGriddingResolution * M22FT2); // Calc cos and sin of Zone Relative North values for later use in transforming Reference Point coordinates - CosZoneRelNorth = std::cos(-zn.RelNorth * Constant::DegToRadians); - SinZoneRelNorth = std::sin(-zn.RelNorth * Constant::DegToRadians); + CosZoneRelNorth = std::cos(-zn.RelNorth * Constant::DegToRad); + SinZoneRelNorth = std::sin(-zn.RelNorth * Constant::DegToRad); // Zone Lighting Schedule Data Section // NOTE: Schedules are not required since hourly values are retrieved from EnergyPlus as needed diff --git a/src/EnergyPlus/DXCoils.cc b/src/EnergyPlus/DXCoils.cc index c6797fa12eb..eed19f4d915 100644 --- a/src/EnergyPlus/DXCoils.cc +++ b/src/EnergyPlus/DXCoils.cc @@ -123,9 +123,6 @@ namespace EnergyPlus::DXCoils { using namespace DataLoopNode; using namespace Psychrometrics; -// Use statements for access to subroutines in other modules -using namespace ScheduleManager; - // Functions void SimDXCoil(EnergyPlusData &state, @@ -721,12 +718,13 @@ void GetDXCoils(EnergyPlusData &state) using GlobalNames::VerifyUniqueCoilName; using NodeInputManager::GetOnlySingleNode; using OutAirNodeManager::CheckOutAirNodeNumber; - using ScheduleManager::GetScheduleIndex; using WaterManager::SetupTankDemandComponent; using WaterManager::SetupTankSupplyComponent; // SUBROUTINE PARAMETER DEFINITIONS: static constexpr std::string_view RoutineName("GetDXCoils: "); // include trailing blank space + static constexpr std::string_view routineName = "GetDXCoils"; // include trailing blank space + constexpr Real64 minOATCompDXCooling = -25.0; // min OAT for compressor operation for DX cooling coils // SUBROUTINE LOCAL VARIABLE DECLARATIONS: @@ -912,6 +910,8 @@ void GetDXCoils(EnergyPlusData &state) cAlphaFields, cNumericFields); + ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)}; + ++DXCoilNum; // allocate single performance mode for numeric field strings used for sizing routine state.dataDXCoils->DXCoilNumericFields(DXCoilNum).PerfMode.allocate(1); @@ -927,16 +927,11 @@ void GetDXCoils(EnergyPlusData &state) state.dataHeatBal->HeatReclaimDXCoil(DXCoilNum).SourceType = CurrentModuleObject; thisDXCoil.DXCoilType = CurrentModuleObject; thisDXCoil.DXCoilType_Num = HVAC::CoilDX_CoolingSingleSpeed; - thisDXCoil.Schedule = Alphas(2); if (lAlphaBlanks(2)) { - thisDXCoil.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - thisDXCoil.SchedPtr = GetScheduleIndex(state, Alphas(2)); // convert schedule name to pointer - if (thisDXCoil.SchedPtr == 0) { - ShowSevereError(state, format("{}{}=\"{}\", invalid", RoutineName, CurrentModuleObject, thisDXCoil.Name)); - ShowContinueError(state, format("...{}=\"{}\".", cAlphaFields(2), Alphas(2))); - ErrorsFound = true; - } + thisDXCoil.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((thisDXCoil.availSched = Sched::GetSchedule(state, Alphas(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(2), Alphas(2)); + ErrorsFound = true; } thisDXCoil.RatedTotCap(1) = Numbers(1); thisDXCoil.RatedSHR(1) = Numbers(2); @@ -1305,11 +1300,8 @@ void GetDXCoils(EnergyPlusData &state) } if (!lAlphaBlanks(15)) { - thisDXCoil.BasinHeaterSchedulePtr = GetScheduleIndex(state, Alphas(15)); - if (thisDXCoil.BasinHeaterSchedulePtr == 0) { - ShowWarningError(state, format("{}{}=\"{}\", invalid", RoutineName, CurrentModuleObject, thisDXCoil.Name)); - ShowContinueError(state, format("...not found {}=\"{}\".", cAlphaFields(15), Alphas(15))); - ShowContinueError(state, "Basin heater will be available to operate throughout the simulation."); + if ((thisDXCoil.basinHeaterSched = Sched::GetSchedule(state, Alphas(15))) == nullptr) { + ShowWarningItemNotFound(state, eoh, cAlphaFields(15), Alphas(15), "Basin heater will be available to operate throughout the simulation."); } } @@ -1401,6 +1393,8 @@ void GetDXCoils(EnergyPlusData &state) cAlphaFields, cNumericFields); + + ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)}; ++DXCoilNum; // ErrorsFound will be set to True if problem was found, left untouched otherwise VerifyUniqueCoilName(state, CurrentModuleObject, Alphas(1), ErrorsFound, CurrentModuleObject + " Name"); @@ -1412,16 +1406,11 @@ void GetDXCoils(EnergyPlusData &state) state.dataHeatBal->HeatReclaimDXCoil(DXCoilNum).SourceType = CurrentModuleObject; thisDXCoil.DXCoilType = CurrentModuleObject; thisDXCoil.DXCoilType_Num = HVAC::CoilDX_CoolingTwoStageWHumControl; - thisDXCoil.Schedule = Alphas(2); if (lAlphaBlanks(2)) { - thisDXCoil.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - thisDXCoil.SchedPtr = GetScheduleIndex(state, Alphas(2)); // convert schedule name to pointer - if (thisDXCoil.SchedPtr == 0) { - ShowSevereError(state, format("{}{}=\"{}\", invalid", RoutineName, CurrentModuleObject, thisDXCoil.Name)); - ShowContinueError(state, format("...{}=\"{}\".", cAlphaFields(2), Alphas(2))); - ErrorsFound = true; - } + thisDXCoil.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((thisDXCoil.availSched = Sched::GetSchedule(state, Alphas(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(2), Alphas(2)); + ErrorsFound = true; } thisDXCoil.AirInNode = GetOnlySingleNode(state, @@ -1928,11 +1917,8 @@ void GetDXCoils(EnergyPlusData &state) } if (!lAlphaBlanks(16)) { - thisDXCoil.BasinHeaterSchedulePtr = GetScheduleIndex(state, Alphas(16)); - if (thisDXCoil.BasinHeaterSchedulePtr == 0) { - ShowWarningError(state, format("{}{}=\"{}\", invalid", RoutineName, CurrentModuleObject, thisDXCoil.Name)); - ShowContinueError(state, format("...not found {}=\"{}\".", cAlphaFields(16), Alphas(16))); - ShowContinueError(state, "Basin heater will be available to operate throughout the simulation."); + if ((thisDXCoil.basinHeaterSched = Sched::GetSchedule(state, Alphas(16))) == nullptr) { + ShowWarningItemNotFound(state, eoh, cAlphaFields(16), Alphas(16), "Basin heater will be available to operate throughout the simulation."); } } @@ -1962,6 +1948,7 @@ void GetDXCoils(EnergyPlusData &state) cAlphaFields, cNumericFields); + ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)}; // allocate single performance mode for numeric field strings used for sizing routine state.dataDXCoils->DXCoilNumericFields(DXCoilNum).PerfMode.allocate(1); state.dataDXCoils->DXCoilNumericFields(DXCoilNum).PerfMode(1).FieldNames.allocate(MaxNumbers); @@ -1973,16 +1960,11 @@ void GetDXCoils(EnergyPlusData &state) thisDXCoil.Name = Alphas(1); thisDXCoil.DXCoilType = CurrentModuleObject; thisDXCoil.DXCoilType_Num = HVAC::CoilDX_HeatingEmpirical; - thisDXCoil.Schedule = Alphas(2); if (lAlphaBlanks(2)) { - thisDXCoil.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - thisDXCoil.SchedPtr = GetScheduleIndex(state, Alphas(2)); // convert schedule name to pointer - if (thisDXCoil.SchedPtr == 0) { - ShowSevereError(state, format("{}{}=\"{}\", invalid", RoutineName, CurrentModuleObject, thisDXCoil.Name)); - ShowContinueError(state, format("...{}=\"{}\".", cAlphaFields(2), Alphas(2))); - ErrorsFound = true; - } + thisDXCoil.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((thisDXCoil.availSched = Sched::GetSchedule(state, Alphas(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(2), Alphas(2)); + ErrorsFound = true; } thisDXCoil.AirInNode = GetOnlySingleNode(state, @@ -2426,6 +2408,8 @@ void GetDXCoils(EnergyPlusData &state) cAlphaFields, cNumericFields); + ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)}; + // allocate single performance mode for numeric field strings used for sizing routine state.dataDXCoils->DXCoilNumericFields(DXCoilNum).PerfMode.allocate(1); state.dataDXCoils->DXCoilNumericFields(DXCoilNum).PerfMode(1).FieldNames.allocate(MaxNumbers); @@ -2440,16 +2424,11 @@ void GetDXCoils(EnergyPlusData &state) state.dataHeatBal->HeatReclaimDXCoil(DXCoilNum).SourceType = CurrentModuleObject; thisDXCoil.DXCoilType = CurrentModuleObject; thisDXCoil.DXCoilType_Num = HVAC::CoilDX_CoolingTwoSpeed; - thisDXCoil.Schedule = Alphas(2); if (lAlphaBlanks(2)) { - thisDXCoil.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - thisDXCoil.SchedPtr = GetScheduleIndex(state, Alphas(2)); // convert schedule name to pointer - if (thisDXCoil.SchedPtr == 0) { - ShowSevereError(state, format("{}{}=\"{}\", invalid", RoutineName, CurrentModuleObject, thisDXCoil.Name)); - ShowContinueError(state, format("...{}=\"{}\".", cAlphaFields(2), Alphas(2))); - ErrorsFound = true; - } + thisDXCoil.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((thisDXCoil.availSched = Sched::GetSchedule(state, Alphas(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(2), Alphas(2)); + ErrorsFound = true; } thisDXCoil.RatedTotCap(1) = Numbers(1); thisDXCoil.RatedSHR(1) = Numbers(2); @@ -2880,11 +2859,8 @@ void GetDXCoils(EnergyPlusData &state) } if (!lAlphaBlanks(16)) { - thisDXCoil.BasinHeaterSchedulePtr = GetScheduleIndex(state, Alphas(16)); - if (thisDXCoil.BasinHeaterSchedulePtr == 0) { - ShowWarningError(state, format("{}{}=\"{}\", invalid", RoutineName, CurrentModuleObject, thisDXCoil.Name)); - ShowContinueError(state, format("...not found {}=\"{}\".", cAlphaFields(16), Alphas(16))); - ShowContinueError(state, "Basin heater will be available to operate throughout the simulation."); + if ((thisDXCoil.basinHeaterSched = Sched::GetSchedule(state, Alphas(16))) == nullptr) { + ShowWarningItemNotFound(state, eoh, cAlphaFields(16), Alphas(16), "Basin heater will be available to operate throughout the simulation."); } } @@ -3014,7 +2990,7 @@ void GetDXCoils(EnergyPlusData &state) thisDXCoil.Name = Alphas(1); thisDXCoil.DXCoilType = CurrentModuleObject; thisDXCoil.DXCoilType_Num = HVAC::CoilDX_HeatPumpWaterHeaterPumped; - thisDXCoil.SchedPtr = 0; // heat pump water heater DX coil has no schedule + thisDXCoil.availSched = Sched::GetScheduleAlwaysOff(state); // heat pump water heater DX coil has no schedule // Store the HPWH DX coil heating capacity in RatedTotCap2. After backing off pump and fan heat, // move to RatedTotCap() for use by DX coil @@ -3507,7 +3483,7 @@ void GetDXCoils(EnergyPlusData &state) thisDXCoil.Name = Alphas(1); thisDXCoil.DXCoilType = CurrentModuleObject; thisDXCoil.DXCoilType_Num = HVAC::CoilDX_HeatPumpWaterHeaterWrapped; - thisDXCoil.SchedPtr = 0; // heat pump water heater DX coil has no schedule + thisDXCoil.availSched = Sched::GetScheduleAlwaysOff(state); // heat pump water heater DX coil has no schedule // Store the HPWH DX coil heating capacity in RatedTotCap2. After backing off pump and fan heat, // move to RatedTotCap() for use by DX coil @@ -3890,6 +3866,7 @@ void GetDXCoils(EnergyPlusData &state) cAlphaFields, cNumericFields); + ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)}; // allocate single performance mode for numeric field strings used for sizing routine (all fields are in this object) state.dataDXCoils->DXCoilNumericFields(DXCoilNum).PerfMode.allocate(1); state.dataDXCoils->DXCoilNumericFields(DXCoilNum).PerfMode(1).FieldNames.allocate(MaxNumbers); @@ -3904,16 +3881,11 @@ void GetDXCoils(EnergyPlusData &state) state.dataHeatBal->HeatReclaimDXCoil(DXCoilNum).SourceType = CurrentModuleObject; thisDXCoil.DXCoilType = CurrentModuleObject; thisDXCoil.DXCoilType_Num = HVAC::CoilDX_MultiSpeedCooling; - thisDXCoil.Schedule = Alphas(2); if (lAlphaBlanks(2)) { - thisDXCoil.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - thisDXCoil.SchedPtr = GetScheduleIndex(state, Alphas(2)); // convert schedule name to pointer - if (thisDXCoil.SchedPtr == 0) { - ShowSevereError(state, format("{}{}=\"{}\", invalid", RoutineName, CurrentModuleObject, thisDXCoil.Name)); - ShowContinueError(state, format("...{}=\"{}\".", cAlphaFields(2), Alphas(2))); - ErrorsFound = true; - } + thisDXCoil.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((thisDXCoil.availSched = Sched::GetSchedule(state, Alphas(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(2), Alphas(2)); + ErrorsFound = true; } thisDXCoil.AirInNode = GetOnlySingleNode(state, @@ -4072,11 +4044,8 @@ void GetDXCoils(EnergyPlusData &state) } if (!lAlphaBlanks(12)) { - thisDXCoil.BasinHeaterSchedulePtr = GetScheduleIndex(state, Alphas(12)); - if (thisDXCoil.BasinHeaterSchedulePtr == 0) { - ShowWarningError(state, format("{}{}=\"{}\", invalid", RoutineName, CurrentModuleObject, thisDXCoil.Name)); - ShowContinueError(state, format("...not found {}=\"{}\".", cAlphaFields(12), Alphas(12))); - ShowContinueError(state, "Basin heater will be available to operate throughout the simulation."); + if ((thisDXCoil.basinHeaterSched = Sched::GetSchedule(state, Alphas(12))) == nullptr) { + ShowWarningItemNotFound(state, eoh, cAlphaFields(12), Alphas(12), "Basin heater will be available to operate throughout the simulation."); } } @@ -4439,6 +4408,9 @@ void GetDXCoils(EnergyPlusData &state) cAlphaFields, cNumericFields); + + ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)}; + // *** will have to circle back to this one to fix since the multispeed coil has all fields in this coil object *** // allocate single performance mode for numeric field strings used for sizing routine state.dataDXCoils->DXCoilNumericFields(DXCoilNum).PerfMode.allocate(1); @@ -4454,16 +4426,11 @@ void GetDXCoils(EnergyPlusData &state) state.dataHeatBal->HeatReclaimDXCoil(DXCoilNum).SourceType = CurrentModuleObject; thisDXCoil.DXCoilType = CurrentModuleObject; thisDXCoil.DXCoilType_Num = HVAC::CoilDX_MultiSpeedHeating; - thisDXCoil.Schedule = Alphas(2); if (lAlphaBlanks(2)) { - thisDXCoil.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - thisDXCoil.SchedPtr = GetScheduleIndex(state, Alphas(2)); // convert schedule name to pointer - if (thisDXCoil.SchedPtr == 0) { - ShowSevereError(state, format("{}{}=\"{}\", invalid", RoutineName, CurrentModuleObject, thisDXCoil.Name)); - ShowContinueError(state, format("...{}=\"{}\".", cAlphaFields(2), Alphas(2))); - ErrorsFound = true; - } + thisDXCoil.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((thisDXCoil.availSched = Sched::GetSchedule(state, Alphas(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(2), Alphas(2)); + ErrorsFound = true; } thisDXCoil.AirInNode = GetOnlySingleNode(state, @@ -4931,6 +4898,8 @@ void GetDXCoils(EnergyPlusData &state) cAlphaFields, cNumericFields); + ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)}; + ++DXCoilNum; // allocate single performance mode for numeric field strings used for sizing routine @@ -4944,16 +4913,12 @@ void GetDXCoils(EnergyPlusData &state) thisDXCoil.Name = Alphas(1); thisDXCoil.DXCoilType = CurrentModuleObject; thisDXCoil.DXCoilType_Num = HVAC::CoilVRF_Cooling; - thisDXCoil.Schedule = Alphas(2); + if (lAlphaBlanks(2)) { - thisDXCoil.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - thisDXCoil.SchedPtr = GetScheduleIndex(state, Alphas(2)); // convert schedule name to pointer - if (thisDXCoil.SchedPtr == 0) { - ShowSevereError(state, format("{}{}=\"{}\", invalid", RoutineName, CurrentModuleObject, thisDXCoil.Name)); - ShowContinueError(state, format("...{}=\"{}\".", cAlphaFields(2), Alphas(2))); - ErrorsFound = true; - } + thisDXCoil.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((thisDXCoil.availSched = Sched::GetSchedule(state, Alphas(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(2), Alphas(2)); + ErrorsFound = true; } thisDXCoil.RatedTotCap(1) = Numbers(1); thisDXCoil.RatedSHR(1) = Numbers(2); @@ -5075,6 +5040,7 @@ void GetDXCoils(EnergyPlusData &state) cAlphaFields, cNumericFields); + ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)}; ++DXCoilNum; // allocate single performance mode for numeric field strings used for sizing routine @@ -5088,16 +5054,11 @@ void GetDXCoils(EnergyPlusData &state) thisDXCoil.Name = Alphas(1); thisDXCoil.DXCoilType = CurrentModuleObject; thisDXCoil.DXCoilType_Num = HVAC::CoilVRF_Heating; - thisDXCoil.Schedule = Alphas(2); if (lAlphaBlanks(2)) { - thisDXCoil.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - thisDXCoil.SchedPtr = GetScheduleIndex(state, Alphas(2)); // convert schedule name to pointer - if (thisDXCoil.SchedPtr == 0) { - ShowSevereError(state, format("{}{}=\"{}\", invalid", RoutineName, CurrentModuleObject, thisDXCoil.Name)); - ShowContinueError(state, format("...{}=\"{}\".", cAlphaFields(2), Alphas(2))); - ErrorsFound = true; - } + thisDXCoil.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((thisDXCoil.availSched = Sched::GetSchedule(state, Alphas(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(2), Alphas(2)); + ErrorsFound = true; } thisDXCoil.RatedTotCap(1) = Numbers(1); thisDXCoil.RatedAirVolFlowRate(1) = Numbers(2); @@ -5208,6 +5169,7 @@ void GetDXCoils(EnergyPlusData &state) cAlphaFields, cNumericFields); + ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)}; ++DXCoilNum; // allocate single performance mode for numeric field strings used for sizing routine @@ -5221,16 +5183,11 @@ void GetDXCoils(EnergyPlusData &state) thisDXCoil.Name = Alphas(1); thisDXCoil.DXCoilType = CurrentModuleObject; thisDXCoil.DXCoilType_Num = HVAC::CoilVRF_FluidTCtrl_Cooling; - thisDXCoil.Schedule = Alphas(2); if (lAlphaBlanks(2)) { - thisDXCoil.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - thisDXCoil.SchedPtr = GetScheduleIndex(state, Alphas(2)); // convert schedule name to pointer - if (thisDXCoil.SchedPtr == 0) { - ShowSevereError(state, format("{}{}=\"{}\", invalid", RoutineName, CurrentModuleObject, thisDXCoil.Name)); - ShowContinueError(state, format("...{}=\"{}\".", cAlphaFields(2), Alphas(2))); - ErrorsFound = true; - } + thisDXCoil.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((thisDXCoil.availSched = Sched::GetSchedule(state, Alphas(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(2), Alphas(2)); + ErrorsFound = true; } thisDXCoil.AirInNode = GetOnlySingleNode(state, @@ -5326,6 +5283,7 @@ void GetDXCoils(EnergyPlusData &state) cAlphaFields, cNumericFields); + ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)}; ++DXCoilNum; // allocate single performance mode for numeric field strings used for sizing routine @@ -5339,16 +5297,11 @@ void GetDXCoils(EnergyPlusData &state) thisDXCoil.Name = Alphas(1); thisDXCoil.DXCoilType = CurrentModuleObject; thisDXCoil.DXCoilType_Num = HVAC::CoilVRF_FluidTCtrl_Heating; - thisDXCoil.Schedule = Alphas(2); if (lAlphaBlanks(2)) { - thisDXCoil.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - thisDXCoil.SchedPtr = GetScheduleIndex(state, Alphas(2)); // convert schedule name to pointer - if (thisDXCoil.SchedPtr == 0) { - ShowSevereError(state, format("{}{}=\"{}\", invalid", RoutineName, CurrentModuleObject, thisDXCoil.Name)); - ShowContinueError(state, format("...{}=\"{}\".", cAlphaFields(2), Alphas(2))); - ErrorsFound = true; - } + thisDXCoil.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((thisDXCoil.availSched = Sched::GetSchedule(state, Alphas(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(2), Alphas(2)); + ErrorsFound = true; } thisDXCoil.AirInNode = GetOnlySingleNode(state, @@ -9382,7 +9335,7 @@ void CalcDoe2DXCoil(EnergyPlusData &state, thisDXCoil.PrintLowOutTempMessage = false; if ((AirMassFlow > 0.0) && - (GetCurrentScheduleValue(state, thisDXCoil.SchedPtr) > 0.0 || thisDXCoil.DXCoilType_Num == HVAC::CoilDX_HeatPumpWaterHeaterPumped || + (thisDXCoil.availSched->getCurrentVal() > 0.0 || thisDXCoil.DXCoilType_Num == HVAC::CoilDX_HeatPumpWaterHeaterPumped || thisDXCoil.DXCoilType_Num == HVAC::CoilDX_HeatPumpWaterHeaterWrapped) && (PartLoadRatio > 0.0) && (compressorOp == HVAC::CompressorOp::On) && CompAmbTemp > thisDXCoil.MinOATCompressor) { // criteria for coil operation @@ -10010,7 +9963,7 @@ void CalcDoe2DXCoil(EnergyPlusData &state, // Calculate basin heater power CalcBasinHeaterPower(state, thisDXCoil.BasinHeaterPowerFTempDiff, - thisDXCoil.BasinHeaterSchedulePtr, + thisDXCoil.basinHeaterSched, thisDXCoil.BasinHeaterSetPointTemp, thisDXCoil.BasinHeaterPower); if (thisDXCoil.DXCoilType_Num == HVAC::CoilDX_CoolingSingleSpeed) { @@ -10054,7 +10007,7 @@ void CalcDoe2DXCoil(EnergyPlusData &state, if (any_eq(thisDXCoil.CondenserType, DataHeatBalance::RefrigCondenserType::Evap)) { CalcBasinHeaterPower(state, thisDXCoil.BasinHeaterPowerFTempDiff, - thisDXCoil.BasinHeaterSchedulePtr, + thisDXCoil.basinHeaterSched, thisDXCoil.BasinHeaterSetPointTemp, thisDXCoil.BasinHeaterPower); } @@ -10062,7 +10015,7 @@ void CalcDoe2DXCoil(EnergyPlusData &state, if (thisDXCoil.CondenserType(Mode) == DataHeatBalance::RefrigCondenserType::Evap) { CalcBasinHeaterPower(state, thisDXCoil.BasinHeaterPowerFTempDiff, - thisDXCoil.BasinHeaterSchedulePtr, + thisDXCoil.basinHeaterSched, thisDXCoil.BasinHeaterSetPointTemp, thisDXCoil.BasinHeaterPower); } @@ -10374,7 +10327,7 @@ void CalcVRFCoolingCoil(EnergyPlusData &state, thisDXCoil.PrintLowAmbMessage = false; thisDXCoil.PrintLowOutTempMessage = false; - if ((AirMassFlow > 0.0) && (GetCurrentScheduleValue(state, thisDXCoil.SchedPtr) > 0.0) && (PartLoadRatio > 0.0) && + if ((AirMassFlow > 0.0) && (thisDXCoil.availSched->getCurrentVal() > 0.0) && (PartLoadRatio > 0.0) && (compressorOp == HVAC::CompressorOp::On)) { // for cycling fan, reset mass flow to full on rate if (fanOp == HVAC::FanOp::Cycling) { AirMassFlow /= PartLoadRatio; @@ -10954,7 +10907,7 @@ void CalcDXHeatingCoil(EnergyPlusData &state, CrankcaseHeatingPower = 0.0; } - if ((AirMassFlow > 0.0) && (GetCurrentScheduleValue(state, thisDXCoil.SchedPtr) > 0.0) && (PartLoadRatio > 0.0) && + if ((AirMassFlow > 0.0) && (thisDXCoil.availSched->getCurrentVal() > 0.0) && (PartLoadRatio > 0.0) && OutdoorDryBulb > thisDXCoil.MinOATCompressor) { // for cycling fan, reset mass flow to full on rate if (fanOp == HVAC::FanOp::Cycling) AirMassFlow /= PartLoadRatio; @@ -11435,7 +11388,7 @@ void CalcMultiSpeedDXCoil(EnergyPlusData &state, } if ((AirMassFlow > 0.0 && CompAmbTemp >= thisDXCoil.MinOATCompressor) && - ((GetCurrentScheduleValue(state, thisDXCoil.SchedPtr) > 0.0) || (LocalForceOn)) && (SpeedRatio > 0.0 || CycRatio > 0.0)) { + ((thisDXCoil.availSched->getCurrentVal() > 0.0) || (LocalForceOn)) && (SpeedRatio > 0.0 || CycRatio > 0.0)) { RhoAir = PsyRhoAirFnPbTdbW(state, OutdoorPressure, OutdoorDryBulb, OutdoorHumRat); if (SpeedRatio > 0.0) { @@ -11744,7 +11697,7 @@ void CalcMultiSpeedDXCoil(EnergyPlusData &state, // Calculate basin heater power CalcBasinHeaterPower(state, thisDXCoil.BasinHeaterPowerFTempDiff, - thisDXCoil.BasinHeaterSchedulePtr, + thisDXCoil.basinHeaterSched, thisDXCoil.BasinHeaterSetPointTemp, thisDXCoil.BasinHeaterPower); thisDXCoil.BasinHeaterPower *= (1.0 - thisDXCoil.CoolingCoilRuntimeFraction); @@ -11768,7 +11721,7 @@ void CalcMultiSpeedDXCoil(EnergyPlusData &state, if (thisDXCoil.CondenserType(Mode) == DataHeatBalance::RefrigCondenserType::Evap) { CalcBasinHeaterPower(state, thisDXCoil.BasinHeaterPowerFTempDiff, - thisDXCoil.BasinHeaterSchedulePtr, + thisDXCoil.basinHeaterSched, thisDXCoil.BasinHeaterSetPointTemp, thisDXCoil.BasinHeaterPower); } @@ -11828,7 +11781,7 @@ void CalcBasinHeaterPowerForMultiModeDXCoil(EnergyPlusData &state, } else if (thisDXCoil.CondenserType(PerfMode + 1) == DataHeatBalance::RefrigCondenserType::Evap) { CalcBasinHeaterPower(state, thisDXCoil.BasinHeaterPowerFTempDiff, - thisDXCoil.BasinHeaterSchedulePtr, + thisDXCoil.basinHeaterSched, thisDXCoil.BasinHeaterSetPointTemp, thisDXCoil.BasinHeaterPower); thisDXCoil.BasinHeaterPower *= (1.0 - thisDXCoil.CoolingCoilStg2RuntimeFrac); @@ -12720,7 +12673,7 @@ void CalcMultiSpeedDXCoilCooling(EnergyPlusData &state, CrankcaseHeatingPower = 0.0; } - if ((AirMassFlow > 0.0 && CondInletTemp >= thisDXCoil.MinOATCompressor) && (GetCurrentScheduleValue(state, thisDXCoil.SchedPtr) > 0.0) && + if ((AirMassFlow > 0.0 && CondInletTemp >= thisDXCoil.MinOATCompressor) && (thisDXCoil.availSched->getCurrentVal() > 0.0) && ((SpeedRatio > 0.0 && SingleMode == 0) || CycRatio > 0.0) && (compressorOp == HVAC::CompressorOp::On)) { RhoAir = PsyRhoAirFnPbTdbW(state, OutdoorPressure, OutdoorDryBulb, OutdoorHumRat, RoutineName); @@ -13298,7 +13251,7 @@ void CalcMultiSpeedDXCoilCooling(EnergyPlusData &state, // Calculate basin heater power CalcBasinHeaterPower(state, thisDXCoil.BasinHeaterPowerFTempDiff, - thisDXCoil.BasinHeaterSchedulePtr, + thisDXCoil.basinHeaterSched, thisDXCoil.BasinHeaterSetPointTemp, thisDXCoil.BasinHeaterPower); thisDXCoil.BasinHeaterPower *= (1.0 - thisDXCoil.CoolingCoilRuntimeFraction); @@ -13330,7 +13283,7 @@ void CalcMultiSpeedDXCoilCooling(EnergyPlusData &state, if (thisDXCoil.CondenserType(DXMode) == DataHeatBalance::RefrigCondenserType::Evap) { CalcBasinHeaterPower(state, thisDXCoil.BasinHeaterPowerFTempDiff, - thisDXCoil.BasinHeaterSchedulePtr, + thisDXCoil.basinHeaterSched, thisDXCoil.BasinHeaterSetPointTemp, thisDXCoil.BasinHeaterPower); } @@ -13559,7 +13512,7 @@ void CalcMultiSpeedDXCoilHeating(EnergyPlusData &state, thisDXCoil.PartLoadRatio = 0.0; state.dataHeatBal->HeatReclaimDXCoil(DXCoilNum).AvailCapacity = 0.0; - if ((AirMassFlow > 0.0) && (GetCurrentScheduleValue(state, thisDXCoil.SchedPtr) > 0.0) && + if ((AirMassFlow > 0.0) && (thisDXCoil.availSched->getCurrentVal() > 0.0) && ((CycRatio > 0.0) || (SpeedRatio > 0.0 && SingleMode == 0)) && OutdoorDryBulb > thisDXCoil.MinOATCompressor) { if (SpeedNum > 1 && SingleMode == 0) { @@ -15646,11 +15599,11 @@ int GetDXCoilNumberOfSpeeds(EnergyPlusData &state, return NumberOfSpeeds; } -int GetDXCoilAvailSchPtr(EnergyPlusData &state, - std::string const &CoilType, // must match coil types in this module - std::string const &CoilName, // must match coil names for the coil type - bool &ErrorsFound, // set to true if problem - ObjexxFCL::Optional_int_const CoilIndex // Coil index number +Sched::Schedule *GetDXCoilAvailSched(EnergyPlusData &state, + std::string const &CoilType, // must match coil types in this module + std::string const &CoilName, // must match coil names for the coil type + bool &ErrorsFound, // set to true if problem + ObjexxFCL::Optional_int_const CoilIndex // Coil index number ) { @@ -15663,9 +15616,6 @@ int GetDXCoilAvailSchPtr(EnergyPlusData &state, // incorrect coil type or name is given, ErrorsFound is returned as true and schedule index is returned // as -1. - // Return value - int SchPtr; // returned availabiltiy schedule of matched coil - // FUNCTION LOCAL VARIABLE DECLARATIONS: int WhichCoil; @@ -15680,8 +15630,7 @@ int GetDXCoilAvailSchPtr(EnergyPlusData &state, ShowSevereError(state, "GetDXCoilAvailSchPtr: Invalid index passed = 0"); ShowContinueError(state, "... returning DXCoilAvailSchPtr as -1."); ErrorsFound = true; - SchPtr = -1; - return SchPtr; + return nullptr; } else { WhichCoil = CoilIndex; } @@ -15689,7 +15638,7 @@ int GetDXCoilAvailSchPtr(EnergyPlusData &state, WhichCoil = Util::FindItemInList(CoilName, state.dataDXCoils->DXCoil); } if (WhichCoil != 0) { - SchPtr = state.dataDXCoils->DXCoil(WhichCoil).SchedPtr; + return state.dataDXCoils->DXCoil(WhichCoil).availSched; } else { if (!present(CoilIndex)) { ShowSevereError(state, @@ -15698,10 +15647,8 @@ int GetDXCoilAvailSchPtr(EnergyPlusData &state, CoilName)); } ErrorsFound = true; - SchPtr = -1; + return nullptr; } - - return SchPtr; } Real64 GetDXCoilAirFlow(EnergyPlusData &state, @@ -16725,7 +16672,7 @@ void CalcVRFCoolingCoil_FluidTCtrl(EnergyPlusData &state, thisDXCoil.PrintLowAmbMessage = false; thisDXCoil.PrintLowOutTempMessage = false; - if ((AirMassFlow > 0.0) && (GetCurrentScheduleValue(state, thisDXCoil.SchedPtr) > 0.0) && (PartLoadRatio > 0.0) && + if ((AirMassFlow > 0.0) && (thisDXCoil.availSched->getCurrentVal() > 0.0) && (PartLoadRatio > 0.0) && (compressorOp == HVAC::CompressorOp::On)) { // for cycling fan, reset mass flow to full on rate if (thisDXCoil.RatedTotCap(Mode) <= 0.0) { @@ -17070,7 +17017,7 @@ void CalcVRFHeatingCoil_FluidTCtrl(EnergyPlusData &state, CrankcaseHeatingPower = 0.0; } - if ((AirMassFlow > 0.0) && (compressorOp == HVAC::CompressorOp::On) && (GetCurrentScheduleValue(state, thisDXCoil.SchedPtr) > 0.0) && + if ((AirMassFlow > 0.0) && (compressorOp == HVAC::CompressorOp::On) && (thisDXCoil.availSched->getCurrentVal() > 0.0) && (PartLoadRatio > 0.0) && (OutdoorDryBulb > thisDXCoil.MinOATCompressor)) { TotCap = thisDXCoil.RatedTotCap(Mode); diff --git a/src/EnergyPlus/DXCoils.hh b/src/EnergyPlus/DXCoils.hh index af96c667b24..a110832b023 100644 --- a/src/EnergyPlus/DXCoils.hh +++ b/src/EnergyPlus/DXCoils.hh @@ -113,8 +113,7 @@ namespace DXCoils { std::string Name; // Name of the DX Coil std::string DXCoilType; // type of coil int DXCoilType_Num; // Integer equivalent to DXCoilType - std::string Schedule; // WaterCoil Operation Schedule - int SchedPtr; // Pointer to the correct schedule + Sched::Schedule *availSched = nullptr; // availability schedule // RatedCoolCap, RatedSHR and RatedCOP do not include the thermal or electrical // effects due to the supply air fan Array1D RatedTotCap; // Gross total cooling capacity at rated conditions [watts] @@ -171,7 +170,7 @@ namespace DXCoils { std::string LowOutTempBuffer1; // holds warning message until next iteration (only prints 1 message/iteration) std::string LowOutTempBuffer2; // holds warning message until next iteration (only prints 1 message/iteration) int HeatingCoilPLFCurvePTR; // PLF curve index to gas or electric heating coil (used in latent degradation model) - int BasinHeaterSchedulePtr; // Pointer to basin heater schedule + Sched::Schedule *basinHeaterSched = nullptr; // Pointer to basin heater schedule // start of multi-speed compressor variables Real64 RatedTotCap2; // Gross total cooling capacity at rated conditions, low speed [watts] // Note: For HPWHs, RatedTotCap2 = Water Heating Capacity for Coil:DX:HPWH and @@ -455,7 +454,7 @@ namespace DXCoils { // Default Constructor DXCoilData() - : DXCoilType_Num(0), SchedPtr(0), RatedTotCap(MaxModes, 0.0), HeatSizeRatio(1.0), RatedTotCapEMSOverrideOn(MaxModes, false), + : DXCoilType_Num(0), RatedTotCap(MaxModes, 0.0), HeatSizeRatio(1.0), RatedTotCapEMSOverrideOn(MaxModes, false), RatedTotCapEMSOverrideValue(MaxModes, 0.0), RatedSHR(MaxModes, 0.0), RatedSHREMSOverrideOn(MaxModes, false), RatedSHREMSOverrideValue(MaxModes, 0.0), RatedCOP(MaxModes, 0.0), RatedAirVolFlowRate(MaxModes, 0.0), RatedAirVolFlowRateEMSOverrideON(MaxModes, false), RatedAirVolFlowRateEMSOverrideValue(MaxModes, 0.0), @@ -466,7 +465,7 @@ namespace DXCoils { CrankcaseHeaterPower(0.0), MaxOATCrankcaseHeater(0.0), CrankcaseHeaterCapacityCurveIndex(0), CrankcaseHeaterConsumption(0.0), BasinHeaterPowerFTempDiff(0.0), BasinHeaterSetPointTemp(0.0), CompanionUpstreamDXCoil(0), FindCompanionUpStreamCoil(true), CondenserInletNodeNum(MaxModes, 0), LowOutletTempIndex(0), FullLoadOutAirTempLast(0.0), FullLoadInletAirTempLast(0.0), - PrintLowOutTempMessage(false), HeatingCoilPLFCurvePTR(0), BasinHeaterSchedulePtr(0), RatedTotCap2(0.0), RatedSHR2(0.0), RatedCOP2(0.0), + PrintLowOutTempMessage(false), HeatingCoilPLFCurvePTR(0), RatedTotCap2(0.0), RatedSHR2(0.0), RatedCOP2(0.0), RatedAirVolFlowRate2(0.0), FanPowerPerEvapAirFlowRate_LowSpeed(MaxModes, 0.0), FanPowerPerEvapAirFlowRate_2023_LowSpeed(MaxModes, 0.0), RatedAirMassFlowRate2(0.0), RatedCBF2(0.0), CCapFTemp2(0), EIRFTemp2(0), RatedEIR2(0.0), InternalStaticPressureDrop(0.0), RateWithInternalStaticAndFanObject(false), SupplyFanIndex(0), supplyFanType(HVAC::FanType::Invalid), RatedEIR(MaxModes, 0.0), @@ -785,7 +784,7 @@ namespace DXCoils { bool &ErrorsFound // set to true if problem ); - int GetDXCoilAvailSchPtr(EnergyPlusData &state, + Sched::Schedule *GetDXCoilAvailSched(EnergyPlusData &state, std::string const &CoilType, // must match coil types in this module std::string const &CoilName, // must match coil names for the coil type bool &ErrorsFound, // set to true if problem @@ -991,6 +990,10 @@ struct DXCoilsData : BaseGlobalStruct Real64 EIRFlowModFac = 0.0; // EIR modifier (function of actual supply air flow vs rated flow) [-] Real64 TempDryBulb_Leaving_Apoint = 0.0; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/DXFEarClipping.hh b/src/EnergyPlus/DXFEarClipping.hh index 5597301b792..42ad7b37ca6 100644 --- a/src/EnergyPlus/DXFEarClipping.hh +++ b/src/EnergyPlus/DXFEarClipping.hh @@ -143,6 +143,10 @@ struct DXFEarClippingData : BaseGlobalStruct bool trackit = false; int errcount = 0; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/Data/BaseData.hh b/src/EnergyPlus/Data/BaseData.hh index 17d248e66d0..5bfbee26b86 100644 --- a/src/EnergyPlus/Data/BaseData.hh +++ b/src/EnergyPlus/Data/BaseData.hh @@ -54,6 +54,7 @@ struct EnergyPlusData; // Forward declaration struct BaseGlobalStruct { + virtual void init_constant_state([[maybe_unused]] EnergyPlusData &state) = 0; virtual void init_state([[maybe_unused]] EnergyPlusData &state) = 0; virtual void clear_state() = 0; }; diff --git a/src/EnergyPlus/Data/EnergyPlusData.cc b/src/EnergyPlus/Data/EnergyPlusData.cc index b09d3575914..e4acd4bb0bd 100644 --- a/src/EnergyPlus/Data/EnergyPlusData.cc +++ b/src/EnergyPlus/Data/EnergyPlusData.cc @@ -233,7 +233,7 @@ EnergyPlusData::EnergyPlusData() this->dataRuntimeLang = std::make_unique(); this->dataRuntimeLangProcessor = std::make_unique(); this->dataSQLiteProcedures = std::make_unique(); - this->dataScheduleMgr = std::make_unique(); + this->dataSched = std::make_unique(); this->dataSetPointManager = std::make_unique(); this->dataShadowComb = std::make_unique(); this->dataSimAirServingZones = std::make_unique(); @@ -489,7 +489,7 @@ void EnergyPlusData::clear_state() this->dataRuntimeLang->clear_state(); this->dataRuntimeLangProcessor->clear_state(); this->dataSQLiteProcedures->clear_state(); - this->dataScheduleMgr->clear_state(); + this->dataSched->clear_state(); this->dataSetPointManager->clear_state(); this->dataShadowComb->clear_state(); this->dataSimAirServingZones->clear_state(); @@ -570,10 +570,273 @@ void EnergyPlusData::clear_state() this->files.spsz.close(); } +void EnergyPlusData::init_constant_state(EnergyPlusData &state) +{ + if (this->init_constant_state_called) { + return; + } + + this->init_constant_state_called = true; + + this->dataSimulationManager->init_constant_state(state); // GetProjectData + this->dataFluidProps->init_constant_state(state); // GetFluidPropertiesData + this->dataPsychrometrics->init_constant_state(state); // InitializePsychRoutines + this->dataSched->init_constant_state(state); + + this->dataAirLoop->init_constant_state(state); + this->dataAirLoopHVACDOAS->init_constant_state(state); + this->dataAirSystemsData->init_constant_state(state); + this->afn->init_constant_state(state); + this->dataBSDFWindow->init_constant_state(state); + this->dataBaseSizerFanHeatInputs->init_constant_state(state); + this->dataBaseSizerScalableInputs->init_constant_state(state); + this->dataBaseboardElectric->init_constant_state(state); + this->dataBaseboardRadiator->init_constant_state(state); + this->dataBoilerSteam->init_constant_state(state); + this->dataBoilers->init_constant_state(state); + this->dataBranchAirLoopPlant->init_constant_state(state); + this->dataBranchInputManager->init_constant_state(state); + this->dataBranchNodeConnections->init_constant_state(state); + this->dataCHPElectGen->init_constant_state(state); + this->dataCTElectricGenerator->init_constant_state(state); + this->dataChilledCeilingPanelSimple->init_constant_state(state); + this->dataChillerAbsorber->init_constant_state(state); + this->dataChillerElectricEIR->init_constant_state(state); + this->dataChillerExhaustAbsorption->init_constant_state(state); + this->dataChillerGasAbsorption->init_constant_state(state); + this->dataChillerIndirectAbsorption->init_constant_state(state); + this->dataChillerReformulatedEIR->init_constant_state(state); + this->dataChillerElectricASHRAE205->init_constant_state(state); + this->dataCoilCooingDX->init_constant_state(state); + this->dataCondenserLoopTowers->init_constant_state(state); + this->dataConstruction->init_constant_state(state); + this->dataContaminantBalance->init_constant_state(state); + this->dataConvect->init_constant_state(state); + this->dataConvergeParams->init_constant_state(state); + this->dataCoolTower->init_constant_state(state); + this->dataCostEstimateManager->init_constant_state(state); + this->dataCrossVentMgr->init_constant_state(state); + this->dataCurveManager->init_constant_state(state); + this->dataDXCoils->init_constant_state(state); + this->dataDXFEarClipping->init_constant_state(state); + this->dataDaylightingDevices->init_constant_state(state); + this->dataDaylightingDevicesData->init_constant_state(state); + this->dataDayltg->init_constant_state(state); + this->dataDefineEquipment->init_constant_state(state); + this->dataDemandManager->init_constant_state(state); + this->dataDesiccantDehumidifiers->init_constant_state(state); + this->dataDispVentMgr->init_constant_state(state); + this->dataDualDuct->init_constant_state(state); + this->dataEIRFuelFiredHeatPump->init_constant_state(state); + this->dataEIRPlantLoopHeatPump->init_constant_state(state); + this->dataEMSMgr->init_constant_state(state); + this->dataEarthTube->init_constant_state(state); + this->dataEcoRoofMgr->init_constant_state(state); + this->dataEconLifeCycleCost->init_constant_state(state); + this->dataEconTariff->init_constant_state(state); + this->dataElectBaseboardRad->init_constant_state(state); + this->dataElectPwrSvcMgr->init_constant_state(state); + this->dataEnvrn->init_constant_state(state); + this->dataErrTracking->init_constant_state(state); + this->dataEvapCoolers->init_constant_state(state); + this->dataEvapFluidCoolers->init_constant_state(state); + this->dataExteriorEnergyUse->init_constant_state(state); + this->dataExternalInterface->init_constant_state(state); + this->dataFanCoilUnits->init_constant_state(state); + this->dataFans->init_constant_state(state); + this->dataFaultsMgr->init_constant_state(state); + this->dataFluidCoolers->init_constant_state(state); + this->dataFourPipeBeam->init_constant_state(state); + this->dataFuelCellElectGen->init_constant_state(state); + this->dataFurnaces->init_constant_state(state); + this->dataGeneral->init_constant_state(state); + this->dataGeneralRoutines->init_constant_state(state); + this->dataGenerator->init_constant_state(state); + this->dataGeneratorFuelSupply->init_constant_state(state); + this->dataGlobal->init_constant_state(state); + this->dataGlobalNames->init_constant_state(state); + this->dataGrndTempModelMgr->init_constant_state(state); + this->dataGroundHeatExchanger->init_constant_state(state); + this->dataHPWaterToWaterClg->init_constant_state(state); + this->dataHPWaterToWaterHtg->init_constant_state(state); + this->dataHPWaterToWaterSimple->init_constant_state(state); + this->dataHVACAssistedCC->init_constant_state(state); + this->dataHVACControllers->init_constant_state(state); + this->dataHVACCooledBeam->init_constant_state(state); + this->dataHVACCtrl->init_constant_state(state); + this->dataHVACDXHeatPumpSys->init_constant_state(state); + this->dataHVACDuct->init_constant_state(state); + this->dataHVACGlobal->init_constant_state(state); + this->dataHVACInterfaceMgr->init_constant_state(state); + this->dataHVACMgr->init_constant_state(state); + this->dataHVACMultiSpdHP->init_constant_state(state); + this->dataHVACSingleDuctInduc->init_constant_state(state); + this->dataHVACSizingSimMgr->init_constant_state(state); + this->dataHVACStandAloneERV->init_constant_state(state); + this->dataHVACUnitaryBypassVAV->init_constant_state(state); + this->dataHVACVarRefFlow->init_constant_state(state); + this->dataHWBaseboardRad->init_constant_state(state); + this->dataHeatBal->init_constant_state(state); + this->dataHeatBalAirMgr->init_constant_state(state); + this->dataHeatBalFanSys->init_constant_state(state); + this->dataHeatBalFiniteDiffMgr->init_constant_state(state); + this->dataHeatBalHAMTMgr->init_constant_state(state); + this->dataHeatBalIntHeatGains->init_constant_state(state); + this->dataHeatBalIntRadExchg->init_constant_state(state); + this->dataHeatBalMgr->init_constant_state(state); + this->dataHeatBalSurf->init_constant_state(state); + this->dataHeatBalSurfMgr->init_constant_state(state); + this->dataHeatRecovery->init_constant_state(state); + this->dataHeatingCoils->init_constant_state(state); + this->dataHighTempRadSys->init_constant_state(state); + this->dataHumidifiers->init_constant_state(state); + this->dataHybridModel->init_constant_state(state); + this->dataHybridUnitaryAC->init_constant_state(state); + this->dataHysteresisPhaseChange->init_constant_state(state); + this->dataICEngElectGen->init_constant_state(state); + this->dataIPShortCut->init_constant_state(state); + this->dataIceThermalStorage->init_constant_state(state); + this->dataIndoorGreen->init_constant_state(state); + this->dataInputProcessing->init_constant_state(state); + this->dataIntegratedHP->init_constant_state(state); + this->dataInternalHeatGains->init_constant_state(state); + this->dataLoopNodes->init_constant_state(state); + this->dataLowTempRadSys->init_constant_state(state); + this->dataMaterial->init_constant_state(state); + this->dataMatrixDataManager->init_constant_state(state); + this->dataMircoturbElectGen->init_constant_state(state); + this->dataMixedAir->init_constant_state(state); + this->dataMixerComponent->init_constant_state(state); + this->dataMoistureBalEMPD->init_constant_state(state); + this->dataMstBal->init_constant_state(state); + this->dataMstBalEMPD->init_constant_state(state); + this->dataMundtSimMgr->init_constant_state(state); + this->dataNodeInputMgr->init_constant_state(state); + this->dataOutAirNodeMgr->init_constant_state(state); + this->dataOutRptPredefined->init_constant_state(state); + this->dataOutRptTab->init_constant_state(state); + this->dataOutdoorAirUnit->init_constant_state(state); + this->dataOutput->init_constant_state(state); + this->dataOutputProcessor->init_constant_state(state); + this->dataOutputReportTabularAnnual->init_constant_state(state); + this->dataOutputReports->init_constant_state(state); + this->dataOutsideEnergySrcs->init_constant_state(state); + this->dataPackagedThermalStorageCoil->init_constant_state(state); + this->dataPhotovoltaic->init_constant_state(state); + this->dataPhotovoltaicState->init_constant_state(state); + this->dataPhotovoltaicThermalCollector->init_constant_state(state); + this->dataPipeHT->init_constant_state(state); + this->dataPipes->init_constant_state(state); + this->dataPlantCentralGSHP->init_constant_state(state); + this->dataPlantChillers->init_constant_state(state); + this->dataPlantCompTempSrc->init_constant_state(state); + this->dataPlantCondLoopOp->init_constant_state(state); + this->dataPlantHXFluidToFluid->init_constant_state(state); + this->dataPlantLoadProfile->init_constant_state(state); + this->dataPlantMgr->init_constant_state(state); + this->dataPlantPipingSysMgr->init_constant_state(state); + this->dataPlantPressureSys->init_constant_state(state); + this->dataPlantUtilities->init_constant_state(state); + this->dataPlantValves->init_constant_state(state); + this->dataPlnt->init_constant_state(state); + this->dataPluginManager->init_constant_state(state); + this->dataPollution->init_constant_state(state); + this->dataPondGHE->init_constant_state(state); + this->dataPowerInductionUnits->init_constant_state(state); + this->dataPsychCache->init_constant_state(state); + this->dataPumps->init_constant_state(state); + this->dataPurchasedAirMgr->init_constant_state(state); + this->dataRefrigCase->init_constant_state(state); + this->dataReportFlag->init_constant_state(state); + this->dataResultsFramework->init_constant_state(state); + this->dataRetAirPathMrg->init_constant_state(state); + this->dataExhAirSystemMrg->init_constant_state(state); + this->dataExhCtrlSystemMrg->init_constant_state(state); + this->dataRoomAir->init_constant_state(state); + this->dataRoomAirModelTempPattern->init_constant_state(state); + this->dataRoomAirflowNetModel->init_constant_state(state); + this->dataRootFinder->init_constant_state(state); + this->dataRptCoilSelection->init_constant_state(state); + this->dataRuntimeLang->init_constant_state(state); + this->dataRuntimeLangProcessor->init_constant_state(state); + this->dataSQLiteProcedures->init_constant_state(state); + this->dataSetPointManager->init_constant_state(state); + this->dataShadowComb->init_constant_state(state); + this->dataSimAirServingZones->init_constant_state(state); + this->dataSingleDuct->init_constant_state(state); + this->dataSize->init_constant_state(state); + this->dataSizingManager->init_constant_state(state); + this->dataSolarCollectors->init_constant_state(state); + this->dataSolarReflectionManager->init_constant_state(state); + this->dataSolarShading->init_constant_state(state); + this->dataSplitterComponent->init_constant_state(state); + this->dataSteamBaseboardRadiator->init_constant_state(state); + this->dataSteamCoils->init_constant_state(state); + this->dataStrGlobals->init_constant_state(state); + this->dataSurfColor->init_constant_state(state); + this->dataSurfLists->init_constant_state(state); + this->dataSurface->init_constant_state(state); + this->dataSurfaceGeometry->init_constant_state(state); + this->dataSurfaceGroundHeatExchangers->init_constant_state(state); + this->dataSwimmingPools->init_constant_state(state); + this->dataSysAirFlowSizer->init_constant_state(state); + this->dataSysRpts->init_constant_state(state); + this->dataSysVars->init_constant_state(state); + this->dataAvail->init_constant_state(state); + this->dataTARCOGCommon->init_constant_state(state); + this->dataTARCOGOutputs->init_constant_state(state); + this->dataThermalChimneys->init_constant_state(state); + this->dataThermalComforts->init_constant_state(state); + this->dataThermalISO15099Calc->init_constant_state(state); + this->dataTARCOGGasses90->init_constant_state(state); + this->dataTARCOGMain->init_constant_state(state); + this->dataTarcogShading->init_constant_state(state); + this->dataTimingsData->init_constant_state(state); + this->dataTranspiredCollector->init_constant_state(state); + this->dataUFADManager->init_constant_state(state); + this->dataUnitHeaters->init_constant_state(state); + this->dataUnitVentilators->init_constant_state(state); + this->dataUnitarySystems->init_constant_state(state); + this->dataUserDefinedComponents->init_constant_state(state); + this->dataUtilityRoutines->init_constant_state(state); + this->dataVariableSpeedCoils->init_constant_state(state); + this->dataVectors->init_constant_state(state); + this->dataVentilatedSlab->init_constant_state(state); + this->dataViewFactor->init_constant_state(state); + this->dataWaterCoils->init_constant_state(state); + this->dataWaterData->init_constant_state(state); + this->dataWaterManager->init_constant_state(state); + this->dataWaterThermalTanks->init_constant_state(state); + this->dataWaterToAirHeatPump->init_constant_state(state); + this->dataWaterToAirHeatPumpSimple->init_constant_state(state); + this->dataWaterUse->init_constant_state(state); + this->dataWeather->init_constant_state(state); + this->dataWindTurbine->init_constant_state(state); + this->dataWindowAC->init_constant_state(state); + this->dataWindowComplexManager->init_constant_state(state); + this->dataWindowEquivLayer->init_constant_state(state); + this->dataWindowEquivalentLayer->init_constant_state(state); + this->dataWindowManager->init_constant_state(state); + this->dataWindowManagerExterior->init_constant_state(state); + this->dataZoneAirLoopEquipmentManager->init_constant_state(state); + this->dataZoneContaminantPredictorCorrector->init_constant_state(state); + this->dataZoneCtrls->init_constant_state(state); + this->dataZoneDehumidifier->init_constant_state(state); + this->dataZoneEnergyDemand->init_constant_state(state); + this->dataZoneEquip->init_constant_state(state); + this->dataZoneEquipmentManager->init_constant_state(state); + this->dataZonePlenum->init_constant_state(state); + this->dataZoneTempPredictorCorrector->init_constant_state(state); +} + void EnergyPlusData::init_state(EnergyPlusData &state) { - if (this->init_state_called) return; + if (this->init_state_called) { + return; + } + this->init_state_called = true; + // The order in which we do this matters. We're going to try to // do this in "topological" order meaning the first to go are the // objects that do not reference any other objects, like fluids, @@ -581,6 +844,7 @@ void EnergyPlusData::init_state(EnergyPlusData &state) this->dataSimulationManager->init_state(state); // GetProjectData this->dataFluidProps->init_state(state); // GetFluidPropertiesData this->dataPsychrometrics->init_state(state); // InitializePsychRoutines + this->dataSched->init_state(state); this->dataAirLoop->init_state(state); this->dataAirLoopHVACDOAS->init_state(state); @@ -759,7 +1023,6 @@ void EnergyPlusData::init_state(EnergyPlusData &state) this->dataRuntimeLang->init_state(state); this->dataRuntimeLangProcessor->init_state(state); this->dataSQLiteProcedures->init_state(state); - this->dataScheduleMgr->init_state(state); this->dataSetPointManager->init_state(state); this->dataShadowComb->init_state(state); this->dataSimAirServingZones->init_state(state); diff --git a/src/EnergyPlus/Data/EnergyPlusData.hh b/src/EnergyPlus/Data/EnergyPlusData.hh index bfe3499577e..c985b31e5c5 100644 --- a/src/EnergyPlus/Data/EnergyPlusData.hh +++ b/src/EnergyPlus/Data/EnergyPlusData.hh @@ -504,7 +504,7 @@ struct EnergyPlusData : BaseGlobalStruct std::unique_ptr dataRuntimeLang; std::unique_ptr dataRuntimeLangProcessor; std::unique_ptr dataSQLiteProcedures; - std::unique_ptr dataScheduleMgr; + std::unique_ptr dataSched; std::unique_ptr dataSetPointManager; std::unique_ptr dataShadowComb; std::unique_ptr dataSimAirServingZones; @@ -576,8 +576,10 @@ struct EnergyPlusData : BaseGlobalStruct EnergyPlusData(const EnergyPlusData &) = delete; EnergyPlusData(EnergyPlusData &&) = delete; - void init_state([[maybe_unused]] EnergyPlusData &state) override; + void init_constant_state(EnergyPlusData &state) override; + void init_state(EnergyPlusData &state) override; bool init_state_called = false; + bool init_constant_state_called = false; void clear_state() override; }; diff --git a/src/EnergyPlus/DataAirLoop.hh b/src/EnergyPlus/DataAirLoop.hh index e1a6e359749..0340933a7ec 100644 --- a/src/EnergyPlus/DataAirLoop.hh +++ b/src/EnergyPlus/DataAirLoop.hh @@ -125,7 +125,7 @@ namespace DataAirLoop { int OASysNum = 0; // index of OA System bool CyclingFan = false; // TRUE if currently the air loop supply fan is cycling bool AnyContFan = false; // TRUE if at any time supply fan is continuous - int CycFanSchedPtr = 0; // index of schedule indicating whether fan is cycling or continuous in a unitary system + Sched::Schedule *cycFanSched = nullptr; // schedule indicating whether fan is cycling or continuous in a unitary system HVAC::FanOp fanOp = HVAC::FanOp::Invalid; // 1=cycling fan cycling compressor; 2=constant fan cycling comptressor bool UnitarySys = false; // TRUE if a unitary system bool UnitarySysSimulating = true; // set FALSE for AirloopUnitarySystem after simulating to downstream coils can size independently @@ -250,6 +250,10 @@ struct DataAirLoopData : BaseGlobalStruct EPVector OutsideAirSys; EPVector AirLoopAFNInfo; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/DataAirSystems.hh b/src/EnergyPlus/DataAirSystems.hh index 4a029e8b81d..7fdc0767d2d 100644 --- a/src/EnergyPlus/DataAirSystems.hh +++ b/src/EnergyPlus/DataAirSystems.hh @@ -332,6 +332,10 @@ struct AirSystemsData : BaseGlobalStruct Array1D AirSysSubCompToPlant; // Connections between loops Array1D AirSysSubSubCompToPlant; // Connections between loops + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/DataBSDFWindow.hh b/src/EnergyPlus/DataBSDFWindow.hh index 044fdea031d..d4e429c5aa1 100644 --- a/src/EnergyPlus/DataBSDFWindow.hh +++ b/src/EnergyPlus/DataBSDFWindow.hh @@ -393,6 +393,10 @@ struct BSDFWindowData : BaseGlobalStruct Array2D BSDFTempMtrx; // Temporary matrix for holding axisymmetric input EPVector ComplexWind; // Window geometry structure: set in CalcPerSolarBeam/SolarShading + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/DataBranchAirLoopPlant.hh b/src/EnergyPlus/DataBranchAirLoopPlant.hh index f4a533b0497..8e39a62f9ad 100644 --- a/src/EnergyPlus/DataBranchAirLoopPlant.hh +++ b/src/EnergyPlus/DataBranchAirLoopPlant.hh @@ -111,6 +111,10 @@ struct DataBranchAirLoopPlantData : BaseGlobalStruct { Array1D PressureCurve; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/DataBranchNodeConnections.hh b/src/EnergyPlus/DataBranchNodeConnections.hh index eb724939835..cd81a6f2600 100644 --- a/src/EnergyPlus/DataBranchNodeConnections.hh +++ b/src/EnergyPlus/DataBranchNodeConnections.hh @@ -130,6 +130,10 @@ struct BranchNodeConnectionsData : BaseGlobalStruct EPVector AirTerminalNodeConnections; Array1D_bool NonConnectedNodes; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/DataContaminantBalance.hh b/src/EnergyPlus/DataContaminantBalance.hh index 177d4eed26e..a2fedd3762a 100644 --- a/src/EnergyPlus/DataContaminantBalance.hh +++ b/src/EnergyPlus/DataContaminantBalance.hh @@ -55,6 +55,7 @@ #include #include #include +#include namespace EnergyPlus { @@ -68,9 +69,9 @@ namespace DataContaminantBalance { // Members bool SimulateContaminants = false; // A logical flag to determine whether any contaminants are simulated or not bool CO2Simulation = false; // CO2 simulation flag - int CO2OutdoorSchedPtr = 0; // CO2 outdoor level schedule pointer + Sched::Schedule *CO2OutdoorSched = nullptr; // CO2 outdoor level schedule bool GenericContamSimulation = false; // Generic contaminant simulation flag - int GenericContamOutdoorSchedPtr = 0; // Generic contaminant outdoor level schedule pointer + Sched::Schedule *genericOutdoorSched = nullptr; // Generic contaminant outdoor level schedule }; struct ZoneContControls @@ -79,23 +80,18 @@ namespace DataContaminantBalance { std::string Name; // Name of the contaminant controller std::string ZoneName; // Name of the zone int ActualZoneNum = 0; - std::string AvaiSchedule; // Availability Schedule name - int AvaiSchedPtr = 0; // Pointer to the correct schedule - std::string SetPointSchedName; // Name of the schedule which determines the CO2 setpoint - int SPSchedIndex = 0; // Index for this schedule + Sched::Schedule *availSched = nullptr; // Availability schedule + Sched::Schedule *setptSched = nullptr; // Setpoint schedule bool EMSOverrideCO2SetPointOn = false; // EMS is calling to override CO2 setpoint Real64 EMSOverrideCO2SetPointValue = 0.0; // value EMS is directing to use for CO2 setpoint int NumOfZones = 0; // Number of controlled zones in the same airloop Array1D_int ControlZoneNum; // Controlled zone number - std::string ZoneMinCO2SchedName; // Name of the schedule which determines minimum CO2 concentration - int ZoneMinCO2SchedIndex = 0; // Index for this schedule - std::string ZoneMaxCO2SchedName; // Name of the schedule which determines maximum CO2 concentration - int ZoneMaxCO2SchedIndex = 0; // Index for this schedule - int ZoneContamControllerSchedIndex = 0; // Index for this schedule - std::string GCAvaiSchedule; // Availability Schedule name for generic contamiant - int GCAvaiSchedPtr = 0; // Pointer to the correct generic contaminant availability schedule - std::string GCSetPointSchedName; // Name of the schedule which determines the generic contaminant setpoint - int GCSPSchedIndex = 0; // Index for this schedule + Sched::Schedule *zoneMinCO2Sched = nullptr; // Minimum CO2 concentration schedule + Sched::Schedule *zoneMaxCO2Sched = nullptr; // Maximum CO2 concentration schedule + + Sched::Schedule *zoneContamControllerSched = nullptr; // Index for this schedule + Sched::Schedule *genericContamAvailSched = nullptr; // Availability Schedule name for generic contamiant + Sched::Schedule *genericContamSetptSched = nullptr; // Schedule which determines the generic contaminant setpoint bool EMSOverrideGCSetPointOn = false; // EMS is calling to override generic contaminant setpoint Real64 EMSOverrideGCSetPointValue = 0.0; // value EMS is directing to use for generic contaminant setpoint }; @@ -115,11 +111,11 @@ namespace DataContaminantBalance { std::string Name; // Name of the constant generic contaminant source and sink std::string ZoneName; // Name of the zone int ActualZoneNum = 0; // Zone number - Real64 GCGenerateRate = 0.0; // Generic contaminant design generation rate [m3/s] - int GCGenerateRateSchedPtr = 0; // Generic contaminant design generation rate schedule pointer - Real64 GCRemovalCoef = 0.0; // Generic contaminant design removal coefficient [m3/s] - int GCRemovalCoefSchedPtr = 0; // Generic contaminant design removal coefficient schedule pointer - Real64 GCGenRate = 0.0; // Generic contaminant design generation rate [m3/s] for reporting + Real64 GenerateRate = 0.0; // Generic contaminant design generation rate [m3/s] + Sched::Schedule *generateRateSched = nullptr; // Generic contaminant design generation rate schedule pointer + Real64 RemovalCoef = 0.0; // Generic contaminant design removal coefficient [m3/s] + Sched::Schedule *removalCoefSched = nullptr; // Generic contaminant design removal coefficient schedule pointer + Real64 GenRate = 0.0; // Generic contaminant design generation rate [m3/s] for reporting }; struct ZoneContamGenericDataPDriven @@ -128,10 +124,10 @@ namespace DataContaminantBalance { std::string Name; // Name of the pressure driven generic contaminant source and sink std::string SurfName; // Name of the surface int SurfNum = 0; // Surface number - Real64 GCGenRateCoef = 0.0; // Generic contaminant design generation rate coefficeint [m3/s] - int GCGenRateCoefSchedPtr = 0; // Generic contaminant design generation rate schedule pointer - Real64 GCExpo = 0.0; // Generic contaminant exponent [] - Real64 GCGenRate = 0.0; // Generic contaminant design generation rate [m3/s] for reporting + Real64 GenRateCoef = 0.0; // Generic contaminant design generation rate coefficeint [m3/s] + Sched::Schedule * generateRateCoefSched = nullptr; // Generic contaminant design generation rate schedule + Real64 Expo = 0.0; // Generic contaminant exponent [] + Real64 GenRate = 0.0; // Generic contaminant design generation rate [m3/s] for reporting }; struct ZoneContamGenericDataCutoff @@ -140,10 +136,10 @@ namespace DataContaminantBalance { std::string Name; // Name of the cutoff generic contaminant source and sink std::string ZoneName; // Name of the zone int ActualZoneNum = 0; // Zone number - Real64 GCGenerateRate = 0.0; // Generic contaminant design generation rate [m3/s] - int GCGenerateRateSchedPtr = 0; // Generic contaminant design generation rate schedule pointer - Real64 GCCutoffValue = 0.0; // Cutoff value [ppm] - Real64 GCGenRate = 0.0; // Generic contaminant design generation rate [m3/s] for reporting + Real64 GenerateRate = 0.0; // Generic contaminant design generation rate [m3/s] + Sched::Schedule *generateRateSched = nullptr; // Generic contaminant design generation rate schedule pointer + Real64 CutoffValue = 0.0; // Cutoff value [ppm] + Real64 GenRate = 0.0; // Generic contaminant design generation rate [m3/s] for reporting }; struct ZoneContamGenericDataDecay @@ -152,11 +148,11 @@ namespace DataContaminantBalance { std::string Name; // Name of the decay generic contaminant source and sink std::string ZoneName; // Name of the zone int ActualZoneNum = 0; // Zone number - Real64 GCInitEmiRate = 0.0; // Generic contaminant design generation rate [m3/s] - int GCEmiRateSchedPtr = 0; // Generic contaminant emission rate schedule pointer - Real64 GCTime = 0.0; // Time since the styart of emission [s] - Real64 GCDelayTime = 0.0; // Delay time constant [s] - Real64 GCGenRate = 0.0; // Generic contaminant design generation rate [m3/s] for reporting + Real64 InitEmitRate = 0.0; // Generic contaminant design generation rate [m3/s] + Sched::Schedule *emitRateSched = nullptr; // Generic contaminant emission rate schedule pointer + Real64 Time = 0.0; // Time since the styart of emission [s] + Real64 DelayTime = 0.0; // Delay time constant [s] + Real64 GenRate = 0.0; // Generic contaminant design generation rate [m3/s] for reporting }; struct ZoneContamGenericDataBLDiff @@ -166,11 +162,11 @@ namespace DataContaminantBalance { // and sink std::string SurfName; // Name of the surface int SurfNum = 0; // Surface number - Real64 GCTranCoef = 0.0; // Generic contaminant mass transfer coefficeint [m/s] - int GCTranCoefSchedPtr = 0; // Generic contaminant mass transfer coefficeint schedule pointer - Real64 GCHenryCoef = 0.0; // Generic contaminant Henry adsorption constant or + Real64 TransCoef = 0.0; // Generic contaminant mass transfer coefficeint [m/s] + Sched::Schedule *transCoefSched = nullptr; // Generic contaminant mass transfer coefficeint schedule pointer + Real64 HenryCoef = 0.0; // Generic contaminant Henry adsorption constant or // partition coefficient [] - Real64 GCGenRate = 0.0; // Generic contaminant design generation rate [m3/s] for reporting + Real64 GenRate = 0.0; // Generic contaminant design generation rate [m3/s] for reporting }; struct ZoneContamGenericDataDVS @@ -179,9 +175,9 @@ namespace DataContaminantBalance { std::string Name; // Name of the deposition velocity generic contaminant sink std::string SurfName; // Name of the surface int SurfNum = 0; // Surface number - Real64 GCDepoVelo = 0.0; // Generic contaminant deposition velocity [m/s] - int GCDepoVeloPtr = 0; // Generic contaminant deposition velocity sink schedule pointer - Real64 GCGenRate = 0.0; // Generic contaminant design generation rate [m3/s] for reporting + Real64 DepoVelo = 0.0; // Generic contaminant deposition velocity [m/s] + Sched::Schedule *depoVeloSched = nullptr; // Generic contaminant deposition velocity sink schedule pointer + Real64 GenRate = 0.0; // Generic contaminant design generation rate [m3/s] for reporting }; struct ZoneContamGenericDataDRS @@ -190,16 +186,15 @@ namespace DataContaminantBalance { std::string Name; // Name of the deposition rate generic contaminant sink std::string ZoneName; // Name of the zone int ActualZoneNum = 0; // Zone number - Real64 GCDepoRate = 0.0; // Generic contaminant deposition rate [m/s] - int GCDepoRatePtr = 0; // Generic contaminant deposition rate sink schedule pointer - Real64 GCGenRate = 0.0; // Generic contaminant design generation rate [m3/s] for reporting + Real64 DepoRate = 0.0; // Generic contaminant deposition rate [m/s] + Sched::Schedule *depoRateSched = nullptr; // Generic contaminant deposition rate sink schedule + Real64 GenRate = 0.0; // Generic contaminant design generation rate [m3/s] for reporting }; } // namespace DataContaminantBalance struct ContaminantBalanceData : BaseGlobalStruct { - Array1D ZoneCO2SetPoint; Array1D CO2PredictedRate; @@ -291,6 +286,10 @@ struct ContaminantBalanceData : BaseGlobalStruct Array1D ZoneContamGenericDVS; Array1D ZoneContamGenericDRS; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/DataConvergParams.hh b/src/EnergyPlus/DataConvergParams.hh index ccb329ae122..a18b83f4a82 100644 --- a/src/EnergyPlus/DataConvergParams.hh +++ b/src/EnergyPlus/DataConvergParams.hh @@ -183,6 +183,10 @@ struct ConvergParamsData : BaseGlobalStruct Array1D AirLoopConvergence; Array1D PlantConvergence; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/DataDaylighting.hh b/src/EnergyPlus/DataDaylighting.hh index 36b8c0a78c4..ad945271825 100644 --- a/src/EnergyPlus/DataDaylighting.hh +++ b/src/EnergyPlus/DataDaylighting.hh @@ -189,7 +189,7 @@ namespace Dayltg { int spaceIndex = 0; // Index to space where the daylighting:controls object is located (0 if specified for a zone) int enclIndex = 0; // Index to enclosure where the daylighting:controls object is located Dayltg::DaylightingMethod DaylightMethod = DaylightingMethod::None; // Type of Daylighting (1=SplitFlux, 2=DElight) - int AvailSchedNum = 0; // pointer to availability schedule if present + Sched::Schedule *availSched = nullptr; // availability schedule if present int TotalExtWindows = 0; int TotalDaylRefPoints = 0; // Number of daylighting reference points for this control @@ -214,7 +214,7 @@ namespace Dayltg { // 3: Reference point number (1 to Total Daylighting Reference Points) // 4: Sky type (1 to 4; 1 = clear, 2 = clear turbid, 3 = intermediate, 4 = overcast // 5: Daylit window number (1 to NumOfDayltgExtWins) - std::array, (int)DataSurfaces::WinCover::Num>>, (int)Constant::HoursInDay + 1> + std::array, (int)DataSurfaces::WinCover::Num>>, (int)Constant::iHoursInDay + 1> daylFac; // Time exceeding daylight illuminance setpoint at reference points (hours) @@ -271,7 +271,7 @@ namespace Dayltg { // 3: Reference point number (1 to Total Map Reference Points) // 4: Shading index (1 to MaxSlatAngs+1; 1 = bare window; 2 = with shade, or, if blinds // 2 = first slat position, 3 = second position, ..., MaxSlatAngs+1 = last position) - std::array>, (int)Constant::HoursInDay + 1> daylFac; + std::array>, (int)Constant::iHoursInDay + 1> daylFac; }; struct RefPointData diff --git a/src/EnergyPlus/DataDaylightingDevices.hh b/src/EnergyPlus/DataDaylightingDevices.hh index 7b2a98d0d05..73bae717523 100644 --- a/src/EnergyPlus/DataDaylightingDevices.hh +++ b/src/EnergyPlus/DataDaylightingDevices.hh @@ -136,6 +136,10 @@ struct DataDaylightingDevicesData : BaseGlobalStruct Array1D TDDPipe; Array1D Shelf; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/DataDefineEquip.hh b/src/EnergyPlus/DataDefineEquip.hh index 98d7bcaf6e6..a183a9167db 100644 --- a/src/EnergyPlus/DataDefineEquip.hh +++ b/src/EnergyPlus/DataDefineEquip.hh @@ -145,6 +145,10 @@ struct DefineEquipData : BaseGlobalStruct { Array1D AirDistUnit; // Used to specify zone related + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/DataEnvironment.hh b/src/EnergyPlus/DataEnvironment.hh index f1ff959a438..e3cf0dc213d 100644 --- a/src/EnergyPlus/DataEnvironment.hh +++ b/src/EnergyPlus/DataEnvironment.hh @@ -54,6 +54,7 @@ // EnergyPlus Headers #include #include +#include namespace EnergyPlus { @@ -205,12 +206,16 @@ struct EnvironmentData : BaseGlobalStruct std::string EnvironmentStartEnd; // Start/End dates for Environment bool CurrentYearIsLeapYear = false; // true when current year is leap year (convoluted logic dealing with whether weather file allows leap years, runperiod inputs. - int varyingLocationSchedIndexLat = 0; - int varyingLocationSchedIndexLong = 0; - int varyingOrientationSchedIndex = 0; + Sched::Schedule *varyingLocationLatSched = nullptr; + Sched::Schedule *varyingLocationLongSched = nullptr; + Sched::Schedule *varyingOrientationSched = nullptr; bool forceBeginEnvResetSuppress = false; // for PerformancePrecisionTradeoffs bool oneTimeCompRptHeaderFlag = true; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/DataErrorTracking.hh b/src/EnergyPlus/DataErrorTracking.hh index d88f17840da..b46d2e6d3f6 100644 --- a/src/EnergyPlus/DataErrorTracking.hh +++ b/src/EnergyPlus/DataErrorTracking.hh @@ -232,6 +232,10 @@ struct ErrorTrackingData : BaseGlobalStruct MatchCounts = Array1D_int(DataErrorTracking::SearchCounts, 0); } + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/DataGenerators.hh b/src/EnergyPlus/DataGenerators.hh index 88246121787..0ae75640a83 100644 --- a/src/EnergyPlus/DataGenerators.hh +++ b/src/EnergyPlus/DataGenerators.hh @@ -55,6 +55,7 @@ #include #include #include +#include namespace EnergyPlus { @@ -203,7 +204,7 @@ namespace DataGenerators { DataGenerators::FuelMode FuelTypeMode = DataGenerators::FuelMode::Invalid; // type of fuel, gasous or liquid std::string NodeName; // node name for temperature at input int NodeNum = 0; // node number for temperature at input - int SchedNum = 0; // fuel temperature at input + Sched::Schedule *sched = nullptr; // fuel temperature at input int CompPowerCurveID = 0; // "pointer" to compressor power cubic curve Real64 CompPowerLossFactor = 0.0; int NumConstituents = 0; // number of constituents in fue supply @@ -292,7 +293,7 @@ namespace DataGenerators { Real64 kp = 0.0; // coefficient k_p for warmup power bool MandatoryFullCoolDown = false; bool WarmRestartOkay = true; - int AvailabilitySchedID = 0; + Sched::Schedule *availSched = nullptr; // Calculated values and input from elsewhere DataGenerators::OperatingMode CurrentOpMode = DataGenerators::OperatingMode::Off; // current operating mode, uses params like OpModeNormal DataGenerators::OperatingMode LastOpMode = DataGenerators::OperatingMode::Off; @@ -327,6 +328,10 @@ struct GeneratorsData : BaseGlobalStruct Real64 TrialMdotcw = 0.0; // test or estimate of what the plant flows are going to be (kg/s) Real64 LimitMinMdotcw = 0.0; // lower limit for cooling water flow for generatior operation (kg/s) + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/DataGlobalConstants.hh b/src/EnergyPlus/DataGlobalConstants.hh index 7ddb061d90f..100343844f7 100644 --- a/src/EnergyPlus/DataGlobalConstants.hh +++ b/src/EnergyPlus/DataGlobalConstants.hh @@ -597,13 +597,24 @@ namespace Constant { Real64 constexpr Pi = 3.14159265358979324; // Pi 3.1415926535897932384626435 Real64 constexpr PiOvr2 = Pi / 2.0; // Pi/2 Real64 constexpr TwoPi = 2.0 * Pi; // 2*Pi 6.2831853071795864769252868 - Real64 constexpr GravityConstant = 9.807; - Real64 constexpr DegToRadians = Pi / 180.0; // Conversion for Degrees to Radians + Real64 constexpr Gravity = 9.807; Real64 constexpr DegToRad = Pi / 180.0; // Why is it DegToRadians and RadToDeg? Why? WHY? Real64 constexpr RadToDeg = 180.0 / Pi; // Conversion for Radians to Degrees - Real64 constexpr SecInHour = 3600.0; // Conversion for hours to seconds - Real64 constexpr HoursInDay = 24.0; // Number of Hours in Day - Real64 constexpr SecsInDay = SecInHour * HoursInDay; // Number of seconds in Day + + int constexpr iSecsInMinute = 60; // Conversion for hours to seconds + int constexpr iMinutesInHour = 60; // Conversion for hours to minutes + int constexpr iSecsInHour = iSecsInMinute * iMinutesInHour; // Conversion for hours to seconds + int constexpr iHoursInDay = 24; // Number of Hours in Day + int constexpr iMinutesInDay = iMinutesInHour * iHoursInDay; // Number of seconds in Day + int constexpr iSecsInDay = iSecsInHour * iHoursInDay; // Number of seconds in Day + + Real64 constexpr rSecsInMinute = 60.0; // Conversion for hours to seconds + Real64 constexpr rMinutesInHour = 60.0; // Conversion for hours to minutes + Real64 constexpr rSecsInHour = rSecsInMinute * rMinutesInHour; // Conversion for hours to seconds + Real64 constexpr rHoursInDay = 24.0; // Number of Hours in Day + Real64 constexpr rMinutesInDay = rMinutesInHour * rHoursInDay; // Number of seconds in Day + Real64 constexpr rSecsInDay = rSecsInHour * rHoursInDay; // Number of seconds in Day + Real64 constexpr BigNumber = std::numeric_limits::max(); // Max Number real used for initializations Real64 constexpr rTinyValue = std::numeric_limits::epsilon(); // Tiny value to replace use of TINY(x) std::string::size_type constexpr MaxNameLength = diff --git a/src/EnergyPlus/DataGlobals.hh b/src/EnergyPlus/DataGlobals.hh index fb4d70283fd..b5b3c82ad23 100644 --- a/src/EnergyPlus/DataGlobals.hh +++ b/src/EnergyPlus/DataGlobals.hh @@ -105,7 +105,7 @@ struct DataGlobal : BaseGlobalStruct Real64 WeightNow = 0.0; // Weighting of value for current hour int NumOfDayInEnvrn = 0; // Number of days in the simulation for a particular environment bool OverrideTimestep = false; // True if PerformancePrecision object overrides the number of time steps in each hour - int NumOfTimeStepInHour = 0; // Number of time steps in each hour of the simulation + int TimeStepsInHour = 0; // Number of time steps in each hour of the simulation int NumOfZones = 0; // Total number of Zones for simulation int numSpaces = 0; // Total number of Spaces for simulation int numSpaceTypes = 0; // Number of unique space types @@ -139,7 +139,7 @@ struct DataGlobal : BaseGlobalStruct bool CreateMinimalSurfaceVariables = false; // True when selection for "CreateMinimalSurfaceVariables" is entered Real64 CurrentTime = 0.0; // CurrentTime, in fractional hours, from start of day. Uses Loads time step. int SimTimeSteps = 0; // Number of (Loads) timesteps since beginning of run period (environment). - int MinutesPerTimeStep = 0; // Minutes per time step calculated from NumTimeStepInHour (number of minutes per load time step) + int MinutesInTimeStep = 0; // Minutes per time step calculated from NumTimeStepInHour (number of minutes per load time step) Real64 TimeStepZoneSec = 0.0; // Seconds per time step bool MetersHaveBeenInitialized = false; bool KickOffSimulation = false; // Kick off simulation -- meaning run each environment for 1 or 2 time steps. @@ -177,6 +177,10 @@ struct DataGlobal : BaseGlobalStruct int numThread = 1; bool AirLoopHVACDOASUsedInSim = false; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/DataHVACControllers.hh b/src/EnergyPlus/DataHVACControllers.hh index 0c6be17f416..c26d8e29805 100644 --- a/src/EnergyPlus/DataHVACControllers.hh +++ b/src/EnergyPlus/DataHVACControllers.hh @@ -120,6 +120,10 @@ struct HVACCtrlData : BaseGlobalStruct "Active min-constrained controller mode", "Active max-constrained controller mode"}); + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/DataHVACGlobals.hh b/src/EnergyPlus/DataHVACGlobals.hh index 5565538e8bc..d80809c1794 100644 --- a/src/EnergyPlus/DataHVACGlobals.hh +++ b/src/EnergyPlus/DataHVACGlobals.hh @@ -109,18 +109,21 @@ namespace HVAC { int constexpr AutoCalculateSizing(25); // identifies an autocalulate input // The following parameters describe the setpoint types in TempControlType(ActualZoneNum) - enum class ThermostatType + enum class SetptType { Invalid = -1, Uncontrolled, - SingleHeating, - SingleCooling, + SingleHeat, + SingleCool, SingleHeatCool, - DualSetPointWithDeadBand, + DualHeatCool, Num }; - static constexpr std::array(ThermostatType::Num)> thermostatTypeNames = { + static constexpr std::array setptTypes = { + SetptType::SingleHeat, SetptType::SingleCool, SetptType::SingleHeatCool, SetptType::DualHeatCool}; + + static constexpr std::array setptTypeNames = { "Uncontrolled", "SingleHeating", "SingleCooling", "SingleHeatCool", "DualSetPointWithDeadBand"}; enum class AirDuctType @@ -534,6 +537,10 @@ struct HVACGlobalsData : BaseGlobalStruct bool StandardRatingsMyHeatOneTimeFlag = true; bool StandardRatingsMyHeatOneTimeFlag2 = true; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/DataHeatBalFanSys.hh b/src/EnergyPlus/DataHeatBalFanSys.hh index aab092488ea..20d9336a091 100644 --- a/src/EnergyPlus/DataHeatBalFanSys.hh +++ b/src/EnergyPlus/DataHeatBalFanSys.hh @@ -98,6 +98,16 @@ namespace DataHeatBalFanSys { Real64 CoolingPanel; // Current radiant heat flux to surface from simple cooling panels }; + struct ZoneTstatSetpt + { + Real64 setpt = 0.0; + Real64 setptAdapComfortCool = 0.0; + Real64 setptHi = 0.0; + Real64 setptLo = 0.0; + Real64 setptHiAver = 0.0; + Real64 setptLoAver = 0.0; + }; + } // namespace DataHeatBalFanSys struct HeatBalFanSysData : BaseGlobalStruct @@ -141,12 +151,7 @@ struct HeatBalFanSysData : BaseGlobalStruct Array1D RadSysToHBTinCoef; // Outside heat balance coefficient that modifies Toutside Array1D RadSysToHBQsrcCoef; // Outside heat balance coefficient that modifies source/sink - Array1D TempZoneThermostatSetPoint; - Array1D AdapComfortCoolingSetPoint; - Array1D ZoneThermostatSetPointHi; - Array1D ZoneThermostatSetPointLo; - Array1D ZoneThermostatSetPointHiAver; - Array1D ZoneThermostatSetPointLoAver; + Array1D zoneTstatSetpts; EPVector LoadCorrectionFactor; // PH 3/3/04 @@ -157,9 +162,9 @@ struct HeatBalFanSysData : BaseGlobalStruct Array1D PreviousMeasuredHumRat1; // Hybrid model zone humidity ratio at previous timestep Array1D PreviousMeasuredHumRat2; // Hybrid model zone humidity ratio at previous timestep Array1D PreviousMeasuredHumRat3; // Hybrid model zone humidity ratio at previous timestep - EPVector TempControlType; + EPVector TempControlType; EPVector TempControlTypeRpt; - EPVector ComfortControlType; + EPVector ComfortControlType; EPVector ComfortControlTypeRpt; Array2D CrossedColdThreshRepPeriod; @@ -195,6 +200,10 @@ struct HeatBalFanSysData : BaseGlobalStruct EPVector ZoneComfortControlsFanger; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/DataHeatBalSurface.hh b/src/EnergyPlus/DataHeatBalSurface.hh index 0a70f0a729f..e940be3f6b6 100644 --- a/src/EnergyPlus/DataHeatBalSurface.hh +++ b/src/EnergyPlus/DataHeatBalSurface.hh @@ -245,6 +245,10 @@ struct HeatBalSurfData : BaseGlobalStruct std::vector SurfMovInsulIndexList; std::vector SurfMovSlatsIndexList; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/DataHeatBalance.hh b/src/EnergyPlus/DataHeatBalance.hh index 39cfa28773c..ceb4184b556 100644 --- a/src/EnergyPlus/DataHeatBalance.hh +++ b/src/EnergyPlus/DataHeatBalance.hh @@ -639,9 +639,9 @@ namespace DataHeatBalance { Real64 NominalMixing = 0.0; // internal mixing/cross mixing bool TempOutOfBoundsReported = false; // if any temp out of bounds errors, first will show zone details. bool EnforcedReciprocity = false; // if zone/space required forced reciprocity -- less out of bounds temp errors allowed - int ZoneMinCO2SchedIndex = 0; // Index for the schedule the schedule which determines minimum CO2 concentration - int ZoneMaxCO2SchedIndex = 0; // Index for the schedule the schedule which determines maximum CO2 concentration - int ZoneContamControllerSchedIndex = 0; // Index for this schedule + Sched::Schedule *zoneMinCO2Sched = nullptr; // Index for the schedule the schedule which determines minimum CO2 concentration + Sched::Schedule *zoneMaxCO2Sched = nullptr; // Index for the schedule the schedule which determines maximum CO2 concentration + Sched::Schedule *zoneContamControllerSched = nullptr; // Index for this schedule bool FlagCustomizedZoneCap = false; // True if customized Zone Capacitance Multiplier is used std::vector otherEquipFuelTypeNums; // List of fuel types used by other equipment in this zone @@ -733,24 +733,24 @@ namespace DataHeatBalance { int ZonePtr = 0; // Zone index for this people statement int spaceIndex = 0; // Space index for this people statement Real64 NumberOfPeople = 0.0; // Maximum number of people for this statement - int NumberOfPeoplePtr = -1; // Pointer to schedule for number of people + Sched::Schedule *numberOfPeopleSched = nullptr; // schedule for number of people bool EMSPeopleOn = false; // EMS actuating number of people if .TRUE. Real64 EMSNumberOfPeople = 0.0; // Value EMS is directing to use for override // Note that the schedule and maximum number was kept for people since it seemed likely that // users would want to assign the same schedule to multiple people statements. - int ActivityLevelPtr = -1; // Pointer to schedule for activity level + Sched::Schedule *activityLevelSched = nullptr; // schedule for activity level Real64 FractionRadiant = 0.0; // Percentage (fraction 0.0-1.0) of sensible heat gain from people // that is radiant Real64 FractionConvected = 0.0; // Percentage (fraction 0.0-1.0) of sensible heat gain from people // that is convective Real64 NomMinNumberPeople = 0.0; // Nominal Minimum Number of People (min sch X number of people) Real64 NomMaxNumberPeople = 0.0; // Nominal Maximum Number of People (min sch X number of people) - int WorkEffPtr = -1; // Pointer to schedule for work efficiency - int ClothingPtr = -1; // Pointer to schedule for clothing insulation - int ClothingMethodPtr = -1; + Sched::Schedule *workEffSched = nullptr; // schedule for work efficiency + Sched::Schedule *clothingSched = nullptr; // schedule for clothing insulation + Sched::Schedule *clothingMethodSched = nullptr; ClothingType clothingType = ClothingType::Invalid; // Clothing type - int AirVelocityPtr = -1; // Pointer to schedule for air velocity in zone - int AnkleAirVelocityPtr = -1; // Pointer to schedule for air velocity in zone + Sched::Schedule *airVelocitySched = nullptr; // schedule for air velocity in zone + Sched::Schedule *ankleAirVelocitySched = nullptr; // schedule for ankle air velocity in zone bool Fanger = false; // True when Fanger calculation to be performed bool Pierce = false; // True when Pierce 2-node calculation to be performed bool KSU = false; // True when KSU 2-node calculation to be performed @@ -800,7 +800,7 @@ namespace DataHeatBalance { std::string Name; // LIGHTS object name int ZonePtr = 0; // Which zone lights are in int spaceIndex = 0; // Space index for this lights instance - int SchedPtr = -1; // Schedule for lights + Sched::Schedule *sched = nullptr; // Schedule for lights Real64 DesignLevel = 0.0; // design level for lights [W] bool EMSLightsOn = false; // EMS actuating Lighting power if .TRUE. Real64 EMSLightingPower = 0.0; // Value EMS is directing to use for override @@ -843,7 +843,7 @@ namespace DataHeatBalance { std::string Name; // EQUIPMENT object name int ZonePtr = 0; // Which zone internal gain is in int spaceIndex = 0; // Space index for this equipment instance - int SchedPtr = 0; // Schedule for internal gain + Sched::Schedule *sched = nullptr; // Schedule for internal gain Real64 DesignLevel = 0.0; // design level for internal gain [W] bool EMSZoneEquipOverrideOn = false; // EMS actuating equipment power if .TRUE. Real64 EMSEquipPower = 0.0; // Value EMS is directing to use for override @@ -977,8 +977,8 @@ namespace DataHeatBalance { Real64 NomMinDesignLevel = 0.0; // Nominal Minimum Design Level (min sch X design level) Real64 NomMaxDesignLevel = 0.0; // Nominal Maximum Design Level (max sch X design level) Real64 DesignFanPowerFrac = 0.0; // Fraction (0.0-1.0) of design power level that is fans - int OperSchedPtr = 0; // Schedule pointer for design power input or operating schedule - int CPULoadSchedPtr = 0; // Schedule pointer for CPU loading schedule + Sched::Schedule *operSched = nullptr; // Schedule for design power input or operating schedule + Sched::Schedule *cpuLoadSched = nullptr; // Schedule for CPU loading schedule Real64 SizingTAirIn = 0.0; // Entering air dry-bulb temperature at maximum value during sizing[C] Real64 DesignTAirIn = 0.0; // Design entering air dry-bulb temperature [C] Real64 DesignFanPower = 0.0; // Design fan power input [W] @@ -1007,9 +1007,9 @@ namespace DataHeatBalance { bool EMSUPSPowerOverrideOn = false; // EMS actuating UPS power if .TRUE. Real64 EMSUPSPower = 0.0; // Value EMS is directing to use for override of UPS power [W] Real64 SupplyApproachTemp = 0.0; // The difference of the IT inlet temperature from the AHU supply air temperature - int SupplyApproachTempSch = 0; // The difference schedule of the IT inlet temperature from the AHU supply air temperature + Sched::Schedule *supplyApproachTempSched = nullptr; // The difference schedule of the IT inlet temperature from the AHU supply air temperature Real64 ReturnApproachTemp = 0.0; // The difference of the unit outlet temperature from the well mixed zone temperature - int ReturnApproachTempSch = 0; // The difference schedule of the unit outlet temperature from the well mixed zone temperature + Sched::Schedule *returnApproachTempSched = nullptr; // The difference schedule of the unit outlet temperature from the well mixed zone temperature bool inControlledZone = false; // True if in a controlled zone // Report variables @@ -1045,7 +1045,7 @@ namespace DataHeatBalance { std::string Name; // BASEBOARD HEAT object name int ZonePtr = 0; int spaceIndex = 0; // Space index for this equipment instance - int SchedPtr = 0; + Sched::Schedule *sched = nullptr; Real64 CapatLowTemperature = 0.0; Real64 LowTemperature = 0.0; Real64 CapatHighTemperature = 0.0; @@ -1074,7 +1074,7 @@ namespace DataHeatBalance { std::string Name; int ZonePtr = 0; // Which zone infiltration is in int spaceIndex = 0; // Space index for this infiltration instance - int SchedPtr = 0; // Schedule for infiltration + Sched::Schedule *sched = nullptr; // Schedule for infiltration InfiltrationModelType ModelType = InfiltrationModelType::Invalid; // which model is used for infiltration // Design Flow Rate model terms Real64 DesignLevel = 0.0; @@ -1118,7 +1118,7 @@ namespace DataHeatBalance { std::string Name; int ZonePtr = 0; int spaceIndex = 0; // Space index for this ventilation instance - int SchedPtr = 0; + Sched::Schedule *sched = nullptr; VentilationModelType ModelType = VentilationModelType::Invalid; // which model is used for ventilation: DesignFlowRate and WindandStackOpenArea Real64 DesignLevel = 0.0; @@ -1139,11 +1139,11 @@ namespace DataHeatBalance { Real64 MinOutdoorTemperature = -100.0; Real64 MaxOutdoorTemperature = 100.0; Real64 MaxWindSpeed = 40.0; - int MinIndoorTempSchedPtr = 0; // Minimum indoor temperature schedule index - int MaxIndoorTempSchedPtr = 0; // Maximum indoor temperature schedule index - int DeltaTempSchedPtr = 0; // Delta temperature schedule index - int MinOutdoorTempSchedPtr = 0; // Minimum outdoor temperature schedule index - int MaxOutdoorTempSchedPtr = 0; // Maximum outdoor temperature schedule index + Sched::Schedule *minIndoorTempSched = nullptr; // Minimum indoor temperature schedule + Sched::Schedule *maxIndoorTempSched = nullptr; // Maximum indoor temperature schedule + Sched::Schedule *deltaTempSched = nullptr; // Delta temperature schedule + Sched::Schedule *minOutdoorTempSched = nullptr; // Minimum outdoor temperature schedule + Sched::Schedule *maxOutdoorTempSched = nullptr; // Maximum outdoor temperature schedule int IndoorTempErrCount = 0; // Indoor temperature error count int OutdoorTempErrCount = 0; // Outdoor temperature error count int IndoorTempErrIndex = 0; // Indoor temperature error Index @@ -1153,7 +1153,7 @@ namespace DataHeatBalance { bool HybridControlMasterStatus = false; // Hybrid ventilation control master object opening status // WindandStackOpenArea Real64 OpenArea = 0.0; // Opening area [m2] - int OpenAreaSchedPtr = 0; // Opening area fraction schedule pointer + Sched::Schedule *openAreaSched = nullptr; // Opening area fraction schedule Real64 OpenEff = 0.0; // Opening effectiveness [dimensionless] Real64 EffAngle = 0.0; // Effective angle [degree] Real64 DH = 0.0; // Height difference [m] @@ -1169,7 +1169,7 @@ namespace DataHeatBalance { int ZonePtr = 0; // Zone number AirBalance BalanceMethod = AirBalance::None; // Air Balance Method Real64 InducedAirRate = 0.0; // Induced Outdoor Air Due to Duct Leakage Unbalance [m3/s] - int InducedAirSchedPtr = 0; // Induced Outdoor Air Fraction Schedule + Sched::Schedule *inducedAirSched = nullptr; // Induced Outdoor Air Fraction Schedule Real64 BalMassFlowRate = 0.0; // balanced mass flow rate Real64 InfMassFlowRate = 0.0; // unbalanced mass flow rate from infiltration Real64 NatMassFlowRate = 0.0; // unbalanced mass flow rate from natural ventilation @@ -1188,7 +1188,7 @@ namespace DataHeatBalance { std::string Name; int ZonePtr = 0; int spaceIndex = 0; // Space index for this mixing instance - int SchedPtr = 0; + Sched::Schedule *sched = nullptr; Real64 DesignLevel = 0.0; int FromZone = 0; int fromSpaceIndex = 0; // Source space index for this mixing instance @@ -1196,13 +1196,13 @@ namespace DataHeatBalance { Real64 DesiredAirFlowRate = 0.0; Real64 DesiredAirFlowRateSaved = 0.0; Real64 MixingMassFlowRate = 0.0; - int DeltaTempSchedPtr = 0; // Delta temperature schedule index - int MinIndoorTempSchedPtr = 0; // Minimum indoor temperature schedule index - int MaxIndoorTempSchedPtr = 0; // Maximum indoor temperature schedule index - int MinSourceTempSchedPtr = 0; // Minimum source zone temperature schedule index - int MaxSourceTempSchedPtr = 0; // Maximum source zone temperature schedule index - int MinOutdoorTempSchedPtr = 0; // Minimum outdoor temperature schedule index - int MaxOutdoorTempSchedPtr = 0; // Maximum outdoor temperature schedule index + Sched::Schedule *deltaTempSched = nullptr; // Delta temperature schedule index + Sched::Schedule *minIndoorTempSched = nullptr; // Minimum indoor temperature schedule index + Sched::Schedule *maxIndoorTempSched = nullptr; // Maximum indoor temperature schedule index + Sched::Schedule *minSourceTempSched = nullptr; // Minimum source zone temperature schedule index + Sched::Schedule *maxSourceTempSched = nullptr; // Maximum source zone temperature schedule index + Sched::Schedule *minOutdoorTempSched = nullptr; // Minimum outdoor temperature schedule index + Sched::Schedule *maxOutdoorTempSched = nullptr; // Maximum outdoor temperature schedule index int IndoorTempErrCount = 0; // Indoor temperature error count int SourceTempErrCount = 0; // Source zone temperature error count int OutdoorTempErrCount = 0; // Outdoor temperature error count @@ -1219,7 +1219,7 @@ namespace DataHeatBalance { Array1D_bool EMSRefDoorMixingOn; Array1D EMSRefDoorFlowRate; Array1D VolRefDoorFlowRate; - Array1D_int OpenSchedPtr; // Schedule for Refrigeration door open fraction + Array1D openScheds; // Schedule for Refrigeration door open fraction Array1D DoorHeight; // Door height for refrigeration door, m Array1D DoorArea; // Door area for refrigeration door, m2 Array1D Protection; // Refrigeration door protection factor, dimensionless @@ -1234,7 +1234,7 @@ namespace DataHeatBalance { { int space1; // Air boundary simple mixing space 1 int space2; // Air boundary simple mixing space 2 - int scheduleIndex; // Air boundary simple mixing schedule index + Sched::Schedule *sched = nullptr; // Air boundary simple mixing schedule index Real64 mixingVolumeFlowRate; // Air boundary simple mixing volume flow rate [m3/s] }; @@ -2005,6 +2005,10 @@ struct HeatBalanceData : BaseGlobalStruct EPVector spaceTypes; EPVector ExtVentedCavity; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/DataIPShortCuts.hh b/src/EnergyPlus/DataIPShortCuts.hh index 9ed7b0dcfd5..d7ed651c680 100644 --- a/src/EnergyPlus/DataIPShortCuts.hh +++ b/src/EnergyPlus/DataIPShortCuts.hh @@ -67,6 +67,10 @@ struct IPShortCutsData : BaseGlobalStruct Array1D rNumericArgs; std::string cCurrentModuleObject; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/DataLoopNode.hh b/src/EnergyPlus/DataLoopNode.hh index 6d409b27070..c65acef363a 100644 --- a/src/EnergyPlus/DataLoopNode.hh +++ b/src/EnergyPlus/DataLoopNode.hh @@ -57,6 +57,7 @@ #include #include #include +#include namespace EnergyPlus { @@ -463,10 +464,10 @@ namespace DataLoopNode { // Following are for Outdoor Air Nodes Scheduled Properties bool IsLocalNode = false; - int OutAirDryBulbSchedNum = 0; - int OutAirWetBulbSchedNum = 0; - int OutAirWindSpeedSchedNum = 0; - int OutAirWindDirSchedNum = 0; + Sched::Schedule *outAirDryBulbSched = nullptr; + Sched::Schedule *outAirWetBulbSched = nullptr; + Sched::Schedule *outAirWindSpeedSched = nullptr; + Sched::Schedule *outAirWindDirSched = nullptr; // Following are for Outdoor Air Nodes "read only" Real64 OutAirDryBulb = 0.0; // {C} @@ -538,6 +539,10 @@ struct LoopNodeData : BaseGlobalStruct Array1D MarkedNode; Array1D NodeSetpointCheck; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/DataMoistureBalance.hh b/src/EnergyPlus/DataMoistureBalance.hh index da72293b4fd..eca0899b205 100644 --- a/src/EnergyPlus/DataMoistureBalance.hh +++ b/src/EnergyPlus/DataMoistureBalance.hh @@ -92,6 +92,10 @@ struct MoistureBalanceData : BaseGlobalStruct Array1D HGrndFD; // Ground Convection Coefficient Array1D HAirFD; // Air Convection Coefficient + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/DataMoistureBalanceEMPD.hh b/src/EnergyPlus/DataMoistureBalanceEMPD.hh index 66411f76f34..22d3b641f9c 100644 --- a/src/EnergyPlus/DataMoistureBalanceEMPD.hh +++ b/src/EnergyPlus/DataMoistureBalanceEMPD.hh @@ -76,6 +76,10 @@ struct MoistureBalanceEMPDData : BaseGlobalStruct Array1D RVDeepLayer; Array1D RVwall; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/DataOutputs.hh b/src/EnergyPlus/DataOutputs.hh index 73e9e96f9f4..4fd256d82cb 100644 --- a/src/EnergyPlus/DataOutputs.hh +++ b/src/EnergyPlus/DataOutputs.hh @@ -112,6 +112,10 @@ struct OutputsData : BaseGlobalStruct Util::case_insensitive_comparator> OutputVariablesForSimulation; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/DataPhotovoltaics.hh b/src/EnergyPlus/DataPhotovoltaics.hh index df0f72c0488..33dfab21d07 100644 --- a/src/EnergyPlus/DataPhotovoltaics.hh +++ b/src/EnergyPlus/DataPhotovoltaics.hh @@ -106,11 +106,11 @@ namespace DataPhotovoltaics { Real64 AreaCol; // effective area of solar collection Real64 ActiveFraction; // fraction of parent surface that has active solar cells Efficiency EfficencyInputMode; // to schedule or not - int EffSchedPtr; // index pointer for efficiency schedule + Sched::Schedule *effSched = nullptr; // index pointer for efficiency schedule Real64 PVEfficiency; // fixed or current PV efficiency // Default Constructor - SimplePVParamsStruct() : AreaCol(0.0), ActiveFraction(0.0), EfficencyInputMode(Efficiency::Invalid), EffSchedPtr(0), PVEfficiency(0.0) + SimplePVParamsStruct() : AreaCol(0.0), ActiveFraction(0.0), EfficencyInputMode(Efficiency::Invalid), PVEfficiency(0.0) { } }; @@ -350,6 +350,10 @@ struct PhotovoltaicsData : BaseGlobalStruct Real64 ShuntResistance = 0.0; // old "RSH" in common block of trnsys code Array1D PVarray; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/DataReportingFlags.hh b/src/EnergyPlus/DataReportingFlags.hh index 2b6b0342ab5..cfaa61d697d 100644 --- a/src/EnergyPlus/DataReportingFlags.hh +++ b/src/EnergyPlus/DataReportingFlags.hh @@ -70,6 +70,10 @@ struct ReportFlagData : BaseGlobalStruct bool DebugOutput = false; bool EvenDuringWarmup = false; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/DataRoomAirModel.hh b/src/EnergyPlus/DataRoomAirModel.hh index 65d9819f34a..0f761892235 100644 --- a/src/EnergyPlus/DataRoomAirModel.hh +++ b/src/EnergyPlus/DataRoomAirModel.hh @@ -195,8 +195,7 @@ namespace RoomAir { // Members std::string ZoneName = ""; // Name of zone int ZonePtr = 0; // Pointer to the zone number for this statement - int SchedGainsPtr = -1; // Schedule for internal gain fraction to occupied zone - std::string SchedGainsName = ""; // Gains Schedule name + Sched::Schedule *gainsSched = nullptr; // Schedule for internal gain fraction to occupied zone Real64 NumPlumesPerOcc = 0.0; // Effective number of plumes per occupant Real64 ThermostatHeight = 0.0; // Height of thermostat/ temperature control sensor Real64 ComfortHeight = 0.0; // Height at which air temperature is measured for comfort purposes @@ -208,8 +207,7 @@ namespace RoomAir { // Members std::string ZoneName = ""; // Name of zone int ZonePtr = 0; // Pointer to the zone number for this statement - int SchedGainsPtr = 0; // Schedule for internal gain fraction to occupied zone - std::string SchedGainsName = ""; // Gains Schedule name + Sched::Schedule *gainsSched = nullptr; // Schedule for internal gain fraction to occupied zone Comfort VforComfort = Comfort::Invalid; // Use Recirculation or Jet velocity and temperatures // for comfort models }; @@ -345,10 +343,8 @@ namespace RoomAir { std::string Name = ""; // Name std::string ZoneName = ""; // Zone name in building int ZoneID = 0; // Index of Zone in Heat Balance - std::string AvailSched = ""; // Name of availability schedule - int AvailSchedID = 0; // index of availability schedule - std::string PatternCntrlSched = ""; // name of schedule that selects pattern - int PatternSchedID = 0; // index of pattern selecting schedule + Sched::Schedule *availSched = nullptr; // availability schedule + Sched::Schedule *patternSched = nullptr; // pattern selecting schedule // calculated and from elsewhere Real64 ZoneHeight = 0.0; // in meters, from Zone%CeilingHeight int ZoneNodeID = 0; // index in Node array for this zone @@ -482,8 +478,7 @@ namespace RoomAir { std::string ZoneName = ""; // Zone name in building int ZoneID = 0; // Index of Zone in Heat Balance int ActualZoneID = 0; // Index of controlled zones in ZoneCOnfigure - std::string AvailSched = ""; // Name of availability schedule - int AvailSchedID = 0; // index of availability schedule + Sched::Schedule *availSched = nullptr; // index of availability schedule int ControlAirNodeID = 0; // index of roomair node that is HVAC control sensor location int NumOfAirNodes = 0; // Number of air nodes Array1D Node; // Node struct @@ -650,6 +645,10 @@ struct RoomAirModelData : BaseGlobalStruct EPVector AirPatternZoneInfo; // added zone information for user defined patterns EPVector AFNZoneInfo; // added zone info + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/DataRuntimeLanguage.hh b/src/EnergyPlus/DataRuntimeLanguage.hh index 85a0424dad6..96b320081b2 100644 --- a/src/EnergyPlus/DataRuntimeLanguage.hh +++ b/src/EnergyPlus/DataRuntimeLanguage.hh @@ -62,6 +62,7 @@ #include #include #include +#include namespace EnergyPlus { @@ -249,11 +250,11 @@ namespace DataRuntimeLanguage { OutputProcessor::VariableType VariableType; int Index; // ref index in output processor, points to variable int VariableNum; // ref to global variable in runtime language - int SchedNum; // ref index ptr to schedule service (filled if Schedule Value) + Sched::Schedule *sched = nullptr; // ref index ptr to schedule service (filled if Schedule Value) // INTEGER :: VarType = 0 // Default Constructor - OutputVarSensorType() : CheckedOkay(false), VariableType(OutputProcessor::VariableType::Invalid), Index(0), VariableNum(0), SchedNum(0) + OutputVarSensorType() : CheckedOkay(false), VariableType(OutputProcessor::VariableType::Invalid), Index(0), VariableNum(0) { } }; @@ -809,6 +810,10 @@ struct RuntimeLanguageData : BaseGlobalStruct std::unordered_set, DataRuntimeLanguage::EMSActuatorKey_hash> EMSActuator_lookup; // Fast duplicate lookup structure + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/DataShadowingCombinations.hh b/src/EnergyPlus/DataShadowingCombinations.hh index 561db8470d5..55eed10cff6 100644 --- a/src/EnergyPlus/DataShadowingCombinations.hh +++ b/src/EnergyPlus/DataShadowingCombinations.hh @@ -83,6 +83,10 @@ struct ShadowCombData : BaseGlobalStruct Array1D ShadowComb; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/DataSizing.cc b/src/EnergyPlus/DataSizing.cc index 66f30fcabfc..c98c6b8bc32 100644 --- a/src/EnergyPlus/DataSizing.cc +++ b/src/EnergyPlus/DataSizing.cc @@ -602,9 +602,9 @@ Real64 ZoneAirDistributionData::calculateEz(EnergyPlusData &state, int const Zon // Calc the zone supplied OA flow rate counting the zone air distribution effectiveness // First check whether the zone air distribution effectiveness schedule exists, if yes uses it; // otherwise uses the inputs of zone distribution effectiveness in cooling mode or heating mode - if (this->ZoneADEffSchPtr > 0) { + if (this->zoneADEffSched != nullptr) { // Get schedule value for the zone air distribution effectiveness - zoneEz = ScheduleManager::GetCurrentScheduleValue(state, this->ZoneADEffSchPtr); + zoneEz = this->zoneADEffSched->getCurrentVal(); } else { Real64 zoneLoad = state.dataZoneEnergyDemand->ZoneSysEnergyDemand(ZoneNum).TotalOutputRequired; @@ -901,23 +901,23 @@ Real64 OARequirementsData::calcOAFlowRate(EnergyPlusData &state, if (state.dataHeatBal->People(PeopleNum).ZonePtr != ActualZoneNum) continue; } CO2PeopleGeneration += state.dataHeatBal->People(PeopleNum).NumberOfPeople * state.dataHeatBal->People(PeopleNum).CO2RateFactor * - ScheduleManager::GetCurrentScheduleValue(state, state.dataHeatBal->People(PeopleNum).ActivityLevelPtr); + state.dataHeatBal->People(PeopleNum).activityLevelSched->getCurrentVal(); } } } ZoneOAArea = floorArea * thisZone.Multiplier * thisZone.ListMultiplier * this->OAFlowPerArea; ZoneOAMin = ZoneOAArea; ZoneOAMax = (ZoneOAArea + ZoneOAPeople); - if (thisZone.ZoneContamControllerSchedIndex > 0.0) { + if (thisZone.zoneContamControllerSched != nullptr ) { // Check the availability schedule value for ZoneControl:ContaminantController - ZoneContamControllerSched = ScheduleManager::GetCurrentScheduleValue(state, thisZone.ZoneContamControllerSchedIndex); + ZoneContamControllerSched = thisZone.zoneContamControllerSched->getCurrentVal(); if (ZoneContamControllerSched > 0.0) { if (ZoneOAPeople > 0.0) { if (state.dataContaminantBalance->ZoneCO2GainFromPeople(ActualZoneNum) > 0.0) { - if (thisZone.ZoneMinCO2SchedIndex > 0.0) { + if (thisZone.zoneMinCO2Sched != nullptr) { // Take the schedule value of "Minimum Carbon Dioxide Concentration Schedule Name" // in the ZoneControl:ContaminantController - ZoneMinCO2 = ScheduleManager::GetCurrentScheduleValue(state, thisZone.ZoneMinCO2SchedIndex); + ZoneMinCO2 = thisZone.zoneMinCO2Sched->getCurrentVal(); } else { ZoneMinCO2 = state.dataContaminantBalance->OutdoorCO2; } @@ -1075,11 +1075,11 @@ Real64 OARequirementsData::calcOAFlowRate(EnergyPlusData &state, OAVolumeFlowRate *= thisZone.Multiplier * thisZone.ListMultiplier; // Apply schedule as needed. Sizing does not use schedule. - if (this->OAFlowFracSchPtr > 0 && UseMinOASchFlag) { + if (this->oaFlowFracSched != nullptr && UseMinOASchFlag) { if (MaxOAVolFlowFlag) { - OAVolumeFlowRate *= ScheduleManager::GetScheduleMaxValue(state, this->OAFlowFracSchPtr); + OAVolumeFlowRate *= this->oaFlowFracSched->getMaxVal(state); } else { - OAVolumeFlowRate *= ScheduleManager::GetCurrentScheduleValue(state, this->OAFlowFracSchPtr); + OAVolumeFlowRate *= this->oaFlowFracSched->getCurrentVal(); } } diff --git a/src/EnergyPlus/DataSizing.hh b/src/EnergyPlus/DataSizing.hh index ef4f8e2e07f..f3082f3f78c 100644 --- a/src/EnergyPlus/DataSizing.hh +++ b/src/EnergyPlus/DataSizing.hh @@ -363,8 +363,8 @@ namespace DataSizing { Real64 HeatDesHumRatDiff = 0.005; // zone design heating supply air humidity ratio temperature difference [deltakgw/kga] int ZnLatCoolDgnSAMethod = 0; // choice of how to get zone latent cooling design air humidity ratio; int ZnLatHeatDgnSAMethod = 0; // choice of how to get zone latent heating design air humidity ratio; - int zoneRHDehumidifySchIndex = 0; // index to zone RH dehumidifying schedule used for zone sizing - int zoneRHHumidifySchIndex = 0; // index to zone RH humidifying schedule used for zone sizing + Sched::Schedule *zoneRHDehumidifySched = nullptr; // zone RH dehumidifying schedule used for zone sizing + Sched::Schedule *zoneRHHumidifySched = nullptr; // zone RH humidifying schedule used for zone sizing ZoneSizing zoneSizingMethod = ZoneSizing::Invalid; // load to sizing on: sensible, latent, sensibleandlatent, sensibleonlynolatent }; @@ -609,9 +609,9 @@ namespace DataSizing { Array1D LatentHeatFlowSeq; // daily sequence of zone latent heating supply mass flow rate (zone time step) [Kg/s] bool zoneLatentSizing = false; // trigger to do RH control during zone sizing Real64 zoneRHDehumidifySetPoint = 50.0; // RH dehumidifying set point used during sizing, default to 50% - int zoneRHDehumidifySchIndex = 0; // index to zone RH dehumidifying schedule used for zone sizing + Sched::Schedule *zoneRHDehumidifySched = nullptr; // zone RH dehumidifying schedule used for zone sizing Real64 zoneRHHumidifySetPoint = 50.0; // RH humidifying set point used during sizing, default to 50% - int zoneRHHumidifySchIndex = 0; // index to zone RH humidifying schedule used for zone sizing + Sched::Schedule *zoneRHHumidifySched = nullptr; // zone RH humidifying schedule used for zone sizing Real64 LatentCoolDesHumRat = 0.0; // zone design dehumidification supply air humidity ratio [kgw/kga] Real64 CoolDesHumRatDiff = 0.005; // zone design cooling supply air humidity ratio difference [deltakgw/kga] Real64 LatentHeatDesHumRat = 0.0; // zone design humidification supply air humidity ratio [kgw/kga] @@ -1120,9 +1120,8 @@ namespace DataSizing { Real64 OAFlowPerArea = 0.0; // - OA requirement per zone area Real64 OAFlowPerZone = 0.0; // - OA requirement per zone Real64 OAFlowACH = 0.0; // - OA requirement per zone per hour - int OAFlowFracSchPtr = ScheduleManager::ScheduleAlwaysOn; // - Fraction schedule applied to total OA requirement - int OAPropCtlMinRateSchPtr = - ScheduleManager::ScheduleAlwaysOn; // - Fraction schedule applied to Proportional Control Minimum Outdoor Air Flow Rate + Sched::Schedule *oaFlowFracSched = nullptr; // - Fraction schedule applied to total OA requirement + Sched::Schedule *oaPropCtlMinRateSched = nullptr; // - Fraction schedule applied to Proportional Control Minimum Outdoor Air Flow Rate int CO2MaxMinLimitErrorCount = 0; // Counter when max CO2 concentration < min CO2 concentration for SOAM_ProportionalControlSchOcc int CO2MaxMinLimitErrorIndex = 0; // Index for max CO2 concentration < min CO2 concentration recurring error message for // SOAM_ProportionalControlSchOcc @@ -1156,12 +1155,12 @@ namespace DataSizing { Real64 ZoneADEffCooling; // - Zone air distribution effectiveness in cooling mode Real64 ZoneADEffHeating; // - Zone air distribution effectiveness in heating mode Real64 ZoneSecondaryRecirculation; // - Zone air secondary recirculation ratio - int ZoneADEffSchPtr; // - Zone air distribution effectiveness schedule index + Sched::Schedule *zoneADEffSched = nullptr; // - Zone air distribution effectiveness schedule index Real64 ZoneVentilationEff; // Zone ventilation effectiveness // Default Constructor ZoneAirDistributionData() - : ZoneADEffCooling(1.0), ZoneADEffHeating(1.0), ZoneSecondaryRecirculation(0.0), ZoneADEffSchPtr(0), ZoneVentilationEff(0.0) + : ZoneADEffCooling(1.0), ZoneADEffHeating(1.0), ZoneSecondaryRecirculation(0.0), ZoneVentilationEff(0.0) { } @@ -1375,6 +1374,10 @@ struct SizingData : BaseGlobalStruct Array1D FaByZoneCool; // triggers allocation in UpdateSysSizing Array1D SensCoolCapTemp; // triggers allocation in UpdateSysSizing + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/DataStringGlobals.hh b/src/EnergyPlus/DataStringGlobals.hh index a68e147b905..d39492ece1d 100644 --- a/src/EnergyPlus/DataStringGlobals.hh +++ b/src/EnergyPlus/DataStringGlobals.hh @@ -129,6 +129,10 @@ struct DataStringGlobalsData : BaseGlobalStruct std::string CurrentDateTime; // For printing current date and time at start of run std::string VerStringVar; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/DataSurfaceColors.hh b/src/EnergyPlus/DataSurfaceColors.hh index 51a631c0bf5..1f9f1a36876 100644 --- a/src/EnergyPlus/DataSurfaceColors.hh +++ b/src/EnergyPlus/DataSurfaceColors.hh @@ -99,6 +99,10 @@ struct SurfaceColorData : BaseGlobalStruct { std::array DXFcolorno = DataSurfaceColors::defaultcolorno; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/DataSurfaceLists.hh b/src/EnergyPlus/DataSurfaceLists.hh index dcbfc916878..b38b184746b 100644 --- a/src/EnergyPlus/DataSurfaceLists.hh +++ b/src/EnergyPlus/DataSurfaceLists.hh @@ -117,6 +117,10 @@ struct SurfaceListsData : BaseGlobalStruct Array1D SurfList; Array1D SlabList; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/DataSurfaces.cc b/src/EnergyPlus/DataSurfaces.cc index 77d09bf2bd7..26300827853 100644 --- a/src/EnergyPlus/DataSurfaces.cc +++ b/src/EnergyPlus/DataSurfaces.cc @@ -514,6 +514,8 @@ Real64 SurfaceData::get_average_height(EnergyPlusData &state) const void SurfaceData::make_hash_key(EnergyPlusData &state, const int SurfNum) { + auto &s_surf = state.dataSurface; + calcHashKey = SurfaceCalcHashKey(); calcHashKey.Construction = Construction; calcHashKey.Azimuth = round(Azimuth * 10.0) / 10.0; @@ -521,12 +523,12 @@ void SurfaceData::make_hash_key(EnergyPlusData &state, const int SurfNum) calcHashKey.Height = round(Height * 10.0) / 10.0; calcHashKey.Zone = Zone; calcHashKey.EnclIndex = SolarEnclIndex; - calcHashKey.TAirRef = state.dataSurface->SurfTAirRef(SurfNum); + calcHashKey.TAirRef = s_surf->SurfTAirRef(SurfNum); - int extBoundCond = state.dataSurface->Surface(SurfNum).ExtBoundCond; + int extBoundCond = s_surf->Surface(SurfNum).ExtBoundCond; if (extBoundCond > 0) { - calcHashKey.ExtZone = state.dataSurface->Surface(extBoundCond).Zone; - calcHashKey.ExtEnclIndex = state.dataSurface->Surface(extBoundCond).SolarEnclIndex; + calcHashKey.ExtZone = s_surf->Surface(extBoundCond).Zone; + calcHashKey.ExtEnclIndex = s_surf->Surface(extBoundCond).SolarEnclIndex; calcHashKey.ExtCond = 1; } else { calcHashKey.ExtZone = 0; @@ -540,26 +542,26 @@ void SurfaceData::make_hash_key(EnergyPlusData &state, const int SurfNum) calcHashKey.ViewFactorSky = round(ViewFactorSky * 10.0) / 10.0; calcHashKey.HeatTransferAlgorithm = HeatTransferAlgorithm; - calcHashKey.intConvModel = state.dataSurface->surfIntConv(SurfNum).model; - calcHashKey.extConvModel = state.dataSurface->surfExtConv(SurfNum).model; - calcHashKey.intConvUserModelNum = state.dataSurface->surfIntConv(SurfNum).userModelNum; - calcHashKey.extConvUserModelNum = state.dataSurface->surfExtConv(SurfNum).userModelNum; + calcHashKey.intConvModel = s_surf->surfIntConv(SurfNum).model; + calcHashKey.extConvModel = s_surf->surfExtConv(SurfNum).model; + calcHashKey.intConvUserModelNum = s_surf->surfIntConv(SurfNum).userModelNum; + calcHashKey.extConvUserModelNum = s_surf->surfExtConv(SurfNum).userModelNum; calcHashKey.OSCPtr = OSCPtr; calcHashKey.OSCMPtr = OSCMPtr; calcHashKey.FrameDivider = FrameDivider; - calcHashKey.SurfWinStormWinConstr = state.dataSurface->SurfWinStormWinConstr(SurfNum); - - calcHashKey.MaterialMovInsulExt = state.dataSurface->SurfMaterialMovInsulExt(SurfNum); - calcHashKey.MaterialMovInsulInt = state.dataSurface->SurfMaterialMovInsulInt(SurfNum); - calcHashKey.SchedMovInsulExt = state.dataSurface->SurfSchedMovInsulExt(SurfNum); - calcHashKey.SchedMovInsulInt = state.dataSurface->SurfSchedMovInsulInt(SurfNum); - calcHashKey.ExternalShadingSchInd = state.dataSurface->Surface(SurfNum).SurfExternalShadingSchInd; - calcHashKey.SurroundingSurfacesNum = state.dataSurface->Surface(SurfNum).SurfSurroundingSurfacesNum; - calcHashKey.LinkedOutAirNode = state.dataSurface->Surface(SurfNum).SurfLinkedOutAirNode; - calcHashKey.OutsideHeatSourceTermSchedule = OutsideHeatSourceTermSchedule; - calcHashKey.InsideHeatSourceTermSchedule = InsideHeatSourceTermSchedule; - calcHashKey.ViewFactorSrdSurfs = state.dataSurface->Surface(SurfNum).ViewFactorSrdSurfs; + calcHashKey.SurfWinStormWinConstr = s_surf->SurfWinStormWinConstr(SurfNum); + + calcHashKey.MaterialMovInsulExt = s_surf->SurfMaterialMovInsulExt(SurfNum); + calcHashKey.MaterialMovInsulInt = s_surf->SurfMaterialMovInsulInt(SurfNum); + calcHashKey.movInsulExtSchedNum = (s_surf->SurfMovInsulExtScheds(SurfNum) != nullptr) ? s_surf->SurfMovInsulExtScheds(SurfNum)->Num : -1; + calcHashKey.movInsulIntSchedNum = (s_surf->SurfMovInsulIntScheds(SurfNum) != nullptr) ? s_surf->SurfMovInsulIntScheds(SurfNum)->Num : -1; + calcHashKey.externalShadingSchedNum = (s_surf->Surface(SurfNum).surfExternalShadingSched != nullptr) ? s_surf->Surface(SurfNum).surfExternalShadingSched->Num : -1; + calcHashKey.SurroundingSurfacesNum = s_surf->Surface(SurfNum).SurfSurroundingSurfacesNum; + calcHashKey.LinkedOutAirNode = s_surf->Surface(SurfNum).SurfLinkedOutAirNode; + calcHashKey.outsideHeatSourceTermSchedNum = (outsideHeatSourceTermSched != nullptr) ? outsideHeatSourceTermSched->Num : -1; + calcHashKey.insideHeatSourceTermSchedNum = (insideHeatSourceTermSched != nullptr) ? insideHeatSourceTermSched->Num : -1; + calcHashKey.ViewFactorSrdSurfs = s_surf->Surface(SurfNum).ViewFactorSrdSurfs; } void SurfaceData::set_representative_surface(EnergyPlusData &state, const int SurfNum) diff --git a/src/EnergyPlus/DataSurfaces.hh b/src/EnergyPlus/DataSurfaces.hh index c1c96b5beb2..87736d6c484 100644 --- a/src/EnergyPlus/DataSurfaces.hh +++ b/src/EnergyPlus/DataSurfaces.hh @@ -67,6 +67,7 @@ #include #include #include +#include #include namespace EnergyPlus { @@ -589,13 +590,13 @@ namespace DataSurfaces { // SolarIncidentInside // Not supported int MaterialMovInsulExt = 0; // Pointer to the material used for exterior movable insulation int MaterialMovInsulInt = 0; // Pointer to the material used for interior movable insulation - int SchedMovInsulExt = 0; // Schedule for exterior movable insulation - int SchedMovInsulInt = 0; // Schedule for interior movable insulation - int ExternalShadingSchInd = 0; // Schedule for a the external shading + int movInsulExtSchedNum = Sched::SchedNum_Invalid; // Schedule for exterior movable insulation + int movInsulIntSchedNum = Sched::SchedNum_Invalid; // Schedule for interior movable insulation + int externalShadingSchedNum = Sched::SchedNum_Invalid; // Schedule for a the external shading int SurroundingSurfacesNum = 0; // Index of a surrounding surfaces list (defined in SurfaceProperties::SurroundingSurfaces) int LinkedOutAirNode = 0; // Index of the an OutdoorAir:Node - int OutsideHeatSourceTermSchedule = 0; // Pointer to the schedule of additional source of heat flux rate applied to the outside surface - int InsideHeatSourceTermSchedule = 0; // Pointer to the schedule of additional source of heat flux rate applied to the inside surface + int outsideHeatSourceTermSchedNum = Sched::SchedNum_Invalid; // schedule of additional source of heat flux rate applied to the outside surface + int insideHeatSourceTermSchedNum = Sched::SchedNum_Invalid; // schedule of additional source of heat flux rate applied to the inside surface // based on boost::hash_combine std::size_t hash_combine(std::size_t current_hash, std::size_t new_hash) const @@ -636,13 +637,13 @@ namespace DataSurfaces { hash()(MaterialMovInsulExt), hash()(MaterialMovInsulInt), - hash()(SchedMovInsulExt), - hash()(SchedMovInsulInt), - hash()(ExternalShadingSchInd), + hash()(movInsulExtSchedNum), + hash()(movInsulIntSchedNum), + hash()(externalShadingSchedNum), hash()(SurroundingSurfacesNum), hash()(LinkedOutAirNode), - hash()(OutsideHeatSourceTermSchedule), - hash()(InsideHeatSourceTermSchedule)}; + hash()(outsideHeatSourceTermSchedNum), + hash()(insideHeatSourceTermSchedNum)}; } std::size_t get_hash() const @@ -669,10 +670,10 @@ namespace DataSurfaces { FrameDivider == other.FrameDivider && SurfWinStormWinConstr == other.SurfWinStormWinConstr && MaterialMovInsulExt == other.MaterialMovInsulExt && MaterialMovInsulInt == other.MaterialMovInsulInt && - SchedMovInsulExt == other.SchedMovInsulExt && SchedMovInsulInt == other.SchedMovInsulInt && - ExternalShadingSchInd == other.ExternalShadingSchInd && SurroundingSurfacesNum == other.SurroundingSurfacesNum && - LinkedOutAirNode == other.LinkedOutAirNode && OutsideHeatSourceTermSchedule == other.OutsideHeatSourceTermSchedule && - InsideHeatSourceTermSchedule == other.InsideHeatSourceTermSchedule); + movInsulExtSchedNum == other.movInsulExtSchedNum && movInsulIntSchedNum == other.movInsulIntSchedNum && + externalShadingSchedNum == other.externalShadingSchedNum && SurroundingSurfacesNum == other.SurroundingSurfacesNum && + LinkedOutAirNode == other.LinkedOutAirNode && outsideHeatSourceTermSchedNum == other.outsideHeatSourceTermSchedNum && + insideHeatSourceTermSchedNum == other.insideHeatSourceTermSchedNum); } }; @@ -749,8 +750,8 @@ namespace DataSurfaces { // Boundary conditions and interconnections bool HeatTransSurf; // True if surface is a heat transfer surface (light shelf can also be IsShadowing) - int OutsideHeatSourceTermSchedule; // Pointer to the schedule of additional source of heat flux rate applied to the outside surface - int InsideHeatSourceTermSchedule; // Pointer to the schedule of additional source of heat flux rate applied to the inside surface + Sched::Schedule *outsideHeatSourceTermSched = nullptr; // Schedule of additional source of heat flux rate applied to the outside surface + Sched::Schedule *insideHeatSourceTermSched = nullptr; // Schedule of additional source of heat flux rate applied to the inside surface // False if a (detached) shadowing (sub)surface HeatTransferModel HeatTransferAlgorithm; // used for surface-specific heat transfer algorithm. std::string BaseSurfName; // Name of BaseSurf @@ -786,7 +787,7 @@ namespace DataSurfaces { bool IsShadowPossibleObstruction; // True if a surface can be an exterior obstruction // Optional parameters specific to shadowing surfaces and subsurfaces (detached shading, overhangs, wings, etc.) - int SchedShadowSurfIndex; // Schedule for a shadowing (sub)surface + Sched::Schedule *shadowSurfSched = nullptr; // Schedule for a shadowing (sub)surface bool IsTransparent; // True if the schedule values are always 1.0 (or the minimum is 1.0) Real64 SchedMinValue; // Schedule minimum value. @@ -820,7 +821,7 @@ namespace DataSurfaces { bool SurfHasSurroundingSurfProperty; // true if surrounding surfaces properties are listed for an external surface bool SurfSchedExternalShadingFrac; // true if the external shading is scheduled or calculated externally to be imported int SurfSurroundingSurfacesNum; // Index of a surrounding surfaces list (defined in SurfaceProperties::SurroundingSurfaces) - int SurfExternalShadingSchInd; // Schedule for a the external shading + Sched::Schedule *surfExternalShadingSched = nullptr; // Schedule for a the external shading int SurfLinkedOutAirNode; // Index of the an OutdoorAir:Node, zero if none Real64 AE = 0.0; // Product of area and emissivity for each surface Real64 enclAESum = 0.0; // Sum of area times emissivity for all other surfaces in enclosure @@ -834,15 +835,15 @@ namespace DataSurfaces { Width(0.0), shapeCat(ShapeCat::Invalid), plane(0.0, 0.0, 0.0, 0.0), Centroid(0.0, 0.0, 0.0), lcsx(0.0, 0.0, 0.0), lcsy(0.0, 0.0, 0.0), lcsz(0.0, 0.0, 0.0), NewellAreaVector(0.0, 0.0, 0.0), NewellSurfaceNormalVector(0.0, 0.0, 0.0), OutNormVec(0.0, 0.0, 0.0), SinAzim(0.0), CosAzim(0.0), SinTilt(0.0), CosTilt(0.0), IsConvex(true), IsDegenerate(false), VerticesProcessed(false), XShift(0.0), YShift(0.0), - HeatTransSurf(false), OutsideHeatSourceTermSchedule(0), InsideHeatSourceTermSchedule(0), + HeatTransSurf(false), HeatTransferAlgorithm(HeatTransferModel::Invalid), BaseSurf(0), NumSubSurfaces(0), Zone(0), spaceNum(0), ExtBoundCond(0), ExtSolar(false), ExtWind(false), hasIncSolMultiplier(false), IncSolMultiplier(1.0), ViewFactorGround(0.0), ViewFactorSky(0.0), ViewFactorGroundIR(0.0), ViewFactorSkyIR(0.0), OSCPtr(0), OSCMPtr(0), MirroredSurf(false), IsShadowing(false), - IsShadowPossibleObstruction(false), SchedShadowSurfIndex(0), IsTransparent(false), SchedMinValue(0.0), activeWindowShadingControl(0), + IsShadowPossibleObstruction(false), IsTransparent(false), SchedMinValue(0.0), activeWindowShadingControl(0), HasShadeControl(false), activeShadedConstruction(0), activeShadedConstructionPrev(0), FrameDivider(0), Multiplier(1.0), SolarEnclIndex(0), SolarEnclSurfIndex(0), IsAirBoundarySurf(false), IsSurfPropertyGndSurfacesDefined(false), SurfPropertyGndSurfIndex(0), UseSurfPropertyGndSurfTemp(false), UseSurfPropertyGndSurfRefl(false), GndReflSolarRad(0.0), - SurfHasSurroundingSurfProperty(false), SurfSchedExternalShadingFrac(false), SurfSurroundingSurfacesNum(0), SurfExternalShadingSchInd(0), + SurfHasSurroundingSurfProperty(false), SurfSchedExternalShadingFrac(false), SurfSurroundingSurfacesNum(0), SurfLinkedOutAirNode(0), SrdSurfTemp(0.0), ViewFactorSrdSurfs(0.0) { } @@ -913,10 +914,10 @@ namespace DataSurfaces { // Multiplier on sunlit fraction due to shadowing of glass by // frame and divider outside projections - std::array OutProjSLFracMult = {1.0}; + std::array OutProjSLFracMult = {1.0}; // Multiplier on sunlit fraction due to shadowing of glass by // frame and divider inside and outside projections - std::array InOutProjSLFracMult = {1.0}; + std::array InOutProjSLFracMult = {1.0}; // for shadowing of ground by building and obstructions [W/m2] // Enclosure inside surface area minus this surface and its @@ -1159,7 +1160,7 @@ namespace DataSurfaces { // OnNight/OnDayIfCoolingAndHighSolarOnWindow: shading on at night; shading on daytime if // solar on window > setpoint (W/m2 of window) and // prev. time step cooling rate > 0 - int Schedule{0}; // Pointer to schedule of 0 and 1 values: 0 => window is not shaded; + Sched::Schedule *sched = nullptr; // schedule of 0 and 1 values: 0 => window is not shaded; // 1 => window is shaded if Type=Schedule or Type = ScheduleAnd... // and setpoint is exceeded. Real64 SetPoint{0.0}; // Control setpoint (dimension depends on Trigger: @@ -1172,7 +1173,7 @@ namespace DataSurfaces { // Dimension is deg C or W/m2. bool ShadingControlIsScheduled{false}; // True if shading control has a schedule bool GlareControlIsActive{false}; // True if shading control to reduce daylight glare is active - int SlatAngleSchedule{0}; // Pointer to schedule of slat angle values between 0.0 and 180.0 degrees + Sched::Schedule *slatAngleSched = nullptr; // schedule of slat angle values between 0.0 and 180.0 degrees SlatAngleControl slatAngleControl{ SlatAngleControl::Invalid}; // Takes one of the following values that specifies // CHARACTER(len=32) :: slatAngleControlForBlinds = ' ' ! Takes one of the following values that specifies @@ -1206,7 +1207,7 @@ namespace DataSurfaces { Real64 WindSpeedCoef; // Coefficient modifying the wind speed term (s/m) Real64 ZoneAirTempCoef; // Coefficient modifying the zone air temperature part of the equation std::string ConstTempScheduleName; // Schedule name for scheduled outside temp - int ConstTempScheduleIndex; // Index for scheduled outside temp. + Sched::Schedule *constTempSched = nullptr; // Index for scheduled outside temp. bool SinusoidalConstTempCoef; // If true then ConstTempCoef varies by sine wave Real64 SinusoidPeriod; // period of sine wave variation (hr) Real64 TPreviousCoef; // Coefficient modifying the OSC temp from the previous timestep (dimensionless) @@ -1220,7 +1221,7 @@ namespace DataSurfaces { // Default Constructor OSCData() : ConstTemp(0.0), ConstTempCoef(0.0), ExtDryBulbCoef(0.0), GroundTempCoef(0.0), SurfFilmCoef(0.0), WindSpeedCoef(0.0), - ZoneAirTempCoef(0.0), ConstTempScheduleIndex(0), SinusoidalConstTempCoef(false), SinusoidPeriod(0.0), TPreviousCoef(0.0), + ZoneAirTempCoef(0.0), SinusoidalConstTempCoef(false), SinusoidPeriod(0.0), TPreviousCoef(0.0), TOutsideSurfPast(0.0), MinTempLimit(0.0), MaxTempLimit(0.0), MinLimitPresent(false), MaxLimitPresent(false), OSCTempCalc(0.0) { } @@ -1260,8 +1261,7 @@ namespace DataSurfaces { Convect::OverrideType overrideType = // Override type, 1=value, 2=schedule, 3=model, 4=user curve Convect::OverrideType::Invalid; Real64 OverrideValue = 0.0; // User specified value - std::string ScheduleName = ""; // Which surface (name) - int ScheduleIndex = 0; // if type="schedule" is used + Sched::Schedule *sched = nullptr; // if type="schedule" is used int UserCurveIndex = 0; // if type=UserCurve is used Convect::HcInt HcIntModelEq = Convect::HcInt::Invalid; // if type is one of specific model equations Convect::HcExt HcExtModelEq = Convect::HcExt::Invalid; @@ -1285,14 +1285,9 @@ namespace DataSurfaces { { // Members std::string Name; - int SurfPtr; // surface pointer - int ConstrPtr; // construction pointer - int SchedPtr; // schedule pointer - - // Default Constructor - SurfaceSolarIncident() : SurfPtr(0), ConstrPtr(0), SchedPtr(0) - { - } + int SurfPtr = 0; // surface pointer + int ConstrPtr = 0; // construction pointer + Sched::Schedule *sched = nullptr; // schedule }; struct SurfaceIncidentSolarMultiplier @@ -1301,7 +1296,7 @@ namespace DataSurfaces { std::string Name; int SurfaceIdx = 0; // surface index Real64 Scaler = 1.0; // the constant multiplier constant from user input - int SchedPtr = 0; // the index of the multiplier schedule + Sched::Schedule *sched = nullptr; // multiplier schedule }; struct FenestrationSolarAbsorbed @@ -1311,7 +1306,7 @@ namespace DataSurfaces { int SurfPtr; // surface pointer int ConstrPtr; // construction pointer int NumOfSched; // number of scheduled layers - Array1D_int SchedPtrs; // pointer to schedules for each layer in construction + Array1D scheds; // pointer to schedules for each layer in construction // Default Constructor FenestrationSolarAbsorbed() : SurfPtr(0), ConstrPtr(0), NumOfSched(0) @@ -1324,8 +1319,8 @@ namespace DataSurfaces { // Members std::string Name; // name of a ground surface Real64 ViewFactor = 0.0; // view factor to a ground surface - int TempSchPtr = 0; // pointer to a ground surface temperature schedule object - int ReflSchPtr = 0; // pointer to a ground Surface reflectance schedule object + Sched::Schedule *tempSched = nullptr; // pointer to a ground surface temperature schedule object + Sched::Schedule *reflSched = nullptr; // pointer to a ground Surface reflectance schedule object }; struct GroundSurfacesProperty @@ -1345,7 +1340,7 @@ namespace DataSurfaces { // Members std::string Name; int SurfPtr = 0; // surface pointer - int SunlitFracSchedPtr = 0; // schedule pointer + Sched::Schedule *sunlitFracSched = nullptr; // schedule int SurroundingSurfsPtr = 0; // schedule pointer int OutdoorAirNodePtr = 0; // outdoor air node pointer int GroundSurfsPtr = 0; // pointer to multiple ground surfaces object @@ -1356,7 +1351,7 @@ namespace DataSurfaces { // Members std::string Name; Real64 ViewFactor = 0.0; // view factor to surrounding surface - int TempSchNum = 0; // schedule pointer + Sched::Schedule *tempSched = nullptr; // temperature schedule }; struct SurroundingSurfacesProperty @@ -1366,8 +1361,8 @@ namespace DataSurfaces { Real64 SkyViewFactor = 0.0; // sky view factor Real64 GroundViewFactor = 0.0; // ground view factor Real64 SurfsViewFactorSum = 0.0; // surrounding surfaces view factor sum - int SkyTempSchNum = 0; // schedule pointer - int GroundTempSchNum = 0; // schedule pointer + Sched::Schedule *skyTempSched = nullptr; // schedule + Sched::Schedule *groundTempSched = nullptr; // schedule int TotSurroundingSurface = 0; // Total number of surrounding surfaces defined for an exterior surface bool IsSkyViewFactorSet = false; // false if the sky view factor field is blank bool IsGroundViewFactorSet = false; // false if the ground view factor field is blank @@ -1580,8 +1575,8 @@ struct SurfacesData : BaseGlobalStruct // Surface movable insulation properties Array1D SurfMaterialMovInsulExt; // Pointer to the material used for exterior movable insulation Array1D SurfMaterialMovInsulInt; // Pointer to the material used for interior movable insulation - Array1D SurfSchedMovInsulExt; // Schedule for exterior movable insulation - Array1D SurfSchedMovInsulInt; // Schedule for interior movable insulation + Array1D SurfMovInsulExtScheds; // Schedule for exterior movable insulation + Array1D SurfMovInsulIntScheds; // Schedule for interior movable insulation // Surface EMS Array1D SurfEMSConstructionOverrideON; // if true, EMS is calling to override the construction value @@ -1788,7 +1783,7 @@ struct SurfacesData : BaseGlobalStruct Array1D SurfWinMaxAirflow; // Maximum gap airflow (m3/s per m of glazing width) Array1D SurfWinAirflowControlType; // Gap airflow control type (ALWAYSONATMAXFLOW, etc.) Array1D SurfWinAirflowHasSchedule; // True if gap airflow is scheduled - Array1D SurfWinAirflowSchedulePtr; // Gap airflow schedule pointer + Array1D SurfWinAirflowScheds; // Gap airflow schedule Array1D SurfWinAirflowThisTS; // Gap airflow this timestep (m3/s per m of glazing width) Array1D SurfWinTAirflowGapOutlet; // Temperature of air leaving airflow gap between glass panes (C) Array1D SurfWinWindowCalcIterationsRep; // Number of iterations in window heat balance calculation @@ -1830,6 +1825,10 @@ struct SurfacesData : BaseGlobalStruct EPVector IntMassObjects; EPVector GroundSurfsProperty; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/DataSystemVariables.hh b/src/EnergyPlus/DataSystemVariables.hh index f1d57148038..0a1d6d750bb 100644 --- a/src/EnergyPlus/DataSystemVariables.hh +++ b/src/EnergyPlus/DataSystemVariables.hh @@ -152,6 +152,10 @@ struct SystemVarsData : BaseGlobalStruct bool Threading = false; bool ciForceTimeStep = false; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/DataTimings.hh b/src/EnergyPlus/DataTimings.hh index 19adecf5799..0530485b6f7 100644 --- a/src/EnergyPlus/DataTimings.hh +++ b/src/EnergyPlus/DataTimings.hh @@ -76,6 +76,10 @@ struct DataTimingsData : BaseGlobalStruct int NumCalcScriptF_Calls = 0; #endif + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/DataViewFactorInformation.hh b/src/EnergyPlus/DataViewFactorInformation.hh index 1882c62ee24..a28bf9fd0b0 100644 --- a/src/EnergyPlus/DataViewFactorInformation.hh +++ b/src/EnergyPlus/DataViewFactorInformation.hh @@ -106,6 +106,10 @@ struct ViewFactorInfoData : BaseGlobalStruct EPVector EnclRadInfo; EPVector EnclSolInfo; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/DataWater.hh b/src/EnergyPlus/DataWater.hh index 2699f3ca3e7..ea8a8186e3d 100644 --- a/src/EnergyPlus/DataWater.hh +++ b/src/EnergyPlus/DataWater.hh @@ -156,9 +156,9 @@ namespace DataWater { Real64 MaxOutFlowRate; // limit on rate of outlet [m3/s] TankThermalMode ThermalMode; Real64 InitialTankTemp; // initial tank temperature [C] - int TempSchedID; // index "pointer" to schedule + Sched::Schedule *tempSched = nullptr; // temp schedule AmbientTempType AmbientTempIndicator; // Indicator for ambient tank losses (SCHEDULE, ZONE, EXTERIOR) - int AmbientTempSchedule; // Schedule index pointer + Sched::Schedule *ambientTempSched = nullptr; // Ambient temp schedule int ZoneID; // index "pointer" to zone where tank is Real64 UValue; // U-value for tank [W/m2-k] Real64 SurfArea; // surface are of tank on Zone side... [m2] @@ -199,8 +199,8 @@ namespace DataWater { : MaxCapacity(0.0), OverflowMode(Overflow::Invalid), OverflowTankID(0), OverflowTankSupplyARRID(0), ValveOnCapacity(0.0), ValveOffCapacity(0.0), LastTimeStepFilling(false), ControlSupply(ControlSupplyType::Invalid), GroundWellID(0), SupplyTankID(0), SupplyTankDemandARRID(0), BackupMainsCapacity(0.0), InitialVolume(0.0), MaxInFlowRate(0.0), MaxOutFlowRate(0.0), - ThermalMode(TankThermalMode::Invalid), InitialTankTemp(20.0), TempSchedID(0), AmbientTempIndicator(AmbientTempType::Invalid), - AmbientTempSchedule(0), ZoneID(0), UValue(0.0), SurfArea(0.0), InternalMassID(0), ThisTimeStepVolume(0.0), LastTimeStepVolume(0.0), + ThermalMode(TankThermalMode::Invalid), InitialTankTemp(20.0), AmbientTempIndicator(AmbientTempType::Invalid), + ZoneID(0), UValue(0.0), SurfArea(0.0), InternalMassID(0), ThisTimeStepVolume(0.0), LastTimeStepVolume(0.0), LastTimeStepTemp(0.0), NumWaterSupplies(0), NumWaterDemands(0), VdotFromTank(0.0), VdotToTank(0.0), VdotOverflow(0.0), VolOverflow(0.0), NetVdot(0.0), Twater(0.0), TouterSkin(0.0), TwaterOverflow(0.0), MainsDrawVdot(0.0), MainsDrawVol(0.0), SkinLossPower(0.0), SkinLossEnergy(0.0), SkinLossConvect(0.0), SkinLossRadiat(0.0) @@ -218,7 +218,7 @@ namespace DataWater { int StorageTankSupplyARRID; RainLossFactor LossFactorMode; // control how loss factor(s) are entered Real64 LossFactor; // loss factor when constant - int LossFactorSchedID; // index "pointer" to schedule + Sched::Schedule *lossFactorSched = nullptr; // schedule Real64 MaxCollectRate; int NumCollectSurfs; // number of surfaces used in the collector Array1D_string SurfName; @@ -232,7 +232,7 @@ namespace DataWater { // Default Constructor RainfallCollectorDataStruct() - : StorageTankID(0), StorageTankSupplyARRID(0), LossFactorMode(RainLossFactor::Invalid), LossFactor(0.0), LossFactorSchedID(0), + : StorageTankID(0), StorageTankSupplyARRID(0), LossFactorMode(RainLossFactor::Invalid), LossFactor(0.0), MaxCollectRate(0.0), NumCollectSurfs(0), HorizArea(0.0), VdotAvail(0.0), VolCollected(0.0), MeanHeight(0.0) { } @@ -255,7 +255,7 @@ namespace DataWater { Real64 NomWellStorageVol; // water storage in well at average water table depth [m3] GroundWaterTable GroundwaterTableMode; // method of determining water table depth Real64 WaterTableDepth; - int WaterTableDepthSchedID; + Sched::Schedule *waterTableDepthSched = nullptr; // calculated and from elsewhere Real64 VdotRequest; // rate of flow over timestep requested by tank Real64 VdotDelivered; // rate of flow provided [m3/s] @@ -267,7 +267,7 @@ namespace DataWater { GroundwaterWellDataStruct() : StorageTankID(0), StorageTankSupplyARRID(0), PumpDepth(0.0), PumpNomVolFlowRate(0.0), PumpNomHead(0.0), PumpNomPowerUse(0.0), PumpEfficiency(0.0), WellRecoveryRate(0.0), NomWellStorageVol(0.0), GroundwaterTableMode(GroundWaterTable::Invalid), - WaterTableDepth(0.0), WaterTableDepthSchedID(0), VdotRequest(0.0), VdotDelivered(0.0), VolDelivered(0.0), PumpPower(0.0), + WaterTableDepth(0.0), VdotRequest(0.0), VdotDelivered(0.0), VolDelivered(0.0), PumpPower(0.0), PumpEnergy(0.0) { } @@ -278,7 +278,7 @@ namespace DataWater { // Members RainfallMode ModeID; // type of rainfall modeling Real64 DesignAnnualRain; - int RainSchedID; + Sched::Schedule *rainSched = nullptr; Real64 NomAnnualRain; // calculated and from elsewhere. Real64 CurrentRate; @@ -289,7 +289,7 @@ namespace DataWater { // Default Constructor SiteRainFallDataStruct() - : ModeID(RainfallMode::None), DesignAnnualRain(0.0), RainSchedID(0), NomAnnualRain(0.0), CurrentRate(0.0), CurrentAmount(0.0) + : ModeID(RainfallMode::None), DesignAnnualRain(0.0), NomAnnualRain(0.0), CurrentRate(0.0), CurrentAmount(0.0) { } }; @@ -298,13 +298,13 @@ namespace DataWater { { // Members IrrigationMode ModeID; // type of irrigation modeling - int IrrSchedID; + Sched::Schedule *irrSched = nullptr; Real64 ScheduledAmount; Real64 ActualAmount; Real64 IrrigationThreshold; // percent at which no irrigation happens (smart schedule) // Default Constructor - IrrigationDataStruct() : ModeID(IrrigationMode::Invalid), IrrSchedID(0), ScheduledAmount(0.0), ActualAmount(0.0), IrrigationThreshold(0.4) + IrrigationDataStruct() : ModeID(IrrigationMode::Invalid), ScheduledAmount(0.0), ActualAmount(0.0), IrrigationThreshold(0.4) { } }; @@ -331,6 +331,10 @@ struct DataWaterData : BaseGlobalStruct bool AnyIrrigationInModel = false; // control flag set true if irrigation input for ecoroof DJS PSU Dec 2006 int PrecipOverwrittenByRainFlag = 0; // recurring warning index when the rain flag is on but the liquidprecipitation = 0 + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/DataWindowEquivalentLayer.hh b/src/EnergyPlus/DataWindowEquivalentLayer.hh index 3a245c1691b..1393f142ca8 100644 --- a/src/EnergyPlus/DataWindowEquivalentLayer.hh +++ b/src/EnergyPlus/DataWindowEquivalentLayer.hh @@ -292,6 +292,10 @@ struct WindowEquivLayerData : BaseGlobalStruct Array1D CFS; Array1D CFSGaps; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/DataZoneControls.hh b/src/EnergyPlus/DataZoneControls.hh index c0d79f4f2ce..61cec343984 100644 --- a/src/EnergyPlus/DataZoneControls.hh +++ b/src/EnergyPlus/DataZoneControls.hh @@ -71,30 +71,24 @@ namespace DataZoneControls { Num }; + struct TempSetptType + { + std::string Name; + bool isUsed = false; + Sched::Schedule *heatSetptSched = nullptr; + Sched::Schedule *coolSetptSched = nullptr; + }; + struct ZoneTempControls { // Members std::string Name; // Name of the thermostat std::string ZoneName; // Name of the zone int ActualZoneNum; - std::string ControlTypeSchedName; // Name of the schedule which determines the zone temp setpoint - int CTSchedIndex; // Index for this schedule - // this is the number of control types defined on this zone control object - int NumControlTypes; + Sched::Schedule *setptTypeSched = nullptr; // Index for this schedule - // these are all allocated to NumControlTypes, should be a struct allocated once - Array1D_string ControlType; // from IDF, the "types" (string-should be an enum) of control modes for this particular thermostat - delete this - Array1D_string ControlTypeName; // from IDF, the names of the control modes for this particular thermostat - Array1D ControlTypeEnum; // from IDF, the enum types of each control mode for this particular thermostat - - // these now reflect that actual underlying setpoint temperature schedule indexes for each possible control type, - // so they can be used to call directly to ScheduleValue(...) - int SchIndx_SingleHeatSetPoint; - int SchIndx_SingleCoolSetPoint; - int SchIndx_SingleHeatCoolSetPoint; - int SchIndx_DualSetPointWDeadBandHeat; - int SchIndx_DualSetPointWDeadBandCool; + std::array setpts; bool ManageDemand; // Flag to indicate whether to use demand limiting Real64 HeatingResetLimit; // Lowest heating setpoint that can be set by demand manager [C] @@ -107,7 +101,7 @@ namespace DataZoneControls { bool OpTempCntrlModeScheduled; // flag to indicate if radiative fraction is scheduled, // else constant Real64 FixedRadiativeFraction; // weighting factor for mean radiant temp for Operative temperature - int OpTempRadiativeFractionSched; // index of schedule for when fraction is scheduled + Sched::Schedule *opTempRadiativeFractionSched = nullptr; // schedule for when fraction is scheduled bool AdaptiveComfortTempControl; // flag to indicate whether control based on Operative Temp int AdaptiveComfortModelTypeIndex; // index to adaptive comfort model type @@ -117,11 +111,10 @@ namespace DataZoneControls { bool OvercoolCntrlModeScheduled; // Flag to indicate if zone overcool range is scheduled // or constant Real64 ZoneOvercoolConstRange; // Overcool Range for Zone Air Setpoint Temperature [deltaC] - int ZoneOvercoolRangeSchedIndex; // Index for Overcool Range Schedule + Sched::Schedule *zoneOvercoolRangeSched = nullptr; // Overcool Range Schedule Real64 ZoneOvercoolControlRatio; // Zone relative humidity shift per dry-bulb temperature overcooling // below the original cooling setpoint, %RH/deltaC - std::string DehumidifyingSched; // Name of the schedule to determine the zone dehumidifying setpoint - int DehumidifyingSchedIndex; // Index for dehumidifying schedule + Sched::Schedule *dehumidifyingSched = nullptr; // dehumidifying schedule Real64 DeltaTCutSet; // Temperature difference between cutout and setpoint Real64 ZoneThermostatSetPointHi; // Cooling setpoint Real64 ZoneThermostatSetPointLo; // Heating setpoint @@ -134,13 +127,13 @@ namespace DataZoneControls { // Default Constructor ZoneTempControls() - : ActualZoneNum(0), CTSchedIndex(0), NumControlTypes(0), SchIndx_SingleHeatSetPoint(0), SchIndx_SingleCoolSetPoint(0), - SchIndx_SingleHeatCoolSetPoint(0), SchIndx_DualSetPointWDeadBandHeat(0), SchIndx_DualSetPointWDeadBandCool(0), ManageDemand(false), + : ActualZoneNum(0), + ManageDemand(false), HeatingResetLimit(0.0), CoolingResetLimit(0.0), EMSOverrideHeatingSetPointOn(false), EMSOverrideHeatingSetPointValue(0.0), EMSOverrideCoolingSetPointOn(false), EMSOverrideCoolingSetPointValue(0.0), OperativeTempControl(false), OpTempCntrlModeScheduled(false), - FixedRadiativeFraction(0.0), OpTempRadiativeFractionSched(0), AdaptiveComfortTempControl(false), AdaptiveComfortModelTypeIndex(0), + FixedRadiativeFraction(0.0), AdaptiveComfortTempControl(false), AdaptiveComfortModelTypeIndex(0), ZoneOvercoolRange(0.0), ZoneOvercoolControl(false), OvercoolCntrlModeScheduled(false), ZoneOvercoolConstRange(0.0), - ZoneOvercoolRangeSchedIndex(0), ZoneOvercoolControlRatio(0.0), DehumidifyingSchedIndex(0), DeltaTCutSet(0), + ZoneOvercoolControlRatio(0.0), DeltaTCutSet(0), ZoneThermostatSetPointHi(0.0), ZoneThermostatSetPointLo(0.0), CoolModeLast(false), HeatModeLast(false), CoolModeLastSave(false), HeatModeLastSave(false), CoolOffFlag(false), HeatOffFlag(false) @@ -153,11 +146,9 @@ namespace DataZoneControls { // Members std::string ControlName; // Name of this humidity controller std::string ZoneName; // Name of the zone - std::string HumidifyingSched; // Name of the schedule to determine the zone humidifying setpoint - std::string DehumidifyingSched; // Name of the schedule to determine the zone dehumidifying setpoint int ActualZoneNum; - int HumidifyingSchedIndex; // Index for humidifying schedule - int DehumidifyingSchedIndex; // Index for dehumidifying schedule + Sched::Schedule *humidifyingSched = nullptr; // humidifying schedule + Sched::Schedule *dehumidifyingSched = nullptr; // dehumidifying schedule int ErrorIndex; // Error index when LowRH setpoint > HighRH setpoint bool EMSOverrideHumidifySetPointOn; // EMS is calling to override humidifying setpoint Real64 EMSOverrideHumidifySetPointValue; // value EMS is directing to use for humidifying setpoint @@ -166,28 +157,31 @@ namespace DataZoneControls { // Default Constructor ZoneHumidityControls() - : ActualZoneNum(0), HumidifyingSchedIndex(0), DehumidifyingSchedIndex(0), ErrorIndex(0), EMSOverrideHumidifySetPointOn(false), + : ActualZoneNum(0), ErrorIndex(0), EMSOverrideHumidifySetPointOn(false), EMSOverrideHumidifySetPointValue(0.0), EMSOverrideDehumidifySetPointOn(false), EMSOverrideDehumidifySetPointValue(0.0) { } }; + + struct ComfortSetptType + { + std::string Name; + bool isUsed = false; + Sched::Schedule *heatSetptSched = nullptr; + Sched::Schedule *coolSetptSched = nullptr; + }; + struct ZoneComfortControls { // Members std::string Name; // Name of the thermostat std::string ZoneName; // Name of the zone int ActualZoneNum; // Index number of zone - std::string ControlTypeSchedName; // Name of the schedule which determines the zone temp setpoint - int ComfortSchedIndex; // Index for this schedule - int NumControlTypes; // Number of control types in ZoneControl:ThermalComfort object - Array1D_string ControlType; // Type of control - Array1D_string ControlTypeName; // Name of control type - Array1D_int ControlTypeSchIndx; // Index to control type schedule - int SchIndx_SingleHeating; // Index to fanger single heating setpoint schedule - int SchIndx_SingleCooling; // Index to fanger single cooling setpoint schedule - int SchIndx_SingleHeatCool; // Index to fanger single heating/cooling setpoint schedule - int SchIndx_DualSetPointWithDeadBand; // Index to fanger dual setpoint schedule + Sched::Schedule *setptTypeSched = nullptr; // Schedule determines which thermostat type is active + + std::array setpts; // Type of control + bool ManageDemand; // Flag to indicate whether to use demand limiting Real64 HeatingResetLimit; // Lowest heating setpoint that can be set by demand manager [C] Real64 CoolingResetLimit; // Highest cooling setpoint that can be set by demand manager [C] @@ -197,7 +191,7 @@ namespace DataZoneControls { Real64 EMSOverrideCoolingSetPointValue; // value EMS is directing to use for cooling setpoint Real64 TdbMaxSetPoint; // Maximum dry-bulb temperature setpoint [C] Real64 TdbMinSetPoint; // Minimum dry-bulb temperature setpoint [C] - std::string AverageMethodName; // Averaging Method for Zones with Multiple People Objects + std::string AverageMethodName; // Name for Averaging Method std::string AverageObjectName; // Object Name for Specific Object Average DataZoneControls::AverageMethod AverageMethod; // Averaging method int SpecificObjectNum; // People Object number used for Specific people object choice @@ -210,8 +204,8 @@ namespace DataZoneControls { // Default Constructor ZoneComfortControls() - : ActualZoneNum(0), ComfortSchedIndex(0), NumControlTypes(0), SchIndx_SingleHeating(0), SchIndx_SingleCooling(0), - SchIndx_SingleHeatCool(0), SchIndx_DualSetPointWithDeadBand(0), ManageDemand(false), HeatingResetLimit(0.0), CoolingResetLimit(0.0), + : ActualZoneNum(0), + ManageDemand(false), HeatingResetLimit(0.0), CoolingResetLimit(0.0), EMSOverrideHeatingSetPointOn(false), EMSOverrideHeatingSetPointValue(0.0), EMSOverrideCoolingSetPointOn(false), EMSOverrideCoolingSetPointValue(0.0), TdbMaxSetPoint(50.0), TdbMinSetPoint(0.0), AverageMethodName("PEOPLE AVERGAE"), AverageMethod(DataZoneControls::AverageMethod::NO), SpecificObjectNum(0), PeopleAverageErrIndex(0), TdbMaxErrIndex(0), @@ -226,10 +220,8 @@ namespace DataZoneControls { std::string Name; // Name of the thermostat std::string ZoneName; // Name of the zone int ActualZoneNum; // Index number of zone - std::string HeatSetBaseSchedName; // Name of the schedule which provides zone heating setpoint base - int HSBchedIndex; // Index for this schedule - std::string CoolSetBaseSchedName; // Name of the schedule which provides zone cooling setpoint base - int CSBchedIndex; // Index for this schedule + Sched::Schedule *heatSetptBaseSched = nullptr; // schedule which provides zone heating setpoint base + Sched::Schedule *coolSetptBaseSched = nullptr;// schedule which provides zone cooling setpoint base int NumOfHeatStages; // Number of heating stages int NumOfCoolStages; // Number of cooling stages Real64 HeatThroRange; // Heating throttling tempeature range @@ -243,7 +235,7 @@ namespace DataZoneControls { // Default Constructor ZoneStagedControls() - : ActualZoneNum(0), HSBchedIndex(0), CSBchedIndex(0), NumOfHeatStages(0), NumOfCoolStages(0), HeatThroRange(0.0), CoolThroRange(0.0), + : ActualZoneNum(0), NumOfHeatStages(0), NumOfCoolStages(0), HeatThroRange(0.0), CoolThroRange(0.0), HeatSetPoint(0.0), CoolSetPoint(0.0), StageErrCount(0), StageErrIndex(0) { } @@ -293,6 +285,10 @@ struct DataZoneControlsData : BaseGlobalStruct Array1D StagedTStatObjects; Array1D StageControlledZone; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/DataZoneEnergyDemands.hh b/src/EnergyPlus/DataZoneEnergyDemands.hh index 13e84b63452..61e0eb75cf8 100644 --- a/src/EnergyPlus/DataZoneEnergyDemands.hh +++ b/src/EnergyPlus/DataZoneEnergyDemands.hh @@ -172,6 +172,10 @@ struct DataZoneEnergyDemandsData : BaseGlobalStruct EPVector spaceSysEnergyDemand; EPVector spaceSysMoistureDemand; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/DataZoneEquipment.cc b/src/EnergyPlus/DataZoneEquipment.cc index 869dfd51857..498d13c9d89 100644 --- a/src/EnergyPlus/DataZoneEquipment.cc +++ b/src/EnergyPlus/DataZoneEquipment.cc @@ -181,7 +181,6 @@ void GetZoneEquipmentData(EnergyPlusData &state) using NodeInputManager::GetOnlySingleNode; using NodeInputManager::InitUniqueNodeCheck; using namespace DataLoopNode; - using namespace ScheduleManager; // SUBROUTINE PARAMETER DEFINITIONS: static constexpr std::string_view RoutineName("GetZoneEquipmentData: "); // include trailing blank space @@ -751,11 +750,15 @@ void processZoneEquipmentInput(EnergyPlusData &state, Array1D_int &NodeNums) { static constexpr std::string_view RoutineName("processZoneEquipmentInput: "); // include trailing blank space + static constexpr std::string_view routineName = "processZoneEquipmentInput"; + int spaceFieldShift = 0; if (isSpace) { spaceFieldShift = -1; } + ErrorObjectHeader eoh{routineName, zoneEqModuleObject, AlphArray(1)}; + thisEquipConfig.IsControlled = true; thisEquipConfig.ZoneName = AlphArray(1); // for x-referencing with the geometry data @@ -794,20 +797,10 @@ void processZoneEquipmentInput(EnergyPlusData &state, std::string ReturnNodeListName = AlphArray(6 + spaceFieldShift); if (lAlphaBlanks(7)) { - thisEquipConfig.ReturnFlowSchedPtrNum = ScheduleManager::ScheduleAlwaysOn; - } else { - thisEquipConfig.ReturnFlowSchedPtrNum = ScheduleManager::GetScheduleIndex(state, AlphArray(7 + spaceFieldShift)); - if (thisEquipConfig.ReturnFlowSchedPtrNum == 0) { - ShowSevereError(state, - format("{}{}: invalid {} entered ={} for {}={}", - RoutineName, - zoneEqModuleObject, - cAlphaFields(7), - AlphArray(7), - cAlphaFields(1), - AlphArray(1))); - state.dataZoneEquip->GetZoneEquipmentDataErrorsFound = true; - } + thisEquipConfig.returnFlowSched = Sched::GetScheduleAlwaysOn(state); + } else if ((thisEquipConfig.returnFlowSched = Sched::GetSchedule(state, AlphArray(7 + spaceFieldShift))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(7), AlphArray(7)); + state.dataZoneEquip->GetZoneEquipmentDataErrorsFound = true; } std::string ReturnFlowBasisNodeListName = AlphArray(8 + spaceFieldShift); @@ -861,8 +854,8 @@ void processZoneEquipmentInput(EnergyPlusData &state, thisZoneEquipList.HeatingPriority.allocate(thisZoneEquipList.NumOfEquipTypes); thisZoneEquipList.CoolingCapacity.allocate(thisZoneEquipList.NumOfEquipTypes); thisZoneEquipList.HeatingCapacity.allocate(thisZoneEquipList.NumOfEquipTypes); - thisZoneEquipList.SequentialCoolingFractionSchedPtr.allocate(thisZoneEquipList.NumOfEquipTypes); - thisZoneEquipList.SequentialHeatingFractionSchedPtr.allocate(thisZoneEquipList.NumOfEquipTypes); + thisZoneEquipList.sequentialCoolingFractionScheds.allocate(thisZoneEquipList.NumOfEquipTypes); + thisZoneEquipList.sequentialHeatingFractionScheds.allocate(thisZoneEquipList.NumOfEquipTypes); for (int eqNum = 1; eqNum <= thisZoneEquipList.NumOfEquipTypes; ++eqNum) { thisZoneEquipList.EquipTypeName(eqNum) = ""; thisZoneEquipList.EquipType(eqNum) = DataZoneEquipment::ZoneEquipType::Invalid; @@ -874,8 +867,8 @@ void processZoneEquipmentInput(EnergyPlusData &state, thisZoneEquipList.HeatingPriority(eqNum) = 0; thisZoneEquipList.CoolingCapacity(eqNum) = 0; thisZoneEquipList.HeatingCapacity(eqNum) = 0; - thisZoneEquipList.SequentialCoolingFractionSchedPtr(eqNum) = 0; - thisZoneEquipList.SequentialHeatingFractionSchedPtr(eqNum) = 0; + thisZoneEquipList.sequentialCoolingFractionScheds(eqNum) = nullptr; + thisZoneEquipList.sequentialHeatingFractionScheds(eqNum) = nullptr; } auto const &extensionSchemaProps = objectSchemaProps["equipment"]["items"]["properties"]; @@ -932,15 +925,11 @@ void processZoneEquipmentInput(EnergyPlusData &state, std::string coolingSchName = ip->getAlphaFieldValue(extensibleInstance, extensionSchemaProps, "zone_equipment_sequential_cooling_fraction_schedule_name"); if (coolingSchName.empty()) { - thisZoneEquipList.SequentialCoolingFractionSchedPtr(ZoneEquipTypeNum) = ScheduleManager::ScheduleAlwaysOn; + thisZoneEquipList.sequentialCoolingFractionScheds(ZoneEquipTypeNum) = Sched::GetScheduleAlwaysOn(state); } else { - thisZoneEquipList.SequentialCoolingFractionSchedPtr(ZoneEquipTypeNum) = - ScheduleManager::GetScheduleIndex(state, coolingSchName); - if (thisZoneEquipList.SequentialCoolingFractionSchedPtr(ZoneEquipTypeNum) == 0) { - ShowSevereError(state, format("{}{} = \"{}\".", RoutineName, CurrentModuleObject, thisZoneEquipList.Name)); - ShowContinueError(state, - format("invalid zone_equipment_sequential_cooling_fraction_schedule_name=[{}].", coolingSchName)); - ShowContinueError(state, "Schedule does not exist."); + thisZoneEquipList.sequentialCoolingFractionScheds(ZoneEquipTypeNum) = Sched::GetSchedule(state, coolingSchName); + if (thisZoneEquipList.sequentialCoolingFractionScheds(ZoneEquipTypeNum) == nullptr) { + ShowSevereItemNotFound(state, eoh, "zone_equipment_sequential_cooling_fraction_schedule_name", coolingSchName); state.dataZoneEquip->GetZoneEquipmentDataErrorsFound = true; } } @@ -948,15 +937,11 @@ void processZoneEquipmentInput(EnergyPlusData &state, std::string heatingSchName = ip->getAlphaFieldValue(extensibleInstance, extensionSchemaProps, "zone_equipment_sequential_heating_fraction_schedule_name"); if (heatingSchName.empty()) { - thisZoneEquipList.SequentialHeatingFractionSchedPtr(ZoneEquipTypeNum) = ScheduleManager::ScheduleAlwaysOn; + thisZoneEquipList.sequentialHeatingFractionScheds(ZoneEquipTypeNum) = Sched::GetScheduleAlwaysOn(state); } else { - thisZoneEquipList.SequentialHeatingFractionSchedPtr(ZoneEquipTypeNum) = - ScheduleManager::GetScheduleIndex(state, heatingSchName); - if (thisZoneEquipList.SequentialHeatingFractionSchedPtr(ZoneEquipTypeNum) == 0) { - ShowSevereError(state, format("{}{} = \"{}\".", RoutineName, CurrentModuleObject, thisZoneEquipList.Name)); - ShowContinueError(state, - format("invalid zone_equipment_sequential_heating_fraction_schedule_name=[{}].", coolingSchName)); - ShowContinueError(state, "Schedule does not exist."); + thisZoneEquipList.sequentialHeatingFractionScheds(ZoneEquipTypeNum) = Sched::GetSchedule(state, heatingSchName); + if (thisZoneEquipList.sequentialHeatingFractionScheds(ZoneEquipTypeNum) == nullptr) { + ShowSevereItemNotFound(state, eoh, "zone_equipment_sequential_heating_fraction_schedule_name", coolingSchName); state.dataZoneEquip->GetZoneEquipmentDataErrorsFound = true; } } @@ -1746,14 +1731,14 @@ void EquipList::getPrioritiesForInletNode(EnergyPlusData &state, state.dataHVACGlobal->MinAirLoopIterationsAfterFirst = minIterations; } -Real64 EquipList::SequentialHeatingFraction(EnergyPlusData &state, const int equipNum) +Real64 EquipList::SequentialHeatingFraction([[maybe_unused]] EnergyPlusData &state, const int equipNum) { - return ScheduleManager::GetCurrentScheduleValue(state, SequentialHeatingFractionSchedPtr(equipNum)); + return sequentialHeatingFractionScheds(equipNum)->getCurrentVal(); } -Real64 EquipList::SequentialCoolingFraction(EnergyPlusData &state, const int equipNum) +Real64 EquipList::SequentialCoolingFraction([[maybe_unused]] EnergyPlusData &state, const int equipNum) { - return ScheduleManager::GetCurrentScheduleValue(state, SequentialCoolingFractionSchedPtr(equipNum)); + return sequentialCoolingFractionScheds(equipNum)->getCurrentVal(); } int GetZoneEquipControlledZoneNum(EnergyPlusData &state, DataZoneEquipment::ZoneEquipType const zoneEquipType, std::string const &EquipmentName) @@ -2036,12 +2021,16 @@ void ZoneEquipmentSplitter::adjustLoads(EnergyPlusData &state, int zoneNum, int { auto &thisZoneEnergyDemand = state.dataZoneEnergyDemand->ZoneSysEnergyDemand(zoneNum); auto &thisZoneMoistureDemand = state.dataZoneEnergyDemand->ZoneSysMoistureDemand(zoneNum); + + auto &zoneTstatSetpt = state.dataHeatBalFanSys->zoneTstatSetpts(zoneNum); + Real64 sensibleRatio = 1.0; Real64 latentRatio = 1.0; switch (this->tstatControl) { - case DataZoneEquipment::ZoneEquipTstatControl::Ideal: + case DataZoneEquipment::ZoneEquipTstatControl::Ideal: { return; - break; // Do nothing + } break; // Do nothing + case DataZoneEquipment::ZoneEquipTstatControl::SingleSpace: { Real64 controlSpaceFrac = this->spaces[this->controlSpaceNumber].fraction; if (controlSpaceFrac > 0.0) { @@ -2057,6 +2046,7 @@ void ZoneEquipmentSplitter::adjustLoads(EnergyPlusData &state, int zoneNum, int } } } break; + case DataZoneEquipment::ZoneEquipTstatControl::Maximum: { int maxSpaceIndex = 0; Real64 maxDeltaTemp = 0.0; // Only positive deltaTemps are relevant @@ -2064,8 +2054,7 @@ void ZoneEquipmentSplitter::adjustLoads(EnergyPlusData &state, int zoneNum, int for (auto &splitterSpace : this->spaces) { Real64 spaceTemp = state.dataZoneTempPredictorCorrector->spaceHeatBalance(splitterSpace.spaceIndex).T1; // Based on calcPredictedSystemLoad usage - Real64 spaceDeltaTemp = max((state.dataHeatBalFanSys->ZoneThermostatSetPointLo(zoneNum) - spaceTemp), - (spaceTemp - state.dataHeatBalFanSys->ZoneThermostatSetPointHi(zoneNum))); + Real64 spaceDeltaTemp = max((zoneTstatSetpt.setptLo - spaceTemp), (spaceTemp - zoneTstatSetpt.setptHi)); if (spaceDeltaTemp > maxDeltaTemp) { maxSpaceIndex = splitterSpace.spaceIndex; maxSpaceFrac = splitterSpace.fraction; @@ -2250,7 +2239,7 @@ void EquipConfiguration::calcReturnFlows(EnergyPlusData &state, Real64 totReturnFlow = 0.0; // Total flow to all return nodes in the zone (kg/s) Real64 totVarReturnFlow = 0.0; // Total variable return flow, for return nodes connected to an airloop with an OA system or not with specified flow (kg/s) - Real64 returnSchedFrac = ScheduleManager::GetCurrentScheduleValue(state, this->ReturnFlowSchedPtrNum); + Real64 returnSchedFrac = this->returnFlowSched->getCurrentVal(); this->FixedReturnFlow = false; FinalTotalReturnMassFlow = 0.0; this->TotAvailAirLoopOA = 0.0; diff --git a/src/EnergyPlus/DataZoneEquipment.hh b/src/EnergyPlus/DataZoneEquipment.hh index 008be07c127..b370b4ed008 100644 --- a/src/EnergyPlus/DataZoneEquipment.hh +++ b/src/EnergyPlus/DataZoneEquipment.hh @@ -310,7 +310,7 @@ namespace DataZoneEquipment { int NumExhaustNodes; // number of exhaust nodes int NumReturnNodes; // number of return air nodes int NumReturnFlowBasisNodes; // number of return air flow basis nodes - int ReturnFlowSchedPtrNum; // return air flow fraction schedule pointer + Sched::Schedule *returnFlowSched = nullptr; // return air flow fraction schedule pointer bool FlowError; // flow error flag Array1D_int InletNode; // zone supply air inlet nodes Array1D_int InletNodeAirLoopNum; // air loop number connected to this inlet node (0 if not an airloop node) @@ -359,7 +359,7 @@ namespace DataZoneEquipment { // Default Constructor EquipConfiguration() : ZoneName("Uncontrolled Zone"), EquipListIndex(0), ZoneNode(0), NumInletNodes(0), NumExhaustNodes(0), NumReturnNodes(0), - NumReturnFlowBasisNodes(0), ReturnFlowSchedPtrNum(0), FlowError(false), ZonalSystemOnly(false), IsControlled(false), ZoneExh(0.0), + NumReturnFlowBasisNodes(0), FlowError(false), ZonalSystemOnly(false), IsControlled(false), ZoneExh(0.0), ZoneExhBalanced(0.0), PlenumMassFlow(0.0), ExcessZoneExh(0.0), TotAvailAirLoopOA(0.0), TotInletAirMassFlowRate(0.0), TotExhaustAirMassFlowRate(0.0), InFloorActiveElement(false), InWallActiveElement(false), InCeilingActiveElement(false), ZoneHasAirLoopWithOASys(false), ZoneAirDistributionIndex(0), ZoneDesignSpecOAIndex(0), AirLoopDesSupply(0.0) @@ -426,8 +426,8 @@ namespace DataZoneEquipment { std::vector compPointer; Array1D_int CoolingPriority; Array1D_int HeatingPriority; - Array1D_int SequentialCoolingFractionSchedPtr; - Array1D_int SequentialHeatingFractionSchedPtr; + Array1D sequentialCoolingFractionScheds; + Array1D sequentialHeatingFractionScheds; Array1D_int CoolingCapacity; // Current cooling capacity (negative) [W] Array1D_int HeatingCapacity; // Current heating capacity (positive) [W] Array1D EquipData; // Index of energy output report data @@ -645,6 +645,10 @@ struct DataZoneEquipmentData : BaseGlobalStruct std::vector zoneEquipMixer; std::vector zoneReturnMixer; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/DaylightingDevices.cc b/src/EnergyPlus/DaylightingDevices.cc index 37a8942ad32..24e9d533b18 100644 --- a/src/EnergyPlus/DaylightingDevices.cc +++ b/src/EnergyPlus/DaylightingDevices.cc @@ -210,8 +210,8 @@ namespace Dayltg { state.dataDaylightingDevices->COSAngle(1) = 0.0; state.dataDaylightingDevices->COSAngle(NumOfAngles) = 1.0; - Real64 dTheta = 90.0 * Constant::DegToRadians / (NumOfAngles - 1.0); - Real64 Theta = 90.0 * Constant::DegToRadians; + Real64 dTheta = 90.0 * Constant::DegToRad / (NumOfAngles - 1.0); + Real64 Theta = 90.0 * Constant::DegToRad; for (int AngleNum = 2; AngleNum <= NumOfAngles - 1; ++AngleNum) { Theta -= dTheta; state.dataDaylightingDevices->COSAngle(AngleNum) = std::cos(Theta); @@ -256,7 +256,7 @@ namespace Dayltg { TDDPipeStored(NumStored).TransBeam(NumOfAngles) = 1.0; // Calculate intermediate beam transmittances between 0 and 90 degrees - Theta = 90.0 * Constant::DegToRadians; + Theta = 90.0 * Constant::DegToRad; for (int AngleNum = 2; AngleNum <= NumOfAngles - 1; ++AngleNum) { Theta -= dTheta; TDDPipeStored(NumStored).TransBeam(AngleNum) = @@ -752,10 +752,10 @@ namespace Dayltg { } // PipeNum if (state.dataDaylightingDevices->GetTDDInputErrorsFound) ShowFatalError(state, "Errors in DaylightingDevice:Tubular input."); - state.dataDayltg->TDDTransVisBeam.allocate(Constant::HoursInDay, NumOfTDDPipes); - state.dataDayltg->TDDFluxInc.allocate(Constant::HoursInDay, NumOfTDDPipes); - state.dataDayltg->TDDFluxTrans.allocate(Constant::HoursInDay, NumOfTDDPipes); - for (int hr = 1; hr <= Constant::HoursInDay; ++hr) { + state.dataDayltg->TDDTransVisBeam.allocate(Constant::iHoursInDay, NumOfTDDPipes); + state.dataDayltg->TDDFluxInc.allocate(Constant::iHoursInDay, NumOfTDDPipes); + state.dataDayltg->TDDFluxTrans.allocate(Constant::iHoursInDay, NumOfTDDPipes); + for (int hr = 1; hr <= Constant::iHoursInDay; ++hr) { for (int tddNum = 1; tddNum <= NumOfTDDPipes; ++tddNum) { state.dataDayltg->TDDTransVisBeam(hr, tddNum) = 0.0; state.dataDayltg->TDDFluxInc(hr, tddNum) = Illums(); @@ -919,7 +919,7 @@ namespace Dayltg { state.dataDaylightingDevices->GetShelfInputErrorsFound = true; } - if (state.dataSurface->Surface(SurfNum).SchedShadowSurfIndex > 0) { + if (state.dataSurface->Surface(SurfNum).shadowSurfSched != nullptr) { ShowSevereError(state, format("{} = {}: Outside shelf {} must not have a transmittance schedule.", cCurrentModuleObject, @@ -1129,7 +1129,7 @@ namespace Dayltg { Real64 COSI; // Cosine of incident angle Real64 SINI; // Sine of incident angle - Real64 const dPH = 90.0 * Constant::DegToRadians / NPH; // Altitude angle of sky element + Real64 const dPH = 90.0 * Constant::DegToRad / NPH; // Altitude angle of sky element Real64 PH = 0.5 * dPH; // Altitude angle increment // Integrate from 0 to Pi/2 altitude @@ -1194,14 +1194,14 @@ namespace Dayltg { Real64 Theta; // TDD:DOME azimuth angle CosPhi = std::cos(Constant::PiOvr2 - - state.dataSurface->Surface(state.dataDaylightingDevicesData->TDDPipe(PipeNum).Dome).Tilt * Constant::DegToRadians); - Theta = state.dataSurface->Surface(state.dataDaylightingDevicesData->TDDPipe(PipeNum).Dome).Azimuth * Constant::DegToRadians; + state.dataSurface->Surface(state.dataDaylightingDevicesData->TDDPipe(PipeNum).Dome).Tilt * Constant::DegToRad); + Theta = state.dataSurface->Surface(state.dataDaylightingDevicesData->TDDPipe(PipeNum).Dome).Azimuth * Constant::DegToRad; if (CosPhi > 0.01) { // Dome has a view of the horizon // Integrate over the semicircle Real64 const THMIN = Theta - Constant::PiOvr2; // Minimum azimuth integration limit // Real64 const THMAX = Theta + PiOvr2; // Maximum azimuth integration limit - Real64 const dTH = 180.0 * Constant::DegToRadians / NTH; // Azimuth angle increment + Real64 const dTH = 180.0 * Constant::DegToRad / NTH; // Azimuth angle increment Real64 TH = THMIN + 0.5 * dTH; // Azimuth angle of sky horizon element for (int N = 1; N <= NTH; ++N) { diff --git a/src/EnergyPlus/DaylightingDevices.hh b/src/EnergyPlus/DaylightingDevices.hh index 949ad96e7f1..5e79e5ee354 100644 --- a/src/EnergyPlus/DaylightingDevices.hh +++ b/src/EnergyPlus/DaylightingDevices.hh @@ -112,6 +112,10 @@ struct DaylightingDevicesData : BaseGlobalStruct bool GetShelfInputErrorsFound = false; // Set to true if errors in input, fatal at end of routine bool MyEnvrnFlag = true; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/DaylightingManager.cc b/src/EnergyPlus/DaylightingManager.cc index 073ad84dffe..04f4e95ef7e 100644 --- a/src/EnergyPlus/DaylightingManager.cc +++ b/src/EnergyPlus/DaylightingManager.cc @@ -449,7 +449,7 @@ void CalcDayltgCoefficients(EnergyPlusData &state) // Zero daylighting factor arrays if (numTDD > 0) { int iHrBeg = state.dataSysVars->DetailedSolarTimestepIntegration ? state.dataGlobal->HourOfDay : 1; - int iHrEnd = state.dataSysVars->DetailedSolarTimestepIntegration ? state.dataGlobal->HourOfDay : Constant::HoursInDay; + int iHrEnd = state.dataSysVars->DetailedSolarTimestepIntegration ? state.dataGlobal->HourOfDay : Constant::iHoursInDay; for (int iHr = iHrBeg; iHr <= iHrEnd; ++iHr) { for (int iTDD = 1; iTDD <= numTDD; ++iTDD) { dl->TDDTransVisBeam(iHr, iTDD) = 0.0; @@ -465,7 +465,7 @@ void CalcDayltgCoefficients(EnergyPlusData &state) dl->sunAngles = SunAngles(); dl->sunAnglesHr = {SunAngles()}; dl->horIllum = {Illums()}; - for (int IHR = 1; IHR <= Constant::HoursInDay; ++IHR) { + for (int IHR = 1; IHR <= Constant::iHoursInDay; ++IHR) { auto const &surfSunCosHr = s_surf->SurfSunCosHourly(IHR); if (surfSunCosHr.z < DataEnvironment::SunIsUpValue) continue; // Skip if sun is below horizon //Autodesk SurfSunCosHourly was uninitialized here @@ -604,7 +604,7 @@ void CalcDayltgCoefficients(EnergyPlusData &state) s_surf->Surface(windowSurfNum).Name); } - for (int IHR = 1; IHR <= Constant::HoursInDay; ++IHR) { + for (int IHR = 1; IHR <= Constant::iHoursInDay; ++IHR) { // For each Daylight Reference Point auto &daylFacHr = thisDayltgCtrl.daylFac[IHR]; for (int refPtNum = 1; refPtNum <= thisDayltgCtrl.TotalDaylRefPoints; ++refPtNum) { @@ -776,7 +776,7 @@ void CalcDayltgCoeffsRefPoints(EnergyPlusData &state, int const daylightCtrlNum) // Azimuth of view vector in absolute coord sys Real64 AZVIEW = (thisDayltgCtrl.ViewAzimuthForGlare + state.dataHeatBal->Zone(zoneNum).RelNorth + state.dataHeatBal->BuildingAzimuth + state.dataHeatBal->BuildingRotationAppendixG) * - Constant::DegToRadians; + Constant::DegToRad; // View vector components in absolute coord sys VIEWVC = {std::sin(AZVIEW), std::cos(AZVIEW), 0.0}; @@ -790,7 +790,7 @@ void CalcDayltgCoeffsRefPoints(EnergyPlusData &state, int const daylightCtrlNum) } int iHrBeg = state.dataSysVars->DetailedSolarTimestepIntegration ? state.dataGlobal->HourOfDay : 1; - int iHrEnd = state.dataSysVars->DetailedSolarTimestepIntegration ? state.dataGlobal->HourOfDay : Constant::HoursInDay; + int iHrEnd = state.dataSysVars->DetailedSolarTimestepIntegration ? state.dataGlobal->HourOfDay : Constant::iHoursInDay; int numExtWins = thisEnclDaylight.NumOfDayltgExtWins; int numRefPts = thisDayltgCtrl.TotalDaylRefPoints; @@ -922,7 +922,7 @@ void CalcDayltgCoeffsRefPoints(EnergyPlusData &state, int const daylightCtrlNum) if (!state.dataSysVars->DetailedSolarTimestepIntegration) { ISunPos = 0; - for (int IHR = 1; IHR <= Constant::HoursInDay; ++IHR) { + for (int IHR = 1; IHR <= Constant::iHoursInDay; ++IHR) { FigureDayltgCoeffsAtPointsForSunPosition(state, daylightCtrlNum, @@ -1024,7 +1024,7 @@ void CalcDayltgCoeffsRefPoints(EnergyPlusData &state, int const daylightCtrlNum) if (!state.dataSysVars->DetailedSolarTimestepIntegration) { ISunPos = 0; - for (int IHR = 1; IHR <= Constant::HoursInDay; ++IHR) { + for (int IHR = 1; IHR <= Constant::iHoursInDay; ++IHR) { FigureRefPointDayltgFactorsToAddIllums(state, daylightCtrlNum, ILB, IHR, ISunPos, IWin, loopwin, NWX, NWY, ICtrl); } // End of sun position loop, IHR @@ -1151,7 +1151,7 @@ void CalcDayltgCoeffsMapPoints(EnergyPlusData &state, int const mapNum) } int iHrBeg = state.dataSysVars->DetailedSolarTimestepIntegration ? state.dataGlobal->HourOfDay : 1; - int iHrEnd = state.dataSysVars->DetailedSolarTimestepIntegration ? state.dataGlobal->HourOfDay : Constant::HoursInDay; + int iHrEnd = state.dataSysVars->DetailedSolarTimestepIntegration ? state.dataGlobal->HourOfDay : Constant::iHoursInDay; for (int iHr = iHrBeg; iHr <= iHrEnd; ++iHr) { auto &daylFacHr = illumMap.daylFac[iHr]; @@ -1277,7 +1277,7 @@ void CalcDayltgCoeffsMapPoints(EnergyPlusData &state, int const mapNum) // that do not depend on sun position. if (!state.dataSysVars->DetailedSolarTimestepIntegration) { ISunPos = 0; - for (int IHR = 1; IHR <= Constant::HoursInDay; ++IHR) { + for (int IHR = 1; IHR <= Constant::iHoursInDay; ++IHR) { // daylightingCtrlNum parameter is unused for map points FigureDayltgCoeffsAtPointsForSunPosition(state, 0, @@ -1376,7 +1376,7 @@ void CalcDayltgCoeffsMapPoints(EnergyPlusData &state, int const mapNum) // direct and inter-reflected illum components, then dividing by exterior horiz illum. // Also calculate corresponding glare factors. ILB = IL; - for (int IHR = 1; IHR <= Constant::HoursInDay; ++IHR) { + for (int IHR = 1; IHR <= Constant::iHoursInDay; ++IHR) { FigureMapPointDayltgFactorsToAddIllums(state, mapNum, ILB, IHR, IWin, loopwin, ICtrl); } // End of sun position loop, IHR } else { @@ -1760,7 +1760,7 @@ void FigureDayltgCoeffsAtPointsSetupForWindow(EnergyPlusData &state, } int iHrBeg = state.dataSysVars->DetailedSolarTimestepIntegration ? state.dataGlobal->HourOfDay : 1; - int iHrEnd = state.dataSysVars->DetailedSolarTimestepIntegration ? state.dataGlobal->HourOfDay : Constant::HoursInDay; + int iHrEnd = state.dataSysVars->DetailedSolarTimestepIntegration ? state.dataGlobal->HourOfDay : Constant::iHoursInDay; for (int iHr = iHrBeg; iHr <= iHrEnd; ++iHr) { // Initialize sky and sun components of direct illuminance (arrays EDIRSK, EDIRSU, EDIRSUdisk) @@ -2108,7 +2108,7 @@ void InitializeCFSDaylighting(EnergyPlusData &state, int zoneNum = dl->daylightControl(daylightCtrlNum).zoneIndex; Real64 AZVIEW = (dl->daylightControl(daylightCtrlNum).ViewAzimuthForGlare + state.dataHeatBal->Zone(zoneNum).RelNorth + state.dataHeatBal->BuildingAzimuth + state.dataHeatBal->BuildingRotationAppendixG) * - Constant::DegToRadians; + Constant::DegToRad; // Perform necessary calculations for window coordinates and vectors. This will be used to calculate centroids for // each window element @@ -2342,7 +2342,7 @@ void InitializeCFSStateData(EnergyPlusData &state, V = HitPt - Centroid; // vector array from window ctr to hit pt LeastHitDsq = V.magnitude_squared(); // dist^2 window ctr to hit pt TmpHSurfDSq(1, NReflSurf) = LeastHitDsq; - if (!surf2.HeatTransSurf && surf2.SchedShadowSurfIndex != 0) { + if (!surf2.HeatTransSurf && surf2.shadowSurfSched != nullptr) { TransRSurf = 1.0; // If a shadowing surface may have a scheduled transmittance, treat it here as completely transparent } else { TransRSurf = 0.0; @@ -2360,7 +2360,7 @@ void InitializeCFSStateData(EnergyPlusData &state, break; } } - if (!surf2.HeatTransSurf && surf2.SchedShadowSurfIndex == 0) { + if (!surf2.HeatTransSurf && surf2.shadowSurfSched == nullptr) { // The new hit is opaque, so we can drop all the hits further away TmpHSurfNo(J, NReflSurf) = JSurf; TmpHitPt(J, NReflSurf) = HitPt; @@ -2388,7 +2388,7 @@ void InitializeCFSStateData(EnergyPlusData &state, // A new closest hit. If it is opaque, drop the current hit list, // otherwise add it at the front LeastHitDsq = HitDsq; - if (!surf2.HeatTransSurf && surf2.SchedShadowSurfIndex != 0) { + if (!surf2.HeatTransSurf && surf2.shadowSurfSched != nullptr) { TransRSurf = 1.0; // New closest hit is transparent, keep the existing hit list for (int I = TotHits; I >= 1; --I) { TmpHSurfNo(I + 1, NReflSurf) = TmpHSurfNo(I, NReflSurf); @@ -3661,10 +3661,10 @@ void GetDaylightingParametersInput(EnergyPlusData &state) if (!dl->getDaylightingParametersInputFlag) return; dl->getDaylightingParametersInputFlag = false; - auto const &ipsc = state.dataIPShortCut; - ipsc->cCurrentModuleObject = "Daylighting:Controls"; + auto const &s_ipsc = state.dataIPShortCut; + s_ipsc->cCurrentModuleObject = "Daylighting:Controls"; bool ErrorsFound = false; - int TotDaylightingControls = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, ipsc->cCurrentModuleObject); + int TotDaylightingControls = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, s_ipsc->cCurrentModuleObject); if (TotDaylightingControls > 0) { dl->enclDaylight.allocate(state.dataViewFactor->NumOfSolarEnclosures); GetInputDayliteRefPt(state, ErrorsFound); @@ -3913,27 +3913,27 @@ void GetDaylightingParametersInput(EnergyPlusData &state) // RJH DElight Modification End - Calls to DElight preprocessing subroutines // TH 6/3/2010, added to report daylight factors - ipsc->cCurrentModuleObject = "Output:DaylightFactors"; - int NumReports = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, ipsc->cCurrentModuleObject); + s_ipsc->cCurrentModuleObject = "Output:DaylightFactors"; + int NumReports = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, s_ipsc->cCurrentModuleObject); if (NumReports > 0) { int NumNames; int NumNumbers; int IOStat; state.dataInputProcessing->inputProcessor->getObjectItem(state, - ipsc->cCurrentModuleObject, + s_ipsc->cCurrentModuleObject, 1, - ipsc->cAlphaArgs, + s_ipsc->cAlphaArgs, NumNames, - ipsc->rNumericArgs, + s_ipsc->rNumericArgs, NumNumbers, IOStat, - ipsc->lNumericFieldBlanks, - ipsc->lAlphaFieldBlanks, - ipsc->cAlphaFieldNames, - ipsc->cNumericFieldNames); - if (has_prefix(ipsc->cAlphaArgs(1), "SIZINGDAYS")) { + s_ipsc->lNumericFieldBlanks, + s_ipsc->lAlphaFieldBlanks, + s_ipsc->cAlphaFieldNames, + s_ipsc->cNumericFieldNames); + if (has_prefix(s_ipsc->cAlphaArgs(1), "SIZINGDAYS")) { dl->DFSReportSizingDays = true; - } else if (has_prefix(ipsc->cAlphaArgs(1), "ALLSHADOWCALCULATIONDAYS")) { + } else if (has_prefix(s_ipsc->cAlphaArgs(1), "ALLSHADOWCALCULATIONDAYS")) { dl->DFSReportAllShadowCalculationDays = true; } } @@ -3950,11 +3950,11 @@ void GetInputIlluminanceMap(EnergyPlusData &state, bool &ErrorsFound) Array1D_bool ZoneMsgDone; - Real64 CosBldgRelNorth = std::cos(-(state.dataHeatBal->BuildingAzimuth + state.dataHeatBal->BuildingRotationAppendixG) * Constant::DegToRadians); - Real64 SinBldgRelNorth = std::sin(-(state.dataHeatBal->BuildingAzimuth + state.dataHeatBal->BuildingRotationAppendixG) * Constant::DegToRadians); + Real64 CosBldgRelNorth = std::cos(-(state.dataHeatBal->BuildingAzimuth + state.dataHeatBal->BuildingRotationAppendixG) * Constant::DegToRad); + Real64 SinBldgRelNorth = std::sin(-(state.dataHeatBal->BuildingAzimuth + state.dataHeatBal->BuildingRotationAppendixG) * Constant::DegToRad); // these are only for Building Rotation for Appendix G when using world coordinate system - Real64 CosBldgRotAppGonly = std::cos(-state.dataHeatBal->BuildingRotationAppendixG * Constant::DegToRadians); - Real64 SinBldgRotAppGonly = std::sin(-state.dataHeatBal->BuildingRotationAppendixG * Constant::DegToRadians); + Real64 CosBldgRotAppGonly = std::cos(-state.dataHeatBal->BuildingRotationAppendixG * Constant::DegToRad); + Real64 SinBldgRotAppGonly = std::sin(-state.dataHeatBal->BuildingRotationAppendixG * Constant::DegToRad); bool doTransform = false; Real64 OldAspectRatio = 1.0; @@ -3963,9 +3963,9 @@ void GetInputIlluminanceMap(EnergyPlusData &state, bool &ErrorsFound) CheckForGeometricTransform(state, doTransform, OldAspectRatio, NewAspectRatio); auto &ip = state.dataInputProcessing->inputProcessor; - auto const &ipsc = state.dataIPShortCut; - ipsc->cCurrentModuleObject = "Output:IlluminanceMap"; - int TotIllumMaps = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, ipsc->cCurrentModuleObject); + auto const &s_ipsc = state.dataIPShortCut; + s_ipsc->cCurrentModuleObject = "Output:IlluminanceMap"; + int TotIllumMaps = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, s_ipsc->cCurrentModuleObject); dl->illumMaps.allocate(TotIllumMaps); @@ -3975,21 +3975,21 @@ void GetInputIlluminanceMap(EnergyPlusData &state, bool &ErrorsFound) int NumNumber; for (int MapNum = 1; MapNum <= TotIllumMaps; ++MapNum) { ip->getObjectItem(state, - ipsc->cCurrentModuleObject, + s_ipsc->cCurrentModuleObject, MapNum, - ipsc->cAlphaArgs, + s_ipsc->cAlphaArgs, NumAlpha, - ipsc->rNumericArgs, + s_ipsc->rNumericArgs, NumNumber, IOStat, - ipsc->lNumericFieldBlanks, - ipsc->lAlphaFieldBlanks, - ipsc->cAlphaFieldNames, - ipsc->cNumericFieldNames); + s_ipsc->lNumericFieldBlanks, + s_ipsc->lAlphaFieldBlanks, + s_ipsc->cAlphaFieldNames, + s_ipsc->cNumericFieldNames); auto &illumMap = dl->illumMaps(MapNum); - illumMap.Name = ipsc->cAlphaArgs(1); - int const zoneNum = Util::FindItemInList(ipsc->cAlphaArgs(2), state.dataHeatBal->Zone); + illumMap.Name = s_ipsc->cAlphaArgs(1); + int const zoneNum = Util::FindItemInList(s_ipsc->cAlphaArgs(2), state.dataHeatBal->Zone); if (zoneNum > 0) { illumMap.zoneIndex = zoneNum; // set enclosure index for first space in zone @@ -4001,8 +4001,8 @@ void GetInputIlluminanceMap(EnergyPlusData &state, bool &ErrorsFound) if (enclNum != state.dataHeatBal->space(spaceNum).solarEnclosureNum) { ShowSevereError(state, format("{}=\"{}\" All spaces in the zone must be in the same enclosure for daylighting illuminance maps.", - ipsc->cCurrentModuleObject, - ipsc->cAlphaArgs(1))); + s_ipsc->cCurrentModuleObject, + s_ipsc->cAlphaArgs(1))); ShowContinueError( state, format("Zone=\"{}\" spans multiple enclosures. Use a Space Name instead.", state.dataHeatBal->Zone(zoneNum).Name)); ErrorsFound = true; @@ -4014,10 +4014,10 @@ void GetInputIlluminanceMap(EnergyPlusData &state, bool &ErrorsFound) if (spaceNum == 0) { ShowSevereError(state, format("{}=\"{}\", invalid {}=\"{}\".", - ipsc->cCurrentModuleObject, - ipsc->cAlphaArgs(1), - ipsc->cAlphaFieldNames(2), - ipsc->cAlphaArgs(2))); + s_ipsc->cCurrentModuleObject, + s_ipsc->cAlphaArgs(1), + s_ipsc->cAlphaFieldNames(2), + s_ipsc->cAlphaArgs(2))); ErrorsFound = true; } else { illumMap.spaceIndex = spaceNum; @@ -4027,90 +4027,90 @@ void GetInputIlluminanceMap(EnergyPlusData &state, bool &ErrorsFound) } } - illumMap.Z = ipsc->rNumericArgs(1); - illumMap.Xmin = ipsc->rNumericArgs(2); - illumMap.Xmax = ipsc->rNumericArgs(3); - if (ipsc->rNumericArgs(2) > ipsc->rNumericArgs(3)) { - ShowSevereError(state, format("{}=\"{}\", invalid entry.", ipsc->cCurrentModuleObject, ipsc->cAlphaArgs(1))); + illumMap.Z = s_ipsc->rNumericArgs(1); + illumMap.Xmin = s_ipsc->rNumericArgs(2); + illumMap.Xmax = s_ipsc->rNumericArgs(3); + if (s_ipsc->rNumericArgs(2) > s_ipsc->rNumericArgs(3)) { + ShowSevereError(state, format("{}=\"{}\", invalid entry.", s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); ShowContinueError(state, format("...{} {:.2R} must be <= {} {:.2R}.", - ipsc->cNumericFieldNames(2), - ipsc->rNumericArgs(2), - ipsc->cNumericFieldNames(3), - ipsc->rNumericArgs(3))); + s_ipsc->cNumericFieldNames(2), + s_ipsc->rNumericArgs(2), + s_ipsc->cNumericFieldNames(3), + s_ipsc->rNumericArgs(3))); ErrorsFound = true; } - illumMap.Xnum = ipsc->rNumericArgs(4); + illumMap.Xnum = s_ipsc->rNumericArgs(4); illumMap.Xinc = (illumMap.Xnum != 1) ? ((illumMap.Xmax - illumMap.Xmin) / (illumMap.Xnum - 1)) : 0.0; - illumMap.Ymin = ipsc->rNumericArgs(5); - illumMap.Ymax = ipsc->rNumericArgs(6); - if (ipsc->rNumericArgs(5) > ipsc->rNumericArgs(6)) { - ShowSevereError(state, format("{}=\"{}\", invalid entry.", ipsc->cCurrentModuleObject, ipsc->cAlphaArgs(1))); + illumMap.Ymin = s_ipsc->rNumericArgs(5); + illumMap.Ymax = s_ipsc->rNumericArgs(6); + if (s_ipsc->rNumericArgs(5) > s_ipsc->rNumericArgs(6)) { + ShowSevereError(state, format("{}=\"{}\", invalid entry.", s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); ShowContinueError(state, format("...{} {:.2R} must be <= {} {:.2R}.", - ipsc->cNumericFieldNames(5), - ipsc->rNumericArgs(5), - ipsc->cNumericFieldNames(6), - ipsc->rNumericArgs(6))); + s_ipsc->cNumericFieldNames(5), + s_ipsc->rNumericArgs(5), + s_ipsc->cNumericFieldNames(6), + s_ipsc->rNumericArgs(6))); ErrorsFound = true; } - illumMap.Ynum = ipsc->rNumericArgs(7); + illumMap.Ynum = s_ipsc->rNumericArgs(7); illumMap.Yinc = (illumMap.Ynum != 1) ? ((illumMap.Ymax - illumMap.Ymin) / (illumMap.Ynum - 1)) : 0.0; if (illumMap.Xnum * illumMap.Ynum > MaxMapRefPoints) { - ShowSevereError(state, format("{}=\"{}\", too many map points specified.", ipsc->cCurrentModuleObject, ipsc->cAlphaArgs(1))); + ShowSevereError(state, format("{}=\"{}\", too many map points specified.", s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); ShowContinueError(state, format("...{}[{}] * {}[{}].= [{}] must be <= [{}].", - ipsc->cNumericFieldNames(4), + s_ipsc->cNumericFieldNames(4), illumMap.Xnum, - ipsc->cNumericFieldNames(7), + s_ipsc->cNumericFieldNames(7), illumMap.Ynum, illumMap.Xnum * illumMap.Ynum, MaxMapRefPoints)); ErrorsFound = true; } } // MapNum - ipsc->cCurrentModuleObject = "OutputControl:IlluminanceMap:Style"; - int MapStyleIn = ip->getNumObjectsFound(state, ipsc->cCurrentModuleObject); + s_ipsc->cCurrentModuleObject = "OutputControl:IlluminanceMap:Style"; + int MapStyleIn = ip->getNumObjectsFound(state, s_ipsc->cCurrentModuleObject); if (MapStyleIn == 0) { - ipsc->cAlphaArgs(1) = "COMMA"; + s_ipsc->cAlphaArgs(1) = "COMMA"; dl->MapColSep = DataStringGlobals::CharComma; // comma } else if (MapStyleIn == 1) { ip->getObjectItem(state, - ipsc->cCurrentModuleObject, + s_ipsc->cCurrentModuleObject, 1, - ipsc->cAlphaArgs, + s_ipsc->cAlphaArgs, NumAlpha, - ipsc->rNumericArgs, + s_ipsc->rNumericArgs, NumNumber, IOStat, - ipsc->lNumericFieldBlanks, - ipsc->lAlphaFieldBlanks, - ipsc->cAlphaFieldNames, - ipsc->cNumericFieldNames); - if (ipsc->cAlphaArgs(1) == "COMMA") { + s_ipsc->lNumericFieldBlanks, + s_ipsc->lAlphaFieldBlanks, + s_ipsc->cAlphaFieldNames, + s_ipsc->cNumericFieldNames); + if (s_ipsc->cAlphaArgs(1) == "COMMA") { dl->MapColSep = DataStringGlobals::CharComma; // comma - } else if (ipsc->cAlphaArgs(1) == "TAB") { + } else if (s_ipsc->cAlphaArgs(1) == "TAB") { dl->MapColSep = DataStringGlobals::CharTab; // tab - } else if (ipsc->cAlphaArgs(1) == "FIXED" || ipsc->cAlphaArgs(1) == "SPACE") { + } else if (s_ipsc->cAlphaArgs(1) == "FIXED" || s_ipsc->cAlphaArgs(1) == "SPACE") { dl->MapColSep = DataStringGlobals::CharSpace; // space } else { dl->MapColSep = DataStringGlobals::CharComma; // comma ShowWarningError(state, format("{}: invalid {}=\"{}\", Commas will be used to separate fields.", - ipsc->cCurrentModuleObject, - ipsc->cAlphaFieldNames(1), - ipsc->cAlphaArgs(1))); - ipsc->cAlphaArgs(1) = "COMMA"; + s_ipsc->cCurrentModuleObject, + s_ipsc->cAlphaFieldNames(1), + s_ipsc->cAlphaArgs(1))); + s_ipsc->cAlphaArgs(1) = "COMMA"; } } print(state.files.eio, "! ,#Maps,Style\n"); - ConvertCaseToLower(ipsc->cAlphaArgs(1), ipsc->cAlphaArgs(2)); - ipsc->cAlphaArgs(1).erase(1); - ipsc->cAlphaArgs(1) += ipsc->cAlphaArgs(2).substr(1); - print(state.files.eio, "Daylighting:Illuminance Maps,{},{}\n", TotIllumMaps, ipsc->cAlphaArgs(1)); + ConvertCaseToLower(s_ipsc->cAlphaArgs(1), s_ipsc->cAlphaArgs(2)); + s_ipsc->cAlphaArgs(1).erase(1); + s_ipsc->cAlphaArgs(1) += s_ipsc->cAlphaArgs(2).substr(1); + print(state.files.eio, "Daylighting:Illuminance Maps,{},{}\n", TotIllumMaps, s_ipsc->cAlphaArgs(1)); } // Check for illuminance maps associated with this zone @@ -4120,8 +4120,8 @@ void GetInputIlluminanceMap(EnergyPlusData &state, bool &ErrorsFound) auto &zone = state.dataHeatBal->Zone(illumMap.zoneIndex); // Calc cos and sin of Zone Relative North values for later use in transforming Reference Point coordinates - Real64 CosZoneRelNorth = std::cos(-zone.RelNorth * Constant::DegToRadians); - Real64 SinZoneRelNorth = std::sin(-zone.RelNorth * Constant::DegToRadians); + Real64 CosZoneRelNorth = std::cos(-zone.RelNorth * Constant::DegToRad); + Real64 SinZoneRelNorth = std::sin(-zone.RelNorth * Constant::DegToRad); if (illumMap.Xnum * illumMap.Ynum == 0) continue; @@ -4304,6 +4304,8 @@ void GetDaylightingControls(EnergyPlusData &state, bool &ErrorsFound) // MODIFIED Glazer - July 2016 - Move geometry transformation portion, rearrange input, allow more than three reference points // Obtain the user input data for Daylighting:Controls object in the input file. + static constexpr std::string_view routineName = "GetDaylightingControls"; + auto &dl = state.dataDayltg; int IOStat; @@ -4317,9 +4319,9 @@ void GetDaylightingControls(EnergyPlusData &state, bool &ErrorsFound) constexpr Real64 FractionTolerance(0.001); auto &ip = state.dataInputProcessing->inputProcessor; - auto const &ipsc = state.dataIPShortCut; - ipsc->cCurrentModuleObject = "Daylighting:Controls"; - int totDaylightingControls = ip->getNumObjectsFound(state, ipsc->cCurrentModuleObject); + auto const &s_ipsc = state.dataIPShortCut; + s_ipsc->cCurrentModuleObject = "Daylighting:Controls"; + int totDaylightingControls = ip->getNumObjectsFound(state, s_ipsc->cCurrentModuleObject); dl->daylightControl.allocate(totDaylightingControls); Array1D spaceHasDaylightingControl; spaceHasDaylightingControl.dimension(state.dataGlobal->numSpaces, false); @@ -4328,22 +4330,25 @@ void GetDaylightingControls(EnergyPlusData &state, bool &ErrorsFound) state.dataViewFactor->EnclSolInfo(enclNum).TotalEnclosureDaylRefPoints = 0; } for (int controlNum = 1; controlNum <= totDaylightingControls; ++controlNum) { - ipsc->cAlphaArgs = ""; - ipsc->rNumericArgs = 0.0; + s_ipsc->cAlphaArgs = ""; + s_ipsc->rNumericArgs = 0.0; ip->getObjectItem(state, - ipsc->cCurrentModuleObject, + s_ipsc->cCurrentModuleObject, controlNum, - ipsc->cAlphaArgs, + s_ipsc->cAlphaArgs, NumAlpha, - ipsc->rNumericArgs, + s_ipsc->rNumericArgs, NumNumber, IOStat, - ipsc->lNumericFieldBlanks, - ipsc->lAlphaFieldBlanks, - ipsc->cAlphaFieldNames, - ipsc->cNumericFieldNames); + s_ipsc->lNumericFieldBlanks, + s_ipsc->lAlphaFieldBlanks, + s_ipsc->cAlphaFieldNames, + s_ipsc->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)}; + auto &daylightControl = dl->daylightControl(controlNum); - daylightControl.Name = ipsc->cAlphaArgs(1); + daylightControl.Name = s_ipsc->cAlphaArgs(1); // Is it a zone or space name? int const zoneNum = Util::FindItemInList(state.dataIPShortCut->cAlphaArgs(2), state.dataHeatBal->Zone); @@ -4358,9 +4363,9 @@ void GetDaylightingControls(EnergyPlusData &state, bool &ErrorsFound) if (daylightControl.enclIndex != state.dataHeatBal->space(zoneSpaceNum).solarEnclosureNum) { ShowSevereError(state, format("{}: invalid {}=\"{}\" All spaces in the zone must be in the same enclosure for daylighting.", - ipsc->cCurrentModuleObject, - ipsc->cAlphaFieldNames(2), - ipsc->cAlphaArgs(2))); + s_ipsc->cCurrentModuleObject, + s_ipsc->cAlphaFieldNames(2), + s_ipsc->cAlphaArgs(2))); ErrorsFound = true; break; } @@ -4370,10 +4375,10 @@ void GetDaylightingControls(EnergyPlusData &state, bool &ErrorsFound) if (spaceHasDaylightingControl(zoneSpaceNum)) { ShowWarningError(state, format("{}=\"{}\" Space=\"{}\" already has a {} object assigned to it.", - ipsc->cCurrentModuleObject, + s_ipsc->cCurrentModuleObject, daylightControl.Name, state.dataHeatBal->space(zoneSpaceNum).Name, - ipsc->cCurrentModuleObject)); + s_ipsc->cCurrentModuleObject)); ShowContinueError(state, "This control will override the lighting power factor for this space."); } spaceHasDaylightingControl(zoneSpaceNum) = true; @@ -4381,7 +4386,7 @@ void GetDaylightingControls(EnergyPlusData &state, bool &ErrorsFound) } else { int const spaceNum = Util::FindItemInList(state.dataIPShortCut->cAlphaArgs(2), state.dataHeatBal->space); if (spaceNum == 0) { - ShowSevereError(state, format("{}: invalid {}=\"{}\".", ipsc->cCurrentModuleObject, ipsc->cAlphaFieldNames(2), ipsc->cAlphaArgs(2))); + ShowSevereError(state, format("{}: invalid {}=\"{}\".", s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2))); ErrorsFound = true; continue; } else { @@ -4392,10 +4397,10 @@ void GetDaylightingControls(EnergyPlusData &state, bool &ErrorsFound) if (spaceHasDaylightingControl(spaceNum)) { ShowWarningError(state, format("{}=\"{}\" Space=\"{}\" already has a {} object assigned to it.", - ipsc->cCurrentModuleObject, + s_ipsc->cCurrentModuleObject, daylightControl.Name, state.dataHeatBal->space(spaceNum).Name, - ipsc->cCurrentModuleObject)); + s_ipsc->cCurrentModuleObject)); ShowContinueError(state, "This control will override the lighting power factor for this space."); } spaceHasDaylightingControl(spaceNum) = true; @@ -4405,85 +4410,69 @@ void GetDaylightingControls(EnergyPlusData &state, bool &ErrorsFound) dl->enclDaylight(daylightControl.enclIndex).daylightControlIndexes.emplace_back(controlNum); daylightControl.ZoneName = state.dataHeatBal->Zone(daylightControl.zoneIndex).Name; - if (ipsc->lAlphaFieldBlanks(3)) { + if (s_ipsc->lAlphaFieldBlanks(3)) { daylightControl.DaylightMethod = DaylightingMethod::SplitFlux; } else { daylightControl.DaylightMethod = - static_cast(getEnumValue(DaylightingMethodNamesUC, Util::makeUPPER(ipsc->cAlphaArgs(3)))); + static_cast(getEnumValue(DaylightingMethodNamesUC, Util::makeUPPER(s_ipsc->cAlphaArgs(3)))); if (daylightControl.DaylightMethod == DaylightingMethod::Invalid) { daylightControl.DaylightMethod = DaylightingMethod::SplitFlux; ShowWarningError(state, format("Invalid {} = {}, occurs in {}object for {}=\"{}", - ipsc->cAlphaFieldNames(3), - ipsc->cAlphaArgs(3), - ipsc->cCurrentModuleObject, - ipsc->cCurrentModuleObject, - ipsc->cAlphaArgs(1))); + s_ipsc->cAlphaFieldNames(3), + s_ipsc->cAlphaArgs(3), + s_ipsc->cCurrentModuleObject, + s_ipsc->cCurrentModuleObject, + s_ipsc->cAlphaArgs(1))); ShowContinueError(state, "SplitFlux assumed, and the simulation continues."); } } dl->enclDaylight(daylightControl.enclIndex).hasSplitFluxDaylighting |= (daylightControl.DaylightMethod == DaylightingMethod::SplitFlux); - if (!ipsc->lAlphaFieldBlanks(4)) { // Field: Availability Schedule Name - daylightControl.AvailSchedNum = ScheduleManager::GetScheduleIndex(state, ipsc->cAlphaArgs(4)); - if (daylightControl.AvailSchedNum == 0) { - ShowWarningError(state, - format("Invalid {} = {}, occurs in {}object for {}=\"{}", - ipsc->cAlphaFieldNames(4), - ipsc->cAlphaArgs(4), - ipsc->cCurrentModuleObject, - ipsc->cCurrentModuleObject, - ipsc->cAlphaArgs(1))); - ShowContinueError(state, "Schedule was not found so controls will always be available, and the simulation continues."); - daylightControl.AvailSchedNum = ScheduleManager::ScheduleAlwaysOn; - } - } else { - daylightControl.AvailSchedNum = ScheduleManager::ScheduleAlwaysOn; + if (s_ipsc->lAlphaFieldBlanks(4)) { // Field: Availability Schedule Name + daylightControl.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((daylightControl.availSched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(4))) == nullptr) { + ShowWarningItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(4), s_ipsc->cAlphaArgs(4), + "Schedule was not found so controls will always be available, and the simulation continues."); + daylightControl.availSched = Sched::GetScheduleAlwaysOn(state); } - daylightControl.LightControlType = static_cast(getEnumValue(LtgCtrlTypeNamesUC, Util::makeUPPER(ipsc->cAlphaArgs(5)))); + daylightControl.LightControlType = static_cast(getEnumValue(LtgCtrlTypeNamesUC, s_ipsc->cAlphaArgs(5))); if (daylightControl.LightControlType == LtgCtrlType::Invalid) { - ShowWarningError(state, - format("Invalid {} = {}, occurs in {}object for {}=\"{}", - ipsc->cAlphaFieldNames(5), - ipsc->cAlphaArgs(5), - ipsc->cCurrentModuleObject, - ipsc->cCurrentModuleObject, - ipsc->cAlphaArgs(1))); - ShowContinueError(state, "Continuous assumed, and the simulation continues."); - } - - daylightControl.MinPowerFraction = ipsc->rNumericArgs(1); // Field: Minimum Input Power Fraction for Continuous Dimming Control - daylightControl.MinLightFraction = ipsc->rNumericArgs(2); // Field: Minimum Light Output Fraction for Continuous Dimming Control - daylightControl.LightControlSteps = ipsc->rNumericArgs(3); // Field: Number of Stepped Control Steps + ShowWarningInvalidKey(state, eoh, s_ipsc->cAlphaFieldNames(5), s_ipsc->cAlphaArgs(5), "Continuous assumed, and the simulation continues."); + } + + daylightControl.MinPowerFraction = s_ipsc->rNumericArgs(1); // Field: Minimum Input Power Fraction for Continuous Dimming Control + daylightControl.MinLightFraction = s_ipsc->rNumericArgs(2); // Field: Minimum Light Output Fraction for Continuous Dimming Control + daylightControl.LightControlSteps = s_ipsc->rNumericArgs(3); // Field: Number of Stepped Control Steps daylightControl.LightControlProbability = - ipsc->rNumericArgs(4); // Field: Probability Lighting will be Reset When Needed in Manual Stepped Control + s_ipsc->rNumericArgs(4); // Field: Probability Lighting will be Reset When Needed in Manual Stepped Control - if (!ipsc->lAlphaFieldBlanks(6)) { // Field: Glare Calculation Daylighting Reference Point Name - daylightControl.glareRefPtNumber = Util::FindItemInList(ipsc->cAlphaArgs(6), + if (!s_ipsc->lAlphaFieldBlanks(6)) { // Field: Glare Calculation Daylighting Reference Point Name + daylightControl.glareRefPtNumber = Util::FindItemInList(s_ipsc->cAlphaArgs(6), dl->DaylRefPt, &RefPointData::Name); // Field: Glare Calculation Daylighting Reference Point Name if (daylightControl.glareRefPtNumber == 0) { ShowSevereError(state, format("{}: invalid {}=\"{}\" for object named: {}", - ipsc->cCurrentModuleObject, - ipsc->cAlphaFieldNames(6), - ipsc->cAlphaArgs(6), - ipsc->cAlphaArgs(1))); + s_ipsc->cCurrentModuleObject, + s_ipsc->cAlphaFieldNames(6), + s_ipsc->cAlphaArgs(6), + s_ipsc->cAlphaArgs(1))); ErrorsFound = true; continue; } } else if (daylightControl.DaylightMethod == DaylightingMethod::SplitFlux) { - ShowWarningError(state, format("No {} provided for object named: {}", ipsc->cAlphaFieldNames(6), ipsc->cAlphaArgs(1))); + ShowWarningError(state, format("No {} provided for object named: {}", s_ipsc->cAlphaFieldNames(6), s_ipsc->cAlphaArgs(1))); ShowContinueError(state, "No glare calculation performed, and the simulation continues."); } // Field: Glare Calculation Azimuth Angle of View Direction Clockwise from Zone y-Axis - daylightControl.ViewAzimuthForGlare = !ipsc->lNumericFieldBlanks(5) ? ipsc->rNumericArgs(5) : 0.0; + daylightControl.ViewAzimuthForGlare = !s_ipsc->lNumericFieldBlanks(5) ? s_ipsc->rNumericArgs(5) : 0.0; - daylightControl.MaxGlareallowed = ipsc->rNumericArgs(6); // Field: Maximum Allowable Discomfort Glare Index - daylightControl.DElightGriddingResolution = ipsc->rNumericArgs(7); // Field: DElight Gridding Resolution + daylightControl.MaxGlareallowed = s_ipsc->rNumericArgs(6); // Field: Maximum Allowable Discomfort Glare Index + daylightControl.DElightGriddingResolution = s_ipsc->rNumericArgs(7); // Field: DElight Gridding Resolution int curTotalDaylRefPts = NumAlpha - 6; // first six alpha fields are not part of extensible group daylightControl.TotalDaylRefPoints = curTotalDaylRefPts; @@ -4493,12 +4482,12 @@ void GetDaylightingControls(EnergyPlusData &state, bool &ErrorsFound) if ((NumNumber - 7) / 2 != daylightControl.TotalDaylRefPoints) { ShowSevereError(state, format("{}The number of extensible numeric fields and alpha fields is inconsistent for: {}", - ipsc->cCurrentModuleObject, - ipsc->cAlphaArgs(1))); + s_ipsc->cCurrentModuleObject, + s_ipsc->cAlphaArgs(1))); ShowContinueError(state, format("For each field: {} there needs to be the following fields: Fraction Controlled by Reference Point and " "Illuminance Setpoint at Reference Point", - ipsc->cAlphaFieldNames(NumAlpha))); + s_ipsc->cAlphaFieldNames(NumAlpha))); ErrorsFound = true; } @@ -4512,21 +4501,21 @@ void GetDaylightingControls(EnergyPlusData &state, bool &ErrorsFound) for (int refPtNum = 1; refPtNum <= curTotalDaylRefPts; ++refPtNum) { auto &refPt = daylightControl.refPts(refPtNum); refPt.num = - Util::FindItemInList(ipsc->cAlphaArgs(6 + refPtNum), dl->DaylRefPt, &RefPointData::Name); // Field: Daylighting Reference Point Name + Util::FindItemInList(s_ipsc->cAlphaArgs(6 + refPtNum), dl->DaylRefPt, &RefPointData::Name); // Field: Daylighting Reference Point Name if (refPt.num == 0) { ShowSevereError(state, format("{}: invalid {}=\"{}\" for object named: {}", - ipsc->cCurrentModuleObject, - ipsc->cAlphaFieldNames(6 + refPtNum), - ipsc->cAlphaArgs(6 + refPtNum), - ipsc->cAlphaArgs(1))); + s_ipsc->cCurrentModuleObject, + s_ipsc->cAlphaFieldNames(6 + refPtNum), + s_ipsc->cAlphaArgs(6 + refPtNum), + s_ipsc->cAlphaArgs(1))); ErrorsFound = true; continue; } else { ++countRefPts; } - refPt.fracZoneDaylit = ipsc->rNumericArgs(6 + refPtNum * 2); // Field: Fraction Controlled by Reference Point - refPt.illumSetPoint = ipsc->rNumericArgs(7 + refPtNum * 2); // Field: Illuminance Setpoint at Reference Point + refPt.fracZoneDaylit = s_ipsc->rNumericArgs(6 + refPtNum * 2); // Field: Fraction Controlled by Reference Point + refPt.illumSetPoint = s_ipsc->rNumericArgs(7 + refPtNum * 2); // Field: Illuminance Setpoint at Reference Point if (daylightControl.DaylightMethod == DaylightingMethod::SplitFlux) { SetupOutputVariable(state, @@ -4562,7 +4551,7 @@ void GetDaylightingControls(EnergyPlusData &state, bool &ErrorsFound) // Register Error if 0 DElight RefPts have been input for valid DElight object if (countRefPts < 1) { - ShowSevereError(state, format("No Reference Points input for {} zone ={}", ipsc->cCurrentModuleObject, daylightControl.ZoneName)); + ShowSevereError(state, format("No Reference Points input for {} zone ={}", s_ipsc->cCurrentModuleObject, daylightControl.ZoneName)); ErrorsFound = true; } @@ -4575,14 +4564,14 @@ void GetDaylightingControls(EnergyPlusData &state, bool &ErrorsFound) ShowWarningError(state, "GetDaylightingControls: Fraction of zone or space controlled by the Daylighting reference points is < 1.0."); ShowContinueError(state, format("..discovered in {}=\"{}\", only {:.3R} of the zone or space is controlled.", - ipsc->cCurrentModuleObject, + s_ipsc->cCurrentModuleObject, daylightControl.Name, sumFracs)); } else if ((sumFracs - 1.0) > FractionTolerance) { ShowSevereError(state, "GetDaylightingControls: Fraction of zone or space controlled by the Daylighting reference points is > 1.0."); ShowContinueError(state, format("..discovered in {}=\"{}\", trying to control {:.3R} of the zone or space.", - ipsc->cCurrentModuleObject, + s_ipsc->cCurrentModuleObject, daylightControl.Name, sumFracs)); ErrorsFound = true; @@ -4590,7 +4579,7 @@ void GetDaylightingControls(EnergyPlusData &state, bool &ErrorsFound) if (daylightControl.LightControlType == LtgCtrlType::Stepped && daylightControl.LightControlSteps <= 0) { ShowWarningError(state, "GetDaylightingControls: For Stepped Control, the number of steps must be > 0"); - ShowContinueError(state, format("..discovered in \"{}\" for Zone=\"{}\", will use 1", ipsc->cCurrentModuleObject, ipsc->cAlphaArgs(2))); + ShowContinueError(state, format("..discovered in \"{}\" for Zone=\"{}\", will use 1", s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(2))); daylightControl.LightControlSteps = 1; } SetupOutputVariable(state, @@ -4613,11 +4602,11 @@ void GeometryTransformForDaylighting(EnergyPlusData &state) auto &s_surf = state.dataSurface; // Calc cos and sin of Building Relative North values for later use in transforming Reference Point coordinates - Real64 CosBldgRelNorth = std::cos(-(state.dataHeatBal->BuildingAzimuth + state.dataHeatBal->BuildingRotationAppendixG) * Constant::DegToRadians); - Real64 SinBldgRelNorth = std::sin(-(state.dataHeatBal->BuildingAzimuth + state.dataHeatBal->BuildingRotationAppendixG) * Constant::DegToRadians); + Real64 CosBldgRelNorth = std::cos(-(state.dataHeatBal->BuildingAzimuth + state.dataHeatBal->BuildingRotationAppendixG) * Constant::DegToRad); + Real64 SinBldgRelNorth = std::sin(-(state.dataHeatBal->BuildingAzimuth + state.dataHeatBal->BuildingRotationAppendixG) * Constant::DegToRad); // these are only for Building Rotation for Appendix G when using world coordinate system - Real64 CosBldgRotAppGonly = std::cos(-state.dataHeatBal->BuildingRotationAppendixG * Constant::DegToRadians); - Real64 SinBldgRotAppGonly = std::sin(-state.dataHeatBal->BuildingRotationAppendixG * Constant::DegToRadians); + Real64 CosBldgRotAppGonly = std::cos(-state.dataHeatBal->BuildingRotationAppendixG * Constant::DegToRad); + Real64 SinBldgRotAppGonly = std::sin(-state.dataHeatBal->BuildingRotationAppendixG * Constant::DegToRad); bool doTransform = false; Real64 OldAspectRatio = 1.0; @@ -4628,8 +4617,8 @@ void GeometryTransformForDaylighting(EnergyPlusData &state) auto &zone = state.dataHeatBal->Zone(daylCntrl.zoneIndex); // Calc cos and sin of Zone Relative North values for later use in transforming Reference Point coordinates - Real64 CosZoneRelNorth = std::cos(-zone.RelNorth * Constant::DegToRadians); - Real64 SinZoneRelNorth = std::sin(-zone.RelNorth * Constant::DegToRadians); + Real64 CosZoneRelNorth = std::cos(-zone.RelNorth * Constant::DegToRad); + Real64 SinZoneRelNorth = std::sin(-zone.RelNorth * Constant::DegToRad); Real64 rLightLevel = InternalHeatGains::GetDesignLightingLevelForZone(state, daylCntrl.zoneIndex); InternalHeatGains::CheckLightsReplaceableMinMaxForZone(state, daylCntrl.zoneIndex); @@ -4738,47 +4727,47 @@ void GetInputDayliteRefPt(EnergyPlusData &state, bool &ErrorsFound) // Glazer - July 2016 auto &dl = state.dataDayltg; auto &ip = state.dataInputProcessing->inputProcessor; - auto const &ipsc = state.dataIPShortCut; - ipsc->cCurrentModuleObject = "Daylighting:ReferencePoint"; + auto const &s_ipsc = state.dataIPShortCut; + s_ipsc->cCurrentModuleObject = "Daylighting:ReferencePoint"; int RefPtNum = 0; int IOStat; int NumAlpha; int NumNumber; - int TotRefPoints = ip->getNumObjectsFound(state, ipsc->cCurrentModuleObject); + int TotRefPoints = ip->getNumObjectsFound(state, s_ipsc->cCurrentModuleObject); dl->DaylRefPt.allocate(TotRefPoints); for (auto &pt : dl->DaylRefPt) { ip->getObjectItem(state, - ipsc->cCurrentModuleObject, + s_ipsc->cCurrentModuleObject, ++RefPtNum, - ipsc->cAlphaArgs, + s_ipsc->cAlphaArgs, NumAlpha, - ipsc->rNumericArgs, + s_ipsc->rNumericArgs, NumNumber, IOStat, - ipsc->lNumericFieldBlanks, - ipsc->lAlphaFieldBlanks, - ipsc->cAlphaFieldNames, - ipsc->cNumericFieldNames); - pt.Name = ipsc->cAlphaArgs(1); - pt.ZoneNum = Util::FindItemInList(ipsc->cAlphaArgs(2), state.dataHeatBal->Zone); + s_ipsc->lNumericFieldBlanks, + s_ipsc->lAlphaFieldBlanks, + s_ipsc->cAlphaFieldNames, + s_ipsc->cNumericFieldNames); + pt.Name = s_ipsc->cAlphaArgs(1); + pt.ZoneNum = Util::FindItemInList(s_ipsc->cAlphaArgs(2), state.dataHeatBal->Zone); if (pt.ZoneNum == 0) { - int spaceNum = Util::FindItemInList(ipsc->cAlphaArgs(2), state.dataHeatBal->space); + int spaceNum = Util::FindItemInList(s_ipsc->cAlphaArgs(2), state.dataHeatBal->space); if (spaceNum == 0) { ShowSevereError(state, format("{}=\"{}\", invalid {}=\"{}\".", - ipsc->cCurrentModuleObject, - ipsc->cAlphaArgs(1), - ipsc->cAlphaFieldNames(2), - ipsc->cAlphaArgs(2))); + s_ipsc->cCurrentModuleObject, + s_ipsc->cAlphaArgs(1), + s_ipsc->cAlphaFieldNames(2), + s_ipsc->cAlphaArgs(2))); ErrorsFound = true; } else { pt.ZoneNum = state.dataHeatBal->space(spaceNum).zoneNum; } } - pt.coords = {ipsc->rNumericArgs(1), ipsc->rNumericArgs(2), ipsc->rNumericArgs(3)}; + pt.coords = {s_ipsc->rNumericArgs(1), s_ipsc->rNumericArgs(2), s_ipsc->rNumericArgs(3)}; } } @@ -4894,32 +4883,32 @@ void GetLightWellData(EnergyPlusData &state, bool &ErrorsFound) // If errors fou auto &ip = state.dataInputProcessing->inputProcessor; auto &s_surf = state.dataSurface; - auto const &ipsc = state.dataIPShortCut; + auto const &s_ipsc = state.dataIPShortCut; // Get the total number of Light Well objects - ipsc->cCurrentModuleObject = "DaylightingDevice:LightWell"; - TotLightWells = ip->getNumObjectsFound(state, ipsc->cCurrentModuleObject); + s_ipsc->cCurrentModuleObject = "DaylightingDevice:LightWell"; + TotLightWells = ip->getNumObjectsFound(state, s_ipsc->cCurrentModuleObject); if (TotLightWells == 0) return; for (int loop = 1; loop <= TotLightWells; ++loop) { ip->getObjectItem(state, - ipsc->cCurrentModuleObject, + s_ipsc->cCurrentModuleObject, loop, - ipsc->cAlphaArgs, + s_ipsc->cAlphaArgs, NumAlpha, - ipsc->rNumericArgs, + s_ipsc->rNumericArgs, NumProp, IOStat, - ipsc->lNumericFieldBlanks, - ipsc->lAlphaFieldBlanks, - ipsc->cAlphaFieldNames, - ipsc->cNumericFieldNames); + s_ipsc->lNumericFieldBlanks, + s_ipsc->lAlphaFieldBlanks, + s_ipsc->cAlphaFieldNames, + s_ipsc->cNumericFieldNames); - int SurfNum = Util::FindItemInList(ipsc->cAlphaArgs(1), s_surf->Surface); + int SurfNum = Util::FindItemInList(s_ipsc->cAlphaArgs(1), s_surf->Surface); if (SurfNum == 0) { ShowSevereError(state, - format("{}: invalid {}=\"{}\" not found.", ipsc->cCurrentModuleObject, ipsc->cAlphaFieldNames(1), ipsc->cAlphaArgs(1))); + format("{}: invalid {}=\"{}\" not found.", s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaFieldNames(1), s_ipsc->cAlphaArgs(1))); ErrorsFound = true; continue; } @@ -4932,22 +4921,22 @@ void GetLightWellData(EnergyPlusData &state, bool &ErrorsFound) // If errors fou ShowSevereError( state, format( - "{}: invalid {}=\"{}\" - not an exterior window.", ipsc->cCurrentModuleObject, ipsc->cAlphaFieldNames(1), ipsc->cAlphaArgs(1))); + "{}: invalid {}=\"{}\" - not an exterior window.", s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaFieldNames(1), s_ipsc->cAlphaArgs(1))); ErrorsFound = true; continue; } // Associated surface is an exterior window; calculate light well efficiency. surfWin.lightWellEff = 1.0; - Real64 HeightWell = ipsc->rNumericArgs(1); // Well height (from window to bottom of well) (m) - Real64 PerimWell = ipsc->rNumericArgs(2); // Well perimeter (at bottom of well) (m) - Real64 AreaWell = ipsc->rNumericArgs(3); // Well area (at bottom of well) (m2) - Real64 VisReflWell = ipsc->rNumericArgs(4); // Area-weighted visible reflectance of well walls + Real64 HeightWell = s_ipsc->rNumericArgs(1); // Well height (from window to bottom of well) (m) + Real64 PerimWell = s_ipsc->rNumericArgs(2); // Well perimeter (at bottom of well) (m) + Real64 AreaWell = s_ipsc->rNumericArgs(3); // Well area (at bottom of well) (m2) + Real64 VisReflWell = s_ipsc->rNumericArgs(4); // Area-weighted visible reflectance of well walls // Warning if light well area is less than window area if (AreaWell < (surf.Area + s_surf->SurfWinDividerArea(SurfNum) - 0.1)) { ShowSevereError(state, - format("{}: invalid {}=\"{}\" - Areas.", ipsc->cCurrentModuleObject, ipsc->cAlphaFieldNames(1), ipsc->cAlphaArgs(1))); + format("{}: invalid {}=\"{}\" - Areas.", s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaFieldNames(1), s_ipsc->cAlphaArgs(1))); ShowContinueError(state, format("has Area of Bottom of Well={:.1R} that is less than window area={:.1R}", surf.Area, AreaWell)); } @@ -5193,8 +5182,7 @@ Real64 DayltgHitObstruction(EnergyPlusData &state, hit = PierceSurface(state, ISurf, R1, RN, DayltgHitObstructionHP); if (hit) { // Shading surface is hit // Get solar transmittance of the shading surface - Real64 const Trans( - surface.SchedShadowSurfIndex > 0 ? ScheduleManager::LookUpScheduleValue(state, surface.SchedShadowSurfIndex, IHOUR, 1) : 0.0); + Real64 const Trans = (surface.shadowSurfSched != nullptr) ? surface.shadowSurfSched->getHrTsVal(state, IHOUR, 1) : 0.0; if (Trans < 1.e-6) { ObTrans = 0.0; break; @@ -5225,8 +5213,7 @@ Real64 DayltgHitObstruction(EnergyPlusData &state, hit = PierceSurface(surface, R1, RN, HP); if (hit) { // Shading surface is hit // Get solar transmittance of the shading surface - Real64 const Trans( - surface.SchedShadowSurfIndex > 0 ? ScheduleManager::LookUpScheduleValue(state, surface.SchedShadowSurfIndex, IHOUR, 1) : 0.0); + Real64 const Trans = (surface.shadowSurfSched != nullptr) ? surface.shadowSurfSched->getHrTsVal(state, IHOUR, 1) : 0.0; if (Trans < 1.e-6) { ObTrans = 0.0; return true; @@ -5639,7 +5626,7 @@ void manageDaylighting(EnergyPlusData &state) } } DayltgElecLightingControl(state); - } else if (dl->mapResultsToReport && state.dataGlobal->TimeStep == state.dataGlobal->NumOfTimeStepInHour) { + } else if (dl->mapResultsToReport && state.dataGlobal->TimeStep == state.dataGlobal->TimeStepsInHour) { for (int MapNum = 1; MapNum <= (int)dl->illumMaps.size(); ++MapNum) { ReportIllumMap(state, MapNum); } @@ -6713,7 +6700,7 @@ void DayltgElecLightingControl(EnergyPlusData &state) Real64 ZFTOT = 0.0; // check if scheduled to be available - if (ScheduleManager::GetCurrentScheduleValue(state, thisDayltgCtrl.AvailSchedNum) > 0.0) { + if (thisDayltgCtrl.availSched->getCurrentVal() > 0.0) { // Loop over reference points for (int IL = 1; IL <= thisDayltgCtrl.TotalDaylRefPoints; ++IL) { @@ -6806,14 +6793,14 @@ void DayltgElecLightingControl(EnergyPlusData &state) auto &illumMap = dl->illumMaps(mapNum); if (state.dataGlobal->TimeStep == 1) dl->mapResultsToReport = false; for (auto &refPt : illumMap.refPts) { - refPt.lumsHr[iLum_Illum] += refPt.lums[iLum_Illum] / double(state.dataGlobal->NumOfTimeStepInHour); + refPt.lumsHr[iLum_Illum] += refPt.lums[iLum_Illum] / double(state.dataGlobal->TimeStepsInHour); if (refPt.lumsHr[iLum_Illum] > 0.0) { dl->mapResultsToReport = true; dl->mapResultsReported = true; } } ReportIllumMap(state, mapNum); - if (state.dataGlobal->TimeStep == state.dataGlobal->NumOfTimeStepInHour) { + if (state.dataGlobal->TimeStep == state.dataGlobal->TimeStepsInHour) { for (auto &refPt : illumMap.refPts) { refPt.lumsHr[iLum_Illum] = refPt.lums[iLum_Illum] = 0.0; } @@ -8404,8 +8391,8 @@ Real64 ProfileAngle(EnergyPlusData &state, Real64 AzimSun = std::atan2(CosDirSun.y, CosDirSun.x); // Sun azimuth (radians) return std::atan(std::sin(ElevSun) / std::abs(std::cos(ElevSun) * std::cos(AzimWin - AzimSun))) - ElevWin; } else { // Profile angle for vertical structures - Real64 ElevWin = Constant::PiOvr2 - surf.Tilt * Constant::DegToRadians; - Real64 AzimWin = surf.Azimuth * Constant::DegToRadians; // 7952 + Real64 ElevWin = Constant::PiOvr2 - surf.Tilt * Constant::DegToRad; + Real64 AzimWin = surf.Azimuth * Constant::DegToRad; // 7952 Real64 AzimSun = std::atan2(CosDirSun.x, CosDirSun.y); // 7952 Real64 ProfileAng; @@ -8897,7 +8884,7 @@ void ReportIllumMap(EnergyPlusData &state, int const MapNum) } if (!state.dataGlobal->WarmupFlag) { - if (state.dataGlobal->TimeStep == state.dataGlobal->NumOfTimeStepInHour) { // Report only hourly + if (state.dataGlobal->TimeStep == state.dataGlobal->TimeStepsInHour) { // Report only hourly int linelen = 0; // Write X scale column header @@ -9323,7 +9310,7 @@ void DayltgSetupAdjZoneListsAndPointers(EnergyPlusData &state) for (int controlNum : thisEnclDaylight.daylightControlIndexes) { auto &thisDayltgCtrl = dl->daylightControl(controlNum); int refSize = thisDayltgCtrl.TotalDaylRefPoints; - for (int iHr = 1; iHr <= (int)Constant::HoursInDay; ++iHr) { + for (int iHr = 1; iHr <= Constant::iHoursInDay; ++iHr) { thisDayltgCtrl.daylFac[iHr].allocate(winSize, refSize); } } @@ -9359,16 +9346,16 @@ void DayltgSetupAdjZoneListsAndPointers(EnergyPlusData &state) } } - for (int iHr = 1; iHr <= (int)Constant::HoursInDay; ++iHr) { + for (int iHr = 1; iHr <= Constant::iHoursInDay; ++iHr) { illumMap.daylFac[iHr].allocate(numExtWin, illumMap.TotalMapRefPoints); } } // End of map loop - dl->dirIllum.allocate(Constant::HoursInDay); - dl->reflIllum.allocate(Constant::HoursInDay); - dl->winLum.allocate(Constant::HoursInDay); - dl->avgWinLum.allocate(Constant::HoursInDay); + dl->dirIllum.allocate(Constant::iHoursInDay); + dl->reflIllum.allocate(Constant::iHoursInDay); + dl->winLum.allocate(Constant::iHoursInDay); + dl->avgWinLum.allocate(Constant::iHoursInDay); static constexpr std::string_view Format_700("! , Enclosure Name, Number of Exterior Windows, " "Number of Exterior Windows in Adjacent Enclosures\n"); @@ -9673,7 +9660,7 @@ void CheckForGeometricTransform(EnergyPlusData &state, bool &doTransform, Real64 NewAspectRatio = 1.0; auto &ip = state.dataInputProcessing->inputProcessor; - auto const &ipsc = state.dataIPShortCut; + auto const &s_ipsc = state.dataIPShortCut; auto &s_surf = state.dataSurface; if (ip->getNumObjectsFound(state, CurrentModuleObject) == 1) { @@ -9688,15 +9675,15 @@ void CheckForGeometricTransform(EnergyPlusData &state, bool &doTransform, Real64 rNumerics, NNum, IOStat, - ipsc->lNumericFieldBlanks, - ipsc->lAlphaFieldBlanks, - ipsc->cAlphaFieldNames, - ipsc->cNumericFieldNames); + s_ipsc->lNumericFieldBlanks, + s_ipsc->lAlphaFieldBlanks, + s_ipsc->cAlphaFieldNames, + s_ipsc->cNumericFieldNames); OldAspectRatio = rNumerics(1); NewAspectRatio = rNumerics(2); std::string transformPlane = cAlphas(1); if (transformPlane != "XY") { - ShowWarningError(state, format("{}: invalid {}=\"{}...ignored.", CurrentModuleObject, ipsc->cAlphaFieldNames(1), cAlphas(1))); + ShowWarningError(state, format("{}: invalid {}=\"{}...ignored.", CurrentModuleObject, s_ipsc->cAlphaFieldNames(1), cAlphas(1))); } doTransform = true; s_surf->AspectTransform = true; diff --git a/src/EnergyPlus/DaylightingManager.hh b/src/EnergyPlus/DaylightingManager.hh index 66c77d7fbc8..fcbd11dd9e0 100644 --- a/src/EnergyPlus/DaylightingManager.hh +++ b/src/EnergyPlus/DaylightingManager.hh @@ -518,13 +518,13 @@ struct DaylightingData : BaseGlobalStruct int maxNumRefPtInAnyEncl = 0; // The most number of reference points that any single enclosure has Dayltg::SunAngles sunAngles = Dayltg::SunAngles(); - std::array sunAnglesHr = {Dayltg::SunAngles()}; + std::array sunAnglesHr = {Dayltg::SunAngles()}; // In the following I,J,K arrays: // I = 1 for clear sky, 2 for clear turbid, 3 for intermediate, 4 for overcast; // J = 1 for bare window, 2 - 12 for shaded; // K = sun position index. - std::array horIllum = { + std::array horIllum = { Dayltg::Illums()}; // Horizontal illuminance from sky, by sky type, for each hour of the day Array1D> dirIllum; // Sky-related component of direct illuminance Array1D> reflIllum; // Sky-related portion of internally reflected illuminance @@ -568,6 +568,10 @@ struct DaylightingData : BaseGlobalStruct Array1D YValue; Array2D IllumValue; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/DemandManager.cc b/src/EnergyPlus/DemandManager.cc index 34d0da88b48..43661852f40 100644 --- a/src/EnergyPlus/DemandManager.cc +++ b/src/EnergyPlus/DemandManager.cc @@ -210,7 +210,7 @@ void SimulateDemandManagerList(EnergyPlusData &state, auto &demandManagerList = state.dataDemandManager->DemandManagerList(ListNum); - demandManagerList.ScheduledLimit = ScheduleManager::GetCurrentScheduleValue(state, demandManagerList.LimitSchedule); + demandManagerList.ScheduledLimit = demandManagerList.limitSched->getCurrentVal(); demandManagerList.DemandLimit = demandManagerList.ScheduledLimit * demandManagerList.SafetyFraction; demandManagerList.MeterDemand = @@ -221,15 +221,7 @@ void SimulateDemandManagerList(EnergyPlusData &state, Real64 AverageDemand = demandManagerList.AverageDemand + (demandManagerList.MeterDemand - demandManagerList.History(1)) / demandManagerList.AveragingWindow; - if (demandManagerList.PeakSchedule == 0) { - OnPeak = true; - } else { - if (ScheduleManager::GetCurrentScheduleValue(state, demandManagerList.PeakSchedule) == 1) { - OnPeak = true; - } else { - OnPeak = false; - } - } + OnPeak = (demandManagerList.peakSched == nullptr) || (demandManagerList.peakSched->getCurrentVal() == 1); if (OnPeak) { Real64 OverLimit = AverageDemand - demandManagerList.DemandLimit; @@ -321,8 +313,13 @@ void GetDemandManagerListInput(EnergyPlusData &state) // SUBROUTINE LOCAL VARIABLE DECLARATIONS: + static constexpr std::string_view routineName = "GetDemandManagerListInput"; constexpr std::string_view cCurrentModuleObject = "DemandManagerAssignmentList"; - state.dataDemandManager->NumDemandManagerList = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); + + auto &s_ipsc = state.dataIPShortCut; + auto const &s_ip = state.dataInputProcessing->inputProcessor; + + state.dataDemandManager->NumDemandManagerList = s_ip->getNumObjectsFound(state, cCurrentModuleObject); if (state.dataDemandManager->NumDemandManagerList > 0) { int NumAlphas; // Number of elements in the alpha array @@ -336,25 +333,27 @@ void GetDemandManagerListInput(EnergyPlusData &state) auto &thisDemandMgrList = state.dataDemandManager->DemandManagerList(ListNum); - state.dataInputProcessing->inputProcessor->getObjectItem(state, + s_ip->getObjectItem(state, cCurrentModuleObject, ListNum, - state.dataIPShortCut->cAlphaArgs, + s_ipsc->cAlphaArgs, NumAlphas, - state.dataIPShortCut->rNumericArgs, + s_ipsc->rNumericArgs, NumNums, IOStat, _, - state.dataIPShortCut->lAlphaFieldBlanks, - state.dataIPShortCut->cAlphaFieldNames, - state.dataIPShortCut->cNumericFieldNames); + s_ipsc->lAlphaFieldBlanks, + s_ipsc->cAlphaFieldNames, + s_ipsc->cNumericFieldNames); - thisDemandMgrList.Name = state.dataIPShortCut->cAlphaArgs(1); + ErrorObjectHeader eoh{routineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)}; + + thisDemandMgrList.Name = s_ipsc->cAlphaArgs(1); - thisDemandMgrList.Meter = GetMeterIndex(state, state.dataIPShortCut->cAlphaArgs(2)); + thisDemandMgrList.Meter = GetMeterIndex(state, s_ipsc->cAlphaArgs(2)); if (thisDemandMgrList.Meter == -1) { - ShowSevereError(state, format("Invalid {} = {}", state.dataIPShortCut->cAlphaFieldNames(2), state.dataIPShortCut->cAlphaArgs(2))); + ShowSevereError(state, format("Invalid {} = {}", s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2))); ShowContinueError(state, format("Entered in {} = {}", cCurrentModuleObject, thisDemandMgrList.Name)); ErrorsFound = true; @@ -366,8 +365,8 @@ void GetDemandManagerListInput(EnergyPlusData &state) format("{} = \"{}\" invalid value {} = \"{}\".", cCurrentModuleObject, thisDemandMgrList.Name, - state.dataIPShortCut->cAlphaFieldNames(2), - state.dataIPShortCut->cAlphaArgs(2))); + s_ipsc->cAlphaFieldNames(2), + s_ipsc->cAlphaArgs(2))); ShowContinueError(state, "Only Electricity and ElectricityNet meters are currently allowed."); ErrorsFound = true; } @@ -375,51 +374,30 @@ void GetDemandManagerListInput(EnergyPlusData &state) // Further checking for conflicting DEMAND MANAGER LISTs - if (!state.dataIPShortCut->lAlphaFieldBlanks(3)) { - thisDemandMgrList.LimitSchedule = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(3)); - - if (thisDemandMgrList.LimitSchedule == 0) { - ShowSevereError(state, - format("{} = \"{}\" invalid {} = \"{}\" not found.", - cCurrentModuleObject, - thisDemandMgrList.Name, - state.dataIPShortCut->cAlphaFieldNames(3), - state.dataIPShortCut->cAlphaArgs(3))); + if (!s_ipsc->lAlphaFieldBlanks(3)) { + if ((thisDemandMgrList.limitSched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(3))) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(3), s_ipsc->cAlphaArgs(3)); ErrorsFound = true; } } - thisDemandMgrList.SafetyFraction = state.dataIPShortCut->rNumericArgs(1); - - if (!state.dataIPShortCut->lAlphaFieldBlanks(4)) { - thisDemandMgrList.BillingSchedule = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(4)); + thisDemandMgrList.SafetyFraction = s_ipsc->rNumericArgs(1); - if (thisDemandMgrList.BillingSchedule == 0) { - ShowSevereError(state, - format("{} = \"{}\" invalid {} = \"{}\" not found.", - cCurrentModuleObject, - thisDemandMgrList.Name, - state.dataIPShortCut->cAlphaFieldNames(4), - state.dataIPShortCut->cAlphaArgs(4))); + if (!s_ipsc->lAlphaFieldBlanks(4)) { + if ((thisDemandMgrList.billingSched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(4))) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(4), s_ipsc->cAlphaArgs(4)); ErrorsFound = true; } } - if (!state.dataIPShortCut->lAlphaFieldBlanks(5)) { - thisDemandMgrList.PeakSchedule = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(5)); - - if (thisDemandMgrList.PeakSchedule == 0) { - ShowSevereError(state, - format("{} = \"{}\" invalid {} = \"{}\" not found.", - cCurrentModuleObject, - thisDemandMgrList.Name, - state.dataIPShortCut->cAlphaFieldNames(5), - state.dataIPShortCut->cAlphaArgs(5))); + if (!s_ipsc->lAlphaFieldBlanks(5)) { + if ((thisDemandMgrList.peakSched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(5))) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(5), s_ipsc->cAlphaArgs(5)); ErrorsFound = true; } } - thisDemandMgrList.AveragingWindow = max(int(state.dataIPShortCut->rNumericArgs(2) / state.dataGlobal->MinutesPerTimeStep), 1); + thisDemandMgrList.AveragingWindow = max(int(s_ipsc->rNumericArgs(2) / state.dataGlobal->MinutesInTimeStep), 1); // Round to nearest timestep // Can make this fancier to include windows that do not fit the timesteps thisDemandMgrList.History.allocate(thisDemandMgrList.AveragingWindow); @@ -427,7 +405,7 @@ void GetDemandManagerListInput(EnergyPlusData &state) // Validate Demand Manager Priority thisDemandMgrList.ManagerPriority = - static_cast(getEnumValue(ManagePriorityNamesUC, Util::makeUPPER(state.dataIPShortCut->cAlphaArgs(6)))); + static_cast(getEnumValue(ManagePriorityNamesUC, Util::makeUPPER(s_ipsc->cAlphaArgs(6)))); ErrorsFound = ErrorsFound || (thisDemandMgrList.ManagerPriority == ManagePriorityType::Invalid); // Get DEMAND MANAGER Type and Name pairs @@ -440,16 +418,16 @@ void GetDemandManagerListInput(EnergyPlusData &state) auto &thisManager = thisDemandMgrList.Manager(MgrNum); // Validate DEMAND MANAGER Type ManagerType MgrType = - static_cast(getEnumValue(ManagerNamesUC, Util::makeUPPER(state.dataIPShortCut->cAlphaArgs(MgrNum * 2 + 5)))); + static_cast(getEnumValue(ManagerNamesUC, Util::makeUPPER(s_ipsc->cAlphaArgs(MgrNum * 2 + 5)))); if (MgrType != ManagerType::Invalid) { - thisManager = Util::FindItemInList(state.dataIPShortCut->cAlphaArgs(MgrNum * 2 + 6), state.dataDemandManager->DemandMgr); + thisManager = Util::FindItemInList(s_ipsc->cAlphaArgs(MgrNum * 2 + 6), state.dataDemandManager->DemandMgr); if (thisManager == 0) { ShowSevereError(state, format("{} = \"{}\" invalid {} = \"{}\" not found.", cCurrentModuleObject, thisDemandMgrList.Name, - state.dataIPShortCut->cAlphaFieldNames(MgrNum * 2 + 6), - state.dataIPShortCut->cAlphaArgs(MgrNum * 2 + 6))); + s_ipsc->cAlphaFieldNames(MgrNum * 2 + 6), + s_ipsc->cAlphaArgs(MgrNum * 2 + 6))); ErrorsFound = true; } } else { @@ -457,8 +435,8 @@ void GetDemandManagerListInput(EnergyPlusData &state) format("{} = \"{}\" invalid value {} = \"{}\".", cCurrentModuleObject, thisDemandMgrList.Name, - state.dataIPShortCut->cAlphaFieldNames(MgrNum * 2 + 5), - state.dataIPShortCut->cAlphaArgs(MgrNum * 2 + 5))); + s_ipsc->cAlphaFieldNames(MgrNum * 2 + 5), + s_ipsc->cAlphaArgs(MgrNum * 2 + 5))); ErrorsFound = true; } @@ -568,6 +546,11 @@ void GetDemandManagerInput(EnergyPlusData &state) // PURPOSE OF THIS SUBROUTINE: // Gets the DEMAND MANAGER input from the input file. + static constexpr std::string_view routineName = "GetDemandManagerInput"; + + auto &s_ipsc = state.dataIPShortCut; + auto const &s_ip = state.dataInputProcessing->inputProcessor; + // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int NumAlphas; // Number of elements in the alpha array int NumNums; // Number of elements in the numeric array @@ -579,37 +562,37 @@ void GetDemandManagerInput(EnergyPlusData &state) int MaxAlphas = 0; int MaxNums = 0; std::string CurrentModuleObject = "DemandManager:ExteriorLights"; - int NumDemandMgrExtLights = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject); + int NumDemandMgrExtLights = s_ip->getNumObjectsFound(state, CurrentModuleObject); if (NumDemandMgrExtLights > 0) { - state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, CurrentModuleObject, NumParams, NumAlphas, NumNums); + s_ip->getObjectDefMaxArgs(state, CurrentModuleObject, NumParams, NumAlphas, NumNums); MaxAlphas = max(MaxAlphas, NumAlphas); MaxNums = max(MaxNums, NumNums); } CurrentModuleObject = "DemandManager:Lights"; - int NumDemandMgrLights = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject); + int NumDemandMgrLights = s_ip->getNumObjectsFound(state, CurrentModuleObject); if (NumDemandMgrLights > 0) { - state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, CurrentModuleObject, NumParams, NumAlphas, NumNums); + s_ip->getObjectDefMaxArgs(state, CurrentModuleObject, NumParams, NumAlphas, NumNums); MaxAlphas = max(MaxAlphas, NumAlphas); MaxNums = max(MaxNums, NumNums); } CurrentModuleObject = "DemandManager:ElectricEquipment"; - int NumDemandMgrElecEquip = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject); + int NumDemandMgrElecEquip = s_ip->getNumObjectsFound(state, CurrentModuleObject); if (NumDemandMgrElecEquip > 0) { - state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, CurrentModuleObject, NumParams, NumAlphas, NumNums); + s_ip->getObjectDefMaxArgs(state, CurrentModuleObject, NumParams, NumAlphas, NumNums); MaxAlphas = max(MaxAlphas, NumAlphas); MaxNums = max(MaxNums, NumNums); } CurrentModuleObject = "DemandManager:Thermostats"; - int NumDemandMgrThermostats = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject); + int NumDemandMgrThermostats = s_ip->getNumObjectsFound(state, CurrentModuleObject); if (NumDemandMgrThermostats > 0) { - state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, CurrentModuleObject, NumParams, NumAlphas, NumNums); + s_ip->getObjectDefMaxArgs(state, CurrentModuleObject, NumParams, NumAlphas, NumNums); MaxAlphas = max(MaxAlphas, NumAlphas); MaxNums = max(MaxNums, NumNums); } CurrentModuleObject = "DemandManager:Ventilation"; - int NumDemandMgrVentilation = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject); + int NumDemandMgrVentilation = s_ip->getNumObjectsFound(state, CurrentModuleObject); if (NumDemandMgrVentilation > 0) { - state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, CurrentModuleObject, NumParams, NumAlphas, NumNums); + s_ip->getObjectDefMaxArgs(state, CurrentModuleObject, NumParams, NumAlphas, NumNums); MaxAlphas = max(MaxAlphas, NumAlphas); MaxNums = max(MaxNums, NumNums); } @@ -636,7 +619,7 @@ void GetDemandManagerInput(EnergyPlusData &state) for (int MgrNum = StartIndex; MgrNum <= EndIndex; ++MgrNum) { auto &demandMgr = DemandMgr(MgrNum); - state.dataInputProcessing->inputProcessor->getObjectItem(state, + s_ip->getObjectItem(state, CurrentModuleObject, MgrNum - StartIndex + 1, AlphArray, @@ -645,33 +628,27 @@ void GetDemandManagerInput(EnergyPlusData &state) NumNums, IOStat, _, - state.dataIPShortCut->lAlphaFieldBlanks, - state.dataIPShortCut->cAlphaFieldNames, - state.dataIPShortCut->cNumericFieldNames); + s_ipsc->lAlphaFieldBlanks, + s_ipsc->cAlphaFieldNames, + s_ipsc->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, CurrentModuleObject, AlphArray(1)}; + GlobalNames::VerifyUniqueInterObjectName(state, state.dataDemandManager->UniqueDemandMgrNames, AlphArray(1), CurrentModuleObject, - state.dataIPShortCut->cAlphaFieldNames(1), + s_ipsc->cAlphaFieldNames(1), ErrorsFound); demandMgr.Name = AlphArray(1); demandMgr.Type = ManagerType::ExtLights; - if (!state.dataIPShortCut->lAlphaFieldBlanks(2)) { - demandMgr.AvailSchedule = ScheduleManager::GetScheduleIndex(state, AlphArray(2)); - - if (demandMgr.AvailSchedule == 0) { - ShowSevereError(state, - format("{}=\"{}\" invalid {}=\"{}\" not found.", - CurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaFieldNames(2), - AlphArray(2))); - ErrorsFound = true; - } - } else { - demandMgr.AvailSchedule = ScheduleManager::ScheduleAlwaysOn; + if (s_ipsc->lAlphaFieldBlanks(2)) { + demandMgr.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((demandMgr.availSched = Sched::GetSchedule(state, AlphArray(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(2), AlphArray(2)); + ErrorsFound = true; } // Validate Limiting Control @@ -679,7 +656,7 @@ void GetDemandManagerInput(EnergyPlusData &state) ErrorsFound = ErrorsFound || (demandMgr.LimitControl == ManagerLimit::Invalid); if (NumArray(1) == 0.0) - demandMgr.LimitDuration = state.dataGlobal->MinutesPerTimeStep; + demandMgr.LimitDuration = state.dataGlobal->MinutesInTimeStep; else demandMgr.LimitDuration = NumArray(1); @@ -690,7 +667,7 @@ void GetDemandManagerInput(EnergyPlusData &state) ErrorsFound = ErrorsFound || (demandMgr.SelectionControl == ManagerSelection::Invalid); if (NumArray(4) == 0.0) - demandMgr.RotationDuration = state.dataGlobal->MinutesPerTimeStep; + demandMgr.RotationDuration = state.dataGlobal->MinutesInTimeStep; else demandMgr.RotationDuration = NumArray(4); @@ -709,15 +686,15 @@ void GetDemandManagerInput(EnergyPlusData &state) ShowSevereError(state, format("{}=\"{}\" invalid {}=\"{}\" not found.", CurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaFieldNames(LoadNum + 4), + s_ipsc->cAlphaArgs(1), + s_ipsc->cAlphaFieldNames(LoadNum + 4), AlphArray(LoadNum + 4))); ErrorsFound = true; } } // LoadNum } else { ShowSevereError(state, - format("{}=\"{}\" invalid value for number of loads.", CurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); + format("{}=\"{}\" invalid value for number of loads.", CurrentModuleObject, s_ipsc->cAlphaArgs(1))); ShowContinueError(state, "Number of loads is calculated to be less than one. Demand manager must have at least one load assigned."); ErrorsFound = true; } @@ -733,7 +710,7 @@ void GetDemandManagerInput(EnergyPlusData &state) for (int MgrNum = StartIndex; MgrNum <= EndIndex; ++MgrNum) { auto &demandMgr = DemandMgr(MgrNum); - state.dataInputProcessing->inputProcessor->getObjectItem(state, + s_ip->getObjectItem(state, CurrentModuleObject, MgrNum - StartIndex + 1, AlphArray, @@ -742,33 +719,26 @@ void GetDemandManagerInput(EnergyPlusData &state) NumNums, IOStat, _, - state.dataIPShortCut->lAlphaFieldBlanks, - state.dataIPShortCut->cAlphaFieldNames, - state.dataIPShortCut->cNumericFieldNames); + s_ipsc->lAlphaFieldBlanks, + s_ipsc->cAlphaFieldNames, + s_ipsc->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, CurrentModuleObject, AlphArray(1)}; GlobalNames::VerifyUniqueInterObjectName(state, state.dataDemandManager->UniqueDemandMgrNames, AlphArray(1), CurrentModuleObject, - state.dataIPShortCut->cAlphaFieldNames(1), + s_ipsc->cAlphaFieldNames(1), ErrorsFound); demandMgr.Name = AlphArray(1); demandMgr.Type = ManagerType::Lights; - if (!state.dataIPShortCut->lAlphaFieldBlanks(2)) { - demandMgr.AvailSchedule = ScheduleManager::GetScheduleIndex(state, AlphArray(2)); - - if (demandMgr.AvailSchedule == 0) { - ShowSevereError(state, - format("{}=\"{}\" invalid {}=\"{}\" not found.", - CurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaFieldNames(2), - AlphArray(2))); - ErrorsFound = true; - } - } else { - demandMgr.AvailSchedule = ScheduleManager::ScheduleAlwaysOn; + if (s_ipsc->lAlphaFieldBlanks(2)) { + demandMgr.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((demandMgr.availSched = Sched::GetSchedule(state, AlphArray(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(2), AlphArray(2)); + ErrorsFound = true; } // Validate Limiting Control @@ -776,7 +746,7 @@ void GetDemandManagerInput(EnergyPlusData &state) ErrorsFound = ErrorsFound || (demandMgr.LimitControl == ManagerLimit::Invalid); if (NumArray(1) == 0.0) - demandMgr.LimitDuration = state.dataGlobal->MinutesPerTimeStep; + demandMgr.LimitDuration = state.dataGlobal->MinutesInTimeStep; else demandMgr.LimitDuration = NumArray(1); @@ -787,7 +757,7 @@ void GetDemandManagerInput(EnergyPlusData &state) ErrorsFound = ErrorsFound || (demandMgr.SelectionControl == ManagerSelection::Invalid); if (NumArray(4) == 0.0) - demandMgr.RotationDuration = state.dataGlobal->MinutesPerTimeStep; + demandMgr.RotationDuration = state.dataGlobal->MinutesInTimeStep; else demandMgr.RotationDuration = NumArray(4); @@ -805,8 +775,8 @@ void GetDemandManagerInput(EnergyPlusData &state) ShowSevereError(state, format("{}=\"{}\" invalid {}=\"{}\" not found.", CurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaFieldNames(LoadNum + 4), + s_ipsc->cAlphaArgs(1), + s_ipsc->cAlphaFieldNames(LoadNum + 4), AlphArray(LoadNum + 4))); ErrorsFound = true; } @@ -835,7 +805,7 @@ void GetDemandManagerInput(EnergyPlusData &state) } // LoadNum } else { ShowSevereError(state, - format("{}=\"{}\" invalid value for number of loads.", CurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); + format("{}=\"{}\" invalid value for number of loads.", CurrentModuleObject, s_ipsc->cAlphaArgs(1))); ShowContinueError(state, "Number of loads is calculated to be less than one. Demand manager must have at least one load assigned."); ErrorsFound = true; } @@ -851,7 +821,7 @@ void GetDemandManagerInput(EnergyPlusData &state) for (int MgrNum = StartIndex; MgrNum <= EndIndex; ++MgrNum) { auto &demandMgr = DemandMgr(MgrNum); - state.dataInputProcessing->inputProcessor->getObjectItem(state, + s_ip->getObjectItem(state, CurrentModuleObject, MgrNum - StartIndex + 1, AlphArray, @@ -860,33 +830,27 @@ void GetDemandManagerInput(EnergyPlusData &state) NumNums, IOStat, _, - state.dataIPShortCut->lAlphaFieldBlanks, - state.dataIPShortCut->cAlphaFieldNames, - state.dataIPShortCut->cNumericFieldNames); + s_ipsc->lAlphaFieldBlanks, + s_ipsc->cAlphaFieldNames, + s_ipsc->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, CurrentModuleObject, AlphArray(1)}; GlobalNames::VerifyUniqueInterObjectName(state, state.dataDemandManager->UniqueDemandMgrNames, AlphArray(1), CurrentModuleObject, - state.dataIPShortCut->cAlphaFieldNames(1), + s_ipsc->cAlphaFieldNames(1), ErrorsFound); + demandMgr.Name = AlphArray(1); demandMgr.Type = ManagerType::ElecEquip; - if (!state.dataIPShortCut->lAlphaFieldBlanks(2)) { - demandMgr.AvailSchedule = ScheduleManager::GetScheduleIndex(state, AlphArray(2)); - - if (demandMgr.AvailSchedule == 0) { - ShowSevereError(state, - format("{}=\"{}\" invalid {}=\"{}\" not found.", - CurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaFieldNames(2), - AlphArray(2))); - ErrorsFound = true; - } - } else { - demandMgr.AvailSchedule = ScheduleManager::ScheduleAlwaysOn; + if (s_ipsc->lAlphaFieldBlanks(2)) { + demandMgr.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((demandMgr.availSched = Sched::GetSchedule(state, AlphArray(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(2), AlphArray(2)); + ErrorsFound = true; } // Validate Limiting Control @@ -894,7 +858,7 @@ void GetDemandManagerInput(EnergyPlusData &state) ErrorsFound = ErrorsFound || (demandMgr.LimitControl == ManagerLimit::Invalid); if (NumArray(1) == 0.0) - demandMgr.LimitDuration = state.dataGlobal->MinutesPerTimeStep; + demandMgr.LimitDuration = state.dataGlobal->MinutesInTimeStep; else demandMgr.LimitDuration = NumArray(1); @@ -905,7 +869,7 @@ void GetDemandManagerInput(EnergyPlusData &state) ErrorsFound = ErrorsFound || (demandMgr.SelectionControl == ManagerSelection::Invalid); if (NumArray(4) == 0.0) - demandMgr.RotationDuration = state.dataGlobal->MinutesPerTimeStep; + demandMgr.RotationDuration = state.dataGlobal->MinutesInTimeStep; else demandMgr.RotationDuration = NumArray(4); @@ -923,8 +887,8 @@ void GetDemandManagerInput(EnergyPlusData &state) ShowSevereError(state, format("{}=\"{}\" invalid {}=\"{}\" not found.", CurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaFieldNames(LoadNum + 4), + s_ipsc->cAlphaArgs(1), + s_ipsc->cAlphaFieldNames(LoadNum + 4), AlphArray(LoadNum + 4))); ErrorsFound = true; } @@ -953,7 +917,7 @@ void GetDemandManagerInput(EnergyPlusData &state) } // LoadNum } else { ShowSevereError(state, - format("{}=\"{}\" invalid value for number of loads.", CurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); + format("{}=\"{}\" invalid value for number of loads.", CurrentModuleObject, s_ipsc->cAlphaArgs(1))); ShowContinueError(state, "Number of loads is calculated to be less than one. Demand manager must have at least one load assigned."); ErrorsFound = true; } @@ -969,7 +933,7 @@ void GetDemandManagerInput(EnergyPlusData &state) for (int MgrNum = StartIndex; MgrNum <= EndIndex; ++MgrNum) { auto &demandMgr = DemandMgr(MgrNum); - state.dataInputProcessing->inputProcessor->getObjectItem(state, + s_ip->getObjectItem(state, CurrentModuleObject, MgrNum - StartIndex + 1, AlphArray, @@ -978,34 +942,27 @@ void GetDemandManagerInput(EnergyPlusData &state) NumNums, IOStat, _, - state.dataIPShortCut->lAlphaFieldBlanks, - state.dataIPShortCut->cAlphaFieldNames, - state.dataIPShortCut->cNumericFieldNames); + s_ipsc->lAlphaFieldBlanks, + s_ipsc->cAlphaFieldNames, + s_ipsc->cNumericFieldNames); + ErrorObjectHeader eoh{routineName, CurrentModuleObject, AlphArray(1)}; + GlobalNames::VerifyUniqueInterObjectName(state, state.dataDemandManager->UniqueDemandMgrNames, AlphArray(1), CurrentModuleObject, - state.dataIPShortCut->cAlphaFieldNames(1), + s_ipsc->cAlphaFieldNames(1), ErrorsFound); demandMgr.Name = AlphArray(1); demandMgr.Type = ManagerType::Thermostats; - if (!state.dataIPShortCut->lAlphaFieldBlanks(2)) { - demandMgr.AvailSchedule = ScheduleManager::GetScheduleIndex(state, AlphArray(2)); - - if (demandMgr.AvailSchedule == 0) { - ShowSevereError(state, - format("{}=\"{}\" invalid {}=\"{}\" not found.", - CurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaFieldNames(2), - AlphArray(2))); - ErrorsFound = true; - } - } else { - demandMgr.AvailSchedule = ScheduleManager::ScheduleAlwaysOn; + if (s_ipsc->lAlphaFieldBlanks(2)) { + demandMgr.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((demandMgr.availSched = Sched::GetSchedule(state, AlphArray(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(2), AlphArray(2)); + ErrorsFound = true; } // Validate Limiting Control @@ -1013,7 +970,7 @@ void GetDemandManagerInput(EnergyPlusData &state) ErrorsFound = ErrorsFound || (demandMgr.LimitControl == ManagerLimit::Invalid); if (NumArray(1) == 0.0) - demandMgr.LimitDuration = state.dataGlobal->MinutesPerTimeStep; + demandMgr.LimitDuration = state.dataGlobal->MinutesInTimeStep; else demandMgr.LimitDuration = NumArray(1); @@ -1024,13 +981,13 @@ void GetDemandManagerInput(EnergyPlusData &state) ShowSevereError(state, format("Invalid input for {} = {}", CurrentModuleObject, AlphArray(1))); ShowContinueError(state, format("{} [{:.R2}] > {} [{.R2}]", - state.dataIPShortCut->cNumericFieldNames(2), + s_ipsc->cNumericFieldNames(2), NumArray(2), - state.dataIPShortCut->cNumericFieldNames(3), + s_ipsc->cNumericFieldNames(3), NumArray(3))); ShowContinueError( state, - format("{} cannot be greater than {}", state.dataIPShortCut->cNumericFieldNames(2), state.dataIPShortCut->cNumericFieldNames(3))); + format("{} cannot be greater than {}", s_ipsc->cNumericFieldNames(2), s_ipsc->cNumericFieldNames(3))); ErrorsFound = true; } @@ -1039,7 +996,7 @@ void GetDemandManagerInput(EnergyPlusData &state) ErrorsFound = ErrorsFound || (demandMgr.SelectionControl == ManagerSelection::Invalid); if (NumArray(5) == 0.0) - demandMgr.RotationDuration = state.dataGlobal->MinutesPerTimeStep; + demandMgr.RotationDuration = state.dataGlobal->MinutesInTimeStep; else demandMgr.RotationDuration = NumArray(5); @@ -1057,8 +1014,8 @@ void GetDemandManagerInput(EnergyPlusData &state) ShowSevereError(state, format("{}=\"{}\" invalid {}=\"{}\" not found.", CurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaFieldNames(LoadNum + 4), + s_ipsc->cAlphaArgs(1), + s_ipsc->cAlphaFieldNames(LoadNum + 4), AlphArray(LoadNum + 4))); ErrorsFound = true; } @@ -1085,7 +1042,7 @@ void GetDemandManagerInput(EnergyPlusData &state) } // LoadNum } else { ShowSevereError(state, - format("{}=\"{}\" invalid value for number of loads.", CurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); + format("{}=\"{}\" invalid value for number of loads.", CurrentModuleObject, s_ipsc->cAlphaArgs(1))); ShowContinueError(state, "Number of loads is calculated to be less than one. Demand manager must have at least one load assigned."); ErrorsFound = true; } @@ -1100,7 +1057,7 @@ void GetDemandManagerInput(EnergyPlusData &state) for (int MgrNum = StartIndex; MgrNum <= EndIndex; ++MgrNum) { auto &demandMgr = DemandMgr(MgrNum); - state.dataInputProcessing->inputProcessor->getObjectItem(state, + s_ip->getObjectItem(state, CurrentModuleObject, MgrNum - StartIndex + 1, AlphArray, @@ -1109,44 +1066,33 @@ void GetDemandManagerInput(EnergyPlusData &state) NumNums, IOStat, _, - state.dataIPShortCut->lAlphaFieldBlanks, - state.dataIPShortCut->cAlphaFieldNames, - state.dataIPShortCut->cNumericFieldNames); + s_ipsc->lAlphaFieldBlanks, + s_ipsc->cAlphaFieldNames, + s_ipsc->cNumericFieldNames); + ErrorObjectHeader eoh{routineName, CurrentModuleObject, AlphArray(1)}; GlobalNames::VerifyUniqueInterObjectName(state, state.dataDemandManager->UniqueDemandMgrNames, AlphArray(1), CurrentModuleObject, - state.dataIPShortCut->cAlphaFieldNames(1), + s_ipsc->cAlphaFieldNames(1), ErrorsFound); demandMgr.Name = AlphArray(1); demandMgr.Type = ManagerType::Ventilation; - if (!state.dataIPShortCut->lAlphaFieldBlanks(2)) { - demandMgr.AvailSchedule = ScheduleManager::GetScheduleIndex(state, AlphArray(2)); - - if (demandMgr.AvailSchedule == 0) { - ShowSevereError(state, - format("{}=\"{}\" invalid {}=\"{}\" not found.", - CurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaFieldNames(2), - AlphArray(2))); - ErrorsFound = true; - } - } else { - demandMgr.AvailSchedule = ScheduleManager::ScheduleAlwaysOn; + if (s_ipsc->lAlphaFieldBlanks(2)) { + demandMgr.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((demandMgr.availSched = Sched::GetSchedule(state, AlphArray(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(2), AlphArray(2)); + ErrorsFound = true; } // Validate Limiting Control demandMgr.LimitControl = static_cast(getEnumValue(ManagerLimitVentNamesUC, Util::makeUPPER(AlphArray(3)))); ErrorsFound = ErrorsFound || (demandMgr.LimitControl == ManagerLimit::Invalid); - if (NumArray(1) == 0.0) - demandMgr.LimitDuration = state.dataGlobal->MinutesPerTimeStep; - else - demandMgr.LimitDuration = NumArray(1); + demandMgr.LimitDuration = (NumArray(1) == 0.0) ? state.dataGlobal->MinutesInTimeStep : NumArray(1); if (demandMgr.LimitControl == ManagerLimit::Fixed) demandMgr.FixedRate = NumArray(2); if (demandMgr.LimitControl == ManagerLimit::ReductionRatio) demandMgr.ReductionRatio = NumArray(3); @@ -1157,10 +1103,7 @@ void GetDemandManagerInput(EnergyPlusData &state) demandMgr.SelectionControl = static_cast(getEnumValue(ManagerSelectionNamesUC, Util::makeUPPER(AlphArray(4)))); ErrorsFound = ErrorsFound || (demandMgr.SelectionControl == ManagerSelection::Invalid); - if (NumArray(5) == 0.0) - demandMgr.RotationDuration = state.dataGlobal->MinutesPerTimeStep; - else - demandMgr.RotationDuration = NumArray(5); + demandMgr.RotationDuration = (NumArray(5) == 0.0) ? state.dataGlobal->MinutesInTimeStep : NumArray(5); // Count number of string fields for loading Controller:OutdoorAir names. This number must be increased in case if // new string field is added or decreased if string fields are removed. @@ -1176,8 +1119,8 @@ void GetDemandManagerInput(EnergyPlusData &state) ShowSevereError(state, format("{}=\"{}\" invalid {}=\"{}\" not found.", CurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaFieldNames(LoadNum + AlphaShift), + s_ipsc->cAlphaArgs(1), + s_ipsc->cAlphaFieldNames(LoadNum + AlphaShift), AlphArray(LoadNum + AlphaShift))); ErrorsFound = true; } @@ -1193,7 +1136,7 @@ void GetDemandManagerInput(EnergyPlusData &state) } } else { ShowSevereError(state, - format("{}=\"{}\" invalid value for number of loads.", CurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); + format("{}=\"{}\" invalid value for number of loads.", CurrentModuleObject, s_ipsc->cAlphaArgs(1))); ShowContinueError(state, "Number of loads is calculated to be less than one. Demand manager must have at least one load assigned."); ErrorsFound = true; } @@ -1346,7 +1289,6 @@ void UpdateDemandManagers(EnergyPlusData &state) // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int LoadPtr; - bool Available; bool CanReduceDemand; int RotatedLoadNum; @@ -1355,12 +1297,7 @@ void UpdateDemandManagers(EnergyPlusData &state) auto &demandMgr = state.dataDemandManager->DemandMgr(MgrNum); // Check availability - if (ScheduleManager::GetCurrentScheduleValue(state, demandMgr.AvailSchedule) > 0.0) { - Available = true; - } else { - Available = false; - } - // END IF + bool Available = demandMgr.availSched->getCurrentVal() > 0.0; demandMgr.Available = Available; @@ -1369,7 +1306,7 @@ void UpdateDemandManagers(EnergyPlusData &state) if (demandMgr.Active) { - demandMgr.ElapsedTime += state.dataGlobal->MinutesPerTimeStep; + demandMgr.ElapsedTime += state.dataGlobal->MinutesInTimeStep; // Check for expiring limit duration if (demandMgr.ElapsedTime >= demandMgr.LimitDuration) { @@ -1391,7 +1328,7 @@ void UpdateDemandManagers(EnergyPlusData &state) } break; case ManagerSelection::Many: { // All loads are limited except for one - demandMgr.ElapsedRotationTime += state.dataGlobal->MinutesPerTimeStep; + demandMgr.ElapsedRotationTime += state.dataGlobal->MinutesInTimeStep; if (demandMgr.ElapsedRotationTime >= demandMgr.RotationDuration) { demandMgr.ElapsedRotationTime = 0; @@ -1415,7 +1352,7 @@ void UpdateDemandManagers(EnergyPlusData &state) } break; case ManagerSelection::One: { // Only one load is limited - demandMgr.ElapsedRotationTime += state.dataGlobal->MinutesPerTimeStep; + demandMgr.ElapsedRotationTime += state.dataGlobal->MinutesInTimeStep; if (demandMgr.ElapsedRotationTime >= demandMgr.RotationDuration) { demandMgr.ElapsedRotationTime = 0; @@ -1470,19 +1407,14 @@ void ReportDemandManagerList(EnergyPlusData &state, int const ListNum) // Standard EnergyPlus methodology. // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - Real64 BillingPeriod; int AveragingWindow; bool OnPeak; Real64 OverLimit; auto &demandManagerList = state.dataDemandManager->DemandManagerList(ListNum); - if (demandManagerList.BillingSchedule == 0) { - BillingPeriod = state.dataEnvrn->Month; - } else { - BillingPeriod = ScheduleManager::GetCurrentScheduleValue(state, demandManagerList.BillingSchedule); - } - + Real64 BillingPeriod = (demandManagerList.billingSched == nullptr) ? state.dataEnvrn->Month : demandManagerList.billingSched->getCurrentVal(); + if (demandManagerList.BillingPeriod != BillingPeriod) { // Reset variables for new billing period // demandManagerList%History = 0.0 ! Don't reset--continue from previous billing period @@ -1503,15 +1435,7 @@ void ReportDemandManagerList(EnergyPlusData &state, int const ListNum) } demandManagerList.History(AveragingWindow) = demandManagerList.MeterDemand; - if (demandManagerList.PeakSchedule == 0) { - OnPeak = true; - } else { - if (ScheduleManager::GetCurrentScheduleValue(state, demandManagerList.PeakSchedule) == 1) { - OnPeak = true; - } else { - OnPeak = false; - } - } + OnPeak = (demandManagerList.peakSched == nullptr) || (demandManagerList.peakSched->getCurrentVal() == 1); if (OnPeak) { demandManagerList.PeakDemand = max(demandManagerList.AverageDemand, demandManagerList.PeakDemand); @@ -1519,7 +1443,7 @@ void ReportDemandManagerList(EnergyPlusData &state, int const ListNum) OverLimit = demandManagerList.AverageDemand - demandManagerList.ScheduledLimit; if (OverLimit > 0.0) { demandManagerList.OverLimit = OverLimit; - demandManagerList.OverLimitDuration += (state.dataGlobal->MinutesPerTimeStep / 60.0); + demandManagerList.OverLimitDuration += (state.dataGlobal->MinutesInTimeStep / 60.0); } else { demandManagerList.OverLimit = 0.0; } @@ -1541,8 +1465,9 @@ void LoadInterface(EnergyPlusData &state, DemandAction const Action, int const M // Demand managers for new types of loads can be easily added with a new CASE statement in this subroutine // and new GetInput code. + auto const &s_dhbf = state.dataHeatBalFanSys; auto const &demandMgr = state.dataDemandManager->DemandMgr(MgrNum); - + // SUBROUTINE LOCAL VARIABLE DECLARATIONS: Real64 LowestPower; @@ -1560,6 +1485,7 @@ void LoadInterface(EnergyPlusData &state, DemandAction const Action, int const M state.dataExteriorEnergyUse->ExteriorLights(LoadPtr).ManageDemand = false; } } break; + case ManagerType::Lights: { LowestPower = state.dataHeatBal->Lights(LoadPtr).DesignLevel * demandMgr.LowerLimit; if (Action == DemandAction::CheckCanReduce) { @@ -1570,8 +1496,8 @@ void LoadInterface(EnergyPlusData &state, DemandAction const Action, int const M } else if (Action == DemandAction::ClearLimit) { state.dataHeatBal->Lights(LoadPtr).ManageDemand = false; } - } break; + case ManagerType::ElecEquip: { LowestPower = state.dataHeatBal->ZoneElectric(LoadPtr).DesignLevel * demandMgr.LowerLimit; if (Action == DemandAction::CheckCanReduce) { @@ -1583,39 +1509,38 @@ void LoadInterface(EnergyPlusData &state, DemandAction const Action, int const M state.dataHeatBal->ZoneElectric(LoadPtr).ManageDemand = false; } } break; + case ManagerType::Thermostats: { + auto &tempZone = state.dataZoneCtrls->TempControlledZone(LoadPtr); + auto &zoneTstatSetpt = s_dhbf->zoneTstatSetpts(tempZone.ActualZoneNum); if (Action == DemandAction::CheckCanReduce) { - if (state.dataHeatBalFanSys->ZoneThermostatSetPointLo(state.dataZoneCtrls->TempControlledZone(LoadPtr).ActualZoneNum) > - demandMgr.LowerLimit || - state.dataHeatBalFanSys->ZoneThermostatSetPointHi(state.dataZoneCtrls->TempControlledZone(LoadPtr).ActualZoneNum) < - demandMgr.UpperLimit) + if (zoneTstatSetpt.setptLo > demandMgr.LowerLimit || zoneTstatSetpt.setptHi < demandMgr.UpperLimit) CanReduceDemand = true; // Heating | Cooling } else if (Action == DemandAction::SetLimit) { - state.dataZoneCtrls->TempControlledZone(LoadPtr).ManageDemand = true; - state.dataZoneCtrls->TempControlledZone(LoadPtr).HeatingResetLimit = demandMgr.LowerLimit; - state.dataZoneCtrls->TempControlledZone(LoadPtr).CoolingResetLimit = demandMgr.UpperLimit; + tempZone.ManageDemand = true; + tempZone.HeatingResetLimit = demandMgr.LowerLimit; + tempZone.CoolingResetLimit = demandMgr.UpperLimit; } else if (Action == DemandAction::ClearLimit) { - state.dataZoneCtrls->TempControlledZone(LoadPtr).ManageDemand = false; + tempZone.ManageDemand = false; } if (state.dataZoneCtrls->NumComfortControlledZones > 0) { - if (state.dataHeatBalFanSys->ComfortControlType(state.dataZoneCtrls->TempControlledZone(LoadPtr).ActualZoneNum) != - HVAC::ThermostatType::Uncontrolled) { + auto &comfortZone = state.dataZoneCtrls->ComfortControlledZone(LoadPtr); + if (state.dataHeatBalFanSys->ComfortControlType(comfortZone.ActualZoneNum) != HVAC::SetptType::Uncontrolled) { + auto &zoneTstatSetpt = s_dhbf->zoneTstatSetpts(comfortZone.ActualZoneNum); if (Action == DemandAction::CheckCanReduce) { - if (state.dataHeatBalFanSys->ZoneThermostatSetPointLo(state.dataZoneCtrls->ComfortControlledZone(LoadPtr).ActualZoneNum) > - demandMgr.LowerLimit || - state.dataHeatBalFanSys->ZoneThermostatSetPointHi(state.dataZoneCtrls->ComfortControlledZone(LoadPtr).ActualZoneNum) < - demandMgr.UpperLimit) + if (zoneTstatSetpt.setptLo > demandMgr.LowerLimit || zoneTstatSetpt.setptHi < demandMgr.UpperLimit) CanReduceDemand = true; // Heating } else if (Action == DemandAction::SetLimit) { - state.dataZoneCtrls->ComfortControlledZone(LoadPtr).ManageDemand = true; - state.dataZoneCtrls->ComfortControlledZone(LoadPtr).HeatingResetLimit = demandMgr.LowerLimit; - state.dataZoneCtrls->ComfortControlledZone(LoadPtr).CoolingResetLimit = demandMgr.UpperLimit; + comfortZone.ManageDemand = true; + comfortZone.HeatingResetLimit = demandMgr.LowerLimit; + comfortZone.CoolingResetLimit = demandMgr.UpperLimit; } else if (Action == DemandAction::ClearLimit) { - state.dataZoneCtrls->ComfortControlledZone(LoadPtr).ManageDemand = false; + comfortZone.ManageDemand = false; } } } } break; + case ManagerType::Ventilation: { Real64 FlowRate(0); FlowRate = MixedAir::OAGetFlowRate(state, LoadPtr); diff --git a/src/EnergyPlus/DemandManager.hh b/src/EnergyPlus/DemandManager.hh index 485cb8fd0c5..166a199a3f9 100644 --- a/src/EnergyPlus/DemandManager.hh +++ b/src/EnergyPlus/DemandManager.hh @@ -58,6 +58,7 @@ #include #include #include +#include namespace EnergyPlus { @@ -121,11 +122,11 @@ namespace DemandManager { // Members std::string Name; // Name of DEMAND MANAGER LIST int Meter; // Index to meter to demand limit - int LimitSchedule; // Schedule index for demand limit + Sched::Schedule *limitSched = nullptr; // Schedule for demand limit Real64 SafetyFraction; // Multiplier applied to demand limit schedule - int BillingSchedule; // Schedule index for billing month periods + Sched::Schedule *billingSched = nullptr; // Schedule for billing month periods Real64 BillingPeriod; // Current billing period value - int PeakSchedule; // Schedule index for billing month periods + Sched::Schedule *peakSched = nullptr; // Schedule index for billing month periods int AveragingWindow; // Number of timesteps for averaging demand window Array1D History; // Demand window history ManagePriorityType ManagerPriority; // Indicator for priority (SEQUENTIAL, OPTIMAL, ALL) @@ -142,7 +143,7 @@ namespace DemandManager { // Default Constructor DemandManagerListData() - : Meter(0), LimitSchedule(0), SafetyFraction(1.0), BillingSchedule(0), BillingPeriod(0.0), PeakSchedule(0), AveragingWindow(1), + : Meter(0), SafetyFraction(1.0), BillingPeriod(0.0), AveragingWindow(1), ManagerPriority(ManagePriorityType::Invalid), MeterDemand(0.0), AverageDemand(0.0), PeakDemand(0.0), ScheduledLimit(0.0), DemandLimit(0.0), AvoidedDemand(0.0), OverLimit(0.0), OverLimitDuration(0.0) { @@ -156,7 +157,7 @@ namespace DemandManager { ManagerType Type; // Type of DEMAND MANAGER (:LIGHTS, :ELECTRICEQUIPMENT, etc.) int DemandManagerList; // Reference to parent DEMAND MANAGER LIST for error checking bool CanReduceDemand; // Flag to indicate whether manager can reduce demand - int AvailSchedule; // Schedule index pointer for Availability Schedule + Sched::Schedule *availSched = nullptr; // Availability Schedule bool Available; // Availability flag bool Activate; // Flag to activate the manager bool Active; // Flag to indicate that the manager is active @@ -180,7 +181,7 @@ namespace DemandManager { // Default Constructor DemandManagerData() - : Type(ManagerType::Invalid), DemandManagerList(0), CanReduceDemand(false), AvailSchedule(0), Available(false), Activate(false), + : Type(ManagerType::Invalid), DemandManagerList(0), CanReduceDemand(false), Available(false), Activate(false), Active(false), LimitControl(ManagerLimit::Invalid), SelectionControl(ManagerSelection::Invalid), LimitDuration(0), ElapsedTime(0), RotationDuration(0), ElapsedRotationTime(0), RotatedLoadNum(0), LowerLimit(0.0), UpperLimit(0.0), NumOfLoads(0), FixedRate(0.0), ReductionRatio(0.0) @@ -233,6 +234,10 @@ struct DemandManagerData : BaseGlobalStruct bool ResimExt = true; bool firstTime = true; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/DesiccantDehumidifiers.cc b/src/EnergyPlus/DesiccantDehumidifiers.cc index 5b26d322892..b9fbadbcd9c 100644 --- a/src/EnergyPlus/DesiccantDehumidifiers.cc +++ b/src/EnergyPlus/DesiccantDehumidifiers.cc @@ -302,21 +302,12 @@ namespace DesiccantDehumidifiers { desicDehum.DehumType = CurrentModuleObject; desicDehum.DehumTypeCode = DesicDehumType::Solid; desicDehum.Sched = Alphas(2); + if (lAlphaBlanks(2)) { - desicDehum.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - desicDehum.SchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(2)); // convert schedule name to pointer - if (desicDehum.SchedPtr == 0) { - ShowSevereError(state, - format("{}{}: invalid {} entered ={} for {}={}", - RoutineName, - CurrentModuleObject, - cAlphaFields(2), - Alphas(2), - cAlphaFields(1), - Alphas(1))); - ErrorsFound = true; - } + desicDehum.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((desicDehum.availSched = Sched::GetSchedule(state, Alphas(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(2), Alphas(2)); + ErrorsFound = true; } // For node connections, this object is both a parent and a non-parent, because the // Desiccant wheel is not called out as a separate component, its nodes must be connected @@ -678,20 +669,10 @@ namespace DesiccantDehumidifiers { desicDehum.Sched = Alphas(2); if (lAlphaBlanks(2)) { - desicDehum.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - desicDehum.SchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(2)); // convert schedule name to pointer - if (desicDehum.SchedPtr == 0) { - ShowSevereError(state, - format("{}{}: invalid {} entered ={} for {}={}", - RoutineName, - CurrentModuleObject, - cAlphaFields(2), - Alphas(2), - cAlphaFields(1), - Alphas(1))); - ErrorsFound = true; - } + desicDehum.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((desicDehum.availSched = Sched::GetSchedule(state, Alphas(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(2), Alphas(2)); + ErrorsFound = true; } desicDehum.HXType = Alphas(3); @@ -1885,7 +1866,7 @@ namespace DesiccantDehumidifiers { ProcAirMassFlowRate = desicDehum.ProcAirInMassFlowRate; if (ProcAirMassFlowRate <= HVAC::SmallMassFlow) UnitOn = false; - if (ScheduleManager::GetCurrentScheduleValue(state, desicDehum.SchedPtr) <= 0.0) UnitOn = false; + if (desicDehum.availSched->getCurrentVal() <= 0.0) UnitOn = false; // If incoming conditions are outside valid range for curve fits, then shut unit off, do not issue warnings @@ -1931,7 +1912,7 @@ namespace DesiccantDehumidifiers { ProcAirMassFlowRate = state.dataLoopNodes->Node(desicDehum.ProcAirInNode).MassFlowRate; if (ProcAirMassFlowRate <= HVAC::SmallMassFlow) UnitOn = false; - if (ScheduleManager::GetCurrentScheduleValue(state, desicDehum.SchedPtr) <= 0.0) UnitOn = false; + if (desicDehum.availSched->getCurrentVal() <= 0.0) UnitOn = false; if (UnitOn) { if (desicDehum.ControlNodeNum == desicDehum.ProcAirOutNode) { diff --git a/src/EnergyPlus/DesiccantDehumidifiers.hh b/src/EnergyPlus/DesiccantDehumidifiers.hh index a72db21bde4..1e6c22f4161 100644 --- a/src/EnergyPlus/DesiccantDehumidifiers.hh +++ b/src/EnergyPlus/DesiccantDehumidifiers.hh @@ -140,7 +140,7 @@ namespace DesiccantDehumidifiers { Real64 MinProcAirInHumRat; // min allowable process inlet air humidity ratio [kg water / kg air] Real64 MaxProcAirInHumRat; // max allowable process inlet air humidity ratio [kg water / kg air] // Internal Data - int SchedPtr; // index of availability schedule + Sched::Schedule *availSched = nullptr; // availability schedule Real64 NomProcAirMassFlow; // nominal process air mass flow rate [kg/s] Real64 NomRegenAirMassFlow; // nominal regeneration air mass flow rate [kg/s] Real64 ProcAirInTemp; // process inlet air temperature [C] @@ -224,7 +224,7 @@ namespace DesiccantDehumidifiers { NomRotorPower(0.0), RegenCoilIndex(0), RegenFanIndex(0), regenFanType(HVAC::FanType::Invalid), ProcDryBulbCurvefTW(0), ProcDryBulbCurvefV(0), ProcHumRatCurvefTW(0), ProcHumRatCurvefV(0), RegenEnergyCurvefTW(0), RegenEnergyCurvefV(0), RegenVelCurvefTW(0), RegenVelCurvefV(0), NomRegenTemp(121.0), MinProcAirInTemp(-73.3), MaxProcAirInTemp(65.6), MinProcAirInHumRat(0.0), - MaxProcAirInHumRat(0.21273), SchedPtr(0), NomProcAirMassFlow(0.0), NomRegenAirMassFlow(0.0), ProcAirInTemp(0.0), ProcAirInHumRat(0.0), + MaxProcAirInHumRat(0.21273), NomProcAirMassFlow(0.0), NomRegenAirMassFlow(0.0), ProcAirInTemp(0.0), ProcAirInHumRat(0.0), ProcAirInEnthalpy(0.0), ProcAirInMassFlowRate(0.0), ProcAirOutTemp(0.0), ProcAirOutHumRat(0.0), ProcAirOutEnthalpy(0.0), ProcAirOutMassFlowRate(0.0), RegenAirInTemp(0.0), RegenAirInHumRat(0.0), RegenAirInEnthalpy(0.0), RegenAirInMassFlowRate(0.0), RegenAirVel(0.0), DehumTypeCode(DesicDehumType::Invalid), WaterRemove(0.0), WaterRemoveRate(0.0), SpecRegenEnergy(0.0), QRegen(0.0), @@ -307,6 +307,10 @@ struct DesiccantDehumidifiersData : BaseGlobalStruct Array1D_bool MyPlantScanFlag; // Used for init plant component for heating coils Real64 QRegen = 0.0; // required coil load passed to sim heating coil routine (W) + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/DisplacementVentMgr.cc b/src/EnergyPlus/DisplacementVentMgr.cc index 3c687532b1d..86e093083d1 100644 --- a/src/EnergyPlus/DisplacementVentMgr.cc +++ b/src/EnergyPlus/DisplacementVentMgr.cc @@ -176,7 +176,6 @@ namespace RoomAir { // Using/Aliasing using namespace DataEnvironment; using namespace DataHeatBalance; - using ScheduleManager::GetScheduleIndex; // SUBROUTINE LOCAL VARIABLE DECLARATIONS: Real64 HLD; // Convection coefficient for the lower area of surface @@ -513,8 +512,6 @@ namespace RoomAir { using Psychrometrics::PsyCpAirFnW; using Psychrometrics::PsyRhoAirFnPbTdbW; - using ScheduleManager::GetCurrentScheduleValue; - using ScheduleManager::GetScheduleIndex; // SUBROUTINE PARAMETER DEFINITIONS: Real64 const OneThird(1.0 / 3.0); @@ -592,7 +589,7 @@ namespace RoomAir { for (int Ctd = 1; Ctd <= state.dataRoomAir->TotDispVent3Node; ++Ctd) { auto &zoneDV3N = state.dataRoomAir->ZoneDispVent3Node(Ctd); if (ZoneNum == zoneDV3N.ZonePtr) { - GainsFrac = GetCurrentScheduleValue(state, zoneDV3N.SchedGainsPtr); + GainsFrac = zoneDV3N.gainsSched->getCurrentVal(); NumPLPP = zoneDV3N.NumPlumesPerOcc; HeightThermostat = zoneDV3N.ThermostatHeight; HeightComfort = zoneDV3N.ComfortHeight; diff --git a/src/EnergyPlus/DisplacementVentMgr.hh b/src/EnergyPlus/DisplacementVentMgr.hh index 9afcfe76436..2b6bcab0a0f 100644 --- a/src/EnergyPlus/DisplacementVentMgr.hh +++ b/src/EnergyPlus/DisplacementVentMgr.hh @@ -158,6 +158,10 @@ struct DisplacementVentMgrData : BaseGlobalStruct Real64 TempDepCoef = 0.0; // Formerly CoefSumha, coef in zone temp equation with dimensions of h*A Real64 TempIndCoef = 0.0; // Formerly CoefSumhat, coef in zone temp equation with dimensions of h*A(T1 + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/DualDuct.cc b/src/EnergyPlus/DualDuct.cc index ae896577a69..d1bd1d15056 100644 --- a/src/EnergyPlus/DualDuct.cc +++ b/src/EnergyPlus/DualDuct.cc @@ -201,6 +201,7 @@ namespace DualDuct { // SUBROUTINE PARAMETER DEFINITIONS: static constexpr std::string_view RoutineName("GetDualDuctInput: "); // include trailing bla + static constexpr std::string_view routineName = "GetDualDuctInput"; // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int NumAlphas; @@ -244,6 +245,8 @@ namespace DualDuct { cAlphaFields, cNumericFields); + ErrorObjectHeader eoh{routineName, CurrentModuleObject, AlphArray(1)}; + // Anything below this line in this control block should use DDNum int DDNum = DamperIndex; auto &thisDD = state.dataDualDuct->dd_airterminal(DDNum); @@ -252,14 +255,10 @@ namespace DualDuct { thisDD.Name = AlphArray(1); thisDD.DamperType = DualDuctDamper::ConstantVolume; if (lAlphaBlanks(2)) { - thisDD.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - thisDD.SchedPtr = ScheduleManager::GetScheduleIndex(state, AlphArray(2)); - if (thisDD.SchedPtr == 0) { - ShowSevereError(state, - format("{}, \"{}\" {} = {} not found.", CurrentModuleObject, thisDD.Name, cAlphaFields(2), AlphArray(2))); - ErrorsFound = true; - } + thisDD.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((thisDD.availSched = Sched::GetSchedule(state, AlphArray(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(2), AlphArray(2)); + ErrorsFound = true; } thisDD.OutletNodeNum = GetOnlySingleNode(state, AlphArray(3), @@ -383,6 +382,8 @@ namespace DualDuct { cAlphaFields, cNumericFields); + ErrorObjectHeader eoh{routineName, CurrentModuleObject, AlphArray(1)}; + // Anything below this line in this control block should use DDNum int DDNum = DamperIndex + NumDualDuctConstVolDampers; auto &thisDD = state.dataDualDuct->dd_airterminal(DDNum); @@ -391,14 +392,10 @@ namespace DualDuct { thisDD.Name = AlphArray(1); thisDD.DamperType = DualDuctDamper::VariableVolume; if (lAlphaBlanks(2)) { - thisDD.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - thisDD.SchedPtr = ScheduleManager::GetScheduleIndex(state, AlphArray(2)); - if (thisDD.SchedPtr == 0) { - ShowSevereError(state, - format("{}, \"{}\" {} = {} not found.", CurrentModuleObject, thisDD.Name, cAlphaFields(2), AlphArray(2))); - ErrorsFound = true; - } + thisDD.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((thisDD.availSched = Sched::GetSchedule(state, AlphArray(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(2), AlphArray(2)); + ErrorsFound = true; } thisDD.OutletNodeNum = GetOnlySingleNode(state, AlphArray(3), @@ -488,15 +485,9 @@ namespace DualDuct { if (lAlphaBlanks(7)) { thisDD.ZoneTurndownMinAirFrac = 1.0; - thisDD.ZoneTurndownMinAirFracSchExist = false; - } else { - thisDD.ZoneTurndownMinAirFracSchPtr = ScheduleManager::GetScheduleIndex(state, AlphArray(7)); - if (thisDD.ZoneTurndownMinAirFracSchPtr == 0) { - ShowSevereError(state, format("{} = {} not found.", cAlphaFields(7), AlphArray(7))); - ShowContinueError(state, format("Occurs in {} = {}", cCMO_DDVariableVolume, thisDD.Name)); - ErrorsFound = true; - } - thisDD.ZoneTurndownMinAirFracSchExist = true; + } else if ((thisDD.zoneTurndownMinAirFracSched = Sched::GetSchedule(state, AlphArray(7))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(7), AlphArray(7)); + ErrorsFound = true; } // Setup the Average damper Position output variable @@ -543,6 +534,8 @@ namespace DualDuct { cAlphaFields, cNumericFields); + ErrorObjectHeader eoh{routineName, CurrentModuleObject, AlphArray(1)}; + // Anything below this line in this control block should use DDNum int DDNum = DamperIndex + NumDualDuctConstVolDampers + NumDualDuctVarVolDampers; auto &thisDD = state.dataDualDuct->dd_airterminal(DDNum); @@ -551,14 +544,10 @@ namespace DualDuct { thisDD.Name = AlphArray(1); thisDD.DamperType = DualDuctDamper::OutdoorAir; if (lAlphaBlanks(2)) { - thisDD.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - thisDD.SchedPtr = ScheduleManager::GetScheduleIndex(state, AlphArray(2)); - if (thisDD.SchedPtr == 0) { - ShowSevereError(state, - format("{}, \"{}\" {} = {} not found.", CurrentModuleObject, thisDD.Name, cAlphaFields(2), AlphArray(2))); - ErrorsFound = true; - } + thisDD.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((thisDD.availSched = Sched::GetSchedule(state, AlphArray(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(2), AlphArray(2)); + ErrorsFound = true; } thisDD.OutletNodeNum = GetOnlySingleNode(state, AlphArray(3), @@ -800,8 +789,8 @@ namespace DualDuct { state.dataLoopNodes->Node(OutNode).MassFlowRateMin = 0.0; } else if (this->DamperType == DualDuctDamper::VariableVolume) { // get dual duct air terminal box minimum flow fraction value - if (this->ZoneTurndownMinAirFracSchExist) { - this->ZoneTurndownMinAirFrac = ScheduleManager::GetScheduleMinValue(state, this->ZoneTurndownMinAirFracSchPtr); + if (this->zoneTurndownMinAirFracSched != nullptr) { + this->ZoneTurndownMinAirFrac = this->zoneTurndownMinAirFracSched->getMinVal(state); } else { this->ZoneTurndownMinAirFrac = 1.0; } @@ -884,7 +873,7 @@ namespace DualDuct { if (this->DamperType == DualDuctDamper::ConstantVolume || this->DamperType == DualDuctDamper::VariableVolume) { auto &thisHotInNode = state.dataLoopNodes->Node(HotInNode); auto &thisColdInNode = state.dataLoopNodes->Node(ColdInNode); - Real64 schedValue = ScheduleManager::GetCurrentScheduleValue(state, this->SchedPtr); + Real64 schedValue = this->availSched->getCurrentVal(); if ((thisHotInNode.MassFlowRate > 0.0) && (schedValue > 0.0)) { thisHotInNode.MassFlowRate = this->dd_airterminalHotAirInlet.AirMassFlowRateMax; } else { @@ -907,8 +896,8 @@ namespace DualDuct { thisColdInNode.MassFlowRateMaxAvail = 0.0; } // get current time step air terminal box turndown minimum flow fraction - if (this->ZoneTurndownMinAirFracSchExist) { - this->ZoneTurndownMinAirFrac = ScheduleManager::GetCurrentScheduleValue(state, this->ZoneTurndownMinAirFracSchPtr); + if (this->zoneTurndownMinAirFracSched != nullptr) { + this->ZoneTurndownMinAirFrac = this->zoneTurndownMinAirFracSched->getCurrentVal(); } else { this->ZoneTurndownMinAirFrac = 1.0; } @@ -928,7 +917,7 @@ namespace DualDuct { } else if (this->DamperType == DualDuctDamper::OutdoorAir) { auto &thisOAInNode = state.dataLoopNodes->Node(OAInNode); - Real64 schedValue = ScheduleManager::GetCurrentScheduleValue(state, this->SchedPtr); + Real64 schedValue = this->availSched->getCurrentVal(); // The first time through set the mass flow rate to the Max for VAV:OutdoorAir if ((thisOAInNode.MassFlowRate > 0.0) && (schedValue > 0.0)) { thisOAInNode.MassFlowRate = this->dd_airterminalOAInlet.AirMassFlowRateMax; @@ -1115,7 +1104,7 @@ namespace DualDuct { // Get the calculated load from the Heat Balance from ZoneSysEnergyDemand QTotLoad = state.dataZoneEnergyDemand->ZoneSysEnergyDemand(ZoneNum).RemainingOutputRequired; // Need the design MassFlowRate for calculations - if (ScheduleManager::GetCurrentScheduleValue(state, this->SchedPtr) > 0.0) { + if (this->availSched->getCurrentVal() > 0.0) { MassFlow = this->dd_airterminalHotAirInlet.AirMassFlowRateMaxAvail / 2.0 + this->dd_airterminalColdAirInlet.AirMassFlowRateMaxAvail / 2.0; } else { MassFlow = 0.0; @@ -1243,7 +1232,7 @@ namespace DualDuct { // the massflow rate of either heating or cooling is determined to meet the entire load. Then // if the massflow is below the minimum or greater than the Max it is set to either the Min // or the Max as specified for the VAV model. - if (ScheduleManager::GetCurrentScheduleValue(state, this->SchedPtr) == 0.0) { + if (this->availSched->getCurrentVal() == 0.0) { // System is Off set massflow to 0.0 MassFlow = 0.0; @@ -1476,10 +1465,11 @@ namespace DualDuct { QOALoad = this->dd_airterminalOAInlet.AirMassFlowRate * (CpAirSysOA * this->dd_airterminalOAInlet.AirTemp - CpAirZn * state.dataLoopNodes->Node(ZoneNodeNum).Temp); + auto const &zoneTstatSetpt = state.dataHeatBalFanSys->zoneTstatSetpts(ZoneNum); QOALoadToHeatSP = this->dd_airterminalOAInlet.AirMassFlowRate * (CpAirSysOA * this->dd_airterminalOAInlet.AirTemp - - CpAirZn * state.dataHeatBalFanSys->ZoneThermostatSetPointLo(ZoneNum)); + CpAirZn * zoneTstatSetpt.setptLo); QOALoadToCoolSP = this->dd_airterminalOAInlet.AirMassFlowRate * (CpAirSysOA * this->dd_airterminalOAInlet.AirTemp - - CpAirZn * state.dataHeatBalFanSys->ZoneThermostatSetPointHi(ZoneNum)); + CpAirZn * zoneTstatSetpt.setptHi); } else { QOALoad = 0.0; @@ -1548,7 +1538,7 @@ namespace DualDuct { // Find the Max Box Flow Rate. MassFlowMax = this->dd_airterminalOAInlet.AirMassFlowRateMaxAvail + this->dd_airterminalRecircAirInlet.AirMassFlowRateMaxAvail; - if (ScheduleManager::GetCurrentScheduleValue(state, this->SchedPtr) > 0.0) { + if (this->availSched->getCurrentVal() > 0.0) { TotMassFlow = this->dd_airterminalOAInlet.AirMassFlowRate + this->dd_airterminalRecircAirInlet.AirMassFlowRate; } else { TotMassFlow = 0.0; @@ -2053,17 +2043,16 @@ namespace DualDuct { OutputReportPredefined::PreDefTableEntry(state, orp->pdchAirTermTypeInp, adu.Name, dualDuctDamperNames[(int)this->DamperType]); OutputReportPredefined::PreDefTableEntry(state, orp->pdchAirTermPrimFlow, adu.Name, this->MaxAirVolFlowRate); OutputReportPredefined::PreDefTableEntry(state, orp->pdchAirTermSecdFlow, adu.Name, "n/a"); - if (this->ZoneTurndownMinAirFracSchPtr > 0) { + if (this->zoneTurndownMinAirFracSched != nullptr) { OutputReportPredefined::PreDefTableEntry( - state, orp->pdchAirTermMinFlowSch, adu.Name, ScheduleManager::GetScheduleName(state, this->ZoneTurndownMinAirFracSchPtr)); + state, orp->pdchAirTermMinFlowSch, adu.Name, this->zoneTurndownMinAirFracSched->Name); } else { OutputReportPredefined::PreDefTableEntry(state, orp->pdchAirTermMinFlowSch, adu.Name, "n/a"); } OutputReportPredefined::PreDefTableEntry(state, orp->pdchAirTermMaxFlowReh, adu.Name, "n/a"); std::string schName = "n/a"; if (this->OARequirementsPtr > 0) { - int minOAsch = state.dataSize->OARequirements(this->OARequirementsPtr).OAFlowFracSchPtr; - if (minOAsch > 0) schName = ScheduleManager::GetScheduleName(state, minOAsch); + schName = state.dataSize->OARequirements(this->OARequirementsPtr).oaFlowFracSched->Name; } OutputReportPredefined::PreDefTableEntry(state, orp->pdchAirTermMinOAflowSch, adu.Name, schName); OutputReportPredefined::PreDefTableEntry(state, orp->pdchAirTermHeatCoilType, adu.Name, "n/a"); diff --git a/src/EnergyPlus/DualDuct.hh b/src/EnergyPlus/DualDuct.hh index f99c2cb262d..c6a06df43fa 100644 --- a/src/EnergyPlus/DualDuct.hh +++ b/src/EnergyPlus/DualDuct.hh @@ -104,7 +104,7 @@ namespace DualDuct { { std::string Name; // Name of the Damper DualDuctDamper DamperType = DualDuctDamper::Invalid; // Type of Damper ie. VAV, Mixing, Inducing, etc. - int SchedPtr = 0; // Pointer to the correct schedule + Sched::Schedule *availSched = nullptr; // Pointer to the correct schedule // brazenly assume that this is an availability schedule Real64 MaxAirVolFlowRate = 0.0; // Max Specified Volume Flow Rate of Damper [m3/sec] Real64 MaxAirMassFlowRate = 0.0; // Max Specified MAss Flow Rate of Damper [kg/s] int HotAirInletNodeNum = 0; @@ -130,9 +130,8 @@ namespace DualDuct { int OARequirementsPtr = 0; // - Index to DesignSpecification:OutdoorAir object PerPersonMode OAPerPersonMode = PerPersonMode::ModeNotSet; // mode for how per person rates are determined, DCV or design. int AirLoopNum = 0; // index to airloop that this terminal unit is connected to - int ZoneTurndownMinAirFracSchPtr = 0; // pointer to the schedule for turndown minimum airflow fraction + Sched::Schedule *zoneTurndownMinAirFracSched = nullptr; // pointer to the schedule for turndown minimum airflow fraction Real64 ZoneTurndownMinAirFrac = 1.0; // turndown minimum airflow fraction value, multiplier of zone design minimum air flow - bool ZoneTurndownMinAirFracSchExist = false; // if true, if zone turndown min air frac schedule exist bool MyEnvrnFlag = true; // environment flag bool MySizeFlag = true; // sizing flag bool MyAirLoopFlag = true; // airloop flag @@ -192,6 +191,10 @@ struct DualDuctData : BaseGlobalStruct Array1D_bool RecircIsUsedARR; Array1D_string DamperNamesARR; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/EMSManager.cc b/src/EnergyPlus/EMSManager.cc index bb2105de660..7c33814d603 100644 --- a/src/EnergyPlus/EMSManager.cc +++ b/src/EnergyPlus/EMSManager.cc @@ -443,7 +443,7 @@ namespace EMSManager { for (int SensorNum = 1; SensorNum <= state.dataRuntimeLang->NumSensors; ++SensorNum) { int ErlVariableNum = state.dataRuntimeLang->Sensor(SensorNum).VariableNum; if ((ErlVariableNum > 0) && (state.dataRuntimeLang->Sensor(SensorNum).Index > -1)) { - if (state.dataRuntimeLang->Sensor(SensorNum).SchedNum == 0) { // not a schedule so get from output processor + if (state.dataRuntimeLang->Sensor(SensorNum).sched == nullptr) { // not a schedule so get from output processor state.dataRuntimeLang->ErlVariable(ErlVariableNum).Value = RuntimeLanguageProcessor::SetErlValueNumber( GetInternalVariableValue( @@ -452,7 +452,7 @@ namespace EMSManager { } else { // schedule so use schedule service state.dataRuntimeLang->ErlVariable(ErlVariableNum).Value = RuntimeLanguageProcessor::SetErlValueNumber( - ScheduleManager::GetCurrentScheduleValue(state, state.dataRuntimeLang->Sensor(SensorNum).SchedNum), + state.dataRuntimeLang->Sensor(SensorNum).sched->getCurrentVal(), state.dataRuntimeLang->ErlVariable(ErlVariableNum).Value); } } @@ -995,9 +995,8 @@ namespace EMSManager { state.dataRuntimeLang->Sensor(SensorNum).CheckedOkay = true; // If variable is Schedule Value, then get the schedule id to register it as being used if (Util::SameString(state.dataRuntimeLang->Sensor(SensorNum).OutputVarName, "Schedule Value")) { - state.dataRuntimeLang->Sensor(SensorNum).SchedNum = - ScheduleManager::GetScheduleIndex(state, state.dataRuntimeLang->Sensor(SensorNum).UniqueKeyName); - if (state.dataRuntimeLang->Sensor(SensorNum).SchedNum == 0) { + state.dataRuntimeLang->Sensor(SensorNum).sched = Sched::GetSchedule(state, state.dataRuntimeLang->Sensor(SensorNum).UniqueKeyName); + if (state.dataRuntimeLang->Sensor(SensorNum).sched == nullptr) { state.dataRuntimeLang->Sensor(SensorNum).CheckedOkay = false; if (reportErrors) { ShowSevereError(state, @@ -1589,14 +1588,12 @@ namespace EMSManager { return FoundControl; } - bool isScheduleManaged(EnergyPlusData &state, int const scheduleNum) + bool isScheduleManaged(EnergyPlusData &state, Sched::Schedule *sched) { // Check if a specific schedule has an EMS or External Interface actuator assigned to it static constexpr std::string_view cControlTypeName = "SCHEDULE VALUE"; - std::string_view cSchedName = state.dataScheduleMgr->Schedule(scheduleNum).Name; - for (int Loop = 1; Loop <= state.dataRuntimeLang->numActuatorsUsed + state.dataRuntimeLang->NumExternalInterfaceActuatorsUsed; ++Loop) { - if ((Util::SameString(state.dataRuntimeLang->EMSActuatorUsed(Loop).UniqueIDName, cSchedName)) && + if ((Util::SameString(state.dataRuntimeLang->EMSActuatorUsed(Loop).UniqueIDName, sched->Name)) && (Util::SameString(state.dataRuntimeLang->EMSActuatorUsed(Loop).ControlTypeName, cControlTypeName))) { return true; } diff --git a/src/EnergyPlus/EMSManager.hh b/src/EnergyPlus/EMSManager.hh index 929d7265823..22f9fe71b45 100644 --- a/src/EnergyPlus/EMSManager.hh +++ b/src/EnergyPlus/EMSManager.hh @@ -135,7 +135,7 @@ namespace EMSManager { int nodeNum, // index of node being checked. std::string const &varName); - bool isScheduleManaged(EnergyPlusData &state, int const scheduleNum); + bool isScheduleManaged(EnergyPlusData &state, Sched::Schedule *const sched); void SetupPrimaryAirSystemAvailMgrAsActuators(EnergyPlusData &state); @@ -201,6 +201,10 @@ struct EMSManagerData : BaseGlobalStruct bool lDummy = false; // dummy pointer location bool lDummy2 = false; // dummy pointer location + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/EarthTube.cc b/src/EnergyPlus/EarthTube.cc index 3a8bb30db2a..77d5a6f806c 100644 --- a/src/EnergyPlus/EarthTube.cc +++ b/src/EnergyPlus/EarthTube.cc @@ -142,6 +142,8 @@ void GetEarthTube(EnergyPlusData &state, bool &ErrorsFound) // If errors found i // This subroutine obtains input data for EarthTube units and // stores it in the EarthTube data structure. + static constexpr std::string_view routineName = "GetEarthTube"; + // SUBROUTINE PARAMETER DEFINITIONS: Real64 constexpr EarthTubeTempLimit(100.0); // degrees Celsius @@ -157,228 +159,214 @@ void GetEarthTube(EnergyPlusData &state, bool &ErrorsFound) // If errors found i // Following used for reporting state.dataEarthTube->ZnRptET.allocate(state.dataGlobal->NumOfZones); - std::string_view cCurrentModuleObject = "ZoneEarthtube:Parameters"; - int totEarthTubePars = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); + auto &s_ipsc = state.dataIPShortCut; + + s_ipsc->cCurrentModuleObject = "ZoneEarthtube:Parameters"; + + int totEarthTubePars = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, s_ipsc->cCurrentModuleObject); state.dataEarthTube->EarthTubePars.allocate(totEarthTubePars); for (Loop = 1; Loop <= totEarthTubePars; ++Loop) { auto &thisEarthTubePars = state.dataEarthTube->EarthTubePars(Loop); state.dataInputProcessing->inputProcessor->getObjectItem(state, - cCurrentModuleObject, + s_ipsc->cCurrentModuleObject, Loop, - state.dataIPShortCut->cAlphaArgs, + s_ipsc->cAlphaArgs, NumAlpha, - state.dataIPShortCut->rNumericArgs, + s_ipsc->rNumericArgs, NumNumber, IOStat, - state.dataIPShortCut->lNumericFieldBlanks, - state.dataIPShortCut->lAlphaFieldBlanks, - state.dataIPShortCut->cAlphaFieldNames, - state.dataIPShortCut->cNumericFieldNames); + s_ipsc->lNumericFieldBlanks, + s_ipsc->lAlphaFieldBlanks, + s_ipsc->cAlphaFieldNames, + s_ipsc->cNumericFieldNames); - thisEarthTubePars.nameParameters = state.dataIPShortCut->cAlphaArgs(1); + thisEarthTubePars.nameParameters = s_ipsc->cAlphaArgs(1); // Check to make sure name is unique for (int otherParams = 1; otherParams < Loop; ++otherParams) { if (Util::SameString(thisEarthTubePars.nameParameters, state.dataEarthTube->EarthTubePars(otherParams).nameParameters)) { ShowSevereError(state, format("{}: {} = {} is not a unique name.", - cCurrentModuleObject, - state.dataIPShortCut->cAlphaFieldNames(1), - state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("Check the other {} names for a duplicate.", cCurrentModuleObject)); + s_ipsc->cCurrentModuleObject, + s_ipsc->cAlphaFieldNames(1), + s_ipsc->cAlphaArgs(1))); + ShowContinueError(state, format("Check the other {} names for a duplicate.", s_ipsc->cCurrentModuleObject)); ErrorsFound = true; } } - thisEarthTubePars.numNodesAbove = state.dataIPShortCut->rNumericArgs(1); - thisEarthTubePars.numNodesBelow = state.dataIPShortCut->rNumericArgs(2); - thisEarthTubePars.dimBoundAbove = state.dataIPShortCut->rNumericArgs(3); - thisEarthTubePars.dimBoundBelow = state.dataIPShortCut->rNumericArgs(4); - thisEarthTubePars.width = state.dataIPShortCut->rNumericArgs(5); + thisEarthTubePars.numNodesAbove = s_ipsc->rNumericArgs(1); + thisEarthTubePars.numNodesBelow = s_ipsc->rNumericArgs(2); + thisEarthTubePars.dimBoundAbove = s_ipsc->rNumericArgs(3); + thisEarthTubePars.dimBoundBelow = s_ipsc->rNumericArgs(4); + thisEarthTubePars.width = s_ipsc->rNumericArgs(5); } - cCurrentModuleObject = "ZoneEarthtube"; - totEarthTube = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); + s_ipsc->cCurrentModuleObject = "ZoneEarthtube"; + totEarthTube = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, s_ipsc->cCurrentModuleObject); state.dataEarthTube->EarthTubeSys.allocate(totEarthTube); for (Loop = 1; Loop <= totEarthTube; ++Loop) { auto &thisEarthTube = state.dataEarthTube->EarthTubeSys(Loop); state.dataInputProcessing->inputProcessor->getObjectItem(state, - cCurrentModuleObject, + s_ipsc->cCurrentModuleObject, Loop, - state.dataIPShortCut->cAlphaArgs, + s_ipsc->cAlphaArgs, NumAlpha, - state.dataIPShortCut->rNumericArgs, + s_ipsc->rNumericArgs, NumNumber, IOStat, - state.dataIPShortCut->lNumericFieldBlanks, - state.dataIPShortCut->lAlphaFieldBlanks, - state.dataIPShortCut->cAlphaFieldNames, - state.dataIPShortCut->cNumericFieldNames); + s_ipsc->lNumericFieldBlanks, + s_ipsc->lAlphaFieldBlanks, + s_ipsc->cAlphaFieldNames, + s_ipsc->cNumericFieldNames); + ErrorObjectHeader eoh{routineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)}; + // First Alpha is Zone Name - thisEarthTube.ZonePtr = Util::FindItemInList(state.dataIPShortCut->cAlphaArgs(1), state.dataHeatBal->Zone); + thisEarthTube.ZonePtr = Util::FindItemInList(s_ipsc->cAlphaArgs(1), state.dataHeatBal->Zone); if (thisEarthTube.ZonePtr == 0) { ShowSevereError( state, - format("{}: {} not found={}", cCurrentModuleObject, state.dataIPShortCut->cAlphaFieldNames(1), state.dataIPShortCut->cAlphaArgs(1))); + format("{}: {} not found={}", s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaFieldNames(1), s_ipsc->cAlphaArgs(1))); ErrorsFound = true; } // Second Alpha is Schedule Name - thisEarthTube.SchedPtr = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(2)); - if (thisEarthTube.SchedPtr == 0) { - if (state.dataIPShortCut->lAlphaFieldBlanks(2)) { - ShowSevereError(state, - format("{}: {} is required, missing for {}={}", - cCurrentModuleObject, - state.dataIPShortCut->cAlphaFieldNames(2), - state.dataIPShortCut->cAlphaFieldNames(1), - state.dataIPShortCut->cAlphaArgs(1))); - } else { - ShowSevereError(state, - format("{}: invalid {} entered={} for {}={}", - cCurrentModuleObject, - state.dataIPShortCut->cAlphaFieldNames(2), - state.dataIPShortCut->cAlphaArgs(2), - state.dataIPShortCut->cAlphaFieldNames(1), - state.dataIPShortCut->cAlphaArgs(1))); - } + if (s_ipsc->lAlphaFieldBlanks(2)) { + ShowSevereEmptyField(state, eoh, s_ipsc->cAlphaFieldNames(2)); + ErrorsFound = true; + } else if ((thisEarthTube.availSched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2)); ErrorsFound = true; } // Overall parameters and their limits - thisEarthTube.DesignLevel = state.dataIPShortCut->rNumericArgs(1); + thisEarthTube.DesignLevel = s_ipsc->rNumericArgs(1); - thisEarthTube.MinTemperature = state.dataIPShortCut->rNumericArgs(2); + thisEarthTube.MinTemperature = s_ipsc->rNumericArgs(2); if ((thisEarthTube.MinTemperature < -EarthTubeTempLimit) || (thisEarthTube.MinTemperature > EarthTubeTempLimit)) { ShowSevereError(state, format("{}: {}={} must have a minimum temperature between -{:.0R}C and {:.0R}C", - cCurrentModuleObject, - state.dataIPShortCut->cAlphaFieldNames(1), - state.dataIPShortCut->cAlphaArgs(1), + s_ipsc->cCurrentModuleObject, + s_ipsc->cAlphaFieldNames(1), + s_ipsc->cAlphaArgs(1), EarthTubeTempLimit, EarthTubeTempLimit)); ShowContinueError(state, format("Entered value={:.0R}", thisEarthTube.MinTemperature)); ErrorsFound = true; } - thisEarthTube.MaxTemperature = state.dataIPShortCut->rNumericArgs(3); + thisEarthTube.MaxTemperature = s_ipsc->rNumericArgs(3); if ((thisEarthTube.MaxTemperature < -EarthTubeTempLimit) || (thisEarthTube.MaxTemperature > EarthTubeTempLimit)) { ShowSevereError(state, format("{}: {}={} must have a maximum temperature between -{:.0R}C and {:.0R}C", - cCurrentModuleObject, - state.dataIPShortCut->cAlphaFieldNames(1), - state.dataIPShortCut->cAlphaArgs(1), + s_ipsc->cCurrentModuleObject, + s_ipsc->cAlphaFieldNames(1), + s_ipsc->cAlphaArgs(1), EarthTubeTempLimit, EarthTubeTempLimit)); ShowContinueError(state, format("Entered value={:.0R}", thisEarthTube.MaxTemperature)); ErrorsFound = true; } - thisEarthTube.DelTemperature = state.dataIPShortCut->rNumericArgs(4); // 3/12/03 Negative del temp now allowed COP + thisEarthTube.DelTemperature = s_ipsc->rNumericArgs(4); // 3/12/03 Negative del temp now allowed COP // if we have a blank, then just set it to the Natural type, otherwise, search on it - if (state.dataIPShortCut->cAlphaArgs(3).empty()) { + if (s_ipsc->cAlphaArgs(3).empty()) { thisEarthTube.FanType = Ventilation::Natural; } else { - thisEarthTube.FanType = static_cast(getEnumValue(ventilationNamesUC, state.dataIPShortCut->cAlphaArgs(3))); + thisEarthTube.FanType = static_cast(getEnumValue(ventilationNamesUC, s_ipsc->cAlphaArgs(3))); if (thisEarthTube.FanType == Ventilation::Invalid) { - ShowSevereError(state, - format("{}: {}={}, {} invalid={}", - cCurrentModuleObject, - state.dataIPShortCut->cAlphaFieldNames(1), - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaFieldNames(3), - state.dataIPShortCut->cAlphaArgs(3))); + ShowSevereInvalidKey(state, eoh, s_ipsc->cAlphaFieldNames(3), s_ipsc->cAlphaArgs(3)); ErrorsFound = true; } } - thisEarthTube.FanPressure = state.dataIPShortCut->rNumericArgs(5); + thisEarthTube.FanPressure = s_ipsc->rNumericArgs(5); if (thisEarthTube.FanPressure < 0.0) { ShowSevereError(state, format("{}: {}={}, {} must be positive, entered value={:.2R}", - cCurrentModuleObject, - state.dataIPShortCut->cAlphaFieldNames(1), - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cNumericFieldNames(5), + s_ipsc->cCurrentModuleObject, + s_ipsc->cAlphaFieldNames(1), + s_ipsc->cAlphaArgs(1), + s_ipsc->cNumericFieldNames(5), thisEarthTube.FanPressure)); ErrorsFound = true; } - thisEarthTube.FanEfficiency = state.dataIPShortCut->rNumericArgs(6); + thisEarthTube.FanEfficiency = s_ipsc->rNumericArgs(6); if ((thisEarthTube.FanEfficiency <= 0.0) || (thisEarthTube.FanEfficiency > 1.0)) { ShowSevereError(state, format("{}: {}={}, {} must be greater than zero and less than or equal to one, entered value={:.2R}", - cCurrentModuleObject, - state.dataIPShortCut->cAlphaFieldNames(1), - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cNumericFieldNames(6), + s_ipsc->cCurrentModuleObject, + s_ipsc->cAlphaFieldNames(1), + s_ipsc->cAlphaArgs(1), + s_ipsc->cNumericFieldNames(6), thisEarthTube.FanEfficiency)); ErrorsFound = true; } - thisEarthTube.r1 = state.dataIPShortCut->rNumericArgs(7); + thisEarthTube.r1 = s_ipsc->rNumericArgs(7); if (thisEarthTube.r1 <= 0.0) { ShowSevereError(state, format("{}: {}={}, {} must be positive, entered value={:.2R}", - cCurrentModuleObject, - state.dataIPShortCut->cAlphaFieldNames(1), - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cNumericFieldNames(7), + s_ipsc->cCurrentModuleObject, + s_ipsc->cAlphaFieldNames(1), + s_ipsc->cAlphaArgs(1), + s_ipsc->cNumericFieldNames(7), thisEarthTube.r1)); ErrorsFound = true; } - thisEarthTube.r2 = state.dataIPShortCut->rNumericArgs(8); + thisEarthTube.r2 = s_ipsc->rNumericArgs(8); if (thisEarthTube.r2 <= 0.0) { ShowSevereError(state, format("{}: {}={}, {} must be positive, entered value={:.2R}", - cCurrentModuleObject, - state.dataIPShortCut->cAlphaFieldNames(1), - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cNumericFieldNames(8), + s_ipsc->cCurrentModuleObject, + s_ipsc->cAlphaFieldNames(1), + s_ipsc->cAlphaArgs(1), + s_ipsc->cNumericFieldNames(8), thisEarthTube.r2)); ErrorsFound = true; } thisEarthTube.r3 = 2.0 * thisEarthTube.r1; - thisEarthTube.PipeLength = state.dataIPShortCut->rNumericArgs(9); + thisEarthTube.PipeLength = s_ipsc->rNumericArgs(9); if (thisEarthTube.PipeLength <= 0.0) { ShowSevereError(state, format("{}: {}={}, {} must be positive, entered value={:.2R}", - cCurrentModuleObject, - state.dataIPShortCut->cAlphaFieldNames(1), - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cNumericFieldNames(9), + s_ipsc->cCurrentModuleObject, + s_ipsc->cAlphaFieldNames(1), + s_ipsc->cAlphaArgs(1), + s_ipsc->cNumericFieldNames(9), thisEarthTube.PipeLength)); ErrorsFound = true; } - thisEarthTube.PipeThermCond = state.dataIPShortCut->rNumericArgs(10); + thisEarthTube.PipeThermCond = s_ipsc->rNumericArgs(10); if (thisEarthTube.PipeThermCond <= 0.0) { ShowSevereError(state, format("{}: {}={}, {} must be positive, entered value={:.2R}", - cCurrentModuleObject, - state.dataIPShortCut->cAlphaFieldNames(1), - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cNumericFieldNames(10), + s_ipsc->cCurrentModuleObject, + s_ipsc->cAlphaFieldNames(1), + s_ipsc->cAlphaArgs(1), + s_ipsc->cNumericFieldNames(10), thisEarthTube.PipeThermCond)); ErrorsFound = true; } - thisEarthTube.z = state.dataIPShortCut->rNumericArgs(11); + thisEarthTube.z = s_ipsc->rNumericArgs(11); if (thisEarthTube.z <= 0.0) { ShowSevereError(state, format("{}: {}={}, {} must be positive, entered value={:.2R}", - cCurrentModuleObject, - state.dataIPShortCut->cAlphaFieldNames(1), - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cNumericFieldNames(11), + s_ipsc->cCurrentModuleObject, + s_ipsc->cAlphaFieldNames(1), + s_ipsc->cAlphaArgs(1), + s_ipsc->cNumericFieldNames(11), thisEarthTube.z)); ErrorsFound = true; } @@ -387,37 +375,31 @@ void GetEarthTube(EnergyPlusData &state, bool &ErrorsFound) // If errors found i // code in initEarthTubeVertical must be modified ShowSevereError(state, format("{}: {}={}, {} must be greater than 3*{} + {} entered value={:.2R} ref sum={:.2R}", - cCurrentModuleObject, - state.dataIPShortCut->cAlphaFieldNames(1), - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cNumericFieldNames(11), - state.dataIPShortCut->cNumericFieldNames(7), - state.dataIPShortCut->cNumericFieldNames(8), + s_ipsc->cCurrentModuleObject, + s_ipsc->cAlphaFieldNames(1), + s_ipsc->cAlphaArgs(1), + s_ipsc->cNumericFieldNames(11), + s_ipsc->cNumericFieldNames(7), + s_ipsc->cNumericFieldNames(8), thisEarthTube.z, thisEarthTube.r1 + thisEarthTube.r2 + thisEarthTube.r3)); ErrorsFound = true; } - SoilType soilType = static_cast(getEnumValue(soilTypeNamesUC, state.dataIPShortCut->cAlphaArgs(4))); + SoilType soilType = static_cast(getEnumValue(soilTypeNamesUC, s_ipsc->cAlphaArgs(4))); constexpr std::array(SoilType::Num)> thermalDiffusivity = {0.0781056, 0.055728, 0.0445824, 0.024192}; constexpr std::array(SoilType::Num)> thermalConductivity = {2.42, 1.3, 0.865, 0.346}; if (soilType == SoilType::Invalid) { - ShowSevereError(state, - format("{}: {}={}, {} invalid={}", - cCurrentModuleObject, - state.dataIPShortCut->cAlphaFieldNames(1), - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaFieldNames(4), - state.dataIPShortCut->cAlphaArgs(4))); + ShowSevereInvalidKey(state, eoh, s_ipsc->cAlphaFieldNames(4), s_ipsc->cAlphaArgs(4)); ErrorsFound = true; } else { thisEarthTube.SoilThermDiff = thermalDiffusivity[static_cast(soilType)]; thisEarthTube.SoilThermCond = thermalConductivity[static_cast(soilType)]; } - thisEarthTube.AverSoilSurTemp = state.dataIPShortCut->rNumericArgs(12); - thisEarthTube.ApmlSoilSurTemp = state.dataIPShortCut->rNumericArgs(13); - thisEarthTube.SoilSurPhaseConst = int(state.dataIPShortCut->rNumericArgs(14)); + thisEarthTube.AverSoilSurTemp = s_ipsc->rNumericArgs(12); + thisEarthTube.ApmlSoilSurTemp = s_ipsc->rNumericArgs(13); + thisEarthTube.SoilSurPhaseConst = int(s_ipsc->rNumericArgs(14)); // Override any user input for cases where natural ventilation is being used if (thisEarthTube.FanType == Ventilation::Natural) { @@ -425,25 +407,19 @@ void GetEarthTube(EnergyPlusData &state, bool &ErrorsFound) // If errors found i thisEarthTube.FanEfficiency = 1.0; } - thisEarthTube.ConstantTermCoef = state.dataIPShortCut->rNumericArgs(15); - thisEarthTube.TemperatureTermCoef = state.dataIPShortCut->rNumericArgs(16); - thisEarthTube.VelocityTermCoef = state.dataIPShortCut->rNumericArgs(17); - thisEarthTube.VelocitySQTermCoef = state.dataIPShortCut->rNumericArgs(18); + thisEarthTube.ConstantTermCoef = s_ipsc->rNumericArgs(15); + thisEarthTube.TemperatureTermCoef = s_ipsc->rNumericArgs(16); + thisEarthTube.VelocityTermCoef = s_ipsc->rNumericArgs(17); + thisEarthTube.VelocitySQTermCoef = s_ipsc->rNumericArgs(18); // cAlphaArgs(5)--Model type: basic or vertical // only process cAlphaArgs(6) if cAlphaArgs(5) is "Vertical" - if (state.dataIPShortCut->cAlphaArgs(5).empty()) { + if (s_ipsc->cAlphaArgs(5).empty()) { thisEarthTube.ModelType = EarthTubeModelType::Basic; } else { - thisEarthTube.ModelType = static_cast(getEnumValue(solutionTypeNamesUC, state.dataIPShortCut->cAlphaArgs(5))); + thisEarthTube.ModelType = static_cast(getEnumValue(solutionTypeNamesUC, s_ipsc->cAlphaArgs(5))); if (thisEarthTube.ModelType == EarthTubeModelType::Invalid) { - ShowSevereError(state, - format("{}: {}={}, {} invalid={}", - cCurrentModuleObject, - state.dataIPShortCut->cAlphaFieldNames(1), - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaFieldNames(5), - state.dataIPShortCut->cAlphaArgs(5))); + ShowSevereInvalidKey(state, eoh, s_ipsc->cAlphaFieldNames(5), s_ipsc->cAlphaArgs(5)); ErrorsFound = true; } } @@ -453,19 +429,13 @@ void GetEarthTube(EnergyPlusData &state, bool &ErrorsFound) // If errors found i // Process the parameters based on the name (link via index) thisEarthTube.vertParametersPtr = 0; for (int parIndex = 1; parIndex <= totEarthTubePars; ++parIndex) { - if (Util::SameString(state.dataIPShortCut->cAlphaArgs(6), state.dataEarthTube->EarthTubePars(parIndex).nameParameters)) { + if (Util::SameString(s_ipsc->cAlphaArgs(6), state.dataEarthTube->EarthTubePars(parIndex).nameParameters)) { thisEarthTube.vertParametersPtr = parIndex; break; } } if (thisEarthTube.vertParametersPtr == 0) { // didn't find a match - ShowSevereError(state, - format("{}: {}={}, Parameter Object {} was not found in the input file.", - cCurrentModuleObject, - state.dataIPShortCut->cAlphaFieldNames(1), - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaArgs(6))); - ShowContinueError(state, "Check this name and make sure one of the earth tube parameters objects matches it."); + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(6), s_ipsc->cAlphaArgs(6)); ErrorsFound = true; } } @@ -601,10 +571,10 @@ void GetEarthTube(EnergyPlusData &state, bool &ErrorsFound) // If errors found i } } - CheckEarthTubesInZones(state, state.dataIPShortCut->cAlphaArgs(1), cCurrentModuleObject, ErrorsFound); + CheckEarthTubesInZones(state, s_ipsc->cAlphaArgs(1), s_ipsc->cCurrentModuleObject, ErrorsFound); if (ErrorsFound) { - ShowFatalError(state, format("{}: Errors getting input. Program terminates.", cCurrentModuleObject)); + ShowFatalError(state, format("{}: Errors getting input. Program terminates.", s_ipsc->cCurrentModuleObject)); } } @@ -654,7 +624,7 @@ void initEarthTubeVertical(EnergyPlusData &state) Real64 thickBottom = thickBase * thisEarthTubeParams.dimBoundBelow / float(thisEarthTubeParams.numNodesBelow); Real64 thickEarthTube = 4.0 * thisEarthTube.r1; Real64 deltat = state.dataGlobal->TimeStepZone; - Real64 thermDiff = thisEarthTube.SoilThermDiff / Constant::HoursInDay; // convert to "per hour" from "per day" + Real64 thermDiff = thisEarthTube.SoilThermDiff / Constant::rHoursInDay; // convert to "per hour" from "per day" // Node equations determine the _Coeff terms--see Engineering Referenve for details on these equation types // Note that node numbers are shifted for c++ arrays that go from 0 to numNodes-1. @@ -874,7 +844,7 @@ void CalcEarthTube(EnergyPlusData &state) if (tempShutDown) { EVF = 0.0; } else { - EVF = thisEarthTube.DesignLevel * ScheduleManager::GetCurrentScheduleValue(state, thisEarthTube.SchedPtr); + EVF = thisEarthTube.DesignLevel * thisEarthTube.availSched->getCurrentVal(); } thisZoneHB.MCPE = EVF * AirDensity * AirSpecHeat * diff --git a/src/EnergyPlus/EarthTube.hh b/src/EnergyPlus/EarthTube.hh index 8f6ebeee8cd..bfb49a98172 100644 --- a/src/EnergyPlus/EarthTube.hh +++ b/src/EnergyPlus/EarthTube.hh @@ -55,6 +55,7 @@ #include #include #include +#include namespace EnergyPlus { @@ -84,7 +85,7 @@ namespace EarthTube { struct EarthTubeData { int ZonePtr = 0; - int SchedPtr = 0; + Sched::Schedule *availSched = nullptr; // Assuming this is an availability schedule Real64 DesignLevel = 0.0; Real64 MinTemperature = 0.0; Real64 MaxTemperature = 0.0; @@ -206,6 +207,10 @@ struct EarthTubeData : BaseGlobalStruct EPVector ZnRptET; EPVector EarthTubePars; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/EcoRoofManager.cc b/src/EnergyPlus/EcoRoofManager.cc index 978713dff92..4f42ba2cbbf 100644 --- a/src/EnergyPlus/EcoRoofManager.cc +++ b/src/EnergyPlus/EcoRoofManager.cc @@ -774,8 +774,8 @@ namespace EcoRoofManager { // DJS 2011 FEB - Since we no longer use CTF with soil-dependent properties (Do not RECALL INITCONDUCTION... // DJS 2011 FEB - we may be able to get away with NO limits on rates of change when using CFD routine. // DJS 2011 FEB - for now we stick with 20% per quarter hour. - RatioMax = 1.0 + 0.20 * state.dataGlobal->MinutesPerTimeStep / 15.0; - RatioMin = 1.0 - 0.20 * state.dataGlobal->MinutesPerTimeStep / 15.0; + RatioMax = 1.0 + 0.20 * state.dataGlobal->MinutesInTimeStep / 15.0; + RatioMin = 1.0 - 0.20 * state.dataGlobal->MinutesInTimeStep / 15.0; auto *mat = state.dataMaterial->materials(state.dataConstruction->Construct(ConstrNum).LayerPoint(1)); assert(mat->group == Material::Group::EcoRoof); @@ -800,16 +800,16 @@ namespace EcoRoofManager { int index1; Real64 const depth_limit(depth_fac * std::pow(state.dataEcoRoofMgr->TopDepth + state.dataEcoRoofMgr->RootDepth, 2.07)); for (index1 = 1; index1 <= 20; ++index1) { - if (double(state.dataGlobal->MinutesPerTimeStep / index1) <= depth_limit) break; + if (double(state.dataGlobal->MinutesInTimeStep / index1) <= depth_limit) break; } if (index1 > 1) { ShowWarningError(state, "CalcEcoRoof: Too few time steps per hour for stability."); - if (ceil(60 * index1 / state.dataGlobal->MinutesPerTimeStep) <= 60) { + if (ceil(60 * index1 / state.dataGlobal->MinutesInTimeStep) <= 60) { ShowContinueError( state, format("...Entered Timesteps per hour=[{}], Change to some value greater than or equal to [{}] for assured stability.", - state.dataGlobal->NumOfTimeStepInHour, - 60 * index1 / state.dataGlobal->MinutesPerTimeStep)); + state.dataGlobal->TimeStepsInHour, + 60 * index1 / state.dataGlobal->MinutesInTimeStep)); ShowContinueError(state, "...Note that EnergyPlus has a maximum of 60 timesteps per hour"); ShowContinueError(state, "...The program will continue, but if the simulation fails due to too low/high temperatures, instability " @@ -818,8 +818,8 @@ namespace EcoRoofManager { ShowContinueError(state, format("...Entered Timesteps per hour=[{}], however the required frequency for stability [{}] is over the " "EnergyPlus maximum of 60.", - state.dataGlobal->NumOfTimeStepInHour, - 60 * index1 / state.dataGlobal->MinutesPerTimeStep)); + state.dataGlobal->TimeStepsInHour, + 60 * index1 / state.dataGlobal->MinutesInTimeStep)); ShowContinueError(state, "...Consider using the simple moisture diffusion calculation method for this application"); ShowContinueError(state, "...The program will continue, but if the simulation fails due to too low/high temperatures, instability " @@ -830,7 +830,7 @@ namespace EcoRoofManager { state.dataEcoRoofMgr->RootDepth = SoilThickness - state.dataEcoRoofMgr->TopDepth; // Next create a timestep in seconds - state.dataEcoRoofMgr->TimeStepZoneSec = state.dataGlobal->MinutesPerTimeStep * 60.0; + state.dataEcoRoofMgr->TimeStepZoneSec = state.dataGlobal->MinutesInTimeStep * 60.0; state.dataEcoRoofMgr->UpdatebeginFlag = false; } @@ -838,11 +838,11 @@ namespace EcoRoofManager { 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 / state.dataEcoRoofMgr->TopDepth; // soil surface evaporation - MeanRootMoisture -= (Vfluxf)*state.dataGlobal->MinutesPerTimeStep * 60.0 / state.dataEcoRoofMgr->RootDepth; // plant extraction from root zone + Moisture -= (Vfluxg)*state.dataGlobal->MinutesInTimeStep * 60.0 / state.dataEcoRoofMgr->TopDepth; // soil surface evaporation + MeanRootMoisture -= (Vfluxf)*state.dataGlobal->MinutesInTimeStep * 60.0 / state.dataEcoRoofMgr->RootDepth; // plant extraction from root zone // NEXT Update evapotranspiration summary variable for print out - state.dataEcoRoofMgr->CurrentET = (Vfluxg + Vfluxf) * state.dataGlobal->MinutesPerTimeStep * 60.0; // units are meters + state.dataEcoRoofMgr->CurrentET = (Vfluxg + Vfluxf) * state.dataGlobal->MinutesInTimeStep * 60.0; // units are meters if (!state.dataGlobal->WarmupFlag) { state.dataEcoRoofMgr->CumET += state.dataEcoRoofMgr->CurrentET; } @@ -895,9 +895,9 @@ namespace EcoRoofManager { // 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 (state.dataEcoRoofMgr->CurrentIrrigation + state.dataEcoRoofMgr->CurrentPrecipitation > - 0.5 * 0.0254 * state.dataGlobal->MinutesPerTimeStep / 60.0) { + 0.5 * 0.0254 * state.dataGlobal->MinutesInTimeStep / 60.0) { state.dataEcoRoofMgr->CurrentRunoff = state.dataEcoRoofMgr->CurrentIrrigation + state.dataEcoRoofMgr->CurrentPrecipitation - - (0.5 * 0.0254 * state.dataGlobal->MinutesPerTimeStep / 60.0); + (0.5 * 0.0254 * state.dataGlobal->MinutesInTimeStep / 60.0); // If we get here then TOO much moisture has already been added to soil (must now subtract excess) Moisture -= state.dataEcoRoofMgr->CurrentRunoff / state.dataEcoRoofMgr->TopDepth; // currently any incident moisture in excess of 1/4 " // per hour @@ -933,7 +933,7 @@ namespace EcoRoofManager { (Moisture - MeanRootMoisture) * state.dataEcoRoofMgr->TopDepth); MoistureDiffusion = max(0.0, MoistureDiffusion); // Safety net to keep positive (not needed?) // at this point moistureDiffusion is in units of (m)/timestep - MoistureDiffusion *= 0.00005 * state.dataGlobal->MinutesPerTimeStep * 60.0; + MoistureDiffusion *= 0.00005 * state.dataGlobal->MinutesInTimeStep * 60.0; Moisture -= MoistureDiffusion / state.dataEcoRoofMgr->TopDepth; MeanRootMoisture += MoistureDiffusion / state.dataEcoRoofMgr->RootDepth; } else if (MeanRootMoisture > Moisture) { @@ -942,7 +942,7 @@ namespace EcoRoofManager { min((MoistureMax - Moisture) * state.dataEcoRoofMgr->TopDepth, (MeanRootMoisture - Moisture) * state.dataEcoRoofMgr->RootDepth); MoistureDiffusion = max(0.0, MoistureDiffusion); // Safety net (not needed?) // at this point moistureDiffusion is in units of (m)/timestep - MoistureDiffusion *= 0.00001 * state.dataGlobal->MinutesPerTimeStep * 60.0; + MoistureDiffusion *= 0.00001 * state.dataGlobal->MinutesInTimeStep * 60.0; Moisture += MoistureDiffusion / state.dataEcoRoofMgr->TopDepth; MeanRootMoisture -= MoistureDiffusion / state.dataEcoRoofMgr->RootDepth; } diff --git a/src/EnergyPlus/EcoRoofManager.hh b/src/EnergyPlus/EcoRoofManager.hh index e7ddb18d47d..d8f33e52df4 100644 --- a/src/EnergyPlus/EcoRoofManager.hh +++ b/src/EnergyPlus/EcoRoofManager.hh @@ -169,6 +169,10 @@ struct EcoRoofManagerData : BaseGlobalStruct Real64 TestMoisture = 0.15; // This makes sure that the moisture cannot change by too much in each step int ErrIndex = 0; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/EconomicLifeCycleCost.hh b/src/EnergyPlus/EconomicLifeCycleCost.hh index ac10e829859..6a1de6272c4 100644 --- a/src/EnergyPlus/EconomicLifeCycleCost.hh +++ b/src/EnergyPlus/EconomicLifeCycleCost.hh @@ -512,6 +512,10 @@ struct EconomicLifeCycleCostData : BaseGlobalStruct EPVector UseAdjustment; std::vector CashFlow; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/EconomicTariff.cc b/src/EnergyPlus/EconomicTariff.cc index cb2ec0a5f6a..8652bb5c03d 100644 --- a/src/EnergyPlus/EconomicTariff.cc +++ b/src/EnergyPlus/EconomicTariff.cc @@ -136,6 +136,8 @@ void GetInputEconomicsTariff(EnergyPlusData &state, bool &ErrorsFound) // true i // meaning if "CCF" is picked, the conversion factor isn't the same whether it's a water meter or a fuel meter. static constexpr std::string_view RoutineName("GetInputEconomicsTariff: "); + static constexpr std::string_view routineName = "GetInputEconomicsTariff"; + int NumAlphas; // Number of elements in the alpha array int NumNums; // Number of elements in the numeric array int IOStat; // IO Status when calling get input subroutine @@ -149,6 +151,8 @@ void GetInputEconomicsTariff(EnergyPlusData &state, bool &ErrorsFound) // true i Array1D_string NamesOfKeys; // Specific key name Array1D_int IndexesForKeyVar; // Array index + auto &s_ipsc = state.dataIPShortCut; + auto &tariff(state.dataEconTariff->tariff); std::string_view CurrentModuleObject = "UtilityCost:Tariff"; @@ -158,25 +162,27 @@ void GetInputEconomicsTariff(EnergyPlusData &state, bool &ErrorsFound) // true i state.dataInputProcessing->inputProcessor->getObjectItem(state, CurrentModuleObject, iInObj, - state.dataIPShortCut->cAlphaArgs, + s_ipsc->cAlphaArgs, NumAlphas, - state.dataIPShortCut->rNumericArgs, + s_ipsc->rNumericArgs, NumNums, IOStat, - state.dataIPShortCut->lNumericFieldBlanks, - state.dataIPShortCut->lAlphaFieldBlanks, - state.dataIPShortCut->cAlphaFieldNames, - state.dataIPShortCut->cNumericFieldNames); + s_ipsc->lNumericFieldBlanks, + s_ipsc->lAlphaFieldBlanks, + s_ipsc->cAlphaFieldNames, + s_ipsc->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)}; // check to make sure none of the values are another economic object for (int jFld = 1; jFld <= NumAlphas; ++jFld) { // args are always turned to upper case but this is okay... - if (hasi(state.dataIPShortCut->cAlphaArgs(jFld), "UtilityCost:")) { - ShowWarningError(state, format("{}{}=\"{}\".", RoutineName, CurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); + if (hasi(s_ipsc->cAlphaArgs(jFld), "UtilityCost:")) { + ShowWarningError(state, format("{}{}=\"{}\".", RoutineName, CurrentModuleObject, s_ipsc->cAlphaArgs(1))); ShowContinueError(state, "... a field was found containing UtilityCost: which may indicate a missing comma."); } } // name of the tariff - tariff(iInObj).tariffName = state.dataIPShortCut->cAlphaArgs(1); + tariff(iInObj).tariffName = s_ipsc->cAlphaArgs(1); // check if tariff name is unique int found = 0; for (int jObj = 1; jObj <= iInObj - 1; ++jObj) { @@ -186,17 +192,17 @@ void GetInputEconomicsTariff(EnergyPlusData &state, bool &ErrorsFound) // true i } } if (found > 0) { - ShowSevereError(state, format("{}{}=\"{}\" invalid data", RoutineName, CurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); + ShowSevereError(state, format("{}{}=\"{}\" invalid data", RoutineName, CurrentModuleObject, s_ipsc->cAlphaArgs(1))); ShowContinueError(state, "...Duplicate name. Name has already been used."); ErrorsFound = true; } // name of the report meter - tariff(iInObj).reportMeter = state.dataIPShortCut->cAlphaArgs(2); + tariff(iInObj).reportMeter = s_ipsc->cAlphaArgs(2); // call the key count function but only need count during this pass GetVariableKeyCountandType(state, tariff(iInObj).reportMeter, KeyCount, TypeVar, AvgSumVar, StepTypeVar, UnitsVar); // if no meters found for that name if (KeyCount == 0) { - ShowWarningError(state, format("{}{}=\"{}\" missing meter", RoutineName, CurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); + ShowWarningError(state, format("{}{}=\"{}\" missing meter", RoutineName, CurrentModuleObject, s_ipsc->cAlphaArgs(1))); ShowContinueError(state, format("Meter referenced is not present due to a lack of equipment that uses that energy source/meter:\"{}\".", tariff(iInObj).reportMeter)); @@ -207,7 +213,7 @@ void GetInputEconomicsTariff(EnergyPlusData &state, bool &ErrorsFound) // true i GetVariableKeys(state, tariff(iInObj).reportMeter, TypeVar, NamesOfKeys, IndexesForKeyVar); // although this retrieves all keys for a variable, we only need one so the first one is chosen if (KeyCount > 1) { - ShowWarningError(state, format("{}{}=\"{}\" multiple keys", RoutineName, CurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); + ShowWarningError(state, format("{}{}=\"{}\" multiple keys", RoutineName, CurrentModuleObject, s_ipsc->cAlphaArgs(1))); ShowContinueError(state, "... Multiple keys for variable select. First key will be used."); } // assign the index @@ -267,23 +273,23 @@ void GetInputEconomicsTariff(EnergyPlusData &state, bool &ErrorsFound) // true i // We set demandConv to something analogous to m3/h if (tariff(iInObj).kindWaterMtr == kindMeterWater) { // conversion factor - if (Util::SameString(state.dataIPShortCut->cAlphaArgs(3), "USERDEFINED")) { + if (Util::SameString(s_ipsc->cAlphaArgs(3), "USERDEFINED")) { tariff(iInObj).convChoice = EconConv::USERDEF; - tariff(iInObj).energyConv = state.dataIPShortCut->rNumericArgs(1); // energy conversion factor - tariff(iInObj).demandConv = state.dataIPShortCut->rNumericArgs(2); // demand conversion factor - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(3), "M3")) { + tariff(iInObj).energyConv = s_ipsc->rNumericArgs(1); // energy conversion factor + tariff(iInObj).demandConv = s_ipsc->rNumericArgs(2); // demand conversion factor + } else if (Util::SameString(s_ipsc->cAlphaArgs(3), "M3")) { tariff(iInObj).convChoice = EconConv::M3; tariff(iInObj).energyConv = 1.0; tariff(iInObj).demandConv = 3600.0; - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(3), "CCF")) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(3), "CCF")) { tariff(iInObj).convChoice = EconConv::CCF; tariff(iInObj).energyConv = 0.35314666721488586; tariff(iInObj).demandConv = 0.35314666721488586 * 3600; - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(3), "GAL")) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(3), "GAL")) { tariff(iInObj).convChoice = EconConv::GAL; tariff(iInObj).energyConv = 264.1720523602524; tariff(iInObj).demandConv = 264.1720523602524 * 3600; - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(3), "KGAL")) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(3), "KGAL")) { tariff(iInObj).convChoice = EconConv::KGAL; tariff(iInObj).energyConv = 0.2641720523602524; tariff(iInObj).demandConv = 0.2641720523602524 * 3600; @@ -292,100 +298,100 @@ void GetInputEconomicsTariff(EnergyPlusData &state, bool &ErrorsFound) // true i tariff(iInObj).convChoice = EconConv::M3; tariff(iInObj).energyConv = 1.0; tariff(iInObj).demandConv = 3600.0; - ShowWarningError(state, format("{}{}=\"{}\" invalid data", RoutineName, CurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); + ShowWarningError(state, format("{}{}=\"{}\" invalid data", RoutineName, CurrentModuleObject, s_ipsc->cAlphaArgs(1))); ShowContinueError(state, format("{}=\"{}\", Defaulting to m^3 (Water resource detected).", - state.dataIPShortCut->cAlphaFieldNames(3), - state.dataIPShortCut->cAlphaArgs(3))); + s_ipsc->cAlphaFieldNames(3), + s_ipsc->cAlphaArgs(3))); } // If it's an electric meter // Volumetric units such as MCF or CCF doesn't make sense IMHO (JM) // THERM is strange for an electric meter but currently I accept but issue a warning } else if (tariff(iInObj).kindElectricMtr != kindMeterNotElectric) { - if (Util::SameString(state.dataIPShortCut->cAlphaArgs(3), "USERDEFINED")) { + if (Util::SameString(s_ipsc->cAlphaArgs(3), "USERDEFINED")) { tariff(iInObj).convChoice = EconConv::USERDEF; - tariff(iInObj).energyConv = state.dataIPShortCut->rNumericArgs(1); // energy conversion factor - tariff(iInObj).demandConv = state.dataIPShortCut->rNumericArgs(2); // demand conversion factor - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(3), "KWH")) { + tariff(iInObj).energyConv = s_ipsc->rNumericArgs(1); // energy conversion factor + tariff(iInObj).demandConv = s_ipsc->rNumericArgs(2); // demand conversion factor + } else if (Util::SameString(s_ipsc->cAlphaArgs(3), "KWH")) { tariff(iInObj).convChoice = EconConv::KWH; tariff(iInObj).energyConv = 0.0000002778; tariff(iInObj).demandConv = 0.001; - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(3), "MJ")) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(3), "MJ")) { tariff(iInObj).convChoice = EconConv::MJ; tariff(iInObj).energyConv = 0.000001; tariff(iInObj).demandConv = 0.0036; - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(3), "MMBTU")) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(3), "MMBTU")) { tariff(iInObj).convChoice = EconConv::MMBTU; tariff(iInObj).energyConv = 9.4781712e-10; tariff(iInObj).demandConv = 0.000003412; - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(3), "KBTU")) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(3), "KBTU")) { tariff(iInObj).convChoice = EconConv::KBTU; tariff(iInObj).energyConv = 9.4781712e-7; tariff(iInObj).demandConv = 0.003412; // We accept the following choices, but issue a warning - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(3), "THERM")) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(3), "THERM")) { tariff(iInObj).convChoice = EconConv::THERM; tariff(iInObj).energyConv = 9.4781712e-9; tariff(iInObj).demandConv = 0.00003412; ShowWarningError( - state, format("{}{}=\"{}\" potentially invalid data", RoutineName, CurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); + state, format("{}{}=\"{}\" potentially invalid data", RoutineName, CurrentModuleObject, s_ipsc->cAlphaArgs(1))); ShowContinueError(state, format("{}=\"{}\", Therm is an unusual choice for an electric resource.", - state.dataIPShortCut->cAlphaFieldNames(3), - state.dataIPShortCut->cAlphaArgs(3))); + s_ipsc->cAlphaFieldNames(3), + s_ipsc->cAlphaArgs(3))); // Otherwise, default to kWh } else { tariff(iInObj).convChoice = EconConv::KWH; tariff(iInObj).energyConv = 0.0000002778; tariff(iInObj).demandConv = 0.001; - ShowWarningError(state, format("{}{}=\"{}\" invalid data", RoutineName, CurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); + ShowWarningError(state, format("{}{}=\"{}\" invalid data", RoutineName, CurrentModuleObject, s_ipsc->cAlphaArgs(1))); ShowContinueError(state, format("{}=\"{}\", Defaulting to kWh (Electric resource detected)", - state.dataIPShortCut->cAlphaFieldNames(3), - state.dataIPShortCut->cAlphaArgs(3))); + s_ipsc->cAlphaFieldNames(3), + s_ipsc->cAlphaArgs(3))); } // If it's a gas meter } else if (tariff(iInObj).kindGasMtr == kindMeterGas) { - if (Util::SameString(state.dataIPShortCut->cAlphaArgs(3), "USERDEFINED")) { + if (Util::SameString(s_ipsc->cAlphaArgs(3), "USERDEFINED")) { tariff(iInObj).convChoice = EconConv::USERDEF; - tariff(iInObj).energyConv = state.dataIPShortCut->rNumericArgs(1); // energy conversion factor - tariff(iInObj).demandConv = state.dataIPShortCut->rNumericArgs(2); // demand conversion factor - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(3), "KWH")) { + tariff(iInObj).energyConv = s_ipsc->rNumericArgs(1); // energy conversion factor + tariff(iInObj).demandConv = s_ipsc->rNumericArgs(2); // demand conversion factor + } else if (Util::SameString(s_ipsc->cAlphaArgs(3), "KWH")) { tariff(iInObj).convChoice = EconConv::KWH; tariff(iInObj).energyConv = 0.0000002778; tariff(iInObj).demandConv = 0.001; - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(3), "THERM")) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(3), "THERM")) { tariff(iInObj).convChoice = EconConv::THERM; tariff(iInObj).energyConv = 9.4781712e-9; tariff(iInObj).demandConv = 0.00003412; - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(3), "MMBTU")) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(3), "MMBTU")) { tariff(iInObj).convChoice = EconConv::MMBTU; tariff(iInObj).energyConv = 9.4781712e-10; tariff(iInObj).demandConv = 0.000003412; - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(3), "MJ")) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(3), "MJ")) { tariff(iInObj).convChoice = EconConv::MJ; tariff(iInObj).energyConv = 0.000001; tariff(iInObj).demandConv = 0.0036; - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(3), "KBTU")) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(3), "KBTU")) { tariff(iInObj).convChoice = EconConv::KBTU; tariff(iInObj).energyConv = 9.4781712e-7; tariff(iInObj).demandConv = 0.003412; // Volumetric units for natural gas // Actually assuming 1 therm = 1 CCF (= 100 ft^3) - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(3), "MCF")) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(3), "MCF")) { tariff(iInObj).convChoice = EconConv::MCF; tariff(iInObj).energyConv = 9.4781712e-10; tariff(iInObj).demandConv = 0.000003412; - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(3), "CCF")) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(3), "CCF")) { tariff(iInObj).convChoice = EconConv::CCF; tariff(iInObj).energyConv = 9.4781712e-9; tariff(iInObj).demandConv = 0.00003412; - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(3), "M3")) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(3), "M3")) { // Obtained from converting CCF above to m^3 so the same heat content of natural gas is used (1 therm = 1 CCF) tariff(iInObj).convChoice = EconConv::M3; tariff(iInObj).energyConv = 2.6839192e-10; @@ -396,35 +402,35 @@ void GetInputEconomicsTariff(EnergyPlusData &state, bool &ErrorsFound) // true i tariff(iInObj).convChoice = EconConv::KWH; tariff(iInObj).energyConv = 0.0000002778; tariff(iInObj).demandConv = 0.001; - ShowWarningError(state, format("{}{}=\"{}\" invalid data", RoutineName, CurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); + ShowWarningError(state, format("{}{}=\"{}\" invalid data", RoutineName, CurrentModuleObject, s_ipsc->cAlphaArgs(1))); ShowContinueError( - state, format("{}=\"{}\", Defaulting to kWh.", state.dataIPShortCut->cAlphaFieldNames(3), state.dataIPShortCut->cAlphaArgs(3))); + state, format("{}=\"{}\", Defaulting to kWh.", s_ipsc->cAlphaFieldNames(3), s_ipsc->cAlphaArgs(3))); } // It it's neither an electric, water or gas meter, we cannot accept volumetric units // because we cannot infer the heat content } else { - if (Util::SameString(state.dataIPShortCut->cAlphaArgs(3), "USERDEFINED")) { + if (Util::SameString(s_ipsc->cAlphaArgs(3), "USERDEFINED")) { tariff(iInObj).convChoice = EconConv::USERDEF; - tariff(iInObj).energyConv = state.dataIPShortCut->rNumericArgs(1); // energy conversion factor - tariff(iInObj).demandConv = state.dataIPShortCut->rNumericArgs(2); // demand conversion factor - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(3), "KWH")) { + tariff(iInObj).energyConv = s_ipsc->rNumericArgs(1); // energy conversion factor + tariff(iInObj).demandConv = s_ipsc->rNumericArgs(2); // demand conversion factor + } else if (Util::SameString(s_ipsc->cAlphaArgs(3), "KWH")) { tariff(iInObj).convChoice = EconConv::KWH; tariff(iInObj).energyConv = 0.0000002778; tariff(iInObj).demandConv = 0.001; - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(3), "THERM")) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(3), "THERM")) { tariff(iInObj).convChoice = EconConv::THERM; tariff(iInObj).energyConv = 9.4781712e-9; tariff(iInObj).demandConv = 0.00003412; - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(3), "MMBTU")) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(3), "MMBTU")) { tariff(iInObj).convChoice = EconConv::MMBTU; tariff(iInObj).energyConv = 9.4781712e-10; tariff(iInObj).demandConv = 0.000003412; - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(3), "MJ")) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(3), "MJ")) { tariff(iInObj).convChoice = EconConv::MJ; tariff(iInObj).energyConv = 0.000001; tariff(iInObj).demandConv = 0.0036; - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(3), "KBTU")) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(3), "KBTU")) { tariff(iInObj).convChoice = EconConv::KBTU; tariff(iInObj).energyConv = 9.4781712e-7; tariff(iInObj).demandConv = 0.003412; @@ -434,60 +440,41 @@ void GetInputEconomicsTariff(EnergyPlusData &state, bool &ErrorsFound) // true i tariff(iInObj).convChoice = EconConv::KWH; tariff(iInObj).energyConv = 0.0000002778; tariff(iInObj).demandConv = 0.001; - ShowWarningError(state, format("{}{}=\"{}\" invalid data", RoutineName, CurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); + ShowWarningError(state, format("{}{}=\"{}\" invalid data", RoutineName, CurrentModuleObject, s_ipsc->cAlphaArgs(1))); ShowContinueError( - state, format("{}=\"{}\", Defaulting to kWh.", state.dataIPShortCut->cAlphaFieldNames(3), state.dataIPShortCut->cAlphaArgs(3))); + state, format("{}=\"{}\", Defaulting to kWh.", s_ipsc->cAlphaFieldNames(3), s_ipsc->cAlphaArgs(3))); } } // Default conversion factors have been applied from here on // schedules // period schedule - if (len(state.dataIPShortCut->cAlphaArgs(4)) > 0) { - tariff(iInObj).periodSchedule = state.dataIPShortCut->cAlphaArgs(4); // name of the period schedule (time of day) - tariff(iInObj).periodSchIndex = - ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(4)); // index to the period schedule - if (tariff(iInObj).periodSchIndex == 0) { - ShowSevereError(state, format("{}{}=\"{}\" invalid data", RoutineName, CurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, - format(" not found {}=\"{}\".", state.dataIPShortCut->cAlphaFieldNames(4), state.dataIPShortCut->cAlphaArgs(4))); + if (len(s_ipsc->cAlphaArgs(4)) > 0) { + if ((tariff(iInObj).periodSched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(4))) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(4), s_ipsc->cAlphaArgs(4)); ErrorsFound = true; } - } else { - tariff(iInObj).periodSchIndex = 0; // flag value for no schedule used } + // season schedule - if (len(state.dataIPShortCut->cAlphaArgs(5)) > 0) { - tariff(iInObj).seasonSchedule = state.dataIPShortCut->cAlphaArgs(5); // name of the season schedule (winter/summer) - tariff(iInObj).seasonSchIndex = - ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(5)); // index to the season schedule - if (tariff(iInObj).seasonSchIndex == 0) { - ShowSevereError(state, format("{}{}=\"{}\" invalid data", RoutineName, CurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, - format(" not found {}=\"{}\".", state.dataIPShortCut->cAlphaFieldNames(5), state.dataIPShortCut->cAlphaArgs(5))); + if (len(s_ipsc->cAlphaArgs(5)) > 0) { + if ((tariff(iInObj).seasonSched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(5))) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(5), s_ipsc->cAlphaArgs(5)); ErrorsFound = true; } - } else { - tariff(iInObj).seasonSchIndex = 0; // flag value for no schedule used } + // month schedule - if (len(state.dataIPShortCut->cAlphaArgs(6)) > 0) { - tariff(iInObj).monthSchedule = state.dataIPShortCut->cAlphaArgs(6); // name of month schedule (when months end) - tariff(iInObj).monthSchIndex = - ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(6)); // index to the month schedule - if (tariff(iInObj).monthSchIndex == 0) { - ShowSevereError(state, format("{}{}=\"{}\" invalid data", RoutineName, CurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, - format(" not found {}=\"{}\".", state.dataIPShortCut->cAlphaFieldNames(6), state.dataIPShortCut->cAlphaArgs(6))); + if (len(s_ipsc->cAlphaArgs(6)) > 0) { + if ((tariff(iInObj).monthSched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(6))) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(6), s_ipsc->cAlphaArgs(6)); ErrorsFound = true; } - } else { - tariff(iInObj).monthSchIndex = 0; // flag value for no schedule used } // type of demand window - if (Util::SameString(state.dataIPShortCut->cAlphaArgs(7), "QuarterHour")) { + if (Util::SameString(s_ipsc->cAlphaArgs(7), "QuarterHour")) { // check to make sure that the demand window and the TIMESTEP IN HOUR are consistant. { - switch (state.dataGlobal->NumOfTimeStepInHour) { + switch (state.dataGlobal->TimeStepsInHour) { case 1: case 3: case 5: @@ -495,10 +482,10 @@ void GetInputEconomicsTariff(EnergyPlusData &state, bool &ErrorsFound) // true i tariff(iInObj).demandWindow = DemandWindow::Hour; tariff(iInObj).demWinTime = 1.00; ShowWarningError(state, - format("{}{}=\"{}\" invalid data", RoutineName, CurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); + format("{}{}=\"{}\" invalid data", RoutineName, CurrentModuleObject, s_ipsc->cAlphaArgs(1))); ShowContinueError(state, format("Demand window of QuarterHour is not consistent with number of timesteps per hour [{}].", - state.dataGlobal->NumOfTimeStepInHour)); + state.dataGlobal->TimeStepsInHour)); ShowContinueError(state, "Demand window will be set to FullHour, and the simulation continues."); } break; case 2: @@ -508,10 +495,10 @@ void GetInputEconomicsTariff(EnergyPlusData &state, bool &ErrorsFound) // true i tariff(iInObj).demandWindow = DemandWindow::Half; tariff(iInObj).demWinTime = 0.50; ShowWarningError(state, - format("{}{}=\"{}\" invalid data", RoutineName, CurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); + format("{}{}=\"{}\" invalid data", RoutineName, CurrentModuleObject, s_ipsc->cAlphaArgs(1))); ShowContinueError(state, format("Demand window of QuarterHour is not consistent with number of timesteps per hour [{}].", - state.dataGlobal->NumOfTimeStepInHour)); + state.dataGlobal->TimeStepsInHour)); ShowContinueError(state, "Demand window will be set to HalfHour, and the simulation continues."); } break; case 4: @@ -526,9 +513,9 @@ void GetInputEconomicsTariff(EnergyPlusData &state, bool &ErrorsFound) // true i } break; } } - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(7), "HalfHour")) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(7), "HalfHour")) { { - switch (state.dataGlobal->NumOfTimeStepInHour) { + switch (state.dataGlobal->TimeStepsInHour) { case 1: case 3: case 5: @@ -536,10 +523,10 @@ void GetInputEconomicsTariff(EnergyPlusData &state, bool &ErrorsFound) // true i tariff(iInObj).demandWindow = DemandWindow::Hour; tariff(iInObj).demWinTime = 1.00; ShowWarningError(state, - format("{}{}=\"{}\" invalid data", RoutineName, CurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); + format("{}{}=\"{}\" invalid data", RoutineName, CurrentModuleObject, s_ipsc->cAlphaArgs(1))); ShowContinueError(state, format("Demand window of HalfHour is not consistent with number of timesteps per hour [{}].", - state.dataGlobal->NumOfTimeStepInHour)); + state.dataGlobal->TimeStepsInHour)); ShowContinueError(state, "Demand window will be set to FullHour, and the simulation continues."); } break; case 2: @@ -558,19 +545,19 @@ void GetInputEconomicsTariff(EnergyPlusData &state, bool &ErrorsFound) // true i } break; } } - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(7), "FullHour")) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(7), "FullHour")) { tariff(iInObj).demandWindow = DemandWindow::Hour; tariff(iInObj).demWinTime = 1.00; - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(7), "Day")) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(7), "Day")) { tariff(iInObj).demandWindow = DemandWindow::Day; tariff(iInObj).demWinTime = 24.00; - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(7), "Week")) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(7), "Week")) { tariff(iInObj).demandWindow = DemandWindow::Week; tariff(iInObj).demWinTime = 24.0 * 7.0; } else { // if not entered default to the same logic as quarter of an hour { - switch (state.dataGlobal->NumOfTimeStepInHour) { + switch (state.dataGlobal->TimeStepsInHour) { case 1: case 3: case 5: @@ -599,43 +586,41 @@ void GetInputEconomicsTariff(EnergyPlusData &state, bool &ErrorsFound) // true i } } // monthly charge - tariff(iInObj).monthChgVal = Util::ProcessNumber(state.dataIPShortCut->cAlphaArgs(8), isNotNumeric); + tariff(iInObj).monthChgVal = Util::ProcessNumber(s_ipsc->cAlphaArgs(8), isNotNumeric); tariff(iInObj).monthChgPt = - AssignVariablePt(state, state.dataIPShortCut->cAlphaArgs(8), isNotNumeric, varIsArgument, varNotYetDefined, ObjType::Invalid, 0, iInObj); + AssignVariablePt(state, s_ipsc->cAlphaArgs(8), isNotNumeric, varIsArgument, varNotYetDefined, ObjType::Invalid, 0, iInObj); // minimum monthly charge - if (len(state.dataIPShortCut->cAlphaArgs(9)) > 0) { - tariff(iInObj).minMonthChgVal = Util::ProcessNumber(state.dataIPShortCut->cAlphaArgs(9), isNotNumeric); + if (len(s_ipsc->cAlphaArgs(9)) > 0) { + tariff(iInObj).minMonthChgVal = Util::ProcessNumber(s_ipsc->cAlphaArgs(9), isNotNumeric); } else { tariff(iInObj).minMonthChgVal = -HUGE_(-1.0); // set to a very negative value } tariff(iInObj).minMonthChgPt = - AssignVariablePt(state, state.dataIPShortCut->cAlphaArgs(9), isNotNumeric, varIsArgument, varNotYetDefined, ObjType::Invalid, 0, iInObj); + AssignVariablePt(state, s_ipsc->cAlphaArgs(9), isNotNumeric, varIsArgument, varNotYetDefined, ObjType::Invalid, 0, iInObj); // real time pricing - tariff(iInObj).chargeSchedule = state.dataIPShortCut->cAlphaArgs(10); - tariff(iInObj).chargeSchIndex = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(10)); - tariff(iInObj).baseUseSchedule = state.dataIPShortCut->cAlphaArgs(11); - tariff(iInObj).baseUseSchIndex = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(11)); + tariff(iInObj).chargeSched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(10)); + tariff(iInObj).baseUseSched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(11)); // group name for separate distribution and transmission rates - tariff(iInObj).groupName = state.dataIPShortCut->cAlphaArgs(12); + tariff(iInObj).groupName = s_ipsc->cAlphaArgs(12); // buy or sell option - if (Util::SameString(state.dataIPShortCut->cAlphaArgs(13), "BuyFromUtility")) { + if (Util::SameString(s_ipsc->cAlphaArgs(13), "BuyFromUtility")) { tariff(iInObj).buyOrSell = buyFromUtility; - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(13), "SellToUtility")) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(13), "SellToUtility")) { tariff(iInObj).buyOrSell = sellToUtility; - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(13), "NetMetering")) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(13), "NetMetering")) { tariff(iInObj).buyOrSell = netMetering; } else { tariff(iInObj).buyOrSell = buyFromUtility; } // check if meter is consistent with buy or sell option if ((tariff(iInObj).buyOrSell == sellToUtility) && (!Util::SameString(tariff(iInObj).reportMeter, "ELECTRICITYSURPLUSSOLD:FACILITY"))) { - ShowWarningError(state, format("{}{}=\"{}\" atypical meter", RoutineName, CurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); + ShowWarningError(state, format("{}{}=\"{}\" atypical meter", RoutineName, CurrentModuleObject, s_ipsc->cAlphaArgs(1))); ShowContinueError(state, format("The meter chosen \"{}\" is not typically used with the sellToUtility option.", tariff(iInObj).reportMeter)); ShowContinueError(state, "Usually the ElectricitySurplusSold:Facility meter is selected when the sellToUtility option is used."); } if ((tariff(iInObj).buyOrSell == netMetering) && (!Util::SameString(tariff(iInObj).reportMeter, "ELECTRICITYNET:FACILITY"))) { - ShowWarningError(state, format("{}{}=\"{}\" atypical meter", RoutineName, CurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); + ShowWarningError(state, format("{}{}=\"{}\" atypical meter", RoutineName, CurrentModuleObject, s_ipsc->cAlphaArgs(1))); ShowContinueError(state, format("The meter chosen \"{}\" is not typically used with the netMetering option.", tariff(iInObj).reportMeter)); ShowContinueError(state, "Usually the ElectricityNet:Facility meter is selected when the netMetering option is used."); @@ -646,7 +631,7 @@ void GetInputEconomicsTariff(EnergyPlusData &state, bool &ErrorsFound) // true i if (!(Util::SameString(tariff(iInObj).reportMeter, "Electricity:Facility") || Util::SameString(tariff(iInObj).reportMeter, "ElectricityPurchased:Facility"))) { ShowWarningError(state, - format("{}{}=\"{}\" atypical meter", RoutineName, CurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); + format("{}{}=\"{}\" atypical meter", RoutineName, CurrentModuleObject, s_ipsc->cAlphaArgs(1))); ShowContinueError( state, format("The meter chosen \"{}\" is not typically used with the buyFromUtility option.", tariff(iInObj).reportMeter)); ShowContinueError(state, @@ -684,63 +669,66 @@ void GetInputEconomicsQualify(EnergyPlusData &state, bool &ErrorsFound) // true // Read the input file for "Economics:Qualify" objects. static constexpr std::string_view RoutineName("GetInputEconomicsQualify: "); + int iInObj; // loop index variable for reading in objects int NumAlphas; // Number of elements in the alpha array int NumNums; // Number of elements in the numeric array int IOStat; // IO Status when calling get input subroutine bool isNotNumeric; int jFld; - std::string CurrentModuleObject; // for ease in renaming. auto &qualify(state.dataEconTariff->qualify); - CurrentModuleObject = "UtilityCost:Qualify"; - state.dataEconTariff->numQualify = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject); + auto &s_ipsc = state.dataIPShortCut; + + s_ipsc->cCurrentModuleObject = "UtilityCost:Qualify"; + state.dataEconTariff->numQualify = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, s_ipsc->cCurrentModuleObject); qualify.allocate(state.dataEconTariff->numQualify); for (iInObj = 1; iInObj <= state.dataEconTariff->numQualify; ++iInObj) { state.dataInputProcessing->inputProcessor->getObjectItem(state, - CurrentModuleObject, + s_ipsc->cCurrentModuleObject, iInObj, - state.dataIPShortCut->cAlphaArgs, + s_ipsc->cAlphaArgs, NumAlphas, - state.dataIPShortCut->rNumericArgs, + s_ipsc->rNumericArgs, NumNums, IOStat, - state.dataIPShortCut->lNumericFieldBlanks, - state.dataIPShortCut->lAlphaFieldBlanks, - state.dataIPShortCut->cAlphaFieldNames, - state.dataIPShortCut->cNumericFieldNames); + s_ipsc->lNumericFieldBlanks, + s_ipsc->lAlphaFieldBlanks, + s_ipsc->cAlphaFieldNames, + s_ipsc->cNumericFieldNames); + // check to make sure none of the values are another economic object for (jFld = 1; jFld <= NumAlphas; ++jFld) { - if (hasi(state.dataIPShortCut->cAlphaArgs(jFld), "UtilityCost:")) { - ShowWarningError(state, format("{}{}=\"{}\".", RoutineName, CurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); + if (hasi(s_ipsc->cAlphaArgs(jFld), "UtilityCost:")) { + ShowWarningError(state, format("{}{}=\"{}\".", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); ShowContinueError(state, "... a field was found containing UtilityCost: which may indicate a missing comma."); } } // index of the tariff name in the tariff array qualify(iInObj).tariffIndx = - FindTariffIndex(state, state.dataIPShortCut->cAlphaArgs(2), state.dataIPShortCut->cAlphaArgs(1), ErrorsFound, CurrentModuleObject); - warnIfNativeVarname(state, state.dataIPShortCut->cAlphaArgs(1), qualify(iInObj).tariffIndx, ErrorsFound, CurrentModuleObject); + FindTariffIndex(state, s_ipsc->cAlphaArgs(2), s_ipsc->cAlphaArgs(1), ErrorsFound, s_ipsc->cCurrentModuleObject); + warnIfNativeVarname(state, s_ipsc->cAlphaArgs(1), qualify(iInObj).tariffIndx, ErrorsFound, s_ipsc->cCurrentModuleObject); qualify(iInObj).namePt = AssignVariablePt( - state, state.dataIPShortCut->cAlphaArgs(1), true, varIsAssigned, varNotYetDefined, ObjType::Qualify, iInObj, qualify(iInObj).tariffIndx); + state, s_ipsc->cAlphaArgs(1), true, varIsAssigned, varNotYetDefined, ObjType::Qualify, iInObj, qualify(iInObj).tariffIndx); // index of the variable in the variable array qualify(iInObj).sourcePt = AssignVariablePt( - state, state.dataIPShortCut->cAlphaArgs(3), true, varIsArgument, varNotYetDefined, ObjType::Invalid, 0, qualify(iInObj).tariffIndx); + state, s_ipsc->cAlphaArgs(3), true, varIsArgument, varNotYetDefined, ObjType::Invalid, 0, qualify(iInObj).tariffIndx); // indicator if maximum test otherwise minimum - if (Util::SameString(state.dataIPShortCut->cAlphaArgs(4), "Minimum")) { + if (Util::SameString(s_ipsc->cAlphaArgs(4), "Minimum")) { qualify(iInObj).isMaximum = false; - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(4), "Maximum")) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(4), "Maximum")) { qualify(iInObj).isMaximum = true; } else { - ShowSevereError(state, format("{}{}=\"{}\" invalid data", RoutineName, CurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("{}=\"{}\".", state.dataIPShortCut->cAlphaFieldNames(4), state.dataIPShortCut->cAlphaArgs(4))); + ShowSevereError(state, format("{}{}=\"{}\" invalid data", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); + ShowContinueError(state, format("{}=\"{}\".", s_ipsc->cAlphaFieldNames(4), s_ipsc->cAlphaArgs(4))); ErrorsFound = true; qualify(iInObj).isMaximum = true; } // value of the threshold - qualify(iInObj).thresholdVal = Util::ProcessNumber(state.dataIPShortCut->cAlphaArgs(5), isNotNumeric); + qualify(iInObj).thresholdVal = Util::ProcessNumber(s_ipsc->cAlphaArgs(5), isNotNumeric); qualify(iInObj).thresholdPt = AssignVariablePt(state, - state.dataIPShortCut->cAlphaArgs(5), + s_ipsc->cAlphaArgs(5), isNotNumeric, varIsArgument, varNotYetDefined, @@ -748,20 +736,20 @@ void GetInputEconomicsQualify(EnergyPlusData &state, bool &ErrorsFound) // true 0, qualify(iInObj).tariffIndx); // enumerated list of the kind of season - qualify(iInObj).season = LookUpSeason(state, state.dataIPShortCut->cAlphaArgs(6), state.dataIPShortCut->cAlphaArgs(1)); + qualify(iInObj).season = LookUpSeason(state, s_ipsc->cAlphaArgs(6), s_ipsc->cAlphaArgs(1)); // indicator if consecutive months otherwise count - if (Util::SameString(state.dataIPShortCut->cAlphaArgs(7), "Count")) { + if (Util::SameString(s_ipsc->cAlphaArgs(7), "Count")) { qualify(iInObj).isConsecutive = false; - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(7), "Consecutive")) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(7), "Consecutive")) { qualify(iInObj).isConsecutive = true; } else { - ShowWarningError(state, format("{}{}=\"{}\" invalid data", RoutineName, CurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("{}=\"{}\".", state.dataIPShortCut->cAlphaFieldNames(5), state.dataIPShortCut->cAlphaArgs(5))); + ShowWarningError(state, format("{}{}=\"{}\" invalid data", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); + ShowContinueError(state, format("{}=\"{}\".", s_ipsc->cAlphaFieldNames(5), s_ipsc->cAlphaArgs(5))); ErrorsFound = true; qualify(iInObj).isConsecutive = true; } // number of months the test must be good for - qualify(iInObj).numberOfMonths = state.dataIPShortCut->rNumericArgs(1); + qualify(iInObj).numberOfMonths = s_ipsc->rNumericArgs(1); } } @@ -778,36 +766,38 @@ void GetInputEconomicsChargeSimple(EnergyPlusData &state, bool &ErrorsFound) // int IOStat; // IO Status when calling get input subroutine bool isNotNumeric; - std::string CurrentModuleObject = "UtilityCost:Charge:Simple"; - state.dataEconTariff->numChargeSimple = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject); + auto &s_ipsc = state.dataIPShortCut; + s_ipsc->cCurrentModuleObject = "UtilityCost:Charge:Simple"; + + state.dataEconTariff->numChargeSimple = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, s_ipsc->cCurrentModuleObject); state.dataEconTariff->chargeSimple.allocate(state.dataEconTariff->numChargeSimple); for (int iInObj = 1; iInObj <= state.dataEconTariff->numChargeSimple; ++iInObj) { auto &chargeSimple = state.dataEconTariff->chargeSimple(iInObj); state.dataInputProcessing->inputProcessor->getObjectItem(state, - CurrentModuleObject, + s_ipsc->cCurrentModuleObject, iInObj, - state.dataIPShortCut->cAlphaArgs, + s_ipsc->cAlphaArgs, NumAlphas, - state.dataIPShortCut->rNumericArgs, + s_ipsc->rNumericArgs, NumNums, IOStat, - state.dataIPShortCut->lNumericFieldBlanks, - state.dataIPShortCut->lAlphaFieldBlanks, - state.dataIPShortCut->cAlphaFieldNames, - state.dataIPShortCut->cNumericFieldNames); + s_ipsc->lNumericFieldBlanks, + s_ipsc->lAlphaFieldBlanks, + s_ipsc->cAlphaFieldNames, + s_ipsc->cNumericFieldNames); // check to make sure none of the values are another economic object for (int jFld = 1; jFld <= NumAlphas; ++jFld) { - if (hasi(state.dataIPShortCut->cAlphaArgs(jFld), "UtilityCost:")) { - ShowWarningError(state, format("{}{}=\"{}\".", RoutineName, CurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); + if (hasi(s_ipsc->cAlphaArgs(jFld), "UtilityCost:")) { + ShowWarningError(state, format("{}{}=\"{}\".", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); ShowContinueError(state, "... a field was found containing UtilityCost: which may indicate a missing comma."); } } // index of the tariff name in the tariff array chargeSimple.tariffIndx = - FindTariffIndex(state, state.dataIPShortCut->cAlphaArgs(2), state.dataIPShortCut->cAlphaArgs(1), ErrorsFound, CurrentModuleObject); - warnIfNativeVarname(state, state.dataIPShortCut->cAlphaArgs(1), chargeSimple.tariffIndx, ErrorsFound, CurrentModuleObject); + FindTariffIndex(state, s_ipsc->cAlphaArgs(2), s_ipsc->cAlphaArgs(1), ErrorsFound, s_ipsc->cCurrentModuleObject); + warnIfNativeVarname(state, s_ipsc->cAlphaArgs(1), chargeSimple.tariffIndx, ErrorsFound, s_ipsc->cCurrentModuleObject); chargeSimple.namePt = AssignVariablePt(state, - state.dataIPShortCut->cAlphaArgs(1), + s_ipsc->cAlphaArgs(1), true, varIsAssigned, varNotYetDefined, @@ -816,16 +806,16 @@ void GetInputEconomicsChargeSimple(EnergyPlusData &state, bool &ErrorsFound) // chargeSimple.tariffIndx); // index of the variable in the variable array chargeSimple.sourcePt = AssignVariablePt( - state, state.dataIPShortCut->cAlphaArgs(3), true, varIsArgument, varNotYetDefined, ObjType::Invalid, 0, chargeSimple.tariffIndx); + state, s_ipsc->cAlphaArgs(3), true, varIsArgument, varNotYetDefined, ObjType::Invalid, 0, chargeSimple.tariffIndx); // enumerated list of the kind of season - chargeSimple.season = LookUpSeason(state, state.dataIPShortCut->cAlphaArgs(4), state.dataIPShortCut->cAlphaArgs(1)); + chargeSimple.season = LookUpSeason(state, s_ipsc->cAlphaArgs(4), s_ipsc->cAlphaArgs(1)); // check to make sure a seasonal schedule is specified if the season is not annual if (chargeSimple.season != seasonAnnual) { if (chargeSimple.tariffIndx != 0) { - if (state.dataEconTariff->tariff(chargeSimple.tariffIndx).seasonSchIndex == 0) { + if (state.dataEconTariff->tariff(chargeSimple.tariffIndx).seasonSched == nullptr) { ShowWarningError(state, - format("{}{}=\"{}\" invalid data", RoutineName, CurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("{}=\"{}\".", state.dataIPShortCut->cAlphaFieldNames(4), state.dataIPShortCut->cAlphaArgs(4))); + format("{}{}=\"{}\" invalid data", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); + ShowContinueError(state, format("{}=\"{}\".", s_ipsc->cAlphaFieldNames(4), s_ipsc->cAlphaArgs(4))); ShowContinueError(state, " a Season other than Annual is used but no Season Schedule Name is specified in the UtilityCost:Tariff."); } @@ -833,11 +823,11 @@ void GetInputEconomicsChargeSimple(EnergyPlusData &state, bool &ErrorsFound) // } // index of the category in the variable array chargeSimple.categoryPt = AssignVariablePt( - state, state.dataIPShortCut->cAlphaArgs(5), true, varIsAssigned, varNotYetDefined, ObjType::Category, iInObj, chargeSimple.tariffIndx); + state, s_ipsc->cAlphaArgs(5), true, varIsAssigned, varNotYetDefined, ObjType::Category, iInObj, chargeSimple.tariffIndx); // cost per unit value or variable - chargeSimple.costPerVal = Util::ProcessNumber(state.dataIPShortCut->cAlphaArgs(6), isNotNumeric); + chargeSimple.costPerVal = Util::ProcessNumber(s_ipsc->cAlphaArgs(6), isNotNumeric); chargeSimple.costPerPt = AssignVariablePt( - state, state.dataIPShortCut->cAlphaArgs(6), isNotNumeric, varIsArgument, varNotYetDefined, ObjType::Invalid, 0, chargeSimple.tariffIndx); + state, s_ipsc->cAlphaArgs(6), isNotNumeric, varIsArgument, varNotYetDefined, ObjType::Invalid, 0, chargeSimple.tariffIndx); } } @@ -855,51 +845,52 @@ void GetInputEconomicsChargeBlock(EnergyPlusData &state, bool &ErrorsFound) // t bool isNotNumeric; int alphaOffset; // offset used in blocks for alpha array Real64 hugeNumber(0.0); // Autodesk Value not used but suppresses warning about HUGE_() call - std::string CurrentModuleObject; // for ease in renaming. - CurrentModuleObject = "UtilityCost:Charge:Block"; + auto &s_ipsc = state.dataIPShortCut; + s_ipsc->cCurrentModuleObject = "UtilityCost:Charge:Block"; + hugeNumber = HUGE_(hugeNumber); - state.dataEconTariff->numChargeBlock = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject); + state.dataEconTariff->numChargeBlock = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, s_ipsc->cCurrentModuleObject); state.dataEconTariff->chargeBlock.allocate(state.dataEconTariff->numChargeBlock); for (int iInObj = 1; iInObj <= state.dataEconTariff->numChargeBlock; ++iInObj) { auto &chargeBlock = state.dataEconTariff->chargeBlock(iInObj); state.dataInputProcessing->inputProcessor->getObjectItem(state, - CurrentModuleObject, + s_ipsc->cCurrentModuleObject, iInObj, - state.dataIPShortCut->cAlphaArgs, + s_ipsc->cAlphaArgs, NumAlphas, - state.dataIPShortCut->rNumericArgs, + s_ipsc->rNumericArgs, NumNums, IOStat, - state.dataIPShortCut->lNumericFieldBlanks, - state.dataIPShortCut->lAlphaFieldBlanks, - state.dataIPShortCut->cAlphaFieldNames, - state.dataIPShortCut->cNumericFieldNames); + s_ipsc->lNumericFieldBlanks, + s_ipsc->lAlphaFieldBlanks, + s_ipsc->cAlphaFieldNames, + s_ipsc->cNumericFieldNames); // check to make sure none of the values are another economic object for (int jFld = 1; jFld <= NumAlphas; ++jFld) { - if (hasi(state.dataIPShortCut->cAlphaArgs(jFld), "UtilityCost:")) { - ShowWarningError(state, format("{}{}=\"{}\".", RoutineName, CurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); + if (hasi(s_ipsc->cAlphaArgs(jFld), "UtilityCost:")) { + ShowWarningError(state, format("{}{}=\"{}\".", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); ShowContinueError(state, "... a field was found containing UtilityCost: which may indicate a missing comma."); } } // index of the tariff name in the tariff array chargeBlock.tariffIndx = - FindTariffIndex(state, state.dataIPShortCut->cAlphaArgs(2), state.dataIPShortCut->cAlphaArgs(1), ErrorsFound, CurrentModuleObject); - warnIfNativeVarname(state, state.dataIPShortCut->cAlphaArgs(1), chargeBlock.tariffIndx, ErrorsFound, CurrentModuleObject); + FindTariffIndex(state, s_ipsc->cAlphaArgs(2), s_ipsc->cAlphaArgs(1), ErrorsFound, s_ipsc->cCurrentModuleObject); + warnIfNativeVarname(state, s_ipsc->cAlphaArgs(1), chargeBlock.tariffIndx, ErrorsFound, s_ipsc->cCurrentModuleObject); chargeBlock.namePt = AssignVariablePt( - state, state.dataIPShortCut->cAlphaArgs(1), true, varIsAssigned, varNotYetDefined, ObjType::ChargeBlock, iInObj, chargeBlock.tariffIndx); + state, s_ipsc->cAlphaArgs(1), true, varIsAssigned, varNotYetDefined, ObjType::ChargeBlock, iInObj, chargeBlock.tariffIndx); // index of the variable in the variable array chargeBlock.sourcePt = AssignVariablePt( - state, state.dataIPShortCut->cAlphaArgs(3), true, varIsArgument, varNotYetDefined, ObjType::Invalid, 0, chargeBlock.tariffIndx); + state, s_ipsc->cAlphaArgs(3), true, varIsArgument, varNotYetDefined, ObjType::Invalid, 0, chargeBlock.tariffIndx); // enumerated list of the kind of season - chargeBlock.season = LookUpSeason(state, state.dataIPShortCut->cAlphaArgs(4), state.dataIPShortCut->cAlphaArgs(1)); + chargeBlock.season = LookUpSeason(state, s_ipsc->cAlphaArgs(4), s_ipsc->cAlphaArgs(1)); // check to make sure a seasonal schedule is specified if the season is not annual if (chargeBlock.season != seasonAnnual) { if (chargeBlock.tariffIndx != 0) { - if (state.dataEconTariff->tariff(chargeBlock.tariffIndx).seasonSchIndex == 0) { + if (state.dataEconTariff->tariff(chargeBlock.tariffIndx).seasonSched == nullptr) { ShowWarningError(state, - format("{}{}=\"{}\" invalid data", RoutineName, CurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("{}=\"{}\".", state.dataIPShortCut->cAlphaFieldNames(4), state.dataIPShortCut->cAlphaArgs(4))); + format("{}{}=\"{}\" invalid data", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); + ShowContinueError(state, format("{}=\"{}\".", s_ipsc->cAlphaFieldNames(4), s_ipsc->cAlphaArgs(4))); ShowContinueError(state, " a Season other than Annual is used but no Season Schedule Name is specified in the UtilityCost:Tariff."); } @@ -907,18 +898,18 @@ void GetInputEconomicsChargeBlock(EnergyPlusData &state, bool &ErrorsFound) // t } // index of the category in the variable array chargeBlock.categoryPt = AssignVariablePt( - state, state.dataIPShortCut->cAlphaArgs(5), true, varIsAssigned, varNotYetDefined, ObjType::Category, iInObj, chargeBlock.tariffIndx); + state, s_ipsc->cAlphaArgs(5), true, varIsAssigned, varNotYetDefined, ObjType::Category, iInObj, chargeBlock.tariffIndx); // index of the remaining into variable in the variable array chargeBlock.remainingPt = AssignVariablePt( - state, state.dataIPShortCut->cAlphaArgs(6), true, varIsAssigned, varNotYetDefined, ObjType::Category, iInObj, chargeBlock.tariffIndx); + state, s_ipsc->cAlphaArgs(6), true, varIsAssigned, varNotYetDefined, ObjType::Category, iInObj, chargeBlock.tariffIndx); // block size multiplier - if (len(state.dataIPShortCut->cAlphaArgs(7)) == 0) { // if blank + if (len(s_ipsc->cAlphaArgs(7)) == 0) { // if blank chargeBlock.blkSzMultVal = 1.0; // default is 1 if left blank chargeBlock.blkSzMultPt = 0; } else { - chargeBlock.blkSzMultVal = Util::ProcessNumber(state.dataIPShortCut->cAlphaArgs(7), isNotNumeric); + chargeBlock.blkSzMultVal = Util::ProcessNumber(s_ipsc->cAlphaArgs(7), isNotNumeric); chargeBlock.blkSzMultPt = AssignVariablePt(state, - state.dataIPShortCut->cAlphaArgs(7), + s_ipsc->cAlphaArgs(7), isNotNumeric, varIsArgument, varNotYetDefined, @@ -931,15 +922,15 @@ void GetInputEconomicsChargeBlock(EnergyPlusData &state, bool &ErrorsFound) // t for (int jBlk = 1; jBlk <= chargeBlock.numBlk; ++jBlk) { alphaOffset = 7 + (jBlk - 1) * 2; // catch the "remaining" code word for the block size - if (Util::SameString(state.dataIPShortCut->cAlphaArgs(alphaOffset + 1), "REMAINING")) { + if (Util::SameString(s_ipsc->cAlphaArgs(alphaOffset + 1), "REMAINING")) { chargeBlock.blkSzVal(jBlk) = hugeNumber / 1000000; // using small portion of largest possible value to prevent overflow chargeBlock.blkSzPt(jBlk) = 0; } else { // array of block size - chargeBlock.blkSzVal(jBlk) = Util::ProcessNumber(state.dataIPShortCut->cAlphaArgs(alphaOffset + 1), isNotNumeric); + chargeBlock.blkSzVal(jBlk) = Util::ProcessNumber(s_ipsc->cAlphaArgs(alphaOffset + 1), isNotNumeric); chargeBlock.blkSzPt(jBlk) = AssignVariablePt(state, - state.dataIPShortCut->cAlphaArgs(alphaOffset + 1), + s_ipsc->cAlphaArgs(alphaOffset + 1), isNotNumeric, varIsArgument, varNotYetDefined, @@ -948,9 +939,9 @@ void GetInputEconomicsChargeBlock(EnergyPlusData &state, bool &ErrorsFound) // t chargeBlock.tariffIndx); } // array of block cost - chargeBlock.blkCostVal(jBlk) = Util::ProcessNumber(state.dataIPShortCut->cAlphaArgs(alphaOffset + 2), isNotNumeric); + chargeBlock.blkCostVal(jBlk) = Util::ProcessNumber(s_ipsc->cAlphaArgs(alphaOffset + 2), isNotNumeric); chargeBlock.blkCostPt(jBlk) = AssignVariablePt(state, - state.dataIPShortCut->cAlphaArgs(alphaOffset + 2), + s_ipsc->cAlphaArgs(alphaOffset + 2), isNotNumeric, varIsArgument, varNotYetDefined, @@ -969,59 +960,62 @@ void GetInputEconomicsRatchet(EnergyPlusData &state, bool &ErrorsFound) // true // Read the input file for "Economics:Ratchet" objects. static constexpr std::string_view RoutineName("GetInputEconomicsRatchet: "); + int NumAlphas; // Number of elements in the alpha array int NumNums; // Number of elements in the numeric array int IOStat; // IO Status when calling get input subroutine bool isNotNumeric; - std::string CurrentModuleObject = "UtilityCost:Ratchet"; - state.dataEconTariff->numRatchet = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject); + auto &s_ipsc = state.dataIPShortCut; + s_ipsc->cCurrentModuleObject = "UtilityCost:Ratchet"; + + state.dataEconTariff->numRatchet = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, s_ipsc->cCurrentModuleObject); state.dataEconTariff->ratchet.allocate(state.dataEconTariff->numRatchet); for (int iInObj = 1; iInObj <= state.dataEconTariff->numRatchet; ++iInObj) { auto &ratchet = state.dataEconTariff->ratchet(iInObj); state.dataInputProcessing->inputProcessor->getObjectItem(state, - CurrentModuleObject, + s_ipsc->cCurrentModuleObject, iInObj, - state.dataIPShortCut->cAlphaArgs, + s_ipsc->cAlphaArgs, NumAlphas, - state.dataIPShortCut->rNumericArgs, + s_ipsc->rNumericArgs, NumNums, IOStat, - state.dataIPShortCut->lNumericFieldBlanks, - state.dataIPShortCut->lAlphaFieldBlanks, - state.dataIPShortCut->cAlphaFieldNames, - state.dataIPShortCut->cNumericFieldNames); + s_ipsc->lNumericFieldBlanks, + s_ipsc->lAlphaFieldBlanks, + s_ipsc->cAlphaFieldNames, + s_ipsc->cNumericFieldNames); // check to make sure none of the values are another economic object for (int jFld = 1; jFld <= NumAlphas; ++jFld) { - if (hasi(state.dataIPShortCut->cAlphaArgs(jFld), "UtilityCost:")) { - ShowWarningError(state, format("{}{}=\"{}\".", RoutineName, CurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); + if (hasi(s_ipsc->cAlphaArgs(jFld), "UtilityCost:")) { + ShowWarningError(state, format("{}{}=\"{}\".", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); ShowContinueError(state, "... a field was found containing UtilityCost: which may indicate a missing comma."); } } // index of the tariff name in the tariff array ratchet.tariffIndx = - FindTariffIndex(state, state.dataIPShortCut->cAlphaArgs(2), state.dataIPShortCut->cAlphaArgs(1), ErrorsFound, CurrentModuleObject); - warnIfNativeVarname(state, state.dataIPShortCut->cAlphaArgs(1), ratchet.tariffIndx, ErrorsFound, CurrentModuleObject); + FindTariffIndex(state, s_ipsc->cAlphaArgs(2), s_ipsc->cAlphaArgs(1), ErrorsFound, s_ipsc->cCurrentModuleObject); + warnIfNativeVarname(state, s_ipsc->cAlphaArgs(1), ratchet.tariffIndx, ErrorsFound, s_ipsc->cCurrentModuleObject); ratchet.namePt = AssignVariablePt( - state, state.dataIPShortCut->cAlphaArgs(1), true, varIsAssigned, varNotYetDefined, ObjType::Ratchet, iInObj, ratchet.tariffIndx); + state, s_ipsc->cAlphaArgs(1), true, varIsAssigned, varNotYetDefined, ObjType::Ratchet, iInObj, ratchet.tariffIndx); // index of the variable in the variable array ratchet.baselinePt = AssignVariablePt( - state, state.dataIPShortCut->cAlphaArgs(3), true, varIsArgument, varNotYetDefined, ObjType::Ratchet, iInObj, ratchet.tariffIndx); + state, s_ipsc->cAlphaArgs(3), true, varIsArgument, varNotYetDefined, ObjType::Ratchet, iInObj, ratchet.tariffIndx); // index of the variable in the variable array ratchet.adjustmentPt = AssignVariablePt( - state, state.dataIPShortCut->cAlphaArgs(4), true, varIsArgument, varNotYetDefined, ObjType::Ratchet, iInObj, ratchet.tariffIndx); + state, s_ipsc->cAlphaArgs(4), true, varIsArgument, varNotYetDefined, ObjType::Ratchet, iInObj, ratchet.tariffIndx); // seasons to and from - ratchet.seasonFrom = LookUpSeason(state, state.dataIPShortCut->cAlphaArgs(5), state.dataIPShortCut->cAlphaArgs(1)); - ratchet.seasonTo = LookUpSeason(state, state.dataIPShortCut->cAlphaArgs(6), state.dataIPShortCut->cAlphaArgs(1)); + ratchet.seasonFrom = LookUpSeason(state, s_ipsc->cAlphaArgs(5), s_ipsc->cAlphaArgs(1)); + ratchet.seasonTo = LookUpSeason(state, s_ipsc->cAlphaArgs(6), s_ipsc->cAlphaArgs(1)); // ratchet multiplier - ratchet.multiplierVal = Util::ProcessNumber(state.dataIPShortCut->cAlphaArgs(7), isNotNumeric); + ratchet.multiplierVal = Util::ProcessNumber(s_ipsc->cAlphaArgs(7), isNotNumeric); ratchet.multiplierPt = AssignVariablePt( - state, state.dataIPShortCut->cAlphaArgs(7), isNotNumeric, varIsArgument, varNotYetDefined, ObjType::Invalid, 0, ratchet.tariffIndx); + state, s_ipsc->cAlphaArgs(7), isNotNumeric, varIsArgument, varNotYetDefined, ObjType::Invalid, 0, ratchet.tariffIndx); // ratchet offset - ratchet.offsetVal = Util::ProcessNumber(state.dataIPShortCut->cAlphaArgs(8), isNotNumeric); + ratchet.offsetVal = Util::ProcessNumber(s_ipsc->cAlphaArgs(8), isNotNumeric); ratchet.offsetPt = AssignVariablePt( - state, state.dataIPShortCut->cAlphaArgs(8), isNotNumeric, varIsArgument, varNotYetDefined, ObjType::Invalid, 0, ratchet.tariffIndx); + state, s_ipsc->cAlphaArgs(8), isNotNumeric, varIsArgument, varNotYetDefined, ObjType::Invalid, 0, ratchet.tariffIndx); } } @@ -1038,58 +1032,60 @@ void GetInputEconomicsVariable(EnergyPlusData &state, bool &ErrorsFound) // true int NumNums; // Number of elements in the numeric array int IOStat; // IO Status when calling get input subroutine - std::string CurrentModuleObject = "UtilityCost:Variable"; - int numEconVarObj = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject); + auto &s_ipsc = state.dataIPShortCut; + + s_ipsc->cCurrentModuleObject = "UtilityCost:Variable"; + int numEconVarObj = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, s_ipsc->cCurrentModuleObject); for (int iInObj = 1; iInObj <= numEconVarObj; ++iInObj) { state.dataInputProcessing->inputProcessor->getObjectItem(state, - CurrentModuleObject, + s_ipsc->cCurrentModuleObject, iInObj, - state.dataIPShortCut->cAlphaArgs, + s_ipsc->cAlphaArgs, NumAlphas, - state.dataIPShortCut->rNumericArgs, + s_ipsc->rNumericArgs, NumNums, IOStat, - state.dataIPShortCut->lNumericFieldBlanks, - state.dataIPShortCut->lAlphaFieldBlanks, - state.dataIPShortCut->cAlphaFieldNames, - state.dataIPShortCut->cNumericFieldNames); + s_ipsc->lNumericFieldBlanks, + s_ipsc->lAlphaFieldBlanks, + s_ipsc->cAlphaFieldNames, + s_ipsc->cNumericFieldNames); // check to make sure none of the values are another economic object for (int jFld = 1; jFld <= NumAlphas; ++jFld) { - if (hasi(state.dataIPShortCut->cAlphaArgs(jFld), "UtilityCost:")) { - ShowWarningError(state, format("{}{}=\"{}\".", RoutineName, CurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); + if (hasi(s_ipsc->cAlphaArgs(jFld), "UtilityCost:")) { + ShowWarningError(state, format("{}{}=\"{}\".", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); ShowContinueError(state, "... a field was found containing UtilityCost: which may indicate a missing comma."); } } int tariffPt = - FindTariffIndex(state, state.dataIPShortCut->cAlphaArgs(2), state.dataIPShortCut->cAlphaArgs(1), ErrorsFound, CurrentModuleObject); + FindTariffIndex(state, s_ipsc->cAlphaArgs(2), s_ipsc->cAlphaArgs(1), ErrorsFound, s_ipsc->cCurrentModuleObject); int variablePt = - AssignVariablePt(state, state.dataIPShortCut->cAlphaArgs(1), true, varIsArgument, varUserDefined, ObjType::Variable, iInObj, tariffPt); - warnIfNativeVarname(state, state.dataIPShortCut->cAlphaArgs(1), tariffPt, ErrorsFound, CurrentModuleObject); + AssignVariablePt(state, s_ipsc->cAlphaArgs(1), true, varIsArgument, varUserDefined, ObjType::Variable, iInObj, tariffPt); + warnIfNativeVarname(state, s_ipsc->cAlphaArgs(1), tariffPt, ErrorsFound, s_ipsc->cCurrentModuleObject); auto &econVar = state.dataEconTariff->econVar(variablePt); // validate the kind of variable - not used internally except for validation - if (Util::SameString(state.dataIPShortCut->cAlphaArgs(3), "ENERGY")) { + if (Util::SameString(s_ipsc->cAlphaArgs(3), "ENERGY")) { econVar.varUnitType = varUnitTypeEnergy; - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(3), "DEMAND")) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(3), "DEMAND")) { econVar.varUnitType = varUnitTypeDemand; - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(3), "DIMENSIONLESS")) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(3), "DIMENSIONLESS")) { econVar.varUnitType = varUnitTypeDimensionless; - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(3), "CURRENCY")) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(3), "CURRENCY")) { econVar.varUnitType = varUnitTypeCurrency; } else { econVar.varUnitType = varUnitTypeDimensionless; - ShowSevereError(state, format("{}{}=\"{}\" invalid data", RoutineName, CurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("invalid {}=\"{}\".", state.dataIPShortCut->cAlphaFieldNames(3), state.dataIPShortCut->cAlphaArgs(3))); + ShowSevereError(state, format("{}{}=\"{}\" invalid data", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); + ShowContinueError(state, format("invalid {}=\"{}\".", s_ipsc->cAlphaFieldNames(3), s_ipsc->cAlphaArgs(3))); ErrorsFound = true; } // move number inputs into econVar for (int jVal = 1; jVal <= NumNums; ++jVal) { - econVar.values(jVal) = state.dataIPShortCut->rNumericArgs(jVal); + econVar.values(jVal) = s_ipsc->rNumericArgs(jVal); } // fill the rest of the array with the last value entered if (NumNums < MaxNumMonths) { for (int jVal = NumNums + 1; jVal <= MaxNumMonths; ++jVal) { - econVar.values(jVal) = state.dataIPShortCut->rNumericArgs(NumNums); + econVar.values(jVal) = s_ipsc->rNumericArgs(NumNums); } } } @@ -1109,8 +1105,10 @@ void GetInputEconomicsComputation(EnergyPlusData &state, bool &ErrorsFound) // t int NumNums; // Number of elements in the numeric array int IOStat; // IO Status when calling get input subroutine - std::string CurrentModuleObject = "UtilityCost:Computation"; - state.dataEconTariff->numComputation = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject); + auto &s_ipsc = state.dataIPShortCut; + + s_ipsc->cCurrentModuleObject = "UtilityCost:Computation"; + state.dataEconTariff->numComputation = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, s_ipsc->cCurrentModuleObject); state.dataEconTariff->computation.allocate(state.dataEconTariff->numTariff); // not the number of Computations but the number of tariffs // set default values for computation for (auto &e : state.dataEconTariff->computation) { @@ -1121,36 +1119,36 @@ void GetInputEconomicsComputation(EnergyPlusData &state, bool &ErrorsFound) // t } for (int iInObj = 1; iInObj <= state.dataEconTariff->numComputation; ++iInObj) { state.dataInputProcessing->inputProcessor->getObjectItem(state, - CurrentModuleObject, + s_ipsc->cCurrentModuleObject, iInObj, - state.dataIPShortCut->cAlphaArgs, + s_ipsc->cAlphaArgs, NumAlphas, - state.dataIPShortCut->rNumericArgs, + s_ipsc->rNumericArgs, NumNums, IOStat, - state.dataIPShortCut->lNumericFieldBlanks, - state.dataIPShortCut->lAlphaFieldBlanks, - state.dataIPShortCut->cAlphaFieldNames, - state.dataIPShortCut->cNumericFieldNames); + s_ipsc->lNumericFieldBlanks, + s_ipsc->lAlphaFieldBlanks, + s_ipsc->cAlphaFieldNames, + s_ipsc->cNumericFieldNames); // check to make sure none of the values are another economic object for (int jFld = 1; jFld <= NumAlphas; ++jFld) { - if (hasi(state.dataIPShortCut->cAlphaArgs(jFld), "UtilityCost:")) { - ShowWarningError(state, format("{}{}=\"{}\".", RoutineName, CurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); + if (hasi(s_ipsc->cAlphaArgs(jFld), "UtilityCost:")) { + ShowWarningError(state, format("{}{}=\"{}\".", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); ShowContinueError(state, "... a field was found containing UtilityCost: which may indicate a missing comma."); } } int tariffPt = - FindTariffIndex(state, state.dataIPShortCut->cAlphaArgs(2), state.dataIPShortCut->cAlphaArgs(1), ErrorsFound, CurrentModuleObject); - warnIfNativeVarname(state, state.dataIPShortCut->cAlphaArgs(1), tariffPt, ErrorsFound, CurrentModuleObject); + FindTariffIndex(state, s_ipsc->cAlphaArgs(2), s_ipsc->cAlphaArgs(1), ErrorsFound, s_ipsc->cCurrentModuleObject); + warnIfNativeVarname(state, s_ipsc->cAlphaArgs(1), tariffPt, ErrorsFound, s_ipsc->cCurrentModuleObject); // tariff and computation share the same index, the tariff index // so all references are to the tariffPt auto &computation = state.dataEconTariff->computation(tariffPt); if (isWithinRange(state, tariffPt, 1, state.dataEconTariff->numTariff)) { - computation.computeName = state.dataIPShortCut->cAlphaArgs(1); + computation.computeName = s_ipsc->cAlphaArgs(1); computation.firstStep = state.dataEconTariff->numSteps + 1; for (int jLine = 3; jLine <= NumAlphas; ++jLine) { - parseComputeLine(state, state.dataIPShortCut->cAlphaArgs(jLine), tariffPt); + parseComputeLine(state, s_ipsc->cAlphaArgs(jLine), tariffPt); } computation.lastStep = state.dataEconTariff->numSteps; // check to make sure that some steps were defined @@ -1158,16 +1156,16 @@ void GetInputEconomicsComputation(EnergyPlusData &state, bool &ErrorsFound) // t computation.firstStep = 0; computation.lastStep = -1; computation.isUserDef = false; - ShowSevereError(state, format("{}{}=\"{}\" invalid data.", RoutineName, CurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); + ShowSevereError(state, format("{}{}=\"{}\" invalid data.", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); ShowContinueError(state, "... No lines in the computation can be interpreted "); ErrorsFound = true; } else { computation.isUserDef = true; } } else { - ShowSevereError(state, format("{}{}=\"{}\" invalid data.", RoutineName, CurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); + ShowSevereError(state, format("{}{}=\"{}\" invalid data.", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); ShowContinueError(state, - format("... not found {}=\"{}\".", state.dataIPShortCut->cAlphaFieldNames(2), state.dataIPShortCut->cAlphaArgs(2))); + format("... not found {}=\"{}\".", s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2))); ErrorsFound = true; } } @@ -1181,7 +1179,6 @@ void GetInputEconomicsCurrencyType(EnergyPlusData &state, bool &ErrorsFound) // // Sets the type of currency (U.S. Dollar, Euro, Yen, etc.. ) // This is a "unique" object. - std::string const CurrentModuleObject("CurrencyType"); static constexpr std::string_view RoutineName("GetInputEconomicsCurrencyType: "); int NumCurrencyType; @@ -1190,38 +1187,41 @@ void GetInputEconomicsCurrencyType(EnergyPlusData &state, bool &ErrorsFound) // int IOStat; // IO Status when calling get input subroutine int i; + auto &s_ipsc = state.dataIPShortCut; + s_ipsc->cCurrentModuleObject = "CurrencyType"; + initializeMonetaryUnit(state); - NumCurrencyType = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject); + NumCurrencyType = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, s_ipsc->cCurrentModuleObject); state.dataCostEstimateManager->selectedMonetaryUnit = 0; // invalid if (NumCurrencyType == 0) { state.dataCostEstimateManager->selectedMonetaryUnit = 1; // USD - U.S. Dollar } else if (NumCurrencyType == 1) { state.dataInputProcessing->inputProcessor->getObjectItem(state, - CurrentModuleObject, + s_ipsc->cCurrentModuleObject, 1, - state.dataIPShortCut->cAlphaArgs, + s_ipsc->cAlphaArgs, NumAlphas, - state.dataIPShortCut->rNumericArgs, + s_ipsc->rNumericArgs, NumNums, IOStat, - state.dataIPShortCut->lNumericFieldBlanks, - state.dataIPShortCut->lAlphaFieldBlanks, - state.dataIPShortCut->cAlphaFieldNames, - state.dataIPShortCut->cNumericFieldNames); + s_ipsc->lNumericFieldBlanks, + s_ipsc->lAlphaFieldBlanks, + s_ipsc->cAlphaFieldNames, + s_ipsc->cNumericFieldNames); // Monetary Unit for (i = 1; i <= (int)state.dataCostEstimateManager->monetaryUnit.size(); ++i) { - if (Util::SameString(state.dataIPShortCut->cAlphaArgs(1), state.dataCostEstimateManager->monetaryUnit(i).code)) { + if (Util::SameString(s_ipsc->cAlphaArgs(1), state.dataCostEstimateManager->monetaryUnit(i).code)) { state.dataCostEstimateManager->selectedMonetaryUnit = i; break; } } if (state.dataCostEstimateManager->selectedMonetaryUnit == 0) { - ShowSevereError(state, format("{}{}=\"{}\" invalid data.", RoutineName, CurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("... invalid {}.", state.dataIPShortCut->cAlphaFieldNames(1))); + ShowSevereError(state, format("{}{}=\"{}\" invalid data.", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); + ShowContinueError(state, format("... invalid {}.", s_ipsc->cAlphaFieldNames(1))); ErrorsFound = true; } } else if (NumCurrencyType > 1) { - ShowWarningError(state, format("{}{} Only one instance of this object is allowed. USD will be used.", RoutineName, CurrentModuleObject)); + ShowWarningError(state, format("{}{} Only one instance of this object is allowed. USD will be used.", RoutineName, s_ipsc->cCurrentModuleObject)); state.dataCostEstimateManager->selectedMonetaryUnit = 1; // USD - U.S. Dollar } } @@ -2280,7 +2280,7 @@ void CreateDefaultComputation(EnergyPlusData &state) addChargesToOperand(state, iTariff, tariff.ptSurcharge); addChargesToOperand(state, iTariff, tariff.ptTaxes); // add the real time pricing to the energy charges - if (tariff.chargeSchIndex != 0) { + if (tariff.chargeSched != nullptr) { addOperand(state, tariff.ptEnergyCharges, tariff.nativeRealTimePriceCosts); } // now add equations with NOOP to represent each object with its @@ -2586,36 +2586,20 @@ void GatherForEconomics(EnergyPlusData &state) tariff.collectEnergy += curInstantValue; tariff.collectTime += state.dataGlobal->TimeStepZoneSec; // added *SecInHour when adding RTP support August 2008 - if (tariff.collectTime >= tariff.demWinTime * Constant::SecInHour) { - int curSeason; - int curMonth; - int curPeriod; + if (tariff.collectTime >= tariff.demWinTime * Constant::rSecsInHour) { // get current value that has been converted into desired units curDemand = tariff.demandConv * tariff.collectEnergy / tariff.collectTime; curEnergy = tariff.energyConv * tariff.collectEnergy; // get the schedule values // remember no confirmation of schedule values occurs prior to now - if (tariff.seasonSchIndex != 0) { - curSeason = ScheduleManager::GetCurrentScheduleValue(state, tariff.seasonSchIndex); - } else { - curSeason = 1; - } - if (tariff.periodSchIndex != 0) { - curPeriod = ScheduleManager::GetCurrentScheduleValue(state, tariff.periodSchIndex); - } else { - curPeriod = 1; - } - if (tariff.monthSchIndex != 0) { - curMonth = ScheduleManager::GetCurrentScheduleValue(state, tariff.monthSchIndex); - } else { + int curSeason = (tariff.seasonSched != nullptr) ? tariff.seasonSched->getCurrentVal() : 1; + int curPeriod = (tariff.periodSched != nullptr) ? tariff.periodSched->getCurrentVal() : 1; + + int curMonth = (tariff.monthSched != nullptr) ? tariff.monthSched->getCurrentVal() : // #7814 - Have to be careful with DST. tariff::seasonForMonth is overwritten at each timestep, and only the last value is // retained, so make sure to capture the right one - if ((state.dataGlobal->HourOfDay + state.dataEnvrn->DSTIndicator) <= 24) { - curMonth = state.dataEnvrn->Month; - } else { - curMonth = state.dataEnvrn->MonthTomorrow; - } - } + (((state.dataGlobal->HourOfDay + state.dataEnvrn->DSTIndicator) <= Constant::iHoursInDay) ? state.dataEnvrn->Month : state.dataEnvrn->MonthTomorrow); + bool isGood = false; if (isWithinRange(state, curSeason, 1, 5)) { if (isWithinRange(state, curPeriod, 1, 4)) { @@ -2635,12 +2619,12 @@ void GatherForEconomics(EnergyPlusData &state) ShowContinueError(state, "Invalid schedule values - outside of range"); } // Real Time Pricing - if (tariff.chargeSchIndex != 0) { - curRTPprice = ScheduleManager::GetCurrentScheduleValue(state, tariff.chargeSchIndex); + if (tariff.chargeSched != nullptr) { + curRTPprice = tariff.chargeSched->getCurrentVal(); // if customer baseline load schedule is used, subtract that off of the // current energy - if (tariff.baseUseSchIndex != 0) { - curRTPbaseline = ScheduleManager::GetCurrentScheduleValue(state, tariff.baseUseSchIndex); + if (tariff.baseUseSched != nullptr) { + curRTPbaseline = tariff.baseUseSched->getCurrentVal(); curRTPenergy = curEnergy - curRTPbaseline; } else { curRTPenergy = curEnergy; diff --git a/src/EnergyPlus/EconomicTariff.hh b/src/EnergyPlus/EconomicTariff.hh index e7f98d9ffcb..ac34d401a9b 100644 --- a/src/EnergyPlus/EconomicTariff.hh +++ b/src/EnergyPlus/EconomicTariff.hh @@ -57,6 +57,7 @@ #include #include #include +#include namespace EnergyPlus { @@ -372,12 +373,9 @@ namespace EconomicTariff { EconConv convChoice; // enumerated choice index of the conversion factor Real64 energyConv; // energy conversion factor Real64 demandConv; // demand conversion factor - std::string periodSchedule; // name of the period schedule (time of day) - int periodSchIndex; // index to the period schedule - std::string seasonSchedule; // name of the season schedule (winter/summer) - int seasonSchIndex; // index to the season schedule - std::string monthSchedule; // name of month schedule (when months end) - int monthSchIndex; // index to the month schedule + Sched::Schedule *periodSched = nullptr; // period schedule + Sched::Schedule *seasonSched = nullptr; // season schedule + Sched::Schedule *monthSched = nullptr; // month schedule DemandWindow demandWindow; // enumerated list of the kind of demand window Real64 demWinTime; // length of time for the demand window Real64 monthChgVal; // monthly charge value @@ -386,10 +384,8 @@ namespace EconomicTariff { Real64 minMonthChgVal; // minimum monthly charge value int minMonthChgPt; // pointer to a variable that contains the minimum monthly charge // if 0 then use minMonthChgVal - std::string chargeSchedule; // name of the charge schedule (for real time pricing) - int chargeSchIndex; // index to the charge schedule - std::string baseUseSchedule; // name of the baseline use schedule (for real time pricing) - int baseUseSchIndex; // index to the baseline use schedule + Sched::Schedule *chargeSched = nullptr; // index to the charge schedule + Sched::Schedule *baseUseSched = nullptr; // index to the baseline use schedule std::string groupName; // name of the group std::string monetaryUnit; // text string representing monetary unit, usually $ int buyOrSell; // enumerated choice index of the buy or sell options @@ -472,8 +468,8 @@ namespace EconomicTariff { // Default Constructor TariffType() : reportMeterIndx(0), kindElectricMtr(0), kindWaterMtr(0), kindGasMtr(0), convChoice(EconConv::USERDEF), energyConv(0.0), demandConv(0.0), - periodSchIndex(0), seasonSchIndex(0), monthSchIndex(0), demandWindow(DemandWindow::Invalid), demWinTime(0.0), monthChgVal(0.0), - monthChgPt(0), minMonthChgVal(0.0), minMonthChgPt(0), chargeSchIndex(0), baseUseSchIndex(0), buyOrSell(0), firstCategory(0), + demandWindow(DemandWindow::Invalid), demWinTime(0.0), monthChgVal(0.0), + monthChgPt(0), minMonthChgVal(0.0), minMonthChgPt(0), buyOrSell(0), firstCategory(0), lastCategory(0), ptEnergyCharges(0), ptDemandCharges(0), ptServiceCharges(0), ptBasis(0), ptAdjustment(0), ptSurcharge(0), ptSubtotal(0), ptTaxes(0), ptTotal(0), ptNotIncluded(0), firstNative(0), lastNative(0), nativeTotalEnergy(0), nativeTotalDemand(0), nativePeakEnergy(0), nativePeakDemand(0), nativeShoulderEnergy(0), nativeShoulderDemand(0), nativeOffPeakEnergy(0), @@ -778,6 +774,10 @@ struct EconomicTariffData : BaseGlobalStruct EPVector computation; Array1D stack; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/ElectricBaseboardRadiator.cc b/src/EnergyPlus/ElectricBaseboardRadiator.cc index 7970a0034b9..4b1ae6d681c 100644 --- a/src/EnergyPlus/ElectricBaseboardRadiator.cc +++ b/src/EnergyPlus/ElectricBaseboardRadiator.cc @@ -170,6 +170,8 @@ namespace ElectricBaseboardRadiator { // SUBROUTINE PARAMETER DEFINITIONS: static constexpr std::string_view RoutineName("GetElectricBaseboardInput: "); // include trailing blank space + static constexpr std::string_view routineName = "GetElectricBaseboardInput"; // include trailing blank space + Real64 constexpr MaxFraction(1.0); // Maximum limit of fractional values Real64 constexpr MinFraction(0.0); // Minimum limit of fractional values // INTEGER,PARAMETER :: MaxDistribSurfaces = 20 ! Maximum number of surfaces that a baseboard heater can radiate to @@ -185,13 +187,14 @@ namespace ElectricBaseboardRadiator { int NumNumbers; int IOStat; bool ErrorsFound(false); // If errors detected in input - auto &cCurrentModuleObject = state.dataIPShortCut->cCurrentModuleObject; - cCurrentModuleObject = state.dataElectBaseboardRad->cCMO_BBRadiator_Electric; + auto &s_ipsc = state.dataIPShortCut; + + s_ipsc->cCurrentModuleObject = state.dataElectBaseboardRad->cCMO_BBRadiator_Electric; // Update Num in state and make local convenience copy int NumElecBaseboards = state.dataElectBaseboardRad->NumElecBaseboards = - state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); + state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, s_ipsc->cCurrentModuleObject); // object is extensible, no max args needed as IPShortCuts being used auto &ElecBaseboardNumericFields = state.dataElectBaseboardRad->ElecBaseboardNumericFields; @@ -203,138 +206,134 @@ namespace ElectricBaseboardRadiator { auto &elecBaseboard = state.dataElectBaseboardRad->ElecBaseboard(BaseboardNum); state.dataInputProcessing->inputProcessor->getObjectItem(state, - cCurrentModuleObject, + s_ipsc->cCurrentModuleObject, BaseboardNum, - state.dataIPShortCut->cAlphaArgs, + s_ipsc->cAlphaArgs, NumAlphas, - state.dataIPShortCut->rNumericArgs, + s_ipsc->rNumericArgs, NumNumbers, IOStat, - state.dataIPShortCut->lNumericFieldBlanks, - state.dataIPShortCut->lAlphaFieldBlanks, - state.dataIPShortCut->cAlphaFieldNames, - state.dataIPShortCut->cNumericFieldNames); + s_ipsc->lNumericFieldBlanks, + s_ipsc->lAlphaFieldBlanks, + s_ipsc->cAlphaFieldNames, + s_ipsc->cNumericFieldNames); + ErrorObjectHeader eoh{routineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)}; + ElecBaseboardNumericFields(BaseboardNum).FieldNames.allocate(NumNumbers); ElecBaseboardNumericFields(BaseboardNum).FieldNames = ""; - ElecBaseboardNumericFields(BaseboardNum).FieldNames = state.dataIPShortCut->cNumericFieldNames; + ElecBaseboardNumericFields(BaseboardNum).FieldNames = s_ipsc->cNumericFieldNames; // ErrorsFound will be set to True if problem was found, left untouched otherwise GlobalNames::VerifyUniqueBaseboardName( - state, cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1), ErrorsFound, cCurrentModuleObject + " Name"); - - elecBaseboard.EquipName = state.dataIPShortCut->cAlphaArgs(1); // name of this baseboard - elecBaseboard.Schedule = state.dataIPShortCut->cAlphaArgs(2); - if (state.dataIPShortCut->lAlphaFieldBlanks(2)) { - elecBaseboard.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - elecBaseboard.SchedPtr = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(2)); - if (elecBaseboard.SchedPtr == 0) { - ShowSevereError(state, - std::string{RoutineName} + cCurrentModuleObject + ": invalid " + state.dataIPShortCut->cAlphaFieldNames(2) + - " entered =" + state.dataIPShortCut->cAlphaArgs(2) + " for " + state.dataIPShortCut->cAlphaFieldNames(1) + - '=' + state.dataIPShortCut->cAlphaArgs(1)); - ErrorsFound = true; - } + state, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1), ErrorsFound, s_ipsc->cCurrentModuleObject + " Name"); + + elecBaseboard.EquipName = s_ipsc->cAlphaArgs(1); // name of this baseboard + elecBaseboard.Schedule = s_ipsc->cAlphaArgs(2); + if (s_ipsc->lAlphaFieldBlanks(2)) { + elecBaseboard.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((elecBaseboard.availSched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2)); + ErrorsFound = true; } // Determine HW radiant baseboard heating design capacity sizing method - if (Util::SameString(state.dataIPShortCut->cAlphaArgs(iHeatCAPMAlphaNum), "HeatingDesignCapacity")) { + if (Util::SameString(s_ipsc->cAlphaArgs(iHeatCAPMAlphaNum), "HeatingDesignCapacity")) { elecBaseboard.HeatingCapMethod = DataSizing::HeatingDesignCapacity; - if (!state.dataIPShortCut->lNumericFieldBlanks(iHeatDesignCapacityNumericNum)) { - elecBaseboard.ScaledHeatingCapacity = state.dataIPShortCut->rNumericArgs(iHeatDesignCapacityNumericNum); + if (!s_ipsc->lNumericFieldBlanks(iHeatDesignCapacityNumericNum)) { + elecBaseboard.ScaledHeatingCapacity = s_ipsc->rNumericArgs(iHeatDesignCapacityNumericNum); if (elecBaseboard.ScaledHeatingCapacity < 0.0 && elecBaseboard.ScaledHeatingCapacity != DataSizing::AutoSize) { - ShowSevereError(state, cCurrentModuleObject + " = " + elecBaseboard.EquipName); + ShowSevereError(state, format("{} = {}", s_ipsc->cCurrentModuleObject, elecBaseboard.EquipName)); ShowContinueError(state, format("Illegal {} = {:.7T}", - state.dataIPShortCut->cNumericFieldNames(iHeatDesignCapacityNumericNum), - state.dataIPShortCut->rNumericArgs(iHeatDesignCapacityNumericNum))); + s_ipsc->cNumericFieldNames(iHeatDesignCapacityNumericNum), + s_ipsc->rNumericArgs(iHeatDesignCapacityNumericNum))); ErrorsFound = true; } } else { - ShowSevereError(state, cCurrentModuleObject + " = " + elecBaseboard.EquipName); + ShowSevereError(state, format("{} = {}", s_ipsc->cCurrentModuleObject, elecBaseboard.EquipName)); ShowContinueError(state, - "Input for " + state.dataIPShortCut->cAlphaFieldNames(iHeatCAPMAlphaNum) + " = " + - state.dataIPShortCut->cAlphaArgs(iHeatCAPMAlphaNum)); + "Input for " + s_ipsc->cAlphaFieldNames(iHeatCAPMAlphaNum) + " = " + + s_ipsc->cAlphaArgs(iHeatCAPMAlphaNum)); ShowContinueError(state, - "Blank field not allowed for " + state.dataIPShortCut->cNumericFieldNames(iHeatDesignCapacityNumericNum)); + "Blank field not allowed for " + s_ipsc->cNumericFieldNames(iHeatDesignCapacityNumericNum)); ErrorsFound = true; } - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(iHeatCAPMAlphaNum), "CapacityPerFloorArea")) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(iHeatCAPMAlphaNum), "CapacityPerFloorArea")) { elecBaseboard.HeatingCapMethod = DataSizing::CapacityPerFloorArea; - if (!state.dataIPShortCut->lNumericFieldBlanks(iHeatCapacityPerFloorAreaNumericNum)) { - elecBaseboard.ScaledHeatingCapacity = state.dataIPShortCut->rNumericArgs(iHeatCapacityPerFloorAreaNumericNum); + if (!s_ipsc->lNumericFieldBlanks(iHeatCapacityPerFloorAreaNumericNum)) { + elecBaseboard.ScaledHeatingCapacity = s_ipsc->rNumericArgs(iHeatCapacityPerFloorAreaNumericNum); if (elecBaseboard.ScaledHeatingCapacity <= 0.0) { - ShowSevereError(state, cCurrentModuleObject + " = " + elecBaseboard.EquipName); + ShowSevereError(state, format("{} = {}", s_ipsc->cCurrentModuleObject, elecBaseboard.EquipName)); ShowContinueError(state, - "Input for " + state.dataIPShortCut->cAlphaFieldNames(iHeatCAPMAlphaNum) + " = " + - state.dataIPShortCut->cAlphaArgs(iHeatCAPMAlphaNum)); + "Input for " + s_ipsc->cAlphaFieldNames(iHeatCAPMAlphaNum) + " = " + + s_ipsc->cAlphaArgs(iHeatCAPMAlphaNum)); ShowContinueError(state, format("Illegal {} = {:.7T}", - state.dataIPShortCut->cNumericFieldNames(iHeatCapacityPerFloorAreaNumericNum), - state.dataIPShortCut->rNumericArgs(iHeatCapacityPerFloorAreaNumericNum))); + s_ipsc->cNumericFieldNames(iHeatCapacityPerFloorAreaNumericNum), + s_ipsc->rNumericArgs(iHeatCapacityPerFloorAreaNumericNum))); ErrorsFound = true; } else if (elecBaseboard.ScaledHeatingCapacity == DataSizing::AutoSize) { - ShowSevereError(state, cCurrentModuleObject + " = " + elecBaseboard.EquipName); + ShowSevereError(state, format("{} = {}", s_ipsc->cCurrentModuleObject, elecBaseboard.EquipName)); ShowContinueError(state, - "Input for " + state.dataIPShortCut->cAlphaFieldNames(iHeatCAPMAlphaNum) + " = " + - state.dataIPShortCut->cAlphaArgs(iHeatCAPMAlphaNum)); + "Input for " + s_ipsc->cAlphaFieldNames(iHeatCAPMAlphaNum) + " = " + + s_ipsc->cAlphaArgs(iHeatCAPMAlphaNum)); ShowContinueError(state, - "Illegal " + state.dataIPShortCut->cNumericFieldNames(iHeatCapacityPerFloorAreaNumericNum) + " = Autosize"); + "Illegal " + s_ipsc->cNumericFieldNames(iHeatCapacityPerFloorAreaNumericNum) + " = Autosize"); ErrorsFound = true; } } else { - ShowSevereError(state, cCurrentModuleObject + " = " + elecBaseboard.EquipName); + ShowSevereError(state, format(s_ipsc->cCurrentModuleObject, elecBaseboard.EquipName)); ShowContinueError(state, - "Input for " + state.dataIPShortCut->cAlphaFieldNames(iHeatCAPMAlphaNum) + " = " + - state.dataIPShortCut->cAlphaArgs(iHeatCAPMAlphaNum)); + "Input for " + s_ipsc->cAlphaFieldNames(iHeatCAPMAlphaNum) + " = " + + s_ipsc->cAlphaArgs(iHeatCAPMAlphaNum)); ShowContinueError(state, - "Blank field not allowed for " + state.dataIPShortCut->cNumericFieldNames(iHeatCapacityPerFloorAreaNumericNum)); + "Blank field not allowed for " + s_ipsc->cNumericFieldNames(iHeatCapacityPerFloorAreaNumericNum)); ErrorsFound = true; } - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(iHeatCAPMAlphaNum), "FractionOfAutosizedHeatingCapacity")) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(iHeatCAPMAlphaNum), "FractionOfAutosizedHeatingCapacity")) { elecBaseboard.HeatingCapMethod = DataSizing::FractionOfAutosizedHeatingCapacity; - if (!state.dataIPShortCut->lNumericFieldBlanks(iHeatFracOfAutosizedCapacityNumericNum)) { - elecBaseboard.ScaledHeatingCapacity = state.dataIPShortCut->rNumericArgs(iHeatFracOfAutosizedCapacityNumericNum); + if (!s_ipsc->lNumericFieldBlanks(iHeatFracOfAutosizedCapacityNumericNum)) { + elecBaseboard.ScaledHeatingCapacity = s_ipsc->rNumericArgs(iHeatFracOfAutosizedCapacityNumericNum); if (elecBaseboard.ScaledHeatingCapacity < 0.0) { - ShowSevereError(state, cCurrentModuleObject + " = " + elecBaseboard.EquipName); + ShowSevereError(state, s_ipsc->cCurrentModuleObject + " = " + elecBaseboard.EquipName); ShowContinueError(state, format("Illegal {} = {:.7T}", - state.dataIPShortCut->cNumericFieldNames(iHeatFracOfAutosizedCapacityNumericNum), - state.dataIPShortCut->rNumericArgs(iHeatFracOfAutosizedCapacityNumericNum))); + s_ipsc->cNumericFieldNames(iHeatFracOfAutosizedCapacityNumericNum), + s_ipsc->rNumericArgs(iHeatFracOfAutosizedCapacityNumericNum))); ErrorsFound = true; } } else { - ShowSevereError(state, cCurrentModuleObject + " = " + elecBaseboard.EquipName); + ShowSevereError(state, s_ipsc->cCurrentModuleObject + " = " + elecBaseboard.EquipName); ShowContinueError(state, - "Input for " + state.dataIPShortCut->cAlphaFieldNames(iHeatCAPMAlphaNum) + " = " + - state.dataIPShortCut->cAlphaArgs(iHeatCAPMAlphaNum)); + "Input for " + s_ipsc->cAlphaFieldNames(iHeatCAPMAlphaNum) + " = " + + s_ipsc->cAlphaArgs(iHeatCAPMAlphaNum)); ShowContinueError( - state, "Blank field not allowed for " + state.dataIPShortCut->cNumericFieldNames(iHeatFracOfAutosizedCapacityNumericNum)); + state, "Blank field not allowed for " + s_ipsc->cNumericFieldNames(iHeatFracOfAutosizedCapacityNumericNum)); ErrorsFound = true; } } else { - ShowSevereError(state, cCurrentModuleObject + " = " + elecBaseboard.EquipName); + ShowSevereError(state, s_ipsc->cCurrentModuleObject + " = " + elecBaseboard.EquipName); ShowContinueError(state, - "Illegal " + state.dataIPShortCut->cAlphaFieldNames(iHeatCAPMAlphaNum) + " = " + - state.dataIPShortCut->cAlphaArgs(iHeatCAPMAlphaNum)); + "Illegal " + s_ipsc->cAlphaFieldNames(iHeatCAPMAlphaNum) + " = " + + s_ipsc->cAlphaArgs(iHeatCAPMAlphaNum)); ErrorsFound = true; } - elecBaseboard.BaseboardEfficiency = state.dataIPShortCut->rNumericArgs(4); - elecBaseboard.FracRadiant = state.dataIPShortCut->rNumericArgs(5); + elecBaseboard.BaseboardEfficiency = s_ipsc->rNumericArgs(4); + elecBaseboard.FracRadiant = s_ipsc->rNumericArgs(5); if (elecBaseboard.FracRadiant < MinFraction) { ShowWarningError(state, - std::string{RoutineName} + cCurrentModuleObject + "=\"" + state.dataIPShortCut->cAlphaArgs(1) + "\", " + - state.dataIPShortCut->cNumericFieldNames(5) + " was lower than the allowable minimum."); + std::string{RoutineName} + s_ipsc->cCurrentModuleObject + "=\"" + s_ipsc->cAlphaArgs(1) + "\", " + + s_ipsc->cNumericFieldNames(5) + " was lower than the allowable minimum."); ShowContinueError(state, format("...reset to minimum value=[{:.2R}].", MinFraction)); elecBaseboard.FracRadiant = MinFraction; } if (elecBaseboard.FracRadiant > MaxFraction) { ShowWarningError(state, - std::string{RoutineName} + cCurrentModuleObject + "=\"" + state.dataIPShortCut->cAlphaArgs(1) + "\", " + - state.dataIPShortCut->cNumericFieldNames(5) + " was higher than the allowable maximum."); + std::string{RoutineName} + s_ipsc->cCurrentModuleObject + "=\"" + s_ipsc->cAlphaArgs(1) + "\", " + + s_ipsc->cNumericFieldNames(5) + " was higher than the allowable maximum."); ShowContinueError(state, format("...reset to maximum value=[{:.2R}].", MaxFraction)); elecBaseboard.FracRadiant = MaxFraction; } @@ -342,7 +341,7 @@ namespace ElectricBaseboardRadiator { // Remaining fraction is added to the zone as convective heat transfer if (elecBaseboard.FracRadiant > MaxFraction) { ShowWarningError(state, - std::string{RoutineName} + cCurrentModuleObject + "=\"" + state.dataIPShortCut->cAlphaArgs(1) + + std::string{RoutineName} + s_ipsc->cCurrentModuleObject + "=\"" + s_ipsc->cAlphaArgs(1) + "\", Fraction Radiant was higher than the allowable maximum."); elecBaseboard.FracRadiant = MaxFraction; elecBaseboard.FracConvect = 0.0; @@ -350,18 +349,18 @@ namespace ElectricBaseboardRadiator { elecBaseboard.FracConvect = 1.0 - elecBaseboard.FracRadiant; } - elecBaseboard.FracDistribPerson = state.dataIPShortCut->rNumericArgs(6); + elecBaseboard.FracDistribPerson = s_ipsc->rNumericArgs(6); if (elecBaseboard.FracDistribPerson < MinFraction) { ShowWarningError(state, - std::string{RoutineName} + cCurrentModuleObject + "=\"" + state.dataIPShortCut->cAlphaArgs(1) + "\", " + - state.dataIPShortCut->cNumericFieldNames(6) + " was lower than the allowable minimum."); + std::string{RoutineName} + s_ipsc->cCurrentModuleObject + "=\"" + s_ipsc->cAlphaArgs(1) + "\", " + + s_ipsc->cNumericFieldNames(6) + " was lower than the allowable minimum."); ShowContinueError(state, format("...reset to minimum value=[{:.2R}].", MinFraction)); elecBaseboard.FracDistribPerson = MinFraction; } if (elecBaseboard.FracDistribPerson > MaxFraction) { ShowWarningError(state, - std::string{RoutineName} + cCurrentModuleObject + "=\"" + state.dataIPShortCut->cAlphaArgs(1) + "\", " + - state.dataIPShortCut->cNumericFieldNames(6) + " was higher than the allowable maximum."); + std::string{RoutineName} + s_ipsc->cCurrentModuleObject + "=\"" + s_ipsc->cAlphaArgs(1) + "\", " + + s_ipsc->cNumericFieldNames(6) + " was higher than the allowable maximum."); ShowContinueError(state, format("...reset to maximum value=[{:.2R}].", MaxFraction)); elecBaseboard.FracDistribPerson = MaxFraction; } @@ -370,7 +369,7 @@ namespace ElectricBaseboardRadiator { if ((elecBaseboard.TotSurfToDistrib < MinDistribSurfaces) && (elecBaseboard.FracRadiant > MinFraction)) { ShowSevereError(state, - std::string{RoutineName} + cCurrentModuleObject + "=\"" + state.dataIPShortCut->cAlphaArgs(1) + + std::string{RoutineName} + s_ipsc->cCurrentModuleObject + "=\"" + s_ipsc->cAlphaArgs(1) + "\", the number of surface/radiant fraction groups entered was less than the allowable minimum."); ShowContinueError(state, format("...the minimum that must be entered=[{}].", MinDistribSurfaces)); ErrorsFound = true; @@ -389,21 +388,21 @@ namespace ElectricBaseboardRadiator { Real64 AllFracsSummed = elecBaseboard.FracDistribPerson; for (int SurfNum = 1; SurfNum <= elecBaseboard.TotSurfToDistrib; ++SurfNum) { - elecBaseboard.SurfaceName(SurfNum) = state.dataIPShortCut->cAlphaArgs(SurfNum + 3); + elecBaseboard.SurfaceName(SurfNum) = s_ipsc->cAlphaArgs(SurfNum + 3); elecBaseboard.SurfacePtr(SurfNum) = HeatBalanceIntRadExchange::GetRadiantSystemSurface( - state, cCurrentModuleObject, elecBaseboard.EquipName, elecBaseboard.ZonePtr, elecBaseboard.SurfaceName(SurfNum), ErrorsFound); - elecBaseboard.FracDistribToSurf(SurfNum) = state.dataIPShortCut->rNumericArgs(SurfNum + 6); + state, s_ipsc->cCurrentModuleObject, elecBaseboard.EquipName, elecBaseboard.ZonePtr, elecBaseboard.SurfaceName(SurfNum), ErrorsFound); + elecBaseboard.FracDistribToSurf(SurfNum) = s_ipsc->rNumericArgs(SurfNum + 6); if (elecBaseboard.FracDistribToSurf(SurfNum) > MaxFraction) { ShowWarningError(state, - std::string{RoutineName} + cCurrentModuleObject + "=\"" + state.dataIPShortCut->cAlphaArgs(1) + "\", " + - state.dataIPShortCut->cNumericFieldNames(SurfNum + 6) + "was greater than the allowable maximum."); + std::string{RoutineName} + s_ipsc->cCurrentModuleObject + "=\"" + s_ipsc->cAlphaArgs(1) + "\", " + + s_ipsc->cNumericFieldNames(SurfNum + 6) + "was greater than the allowable maximum."); ShowContinueError(state, format("...reset to maximum value=[{:.2R}].", MaxFraction)); elecBaseboard.TotSurfToDistrib = MaxFraction; } if (elecBaseboard.FracDistribToSurf(SurfNum) < MinFraction) { ShowWarningError(state, - std::string{RoutineName} + cCurrentModuleObject + "=\"" + state.dataIPShortCut->cAlphaArgs(1) + "\", " + - state.dataIPShortCut->cNumericFieldNames(SurfNum + 6) + "was less than the allowable minimum."); + std::string{RoutineName} + s_ipsc->cCurrentModuleObject + "=\"" + s_ipsc->cAlphaArgs(1) + "\", " + + s_ipsc->cNumericFieldNames(SurfNum + 6) + "was less than the allowable minimum."); ShowContinueError(state, format("...reset to maximum value=[{:.2R}].", MinFraction)); elecBaseboard.TotSurfToDistrib = MinFraction; } @@ -417,21 +416,21 @@ namespace ElectricBaseboardRadiator { if (AllFracsSummed > (MaxFraction + 0.01)) { ShowSevereError(state, - std::string{RoutineName} + cCurrentModuleObject + "=\"" + state.dataIPShortCut->cAlphaArgs(1) + + std::string{RoutineName} + s_ipsc->cCurrentModuleObject + "=\"" + s_ipsc->cAlphaArgs(1) + "\", Summed radiant fractions for people + surface groups > 1.0"); ErrorsFound = true; } if ((AllFracsSummed < (MaxFraction - 0.01)) && (elecBaseboard.FracRadiant > MinFraction)) { // User didn't distribute all of the | radiation warn that some will be lost ShowWarningError(state, - std::string{RoutineName} + cCurrentModuleObject + "=\"" + state.dataIPShortCut->cAlphaArgs(1) + + std::string{RoutineName} + s_ipsc->cCurrentModuleObject + "=\"" + s_ipsc->cAlphaArgs(1) + "\", Summed radiant fractions for people + surface groups < 1.0"); ShowContinueError(state, "The rest of the radiant energy delivered by the baseboard heater will be lost"); } } if (ErrorsFound) { - ShowFatalError(state, std::string{RoutineName} + cCurrentModuleObject + "Errors found getting input. Program terminates."); + ShowFatalError(state, std::string{RoutineName} + s_ipsc->cCurrentModuleObject + "Errors found getting input. Program terminates."); } for (auto &elecBaseboard : state.dataElectBaseboardRad->ElecBaseboard) { @@ -691,7 +690,7 @@ namespace ElectricBaseboardRadiator { Real64 Effic = elecBaseboard.BaseboardEfficiency; if (QZnReq > HVAC::SmallLoad && !state.dataZoneEnergyDemand->CurDeadBandOrSetback(ZoneNum) && - ScheduleManager::GetCurrentScheduleValue(state, elecBaseboard.SchedPtr) > 0.0) { + elecBaseboard.availSched->getCurrentVal() > 0.0) { // If the load exceeds the capacity than the capacity is set to the BB limit. if (QZnReq > elecBaseboard.NominalCapacity) { diff --git a/src/EnergyPlus/ElectricBaseboardRadiator.hh b/src/EnergyPlus/ElectricBaseboardRadiator.hh index b4a8d2df86f..fbee300222b 100644 --- a/src/EnergyPlus/ElectricBaseboardRadiator.hh +++ b/src/EnergyPlus/ElectricBaseboardRadiator.hh @@ -72,7 +72,7 @@ namespace ElectricBaseboardRadiator { Array1D_string SurfaceName; Array1D_int SurfacePtr; int ZonePtr = 0; - int SchedPtr = 0; + Sched::Schedule *availSched = nullptr; // Assuming availability schedule int TotSurfToDistrib = 0; Real64 NominalCapacity = 0.0; Real64 BaseboardEfficiency = 0.0; @@ -160,6 +160,10 @@ struct ElectricBaseboardRadiatorData : BaseGlobalStruct Array1D ElecBaseboardNumericFields; bool GetInputFlag = true; // One time get input flag + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/ElectricPowerServiceManager.cc b/src/EnergyPlus/ElectricPowerServiceManager.cc index 76069c342d1..c887fe81a17 100644 --- a/src/EnergyPlus/ElectricPowerServiceManager.cc +++ b/src/EnergyPlus/ElectricPowerServiceManager.cc @@ -197,7 +197,9 @@ void ElectricPowerServiceManager::reinitZoneGainsAtBeginEnvironment() void ElectricPowerServiceManager::getPowerManagerInput(EnergyPlusData &state) { - static constexpr std::string_view routineName = "ElectricPowerServiceManager getPowerManagerInput "; + static constexpr std::string_view routineName = "ElectricPowerServiceManager::getPowerManagerInput "; + + auto &s_ipsc = state.dataIPShortCut; numLoadCenters_ = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "ElectricLoadCenter:Distribution"); @@ -261,43 +263,43 @@ void ElectricPowerServiceManager::getPowerManagerInput(EnergyPlusData &state) int iOStat; // IO Status when calling get input subroutine bool foundInFromGridTransformer = false; - state.dataIPShortCut->cCurrentModuleObject = "ElectricLoadCenter:Transformer"; + s_ipsc->cCurrentModuleObject = "ElectricLoadCenter:Transformer"; for (int loopTransformer = 1; loopTransformer <= numTransformers_; ++loopTransformer) { state.dataInputProcessing->inputProcessor->getObjectItem(state, - state.dataIPShortCut->cCurrentModuleObject, + s_ipsc->cCurrentModuleObject, loopTransformer, - state.dataIPShortCut->cAlphaArgs, + s_ipsc->cAlphaArgs, numAlphas, - state.dataIPShortCut->rNumericArgs, + s_ipsc->rNumericArgs, numNums, iOStat, - state.dataIPShortCut->lNumericFieldBlanks, - state.dataIPShortCut->lAlphaFieldBlanks, - state.dataIPShortCut->cAlphaFieldNames, - state.dataIPShortCut->cNumericFieldNames); + s_ipsc->lNumericFieldBlanks, + s_ipsc->lAlphaFieldBlanks, + s_ipsc->cAlphaFieldNames, + s_ipsc->cNumericFieldNames); - if (Util::SameString(state.dataIPShortCut->cAlphaArgs(3), "PowerInFromGrid")) { + if (Util::SameString(s_ipsc->cAlphaArgs(3), "PowerInFromGrid")) { if (!foundInFromGridTransformer) { foundInFromGridTransformer = true; - facilityPowerInTransformerName_ = state.dataIPShortCut->cAlphaArgs(1); + facilityPowerInTransformerName_ = s_ipsc->cAlphaArgs(1); facilityPowerInTransformerPresent_ = true; } else { // should only have one transformer in input that is PowerInFromGrid ShowWarningError(state, format("{}{}=\"{}\", invalid entry.", routineName, - state.dataIPShortCut->cCurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1))); + s_ipsc->cCurrentModuleObject, + s_ipsc->cAlphaArgs(1))); ShowContinueError(state, - format("Invalid {} = {}", state.dataIPShortCut->cAlphaFieldNames(3), state.dataIPShortCut->cAlphaArgs(3))); + format("Invalid {} = {}", s_ipsc->cAlphaFieldNames(3), s_ipsc->cAlphaArgs(3))); ShowContinueError(state, "Only one transformer with Usage PowerInFromGrid can be used, first one in input file will be used and the " "simulation continues..."); } - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(3), "PowerOutToGrid")) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(3), "PowerOutToGrid")) { if (powerOutTransformerObj_ == nullptr) { ++numPowerOutTransformers_; - powerOutTransformerName_ = state.dataIPShortCut->cAlphaArgs(1); + powerOutTransformerName_ = s_ipsc->cAlphaArgs(1); powerOutTransformerObj_ = std::make_unique(state, powerOutTransformerName_); } else { @@ -673,16 +675,19 @@ void ElectricPowerServiceManager::checkLoadCenters(EnergyPlusData &state) } } +// TODO: Absolutely not. Constructors should not do this much work, +// because if this fails, then the constructor fails and who knows who +// will be referencing this object. ElectPowerLoadCenter::ElectPowerLoadCenter(EnergyPlusData &state, int const objectNum) : numGenerators(0), bussType(ElectricBussType::Invalid), thermalProd(0.0), thermalProdRate(0.0), inverterPresent(false), subpanelFeedInRequest(0.0), subpanelFeedInRate(0.0), subpanelDrawRate(0.0), genElectricProd(0.0), genElectProdRate(0.0), storOpCVDrawRate(0.0), storOpCVFeedInRate(0.0), storOpCVChargeRate(0.0), storOpCVDischargeRate(0.0), storOpIsCharging(false), storOpIsDischarging(false), genOperationScheme_(GeneratorOpScheme::Invalid), demandMeterPtr_(0), generatorsPresent_(false), myCoGenSetupFlag_(true), demandLimit_(0.0), - trackSchedPtr_(0), storagePresent_(false), transformerPresent_(false), totalPowerRequest_(0.0), totalThermalPowerRequest_(0.0), + storagePresent_(false), transformerPresent_(false), totalPowerRequest_(0.0), totalThermalPowerRequest_(0.0), storageScheme_(StorageOpScheme::Invalid), trackStorageOpMeterIndex_(0), converterPresent_(false), maxStorageSOCFraction_(1.0), minStorageSOCFraction_(0.0), designStorageChargePower_(0.0), designStorageChargePowerWasSet_(false), designStorageDischargePower_(0.0), - designStorageDischargePowerWasSet_(false), storageChargeModSchedIndex_(0), storageDischargeModSchedIndex_(0), facilityDemandTarget_(0.0), - facilityDemandTargetModSchedIndex_(0), eMSOverridePelFromStorage_(false), // if true, EMS calling for override + designStorageDischargePowerWasSet_(false), facilityDemandTarget_(0.0), + eMSOverridePelFromStorage_(false), // if true, EMS calling for override eMSValuePelFromStorage_(0.0), // value EMS is directing to use, power from storage [W] eMSOverridePelIntoStorage_(false), // if true, EMS calling for override eMSValuePelIntoStorage_(0.0) // value EMS is directing to use, power into storage [W] @@ -693,151 +698,138 @@ ElectPowerLoadCenter::ElectPowerLoadCenter(EnergyPlusData &state, int const obje int numNums; // Number of elements in the numeric array int IOStat; // IO Status when calling get input subroutine - state.dataIPShortCut->cCurrentModuleObject = "ElectricLoadCenter:Distribution"; + auto &s_ipsc = state.dataIPShortCut; + + s_ipsc->cCurrentModuleObject = "ElectricLoadCenter:Distribution"; bool errorsFound = false; if (objectNum > 0) { state.dataInputProcessing->inputProcessor->getObjectItem(state, - state.dataIPShortCut->cCurrentModuleObject, + s_ipsc->cCurrentModuleObject, objectNum, - state.dataIPShortCut->cAlphaArgs, + s_ipsc->cAlphaArgs, numAlphas, - state.dataIPShortCut->rNumericArgs, + s_ipsc->rNumericArgs, numNums, IOStat, - state.dataIPShortCut->lNumericFieldBlanks, - state.dataIPShortCut->lAlphaFieldBlanks, - state.dataIPShortCut->cAlphaFieldNames, - state.dataIPShortCut->cNumericFieldNames); + s_ipsc->lNumericFieldBlanks, + s_ipsc->lAlphaFieldBlanks, + s_ipsc->cAlphaFieldNames, + s_ipsc->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)}; - name_ = state.dataIPShortCut->cAlphaArgs(1); + name_ = s_ipsc->cAlphaArgs(1); // how to verify names are unique across objects? add to GlobalNames? - if (!state.dataIPShortCut->lAlphaFieldBlanks(2)) { - generatorListName_ = state.dataIPShortCut->cAlphaArgs(2); + if (!s_ipsc->lAlphaFieldBlanks(2)) { + generatorListName_ = s_ipsc->cAlphaArgs(2); // check that int testIndex = state.dataInputProcessing->inputProcessor->getObjectItemNum(state, "ElectricLoadCenter:Generators", generatorListName_); if (testIndex == 0) { - ShowSevereError( - state, - format( - "{}{}=\"{}\", invalid entry.", routineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("Invalid {} = {}", state.dataIPShortCut->cAlphaFieldNames(2), state.dataIPShortCut->cAlphaArgs(2))); + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2)); errorsFound = true; } } - if (!state.dataIPShortCut->lAlphaFieldBlanks(3)) { + if (!s_ipsc->lAlphaFieldBlanks(3)) { // Load the Generator Control Operation Scheme - if (Util::SameString(state.dataIPShortCut->cAlphaArgs(3), "Baseload")) { + if (Util::SameString(s_ipsc->cAlphaArgs(3), "Baseload")) { genOperationScheme_ = GeneratorOpScheme::BaseLoad; - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(3), "DemandLimit")) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(3), "DemandLimit")) { genOperationScheme_ = GeneratorOpScheme::DemandLimit; - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(3), "TrackElectrical")) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(3), "TrackElectrical")) { genOperationScheme_ = GeneratorOpScheme::TrackElectrical; - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(3), "TrackSchedule")) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(3), "TrackSchedule")) { genOperationScheme_ = GeneratorOpScheme::TrackSchedule; - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(3), "TrackMeter")) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(3), "TrackMeter")) { genOperationScheme_ = GeneratorOpScheme::TrackMeter; - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(3), "FollowThermal")) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(3), "FollowThermal")) { genOperationScheme_ = GeneratorOpScheme::ThermalFollow; - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(3), "FollowThermalLimitElectrical")) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(3), "FollowThermalLimitElectrical")) { genOperationScheme_ = GeneratorOpScheme::ThermalFollowLimitElectrical; } else { - ShowSevereError( - state, - format( - "{}{}=\"{}\", invalid entry.", routineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("Invalid {} = {}", state.dataIPShortCut->cAlphaFieldNames(3), state.dataIPShortCut->cAlphaArgs(3))); + ShowSevereInvalidKey(state, eoh, s_ipsc->cAlphaFieldNames(3), s_ipsc->cAlphaArgs(3)); errorsFound = true; } } - demandLimit_ = state.dataIPShortCut->rNumericArgs(1); + demandLimit_ = s_ipsc->rNumericArgs(1); - trackSchedPtr_ = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(4)); - if ((trackSchedPtr_ == 0) && (genOperationScheme_ == GeneratorOpScheme::TrackSchedule)) { - if (!state.dataIPShortCut->lAlphaFieldBlanks(4)) { - ShowSevereError( - state, - format( - "{}{}=\"{}\", invalid entry.", routineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("Invalid {} = {}", state.dataIPShortCut->cAlphaFieldNames(4), state.dataIPShortCut->cAlphaArgs(4))); - } else { - ShowSevereError( - state, - format( - "{}{}=\"{}\", invalid entry.", routineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("Invalid {} = blank field.", state.dataIPShortCut->cAlphaFieldNames(4))); + if (genOperationScheme_ == GeneratorOpScheme::TrackSchedule) { + if (s_ipsc->lAlphaFieldBlanks(4)) { + ShowSevereEmptyField(state, eoh, s_ipsc->cAlphaFieldNames(4)); + errorsFound = true; + } else if ((trackSched_ = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(4))) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(4), s_ipsc->cAlphaArgs(4)); + errorsFound = true; } - ShowContinueError(state, "Schedule not found; Must be entered and valid when Generator Operation Scheme=TrackSchedule"); - errorsFound = true; } - demandMeterName_ = Util::makeUPPER(state.dataIPShortCut->cAlphaArgs(5)); + demandMeterName_ = Util::makeUPPER(s_ipsc->cAlphaArgs(5)); // meters may not be "loaded" yet, defered check to later subroutine - if (Util::SameString(state.dataIPShortCut->cAlphaArgs(6), "AlternatingCurrent")) { + if (Util::SameString(s_ipsc->cAlphaArgs(6), "AlternatingCurrent")) { bussType = ElectricBussType::ACBuss; - state.dataIPShortCut->cAlphaArgs(6) = "AlternatingCurrent"; - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(6), "DirectCurrentWithInverter")) { + s_ipsc->cAlphaArgs(6) = "AlternatingCurrent"; + } else if (Util::SameString(s_ipsc->cAlphaArgs(6), "DirectCurrentWithInverter")) { bussType = ElectricBussType::DCBussInverter; inverterPresent = true; - state.dataIPShortCut->cAlphaArgs(6) = "DirectCurrentWithInverter"; - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(6), "AlternatingCurrentWithStorage")) { + s_ipsc->cAlphaArgs(6) = "DirectCurrentWithInverter"; + } else if (Util::SameString(s_ipsc->cAlphaArgs(6), "AlternatingCurrentWithStorage")) { bussType = ElectricBussType::ACBussStorage; storagePresent_ = true; - state.dataIPShortCut->cAlphaArgs(6) = "AlternatingCurrentWithStorage"; - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(6), "DirectCurrentWithInverterDCStorage")) { + s_ipsc->cAlphaArgs(6) = "AlternatingCurrentWithStorage"; + } else if (Util::SameString(s_ipsc->cAlphaArgs(6), "DirectCurrentWithInverterDCStorage")) { bussType = ElectricBussType::DCBussInverterDCStorage; inverterPresent = true; storagePresent_ = true; - state.dataIPShortCut->cAlphaArgs(6) = "DirectCurrentWithInverterDCStorage"; - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(6), "DirectCurrentWithInverterACStorage")) { + s_ipsc->cAlphaArgs(6) = "DirectCurrentWithInverterDCStorage"; + } else if (Util::SameString(s_ipsc->cAlphaArgs(6), "DirectCurrentWithInverterACStorage")) { bussType = ElectricBussType::DCBussInverterACStorage; inverterPresent = true; storagePresent_ = true; - state.dataIPShortCut->cAlphaArgs(6) = "DirectCurrentWithInverterACStorage"; - } else if (state.dataIPShortCut->cAlphaArgs(6).empty()) { + s_ipsc->cAlphaArgs(6) = "DirectCurrentWithInverterACStorage"; + } else if (s_ipsc->cAlphaArgs(6).empty()) { bussType = ElectricBussType::ACBuss; - state.dataIPShortCut->cAlphaArgs(6) = "AlternatingCurrent (field was blank)"; + s_ipsc->cAlphaArgs(6) = "AlternatingCurrent (field was blank)"; } else { ShowSevereError( state, - format("{}{}=\"{}\", invalid entry.", routineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("Invalid {} = {}", state.dataIPShortCut->cAlphaFieldNames(6), state.dataIPShortCut->cAlphaArgs(6))); + format("{}{}=\"{}\", invalid entry.", routineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); + ShowContinueError(state, format("Invalid {} = {}", s_ipsc->cAlphaFieldNames(6), s_ipsc->cAlphaArgs(6))); errorsFound = true; } if (inverterPresent) { - if (!state.dataIPShortCut->lAlphaFieldBlanks(7)) { - inverterName = state.dataIPShortCut->cAlphaArgs(7); + if (!s_ipsc->lAlphaFieldBlanks(7)) { + inverterName = s_ipsc->cAlphaArgs(7); } else { ShowSevereError( state, format( - "{}{}=\"{}\", invalid entry.", routineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("{} is blank, but buss type requires inverter.", state.dataIPShortCut->cAlphaFieldNames(7))); + "{}{}=\"{}\", invalid entry.", routineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); + ShowContinueError(state, format("{} is blank, but buss type requires inverter.", s_ipsc->cAlphaFieldNames(7))); errorsFound = true; } } if (storagePresent_) { - if (!state.dataIPShortCut->lAlphaFieldBlanks(8)) { - storageName_ = state.dataIPShortCut->cAlphaArgs(8); + if (!s_ipsc->lAlphaFieldBlanks(8)) { + storageName_ = s_ipsc->cAlphaArgs(8); } else { ShowSevereError( state, format( - "{}{}=\"{}\", invalid entry.", routineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("{} is blank, but buss type requires storage.", state.dataIPShortCut->cAlphaFieldNames(8))); + "{}{}=\"{}\", invalid entry.", routineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); + ShowContinueError(state, format("{} is blank, but buss type requires storage.", s_ipsc->cAlphaFieldNames(8))); errorsFound = true; } } - if (!state.dataIPShortCut->lAlphaFieldBlanks(9)) { + if (!s_ipsc->lAlphaFieldBlanks(9)) { // process transformer - transformerName_ = state.dataIPShortCut->cAlphaArgs(9); + transformerName_ = s_ipsc->cAlphaArgs(9); // only transformers of use type powerFromLoadCenterToBldg are really held in a load center, The legacy applications for transformers are // held at the higher Electric service level transformerPresent_ = true; @@ -845,173 +837,119 @@ ElectPowerLoadCenter::ElectPowerLoadCenter(EnergyPlusData &state, int const obje // Begin new content for grid supply and more control over storage // user selected storage operation scheme - if (!state.dataIPShortCut->lAlphaFieldBlanks(10)) { - if (Util::SameString(state.dataIPShortCut->cAlphaArgs(10), "TrackFacilityElectricDemandStoreExcessOnSite")) { + if (!s_ipsc->lAlphaFieldBlanks(10)) { + if (Util::SameString(s_ipsc->cAlphaArgs(10), "TrackFacilityElectricDemandStoreExcessOnSite")) { storageScheme_ = StorageOpScheme::FacilityDemandStoreExcessOnSite; - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(10), "TrackMeterDemandStoreExcessOnSite")) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(10), "TrackMeterDemandStoreExcessOnSite")) { storageScheme_ = StorageOpScheme::MeterDemandStoreExcessOnSite; - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(10), "TrackChargeDischargeSchedules")) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(10), "TrackChargeDischargeSchedules")) { storageScheme_ = StorageOpScheme::ChargeDischargeSchedules; - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(10), "FacilityDemandLeveling")) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(10), "FacilityDemandLeveling")) { storageScheme_ = StorageOpScheme::FacilityDemandLeveling; } else { - ShowSevereError( - state, - format( - "{}{}=\"{}\", invalid entry.", routineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("Invalid {} = {}", state.dataIPShortCut->cAlphaFieldNames(10), state.dataIPShortCut->cAlphaArgs(10))); + ShowSevereInvalidKey(state, eoh, s_ipsc->cAlphaFieldNames(10), s_ipsc->cAlphaArgs(10)); errorsFound = true; } } else { // blank (preserve legacy behavior for short files) storageScheme_ = StorageOpScheme::FacilityDemandStoreExcessOnSite; } - if (!state.dataIPShortCut->lAlphaFieldBlanks(11)) { - trackSorageOpMeterName_ = state.dataIPShortCut->cAlphaArgs(11); - - } else { - if (storageScheme_ == StorageOpScheme::MeterDemandStoreExcessOnSite) { // throw error - ShowSevereError( - state, - format( - "{}{}=\"{}\", invalid entry.", routineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, - format("Invalid {}, cannot be blank when storage operation scheme is TrackMeterDemandStoreExcessOnSite", - state.dataIPShortCut->cAlphaFieldNames(11))); - errorsFound = true; - } + if (!s_ipsc->lAlphaFieldBlanks(11)) { + trackSorageOpMeterName_ = s_ipsc->cAlphaArgs(11); + } else if (storageScheme_ == StorageOpScheme::MeterDemandStoreExcessOnSite) { // throw error + ShowSevereEmptyField(state, eoh, s_ipsc->cAlphaFieldNames(11), s_ipsc->cAlphaFieldNames(10), s_ipsc->cAlphaArgs(10)); + errorsFound = true; } - if (!state.dataIPShortCut->lAlphaFieldBlanks(12)) { - converterName_ = state.dataIPShortCut->cAlphaArgs(12); + if (!s_ipsc->lAlphaFieldBlanks(12)) { + converterName_ = s_ipsc->cAlphaArgs(12); converterPresent_ = true; - } else { - if (storageScheme_ == StorageOpScheme::ChargeDischargeSchedules || storageScheme_ == StorageOpScheme::FacilityDemandLeveling) { - ShowSevereError( - state, - format( - "{}{}=\"{}\", invalid entry.", routineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, - format("Invalid {}, cannot be blank when storage scheme is {}", - state.dataIPShortCut->cAlphaFieldNames(12), - state.dataIPShortCut->cAlphaArgs(10))); - errorsFound = true; - } + } else if (storageScheme_ == StorageOpScheme::ChargeDischargeSchedules || storageScheme_ == StorageOpScheme::FacilityDemandLeveling) { + ShowSevereEmptyField(state, eoh, s_ipsc->cAlphaFieldNames(12), s_ipsc->cAlphaFieldNames(10), s_ipsc->cAlphaArgs(10)); + errorsFound = true; } - if (state.dataIPShortCut->lNumericFieldBlanks(2)) { + if (s_ipsc->lNumericFieldBlanks(2)) { maxStorageSOCFraction_ = 1.0; } else { - maxStorageSOCFraction_ = state.dataIPShortCut->rNumericArgs(2); + maxStorageSOCFraction_ = s_ipsc->rNumericArgs(2); } - if (state.dataIPShortCut->lNumericFieldBlanks(3)) { + if (s_ipsc->lNumericFieldBlanks(3)) { minStorageSOCFraction_ = 0.0; } else { - minStorageSOCFraction_ = state.dataIPShortCut->rNumericArgs(3); + minStorageSOCFraction_ = s_ipsc->rNumericArgs(3); } - if (state.dataIPShortCut->lNumericFieldBlanks(4)) { + if (s_ipsc->lNumericFieldBlanks(4)) { designStorageChargePowerWasSet_ = false; } else { designStorageChargePowerWasSet_ = true; - designStorageChargePower_ = state.dataIPShortCut->rNumericArgs(4); + designStorageChargePower_ = s_ipsc->rNumericArgs(4); } - if (state.dataIPShortCut->lNumericFieldBlanks(5)) { + if (s_ipsc->lNumericFieldBlanks(5)) { designStorageDischargePowerWasSet_ = false; } else { designStorageDischargePowerWasSet_ = true; - designStorageDischargePower_ = state.dataIPShortCut->rNumericArgs(5); + designStorageDischargePower_ = s_ipsc->rNumericArgs(5); } - if (state.dataIPShortCut->lNumericFieldBlanks(6)) { - if (storageScheme_ == StorageOpScheme::FacilityDemandLeveling) { - ShowSevereError( - state, - format( - "{}{}=\"{}\", invalid entry.", routineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("Invalid {} = blank field.", state.dataIPShortCut->cNumericFieldNames(6))); - errorsFound = true; - } - } else { - facilityDemandTarget_ = state.dataIPShortCut->rNumericArgs(6); - } - storageChargeModSchedIndex_ = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(13)); - if (storageChargeModSchedIndex_ == 0 && storageScheme_ == StorageOpScheme::ChargeDischargeSchedules) { - if (!state.dataIPShortCut->lAlphaFieldBlanks(13)) { - ShowSevereError( - state, - format( - "{}{}=\"{}\", invalid entry.", routineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("Invalid {} = {}", state.dataIPShortCut->cAlphaFieldNames(13), state.dataIPShortCut->cAlphaArgs(13))); - } else { - ShowSevereError( - state, - format( - "{}{}=\"{}\", invalid entry.", routineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("Invalid {} = blank field.", state.dataIPShortCut->cAlphaFieldNames(13))); - } - ShowContinueError(state, "Schedule not found; Must be entered and valid when Storage Operation Scheme = TrackChargeDischargeSchedules"); + if (!s_ipsc->lNumericFieldBlanks(6)) { + facilityDemandTarget_ = s_ipsc->rNumericArgs(6); + } else if (storageScheme_ == StorageOpScheme::FacilityDemandLeveling) { + ShowSevereEmptyField(state, eoh, s_ipsc->cNumericFieldNames(6), s_ipsc->cAlphaFieldNames(10), s_ipsc->cAlphaArgs(10)); errorsFound = true; } - storageDischargeModSchedIndex_ = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(14)); - if (storageDischargeModSchedIndex_ == 0 && storageScheme_ == StorageOpScheme::ChargeDischargeSchedules) { - if (!state.dataIPShortCut->lAlphaFieldBlanks(14)) { - ShowSevereError( - state, - format( - "{}{}=\"{}\", invalid entry.", routineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("Invalid {} = {}", state.dataIPShortCut->cAlphaFieldNames(14), state.dataIPShortCut->cAlphaArgs(14))); - } else { - ShowSevereError( - state, - format( - "{}{}=\"{}\", invalid entry.", routineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("Invalid {} = blank field.", state.dataIPShortCut->cAlphaFieldNames(14))); + if (storageScheme_ == StorageOpScheme::ChargeDischargeSchedules) { + if (s_ipsc->lAlphaFieldBlanks(13)) { + ShowSevereEmptyField(state, eoh, s_ipsc->cAlphaFieldNames(13), s_ipsc->cAlphaFieldNames(10), s_ipsc->cAlphaArgs(10)); + errorsFound = true; + } else if ((storageChargeModSched_ = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(13))) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(13), s_ipsc->cAlphaArgs(13)); + errorsFound = true; + } + + if (s_ipsc->lAlphaFieldBlanks(14)) { + ShowSevereEmptyField(state, eoh, s_ipsc->cAlphaFieldNames(14), s_ipsc->cAlphaFieldNames(10), s_ipsc->cAlphaArgs(10)); + errorsFound = true; + } else if ((storageDischargeModSched_ = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(14))) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(14), s_ipsc->cAlphaArgs(14)); + errorsFound = true; } - ShowContinueError(state, "Schedule not found; Must be entered and valid when Storage Operation Scheme = TrackChargeDischargeSchedules"); - errorsFound = true; } - facilityDemandTargetModSchedIndex_ = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(15)); - if (facilityDemandTargetModSchedIndex_ == 0 && storageScheme_ == StorageOpScheme::FacilityDemandLeveling) { - if (!state.dataIPShortCut->lAlphaFieldBlanks(15)) { - ShowSevereError( - state, - format( - "{}{}=\"{}\", invalid entry.", routineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("Invalid {} = {}", state.dataIPShortCut->cAlphaFieldNames(15), state.dataIPShortCut->cAlphaArgs(15))); - } else { - ShowSevereError( - state, - format( - "{}{}=\"{}\", invalid entry.", routineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("Invalid {} = blank field.", state.dataIPShortCut->cAlphaFieldNames(15))); + + if (storageScheme_ == StorageOpScheme::FacilityDemandLeveling) { + if (s_ipsc->lAlphaFieldBlanks(15)) { + ShowSevereEmptyField(state, eoh, s_ipsc->cAlphaFieldNames(15), s_ipsc->cAlphaFieldNames(10), s_ipsc->cAlphaArgs(10)); + errorsFound = true; + } else if ((facilityDemandTargetModSched_ = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(15))) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(15), s_ipsc->cAlphaArgs(15)); + errorsFound = true; } - ShowContinueError(state, "Schedule not found; Must be entered and valid when Storage Operation Scheme = FacilityDemandLeveling"); - errorsFound = true; } + } else { // object num == 0 // just construct an empty object and return return; } // now that we are done with processing get input for ElectricLoadCenter:Distribution we can call child input objects without IP shortcut problems - state.dataIPShortCut->cCurrentModuleObject = "ElectricLoadCenter:Generators"; + s_ipsc->cCurrentModuleObject = "ElectricLoadCenter:Generators"; int genListObjectNum = - state.dataInputProcessing->inputProcessor->getObjectItemNum(state, state.dataIPShortCut->cCurrentModuleObject, generatorListName_); + state.dataInputProcessing->inputProcessor->getObjectItemNum(state, s_ipsc->cCurrentModuleObject, generatorListName_); if (genListObjectNum > 0) { state.dataInputProcessing->inputProcessor->getObjectItem(state, - state.dataIPShortCut->cCurrentModuleObject, + s_ipsc->cCurrentModuleObject, genListObjectNum, - state.dataIPShortCut->cAlphaArgs, + s_ipsc->cAlphaArgs, numAlphas, - state.dataIPShortCut->rNumericArgs, + s_ipsc->rNumericArgs, numNums, IOStat, - state.dataIPShortCut->lNumericFieldBlanks, - state.dataIPShortCut->lAlphaFieldBlanks, - state.dataIPShortCut->cAlphaFieldNames, - state.dataIPShortCut->cNumericFieldNames); + s_ipsc->lNumericFieldBlanks, + s_ipsc->lAlphaFieldBlanks, + s_ipsc->cAlphaFieldNames, + s_ipsc->cNumericFieldNames); // Calculate the number of generators in list numGenerators = numNums / 2; // note IDD needs Min Fields = 6 @@ -1021,11 +959,11 @@ ElectPowerLoadCenter::ElectPowerLoadCenter(EnergyPlusData &state, int const obje // call constructor in place generatorsPresent_ = true; elecGenCntrlObj.emplace_back(new GeneratorController(state, - state.dataIPShortCut->cAlphaArgs(alphaCount), - state.dataIPShortCut->cAlphaArgs(alphaCount + 1), - state.dataIPShortCut->rNumericArgs(2 * genCount - 1), - state.dataIPShortCut->cAlphaArgs(alphaCount + 2), - state.dataIPShortCut->rNumericArgs(2 * genCount))); + s_ipsc->cAlphaArgs(alphaCount), + s_ipsc->cAlphaArgs(alphaCount + 1), + s_ipsc->rNumericArgs(2 * genCount - 1), + s_ipsc->cAlphaArgs(alphaCount + 2), + s_ipsc->rNumericArgs(2 * genCount))); ++alphaCount; ++alphaCount; ++alphaCount; @@ -1039,8 +977,8 @@ ElectPowerLoadCenter::ElectPowerLoadCenter(EnergyPlusData &state, int const obje ShowWarningError(state, format("Generator operation needs to be based on following thermal loads and needs values for Rated Thermal to " "Electrical Power Ratio in {} named {}", - state.dataIPShortCut->cCurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1))); + s_ipsc->cCurrentModuleObject, + s_ipsc->cAlphaArgs(1))); } } } @@ -1084,24 +1022,24 @@ ElectPowerLoadCenter::ElectPowerLoadCenter(EnergyPlusData &state, int const obje if (!errorsFound && transformerPresent_) { - state.dataIPShortCut->cCurrentModuleObject = "ElectricLoadCenter:Transformer"; + s_ipsc->cCurrentModuleObject = "ElectricLoadCenter:Transformer"; int transformerItemNum = - state.dataInputProcessing->inputProcessor->getObjectItemNum(state, state.dataIPShortCut->cCurrentModuleObject, transformerName_); + state.dataInputProcessing->inputProcessor->getObjectItemNum(state, s_ipsc->cCurrentModuleObject, transformerName_); if (transformerItemNum > 0) { int iOStat; state.dataInputProcessing->inputProcessor->getObjectItem(state, - state.dataIPShortCut->cCurrentModuleObject, + s_ipsc->cCurrentModuleObject, transformerItemNum, - state.dataIPShortCut->cAlphaArgs, + s_ipsc->cAlphaArgs, numAlphas, - state.dataIPShortCut->rNumericArgs, + s_ipsc->rNumericArgs, numNums, iOStat, - state.dataIPShortCut->lNumericFieldBlanks, - state.dataIPShortCut->lAlphaFieldBlanks, - state.dataIPShortCut->cAlphaFieldNames, - state.dataIPShortCut->cNumericFieldNames); - if (Util::SameString(state.dataIPShortCut->cAlphaArgs(3), + s_ipsc->lNumericFieldBlanks, + s_ipsc->lAlphaFieldBlanks, + s_ipsc->cAlphaFieldNames, + s_ipsc->cNumericFieldNames); + if (Util::SameString(s_ipsc->cAlphaArgs(3), "LoadCenterPowerConditioning")) { // this is the right kind of transformer transformerObj = std::make_unique(state, transformerName_); } else { @@ -1110,7 +1048,7 @@ ElectPowerLoadCenter::ElectPowerLoadCenter(EnergyPlusData &state, int const obje format("Transformer named {} associated with the load center named {} should have {} set to LoadCenterPowerConditioning.", transformerName_, name_, - state.dataIPShortCut->cAlphaFieldNames(3))); + s_ipsc->cAlphaFieldNames(3))); } } else { ShowSevereError(state, format("Transformer named {}, was not found for the load center named {}", transformerName_, name_)); @@ -1250,7 +1188,7 @@ void ElectPowerLoadCenter::dispatchGenerators(EnergyPlusData &state, for (auto &g : elecGenCntrlObj) { - if (ScheduleManager::GetCurrentScheduleValue(state, g->availSchedPtr) > 0.0) { + if (g->availSched->getCurrentVal() > 0.0) { // Set the Operation Flag g->onThisTimestep = true; // Set the electric generator load request @@ -1287,7 +1225,7 @@ void ElectPowerLoadCenter::dispatchGenerators(EnergyPlusData &state, for (auto &g : elecGenCntrlObj) { - if (ScheduleManager::GetCurrentScheduleValue(state, g->availSchedPtr) > 0.0 && remainingLoad > 0.0) { + if (g->availSched->getCurrentVal() > 0.0 && remainingLoad > 0.0) { // Set the Operation Flag g->onThisTimestep = true; @@ -1342,7 +1280,7 @@ void ElectPowerLoadCenter::dispatchGenerators(EnergyPlusData &state, for (auto &g : elecGenCntrlObj) { - if (ScheduleManager::GetCurrentScheduleValue(state, g->availSchedPtr) > 0.0 && remainingLoad > 0.0) { + if (g->availSched->getCurrentVal() > 0.0 && remainingLoad > 0.0) { // Set the Operation Flag g->onThisTimestep = true; @@ -1393,12 +1331,12 @@ void ElectPowerLoadCenter::dispatchGenerators(EnergyPlusData &state, // The Track Schedule scheme tries to have the generators meet the electrical demand determined from a schedule. // Code is very similar to 'Track Electrical' except for initial RemainingLoad is replaced by SchedElecDemand // and PV production is ignored. - remainingLoad = ScheduleManager::GetCurrentScheduleValue(state, trackSchedPtr_); + remainingLoad = trackSched_->getCurrentVal(); loadCenterElectricLoad = remainingLoad; for (auto &g : elecGenCntrlObj) { - if (ScheduleManager::GetCurrentScheduleValue(state, g->availSchedPtr) > 0.0 && remainingLoad > 0.0) { + if (g->availSched->getCurrentVal() > 0.0 && remainingLoad > 0.0) { // Set the Operation Flag g->onThisTimestep = true; @@ -1458,7 +1396,7 @@ void ElectPowerLoadCenter::dispatchGenerators(EnergyPlusData &state, loadCenterElectricLoad = remainingLoad; for (auto &g : elecGenCntrlObj) { - if (ScheduleManager::GetCurrentScheduleValue(state, g->availSchedPtr) > 0.0 && remainingLoad > 0.0) { + if (g->availSched->getCurrentVal() > 0.0 && remainingLoad > 0.0) { // Set the Operation Flag g->onThisTimestep = true; // Set the electric generator load @@ -1511,7 +1449,7 @@ void ElectPowerLoadCenter::dispatchGenerators(EnergyPlusData &state, Real64 loadCenterThermalLoad = remainingThermalLoad; for (auto &g : elecGenCntrlObj) { - if (ScheduleManager::GetCurrentScheduleValue(state, g->availSchedPtr) > 0.0 && remainingThermalLoad > 0.0) { + if (g->availSched->getCurrentVal() > 0.0 && remainingThermalLoad > 0.0) { if (g->nominalThermElectRatio > 0.0) { remainingLoad = remainingThermalLoad / g->nominalThermElectRatio; @@ -1577,7 +1515,7 @@ void ElectPowerLoadCenter::dispatchGenerators(EnergyPlusData &state, loadCenterElectricLoad = remainingWholePowerDemand; Real64 loadCenterThermalLoad = remainingThermalLoad; for (auto &g : elecGenCntrlObj) { - if ((ScheduleManager::GetCurrentScheduleValue(state, g->availSchedPtr) > 0.0) && (remainingThermalLoad > 0.0) && (remainingLoad > 0.0)) { + if ((g->availSched->getCurrentVal() > 0.0) && (remainingThermalLoad > 0.0) && (remainingLoad > 0.0)) { if (g->nominalThermElectRatio > 0.0) { remainingLoad = min(remainingWholePowerDemand, remainingThermalLoad / g->nominalThermElectRatio); g->powerRequestThisTimestep = min(g->maxPowerOut, remainingLoad); @@ -1708,7 +1646,7 @@ void ElectPowerLoadCenter::dispatchStorage(EnergyPlusData &state, break; } case StorageOpScheme::FacilityDemandLeveling: { - Real64 demandTarget = facilityDemandTarget_ * ScheduleManager::GetCurrentScheduleValue(state, facilityDemandTargetModSchedIndex_); + Real64 demandTarget = facilityDemandTarget_ * facilityDemandTargetModSched_->getCurrentVal(); // compare target to Real64 deltaLoad = originalFeedInRequest - demandTarget; if (deltaLoad >= 0.0) { @@ -1811,8 +1749,8 @@ void ElectPowerLoadCenter::dispatchStorage(EnergyPlusData &state, } case StorageOpScheme::ChargeDischargeSchedules: { - storOpCVChargeRate = designStorageChargePower_ * ScheduleManager::GetCurrentScheduleValue(state, storageChargeModSchedIndex_); - storOpCVDischargeRate = designStorageDischargePower_ * ScheduleManager::GetCurrentScheduleValue(state, storageDischargeModSchedIndex_); + storOpCVChargeRate = designStorageChargePower_ * storageChargeModSched_->getCurrentVal(); + storOpCVDischargeRate = designStorageDischargePower_ * storageDischargeModSched_->getCurrentVal(); Real64 genAndStorSum = storOpCVGenRate + storOpCVDischargeRate - storOpCVChargeRate; if (genAndStorSum >= 0.0) { // power to feed toward main panel storOpCVDrawRate = 0.0; @@ -2152,6 +2090,8 @@ Real64 ElectPowerLoadCenter::calcLoadCenterThermalLoad(EnergyPlusData &state) return thermalLoad; } + +// TODO: Constructors should not do this much work GeneratorController::GeneratorController(EnergyPlusData &state, std::string const &objectName, std::string const &objectType, @@ -2159,7 +2099,7 @@ GeneratorController::GeneratorController(EnergyPlusData &state, std::string const &availSchedName, Real64 thermalToElectRatio) : generatorType(GeneratorType::Invalid), compPlantType(DataPlant::PlantEquipmentType::Invalid), generatorIndex(0), maxPowerOut(0.0), - availSchedPtr(0), powerRequestThisTimestep(0.0), onThisTimestep(false), eMSPowerRequest(0.0), eMSRequestOn(false), plantInfoFound(false), + powerRequestThisTimestep(0.0), onThisTimestep(false), eMSPowerRequest(0.0), eMSRequestOn(false), plantInfoFound(false), cogenLocation(PlantLocation(0, DataPlant::LoopSideLocation::Invalid, 0, 0)), nominalThermElectRatio(0.0), dCElectricityProd(0.0), dCElectProdRate(0.0), electricityProd(0.0), electProdRate(0.0), thermalProd(0.0), thermProdRate(0.0), pvwattsGenerator(nullptr), errCountNegElectProd_(0) @@ -2167,6 +2107,10 @@ GeneratorController::GeneratorController(EnergyPlusData &state, static constexpr std::string_view routineName = "GeneratorController constructor "; + auto &s_ipsc = state.dataIPShortCut; + + ErrorObjectHeader eoh{routineName, objectType, objectName}; + name = objectName; generatorType = static_cast(getEnumValue(GeneratorTypeNamesUC, Util::makeUPPER(objectType))); @@ -2222,51 +2166,33 @@ GeneratorController::GeneratorController(EnergyPlusData &state, break; } default: { - ShowSevereError(state, format("{}{} invalid entry.", routineName, state.dataIPShortCut->cCurrentModuleObject)); + ShowSevereError(state, format("{}{} invalid entry.", routineName, s_ipsc->cCurrentModuleObject)); ShowContinueError(state, format("Invalid {} associated with generator = {}", objectType, objectName)); break; } } - availSched = availSchedName; - if (availSched.empty()) { - availSchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - availSchedPtr = ScheduleManager::GetScheduleIndex(state, availSchedName); - if (availSchedPtr <= 0) { - ShowSevereError(state, format("{}{}, invalid entry.", routineName, state.dataIPShortCut->cCurrentModuleObject)); - ShowContinueError(state, format("Invalid availability schedule = {}", availSchedName)); - ShowContinueError(state, "Schedule was not found "); - } else { - if (generatorType == GeneratorType::PVWatts) { - ShowWarningError(state, - format("{}{}, Availability Schedule for Generator:PVWatts '{}' will be be ignored (runs all the time).", - routineName, - state.dataIPShortCut->cCurrentModuleObject, - objectName)); - } else if (generatorType == GeneratorType::PV) { - // It should only warn if Performance type is SimplePV (DataPhotovoltaics::iSimplePVModel). - // Except you need GetPVInput to have run already etc - // Note: you can't use state.dataIPShortCut->cAlphaArgs etc or it'll override what will still need to be processed in - // ElectPowerLoadCenter::ElectPowerLoadCenter after this function is called - int PVNum = state.dataInputProcessing->inputProcessor->getObjectItemNum(state, objectType, Util::makeUPPER(objectName)); - int NumAlphas; // Number of PV Array parameter alpha names being passed - int NumNums; // Number of PV Array numeric parameters are being passed - int IOStat; - Array1D_string Alphas(5); // Alpha items for object - Array1D Numbers(2); // Numeric items for object - state.dataInputProcessing->inputProcessor->getObjectItem(state, objectType, PVNum, Alphas, NumAlphas, Numbers, NumNums, IOStat); - if (Util::SameString(Alphas(3), "PhotovoltaicPerformance:Simple")) { - ShowWarningError(state, - format("{}{}, Availability Schedule for Generator:Photovoltaics '{}' of Type PhotovoltaicPerformance:Simple " - "will be be ignored (runs all the time).", - routineName, - state.dataIPShortCut->cCurrentModuleObject, - objectName)); - ShowContinueError(state, - "To limit this Generator:Photovoltaic's output, please use the Inverter's availability schedule instead."); - } - } + if (availSchedName.empty()) { + availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((availSched = Sched::GetSchedule(state, availSchedName)) == nullptr) { + ShowSevereItemNotFound(state, eoh, "Availability Schedule Name", availSchedName); + } else if (generatorType == GeneratorType::PVWatts) { + ShowWarningCustom(state, eoh, "Availability Schedule will be ignored (runs all the time)."); + } else if (generatorType == GeneratorType::PV) { + // It should only warn if Performance type is SimplePV (DataPhotovoltaics::iSimplePVModel). + // Except you need GetPVInput to have run already etc + // Note: you can't use s_ipsc->cAlphaArgs etc or it'll override what will still need to be processed in + // ElectPowerLoadCenter::ElectPowerLoadCenter after this function is called + int PVNum = state.dataInputProcessing->inputProcessor->getObjectItemNum(state, objectType, Util::makeUPPER(objectName)); + int NumAlphas; // Number of PV Array parameter alpha names being passed + int NumNums; // Number of PV Array numeric parameters are being passed + int IOStat; + Array1D_string Alphas(5); // Alpha items for object + Array1D Numbers(2); // Numeric items for object + state.dataInputProcessing->inputProcessor->getObjectItem(state, objectType, PVNum, Alphas, NumAlphas, Numbers, NumNums, IOStat); + if (Util::SameString(Alphas(3), "PhotovoltaicPerformance:Simple")) { + ShowWarningCustom(state, eoh, "Availability Schedule will be ignored (runs all the time)."); + ShowContinueError(state, "To limit this Generator:Photovoltaic's output, please use the Inverter's availability schedule instead."); } } @@ -2450,7 +2376,7 @@ void GeneratorController::simGeneratorGetPowerOutput(EnergyPlusData &state, DCtoACInverter::DCtoACInverter(EnergyPlusData &state, std::string const &objectName) : aCPowerOut_(0.0), aCEnergyOut_(0.0), efficiency_(0.0), dCPowerIn_(0.0), dCEnergyIn_(0.0), conversionLossPower_(0.0), conversionLossEnergy_(0.0), conversionLossEnergyDecrement_(0.0), thermLossRate_(0.0), thermLossEnergy_(0.0), qdotConvZone_(0.0), qdotRadZone_(0.0), ancillACuseRate_(0.0), - ancillACuseEnergy_(0.0), modelType_(InverterModelType::Invalid), availSchedPtr_(0), heatLossesDestination_(ThermalLossDestination::Invalid), + ancillACuseEnergy_(0.0), modelType_(InverterModelType::Invalid), heatLossesDestination_(ThermalLossDestination::Invalid), zoneNum_(0), zoneRadFract_(0.0), nominalVoltage_(0.0), nomVoltEfficiencyARR_(6, 0.0), curveNum_(0), ratedPower_(0.0), minPower_(0.0), maxPower_(0.0), minEfficiency_(0.0), maxEfficiency_(0.0), standbyPower_(0.0) { @@ -2458,6 +2384,9 @@ DCtoACInverter::DCtoACInverter(EnergyPlusData &state, std::string const &objectN nomVoltEfficiencyARR_.resize(6, 0.0); static constexpr std::string_view routineName = "DCtoACInverter constructor "; + + auto &s_ipsc = state.dataIPShortCut; + bool errorsFound = false; // if/when add object class name to input object this can be simplified. for now search all possible types bool foundInverter = false; @@ -2468,28 +2397,28 @@ DCtoACInverter::DCtoACInverter(EnergyPlusData &state, std::string const &objectN if (testInvertIndex > 0) { foundInverter = true; invertIDFObjectNum = testInvertIndex; - state.dataIPShortCut->cCurrentModuleObject = "ElectricLoadCenter:Inverter:LookUpTable"; + s_ipsc->cCurrentModuleObject = "ElectricLoadCenter:Inverter:LookUpTable"; modelType_ = InverterModelType::CECLookUpTableModel; } testInvertIndex = state.dataInputProcessing->inputProcessor->getObjectItemNum(state, "ElectricLoadCenter:Inverter:FunctionOfPower", objectName); if (testInvertIndex > 0) { foundInverter = true; invertIDFObjectNum = testInvertIndex; - state.dataIPShortCut->cCurrentModuleObject = "ElectricLoadCenter:Inverter:FunctionOfPower"; + s_ipsc->cCurrentModuleObject = "ElectricLoadCenter:Inverter:FunctionOfPower"; modelType_ = InverterModelType::CurveFuncOfPower; } testInvertIndex = state.dataInputProcessing->inputProcessor->getObjectItemNum(state, "ElectricLoadCenter:Inverter:Simple", objectName); if (testInvertIndex > 0) { foundInverter = true; invertIDFObjectNum = testInvertIndex; - state.dataIPShortCut->cCurrentModuleObject = "ElectricLoadCenter:Inverter:Simple"; + s_ipsc->cCurrentModuleObject = "ElectricLoadCenter:Inverter:Simple"; modelType_ = InverterModelType::SimpleConstantEff; } testInvertIndex = state.dataInputProcessing->inputProcessor->getObjectItemNum(state, "ElectricLoadCenter:Inverter:PVWatts", objectName); if (testInvertIndex > 0) { foundInverter = true; invertIDFObjectNum = testInvertIndex; - state.dataIPShortCut->cCurrentModuleObject = "ElectricLoadCenter:Inverter:PVWatts"; + s_ipsc->cCurrentModuleObject = "ElectricLoadCenter:Inverter:PVWatts"; modelType_ = InverterModelType::PVWatts; } @@ -2499,101 +2428,81 @@ DCtoACInverter::DCtoACInverter(EnergyPlusData &state, std::string const &objectN int IOStat; // IO Status when calling get input subroutine state.dataInputProcessing->inputProcessor->getObjectItem(state, - state.dataIPShortCut->cCurrentModuleObject, + s_ipsc->cCurrentModuleObject, invertIDFObjectNum, - state.dataIPShortCut->cAlphaArgs, + s_ipsc->cAlphaArgs, NumAlphas, - state.dataIPShortCut->rNumericArgs, + s_ipsc->rNumericArgs, NumNums, IOStat, - state.dataIPShortCut->lNumericFieldBlanks, - state.dataIPShortCut->lAlphaFieldBlanks, - state.dataIPShortCut->cAlphaFieldNames, - state.dataIPShortCut->cNumericFieldNames); + s_ipsc->lNumericFieldBlanks, + s_ipsc->lAlphaFieldBlanks, + s_ipsc->cAlphaFieldNames, + s_ipsc->cNumericFieldNames); - name_ = state.dataIPShortCut->cAlphaArgs(1); + + ErrorObjectHeader eoh{routineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)}; + name_ = s_ipsc->cAlphaArgs(1); // how to verify names are unique across objects? add to GlobalNames? if (modelType_ == InverterModelType::PVWatts) { - availSchedPtr_ = ScheduleManager::ScheduleAlwaysOn; + availSched_ = Sched::GetScheduleAlwaysOn(state); zoneNum_ = 0; heatLossesDestination_ = ThermalLossDestination::LostToOutside; zoneRadFract_ = 0; + } else if (s_ipsc->lAlphaFieldBlanks(2)) { + availSched_ = Sched::GetScheduleAlwaysOn(state); } else { - if (state.dataIPShortCut->lAlphaFieldBlanks(2)) { - availSchedPtr_ = ScheduleManager::ScheduleAlwaysOn; - } else { - availSchedPtr_ = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(2)); - if (availSchedPtr_ == 0) { - ShowSevereError(state, - format("{}{}=\"{}\", invalid entry.", - routineName, - state.dataIPShortCut->cCurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, - format("Invalid {} = {}", state.dataIPShortCut->cAlphaFieldNames(2), state.dataIPShortCut->cAlphaArgs(2))); - errorsFound = true; - } + if ((availSched_ = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2)); + errorsFound = true; } - zoneNum_ = Util::FindItemInList(state.dataIPShortCut->cAlphaArgs(3), state.dataHeatBal->Zone); - if (zoneNum_ > 0) heatLossesDestination_ = ThermalLossDestination::ZoneGains; - if (zoneNum_ == 0) { - if (state.dataIPShortCut->lAlphaFieldBlanks(3)) { - heatLossesDestination_ = ThermalLossDestination::LostToOutside; - } else { - heatLossesDestination_ = ThermalLossDestination::LostToOutside; - ShowWarningError(state, - format("{}{}=\"{}\", invalid entry.", - routineName, - state.dataIPShortCut->cCurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, - format("Invalid {} = {}", state.dataIPShortCut->cAlphaFieldNames(3), state.dataIPShortCut->cAlphaArgs(3))); - ShowContinueError(state, "Zone name not found. Inverter heat losses will not be added to a zone"); - // continue with simulation but inverter losses not sent to a zone. - } + if (s_ipsc->lAlphaFieldBlanks(3)) { + heatLossesDestination_ = ThermalLossDestination::LostToOutside; + } else if ((zoneNum_ = Util::FindItemInList(s_ipsc->cAlphaArgs(3), state.dataHeatBal->Zone)) == 0) { + heatLossesDestination_ = ThermalLossDestination::LostToOutside; + ShowWarningItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(3), s_ipsc->cAlphaArgs(3), + "Inverter heat losses will not be added to a zone"); + // continue with simulation but inverter losses not sent to a zone. + } else { + heatLossesDestination_ = ThermalLossDestination::ZoneGains; } - zoneRadFract_ = state.dataIPShortCut->rNumericArgs(1); + zoneRadFract_ = s_ipsc->rNumericArgs(1); } // now the input objects differ depending on class type switch (modelType_) { case InverterModelType::CECLookUpTableModel: { - ratedPower_ = state.dataIPShortCut->rNumericArgs(2); - standbyPower_ = state.dataIPShortCut->rNumericArgs(3); - - nominalVoltage_ = state.dataIPShortCut->rNumericArgs(4); - nomVoltEfficiencyARR_[0] = state.dataIPShortCut->rNumericArgs(5); - nomVoltEfficiencyARR_[1] = state.dataIPShortCut->rNumericArgs(6); - nomVoltEfficiencyARR_[2] = state.dataIPShortCut->rNumericArgs(7); - nomVoltEfficiencyARR_[3] = state.dataIPShortCut->rNumericArgs(8); - nomVoltEfficiencyARR_[4] = state.dataIPShortCut->rNumericArgs(9); - nomVoltEfficiencyARR_[5] = state.dataIPShortCut->rNumericArgs(10); + ratedPower_ = s_ipsc->rNumericArgs(2); + standbyPower_ = s_ipsc->rNumericArgs(3); + + nominalVoltage_ = s_ipsc->rNumericArgs(4); + nomVoltEfficiencyARR_[0] = s_ipsc->rNumericArgs(5); + nomVoltEfficiencyARR_[1] = s_ipsc->rNumericArgs(6); + nomVoltEfficiencyARR_[2] = s_ipsc->rNumericArgs(7); + nomVoltEfficiencyARR_[3] = s_ipsc->rNumericArgs(8); + nomVoltEfficiencyARR_[4] = s_ipsc->rNumericArgs(9); + nomVoltEfficiencyARR_[5] = s_ipsc->rNumericArgs(10); break; } case InverterModelType::CurveFuncOfPower: { - curveNum_ = Curve::GetCurveIndex(state, state.dataIPShortCut->cAlphaArgs(4)); + curveNum_ = Curve::GetCurveIndex(state, s_ipsc->cAlphaArgs(4)); if (curveNum_ == 0) { - ShowSevereError( - state, - format( - "{}{}=\"{}\", invalid entry.", routineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("Invalid {} = {}", state.dataIPShortCut->cAlphaFieldNames(4), state.dataIPShortCut->cAlphaArgs(4))); - ShowContinueError(state, "Curve was not found"); + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(4), s_ipsc->cAlphaArgs(4)); errorsFound = true; } - ratedPower_ = state.dataIPShortCut->rNumericArgs(2); - minEfficiency_ = state.dataIPShortCut->rNumericArgs(3); - maxEfficiency_ = state.dataIPShortCut->rNumericArgs(4); - minPower_ = state.dataIPShortCut->rNumericArgs(5); - maxPower_ = state.dataIPShortCut->rNumericArgs(6); - standbyPower_ = state.dataIPShortCut->rNumericArgs(7); + ratedPower_ = s_ipsc->rNumericArgs(2); + minEfficiency_ = s_ipsc->rNumericArgs(3); + maxEfficiency_ = s_ipsc->rNumericArgs(4); + minPower_ = s_ipsc->rNumericArgs(5); + maxPower_ = s_ipsc->rNumericArgs(6); + standbyPower_ = s_ipsc->rNumericArgs(7); break; } case InverterModelType::SimpleConstantEff: { - efficiency_ = state.dataIPShortCut->rNumericArgs(2); + efficiency_ = s_ipsc->rNumericArgs(2); break; } case InverterModelType::Invalid: { @@ -2601,8 +2510,8 @@ DCtoACInverter::DCtoACInverter(EnergyPlusData &state, std::string const &objectN break; } case InverterModelType::PVWatts: { - pvWattsDCtoACSizeRatio_ = state.dataIPShortCut->rNumericArgs(1); - pvWattsInverterEfficiency_ = state.dataIPShortCut->rNumericArgs(2); + pvWattsDCtoACSizeRatio_ = s_ipsc->rNumericArgs(1); + pvWattsInverterEfficiency_ = s_ipsc->rNumericArgs(2); break; } default: @@ -2915,7 +2824,7 @@ void DCtoACInverter::simulate(EnergyPlusData &state, Real64 const powerIntoInver dCPowerIn_ = powerIntoInverter; dCEnergyIn_ = dCPowerIn_ * (state.dataHVACGlobal->TimeStepSysSec); // check availability schedule - if (ScheduleManager::GetCurrentScheduleValue(state, availSchedPtr_) > 0.0) { + if (availSched_->getCurrentVal() > 0.0) { // now calculate Inverter based on model type calcEfficiency(state); @@ -2949,12 +2858,15 @@ void DCtoACInverter::simulate(EnergyPlusData &state, Real64 const powerIntoInver ACtoDCConverter::ACtoDCConverter(EnergyPlusData &state, std::string const &objectName) : efficiency_(0.0), aCPowerIn_(0.0), aCEnergyIn_(0.0), dCPowerOut_(0.0), dCEnergyOut_(0.0), conversionLossPower_(0.0), conversionLossEnergy_(0.0), conversionLossEnergyDecrement_(0.0), thermLossRate_(0.0), thermLossEnergy_(0.0), qdotConvZone_(0.0), qdotRadZone_(0.0), ancillACuseRate_(0.0), - ancillACuseEnergy_(0.0), availSchedPtr_(0), modelType_(ConverterModelType::Invalid), heatLossesDestination_(ThermalLossDestination::Invalid), + ancillACuseEnergy_(0.0), modelType_(ConverterModelType::Invalid), heatLossesDestination_(ThermalLossDestination::Invalid), zoneNum_(0), zoneRadFract_(0.0), // radiative fraction for thermal losses to zone standbyPower_(0.0), maxPower_(0.0) { static constexpr std::string_view routineName = "ACtoDCConverter constructor "; + + auto &s_ipsc = state.dataIPShortCut; + bool errorsFound = false; // if/when add object class name to input object this can be simplified. for now search all possible types @@ -2964,66 +2876,53 @@ ACtoDCConverter::ACtoDCConverter(EnergyPlusData &state, std::string const &objec int NumAlphas; // Number of elements in the alpha array int NumNums; // Number of elements in the numeric array int IOStat; // IO Status when calling get input subroutine - state.dataIPShortCut->cCurrentModuleObject = "ElectricLoadCenter:Storage:Converter"; + s_ipsc->cCurrentModuleObject = "ElectricLoadCenter:Storage:Converter"; state.dataInputProcessing->inputProcessor->getObjectItem(state, - state.dataIPShortCut->cCurrentModuleObject, + s_ipsc->cCurrentModuleObject, testConvertIndex, - state.dataIPShortCut->cAlphaArgs, + s_ipsc->cAlphaArgs, NumAlphas, - state.dataIPShortCut->rNumericArgs, + s_ipsc->rNumericArgs, NumNums, IOStat, - state.dataIPShortCut->lNumericFieldBlanks, - state.dataIPShortCut->lAlphaFieldBlanks, - state.dataIPShortCut->cAlphaFieldNames, - state.dataIPShortCut->cNumericFieldNames); - - name_ = state.dataIPShortCut->cAlphaArgs(1); + s_ipsc->lNumericFieldBlanks, + s_ipsc->lAlphaFieldBlanks, + s_ipsc->cAlphaFieldNames, + s_ipsc->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)}; + + name_ = s_ipsc->cAlphaArgs(1); // need a new general approach for verify names are unique across objects, next gen GlobalNames - if (state.dataIPShortCut->lAlphaFieldBlanks(2)) { - availSchedPtr_ = ScheduleManager::ScheduleAlwaysOn; - } else { - availSchedPtr_ = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(2)); - if (availSchedPtr_ == 0) { - ShowSevereError( - state, - format( - "{}{}=\"{}\", invalid entry.", routineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("Invalid {} = {}", state.dataIPShortCut->cAlphaFieldNames(2), state.dataIPShortCut->cAlphaArgs(2))); - errorsFound = true; - } + if (s_ipsc->lAlphaFieldBlanks(2)) { + availSched_ = Sched::GetScheduleAlwaysOn(state); + } else if ((availSched_ = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2)); + errorsFound = true; } - if (Util::SameString(state.dataIPShortCut->cAlphaArgs(3), "SimpleFixed")) { + if (Util::SameString(s_ipsc->cAlphaArgs(3), "SimpleFixed")) { modelType_ = ConverterModelType::SimpleConstantEff; - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(3), "FunctionOfPower")) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(3), "FunctionOfPower")) { modelType_ = ConverterModelType::CurveFuncOfPower; } else { - ShowSevereError( - state, - format("{}{}=\"{}\", invalid entry.", routineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("Invalid {} = {}", state.dataIPShortCut->cAlphaFieldNames(3), state.dataIPShortCut->cAlphaArgs(3))); + ShowSevereInvalidKey(state, eoh, s_ipsc->cAlphaFieldNames(3), s_ipsc->cAlphaArgs(3)); errorsFound = true; } switch (modelType_) { case ConverterModelType::SimpleConstantEff: { - efficiency_ = state.dataIPShortCut->rNumericArgs(1); + efficiency_ = s_ipsc->rNumericArgs(1); break; } case ConverterModelType::CurveFuncOfPower: { - maxPower_ = state.dataIPShortCut->rNumericArgs(2); - curveNum_ = Curve::GetCurveIndex(state, state.dataIPShortCut->cAlphaArgs(4)); + maxPower_ = s_ipsc->rNumericArgs(2); + curveNum_ = Curve::GetCurveIndex(state, s_ipsc->cAlphaArgs(4)); if (curveNum_ == 0) { - ShowSevereError( - state, - format( - "{}{}=\"{}\", invalid entry.", routineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("Invalid {} = {}", state.dataIPShortCut->cAlphaFieldNames(4), state.dataIPShortCut->cAlphaArgs(4))); - ShowContinueError(state, "Curve was not found"); + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(4), s_ipsc->cAlphaArgs(4)); errorsFound = true; } break; @@ -3036,25 +2935,19 @@ ACtoDCConverter::ACtoDCConverter(EnergyPlusData &state, std::string const &objec assert(false); } // end switch - standbyPower_ = state.dataIPShortCut->rNumericArgs(3); + standbyPower_ = s_ipsc->rNumericArgs(3); - zoneNum_ = Util::FindItemInList(state.dataIPShortCut->cAlphaArgs(5), state.dataHeatBal->Zone); - if (zoneNum_ > 0) heatLossesDestination_ = ThermalLossDestination::ZoneGains; - if (zoneNum_ == 0) { - if (state.dataIPShortCut->lAlphaFieldBlanks(5)) { - heatLossesDestination_ = ThermalLossDestination::LostToOutside; - } else { - heatLossesDestination_ = ThermalLossDestination::LostToOutside; - ShowWarningError( - state, - format( - "{}{}=\"{}\", invalid entry.", routineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("Invalid {} = {}", state.dataIPShortCut->cAlphaFieldNames(5), state.dataIPShortCut->cAlphaArgs(5))); - ShowContinueError(state, "Zone name not found. Inverter heat losses will not be added to a zone"); - // continue with simulation but inverter losses not sent to a zone. - } + if (s_ipsc->lAlphaFieldBlanks(5)) { + heatLossesDestination_ = ThermalLossDestination::LostToOutside; + } else if ((zoneNum_ = Util::FindItemInList(s_ipsc->cAlphaArgs(5), state.dataHeatBal->Zone)) == 0) { + heatLossesDestination_ = ThermalLossDestination::LostToOutside; + ShowWarningItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(5), s_ipsc->cAlphaArgs(5), "Inverter heat losses will not be added to a zone"); + // continue with simulation but inverter losses not sent to a zone. + } else { + heatLossesDestination_ = ThermalLossDestination::ZoneGains; } - zoneRadFract_ = state.dataIPShortCut->rNumericArgs(4); + + zoneRadFract_ = s_ipsc->rNumericArgs(4); SetupOutputVariable(state, "Converter AC to DC Efficiency", @@ -3214,7 +3107,7 @@ void ACtoDCConverter::simulate(EnergyPlusData &state, Real64 const powerOutFromC // need to invert, find an aCPowerIn that produces the desired DC power out // use last efficiency for initial guess - if (ScheduleManager::GetCurrentScheduleValue(state, availSchedPtr_) > 0.0) { + if (availSched_->getCurrentVal() > 0.0) { aCPowerIn_ = powerOutFromConverter / efficiency_; calcEfficiency(state), aCPowerIn_ = powerOutFromConverter / efficiency_; @@ -3253,7 +3146,7 @@ ElectricStorage::ElectricStorage( // main constructor EnergyPlusData &state, std::string const &objectName) : storedPower_(0.0), storedEnergy_(0.0), drawnPower_(0.0), drawnEnergy_(0.0), decrementedEnergyStored_(0.0), maxRainflowArrayBounds_(100), - myWarmUpFlag_(false), storageModelMode_(StorageModelType::Invalid), availSchedPtr_(0), heatLossesDestination_(ThermalLossDestination::Invalid), + myWarmUpFlag_(false), storageModelMode_(StorageModelType::Invalid), heatLossesDestination_(ThermalLossDestination::Invalid), zoneNum_(0), zoneRadFract_(0.0), startingEnergyStored_(0.0), energeticEfficCharge_(0.0), energeticEfficDischarge_(0.0), maxPowerDraw_(0.0), maxPowerStore_(0.0), maxEnergyCapacity_(0.0), parallelNum_(0), seriesNum_(0), numBattery_(0), chargeCurveNum_(0), dischargeCurveNum_(0), cycleBinNum_(0), startingSOC_(0.0), maxAhCapacity_(0.0), availableFrac_(0.0), chargeConversionRate_(0.0), chargedOCV_(0.0), dischargedOCV_(0.0), @@ -3268,6 +3161,9 @@ ElectricStorage::ElectricStorage( // main constructor { static constexpr std::string_view routineName = "ElectricStorage constructor "; + + auto &s_ipsc = state.dataIPShortCut; + bool errorsFound = false; // if/when add object class name to input object this can be simplified. for now search all possible types bool foundStorage = false; @@ -3283,7 +3179,7 @@ ElectricStorage::ElectricStorage( // main constructor if (testStorageIndex > 0) { foundStorage = true; storageIDFObjectNum = testStorageIndex; - state.dataIPShortCut->cCurrentModuleObject = item.first; + s_ipsc->cCurrentModuleObject = item.first; storageModelMode_ = item.second; break; } @@ -3294,62 +3190,51 @@ ElectricStorage::ElectricStorage( // main constructor int numNums; // Number of elements in the numeric array int iOStat; // IO Status when calling get input subroutine state.dataInputProcessing->inputProcessor->getObjectItem(state, - state.dataIPShortCut->cCurrentModuleObject, + s_ipsc->cCurrentModuleObject, storageIDFObjectNum, - state.dataIPShortCut->cAlphaArgs, + s_ipsc->cAlphaArgs, numAlphas, - state.dataIPShortCut->rNumericArgs, + s_ipsc->rNumericArgs, numNums, iOStat, - state.dataIPShortCut->lNumericFieldBlanks, - state.dataIPShortCut->lAlphaFieldBlanks, - state.dataIPShortCut->cAlphaFieldNames, - state.dataIPShortCut->cNumericFieldNames); - - name_ = state.dataIPShortCut->cAlphaArgs(1); + s_ipsc->lNumericFieldBlanks, + s_ipsc->lAlphaFieldBlanks, + s_ipsc->cAlphaFieldNames, + s_ipsc->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)}; + + name_ = s_ipsc->cAlphaArgs(1); // how to verify names are unique across objects? add to GlobalNames? - if (state.dataIPShortCut->lAlphaFieldBlanks(2)) { - availSchedPtr_ = ScheduleManager::ScheduleAlwaysOn; - } else { - availSchedPtr_ = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(2)); - if (availSchedPtr_ == 0) { - ShowSevereError( - state, - format( - "{}{}=\"{}\", invalid entry.", routineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("Invalid {} = {}", state.dataIPShortCut->cAlphaFieldNames(2), state.dataIPShortCut->cAlphaArgs(2))); - errorsFound = true; - } + if (s_ipsc->lAlphaFieldBlanks(2)) { + availSched_ = Sched::GetScheduleAlwaysOn(state); + } else if ((availSched_ = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2)); + errorsFound = true; } - zoneNum_ = Util::FindItemInList(state.dataIPShortCut->cAlphaArgs(3), state.dataHeatBal->Zone); - if (zoneNum_ > 0) heatLossesDestination_ = ThermalLossDestination::ZoneGains; - if (zoneNum_ == 0) { - if (state.dataIPShortCut->lAlphaFieldBlanks(3)) { - heatLossesDestination_ = ThermalLossDestination::LostToOutside; - } else { - heatLossesDestination_ = ThermalLossDestination::LostToOutside; - ShowWarningError( - state, - format( - "{}{}=\"{}\", invalid entry.", routineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("Invalid {} = {}", state.dataIPShortCut->cAlphaFieldNames(3), state.dataIPShortCut->cAlphaArgs(3))); - ShowContinueError(state, "Zone name not found. Storage heat losses will not be added to a zone"); - // continue with simulation but storage losses not sent to a zone. - } + if (s_ipsc->lAlphaFieldBlanks(3)) { + heatLossesDestination_ = ThermalLossDestination::LostToOutside; + } else if ((zoneNum_ = Util::FindItemInList(s_ipsc->cAlphaArgs(3), state.dataHeatBal->Zone)) == 0) { + heatLossesDestination_ = ThermalLossDestination::LostToOutside; + ShowWarningItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(3), s_ipsc->cAlphaArgs(3), "Storage heat losses will not be added to a zone"); + // continue with simulation but storage losses not sent to a zone. + } else { + heatLossesDestination_ = ThermalLossDestination::ZoneGains; } - zoneRadFract_ = state.dataIPShortCut->rNumericArgs(1); + + zoneRadFract_ = s_ipsc->rNumericArgs(1); switch (storageModelMode_) { case StorageModelType::SimpleBucketStorage: { - energeticEfficCharge_ = checkUserEfficiencyInput(state, state.dataIPShortCut->rNumericArgs(2), "CHARGING", name_, errorsFound); - energeticEfficDischarge_ = checkUserEfficiencyInput(state, state.dataIPShortCut->rNumericArgs(3), "DISCHARGING", name_, errorsFound); - maxEnergyCapacity_ = state.dataIPShortCut->rNumericArgs(4); - maxPowerDraw_ = state.dataIPShortCut->rNumericArgs(5); - maxPowerStore_ = state.dataIPShortCut->rNumericArgs(6); - startingEnergyStored_ = state.dataIPShortCut->rNumericArgs(7); + energeticEfficCharge_ = checkUserEfficiencyInput(state, s_ipsc->rNumericArgs(2), "CHARGING", name_, errorsFound); + energeticEfficDischarge_ = checkUserEfficiencyInput(state, s_ipsc->rNumericArgs(3), "DISCHARGING", name_, errorsFound); + maxEnergyCapacity_ = s_ipsc->rNumericArgs(4); + maxPowerDraw_ = s_ipsc->rNumericArgs(5); + maxPowerStore_ = s_ipsc->rNumericArgs(6); + startingEnergyStored_ = s_ipsc->rNumericArgs(7); SetupOutputVariable(state, "Electric Storage Simple Charge State", Constant::Units::J, @@ -3361,101 +3246,101 @@ ElectricStorage::ElectricStorage( // main constructor } case StorageModelType::KIBaMBattery: { - chargeCurveNum_ = Curve::GetCurveIndex(state, state.dataIPShortCut->cAlphaArgs(4)); // voltage calculation for charging - if (chargeCurveNum_ == 0 && !state.dataIPShortCut->lAlphaFieldBlanks(4)) { + chargeCurveNum_ = Curve::GetCurveIndex(state, s_ipsc->cAlphaArgs(4)); // voltage calculation for charging + if (chargeCurveNum_ == 0 && !s_ipsc->lAlphaFieldBlanks(4)) { ShowSevereError( state, format( - "{}{}=\"{}\", invalid entry.", routineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("Invalid {}={}", state.dataIPShortCut->cAlphaFieldNames(4), state.dataIPShortCut->cAlphaArgs(4))); + "{}{}=\"{}\", invalid entry.", routineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); + ShowContinueError(state, format("Invalid {}={}", s_ipsc->cAlphaFieldNames(4), s_ipsc->cAlphaArgs(4))); errorsFound = true; - } else if (state.dataIPShortCut->lAlphaFieldBlanks(4)) { + } else if (s_ipsc->lAlphaFieldBlanks(4)) { ShowSevereError( state, format( - "{}{}=\"{}\", invalid entry.", routineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("Invalid {} cannot be blank. But no entry found.", state.dataIPShortCut->cAlphaFieldNames(4))); + "{}{}=\"{}\", invalid entry.", routineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); + ShowContinueError(state, format("Invalid {} cannot be blank. But no entry found.", s_ipsc->cAlphaFieldNames(4))); errorsFound = true; } else { errorsFound |= Curve::CheckCurveDims(state, chargeCurveNum_, // Curve index {1}, // Valid dimensions routineName, // Routine name - state.dataIPShortCut->cCurrentModuleObject, // Object Type + s_ipsc->cCurrentModuleObject, // Object Type name_, // Object Name - state.dataIPShortCut->cAlphaFieldNames(4)); // Field Name + s_ipsc->cAlphaFieldNames(4)); // Field Name } - dischargeCurveNum_ = Curve::GetCurveIndex(state, state.dataIPShortCut->cAlphaArgs(5)); // voltage calculation for discharging - if (dischargeCurveNum_ == 0 && !state.dataIPShortCut->lAlphaFieldBlanks(5)) { + dischargeCurveNum_ = Curve::GetCurveIndex(state, s_ipsc->cAlphaArgs(5)); // voltage calculation for discharging + if (dischargeCurveNum_ == 0 && !s_ipsc->lAlphaFieldBlanks(5)) { ShowSevereError( state, format( - "{}{}=\"{}\", invalid entry.", routineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("Invalid {}={}", state.dataIPShortCut->cAlphaFieldNames(5), state.dataIPShortCut->cAlphaArgs(5))); + "{}{}=\"{}\", invalid entry.", routineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); + ShowContinueError(state, format("Invalid {}={}", s_ipsc->cAlphaFieldNames(5), s_ipsc->cAlphaArgs(5))); errorsFound = true; - } else if (state.dataIPShortCut->lAlphaFieldBlanks(5)) { + } else if (s_ipsc->lAlphaFieldBlanks(5)) { ShowSevereError( state, format( - "{}{}=\"{}\", invalid entry.", routineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("Invalid {} cannot be blank. But no entry found.", state.dataIPShortCut->cAlphaFieldNames(5))); + "{}{}=\"{}\", invalid entry.", routineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); + ShowContinueError(state, format("Invalid {} cannot be blank. But no entry found.", s_ipsc->cAlphaFieldNames(5))); errorsFound = true; } else { errorsFound |= Curve::CheckCurveDims(state, dischargeCurveNum_, // Curve index {1}, // Valid dimensions routineName, // Routine name - state.dataIPShortCut->cCurrentModuleObject, // Object Type + s_ipsc->cCurrentModuleObject, // Object Type name_, // Object Name - state.dataIPShortCut->cAlphaFieldNames(5)); // Field Name + s_ipsc->cAlphaFieldNames(5)); // Field Name } - if (Util::SameString(state.dataIPShortCut->cAlphaArgs(6), "Yes")) { + if (Util::SameString(s_ipsc->cAlphaArgs(6), "Yes")) { lifeCalculation_ = BatteryDegradationModelType::LifeCalculationYes; - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(6), "No")) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(6), "No")) { lifeCalculation_ = BatteryDegradationModelType::LifeCalculationNo; } else { ShowWarningError( state, format( - "{}{}=\"{}\", invalid entry.", routineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("Invalid {} = {}", state.dataIPShortCut->cAlphaFieldNames(6), state.dataIPShortCut->cAlphaArgs(6))); + "{}{}=\"{}\", invalid entry.", routineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); + ShowContinueError(state, format("Invalid {} = {}", s_ipsc->cAlphaFieldNames(6), s_ipsc->cAlphaArgs(6))); ShowContinueError(state, "Yes or No should be selected. Default value No is used to continue simulation"); lifeCalculation_ = BatteryDegradationModelType::LifeCalculationNo; } if (lifeCalculation_ == BatteryDegradationModelType::LifeCalculationYes) { - lifeCurveNum_ = Curve::GetCurveIndex(state, state.dataIPShortCut->cAlphaArgs(7)); // Battery life calculation - if (lifeCurveNum_ == 0 && !state.dataIPShortCut->lAlphaFieldBlanks(7)) { + lifeCurveNum_ = Curve::GetCurveIndex(state, s_ipsc->cAlphaArgs(7)); // Battery life calculation + if (lifeCurveNum_ == 0 && !s_ipsc->lAlphaFieldBlanks(7)) { ShowSevereError(state, format("{}{}=\"{}\", invalid entry.", routineName, - state.dataIPShortCut->cCurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("Invalid {}={}", state.dataIPShortCut->cAlphaFieldNames(7), state.dataIPShortCut->cAlphaArgs(7))); + s_ipsc->cCurrentModuleObject, + s_ipsc->cAlphaArgs(1))); + ShowContinueError(state, format("Invalid {}={}", s_ipsc->cAlphaFieldNames(7), s_ipsc->cAlphaArgs(7))); errorsFound = true; - } else if (state.dataIPShortCut->lAlphaFieldBlanks(7)) { + } else if (s_ipsc->lAlphaFieldBlanks(7)) { ShowSevereError(state, format("{}{}=\"{}\", invalid entry.", routineName, - state.dataIPShortCut->cCurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1))); + s_ipsc->cCurrentModuleObject, + s_ipsc->cAlphaArgs(1))); ShowContinueError(state, format("Invalid {} cannot be blank when {} = Yes. But no entry found.", - state.dataIPShortCut->cAlphaFieldNames(7), - state.dataIPShortCut->cAlphaArgs(6))); + s_ipsc->cAlphaFieldNames(7), + s_ipsc->cAlphaArgs(6))); errorsFound = true; } else { errorsFound |= Curve::CheckCurveDims(state, lifeCurveNum_, // Curve index {1}, // Valid dimensions routineName, // Routine name - state.dataIPShortCut->cCurrentModuleObject, // Object Type + s_ipsc->cCurrentModuleObject, // Object Type name_, // Object Name - state.dataIPShortCut->cAlphaFieldNames(7)); // Field Name + s_ipsc->cAlphaFieldNames(7)); // Field Name } - cycleBinNum_ = state.dataIPShortCut->rNumericArgs(14); + cycleBinNum_ = s_ipsc->rNumericArgs(14); if (!errorsFound) { // life cycle calculation for this battery, allocate arrays for degradation calculation // std::vector is zero base instead of 1, so first index is now 0. @@ -3466,7 +3351,7 @@ ElectricStorage::ElectricStorage( // main constructor } } - parallelNum_ = state.dataIPShortCut->rNumericArgs(2); + parallelNum_ = s_ipsc->rNumericArgs(2); seriesNum_ = state.dataIPShortCut->rNumericArgs(3); numBattery_ = parallelNum_ * seriesNum_; maxAhCapacity_ = state.dataIPShortCut->rNumericArgs(4); @@ -4004,7 +3889,7 @@ void ElectricStorage::simulate(EnergyPlusData &state, Real64 const controlSOCMinFracLimit) { // pass thru to constrain function depending on storage model type - if (ScheduleManager::GetCurrentScheduleValue(state, availSchedPtr_) == 0.0) { // storage not available + if (availSched_->getCurrentVal() == 0.0) { // storage not available discharging = false; powerDischarge = 0.0; charging = false; @@ -4641,7 +4526,7 @@ void ElectricStorage::shift(std::vector &A, int const m, int const n, st // constructor ElectricTransformer::ElectricTransformer(EnergyPlusData &state, std::string const &objectName) - : myOneTimeFlag_(true), availSchedPtr_(0), usageMode_(TransformerUse::Invalid), heatLossesDestination_(ThermalLossDestination::Invalid), + : myOneTimeFlag_(true), usageMode_(TransformerUse::Invalid), heatLossesDestination_(ThermalLossDestination::Invalid), zoneNum_(0), zoneRadFrac_(0.0), ratedCapacity_(0.0), factorTempCoeff_(0.0), tempRise_(0.0), eddyFrac_(0.0), performanceInputMode_(TransformerPerformanceInput::Invalid), ratedEfficiency_(0.0), ratedPUL_(0.0), ratedTemp_(0.0), maxPUL_(0.0), considerLosses_(true), ratedNL_(0.0), ratedLL_(0.0), overloadErrorIndex_(0), efficiency_(0.0), powerIn_(0.0), energyIn_(0.0), powerOut_(0.0), @@ -4649,9 +4534,11 @@ ElectricTransformer::ElectricTransformer(EnergyPlusData &state, std::string cons thermalLossEnergy_(0.0), elecUseMeteredUtilityLosses_(0.0), powerConversionMeteredLosses_(0.0), qdotConvZone_(0.0), qdotRadZone_(0.0) { static constexpr std::string_view routineName = "ElectricTransformer constructor "; + auto &s_ipsc = state.dataIPShortCut; + bool errorsFound = false; int transformerIDFObjectNum = 0; - state.dataIPShortCut->cCurrentModuleObject = "ElectricLoadCenter:Transformer"; + s_ipsc->cCurrentModuleObject = "ElectricLoadCenter:Transformer"; transformerIDFObjectNum = state.dataInputProcessing->inputProcessor->getObjectItemNum(state, "ElectricLoadCenter:Transformer", objectName); if (transformerIDFObjectNum > 0) { @@ -4659,137 +4546,117 @@ ElectricTransformer::ElectricTransformer(EnergyPlusData &state, std::string cons int numNums; // Number of elements in the numeric array int IOStat; // IO Status when calling get input subroutine state.dataInputProcessing->inputProcessor->getObjectItem(state, - state.dataIPShortCut->cCurrentModuleObject, + s_ipsc->cCurrentModuleObject, transformerIDFObjectNum, - state.dataIPShortCut->cAlphaArgs, + s_ipsc->cAlphaArgs, numAlphas, - state.dataIPShortCut->rNumericArgs, + s_ipsc->rNumericArgs, numNums, IOStat, - state.dataIPShortCut->lNumericFieldBlanks, - state.dataIPShortCut->lAlphaFieldBlanks, - state.dataIPShortCut->cAlphaFieldNames, - state.dataIPShortCut->cNumericFieldNames); - name_ = state.dataIPShortCut->cAlphaArgs(1); + s_ipsc->lNumericFieldBlanks, + s_ipsc->lAlphaFieldBlanks, + s_ipsc->cAlphaFieldNames, + s_ipsc->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)}; + name_ = s_ipsc->cAlphaArgs(1); // how to verify names are unique across objects? add to GlobalNames? - if (state.dataIPShortCut->lAlphaFieldBlanks(2)) { - availSchedPtr_ = ScheduleManager::ScheduleAlwaysOn; - } else { - availSchedPtr_ = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(2)); - if (availSchedPtr_ == 0) { - ShowSevereError( - state, - format( - "{}{}=\"{}\", invalid entry.", routineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("Invalid {} = {}", state.dataIPShortCut->cAlphaFieldNames(2), state.dataIPShortCut->cAlphaArgs(2))); - errorsFound = true; - } + if (s_ipsc->lAlphaFieldBlanks(2)) { + availSched_ = Sched::GetScheduleAlwaysOn(state); + } else if ((availSched_ = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2)); + errorsFound = true; } - if (state.dataIPShortCut->lAlphaFieldBlanks(3)) { + if (s_ipsc->lAlphaFieldBlanks(3)) { usageMode_ = TransformerUse::PowerInFromGrid; // default - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(3), "PowerInFromGrid")) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(3), "PowerInFromGrid")) { usageMode_ = TransformerUse::PowerInFromGrid; - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(3), "PowerOutToGrid")) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(3), "PowerOutToGrid")) { usageMode_ = TransformerUse::PowerOutFromBldgToGrid; - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(3), "LoadCenterPowerConditioning")) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(3), "LoadCenterPowerConditioning")) { usageMode_ = TransformerUse::PowerBetweenLoadCenterAndBldg; - } else { - ShowWarningError( - state, - format("{}{}=\"{}\", invalid entry.", routineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("Invalid {} = {}", state.dataIPShortCut->cAlphaFieldNames(3), state.dataIPShortCut->cAlphaArgs(3))); + ShowSevereInvalidKey(state, eoh, s_ipsc->cAlphaFieldNames(3), s_ipsc->cAlphaArgs(3)); errorsFound = true; } - zoneNum_ = Util::FindItemInList(state.dataIPShortCut->cAlphaArgs(4), state.dataHeatBal->Zone); - if (zoneNum_ > 0) heatLossesDestination_ = ThermalLossDestination::ZoneGains; - if (zoneNum_ == 0) { - if (state.dataIPShortCut->lAlphaFieldBlanks(4)) { - heatLossesDestination_ = ThermalLossDestination::LostToOutside; - } else { - heatLossesDestination_ = ThermalLossDestination::LostToOutside; - ShowWarningError( - state, - format( - "{}{}=\"{}\", invalid entry.", routineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("Invalid {} = {}", state.dataIPShortCut->cAlphaFieldNames(4), state.dataIPShortCut->cAlphaArgs(4))); - ShowContinueError(state, "Zone name not found. Transformer heat losses will not be added to a zone"); + if (s_ipsc->lAlphaFieldBlanks(4)) { + heatLossesDestination_ = ThermalLossDestination::LostToOutside; + } else if ((zoneNum_ = Util::FindItemInList(s_ipsc->cAlphaArgs(4), state.dataHeatBal->Zone)) == 0) { + heatLossesDestination_ = ThermalLossDestination::LostToOutside; + ShowWarningItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(4), s_ipsc->cAlphaArgs(4), "Transformer heat losses will not be added to a zone"); // continue with simulation but storage losses not sent to a zone. - } + } else { + heatLossesDestination_ = ThermalLossDestination::ZoneGains; } - zoneRadFrac_ = state.dataIPShortCut->rNumericArgs(1); - ratedCapacity_ = state.dataIPShortCut->rNumericArgs(2); - // unused phase_ = state.dataIPShortCut->rNumericArgs(3); + + zoneRadFrac_ = s_ipsc->rNumericArgs(1); + ratedCapacity_ = s_ipsc->rNumericArgs(2); + // unused phase_ = s_ipsc->rNumericArgs(3); - if (Util::SameString(state.dataIPShortCut->cAlphaArgs(5), "Copper")) { + if (Util::SameString(s_ipsc->cAlphaArgs(5), "Copper")) { factorTempCoeff_ = 234.5; - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(5), "Aluminum")) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(5), "Aluminum")) { factorTempCoeff_ = 225.0; } else { - ShowSevereError( - state, - format("{}{}=\"{}\", invalid entry.", routineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("Invalid {} = {}", state.dataIPShortCut->cAlphaFieldNames(5), state.dataIPShortCut->cAlphaArgs(5))); + ShowSevereInvalidKey(state, eoh, s_ipsc->cAlphaFieldNames(5), s_ipsc->cAlphaArgs(5)); errorsFound = true; } - tempRise_ = state.dataIPShortCut->rNumericArgs(4); - eddyFrac_ = state.dataIPShortCut->rNumericArgs(5); + tempRise_ = s_ipsc->rNumericArgs(4); + eddyFrac_ = s_ipsc->rNumericArgs(5); - if (Util::SameString(state.dataIPShortCut->cAlphaArgs(6), "RatedLosses")) { + if (Util::SameString(s_ipsc->cAlphaArgs(6), "RatedLosses")) { performanceInputMode_ = TransformerPerformanceInput::LossesMethod; - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(6), "NominalEfficiency")) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(6), "NominalEfficiency")) { performanceInputMode_ = TransformerPerformanceInput::EfficiencyMethod; } else { - ShowSevereError( - state, - format("{}{}=\"{}\", invalid entry.", routineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("Invalid {} = {}", state.dataIPShortCut->cAlphaFieldNames(6), state.dataIPShortCut->cAlphaArgs(6))); + ShowSevereInvalidKey(state, eoh, s_ipsc->cAlphaFieldNames(6), s_ipsc->cAlphaArgs(6)); errorsFound = true; } + if (ratedCapacity_ == 0) { if (performanceInputMode_ == TransformerPerformanceInput::LossesMethod) { ShowWarningError( - state, format("{}{}=\"{}\".", routineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("Specified {} = {}", state.dataIPShortCut->cAlphaFieldNames(6), state.dataIPShortCut->cAlphaArgs(6))); - ShowContinueError(state, format("Specified {} = {:.1R}", state.dataIPShortCut->cNumericFieldNames(2), ratedCapacity_)); + state, format("{}{}=\"{}\".", routineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); + ShowContinueError(state, format("Specified {} = {}", s_ipsc->cAlphaFieldNames(6), s_ipsc->cAlphaArgs(6))); + ShowContinueError(state, format("Specified {} = {:.1R}", s_ipsc->cNumericFieldNames(2), ratedCapacity_)); ShowContinueError(state, "Transformer load and no load losses cannot be calculated with 0.0 rated capacity."); ShowContinueError(state, "Simulation continues but transformer losses will be set to zero."); } } - ratedNL_ = state.dataIPShortCut->rNumericArgs(6); - ratedLL_ = state.dataIPShortCut->rNumericArgs(7); - ratedEfficiency_ = state.dataIPShortCut->rNumericArgs(8); - ratedPUL_ = state.dataIPShortCut->rNumericArgs(9); - ratedTemp_ = state.dataIPShortCut->rNumericArgs(10); - maxPUL_ = state.dataIPShortCut->rNumericArgs(11); + ratedNL_ = s_ipsc->rNumericArgs(6); + ratedLL_ = s_ipsc->rNumericArgs(7); + ratedEfficiency_ = s_ipsc->rNumericArgs(8); + ratedPUL_ = s_ipsc->rNumericArgs(9); + ratedTemp_ = s_ipsc->rNumericArgs(10); + maxPUL_ = s_ipsc->rNumericArgs(11); // Check the input for MaxPUL if the performance input method is EfficiencyMethod if (performanceInputMode_ == TransformerPerformanceInput::EfficiencyMethod) { - if (state.dataIPShortCut->lNumericFieldBlanks(11)) { + if (s_ipsc->lNumericFieldBlanks(11)) { maxPUL_ = ratedPUL_; } else if (maxPUL_ <= 0 || maxPUL_ > 1) { ShowSevereError( state, format( - "{}{}=\"{}\", invalid entry.", routineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); + "{}{}=\"{}\", invalid entry.", routineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); ShowContinueError( - state, format("Invalid {}=[{:.3R}].", state.dataIPShortCut->cNumericFieldNames(11), state.dataIPShortCut->rNumericArgs(11))); + state, format("Invalid {}=[{:.3R}].", s_ipsc->cNumericFieldNames(11), s_ipsc->rNumericArgs(11))); ShowContinueError(state, "Entered value must be > 0 and <= 1."); errorsFound = true; } } - if (Util::SameString(state.dataIPShortCut->cAlphaArgs(7), "Yes")) { + if (Util::SameString(s_ipsc->cAlphaArgs(7), "Yes")) { considerLosses_ = true; - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(7), "No")) { + } else if (Util::SameString(s_ipsc->cAlphaArgs(7), "No")) { considerLosses_ = false; } else { if (usageMode_ == TransformerUse::PowerInFromGrid) { ShowSevereError( state, format( - "{}{}=\"{}\", invalid entry.", routineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("Invalid {} = {}", state.dataIPShortCut->cAlphaFieldNames(7), state.dataIPShortCut->cAlphaArgs(7))); + "{}{}=\"{}\", invalid entry.", routineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); + ShowContinueError(state, format("Invalid {} = {}", s_ipsc->cAlphaFieldNames(7), s_ipsc->cAlphaArgs(7))); errorsFound = true; } } @@ -4811,7 +4678,7 @@ ElectricTransformer::ElectricTransformer(EnergyPlusData &state, std::string cons // Meter check deferred because they may have not been "loaded" yet, for (int loopCount = 0; loopCount < numWiredMeters; ++loopCount) { - wiredMeterNames_[loopCount] = Util::makeUPPER(state.dataIPShortCut->cAlphaArgs(loopCount + numAlphaBeforeMeter + 1)); + wiredMeterNames_[loopCount] = Util::makeUPPER(s_ipsc->cAlphaArgs(loopCount + numAlphaBeforeMeter + 1)); // Assign SpecialMeter as TRUE if the meter name is Electricity:Facility or Electricity:HVAC if (Util::SameString(wiredMeterNames_[loopCount], "Electricity:Facility") || Util::SameString(wiredMeterNames_[loopCount], "Electricity:HVAC")) { @@ -5037,7 +4904,7 @@ void ElectricTransformer::manageTransformers(EnergyPlusData &state, Real64 const } // switch usage mode // check availability schedule - if (ratedCapacity_ > 0.0 && ScheduleManager::GetCurrentScheduleValue(state, availSchedPtr_) > 0.0) { + if (ratedCapacity_ > 0.0 && availSched_->getCurrentVal() > 0.0) { Real64 pUL = elecLoad / ratedCapacity_; diff --git a/src/EnergyPlus/ElectricPowerServiceManager.hh b/src/EnergyPlus/ElectricPowerServiceManager.hh index 518c5b33aa3..b8d2331f9d1 100644 --- a/src/EnergyPlus/ElectricPowerServiceManager.hh +++ b/src/EnergyPlus/ElectricPowerServiceManager.hh @@ -172,7 +172,7 @@ private: // data Real64 ancillACuseRate_; Real64 ancillACuseEnergy_; InverterModelType modelType_; // type of inverter model used - int availSchedPtr_; // number for availability schedule. + Sched::Schedule *availSched_ = nullptr; // number for availability schedule. ThermalLossDestination heatLossesDestination_; int zoneNum_; // destination zone for heat losses from inverter. Real64 zoneRadFract_; // radiative fraction for thermal losses to zone @@ -238,7 +238,7 @@ private: // data Real64 qdotRadZone_; Real64 ancillACuseRate_; Real64 ancillACuseEnergy_; - int availSchedPtr_; // number for availability schedule. + Sched::Schedule *availSched_ = nullptr; // number for availability schedule. ConverterModelType modelType_; // type of inverter model used int curveNum_; // performance curve or table index ThermalLossDestination heatLossesDestination_; @@ -371,7 +371,7 @@ private: // data int maxRainflowArrayBounds_; bool myWarmUpFlag_; StorageModelType storageModelMode_; // type of model parameter, SimpleBucketStorage - int availSchedPtr_; // availability schedule index. + Sched::Schedule *availSched_ = nullptr; // availability schedule index. ThermalLossDestination heatLossesDestination_; // mode for where thermal losses go int zoneNum_; // destination zone for heat losses from inverter. Real64 zoneRadFract_; // radiative fraction for thermal losses to zone @@ -495,7 +495,7 @@ private: // data std::string name_; // user identifier bool myOneTimeFlag_; - int availSchedPtr_; // availability schedule index. + Sched::Schedule *availSched_ = nullptr; // availability schedule TransformerUse usageMode_; // mode for transformer usage ThermalLossDestination heatLossesDestination_; // mode for where thermal losses go int zoneNum_; // destination zone for heat losses from inverter. @@ -572,8 +572,7 @@ public: // data // might make this class a friend of El std::string compPlantName; // name of plant component if heat recovery int generatorIndex; // index in generator model data struct Real64 maxPowerOut; // Maximum Power Output (W) - std::string availSched; // Operation Schedule. - int availSchedPtr; // pointer to operation schedule + Sched::Schedule *availSched = nullptr; // pointer to operation schedule Real64 powerRequestThisTimestep; // Current Demand on Equipment (W) bool onThisTimestep; // Indicator whether Generator on Real64 eMSPowerRequest; // EMS actuator for current demand on equipment (W) @@ -696,7 +695,7 @@ private: // data bool generatorsPresent_; // true if any generators bool myCoGenSetupFlag_; Real64 demandLimit_; // Demand Limit in Watts(W) which the generator will operate above - int trackSchedPtr_; // "pointer" to schedule for electrical demand to meet. + Sched::Schedule *trackSched_ = nullptr; // schedule for electrical demand to meet. bool storagePresent_; std::string storageName_; // hold name for verificaton and error messages bool transformerPresent_; // should only be transformers for on-site load center, not facility service @@ -714,10 +713,10 @@ private: // data bool designStorageChargePowerWasSet_; // true if a value was input Real64 designStorageDischargePower_; // rate of electric power exported to grid by being drawn from storage bool designStorageDischargePowerWasSet_; // true if value was input - int storageChargeModSchedIndex_; // index of fraction schedule for controlling charge rate over time - int storageDischargeModSchedIndex_; // index of fraction schedule for controlling discharge rate over time. + Sched::Schedule *storageChargeModSched_ = nullptr; // index of fraction schedule for controlling charge rate over time + Sched::Schedule *storageDischargeModSched_ = nullptr; // index of fraction schedule for controlling discharge rate over time. Real64 facilityDemandTarget_; // target utility demand level in Watts - int facilityDemandTargetModSchedIndex_; // index of fracton schedule for controlling target demand over time. + Sched::Schedule *facilityDemandTargetModSched_ = nullptr; // index of fracton schedule for controlling target demand over time. bool eMSOverridePelFromStorage_; // if true, EMS calling for override Real64 eMSValuePelFromStorage_; // value EMS is directing to use, power from storage [W] bool eMSOverridePelIntoStorage_; // if true, EMS calling for override @@ -828,6 +827,10 @@ struct ElectPwrSvcMgrData : BaseGlobalStruct std::unique_ptr facilityElectricServiceObj; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/EvaporativeCoolers.cc b/src/EnergyPlus/EvaporativeCoolers.cc index ae2801a861e..44fb87a60f6 100644 --- a/src/EnergyPlus/EvaporativeCoolers.cc +++ b/src/EnergyPlus/EvaporativeCoolers.cc @@ -214,6 +214,8 @@ void GetEvapInput(EnergyPlusData &state) // METHODOLOGY EMPLOYED: // Uses the status flags to trigger events. + static constexpr std::string_view routineName = "GetEvapInput"; + // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int NumDirectEvapCool; // The number of Direct CelDek EvapCooler in this simulation int NumDryInDirectEvapCool; // The number of dry indirect evap coolers @@ -264,25 +266,25 @@ void GetEvapInput(EnergyPlusData &state) state.dataIPShortCut->lAlphaFieldBlanks, state.dataIPShortCut->cAlphaFieldNames, state.dataIPShortCut->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1)}; + GlobalNames::VerifyUniqueInterObjectName(state, UniqueEvapCondNames, state.dataIPShortCut->cAlphaArgs(1), cCurrentModuleObject, state.dataIPShortCut->cAlphaFieldNames(1), ErrorsFound); + thisEvapCooler.Name = state.dataIPShortCut->cAlphaArgs(1); thisEvapCooler.evapCoolerType = EvapCoolerType::DirectCELDEKPAD; thisEvapCooler.Schedule = state.dataIPShortCut->cAlphaArgs(2); if (state.dataIPShortCut->lAlphaFieldBlanks(2)) { - thisEvapCooler.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - thisEvapCooler.SchedPtr = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(2)); - if (thisEvapCooler.SchedPtr == 0) { - ShowSevereError(state, format("Invalid {}={}", state.dataIPShortCut->cAlphaFieldNames(2), state.dataIPShortCut->cAlphaArgs(2))); - ShowContinueError(state, format("Entered in {}={}", cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ErrorsFound = true; - } + thisEvapCooler.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((thisEvapCooler.availSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(2), state.dataIPShortCut->cAlphaArgs(2)); + ErrorsFound = true; } thisEvapCooler.InletNode = GetOnlySingleNode(state, @@ -363,6 +365,9 @@ void GetEvapInput(EnergyPlusData &state) state.dataIPShortCut->lAlphaFieldBlanks, state.dataIPShortCut->cAlphaFieldNames, state.dataIPShortCut->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1)}; + GlobalNames::VerifyUniqueInterObjectName(state, UniqueEvapCondNames, state.dataIPShortCut->cAlphaArgs(1), @@ -374,14 +379,10 @@ void GetEvapInput(EnergyPlusData &state) thisEvapCooler.Schedule = state.dataIPShortCut->cAlphaArgs(2); if (state.dataIPShortCut->lAlphaFieldBlanks(2)) { - thisEvapCooler.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - thisEvapCooler.SchedPtr = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(2)); - if (thisEvapCooler.SchedPtr == 0) { - ShowSevereError(state, format("Invalid {}={}", state.dataIPShortCut->cAlphaFieldNames(2), state.dataIPShortCut->cAlphaArgs(2))); - ShowContinueError(state, format("Entered in {}={}", cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ErrorsFound = true; - } + thisEvapCooler.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((thisEvapCooler.availSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(2), state.dataIPShortCut->cAlphaArgs(2)); + ErrorsFound = true; } thisEvapCooler.InletNode = GetOnlySingleNode(state, @@ -494,6 +495,9 @@ void GetEvapInput(EnergyPlusData &state) state.dataIPShortCut->lAlphaFieldBlanks, state.dataIPShortCut->cAlphaFieldNames, state.dataIPShortCut->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1)}; + GlobalNames::VerifyUniqueInterObjectName(state, UniqueEvapCondNames, state.dataIPShortCut->cAlphaArgs(1), @@ -505,14 +509,10 @@ void GetEvapInput(EnergyPlusData &state) thisEvapCooler.Schedule = state.dataIPShortCut->cAlphaArgs(2); if (state.dataIPShortCut->lAlphaFieldBlanks(2)) { - thisEvapCooler.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - thisEvapCooler.SchedPtr = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(2)); - if (thisEvapCooler.SchedPtr == 0) { - ShowSevereError(state, format("Invalid {}={}", state.dataIPShortCut->cAlphaFieldNames(2), state.dataIPShortCut->cAlphaArgs(2))); - ShowContinueError(state, format("Entered in {}={}", cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ErrorsFound = true; - } + thisEvapCooler.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((thisEvapCooler.availSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(2), state.dataIPShortCut->cAlphaArgs(2)); + ErrorsFound = true; } thisEvapCooler.InletNode = GetOnlySingleNode(state, @@ -616,6 +616,8 @@ void GetEvapInput(EnergyPlusData &state) state.dataIPShortCut->lAlphaFieldBlanks, state.dataIPShortCut->cAlphaFieldNames, state.dataIPShortCut->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1)}; GlobalNames::VerifyUniqueInterObjectName(state, UniqueEvapCondNames, state.dataIPShortCut->cAlphaArgs(1), @@ -627,14 +629,10 @@ void GetEvapInput(EnergyPlusData &state) thisEvapCooler.Schedule = state.dataIPShortCut->cAlphaArgs(2); if (state.dataIPShortCut->lAlphaFieldBlanks(2)) { - thisEvapCooler.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - thisEvapCooler.SchedPtr = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(2)); - if (thisEvapCooler.SchedPtr == 0) { - ShowSevereError(state, format("Invalid {}={}", state.dataIPShortCut->cAlphaFieldNames(2), state.dataIPShortCut->cAlphaArgs(2))); - ShowContinueError(state, format("Entered in {}={}", cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ErrorsFound = true; - } + thisEvapCooler.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((thisEvapCooler.availSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(2), state.dataIPShortCut->cAlphaArgs(2)); + ErrorsFound = true; } thisEvapCooler.InletNode = GetOnlySingleNode(state, @@ -818,6 +816,8 @@ void GetEvapInput(EnergyPlusData &state) state.dataIPShortCut->lAlphaFieldBlanks, state.dataIPShortCut->cAlphaFieldNames, state.dataIPShortCut->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1)}; GlobalNames::VerifyUniqueInterObjectName(state, UniqueEvapCondNames, state.dataIPShortCut->cAlphaArgs(1), @@ -829,14 +829,10 @@ void GetEvapInput(EnergyPlusData &state) thisEvapCooler.Schedule = state.dataIPShortCut->cAlphaArgs(2); if (state.dataIPShortCut->lAlphaFieldBlanks(2)) { - thisEvapCooler.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - thisEvapCooler.SchedPtr = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(2)); - if (thisEvapCooler.SchedPtr == 0) { - ShowSevereError(state, format("Invalid {}={}", state.dataIPShortCut->cAlphaFieldNames(2), state.dataIPShortCut->cAlphaArgs(2))); - ShowContinueError(state, format("Entered in {}={}", cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ErrorsFound = true; - } + thisEvapCooler.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((thisEvapCooler.availSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(2), state.dataIPShortCut->cAlphaArgs(2)); + ErrorsFound = true; } thisEvapCooler.InletNode = GetOnlySingleNode(state, @@ -1691,7 +1687,7 @@ void CalcDirectEvapCooler(EnergyPlusData &state, int EvapCoolNum, Real64 const P // If the Evaporative Cooler is operating there should be some mass flow rate // Also the evap cooler has to be scheduled to be available - if ((thisEvapCond.InletMassFlowRate > 0.0) && (ScheduleManager::GetCurrentScheduleValue(state, thisEvapCond.SchedPtr) > 0.0)) { + if ((thisEvapCond.InletMassFlowRate > 0.0) && (thisEvapCond.availSched->getCurrentVal() > 0.0)) { PadDepth = thisEvapCond.PadDepth; //****************************************************************************** @@ -1797,7 +1793,7 @@ void CalcDryIndirectEvapCooler(EnergyPlusData &state, int EvapCoolNum, Real64 co // If the Evaporative Cooler is operating there should be some mass flow rate // Also the evap cooler has to be scheduled to be available - if ((thisEvapCond.InletMassFlowRate > 0.0) && (ScheduleManager::GetCurrentScheduleValue(state, thisEvapCond.SchedPtr) > 0.0)) { + if ((thisEvapCond.InletMassFlowRate > 0.0) && (thisEvapCond.availSched->getCurrentVal() > 0.0)) { PadDepth = thisEvapCond.IndirectPadDepth; //****************************************************************************** @@ -1933,7 +1929,7 @@ void CalcWetIndirectEvapCooler(EnergyPlusData &state, int EvapCoolNum, Real64 co // If the Evaporative Cooler is operating there should be some mass flow rate // Also the evap cooler has to be scheduled to be available - if ((thisEvapCond.InletMassFlowRate > 0.0) && (ScheduleManager::GetCurrentScheduleValue(state, thisEvapCond.SchedPtr) > 0.0)) { + if ((thisEvapCond.InletMassFlowRate > 0.0) && (thisEvapCond.availSched->getCurrentVal() > 0.0)) { //****************************************************************************** // THIS SUBROUTINE WILL CACULATE THE TEMPERATURE OF THE LEAVING AIR DRY BULB @@ -2064,7 +2060,7 @@ void CalcResearchSpecialPartLoad(EnergyPlusData &state, int EvapCoolNum) Real64 PartLoadFrac = 0.0; // If Evap Cooler runs with a cooling load then set PartLoadFrac on Cooling System and the Mass Flow - if ((ScheduleManager::GetCurrentScheduleValue(state, thisEvapCond.SchedPtr) > 0.0) && + if ((thisEvapCond.availSched->getCurrentVal() > 0.0) && (state.dataLoopNodes->Node(InletNode).MassFlowRate > MinAirMassFlow) && (state.dataLoopNodes->Node(InletNode).Temp > state.dataLoopNodes->Node(ControlNode).TempSetPoint) && (std::abs(state.dataLoopNodes->Node(InletNode).Temp - DesOutTemp) > HVAC::TempControlTol)) { @@ -2173,7 +2169,7 @@ void CalcIndirectResearchSpecialEvapCooler(EnergyPlusData &state, int const Evap // If the Evaporative Cooler is operating there should be some mass flow rate // Also the evap cooler has to be scheduled to be available - if ((thisEvapCond.InletMassFlowRate > 0.0) && (ScheduleManager::GetCurrentScheduleValue(state, thisEvapCond.SchedPtr) > 0.0)) { + if ((thisEvapCond.InletMassFlowRate > 0.0) && (thisEvapCond.availSched->getCurrentVal() > 0.0)) { //****************************************************************************** // THIS SUBROUTINE WILL CACULATE THE TEMPERATURE OF THE LEAVING AIR DRY BULB @@ -3092,7 +3088,7 @@ void CalcDirectResearchSpecialEvapCooler(EnergyPlusData &state, int const EvapCo // If the Evaporative Cooler is operating there should be some mass flow rate // Also the evap cooler has to be scheduled to be available - if ((thisEvapCond.InletMassFlowRate > 0.0) && (ScheduleManager::GetCurrentScheduleValue(state, thisEvapCond.SchedPtr) > 0.0) && + if ((thisEvapCond.InletMassFlowRate > 0.0) && (thisEvapCond.availSched->getCurrentVal() > 0.0) && EvapCoolerOperatingLimitFlag) { //*************************************************************************** @@ -3419,15 +3415,10 @@ void GetInputZoneEvaporativeCoolerUnit(EnergyPlusData &state) auto &thisZoneEvapUnit = ZoneEvapUnit(UnitLoop); thisZoneEvapUnit.Name = Alphas(1); if (lAlphaBlanks(2)) { - thisZoneEvapUnit.AvailSchedIndex = ScheduleManager::ScheduleAlwaysOn; - } else { - thisZoneEvapUnit.AvailSchedIndex = ScheduleManager::GetScheduleIndex(state, - Alphas(2)); // convert schedule name to pointer (index number) - if (thisZoneEvapUnit.AvailSchedIndex == 0) { - ShowSevereError(state, format("{}=\"{}\" invalid data.", CurrentModuleObject, thisZoneEvapUnit.Name)); - ShowContinueError(state, format("invalid-not found {}=\"{}\".", cAlphaFields(2), Alphas(2))); - ErrorsFound = true; - } + thisZoneEvapUnit.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((thisZoneEvapUnit.availSched = Sched::GetSchedule(state, Alphas(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(2), Alphas(2)); + ErrorsFound = true; } if (!lAlphaBlanks(3)) { @@ -3481,7 +3472,7 @@ void GetInputZoneEvaporativeCoolerUnit(EnergyPlusData &state) thisZoneEvapUnit.FanInletNodeNum = fan->inletNodeNum; thisZoneEvapUnit.FanOutletNodeNum = fan->outletNodeNum; thisZoneEvapUnit.ActualFanVolFlowRate = fan->maxAirFlowRate; - thisZoneEvapUnit.FanAvailSchedPtr = fan->availSchedNum; + thisZoneEvapUnit.fanAvailSched = fan->availSched; } // set evap unit to cycling mode for all fan types. Note OpMode var is not used @@ -3788,20 +3779,19 @@ void InitZoneEvaporativeCoolerUnit(EnergyPlusData &state, } } - if (zoneEvapUnit.FanAvailSchedPtr > 0) { + if (zoneEvapUnit.fanAvailSched != nullptr) { // include fan is not available, then unit is not available - zoneEvapUnit.UnitIsAvailable = ((ScheduleManager::GetCurrentScheduleValue(state, zoneEvapUnit.FanAvailSchedPtr) > 0.0) && - (ScheduleManager::GetCurrentScheduleValue(state, zoneEvapUnit.AvailSchedIndex) > 0.0)); + zoneEvapUnit.UnitIsAvailable = ((zoneEvapUnit.fanAvailSched->getCurrentVal() > 0.0) && + (zoneEvapUnit.availSched->getCurrentVal() > 0.0)); } else { - zoneEvapUnit.UnitIsAvailable = (ScheduleManager::GetCurrentScheduleValue(state, zoneEvapUnit.AvailSchedIndex) > 0.0); + zoneEvapUnit.UnitIsAvailable = (zoneEvapUnit.availSched->getCurrentVal() > 0.0); } zoneEvapUnit.EvapCooler_1_AvailStatus = - (ScheduleManager::GetCurrentScheduleValue(state, state.dataEvapCoolers->EvapCond(zoneEvapUnit.EvapCooler_1_Index).SchedPtr) > 0.0); + (state.dataEvapCoolers->EvapCond(zoneEvapUnit.EvapCooler_1_Index).availSched->getCurrentVal() > 0.0); if (zoneEvapUnit.EvapCooler_2_Index > 0) { - zoneEvapUnit.EvapCooler_2_AvailStatus = - (ScheduleManager::GetCurrentScheduleValue(state, state.dataEvapCoolers->EvapCond(zoneEvapUnit.EvapCooler_2_Index).SchedPtr) > 0.0); + zoneEvapUnit.EvapCooler_2_AvailStatus = (state.dataEvapCoolers->EvapCond(zoneEvapUnit.EvapCooler_2_Index).availSched->getCurrentVal() > 0.0); } // Do the Begin Environment initializations if (state.dataGlobal->BeginEnvrnFlag && zoneEvapUnit.MyEnvrn) { @@ -4022,8 +4012,10 @@ void CalcZoneEvaporativeCoolerUnit(EnergyPlusData &state, if (zoneEvapUnit.ControlSchemeType == ControlType::ZoneTemperatureDeadBandOnOffCycling) { ZoneTemp = state.dataLoopNodes->Node(zoneEvapUnit.ZoneNodeNum).Temp; - CoolSetLowThrottle = state.dataHeatBalFanSys->ZoneThermostatSetPointHi(ZoneNum) - (0.5 * zoneEvapUnit.ThrottlingRange); - CoolSetHiThrottle = state.dataHeatBalFanSys->ZoneThermostatSetPointHi(ZoneNum) + (0.5 * zoneEvapUnit.ThrottlingRange); + + auto const &zoneTstatSetpt = state.dataHeatBalFanSys->zoneTstatSetpts(ZoneNum); + CoolSetLowThrottle = zoneTstatSetpt.setptHi - (0.5 * zoneEvapUnit.ThrottlingRange); + CoolSetHiThrottle = zoneTstatSetpt.setptHi + (0.5 * zoneEvapUnit.ThrottlingRange); if ((ZoneTemp < CoolSetLowThrottle) || !zoneEvapUnit.UnitIsAvailable) { zoneEvapUnit.IsOnThisTimestep = false; diff --git a/src/EnergyPlus/EvaporativeCoolers.hh b/src/EnergyPlus/EvaporativeCoolers.hh index 9b72aa49005..4920cef5dec 100644 --- a/src/EnergyPlus/EvaporativeCoolers.hh +++ b/src/EnergyPlus/EvaporativeCoolers.hh @@ -113,7 +113,7 @@ namespace EvaporativeCoolers { EvapCoolerType evapCoolerType; // Type of the EvapCooler std::string EvapControlType; // Type of Control for the EvapCooler std::string Schedule; // HeatingCoil Operation Schedule - int SchedPtr; // Pointer to the correct schedule + Sched::Schedule *availSched = nullptr; // Pointer to the correct schedule Real64 VolFlowRate; // Volume Flow Rate in Evap Cooler needed for calculating SatEff Real64 DesVolFlowRate; // Design volume flow rate (autosize or user input) - this is only used to compute design pump power Real64 OutletTemp; @@ -209,7 +209,7 @@ namespace EvaporativeCoolers { // Default Constructor EvapConditions() - : EquipIndex(0), evapCoolerType(EvapCoolerType::Invalid), SchedPtr(0), VolFlowRate(0.0), DesVolFlowRate(0.0), OutletTemp(0.0), + : EquipIndex(0), evapCoolerType(EvapCoolerType::Invalid), VolFlowRate(0.0), DesVolFlowRate(0.0), OutletTemp(0.0), OuletWetBulbTemp(0.0), OutletHumRat(0.0), OutletEnthalpy(0.0), OutletPressure(0.0), OutletMassFlowRate(0.0), OutletMassFlowRateMaxAvail(0.0), OutletMassFlowRateMinAvail(0.0), InitFlag(false), InletNode(0), OutletNode(0), SecondaryInletNode(0), SecondaryOutletNode(0), TertiaryInletNode(0), InletMassFlowRate(0.0), InletMassFlowRateMaxAvail(0.0), InletMassFlowRateMinAvail(0.0), @@ -236,7 +236,7 @@ namespace EvaporativeCoolers { { std::string Name; // user identifier int ZoneNodeNum; - int AvailSchedIndex; // pointer to local availability schedule + Sched::Schedule *availSched = nullptr; // local availability schedule std::string AvailManagerListName; // Name of an availability manager list object bool UnitIsAvailable; Avail::Status FanAvailStatus = Avail::Status::NoAction; @@ -247,7 +247,7 @@ namespace EvaporativeCoolers { std::string FanName; int FanIndex; Real64 ActualFanVolFlowRate; - int FanAvailSchedPtr; + Sched::Schedule *fanAvailSched = nullptr; int FanInletNodeNum; int FanOutletNodeNum; HVAC::FanOp fanOp = HVAC::FanOp::Invalid; @@ -307,8 +307,8 @@ namespace EvaporativeCoolers { // Default Constructor ZoneEvapCoolerUnitStruct() - : ZoneNodeNum(0), AvailSchedIndex(0), UnitIsAvailable(false), OAInletNodeNum(0), UnitOutletNodeNum(0), UnitReliefNodeNum(0), - fanType(HVAC::FanType::Invalid), FanIndex(0), ActualFanVolFlowRate(0.0), FanAvailSchedPtr(0), FanInletNodeNum(0), FanOutletNodeNum(0), + : ZoneNodeNum(0), UnitIsAvailable(false), OAInletNodeNum(0), UnitOutletNodeNum(0), UnitReliefNodeNum(0), + fanType(HVAC::FanType::Invalid), FanIndex(0), ActualFanVolFlowRate(0.0), FanInletNodeNum(0), FanOutletNodeNum(0), DesignAirVolumeFlowRate(0.0), DesignAirMassFlowRate(0.0), DesignFanSpeedRatio(0.0), FanSpeedRatio(0.0), fanPlace(HVAC::FanPlace::Invalid), ControlSchemeType(ControlType::Invalid), TimeElapsed(0.0), ThrottlingRange(0.0), IsOnThisTimestep(false), WasOnLastTimestep(false), ThresholdCoolingLoad(0.0), EvapCooler_1_Type_Num(EvapCoolerType::Invalid), @@ -450,6 +450,10 @@ struct EvaporativeCoolersData : BaseGlobalStruct bool MySetPointCheckFlag = true; bool ZoneEquipmentListChecked = false; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/EvaporativeFluidCoolers.cc b/src/EnergyPlus/EvaporativeFluidCoolers.cc index 3e170a3c51e..36ce9e1981a 100644 --- a/src/EnergyPlus/EvaporativeFluidCoolers.cc +++ b/src/EnergyPlus/EvaporativeFluidCoolers.cc @@ -142,6 +142,8 @@ namespace EvaporativeFluidCoolers { // B.A. Qureshi and S.M. Zubair , Prediction of evaporation losses in evaporative fluid coolers // Applied thermal engineering 27 (2007) 520-527 + static constexpr std::string_view routineName = "GetEvapFluidCoolerInput"; + int NumAlphas; // Number of elements in the alpha array int NumNums; // Number of elements in the numeric array int IOStat; // IO Status when calling get input subroutine @@ -181,6 +183,9 @@ namespace EvaporativeFluidCoolers { state.dataIPShortCut->lAlphaFieldBlanks, state.dataIPShortCut->cAlphaFieldNames, state.dataIPShortCut->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, state.dataIPShortCut->cCurrentModuleObject, AlphArray(1)}; + GlobalNames::VerifyUniqueInterObjectName(state, state.dataEvapFluidCoolers->UniqueSimpleEvapFluidCoolerNames, AlphArray(1), @@ -335,11 +340,11 @@ namespace EvaporativeFluidCoolers { } } - thisEFC.SchedIDBlowdown = ScheduleManager::GetScheduleIndex(state, AlphArray(9)); - if ((thisEFC.SchedIDBlowdown == 0) && (thisEFC.BlowdownMode == Blowdown::BySchedule)) { - ShowSevereError(state, format("Invalid, {} = {}", state.dataIPShortCut->cAlphaFieldNames(9), AlphArray(9))); - ShowContinueError(state, format("Entered in {} ={}", state.dataIPShortCut->cCurrentModuleObject, AlphArray(1))); - ErrorsFound = true; + if (thisEFC.BlowdownMode == Blowdown::BySchedule) { + if ((thisEFC.blowdownSched = Sched::GetSchedule(state, AlphArray(9))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(9), AlphArray(9)); + ErrorsFound = true; + } } if (AlphArray(10).empty()) { @@ -518,6 +523,8 @@ namespace EvaporativeFluidCoolers { state.dataIPShortCut->cAlphaFieldNames, state.dataIPShortCut->cNumericFieldNames); + ErrorObjectHeader eoh{routineName, state.dataIPShortCut->cCurrentModuleObject, AlphArray(1)}; + GlobalNames::VerifyUniqueInterObjectName(state, state.dataEvapFluidCoolers->UniqueSimpleEvapFluidCoolerNames, AlphArray(1), @@ -675,11 +682,11 @@ namespace EvaporativeFluidCoolers { } } - thisEFC.SchedIDBlowdown = ScheduleManager::GetScheduleIndex(state, AlphArray(8)); - if ((thisEFC.SchedIDBlowdown == 0) && (thisEFC.BlowdownMode == Blowdown::BySchedule)) { - ShowSevereError(state, format("Invalid {} = {}", state.dataIPShortCut->cAlphaFieldNames(8), AlphArray(8))); - ShowContinueError(state, format("Entered in {} = {}", state.dataIPShortCut->cCurrentModuleObject, AlphArray(1))); - ErrorsFound = true; + if (thisEFC.BlowdownMode == Blowdown::BySchedule) { + if ((thisEFC.blowdownSched = Sched::GetSchedule(state, AlphArray(8))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(8), AlphArray(8)); + ErrorsFound = true; + } } if (state.dataIPShortCut->lAlphaFieldBlanks(9)) { @@ -2584,11 +2591,7 @@ namespace EvaporativeFluidCoolers { if (this->BlowdownMode == Blowdown::BySchedule) { // Amount of water lost due to blow down (purging contaminants from evaporative fluid cooler basin) - if (this->SchedIDBlowdown > 0) { - this->BlowdownVdot = ScheduleManager::GetCurrentScheduleValue(state, this->SchedIDBlowdown); - } else { - this->BlowdownVdot = 0.0; - } + this->BlowdownVdot = (this->blowdownSched != nullptr) ? this->blowdownSched->getCurrentVal() : 0.0; } else if (this->BlowdownMode == Blowdown::ByConcentration) { if (this->ConcentrationRatio > 2.0) { // protect divide by zero this->BlowdownVdot = this->EvaporationVdot / (this->ConcentrationRatio - 1) - this->DriftVdot; diff --git a/src/EnergyPlus/EvaporativeFluidCoolers.hh b/src/EnergyPlus/EvaporativeFluidCoolers.hh index 56e262a19d8..849e5801137 100644 --- a/src/EnergyPlus/EvaporativeFluidCoolers.hh +++ b/src/EnergyPlus/EvaporativeFluidCoolers.hh @@ -171,7 +171,7 @@ namespace EvaporativeFluidCoolers { // begin water system interactions EvapLoss EvapLossMode = EvapLoss::ByMoistTheory; // sets how evaporative fluid cooler water evaporation is modeled Blowdown BlowdownMode = Blowdown::ByConcentration; // sets how evaporative fluid cooler water blowdown is modeled - int SchedIDBlowdown = 0; // index "pointer" to schedule of blowdown in [m3/s] + Sched::Schedule *blowdownSched = nullptr; // schedule of blowdown in [m3/s] int WaterTankID = 0; // index "pointer" to WaterStorage structure int WaterTankDemandARRID = 0; // index "pointer" to demand array inside WaterStorage structure Real64 UserEvapLossFactor = 0.0; // simple model [%/Delt C] @@ -258,6 +258,10 @@ struct EvaporativeFluidCoolersData : BaseGlobalStruct Array1D SimpleEvapFluidCooler; // dimension to number of machines std::unordered_map UniqueSimpleEvapFluidCoolerNames; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/ExhaustAirSystemManager.cc b/src/EnergyPlus/ExhaustAirSystemManager.cc index 0e90d5918b4..374fad2430c 100644 --- a/src/EnergyPlus/ExhaustAirSystemManager.cc +++ b/src/EnergyPlus/ExhaustAirSystemManager.cc @@ -174,7 +174,7 @@ namespace ExhaustAirSystemManager { } else { auto *fan = state.dataFans->fans(centralFanIndex); - thisExhSys.AvailScheduleNum = fan->availSchedNum; + thisExhSys.availSched = fan->availSched; BranchNodeConnections::SetUpCompSets(state, cCurrentModuleObject, @@ -362,6 +362,8 @@ namespace ExhaustAirSystemManager { // Use the json helper to process input constexpr std::string_view RoutineName("GetZoneExhaustControlInput: "); + constexpr std::string_view routineName = "GetZoneExhaustControlInput"; + std::string const cCurrentModuleObject = "ZoneHVAC:ExhaustControl"; auto &ip = state.dataInputProcessing->inputProcessor; auto const instances = ip->epJSON.find(cCurrentModuleObject); @@ -381,22 +383,20 @@ namespace ExhaustAirSystemManager { ++exhCtrlNum; auto const &objectFields = instance.value(); auto &thisExhCtrl = state.dataZoneEquip->ZoneExhaustControlSystem(exhCtrlNum); + + ErrorObjectHeader eoh{routineName, cCurrentModuleObject, instance.key()}; + thisExhCtrl.Name = Util::makeUPPER(instance.key()); ip->markObjectAsUsed(cCurrentModuleObject, instance.key()); std::string availSchName = ip->getAlphaFieldValue(objectFields, objectSchemaProps, "availability_schedule_name"); - if (availSchName == "") { + if (availSchName.empty()) { // blank - thisExhCtrl.AvailScheduleNum = ScheduleManager::ScheduleAlwaysOn; - } else { - thisExhCtrl.AvailScheduleNum = ScheduleManager::GetScheduleIndex(state, availSchName); - if (thisExhCtrl.AvailScheduleNum == 0) { - // mismatch, reset to always on - thisExhCtrl.AvailScheduleNum = ScheduleManager::ScheduleAlwaysOn; - ShowWarningError(state, format("{}{}={}", RoutineName, cCurrentModuleObject, thisExhCtrl.Name)); - ShowContinueError(state, format("Avaiability Schedule Name = {} not found.", availSchName)); - ShowContinueError(state, "Availability Schedule is reset to Always ON."); - } + thisExhCtrl.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((thisExhCtrl.availSched = Sched::GetSchedule(state, availSchName)) == nullptr) { + // mismatch, reset to always on + thisExhCtrl.availSched = Sched::GetScheduleAlwaysOn(state); + ShowWarningItemNotFound(state, eoh, "Avaiability Schedule Name", availSchName, "Availability Schedule is reset to Always ON."); } std::string zoneName = ip->getAlphaFieldValue(objectFields, objectSchemaProps, "zone_name"); @@ -444,23 +444,14 @@ namespace ExhaustAirSystemManager { thisExhCtrl.FlowControlOption = static_cast(getEnumValue(flowControlTypeNamesUC, flowControlTypeName)); - std::string exhaustFlowFractionScheduleName = + std::string exhaustFlowFractionSchedName = ip->getAlphaFieldValue(objectFields, objectSchemaProps, "exhaust_flow_fraction_schedule_name"); - // Schedule matching - int exhaustFlowFractionScheduleNum = 0; - exhaustFlowFractionScheduleNum = ScheduleManager::GetScheduleIndex(state, exhaustFlowFractionScheduleName); - - if (exhaustFlowFractionScheduleNum > 0) { - // normal conditions - } else if (exhaustFlowFractionScheduleNum == 0) { - // blank, treat as always available - } else { - exhaustFlowFractionScheduleNum = 0; - // a regular warning - ShowWarningError(state, format("{}{}={}", RoutineName, cCurrentModuleObject, thisExhCtrl.Name)); - ShowContinueError(state, format("Schedule Name = {} not found.", exhaustFlowFractionScheduleName)); + + if (exhaustFlowFractionSchedName.empty()) { + thisExhCtrl.exhaustFlowFractionSched = Sched::GetScheduleAlwaysOn(state); + } else if ((thisExhCtrl.exhaustFlowFractionSched = Sched::GetSchedule(state, exhaustFlowFractionSchedName)) == nullptr) { + ShowSevereItemNotFound(state, eoh, "Exhaust Flow Fraction Schedule Name", exhaustFlowFractionSchedName); } - thisExhCtrl.ExhaustFlowFractionScheduleNum = exhaustFlowFractionScheduleNum; thisExhCtrl.SupplyNodeOrNodelistName = ip->getAlphaFieldValue(objectFields, objectSchemaProps, "supply_node_or_nodelist_name"); @@ -501,72 +492,39 @@ namespace ExhaustAirSystemManager { SizeExhaustControlFlow(state, exhCtrlNum, thisExhCtrl.SuppNodeNums); } - std::string minZoneTempLimitScheduleName = + std::string minZoneTempLimitSchedName = ip->getAlphaFieldValue(objectFields, objectSchemaProps, "minimum_zone_temperature_limit_schedule_name"); - int minZoneTempLimitScheduleNum = 0; - minZoneTempLimitScheduleNum = ScheduleManager::GetScheduleIndex(state, minZoneTempLimitScheduleName); - - if (minZoneTempLimitScheduleNum > 0) { - // normal conditions - } else if (minZoneTempLimitScheduleNum == 0) { - // blank or anything like that, treat as no comparision - } else { - minZoneTempLimitScheduleNum = 0; - // a regular warning - ShowWarningError(state, format("{}{}={}", RoutineName, cCurrentModuleObject, thisExhCtrl.Name)); - ShowContinueError(state, format("Schedule Name ={} not found.", minZoneTempLimitScheduleName)); + if (minZoneTempLimitSchedName.empty()) { + } else if ((thisExhCtrl.minZoneTempLimitSched = Sched::GetSchedule(state, minZoneTempLimitSchedName)) == nullptr) { + ShowSevereItemNotFound(state, eoh, "Minimum Zone Temperature Limit Schedule Name", minZoneTempLimitSchedName); } - thisExhCtrl.MinZoneTempLimitScheduleNum = minZoneTempLimitScheduleNum; - std::string minExhFlowFracScheduleName = + std::string minExhFlowFracSchedName = ip->getAlphaFieldValue(objectFields, objectSchemaProps, "minimum_exhaust_flow_fraction_schedule_name"); // to do so schedule matching - int minExhFlowFracScheduleNum = 0; - minExhFlowFracScheduleNum = ScheduleManager::GetScheduleIndex(state, minExhFlowFracScheduleName); - - if (minExhFlowFracScheduleNum > 0) { - // normal conditions - } else if (minExhFlowFracScheduleNum == 0) { - // blank, meaning minimum is zero - } else { - minExhFlowFracScheduleNum = 0; - // a regular warning - ShowWarningError(state, format("{}{}={}", RoutineName, cCurrentModuleObject, thisExhCtrl.Name)); - ShowContinueError(state, format("Schedule Name ={} not found.", minExhFlowFracScheduleName)); + if (minExhFlowFracSchedName.empty()) { + } else if ((thisExhCtrl.minExhFlowFracSched = Sched::GetSchedule(state, minExhFlowFracSchedName)) == nullptr) { + ShowSevereItemNotFound(state, eoh, "Minimum Exhaust Flow Fraction Schedule Name", minExhFlowFracSchedName); } - thisExhCtrl.MinExhFlowFracScheduleNum = minExhFlowFracScheduleNum; - std::string balancedExhFracScheduleName = + std::string balancedExhFracSchedName = ip->getAlphaFieldValue(objectFields, objectSchemaProps, "balanced_exhaust_fraction_schedule_name"); // to do so schedule matching - int balancedExhFracScheduleNum = 0; - balancedExhFracScheduleNum = ScheduleManager::GetScheduleIndex(state, balancedExhFracScheduleName); - - if (balancedExhFracScheduleNum > 0) { - // normal conditions - } else if (balancedExhFracScheduleNum == 0) { - // blank, treated as not activated - } else { - balancedExhFracScheduleNum = 0; - // a regular warning - ShowWarningError(state, format("{}{}={}", RoutineName, cCurrentModuleObject, thisExhCtrl.Name)); - ShowContinueError(state, format("Schedule Name ={} not found.", balancedExhFracScheduleName)); + if (balancedExhFracSchedName.empty()) { + } else if ((thisExhCtrl.balancedExhFracSched = Sched::GetSchedule(state, balancedExhFracSchedName)) == nullptr) { + ShowSevereItemNotFound(state, eoh, "Balanced Exhaust Fraction Schedule Name", balancedExhFracSchedName); } // Maybe an additional check per IORef: // This input field must be blank when the zone air flow balance is enforced. If user specifies a schedule and zone air flow balance // is enforced, then EnergyPlus throws a warning error message, ignores the schedule and simulation continues. - - thisExhCtrl.BalancedExhFracScheduleNum = balancedExhFracScheduleNum; } state.dataZoneEquip->NumZoneExhaustControls = numZoneExhaustControls; // or exhCtrlNum // Done with creating a map that contains a table of for each zone to exhasut controls state.dataExhAirSystemMrg->mappingDone = true; - } else { - // If no exhaust systems are defined, then do something : - } + } if (ErrorsFound) { ShowFatalError(state, "Errors found getting ZoneHVAC:ExhaustControl. Preceding condition(s) causes termination."); @@ -599,7 +557,7 @@ namespace ExhaustAirSystemManager { auto &thisExhOutlet = state.dataLoopNodes->Node(OutletNode); Real64 MassFlow; Real64 Tin = state.dataZoneTempPredictorCorrector->zoneHeatBalance(thisExhCtrl.ZoneNum).ZT; - Real64 thisExhCtrlAvailScheVal = ScheduleManager::GetCurrentScheduleValue(state, thisExhCtrl.AvailScheduleNum); + Real64 thisExhCtrlAvailScheVal = thisExhCtrl.availSched->getCurrentVal(); if (FlowRatio >= 0.0) { thisExhCtrl.BalancedFlow *= FlowRatio; @@ -617,8 +575,8 @@ namespace ExhaustAirSystemManager { Real64 DesignFlowRate = thisExhCtrl.DesignExhaustFlowRate; Real64 FlowFrac = 0.0; - if (thisExhCtrl.MinExhFlowFracScheduleNum > 0) { - FlowFrac = ScheduleManager::GetCurrentScheduleValue(state, thisExhCtrl.ExhaustFlowFractionScheduleNum); + if (thisExhCtrl.minExhFlowFracSched != nullptr) { + FlowFrac = thisExhCtrl.exhaustFlowFractionSched->getCurrentVal(); if (FlowFrac < 0.0) { ShowWarningError( state, format("Exhaust Flow Fraction Schedule value is negative for Zone Exhaust Control Named: {};", thisExhCtrl.Name)); @@ -628,8 +586,8 @@ namespace ExhaustAirSystemManager { } Real64 MinFlowFrac = 0.0; - if (thisExhCtrl.MinExhFlowFracScheduleNum > 0) { - MinFlowFrac = ScheduleManager::GetCurrentScheduleValue(state, thisExhCtrl.MinExhFlowFracScheduleNum); + if (thisExhCtrl.minExhFlowFracSched != nullptr) { + MinFlowFrac = thisExhCtrl.minExhFlowFracSched->getCurrentVal(); if (MinFlowFrac < 0.0) { ShowWarningError( state, @@ -644,8 +602,8 @@ namespace ExhaustAirSystemManager { } if (thisExhCtrlAvailScheVal > 0.0) { // available - if (thisExhCtrl.MinZoneTempLimitScheduleNum > 0) { - if (Tin >= ScheduleManager::GetCurrentScheduleValue(state, thisExhCtrl.MinZoneTempLimitScheduleNum)) { + if (thisExhCtrl.minZoneTempLimitSched != nullptr) { + if (Tin >= thisExhCtrl.minZoneTempLimitSched->getCurrentVal()) { } else { FlowFrac = MinFlowFrac; } @@ -667,10 +625,10 @@ namespace ExhaustAirSystemManager { MassFlow = DesignFlowRate * FlowFrac; } - if (thisExhCtrl.BalancedExhFracScheduleNum > 0) { + if (thisExhCtrl.balancedExhFracSched != nullptr) { thisExhCtrl.BalancedFlow = // state.dataHVACGlobal->BalancedExhMassFlow = MassFlow * // state.dataHVACGlobal->UnbalExhMassFlow * - ScheduleManager::GetCurrentScheduleValue(state, thisExhCtrl.BalancedExhFracScheduleNum); + thisExhCtrl.balancedExhFracSched->getCurrentVal(); thisExhCtrl.UnbalancedFlow = // state.dataHVACGlobal->UnbalExhMassFlow = MassFlow - // = state.dataHVACGlobal->UnbalExhMassFlow - thisExhCtrl.BalancedFlow; // state.dataHVACGlobal->BalancedExhMassFlow; diff --git a/src/EnergyPlus/ExhaustAirSystemManager.hh b/src/EnergyPlus/ExhaustAirSystemManager.hh index 4c61d5d8958..0d2d09705a7 100644 --- a/src/EnergyPlus/ExhaustAirSystemManager.hh +++ b/src/EnergyPlus/ExhaustAirSystemManager.hh @@ -66,7 +66,7 @@ namespace ExhaustAirSystemManager { // Members std::string Name = ""; - int AvailScheduleNum = ScheduleManager::ScheduleAlwaysOn; + Sched::Schedule *availSched = nullptr; std::string ZoneMixerName = ""; int ZoneMixerIndex = 0; HVAC::FanType centralFanType = HVAC::FanType::Invalid; @@ -98,7 +98,7 @@ namespace ExhaustAirSystemManager { std::string Name = ""; - int AvailScheduleNum = ScheduleManager::ScheduleAlwaysOn; + Sched::Schedule *availSched = nullptr; std::string ZoneName = ""; int ZoneNum = 0; @@ -109,12 +109,12 @@ namespace ExhaustAirSystemManager { Real64 DesignExhaustFlowRate = 0.0; FlowControlType FlowControlOption = FlowControlType::Scheduled; - int ExhaustFlowFractionScheduleNum = 0; + Sched::Schedule *exhaustFlowFractionSched = nullptr; std::string SupplyNodeOrNodelistName = ""; int SupplyNodeOrNodelistNum = 0; // may not need this one - int MinZoneTempLimitScheduleNum = 0; - int MinExhFlowFracScheduleNum = 0; - int BalancedExhFracScheduleNum = 0; + Sched::Schedule *minZoneTempLimitSched = nullptr; + Sched::Schedule *minExhFlowFracSched = nullptr; + Sched::Schedule *balancedExhFracSched = nullptr; Real64 BalancedFlow = 0.0; Real64 UnbalancedFlow = 0.0; @@ -150,6 +150,10 @@ struct ExhaustAirSystemMgr : BaseGlobalStruct std::map mixerIndexMap; bool mappingDone = false; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } @@ -165,6 +169,10 @@ struct ExhaustControlSystemMgr : BaseGlobalStruct bool GetInputFlag = true; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/ExteriorEnergyUse.cc b/src/EnergyPlus/ExteriorEnergyUse.cc index 64eede6d095..10584ab7b12 100644 --- a/src/EnergyPlus/ExteriorEnergyUse.cc +++ b/src/EnergyPlus/ExteriorEnergyUse.cc @@ -107,11 +107,6 @@ namespace ExteriorEnergyUse { // This subroutine gets the input for the Exterior Lights and Equipment. // Using/Aliasing - - using ScheduleManager::GetScheduleIndex; - using ScheduleManager::GetScheduleMaxValue; - using ScheduleManager::GetScheduleMinValue; - using ScheduleManager::GetScheduleName; using namespace OutputReportPredefined; // SUBROUTINE PARAMETER DEFINITIONS: std::string_view constexpr routineName = "GetExteriorEnergyUseInput"; @@ -122,10 +117,8 @@ namespace ExteriorEnergyUse { int IOStatus; // Used in GetObjectItem bool ErrorsFound(false); // Set to true if errors in input, fatal at end of routine std::string EndUseSubcategoryName; - Real64 SchMax; // Max value of schedule for item - Real64 SchMin; // Min value of schedule for item - auto &ipsc = state.dataIPShortCut; + auto &s_ipsc = state.dataIPShortCut; state.dataExteriorEnergyUse->NumExteriorLights = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Exterior:Lights"); state.dataExteriorEnergyUse->ExteriorLights.allocate(state.dataExteriorEnergyUse->NumExteriorLights); @@ -144,81 +137,40 @@ namespace ExteriorEnergyUse { state.dataInputProcessing->inputProcessor->getObjectItem(state, cCurrentModuleObject, Item, - ipsc->cAlphaArgs, + s_ipsc->cAlphaArgs, NumAlphas, - ipsc->rNumericArgs, + s_ipsc->rNumericArgs, NumNumbers, IOStatus, - ipsc->lNumericFieldBlanks, - ipsc->lAlphaFieldBlanks, - ipsc->cAlphaFieldNames, - ipsc->cNumericFieldNames); - - state.dataExteriorEnergyUse->ExteriorLights(Item).Name = ipsc->cAlphaArgs(1); - state.dataExteriorEnergyUse->ExteriorLights(Item).SchedPtr = GetScheduleIndex(state, ipsc->cAlphaArgs(2)); - if (state.dataExteriorEnergyUse->ExteriorLights(Item).SchedPtr == 0) { - if (ipsc->lAlphaFieldBlanks(2)) { - ShowSevereError(state, - format("{}: {}: {} is required, missing for {}={}", - routineName, - cCurrentModuleObject, - ipsc->cAlphaFieldNames(2), - ipsc->cAlphaFieldNames(1), - ipsc->cAlphaArgs(1))); - } else { - ShowSevereError(state, - format("{}: {}: invalid {} entered={} for {}={}", - routineName, - cCurrentModuleObject, - ipsc->cAlphaFieldNames(2), - ipsc->cAlphaArgs(2), - ipsc->cAlphaFieldNames(1), - ipsc->cAlphaArgs(1))); - } + s_ipsc->lNumericFieldBlanks, + s_ipsc->lAlphaFieldBlanks, + s_ipsc->cAlphaFieldNames, + s_ipsc->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, cCurrentModuleObject, s_ipsc->cAlphaArgs(1)}; + + state.dataExteriorEnergyUse->ExteriorLights(Item).Name = s_ipsc->cAlphaArgs(1); + + if (s_ipsc->lAlphaFieldBlanks(2)) { + ShowSevereEmptyField(state, eoh, s_ipsc->cAlphaFieldNames(2)); + ErrorsFound = true; + } else if ((state.dataExteriorEnergyUse->ExteriorLights(Item).sched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2)); + ErrorsFound = true; + } else if (int SchMin = state.dataExteriorEnergyUse->ExteriorLights(Item).sched->getMinVal(state); SchMin < 0.0) { + ShowSevereCustom(state, eoh, format("{} = {} minimum is [{:.1R}]. Values must be >= 0.0.", + s_ipsc->cAlphaFieldNames(3), s_ipsc->cAlphaArgs(3), SchMin)); ErrorsFound = true; - } else { // check min/max on schedule - SchMin = GetScheduleMinValue(state, state.dataExteriorEnergyUse->ExteriorLights(Item).SchedPtr); - SchMax = GetScheduleMaxValue(state, state.dataExteriorEnergyUse->ExteriorLights(Item).SchedPtr); - if (SchMin < 0.0 || SchMax < 0.0) { - if (SchMin < 0.0) { - ShowSevereError(state, - format("{}: {}: invalid {} minimum, is < 0.0 for {}={}", - routineName, - cCurrentModuleObject, - ipsc->cAlphaFieldNames(2), - ipsc->cAlphaFieldNames(1), - ipsc->cAlphaArgs(1))); - ShowContinueError(state, format("{}\". Minimum is [{:.1R}]. Values must be >= 0.0.", ipsc->cAlphaArgs(2), SchMin)); - ErrorsFound = true; - } - if (SchMax < 0.0) { - ShowSevereError(state, - format("{}: {}: invalid {} maximum, is < 0.0 for {}={}", - routineName, - cCurrentModuleObject, - ipsc->cAlphaFieldNames(2), - ipsc->cAlphaFieldNames(1), - ipsc->cAlphaArgs(1))); - ShowContinueError(state, format("{}\". Maximum is [{:.1R}]. Values must be >= 0.0.", ipsc->cAlphaArgs(2), SchMax)); - ErrorsFound = true; - } - } } - if (ipsc->lAlphaFieldBlanks(3)) { + + if (s_ipsc->lAlphaFieldBlanks(3)) { state.dataExteriorEnergyUse->ExteriorLights(Item).ControlMode = ExteriorEnergyUse::LightControlType::ScheduleOnly; } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(3), "ScheduleNameOnly")) { state.dataExteriorEnergyUse->ExteriorLights(Item).ControlMode = ExteriorEnergyUse::LightControlType::ScheduleOnly; } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(3), "AstronomicalClock")) { state.dataExteriorEnergyUse->ExteriorLights(Item).ControlMode = ExteriorEnergyUse::LightControlType::AstroClockOverride; } else { - ShowSevereError(state, - format("{}: {}: invalid {} entered={} for {}={}", - routineName, - cCurrentModuleObject, - state.dataIPShortCut->cAlphaFieldNames(3), - state.dataIPShortCut->cAlphaArgs(3), - state.dataIPShortCut->cAlphaFieldNames(1), - state.dataIPShortCut->cAlphaArgs(1))); + ShowSevereInvalidKey(state, eoh, state.dataIPShortCut->cAlphaFieldNames(3), state.dataIPShortCut->cAlphaArgs(3)); } if (NumAlphas > 3) { @@ -275,9 +227,9 @@ namespace ExteriorEnergyUse { PreDefTableEntry(state, state.dataOutRptPredefined->pdchExLtSchd, state.dataExteriorEnergyUse->ExteriorLights(Item).Name, - GetScheduleName(state, state.dataExteriorEnergyUse->ExteriorLights(Item).SchedPtr)); + state.dataExteriorEnergyUse->ExteriorLights(Item).sched->Name); + } } - } PreDefTableEntry(state, state.dataOutRptPredefined->pdchExLtPower, "Exterior Lighting Total", state.dataExteriorEnergyUse->sumDesignLevel); // ================================= Get Exterior Fuel Equipment @@ -303,7 +255,7 @@ namespace ExteriorEnergyUse { state.dataIPShortCut->cAlphaFieldNames(1), ErrorsFound); - ErrorObjectHeader eoh{routineName, ipsc->cCurrentModuleObject, ipsc->cAlphaArgs(1)}; + ErrorObjectHeader eoh{routineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)}; ++state.dataExteriorEnergyUse->NumExteriorEqs; @@ -317,12 +269,12 @@ namespace ExteriorEnergyUse { } if (state.dataIPShortCut->lAlphaFieldBlanks(2)) { - ShowSevereEmptyField(state, eoh, ipsc->cAlphaFieldNames(2)); + ShowSevereEmptyField(state, eoh, s_ipsc->cAlphaFieldNames(2)); ErrorsFound = true; } else if ((exteriorEquip.FuelType = static_cast( - getEnumValue(Constant::eFuelNamesUC, Util::makeUPPER(ipsc->cAlphaArgs(2))))) == Constant::eFuel::Invalid) { - ShowSevereInvalidKey(state, eoh, ipsc->cAlphaFieldNames(2), ipsc->cAlphaArgs(2)); + getEnumValue(Constant::eFuelNamesUC, s_ipsc->cAlphaArgs(2)))) == Constant::eFuel::Invalid) { + ShowSevereInvalidKey(state, eoh, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2)); ErrorsFound = true; } else if (exteriorEquip.FuelType != Constant::eFuel::Water) { @@ -365,143 +317,71 @@ namespace ExteriorEnergyUse { EndUseSubcategoryName); } - exteriorEquip.SchedPtr = GetScheduleIndex(state, ipsc->cAlphaArgs(3)); - if (exteriorEquip.SchedPtr == 0) { - if (ipsc->lAlphaFieldBlanks(3)) { - ShowSevereError(state, - format("{}: {}: {} is required, missing for {}={}", - routineName, - cCurrentModuleObject, - ipsc->cAlphaFieldNames(3), - ipsc->cAlphaFieldNames(1), - ipsc->cAlphaArgs(1))); - } else { - ShowSevereError(state, - format("{}: {}: invalid {} entered={} for {}={}", - routineName, - cCurrentModuleObject, - ipsc->cAlphaFieldNames(3), - ipsc->cAlphaArgs(3), - ipsc->cAlphaFieldNames(1), - ipsc->cAlphaArgs(1))); - } + if (s_ipsc->lAlphaFieldBlanks(3)) { + ShowSevereEmptyField(state, eoh, s_ipsc->cAlphaFieldNames(3)); + ErrorsFound = true; + } else if ((exteriorEquip.sched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(3))) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(3), s_ipsc->cAlphaArgs(3)); + ErrorsFound = true; + } else if (int SchMin = exteriorEquip.sched->getMinVal(state); SchMin < 0.0) { + ShowSevereCustom(state, eoh, format("{} = {} minimum is [{:.1R}]. Values must be >= 0.0.", + s_ipsc->cAlphaFieldNames(3), s_ipsc->cAlphaArgs(3), SchMin)); ErrorsFound = true; - } else { // check min/max on schedule - SchMin = GetScheduleMinValue(state, exteriorEquip.SchedPtr); - SchMax = GetScheduleMaxValue(state, exteriorEquip.SchedPtr); - if (SchMin < 0.0 || SchMax < 0.0) { - if (SchMin < 0.0) { - ShowSevereError(state, - format("{}: {}: invalid {} minimum, is < 0.0 for {}={}", - routineName, - cCurrentModuleObject, - ipsc->cAlphaFieldNames(3), - ipsc->cAlphaFieldNames(1), - ipsc->cAlphaArgs(1))); - ShowContinueError(state, format("{}\". Minimum is [{:.1R}]. Values must be >= 0.0.", ipsc->cAlphaArgs(3), SchMin)); - ErrorsFound = true; - } - if (SchMax < 0.0) { - ShowSevereError(state, - format("{}: {}: invalid {} maximum, is < 0.0 for {}={}", - routineName, - cCurrentModuleObject, - ipsc->cAlphaFieldNames(3), - ipsc->cAlphaFieldNames(1), - ipsc->cAlphaArgs(1))); - ShowContinueError(state, format("{}\". Maximum is [{:.1R}]. Values must be >= 0.0.", ipsc->cAlphaArgs(3), SchMax)); - ErrorsFound = true; - } - } } - exteriorEquip.DesignLevel = ipsc->rNumericArgs(1); + exteriorEquip.DesignLevel = s_ipsc->rNumericArgs(1); } // ================================= Get Exterior Water Equipment - + cCurrentModuleObject = "Exterior:WaterEquipment"; for (int Item = 1; Item <= NumWtrEq; ++Item) { state.dataInputProcessing->inputProcessor->getObjectItem(state, cCurrentModuleObject, Item, - ipsc->cAlphaArgs, + s_ipsc->cAlphaArgs, NumAlphas, - ipsc->rNumericArgs, + s_ipsc->rNumericArgs, NumNumbers, IOStatus, - ipsc->lNumericFieldBlanks, - ipsc->lAlphaFieldBlanks, - ipsc->cAlphaFieldNames, - ipsc->cNumericFieldNames); + s_ipsc->lNumericFieldBlanks, + s_ipsc->lAlphaFieldBlanks, + s_ipsc->cAlphaFieldNames, + s_ipsc->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, cCurrentModuleObject, s_ipsc->cAlphaArgs(1)}; + GlobalNames::VerifyUniqueInterObjectName(state, state.dataExteriorEnergyUse->UniqueExteriorEquipNames, - ipsc->cAlphaArgs(1), + s_ipsc->cAlphaArgs(1), cCurrentModuleObject, - ipsc->cAlphaFieldNames(1), + s_ipsc->cAlphaFieldNames(1), ErrorsFound); ++state.dataExteriorEnergyUse->NumExteriorEqs; auto &exteriorEquip = state.dataExteriorEnergyUse->ExteriorEquipment(state.dataExteriorEnergyUse->NumExteriorEqs); - exteriorEquip.Name = ipsc->cAlphaArgs(1); + exteriorEquip.Name = s_ipsc->cAlphaArgs(1); exteriorEquip.FuelType = Constant::eFuel::Water; - exteriorEquip.SchedPtr = GetScheduleIndex(state, ipsc->cAlphaArgs(3)); - if (exteriorEquip.SchedPtr == 0) { - if (ipsc->lAlphaFieldBlanks(3)) { - ShowSevereError(state, - format("{}: {}: {} is required, missing for {}={}", - routineName, - cCurrentModuleObject, - ipsc->cAlphaFieldNames(3), - ipsc->cAlphaFieldNames(1), - ipsc->cAlphaArgs(1))); - } else { - ShowSevereError(state, - format("{}: {}: invalid {} entered={} for {}={}", - routineName, - cCurrentModuleObject, - ipsc->cAlphaFieldNames(3), - ipsc->cAlphaArgs(3), - ipsc->cAlphaFieldNames(1), - ipsc->cAlphaArgs(1))); - } + + if (s_ipsc->lAlphaFieldBlanks(3)) { + ShowSevereEmptyField(state, eoh, s_ipsc->cAlphaFieldNames(3)); + ErrorsFound = true; + } else if ((exteriorEquip.sched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(3))) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(3), s_ipsc->cAlphaArgs(3)); + ErrorsFound = true; + } else if (int SchMin = exteriorEquip.sched->getMinVal(state); SchMin < 0.0) { + ShowSevereCustom(state, eoh, format("{} = {} minimum is [{:.1R}]. Values must be >= 0.0.", + s_ipsc->cAlphaFieldNames(3), s_ipsc->cAlphaArgs(3), SchMin)); ErrorsFound = true; - } else { // check min/max on schedule - SchMin = GetScheduleMinValue(state, exteriorEquip.SchedPtr); - SchMax = GetScheduleMaxValue(state, exteriorEquip.SchedPtr); - if (SchMin < 0.0 || SchMax < 0.0) { - if (SchMin < 0.0) { - ShowSevereError(state, - format("{}: {}: invalid {} minimum, is < 0.0 for {}={}", - routineName, - cCurrentModuleObject, - ipsc->cAlphaFieldNames(3), - ipsc->cAlphaFieldNames(1), - ipsc->cAlphaArgs(1))); - ShowContinueError(state, format("{}\". Minimum is [{:.1R}]. Values must be >= 0.0.", ipsc->cAlphaArgs(3), SchMin)); - ErrorsFound = true; - } - if (SchMax < 0.0) { - ShowSevereError(state, - format("{}: {}: invalid {} maximum, is < 0.0 for {}={}", - routineName, - cCurrentModuleObject, - ipsc->cAlphaFieldNames(3), - ipsc->cAlphaFieldNames(1), - ipsc->cAlphaArgs(1))); - ShowContinueError(state, format("{}\". Maximum is [{:.1R}]. Values must be >= 0.0.", ipsc->cAlphaArgs(3), SchMax)); - ErrorsFound = true; - } - } } if (NumAlphas > 3) { - EndUseSubcategoryName = ipsc->cAlphaArgs(4); + EndUseSubcategoryName = s_ipsc->cAlphaArgs(4); } else { EndUseSubcategoryName = "General"; } - exteriorEquip.DesignLevel = ipsc->rNumericArgs(1); + exteriorEquip.DesignLevel = s_ipsc->rNumericArgs(1); SetupOutputVariable(state, "Exterior Equipment Water Volume Flow Rate", @@ -538,7 +418,7 @@ namespace ExteriorEnergyUse { if (ErrorsFound) { ShowFatalError(state, format("{}Errors found in input. Program terminates.", routineName)); } - } + } // GetExteriorEnergyUseInput() void ReportExteriorEnergyUse(EnergyPlusData &state) { @@ -546,44 +426,17 @@ namespace ExteriorEnergyUse { // SUBROUTINE INFORMATION: // AUTHOR Linda Lawrie // DATE WRITTEN January 2001 - // MODIFIED na - // RE-ENGINEERED na // PURPOSE OF THIS SUBROUTINE: // This subroutine performs the calculations necessary to report // the exterior energy use types. - // METHODOLOGY EMPLOYED: - // na - - // REFERENCES: - // na - - // Using/Aliasing - using ScheduleManager::GetCurrentScheduleValue; - - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - // na - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS: - // na - - // DERIVED TYPE DEFINITIONS: - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - int Item; // Loop Control - - for (Item = 1; Item <= state.dataExteriorEnergyUse->NumExteriorLights; ++Item) { + for (int Item = 1; Item <= state.dataExteriorEnergyUse->NumExteriorLights; ++Item) { switch (state.dataExteriorEnergyUse->ExteriorLights(Item).ControlMode) { case ExteriorEnergyUse::LightControlType::ScheduleOnly: state.dataExteriorEnergyUse->ExteriorLights(Item).Power = state.dataExteriorEnergyUse->ExteriorLights(Item).DesignLevel * - GetCurrentScheduleValue(state, state.dataExteriorEnergyUse->ExteriorLights(Item).SchedPtr); + state.dataExteriorEnergyUse->ExteriorLights(Item).sched->getCurrentVal(); state.dataExteriorEnergyUse->ExteriorLights(Item).CurrentUse = state.dataExteriorEnergyUse->ExteriorLights(Item).Power * state.dataGlobal->TimeStepZoneSec; break; @@ -594,7 +447,7 @@ namespace ExteriorEnergyUse { } else { state.dataExteriorEnergyUse->ExteriorLights(Item).Power = state.dataExteriorEnergyUse->ExteriorLights(Item).DesignLevel * - GetCurrentScheduleValue(state, state.dataExteriorEnergyUse->ExteriorLights(Item).SchedPtr); + state.dataExteriorEnergyUse->ExteriorLights(Item).sched->getCurrentVal(); state.dataExteriorEnergyUse->ExteriorLights(Item).CurrentUse = state.dataExteriorEnergyUse->ExteriorLights(Item).Power * state.dataGlobal->TimeStepZoneSec; } @@ -634,10 +487,10 @@ namespace ExteriorEnergyUse { } } - for (Item = 1; Item <= state.dataExteriorEnergyUse->NumExteriorEqs; ++Item) { + for (int Item = 1; Item <= state.dataExteriorEnergyUse->NumExteriorEqs; ++Item) { state.dataExteriorEnergyUse->ExteriorEquipment(Item).Power = state.dataExteriorEnergyUse->ExteriorEquipment(Item).DesignLevel * - GetCurrentScheduleValue(state, state.dataExteriorEnergyUse->ExteriorEquipment(Item).SchedPtr); + state.dataExteriorEnergyUse->ExteriorEquipment(Item).sched->getCurrentVal(); state.dataExteriorEnergyUse->ExteriorEquipment(Item).CurrentUse = state.dataExteriorEnergyUse->ExteriorEquipment(Item).Power * state.dataGlobal->TimeStepZoneSec; } diff --git a/src/EnergyPlus/ExteriorEnergyUse.hh b/src/EnergyPlus/ExteriorEnergyUse.hh index 6c10765e96e..bee96e5f3ea 100644 --- a/src/EnergyPlus/ExteriorEnergyUse.hh +++ b/src/EnergyPlus/ExteriorEnergyUse.hh @@ -58,6 +58,7 @@ #include #include #include +#include namespace EnergyPlus { @@ -78,7 +79,7 @@ namespace ExteriorEnergyUse { { // Members std::string Name; // Descriptive name -- will show on reporting - int SchedPtr; // Can be scheduled + Sched::Schedule *sched = nullptr; // Can be scheduled Real64 DesignLevel; // Consumption in Watts Real64 Power; // Power = DesignLevel * ScheduleValue Real64 CurrentUse; // Use for this time step @@ -92,7 +93,7 @@ namespace ExteriorEnergyUse { // Default Constructor ExteriorLightUsage() - : SchedPtr(0), DesignLevel(0.0), Power(0.0), CurrentUse(0.0), ControlMode(LightControlType::ScheduleOnly), ManageDemand(false), + : DesignLevel(0.0), Power(0.0), CurrentUse(0.0), ControlMode(LightControlType::ScheduleOnly), ManageDemand(false), DemandLimit(0.0), PowerActuatorOn(false), PowerActuatorValue(0.0), SumConsumption(0.0), SumTimeNotZeroCons(0.0) { } @@ -103,7 +104,7 @@ namespace ExteriorEnergyUse { // Members std::string Name; // Descriptive name -- will show on reporting Constant::eFuel FuelType; - int SchedPtr; // Can be scheduled + Sched::Schedule *sched = nullptr; // Can be scheduled Real64 DesignLevel; // Design Consumption (Watts, except for Water Equipment) Real64 Power; // Power = DesignLevel * ScheduleValue Real64 CurrentUse; // Use for this time step @@ -112,7 +113,7 @@ namespace ExteriorEnergyUse { // Default Constructor ExteriorEquipmentUsage() - : FuelType(Constant::eFuel::Invalid), SchedPtr(0), DesignLevel(0.0), Power(0.0), CurrentUse(0.0), ManageDemand(false), DemandLimit(0.0) + : FuelType(Constant::eFuel::Invalid), DesignLevel(0.0), Power(0.0), CurrentUse(0.0), ManageDemand(false), DemandLimit(0.0) { } }; @@ -136,6 +137,10 @@ struct ExteriorEnergyUseData : BaseGlobalStruct bool GetExteriorEnergyInputFlag = true; // First time, input is "gotten" Real64 sumDesignLevel = 0.0; // for predefined report of design level total + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/ExternalInterface.cc b/src/EnergyPlus/ExternalInterface.cc index 30e6ff105df..efd5d0585ff 100644 --- a/src/EnergyPlus/ExternalInterface.cc +++ b/src/EnergyPlus/ExternalInterface.cc @@ -532,7 +532,7 @@ void InitExternalInterface(EnergyPlusData &state) state.dataExternalInterface->varInd.allocate(state.dataExternalInterface->nInpVar); for (int i = 1; i <= state.dataExternalInterface->nInpVar; ++i) { if (state.dataExternalInterface->inpVarTypes(i) == indexSchedule) { - state.dataExternalInterface->varInd(i) = ScheduleManager::GetDayScheduleIndex(state, state.dataExternalInterface->inpVarNames(i)); + state.dataExternalInterface->varInd(i) = Sched::GetDayScheduleNum(state, state.dataExternalInterface->inpVarNames(i)); } else if (state.dataExternalInterface->inpVarTypes(i) == indexVariable) { state.dataExternalInterface->varInd(i) = RuntimeLanguageProcessor::FindEMSVariable(state, state.dataExternalInterface->inpVarNames(i), 0); @@ -591,128 +591,134 @@ void GetSetVariablesAndDoStepFMUImport(EnergyPlusData &state) // This routine gets, sets and does the time integration in FMUs. for (int i = 1; i <= state.dataExternalInterface->NumFMUObjects; ++i) { - for (int j = 1; j <= state.dataExternalInterface->FMU(i).NumInstances; ++j) { + auto &fmu = state.dataExternalInterface->FMU(i); + auto &fmuTemp = state.dataExternalInterface->FMUTemp(i); + + for (int j = 1; j <= fmu.NumInstances; ++j) { + auto &fmuInst = fmu.Instance(j); + auto &fmuTempInst = fmuTemp.Instance(j); + if (state.dataExternalInterface->FlagReIni) { // Get from FMUs, values that will be set in EnergyPlus (Schedule) - for (int k = 1; k <= state.dataExternalInterface->FMUTemp(i).Instance(j).NumOutputVariablesSchedule; ++k) { - state.dataExternalInterface->FMU(i).Instance(j).fmuOutputVariableSchedule(k).RealVarValue = - state.dataExternalInterface->FMUTemp(i).Instance(j).fmuOutputVariableSchedule(k).RealVarValue; + for (int k = 1; k <= fmuTempInst.NumOutputVariablesSchedule; ++k) { + fmuInst.fmuOutputVariableSchedule(k).RealVarValue = + fmuTempInst.fmuOutputVariableSchedule(k).RealVarValue; } // Get from FMUs, values that will be set in EnergyPlus (Variable) - for (int k = 1; k <= state.dataExternalInterface->FMUTemp(i).Instance(j).NumOutputVariablesVariable; ++k) { - state.dataExternalInterface->FMU(i).Instance(j).fmuOutputVariableVariable(k).RealVarValue = - state.dataExternalInterface->FMUTemp(i).Instance(j).fmuOutputVariableVariable(k).RealVarValue; + for (int k = 1; k <= fmuTempInst.NumOutputVariablesVariable; ++k) { + fmuInst.fmuOutputVariableVariable(k).RealVarValue = + fmuTempInst.fmuOutputVariableVariable(k).RealVarValue; } // Get from FMUs, values that will be set in EnergyPlus (Actuator) - for (int k = 1; k <= state.dataExternalInterface->FMUTemp(i).Instance(j).NumOutputVariablesActuator; ++k) { - state.dataExternalInterface->FMU(i).Instance(j).fmuOutputVariableActuator(k).RealVarValue = - state.dataExternalInterface->FMUTemp(i).Instance(j).fmuOutputVariableActuator(k).RealVarValue; + for (int k = 1; k <= fmuTempInst.NumOutputVariablesActuator; ++k) { + fmuInst.fmuOutputVariableActuator(k).RealVarValue = + fmuTempInst.fmuOutputVariableActuator(k).RealVarValue; } } else { // Get from FMUs, values that will be set in EnergyPlus (Schedule) - if (size(state.dataExternalInterface->FMU(i).Instance(j).fmuOutputVariableSchedule) > 0) { + if (size(fmuInst.fmuOutputVariableSchedule) > 0) { // generate vectors here first std::vector valueReferenceVec; std::vector realVarValueVec; - for (unsigned long x = 1; x <= size(state.dataExternalInterface->FMU(i).Instance(j).fmuOutputVariableSchedule); ++x) { - valueReferenceVec.push_back(state.dataExternalInterface->FMU(i).Instance(j).fmuOutputVariableSchedule(x).ValueReference); - realVarValueVec.push_back(state.dataExternalInterface->FMU(i).Instance(j).fmuOutputVariableSchedule(x).RealVarValue); + for (unsigned long x = 1; x <= size(fmuInst.fmuOutputVariableSchedule); ++x) { + valueReferenceVec.push_back(fmuInst.fmuOutputVariableSchedule(x).ValueReference); + realVarValueVec.push_back(fmuInst.fmuOutputVariableSchedule(x).RealVarValue); } // pass in the vectors as pointers to the first member of the vector - state.dataExternalInterface->FMU(i).Instance(j).fmistatus = - fmiEPlusGetReal(&state.dataExternalInterface->FMU(i).Instance(j).fmicomponent, + fmuInst.fmistatus = + fmiEPlusGetReal(&fmuInst.fmicomponent, &valueReferenceVec[0], &realVarValueVec[0], - &state.dataExternalInterface->FMU(i).Instance(j).NumOutputVariablesSchedule, - &state.dataExternalInterface->FMU(i).Instance(j).Index); + &fmuInst.NumOutputVariablesSchedule, + &fmuInst.Index); - for (unsigned long x = 1; x <= size(state.dataExternalInterface->FMU(i).Instance(j).fmuOutputVariableSchedule); ++x) { - state.dataExternalInterface->FMU(i).Instance(j).fmuOutputVariableSchedule(x).ValueReference = valueReferenceVec[x - 1]; - state.dataExternalInterface->FMU(i).Instance(j).fmuOutputVariableSchedule(x).RealVarValue = realVarValueVec[x - 1]; + for (unsigned long x = 1; x <= size(fmuInst.fmuOutputVariableSchedule); ++x) { + fmuInst.fmuOutputVariableSchedule(x).ValueReference = valueReferenceVec[x - 1]; + fmuInst.fmuOutputVariableSchedule(x).RealVarValue = realVarValueVec[x - 1]; } - if (state.dataExternalInterface->FMU(i).Instance(j).fmistatus != fmiOK) { + if (fmuInst.fmistatus != fmiOK) { ShowSevereError(state, "ExternalInterface/GetSetVariablesAndDoStepFMUImport: Error when trying to get outputs"); ShowContinueError(state, format("in instance \"{}\" of FMU \"{}\"", - state.dataExternalInterface->FMU(i).Instance(j).Name, - state.dataExternalInterface->FMU(i).Name)); - ShowContinueError(state, format("Error Code = \"{}\"", state.dataExternalInterface->FMU(i).Instance(j).fmistatus)); + fmuInst.Name, + fmu.Name)); + ShowContinueError(state, format("Error Code = \"{}\"", fmuInst.fmistatus)); state.dataExternalInterface->ErrorsFound = true; StopExternalInterfaceIfError(state); } } // generate vectors here first - if (size(state.dataExternalInterface->FMU(i).Instance(j).fmuOutputVariableVariable) > 0) { + if (size(fmuInst.fmuOutputVariableVariable) > 0) { std::vector valueReferenceVec2; std::vector realVarValueVec2; - for (unsigned long x = 1; x <= size(state.dataExternalInterface->FMU(i).Instance(j).fmuOutputVariableVariable); ++x) { - valueReferenceVec2.push_back(state.dataExternalInterface->FMU(i).Instance(j).fmuOutputVariableVariable(x).ValueReference); - realVarValueVec2.push_back(state.dataExternalInterface->FMU(i).Instance(j).fmuOutputVariableVariable(x).RealVarValue); + for (unsigned long x = 1; x <= size(fmuInst.fmuOutputVariableVariable); ++x) { + valueReferenceVec2.push_back(fmuInst.fmuOutputVariableVariable(x).ValueReference); + realVarValueVec2.push_back(fmuInst.fmuOutputVariableVariable(x).RealVarValue); } // pass in the vectors as pointers to the first member of the vector - state.dataExternalInterface->FMU(i).Instance(j).fmistatus = - fmiEPlusGetReal(&state.dataExternalInterface->FMU(i).Instance(j).fmicomponent, + fmuInst.fmistatus = + fmiEPlusGetReal(&fmuInst.fmicomponent, &valueReferenceVec2[0], &realVarValueVec2[0], - &state.dataExternalInterface->FMU(i).Instance(j).NumOutputVariablesVariable, - &state.dataExternalInterface->FMU(i).Instance(j).Index); + &fmuInst.NumOutputVariablesVariable, + &fmuInst.Index); - for (unsigned long x = 1; x <= size(state.dataExternalInterface->FMU(i).Instance(j).fmuOutputVariableVariable); ++x) { - state.dataExternalInterface->FMU(i).Instance(j).fmuOutputVariableVariable(x).ValueReference = valueReferenceVec2[x - 1]; - state.dataExternalInterface->FMU(i).Instance(j).fmuOutputVariableVariable(x).RealVarValue = realVarValueVec2[x - 1]; + for (unsigned long x = 1; x <= size(fmuInst.fmuOutputVariableVariable); ++x) { + fmuInst.fmuOutputVariableVariable(x).ValueReference = valueReferenceVec2[x - 1]; + fmuInst.fmuOutputVariableVariable(x).RealVarValue = realVarValueVec2[x - 1]; } - if (state.dataExternalInterface->FMU(i).Instance(j).fmistatus != fmiOK) { + if (fmuInst.fmistatus != fmiOK) { ShowSevereError(state, "ExternalInterface/GetSetVariablesAndDoStepFMUImport: Error when trying to get outputs"); ShowContinueError(state, format("in instance \"{}\" of FMU \"{}\"", - state.dataExternalInterface->FMU(i).Instance(j).Name, - state.dataExternalInterface->FMU(i).Name)); - ShowContinueError(state, format("Error Code = \"{}\"", state.dataExternalInterface->FMU(i).Instance(j).fmistatus)); + fmuInst.Name, + fmu.Name)); + ShowContinueError(state, format("Error Code = \"{}\"", fmuInst.fmistatus)); state.dataExternalInterface->ErrorsFound = true; StopExternalInterfaceIfError(state); } } - if (size(state.dataExternalInterface->FMU(i).Instance(j).fmuOutputVariableActuator) > 0) { + if (size(fmuInst.fmuOutputVariableActuator) > 0) { // generate vectors here first std::vector valueReferenceVec3; std::vector realVarValueVec3; - for (unsigned long x = 1; x <= size(state.dataExternalInterface->FMU(i).Instance(j).fmuOutputVariableActuator); ++x) { - valueReferenceVec3.push_back(state.dataExternalInterface->FMU(i).Instance(j).fmuOutputVariableActuator(x).ValueReference); - realVarValueVec3.push_back(state.dataExternalInterface->FMU(i).Instance(j).fmuOutputVariableActuator(x).RealVarValue); + for (unsigned long x = 1; x <= size(fmuInst.fmuOutputVariableActuator); ++x) { + valueReferenceVec3.push_back(fmuInst.fmuOutputVariableActuator(x).ValueReference); + realVarValueVec3.push_back(fmuInst.fmuOutputVariableActuator(x).RealVarValue); } // pass in the vectors as pointers to the first member of the vector - state.dataExternalInterface->FMU(i).Instance(j).fmistatus = - fmiEPlusGetReal(&state.dataExternalInterface->FMU(i).Instance(j).fmicomponent, + fmuInst.fmistatus = + fmiEPlusGetReal(&fmuInst.fmicomponent, &valueReferenceVec3[0], &realVarValueVec3[0], - &state.dataExternalInterface->FMU(i).Instance(j).NumOutputVariablesActuator, - &state.dataExternalInterface->FMU(i).Instance(j).Index); + &fmuInst.NumOutputVariablesActuator, + &fmuInst.Index); - for (unsigned long x = 1; x <= size(state.dataExternalInterface->FMU(i).Instance(j).fmuOutputVariableActuator); ++x) { - state.dataExternalInterface->FMU(i).Instance(j).fmuOutputVariableActuator(x).ValueReference = valueReferenceVec3[x - 1]; - state.dataExternalInterface->FMU(i).Instance(j).fmuOutputVariableActuator(x).RealVarValue = realVarValueVec3[x - 1]; + for (unsigned long x = 1; x <= size(fmuInst.fmuOutputVariableActuator); ++x) { + fmuInst.fmuOutputVariableActuator(x).ValueReference = valueReferenceVec3[x - 1]; + fmuInst.fmuOutputVariableActuator(x).RealVarValue = realVarValueVec3[x - 1]; } - if (state.dataExternalInterface->FMU(i).Instance(j).fmistatus != fmiOK) { + if (fmuInst.fmistatus != fmiOK) { ShowSevereError(state, "ExternalInterface/GetSetVariablesAndDoStepFMUImport: Error when trying to get outputs"); ShowContinueError(state, format("in instance \"{}\" of FMU \"{}\"", - state.dataExternalInterface->FMU(i).Instance(j).Name, - state.dataExternalInterface->FMU(i).Name)); - ShowContinueError(state, format("Error Code = \"{}\"", state.dataExternalInterface->FMU(i).Instance(j).fmistatus)); + fmuInst.Name, + fmu.Name)); + ShowContinueError(state, format("Error Code = \"{}\"", fmuInst.fmistatus)); state.dataExternalInterface->ErrorsFound = true; StopExternalInterfaceIfError(state); } @@ -720,46 +726,46 @@ void GetSetVariablesAndDoStepFMUImport(EnergyPlusData &state) } // Set in EnergyPlus the values of the schedules - for (int k = 1; k <= state.dataExternalInterface->FMU(i).Instance(j).NumOutputVariablesSchedule; ++k) { - ScheduleManager::ExternalInterfaceSetSchedule( + for (int k = 1; k <= fmuInst.NumOutputVariablesSchedule; ++k) { + Sched::ExternalInterfaceSetSchedule( state, - state.dataExternalInterface->FMU(i).Instance(j).eplusInputVariableSchedule(k).VarIndex, - state.dataExternalInterface->FMU(i).Instance(j).fmuOutputVariableSchedule(k).RealVarValue); + fmuInst.eplusInputVariableSchedule(k).VarIndex, + fmuInst.fmuOutputVariableSchedule(k).RealVarValue); } // Set in EnergyPlus the values of the variables - for (int k = 1; k <= state.dataExternalInterface->FMU(i).Instance(j).NumOutputVariablesVariable; ++k) { + for (int k = 1; k <= fmuInst.NumOutputVariablesVariable; ++k) { RuntimeLanguageProcessor::ExternalInterfaceSetErlVariable( state, - state.dataExternalInterface->FMU(i).Instance(j).eplusInputVariableVariable(k).VarIndex, - state.dataExternalInterface->FMU(i).Instance(j).fmuOutputVariableVariable(k).RealVarValue); + fmuInst.eplusInputVariableVariable(k).VarIndex, + fmuInst.fmuOutputVariableVariable(k).RealVarValue); } // Set in EnergyPlus the values of the actuators - for (int k = 1; k <= state.dataExternalInterface->FMU(i).Instance(j).NumOutputVariablesActuator; ++k) { + for (int k = 1; k <= fmuInst.NumOutputVariablesActuator; ++k) { RuntimeLanguageProcessor::ExternalInterfaceSetErlVariable( state, - state.dataExternalInterface->FMU(i).Instance(j).eplusInputVariableActuator(k).VarIndex, - state.dataExternalInterface->FMU(i).Instance(j).fmuOutputVariableActuator(k).RealVarValue); + fmuInst.eplusInputVariableActuator(k).VarIndex, + fmuInst.fmuOutputVariableActuator(k).RealVarValue); } if (state.dataExternalInterface->FirstCallGetSetDoStep) { // Get from EnergyPlus, values that will be set in fmus - for (int k = 1; k <= state.dataExternalInterface->FMU(i).Instance(j).NumInputVariablesInIDF; ++k) { + for (int k = 1; k <= fmuInst.NumInputVariablesInIDF; ++k) { // This make sure that the variables are updated at the Zone Time Step - state.dataExternalInterface->FMU(i).Instance(j).eplusOutputVariable(k).RTSValue = + fmuInst.eplusOutputVariable(k).RTSValue = GetInternalVariableValue(state, - state.dataExternalInterface->FMU(i).Instance(j).eplusOutputVariable(k).VarType, - state.dataExternalInterface->FMU(i).Instance(j).eplusOutputVariable(k).VarIndex); + fmuInst.eplusOutputVariable(k).VarType, + fmuInst.eplusOutputVariable(k).VarIndex); } } else { // Get from EnergyPlus, values that will be set in fmus - for (int k = 1; k <= state.dataExternalInterface->FMU(i).Instance(j).NumInputVariablesInIDF; ++k) { + for (int k = 1; k <= fmuInst.NumInputVariablesInIDF; ++k) { // This make sure that the variables are updated at the Zone Time Step - state.dataExternalInterface->FMU(i).Instance(j).eplusOutputVariable(k).RTSValue = + fmuInst.eplusOutputVariable(k).RTSValue = GetInternalVariableValueExternalInterface(state, - state.dataExternalInterface->FMU(i).Instance(j).eplusOutputVariable(k).VarType, - state.dataExternalInterface->FMU(i).Instance(j).eplusOutputVariable(k).VarIndex); + fmuInst.eplusOutputVariable(k).VarType, + fmuInst.eplusOutputVariable(k).VarIndex); } } @@ -767,45 +773,42 @@ void GetSetVariablesAndDoStepFMUImport(EnergyPlusData &state) // generate vectors here first std::vector valueReferenceVec4; - for (unsigned long x = 1; x <= size(state.dataExternalInterface->FMU(i).Instance(j).fmuInputVariable); ++x) { - valueReferenceVec4.push_back(state.dataExternalInterface->FMU(i).Instance(j).fmuInputVariable(x).ValueReference); + for (unsigned long x = 1; x <= size(fmuInst.fmuInputVariable); ++x) { + valueReferenceVec4.push_back(fmuInst.fmuInputVariable(x).ValueReference); } std::vector rtsValueVec4; - for (unsigned long x = 1; x <= size(state.dataExternalInterface->FMU(i).Instance(j).eplusOutputVariable); ++x) { - rtsValueVec4.push_back(state.dataExternalInterface->FMU(i).Instance(j).eplusOutputVariable(x).RTSValue); + for (unsigned long x = 1; x <= size(fmuInst.eplusOutputVariable); ++x) { + rtsValueVec4.push_back(fmuInst.eplusOutputVariable(x).RTSValue); } - state.dataExternalInterface->FMU(i).Instance(j).fmistatus = - fmiEPlusSetReal(&state.dataExternalInterface->FMU(i).Instance(j).fmicomponent, + fmuInst.fmistatus = + fmiEPlusSetReal(&fmuInst.fmicomponent, &valueReferenceVec4[0], &rtsValueVec4[0], - &state.dataExternalInterface->FMU(i).Instance(j).NumInputVariablesInIDF, - &state.dataExternalInterface->FMU(i).Instance(j).Index); + &fmuInst.NumInputVariablesInIDF, + &fmuInst.Index); - if (state.dataExternalInterface->FMU(i).Instance(j).fmistatus != fmiOK) { + if (fmuInst.fmistatus != fmiOK) { ShowSevereError(state, "ExternalInterface/GetSetVariablesAndDoStepFMUImport: Error when trying to set inputs"); - ShowContinueError(state, - format("in instance \"{}\" of FMU \"{}\"", - state.dataExternalInterface->FMU(i).Instance(j).Name, - state.dataExternalInterface->FMU(i).Name)); - ShowContinueError(state, format("Error Code = \"{}\"", state.dataExternalInterface->FMU(i).Instance(j).fmistatus)); + ShowContinueError(state, format("in instance \"{}\" of FMU \"{}\"", fmuInst.Name, fmu.Name)); + ShowContinueError(state, format("Error Code = \"{}\"", fmuInst.fmistatus)); state.dataExternalInterface->ErrorsFound = true; StopExternalInterfaceIfError(state); } } int localfmitrue(fmiTrue); // Call and simulate the FMUs to get values at the corresponding timestep. - state.dataExternalInterface->FMU(i).Instance(j).fmistatus = fmiEPlusDoStep(&state.dataExternalInterface->FMU(i).Instance(j).fmicomponent, - &state.dataExternalInterface->tComm, - &state.dataExternalInterface->hStep, - &localfmitrue, - &state.dataExternalInterface->FMU(i).Instance(j).Index); - if (state.dataExternalInterface->FMU(i).Instance(j).fmistatus != fmiOK) { + fmuInst.fmistatus = fmiEPlusDoStep(&fmuInst.fmicomponent, + &state.dataExternalInterface->tComm, + &state.dataExternalInterface->hStep, + &localfmitrue, + &fmuInst.Index); + if (fmuInst.fmistatus != fmiOK) { ShowSevereError(state, "ExternalInterface/GetSetVariablesAndDoStepFMUImport: Error when trying to"); - ShowContinueError(state, format("do the coSimulation with instance \"{}\"", state.dataExternalInterface->FMU(i).Instance(j).Name)); - ShowContinueError(state, format("of FMU \"{}\"", state.dataExternalInterface->FMU(i).Name)); - ShowContinueError(state, format("Error Code = \"{}\"", state.dataExternalInterface->FMU(i).Instance(j).fmistatus)); + ShowContinueError(state, format("do the coSimulation with instance \"{}\"", fmuInst.Name)); + ShowContinueError(state, format("of FMU \"{}\"", fmu.Name)); + ShowContinueError(state, format("Error Code = \"{}\"", fmuInst.fmistatus)); state.dataExternalInterface->ErrorsFound = true; StopExternalInterfaceIfError(state); } @@ -832,23 +835,22 @@ void InstantiateInitializeFMUImport(EnergyPlusData &state) // Instantiate FMUs for (int i = 1; i <= state.dataExternalInterface->NumFMUObjects; ++i) { - for (int j = 1; j <= state.dataExternalInterface->FMU(i).NumInstances; ++j) { - std::string const folderStr = FileSystem::toString(state.dataExternalInterface->FMU(i).Instance(j).WorkingFolder); - state.dataExternalInterface->FMU(i).Instance(j).fmicomponent = + auto &fmu = state.dataExternalInterface->FMU(i); + for (int j = 1; j <= fmu.NumInstances; ++j) { + auto &fmuInst = fmu.Instance(j); + std::string const folderStr = FileSystem::toString(fmuInst.WorkingFolder); + fmuInst.fmicomponent = fmiEPlusInstantiateSlave((char *)folderStr.c_str(), - &state.dataExternalInterface->FMU(i).Instance(j).LenWorkingFolder, - &state.dataExternalInterface->FMU(i).TimeOut, - &state.dataExternalInterface->FMU(i).Visible, - &state.dataExternalInterface->FMU(i).Interactive, - &state.dataExternalInterface->FMU(i).LoggingOn, - &state.dataExternalInterface->FMU(i).Instance(j).Index); + &fmuInst.LenWorkingFolder, + &fmu.TimeOut, + &fmu.Visible, + &fmu.Interactive, + &fmu.LoggingOn, + &fmuInst.Index); // TODO: This is doing a null pointer check; OK? - if (!state.dataExternalInterface->FMU(i).Instance(j).fmicomponent) { + if (!fmuInst.fmicomponent) { ShowSevereError(state, "ExternalInterface/CalcExternalInterfaceFMUImport: Error when trying to instantiate"); - ShowContinueError(state, - format("instance \"{}\" of FMU \"{}\"", - state.dataExternalInterface->FMU(i).Instance(j).Name, - state.dataExternalInterface->FMU(i).Name)); + ShowContinueError(state, format("instance \"{}\" of FMU \"{}\"", fmuInst.Name, fmu.Name)); state.dataExternalInterface->ErrorsFound = true; StopExternalInterfaceIfError(state); } @@ -858,20 +860,19 @@ void InstantiateInitializeFMUImport(EnergyPlusData &state) // Initialize FMUs int localfmiTrue(fmiTrue); for (int i = 1; i <= state.dataExternalInterface->NumFMUObjects; ++i) { - for (int j = 1; j <= state.dataExternalInterface->FMU(i).NumInstances; ++j) { - state.dataExternalInterface->FMU(i).Instance(j).fmistatus = - fmiEPlusInitializeSlave(&state.dataExternalInterface->FMU(i).Instance(j).fmicomponent, + auto &fmu = state.dataExternalInterface->FMU(i); + for (int j = 1; j <= fmu.NumInstances; ++j) { + auto &fmuInst = fmu.Instance(j); + fmuInst.fmistatus = + fmiEPlusInitializeSlave(&fmuInst.fmicomponent, &state.dataExternalInterface->tStart, &localfmiTrue, &state.dataExternalInterface->tStop, - &state.dataExternalInterface->FMU(i).Instance(j).Index); - if (state.dataExternalInterface->FMU(i).Instance(j).fmistatus != fmiOK) { + &fmuInst.Index); + if (fmuInst.fmistatus != fmiOK) { ShowSevereError(state, "ExternalInterface/CalcExternalInterfaceFMUImport: Error when trying to initialize"); - ShowContinueError(state, - format("instance \"{}\" of FMU \"{}\"", - state.dataExternalInterface->FMU(i).Instance(j).Name, - state.dataExternalInterface->FMU(i).Name)); - ShowContinueError(state, format("Error Code = \"{}\"", state.dataExternalInterface->FMU(i).Instance(j).fmistatus)); + ShowContinueError(state, format("instance \"{}\" of FMU \"{}\"", fmuInst.Name, fmu.Name)); + ShowContinueError(state, format("Error Code = \"{}\"", fmuInst.fmistatus)); state.dataExternalInterface->ErrorsFound = true; StopExternalInterfaceIfError(state); } @@ -893,20 +894,19 @@ void InitializeFMU(EnergyPlusData &state) // Initialize FMUs for (int i = 1; i <= state.dataExternalInterface->NumFMUObjects; ++i) { - for (int j = 1; j <= state.dataExternalInterface->FMU(i).NumInstances; ++j) { - state.dataExternalInterface->FMU(i).Instance(j).fmistatus = - fmiEPlusInitializeSlave(&state.dataExternalInterface->FMU(i).Instance(j).fmicomponent, + auto &fmu = state.dataExternalInterface->FMU(i); + for (int j = 1; j <= fmu.NumInstances; ++j) { + auto &fmuInst = fmu.Instance(j); + fmuInst.fmistatus = + fmiEPlusInitializeSlave(&fmuInst.fmicomponent, &state.dataExternalInterface->tStart, &localfmiTrue, &state.dataExternalInterface->tStop, - &state.dataExternalInterface->FMU(i).Instance(j).Index); - if (state.dataExternalInterface->FMU(i).Instance(j).fmistatus != fmiOK) { + &fmuInst.Index); + if (fmuInst.fmistatus != fmiOK) { ShowSevereError(state, "ExternalInterface/CalcExternalInterfaceFMUImport: Error when trying to initialize"); - ShowContinueError(state, - format("instance \"{}\" of FMU \"{}\"", - state.dataExternalInterface->FMU(i).Instance(j).Name, - state.dataExternalInterface->FMU(i).Name)); - ShowContinueError(state, format("Error Code = \"{}\"", state.dataExternalInterface->FMU(i).Instance(j).fmistatus)); + ShowContinueError(state, format("instance \"{}\" of FMU \"{}\"", fmuInst.Name, fmu.Name)); + ShowContinueError(state, format("Error Code = \"{}\"", fmuInst.fmistatus)); state.dataExternalInterface->ErrorsFound = true; StopExternalInterfaceIfError(state); } @@ -925,21 +925,17 @@ void TerminateResetFreeFMUImport(EnergyPlusData &state, int fmiEndSimulation) //----Needs to have function that allows to terminates FMU. Was not defined in version 1.0 -- fixme for (int i = 1; i <= state.dataExternalInterface->NumFMUObjects; ++i) { - for (int j = 1; j <= state.dataExternalInterface->FMU(i).NumInstances; ++j) { - if (state.dataExternalInterface->FMU(i).Instance(j).fmistatus != fmiFatal) { + auto &fmu = state.dataExternalInterface->FMU(i); + for (int j = 1; j <= fmu.NumInstances; ++j) { + auto &fmuInst = fmu.Instance(j); + if (fmuInst.fmistatus != fmiFatal) { // Cleanup slaves - state.dataExternalInterface->FMU(i).Instance(j).fmistatus = - fmiEPlusFreeSlave(&state.dataExternalInterface->FMU(i).Instance(j).fmicomponent, - &state.dataExternalInterface->FMU(i).Instance(j).Index, - &fmiEndSimulation); + fmuInst.fmistatus = fmiEPlusFreeSlave(&fmuInst.fmicomponent, &fmuInst.Index, &fmiEndSimulation); } // check if fmiComponent has been freed - if (!state.dataExternalInterface->FMU(i).Instance(j).fmicomponent) { + if (!fmuInst.fmicomponent) { ShowSevereError(state, "ExternalInterface/TerminateResetFreeFMUImport: Error when trying to terminate"); - ShowContinueError(state, - format("instance \"{}\" of FMU \"{}\"", - state.dataExternalInterface->FMU(i).Instance(j).Name, - state.dataExternalInterface->FMU(i).Name)); + ShowContinueError(state, format("instance \"{}\" of FMU \"{}\"", fmuInst.Name, fmu.Name)); state.dataExternalInterface->ErrorsFound = true; StopExternalInterfaceIfError(state); } @@ -1065,10 +1061,12 @@ void InitExternalInterfaceFMUImport(EnergyPlusData &state) int NumFMUInputVariables = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); // Determine the number of instances for each FMUs for (int i = 1; i <= state.dataExternalInterface->NumFMUObjects; ++i) { + auto &fmu = state.dataExternalInterface->FMU(i); + std::string Name_OLD = ""; int j = 1; int k = 1; - state.dataExternalInterface->FMU(i).Instance.allocate(NumFMUInputVariables); + fmu.Instance.allocate(NumFMUInputVariables); state.dataExternalInterface->checkInstanceName.allocate(NumFMUInputVariables); for (int l = 1; l <= NumFMUInputVariables; ++l) { state.dataInputProcessing->inputProcessor->getObjectItem(state, @@ -1083,19 +1081,19 @@ void InitExternalInterfaceFMUImport(EnergyPlusData &state) _, state.dataIPShortCut->cAlphaFieldNames, state.dataIPShortCut->cNumericFieldNames); - if (Util::SameString(state.dataIPShortCut->cAlphaArgs(3), state.dataExternalInterface->FMU(i).Name)) { + if (Util::SameString(state.dataIPShortCut->cAlphaArgs(3), fmu.Name)) { std::string Name_NEW = state.dataIPShortCut->cAlphaArgs(4); if (!Util::SameString(Name_OLD, Name_NEW)) { int FOUND = Util::FindItem(Name_NEW, state.dataExternalInterface->checkInstanceName); if (FOUND == 0) { state.dataExternalInterface->checkInstanceName(l).Name = Name_NEW; - state.dataExternalInterface->FMU(i).NumInstances = j; - state.dataExternalInterface->FMU(i).Instance(j).Name = Name_NEW; + fmu.NumInstances = j; + fmu.Instance(j).Name = Name_NEW; ++j; Name_OLD = Name_NEW; } } - state.dataExternalInterface->FMU(i).TotNumInputVariablesInIDF = k; + fmu.TotNumInputVariablesInIDF = k; ++k; } } @@ -1103,16 +1101,17 @@ void InitExternalInterfaceFMUImport(EnergyPlusData &state) } for (int i = 1; i <= state.dataExternalInterface->NumFMUObjects; ++i) { - if (state.dataExternalInterface->FMU(i).NumInstances == 0) { + auto &fmu = state.dataExternalInterface->FMU(i); + if (fmu.NumInstances == 0) { ShowSevereError( - state, format("ExternalInterface/InitExternalInterfaceFMUImport: The FMU \"{}\" does", state.dataExternalInterface->FMU(i).Name)); + state, format("ExternalInterface/InitExternalInterfaceFMUImport: The FMU \"{}\" does", fmu.Name)); ShowContinueError(state, "not have any instances or any input variable. An FMU should have at least one instance"); ShowContinueError(state, "or one input variable defined in input file. Check FMU object in the input file."); state.dataExternalInterface->ErrorsFound = true; StopExternalInterfaceIfError(state); } - if (NumFMUInputVariables > 0 && state.dataExternalInterface->FMU(i).TotNumInputVariablesInIDF == 0) { - ShowWarningError(state, format("InitExternalInterfaceFMUImport: The FMU \"{}\"", state.dataExternalInterface->FMU(i).Name)); + if (NumFMUInputVariables > 0 && fmu.TotNumInputVariablesInIDF == 0) { + ShowWarningError(state, format("InitExternalInterfaceFMUImport: The FMU \"{}\"", fmu.Name)); ShowContinueError(state, "is defined but has no input variables."); ShowContinueError(state, "Check the input field of the corresponding object"); ShowContinueError(state, "ExternalInterface:FunctionalMockupUnitImport:From:Variable."); @@ -1121,19 +1120,21 @@ void InitExternalInterfaceFMUImport(EnergyPlusData &state) // write output folder where FMUs will be unpacked later on. for (int i = 1; i <= state.dataExternalInterface->NumFMUObjects; ++i) { - for (int j = 1; j <= state.dataExternalInterface->FMU(i).NumInstances; ++j) { - state.dataExternalInterface->FMU(i).Instance(j).WorkingFolder = - state.dataExternalInterface->FMURootWorkingFolder / - fs::path(strippedFileName(i) + '_' + state.dataExternalInterface->FMU(i).Instance(j).Name); + auto &fmu = state.dataExternalInterface->FMU(i); + for (int j = 1; j <= fmu.NumInstances; ++j) { + auto &fmuInst = fmu.Instance(j); + fmuInst.WorkingFolder = state.dataExternalInterface->FMURootWorkingFolder / fs::path(strippedFileName(i) + '_' + fmuInst.Name); } } // parse the fmu defined in the idf using the fmuUnpack. for (int i = 1; i <= state.dataExternalInterface->NumFMUObjects; ++i) { - for (int j = 1; j <= state.dataExternalInterface->FMU(i).NumInstances; ++j) { + auto &fmu = state.dataExternalInterface->FMU(i); + for (int j = 1; j <= fmu.NumInstances; ++j) { + auto &fmuInst = fmu.Instance(j); // get the length of working folder trimmed - std::string const workingFolderStr = FileSystem::toString(state.dataExternalInterface->FMU(i).Instance(j).WorkingFolder); - state.dataExternalInterface->FMU(i).Instance(j).LenWorkingFolder = workingFolderStr.length(); + std::string const workingFolderStr = FileSystem::toString(fmuInst.WorkingFolder); + fmuInst.LenWorkingFolder = workingFolderStr.length(); // unpack fmus // preprocess arguments for library call { @@ -1143,11 +1144,11 @@ void InitExternalInterfaceFMUImport(EnergyPlusData &state) // make the library call int retVal = fmiEPlusUnpack( - &fullFileNameArr[0], &workingFolderArr[0], &lenFileName, &state.dataExternalInterface->FMU(i).Instance(j).LenWorkingFolder); + &fullFileNameArr[0], &workingFolderArr[0], &lenFileName, &fmuInst.LenWorkingFolder); if (retVal != 0) { ShowSevereError(state, "ExternalInterface/InitExternalInterfaceFMUImport: Error when trying to"); - ShowContinueError(state, format("unpack the FMU \"{}\".", state.dataExternalInterface->FMU(i).Name)); + ShowContinueError(state, format("unpack the FMU \"{}\".", fmu.Name)); ShowContinueError(state, "Check if the FMU exists. Also check if the FMU folder is not write protected."); state.dataExternalInterface->ErrorsFound = true; StopExternalInterfaceIfError(state); @@ -1160,20 +1161,20 @@ void InitExternalInterfaceFMUImport(EnergyPlusData &state) std::vector workingFolderArr(getCharArrayFromString(workingFolderStr)); // make the library call - state.dataExternalInterface->FMU(i).Instance(j).Index = - model_ID_GUID((char *)state.dataExternalInterface->FMU(i).Instance(j).Name.c_str(), + fmuInst.Index = + model_ID_GUID((char *)fmuInst.Name.c_str(), &workingFolderArr[0], - &state.dataExternalInterface->FMU(i).Instance(j).LenWorkingFolder, - &state.dataExternalInterface->FMU(i).Instance(j).NumInputVariablesInFMU, - &state.dataExternalInterface->FMU(i).Instance(j).NumOutputVariablesInFMU); + &fmuInst.LenWorkingFolder, + &fmuInst.NumInputVariablesInFMU, + &fmuInst.NumOutputVariablesInFMU); - if (state.dataExternalInterface->FMU(i).Instance(j).Index < 0) { + if (fmuInst.Index < 0) { ShowSevereError(state, "ExternalInterface/InitExternalInterfaceFMUImport: Error when trying to"); ShowContinueError(state, "get the model ID and model GUID"); ShowContinueError(state, format("of instance \"{}\" of FMU \"{}\".", - state.dataExternalInterface->FMU(i).Instance(j).Name, - state.dataExternalInterface->FMU(i).Name)); + fmuInst.Name, + fmu.Name)); ShowContinueError(state, "Check if modelDescription.xml exists in the folder where the FMU has been unpacked."); state.dataExternalInterface->ErrorsFound = true; StopExternalInterfaceIfError(state); @@ -1194,11 +1195,11 @@ void InitExternalInterfaceFMUImport(EnergyPlusData &state) // make the library call int retValfmiPathLib = addLibPathCurrentWorkingFolder(&workingFolderWithLibArr[0], &workingFolderArr[0], - &state.dataExternalInterface->FMU(i).Instance(j).LenWorkingFolder, - &state.dataExternalInterface->FMU(i).Instance(j).Index); + &fmuInst.LenWorkingFolder, + &fmuInst.Index); // post process args in case they are used later - state.dataExternalInterface->FMU(i).Instance(j).WorkingFolder_wLib = + fmuInst.WorkingFolder_wLib = fs::path(trim(getStringFromCharArray(workingFolderWithLibArr))); if (retValfmiPathLib != 0) { @@ -1206,54 +1207,54 @@ void InitExternalInterfaceFMUImport(EnergyPlusData &state) ShowContinueError(state, "get the path to the binaries of instance"); ShowContinueError(state, format("\"{}\" of FMU \"{}\".", - state.dataExternalInterface->FMU(i).Instance(j).Name, - state.dataExternalInterface->FMU(i).Name)); + fmuInst.Name, + fmu.Name)); ShowContinueError(state, "Check if binaries folder exists where the FMU has been unpacked."); state.dataExternalInterface->ErrorsFound = true; StopExternalInterfaceIfError(state); } // get the length of the working folder with libraries - state.dataExternalInterface->FMU(i).Instance(j).LenWorkingFolder_wLib = - FileSystem::toString(state.dataExternalInterface->FMU(i).Instance(j).WorkingFolder_wLib).length(); + fmuInst.LenWorkingFolder_wLib = + FileSystem::toString(fmuInst.WorkingFolder_wLib).length(); } { // determine the FMI version // preprocess args for library call std::vector workingFolderWithLibArr( - getCharArrayFromString(FileSystem::toString(state.dataExternalInterface->FMU(i).Instance(j).WorkingFolder_wLib))); + getCharArrayFromString(FileSystem::toString(fmuInst.WorkingFolder_wLib))); std::vector VersionNumArr( getCharArrayFromString(" ")); // the version should only be 3 characters long, since for now we only handle "1.0" // make the library call int retValfmiVersion = getfmiEPlusVersion(&workingFolderWithLibArr[0], - &state.dataExternalInterface->FMU(i).Instance(j).LenWorkingFolder_wLib, + &fmuInst.LenWorkingFolder_wLib, &VersionNumArr[0], - &state.dataExternalInterface->FMU(i).Instance(j).Index); + &fmuInst.Index); // post process in case args are used later - state.dataExternalInterface->FMU(i).Instance(j).fmiVersionNumber = getStringFromCharArray(VersionNumArr); + fmuInst.fmiVersionNumber = getStringFromCharArray(VersionNumArr); if (retValfmiVersion != 0) { ShowSevereError(state, "ExternalInterface/InitExternalInterfaceFMUImport: Error when trying to"); ShowContinueError(state, "load FMI functions library of instance"); ShowContinueError(state, format("\"{}\" of FMU \"{}\".", - state.dataExternalInterface->FMU(i).Instance(j).Name, - state.dataExternalInterface->FMU(i).Name)); - ShowContinueError(state, format("\"{}\".", state.dataExternalInterface->FMU(i).Instance(j).fmiVersionNumber)); + fmuInst.Name, + fmu.Name)); + ShowContinueError(state, format("\"{}\".", fmuInst.fmiVersionNumber)); state.dataExternalInterface->ErrorsFound = true; StopExternalInterfaceIfError(state); } - if (state.dataExternalInterface->FMU(i).Instance(j).fmiVersionNumber.substr(0, 3) != "1.0") { + if (fmuInst.fmiVersionNumber.substr(0, 3) != "1.0") { ShowSevereError(state, "ExternalInterface/InitExternalInterfaceFMUImport: Error when getting version"); - ShowContinueError(state, format("number of instance \"{}\"", state.dataExternalInterface->FMU(i).Instance(j).Name)); - ShowContinueError(state, format("of FMU \"{}\".", state.dataExternalInterface->FMU(i).Name)); + ShowContinueError(state, format("number of instance \"{}\"", fmuInst.Name)); + ShowContinueError(state, format("of FMU \"{}\".", fmu.Name)); ShowContinueError(state, format("The version number found (\"{}\")", - state.dataExternalInterface->FMU(i).Instance(j).fmiVersionNumber.substr(0, 3))); + fmuInst.fmiVersionNumber.substr(0, 3))); ShowContinueError(state, "differs from version 1.0 which is currently supported."); state.dataExternalInterface->ErrorsFound = true; StopExternalInterfaceIfError(state); @@ -1267,11 +1268,13 @@ void InitExternalInterfaceFMUImport(EnergyPlusData &state) state.dataExternalInterface->UniqueFMUInputVarNames.reserve(static_cast(NumFMUInputVariables)); for (int i = 1; i <= state.dataExternalInterface->NumFMUObjects; ++i) { - for (int j = 1; j <= state.dataExternalInterface->FMU(i).NumInstances; ++j) { - state.dataExternalInterface->FMU(i).Instance(j).fmuInputVariable.allocate(NumFMUInputVariables); - state.dataExternalInterface->FMU(i).Instance(j).checkfmuInputVariable.allocate(NumFMUInputVariables); + auto &fmu = state.dataExternalInterface->FMU(i); + for (int j = 1; j <= fmu.NumInstances; ++j) { + auto &fmuInst = fmu.Instance(j); + fmuInst.fmuInputVariable.allocate(NumFMUInputVariables); + fmuInst.checkfmuInputVariable.allocate(NumFMUInputVariables); state.dataExternalInterface->UniqueFMUInputVarNames.clear(); - state.dataExternalInterface->FMU(i).Instance(j).eplusOutputVariable.allocate(NumFMUInputVariables); + fmuInst.eplusOutputVariable.allocate(NumFMUInputVariables); int k = 1; for (int l = 1; l <= NumFMUInputVariables; ++l) { state.dataInputProcessing->inputProcessor->getObjectItem(state, @@ -1286,17 +1289,17 @@ void InitExternalInterfaceFMUImport(EnergyPlusData &state) _, state.dataIPShortCut->cAlphaFieldNames, state.dataIPShortCut->cNumericFieldNames); - if (Util::SameString(state.dataIPShortCut->cAlphaArgs(3), state.dataExternalInterface->FMU(i).Name) && - Util::SameString(state.dataIPShortCut->cAlphaArgs(4), state.dataExternalInterface->FMU(i).Instance(j).Name)) { - state.dataExternalInterface->FMU(i).Instance(j).fmuInputVariable(k).Name = state.dataIPShortCut->cAlphaArgs(5); - state.dataExternalInterface->FMU(i).Instance(j).eplusOutputVariable(k).VarKey = state.dataIPShortCut->cAlphaArgs(1); - state.dataExternalInterface->FMU(i).Instance(j).eplusOutputVariable(k).Name = state.dataIPShortCut->cAlphaArgs(2); + if (Util::SameString(state.dataIPShortCut->cAlphaArgs(3), fmu.Name) && + Util::SameString(state.dataIPShortCut->cAlphaArgs(4), fmuInst.Name)) { + fmuInst.fmuInputVariable(k).Name = state.dataIPShortCut->cAlphaArgs(5); + fmuInst.eplusOutputVariable(k).VarKey = state.dataIPShortCut->cAlphaArgs(1); + fmuInst.eplusOutputVariable(k).Name = state.dataIPShortCut->cAlphaArgs(2); // verify whether we have duplicate FMU input variables in the idf GlobalNames::VerifyUniqueInterObjectName(state, state.dataExternalInterface->UniqueFMUInputVarNames, - state.dataExternalInterface->FMU(i).Instance(j).fmuInputVariable(k).Name, + fmuInst.fmuInputVariable(k).Name, cCurrentModuleObject, - state.dataExternalInterface->FMU(i).Instance(j).Name, + fmuInst.Name, state.dataExternalInterface->ErrorsFound); // Util::VerifyName( state.dataExternalInterface->FMU( i ).Instance( j // ).fmuInputVariable( @@ -1313,45 +1316,45 @@ void InitExternalInterfaceFMUImport(EnergyPlusData &state) if (state.dataExternalInterface->ErrorsFound) { StopExternalInterfaceIfError(state); } else { - state.dataExternalInterface->FMU(i).Instance(j).checkfmuInputVariable(k).Name = - state.dataExternalInterface->FMU(i).Instance(j).fmuInputVariable(k).Name; + fmuInst.checkfmuInputVariable(k).Name = + fmuInst.fmuInputVariable(k).Name; } // preprocess args for library call std::vector inputVarNameArr( - getCharArrayFromString(state.dataExternalInterface->FMU(i).Instance(j).fmuInputVariable(k).Name)); - int inputVarNameLen(len(state.dataExternalInterface->FMU(i).Instance(j).fmuInputVariable(k).Name)); + getCharArrayFromString(fmuInst.fmuInputVariable(k).Name)); + int inputVarNameLen(len(fmuInst.fmuInputVariable(k).Name)); // make the library call - state.dataExternalInterface->FMU(i).Instance(j).fmuInputVariable(k).ValueReference = getValueReferenceByNameFMUInputVariables( - &inputVarNameArr[0], &inputVarNameLen, &state.dataExternalInterface->FMU(i).Instance(j).Index); + fmuInst.fmuInputVariable(k).ValueReference = getValueReferenceByNameFMUInputVariables( + &inputVarNameArr[0], &inputVarNameLen, &fmuInst.Index); // postprocess args in case they are used later - state.dataExternalInterface->FMU(i).Instance(j).fmuInputVariable(k).Name = getStringFromCharArray(inputVarNameArr); + fmuInst.fmuInputVariable(k).Name = getStringFromCharArray(inputVarNameArr); - if (state.dataExternalInterface->FMU(i).Instance(j).fmuInputVariable(k).ValueReference == -999) { + if (fmuInst.fmuInputVariable(k).ValueReference == -999) { ShowSevereError(state, "ExternalInterface/InitExternalInterfaceFMUImport: Error when trying to"); ShowContinueError(state, "get the value reference of FMU input variable"); ShowContinueError(state, format("\"{}\" of instance \"{}\" of FMU", - state.dataExternalInterface->FMU(i).Instance(j).fmuInputVariable(k).Name, - state.dataExternalInterface->FMU(i).Instance(j).Name)); + fmuInst.fmuInputVariable(k).Name, + fmuInst.Name)); ShowContinueError( - state, format("of FMU \"{}\". Please check the name of input variable", state.dataExternalInterface->FMU(i).Name)); + state, format("of FMU \"{}\". Please check the name of input variable", fmu.Name)); ShowContinueError(state, "in the input file and in the modelDescription file."); state.dataExternalInterface->ErrorsFound = true; StopExternalInterfaceIfError(state); } - if (state.dataExternalInterface->FMU(i).Instance(j).fmuInputVariable(k).ValueReference == -1) { + if (fmuInst.fmuInputVariable(k).ValueReference == -1) { ShowSevereError(state, "ExternalInterface/InitExternalInterfaceFMUImport: Error when trying to"); ShowContinueError(state, "get the value reference of FMU input variable"); ShowContinueError(state, format("\"{}\" of instance \"{}\" of FMU", - state.dataExternalInterface->FMU(i).Instance(j).fmuInputVariable(k).Name, - state.dataExternalInterface->FMU(i).Instance(j).Name)); + fmuInst.fmuInputVariable(k).Name, + fmuInst.Name)); ShowContinueError( - state, format("\"{}\". This variable is not an FMU input variable.", state.dataExternalInterface->FMU(i).Name)); + state, format("\"{}\". This variable is not an FMU input variable.", fmu.Name)); ShowContinueError(state, "Please check the causality of the variable in the modelDescription file."); state.dataExternalInterface->ErrorsFound = true; StopExternalInterfaceIfError(state); @@ -1359,28 +1362,28 @@ void InitExternalInterfaceFMUImport(EnergyPlusData &state) // The next call expects an array, but a single item is passed // Therefore create a single item array here first - Array1D_string tempSingleStringA(1, state.dataExternalInterface->FMU(i).Instance(j).eplusOutputVariable(k).VarKey); - Array1D_string tempSingleStringB(1, state.dataExternalInterface->FMU(i).Instance(j).eplusOutputVariable(k).Name); + Array1D_string tempSingleStringA(1, fmuInst.eplusOutputVariable(k).VarKey); + Array1D_string tempSingleStringB(1, fmuInst.eplusOutputVariable(k).Name); // Make the call with arrays GetReportVariableKey(state, tempSingleStringA, 1, tempSingleStringB, keyIndexes, varTypes); // Then postprocess the array items back in case they changed - state.dataExternalInterface->FMU(i).Instance(j).eplusOutputVariable(k).VarKey = tempSingleStringA(1); - state.dataExternalInterface->FMU(i).Instance(j).eplusOutputVariable(k).Name = tempSingleStringB(1); + fmuInst.eplusOutputVariable(k).VarKey = tempSingleStringA(1); + fmuInst.eplusOutputVariable(k).Name = tempSingleStringB(1); - state.dataExternalInterface->FMU(i).Instance(j).eplusOutputVariable(k).VarIndex = keyIndexes(1); - state.dataExternalInterface->FMU(i).Instance(j).eplusOutputVariable(k).VarType = varTypes(1); - state.dataExternalInterface->FMU(i).Instance(j).NumInputVariablesInIDF = k; + fmuInst.eplusOutputVariable(k).VarIndex = keyIndexes(1); + fmuInst.eplusOutputVariable(k).VarType = varTypes(1); + fmuInst.NumInputVariablesInIDF = k; ++k; } } - if (NumFMUInputVariables > 0 && state.dataExternalInterface->FMU(i).Instance(j).NumInputVariablesInIDF == 0) { + if (NumFMUInputVariables > 0 && fmuInst.NumInputVariablesInIDF == 0) { ShowWarningError(state, format("InitExternalInterfaceFMUImport: The instance \"{}\" of FMU \"{}\"", - state.dataExternalInterface->FMU(i).Instance(j).Name, - state.dataExternalInterface->FMU(i).Name)); + fmuInst.Name, + fmu.Name)); ShowContinueError(state, "is defined but has no input variables. Check the input field of the"); ShowContinueError(state, "corresponding object: ExternalInterface:FunctionalMockupUnitImport:From:Variable."); } @@ -1388,33 +1391,35 @@ void InitExternalInterfaceFMUImport(EnergyPlusData &state) } for (int i = 1; i <= state.dataExternalInterface->NumFMUObjects; ++i) { - for (int j = 1; j <= state.dataExternalInterface->FMU(i).NumInstances; ++j) { + auto &fmu = state.dataExternalInterface->FMU(i); + for (int j = 1; j <= fmu.NumInstances; ++j) { + auto &fmuInst = fmu.Instance(j); // check whether the number of input variables in fmu is bigger than in the idf - if (state.dataExternalInterface->FMU(i).Instance(j).NumInputVariablesInFMU > - state.dataExternalInterface->FMU(i).Instance(j).NumInputVariablesInIDF) { + if (fmuInst.NumInputVariablesInFMU > + fmuInst.NumInputVariablesInIDF) { ShowWarningError(state, format("InitExternalInterfaceFMUImport: The number of input variables defined in input file ({})", - state.dataExternalInterface->FMU(i).Instance(j).NumInputVariablesInIDF)); + fmuInst.NumInputVariablesInIDF)); ShowContinueError(state, format("of instance \"{}\" of FMU \"{}\" is less than the number of input variables", - state.dataExternalInterface->FMU(i).Instance(j).Name, - state.dataExternalInterface->FMU(i).Name)); + fmuInst.Name, + fmu.Name)); ShowContinueError( - state, format("in the modelDescription file ({}).", state.dataExternalInterface->FMU(i).Instance(j).NumInputVariablesInFMU)); + state, format("in the modelDescription file ({}).", fmuInst.NumInputVariablesInFMU)); ShowContinueError(state, "Check the input file and the modelDescription file again."); } // check whether the number of input variables in fmu is less than in the idf - if (state.dataExternalInterface->FMU(i).Instance(j).NumInputVariablesInFMU < - state.dataExternalInterface->FMU(i).Instance(j).NumInputVariablesInIDF) { + if (fmuInst.NumInputVariablesInFMU < + fmuInst.NumInputVariablesInIDF) { ShowWarningError(state, format("InitExternalInterfaceFMUImport: The number of input variables defined in input file ({})", - state.dataExternalInterface->FMU(i).Instance(j).NumInputVariablesInIDF)); + fmuInst.NumInputVariablesInIDF)); ShowContinueError(state, format("of instance \"{}\" of FMU \"{}\" is bigger than the number of input variables", - state.dataExternalInterface->FMU(i).Instance(j).Name, - state.dataExternalInterface->FMU(i).Name)); + fmuInst.Name, + fmu.Name)); ShowContinueError( - state, format("in the modelDescription file ({}).", state.dataExternalInterface->FMU(i).Instance(j).NumInputVariablesInFMU)); + state, format("in the modelDescription file ({}).", fmuInst.NumInputVariablesInFMU)); ShowContinueError(state, "Check the input file and the modelDescription file again."); } } @@ -1426,6 +1431,7 @@ void InitExternalInterfaceFMUImport(EnergyPlusData &state) NumFMUInputVariables = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); for (int i = 1; i <= state.dataExternalInterface->NumFMUObjects; ++i) { + auto &fmu = state.dataExternalInterface->FMU(i); int j = 1; for (int k = 1; k <= NumFMUInputVariables; ++k) { state.dataInputProcessing->inputProcessor->getObjectItem(state, @@ -1440,17 +1446,19 @@ void InitExternalInterfaceFMUImport(EnergyPlusData &state) _, state.dataIPShortCut->cAlphaFieldNames, state.dataIPShortCut->cNumericFieldNames); - if (Util::SameString(state.dataIPShortCut->cAlphaArgs(3), state.dataExternalInterface->FMU(i).Name)) { - state.dataExternalInterface->FMU(i).TotNumOutputVariablesSchedule = j; + if (Util::SameString(state.dataIPShortCut->cAlphaArgs(3), fmu.Name)) { + fmu.TotNumOutputVariablesSchedule = j; ++j; } } } for (int i = 1; i <= state.dataExternalInterface->NumFMUObjects; ++i) { - for (int j = 1; j <= state.dataExternalInterface->FMU(i).NumInstances; ++j) { - state.dataExternalInterface->FMU(i).Instance(j).fmuOutputVariableSchedule.allocate(NumFMUInputVariables); - state.dataExternalInterface->FMU(i).Instance(j).eplusInputVariableSchedule.allocate(NumFMUInputVariables); + auto &fmu = state.dataExternalInterface->FMU(i); + for (int j = 1; j <= fmu.NumInstances; ++j) { + auto &fmuInst = fmu.Instance(j); + fmuInst.fmuOutputVariableSchedule.allocate(NumFMUInputVariables); + fmuInst.eplusInputVariableSchedule.allocate(NumFMUInputVariables); int k = 1; for (int l = 1; l <= NumFMUInputVariables; ++l) { state.dataInputProcessing->inputProcessor->getObjectItem(state, @@ -1465,67 +1473,67 @@ void InitExternalInterfaceFMUImport(EnergyPlusData &state) _, state.dataIPShortCut->cAlphaFieldNames, state.dataIPShortCut->cNumericFieldNames); - if (Util::SameString(state.dataIPShortCut->cAlphaArgs(3), state.dataExternalInterface->FMU(i).Name) && - Util::SameString(state.dataIPShortCut->cAlphaArgs(4), state.dataExternalInterface->FMU(i).Instance(j).Name)) { - state.dataExternalInterface->FMU(i).Instance(j).fmuOutputVariableSchedule(k).Name = state.dataIPShortCut->cAlphaArgs(5); - state.dataExternalInterface->FMU(i).Instance(j).eplusInputVariableSchedule(k).Name = state.dataIPShortCut->cAlphaArgs(1); - state.dataExternalInterface->FMU(i).Instance(j).eplusInputVariableSchedule(k).InitialValue = + if (Util::SameString(state.dataIPShortCut->cAlphaArgs(3), fmu.Name) && + Util::SameString(state.dataIPShortCut->cAlphaArgs(4), fmuInst.Name)) { + fmuInst.fmuOutputVariableSchedule(k).Name = state.dataIPShortCut->cAlphaArgs(5); + fmuInst.eplusInputVariableSchedule(k).Name = state.dataIPShortCut->cAlphaArgs(1); + fmuInst.eplusInputVariableSchedule(k).InitialValue = state.dataIPShortCut->rNumericArgs(1); // get the value reference by using the FMU name and the variable name. // preprocess the arguments before the following library call std::vector NameCharArr( - getCharArrayFromString(state.dataExternalInterface->FMU(i).Instance(j).fmuOutputVariableSchedule(k).Name)); - int lengthVar(len(state.dataExternalInterface->FMU(i).Instance(j).fmuOutputVariableSchedule(k).Name)); + getCharArrayFromString(fmuInst.fmuOutputVariableSchedule(k).Name)); + int lengthVar(len(fmuInst.fmuOutputVariableSchedule(k).Name)); // make the library call - state.dataExternalInterface->FMU(i).Instance(j).fmuOutputVariableSchedule(k).ValueReference = + fmuInst.fmuOutputVariableSchedule(k).ValueReference = getValueReferenceByNameFMUOutputVariables( - &NameCharArr[0], &lengthVar, &state.dataExternalInterface->FMU(i).Instance(j).Index); + &NameCharArr[0], &lengthVar, &fmuInst.Index); // postprocess the arguments after the library call in case they are changed and used later - state.dataExternalInterface->FMU(i).Instance(j).fmuOutputVariableSchedule(k).Name = getStringFromCharArray(NameCharArr); + fmuInst.fmuOutputVariableSchedule(k).Name = getStringFromCharArray(NameCharArr); - if (state.dataExternalInterface->FMU(i).Instance(j).fmuOutputVariableSchedule(k).ValueReference == -999) { + if (fmuInst.fmuOutputVariableSchedule(k).ValueReference == -999) { ShowSevereError(state, "ExternalInterface/InitExternalInterfaceFMUImport: Error when trying to get the value reference of " "the FMU output variable"); ShowContinueError(state, format("\"{}\" of instance \"{}\"", - state.dataExternalInterface->FMU(i).Instance(j).fmuOutputVariableSchedule(k).Name, - state.dataExternalInterface->FMU(i).Instance(j).Name)); + fmuInst.fmuOutputVariableSchedule(k).Name, + fmuInst.Name)); ShowContinueError(state, - format("of FMU \"{}\" that will be mapped to a schedule.", state.dataExternalInterface->FMU(i).Name)); + format("of FMU \"{}\" that will be mapped to a schedule.", fmu.Name)); ShowContinueError(state, "Please check the name of output variables in the input file and"); ShowContinueError(state, "in the modelDescription file."); state.dataExternalInterface->ErrorsFound = true; StopExternalInterfaceIfError(state); } - if (state.dataExternalInterface->FMU(i).Instance(j).fmuOutputVariableSchedule(k).ValueReference == -1) { + if (fmuInst.fmuOutputVariableSchedule(k).ValueReference == -1) { ShowSevereError(state, "ExternalInterface/InitExternalInterfaceFMUImport: Error when trying to get the value reference of " "the FMU output variable"); ShowContinueError(state, format("\"{}\" of instance \"{}\"", - state.dataExternalInterface->FMU(i).Instance(j).fmuOutputVariableSchedule(k).Name, - state.dataExternalInterface->FMU(i).Instance(j).Name)); + fmuInst.fmuOutputVariableSchedule(k).Name, + fmuInst.Name)); ShowContinueError(state, - format("of FMU \"{}\" that will be mapped to a schedule.", state.dataExternalInterface->FMU(i).Name)); + format("of FMU \"{}\" that will be mapped to a schedule.", fmu.Name)); ShowContinueError(state, "This variable is not an FMU output variable."); ShowContinueError(state, "Please check the causality of the variable in the modelDescription file."); state.dataExternalInterface->ErrorsFound = true; StopExternalInterfaceIfError(state); } - state.dataExternalInterface->FMU(i).Instance(j).eplusInputVariableSchedule(k).VarIndex = ScheduleManager::GetDayScheduleIndex( - state, state.dataExternalInterface->FMU(i).Instance(j).eplusInputVariableSchedule(k).Name); - state.dataExternalInterface->FMU(i).Instance(j).NumOutputVariablesSchedule = k; - if (state.dataExternalInterface->FMU(i).Instance(j).eplusInputVariableSchedule(k).VarIndex <= 0) { + fmuInst.eplusInputVariableSchedule(k).VarIndex = Sched::GetDayScheduleNum( + state, fmuInst.eplusInputVariableSchedule(k).Name); + fmuInst.NumOutputVariablesSchedule = k; + if (fmuInst.eplusInputVariableSchedule(k).VarIndex <= 0) { ShowSevereError(state, format("ExternalInterface/InitExternalInterfaceFMUImport:declares variable \"{}\",", - state.dataExternalInterface->FMU(i).Instance(j).eplusInputVariableSchedule(k).Name)); + fmuInst.eplusInputVariableSchedule(k).Name)); ShowContinueError(state, "but variable is not a schedule variable."); state.dataExternalInterface->ErrorsFound = true; StopExternalInterfaceIfError(state); @@ -1542,6 +1550,7 @@ void InitExternalInterfaceFMUImport(EnergyPlusData &state) NumFMUInputVariables = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); for (int i = 1; i <= state.dataExternalInterface->NumFMUObjects; ++i) { + auto &fmu = state.dataExternalInterface->FMU(i); int j = 1; for (int k = 1; k <= NumFMUInputVariables; ++k) { state.dataInputProcessing->inputProcessor->getObjectItem(state, @@ -1556,17 +1565,19 @@ void InitExternalInterfaceFMUImport(EnergyPlusData &state) _, state.dataIPShortCut->cAlphaFieldNames, state.dataIPShortCut->cNumericFieldNames); - if (Util::SameString(state.dataIPShortCut->cAlphaArgs(2), state.dataExternalInterface->FMU(i).Name)) { - state.dataExternalInterface->FMU(i).TotNumOutputVariablesVariable = j; + if (Util::SameString(state.dataIPShortCut->cAlphaArgs(2), fmu.Name)) { + fmu.TotNumOutputVariablesVariable = j; ++j; } } } for (int i = 1; i <= state.dataExternalInterface->NumFMUObjects; ++i) { - for (int j = 1; j <= state.dataExternalInterface->FMU(i).NumInstances; ++j) { - state.dataExternalInterface->FMU(i).Instance(j).fmuOutputVariableVariable.allocate(NumFMUInputVariables); - state.dataExternalInterface->FMU(i).Instance(j).eplusInputVariableVariable.allocate(NumFMUInputVariables); + auto &fmu = state.dataExternalInterface->FMU(i); + for (int j = 1; j <= fmu.NumInstances; ++j) { + auto &fmuInst = fmu.Instance(j); + fmuInst.fmuOutputVariableVariable.allocate(NumFMUInputVariables); + fmuInst.eplusInputVariableVariable.allocate(NumFMUInputVariables); int k = 1; for (int l = 1; l <= NumFMUInputVariables; ++l) { state.dataInputProcessing->inputProcessor->getObjectItem(state, @@ -1581,46 +1592,46 @@ void InitExternalInterfaceFMUImport(EnergyPlusData &state) _, state.dataIPShortCut->cAlphaFieldNames, state.dataIPShortCut->cNumericFieldNames); - if (Util::SameString(state.dataIPShortCut->cAlphaArgs(2), state.dataExternalInterface->FMU(i).Name) && - Util::SameString(state.dataIPShortCut->cAlphaArgs(3), state.dataExternalInterface->FMU(i).Instance(j).Name)) { - state.dataExternalInterface->FMU(i).Instance(j).fmuOutputVariableVariable(k).Name = state.dataIPShortCut->cAlphaArgs(4); - state.dataExternalInterface->FMU(i).Instance(j).eplusInputVariableVariable(k).Name = state.dataIPShortCut->cAlphaArgs(1); + if (Util::SameString(state.dataIPShortCut->cAlphaArgs(2), fmu.Name) && + Util::SameString(state.dataIPShortCut->cAlphaArgs(3), fmuInst.Name)) { + fmuInst.fmuOutputVariableVariable(k).Name = state.dataIPShortCut->cAlphaArgs(4); + fmuInst.eplusInputVariableVariable(k).Name = state.dataIPShortCut->cAlphaArgs(1); // get the value reference by using the FMU name and the variable name. std::vector NameCharArr( - getCharArrayFromString(state.dataExternalInterface->FMU(i).Instance(j).fmuOutputVariableVariable(k).Name)); - int tempLength(len(state.dataExternalInterface->FMU(i).Instance(j).fmuOutputVariableVariable(k).Name)); - state.dataExternalInterface->FMU(i).Instance(j).fmuOutputVariableVariable(k).ValueReference = + getCharArrayFromString(fmuInst.fmuOutputVariableVariable(k).Name)); + int tempLength(len(fmuInst.fmuOutputVariableVariable(k).Name)); + fmuInst.fmuOutputVariableVariable(k).ValueReference = getValueReferenceByNameFMUOutputVariables( - &NameCharArr[0], &tempLength, &state.dataExternalInterface->FMU(i).Instance(j).Index); + &NameCharArr[0], &tempLength, &fmuInst.Index); // state.dataExternalInterface->FMU( i ).Instance( j ).fmuOutputVariableVariable( k ).Name = getStringFromCharArray( // NameCharArr ); - if (state.dataExternalInterface->FMU(i).Instance(j).fmuOutputVariableVariable(k).ValueReference == -999) { + if (fmuInst.fmuOutputVariableVariable(k).ValueReference == -999) { ShowSevereError(state, "ExternalInterface/InitExternalInterfaceFMUImport: Error when trying to get the value reference of " "the FMU output variable"); ShowContinueError(state, format("\"{}\" of instance \"{}\"", - state.dataExternalInterface->FMU(i).Instance(j).fmuOutputVariableVariable(k).Name, - state.dataExternalInterface->FMU(i).Instance(j).Name)); + fmuInst.fmuOutputVariableVariable(k).Name, + fmuInst.Name)); ShowContinueError(state, - format("of FMU \"{}\" that will be mapped to a variable.", state.dataExternalInterface->FMU(i).Name)); + format("of FMU \"{}\" that will be mapped to a variable.", fmu.Name)); ShowContinueError(state, "Please check the name of output variables in the input file and in the modelDescription file."); state.dataExternalInterface->ErrorsFound = true; StopExternalInterfaceIfError(state); } - if (state.dataExternalInterface->FMU(i).Instance(j).fmuOutputVariableVariable(k).ValueReference == -1) { + if (fmuInst.fmuOutputVariableVariable(k).ValueReference == -1) { ShowSevereError(state, "ExternalInterface/InitExternalInterfaceFMUImport: Error when trying to get the value reference of " "the FMU output variable"); ShowContinueError(state, format("\"{}\" of instance \"{}\"", - state.dataExternalInterface->FMU(i).Instance(j).fmuOutputVariableVariable(k).Name, - state.dataExternalInterface->FMU(i).Instance(j).Name)); + fmuInst.fmuOutputVariableVariable(k).Name, + fmuInst.Name)); ShowContinueError(state, - format("of FMU \"{}\" that will be mapped to a variable.", state.dataExternalInterface->FMU(i).Name)); + format("of FMU \"{}\" that will be mapped to a variable.", fmu.Name)); ShowContinueError(state, "This variable is not an FMU output variable. Please check the causality of the variable in the " "modelDescription file."); @@ -1628,14 +1639,14 @@ void InitExternalInterfaceFMUImport(EnergyPlusData &state) StopExternalInterfaceIfError(state); } - state.dataExternalInterface->FMU(i).Instance(j).eplusInputVariableVariable(k).VarIndex = + fmuInst.eplusInputVariableVariable(k).VarIndex = RuntimeLanguageProcessor::FindEMSVariable( - state, state.dataExternalInterface->FMU(i).Instance(j).eplusInputVariableVariable(k).Name, 0); - state.dataExternalInterface->FMU(i).Instance(j).NumOutputVariablesVariable = k; - if (state.dataExternalInterface->FMU(i).Instance(j).eplusInputVariableVariable(k).VarIndex <= 0) { + state, fmuInst.eplusInputVariableVariable(k).Name, 0); + fmuInst.NumOutputVariablesVariable = k; + if (fmuInst.eplusInputVariableVariable(k).VarIndex <= 0) { ShowSevereError(state, format("ExternalInterface/InitExternalInterfaceFMUImport:declares variable \"{}\",", - state.dataExternalInterface->FMU(i).Instance(j).eplusInputVariableVariable(k).Name)); + fmuInst.eplusInputVariableVariable(k).Name)); ShowContinueError(state, "but variable is not an EMS variable."); state.dataExternalInterface->ErrorsFound = true; StopExternalInterfaceIfError(state); @@ -1643,7 +1654,7 @@ void InitExternalInterfaceFMUImport(EnergyPlusData &state) ++k; } } - if (state.dataExternalInterface->FMU(i).Instance(j).NumOutputVariablesVariable >= 1) { + if (fmuInst.NumOutputVariablesVariable >= 1) { state.dataExternalInterface->useEMS = true; } } @@ -1655,6 +1666,7 @@ void InitExternalInterfaceFMUImport(EnergyPlusData &state) NumFMUInputVariables = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); for (int i = 1; i <= state.dataExternalInterface->NumFMUObjects; ++i) { + auto &fmu = state.dataExternalInterface->FMU(i); int j = 1; for (int k = 1; k <= NumFMUInputVariables; ++k) { state.dataInputProcessing->inputProcessor->getObjectItem(state, @@ -1669,17 +1681,19 @@ void InitExternalInterfaceFMUImport(EnergyPlusData &state) _, state.dataIPShortCut->cAlphaFieldNames, state.dataIPShortCut->cNumericFieldNames); - if (Util::SameString(state.dataIPShortCut->cAlphaArgs(5), state.dataExternalInterface->FMU(i).Name)) { - state.dataExternalInterface->FMU(i).TotNumOutputVariablesActuator = j; + if (Util::SameString(state.dataIPShortCut->cAlphaArgs(5), fmu.Name)) { + fmu.TotNumOutputVariablesActuator = j; ++j; } } } for (int i = 1; i <= state.dataExternalInterface->NumFMUObjects; ++i) { - for (int j = 1; j <= state.dataExternalInterface->FMU(i).NumInstances; ++j) { - state.dataExternalInterface->FMU(i).Instance(j).fmuOutputVariableActuator.allocate(NumFMUInputVariables); - state.dataExternalInterface->FMU(i).Instance(j).eplusInputVariableActuator.allocate(NumFMUInputVariables); + auto &fmu = state.dataExternalInterface->FMU(i); + for (int j = 1; j <= fmu.NumInstances; ++j) { + auto &fmuInst = fmu.Instance(j); + fmuInst.fmuOutputVariableActuator.allocate(NumFMUInputVariables); + fmuInst.eplusInputVariableActuator.allocate(NumFMUInputVariables); int k = 1; for (int l = 1; l <= NumFMUInputVariables; ++l) { state.dataInputProcessing->inputProcessor->getObjectItem(state, @@ -1694,46 +1708,46 @@ void InitExternalInterfaceFMUImport(EnergyPlusData &state) _, state.dataIPShortCut->cAlphaFieldNames, state.dataIPShortCut->cNumericFieldNames); - if (Util::SameString(state.dataIPShortCut->cAlphaArgs(5), state.dataExternalInterface->FMU(i).Name) && - Util::SameString(state.dataIPShortCut->cAlphaArgs(6), state.dataExternalInterface->FMU(i).Instance(j).Name)) { - state.dataExternalInterface->FMU(i).Instance(j).fmuOutputVariableActuator(k).Name = state.dataIPShortCut->cAlphaArgs(7); - state.dataExternalInterface->FMU(i).Instance(j).eplusInputVariableActuator(k).Name = state.dataIPShortCut->cAlphaArgs(1); + if (Util::SameString(state.dataIPShortCut->cAlphaArgs(5), fmu.Name) && + Util::SameString(state.dataIPShortCut->cAlphaArgs(6), fmuInst.Name)) { + fmuInst.fmuOutputVariableActuator(k).Name = state.dataIPShortCut->cAlphaArgs(7); + fmuInst.eplusInputVariableActuator(k).Name = state.dataIPShortCut->cAlphaArgs(1); // get the value reference by using the FMU name and the variable name. std::vector tempNameArr( - getCharArrayFromString(state.dataExternalInterface->FMU(i).Instance(j).fmuOutputVariableActuator(k).Name)); - int tempLength(len(state.dataExternalInterface->FMU(i).Instance(j).fmuOutputVariableActuator(k).Name)); - state.dataExternalInterface->FMU(i).Instance(j).fmuOutputVariableActuator(k).ValueReference = + getCharArrayFromString(fmuInst.fmuOutputVariableActuator(k).Name)); + int tempLength(len(fmuInst.fmuOutputVariableActuator(k).Name)); + fmuInst.fmuOutputVariableActuator(k).ValueReference = getValueReferenceByNameFMUOutputVariables( - &tempNameArr[0], &tempLength, &state.dataExternalInterface->FMU(i).Instance(j).Index); + &tempNameArr[0], &tempLength, &fmuInst.Index); // state.dataExternalInterface->FMU( i ).Instance( j ).fmuOutputVariableActuator( k ).Name = getStringFromCharArray( // tempNameArr ); - if (state.dataExternalInterface->FMU(i).Instance(j).fmuOutputVariableActuator(k).ValueReference == -999) { + if (fmuInst.fmuOutputVariableActuator(k).ValueReference == -999) { ShowSevereError(state, "ExternalInterface/InitExternalInterfaceFMUImport: Error when trying to get the value reference of " "the FMU output variable"); ShowContinueError(state, format("\"{}\" of instance \"{}\"", - state.dataExternalInterface->FMU(i).Instance(j).fmuOutputVariableActuator(k).Name, - state.dataExternalInterface->FMU(i).Instance(j).Name)); + fmuInst.fmuOutputVariableActuator(k).Name, + fmuInst.Name)); ShowContinueError(state, - format("of FMU \"{}\" that will be mapped to an actuator.", state.dataExternalInterface->FMU(i).Name)); + format("of FMU \"{}\" that will be mapped to an actuator.", fmu.Name)); ShowContinueError(state, "Please check the name of output variables in the input file and in the modelDescription file."); state.dataExternalInterface->ErrorsFound = true; StopExternalInterfaceIfError(state); } - if (state.dataExternalInterface->FMU(i).Instance(j).fmuOutputVariableActuator(k).ValueReference == -1) { + if (fmuInst.fmuOutputVariableActuator(k).ValueReference == -1) { ShowSevereError(state, "ExternalInterface/InitExternalInterfaceFMUImport: Error when trying to get the value reference of " "the FMU output variable"); ShowContinueError(state, format("\"{}\" of instance \"{}\"", - state.dataExternalInterface->FMU(i).Instance(j).fmuOutputVariableActuator(k).Name, - state.dataExternalInterface->FMU(i).Instance(j).Name)); + fmuInst.fmuOutputVariableActuator(k).Name, + fmuInst.Name)); ShowContinueError(state, - format("of FMU \"{}\" that will be mapped to an actuator.", state.dataExternalInterface->FMU(i).Name)); + format("of FMU \"{}\" that will be mapped to an actuator.", fmu.Name)); ShowContinueError(state, "This variable is not an FMU output variable. Please check the causality of the variable in the " "modelDescription file."); @@ -1741,14 +1755,14 @@ void InitExternalInterfaceFMUImport(EnergyPlusData &state) StopExternalInterfaceIfError(state); } - state.dataExternalInterface->FMU(i).Instance(j).eplusInputVariableActuator(k).VarIndex = + fmuInst.eplusInputVariableActuator(k).VarIndex = RuntimeLanguageProcessor::FindEMSVariable( - state, state.dataExternalInterface->FMU(i).Instance(j).eplusInputVariableActuator(k).Name, 0); - state.dataExternalInterface->FMU(i).Instance(j).NumOutputVariablesActuator = k; - if (state.dataExternalInterface->FMU(i).Instance(j).eplusInputVariableActuator(k).VarIndex <= 0) { + state, fmuInst.eplusInputVariableActuator(k).Name, 0); + fmuInst.NumOutputVariablesActuator = k; + if (fmuInst.eplusInputVariableActuator(k).VarIndex <= 0) { ShowSevereError(state, format("ExternalInterface/InitExternalInterfaceFMUImport:declares variable \"{}\",", - state.dataExternalInterface->FMU(i).Instance(j).eplusInputVariableActuator(k).Name)); + fmuInst.eplusInputVariableActuator(k).Name)); ShowContinueError(state, "but variable is not an EMS variable."); state.dataExternalInterface->ErrorsFound = true; StopExternalInterfaceIfError(state); @@ -1757,7 +1771,7 @@ void InitExternalInterfaceFMUImport(EnergyPlusData &state) } } // set the flag state.dataExternalInterface->useEMS to true. This will be used then to update the erl variables in erl data structure - if (state.dataExternalInterface->FMU(i).Instance(j).NumOutputVariablesActuator >= 1) { + if (fmuInst.NumOutputVariablesActuator >= 1) { state.dataExternalInterface->useEMS = true; } } @@ -1765,50 +1779,52 @@ void InitExternalInterfaceFMUImport(EnergyPlusData &state) // parse the fmu defined in the idf using the fmuUnpack with the flag --unpack. for (int i = 1; i <= state.dataExternalInterface->NumFMUObjects; ++i) { - for (int j = 1; j <= state.dataExternalInterface->FMU(i).NumInstances; ++j) { - state.dataExternalInterface->FMU(i).Instance(j).NumOutputVariablesInIDF = - state.dataExternalInterface->FMU(i).Instance(j).NumOutputVariablesSchedule + - state.dataExternalInterface->FMU(i).Instance(j).NumOutputVariablesVariable + - state.dataExternalInterface->FMU(i).Instance(j).NumOutputVariablesActuator; + auto &fmu = state.dataExternalInterface->FMU(i); + for (int j = 1; j <= fmu.NumInstances; ++j) { + auto &fmuInst = fmu.Instance(j); + fmuInst.NumOutputVariablesInIDF = + fmuInst.NumOutputVariablesSchedule + + fmuInst.NumOutputVariablesVariable + + fmuInst.NumOutputVariablesActuator; // check whether the number of output variables in fmu is bigger than in the idf - if (state.dataExternalInterface->FMU(i).Instance(j).NumOutputVariablesInFMU > - state.dataExternalInterface->FMU(i).Instance(j).NumOutputVariablesInIDF) { + if (fmuInst.NumOutputVariablesInFMU > + fmuInst.NumOutputVariablesInIDF) { ShowWarningError(state, format("InitExternalInterfaceFMUImport: The number of output variables defined in input file ({})", - state.dataExternalInterface->FMU(i).Instance(j).NumOutputVariablesInIDF)); + fmuInst.NumOutputVariablesInIDF)); ShowContinueError(state, format("of instance \"{}\" of FMU \"{}\" is less than the number of output variables", - state.dataExternalInterface->FMU(i).Instance(j).Name, - state.dataExternalInterface->FMU(i).Name)); + fmuInst.Name, + fmu.Name)); ShowContinueError( - state, format("in the modelDescription file ({}).", state.dataExternalInterface->FMU(i).Instance(j).NumOutputVariablesInFMU)); + state, format("in the modelDescription file ({}).", fmuInst.NumOutputVariablesInFMU)); ShowContinueError(state, "Check the input file and the modelDescription file again."); } // check whether the number of output variables in fmu is less than in the idf - if (state.dataExternalInterface->FMU(i).Instance(j).NumOutputVariablesInFMU < - state.dataExternalInterface->FMU(i).Instance(j).NumOutputVariablesInIDF) { + if (fmuInst.NumOutputVariablesInFMU < + fmuInst.NumOutputVariablesInIDF) { ShowWarningError(state, format("InitExternalInterfaceFMUImport: The number of output variables defined in input file ({})", - state.dataExternalInterface->FMU(i).Instance(j).NumOutputVariablesInIDF)); + fmuInst.NumOutputVariablesInIDF)); ShowContinueError(state, format("of instance \"{}\" of FMU \"{}\" is bigger than the number of output variables", - state.dataExternalInterface->FMU(i).Instance(j).Name, - state.dataExternalInterface->FMU(i).Name)); + fmuInst.Name, + fmu.Name)); ShowContinueError( - state, format("in the modelDescription file ({}).", state.dataExternalInterface->FMU(i).Instance(j).NumOutputVariablesInFMU)); + state, format("in the modelDescription file ({}).", fmuInst.NumOutputVariablesInFMU)); ShowContinueError(state, "Check the input file and the modelDescription file again."); } DisplayString(state, format("Number of inputs in instance \"{}\" of FMU \"{}\" = \"{}\".", - state.dataExternalInterface->FMU(i).Instance(j).Name, - state.dataExternalInterface->FMU(i).Name, - state.dataExternalInterface->FMU(i).Instance(j).NumInputVariablesInIDF)); + fmuInst.Name, + fmu.Name, + fmuInst.NumInputVariablesInIDF)); DisplayString(state, format("Number of outputs in instance \"{}\" of FMU \"{}\" = \"{}\".", - state.dataExternalInterface->FMU(i).Instance(j).Name, - state.dataExternalInterface->FMU(i).Name, - state.dataExternalInterface->FMU(i).Instance(j).NumOutputVariablesInIDF)); + fmuInst.Name, + fmu.Name, + fmuInst.NumOutputVariablesInIDF)); } } StopExternalInterfaceIfError(state); @@ -1964,20 +1980,22 @@ void CalcExternalInterfaceFMUImport(EnergyPlusData &state) // allocate memory for a temporary FMU that will be used at the end of the warmup state.dataExternalInterface->FMUTemp.allocate(state.dataExternalInterface->NumFMUObjects); for (int i = 1; i <= state.dataExternalInterface->NumFMUObjects; ++i) { - state.dataExternalInterface->FMUTemp(i).Instance.allocate(state.dataExternalInterface->FMU(i).NumInstances); + auto const &fmu = state.dataExternalInterface->FMU(i); + auto &fmuTemp = state.dataExternalInterface->FMUTemp(i); + fmuTemp.Instance.allocate(fmu.NumInstances); } for (int i = 1; i <= state.dataExternalInterface->NumFMUObjects; ++i) { - for (int j = 1; j <= state.dataExternalInterface->FMU(i).NumInstances; ++j) { - state.dataExternalInterface->FMUTemp(i).Instance(j).fmuInputVariable.allocate( - state.dataExternalInterface->FMU(i).Instance(j).NumInputVariablesInIDF); - state.dataExternalInterface->FMUTemp(i).Instance(j).eplusOutputVariable.allocate( - state.dataExternalInterface->FMU(i).Instance(j).NumInputVariablesInIDF); - state.dataExternalInterface->FMUTemp(i).Instance(j).fmuOutputVariableSchedule.allocate( - state.dataExternalInterface->FMU(i).Instance(j).NumOutputVariablesSchedule); - state.dataExternalInterface->FMUTemp(i).Instance(j).fmuOutputVariableVariable.allocate( - state.dataExternalInterface->FMU(i).Instance(j).NumOutputVariablesVariable); - state.dataExternalInterface->FMUTemp(i).Instance(j).fmuOutputVariableActuator.allocate( - state.dataExternalInterface->FMU(i).Instance(j).NumOutputVariablesActuator); + auto const &fmu = state.dataExternalInterface->FMU(i); + auto &fmuTemp = state.dataExternalInterface->FMUTemp(i); + for (int j = 1; j <= fmu.NumInstances; ++j) { + auto const &fmuInst = fmu.Instance(j); + auto &fmuTempInst = fmuTemp.Instance(j); + + fmuTempInst.fmuInputVariable.allocate(fmuInst.NumInputVariablesInIDF); + fmuTempInst.eplusOutputVariable.allocate(fmuInst.NumInputVariablesInIDF); + fmuTempInst.fmuOutputVariableSchedule.allocate(fmuInst.NumOutputVariablesSchedule); + fmuTempInst.fmuOutputVariableVariable.allocate(fmuInst.NumOutputVariablesVariable); + fmuTempInst.fmuOutputVariableActuator.allocate(fmuInst.NumOutputVariablesActuator); } } @@ -1992,43 +2010,36 @@ void CalcExternalInterfaceFMUImport(EnergyPlusData &state) state.dataExternalInterface->tComm += state.dataExternalInterface->hStep; } else { for (int i = 1; i <= state.dataExternalInterface->NumFMUObjects; ++i) { - for (int j = 1; j <= state.dataExternalInterface->FMU(i).NumInstances; ++j) { - - state.dataExternalInterface->FMUTemp(i).Instance(j).NumInputVariablesInIDF = - state.dataExternalInterface->FMU(i).Instance(j).NumInputVariablesInIDF; - for (int k = 1; k <= state.dataExternalInterface->FMU(i).Instance(j).NumInputVariablesInIDF; ++k) { - state.dataExternalInterface->FMUTemp(i).Instance(j).fmuInputVariable(k).ValueReference = - state.dataExternalInterface->FMU(i).Instance(j).fmuInputVariable(k).ValueReference; - state.dataExternalInterface->FMUTemp(i).Instance(j).eplusOutputVariable(k).RTSValue = - state.dataExternalInterface->FMU(i).Instance(j).eplusOutputVariable(k).RTSValue; - state.dataExternalInterface->FMUTemp(i).Instance(j).eplusOutputVariable(k).ITSValue = - state.dataExternalInterface->FMU(i).Instance(j).eplusOutputVariable(k).ITSValue; - state.dataExternalInterface->FMUTemp(i).Instance(j).eplusOutputVariable(k).VarType = - state.dataExternalInterface->FMU(i).Instance(j).eplusOutputVariable(k).VarType; + auto const &fmu = state.dataExternalInterface->FMU(i); + auto &fmuTemp = state.dataExternalInterface->FMUTemp(i); + for (int j = 1; j <= fmu.NumInstances; ++j) { + auto const &fmuInst = fmu.Instance(j); + auto &fmuTempInst = fmuTemp.Instance(j); + + fmuTempInst.NumInputVariablesInIDF = fmuInst.NumInputVariablesInIDF; + for (int k = 1; k <= fmuInst.NumInputVariablesInIDF; ++k) { + fmuTempInst.fmuInputVariable(k).ValueReference = fmuInst.fmuInputVariable(k).ValueReference; + fmuTempInst.eplusOutputVariable(k).RTSValue = fmuInst.eplusOutputVariable(k).RTSValue; + fmuTempInst.eplusOutputVariable(k).ITSValue = fmuInst.eplusOutputVariable(k).ITSValue; + fmuTempInst.eplusOutputVariable(k).VarType = fmuInst.eplusOutputVariable(k).VarType; } // save values that will be set in EnergyPlus (Schedule) - state.dataExternalInterface->FMUTemp(i).Instance(j).NumOutputVariablesSchedule = - state.dataExternalInterface->FMU(i).Instance(j).NumOutputVariablesSchedule; - for (int k = 1; k <= state.dataExternalInterface->FMU(i).Instance(j).NumOutputVariablesSchedule; ++k) { - state.dataExternalInterface->FMUTemp(i).Instance(j).fmuOutputVariableSchedule(k).RealVarValue = - state.dataExternalInterface->FMU(i).Instance(j).fmuOutputVariableSchedule(k).RealVarValue; + fmuTempInst.NumOutputVariablesSchedule = fmuInst.NumOutputVariablesSchedule; + for (int k = 1; k <= fmuInst.NumOutputVariablesSchedule; ++k) { + fmuTempInst.fmuOutputVariableSchedule(k).RealVarValue = fmuInst.fmuOutputVariableSchedule(k).RealVarValue; } // save values that will be set in EnergyPlus (Variable) - state.dataExternalInterface->FMUTemp(i).Instance(j).NumOutputVariablesVariable = - state.dataExternalInterface->FMU(i).Instance(j).NumOutputVariablesVariable; - for (int k = 1; k <= state.dataExternalInterface->FMU(i).Instance(j).NumOutputVariablesVariable; ++k) { - state.dataExternalInterface->FMUTemp(i).Instance(j).fmuOutputVariableVariable(k).RealVarValue = - state.dataExternalInterface->FMU(i).Instance(j).fmuOutputVariableVariable(k).RealVarValue; + fmuTempInst.NumOutputVariablesVariable = fmuInst.NumOutputVariablesVariable; + for (int k = 1; k <= fmuInst.NumOutputVariablesVariable; ++k) { + fmuTempInst.fmuOutputVariableVariable(k).RealVarValue = fmuInst.fmuOutputVariableVariable(k).RealVarValue; } // save values that will be set in EnergyPlus (Actuator) - state.dataExternalInterface->FMUTemp(i).Instance(j).NumOutputVariablesActuator = - state.dataExternalInterface->FMU(i).Instance(j).NumOutputVariablesActuator; - for (int k = 1; k <= state.dataExternalInterface->FMU(i).Instance(j).NumOutputVariablesActuator; ++k) { - state.dataExternalInterface->FMUTemp(i).Instance(j).fmuOutputVariableActuator(k).RealVarValue = - state.dataExternalInterface->FMU(i).Instance(j).fmuOutputVariableActuator(k).RealVarValue; + fmuTempInst.NumOutputVariablesActuator = fmuInst.NumOutputVariablesActuator; + for (int k = 1; k <= fmuInst.NumOutputVariablesActuator; ++k) { + fmuTempInst.fmuOutputVariableActuator(k).RealVarValue = fmuInst.fmuOutputVariableActuator(k).RealVarValue; } } } @@ -2046,35 +2057,36 @@ void CalcExternalInterfaceFMUImport(EnergyPlusData &state) // Set the values that have been saved in the FMUs-- saveFMUStateVariables () for (int i = 1; i <= state.dataExternalInterface->NumFMUObjects; ++i) { - for (int j = 1; j <= state.dataExternalInterface->FMU(i).NumInstances; ++j) { + auto &fmu = state.dataExternalInterface->FMU(i); + auto &fmuTemp = state.dataExternalInterface->FMUTemp(i); + for (int j = 1; j <= fmu.NumInstances; ++j) { + auto &fmuInst = fmu.Instance(j); + auto &fmuTempInst = fmuTemp.Instance(j); std::vector valRefVec; - for (unsigned long x = 1; x <= size(state.dataExternalInterface->FMU(i).Instance(j).fmuInputVariable); ++x) { - valRefVec.push_back(state.dataExternalInterface->FMU(i).Instance(j).fmuInputVariable(x).ValueReference); + for (unsigned long x = 1; x <= size(fmuInst.fmuInputVariable); ++x) { + valRefVec.push_back(fmuInst.fmuInputVariable(x).ValueReference); } std::vector rtsValVec; - for (unsigned long x = 1; x <= size(state.dataExternalInterface->FMU(i).Instance(j).eplusOutputVariable); ++x) { - rtsValVec.push_back(state.dataExternalInterface->FMU(i).Instance(j).eplusOutputVariable(x).RTSValue); + for (unsigned long x = 1; x <= size(fmuInst.eplusOutputVariable); ++x) { + rtsValVec.push_back(fmuInst.eplusOutputVariable(x).RTSValue); } // make the library call - state.dataExternalInterface->FMU(i).Instance(j).fmistatus = - fmiEPlusSetReal(&state.dataExternalInterface->FMU(i).Instance(j).fmicomponent, + fmuInst.fmistatus = + fmiEPlusSetReal(&fmuInst.fmicomponent, &valRefVec[0], &rtsValVec[0], - &state.dataExternalInterface->FMUTemp(i).Instance(j).NumInputVariablesInIDF, - &state.dataExternalInterface->FMU(i).Instance(j).Index); + &fmuTempInst.NumInputVariablesInIDF, + &fmuInst.Index); - if (state.dataExternalInterface->FMU(i).Instance(j).fmistatus != fmiOK) { + if (fmuInst.fmistatus != fmiOK) { ShowSevereError( state, format("ExternalInterface/CalcExternalInterfaceFMUImport: Error when trying to set an input value in instance \"{}\"", - state.dataExternalInterface->FMU(i).Instance(j).Name)); - ShowContinueError(state, - format("of FMU \"{}\"; Error Code = \"{}\"", - state.dataExternalInterface->FMU(i).Name, - state.dataExternalInterface->FMU(i).Instance(j).fmistatus)); + fmuInst.Name)); + ShowContinueError(state, format("of FMU \"{}\"; Error Code = \"{}\"", fmu.Name, fmuInst.fmistatus)); state.dataExternalInterface->ErrorsFound = true; StopExternalInterfaceIfError(state); } @@ -2109,34 +2121,38 @@ void CalcExternalInterfaceFMUImport(EnergyPlusData &state) // Set the values that have been saved in the FMUs-- saveFMUStateVariables () for (int i = 1; i <= state.dataExternalInterface->NumFMUObjects; ++i) { - for (int j = 1; j <= state.dataExternalInterface->FMU(i).NumInstances; ++j) { + auto &fmu = state.dataExternalInterface->FMU(i); + auto &fmuTemp = state.dataExternalInterface->FMUTemp(i); + for (int j = 1; j <= fmu.NumInstances; ++j) { + auto &fmuInst = fmu.Instance(j); + auto &fmuTempInst = fmuTemp.Instance(j); // make vectors first std::vector valRefVec; - for (unsigned long x = 1; x <= size(state.dataExternalInterface->FMUTemp(i).Instance(j).fmuInputVariable); ++x) { - valRefVec.push_back(state.dataExternalInterface->FMUTemp(i).Instance(j).fmuInputVariable(x).ValueReference); + for (unsigned long x = 1; x <= size(fmuTempInst.fmuInputVariable); ++x) { + valRefVec.push_back(fmuTempInst.fmuInputVariable(x).ValueReference); } std::vector rtsValVec; - for (unsigned long x = 1; x <= size(state.dataExternalInterface->FMUTemp(i).Instance(j).eplusOutputVariable); ++x) { - rtsValVec.push_back(state.dataExternalInterface->FMUTemp(i).Instance(j).eplusOutputVariable(x).RTSValue); + for (unsigned long x = 1; x <= size(fmuTempInst.eplusOutputVariable); ++x) { + rtsValVec.push_back(fmuTempInst.eplusOutputVariable(x).RTSValue); } // make the library call - state.dataExternalInterface->FMU(i).Instance(j).fmistatus = - fmiEPlusSetReal(&state.dataExternalInterface->FMU(i).Instance(j).fmicomponent, + fmuInst.fmistatus = + fmiEPlusSetReal(&fmuInst.fmicomponent, &valRefVec[0], &rtsValVec[0], - &state.dataExternalInterface->FMUTemp(i).Instance(j).NumInputVariablesInIDF, - &state.dataExternalInterface->FMU(i).Instance(j).Index); + &fmuTempInst.NumInputVariablesInIDF, + &fmuInst.Index); - if (state.dataExternalInterface->FMU(i).Instance(j).fmistatus != fmiOK) { + if (fmuInst.fmistatus != fmiOK) { ShowSevereError(state, "ExternalInterface/CalcExternalInterfaceFMUImport: "); ShowContinueError(state, "Error when trying to set inputs in instance"); ShowContinueError(state, format("\"{}\" of FMU \"{}\"", - state.dataExternalInterface->FMU(i).Instance(j).Name, - state.dataExternalInterface->FMU(i).Name)); - ShowContinueError(state, format("Error Code = \"{}\"", state.dataExternalInterface->FMU(i).Instance(j).fmistatus)); + fmuInst.Name, + fmu.Name)); + ShowContinueError(state, format("Error Code = \"{}\"", fmuInst.fmistatus)); state.dataExternalInterface->ErrorsFound = true; StopExternalInterfaceIfError(state); } @@ -2158,37 +2174,44 @@ void CalcExternalInterfaceFMUImport(EnergyPlusData &state) state.dataExternalInterface->fmiEndSimulation = 1; TerminateResetFreeFMUImport(state, state.dataExternalInterface->fmiEndSimulation); for (int i = 1; i <= state.dataExternalInterface->NumFMUObjects; ++i) { - for (int j = 1; j <= state.dataExternalInterface->FMU(i).NumInstances; ++j) { + auto &fmu = state.dataExternalInterface->FMU(i); + auto &fmuTemp = state.dataExternalInterface->FMUTemp(i); + for (int j = 1; j <= fmu.NumInstances; ++j) { + auto &fmuTempInst = fmuTemp.Instance(j); // Deallocate used objects - state.dataExternalInterface->FMUTemp(i).Instance(j).fmuInputVariable.deallocate(); - state.dataExternalInterface->FMUTemp(i).Instance(j).eplusOutputVariable.deallocate(); - state.dataExternalInterface->FMUTemp(i).Instance(j).fmuOutputVariableSchedule.deallocate(); - state.dataExternalInterface->FMUTemp(i).Instance(j).fmuOutputVariableVariable.deallocate(); - state.dataExternalInterface->FMUTemp(i).Instance(j).fmuOutputVariableActuator.deallocate(); + fmuTempInst.fmuInputVariable.deallocate(); + fmuTempInst.eplusOutputVariable.deallocate(); + fmuTempInst.fmuOutputVariableSchedule.deallocate(); + fmuTempInst.fmuOutputVariableVariable.deallocate(); + fmuTempInst.fmuOutputVariableActuator.deallocate(); } } for (int i = 1; i <= state.dataExternalInterface->NumFMUObjects; ++i) { - state.dataExternalInterface->FMUTemp(i).Instance.deallocate(); + auto &fmuTemp = state.dataExternalInterface->FMUTemp(i); + fmuTemp.Instance.deallocate(); } state.dataExternalInterface->FMUTemp.deallocate(); for (int i = 1; i <= state.dataExternalInterface->NumFMUObjects; ++i) { - for (int j = 1; j <= state.dataExternalInterface->FMU(i).NumInstances; ++j) { - state.dataExternalInterface->FMU(i).Instance(j).eplusInputVariableSchedule.deallocate(); - state.dataExternalInterface->FMU(i).Instance(j).fmuOutputVariableSchedule.deallocate(); - state.dataExternalInterface->FMU(i).Instance(j).eplusInputVariableVariable.deallocate(); - state.dataExternalInterface->FMU(i).Instance(j).fmuOutputVariableVariable.deallocate(); - state.dataExternalInterface->FMU(i).Instance(j).eplusInputVariableActuator.deallocate(); - state.dataExternalInterface->FMU(i).Instance(j).fmuOutputVariableActuator.deallocate(); - state.dataExternalInterface->FMU(i).Instance(j).fmuInputVariable.deallocate(); - state.dataExternalInterface->FMU(i).Instance(j).checkfmuInputVariable.deallocate(); + auto &fmu = state.dataExternalInterface->FMU(i); + for (int j = 1; j <= fmu.NumInstances; ++j) { + auto &fmuInst = fmu.Instance(j); + fmuInst.eplusInputVariableSchedule.deallocate(); + fmuInst.fmuOutputVariableSchedule.deallocate(); + fmuInst.eplusInputVariableVariable.deallocate(); + fmuInst.fmuOutputVariableVariable.deallocate(); + fmuInst.eplusInputVariableActuator.deallocate(); + fmuInst.fmuOutputVariableActuator.deallocate(); + fmuInst.fmuInputVariable.deallocate(); + fmuInst.checkfmuInputVariable.deallocate(); } } for (int i = 1; i <= state.dataExternalInterface->NumFMUObjects; ++i) { - state.dataExternalInterface->FMU(i).Instance.deallocate(); + auto &fmu = state.dataExternalInterface->FMU(i); + fmu.Instance.deallocate(); } state.dataExternalInterface->FMU.deallocate(); } @@ -2260,7 +2283,7 @@ void CalcExternalInterface(EnergyPlusData &state) state.dataExternalInterface->simulationStatus = 2; preSimTim = 0; // In the first call, E+ did not reset SimTimeSteps to zero } else { - preSimTim = state.dataGlobal->SimTimeSteps * state.dataGlobal->MinutesPerTimeStep * 60.0; + preSimTim = state.dataGlobal->SimTimeSteps * state.dataGlobal->MinutesInTimeStep * 60.0; } // Socket asked to terminate simulation, but simulation continues @@ -2360,7 +2383,7 @@ void CalcExternalInterface(EnergyPlusData &state) if ((flaRea == 0) && continueSimulation) { for (int i = 1; i <= isize(state.dataExternalInterface->varInd); ++i) { if (state.dataExternalInterface->inpVarTypes(i) == indexSchedule) { - ScheduleManager::ExternalInterfaceSetSchedule(state, state.dataExternalInterface->varInd(i), dblValRea(i)); + Sched::ExternalInterfaceSetSchedule(state, state.dataExternalInterface->varInd(i), dblValRea(i)); } else if ((state.dataExternalInterface->inpVarTypes(i) == indexVariable) || (state.dataExternalInterface->inpVarTypes(i) == indexActuator)) { RuntimeLanguageProcessor::ExternalInterfaceSetErlVariable(state, state.dataExternalInterface->varInd(i), dblValRea(i)); diff --git a/src/EnergyPlus/ExternalInterface.hh b/src/EnergyPlus/ExternalInterface.hh index ac0fec96911..61367c96761 100644 --- a/src/EnergyPlus/ExternalInterface.hh +++ b/src/EnergyPlus/ExternalInterface.hh @@ -392,6 +392,10 @@ struct ExternalInterfaceData : BaseGlobalStruct int nOutVal; // Number of output values (E+ -> ExternalInterface) int nInpVar; // Number of input values (ExternalInterface -> E+) + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/FanCoilUnits.cc b/src/EnergyPlus/FanCoilUnits.cc index 7c27178d74f..062731eb329 100644 --- a/src/EnergyPlus/FanCoilUnits.cc +++ b/src/EnergyPlus/FanCoilUnits.cc @@ -272,16 +272,12 @@ namespace FanCoilUnits { fanCoil.Name = Alphas(1); fanCoil.UnitType = CurrentModuleObject; fanCoil.UnitType_Num = FanCoilUnit_4Pipe; - fanCoil.Sched = Alphas(2); + if (lAlphaBlanks(2)) { - fanCoil.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - fanCoil.SchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(2)); // convert schedule name to pointer - if (fanCoil.SchedPtr == 0) { - ShowSevereError(state, format("{}{}=\"{}\", invalid", RoutineName, CurrentModuleObject, Alphas(1))); - ShowContinueError(state, format("invalid-not found: {}=\"{}\".", cAlphaFields(2), Alphas(2))); - ErrorsFound = true; - } + fanCoil.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((fanCoil.availSched = Sched::GetSchedule(state, Alphas(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(2), Alphas(2)); + ErrorsFound = true; } constexpr std::array(CCM::Num)> CapCtrlMethUC{"CONSTANTFANVARIABLEFLOW", "CYCLINGFAN", @@ -297,11 +293,8 @@ namespace FanCoilUnits { fanCoil.fanOp = HVAC::FanOp::Continuous; } - fanCoil.SchedOutAir = Alphas(4); - fanCoil.SchedOutAirPtr = ScheduleManager::GetScheduleIndex(state, Alphas(4)); // convert schedule name to pointer - if (fanCoil.SchedOutAirPtr == 0 && (!lAlphaBlanks(4))) { - ShowSevereError(state, format("{}{}=\"{}\", invalid", RoutineName, CurrentModuleObject, fanCoil.Name)); - ShowContinueError(state, format("illegal value: {}=\"{}\".", cAlphaFields(4), Alphas(4))); + if (!lAlphaBlanks(4) && ((fanCoil.oaSched = Sched::GetSchedule(state, Alphas(4))) == nullptr)) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(4), Alphas(4)); ErrorsFound = true; } fanCoil.MaxAirVolFlow = Numbers(1); @@ -520,16 +513,12 @@ namespace FanCoilUnits { auto *fan = state.dataFans->fans(fanCoil.FanIndex); if (fanCoil.fanType != fan->type) { - ShowSevereCustomMessage(state, - eoh, - format("{} was specified as having type {}, but has type {}", - fanCoil.FanName, - HVAC::fanTypeNamesUC[(int)fanCoil.fanType], - HVAC::fanTypeNamesUC[(int)fan->type])); + ShowSevereCustom(state, eoh, format("{} was specified as having type {}, but has type {}", + fanCoil.FanName, HVAC::fanTypeNamesUC[(int)fanCoil.fanType], HVAC::fanTypeNamesUC[(int)fan->type])); ErrorsFound = true; } - fanCoil.fanAvailSchIndex = fan->availSchedNum; + fanCoil.fanAvailSched = fan->availSched; fanCoil.FanAirVolFlow = fan->maxAirFlowRate; if (fanCoil.MaxAirVolFlow > fanCoil.FanAirVolFlow && fanCoil.FanAirVolFlow != DataSizing::AutoSize) { @@ -749,24 +738,19 @@ namespace FanCoilUnits { } if (fanCoil.CapCtrlMeth_Num == CCM::MultiSpeedFan) { if (!lAlphaBlanks(17)) { - fanCoil.FanOpModeSchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(17)); + fanCoil.fanOpModeSched = Sched::GetSchedule(state, Alphas(17)); if (fanCoil.fanType != HVAC::FanType::OnOff && fanCoil.fanType != HVAC::FanType::SystemModel) { ShowSevereError(state, format("{} = {}", CurrentModuleObject, fanCoil.Name)); ShowContinueError(state, format("For {} = {}", cAlphaFields(17), Alphas(17))); ShowContinueError(state, format("Illegal {} = {}", cAlphaFields(9), Alphas(9))); ShowContinueError(state, "...fan operating schedule is allowed for on off or system model fan type only )"); ErrorsFound = true; - } else { - if (fanCoil.FanOpModeSchedPtr == 0) { - ShowSevereError(state, format("{} = {}", CurrentModuleObject, fanCoil.Name)); - ShowContinueError(state, format("Illegal {} = {}", cAlphaFields(17), Alphas(17))); - ErrorsFound = true; - } - } - } else { - if (fanCoil.fanType == HVAC::FanType::OnOff || fanCoil.fanType == HVAC::FanType::SystemModel) { - fanCoil.fanOp = HVAC::FanOp::Cycling; + } else if (fanCoil.fanOpModeSched == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(17), Alphas(17)); + ErrorsFound = true; } + } else if (fanCoil.fanType == HVAC::FanType::OnOff || fanCoil.fanType == HVAC::FanType::SystemModel) { + fanCoil.fanOp = HVAC::FanOp::Cycling; } } @@ -1126,17 +1110,11 @@ namespace FanCoilUnits { // These initializations are done every iteration fanCoil.SpeedRatio = 0.0; - if (fanCoil.FanOpModeSchedPtr > 0) { - if (ScheduleManager::GetCurrentScheduleValue(state, fanCoil.FanOpModeSchedPtr) == 0.0) { - fanCoil.fanOp = HVAC::FanOp::Cycling; - } else { - fanCoil.fanOp = HVAC::FanOp::Continuous; - } + if (fanCoil.fanOpModeSched != nullptr) { + fanCoil.fanOp = (fanCoil.fanOpModeSched->getCurrentVal() == 0.0) ? HVAC::FanOp::Cycling : HVAC::FanOp::Continuous; } // Set the inlet node mass flow rate - if (((ScheduleManager::GetCurrentScheduleValue(state, fanCoil.SchedPtr) > 0.0 && - ScheduleManager::GetCurrentScheduleValue(state, fanCoil.fanAvailSchIndex) > 0.0) || - state.dataHVACGlobal->TurnFansOn) && + if (((fanCoil.availSched->getCurrentVal() > 0.0 && fanCoil.fanAvailSched->getCurrentVal() > 0.0) || state.dataHVACGlobal->TurnFansOn) && !state.dataHVACGlobal->TurnFansOff) { state.dataLoopNodes->Node(fanCoil.AirInNode).MassFlowRate = fanCoil.MaxAirMassFlow; state.dataLoopNodes->Node(fanCoil.AirInNode).MassFlowRateMaxAvail = state.dataLoopNodes->Node(fanCoil.AirInNode).MassFlowRate; @@ -2085,7 +2063,7 @@ namespace FanCoilUnits { // if cooling if (UnitOn && QCoilCoolSP < -HVAC::SmallLoad && - state.dataHeatBalFanSys->TempControlType(ControlledZoneNum) != HVAC::ThermostatType::SingleHeating) { + state.dataHeatBalFanSys->TempControlType(ControlledZoneNum) != HVAC::SetptType::SingleHeat) { int ControlNode = fanCoil.CoolCoilFluidInletNode; ControlOffset = fanCoil.ColdControlOffset; MaxWaterFlow = fanCoil.MaxCoolCoilFluidFlow; @@ -2217,7 +2195,7 @@ namespace FanCoilUnits { // if heating } else if (UnitOn && QCoilHeatSP > HVAC::SmallLoad && - state.dataHeatBalFanSys->TempControlType(ControlledZoneNum) != HVAC::ThermostatType::SingleCooling) { + state.dataHeatBalFanSys->TempControlType(ControlledZoneNum) != HVAC::SetptType::SingleCool) { // get full load result if (fanCoil.HCoilType_Num == HCoil::Water) { // if HW Coil int ControlNode = fanCoil.HeatCoilFluidInletNode; @@ -2456,7 +2434,7 @@ namespace FanCoilUnits { // meet the coil load adjusted for fan operation if (UnitOn && QCoilCoolSP < (-1.0 * HVAC::SmallLoad) && - state.dataHeatBalFanSys->TempControlType(ControlledZoneNum) != HVAC::ThermostatType::SingleHeating) { + state.dataHeatBalFanSys->TempControlType(ControlledZoneNum) != HVAC::SetptType::SingleHeat) { // cooling coil action, maximum cold water flow mdot = fanCoil.MaxCoolCoilFluidFlow; PlantUtilities::SetComponentFlowRate( @@ -2550,7 +2528,7 @@ namespace FanCoilUnits { Calc4PipeFanCoil(state, FanCoilNum, ControlledZoneNum, FirstHVACIteration, QUnitOut, PLR); } else if (UnitOn && QCoilHeatSP > HVAC::SmallLoad && - state.dataHeatBalFanSys->TempControlType(ControlledZoneNum) != HVAC::ThermostatType::SingleCooling) { + state.dataHeatBalFanSys->TempControlType(ControlledZoneNum) != HVAC::SetptType::SingleCool) { // heating coil action, maximun hot water flow if (fanCoil.HCoilType_Num == HCoil::Water) { @@ -2736,18 +2714,18 @@ namespace FanCoilUnits { QCoilHeatSP = state.dataZoneEnergyDemand->ZoneSysEnergyDemand(ControlledZoneNum).RemainingOutputReqToHeatSP; if (QCoilHeatSP > 0.0 && QCoilCoolSP > 0.0 && - state.dataHeatBalFanSys->TempControlType(ControlledZoneNum) != HVAC::ThermostatType::SingleCooling) { + state.dataHeatBalFanSys->TempControlType(ControlledZoneNum) != HVAC::SetptType::SingleCool) { QZnReq = QCoilHeatSP; state.dataFanCoilUnits->HeatingLoad = true; } else if (QCoilHeatSP > 0.0 && QCoilCoolSP > 0.0 && - state.dataHeatBalFanSys->TempControlType(ControlledZoneNum) == HVAC::ThermostatType::SingleCooling) { + state.dataHeatBalFanSys->TempControlType(ControlledZoneNum) == HVAC::SetptType::SingleCool) { QZnReq = 0.0; } else if (QCoilHeatSP < 0.0 && QCoilCoolSP < 0.0 && - state.dataHeatBalFanSys->TempControlType(ControlledZoneNum) != HVAC::ThermostatType::SingleHeating) { + state.dataHeatBalFanSys->TempControlType(ControlledZoneNum) != HVAC::SetptType::SingleHeat) { QZnReq = QCoilCoolSP; state.dataFanCoilUnits->CoolingLoad = true; } else if (QCoilHeatSP < 0.0 && QCoilCoolSP < 0.0 && - state.dataHeatBalFanSys->TempControlType(ControlledZoneNum) == HVAC::ThermostatType::SingleHeating) { + state.dataHeatBalFanSys->TempControlType(ControlledZoneNum) == HVAC::SetptType::SingleHeat) { QZnReq = 0.0; } else if (QCoilHeatSP <= 0.0 && QCoilCoolSP >= 0.0) { QZnReq = 0.0; @@ -2854,7 +2832,7 @@ namespace FanCoilUnits { int Iter = 0; if (UnitOn && state.dataZoneEnergyDemand->ZoneSysEnergyDemand(ControlledZoneNum).RemainingOutputReqToCoolSP < (-1.0 * HVAC::SmallLoad) && - state.dataHeatBalFanSys->TempControlType(ControlledZoneNum) != HVAC::ThermostatType::SingleHeating) { + state.dataHeatBalFanSys->TempControlType(ControlledZoneNum) != HVAC::SetptType::SingleHeat) { // cooling coil action, maximum cold water flow mdot = fanCoil.MaxCoolCoilFluidFlow; PlantUtilities::SetComponentFlowRate( @@ -2900,7 +2878,7 @@ namespace FanCoilUnits { Calc4PipeFanCoil(state, FanCoilNum, ControlledZoneNum, FirstHVACIteration, QUnitOut, PLR); } else if (UnitOn && state.dataZoneEnergyDemand->ZoneSysEnergyDemand(ControlledZoneNum).RemainingOutputReqToHeatSP > HVAC::SmallLoad && - state.dataHeatBalFanSys->TempControlType(ControlledZoneNum) != HVAC::ThermostatType::SingleCooling) { + state.dataHeatBalFanSys->TempControlType(ControlledZoneNum) != HVAC::SetptType::SingleCool) { // heating coil action, maximun hot water flow if (fanCoil.HCoilType_Num == HCoil::Water) { mdot = fanCoil.MaxHeatCoilFluidFlow; @@ -3221,9 +3199,7 @@ namespace FanCoilUnits { // Assume the unit is able to vary the flow. A cycling unit is treated as // if it were variable flow, with the flow being the averaqe flow over the time step - if (((ScheduleManager::GetCurrentScheduleValue(state, fanCoil.SchedPtr) > 0.0 && - ScheduleManager::GetCurrentScheduleValue(state, fanCoil.fanAvailSchIndex) > 0.0) || - state.dataHVACGlobal->TurnFansOn) && + if (((fanCoil.availSched->getCurrentVal() > 0.0 && fanCoil.fanAvailSched->getCurrentVal() > 0.0) || state.dataHVACGlobal->TurnFansOn) && !state.dataHVACGlobal->TurnFansOff) { if (fanCoil.CapCtrlMeth_Num != CCM::ConsFanVarFlow) { if (fanCoil.CapCtrlMeth_Num != CCM::ASHRAE) @@ -3234,11 +3210,7 @@ namespace FanCoilUnits { } // use the value of the outside air schedule if present - if (fanCoil.SchedOutAirPtr > 0) { - OASchedValue = ScheduleManager::GetCurrentScheduleValue(state, fanCoil.SchedOutAirPtr); - } else { - OASchedValue = 1.0; - } + OASchedValue = (fanCoil.oaSched != nullptr) ? fanCoil.oaSched->getCurrentVal() : 1.0; if (fanCoil.ATMixerExists) { state.dataFanCoilUnits->ATMixOutNode = fanCoil.ATMixerOutNode; @@ -3471,18 +3443,18 @@ namespace FanCoilUnits { state.dataFanCoilUnits->HeatingLoad = false; state.dataFanCoilUnits->CoolingLoad = false; - if (QCoilHeatSP > 0.0 && QCoilCoolSP > 0.0 && state.dataHeatBalFanSys->TempControlType(ZoneNum) != HVAC::ThermostatType::SingleCooling) { + if (QCoilHeatSP > 0.0 && QCoilCoolSP > 0.0 && state.dataHeatBalFanSys->TempControlType(ZoneNum) != HVAC::SetptType::SingleCool) { QZnReq = QCoilHeatSP; HeatingLoad = true; } else if (QCoilHeatSP > 0.0 && QCoilCoolSP > 0.0 && - state.dataHeatBalFanSys->TempControlType(ZoneNum) == HVAC::ThermostatType::SingleCooling) { + state.dataHeatBalFanSys->TempControlType(ZoneNum) == HVAC::SetptType::SingleCool) { QZnReq = 0.0; } else if (QCoilHeatSP < 0.0 && QCoilCoolSP < 0.0 && - state.dataHeatBalFanSys->TempControlType(ZoneNum) != HVAC::ThermostatType::SingleHeating) { + state.dataHeatBalFanSys->TempControlType(ZoneNum) != HVAC::SetptType::SingleHeat) { QZnReq = QCoilCoolSP; CoolingLoad = true; } else if (QCoilHeatSP < 0.0 && QCoilCoolSP < 0.0 && - state.dataHeatBalFanSys->TempControlType(ZoneNum) == HVAC::ThermostatType::SingleHeating) { + state.dataHeatBalFanSys->TempControlType(ZoneNum) == HVAC::SetptType::SingleHeat) { QZnReq = 0.0; } else if (QCoilHeatSP <= 0.0 && QCoilCoolSP >= 0.0) { QZnReq = 0.0; @@ -3491,7 +3463,7 @@ namespace FanCoilUnits { // Zone load calculation for constant fan systems, adopted from unitary system if (fanCoil.fanOp == HVAC::FanOp::Continuous) { switch (state.dataHeatBalFanSys->TempControlType(ZoneNum)) { - case HVAC::ThermostatType::SingleHeating: { + case HVAC::SetptType::SingleHeat: { CoolingLoad = false; // No heating load and constant fan pushes zone below heating set point if (QUnitOutNoHC < 0.0 && QCoilHeatSP < 0.0 && QUnitOutNoHC - QCoilHeatSP < -HVAC::SmallLoad) { @@ -3500,7 +3472,7 @@ namespace FanCoilUnits { QZnReq = QCoilHeatSP; } } break; - case HVAC::ThermostatType::SingleCooling: { + case HVAC::SetptType::SingleCool: { HeatingLoad = false; // No heating load and constant fan pushes zone above cooling set point if (QUnitOutNoHC > 0.0 && QCoilCoolSP > 0.0 && QUnitOutNoHC - QCoilCoolSP > HVAC::SmallLoad) { @@ -3509,7 +3481,7 @@ namespace FanCoilUnits { QZnReq = QCoilCoolSP; } } break; - case HVAC::ThermostatType::SingleHeatCool: { + case HVAC::SetptType::SingleHeatCool: { // zone temp above cooling and heating set point temps if (QCoilHeatSP < 0.0 && QCoilCoolSP < 0.0) { // zone pushed below heating set point @@ -3528,7 +3500,7 @@ namespace FanCoilUnits { } } } break; - case HVAC::ThermostatType::DualSetPointWithDeadBand: { + case HVAC::SetptType::DualHeatCool: { // zone temp above cooling and heating set point temps if (QCoilHeatSP < 0.0 && QCoilCoolSP < 0.0) { // zone pushed into deadband diff --git a/src/EnergyPlus/FanCoilUnits.hh b/src/EnergyPlus/FanCoilUnits.hh index 68983667875..9ebd866c06a 100644 --- a/src/EnergyPlus/FanCoilUnits.hh +++ b/src/EnergyPlus/FanCoilUnits.hh @@ -110,11 +110,11 @@ namespace FanCoilUnits { // Members // Input data int UnitType_Num = 0; - std::string Sched; // availability schedule - int SchedPtr = 0; // index to schedule + std::string availSchedName; // availability schedule + Sched::Schedule *availSched = nullptr; // availability schedule std::string SchedOutAir; // outside air schedule, multipliy maximum outdoor air flow rate - int SchedOutAirPtr = 0; // index to outside air schedule - HVAC::FanType fanType = HVAC::FanType::Invalid; // index to fan type + Sched::Schedule *oaSched = nullptr; // outside air schedule + HVAC::FanType fanType = HVAC::FanType::Invalid; // fan type int SpeedFanSel = 0; // Speed fan selected CCM CapCtrlMeth_Num = CCM::Invalid; Real64 PLR = 0.0; // Part Load Ratio, fraction of time step fancoil is on @@ -176,7 +176,7 @@ namespace FanCoilUnits { int ATMixerSecNode = 0; // secondary air inlet node number for the air terminal mixer int HVACSizingIndex = 0; // index of a HVACSizing object for a fancoil unit Real64 SpeedRatio = 0.0; // speed ratio when the fan is cycling between stages - int FanOpModeSchedPtr = 0; // pointer to supply air fan operating mode schedule + Sched::Schedule *fanOpModeSched = nullptr; // supply air fan operating mode schedule HVAC::FanOp fanOp = HVAC::FanOp::Cycling; // 1=cycling fan cycling coil; 2=constant fan cycling coil bool ASHRAETempControl = false; // ASHRAE90.1 control to temperature set point when true Real64 QUnitOutNoHC = 0.0; // unit output with coils off [W] @@ -201,7 +201,7 @@ namespace FanCoilUnits { Real64 DesZoneHeatingLoad = 0.0; // used for reporting in watts int DSOAPtr = 0; // design specification outdoor air object index bool FirstPass = true; // detects first time through for resetting sizing data - int fanAvailSchIndex = 0; // fan availability schedule index + Sched::Schedule *fanAvailSched = nullptr; // fan availability schedule index // SZVAV Model inputs std::string Name; // name of unit @@ -419,6 +419,10 @@ struct FanCoilUnitsData : BaseGlobalStruct int ATMixOutNode = 0; // outlet node of ATM Mixer int ZoneNode = 0; // zone node + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/Fans.cc b/src/EnergyPlus/Fans.cc index 6c0c23e29da..2f1f2a4f13f 100644 --- a/src/EnergyPlus/Fans.cc +++ b/src/EnergyPlus/Fans.cc @@ -304,8 +304,8 @@ void GetFanInput(EnergyPlusData &state) fan->sizingPrefix = cNumericFieldNames(3); if (lAlphaFieldBlanks(2)) { - fan->availSchedNum = ScheduleManager::ScheduleAlwaysOn; - } else if ((fan->availSchedNum = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(2))) == 0) { + fan->availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((fan->availSched = Sched::GetSchedule(state, cAlphaArgs(2))) == nullptr) { ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(2), cAlphaArgs(2)); ErrorsFound = true; } @@ -383,8 +383,8 @@ void GetFanInput(EnergyPlusData &state) fan->sizingPrefix = cNumericFieldNames(3); if (lAlphaFieldBlanks(2)) { - fan->availSchedNum = ScheduleManager::ScheduleAlwaysOn; - } else if ((fan->availSchedNum = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(2))) == 0) { + fan->availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((fan->availSched = Sched::GetSchedule(state, cAlphaArgs(2))) == nullptr) { ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(2), cAlphaArgs(2)); ErrorsFound = true; } @@ -473,16 +473,13 @@ void GetFanInput(EnergyPlusData &state) fan->sizingPrefix = cNumericFieldNames(3); if (lAlphaFieldBlanks(2)) { - fan->availSchedNum = ScheduleManager::ScheduleAlwaysOn; - } else if ((fan->availSchedNum = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(2))) == 0) { + fan->availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((fan->availSched = Sched::GetSchedule(state, cAlphaArgs(2))) == nullptr) { ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(2), cAlphaArgs(2)); ErrorsFound = true; - } else if (ScheduleManager::HasFractionalScheduleValue(state, fan->availSchedNum)) { - ShowWarningError(state, - format("{}=\"{}\" has fractional values in Schedule={}. Only 0.0 in the schedule value turns the fan off.", - cCurrentModuleObject, - fan->Name, - cAlphaArgs(2))); + } else if (fan->availSched->hasFractionalVal(state)) { + ShowWarningCustom(state, eoh, format("{}={} has fracdtional values. Only 0.0 in the schedule value turns the fan off.", + cAlphaFieldNames(2), cAlphaArgs(2))); } fan->totalEff = rNumericArgs(1); @@ -523,17 +520,12 @@ void GetFanInput(EnergyPlusData &state) fan->endUseSubcategoryName = (NumAlphas > 4 && !lAlphaFieldBlanks(5)) ? cAlphaArgs(5) : "General"; if (NumAlphas <= 5 || lAlphaFieldBlanks(6)) { - fan->flowFracSchedNum = ScheduleManager::ScheduleAlwaysOn; - } else if ((fan->flowFracSchedNum = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(6))) == 0) { + fan->flowFracSched = Sched::GetScheduleAlwaysOn(state); + } else if ((fan->flowFracSched = Sched::GetSchedule(state, cAlphaArgs(6))) == nullptr) { ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(6), cAlphaArgs(6)); ErrorsFound = true; - } else if (!ScheduleManager::CheckScheduleValueMinMax( - state, fan->flowFracSchedNum, ScheduleManager::Clusivity::Inclusive, 0.0, ScheduleManager::Clusivity::Inclusive, 1.0)) { - ShowSevereError( - state, - format("{}: {}: invalid {} for {}={}", routineName, cCurrentModuleObject, cAlphaFieldNames(6), cAlphaFieldNames(1), cAlphaArgs(1))); - ShowContinueError(state, format("Error found in {} = {}", cAlphaFieldNames(6), cAlphaArgs(6))); - ShowContinueError(state, "Schedule values must be (>=0., <=1.)"); + } else if (!fan->flowFracSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) { + Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(6), cAlphaArgs(6), Clusive::In, 0.0, Clusive::In, 1.0); ErrorsFound = true; } @@ -546,14 +538,14 @@ void GetFanInput(EnergyPlusData &state) } if (NumAlphas <= 7 || lAlphaFieldBlanks(8)) { - fan->minTempLimitSchedNum = 0; - } else if ((fan->minTempLimitSchedNum = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(8))) == 0) { + fan->minTempLimitSched = nullptr; + } else if ((fan->minTempLimitSched = Sched::GetSchedule(state, cAlphaArgs(8))) == nullptr) { ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(8), cAlphaArgs(8)); ErrorsFound = true; } if (NumAlphas <= 8 || lAlphaFieldBlanks(9)) { - fan->balancedFractSchedNum = 0; + fan->balancedFractSched = nullptr; } else if (state.dataHeatBal->ZoneAirMassFlow.ZoneFlowAdjustment != DataHeatBalance::AdjustmentType::NoAdjustReturnAndMixing) { // do not include adjusted for "balanced" exhaust flow in the zone total return calculation ShowWarningError(state, @@ -566,17 +558,12 @@ void GetFanInput(EnergyPlusData &state) cAlphaArgs(1))); ShowContinueError(state, "When zone air mass flow balance is enforced, this input field should be left blank."); ShowContinueError(state, "This schedule will be ignored in the simulation."); - fan->balancedFractSchedNum = 0; - } else if ((fan->balancedFractSchedNum = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(9))) == 0) { + fan->balancedFractSched = nullptr; + } else if ((fan->balancedFractSched = Sched::GetSchedule(state, cAlphaArgs(9))) == nullptr) { ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(9), cAlphaArgs(9)); ErrorsFound = true; - } else if (!ScheduleManager::CheckScheduleValueMinMax( - state, fan->balancedFractSchedNum, ScheduleManager::Clusivity::Inclusive, 0.0, ScheduleManager::Clusivity::Inclusive, 1.0)) { - ShowSevereError( - state, - format("{}: {}: invalid {} for {}={}", routineName, cCurrentModuleObject, cAlphaFieldNames(9), cAlphaFieldNames(1), cAlphaArgs(1))); - ShowContinueError(state, format("Error found in {} = {}", cAlphaFieldNames(9), cAlphaArgs(9))); - ShowContinueError(state, "Schedule values must be (>=0., <=1.)"); + } else if (!fan->balancedFractSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) { + Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(9), cAlphaArgs(9), Clusive::In, 0.0, Clusive::In, 1.0); ErrorsFound = true; } if (ErrorsFound) { @@ -616,8 +603,8 @@ void GetFanInput(EnergyPlusData &state) fan->sizingPrefix = cNumericFieldNames(3); if (lAlphaFieldBlanks(2)) { - fan->availSchedNum = ScheduleManager::ScheduleAlwaysOn; - } else if ((fan->availSchedNum = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(2))) == 0) { + fan->availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((fan->availSched = Sched::GetSchedule(state, cAlphaArgs(2))) == nullptr) { ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(2), cAlphaArgs(2)); ErrorsFound = true; } @@ -780,8 +767,8 @@ void GetFanInput(EnergyPlusData &state) BranchNodeConnections::TestCompSet(state, cCurrentModuleObject, cAlphaArgs(1), cAlphaArgs(2), cAlphaArgs(3), "Air Nodes"); if (lAlphaFieldBlanks(4)) { - fan->availSchedNum = 0; - } else if ((fan->availSchedNum = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(4))) == 0) { + fan->availSched = nullptr; + } else if ((fan->availSched = Sched::GetSchedule(state, cAlphaArgs(4))) == nullptr) { ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(4), cAlphaArgs(4)); ErrorsFound = true; } @@ -875,8 +862,8 @@ void GetFanInput(EnergyPlusData &state) fan->type = HVAC::FanType::SystemModel; if (lAlphaFieldBlanks(2)) { - fan->availSchedNum = ScheduleManager::ScheduleAlwaysOn; - } else if ((fan->availSchedNum = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(2))) == 0) { + fan->availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((fan->availSched = Sched::GetSchedule(state, cAlphaArgs(2))) == nullptr) { ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(2), cAlphaArgs(2)); ErrorsFound = true; } @@ -1124,7 +1111,7 @@ void GetFanInput(EnergyPlusData &state) if (fan->type == HVAC::FanType::Exhaust) { auto *fanExhaust = dynamic_cast(fan); assert(fanExhaust != nullptr); - if (fanExhaust->balancedFractSchedNum > 0) { + if (fanExhaust->balancedFractSched != nullptr) { SetupOutputVariable(state, "Fan Unbalanced Air Mass Flow Rate", Constant::Units::kg_s, @@ -1306,8 +1293,8 @@ void FanComponent::init(EnergyPlusData &state) } else { // zone exhaust fans massFlowRateMaxAvail = maxAirMassFlowRate; massFlowRateMinAvail = 0.0; - if (flowFracSchedNum > 0) { // modulate flow - inletAirMassFlowRate = massFlowRateMaxAvail * ScheduleManager::GetCurrentScheduleValue(state, flowFracSchedNum); + if (flowFracSched != nullptr) { // modulate flow + inletAirMassFlowRate = massFlowRateMaxAvail * flowFracSched->getCurrentVal(); inletAirMassFlowRate = max(0.0, inletAirMassFlowRate); } else { // always run at max inletAirMassFlowRate = massFlowRateMaxAvail; @@ -1658,19 +1645,19 @@ void FanComponent::simulateConstant(EnergyPlusData &state) if (faultyFilterFlag && (!state.dataGlobal->WarmupFlag) && (!state.dataGlobal->DoingSizing) && (!state.dataGlobal->KickOffSimulation)) { auto &fault = state.dataFaultsMgr->FaultsFouledAirFilters(faultyFilterIndex); // Check fault availability schedules - if (ScheduleManager::GetCurrentScheduleValue(state, fault.availSchedNum) > 0.0) { + if (fault.availSched->getCurrentVal() > 0.0) { // Decrease of the Fan Design Volume Flow Rate [m3/sec] Real64 _fanDesignFlowRateDec = CalFaultyFanAirFlowReduction(state, Name, maxAirFlowRate, deltaPress, - (ScheduleManager::GetCurrentScheduleValue(state, fault.pressFracSchedNum) - 1) * deltaPress, + (fault.pressFracSched->getCurrentVal() - 1) * deltaPress, fault.fanCurveNum); // Update MassFlow & DeltaPress of the fan _massFlow = min(_massFlow, maxAirMassFlowRate - _fanDesignFlowRateDec * _rhoAir); - _deltaPress = ScheduleManager::GetCurrentScheduleValue(state, fault.pressFracSchedNum) * deltaPress; + _deltaPress = fault.pressFracSched->getCurrentVal() * deltaPress; } } @@ -1683,7 +1670,7 @@ void FanComponent::simulateConstant(EnergyPlusData &state) _massFlow = max(_massFlow, minAirMassFlowRate); // Determine the Fan Schedule for the Time step - if ((ScheduleManager::GetCurrentScheduleValue(state, availSchedNum) > 0.0 || state.dataHVACGlobal->TurnFansOn) && + if ((availSched->getCurrentVal() > 0.0 || state.dataHVACGlobal->TurnFansOn) && !state.dataHVACGlobal->TurnFansOff && _massFlow > 0.0) { // Fan is operating totalPower = max(0.0, _massFlow * _deltaPress / (_totalEff * _rhoAir)); // total fan power @@ -1775,19 +1762,19 @@ void FanComponent::simulateVAV(EnergyPlusData &state, ObjexxFCL::OptionalFaultsFouledAirFilters(faultyFilterIndex); // Check fault availability schedules - if (ScheduleManager::GetCurrentScheduleValue(state, fault.availSchedNum) > 0.0) { + if (fault.availSched->getCurrentVal() > 0.0) { Real64 _fanDesignFlowRateDec = // Decrease of the Fan Design Volume Flow Rate [m3/sec] CalFaultyFanAirFlowReduction(state, Name, maxAirFlowRate, deltaPress, - (ScheduleManager::GetCurrentScheduleValue(state, fault.pressFracSchedNum) - 1) * deltaPress, + (fault.pressFracSched->getCurrentVal() - 1) * deltaPress, fault.fanCurveNum); // Update MassFlow & DeltaPress of the fan _maxAirFlowRate = maxAirFlowRate - _fanDesignFlowRateDec; _maxAirMassFlowRate = maxAirMassFlowRate - _fanDesignFlowRateDec * _rhoAir; - _deltaPress = ScheduleManager::GetCurrentScheduleValue(state, fault.pressFracSchedNum) * deltaPress; + _deltaPress = fault.pressFracSched->getCurrentVal() * deltaPress; } } @@ -1799,7 +1786,7 @@ void FanComponent::simulateVAV(EnergyPlusData &state, ObjexxFCL::Optional 0.0 || state.dataHVACGlobal->TurnFansOn) && + if ((availSched->getCurrentVal() > 0.0 || state.dataHVACGlobal->TurnFansOn) && !state.dataHVACGlobal->TurnFansOff && _massFlow > 0.0) { // Fan is operating - calculate power loss and enthalpy rise // fan%FanPower = PartLoadFrac*FullMassFlow*DeltaPress/(FanEff*RhoAir) ! total fan power @@ -1918,18 +1905,18 @@ void FanComponent::simulateOnOff(EnergyPlusData &state, ObjexxFCL::OptionalFaultsFouledAirFilters(faultyFilterIndex); // Check fault availability schedules - if (ScheduleManager::GetCurrentScheduleValue(state, fault.availSchedNum) > 0.0) { + if (fault.availSched->getCurrentVal() > 0.0) { Real64 _fanDesignFlowRateDec = // Decrease of the Fan Design Volume Flow Rate [m3/sec] CalFaultyFanAirFlowReduction(state, Name, maxAirFlowRate, deltaPress, - (ScheduleManager::GetCurrentScheduleValue(state, fault.pressFracSchedNum) - 1) * deltaPress, + (fault.pressFracSched->getCurrentVal() - 1) * deltaPress, fault.fanCurveNum); // Update MassFlow & DeltaPress of the fan _maxAirMassFlowRate = maxAirMassFlowRate - _fanDesignFlowRateDec * _rhoAir; - _deltaPress = ScheduleManager::GetCurrentScheduleValue(state, fault.pressFracSchedNum) * deltaPress; + _deltaPress = fault.pressFracSched->getCurrentVal() * deltaPress; } } @@ -1943,7 +1930,7 @@ void FanComponent::simulateOnOff(EnergyPlusData &state, ObjexxFCL::Optional 0.0 || state.dataHVACGlobal->TurnFansOn) && + if ((availSched->getCurrentVal() > 0.0 || state.dataHVACGlobal->TurnFansOn) && !state.dataHVACGlobal->TurnFansOff && _massFlow > 0.0 && maxAirMassFlowRate > 0.0) { // The actual flow fraction is calculated from MassFlow and the MaxVolumeFlow * AirDensity Real64 _flowFrac = _massFlow / _maxAirMassFlowRate; @@ -2079,24 +2066,16 @@ void FanComponent::simulateZoneExhaust(EnergyPlusData &state) // apply controls to determine if operating if (availManagerMode == AvailManagerMode::Coupled) { - if (((ScheduleManager::GetCurrentScheduleValue(state, availSchedNum) > 0.0) || state.dataHVACGlobal->TurnFansOn) && + if (((availSched->getCurrentVal() > 0.0) || state.dataHVACGlobal->TurnFansOn) && !state.dataHVACGlobal->TurnFansOff && _massFlow > 0.0) { // available - if (minTempLimitSchedNum > 0) { - _fanIsRunning = (_Tin >= ScheduleManager::GetCurrentScheduleValue(state, minTempLimitSchedNum)); - } else { - _fanIsRunning = true; - } + _fanIsRunning = (minTempLimitSched != nullptr) ? (_Tin >= minTempLimitSched->getCurrentVal()) : true; } else { _fanIsRunning = false; } } else if (availManagerMode == AvailManagerMode::Decoupled) { - if (ScheduleManager::GetCurrentScheduleValue(state, availSchedNum) > 0.0 && _massFlow > 0.0) { - if (minTempLimitSchedNum > 0) { - _fanIsRunning = (_Tin >= ScheduleManager::GetCurrentScheduleValue(state, minTempLimitSchedNum)); - } else { - _fanIsRunning = true; - } + if (availSched->getCurrentVal() > 0.0 && _massFlow > 0.0) { + _fanIsRunning = (minTempLimitSched != nullptr) ? (_Tin >= minTempLimitSched->getCurrentVal()) : true; } else { _fanIsRunning = false; } @@ -2187,7 +2166,7 @@ void FanComponent::simulateComponentModel(EnergyPlusData &state) // IF (fan%EMSMaxMassFlowOverrideOn) MassFlow = fan%EMSAirMassFlowValue // Determine the Fan Schedule for the Time step - if ((ScheduleManager::GetCurrentScheduleValue(state, availSchedNum) > 0.0 || state.dataHVACGlobal->TurnFansOn) && + if ((availSched->getCurrentVal() > 0.0 || state.dataHVACGlobal->TurnFansOn) && !state.dataHVACGlobal->TurnFansOff && _massFlow > 0.0) { // Fan is operating - calculate fan pressure rise, component efficiencies and power, and also air enthalpy rise @@ -2358,9 +2337,9 @@ void FanComponent::update(EnergyPlusData &state) inletNode.MassFlowRate = inletAirMassFlowRate; if (state.afn->AirflowNetworkNumOfExhFan == 0) { state.dataHVACGlobal->UnbalExhMassFlow = inletAirMassFlowRate; - if (balancedFractSchedNum > 0) { + if (balancedFractSched != nullptr) { state.dataHVACGlobal->BalancedExhMassFlow = - state.dataHVACGlobal->UnbalExhMassFlow * ScheduleManager::GetCurrentScheduleValue(state, balancedFractSchedNum); + state.dataHVACGlobal->UnbalExhMassFlow * balancedFractSched->getCurrentVal(); state.dataHVACGlobal->UnbalExhMassFlow = state.dataHVACGlobal->UnbalExhMassFlow - state.dataHVACGlobal->BalancedExhMassFlow; } else { state.dataHVACGlobal->BalancedExhMassFlow = 0.0; @@ -2803,9 +2782,9 @@ void FanSystem::calcSimpleSystemFan( if (faultyFilterFlag && (state.dataFaultsMgr->NumFaultyAirFilter > 0) && (!state.dataGlobal->WarmupFlag) && (!state.dataGlobal->DoingSizing) && state.dataGlobal->DoWeathSim && (!EMSMaxMassFlowOverrideOn) && (!EMSPressureOverrideOn)) { auto &fault = state.dataFaultsMgr->FaultsFouledAirFilters(faultyFilterIndex); - if (ScheduleManager::GetCurrentScheduleValue(state, fault.availSchedNum) > 0) { + if (fault.availSched->getCurrentVal() > 0) { _faultActive = true; - Real64 _pressFrac = ScheduleManager::GetCurrentScheduleValue(state, fault.pressFracSchedNum); + Real64 _pressFrac = fault.pressFracSched->getCurrentVal(); Real64 _designFlowRateDec = // Decrease of the Fan Design Volume Flow Rate [m3/sec] Fans::CalFaultyFanAirFlowReduction(state, Name, maxAirFlowRate, deltaPress, (_pressFrac - 1) * deltaPress, fault.fanCurveNum); @@ -2844,7 +2823,7 @@ void FanSystem::calcSimpleSystemFan( } } - if ((ScheduleManager::GetCurrentScheduleValue(state, availSchedNum) > 0.0 || state.dataHVACGlobal->TurnFansOn) && + if ((availSched->getCurrentVal() > 0.0 || state.dataHVACGlobal->TurnFansOn) && !state.dataHVACGlobal->TurnFansOff && ((_localAirMassFlow[0] + _localAirMassFlow[1]) > 0.0)) { // fan is running diff --git a/src/EnergyPlus/Fans.hh b/src/EnergyPlus/Fans.hh index e78811ef0b3..f9b539d32d6 100644 --- a/src/EnergyPlus/Fans.hh +++ b/src/EnergyPlus/Fans.hh @@ -130,7 +130,7 @@ namespace Fans { std::string endUseSubcategoryName; - int availSchedNum = 0; // Pointer to the availability schedule + Sched::Schedule *availSched = nullptr; // Pointer to the availability schedule int inletNodeNum = 0; int outletNodeNum = 0; int airLoopNum = 0; @@ -293,10 +293,10 @@ namespace Fans { Real64 vfdEff = 0.0; // VFD efficiency (electrical) Real64 vfdInputPower = 0.0; // VFD input power for fan being Simulated [W] // zone exhaust fan - int flowFracSchedNum = 0; // schedule index flow rate modifier schedule + Sched::Schedule *flowFracSched = nullptr; // schedule index flow rate modifier schedule AvailManagerMode availManagerMode = AvailManagerMode::Invalid; // mode for how exhaust fan should react to availability managers - int minTempLimitSchedNum = 0; // schedule index minimum temperature limit - int balancedFractSchedNum = 0; // schedule index portion recirculated + Sched::Schedule *minTempLimitSched = nullptr; // schedule index minimum temperature limit + Sched::Schedule *balancedFractSched = nullptr; // schedule index portion recirculated Real64 unbalancedOutletMassFlowRate = 0.0; Real64 balancedOutletMassFlowRate = 0.0; Real64 designPointFEI = 0.0; // Fan Energy Index for the fan at the design operating point @@ -455,6 +455,10 @@ struct FansData : BaseGlobalStruct Array1D fans; std::map fanMap; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/FaultsManager.cc b/src/EnergyPlus/FaultsManager.cc index 01f96db6798..20769fad6f1 100644 --- a/src/EnergyPlus/FaultsManager.cc +++ b/src/EnergyPlus/FaultsManager.cc @@ -344,16 +344,16 @@ namespace FaultsManager { // Fault availability schedule if (lAlphaFieldBlanks(2)) { - faultsECFouling.availSchedNum = -1; // returns schedule value of 1 - } else if ((faultsECFouling.availSchedNum = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(2))) == 0) { + faultsECFouling.availSched = Sched::GetScheduleAlwaysOn(state); // returns schedule value of 1 + } else if ((faultsECFouling.availSched = Sched::GetSchedule(state, cAlphaArgs(2))) == nullptr) { ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(2), cAlphaArgs(2)); state.dataFaultsMgr->ErrorsFound = true; } // Fault severity schedule if (lAlphaFieldBlanks(3)) { - faultsECFouling.severitySchedNum = -1; // returns schedule value of 1 - } else if ((faultsECFouling.severitySchedNum = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(3))) == 0) { + faultsECFouling.severitySched = Sched::GetScheduleAlwaysOn(state); // returns schedule value of 1 + } else if ((faultsECFouling.severitySched = Sched::GetSchedule(state, cAlphaArgs(3))) == nullptr) { ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(3), cAlphaArgs(3)); state.dataFaultsMgr->ErrorsFound = true; } @@ -425,16 +425,16 @@ namespace FaultsManager { // Fault availability schedule if (lAlphaFieldBlanks(2)) { - faultsChillerFouling.availSchedNum = -1; // returns schedule value of 1 - } else if ((faultsChillerFouling.availSchedNum = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(2))) == 0) { + faultsChillerFouling.availSched = Sched::GetScheduleAlwaysOn(state); // returns schedule value of 1 + } else if ((faultsChillerFouling.availSched = Sched::GetSchedule(state, cAlphaArgs(2))) == nullptr) { ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(2), cAlphaArgs(2)); state.dataFaultsMgr->ErrorsFound = true; } // Fault severity schedule if (lAlphaFieldBlanks(3)) { - faultsChillerFouling.severitySchedNum = -1; // returns schedule value of 1 - } else if ((faultsChillerFouling.severitySchedNum = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(3))) == 0) { + faultsChillerFouling.severitySched = Sched::GetScheduleAlwaysOn(state); // returns schedule value of 1 + } else if ((faultsChillerFouling.severitySched = Sched::GetSchedule(state, cAlphaArgs(3))) == nullptr) { ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(3), cAlphaArgs(3)); state.dataFaultsMgr->ErrorsFound = true; } @@ -693,16 +693,16 @@ namespace FaultsManager { // Fault availability schedule if (lAlphaFieldBlanks(2)) { - faultsBoilerFouling.availSchedNum = -1; // returns schedule value of 1 - } else if ((faultsBoilerFouling.availSchedNum = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(2))) == 0) { + faultsBoilerFouling.availSched = Sched::GetScheduleAlwaysOn(state); // returns schedule value of 1 + } else if ((faultsBoilerFouling.availSched = Sched::GetSchedule(state, cAlphaArgs(2))) == nullptr) { ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(2), cAlphaArgs(2)); state.dataFaultsMgr->ErrorsFound = true; } // Fault severity schedule if (lAlphaFieldBlanks(3)) { - faultsBoilerFouling.severitySchedNum = -1; // returns schedule value of 1 - } else if ((faultsBoilerFouling.severitySchedNum = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(3))) == 0) { + faultsBoilerFouling.severitySched = Sched::GetScheduleAlwaysOn(state); // returns schedule value of 1 + } else if ((faultsBoilerFouling.severitySched = Sched::GetSchedule(state, cAlphaArgs(3))) == nullptr) { ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(3), cAlphaArgs(3)); state.dataFaultsMgr->ErrorsFound = true; } @@ -771,16 +771,16 @@ namespace FaultsManager { // Fault availability schedule if (lAlphaFieldBlanks(2)) { - faultsCoilSATFouling.availSchedNum = -1; // returns schedule value of 1 - } else if ((faultsCoilSATFouling.availSchedNum = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(2))) == 0) { + faultsCoilSATFouling.availSched = Sched::GetScheduleAlwaysOn(state); // returns schedule value of 1 + } else if ((faultsCoilSATFouling.availSched = Sched::GetSchedule(state, cAlphaArgs(2))) == nullptr) { ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(2), cAlphaArgs(2)); state.dataFaultsMgr->ErrorsFound = true; } // Fault severity schedule if (lAlphaFieldBlanks(3)) { - faultsCoilSATFouling.severitySchedNum = -1; // returns schedule value of 1 - } else if ((faultsCoilSATFouling.severitySchedNum = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(3))) == 0) { + faultsCoilSATFouling.severitySched = Sched::GetScheduleAlwaysOn(state); // returns schedule value of 1 + } else if ((faultsCoilSATFouling.severitySched = Sched::GetSchedule(state, cAlphaArgs(3))) == nullptr) { ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(3), cAlphaArgs(3)); state.dataFaultsMgr->ErrorsFound = true; } @@ -991,16 +991,16 @@ namespace FaultsManager { // Fault availability schedule if (lAlphaFieldBlanks(2)) { - faultsTowerFouling.availSchedNum = -1; // returns schedule value of 1 - } else if ((faultsTowerFouling.availSchedNum = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(2))) == 0) { + faultsTowerFouling.availSched = Sched::GetScheduleAlwaysOn(state); // returns schedule value of 1 + } else if ((faultsTowerFouling.availSched = Sched::GetSchedule(state, cAlphaArgs(2))) == nullptr) { ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(2), cAlphaArgs(2)); state.dataFaultsMgr->ErrorsFound = true; } // Fault severity schedule if (lAlphaFieldBlanks(3)) { - faultsTowerFouling.severitySchedNum = -1; // returns schedule value of 1 - } else if ((faultsTowerFouling.severitySchedNum = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(3))) == 0) { + faultsTowerFouling.severitySched = Sched::GetScheduleAlwaysOn(state); // returns schedule value of 1 + } else if ((faultsTowerFouling.severitySched = Sched::GetSchedule(state, cAlphaArgs(3))) == nullptr) { ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(3), cAlphaArgs(3)); state.dataFaultsMgr->ErrorsFound = true; } @@ -1099,16 +1099,16 @@ namespace FaultsManager { // Fault availability schedule if (lAlphaFieldBlanks(2)) { - faultsCondSWTFouling.availSchedNum = -1; // returns schedule value of 1 - } else if ((faultsCondSWTFouling.availSchedNum = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(2))) == 0) { + faultsCondSWTFouling.availSched = Sched::GetScheduleAlwaysOn(state); // returns schedule value of 1 + } else if ((faultsCondSWTFouling.availSched = Sched::GetSchedule(state, cAlphaArgs(2))) == nullptr) { ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(2), cAlphaArgs(2)); state.dataFaultsMgr->ErrorsFound = true; } // Fault severity schedule if (lAlphaFieldBlanks(3)) { - faultsCondSWTFouling.severitySchedNum = -1; // returns schedule value of 1 - } else if ((faultsCondSWTFouling.severitySchedNum = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(3))) == 0) { + faultsCondSWTFouling.severitySched = Sched::GetScheduleAlwaysOn(state); // returns schedule value of 1 + } else if ((faultsCondSWTFouling.severitySched = Sched::GetSchedule(state, cAlphaArgs(3))) == nullptr) { ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(3), cAlphaArgs(3)); state.dataFaultsMgr->ErrorsFound = true; } @@ -1192,16 +1192,16 @@ namespace FaultsManager { // Fault availability schedule if (lAlphaFieldBlanks(2)) { - faultsChillerSWT.availSchedNum = -1; // returns schedule value of 1 - } else if ((faultsChillerSWT.availSchedNum = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(2))) == 0) { + faultsChillerSWT.availSched = Sched::GetScheduleAlwaysOn(state); // returns schedule value of 1 + } else if ((faultsChillerSWT.availSched = Sched::GetSchedule(state, cAlphaArgs(2))) == nullptr) { ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(2), cAlphaArgs(2)); state.dataFaultsMgr->ErrorsFound = true; } // Fault severity schedule if (lAlphaFieldBlanks(3)) { - faultsChillerSWT.severitySchedNum = -1; // returns schedule value of 1 - } else if ((faultsChillerSWT.severitySchedNum = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(3))) == 0) { + faultsChillerSWT.severitySched = Sched::GetScheduleAlwaysOn(state); // returns schedule value of 1 + } else if ((faultsChillerSWT.severitySched = Sched::GetSchedule(state, cAlphaArgs(3))) == nullptr) { ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(3), cAlphaArgs(3)); state.dataFaultsMgr->ErrorsFound = true; } @@ -1441,16 +1441,16 @@ namespace FaultsManager { // Fault availability schedule if (lAlphaFieldBlanks(4)) { - faultsAirFilter.availSchedNum = -1; // returns schedule value of 1 - } else if ((faultsAirFilter.availSchedNum = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(4))) == 0) { + faultsAirFilter.availSched = Sched::GetScheduleAlwaysOn(state); // returns schedule value of 1 + } else if ((faultsAirFilter.availSched = Sched::GetSchedule(state, cAlphaArgs(4))) == nullptr) { ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(4), cAlphaArgs(4)); state.dataFaultsMgr->ErrorsFound = true; } // Fan pressure increase fraction schedule if (lAlphaFieldBlanks(5)) { - faultsAirFilter.pressFracSchedNum = -1; // returns schedule value of 1 - } else if ((faultsAirFilter.pressFracSchedNum = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(5))) == 0) { + faultsAirFilter.pressFracSched = Sched::GetScheduleAlwaysOn(state); // returns schedule value of 1 + } else if ((faultsAirFilter.pressFracSched = Sched::GetSchedule(state, cAlphaArgs(5))) == nullptr) { ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(5), cAlphaArgs(5)); state.dataFaultsMgr->ErrorsFound = true; } @@ -1512,16 +1512,16 @@ namespace FaultsManager { // Availability schedule if (lAlphaFieldBlanks(4)) { - faultsHStat.availSchedNum = -1; // returns schedule value of 1 - } else if ((faultsHStat.availSchedNum = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(4))) == 0) { + faultsHStat.availSched = Sched::GetScheduleAlwaysOn(state); // returns schedule value of 1 + } else if ((faultsHStat.availSched = Sched::GetSchedule(state, cAlphaArgs(4))) == nullptr) { ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(4), cAlphaArgs(4)); state.dataFaultsMgr->ErrorsFound = true; } // Severity schedule if (lAlphaFieldBlanks(5)) { - faultsHStat.severitySchedNum = -1; // returns schedule value of 1 - } else if ((faultsHStat.severitySchedNum = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(5))) == 0) { + faultsHStat.severitySched = Sched::GetScheduleAlwaysOn(state); // returns schedule value of 1 + } else if ((faultsHStat.severitySched = Sched::GetSchedule(state, cAlphaArgs(5))) == nullptr) { ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(5), cAlphaArgs(5)); state.dataFaultsMgr->ErrorsFound = true; } @@ -1565,16 +1565,16 @@ namespace FaultsManager { // Availability schedule if (lAlphaFieldBlanks(3)) { - faultsTStat.availSchedNum = -1; // returns schedule value of 1 - } else if ((faultsTStat.availSchedNum = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(3))) == 0) { + faultsTStat.availSched = Sched::GetScheduleAlwaysOn(state); // returns schedule value of 1 + } else if ((faultsTStat.availSched = Sched::GetSchedule(state, cAlphaArgs(3))) == nullptr) { ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(3), cAlphaArgs(3)); state.dataFaultsMgr->ErrorsFound = true; } // Severity schedule if (lAlphaFieldBlanks(4)) { - faultsTStat.severitySchedNum = -1; // returns schedule value of 1 - } else if ((faultsTStat.severitySchedNum = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(4))) == 0) { + faultsTStat.severitySched = Sched::GetScheduleAlwaysOn(state); // returns schedule value of 1 + } else if ((faultsTStat.severitySched = Sched::GetSchedule(state, cAlphaArgs(4))) == nullptr) { ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(4), cAlphaArgs(4)); state.dataFaultsMgr->ErrorsFound = true; } @@ -1613,16 +1613,16 @@ namespace FaultsManager { // Availability schedule if (lAlphaFieldBlanks(3)) { - faultsFoulCoil.availSchedNum = -1; // returns schedule value of 1 - } else if ((faultsFoulCoil.availSchedNum = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(3))) == 0) { + faultsFoulCoil.availSched = Sched::GetScheduleAlwaysOn(state); // returns schedule value of 1 + } else if ((faultsFoulCoil.availSched = Sched::GetSchedule(state, cAlphaArgs(3))) == nullptr) { ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(3), cAlphaArgs(3)); state.dataFaultsMgr->ErrorsFound = true; } // Severity schedule if (lAlphaFieldBlanks(4)) { - faultsFoulCoil.severitySchedNum = -1; // returns schedule value of 1 - } else if ((faultsFoulCoil.severitySchedNum = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(4))) == 0) { + faultsFoulCoil.severitySched = Sched::GetScheduleAlwaysOn(state); // returns schedule value of 1 + } else if ((faultsFoulCoil.severitySched = Sched::GetSchedule(state, cAlphaArgs(4))) == nullptr) { ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(4), cAlphaArgs(4)); state.dataFaultsMgr->ErrorsFound = true; } @@ -1775,16 +1775,16 @@ namespace FaultsManager { // check availability schedule if (lAlphaFieldBlanks(2)) { - fault.availSchedNum = -1; // returns schedule value of 1 - } else if ((fault.availSchedNum = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(2))) == 0) { + fault.availSched = Sched::GetScheduleAlwaysOn(state); // returns schedule value of 1 + } else if ((fault.availSched = Sched::GetSchedule(state, cAlphaArgs(2))) == nullptr) { ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(2), cAlphaArgs(2)); state.dataFaultsMgr->ErrorsFound = true; } // check severity schedule if (lAlphaFieldBlanks(3)) { - fault.severitySchedNum = -1; // returns schedule value of 1 - } else if ((fault.severitySchedNum = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(3))) == 0) { + fault.severitySched = Sched::GetScheduleAlwaysOn(state); // returns schedule value of 1 + } else if ((fault.severitySched = Sched::GetSchedule(state, cAlphaArgs(3))) == nullptr) { ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(3), cAlphaArgs(3)); state.dataFaultsMgr->ErrorsFound = true; } @@ -1827,7 +1827,7 @@ namespace FaultsManager { } } - Real64 FaultProperties::CalFaultOffsetAct(EnergyPlusData &state) + Real64 FaultProperties::CalFaultOffsetAct([[maybe_unused]] EnergyPlusData &state) { // SUBROUTINE INFORMATION: @@ -1839,25 +1839,18 @@ namespace FaultsManager { // SUBROUTINE LOCAL VARIABLE DECLARATIONS: Real64 FaultFac(0.0); // fault modification factor - Real64 OffsetAct; // actual offset after applying the modification factor // Check fault availability schedules - if (ScheduleManager::GetCurrentScheduleValue(state, this->availSchedNum) > 0.0) { + if (this->availSched->getCurrentVal() > 0.0) { // Check fault severity schedules - if (this->severitySchedNum >= 0) { - FaultFac = ScheduleManager::GetCurrentScheduleValue(state, this->severitySchedNum); - } else { - FaultFac = 1.0; - } + FaultFac = (this->severitySched != nullptr) ? this->severitySched->getCurrentVal() : 1.0; } - OffsetAct = FaultFac * this->Offset; - - return OffsetAct; + return FaultFac * this->Offset; } - Real64 FaultPropertiesFouling::CalFoulingFactor(EnergyPlusData &state) + Real64 FaultPropertiesFouling::CalFoulingFactor([[maybe_unused]] EnergyPlusData &state) { // SUBROUTINE INFORMATION: @@ -1874,14 +1867,10 @@ namespace FaultsManager { 1.0); // Actual Nominal Fouling Factor, ratio between the nominal capacity or efficiency at fouling case and that at fault free case // Check fault availability schedules - if (ScheduleManager::GetCurrentScheduleValue(state, this->availSchedNum) > 0.0) { + if (this->availSched->getCurrentVal() > 0.0) { // Check fault severity schedules - if (this->severitySchedNum >= 0) { - FaultFac = ScheduleManager::GetCurrentScheduleValue(state, this->severitySchedNum); - } else { - FaultFac = 1.0; - } + FaultFac = (this->severitySched != nullptr) ? this->severitySched->getCurrentVal() : 1.0; } // The more severe the fouling fault is (i.e., larger FaultFac), the less the FoulingFactor is @@ -1890,7 +1879,7 @@ namespace FaultsManager { return FoulingFactor; } - Real64 FaultPropertiesTowerFouling::CalFaultyTowerFoulingFactor(EnergyPlusData &state) + Real64 FaultPropertiesTowerFouling::CalFaultyTowerFoulingFactor([[maybe_unused]] EnergyPlusData &state) { // SUBROUTINE INFORMATION: @@ -1906,14 +1895,10 @@ namespace FaultsManager { Real64 UAReductionFactorAct(1.0); // actual UA Reduction Factor, ratio between the UA value at fouling case and that at fault free case // Check fault availability schedules - if (ScheduleManager::GetCurrentScheduleValue(state, this->availSchedNum) > 0.0) { + if (this->availSched->getCurrentVal() > 0.0) { // Check fault severity schedules - if (this->severitySchedNum >= 0) { - FaultFac = ScheduleManager::GetCurrentScheduleValue(state, this->severitySchedNum); - } else { - FaultFac = 1.0; - } + FaultFac = (this->severitySched != nullptr) ? this->severitySched->getCurrentVal() : 1.0; } // The more severe the fouling fault is (i.e., larger FaultFac), the less the UAReductionFactor is @@ -1922,7 +1907,7 @@ namespace FaultsManager { return UAReductionFactorAct; } - Real64 FaultPropertiesFoulingCoil::FaultFraction(EnergyPlusData &state) + Real64 FaultPropertiesFoulingCoil::FaultFraction([[maybe_unused]]EnergyPlusData &state) { // SUBROUTINE INFORMATION: // AUTHOR Julien Marrec, EffiBEM @@ -1932,10 +1917,10 @@ namespace FaultsManager { // Calculate the Fault Fraction based on Availability and Severity Schedules // Check fault availability schedules - if (ScheduleManager::GetCurrentScheduleValue(state, this->availSchedNum) > 0.0) { + if (this->availSched->getCurrentVal() > 0.0) { // Check fault severity schedules (Ptr initialized to -1, so would return a FaultFrac of 1 if not set) - return ScheduleManager::GetCurrentScheduleValue(state, this->severitySchedNum); + return this->severitySched->getCurrentVal(); } return 0.0; diff --git a/src/EnergyPlus/FaultsManager.hh b/src/EnergyPlus/FaultsManager.hh index 706830572bd..b13a7de0c30 100644 --- a/src/EnergyPlus/FaultsManager.hh +++ b/src/EnergyPlus/FaultsManager.hh @@ -149,8 +149,8 @@ namespace FaultsManager { // Members std::string Name; FaultType type = FaultType::Invalid; - int availSchedNum = 0; - int severitySchedNum = 0; + Sched::Schedule *availSched = nullptr; + Sched::Schedule *severitySched = nullptr; Real64 Offset = 0.0; // offset, + means sensor reading is higher than actual value bool Status = false; // for future use @@ -246,7 +246,7 @@ namespace FaultsManager { int fanNum = 0; HVAC::FanType fanType = HVAC::FanType::Invalid; // The type of the fan corresponding to the fouled air filter int fanCurveNum = 0; // The index to the curve - int pressFracSchedNum = 0; // The pointer to the schedule + Sched::Schedule *pressFracSched = nullptr; // The pointer to the schedule Real64 fanPressInc = 0.0; // The increase of the fan pressure due to fouled air filter Real64 fanFlowDec = 0.0; // The decrease of the fan airflow rate due to fouled air filter @@ -417,6 +417,10 @@ struct FaultsManagerData : BaseGlobalStruct Array1D FaultsChillerFouling; Array1D FaultsEvapCoolerFouling; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/FluidCoolers.hh b/src/EnergyPlus/FluidCoolers.hh index 894e5d7a171..c7612e48b3d 100644 --- a/src/EnergyPlus/FluidCoolers.hh +++ b/src/EnergyPlus/FluidCoolers.hh @@ -224,6 +224,10 @@ struct FluidCoolersData : BaseGlobalStruct Array1D SimpleFluidCooler; std::unordered_map UniqueSimpleFluidCoolerNames; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/FluidProperties.cc b/src/EnergyPlus/FluidProperties.cc index f42be6b6a47..548bf6553b4 100644 --- a/src/EnergyPlus/FluidProperties.cc +++ b/src/EnergyPlus/FluidProperties.cc @@ -506,6 +506,170 @@ namespace FluidProperties { 2797000.0, 3347000.0, 3976000.0, 4692000.0, 5503000.0, 6417000.0, 7442000.0, 8588000.0, 9865000.0, 11280000.0, 12860000.0, 14600000.0, 16530000.0, 18670000.0, 21040000.0, 30000000.0, 35000000.0, 40000000.0}; + void InitConstantFluidPropertiesData(EnergyPlusData &state) + { + constexpr std::string_view routineName = "InitConstantFluidPropertiesData"; + + auto &df = state.dataFluidProps; + bool ErrorsFound = false; + + // Where are these things initialized? + Array2D DefaultSteamSuperheatedEnthalpyData(DefaultNumSteamSuperheatedPressure, DefaultNumSteamSuperheatedTemps); + Array2D DefaultSteamSuperheatedDensityData(DefaultNumSteamSuperheatedPressure, DefaultNumSteamSuperheatedTemps); + + // Add refrigerant object for Steam. + auto *steam = new RefrigProps; + steam->Name = "STEAM"; + df->refrigs.push_back(steam); + steam->Num = df->refrigs.isize(); + + // Initialize Steam + steam->NumPsPoints = DefaultNumSteamTemps; + steam->PsTemps.allocate(DefaultNumSteamTemps); + steam->PsValues.allocate(DefaultNumSteamTemps); + steam->NumHPoints = DefaultNumSteamTemps; + steam->HTemps.allocate(DefaultNumSteamTemps); + steam->HfValues.allocate(DefaultNumSteamTemps); + steam->HfgValues.allocate(DefaultNumSteamTemps); + steam->NumCpPoints = DefaultNumSteamTemps; + steam->CpTemps.allocate(DefaultNumSteamTemps); + steam->CpfValues.allocate(DefaultNumSteamTemps); + steam->CpfgValues.allocate(DefaultNumSteamTemps); + steam->NumRhoPoints = DefaultNumSteamTemps; + steam->RhoTemps.allocate(DefaultNumSteamTemps); + steam->RhofValues.allocate(DefaultNumSteamTemps); + steam->RhofgValues.allocate(DefaultNumSteamTemps); + + steam->PsTemps = DefaultSteamTemps; + steam->PsValues = DefaultSteamPressData; + steam->HTemps = DefaultSteamTemps; + steam->HfValues = DefaultSteamEnthalpyFluidData; + steam->HfgValues = DefaultSteamEnthalpyGasFluidData; + steam->CpTemps = DefaultSteamTemps; + steam->CpfValues = DefaultSteamCpFluidData; + steam->CpfgValues = DefaultSteamCpGasFluidData; + steam->RhoTemps = DefaultSteamTemps; + steam->RhofValues = DefaultSteamDensityFluidData; + steam->RhofgValues = DefaultSteamDensityGasFluidData; + + steam->NumSupTempPoints = DefaultNumSteamSuperheatedTemps; + steam->NumSupPressPoints = DefaultNumSteamSuperheatedPressure; + steam->SupTemps.allocate(steam->NumSupTempPoints); + steam->SupPress.allocate(steam->NumSupPressPoints); + steam->HshValues.allocate(steam->NumSupPressPoints, steam->NumSupTempPoints); + steam->RhoshValues.allocate(steam->NumSupPressPoints, steam->NumSupTempPoints); + steam->SupTemps = DefaultSteamSuperheatedTemps; + steam->SupPress = DefaultSteamSuperheatedPressData; + steam->HshValues = DefaultSteamSuperheatedEnthalpyData; + steam->RhoshValues = DefaultSteamSuperheatedDensityData; + + // Water is always available + auto *waterRaw = GetGlycolRaw(state, "WATER"); + if (waterRaw == nullptr) { + waterRaw = new GlycolRawProps; + waterRaw->Name = "WATER"; + + df->glycolsRaw.push_back(waterRaw); + waterRaw->Num = df->glycolsRaw.isize(); + } + + waterRaw->CpDataPresent = true; + waterRaw->NumCpConcPoints = 1; + waterRaw->NumCpTempPoints = DefaultNumGlyTemps; + waterRaw->CpTemps.allocate(waterRaw->NumCpTempPoints); + waterRaw->CpTemps = DefaultGlycolTemps; + waterRaw->CpConcs.allocate(waterRaw->NumCpConcPoints); + waterRaw->CpConcs = 0.0; + waterRaw->CpValues.allocate(waterRaw->NumCpConcPoints, waterRaw->NumCpTempPoints); + waterRaw->CpValues(1, {1, waterRaw->NumCpTempPoints}) = DefaultWaterCpData; + + waterRaw->RhoDataPresent = true; + waterRaw->NumRhoConcPoints = 1; + waterRaw->NumRhoTempPoints = DefaultNumGlyTemps; + waterRaw->RhoTemps.allocate(waterRaw->NumRhoTempPoints); + waterRaw->RhoTemps = DefaultGlycolTemps; + waterRaw->RhoConcs.allocate(waterRaw->NumRhoConcPoints); + waterRaw->RhoConcs = 0.0; + waterRaw->RhoValues.allocate(waterRaw->NumRhoConcPoints, waterRaw->NumRhoTempPoints); + waterRaw->RhoValues(1, {1, waterRaw->NumRhoTempPoints}) = DefaultWaterRhoData; + + waterRaw->CondDataPresent = true; + waterRaw->NumCondConcPoints = 1; + waterRaw->NumCondTempPoints = DefaultNumGlyTemps; + waterRaw->CondTemps.allocate(waterRaw->NumCondTempPoints); + waterRaw->CondTemps = DefaultGlycolTemps; + waterRaw->CondConcs.allocate(waterRaw->NumCondConcPoints); + waterRaw->CondConcs = 0.0; + waterRaw->CondValues.allocate(waterRaw->NumCondConcPoints, waterRaw->NumCondTempPoints); + waterRaw->CondValues(1, {1, waterRaw->NumCondTempPoints}) = DefaultWaterCondData; + + waterRaw->ViscDataPresent = true; + waterRaw->NumViscConcPoints = 1; + waterRaw->NumViscTempPoints = DefaultNumGlyTemps; + waterRaw->ViscTemps.allocate(waterRaw->NumViscTempPoints); + waterRaw->ViscTemps = DefaultGlycolTemps; + waterRaw->ViscConcs.allocate(waterRaw->NumViscConcPoints); + waterRaw->ViscConcs = 0.0; + waterRaw->ViscValues.allocate(waterRaw->NumViscConcPoints, waterRaw->NumViscTempPoints); + waterRaw->ViscValues(1, {1, waterRaw->NumViscTempPoints}) = DefaultWaterViscData; + + // Water is always available + auto *water = GetGlycol(state, "WATER"); + if (water == nullptr) { + water = new GlycolProps; + water->Name = "WATER"; + water->GlycolName = "WATER"; + water->used = true; // mark Water as always used + + df->glycols.push_back(water); + water->Num = df->glycols.isize(); + } + water->Concentration = 1.0; + water->CpDataPresent = true; + water->NumCpTempPoints = DefaultNumGlyTemps; + water->RhoDataPresent = true; + water->NumRhoTempPoints = DefaultNumGlyTemps; + water->CondDataPresent = true; + water->NumCondTempPoints = DefaultNumGlyTemps; + water->ViscDataPresent = true; + water->NumViscTempPoints = DefaultNumGlyTemps; + water->CpTemps.allocate(water->NumCpTempPoints); + water->CpValues.allocate(water->NumCpTempPoints); + water->RhoTemps.allocate(water->NumRhoTempPoints); + water->RhoValues.allocate(water->NumRhoTempPoints); + water->CondTemps.allocate(water->NumCondTempPoints); + water->CondValues.allocate(water->NumCondTempPoints); + water->ViscTemps.allocate(water->NumViscTempPoints); + water->ViscValues.allocate(water->NumViscTempPoints); + water->CpTemps = DefaultGlycolTemps; + water->CpValues = DefaultWaterCpData; + water->RhoTemps = DefaultGlycolTemps; + water->RhoValues = DefaultWaterRhoData; + water->CondTemps = DefaultGlycolTemps; + water->CondValues = DefaultWaterCondData; + water->ViscTemps = DefaultGlycolTemps; + water->ViscValues = DefaultWaterViscData; + + water->setTemperatureLimits(state, ErrorsFound, routineName); + +#ifdef PERFORMANCE_OPT + // This is a speed optimization. Maybe. + water->CpTempRatios.allocate(water->NumCpTempPoints); + for (int i = 1; i < water->NumCpTempPoints; ++i) + water->CpTempRatios(i) = (water->CpValues(i + 1) - water->CpValues(i)) / (water->CpTemps(i + 1) - water->CpTemps(i)); + water->RhoTempRatios.allocate(water->NumRhoTempPoints); + for (int i = 1; i < water->NumRhoTempPoints; ++i) + water->RhoTempRatios(i) = (water->RhoValues(i + 1) - water->RhoValues(i)) / (water->RhoTemps(i + 1) - water->RhoTemps(i)); + water->CondTempRatios.allocate(water->NumCondTempPoints); + for (int i = 1; i < water->NumCondTempPoints; ++i) + water->CondTempRatios(i) = (water->CondValues(i + 1) - water->CondValues(i)) / (water->CondTemps(i + 1) - water->CondTemps(i)); + water->ViscTempRatios.allocate(water->NumViscTempPoints); + for (int i = 1; i < water->NumCondTempPoints; ++i) + water->ViscTempRatios(i) = (water->ViscValues(i + 1) - water->ViscValues(i)) / (water->ViscTemps(i + 1) - water->ViscTemps(i)); +#endif // PERFORMANCE_OPT + + } // InitConstantFluidPropertiesData() + void GetFluidPropertiesData(EnergyPlusData &state) { @@ -526,7 +690,7 @@ namespace FluidProperties { // allocated as necessary as the data is read into the program. // SUBROUTINE PARAMETER DEFINITIONS: - Real64 constexpr PressToler(1.0); // Some reasonable value for comparisons + // Real64 constexpr PressToler(1.0); // Some reasonable value for comparisons static constexpr std::string_view routineName = "GetFluidPropertiesData"; // SUBROUTINE LOCAL VARIABLE DECLARATIONS: @@ -555,23 +719,8 @@ namespace FluidProperties { auto &df = state.dataFluidProps; - // This is here because of a unit test in HVACVRF:2358 - for (int i = 1; i <= df->refrigs.isize(); ++i) - delete df->refrigs(i); - df->refrigs.clear(); - for (int i = 1; i <= df->glycolsRaw.isize(); ++i) - delete df->glycolsRaw(i); - df->glycolsRaw.clear(); - for (int i = 1; i <= df->glycols.isize(); ++i) - delete df->glycols(i); - df->glycols.clear(); - // For default "glycol" fluids of Water, Ethylene Glycol, and Propylene Glycol - // Where are these things initialized? - Array2D DefaultSteamSuperheatedEnthalpyData(DefaultNumSteamSuperheatedPressure, DefaultNumSteamSuperheatedTemps); - Array2D DefaultSteamSuperheatedDensityData(DefaultNumSteamSuperheatedPressure, DefaultNumSteamSuperheatedTemps); - struct FluidTempData { // Members @@ -637,12 +786,6 @@ namespace FluidProperties { cNumericFields = ""; lNumericFieldBlanks = false; - // First things first, add refrigerant placeholder for Steam. - auto *steam = new RefrigProps; - steam->Name = "STEAM"; - df->refrigs.push_back(steam); - steam->Num = df->refrigs.isize(); - // Check to see if there is any FluidName input. If not, this is okay as // long as the user only desires to simulate loops with water. More than // one FluidName input is not allowed. @@ -688,46 +831,6 @@ namespace FluidProperties { ShowFatalError(state, format("{}: Previous errors in input cause program termination.", routineName)); } - // Initialize Steam - steam->NumPsPoints = DefaultNumSteamTemps; - steam->PsTemps.allocate(DefaultNumSteamTemps); - steam->PsValues.allocate(DefaultNumSteamTemps); - steam->NumHPoints = DefaultNumSteamTemps; - steam->HTemps.allocate(DefaultNumSteamTemps); - steam->HfValues.allocate(DefaultNumSteamTemps); - steam->HfgValues.allocate(DefaultNumSteamTemps); - steam->NumCpPoints = DefaultNumSteamTemps; - steam->CpTemps.allocate(DefaultNumSteamTemps); - steam->CpfValues.allocate(DefaultNumSteamTemps); - steam->CpfgValues.allocate(DefaultNumSteamTemps); - steam->NumRhoPoints = DefaultNumSteamTemps; - steam->RhoTemps.allocate(DefaultNumSteamTemps); - steam->RhofValues.allocate(DefaultNumSteamTemps); - steam->RhofgValues.allocate(DefaultNumSteamTemps); - - steam->PsTemps = DefaultSteamTemps; - steam->PsValues = DefaultSteamPressData; - steam->HTemps = DefaultSteamTemps; - steam->HfValues = DefaultSteamEnthalpyFluidData; - steam->HfgValues = DefaultSteamEnthalpyGasFluidData; - steam->CpTemps = DefaultSteamTemps; - steam->CpfValues = DefaultSteamCpFluidData; - steam->CpfgValues = DefaultSteamCpGasFluidData; - steam->RhoTemps = DefaultSteamTemps; - steam->RhofValues = DefaultSteamDensityFluidData; - steam->RhofgValues = DefaultSteamDensityGasFluidData; - - steam->NumSupTempPoints = DefaultNumSteamSuperheatedTemps; - steam->NumSupPressPoints = DefaultNumSteamSuperheatedPressure; - steam->SupTemps.allocate(steam->NumSupTempPoints); - steam->SupPress.allocate(steam->NumSupPressPoints); - steam->HshValues.allocate(steam->NumSupPressPoints, steam->NumSupTempPoints); - steam->RhoshValues.allocate(steam->NumSupPressPoints, steam->NumSupTempPoints); - steam->SupTemps = DefaultSteamSuperheatedTemps; - steam->SupPress = DefaultSteamSuperheatedPressData; - steam->HshValues = DefaultSteamSuperheatedEnthalpyData; - steam->RhoshValues = DefaultSteamSuperheatedDensityData; - // Read in all of the temperature arrays in the input file FluidTemps.allocate(NumOfFluidTempArrays); @@ -803,7 +906,7 @@ namespace FluidProperties { } if (refrig->satTempArrayName != "" && refrig->satTempArrayName != Alphas(4)) { - ShowSevereCustomMessage(state, eoh, "Saturated temperature arrays are not the same for different properties"); + ShowSevereCustom(state, eoh, "Saturated temperature arrays are not the same for different properties"); ErrorsFound = true; continue; } @@ -901,66 +1004,44 @@ namespace FluidProperties { ErrorObjectHeader eoh{routineName, CurrentModuleObject, refrig->Name}; if (refrig->PsValues.size() == 0) { - ShowSevereCustomMessage(state, - eoh, - format(R"(No Gas/Fluid Saturation Pressure found. Need properties with {}="Pressure" and {}="FluidGas".)", - cAlphaFields(2), - cAlphaFields(3))); + ShowSevereCustom(state, eoh, format(R"(No Gas/Fluid Saturation Pressure found. Need properties with {}="Pressure" and {}="FluidGas".)", + cAlphaFields(2), cAlphaFields(3))); ErrorsFound = true; } if (refrig->HfValues.size() == 0) { - ShowSevereCustomMessage(state, - eoh, - format(R"(No Saturated Fluid Enthalpy found. Need properties with {}="Enthalpy" and {}="Fluid".)", - cAlphaFields(2), - cAlphaFields(3))); + ShowSevereCustom(state, eoh, format(R"(No Saturated Fluid Enthalpy found. Need properties with {}="Enthalpy" and {}="Fluid".)", + cAlphaFields(2), cAlphaFields(3))); ErrorsFound = true; } if (refrig->HfgValues.size() == 0) { - ShowSevereCustomMessage(state, - eoh, - format(R"(No Saturated Gas/Fluid Enthalpy found. Need properties with {}="Enthalpy" and {}="FluidGas".)", - cAlphaFields(2), - cAlphaFields(3))); + ShowSevereCustom(state, eoh, format(R"(No Saturated Gas/Fluid Enthalpy found. Need properties with {}="Enthalpy" and {}="FluidGas".)", + cAlphaFields(2), cAlphaFields(3))); ErrorsFound = true; } if (refrig->CpfValues.size() == 0) { - ShowSevereCustomMessage(state, - eoh, - format(R"(No Saturated Fluid Specific Heat found. Need properties with {}="SpecificHeat" and {}="Fluid".)", - cAlphaFields(2), - cAlphaFields(3))); + ShowSevereCustom(state, eoh, format(R"(No Saturated Fluid Specific Heat found. Need properties with {}="SpecificHeat" and {}="Fluid".)", + cAlphaFields(2), cAlphaFields(3))); ErrorsFound = true; } if (refrig->CpfgValues.size() == 0) { - ShowSevereCustomMessage( - state, - eoh, - format(R"(No Saturated Gas/Fluid Specific Heat found. Need properties with {}="SpecificHeat" and {}="FluidGas".)", - cAlphaFields(2), - cAlphaFields(3))); + ShowSevereCustom(state, eoh, format(R"(No Saturated Gas/Fluid Specific Heat found. Need properties with {}="SpecificHeat" and {}="FluidGas".)", + cAlphaFields(2), cAlphaFields(3))); ErrorsFound = true; } if (refrig->RhofValues.size() == 0) { - ShowSevereCustomMessage(state, - eoh, - format(R"(No Saturated Fluid Density found. Need properties with {}="Density" and {}="Fluid".)", - cAlphaFields(2), - cAlphaFields(3))); + ShowSevereCustom(state, eoh, format(R"(No Saturated Fluid Density found. Need properties with {}="Density" and {}="Fluid".)", + cAlphaFields(2), cAlphaFields(3))); ErrorsFound = true; } if (refrig->RhofgValues.size() == 0) { - ShowSevereCustomMessage(state, - eoh, - format(R"(No Saturated Gas/Fluid Density found. Need properties with {}="Density" and {}="FluidGas".)", - cAlphaFields(2), - cAlphaFields(3))); + ShowSevereCustom(state, eoh, format(R"(No Saturated Gas/Fluid Density found. Need properties with {}="Density" and {}="FluidGas".)", + cAlphaFields(2), cAlphaFields(3))); ErrorsFound = true; } } // for (refrigNum) @@ -1019,7 +1100,7 @@ namespace FluidProperties { } if (refrig->supTempArrayName != "" && refrig->supTempArrayName != Alphas(3)) { - ShowSevereCustomMessage(state, eoh, "Saturated temperature arrays are not the same for different properties"); + ShowSevereCustom(state, eoh, "Saturated temperature arrays are not the same for different properties"); ErrorsFound = true; continue; } @@ -1089,12 +1170,8 @@ namespace FluidProperties { } if ((NumNumbers - 1) != refrig->NumSupTempPoints) { - ShowSevereCustomMessage(state, - eoh, - format("Number of superheated {} points ({}) not equal to number of temperature points ({})", - Alphas(2), - NumNumbers - 1, - refrig->NumSupTempPoints)); + ShowSevereCustom(state, eoh, format("Number of superheated {} points ({}) not equal to number of temperature points ({})", + Alphas(2), NumNumbers - 1, refrig->NumSupTempPoints)); ErrorsFound = true; continue; } @@ -1120,62 +1197,11 @@ namespace FluidProperties { } } // for (InData) - // *************** RAW GLYCOLS *************** - // Go through each glycol found in the fluid names statement and read in the data - // Note that every valid fluid must have ALL of the necessary data or a fatal error will - // be produced. - - // Propylene and ethylene are available by default - - auto *waterRaw = GetGlycolRaw(state, "WATER"); - if (waterRaw == nullptr) { - waterRaw = new GlycolRawProps; - waterRaw->Name = "WATER"; - - df->glycolsRaw.push_back(waterRaw); - waterRaw->Num = df->glycolsRaw.isize(); + if (!ErrorsFound) { + for (auto *refrig : df->refrigs) refrig->setTemperatureLimits(state, ErrorsFound, routineName); } - - waterRaw->CpDataPresent = true; - waterRaw->NumCpConcPoints = 1; - waterRaw->NumCpTempPoints = DefaultNumGlyTemps; - waterRaw->CpTemps.allocate(waterRaw->NumCpTempPoints); - waterRaw->CpTemps = DefaultGlycolTemps; - waterRaw->CpConcs.allocate(waterRaw->NumCpConcPoints); - waterRaw->CpConcs = 0.0; - waterRaw->CpValues.allocate(waterRaw->NumCpConcPoints, waterRaw->NumCpTempPoints); - waterRaw->CpValues(1, {1, waterRaw->NumCpTempPoints}) = DefaultWaterCpData; - - waterRaw->RhoDataPresent = true; - waterRaw->NumRhoConcPoints = 1; - waterRaw->NumRhoTempPoints = DefaultNumGlyTemps; - waterRaw->RhoTemps.allocate(waterRaw->NumRhoTempPoints); - waterRaw->RhoTemps = DefaultGlycolTemps; - waterRaw->RhoConcs.allocate(waterRaw->NumRhoConcPoints); - waterRaw->RhoConcs = 0.0; - waterRaw->RhoValues.allocate(waterRaw->NumRhoConcPoints, waterRaw->NumRhoTempPoints); - waterRaw->RhoValues(1, {1, waterRaw->NumRhoTempPoints}) = DefaultWaterRhoData; - - waterRaw->CondDataPresent = true; - waterRaw->NumCondConcPoints = 1; - waterRaw->NumCondTempPoints = DefaultNumGlyTemps; - waterRaw->CondTemps.allocate(waterRaw->NumCondTempPoints); - waterRaw->CondTemps = DefaultGlycolTemps; - waterRaw->CondConcs.allocate(waterRaw->NumCondConcPoints); - waterRaw->CondConcs = 0.0; - waterRaw->CondValues.allocate(waterRaw->NumCondConcPoints, waterRaw->NumCondTempPoints); - waterRaw->CondValues(1, {1, waterRaw->NumCondTempPoints}) = DefaultWaterCondData; - - waterRaw->ViscDataPresent = true; - waterRaw->NumViscConcPoints = 1; - waterRaw->NumViscTempPoints = DefaultNumGlyTemps; - waterRaw->ViscTemps.allocate(waterRaw->NumViscTempPoints); - waterRaw->ViscTemps = DefaultGlycolTemps; - waterRaw->ViscConcs.allocate(waterRaw->NumViscConcPoints); - waterRaw->ViscConcs = 0.0; - waterRaw->ViscValues.allocate(waterRaw->NumViscConcPoints, waterRaw->NumViscTempPoints); - waterRaw->ViscValues(1, {1, waterRaw->NumViscTempPoints}) = DefaultWaterViscData; - + + // Ethylene and Propylene are available auto *ethylene = GetGlycolRaw(state, "ETHYLENEGLYCOL"); if (ethylene == nullptr) { ethylene = new GlycolRawProps; @@ -1314,6 +1340,11 @@ namespace FluidProperties { for (int i = 1; i <= propylene->NumViscConcPoints; ++i) propylene->ViscValues(i, {1, propylene->NumViscTempPoints}) = DefaultPropGlyViscData[i - 1]; + // *************** RAW GLYCOLS *************** + // Go through each glycol found in the fluid names statement and read in the data + // Note that every valid fluid must have ALL of the necessary data or a fatal error will + // be produced. + CurrentModuleObject = "FluidProperties:Concentration"; for (int InData = 1; InData <= NumOfGlyFluidPropArrays; ++InData) { // check temperatures given for specific heat are consistant state.dataInputProcessing->inputProcessor->getObjectItem(state, @@ -1347,7 +1378,7 @@ namespace FluidProperties { } if (Numbers(1) < 0.0) { - ShowSevereCustomMessage(state, eoh, "Negative concentrations not allowed in fluid property input data"); + ShowSevereCustom(state, eoh, "Negative concentrations not allowed in fluid property input data"); ErrorsFound = true; continue; } @@ -1355,12 +1386,9 @@ namespace FluidProperties { // Can temperatue and pressure points be different for different properties? Why is this allowed? if (Alphas(2) == "SPECIFICHEAT") { if (glycolRaw->CpTempArrayName != "" && glycolRaw->CpTempArrayName != Alphas(3)) { - ShowSevereCustomMessage(state, - eoh, - format("All specific heat data for the same glycol must use the same temperature list" - "Expected name={}, Entered name={}", - glycolRaw->CpTempArrayName, - Alphas(3))); + ShowSevereCustom(state, eoh, + format("All specific heat data for the same glycol must use the same temperature list" + "Expected name={}, Entered name={}", glycolRaw->CpTempArrayName, Alphas(3))); ErrorsFound = true; continue; } @@ -1374,12 +1402,8 @@ namespace FluidProperties { } else if (Alphas(2) == "DENSITY") { if (glycolRaw->RhoTempArrayName != "" && glycolRaw->RhoTempArrayName != Alphas(3)) { - ShowSevereCustomMessage(state, - eoh, - format("All density data for the same glycol must use the same temperature list" - "Expected name={}, Entered name={}", - glycolRaw->RhoTempArrayName, - Alphas(3))); + ShowSevereCustom(state, eoh, format("All density data for the same glycol must use the same temperature list" + "Expected name={}, Entered name={}", glycolRaw->RhoTempArrayName, Alphas(3))); ErrorsFound = true; continue; } @@ -1393,12 +1417,8 @@ namespace FluidProperties { } else if (Alphas(2) == "CONDUCTIVITY") { if (glycolRaw->CondTempArrayName != "" && glycolRaw->CondTempArrayName != Alphas(3)) { - ShowSevereCustomMessage(state, - eoh, - format("All conductivity data for the same glycol must use the same temperature list" - "Expected name={}, Entered name={}", - glycolRaw->CondTempArrayName, - Alphas(3))); + ShowSevereCustom(state, eoh, format("All conductivity data for the same glycol must use the same temperature list" + "Expected name={}, Entered name={}", glycolRaw->CondTempArrayName, Alphas(3))); ErrorsFound = true; continue; } @@ -1412,12 +1432,8 @@ namespace FluidProperties { } else if (Alphas(2) == "VISCOSITY") { if (glycolRaw->ViscTempArrayName != "" && glycolRaw->ViscTempArrayName != Alphas(3)) { - ShowSevereCustomMessage(state, - eoh, - format("All conductivity data for the same glycol must use the same temperature list" - "Expected name={}, Entered name={}", - glycolRaw->ViscTempArrayName, - Alphas(3))); + ShowSevereCustom(state, eoh, format("All conductivity data for the same glycol must use the same temperature list" + "Expected name={}, Entered name={}", glycolRaw->ViscTempArrayName, Alphas(3))); ErrorsFound = true; continue; } @@ -1508,11 +1524,8 @@ namespace FluidProperties { if (Alphas(2) == "SPECIFICHEAT") { if ((NumNumbers - 1) != glycolRaw->NumCpTempPoints) { - ShowSevereCustomMessage(state, - eoh, - format("Number of specific heat points ({}) not equal to number of temperature points ({})", - NumNumbers - 1, - glycolRaw->NumCpTempPoints)); + ShowSevereCustom(state, eoh, format("Number of specific heat points ({}) not equal to number of temperature points ({})", + NumNumbers - 1, glycolRaw->NumCpTempPoints)); ErrorsFound = true; continue; } @@ -1523,11 +1536,8 @@ namespace FluidProperties { } else if (Alphas(2) == "DENSITY") { if ((NumNumbers - 1) != glycolRaw->NumRhoTempPoints) { - ShowSevereCustomMessage(state, - eoh, - format("Number of density points ({}) not equal to number of temperature points ({})", - NumNumbers - 1, - glycolRaw->NumRhoTempPoints)); + ShowSevereCustom(state, eoh, format("Number of density points ({}) not equal to number of temperature points ({})", + NumNumbers - 1, glycolRaw->NumRhoTempPoints)); ErrorsFound = true; continue; } @@ -1538,11 +1548,8 @@ namespace FluidProperties { } else if (Alphas(2) == "CONDUCTIVITY") { if ((NumNumbers - 1) != glycolRaw->NumCondTempPoints) { - ShowSevereCustomMessage(state, - eoh, - format("Number of conductivity points ({}) not equal to number of temperature points ({})", - NumNumbers - 1, - glycolRaw->NumCondTempPoints)); + ShowSevereCustom(state, eoh, format("Number of conductivity points ({}) not equal to number of temperature points ({})", + NumNumbers - 1, glycolRaw->NumCondTempPoints)); ErrorsFound = true; continue; } @@ -1553,11 +1560,8 @@ namespace FluidProperties { } else if (Alphas(2) == "VISCOSITY") { if ((NumNumbers - 1) != glycolRaw->NumViscTempPoints) { - ShowSevereCustomMessage(state, - eoh, - format("Number of viscosity points ({}) not equal to number of temperature points ({})", - NumNumbers - 1, - glycolRaw->NumViscTempPoints)); + ShowSevereCustom(state, eoh, format("Number of viscosity points ({}) not equal to number of temperature points ({})", + NumNumbers - 1, glycolRaw->NumViscTempPoints)); ErrorsFound = true; continue; } @@ -1599,58 +1603,6 @@ namespace FluidProperties { CurrentModuleObject = "FluidProperties:GlycolConcentration"; NumOfOptionalInput = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject); - auto *water = GetGlycol(state, "WATER"); - if (water == nullptr) { - water = new GlycolProps; - water->Name = "WATER"; - water->GlycolName = "WATER"; - water->used = true; // mark Water as always used - - df->glycols.push_back(water); - water->Num = df->glycols.isize(); - } - water->Concentration = 1.0; - water->CpDataPresent = true; - water->NumCpTempPoints = DefaultNumGlyTemps; - water->RhoDataPresent = true; - water->NumRhoTempPoints = DefaultNumGlyTemps; - water->CondDataPresent = true; - water->NumCondTempPoints = DefaultNumGlyTemps; - water->ViscDataPresent = true; - water->NumViscTempPoints = DefaultNumGlyTemps; - water->CpTemps.allocate(water->NumCpTempPoints); - water->CpValues.allocate(water->NumCpTempPoints); - water->RhoTemps.allocate(water->NumRhoTempPoints); - water->RhoValues.allocate(water->NumRhoTempPoints); - water->CondTemps.allocate(water->NumCondTempPoints); - water->CondValues.allocate(water->NumCondTempPoints); - water->ViscTemps.allocate(water->NumViscTempPoints); - water->ViscValues.allocate(water->NumViscTempPoints); - water->CpTemps = DefaultGlycolTemps; - water->CpValues = DefaultWaterCpData; - water->RhoTemps = DefaultGlycolTemps; - water->RhoValues = DefaultWaterRhoData; - water->CondTemps = DefaultGlycolTemps; - water->CondValues = DefaultWaterCondData; - water->ViscTemps = DefaultGlycolTemps; - water->ViscValues = DefaultWaterViscData; - -#ifdef PERFORMANCE_OPT - // This is a speed optimization. Maybe. - water->CpTempRatios.allocate(water->NumCpTempPoints); - for (int i = 1; i < water->NumCpTempPoints; ++i) - water->CpTempRatios(i) = (water->CpValues(i + 1) - water->CpValues(i)) / (water->CpTemps(i + 1) - water->CpTemps(i)); - water->RhoTempRatios.allocate(water->NumRhoTempPoints); - for (int i = 1; i < water->NumRhoTempPoints; ++i) - water->RhoTempRatios(i) = (water->RhoValues(i + 1) - water->RhoValues(i)) / (water->RhoTemps(i + 1) - water->RhoTemps(i)); - water->CondTempRatios.allocate(water->NumCondTempPoints); - for (int i = 1; i < water->NumCondTempPoints; ++i) - water->CondTempRatios(i) = (water->CondValues(i + 1) - water->CondValues(i)) / (water->CondTemps(i + 1) - water->CondTemps(i)); - water->ViscTempRatios.allocate(water->NumViscTempPoints); - for (int i = 1; i < water->NumCondTempPoints; ++i) - water->ViscTempRatios(i) = (water->ViscValues(i + 1) - water->ViscValues(i)) / (water->ViscTemps(i + 1) - water->ViscTemps(i)); -#endif // PERFORMANCE_OPT - for (int Loop = 1; Loop <= NumOfOptionalInput; ++Loop) { state.dataInputProcessing->inputProcessor->getObjectItem(state, CurrentModuleObject, @@ -1786,6 +1738,7 @@ namespace FluidProperties { glycol->Concentration, glycol->ViscValues); + glycol->setTemperatureLimits(state, ErrorsFound, routineName); #ifdef PERFORMANCE_OPT // This is a speed optimization. Maybe. glycol->CpTempRatios.allocate(glycol->NumCpTempPoints); @@ -1803,10 +1756,6 @@ namespace FluidProperties { #endif // PERFORMANCE_OPT } // for (Loop) - if (!ErrorsFound) InitializeGlycolTempLimits(state, ErrorsFound); // Initialize the Temp limits for the glycols - - if (!ErrorsFound) InitializeRefrigerantLimits(state, ErrorsFound); // Initialize the limits for the refrigerants - FluidTemps.deallocate(); Alphas.deallocate(); @@ -1924,110 +1873,79 @@ namespace FluidProperties { //***************************************************************************** - void InitializeGlycolTempLimits(EnergyPlusData &state, bool &ErrorsFound) // set to true if errors found here + void GlycolProps::setTemperatureLimits(EnergyPlusData &state, bool &ErrorsFound, std::string_view routineName) { + // check for lowest non-zero value by referencing temp data + for (int iTemp = 1; iTemp <= this->NumCpTempPoints; ++iTemp) { + if (this->CpValues(iTemp) <= 0.0) continue; + this->CpLowTempIndex = iTemp; + this->CpLowTempValue = this->CpTemps(iTemp); + break; + } + // check for highest non-zero value by referencing temp data + for (int iTemp = this->NumCpTempPoints; iTemp >= 1; --iTemp) { + if (this->CpValues(iTemp) <= 0.0) continue; + this->CpHighTempIndex = iTemp; + this->CpHighTempValue = this->CpTemps(iTemp); + break; + } - // SUBROUTINE INFORMATION: - // AUTHOR Linda Lawrie - // DATE WRITTEN March 2008 - - // PURPOSE OF THIS SUBROUTINE: - // This routine sets up the min/max temperature limits for the glycol properties. - // Most properties requested (e.g., Specific Heat) must be > 0 but the tables may - // be set up for symmetry and not be limited to just valid values. - - auto const &df = state.dataFluidProps; - - for (auto *glycol : df->glycols) { - if (glycol->CpDataPresent) { - // check for lowest non-zero value by referencing temp data - for (int IndexNum = 1; IndexNum <= glycol->NumCpTempPoints; ++IndexNum) { - if (glycol->CpValues(IndexNum) <= 0.0) continue; - glycol->CpLowTempIndex = IndexNum; - glycol->CpLowTempValue = glycol->CpTemps(IndexNum); - break; - } - // check for highest non-zero value by referencing temp data - for (int IndexNum = glycol->NumCpTempPoints; IndexNum >= 1; --IndexNum) { - if (glycol->CpValues(IndexNum) <= 0.0) continue; - glycol->CpHighTempIndex = IndexNum; - glycol->CpHighTempValue = glycol->CpTemps(IndexNum); - break; - } - } - if (glycol->RhoDataPresent) { - // check for lowest non-zero value by referencing temp data - for (int IndexNum = 1; IndexNum <= glycol->NumRhoTempPoints; ++IndexNum) { - if (glycol->RhoValues(IndexNum) <= 0.0) continue; - glycol->RhoLowTempIndex = IndexNum; - glycol->RhoLowTempValue = glycol->RhoTemps(IndexNum); - break; - } - // check for highest non-zero value by referencing temp data - for (int IndexNum = glycol->NumRhoTempPoints; IndexNum >= 1; --IndexNum) { - if (glycol->RhoValues(IndexNum) <= 0.0) continue; - glycol->RhoHighTempIndex = IndexNum; - glycol->RhoHighTempValue = glycol->RhoTemps(IndexNum); - break; - } - } - if (glycol->CondDataPresent) { - // check for lowest non-zero value by referencing temp data - for (int IndexNum = 1; IndexNum <= glycol->NumCondTempPoints; ++IndexNum) { - if (glycol->CondValues(IndexNum) <= 0.0) continue; - glycol->CondLowTempIndex = IndexNum; - glycol->CondLowTempValue = glycol->CondTemps(IndexNum); - break; - } - // check for highest non-zero value by referencing temp data - for (int IndexNum = glycol->NumCondTempPoints; IndexNum >= 1; --IndexNum) { - if (glycol->CondValues(IndexNum) <= 0.0) continue; - glycol->CondHighTempIndex = IndexNum; - glycol->CondHighTempValue = glycol->CondTemps(IndexNum); - break; - } - } - if (glycol->ViscDataPresent) { - // check for lowest non-zero value by referencing temp data - for (int IndexNum = 1; IndexNum <= glycol->NumViscTempPoints; ++IndexNum) { - if (glycol->ViscValues(IndexNum) <= 0.0) continue; - glycol->ViscLowTempIndex = IndexNum; - glycol->ViscLowTempValue = glycol->ViscTemps(IndexNum); - break; - } - // check for highest non-zero value by referencing temp data - for (int IndexNum = glycol->NumViscTempPoints; IndexNum >= 1; --IndexNum) { - if (glycol->ViscValues(IndexNum) <= 0.0) continue; - glycol->ViscHighTempIndex = IndexNum; - glycol->ViscHighTempValue = glycol->ViscTemps(IndexNum); - break; - } - } - bool Failure = false; - // Check to see that all are set to non-zero - if (glycol->CpDataPresent) { - Failure = glycol->CpLowTempIndex == 0 || glycol->CpHighTempIndex == 0; - } - if (glycol->RhoDataPresent) { - Failure = glycol->RhoLowTempIndex == 0 || glycol->RhoHighTempIndex == 0; - } - if (glycol->CondDataPresent) { - Failure = glycol->CondLowTempIndex == 0 || glycol->CondHighTempIndex == 0; - } - if (glycol->ViscDataPresent) { - Failure = glycol->ViscLowTempIndex == 0 || glycol->ViscHighTempIndex == 0; - } - if (Failure) { - ShowSevereError( - state, format("InitializeGlycolTempLimits: Required values for Glycol={} are all zeroes for some data types.", glycol->Name)); - ErrorsFound = true; - } + // check for lowest non-zero value by referencing temp data + for (int iTemp = 1; iTemp <= this->NumRhoTempPoints; ++iTemp) { + if (this->RhoValues(iTemp) <= 0.0) continue; + this->RhoLowTempIndex = iTemp; + this->RhoLowTempValue = this->RhoTemps(iTemp); + break; + } + // check for highest non-zero value by referencing temp data + for (int iTemp = this->NumRhoTempPoints; iTemp >= 1; --iTemp) { + if (this->RhoValues(iTemp) <= 0.0) continue; + this->RhoHighTempIndex = iTemp; + this->RhoHighTempValue = this->RhoTemps(iTemp); + break; + } + // check for lowest non-zero value by referencing temp data + for (int iTemp = 1; iTemp <= this->NumCondTempPoints; ++iTemp) { + if (this->CondValues(iTemp) <= 0.0) continue; + this->CondLowTempIndex = iTemp; + this->CondLowTempValue = this->CondTemps(iTemp); + break; + } + // check for highest non-zero value by referencing temp data + for (int iTemp = this->NumCondTempPoints; iTemp >= 1; --iTemp) { + if (this->CondValues(iTemp) <= 0.0) continue; + this->CondHighTempIndex = iTemp; + this->CondHighTempValue = this->CondTemps(iTemp); + break; + } + // check for lowest non-zero value by referencing temp data + for (int iTemp = 1; iTemp <= this->NumViscTempPoints; ++iTemp) { + if (this->ViscValues(iTemp) <= 0.0) continue; + this->ViscLowTempIndex = iTemp; + this->ViscLowTempValue = this->ViscTemps(iTemp); + break; + } + // check for highest non-zero value by referencing temp data + for (int iTemp = this->NumViscTempPoints; iTemp >= 1; --iTemp) { + if (this->ViscValues(iTemp) <= 0.0) continue; + this->ViscHighTempIndex = iTemp; + this->ViscHighTempValue = this->ViscTemps(iTemp); + break; } - } + // Check to see that all are set to non-zero + if ((this->CpDataPresent && (this->CpLowTempIndex == 0 || this->CpHighTempIndex == 0)) || + (this->RhoDataPresent && (this->RhoLowTempIndex == 0 || this->RhoHighTempIndex == 0)) || + (this->CondDataPresent && (this->CondLowTempIndex == 0 || this->CondHighTempIndex == 0)) || + (this->ViscDataPresent && (this->ViscLowTempIndex == 0 || this->ViscHighTempIndex == 0))) { + ShowSevereError(state, format("{}: Required values for Glycol = {} are all zeroes for some data types.", routineName, this->Name)); + ErrorsFound = true; + } + } // GlycolProps::setTempLimits() + //***************************************************************************** - void InitializeRefrigerantLimits(EnergyPlusData &state, bool &ErrorsFound) // set to true if errors found here + void RefrigProps::setTemperatureLimits(EnergyPlusData &state, bool &ErrorsFound, std::string_view routineName) // set to true if errors found here { // SUBROUTINE INFORMATION: @@ -2039,122 +1957,106 @@ namespace FluidProperties { // for the refrigerant properties. // Most properties requested (e.g., Specific Heat) must be > 0 but the tables may // be set up for symmetry and not be limited to just valid values. - auto const &df = state.dataFluidProps; + for (int iTemp = 1; iTemp <= this->NumPsPoints; ++iTemp) { + if (this->PsValues(iTemp) <= 0.0) continue; + this->PsLowPresIndex = iTemp; + this->PsLowPresValue = this->PsValues(iTemp); + this->PsLowTempValue = this->PsTemps(iTemp); + this->PsLowTempIndex = iTemp; + break; + } - for (auto *refrig : df->refrigs) { - for (int IndexNum = 1; IndexNum <= refrig->NumPsPoints; ++IndexNum) { - if (refrig->PsValues(IndexNum) <= 0.0) continue; - refrig->PsLowPresIndex = IndexNum; - refrig->PsLowPresValue = refrig->PsValues(IndexNum); - refrig->PsLowTempValue = refrig->PsTemps(IndexNum); - refrig->PsLowTempIndex = IndexNum; - break; - } - for (int IndexNum = refrig->NumPsPoints; IndexNum >= 1; --IndexNum) { - if (refrig->PsValues(IndexNum) <= 0.0) continue; - refrig->PsHighPresIndex = IndexNum; - refrig->PsHighPresValue = refrig->PsValues(IndexNum); - refrig->PsHighTempValue = refrig->PsTemps(IndexNum); - refrig->PsHighTempIndex = IndexNum; - break; - } - for (int IndexNum = 1; IndexNum <= refrig->NumHPoints; ++IndexNum) { - if (refrig->HfValues(IndexNum) <= 0.0) continue; - refrig->HfLowTempValue = refrig->HfValues(IndexNum); - refrig->HfLowTempIndex = IndexNum; - break; - } - for (int IndexNum = refrig->NumHPoints; IndexNum >= 1; --IndexNum) { - if (refrig->HfValues(IndexNum) <= 0.0) continue; - refrig->HfHighTempValue = refrig->HfValues(IndexNum); - refrig->HfHighTempIndex = IndexNum; - break; - } - for (int IndexNum = 1; IndexNum <= refrig->NumHPoints; ++IndexNum) { - if (refrig->HfgValues(IndexNum) <= 0.0) continue; - refrig->HfgLowTempValue = refrig->HfgValues(IndexNum); - refrig->HfgLowTempIndex = IndexNum; - break; - } - for (int IndexNum = refrig->NumHPoints; IndexNum >= 1; --IndexNum) { - if (refrig->HfgValues(IndexNum) <= 0.0) continue; - refrig->HfgHighTempValue = refrig->HfgValues(IndexNum); - refrig->HfgHighTempIndex = IndexNum; - break; - } - for (int IndexNum = 1; IndexNum <= refrig->NumCpPoints; ++IndexNum) { - if (refrig->CpfValues(IndexNum) <= 0.0) continue; - refrig->CpfLowTempValue = refrig->CpfValues(IndexNum); - refrig->CpfLowTempIndex = IndexNum; - break; - } - for (int IndexNum = refrig->NumCpPoints; IndexNum >= 1; --IndexNum) { - if (refrig->CpfValues(IndexNum) <= 0.0) continue; - refrig->CpfHighTempValue = refrig->CpfValues(IndexNum); - refrig->CpfHighTempIndex = IndexNum; - break; - } - for (int IndexNum = 1; IndexNum <= refrig->NumCpPoints; ++IndexNum) { - if (refrig->CpfgValues(IndexNum) <= 0.0) continue; - refrig->CpfgLowTempValue = refrig->CpfgValues(IndexNum); - refrig->CpfgLowTempIndex = IndexNum; - break; - } - for (int IndexNum = refrig->NumCpPoints; IndexNum >= 1; --IndexNum) { - if (refrig->CpfgValues(IndexNum) <= 0.0) continue; - refrig->CpfgHighTempValue = refrig->CpfgValues(IndexNum); - refrig->CpfgHighTempIndex = IndexNum; - break; - } - for (int IndexNum = 1; IndexNum <= refrig->NumRhoPoints; ++IndexNum) { - if (refrig->RhofValues(IndexNum) <= 0.0) continue; - refrig->RhofLowTempValue = refrig->RhofValues(IndexNum); - refrig->RhofLowTempIndex = IndexNum; - break; - } - for (int IndexNum = refrig->NumRhoPoints; IndexNum >= 1; --IndexNum) { - if (refrig->RhofValues(IndexNum) <= 0.0) continue; - refrig->RhofHighTempValue = refrig->RhofValues(IndexNum); - refrig->RhofHighTempIndex = IndexNum; - break; - } - for (int IndexNum = 1; IndexNum <= refrig->NumRhoPoints; ++IndexNum) { - if (refrig->RhofgValues(IndexNum) <= 0.0) continue; - refrig->RhofgLowTempValue = refrig->RhofgValues(IndexNum); - refrig->RhofgLowTempIndex = IndexNum; - break; - } - for (int IndexNum = refrig->NumRhoPoints; IndexNum >= 1; --IndexNum) { - if (refrig->RhofgValues(IndexNum) <= 0.0) continue; - refrig->RhofgHighTempValue = refrig->RhofgValues(IndexNum); - refrig->RhofgHighTempIndex = IndexNum; - break; - } - bool Failure = false; - // Check to see that all are set to non-zero - if (refrig->NumPsPoints > 0) { - Failure = refrig->PsLowPresIndex == 0 || refrig->PsLowTempIndex == 0 || refrig->PsHighPresIndex == 0 || refrig->PsHighTempIndex == 0; - } - if (refrig->NumHPoints > 0) { - Failure = - refrig->HfLowTempIndex == 0 || refrig->HfgLowTempIndex == 0 || refrig->HfHighTempIndex == 0 || refrig->HfgHighTempIndex == 0; - } - if (refrig->NumCpPoints > 0) { - Failure = - refrig->CpfLowTempIndex == 0 || refrig->CpfgLowTempIndex == 0 || refrig->CpfHighTempIndex == 0 || refrig->CpfgHighTempIndex == 0; - } - if (refrig->NumRhoPoints > 0) { - Failure = refrig->RhofLowTempIndex == 0 || refrig->RhofgLowTempIndex == 0 || refrig->RhofHighTempIndex == 0 || - refrig->RhofgHighTempIndex == 0; - } - if (Failure) { - ShowSevereError( - state, - format("InitializeRefrigerantLimits: Required values for Refrigerant={} are all zeroes for some data types.", refrig->Name)); - ErrorsFound = true; - } + for (int iTemp = this->NumPsPoints; iTemp >= 1; --iTemp) { + if (this->PsValues(iTemp) <= 0.0) continue; + this->PsHighPresIndex = iTemp; + this->PsHighPresValue = this->PsValues(iTemp); + this->PsHighTempValue = this->PsTemps(iTemp); + this->PsHighTempIndex = iTemp; + break; } - } + + for (int iTemp = 1; iTemp <= this->NumHPoints; ++iTemp) { + if (this->HfValues(iTemp) <= 0.0) continue; + this->HfLowTempValue = this->HfValues(iTemp); + this->HfLowTempIndex = iTemp; + break; + } + for (int iTemp = this->NumHPoints; iTemp >= 1; --iTemp) { + if (this->HfValues(iTemp) <= 0.0) continue; + this->HfHighTempValue = this->HfValues(iTemp); + this->HfHighTempIndex = iTemp; + break; + } + for (int iTemp = 1; iTemp <= this->NumHPoints; ++iTemp) { + if (this->HfgValues(iTemp) <= 0.0) continue; + this->HfgLowTempValue = this->HfgValues(iTemp); + this->HfgLowTempIndex = iTemp; + break; + } + for (int iTemp = this->NumHPoints; iTemp >= 1; --iTemp) { + if (this->HfgValues(iTemp) <= 0.0) continue; + this->HfgHighTempValue = this->HfgValues(iTemp); + this->HfgHighTempIndex = iTemp; + break; + } + for (int iTemp = 1; iTemp <= this->NumCpPoints; ++iTemp) { + if (this->CpfValues(iTemp) <= 0.0) continue; + this->CpfLowTempValue = this->CpfValues(iTemp); + this->CpfLowTempIndex = iTemp; + break; + } + for (int iTemp = this->NumCpPoints; iTemp >= 1; --iTemp) { + if (this->CpfValues(iTemp) <= 0.0) continue; + this->CpfHighTempValue = this->CpfValues(iTemp); + this->CpfHighTempIndex = iTemp; + break; + } + for (int iTemp = 1; iTemp <= this->NumCpPoints; ++iTemp) { + if (this->CpfgValues(iTemp) <= 0.0) continue; + this->CpfgLowTempValue = this->CpfgValues(iTemp); + this->CpfgLowTempIndex = iTemp; + break; + } + for (int iTemp = this->NumCpPoints; iTemp >= 1; --iTemp) { + if (this->CpfgValues(iTemp) <= 0.0) continue; + this->CpfgHighTempValue = this->CpfgValues(iTemp); + this->CpfgHighTempIndex = iTemp; + break; + } + for (int iTemp = 1; iTemp <= this->NumRhoPoints; ++iTemp) { + if (this->RhofValues(iTemp) <= 0.0) continue; + this->RhofLowTempValue = this->RhofValues(iTemp); + this->RhofLowTempIndex = iTemp; + break; + } + for (int iTemp = this->NumRhoPoints; iTemp >= 1; --iTemp) { + if (this->RhofValues(iTemp) <= 0.0) continue; + this->RhofHighTempValue = this->RhofValues(iTemp); + this->RhofHighTempIndex = iTemp; + break; + } + for (int iTemp = 1; iTemp <= this->NumRhoPoints; ++iTemp) { + if (this->RhofgValues(iTemp) <= 0.0) continue; + this->RhofgLowTempValue = this->RhofgValues(iTemp); + this->RhofgLowTempIndex = iTemp; + break; + } + for (int iTemp = this->NumRhoPoints; iTemp >= 1; --iTemp) { + if (this->RhofgValues(iTemp) <= 0.0) continue; + this->RhofgHighTempValue = this->RhofgValues(iTemp); + this->RhofgHighTempIndex = iTemp; + break; + } + + // Check to see that all are set to non-zero + if ((this->NumPsPoints > 0 && (this->PsLowPresIndex == 0 || this->PsLowTempIndex == 0 || this->PsHighPresIndex == 0 || this->PsHighTempIndex == 0)) || + (this->NumHPoints > 0 && (this->HfLowTempIndex == 0 || this->HfgLowTempIndex == 0 || this->HfHighTempIndex == 0 || this->HfgHighTempIndex == 0)) || + (this->NumCpPoints > 0 && (this->CpfLowTempIndex == 0 || this->CpfgLowTempIndex == 0 || this->CpfHighTempIndex == 0 || this->CpfgHighTempIndex == 0)) || + (this->NumRhoPoints > 0 && (this->RhofLowTempIndex == 0 || this->RhofgLowTempIndex == 0 || this->RhofHighTempIndex == 0 || this->RhofgHighTempIndex == 0))) { + ShowSevereError(state, format("{}: Required values for Refrigerant = {} are all zeroes for some data types.", routineName, this->Name)); + ErrorsFound = true; + } + } // RefrigProps::setTemperatureLimits() //***************************************************************************** diff --git a/src/EnergyPlus/FluidProperties.hh b/src/EnergyPlus/FluidProperties.hh index 2fd4cf1aeb8..ef80a3b4317 100644 --- a/src/EnergyPlus/FluidProperties.hh +++ b/src/EnergyPlus/FluidProperties.hh @@ -229,6 +229,10 @@ namespace FluidProperties { Real64 Temperature, // actual temperature given as input Real64 Pressure, // actual pressure given as input std::string_view CalledFrom); // routine this function was called from (error messages) + + void setTemperatureLimits(EnergyPlusData &state, + bool &errorsFound, + std::string_view calledFrom); }; enum class GlycolError @@ -372,6 +376,10 @@ namespace FluidProperties { Real64 getViscosity(EnergyPlusData &state, Real64 Temperature, // actual temperature given as input std::string_view CalledFrom); // routine this function was called from (error messages) + + void setTemperatureLimits(EnergyPlusData &state, + bool &errorsFound, + std::string_view calledFrom); }; struct cached_tsh @@ -388,6 +396,8 @@ namespace FluidProperties { void GetFluidPropertiesData(EnergyPlusData &state); + void InitConstantFluidPropertiesData(EnergyPlusData &state); + template void InterpDefValuesForGlycolConc( EnergyPlusData &state, @@ -406,10 +416,6 @@ namespace FluidProperties { Array1D &InterpData // interpolated output data at proper concentration ); - void InitializeGlycolTempLimits(EnergyPlusData &state, bool &ErrorsFound); // set to true if errors found here - - void InitializeRefrigerantLimits(EnergyPlusData &state, bool &ErrorsFound); // set to true if errors found here - void ReportAndTestGlycols(EnergyPlusData &state); void ReportAndTestRefrigerants(EnergyPlusData &state); @@ -629,6 +635,11 @@ struct FluidData : BaseGlobalStruct std::array cached_t_sh; #endif + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + FluidProperties::InitConstantFluidPropertiesData(state); + } + void init_state(EnergyPlusData &state) override { FluidProperties::GetFluidPropertiesData(state); @@ -637,8 +648,11 @@ struct FluidData : BaseGlobalStruct void clear_state() override { - for (int i = 1; i <= refrigs.isize(); ++i) + for (int i = 1; i <= refrigs.isize(); ++i) { + refrigs(i)->HshValues.deallocate(); + refrigs(i)->RhoshValues.deallocate(); delete refrigs(i); + } for (int i = 1; i <= glycolsRaw.isize(); ++i) delete glycolsRaw(i); for (int i = 1; i <= glycols.isize(); ++i) diff --git a/src/EnergyPlus/FuelCellElectricGenerator.cc b/src/EnergyPlus/FuelCellElectricGenerator.cc index c2a50442c7f..6d040675b69 100644 --- a/src/EnergyPlus/FuelCellElectricGenerator.cc +++ b/src/EnergyPlus/FuelCellElectricGenerator.cc @@ -168,6 +168,7 @@ namespace FuelCellElectricGenerator { // METHODOLOGY EMPLOYED: // EnergyPlus input processor + static constexpr std::string_view routineName = "getFuelCellInput"; int NumAlphas; // Number of elements in the alpha array int NumNums; // Number of elements in the numeric array @@ -272,12 +273,12 @@ namespace FuelCellElectricGenerator { state.dataFuelCellElectGen->FuelCell(thisFuelCell).FCPM.UpTranLimit = NumArray(8); state.dataFuelCellElectGen->FuelCell(thisFuelCell).FCPM.DownTranLimit = NumArray(9); state.dataFuelCellElectGen->FuelCell(thisFuelCell).FCPM.StartUpTime = - NumArray(10) / Constant::SecInHour; // convert to hours from seconds + NumArray(10) / Constant::rSecsInHour; // convert to hours from seconds state.dataFuelCellElectGen->FuelCell(thisFuelCell).FCPM.StartUpFuel = NumArray(11); state.dataFuelCellElectGen->FuelCell(thisFuelCell).FCPM.StartUpElectConsum = NumArray(12); state.dataFuelCellElectGen->FuelCell(thisFuelCell).FCPM.StartUpElectProd = NumArray(13); state.dataFuelCellElectGen->FuelCell(thisFuelCell).FCPM.ShutDownTime = - NumArray(14) / Constant::SecInHour; // convert to hours from seconds + NumArray(14) / Constant::rSecsInHour; // convert to hours from seconds state.dataFuelCellElectGen->FuelCell(thisFuelCell).FCPM.ShutDownFuel = NumArray(15); state.dataFuelCellElectGen->FuelCell(thisFuelCell).FCPM.ShutDownElectConsum = NumArray(16); state.dataFuelCellElectGen->FuelCell(thisFuelCell).FCPM.ANC0 = NumArray(17); @@ -608,6 +609,7 @@ namespace FuelCellElectricGenerator { state.dataIPShortCut->cAlphaFieldNames, state.dataIPShortCut->cNumericFieldNames); + ErrorObjectHeader eoh{routineName, state.dataIPShortCut->cCurrentModuleObject, AlphArray(1)}; int thisFuelCell = Util::FindItemInList(AlphArray(1), state.dataFuelCellElectGen->FuelCell, &FCDataStruct::NameFCWaterSup); if (thisFuelCell > 0) { @@ -674,13 +676,11 @@ namespace FuelCellElectricGenerator { ErrorsFound = true; } - state.dataFuelCellElectGen->FuelCell(thisFuelCell).WaterSup.SchedNum = ScheduleManager::GetScheduleIndex(state, AlphArray(6)); - if ((state.dataFuelCellElectGen->FuelCell(thisFuelCell).WaterSup.SchedNum == 0) && + state.dataFuelCellElectGen->FuelCell(thisFuelCell).WaterSup.sched = Sched::GetSchedule(state, AlphArray(6)); + if ((state.dataFuelCellElectGen->FuelCell(thisFuelCell).WaterSup.sched == nullptr) && (state.dataFuelCellElectGen->FuelCell(thisFuelCell).WaterSup.WaterTempMode == DataGenerators::WaterTemperatureMode::WaterInReformSchedule)) { - ShowSevereError(state, format("Invalid, {} = {}", state.dataIPShortCut->cAlphaFieldNames(6), AlphArray(6))); - ShowContinueError(state, format("Entered in {}={}", state.dataIPShortCut->cCurrentModuleObject, AlphArray(1))); - ShowContinueError(state, "Schedule was not found"); + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(6), AlphArray(6)); ErrorsFound = true; } @@ -1606,7 +1606,7 @@ namespace FuelCellElectricGenerator { double(state.dataGlobal->DayOfSim) + (int(state.dataGlobal->CurrentTime) + (state.dataHVACGlobal->SysTimeElapsed + (state.dataGlobal->CurrentTime - int(state.dataGlobal->CurrentTime)))) / - Constant::HoursInDay; + Constant::rHoursInDay; this->FCPM.HasBeenOn = false; if (this->FCPM.ShutDownTime > 0.0) this->FCPM.DuringShutDown = true; @@ -1627,7 +1627,7 @@ namespace FuelCellElectricGenerator { double(state.dataGlobal->DayOfSim) + (int(state.dataGlobal->CurrentTime) + (state.dataHVACGlobal->SysTimeElapsed + (state.dataGlobal->CurrentTime - int(state.dataGlobal->CurrentTime)))) / - Constant::HoursInDay; + Constant::rHoursInDay; this->FCPM.HasBeenOn = true; ++this->FCPM.NumCycles; // increment cycling counter @@ -1761,7 +1761,7 @@ namespace FuelCellElectricGenerator { } else if (state.dataGenerator->FuelSupply(this->FuelSupNum).FuelTempMode == DataGenerators::FuelTemperatureMode::FuelInTempSchedule) { state.dataGenerator->FuelSupply(this->FuelSupNum).TfuelIntoCompress = - ScheduleManager::GetCurrentScheduleValue(state, state.dataGenerator->FuelSupply(this->FuelSupNum).SchedNum); + state.dataGenerator->FuelSupply(this->FuelSupNum).sched->getCurrentVal(); } // evaluate heat capacity at average temperature using shomate @@ -1823,7 +1823,7 @@ namespace FuelCellElectricGenerator { this->WaterSup.TwaterIntoCompress = state.dataLoopNodes->Node(this->WaterSup.NodeNum).Temp; } break; case DataGenerators::WaterTemperatureMode::WaterInReformSchedule: { - this->WaterSup.TwaterIntoCompress = ScheduleManager::GetCurrentScheduleValue(state, this->WaterSup.SchedNum); + this->WaterSup.TwaterIntoCompress = this->WaterSup.sched->getCurrentVal(); } break; default: break; @@ -2910,13 +2910,13 @@ namespace FuelCellElectricGenerator { Real64 CurrentFractionalDay = double(state.dataGlobal->DayOfSim) + (int(state.dataGlobal->CurrentTime) + (state.dataHVACGlobal->SysTimeElapsed + (state.dataGlobal->CurrentTime - int(state.dataGlobal->CurrentTime)))) / - Constant::HoursInDay; + Constant::rHoursInDay; // Check if in start up and if it still should be if (this->FCPM.DuringStartUp) { // calculate time for end of start up period - Real64 EndingFractionalDay = this->FCPM.FractionalDayofLastStartUp + this->FCPM.StartUpTime / Constant::HoursInDay; + Real64 EndingFractionalDay = this->FCPM.FractionalDayofLastStartUp + this->FCPM.StartUpTime / Constant::rHoursInDay; if (CurrentFractionalDay > EndingFractionalDay) { // start up period is now over @@ -2928,7 +2928,7 @@ namespace FuelCellElectricGenerator { if (this->FCPM.DuringShutDown) { // calculate time for end of shut down period - Real64 EndingFractionalDay = this->FCPM.FractionalDayofLastShutDown + this->FCPM.ShutDownTime / Constant::HoursInDay; + Real64 EndingFractionalDay = this->FCPM.FractionalDayofLastShutDown + this->FCPM.ShutDownTime / Constant::rHoursInDay; if (CurrentFractionalDay > EndingFractionalDay) { // start up period is now over @@ -3560,7 +3560,7 @@ namespace FuelCellElectricGenerator { this->Report.FuelCompressPower = state.dataGenerator->FuelSupply(this->FuelSupNum).PfuelCompEl; // electrical power used by fuel supply compressor [W] this->Report.FuelCompressEnergy = - state.dataGenerator->FuelSupply(this->FuelSupNum).PfuelCompEl * state.dataHVACGlobal->TimeStepSys * Constant::SecInHour; // elect energy + state.dataGenerator->FuelSupply(this->FuelSupNum).PfuelCompEl * state.dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; // elect energy this->Report.FuelCompressSkinLoss = state.dataGenerator->FuelSupply(this->FuelSupNum).QskinLoss; // heat rate of losses.by fuel supply compressor [W] this->Report.FuelEnergyLHV = this->FCPM.NdotFuel * state.dataGenerator->FuelSupply(this->FuelSupNum).LHV * 1000000.0 * @@ -3569,7 +3569,7 @@ namespace FuelCellElectricGenerator { this->FCPM.NdotFuel * state.dataGenerator->FuelSupply(this->FuelSupNum).LHV * 1000000.0; // reporting: Fuel Energy used (W) this->Report.FuelEnergyHHV = this->FCPM.NdotFuel * state.dataGenerator->FuelSupply(this->FuelSupNum).HHV * state.dataGenerator->FuelSupply(this->FuelSupNum).KmolPerSecToKgPerSec * state.dataHVACGlobal->TimeStepSys * - Constant::SecInHour; + Constant::rSecsInHour; this->Report.FuelEnergyUseRateHHV = this->FCPM.NdotFuel * state.dataGenerator->FuelSupply(this->FuelSupNum).HHV * state.dataGenerator->FuelSupply(this->FuelSupNum).KmolPerSecToKgPerSec; diff --git a/src/EnergyPlus/FuelCellElectricGenerator.hh b/src/EnergyPlus/FuelCellElectricGenerator.hh index 6a3e148b9a9..623a1652741 100644 --- a/src/EnergyPlus/FuelCellElectricGenerator.hh +++ b/src/EnergyPlus/FuelCellElectricGenerator.hh @@ -203,7 +203,7 @@ namespace FuelCellElectricGenerator { DataGenerators::WaterTemperatureMode WaterTempMode; // temperature of water inlet determination std::string NodeName; // node name for temperature at input int NodeNum; // node number for temperature at input - int SchedNum; // water temperature at input + Sched::Schedule *sched = nullptr; // water temperature at input int WaterSupRateCurveID; // "pointer" to water flow rate curve as a function of fuel rate int PmpPowerCurveID; // "pointer to Pump power curve as a function of water flow Rate Real64 PmpPowerLossFactor; // Pump heat loss factor @@ -216,7 +216,7 @@ namespace FuelCellElectricGenerator { // Default Constructor FCWaterSupplyDataStruct() - : WaterTempMode(DataGenerators::WaterTemperatureMode::Invalid), NodeNum(0), SchedNum(0), WaterSupRateCurveID(0), PmpPowerCurveID(0), + : WaterTempMode(DataGenerators::WaterTemperatureMode::Invalid), NodeNum(0), WaterSupRateCurveID(0), PmpPowerCurveID(0), PmpPowerLossFactor(0.0), IsModeled(true), TwaterIntoCompress(0.0), TwaterIntoFCPM(0.0), PwaterCompEl(0.0), QskinLoss(0.0) { } @@ -652,6 +652,10 @@ struct FuelCellElectricGeneratorData : BaseGlobalStruct bool MyEnvrnFlag = true; Array1D FuelCell; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/Furnaces.cc b/src/EnergyPlus/Furnaces.cc index 1d590e325e1..838216b36b4 100644 --- a/src/EnergyPlus/Furnaces.cc +++ b/src/EnergyPlus/Furnaces.cc @@ -251,13 +251,13 @@ namespace Furnaces { Real64 ZoneLoadToCoolSPSequenced = zoneSysEnergyDemand.SequencedOutputRequiredToCoolingSP(thisFurnace.ZoneSequenceCoolingNum); Real64 ZoneLoadToHeatSPSequenced = zoneSysEnergyDemand.SequencedOutputRequiredToHeatingSP(thisFurnace.ZoneSequenceHeatingNum); auto const &tempControlType = state.dataHeatBalFanSys->TempControlType(thisFurnace.ControlZoneNum); - if (ZoneLoadToHeatSPSequenced > 0.0 && ZoneLoadToCoolSPSequenced > 0.0 && tempControlType != HVAC::ThermostatType::SingleCooling) { + if (ZoneLoadToHeatSPSequenced > 0.0 && ZoneLoadToCoolSPSequenced > 0.0 && tempControlType != HVAC::SetptType::SingleCool) { ZoneLoad = ZoneLoadToHeatSPSequenced; - } else if (ZoneLoadToHeatSPSequenced > 0.0 && ZoneLoadToCoolSPSequenced > 0.0 && tempControlType == HVAC::ThermostatType::SingleCooling) { + } else if (ZoneLoadToHeatSPSequenced > 0.0 && ZoneLoadToCoolSPSequenced > 0.0 && tempControlType == HVAC::SetptType::SingleCool) { ZoneLoad = 0.0; - } else if (ZoneLoadToHeatSPSequenced < 0.0 && ZoneLoadToCoolSPSequenced < 0.0 && tempControlType != HVAC::ThermostatType::SingleHeating) { + } else if (ZoneLoadToHeatSPSequenced < 0.0 && ZoneLoadToCoolSPSequenced < 0.0 && tempControlType != HVAC::SetptType::SingleHeat) { ZoneLoad = ZoneLoadToCoolSPSequenced; - } else if (ZoneLoadToHeatSPSequenced < 0.0 && ZoneLoadToCoolSPSequenced < 0.0 && tempControlType == HVAC::ThermostatType::SingleHeating) { + } else if (ZoneLoadToHeatSPSequenced < 0.0 && ZoneLoadToCoolSPSequenced < 0.0 && tempControlType == HVAC::SetptType::SingleHeat) { ZoneLoad = 0.0; } else if (ZoneLoadToHeatSPSequenced <= 0.0 && ZoneLoadToCoolSPSequenced >= 0.0) { ZoneLoad = 0.0; @@ -848,14 +848,10 @@ namespace Furnaces { ErrorObjectHeader eoh{routineName, cAlphaFields(1), thisFurnace.Name}; if (lAlphaBlanks(2)) { - thisFurnace.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - thisFurnace.SchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(2)); - if (thisFurnace.SchedPtr == 0) { - ShowSevereError(state, format("{} = {}", CurrentModuleObject, Alphas(1))); - ShowContinueError(state, format("Illegal {} = {}", cAlphaFields(2), Alphas(2))); - ErrorsFound = true; - } + thisFurnace.sched = Sched::GetScheduleAlwaysOn(state); + } else if ((thisFurnace.sched = Sched::GetSchedule(state, Alphas(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(2), Alphas(2)); + ErrorsFound = true; } thisFurnace.FurnaceInletNodeNum = NodeInputManager::GetOnlySingleNode(state, @@ -879,13 +875,11 @@ namespace Furnaces { BranchNodeConnections::TestCompSet(state, CurrentModuleObject, Alphas(1), Alphas(3), Alphas(4), "Air Nodes"); - thisFurnace.FanSchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(5)); - if (!lAlphaBlanks(5) && thisFurnace.FanSchedPtr == 0) { - ShowSevereError(state, format("{} = {}", CurrentModuleObject, Alphas(1))); - ShowContinueError(state, format("Illegal {} = {}", cAlphaFields(5), Alphas(5))); - ErrorsFound = true; - } else if (lAlphaBlanks(5)) { + if (lAlphaBlanks(5)) { thisFurnace.fanOp = HVAC::FanOp::Cycling; + } else if ((thisFurnace.fanOpModeSched = Sched::GetSchedule(state, Alphas(5))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(5), Alphas(5)); + ErrorsFound = true; } // Get the Controlling Zone or Location of the Furnace Thermostat @@ -970,17 +964,13 @@ namespace Furnaces { thisFurnace.ActualFanVolFlowRate = fan->maxAirFlowRate; FanInletNode = fan->inletNodeNum; FanOutletNode = fan->outletNodeNum; - thisFurnace.FanAvailSchedPtr = fan->availSchedNum; + thisFurnace.fanAvailSched = fan->availSched; // Check fan's schedule for cycling fan operation if constant volume fan is used - if (thisFurnace.FanSchedPtr > 0 && thisFurnace.fanType == HVAC::FanType::Constant) { - if (!ScheduleManager::CheckScheduleValueMinMax( - state, thisFurnace.FanSchedPtr, ScheduleManager::Clusivity::Exclusive, 0.0, ScheduleManager::Clusivity::Inclusive, 1.0)) { - ShowSevereError(state, format("{} = {}", CurrentModuleObject, Alphas(1))); - ShowContinueError(state, format("For {} = {}", cAlphaFields(7), Alphas(7))); - ShowContinueError(state, "Fan operating mode must be continuous (fan operating mode schedule values > 0)."); - ShowContinueError(state, format("Error found in {} = {}", cAlphaFields(5), Alphas(5))); - ShowContinueError(state, "...schedule values must be (>0., <=1.)"); + if (thisFurnace.fanOpModeSched != nullptr && thisFurnace.fanType == HVAC::FanType::Constant) { + if (!thisFurnace.fanOpModeSched->checkMinMaxVals(state, Clusive::Ex, 0.0, Clusive::In, 1.0)) { + Sched::ShowSevereBadMinMax(state, eoh, cAlphaFields(5), Alphas(5), Clusive::Ex, 0.0, Clusive::In, 1.0, + format("For {} = {}, Fan operating mode must be continuous (schedule values > 0)", cAlphaFields(7), Alphas(7))); ErrorsFound = true; } } else if (lAlphaBlanks(5) && thisFurnace.fanType != HVAC::FanType::OnOff) { @@ -1382,14 +1372,10 @@ namespace Furnaces { ErrorObjectHeader eoh{routineName, CurrentModuleObject, thisFurnace.Name}; if (lAlphaBlanks(2)) { - thisFurnace.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - thisFurnace.SchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(2)); - if (thisFurnace.SchedPtr == 0) { - ShowSevereError(state, format("{} = {}", CurrentModuleObject, Alphas(1))); - ShowContinueError(state, format("Illegal {} = {}", cAlphaFields(2), Alphas(2))); - ErrorsFound = true; - } + thisFurnace.sched = Sched::GetScheduleAlwaysOn(state); + } else if ((thisFurnace.sched = Sched::GetSchedule(state, Alphas(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(2), Alphas(2)); + ErrorsFound = true; } thisFurnace.FurnaceInletNodeNum = NodeInputManager::GetOnlySingleNode(state, @@ -1413,13 +1399,11 @@ namespace Furnaces { BranchNodeConnections::TestCompSet(state, CurrentModuleObject, Alphas(1), Alphas(3), Alphas(4), "Air Nodes"); - thisFurnace.FanSchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(5)); - if (!lAlphaBlanks(5) && thisFurnace.FanSchedPtr == 0) { - ShowSevereError(state, format("{} = {}", CurrentModuleObject, Alphas(1))); - ShowContinueError(state, format("Illegal {} = {}", cAlphaFields(5), Alphas(5))); - ErrorsFound = true; - } else if (lAlphaBlanks(5)) { + if (lAlphaBlanks(5)) { thisFurnace.fanOp = HVAC::FanOp::Cycling; + } else if ((thisFurnace.fanOpModeSched = Sched::GetSchedule(state, Alphas(5))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(5), Alphas(5)); + ErrorsFound = true; } // Get the Controlling Zone or Location of the Furnace Thermostat @@ -1503,17 +1487,13 @@ namespace Furnaces { thisFurnace.ActualFanVolFlowRate = fan->maxAirFlowRate; FanInletNode = fan->inletNodeNum; FanOutletNode = fan->outletNodeNum; - thisFurnace.FanAvailSchedPtr = fan->availSchedNum; + thisFurnace.fanAvailSched = fan->availSched; // Check fan's schedule for cycling fan operation if constant volume fan is used - if (thisFurnace.FanSchedPtr > 0 && thisFurnace.fanType == HVAC::FanType::Constant) { - if (!ScheduleManager::CheckScheduleValueMinMax( - state, thisFurnace.FanSchedPtr, ScheduleManager::Clusivity::Exclusive, 0.0, ScheduleManager::Clusivity::Inclusive, 1.0)) { - ShowSevereError(state, format("{} = {}", CurrentModuleObject, Alphas(1))); - ShowContinueError(state, format("For {} = {}", cAlphaFields(7), Alphas(7))); - ShowContinueError(state, "Fan operating mode must be continuous (fan operating mode schedule values > 0)."); - ShowContinueError(state, format("Error found in {} = {}", cAlphaFields(5), Alphas(5))); - ShowContinueError(state, "...schedule values must be (>0., <=1.)"); + if (thisFurnace.fanOpModeSched != nullptr && thisFurnace.fanType == HVAC::FanType::Constant) { + if (!thisFurnace.fanOpModeSched->checkMinMaxVals(state, Clusive::Ex, 0.0, Clusive::In, 1.0)) { + Sched::ShowSevereBadMinMax(state, eoh, cAlphaFields(5), Alphas(5), Clusive::In, 0.0, Clusive::In, 1.0, + format("For {} = {}, fan operating mode must be continuous (schedule values > 0)", cAlphaFields(7), Alphas(7))); ErrorsFound = true; } } else if (lAlphaBlanks(5) && thisFurnace.fanType != HVAC::FanType::OnOff) { @@ -2583,8 +2563,9 @@ namespace Furnaces { } } - if (thisFurnace.FanSchedPtr > 0) { - if (!ScheduleManager::CheckScheduleValueMinMax(state, thisFurnace.FanSchedPtr, ">=", 0.0, "<=", 0.0)) { + if (thisFurnace.fanOpModeSched != nullptr) { + // Is this correct? 0.0 for max also? + if (!thisFurnace.fanOpModeSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 0.0)) { // set air flow control mode: // UseCompressorOnFlow = operate at last cooling or heating air flow requested when compressor is off // UseCompressorOffFlow = operate at value specified by user @@ -2669,14 +2650,10 @@ namespace Furnaces { ErrorObjectHeader eoh{routineName, CurrentModuleObject, thisFurnace.Name}; if (lAlphaBlanks(2)) { - thisFurnace.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - thisFurnace.SchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(2)); - if (thisFurnace.SchedPtr == 0) { - ShowSevereError(state, format("{} = {}", CurrentModuleObject, Alphas(1))); - ShowContinueError(state, format("Illegal {} = {}", cAlphaFields(2), Alphas(2))); - ErrorsFound = true; - } + thisFurnace.sched = Sched::GetScheduleAlwaysOn(state); + } else if ((thisFurnace.sched = Sched::GetSchedule(state, Alphas(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(2), Alphas(2)); + ErrorsFound = true; } thisFurnace.FurnaceInletNodeNum = @@ -2779,7 +2756,7 @@ namespace Furnaces { auto *fan = state.dataFans->fans(thisFurnace.FanIndex); FanInletNode = fan->inletNodeNum; FanOutletNode = fan->outletNodeNum; - thisFurnace.FanAvailSchedPtr = fan->availSchedNum; + thisFurnace.fanAvailSched = fan->availSched; thisFurnace.ActualFanVolFlowRate = fan->maxAirFlowRate; } } @@ -3171,12 +3148,7 @@ namespace Furnaces { thisFurnace.fanPlace = static_cast(getEnumValue(HVAC::fanPlaceNamesUC, Alphas(14))); assert(thisFurnace.fanPlace != HVAC::FanPlace::Invalid); - thisFurnace.FanSchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(15)); - if (!lAlphaBlanks(15) && thisFurnace.FanSchedPtr == 0) { - ShowSevereError(state, format("{} = {}", CurrentModuleObject, Alphas(1))); - ShowContinueError(state, format("Illegal {} = {}", cAlphaFields(15), Alphas(15))); - ErrorsFound = true; - } else if (lAlphaBlanks(15)) { + if (lAlphaBlanks(15)) { thisFurnace.fanOp = HVAC::FanOp::Cycling; if (thisFurnace.fanType != HVAC::FanType::OnOff) { ShowSevereError(state, format("{} = {}", CurrentModuleObject, thisFurnace.Name)); @@ -3184,19 +3156,17 @@ namespace Furnaces { ShowContinueError(state, format("Fan type must be Fan:OnOff when {} = Blank.", cAlphaFields(15))); ErrorsFound = true; } + } else if ((thisFurnace.fanOpModeSched = Sched::GetSchedule(state, Alphas(15))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(15), Alphas(15)); + ErrorsFound = true; } - - if (thisFurnace.fanType == HVAC::FanType::Constant) { - if (thisFurnace.FanSchedPtr > 0) { - if (!ScheduleManager::CheckScheduleValueMinMax(state, thisFurnace.FanSchedPtr, ">", 0.0, "<=", 1.0)) { - ShowSevereError(state, format("{} = {}", CurrentModuleObject, Alphas(1))); - ShowContinueError(state, format("For {} = {}", cAlphaFields(7), Alphas(7))); - ShowContinueError(state, "Fan operating mode must be continuous (fan operating mode schedule values > 0)."); - ShowContinueError(state, format("Error found in {} = {}", cAlphaFields(15), Alphas(15))); - ShowContinueError(state, "...schedule values must be (>0., <=1.)"); - ErrorsFound = true; - } - } + + if (thisFurnace.fanType == HVAC::FanType::Constant && + thisFurnace.fanOpModeSched != nullptr && + !thisFurnace.fanOpModeSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) { + Sched::ShowSevereBadMinMax(state, eoh, cAlphaFields(15), Alphas(15), Clusive::In, 0.0, Clusive::In, 1.0, + format("For {} = {}, fan operating mode must be continuous (schedule values > 0)", cAlphaFields(7), Alphas(7))); + ErrorsFound = true; } // Dehumidification Control Type @@ -3393,9 +3363,8 @@ namespace Furnaces { ErrorsFound = true; } - if (thisFurnace.FanSchedPtr > 0) { - if (!ScheduleManager::CheckScheduleValueMinMax( - state, thisFurnace.FanSchedPtr, ">=", 0.0, "<=", 0.0)) { // Autodesk:Note Range is 0 to 0? + if (thisFurnace.fanOpModeSched != nullptr) { + if (!thisFurnace.fanOpModeSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 0.0)) { // Autodesk:Note Range is 0 to 0? // set air flow control mode: // UseCompressorOnFlow = operate at last cooling or heating air flow requested when compressor is off // UseCompressorOffFlow = operate at value specified by user @@ -3588,14 +3557,10 @@ namespace Furnaces { ErrorObjectHeader eoh{routineName, CurrentModuleObject, thisFurnace.Name}; if (lAlphaBlanks(2)) { - thisFurnace.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - thisFurnace.SchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(2)); - if (thisFurnace.SchedPtr == 0) { - ShowSevereError(state, format("{} = {}", CurrentModuleObject, Alphas(1))); - ShowContinueError(state, format("Illegal {} = {}", cAlphaFields(2), Alphas(2))); - ErrorsFound = true; - } + thisFurnace.sched = Sched::GetScheduleAlwaysOn(state); + } else if ((thisFurnace.sched = Sched::GetSchedule(state, Alphas(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(2), Alphas(2)); + ErrorsFound = true; } thisFurnace.FurnaceInletNodeNum = @@ -3702,7 +3667,7 @@ namespace Furnaces { auto *fan = state.dataFans->fans(thisFurnace.FanIndex); FanInletNode = fan->inletNodeNum; FanOutletNode = fan->outletNodeNum; - thisFurnace.FanAvailSchedPtr = fan->availSchedNum; + thisFurnace.fanAvailSched = fan->availSched; } // Get heating coil type and name data @@ -4010,12 +3975,7 @@ namespace Furnaces { thisFurnace.fanPlace = static_cast(getEnumValue(HVAC::fanPlaceNamesUC, Alphas(15))); assert(thisFurnace.fanPlace != HVAC::FanPlace::Invalid); - thisFurnace.FanSchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(16)); - if (!lAlphaBlanks(16) && thisFurnace.FanSchedPtr == 0) { - ShowSevereError(state, format("{} = {}", CurrentModuleObject, Alphas(1))); - ShowContinueError(state, format("Illegal {} = {}", cAlphaFields(16), Alphas(16))); - ErrorsFound = true; - } else if (lAlphaBlanks(16)) { + if (lAlphaBlanks(16)) { thisFurnace.fanOp = HVAC::FanOp::Cycling; if (thisFurnace.fanType != HVAC::FanType::OnOff) { ShowSevereError(state, format("{} = {}", CurrentModuleObject, thisFurnace.Name)); @@ -4023,6 +3983,9 @@ namespace Furnaces { ShowContinueError(state, format("Fan type must be Fan:OnOff when {} = Blank.", cAlphaFields(16))); ErrorsFound = true; } + } else if ((thisFurnace.fanOpModeSched = Sched::GetSchedule(state, Alphas(16))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(16), Alphas(16)); + ErrorsFound = true; } // add the Dehumidification Type @@ -4719,7 +4682,7 @@ namespace Furnaces { state.dataFurnaces->MySizeFlag(FurnaceNum) = false; // Pass the fan cycling schedule index up to the air loop. Set the air loop unitary system flag. - state.dataAirLoop->AirLoopControlInfo(AirLoopNum).CycFanSchedPtr = thisFurnace.FanSchedPtr; + state.dataAirLoop->AirLoopControlInfo(AirLoopNum).cycFanSched = thisFurnace.fanOpModeSched; state.dataAirLoop->AirLoopControlInfo(AirLoopNum).UnitarySys = true; // RR this is wrong, Op mode needs to be updated each time atep state.dataAirLoop->AirLoopControlInfo(AirLoopNum).fanOp = thisFurnace.fanOp; @@ -5136,12 +5099,8 @@ namespace Furnaces { } } - if (thisFurnace.FanSchedPtr > 0) { - if (ScheduleManager::GetCurrentScheduleValue(state, thisFurnace.FanSchedPtr) == 0.0) { - thisFurnace.fanOp = HVAC::FanOp::Cycling; - } else { - thisFurnace.fanOp = HVAC::FanOp::Continuous; - } + if (thisFurnace.fanOpModeSched != nullptr) { + thisFurnace.fanOp = (thisFurnace.fanOpModeSched->getCurrentVal() == 0.0) ? HVAC::FanOp::Cycling : HVAC::FanOp::Continuous; if (AirLoopNum > 0) { state.dataAirLoop->AirLoopControlInfo(AirLoopNum).fanOp = thisFurnace.fanOp; } @@ -5187,7 +5146,7 @@ namespace Furnaces { // Check for heat only furnace if (thisFurnace.type != HVAC::UnitarySysType::Furnace_HeatOnly && thisFurnace.type != HVAC::UnitarySysType::Unitary_HeatOnly) { - if (ScheduleManager::GetCurrentScheduleValue(state, thisFurnace.SchedPtr) > 0.0) { + if (thisFurnace.sched->getCurrentVal() > 0.0) { if ((state.dataFurnaces->HeatingLoad || state.dataFurnaces->CoolingLoad) || (thisFurnace.Humidistat && MoistureLoad < 0.0)) { PartLoadRatio = 1.0; } else { @@ -5406,8 +5365,8 @@ namespace Furnaces { QToCoolSetPt = 0.0; QToHeatSetPt = 0.0; - if (fanOp == HVAC::FanOp::Continuous && ScheduleManager::GetCurrentScheduleValue(state, thisFurnace.SchedPtr) > 0.0 && - ((ScheduleManager::GetCurrentScheduleValue(state, thisFurnace.FanAvailSchedPtr) > 0.0 || state.dataHVACGlobal->TurnFansOn) && + if (fanOp == HVAC::FanOp::Continuous && thisFurnace.sched->getCurrentVal() > 0.0 && + ((thisFurnace.fanAvailSched->getCurrentVal() > 0.0 || state.dataHVACGlobal->TurnFansOn) && !state.dataHVACGlobal->TurnFansOff)) { if (thisFurnace.NumOfSpeedCooling > 0) { @@ -5468,8 +5427,8 @@ namespace Furnaces { QZnReq = QToHeatSetPt; state.dataFurnaces->CoolingLoad = false; // Don't set mode TRUE unless mode is allowed. Also check for floating zone. - if (state.dataHeatBalFanSys->TempControlType(thisFurnace.ControlZoneNum) == HVAC::ThermostatType::SingleCooling || - state.dataHeatBalFanSys->TempControlType(thisFurnace.ControlZoneNum) == HVAC::ThermostatType::Uncontrolled) { + if (state.dataHeatBalFanSys->TempControlType(thisFurnace.ControlZoneNum) == HVAC::SetptType::SingleCool || + state.dataHeatBalFanSys->TempControlType(thisFurnace.ControlZoneNum) == HVAC::SetptType::Uncontrolled) { state.dataFurnaces->HeatingLoad = false; } else { state.dataFurnaces->HeatingLoad = true; @@ -5539,8 +5498,8 @@ namespace Furnaces { if (SensibleOutput > QToCoolSetPt) { QZnReq = QToCoolSetPt; // Don't set mode TRUE unless mode is allowed. Also check for floating zone. - if (state.dataHeatBalFanSys->TempControlType(thisFurnace.ControlZoneNum) == HVAC::ThermostatType::SingleHeating || - state.dataHeatBalFanSys->TempControlType(thisFurnace.ControlZoneNum) == HVAC::ThermostatType::Uncontrolled) { + if (state.dataHeatBalFanSys->TempControlType(thisFurnace.ControlZoneNum) == HVAC::SetptType::SingleHeat || + state.dataHeatBalFanSys->TempControlType(thisFurnace.ControlZoneNum) == HVAC::SetptType::Uncontrolled) { state.dataFurnaces->CoolingLoad = false; } else { state.dataFurnaces->CoolingLoad = true; @@ -6246,7 +6205,7 @@ namespace Furnaces { state.dataHVACGlobal->OnOffFanPartLoadFraction = 1.0; } else { // If Furnace runs then set HeatCoilLoad on Heating Coil and the Mass Flow - if ((ScheduleManager::GetCurrentScheduleValue(state, thisFurnace.SchedPtr) > 0.0) && (furnaceInNode.MassFlowRate > 0.0) && + if ((thisFurnace.sched->getCurrentVal() > 0.0) && (furnaceInNode.MassFlowRate > 0.0) && (state.dataFurnaces->HeatingLoad)) { furnaceInNode.MassFlowRate = thisFurnace.MdotFurnace; @@ -6410,7 +6369,7 @@ namespace Furnaces { // END IF thisFurnace.MdotFurnace = furnaceInNode.MassFlowRate; - } else if ((ScheduleManager::GetCurrentScheduleValue(state, thisFurnace.SchedPtr) > 0.0) && (furnaceInNode.MassFlowRate > 0.0) && + } else if ((thisFurnace.sched->getCurrentVal() > 0.0) && (furnaceInNode.MassFlowRate > 0.0) && (fanOp == HVAC::FanOp::Continuous)) { HeatCoilLoad = 0.0; } else { // no heating and no flow @@ -6650,7 +6609,7 @@ namespace Furnaces { //*********** Heating Section ************ // If Furnace runs with a heating load then set HeatCoilLoad on Heating Coil and the Mass Flow // (Node(FurnaceInletNode)%MassFlowRate .gt. 0.0d0) .and. & - if ((ScheduleManager::GetCurrentScheduleValue(state, thisFurnace.SchedPtr) > 0.0) && (state.dataFurnaces->HeatingLoad)) { + if ((thisFurnace.sched->getCurrentVal() > 0.0) && (state.dataFurnaces->HeatingLoad)) { // Heat pumps only calculate a single PLR each time step (i.e. only cooling or heating allowed in a single time step) if (thisFurnace.type == HVAC::UnitarySysType::Unitary_HeatPump_AirToAir || @@ -7128,7 +7087,7 @@ namespace Furnaces { // Simulate if scheduled ON and cooling load or if a moisture load exists when using a humidistat // Check of HeatingLatentOutput is used to reduce overshoot during simultaneous heating and cooling // Setback flag is used to avoid continued RH control when Tstat is setback (RH should float down) - if ((ScheduleManager::GetCurrentScheduleValue(state, thisFurnace.SchedPtr) > 0.0 && state.dataFurnaces->CoolingLoad) || + if ((thisFurnace.sched->getCurrentVal() > 0.0 && state.dataFurnaces->CoolingLoad) || (thisFurnace.Humidistat && thisFurnace.DehumidControlType_Num == DehumidificationControlMode::CoolReheat && (SystemMoistureLoad < 0.0 || (SystemMoistureLoad >= 0.0 && HeatingLatentOutput > SystemMoistureLoad && !state.dataZoneEnergyDemand->Setback(thisFurnace.ControlZoneNum))))) { @@ -7815,7 +7774,7 @@ namespace Furnaces { //*********HVAC Scheduled OFF************* // No heating or cooling or dehumidification //!!LKL discrepancy with < 0? - if (ScheduleManager::GetCurrentScheduleValue(state, thisFurnace.SchedPtr) == 0.0 || + if (thisFurnace.sched->getCurrentVal() == 0.0 || state.dataLoopNodes->Node(FurnaceInletNode).MassFlowRate == 0.0) { thisFurnace.MdotFurnace = 0.0; CoolCoilLoad = 0.0; @@ -7918,7 +7877,7 @@ namespace Furnaces { // AND air flow rate is greater than zero... // AND the air system has a cooling load and is not set back or in the deadband... // OR the system is controlled by a humidistat and there is a latent load - if ((ScheduleManager::GetCurrentScheduleValue(state, thisFurnace.SchedPtr) > 0.0 && + if ((thisFurnace.sched->getCurrentVal() > 0.0 && state.dataLoopNodes->Node(FurnaceInletNode).MassFlowRate > 0.0) && ((state.dataFurnaces->CoolingLoad) || (thisFurnace.Humidistat && thisFurnace.CoolingCoilLatentDemand < 0.0))) { @@ -8120,7 +8079,7 @@ namespace Furnaces { //*********HEATING CALCULATIONS**************** // If Furnace runs with a heating load then set HeatCoilLoad on Heating Coil and the Mass Flow - } else if ((ScheduleManager::GetCurrentScheduleValue(state, thisFurnace.SchedPtr) > 0.0) && + } else if ((thisFurnace.sched->getCurrentVal() > 0.0) && (state.dataLoopNodes->Node(FurnaceInletNode).MassFlowRate > 0.0) && state.dataFurnaces->HeatingLoad) { // Set the air flow rate to the design flow rate and set the fan operation fraction to 1 (continuous operation) @@ -8337,7 +8296,7 @@ namespace Furnaces { } //**********HVAC Scheduled ON, but no cooling, dehumidification or heating load********* - } else if (ScheduleManager::GetCurrentScheduleValue(state, thisFurnace.SchedPtr) > 0.0) { + } else if (thisFurnace.sched->getCurrentVal() > 0.0) { thisFurnace.InitHeatPump = true; // initialization call to Calc Furnace HeatPartLoadRatio = 0.0; CoolPartLoadRatio = 0.0; @@ -9049,8 +9008,8 @@ namespace Furnaces { state.dataFurnaces->FanSpeedRatio = state.dataFurnaces->CompOnFlowRatio; } // IF the furnace is scheduled on or nightime cycle overrides fan schedule. Uses same logic as fan. - if (ScheduleManager::GetCurrentScheduleValue(state, state.dataFurnaces->Furnace(FurnaceNum).SchedPtr) > 0.0 && - ((ScheduleManager::GetCurrentScheduleValue(state, state.dataFurnaces->Furnace(FurnaceNum).FanAvailSchedPtr) > 0.0 || + if (state.dataFurnaces->Furnace(FurnaceNum).sched->getCurrentVal() > 0.0 && + ((state.dataFurnaces->Furnace(FurnaceNum).fanAvailSched->getCurrentVal() > 0.0 || state.dataHVACGlobal->TurnFansOn) && !state.dataHVACGlobal->TurnFansOff)) { state.dataLoopNodes->Node(InletNode).MassFlowRate = AverageUnitMassFlow; @@ -9469,7 +9428,7 @@ namespace Furnaces { TotalZoneSensibleLoad = QZnReq; TotalZoneLatentLoad = QLatReq; // Calculate the reheat coil output - if ((ScheduleManager::GetCurrentScheduleValue(state, thisFurnace.SchedPtr) > 0.0) && + if ((thisFurnace.sched->getCurrentVal() > 0.0) && (thisFurnace.Humidistat && thisFurnace.DehumidControlType_Num == DehumidificationControlMode::CoolReheat && (QLatReq < 0.0))) { // if a Humidistat is installed and dehumdification control type is CoolReheat CalcVarSpeedHeatPump(state, @@ -9675,7 +9634,7 @@ namespace Furnaces { Real64 ErrorToler = 0.001; // Error tolerance for convergence from input deck auto &thisFurnace = state.dataFurnaces->Furnace(FurnaceNum); - if (ScheduleManager::GetCurrentScheduleValue(state, thisFurnace.SchedPtr) == 0.0) return; + if (thisFurnace.sched->getCurrentVal() == 0.0) return; // Get result when DX coil is off SupHeaterLoad = 0.0; @@ -10853,8 +10812,8 @@ namespace Furnaces { } } - if ((ScheduleManager::GetCurrentScheduleValue(state, thisFurnace.SchedPtr) == 0.0) || state.dataHVACGlobal->TurnFansOff || - (ScheduleManager::GetCurrentScheduleValue(state, thisFurnace.FanAvailSchedPtr) == 0.0 && !state.dataHVACGlobal->TurnFansOn)) { + if ((thisFurnace.sched->getCurrentVal() == 0.0) || state.dataHVACGlobal->TurnFansOff || + (thisFurnace.fanAvailSched->getCurrentVal() == 0.0 && !state.dataHVACGlobal->TurnFansOn)) { state.dataLoopNodes->Node(thisFurnace.FurnaceInletNodeNum).MassFlowRate = 0.0; OnOffAirFlowRatio = 0.0; } else { diff --git a/src/EnergyPlus/Furnaces.hh b/src/EnergyPlus/Furnaces.hh index 0c42383cead..74f789fd847 100644 --- a/src/EnergyPlus/Furnaces.hh +++ b/src/EnergyPlus/Furnaces.hh @@ -111,9 +111,9 @@ namespace Furnaces { std::string Name; // Name of the Furnace HVAC::UnitarySysType type = HVAC::UnitarySysType::Invalid; // Numeric Equivalent for Furnace Type int FurnaceIndex; // Index to furnace - int SchedPtr; // Index to furnace operating schedule - int FanSchedPtr; // Index to fan operating mode schedule - int FanAvailSchedPtr; // Index to fan availability schedule + Sched::Schedule *sched = nullptr; // furnace operating schedule + Sched::Schedule *fanOpModeSched = nullptr; // fan operating mode schedule + Sched::Schedule *fanAvailSched = nullptr; // fan availability schedule int ControlZoneNum; // Index to controlled zone int ZoneSequenceCoolingNum; // Index to cooling sequence/priority for this zone int ZoneSequenceHeatingNum; // Index to heating sequence/priority for this zone @@ -255,7 +255,7 @@ namespace Furnaces { int ErrCountVar2 = 0; // Counter used to minimize the occurrence of output warnings FurnaceEquipConditions() - : FurnaceIndex(0), SchedPtr(0), FanSchedPtr(0), FanAvailSchedPtr(0), ControlZoneNum(0), ZoneSequenceCoolingNum(0), + : FurnaceIndex(0), ControlZoneNum(0), ZoneSequenceCoolingNum(0), ZoneSequenceHeatingNum(0), CoolingCoilType_Num(0), CoolingCoilIndex(0), ActualDXCoilIndexForHXAssisted(0), CoolingCoilUpstream(true), HeatingCoilType_Num(0), HeatingCoilIndex(0), ReheatingCoilType_Num(0), ReheatingCoilIndex(0), CoilControlNode(0), HWCoilAirInletNode(0), HWCoilAirOutletNode(0), SuppCoilAirInletNode(0), SuppCoilAirOutletNode(0), SuppHeatCoilType_Num(0), SuppHeatCoilIndex(0), @@ -577,6 +577,10 @@ struct FurnacesData : BaseGlobalStruct int SpeedNum = 1; // Speed number Real64 SupHeaterLoad = 0.0; // supplement heater load + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/General.hh b/src/EnergyPlus/General.hh index 31f26cdf9f4..c66881403cd 100644 --- a/src/EnergyPlus/General.hh +++ b/src/EnergyPlus/General.hh @@ -346,6 +346,10 @@ struct GeneralData : BaseGlobalStruct std::string VarDictOption1; std::string VarDictOption2; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/GeneralRoutines.cc b/src/EnergyPlus/GeneralRoutines.cc index 4784ac71328..46ac28bb9b2 100644 --- a/src/EnergyPlus/GeneralRoutines.cc +++ b/src/EnergyPlus/GeneralRoutines.cc @@ -798,7 +798,7 @@ void ValidateComponent(EnergyPlusData &state, void CalcBasinHeaterPower(EnergyPlusData &state, Real64 const Capacity, // Basin heater capacity per degree C below setpoint (W/C) - int const SchedulePtr, // Pointer to basin heater schedule + Sched::Schedule *sched, // basin heater schedule Real64 const SetPointTemp, // setpoint temperature for basin heater operation (C) Real64 &Power // Basin heater power (W) ) @@ -821,8 +821,8 @@ void CalcBasinHeaterPower(EnergyPlusData &state, Power = 0.0; // Operate basin heater anytime outdoor temperature is below setpoint and water is not flowing through the equipment // IF schedule exists, basin heater performance can be scheduled OFF - if (SchedulePtr > 0) { - Real64 BasinHeaterSch = ScheduleManager::GetCurrentScheduleValue(state, SchedulePtr); + if (sched != nullptr) { + Real64 BasinHeaterSch = sched->getCurrentVal(); if (Capacity > 0.0 && BasinHeaterSch > 0.0) { Power = max(0.0, Capacity * (SetPointTemp - state.dataEnvrn->OutDryBulbTemp)); } diff --git a/src/EnergyPlus/GeneralRoutines.hh b/src/EnergyPlus/GeneralRoutines.hh index 2b13e24cccb..9c39f0626c4 100644 --- a/src/EnergyPlus/GeneralRoutines.hh +++ b/src/EnergyPlus/GeneralRoutines.hh @@ -57,6 +57,7 @@ #include #include #include +#include namespace EnergyPlus { @@ -175,9 +176,10 @@ void ValidateComponent(EnergyPlusData &state, std::string_view CallString // Context of this pair -- for error message ); +// Why is this in GeneralRoutines? Asking for a friend void CalcBasinHeaterPower(EnergyPlusData &state, Real64 const Capacity, // Basin heater capacity per degree C below setpoint (W/C) - int const SchedulePtr, // Pointer to basin heater schedule + Sched::Schedule *sched, // Pointer to basin heater schedule Real64 const SetPointTemp, // setpoint temperature for basin heater operation (C) Real64 &Power // Basin heater power (W) ); @@ -220,6 +222,10 @@ struct GeneralRoutinesData : BaseGlobalStruct IntervalHalf ZoneInterHalf = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, false, false, false, false}; ZoneEquipControllerProps ZoneController = {0.0, 0.0, 0.0, 0.0, 0.0}; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/GeneratorDynamicsManager.cc b/src/EnergyPlus/GeneratorDynamicsManager.cc index f20c5159d5b..a2e9e3952ab 100644 --- a/src/EnergyPlus/GeneratorDynamicsManager.cc +++ b/src/EnergyPlus/GeneratorDynamicsManager.cc @@ -122,7 +122,7 @@ namespace GeneratorDynamicsManager { thisGen.MandatoryFullCoolDown = thisMicroCHP.A42Model.MandatoryFullCoolDown; thisGen.WarmRestartOkay = thisMicroCHP.A42Model.WarmRestartOkay; thisGen.WarmUpDelay = thisMicroCHP.A42Model.WarmUpDelay; - thisGen.CoolDownDelay = thisMicroCHP.A42Model.CoolDownDelay / Constant::SecInHour; // seconds to hours + thisGen.CoolDownDelay = thisMicroCHP.A42Model.CoolDownDelay / Constant::rSecsInHour; // seconds to hours thisGen.PcoolDown = thisMicroCHP.A42Model.PcoolDown; thisGen.Pstandby = thisMicroCHP.A42Model.Pstandby; thisGen.MCeng = thisMicroCHP.A42Model.MCeng; @@ -130,8 +130,8 @@ namespace GeneratorDynamicsManager { thisGen.kf = thisMicroCHP.A42Model.kf; thisGen.TnomEngOp = thisMicroCHP.A42Model.TnomEngOp; thisGen.kp = thisMicroCHP.A42Model.kp; - thisGen.AvailabilitySchedID = thisMicroCHP.AvailabilitySchedID; - thisGen.StartUpTimeDelay = thisMicroCHP.A42Model.WarmUpDelay / Constant::SecInHour; // seconds to hours + thisGen.availSched = thisMicroCHP.availSched; + thisGen.StartUpTimeDelay = thisMicroCHP.A42Model.WarmUpDelay / Constant::rSecsInHour; // seconds to hours thisGen.ElectEffNom = thisMicroCHP.A42Model.ElecEff; thisGen.ThermEffNom = thisMicroCHP.A42Model.ThermEff; @@ -245,7 +245,7 @@ namespace GeneratorDynamicsManager { } // check availability schedule - Real64 SchedVal = ScheduleManager::GetCurrentScheduleValue(state, thisGen.AvailabilitySchedID); + Real64 SchedVal = thisGen.availSched->getCurrentVal(); Real64 Pel = PelInput; // get data to check if sufficient flow available from Plant @@ -280,7 +280,7 @@ namespace GeneratorDynamicsManager { double(state.dataGlobal->DayOfSim) + (int(state.dataGlobal->CurrentTime) + (SysTimeElapsed + (state.dataGlobal->CurrentTime - int(state.dataGlobal->CurrentTime) - TimeStepSys))) / - Constant::HoursInDay; + Constant::rHoursInDay; } else { // warm up period is less than a single system time step newOpMode = DataGenerators::OperatingMode::Normal; @@ -323,7 +323,7 @@ namespace GeneratorDynamicsManager { double(state.dataGlobal->DayOfSim) + (int(state.dataGlobal->CurrentTime) + (SysTimeElapsed + (state.dataGlobal->CurrentTime - int(state.dataGlobal->CurrentTime)))) / - Constant::HoursInDay; + Constant::rHoursInDay; } else { newOpMode = DataGenerators::OperatingMode::Off; } @@ -340,7 +340,7 @@ namespace GeneratorDynamicsManager { double(state.dataGlobal->DayOfSim) + (int(state.dataGlobal->CurrentTime) + (SysTimeElapsed + (state.dataGlobal->CurrentTime - int(state.dataGlobal->CurrentTime)))) / - Constant::HoursInDay; + Constant::rHoursInDay; } else { newOpMode = DataGenerators::OperatingMode::Standby; @@ -356,12 +356,12 @@ namespace GeneratorDynamicsManager { Real64 CurrentFractionalDay = double(state.dataGlobal->DayOfSim) + (int(state.dataGlobal->CurrentTime) + (SysTimeElapsed + (state.dataGlobal->CurrentTime - int(state.dataGlobal->CurrentTime)))) / - Constant::HoursInDay; - Real64 EndingFractionalDay = thisGen.FractionalDayofLastStartUp + thisGen.StartUpTimeDelay / Constant::HoursInDay; + Constant::rHoursInDay; + Real64 EndingFractionalDay = thisGen.FractionalDayofLastStartUp + thisGen.StartUpTimeDelay / Constant::rHoursInDay; if ((std::abs(CurrentFractionalDay - EndingFractionalDay) < 0.000001) || (CurrentFractionalDay > EndingFractionalDay)) { newOpMode = DataGenerators::OperatingMode::Normal; PLRStartUp = true; - Real64 LastSystemTimeStepFractionalDay = CurrentFractionalDay - (TimeStepSys / Constant::HoursInDay); + Real64 LastSystemTimeStepFractionalDay = CurrentFractionalDay - (TimeStepSys / Constant::rHoursInDay); PLRforSubtimestepStartUp = ((CurrentFractionalDay - EndingFractionalDay) / (CurrentFractionalDay - LastSystemTimeStepFractionalDay)); } else { @@ -407,7 +407,7 @@ namespace GeneratorDynamicsManager { thisGen.FractionalDayofLastShutDown = double(state.dataGlobal->DayOfSim) + (int(state.dataGlobal->CurrentTime) + (SysTimeElapsed + (state.dataGlobal->CurrentTime - int(state.dataGlobal->CurrentTime)))) / - Constant::HoursInDay; + Constant::rHoursInDay; } else { // cool down period is less than a single system time step if (SchedVal != 0.0) { newOpMode = DataGenerators::OperatingMode::Standby; @@ -421,7 +421,7 @@ namespace GeneratorDynamicsManager { thisGen.FractionalDayofLastShutDown = double(state.dataGlobal->DayOfSim) + (int(state.dataGlobal->CurrentTime) + (SysTimeElapsed + (state.dataGlobal->CurrentTime - int(state.dataGlobal->CurrentTime)))) / - Constant::HoursInDay; + Constant::rHoursInDay; } } else { @@ -438,15 +438,15 @@ namespace GeneratorDynamicsManager { Real64 CurrentFractionalDay = double(state.dataGlobal->DayOfSim) + (int(state.dataGlobal->CurrentTime) + (SysTimeElapsed + (state.dataGlobal->CurrentTime - int(state.dataGlobal->CurrentTime)))) / - Constant::HoursInDay; + Constant::rHoursInDay; Real64 EndingFractionalDay = - thisGen.FractionalDayofLastShutDown + thisGen.CoolDownDelay / Constant::HoursInDay - (TimeStepSys / Constant::HoursInDay); + thisGen.FractionalDayofLastShutDown + thisGen.CoolDownDelay / Constant::rHoursInDay - (TimeStepSys / Constant::rHoursInDay); if ((std::abs(CurrentFractionalDay - EndingFractionalDay) < 0.000001) || (CurrentFractionalDay > EndingFractionalDay)) { // CurrentFractionalDay == EndingFractionalDay newOpMode = DataGenerators::OperatingMode::Off; PLRShutDown = true; - Real64 LastSystemTimeStepFractionalDay = CurrentFractionalDay - (TimeStepSys / Constant::HoursInDay); - PLRforSubtimestepShutDown = (EndingFractionalDay - LastSystemTimeStepFractionalDay) * Constant::HoursInDay / TimeStepSys; + Real64 LastSystemTimeStepFractionalDay = CurrentFractionalDay - (TimeStepSys / Constant::rHoursInDay); + PLRforSubtimestepShutDown = (EndingFractionalDay - LastSystemTimeStepFractionalDay) * Constant::rHoursInDay / TimeStepSys; } else { // CurrentFractionalDay > EndingFractionalDay newOpMode = DataGenerators::OperatingMode::CoolDown; } @@ -460,15 +460,15 @@ namespace GeneratorDynamicsManager { Real64 CurrentFractionalDay = double(state.dataGlobal->DayOfSim) + (int(state.dataGlobal->CurrentTime) + (SysTimeElapsed + (state.dataGlobal->CurrentTime - int(state.dataGlobal->CurrentTime)))) / - Constant::HoursInDay; + Constant::rHoursInDay; Real64 EndingFractionalDay = - thisGen.FractionalDayofLastShutDown + thisGen.CoolDownDelay / Constant::HoursInDay - (TimeStepSys / Constant::HoursInDay); + thisGen.FractionalDayofLastShutDown + thisGen.CoolDownDelay / Constant::rHoursInDay - (TimeStepSys / Constant::rHoursInDay); if ((std::abs(CurrentFractionalDay - EndingFractionalDay) < 0.000001) || (CurrentFractionalDay > EndingFractionalDay)) { // CurrentFractionalDay == EndingFractionalDay newOpMode = DataGenerators::OperatingMode::Standby; PLRShutDown = true; - Real64 LastSystemTimeStepFractionalDay = CurrentFractionalDay - (TimeStepSys / Constant::HoursInDay); - PLRforSubtimestepShutDown = (EndingFractionalDay - LastSystemTimeStepFractionalDay) * Constant::HoursInDay / TimeStepSys; + Real64 LastSystemTimeStepFractionalDay = CurrentFractionalDay - (TimeStepSys / Constant::rHoursInDay); + PLRforSubtimestepShutDown = (EndingFractionalDay - LastSystemTimeStepFractionalDay) * Constant::rHoursInDay / TimeStepSys; } else { // CurrentFractionalDay < EndingFractionalDay newOpMode = DataGenerators::OperatingMode::CoolDown; } @@ -485,9 +485,9 @@ namespace GeneratorDynamicsManager { Real64 CurrentFractionalDay = double(state.dataGlobal->DayOfSim) + (int(state.dataGlobal->CurrentTime) + (SysTimeElapsed + (state.dataGlobal->CurrentTime - int(state.dataGlobal->CurrentTime)))) / - Constant::HoursInDay; + Constant::rHoursInDay; Real64 EndingFractionalDay = - thisGen.FractionalDayofLastShutDown + thisGen.CoolDownDelay / Constant::HoursInDay - (TimeStepSys / Constant::HoursInDay); + thisGen.FractionalDayofLastShutDown + thisGen.CoolDownDelay / Constant::rHoursInDay - (TimeStepSys / Constant::rHoursInDay); if ((std::abs(CurrentFractionalDay - EndingFractionalDay) < 0.000001) || (CurrentFractionalDay < EndingFractionalDay)) { // CurrentFractionalDay == EndingFractionalDay @@ -495,8 +495,8 @@ namespace GeneratorDynamicsManager { } else { // CurrentFractionalDay > EndingFractionalDay // could go to warm up or normal now PLRShutDown = true; - Real64 LastSystemTimeStepFractionalDay = CurrentFractionalDay - (TimeStepSys / Constant::HoursInDay); - PLRforSubtimestepShutDown = (EndingFractionalDay - LastSystemTimeStepFractionalDay) * Constant::HoursInDay / TimeStepSys; + Real64 LastSystemTimeStepFractionalDay = CurrentFractionalDay - (TimeStepSys / Constant::rHoursInDay); + PLRforSubtimestepShutDown = (EndingFractionalDay - LastSystemTimeStepFractionalDay) * Constant::rHoursInDay / TimeStepSys; if (thisGen.StartUpTimeDelay == 0.0) { newOpMode = DataGenerators::OperatingMode::Normal; // possible PLR on start up. @@ -519,7 +519,7 @@ namespace GeneratorDynamicsManager { double(state.dataGlobal->DayOfSim) + (int(state.dataGlobal->CurrentTime) + (SysTimeElapsed + (state.dataGlobal->CurrentTime - int(state.dataGlobal->CurrentTime) - TimeStepSys))) / - Constant::HoursInDay; + Constant::rHoursInDay; } } } @@ -537,14 +537,14 @@ namespace GeneratorDynamicsManager { Real64 CurrentFractionalDay = double(state.dataGlobal->DayOfSim) + (int(state.dataGlobal->CurrentTime) + (SysTimeElapsed + (state.dataGlobal->CurrentTime - int(state.dataGlobal->CurrentTime)))) / - Constant::HoursInDay; - Real64 EndingFractionalDay = thisGen.FractionalDayofLastShutDown + thisGen.CoolDownDelay / Constant::HoursInDay; + Constant::rHoursInDay; + Real64 EndingFractionalDay = thisGen.FractionalDayofLastShutDown + thisGen.CoolDownDelay / Constant::rHoursInDay; if ((std::abs(CurrentFractionalDay - EndingFractionalDay) < 0.000001) || (CurrentFractionalDay > EndingFractionalDay)) { // CurrentFractionalDay == EndingFractionalDay newOpMode = DataGenerators::OperatingMode::Normal; // possible PLR on start up. PLRStartUp = true; - Real64 LastSystemTimeStepFractionalDay = CurrentFractionalDay - (TimeStepSys / Constant::HoursInDay); + Real64 LastSystemTimeStepFractionalDay = CurrentFractionalDay - (TimeStepSys / Constant::rHoursInDay); PLRforSubtimestepStartUp = ((CurrentFractionalDay - EndingFractionalDay) / (CurrentFractionalDay - LastSystemTimeStepFractionalDay)); } else { @@ -555,7 +555,7 @@ namespace GeneratorDynamicsManager { double(state.dataGlobal->DayOfSim) + (int(state.dataGlobal->CurrentTime) + (SysTimeElapsed + (state.dataGlobal->CurrentTime - int(state.dataGlobal->CurrentTime) - TimeStepSys))) / - Constant::HoursInDay; + Constant::rHoursInDay; } } } diff --git a/src/EnergyPlus/GeneratorFuelSupply.cc b/src/EnergyPlus/GeneratorFuelSupply.cc index ebbe59af1ac..dc65b8b4f42 100644 --- a/src/EnergyPlus/GeneratorFuelSupply.cc +++ b/src/EnergyPlus/GeneratorFuelSupply.cc @@ -100,6 +100,7 @@ namespace GeneratorFuelSupply { // RE-ENGINEERED this module extracted from older SOFC module for // reuse with both Annex 42 models, + static constexpr std::string_view routineName = "GetGeneratorFuelSupplyInput"; // SUBROUTINE LOCAL VARIABLE DECLARATIONS: // INTEGER :: GeneratorNum !Generator counter Array1D_string AlphArray(25); // character string data @@ -134,6 +135,7 @@ namespace GeneratorFuelSupply { state.dataIPShortCut->cAlphaFieldNames, state.dataIPShortCut->cNumericFieldNames); + ErrorObjectHeader eoh{routineName, cCurrentModuleObject, AlphArray(1)}; state.dataGenerator->FuelSupply(FuelSupNum).Name = AlphArray(1); if (Util::SameString("TemperatureFromAirNode", AlphArray(2))) { state.dataGenerator->FuelSupply(FuelSupNum).FuelTempMode = DataGenerators::FuelTemperatureMode::FuelInTempFromNode; @@ -157,13 +159,11 @@ namespace GeneratorFuelSupply { NodeInputManager::CompFluidStream::Primary, DataLoopNode::ObjectIsNotParent); - state.dataGenerator->FuelSupply(FuelSupNum).SchedNum = ScheduleManager::GetScheduleIndex(state, AlphArray(4)); - if ((state.dataGenerator->FuelSupply(FuelSupNum).SchedNum == 0) && - (state.dataGenerator->FuelSupply(FuelSupNum).FuelTempMode == DataGenerators::FuelTemperatureMode::FuelInTempSchedule)) { - ShowSevereError(state, format("Invalid, {} = {}", state.dataIPShortCut->cAlphaFieldNames(4), AlphArray(4))); - ShowContinueError(state, format("Entered in {}={}", cCurrentModuleObject, AlphArray(1))); - ShowContinueError(state, "Schedule named was not found"); - ErrorsFound = true; + if (state.dataGenerator->FuelSupply(FuelSupNum).FuelTempMode == DataGenerators::FuelTemperatureMode::FuelInTempSchedule) { + if ((state.dataGenerator->FuelSupply(FuelSupNum).sched = Sched::GetSchedule(state, AlphArray(4))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(4), AlphArray(4)); + ErrorsFound = true; + } } state.dataGenerator->FuelSupply(FuelSupNum).CompPowerCurveID = Curve::GetCurveIndex(state, AlphArray(5)); diff --git a/src/EnergyPlus/GeneratorFuelSupply.hh b/src/EnergyPlus/GeneratorFuelSupply.hh index a612372720b..0ece9776479 100644 --- a/src/EnergyPlus/GeneratorFuelSupply.hh +++ b/src/EnergyPlus/GeneratorFuelSupply.hh @@ -70,6 +70,10 @@ struct GeneratorFuelSupplyData : BaseGlobalStruct bool MyOneTimeFlag = true; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/GlobalNames.hh b/src/EnergyPlus/GlobalNames.hh index e5ca827a7a2..64d5d13b05e 100644 --- a/src/EnergyPlus/GlobalNames.hh +++ b/src/EnergyPlus/GlobalNames.hh @@ -145,6 +145,10 @@ struct GlobalNamesData : BaseGlobalStruct std::unordered_map CoilNames; std::unordered_map aDUNames; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/GroundHeatExchangers.cc b/src/EnergyPlus/GroundHeatExchangers.cc index 7c86b973419..694d4c43ff5 100644 --- a/src/EnergyPlus/GroundHeatExchangers.cc +++ b/src/EnergyPlus/GroundHeatExchangers.cc @@ -1018,7 +1018,7 @@ void GLHEVert::setupTimeVectors() // Determine how many g-function pairs to generate based on user defined maximum simulation time while (true) { Real64 maxPossibleSimTime = exp(tempLNTTS.back()) * t_s; - if (maxPossibleSimTime < this->myRespFactors->maxSimYears * numDaysInYear * Constant::HoursInDay * Constant::SecInHour) { + if (maxPossibleSimTime < this->myRespFactors->maxSimYears * numDaysInYear * Constant::rHoursInDay * Constant::rSecsInHour) { tempLNTTS.push_back(tempLNTTS.back() + lnttsStepSize); } else { break; @@ -1934,7 +1934,7 @@ void GLHEVert::getAnnualTimeConstant() constexpr Real64 hrInYear = 8760; - this->timeSS = (pow_2(this->bhLength) / (9.0 * this->soil.diffusivity)) / Constant::SecInHour / hrInYear; + this->timeSS = (pow_2(this->bhLength) / (9.0 * this->soil.diffusivity)) / Constant::rSecsInHour / hrInYear; // Excuse me? this->timeSSFactor = this->timeSS * 8760.0; } @@ -2031,7 +2031,7 @@ void GLHEBase::calcGroundHeatExchanger(EnergyPlusData &state) state.dataGroundHeatExchanger->currentSimTime = (state.dataGlobal->DayOfSim - 1) * 24 + state.dataGlobal->HourOfDay - 1 + (state.dataGlobal->TimeStep - 1) * state.dataGlobal->TimeStepZone + state.dataHVACGlobal->SysTimeElapsed; //+ TimeStepsys - state.dataGroundHeatExchanger->locHourOfDay = static_cast(mod(state.dataGroundHeatExchanger->currentSimTime, Constant::HoursInDay) + 1); + state.dataGroundHeatExchanger->locHourOfDay = static_cast(mod(state.dataGroundHeatExchanger->currentSimTime, Constant::iHoursInDay) + 1); state.dataGroundHeatExchanger->locDayOfSim = static_cast(state.dataGroundHeatExchanger->currentSimTime / 24 + 1); if (state.dataGlobal->DayOfSim > 1) { @@ -2347,11 +2347,11 @@ void GLHEBase::calcAggregateLoad(EnergyPlusData &state) } // CHECK IF A MONTH PASSES... - if (mod(((state.dataGroundHeatExchanger->locDayOfSim - 1) * Constant::HoursInDay + (state.dataGroundHeatExchanger->locHourOfDay)), hrsPerMonth) == + if (mod(((state.dataGroundHeatExchanger->locDayOfSim - 1) * Constant::iHoursInDay + (state.dataGroundHeatExchanger->locHourOfDay)), hrsPerMonth) == 0 && this->prevHour != state.dataGroundHeatExchanger->locHourOfDay) { Real64 MonthNum = static_cast( - (state.dataGroundHeatExchanger->locDayOfSim * Constant::HoursInDay + state.dataGroundHeatExchanger->locHourOfDay) / hrsPerMonth); + (state.dataGroundHeatExchanger->locDayOfSim * Constant::iHoursInDay + state.dataGroundHeatExchanger->locHourOfDay) / hrsPerMonth); Real64 SumQnMonth = 0.0; for (int J = 1; J <= int(hrsPerMonth); ++J) { SumQnMonth += this->QnHr(J); @@ -2913,7 +2913,7 @@ void GLHEVert::initGLHESimVars(EnergyPlusData &state) // SUBROUTINE LOCAL VARIABLE DECLARATIONS: Real64 currTime = ((state.dataGlobal->DayOfSim - 1) * 24 + (state.dataGlobal->HourOfDay - 1) + (state.dataGlobal->TimeStep - 1) * state.dataGlobal->TimeStepZone + state.dataHVACGlobal->SysTimeElapsed) * - Constant::SecInHour; + Constant::rSecsInHour; if (this->myEnvrnFlag && state.dataGlobal->BeginEnvrnFlag) { this->initEnvironment(state, currTime); @@ -2999,9 +2999,9 @@ void GLHESlinky::initGLHESimVars(EnergyPlusData &state) // DATE WRITTEN: August, 2000 // MODIFIED Arun Murugappan - Real64 CurTime = ((state.dataGlobal->DayOfSim - 1) * 24 + (state.dataGlobal->HourOfDay - 1) + + Real64 CurTime = ((state.dataGlobal->DayOfSim - 1) * Constant::rHoursInDay + (state.dataGlobal->HourOfDay - 1) + (state.dataGlobal->TimeStep - 1) * state.dataGlobal->TimeStepZone + state.dataHVACGlobal->SysTimeElapsed) * - Constant::SecInHour; + Constant::rSecsInHour; // Init more variables if (this->myEnvrnFlag && state.dataGlobal->BeginEnvrnFlag) { diff --git a/src/EnergyPlus/GroundHeatExchangers.hh b/src/EnergyPlus/GroundHeatExchangers.hh index a8b5ff2db37..50260f32822 100644 --- a/src/EnergyPlus/GroundHeatExchangers.hh +++ b/src/EnergyPlus/GroundHeatExchangers.hh @@ -530,6 +530,10 @@ struct GroundHeatExchangerData : BaseGlobalStruct std::vector> responseFactorsVector; std::vector> singleBoreholesVector; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/GroundTemperatureModeling/FiniteDifferenceGroundTemperatureModel.cc b/src/EnergyPlus/GroundTemperatureModeling/FiniteDifferenceGroundTemperatureModel.cc index 7cb4a0bb2b1..17605275c0e 100644 --- a/src/EnergyPlus/GroundTemperatureModeling/FiniteDifferenceGroundTemperatureModel.cc +++ b/src/EnergyPlus/GroundTemperatureModeling/FiniteDifferenceGroundTemperatureModel.cc @@ -260,7 +260,7 @@ void FiniteDiffGroundTempsModel::getWeatherData(EnergyPlusData &state) state.dataGlobal->BeginHourFlag = true; state.dataGlobal->EndHourFlag = false; - for (state.dataGlobal->TimeStep = 1; state.dataGlobal->TimeStep <= state.dataGlobal->NumOfTimeStepInHour; ++state.dataGlobal->TimeStep) { + for (state.dataGlobal->TimeStep = 1; state.dataGlobal->TimeStep <= state.dataGlobal->TimeStepsInHour; ++state.dataGlobal->TimeStep) { state.dataGlobal->BeginTimeStepFlag = true; @@ -271,7 +271,7 @@ void FiniteDiffGroundTempsModel::getWeatherData(EnergyPlusData &state) // Note also that BeginTimeStepFlag, EndTimeStepFlag, and the // SubTimeStepFlags can/will be set/reset in the HVAC Manager. - if (state.dataGlobal->TimeStep == state.dataGlobal->NumOfTimeStepInHour) { + if (state.dataGlobal->TimeStep == state.dataGlobal->TimeStepsInHour) { state.dataGlobal->EndHourFlag = true; if (state.dataGlobal->HourOfDay == 24) { state.dataGlobal->EndDayFlag = true; @@ -441,7 +441,7 @@ void FiniteDiffGroundTempsModel::performSimulation(EnergyPlusData &state) // Simulates model, repeating years, until steady-periodic temperatures are determined. // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - timeStepInSeconds = Constant::SecsInDay; + timeStepInSeconds = Constant::rSecsInDay; bool convergedFinal = false; initDomain(state); @@ -798,7 +798,7 @@ void FiniteDiffGroundTempsModel::initDomain(EnergyPlusData &state) tempModel->aveGroundTemp = annualAveAirTemp; tempModel->aveGroundTempAmplitude = (maxDailyAirTemp - minDailyAirTemp) / 4.0; // Rough estimate here. Ground temps will not swing as far as the air temp. - tempModel->phaseShiftInSecs = dayOfMinDailyAirTemp * Constant::SecsInDay; + tempModel->phaseShiftInSecs = dayOfMinDailyAirTemp * Constant::rSecsInDay; tempModel->groundThermalDiffisivity = baseConductivity / (baseDensity * baseSpecificHeat); // Initialize temperatures and volume @@ -1023,7 +1023,7 @@ Real64 FiniteDiffGroundTempsModel::getGroundTempAtTimeInSeconds(EnergyPlusData & depth = _depth; - simTimeInDays = seconds / Constant::SecsInDay; + simTimeInDays = seconds / Constant::rSecsInDay; if (simTimeInDays > state.dataWeather->NumDaysInYear) { simTimeInDays = remainder(simTimeInDays, state.dataWeather->NumDaysInYear); diff --git a/src/EnergyPlus/GroundTemperatureModeling/GroundTemperatureModelManager.hh b/src/EnergyPlus/GroundTemperatureModeling/GroundTemperatureModelManager.hh index a905559976b..08acd5d24b0 100644 --- a/src/EnergyPlus/GroundTemperatureModeling/GroundTemperatureModelManager.hh +++ b/src/EnergyPlus/GroundTemperatureModeling/GroundTemperatureModelManager.hh @@ -80,6 +80,10 @@ struct GroundTemperatureManagerData : BaseGlobalStruct { std::vector> groundTempModels; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/GroundTemperatureModeling/KusudaAchenbachGroundTemperatureModel.cc b/src/EnergyPlus/GroundTemperatureModeling/KusudaAchenbachGroundTemperatureModel.cc index 950331d122b..d9e33df11b2 100644 --- a/src/EnergyPlus/GroundTemperatureModeling/KusudaAchenbachGroundTemperatureModel.cc +++ b/src/EnergyPlus/GroundTemperatureModeling/KusudaAchenbachGroundTemperatureModel.cc @@ -108,7 +108,7 @@ std::shared_ptr KusudaGroundTempsModel::KusudaGTMFactory // Use Kusuda Parameters thisModel->aveGroundTemp = state.dataIPShortCut->rNumericArgs(4); thisModel->aveGroundTempAmplitude = state.dataIPShortCut->rNumericArgs(5); - thisModel->phaseShiftInSecs = state.dataIPShortCut->rNumericArgs(6) * Constant::SecsInDay; + thisModel->phaseShiftInSecs = state.dataIPShortCut->rNumericArgs(6) * Constant::rSecsInDay; } else { // Use data from Site:GroundTemperature:Shallow to generate parameters @@ -153,7 +153,7 @@ std::shared_ptr KusudaGroundTempsModel::KusudaGTMFactory // Assign to KA Model thisModel->aveGroundTemp = averageGroundTemp; thisModel->aveGroundTempAmplitude = amplitudeOfGroundTemp; - thisModel->phaseShiftInSecs = phaseShiftOfMinGroundTempDays * Constant::SecsInDay; + thisModel->phaseShiftInSecs = phaseShiftOfMinGroundTempDays * Constant::rSecsInDay; } found = true; @@ -185,7 +185,7 @@ Real64 KusudaGroundTempsModel::getGroundTemp(EnergyPlusData &state) // METHODOLOGY EMPLOYED: // Kusuda and Achenbach correlation is used - Real64 const secsInYear = Constant::SecsInDay * state.dataWeather->NumDaysInYear; + Real64 const secsInYear = Constant::rSecsInDay * state.dataWeather->NumDaysInYear; Real64 term1 = -depth * std::sqrt(Constant::Pi / (secsInYear * groundThermalDiffisivity)); Real64 term2 = (2 * Constant::Pi / secsInYear) * @@ -206,7 +206,7 @@ Real64 KusudaGroundTempsModel::getGroundTempAtTimeInSeconds(EnergyPlusData &stat // Returns the ground temperature when input time is in seconds // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - Real64 const secondsInYear = state.dataWeather->NumDaysInYear * Constant::SecsInDay; + Real64 const secondsInYear = state.dataWeather->NumDaysInYear * Constant::rSecsInDay; depth = _depth; @@ -232,8 +232,8 @@ Real64 KusudaGroundTempsModel::getGroundTempAtTimeInMonths(EnergyPlusData &state // Returns the ground temperature when input time is in months // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - Real64 const aveSecondsInMonth = (state.dataWeather->NumDaysInYear / 12) * Constant::SecsInDay; - Real64 const secondsPerYear = state.dataWeather->NumDaysInYear * Constant::SecsInDay; + Real64 const aveSecondsInMonth = (state.dataWeather->NumDaysInYear / 12) * Constant::rSecsInDay; + Real64 const secondsPerYear = state.dataWeather->NumDaysInYear * Constant::rSecsInDay; depth = _depth; diff --git a/src/EnergyPlus/GroundTemperatureModeling/SiteBuildingSurfaceGroundTemperatures.cc b/src/EnergyPlus/GroundTemperatureModeling/SiteBuildingSurfaceGroundTemperatures.cc index 90d687cd7b2..7539dc94fa5 100644 --- a/src/EnergyPlus/GroundTemperatureModeling/SiteBuildingSurfaceGroundTemperatures.cc +++ b/src/EnergyPlus/GroundTemperatureModeling/SiteBuildingSurfaceGroundTemperatures.cc @@ -171,7 +171,7 @@ SiteBuildingSurfaceGroundTemps::getGroundTempAtTimeInSeconds(EnergyPlusData &sta // USE STATEMENTS: // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - Real64 secPerMonth = state.dataWeather->NumDaysInYear * Constant::SecsInDay / 12; + Real64 secPerMonth = state.dataWeather->NumDaysInYear * Constant::rSecsInDay / 12; // Convert secs to months int month = ceil(_seconds / secPerMonth); diff --git a/src/EnergyPlus/GroundTemperatureModeling/SiteDeepGroundTemperatures.cc b/src/EnergyPlus/GroundTemperatureModeling/SiteDeepGroundTemperatures.cc index 236eb1f79d3..8061ffd14bc 100644 --- a/src/EnergyPlus/GroundTemperatureModeling/SiteDeepGroundTemperatures.cc +++ b/src/EnergyPlus/GroundTemperatureModeling/SiteDeepGroundTemperatures.cc @@ -160,7 +160,7 @@ Real64 SiteDeepGroundTemps::getGroundTempAtTimeInSeconds(EnergyPlusData &state, // Returns the ground temperature when input time is in seconds // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - Real64 secPerMonth = state.dataWeather->NumDaysInYear * Constant::SecsInDay / 12; + Real64 secPerMonth = state.dataWeather->NumDaysInYear * Constant::rSecsInDay / 12; // Convert secs to months int month = ceil(_seconds / secPerMonth); diff --git a/src/EnergyPlus/GroundTemperatureModeling/SiteFCFactorMethodGroundTemperatures.cc b/src/EnergyPlus/GroundTemperatureModeling/SiteFCFactorMethodGroundTemperatures.cc index 55e08254873..664d0d9df16 100644 --- a/src/EnergyPlus/GroundTemperatureModeling/SiteFCFactorMethodGroundTemperatures.cc +++ b/src/EnergyPlus/GroundTemperatureModeling/SiteFCFactorMethodGroundTemperatures.cc @@ -174,7 +174,7 @@ Real64 SiteFCFactorMethodGroundTemps::getGroundTempAtTimeInSeconds(EnergyPlusDat // Returns the ground temperature when input time is in seconds // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - Real64 secPerMonth = state.dataWeather->NumDaysInYear * Constant::SecsInDay / 12; + Real64 secPerMonth = state.dataWeather->NumDaysInYear * Constant::rSecsInDay / 12; // Convert secs to months int month = ceil(_seconds / secPerMonth); diff --git a/src/EnergyPlus/GroundTemperatureModeling/SiteShallowGroundTemperatures.cc b/src/EnergyPlus/GroundTemperatureModeling/SiteShallowGroundTemperatures.cc index a430cc98fce..757c73089e4 100644 --- a/src/EnergyPlus/GroundTemperatureModeling/SiteShallowGroundTemperatures.cc +++ b/src/EnergyPlus/GroundTemperatureModeling/SiteShallowGroundTemperatures.cc @@ -160,7 +160,7 @@ Real64 SiteShallowGroundTemps::getGroundTempAtTimeInSeconds(EnergyPlusData &stat // USE STATEMENTS: // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - Real64 secPerMonth = state.dataWeather->NumDaysInYear * Constant::SecsInDay / 12; + Real64 secPerMonth = state.dataWeather->NumDaysInYear * Constant::rSecsInDay / 12; // Convert secs to months int month = ceil(_seconds / secPerMonth); diff --git a/src/EnergyPlus/GroundTemperatureModeling/XingGroundTemperatureModel.cc b/src/EnergyPlus/GroundTemperatureModeling/XingGroundTemperatureModel.cc index 3f9701fb3c2..da6998373cb 100644 --- a/src/EnergyPlus/GroundTemperatureModeling/XingGroundTemperatureModel.cc +++ b/src/EnergyPlus/GroundTemperatureModeling/XingGroundTemperatureModel.cc @@ -99,7 +99,7 @@ std::shared_ptr XingGroundTempsModel::XingGTMFactory(Energ thisModel->objectType = objType; thisModel->groundThermalDiffisivity = state.dataIPShortCut->rNumericArgs(1) / (state.dataIPShortCut->rNumericArgs(2) * state.dataIPShortCut->rNumericArgs(3)) * - Constant::SecsInDay; + Constant::rSecsInDay; thisModel->aveGroundTemp = state.dataIPShortCut->rNumericArgs(4); thisModel->surfTempAmplitude_1 = state.dataIPShortCut->rNumericArgs(5); thisModel->surfTempAmplitude_2 = state.dataIPShortCut->rNumericArgs(6); @@ -198,7 +198,7 @@ Real64 XingGroundTempsModel::getGroundTempAtTimeInSeconds(EnergyPlusData &state, depth = _depth; - simTimeInDays = seconds / Constant::SecsInDay; + simTimeInDays = seconds / Constant::rSecsInDay; if (simTimeInDays > state.dataWeather->NumDaysInYear) { simTimeInDays = remainder(simTimeInDays, state.dataWeather->NumDaysInYear); diff --git a/src/EnergyPlus/HVACControllers.cc b/src/EnergyPlus/HVACControllers.cc index 18614ac6d3a..c2c2f746336 100644 --- a/src/EnergyPlus/HVACControllers.cc +++ b/src/EnergyPlus/HVACControllers.cc @@ -2473,7 +2473,7 @@ Real64 GetCurrentHVACTime(const EnergyPlusData &state) // as real. Real64 const CurrentHVACTime = (state.dataGlobal->CurrentTime - state.dataGlobal->TimeStepZone) + state.dataHVACGlobal->SysTimeElapsed + state.dataHVACGlobal->TimeStepSys; - return CurrentHVACTime * Constant::SecInHour; + return CurrentHVACTime * Constant::rSecsInHour; } Real64 GetPreviousHVACTime(const EnergyPlusData &state) @@ -2488,7 +2488,7 @@ Real64 GetPreviousHVACTime(const EnergyPlusData &state) // This is the correct formula that does not use MinutesPerSystemTimeStep, which would // erronously truncate all sub-minute system time steps down to the closest full minute. Real64 const PreviousHVACTime = (state.dataGlobal->CurrentTime - state.dataGlobal->TimeStepZone) + state.dataHVACGlobal->SysTimeElapsed; - return PreviousHVACTime * Constant::SecInHour; + return PreviousHVACTime * Constant::rSecsInHour; } std::string CreateHVACTimeString(const EnergyPlusData &state) diff --git a/src/EnergyPlus/HVACControllers.hh b/src/EnergyPlus/HVACControllers.hh index 4798aeee770..39ef6097bcf 100644 --- a/src/EnergyPlus/HVACControllers.hh +++ b/src/EnergyPlus/HVACControllers.hh @@ -367,6 +367,10 @@ struct HVACControllersData : BaseGlobalStruct Array1D_bool MySizeFlag; Array1D_bool MyPlantIndexsFlag; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/HVACCooledBeam.cc b/src/EnergyPlus/HVACCooledBeam.cc index 91bc20a0de9..0c99125b3c7 100644 --- a/src/EnergyPlus/HVACCooledBeam.cc +++ b/src/EnergyPlus/HVACCooledBeam.cc @@ -102,7 +102,6 @@ namespace HVACCooledBeam { // Using/Aliasing using namespace DataLoopNode; - using namespace ScheduleManager; using HVAC::SmallAirVolFlow; using HVAC::SmallLoad; using HVAC::SmallMassFlow; @@ -209,6 +208,7 @@ namespace HVACCooledBeam { // SUBROUTINE PARAMETER DEFINITIONS: static constexpr std::string_view RoutineName("GetCoolBeams "); // include trailing blank space + static constexpr std::string_view routineName = "GetCoolBeams"; int CBIndex; // loop index std::string CurrentModuleObject; // for ease in getting objects @@ -267,6 +267,8 @@ namespace HVACCooledBeam { lAlphaBlanks, cAlphaFields, cNumericFields); + + ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)}; int CBNum = CBIndex; CoolBeam(CBNum).Name = Alphas(1); @@ -282,22 +284,12 @@ namespace HVACCooledBeam { ShowContinueError(state, format("Occurs in {} = {}", CurrentModuleObject, CoolBeam(CBNum).Name)); ErrorsFound = true; } - CoolBeam(CBNum).Sched = Alphas(2); + if (lAlphaBlanks(2)) { - CoolBeam(CBNum).SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - CoolBeam(CBNum).SchedPtr = GetScheduleIndex(state, Alphas(2)); // convert schedule name to pointer - if (CoolBeam(CBNum).SchedPtr == 0) { - ShowSevereError(state, - format("{}{}: invalid {} entered ={} for {}={}", - RoutineName, - CurrentModuleObject, - cAlphaFields(2), - Alphas(2), - cAlphaFields(1), - Alphas(1))); - ErrorsFound = true; - } + CoolBeam(CBNum).availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((CoolBeam(CBNum).availSched = Sched::GetSchedule(state, Alphas(2))) == nullptr) { // convert schedule name to pointer + ShowSevereItemNotFound(state, eoh, cAlphaFields(2), Alphas(2)); + ErrorsFound = true; } CoolBeam(CBNum).AirInNode = GetOnlySingleNode(state, Alphas(4), @@ -607,13 +599,13 @@ namespace HVACCooledBeam { // Do the start of HVAC time step initializations if (FirstHVACIteration) { // check for upstream zero flow. If nonzero and schedule ON, set primary flow to max - if (GetCurrentScheduleValue(state, coolBeam.SchedPtr) > 0.0 && state.dataLoopNodes->Node(InAirNode).MassFlowRate > 0.0) { + if (coolBeam.availSched->getCurrentVal() > 0.0 && state.dataLoopNodes->Node(InAirNode).MassFlowRate > 0.0) { state.dataLoopNodes->Node(InAirNode).MassFlowRate = coolBeam.MaxAirMassFlow; } else { state.dataLoopNodes->Node(InAirNode).MassFlowRate = 0.0; } // reset the max and min avail flows - if (GetCurrentScheduleValue(state, coolBeam.SchedPtr) > 0.0 && state.dataLoopNodes->Node(InAirNode).MassFlowRateMaxAvail > 0.0) { + if (coolBeam.availSched->getCurrentVal() > 0.0 && state.dataLoopNodes->Node(InAirNode).MassFlowRateMaxAvail > 0.0) { state.dataLoopNodes->Node(InAirNode).MassFlowRateMaxAvail = coolBeam.MaxAirMassFlow; state.dataLoopNodes->Node(InAirNode).MassFlowRateMinAvail = coolBeam.MaxAirMassFlow; } else { @@ -932,7 +924,7 @@ namespace HVACCooledBeam { MinColdWaterFlow = 0.0; SetComponentFlowRate(state, MinColdWaterFlow, coolBeam.CWInNode, coolBeam.CWOutNode, coolBeam.CWPlantLoc); - if (GetCurrentScheduleValue(state, coolBeam.SchedPtr) <= 0.0) UnitOn = false; + if (coolBeam.availSched->getCurrentVal() <= 0.0) UnitOn = false; if (MaxColdWaterFlow <= SmallMassFlow) UnitOn = false; // Set the unit's air inlet nodes mass flow rates diff --git a/src/EnergyPlus/HVACCooledBeam.hh b/src/EnergyPlus/HVACCooledBeam.hh index 08835018e67..e12a3c1b475 100644 --- a/src/EnergyPlus/HVACCooledBeam.hh +++ b/src/EnergyPlus/HVACCooledBeam.hh @@ -56,6 +56,7 @@ #include #include #include +#include namespace EnergyPlus { @@ -82,8 +83,7 @@ namespace HVACCooledBeam { int UnitType_Num; // index to type of unit = 1 (there's only 1 type so far) std::string CBTypeString; // type of cooled beam: active | passive CooledBeamType CBType; // index to type of cooled beam - std::string Sched; // availability schedule - int SchedPtr; // index to schedule + Sched::Schedule *availSched = nullptr; // availability schedule Real64 MaxAirVolFlow; // m3/s (autosizable) Real64 MaxAirMassFlow; // kg/s Real64 MaxCoolWaterVolFlow; // m3/s @@ -133,7 +133,7 @@ namespace HVACCooledBeam { // Default Constructor CoolBeamData() - : UnitType_Num(0), CBType(CooledBeamType::Invalid), SchedPtr(0), MaxAirVolFlow(0.0), MaxAirMassFlow(0.0), MaxCoolWaterVolFlow(0.0), + : UnitType_Num(0), CBType(CooledBeamType::Invalid), MaxAirVolFlow(0.0), MaxAirMassFlow(0.0), MaxCoolWaterVolFlow(0.0), MaxCoolWaterMassFlow(0.0), AirInNode(0), AirOutNode(0), CWInNode(0), CWOutNode(0), ADUNum(0), NumBeams(0.0), BeamLength(0.0), DesInletWaterTemp(0.0), DesOutletWaterTemp(0.0), CoilArea(0.0), a(0.0), n1(0.0), n2(0.0), n3(0.0), a0(0.0), K1(0.0), n(0.0), Kin(0.0), InDiam(0.0), TWIn(0.0), TWOut(0.0), EnthWaterOut(0.0), BeamFlow(0.0), CoolWaterMassFlow(0.0), BeamCoolingEnergy(0.0), @@ -195,6 +195,10 @@ struct HVACCooledBeamData : BaseGlobalStruct bool GetInputFlag = true; // First time, input is "gotten" bool ZoneEquipmentListChecked = false; // True after the Zone Equipment List has been checked for items + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/HVACDXHeatPumpSystem.cc b/src/EnergyPlus/HVACDXHeatPumpSystem.cc index a5a2a332cdc..2c028b05760 100644 --- a/src/EnergyPlus/HVACDXHeatPumpSystem.cc +++ b/src/EnergyPlus/HVACDXHeatPumpSystem.cc @@ -94,7 +94,6 @@ namespace HVACDXHeatPumpSystem { // Use statements for data only modules // Using/Aliasing using namespace DataLoopNode; - using namespace ScheduleManager; void SimDXHeatPumpSystem(EnergyPlusData &state, std::string_view DXHeatPumpSystemName, // Name of DXSystem:Airloop object @@ -246,8 +245,6 @@ namespace HVACDXHeatPumpSystem { // METHODOLOGY EMPLOYED: // Uses "Get" routines to read in data. - // REFERENCES: - // Using/Aliasing using BranchNodeConnections::SetUpCompSets; using BranchNodeConnections::TestCompSet; @@ -262,6 +259,7 @@ namespace HVACDXHeatPumpSystem { int NumNums; int IOStat; static constexpr std::string_view RoutineName("GetDXHeatPumpSystemInput: "); // include trailing blank space + static constexpr std::string_view routineName = "GetDXHeatPumpSystemInput"; bool IsNotOK; // Flag to verify name int DXHeatSysNum; std::string CurrentModuleObject; // for ease in getting objects @@ -307,23 +305,16 @@ namespace HVACDXHeatPumpSystem { lAlphaBlanks, cAlphaFields, cNumericFields); + + ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)}; DXHeatPumpSystem(DXHeatSysNum).DXHeatPumpSystemType = CurrentModuleObject; // push Object Name into data array DXHeatPumpSystem(DXHeatSysNum).Name = Alphas(1); + if (lAlphaBlanks(2)) { - DXHeatPumpSystem(DXHeatSysNum).SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - DXHeatPumpSystem(DXHeatSysNum).SchedPtr = GetScheduleIndex(state, Alphas(2)); - if (DXHeatPumpSystem(DXHeatSysNum).SchedPtr == 0) { - ShowSevereError(state, - format("{}{}: invalid {} entered ={} for {}={}", - RoutineName, - CurrentModuleObject, - cAlphaFields(2), - Alphas(2), - cAlphaFields(1), - Alphas(1))); - state.dataHVACDXHeatPumpSys->ErrorsFound = true; - } + DXHeatPumpSystem(DXHeatSysNum).availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((DXHeatPumpSystem(DXHeatSysNum).availSched = Sched::GetSchedule(state, Alphas(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(2), Alphas(2)); + state.dataHVACDXHeatPumpSys->ErrorsFound = true; } if (Util::SameString(Alphas(3), "Coil:Heating:DX:SingleSpeed")) { @@ -549,7 +540,6 @@ namespace HVACDXHeatPumpSystem { // Data is moved from the System data structure to the System outlet nodes. // Using/Aliasing - using namespace ScheduleManager; using DXCoils::SimDXCoil; using HVAC::TempControlTol; @@ -626,7 +616,7 @@ namespace HVACDXHeatPumpSystem { } // If DXHeatingSystem is scheduled on and there is flow - if ((GetCurrentScheduleValue(state, DXHeatPumpSystem.SchedPtr) > 0.0) && + if ((DXHeatPumpSystem.availSched->getCurrentVal() > 0.0) && (state.dataLoopNodes->Node(InletNode).MassFlowRate > MinAirMassFlow)) { // Determine if there is a sensible load on this system diff --git a/src/EnergyPlus/HVACDXHeatPumpSystem.hh b/src/EnergyPlus/HVACDXHeatPumpSystem.hh index d2ef78c3304..0e627c29725 100644 --- a/src/EnergyPlus/HVACDXHeatPumpSystem.hh +++ b/src/EnergyPlus/HVACDXHeatPumpSystem.hh @@ -73,7 +73,7 @@ namespace HVACDXHeatPumpSystem { // Members std::string DXHeatPumpSystemType; // Type of DXHeatingSystem std::string Name; // Name of the DXHeatingSystem - int SchedPtr; + Sched::Schedule *availSched = nullptr; std::string HeatPumpCoilType; int HeatPumpCoilType_Num; std::string HeatPumpCoilName; @@ -103,7 +103,7 @@ namespace HVACDXHeatPumpSystem { // Default Constructor DXHeatPumpSystemStruct() - : SchedPtr(0), HeatPumpCoilType_Num(0), HeatPumpCoilIndex(0), DXHeatPumpCoilInletNodeNum(0), DXHeatPumpCoilOutletNodeNum(0), + : HeatPumpCoilType_Num(0), HeatPumpCoilIndex(0), DXHeatPumpCoilInletNodeNum(0), DXHeatPumpCoilOutletNodeNum(0), DXSystemControlNodeNum(0), DesiredOutletTemp(0.0), PartLoadFrac(0.0), SpeedRatio(0.0), CycRatio(0.0), DXCoilSensPLRIter(0), DXCoilSensPLRIterIndex(0), DXCoilSensPLRFail(0), DXCoilSensPLRFailIndex(0), OAUnitSetTemp(0.0), SpeedNum(0), FaultyCoilSATFlag(false), FaultyCoilSATIndex(0), FaultyCoilSATOffset(0.0) @@ -197,6 +197,10 @@ struct HVACDXHeatPumpSystemData : BaseGlobalStruct Real64 AirFlowOnOffRatio = 1.0; // ratio of compressor on flow to average flow over time step Real64 SpeedPartLoadRatio = 1.0; // SpeedRatio varies between 1.0 (higher speed) and 0.0 (lower speed) + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/HVACDuct.hh b/src/EnergyPlus/HVACDuct.hh index 4e0aa3ae80b..1cf896d4ac6 100644 --- a/src/EnergyPlus/HVACDuct.hh +++ b/src/EnergyPlus/HVACDuct.hh @@ -118,6 +118,10 @@ struct HVACDuctData : BaseGlobalStruct Array1D Duct; bool GetInputFlag = true; // First time, input is "gotten" + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/HVACFourPipeBeam.cc b/src/EnergyPlus/HVACFourPipeBeam.cc index d2359453977..3be6b4a3710 100644 --- a/src/EnergyPlus/HVACFourPipeBeam.cc +++ b/src/EnergyPlus/HVACFourPipeBeam.cc @@ -96,7 +96,6 @@ namespace FourPipeBeam { using NodeInputManager::GetOnlySingleNode; using namespace DataSizing; using Curve::GetCurveIndex; - using ScheduleManager::GetScheduleIndex; static constexpr std::string_view routineName("FourPipeBeamFactory "); // include trailing blank space int beamIndex; // loop index @@ -137,6 +136,8 @@ namespace FourPipeBeam { ErrorsFound = true; } + ErrorObjectHeader eoh{routineName, cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1)}; + errFlag = false; GlobalNames::VerifyUniqueADUName(state, cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1), errFlag, cCurrentModuleObject + " Name"); if (errFlag) { @@ -146,52 +147,23 @@ namespace FourPipeBeam { thisBeam->unitType = cCurrentModuleObject; if (state.dataIPShortCut->lAlphaFieldBlanks(2)) { - thisBeam->airAvailSchedNum = ScheduleManager::ScheduleAlwaysOn; - } else { - thisBeam->airAvailSchedNum = GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(2)); // convert schedule name to pointer - if (thisBeam->airAvailSchedNum == 0) { - ShowSevereError(state, - format("{}{}: invalid {} entered ={} for {}={}", - routineName, - cCurrentModuleObject, - state.dataIPShortCut->cAlphaFieldNames(2), - state.dataIPShortCut->cAlphaArgs(2), - state.dataIPShortCut->cAlphaFieldNames(1), - state.dataIPShortCut->cAlphaArgs(1))); - ErrorsFound = true; - } + thisBeam->airAvailSched = Sched::GetScheduleAlwaysOn(state); + } else if ((thisBeam->airAvailSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(2), state.dataIPShortCut->cAlphaArgs(2)); + ErrorsFound = true; } + if (state.dataIPShortCut->lAlphaFieldBlanks(3)) { - thisBeam->coolingAvailSchedNum = ScheduleManager::ScheduleAlwaysOn; - } else { - thisBeam->coolingAvailSchedNum = GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(3)); // convert schedule name to index - if (thisBeam->coolingAvailSchedNum == 0) { - ShowSevereError(state, - format("{}{}: invalid {} entered ={} for {}={}", - routineName, - cCurrentModuleObject, - state.dataIPShortCut->cAlphaFieldNames(3), - state.dataIPShortCut->cAlphaArgs(3), - state.dataIPShortCut->cAlphaFieldNames(1), - state.dataIPShortCut->cAlphaArgs(1))); - ErrorsFound = true; - } + thisBeam->coolingAvailSched = Sched::GetScheduleAlwaysOn(state); + } else if ((thisBeam->coolingAvailSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(3))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(3), state.dataIPShortCut->cAlphaArgs(3)); + ErrorsFound = true; } if (state.dataIPShortCut->lAlphaFieldBlanks(4)) { - thisBeam->heatingAvailSchedNum = ScheduleManager::ScheduleAlwaysOn; - } else { - thisBeam->heatingAvailSchedNum = GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(4)); // convert schedule name to index - if (thisBeam->heatingAvailSchedNum == 0) { - ShowSevereError(state, - format("{}{}: invalid {} entered ={} for {}={}", - routineName, - cCurrentModuleObject, - state.dataIPShortCut->cAlphaFieldNames(4), - state.dataIPShortCut->cAlphaArgs(4), - state.dataIPShortCut->cAlphaFieldNames(1), - state.dataIPShortCut->cAlphaArgs(1))); - ErrorsFound = true; - } + thisBeam->heatingAvailSched = Sched::GetScheduleAlwaysOn(state); + } else if ((thisBeam->heatingAvailSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(4))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(4), state.dataIPShortCut->cAlphaArgs(4)); + ErrorsFound = true; } thisBeam->airInNodeNum = GetOnlySingleNode(state, @@ -576,7 +548,6 @@ namespace FourPipeBeam { using PlantUtilities::InitComponentNodes; using PlantUtilities::ScanPlantLoopsForObject; using PlantUtilities::SetComponentFlowRate; - using ScheduleManager::GetCurrentScheduleValue; static constexpr std::string_view routineName("HVACFourPipeBeam::init"); @@ -674,21 +645,10 @@ namespace FourPipeBeam { // Do the start of HVAC time step initializations if (FirstHVACIteration) { // check availability schedules and set flags - if (GetCurrentScheduleValue(state, this->airAvailSchedNum) > 0.0) { - this->airAvailable = true; - } else { - this->airAvailable = false; - } - if (this->airAvailable && beamCoolingPresent && (GetCurrentScheduleValue(state, this->coolingAvailSchedNum) > 0.0)) { - this->coolingAvailable = true; - } else { - this->coolingAvailable = false; - } - if (this->airAvailable && beamHeatingPresent && (GetCurrentScheduleValue(state, this->heatingAvailSchedNum) > 0.0)) { - this->heatingAvailable = true; - } else { - this->heatingAvailable = false; - } + this->airAvailable = (this->airAvailSched->getCurrentVal() > 0.0); + this->coolingAvailable = (this->airAvailable && beamCoolingPresent && (this->coolingAvailSched->getCurrentVal() > 0.0)); + this->heatingAvailable = (this->airAvailable && beamHeatingPresent && (this->heatingAvailSched->getCurrentVal() > 0.0)); + // check for upstream zero flow. If nonzero and air available, set primary flow to max if (this->airAvailable && state.dataLoopNodes->Node(this->airInNodeNum).MassFlowRate > 0.0) { state.dataLoopNodes->Node(this->airInNodeNum).MassFlowRate = this->mDotDesignPrimAir; diff --git a/src/EnergyPlus/HVACFourPipeBeam.hh b/src/EnergyPlus/HVACFourPipeBeam.hh index f6d4d4e5732..4b467158aa8 100644 --- a/src/EnergyPlus/HVACFourPipeBeam.hh +++ b/src/EnergyPlus/HVACFourPipeBeam.hh @@ -73,7 +73,7 @@ namespace FourPipeBeam { private: // Creation // Default Constructor HVACFourPipeBeam() - : coolingAvailSchedNum(0), coolingAvailable(false), heatingAvailSchedNum(0), heatingAvailable(false), totBeamLength(0.0), + : coolingAvailable(false), heatingAvailable(false), totBeamLength(0.0), totBeamLengthWasAutosized(false), vDotNormRatedPrimAir(0.0), mDotNormRatedPrimAir(0.0), beamCoolingPresent(false), vDotDesignCW(0.0), vDotDesignCWWasAutosized(false), mDotDesignCW(0.0), qDotNormRatedCooling(0.0), deltaTempRatedCooling(0.0), vDotNormRatedCW(0.0), mDotNormRatedCW(0.0), modCoolingQdotDeltaTFuncNum(0), modCoolingQdotAirFlowFuncNum(0), modCoolingQdotCWFlowFuncNum(0), mDotCW(0.0), @@ -137,9 +137,9 @@ namespace FourPipeBeam { void CalcOutdoorAirVolumeFlowRate(EnergyPlusData &state); private: // data - int coolingAvailSchedNum; // index to schedule for cooling availability + Sched::Schedule *coolingAvailSched = nullptr; // schedule for cooling availability bool coolingAvailable; // true if beam cooling is available - int heatingAvailSchedNum; // index to schedule for heating availability + Sched::Schedule *heatingAvailSched = nullptr; // schedule for heating availability bool heatingAvailable; // true if beam heating is available Real64 totBeamLength; // length of all the beams in the zone (autosizable) (m) @@ -228,6 +228,10 @@ struct FourPipeBeamData : BaseGlobalStruct ///// Note use of shared_ptr here is not a good pattern, not to be replicated without further discussion. Array1D> FourPipeBeams; // dimension to number of machines + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/HVACHXAssistedCoolingCoil.hh b/src/EnergyPlus/HVACHXAssistedCoolingCoil.hh index a24688310fe..024627417d4 100644 --- a/src/EnergyPlus/HVACHXAssistedCoolingCoil.hh +++ b/src/EnergyPlus/HVACHXAssistedCoolingCoil.hh @@ -248,6 +248,10 @@ struct HVACHXAssistedCoolingCoilData : BaseGlobalStruct int ErrCount = 0; int ErrCount2 = 0; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/HVACInterfaceManager.hh b/src/EnergyPlus/HVACInterfaceManager.hh index aa0a15cbe38..da2a4117fee 100644 --- a/src/EnergyPlus/HVACInterfaceManager.hh +++ b/src/EnergyPlus/HVACInterfaceManager.hh @@ -158,6 +158,10 @@ struct HVACInterfaceManagerData : BaseGlobalStruct Array1D PlantCommonPipe; Array1D TmpRealARR = Array1D(DataConvergParams::ConvergLogStackDepth); // Tuned Made static + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/HVACManager.cc b/src/EnergyPlus/HVACManager.cc index 8bc8708c0ed..431d1b43fc8 100644 --- a/src/EnergyPlus/HVACManager.cc +++ b/src/EnergyPlus/HVACManager.cc @@ -152,6 +152,8 @@ void ManageHVAC(EnergyPlusData &state) Real64 PriorTimeStep; // magnitude of time step for previous history terms Real64 ZoneTempChange(0.0); // change in zone air temperature from timestep t-1 to t + auto &s_hbfs = state.dataHeatBalFanSys; + // SYSTEM INITIALIZATION if (state.dataHVACMgr->TriggerGetAFN) { state.dataHVACMgr->TriggerGetAFN = false; @@ -171,17 +173,18 @@ void ManageHVAC(EnergyPlusData &state) thisSpaceHB.ZTAV = 0.0; thisSpaceHB.airHumRatAvg = 0.0; } - state.dataHeatBalFanSys->ZoneThermostatSetPointHiAver = 0.0; - state.dataHeatBalFanSys->ZoneThermostatSetPointLoAver = 0.0; + + for (auto &zoneTstatSetpt : s_hbfs->zoneTstatSetpts) { + zoneTstatSetpt.setptHiAver = zoneTstatSetpt.setptLoAver = 0.0; + } + state.dataHVACMgr->PrintedWarmup = false; if (state.dataContaminantBalance->Contaminant.CO2Simulation) { - state.dataContaminantBalance->OutdoorCO2 = - ScheduleManager::GetCurrentScheduleValue(state, state.dataContaminantBalance->Contaminant.CO2OutdoorSchedPtr); + state.dataContaminantBalance->OutdoorCO2 = state.dataContaminantBalance->Contaminant.CO2OutdoorSched->getCurrentVal(); state.dataContaminantBalance->ZoneAirCO2Avg = 0.0; } if (state.dataContaminantBalance->Contaminant.GenericContamSimulation) { - state.dataContaminantBalance->OutdoorGC = - ScheduleManager::GetCurrentScheduleValue(state, state.dataContaminantBalance->Contaminant.GenericContamOutdoorSchedPtr); + state.dataContaminantBalance->OutdoorGC = state.dataContaminantBalance->Contaminant.genericOutdoorSched->getCurrentVal(); if (allocated(state.dataContaminantBalance->ZoneAirGCAvg)) state.dataContaminantBalance->ZoneAirGCAvg = 0.0; } @@ -199,7 +202,7 @@ void ManageHVAC(EnergyPlusData &state) state.dataHVACGlobal->SysTimeElapsed = 0.0; state.dataHVACGlobal->TimeStepSys = state.dataGlobal->TimeStepZone; - state.dataHVACGlobal->TimeStepSysSec = state.dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state.dataHVACGlobal->TimeStepSysSec = state.dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; state.dataHVACGlobal->FirstTimeStepSysFlag = true; state.dataHVACGlobal->ShortenTimeStepSys = false; state.dataHVACGlobal->UseZoneTimeStepHistory = true; @@ -306,7 +309,7 @@ void ManageHVAC(EnergyPlusData &state) state.dataHVACGlobal->TimeStepSys = state.dataGlobal->TimeStepZone / state.dataHVACGlobal->NumOfSysTimeSteps; } state.dataHVACGlobal->TimeStepSys = max(state.dataHVACGlobal->TimeStepSys, state.dataConvergeParams->MinTimeStepSys); - state.dataHVACGlobal->TimeStepSysSec = state.dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state.dataHVACGlobal->TimeStepSysSec = state.dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; state.dataHVACGlobal->UseZoneTimeStepHistory = false; state.dataHVACGlobal->ShortenTimeStepSys = true; @@ -404,10 +407,9 @@ void ManageHVAC(EnergyPlusData &state) state.dataContaminantBalance->ZoneAirGCAvg(ZoneNum) += state.dataContaminantBalance->ZoneAirGC(ZoneNum) * state.dataHVACGlobal->FracTimeStepZone; if (state.dataZoneTempPredictorCorrector->NumOnOffCtrZone > 0) { - state.dataHeatBalFanSys->ZoneThermostatSetPointHiAver(ZoneNum) += - state.dataHeatBalFanSys->ZoneThermostatSetPointHi(ZoneNum) * state.dataHVACGlobal->FracTimeStepZone; - state.dataHeatBalFanSys->ZoneThermostatSetPointLoAver(ZoneNum) += - state.dataHeatBalFanSys->ZoneThermostatSetPointLo(ZoneNum) * state.dataHVACGlobal->FracTimeStepZone; + auto &zoneTstatSetpt = s_hbfs->zoneTstatSetpts(ZoneNum); + zoneTstatSetpt.setptHiAver += zoneTstatSetpt.setptHi * state.dataHVACGlobal->FracTimeStepZone; + zoneTstatSetpt.setptLoAver += zoneTstatSetpt.setptLo * state.dataHVACGlobal->FracTimeStepZone; } } @@ -2742,19 +2744,12 @@ void SetHeatToReturnAirFlag(EnergyPlusData &state) for (int AirLoopNum = 1; AirLoopNum <= NumPrimaryAirSys; ++AirLoopNum) { auto &airLoopControlInfo = state.dataAirLoop->AirLoopControlInfo(AirLoopNum); - if (airLoopControlInfo.UnitarySys) { // for unitary systems check the cycling fan schedule - if (airLoopControlInfo.CycFanSchedPtr > 0) { - Real64 CycFanMaxVal = ScheduleManager::GetScheduleMaxValue(state, airLoopControlInfo.CycFanSchedPtr); - if (CycFanMaxVal > 0.0) { - airLoopControlInfo.AnyContFan = true; - } else { - airLoopControlInfo.AnyContFan = false; - } - } else { // no schedule means always cycling fan - airLoopControlInfo.AnyContFan = false; - } - } else { // for nonunitary (central) all systems are continuous fan + if (!airLoopControlInfo.UnitarySys) { // for nonunitary (central) all systems are continuous fan airLoopControlInfo.AnyContFan = true; + } else if (airLoopControlInfo.cycFanSched != nullptr) { // for unitary systems check the cycling fan schedule + airLoopControlInfo.AnyContFan = (airLoopControlInfo.cycFanSched->getMaxVal(state) > 0.0); + } else { // no schedule means always cycling fan + airLoopControlInfo.AnyContFan = false; } } // check to see if a controlled zone is served exclusively by a zonal system @@ -2779,9 +2774,8 @@ void SetHeatToReturnAirFlag(EnergyPlusData &state) for (int zoneInNode = 1; zoneInNode <= zoneEquipConfig.NumInletNodes; ++zoneInNode) { int AirLoopNum = zoneEquipConfig.InletNodeAirLoopNum(zoneInNode); if (AirLoopNum > 0) { - if (state.dataAirLoop->AirLoopControlInfo(AirLoopNum).CycFanSchedPtr > 0) { - CyclingFan = - ScheduleManager::CheckScheduleValue(state, state.dataAirLoop->AirLoopControlInfo(AirLoopNum).CycFanSchedPtr, 0.0); + if (state.dataAirLoop->AirLoopControlInfo(AirLoopNum).cycFanSched != nullptr) { + CyclingFan = state.dataAirLoop->AirLoopControlInfo(AirLoopNum).cycFanSched->hasVal(state, 0.0); } } } @@ -2820,12 +2814,8 @@ void SetHeatToReturnAirFlag(EnergyPlusData &state) // set the air loop fan operation mode for (int AirLoopNum = 1; AirLoopNum <= NumPrimaryAirSys; ++AirLoopNum) { auto &airLoopControlInfo = state.dataAirLoop->AirLoopControlInfo(AirLoopNum); - if (airLoopControlInfo.CycFanSchedPtr > 0) { - if (ScheduleManager::GetCurrentScheduleValue(state, airLoopControlInfo.CycFanSchedPtr) == 0.0) { - airLoopControlInfo.fanOp = HVAC::FanOp::Cycling; - } else { - airLoopControlInfo.fanOp = HVAC::FanOp::Continuous; - } + if (airLoopControlInfo.cycFanSched != nullptr) { + airLoopControlInfo.fanOp = (airLoopControlInfo.cycFanSched->getCurrentVal() == 0.0) ? HVAC::FanOp::Cycling : HVAC::FanOp::Continuous; } } // set the zone level NoHeatToReturnAir flag diff --git a/src/EnergyPlus/HVACManager.hh b/src/EnergyPlus/HVACManager.hh index 89d35831ceb..93590a8ba6d 100644 --- a/src/EnergyPlus/HVACManager.hh +++ b/src/EnergyPlus/HVACManager.hh @@ -143,6 +143,10 @@ struct HVACManagerData : BaseGlobalStruct Array1D MixSenLoad; // Mixing sensible loss or gain Array1D MixLatLoad; // Mixing latent loss or gain + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/HVACMultiSpeedHeatPump.cc b/src/EnergyPlus/HVACMultiSpeedHeatPump.cc index ea4fc8c7ee4..e082ac9f7df 100644 --- a/src/EnergyPlus/HVACMultiSpeedHeatPump.cc +++ b/src/EnergyPlus/HVACMultiSpeedHeatPump.cc @@ -547,16 +547,10 @@ namespace HVACMultiSpeedHeatPump { ErrorObjectHeader eoh{routineName, state.dataHVACMultiSpdHP->CurrentModuleObject, thisMSHP.Name}; if (lAlphaBlanks(2)) { - thisMSHP.AvaiSchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - thisMSHP.AvaiSchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(2)); - if (thisMSHP.AvaiSchedPtr == 0) { - ShowSevereError( - state, - format( - "{}, \"{}\" {} not found: {}", state.dataHVACMultiSpdHP->CurrentModuleObject, thisMSHP.Name, cAlphaFields(2), Alphas(2))); - ErrorsFound = true; - } + thisMSHP.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((thisMSHP.availSched = Sched::GetSchedule(state, Alphas(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(2), Alphas(2)); + ErrorsFound = true; } thisMSHP.AirInletNodeName = Alphas(3); @@ -680,24 +674,15 @@ namespace HVACMultiSpeedHeatPump { thisMSHP.fanPlace = static_cast(getEnumValue(HVAC::fanPlaceNamesUC, Alphas(8))); assert(thisMSHP.fanPlace != HVAC::FanPlace::Invalid); - thisMSHP.FanSchedule = Alphas(9); - thisMSHP.FanSchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(9)); - if (thisMSHP.FanSchedPtr == 0) { - ShowSevereError( - state, - format("{}, \"{}\" {} not found: {}", state.dataHVACMultiSpdHP->CurrentModuleObject, thisMSHP.Name, cAlphaFields(9), Alphas(9))); + if ((thisMSHP.fanOpModeSched = Sched::GetSchedule(state, Alphas(9))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(9), Alphas(9)); ErrorsFound = true; } - if (thisMSHP.FanSchedPtr > 0 && thisMSHP.fanType == HVAC::FanType::Constant) { - if (!ScheduleManager::CheckScheduleValueMinMax(state, thisMSHP.FanSchedPtr, ">", 0.0, "<=", 1.0)) { - ShowSevereError(state, format("{} \"{}\"", state.dataHVACMultiSpdHP->CurrentModuleObject, thisMSHP.Name)); - ShowContinueError(state, - format("{} must be continuous (fan operating mode schedule values > 0) for {} = Fan:ConstantVolume.", - cAlphaFields(9), - cAlphaFields(6))); - ShowContinueError(state, format("Error found in {} = {}", cAlphaFields(9), Alphas(9))); - ShowContinueError(state, "schedule values must be (>0., <=1.)"); + if (thisMSHP.fanOpModeSched != nullptr && thisMSHP.fanType == HVAC::FanType::Constant) { + if (!thisMSHP.fanOpModeSched->checkMinMaxVals(state, Clusive::Ex, 0.0, Clusive::In, 1.0)) { + Sched::ShowSevereBadMinMax(state, eoh, cAlphaFields(9), Alphas(9), Clusive::Ex, 0.0, Clusive::In, 1.0, + "Fan mode must be continuous (schedule values > 0) for Fan:ConstantVolume."); ErrorsFound = true; } } @@ -1961,7 +1946,7 @@ namespace HVACMultiSpeedHeatPump { MSHeatPump(MSHeatPumpNum).FlowFraction = 1.0; MSHeatPump(MSHeatPumpNum).MySizeFlag = false; // Pass the fan cycling schedule index up to the air loop. Set the air loop unitary system flag. - state.dataAirLoop->AirLoopControlInfo(AirLoopNum).CycFanSchedPtr = MSHeatPump(MSHeatPumpNum).FanSchedPtr; + state.dataAirLoop->AirLoopControlInfo(AirLoopNum).cycFanSched = MSHeatPump(MSHeatPumpNum).fanOpModeSched; state.dataAirLoop->AirLoopControlInfo(AirLoopNum).UnitarySys = true; state.dataAirLoop->AirLoopControlInfo(AirLoopNum).UnitarySysSimulating = false; // affects child coil sizing by allowing coil to size itself instead of parent telling coil what size to use @@ -2283,12 +2268,9 @@ namespace HVACMultiSpeedHeatPump { } } - if (MSHeatPump(MSHeatPumpNum).FanSchedPtr > 0) { - if (ScheduleManager::GetCurrentScheduleValue(state, MSHeatPump(MSHeatPumpNum).FanSchedPtr) == 0.0) { - MSHeatPump(MSHeatPumpNum).fanOp = HVAC::FanOp::Cycling; - } else { - MSHeatPump(MSHeatPumpNum).fanOp = HVAC::FanOp::Continuous; - } + if (MSHeatPump(MSHeatPumpNum).fanOpModeSched != nullptr) { + MSHeatPump(MSHeatPumpNum).fanOp = (MSHeatPump(MSHeatPumpNum).fanOpModeSched->getCurrentVal() == 0.0) ? + HVAC::FanOp::Cycling : HVAC::FanOp::Continuous; } // Calcuate air distribution losses @@ -2406,8 +2388,7 @@ namespace HVACMultiSpeedHeatPump { } // Set the inlet node mass flow rate - if (ScheduleManager::GetCurrentScheduleValue(state, MSHeatPump(MSHeatPumpNum).AvaiSchedPtr) > 0.0 && - state.dataHVACMultiSpdHP->CompOnMassFlow != 0.0) { + if (MSHeatPump(MSHeatPumpNum).availSched->getCurrentVal() > 0.0 && state.dataHVACMultiSpdHP->CompOnMassFlow != 0.0) { OnOffAirFlowRatio = 1.0; if (FirstHVACIteration) { state.dataLoopNodes->Node(MSHeatPump(MSHeatPumpNum).AirInletNodeNum).MassFlowRate = state.dataHVACMultiSpdHP->CompOnMassFlow; @@ -2428,10 +2409,9 @@ namespace HVACMultiSpeedHeatPump { } // Check availability of DX coils - if (ScheduleManager::GetCurrentScheduleValue(state, MSHeatPump(MSHeatPumpNum).AvaiSchedPtr) > 0.0) { - int CoilAvailSchPtr; // DX coil availability schedule pointer + if (MSHeatPump(MSHeatPumpNum).availSched->getCurrentVal() > 0.0) { if (MSHeatPump(MSHeatPumpNum).HeatCoolMode == ModeOfOperation::CoolingMode) { - CoilAvailSchPtr = DXCoils::GetDXCoilAvailSchPtr( // TODO: Why isn't this stored on the struct? + auto *coilAvailSched = DXCoils::GetDXCoilAvailSched( // TODO: Why isn't this stored on the struct? state, "Coil:Cooling:DX:MultiSpeed", MSHeatPump(MSHeatPumpNum).DXCoolCoilName, @@ -2440,7 +2420,7 @@ namespace HVACMultiSpeedHeatPump { if (ErrorsFound) { ShowFatalError(state, "InitMSHeatPump, The previous error causes termination."); } - if (ScheduleManager::GetCurrentScheduleValue(state, CoilAvailSchPtr) == 0.0) { + if (coilAvailSched->getCurrentVal() == 0.0) { if (MSHeatPump(MSHeatPumpNum).CoolCountAvail == 0) { ++MSHeatPump(MSHeatPumpNum).CoolCountAvail; ShowWarningError( @@ -2448,22 +2428,21 @@ namespace HVACMultiSpeedHeatPump { format("{} is ready to perform cooling, but its DX cooling coil = {} is not available at Available Schedule = {}.", MSHeatPump(MSHeatPumpNum).Name, MSHeatPump(MSHeatPumpNum).DXCoolCoilName, - ScheduleManager::GetScheduleName(state, CoilAvailSchPtr))); - ShowContinueErrorTimeStamp( - state, format("Availability schedule returned={:.1R}", ScheduleManager::GetCurrentScheduleValue(state, CoilAvailSchPtr))); + coilAvailSched->Name)); + ShowContinueErrorTimeStamp(state, format("Availability schedule returned={:.1R}", coilAvailSched->getCurrentVal())); } else { ++MSHeatPump(MSHeatPumpNum).CoolCountAvail; ShowRecurringWarningErrorAtEnd(state, MSHeatPump(MSHeatPumpNum).Name + ": Cooling coil is still not available ...", MSHeatPump(MSHeatPumpNum).CoolIndexAvail, - ScheduleManager::GetCurrentScheduleValue(state, CoilAvailSchPtr), - ScheduleManager::GetCurrentScheduleValue(state, CoilAvailSchPtr)); + coilAvailSched->getCurrentVal(), + coilAvailSched->getCurrentVal()); } } } if (MSHeatPump(MSHeatPumpNum).HeatCoolMode == ModeOfOperation::HeatingMode && MSHeatPump(MSHeatPumpNum).HeatCoilType == MultiSpeedHeatingCoil) { - CoilAvailSchPtr = DXCoils::GetDXCoilAvailSchPtr(state, + auto *coilAvailSched = DXCoils::GetDXCoilAvailSched(state, "Coil:Heating:DX:MultiSpeed", MSHeatPump(MSHeatPumpNum).DXHeatCoilName, ErrorsFound, @@ -2471,7 +2450,7 @@ namespace HVACMultiSpeedHeatPump { if (ErrorsFound) { ShowFatalError(state, "InitMSHeatPump, The previous error causes termination."); } - if (ScheduleManager::GetCurrentScheduleValue(state, CoilAvailSchPtr) == 0.0) { + if (coilAvailSched->getCurrentVal() == 0.0) { if (MSHeatPump(MSHeatPumpNum).HeatCountAvail == 0) { ++MSHeatPump(MSHeatPumpNum).HeatCountAvail; ShowWarningError( @@ -2479,16 +2458,16 @@ namespace HVACMultiSpeedHeatPump { format("{} is ready to perform heating, but its DX heating coil = {} is not available at Available Schedule = {}.", MSHeatPump(MSHeatPumpNum).Name, MSHeatPump(MSHeatPumpNum).DXCoolCoilName, - ScheduleManager::GetScheduleName(state, CoilAvailSchPtr))); + coilAvailSched->Name)); ShowContinueErrorTimeStamp( - state, format("Availability schedule returned={:.1R}", ScheduleManager::GetCurrentScheduleValue(state, CoilAvailSchPtr))); + state, format("Availability schedule returned={:.1R}", coilAvailSched->getCurrentVal())); } else { ++MSHeatPump(MSHeatPumpNum).HeatCountAvail; ShowRecurringWarningErrorAtEnd(state, MSHeatPump(MSHeatPumpNum).Name + ": Heating coil is still not available ...", MSHeatPump(MSHeatPumpNum).HeatIndexAvail, - ScheduleManager::GetCurrentScheduleValue(state, CoilAvailSchPtr), - ScheduleManager::GetCurrentScheduleValue(state, CoilAvailSchPtr)); + coilAvailSched->getCurrentVal(), + coilAvailSched->getCurrentVal()); } } } @@ -2521,7 +2500,7 @@ namespace HVACMultiSpeedHeatPump { } // If unit is scheduled OFF, setpoint is equal to inlet node temperature. //!!LKL Discrepancy with < 0 - if (ScheduleManager::GetCurrentScheduleValue(state, MSHeatPump(MSHeatPumpNum).AvaiSchedPtr) == 0.0) { + if (MSHeatPump(MSHeatPumpNum).availSched->getCurrentVal() == 0.0) { state.dataLoopNodes->Node(OutNode).Temp = state.dataLoopNodes->Node(InNode).Temp; return; } @@ -3026,7 +3005,7 @@ namespace HVACMultiSpeedHeatPump { auto &MSHeatPump = state.dataHVACMultiSpdHP->MSHeatPump(MSHeatPumpNum); //!!LKL Discrepancy with < 0 - if (ScheduleManager::GetCurrentScheduleValue(state, MSHeatPump.AvaiSchedPtr) == 0.0) return; + if (MSHeatPump.availSched->getCurrentVal() == 0.0) return; // Get result when DX coil is off CalcMSHeatPump(state, @@ -4085,7 +4064,7 @@ namespace HVACMultiSpeedHeatPump { } //!!LKL Discrepancy with > 0 - if (ScheduleManager::GetCurrentScheduleValue(state, state.dataHVACMultiSpdHP->MSHeatPump(MSHeatPumpNum).AvaiSchedPtr) == 0.0) { + if (state.dataHVACMultiSpdHP->MSHeatPump(MSHeatPumpNum).availSched->getCurrentVal() == 0.0) { state.dataLoopNodes->Node(InletNode).MassFlowRate = 0.0; OnOffAirFlowRatio = 0.0; } else { diff --git a/src/EnergyPlus/HVACMultiSpeedHeatPump.hh b/src/EnergyPlus/HVACMultiSpeedHeatPump.hh index 975d4e91fb6..9c3448d8411 100644 --- a/src/EnergyPlus/HVACMultiSpeedHeatPump.hh +++ b/src/EnergyPlus/HVACMultiSpeedHeatPump.hh @@ -98,8 +98,7 @@ namespace HVACMultiSpeedHeatPump { // Members // Some variables in this type are arrays (dimension=MaxSpeed) to support the number of speeds std::string Name; // Name of the engine driven heat pump - std::string AvaiSchedule; // Availability Schedule name - int AvaiSchedPtr; // Pointer to the correct schedule + Sched::Schedule *availSched = nullptr; // availability schedule int AirInletNodeNum; // Node number of the heat pump air inlet int AirOutletNodeNum; // Node number of the heat pump air inlet std::string AirInletNodeName; // Node name of the heat pump air inlet @@ -117,8 +116,7 @@ namespace HVACMultiSpeedHeatPump { int FanInletNode; // Fan Inlet node int FanOutletNode; // Fan Outlet node Real64 FanVolFlow; // Supply fan volumetric flow rate - std::string FanSchedule; // Supply air fan operating mode schedule name - int FanSchedPtr; // Pointer to the Supply air fan operating mode schedule + Sched::Schedule *fanOpModeSched = nullptr; // Supply air fan operating mode schedule HVAC::FanOp fanOp = HVAC::FanOp::Invalid; // mode of operation; 1=cycling fan, cycling compressor; 2=continuous fan, cycling compresor std::string DXHeatCoilName; // COIL:DX:MultiSpeed:Heating name int HeatCoilType; // Heating coil type: 1 COIL:DX:MultiSpeed:Heating only @@ -223,9 +221,9 @@ namespace HVACMultiSpeedHeatPump { // Default Constructor MSHeatPumpData() - : AvaiSchedPtr(0), AirInletNodeNum(0), AirOutletNodeNum(0), ControlZoneNum(0), ZoneSequenceCoolingNum(0), ZoneSequenceHeatingNum(0), + : AirInletNodeNum(0), AirOutletNodeNum(0), ControlZoneNum(0), ZoneSequenceCoolingNum(0), ZoneSequenceHeatingNum(0), NodeNumOfControlledZone(0), FlowFraction(0.0), fanType(HVAC::FanType::Invalid), FanNum(0), fanPlace(HVAC::FanPlace::Invalid), - FanInletNode(0), FanOutletNode(0), FanVolFlow(0.0), FanSchedPtr(0), HeatCoilType(0), HeatCoilNum(0), DXHeatCoilIndex(0), + FanInletNode(0), FanOutletNode(0), FanVolFlow(0.0), HeatCoilType(0), HeatCoilNum(0), DXHeatCoilIndex(0), HeatCoilIndex(0), CoolCoilType(0), DXCoolCoilIndex(0), SuppHeatCoilType(0), SuppHeatCoilNum(0), DesignSuppHeatingCapacity(0.0), SuppMaxAirTemp(0.0), SuppMaxOATemp(0.0), AuxOnCyclePower(0.0), AuxOffCyclePower(0.0), DesignHeatRecFlowRate(0.0), HeatRecActive(false), HeatRecInletNodeNum(0), HeatRecOutletNodeNum(0), MaxHeatRecOutletTemp(0.0), DesignHeatRecMassFlowRate(0.0), HRPlantLoc{}, @@ -418,6 +416,10 @@ struct HVACMultiSpeedHeatPumpData : BaseGlobalStruct std::string HeatCoilName; // TODO: What's the best plan here? + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/HVACSingleDuctInduc.cc b/src/EnergyPlus/HVACSingleDuctInduc.cc index 5d1ece65db0..4b180009ce6 100644 --- a/src/EnergyPlus/HVACSingleDuctInduc.cc +++ b/src/EnergyPlus/HVACSingleDuctInduc.cc @@ -197,6 +197,7 @@ namespace HVACSingleDuctInduc { // SUBROUTINE PARAMETER DEFINITIONS: static constexpr std::string_view RoutineName("GetIndUnits "); // include trailing blank space + static constexpr std::string_view routineName = "GetIndUnits"; Array1D_string Alphas; // Alpha input items for object Array1D_string cAlphaFields; // Alpha field names @@ -244,29 +245,20 @@ namespace HVACSingleDuctInduc { cAlphaFields, cNumericFields); + ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)}; + int IUNum = IUIndex; Util::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound); state.dataHVACSingleDuctInduc->IndUnit(IUNum).Name = Alphas(1); state.dataHVACSingleDuctInduc->IndUnit(IUNum).UnitType = CurrentModuleObject; state.dataHVACSingleDuctInduc->IndUnit(IUNum).UnitType_Num = SingleDuct_CV::FourPipeInduc; - state.dataHVACSingleDuctInduc->IndUnit(IUNum).Sched = Alphas(2); + if (lAlphaBlanks(2)) { - state.dataHVACSingleDuctInduc->IndUnit(IUNum).SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - state.dataHVACSingleDuctInduc->IndUnit(IUNum).SchedPtr = - ScheduleManager::GetScheduleIndex(state, Alphas(2)); // convert schedule name to pointer - if (state.dataHVACSingleDuctInduc->IndUnit(IUNum).SchedPtr == 0) { - ShowSevereError(state, - format("{}{}: invalid {} entered ={} for {}={}", - RoutineName, - CurrentModuleObject, - cAlphaFields(2), - Alphas(2), - cAlphaFields(1), - Alphas(1))); - ErrorsFound = true; - } + state.dataHVACSingleDuctInduc->IndUnit(IUNum).availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((state.dataHVACSingleDuctInduc->IndUnit(IUNum).availSched = Sched::GetSchedule(state, Alphas(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(2), Alphas(2)); + ErrorsFound = true; } state.dataHVACSingleDuctInduc->IndUnit(IUNum).MaxTotAirVolFlow = Numbers(1); state.dataHVACSingleDuctInduc->IndUnit(IUNum).InducRatio = Numbers(2); @@ -674,7 +666,7 @@ namespace HVACSingleDuctInduc { // Do the start of HVAC time step initializations if (FirstHVACIteration) { // check for upstream zero flow. If nonzero and schedule ON, set primary flow to max - if (ScheduleManager::GetCurrentScheduleValue(state, state.dataHVACSingleDuctInduc->IndUnit(IUNum).SchedPtr) > 0.0 && + if (state.dataHVACSingleDuctInduc->IndUnit(IUNum).availSched->getCurrentVal() > 0.0 && state.dataLoopNodes->Node(PriNode).MassFlowRate > 0.0) { if (Util::SameString(state.dataHVACSingleDuctInduc->IndUnit(IUNum).UnitType, "AirTerminal:SingleDuct:ConstantVolume:FourPipeInduction")) { @@ -686,7 +678,7 @@ namespace HVACSingleDuctInduc { state.dataLoopNodes->Node(SecNode).MassFlowRate = 0.0; } // reset the max and min avail flows - if (ScheduleManager::GetCurrentScheduleValue(state, state.dataHVACSingleDuctInduc->IndUnit(IUNum).SchedPtr) > 0.0 && + if (state.dataHVACSingleDuctInduc->IndUnit(IUNum).availSched->getCurrentVal() > 0.0 && state.dataLoopNodes->Node(PriNode).MassFlowRateMaxAvail > 0.0) { if (Util::SameString(state.dataHVACSingleDuctInduc->IndUnit(IUNum).UnitType, "AirTerminal:SingleDuct:ConstantVolume:FourPipeInduction")) { @@ -1151,7 +1143,7 @@ namespace HVACSingleDuctInduc { PlantUtilities::SetComponentFlowRate( state, MinColdWaterFlow, ColdControlNode, CWOutletNode, state.dataHVACSingleDuctInduc->IndUnit(IUNum).CWPlantLoc); - if (ScheduleManager::GetCurrentScheduleValue(state, state.dataHVACSingleDuctInduc->IndUnit(IUNum).SchedPtr) <= 0.0) UnitOn = false; + if (state.dataHVACSingleDuctInduc->IndUnit(IUNum).availSched->getCurrentVal() <= 0.0) UnitOn = false; if (PriAirMassFlow <= HVAC::SmallMassFlow) UnitOn = false; // Set the unit's air inlet nodes mass flow rates diff --git a/src/EnergyPlus/HVACSingleDuctInduc.hh b/src/EnergyPlus/HVACSingleDuctInduc.hh index a57ed44349d..de98d8601d9 100644 --- a/src/EnergyPlus/HVACSingleDuctInduc.hh +++ b/src/EnergyPlus/HVACSingleDuctInduc.hh @@ -79,8 +79,7 @@ namespace HVACSingleDuctInduc { std::string Name; // name of unit std::string UnitType; // type of unit SingleDuct_CV UnitType_Num; // index to type of unit - std::string Sched; // availability schedule - int SchedPtr; // index to schedule + Sched::Schedule *availSched = nullptr; // index to schedule Real64 MaxTotAirVolFlow; // m3/s (autosizable) Real64 MaxTotAirMassFlow; // kg/s Real64 InducRatio; // ratio of induced air flow to primary air flow @@ -127,7 +126,7 @@ namespace HVACSingleDuctInduc { // Default Constructor IndUnitData() - : UnitType_Num(SingleDuct_CV::Invalid), SchedPtr(0), MaxTotAirVolFlow(0.0), MaxTotAirMassFlow(0.0), InducRatio(2.5), PriAirInNode(0), + : UnitType_Num(SingleDuct_CV::Invalid), MaxTotAirVolFlow(0.0), MaxTotAirMassFlow(0.0), InducRatio(2.5), PriAirInNode(0), SecAirInNode(0), OutAirNode(0), HWControlNode(0), CWControlNode(0), HCoil_Num(0), HeatingCoilType(DataPlant::PlantEquipmentType::Invalid), MaxVolHotWaterFlow(0.0), MaxHotWaterFlow(0.0), MinVolHotWaterFlow(0.0), MinHotWaterFlow(0.0), HotControlOffset(0.0), HWPlantLoc{}, HWCoilFailNum1(0), HWCoilFailNum2(0), CCoil_Num(0), @@ -193,6 +192,10 @@ struct HVACSingleDuctInducData : BaseGlobalStruct Array1D IndUnit; bool ZoneEquipmentListChecked = false; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/HVACSizingSimulationManager.cc b/src/EnergyPlus/HVACSizingSimulationManager.cc index 9dd268ccea2..83d48d71856 100644 --- a/src/EnergyPlus/HVACSizingSimulationManager.cc +++ b/src/EnergyPlus/HVACSizingSimulationManager.cc @@ -299,7 +299,7 @@ void ManageHVACSizingSimulation(EnergyPlusData &state, bool &ErrorsFound) state.dataGlobal->BeginHourFlag = true; state.dataGlobal->EndHourFlag = false; - for (state.dataGlobal->TimeStep = 1; state.dataGlobal->TimeStep <= state.dataGlobal->NumOfTimeStepInHour; + for (state.dataGlobal->TimeStep = 1; state.dataGlobal->TimeStep <= state.dataGlobal->TimeStepsInHour; ++state.dataGlobal->TimeStep) { if (state.dataGlobal->AnySlabsInModel || state.dataGlobal->AnyBasementsInModel) { PlantPipingSystemsManager::SimulateGroundDomains(state, false); @@ -314,7 +314,7 @@ void ManageHVACSizingSimulation(EnergyPlusData &state, bool &ErrorsFound) // Note also that BeginTimeStepFlag, EndTimeStepFlag, and the // SubTimeStepFlags can/will be set/reset in the HVAC Manager. - if (state.dataGlobal->TimeStep == state.dataGlobal->NumOfTimeStepInHour) { + if (state.dataGlobal->TimeStep == state.dataGlobal->TimeStepsInHour) { state.dataGlobal->EndHourFlag = true; if (state.dataGlobal->HourOfDay == 24) { state.dataGlobal->EndDayFlag = true; diff --git a/src/EnergyPlus/HVACSizingSimulationManager.hh b/src/EnergyPlus/HVACSizingSimulationManager.hh index 7498901cde4..41a80ba9fb2 100644 --- a/src/EnergyPlus/HVACSizingSimulationManager.hh +++ b/src/EnergyPlus/HVACSizingSimulationManager.hh @@ -106,6 +106,10 @@ void ManageHVACSizingSimulation(EnergyPlusData &state, bool &ErrorsFound); struct HVACSizingSimMgrData : BaseGlobalStruct { std::unique_ptr hvacSizingSimulationManager; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/HVACStandAloneERV.cc b/src/EnergyPlus/HVACStandAloneERV.cc index a606bccb8c8..93055f4d992 100644 --- a/src/EnergyPlus/HVACStandAloneERV.cc +++ b/src/EnergyPlus/HVACStandAloneERV.cc @@ -250,13 +250,10 @@ void GetStandAloneERV(EnergyPlusData &state) ErrorObjectHeader eoh{routineName, CurrentModuleObject, standAloneERV.Name}; if (lAlphaBlanks(2)) { - standAloneERV.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - standAloneERV.SchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(2)); // convert schedule name to pointer - if (standAloneERV.SchedPtr == 0) { - ShowSevereError(state, format("{}, \"{}\" {} not found = {}", CurrentModuleObject, standAloneERV.Name, cAlphaFields(2), Alphas(2))); - ErrorsFound = true; - } + standAloneERV.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((standAloneERV.availSched = Sched::GetSchedule(state, Alphas(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(2), Alphas(2)); + ErrorsFound = true; } GlobalNames::IntraObjUniquenessCheck( @@ -287,7 +284,7 @@ void GetStandAloneERV(EnergyPlusData &state) } else { auto *fan = state.dataFans->fans(standAloneERV.SupplyAirFanIndex); standAloneERV.supplyAirFanType = fan->type; - standAloneERV.SupplyAirFanSchPtr = fan->availSchedNum; + standAloneERV.supplyAirFanSched = fan->availSched; standAloneERV.DesignSAFanVolFlowRate = fan->maxAirFlowRate; standAloneERV.SupplyAirOutletNode = fan->outletNodeNum; } @@ -304,7 +301,7 @@ void GetStandAloneERV(EnergyPlusData &state) auto *fan = state.dataFans->fans(standAloneERV.ExhaustAirFanIndex); standAloneERV.exhaustAirFanType = fan->type; - standAloneERV.ExhaustAirFanSchPtr = fan->availSchedNum; + standAloneERV.exhaustAirFanSched = fan->availSched; standAloneERV.DesignEAFanVolFlowRate = fan->maxAirFlowRate; standAloneERV.ExhaustAirOutletNode = fan->outletNodeNum; } @@ -862,10 +859,10 @@ void GetStandAloneERV(EnergyPlusData &state) } // Check for a time of day outside air schedule - thisOAController.EconomizerOASchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(5)); + thisOAController.economizerOASched = Sched::GetSchedule(state, Alphas(5)); if (WhichERV != 0) { - state.dataHVACStandAloneERV->StandAloneERV(WhichERV).EconomizerOASchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(5)); + state.dataHVACStandAloneERV->StandAloneERV(WhichERV).economizerOASched = Sched::GetSchedule(state, Alphas(5)); // Compare the ERV SA fan flow rates to modified air flow rate. if (HighRHOARatio > 1.0 && state.dataHVACStandAloneERV->StandAloneERV(WhichERV).SupplyAirVolFlow != DataSizing::AutoSize && @@ -1150,7 +1147,7 @@ void InitStandAloneERV(EnergyPlusData &state, auto &exhInNode = state.dataLoopNodes->Node(ExhInNode); // Set the inlet node mass flow rate - if (ScheduleManager::GetCurrentScheduleValue(state, state.dataHVACStandAloneERV->StandAloneERV(StandAloneERVNum).SchedPtr) > 0.0) { + if (state.dataHVACStandAloneERV->StandAloneERV(StandAloneERVNum).availSched->getCurrentVal() > 0.0) { // IF optional ControllerName is defined SimOAController ONLY to set economizer and Modifyairflow flags if (state.dataHVACStandAloneERV->StandAloneERV(StandAloneERVNum).ControllerNameDefined) { @@ -1163,7 +1160,7 @@ void InitStandAloneERV(EnergyPlusData &state, 0); } - if (ScheduleManager::GetCurrentScheduleValue(state, state.dataHVACStandAloneERV->StandAloneERV(StandAloneERVNum).SupplyAirFanSchPtr) > 0 || + if (state.dataHVACStandAloneERV->StandAloneERV(StandAloneERVNum).supplyAirFanSched->getCurrentVal() > 0 || (state.dataHVACGlobal->TurnFansOn && !state.dataHVACGlobal->TurnFansOff)) { if (state.dataHVACStandAloneERV->StandAloneERV(StandAloneERVNum).ControllerNameDefined) { if (state.dataMixedAir->OAController(state.dataHVACStandAloneERV->StandAloneERV(StandAloneERVNum).ControllerIndex) @@ -1185,7 +1182,7 @@ void InitStandAloneERV(EnergyPlusData &state, supInNode.MassFlowRateMaxAvail = supInNode.MassFlowRate; supInNode.MassFlowRateMinAvail = supInNode.MassFlowRate; - if (ScheduleManager::GetCurrentScheduleValue(state, state.dataHVACStandAloneERV->StandAloneERV(StandAloneERVNum).ExhaustAirFanSchPtr) > 0) { + if (state.dataHVACStandAloneERV->StandAloneERV(StandAloneERVNum).exhaustAirFanSched->getCurrentVal() > 0) { if (state.dataHVACStandAloneERV->StandAloneERV(StandAloneERVNum).ControllerNameDefined) { if (state.dataMixedAir->OAController(state.dataHVACStandAloneERV->StandAloneERV(StandAloneERVNum).ControllerIndex) .HighHumCtrlActive) { @@ -1259,8 +1256,7 @@ void SizeStandAloneERV(EnergyPlusData &state, int const StandAloneERVNum) Real64 MaxPeopleSch = 0.0; for (int PeopleNum = 1; PeopleNum <= state.dataHeatBal->TotPeople; ++PeopleNum) { if (ZoneNum != state.dataHeatBal->People(PeopleNum).ZonePtr) continue; - int PeopleSchPtr = state.dataHeatBal->People(PeopleNum).NumberOfPeoplePtr; - MaxPeopleSch = ScheduleManager::GetScheduleMaxValue(state, PeopleSchPtr); + MaxPeopleSch = state.dataHeatBal->People(PeopleNum).numberOfPeopleSched->getMaxVal(state); NumberOfPeople = NumberOfPeople + (state.dataHeatBal->People(PeopleNum).NumberOfPeople * MaxPeopleSch); } SupplyAirVolFlowDes = FloorArea * state.dataHVACStandAloneERV->StandAloneERV(StandAloneERVNum).AirVolFlowPerFloorArea + diff --git a/src/EnergyPlus/HVACStandAloneERV.hh b/src/EnergyPlus/HVACStandAloneERV.hh index 382cbea51bb..2da97e94d0c 100644 --- a/src/EnergyPlus/HVACStandAloneERV.hh +++ b/src/EnergyPlus/HVACStandAloneERV.hh @@ -72,7 +72,7 @@ namespace HVACStandAloneERV { // input data std::string Name; // name of the stand alone ERV unit std::string UnitType; // ZoneHVAC:EnergyRecoveryVentilator - int SchedPtr; // pointer to availability schedule + Sched::Schedule *availSched = nullptr; // availability schedule std::string HeatExchangerName; // name of the heat exchanger within the ERV unit int HeatExchangerIndex; // Pointer to heat exchanger HVAC::HXType hxType = HVAC::HXType::Invalid; // Parameter equivalent of HX object type @@ -80,13 +80,13 @@ namespace HVACStandAloneERV { int SupplyAirOutletNode; // supply air outlet node for the stand alone ERV std::string SupplyAirFanName; // fan name in the supply air stream of the ERV int SupplyAirFanIndex; // index to supply air fan - int SupplyAirFanSchPtr; // index to supply air fan schedule + Sched::Schedule *supplyAirFanSched = nullptr; // supply air fan schedule HVAC::FanType supplyAirFanType; // parameter equivalent of fan type int ExhaustAirInletNode; // exhaust air inlet node for the stand alone ERV int ExhaustAirOutletNode; // exhaust air outlet node for the stand alone ERV std::string ExhaustAirFanName; // fan name in exhaust air stream of the ERV int ExhaustAirFanIndex; // index to exhaust air fan - int ExhaustAirFanSchPtr; // index to exhaust air fan schedule + Sched::Schedule *exhaustAirFanSched = nullptr; // exhaust air fan schedule HVAC::FanType exhaustAirFanType; // paramter equivalent of fan type Real64 SupplyAirVolFlow; // volumetric flow rate through the supply side of the ERV Real64 ExhaustAirVolFlow; // volumetric flow rate through the exhaust side of the ERV @@ -104,7 +104,7 @@ namespace HVACStandAloneERV { Real64 DesignEAFanMassFlowRate; // EA fan mass flow rate Real64 AirVolFlowPerFloorArea; // Air flow rate per unit floor area, used for autosizing Real64 AirVolFlowPerOccupant; // Air flow rate per occupant, used for autosizing - int EconomizerOASchedPtr; // schedule to modify outdoor air + Sched::Schedule *economizerOASched = nullptr; // schedule to modify outdoor air bool FlowError; // used for one-time warning message for flow imbalance (Init) Avail::Status availStatus = Avail::Status::NoAction; std::string AvailManagerListName; // Name of an availability manager list object @@ -127,13 +127,13 @@ namespace HVACStandAloneERV { // Default Constructor StandAloneERVData() - : SchedPtr(0), HeatExchangerIndex(0), SupplyAirInletNode(0), SupplyAirOutletNode(0), SupplyAirFanIndex(0), SupplyAirFanSchPtr(0), + : HeatExchangerIndex(0), SupplyAirInletNode(0), SupplyAirOutletNode(0), SupplyAirFanIndex(0), supplyAirFanType(HVAC::FanType::Invalid), ExhaustAirInletNode(0), ExhaustAirOutletNode(0), ExhaustAirFanIndex(0), - ExhaustAirFanSchPtr(0), exhaustAirFanType(HVAC::FanType::Invalid), SupplyAirVolFlow(0.0), ExhaustAirVolFlow(0.0), + exhaustAirFanType(HVAC::FanType::Invalid), SupplyAirVolFlow(0.0), ExhaustAirVolFlow(0.0), ControllerNameDefined(false), ControlledZoneNum(0), ControllerIndex(0), MaxSupAirMassFlow(0.0), MaxExhAirMassFlow(0.0), HighRHOAFlowRatio(1.0), DesignSAFanVolFlowRate(0.0), DesignEAFanVolFlowRate(0.0), DesignHXVolFlowRate(0.0), DesignSAFanMassFlowRate(0.0), DesignEAFanMassFlowRate(0.0), AirVolFlowPerFloorArea(0.0), AirVolFlowPerOccupant(0.0), - EconomizerOASchedPtr(0), FlowError(true), ElecUseRate(0.0), ElecUseEnergy(0.0), SensCoolingEnergy(0.0), SensCoolingRate(0.0), + FlowError(true), ElecUseRate(0.0), ElecUseEnergy(0.0), SensCoolingEnergy(0.0), SensCoolingRate(0.0), LatCoolingEnergy(0.0), LatCoolingRate(0.0), TotCoolingEnergy(0.0), TotCoolingRate(0.0), SensHeatingEnergy(0.0), SensHeatingRate(0.0), LatHeatingEnergy(0.0), LatHeatingRate(0.0), TotHeatingEnergy(0.0), TotHeatingRate(0.0), FirstPass(true) { @@ -208,6 +208,10 @@ struct HVACStandAloneERVData : BaseGlobalStruct Array1D_bool MyZoneEqFlag; // used to set up zone equipment availability managers bool ZoneEquipmentListChecked = false; // True after the Zone Equipment List has been checked for items + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/HVACSystemRootFindingAlgorithm.hh b/src/EnergyPlus/HVACSystemRootFindingAlgorithm.hh index 6138bacc004..f6732795e89 100644 --- a/src/EnergyPlus/HVACSystemRootFindingAlgorithm.hh +++ b/src/EnergyPlus/HVACSystemRootFindingAlgorithm.hh @@ -70,6 +70,10 @@ struct HVACSystemRootFindingAlgorithm struct RootFindingData : BaseGlobalStruct { HVACSystemRootFindingAlgorithm HVACSystemRootFinding; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/HVACUnitaryBypassVAV.cc b/src/EnergyPlus/HVACUnitaryBypassVAV.cc index 29014cd42a6..f27673a6189 100644 --- a/src/EnergyPlus/HVACUnitaryBypassVAV.cc +++ b/src/EnergyPlus/HVACUnitaryBypassVAV.cc @@ -372,16 +372,11 @@ namespace HVACUnitaryBypassVAV { ErrorObjectHeader eoh{routineName, CurrentModuleObject, thisCBVAV.Name}; thisCBVAV.UnitType = CurrentModuleObject; - thisCBVAV.Sched = Alphas(2); if (lAlphaBlanks(2)) { - thisCBVAV.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - thisCBVAV.SchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(2)); // convert schedule name to pointer (index number) - if (thisCBVAV.SchedPtr == 0) { - ShowSevereError(state, format("{} {} not found = {}", CurrentModuleObject, cAlphaFields(2), Alphas(2))); - ShowContinueError(state, format("Occurs in {} = {}", CurrentModuleObject, thisCBVAV.Name)); - ErrorsFound = true; - } + thisCBVAV.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((thisCBVAV.availSched = Sched::GetSchedule(state, Alphas(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(2), Alphas(2)); + ErrorsFound = true; } thisCBVAV.MaxCoolAirVolFlow = Numbers(1); @@ -432,11 +427,10 @@ namespace HVACUnitaryBypassVAV { ErrorsFound = true; } - thisCBVAV.OutAirSchPtr = ScheduleManager::GetScheduleIndex(state, Alphas(3)); // convert schedule name to pointer (index number) - if (thisCBVAV.OutAirSchPtr != 0) { - if (!ScheduleManager::CheckScheduleValueMinMax(state, thisCBVAV.OutAirSchPtr, ">=", 0.0, "<=", 1.0)) { - ShowSevereError(state, format("{}: {}", CurrentModuleObject, thisCBVAV.Name)); - ShowContinueError(state, format("The schedule values in {} must be 0 to 1.", cAlphaFields(3))); + thisCBVAV.outAirSched = Sched::GetSchedule(state, Alphas(3)); + if (thisCBVAV.outAirSched != nullptr) { + if (!thisCBVAV.outAirSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) { + Sched::ShowSevereBadMinMax(state, eoh, cAlphaFields(3), Alphas(3), Clusive::In, 0.0, Clusive::In, 1.0); ErrorsFound = true; } } @@ -773,27 +767,21 @@ namespace HVACUnitaryBypassVAV { } } - thisCBVAV.FanOpModeSchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(13)); // convert schedule name to pointer (index number) - if (thisCBVAV.FanOpModeSchedPtr != 0) { - if (!ScheduleManager::CheckScheduleValueMinMax(state, thisCBVAV.FanOpModeSchedPtr, ">=", 0.0, "<=", 1.0)) { - ShowSevereError(state, format("{}: {}", CurrentModuleObject, thisCBVAV.Name)); - ShowContinueError(state, format("The schedule values in {} must be 0 to 1.", cAlphaFields(13))); + thisCBVAV.fanOpModeSched = Sched::GetSchedule(state, Alphas(13)); + if (thisCBVAV.fanOpModeSched != nullptr) { + if (!thisCBVAV.fanOpModeSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) { + Sched::ShowSevereBadMinMax(state, eoh, cAlphaFields(13), Alphas(13), Clusive::In, 0.0, Clusive::In, 1.0); ShowContinueError(state, "A value of 0 represents cycling fan mode, any other value up to 1 represents constant fan mode."); ErrorsFound = true; } // Check supply air fan operating mode for cycling fan, if NOT cycling fan set AirFlowControl - if (!ScheduleManager::CheckScheduleValueMinMax( - state, thisCBVAV.FanOpModeSchedPtr, ">=", 0.0, "<=", 0.0)) { // Autodesk:Note Range is 0 to 0? + if (!thisCBVAV.fanOpModeSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 0.0)) { // Autodesk:Note Range is 0 to 0? // set air flow control mode, // UseCompressorOnFlow = operate at last cooling or heating air flow requested when compressor is off // UseCompressorOffFlow = operate at value specified by user (no input for this object type, UseCompONFlow) // AirFlowControl only valid if fan opmode = HVAC::FanOp::Continuous - if (thisCBVAV.MaxNoCoolHeatAirVolFlow == 0.0) { - thisCBVAV.AirFlowControl = AirFlowCtrlMode::UseCompressorOnFlow; - } else { - thisCBVAV.AirFlowControl = AirFlowCtrlMode::UseCompressorOffFlow; - } + thisCBVAV.AirFlowControl = (thisCBVAV.MaxNoCoolHeatAirVolFlow == 0.0) ? AirFlowCtrlMode::UseCompressorOnFlow : AirFlowCtrlMode::UseCompressorOffFlow; } } else { @@ -1427,7 +1415,7 @@ namespace HVACUnitaryBypassVAV { if (!state.dataGlobal->SysSizingCalc && state.dataHVACUnitaryBypassVAV->MySizeFlag(CBVAVNum)) { SizeCBVAV(state, CBVAVNum); // Pass the fan cycling schedule index up to the air loop. Set the air loop unitary system flag. - state.dataAirLoop->AirLoopControlInfo(AirLoopNum).CycFanSchedPtr = cBVAV.FanOpModeSchedPtr; + state.dataAirLoop->AirLoopControlInfo(AirLoopNum).cycFanSched = cBVAV.fanOpModeSched; // Set UnitarySys flag to FALSE and let the heating coil autosize independently of the cooling coil state.dataAirLoop->AirLoopControlInfo(AirLoopNum).UnitarySys = false; state.dataAirLoop->AirLoopControlInfo(AirLoopNum).fanOp = cBVAV.fanOp; @@ -1635,23 +1623,15 @@ namespace HVACUnitaryBypassVAV { } } - if (cBVAV.FanOpModeSchedPtr > 0) { - if (ScheduleManager::GetCurrentScheduleValue(state, cBVAV.FanOpModeSchedPtr) == 0.0) { - cBVAV.fanOp = HVAC::FanOp::Cycling; - } else { - cBVAV.fanOp = HVAC::FanOp::Continuous; - } + if (cBVAV.fanOpModeSched != nullptr) { + cBVAV.fanOp = (cBVAV.fanOpModeSched->getCurrentVal() == 0.0) ? HVAC::FanOp::Cycling : HVAC::FanOp::Continuous; } // Returns load only for zones requesting cooling (heating). If in deadband, Qzoneload = 0. if (FirstHVACIteration) cBVAV.modeChanged = false; GetZoneLoads(state, CBVAVNum); - if (cBVAV.OutAirSchPtr > 0) { - OutsideAirMultiplier = ScheduleManager::GetCurrentScheduleValue(state, cBVAV.OutAirSchPtr); - } else { - OutsideAirMultiplier = 1.0; - } + OutsideAirMultiplier = (cBVAV.outAirSched != nullptr) ? cBVAV.outAirSched->getCurrentVal() : 1.0; // Set the inlet node mass flow rate if (cBVAV.fanOp == HVAC::FanOp::Continuous) { @@ -1741,7 +1721,7 @@ namespace HVACUnitaryBypassVAV { } // Set the inlet node mass flow rate - if (ScheduleManager::GetCurrentScheduleValue(state, cBVAV.SchedPtr) > 0.0 && state.dataHVACUnitaryBypassVAV->CompOnMassFlow != 0.0) { + if (cBVAV.availSched->getCurrentVal() > 0.0 && state.dataHVACUnitaryBypassVAV->CompOnMassFlow != 0.0) { OnOffAirFlowRatio = 1.0; if (FirstHVACIteration) { state.dataLoopNodes->Node(cBVAV.AirInNode).MassFlowRate = state.dataHVACUnitaryBypassVAV->CompOnMassFlow; @@ -1782,7 +1762,7 @@ namespace HVACUnitaryBypassVAV { 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.SchedPtr) == 0.0) { + if (cBVAV.availSched->getCurrentVal() == 0.0) { cBVAV.OutletTempSetPoint = state.dataLoopNodes->Node(InNode).Temp; return; } @@ -2029,7 +2009,7 @@ namespace HVACUnitaryBypassVAV { auto &cBVAV = state.dataHVACUnitaryBypassVAV->CBVAV(CBVAVNum); - if (ScheduleManager::GetCurrentScheduleValue(state, cBVAV.SchedPtr) == 0.0) return; + if (cBVAV.availSched->getCurrentVal() == 0.0) return; // Get operating result PartLoadFrac = 1.0; @@ -3756,7 +3736,7 @@ namespace HVACUnitaryBypassVAV { state.dataLoopNodes->Node(MixerMixedAirNode).MassFlowRateMin = 0.0; - if (ScheduleManager::GetCurrentScheduleValue(state, cBVAV.SchedPtr) == 0.0 || AverageUnitMassFlow == 0.0) { + if (cBVAV.availSched->getCurrentVal() == 0.0 || AverageUnitMassFlow == 0.0) { state.dataLoopNodes->Node(InletNode).MassFlowRate = 0.0; state.dataLoopNodes->Node(MixerOutsideAirNode).MassFlowRate = 0.0; state.dataLoopNodes->Node(MixerReliefAirNode).MassFlowRate = 0.0; diff --git a/src/EnergyPlus/HVACUnitaryBypassVAV.hh b/src/EnergyPlus/HVACUnitaryBypassVAV.hh index fb359ee33b7..9ec2d88c0e3 100644 --- a/src/EnergyPlus/HVACUnitaryBypassVAV.hh +++ b/src/EnergyPlus/HVACUnitaryBypassVAV.hh @@ -108,8 +108,8 @@ namespace HVACUnitaryBypassVAV { { std::string Name; // Name of unit std::string UnitType; // Type of unit - std::string Sched; // Availability schedule name - int SchedPtr = 0; // Index number to availability schedule + std::string availSchedName; // Availability schedule name + Sched::Schedule *availSched = nullptr; // availability schedule Real64 MaxCoolAirVolFlow = 0.0; // System air volumetric flow rate during cooling operation [m3/s] Real64 MaxHeatAirVolFlow = 0.0; // System air volumetric flow rate during heating operation [m3/s] Real64 MaxNoCoolHeatAirVolFlow = 0.0; // System air volumetric flow rate when no cooling or heating [m3/s] @@ -122,7 +122,7 @@ namespace HVACUnitaryBypassVAV { Real64 CoolOutAirMassFlow = 0.0; // OA mass flow rate during cooling operation [kg/s] Real64 HeatOutAirMassFlow = 0.0; // OA mass flow rate during heating operation [kg/s] Real64 NoCoolHeatOutAirMassFlow = 0.0; // OA mass flow rate when no cooling or heating [kg/s] - int OutAirSchPtr = 0; // Index number to outside air multiplier schedule + Sched::Schedule *outAirSched = nullptr; // outside air multiplier schedule int AirInNode = 0; // Inlet air node number for CBVAV unit int AirOutNode = 0; // Outlet air node number for CBVAV unit int CondenserNodeNum = 0; // DX Coil condenser air inlet node number @@ -139,7 +139,7 @@ namespace HVACUnitaryBypassVAV { HVAC::FanType fanType = HVAC::FanType::Invalid; HVAC::FanPlace fanPlace = HVAC::FanPlace::Invalid; // Fan placement is either blowthru (1) or drawthru (2) int FanIndex = 0; // Index number to fan - int FanOpModeSchedPtr = 0; // Fan operating mode schedule pointer + Sched::Schedule *fanOpModeSched = nullptr; // Fan operating mode schedule Real64 FanVolFlow = 0.0; // Volumetric flow rate of system supply air fan [m3/s] Real64 HeatingSpeedRatio = 1.0; // Fan speed ratio in heating mode Real64 CoolingSpeedRatio = 1.0; // Fan speed ratio in cooling mode @@ -343,6 +343,10 @@ struct HVACUnitaryBypassVAVData : BaseGlobalStruct Array1D_bool MySizeFlag; // Used for sizing CBVAV inputs one time Array1D_bool MyPlantScanFlag; // Used for initializations plant component for heating coils + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/HVACVariableRefrigerantFlow.cc b/src/EnergyPlus/HVACVariableRefrigerantFlow.cc index 6bb48f857f3..68bde23e49a 100644 --- a/src/EnergyPlus/HVACVariableRefrigerantFlow.cc +++ b/src/EnergyPlus/HVACVariableRefrigerantFlow.cc @@ -131,9 +131,9 @@ void SimulateVRF(EnergyPlusData &state, int &CompIndex, bool &HeatingActive, bool &CoolingActive, - int const OAUnitNum, // If the system is an equipment of OutdoorAirUnit - Real64 const OAUCoilOutTemp, // the coil inlet temperature of OutdoorAirUnit - bool const ZoneEquipment, // TRUE if called as zone equipment + [[maybe_unused]] int const OAUnitNum, // If the system is an equipment of OutdoorAirUnit + [[maybe_unused]] Real64 const OAUCoilOutTemp, // the coil inlet temperature of OutdoorAirUnit + [[maybe_unused]] bool const ZoneEquipment, // TRUE if called as zone equipment Real64 &SysOutputProvided, Real64 &LatOutputProvided) { @@ -1226,7 +1226,7 @@ void CalcVRFCondenser(EnergyPlusData &state, int const VRFCond) if (vrf.CondenserType == DataHeatBalance::RefrigCondenserType::Evap) { // Calculate basin heater power - CalcBasinHeaterPower(state, vrf.BasinHeaterPowerFTempDiff, vrf.BasinHeaterSchedulePtr, vrf.BasinHeaterSetPointTemp, vrf.BasinHeaterPower); + CalcBasinHeaterPower(state, vrf.BasinHeaterPowerFTempDiff, vrf.basinHeaterSched, vrf.BasinHeaterSetPointTemp, vrf.BasinHeaterPower); vrf.BasinHeaterPower *= (1.0 - VRFRTF); // calculate evaporative condenser pump power and water consumption @@ -1382,7 +1382,6 @@ void GetVRFInputData(EnergyPlusData &state, bool &ErrorsFound) using DataSizing::AutoSize; using DXCoils::GetCoilCondenserInletNode; using DXCoils::GetCoilTypeNum; - using DXCoils::GetDXCoilAvailSchPtr; using DXCoils::GetDXCoilCapFTCurveIndex; using DXCoils::GetDXCoilName; using DXCoils::RatedInletAirTempHeat; @@ -1394,8 +1393,6 @@ void GetVRFInputData(EnergyPlusData &state, bool &ErrorsFound) using MixedAir::GetOAMixerNodeNumbers; using NodeInputManager::GetOnlySingleNode; using OutAirNodeManager::CheckOutAirNodeNumber; - using ScheduleManager::CheckScheduleValueMinMax; - using ScheduleManager::GetScheduleIndex; using SingleDuct::GetATMixer; using WaterManager::SetupTankDemandComponent; using WaterManager::SetupTankSupplyComponent; @@ -1545,8 +1542,8 @@ void GetVRFInputData(EnergyPlusData &state, bool &ErrorsFound) thisTUList.HRCoolRequest.allocate(thisTUList.NumTUInList); thisTUList.CoolingCoilAvailable.allocate(thisTUList.NumTUInList); thisTUList.HeatingCoilAvailable.allocate(thisTUList.NumTUInList); - thisTUList.CoolingCoilAvailSchPtr.allocate(thisTUList.NumTUInList); - thisTUList.HeatingCoilAvailSchPtr.allocate(thisTUList.NumTUInList); + thisTUList.coolingCoilAvailScheds.allocate(thisTUList.NumTUInList); + thisTUList.heatingCoilAvailScheds.allocate(thisTUList.NumTUInList); thisTUList.ZoneTUPtr = 0; thisTUList.IsSimulated = false; thisTUList.TotalCoolLoad = 0.0; @@ -1558,8 +1555,8 @@ void GetVRFInputData(EnergyPlusData &state, bool &ErrorsFound) thisTUList.HRCoolRequest = false; thisTUList.CoolingCoilAvailable = false; thisTUList.HeatingCoilAvailable = false; - thisTUList.CoolingCoilAvailSchPtr = -1; - thisTUList.HeatingCoilAvailSchPtr = -1; + thisTUList.coolingCoilAvailScheds = nullptr; + thisTUList.heatingCoilAvailScheds = nullptr; for (int TUNum = 1; TUNum <= thisTUList.NumTUInList; ++TUNum) { thisTUList.ZoneTUName(TUNum) = cAlphaArgs(TUNum + 1); @@ -1602,6 +1599,8 @@ void GetVRFInputData(EnergyPlusData &state, bool &ErrorsFound) lAlphaFieldBlanks, cAlphaFieldNames, cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, cCurrentModuleObject, cAlphaArgs(1)}; GlobalNames::VerifyUniqueInterObjectName( state, state.dataHVACVarRefFlow->VrfUniqueNames, cAlphaArgs(1), cCurrentModuleObject, cAlphaFieldNames(1), ErrorsFound); @@ -1609,15 +1608,12 @@ void GetVRFInputData(EnergyPlusData &state, bool &ErrorsFound) thisVrfSys.Name = cAlphaArgs(1); thisVrfSys.VRFSystemTypeNum = VRF_HeatPump; thisVrfSys.VRFAlgorithmType = AlgorithmType::SysCurve; + if (lAlphaFieldBlanks(2)) { - thisVrfSys.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - thisVrfSys.SchedPtr = GetScheduleIndex(state, cAlphaArgs(2)); - if (thisVrfSys.SchedPtr == 0) { - ShowSevereError(state, format("{}=\"{}\" invalid data", cCurrentModuleObject, thisVrfSys.Name)); - ShowContinueError(state, format("Invalid-not found {}=\"{}\".", cAlphaFieldNames(2), cAlphaArgs(2))); - ErrorsFound = true; - } + thisVrfSys.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((thisVrfSys.availSched = Sched::GetSchedule(state, cAlphaArgs(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(2), cAlphaArgs(2)); + ErrorsFound = true; } thisVrfSys.CoolingCapacity = rNumericArgs(1); @@ -2034,11 +2030,10 @@ void GetVRFInputData(EnergyPlusData &state, bool &ErrorsFound) } if (thisVrfSys.ThermostatPriority == ThermostatCtrlType::ScheduledPriority) { - thisVrfSys.SchedPriorityPtr = GetScheduleIndex(state, cAlphaArgs(26)); - if (thisVrfSys.SchedPriorityPtr == 0) { - ShowSevereError(state, format("{} = \"{}\"", cCurrentModuleObject, thisVrfSys.Name)); - ShowContinueError(state, format("...{} = {} not found.", cAlphaFieldNames(26), cAlphaArgs(26))); - ShowContinueError(state, format("A schedule name is required when {}={}", cAlphaFieldNames(25), cAlphaArgs(25))); + if (lAlphaFieldBlanks(26)) { + ShowSevereEmptyField(state, eoh, cAlphaFieldNames(26), cAlphaFieldNames(25), cAlphaArgs(25)); + } else if ((thisVrfSys.prioritySched = Sched::GetSchedule(state, cAlphaArgs(26))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(26), cAlphaArgs(26)); ErrorsFound = true; } } @@ -2292,24 +2287,16 @@ void GetVRFInputData(EnergyPlusData &state, bool &ErrorsFound) } if (!lAlphaFieldBlanks(38)) { - thisVrfSys.BasinHeaterSchedulePtr = GetScheduleIndex(state, cAlphaArgs(38)); - if (thisVrfSys.BasinHeaterSchedulePtr == 0) { - ShowSevereError( - state, - format("{} = \"{}\", {} = \"{}\" was not found.", cCurrentModuleObject, thisVrfSys.Name, cAlphaFieldNames(38), cAlphaArgs(38))); - ShowContinueError(state, "Basin heater will be available to operate throughout the simulation."); + if ((thisVrfSys.basinHeaterSched = Sched::GetSchedule(state, cAlphaArgs(38))) == nullptr) { + ShowWarningItemNotFound(state, eoh, cAlphaFieldNames(38), cAlphaArgs(38), + "Basin heater will be available to operate throughout the simulation."); } } if (!lAlphaFieldBlanks(39)) { // A39; \field Fuel type, Validate fuel type input - thisVrfSys.fuel = static_cast(getEnumValue(Constant::eFuelNamesUC, cAlphaArgs(39))); - if (thisVrfSys.fuel == Constant::eFuel::Invalid) { - ShowSevereError( - state, - format("{} = \"{}\", {} = \"{}\" was not found.", cCurrentModuleObject, thisVrfSys.Name, cAlphaFieldNames(39), cAlphaArgs(39))); - ShowContinueError( - state, "Valid choices are Electricity, NaturalGas, Propane, Diesel, Gasoline, FuelOilNo1, FuelOilNo2, OtherFuel1 or OtherFuel2"); + if ((thisVrfSys.fuel = static_cast(getEnumValue(Constant::eFuelNamesUC, cAlphaArgs(39)))) == Constant::eFuel::Invalid) { + ShowSevereInvalidKey(state, eoh, cAlphaFieldNames(39), cAlphaArgs(39)); ErrorsFound = true; } } @@ -2453,14 +2440,10 @@ void GetVRFInputData(EnergyPlusData &state, bool &ErrorsFound) thisVrfFluidCtrl.fuel = Constant::eFuel::Electricity; if (lAlphaFieldBlanks(2)) { - thisVrfFluidCtrl.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - thisVrfFluidCtrl.SchedPtr = GetScheduleIndex(state, cAlphaArgs(2)); - if (thisVrfFluidCtrl.SchedPtr == 0) { - ShowSevereError(state, cCurrentModuleObject + "=\"" + thisVrfFluidCtrl.Name + "\" invalid data"); - ShowContinueError(state, "Invalid-not found " + cAlphaFieldNames(2) + "=\"" + cAlphaArgs(2) + "\"."); - ErrorsFound = true; - } + thisVrfFluidCtrl.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((thisVrfFluidCtrl.availSched = Sched::GetSchedule(state, cAlphaArgs(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(2), cAlphaArgs(2)); + ErrorsFound = true; } thisVrfFluidCtrl.ZoneTUListPtr = @@ -2851,14 +2834,10 @@ void GetVRFInputData(EnergyPlusData &state, bool &ErrorsFound) thisVrfFluidCtrlHR.fuel = Constant::eFuel::Electricity; if (lAlphaFieldBlanks(2)) { - thisVrfFluidCtrlHR.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - thisVrfFluidCtrlHR.SchedPtr = GetScheduleIndex(state, cAlphaArgs(2)); - if (thisVrfFluidCtrlHR.SchedPtr == 0) { - ShowSevereError(state, cCurrentModuleObject + "=\"" + thisVrfFluidCtrlHR.Name + "\" invalid data"); - ShowContinueError(state, "Invalid-not found " + cAlphaFieldNames(2) + "=\"" + cAlphaArgs(2) + "\"."); - ErrorsFound = true; - } + thisVrfFluidCtrlHR.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((thisVrfFluidCtrlHR.availSched = Sched::GetSchedule(state, cAlphaArgs(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(2), cAlphaArgs(2)); + ErrorsFound = true; } thisVrfFluidCtrlHR.ZoneTUListPtr = @@ -3309,14 +3288,10 @@ void GetVRFInputData(EnergyPlusData &state, bool &ErrorsFound) } thisVrfTU.type = TUType::ConstantVolume; if (lAlphaFieldBlanks(2)) { - thisVrfTU.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - thisVrfTU.SchedPtr = GetScheduleIndex(state, cAlphaArgs(2)); - if (thisVrfTU.SchedPtr == 0) { - ShowSevereError(state, cCurrentModuleObject + "=\"" + thisVrfTU.Name + "\" invalid data"); - ShowContinueError(state, "Invalid-not found " + cAlphaFieldNames(2) + "=\"" + cAlphaArgs(2) + "\"."); - ErrorsFound = true; - } + thisVrfTU.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((thisVrfTU.availSched = Sched::GetSchedule(state, cAlphaArgs(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(2), cAlphaArgs(2)); + ErrorsFound = true; } thisVrfTU.VRFTUInletNodeNum = GetOnlySingleNode(state, @@ -3347,14 +3322,11 @@ void GetVRFInputData(EnergyPlusData &state, bool &ErrorsFound) thisVrfTU.HeatOutAirVolFlow = rNumericArgs(6); thisVrfTU.NoCoolHeatOutAirVolFlow = rNumericArgs(7); - thisVrfTU.FanOpModeSchedPtr = GetScheduleIndex(state, cAlphaArgs(5)); - // default to constant fan operating mode - if (thisVrfTU.FanOpModeSchedPtr == 0) { - if (!lAlphaFieldBlanks(5)) { - ShowSevereError(state, cCurrentModuleObject + " = " + thisVrfTU.Name); - ShowContinueError(state, "..." + cAlphaFieldNames(5) + " = " + cAlphaArgs(5) + " not found."); - ShowContinueError(state, "...Defaulting to constant fan operating mode and simulation continues."); - } + if (lAlphaFieldBlanks(5)) { + thisVrfTU.fanOp = HVAC::FanOp::Continuous; + } else if ((thisVrfTU.fanOpModeSched = Sched::GetSchedule(state, cAlphaArgs(5))) == nullptr) { + ShowWarningItemNotFound(state, eoh, cAlphaFieldNames(5), cAlphaArgs(5), + "Defaulting to constant fan operating mode and simulation continues."); thisVrfTU.fanOp = HVAC::FanOp::Continuous; } @@ -3422,16 +3394,14 @@ void GetVRFInputData(EnergyPlusData &state, bool &ErrorsFound) thisVrfTU.ActualFanVolFlowRate = FanVolFlowRate; int FanInletNodeNum = fan->inletNodeNum; int FanOutletNodeNum = fan->outletNodeNum; - thisVrfTU.FanAvailSchedPtr = fan->availSchedNum; + thisVrfTU.fanAvailSched = fan->availSched; // Check fan's schedule for cycling fan operation if constant volume fan is used - if (thisVrfTU.FanOpModeSchedPtr > 0 && thisVrfTU.fanType == HVAC::FanType::Constant) { - if (!CheckScheduleValueMinMax(state, thisVrfTU.FanOpModeSchedPtr, ">", 0.0, "<=", 1.0)) { - ShowSevereError(state, cCurrentModuleObject + " = " + thisVrfTU.Name); - ShowContinueError(state, format("For fan type = {}", HVAC::fanTypeNames[(int)HVAC::FanType::Constant])); - ShowContinueError(state, "Fan operating mode must be continuous (fan operating mode schedule values > 0)."); - ShowContinueError(state, format("Error found in {} = {}", cAlphaFieldNames(5), cAlphaArgs(5))); - ShowContinueError(state, "...schedule values must be (>0., <=1.)"); + if (thisVrfTU.fanOpModeSched != nullptr && thisVrfTU.fanType == HVAC::FanType::Constant) { + if (!thisVrfTU.fanOpModeSched->checkMinMaxVals(state, Clusive::Ex, 0.0, Clusive::In, 1.0)) { + Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(5), cAlphaArgs(5), Clusive::Ex, 0.0, Clusive::In, 1.0, + format("For fan type = {}, operating mode must be continuous (schedule values > 0).", + HVAC::fanTypeNames[(int)HVAC::FanType::Constant])); ErrorsFound = true; } } // IF (FanType_Num == HVAC::FanType_SimpleOnOff .OR. FanType_Num == HVAC::FanType_SimpleConstVolume)THEN @@ -3492,8 +3462,8 @@ void GetVRFInputData(EnergyPlusData &state, bool &ErrorsFound) if (Util::SameString(HVAC::cAllCoilTypes(thisVrfTU.DXCoolCoilType_Num), HVAC::cAllCoilTypes(HVAC::CoilVRF_FluidTCtrl_Cooling))) { errFlag = false; if (thisVrfTU.TUListIndex > 0 && thisVrfTU.IndexToTUInTUList > 0) { - state.dataHVACVarRefFlow->TerminalUnitList(thisVrfTU.TUListIndex).CoolingCoilAvailSchPtr(thisVrfTU.IndexToTUInTUList) = - GetDXCoilAvailSchPtr(state, DXCoolingCoilType, cAlphaArgs(12), errFlag); + state.dataHVACVarRefFlow->TerminalUnitList(thisVrfTU.TUListIndex).coolingCoilAvailScheds(thisVrfTU.IndexToTUInTUList) = + DXCoils::GetDXCoilAvailSched(state, DXCoolingCoilType, cAlphaArgs(12), errFlag); } GetDXCoilIndex( state, cAlphaArgs(12), thisVrfTU.CoolCoilIndex, errFlag, HVAC::cAllCoilTypes(HVAC::CoilVRF_FluidTCtrl_Cooling)); @@ -3573,8 +3543,8 @@ void GetVRFInputData(EnergyPlusData &state, bool &ErrorsFound) if (Util::SameString(HVAC::cAllCoilTypes(thisVrfTU.DXCoolCoilType_Num), HVAC::cAllCoilTypes(HVAC::CoilVRF_Cooling))) { if (thisVrfTU.TUListIndex > 0 && thisVrfTU.IndexToTUInTUList > 0) { - state.dataHVACVarRefFlow->TerminalUnitList(thisVrfTU.TUListIndex).CoolingCoilAvailSchPtr(thisVrfTU.IndexToTUInTUList) = - GetDXCoilAvailSchPtr(state, DXCoolingCoilType, cAlphaArgs(12), errFlag); + state.dataHVACVarRefFlow->TerminalUnitList(thisVrfTU.TUListIndex).coolingCoilAvailScheds(thisVrfTU.IndexToTUInTUList) = + DXCoils::GetDXCoilAvailSched(state, DXCoolingCoilType, cAlphaArgs(12), errFlag); } else { thisVrfTU.CoolingCoilPresent = false; } @@ -3651,8 +3621,8 @@ void GetVRFInputData(EnergyPlusData &state, bool &ErrorsFound) if (Util::SameString(HVAC::cAllCoilTypes(thisVrfTU.DXHeatCoilType_Num), HVAC::cAllCoilTypes(HVAC::CoilVRF_FluidTCtrl_Heating))) { errFlag = false; if (thisVrfTU.TUListIndex > 0 && thisVrfTU.IndexToTUInTUList > 0) { - state.dataHVACVarRefFlow->TerminalUnitList(thisVrfTU.TUListIndex).HeatingCoilAvailSchPtr(thisVrfTU.IndexToTUInTUList) = - GetDXCoilAvailSchPtr(state, DXHeatingCoilType, cAlphaArgs(14), errFlag); + state.dataHVACVarRefFlow->TerminalUnitList(thisVrfTU.TUListIndex).heatingCoilAvailScheds(thisVrfTU.IndexToTUInTUList) = + DXCoils::GetDXCoilAvailSched(state, DXHeatingCoilType, cAlphaArgs(14), errFlag); } GetDXCoilIndex( state, cAlphaArgs(14), thisVrfTU.HeatCoilIndex, errFlag, HVAC::cAllCoilTypes(HVAC::CoilVRF_FluidTCtrl_Heating)); @@ -3891,8 +3861,8 @@ void GetVRFInputData(EnergyPlusData &state, bool &ErrorsFound) // Algorithm Type: VRF model based on system curve if (Util::SameString(HVAC::cAllCoilTypes(thisVrfTU.DXHeatCoilType_Num), HVAC::cAllCoilTypes(HVAC::CoilVRF_Heating))) { if (thisVrfTU.TUListIndex > 0 && thisVrfTU.IndexToTUInTUList > 0) { - state.dataHVACVarRefFlow->TerminalUnitList(thisVrfTU.TUListIndex).HeatingCoilAvailSchPtr(thisVrfTU.IndexToTUInTUList) = - GetDXCoilAvailSchPtr(state, DXHeatingCoilType, cAlphaArgs(14), errFlag); + state.dataHVACVarRefFlow->TerminalUnitList(thisVrfTU.TUListIndex).heatingCoilAvailScheds(thisVrfTU.IndexToTUInTUList) = + DXCoils::GetDXCoilAvailSched(state, DXHeatingCoilType, cAlphaArgs(14), errFlag); } else { thisVrfTU.HeatingCoilPresent = false; } @@ -5509,7 +5479,6 @@ void InitVRF(EnergyPlusData &state, int const VRFTUNum, int const ZoneNum, bool using DataZoneEquipment::CheckZoneEquipmentList; using PlantUtilities::InitComponentNodes; - using ScheduleManager::GetCurrentScheduleValue; using SingleDuct::SimATMixer; static constexpr std::string_view RoutineName("InitVRF"); @@ -5968,9 +5937,8 @@ void InitVRF(EnergyPlusData &state, int const VRFTUNum, int const ZoneNum, bool state.dataHVACVarRefFlow->VRFTU(TUIndex).ZoneAirNode == 0) { // TU must be set point controlled and use constant fan mode (or coil out T won't change with PLR/air flow) state.dataHVACVarRefFlow->VRFTU(TUIndex).isSetPointControlled = true; - if (state.dataHVACVarRefFlow->VRFTU(TUIndex).FanOpModeSchedPtr > 0) { - if (ScheduleManager::GetScheduleMinValue(state, state.dataHVACVarRefFlow->VRFTU(TUIndex).FanOpModeSchedPtr) == - 0.0) { + if (state.dataHVACVarRefFlow->VRFTU(TUIndex).fanOpModeSched != nullptr) { + if (state.dataHVACVarRefFlow->VRFTU(TUIndex).fanOpModeSched->getCurrentVal() == 0.0) { ShowSevereError(state, format("{} = {}", tuTypeNames[(int)state.dataHVACVarRefFlow->VRFTU(TUIndex).type], @@ -5981,8 +5949,7 @@ void InitVRF(EnergyPlusData &state, int const VRFTUNum, int const ZoneNum, bool ShowContinueError( state, format("Error found in Supply Air Fan Operating Mode Schedule Name = {}", - state.dataScheduleMgr->Schedule(state.dataHVACVarRefFlow->VRFTU(TUIndex).FanOpModeSchedPtr) - .Name)); + state.dataHVACVarRefFlow->VRFTU(TUIndex).fanOpModeSched->Name)); ShowContinueError(state, "...schedule values must be (>0., <=1.)"); ErrorsFound = true; } @@ -6601,8 +6568,8 @@ void InitVRF(EnergyPlusData &state, int const VRFTUNum, int const ZoneNum, bool TimeStepSysLast = state.dataHVACGlobal->TimeStepSys; state.dataHVACVarRefFlow->CurrentEndTimeLast = CurrentEndTime; - if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FanOpModeSchedPtr > 0) { - if (GetCurrentScheduleValue(state, state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FanOpModeSchedPtr) == 0.0) { + if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).fanOpModeSched != nullptr) { + if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).fanOpModeSched->getCurrentVal() == 0.0) { state.dataHVACVarRefFlow->VRFTU(VRFTUNum).fanOp = HVAC::FanOp::Cycling; } else { state.dataHVACVarRefFlow->VRFTU(VRFTUNum).fanOp = HVAC::FanOp::Continuous; @@ -6610,7 +6577,7 @@ void InitVRF(EnergyPlusData &state, int const VRFTUNum, int const ZoneNum, bool } // if condenser is off, all terminal unit coils are off - if (GetCurrentScheduleValue(state, state.dataHVACVarRefFlow->VRF(VRFCond).SchedPtr) == 0.0) { + if (state.dataHVACVarRefFlow->VRF(VRFCond).availSched->getCurrentVal() == 0.0) { state.dataHVACVarRefFlow->HeatingLoad(VRFCond) = false; state.dataHVACVarRefFlow->CoolingLoad(VRFCond) = false; } else { @@ -6948,9 +6915,9 @@ void InitVRF(EnergyPlusData &state, int const VRFTUNum, int const ZoneNum, bool if (TempOutput < LoadToHeatingSP) { // Don't count as heating load unless mode is allowed. Also check for floating zone. if (state.dataHeatBalFanSys->TempControlType(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ZoneNum) != - HVAC::ThermostatType::SingleCooling && + HVAC::SetptType::SingleCool && state.dataHeatBalFanSys->TempControlType(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ZoneNum) != - HVAC::ThermostatType::Uncontrolled) { + HVAC::SetptType::Uncontrolled) { if (!state.dataHVACVarRefFlow->LastModeHeating(VRFCond)) { // system last operated in cooling mode, change air flows and repeat coil off capacity test if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).OAMixerUsed) { @@ -7005,9 +6972,9 @@ void InitVRF(EnergyPlusData &state, int const VRFTUNum, int const ZoneNum, bool if (TempOutput > LoadToCoolingSP) { // Don't count as cooling load unless mode is allowed. Also check for floating zone. if (state.dataHeatBalFanSys->TempControlType(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ZoneNum) != - HVAC::ThermostatType::SingleHeating && + HVAC::SetptType::SingleHeat && state.dataHeatBalFanSys->TempControlType(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ZoneNum) != - HVAC::ThermostatType::Uncontrolled) { + HVAC::SetptType::Uncontrolled) { if (!state.dataHVACVarRefFlow->LastModeCooling(VRFCond)) { if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).OAMixerUsed) { state.dataLoopNodes->Node(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUOAMixerRetNodeNum).MassFlowRate = @@ -7046,9 +7013,9 @@ void InitVRF(EnergyPlusData &state, int const VRFTUNum, int const ZoneNum, bool } else if (TempOutput < LoadToHeatingSP) { // Don't count as heating load unless mode is allowed. Also check for floating zone. if (state.dataHeatBalFanSys->TempControlType(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ZoneNum) != - HVAC::ThermostatType::SingleCooling && + HVAC::SetptType::SingleCool && state.dataHeatBalFanSys->TempControlType(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ZoneNum) != - HVAC::ThermostatType::Uncontrolled) { + HVAC::SetptType::Uncontrolled) { if (!state.dataHVACVarRefFlow->LastModeHeating(VRFCond)) { if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).OAMixerUsed) { state.dataLoopNodes->Node(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUOAMixerRetNodeNum).MassFlowRate = @@ -7100,8 +7067,8 @@ void InitVRF(EnergyPlusData &state, int const VRFTUNum, int const ZoneNum, bool } else if (TempOutput > 0.0 && LoadToCoolingSP < 0.0) { // If the net heating capacity overshoots the cooling setpoint count as cooling load // Don't count as cooling load unless mode is allowed. Also check for floating zone. - if (state.dataHeatBalFanSys->TempControlType(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ZoneNum) != HVAC::ThermostatType::SingleHeating && - state.dataHeatBalFanSys->TempControlType(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ZoneNum) != HVAC::ThermostatType::Uncontrolled) { + if (state.dataHeatBalFanSys->TempControlType(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ZoneNum) != HVAC::SetptType::SingleHeat && + state.dataHeatBalFanSys->TempControlType(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ZoneNum) != HVAC::SetptType::Uncontrolled) { if (!state.dataHVACVarRefFlow->LastModeCooling(VRFCond)) { if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).OAMixerUsed) { state.dataLoopNodes->Node(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUOAMixerRetNodeNum).MassFlowRate = @@ -7143,8 +7110,8 @@ void InitVRF(EnergyPlusData &state, int const VRFTUNum, int const ZoneNum, bool // see if the terminal unit operation will exceed the setpoint } else if (TempOutput < 0.0 && LoadToHeatingSP > 0.0) { // Don't count as heating load unless mode is allowed. Also check for floating zone. - if (state.dataHeatBalFanSys->TempControlType(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ZoneNum) != HVAC::ThermostatType::SingleCooling && - state.dataHeatBalFanSys->TempControlType(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ZoneNum) != HVAC::ThermostatType::Uncontrolled) { + if (state.dataHeatBalFanSys->TempControlType(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ZoneNum) != HVAC::SetptType::SingleCool && + state.dataHeatBalFanSys->TempControlType(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ZoneNum) != HVAC::SetptType::Uncontrolled) { if (!state.dataHVACVarRefFlow->LastModeHeating(VRFCond)) { // system last operated in cooling mode, change air flows and repeat coil off capacity test if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).OAMixerUsed) { @@ -8011,7 +7978,6 @@ void SizeVRF(EnergyPlusData &state, int const VRFTUNum) FieldNum = 3; // N3, \field Supply Air Flow Rate During Heating Operation SizingString = state.dataHVACVarRefFlow->VRFTUNumericFields(VRFTUNum).FieldNames(FieldNum) + " [m3/s]"; - int SizingMethod = HeatingAirflowSizing; // either this isn't needed or needs to be assigned to EqSizing TempSize = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxHeatAirVolFlow; errorsFound = false; HeatingAirFlowSizer sizingHeatingAirFlow; @@ -9017,7 +8983,7 @@ void VRFTerminalUnitEquipment::ControlVRF(EnergyPlusData &state, // The RETURNS here will jump back to SimVRF where the CalcVRF routine will simulate with latest PLR // do nothing else if TU is scheduled off - if (ScheduleManager::GetCurrentScheduleValue(state, this->SchedPtr) == 0.0) return; + if (this->availSched->getCurrentVal() == 0.0) return; // do nothing if TU has no load (TU will be modeled using PLR=0) if (QZnReq == 0.0) return; @@ -9876,8 +9842,6 @@ void SetAverageAirFlow(EnergyPlusData &state, // Set the average air mass flow rates using the part load fraction of the heat pump for this time step // Set OnOffAirFlowRatio to be used by DX coils - using ScheduleManager::GetCurrentScheduleValue; - int InletNode; // inlet node number int OutsideAirNode; // outside air node number int AirRelNode; // relief air node number @@ -9947,8 +9911,8 @@ void SetAverageAirFlow(EnergyPlusData &state, } // if the terminal unit and fan are scheduled on then set flow rate - if (GetCurrentScheduleValue(state, state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SchedPtr) > 0.0 && - (GetCurrentScheduleValue(state, state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FanAvailSchedPtr) > 0.0 || state.dataHVACGlobal->TurnFansOn) && + if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).availSched->getCurrentVal() > 0.0 && + (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).fanAvailSched->getCurrentVal() > 0.0 || state.dataHVACGlobal->TurnFansOn) && !state.dataHVACGlobal->TurnFansOff) { // so for sure OA system TUs should use inlet node flow rate, don't overwrite inlet node flow rate @@ -9998,8 +9962,6 @@ void InitializeOperatingMode(EnergyPlusData &state, // Scans each zone coil and determines the load based on control // Moved from Init to clean up and localize code segments - using ScheduleManager::GetCurrentScheduleValue; - Real64 ZoneDeltaT; // zone temperature difference from setpoint Real64 SPTempHi; // thermostat setpoint high Real64 SPTempLo; // thermostat setpoint low @@ -10038,7 +10000,7 @@ void InitializeOperatingMode(EnergyPlusData &state, // check to see if coil is present if (state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).CoolingCoilPresent(NumTU)) { // now check to see if coil is scheduled off - if (GetCurrentScheduleValue(state, state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).CoolingCoilAvailSchPtr(NumTU)) > 0.0) { + if (state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).coolingCoilAvailScheds(NumTU)->getCurrentVal() > 0.0) { state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).CoolingCoilAvailable(NumTU) = true; } } @@ -10046,7 +10008,7 @@ void InitializeOperatingMode(EnergyPlusData &state, // check to see if coil is present if (state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).HeatingCoilPresent(NumTU)) { // now check to see if coil is scheduled off - if (GetCurrentScheduleValue(state, state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).HeatingCoilAvailSchPtr(NumTU)) > 0.0) { + if (state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).heatingCoilAvailScheds(NumTU)->getCurrentVal() > 0.0) { state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).HeatingCoilAvailable(NumTU) = true; } } @@ -10155,24 +10117,25 @@ void InitializeOperatingMode(EnergyPlusData &state, // for TSTATPriority, just check difference between zone temp and thermostat setpoint if (ThisZoneNum > 0) { auto const &thisZoneHB = state.dataZoneTempPredictorCorrector->zoneHeatBalance(ThisZoneNum); - SPTempHi = state.dataHeatBalFanSys->ZoneThermostatSetPointHi(ThisZoneNum); - SPTempLo = state.dataHeatBalFanSys->ZoneThermostatSetPointLo(ThisZoneNum); + auto const &zoneTstatSetpt = state.dataHeatBalFanSys->zoneTstatSetpts(ThisZoneNum); + SPTempHi = zoneTstatSetpt.setptHi; + SPTempLo = zoneTstatSetpt.setptLo; switch (state.dataHeatBalFanSys->TempControlType(ThisZoneNum)) { - case HVAC::ThermostatType::Uncontrolled: + case HVAC::SetptType::Uncontrolled: // MaxDeltaT denotes cooling, MinDeltaT denotes heating break; - case HVAC::ThermostatType::SingleHeating: + case HVAC::SetptType::SingleHeat: // if heating load, ZoneDeltaT will be negative ZoneDeltaT = min(0.0, thisZoneHB.ZT - SPTempLo); state.dataHVACVarRefFlow->MinDeltaT(VRFCond) = min(state.dataHVACVarRefFlow->MinDeltaT(VRFCond), ZoneDeltaT); break; - case HVAC::ThermostatType::SingleCooling: + case HVAC::SetptType::SingleCool: // if cooling load, ZoneDeltaT will be positive ZoneDeltaT = max(0.0, thisZoneHB.ZT - SPTempHi); state.dataHVACVarRefFlow->MaxDeltaT(VRFCond) = max(state.dataHVACVarRefFlow->MaxDeltaT(VRFCond), ZoneDeltaT); break; - case HVAC::ThermostatType::SingleHeatCool: + case HVAC::SetptType::SingleHeatCool: ZoneDeltaT = thisZoneHB.ZT - SPTempHi; //- SPTempHi and SPTempLo are same value if (ZoneDeltaT > 0.0) { state.dataHVACVarRefFlow->MaxDeltaT(VRFCond) = max(state.dataHVACVarRefFlow->MaxDeltaT(VRFCond), ZoneDeltaT); @@ -10180,7 +10143,7 @@ void InitializeOperatingMode(EnergyPlusData &state, state.dataHVACVarRefFlow->MinDeltaT(VRFCond) = min(state.dataHVACVarRefFlow->MinDeltaT(VRFCond), ZoneDeltaT); } break; - case HVAC::ThermostatType::DualSetPointWithDeadBand: + case HVAC::SetptType::DualHeatCool: if (thisZoneHB.ZT - SPTempHi > 0.0) { ZoneDeltaT = max(0.0, thisZoneHB.ZT - SPTempHi); state.dataHVACVarRefFlow->MaxDeltaT(VRFCond) = max(state.dataHVACVarRefFlow->MaxDeltaT(VRFCond), ZoneDeltaT); @@ -10214,8 +10177,8 @@ void InitializeOperatingMode(EnergyPlusData &state, // If the net cooling capacity overshoots the heating setpoint count as heating load if (TempOutput < LoadToHeatingSP) { // Don't count as heating load unless mode is allowed. Also check for floating zone. - if (state.dataHeatBalFanSys->TempControlType(ThisZoneNum) != HVAC::ThermostatType::SingleCooling && - state.dataHeatBalFanSys->TempControlType(ThisZoneNum) != HVAC::ThermostatType::Uncontrolled) { + if (state.dataHeatBalFanSys->TempControlType(ThisZoneNum) != HVAC::SetptType::SingleCool && + state.dataHeatBalFanSys->TempControlType(ThisZoneNum) != HVAC::SetptType::Uncontrolled) { if (!state.dataHVACVarRefFlow->LastModeHeating(VRFCond)) { // if last mode was cooling, make sure heating flow rate is used if (state.dataHVACVarRefFlow->VRFTU(TUIndex).OAMixerUsed) { @@ -10268,8 +10231,8 @@ void InitializeOperatingMode(EnergyPlusData &state, // If the net heating capacity overshoots the cooling setpoint count as cooling load if (TempOutput > LoadToCoolingSP) { // Don't count as cooling load unless mode is allowed. Also check for floating zone. - if (state.dataHeatBalFanSys->TempControlType(ThisZoneNum) != HVAC::ThermostatType::SingleHeating && - state.dataHeatBalFanSys->TempControlType(ThisZoneNum) != HVAC::ThermostatType::Uncontrolled) { + if (state.dataHeatBalFanSys->TempControlType(ThisZoneNum) != HVAC::SetptType::SingleHeat && + state.dataHeatBalFanSys->TempControlType(ThisZoneNum) != HVAC::SetptType::Uncontrolled) { if (!state.dataHVACVarRefFlow->LastModeCooling(VRFCond)) { if (state.dataHVACVarRefFlow->VRFTU(TUIndex).OAMixerUsed) { state.dataLoopNodes->Node(state.dataHVACVarRefFlow->VRFTU(TUIndex).VRFTUOAMixerRetNodeNum).MassFlowRate = @@ -10376,10 +10339,10 @@ void InitializeOperatingMode(EnergyPlusData &state, } } break; case ThermostatCtrlType::ScheduledPriority: { - if (GetCurrentScheduleValue(state, state.dataHVACVarRefFlow->VRF(VRFCond).SchedPriorityPtr) == 0) { + if (state.dataHVACVarRefFlow->VRF(VRFCond).prioritySched->getCurrentVal() == 0) { state.dataHVACVarRefFlow->HeatingLoad(VRFCond) = true; state.dataHVACVarRefFlow->CoolingLoad(VRFCond) = false; - } else if (GetCurrentScheduleValue(state, state.dataHVACVarRefFlow->VRF(VRFCond).SchedPriorityPtr) == 1) { + } else if (state.dataHVACVarRefFlow->VRF(VRFCond).prioritySched->getCurrentVal() == 1) { state.dataHVACVarRefFlow->HeatingLoad(VRFCond) = false; state.dataHVACVarRefFlow->CoolingLoad(VRFCond) = true; } else { @@ -10753,19 +10716,19 @@ void getVRFTUZoneLoad( .SequencedOutputRequiredToHeatingSP(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).zoneSequenceHeatingNum) / state.dataHVACVarRefFlow->VRFTU(VRFTUNum).controlZoneMassFlowFrac; if (LoadToHeatingSP > 0.0 && LoadToCoolingSP > 0.0 && - state.dataHeatBalFanSys->TempControlType(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ZoneNum) != HVAC::ThermostatType::SingleCooling) { + state.dataHeatBalFanSys->TempControlType(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ZoneNum) != HVAC::SetptType::SingleCool) { zoneLoad = LoadToHeatingSP; } else if (LoadToHeatingSP > 0.0 && LoadToCoolingSP > 0.0 && state.dataHeatBalFanSys->TempControlType(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ZoneNum) == - HVAC::ThermostatType::SingleCooling) { + HVAC::SetptType::SingleCool) { zoneLoad = 0.0; } else if (LoadToHeatingSP < 0.0 && LoadToCoolingSP < 0.0 && state.dataHeatBalFanSys->TempControlType(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ZoneNum) != - HVAC::ThermostatType::SingleHeating) { + HVAC::SetptType::SingleHeat) { zoneLoad = LoadToCoolingSP; } else if (LoadToHeatingSP < 0.0 && LoadToCoolingSP < 0.0 && state.dataHeatBalFanSys->TempControlType(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ZoneNum) == - HVAC::ThermostatType::SingleHeating) { + HVAC::SetptType::SingleHeat) { zoneLoad = 0.0; } else if (LoadToHeatingSP <= 0.0 && LoadToCoolingSP >= 0.0) { zoneLoad = 0.0; @@ -12374,7 +12337,6 @@ void VRFTerminalUnitEquipment::ControlVRF_FluidTCtrl(EnergyPlusData &state, // Use RegulaFalsi technique to iterate on part-load ratio until convergence is achieved. using General::SolveRoot; - using ScheduleManager::GetCurrentScheduleValue; int constexpr MaxIte(500); // maximum number of iterations Real64 constexpr MinPLF(0.0); // minimum part load factor allowed @@ -12410,7 +12372,7 @@ void VRFTerminalUnitEquipment::ControlVRF_FluidTCtrl(EnergyPlusData &state, // The RETURNS here will jump back to SimVRF where the CalcVRF routine will simulate with latest PLR // do nothing else if TU is scheduled off - if (GetCurrentScheduleValue(state, this->SchedPtr) == 0.0) return; + if (this->availSched->getCurrentVal() == 0.0) return; // Block the following statement: QZnReq==0 doesn't mean QCoilReq==0 due to possible OA mixer operation. zrp_201511 // do nothing if TU has no load (TU will be modeled using PLR=0) diff --git a/src/EnergyPlus/HVACVariableRefrigerantFlow.hh b/src/EnergyPlus/HVACVariableRefrigerantFlow.hh index d34e72a3a4a..efa2a603f5f 100644 --- a/src/EnergyPlus/HVACVariableRefrigerantFlow.hh +++ b/src/EnergyPlus/HVACVariableRefrigerantFlow.hh @@ -161,7 +161,7 @@ namespace HVACVariableRefrigerantFlow { Real64 QCondenser; // Water condenser heat rejection/absorption (W) Real64 QCondEnergy; // Water condenser heat rejection/aborption energy (J) Real64 CondenserSideOutletTemp; // Water condenser outlet temp (C) - int SchedPtr; // Pointer to the correct schedule + Sched::Schedule *availSched = nullptr; // Pointer to the correct schedule // LOL Real64 CoolingCapacity; // Nominal VRF heat pump cooling capacity (W) Real64 TotalCoolingCapacity; // Nominal VRF heat pump cooling capacity (W) Real64 CoolingCombinationRatio; // Ratio or terminal unit cooling capacity to VRF condenser capacity @@ -207,7 +207,7 @@ namespace HVACVariableRefrigerantFlow { int MasterZonePtr; // index to master thermostat zone int MasterZoneTUIndex; // index to TU in master thermostat zone ThermostatCtrlType ThermostatPriority; // VRF priority control (1=LoadPriority, 2=ZonePriority, etc) - int SchedPriorityPtr; // VRF priority control schedule pointer + Sched::Schedule *prioritySched = nullptr; // VRF priority control schedule int ZoneTUListPtr; // index to zone terminal unit list bool HeatRecoveryUsed; // .TRUE. = heat recovery used Real64 VertPipeLngth; // vertical piping length (m) @@ -308,7 +308,7 @@ namespace HVACVariableRefrigerantFlow { Real64 BasinHeaterSetPointTemp; // setpoint temperature for basin heater operation (C) Real64 BasinHeaterPower; // Basin heater power (W) Real64 BasinHeaterConsumption; // Basin heater energy consumption (J) - int BasinHeaterSchedulePtr; // Pointer to basin heater schedule + Sched::Schedule *basinHeaterSched = nullptr; // Pointer to basin heater schedule // end variables for Basin Heater interactions bool EMSOverrideHPOperatingMode; Real64 EMSValueForHPOperatingMode; @@ -392,14 +392,14 @@ namespace HVACVariableRefrigerantFlow { VRFCondenserEquipment() : VRFSystemTypeNum(0), VRFAlgorithmType(AlgorithmType::Invalid), VRFType(DataPlant::PlantEquipmentType::Invalid), SourcePlantLoc{}, WaterCondenserDesignMassFlow(0.0), WaterCondenserMassFlow(0.0), QCondenser(0.0), QCondEnergy(0.0), CondenserSideOutletTemp(0.0), - SchedPtr(-1), CoolingCapacity(0.0), TotalCoolingCapacity(0.0), CoolingCombinationRatio(1.0), VRFCondPLR(0.0), VRFCondRTF(0.0), + CoolingCapacity(0.0), TotalCoolingCapacity(0.0), CoolingCombinationRatio(1.0), VRFCondPLR(0.0), VRFCondRTF(0.0), VRFCondCyclingRatio(0.0), CondenserInletTemp(0.0), CoolingCOP(0.0), OperatingCoolingCOP(0.0), RatedCoolingPower(0.0), HeatingCapacity(0.0), HeatingCapacitySizeRatio(1.0), LockHeatingCapacity(false), TotalHeatingCapacity(0.0), HeatingCombinationRatio(1.0), HeatingCOP(0.0), OperatingHeatingCOP(0.0), RatedHeatingPower(0.0), MinOATCooling(0.0), MaxOATCooling(0.0), MinOATHeating(0.0), MaxOATHeating(0.0), CoolCapFT(0), CoolEIRFT(0), HeatCapFT(0), HeatEIRFT(0), CoolBoundaryCurvePtr(0), HeatBoundaryCurvePtr(0), EIRCoolBoundaryCurvePtr(0), CoolEIRFPLR1(0), CoolEIRFPLR2(0), CoolCapFTHi(0), CoolEIRFTHi(0), HeatCapFTHi(0), HeatEIRFTHi(0), EIRHeatBoundaryCurvePtr(0), HeatEIRFPLR1(0), HeatEIRFPLR2(0), CoolPLFFPLR(0), HeatPLFFPLR(0), MinPLR(0.0), - MasterZonePtr(0), MasterZoneTUIndex(0), ThermostatPriority(ThermostatCtrlType::Invalid), SchedPriorityPtr(0), ZoneTUListPtr(0), + MasterZonePtr(0), MasterZoneTUIndex(0), ThermostatPriority(ThermostatCtrlType::Invalid), ZoneTUListPtr(0), HeatRecoveryUsed(false), VertPipeLngth(0.0), PCFLengthCoolPtr(0), PCFHeightCool(0.0), EquivPipeLngthCool(0.0), PipingCorrectionCooling(1.0), PCFLengthHeatPtr(0), PCFHeightHeat(0.0), EquivPipeLngthHeat(0.0), PipingCorrectionHeating(1.0), CCHeaterPower(0.0), CompressorSizeRatio(0.0), NumCompressors(0), MaxOATCCHeater(0.0), DefrostEIRPtr(0), DefrostFraction(0.0), @@ -417,7 +417,7 @@ namespace HVACVariableRefrigerantFlow { HRModeChange(false), HRTimer(0.0), HRTime(0.0), EvapWaterSupplyMode(EvapWaterSupply::FromMains), EvapWaterSupTankID(0), EvapWaterTankDemandARRID(0), CondensateTankID(0), CondensateTankSupplyARRID(0), CondensateVdot(0.0), CondensateVol(0.0), BasinHeaterPowerFTempDiff(0.0), BasinHeaterSetPointTemp(0.0), BasinHeaterPower(0.0), BasinHeaterConsumption(0.0), - BasinHeaterSchedulePtr(0), EMSOverrideHPOperatingMode(false), EMSValueForHPOperatingMode(0.0), HPOperatingModeErrorIndex(0), + EMSOverrideHPOperatingMode(false), EMSValueForHPOperatingMode(0.0), HPOperatingModeErrorIndex(0), VRFHeatRec(0.0), VRFHeatEnergyRec(0.0), AlgorithmIUCtrl(1), CondensingTemp(44.0), CondTempFixed(0.0), CoffEvapCap(1.0), CompActSpeed(0.0), CompMaxDeltaP(0.0), C1Te(0.0), C2Te(0.0), C3Te(0.0), C1Tc(0.0), C2Tc(0.0), C3Tc(0.0), DiffOUTeTo(5), EffCompInverter(0.95), EvaporatingTemp(6.0), EvapTempFixed(0.0), HROUHexRatio(0.0), IUEvaporatingTemp(6.0), IUCondensingTemp(44.0), @@ -630,8 +630,8 @@ namespace HVACVariableRefrigerantFlow { Array1D_bool HRCoolRequest; // defines a cooling load on VRFTerminalUnits when QZnReq > 0 Array1D_bool CoolingCoilAvailable; // cooling coil availability scheduled on Array1D_bool HeatingCoilAvailable; // cooling coil availability scheduled on - Array1D_int CoolingCoilAvailSchPtr; // cooling coil availability schedule index - Array1D_int HeatingCoilAvailSchPtr; // heating coil availability schedule index + Array1D coolingCoilAvailScheds; // cooling coil availability schedule index + Array1D heatingCoilAvailScheds; // heating coil availability schedule index // Default Constructor TerminalUnitListData() : NumTUInList(0), reset_isSimulatedFlags(true) @@ -644,7 +644,7 @@ namespace HVACVariableRefrigerantFlow { // Members std::string Name; // Name of the VRF Terminal Unit TUType type = TUType::Invalid; // DataHVACGlobals VRF Terminal Unit type - int SchedPtr = -1; // Pointer to the correct schedule + Sched::Schedule *availSched = nullptr; // Pointer to the correct schedule // LOL // avail? int VRFSysNum = 0; // index to VRF Condenser int TUListIndex = 0; // index to VRF Terminal Unit List int IndexToTUInTUList = 0; // index to TU in VRF Terminal Unit List @@ -678,8 +678,8 @@ namespace HVACVariableRefrigerantFlow { Real64 SuppHeatPartLoadRatio = 0.0; // supplemental heating coil part load ratio Real64 SuppHeatingCoilLoad = 0.0; // supplemental heating coil heating load HVAC::FanType fanType = HVAC::FanType::Invalid; // index to fan type - int FanOpModeSchedPtr = 0; // Pointer to the correct fan operating mode schedule - int FanAvailSchedPtr = -1; // Pointer to the correct fan availability schedule + Sched::Schedule *fanOpModeSched = nullptr; // Pointer to the correct fan operating mode schedule + Sched::Schedule *fanAvailSched = nullptr; // Pointer to the correct fan availability schedule int FanIndex = 0; // Index to fan object Real64 FanPower = 0.0; // power reported by fan component HVAC::FanOp fanOp = HVAC::FanOp::Invalid; // operation mode: 1 = cycling fan, cycling coil 2 = constant fan, cycling coil @@ -1039,6 +1039,10 @@ struct HVACVarRefFlowData : BaseGlobalStruct EPVector TerminalUnitList; // zoneTerminalUnitList object EPVector VRFTUNumericFields; // holds VRF TU numeric input fields character field name + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/HWBaseboardRadiator.cc b/src/EnergyPlus/HWBaseboardRadiator.cc index c6ff41bfedc..cb312069b51 100644 --- a/src/EnergyPlus/HWBaseboardRadiator.cc +++ b/src/EnergyPlus/HWBaseboardRadiator.cc @@ -236,6 +236,8 @@ namespace HWBaseboardRadiator { // SUBROUTINE PARAMETER DEFINITIONS: static constexpr std::string_view RoutineName("GetHWBaseboardInput:"); + static constexpr std::string_view routineName = "GetHWBaseboardInput"; + Real64 constexpr MaxFraction(1.0); Real64 constexpr MinFraction(0.0); Real64 constexpr MaxWaterTempAvg(150.0); // Maximum limit of average water temperature in degree C @@ -439,6 +441,8 @@ namespace HWBaseboardRadiator { state.dataIPShortCut->cAlphaFieldNames, state.dataIPShortCut->cNumericFieldNames); + ErrorObjectHeader eoh{routineName, cCMO_BBRadiator_Water, state.dataIPShortCut->cAlphaArgs(1)}; + HWBaseboardNumericFields.FieldNames.allocate(NumNumbers); HWBaseboardNumericFields.FieldNames = state.dataIPShortCut->cNumericFieldNames; @@ -456,19 +460,10 @@ namespace HWBaseboardRadiator { // Get schedule if (state.dataIPShortCut->lAlphaFieldBlanks(3)) { - thisHWBaseboard.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - thisHWBaseboard.SchedPtr = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(3)); - if (thisHWBaseboard.SchedPtr == 0) { - ShowSevereError(state, - format("{}{}=\"{}\", {}=\"{}\" not found.", - RoutineName, - cCMO_BBRadiator_Water, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaFieldNames(3), - state.dataIPShortCut->cAlphaArgs(3))); - ErrorsFound = true; - } + thisHWBaseboard.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((thisHWBaseboard.availSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(3))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(3), state.dataIPShortCut->cAlphaArgs(3)); + ErrorsFound = true; } // Get inlet node number @@ -1285,7 +1280,7 @@ namespace HWBaseboardRadiator { Real64 WaterMassFlowRate = state.dataLoopNodes->Node(hWBaseboard.WaterInletNode).MassFlowRate; if (QZnReq > HVAC::SmallLoad && !state.dataZoneEnergyDemand->CurDeadBandOrSetback(ZoneNum) && - (ScheduleManager::GetCurrentScheduleValue(state, hWBaseboard.SchedPtr) > 0) && (WaterMassFlowRate > 0.0)) { + (hWBaseboard.availSched->getCurrentVal() > 0) && (WaterMassFlowRate > 0.0)) { HWBaseboardDesignData const &HWBaseboardDesignDataObject{ state.dataHWBaseboardRad->HWBaseboardDesignObject(hWBaseboard.DesignObjectPtr)}; // Contains the data for the design object diff --git a/src/EnergyPlus/HWBaseboardRadiator.hh b/src/EnergyPlus/HWBaseboardRadiator.hh index ac714b4cf27..f05a2834291 100644 --- a/src/EnergyPlus/HWBaseboardRadiator.hh +++ b/src/EnergyPlus/HWBaseboardRadiator.hh @@ -77,7 +77,7 @@ namespace HWBaseboardRadiator { int DesignObjectPtr = 0; Array1D_int SurfacePtr; int ZonePtr = 0; - int SchedPtr = 0; + Sched::Schedule *availSched = nullptr; int WaterInletNode = 0; int WaterOutletNode = 0; int TotSurfToDistrib = 0; @@ -219,6 +219,10 @@ struct HWBaseboardRadiatorData : BaseGlobalStruct bool MyEnvrnFlag2 = true; Array1D_bool MyEnvrnFlag; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/HeatBalFiniteDiffManager.cc b/src/EnergyPlus/HeatBalFiniteDiffManager.cc index 94d4b94b7c8..05f5fb4859d 100644 --- a/src/EnergyPlus/HeatBalFiniteDiffManager.cc +++ b/src/EnergyPlus/HeatBalFiniteDiffManager.cc @@ -586,10 +586,10 @@ namespace HeatBalFiniteDiffManager { // set a Delt that fits the zone time step and keeps it below 200s. - s_hbfd->fracTimeStepZone_Hour = 1.0 / double(state.dataGlobal->NumOfTimeStepInHour); + s_hbfd->fracTimeStepZone_Hour = 1.0 / double(state.dataGlobal->TimeStepsInHour); for (int index = 1; index <= 20; ++index) { - Delt = (s_hbfd->fracTimeStepZone_Hour * Constant::SecInHour) / index; // TimeStepZone = Zone time step in fractional hours + Delt = (s_hbfd->fracTimeStepZone_Hour * Constant::rSecsInHour) / index; // TimeStepZone = Zone time step in fractional hours if (Delt <= 200) break; } @@ -1364,7 +1364,7 @@ namespace HeatBalFiniteDiffManager { ThisNum, construct.TotLayers, int(constructFD.TotNodes + 1), - constructFD.DeltaTime / Constant::SecInHour); + constructFD.DeltaTime / Constant::rSecsInHour); for (int Layer = 1; Layer <= construct.TotLayers; ++Layer) { static constexpr std::string_view Format_701(" Material CondFD Summary,{},{:.4R},{},{:.8R},{:.8R},{:.8R}\n"); diff --git a/src/EnergyPlus/HeatBalFiniteDiffManager.hh b/src/EnergyPlus/HeatBalFiniteDiffManager.hh index 39d2a3eab68..1ec6d808938 100644 --- a/src/EnergyPlus/HeatBalFiniteDiffManager.hh +++ b/src/EnergyPlus/HeatBalFiniteDiffManager.hh @@ -347,6 +347,10 @@ struct HeatBalFiniteDiffMgr : BaseGlobalStruct Array1D MaterialFD; bool MyEnvrnFlag = true; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/HeatBalanceAirManager.cc b/src/EnergyPlus/HeatBalanceAirManager.cc index 8467d62d731..bede216506b 100644 --- a/src/EnergyPlus/HeatBalanceAirManager.cc +++ b/src/EnergyPlus/HeatBalanceAirManager.cc @@ -261,6 +261,7 @@ void GetSimpleAirModelInputs(EnergyPlusData &state, bool &ErrorsFound) // IF err Real64 constexpr MixingTempLimit = 100.0; // degrees Celsius Real64 constexpr VentilWSLimit = 40.0; // m/s static constexpr std::string_view RoutineName("GetSimpleAirModelInputs: "); // include trailing blank space + static constexpr std::string_view routineName = "GetSimpleAirModelInputs"; // Refrigeration Door Mixing Protection types, factors used to moderate mixing flow. Real64 constexpr RefDoorNone = 0.0; Real64 constexpr RefDoorAirCurtain = 0.5; @@ -453,6 +454,8 @@ void GetSimpleAirModelInputs(EnergyPlusData &state, bool &ErrorsFound) // IF err lAlphaFieldBlanks, cAlphaFieldNames, cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, cCurrentModuleObject, cAlphaArgs(1)}; bool IsNotOK = false; auto &thisZoneAirBalance = state.dataHeatBal->ZoneAirBalance(Loop); thisZoneAirBalance.Name = cAlphaArgs(1); @@ -512,27 +515,13 @@ void GetSimpleAirModelInputs(EnergyPlusData &state, bool &ErrorsFound) // IF err ErrorsFound = true; } - thisZoneAirBalance.InducedAirSchedPtr = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(4)); - if (thisZoneAirBalance.InducedAirSchedPtr == 0) { - if (lAlphaFieldBlanks(4)) { - ShowSevereError( - state, - format("{}{}=\"{}\",{} is required but field is blank.", RoutineName, cCurrentModuleObject, cAlphaArgs(1), cAlphaFieldNames(4))); - } else { - ShowSevereError(state, - format(R"({}{}="{}", invalid (not found) {}="{}".)", - RoutineName, - cCurrentModuleObject, - cAlphaArgs(1), - cAlphaFieldNames(4), - cAlphaArgs(4))); - } + if (lAlphaFieldBlanks(4)) { + ShowSevereEmptyField(state, eoh, cAlphaFieldNames(4)); + } else if ((thisZoneAirBalance.inducedAirSched = Sched::GetSchedule(state, cAlphaArgs(4))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(4), cAlphaArgs(4)); ErrorsFound = true; - } - if (!ScheduleManager::CheckScheduleValueMinMax(state, thisZoneAirBalance.InducedAirSchedPtr, ">=", 0.0, "<=", 1.0)) { - ShowSevereError( - state, format("{} = {}: Error found in {} = {}", cCurrentModuleObject, thisZoneAirBalance.Name, cAlphaFieldNames(4), cAlphaArgs(4))); - ShowContinueError(state, "Schedule values must be (>=0., <=1.)"); + } else if (!thisZoneAirBalance.inducedAirSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) { + Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(4), cAlphaArgs(4), Clusive::In, 0.0, Clusive::In, 1.0); ErrorsFound = true; } @@ -714,6 +703,7 @@ void GetSimpleAirModelInputs(EnergyPlusData &state, bool &ErrorsFound) // IF err cAlphaFieldNames, cNumericFieldNames); + ErrorObjectHeader eoh{routineName, cCurrentModuleObject, cAlphaArgs(1)}; // Create one Infiltration instance for every space associated with this input object auto &thisInfiltrationInput = infiltrationDesignFlowRateObjects(infilInputNum); for (int Item1 = 1; Item1 <= thisInfiltrationInput.numOfSpaces; ++Item1) { @@ -727,20 +717,11 @@ void GetSimpleAirModelInputs(EnergyPlusData &state, bool &ErrorsFound) // IF err thisInfiltration.ModelType = DataHeatBalance::InfiltrationModelType::DesignFlowRate; if (lAlphaFieldBlanks(3)) { - thisInfiltration.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - thisInfiltration.SchedPtr = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(3)); - if (thisInfiltration.SchedPtr == 0) { - if (Item1 == 1) { // avoid repeated error messages from the same input object - ShowSevereError(state, - format("{}{}=\"{}\", invalid (not found) {}=\"{}\".", - RoutineName, - cCurrentModuleObject, - cAlphaArgs(1), - cAlphaFieldNames(3), - cAlphaArgs(3))); - ErrorsFound = true; - } + thisInfiltration.sched = Sched::GetScheduleAlwaysOn(state); + } else if ((thisInfiltration.sched = Sched::GetSchedule(state, cAlphaArgs(3))) == nullptr) { + if (Item1 == 1) { // avoid repeated error messages from the same input object + ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(3), cAlphaArgs(3)); + ErrorsFound = true; } } @@ -884,7 +865,7 @@ void GetSimpleAirModelInputs(EnergyPlusData &state, bool &ErrorsFound) // IF err case AirflowSpecAlt::AirChanges: if (thisInfiltration.spaceIndex != 0) { if (rNumericArgs(4) >= 0.0) { - thisInfiltration.DesignLevel = rNumericArgs(4) * thisSpace.Volume / Constant::SecInHour; + thisInfiltration.DesignLevel = rNumericArgs(4) * thisSpace.Volume / Constant::rSecsInHour; if (thisSpace.Volume <= 0.0) { ShowWarningError(state, format("{}{}=\"{}\", {} specifies {}, but Space Volume = 0. 0 Infiltration will result.", @@ -958,6 +939,9 @@ void GetSimpleAirModelInputs(EnergyPlusData &state, bool &ErrorsFound) // IF err lAlphaFieldBlanks, cAlphaFieldNames, cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, cCurrentModuleObject, cAlphaArgs(1)}; + // Create one Infiltration instance for every space associated with this input object auto &thisInfiltrationInput = infiltrationLeakageAreaObjects(infilInputNum); for (int Item1 = 1; Item1 <= thisInfiltrationInput.numOfSpaces; ++Item1) { @@ -972,19 +956,10 @@ void GetSimpleAirModelInputs(EnergyPlusData &state, bool &ErrorsFound) // IF err thisInfiltration.ModelType = DataHeatBalance::InfiltrationModelType::ShermanGrimsrud; if (lAlphaFieldBlanks(3)) { - thisInfiltration.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - thisInfiltration.SchedPtr = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(3)); - if (thisInfiltration.SchedPtr == 0) { - ShowSevereError(state, - format(R"({}{}="{}", invalid (not found) {}="{}".)", - RoutineName, - cCurrentModuleObject, - cAlphaArgs(1), - cAlphaFieldNames(3), - cAlphaArgs(3))); - ErrorsFound = true; - } + thisInfiltration.sched = Sched::GetScheduleAlwaysOn(state); + } else if ((thisInfiltration.sched = Sched::GetSchedule(state, cAlphaArgs(3))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(3), cAlphaArgs(3)); + ErrorsFound = true; } thisInfiltration.BasicStackCoefficient = rNumericArgs(2); thisInfiltration.BasicWindCoefficient = rNumericArgs(3); @@ -1045,6 +1020,9 @@ void GetSimpleAirModelInputs(EnergyPlusData &state, bool &ErrorsFound) // IF err lAlphaFieldBlanks, cAlphaFieldNames, cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, cCurrentModuleObject, cAlphaArgs(1)}; + // Create one Infiltration instance for every space associated with this input object auto &thisInfiltrationInput = infiltrationFlowCoefficientObjects(infilInputNum); for (int Item1 = 1; Item1 <= thisInfiltrationInput.numOfSpaces; ++Item1) { @@ -1059,19 +1037,10 @@ void GetSimpleAirModelInputs(EnergyPlusData &state, bool &ErrorsFound) // IF err thisInfiltration.ModelType = DataHeatBalance::InfiltrationModelType::AIM2; if (lAlphaFieldBlanks(3)) { - thisInfiltration.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - thisInfiltration.SchedPtr = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(3)); - if (thisInfiltration.SchedPtr == 0) { - ShowSevereError(state, - format("{}{}=\"{}\", invalid (not found) {}=\"{}\".", - RoutineName, - cCurrentModuleObject, - cAlphaArgs(1), - cAlphaFieldNames(3), - cAlphaArgs(3))); - ErrorsFound = true; - } + thisInfiltration.sched = Sched::GetScheduleAlwaysOn(state); + } else if ((thisInfiltration.sched = Sched::GetSchedule(state, cAlphaArgs(3))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(3), cAlphaArgs(3)); + ErrorsFound = true; } thisInfiltration.AIM2StackCoefficient = rNumericArgs(2); thisInfiltration.PressureExponent = rNumericArgs(3); @@ -1368,6 +1337,7 @@ void GetSimpleAirModelInputs(EnergyPlusData &state, bool &ErrorsFound) // IF err cAlphaFieldNames, cNumericFieldNames); + ErrorObjectHeader eoh{routineName, cCurrentModuleObject, cAlphaArgs(1)}; auto &thisVentilationInput = ventilationDesignFlowRateObjects(ventInputNum); for (int Item1 = 1; Item1 <= thisVentilationInput.numOfSpaces; ++Item1) { ++ventilationNum; @@ -1380,19 +1350,10 @@ void GetSimpleAirModelInputs(EnergyPlusData &state, bool &ErrorsFound) // IF err thisVentilation.ModelType = DataHeatBalance::VentilationModelType::DesignFlowRate; if (lAlphaFieldBlanks(3)) { - thisVentilation.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - thisVentilation.SchedPtr = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(3)); - if (thisVentilation.SchedPtr == 0) { - if (Item1 == 1) { - ShowSevereError(state, - format("{}{}=\"{}\", invalid (not found) {}=\"{}\".", - RoutineName, - cCurrentModuleObject, - cAlphaArgs(1), - cAlphaFieldNames(3), - cAlphaArgs(3))); - } + thisVentilation.sched = Sched::GetScheduleAlwaysOn(state); + } else if ((thisVentilation.sched = Sched::GetSchedule(state, cAlphaArgs(3))) == nullptr) { + if (Item1 == 1) { + ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(3), cAlphaArgs(3)); ErrorsFound = true; } } @@ -1485,7 +1446,7 @@ void GetSimpleAirModelInputs(EnergyPlusData &state, bool &ErrorsFound) // IF err case AirflowSpec::AirChanges: if (thisVentilation.spaceIndex != 0) { if (rNumericArgs(4) >= 0.0) { - thisVentilation.DesignLevel = rNumericArgs(4) * thisSpace.Volume / Constant::SecInHour; + thisVentilation.DesignLevel = rNumericArgs(4) * thisSpace.Volume / Constant::rSecsInHour; if (thisSpace.Volume <= 0.0) { ShowWarningError(state, format("{}{}=\"{}\", {} specifies {}, but Space Volume = 0. 0 Ventilation will result.", @@ -1591,6 +1552,7 @@ void GetSimpleAirModelInputs(EnergyPlusData &state, bool &ErrorsFound) // IF err } else { thisVentilation.MinIndoorTemperature = -VentilTempLimit; } + // Ventilation(Loop)%MinIndoorTemperature = rNumericArgs(11) if ((thisVentilation.MinIndoorTemperature < -VentilTempLimit) || (thisVentilation.MinIndoorTemperature > VentilTempLimit)) { if (Item1 == 1) { @@ -1605,57 +1567,29 @@ void GetSimpleAirModelInputs(EnergyPlusData &state, bool &ErrorsFound) // IF err } } - thisVentilation.MinIndoorTempSchedPtr = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(6)); - if (thisVentilation.MinIndoorTempSchedPtr > 0) { - if (Item1 == 1) { - if (!lNumericFieldBlanks(11)) - ShowWarningError(state, - format("{}The Minimum Indoor Temperature value and schedule are provided. The scheduled temperature " - "will be used in the {} object = {}", - RoutineName, - cCurrentModuleObject, - cAlphaArgs(1))); - // Check min and max values in the schedule to ensure both values are within the range - if (!ScheduleManager::CheckScheduleValueMinMax( - state, thisVentilation.MinIndoorTempSchedPtr, ">=", -VentilTempLimit, "<=", VentilTempLimit)) { - ShowSevereError( - state, - format( - "{}{} statement = {} must have a minimum indoor temperature between -100C and 100C defined in the schedule = {}", - RoutineName, - cCurrentModuleObject, - cAlphaArgs(1), - cAlphaArgs(6))); - ErrorsFound = true; - } - } + if (!lAlphaFieldBlanks(6)) { + thisVentilation.minIndoorTempSched = Sched::GetSchedule(state, cAlphaArgs(6)); } - if (thisVentilation.MinIndoorTempSchedPtr == 0 && lNumericFieldBlanks(11) && (!lAlphaFieldBlanks(6))) { - if (Item1 == 1) { - ShowWarningError( - state, - format("{}{}: the value field is blank and schedule field is invalid. The default value will be used ({:.1R}) ", - RoutineName, - cNumericFieldNames(11), - -VentilTempLimit)); - ShowContinueError(state, - format("in the {} object = {} and the simulation continues...", cCurrentModuleObject, cAlphaArgs(1))); - } - } - // Check Minimum indoor temperature value and schedule fields - if (!lNumericFieldBlanks(11) && (!cAlphaArgs(6).empty() && thisVentilation.MinIndoorTempSchedPtr == 0)) { - if (Item1 == 1) { - ShowWarningError(state, - format("{}{} = {} is invalid. The constant value will be used at {:.1R} degrees C ", - RoutineName, - cAlphaFieldNames(6), - cAlphaArgs(6), - rNumericArgs(11))); - ShowContinueError(state, - format("in the {} object = {} and the simulation continues...", cCurrentModuleObject, cAlphaArgs(1))); + + if (Item1 == 1) { // Item check prevents this error from printing multiple times + if (lAlphaFieldBlanks(6)) { + if (lNumericFieldBlanks(11)) { + // ShowWarningEmptyField(state, eoh, cNumericFieldNames(11), format("The default value will be used ({:.1R})", -VentilTempLimit)); + } + } else if (thisVentilation.minIndoorTempSched == nullptr) { + ShowWarningItemNotFound(state, eoh, cAlphaFieldNames(6), cAlphaArgs(6), + format("The default value will be used ({:.1R})", thisVentilation.MinIndoorTemperature)); + } else if (!thisVentilation.minIndoorTempSched->checkMinMaxVals(state, Clusive::In, -VentilTempLimit, + Clusive::In, VentilTempLimit)) { + Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(6), cAlphaArgs(6), + Clusive::In, -VentilTempLimit, Clusive::In, VentilTempLimit); + ErrorsFound = true; + } else if (!lNumericFieldBlanks(11)) { + ShowWarningCustom(state, eoh, format("Both {} and {} provided, {} will be used.", + cAlphaFieldNames(6), cAlphaFieldNames(11), cAlphaFieldNames(6))); } } - + thisVentilation.MaxIndoorTemperature = !lNumericFieldBlanks(12) ? rNumericArgs(12) : VentilTempLimit; if ((thisVentilation.MaxIndoorTemperature < -VentilTempLimit) || (thisVentilation.MaxIndoorTemperature > VentilTempLimit)) { if (Item1 == 1) { @@ -1668,104 +1602,50 @@ void GetSimpleAirModelInputs(EnergyPlusData &state, bool &ErrorsFound) // IF err } } - thisVentilation.MaxIndoorTempSchedPtr = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(7)); - if (thisVentilation.MaxIndoorTempSchedPtr > 0) { - if (Item1 == 1) { - if (!lNumericFieldBlanks(12)) - ShowWarningError(state, - format("{}The Maximum Indoor Temperature value and schedule are provided. The scheduled temperature " - "will be used in the {} object = {}", - RoutineName, - cCurrentModuleObject, - cAlphaArgs(1))); - // Check min and max values in the schedule to ensure both values are within the range - if (!ScheduleManager::CheckScheduleValueMinMax( - state, thisVentilation.MaxIndoorTempSchedPtr, ">=", -VentilTempLimit, "<=", VentilTempLimit)) { - ShowSevereError( - state, - format("{} = {} must have a maximum indoor temperature between -100C and 100C defined in the schedule = {}", - cCurrentModuleObject, - cAlphaArgs(1), - cAlphaArgs(7))); - ErrorsFound = true; - } - } - } - if (thisVentilation.MaxIndoorTempSchedPtr == 0 && lNumericFieldBlanks(12) && (!lAlphaFieldBlanks(7))) { - if (Item1 == 1) { - ShowWarningError( - state, - format("{}{}: the value field is blank and schedule field is invalid. The default value will be used ({:.1R}) ", - RoutineName, - cNumericFieldNames(12), - VentilTempLimit)); - ShowContinueError(state, - format("in the {} object = {} and the simulation continues...", cCurrentModuleObject, cAlphaArgs(1))); - } + if (!lAlphaFieldBlanks(7)) { + thisVentilation.maxIndoorTempSched = Sched::GetSchedule(state, cAlphaArgs(7)); } - // Check Maximum indoor temperature value and schedule fields - if (!lNumericFieldBlanks(12) && ((!lAlphaFieldBlanks(7)) && thisVentilation.MaxIndoorTempSchedPtr == 0)) { - if (Item1 == 1) { - ShowWarningError(state, - format("{}{} = {} is invalid. The constant value will be used at {:.1R} degrees C ", - RoutineName, - cAlphaFieldNames(7), - cAlphaArgs(7), - rNumericArgs(12))); - ShowContinueError(state, - format("in the {} object = {} and the simulation continues...", cCurrentModuleObject, cAlphaArgs(1))); + + if (Item1 == 1) { // Item check prevents this error from printing multiple times + if (lAlphaFieldBlanks(7)) { + if (lNumericFieldBlanks(12)) { + // ShowWarningEmptyField(state, eoh, cNumericFieldNames(12), format("The default value will be used ({:.1R})", VentilTempLimit)); + } + } else if (thisVentilation.maxIndoorTempSched == nullptr) { + ShowWarningItemNotFound(state, eoh, cAlphaFieldNames(7), cAlphaArgs(7), + format("The default value will be used ({:.1R})", thisVentilation.MaxIndoorTemperature)); + } else if (!thisVentilation.maxIndoorTempSched->checkMinMaxVals(state, Clusive::In, -VentilTempLimit, + Clusive::In, VentilTempLimit)) { + Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(7), cAlphaArgs(7), + Clusive::In, -VentilTempLimit, Clusive::In, VentilTempLimit); + ErrorsFound = true; + } else if (!lNumericFieldBlanks(12)) { + ShowWarningCustom(state, eoh, format("Both {} and {} provided, {} will be used.", + cAlphaFieldNames(7), cAlphaFieldNames(12), cAlphaFieldNames(7))); } } thisVentilation.DelTemperature = !lNumericFieldBlanks(13) ? rNumericArgs(13) : -VentilTempLimit; // Ventilation(Loop)%DelTemperature = rNumericArgs(13) ! 3/12/03 Negative del temp now allowed COP - thisVentilation.DeltaTempSchedPtr = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(8)); - if (thisVentilation.DeltaTempSchedPtr > 0) { - if (Item1 == 1) { - if (!lNumericFieldBlanks(13)) - ShowWarningError(state, - format("{}The Delta Temperature value and schedule are provided. The scheduled temperature will be used " - "in the {} object = {}", - RoutineName, - cCurrentModuleObject, - cAlphaArgs(1))); - // Check min value in the schedule to ensure both values are within the range - if (ScheduleManager::GetScheduleMinValue(state, thisVentilation.DeltaTempSchedPtr) < -VentilTempLimit) { - ShowSevereError( - state, - format("{}{} statement = {} must have a delta temperature equal to or above -100C defined in the schedule = {}", - RoutineName, - cCurrentModuleObject, - cAlphaArgs(1), - cAlphaArgs(8))); - ErrorsFound = true; - } - } - } - if (thisVentilation.DeltaTempSchedPtr == 0 && lNumericFieldBlanks(13) && (!lAlphaFieldBlanks(8))) { - if (Item1 == 1) { - ShowWarningError( - state, - format("{}{}: the value field is blank and schedule field is invalid. The default value will be used ({:.1R}) ", - RoutineName, - cNumericFieldNames(13), - VentilTempLimit)); - ShowContinueError(state, - format("in the {} object = {} and the simulation continues...", cCurrentModuleObject, cAlphaArgs(1))); - } + if (!lAlphaFieldBlanks(8)) { + thisVentilation.deltaTempSched = Sched::GetSchedule(state, cAlphaArgs(8)); } - if (!lNumericFieldBlanks(13) && ((!lAlphaFieldBlanks(8)) && thisVentilation.DeltaTempSchedPtr == 0)) { - if (Item1 == 1) { - ShowWarningError(state, - format("{}{} = {} is invalid. The constant value will be used at {:.1R} degrees C ", - RoutineName, - cAlphaFieldNames(8), - cAlphaArgs(8), - rNumericArgs(13))); - ShowContinueError(state, - format("in the {} object = {} and the simulation continues...", cCurrentModuleObject, cAlphaArgs(1))); + if (Item1 == 1) { // Item check prevents this error from printing multiple times + if (lAlphaFieldBlanks(8)) { + if (lNumericFieldBlanks(13)) { + // ShowWarningEmptyField(state, eoh, cNumericFieldNames(13), format("The default value will be used ({:.1R})", VentilTempLimit)); + } + } else if (thisVentilation.deltaTempSched == nullptr) { + ShowWarningItemNotFound(state, eoh, cAlphaFieldNames(8), cAlphaArgs(8), + format("The default value will be used ({:.1R})", thisVentilation.DelTemperature)); + } else if (!thisVentilation.deltaTempSched->checkMinVal(state, Clusive::In, -VentilTempLimit)) { + Sched::ShowSevereBadMin(state, eoh, cAlphaFieldNames(8), cAlphaArgs(8), Clusive::In, -100); + ErrorsFound = true; + } else if (!lNumericFieldBlanks(13)) { + ShowWarningCustom(state, eoh, format("Both {} and {} provided, {} will be used.", + cAlphaFieldNames(8), cAlphaFieldNames(13), cAlphaFieldNames(8))); } } @@ -1782,52 +1662,30 @@ void GetSimpleAirModelInputs(EnergyPlusData &state, bool &ErrorsFound) // IF err } } - thisVentilation.MinOutdoorTempSchedPtr = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(9)); - if (Item1 == 1) { - if (thisVentilation.MinOutdoorTempSchedPtr > 0) { - if (!lNumericFieldBlanks(14)) - ShowWarningError(state, - format("{}The Minimum Outdoor Temperature value and schedule are provided. The scheduled temperature " - "will be used in the {} object = {}", - RoutineName, - cCurrentModuleObject, - cAlphaArgs(1))); - // Check min and max values in the schedule to ensure both values are within the range - if (!ScheduleManager::CheckScheduleValueMinMax( - state, thisVentilation.MinOutdoorTempSchedPtr, ">=", -VentilTempLimit, "<=", VentilTempLimit)) { - ShowSevereError( - state, - format( - "{}{} statement = {} must have a minimum outdoor temperature between -100C and 100C defined in the schedule = {}", - RoutineName, - cCurrentModuleObject, - cAlphaArgs(1), - cAlphaArgs(9))); - ErrorsFound = true; + if (!lAlphaFieldBlanks(9)) { + thisVentilation.minOutdoorTempSched = Sched::GetSchedule(state, cAlphaArgs(9)); + } + + if (Item1 == 1) { // Item check prevents this error from printing multiple times + if (lAlphaFieldBlanks(9)) { + if (lNumericFieldBlanks(14)) { + // ShowWarningEmptyField(state, eoh, cNumericFieldNames(14), format("The default value will be used ({:.1R})", VentilTempLimit)); } - } - if (thisVentilation.MinOutdoorTempSchedPtr == 0 && lNumericFieldBlanks(14) && (!lAlphaFieldBlanks(9))) { - ShowWarningError(state, - format("{}Minimum Outdoor Temperature: the value field is blank and schedule field is invalid. The " - "default value will be used ({:.1R}) ", - RoutineName, - -VentilTempLimit)); - ShowContinueError(state, - format("in the {} object = {} and the simulation continues...", cCurrentModuleObject, cAlphaArgs(1))); - } - // Check Minimum outdoor temperature value and schedule fields - if (!lNumericFieldBlanks(14) && ((!lAlphaFieldBlanks(9)) && thisVentilation.MinOutdoorTempSchedPtr == 0)) { - ShowWarningError(state, - format("{}{} = {} is invalid. The constant value will be used at {:.1R} degrees C ", - RoutineName, - cAlphaFieldNames(9), - cAlphaArgs(9), - rNumericArgs(14))); - ShowContinueError(state, - format("in the {} object = {} and the simulation continues...", cCurrentModuleObject, cAlphaArgs(1))); + } else if (thisVentilation.minOutdoorTempSched == nullptr) { + ShowWarningItemNotFound(state, eoh, cAlphaFieldNames(9), cAlphaArgs(9), + format("The default value will be used ({:.1R})", thisVentilation.MinOutdoorTemperature)); + } else if (!thisVentilation.minOutdoorTempSched->checkMinMaxVals(state, Clusive::In, -VentilTempLimit, + Clusive::In, VentilTempLimit)) { + Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(9), cAlphaArgs(9), Clusive::In, -VentilTempLimit, + Clusive::In, VentilTempLimit); + ErrorsFound = true; + } else if (!lNumericFieldBlanks(14)) { + ShowWarningCustom(state, eoh, format("Both {} and {} provided, {} will be used.", + cAlphaFieldNames(9), cNumericFieldNames(14), cAlphaFieldNames(9))); } } + thisVentilation.MaxOutdoorTemperature = !lNumericFieldBlanks(15) ? rNumericArgs(15) : VentilTempLimit; if (Item1 == 1) { if ((thisVentilation.MaxOutdoorTemperature < -VentilTempLimit) || (thisVentilation.MaxOutdoorTemperature > VentilTempLimit)) { @@ -1841,52 +1699,29 @@ void GetSimpleAirModelInputs(EnergyPlusData &state, bool &ErrorsFound) // IF err } } - thisVentilation.MaxOutdoorTempSchedPtr = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(10)); - if (Item1 == 1) { - if (thisVentilation.MaxOutdoorTempSchedPtr > 0) { - if (!lNumericFieldBlanks(15)) - ShowWarningError(state, - format("{}The Maximum Outdoor Temperature value and schedule are provided. The scheduled temperature " - "will be used in the {} object = {}", - RoutineName, - cCurrentModuleObject, - cAlphaArgs(1))); - if (!ScheduleManager::CheckScheduleValueMinMax( - state, thisVentilation.MaxOutdoorTempSchedPtr, ">=", -VentilTempLimit, "<=", VentilTempLimit)) { - ShowSevereError( - state, - format( - "{}{} statement = {} must have a maximum outdoor temperature between -100C and 100C defined in the schedule = {}", - RoutineName, - cCurrentModuleObject, - cAlphaArgs(1), - cAlphaArgs(10))); - ErrorsFound = true; + if (!lAlphaFieldBlanks(10)) { + thisVentilation.maxOutdoorTempSched = Sched::GetSchedule(state, cAlphaArgs(10)); + } + + if (Item1 == 1) { // Item check prevents this error from printing multiple times + if (lAlphaFieldBlanks(10)) { + if (lNumericFieldBlanks(15)) { + // ShowWarningEmptyField(state, eoh, cNumericFieldNames(15), format("The default value will be used ({:.1R})", VentilTempLimit)); } - } - if (thisVentilation.MaxOutdoorTempSchedPtr == 0 && lNumericFieldBlanks(15) && (!lAlphaFieldBlanks(10))) { - ShowWarningError( - state, - format("{}{}: the value field is blank and schedule field is invalid. The default value will be used ({:.1R}) ", - RoutineName, - cNumericFieldNames(15), - VentilTempLimit)); - ShowContinueError(state, - format("in the {} object = {} and the simulation continues...", cCurrentModuleObject, cAlphaArgs(1))); - } - // Check Maximum outdoor temperature value and schedule fields - if (!lNumericFieldBlanks(15) && ((!lAlphaFieldBlanks(10)) && thisVentilation.MaxOutdoorTempSchedPtr == 0)) { - ShowWarningError(state, - format("{}{} = {}is invalid. The constant value will be used at {:.1R} degrees C ", - RoutineName, - cAlphaFieldNames(10), - cAlphaArgs(10), - rNumericArgs(15))); - ShowContinueError(state, - format("in the {} object = {} and the simulation continues...", cCurrentModuleObject, cAlphaArgs(1))); + } else if (thisVentilation.maxOutdoorTempSched == nullptr) { + ShowWarningItemNotFound(state, eoh, cAlphaFieldNames(10), cAlphaArgs(10), + format("The default value will be used ({:.1R})", thisVentilation.MaxOutdoorTemperature)); + } else if (!thisVentilation.maxOutdoorTempSched->checkMinMaxVals(state, Clusive::In, -VentilTempLimit, + Clusive::In, VentilTempLimit)) { + Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(10), cAlphaArgs(10), Clusive::In, -VentilTempLimit, + Clusive::In, VentilTempLimit); + ErrorsFound = true; + } else if (!lNumericFieldBlanks(15)) { + ShowWarningCustom(state, eoh, format("Both {} and {} provided, {} will be used.", + cAlphaFieldNames(10), cNumericFieldNames(15), cAlphaFieldNames(15))); } } - + thisVentilation.MaxWindSpeed = !lNumericFieldBlanks(16) ? rNumericArgs(16) : VentilWSLimit; if (Item1 == 1) { if ((thisVentilation.MaxWindSpeed < -VentilWSLimit) || (thisVentilation.MaxWindSpeed > VentilWSLimit)) { @@ -2047,6 +1882,8 @@ void GetSimpleAirModelInputs(EnergyPlusData &state, bool &ErrorsFound) // IF err cAlphaFieldNames, cNumericFieldNames); + ErrorObjectHeader eoh{routineName, cCurrentModuleObject, cAlphaArgs(1)}; + auto &thisVentilationInput = ventilationWindStackObjects(ventInputNum); for (int Item1 = 1; Item1 <= thisVentilationInput.numOfSpaces; ++Item1) { ++ventilationNum; @@ -2067,19 +1904,10 @@ void GetSimpleAirModelInputs(EnergyPlusData &state, bool &ErrorsFound) // IF err } if (lAlphaFieldBlanks(3)) { - thisVentilation.OpenAreaSchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - thisVentilation.OpenAreaSchedPtr = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(3)); - if (thisVentilation.OpenAreaSchedPtr == 0) { - ShowSevereError(state, - format("{}{}=\"{}\", invalid (not found) {}=\"{}\".", - RoutineName, - cCurrentModuleObject, - cAlphaArgs(1), - cAlphaFieldNames(3), - cAlphaArgs(3))); - ErrorsFound = true; - } + thisVentilation.openAreaSched = Sched::GetScheduleAlwaysOn(state); + } else if ((thisVentilation.openAreaSched = Sched::GetSchedule(state, cAlphaArgs(3))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(3), cAlphaArgs(3)); + ErrorsFound = true; } thisVentilation.OpenEff = rNumericArgs(2); @@ -2129,145 +1957,86 @@ void GetSimpleAirModelInputs(EnergyPlusData &state, bool &ErrorsFound) // IF err ErrorsFound = true; } - thisVentilation.MinIndoorTempSchedPtr = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(4)); - if (thisVentilation.MinIndoorTempSchedPtr > 0) { - if (!lNumericFieldBlanks(6)) - ShowWarningError(state, - format("{}The Minimum Indoor Temperature value and schedule are provided. The scheduled temperature will be " - "used in the {} object = {}", - RoutineName, - cCurrentModuleObject, - cAlphaArgs(1))); - // Check min and max values in the schedule to ensure both values are within the range - if (!ScheduleManager::CheckScheduleValueMinMax( - state, thisVentilation.MinIndoorTempSchedPtr, ">=", -VentilTempLimit, "<=", VentilTempLimit)) { - ShowSevereError( - state, - format("{}{} statement = {} must have a minimum indoor temperature between -100C and 100C defined in the schedule = {}", - RoutineName, - cCurrentModuleObject, - cAlphaArgs(1), - cAlphaArgs(4))); - ErrorsFound = true; - } - } - if (thisVentilation.MinIndoorTempSchedPtr == 0 && lNumericFieldBlanks(6) && (!lAlphaFieldBlanks(4))) { - ShowWarningError(state, - format("{}{}: the value field is blank and schedule field is invalid. The default value will be used ({:.1R}) ", - RoutineName, - cNumericFieldNames(6), - -VentilTempLimit)); - ShowContinueError(state, format("in the {} object = {} and the simulation continues...", cCurrentModuleObject, cAlphaArgs(1))); + if (!lAlphaFieldBlanks(4)) { + thisVentilation.minIndoorTempSched = Sched::GetSchedule(state, cAlphaArgs(4)); } - // Check Minimum indoor temperature value and schedule fields - if (!lNumericFieldBlanks(6) && (!cAlphaArgs(4).empty() && thisVentilation.MinIndoorTempSchedPtr == 0)) { - ShowWarningError(state, - format("{}{} = {} is invalid. The constant value will be used at {:.1R} degrees C ", - RoutineName, - cAlphaFieldNames(4), - cAlphaArgs(4), - rNumericArgs(11))); - ShowContinueError(state, format("in the {} object = {} and the simulation continues...", cCurrentModuleObject, cAlphaArgs(1))); + + if (lAlphaFieldBlanks(4)) { + if (lNumericFieldBlanks(6)) { + // ShowWarningEmptyField(state, eoh, cAlphaFieldNames(12), format("The default value will be used ({:.1R})", VentilTempLimit)); + } + } else if (thisVentilation.minIndoorTempSched == nullptr) { + ShowWarningItemNotFound(state, eoh, cAlphaFieldNames(4), cAlphaArgs(4), + format("The default value will be used ({:.1R})", thisVentilation.MinIndoorTemperature)); + } else if (!thisVentilation.minIndoorTempSched->checkMinMaxVals(state, Clusive::In, -VentilTempLimit, + Clusive::In, VentilTempLimit)) { + Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(4), cAlphaArgs(4), + Clusive::In, -VentilTempLimit, Clusive::In, VentilTempLimit); + ErrorsFound = true; + } else if (!lNumericFieldBlanks(6)) { + ShowWarningCustom(state, eoh, format("Both {} and {} provided, {} will be used.", + cAlphaFieldNames(4), cNumericFieldNames(6), cAlphaFieldNames(4))); } + // Max indoor temperature if (!lNumericFieldBlanks(7)) { thisVentilation.MaxIndoorTemperature = rNumericArgs(7); } else { thisVentilation.MaxIndoorTemperature = VentilTempLimit; } if ((thisVentilation.MaxIndoorTemperature < -VentilTempLimit) || (thisVentilation.MaxIndoorTemperature > VentilTempLimit)) { - ShowSevereError(state, - format("{}{}=\"{}\" must have a maximum indoor temperature between -100C and 100C", - RoutineName, - cCurrentModuleObject, - cAlphaArgs(1))); + ShowSevereCustom(state, eoh, format("{} must be between {}C and {}C", cNumericFieldNames(7), -VentilTempLimit, VentilTempLimit)); ErrorsFound = true; } - thisVentilation.MaxIndoorTempSchedPtr = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(5)); - if (thisVentilation.MaxIndoorTempSchedPtr > 0) { - if (!lNumericFieldBlanks(7)) - ShowWarningError(state, - format("{}The Maximum Indoor Temperature value and schedule are provided. The scheduled temperature will be " - "used in the {} object = {}", - RoutineName, - cCurrentModuleObject, - cAlphaArgs(1))); - // Check min and max values in the schedule to ensure both values are within the range - if (!ScheduleManager::CheckScheduleValueMinMax( - state, thisVentilation.MaxIndoorTempSchedPtr, ">=", -VentilTempLimit, "<=", VentilTempLimit)) { - ShowSevereError(state, - format("{} = {} must have a maximum indoor temperature between -100C and 100C defined in the schedule = {}", - cCurrentModuleObject, - cAlphaArgs(1), - cAlphaArgs(5))); - ErrorsFound = true; - } + if (!lAlphaFieldBlanks(5)) { + thisVentilation.maxIndoorTempSched = Sched::GetSchedule(state, cAlphaArgs(5)); } - if (thisVentilation.MaxIndoorTempSchedPtr == 0 && lNumericFieldBlanks(7) && (!lAlphaFieldBlanks(5))) { - ShowWarningError(state, - format("{}{}: the value field is blank and schedule field is invalid. The default value will be used ({:.1R}) ", - RoutineName, - cNumericFieldNames(7), - VentilTempLimit)); - ShowContinueError(state, format("in the {} object = {} and the simulation continues...", cCurrentModuleObject, cAlphaArgs(1))); - } - // Check Maximum indoor temperature value and schedule fields - if (!lNumericFieldBlanks(7) && ((!lAlphaFieldBlanks(5)) && thisVentilation.MaxIndoorTempSchedPtr == 0)) { - ShowWarningError(state, - format("{}{} = {} is invalid. The constant value will be used at {:.1R} degrees C ", - RoutineName, - cAlphaFieldNames(7), - cAlphaArgs(5), - rNumericArgs(7))); - ShowContinueError(state, format("in the {} object = {} and the simulation continues...", cCurrentModuleObject, cAlphaArgs(1))); + + if (lAlphaFieldBlanks(5)) { + if (lNumericFieldBlanks(7)) { + // ShowWarningEmptyField(state, eoh, cNumericFieldNames(7), format("The default value will be used ({:.1R})", VentilTempLimit)); + } + } else if (thisVentilation.maxIndoorTempSched == nullptr) { + ShowWarningItemNotFound(state, eoh, cAlphaFieldNames(5), cAlphaArgs(5), + format("The default value will be used ({:.1R})", thisVentilation.MaxIndoorTemperature)); + } else if (!thisVentilation.maxIndoorTempSched->checkMinMaxVals(state, Clusive::In, -VentilTempLimit, + Clusive::In, VentilTempLimit)) { + Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(5), cAlphaArgs(5), + Clusive::In, -VentilTempLimit, Clusive::In, VentilTempLimit); + ErrorsFound = true; + } else if (!lNumericFieldBlanks(7)) { + ShowWarningCustom(state, eoh, format("Both {} and {} provided, {} will be used.", + cAlphaFieldNames(5), cNumericFieldNames(7), cAlphaFieldNames(5))); } + if (!lNumericFieldBlanks(8)) { thisVentilation.DelTemperature = rNumericArgs(8); } else { thisVentilation.DelTemperature = -VentilTempLimit; } - thisVentilation.DeltaTempSchedPtr = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(6)); - if (thisVentilation.DeltaTempSchedPtr > 0) { - if (!lNumericFieldBlanks(8)) - ShowWarningError(state, - format("{}The Delta Temperature value and schedule are provided. The scheduled temperature will be used in " - "the {} object = {}", - RoutineName, - cCurrentModuleObject, - cAlphaArgs(1))); - // Check min value in the schedule to ensure both values are within the range - if (ScheduleManager::GetScheduleMinValue(state, thisVentilation.DeltaTempSchedPtr) < -VentilTempLimit) { - ShowSevereError( - state, - format("{}{} statement = {} must have a delta temperature equal to or above -100C defined in the schedule = {}", - RoutineName, - cCurrentModuleObject, - cAlphaArgs(1), - cAlphaArgs(8))); - ErrorsFound = true; - } + if (!lAlphaFieldBlanks(6)) { + thisVentilation.deltaTempSched = Sched::GetSchedule(state, cAlphaArgs(6)); } - if (thisVentilation.DeltaTempSchedPtr == 0 && lNumericFieldBlanks(8) && (!lAlphaFieldBlanks(6))) { - ShowWarningError(state, - format("{}{}: the value field is blank and schedule field is invalid. The default value will be used ({:.1R}) ", - RoutineName, - cNumericFieldNames(8), - VentilTempLimit)); - ShowContinueError(state, format("in the {} object = {} and the simulation continues...", cCurrentModuleObject, cAlphaArgs(1))); - } - if (!lNumericFieldBlanks(8) && ((!lAlphaFieldBlanks(6)) && thisVentilation.DeltaTempSchedPtr == 0)) { - ShowWarningError(state, - format("{}{} = {} is invalid. The constant value will be used at {:.1R} degrees C ", - RoutineName, - cAlphaFieldNames(6), - cAlphaArgs(6), - rNumericArgs(8))); - ShowContinueError(state, format("in the {} object = {} and the simulation continues...", cCurrentModuleObject, cAlphaArgs(1))); + + if (lAlphaFieldBlanks(6)) { + if (lNumericFieldBlanks(8)) { + // ShowWarningEmptyField(state, eoh, cNumericFieldNames(8), format("The default value will be used ({:.1R})", VentilTempLimit)); + } + } else if (thisVentilation.deltaTempSched == nullptr) { + ShowWarningItemNotFound(state, eoh, cAlphaFieldNames(6), cAlphaArgs(6), + format("The default value will be used ({:.1R})", thisVentilation.DelTemperature)); + } else if (!thisVentilation.deltaTempSched->checkMinVal(state, Clusive::In, -VentilTempLimit)) { + Sched::ShowSevereBadMin(state, eoh, cAlphaFieldNames(6), cAlphaArgs(6), Clusive::In, -VentilTempLimit); + ErrorsFound = true; + } else if (!lNumericFieldBlanks(8)) { + ShowWarningCustom(state, eoh, format("Both {} and {} provided, {} will be used.", + cAlphaFieldNames(6), cNumericFieldNames(8), cAlphaFieldNames(6))); } + // Min outdoor temp thisVentilation.MinOutdoorTemperature = !lNumericFieldBlanks(9) ? rNumericArgs(9) : -VentilTempLimit; if ((thisVentilation.MinOutdoorTemperature < -VentilTempLimit) || (thisVentilation.MinOutdoorTemperature > VentilTempLimit)) { ShowSevereError(state, @@ -2279,48 +2048,28 @@ void GetSimpleAirModelInputs(EnergyPlusData &state, bool &ErrorsFound) // IF err ErrorsFound = true; } - thisVentilation.MinOutdoorTempSchedPtr = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(7)); - if (thisVentilation.MinOutdoorTempSchedPtr > 0) { - if (!lNumericFieldBlanks(9)) - ShowWarningError(state, - format("{}The Minimum Outdoor Temperature value and schedule are provided. The scheduled temperature will " - "be used in the {} object = {}", - RoutineName, - cCurrentModuleObject, - cAlphaArgs(1))); - // Check min and max values in the schedule to ensure both values are within the range - if (!ScheduleManager::CheckScheduleValueMinMax( - state, thisVentilation.MinOutdoorTempSchedPtr, ">=", -VentilTempLimit, "<=", VentilTempLimit)) { - ShowSevereError( - state, - format("{}{} statement = {} must have a minimum outdoor temperature between -100C and 100C defined in the schedule = {}", - RoutineName, - cCurrentModuleObject, - cAlphaArgs(1), - cAlphaArgs(7))); - ErrorsFound = true; - } - } - if (thisVentilation.MinOutdoorTempSchedPtr == 0 && lNumericFieldBlanks(9) && (!lAlphaFieldBlanks(7))) { - ShowWarningError( - state, - format("{}Minimum Outdoor Temperature: the value field is blank and schedule field is invalid. The default value " - "will be used ({:.1R}) ", - RoutineName, - -VentilTempLimit)); - ShowContinueError(state, format("in the {} object = {} and the simulation continues...", cCurrentModuleObject, cAlphaArgs(1))); + if (!lAlphaFieldBlanks(7)) { + thisVentilation.minOutdoorTempSched = Sched::GetSchedule(state, cAlphaArgs(7)); } - // Check Minimum outdoor temperature value and schedule fields - if (!lNumericFieldBlanks(9) && ((!lAlphaFieldBlanks(7)) && thisVentilation.MinOutdoorTempSchedPtr == 0)) { - ShowWarningError(state, - format("{}{} = {} is invalid. The constant value will be used at {:.1R} degrees C ", - RoutineName, - cAlphaFieldNames(7), - cAlphaArgs(7), - rNumericArgs(14))); - ShowContinueError(state, format("in the {} object = {} and the simulation continues...", cCurrentModuleObject, cAlphaArgs(1))); + + if (lAlphaFieldBlanks(7)) { + if (lNumericFieldBlanks(9)) { + // ShowWarningEmptyField(state, eoh, cNumericFieldNames(9), format("The default value will be used ({:.1R})", VentilTempLimit)); + } + } else if (thisVentilation.minOutdoorTempSched == nullptr) { + ShowWarningItemNotFound(state, eoh, cAlphaFieldNames(7), cAlphaArgs(7), + format("The default value will be used ({:.1R})", thisVentilation.MinOutdoorTemperature)); + } else if (!thisVentilation.minOutdoorTempSched->checkMinMaxVals(state, Clusive::In, -VentilTempLimit, + Clusive::In, VentilTempLimit)) { + Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(7), cAlphaArgs(7), Clusive::In, -VentilTempLimit, + Clusive::In, VentilTempLimit); + ErrorsFound = true; + } else if (!lNumericFieldBlanks(9)) { + ShowWarningCustom(state, eoh, format("Both {} and {} provided, {} will be used.", + cAlphaFieldNames(7), cNumericFieldNames(9), cAlphaFieldNames(7))); } + // Max outdoor temp thisVentilation.MaxOutdoorTemperature = !lNumericFieldBlanks(10) ? rNumericArgs(10) : VentilTempLimit; if ((thisVentilation.MaxOutdoorTemperature < -VentilTempLimit) || (thisVentilation.MaxOutdoorTemperature > VentilTempLimit)) { ShowSevereError(state, @@ -2332,46 +2081,28 @@ void GetSimpleAirModelInputs(EnergyPlusData &state, bool &ErrorsFound) // IF err ErrorsFound = true; } - thisVentilation.MaxOutdoorTempSchedPtr = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(8)); - if (thisVentilation.MaxOutdoorTempSchedPtr > 0) { - if (!lNumericFieldBlanks(10)) - ShowWarningError(state, - format("{}The Maximum Outdoor Temperature value and schedule are provided. The scheduled temperature will " - "be used in the {} object = {}", - RoutineName, - cCurrentModuleObject, - cAlphaArgs(1))); - if (!ScheduleManager::CheckScheduleValueMinMax( - state, thisVentilation.MaxOutdoorTempSchedPtr, ">=", -VentilTempLimit, "<=", VentilTempLimit)) { - ShowSevereError( - state, - format("{}{} statement = {} must have a maximum outdoor temperature between -100C and 100C defined in the schedule = {}", - RoutineName, - cCurrentModuleObject, - cAlphaArgs(1), - cAlphaArgs(8))); - ErrorsFound = true; - } + if (!lAlphaFieldBlanks(8)) { + thisVentilation.maxOutdoorTempSched = Sched::GetSchedule(state, cAlphaArgs(8)); } - if (thisVentilation.MaxOutdoorTempSchedPtr == 0 && lNumericFieldBlanks(10) && (!lAlphaFieldBlanks(8))) { - ShowWarningError(state, - format("{}{}: the value field is blank and schedule field is invalid. The default value will be used ({:.1R}) ", - RoutineName, - cNumericFieldNames(10), - VentilTempLimit)); - ShowContinueError(state, format("in the {} object = {} and the simulation continues...", cCurrentModuleObject, cAlphaArgs(1))); - } - // Check Maximum outdoor temperature value and schedule fields - if (!lNumericFieldBlanks(10) && ((!lAlphaFieldBlanks(8)) && thisVentilation.MaxOutdoorTempSchedPtr == 0)) { - ShowWarningError(state, - format("{}{} = {}is invalid. The constant value will be used at {:.1R} degrees C ", - RoutineName, - cAlphaFieldNames(8), - cAlphaArgs(8), - rNumericArgs(10))); - ShowContinueError(state, format("in the {} object = {} and the simulation continues...", cCurrentModuleObject, cAlphaArgs(1))); + + if (lAlphaFieldBlanks(8)) { + if (lNumericFieldBlanks(10)) { + // ShowWarningEmptyField(state, eoh, cNumericFieldNames(10), format("The default value will be used ({:.1R})", VentilTempLimit)); + } + } else if (thisVentilation.maxOutdoorTempSched == nullptr) { + ShowWarningItemNotFound(state, eoh, cAlphaFieldNames(8), cAlphaArgs(8), + format("The default value will be used ({:.1R})", thisVentilation.MaxOutdoorTemperature)); + } else if (!thisVentilation.maxOutdoorTempSched->checkMinMaxVals(state, Clusive::In, -VentilTempLimit, + Clusive::In, VentilTempLimit)) { + Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(8), cAlphaArgs(8), Clusive::In, -VentilTempLimit, + Clusive::In, VentilTempLimit); + ErrorsFound = true; + } else if (!lNumericFieldBlanks(10)) { + ShowWarningCustom(state, eoh, format("Both {} and {} provided, {} will be used.", + cAlphaFieldNames(8), cNumericFieldNames(10), cAlphaFieldNames(8))); } + // Max wind speed thisVentilation.MaxWindSpeed = !lNumericFieldBlanks(11) ? rNumericArgs(11) : VentilWSLimit; if ((thisVentilation.MaxWindSpeed < -VentilWSLimit) || (thisVentilation.MaxWindSpeed > VentilWSLimit)) { ShowSevereError(state, @@ -2547,6 +2278,7 @@ void GetSimpleAirModelInputs(EnergyPlusData &state, bool &ErrorsFound) // IF err cAlphaFieldNames, cNumericFieldNames); + ErrorObjectHeader eoh{routineName, cCurrentModuleObject, cAlphaArgs(1)}; // Create one Mixing instance for every space associated with this input object auto const &thisMixingInput = zoneMixingInputObjects(mixingInputNum); for (int Item1 = 1; Item1 <= thisMixingInput.numOfSpaces; ++Item1) { @@ -2559,23 +2291,14 @@ void GetSimpleAirModelInputs(EnergyPlusData &state, bool &ErrorsFound) // IF err auto &thisZone = state.dataHeatBal->Zone(thisSpace.zoneNum); if (lAlphaFieldBlanks(3)) { - thisMixing.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - thisMixing.SchedPtr = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(3)); - if (thisMixing.SchedPtr == 0) { - ShowWarningError(state, - format("{}{}=\"{}\", invalid (not found) {}=\"{}\"", - RoutineName, - cCurrentModuleObject, - thisMixingInput.Name, - cAlphaFieldNames(3), - cAlphaArgs(3))); - ErrorsFound = true; - } + thisMixing.sched = Sched::GetScheduleAlwaysOn(state); + } else if ((thisMixing.sched = Sched::GetSchedule(state, cAlphaArgs(3))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(3), cAlphaArgs(3)); + ErrorsFound = true; } // Mixing equipment design level calculation method - AirflowSpec flow = static_cast(getEnumValue(airflowNamesUC, cAlphaArgs(4))); // NOLINT(modernize-use-auto) + AirflowSpec flow = static_cast(getEnumValue(airflowNamesUC, cAlphaArgs(4))); switch (flow) { case AirflowSpec::Flow: case AirflowSpec::FlowPerZone: @@ -2679,7 +2402,7 @@ void GetSimpleAirModelInputs(EnergyPlusData &state, bool &ErrorsFound) // IF err case AirflowSpec::AirChanges: if (thisMixing.spaceIndex != 0) { if (rNumericArgs(4) >= 0.0) { - thisMixing.DesignLevel = rNumericArgs(4) * thisSpace.Volume / Constant::SecInHour; + thisMixing.DesignLevel = rNumericArgs(4) * thisSpace.Volume / Constant::rSecsInHour; if (thisSpace.Volume <= 0.0) { ShowWarningError(state, format("{}{}=\"{}\", {} specifies {}, but Space Volume = 0. 0 Mixing will result.", @@ -2723,230 +2446,109 @@ void GetSimpleAirModelInputs(EnergyPlusData &state, bool &ErrorsFound) // IF err thisMixing.FromZone = state.dataHeatBal->space(thisMixing.fromSpaceIndex).zoneNum; } if ((thisMixing.FromZone == 0) && (thisMixing.fromSpaceIndex == 0)) { - ShowSevereError( - state, - format("{}{} not found={} for {}={}", RoutineName, cAlphaFieldNames(5), cAlphaArgs(5), cCurrentModuleObject, cAlphaArgs(1))); + ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(5), cAlphaArgs(5)); ErrorsFound = true; } thisMixing.DeltaTemperature = rNumericArgs(5); if (NumAlpha > 5) { - thisMixing.DeltaTempSchedPtr = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(6)); - if (thisMixing.DeltaTempSchedPtr > 0) { - if (!lNumericFieldBlanks(5)) - ShowWarningError(state, - format("{}The Delta Temperature value and schedule are provided. The scheduled temperature will be used " - "in the {} object = {}", - RoutineName, - cCurrentModuleObject, - cAlphaArgs(1))); - if (ScheduleManager::GetScheduleMinValue(state, thisMixing.DeltaTempSchedPtr) < -MixingTempLimit) { - ShowSevereError( - state, - format("{}{} statement = {} must have a delta temperature equal to or above -100C defined in the schedule = {}", - RoutineName, - cCurrentModuleObject, - cAlphaArgs(1), - cAlphaArgs(6))); - ErrorsFound = true; + if (lAlphaFieldBlanks(6)) { + if (lNumericFieldBlanks(5)) { + ShowWarningCustom(state, eoh, format("{} and {} are empty, a default temperature of {:.1R}C will be used.", + cAlphaFieldNames(6), cNumericFieldNames(5), -MixingTempLimit)); } - } - } - if (thisMixing.DeltaTempSchedPtr == 0 && lNumericFieldBlanks(5) && (!lAlphaFieldBlanks(6))) { - ShowWarningError(state, - format("{}{}: the value field is blank and schedule field is invalid. The default value will be used ({:.1R}) ", - RoutineName, - cNumericFieldNames(5), - rNumericArgs(5))); - ShowContinueError(state, format("in the {} object = {} and the simulation continues...", cCurrentModuleObject, cAlphaArgs(1))); - } - if (!lNumericFieldBlanks(5) && ((!lAlphaFieldBlanks(6)) && thisMixing.DeltaTempSchedPtr == 0)) { - ShowWarningError(state, - format("{}{} = {} is invalid. The constant value will be used at {:.1R} degrees C ", - RoutineName, - cAlphaFieldNames(6), - cAlphaArgs(6), - rNumericArgs(5))); - ShowContinueError(state, format("in the {} object = {} and the simulation continues...", cCurrentModuleObject, cAlphaArgs(1))); + } else if ((thisMixing.deltaTempSched = Sched::GetSchedule(state, cAlphaArgs(6))) == nullptr) { + ShowWarningItemNotFound(state, eoh, cAlphaFieldNames(6), cAlphaArgs(6), ""); + if (lNumericFieldBlanks(5)) { + ShowContinueError(state, format("a default temperature of {:.1R}C will be used.", -MixingTempLimit)); + } + } else if (!thisMixing.deltaTempSched->checkMinVal(state, Clusive::In, -MixingTempLimit)) { + Sched::ShowSevereBadMin(state, eoh, cAlphaFieldNames(6), cAlphaArgs(6), Clusive::In, -MixingTempLimit); + ErrorsFound = true; + } else if (!lNumericFieldBlanks(5)) + ShowWarningCustom(state, eoh, format("{} and {} are provided, {} will be used.", + cAlphaFieldNames(6), cNumericFieldNames(5), cAlphaFieldNames(6))); } + // Min indoor temp if (NumAlpha > 6) { - thisMixing.MinIndoorTempSchedPtr = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(7)); - if (thisMixing.MinIndoorTempSchedPtr == 0) { - if ((!lAlphaFieldBlanks(7))) { - ShowSevereError(state, - format("{}{} not found={} for {}={}", - RoutineName, - cAlphaFieldNames(7), - cAlphaArgs(7), - cCurrentModuleObject, - cAlphaArgs(1))); - ErrorsFound = true; - } - } - if (thisMixing.MinIndoorTempSchedPtr > 0) { - // Check min and max values in the schedule to ensure both values are within the range - if (!ScheduleManager::CheckScheduleValueMinMax( - state, thisMixing.MinIndoorTempSchedPtr, ">=", -MixingTempLimit, "<=", MixingTempLimit)) { - ShowSevereError( - state, - format("{}{} statement = {} must have a minimum zone temperature between -100C and 100C defined in the schedule = {}", - RoutineName, - cCurrentModuleObject, - cAlphaArgs(1), - cAlphaArgs(7))); - ErrorsFound = true; - } + if (lAlphaFieldBlanks(7)) { + // Is this an error or is there a default? + } else if ((thisMixing.minIndoorTempSched = Sched::GetSchedule(state, cAlphaArgs(7))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(7), cAlphaArgs(7)); + ErrorsFound = true; + } else if (!thisMixing.minIndoorTempSched->checkMinMaxVals(state, Clusive::In, -MixingTempLimit, + Clusive::In, MixingTempLimit)) { + Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(7), cAlphaArgs(7), + Clusive::In, -MixingTempLimit, Clusive::In, MixingTempLimit); + ErrorsFound = true; } } + // Max indoor temp if (NumAlpha > 7) { - thisMixing.MaxIndoorTempSchedPtr = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(8)); - if (thisMixing.MaxIndoorTempSchedPtr == 0) { - if ((!lAlphaFieldBlanks(8))) { - ShowSevereError(state, - format("{}{}=\"{}\", {} not found=\"{}\".", - RoutineName, - cCurrentModuleObject, - cAlphaArgs(1), - cAlphaFieldNames(8), - cAlphaArgs(8))); - ErrorsFound = true; - } - } - if (thisMixing.MaxIndoorTempSchedPtr > 0) { - // Check min and max values in the schedule to ensure both values are within the range - if (!ScheduleManager::CheckScheduleValueMinMax( - state, thisMixing.MaxIndoorTempSchedPtr, ">=", -MixingTempLimit, "<=", MixingTempLimit)) { - ShowSevereError( - state, - format("{}{}=\"{}\" must have a maximum zone temperature between -100C and 100C defined in the schedule = {}", - RoutineName, - cCurrentModuleObject, - cAlphaArgs(1), - cAlphaArgs(8))); - ErrorsFound = true; - } + if (lAlphaFieldBlanks(8)) { + } else if ((thisMixing.maxIndoorTempSched = Sched::GetSchedule(state, cAlphaArgs(8))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(8), cAlphaArgs(8)); + ErrorsFound = true; + } else if (!thisMixing.maxIndoorTempSched->checkMinMaxVals(state, Clusive::In, -MixingTempLimit, + Clusive::In, MixingTempLimit)) { + Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(8), cAlphaArgs(8), + Clusive::In, -MixingTempLimit, Clusive::In, MixingTempLimit); + ErrorsFound = true; } } + // Min source temp if (NumAlpha > 8) { - thisMixing.MinSourceTempSchedPtr = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(9)); - if (thisMixing.MinSourceTempSchedPtr == 0) { - if ((!lAlphaFieldBlanks(9))) { - ShowSevereError(state, - format("{}{}=\"{}\", {} not found=\"{}\".", - RoutineName, - cCurrentModuleObject, - cAlphaArgs(1), - cAlphaFieldNames(9), - cAlphaArgs(9))); - ErrorsFound = true; - } - } - if (thisMixing.MinSourceTempSchedPtr > 0) { - // Check min and max values in the schedule to ensure both values are within the range - if (!ScheduleManager::CheckScheduleValueMinMax( - state, thisMixing.MinSourceTempSchedPtr, ">=", -MixingTempLimit, "<=", MixingTempLimit)) { - ShowSevereError( - state, - format("{}{}=\"{}\" must have a minimum source temperature between -100C and 100C defined in the schedule = {}", - RoutineName, - cCurrentModuleObject, - cAlphaArgs(1), - cAlphaArgs(9))); - ErrorsFound = true; - } + if (lAlphaFieldBlanks(9)) { + } else if ((thisMixing.minSourceTempSched = Sched::GetSchedule(state, cAlphaArgs(9))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(9), cAlphaArgs(9)); + ErrorsFound = true; + } else if (!thisMixing.minSourceTempSched->checkMinMaxVals(state, Clusive::In, -MixingTempLimit, + Clusive::In, MixingTempLimit)) { + Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(9), cAlphaArgs(9), + Clusive::In, -MixingTempLimit, Clusive::In, MixingTempLimit); + ErrorsFound = true; } } + // Max source temp if (NumAlpha > 9) { - thisMixing.MaxSourceTempSchedPtr = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(10)); - if (thisMixing.MaxSourceTempSchedPtr == 0) { - if ((!lAlphaFieldBlanks(10))) { - ShowSevereError(state, - format("{}{}=\"{}\", {} not found=\"{}\".", - RoutineName, - cCurrentModuleObject, - cAlphaArgs(1), - cAlphaFieldNames(10), - cAlphaArgs(10))); - ErrorsFound = true; - } - } - if (thisMixing.MaxSourceTempSchedPtr > 0) { - // Check min and max values in the schedule to ensure both values are within the range - if (!ScheduleManager::CheckScheduleValueMinMax( - state, thisMixing.MaxSourceTempSchedPtr, ">=", -MixingTempLimit, "<=", MixingTempLimit)) { - ShowSevereError(state, - format("{}{} statement =\"{}\" must have a maximum source temperature between -100C and 100C defined in " - "the schedule = {}", - RoutineName, - cCurrentModuleObject, - cAlphaArgs(1), - cAlphaArgs(10))); - ErrorsFound = true; - } + if (lAlphaFieldBlanks(10)) { + } else if ((thisMixing.maxSourceTempSched = Sched::GetSchedule(state, cAlphaArgs(10))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(10), cAlphaArgs(10)); + ErrorsFound = true; + } else if (!thisMixing.maxSourceTempSched->checkMinMaxVals(state, Clusive::In, -MixingTempLimit, Clusive::In, MixingTempLimit)) { + Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(10), cAlphaArgs(10), + Clusive::In, -MixingTempLimit, Clusive::In, MixingTempLimit); + ErrorsFound = true; } } if (NumAlpha > 10) { - thisMixing.MinOutdoorTempSchedPtr = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(11)); - if (thisMixing.MinOutdoorTempSchedPtr == 0) { - if ((!lAlphaFieldBlanks(11))) { - ShowSevereError(state, - format("{}{}=\"{}\", {} not found=\"{}\".", - RoutineName, - cCurrentModuleObject, - cAlphaArgs(1), - cAlphaFieldNames(11), - cAlphaArgs(11))); - ErrorsFound = true; - } - } - if (thisMixing.MinOutdoorTempSchedPtr > 0) { - // Check min and max values in the schedule to ensure both values are within the range - if (!ScheduleManager::CheckScheduleValueMinMax( - state, thisMixing.MinOutdoorTempSchedPtr, ">=", -MixingTempLimit, "<=", MixingTempLimit)) { - ShowSevereError( - state, - format("{}{} =\"{}\" must have a minimum outdoor temperature between -100C and 100C defined in the schedule = {}", - RoutineName, - cCurrentModuleObject, - cAlphaArgs(1), - cAlphaArgs(11))); - ErrorsFound = true; - } + if (lAlphaFieldBlanks(11)) { + } else if ((thisMixing.minOutdoorTempSched = Sched::GetSchedule(state, cAlphaArgs(11))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(11), cAlphaArgs(11)); + ErrorsFound = true; + } else if (!thisMixing.minOutdoorTempSched->checkMinMaxVals(state, Clusive::In, -MixingTempLimit, + Clusive::In, MixingTempLimit)) { + Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(11), cAlphaArgs(11), + Clusive::In, -MixingTempLimit, Clusive::In, MixingTempLimit); + ErrorsFound = true; } } + // if (NumAlpha > 11) { - thisMixing.MaxOutdoorTempSchedPtr = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(12)); - if (thisMixing.MaxOutdoorTempSchedPtr == 0) { - if ((!lAlphaFieldBlanks(12))) { - ShowSevereError(state, - format("{}{}=\"{}\", {} not found=\"{}\".", - RoutineName, - cCurrentModuleObject, - cAlphaArgs(1), - cAlphaFieldNames(12), - cAlphaArgs(12))); - ErrorsFound = true; - } - } - if (thisMixing.MaxOutdoorTempSchedPtr > 0) { - // Check min and max values in the schedule to ensure both values are within the range - if (!ScheduleManager::CheckScheduleValueMinMax( - state, thisMixing.MaxOutdoorTempSchedPtr, ">=", -MixingTempLimit, "<=", MixingTempLimit)) { - ShowSevereError( - state, - format("{}{} =\"{}\" must have a maximum outdoor temperature between -100C and 100C defined in the schedule = {}", - RoutineName, - cCurrentModuleObject, - cAlphaArgs(1), - cAlphaArgs(12))); - ErrorsFound = true; - } + if (lAlphaFieldBlanks(12)) { + } else if ((thisMixing.maxOutdoorTempSched = Sched::GetSchedule(state, cAlphaArgs(12))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(12), cAlphaArgs(12)); + ErrorsFound = true; + } else if (!thisMixing.maxOutdoorTempSched->checkMinMaxVals(state, Clusive::In, -MixingTempLimit, Clusive::In, MixingTempLimit)) { + Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(12), cAlphaArgs(12), + Clusive::In, -MixingTempLimit, Clusive::In, MixingTempLimit); + ErrorsFound = true; } } @@ -3167,6 +2769,9 @@ void GetSimpleAirModelInputs(EnergyPlusData &state, bool &ErrorsFound) // IF err lAlphaFieldBlanks, cAlphaFieldNames, cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, cCurrentModuleObject, cAlphaArgs(1)}; + // Create one Mixing instance for every space associated with this input object auto const &thisMixingInput = zoneCrossMixingInputObjects(mixingInputNum); for (int Item1 = 1; Item1 <= thisMixingInput.numOfSpaces; ++Item1) { @@ -3179,19 +2784,10 @@ void GetSimpleAirModelInputs(EnergyPlusData &state, bool &ErrorsFound) // IF err auto &thisZone = state.dataHeatBal->Zone(thisSpace.zoneNum); if (lAlphaFieldBlanks(3)) { - thisMixing.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - thisMixing.SchedPtr = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(3)); - if (thisMixing.SchedPtr == 0) { - ShowWarningError(state, - format("{}{}=\"{}\", invalid (not found) {}=\"{}\"", - RoutineName, - cCurrentModuleObject, - thisMixingInput.Name, - cAlphaFieldNames(3), - cAlphaArgs(3))); - ErrorsFound = true; - } + thisMixing.sched = Sched::GetScheduleAlwaysOn(state); + } else if ((thisMixing.sched = Sched::GetSchedule(state, cAlphaArgs(3))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(3), cAlphaArgs(3)); + ErrorsFound = true; } // Mixing equipment design level calculation method. @@ -3299,7 +2895,7 @@ void GetSimpleAirModelInputs(EnergyPlusData &state, bool &ErrorsFound) // IF err case AirflowSpec::AirChanges: if (thisMixing.spaceIndex != 0) { if (rNumericArgs(4) >= 0.0) { - thisMixing.DesignLevel = rNumericArgs(4) * thisSpace.Volume / Constant::SecInHour; + thisMixing.DesignLevel = rNumericArgs(4) * thisSpace.Volume / Constant::rSecsInHour; if (thisSpace.Volume <= 0.0) { ShowWarningError(state, format("{}{}=\"{}\", {} specifies {}, but Space Volume = 0. 0 Cross Mixing will result.", @@ -3355,225 +2951,108 @@ void GetSimpleAirModelInputs(EnergyPlusData &state, bool &ErrorsFound) // IF err thisMixing.DeltaTemperature = rNumericArgs(5); if (NumAlpha > 5) { - thisMixing.DeltaTempSchedPtr = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(6)); - if (thisMixing.DeltaTempSchedPtr > 0) { - if (!lNumericFieldBlanks(5)) - ShowWarningError(state, - format("{}The Delta Temperature value and schedule are provided. The scheduled temperature will be used " - "in the {} object = {}", - RoutineName, - cCurrentModuleObject, - cAlphaArgs(1))); - if (ScheduleManager::GetScheduleMinValue(state, thisMixing.DeltaTempSchedPtr) < 0.0) { - ShowSevereError(state, - format("{}{} = {} must have a delta temperature equal to or above 0 C defined in the schedule = {}", - RoutineName, - cCurrentModuleObject, - cAlphaArgs(1), - cAlphaArgs(6))); - ErrorsFound = true; + if (lAlphaFieldBlanks(6)) { + if (lNumericFieldBlanks(5)) { + ShowWarningCustom(state, eoh, format("{} and {} are empty, a default temperature of {:.1R}C will be used.", + cAlphaFieldNames(6), cNumericFieldNames(5), thisMixing.DeltaTemperature)); } + } else if ((thisMixing.deltaTempSched = Sched::GetSchedule(state, cAlphaArgs(6))) == nullptr) { + ShowWarningItemNotFound(state, eoh, cAlphaFieldNames(6), cAlphaArgs(6), + format("Fixed delta temperature {:.1R}C will be used", thisMixing.DeltaTemperature)); + } else if (!thisMixing.deltaTempSched->checkMinVal(state, Clusive::In, 0.0)) { + Sched::ShowSevereBadMin(state, eoh, cAlphaFieldNames(6), cAlphaArgs(6), Clusive::In, 0.0); + ErrorsFound = true; + } else if (!lNumericFieldBlanks(5)) { + ShowWarningCustom(state, eoh, format("{} and {} provided. {} will be used.", + cAlphaFieldNames(6), cNumericFieldNames(5), cAlphaFieldNames(6))); } } - if (thisMixing.DeltaTempSchedPtr == 0 && lNumericFieldBlanks(5) && (!lAlphaFieldBlanks(6))) { - ShowWarningError(state, - format("{}{}: the value field is blank and schedule field is invalid. The default value will be used ({:.1R}) ", - RoutineName, - cNumericFieldNames(5), - rNumericArgs(5))); - ShowContinueError(state, format("in {} = {} and the simulation continues...", cCurrentModuleObject, cAlphaArgs(1))); - } - if (!lNumericFieldBlanks(5) && ((!lAlphaFieldBlanks(6)) && thisMixing.DeltaTempSchedPtr == 0)) { - ShowWarningError(state, - format("{}{} = {} is invalid. The constant value will be used at {:.1R} degrees C ", - RoutineName, - cAlphaFieldNames(6), - cAlphaArgs(6), - rNumericArgs(5))); - ShowContinueError(state, format("in the {} object = {} and the simulation continues...", cCurrentModuleObject, cAlphaArgs(1))); - } + // Min indoor temp if (NumAlpha > 6) { - thisMixing.MinIndoorTempSchedPtr = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(7)); - if (thisMixing.MinIndoorTempSchedPtr == 0) { - if ((!lAlphaFieldBlanks(7))) { - ShowSevereError(state, - format("{}{}=\"{}\",{} not found={}\".", - RoutineName, - cCurrentModuleObject, - cAlphaArgs(1), - cAlphaFieldNames(7), - cAlphaArgs(7))); - ErrorsFound = true; - } - } - if (thisMixing.MinIndoorTempSchedPtr > 0) { - // Check min and max values in the schedule to ensure both values are within the range - if (!ScheduleManager::CheckScheduleValueMinMax( - state, thisMixing.MinIndoorTempSchedPtr, ">=", -MixingTempLimit, "<=", MixingTempLimit)) { - ShowSevereError( - state, - format("{}{} = {} must have a minimum zone temperature between -100C and 100C defined in the schedule = {}", - RoutineName, - cCurrentModuleObject, - cAlphaArgs(1), - cAlphaArgs(7))); - ErrorsFound = true; - } + if (lAlphaFieldBlanks(7)) { + } else if ((thisMixing.minIndoorTempSched = Sched::GetSchedule(state, cAlphaArgs(7))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(7), cAlphaArgs(7)); + ErrorsFound = true; + } else if (!thisMixing.minIndoorTempSched->checkMinMaxVals(state, Clusive::In, -MixingTempLimit, + Clusive::In, MixingTempLimit)) { + Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(7), cAlphaArgs(7), + Clusive::In, -MixingTempLimit, Clusive::In, MixingTempLimit); + ErrorsFound = true; } } + // Max indoor temp if (NumAlpha > 7) { - thisMixing.MaxIndoorTempSchedPtr = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(8)); - if (thisMixing.MaxIndoorTempSchedPtr == 0) { - if ((!lAlphaFieldBlanks(8))) { - ShowSevereError(state, - format("{}{}=\"{}\",{} not found=\"{}\".", - RoutineName, - cCurrentModuleObject, - cAlphaArgs(1), - cAlphaFieldNames(8), - cAlphaArgs(8))); - ErrorsFound = true; - } - } - if (thisMixing.MaxIndoorTempSchedPtr > 0) { - // Check min and max values in the schedule to ensure both values are within the range - if (!ScheduleManager::CheckScheduleValueMinMax( - state, thisMixing.MaxIndoorTempSchedPtr, ">=", -MixingTempLimit, "<=", MixingTempLimit)) { - ShowSevereError( - state, - format("{}{} = {} must have a maximum zone temperature between -100C and 100C defined in the schedule = {}", - RoutineName, - cCurrentModuleObject, - cAlphaArgs(1), - cAlphaArgs(8))); - ErrorsFound = true; - } + if (lAlphaFieldBlanks(8)) { + } else if ((thisMixing.maxIndoorTempSched = Sched::GetSchedule(state, cAlphaArgs(8))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(8), cAlphaArgs(8)); + ErrorsFound = true; + } else if (!thisMixing.maxIndoorTempSched->checkMinMaxVals(state, Clusive::In, -MixingTempLimit, + Clusive::In, MixingTempLimit)) { + Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(8), cAlphaArgs(8), + Clusive::In, -MixingTempLimit, Clusive::In, MixingTempLimit); + ErrorsFound = true; } } + // Min source temp if (NumAlpha > 8) { - thisMixing.MinSourceTempSchedPtr = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(9)); - if (thisMixing.MinSourceTempSchedPtr == 0) { - if ((!lAlphaFieldBlanks(9))) { - ShowSevereError(state, - format("{}{}=\"{}\",{} not found=\"{}\".", - RoutineName, - cCurrentModuleObject, - cAlphaArgs(1), - cAlphaFieldNames(9), - cAlphaArgs(9))); - ErrorsFound = true; - } - } - if (thisMixing.MinSourceTempSchedPtr > 0) { - // Check min and max values in the schedule to ensure both values are within the range - if (!ScheduleManager::CheckScheduleValueMinMax( - state, thisMixing.MinSourceTempSchedPtr, ">=", -MixingTempLimit, "<=", MixingTempLimit)) { - ShowSevereError( - state, - format("{}{} = {} must have a minimum source temperature between -100C and 100C defined in the schedule = {}", - RoutineName, - cCurrentModuleObject, - cAlphaArgs(1), - cAlphaArgs(9))); - ErrorsFound = true; - } + if (lAlphaFieldBlanks(9)) { + } else if ((thisMixing.minSourceTempSched = Sched::GetSchedule(state, cAlphaArgs(9))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(9), cAlphaArgs(9)); + ErrorsFound = true; + } else if (!thisMixing.minSourceTempSched->checkMinMaxVals(state, Clusive::In, -MixingTempLimit, + Clusive::In, MixingTempLimit)) { + Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(9), cAlphaArgs(9), + Clusive::In, -MixingTempLimit, Clusive::In, MixingTempLimit); + ErrorsFound = true; } } + // Max source temp if (NumAlpha > 9) { - thisMixing.MaxSourceTempSchedPtr = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(10)); - if (thisMixing.MaxSourceTempSchedPtr == 0) { - if ((!lAlphaFieldBlanks(10))) { - ShowSevereError(state, - format("{}{}=\"{}\",{} not found=\"{}\".", - RoutineName, - cCurrentModuleObject, - cAlphaArgs(1), - cAlphaFieldNames(10), - cAlphaArgs(9))); - ErrorsFound = true; - } - } - if (thisMixing.MaxSourceTempSchedPtr > 0) { - // Check min and max values in the schedule to ensure both values are within the range - if (!ScheduleManager::CheckScheduleValueMinMax( - state, thisMixing.MaxSourceTempSchedPtr, ">=", -MixingTempLimit, "<=", MixingTempLimit)) { - ShowSevereError( - state, - format("{}{} = {} must have a maximum source temperature between -100C and 100C defined in the schedule = {}", - RoutineName, - cCurrentModuleObject, - cAlphaArgs(1), - cAlphaArgs(10))); - ErrorsFound = true; - } + if (lAlphaFieldBlanks(10)) { + } else if ((thisMixing.maxSourceTempSched = Sched::GetSchedule(state, cAlphaArgs(10))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(10), cAlphaArgs(10)); + ErrorsFound = true; + } else if (!thisMixing.maxSourceTempSched->checkMinMaxVals(state, Clusive::In, -MixingTempLimit, + Clusive::In, MixingTempLimit)) { + Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(10), cAlphaArgs(10), + Clusive::In, -MixingTempLimit, Clusive::In, MixingTempLimit); + ErrorsFound = true; } } + // Min outdoor temp if (NumAlpha > 10) { - thisMixing.MinOutdoorTempSchedPtr = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(11)); - if (thisMixing.MinOutdoorTempSchedPtr == 0) { - if ((!lAlphaFieldBlanks(11))) { - ShowSevereError(state, - format("{}{}=\"{}\",{} not found=\"{}\".", - RoutineName, - cCurrentModuleObject, - cAlphaArgs(1), - cAlphaFieldNames(11), - cAlphaArgs(9))); - ErrorsFound = true; - } - } - if (thisMixing.MinOutdoorTempSchedPtr > 0) { - // Check min and max values in the schedule to ensure both values are within the range - if (!ScheduleManager::CheckScheduleValueMinMax( - state, thisMixing.MinOutdoorTempSchedPtr, ">=", -MixingTempLimit, "<=", MixingTempLimit)) { - ShowSevereError( - state, - format("{}{} = {} must have a minimum outdoor temperature between -100C and 100C defined in the schedule = {}", - RoutineName, - cCurrentModuleObject, - cAlphaArgs(1), - cAlphaArgs(11))); - ErrorsFound = true; - } + if (lAlphaFieldBlanks(11)) { + } else if ((thisMixing.minOutdoorTempSched = Sched::GetSchedule(state, cAlphaArgs(11))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(11), cAlphaArgs(11)); + ErrorsFound = true; + } else if (!thisMixing.minOutdoorTempSched->checkMinMaxVals(state, Clusive::In, -MixingTempLimit, + Clusive::In, MixingTempLimit)) { + Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(11), cAlphaArgs(11), + Clusive::In, -MixingTempLimit, Clusive::In, MixingTempLimit); + ErrorsFound = true; } } if (NumAlpha > 11) { - thisMixing.MaxOutdoorTempSchedPtr = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(12)); - if (thisMixing.MaxOutdoorTempSchedPtr == 0) { - if ((!lAlphaFieldBlanks(12))) { - ShowSevereError(state, - format("{}{}=\"{}\",{} not found=\"{}\".", - RoutineName, - cCurrentModuleObject, - cAlphaArgs(1), - cAlphaFieldNames(12), - cAlphaArgs(9))); - ErrorsFound = true; - } - } - if (thisMixing.MaxOutdoorTempSchedPtr > 0) { - // Check min and max values in the schedule to ensure both values are within the range - if (!ScheduleManager::CheckScheduleValueMinMax( - state, thisMixing.MaxOutdoorTempSchedPtr, ">=", -MixingTempLimit, "<=", MixingTempLimit)) { - ShowSevereError( - state, - format("{}{} = {} must have a maximum outdoor temperature between -100C and 100C defined in the schedule = {}", - RoutineName, - cCurrentModuleObject, - cAlphaArgs(1), - cAlphaArgs(12))); - ErrorsFound = true; - } + if (lAlphaFieldBlanks(12)) { + } else if ((thisMixing.maxOutdoorTempSched = Sched::GetSchedule(state, cAlphaArgs(12))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(12), cAlphaArgs(12)); + ErrorsFound = true; + } else if (!thisMixing.maxOutdoorTempSched->checkMinMaxVals(state, Clusive::In, -MixingTempLimit, + Clusive::In, MixingTempLimit)) { + Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(12), cAlphaArgs(12), + Clusive::In, -MixingTempLimit, Clusive::In, MixingTempLimit); + ErrorsFound = true; } } } - } + } // for (mixingInputNum) + // Create CrossMixing objects from air boundary info for (auto const &thisAirBoundaryMixing : state.dataHeatBal->airBoundaryMixing) { ++mixingNum; @@ -3586,7 +3065,7 @@ void GetSimpleAirModelInputs(EnergyPlusData &state, bool &ErrorsFound) // IF err thisCrossMizing.Name = fmt::format("Air Boundary Mixing Zones {} and {}", zone1, zone2); thisCrossMizing.spaceIndex = space1; thisCrossMizing.ZonePtr = zone1; - thisCrossMizing.SchedPtr = thisAirBoundaryMixing.scheduleIndex; + thisCrossMizing.sched = thisAirBoundaryMixing.sched; thisCrossMizing.DesignLevel = thisAirBoundaryMixing.mixingVolumeFlowRate; thisCrossMizing.FromZone = zone2; thisCrossMizing.fromSpaceIndex = space2; @@ -3798,6 +3277,7 @@ void GetSimpleAirModelInputs(EnergyPlusData &state, bool &ErrorsFound) // IF err cAlphaFieldNames, cNumericFieldNames); + ErrorObjectHeader eoh{routineName, cCurrentModuleObject, cAlphaArgs(1)}; NameThisObject = cAlphaArgs(1); int AlphaNum = 2; @@ -3855,72 +3335,75 @@ void GetSimpleAirModelInputs(EnergyPlusData &state, bool &ErrorsFound) // IF err spaceNumB = space1Num; } - if (!allocated(state.dataHeatBal->RefDoorMixing(ZoneNumA).OpenSchedPtr)) { - state.dataHeatBal->RefDoorMixing(ZoneNumA).DoorMixingObjectName.allocate(state.dataGlobal->NumOfZones); - state.dataHeatBal->RefDoorMixing(ZoneNumA).OpenSchedPtr.allocate(state.dataGlobal->NumOfZones); - state.dataHeatBal->RefDoorMixing(ZoneNumA).DoorHeight.allocate(state.dataGlobal->NumOfZones); - state.dataHeatBal->RefDoorMixing(ZoneNumA).DoorArea.allocate(state.dataGlobal->NumOfZones); - state.dataHeatBal->RefDoorMixing(ZoneNumA).Protection.allocate(state.dataGlobal->NumOfZones); - state.dataHeatBal->RefDoorMixing(ZoneNumA).MateZonePtr.allocate(state.dataGlobal->NumOfZones); - state.dataHeatBal->RefDoorMixing(ZoneNumA).EMSRefDoorMixingOn.allocate(state.dataGlobal->NumOfZones); - state.dataHeatBal->RefDoorMixing(ZoneNumA).EMSRefDoorFlowRate.allocate(state.dataGlobal->NumOfZones); - state.dataHeatBal->RefDoorMixing(ZoneNumA).VolRefDoorFlowRate.allocate(state.dataGlobal->NumOfZones); - state.dataHeatBal->RefDoorMixing(ZoneNumA).DoorProtTypeName.allocate(state.dataGlobal->NumOfZones); - state.dataHeatBal->RefDoorMixing(ZoneNumA).DoorMixingObjectName = ""; - state.dataHeatBal->RefDoorMixing(ZoneNumA).OpenSchedPtr = 0; - state.dataHeatBal->RefDoorMixing(ZoneNumA).DoorHeight = 0.0; - state.dataHeatBal->RefDoorMixing(ZoneNumA).DoorArea = 0.0; - state.dataHeatBal->RefDoorMixing(ZoneNumA).Protection = RefDoorNone; - state.dataHeatBal->RefDoorMixing(ZoneNumA).MateZonePtr = 0; - state.dataHeatBal->RefDoorMixing(ZoneNumA).EMSRefDoorMixingOn = false; - state.dataHeatBal->RefDoorMixing(ZoneNumA).EMSRefDoorFlowRate = 0.0; - state.dataHeatBal->RefDoorMixing(ZoneNumA).VolRefDoorFlowRate = 0.0; - state.dataHeatBal->RefDoorMixing(ZoneNumA).DoorProtTypeName = ""; + auto &zoneA = state.dataHeatBal->RefDoorMixing(ZoneNumA); + auto &zoneB = state.dataHeatBal->RefDoorMixing(ZoneNumB); + + if (!allocated(zoneA.openScheds)) { + zoneA.DoorMixingObjectName.allocate(state.dataGlobal->NumOfZones); + zoneA.openScheds.allocate(state.dataGlobal->NumOfZones); + zoneA.DoorHeight.allocate(state.dataGlobal->NumOfZones); + zoneA.DoorArea.allocate(state.dataGlobal->NumOfZones); + zoneA.Protection.allocate(state.dataGlobal->NumOfZones); + zoneA.MateZonePtr.allocate(state.dataGlobal->NumOfZones); + zoneA.EMSRefDoorMixingOn.allocate(state.dataGlobal->NumOfZones); + zoneA.EMSRefDoorFlowRate.allocate(state.dataGlobal->NumOfZones); + zoneA.VolRefDoorFlowRate.allocate(state.dataGlobal->NumOfZones); + zoneA.DoorProtTypeName.allocate(state.dataGlobal->NumOfZones); + zoneA.DoorMixingObjectName = ""; + zoneA.openScheds = nullptr; + zoneA.DoorHeight = 0.0; + zoneA.DoorArea = 0.0; + zoneA.Protection = RefDoorNone; + zoneA.MateZonePtr = 0; + zoneA.EMSRefDoorMixingOn = false; + zoneA.EMSRefDoorFlowRate = 0.0; + zoneA.VolRefDoorFlowRate = 0.0; + zoneA.DoorProtTypeName = ""; } // First refrigeration mixing in this zone - if (!allocated(state.dataHeatBal->RefDoorMixing(ZoneNumB).OpenSchedPtr)) { - state.dataHeatBal->RefDoorMixing(ZoneNumB).DoorMixingObjectName.allocate(state.dataGlobal->NumOfZones); - state.dataHeatBal->RefDoorMixing(ZoneNumB).OpenSchedPtr.allocate(state.dataGlobal->NumOfZones); - state.dataHeatBal->RefDoorMixing(ZoneNumB).DoorHeight.allocate(state.dataGlobal->NumOfZones); - state.dataHeatBal->RefDoorMixing(ZoneNumB).DoorArea.allocate(state.dataGlobal->NumOfZones); - state.dataHeatBal->RefDoorMixing(ZoneNumB).Protection.allocate(state.dataGlobal->NumOfZones); - state.dataHeatBal->RefDoorMixing(ZoneNumB).MateZonePtr.allocate(state.dataGlobal->NumOfZones); - state.dataHeatBal->RefDoorMixing(ZoneNumB).EMSRefDoorMixingOn.allocate(state.dataGlobal->NumOfZones); - state.dataHeatBal->RefDoorMixing(ZoneNumB).EMSRefDoorFlowRate.allocate(state.dataGlobal->NumOfZones); - state.dataHeatBal->RefDoorMixing(ZoneNumB).VolRefDoorFlowRate.allocate(state.dataGlobal->NumOfZones); - state.dataHeatBal->RefDoorMixing(ZoneNumB).DoorProtTypeName.allocate(state.dataGlobal->NumOfZones); - state.dataHeatBal->RefDoorMixing(ZoneNumB).DoorMixingObjectName = ""; - state.dataHeatBal->RefDoorMixing(ZoneNumB).OpenSchedPtr = 0; - state.dataHeatBal->RefDoorMixing(ZoneNumB).DoorHeight = 0.0; - state.dataHeatBal->RefDoorMixing(ZoneNumB).DoorArea = 0.0; - state.dataHeatBal->RefDoorMixing(ZoneNumB).Protection = RefDoorNone; - state.dataHeatBal->RefDoorMixing(ZoneNumB).MateZonePtr = 0; - state.dataHeatBal->RefDoorMixing(ZoneNumB).EMSRefDoorMixingOn = false; - state.dataHeatBal->RefDoorMixing(ZoneNumB).EMSRefDoorFlowRate = 0.0; - state.dataHeatBal->RefDoorMixing(ZoneNumB).VolRefDoorFlowRate = 0.0; - state.dataHeatBal->RefDoorMixing(ZoneNumB).DoorProtTypeName = ""; + if (!allocated(zoneB.openScheds)) { + zoneB.DoorMixingObjectName.allocate(state.dataGlobal->NumOfZones); + zoneB.openScheds.allocate(state.dataGlobal->NumOfZones); + zoneB.DoorHeight.allocate(state.dataGlobal->NumOfZones); + zoneB.DoorArea.allocate(state.dataGlobal->NumOfZones); + zoneB.Protection.allocate(state.dataGlobal->NumOfZones); + zoneB.MateZonePtr.allocate(state.dataGlobal->NumOfZones); + zoneB.EMSRefDoorMixingOn.allocate(state.dataGlobal->NumOfZones); + zoneB.EMSRefDoorFlowRate.allocate(state.dataGlobal->NumOfZones); + zoneB.VolRefDoorFlowRate.allocate(state.dataGlobal->NumOfZones); + zoneB.DoorProtTypeName.allocate(state.dataGlobal->NumOfZones); + zoneB.DoorMixingObjectName = ""; + zoneB.openScheds = nullptr; + zoneB.DoorHeight = 0.0; + zoneB.DoorArea = 0.0; + zoneB.Protection = RefDoorNone; + zoneB.MateZonePtr = 0; + zoneB.EMSRefDoorMixingOn = false; + zoneB.EMSRefDoorFlowRate = 0.0; + zoneB.VolRefDoorFlowRate = 0.0; + zoneB.DoorProtTypeName = ""; } // First refrigeration mixing in this zone - ConnectionNumber = state.dataHeatBal->RefDoorMixing(ZoneNumA).NumRefDoorConnections + 1; - state.dataHeatBal->RefDoorMixing(ZoneNumA).NumRefDoorConnections = ConnectionNumber; - state.dataHeatBal->RefDoorMixing(ZoneNumA).ZonePtr = ZoneNumA; - state.dataHeatBal->RefDoorMixing(ZoneNumA).spaceIndex = spaceNumA; - state.dataHeatBal->RefDoorMixing(ZoneNumA).fromSpaceIndex = spaceNumB; - state.dataHeatBal->RefDoorMixing(ZoneNumA).MateZonePtr(ConnectionNumber) = ZoneNumB; - state.dataHeatBal->RefDoorMixing(ZoneNumA).DoorMixingObjectName(ConnectionNumber) = NameThisObject; + ConnectionNumber = zoneA.NumRefDoorConnections + 1; + zoneA.NumRefDoorConnections = ConnectionNumber; + zoneA.ZonePtr = ZoneNumA; + zoneA.spaceIndex = spaceNumA; + zoneA.fromSpaceIndex = spaceNumB; + zoneA.MateZonePtr(ConnectionNumber) = ZoneNumB; + zoneA.DoorMixingObjectName(ConnectionNumber) = NameThisObject; // need to make sure same pair of zones is only entered once. - if (state.dataHeatBal->RefDoorMixing(ZoneNumA).RefDoorMixFlag && state.dataHeatBal->RefDoorMixing(ZoneNumB).RefDoorMixFlag) { - if (state.dataHeatBal->RefDoorMixing(ZoneNumA).NumRefDoorConnections > 1) { + if (zoneA.RefDoorMixFlag && zoneB.RefDoorMixFlag) { + if (zoneA.NumRefDoorConnections > 1) { for (int ConnectTest = 1; ConnectTest <= (ConnectionNumber - 1); ++ConnectTest) { - if (state.dataHeatBal->RefDoorMixing(ZoneNumA).MateZonePtr(ConnectTest) != - state.dataHeatBal->RefDoorMixing(ZoneNumA).MateZonePtr(ConnectionNumber)) + if (zoneA.MateZonePtr(ConnectTest) != + zoneA.MateZonePtr(ConnectionNumber)) continue; ShowSevereError(state, format("{}{}=\"{}\", and {}", RoutineName, cCurrentModuleObject, cAlphaArgs(1), - state.dataHeatBal->RefDoorMixing(ZoneNumA).DoorMixingObjectName(ConnectTest))); + zoneA.DoorMixingObjectName(ConnectTest))); ShowContinueError(state, format(" Share same pair of zones: \"{}\" and \"{}\". Only one RefrigerationDoorMixing object is allowed " "for any unique pair of zones.", @@ -3930,49 +3413,25 @@ void GetSimpleAirModelInputs(EnergyPlusData &state, bool &ErrorsFound) // IF err } // ConnectTest } // NumRefDoorconnections > 1 } else { // Both zones need to be flagged with ref doors - state.dataHeatBal->RefDoorMixing(ZoneNumA).RefDoorMixFlag = true; - state.dataHeatBal->RefDoorMixing(ZoneNumB).RefDoorMixFlag = true; + zoneA.RefDoorMixFlag = true; + zoneB.RefDoorMixFlag = true; } // Both zones already flagged with ref doors ++AlphaNum; // 4 if (lAlphaFieldBlanks(AlphaNum)) { - ShowSevereError(state, - format("{}{}=\"{}\",{} is required but field is blank.", - RoutineName, - cCurrentModuleObject, - cAlphaArgs(1), - cAlphaFieldNames(AlphaNum))); + ShowSevereEmptyField(state, eoh, cAlphaFieldNames(AlphaNum)); + ErrorsFound = true; + } else if ((zoneA.openScheds(ConnectionNumber) = Sched::GetSchedule(state, cAlphaArgs(AlphaNum))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(AlphaNum), cAlphaArgs(AlphaNum)); + ErrorsFound = true; + } else if (!zoneA.openScheds(ConnectionNumber)->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) { + Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(AlphaNum), cAlphaArgs(AlphaNum),Clusive::In, 0.0, Clusive::In, 1.0); ErrorsFound = true; - } else { //(lAlphaFieldBlanks(AlphaNum)) THEN - state.dataHeatBal->RefDoorMixing(ZoneNumA).OpenSchedPtr(ConnectionNumber) = - ScheduleManager::GetScheduleIndex(state, cAlphaArgs(AlphaNum)); - if (state.dataHeatBal->RefDoorMixing(ZoneNumA).OpenSchedPtr(ConnectionNumber) == 0) { - ShowSevereError(state, - format("{}{}=\"{}\", invalid (not found) {}=\"{}\".", - RoutineName, - cCurrentModuleObject, - cAlphaArgs(1), - cAlphaFieldNames(AlphaNum), - cAlphaArgs(AlphaNum))); - ErrorsFound = true; - } else { // OpenSchedPtr(ConnectionNumber) ne 0) - if (!ScheduleManager::CheckScheduleValueMinMax( - state, state.dataHeatBal->RefDoorMixing(ZoneNumA).OpenSchedPtr(ConnectionNumber), ">=", 0.0, "<=", 1.0)) { - ShowSevereError(state, - format("{}{}=\"{}\",{}=\"{}\" has schedule values < 0 or > 1.", - RoutineName, - cCurrentModuleObject, - cAlphaArgs(1), - cAlphaFieldNames(AlphaNum), - cAlphaArgs(AlphaNum))); - ErrorsFound = true; - } // check door opening schedule values between 0 and 1 - } // OpenSchedPtr(ConnectionNumber) == 0) } //(lAlphaFieldBlanks(AlphaNum)) THEN int NumbNum = 1; if (lAlphaFieldBlanks(NumbNum)) { - state.dataHeatBal->RefDoorMixing(ZoneNumA).DoorHeight(ConnectionNumber) = 3.0; // default height of 3 meters + zoneA.DoorHeight(ConnectionNumber) = 3.0; // default height of 3 meters ShowWarningError(state, format("{}{}=\"{}{} is blank and the default value of 3.0 will be used.", RoutineName, @@ -3980,9 +3439,9 @@ void GetSimpleAirModelInputs(EnergyPlusData &state, bool &ErrorsFound) // IF err cAlphaArgs(1), cNumericFieldNames(NumbNum))); } else { - state.dataHeatBal->RefDoorMixing(ZoneNumA).DoorHeight(ConnectionNumber) = rNumericArgs(NumbNum); - if ((state.dataHeatBal->RefDoorMixing(ZoneNumA).DoorHeight(ConnectionNumber) < 0) || - (state.dataHeatBal->RefDoorMixing(ZoneNumA).DoorHeight(ConnectionNumber) > 50.0)) { + zoneA.DoorHeight(ConnectionNumber) = rNumericArgs(NumbNum); + if ((zoneA.DoorHeight(ConnectionNumber) < 0) || + (zoneA.DoorHeight(ConnectionNumber) > 50.0)) { ShowSevereError( state, format("{}{} = {} must have a door height between 0 and 50 meters. ", RoutineName, cCurrentModuleObject, cAlphaArgs(1))); @@ -3992,7 +3451,7 @@ void GetSimpleAirModelInputs(EnergyPlusData &state, bool &ErrorsFound) // IF err ++NumbNum; // 2 if (lAlphaFieldBlanks(NumbNum)) { - state.dataHeatBal->RefDoorMixing(ZoneNumA).DoorArea(ConnectionNumber) = 9.0; // default area of 9 m2 + zoneA.DoorArea(ConnectionNumber) = 9.0; // default area of 9 m2 ShowWarningError(state, format("{}{}=\"{}{} is blank and the default value of 9 m2 will be used.", RoutineName, @@ -4000,9 +3459,9 @@ void GetSimpleAirModelInputs(EnergyPlusData &state, bool &ErrorsFound) // IF err cAlphaArgs(1), cNumericFieldNames(NumbNum))); } else { - state.dataHeatBal->RefDoorMixing(ZoneNumA).DoorArea(ConnectionNumber) = rNumericArgs(NumbNum); - if ((state.dataHeatBal->RefDoorMixing(ZoneNumA).DoorArea(ConnectionNumber) < 0) || - (state.dataHeatBal->RefDoorMixing(ZoneNumA).DoorArea(ConnectionNumber) > 400.0)) { + zoneA.DoorArea(ConnectionNumber) = rNumericArgs(NumbNum); + if ((zoneA.DoorArea(ConnectionNumber) < 0) || + (zoneA.DoorArea(ConnectionNumber) > 400.0)) { ShowSevereError( state, format( @@ -4014,8 +3473,8 @@ void GetSimpleAirModelInputs(EnergyPlusData &state, bool &ErrorsFound) // IF err ++AlphaNum; // 5 // Door protection type. if (lAlphaFieldBlanks(AlphaNum)) { - state.dataHeatBal->RefDoorMixing(ZoneNumA).Protection(ConnectionNumber) = RefDoorNone; // Default - state.dataHeatBal->RefDoorMixing(ZoneNumA).DoorProtTypeName(ConnectionNumber) = "None"; // Default + zoneA.Protection(ConnectionNumber) = RefDoorNone; // Default + zoneA.DoorProtTypeName(ConnectionNumber) = "None"; // Default ShowWarningError(state, format("{}{}=\"{}\" {} is blank. Default of no door protection will be used", RoutineName, @@ -4024,14 +3483,14 @@ void GetSimpleAirModelInputs(EnergyPlusData &state, bool &ErrorsFound) // IF err cAlphaFieldNames(AlphaNum))); } else { if (cAlphaArgs(AlphaNum) == "NONE") { - state.dataHeatBal->RefDoorMixing(ZoneNumA).Protection(ConnectionNumber) = RefDoorNone; - state.dataHeatBal->RefDoorMixing(ZoneNumA).DoorProtTypeName(ConnectionNumber) = "None"; + zoneA.Protection(ConnectionNumber) = RefDoorNone; + zoneA.DoorProtTypeName(ConnectionNumber) = "None"; } else if (cAlphaArgs(AlphaNum) == "AIRCURTAIN") { - state.dataHeatBal->RefDoorMixing(ZoneNumA).Protection(ConnectionNumber) = RefDoorAirCurtain; - state.dataHeatBal->RefDoorMixing(ZoneNumA).DoorProtTypeName(ConnectionNumber) = "AirCurtain"; + zoneA.Protection(ConnectionNumber) = RefDoorAirCurtain; + zoneA.DoorProtTypeName(ConnectionNumber) = "AirCurtain"; } else if (cAlphaArgs(AlphaNum) == "STRIPCURTAIN") { - state.dataHeatBal->RefDoorMixing(ZoneNumA).Protection(ConnectionNumber) = RefDoorStripCurtain; - state.dataHeatBal->RefDoorMixing(ZoneNumA).DoorProtTypeName(ConnectionNumber) = "StripCurtain"; + zoneA.Protection(ConnectionNumber) = RefDoorStripCurtain; + zoneA.DoorProtTypeName(ConnectionNumber) = "StripCurtain"; } else { ShowSevereError(state, format("{}{}=\"{}\", invalid calculation method={} with alphanum of 5: {}", @@ -4129,11 +3588,11 @@ void GetSimpleAirModelInputs(EnergyPlusData &state, bool &ErrorsFound) // IF err if (state.dataGlobal->AnyEnergyManagementSystemInModel) { SetupEMSActuator(state, "ZoneRefDoorMixing", - state.dataHeatBal->RefDoorMixing(ZoneNumA).Name, + zoneA.Name, "Air Exchange Flow Rate", "[m3/s]", - state.dataHeatBal->RefDoorMixing(ZoneNumA).EMSRefDoorMixingOn(ConnectionNumber), - state.dataHeatBal->RefDoorMixing(ZoneNumA).EMSRefDoorFlowRate(ConnectionNumber)); + zoneA.EMSRefDoorMixingOn(ConnectionNumber), + zoneA.EMSRefDoorFlowRate(ConnectionNumber)); } if (ZoneNumB > 0) { @@ -4221,13 +3680,13 @@ void GetSimpleAirModelInputs(EnergyPlusData &state, bool &ErrorsFound) // IF err if (state.dataGlobal->AnyEnergyManagementSystemInModel) { SetupEMSActuator(state, "ZoneRefDoorMixing", - state.dataHeatBal->RefDoorMixing(ZoneNumB).Name, + zoneB.Name, "Air Exchange Flow Rate", "[m3/s]", - state.dataHeatBal->RefDoorMixing(ZoneNumA).EMSRefDoorMixingOn(ConnectionNumber), - state.dataHeatBal->RefDoorMixing(ZoneNumA).EMSRefDoorFlowRate(ConnectionNumber)); + zoneA.EMSRefDoorMixingOn(ConnectionNumber), + state.dataHeatBal->RefDoorMixing(ZoneNumA). + EMSRefDoorFlowRate(ConnectionNumber)); } - } // DO Loop=1,TotRefDoorMixing } // TotRefDoorMixing > 0) @@ -4268,7 +3727,7 @@ void GetSimpleAirModelInputs(EnergyPlusData &state, bool &ErrorsFound) // IF err Format_720, "ZoneInfiltration", state.dataHeatBal->Infiltration(Loop).Name, - ScheduleManager::GetScheduleName(state, state.dataHeatBal->Infiltration(Loop).SchedPtr), + state.dataHeatBal->Infiltration(Loop).sched->Name, state.dataHeatBal->Zone(ZoneNum).Name, state.dataHeatBal->Zone(ZoneNum).FloorArea, state.dataHeatBal->Zone(ZoneNum).TotOccupants); @@ -4278,7 +3737,7 @@ void GetSimpleAirModelInputs(EnergyPlusData &state, bool &ErrorsFound) // IF err divide_and_print_if_greater_than_zero(state.dataHeatBal->Zone(ZoneNum).ExteriorTotalSurfArea, state.dataHeatBal->Infiltration(Loop).DesignLevel); divide_and_print_if_greater_than_zero(state.dataHeatBal->Zone(ZoneNum).Volume, - state.dataHeatBal->Infiltration(Loop).DesignLevel * Constant::SecInHour); + state.dataHeatBal->Infiltration(Loop).DesignLevel * Constant::rSecsInHour); print(state.files.eio, "{:.3R},", state.dataHeatBal->Infiltration(Loop).ConstantTermCoef); print(state.files.eio, "{:.3R},", state.dataHeatBal->Infiltration(Loop).TemperatureTermCoef); @@ -4316,7 +3775,7 @@ void GetSimpleAirModelInputs(EnergyPlusData &state, bool &ErrorsFound) // IF err Format_720, "ZoneVentilation", state.dataHeatBal->Ventilation(Loop).Name, - ScheduleManager::GetScheduleName(state, state.dataHeatBal->Ventilation(Loop).SchedPtr), + state.dataHeatBal->Ventilation(Loop).sched->Name, state.dataHeatBal->Zone(ZoneNum).Name, state.dataHeatBal->Zone(ZoneNum).FloorArea, state.dataHeatBal->Zone(ZoneNum).TotOccupants); @@ -4326,7 +3785,7 @@ void GetSimpleAirModelInputs(EnergyPlusData &state, bool &ErrorsFound) // IF err divide_and_print_if_greater_than_zero(state.dataHeatBal->Zone(ZoneNum).FloorArea, state.dataHeatBal->Ventilation(Loop).DesignLevel); divide_and_print_if_greater_than_zero(state.dataHeatBal->Zone(ZoneNum).TotOccupants, state.dataHeatBal->Ventilation(Loop).DesignLevel); divide_and_print_if_greater_than_zero(state.dataHeatBal->Zone(ZoneNum).Volume, - state.dataHeatBal->Ventilation(Loop).DesignLevel * Constant::SecInHour); + state.dataHeatBal->Ventilation(Loop).DesignLevel * Constant::rSecsInHour); if (state.dataHeatBal->Ventilation(Loop).FanType == DataHeatBalance::VentilationType::Exhaust) { print(state.files.eio, "Exhaust,"); @@ -4347,24 +3806,24 @@ void GetSimpleAirModelInputs(EnergyPlusData &state, bool &ErrorsFound) // IF err print(state.files.eio, "{:.3R},", state.dataHeatBal->Ventilation(Loop).VelocitySQTermCoef); // TODO Should this also be prefixed with "Schedule: " like the following ones are? - if (state.dataHeatBal->Ventilation(Loop).MinIndoorTempSchedPtr > 0) { - print(state.files.eio, "{},", ScheduleManager::GetScheduleName(state, state.dataHeatBal->Ventilation(Loop).MinIndoorTempSchedPtr)); + if (state.dataHeatBal->Ventilation(Loop).minIndoorTempSched != nullptr) { + print(state.files.eio, "{},", state.dataHeatBal->Ventilation(Loop).minIndoorTempSched->Name); } else { print(state.files.eio, "{:.2R},", state.dataHeatBal->Ventilation(Loop).MinIndoorTemperature); } - const auto print_temperature = [&](const int ptr, const Real64 value) { - if (ptr > 0) { - print(state.files.eio, "Schedule: {},", ScheduleManager::GetScheduleName(state, ptr)); + const auto print_temperature = [&](Sched::Schedule const *ptr, const Real64 value) { + if (ptr != nullptr) { + print(state.files.eio, "Schedule: {},", ptr->Name); } else { print(state.files.eio, "{:.2R},", value); } }; - print_temperature(state.dataHeatBal->Ventilation(Loop).MaxIndoorTempSchedPtr, state.dataHeatBal->Ventilation(Loop).MaxIndoorTemperature); - print_temperature(state.dataHeatBal->Ventilation(Loop).DeltaTempSchedPtr, state.dataHeatBal->Ventilation(Loop).DelTemperature); - print_temperature(state.dataHeatBal->Ventilation(Loop).MinOutdoorTempSchedPtr, state.dataHeatBal->Ventilation(Loop).MinOutdoorTemperature); - print_temperature(state.dataHeatBal->Ventilation(Loop).MaxOutdoorTempSchedPtr, state.dataHeatBal->Ventilation(Loop).MaxOutdoorTemperature); + print_temperature(state.dataHeatBal->Ventilation(Loop).maxIndoorTempSched, state.dataHeatBal->Ventilation(Loop).MaxIndoorTemperature); + print_temperature(state.dataHeatBal->Ventilation(Loop).deltaTempSched, state.dataHeatBal->Ventilation(Loop).DelTemperature); + print_temperature(state.dataHeatBal->Ventilation(Loop).minOutdoorTempSched, state.dataHeatBal->Ventilation(Loop).MinOutdoorTemperature); + print_temperature(state.dataHeatBal->Ventilation(Loop).maxOutdoorTempSched, state.dataHeatBal->Ventilation(Loop).MaxOutdoorTemperature); print(state.files.eio, "{:.2R}\n", state.dataHeatBal->Ventilation(Loop).MaxWindSpeed); } @@ -4388,7 +3847,7 @@ void GetSimpleAirModelInputs(EnergyPlusData &state, bool &ErrorsFound) // IF err Format_720, "Mixing", state.dataHeatBal->Mixing(Loop).Name, - ScheduleManager::GetScheduleName(state, state.dataHeatBal->Mixing(Loop).SchedPtr), + state.dataHeatBal->Mixing(Loop).sched->Name, state.dataHeatBal->Zone(ZoneNum).Name, state.dataHeatBal->Zone(ZoneNum).FloorArea, state.dataHeatBal->Zone(ZoneNum).TotOccupants); @@ -4396,7 +3855,7 @@ void GetSimpleAirModelInputs(EnergyPlusData &state, bool &ErrorsFound) // IF err divide_and_print_if_greater_than_zero(state.dataHeatBal->Zone(ZoneNum).FloorArea, state.dataHeatBal->Mixing(Loop).DesignLevel); divide_and_print_if_greater_than_zero(state.dataHeatBal->Zone(ZoneNum).TotOccupants, state.dataHeatBal->Mixing(Loop).DesignLevel); divide_and_print_if_greater_than_zero(state.dataHeatBal->Zone(ZoneNum).Volume, - state.dataHeatBal->Mixing(Loop).DesignLevel * Constant::SecInHour); + state.dataHeatBal->Mixing(Loop).DesignLevel * Constant::rSecsInHour); print(state.files.eio, "{},", state.dataHeatBal->Zone(state.dataHeatBal->Mixing(Loop).FromZone).Name); print(state.files.eio, "{:.2R}\n", state.dataHeatBal->Mixing(Loop).DeltaTemperature); @@ -4421,7 +3880,7 @@ void GetSimpleAirModelInputs(EnergyPlusData &state, bool &ErrorsFound) // IF err Format_720, "CrossMixing", state.dataHeatBal->CrossMixing(Loop).Name, - ScheduleManager::GetScheduleName(state, state.dataHeatBal->CrossMixing(Loop).SchedPtr), + state.dataHeatBal->CrossMixing(Loop).sched->Name, state.dataHeatBal->Zone(ZoneNum).Name, state.dataHeatBal->Zone(ZoneNum).FloorArea, state.dataHeatBal->Zone(ZoneNum).TotOccupants); @@ -4431,7 +3890,7 @@ void GetSimpleAirModelInputs(EnergyPlusData &state, bool &ErrorsFound) // IF err divide_and_print_if_greater_than_zero(state.dataHeatBal->Zone(ZoneNum).FloorArea, state.dataHeatBal->CrossMixing(Loop).DesignLevel); divide_and_print_if_greater_than_zero(state.dataHeatBal->Zone(ZoneNum).TotOccupants, state.dataHeatBal->CrossMixing(Loop).DesignLevel); divide_and_print_if_greater_than_zero(state.dataHeatBal->Zone(ZoneNum).Volume, - state.dataHeatBal->CrossMixing(Loop).DesignLevel * Constant::SecInHour); + state.dataHeatBal->CrossMixing(Loop).DesignLevel * Constant::rSecsInHour); print(state.files.eio, "{},", state.dataHeatBal->Zone(state.dataHeatBal->CrossMixing(Loop).FromZone).Name); print(state.files.eio, "{:.2R}\n", state.dataHeatBal->CrossMixing(Loop).DeltaTemperature); @@ -4455,7 +3914,7 @@ void GetSimpleAirModelInputs(EnergyPlusData &state, bool &ErrorsFound) // IF err state.dataHeatBal->RefDoorMixing(ZoneNumA).DoorMixingObjectName(ConnectionNumber), state.dataHeatBal->Zone(ZoneNumA).Name, state.dataHeatBal->Zone(ZoneNumB).Name, - ScheduleManager::GetScheduleName(state, state.dataHeatBal->RefDoorMixing(ZoneNumA).OpenSchedPtr(ConnectionNumber)), + state.dataHeatBal->RefDoorMixing(ZoneNumA).openScheds(ConnectionNumber)->Name, state.dataHeatBal->RefDoorMixing(ZoneNumA).DoorHeight(ConnectionNumber), state.dataHeatBal->RefDoorMixing(ZoneNumA).DoorArea(ConnectionNumber), state.dataHeatBal->RefDoorMixing(ZoneNumA).DoorProtTypeName(ConnectionNumber)); @@ -4832,7 +4291,7 @@ void InitSimpleMixingConvectiveHeatGains(EnergyPlusData &state) if (state.dataHeatBal->AirFlowFlag) { // Simplified airflow calculation // Process the scheduled Mixing for air heat balance for (auto &thisMixing : state.dataHeatBal->Mixing) { - thisMixing.DesiredAirFlowRate = thisMixing.DesignLevel * ScheduleManager::GetCurrentScheduleValue(state, thisMixing.SchedPtr); + thisMixing.DesiredAirFlowRate = thisMixing.DesignLevel * thisMixing.sched->getCurrentVal(); if (thisMixing.EMSSimpleMixingOn) thisMixing.DesiredAirFlowRate = thisMixing.EMSimpleMixingFlowRate; thisMixing.DesiredAirFlowRateSaved = thisMixing.DesiredAirFlowRate; } @@ -4857,7 +4316,7 @@ void InitSimpleMixingConvectiveHeatGains(EnergyPlusData &state) // Process the scheduled CrossMixing for air heat balance for (auto &thisCrossMix : state.dataHeatBal->CrossMixing) { - thisCrossMix.DesiredAirFlowRate = thisCrossMix.DesignLevel * ScheduleManager::GetCurrentScheduleValue(state, thisCrossMix.SchedPtr); + thisCrossMix.DesiredAirFlowRate = thisCrossMix.DesignLevel * thisCrossMix.sched->getCurrentVal(); if (thisCrossMix.EMSSimpleMixingOn) thisCrossMix.DesiredAirFlowRate = thisCrossMix.EMSimpleMixingFlowRate; } @@ -5008,8 +4467,7 @@ void calcMeanAirTemps(EnergyPlusData &state, Real64 thisMRTFraction; // temp working value for radiative fraction/weight // is operative temp radiative fraction scheduled or fixed? if (state.dataZoneCtrls->TempControlledZone(TempControlledZoneID).OpTempCntrlModeScheduled) { - thisMRTFraction = ScheduleManager::GetCurrentScheduleValue( - state, state.dataZoneCtrls->TempControlledZone(TempControlledZoneID).OpTempRadiativeFractionSched); + thisMRTFraction = state.dataZoneCtrls->TempControlledZone(TempControlledZoneID).opTempRadiativeFractionSched->getCurrentVal(); } else { thisMRTFraction = state.dataZoneCtrls->TempControlledZone(TempControlledZoneID).FixedRadiativeFraction; } diff --git a/src/EnergyPlus/HeatBalanceAirManager.hh b/src/EnergyPlus/HeatBalanceAirManager.hh index 4339ab1a68c..c79db53c52f 100644 --- a/src/EnergyPlus/HeatBalanceAirManager.hh +++ b/src/EnergyPlus/HeatBalanceAirManager.hh @@ -101,6 +101,10 @@ struct HeatBalanceAirMgrData : BaseGlobalStruct bool ManageAirHeatBalanceGetInputFlag = true; bool CalcExtraReportVarMyOneTimeFlag = true; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/HeatBalanceHAMTManager.cc b/src/EnergyPlus/HeatBalanceHAMTManager.cc index ebdb33c004b..2b83915267f 100644 --- a/src/EnergyPlus/HeatBalanceHAMTManager.cc +++ b/src/EnergyPlus/HeatBalanceHAMTManager.cc @@ -285,7 +285,7 @@ namespace HeatBalanceHAMTManager { auto *mat = s_mat->materials(matNum); if (mat->group != Material::Group::Regular) { - ShowSevereCustomMessage(state, eoh, format("{} = \"{}\" is not a regular material.", cAlphaFieldNames(1), AlphaArray(1))); + ShowSevereCustom(state, eoh, format("{} = \"{}\" is not a regular material.", cAlphaFieldNames(1), AlphaArray(1))); ErrorsFound = true; continue; } @@ -334,7 +334,7 @@ namespace HeatBalanceHAMTManager { auto *mat = s_mat->materials(matNum); if (!mat->hasHAMT) { - ShowSevereCustomMessage(state, eoh, format("{} is not defined for {} = \"{}\"", cHAMTObject1, cAlphaFieldNames(1), AlphaArray(1))); + ShowSevereCustom(state, eoh, format("{} is not defined for {} = \"{}\"", cHAMTObject1, cAlphaFieldNames(1), AlphaArray(1))); ErrorsFound = true; continue; } @@ -426,7 +426,7 @@ namespace HeatBalanceHAMTManager { auto *mat = s_mat->materials(matNum); if (!mat->hasHAMT) { - ShowSevereCustomMessage(state, eoh, format("{} is not defined for {} = \"{}\"", cHAMTObject1, cAlphaFieldNames(1), AlphaArray(1))); + ShowSevereCustom(state, eoh, format("{} is not defined for {} = \"{}\"", cHAMTObject1, cAlphaFieldNames(1), AlphaArray(1))); ErrorsFound = true; continue; } @@ -473,7 +473,7 @@ namespace HeatBalanceHAMTManager { auto *mat = s_mat->materials(matNum); if (!mat->hasHAMT) { - ShowSevereCustomMessage(state, eoh, format("{} is not defined for {} = \"{}\"", cHAMTObject1, cAlphaFieldNames(1), AlphaArray(1))); + ShowSevereCustom(state, eoh, format("{} is not defined for {} = \"{}\"", cHAMTObject1, cAlphaFieldNames(1), AlphaArray(1))); ErrorsFound = true; continue; } @@ -520,7 +520,7 @@ namespace HeatBalanceHAMTManager { auto *mat = s_mat->materials(matNum); if (!mat->hasHAMT) { - ShowSevereCustomMessage(state, eoh, format("{} is not defined for {} = \"{}\"", cHAMTObject1, cAlphaFieldNames(1), AlphaArray(1))); + ShowSevereCustom(state, eoh, format("{} is not defined for {} = \"{}\"", cHAMTObject1, cAlphaFieldNames(1), AlphaArray(1))); ErrorsFound = true; continue; } @@ -569,7 +569,7 @@ namespace HeatBalanceHAMTManager { auto *mat = s_mat->materials(matNum); if (!mat->hasHAMT) { - ShowSevereCustomMessage(state, eoh, format("{} is not defined for {} = \"{}\"", cHAMTObject1, cAlphaFieldNames(1), AlphaArray(1))); + ShowSevereCustom(state, eoh, format("{} is not defined for {} = \"{}\"", cHAMTObject1, cAlphaFieldNames(1), AlphaArray(1))); ErrorsFound = true; continue; } diff --git a/src/EnergyPlus/HeatBalanceHAMTManager.hh b/src/EnergyPlus/HeatBalanceHAMTManager.hh index 5fc7516378b..0f6e9914eba 100644 --- a/src/EnergyPlus/HeatBalanceHAMTManager.hh +++ b/src/EnergyPlus/HeatBalanceHAMTManager.hh @@ -227,6 +227,10 @@ struct HeatBalHAMTMgrData : BaseGlobalStruct int qvpErrCount = 0; int qvpErrReport = 0; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/HeatBalanceIntRadExchange.hh b/src/EnergyPlus/HeatBalanceIntRadExchange.hh index 1b8415522a5..c9fa5a17481 100644 --- a/src/EnergyPlus/HeatBalanceIntRadExchange.hh +++ b/src/EnergyPlus/HeatBalanceIntRadExchange.hh @@ -182,6 +182,10 @@ struct HeatBalanceIntRadExchgData : BaseGlobalStruct bool ViewFactorReport = false; // Flag to output view factor report in eio file int LargestSurf = 0; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/HeatBalanceInternalHeatGains.hh b/src/EnergyPlus/HeatBalanceInternalHeatGains.hh index 2af13a0c90d..5908d6dcba1 100644 --- a/src/EnergyPlus/HeatBalanceInternalHeatGains.hh +++ b/src/EnergyPlus/HeatBalanceInternalHeatGains.hh @@ -86,6 +86,10 @@ void SetupSpaceInternalGain(EnergyPlusData &state, struct HeatBalInternalHeatGainsData : BaseGlobalStruct { + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/HeatBalanceKivaManager.cc b/src/EnergyPlus/HeatBalanceKivaManager.cc index a3c6b3425bd..c3d5dae93a5 100644 --- a/src/EnergyPlus/HeatBalanceKivaManager.cc +++ b/src/EnergyPlus/HeatBalanceKivaManager.cc @@ -179,7 +179,7 @@ void KivaInstanceMap::initGround(EnergyPlusData &state, const KivaWeatherData &k int accDate = getAccDate(state, numAccelaratedTimesteps, acceleratedTimestep); // Initialize with steady state before accelerated timestepping instance.ground->foundation.numericalScheme = Kiva::Foundation::NS_STEADY_STATE; - setInitialBoundaryConditions(state, kivaWeather, accDate, 24, state.dataGlobal->NumOfTimeStepInHour); + setInitialBoundaryConditions(state, kivaWeather, accDate, 24, state.dataGlobal->TimeStepsInHour); instance.calculate(); accDate += acceleratedTimestep; while (accDate > 365 + state.dataWeather->LeapYearAdd) { @@ -189,7 +189,7 @@ void KivaInstanceMap::initGround(EnergyPlusData &state, const KivaWeatherData &k // Accelerated timestepping instance.ground->foundation.numericalScheme = Kiva::Foundation::NS_IMPLICIT; for (int i = 0; i < numAccelaratedTimesteps; ++i) { - setInitialBoundaryConditions(state, kivaWeather, accDate, 24, state.dataGlobal->NumOfTimeStepInHour); + setInitialBoundaryConditions(state, kivaWeather, accDate, 24, state.dataGlobal->TimeStepsInHour); instance.calculate(acceleratedTimestep * 24 * 60 * 60); accDate += acceleratedTimestep; while (accDate > 365 + state.dataWeather->LeapYearAdd) { @@ -222,9 +222,9 @@ void KivaInstanceMap::setInitialBoundaryConditions( if (kivaWeather.intervalsPerHour == 1) { index = (date - 1) * 24 + (hour - 1); - weightNow = min(1.0, (double(timestep) / double(state.dataGlobal->NumOfTimeStepInHour))); + weightNow = min(1.0, (double(timestep) / double(state.dataGlobal->TimeStepsInHour))); } else { - index = (date - 1) * 24 * state.dataGlobal->NumOfTimeStepInHour + (hour - 1) * state.dataGlobal->NumOfTimeStepInHour + (timestep - 1); + index = (date - 1) * 24 * state.dataGlobal->TimeStepsInHour + (hour - 1) * state.dataGlobal->TimeStepsInHour + (timestep - 1); weightNow = 1.0; // weather data interval must be the same as the timestep interval (i.e., no interpolation) } if (index == 0) { @@ -268,37 +268,37 @@ void KivaInstanceMap::setInitialBoundaryConditions( } case KIVAZONE_TEMPCONTROL: { - int controlTypeSchId = state.dataZoneCtrls->TempControlledZone(zoneControlNum).CTSchedIndex; - HVAC::ThermostatType controlType = - static_cast(ScheduleManager::LookUpScheduleValue(state, controlTypeSchId, hour, timestep)); + auto const *ctrlTypeSched = state.dataZoneCtrls->TempControlledZone(zoneControlNum).setptTypeSched; + HVAC::SetptType controlType = static_cast(ctrlTypeSched->getHrTsVal(state, hour, timestep)); switch (controlType) { - case HVAC::ThermostatType::Uncontrolled: + case HVAC::SetptType::Uncontrolled: Tin = assumedFloatingTemp + Constant::Kelvin; break; - case HVAC::ThermostatType::SingleHeating: { - int schNameId = state.dataZoneCtrls->TempControlledZone(zoneControlNum).SchIndx_SingleHeatSetPoint; - Real64 setpoint = ScheduleManager::LookUpScheduleValue(state, schNameId, hour, timestep); + case HVAC::SetptType::SingleHeat: { + auto const *sched = state.dataZoneCtrls->TempControlledZone(zoneControlNum).setpts[(int)controlType].heatSetptSched; + Real64 setpoint = sched->getHrTsVal(state, hour, timestep); Tin = setpoint + Constant::Kelvin; - break; - } - case HVAC::ThermostatType::SingleCooling: { - int schNameId = state.dataZoneCtrls->TempControlledZone(zoneControlNum).SchIndx_SingleCoolSetPoint; - Real64 setpoint = ScheduleManager::LookUpScheduleValue(state, schNameId, hour, timestep); + } break; + + case HVAC::SetptType::SingleCool: { + auto const *sched = state.dataZoneCtrls->TempControlledZone(zoneControlNum).setpts[(int)controlType].coolSetptSched; + Real64 setpoint = sched->getHrTsVal(state, hour, timestep); Tin = setpoint + Constant::Kelvin; - break; - } - case HVAC::ThermostatType::SingleHeatCool: { - int schNameId = state.dataZoneCtrls->TempControlledZone(zoneControlNum).SchIndx_SingleHeatCoolSetPoint; - Real64 setpoint = ScheduleManager::LookUpScheduleValue(state, schNameId, hour, timestep); + } break; + + case HVAC::SetptType::SingleHeatCool: { + // Heat and cool setpt scheds will be the same for this option + auto const *sched = state.dataZoneCtrls->TempControlledZone(zoneControlNum).setpts[(int)controlType].heatSetptSched; + Real64 setpoint = sched->getHrTsVal(state, hour, timestep); Tin = setpoint + Constant::Kelvin; - break; - } - case HVAC::ThermostatType::DualSetPointWithDeadBand: { - int schNameIdHeat = state.dataZoneCtrls->TempControlledZone(zoneControlNum).SchIndx_DualSetPointWDeadBandHeat; - int schNameIdCool = state.dataZoneCtrls->TempControlledZone(zoneControlNum).SchIndx_DualSetPointWDeadBandCool; - Real64 heatSetpoint = ScheduleManager::LookUpScheduleValue(state, schNameIdHeat, hour, timestep); - Real64 coolSetpoint = ScheduleManager::LookUpScheduleValue(state, schNameIdCool, hour, timestep); + } break; + + case HVAC::SetptType::DualHeatCool: { + auto const *heatSched = state.dataZoneCtrls->TempControlledZone(zoneControlNum).setpts[(int)controlType].heatSetptSched; + auto const *coolSched = state.dataZoneCtrls->TempControlledZone(zoneControlNum).setpts[(int)controlType].coolSetptSched; + Real64 heatSetpoint = heatSched->getHrTsVal(state, hour, timestep); + Real64 coolSetpoint = coolSched->getHrTsVal(state, hour, timestep); constexpr Real64 heatBalanceTemp = 10.0 + Constant::Kelvin; // (assumed) constexpr Real64 coolBalanceTemp = 15.0 + Constant::Kelvin; // (assumed) @@ -310,16 +310,18 @@ void KivaInstanceMap::setInitialBoundaryConditions( Real64 weight = (coolBalanceTemp - bcs->outdoorTemp) / (coolBalanceTemp - heatBalanceTemp); Tin = heatSetpoint * weight + coolSetpoint * (1.0 - weight) + Constant::Kelvin; } - break; - } - default: + } break; + + default: { Tin = 0.0; ShowSevereError(state, format("Illegal control type for Zone={}, Found value={}, in Schedule={}", state.dataHeatBal->Zone(zoneNum).Name, controlType, - state.dataZoneCtrls->TempControlledZone(zoneControlNum).ControlTypeSchedName)); - } + state.dataZoneCtrls->TempControlledZone(zoneControlNum).setptTypeSched->Name)); + } break; + + } // switch (tstatType) break; } case KIVAZONE_COMFORTCONTROL: { @@ -329,10 +331,10 @@ void KivaInstanceMap::setInitialBoundaryConditions( } case KIVAZONE_STAGEDCONTROL: { - int heatSpSchId = state.dataZoneCtrls->StageControlledZone(zoneControlNum).HSBchedIndex; - int coolSpSchId = state.dataZoneCtrls->StageControlledZone(zoneControlNum).CSBchedIndex; - Real64 heatSetpoint = ScheduleManager::LookUpScheduleValue(state, heatSpSchId, hour, timestep); - Real64 coolSetpoint = ScheduleManager::LookUpScheduleValue(state, coolSpSchId, hour, timestep); + auto const *heatSched = state.dataZoneCtrls->StageControlledZone(zoneControlNum).heatSetptBaseSched; + auto const *coolSched = state.dataZoneCtrls->StageControlledZone(zoneControlNum).coolSetptBaseSched; + Real64 heatSetpoint = heatSched->getHrTsVal(state, hour, timestep); + Real64 coolSetpoint = coolSched->getHrTsVal(state, hour, timestep); constexpr Real64 heatBalanceTemp = 10.0 + Constant::Kelvin; // (assumed) constexpr Real64 coolBalanceTemp = 15.0 + Constant::Kelvin; // (assumed) if (bcs->outdoorTemp < heatBalanceTemp) { @@ -377,7 +379,7 @@ void KivaInstanceMap::setBoundaryConditions(EnergyPlusData &state) bcs->outdoorTemp = state.dataEnvrn->OutDryBulbTemp + Constant::Kelvin; bcs->localWindSpeed = DataEnvironment::WindSpeedAt(state, instance.ground->foundation.grade.roughness); - bcs->windDirection = state.dataEnvrn->WindDir * Constant::DegToRadians; + bcs->windDirection = state.dataEnvrn->WindDir * Constant::DegToRad; bcs->solarAzimuth = std::atan2(state.dataEnvrn->SOLCOS(1), state.dataEnvrn->SOLCOS(2)); bcs->solarAltitude = Constant::PiOvr2 - std::acos(state.dataEnvrn->SOLCOS(3)); bcs->directNormalFlux = state.dataEnvrn->BeamSolarRad; diff --git a/src/EnergyPlus/HeatBalanceManager.cc b/src/EnergyPlus/HeatBalanceManager.cc index a4c2d6ceed3..38c364485c5 100644 --- a/src/EnergyPlus/HeatBalanceManager.cc +++ b/src/EnergyPlus/HeatBalanceManager.cc @@ -1,4 +1,4 @@ -// EnergyPlus, Copyright (c) 1996-2024, The Board of Trustees of the University of Illinois, +// EnergyPlus, Copyright (c) 1996-20Constant::HoursInDay, The Board of Trustees of the University of Illinois, // The Regents of the University of California, through Lawrence Berkeley National Laboratory // (subject to receipt of any required approvals from the U.S. Dept. of Energy), Oak Ridge // National Laboratory, managed by UT-Battelle, Alliance for Sustainable Energy, LLC, and other @@ -512,6 +512,7 @@ namespace HeatBalanceManager { // SUBROUTINE PARAMETER DEFINITIONS: static constexpr std::string_view RoutineName("GetProjectControlData: "); + static constexpr std::string_view routineName = "GetProjectControlData"; // SUBROUTINE LOCAL VARIABLE DECLARATIONS: Array1D_string AlphaName(4); @@ -824,13 +825,13 @@ namespace HeatBalanceManager { state.dataHeatBal->OverallHeatTransferSolutionAlgo = DataSurfaces::HeatTransferModel::CondFD; state.dataHeatBal->AnyCondFD = true; state.dataHeatBal->AllCTF = false; - if (state.dataGlobal->NumOfTimeStepInHour < 20) { + if (state.dataGlobal->TimeStepsInHour < 20) { ShowSevereError( state, format("GetSolutionAlgorithm: {} {} is Conduction Finite Difference but Number of TimeSteps in Hour < 20, Value is {}.", state.dataHeatBalMgr->CurrentModuleObject, state.dataIPShortCut->cAlphaFieldNames(1), - state.dataGlobal->NumOfTimeStepInHour)); + state.dataGlobal->TimeStepsInHour)); ShowContinueError(state, "...Suggested minimum number of time steps in hour for Conduction Finite Difference solutions is 20. " "Errors or inaccurate calculations may occur."); @@ -840,13 +841,13 @@ namespace HeatBalanceManager { state.dataHeatBal->OverallHeatTransferSolutionAlgo = DataSurfaces::HeatTransferModel::HAMT; state.dataHeatBal->AnyHAMT = true; state.dataHeatBal->AllCTF = false; - if (state.dataGlobal->NumOfTimeStepInHour < 20) { + if (state.dataGlobal->TimeStepsInHour < 20) { ShowSevereError(state, format("GetSolutionAlgorithm: {} {} is Combined Heat and Moisture Finite Element but Number of TimeSteps in " "Hour < 20, Value is {}.", state.dataHeatBalMgr->CurrentModuleObject, state.dataIPShortCut->cAlphaFieldNames(1), - state.dataGlobal->NumOfTimeStepInHour)); + state.dataGlobal->TimeStepsInHour)); ShowContinueError(state, "...Suggested minimum number of time steps in hour for Combined Heat and Moisture Finite Element solutions " "is 20. Errors or inaccurate calculations may occur."); @@ -993,8 +994,11 @@ namespace HeatBalanceManager { state.dataIPShortCut->lAlphaFieldBlanks, state.dataIPShortCut->cAlphaFieldNames, state.dataIPShortCut->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, state.dataHeatBalMgr->CurrentModuleObject, state.dataHeatBalMgr->CurrentModuleObject}; + if (NumAlpha > 0) { - { + { // Why an extra nested scope here? std::string const &SELECT_CASE_var = AlphaName(1); if (SELECT_CASE_var == "YES") { state.dataContaminantBalance->Contaminant.CO2Simulation = true; @@ -1011,23 +1015,17 @@ namespace HeatBalanceManager { } } } - if (NumAlpha == 1 && state.dataContaminantBalance->Contaminant.CO2Simulation) { - ShowSevereError(state, - format("{}, {} is required and not given.", - state.dataHeatBalMgr->CurrentModuleObject, - state.dataIPShortCut->cAlphaFieldNames(2))); - ErrorsFound = true; - } else if (NumAlpha > 1 && state.dataContaminantBalance->Contaminant.CO2Simulation) { - state.dataContaminantBalance->Contaminant.CO2OutdoorSchedPtr = ScheduleManager::GetScheduleIndex(state, AlphaName(2)); - if (state.dataContaminantBalance->Contaminant.CO2OutdoorSchedPtr == 0) { - ShowSevereError(state, - format("{}, {} not found: {}", - state.dataHeatBalMgr->CurrentModuleObject, - state.dataIPShortCut->cAlphaFieldNames(2), - AlphaName(2))); + + if (state.dataContaminantBalance->Contaminant.CO2Simulation) { + if (state.dataIPShortCut->lAlphaFieldBlanks(2)) { + ShowSevereEmptyField(state, eoh, state.dataIPShortCut->cAlphaFieldNames(2)); + ErrorsFound = true; + } else if ((state.dataContaminantBalance->Contaminant.CO2OutdoorSched = Sched::GetSchedule(state, AlphaName(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(2), AlphaName(2)); ErrorsFound = true; } } + if (NumAlpha > 2) { { std::string const &SELECT_CASE_var = AlphaName(3); @@ -1046,15 +1044,15 @@ namespace HeatBalanceManager { state.dataIPShortCut->cAlphaFieldNames(3))); } } + if (NumAlpha == 3 && state.dataContaminantBalance->Contaminant.GenericContamSimulation) { - ShowSevereError(state, + ShowSevereError(state, format("{}, {} is required and not given.", state.dataHeatBalMgr->CurrentModuleObject, state.dataIPShortCut->cAlphaFieldNames(4))); ErrorsFound = true; } else if (NumAlpha > 3 && state.dataContaminantBalance->Contaminant.GenericContamSimulation) { - state.dataContaminantBalance->Contaminant.GenericContamOutdoorSchedPtr = ScheduleManager::GetScheduleIndex(state, AlphaName(4)); - if (state.dataContaminantBalance->Contaminant.GenericContamOutdoorSchedPtr == 0) { + if ((state.dataContaminantBalance->Contaminant.genericOutdoorSched = Sched::GetSchedule(state, AlphaName(4))) == nullptr) { ShowSevereError(state, format("{}, {} not found: {}", state.dataHeatBalMgr->CurrentModuleObject, @@ -2077,11 +2075,13 @@ namespace HeatBalanceManager { void GetIncidentSolarMultiplier(EnergyPlusData &state, bool &ErrorsFound) { + static constexpr std::string_view RoutineName("GetIncidentSolarMultiplier: "); + static constexpr std::string_view routineName = "GetIncidentSolarMultiplier"; + auto &s_mat = state.dataMaterial; auto &cCurrentModuleObject = state.dataIPShortCut->cCurrentModuleObject; cCurrentModuleObject = "SurfaceProperty:IncidentSolarMultiplier"; - static constexpr std::string_view RoutineName("GetIncidentSolarMultiplier: "); state.dataSurface->TotSurfIncSolMultiplier = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); @@ -2109,6 +2109,8 @@ namespace HeatBalanceManager { state.dataIPShortCut->cAlphaFieldNames, state.dataIPShortCut->cNumericFieldNames); + ErrorObjectHeader eoh{routineName, cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1)}; + // Assign surface number int SurfNum = Util::FindItemInList(state.dataIPShortCut->cAlphaArgs(1), state.dataSurface->Surface); if (SurfNum == 0) { @@ -2150,20 +2152,19 @@ namespace HeatBalanceManager { ErrorsFound = true; continue; } - int ScheduleIdx = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(2)); - // Schedule not found but schedule field is not empty, user had the wrong schedule name - if (ScheduleIdx == 0 && !(state.dataIPShortCut->cAlphaArgs(2).empty())) { - ShowSevereError(state, "Invalid Incident Solar Multiplier Schedule Name in SurfaceProperty:IncidentSolarMultiplier"); - continue; - } + Surf.hasIncSolMultiplier = true; auto &SurfIncSolMult = state.dataSurface->SurfIncSolMultiplier(SurfNum); SurfIncSolMult.Name = state.dataIPShortCut->cAlphaArgs(1); SurfIncSolMult.SurfaceIdx = SurfNum; SurfIncSolMult.Scaler = state.dataIPShortCut->rNumericArgs(1); - SurfIncSolMult.SchedPtr = ScheduleIdx; - } - } + + if (state.dataIPShortCut->lAlphaFieldBlanks(2)) { + } else if ((SurfIncSolMult.sched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(2), state.dataIPShortCut->cAlphaArgs(2)); + } + } // for (Loop) + } // GetIncidentSolarMultiplier() void GetZoneLocalEnvData(EnergyPlusData &state, bool &ErrorsFound) // Error flag indicator (true if errors found) { @@ -2686,10 +2687,10 @@ namespace HeatBalanceManager { if (state.dataGlobal->BeginDayFlag && !state.dataGlobal->WarmupFlag && state.dataGlobal->KindOfSim == Constant::KindOfSim::RunPeriodWeather && state.dataSysVars->ReportExtShadingSunlitFrac) { - for (int iHour = 1; iHour <= 24; ++iHour) { // Do for all hours. - for (int TS = 1; TS <= state.dataGlobal->NumOfTimeStepInHour; ++TS) { + for (int iHour = 1; iHour <= Constant::iHoursInDay; ++iHour) { // Do for all hours. + for (int TS = 1; TS <= state.dataGlobal->TimeStepsInHour; ++TS) { constexpr const char *ShdFracFmt1(" {:02}/{:02} {:02}:{:02},"); - if (TS == state.dataGlobal->NumOfTimeStepInHour) { + if (TS == state.dataGlobal->TimeStepsInHour) { print(state.files.shade, ShdFracFmt1, state.dataEnvrn->Month, state.dataEnvrn->DayOfMonth, iHour, 0); } else { print(state.files.shade, @@ -2697,7 +2698,7 @@ namespace HeatBalanceManager { state.dataEnvrn->Month, state.dataEnvrn->DayOfMonth, iHour - 1, - (60 / state.dataGlobal->NumOfTimeStepInHour) * TS); + (60 / state.dataGlobal->TimeStepsInHour) * TS); } for (int SurfNum = 1; SurfNum <= state.dataSurface->TotSurfaces; ++SurfNum) { constexpr const char *ShdFracFmt2("{:10.8F},"); @@ -2723,30 +2724,30 @@ namespace HeatBalanceManager { SetOutAirNodes(state); for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) { if (state.dataHeatBal->Zone(ZoneNum).LinkedOutAirNode > 0) { - if (state.dataLoopNodes->Node(state.dataHeatBal->Zone(ZoneNum).LinkedOutAirNode).OutAirDryBulbSchedNum > 0) { - state.dataHeatBal->Zone(ZoneNum).OutDryBulbTemp = ScheduleManager::GetCurrentScheduleValue( - state, state.dataLoopNodes->Node(state.dataHeatBal->Zone(ZoneNum).LinkedOutAirNode).OutAirDryBulbSchedNum); + if (state.dataLoopNodes->Node(state.dataHeatBal->Zone(ZoneNum).LinkedOutAirNode).outAirDryBulbSched != nullptr) { + state.dataHeatBal->Zone(ZoneNum).OutDryBulbTemp = + state.dataLoopNodes->Node(state.dataHeatBal->Zone(ZoneNum).LinkedOutAirNode).outAirDryBulbSched->getCurrentVal(); } else { state.dataHeatBal->Zone(ZoneNum).OutDryBulbTemp = state.dataLoopNodes->Node(state.dataHeatBal->Zone(ZoneNum).LinkedOutAirNode).OutAirDryBulb; } - if (state.dataLoopNodes->Node(state.dataHeatBal->Zone(ZoneNum).LinkedOutAirNode).OutAirWetBulbSchedNum > 0) { - state.dataHeatBal->Zone(ZoneNum).OutWetBulbTemp = ScheduleManager::GetCurrentScheduleValue( - state, state.dataLoopNodes->Node(state.dataHeatBal->Zone(ZoneNum).LinkedOutAirNode).OutAirWetBulbSchedNum); + if (state.dataLoopNodes->Node(state.dataHeatBal->Zone(ZoneNum).LinkedOutAirNode).outAirWetBulbSched != nullptr) { + state.dataHeatBal->Zone(ZoneNum).OutWetBulbTemp = + state.dataLoopNodes->Node(state.dataHeatBal->Zone(ZoneNum).LinkedOutAirNode).outAirWetBulbSched->getCurrentVal(); } else { state.dataHeatBal->Zone(ZoneNum).OutWetBulbTemp = state.dataLoopNodes->Node(state.dataHeatBal->Zone(ZoneNum).LinkedOutAirNode).OutAirWetBulb; } - if (state.dataLoopNodes->Node(state.dataHeatBal->Zone(ZoneNum).LinkedOutAirNode).OutAirWindSpeedSchedNum > 0) { - state.dataHeatBal->Zone(ZoneNum).WindSpeed = ScheduleManager::GetCurrentScheduleValue( - state, state.dataLoopNodes->Node(state.dataHeatBal->Zone(ZoneNum).LinkedOutAirNode).OutAirWindSpeedSchedNum); + if (state.dataLoopNodes->Node(state.dataHeatBal->Zone(ZoneNum).LinkedOutAirNode).outAirWindSpeedSched != nullptr) { + state.dataHeatBal->Zone(ZoneNum).WindSpeed = + state.dataLoopNodes->Node(state.dataHeatBal->Zone(ZoneNum).LinkedOutAirNode).outAirWindSpeedSched->getCurrentVal(); } else { state.dataHeatBal->Zone(ZoneNum).WindSpeed = state.dataLoopNodes->Node(state.dataHeatBal->Zone(ZoneNum).LinkedOutAirNode).OutAirWindSpeed; } - if (state.dataLoopNodes->Node(state.dataHeatBal->Zone(ZoneNum).LinkedOutAirNode).OutAirWindDirSchedNum > 0) { - state.dataHeatBal->Zone(ZoneNum).WindDir = ScheduleManager::GetCurrentScheduleValue( - state, state.dataLoopNodes->Node(state.dataHeatBal->Zone(ZoneNum).LinkedOutAirNode).OutAirWindDirSchedNum); + if (state.dataLoopNodes->Node(state.dataHeatBal->Zone(ZoneNum).LinkedOutAirNode).outAirWindDirSched != nullptr) { + state.dataHeatBal->Zone(ZoneNum).WindDir = + state.dataLoopNodes->Node(state.dataHeatBal->Zone(ZoneNum).LinkedOutAirNode).outAirWindDirSched->getCurrentVal(); } else { state.dataHeatBal->Zone(ZoneNum).WindDir = state.dataLoopNodes->Node(state.dataHeatBal->Zone(ZoneNum).LinkedOutAirNode).OutAirWindDir; @@ -2846,15 +2847,13 @@ namespace HeatBalanceManager { state.dataHeatBalFanSys->ZoneReOrder = 0; state.dataHeatBalFanSys->TempTstatAir.dimension(state.dataGlobal->NumOfZones, DataHeatBalance::ZoneInitialTemp); if (state.dataContaminantBalance->Contaminant.CO2Simulation) { - state.dataContaminantBalance->OutdoorCO2 = - ScheduleManager::GetCurrentScheduleValue(state, state.dataContaminantBalance->Contaminant.CO2OutdoorSchedPtr); + state.dataContaminantBalance->OutdoorCO2 = state.dataContaminantBalance->Contaminant.CO2OutdoorSched->getCurrentVal(); state.dataContaminantBalance->ZoneAirCO2.dimension(state.dataGlobal->NumOfZones, state.dataContaminantBalance->OutdoorCO2); state.dataContaminantBalance->ZoneAirCO2Temp.dimension(state.dataGlobal->NumOfZones, state.dataContaminantBalance->OutdoorCO2); state.dataContaminantBalance->ZoneAirCO2Avg.dimension(state.dataGlobal->NumOfZones, state.dataContaminantBalance->OutdoorCO2); } if (state.dataContaminantBalance->Contaminant.GenericContamSimulation) { - state.dataContaminantBalance->OutdoorGC = - ScheduleManager::GetCurrentScheduleValue(state, state.dataContaminantBalance->Contaminant.GenericContamOutdoorSchedPtr); + state.dataContaminantBalance->OutdoorGC = state.dataContaminantBalance->Contaminant.genericOutdoorSched->getCurrentVal(); state.dataContaminantBalance->ZoneAirGC.dimension(state.dataGlobal->NumOfZones, state.dataContaminantBalance->OutdoorGC); state.dataContaminantBalance->ZoneAirGCTemp.dimension(state.dataGlobal->NumOfZones, state.dataContaminantBalance->OutdoorGC); state.dataContaminantBalance->ZoneAirGCAvg.dimension(state.dataGlobal->NumOfZones, state.dataContaminantBalance->OutdoorGC); @@ -2875,12 +2874,12 @@ namespace HeatBalanceManager { state.dataHeatBalMgr->WarmupLoadDiff.dimension(state.dataGlobal->NumOfZones, 0.0); state.dataHeatBalMgr->TempZone.dimension(state.dataGlobal->NumOfZones, 0.0); state.dataHeatBalMgr->LoadZone.dimension(state.dataGlobal->NumOfZones, 0.0); - state.dataHeatBalMgr->TempZoneRpt.dimension(state.dataGlobal->NumOfZones, state.dataGlobal->NumOfTimeStepInHour * 24, 0.0); - state.dataHeatBalMgr->LoadZoneRpt.dimension(state.dataGlobal->NumOfZones, state.dataGlobal->NumOfTimeStepInHour * 24, 0.0); - state.dataHeatBalMgr->MaxLoadZoneRpt.dimension(state.dataGlobal->NumOfZones, state.dataGlobal->NumOfTimeStepInHour * 24, 0.0); + state.dataHeatBalMgr->TempZoneRpt.dimension(state.dataGlobal->NumOfZones, state.dataGlobal->TimeStepsInHour * Constant::iHoursInDay, 0.0); + state.dataHeatBalMgr->LoadZoneRpt.dimension(state.dataGlobal->NumOfZones, state.dataGlobal->TimeStepsInHour * Constant::iHoursInDay, 0.0); + state.dataHeatBalMgr->MaxLoadZoneRpt.dimension(state.dataGlobal->NumOfZones, state.dataGlobal->TimeStepsInHour * Constant::iHoursInDay, 0.0); state.dataHeatBalMgr->WarmupConvergenceValues.allocate(state.dataGlobal->NumOfZones); - state.dataHeatBalMgr->TempZoneRptStdDev.allocate(state.dataGlobal->NumOfTimeStepInHour * 24); - state.dataHeatBalMgr->LoadZoneRptStdDev.allocate(state.dataGlobal->NumOfTimeStepInHour * 24); + state.dataHeatBalMgr->TempZoneRptStdDev.allocate(state.dataGlobal->TimeStepsInHour * Constant::iHoursInDay); + state.dataHeatBalMgr->LoadZoneRptStdDev.allocate(state.dataGlobal->TimeStepsInHour * Constant::iHoursInDay); // MassConservation.allocate( NumOfZones ); state.dataHeatBalFanSys->CrossedColdThreshRepPeriod.allocate(state.dataGlobal->NumOfZones, state.dataWeather->TotThermalReportPers); @@ -3296,9 +3295,8 @@ namespace HeatBalanceManager { using EconomicTariff::UpdateUtilityBills; // added for computing annual utility costs using NodeInputManager::CalcMoreNodeInfo; using OutputReportTabular::UpdateTabularReports; - using ScheduleManager::ReportScheduleValues; - ReportScheduleValues(state); + Sched::ReportScheduleVals(state); if (!state.dataGlobal->WarmupFlag && state.dataGlobal->DoOutputReporting) { if (!state.dataGlobal->DoingSizing) { @@ -4136,13 +4134,13 @@ namespace HeatBalanceManager { // Pre-calculate constants for (IPhi = 1; IPhi <= 10; ++IPhi) { - CosPhiIndepVar(IPhi) = std::cos((IPhi - 1) * 10.0 * Constant::DegToRadians); + CosPhiIndepVar(IPhi) = std::cos((IPhi - 1) * 10.0 * Constant::DegToRad); } // Pre-calculate constants for (IPhi = 1; IPhi <= 10; ++IPhi) { Phi = double(IPhi - 1) * 10.0; - CosPhi(IPhi) = std::cos(Phi * Constant::DegToRadians); + CosPhi(IPhi) = std::cos(Phi * Constant::DegToRad); if (std::abs(CosPhi(IPhi)) < 0.0001) CosPhi(IPhi) = 0.0; } @@ -4764,9 +4762,10 @@ namespace HeatBalanceManager { bool &errorsFound // If errors found in input ) { + static constexpr std::string_view routineName = "CreateAirBoundaryConstructions"; + auto &cCurrentModuleObject = state.dataIPShortCut->cCurrentModuleObject; cCurrentModuleObject = "Construction:AirBoundary"; - static constexpr std::string_view RoutineName = "CreateAirBoundaryConstructions"; int numAirBoundaryConstructs = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); if (numAirBoundaryConstructs > 0) { auto const instances = state.dataInputProcessing->inputProcessor->epJSON.find(cCurrentModuleObject); @@ -4782,6 +4781,9 @@ namespace HeatBalanceManager { for (auto instance = instancesValue.begin(); instance != instancesValue.end(); ++instance) { auto const &fields = instance.value(); std::string const &thisObjectName = instance.key(); + + ErrorObjectHeader eoh{routineName, cCurrentModuleObject, thisObjectName}; + state.dataInputProcessing->inputProcessor->markObjectAsUsed(cCurrentModuleObject, thisObjectName); if (GlobalNames::VerifyUniqueInterObjectName( @@ -4798,33 +4800,27 @@ namespace HeatBalanceManager { // Air Exchange Method std::string airMethod = "None"; - if (fields.find("air_exchange_method") != fields.end()) { - airMethod = fields.at("air_exchange_method").get(); + if (auto found = fields.find("air_exchange_method"); found != fields.end()) { // find("x") followed by at("x") is the same lookup twice + airMethod = found.value().get(); } if (Util::SameString(airMethod, "SimpleMixing")) { thisConstruct.TypeIsAirBoundaryMixing = true; - if (fields.find("simple_mixing_air_changes_per_hour") != fields.end()) { - thisConstruct.AirBoundaryACH = fields.at("simple_mixing_air_changes_per_hour").get(); + if (auto found = fields.find("simple_mixing_air_changes_per_hour"); found != fields.end()) { + thisConstruct.AirBoundaryACH = found.value().get(); } else { if (!state.dataInputProcessing->inputProcessor->getDefaultValue( state, cCurrentModuleObject, "simple_mixing_air_changes_per_hour", thisConstruct.AirBoundaryACH)) { errorsFound = true; } } - if (fields.find("simple_mixing_schedule_name") != fields.end()) { - const std::string &schedName = fields.at("simple_mixing_schedule_name").get(); - thisConstruct.AirBoundaryMixingSched = ScheduleManager::GetScheduleIndex(state, Util::makeUPPER(schedName)); - if (thisConstruct.AirBoundaryMixingSched == 0) { - ShowSevereError(state, - format("{}{}=\"{}\", invalid (not found) Simple Mixing Schedule Name=\"{}\".", - RoutineName, - cCurrentModuleObject, - thisConstruct.Name, - schedName)); + if (auto found = fields.find("simple_mixing_schedule_name"); found != fields.end()) { + std::string schedName = found.value().get(); // .get() creates and returns a new string, no & + if ((thisConstruct.airBoundaryMixingSched = Sched::GetSchedule(state, Util::makeUPPER(schedName))) == nullptr) { + ShowSevereItemNotFound(state, eoh, "Simple Mixing Schedule Name", schedName); errorsFound = true; } } else { - thisConstruct.AirBoundaryMixingSched = ScheduleManager::ScheduleAlwaysOn; + thisConstruct.airBoundaryMixingSched = Sched::GetScheduleAlwaysOn(state); } } } @@ -4843,7 +4839,8 @@ namespace HeatBalanceManager { // window layers // SUBROUTINE PARAMETER DEFINITIONS: - constexpr const char *RoutineName("GetScheduledSurfaceGains: "); + static constexpr std::string_view RoutineName("GetScheduledSurfaceGains: "); + static constexpr std::string_view routineName = "GetScheduledSurfaceGains"; // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int NumArgs; @@ -4853,7 +4850,6 @@ namespace HeatBalanceManager { int IOStat; int SurfNum; int ConstrNum; - int ScheduleNum; //----------------------------------------------------------------------- // SurfaceProperty:SolarIncidentInside @@ -4890,22 +4886,14 @@ namespace HeatBalanceManager { state.dataIPShortCut->cAlphaFieldNames, state.dataIPShortCut->cNumericFieldNames); + ErrorObjectHeader eoh{routineName, cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1)}; + state.dataSurface->SurfIncSolSSG(Loop).Name = state.dataIPShortCut->cAlphaArgs(1); // Assign surface number SurfNum = Util::FindItemInList(state.dataIPShortCut->cAlphaArgs(2), state.dataSurface->Surface); if (SurfNum == 0) { - ShowSevereError(state, - format("{}{}=\"{}, object. Illegal value for {} has been found.", - RoutineName, - cCurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaFieldNames(2))); - ShowContinueError( - state, - format("{} entered value = \"{}\" no corresponding surface (ref BuildingSurface:Detailed) has been found in the input file.", - state.dataIPShortCut->cAlphaFieldNames(2), - state.dataIPShortCut->cAlphaArgs(2))); + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(2), state.dataIPShortCut->cAlphaArgs(2)); ErrorsFound = true; } else { state.dataSurface->SurfIncSolSSG(Loop).SurfPtr = SurfNum; @@ -4927,38 +4915,15 @@ namespace HeatBalanceManager { // Assign construction number ConstrNum = Util::FindItemInList(state.dataIPShortCut->cAlphaArgs(3), state.dataConstruction->Construct); if (ConstrNum == 0) { - ShowSevereError(state, - format("{}{}=\"{}, object. Illegal value for {} has been found.", - RoutineName, - cCurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaFieldNames(3))); - ShowContinueError( - state, - format("{} entered value = \"{}\" no corresponding construction (ref Construction) has been found in the input file.", - state.dataIPShortCut->cAlphaFieldNames(3), - state.dataIPShortCut->cAlphaArgs(3))); + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(3), state.dataIPShortCut->cAlphaArgs(3)); ErrorsFound = true; } else { state.dataSurface->SurfIncSolSSG(Loop).ConstrPtr = ConstrNum; } - // Assign schedule number - ScheduleNum = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(4)); - if (ScheduleNum == 0) { - ShowSevereError(state, - format("{}{}=\"{}, object. Illegal value for {} has been found.", - RoutineName, - cCurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaFieldNames(4))); - ShowContinueError(state, - format("{} entered value = \"{}\" no corresponding schedule has been found in the input file.", - state.dataIPShortCut->cAlphaFieldNames(4), - state.dataIPShortCut->cAlphaArgs(4))); + if ((state.dataSurface->SurfIncSolSSG(Loop).sched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(4))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(4), state.dataIPShortCut->cAlphaArgs(4)); ErrorsFound = true; - } else { - state.dataSurface->SurfIncSolSSG(Loop).SchedPtr = ScheduleNum; } } } @@ -4988,22 +4953,14 @@ namespace HeatBalanceManager { state.dataIPShortCut->cAlphaFieldNames, state.dataIPShortCut->cNumericFieldNames); + ErrorObjectHeader eoh{routineName, cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1)}; + state.dataSurface->FenLayAbsSSG(Loop).Name = state.dataIPShortCut->cAlphaArgs(1); // Assign surface number SurfNum = Util::FindItemInList(state.dataIPShortCut->cAlphaArgs(2), state.dataSurface->Surface); if (SurfNum == 0) { - ShowSevereError(state, - format("{}{}=\"{}, object. Illegal value for {} has been found.", - RoutineName, - cCurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaFieldNames(2))); - ShowContinueError( - state, - format("{} entered value = \"{}\" no corresponding surface (ref BuildingSurface:Detailed) has been found in the input file.", - state.dataIPShortCut->cAlphaFieldNames(2), - state.dataIPShortCut->cAlphaArgs(2))); + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(2), state.dataIPShortCut->cAlphaArgs(2)); ErrorsFound = true; } else { state.dataSurface->FenLayAbsSSG(Loop).SurfPtr = SurfNum; @@ -5011,19 +4968,9 @@ namespace HeatBalanceManager { // Assign construction number ConstrNum = Util::FindItemInList(state.dataIPShortCut->cAlphaArgs(3), state.dataConstruction->Construct); - auto const &thisConstruct = state.dataConstruction->Construct(ConstrNum); + auto const &thisConstruct = state.dataConstruction->Construct(ConstrNum); // Why is this before the error check? if (ConstrNum == 0) { - ShowSevereError(state, - format("{}{}=\"{}, object. Illegal value for {} has been found.", - RoutineName, - cCurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaFieldNames(3))); - ShowContinueError( - state, - format("{} entered value = \"{}\" no corresponding construction (ref Construction) has been found in the input file.", - state.dataIPShortCut->cAlphaFieldNames(3), - state.dataIPShortCut->cAlphaArgs(3))); + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(3), state.dataIPShortCut->cAlphaArgs(3)); ErrorsFound = true; } else { state.dataSurface->FenLayAbsSSG(Loop).ConstrPtr = ConstrNum; @@ -5051,28 +4998,17 @@ namespace HeatBalanceManager { ErrorsFound = true; } - if (!allocated(state.dataSurface->FenLayAbsSSG(Loop).SchedPtrs)) { - state.dataSurface->FenLayAbsSSG(Loop).SchedPtrs.allocate(NumOfScheduledLayers); + if (!allocated(state.dataSurface->FenLayAbsSSG(Loop).scheds)) { + state.dataSurface->FenLayAbsSSG(Loop).scheds.allocate(NumOfScheduledLayers); } state.dataSurface->FenLayAbsSSG(Loop).NumOfSched = NumOfScheduledLayers; for (int i = 1; i <= NumOfScheduledLayers; ++i) { - ScheduleNum = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(i + 3)); - if (ScheduleNum == 0) { - ShowSevereError(state, - format("{}{}=\"{}, object. Illegal value for {} has been found.", - RoutineName, - cCurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaFieldNames(NumOfScheduledLayers + 3))); - ShowContinueError(state, - format("{} entered value = \"{}\" no corresponding schedule has been found in the input file.", - state.dataIPShortCut->cAlphaFieldNames(NumOfScheduledLayers + 3), - state.dataIPShortCut->cAlphaArgs(NumOfScheduledLayers + 3))); + if ((state.dataSurface->FenLayAbsSSG(Loop).scheds(i) = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(i + 3))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(NumOfScheduledLayers + 3), + state.dataIPShortCut->cAlphaArgs(NumOfScheduledLayers + 3)); ErrorsFound = true; - } else { - state.dataSurface->FenLayAbsSSG(Loop).SchedPtrs(i) = ScheduleNum; } } } @@ -5301,7 +5237,7 @@ namespace HeatBalanceManager { windowThermalModel.SDScalar = s_ipsc->rNumericArgs(1); if ((s_ipsc->rNumericArgs(1) < 0.0) || (s_ipsc->rNumericArgs(1) > 1.0)) { - ShowSevereCustomMessage( + ShowSevereCustom( state, eoh, format("{} should be >= 0.0 and <= 1.0, entered value = {:.2R}", s_ipsc->cNumericFieldNames(1), s_ipsc->rNumericArgs(1))); @@ -5319,22 +5255,19 @@ namespace HeatBalanceManager { windowThermalModel.VacuumPressureLimit = s_ipsc->rNumericArgs(2); if (s_ipsc->rNumericArgs(2) <= 0.0) { ErrorsFound = true; - ShowSevereCustomMessage( - state, eoh, format("{} must be > 0, entered value = {:.2R}", s_ipsc->cNumericFieldNames(2), s_ipsc->rNumericArgs(2))); + ShowSevereCustom(state, eoh, format("{} must be > 0, entered value = {:.2R}", s_ipsc->cNumericFieldNames(2), s_ipsc->rNumericArgs(2))); } windowThermalModel.InitialTemperature = s_ipsc->rNumericArgs(3); if (s_ipsc->rNumericArgs(3) <= 0.0) { ErrorsFound = true; - ShowSevereCustomMessage( - state, eoh, format("{} must be > 0, entered value = {:.2R}", s_ipsc->cNumericFieldNames(3), s_ipsc->rNumericArgs(3))); + ShowSevereCustom(state, eoh, format("{} must be > 0, entered value = {:.2R}", s_ipsc->cNumericFieldNames(3), s_ipsc->rNumericArgs(3))); } windowThermalModel.InitialPressure = s_ipsc->rNumericArgs(4); if (s_ipsc->rNumericArgs(4) <= 0.0) { ErrorsFound = true; - ShowSevereCustomMessage( - state, eoh, format("{} must be > 0, entered value = {:.2R}", s_ipsc->cNumericFieldNames(4), s_ipsc->rNumericArgs(4))); + ShowSevereCustom(state, eoh, format("{} must be > 0, entered value = {:.2R}", s_ipsc->cNumericFieldNames(4), s_ipsc->rNumericArgs(4))); } } @@ -5413,11 +5346,11 @@ namespace HeatBalanceManager { if (NumCols != 2 && NumCols != 1) { ErrorsFound = true; - ShowSevereCustomMessage(state, - eoh, - format("{} entered value=\"{}\" invalid matrix dimensions. Basis matrix dimension can only be 2 x 1.", - locAlphaFieldNames(5), - locAlphaArgs(5))); + ShowSevereCustom(state, + eoh, + format("{} entered value=\"{}\" invalid matrix dimensions. Basis matrix dimension can only be 2 x 1.", + locAlphaFieldNames(5), + locAlphaArgs(5))); } thisConstruct.BSDFInput.BasisMat.allocate(NumCols, NumRows); MatrixDataManager::Get2DMatrix(state, thisConstruct.BSDFInput.BasisMatIndex, thisConstruct.BSDFInput.BasisMat); @@ -5437,7 +5370,7 @@ namespace HeatBalanceManager { if (mod((NumAlphas - 9), 3) != 0) { // throw warning if incomplete field set ErrorsFound = true; - ShowSevereCustomMessage(state, eoh, format("{} is missing some of the layers or/and gaps.", locAlphaArgs(1))); + ShowSevereCustom(state, eoh, format("{} is missing some of the layers or/and gaps.", locAlphaArgs(1))); } if (thisConstruct.BSDFInput.BasisSymmetryType == DataBSDFWindow::BasisSymmetry::None) { @@ -5455,7 +5388,7 @@ namespace HeatBalanceManager { if (NumRows != NBasis) { ErrorsFound = true; - ShowSevereCustomMessage( + ShowSevereCustom( state, eoh, format("Solar front transmittance matrix \"{}\" is not the same size as it is defined by basis definition. Basis " @@ -5466,7 +5399,7 @@ namespace HeatBalanceManager { if (NumRows != NumCols) { ErrorsFound = true; - ShowSevereCustomMessage( + ShowSevereCustom( state, eoh, format("Solar front transmittance matrix \"{}\" must have the same number of rows and columns.", locAlphaArgs(6))); @@ -5480,7 +5413,7 @@ namespace HeatBalanceManager { thisConstruct.BSDFInput.SolFrtTrans.allocate(NumCols, NumRows); if (thisConstruct.BSDFInput.SolFrtTransIndex == 0) { ErrorsFound = true; - ShowSevereCustomMessage( + ShowSevereCustom( state, eoh, format("Solar front transmittance Matrix:TwoDimension = \"{}\" is missing from the input file.", locAlphaArgs(6))); @@ -5498,7 +5431,7 @@ namespace HeatBalanceManager { if (NumRows != NBasis) { ErrorsFound = true; - ShowSevereCustomMessage( + ShowSevereCustom( state, eoh, format("Solar back reflectance matrix \"{}\" is not the same size as it is defined by basis definition. Basis size " @@ -5509,14 +5442,14 @@ namespace HeatBalanceManager { if (NumRows != NumCols) { ErrorsFound = true; - ShowSevereCustomMessage( + ShowSevereCustom( state, eoh, format("Solar back reflectance matrix \"{}\" must have the same number of rows and columns.", locAlphaArgs(7))); } thisConstruct.BSDFInput.SolBkRefl.allocate(NumCols, NumRows); if (thisConstruct.BSDFInput.SolBkReflIndex == 0) { ErrorsFound = true; - ShowSevereCustomMessage( + ShowSevereCustom( state, eoh, format("Solar back reflectance Matrix:TwoDimension = \"{}\" is missing from the input file.", locAlphaArgs(7))); } else { MatrixDataManager::Get2DMatrix(state, thisConstruct.BSDFInput.SolBkReflIndex, thisConstruct.BSDFInput.SolBkRefl); @@ -5532,7 +5465,7 @@ namespace HeatBalanceManager { if (NumRows != NBasis) { ErrorsFound = true; - ShowSevereCustomMessage( + ShowSevereCustom( state, eoh, format("Visible front transmittance matrix \"{}\" is not the same size as it is defined by basis definition. Basis " @@ -5543,7 +5476,7 @@ namespace HeatBalanceManager { if (NumRows != NumCols) { ErrorsFound = true; - ShowSevereCustomMessage( + ShowSevereCustom( state, eoh, format("Visible front transmittance matrix \"{}\" must have the same number of rows and columns.", locAlphaArgs(8))); @@ -5552,7 +5485,7 @@ namespace HeatBalanceManager { thisConstruct.BSDFInput.VisFrtTrans.allocate(NumCols, NumRows); if (thisConstruct.BSDFInput.VisFrtTransIndex == 0) { ErrorsFound = true; - ShowSevereCustomMessage( + ShowSevereCustom( state, eoh, format("Visible front transmittance Matrix:TwoDimension = \"{}\" is missing from the input file.", locAlphaArgs(8))); @@ -5570,7 +5503,7 @@ namespace HeatBalanceManager { if (NumRows != NBasis) { ErrorsFound = true; - ShowSevereCustomMessage( + ShowSevereCustom( state, eoh, format("Visible back reflectance matrix \"{}\" is not the same size as it is defined by basis definition. Basis " @@ -5581,14 +5514,14 @@ namespace HeatBalanceManager { if (NumRows != NumCols) { ErrorsFound = true; - ShowSevereCustomMessage( + ShowSevereCustom( state, eoh, format("Visible back reflectance \"{}\" must have the same number of rows and columns.", locAlphaArgs(9))); } thisConstruct.BSDFInput.VisBkRefl.allocate(NumCols, NumRows); if (thisConstruct.BSDFInput.VisBkReflIndex == 0) { ErrorsFound = true; - ShowSevereCustomMessage( + ShowSevereCustom( state, eoh, format("Visble back reflectance Matrix:TwoDimension = \"{}\" is missing from the input file.", locAlphaArgs(9))); } else { MatrixDataManager::Get2DMatrix(state, thisConstruct.BSDFInput.VisBkReflIndex, thisConstruct.BSDFInput.VisBkRefl); @@ -5616,7 +5549,7 @@ namespace HeatBalanceManager { if (NumRows != 1) { ErrorsFound = true; - ShowSevereCustomMessage(state, + ShowSevereCustom(state, eoh, format("Front absorbtance Matrix:TwoDimension = \"{}\" for layer {} must have only one row.", locAlphaArgs(AlphaIndex), @@ -5625,7 +5558,7 @@ namespace HeatBalanceManager { if (NumCols != NBasis) { ErrorsFound = true; - ShowSevereCustomMessage( + ShowSevereCustom( state, eoh, format("Front absorbtance Matrix:TwoDimension = \"{}\" for layer {} must have same number of columns " @@ -5641,7 +5574,7 @@ namespace HeatBalanceManager { thisConstruct.BSDFInput.Layer(currentOpticalLayer).FrtAbs.allocate(NumCols, NumRows); if (thisConstruct.BSDFInput.Layer(currentOpticalLayer).FrtAbsIndex == 0) { ErrorsFound = true; - ShowSevereCustomMessage( + ShowSevereCustom( state, eoh, format("Front absorbtance Matrix:TwoDimension = \"{}\" for layer {} is missing from the input file.", @@ -5664,16 +5597,16 @@ namespace HeatBalanceManager { if (NumRows != 1) { ErrorsFound = true; - ShowSevereCustomMessage(state, - eoh, - format("Back absorbtance Matrix:TwoDimension = \"{}\" for layer {} must have only one row.", - locAlphaArgs(AlphaIndex), - currentOpticalLayer)); + ShowSevereCustom(state, + eoh, + format("Back absorbtance Matrix:TwoDimension = \"{}\" for layer {} must have only one row.", + locAlphaArgs(AlphaIndex), + currentOpticalLayer)); } if (NumCols != NBasis) { ErrorsFound = true; - ShowSevereCustomMessage( + ShowSevereCustom( state, eoh, format("Back absorbtance Matrix:TwoDimension = \"{}\" for layer {} must have same number of columns as " @@ -5688,7 +5621,7 @@ namespace HeatBalanceManager { thisConstruct.BSDFInput.Layer(currentOpticalLayer).BkAbs.allocate(NumCols, NumRows); if (thisConstruct.BSDFInput.Layer(currentOpticalLayer).BkAbsIndex == 0) { ErrorsFound = true; - ShowSevereCustomMessage( + ShowSevereCustom( state, eoh, format("Back absorbtance Matrix:TwoDimension = \"{}\" for layer {} is missing from the input file.", @@ -5716,7 +5649,7 @@ namespace HeatBalanceManager { if (NumRows != NBasis) { ErrorsFound = true; - ShowSevereCustomMessage( + ShowSevereCustom( state, eoh, format("Solar front transmittance matrix \"{}\" is not the same size as it is defined by basis definition. Basis " @@ -5727,7 +5660,7 @@ namespace HeatBalanceManager { if (NumRows != NumCols) { ErrorsFound = true; - ShowSevereCustomMessage( + ShowSevereCustom( state, eoh, format("Solar front transmittance matrix \"{}\" must have the same number of rows and columns.", locAlphaArgs(6))); @@ -5736,7 +5669,7 @@ namespace HeatBalanceManager { thisConstruct.BSDFInput.SolFrtTrans.allocate(NBasis, NBasis); if (thisConstruct.BSDFInput.SolFrtTransIndex == 0) { ErrorsFound = true; - ShowSevereCustomMessage( + ShowSevereCustom( state, eoh, format("Solar front transmittance Matrix:TwoDimension = \"{}\" is missing from the input file.", locAlphaArgs(6))); @@ -5759,7 +5692,7 @@ namespace HeatBalanceManager { if (NumRows != NBasis) { ErrorsFound = true; - ShowSevereCustomMessage( + ShowSevereCustom( state, eoh, format("Solar back reflectance matrix \"{}\" is not the same size as it is defined by basis definition. Basis size " @@ -5770,14 +5703,14 @@ namespace HeatBalanceManager { if (NumRows != NumCols) { ErrorsFound = true; - ShowSevereCustomMessage( + ShowSevereCustom( state, eoh, format("Solar back reflectance matrix \"{}\" must have the same number of rows and columns.", locAlphaArgs(7))); } thisConstruct.BSDFInput.SolBkRefl.allocate(NBasis, NBasis); if (thisConstruct.BSDFInput.SolBkReflIndex == 0) { ErrorsFound = true; - ShowSevereCustomMessage( + ShowSevereCustom( state, eoh, format("Solar back reflectance Matrix:TwoDimension = \"{}\" is missing from the input file.", locAlphaArgs(7))); } else { MatrixDataManager::Get2DMatrix(state, thisConstruct.BSDFInput.SolBkReflIndex, state.dataBSDFWindow->BSDFTempMtrx); @@ -5797,7 +5730,7 @@ namespace HeatBalanceManager { if (NumRows != NBasis) { ErrorsFound = true; - ShowSevereCustomMessage( + ShowSevereCustom( state, eoh, format("Visible front transmittance matrix \"{}\" is not the same size as it is defined by basis definition. Basis " @@ -5808,7 +5741,7 @@ namespace HeatBalanceManager { if (NumRows != NumCols) { ErrorsFound = true; - ShowSevereCustomMessage( + ShowSevereCustom( state, eoh, format("Visible front transmittance matrix \"{}\" must have the same number of rows and columns.", locAlphaArgs(8))); @@ -5817,7 +5750,7 @@ namespace HeatBalanceManager { thisConstruct.BSDFInput.VisFrtTrans.allocate(NBasis, NBasis); if (thisConstruct.BSDFInput.VisFrtTransIndex == 0) { ErrorsFound = true; - ShowSevereCustomMessage( + ShowSevereCustom( state, eoh, format("Visible front transmittance Matrix:TwoDimension = \"{}\" is missing from the input file.", locAlphaArgs(8))); @@ -5839,7 +5772,7 @@ namespace HeatBalanceManager { if (NumRows != NBasis) { ErrorsFound = true; - ShowSevereCustomMessage( + ShowSevereCustom( state, eoh, format("Visible back reflectance matrix \"{}\" is not the same size as it is defined by basis definition. Basis " @@ -5850,14 +5783,14 @@ namespace HeatBalanceManager { if (NumRows != NumCols) { ErrorsFound = true; - ShowSevereCustomMessage( + ShowSevereCustom( state, eoh, format("Visible back reflectance matrix \"{}\" must have the same number of rows and columns.", locAlphaArgs(9))); } thisConstruct.BSDFInput.VisBkRefl.allocate(NBasis, NBasis); if (thisConstruct.BSDFInput.VisBkReflIndex == 0) { ErrorsFound = true; - ShowSevereCustomMessage( + ShowSevereCustom( state, eoh, format("Visible back reflectance Matrix:TwoDimension = \"{}\" is missing from the input file.", locAlphaArgs(9))); } else { MatrixDataManager::Get2DMatrix(state, thisConstruct.BSDFInput.VisBkReflIndex, state.dataBSDFWindow->BSDFTempMtrx); @@ -5894,16 +5827,16 @@ namespace HeatBalanceManager { if (NumRows != 1) { ErrorsFound = true; - ShowSevereCustomMessage(state, - eoh, - format("Front absorbtance Matrix:TwoDimension = \"{}\" for layer {} must have only one row.", - locAlphaArgs(AlphaIndex), - currentOpticalLayer)); + ShowSevereCustom(state, + eoh, + format("Front absorbtance Matrix:TwoDimension = \"{}\" for layer {} must have only one row.", + locAlphaArgs(AlphaIndex), + currentOpticalLayer)); } if (NumCols != NBasis) { ErrorsFound = true; - ShowSevereCustomMessage( + ShowSevereCustom( state, eoh, format("Front absorbtance Matrix:TwoDimension = \"{}\" for layer {} must have same number of columns " @@ -5920,7 +5853,7 @@ namespace HeatBalanceManager { if (thisConstruct.BSDFInput.Layer(currentOpticalLayer).FrtAbsIndex == 0) { ErrorsFound = true; - ShowSevereCustomMessage( + ShowSevereCustom( state, eoh, format("Front absorbtance Matrix:TwoDimension = \"{}\" for layer {} is missing from the input file.", @@ -5943,16 +5876,16 @@ namespace HeatBalanceManager { if (NumRows != 1) { ErrorsFound = true; - ShowSevereCustomMessage(state, - eoh, - format("Back absorbtance Matrix:TwoDimension = \"{}\" for layer {} must have only one row.", - locAlphaArgs(AlphaIndex), - currentOpticalLayer)); + ShowSevereCustom(state, + eoh, + format("Back absorbtance Matrix:TwoDimension = \"{}\" for layer {} must have only one row.", + locAlphaArgs(AlphaIndex), + currentOpticalLayer)); } if (NumCols != NBasis) { ErrorsFound = true; - ShowSevereCustomMessage( + ShowSevereCustom( state, eoh, format("Back absorbtance Matrix:TwoDimension = \"{}\" for layer {} must have same number of columns as " @@ -5968,7 +5901,7 @@ namespace HeatBalanceManager { if (thisConstruct.BSDFInput.Layer(currentOpticalLayer).BkAbsIndex == 0) { ErrorsFound = true; - ShowSevereCustomMessage( + ShowSevereCustom( state, eoh, format("Back absorbtance Matrix:TwoDimension = \"{}\" for layer {} is missing from the input file.", diff --git a/src/EnergyPlus/HeatBalanceManager.hh b/src/EnergyPlus/HeatBalanceManager.hh index 7b415723c7b..eebacb8c509 100644 --- a/src/EnergyPlus/HeatBalanceManager.hh +++ b/src/EnergyPlus/HeatBalanceManager.hh @@ -227,6 +227,10 @@ struct HeatBalanceMgrData : BaseGlobalStruct Array1D WarmupConvergenceValues; SurfaceOctreeCube surfaceOctree; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/HeatBalanceSurfaceManager.cc b/src/EnergyPlus/HeatBalanceSurfaceManager.cc index 858ea5892a1..ce702a5ce5c 100644 --- a/src/EnergyPlus/HeatBalanceSurfaceManager.cc +++ b/src/EnergyPlus/HeatBalanceSurfaceManager.cc @@ -224,13 +224,13 @@ void UpdateVariableAbsorptances(EnergyPlusData &state) auto const *thisMaterial = s_mat->materials(thisConstruct.LayerPoint(1)); assert(thisMaterial != nullptr); if (thisMaterial->absorpVarCtrlSignal == Material::VariableAbsCtrlSignal::Scheduled) { - if (thisMaterial->absorpThermalVarSchedIdx > 0) { + if (thisMaterial->absorpThermalVarSched != nullptr) { state.dataHeatBalSurf->SurfAbsThermalExt(surfNum) = - max(min(ScheduleManager::GetCurrentScheduleValue(state, thisMaterial->absorpThermalVarSchedIdx), 0.9999), 0.0001); + max(min(thisMaterial->absorpThermalVarSched->getCurrentVal(), 0.9999), 0.0001); } - if (thisMaterial->absorpSolarVarSchedIdx > 0) { + if (thisMaterial->absorpSolarVarSched != nullptr) { state.dataHeatBalSurf->SurfAbsSolarExt(surfNum) = - max(min(ScheduleManager::GetCurrentScheduleValue(state, thisMaterial->absorpThermalVarSchedIdx), 0.9999), 0.0001); + max(min(thisMaterial->absorpThermalVarSched->getCurrentVal(), 0.9999), 0.0001); } } else { Real64 triggerValue; @@ -2338,7 +2338,7 @@ void EvalOutsideMovableInsulation(EnergyPlusData &state) // This subroutine determines whether or not outside movable insulation on opaque surfaces is present at the current time. auto &s_mat = state.dataMaterial; for (int SurfNum : state.dataHeatBalSurf->SurfMovInsulIndexList) { - Real64 MovInsulSchedVal = ScheduleManager::GetCurrentScheduleValue(state, state.dataSurface->SurfSchedMovInsulExt(SurfNum)); + Real64 MovInsulSchedVal = state.dataSurface->SurfMovInsulExtScheds(SurfNum)->getCurrentVal(); if (MovInsulSchedVal <= 0) { // Movable insulation not present at current time state.dataHeatBalSurf->SurfMovInsulExtPresent(SurfNum) = false; int ConstrNum = state.dataSurface->SurfActiveConstruction(SurfNum); @@ -2369,7 +2369,7 @@ void EvalInsideMovableInsulation(EnergyPlusData &state) auto &s_mat = state.dataMaterial; // This subroutine determines whether or not inside movable insulation is present at the current time. for (int SurfNum : state.dataHeatBalSurf->SurfMovInsulIndexList) { - Real64 MovInsulSchedVal = ScheduleManager::GetCurrentScheduleValue(state, state.dataSurface->SurfSchedMovInsulInt(SurfNum)); + Real64 MovInsulSchedVal = state.dataSurface->SurfMovInsulIntScheds(SurfNum)->getCurrentVal(); if (MovInsulSchedVal <= 0.0) { // Movable insulation not present at current time state.dataHeatBalSurf->SurfMovInsulIntPresent(SurfNum) = false; int ConstrNum = state.dataSurface->SurfActiveConstruction(SurfNum); @@ -3197,7 +3197,7 @@ void InitSolarHeatGains(EnergyPlusData &state) for (int Lay = 1; Lay <= TotSolidLay; ++Lay) { if (SurfSolAbs != 0) { state.dataSurface->SurfWinA(SurfNum, Lay) = - ScheduleManager::GetCurrentScheduleValue(state, state.dataSurface->FenLayAbsSSG(SurfSolAbs).SchedPtrs(Lay)); + state.dataSurface->FenLayAbsSSG(SurfSolAbs).scheds(Lay)->getCurrentVal(); // ABWin(Lay) = SurfWinA(SurfNum,Lay) state.dataHeatBal->SurfWinQRadSWwinAbs(SurfNum, Lay) = state.dataSurface->SurfWinA(SurfNum, Lay); } else { @@ -5644,7 +5644,7 @@ void ReportThermalResilience(EnergyPlusData &state) int ZoneNum = state.dataHeatBal->People(iPeople).ZonePtr; state.dataHeatBal->Resilience(ZoneNum).ZoneNumOcc = state.dataHeatBal->People(iPeople).NumberOfPeople * - ScheduleManager::GetCurrentScheduleValue(state, state.dataHeatBal->People(iPeople).NumberOfPeoplePtr); + state.dataHeatBal->People(iPeople).numberOfPeopleSched->getCurrentVal(); state.dataHeatBal->Resilience(ZoneNum).ZonePierceSETLastStep = state.dataHeatBal->Resilience(ZoneNum).ZonePierceSET; if (state.dataHeatBal->People(iPeople).Pierce) { state.dataHeatBal->Resilience(ZoneNum).ZonePierceSET = state.dataThermalComforts->ThermalComfortData(iPeople).PierceSET; @@ -5894,8 +5894,9 @@ void ReportThermalResilience(EnergyPlusData &state) } Real64 Temperature = state.dataZoneTempPredictorCorrector->zoneHeatBalance(ZoneNum).ZTAV; - Real64 CoolingSetpoint = state.dataHeatBalFanSys->ZoneThermostatSetPointHi(ZoneNum); - Real64 HeatingSetpoint = state.dataHeatBalFanSys->ZoneThermostatSetPointLo(ZoneNum); + auto const &zoneTstatSetpt = state.dataHeatBalFanSys->zoneTstatSetpts(ZoneNum); + Real64 CoolingSetpoint = zoneTstatSetpt.setptHi; + Real64 HeatingSetpoint = zoneTstatSetpt.setptLo; if ((CoolingSetpoint > 0) && (Temperature > CoolingSetpoint)) { state.dataHeatBal->Resilience(ZoneNum).ZoneUnmetDegreeHourBins[0] += (Temperature - CoolingSetpoint) * state.dataGlobal->TimeStepZone; @@ -6164,7 +6165,7 @@ void ReportCO2Resilience(EnergyPlusData &state) int ZoneNum = state.dataHeatBal->People(iPeople).ZonePtr; state.dataHeatBal->Resilience(ZoneNum).ZoneNumOcc = state.dataHeatBal->People(iPeople).NumberOfPeople * - ScheduleManager::GetCurrentScheduleValue(state, state.dataHeatBal->People(iPeople).NumberOfPeoplePtr); + state.dataHeatBal->People(iPeople).numberOfPeopleSched->getCurrentVal(); } Array1D_bool reportPeriodFlags; @@ -6255,7 +6256,7 @@ void ReportVisualResilience(EnergyPlusData &state) int ZoneNum = state.dataHeatBal->People(iPeople).ZonePtr; state.dataHeatBal->Resilience(ZoneNum).ZoneNumOcc = state.dataHeatBal->People(iPeople).NumberOfPeople * - ScheduleManager::GetCurrentScheduleValue(state, state.dataHeatBal->People(iPeople).NumberOfPeoplePtr); + state.dataHeatBal->People(iPeople).numberOfPeopleSched->getCurrentVal(); } // Accumulate across daylighting controls first for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) { @@ -6570,7 +6571,7 @@ void ReportSurfaceHeatBalance(EnergyPlusData &state) } if (state.dataGlobal->ZoneSizingCalc && state.dataGlobal->CompLoadReportIsReq) { - int TimeStepInDay = (state.dataGlobal->HourOfDay - 1) * state.dataGlobal->NumOfTimeStepInHour + state.dataGlobal->TimeStep; + int TimeStepInDay = (state.dataGlobal->HourOfDay - 1) * state.dataGlobal->TimeStepsInHour + state.dataGlobal->TimeStep; for (int zoneNum = 1; zoneNum <= state.dataGlobal->NumOfZones; ++zoneNum) { for (int spaceNum : state.dataHeatBal->Zone(zoneNum).spaceIndexes) { auto const &thisSpace = state.dataHeatBal->space(spaceNum); @@ -6731,8 +6732,6 @@ void CalcHeatBalanceOutsideSurf(EnergyPlusData &state, // using namespace DataHeatBalSurface; // using namespace DataSurfaces; // using HeatBalanceIntRadExchange::CalcInteriorRadExchange; - // using ScheduleManager::GetCurrentScheduleValue; - // using ScheduleManager::GetScheduleIndex; // using namespace Psychrometrics; // using EcoRoofManager::CalcEcoRoof; // @@ -6794,8 +6793,7 @@ void CalcHeatBalanceOutsideSurf(EnergyPlusData &state, // Calculate heat extract due to additional heat flux source term as the surface boundary condition for (int surfNum : state.dataSurface->allOutsideSourceSurfaceList) { - state.dataHeatBalSurf->SurfQAdditionalHeatSourceOutside(surfNum) = - EnergyPlus::ScheduleManager::GetCurrentScheduleValue(state, Surface(surfNum).OutsideHeatSourceTermSchedule); + state.dataHeatBalSurf->SurfQAdditionalHeatSourceOutside(surfNum) = Surface(surfNum).outsideHeatSourceTermSched->getCurrentVal(); } for (int zoneNum = 1; zoneNum <= state.dataGlobal->NumOfZones; ++zoneNum) { // Loop through all surfaces... for (int spaceNum : state.dataHeatBal->Zone(zoneNum).spaceIndexes) { @@ -6960,9 +6958,8 @@ void CalcHeatBalanceOutsideSurf(EnergyPlusData &state, state.dataSurface->OSC(OPtr).TOutsideSurfPast = state.dataHeatBalSurf->SurfOutsideTempHist(1)(SurfNum); } - if (state.dataSurface->OSC(OPtr).ConstTempScheduleIndex != 0) { // Determine outside temperature from schedule - state.dataSurface->OSC(OPtr).ConstTemp = - ScheduleManager::GetCurrentScheduleValue(state, state.dataSurface->OSC(OPtr).ConstTempScheduleIndex); + if (state.dataSurface->OSC(OPtr).constTempSched != nullptr) { // Determine outside temperature from schedule + state.dataSurface->OSC(OPtr).ConstTemp = state.dataSurface->OSC(OPtr).constTempSched->getCurrentVal(); } // Allow for modification of TemperatureCoefficient with unitary sine wave. @@ -7031,9 +7028,8 @@ void CalcHeatBalanceOutsideSurf(EnergyPlusData &state, state.dataSurface->OSC(OPtr).TOutsideSurfPast = state.dataHeatBalSurf->SurfOutsideTempHist(1)(SurfNum); } - if (state.dataSurface->OSC(OPtr).ConstTempScheduleIndex != 0) { // Determine outside temperature from schedule - state.dataSurface->OSC(OPtr).ConstTemp = - ScheduleManager::GetCurrentScheduleValue(state, state.dataSurface->OSC(OPtr).ConstTempScheduleIndex); + if (state.dataSurface->OSC(OPtr).constTempSched != nullptr) { // Determine outside temperature from schedule + state.dataSurface->OSC(OPtr).ConstTemp = state.dataSurface->OSC(OPtr).constTempSched->getCurrentVal(); } state.dataHeatBalSurf->SurfHConvExt(SurfNum) = state.dataSurface->OSC(OPtr).SurfFilmCoef; @@ -7335,9 +7331,7 @@ void CalcHeatBalanceOutsideSurf(EnergyPlusData &state, // View factor of a surrounding surface Real64 SrdSurfViewFac = state.dataSurface->SurroundingSurfsProperty(SrdSurfsNum).SurroundingSurfs(SrdSurfNum).ViewFactor; // Absolute temperature of a surrounding surface - Real64 SrdSurfTempAbs = - ScheduleManager::GetCurrentScheduleValue( - state, state.dataSurface->SurroundingSurfsProperty(SrdSurfsNum).SurroundingSurfs(SrdSurfNum).TempSchNum) + + Real64 SrdSurfTempAbs = state.dataSurface->SurroundingSurfsProperty(SrdSurfsNum).SurroundingSurfs(SrdSurfNum).tempSched->getCurrentVal() + Constant::Kelvin; state.dataHeatBalSurf->SurfQRadLWOutSrdSurfs(SurfNum) += Constant::StefanBoltzmann * AbsThermSurf * SrdSurfViewFac * (pow_4(SrdSurfTempAbs) - pow_4(TSurf)); @@ -7619,7 +7613,7 @@ void CalcHeatBalanceInsideSurf2(EnergyPlusData &state, // Calculate heat extract due to additional heat flux source term as the surface boundary condition for (int surfNum : state.dataSurface->allInsideSourceSurfaceList) { state.dataHeatBalSurf->SurfQAdditionalHeatSourceInside(surfNum) = - EnergyPlus::ScheduleManager::GetCurrentScheduleValue(state, state.dataSurface->Surface(surfNum).InsideHeatSourceTermSchedule); + state.dataSurface->Surface(surfNum).insideHeatSourceTermSched->getCurrentVal(); } // Calculate Kiva instances @@ -8462,7 +8456,7 @@ void CalcHeatBalanceInsideSurf2CTFOnly(EnergyPlusData &state, // Calculate heat extract due to additional heat flux source term as the surface boundary condition for (int surfNum : state.dataSurface->allInsideSourceSurfaceList) { state.dataHeatBalSurf->SurfQAdditionalHeatSourceInside(surfNum) = - EnergyPlus::ScheduleManager::GetCurrentScheduleValue(state, state.dataSurface->Surface(surfNum).InsideHeatSourceTermSchedule); + state.dataSurface->Surface(surfNum).insideHeatSourceTermSched->getCurrentVal(); } // Set up coefficient arrays prior to calculations and precalc terms that do no change during iteration - non-window surfaces @@ -9200,11 +9194,11 @@ void CalcOutsideSurfTemp(EnergyPlusData &state, if (surface.SurfHasSurroundingSurfProperty) { int SrdSurfsNum = surface.SurfSurroundingSurfacesNum; - if (state.dataSurface->SurroundingSurfsProperty(SrdSurfsNum).SkyTempSchNum != 0) { - TSky = ScheduleManager::GetCurrentScheduleValue(state, state.dataSurface->SurroundingSurfsProperty(SrdSurfsNum).SkyTempSchNum); + if (state.dataSurface->SurroundingSurfsProperty(SrdSurfsNum).skyTempSched != nullptr) { + TSky = state.dataSurface->SurroundingSurfsProperty(SrdSurfsNum).skyTempSched->getCurrentVal(); } - if (state.dataSurface->SurroundingSurfsProperty(SrdSurfsNum).GroundTempSchNum != 0) { - TGround = ScheduleManager::GetCurrentScheduleValue(state, state.dataSurface->SurroundingSurfsProperty(SrdSurfsNum).GroundTempSchNum); + if (state.dataSurface->SurroundingSurfsProperty(SrdSurfsNum).groundTempSched != nullptr) { + TGround = state.dataSurface->SurroundingSurfsProperty(SrdSurfsNum).groundTempSched->getCurrentVal(); } TSrdSurfs = state.dataSurface->Surface(SurfNum).SrdSurfTemp; } @@ -9500,7 +9494,7 @@ void CalcExteriorVentedCavity(EnergyPlusData &state, int const SurfNum) // index state.dataHeatBal->ExtVentedCavity(CavNum).HcPlen = HcPlen; state.dataHeatBal->ExtVentedCavity(CavNum).PassiveACH = (MdotVent / RhoAir) * - (1.0 / (state.dataHeatBal->ExtVentedCavity(CavNum).ProjArea * state.dataHeatBal->ExtVentedCavity(CavNum).PlenGapThick)) * Constant::SecInHour; + (1.0 / (state.dataHeatBal->ExtVentedCavity(CavNum).ProjArea * state.dataHeatBal->ExtVentedCavity(CavNum).PlenGapThick)) * Constant::rSecsInHour; state.dataHeatBal->ExtVentedCavity(CavNum).PassiveMdotVent = MdotVent; state.dataHeatBal->ExtVentedCavity(CavNum).PassiveMdotWind = VdotWind * RhoAir; state.dataHeatBal->ExtVentedCavity(CavNum).PassiveMdotTherm = VdotThermal * RhoAir; @@ -9531,7 +9525,7 @@ void GatherComponentLoadsSurfAbsFact(EnergyPlusData &state) // Save sequence of values for report during sizing. if (state.dataGlobal->CompLoadReportIsReq && !state.dataGlobal->isPulseZoneSizing) { - int TimeStepInDay = (state.dataGlobal->HourOfDay - 1) * state.dataGlobal->NumOfTimeStepInHour + state.dataGlobal->TimeStep; + int TimeStepInDay = (state.dataGlobal->HourOfDay - 1) * state.dataGlobal->TimeStepsInHour + state.dataGlobal->TimeStep; for (int enclosureNum = 1; enclosureNum <= state.dataViewFactor->NumOfRadiantEnclosures; ++enclosureNum) { state.dataOutRptTab->TMULTseq(state.dataSize->CurOverallSimDay, TimeStepInDay, enclosureNum) = state.dataViewFactor->EnclRadInfo(enclosureNum).radThermAbsMult; @@ -9547,15 +9541,13 @@ void GatherComponentLoadsSurfAbsFact(EnergyPlusData &state) Real64 GetSurfIncidentSolarMultiplier(EnergyPlusData &state, int SurfNum) { - if (state.dataSurface->Surface(SurfNum).hasIncSolMultiplier) { - if (state.dataSurface->SurfIncSolMultiplier(SurfNum).SchedPtr > 0) { - return ScheduleManager::GetCurrentScheduleValue(state, state.dataSurface->SurfIncSolMultiplier(SurfNum).SchedPtr) * - state.dataSurface->SurfIncSolMultiplier(SurfNum).Scaler; - } else { - return state.dataSurface->SurfIncSolMultiplier(SurfNum).Scaler; - } - } else { + if (!state.dataSurface->Surface(SurfNum).hasIncSolMultiplier) { return 1.0; + } else if (state.dataSurface->SurfIncSolMultiplier(SurfNum).sched != nullptr) { + return state.dataSurface->SurfIncSolMultiplier(SurfNum).sched->getCurrentVal() * + state.dataSurface->SurfIncSolMultiplier(SurfNum).Scaler; + } else { + return state.dataSurface->SurfIncSolMultiplier(SurfNum).Scaler; } } @@ -9684,8 +9676,8 @@ void GetGroundSurfacesTemperatureAverage(EnergyPlusData &state) for (int gSurfNum = 1; gSurfNum <= GndSurfsProperty.NumGndSurfs; gSurfNum++) { GndSurfViewFactor = GndSurfsProperty.GndSurfs(gSurfNum).ViewFactor; if (GndSurfViewFactor == 0.0) continue; - if (GndSurfsProperty.GndSurfs(gSurfNum).TempSchPtr == 0) continue; - GndSurfaceTemp = ScheduleManager::GetCurrentScheduleValue(state, GndSurfsProperty.GndSurfs(gSurfNum).TempSchPtr); + if (GndSurfsProperty.GndSurfs(gSurfNum).tempSched == nullptr) continue; + GndSurfaceTemp = GndSurfsProperty.GndSurfs(gSurfNum).tempSched->getCurrentVal(); GndSurfaceTempSum += GndSurfViewFactor * pow_4(GndSurfaceTemp + Constant::Kelvin); } if (GndSurfaceTempSum == 0.0) { @@ -9717,8 +9709,8 @@ void GetGroundSurfacesReflectanceAverage(EnergyPlusData &state) Real64 GndSurfRefl = 0.0; Real64 GndSurfsReflSum = 0.0; for (int gSurfNum = 1; gSurfNum <= GndSurfsProperty.NumGndSurfs; gSurfNum++) { - if (GndSurfsProperty.GndSurfs(gSurfNum).ReflSchPtr == 0) continue; - GndSurfRefl = ScheduleManager::GetCurrentScheduleValue(state, GndSurfsProperty.GndSurfs(gSurfNum).ReflSchPtr); + if (GndSurfsProperty.GndSurfs(gSurfNum).reflSched == nullptr) continue; + GndSurfRefl = GndSurfsProperty.GndSurfs(gSurfNum).reflSched->getCurrentVal(); GndSurfsReflSum += GndSurfsProperty.GndSurfs(gSurfNum).ViewFactor * GndSurfRefl; } if (GndSurfsReflSum == 0.0) { @@ -9765,8 +9757,7 @@ void GetSurroundingSurfacesTemperatureAverage(EnergyPlusData &state) Real64 SrdSurfaceTempSum = 0.0; auto &SrdSurfsProperty = state.dataSurface->SurroundingSurfsProperty(surface.SurfSurroundingSurfacesNum); for (int SrdSurfNum = 1; SrdSurfNum <= SrdSurfsProperty.TotSurroundingSurface; SrdSurfNum++) { - SrdSurfaceTemp = - ScheduleManager::GetCurrentScheduleValue(state, SrdSurfsProperty.SurroundingSurfs(SrdSurfNum).TempSchNum) + Constant::Kelvin; + SrdSurfaceTemp = SrdSurfsProperty.SurroundingSurfs(SrdSurfNum).tempSched->getCurrentVal() + Constant::Kelvin; SrdSurfaceTempSum += SrdSurfsProperty.SurroundingSurfs(SrdSurfNum).ViewFactor * pow_4(SrdSurfaceTemp); } surface.SrdSurfTemp = root_4(SrdSurfaceTempSum / surface.ViewFactorSrdSurfs) - Constant::Kelvin; diff --git a/src/EnergyPlus/HeatBalanceSurfaceManager.hh b/src/EnergyPlus/HeatBalanceSurfaceManager.hh index caaef860db2..06b0c68cc1d 100644 --- a/src/EnergyPlus/HeatBalanceSurfaceManager.hh +++ b/src/EnergyPlus/HeatBalanceSurfaceManager.hh @@ -267,6 +267,10 @@ struct HeatBalSurfMgr : BaseGlobalStruct Array1D AbsDiffWinSky = Array1D(DataWindowEquivalentLayer::CFSMAXNL); // Sky diffuse solar absorptance of glass layers //Tuned Made static + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/HeatPumpWaterToWaterCOOLING.hh b/src/EnergyPlus/HeatPumpWaterToWaterCOOLING.hh index 257dff06e0a..55a2cddd636 100644 --- a/src/EnergyPlus/HeatPumpWaterToWaterCOOLING.hh +++ b/src/EnergyPlus/HeatPumpWaterToWaterCOOLING.hh @@ -174,6 +174,10 @@ struct HeatPumpWaterToWaterCOOLINGData : BaseGlobalStruct bool GetWWHPCoolingInput = true; Array1D GSHP; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/HeatPumpWaterToWaterHEATING.hh b/src/EnergyPlus/HeatPumpWaterToWaterHEATING.hh index d431aa8535b..d2c16df3c1b 100644 --- a/src/EnergyPlus/HeatPumpWaterToWaterHEATING.hh +++ b/src/EnergyPlus/HeatPumpWaterToWaterHEATING.hh @@ -171,6 +171,10 @@ struct HeatPumpWaterToWaterHEATINGData : BaseGlobalStruct bool GetWWHPHeatingInput = true; Array1D GSHP; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/HeatPumpWaterToWaterSimple.hh b/src/EnergyPlus/HeatPumpWaterToWaterSimple.hh index 868eb95b4c1..803dc9c2abc 100644 --- a/src/EnergyPlus/HeatPumpWaterToWaterSimple.hh +++ b/src/EnergyPlus/HeatPumpWaterToWaterSimple.hh @@ -210,6 +210,10 @@ struct HeatPumpWaterToWaterSimpleData : BaseGlobalStruct Array1D GSHP; std::unordered_map HeatPumpWaterUniqueNames; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/HeatRecovery.cc b/src/EnergyPlus/HeatRecovery.cc index 687580fe2e5..9f7060f48ec 100644 --- a/src/EnergyPlus/HeatRecovery.cc +++ b/src/EnergyPlus/HeatRecovery.cc @@ -249,6 +249,7 @@ namespace HeatRecovery { int IOStatus; // Used in GetObjectItem bool ErrorsFound(false); // Set to true if errors in input, fatal at end of routine constexpr std::string_view RoutineName = "GetHeatRecoveryInput: "; // include trailing blank space + constexpr std::string_view routineName = "GetHeatRecoveryInput"; auto &cCurrentModuleObject = state.dataIPShortCut->cCurrentModuleObject; int NumAirToAirPlateExchs = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "HeatExchanger:AirToAir:FlatPlate"); @@ -283,6 +284,8 @@ namespace HeatRecovery { state.dataIPShortCut->lAlphaFieldBlanks, state.dataIPShortCut->cAlphaFieldNames, state.dataIPShortCut->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1)}; int const ExchNum = ExchIndex; auto &thisExchanger = state.dataHeatRecovery->ExchCond(ExchNum); thisExchanger.NumericFieldNames.allocate(NumNumbers); @@ -298,20 +301,10 @@ namespace HeatRecovery { thisExchanger.Name = state.dataIPShortCut->cAlphaArgs(1); thisExchanger.type = HVAC::HXType::AirToAir_FlatPlate; if (state.dataIPShortCut->lAlphaFieldBlanks(2)) { - thisExchanger.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - thisExchanger.SchedPtr = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(2)); - if (thisExchanger.SchedPtr == 0) { - ShowSevereError(state, - format("{}{}: invalid {} entered ={} for {}={}", - RoutineName, - cCurrentModuleObject, - state.dataIPShortCut->cAlphaFieldNames(2), - state.dataIPShortCut->cAlphaArgs(2), - state.dataIPShortCut->cAlphaFieldNames(1), - state.dataIPShortCut->cAlphaArgs(1))); - ErrorsFound = true; - } + thisExchanger.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((thisExchanger.availSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(2), state.dataIPShortCut->cAlphaArgs(2)); + ErrorsFound = true; } constexpr std::array(HXConfiguration::Num)> hxConfigurationNamesUC = { @@ -400,6 +393,8 @@ namespace HeatRecovery { state.dataIPShortCut->lAlphaFieldBlanks, state.dataIPShortCut->cAlphaFieldNames, state.dataIPShortCut->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1)}; int const ExchNum = ExchIndex + NumAirToAirPlateExchs; auto &thisExchanger = state.dataHeatRecovery->ExchCond(ExchNum); thisExchanger.NumericFieldNames.allocate(NumNumbers); @@ -415,20 +410,10 @@ namespace HeatRecovery { thisExchanger.Name = state.dataIPShortCut->cAlphaArgs(1); thisExchanger.type = HVAC::HXType::AirToAir_Generic; if (state.dataIPShortCut->lAlphaFieldBlanks(2)) { - thisExchanger.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - thisExchanger.SchedPtr = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(2)); - if (thisExchanger.SchedPtr == 0) { - ShowSevereError(state, - format("{}{}: invalid {} entered ={} for {}={}", - RoutineName, - cCurrentModuleObject, - state.dataIPShortCut->cAlphaFieldNames(2), - state.dataIPShortCut->cAlphaArgs(2), - state.dataIPShortCut->cAlphaFieldNames(1), - thisExchanger.Name)); - ErrorsFound = true; - } + thisExchanger.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((thisExchanger.availSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(2), state.dataIPShortCut->cAlphaArgs(2)); + ErrorsFound = true; } thisExchanger.NomSupAirVolFlow = state.dataIPShortCut->rNumericArgs(1); thisExchanger.HeatEffectSensible100 = state.dataIPShortCut->rNumericArgs(2); @@ -550,6 +535,9 @@ namespace HeatRecovery { state.dataIPShortCut->lAlphaFieldBlanks, state.dataIPShortCut->cAlphaFieldNames, state.dataIPShortCut->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1)}; + int const ExchNum = ExchIndex + NumAirToAirPlateExchs + NumAirToAirGenericExchs; auto &thisExchanger = state.dataHeatRecovery->ExchCond(ExchNum); thisExchanger.NumericFieldNames.allocate(NumNumbers); @@ -565,20 +553,10 @@ namespace HeatRecovery { thisExchanger.Name = state.dataIPShortCut->cAlphaArgs(1); thisExchanger.type = HVAC::HXType::Desiccant_Balanced; if (state.dataIPShortCut->lAlphaFieldBlanks(2)) { - thisExchanger.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - thisExchanger.SchedPtr = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(2)); - if (thisExchanger.SchedPtr == 0) { - ShowSevereError(state, - format("{}{}: invalid {} entered ={} for {}={}", - RoutineName, - cCurrentModuleObject, - state.dataIPShortCut->cAlphaFieldNames(2), - state.dataIPShortCut->cAlphaArgs(2), - state.dataIPShortCut->cAlphaFieldNames(1), - thisExchanger.Name)); - ErrorsFound = true; - } + thisExchanger.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((thisExchanger.availSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(2), state.dataIPShortCut->cAlphaArgs(2)); + ErrorsFound = true; } // desiccant HX's usually refer to process and regeneration air streams // In this module, Sup = Regeneration nodes and Sec = Process nodes @@ -1745,7 +1723,7 @@ namespace HeatRecovery { UnitSecMassFlow = min(this->NomSecAirMassFlow, this->SecInMassFlow); } - if (ScheduleManager::GetCurrentScheduleValue(state, this->SchedPtr) <= 0.0) UnitOn = false; + if (this->availSched->getCurrentVal() <= 0.0) UnitOn = false; if (this->SupInMassFlow <= HVAC::SmallMassFlow) UnitOn = false; if (this->SecInMassFlow <= HVAC::SmallMassFlow) UnitOn = false; if (!HXUnitOn) UnitOn = false; @@ -1972,7 +1950,7 @@ namespace HeatRecovery { this->SecBypassMassFlow = 0.0; } // Unit is scheduled OFF, so bypass heat exchange calcs - if (ScheduleManager::GetCurrentScheduleValue(state, this->SchedPtr) <= 0.0) UnitOn = false; + if (this->availSched->getCurrentVal() <= 0.0) UnitOn = false; //! Economizer is active, so bypass heat exchange calcs. This applies to both flat plate and rotary HX's if ((EconomizerActiveFlag || HighHumCtrlActiveFlag) && this->EconoLockOut) { UnitOn = false; @@ -2493,7 +2471,7 @@ namespace HeatRecovery { } // Unit is scheduled OFF, so bypass heat exchange calcs - if (ScheduleManager::GetCurrentScheduleValue(state, this->SchedPtr) <= 0.0) UnitOn = false; + if (this->availSched->getCurrentVal() <= 0.0) UnitOn = false; // Determine if unit is ON or OFF based on air mass flow through the supply and secondary airstreams and operation flag if (this->SupInMassFlow <= HVAC::SmallMassFlow) UnitOn = false; if (this->SecInMassFlow <= HVAC::SmallMassFlow) UnitOn = false; diff --git a/src/EnergyPlus/HeatRecovery.hh b/src/EnergyPlus/HeatRecovery.hh index 518ec873657..2f6b6e9cd1b 100644 --- a/src/EnergyPlus/HeatRecovery.hh +++ b/src/EnergyPlus/HeatRecovery.hh @@ -111,7 +111,7 @@ namespace HeatRecovery { std::string Name; // name of component HVAC::HXType type = HVAC::HXType::Invalid; std::string HeatExchPerfName; // Desiccant balanced heat exchanger performance data name - int SchedPtr = 0; // index of schedule + Sched::Schedule *availSched = nullptr; // schedule // availability ? HXConfiguration FlowArr = HXConfiguration::Invalid; // flow Arrangement: bool EconoLockOut = false; Real64 hARatio = 0.0; // ratio of supply side h*A to secondary side h*A @@ -502,6 +502,10 @@ struct HeatRecoveryData : BaseGlobalStruct Array1D ExchCond; Array1D BalDesDehumPerfData; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/HeatingCoils.cc b/src/EnergyPlus/HeatingCoils.cc index 7ed94619dc5..9d6a52ff40e 100644 --- a/src/EnergyPlus/HeatingCoils.cc +++ b/src/EnergyPlus/HeatingCoils.cc @@ -254,6 +254,7 @@ namespace HeatingCoils { // SUBROUTINE PARAMETER DEFINITIONS: static constexpr std::string_view RoutineName = "GetHeatingCoilInput: "; // include trailing blank space + static constexpr std::string_view routineName = "GetHeatingCoilInput"; // SUBROUTINE LOCAL VARIABLE DECLARATIONS: std::string CurrentModuleObject; // for ease in getting objects @@ -338,6 +339,7 @@ namespace HeatingCoils { cAlphaFields, cNumericFields); + ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)}; heatingCoilNumericFields.FieldNames.allocate(state.dataHeatingCoils->MaxNums); heatingCoilNumericFields.FieldNames = cNumericFields; @@ -346,22 +348,11 @@ namespace HeatingCoils { state, CurrentModuleObject, Alphas(1), state.dataHeatingCoils->InputErrorsFound, CurrentModuleObject + " Name"); heatingCoil.Name = Alphas(1); - heatingCoil.Schedule = Alphas(2); if (lAlphaBlanks(2)) { - heatingCoil.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - heatingCoil.SchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(2)); - if (heatingCoil.SchedPtr == 0) { - ShowSevereError(state, - format("{}{}: Invalid {} entered ={} for {}={}", - RoutineName, - CurrentModuleObject, - cAlphaFields(2), - Alphas(2), - cAlphaFields(1), - Alphas(1))); - state.dataHeatingCoils->InputErrorsFound = true; - } + heatingCoil.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((heatingCoil.availSched = Sched::GetSchedule(state, Alphas(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(2), Alphas(2)); + state.dataHeatingCoils->InputErrorsFound = true; } heatingCoil.HeatingCoilType = "Heating"; @@ -468,6 +459,7 @@ namespace HeatingCoils { cAlphaFields, cNumericFields); + ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)}; heatingCoilNumericFields.FieldNames.allocate(state.dataHeatingCoils->MaxNums); heatingCoilNumericFields.FieldNames = cNumericFields; @@ -475,22 +467,11 @@ namespace HeatingCoils { GlobalNames::VerifyUniqueCoilName( state, CurrentModuleObject, Alphas(1), state.dataHeatingCoils->InputErrorsFound, CurrentModuleObject + " Name"); heatingCoil.Name = Alphas(1); - heatingCoil.Schedule = Alphas(2); if (lAlphaBlanks(2)) { - heatingCoil.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - heatingCoil.SchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(2)); - if (heatingCoil.SchedPtr == 0) { - ShowSevereError(state, - format("{}{}: Invalid {} entered ={} for {}={}", - RoutineName, - CurrentModuleObject, - cAlphaFields(2), - Alphas(2), - cAlphaFields(1), - Alphas(1))); - state.dataHeatingCoils->InputErrorsFound = true; - } + heatingCoil.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((heatingCoil.availSched = Sched::GetSchedule(state, Alphas(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(2), Alphas(2)); + state.dataHeatingCoils->InputErrorsFound = true; } heatingCoil.HeatingCoilType = "Heating"; @@ -605,6 +586,7 @@ namespace HeatingCoils { cAlphaFields, cNumericFields); + ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)}; heatingCoilNumericFields.FieldNames.allocate(state.dataHeatingCoils->MaxNums); heatingCoilNumericFields.FieldNames = cNumericFields; @@ -612,22 +594,11 @@ namespace HeatingCoils { GlobalNames::VerifyUniqueCoilName( state, CurrentModuleObject, Alphas(1), state.dataHeatingCoils->InputErrorsFound, CurrentModuleObject + " Name"); heatingCoil.Name = Alphas(1); - heatingCoil.Schedule = Alphas(2); if (lAlphaBlanks(2)) { - heatingCoil.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - heatingCoil.SchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(2)); - if (heatingCoil.SchedPtr == 0) { - ShowSevereError(state, - format("{}{}: Invalid {} entered ={} for {}={}", - RoutineName, - CurrentModuleObject, - cAlphaFields(2), - Alphas(2), - cAlphaFields(1), - Alphas(1))); - state.dataHeatingCoils->InputErrorsFound = true; - } + heatingCoil.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((heatingCoil.availSched = Sched::GetSchedule(state, Alphas(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(2),Alphas(2)); + state.dataHeatingCoils->InputErrorsFound = true; } heatingCoil.HeatingCoilType = "Heating"; @@ -802,6 +773,8 @@ namespace HeatingCoils { cAlphaFields, cNumericFields); + ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)}; + heatingCoilNumericFields.FieldNames.allocate(state.dataHeatingCoils->MaxNums); heatingCoilNumericFields.FieldNames = cNumericFields; @@ -809,22 +782,12 @@ namespace HeatingCoils { GlobalNames::VerifyUniqueCoilName( state, CurrentModuleObject, Alphas(1), state.dataHeatingCoils->InputErrorsFound, CurrentModuleObject + " Name"); heatingCoil.Name = Alphas(1); - heatingCoil.Schedule = Alphas(2); + if (lAlphaBlanks(2)) { - heatingCoil.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - heatingCoil.SchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(2)); - if (heatingCoil.SchedPtr == 0) { - ShowSevereError(state, - format("{}{}: Invalid {} entered ={} for {}={}", - RoutineName, - CurrentModuleObject, - cAlphaFields(2), - Alphas(2), - cAlphaFields(1), - Alphas(1))); - state.dataHeatingCoils->InputErrorsFound = true; - } + heatingCoil.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((heatingCoil.availSched = Sched::GetSchedule(state, Alphas(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(2), Alphas(2)); + state.dataHeatingCoils->InputErrorsFound = true; } heatingCoil.HeatingCoilType = "Heating"; @@ -992,6 +955,7 @@ namespace HeatingCoils { cAlphaFields, cNumericFields); + ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)}; heatingCoilNumericFields.FieldNames.allocate(state.dataHeatingCoils->MaxNums); heatingCoilNumericFields.FieldNames = cNumericFields; @@ -999,32 +963,14 @@ namespace HeatingCoils { GlobalNames::VerifyUniqueCoilName( state, CurrentModuleObject, Alphas(1), state.dataHeatingCoils->InputErrorsFound, CurrentModuleObject + " Name"); heatingCoil.Name = Alphas(1); - heatingCoil.Schedule = Alphas(2); if (lAlphaBlanks(2)) { - heatingCoil.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - heatingCoil.SchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(2)); - if (heatingCoil.SchedPtr == 0) { - ShowSevereError(state, - format("{}{}: Invalid {} entered ={} for {}={}", - RoutineName, - CurrentModuleObject, - cAlphaFields(2), - Alphas(2), - cAlphaFields(1), - Alphas(1))); - state.dataHeatingCoils->InputErrorsFound = true; - } - } - - // check availability schedule for values between 0 and 1 - if (heatingCoil.SchedPtr > 0) { - if (!ScheduleManager::CheckScheduleValueMinMax(state, heatingCoil.SchedPtr, ">=", 0.0, "<=", 1.0)) { - ShowSevereError(state, format("{} = \"{}\"", CurrentModuleObject, heatingCoil.Name)); - ShowContinueError(state, format("Error found in {} = {}", cAlphaFields(2), Alphas(2))); - ShowContinueError(state, "Schedule values must be (>=0., <=1.)"); - state.dataHeatingCoils->InputErrorsFound = true; - } + heatingCoil.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((heatingCoil.availSched = Sched::GetSchedule(state, Alphas(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(2), Alphas(2)); + state.dataHeatingCoils->InputErrorsFound = true; + } else if (!heatingCoil.availSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) { + Sched::ShowSevereBadMinMax(state, eoh, cAlphaFields(2), Alphas(2), Clusive::In, 0.0, Clusive::In, 1.0); + state.dataHeatingCoils->InputErrorsFound = true; } heatingCoil.HeatingCoilType = "Heating"; @@ -1890,7 +1836,7 @@ namespace HeatingCoils { // Control output to meet load QCoilReq (QCoilReq is passed in if load controlled, otherwise QCoilReq=-999) if ((AirMassFlow > 0.0 && heatingCoil.NominalCapacity > 0.0) && - (ScheduleManager::GetCurrentScheduleValue(state, heatingCoil.SchedPtr) > 0.0) && (QCoilReq > 0.0)) { + (heatingCoil.availSched->getCurrentVal() > 0.0) && (QCoilReq > 0.0)) { // check to see if the Required heating capacity is greater than the user specified capacity. if (QCoilReq > heatingCoil.NominalCapacity) { @@ -1907,7 +1853,7 @@ namespace HeatingCoils { // Control coil output to meet a setpoint temperature. } else if ((AirMassFlow > 0.0 && heatingCoil.NominalCapacity > 0.0) && - (ScheduleManager::GetCurrentScheduleValue(state, heatingCoil.SchedPtr) > 0.0) && (QCoilReq == DataLoopNode::SensedLoadFlagValue) && + (heatingCoil.availSched->getCurrentVal() > 0.0) && (QCoilReq == DataLoopNode::SensedLoadFlagValue) && (std::abs(TempSetPoint - TempAirIn) > HVAC::TempControlTol)) { QCoilCap = CapacitanceAir * (TempSetPoint - TempAirIn); @@ -2038,7 +1984,7 @@ namespace HeatingCoils { Real64 OutdoorPressure = state.dataEnvrn->OutBaroPress; - if ((AirMassFlow > 0.0) && (ScheduleManager::GetCurrentScheduleValue(state, heatingCoil.SchedPtr) > 0.0) && + if ((AirMassFlow > 0.0) && (heatingCoil.availSched->getCurrentVal() > 0.0) && ((CycRatio > 0.0) || (SpeedRatio > 0.0))) { if (StageNum > 1) { @@ -2210,7 +2156,7 @@ namespace HeatingCoils { // Control output to meet load QCoilReq (QCoilReq is passed in if load controlled, otherwise QCoilReq=-999) if ((AirMassFlow > 0.0 && heatingCoil.NominalCapacity > 0.0) && - (ScheduleManager::GetCurrentScheduleValue(state, heatingCoil.SchedPtr) > 0.0) && (QCoilReq > 0.0)) { + (heatingCoil.availSched->getCurrentVal() > 0.0) && (QCoilReq > 0.0)) { // check to see if the Required heating capacity is greater than the user specified capacity. if (QCoilReq > heatingCoil.NominalCapacity) { @@ -2231,7 +2177,7 @@ namespace HeatingCoils { // Control coil output to meet a setpoint temperature. } else if ((AirMassFlow > 0.0 && heatingCoil.NominalCapacity > 0.0) && - (ScheduleManager::GetCurrentScheduleValue(state, heatingCoil.SchedPtr) > 0.0) && (QCoilReq == DataLoopNode::SensedLoadFlagValue) && + (heatingCoil.availSched->getCurrentVal() > 0.0) && (QCoilReq == DataLoopNode::SensedLoadFlagValue) && (std::abs(TempSetPoint - TempAirIn) > HVAC::TempControlTol)) { QCoilCap = CapacitanceAir * (TempSetPoint - TempAirIn); @@ -2419,7 +2365,7 @@ namespace HeatingCoils { Real64 InletAirHumRat = heatingCoil.InletAirHumRat; Real64 OutdoorPressure = state.dataEnvrn->OutBaroPress; - if ((AirMassFlow > 0.0) && (ScheduleManager::GetCurrentScheduleValue(state, heatingCoil.SchedPtr) > 0.0) && + if ((AirMassFlow > 0.0) && (heatingCoil.availSched->getCurrentVal() > 0.0) && ((CycRatio > 0.0) || (SpeedRatio > 0.0))) { if (StageNum > 1) { @@ -2714,7 +2660,7 @@ namespace HeatingCoils { } // Control output to meet load (QCoilReq) - if ((AirMassFlow > 0.0) && (ScheduleManager::GetCurrentScheduleValue(state, heatingCoil.SchedPtr) > 0.0) && (QCoilReq > 0.0)) { + if ((AirMassFlow > 0.0) && (heatingCoil.availSched->getCurrentVal() > 0.0) && (QCoilReq > 0.0)) { // check to see if the Required heating capacity is greater than the available heating capacity. if (QCoilReq > heatingCoil.NominalCapacity) { @@ -2736,7 +2682,7 @@ namespace HeatingCoils { // Control coil output to meet a setpoint temperature. } else if ((AirMassFlow > 0.0 && heatingCoil.NominalCapacity > 0.0) && - (ScheduleManager::GetCurrentScheduleValue(state, heatingCoil.SchedPtr) > 0.0) && (QCoilReq == DataLoopNode::SensedLoadFlagValue) && + (heatingCoil.availSched->getCurrentVal() > 0.0) && (QCoilReq == DataLoopNode::SensedLoadFlagValue) && (std::abs(TempSetPoint - TempAirIn) > HVAC::TempControlTol)) { QCoilCap = CapacitanceAir * (TempSetPoint - TempAirIn); @@ -2978,7 +2924,7 @@ namespace HeatingCoils { ShowFatalError(state, "Program terminates due to preceding conditions."); } CompIndex = CoilNum; - Value = ScheduleManager::GetCurrentScheduleValue(state, state.dataHeatingCoils->HeatingCoil(CoilNum).SchedPtr); // not scheduled? + Value = state.dataHeatingCoils->HeatingCoil(CoilNum).availSched->getCurrentVal(); // not scheduled? } else { int CoilNum = CompIndex; if (CoilNum > state.dataHeatingCoils->NumHeatingCoils || CoilNum < 1) { @@ -3000,7 +2946,7 @@ namespace HeatingCoils { HVAC::cAllCoilTypes(state.dataHeatingCoils->HeatingCoil(CoilNum).HCoilType_Num))); ShowFatalError(state, "Program terminates due to preceding conditions."); } - Value = ScheduleManager::GetCurrentScheduleValue(state, state.dataHeatingCoils->HeatingCoil(CoilNum).SchedPtr); // not scheduled? + Value = state.dataHeatingCoils->HeatingCoil(CoilNum).availSched->getCurrentVal(); // not scheduled? } } @@ -3068,10 +3014,10 @@ namespace HeatingCoils { return CoilCapacity; } - int GetCoilAvailScheduleIndex(EnergyPlusData &state, - std::string const &CoilType, // must match coil types in this module - std::string const &CoilName, // must match coil names for the coil type - bool &ErrorsFound // set to true if problem + Sched::Schedule *GetCoilAvailSched(EnergyPlusData &state, + std::string const &CoilType, // must match coil types in this module + std::string const &CoilName, // must match coil names for the coil type + bool &ErrorsFound // set to true if problem ) { @@ -3091,14 +3037,13 @@ namespace HeatingCoils { } int WhichCoil = 0; - int AvailSchIndex = 0; int FoundType = Util::FindItem(CoilType, HVAC::cAllCoilTypes, HVAC::NumAllCoilTypes); if (FoundType == HVAC::Coil_HeatingElectric || FoundType == HVAC::Coil_HeatingElectric_MultiStage || FoundType == HVAC::Coil_HeatingGasOrOtherFuel || FoundType == HVAC::Coil_HeatingGas_MultiStage || FoundType == HVAC::Coil_HeatingDesuperheater) { WhichCoil = Util::FindItem(CoilName, state.dataHeatingCoils->HeatingCoil); if (WhichCoil != 0) { - AvailSchIndex = state.dataHeatingCoils->HeatingCoil(WhichCoil).SchedPtr; + return state.dataHeatingCoils->HeatingCoil(WhichCoil).availSched; } } else { WhichCoil = 0; @@ -3107,10 +3052,9 @@ namespace HeatingCoils { if (WhichCoil == 0) { ShowSevereError(state, format("GetCoilAvailScheduleIndex: Could not find Coil, Type=\"{}\" Name=\"{}\"", CoilType, CoilName)); ErrorsFound = true; - AvailSchIndex = 0; } - return AvailSchIndex; + return nullptr; } int GetCoilInletNode(EnergyPlusData &state, diff --git a/src/EnergyPlus/HeatingCoils.hh b/src/EnergyPlus/HeatingCoils.hh index aa17c58dbe5..0af08ab65cc 100644 --- a/src/EnergyPlus/HeatingCoils.hh +++ b/src/EnergyPlus/HeatingCoils.hh @@ -88,8 +88,7 @@ namespace HeatingCoils { std::string HeatingCoilModel; // Type of HeatingCoil ie. Simple, Detailed, etc. int HCoilType_Num = 0; Constant::eFuel FuelType = Constant::eFuel::Invalid; // Type of fuel used, reference resource type integers - std::string Schedule; // HeatingCoil Operation Schedule - int SchedPtr = 0; // Pointer to the correct schedule + Sched::Schedule *availSched = nullptr; // availability schedule int InsuffTemperatureWarn = 0; // Used for recurring error message Real64 InletAirMassFlowRate = 0.0; // MassFlow through the HeatingCoil being Simulated [kg/Sec] Real64 OutletAirMassFlowRate = 0.0; @@ -221,10 +220,10 @@ namespace HeatingCoils { bool &ErrorsFound // set to true if problem ); - int GetCoilAvailScheduleIndex(EnergyPlusData &state, - std::string const &CoilType, // must match coil types in this module - std::string const &CoilName, // must match coil names for the coil type - bool &ErrorsFound // set to true if problem + Sched::Schedule *GetCoilAvailSched(EnergyPlusData &state, + std::string const &CoilType, // must match coil types in this module + std::string const &CoilName, // must match coil names for the coil type + bool &ErrorsFound // set to true if problem ); int GetCoilInletNode(EnergyPlusData &state, @@ -316,6 +315,10 @@ struct HeatingCoilsData : BaseGlobalStruct Array1D_bool ShowSingleWarning; // Used for single warning message for desuperheater coil Array1D_bool MyEnvrnFlag; // one time environment flag + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/HighTempRadiantSystem.cc b/src/EnergyPlus/HighTempRadiantSystem.cc index 245b5ea1acd..bd50d60185e 100644 --- a/src/EnergyPlus/HighTempRadiantSystem.cc +++ b/src/EnergyPlus/HighTempRadiantSystem.cc @@ -206,6 +206,7 @@ namespace HighTempRadiantSystem { // METHODOLOGY EMPLOYED: // Standard EnergyPlus methodology. + static constexpr std::string_view routineName = "GetHighTempRadiantSystem"; // SUBROUTINE PARAMETER DEFINITIONS: Real64 constexpr MaxCombustionEffic = 1.0; // Limit the combustion efficiency to perfection @@ -253,27 +254,19 @@ namespace HighTempRadiantSystem { state.dataIPShortCut->cAlphaFieldNames, state.dataIPShortCut->cNumericFieldNames); + ErrorObjectHeader eoh{routineName, cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1)}; + state.dataHighTempRadSys->HighTempRadSysNumericFields(Item).FieldNames.allocate(NumNumbers); state.dataHighTempRadSys->HighTempRadSysNumericFields(Item).FieldNames = ""; state.dataHighTempRadSys->HighTempRadSysNumericFields(Item).FieldNames = state.dataIPShortCut->cNumericFieldNames; // General user input data highTempRadSys.Name = state.dataIPShortCut->cAlphaArgs(1); - highTempRadSys.SchedName = state.dataIPShortCut->cAlphaArgs(2); if (state.dataIPShortCut->lAlphaFieldBlanks(2)) { - highTempRadSys.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - highTempRadSys.SchedPtr = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(2)); - if (highTempRadSys.SchedPtr == 0) { - ShowSevereError(state, - format("{}: invalid {} entered ={} for {} = {}", - cCurrentModuleObject, - state.dataIPShortCut->cAlphaFieldNames(2), - state.dataIPShortCut->cAlphaArgs(2), - state.dataIPShortCut->cAlphaFieldNames(1), - state.dataIPShortCut->cAlphaArgs(1))); - ErrorsFound = true; - } + highTempRadSys.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((highTempRadSys.availSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(2), state.dataIPShortCut->cAlphaArgs(2)); + ErrorsFound = true; } highTempRadSys.ZonePtr = Util::FindItemInList(state.dataIPShortCut->cAlphaArgs(3), state.dataHeatBal->Zone); @@ -457,11 +450,9 @@ namespace HighTempRadiantSystem { ShowContinueError(state, "Thus, the throttling range value has been reset to 1.0"); } - highTempRadSys.SetptSched = state.dataIPShortCut->cAlphaArgs(7); - highTempRadSys.SetptSchedPtr = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(7)); - if ((highTempRadSys.SetptSchedPtr == 0) && (!state.dataIPShortCut->lAlphaFieldBlanks(7))) { - ShowSevereError(state, format("{} not found: {}", state.dataIPShortCut->cAlphaFieldNames(7), state.dataIPShortCut->cAlphaArgs(7))); - ShowContinueError(state, format("Occurs for {} = {}", cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); + if (state.dataIPShortCut->lAlphaFieldBlanks(7)) { + } else if ((highTempRadSys.setptSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(7))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(7), state.dataIPShortCut->cAlphaArgs(7)); ErrorsFound = true; } @@ -799,7 +790,7 @@ namespace HighTempRadiantSystem { int ZoneNum = thisHTR.ZonePtr; Real64 HeatFrac = 0.0; // fraction of maximum energy input to radiant system [dimensionless] - if (ScheduleManager::GetCurrentScheduleValue(state, thisHTR.SchedPtr) <= 0) { + if (thisHTR.availSched->getCurrentVal() <= 0) { // Unit is off or has no load upon it; set the flow rates to zero and then // simulate the components with the no flow conditions @@ -809,7 +800,7 @@ namespace HighTempRadiantSystem { // high temperature radiant heater (temperature controlled) // Determine the current setpoint temperature and the temperature at which the unit should be completely off - Real64 SetPtTemp = ScheduleManager::GetCurrentScheduleValue(state, thisHTR.SetptSchedPtr); + Real64 SetPtTemp = thisHTR.setptSched->getCurrentVal(); Real64 OffTemp = SetPtTemp + 0.5 * thisHTR.ThrottlRange; auto const &thisZoneHB = state.dataZoneTempPredictorCorrector->zoneHeatBalance(ZoneNum); Real64 OpTemp = (thisZoneHB.MAT + thisZoneHB.MRT) / 2.0; // Approximate the "operative" temperature @@ -886,13 +877,13 @@ namespace HighTempRadiantSystem { int ZoneNum = thisHTR.ZonePtr; thisHTR.QHTRRadSource = 0.0; - if (ScheduleManager::GetCurrentScheduleValue(state, thisHTR.SchedPtr) > 0) { + if (thisHTR.availSched->getCurrentVal() > 0) { // Unit is scheduled on-->this section is intended to control the output of the // high temperature radiant heater (temperature controlled) // Determine the current setpoint temperature and the temperature at which the unit should be completely off - Real64 SetPtTemp = ScheduleManager::GetCurrentScheduleValue(state, thisHTR.SetptSchedPtr); + Real64 SetPtTemp = thisHTR.setptSched->getCurrentVal(); // Now, distribute the radiant energy of all systems to the appropriate // surfaces, to people, and the air; determine the latent portion diff --git a/src/EnergyPlus/HighTempRadiantSystem.hh b/src/EnergyPlus/HighTempRadiantSystem.hh index 9d2e4ab6c40..81da21951c3 100644 --- a/src/EnergyPlus/HighTempRadiantSystem.hh +++ b/src/EnergyPlus/HighTempRadiantSystem.hh @@ -83,8 +83,7 @@ namespace HighTempRadiantSystem { // Members // Input data std::string Name; // name of hydronic radiant system - std::string SchedName; // availability schedule - int SchedPtr; // index to schedule + Sched::Schedule *availSched = nullptr; // availability schedule int ZonePtr; // Point to this zone in the Zone derived type Constant::eResource HeaterType; // Type of heater (NaturalGas or Electricity) Real64 MaxPowerCapac; // Maximum capacity of the radiant heater in Watts @@ -96,8 +95,7 @@ namespace HighTempRadiantSystem { // (by definition this is 1 minus the sum of all other fractions) RadControlType ControlType; // Control type for the system (MAT, MRT, or op temp) Real64 ThrottlRange; // Throttling range for heating [C] - std::string SetptSched; // Schedule name for the zone setpoint temperature - int SetptSchedPtr; // Schedule index for the zone setpoint temperature + Sched::Schedule *setptSched = nullptr; // Schedule for the zone setpoint temperature Real64 FracDistribPerson; // Fraction of fraction radiant incident on a "person" in the space int TotSurfToDistrib; // Total number of surfaces the heater sends radiation to Array1D_string SurfaceName; // Surface name in the list of surfaces heater sends radiation to @@ -126,8 +124,8 @@ namespace HighTempRadiantSystem { // Default Constructor HighTempRadiantSystemData() - : SchedPtr(0), ZonePtr(0), HeaterType(Constant::eResource::Invalid), MaxPowerCapac(0.0), CombustionEffic(0.0), FracRadiant(0.0), - FracLatent(0.0), FracLost(0.0), FracConvect(0.0), ControlType(RadControlType::Invalid), ThrottlRange(0.0), SetptSchedPtr(0), + : ZonePtr(0), HeaterType(Constant::eResource::Invalid), MaxPowerCapac(0.0), CombustionEffic(0.0), FracRadiant(0.0), + FracLatent(0.0), FracLost(0.0), FracConvect(0.0), ControlType(RadControlType::Invalid), ThrottlRange(0.0), FracDistribPerson(0.0), TotSurfToDistrib(0), ZeroHTRSourceSumHATsurf(0.0), QHTRRadSource(0.0), QHTRRadSrcAvg(0.0), LastSysTimeElapsed(0.0), LastTimeStepSys(0.0), LastQHTRRadSrc(0.0), ElecPower(0.0), ElecEnergy(0.0), GasPower(0.0), GasEnergy(0.0), HeatPower(0.0), HeatEnergy(0.0), HeatingCapMethod(DataSizing::DesignSizingType::Invalid), ScaledHeatingCapacity(0.0) @@ -201,6 +199,10 @@ struct HighTempRadiantSystemData : BaseGlobalStruct bool MyEnvrnFlag = true; bool ZoneEquipmentListChecked = false; // True after the Zone Equipment List has been checked for items + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/Humidifiers.cc b/src/EnergyPlus/Humidifiers.cc index e59b1dd8ec6..9465250f46f 100644 --- a/src/EnergyPlus/Humidifiers.cc +++ b/src/EnergyPlus/Humidifiers.cc @@ -103,7 +103,6 @@ namespace Humidifiers { // Using/Aliasing using namespace DataLoopNode; using HVAC::SmallMassFlow; - using namespace ScheduleManager; void SimHumidifier(EnergyPlusData &state, std::string_view CompName, // name of the humidifier unit @@ -215,6 +214,7 @@ namespace Humidifiers { // SUBROUTINE PARAMETER DEFINITIONS: static constexpr std::string_view RoutineName("GetHumidifierInputs: "); // include trailing blank space + static constexpr std::string_view routineName = "GetHumidifierInputs"; // include trailing blank space // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int HumidifierIndex; // loop index @@ -276,28 +276,20 @@ namespace Humidifiers { lAlphaBlanks, cAlphaFields, cNumericFields); + + ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)}; HumNum = HumidifierIndex; auto &Humidifier = state.dataHumidifiers->Humidifier(HumNum); GlobalNames::VerifyUniqueInterObjectName( state, state.dataHumidifiers->HumidifierUniqueNames, Alphas(1), CurrentModuleObject, cAlphaFields(1), ErrorsFound); Humidifier.Name = Alphas(1); Humidifier.HumType = HumidType::Electric; - Humidifier.Sched = Alphas(2); + if (lAlphaBlanks(2)) { - Humidifier.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - Humidifier.SchedPtr = GetScheduleIndex(state, Alphas(2)); // convert schedule name to pointer - if (Humidifier.SchedPtr == 0) { - ShowSevereError(state, - format("{}{}: invalid {} entered ={} for {}={}", - RoutineName, - CurrentModuleObject, - cAlphaFields(2), - Alphas(2), - cAlphaFields(1), - Alphas(1))); - ErrorsFound = true; - } + Humidifier.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((Humidifier.availSched = Sched::GetSchedule(state, Alphas(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(2), Alphas(2)); + ErrorsFound = true; } Humidifier.NomCapVol = Numbers(1); Humidifier.NomPower = Numbers(2); @@ -348,28 +340,21 @@ namespace Humidifiers { lAlphaBlanks, cAlphaFields, cNumericFields); + + ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)}; + HumNum = NumElecSteamHums + HumidifierIndex; auto &Humidifier = state.dataHumidifiers->Humidifier(HumNum); GlobalNames::VerifyUniqueInterObjectName( state, state.dataHumidifiers->HumidifierUniqueNames, Alphas(1), CurrentModuleObject, cAlphaFields(1), ErrorsFound); Humidifier.Name = Alphas(1); Humidifier.HumType = HumidType::Gas; - Humidifier.Sched = Alphas(2); + if (lAlphaBlanks(2)) { - Humidifier.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - Humidifier.SchedPtr = GetScheduleIndex(state, Alphas(2)); // convert schedule name to pointer - if (Humidifier.SchedPtr == 0) { - ShowSevereError(state, - format("{}{}: invalid {} entered ={} for {}={}", - RoutineName, - CurrentModuleObject, - cAlphaFields(2), - Alphas(2), - cAlphaFields(1), - Alphas(1))); - ErrorsFound = true; - } + Humidifier.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((Humidifier.availSched = Sched::GetSchedule(state, Alphas(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(2), Alphas(2)); + ErrorsFound = true; } Humidifier.NomCapVol = Numbers(1); Humidifier.NomPower = Numbers(2); // nominal gas use rate for gas fired steam humidifier @@ -1004,7 +989,7 @@ namespace Humidifiers { UnitOn = true; if (HumRatSet <= 0.0) UnitOn = false; if (AirInMassFlowRate <= SmallMassFlow) UnitOn = false; - if (GetCurrentScheduleValue(state, SchedPtr) <= 0.0) UnitOn = false; + if (availSched->getCurrentVal() <= 0.0) UnitOn = false; if (AirInHumRat >= HumRatSet) UnitOn = false; HumRatSatIn = PsyWFnTdbRhPb(state, AirInTemp, 1.0, state.dataEnvrn->OutBaroPress, RoutineName); if (AirInHumRat >= HumRatSatIn) UnitOn = false; @@ -1117,7 +1102,7 @@ namespace Humidifiers { } if (WaterAdd > 0.0) { ElecUseRate = (WaterAdd / NomCap) * NomPower + FanPower + StandbyPower; - } else if (GetCurrentScheduleValue(state, SchedPtr) > 0.0) { + } else if (availSched->getCurrentVal() > 0.0) { ElecUseRate = StandbyPower; } else { ElecUseRate = 0.0; @@ -1254,7 +1239,7 @@ namespace Humidifiers { } AuxElecUseRate = FanPower + StandbyPower; - } else if (GetCurrentScheduleValue(state, SchedPtr) > 0.0) { + } else if (availSched->getCurrentVal() > 0.0) { AuxElecUseRate = StandbyPower; } else { AuxElecUseRate = 0.0; diff --git a/src/EnergyPlus/Humidifiers.hh b/src/EnergyPlus/Humidifiers.hh index 91989b2fabb..bb2228c24c8 100644 --- a/src/EnergyPlus/Humidifiers.hh +++ b/src/EnergyPlus/Humidifiers.hh @@ -93,8 +93,7 @@ namespace Humidifiers { std::string Name; // unique name of component HumidType HumType; // Pointer to Humidifier in list of humidifiers int EquipIndex; // Pointer to Humidifier in list of humidifiers - std::string Sched; // name of availability schedule - int SchedPtr; // index of availability schedule + Sched::Schedule *availSched = nullptr; // availability schedule Real64 NomCapVol; // nominal capacity [m3/s of water] Real64 NomCap; // nominal capacity [kg/s of water] Real64 NomPower; // power consumption at full output [watts] @@ -140,7 +139,7 @@ namespace Humidifiers { // Default Constructor HumidifierData() - : HumType(HumidType::Invalid), EquipIndex(0), SchedPtr(0), NomCapVol(0.0), NomCap(0.0), NomPower(0.0), ThermalEffRated(1.0), + : HumType(HumidType::Invalid), EquipIndex(0), NomCapVol(0.0), NomCap(0.0), NomPower(0.0), ThermalEffRated(1.0), CurMakeupWaterTemp(0.0), EfficiencyCurvePtr(0), InletWaterTempOption(InletWaterTemp::Invalid), FanPower(0.0), StandbyPower(0.0), AirInNode(0), AirOutNode(0), AirInTemp(0.0), AirInHumRat(0.0), AirInEnthalpy(0.0), AirInMassFlowRate(0.0), AirOutTemp(0.0), AirOutHumRat(0.0), AirOutEnthalpy(0.0), AirOutMassFlowRate(0.0), HumRatSet(0.0), WaterAdd(0.0), ElecUseEnergy(0.0), ElecUseRate(0.0), @@ -197,6 +196,10 @@ struct HumidifiersData : BaseGlobalStruct Array1D Humidifier; std::unordered_map HumidifierUniqueNames; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/HybridEvapCoolingModel.cc b/src/EnergyPlus/HybridEvapCoolingModel.cc index 43fc5c8108d..c8b101e9809 100644 --- a/src/EnergyPlus/HybridEvapCoolingModel.cc +++ b/src/EnergyPlus/HybridEvapCoolingModel.cc @@ -90,8 +90,8 @@ namespace HybridEvapCoolingModel { using Curve::CurveValue; using Curve::GetCurveIndex; using Curve::GetCurveMinMaxValues; - using ScheduleManager::GetCurrentScheduleValue; +// Ummm these will have to go #define DEF_Tdb 0 #define DEF_RH 1 @@ -713,7 +713,7 @@ namespace HybridEvapCoolingModel { } } - bool Model::MeetsSupplyAirTOC(EnergyPlusData &state, Real64 Tsupplyair) + bool Model::MeetsSupplyAirTOC([[maybe_unused]] EnergyPlusData &state, Real64 Tsupplyair) { // SUBROUTINE INFORMATION: // AUTHOR Spencer Maxwell Dutton @@ -734,17 +734,17 @@ namespace HybridEvapCoolingModel { // Using/Aliasing Real64 MinSAT = 10; Real64 MaxSAT = 20; - if (TsaMin_schedule_pointer > 0) { - MinSAT = GetCurrentScheduleValue(state, TsaMin_schedule_pointer); + if (TsaMinSched != nullptr) { + MinSAT = TsaMinSched->getCurrentVal(); } - if (TsaMax_schedule_pointer > 0) { - MaxSAT = GetCurrentScheduleValue(state, TsaMax_schedule_pointer); + if (TsaMaxSched != nullptr) { + MaxSAT = TsaMaxSched->getCurrentVal(); } if (Tsupplyair < MinSAT || Tsupplyair > MaxSAT) return false; return true; } - bool Model::MeetsSupplyAirRHOC(EnergyPlusData &state, Real64 SupplyW) + bool Model::MeetsSupplyAirRHOC([[maybe_unused]] EnergyPlusData &state, Real64 SupplyW) { // SUBROUTINE INFORMATION: // AUTHOR Spencer Maxwell Dutton @@ -765,18 +765,18 @@ namespace HybridEvapCoolingModel { // Using/Aliasing Real64 MinRH = 0; Real64 MaxRH = 1; - if (RHsaMin_schedule_pointer > 0) { - MinRH = GetCurrentScheduleValue(state, RHsaMin_schedule_pointer); + if (RHsaMinSched != nullptr) { + MinRH = RHsaMinSched->getCurrentVal(); } - if (RHsaMax_schedule_pointer > 0) { - MaxRH = GetCurrentScheduleValue(state, RHsaMax_schedule_pointer); + if (RHsaMaxSched != nullptr) { + MaxRH = RHsaMaxSched->getCurrentVal(); } if (SupplyW < MinRH || SupplyW > MaxRH) return false; return true; } Model::Model() - : Initialized(false), ZoneNum(0), SchedPtr(0), SystemMaximumSupplyAirFlowRate(0.0), ScalingFactor(0.0), + : Initialized(false), ZoneNum(0), SystemMaximumSupplyAirFlowRate(0.0), ScalingFactor(0.0), ScaledSystemMaximumSupplyAirMassFlowRate(0.0), UnitOn(0), UnitTotalCoolingRate(0.0), UnitTotalCoolingEnergy(0.0), UnitSensibleCoolingRate(0.0), UnitSensibleCoolingEnergy(0.0), UnitLatentCoolingRate(0.0), UnitLatentCoolingEnergy(0.0), SystemTotalCoolingRate(0.0), SystemTotalCoolingEnergy(0.0), SystemSensibleCoolingRate(0.0), SystemSensibleCoolingEnergy(0.0), @@ -788,8 +788,8 @@ namespace HybridEvapCoolingModel { WaterConsumptionRate(0.0), WaterConsumption(0.0), QSensZoneOut(0), QLatentZoneOut(0), QLatentZoneOutMass(0), ExternalStaticPressure(0.0), RequestedHumdificationMass(0.0), RequestedHumdificationLoad(0.0), RequestedHumdificationEnergy(0.0), RequestedDeHumdificationMass(0.0), RequestedDeHumdificationLoad(0.0), RequestedDeHumdificationEnergy(0.0), RequestedLoadToHeatingSetpoint(0.0), - RequestedLoadToCoolingSetpoint(0.0), TsaMin_schedule_pointer(0), TsaMax_schedule_pointer(0), RHsaMin_schedule_pointer(0), - RHsaMax_schedule_pointer(0), PrimaryMode(0), PrimaryModeRuntimeFraction(0.0), averageOSAF(0), ErrorCode(0), InletNode(0), OutletNode(0), + RequestedLoadToCoolingSetpoint(0.0), + PrimaryMode(0), PrimaryModeRuntimeFraction(0.0), averageOSAF(0), ErrorCode(0), InletNode(0), OutletNode(0), SecondaryInletNode(0), SecondaryOutletNode(0), FinalElectricalPower(0.0), FinalElectricalEnergy(0.0), InletMassFlowRate(0.0), InletTemp(0.0), InletWetBulbTemp(0.0), InletHumRat(0.0), InletEnthalpy(0.0), InletPressure(0.0), InletRH(0.0), OutletVolumetricFlowRate(0.0), OutletMassFlowRate(0.0), PowerLossToAir(0.0), FanHeatTemp(0.0), OutletTemp(0.0), OutletWetBulbTemp(0.0), @@ -1843,7 +1843,7 @@ namespace HybridEvapCoolingModel { UnitOn = 1; bool ForceOff = false; StandBy = false; - if (GetCurrentScheduleValue(state, SchedPtr) <= 0 || availStatus == Avail::Status::ForceOff) { + if (availSched->getCurrentVal() <= 0 || availStatus == Avail::Status::ForceOff) { UnitOn = 0; ForceOff = true; } diff --git a/src/EnergyPlus/HybridEvapCoolingModel.hh b/src/EnergyPlus/HybridEvapCoolingModel.hh index c4309a2eea7..31c81b1c082 100644 --- a/src/EnergyPlus/HybridEvapCoolingModel.hh +++ b/src/EnergyPlus/HybridEvapCoolingModel.hh @@ -231,11 +231,10 @@ namespace HybridEvapCoolingModel { // Default Constructor std::string Name; // user identifier - std::string Schedule; // Availability Schedule Name bool Initialized; // initialization flag ensures the system object is initialized only once. int ZoneNum; // stores the current zone associated with the system, this is currently not used but is expected to be used in the next set of // functionality additions. - int SchedPtr; // Pointer to the correct schedule + Sched::Schedule *availSched = nullptr; // Pointer to the correct schedule int ZoneNodeNum; // index of zone air node in node structure std::string AvailManagerListName; // Name of an availability manager list object Avail::Status availStatus = Avail::Status::NoAction; @@ -296,10 +295,10 @@ namespace HybridEvapCoolingModel { Real64 RequestedDeHumdificationEnergy; Real64 RequestedLoadToHeatingSetpoint; Real64 RequestedLoadToCoolingSetpoint; - int TsaMin_schedule_pointer; - int TsaMax_schedule_pointer; - int RHsaMin_schedule_pointer; - int RHsaMax_schedule_pointer; + Sched::Schedule *TsaMinSched = nullptr; + Sched::Schedule *TsaMaxSched = nullptr; + Sched::Schedule *RHsaMinSched = nullptr; + Sched::Schedule *RHsaMaxSched = nullptr; int PrimaryMode; Real64 PrimaryModeRuntimeFraction; Real64 averageOSAF; diff --git a/src/EnergyPlus/HybridModel.cc b/src/EnergyPlus/HybridModel.cc index 48e06543b2a..d01ffc7e360 100644 --- a/src/EnergyPlus/HybridModel.cc +++ b/src/EnergyPlus/HybridModel.cc @@ -83,9 +83,6 @@ namespace HybridModel { void GetHybridModelZone(EnergyPlusData &state) { - - using ScheduleManager::GetScheduleIndex; - Array1D_bool lAlphaFieldBlanks(16, false); Array1D_bool lNumericFieldBlanks(4, false); std::string CurrentModuleObject; // to assist in getting input @@ -99,7 +96,7 @@ namespace HybridModel { state.dataHybridModel->NumOfHybridModelZones = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject); if (state.dataHybridModel->NumOfHybridModelZones > 0) { - state.dataHybridModel->HybridModelZone.allocate(state.dataGlobal->NumOfZones); + state.dataHybridModel->hybridModelZones.allocate(state.dataGlobal->NumOfZones); bool ErrorsFound = false; // If errors detected in input int NumAlphas = 0; // Number of Alphas for each GetobjectItem call int NumNumbers = 0; // Number of Numbers for each GetobjectItem call @@ -122,28 +119,29 @@ namespace HybridModel { ZonePtr = Util::FindItemInList(cAlphaArgs(2), state.dataHeatBal->Zone); // "Zone" is a 1D array, cAlphaArgs(2) is the zone name if (ZonePtr > 0) { - state.dataHybridModel->HybridModelZone(ZonePtr).Name = cAlphaArgs(1); // Zone HybridModel name + auto &hmZone = state.dataHybridModel->hybridModelZones(ZonePtr); + hmZone.Name = cAlphaArgs(1); // Zone HybridModel name state.dataHybridModel->FlagHybridModel_TM = Util::SameString(cAlphaArgs(3), "Yes"); // Calculate thermal mass option state.dataHybridModel->FlagHybridModel_AI = Util::SameString(cAlphaArgs(4), "Yes"); // Calculate infiltration rate option state.dataHybridModel->FlagHybridModel_PC = Util::SameString(cAlphaArgs(5), "Yes"); // Calculate people count option // Pointers used to help decide which unknown parameter to solve // Zone Air Infiltration Rate and Zone Internal Thermal Mass calculations cannot be performed simultaneously - int TemperatureSchPtr = GetScheduleIndex(state, cAlphaArgs(6)); - int HumidityRatioSchPtr = GetScheduleIndex(state, cAlphaArgs(7)); - int CO2ConcentrationSchPtr = GetScheduleIndex(state, cAlphaArgs(8)); + Sched::Schedule *temperatureSched = Sched::GetSchedule(state, cAlphaArgs(6)); + Sched::Schedule *humidityRatioSched = Sched::GetSchedule(state, cAlphaArgs(7)); + Sched::Schedule *CO2ConcentrationSched = Sched::GetSchedule(state, cAlphaArgs(8)); // Not used for now - int PeopleActivityLevelSchPtr = GetScheduleIndex(state, cAlphaArgs(9)); - int PeopleSensibleFractionSchPtr = GetScheduleIndex(state, cAlphaArgs(10)); - int PeopleRadiantFractionSchPtr = GetScheduleIndex(state, cAlphaArgs(11)); - int PeopleCO2GenRateSchPtr = GetScheduleIndex(state, cAlphaArgs(12)); + Sched::Schedule *peopleActivityLevelSched = Sched::GetSchedule(state, cAlphaArgs(9)); + Sched::Schedule *peopleSensibleFractionSched = Sched::GetSchedule(state, cAlphaArgs(10)); + Sched::Schedule *peopleRadiantFractionSched = Sched::GetSchedule(state, cAlphaArgs(11)); + Sched::Schedule *peopleCO2GenRateSched = Sched::GetSchedule(state, cAlphaArgs(12)); // Pointers used to help decide wheather to include system supply terms in the inverse algorithms - int SupplyAirTemperatureSchPtr = GetScheduleIndex(state, cAlphaArgs(13)); - int SupplyAirMassFlowRateSchPtr = GetScheduleIndex(state, cAlphaArgs(14)); - int SupplyAirHumidityRatioSchPtr = GetScheduleIndex(state, cAlphaArgs(15)); - int SupplyAirCO2ConcentrationSchPtr = GetScheduleIndex(state, cAlphaArgs(16)); + Sched::Schedule *supplyAirTemperatureSched = Sched::GetSchedule(state, cAlphaArgs(13)); + Sched::Schedule *supplyAirMassFlowRateSched = Sched::GetSchedule(state, cAlphaArgs(14)); + Sched::Schedule *supplyAirHumidityRatioSched = Sched::GetSchedule(state, cAlphaArgs(15)); + Sched::Schedule *supplyAirCO2ConcentrationSched = Sched::GetSchedule(state, cAlphaArgs(16)); // Note: Internal thermal mass can be calculated only with measured temperature. // Air infiltration rate can be calculated with either measured temperature, humifity ratio, or CO2 @@ -151,13 +149,13 @@ namespace HybridModel { // concentration. // Initially set all flags to be false - state.dataHybridModel->HybridModelZone(ZonePtr).InternalThermalMassCalc_T = false; - state.dataHybridModel->HybridModelZone(ZonePtr).InfiltrationCalc_T = false; - state.dataHybridModel->HybridModelZone(ZonePtr).InfiltrationCalc_H = false; - state.dataHybridModel->HybridModelZone(ZonePtr).InfiltrationCalc_C = false; - state.dataHybridModel->HybridModelZone(ZonePtr).PeopleCountCalc_T = false; - state.dataHybridModel->HybridModelZone(ZonePtr).PeopleCountCalc_H = false; - state.dataHybridModel->HybridModelZone(ZonePtr).PeopleCountCalc_C = false; + hmZone.InternalThermalMassCalc_T = false; + hmZone.InfiltrationCalc_T = false; + hmZone.InfiltrationCalc_H = false; + hmZone.InfiltrationCalc_C = false; + hmZone.PeopleCountCalc_T = false; + hmZone.PeopleCountCalc_H = false; + hmZone.PeopleCountCalc_C = false; // Scenario 1: Only one unknown parameter to solve // Scenario 1-1: To solve thermal mass @@ -174,11 +172,11 @@ namespace HybridModel { ErrorsFound = true; } - if (TemperatureSchPtr == 0) { + if (temperatureSched == nullptr) { ShowSevereError(state, format("Measured Zone Air Tempearture Schedule is not defined for: {}", CurrentModuleObject)); ErrorsFound = true; } else { - state.dataHybridModel->HybridModelZone(ZonePtr).InternalThermalMassCalc_T = true; + hmZone.InternalThermalMassCalc_T = true; } } @@ -189,7 +187,7 @@ namespace HybridModel { format("Field \"{}\" and \"{}\" cannot be both set to YES.", cAlphaFieldNames(4), cAlphaFieldNames(5))); ErrorsFound = true; } - if (TemperatureSchPtr == 0 && HumidityRatioSchPtr == 0 && CO2ConcentrationSchPtr == 0) { + if (temperatureSched == nullptr && humidityRatioSched == nullptr && CO2ConcentrationSched == nullptr) { // Show fatal error if no measurement schedule is provided ShowSevereError(state, format("No measured envrionmental parameter is provided for: {}", CurrentModuleObject)); ShowContinueError(state, @@ -199,36 +197,36 @@ namespace HybridModel { cAlphaFieldNames(8))); ErrorsFound = true; } else { - if (TemperatureSchPtr > 0 && !state.dataHybridModel->FlagHybridModel_TM) { + if (temperatureSched != nullptr && !state.dataHybridModel->FlagHybridModel_TM) { // Temperature schedule is provided, igonore humidity ratio and CO2 concentration schedules. - state.dataHybridModel->HybridModelZone(ZonePtr).InfiltrationCalc_T = true; - if (HumidityRatioSchPtr > 0) { + hmZone.InfiltrationCalc_T = true; + if (humidityRatioSched != nullptr) { ShowWarningError(state, format("Field \"{}\" is provided.", cAlphaFieldNames(6))); ShowContinueError(state, format("Field \"{}\" will not be used.", cAlphaFieldNames(7))); } - if (CO2ConcentrationSchPtr > 0) { + if (CO2ConcentrationSched != nullptr) { ShowWarningError(state, format("Field \"{}\" is provided.", cAlphaFieldNames(6))); ShowContinueError(state, format("Field \"{}\" will not be used.", cAlphaFieldNames(8))); } } - if (HumidityRatioSchPtr > 0 && TemperatureSchPtr == 0) { + if (humidityRatioSched != nullptr && temperatureSched == nullptr) { // Humidity ratio schedule is provided, ignore CO2 concentration schedule. - state.dataHybridModel->HybridModelZone(ZonePtr).InfiltrationCalc_H = true; - if (CO2ConcentrationSchPtr > 0) { + hmZone.InfiltrationCalc_H = true; + if (CO2ConcentrationSched != nullptr) { ShowWarningError(state, format("Field \"{}\" is provided.", cAlphaFieldNames(7))); ShowContinueError(state, format("Field \"{}\" will not be used.", cAlphaFieldNames(8))); } } - if (CO2ConcentrationSchPtr > 0 && TemperatureSchPtr == 0 && HumidityRatioSchPtr == 0) { + if (CO2ConcentrationSched != nullptr && temperatureSched == nullptr && humidityRatioSched == nullptr) { // Only CO2 concentration schedule is provided. - state.dataHybridModel->HybridModelZone(ZonePtr).InfiltrationCalc_C = true; + hmZone.InfiltrationCalc_C = true; } } } // Scenario 1-3: To solve people count if (state.dataHybridModel->FlagHybridModel_PC) { - if (TemperatureSchPtr == 0 && HumidityRatioSchPtr == 0 && CO2ConcentrationSchPtr == 0) { + if (temperatureSched == nullptr && humidityRatioSched == nullptr && CO2ConcentrationSched == nullptr) { // Show fatal error if no measurement schedule is provided ShowSevereError(state, format("No measured envrionmental parameter is provided for: {}", CurrentModuleObject)); ShowContinueError(state, @@ -238,41 +236,40 @@ namespace HybridModel { cAlphaFieldNames(8))); ErrorsFound = true; } else { - if (TemperatureSchPtr > 0 && !state.dataHybridModel->FlagHybridModel_TM) { + if (temperatureSched != nullptr && !state.dataHybridModel->FlagHybridModel_TM) { // Temperature schedule is provided, igonore humidity ratio and CO2 concentration schedules. - state.dataHybridModel->HybridModelZone(ZonePtr).PeopleCountCalc_T = true; - if (HumidityRatioSchPtr > 0) { + hmZone.PeopleCountCalc_T = true; + if (humidityRatioSched != nullptr) { ShowWarningError( state, "The meausured air humidity ratio schedule will not be used since measured air temperature is provided."); } - if (CO2ConcentrationSchPtr > 0) { + if (CO2ConcentrationSched != nullptr) { ShowWarningError( state, "The meausured air CO2 concentration schedule will not be used since measured air temperature is provided."); } } - if (HumidityRatioSchPtr > 0 && TemperatureSchPtr == 0) { + if (humidityRatioSched != nullptr && temperatureSched == nullptr) { // Humidity ratio schedule is provided, ignore CO2 concentration schedule. - state.dataHybridModel->HybridModelZone(ZonePtr).PeopleCountCalc_H = true; - if (CO2ConcentrationSchPtr > 0) { + hmZone.PeopleCountCalc_H = true; + if (CO2ConcentrationSched != nullptr) { ShowWarningError(state, "The meausured air CO2 concentration schedule will not be used since measured air humidity " "ratio is provided."); } } - if (CO2ConcentrationSchPtr > 0 && TemperatureSchPtr == 0 && HumidityRatioSchPtr == 0) { + if (CO2ConcentrationSched != nullptr && temperatureSched == nullptr && humidityRatioSched == nullptr) { // Only CO2 concentration schedule is provided. - state.dataHybridModel->HybridModelZone(ZonePtr).PeopleCountCalc_C = true; + hmZone.PeopleCountCalc_C = true; } } } // Decide if system supply terms are valid to be included in the inverse solution - if (SupplyAirTemperatureSchPtr > 0 && SupplyAirMassFlowRateSchPtr > 0 && SupplyAirHumidityRatioSchPtr) { - if (state.dataHybridModel->HybridModelZone(ZonePtr).InfiltrationCalc_T || - state.dataHybridModel->HybridModelZone(ZonePtr).PeopleCountCalc_T) { - state.dataHybridModel->HybridModelZone(ZonePtr).IncludeSystemSupplyParameters = true; + if (supplyAirTemperatureSched != nullptr && supplyAirMassFlowRateSched != nullptr && supplyAirHumidityRatioSched != nullptr) { + if (hmZone.InfiltrationCalc_T || hmZone.PeopleCountCalc_T) { + hmZone.IncludeSystemSupplyParameters = true; } else { ShowWarningError(state, format("Field \"{}\", {}, and \"{}\" will not be used in the inverse balance euqation.", @@ -282,10 +279,9 @@ namespace HybridModel { } } - if (SupplyAirHumidityRatioSchPtr && SupplyAirMassFlowRateSchPtr > 0) { - if (state.dataHybridModel->HybridModelZone(ZonePtr).InfiltrationCalc_H || - state.dataHybridModel->HybridModelZone(ZonePtr).PeopleCountCalc_H) { - state.dataHybridModel->HybridModelZone(ZonePtr).IncludeSystemSupplyParameters = true; + if (supplyAirHumidityRatioSched != nullptr && supplyAirMassFlowRateSched != nullptr) { + if (hmZone.InfiltrationCalc_H || hmZone.PeopleCountCalc_H) { + hmZone.IncludeSystemSupplyParameters = true; } else { ShowWarningError(state, format("Field \"{}\" and \"{}\" will not be used in the inverse balance euqation.", @@ -294,10 +290,9 @@ namespace HybridModel { } } - if (SupplyAirCO2ConcentrationSchPtr > 0 && SupplyAirMassFlowRateSchPtr > 0) { - if (state.dataHybridModel->HybridModelZone(ZonePtr).InfiltrationCalc_C || - state.dataHybridModel->HybridModelZone(ZonePtr).PeopleCountCalc_C) { - state.dataHybridModel->HybridModelZone(ZonePtr).IncludeSystemSupplyParameters = true; + if (supplyAirCO2ConcentrationSched != nullptr && supplyAirMassFlowRateSched != nullptr) { + if (hmZone.InfiltrationCalc_C || hmZone.PeopleCountCalc_C) { + hmZone.IncludeSystemSupplyParameters = true; } else { ShowWarningError(state, format("Field \"{}\" and \"{}\" will not be used in the inverse balance euqation.", @@ -307,74 +302,58 @@ namespace HybridModel { } // Flags showing Hybrid Modeling settings - state.dataHybridModel->FlagHybridModel = state.dataHybridModel->HybridModelZone(ZonePtr).InternalThermalMassCalc_T || - state.dataHybridModel->HybridModelZone(ZonePtr).InfiltrationCalc_T || - state.dataHybridModel->HybridModelZone(ZonePtr).InfiltrationCalc_H || - state.dataHybridModel->HybridModelZone(ZonePtr).InfiltrationCalc_C || - state.dataHybridModel->HybridModelZone(ZonePtr).PeopleCountCalc_T || - state.dataHybridModel->HybridModelZone(ZonePtr).PeopleCountCalc_H || - state.dataHybridModel->HybridModelZone(ZonePtr).PeopleCountCalc_C; - - if (state.dataHybridModel->HybridModelZone(ZonePtr).InternalThermalMassCalc_T || - state.dataHybridModel->HybridModelZone(ZonePtr).InfiltrationCalc_T || - state.dataHybridModel->HybridModelZone(ZonePtr).PeopleCountCalc_T) { - state.dataHybridModel->HybridModelZone(ZonePtr).ZoneMeasuredTemperatureSchedulePtr = GetScheduleIndex(state, cAlphaArgs(6)); + state.dataHybridModel->FlagHybridModel = hmZone.InternalThermalMassCalc_T || hmZone.InfiltrationCalc_T || + hmZone.InfiltrationCalc_H || hmZone.InfiltrationCalc_C || + hmZone.PeopleCountCalc_T || hmZone.PeopleCountCalc_H || + hmZone.PeopleCountCalc_C; + + if (hmZone.InternalThermalMassCalc_T || hmZone.InfiltrationCalc_T || hmZone.PeopleCountCalc_T) { + hmZone.measuredTempSched = temperatureSched; } - if (state.dataHybridModel->HybridModelZone(ZonePtr).InfiltrationCalc_H || - state.dataHybridModel->HybridModelZone(ZonePtr).PeopleCountCalc_H) { - state.dataHybridModel->HybridModelZone(ZonePtr).ZoneMeasuredHumidityRatioSchedulePtr = GetScheduleIndex(state, cAlphaArgs(7)); + if (hmZone.InfiltrationCalc_H || hmZone.PeopleCountCalc_H) { + hmZone.measuredHumRatSched = humidityRatioSched; } - if (state.dataHybridModel->HybridModelZone(ZonePtr).InfiltrationCalc_C || - state.dataHybridModel->HybridModelZone(ZonePtr).PeopleCountCalc_C) { - state.dataHybridModel->HybridModelZone(ZonePtr).ZoneMeasuredCO2ConcentrationSchedulePtr = - GetScheduleIndex(state, cAlphaArgs(8)); + if (hmZone.InfiltrationCalc_C || hmZone.PeopleCountCalc_C) { + hmZone.measuredCO2ConcSched = CO2ConcentrationSched; } - if (state.dataHybridModel->HybridModelZone(ZonePtr).IncludeSystemSupplyParameters) { - state.dataHybridModel->HybridModelZone(ZonePtr).ZoneSupplyAirTemperatureSchedulePtr = GetScheduleIndex(state, cAlphaArgs(13)); - state.dataHybridModel->HybridModelZone(ZonePtr).ZoneSupplyAirMassFlowRateSchedulePtr = - GetScheduleIndex(state, cAlphaArgs(14)); - state.dataHybridModel->HybridModelZone(ZonePtr).ZoneSupplyAirHumidityRatioSchedulePtr = - GetScheduleIndex(state, cAlphaArgs(15)); - state.dataHybridModel->HybridModelZone(ZonePtr).ZoneSupplyAirCO2ConcentrationSchedulePtr = - GetScheduleIndex(state, cAlphaArgs(16)); + if (hmZone.IncludeSystemSupplyParameters) { + hmZone.supplyAirTempSched = supplyAirTemperatureSched; + hmZone.supplyAirMassFlowRateSched = supplyAirMassFlowRateSched; + hmZone.supplyAirHumRatSched = supplyAirHumidityRatioSched; + hmZone.supplyAirCO2ConcSched = supplyAirCO2ConcentrationSched; } // Get optional people related schedules - if (state.dataHybridModel->HybridModelZone(ZonePtr).PeopleCountCalc_T || - state.dataHybridModel->HybridModelZone(ZonePtr).PeopleCountCalc_H || - state.dataHybridModel->HybridModelZone(ZonePtr).PeopleCountCalc_C) { - if (PeopleActivityLevelSchPtr > 0) { - state.dataHybridModel->HybridModelZone(ZonePtr).ZonePeopleActivityLevelSchedulePtr = - GetScheduleIndex(state, cAlphaArgs(9)); + if (hmZone.PeopleCountCalc_T || hmZone.PeopleCountCalc_H || hmZone.PeopleCountCalc_C) { + if (peopleActivityLevelSched != nullptr) { + hmZone.peopleActivityLevelSched = peopleActivityLevelSched; } else { ShowWarningError( state, format("Field \"{}\": default people activity level is not provided, default value of 130W/person will be used.", cAlphaFieldNames(9))); } - if (PeopleSensibleFractionSchPtr > 0) { - state.dataHybridModel->HybridModelZone(ZonePtr).ZonePeopleSensibleFractionSchedulePtr = - GetScheduleIndex(state, cAlphaArgs(10)); + if (peopleSensibleFractionSched != nullptr) { + hmZone.peopleSensibleFracSched = peopleSensibleFractionSched; } else { ShowWarningError( state, format("Field \"{}\": default people sensible heat rate is not provided, default value of 0.6 will be used.", cAlphaFieldNames(10))); } - if (PeopleRadiantFractionSchPtr > 0) { - state.dataHybridModel->HybridModelZone(ZonePtr).ZonePeopleRadiationFractionSchedulePtr = - GetScheduleIndex(state, cAlphaArgs(11)); + if (peopleRadiantFractionSched != nullptr) { + hmZone.peopleRadiantFracSched = peopleRadiantFractionSched; } else { ShowWarningError(state, format("Field \"{}\": default people radiant heat portion (of sensible heat) is not provided, default " "value of 0.7 will be used.", cAlphaFieldNames(11))); } - if (PeopleCO2GenRateSchPtr > 0) { - state.dataHybridModel->HybridModelZone(ZonePtr).ZonePeopleCO2GenRateSchedulePtr = GetScheduleIndex(state, cAlphaArgs(12)); + if (peopleCO2GenRateSched != nullptr) { + hmZone.peopleCO2GenRateSched = peopleCO2GenRateSched; } else { ShowWarningError(state, format("Field \"{}\": default people CO2 generation rate is not provided, default value of 0.0000000382 " @@ -385,17 +364,17 @@ namespace HybridModel { if (state.dataHybridModel->FlagHybridModel) { // prepare start and end date for Hybrid Modeling - state.dataHybridModel->HybridModelZone(ZonePtr).ZoneMeasuredTemperatureStartMonth = rNumericArgs(1); - state.dataHybridModel->HybridModelZone(ZonePtr).ZoneMeasuredTemperatureStartDate = rNumericArgs(2); - state.dataHybridModel->HybridModelZone(ZonePtr).ZoneMeasuredTemperatureEndMonth = rNumericArgs(3); - state.dataHybridModel->HybridModelZone(ZonePtr).ZoneMeasuredTemperatureEndDate = rNumericArgs(4); + hmZone.measuredTempStartMonth = rNumericArgs(1); + hmZone.measuredTempStartDate = rNumericArgs(2); + hmZone.measuredTempEndMonth = rNumericArgs(3); + hmZone.measuredTempEndDate = rNumericArgs(4); { int const HMDayArr[12] = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334}; - int HybridModelStartMonth = state.dataHybridModel->HybridModelZone(ZonePtr).ZoneMeasuredTemperatureStartMonth; - int HybridModelStartDate = state.dataHybridModel->HybridModelZone(ZonePtr).ZoneMeasuredTemperatureStartDate; - int HybridModelEndMonth = state.dataHybridModel->HybridModelZone(ZonePtr).ZoneMeasuredTemperatureEndMonth; - int HybridModelEndDate = state.dataHybridModel->HybridModelZone(ZonePtr).ZoneMeasuredTemperatureEndDate; + int HybridModelStartMonth = hmZone.measuredTempStartMonth; + int HybridModelStartDate = hmZone.measuredTempStartDate; + int HybridModelEndMonth = hmZone.measuredTempEndMonth; + int HybridModelEndDate = hmZone.measuredTempEndDate; int HMStartDay = 0; int HMEndDay = 0; @@ -407,15 +386,13 @@ namespace HybridModel { HMEndDay = HMDayArr[HybridModelEndMonth - 1]; } - state.dataHybridModel->HybridModelZone(ZonePtr).HybridStartDayOfYear = HMStartDay + HybridModelStartDate; - state.dataHybridModel->HybridModelZone(ZonePtr).HybridEndDayOfYear = HMEndDay + HybridModelEndDate; + hmZone.HybridStartDayOfYear = HMStartDay + HybridModelStartDate; + hmZone.HybridEndDayOfYear = HMEndDay + HybridModelEndDate; } } // Output variable - if (state.dataHybridModel->HybridModelZone(ZonePtr).InfiltrationCalc_T || - state.dataHybridModel->HybridModelZone(ZonePtr).InfiltrationCalc_H || - state.dataHybridModel->HybridModelZone(ZonePtr).InfiltrationCalc_C) { + if (hmZone.InfiltrationCalc_T || hmZone.InfiltrationCalc_H || hmZone.InfiltrationCalc_C) { SetupOutputVariable(state, "Zone Infiltration Hybrid Model Air Change Rate", Constant::Units::ach, @@ -431,9 +408,7 @@ namespace HybridModel { OutputProcessor::StoreType::Average, state.dataHeatBal->Zone(ZonePtr).Name); } - if (state.dataHybridModel->HybridModelZone(ZonePtr).PeopleCountCalc_T || - state.dataHybridModel->HybridModelZone(ZonePtr).PeopleCountCalc_H || - state.dataHybridModel->HybridModelZone(ZonePtr).PeopleCountCalc_C) { + if (hmZone.PeopleCountCalc_T || hmZone.PeopleCountCalc_H || hmZone.PeopleCountCalc_C) { SetupOutputVariable(state, "Zone Hybrid Model People Count", Constant::Units::None, @@ -442,7 +417,7 @@ namespace HybridModel { OutputProcessor::StoreType::Average, state.dataHeatBal->Zone(ZonePtr).Name); } - if (state.dataHybridModel->HybridModelZone(ZonePtr).InternalThermalMassCalc_T) { + if (hmZone.InternalThermalMassCalc_T) { SetupOutputVariable(state, "Zone Hybrid Model Thermal Mass Multiplier", Constant::Units::None, @@ -451,25 +426,26 @@ namespace HybridModel { OutputProcessor::StoreType::Average, state.dataHeatBal->Zone(ZonePtr).Name); } + + // ZoneAirMassFlowConservation should not be activated during the Hybrid Modeling infiltration calculations + if (hmZone.InfiltrationCalc_T && state.dataHeatBal->ZoneAirMassFlow.EnforceZoneMassBalance) { + state.dataHeatBal->ZoneAirMassFlow.EnforceZoneMassBalance = false; + ShowWarningError(state, "ZoneAirMassFlowConservation is deactivated when Hybrid Modeling is performed."); + } } else { ShowSevereError( state, format("{}=\"{}\" invalid {}=\"{}\" not found.", CurrentModuleObject, cAlphaArgs(1), cAlphaFieldNames(2), cAlphaArgs(2))); ErrorsFound = true; } - } - // ZoneAirMassFlowConservation should not be activated during the Hybrid Modeling infiltration calculations - if (state.dataHybridModel->HybridModelZone(ZonePtr).InfiltrationCalc_T && state.dataHeatBal->ZoneAirMassFlow.EnforceZoneMassBalance) { - state.dataHeatBal->ZoneAirMassFlow.EnforceZoneMassBalance = false; - ShowWarningError(state, "ZoneAirMassFlowConservation is deactivated when Hybrid Modeling is performed."); } - + // RoomAirModelType should be Mixing if Hybrid Modeling is performed for the zone if (state.dataHybridModel->FlagHybridModel) { - for (ZonePtr = 1; ZonePtr <= state.dataGlobal->NumOfZones; ZonePtr++) { - if ((state.dataHybridModel->HybridModelZone(ZonePtr).InternalThermalMassCalc_T || - state.dataHybridModel->HybridModelZone(ZonePtr).InfiltrationCalc_T) && + for (int ZonePtr = 1; ZonePtr <= state.dataGlobal->NumOfZones; ZonePtr++) { + auto &hmZone = state.dataHybridModel->hybridModelZones(ZonePtr); + if ((hmZone.InternalThermalMassCalc_T || hmZone.InfiltrationCalc_T) && (state.dataRoomAir->AirModel(ZonePtr).AirModel != RoomAir::RoomAirModel::Mixing)) { state.dataRoomAir->AirModel(ZonePtr).AirModel = RoomAir::RoomAirModel::Mixing; ShowWarningError(state, "Room Air Model Type should be Mixing if Hybrid Modeling is performed for the zone."); diff --git a/src/EnergyPlus/HybridModel.hh b/src/EnergyPlus/HybridModel.hh index d5067a6c37d..e3eb9738402 100644 --- a/src/EnergyPlus/HybridModel.hh +++ b/src/EnergyPlus/HybridModel.hh @@ -74,52 +74,39 @@ namespace HybridModel { // Types - struct HybridModelProperties + struct HybridModelZone { // Members std::string Name; - int ZoneMeasuredTemperatureSchedulePtr; - int ZoneMeasuredHumidityRatioSchedulePtr; - int ZoneMeasuredCO2ConcentrationSchedulePtr; - - int ZonePeopleActivityLevelSchedulePtr; - int ZonePeopleSensibleFractionSchedulePtr; - int ZonePeopleRadiationFractionSchedulePtr; - int ZonePeopleCO2GenRateSchedulePtr; - - int ZoneSupplyAirTemperatureSchedulePtr; - int ZoneSupplyAirMassFlowRateSchedulePtr; - int ZoneSupplyAirHumidityRatioSchedulePtr; - int ZoneSupplyAirCO2ConcentrationSchedulePtr; - - bool InternalThermalMassCalc_T; // Calculate thermal mass flag with measured temperature - bool InfiltrationCalc_T; // Calculate air infiltration rate flag with measured temperature - bool InfiltrationCalc_H; // Calculate air infiltration rate flag with measured humidity ratio - bool InfiltrationCalc_C; // Calculate air infiltration rate flag with measured CO2 concentration - bool PeopleCountCalc_T; // Calculate zone people count flag with measured temperature - bool PeopleCountCalc_H; // Calculate zone people count flag with measured humidity ratio - bool PeopleCountCalc_C; // Calculate zone people count flag with measured CO2 concentration - bool IncludeSystemSupplyParameters; // Flag to decide whether to include system supply terms - - int ZoneMeasuredTemperatureStartMonth; - int ZoneMeasuredTemperatureStartDate; - int ZoneMeasuredTemperatureEndMonth; - int ZoneMeasuredTemperatureEndDate; - int HybridStartDayOfYear; // Hybrid model start date of year - int HybridEndDayOfYear; // Hybrid model end date of year - - // Default Constructor - HybridModelProperties() - : ZoneMeasuredTemperatureSchedulePtr(0), ZoneMeasuredHumidityRatioSchedulePtr(0), ZoneMeasuredCO2ConcentrationSchedulePtr(0), - ZonePeopleActivityLevelSchedulePtr(0), ZonePeopleSensibleFractionSchedulePtr(0), ZonePeopleRadiationFractionSchedulePtr(0), - ZonePeopleCO2GenRateSchedulePtr(0), ZoneSupplyAirTemperatureSchedulePtr(0), ZoneSupplyAirMassFlowRateSchedulePtr(0), - ZoneSupplyAirHumidityRatioSchedulePtr(0), ZoneSupplyAirCO2ConcentrationSchedulePtr(0), InternalThermalMassCalc_T(false), - InfiltrationCalc_T(false), InfiltrationCalc_H(false), InfiltrationCalc_C(false), PeopleCountCalc_T(false), PeopleCountCalc_H(false), - PeopleCountCalc_C(false), IncludeSystemSupplyParameters(false), ZoneMeasuredTemperatureStartMonth(0), - ZoneMeasuredTemperatureStartDate(0), ZoneMeasuredTemperatureEndMonth(0), ZoneMeasuredTemperatureEndDate(0), HybridStartDayOfYear(0), - HybridEndDayOfYear(0) - { - } + Sched::Schedule *measuredTempSched = nullptr; + Sched::Schedule *measuredHumRatSched = nullptr; + Sched::Schedule *measuredCO2ConcSched = nullptr; + + Sched::Schedule *peopleActivityLevelSched = nullptr; + Sched::Schedule *peopleSensibleFracSched = nullptr; + Sched::Schedule *peopleRadiantFracSched = nullptr; + Sched::Schedule *peopleCO2GenRateSched = nullptr; + + Sched::Schedule *supplyAirTempSched = nullptr; + Sched::Schedule *supplyAirMassFlowRateSched = nullptr; + Sched::Schedule *supplyAirHumRatSched = nullptr; + Sched::Schedule *supplyAirCO2ConcSched = nullptr; + + bool InternalThermalMassCalc_T = false; // Calculate thermal mass flag with measured temperature + bool InfiltrationCalc_T = false; // Calculate air infiltration rate flag with measured temperature + bool InfiltrationCalc_H = false; // Calculate air infiltration rate flag with measured humidity ratio + bool InfiltrationCalc_C = false; // Calculate air infiltration rate flag with measured CO2 concentration + bool PeopleCountCalc_T = false; // Calculate zone people count flag with measured temperature + bool PeopleCountCalc_H = false; // Calculate zone people count flag with measured humidity ratio + bool PeopleCountCalc_C = false; // Calculate zone people count flag with measured CO2 concentration + bool IncludeSystemSupplyParameters = false; // Flag to decide whether to include system supply terms + + int measuredTempStartMonth = 0; + int measuredTempStartDate = 0; + int measuredTempEndMonth = 0; + int measuredTempEndDate = 0; + int HybridStartDayOfYear = 0; // Hybrid model start date of year + int HybridEndDayOfYear = 0; // Hybrid model end date of year }; // Object Data @@ -141,7 +128,11 @@ struct HybridModelData : BaseGlobalStruct int NumOfHybridModelZones = 0; // Number of hybrid model zones in the model std::string CurrentModuleObject; // to assist in getting input - Array1D HybridModelZone; + Array1D hybridModelZones; + + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } void init_state([[maybe_unused]] EnergyPlusData &state) override { @@ -155,7 +146,7 @@ struct HybridModelData : BaseGlobalStruct this->FlagHybridModel_PC = false; this->NumOfHybridModelZones = 0; this->CurrentModuleObject.clear(); - this->HybridModelZone.deallocate(); + this->hybridModelZones.deallocate(); } }; diff --git a/src/EnergyPlus/HybridUnitaryAirConditioners.cc b/src/EnergyPlus/HybridUnitaryAirConditioners.cc index 26f24c4997d..45feee681a8 100644 --- a/src/EnergyPlus/HybridUnitaryAirConditioners.cc +++ b/src/EnergyPlus/HybridUnitaryAirConditioners.cc @@ -443,7 +443,6 @@ void GetInputZoneHybridUnitaryAirConditioners(EnergyPlusData &state, bool &Error // Using/Aliasing using BranchNodeConnections::TestCompSet; - using namespace ScheduleManager; using BranchNodeConnections::SetUpCompSets; using NodeInputManager::GetOnlySingleNode; using namespace DataLoopNode; @@ -510,16 +509,11 @@ void GetInputZoneHybridUnitaryAirConditioners(EnergyPlusData &state, bool &Error // A1, \field Name hybridUnitaryAC.Name = Alphas(1); // A2, \field Availability Schedule Name - hybridUnitaryAC.Schedule = Alphas(2); if (lAlphaBlanks(2)) { - hybridUnitaryAC.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - hybridUnitaryAC.SchedPtr = GetScheduleIndex(state, Alphas(2)); - if (hybridUnitaryAC.SchedPtr == 0) { - ShowSevereError(state, format("Invalid {}={}", cAlphaFields(2), Alphas(2))); - ShowContinueError(state, format("Entered in {}={}", cCurrentModuleObject, Alphas(1))); - ErrorsFound = true; - } + hybridUnitaryAC.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((hybridUnitaryAC.availSched = Sched::GetSchedule(state, Alphas(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(2), Alphas(2)); + ErrorsFound = true; } // A3, \field Availability Manager List Name if (!lAlphaBlanks(3)) { @@ -527,40 +521,31 @@ void GetInputZoneHybridUnitaryAirConditioners(EnergyPlusData &state, bool &Error } // A4, \field Minimum Supply Air Temperature Schedule Named - if (!lAlphaBlanks(4)) { - hybridUnitaryAC.TsaMin_schedule_pointer = GetScheduleIndex(state, Alphas(4)); - if (hybridUnitaryAC.TsaMin_schedule_pointer == 0) { - ShowSevereError(state, format("Invalid {}={}", cAlphaFields(4), Alphas(4))); - ShowContinueError(state, format("Entered in {}={}", cCurrentModuleObject, Alphas(1))); - ErrorsFound = true; - } + if (lAlphaBlanks(4)) { + } else if ((hybridUnitaryAC.TsaMinSched = Sched::GetSchedule(state, Alphas(4))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(4), Alphas(4)); + ErrorsFound = true; } + // A5, \field Maximum Supply Air Temperature Schedule Name - if (!lAlphaBlanks(5)) { - hybridUnitaryAC.TsaMax_schedule_pointer = GetScheduleIndex(state, Alphas(5)); - if (hybridUnitaryAC.TsaMax_schedule_pointer == 0) { - ShowSevereError(state, format("Invalid {}={}", cAlphaFields(5), Alphas(5))); - ShowContinueError(state, format("Entered in {}={}", cCurrentModuleObject, Alphas(1))); - ErrorsFound = true; - } + if (lAlphaBlanks(5)) { + } else if ((hybridUnitaryAC.TsaMaxSched = Sched::GetSchedule(state, Alphas(5))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(5), Alphas(5)); + ErrorsFound = true; } + // A6, \field Minimum Supply Air Humidity Ratio Schedule Name - if (!lAlphaBlanks(6)) { - hybridUnitaryAC.RHsaMin_schedule_pointer = GetScheduleIndex(state, Alphas(6)); - if (hybridUnitaryAC.RHsaMin_schedule_pointer == 0) { - ShowSevereError(state, format("Invalid {}={}", cAlphaFields(6), Alphas(6))); - ShowContinueError(state, format("Entered in {}={}", cCurrentModuleObject, Alphas(1))); - ErrorsFound = true; - } + if (lAlphaBlanks(6)) { + } else if ((hybridUnitaryAC.RHsaMinSched = Sched::GetSchedule(state, Alphas(6))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(6), Alphas(6)); + ErrorsFound = true; } + // A7, \field Maximum Supply Air Humidity Ratio Schedule Name - if (!lAlphaBlanks(7)) { - hybridUnitaryAC.RHsaMax_schedule_pointer = GetScheduleIndex(state, Alphas(7)); - if (hybridUnitaryAC.RHsaMax_schedule_pointer == 0) { - ShowSevereError(state, format("Invalid {}={}", cAlphaFields(7), Alphas(7))); - ShowContinueError(state, format("Entered in {}={}", cCurrentModuleObject, Alphas(1))); - ErrorsFound = true; - } + if (lAlphaBlanks(7)) { + } else if ((hybridUnitaryAC.RHsaMaxSched = Sched::GetSchedule(state, Alphas(7))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(7), Alphas(7)); + ErrorsFound = true; } // A8, \field Method to Choose Value of Controlled Inputs diff --git a/src/EnergyPlus/HybridUnitaryAirConditioners.hh b/src/EnergyPlus/HybridUnitaryAirConditioners.hh index c93210bcff9..b22c730510a 100644 --- a/src/EnergyPlus/HybridUnitaryAirConditioners.hh +++ b/src/EnergyPlus/HybridUnitaryAirConditioners.hh @@ -116,6 +116,10 @@ struct HybridUnitaryAirConditionersData : BaseGlobalStruct Array1D_bool MyFanFlag; Array1D_bool MyZoneEqFlag; // used to set up zone equipment availability managers + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/ICEngineElectricGenerator.hh b/src/EnergyPlus/ICEngineElectricGenerator.hh index b3e093e9dbd..f1489118b9e 100644 --- a/src/EnergyPlus/ICEngineElectricGenerator.hh +++ b/src/EnergyPlus/ICEngineElectricGenerator.hh @@ -186,6 +186,10 @@ struct ICEngineElectricGeneratorData : BaseGlobalStruct bool getICEInput = true; // When TRUE, calls subroutine to read input file. Array1D ICEngineGenerator; // dimension to number of machines + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/IceThermalStorage.cc b/src/EnergyPlus/IceThermalStorage.cc index a6d19af28d0..bff41f8f895 100644 --- a/src/EnergyPlus/IceThermalStorage.cc +++ b/src/EnergyPlus/IceThermalStorage.cc @@ -371,7 +371,7 @@ namespace IceThermalStorage { Real64 LocalLoad = this->MassFlowRate * Cp * (TempIn - TempSetPt); // Determine what the status is regarding the ice storage unit and the loop level flow - if ((std::abs(LocalLoad) <= SmallestLoad) || (ScheduleManager::GetCurrentScheduleValue(state, this->ScheduleIndex) <= 0)) { + if ((std::abs(LocalLoad) <= SmallestLoad) || (this->availSched->getCurrentVal() <= 0)) { // No real load on the ice storage device or ice storage OFF--bypass all of the flow and leave the tank alone this->CompLoad = 0.0; this->OutletTemp = TempIn; @@ -680,6 +680,8 @@ namespace IceThermalStorage { // heating and cooling loops and begin to fill the // arrays associated with the type PlantLoopProps. + static constexpr std::string_view routineName = "GetIceStorageInput"; + bool ErrorsFound; ErrorsFound = false; // Always need to reset this since there are multiple types of ice storage systems @@ -815,6 +817,9 @@ namespace IceThermalStorage { state.dataIPShortCut->lAlphaFieldBlanks, state.dataIPShortCut->cAlphaFieldNames, state.dataIPShortCut->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1)}; + Util::IsNameEmpty(state, state.dataIPShortCut->cAlphaArgs(1), state.dataIPShortCut->cCurrentModuleObject, ErrorsFound); ++state.dataIceThermalStorage->TotalNumIceStorage; @@ -823,26 +828,18 @@ namespace IceThermalStorage { state.dataIceThermalStorage->DetailedIceStorage(iceNum).Name = state.dataIPShortCut->cAlphaArgs(1); // Detailed ice storage name // Get and verify availability schedule - state.dataIceThermalStorage->DetailedIceStorage(iceNum).ScheduleName = - state.dataIPShortCut->cAlphaArgs(2); // Detailed ice storage availability schedule name if (state.dataIPShortCut->lAlphaFieldBlanks(2)) { - state.dataIceThermalStorage->DetailedIceStorage(iceNum).ScheduleIndex = ScheduleManager::ScheduleAlwaysOn; - } else { - state.dataIceThermalStorage->DetailedIceStorage(iceNum).ScheduleIndex = - ScheduleManager::GetScheduleIndex(state, state.dataIceThermalStorage->DetailedIceStorage(iceNum).ScheduleName); - if (state.dataIceThermalStorage->DetailedIceStorage(iceNum).ScheduleIndex == 0) { - ShowSevereError(state, format("Invalid {}={}", state.dataIPShortCut->cAlphaFieldNames(2), state.dataIPShortCut->cAlphaArgs(2))); - ShowContinueError(state, - format("Entered in {}={}", state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ErrorsFound = true; - } + state.dataIceThermalStorage->DetailedIceStorage(iceNum).availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((state.dataIceThermalStorage->DetailedIceStorage(iceNum).availSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(2), state.dataIPShortCut->cAlphaArgs(2)); + ErrorsFound = true; } // Get and Verify ITS nominal Capacity (user input is in GJ, internal value is in W-hr) // Convert GJ to J by multiplying by 10^9 // Convert J to W-hr by dividing by number of seconds in an hour (3600) state.dataIceThermalStorage->DetailedIceStorage(iceNum).NomCapacity = - state.dataIPShortCut->rNumericArgs(1) * (1.e+09) / (Constant::SecInHour); + state.dataIPShortCut->rNumericArgs(1) * (1.e+09) / Constant::rSecsInHour; if (state.dataIPShortCut->rNumericArgs(1) <= 0.0) { ShowSevereError(state, diff --git a/src/EnergyPlus/IceThermalStorage.hh b/src/EnergyPlus/IceThermalStorage.hh index a9e5e2271bf..3c538001dce 100644 --- a/src/EnergyPlus/IceThermalStorage.hh +++ b/src/EnergyPlus/IceThermalStorage.hh @@ -59,6 +59,7 @@ #include #include #include +#include namespace EnergyPlus { @@ -177,9 +178,8 @@ namespace IceThermalStorage { struct DetailedIceStorageData : PlantComponent { - std::string Name; // User identifier - std::string ScheduleName; // User identifier - int ScheduleIndex; // Plant inlet node number for ice storage unit + std::string Name; // User identifier // What kind of a comment is this? + Sched::Schedule *availSched; // schedule (availability?) Real64 NomCapacity; // Design storage capacity of Ice Thermal Storage system [W-hr] // (User input for this parameter in GJ--need to convert to W-hr) int PlantInNodeNum; // Plant inlet node number for ice storage unit @@ -231,7 +231,7 @@ namespace IceThermalStorage { // Default Constructor DetailedIceStorageData() - : ScheduleIndex(0), NomCapacity(0.0), PlantInNodeNum(0), PlantOutNodeNum(0), plantLoc{}, DesignMassFlowRate(0.0), MapNum(0), + : NomCapacity(0.0), PlantInNodeNum(0), PlantOutNodeNum(0), plantLoc{}, DesignMassFlowRate(0.0), MapNum(0), DischargeCurveNum(0), ChargeCurveNum(0), CurveFitTimeStep(1.0), DischargeParaElecLoad(0.0), ChargeParaElecLoad(0.0), TankLossCoeff(0.0), FreezingTemp(0.0), CompLoad(0.0), IceFracChange(0.0), IceFracRemaining(1.0), IceFracOnCoil(1.0), DischargingRate(0.0), DischargingEnergy(0.0), ChargingRate(0.0), ChargingEnergy(0.0), MassFlowRate(0.0), BypassMassFlowRate(0.0), TankMassFlowRate(0.0), @@ -293,6 +293,10 @@ struct IceThermalStorageData : BaseGlobalStruct EPVector SimpleIceStorage; EPVector DetailedIceStorage; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/IndoorGreen.cc b/src/EnergyPlus/IndoorGreen.cc index 19d73bd4366..3a3c7066cb0 100644 --- a/src/EnergyPlus/IndoorGreen.cc +++ b/src/EnergyPlus/IndoorGreen.cc @@ -108,46 +108,46 @@ namespace IndoorGreen { // PURPOSE OF THIS SUBROUTINE: // Get the input for the indoor living wall objects and store the input data in the indoorGreens array. - auto &lw = state.dataIndoorGreen; - auto &ip = state.dataInputProcessing->inputProcessor; + auto &s_lw = state.dataIndoorGreen; + auto &s_ip = state.dataInputProcessing->inputProcessor; + auto &s_ipsc = state.dataIPShortCut; + static constexpr std::string_view RoutineName("GetIndoorLivingWallInput: "); std::string_view cCurrentModuleObject = "IndoorLivingWall"; // match the idd int NumNums; // Number of real numbers returned by GetObjectItem int NumAlphas; // Number of alphanumerics returned by GetObjectItem int IOStat; // Status flag from GetObjectItem - Real64 SchMin; - Real64 SchMax; - lw->NumIndoorGreen = ip->getNumObjectsFound(state, cCurrentModuleObject); - if (lw->NumIndoorGreen > 0) lw->indoorGreens.allocate(lw->NumIndoorGreen); // Allocate the IndoorGreen input data array - for (int IndoorGreenNum = 1; IndoorGreenNum <= lw->NumIndoorGreen; ++IndoorGreenNum) { - auto &ig = lw->indoorGreens(IndoorGreenNum); - ip->getObjectItem(state, + s_lw->NumIndoorGreen = s_ip->getNumObjectsFound(state, cCurrentModuleObject); + if (s_lw->NumIndoorGreen > 0) s_lw->indoorGreens.allocate(s_lw->NumIndoorGreen); // Allocate the IndoorGreen input data array + for (int IndoorGreenNum = 1; IndoorGreenNum <= s_lw->NumIndoorGreen; ++IndoorGreenNum) { + auto &ig = s_lw->indoorGreens(IndoorGreenNum); + s_ip->getObjectItem(state, cCurrentModuleObject, IndoorGreenNum, - state.dataIPShortCut->cAlphaArgs, + s_ipsc->cAlphaArgs, NumAlphas, - state.dataIPShortCut->rNumericArgs, + s_ipsc->rNumericArgs, NumNums, IOStat, - state.dataIPShortCut->lNumericFieldBlanks, - state.dataIPShortCut->lAlphaFieldBlanks, - state.dataIPShortCut->cAlphaFieldNames, - state.dataIPShortCut->cNumericFieldNames); - ErrorObjectHeader eoh{RoutineName, cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1)}; - Util::IsNameEmpty(state, state.dataIPShortCut->cAlphaArgs(1), cCurrentModuleObject, ErrorsFound); - ig.Name = state.dataIPShortCut->cAlphaArgs(1); - ig.SurfName = state.dataIPShortCut->cAlphaArgs(2); - ig.SurfPtr = Util::FindItemInList(state.dataIPShortCut->cAlphaArgs(2), state.dataSurface->Surface); + s_ipsc->lNumericFieldBlanks, + s_ipsc->lAlphaFieldBlanks, + s_ipsc->cAlphaFieldNames, + s_ipsc->cNumericFieldNames); + ErrorObjectHeader eoh{RoutineName, cCurrentModuleObject, s_ipsc->cAlphaArgs(1)}; + Util::IsNameEmpty(state, s_ipsc->cAlphaArgs(1), cCurrentModuleObject, ErrorsFound); + ig.Name = s_ipsc->cAlphaArgs(1); + ig.SurfName = s_ipsc->cAlphaArgs(2); + ig.SurfPtr = Util::FindItemInList(s_ipsc->cAlphaArgs(2), state.dataSurface->Surface); if (ig.SurfPtr <= 0) { - ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(2), state.dataIPShortCut->cAlphaArgs(2)); + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2)); ErrorsFound = true; } else { - if (state.dataSurface->Surface(ig.SurfPtr).InsideHeatSourceTermSchedule > 0) { + if (state.dataSurface->Surface(ig.SurfPtr).insideHeatSourceTermSched != nullptr) { ShowSevereError(state, format("The indoor green surface {} has an Inside Face Heat Source Term Schedule defined. This surface cannot " "also be used for indoor green.", - state.dataIPShortCut->cAlphaArgs(2))); + s_ipsc->cAlphaArgs(2))); ErrorsFound = true; } ig.ZonePtr = state.dataSurface->Surface(ig.SurfPtr).Zone; @@ -157,194 +157,123 @@ namespace IndoorGreen { ShowSevereError(state, format("{}=\"{}\", invalid {} entered={}, {} is not assoicated with a thermal zone or space", RoutineName, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaFieldNames(2), - state.dataIPShortCut->cAlphaArgs(2), - state.dataIPShortCut->cAlphaArgs(2))); + s_ipsc->cAlphaArgs(1), + s_ipsc->cAlphaFieldNames(2), + s_ipsc->cAlphaArgs(2), + s_ipsc->cAlphaArgs(2))); ErrorsFound = true; } else if (state.dataSurface->Surface(ig.SurfPtr).ExtBoundCond < 0 || state.dataSurface->Surface(ig.SurfPtr).HeatTransferAlgorithm != DataSurfaces::HeatTransferModel::CTF) { ShowSevereError(state, format("{}=\"{}\", invalid {} entered={}, not a valid surface for indoor green module", RoutineName, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaFieldNames(2), - state.dataIPShortCut->cAlphaArgs(2))); + s_ipsc->cAlphaArgs(1), + s_ipsc->cAlphaFieldNames(2), + s_ipsc->cAlphaArgs(2))); ErrorsFound = true; } } - ig.SchedPtr = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(3)); - if (ig.SchedPtr == 0) { - ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(3), state.dataIPShortCut->cAlphaArgs(3)); + + if ((ig.sched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(3))) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(3), s_ipsc->cAlphaArgs(3)); + ErrorsFound = true; + } else if (!ig.sched->checkMinVal(state, Clusive::In, 0.0)) { + Sched::ShowSevereBadMin(state, eoh, s_ipsc->cAlphaFieldNames(3), s_ipsc->cAlphaArgs(3), Clusive::In, 0.0); ErrorsFound = true; - } else { // check min/max on schedule - SchMin = ScheduleManager::GetScheduleMinValue(state, ig.SchedPtr); - SchMax = ScheduleManager::GetScheduleMaxValue(state, ig.SchedPtr); - if (SchMin < 0.0 || SchMax < 0.0) { - if (SchMin < 0.0) { - ShowSevereError(state, - format("{}=\"{}\", {}, minimum is < 0.0", - RoutineName, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaFieldNames(3))); - ShowContinueError( - state, - format("Schedule=\"{}\". Minimum is [{:.1R}]. Values must be >= 0.0.", state.dataIPShortCut->cAlphaArgs(3), SchMin)); - ErrorsFound = true; - } - if (SchMax < 0.0) { - ShowSevereError(state, - format("{}=\"{}\", {}, maximum is < 0.0", - RoutineName, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaFieldNames(3))); - ShowContinueError( - state, - format("Schedule=\"{}\". Maximum is [{:.1R}]. Values must be >= 0.0.", state.dataIPShortCut->cAlphaArgs(3), SchMin)); - ErrorsFound = true; - } - } } ig.etCalculationMethod = ETCalculationMethod::PenmanMonteith; // default - ig.etCalculationMethod = static_cast(getEnumValue(etCalculationMethodsUC, state.dataIPShortCut->cAlphaArgs(4))); + ig.etCalculationMethod = static_cast(getEnumValue(etCalculationMethodsUC, s_ipsc->cAlphaArgs(4))); ig.lightingMethod = LightingMethod::LED; // default - ig.lightingMethod = static_cast(getEnumValue(lightingMethodsUC, state.dataIPShortCut->cAlphaArgs(5))); + ig.lightingMethod = static_cast(getEnumValue(lightingMethodsUC, s_ipsc->cAlphaArgs(5))); + switch (ig.lightingMethod) { case LightingMethod::LED: { - ig.SchedLEDPtr = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(6)); - if (ig.SchedLEDPtr == 0) { - ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(6), state.dataIPShortCut->cAlphaArgs(6)); + if ((ig.ledSched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(6))) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(6), s_ipsc->cAlphaArgs(6)); + ErrorsFound = true; + } else if (!ig.ledSched->checkMinVal(state, Clusive::In, 0.0)) { + Sched::ShowSevereBadMin(state, eoh, s_ipsc->cAlphaFieldNames(6), s_ipsc->cAlphaArgs(6), Clusive::In, 0.0); ErrorsFound = true; - } else { // check min/max on schedule - SchMin = ScheduleManager::GetScheduleMinValue(state, ig.SchedLEDPtr); - SchMax = ScheduleManager::GetScheduleMaxValue(state, ig.SchedLEDPtr); - if (SchMin < 0.0 || SchMax < 0.0) { - if (SchMin < 0.0) { - ShowSevereError(state, - format("{}=\"{}\", {}, minimum is < 0.0", - RoutineName, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaFieldNames(6))); - ShowContinueError( - state, - format("Schedule=\"{}\". Minimum is [{:.1R}]. Values must be >= 0.0.", state.dataIPShortCut->cAlphaArgs(6), SchMin)); - ErrorsFound = true; - } - if (SchMax < 0.0) { - ShowSevereError(state, - format("{}=\"{}\", {}, maximum is < 0.0", - RoutineName, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaFieldNames(6))); - ShowContinueError( - state, - format("Schedule=\"{}\". Maximum is [{:.1R}]. Values must be >= 0.0.", state.dataIPShortCut->cAlphaArgs(6), SchMin)); - ErrorsFound = true; - } - } } } break; case LightingMethod::Daylighting: { - ig.LightRefPtr = Util::FindItemInList(state.dataIPShortCut->cAlphaArgs(7), + ig.LightRefPtr = Util::FindItemInList(s_ipsc->cAlphaArgs(7), state.dataDayltg->DaylRefPt, &EnergyPlus::Dayltg::RefPointData::Name); // Field: Daylighting Reference Point Name - ig.LightControlPtr = Util::FindItemInList(state.dataIPShortCut->cAlphaArgs(7), + ig.LightControlPtr = Util::FindItemInList(s_ipsc->cAlphaArgs(7), state.dataDayltg->daylightControl, &EnergyPlus::Dayltg::DaylightingControl::Name); // Field: Daylighting Control Name if (ig.LightControlPtr == 0) { - ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(7), state.dataIPShortCut->cAlphaArgs(7)); + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(7), s_ipsc->cAlphaArgs(7)); ErrorsFound = true; continue; } } break; case LightingMethod::LEDDaylighting: { - ig.LightRefPtr = Util::FindItemInList(state.dataIPShortCut->cAlphaArgs(7), + ig.LightRefPtr = Util::FindItemInList(s_ipsc->cAlphaArgs(7), state.dataDayltg->DaylRefPt, &EnergyPlus::Dayltg::RefPointData::Name); // Field: Daylighting Reference Point Name - ig.LightControlPtr = Util::FindItemInList(state.dataIPShortCut->cAlphaArgs(7), + ig.LightControlPtr = Util::FindItemInList(s_ipsc->cAlphaArgs(7), state.dataDayltg->daylightControl, &EnergyPlus::Dayltg::DaylightingControl::Name); // Field: Daylighting Control Name if (ig.LightControlPtr == 0) { - ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(7), state.dataIPShortCut->cAlphaArgs(7)); + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(7), s_ipsc->cAlphaArgs(7)); ErrorsFound = true; continue; } - ig.SchedLEDDaylightTargetPtr = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(8)); - if (ig.SchedLEDDaylightTargetPtr == 0) { - ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(8), state.dataIPShortCut->cAlphaArgs(8)); + + if ((ig.ledDaylightTargetSched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(8))) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(8), s_ipsc->cAlphaArgs(8)); + ErrorsFound = true; + } else if (!ig.ledDaylightTargetSched->checkMinVal(state, Clusive::In, 0.0)) { + Sched::ShowSevereBadMin(state, eoh, s_ipsc->cAlphaFieldNames(8), s_ipsc->cAlphaArgs(8), Clusive::In, 0.0); ErrorsFound = true; - } else { // check min/max on schedule - SchMin = ScheduleManager::GetScheduleMinValue(state, ig.SchedLEDDaylightTargetPtr); - SchMax = ScheduleManager::GetScheduleMaxValue(state, ig.SchedLEDDaylightTargetPtr); - if (SchMin < 0.0 || SchMax < 0.0) { - if (SchMin < 0.0) { - ShowSevereError(state, - format("{}=\"{}\", {}, minimum is < 0.0", - RoutineName, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaFieldNames(8))); - ShowContinueError( - state, - format("Schedule=\"{}\". Minimum is [{:.1R}]. Values must be >= 0.0.", state.dataIPShortCut->cAlphaArgs(8), SchMin)); - ErrorsFound = true; - } - if (SchMax < 0.0) { - ShowSevereError(state, - format("{}=\"{}\", {}, maximum is < 0.0", - RoutineName, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaFieldNames(8))); - ShowContinueError( - state, - format("Schedule=\"{}\". Maximum is [{:.1R}]. Values must be >= 0.0.", state.dataIPShortCut->cAlphaArgs(8), SchMin)); - ErrorsFound = true; - } - } } } break; + default: break; } - ig.LeafArea = state.dataIPShortCut->rNumericArgs(1); + ig.LeafArea = s_ipsc->rNumericArgs(1); if (ig.LeafArea < 0) { ShowSevereError(state, format("{}=\"{}\", invalid {} entered={}", RoutineName, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cNumericFieldNames(1), - state.dataIPShortCut->rNumericArgs(1))); + s_ipsc->cAlphaArgs(1), + s_ipsc->cNumericFieldNames(1), + s_ipsc->rNumericArgs(1))); ErrorsFound = true; } - ig.LEDNominalPPFD = state.dataIPShortCut->rNumericArgs(2); + ig.LEDNominalPPFD = s_ipsc->rNumericArgs(2); if (ig.LEDNominalPPFD < 0) { ShowSevereError(state, format("{}=\"{}\", invalid {} entered={}", RoutineName, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cNumericFieldNames(2), - state.dataIPShortCut->rNumericArgs(2))); + s_ipsc->cAlphaArgs(1), + s_ipsc->cNumericFieldNames(2), + s_ipsc->rNumericArgs(2))); ErrorsFound = true; } - ig.LEDNominalEleP = state.dataIPShortCut->rNumericArgs(3); + ig.LEDNominalEleP = s_ipsc->rNumericArgs(3); if (ig.LEDNominalEleP < 0) { ShowSevereError(state, format("{}=\"{}\", invalid {} entered={}", RoutineName, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cNumericFieldNames(3), - state.dataIPShortCut->rNumericArgs(3))); + s_ipsc->cAlphaArgs(1), + s_ipsc->cNumericFieldNames(3), + s_ipsc->rNumericArgs(3))); ErrorsFound = true; } - ig.LEDRadFraction = state.dataIPShortCut->rNumericArgs(4); + ig.LEDRadFraction = s_ipsc->rNumericArgs(4); if (ig.LEDRadFraction < 0 || ig.LEDRadFraction > 1.0) { ShowSevereError(state, format("{}=\"{}\", invalid {} entered={}", RoutineName, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cNumericFieldNames(4), - state.dataIPShortCut->rNumericArgs(4))); + s_ipsc->cAlphaArgs(1), + s_ipsc->cNumericFieldNames(4), + s_ipsc->rNumericArgs(4))); ErrorsFound = true; } if (state.dataGlobal->AnyEnergyManagementSystemInModel) { @@ -517,7 +446,7 @@ namespace IndoorGreen { } switch (ig.lightingMethod) { case LightingMethod::LED: { - ig.ZPPFD = ScheduleManager::GetCurrentScheduleValue(state, ig.SchedLEDPtr) * ig.LEDNominalPPFD; // PPFD + ig.ZPPFD = ig.ledSched->getCurrentVal() * ig.LEDNominalPPFD; // PPFD ig.LEDActualPPFD = ig.LEDNominalPPFD; ig.LEDActualEleP = ig.LEDNominalEleP; ig.LEDActualEleCon = ig.LEDNominalEleP * Timestep; @@ -532,8 +461,9 @@ namespace IndoorGreen { 77; // To be updated currently only take one reference point; 77 conversion factor from Lux to PPFD } } break; + case LightingMethod::LEDDaylighting: { - Real64 a = ScheduleManager::GetCurrentScheduleValue(state, ig.SchedLEDDaylightTargetPtr); + Real64 a = ig.ledDaylightTargetSched->getCurrentVal(); Real64 b = 0; if (!state.dataDayltg->CalcDayltghCoefficients_firstTime && state.dataEnvrn->SunIsUp) { b = state.dataDayltg->daylightControl(ig.LightControlPtr).refPts(1).lums[DataSurfaces::iLum_Illum] / @@ -564,8 +494,7 @@ namespace IndoorGreen { } Real64 effectivearea = std::min(ig.LeafArea, LAI * state.dataSurface->Surface(ig.SurfPtr).Area); ETTotal = - ig.ETRate * Timestep * effectivearea * - ScheduleManager::GetCurrentScheduleValue(state, ig.SchedPtr); // kg; this unit area should be surface area instead of total leaf area + ig.ETRate * Timestep * effectivearea * ig.sched->getCurrentVal(); // kg; this unit area should be surface area instead of total leaf area Real64 hfg = Psychrometrics::PsyHfgAirFnWTdb(ZonePreHum, ZonePreTemp) / std::pow(10, 6); // Latent heat of vaporization (MJ/kg) ig.LambdaET = ETTotal * hfg * std::pow(10, 6) / state.dataSurface->Surface(ig.SurfPtr).Area / Timestep; // (W/m2)) rhoair = Psychrometrics::PsyRhoAirFnPbTdbW(state, state.dataEnvrn->OutBaroPress, ZonePreTemp, ZonePreHum); diff --git a/src/EnergyPlus/IndoorGreen.hh b/src/EnergyPlus/IndoorGreen.hh index 2ab4f914d42..8ae064b58cd 100644 --- a/src/EnergyPlus/IndoorGreen.hh +++ b/src/EnergyPlus/IndoorGreen.hh @@ -81,12 +81,11 @@ namespace IndoorGreen { std::string Name; std::string ZoneName; std::string SurfName; - std::string Schedule; - int SchedPtr = 0; - int SchedLEDPtr = 0; + Sched::Schedule *sched = nullptr; + Sched::Schedule *ledSched = nullptr; int LightRefPtr = 0; // daylight reference point number; int LightControlPtr = 0; // daylight control point number; - int SchedLEDDaylightTargetPtr = 0; // LED-Daylight PPFD setpoint schedule pointer + Sched::Schedule *ledDaylightTargetSched = nullptr; // LED-Daylight PPFD setpoint schedule Real64 LeafArea = 0.0; // one-sided leaf area Real64 LEDNominalPPFD = 0.0; // nominal PPFD for LED grow light (PPFD) Real64 LEDNominalEleP = 0.0; // nominal power for total LED grow light (W) @@ -128,6 +127,10 @@ struct IndoorGreenData : BaseGlobalStruct bool getInputFlag = true; Array1D indoorGreens; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/InputProcessing/InputProcessor.hh b/src/EnergyPlus/InputProcessing/InputProcessor.hh index 548672f99c3..1aafcccb8cb 100644 --- a/src/EnergyPlus/InputProcessing/InputProcessor.hh +++ b/src/EnergyPlus/InputProcessing/InputProcessor.hh @@ -324,6 +324,10 @@ struct DataInputProcessing : BaseGlobalStruct { std::unique_ptr inputProcessor = InputProcessor::factory(); + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/IntegratedHeatPump.hh b/src/EnergyPlus/IntegratedHeatPump.hh index 59ab4dcf512..36287aa9a3f 100644 --- a/src/EnergyPlus/IntegratedHeatPump.hh +++ b/src/EnergyPlus/IntegratedHeatPump.hh @@ -350,6 +350,10 @@ struct IntegratedHeatPumpGlobalData : BaseGlobalStruct bool GetCoilsInputFlag = true; EPVector IntegratedHeatPumps; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/InternalHeatGains.cc b/src/EnergyPlus/InternalHeatGains.cc index b7c816e8803..5964c7dad17 100644 --- a/src/EnergyPlus/InternalHeatGains.cc +++ b/src/EnergyPlus/InternalHeatGains.cc @@ -190,8 +190,6 @@ namespace InternalHeatGains { // ZoneBaseboard:OutdoorTemperatureControlled // Using/Aliasing - using namespace ScheduleManager; - using namespace OutputReportPredefined; using namespace DataLoopNode; using Curve::GetCurveIndex; @@ -199,6 +197,7 @@ namespace InternalHeatGains { // SUBROUTINE PARAMETER DEFINITIONS: static constexpr std::string_view RoutineName("GetInternalHeatGains: "); + static constexpr std::string_view routineName = "GetInternalHeatGains"; // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int IOStat; @@ -320,6 +319,7 @@ namespace InternalHeatGains { IHGAlphaFieldNames, IHGNumericFieldNames); + ErrorObjectHeader eoh{routineName, peopleModuleObject, IHGAlphas(1)}; // Create one People instance for every space associated with this People input object auto &thisPeopleInput = peopleObjects(peopleInputNum); for (int Item1 = 1; Item1 <= thisPeopleInput.numOfSpaces; ++Item1) { @@ -331,61 +331,25 @@ namespace InternalHeatGains { thisPeople.spaceIndex = spaceNum; thisPeople.ZonePtr = zoneNum; - thisPeople.NumberOfPeoplePtr = GetScheduleIndex(state, IHGAlphas(3)); + thisPeople.numberOfPeopleSched = Sched::GetSchedule(state, IHGAlphas(3)); SchMin = 0.0; SchMax = 0.0; - if (thisPeople.NumberOfPeoplePtr == 0) { - if (Item1 == 1) { // only show error on first one - if (IHGAlphaFieldBlanks(3)) { - ShowSevereError( - state, - format("{}{}=\"{}\", {} is required.", RoutineName, peopleModuleObject, IHGAlphas(1), IHGAlphaFieldNames(3))); - } else { - ShowSevereError(state, - format("{}{}=\"{}\", invalid {} entered={}", - RoutineName, - peopleModuleObject, - IHGAlphas(1), - IHGAlphaFieldNames(3), - IHGAlphas(3))); - } + + if (Item1 == 1) { // only show error on first one + if (IHGAlphaFieldBlanks(3)) { + ShowSevereEmptyField(state, eoh, IHGAlphaFieldNames(3)); + ErrorsFound = true; + } else if (thisPeople.numberOfPeopleSched == nullptr) { + ShowSevereItemNotFound(state, eoh, IHGAlphaFieldNames(3), IHGAlphas(3)); + ErrorsFound = true; + } else if (!thisPeople.numberOfPeopleSched->checkMinVal(state, Clusive::In, 0.0)) { + Sched::ShowSevereBadMin(state, eoh, IHGAlphaFieldNames(3), IHGAlphas(3), Clusive::In, 0.0); ErrorsFound = true; - } - } else { // check min/max on schedule - SchMin = GetScheduleMinValue(state, thisPeople.NumberOfPeoplePtr); - SchMax = GetScheduleMaxValue(state, thisPeople.NumberOfPeoplePtr); - if (SchMin < 0.0 || SchMax < 0.0) { - if (Item1 == 1) { - if (SchMin < 0.0) { - ShowSevereError(state, - format("{}{}=\"{}\", {}, minimum is < 0.0", - RoutineName, - peopleModuleObject, - IHGAlphas(1), - IHGAlphaFieldNames(3))); - ShowContinueError(state, - format("Schedule=\"{}\". Minimum is [{:.1R}]. Values must be >= 0.0.", IHGAlphas(3), SchMin)); - ErrorsFound = true; - } - } - if (Item1 == 1) { - if (SchMax < 0.0) { - ShowSevereError(state, - format("{}{}=\"{}\", {}, maximum is < 0.0", - RoutineName, - peopleModuleObject, - IHGAlphas(1), - IHGAlphaFieldNames(3))); - ShowContinueError(state, - format("Schedule=\"{}\". Maximum is [{:.1R}]. Values must be >= 0.0.", IHGAlphas(3), SchMax)); - ErrorsFound = true; - } - } } } // Number of people calculation method. - { + { // Why open a new scope here std::string const &peopleMethod = IHGAlphas(4); if (peopleMethod == "PEOPLE") { // Set space load fraction @@ -561,80 +525,35 @@ namespace InternalHeatGains { ErrorsFound = true; } - thisPeople.ActivityLevelPtr = GetScheduleIndex(state, IHGAlphas(5)); - if (thisPeople.ActivityLevelPtr == 0) { - if (Item1 == 1) { - if (IHGAlphaFieldBlanks(5)) { - ShowSevereError( - state, - format("{}{}=\"{}\", {} is required.", RoutineName, peopleModuleObject, IHGAlphas(1), IHGAlphaFieldNames(5))); - } else { - ShowSevereError(state, - format("{}{}=\"{}\", invalid {} entered={}", - RoutineName, - peopleModuleObject, - IHGAlphas(1), - IHGAlphaFieldNames(5), - IHGAlphas(5))); - } + thisPeople.activityLevelSched = Sched::GetSchedule(state, IHGAlphas(5)); + + if (Item1 == 1) { + if (IHGAlphaFieldBlanks(5)) { + ShowSevereEmptyField(state, eoh, IHGAlphaFieldNames(5)); ErrorsFound = true; - } - } else { // Check values in Schedule - SchMin = GetScheduleMinValue(state, thisPeople.ActivityLevelPtr); - SchMax = GetScheduleMaxValue(state, thisPeople.ActivityLevelPtr); - if (SchMin < 0.0 || SchMax < 0.0) { - if (Item1 == 1) { - if (SchMin < 0.0) { - ShowSevereError(state, - format("{}{}=\"{}\", {} minimum is < 0.0", - RoutineName, - peopleModuleObject, - IHGAlphas(1), - IHGAlphaFieldNames(5))); - ShowContinueError(state, - format("Schedule=\"{}\". Minimum is [{:.1R}]. Values must be >= 0.0.", IHGAlphas(5), SchMin)); - ErrorsFound = true; - } - } - if (Item1 == 1) { - if (SchMax < 0.0) { - ShowSevereError(state, - format("{}{}=\"{}\", {} maximum is < 0.0", - RoutineName, - peopleModuleObject, - IHGAlphas(1), - IHGAlphaFieldNames(5))); - ShowContinueError(state, - format("Schedule=\"{}\". Maximum is [{:.1R}]. Values must be >= 0.0.", IHGAlphas(5), SchMax)); - ErrorsFound = true; - } - } - } else if (SchMin < 70.0 || SchMax > 1000.0) { - if (Item1 == 1) { - ShowWarningError( - state, format("{}{}=\"{}\", {} values", RoutineName, peopleModuleObject, IHGAlphas(1), IHGAlphaFieldNames(5))); - ShowContinueError(state, "fall outside typical range [70,1000] W/person for Thermal Comfort Reporting."); - ShowContinueError(state, format("Odd comfort values may result; Schedule=\"{}\".", IHGAlphas(5))); - ShowContinueError(state, format("Entered min/max range=[{:.1R},] W/person.{:.1R}", SchMin, SchMax)); - } + } else if (thisPeople.activityLevelSched == nullptr) { + ShowSevereItemNotFound(state, eoh, IHGAlphaFieldNames(5), IHGAlphas(5)); + ErrorsFound = true; + } else if (!thisPeople.activityLevelSched->checkMinVal(state, Clusive::In, 0.0)) { + Sched::ShowSevereBadMin(state, eoh, IHGAlphaFieldNames(5), IHGAlphas(5), Clusive::In, 0.0); + ErrorsFound = true; + } else if (!thisPeople.activityLevelSched->checkMinMaxVals(state, Clusive::In, 70.0, Clusive::In, 1000.0)) { + Sched::ShowWarningBadMinMax(state, eoh, IHGAlphaFieldNames(5), IHGAlphas(5), + Clusive::In, 70.0, Clusive::In, 1000.0, + "Values fall outside of typical w/person range for thermal comfort reporting."); } } // Following is an optional parameter (ASHRAE 55 warnings if (IHGNumAlphas >= 6) { - if (Util::SameString(IHGAlphas(6), "Yes")) { - thisPeople.Show55Warning = true; - } else if (!Util::SameString(IHGAlphas(6), "No") && !IHGAlphaFieldBlanks(6)) { + BooleanSwitch bs = getYesNoValue(IHGAlphas(6)); + if (bs == BooleanSwitch::Invalid) { if (Item1 == 1) { - ShowSevereError(state, - format("{}{}=\"{}\", {} field should be Yes or No", - RoutineName, - peopleModuleObject, - IHGAlphas(1), - IHGAlphaFieldNames(6))); - ShowContinueError(state, format("...Field value=\"{}\" is invalid.", IHGAlphas(6))); + ShowSevereInvalidKey(state, eoh, IHGAlphaFieldNames(6), IHGAlphas(6)); ErrorsFound = true; } + } else { + thisPeople.Show55Warning = true; } } @@ -675,7 +594,7 @@ namespace InternalHeatGains { for (int OptionNum = NumFirstTCModel; OptionNum <= lastOption; ++OptionNum) { - { + { // Why are we starting a nested scope immediately after opening up a scope? std::string const &thermalComfortType = IHGAlphas(OptionNum); if (thermalComfortType == "FANGER") { @@ -716,13 +635,7 @@ namespace InternalHeatGains { } else { // An invalid keyword was entered--warn but ignore if (Item1 == 1) { - ShowWarningError(state, - format("{}{}=\"{}\", invalid {} Option={}", - RoutineName, - peopleModuleObject, - IHGAlphas(1), - IHGAlphaFieldNames(OptionNum), - IHGAlphas(OptionNum))); + ShowWarningInvalidKey(state, eoh, IHGAlphaFieldNames(OptionNum), IHGAlphas(OptionNum), ""); ShowContinueError(state, "Valid Values are \"Fanger\", \"Pierce\", \"KSU\", \"AdaptiveASH55\", " "\"AdaptiveCEN15251\", \"CoolingEffectASH55\", \"AnkleDraftASH55\""); @@ -797,297 +710,125 @@ namespace InternalHeatGains { ShowContinueError(state, "...Valid values are \"EnclosureAveraged\", \"SurfaceWeighted\", \"AngleFactor\"."); } } break; - } + } // switch (thisPeople.MRTCalcType) if (!IHGAlphaFieldBlanks(9)) { - thisPeople.WorkEffPtr = GetScheduleIndex(state, IHGAlphas(9)); - if (thisPeople.WorkEffPtr == 0) { - if (Item1 == 1) { - ShowSevereError(state, - format("{}{}=\"{}\", invalid {} entered={}", - RoutineName, - peopleModuleObject, - IHGAlphas(1), - IHGAlphaFieldNames(9), - IHGAlphas(9))); + thisPeople.workEffSched = Sched::GetSchedule(state, IHGAlphas(9)); + } + + if (Item1 == 1) { + if (IHGAlphaFieldBlanks(9)) { + if (ModelWithAdditionalInputs) { + ShowSevereEmptyField(state, eoh, IHGAlphaFieldNames(9)); + ShowContinueError(state, "It is required when Thermal Comfort Model Type is one of " + "\"Fanger\", \"Pierce\", \"KSU\", \"CoolingEffectASH55\" or \"AnkleDraftASH55\""); ErrorsFound = true; } - } else { // check min/max on schedule - SchMin = GetScheduleMinValue(state, thisPeople.WorkEffPtr); - SchMax = GetScheduleMaxValue(state, thisPeople.WorkEffPtr); - if (SchMin < 0.0 || SchMax < 0.0) { - if (SchMin < 0.0) { - if (Item1 == 1) { - ShowSevereError(state, - format("{}{}=\"{}\", {}, minimum is < 0.0", - RoutineName, - peopleModuleObject, - IHGAlphas(1), - IHGAlphaFieldNames(9))); - ShowContinueError( - state, - format("Schedule=\"{}\". Minimum is [{:.1R}]. Values must be >= 0.0.", IHGAlphas(9), SchMin)); - ErrorsFound = true; - } - } - if (SchMax < 0.0) { - if (Item1 == 1) { - ShowSevereError(state, - format("{}{}=\"{}\", {}, maximum is < 0.0", - RoutineName, - peopleModuleObject, - IHGAlphas(1), - IHGAlphaFieldNames(9))); - ShowContinueError( - state, - format("Schedule=\"{}\". Maximum is [{:.1R}]. Values must be >= 0.0.", IHGAlphas(9), SchMax)); - ErrorsFound = true; - } - } - } - if (SchMax > 1.0) { - if (Item1 == 1) { - ShowWarningError(state, - format("{}{}=\"{}\", {}, maximum is > 1.0", - RoutineName, - peopleModuleObject, - IHGAlphas(1), - IHGAlphaFieldNames(9))); - ShowContinueError(state, - format("Schedule=\"{}\"; Entered min/max range=[{:.1R},{:.1R}] Work Efficiency.", - IHGAlphas(9), - SchMin, - SchMax)); - } - } - } - } else if (ModelWithAdditionalInputs) { - if (Item1 == 1) { - ShowSevereError(state, - format("{}{}=\"{}\", blank {}. {} is required when Thermal Comfort Model Type is one of " - "\"Fanger\", \"Pierce\", \"KSU\", \"CoolingEffectASH55\" or \"AnkleDraftASH55\"", - RoutineName, - peopleModuleObject, - IHGAlphas(1), - IHGAlphaFieldNames(9), - IHGAlphaFieldNames(9))); - ErrorsFound = true; + } else if (thisPeople.workEffSched == nullptr) { + ShowSevereItemNotFound(state, eoh, IHGAlphaFieldNames(9), IHGAlphas(9)); + ErrorsFound = true; + } else if (!thisPeople.workEffSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) { + Sched::ShowSevereBadMinMax(state, eoh, IHGAlphaFieldNames(9), IHGAlphas(9), + Clusive::In, 0.0, Clusive::In, 1.0); + ErrorsFound = true; } } - if (!IHGAlphaFieldBlanks(10) || !IHGAlphas(10).empty()) { - thisPeople.clothingType = static_cast(getEnumValue(clothingTypeNamesUC, IHGAlphas(10))); - if (thisPeople.clothingType == ClothingType::Invalid) { - ShowSevereError(state, - format("{}{}=\"{}\", invalid {}, value ={}", - RoutineName, - peopleModuleObject, - thisPeople.Name, - IHGAlphaFieldNames(10), - IHGAlphas(10))); - ShowContinueError(state, - format(R"(...Valid values are "{}", "{}", "{}")", - clothingTypeNamesUC[0], - clothingTypeNamesUC[1], - clothingTypeNamesUC[2])); - ErrorsFound = true; - } + if (IHGAlphaFieldBlanks(10)) { + } else if ((thisPeople.clothingType = static_cast(getEnumValue(clothingTypeNamesUC, IHGAlphas(10)))) == + ClothingType::Invalid) { + ShowSevereInvalidKey(state, eoh, IHGAlphaFieldNames(10), IHGAlphas(10)); + ErrorsFound = true; + } else { + switch (thisPeople.clothingType) { - case ClothingType::InsulationSchedule: - thisPeople.clothingType = ClothingType::InsulationSchedule; - thisPeople.ClothingPtr = GetScheduleIndex(state, IHGAlphas(12)); - if (thisPeople.ClothingPtr == 0 && ModelWithAdditionalInputs) { - if (Item1 == 1) { - ShowSevereError(state, - format("{}{}=\"{}\", invalid {} entered=\"{}\".", - RoutineName, - peopleModuleObject, - IHGAlphas(1), - IHGAlphaFieldNames(12), - IHGAlphas(12))); + + case ClothingType::InsulationSchedule: { + + thisPeople.clothingSched = Sched::GetSchedule(state, IHGAlphas(12)); + if (Item1 == 1) { + if (IHGAlphaFieldBlanks(12)) { + ShowSevereEmptyField(state, eoh, IHGAlphaFieldNames(12), IHGAlphaFieldNames(10), IHGAlphas(10)); ErrorsFound = true; - } - } else { // check min/max on schedule - SchMin = GetScheduleMinValue(state, thisPeople.ClothingPtr); - SchMax = GetScheduleMaxValue(state, thisPeople.ClothingPtr); - if (SchMin < 0.0 || SchMax < 0.0) { - if (SchMin < 0.0) { - if (Item1 == 1) { - ShowSevereError(state, - format("{}{}=\"{}\", {}, minimum is < 0.0", - RoutineName, - peopleModuleObject, - IHGAlphas(1), - IHGAlphaFieldNames(12))); - ShowContinueError(state, - format("Schedule=\"{}\". Minimum is [{:.1R}]. Values must be >= 0.0.", - IHGAlphas(12), - SchMin)); - ErrorsFound = true; - } - } - if (SchMax < 0.0) { - if (Item1 == 1) { - ShowSevereError(state, - format("{}{}=\"{}\", {}, maximum is < 0.0", - RoutineName, - peopleModuleObject, - IHGAlphas(1), - IHGAlphaFieldNames(12))); - ShowContinueError(state, - format("Schedule=\"{}\". Maximum is [{:.1R}]. Values must be >= 0.0.", - IHGAlphas(12), - SchMax)); - ErrorsFound = true; - } - } - } - if (SchMax > 2.0) { - if (Item1 == 1) { - ShowWarningError(state, - format("{}{}=\"{}\", {}, maximum is > 2.0", - RoutineName, - peopleModuleObject, - IHGAlphas(1), - IHGAlphaFieldNames(12))); - ShowContinueError(state, - format("Schedule=\"{}\"; Entered min/max range=[{:.1R},{:.1R}] Clothing.", - IHGAlphas(12), - SchMin, - SchMax)); - } + } else if (thisPeople.clothingSched == nullptr) { + ShowSevereItemNotFound(state, eoh, IHGAlphaFieldNames(12), IHGAlphas(12)); + ErrorsFound = true; + } else if (!thisPeople.clothingSched->checkMinVal(state, Clusive::In, 0.0)) { + Sched::ShowSevereBadMin(state, eoh, IHGAlphaFieldNames(12), IHGAlphas(12), Clusive::In, 0.0); + ErrorsFound = true; + } else if (!thisPeople.clothingSched->checkMaxVal(state, Clusive::In, 2.0)) { + Sched::ShowWarningBadMax(state, eoh, IHGAlphaFieldNames(12), IHGAlphas(12), Clusive::In, 2.0, ""); } } - break; - - case ClothingType::DynamicAshrae55: - break; // nothing extra to do, at least for now - - case ClothingType::CalculationSchedule: - thisPeople.ClothingMethodPtr = GetScheduleIndex(state, IHGAlphas(11)); - if (thisPeople.ClothingMethodPtr == 0) { - if (Item1 == 1) { - ShowSevereError(state, - format("{}{}=\"{}\", invalid {} entered=\"{}\".", - RoutineName, - peopleModuleObject, - IHGAlphas(1), - IHGAlphaFieldNames(11), - IHGAlphas(11))); + } break; + + case ClothingType::DynamicAshrae55: { + } break; // nothing extra to do, at least for now + + case ClothingType::CalculationSchedule: { + thisPeople.clothingMethodSched = Sched::GetSchedule(state, IHGAlphas(11)); + + if (Item1 == 1) { + if (thisPeople.clothingMethodSched == nullptr) { + ShowSevereItemNotFound(state, eoh, IHGAlphaFieldNames(11), IHGAlphas(11)); ErrorsFound = true; } } - if (CheckScheduleValue(state, thisPeople.ClothingMethodPtr, 1)) { - thisPeople.ClothingPtr = GetScheduleIndex(state, IHGAlphas(12)); - if (thisPeople.ClothingPtr == 0) { + + if (thisPeople.clothingMethodSched->hasVal(state, 1)) { + if ((thisPeople.clothingSched = Sched::GetSchedule(state, IHGAlphas(12))) == nullptr) { if (Item1 == 1) { - ShowSevereError(state, - format("{}{}=\"{}\", invalid {} entered=\"{}\".", - RoutineName, - peopleModuleObject, - IHGAlphas(1), - IHGAlphaFieldNames(12), - IHGAlphas(12))); + ShowSevereItemNotFound(state, eoh, IHGAlphaFieldNames(12), IHGAlphas(12)); ErrorsFound = true; } } } - break; - default: - break; // nothing to do for the other cases - } + } break; + + default: { + } break; // nothing to do for the other cases + } // switch (thisPeople.clothingType) } + if (!IHGAlphaFieldBlanks(13)) { - thisPeople.AirVelocityPtr = GetScheduleIndex(state, IHGAlphas(13)); - if (thisPeople.AirVelocityPtr == 0) { - if (Item1 == 1) { - ShowSevereError(state, - format("{}{}=\"{}\", invalid {} entered=\"{}\".", - RoutineName, - peopleModuleObject, - IHGAlphas(1), - IHGAlphaFieldNames(13), - IHGAlphas(13))); + thisPeople.airVelocitySched = Sched::GetSchedule(state, IHGAlphas(13)); + } + + if (Item1 == 1) { + if (IHGAlphaFieldBlanks(13)) { + if (ModelWithAdditionalInputs) { + ShowSevereEmptyField(state, eoh, IHGAlphaFieldNames(13)); + ShowContinueError(state, "Required when Thermal Comfort Model Type is one of " + "\"Fanger\", \"Pierce\", \"KSU\", \"CoolingEffectASH55\" or \"AnkleDraftASH55\""); ErrorsFound = true; } - } else { // check min/max on schedule - SchMin = GetScheduleMinValue(state, thisPeople.AirVelocityPtr); - SchMax = GetScheduleMaxValue(state, thisPeople.AirVelocityPtr); - if (SchMin < 0.0 || SchMax < 0.0) { - if (SchMin < 0.0) { - if (Item1 == 1) { - ShowSevereError(state, - format("{}{}=\"{}\", {}, minimum is < 0.0", - RoutineName, - peopleModuleObject, - IHGAlphas(1), - IHGAlphaFieldNames(13))); - ShowContinueError( - state, - format("Schedule=\"{}\". Minimum is [{:.1R}]. Values must be >= 0.0.", IHGAlphas(13), SchMin)); - ErrorsFound = true; - } - } - if (SchMax < 0.0) { - if (Item1 == 1) { - ShowSevereError(state, - format("{}{}=\"{}\", {}, maximum is < 0.0", - RoutineName, - peopleModuleObject, - IHGAlphas(1), - IHGAlphaFieldNames(13))); - ShowContinueError( - state, - format("Schedule=\"{}\". Maximum is [{:.1R}]. Values must be >= 0.0.", IHGAlphas(13), SchMax)); - ErrorsFound = true; - } - } - } - } - } else if (ModelWithAdditionalInputs) { - if (Item1 == 1) { - ShowSevereError(state, - format("{}{}=\"{}\", blank {}. {} is required when Thermal Comfort Model Type is one of " - "\"Fanger\", \"Pierce\", \"KSU\", \"CoolingEffectASH55\" or \"AnkleDraftASH55\"", - RoutineName, - peopleModuleObject, - IHGAlphas(1), - IHGAlphaFieldNames(13), - IHGAlphaFieldNames(13))); + } else if (thisPeople.airVelocitySched == nullptr) { + ShowSevereItemNotFound(state, eoh, IHGAlphaFieldNames(13), IHGAlphas(13)); + ErrorsFound = true; + } else if (!thisPeople.airVelocitySched->checkMinVal(state, Clusive::In, 0.0)) { + Sched::ShowSevereBadMin(state, eoh, IHGAlphaFieldNames(13), IHGAlphas(13), Clusive::In, 0.0); ErrorsFound = true; } } + + if (!IHGAlphaFieldBlanks(21)) { + thisPeople.ankleAirVelocitySched = Sched::GetSchedule(state, IHGAlphas(21)); + } - int indexAnkleAirVelPtr = 21; - if (!IHGAlphaFieldBlanks(indexAnkleAirVelPtr) || !IHGAlphas(indexAnkleAirVelPtr).empty()) { - thisPeople.AnkleAirVelocityPtr = GetScheduleIndex(state, IHGAlphas(indexAnkleAirVelPtr)); - if (thisPeople.AnkleAirVelocityPtr == 0) { - if (Item1 == 1) { - ShowSevereError(state, - format("{}{}=\"{}\", invalid {} entered=\"{}\".", - RoutineName, - peopleModuleObject, - IHGAlphas(1), - IHGAlphaFieldNames(indexAnkleAirVelPtr), - IHGAlphas(indexAnkleAirVelPtr))); + if (Item1 == 1) { + if (IHGAlphaFieldBlanks(21)) { + if (thisPeople.AnkleDraftASH55) { + ShowSevereEmptyField(state, eoh, IHGAlphaFieldNames(21), IHGAlphas(21)); + ShowContinueError(state, "Required when Thermal Comfort Model Type is one of " + "\"Fanger\", \"Pierce\", \"KSU\", \"CoolingEffectASH55\" or \"AnkleDraftASH55\""); ErrorsFound = true; } - } - } else if (thisPeople.AnkleDraftASH55) { - if (Item1 == 1) { - ShowSevereError(state, - format("{}{}=\"{}\", blank {}. {} is required when Thermal Comfort Model Type is one of " - "\"Fanger\", \"Pierce\", \"KSU\", \"CoolingEffectASH55\" or \"AnkleDraftASH55\"", - RoutineName, - peopleModuleObject, - IHGAlphas(1), - IHGAlphaFieldNames(indexAnkleAirVelPtr), - IHGAlphaFieldNames(indexAnkleAirVelPtr))); + } else if (thisPeople.ankleAirVelocitySched == nullptr) { + ShowSevereItemNotFound(state, eoh, IHGAlphaFieldNames(21), IHGAlphas(21)); ErrorsFound = true; } } - } // usingthermalcomfort block } // ...end of thermal comfort data IF-THEN block (IHGNumAlphass > 6) @@ -1095,7 +836,7 @@ namespace InternalHeatGains { if (thisPeople.ZonePtr <= 0) continue; // Error, will be caught and terminated later } } - + for (int peopleNum = 1; peopleNum <= state.dataHeatBal->TotPeople; ++peopleNum) { if (state.dataGlobal->AnyEnergyManagementSystemInModel) { SetupEMSActuator(state, @@ -1148,9 +889,9 @@ namespace InternalHeatGains { int OptionNum = 0; for (int Loop1 = 1; Loop1 <= state.dataHeatBal->TotPeople; ++Loop1) { if (state.dataHeatBal->People(Loop1).ZonePtr != Loop) continue; - if (maxOccupLoad < GetScheduleMaxValue(state, state.dataHeatBal->People(Loop1).NumberOfPeoplePtr) * + if (maxOccupLoad < state.dataHeatBal->People(Loop1).numberOfPeopleSched->getCurrentVal() * state.dataHeatBal->People(Loop1).NumberOfPeople) { - maxOccupLoad = GetScheduleMaxValue(state, state.dataHeatBal->People(Loop1).NumberOfPeoplePtr) * + maxOccupLoad = state.dataHeatBal->People(Loop1).numberOfPeopleSched->getCurrentVal() * state.dataHeatBal->People(Loop1).NumberOfPeople; OptionNum = Loop1; } @@ -1171,7 +912,7 @@ namespace InternalHeatGains { ShowContinueError(state, format("Check values in People={}, Number of People Schedule={}", state.dataHeatBal->People(OptionNum).Name, - GetScheduleName(state, state.dataHeatBal->People(OptionNum).NumberOfPeoplePtr))); + state.dataHeatBal->People(OptionNum).numberOfPeopleSched->getCurrentVal())); } } } @@ -1217,8 +958,11 @@ namespace InternalHeatGains { IHGAlphaFieldNames, IHGNumericFieldNames); + ErrorObjectHeader eoh{routineName, lightsModuleObject, IHGAlphas(1)}; + auto &thisLightsInput = state.dataInternalHeatGains->lightsObjects(lightsInputNum); // Create one Lights instance for every space associated with this Lights input object + // Why? Why can't multple spaces share a single lights instance? for (int Item1 = 1; Item1 <= thisLightsInput.numOfSpaces; ++Item1) { ++lightsNum; auto &thisLights = state.dataHeatBal->Lights(lightsNum); @@ -1228,56 +972,20 @@ namespace InternalHeatGains { thisLights.spaceIndex = spaceNum; thisLights.ZonePtr = zoneNum; - thisLights.SchedPtr = GetScheduleIndex(state, IHGAlphas(3)); - SchMin = 0.0; - SchMax = 0.0; - if (thisLights.SchedPtr == 0) { - if (Item1 == 1) { - if (IHGAlphaFieldBlanks(3)) { - ShowSevereError( - state, - format("{}{}=\"{}\", {} is required.", RoutineName, lightsModuleObject, IHGAlphas(1), IHGAlphaFieldNames(3))); - } else { - ShowSevereError(state, - format("{}{}=\"{}\", invalid {} entered={}", - RoutineName, - lightsModuleObject, - IHGAlphas(1), - IHGAlphaFieldNames(3), - IHGAlphas(3))); - } + if (!IHGAlphaFieldBlanks(3)) { + thisLights.sched = Sched::GetSchedule(state, IHGAlphas(3)); + } + + if (Item1 == 1) { + if (IHGAlphaFieldBlanks(3)) { + ShowSevereEmptyField(state, eoh, IHGAlphaFieldNames(3)); + ErrorsFound = true; + } else if (thisLights.sched == nullptr) { + ShowSevereItemNotFound(state, eoh,IHGAlphaFieldNames(3), IHGAlphas(3)); + ErrorsFound = true; + } else if (!thisLights.sched->checkMinVal(state, Clusive::In, 0.0)) { + Sched::ShowSevereBadMin(state, eoh, IHGAlphaFieldNames(3), IHGAlphas(3), Clusive::In, 0.0); ErrorsFound = true; - } - } else { // check min/max on schedule - SchMin = GetScheduleMinValue(state, thisLights.SchedPtr); - SchMax = GetScheduleMaxValue(state, thisLights.SchedPtr); - if (SchMin < 0.0 || SchMax < 0.0) { - if (Item1 == 1) { - if (SchMin < 0.0) { - ShowSevereError(state, - format("{}{}=\"{}\", {}, minimum is < 0.0", - RoutineName, - lightsModuleObject, - IHGAlphas(1), - IHGAlphaFieldNames(3))); - ShowContinueError(state, - format("Schedule=\"{}\". Minimum is [{:.1R}]. Values must be >= 0.0.", IHGAlphas(3), SchMin)); - ErrorsFound = true; - } - } - if (Item1 == 1) { - if (SchMax < 0.0) { - ShowSevereError(state, - format("{}{}=\"{}\", {}, maximum is < 0.0", - RoutineName, - lightsModuleObject, - IHGAlphas(1), - IHGAlphaFieldNames(3))); - ShowContinueError(state, - format("Schedule=\"{}\". Maximum is [{:.1R}]. Values must be >= 0.0.", IHGAlphas(3), SchMax)); - ErrorsFound = true; - } - } } } @@ -1591,7 +1299,7 @@ namespace InternalHeatGains { PreDefTableEntry(state, state.dataOutRptPredefined->pdchInLtPower, liteName, state.dataHeatBal->Lights(lightsNum).DesignLevel * mult); PreDefTableEntry(state, state.dataOutRptPredefined->pdchInLtEndUse, liteName, state.dataHeatBal->Lights(lightsNum).EndUseSubcategory); PreDefTableEntry( - state, state.dataOutRptPredefined->pdchInLtSchd, liteName, GetScheduleName(state, state.dataHeatBal->Lights(lightsNum).SchedPtr)); + state, state.dataOutRptPredefined->pdchInLtSchd, liteName, state.dataHeatBal->Lights(lightsNum).sched->Name); PreDefTableEntry( state, state.dataOutRptPredefined->pdchInLtRetAir, liteName, state.dataHeatBal->Lights(lightsNum).FractionReturnAir, 4); } // Item1 - Number of Lights instances @@ -1668,6 +1376,8 @@ namespace InternalHeatGains { IHGAlphaFieldNames, IHGNumericFieldNames); + ErrorObjectHeader eoh{routineName, elecEqModuleObject, IHGAlphas(1)}; + auto &thisElecEqInput = state.dataInternalHeatGains->zoneElectricObjects(elecEqInputNum); for (int Item1 = 1; Item1 <= thisElecEqInput.numOfSpaces; ++Item1) { ++elecEqNum; @@ -1678,46 +1388,17 @@ namespace InternalHeatGains { thisZoneElectric.spaceIndex = spaceNum; thisZoneElectric.ZonePtr = zoneNum; - thisZoneElectric.SchedPtr = GetScheduleIndex(state, IHGAlphas(3)); - SchMin = 0.0; - SchMax = 0.0; - if (thisZoneElectric.SchedPtr == 0) { - if (IHGAlphaFieldBlanks(3)) { - ShowSevereError( - state, format("{}{}=\"{}\", {} is required.", RoutineName, elecEqModuleObject, IHGAlphas(1), IHGAlphaFieldNames(3))); - } else { - ShowSevereError(state, - format("{}{}=\"{}\", invalid {} entered={}", - RoutineName, - elecEqModuleObject, - IHGAlphas(1), - IHGAlphaFieldNames(3), - IHGAlphas(3))); - } + // Why are error messages not guarded by (Item1 == 1) checks for equipment? + + if (IHGAlphaFieldBlanks(3)) { + ShowSevereEmptyField(state, eoh, IHGAlphaFieldNames(3)); + ErrorsFound = true; + } else if ((thisZoneElectric.sched = Sched::GetSchedule(state, IHGAlphas(3))) == nullptr) { + ShowSevereItemNotFound(state, eoh, IHGAlphaFieldNames(3), IHGAlphas(3)); + ErrorsFound = true; + } else if (!thisZoneElectric.sched->checkMinVal(state, Clusive::In, 0.0)) { + Sched::ShowSevereBadMin(state, eoh, IHGAlphaFieldNames(3), IHGAlphas(3), Clusive::In, 0.0); ErrorsFound = true; - } else { // check min/max on schedule - SchMin = GetScheduleMinValue(state, thisZoneElectric.SchedPtr); - SchMax = GetScheduleMaxValue(state, thisZoneElectric.SchedPtr); - if (SchMin < 0.0 || SchMax < 0.0) { - if (SchMin < 0.0) { - ShowSevereError( - state, - format( - "{}{}=\"{}\", {}, minimum is < 0.0", RoutineName, elecEqModuleObject, IHGAlphas(1), IHGAlphaFieldNames(3))); - ShowContinueError(state, - format("Schedule=\"{}\". Minimum is [{:.1R}]. Values must be >= 0.0.", IHGAlphas(3), SchMin)); - ErrorsFound = true; - } - if (SchMax < 0.0) { - ShowSevereError( - state, - format( - "{}{}=\"{}\", {}, maximum is < 0.0", RoutineName, elecEqModuleObject, IHGAlphas(1), IHGAlphaFieldNames(3))); - ShowContinueError(state, - format("Schedule=\"{}\". Maximum is [{:.1R}]. Values must be >= 0.0.", IHGAlphas(3), SchMax)); - ErrorsFound = true; - } - } } // Electric equipment design level calculation method. @@ -1900,6 +1581,8 @@ namespace InternalHeatGains { IHGAlphaFieldNames, IHGNumericFieldNames); + ErrorObjectHeader eoh{routineName, gasEqModuleObject, IHGAlphas(1)}; + auto &thisGasEqInput = zoneGasObjects(gasEqInputNum); for (int Item1 = 1; Item1 <= thisGasEqInput.numOfSpaces; ++Item1) { ++gasEqNum; @@ -1910,57 +1593,21 @@ namespace InternalHeatGains { thisZoneGas.spaceIndex = spaceNum; thisZoneGas.ZonePtr = zoneNum; - thisZoneGas.SchedPtr = GetScheduleIndex(state, IHGAlphas(3)); - SchMin = 0.0; - SchMax = 0.0; - if (thisZoneGas.SchedPtr == 0) { - if (Item1 == 1) { - if (IHGAlphaFieldBlanks(3)) { - ShowSevereError( - state, - format( - "{}{}=\"{}\", {} is required.", RoutineName, gasEqModuleObject, thisGasEqInput.Name, IHGAlphaFieldNames(3))); - } else { - ShowSevereError(state, - format("{}{}=\"{}\", invalid {} entered={}", - RoutineName, - gasEqModuleObject, - thisGasEqInput.Name, - IHGAlphaFieldNames(3), - IHGAlphas(3))); - } + if (!IHGAlphaFieldBlanks(3)) { + thisZoneGas.sched = Sched::GetSchedule(state, IHGAlphas(3)); + } + + // And here for gas, we are guarding with (Item1 == 1) again + if (Item1 == 1) { + if (IHGAlphaFieldBlanks(3)) { + ShowSevereEmptyField(state, eoh, IHGAlphaFieldNames(3)); + ErrorsFound = true; + } else if (thisZoneGas.sched == nullptr) { + ShowSevereItemNotFound(state, eoh, IHGAlphaFieldNames(3), IHGAlphas(3)); + ErrorsFound = true; + } else if (!thisZoneGas.sched->checkMinVal(state, Clusive::In, 0.0)) { + Sched::ShowSevereBadMin(state, eoh, IHGAlphaFieldNames(3), IHGAlphas(3), Clusive::In, 0.0); ErrorsFound = true; - } - } else { // check min/max on schedule - SchMin = GetScheduleMinValue(state, thisZoneGas.SchedPtr); - SchMax = GetScheduleMaxValue(state, thisZoneGas.SchedPtr); - if (SchMin < 0.0 || SchMax < 0.0) { - if (Item1 == 1) { - if (SchMin < 0.0) { - ShowSevereError(state, - format("{}{}=\"{}\", {}, minimum is < 0.0", - RoutineName, - gasEqModuleObject, - thisGasEqInput.Name, - IHGAlphaFieldNames(3))); - ShowContinueError(state, - format("Schedule=\"{}\". Minimum is [{:.1R}]. Values must be >= 0.0.", IHGAlphas(3), SchMin)); - ErrorsFound = true; - } - } - if (Item1 == 1) { - if (SchMax < 0.0) { - ShowSevereError(state, - format("{}{}=\"{}\", {}, maximum is < 0.0", - RoutineName, - gasEqModuleObject, - thisGasEqInput.Name, - IHGAlphaFieldNames(3))); - ShowContinueError(state, - format("Schedule=\"{}\". Maximum is [{:.1R}]. Values must be >= 0.0.", IHGAlphas(3), SchMax)); - ErrorsFound = true; - } - } } } @@ -2059,14 +1706,7 @@ namespace InternalHeatGains { } else { if (Item1 == 1) { - ShowSevereError(state, - format("{}{}=\"{}\", invalid {}, value ={}", - RoutineName, - gasEqModuleObject, - thisGasEqInput.Name, - IHGAlphaFieldNames(4), - IHGAlphas(4))); - ShowContinueError(state, "...Valid values are \"EquipmentLevel\", \"Watts/Area\", \"Watts/Person\"."); + ShowSevereInvalidKey(state, eoh, IHGAlphaFieldNames(4), IHGAlphas(4)); ErrorsFound = true; } } @@ -2171,6 +1811,8 @@ namespace InternalHeatGains { IHGAlphaFieldNames, IHGNumericFieldNames); + ErrorObjectHeader eoh{routineName, hwEqModuleObject, IHGAlphas(1)}; + auto &thisHWEqInput = hotWaterEqObjects(hwEqInputNum); for (int Item1 = 1; Item1 <= thisHWEqInput.numOfSpaces; ++Item1) { ++hwEqNum; @@ -2181,51 +1823,15 @@ namespace InternalHeatGains { thisZoneHWEq.spaceIndex = spaceNum; thisZoneHWEq.ZonePtr = zoneNum; - thisZoneHWEq.SchedPtr = GetScheduleIndex(state, IHGAlphas(3)); - SchMin = 0.0; - SchMax = 0.0; - if (thisZoneHWEq.SchedPtr == 0) { - if (IHGAlphaFieldBlanks(3)) { - ShowSevereError( - state, - format("{}{}=\"{}\", {} is required.", RoutineName, hwEqModuleObject, thisHWEqInput.Name, IHGAlphaFieldNames(3))); - } else { - ShowSevereError(state, - format("{}{}=\"{}\", invalid {} entered={}", - RoutineName, - hwEqModuleObject, - thisHWEqInput.Name, - IHGAlphaFieldNames(3), - IHGAlphas(3))); - } + if (IHGAlphaFieldBlanks(3)) { + ShowSevereEmptyField(state, eoh, IHGAlphaFieldNames(3)); + ErrorsFound = true; + } else if ((thisZoneHWEq.sched = Sched::GetSchedule(state, IHGAlphas(3))) == nullptr) { + ShowSevereItemNotFound(state, eoh, IHGAlphaFieldNames(3), IHGAlphas(3)); + ErrorsFound = true; + } else if (!thisZoneHWEq.sched->checkMinVal(state, Clusive::In, 0.0)) { + Sched::ShowSevereBadMin(state, eoh, IHGAlphaFieldNames(3), IHGAlphas(3), Clusive::In, 0.0); ErrorsFound = true; - } else { // check min/max on schedule - SchMin = GetScheduleMinValue(state, thisZoneHWEq.SchedPtr); - SchMax = GetScheduleMaxValue(state, thisZoneHWEq.SchedPtr); - if (SchMin < 0.0 || SchMax < 0.0) { - if (SchMin < 0.0) { - ShowSevereError(state, - format("{}{}=\"{}\", {}, minimum is < 0.0", - RoutineName, - hwEqModuleObject, - thisHWEqInput.Name, - IHGAlphaFieldNames(3))); - ShowContinueError(state, - format("Schedule=\"{}\". Minimum is [{:.1R}]. Values must be >= 0.0.", IHGAlphas(3), SchMin)); - ErrorsFound = true; - } - if (SchMax < 0.0) { - ShowSevereError(state, - format("{}{}=\"{}\", {}, maximum is < 0.0", - RoutineName, - hwEqModuleObject, - thisHWEqInput.Name, - IHGAlphaFieldNames(3))); - ShowContinueError(state, - format("Schedule=\"{}\". Maximum is [{:.1R}]. Values must be >= 0.0.", IHGAlphas(3), SchMax)); - ErrorsFound = true; - } - } } // Hot Water equipment design level calculation method. @@ -2407,6 +2013,8 @@ namespace InternalHeatGains { IHGAlphaFieldNames, IHGNumericFieldNames); + ErrorObjectHeader eoh{routineName, stmEqModuleObject, IHGAlphas(1)}; + auto &thisStmEqInput = steamEqObjects(stmEqInputNum); for (int Item1 = 1; Item1 <= thisStmEqInput.numOfSpaces; ++Item1) { ++stmEqNum; @@ -2417,51 +2025,15 @@ namespace InternalHeatGains { thisZoneStmEq.spaceIndex = spaceNum; thisZoneStmEq.ZonePtr = zoneNum; - thisZoneStmEq.SchedPtr = GetScheduleIndex(state, IHGAlphas(3)); - SchMin = 0.0; - SchMax = 0.0; - if (thisZoneStmEq.SchedPtr == 0) { - if (IHGAlphaFieldBlanks(3)) { - ShowSevereError( - state, - format("{}{}=\"{}\", {} is required.", RoutineName, stmEqModuleObject, thisStmEqInput.Name, IHGAlphaFieldNames(3))); - } else { - ShowSevereError(state, - format("{}{}=\"{}\", invalid {} entered={}", - RoutineName, - stmEqModuleObject, - thisStmEqInput.Name, - IHGAlphaFieldNames(3), - IHGAlphas(3))); - } + if (IHGAlphaFieldBlanks(3)) { + ShowSevereEmptyField(state, eoh, IHGAlphaFieldNames(3)); + ErrorsFound = true; + } else if ((thisZoneStmEq.sched = Sched::GetSchedule(state, IHGAlphas(3))) == nullptr) { + ShowSevereItemNotFound(state, eoh, IHGAlphaFieldNames(3), IHGAlphas(3)); + ErrorsFound = true; + } else if (!thisZoneStmEq.sched->checkMinVal(state, Clusive::In, 0.0)) { + Sched::ShowSevereBadMin(state, eoh, IHGAlphaFieldNames(3), IHGAlphas(3), Clusive::In, 0.0); ErrorsFound = true; - } else { // check min/max on schedule - SchMin = GetScheduleMinValue(state, thisZoneStmEq.SchedPtr); - SchMax = GetScheduleMaxValue(state, thisZoneStmEq.SchedPtr); - if (SchMin < 0.0 || SchMax < 0.0) { - if (SchMin < 0.0) { - ShowSevereError(state, - format("{}{}=\"{}\", {}, minimum is < 0.0", - RoutineName, - stmEqModuleObject, - thisStmEqInput.Name, - IHGAlphaFieldNames(3))); - ShowContinueError(state, - format("Schedule=\"{}\". Minimum is [{:.1R}]. Values must be >= 0.0.", IHGAlphas(3), SchMin)); - ErrorsFound = true; - } - if (SchMax < 0.0) { - ShowSevereError(state, - format("{}{}=\"{}\", {}, maximum is < 0.0", - RoutineName, - stmEqModuleObject, - thisStmEqInput.Name, - IHGAlphaFieldNames(3))); - ShowContinueError(state, - format("Schedule=\"{}\". Maximum is [{:.1R}]. Values must be >= 0.0.", IHGAlphas(3), SchMax)); - ErrorsFound = true; - } - } } // Steam equipment design level calculation method. @@ -2647,6 +2219,8 @@ namespace InternalHeatGains { IHGAlphaFieldNames, IHGNumericFieldNames); + ErrorObjectHeader eoh{routineName, othEqModuleObject, IHGAlphas(1)}; + auto &thisOthEqInput = otherEqObjects(othEqInputNum); for (int Item1 = 1; Item1 <= thisOthEqInput.numOfSpaces; ++Item1) { ++othEqNum; @@ -2700,29 +2274,17 @@ namespace InternalHeatGains { } } - thisZoneOthEq.SchedPtr = GetScheduleIndex(state, IHGAlphas(4)); - SchMin = 0.0; - SchMax = 0.0; - if (thisZoneOthEq.SchedPtr == 0) { - if (IHGAlphaFieldBlanks(4)) { - ShowSevereError( - state, - format("{}{}=\"{}\", {} is required.", RoutineName, othEqModuleObject, thisOthEqInput.Name, IHGAlphaFieldNames(4))); - } else { - ShowSevereError(state, - format("{}{}=\"{}\", invalid {} entered={}", - RoutineName, - othEqModuleObject, - thisOthEqInput.Name, - IHGAlphaFieldNames(4), - IHGAlphas(4))); - } + if (IHGAlphaFieldBlanks(4)) { + ShowSevereEmptyField(state, eoh, IHGAlphaFieldNames(4)); + ErrorsFound = true; + } else if ((thisZoneOthEq.sched = Sched::GetSchedule(state, IHGAlphas(4))) == nullptr) { + ShowSevereItemNotFound(state, eoh, IHGAlphaFieldNames(4), IHGAlphas(4)); + ErrorsFound = true; + } else if (!thisZoneOthEq.sched->checkMinVal(state, Clusive::In, 0.0)) { + Sched::ShowSevereBadMin(state, eoh, IHGAlphaFieldNames(4), IHGAlphas(4), Clusive::In, 0.0); ErrorsFound = true; - } else { // check min/max on schedule - SchMin = GetScheduleMinValue(state, thisZoneOthEq.SchedPtr); - SchMax = GetScheduleMaxValue(state, thisZoneOthEq.SchedPtr); } - + // equipment design level calculation method. unsigned int DesignLevelFieldNumber; { @@ -2926,6 +2488,8 @@ namespace InternalHeatGains { IHGAlphaFieldNames, IHGNumericFieldNames); + ErrorObjectHeader eoh{routineName, itEqModuleObject, IHGAlphas(1)}; + auto &thisITEqInput = iTEqObjects(itEqInputNum); for (int Item1 = 1; Item1 <= thisITEqInput.numOfSpaces; ++Item1) { ++itEqNum; @@ -3041,85 +2605,23 @@ namespace InternalHeatGains { } if (IHGAlphaFieldBlanks(5)) { - thisZoneITEq.OperSchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - thisZoneITEq.OperSchedPtr = GetScheduleIndex(state, IHGAlphas(5)); - } - SchMin = 0.0; - SchMax = 0.0; - if (thisZoneITEq.OperSchedPtr == 0) { - ShowSevereError(state, - format("{}{}=\"{}\", invalid {} entered={}", - RoutineName, - itEqModuleObject, - IHGAlphas(1), - IHGAlphaFieldNames(5), - IHGAlphas(5))); + thisZoneITEq.operSched = Sched::GetScheduleAlwaysOn(state); + } else if ((thisZoneITEq.operSched = Sched::GetSchedule(state, IHGAlphas(5))) == nullptr) { + ShowSevereItemNotFound(state, eoh, IHGAlphaFieldNames(5), IHGAlphas(5)); + ErrorsFound = true; + } else if (!thisZoneITEq.operSched->checkMinVal(state, Clusive::In, 0.0)) { + Sched::ShowSevereBadMin(state, eoh, IHGAlphaFieldNames(5), IHGAlphas(5), Clusive::In, 0.0); ErrorsFound = true; - } else { // check min/max on schedule - SchMin = GetScheduleMinValue(state, thisZoneITEq.OperSchedPtr); - SchMax = GetScheduleMaxValue(state, thisZoneITEq.OperSchedPtr); - if (SchMin < 0.0 || SchMax < 0.0) { - if (SchMin < 0.0) { - ShowSevereError( - state, - format( - "{}{}=\"{}\", {}, minimum is < 0.0", RoutineName, itEqModuleObject, IHGAlphas(1), IHGAlphaFieldNames(5))); - ShowContinueError(state, - format("Schedule=\"{}\". Minimum is [{:.1R}]. Values must be >= 0.0.", IHGAlphas(5), SchMin)); - ErrorsFound = true; - } - if (SchMax < 0.0) { - ShowSevereError( - state, - format( - "{}{}=\"{}\", {}, maximum is < 0.0", RoutineName, itEqModuleObject, IHGAlphas(1), IHGAlphaFieldNames(5))); - ShowContinueError(state, - format("Schedule=\"{}\". Maximum is [{:.1R}]. Values must be >= 0.0.", IHGAlphas(5), SchMax)); - ErrorsFound = true; - } - } } - + if (IHGAlphaFieldBlanks(6)) { - thisZoneITEq.CPULoadSchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - thisZoneITEq.CPULoadSchedPtr = GetScheduleIndex(state, IHGAlphas(6)); - } - SchMin = 0.0; - SchMax = 0.0; - if (thisZoneITEq.CPULoadSchedPtr == 0) { - ShowSevereError(state, - format("{}{}=\"{}\", invalid {} entered={}", - RoutineName, - itEqModuleObject, - IHGAlphas(1), - IHGAlphaFieldNames(6), - IHGAlphas(6))); + thisZoneITEq.cpuLoadSched = Sched::GetScheduleAlwaysOn(state); + } else if ((thisZoneITEq.cpuLoadSched = Sched::GetSchedule(state, IHGAlphas(6))) == nullptr) { + ShowSevereItemNotFound(state, eoh, IHGAlphaFieldNames(6), IHGAlphas(6)); + ErrorsFound = true; + } else if (!thisZoneITEq.cpuLoadSched->checkMinVal(state, Clusive::In, 0.0)) { + Sched::ShowSevereBadMin(state, eoh, IHGAlphaFieldNames(6), IHGAlphas(6), Clusive::In, 0.0); ErrorsFound = true; - } else { // check min/max on schedule - SchMin = GetScheduleMinValue(state, thisZoneITEq.CPULoadSchedPtr); - SchMax = GetScheduleMaxValue(state, thisZoneITEq.CPULoadSchedPtr); - if (SchMin < 0.0 || SchMax < 0.0) { - if (SchMin < 0.0) { - ShowSevereError( - state, - format( - "{}{}=\"{}\", {}, minimum is < 0.0", RoutineName, itEqModuleObject, IHGAlphas(1), IHGAlphaFieldNames(6))); - ShowContinueError(state, - format("Schedule=\"{}\". Minimum is [{:.1R}]. Values must be >= 0.0.", IHGAlphas(6), SchMin)); - ErrorsFound = true; - } - if (SchMax < 0.0) { - ShowSevereError( - state, - format( - "{}{}=\"{}\", {}, maximum is < 0.0", RoutineName, itEqModuleObject, IHGAlphas(1), IHGAlphaFieldNames(6))); - ShowContinueError(state, - format("Schedule=\"{}\". Maximum is [{:.1R}]. Values must be >= 0.0.", IHGAlphas(6), SchMax)); - ErrorsFound = true; - } - } } // Calculate nominal min/max equipment level @@ -3287,54 +2789,32 @@ namespace InternalHeatGains { thisZoneITEq.EndUseSubcategoryUPS = "ITE-UPS"; } if (thisZoneITEq.FlowControlWithApproachTemps) { - if (!IHGAlphaFieldBlanks(20)) { - thisZoneITEq.SupplyApproachTempSch = GetScheduleIndex(state, IHGAlphas(20)); - if (thisZoneITEq.SupplyApproachTempSch == 0) { - ShowSevereError(state, - format("{}{}=\"{}\", invalid {} entered={}", - RoutineName, - itEqModuleObject, - IHGAlphas(1), - IHGAlphaFieldNames(20), - IHGAlphas(20))); - ErrorsFound = true; - } - } else { + if (IHGAlphaFieldBlanks(20)) { if (!hasSupplyApproachTemp) { - ShowSevereError(state, format("{}{} \"{}\"", RoutineName, itEqModuleObject, IHGAlphas(1))); - ShowContinueError( - state, + ShowSevereCustom(state, eoh, format("For {}= FlowControlWithApproachTemperatures, either {} or {} is required, but both are left blank.", IHGAlphaFieldNames(3), IHGNumericFieldNames(10), IHGAlphaFieldNames(20))); ErrorsFound = true; } - } + } else if ((thisZoneITEq.supplyApproachTempSched = Sched::GetSchedule(state, IHGAlphas(20))) == nullptr) { + ShowSevereItemNotFound(state, eoh, IHGAlphaFieldNames(20), IHGAlphas(20)); + ErrorsFound = true; + } - if (!IHGAlphaFieldBlanks(21)) { - thisZoneITEq.ReturnApproachTempSch = GetScheduleIndex(state, IHGAlphas(21)); - if (thisZoneITEq.ReturnApproachTempSch == 0) { - ShowSevereError(state, - format("{}{}=\"{}\", invalid {} entered={}", - RoutineName, - itEqModuleObject, - IHGAlphas(1), - IHGAlphaFieldNames(20), - IHGAlphas(20))); - ErrorsFound = true; - } - } else { + if (IHGAlphaFieldBlanks(21)) { if (!hasReturnApproachTemp) { - ShowSevereError(state, format("{}{} \"{}\"", RoutineName, itEqModuleObject, IHGAlphas(1))); - ShowContinueError( - state, + ShowSevereCustom(state, eoh, format("For {}= FlowControlWithApproachTemperatures, either {} or {} is required, but both are left blank.", IHGAlphaFieldNames(3), IHGNumericFieldNames(11), IHGAlphaFieldNames(21))); ErrorsFound = true; } + } else if ((thisZoneITEq.returnApproachTempSched = Sched::GetSchedule(state, IHGAlphas(21))) == nullptr) { + ShowSevereItemNotFound(state, eoh, IHGAlphaFieldNames(20), IHGAlphas(20)); + ErrorsFound = true; } } @@ -3409,6 +2889,8 @@ namespace InternalHeatGains { IHGAlphaFieldNames, IHGNumericFieldNames); + ErrorObjectHeader eoh{routineName, bbModuleObject, IHGAlphas(1)}; + auto &thisBBHeatInput = zoneBBHeatObjects(bbHeatInputNum); for (int Item1 = 1; Item1 <= thisBBHeatInput.numOfSpaces; ++Item1) { ++bbHeatNum; @@ -3419,49 +2901,15 @@ namespace InternalHeatGains { thisZoneBBHeat.spaceIndex = spaceNum; thisZoneBBHeat.ZonePtr = zoneNum; - thisZoneBBHeat.SchedPtr = GetScheduleIndex(state, IHGAlphas(3)); - if (thisZoneBBHeat.SchedPtr == 0) { - if (IHGAlphaFieldBlanks(3)) { - ShowSevereError( - state, - format("{}{}=\"{}\", {} is required.", RoutineName, bbModuleObject, thisBBHeatInput.Name, IHGAlphaFieldNames(3))); - } else { - ShowSevereError(state, - format("{}{}=\"{}\", invalid {} entered={}", - RoutineName, - bbModuleObject, - thisBBHeatInput.Name, - IHGAlphaFieldNames(3), - IHGAlphas(3))); - } + if (IHGAlphaFieldBlanks(3)) { + ShowSevereEmptyField(state, eoh, IHGAlphaFieldNames(3)); + ErrorsFound = true; + } else if ((thisZoneBBHeat.sched = Sched::GetSchedule(state, IHGAlphas(3))) == nullptr) { + ShowSevereItemNotFound(state, eoh, IHGAlphaFieldNames(3), IHGAlphas(3)); + ErrorsFound = true; + } else if (!thisZoneBBHeat.sched->checkMinVal(state, Clusive::In, 0.0)) { + Sched::ShowSevereBadMin(state, eoh, IHGAlphaFieldNames(3), IHGAlphas(3), Clusive::In, 0.0); ErrorsFound = true; - } else { // check min/max on schedule - SchMin = GetScheduleMinValue(state, thisZoneBBHeat.SchedPtr); - SchMax = GetScheduleMaxValue(state, thisZoneBBHeat.SchedPtr); - if (SchMin < 0.0 || SchMax < 0.0) { - if (SchMin < 0.0) { - ShowSevereError(state, - format("{}{}=\"{}\", {}, minimum is < 0.0", - RoutineName, - bbModuleObject, - thisBBHeatInput.Name, - IHGAlphaFieldNames(3))); - ShowContinueError(state, - format("Schedule=\"{}\". Minimum is [{:.1R}]. Values must be >= 0.0.", IHGAlphas(3), SchMin)); - ErrorsFound = true; - } - if (SchMax < 0.0) { - ShowSevereError(state, - format("{}{}=\"{}\", {}, maximum is < 0.0", - RoutineName, - bbModuleObject, - thisBBHeatInput.Name, - IHGAlphaFieldNames(3))); - ShowContinueError(state, - format("Schedule=\"{}\". Maximum is [{:.1R}]. Values must be >= 0.0.", IHGAlphas(3), SchMax)); - ErrorsFound = true; - } - } } if (IHGNumAlphas > 3) { @@ -3550,6 +2998,8 @@ namespace InternalHeatGains { IHGAlphaFieldBlanks, IHGAlphaFieldNames, IHGNumericFieldNames); + + ErrorObjectHeader eoh{routineName, contamSSModuleObject, IHGAlphas(1)}; Util::IsNameEmpty(state, IHGAlphas(1), contamSSModuleObject, ErrorsFound); state.dataHeatBal->ZoneCO2Gen(Loop).Name = IHGAlphas(1); @@ -3563,40 +3013,15 @@ namespace InternalHeatGains { ErrorsFound = true; } - state.dataHeatBal->ZoneCO2Gen(Loop).SchedPtr = GetScheduleIndex(state, IHGAlphas(3)); - if (state.dataHeatBal->ZoneCO2Gen(Loop).SchedPtr == 0) { - if (IHGAlphaFieldBlanks(3)) { - ShowSevereError(state, - format("{}{}=\"{}\", {} is required.", RoutineName, contamSSModuleObject, IHGAlphas(1), IHGAlphaFieldNames(3))); - } else { - ShowSevereError(state, - format("{}{}=\"{}\", invalid {} entered={}", - RoutineName, - contamSSModuleObject, - IHGAlphas(1), - IHGAlphaFieldNames(3), - IHGAlphas(3))); - } + if (IHGAlphaFieldBlanks(3)) { + ShowSevereEmptyField(state, eoh, IHGAlphaFieldNames(3)); + ErrorsFound = true; + } else if ((state.dataHeatBal->ZoneCO2Gen(Loop).sched = Sched::GetSchedule(state, IHGAlphas(3))) == nullptr) { + ShowSevereItemNotFound(state, eoh, IHGAlphaFieldNames(3), IHGAlphas(3)); + ErrorsFound = true; + } else if (!state.dataHeatBal->ZoneCO2Gen(Loop).sched->checkMinVal(state, Clusive::In, 0.0)) { + Sched::ShowSevereBadMin(state, eoh, IHGAlphaFieldNames(3), IHGAlphas(3), Clusive::In, 0.0); ErrorsFound = true; - } else { // check min/max on schedule - SchMin = GetScheduleMinValue(state, state.dataHeatBal->ZoneCO2Gen(Loop).SchedPtr); - SchMax = GetScheduleMaxValue(state, state.dataHeatBal->ZoneCO2Gen(Loop).SchedPtr); - if (SchMin < 0.0 || SchMax < 0.0) { - if (SchMin < 0.0) { - ShowSevereError( - state, - format("{}{}=\"{}\", {}, minimum is < 0.0", RoutineName, contamSSModuleObject, IHGAlphas(1), IHGAlphaFieldNames(3))); - ShowContinueError(state, format("Schedule=\"{}\". Minimum is [{:.1R}]. Values must be >= 0.0.", IHGAlphas(3), SchMin)); - ErrorsFound = true; - } - if (SchMax < 0.0) { - ShowSevereError( - state, - format("{}{}=\"{}\", {}, maximum is < 0.0", RoutineName, contamSSModuleObject, IHGAlphas(1), IHGAlphaFieldNames(3))); - ShowContinueError(state, format("Schedule=\"{}\". Maximum is [{:.1R}]. Values must be >= 0.0.", IHGAlphas(3), SchMax)); - ErrorsFound = true; - } - } } state.dataHeatBal->ZoneCO2Gen(Loop).CO2DesignRate = IHGNumbers(1); @@ -3642,7 +3067,6 @@ namespace InternalHeatGains { if (ErrorsFound) { ShowFatalError(state, format("{}Errors found in Getting Internal Gains Input, Program Stopped", RoutineName)); } - setupIHGOutputs(state); static constexpr std::string_view Format_721( @@ -3754,7 +3178,7 @@ namespace InternalHeatGains { Format_722, "People", state.dataHeatBal->People(Loop).Name, - GetScheduleName(state, state.dataHeatBal->People(Loop).NumberOfPeoplePtr), + state.dataHeatBal->People(Loop).numberOfPeopleSched->Name, state.dataHeatBal->Zone(ZoneNum).Name, state.dataHeatBal->Zone(ZoneNum).FloorArea, state.dataHeatBal->Zone(ZoneNum).TotOccupants); @@ -3776,7 +3200,7 @@ namespace InternalHeatGains { } else { print(state.files.eio, "{:.3R},", state.dataHeatBal->People(Loop).UserSpecSensFrac); } - print(state.files.eio, "{},", GetScheduleName(state, state.dataHeatBal->People(Loop).ActivityLevelPtr)); + print(state.files.eio, "{},", state.dataHeatBal->People(Loop).activityLevelSched->Name); if (state.dataHeatBal->People(Loop).Show55Warning) { print(state.files.eio, "Yes,"); @@ -3789,22 +3213,22 @@ namespace InternalHeatGains { auto &thisPeople = state.dataHeatBal->People(Loop); // weekdays - std::tie(SchMin, SchMax) = getScheduleMinMaxByDayType(state, thisPeople.NumberOfPeoplePtr, DayTypeGroup::Weekday); + std::tie(SchMin, SchMax) = thisPeople.numberOfPeopleSched->getMinMaxValsByDayType(state, Sched::DayTypeGroup::Weekday); print(state.files.eio, "{:.1R},", thisPeople.NumberOfPeople * SchMin); print(state.files.eio, "{:.1R},", thisPeople.NumberOfPeople * SchMax); // weekends/holidays - std::tie(SchMin, SchMax) = getScheduleMinMaxByDayType(state, thisPeople.NumberOfPeoplePtr, DayTypeGroup::WeekEndHoliday); + std::tie(SchMin, SchMax) = thisPeople.numberOfPeopleSched->getMinMaxValsByDayType(state, Sched::DayTypeGroup::WeekEndHoliday); print(state.files.eio, "{:.1R},", thisPeople.NumberOfPeople * SchMin); print(state.files.eio, "{:.1R},", thisPeople.NumberOfPeople * SchMax); // summer design days - std::tie(SchMin, SchMax) = getScheduleMinMaxByDayType(state, thisPeople.NumberOfPeoplePtr, DayTypeGroup::SummerDesignDay); + std::tie(SchMin, SchMax) = thisPeople.numberOfPeopleSched->getMinMaxValsByDayType(state, Sched::DayTypeGroup::SummerDesignDay); print(state.files.eio, "{:.1R},", thisPeople.NumberOfPeople * SchMin); print(state.files.eio, "{:.1R},", thisPeople.NumberOfPeople * SchMax); // winter design days - std::tie(SchMin, SchMax) = getScheduleMinMaxByDayType(state, thisPeople.NumberOfPeoplePtr, DayTypeGroup::WinterDesignDay); + std::tie(SchMin, SchMax) = thisPeople.numberOfPeopleSched->getMinMaxValsByDayType(state, Sched::DayTypeGroup::WinterDesignDay); print(state.files.eio, "{:.1R},", thisPeople.NumberOfPeople * SchMin); print(state.files.eio, "{:.1R},", thisPeople.NumberOfPeople * SchMax); @@ -3820,18 +3244,18 @@ namespace InternalHeatGains { } else { print(state.files.eio, "N/A,"); } - print(state.files.eio, "{},", GetScheduleName(state, state.dataHeatBal->People(Loop).WorkEffPtr)); + print(state.files.eio, "{},", state.dataHeatBal->People(Loop).workEffSched->Name); print(state.files.eio, clothingTypeEIOStrings[static_cast(state.dataHeatBal->People(Loop).clothingType)]); if (state.dataHeatBal->People(Loop).clothingType == ClothingType::CalculationSchedule) { - print(state.files.eio, "{},", GetScheduleName(state, state.dataHeatBal->People(Loop).ClothingMethodPtr)); + print(state.files.eio, "{},", state.dataHeatBal->People(Loop).clothingMethodSched->Name); } else { print(state.files.eio, "N/A,"); } - print(state.files.eio, "{},", GetScheduleName(state, state.dataHeatBal->People(Loop).ClothingPtr)); - print(state.files.eio, "{},", GetScheduleName(state, state.dataHeatBal->People(Loop).AirVelocityPtr)); + print(state.files.eio, "{},", state.dataHeatBal->People(Loop).clothingSched->Name); + print(state.files.eio, "{},", state.dataHeatBal->People(Loop).airVelocitySched->Name); if (state.dataHeatBal->People(Loop).Fanger) { print(state.files.eio, "Yes,"); @@ -3862,6 +3286,7 @@ namespace InternalHeatGains { print(state.files.eio, "\n"); } } + for (int Loop = 1; Loop <= state.dataHeatBal->TotLights; ++Loop) { if (Loop == 1) { print(state.files.eio, @@ -3886,7 +3311,7 @@ namespace InternalHeatGains { Format_722, "Lights", state.dataHeatBal->Lights(Loop).Name, - GetScheduleName(state, state.dataHeatBal->Lights(Loop).SchedPtr), + state.dataHeatBal->Lights(Loop).sched->Name, state.dataHeatBal->Zone(ZoneNum).Name, state.dataHeatBal->Zone(ZoneNum).FloorArea, state.dataHeatBal->Zone(ZoneNum).TotOccupants); @@ -3907,25 +3332,26 @@ namespace InternalHeatGains { auto &light = state.dataHeatBal->Lights(Loop); // weekdays - std::tie(SchMin, SchMax) = getScheduleMinMaxByDayType(state, light.SchedPtr, DayTypeGroup::Weekday); + std::tie(SchMin, SchMax) = light.sched->getMinMaxValsByDayType(state, Sched::DayTypeGroup::Weekday); print(state.files.eio, "{:.3R},", light.DesignLevel * SchMin); print(state.files.eio, "{:.1R},", light.DesignLevel * SchMax); // weekends/holidays - std::tie(SchMin, SchMax) = getScheduleMinMaxByDayType(state, light.SchedPtr, DayTypeGroup::WeekEndHoliday); + std::tie(SchMin, SchMax) = light.sched->getMinMaxValsByDayType(state, Sched::DayTypeGroup::WeekEndHoliday); print(state.files.eio, "{:.3R},", light.DesignLevel * SchMin); print(state.files.eio, "{:.3R},", light.DesignLevel * SchMax); // summer design days - std::tie(SchMin, SchMax) = getScheduleMinMaxByDayType(state, light.SchedPtr, DayTypeGroup::SummerDesignDay); + std::tie(SchMin, SchMax) = light.sched->getMinMaxValsByDayType(state, Sched::DayTypeGroup::SummerDesignDay); print(state.files.eio, "{:.3R},", light.DesignLevel * SchMin); print(state.files.eio, "{:.3R},", light.DesignLevel * SchMax); // winter design days - std::tie(SchMin, SchMax) = getScheduleMinMaxByDayType(state, light.SchedPtr, DayTypeGroup::WinterDesignDay); + std::tie(SchMin, SchMax) = light.sched->getMinMaxValsByDayType(state, Sched::DayTypeGroup::WinterDesignDay); print(state.files.eio, "{:.3R},", light.DesignLevel * SchMin); print(state.files.eio, "{:.3R}\n", light.DesignLevel * SchMax); } + for (int Loop = 1; Loop <= state.dataHeatBal->TotElecEquip; ++Loop) { if (Loop == 1) { print(state.files.eio, @@ -3950,7 +3376,7 @@ namespace InternalHeatGains { Format_722, "ElectricEquipment", state.dataHeatBal->ZoneElectric(Loop).Name, - GetScheduleName(state, state.dataHeatBal->ZoneElectric(Loop).SchedPtr), + state.dataHeatBal->ZoneElectric(Loop).sched->Name, state.dataHeatBal->Zone(ZoneNum).Name, state.dataHeatBal->Zone(ZoneNum).FloorArea, state.dataHeatBal->Zone(ZoneNum).TotOccupants); @@ -3970,22 +3396,22 @@ namespace InternalHeatGains { auto &electric = state.dataHeatBal->ZoneElectric(Loop); // weekdays - std::tie(SchMin, SchMax) = getScheduleMinMaxByDayType(state, electric.SchedPtr, DayTypeGroup::Weekday); + std::tie(SchMin, SchMax) = electric.sched->getMinMaxValsByDayType(state, Sched::DayTypeGroup::Weekday); print(state.files.eio, "{:.3R},", electric.DesignLevel * SchMin); print(state.files.eio, "{:.3R},", electric.DesignLevel * SchMax); // weekends/holidays - std::tie(SchMin, SchMax) = getScheduleMinMaxByDayType(state, electric.SchedPtr, DayTypeGroup::WeekEndHoliday); + std::tie(SchMin, SchMax) = electric.sched->getMinMaxValsByDayType(state, Sched::DayTypeGroup::WeekEndHoliday); print(state.files.eio, "{:.3R},", electric.DesignLevel * SchMin); print(state.files.eio, "{:.3R},", electric.DesignLevel * SchMax); // summer design days - std::tie(SchMin, SchMax) = getScheduleMinMaxByDayType(state, electric.SchedPtr, DayTypeGroup::SummerDesignDay); + std::tie(SchMin, SchMax) = electric.sched->getMinMaxValsByDayType(state, Sched::DayTypeGroup::SummerDesignDay); print(state.files.eio, "{:.3R},", electric.DesignLevel * SchMin); print(state.files.eio, "{:.3R},", electric.DesignLevel * SchMax); // winter design days - std::tie(SchMin, SchMax) = getScheduleMinMaxByDayType(state, electric.SchedPtr, DayTypeGroup::WinterDesignDay); + std::tie(SchMin, SchMax) = electric.sched->getMinMaxValsByDayType(state, Sched::DayTypeGroup::WinterDesignDay); print(state.files.eio, "{:.3R},", electric.DesignLevel * SchMin); print(state.files.eio, "{:.3R}\n", electric.DesignLevel * SchMax); } @@ -4014,7 +3440,7 @@ namespace InternalHeatGains { Format_722, "GasEquipment", state.dataHeatBal->ZoneGas(Loop).Name, - GetScheduleName(state, state.dataHeatBal->ZoneGas(Loop).SchedPtr), + state.dataHeatBal->ZoneGas(Loop).sched->Name, state.dataHeatBal->Zone(ZoneNum).Name, state.dataHeatBal->Zone(ZoneNum).FloorArea, state.dataHeatBal->Zone(ZoneNum).TotOccupants); @@ -4034,22 +3460,22 @@ namespace InternalHeatGains { auto &gas = state.dataHeatBal->ZoneGas(Loop); // weekdays - std::tie(SchMin, SchMax) = getScheduleMinMaxByDayType(state, gas.SchedPtr, DayTypeGroup::Weekday); + std::tie(SchMin, SchMax) = gas.sched->getMinMaxValsByDayType(state, Sched::DayTypeGroup::Weekday); print(state.files.eio, "{:.3R},", gas.DesignLevel * SchMin); print(state.files.eio, "{:.3R},", gas.DesignLevel * SchMax); // weekends/holidays - std::tie(SchMin, SchMax) = getScheduleMinMaxByDayType(state, gas.SchedPtr, DayTypeGroup::WeekEndHoliday); + std::tie(SchMin, SchMax) = gas.sched->getMinMaxValsByDayType(state, Sched::DayTypeGroup::WeekEndHoliday); print(state.files.eio, "{:.3R},", gas.DesignLevel * SchMin); print(state.files.eio, "{:.3R},", gas.DesignLevel * SchMax); // summer design days - std::tie(SchMin, SchMax) = getScheduleMinMaxByDayType(state, gas.SchedPtr, DayTypeGroup::SummerDesignDay); + std::tie(SchMin, SchMax) = gas.sched->getMinMaxValsByDayType(state, Sched::DayTypeGroup::SummerDesignDay); print(state.files.eio, "{:.3R},", gas.DesignLevel * SchMin); print(state.files.eio, "{:.3R},", gas.DesignLevel * SchMax); // winter design days - std::tie(SchMin, SchMax) = getScheduleMinMaxByDayType(state, gas.SchedPtr, DayTypeGroup::WinterDesignDay); + std::tie(SchMin, SchMax) = gas.sched->getMinMaxValsByDayType(state, Sched::DayTypeGroup::WinterDesignDay); print(state.files.eio, "{:.3R},", gas.DesignLevel * SchMin); print(state.files.eio, "{:.3R}\n", gas.DesignLevel * SchMax); } @@ -4079,7 +3505,7 @@ namespace InternalHeatGains { Format_722, "HotWaterEquipment", state.dataHeatBal->ZoneHWEq(Loop).Name, - GetScheduleName(state, state.dataHeatBal->ZoneHWEq(Loop).SchedPtr), + state.dataHeatBal->ZoneHWEq(Loop).sched->Name, state.dataHeatBal->Zone(ZoneNum).Name, state.dataHeatBal->Zone(ZoneNum).FloorArea, state.dataHeatBal->Zone(ZoneNum).TotOccupants); @@ -4099,22 +3525,22 @@ namespace InternalHeatGains { auto &hweq = state.dataHeatBal->ZoneHWEq(Loop); // weekdays - std::tie(SchMin, SchMax) = getScheduleMinMaxByDayType(state, hweq.SchedPtr, DayTypeGroup::Weekday); + std::tie(SchMin, SchMax) = hweq.sched->getMinMaxValsByDayType(state, Sched::DayTypeGroup::Weekday); print(state.files.eio, "{:.3R},", hweq.DesignLevel * SchMin); print(state.files.eio, "{:.3R},", hweq.DesignLevel * SchMax); // weekends/holidays - std::tie(SchMin, SchMax) = getScheduleMinMaxByDayType(state, hweq.SchedPtr, DayTypeGroup::WeekEndHoliday); + std::tie(SchMin, SchMax) = hweq.sched->getMinMaxValsByDayType(state, Sched::DayTypeGroup::WeekEndHoliday); print(state.files.eio, "{:.3R},", hweq.DesignLevel * SchMin); print(state.files.eio, "{:.3R},", hweq.DesignLevel * SchMax); // summer design days - std::tie(SchMin, SchMax) = getScheduleMinMaxByDayType(state, hweq.SchedPtr, DayTypeGroup::SummerDesignDay); + std::tie(SchMin, SchMax) = hweq.sched->getMinMaxValsByDayType(state, Sched::DayTypeGroup::SummerDesignDay); print(state.files.eio, "{:.3R},", hweq.DesignLevel * SchMin); print(state.files.eio, "{:.3R},", hweq.DesignLevel * SchMax); // winter design days - std::tie(SchMin, SchMax) = getScheduleMinMaxByDayType(state, hweq.SchedPtr, DayTypeGroup::WinterDesignDay); + std::tie(SchMin, SchMax) = hweq.sched->getMinMaxValsByDayType(state, Sched::DayTypeGroup::WinterDesignDay); print(state.files.eio, "{:.3R},", hweq.DesignLevel * SchMin); print(state.files.eio, "{:.3R}\n", hweq.DesignLevel * SchMax); } @@ -4144,7 +3570,7 @@ namespace InternalHeatGains { Format_722, "SteamEquipment", state.dataHeatBal->ZoneSteamEq(Loop).Name, - GetScheduleName(state, state.dataHeatBal->ZoneSteamEq(Loop).SchedPtr), + state.dataHeatBal->ZoneSteamEq(Loop).sched->Name, state.dataHeatBal->Zone(ZoneNum).Name, state.dataHeatBal->Zone(ZoneNum).FloorArea, state.dataHeatBal->Zone(ZoneNum).TotOccupants); @@ -4164,22 +3590,22 @@ namespace InternalHeatGains { auto &stmeq = state.dataHeatBal->ZoneSteamEq(Loop); // weekdays - std::tie(SchMin, SchMax) = getScheduleMinMaxByDayType(state, stmeq.SchedPtr, DayTypeGroup::Weekday); + std::tie(SchMin, SchMax) = stmeq.sched->getMinMaxValsByDayType(state, Sched::DayTypeGroup::Weekday); print(state.files.eio, "{:.3R},", stmeq.DesignLevel * SchMin); print(state.files.eio, "{:.3R},", stmeq.DesignLevel * SchMax); // weekends/holidays - std::tie(SchMin, SchMax) = getScheduleMinMaxByDayType(state, stmeq.SchedPtr, DayTypeGroup::WeekEndHoliday); + std::tie(SchMin, SchMax) = stmeq.sched->getMinMaxValsByDayType(state, Sched::DayTypeGroup::WeekEndHoliday); print(state.files.eio, "{:.3R},", stmeq.DesignLevel * SchMin); print(state.files.eio, "{:.3R},", stmeq.DesignLevel * SchMax); // summer design days - std::tie(SchMin, SchMax) = getScheduleMinMaxByDayType(state, stmeq.SchedPtr, DayTypeGroup::SummerDesignDay); + std::tie(SchMin, SchMax) = stmeq.sched->getMinMaxValsByDayType(state, Sched::DayTypeGroup::SummerDesignDay); print(state.files.eio, "{:.3R},", stmeq.DesignLevel * SchMin); print(state.files.eio, "{:.3R},", stmeq.DesignLevel * SchMax); // winter design days - std::tie(SchMin, SchMax) = getScheduleMinMaxByDayType(state, stmeq.SchedPtr, DayTypeGroup::WinterDesignDay); + std::tie(SchMin, SchMax) = stmeq.sched->getMinMaxValsByDayType(state, Sched::DayTypeGroup::WinterDesignDay); print(state.files.eio, "{:.3R},", stmeq.DesignLevel * SchMin); print(state.files.eio, "{:.3R}\n", stmeq.DesignLevel * SchMax); } @@ -4209,7 +3635,7 @@ namespace InternalHeatGains { Format_722, "OtherEquipment", state.dataHeatBal->ZoneOtherEq(Loop).Name, - GetScheduleName(state, state.dataHeatBal->ZoneOtherEq(Loop).SchedPtr), + state.dataHeatBal->ZoneOtherEq(Loop).sched->Name, state.dataHeatBal->Zone(ZoneNum).Name, state.dataHeatBal->Zone(ZoneNum).FloorArea, state.dataHeatBal->Zone(ZoneNum).TotOccupants); @@ -4228,22 +3654,22 @@ namespace InternalHeatGains { auto &other = state.dataHeatBal->ZoneOtherEq(Loop); // weekdays - std::tie(SchMin, SchMax) = getScheduleMinMaxByDayType(state, other.SchedPtr, DayTypeGroup::Weekday); + std::tie(SchMin, SchMax) = other.sched->getMinMaxValsByDayType(state, Sched::DayTypeGroup::Weekday); print(state.files.eio, "{:.3R},", other.DesignLevel * SchMin); print(state.files.eio, "{:.3R},", other.DesignLevel * SchMax); // weekends/holidays - std::tie(SchMin, SchMax) = getScheduleMinMaxByDayType(state, other.SchedPtr, DayTypeGroup::WeekEndHoliday); + std::tie(SchMin, SchMax) = other.sched->getMinMaxValsByDayType(state, Sched::DayTypeGroup::WeekEndHoliday); print(state.files.eio, "{:.3R},", other.DesignLevel * SchMin); print(state.files.eio, "{:.3R},", other.DesignLevel * SchMax); // summer design days - std::tie(SchMin, SchMax) = getScheduleMinMaxByDayType(state, other.SchedPtr, DayTypeGroup::SummerDesignDay); + std::tie(SchMin, SchMax) = other.sched->getMinMaxValsByDayType(state, Sched::DayTypeGroup::SummerDesignDay); print(state.files.eio, "{:.3R},", other.DesignLevel * SchMin); print(state.files.eio, "{:.3R},", other.DesignLevel * SchMax); // winter design days - std::tie(SchMin, SchMax) = getScheduleMinMaxByDayType(state, other.SchedPtr, DayTypeGroup::WinterDesignDay); + std::tie(SchMin, SchMax) = other.sched->getMinMaxValsByDayType(state, Sched::DayTypeGroup::WinterDesignDay); print(state.files.eio, "{:.3R},", other.DesignLevel * SchMin); print(state.files.eio, "{:.3R}\n", other.DesignLevel * SchMax); } @@ -4274,7 +3700,7 @@ namespace InternalHeatGains { Format_722, "ElectricEquipment:ITE:AirCooled", state.dataHeatBal->ZoneITEq(Loop).Name, - GetScheduleName(state, state.dataHeatBal->ZoneITEq(Loop).OperSchedPtr), + state.dataHeatBal->ZoneITEq(Loop).operSched->Name, state.dataHeatBal->Zone(ZoneNum).Name, state.dataHeatBal->Zone(ZoneNum).FloorArea, state.dataHeatBal->Zone(ZoneNum).TotOccupants); @@ -4295,22 +3721,22 @@ namespace InternalHeatGains { auto &iteq = state.dataHeatBal->ZoneITEq(Loop); // weekdays - std::tie(SchMin, SchMax) = getScheduleMinMaxByDayType(state, iteq.OperSchedPtr, DayTypeGroup::Weekday); + std::tie(SchMin, SchMax) = iteq.operSched->getMinMaxValsByDayType(state, Sched::DayTypeGroup::Weekday); print(state.files.eio, "{:.3R},", iteq.DesignTotalPower * SchMin); print(state.files.eio, "{:.3R},", iteq.DesignTotalPower * SchMax); // weekends/holidays - std::tie(SchMin, SchMax) = getScheduleMinMaxByDayType(state, iteq.OperSchedPtr, DayTypeGroup::WeekEndHoliday); + std::tie(SchMin, SchMax) = iteq.operSched->getMinMaxValsByDayType(state, Sched::DayTypeGroup::WeekEndHoliday); print(state.files.eio, "{:.3R},", iteq.DesignTotalPower * SchMin); print(state.files.eio, "{:.3R},", iteq.DesignTotalPower * SchMax); // summer design days - std::tie(SchMin, SchMax) = getScheduleMinMaxByDayType(state, iteq.OperSchedPtr, DayTypeGroup::SummerDesignDay); + std::tie(SchMin, SchMax) = iteq.operSched->getMinMaxValsByDayType(state, Sched::DayTypeGroup::SummerDesignDay); print(state.files.eio, "{:.3R},", iteq.DesignTotalPower * SchMin); print(state.files.eio, "{:.3R},", iteq.DesignTotalPower * SchMax); // winter design days - std::tie(SchMin, SchMax) = getScheduleMinMaxByDayType(state, iteq.OperSchedPtr, DayTypeGroup::WinterDesignDay); + std::tie(SchMin, SchMax) = iteq.operSched->getMinMaxValsByDayType(state, Sched::DayTypeGroup::WinterDesignDay); print(state.files.eio, "{:.3R},", iteq.DesignTotalPower * SchMin); print(state.files.eio, "{:.3R},", iteq.DesignTotalPower * SchMax); @@ -4339,7 +3765,7 @@ namespace InternalHeatGains { Format_722, "Outdoor Controlled Baseboard Heat", state.dataHeatBal->ZoneBBHeat(Loop).Name, - GetScheduleName(state, state.dataHeatBal->ZoneBBHeat(Loop).SchedPtr), + state.dataHeatBal->ZoneBBHeat(Loop).sched->Name, state.dataHeatBal->Zone(ZoneNum).Name, state.dataHeatBal->Zone(ZoneNum).FloorArea, state.dataHeatBal->Zone(ZoneNum).TotOccupants); @@ -7356,7 +6782,6 @@ namespace InternalHeatGains { // that are independent of the zone air temperature. // Using/Aliasing - using namespace ScheduleManager; using Dayltg::FigureTDDZoneGains; using FuelCellElectricGenerator::FigureFuelCellZoneGains; using MicroCHPElectricGenerator::FigureMicroCHPZoneGains; @@ -7540,7 +6965,7 @@ namespace InternalHeatGains { int NZ = state.dataHeatBal->People(Loop).ZonePtr; int spaceNum = thisPeople.spaceIndex; auto &thisSpaceHB = state.dataZoneTempPredictorCorrector->spaceHeatBalance(spaceNum); - NumberOccupants = thisPeople.NumberOfPeople * GetCurrentScheduleValue(state, thisPeople.NumberOfPeoplePtr); + NumberOccupants = thisPeople.NumberOfPeople * thisPeople.numberOfPeopleSched->getCurrentVal(); if (thisPeople.EMSPeopleOn) NumberOccupants = thisPeople.EMSNumberOfPeople; TotalPeopleGain = 0.0; @@ -7548,7 +6973,7 @@ namespace InternalHeatGains { auto &thisZoneRep = state.dataHeatBal->ZonePreDefRep(NZ); if (NumberOccupants > 0.0) { - ActivityLevel_WperPerson = GetCurrentScheduleValue(state, thisPeople.ActivityLevelPtr); + ActivityLevel_WperPerson = thisPeople.activityLevelSched->getCurrentVal(); TotalPeopleGain = NumberOccupants * ActivityLevel_WperPerson; // if the user did not specify a sensible fraction, calculate the sensible heat gain if (thisPeople.UserSpecSensFrac == Constant::AutoCalculate) { @@ -7600,7 +7025,7 @@ namespace InternalHeatGains { auto &thisLights = state.dataHeatBal->Lights(Loop); int NZ = thisLights.ZonePtr; int spaceNum = thisLights.spaceIndex; - Q = thisLights.DesignLevel * GetCurrentScheduleValue(state, thisLights.SchedPtr); + Q = thisLights.DesignLevel * thisLights.sched->getCurrentVal(); if (state.dataDayltg->ZoneDaylight(NZ).totRefPts > 0) { if (thisLights.FractionReplaceable > 0.0) { // FractionReplaceable can only be 0 or 1 for these models @@ -7660,7 +7085,7 @@ namespace InternalHeatGains { for (int Loop = 1; Loop <= state.dataHeatBal->TotElecEquip; ++Loop) { auto &thisElecEq = state.dataHeatBal->ZoneElectric(Loop); - Q = thisElecEq.DesignLevel * GetCurrentScheduleValue(state, thisElecEq.SchedPtr); + Q = thisElecEq.DesignLevel * thisElecEq.sched->getCurrentVal(); // Reduce equipment power due to demand limiting if (thisElecEq.ManageDemand && (Q > thisElecEq.DemandLimit)) Q = thisElecEq.DemandLimit; @@ -7685,7 +7110,7 @@ namespace InternalHeatGains { for (int Loop = 1; Loop <= state.dataHeatBal->TotGasEquip; ++Loop) { auto &thisGasEq = state.dataHeatBal->ZoneGas(Loop); - Q = thisGasEq.DesignLevel * GetCurrentScheduleValue(state, thisGasEq.SchedPtr); + Q = thisGasEq.DesignLevel * thisGasEq.sched->getCurrentVal(); // Set Q to EMS override if being called for by EMs if (thisGasEq.EMSZoneEquipOverrideOn) Q = thisGasEq.EMSEquipPower; @@ -7708,7 +7133,7 @@ namespace InternalHeatGains { for (int Loop = 1; Loop <= state.dataHeatBal->TotOthEquip; ++Loop) { auto &thisOtherEq = state.dataHeatBal->ZoneOtherEq(Loop); - Q = thisOtherEq.DesignLevel * GetCurrentScheduleValue(state, thisOtherEq.SchedPtr); + Q = thisOtherEq.DesignLevel * thisOtherEq.sched->getCurrentVal(); // Set Q to EMS override if being called for by EMs if (thisOtherEq.EMSZoneEquipOverrideOn) Q = thisOtherEq.EMSEquipPower; @@ -7732,7 +7157,7 @@ namespace InternalHeatGains { for (int Loop = 1; Loop <= state.dataHeatBal->TotHWEquip; ++Loop) { auto &thisHWEq = state.dataHeatBal->ZoneHWEq(Loop); - Q = thisHWEq.DesignLevel * GetCurrentScheduleValue(state, thisHWEq.SchedPtr); + Q = thisHWEq.DesignLevel * thisHWEq.sched->getCurrentVal(); // Set Q to EMS override if being called for by EMs if (thisHWEq.EMSZoneEquipOverrideOn) Q = thisHWEq.EMSEquipPower; @@ -7754,7 +7179,7 @@ namespace InternalHeatGains { for (int Loop = 1; Loop <= state.dataHeatBal->TotStmEquip; ++Loop) { auto &thisSteamEq = state.dataHeatBal->ZoneSteamEq(Loop); - Q = thisSteamEq.DesignLevel * GetCurrentScheduleValue(state, thisSteamEq.SchedPtr); + Q = thisSteamEq.DesignLevel * thisSteamEq.sched->getCurrentVal(); // Set Q to EMS override if being called for by EMs if (thisSteamEq.EMSZoneEquipOverrideOn) Q = thisSteamEq.EMSEquipPower; @@ -7787,7 +7212,7 @@ namespace InternalHeatGains { } else { Q = thisBBHeat.CapatLowTemperature; } - Q *= GetCurrentScheduleValue(state, thisBBHeat.SchedPtr); + Q *= thisBBHeat.sched->getCurrentVal(); // set with EMS value if being called for. if (thisBBHeat.EMSZoneBaseboardOverrideOn) Q = thisBBHeat.EMSZoneBaseboardPower; @@ -7806,7 +7231,7 @@ namespace InternalHeatGains { for (int Loop = 1; Loop <= state.dataHeatBal->TotCO2Gen; ++Loop) { int NZ = state.dataHeatBal->ZoneCO2Gen(Loop).ZonePtr; state.dataHeatBal->ZoneCO2Gen(Loop).CO2GainRate = - state.dataHeatBal->ZoneCO2Gen(Loop).CO2DesignRate * GetCurrentScheduleValue(state, state.dataHeatBal->ZoneCO2Gen(Loop).SchedPtr); + state.dataHeatBal->ZoneCO2Gen(Loop).CO2DesignRate * state.dataHeatBal->ZoneCO2Gen(Loop).sched->getCurrentVal(); state.dataHeatBal->ZoneRpt(NZ).CO2Rate += state.dataHeatBal->ZoneCO2Gen(Loop).CO2GainRate; } @@ -7870,7 +7295,7 @@ namespace InternalHeatGains { state.dataInternalHeatGains->adjQL * thisEnclosure.radThermAbsMult * state.dataHeatBalSurf->SurfAbsThermalInt(SurfNum); // store the magnitude and time of the pulse state.dataOutRptTab->radiantPulseTimestep(state.dataSize->CurOverallSimDay, zoneNum) = - (state.dataGlobal->HourOfDay - 1) * state.dataGlobal->NumOfTimeStepInHour + state.dataGlobal->TimeStep; + (state.dataGlobal->HourOfDay - 1) * state.dataGlobal->TimeStepsInHour + state.dataGlobal->TimeStep; state.dataOutRptTab->radiantPulseReceived(state.dataSize->CurOverallSimDay, SurfNum) = (state.dataInternalHeatGains->adjQL - state.dataInternalHeatGains->curQL) * thisEnclosure.radThermAbsMult * state.dataHeatBalSurf->SurfAbsThermalInt(SurfNum) * state.dataSurface->Surface(SurfNum).Area; @@ -7918,7 +7343,6 @@ namespace InternalHeatGains { // This broken into a separate subroutine, because the calculations are more detailed than the other // types of internal gains. - using ScheduleManager::GetCurrentScheduleValue; using namespace Psychrometrics; using Curve::CurveValue; using HVAC::SmallAirVolFlow; @@ -8057,8 +7481,8 @@ namespace InternalHeatGains { NZ = state.dataHeatBal->ZoneITEq(Loop).ZonePtr; auto &thisZoneHB = state.dataZoneTempPredictorCorrector->zoneHeatBalance(NZ); int spaceNum = state.dataHeatBal->ZoneITEq(Loop).spaceIndex; - OperSchedFrac = GetCurrentScheduleValue(state, state.dataHeatBal->ZoneITEq(Loop).OperSchedPtr); - CPULoadSchedFrac = GetCurrentScheduleValue(state, state.dataHeatBal->ZoneITEq(Loop).CPULoadSchedPtr); + OperSchedFrac = state.dataHeatBal->ZoneITEq(Loop).operSched->getCurrentVal(); + CPULoadSchedFrac = state.dataHeatBal->ZoneITEq(Loop).cpuLoadSched->getCurrentVal(); // Determine inlet air temperature and humidity AirConnection = state.dataHeatBal->ZoneITEq(Loop).AirConnectionType; @@ -8067,8 +7491,8 @@ namespace InternalHeatGains { if (state.dataHeatBal->ZoneITEq(Loop).FlowControlWithApproachTemps) { TSupply = state.dataLoopNodes->Node(SupplyNodeNum).Temp; WSupply = state.dataLoopNodes->Node(SupplyNodeNum).HumRat; - if (state.dataHeatBal->ZoneITEq(Loop).SupplyApproachTempSch != 0) { - TAirIn = TSupply + GetCurrentScheduleValue(state, state.dataHeatBal->ZoneITEq(Loop).SupplyApproachTempSch); + if (state.dataHeatBal->ZoneITEq(Loop).supplyApproachTempSched != nullptr) { + TAirIn = TSupply + state.dataHeatBal->ZoneITEq(Loop).supplyApproachTempSched->getCurrentVal(); } else { TAirIn = TSupply + state.dataHeatBal->ZoneITEq(Loop).SupplyApproachTemp; } @@ -8113,13 +7537,13 @@ namespace InternalHeatGains { if (state.dataGlobal->DoingSizing && state.dataHeatBal->ZoneITEq(Loop).FlowControlWithApproachTemps) { TAirInDesign = state.dataHeatBal->ZoneITEq(Loop).SizingTAirIn; - if (state.dataHeatBal->ZoneITEq(Loop).SupplyApproachTempSch != 0) { - TAirInDesign = TAirInDesign + GetCurrentScheduleValue(state, state.dataHeatBal->ZoneITEq(Loop).SupplyApproachTempSch); + if (state.dataHeatBal->ZoneITEq(Loop).supplyApproachTempSched != nullptr) { + TAirInDesign = TAirInDesign + state.dataHeatBal->ZoneITEq(Loop).supplyApproachTempSched->getCurrentVal(); } else { TAirInDesign = TAirInDesign + state.dataHeatBal->ZoneITEq(Loop).SupplyApproachTemp; } - OperSchedFrac = GetCurrentScheduleValue(state, state.dataHeatBal->ZoneITEq(Loop).OperSchedPtr); - CPULoadSchedFrac = GetCurrentScheduleValue(state, state.dataHeatBal->ZoneITEq(Loop).CPULoadSchedPtr); + OperSchedFrac = state.dataHeatBal->ZoneITEq(Loop).operSched->getCurrentVal(); + CPULoadSchedFrac = state.dataHeatBal->ZoneITEq(Loop).cpuLoadSched->getCurrentVal(); } CPUPower = max(state.dataHeatBal->ZoneITEq(Loop).DesignCPUPower * OperSchedFrac * @@ -8321,9 +7745,9 @@ namespace InternalHeatGains { totalGain = 0; totalRate = 0; for (int i : it->second) { - if (state.dataHeatBal->ZoneITEq(i).ReturnApproachTempSch != 0) { + if (state.dataHeatBal->ZoneITEq(i).returnApproachTempSched != nullptr) { TAirReturn = state.dataHeatBal->ZoneITEq(i).AirOutletDryBulbT + - GetCurrentScheduleValue(state, state.dataHeatBal->ZoneITEq(i).ReturnApproachTempSch); + state.dataHeatBal->ZoneITEq(i).returnApproachTempSched->getCurrentVal(); } else { TAirReturn = state.dataHeatBal->ZoneITEq(i).AirOutletDryBulbT + state.dataHeatBal->ZoneITEq(i).ReturnApproachTemp; } @@ -9571,7 +8995,7 @@ namespace InternalHeatGains { (int)DataHeatBalance::IntGainType::Num); if (state.dataGlobal->CompLoadReportIsReq && !state.dataGlobal->isPulseZoneSizing) { - int TimeStepInDay = (state.dataGlobal->HourOfDay - 1) * state.dataGlobal->NumOfTimeStepInHour + state.dataGlobal->TimeStep; + int TimeStepInDay = (state.dataGlobal->HourOfDay - 1) * state.dataGlobal->TimeStepsInHour + state.dataGlobal->TimeStep; for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) { state.dataOutRptTab->peopleInstantSeq(state.dataSize->CurOverallSimDay, TimeStepInDay, iZone) = SumInternalConvectionGainsByTypes(state, iZone, IntGainTypesPeople); @@ -9748,7 +9172,6 @@ namespace InternalHeatGains { } return sumReturnAirGainRate; } - } // namespace InternalHeatGains } // namespace EnergyPlus diff --git a/src/EnergyPlus/InternalHeatGains.hh b/src/EnergyPlus/InternalHeatGains.hh index a44469c5e89..f2618f8b781 100644 --- a/src/EnergyPlus/InternalHeatGains.hh +++ b/src/EnergyPlus/InternalHeatGains.hh @@ -240,6 +240,10 @@ struct InternalHeatGainsData : BaseGlobalStruct EPVector lightsObjects; EPVector zoneElectricObjects; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/LowTempRadiantSystem.cc b/src/EnergyPlus/LowTempRadiantSystem.cc index 98d926fd018..26f8e3594c7 100644 --- a/src/EnergyPlus/LowTempRadiantSystem.cc +++ b/src/EnergyPlus/LowTempRadiantSystem.cc @@ -274,12 +274,13 @@ namespace LowTempRadiantSystem { using DataSizing::HeatingDesignCapacity; using NodeInputManager::GetOnlySingleNode; - using ScheduleManager::GetScheduleIndex; using namespace DataLoopNode; using namespace DataSurfaceLists; // SUBROUTINE PARAMETER DEFINITIONS: constexpr std::string_view RoutineName("GetLowTempRadiantSystem: "); // include trailing blank space + constexpr std::string_view routineName = "GetLowTempRadiantSystem"; + constexpr std::string_view Off("Off"); constexpr std::string_view SimpleOff("SimpleOff"); constexpr std::string_view VariableOff("VariableOff"); @@ -431,6 +432,8 @@ namespace LowTempRadiantSystem { cAlphaFields, cNumericFields); + ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)}; + state.dataLowTempRadSys->HydronicRadiantSysDesign(Item).FieldNames.allocate(NumNumbers); state.dataLowTempRadSys->HydronicRadiantSysDesign(Item).FieldNames = ""; state.dataLowTempRadSys->HydronicRadiantSysDesign(Item).FieldNames = cNumericFields; @@ -506,11 +509,10 @@ namespace LowTempRadiantSystem { thisRadSysDesign.HotThrottlRange = Numbers(6); - thisRadSysDesign.HotSetptSched = Alphas(6); - thisRadSysDesign.HotSetptSchedPtr = GetScheduleIndex(state, thisRadSysDesign.HotSetptSched); - if ((thisRadSysDesign.HotSetptSchedPtr == 0) && (!lAlphaBlanks(6))) { - ShowSevereError(state, format("{} not found: {}", cAlphaFields(6), Alphas(6))); - ShowContinueError(state, format("Occurs in {} = {}", CurrentModuleObject, Alphas(1))); + + if (lAlphaBlanks(6)) { + } else if ((thisRadSysDesign.heatSetptSched = Sched::GetSchedule(state, Alphas(6))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(6), Alphas(6)); ErrorsFound = true; } @@ -563,11 +565,9 @@ namespace LowTempRadiantSystem { thisRadSysDesign.ColdThrottlRange = Numbers(9); - thisRadSysDesign.ColdSetptSched = Alphas(8); - thisRadSysDesign.ColdSetptSchedPtr = GetScheduleIndex(state, Alphas(8)); - if ((thisRadSysDesign.ColdSetptSchedPtr == 0) && (!lAlphaBlanks(8))) { - ShowSevereError(state, format("{} not found: {}", cAlphaFields(8), Alphas(8))); - ShowContinueError(state, format("Occurs in {} = {}", CurrentModuleObject, Alphas(1))); + if (lAlphaBlanks(8)) { + } else if ((thisRadSysDesign.coolSetptSched = Sched::GetSchedule(state, Alphas(8))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(8), Alphas(8)); ErrorsFound = true; } @@ -583,14 +583,9 @@ namespace LowTempRadiantSystem { thisRadSysDesign.CondDewPtDeltaT = Numbers(10); - thisRadSysDesign.schedNameChangeoverDelay = Alphas(10); - if (!lAlphaBlanks(10)) { - thisRadSysDesign.schedPtrChangeoverDelay = GetScheduleIndex(state, thisRadSysDesign.schedNameChangeoverDelay); - if (thisRadSysDesign.schedPtrChangeoverDelay == 0) { - ShowWarningError(state, format("{} not found for {}", cAlphaFields(10), thisRadSysDesign.schedNameChangeoverDelay)); - ShowContinueError(state, format("This occurs for {} = {}", cAlphaFields(1), Alphas(1))); - ShowContinueError(state, "As a result, no changeover delay will be used for this radiant system."); - } + if (lAlphaBlanks(10)) { + } else if ((thisRadSysDesign.changeoverDelaySched = Sched::GetSchedule(state, Alphas(10))) == nullptr) { + ShowWarningItemNotFound(state, eoh, cAlphaFields(10), Alphas(10), "No changeover delay will be used for this radiant system."); } VarFlowRadDesignNames(Item) = Alphas(1); @@ -614,6 +609,8 @@ namespace LowTempRadiantSystem { cAlphaFields, cNumericFields); + ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)}; + state.dataLowTempRadSys->HydronicRadiantSysNumericFields(Item).FieldNames.allocate(NumNumbers); state.dataLowTempRadSys->HydronicRadiantSysNumericFields(Item).FieldNames = ""; state.dataLowTempRadSys->HydronicRadiantSysNumericFields(Item).FieldNames = cNumericFields; @@ -634,16 +631,11 @@ namespace LowTempRadiantSystem { VarFlowRadDesignData variableFlowDesignDataObject{state.dataLowTempRadSys->HydronicRadiantSysDesign( thisRadSys.DesignObjectPtr)}; // Contains the data for variable flow hydronic systems - thisRadSys.SchedName = Alphas(3); if (lAlphaBlanks(3)) { - thisRadSys.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - thisRadSys.SchedPtr = GetScheduleIndex(state, Alphas(3)); - if (thisRadSys.SchedPtr == 0) { - ShowSevereError(state, format("{} not found for {}", cAlphaFields(2), Alphas(1))); - ShowContinueError(state, format("Missing {} is {}", cAlphaFields(3), Alphas(3))); - ErrorsFound = true; - } + thisRadSys.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((thisRadSys.availSched = Sched::GetSchedule(state, Alphas(3))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(3), Alphas(3)); + ErrorsFound = true; } thisRadSys.ZoneName = Alphas(4); @@ -758,7 +750,7 @@ namespace LowTempRadiantSystem { } if ((thisRadSys.WaterVolFlowMaxHeat == AutoSize) && (lAlphaBlanks(6) || lAlphaBlanks(7) || (thisRadSys.HotWaterInNode <= 0) || (thisRadSys.HotWaterOutNode <= 0) || - (variableFlowDesignDataObject.HotSetptSchedPtr == 0))) { + (variableFlowDesignDataObject.heatSetptSched == nullptr))) { ShowSevereError(state, "Hydronic radiant systems may not be autosized without specification of nodes or schedules."); ShowContinueError(state, format("Occurs in {} (heating input) = {}", CurrentModuleObject, Alphas(1))); ErrorsFound = true; @@ -825,13 +817,13 @@ namespace LowTempRadiantSystem { thisRadSys.NumCircCalcMethod = CircuitCalc::OneCircuit; } - thisRadSys.schedPtrChangeoverDelay = variableFlowDesignDataObject.schedPtrChangeoverDelay; + thisRadSys.changeoverDelaySched = variableFlowDesignDataObject.changeoverDelaySched; thisRadSys.CircLength = Numbers(6); if ((thisRadSys.WaterVolFlowMaxCool == AutoSize) && (variableFlowDesignDataObject.DesignCoolingCapMethod == 0 || lAlphaBlanks(8) || lAlphaBlanks(9) || - (thisRadSys.ColdWaterInNode <= 0) || (thisRadSys.ColdWaterOutNode <= 0) || (variableFlowDesignDataObject.ColdSetptSchedPtr == 0))) { + (thisRadSys.ColdWaterInNode <= 0) || (thisRadSys.ColdWaterOutNode <= 0) || (variableFlowDesignDataObject.coolSetptSched == nullptr))) { ShowSevereError(state, "Hydronic radiant systems may not be autosized without specification of nodes or schedules"); ShowContinueError(state, format("Occurs in {} (cooling input) ={}", CurrentModuleObject, Alphas(1))); ErrorsFound = true; @@ -855,6 +847,8 @@ namespace LowTempRadiantSystem { cAlphaFields, cNumericFields); + ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)}; + state.dataLowTempRadSys->CflowRadiantSysDesign(Item).FieldNames.allocate(NumNumbers); state.dataLowTempRadSys->CflowRadiantSysDesign(Item).FieldNames = ""; state.dataLowTempRadSys->CflowRadiantSysDesign(Item).FieldNames = cNumericFields; @@ -890,14 +884,9 @@ namespace LowTempRadiantSystem { } thisRadSysDesign.CondDewPtDeltaT = Numbers(7); - thisRadSysDesign.schedNameChangeoverDelay = Alphas(5); - if (!lAlphaBlanks(5)) { - thisRadSysDesign.schedPtrChangeoverDelay = GetScheduleIndex(state, thisRadSysDesign.schedNameChangeoverDelay); - if (thisRadSysDesign.schedPtrChangeoverDelay == 0) { - ShowWarningError(state, format("{} not found for {}", cAlphaFields(5), thisRadSysDesign.schedNameChangeoverDelay)); - ShowContinueError(state, format("This occurs for {} = {}", cAlphaFields(1), Alphas(1))); - ShowContinueError(state, "As a result, no changeover delay will be used for this radiant system."); - } + if (lAlphaBlanks(5)) { + } else if ((thisRadSysDesign.changeoverDelaySched = Sched::GetSchedule(state, Alphas(5))) == nullptr) { + ShowWarningItemNotFound(state, eoh, cAlphaFields(5), Alphas(5), "No changeover delay will be used for this radiant system."); } CFlowRadDesignNames(Item) = Alphas(1); } @@ -918,6 +907,9 @@ namespace LowTempRadiantSystem { lAlphaBlanks, cAlphaFields, cNumericFields); + + ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)}; + GlobalNames::VerifyUniqueInterObjectName( state, state.dataLowTempRadSys->LowTempRadUniqueNames, Alphas(1), CurrentModuleObject, cAlphaFields(1), ErrorsFound); ++BaseNum; @@ -933,16 +925,11 @@ namespace LowTempRadiantSystem { ConstantFlowRadDesignData ConstantFlowRadDesignDataObject{ state.dataLowTempRadSys->CflowRadiantSysDesign(thisCFloSys.DesignObjectPtr)}; // Contains the data for variable flow hydronic systems - thisCFloSys.SchedName = Alphas(3); if (lAlphaBlanks(3)) { - thisCFloSys.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - thisCFloSys.SchedPtr = GetScheduleIndex(state, Alphas(3)); - if (thisCFloSys.SchedPtr == 0) { - ShowSevereError(state, format("{} not found for {}", cAlphaFields(3), Alphas(1))); - ShowContinueError(state, format("Missing {} is {}", cAlphaFields(3), Alphas(3))); - ErrorsFound = true; - } + thisCFloSys.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((thisCFloSys.availSched = Sched::GetSchedule(state, Alphas(3))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(3), Alphas(3)); + ErrorsFound = true; } thisCFloSys.ZoneName = Alphas(4); @@ -1008,11 +995,10 @@ namespace LowTempRadiantSystem { // Process pump input for constant flow (hydronic) radiant system thisCFloSys.WaterVolFlowMax = Numbers(2); - thisCFloSys.VolFlowSched = Alphas(6); - thisCFloSys.VolFlowSchedPtr = GetScheduleIndex(state, thisCFloSys.VolFlowSched); - if ((thisCFloSys.VolFlowSchedPtr == 0) && (!lAlphaBlanks(6))) { - ShowSevereError(state, format("{} not found: {}", cAlphaFields(6), Alphas(6))); - ShowContinueError(state, format("Occurs in {} = {}", CurrentModuleObject, Alphas(1))); + + if (lAlphaBlanks(6)) { + } else if ((thisCFloSys.volFlowSched = Sched::GetSchedule(state, Alphas(6))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(6), Alphas(6)); ErrorsFound = true; } thisCFloSys.NomPumpHead = Numbers(3); @@ -1043,35 +1029,28 @@ namespace LowTempRadiantSystem { TestCompSet(state, CurrentModuleObject, Alphas(1), Alphas(7), Alphas(8), "Hot Water Nodes"); } - thisCFloSys.HotWaterHiTempSched = Alphas(9); - thisCFloSys.HotWaterHiTempSchedPtr = GetScheduleIndex(state, Alphas(9)); - if ((thisCFloSys.HotWaterHiTempSchedPtr == 0) && (!lAlphaBlanks(9))) { - ShowSevereError(state, format("{} not found: {}", cAlphaFields(9), Alphas(9))); - ShowContinueError(state, format("Occurs in {} = {}", CurrentModuleObject, Alphas(1))); + if (lAlphaBlanks(9)) { + } else if ((thisCFloSys.hotWaterHiTempSched = Sched::GetSchedule(state, Alphas(9))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(9), Alphas(9)); ErrorsFound = true; } - thisCFloSys.HotWaterLoTempSched = Alphas(10); - thisCFloSys.HotWaterLoTempSchedPtr = GetScheduleIndex(state, Alphas(10)); - if ((thisCFloSys.HotWaterLoTempSchedPtr == 0) && (!lAlphaBlanks(10))) { - ShowSevereError(state, format("{} not found: {}", cAlphaFields(10), Alphas(10))); - ShowContinueError(state, format("Occurs in {} = {}", CurrentModuleObject, Alphas(1))); + if (lAlphaBlanks(10)) { + } else if ((thisCFloSys.hotWaterLoTempSched = Sched::GetSchedule(state, Alphas(10))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(10), Alphas(10)); ErrorsFound = true; } - thisCFloSys.HotCtrlHiTempSched = Alphas(11); - thisCFloSys.HotCtrlHiTempSchedPtr = GetScheduleIndex(state, Alphas(11)); - if ((thisCFloSys.HotCtrlHiTempSchedPtr == 0) && (!lAlphaBlanks(11))) { - ShowSevereError(state, format("{} not found: {}", cAlphaFields(11), Alphas(11))); - ShowContinueError(state, format("Occurs in {} = {}", CurrentModuleObject, Alphas(1))); + // This may look like a weird thing to do, but it's equivalent to a nested if and also uses less nesting + if (lAlphaBlanks(11)) { + } else if ((thisCFloSys.hotCtrlHiTempSched = Sched::GetSchedule(state, Alphas(11))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(11), Alphas(11)); ErrorsFound = true; } - thisCFloSys.HotCtrlLoTempSched = Alphas(12); - thisCFloSys.HotCtrlLoTempSchedPtr = GetScheduleIndex(state, Alphas(12)); - if ((thisCFloSys.HotCtrlLoTempSchedPtr == 0) && (!lAlphaBlanks(12))) { - ShowSevereError(state, format("{} not found: {}", cAlphaFields(12), Alphas(12))); - ShowContinueError(state, format("Occurs in {} = {}", CurrentModuleObject, Alphas(1))); + if (lAlphaBlanks(12)) { + } else if ((thisCFloSys.hotCtrlLoTempSched = Sched::GetSchedule(state, Alphas(12))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(12), Alphas(12)); ErrorsFound = true; } @@ -1100,35 +1079,27 @@ namespace LowTempRadiantSystem { TestCompSet(state, CurrentModuleObject, Alphas(1), Alphas(13), Alphas(14), "Chilled Water Nodes"); } - thisCFloSys.ColdWaterHiTempSched = Alphas(15); - thisCFloSys.ColdWaterHiTempSchedPtr = GetScheduleIndex(state, Alphas(15)); - if ((thisCFloSys.ColdWaterHiTempSchedPtr == 0) && (!lAlphaBlanks(15))) { - ShowSevereError(state, format("{} not found: {}", cAlphaFields(15), Alphas(15))); - ShowContinueError(state, format("Occurs in {} = {}", CurrentModuleObject, Alphas(1))); + if (lAlphaBlanks(15)) { + } else if ((thisCFloSys.coldWaterHiTempSched = Sched::GetSchedule(state, Alphas(15))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(15), Alphas(15)); ErrorsFound = true; } - thisCFloSys.ColdWaterLoTempSched = Alphas(16); - thisCFloSys.ColdWaterLoTempSchedPtr = GetScheduleIndex(state, Alphas(16)); - if ((thisCFloSys.ColdWaterLoTempSchedPtr == 0) && (!lAlphaBlanks(16))) { - ShowSevereError(state, format("{} not found: {}", cAlphaFields(16), Alphas(16))); - ShowContinueError(state, format("Occurs in {} = {}", CurrentModuleObject, Alphas(1))); + if (lAlphaBlanks(16)) { + } else if ((thisCFloSys.coldWaterLoTempSched = Sched::GetSchedule(state, Alphas(16))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(16), Alphas(16)); ErrorsFound = true; } - thisCFloSys.ColdCtrlHiTempSched = Alphas(17); - thisCFloSys.ColdCtrlHiTempSchedPtr = GetScheduleIndex(state, Alphas(17)); - if ((thisCFloSys.ColdCtrlHiTempSchedPtr == 0) && (!lAlphaBlanks(17))) { - ShowSevereError(state, format("{} not found: {}", cAlphaFields(17), Alphas(17))); - ShowContinueError(state, format("Occurs in {} = {}", CurrentModuleObject, Alphas(1))); + if (lAlphaBlanks(17)) { + } else if ((thisCFloSys.coldCtrlHiTempSched = Sched::GetSchedule(state, Alphas(17))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(17), Alphas(17)); ErrorsFound = true; } - thisCFloSys.ColdCtrlLoTempSched = Alphas(18); - thisCFloSys.ColdCtrlLoTempSchedPtr = GetScheduleIndex(state, Alphas(18)); - if ((thisCFloSys.ColdCtrlLoTempSchedPtr == 0) && (!lAlphaBlanks(18))) { - ShowSevereError(state, format("{} not found: {}", cAlphaFields(19), Alphas(18))); - ShowContinueError(state, format("Occurs in {} = {}", CurrentModuleObject, Alphas(1))); + if (lAlphaBlanks(18)) { + } else if ((thisCFloSys.coldCtrlLoTempSched = Sched::GetSchedule(state, Alphas(18))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(18), Alphas(18)); ErrorsFound = true; } @@ -1140,7 +1111,7 @@ namespace LowTempRadiantSystem { thisCFloSys.NumCircCalcMethod = CircuitCalc::OneCircuit; } - thisCFloSys.schedPtrChangeoverDelay = ConstantFlowRadDesignDataObject.schedPtrChangeoverDelay; + thisCFloSys.changeoverDelaySched = ConstantFlowRadDesignDataObject.changeoverDelaySched; thisCFloSys.CircLength = Numbers(5); } @@ -1163,6 +1134,8 @@ namespace LowTempRadiantSystem { cAlphaFields, cNumericFields); + ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)}; + state.dataLowTempRadSys->ElecRadSysNumericFields(Item).FieldNames.allocate(NumNumbers); state.dataLowTempRadSys->ElecRadSysNumericFields(Item).FieldNames = ""; state.dataLowTempRadSys->ElecRadSysNumericFields(Item).FieldNames = cNumericFields; @@ -1178,16 +1151,11 @@ namespace LowTempRadiantSystem { thisElecSys.Name = Alphas(1); - thisElecSys.SchedName = Alphas(2); if (lAlphaBlanks(2)) { - thisElecSys.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - thisElecSys.SchedPtr = GetScheduleIndex(state, Alphas(2)); - if (thisElecSys.SchedPtr == 0) { - ShowSevereError(state, format("{} not found for{}", cAlphaFields(2), Alphas(1))); - ShowContinueError(state, format("Incorrect {} = {}", cAlphaFields(2), Alphas(2))); - ErrorsFound = true; - } + thisElecSys.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((thisElecSys.availSched = Sched::GetSchedule(state, Alphas(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(2), Alphas(2)); + ErrorsFound = true; } thisElecSys.ZoneName = Alphas(3); @@ -1318,15 +1286,11 @@ namespace LowTempRadiantSystem { thisElecSys.ThrottlRange = Numbers(4); - thisElecSys.SetptSched = Alphas(8); - thisElecSys.SetptSchedPtr = GetScheduleIndex(state, Alphas(8)); - if (thisElecSys.SetptSchedPtr == 0) { - if (lAlphaBlanks(8)) { - ShowSevereError(state, format("{} must be input, missing for {}", cAlphaFields(8), Alphas(1))); - } else { - ShowSevereError(state, format("{} not found for {}", cAlphaFields(8), Alphas(8))); - ShowContinueError(state, format("Incorrect {} = {}", cAlphaFields(8), Alphas(8))); - } + if (lAlphaBlanks(8)) { + ShowSevereEmptyField(state, eoh, cAlphaFields(8)); + ErrorsFound = true; + } else if ((thisElecSys.setptSched = Sched::GetSchedule(state, Alphas(8))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(8), Alphas(8)); ErrorsFound = true; } } @@ -1908,7 +1872,6 @@ namespace LowTempRadiantSystem { using PlantUtilities::InitComponentNodes; using PlantUtilities::ScanPlantLoopsForObject; using PlantUtilities::SetComponentFlowRate; - using ScheduleManager::GetCurrentScheduleValue; // SUBROUTINE PARAMETER DEFINITIONS: Real64 constexpr ZeroTol(0.0000001); // Smallest non-zero value allowed @@ -2144,25 +2107,25 @@ namespace LowTempRadiantSystem { SizeLowTempRadiantSystem(state, RadSysNum, SystemType); state.dataLowTempRadSys->MySizeFlagHydr(RadSysNum) = false; - int ColdSetptSchedPtr(0), HotSetptSchedPtr(0); + Sched::Schedule *coldSetptSched = nullptr, *hotSetptSched = nullptr; if (SystemType == LowTempRadiantSystem::SystemType::HydronicSystem) { VarFlowRadDesignData variableFlowDesignDataObject{state.dataLowTempRadSys->HydronicRadiantSysDesign( state.dataLowTempRadSys->HydrRadSys(RadSysNum).DesignObjectPtr)}; // Contains the data for variable flow hydronic systems; - ColdSetptSchedPtr = variableFlowDesignDataObject.ColdSetptSchedPtr; - HotSetptSchedPtr = variableFlowDesignDataObject.HotSetptSchedPtr; + coldSetptSched = variableFlowDesignDataObject.coolSetptSched; + hotSetptSched = variableFlowDesignDataObject.heatSetptSched; } // Can this system actually do cooling? if ((state.dataLowTempRadSys->HydrRadSys(RadSysNum).WaterVolFlowMaxCool > 0.0) && (state.dataLowTempRadSys->HydrRadSys(RadSysNum).ColdWaterInNode > 0) && - (state.dataLowTempRadSys->HydrRadSys(RadSysNum).ColdWaterOutNode > 0) && ColdSetptSchedPtr > 0) { + (state.dataLowTempRadSys->HydrRadSys(RadSysNum).ColdWaterOutNode > 0) && (coldSetptSched != nullptr)) { state.dataLowTempRadSys->HydrRadSys(RadSysNum).CoolingSystem = true; } // Can this system actually do heating? if ((state.dataLowTempRadSys->HydrRadSys(RadSysNum).WaterVolFlowMaxHeat > 0.0) && (state.dataLowTempRadSys->HydrRadSys(RadSysNum).HotWaterInNode > 0) && - (state.dataLowTempRadSys->HydrRadSys(RadSysNum).HotWaterOutNode > 0) && (HotSetptSchedPtr > 0)) { + (state.dataLowTempRadSys->HydrRadSys(RadSysNum).HotWaterOutNode > 0) && (hotSetptSched != nullptr)) { state.dataLowTempRadSys->HydrRadSys(RadSysNum).HeatingSystem = true; } @@ -2389,10 +2352,10 @@ namespace LowTempRadiantSystem { if ((state.dataLowTempRadSys->CFloRadSys(RadSysNum).WaterVolFlowMax > 0.0) && (state.dataLowTempRadSys->CFloRadSys(RadSysNum).HotWaterInNode > 0) && (state.dataLowTempRadSys->CFloRadSys(RadSysNum).HotWaterOutNode > 0) && - (state.dataLowTempRadSys->CFloRadSys(RadSysNum).HotWaterHiTempSchedPtr > 0) && - (state.dataLowTempRadSys->CFloRadSys(RadSysNum).HotWaterLoTempSchedPtr > 0) && - (state.dataLowTempRadSys->CFloRadSys(RadSysNum).HotCtrlHiTempSchedPtr > 0) && - (state.dataLowTempRadSys->CFloRadSys(RadSysNum).HotCtrlLoTempSchedPtr > 0)) { + (state.dataLowTempRadSys->CFloRadSys(RadSysNum).hotWaterHiTempSched != nullptr) && + (state.dataLowTempRadSys->CFloRadSys(RadSysNum).hotWaterLoTempSched != nullptr) && + (state.dataLowTempRadSys->CFloRadSys(RadSysNum).hotCtrlHiTempSched != nullptr) && + (state.dataLowTempRadSys->CFloRadSys(RadSysNum).hotCtrlLoTempSched != nullptr)) { state.dataLowTempRadSys->CFloRadSys(RadSysNum).HeatingSystem = true; } @@ -2400,10 +2363,10 @@ namespace LowTempRadiantSystem { if ((state.dataLowTempRadSys->CFloRadSys(RadSysNum).WaterVolFlowMax > 0.0) && (state.dataLowTempRadSys->CFloRadSys(RadSysNum).ColdWaterInNode > 0) && (state.dataLowTempRadSys->CFloRadSys(RadSysNum).ColdWaterOutNode > 0) && - (state.dataLowTempRadSys->CFloRadSys(RadSysNum).ColdWaterHiTempSchedPtr > 0) && - (state.dataLowTempRadSys->CFloRadSys(RadSysNum).ColdWaterLoTempSchedPtr > 0) && - (state.dataLowTempRadSys->CFloRadSys(RadSysNum).ColdCtrlHiTempSchedPtr > 0) && - (state.dataLowTempRadSys->CFloRadSys(RadSysNum).ColdCtrlLoTempSchedPtr > 0)) { + (state.dataLowTempRadSys->CFloRadSys(RadSysNum).coldWaterHiTempSched != nullptr) && + (state.dataLowTempRadSys->CFloRadSys(RadSysNum).coldWaterLoTempSched != nullptr) && + (state.dataLowTempRadSys->CFloRadSys(RadSysNum).coldCtrlHiTempSched != nullptr) && + (state.dataLowTempRadSys->CFloRadSys(RadSysNum).coldCtrlLoTempSched != nullptr)) { state.dataLowTempRadSys->CFloRadSys(RadSysNum).CoolingSystem = true; } } @@ -2478,8 +2441,8 @@ namespace LowTempRadiantSystem { state.dataLowTempRadSys->CFloRadSys(RadSysNum).WaterMassFlowRate = 0.0; // Initialize the appropriate node data if (state.dataLowTempRadSys->CFloRadSys(RadSysNum).HeatingSystem) { - if (state.dataLowTempRadSys->CFloRadSys(RadSysNum).VolFlowSchedPtr > 0) { - CurrentFlowSchedule = GetCurrentScheduleValue(state, state.dataLowTempRadSys->CFloRadSys(RadSysNum).VolFlowSchedPtr); + if (state.dataLowTempRadSys->CFloRadSys(RadSysNum).volFlowSched != nullptr) { + CurrentFlowSchedule = state.dataLowTempRadSys->CFloRadSys(RadSysNum).volFlowSched->getCurrentVal(); } else { CurrentFlowSchedule = 1.0; // Allow user to avoid putting in a schedule (defaults to constant flow at all times) } @@ -2501,8 +2464,8 @@ namespace LowTempRadiantSystem { state.dataLowTempRadSys->CFloRadSys(RadSysNum).HWPlantLoc); } if (state.dataLowTempRadSys->CFloRadSys(RadSysNum).CoolingSystem) { - if (state.dataLowTempRadSys->CFloRadSys(RadSysNum).VolFlowSchedPtr > 0) { - CurrentFlowSchedule = GetCurrentScheduleValue(state, state.dataLowTempRadSys->CFloRadSys(RadSysNum).VolFlowSchedPtr); + if (state.dataLowTempRadSys->CFloRadSys(RadSysNum).volFlowSched != nullptr) { + CurrentFlowSchedule = state.dataLowTempRadSys->CFloRadSys(RadSysNum).volFlowSched->getCurrentVal(); } else { CurrentFlowSchedule = 1.0; // Allow user to avoid putting in a schedule (defaults to constant flow at all times) } @@ -2548,8 +2511,8 @@ namespace LowTempRadiantSystem { // So, the day should be the previous day, the hour should bethe last hour of the // day, and the time step should be the last time step. this->lastDayOfSim = state.dataGlobal->DayOfSim - 1; - this->lastHourOfDay = int(Constant::HoursInDay); - this->lastTimeStep = state.dataGlobal->NumOfTimeStepInHour; + this->lastHourOfDay = Constant::iHoursInDay; + this->lastTimeStep = state.dataGlobal->TimeStepsInHour; } else if (state.dataGlobal->BeginHourFlag) { // It's not the beginning of the day but it is the beginning of an hour other than // the first hour. This means that the previous time step was the previous hour of @@ -2557,7 +2520,7 @@ namespace LowTempRadiantSystem { // be the previous hour, and the time step should be the last time step. this->lastDayOfSim = state.dataGlobal->DayOfSim; this->lastHourOfDay = state.dataGlobal->HourOfDay - 1; - this->lastTimeStep = state.dataGlobal->NumOfTimeStepInHour; + this->lastTimeStep = state.dataGlobal->TimeStepsInHour; } else if (state.dataGlobal->BeginTimeStepFlag) { // It's neither the beginning of the day nor the beginning of an hour but it is the start // of a time step other than the first time step in the hour. So, the day should be the @@ -2589,17 +2552,17 @@ namespace LowTempRadiantSystem { if (this->OperatingMode == this->lastOperatingMode) return; // always let it continue to operating in the same mode - if (this->schedPtrChangeoverDelay == 0) return; // user not requesting any delays (no schedule entered) so let it do whatever is requested + if (this->changeoverDelaySched == nullptr) return; // user not requesting any delays (no schedule entered) so let it do whatever is requested - Real64 currentChangeoverDelay = ScheduleManager::GetCurrentScheduleValue(state, this->schedPtrChangeoverDelay); + Real64 currentChangeoverDelay = this->changeoverDelaySched->getCurrentVal(); if (currentChangeoverDelay <= 0.0) return; // delay is zero so let it do whatever it requested // At this point, the radiant system is trying to switch modes from the previous time step, the user is requesting a delay in the changeover, // and the requested delay is greater than zero. Calculate what the current time is in hours from the start of the simulation Real64 timeCurrent = 24.0 * float(state.dataGlobal->DayOfSim - 1) + float(state.dataGlobal->HourOfDay - 1) + - float(state.dataGlobal->TimeStep - 1) / float(state.dataGlobal->NumOfTimeStepInHour); + float(state.dataGlobal->TimeStep - 1) / float(state.dataGlobal->TimeStepsInHour); Real64 timeLast = 24.0 * float(this->lastDayOfSim - 1) + float(this->lastHourOfDay - 1) + - float(this->lastTimeStep - 1) / float(state.dataGlobal->NumOfTimeStepInHour); + float(this->lastTimeStep - 1) / float(state.dataGlobal->TimeStepsInHour); Real64 actualTimeDifference = timeCurrent - timeLast; // If the time difference is not longer than the user delay, then the system should not switch modes and needs to be turned off. @@ -3532,7 +3495,6 @@ namespace LowTempRadiantSystem { using DataHeatBalance::ZoneData; using HVAC::SmallLoad; using PlantUtilities::SetComponentFlowRate; - using ScheduleManager::GetCurrentScheduleValue; // SUBROUTINE LOCAL VARIABLE DECLARATIONS: Real64 ActWaterFlow; // actual water flow for heating or cooling [kg/sec] @@ -3560,7 +3522,7 @@ namespace LowTempRadiantSystem { this->OperatingMode = NotOperating; SysRunning = true; - if (GetCurrentScheduleValue(state, this->SchedPtr) <= 0) { + if (this->availSched->getCurrentVal() <= 0) { // Unit is off or has no load upon it; set the flow rates to zero and then // simulate the components with the no flow conditions @@ -3583,21 +3545,21 @@ namespace LowTempRadiantSystem { ControlTemp = this->setRadiantSystemControlTemperature(state, variableFlowDesignDataObject.VarFlowControlType); - if (variableFlowDesignDataObject.HotSetptSchedPtr > 0) { + if (variableFlowDesignDataObject.heatSetptSched != nullptr) { // OffTempHeat = this->setOffTemperatureLowTemperatureRadiantSystem(state, this->HotSetptSchedPtr, // this->HotThrottlRange); Real64 a; - a = variableFlowDesignDataObject.HotThrottlRange; + a = variableFlowDesignDataObject.HotThrottlRange; // Why are we doing this? OffTempHeat = this->setOffTemperatureLowTemperatureRadiantSystem(state, - variableFlowDesignDataObject.HotSetptSchedPtr, + variableFlowDesignDataObject.heatSetptSched, variableFlowDesignDataObject.HotThrottlRange, variableFlowDesignDataObject.VarFlowSetpointType); } else { // This system is not capable of heating, set OffTempHeat to something really low OffTempHeat = state.dataLowTempRadSys->LowTempHeating; } - if (variableFlowDesignDataObject.ColdSetptSchedPtr > 0) { + if (variableFlowDesignDataObject.coolSetptSched != nullptr) { OffTempCool = this->setOffTemperatureLowTemperatureRadiantSystem(state, - variableFlowDesignDataObject.ColdSetptSchedPtr, + variableFlowDesignDataObject.coolSetptSched, -variableFlowDesignDataObject.ColdThrottlRange, variableFlowDesignDataObject.VarFlowSetpointType); } else { // This system is not capable of cooling, set OffTempCool to something really high @@ -4183,7 +4145,6 @@ namespace LowTempRadiantSystem { using FluidProperties::GetSpecificHeatGlycol; using HVAC::SmallLoad; using PlantUtilities::SetComponentFlowRate; - using ScheduleManager::GetCurrentScheduleValue; // SUBROUTINE PARAMETER DEFINITIONS: Real64 constexpr LowCpFluidValue(100.0); // lowest allowed Cp fluid value (to avoid dividing by zero) [J/kg-K] @@ -4220,7 +4181,7 @@ namespace LowTempRadiantSystem { SysRunning = true; // default to running and turn off only if not running state.dataLowTempRadSys->VarOffCond = false; - if (GetCurrentScheduleValue(state, this->SchedPtr) <= 0) SysRunning = false; + if (this->availSched->getCurrentVal() <= 0) SysRunning = false; if (SysRunning) { // Unit is probably on-->this section is intended to control the water // mass flow rate being sent to the radiant system @@ -4230,13 +4191,13 @@ namespace LowTempRadiantSystem { SetPointTemp = this->setRadiantSystemControlTemperature(state, ConstantFlowDesignDataObject.ConstFlowControlType); // Avoid problems when there is no heating or cooling control because the system only cools or heats - if (this->HotCtrlHiTempSchedPtr > 0) { - OffTempHeat = GetCurrentScheduleValue(state, this->HotCtrlHiTempSchedPtr); + if (this->hotCtrlHiTempSched != nullptr) { + OffTempHeat = this->hotCtrlHiTempSched->getCurrentVal(); } else { OffTempHeat = state.dataLowTempRadSys->LowTempHeating; } - if (this->ColdCtrlLoTempSchedPtr > 0) { - OffTempCool = GetCurrentScheduleValue(state, this->ColdCtrlLoTempSchedPtr); + if (this->coldCtrlLoTempSched != nullptr) { + OffTempCool = this->coldCtrlLoTempSched->getCurrentVal(); } else { OffTempCool = state.dataLowTempRadSys->HighTempCooling; } @@ -4260,16 +4221,16 @@ namespace LowTempRadiantSystem { } else { // It is a heating system so set all of the values for controls - SetPointTempHi = GetCurrentScheduleValue(state, this->HotCtrlHiTempSchedPtr); - SetPointTempLo = GetCurrentScheduleValue(state, this->HotCtrlLoTempSchedPtr); + SetPointTempHi = this->hotCtrlHiTempSched->getCurrentVal(); + SetPointTempLo = this->hotCtrlLoTempSched->getCurrentVal(); if (SetPointTempHi < SetPointTempLo) { ShowSevereError(state, format("Heating setpoint temperature mismatch in{}", this->Name)); ShowContinueError(state, "High setpoint temperature is less than low setpoint temperature--check your schedule input"); ShowFatalError(state, "Preceding condition causes termination."); } - WaterTempHi = GetCurrentScheduleValue(state, this->HotWaterHiTempSchedPtr); - WaterTempLo = GetCurrentScheduleValue(state, this->HotWaterLoTempSchedPtr); + WaterTempHi = this->hotWaterHiTempSched->getCurrentVal(); + WaterTempLo = this->hotWaterLoTempSched->getCurrentVal(); if (WaterTempHi < WaterTempLo) { ShowSevereError(state, format("Heating water temperature mismatch in{}", this->Name)); ShowContinueError(state, "High water temperature is less than low water temperature--check your schedule input"); @@ -4299,16 +4260,16 @@ namespace LowTempRadiantSystem { } else { // It is a cooling system so set all of the values for controls - SetPointTempHi = GetCurrentScheduleValue(state, this->ColdCtrlHiTempSchedPtr); - SetPointTempLo = GetCurrentScheduleValue(state, this->ColdCtrlLoTempSchedPtr); + SetPointTempHi = this->coldCtrlHiTempSched->getCurrentVal(); + SetPointTempLo = this->coldCtrlLoTempSched->getCurrentVal(); if (SetPointTempHi < SetPointTempLo) { ShowSevereError(state, format("Cooling setpoint temperature mismatch in{}", this->Name)); ShowContinueError(state, "High setpoint temperature is less than low setpoint temperature--check your schedule input"); ShowFatalError(state, "Preceding condition causes termination."); } - WaterTempHi = GetCurrentScheduleValue(state, this->ColdWaterHiTempSchedPtr); - WaterTempLo = GetCurrentScheduleValue(state, this->ColdWaterLoTempSchedPtr); + WaterTempHi = this->coldWaterHiTempSched->getCurrentVal(); + WaterTempLo = this->coldWaterLoTempSched->getCurrentVal(); if (WaterTempHi < WaterTempLo) { ShowSevereError(state, format("Cooling water temperature mismatch in{}", this->Name)); ShowContinueError(state, "High water temperature is less than low water temperature--check your schedule input"); @@ -4373,11 +4334,8 @@ namespace LowTempRadiantSystem { // Determine pump flow rate and pump heat addition this->PumpMassFlowRate = this->WaterMassFlowRate; // Set in InitLowTempRadiantSystem - if (this->VolFlowSchedPtr > 0) { - PumpPartLoadRat = GetCurrentScheduleValue(state, this->VolFlowSchedPtr); - } else { - PumpPartLoadRat = 1.0; - } + PumpPartLoadRat = (this->volFlowSched != nullptr) ? this->volFlowSched->getCurrentVal() : 1.0; + this->PumpPower = PumpPartLoadRat * this->NomPowerUse; ShaftPower = this->PumpPower * ConstantFlowDesignDataObject.MotorEffic; // This adds the pump heat based on User input for the pump (same as in Pump module) @@ -5183,12 +5141,12 @@ namespace LowTempRadiantSystem { Real64 ConstantFlowRadiantSystemData::calculateCurrentDailyAverageODB(EnergyPlusData &state) { Real64 sum = 0.0; - for (int hourNumber = 1; hourNumber <= Constant::HoursInDay; ++hourNumber) { - for (int timeStepNumber = 1; timeStepNumber <= state.dataGlobal->NumOfTimeStepInHour; ++timeStepNumber) { + for (int hourNumber = 1; hourNumber <= Constant::iHoursInDay; ++hourNumber) { + for (int timeStepNumber = 1; timeStepNumber <= state.dataGlobal->TimeStepsInHour; ++timeStepNumber) { sum += state.dataWeather->wvarsHrTsToday(timeStepNumber, hourNumber).OutDryBulbTemp; } } - return sum / double(Constant::HoursInDay * state.dataGlobal->NumOfTimeStepInHour); + return sum / (Constant::rHoursInDay * state.dataGlobal->TimeStepsInHour); } void ElectricRadiantSystemData::calculateLowTemperatureRadiantSystem(EnergyPlusData &state, @@ -5224,7 +5182,6 @@ namespace LowTempRadiantSystem { // Using/Aliasing using DataHeatBalance::ZoneData; using HVAC::SmallLoad; - using ScheduleManager::GetCurrentScheduleValue; // SUBROUTINE LOCAL VARIABLE DECLARATIONS: Real64 ControlTemp; // Temperature of the parameter that is controlling the radiant system @@ -5239,7 +5196,7 @@ namespace LowTempRadiantSystem { HeatFrac = 0.0; auto &Surface = state.dataSurface->Surface; - if (GetCurrentScheduleValue(state, this->SchedPtr) <= 0.0) { + if (this->availSched->getCurrentVal() <= 0.0) { // Unit is off; set the heat source terms to zero for (RadSurfNum = 1; RadSurfNum <= this->NumOfSurfaces; ++RadSurfNum) { @@ -5253,7 +5210,7 @@ namespace LowTempRadiantSystem { // that the unit should be on or not // Determine the current setpoint temperature and the temperature at which the unit should be completely off - OffTemp = this->setOffTemperatureLowTemperatureRadiantSystem(state, this->SetptSchedPtr, this->ThrottlRange, this->SetpointType); + OffTemp = this->setOffTemperatureLowTemperatureRadiantSystem(state, this->setptSched, this->ThrottlRange, this->SetpointType); // Determine the control temperature--what the setpoint/offtemp is being compared to for unit operation @@ -5590,11 +5547,11 @@ namespace LowTempRadiantSystem { } Real64 RadiantSystemBaseData::setOffTemperatureLowTemperatureRadiantSystem(EnergyPlusData &state, - const int scheduleIndex, + Sched::Schedule const *sched, const Real64 throttlingRange, LowTempRadiantSetpointTypes SetpointControlType) { - Real64 scheduleValue = ScheduleManager::GetCurrentScheduleValue(state, scheduleIndex); + Real64 scheduleValue = sched->getCurrentVal(); switch (SetpointControlType) { case LowTempRadiantSetpointTypes::HalfFlowPower: return scheduleValue + 0.5 * throttlingRange; diff --git a/src/EnergyPlus/LowTempRadiantSystem.hh b/src/EnergyPlus/LowTempRadiantSystem.hh index 6ce58b4c4ab..9bb35dffefe 100644 --- a/src/EnergyPlus/LowTempRadiantSystem.hh +++ b/src/EnergyPlus/LowTempRadiantSystem.hh @@ -140,8 +140,7 @@ namespace LowTempRadiantSystem { { // Members std::string Name; // name of hydronic radiant system - std::string SchedName; // availability schedule - int SchedPtr = 0; // index to schedule + Sched::Schedule *availSched = nullptr; // index to schedule std::string ZoneName; // Name of zone the system is serving int ZonePtr = 0; // Point to this zone in the Zone derived type std::string SurfListName; // Name of surface/surface list that is the radiant system @@ -188,7 +187,7 @@ namespace LowTempRadiantSystem { virtual void calculateLowTemperatureRadiantSystem(EnergyPlusData &state, Real64 &LoadMet) = 0; Real64 setOffTemperatureLowTemperatureRadiantSystem(EnergyPlusData &state, - int const scheduleIndex, + Sched::Schedule const *sched, Real64 const throttlingRange, LowTempRadiantSetpointTypes SetpointControlType); @@ -223,8 +222,7 @@ namespace LowTempRadiantSystem { CircuitCalc NumCircCalcMethod = CircuitCalc::Invalid; // Calculation method for number of circuits per surface; 1=1 per surface, 2=use cicuit length Real64 CircLength = 0.0; // Circuit length {m} - std::string schedNameChangeoverDelay; // changeover delay schedule - int schedPtrChangeoverDelay = 0; // Pointer to the schedule for the changeover delay in hours + Sched::Schedule *changeoverDelaySched = nullptr; // schedule for the changeover delay in hours int lastOperatingMode = NotOperating; // Last mode of operation (heating or cooling) int lastDayOfSim = 1; // Last day of simulation radiant system operated in lastOperatingMode int lastHourOfDay = 1; // Last hour of the day radiant system operated in lastOperatingMode @@ -330,14 +328,12 @@ namespace LowTempRadiantSystem { 0.0; // - Low Temp Radiant system scaled maximum heating capacity {W} or scalable variable of zone HVAC equipment, // {-}, or {W/m2} Real64 HotThrottlRange = 0.0; // Throttling range for heating [C] - std::string HotSetptSched; // Schedule name for the zone setpoint temperature - int HotSetptSchedPtr = 0; // Schedule index for the zone setpoint temperature + Sched::Schedule *heatSetptSched = nullptr; // Schedule index for the zone setpoint temperature Real64 ColdThrottlRange = 0.0; // Throttling range for cooling [C] Array1D_string FieldNames; CondContrlType CondCtrlType = CondContrlType::CondCtrlSimpleOff; // Condensation control type (initialize to simple off) Real64 CondDewPtDeltaT = 1.0; // Diff between surface temperature and dew point for cond. shut-off - std::string ColdSetptSched; // Schedule name for the zone setpoint temperature - int ColdSetptSchedPtr = 0; // Schedule index for the zone setpoint temperature + Sched::Schedule *coolSetptSched = nullptr; // Schedule index for the zone setpoint temperature std::string DesignCoolingCapMethodInput; int DesignCoolingCapMethod = 0; // - Method for Low Temp Radiant system cooling capacity scaledsizing calculation (CoolingDesignCapacity, // CapacityPerFloorArea, FracOfAutosizedCoolingCapacity) @@ -359,36 +355,23 @@ namespace LowTempRadiantSystem { Real64 WaterMassFlowRate = 0.0; // current flow rate through system (calculated) Real64 HotWaterMassFlowRate = 0.0; // current hot water flow rate through heating side of system (calculated) Real64 ChWaterMassFlowRate = 0.0; // current chilled water flow rate through cooling side of system (calculated) - std::string VolFlowSched; // schedule of maximum flow at the current time std::string designObjectName; // Design Object int DesignObjectPtr = 0; - int VolFlowSchedPtr = 0; // index to the volumetric flow schedule + Sched::Schedule *volFlowSched = nullptr; // index to the volumetric flow schedule Real64 NomPumpHead = 0.0; // nominal head of the constant flow pump Real64 NomPowerUse = 0.0; // nominal power use of the constant flow pump Real64 PumpEffic = 0.0; // overall efficiency of the pump (calculated) - std::string HotWaterHiTempSched; // Schedule name for the highest water temperature - int HotWaterHiTempSchedPtr = 0; // Schedule index for the highest water temperature - std::string HotWaterLoTempSched; // Schedule name for the lowest water temperature - int HotWaterLoTempSchedPtr = 0; // Schedule index for the lowest water temperature - std::string HotCtrlHiTempSched; // Schedule name for the highest control temperature + Sched::Schedule *hotWaterHiTempSched = nullptr; // Schedule for the highest water temperature + Sched::Schedule *hotWaterLoTempSched = nullptr; // Schedule for the lowest water temperature + Sched::Schedule *hotCtrlHiTempSched = nullptr; // Schedule for the highest control temperature // (where the lowest water temperature is requested) - int HotCtrlHiTempSchedPtr = 0; // Schedule index for the highest control temperature - // (where the lowest water temperature is requested) - std::string HotCtrlLoTempSched; // Schedule name for the lowest control temperature - // (where the highest water temperature is requested) - int HotCtrlLoTempSchedPtr = 0; // Schedule index for the lowest control temperature + Sched::Schedule *hotCtrlLoTempSched = nullptr; // Schedule for the lowest control temperature // (where the highest water temperature is requested) - std::string ColdWaterHiTempSched; // Schedule name for the highest water temperature - int ColdWaterHiTempSchedPtr = 0; // Schedule index for the highest water temperature - std::string ColdWaterLoTempSched; // Schedule name for the lowest water temperature - int ColdWaterLoTempSchedPtr = 0; // Schedule index for the lowest water temperature - std::string ColdCtrlHiTempSched; // Schedule name for the highest control temperature + Sched::Schedule *coldWaterHiTempSched = nullptr; // Schedule for the highest water temperature + Sched::Schedule *coldWaterLoTempSched = nullptr; // Schedule for the lowest water temperature + Sched::Schedule *coldCtrlHiTempSched = nullptr; // Schedule for the highest control temperature // (where the lowest water temperature is requested) - int ColdCtrlHiTempSchedPtr = 0; // Schedule index for the highest control temperature - // (where the lowest water temperature is requested) - std::string ColdCtrlLoTempSched; // Schedule name for the lowest control temperature - // (where the highest water temperature is requested) - int ColdCtrlLoTempSchedPtr = 0; // Schedule index for the lowest control temperature + Sched::Schedule *coldCtrlLoTempSched = nullptr; // Schedule for the lowest control temperature // (where the highest water temperature is requested) Real64 WaterInjectionRate = 0.0; // water injection mass flow rate from main loop Real64 WaterRecircRate = 0.0; // water recirculation rate (outlet from radiant system recirculated) @@ -456,8 +439,7 @@ namespace LowTempRadiantSystem { // Input data Real64 MaxElecPower = 0.0; // Maximum electric power that can be supplied to surface, Watts Real64 ThrottlRange = 0.0; // Throttling range for heating [C] - std::string SetptSched; // Schedule name for the zone setpoint temperature - int SetptSchedPtr = 0; // Schedule index for the zone setpoint temperature + Sched::Schedule *setptSched = nullptr; // Schedule for the zone setpoint temperature // Other parameters // Report data Real64 ElecPower = 0.0; // heating sent to panel in Watts @@ -600,6 +582,10 @@ struct LowTempRadiantSystemData : BaseGlobalStruct Array1D CflowRadiantSysDesign; Array1D HydronicRadiantSysDesign; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/Material.cc b/src/EnergyPlus/Material.cc index 812ec2f07d9..9441d8fd497 100644 --- a/src/EnergyPlus/Material.cc +++ b/src/EnergyPlus/Material.cc @@ -485,8 +485,7 @@ void GetMaterialData(EnergyPlusData &state, bool &ErrorsFound) // set to true if if (mat->windowOpticalData == Window::OpticalDataModel::Spectral) { if (s_ipsc->lAlphaFieldBlanks(3)) { - ShowSevereCustomMessage( - state, eoh, format("{} = Spectral but {} is blank.", s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaFieldNames(3))); + ShowSevereCustom(state, eoh, format("{} = Spectral but {} is blank.", s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaFieldNames(3))); ErrorsFound = true; } else if ((mat->GlassSpectralDataPtr = Util::FindItemInList(s_ipsc->cAlphaArgs(3), s_mat->SpectralData)) == 0) { ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(3), s_ipsc->cAlphaArgs(3)); @@ -499,82 +498,82 @@ void GetMaterialData(EnergyPlusData &state, bool &ErrorsFound) // set to true if if (s_ipsc->rNumericArgs(2) + s_ipsc->rNumericArgs(3) > 1.0) { ErrorsFound = true; - ShowSevereCustomMessage(state, eoh, format("{} + {} not <= 1.0", s_ipsc->cNumericFieldNames(2), s_ipsc->cNumericFieldNames(3))); + ShowSevereCustom(state, eoh, format("{} + {} not <= 1.0", s_ipsc->cNumericFieldNames(2), s_ipsc->cNumericFieldNames(3))); } if (s_ipsc->rNumericArgs(2) + s_ipsc->rNumericArgs(4) > 1.0) { ErrorsFound = true; - ShowSevereCustomMessage(state, eoh, format("{} + {} not <= 1.0", s_ipsc->cNumericFieldNames(2), s_ipsc->cNumericFieldNames(4))); + ShowSevereCustom(state, eoh, format("{} + {} not <= 1.0", s_ipsc->cNumericFieldNames(2), s_ipsc->cNumericFieldNames(4))); } if (s_ipsc->rNumericArgs(5) + s_ipsc->rNumericArgs(6) > 1.0) { ErrorsFound = true; - ShowSevereCustomMessage(state, eoh, format("{} + {} not <= 1.0", s_ipsc->cNumericFieldNames(5), s_ipsc->cNumericFieldNames(6))); + ShowSevereCustom(state, eoh, format("{} + {} not <= 1.0", s_ipsc->cNumericFieldNames(5), s_ipsc->cNumericFieldNames(6))); } if (s_ipsc->rNumericArgs(5) + s_ipsc->rNumericArgs(7) > 1.0) { ErrorsFound = true; - ShowSevereCustomMessage(state, eoh, format("{} + {} not <= 1.0", s_ipsc->cNumericFieldNames(5), s_ipsc->cNumericFieldNames(7))); + ShowSevereCustom(state, eoh, format("{} + {} not <= 1.0", s_ipsc->cNumericFieldNames(5), s_ipsc->cNumericFieldNames(7))); } if (s_ipsc->rNumericArgs(8) + s_ipsc->rNumericArgs(9) > 1.0) { ErrorsFound = true; - ShowSevereCustomMessage(state, eoh, format("{} + {} not <= 1.0", s_ipsc->cNumericFieldNames(8), s_ipsc->cNumericFieldNames(9))); + ShowSevereCustom(state, eoh, format("{} + {} not <= 1.0", s_ipsc->cNumericFieldNames(8), s_ipsc->cNumericFieldNames(9))); } if (s_ipsc->rNumericArgs(8) + s_ipsc->rNumericArgs(10) > 1.0) { ErrorsFound = true; - ShowSevereCustomMessage(state, eoh, format("{} + {} not <= 1.0", s_ipsc->cNumericFieldNames(8), s_ipsc->cNumericFieldNames(10))); + ShowSevereCustom(state, eoh, format("{} + {} not <= 1.0", s_ipsc->cNumericFieldNames(8), s_ipsc->cNumericFieldNames(10))); } if (s_ipsc->rNumericArgs(2) < 0.0) { - ShowSevereCustomMessage(state, eoh, format("{} not >= 0.0", s_ipsc->cNumericFieldNames(2))); + ShowSevereCustom(state, eoh, format("{} not >= 0.0", s_ipsc->cNumericFieldNames(2))); ErrorsFound = true; } if (s_ipsc->rNumericArgs(2) > 1.0) { ErrorsFound = true; - ShowSevereCustomMessage(state, eoh, format("{} not <= 1.0", s_ipsc->cNumericFieldNames(2))); + ShowSevereCustom(state, eoh, format("{} not <= 1.0", s_ipsc->cNumericFieldNames(2))); } if (s_ipsc->rNumericArgs(3) < 0.0 || s_ipsc->rNumericArgs(3) > 1.0) { ErrorsFound = true; - ShowSevereCustomMessage(state, eoh, format("{} not >= 0.0 and <= 1.0", s_ipsc->cNumericFieldNames(3))); + ShowSevereCustom(state, eoh, format("{} not >= 0.0 and <= 1.0", s_ipsc->cNumericFieldNames(3))); } if (s_ipsc->rNumericArgs(4) < 0.0 || s_ipsc->rNumericArgs(4) > 1.0) { ErrorsFound = true; - ShowSevereCustomMessage(state, eoh, format("{} not >= 0.0 and <= 1.0", s_ipsc->cNumericFieldNames(4))); + ShowSevereCustom(state, eoh, format("{} not >= 0.0 and <= 1.0", s_ipsc->cNumericFieldNames(4))); } if (s_ipsc->rNumericArgs(5) < 0.0) { - ShowWarningCustomMessage(state, eoh, format("{} not >= 0.0", s_ipsc->cNumericFieldNames(5))); + ShowWarningCustom(state, eoh, format("{} not >= 0.0", s_ipsc->cNumericFieldNames(5))); } if (s_ipsc->rNumericArgs(5) > 1.0) { ErrorsFound = true; - ShowSevereCustomMessage(state, eoh, format("{} not <= 1.0", s_ipsc->cNumericFieldNames(5))); + ShowSevereCustom(state, eoh, format("{} not <= 1.0", s_ipsc->cNumericFieldNames(5))); } if (s_ipsc->rNumericArgs(6) < 0.0 || s_ipsc->rNumericArgs(6) > 1.0) { ErrorsFound = true; - ShowSevereCustomMessage(state, eoh, format("{} not >= 0.0 and <= 1.0", s_ipsc->cNumericFieldNames(6))); + ShowSevereCustom(state, eoh, format("{} not >= 0.0 and <= 1.0", s_ipsc->cNumericFieldNames(6))); } if (s_ipsc->rNumericArgs(7) < 0.0 || s_ipsc->rNumericArgs(7) > 1.0) { ErrorsFound = true; - ShowSevereCustomMessage(state, eoh, format("{} not >= 0.0 and <= 1.0", s_ipsc->cNumericFieldNames(7))); + ShowSevereCustom(state, eoh, format("{} not >= 0.0 and <= 1.0", s_ipsc->cNumericFieldNames(7))); } } if (s_ipsc->rNumericArgs(8) > 1.0) { ErrorsFound = true; - ShowSevereCustomMessage(state, eoh, format("{} not <= 1.0", s_ipsc->cNumericFieldNames(8))); + ShowSevereCustom(state, eoh, format("{} not <= 1.0", s_ipsc->cNumericFieldNames(8))); } if (s_ipsc->rNumericArgs(9) <= 0.0 || s_ipsc->rNumericArgs(9) >= 1.0) { ErrorsFound = true; - ShowSevereCustomMessage(state, eoh, format("{} not > 0.0 and < 1.0", s_ipsc->cNumericFieldNames(9))); + ShowSevereCustom(state, eoh, format("{} not > 0.0 and < 1.0", s_ipsc->cNumericFieldNames(9))); } if (s_ipsc->rNumericArgs(10) <= 0.0 || s_ipsc->rNumericArgs(10) >= 1.0) { @@ -585,17 +584,17 @@ void GetMaterialData(EnergyPlusData &state, bool &ErrorsFound) // set to true if if (s_ipsc->rNumericArgs(11) <= 0.0) { ErrorsFound = true; - ShowSevereCustomMessage(state, eoh, format("{} not > 0.0", s_ipsc->cNumericFieldNames(11))); + ShowSevereCustom(state, eoh, format("{} not > 0.0", s_ipsc->cNumericFieldNames(11))); } if (s_ipsc->rNumericArgs(13) < 0.0) { ErrorsFound = true; - ShowSevereCustomMessage(state, eoh, format("{} not > 0.0", s_ipsc->cNumericFieldNames(13))); + ShowSevereCustom(state, eoh, format("{} not > 0.0", s_ipsc->cNumericFieldNames(13))); } if (s_ipsc->rNumericArgs(14) < 0.0 || s_ipsc->rNumericArgs(14) >= 1.0) { ErrorsFound = true; - ShowSevereCustomMessage(state, eoh, format("{} not > 0.0 and < 1.0", s_ipsc->cNumericFieldNames(14))); + ShowSevereCustom(state, eoh, format("{} not > 0.0 and < 1.0", s_ipsc->cNumericFieldNames(14))); } if (s_ipsc->cAlphaArgs(4) == "") { @@ -631,7 +630,7 @@ void GetMaterialData(EnergyPlusData &state, bool &ErrorsFound) // set to true if GetCurveMinMaxValues(state, mat->GlassSpecAngTransDataPtr, minAngValue, maxAngValue, minLamValue, maxLamValue); if (minAngValue > 1.0e-6) { ErrorsFound = true; - ShowSevereCustomMessage(state, + ShowSevereCustom(state, eoh, format("{} requires the minumum value = 0.0 in the entered table name={}", s_ipsc->cAlphaFieldNames(5), @@ -640,7 +639,7 @@ void GetMaterialData(EnergyPlusData &state, bool &ErrorsFound) // set to true if if (std::abs(maxAngValue - 90.0) > 1.0e-6) { ErrorsFound = true; - ShowSevereCustomMessage(state, + ShowSevereCustom(state, eoh, format("{} requires the maximum value = 90.0 in the entered table name={}", s_ipsc->cAlphaFieldNames(5), @@ -649,7 +648,7 @@ void GetMaterialData(EnergyPlusData &state, bool &ErrorsFound) // set to true if if (minLamValue < 0.1) { ErrorsFound = true; - ShowSevereCustomMessage(state, + ShowSevereCustom(state, eoh, format("{} requires the minumum value = 0.1 micron in the entered table name={}", s_ipsc->cAlphaFieldNames(5), @@ -658,7 +657,7 @@ void GetMaterialData(EnergyPlusData &state, bool &ErrorsFound) // set to true if if (maxLamValue > 4.0) { ErrorsFound = true; - ShowSevereCustomMessage(state, + ShowSevereCustom(state, eoh, format("{} requires the maximum value = 4.0 microns in the entered table name={}", s_ipsc->cAlphaFieldNames(5), @@ -684,7 +683,7 @@ void GetMaterialData(EnergyPlusData &state, bool &ErrorsFound) // set to true if GetCurveMinMaxValues(state, mat->GlassSpecAngFRefleDataPtr, minAngValue, maxAngValue, minLamValue, maxLamValue); if (minAngValue > 1.0e-6) { ErrorsFound = true; - ShowSevereCustomMessage(state, + ShowSevereCustom(state, eoh, format("{} requires the minumum value = 0.0 in the entered table name={}", s_ipsc->cAlphaFieldNames(5), @@ -692,7 +691,7 @@ void GetMaterialData(EnergyPlusData &state, bool &ErrorsFound) // set to true if } if (std::abs(maxAngValue - 90.0) > 1.0e-6) { ErrorsFound = true; - ShowSevereCustomMessage(state, + ShowSevereCustom(state, eoh, format("{} requires the maximum value = 90.0 in the entered table name={}", s_ipsc->cAlphaFieldNames(5), @@ -700,7 +699,7 @@ void GetMaterialData(EnergyPlusData &state, bool &ErrorsFound) // set to true if } if (minLamValue < 0.1) { ErrorsFound = true; - ShowSevereCustomMessage(state, + ShowSevereCustom(state, eoh, format("{} requires the minumum value = 0.1 micron in the entered table name={}", s_ipsc->cAlphaFieldNames(5), @@ -708,7 +707,7 @@ void GetMaterialData(EnergyPlusData &state, bool &ErrorsFound) // set to true if } if (maxLamValue > 4.0) { ErrorsFound = true; - ShowSevereCustomMessage(state, + ShowSevereCustom(state, eoh, format("{} requires the maximum value = 4.0 microns in the entered table name={}", s_ipsc->cAlphaFieldNames(5), @@ -734,7 +733,7 @@ void GetMaterialData(EnergyPlusData &state, bool &ErrorsFound) // set to true if GetCurveMinMaxValues(state, mat->GlassSpecAngBRefleDataPtr, minAngValue, maxAngValue, minLamValue, maxLamValue); if (minAngValue > 1.0e-6) { ErrorsFound = true; - ShowSevereCustomMessage(state, + ShowSevereCustom(state, eoh, format("{} requires the minumum value = 0.0 in the entered table name={}", s_ipsc->cAlphaFieldNames(5), @@ -742,7 +741,7 @@ void GetMaterialData(EnergyPlusData &state, bool &ErrorsFound) // set to true if } if (std::abs(maxAngValue - 90.0) > 1.0e-6) { ErrorsFound = true; - ShowSevereCustomMessage(state, + ShowSevereCustom(state, eoh, format("{} requires the maximum value = 90.0 in the entered table name={}", s_ipsc->cAlphaFieldNames(5), @@ -750,7 +749,7 @@ void GetMaterialData(EnergyPlusData &state, bool &ErrorsFound) // set to true if } if (minLamValue < 0.1) { ErrorsFound = true; - ShowSevereCustomMessage(state, + ShowSevereCustom(state, eoh, format("{} requires the minumum value = 0.1 micron in the entered table name={}", s_ipsc->cAlphaFieldNames(5), @@ -758,7 +757,7 @@ void GetMaterialData(EnergyPlusData &state, bool &ErrorsFound) // set to true if } if (maxLamValue > 4.0) { ErrorsFound = true; - ShowSevereCustomMessage(state, + ShowSevereCustom(state, eoh, format("{} requires the maximum value = 4.0 microns in the entered table name={}", s_ipsc->cAlphaFieldNames(5), @@ -841,7 +840,7 @@ void GetMaterialData(EnergyPlusData &state, bool &ErrorsFound) // set to true if if (s_ipsc->rNumericArgs(6) + s_ipsc->rNumericArgs(7) >= 1.0) { ErrorsFound = true; - ShowSevereCustomMessage(state, eoh, format("{} + {} not < 1.0", s_ipsc->cNumericFieldNames(6), s_ipsc->cNumericFieldNames(7))); + ShowSevereCustom(state, eoh, format("{} + {} not < 1.0", s_ipsc->cNumericFieldNames(6), s_ipsc->cNumericFieldNames(7))); } if (s_ipsc->cAlphaArgs(2) == "") { @@ -1024,11 +1023,11 @@ void GetMaterialData(EnergyPlusData &state, bool &ErrorsFound) // set to true if if (matGas->gases[0].vis.c0 <= 0.0) { ErrorsFound = true; - ShowSevereCustomMessage(state, eoh, format("{} not > 0.0", s_ipsc->cNumericFieldNames(5))); + ShowSevereCustom(state, eoh, format("{} not > 0.0", s_ipsc->cNumericFieldNames(5))); } if (matGas->gases[0].cp.c0 <= 0.0) { ErrorsFound = true; - ShowSevereCustomMessage(state, eoh, format("{} not > 0.0", s_ipsc->cNumericFieldNames(8))); + ShowSevereCustom(state, eoh, format("{} not > 0.0", s_ipsc->cNumericFieldNames(8))); } if (matGas->gases[0].wght <= 0.0) { ErrorsFound = true; @@ -1993,7 +1992,7 @@ void GetMaterialData(EnergyPlusData &state, bool &ErrorsFound) // set to true if // Minimum and maximum slat angles allowed by slat geometry if (matBlind->SlatWidth > matBlind->SlatSeparation) { - MinSlatAngGeom = std::asin(matBlind->SlatThickness / (matBlind->SlatThickness + matBlind->SlatSeparation)) / Constant::DegToRadians; + MinSlatAngGeom = std::asin(matBlind->SlatThickness / (matBlind->SlatThickness + matBlind->SlatSeparation)) / Constant::DegToRad; } else { MinSlatAngGeom = 0.0; } @@ -2340,7 +2339,7 @@ void GetMaterialData(EnergyPlusData &state, bool &ErrorsFound) // set to true if s_mat->materialMap.insert_or_assign(nameUC, mat->Num); if (NumNums + 1 != NumAlphas) { - ShowSevereCustomMessage( + ShowSevereCustom( state, eoh, format("Check number of {} compared to number of {}", s_ipsc->cAlphaFieldNames(2), s_ipsc->cNumericFieldNames(1))); ErrorsFound = true; continue; @@ -2365,7 +2364,7 @@ void GetMaterialData(EnergyPlusData &state, bool &ErrorsFound) // set to true if auto *matGlass = s_mat->materials(matRef.matNum); // test that named material is of the right type if (matGlass->group != Group::Glass) { - ShowSevereCustomMessage( + ShowSevereCustom( state, eoh, format("{} = {}, Material is not a window glazing ", s_ipsc->cAlphaFieldNames(1 + iMatRef), s_ipsc->cAlphaArgs(1 + iMatRef))); @@ -2462,13 +2461,13 @@ void GetMaterialData(EnergyPlusData &state, bool &ErrorsFound) // set to true if mat->Thickness = s_ipsc->rNumericArgs(1); if (s_ipsc->rNumericArgs(1) <= 0.0) { ErrorsFound = true; - ShowSevereCustomMessage(state, eoh, format("{} must be > 0, entered {:.2R}", s_ipsc->cNumericFieldNames(1), s_ipsc->rNumericArgs(1))); + ShowSevereCustom(state, eoh, format("{} must be > 0, entered {:.2R}", s_ipsc->cNumericFieldNames(1), s_ipsc->rNumericArgs(1))); } mat->Pressure = s_ipsc->rNumericArgs(2); if (s_ipsc->rNumericArgs(2) <= 0.0) { ErrorsFound = true; - ShowSevereCustomMessage(state, eoh, format("{} must be > 0, entered {:.2R}", s_ipsc->cNumericFieldNames(2), s_ipsc->rNumericArgs(2))); + ShowSevereCustom(state, eoh, format("{} must be > 0, entered {:.2R}", s_ipsc->cNumericFieldNames(2), s_ipsc->rNumericArgs(2))); } if (!s_ipsc->lAlphaFieldBlanks(2)) { @@ -2609,61 +2608,61 @@ void GetMaterialData(EnergyPlusData &state, bool &ErrorsFound) // set to true if if (s_ipsc->rNumericArgs(1) <= 0.0) { ErrorsFound = true; - ShowSevereCustomMessage( + ShowSevereCustom( state, eoh, format("{} must be > 0, entered value = {:.2R}", s_ipsc->cNumericFieldNames(1), s_ipsc->rNumericArgs(1))); } if (s_ipsc->rNumericArgs(2) <= 0.0) { ErrorsFound = true; - ShowSevereCustomMessage( + ShowSevereCustom( state, eoh, format("{} must be > 0, entered value = {:.2R}", s_ipsc->cNumericFieldNames(2), s_ipsc->rNumericArgs(2))); } if ((s_ipsc->rNumericArgs(3) < 0.0) || (s_ipsc->rNumericArgs(3) > 1.0)) { ErrorsFound = true; - ShowSevereCustomMessage( + ShowSevereCustom( state, eoh, format("{} value must be >= 0 and <= 1, entered value = {:.2R}", s_ipsc->cNumericFieldNames(3), s_ipsc->rNumericArgs(3))); } if ((s_ipsc->rNumericArgs(4) <= 0.0) || (s_ipsc->rNumericArgs(4) > 1.0)) { ErrorsFound = true; - ShowSevereCustomMessage( + ShowSevereCustom( state, eoh, format("{} value must be >= 0 and <= 1, entered value = {:.2R}", s_ipsc->cNumericFieldNames(4), s_ipsc->rNumericArgs(4))); } if ((s_ipsc->rNumericArgs(5) <= 0.0) || (s_ipsc->rNumericArgs(5) > 1.0)) { ErrorsFound = true; - ShowSevereCustomMessage( + ShowSevereCustom( state, eoh, format("{} value must be >= 0 and <= 1, entered value = {:.2R}", s_ipsc->cNumericFieldNames(5), s_ipsc->rNumericArgs(5))); } if ((s_ipsc->rNumericArgs(6) < 0.0) || (s_ipsc->rNumericArgs(6) > 1.0)) { ErrorsFound = true; - ShowSevereCustomMessage( + ShowSevereCustom( state, eoh, format("{} must be >= 0 or <= 1, entered value = {:.2R}", s_ipsc->cNumericFieldNames(6), s_ipsc->rNumericArgs(6))); } if ((s_ipsc->rNumericArgs(7) < 0.0) || (s_ipsc->rNumericArgs(7) > 1.0)) { ErrorsFound = true; - ShowSevereCustomMessage( + ShowSevereCustom( state, eoh, format("{} must be >=0 or <=1, entered {:.2R}", s_ipsc->cNumericFieldNames(7), s_ipsc->rNumericArgs(7))); } if ((s_ipsc->rNumericArgs(8) < 0.0) || (s_ipsc->rNumericArgs(8) > 1.0)) { ErrorsFound = true; - ShowSevereCustomMessage( + ShowSevereCustom( state, eoh, format("{} must be >=0 or <=1, entered value = {:.2R}", s_ipsc->cNumericFieldNames(8), s_ipsc->rNumericArgs(8))); } if ((s_ipsc->rNumericArgs(9) < 0.0) || (s_ipsc->rNumericArgs(9) > 1.0)) { ErrorsFound = true; - ShowSevereCustomMessage( + ShowSevereCustom( state, eoh, format("{} must be >=0 or <=1, entered value = {:.2R}", s_ipsc->cNumericFieldNames(9), s_ipsc->rNumericArgs(9))); } if ((s_ipsc->rNumericArgs(10) < 0.0) || (s_ipsc->rNumericArgs(10) > 1.0)) { ErrorsFound = true; - ShowSevereCustomMessage( + ShowSevereCustom( state, eoh, format("{} must be >=0 or <=1, entered value = {:.2R}", s_ipsc->cNumericFieldNames(10), s_ipsc->rNumericArgs(10))); } @@ -2671,25 +2670,25 @@ void GetMaterialData(EnergyPlusData &state, bool &ErrorsFound) // set to true if (mat->LayerType == TARCOGParams::TARCOGLayerType::VENETBLIND_HORIZ)) { if (s_ipsc->rNumericArgs(11) <= 0.0) { ErrorsFound = true; - ShowSevereCustomMessage( + ShowSevereCustom( state, eoh, format("{} must be >0, entered value = {:.2R}", s_ipsc->cNumericFieldNames(11), s_ipsc->rNumericArgs(11))); } if (s_ipsc->rNumericArgs(12) <= 0.0) { ErrorsFound = true; - ShowSevereCustomMessage( + ShowSevereCustom( state, eoh, format("{} must be >0, entered value = {:.2R}", s_ipsc->cNumericFieldNames(12), s_ipsc->rNumericArgs(12))); } if (s_ipsc->rNumericArgs(13) <= 0.0) { ErrorsFound = true; - ShowSevereCustomMessage( + ShowSevereCustom( state, eoh, format("{} must be >0, entered value = {:.2R}", s_ipsc->cNumericFieldNames(13), s_ipsc->rNumericArgs(13))); } if ((s_ipsc->rNumericArgs(14) < -90.0) || (s_ipsc->rNumericArgs(14) > 90.0)) { ErrorsFound = true; - ShowSevereCustomMessage( + ShowSevereCustom( state, eoh, format("{} must be >=-90 and <=90, entered value = {:.2R}", s_ipsc->cNumericFieldNames(14), s_ipsc->rNumericArgs(14))); @@ -2697,14 +2696,14 @@ void GetMaterialData(EnergyPlusData &state, bool &ErrorsFound) // set to true if if (s_ipsc->rNumericArgs(15) <= 0.0) { ErrorsFound = true; - ShowSevereCustomMessage( + ShowSevereCustom( state, eoh, format("{} must be >0, entered value = {:.2R}", s_ipsc->cNumericFieldNames(15), s_ipsc->rNumericArgs(15))); } if ((s_ipsc->rNumericArgs(16) < 0.0) || ((s_ipsc->rNumericArgs(16) > 0.0) && (s_ipsc->rNumericArgs(16) < (s_ipsc->rNumericArgs(11) / 2)))) { ErrorsFound = true; - ShowSevereCustomMessage(state, + ShowSevereCustom(state, eoh, format("{} must be =0 or greater than SlatWidth/2, entered value = {:.2R}", s_ipsc->cNumericFieldNames(16), @@ -2845,13 +2844,13 @@ void GetVariableAbsorptanceInput(EnergyPlusData &state, bool &errorsFound) mat->absorpVarCtrlSignal = VariableAbsCtrlSignal::SurfaceTemperature; // default value mat->absorpVarCtrlSignal = static_cast(getEnumValue(variableAbsCtrlSignalNamesUC, s_ipsc->cAlphaArgs(3))); - // init to 0 as GetScheduleIndex returns 0 for not-found schedule + mat->absorpThermalVarFuncIdx = Curve::GetCurveIndex(state, s_ipsc->cAlphaArgs(4)); - mat->absorpThermalVarSchedIdx = ScheduleManager::GetScheduleIndex(state, s_ipsc->cAlphaArgs(5)); + mat->absorpThermalVarSched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(5)); mat->absorpSolarVarFuncIdx = Curve::GetCurveIndex(state, s_ipsc->cAlphaArgs(6)); - mat->absorpSolarVarSchedIdx = ScheduleManager::GetScheduleIndex(state, s_ipsc->cAlphaArgs(7)); + mat->absorpSolarVarSched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(7)); if (mat->absorpVarCtrlSignal == VariableAbsCtrlSignal::Scheduled) { - if ((mat->absorpThermalVarSchedIdx == 0) && (mat->absorpSolarVarSchedIdx == 0)) { + if ((mat->absorpThermalVarSched == nullptr) && (mat->absorpSolarVarSched == nullptr)) { ShowSevereError( state, format("{}: Control signal \"Scheduled\" is chosen but both thermal and solar absorptance schedules are undefined, for object {}", @@ -2879,7 +2878,7 @@ void GetVariableAbsorptanceInput(EnergyPlusData &state, bool &errorsFound) errorsFound = true; return; } - if ((mat->absorpThermalVarSchedIdx > 0) || (mat->absorpSolarVarSchedIdx > 0)) { + if ((mat->absorpThermalVarSched != nullptr) || (mat->absorpSolarVarSched != nullptr)) { ShowWarningError(state, format("{}: Non-schedule control signal is chosen. Thermal or solar absorptance schedule name is going to be " "ignored, for object {}", @@ -2954,7 +2953,7 @@ void GetWindowGlassSpectralData(EnergyPlusData &state, bool &ErrorsFound) // set specData.Name = s_ipsc->cAlphaArgs(1); int TotLam = NumNums / 4; if (mod(NumNums, 4) != 0) { - ShowWarningCustomMessage( + ShowWarningCustom( state, eoh, format("{} of items in data set is not a multiple of 4 (Wavelength,Trans,ReflFront,ReflBack), remainder items set to 0.0", NumNums)); @@ -2963,7 +2962,7 @@ void GetWindowGlassSpectralData(EnergyPlusData &state, bool &ErrorsFound) // set } if (TotLam > MaxSpectralDataElements) { - ShowSevereCustomMessage(state, eoh, format("More than {} entries in set ({})", MaxSpectralDataElements, NumNums)); + ShowSevereCustom(state, eoh, format("More than {} entries in set ({})", MaxSpectralDataElements, NumNums)); ErrorsFound = true; continue; } diff --git a/src/EnergyPlus/Material.hh b/src/EnergyPlus/Material.hh index 051dbd0cb20..84325cc6dcd 100644 --- a/src/EnergyPlus/Material.hh +++ b/src/EnergyPlus/Material.hh @@ -53,6 +53,7 @@ #include #include #include +#include #include #include #include @@ -255,9 +256,9 @@ namespace Material { // dynamic thermal and solar absorptance coating parameters VariableAbsCtrlSignal absorpVarCtrlSignal = VariableAbsCtrlSignal::Invalid; - int absorpThermalVarSchedIdx = 0; + Sched::Schedule *absorpThermalVarSched = nullptr; int absorpThermalVarFuncIdx = 0; - int absorpSolarVarSchedIdx = 0; + Sched::Schedule *absorpSolarVarSched = nullptr; int absorpSolarVarFuncIdx = 0; bool hasEMPD = false; @@ -964,6 +965,10 @@ struct MaterialData : BaseGlobalStruct Array1D WindowThermalModel; Array1D SpectralData; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/MatrixDataManager.hh b/src/EnergyPlus/MatrixDataManager.hh index ec630344c2f..a26476abbfa 100644 --- a/src/EnergyPlus/MatrixDataManager.hh +++ b/src/EnergyPlus/MatrixDataManager.hh @@ -130,6 +130,10 @@ struct MatrixDataManagerData : BaseGlobalStruct Array1D MatData; int NumMats; // number of matracies in input file + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/MicroCHPElectricGenerator.cc b/src/EnergyPlus/MicroCHPElectricGenerator.cc index 8694908e136..e9648b74209 100644 --- a/src/EnergyPlus/MicroCHPElectricGenerator.cc +++ b/src/EnergyPlus/MicroCHPElectricGenerator.cc @@ -134,7 +134,8 @@ void GetMicroCHPGeneratorInput(EnergyPlusData &state) // METHODOLOGY EMPLOYED: // EnergyPlus input processor - + static constexpr std::string_view routineName = "GetMicroCHPGeneratorInput"; + Array1D_string AlphArray(25); // character string data Array1D NumArray(200); // numeric data TODO deal with allocatable for extensible @@ -283,6 +284,9 @@ void GetMicroCHPGeneratorInput(EnergyPlusData &state) state.dataIPShortCut->lAlphaFieldBlanks, state.dataIPShortCut->cAlphaFieldNames, state.dataIPShortCut->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, state.dataIPShortCut->cCurrentModuleObject, AlphArray(1)}; + Util::IsNameEmpty(state, AlphArray(1), state.dataIPShortCut->cCurrentModuleObject, ErrorsFound); // GENERATOR:MICRO CHP, @@ -372,14 +376,10 @@ void GetMicroCHPGeneratorInput(EnergyPlusData &state) } if (state.dataIPShortCut->lAlphaFieldBlanks(9)) { - state.dataCHPElectGen->MicroCHP(GeneratorNum).AvailabilitySchedID = ScheduleManager::ScheduleAlwaysOn; - } else { - state.dataCHPElectGen->MicroCHP(GeneratorNum).AvailabilitySchedID = ScheduleManager::GetScheduleIndex(state, AlphArray(9)); - if (state.dataCHPElectGen->MicroCHP(GeneratorNum).AvailabilitySchedID == 0) { - ShowSevereError(state, format("Invalid, {} = {}", state.dataIPShortCut->cAlphaFieldNames(9), AlphArray(9))); - ShowContinueError(state, format("Entered in {}={}", state.dataIPShortCut->cCurrentModuleObject, AlphArray(1))); - ErrorsFound = true; - } + state.dataCHPElectGen->MicroCHP(GeneratorNum).availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((state.dataCHPElectGen->MicroCHP(GeneratorNum).availSched = Sched::GetSchedule(state, AlphArray(9))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(9), AlphArray(9)); + ErrorsFound = true; } state.dataCHPElectGen->MicroCHP(GeneratorNum).A42Model.TengLast = 20.0; // inits state.dataCHPElectGen->MicroCHP(GeneratorNum).A42Model.TempCWOutLast = 20.0; // inits @@ -1426,12 +1426,12 @@ void MicroCHPDataStruct::UpdateMicroCHPGeneratorRecords(EnergyPlusData &state) / this->A42Model.FuelCompressPower = state.dataGenerator->FuelSupply(this->FuelSupplyID).PfuelCompEl; // electrical power used by fuel supply compressor [W] this->A42Model.FuelCompressEnergy = - state.dataGenerator->FuelSupply(this->FuelSupplyID).PfuelCompEl * state.dataHVACGlobal->TimeStepSys * Constant::SecInHour; // elect energy + state.dataGenerator->FuelSupply(this->FuelSupplyID).PfuelCompEl * state.dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; // elect energy this->A42Model.FuelCompressSkinLoss = state.dataGenerator->FuelSupply(this->FuelSupplyID).QskinLoss; // heat rate of losses.by fuel supply compressor [W] this->A42Model.FuelEnergyHHV = this->A42Model.NdotFuel * state.dataGenerator->FuelSupply(this->FuelSupplyID).HHV * state.dataGenerator->FuelSupply(this->FuelSupplyID).KmolPerSecToKgPerSec * state.dataHVACGlobal->TimeStepSys * - Constant::SecInHour; + Constant::rSecsInHour; // reporting: Fuel Energy used (W) this->A42Model.FuelEnergyUseRateHHV = this->A42Model.NdotFuel * state.dataGenerator->FuelSupply(this->FuelSupplyID).HHV * state.dataGenerator->FuelSupply(this->FuelSupplyID).KmolPerSecToKgPerSec; diff --git a/src/EnergyPlus/MicroCHPElectricGenerator.hh b/src/EnergyPlus/MicroCHPElectricGenerator.hh index bf67f5b7635..9de2f656a08 100644 --- a/src/EnergyPlus/MicroCHPElectricGenerator.hh +++ b/src/EnergyPlus/MicroCHPElectricGenerator.hh @@ -178,7 +178,7 @@ namespace MicroCHPElectricGenerator { int AirOutletNodeID; int FuelSupplyID; // index for fuel supply data structure int DynamicsControlID; // index in GeneratorDynamics data where control issues are handled - int AvailabilitySchedID; // index for availability schedule + Sched::Schedule *availSched = nullptr; // index for availability schedule PlantLocation CWPlantLoc; // cooling water plant loop component index bool CheckEquipName; bool MySizeFlag; @@ -190,7 +190,7 @@ namespace MicroCHPElectricGenerator { MicroCHPDataStruct() : NomEff(0.0), ZoneID(0), PlantInletNodeID(0), PlantOutletNodeID(0), PlantMassFlowRate(0.0), PlantMassFlowRateMax(0.0), PlantMassFlowRateMaxWasAutoSized(false), AirInletNodeID(0), AirOutletNodeID(0), FuelSupplyID(0), DynamicsControlID(0), - AvailabilitySchedID(0), CWPlantLoc{}, CheckEquipName(true), MySizeFlag(true), MyEnvrnFlag(true), MyPlantScanFlag(true), myFlag(true) + CWPlantLoc{}, CheckEquipName(true), MySizeFlag(true), MyEnvrnFlag(true), MyPlantScanFlag(true), myFlag(true) { } @@ -276,6 +276,10 @@ struct MicroCHPElectricGeneratorData : BaseGlobalStruct bool MyOneTimeFlag = true; bool MyEnvrnFlag = true; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/MicroturbineElectricGenerator.hh b/src/EnergyPlus/MicroturbineElectricGenerator.hh index 2b72a7adf4a..5612679a779 100644 --- a/src/EnergyPlus/MicroturbineElectricGenerator.hh +++ b/src/EnergyPlus/MicroturbineElectricGenerator.hh @@ -235,6 +235,10 @@ struct MicroturbineElectricGeneratorData : BaseGlobalStruct bool GetMTInput = true; EPVector MTGenerator; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/MixedAir.cc b/src/EnergyPlus/MixedAir.cc index d10119a85d4..7dd93ff97bd 100644 --- a/src/EnergyPlus/MixedAir.cc +++ b/src/EnergyPlus/MixedAir.cc @@ -132,7 +132,6 @@ namespace EnergyPlus::MixedAir { using namespace DataLoopNode; using namespace DataAirLoop; using namespace DataEnvironment; -using namespace ScheduleManager; using namespace DataSizing; using namespace FaultsManager; @@ -1153,6 +1152,7 @@ void GetOAControllerInputs(EnergyPlusData &state) // SUBROUTINE PARAMETER DEFINITIONS: static constexpr std::string_view RoutineName("GetOAControllerInputs: "); // include trailing blank space + static constexpr std::string_view routineName = "GetOAControllerInputs"; // include trailing blank space // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int NumArg; // Number of arguments from GetObjectDefMaxArgs call @@ -1291,21 +1291,18 @@ void GetOAControllerInputs(EnergyPlusData &state) cAlphaFields, cNumericFields); + ErrorObjectHeader eoh{routineName, CurrentModuleObject, AlphArray(1)}; + int MechVentZoneCount = 0; int NumGroups = (NumAlphas + NumNums - 5) / 3; // Number of extensible input groups of the VentilationMechanical object if (mod((NumAlphas + NumNums - 5), 3) != 0) ++NumGroups; thisVentilationMechanical.Name = AlphArray(1); // no need to check if AlphaArray(1) is empty since Json will catch missing required fields - thisVentilationMechanical.SchName = AlphArray(2); if (lAlphaBlanks(2)) { - thisVentilationMechanical.SchPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - thisVentilationMechanical.SchPtr = GetScheduleIndex(state, AlphArray(2)); // convert schedule name to pointer - if (thisVentilationMechanical.SchPtr == 0) { - ShowSevereError( - state, format("{}=\"{}\" invalid {}=\"{}\" not found.", CurrentModuleObject, AlphArray(1), cAlphaFields(2), AlphArray(2))); - ErrorsFound = true; - } + thisVentilationMechanical.sched = Sched::GetScheduleAlwaysOn(state); + } else if ((thisVentilationMechanical.sched = Sched::GetSchedule(state, AlphArray(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(2), AlphArray(2)); + ErrorsFound = true; } // Adding new flag for DCV @@ -1567,8 +1564,8 @@ void GetOAControllerInputs(EnergyPlusData &state) thisVentMechZone.ZoneOAFlowRate = curOARequirements.OAFlowPerZone; thisVentMechZone.ZoneOAACHRate = curOARequirements.OAFlowACH; thisVentMechZone.ZoneOAFlowMethod = curOARequirements.OAFlowMethod; - thisVentMechZone.ZoneOASchPtr = curOARequirements.OAFlowFracSchPtr; - thisVentMechZone.OAPropCtlMinRateSchPtr = curOARequirements.OAPropCtlMinRateSchPtr; + thisVentMechZone.zoneOASched = curOARequirements.oaFlowFracSched; + thisVentMechZone.oaPropCtlMinRateSched = curOARequirements.oaPropCtlMinRateSched; if (thisVentilationMechanical.SystemOAMethod == DataSizing::SysOAMethod::ProportionalControlDesOARate) { if (thisVentMechZone.ZoneOAPeopleRate == 0.0 && thisVentMechZone.ZoneOAAreaRate == 0.0) { ShowSevereError( @@ -1591,7 +1588,7 @@ void GetOAControllerInputs(EnergyPlusData &state) thisVentMechZone.ZoneOAFlowRate = 0.0; thisVentMechZone.ZoneOAACHRate = 0.0; thisVentMechZone.ZoneOAFlowMethod = OAFlowCalcMethod::PerPerson; - thisVentMechZone.ZoneOASchPtr = ScheduleManager::ScheduleAlwaysOn; + thisVentMechZone.zoneOASched = Sched::GetScheduleAlwaysOn(state); ShowWarningError(state, format("{}{}=\"{}", RoutineName, CurrentModuleObject, thisVentilationMechanical.Name)); ShowContinueError( state, format("Cannot locate a matching DesignSpecification:OutdoorAir object for Zone=\"{}\".", thisVentMechZone.name)); @@ -1602,7 +1599,7 @@ void GetOAControllerInputs(EnergyPlusData &state) auto const &curZoneAirDistribution(state.dataSize->ZoneAirDistribution(zoneAirDistObjIndex)); thisVentMechZone.ZoneADEffCooling = curZoneAirDistribution.ZoneADEffCooling; thisVentMechZone.ZoneADEffHeating = curZoneAirDistribution.ZoneADEffHeating; - thisVentMechZone.ZoneADEffSchPtr = curZoneAirDistribution.ZoneADEffSchPtr; + thisVentMechZone.zoneADEffSched = curZoneAirDistribution.zoneADEffSched; thisVentMechZone.ZoneSecondaryRecirculation = curZoneAirDistribution.ZoneSecondaryRecirculation; } else { // use defaults thisVentMechZone.ZoneADEffCooling = 1.0; @@ -1776,7 +1773,7 @@ void GetOAControllerInputs(EnergyPlusData &state) print(state.files.eio, "{}\n", Format_700); for (int VentMechNum = 1; VentMechNum <= state.dataMixedAir->NumVentMechControllers; ++VentMechNum) { auto &thisVentilationMechanical(state.dataMixedAir->VentilationMechanical(VentMechNum)); - print(state.files.eio, " Controller:MechanicalVentilation,{},{},", thisVentilationMechanical.Name, thisVentilationMechanical.SchName); + print(state.files.eio, " Controller:MechanicalVentilation,{},{},", thisVentilationMechanical.Name, thisVentilationMechanical.sched->Name); if (thisVentilationMechanical.DCVFlag) { print(state.files.eio, "Yes,"); @@ -2047,6 +2044,9 @@ void ProcessOAControllerInputs(EnergyPlusData &state, // SUBROUTINE PARAMETER DEFINITIONS: static constexpr std::string_view RoutineName("GetOAControllerInputs: "); // include trailing blank space + static constexpr std::string_view routineName = "GetOAControllerInputs"; + + ErrorObjectHeader eoh{routineName, CurrentModuleObject, AlphArray(1)}; state.dataMixedAir->OAController(OutAirNum).Name = AlphArray(1); state.dataMixedAir->OAController(OutAirNum).ControllerType = MixedAirControllerType::ControllerOutsideAir; @@ -2182,31 +2182,29 @@ void ProcessOAControllerInputs(EnergyPlusData &state, DataLoopNode::ConnectionType::Sensor, NodeInputManager::CompFluidStream::Primary, ObjectIsNotParent); - state.dataMixedAir->OAController(OutAirNum).MinOASch = AlphArray(11); - state.dataMixedAir->OAController(OutAirNum).MinOASchPtr = GetScheduleIndex(state, AlphArray(11)); - if (state.dataMixedAir->OAController(OutAirNum).MinOASchPtr == 0 && (!lAlphaBlanks(11))) { - ShowSevereError(state, format("{}=\"{}\" invalid {}=\"{}\" not found.", CurrentModuleObject, AlphArray(1), cAlphaFields(11), AlphArray(11))); + + if (lAlphaBlanks(11)) { + } else if ((state.dataMixedAir->OAController(OutAirNum).minOASched = Sched::GetSchedule(state, AlphArray(11))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(11), AlphArray(11)); ErrorsFound = true; } // Changed by Amit for new feature implementation - state.dataMixedAir->OAController(OutAirNum).MinOAflowSch = AlphArray(12); - state.dataMixedAir->OAController(OutAirNum).MinOAflowSchPtr = GetScheduleIndex(state, AlphArray(12)); - if (state.dataMixedAir->OAController(OutAirNum).MinOAflowSchPtr == 0 && (!lAlphaBlanks(12))) { - ShowSevereError(state, format("{}=\"{}\" invalid {}=\"{}\" not found.", CurrentModuleObject, AlphArray(1), cAlphaFields(12), AlphArray(12))); + if (lAlphaBlanks(12)) { + } else if ((state.dataMixedAir->OAController(OutAirNum).minOAflowSched = Sched::GetSchedule(state, AlphArray(12))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(12), AlphArray(12)); ErrorsFound = true; } - state.dataMixedAir->OAController(OutAirNum).MaxOAflowSch = AlphArray(13); - state.dataMixedAir->OAController(OutAirNum).MaxOAflowSchPtr = GetScheduleIndex(state, AlphArray(13)); - if (state.dataMixedAir->OAController(OutAirNum).MaxOAflowSchPtr == 0 && (!lAlphaBlanks(13))) { - ShowSevereError(state, format("{}=\"{}\" invalid {}=\"{}\" not found.", CurrentModuleObject, AlphArray(1), cAlphaFields(13), AlphArray(13))); + if (lAlphaBlanks(13)) { + } else if ((state.dataMixedAir->OAController(OutAirNum).maxOAflowSched = Sched::GetSchedule(state, AlphArray(13))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(13), AlphArray(13)); ErrorsFound = true; } state.dataMixedAir->OAController(OutAirNum).VentilationMechanicalName = AlphArray(14); // Check for a time of day economizer control schedule - state.dataMixedAir->OAController(OutAirNum).EconomizerOASchedPtr = GetScheduleIndex(state, AlphArray(15)); + state.dataMixedAir->OAController(OutAirNum).economizerOASched = Sched::GetSchedule(state, AlphArray(15)); // High humidity control option can be used with any economizer flag if (Util::SameString(AlphArray(16), "Yes")) { @@ -2722,14 +2720,14 @@ void InitOAController(EnergyPlusData &state, int const OAControllerNum, bool con tempMechVentZone.ZoneOAFlowRate = thisMechVentZone.ZoneOAFlowRate; tempMechVentZone.ZoneOAACHRate = thisMechVentZone.ZoneOAACHRate; tempMechVentZone.ZoneOAFlowMethod = thisMechVentZone.ZoneOAFlowMethod; - tempMechVentZone.ZoneOASchPtr = thisMechVentZone.ZoneOASchPtr; + tempMechVentZone.zoneOASched = thisMechVentZone.zoneOASched; tempMechVentZone.ZoneDesignSpecOAObjIndex = thisMechVentZone.ZoneDesignSpecOAObjIndex; tempMechVentZone.ZoneDesignSpecOAObjName = thisMechVentZone.ZoneDesignSpecOAObjName; // new DCV tempMechVentZone.ZoneADEffCooling = thisMechVentZone.ZoneADEffCooling; tempMechVentZone.ZoneADEffHeating = thisMechVentZone.ZoneADEffHeating; - tempMechVentZone.ZoneADEffSchPtr = thisMechVentZone.ZoneADEffSchPtr; + tempMechVentZone.zoneADEffSched = thisMechVentZone.zoneADEffSched; } // Sum outside air per unit floor area for each mechanical ventilation object only once per simulation @@ -2775,21 +2773,21 @@ void InitOAController(EnergyPlusData &state, int const OAControllerNum, bool con OAFlowCalcMethodNames[static_cast(thisMechVentZone.ZoneOAFlowMethod)]); OutputReportPredefined::PreDefTableEntry( state, state.dataOutRptPredefined->pdchDCVType, zoneName, SysOAMethodNames[static_cast(vent_mech.SystemOAMethod)]); - if (thisMechVentZone.ZoneOASchPtr > 0) { + if (thisMechVentZone.zoneOASched != nullptr) { OutputReportPredefined::PreDefTableEntry( - state, state.dataOutRptPredefined->pdchDCVOASchName, zoneName, GetScheduleName(state, thisMechVentZone.ZoneOASchPtr)); + state, state.dataOutRptPredefined->pdchDCVOASchName, zoneName, thisMechVentZone.zoneOASched->Name); } else { OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchDCVOASchName, zoneName, ""); } // added for new DCV inputs - if (thisMechVentZone.ZoneADEffSchPtr > 0) { + if (thisMechVentZone.zoneADEffSched != nullptr) { OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchDCVZoneADEffCooling, zoneName, ""); OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchDCVZoneADEffHeating, zoneName, ""); OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchDCVZoneADEffSchName, zoneName, - GetScheduleName(state, thisMechVentZone.ZoneADEffSchPtr)); + thisMechVentZone.zoneADEffSched->Name); } else { OutputReportPredefined::PreDefTableEntry( state, state.dataOutRptPredefined->pdchDCVZoneADEffCooling, zoneName, thisMechVentZone.ZoneADEffCooling, 2); @@ -3121,7 +3119,7 @@ void InitOAController(EnergyPlusData &state, int const OAControllerNum, bool con OAFlowMethod == OAFlowCalcMethod::Max) { TotalPeopleOAFlow += state.dataHeatBal->ZoneIntGain(ZoneNum).NOFOCC * state.dataHeatBal->Zone(ZoneNum).Multiplier * state.dataHeatBal->Zone(ZoneNum).ListMultiplier * thisVentMechZone.ZoneOAPeopleRate * - GetCurrentScheduleValue(state, thisVentMechZone.ZoneOASchPtr); + thisVentMechZone.zoneOASched->getCurrentVal(); } } vent_mech.TotPeopleOAFlow = TotalPeopleOAFlow; @@ -3193,10 +3191,10 @@ void InitOAController(EnergyPlusData &state, int const OAControllerNum, bool con for (int i = 1; i <= thisOAController.NumFaultyEconomizer; ++i) { int j = thisOAController.EconmizerFaultNum(i); Real64 rSchVal = 0.0; - if (GetCurrentScheduleValue(state, state.dataFaultsMgr->FaultsEconomizer(j).availSchedNum) > 0.0) { + if (state.dataFaultsMgr->FaultsEconomizer(j).availSched->getCurrentVal() > 0.0) { rSchVal = 1.0; - if (state.dataFaultsMgr->FaultsEconomizer(j).severitySchedNum > 0) { - rSchVal = GetCurrentScheduleValue(state, state.dataFaultsMgr->FaultsEconomizer(j).severitySchedNum); + if (state.dataFaultsMgr->FaultsEconomizer(j).severitySched != nullptr) { + rSchVal = state.dataFaultsMgr->FaultsEconomizer(j).severitySched->getCurrentVal(); } } else { continue; // no fault @@ -3400,8 +3398,8 @@ void OAControllerProps::CalcOAController(EnergyPlusData &state, int const AirLoo } } Real64 MinOASchedVal = 1.0; // value of the minimum outside air schedule - if (this->MinOASchPtr > 0) { - MinOASchedVal = GetCurrentScheduleValue(state, this->MinOASchPtr); + if (this->minOASched != nullptr) { + MinOASchedVal = this->minOASched->getCurrentVal(); MinOASchedVal = min(max(MinOASchedVal, 0.0), 1.0); OutAirMinFrac *= MinOASchedVal; this->OALimitingFactor = OALimitFactor::Limits; @@ -3516,8 +3514,8 @@ void OAControllerProps::CalcOAController(EnergyPlusData &state, int const AirLoo } // Apply Minimum Fraction of Outdoor Air Schedule - if (this->MinOAflowSchPtr > 0) { - Real64 MinOAflowfracVal = GetCurrentScheduleValue(state, this->MinOAflowSchPtr); + if (this->minOAflowSched != nullptr) { + Real64 MinOAflowfracVal = this->minOAflowSched->getCurrentVal(); MinOAflowfracVal = min(max(MinOAflowfracVal, 0.0), 1.0); OutAirMinFrac = max(MinOAflowfracVal, OutAirMinFrac); Real64 minOAFracMassFlowRate = this->MixMassFlow * MinOAflowfracVal; @@ -3529,8 +3527,8 @@ void OAControllerProps::CalcOAController(EnergyPlusData &state, int const AirLoo // Apply Maximum Fraction of Outdoor Air Schedule Real64 currentMaxOAMassFlowRate = this->MaxOAMassFlowRate; - if (this->MaxOAflowSchPtr > 0) { - Real64 MaxOAflowfracVal = GetCurrentScheduleValue(state, this->MaxOAflowSchPtr); + if (this->maxOAflowSched != nullptr) { + Real64 MaxOAflowfracVal = this->maxOAflowSched->getCurrentVal(); MaxOAflowfracVal = min(max(MaxOAflowfracVal, 0.0), 1.0); currentMaxOAMassFlowRate = min(this->MaxOAMassFlowRate, this->MixMassFlow * MaxOAflowfracVal); OutAirMinFrac = min(MaxOAflowfracVal, OutAirMinFrac); @@ -3672,7 +3670,7 @@ Real64 VentilationMechanicalProps::CalcMechVentController(EnergyPlusData &state, Real64 MechVentOAMassFlow = 0.0; // Apply mechanical ventilation only when it is available/allowed - if (GetCurrentScheduleValue(state, this->SchPtr) > 0) { + if (this->sched->getCurrentVal() > 0) { Real64 SysOAMassFlow = 0.0; // System supply OA mass flow rate [kg/s] if (this->SystemOAMethod == DataSizing::SysOAMethod::IAQP) { // IAQP for CO2 control @@ -3680,7 +3678,7 @@ Real64 VentilationMechanicalProps::CalcMechVentController(EnergyPlusData &state, auto &thisMechVentZone = this->VentMechZone(ZoneIndex); int ZoneNum = thisMechVentZone.zoneNum; SysOAMassFlow += state.dataContaminantBalance->ZoneSysContDemand(ZoneNum).OutputRequiredToCO2SP * - GetCurrentScheduleValue(state, thisMechVentZone.ZoneOASchPtr); + thisMechVentZone.zoneOASched->getCurrentVal(); } MechVentOAMassFlow = SysOAMassFlow; } else if (this->SystemOAMethod == DataSizing::SysOAMethod::IAQPGC) { @@ -3689,7 +3687,7 @@ Real64 VentilationMechanicalProps::CalcMechVentController(EnergyPlusData &state, auto &thisMechVentZone = this->VentMechZone(ZoneIndex); int ZoneNum = thisMechVentZone.zoneNum; SysOAMassFlow += state.dataContaminantBalance->ZoneSysContDemand(ZoneNum).OutputRequiredToGCSP * - GetCurrentScheduleValue(state, thisMechVentZone.ZoneOASchPtr); + thisMechVentZone.zoneOASched->getCurrentVal(); } MechVentOAMassFlow = SysOAMassFlow; } else if (this->SystemOAMethod == DataSizing::SysOAMethod::IAQPCOM) { @@ -3699,7 +3697,7 @@ Real64 VentilationMechanicalProps::CalcMechVentController(EnergyPlusData &state, auto &thisMechVentZone = this->VentMechZone(ZoneIndex); int ZoneNum = thisMechVentZone.zoneNum; SysOAMassFlow += state.dataContaminantBalance->ZoneSysContDemand(ZoneNum).OutputRequiredToCO2SP * - GetCurrentScheduleValue(state, thisMechVentZone.ZoneOASchPtr); + thisMechVentZone.zoneOASched->getCurrentVal(); } MechVentOAMassFlow = SysOAMassFlow; SysOAMassFlow = 0.0; @@ -3707,7 +3705,7 @@ Real64 VentilationMechanicalProps::CalcMechVentController(EnergyPlusData &state, auto &thisMechVentZone = this->VentMechZone(ZoneIndex); int ZoneNum = thisMechVentZone.zoneNum; SysOAMassFlow += state.dataContaminantBalance->ZoneSysContDemand(ZoneNum).OutputRequiredToGCSP * - GetCurrentScheduleValue(state, thisMechVentZone.ZoneOASchPtr); + thisMechVentZone.zoneOASched->getCurrentVal(); } MechVentOAMassFlow = max(SysOAMassFlow, MechVentOAMassFlow); } else { @@ -3721,7 +3719,7 @@ Real64 VentilationMechanicalProps::CalcMechVentController(EnergyPlusData &state, auto &thisMechVentZone = this->VentMechZone(ZoneIndex); int ZoneNum = thisMechVentZone.zoneNum; auto const &curZone(state.dataHeatBal->Zone(ZoneNum)); - Real64 multiplier = curZone.Multiplier * curZone.ListMultiplier * GetCurrentScheduleValue(state, thisMechVentZone.ZoneOASchPtr); + Real64 multiplier = curZone.Multiplier * curZone.ListMultiplier * thisMechVentZone.zoneOASched->getCurrentVal(); // Calc the zone OA flow rate based on the people component // ZoneIntGain(ZoneNum)%NOFOCC is the number of occupants of a zone at each time step, already counting the occupant schedule @@ -3800,7 +3798,7 @@ Real64 VentilationMechanicalProps::CalcMechVentController(EnergyPlusData &state, // Assign references auto &curZone(state.dataHeatBal->Zone(ZoneNum)); auto &curZoneSysEnergyDemand(state.dataZoneEnergyDemand->ZoneSysEnergyDemand(ZoneEquipConfigNum)); - Real64 multiplier = curZone.Multiplier * curZone.ListMultiplier * GetCurrentScheduleValue(state, thisMechVentZone.ZoneOASchPtr); + Real64 multiplier = curZone.Multiplier * curZone.ListMultiplier * thisMechVentZone.zoneOASched->getCurrentVal(); // Calc the zone OA flow rate based on the people component // ZoneIntGain(ZoneNum)%NOFOCC is the number of occupants of a zone at each time step, already counting the occupant schedule @@ -3848,10 +3846,9 @@ Real64 VentilationMechanicalProps::CalcMechVentController(EnergyPlusData &state, // Calc the zone supplied OA flow rate counting the zone air distribution effectiveness // First check whether the zone air distribution effectiveness schedule exists, if yes uses it; // otherwise uses the inputs of zone distribution effectiveness in cooling mode or heating mode - int ADEffSchPtr = thisMechVentZone.ZoneADEffSchPtr; - if (ADEffSchPtr > 0) { + if (thisMechVentZone.zoneADEffSched != nullptr) { // Get schedule value for the zone air distribution effectiveness - ZoneEz = GetCurrentScheduleValue(state, ADEffSchPtr); + ZoneEz = thisMechVentZone.zoneADEffSched->getCurrentVal(); } else { Real64 ZoneLoad = state.dataZoneEnergyDemand->ZoneSysEnergyDemand(ZoneNum).TotalOutputRequired; @@ -3875,18 +3872,18 @@ Real64 VentilationMechanicalProps::CalcMechVentController(EnergyPlusData &state, this->SystemOAMethod == DataSizing::SysOAMethod::ProportionalControlDesOcc || this->SystemOAMethod == DataSizing::SysOAMethod::ProportionalControlDesOARate) { // Check whether "Carbon Dioxide Control Availability Schedule" for ZoneControl:ContaminantController is specified - if (curZone.ZoneContamControllerSchedIndex > 0.0) { + if (curZone.zoneContamControllerSched != nullptr) { // Check the availability schedule value for ZoneControl:ContaminantController - Real64 ZoneContamControllerSched = GetCurrentScheduleValue(state, curZone.ZoneContamControllerSchedIndex); - if (ZoneContamControllerSched > 0.0) { + Real64 ZoneContamControllerSchedVal = curZone.zoneContamControllerSched->getCurrentVal(); + if (ZoneContamControllerSchedVal > 0.0) { ZoneOAMin = ZoneOACalc[static_cast(DataSizing::OAFlowCalcMethod::PerArea)] / ZoneEz; ZoneOAMax = (ZoneOACalc[static_cast(DataSizing::OAFlowCalcMethod::PerArea)] + ZoneOACalc[static_cast(DataSizing::OAFlowCalcMethod::PerPerson)]) / ZoneEz; if (this->SystemOAMethod == DataSizing::SysOAMethod::ProportionalControlDesOARate) { ZoneOAMax = ZoneOABZ / ZoneEz; - if (thisMechVentZone.OAPropCtlMinRateSchPtr > 0) { - ZoneOAMin = ZoneOAMax * GetCurrentScheduleValue(state, thisMechVentZone.OAPropCtlMinRateSchPtr); + if (thisMechVentZone.oaPropCtlMinRateSched != nullptr) { + ZoneOAMin = ZoneOAMax * thisMechVentZone.oaPropCtlMinRateSched->getCurrentVal(); } else { ZoneOAMin = ZoneOAMax; } @@ -3919,10 +3916,10 @@ Real64 VentilationMechanicalProps::CalcMechVentController(EnergyPlusData &state, if (ZoneOACalc[static_cast(DataSizing::OAFlowCalcMethod::PerPerson)] > 0.0) { if (state.dataContaminantBalance->ZoneCO2GainFromPeople(ZoneNum) > 0.0) { - if (curZone.ZoneMinCO2SchedIndex > 0.0) { + if (curZone.zoneMinCO2Sched != nullptr) { // Take the schedule value of "Minimum Carbon Dioxide Concentration Schedule Name" // in the ZoneControl:ContaminantController - ZoneMinCO2 = GetCurrentScheduleValue(state, curZone.ZoneMinCO2SchedIndex); + ZoneMinCO2 = curZone.zoneMinCO2Sched->getCurrentVal(); } else { ZoneMinCO2 = state.dataContaminantBalance->OutdoorCO2; } @@ -3935,12 +3932,12 @@ Real64 VentilationMechanicalProps::CalcMechVentController(EnergyPlusData &state, CO2PeopleGeneration += state.dataHeatBal->People(PeopleNum).NumberOfPeople * state.dataHeatBal->People(PeopleNum).CO2RateFactor * - GetCurrentScheduleValue(state, state.dataHeatBal->People(PeopleNum).ActivityLevelPtr); + state.dataHeatBal->People(PeopleNum).activityLevelSched->getCurrentVal(); } ZoneMaxCO2 = state.dataContaminantBalance->OutdoorCO2 + (CO2PeopleGeneration * curZone.Multiplier * curZone.ListMultiplier * 1.0e6) / ZoneOAMax; - } else if (curZone.ZoneMaxCO2SchedIndex > 0.0) { - ZoneMaxCO2 = GetCurrentScheduleValue(state, curZone.ZoneMaxCO2SchedIndex); + } else if (curZone.zoneMaxCO2Sched != nullptr) { + ZoneMaxCO2 = curZone.zoneMaxCO2Sched->getCurrentVal(); } else { ZoneMaxCO2 = state.dataContaminantBalance->OutdoorCO2 + (state.dataContaminantBalance->ZoneCO2GainFromPeople(ZoneNum) * curZone.Multiplier * @@ -4403,8 +4400,8 @@ void OAControllerProps::CalcOAEconomizer(EnergyPlusData &state, // Check time of day economizer schedule, enable economizer if schedule value > 0 EconomizerAirFlowScheduleValue = 0.0; - if (this->EconomizerOASchedPtr > 0) { - EconomizerAirFlowScheduleValue = GetCurrentScheduleValue(state, this->EconomizerOASchedPtr); + if (this->economizerOASched != nullptr) { + EconomizerAirFlowScheduleValue = this->economizerOASched->getCurrentVal(); if (EconomizerAirFlowScheduleValue > 0.0) { EconomizerOperationFlag = true; OutAirSignal = 1.0; diff --git a/src/EnergyPlus/MixedAir.hh b/src/EnergyPlus/MixedAir.hh index 026ca0c8f5a..6ac2d81cefa 100644 --- a/src/EnergyPlus/MixedAir.hh +++ b/src/EnergyPlus/MixedAir.hh @@ -175,8 +175,7 @@ namespace MixedAir { int InletNode = 0; // Inlet Air Node for into Mixer (BTG Nov 2004) int RelNode = 0; // Relief Air Node Number int RetNode = 0; // Return Air Node Number - std::string MinOASch; // Name of the minimum outside air schedule - int MinOASchPtr = 0; // Index to the minimum outside air schedule + Sched::Schedule *minOASched = nullptr; // minimum outside air schedule Real64 RelMassFlow = 0.0; Real64 OAMassFlow = 0.0; Real64 ExhMassFlow = 0.0; @@ -208,11 +207,9 @@ namespace MixedAir { Real64 HighRHOAFlowRatio = 1.0; // Modify ratio with respect to maximum outdoor air flow rate (high RH) bool ModifyDuringHighOAMoisture = false; // flag to Modify outdoor air flow, TRUE when modify any time, FALSE when modify only when indoor air // humrat is less than outdoor HR - int EconomizerOASchedPtr = 0; // schedule to modify outdoor air flow - std::string MinOAflowSch; // Name of the Minimum fraction of Design/Mixed Mass of air - std::string MaxOAflowSch; // Name of the Maximum fraction of Design/Mixed Mass of air - int MinOAflowSchPtr = 0; // Index to the Minimum Fraction of Outdoor Air Schedule - int MaxOAflowSchPtr = 0; // Index to the Maximum Fraction of Outdoor Air Schedule + Sched::Schedule *economizerOASched = nullptr; // schedule to modify outdoor air flow + Sched::Schedule *minOAflowSched = nullptr; // Index to the Minimum Fraction of Outdoor Air Schedule + Sched::Schedule *maxOAflowSched = nullptr; // Index to the Maximum Fraction of Outdoor Air Schedule // Economizer Status, which is currently following the EconomizerOperationFlag, might be something like "Economizer status // indicates when the conditions are favorable for the economizer to operate (i.e., none of the control limits have been exceeded). // While this status signal indicates favorable conditions for economizer operation, it does not guarantee that the air-side @@ -274,13 +271,13 @@ namespace MixedAir { std::string ZoneDesignSpecOAObjName; // name of the design specification outdoor air object for each zone Real64 ZoneADEffCooling = 1.0; // Zone air distribution effectiveness in cooling mode for each zone Real64 ZoneADEffHeating = 1.0; // Zone air distribution effectiveness in heating mode for each zone - int ZoneADEffSchPtr = 0; // Pointer to the zone air distribution effectiveness schedule for each zone + Sched::Schedule *zoneADEffSched = nullptr; // air distribution effectiveness schedule for each zone int ZoneDesignSpecADObjIndex = 0; // index of the design specification zone air distribution object for each zone std::string ZoneDesignSpecADObjName; // name of the design specification zone air distribution object for each zone Real64 ZoneSecondaryRecirculation = 0.0; // zone air secondary recirculation ratio for each zone DataSizing::OAFlowCalcMethod ZoneOAFlowMethod = DataSizing::OAFlowCalcMethod::PerPerson; // OA flow method for each zone - int ZoneOASchPtr = 0; // Index to the outdoor air schedule for each zone (from DesignSpecification:OutdoorAir or default) - Real64 OAPropCtlMinRateSchPtr = 0; // Outdoor design OA flow rate schedule from DesignSpecification:OutdoorAir + Sched::Schedule *zoneOASched = nullptr; // Outdoor air schedule for each zone (from DesignSpecification:OutdoorAir or default) + Sched::Schedule *oaPropCtlMinRateSched = nullptr; // Outdoor design OA flow rate schedule from DesignSpecification:OutdoorAir EPVector peopleIndexes; // List of People objects in this zone (for SystemOAMethod == DataSizing::SysOAMethod::ProportionalControlDesOcc) }; @@ -288,8 +285,7 @@ namespace MixedAir { { // Members std::string Name; // Name of Ventilation:Mechanical object - std::string SchName; // Name of the mechanical ventilation schedule - int SchPtr = 0; // Index to the mechanical ventilation schedule + Sched::Schedule *sched = nullptr; // Mechanical ventilation schedule bool DCVFlag = false; // if true, implement OA based on demand controlled ventilation int NumofVentMechZones = 0; // Number of zones with mechanical ventilation Real64 TotAreaOAFlow = 0.0; // Total outdoor air flow rate for all zones per area (m3/s/m2) @@ -521,6 +517,10 @@ struct MixedAirData : BaseGlobalStruct Array1D_bool OAControllerMySizeFlag; Array1D_bool MechVentCheckFlag; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/MixerComponent.hh b/src/EnergyPlus/MixerComponent.hh index 3cadbc9359f..dc558878112 100644 --- a/src/EnergyPlus/MixerComponent.hh +++ b/src/EnergyPlus/MixerComponent.hh @@ -162,6 +162,10 @@ struct MixerComponentData : BaseGlobalStruct Array1D_bool CheckEquipName; EPVector MixerCond; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/MoistureBalanceEMPDManager.cc b/src/EnergyPlus/MoistureBalanceEMPDManager.cc index 92a145ce920..9ecb09b3bac 100644 --- a/src/EnergyPlus/MoistureBalanceEMPDManager.cc +++ b/src/EnergyPlus/MoistureBalanceEMPDManager.cc @@ -200,8 +200,7 @@ void GetMoistureBalanceEMPDInput(EnergyPlusData &state) auto *mat = s_mat->materials(matNum); if (mat->group != Material::Group::Regular || mat->ROnly) { - ShowSevereCustomMessage( - state, eoh, "Reference Material is not appropriate type for EMPD properties, must have regular properties (L,Cp,K,D)"); + ShowSevereCustom(state, eoh, "Reference Material is not appropriate type for EMPD properties, must have regular properties (L,Cp,K,D)"); ErrorsFound = true; continue; } diff --git a/src/EnergyPlus/MoistureBalanceEMPDManager.hh b/src/EnergyPlus/MoistureBalanceEMPDManager.hh index ba1b728b9d4..cfb20735532 100644 --- a/src/EnergyPlus/MoistureBalanceEMPDManager.hh +++ b/src/EnergyPlus/MoistureBalanceEMPDManager.hh @@ -132,6 +132,10 @@ struct MoistureBalanceEMPDManagerData : BaseGlobalStruct int ErrCount = 0; bool OneTimeFlag = true; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/MundtSimMgr.cc b/src/EnergyPlus/MundtSimMgr.cc index 372cc81b9b2..1d04a762df0 100644 --- a/src/EnergyPlus/MundtSimMgr.cc +++ b/src/EnergyPlus/MundtSimMgr.cc @@ -756,7 +756,7 @@ namespace RoomAir { int hbSurfNum = state.dataMundtSimMgr->ZoneData(ZoneNum).HBsurfaceIndexes(SurfNum); DeltaTemp = state.dataMundtSimMgr->MundtAirSurf(SurfNum, state.dataMundtSimMgr->MundtZoneNum).TMeanAir - state.dataMundtSimMgr->LineNode(state.dataMundtSimMgr->TstatNodeID, state.dataMundtSimMgr->MundtZoneNum).Temp; - state.dataHeatBal->SurfTempEffBulkAir(hbSurfNum) = state.dataHeatBalFanSys->TempZoneThermostatSetPoint(ZoneNum) + DeltaTemp; + state.dataHeatBal->SurfTempEffBulkAir(hbSurfNum) = state.dataHeatBalFanSys->zoneTstatSetpts(ZoneNum).setpt + DeltaTemp; // set flag for reference air temperature state.dataSurface->SurfTAirRef(hbSurfNum) = DataSurfaces::RefAirTemp::AdjacentAirTemp; state.dataSurface->SurfTAirRefRpt(hbSurfNum) = DataSurfaces::SurfTAirRefReportVals[state.dataSurface->SurfTAirRef(hbSurfNum)]; @@ -770,7 +770,7 @@ namespace RoomAir { int ZoneNodeNum = state.dataHeatBal->Zone(ZoneNum).SystemZoneNodeNumber; DeltaTemp = state.dataMundtSimMgr->LineNode(state.dataMundtSimMgr->ReturnNodeID, state.dataMundtSimMgr->MundtZoneNum).Temp - state.dataMundtSimMgr->LineNode(state.dataMundtSimMgr->TstatNodeID, state.dataMundtSimMgr->MundtZoneNum).Temp; - state.dataLoopNodes->Node(ZoneNodeNum).Temp = state.dataHeatBalFanSys->TempZoneThermostatSetPoint(ZoneNum) + DeltaTemp; + state.dataLoopNodes->Node(ZoneNodeNum).Temp = state.dataHeatBalFanSys->zoneTstatSetpts(ZoneNum).setpt + DeltaTemp; // d) Thermostat air temperature -> TempTstatAir(ZoneNum) state.dataHeatBalFanSys->TempTstatAir(ZoneNum) = state.dataZoneTempPredictorCorrector->zoneHeatBalance(ZoneNum) .ZT; // for indirect coupling, control air temp is equal to mean air temp? diff --git a/src/EnergyPlus/MundtSimMgr.hh b/src/EnergyPlus/MundtSimMgr.hh index 9bd695cb18b..cc207c2cb6f 100644 --- a/src/EnergyPlus/MundtSimMgr.hh +++ b/src/EnergyPlus/MundtSimMgr.hh @@ -168,6 +168,10 @@ struct MundtSimMgrData : BaseGlobalStruct Array2D MundtAirSurf; // surfaces Array1D FloorSurf; // floor + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/NodeInputManager.cc b/src/EnergyPlus/NodeInputManager.cc index 2d39a19384a..d6a0e8fd509 100644 --- a/src/EnergyPlus/NodeInputManager.cc +++ b/src/EnergyPlus/NodeInputManager.cc @@ -974,7 +974,6 @@ void CalcMoreNodeInfo(EnergyPlusData &state) using Psychrometrics::PsyTdpFnWPb; using Psychrometrics::PsyTwbFnTdbWPb; using Psychrometrics::RhoH2O; - using ScheduleManager::GetCurrentScheduleValue; // SUBROUTINE PARAMETER DEFINITIONS: static constexpr std::string_view RoutineName("CalcMoreNodeInfo"); @@ -982,13 +981,13 @@ void CalcMoreNodeInfo(EnergyPlusData &state) auto &RhoAirStdInit = state.dataNodeInputMgr->RhoAirStdInit; auto &RhoWaterStdInit = state.dataNodeInputMgr->RhoWaterStdInit; - auto &NodeWetBulbSchedPtr = state.dataNodeInputMgr->NodeWetBulbSchedPtr; + auto &NodeWetBulbScheds = state.dataNodeInputMgr->NodeWetBulbScheds; auto &NodeRelHumidityRepReq = state.dataNodeInputMgr->NodeRelHumidityRepReq; - auto &NodeRelHumiditySchedPtr = state.dataNodeInputMgr->NodeRelHumiditySchedPtr; + auto &NodeRelHumidityScheds = state.dataNodeInputMgr->NodeRelHumidityScheds; auto &NodeDewPointRepReq = state.dataNodeInputMgr->NodeDewPointRepReq; - auto &NodeDewPointSchedPtr = state.dataNodeInputMgr->NodeDewPointSchedPtr; + auto &NodeDewPointScheds = state.dataNodeInputMgr->NodeDewPointScheds; auto &NodeSpecificHeatRepReq = state.dataNodeInputMgr->NodeSpecificHeatRepReq; - auto &NodeSpecificHeatSchedPtr = state.dataNodeInputMgr->NodeSpecificHeatSchedPtr; + auto &NodeSpecificHeatScheds = state.dataNodeInputMgr->NodeSpecificHeatScheds; auto &nodeReportingStrings = state.dataNodeInputMgr->nodeReportingStrings; auto &nodeFluidNames = state.dataNodeInputMgr->nodeFluidNames; Real64 SteamDensity; @@ -1002,23 +1001,23 @@ void CalcMoreNodeInfo(EnergyPlusData &state) RhoAirStdInit = state.dataEnvrn->StdRhoAir; RhoWaterStdInit = RhoH2O(Constant::InitConvTemp); state.dataNodeInputMgr->NodeWetBulbRepReq.allocate(state.dataLoopNodes->NumOfNodes); - NodeWetBulbSchedPtr.allocate(state.dataLoopNodes->NumOfNodes); + NodeWetBulbScheds.allocate(state.dataLoopNodes->NumOfNodes); NodeRelHumidityRepReq.allocate(state.dataLoopNodes->NumOfNodes); - NodeRelHumiditySchedPtr.allocate(state.dataLoopNodes->NumOfNodes); + NodeRelHumidityScheds.allocate(state.dataLoopNodes->NumOfNodes); NodeDewPointRepReq.allocate(state.dataLoopNodes->NumOfNodes); - NodeDewPointSchedPtr.allocate(state.dataLoopNodes->NumOfNodes); + NodeDewPointScheds.allocate(state.dataLoopNodes->NumOfNodes); NodeSpecificHeatRepReq.allocate(state.dataLoopNodes->NumOfNodes); - NodeSpecificHeatSchedPtr.allocate(state.dataLoopNodes->NumOfNodes); + NodeSpecificHeatScheds.allocate(state.dataLoopNodes->NumOfNodes); nodeReportingStrings.reserve(state.dataLoopNodes->NumOfNodes); nodeFluidNames.reserve(state.dataLoopNodes->NumOfNodes); state.dataNodeInputMgr->NodeWetBulbRepReq = false; - NodeWetBulbSchedPtr = 0; + NodeWetBulbScheds = nullptr; NodeRelHumidityRepReq = false; - NodeRelHumiditySchedPtr = 0; + NodeRelHumidityScheds = nullptr; NodeDewPointRepReq = false; - NodeDewPointSchedPtr = 0; + NodeDewPointScheds = nullptr; NodeSpecificHeatRepReq = false; - NodeSpecificHeatSchedPtr = 0; + NodeSpecificHeatScheds = nullptr; for (int iNode = 1; iNode <= state.dataLoopNodes->NumOfNodes; ++iNode) { nodeReportingStrings.push_back(std::string(NodeReportingCalc + state.dataLoopNodes->NodeID(iNode))); @@ -1028,34 +1027,34 @@ void CalcMoreNodeInfo(EnergyPlusData &state) if (Util::SameString(reqVar->key, state.dataLoopNodes->NodeID(iNode)) || reqVar->key.empty()) { if (Util::SameString(reqVar->name, "System Node Wetbulb Temperature")) { state.dataNodeInputMgr->NodeWetBulbRepReq(iNode) = true; - NodeWetBulbSchedPtr(iNode) = reqVar->SchedPtr; + NodeWetBulbScheds(iNode) = reqVar->sched; } else if (Util::SameString(reqVar->name, "System Node Relative Humidity")) { NodeRelHumidityRepReq(iNode) = true; - NodeRelHumiditySchedPtr(iNode) = reqVar->SchedPtr; + NodeRelHumidityScheds(iNode) = reqVar->sched; } else if (Util::SameString(reqVar->name, "System Node Dewpoint Temperature")) { NodeDewPointRepReq(iNode) = true; - NodeDewPointSchedPtr(iNode) = reqVar->SchedPtr; + NodeDewPointScheds(iNode) = reqVar->sched; } else if (Util::SameString(reqVar->name, "System Node Specific Heat")) { NodeSpecificHeatRepReq(iNode) = true; - NodeSpecificHeatSchedPtr(iNode) = reqVar->SchedPtr; + NodeSpecificHeatScheds(iNode) = reqVar->sched; } } } if (EMSManager::CheckIfNodeMoreInfoSensedByEMS(state, iNode, "System Node Wetbulb Temperature")) { state.dataNodeInputMgr->NodeWetBulbRepReq(iNode) = true; - NodeWetBulbSchedPtr(iNode) = 0; + NodeWetBulbScheds(iNode) = nullptr; } if (EMSManager::CheckIfNodeMoreInfoSensedByEMS(state, iNode, "System Node Relative Humidity")) { NodeRelHumidityRepReq(iNode) = true; - NodeRelHumiditySchedPtr(iNode) = 0; + NodeRelHumidityScheds(iNode) = nullptr; } if (EMSManager::CheckIfNodeMoreInfoSensedByEMS(state, iNode, "System Node Dewpoint Temperature")) { NodeDewPointRepReq(iNode) = true; - NodeDewPointSchedPtr(iNode) = 0; + NodeDewPointScheds(iNode) = nullptr; } if (EMSManager::CheckIfNodeMoreInfoSensedByEMS(state, iNode, "System Node Specific Heat")) { NodeSpecificHeatRepReq(iNode) = true; - NodeSpecificHeatSchedPtr(iNode) = 0; + NodeSpecificHeatScheds(iNode) = nullptr; } } state.dataNodeInputMgr->CalcMoreNodeInfoMyOneTimeFlag = false; @@ -1066,26 +1065,26 @@ void CalcMoreNodeInfo(EnergyPlusData &state) bool ReportRelHumidity = false; bool ReportDewPoint = false; bool ReportSpecificHeat = false; - if (state.dataNodeInputMgr->NodeWetBulbRepReq(iNode) && NodeWetBulbSchedPtr(iNode) > 0) { - ReportWetBulb = (GetCurrentScheduleValue(state, NodeWetBulbSchedPtr(iNode)) > 0.0); - } else if (state.dataNodeInputMgr->NodeWetBulbRepReq(iNode) && NodeWetBulbSchedPtr(iNode) == 0) { + if (state.dataNodeInputMgr->NodeWetBulbRepReq(iNode) && NodeWetBulbScheds(iNode) != nullptr) { + ReportWetBulb = (NodeWetBulbScheds(iNode)->getCurrentVal() > 0.0); + } else if (state.dataNodeInputMgr->NodeWetBulbRepReq(iNode) && NodeWetBulbScheds(iNode) == nullptr) { ReportWetBulb = true; } else if (state.dataLoopNodes->Node(iNode).SPMNodeWetBulbRepReq) { ReportWetBulb = true; } - if (NodeRelHumidityRepReq(iNode) && NodeRelHumiditySchedPtr(iNode) > 0) { - ReportRelHumidity = (GetCurrentScheduleValue(state, NodeRelHumiditySchedPtr(iNode)) > 0.0); - } else if (NodeRelHumidityRepReq(iNode) && NodeRelHumiditySchedPtr(iNode) == 0) { + if (NodeRelHumidityRepReq(iNode) && NodeRelHumidityScheds(iNode) != nullptr) { + ReportRelHumidity = (NodeRelHumidityScheds(iNode)->getCurrentVal() > 0.0); + } else if (NodeRelHumidityRepReq(iNode) && NodeRelHumidityScheds(iNode) == nullptr) { ReportRelHumidity = true; } - if (NodeDewPointRepReq(iNode) && NodeDewPointSchedPtr(iNode) > 0) { - ReportDewPoint = (GetCurrentScheduleValue(state, NodeDewPointSchedPtr(iNode)) > 0.0); - } else if (NodeDewPointRepReq(iNode) && NodeDewPointSchedPtr(iNode) == 0) { + if (NodeDewPointRepReq(iNode) && NodeDewPointScheds(iNode) != nullptr) { + ReportDewPoint = (NodeDewPointScheds(iNode)->getCurrentVal() > 0.0); + } else if (NodeDewPointRepReq(iNode) && NodeDewPointScheds(iNode) == nullptr) { ReportDewPoint = true; } - if (NodeSpecificHeatRepReq(iNode) && NodeSpecificHeatSchedPtr(iNode) > 0) { - ReportSpecificHeat = (GetCurrentScheduleValue(state, NodeSpecificHeatSchedPtr(iNode)) > 0.0); - } else if (NodeSpecificHeatRepReq(iNode) && NodeSpecificHeatSchedPtr(iNode) == 0) { + if (NodeSpecificHeatRepReq(iNode) && NodeSpecificHeatScheds(iNode) != nullptr) { + ReportSpecificHeat = (NodeSpecificHeatScheds(iNode)->getCurrentVal() > 0.0); + } else if (NodeSpecificHeatRepReq(iNode) && NodeSpecificHeatScheds(iNode) == nullptr) { ReportSpecificHeat = true; } // calculate the volume flow rate diff --git a/src/EnergyPlus/NodeInputManager.hh b/src/EnergyPlus/NodeInputManager.hh index 1e9270a5b52..e11cab3eb2f 100644 --- a/src/EnergyPlus/NodeInputManager.hh +++ b/src/EnergyPlus/NodeInputManager.hh @@ -175,16 +175,20 @@ struct NodeInputManagerData : BaseGlobalStruct Real64 RhoAirStdInit; Real64 RhoWaterStdInit; - Array1D_int NodeWetBulbSchedPtr; + Array1D NodeWetBulbScheds; Array1D_bool NodeRelHumidityRepReq; - Array1D_int NodeRelHumiditySchedPtr; + Array1D NodeRelHumidityScheds; Array1D_bool NodeDewPointRepReq; - Array1D_int NodeDewPointSchedPtr; + Array1D NodeDewPointScheds; Array1D_bool NodeSpecificHeatRepReq; - Array1D_int NodeSpecificHeatSchedPtr; + Array1D NodeSpecificHeatScheds; std::vector nodeReportingStrings; std::vector nodeFluidNames; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/OutAirNodeManager.cc b/src/EnergyPlus/OutAirNodeManager.cc index 379a7765189..0216badebf8 100644 --- a/src/EnergyPlus/OutAirNodeManager.cc +++ b/src/EnergyPlus/OutAirNodeManager.cc @@ -131,11 +131,11 @@ namespace OutAirNodeManager { // Using/Aliasing using namespace NodeInputManager; - using ScheduleManager::GetScheduleIndex; // Locals // SUBROUTINE PARAMETER DEFINITIONS: static constexpr std::string_view RoutineName("GetOutAirNodesInput: "); // include trailing blank space + static constexpr std::string_view routineName = "GetOutAirNodesInput"; // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int NumOutAirInletNodeLists; @@ -271,6 +271,8 @@ namespace OutAirNodeManager { cAlphaFields, cNumericFields); + ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)}; + ErrInList = false; // To support HVAC diagram, every outside inlet node must have a unique fluid stream number // GetNodeNums will increment the value across a node list, the starting value must be incremented @@ -321,40 +323,28 @@ namespace OutAirNodeManager { state.dataGlobal->AnyLocalEnvironmentsInModel = true; } - if (NumAlphas > 1 && !lAlphaBlanks(2)) { - state.dataLoopNodes->Node(NodeNums(1)).OutAirDryBulbSchedNum = GetScheduleIndex(state, Alphas(2)); - if (state.dataLoopNodes->Node(NodeNums(1)).OutAirDryBulbSchedNum == 0) { - ShowSevereError(state, format("{}{}=\"{}\", invalid schedule.", RoutineName, CurrentModuleObject, cAlphaFields(2))); - ShowContinueError(state, format("Dry Bulb Temperature Schedule not found=\"{}\".", Alphas(2))); - ErrorsFound = true; - } + if (NumAlphas <= 1 || lAlphaBlanks(2)) { + } else if ((state.dataLoopNodes->Node(NodeNums(1)).outAirDryBulbSched = Sched::GetSchedule(state, Alphas(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(2), Alphas(2)); + ErrorsFound = true; } - if (NumAlphas > 2 && !lAlphaBlanks(3)) { - state.dataLoopNodes->Node(NodeNums(1)).OutAirWetBulbSchedNum = GetScheduleIndex(state, Alphas(3)); - if (state.dataLoopNodes->Node(NodeNums(1)).OutAirWetBulbSchedNum == 0) { - ShowSevereError(state, format("{}{}=\"{}\", invalid schedule.", RoutineName, CurrentModuleObject, cAlphaFields(3))); - ShowContinueError(state, format("Wet Bulb Temperature Schedule not found=\"{}\".", Alphas(3))); - ErrorsFound = true; - } + if (NumAlphas <= 2 || lAlphaBlanks(3)) { + } else if ((state.dataLoopNodes->Node(NodeNums(1)).outAirWetBulbSched = Sched::GetSchedule(state, Alphas(3))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(3), Alphas(3)); + ErrorsFound = true; } - if (NumAlphas > 3 && !lAlphaBlanks(4)) { - state.dataLoopNodes->Node(NodeNums(1)).OutAirWindSpeedSchedNum = GetScheduleIndex(state, Alphas(4)); - if (state.dataLoopNodes->Node(NodeNums(1)).OutAirWindSpeedSchedNum == 0) { - ShowSevereError(state, format("{}{}=\"{}\", invalid schedule.", RoutineName, CurrentModuleObject, cAlphaFields(4))); - ShowContinueError(state, format("Wind Speed Schedule not found=\"{}\".", Alphas(4))); - ErrorsFound = true; - } + if (NumAlphas <= 3 || lAlphaBlanks(4)) { + } else if ((state.dataLoopNodes->Node(NodeNums(1)).outAirWindSpeedSched = Sched::GetSchedule(state, Alphas(4))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(4), Alphas(4)); + ErrorsFound = true; } - if (NumAlphas > 4 && !lAlphaBlanks(5)) { - state.dataLoopNodes->Node(NodeNums(1)).OutAirWindDirSchedNum = GetScheduleIndex(state, Alphas(5)); - if (state.dataLoopNodes->Node(NodeNums(1)).OutAirWindDirSchedNum == 0) { - ShowSevereError(state, format("{}{}=\"{}\", invalid schedule.", RoutineName, CurrentModuleObject, cAlphaFields(5))); - ShowContinueError(state, format("Wind Direction Schedule not found=\"{}\".", Alphas(5))); - ErrorsFound = true; - } + if (NumAlphas <= 4 || lAlphaBlanks(5)) { + } else if ((state.dataLoopNodes->Node(NodeNums(1)).outAirWindDirSched = Sched::GetSchedule(state, Alphas(5))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(5), Alphas(5)); + ErrorsFound = true; } if (NumAlphas > 8) { @@ -363,8 +353,8 @@ namespace OutAirNodeManager { ErrorsFound = true; continue; } - if (state.dataLoopNodes->Node(NodeNums(1)).OutAirDryBulbSchedNum > 0 || - state.dataLoopNodes->Node(NodeNums(1)).OutAirWetBulbSchedNum > 0) { + if (state.dataLoopNodes->Node(NodeNums(1)).outAirDryBulbSched != nullptr || + state.dataLoopNodes->Node(NodeNums(1)).outAirWetBulbSched != nullptr) { state.dataLoopNodes->Node(NodeNums(1)).IsLocalNode = true; } } @@ -557,7 +547,6 @@ namespace OutAirNodeManager { using Psychrometrics::PsyHFnTdbW; using Psychrometrics::PsyTwbFnTdbWPb; using Psychrometrics::PsyWFnTdbTwbPb; - using ScheduleManager::GetCurrentScheduleValue; // Set node data to global values if (state.dataLoopNodes->Node(NodeNum).Height < 0.0) { @@ -576,21 +565,21 @@ namespace OutAirNodeManager { if (InitCall) { // Set node data to local air node values if defined - if (state.dataLoopNodes->Node(NodeNum).OutAirDryBulbSchedNum != 0) { + if (state.dataLoopNodes->Node(NodeNum).outAirDryBulbSched != nullptr) { state.dataLoopNodes->Node(NodeNum).OutAirDryBulb = - GetCurrentScheduleValue(state, state.dataLoopNodes->Node(NodeNum).OutAirDryBulbSchedNum); + state.dataLoopNodes->Node(NodeNum).outAirDryBulbSched->getCurrentVal(); } - if (state.dataLoopNodes->Node(NodeNum).OutAirWetBulbSchedNum != 0) { + if (state.dataLoopNodes->Node(NodeNum).outAirWetBulbSched != nullptr) { state.dataLoopNodes->Node(NodeNum).OutAirWetBulb = - GetCurrentScheduleValue(state, state.dataLoopNodes->Node(NodeNum).OutAirWetBulbSchedNum); + state.dataLoopNodes->Node(NodeNum).outAirWetBulbSched->getCurrentVal(); } - if (state.dataLoopNodes->Node(NodeNum).OutAirWindSpeedSchedNum != 0) { + if (state.dataLoopNodes->Node(NodeNum).outAirWindSpeedSched != nullptr) { state.dataLoopNodes->Node(NodeNum).OutAirWindSpeed = - GetCurrentScheduleValue(state, state.dataLoopNodes->Node(NodeNum).OutAirWindSpeedSchedNum); + state.dataLoopNodes->Node(NodeNum).outAirWindSpeedSched->getCurrentVal(); } - if (state.dataLoopNodes->Node(NodeNum).OutAirWindDirSchedNum != 0) { + if (state.dataLoopNodes->Node(NodeNum).outAirWindDirSched != nullptr) { state.dataLoopNodes->Node(NodeNum).OutAirWindDir = - GetCurrentScheduleValue(state, state.dataLoopNodes->Node(NodeNum).OutAirWindDirSchedNum); + state.dataLoopNodes->Node(NodeNum).outAirWindDirSched->getCurrentVal(); } // Set node data to EMS overwritten values if defined @@ -610,8 +599,8 @@ namespace OutAirNodeManager { if (state.dataLoopNodes->Node(NodeNum).OutAirWetBulb > state.dataLoopNodes->Node(NodeNum).OutAirDryBulb) { state.dataLoopNodes->Node(NodeNum).OutAirWetBulb = state.dataLoopNodes->Node(NodeNum).OutAirDryBulb; } - if (state.dataLoopNodes->Node(NodeNum).OutAirWetBulbSchedNum == 0 && !state.dataLoopNodes->Node(NodeNum).EMSOverrideOutAirWetBulb && - (state.dataLoopNodes->Node(NodeNum).EMSOverrideOutAirDryBulb || state.dataLoopNodes->Node(NodeNum).OutAirDryBulbSchedNum != 0)) { + if (state.dataLoopNodes->Node(NodeNum).outAirWetBulbSched == nullptr && !state.dataLoopNodes->Node(NodeNum).EMSOverrideOutAirWetBulb && + (state.dataLoopNodes->Node(NodeNum).EMSOverrideOutAirDryBulb || state.dataLoopNodes->Node(NodeNum).outAirDryBulbSched != nullptr)) { state.dataLoopNodes->Node(NodeNum).HumRat = state.dataEnvrn->OutHumRat; state.dataLoopNodes->Node(NodeNum).OutAirWetBulb = PsyTwbFnTdbWPb( state, state.dataLoopNodes->Node(NodeNum).OutAirDryBulb, state.dataEnvrn->OutHumRat, state.dataEnvrn->OutBaroPress); diff --git a/src/EnergyPlus/OutAirNodeManager.hh b/src/EnergyPlus/OutAirNodeManager.hh index fb1d9398248..19d0dae5bd8 100644 --- a/src/EnergyPlus/OutAirNodeManager.hh +++ b/src/EnergyPlus/OutAirNodeManager.hh @@ -90,6 +90,10 @@ struct OutAirNodeManagerData : BaseGlobalStruct { } + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void clear_state() override { this->OutsideAirNodeList.deallocate(); diff --git a/src/EnergyPlus/OutdoorAirUnit.cc b/src/EnergyPlus/OutdoorAirUnit.cc index 0bcfee8c6d0..fe34f6abe74 100644 --- a/src/EnergyPlus/OutdoorAirUnit.cc +++ b/src/EnergyPlus/OutdoorAirUnit.cc @@ -114,7 +114,6 @@ namespace OutdoorAirUnit { using HVAC::SmallAirVolFlow; using HVAC::SmallLoad; using HVAC::SmallMassFlow; - using namespace ScheduleManager; using namespace Psychrometrics; // component types addressed by this module @@ -218,7 +217,6 @@ namespace OutdoorAirUnit { using BranchNodeConnections::SetUpCompSets; using BranchNodeConnections::TestCompSet; using NodeInputManager::GetOnlySingleNode; - using ScheduleManager::GetScheduleIndex; using SteamCoils::GetCoilAirInletNode; using SteamCoils::GetCoilAirOutletNode; using SteamCoils::GetCoilMaxSteamFlowRate; @@ -312,20 +310,11 @@ namespace OutdoorAirUnit { thisOutAirUnit.Name = state.dataIPShortCut->cAlphaArgs(1); // A2 - thisOutAirUnit.SchedName = state.dataIPShortCut->cAlphaArgs(2); if (lAlphaBlanks(2)) { - thisOutAirUnit.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - thisOutAirUnit.SchedPtr = GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(2)); // convert schedule name to pointer - if (thisOutAirUnit.SchedPtr == 0) { - ShowSevereError(state, - format("{}=\"{}\" invalid {}=\"{}\" not found.", - CurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaArgs(2), - state.dataIPShortCut->cAlphaArgs(2))); - ErrorsFound = true; - } + thisOutAirUnit.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((thisOutAirUnit.availSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaArgs(2), state.dataIPShortCut->cAlphaArgs(2)); + ErrorsFound = true; } // A3 @@ -354,16 +343,11 @@ namespace OutdoorAirUnit { // N1 thisOutAirUnit.OutAirVolFlow = NumArray(1); // A4 - thisOutAirUnit.OutAirSchedName = state.dataIPShortCut->cAlphaArgs(4); - // convert schedule name to pointer - thisOutAirUnit.OutAirSchedPtr = GetScheduleIndex(state, thisOutAirUnit.OutAirSchedName); - if (thisOutAirUnit.OutAirSchedPtr == 0) { - ShowSevereError(state, - format("{}=\"{}\" invalid {}=\"{}\" not found.", - CurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), - cAlphaFields(4), - state.dataIPShortCut->cAlphaArgs(4))); + if (lAlphaBlanks(4)) { + ShowSevereEmptyField(state, eoh, cAlphaFields(4)); + ErrorsFound = true; + } else if ((thisOutAirUnit.outAirSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(4))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(4), state.dataIPShortCut->cAlphaArgs(4)); ErrorsFound = true; } @@ -383,7 +367,7 @@ namespace OutdoorAirUnit { auto *fan = state.dataFans->fans(thisOutAirUnit.SFan_Index); thisOutAirUnit.supFanType = fan->type; thisOutAirUnit.SFanMaxAirVolFlow = fan->maxAirFlowRate; - thisOutAirUnit.SFanAvailSchedPtr = fan->availSchedNum; + thisOutAirUnit.supFanAvailSched = fan->availSched; } // A6 :Fan Place thisOutAirUnit.supFanPlace = static_cast(getEnumValue(HVAC::fanPlaceNamesUC, state.dataIPShortCut->cAlphaArgs(6))); @@ -414,7 +398,7 @@ namespace OutdoorAirUnit { auto *fan = state.dataFans->fans(thisOutAirUnit.ExtFan_Index); thisOutAirUnit.extFanType = fan->type; thisOutAirUnit.EFanMaxAirVolFlow = fan->maxAirFlowRate; - thisOutAirUnit.ExtFanAvailSchedPtr = fan->availSchedNum; + thisOutAirUnit.extFanAvailSched = fan->availSched; } thisOutAirUnit.ExtFan = true; } @@ -433,33 +417,28 @@ namespace OutdoorAirUnit { } } // A8 - thisOutAirUnit.ExtAirSchedName = state.dataIPShortCut->cAlphaArgs(8); + // convert schedule name to pointer - thisOutAirUnit.ExtOutAirSchedPtr = GetScheduleIndex(state, thisOutAirUnit.ExtAirSchedName); if (thisOutAirUnit.ExtFan) { - if ((thisOutAirUnit.ExtOutAirSchedPtr == 0) || (lNumericBlanks(2))) { - ShowSevereError(state, - format("{}=\"{}\" invalid {}=\"{}\" not found.", - CurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), - cAlphaFields(8), - state.dataIPShortCut->cAlphaArgs(8))); + if (lAlphaBlanks(8)) { + ShowSevereEmptyField(state, eoh, cAlphaFields(8)); ErrorsFound = true; - } else { - if ((thisOutAirUnit.ExtOutAirSchedPtr != thisOutAirUnit.OutAirSchedPtr) && - (!state.dataHeatBal->ZoneAirMassFlow.EnforceZoneMassBalance)) { - ShowWarningError( - state, - format("{}=\"{}\", different schedule inputs for outdoor air and exhaust air schedules may cause unbalanced mass flow.", - CurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, - format("{}={} and {}={}", - cAlphaFields(4), - state.dataIPShortCut->cAlphaArgs(4), - cAlphaFields(8), - state.dataIPShortCut->cAlphaArgs(8))); - } + } else if ((thisOutAirUnit.extAirSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(8))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(8), state.dataIPShortCut->cAlphaArgs(8)); + ErrorsFound = true; + } else if ((thisOutAirUnit.extAirSched != thisOutAirUnit.outAirSched) && + (!state.dataHeatBal->ZoneAirMassFlow.EnforceZoneMassBalance)) { + ShowWarningError( + state, + format("{}=\"{}\", different schedule inputs for outdoor air and exhaust air schedules may cause unbalanced mass flow.", + CurrentModuleObject, + state.dataIPShortCut->cAlphaArgs(1))); + ShowContinueError(state, + format("{}={} and {}={}", + cAlphaFields(4), + state.dataIPShortCut->cAlphaArgs(4), + cAlphaFields(8), + state.dataIPShortCut->cAlphaArgs(8))); } SetUpCompSets( @@ -467,52 +446,31 @@ namespace OutdoorAirUnit { } // Process the unit control type - if (!lAlphaBlanks(9)) { - constexpr std::array(OAUnitCtrlType::Num)> ctrlTypeNamesUC = { + if (lAlphaBlanks(9)) { + ShowWarningEmptyField(state, eoh, cAlphaFields(9), "Control reset to Unconditioned Control."); + thisOutAirUnit.controlType = OAUnitCtrlType::Neutral; + } else { + constexpr std::array ctrlTypeNamesUC = { "NEUTRALCONTROL", "INVALID-UNCONDITIONED", "TEMPERATURECONTROL"}; - OAUnitCtrlType const tmpCtrlType = static_cast(getEnumValue(ctrlTypeNamesUC, state.dataIPShortCut->cAlphaArgs(9))); - switch (tmpCtrlType) { - case OAUnitCtrlType::Neutral: - case OAUnitCtrlType::Temperature: + OAUnitCtrlType tmpCtrlType = static_cast(getEnumValue(ctrlTypeNamesUC, state.dataIPShortCut->cAlphaArgs(9))); + if (tmpCtrlType == OAUnitCtrlType::Invalid) { + ShowWarningEmptyField(state, eoh, cAlphaFields(9), "Control reset to Unconditioned Control."); + } else if (tmpCtrlType == OAUnitCtrlType::Neutral || tmpCtrlType == OAUnitCtrlType::Temperature) { thisOutAirUnit.controlType = tmpCtrlType; - break; - default: - break; // just leave it alone, nothing was done here } - } else { - ShowSevereError(state, - format(R"({}="{}" invalid {}="{}".)", - CurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), - cAlphaFields(9), - state.dataIPShortCut->cAlphaArgs(9))); - ShowContinueError(state, "Control reset to Unconditioned Control."); - thisOutAirUnit.controlType = OAUnitCtrlType::Neutral; } // A10:High Control Temp : - thisOutAirUnit.HiCtrlTempSched = state.dataIPShortCut->cAlphaArgs(10); - thisOutAirUnit.HiCtrlTempSchedPtr = GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(10)); - if ((thisOutAirUnit.HiCtrlTempSchedPtr == 0) && (!lAlphaBlanks(10))) { - ShowSevereError(state, - format(R"({}="{}" invalid {}="{}" not found.)", - CurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), - cAlphaFields(10), - state.dataIPShortCut->cAlphaArgs(9))); + if (lAlphaBlanks(10)) { + } else if ((thisOutAirUnit.hiCtrlTempSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(10))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(10), state.dataIPShortCut->cAlphaArgs(10)); ErrorsFound = true; } // A11:Low Control Temp : - thisOutAirUnit.LoCtrlTempSched = state.dataIPShortCut->cAlphaArgs(11); - thisOutAirUnit.LoCtrlTempSchedPtr = GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(11)); - if ((thisOutAirUnit.LoCtrlTempSchedPtr == 0) && (!lAlphaBlanks(11))) { - ShowSevereError(state, - format(R"({}="{}" invalid {}="{}" not found.)", - CurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), - cAlphaFields(11), - state.dataIPShortCut->cAlphaArgs(10))); + if (lAlphaBlanks(11)) { + } else if ((thisOutAirUnit.loCtrlTempSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(11))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(11), state.dataIPShortCut->cAlphaArgs(11)); ErrorsFound = true; } @@ -1118,7 +1076,6 @@ namespace OutdoorAirUnit { using HVACHXAssistedCoolingCoil::SimHXAssistedCoolingCoil; using PlantUtilities::InitComponentNodes; using PlantUtilities::ScanPlantLoopsForObject; - using ScheduleManager::GetCurrentScheduleValue; using SteamCoils::GetCoilMaxSteamFlowRate; using WaterCoils::SimulateWaterCoilComponents; @@ -1135,7 +1092,7 @@ namespace OutdoorAirUnit { int const InNode = thisOutAirUnit.AirInletNode; int const OutNode = thisOutAirUnit.AirOutletNode; int const OutsideAirNode = thisOutAirUnit.OutsideAirNode; - Real64 const OAFrac = GetCurrentScheduleValue(state, thisOutAirUnit.OutAirSchedPtr); + Real64 const OAFrac = thisOutAirUnit.outAirSched->getCurrentVal(); if (state.dataOutdoorAirUnit->MyOneTimeFlag) { @@ -1225,7 +1182,7 @@ namespace OutdoorAirUnit { if (thisOutAirUnit.ExtFan) { // set the exhaust air mass flow rate from input - Real64 const EAFrac = GetCurrentScheduleValue(state, thisOutAirUnit.ExtOutAirSchedPtr); + Real64 const EAFrac = thisOutAirUnit.extAirSched->getCurrentVal(); thisOutAirUnit.ExtAirMassFlow = RhoAir * EAFrac * thisOutAirUnit.ExtAirVolFlow; thisOutAirUnit.EMaxAirMassFlow = RhoAir * EAFrac * thisOutAirUnit.EFanMaxAirVolFlow; @@ -1348,9 +1305,8 @@ namespace OutdoorAirUnit { // set the exhaust air mass flow rate from input if (thisOutAirUnit.ExtFan) { - Real64 const EAFrac = GetCurrentScheduleValue(state, thisOutAirUnit.ExtOutAirSchedPtr); - if (thisOutAirUnit.ExtFanAvailSchedPtr > 0.0) { - thisOutAirUnit.ExtAirMassFlow = RhoAir * EAFrac * thisOutAirUnit.ExtAirVolFlow; + if (thisOutAirUnit.extFanAvailSched != nullptr) { + thisOutAirUnit.ExtAirMassFlow = RhoAir * thisOutAirUnit.ExtAirVolFlow * thisOutAirUnit.extAirSched->getCurrentVal(); } else { thisOutAirUnit.ExtAirMassFlow = 0.0; } @@ -1603,7 +1559,6 @@ namespace OutdoorAirUnit { auto &TurnFansOn = state.dataHVACGlobal->TurnFansOn; using HeatingCoils::CheckHeatingCoilSchedule; using HVACHXAssistedCoolingCoil::CheckHXAssistedCoolingCoilSchedule; - using ScheduleManager::GetCurrentScheduleValue; // Locals @@ -1644,8 +1599,8 @@ namespace OutdoorAirUnit { thisOutAirUnit.CompOutSetTemp = 0.0; thisOutAirUnit.FanEffect = false; - if ((GetCurrentScheduleValue(state, thisOutAirUnit.SchedPtr) <= 0) || (GetCurrentScheduleValue(state, thisOutAirUnit.OutAirSchedPtr) <= 0) || - ((GetCurrentScheduleValue(state, thisOutAirUnit.SFanAvailSchedPtr) <= 0) && !TurnFansOn) || TurnFansOff) { + if ((thisOutAirUnit.availSched->getCurrentVal() <= 0) || (thisOutAirUnit.outAirSched->getCurrentVal() <= 0) || + ((thisOutAirUnit.supFanAvailSched->getCurrentVal() <= 0) && !TurnFansOn) || TurnFansOff) { // System is off or has no load upon the unit; set the flow rates to zero and then // simulate the components with the no flow conditions if (thisOutAirUnit.ExtFan) { @@ -1753,8 +1708,8 @@ namespace OutdoorAirUnit { } break; case OAUnitCtrlType::Temperature: { SetPointTemp = DesOATemp; - HiCtrlTemp = GetCurrentScheduleValue(state, thisOutAirUnit.HiCtrlTempSchedPtr); - LoCtrlTemp = GetCurrentScheduleValue(state, thisOutAirUnit.LoCtrlTempSchedPtr); + HiCtrlTemp = thisOutAirUnit.hiCtrlTempSched->getCurrentVal(); + LoCtrlTemp = thisOutAirUnit.loCtrlTempSched->getCurrentVal(); if ((DesOATemp <= HiCtrlTemp) && (DesOATemp >= LoCtrlTemp)) { thisOutAirUnit.OperatingMode = Operation::NeutralMode; AirOutletTemp = DesOATemp; @@ -1913,7 +1868,6 @@ namespace OutdoorAirUnit { using HVAC::SmallLoad; using HVACDXHeatPumpSystem::SimDXHeatPumpSystem; using HVACHXAssistedCoolingCoil::SimHXAssistedCoolingCoil; - using ScheduleManager::GetCurrentScheduleValue; using WaterCoils::SimulateWaterCoilComponents; // SUBROUTINE LOCAL VARIABLE DEFINITIONS diff --git a/src/EnergyPlus/OutdoorAirUnit.hh b/src/EnergyPlus/OutdoorAirUnit.hh index 977c9c4f3fc..ea8cb08d62c 100644 --- a/src/EnergyPlus/OutdoorAirUnit.hh +++ b/src/EnergyPlus/OutdoorAirUnit.hh @@ -173,8 +173,7 @@ namespace OutdoorAirUnit { // Members // Input data std::string Name; // name of unit - std::string SchedName; // availability schedule - int SchedPtr; // index to schedule + Sched::Schedule *availSched = nullptr; // availability std::string ZoneName; // Name of zone the system is serving int ZonePtr; // Point to this zone in the Zone derived type int ZoneNodeNum; // index of zone air node in node structure @@ -186,7 +185,7 @@ namespace OutdoorAirUnit { std::string SFanName; // name of supply fan int SFan_Index; // index in fan structure HVAC::FanType supFanType; // type of fan in cFanTypes - int SFanAvailSchedPtr; // supply fan availability sched from fan object + Sched::Schedule *supFanAvailSched = nullptr; // supply fan availability sched from fan object HVAC::FanPlace supFanPlace; // fan placement; blow through and draw through Real64 FanCorTemp; // correction temperature bool FanEffect; // .TRUE. if unit has a fan type of draw through @@ -194,25 +193,21 @@ namespace OutdoorAirUnit { std::string ExtFanName; // name of exhaust fan int ExtFan_Index; // index in fan structure HVAC::FanType extFanType; // type of fan in cFanTypes - int ExtFanAvailSchedPtr; // exhaust fan availability sched from fan object + Sched::Schedule *extFanAvailSched = nullptr; // exhaust fan availability sched from fan object bool ExtFan; // true if there is an exhaust fan - std::string OutAirSchedName; // schedule of fraction for outside air (all controls) - int OutAirSchedPtr; // index to schedule + Sched::Schedule *outAirSched = nullptr; // schedule of fraction for outside air (all controls) int OutsideAirNode; // outside air node number Real64 OutAirVolFlow; // m3/s Real64 OutAirMassFlow; // kg/s Real64 ExtAirVolFlow; // m3/s Real64 ExtAirMassFlow; // kg/s - std::string ExtAirSchedName; // schedule of fraction for exhaust air - int ExtOutAirSchedPtr; // index to schedule + Sched::Schedule *extAirSched = nullptr; // schedule of fraction for exhaust air Real64 SMaxAirMassFlow; // kg/s Real64 EMaxAirMassFlow; // kg/s Real64 SFanMaxAirVolFlow; // m3/s Real64 EFanMaxAirVolFlow; // m3/s - std::string HiCtrlTempSched; // Schedule name for the High Control Air temperature - int HiCtrlTempSchedPtr; // Schedule index for the High Control Air temperature - std::string LoCtrlTempSched; // Schedule name for the Low Control Air temperature - int LoCtrlTempSchedPtr; // Schedule index for the Low Control Air temperature + Sched::Schedule *hiCtrlTempSched = nullptr; // Schedule name for the High Control Air temperature + Sched::Schedule *loCtrlTempSched = nullptr; // Schedule name for the Low Control Air temperature Operation OperatingMode; // operating condition( NeutralMode, HeatingMode, CoolingMode) int ControlCompTypeNum; int CompErrIndex; @@ -243,12 +238,12 @@ namespace OutdoorAirUnit { // Default Constructor OAUnitData() - : SchedPtr(0), ZonePtr(0), ZoneNodeNum(0), controlType(OAUnitCtrlType::Invalid), AirInletNode(0), AirOutletNode(0), SFan_Index(0), - supFanType(HVAC::FanType::Invalid), SFanAvailSchedPtr(0), supFanPlace(HVAC::FanPlace::Invalid), FanCorTemp(0.0), FanEffect(false), - SFanOutletNode(0), ExtFan_Index(0), extFanType(HVAC::FanType::Invalid), ExtFanAvailSchedPtr(0), ExtFan(false), OutAirSchedPtr(0), - OutsideAirNode(0), OutAirVolFlow(0.0), OutAirMassFlow(0.0), ExtAirVolFlow(0.0), ExtAirMassFlow(0.0), ExtOutAirSchedPtr(0), - SMaxAirMassFlow(0.0), EMaxAirMassFlow(0.0), SFanMaxAirVolFlow(0.0), EFanMaxAirVolFlow(0.0), HiCtrlTempSchedPtr(0), - LoCtrlTempSchedPtr(0), OperatingMode(Operation::Invalid), ControlCompTypeNum(0), CompErrIndex(0), AirMassFlow(0.0), FlowError(false), + : ZonePtr(0), ZoneNodeNum(0), controlType(OAUnitCtrlType::Invalid), AirInletNode(0), AirOutletNode(0), SFan_Index(0), + supFanType(HVAC::FanType::Invalid), supFanPlace(HVAC::FanPlace::Invalid), FanCorTemp(0.0), FanEffect(false), + SFanOutletNode(0), ExtFan_Index(0), extFanType(HVAC::FanType::Invalid), ExtFan(false), + OutsideAirNode(0), OutAirVolFlow(0.0), OutAirMassFlow(0.0), ExtAirVolFlow(0.0), ExtAirMassFlow(0.0), + SMaxAirMassFlow(0.0), EMaxAirMassFlow(0.0), SFanMaxAirVolFlow(0.0), EFanMaxAirVolFlow(0.0), + OperatingMode(Operation::Invalid), ControlCompTypeNum(0), CompErrIndex(0), AirMassFlow(0.0), FlowError(false), NumComponents(0), CompOutSetTemp(0.0), TotCoolingRate(0.0), TotCoolingEnergy(0.0), SensCoolingRate(0.0), SensCoolingEnergy(0.0), LatCoolingRate(0.0), LatCoolingEnergy(0.0), ElecFanRate(0.0), ElecFanEnergy(0.0), SensHeatingEnergy(0.0), SensHeatingRate(0.0), LatHeatingEnergy(0.0), LatHeatingRate(0.0), TotHeatingEnergy(0.0), TotHeatingRate(0.0), FirstPass(true) @@ -333,6 +328,10 @@ struct OutdoorAirUnitData : BaseGlobalStruct bool HeatActive = false; bool CoolActive = false; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/OutputProcessor.cc b/src/EnergyPlus/OutputProcessor.cc index 926a1d947b1..814d02f44ef 100644 --- a/src/EnergyPlus/OutputProcessor.cc +++ b/src/EnergyPlus/OutputProcessor.cc @@ -182,7 +182,7 @@ namespace OutputProcessor { op->OutputInitialized = true; - op->TimeStepZoneSec = double(state.dataGlobal->MinutesPerTimeStep) * 60.0; + op->TimeStepZoneSec = double(state.dataGlobal->MinutesInTimeStep) * 60.0; state.files.mtd.ensure_open(state, "InitializeMeters", state.files.outputControl.mtd); } // InitializeOutput() @@ -329,7 +329,7 @@ namespace OutputProcessor { bool Dup = false; // op->ReportList is allocated to a large value, so we can't use a std::find_if on it (why not?) for (int iReqVar2 : reqVarList) { - if (op->reqVars[iReqVar2]->freq == reqVar->freq && op->reqVars[iReqVar2]->SchedPtr == reqVar->SchedPtr) { + if (op->reqVars[iReqVar2]->freq == reqVar->freq && op->reqVars[iReqVar2]->sched == reqVar->sched) { Dup = true; break; } @@ -447,8 +447,6 @@ namespace OutputProcessor { // \object-list ScheduleNames constexpr std::string_view routineName = "GetReportVariableInput"; - // Using/Aliasing - using ScheduleManager::GetScheduleIndex; // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int NumAlpha; @@ -531,8 +529,8 @@ namespace OutputProcessor { // Schedule information if (lAlphaBlanks(4)) { - reqVar->SchedPtr = 0; - } else if ((reqVar->SchedPtr = GetScheduleIndex(state, Util::makeUPPER(cAlphaArgs(4)))) == 0) { + reqVar->sched = nullptr; + } else if ((reqVar->sched = Sched::GetSchedule(state, cAlphaArgs(4))) == nullptr) { ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(4), cAlphaArgs(4)); ErrorsFound = true; } @@ -782,11 +780,11 @@ namespace OutputProcessor { units = srcMeter->units; itemsAssigned = true; } else if (units != srcMeter->units) { - ShowWarningCustomMessage(state, - eoh, - format(R"(Meter:Custom="{}", differing units in {}="{}".)", - ipsc->cAlphaArgs(1), - ipsc->cAlphaFieldNames(fldIndex + 1), + ShowWarningCustom(state, + eoh, + format(R"(Meter:Custom="{}", differing units in {}="{}".)", + ipsc->cAlphaArgs(1), + ipsc->cAlphaFieldNames(fldIndex + 1), meterOrVarNameUC)); ShowContinueError(state, format("...will not be shown with the Meter results; units for meter={}, units for this variable={}.", @@ -803,12 +801,12 @@ namespace OutputProcessor { // Has to be a summed variable if (srcDDVar->storeType != StoreType::Sum) { - ShowWarningCustomMessage(state, - eoh, - format(R"(Meter:Custom="{}", variable not summed variable {}="{}".)", - ipsc->cAlphaArgs(1), - ipsc->cAlphaFieldNames(fldIndex + 1), - meterOrVarNameUC)); + ShowWarningCustom(state, + eoh, + format(R"(Meter:Custom="{}", variable not summed variable {}="{}".)", + ipsc->cAlphaArgs(1), + ipsc->cAlphaFieldNames(fldIndex + 1), + meterOrVarNameUC)); ShowContinueError(state, format("...will not be shown with the Meter results; units for meter={}, units for this variable={}.", Constant::unitNames[(int)units], @@ -822,7 +820,7 @@ namespace OutputProcessor { units = srcDDVar->units; // Otherwise it has to match the existing units } else if (units != srcDDVar->units) { - ShowWarningCustomMessage( + ShowWarningCustom( state, eoh, format("differing units in {}=\"{}\".", ipsc->cAlphaFieldNames(fldIndex + 1), meterOrVarNameUC)); ShowContinueError(state, format("...will not be shown with the Meter results; units for meter={}, units for this variable={}.", @@ -930,11 +928,11 @@ namespace OutputProcessor { // Check for duplicates if (std::find(meter->srcMeterNums.begin(), meter->srcMeterNums.end(), srcMeterNum) != meter->srcMeterNums.end()) { - ShowWarningCustomMessage(state, - eoh, - format("{}=\"{}\" referenced multiple times, only first instance will be used", - ipsc->cAlphaFieldNames(fldIndex + 1), - meterOrVarNameUC)); + ShowWarningCustom(state, + eoh, + format("{}=\"{}\" referenced multiple times, only first instance will be used", + ipsc->cAlphaFieldNames(fldIndex + 1), + meterOrVarNameUC)); continue; } @@ -963,11 +961,11 @@ namespace OutputProcessor { // No need to check for empty keys for (int keyOutVarNum : srcDDVar->keyOutVarNums) { if (std::find(meter->srcVarNums.begin(), meter->srcVarNums.end(), keyOutVarNum) != meter->srcVarNums.end()) { - ShowWarningCustomMessage(state, - eoh, - format("Output variable \"{}\" referenced multiple times (directly or via meter)", - op->outVars[keyOutVarNum]->keyColonNameUC)); - + ShowWarningCustom(state, + eoh, + format("Output variable \"{}\" referenced multiple times (directly or via meter)", + op->outVars[keyOutVarNum]->keyColonNameUC)); + } else { meter->srcVarNums.push_back(keyOutVarNum); op->outVars[keyOutVarNum]->meterNums.push_back(meterNum); @@ -977,10 +975,10 @@ namespace OutputProcessor { for (int keyOutVarNum : srcDDVar->keyOutVarNums) { if (op->outVars[keyOutVarNum]->keyUC == ipsc->cAlphaArgs(fldIndex)) { if (std::find(meter->srcVarNums.begin(), meter->srcVarNums.end(), keyOutVarNum) != meter->srcVarNums.end()) { - ShowWarningCustomMessage(state, - eoh, - format("Output variable \"{}\" referenced multiple times (directly or via meter)", - op->outVars[keyOutVarNum]->keyColonNameUC)); + ShowWarningCustom(state, + eoh, + format("Output variable \"{}\" referenced multiple times (directly or via meter)", + op->outVars[keyOutVarNum]->keyColonNameUC)); } else { meter->srcVarNums.push_back(keyOutVarNum); op->outVars[keyOutVarNum]->meterNums.push_back(meterNum); @@ -1104,12 +1102,12 @@ namespace OutputProcessor { units = srcMeter->units; itemsAssigned = true; } else if (units != srcMeter->units) { - ShowWarningCustomMessage(state, - eoh, - format(R"(Meter:Custom="{}", differing units in {}="{}".)", - ipsc->cAlphaArgs(1), - ipsc->cAlphaFieldNames(fldIndex + 1), - meterOrVarNameUC)); + ShowWarningCustom(state, + eoh, + format(R"(Meter:Custom="{}", differing units in {}="{}".)", + ipsc->cAlphaArgs(1), + ipsc->cAlphaFieldNames(fldIndex + 1), + meterOrVarNameUC)); ShowContinueError(state, format("...will not be shown with the Meter results; units for meter={}, units for this variable={}.", Constant::unitNames[(int)units], @@ -1125,12 +1123,12 @@ namespace OutputProcessor { // Has to be a summed variable if (srcDDVar->storeType != StoreType::Sum) { - ShowWarningCustomMessage(state, - eoh, - format(R"(Meter:Custom="{}", variable not summed variable {}="{}".)", - ipsc->cAlphaArgs(1), - ipsc->cAlphaFieldNames(fldIndex + 1), - meterOrVarNameUC)); + ShowWarningCustom(state, + eoh, + format(R"(Meter:Custom="{}", variable not summed variable {}="{}".)", + ipsc->cAlphaArgs(1), + ipsc->cAlphaFieldNames(fldIndex + 1), + meterOrVarNameUC)); ShowContinueError(state, format("...will not be shown with the Meter results; units for meter={}, units for this variable={}.", Constant::unitNames[(int)units], @@ -1144,7 +1142,7 @@ namespace OutputProcessor { units = srcDDVar->units; // Otherwise it has to match the existing units } else if (units != srcDDVar->units) { - ShowWarningCustomMessage( + ShowWarningCustom( state, eoh, format("differing units in {}=\"{}\".", ipsc->cAlphaFieldNames(fldIndex + 1), meterOrVarNameUC)); ShowContinueError(state, format("...will not be shown with the Meter results; units for meter={}, units for this variable={}.", @@ -1265,11 +1263,11 @@ namespace OutputProcessor { // Check for duplicates if (std::find(meter->srcMeterNums.begin(), meter->srcMeterNums.end(), srcMeterNum) != meter->srcMeterNums.end()) { - ShowWarningCustomMessage(state, - eoh, - format("{}=\"{}\" referenced multiple times, only first instance will be used", - ipsc->cAlphaFieldNames(fldIndex + 1), - meterOrVarNameUC)); + ShowWarningCustom(state, + eoh, + format("{}=\"{}\" referenced multiple times, only first instance will be used", + ipsc->cAlphaFieldNames(fldIndex + 1), + meterOrVarNameUC)); continue; } @@ -1298,11 +1296,11 @@ namespace OutputProcessor { // No need to check for empty keys for (int keyOutVarNum : srcDDVar->keyOutVarNums) { if (std::find(meter->srcVarNums.begin(), meter->srcVarNums.end(), keyOutVarNum) != meter->srcVarNums.end()) { - ShowWarningCustomMessage(state, - eoh, - format("Output variable \"{}\" referenced multiple times (directly or via meter)", - op->outVars[keyOutVarNum]->keyColonNameUC)); - + ShowWarningCustom(state, + eoh, + format("Output variable \"{}\" referenced multiple times (directly or via meter)", + op->outVars[keyOutVarNum]->keyColonNameUC)); + } else { meter->srcVarNums.push_back(keyOutVarNum); op->outVars[keyOutVarNum]->meterNums.push_back(meterNum); @@ -1312,10 +1310,10 @@ namespace OutputProcessor { for (int keyOutVarNum : srcDDVar->keyOutVarNums) { if (op->outVars[keyOutVarNum]->keyUC == ipsc->cAlphaArgs(fldIndex)) { if (std::find(meter->srcVarNums.begin(), meter->srcVarNums.end(), keyOutVarNum) != meter->srcVarNums.end()) { - ShowWarningCustomMessage(state, - eoh, - format("Output variable \"{}\" referenced multiple times (directly or via meter)", - op->outVars[keyOutVarNum]->keyColonNameUC)); + ShowWarningCustom(state, + eoh, + format("Output variable \"{}\" referenced multiple times (directly or via meter)", + op->outVars[keyOutVarNum]->keyColonNameUC)); } else { meter->srcVarNums.push_back(keyOutVarNum); op->outVars[keyOutVarNum]->meterNums.push_back(meterNum); @@ -1773,7 +1771,7 @@ namespace OutputProcessor { EndMinute, StartMinute, state.dataEnvrn->DSTIndicator, - ScheduleManager::dayTypeNames[CurDayType]); + Sched::dayTypeNames[CurDayType]); if (rfMetersTS.dataFrameEnabled()) { rfMetersTS.newRow( state.dataEnvrn->Month, state.dataEnvrn->DayOfMonth, state.dataGlobal->HourOfDay, EndMinute, state.dataGlobal->CalendarYear); @@ -1796,7 +1794,7 @@ namespace OutputProcessor { EndMinute, StartMinute, state.dataEnvrn->DSTIndicator, - ScheduleManager::dayTypeNames[CurDayType]); + Sched::dayTypeNames[CurDayType]); PrintESOTimeStamp = false; } @@ -1875,7 +1873,7 @@ namespace OutputProcessor { -1, // EndMinute -1, // StartMinute state.dataEnvrn->DSTIndicator, - ScheduleManager::dayTypeNames[CurDayType]); + Sched::dayTypeNames[CurDayType]); } break; case ReportFreq::Day: { @@ -1891,7 +1889,7 @@ namespace OutputProcessor { -1, // EndMinute -1, // StartMinute state.dataEnvrn->DSTIndicator, - ScheduleManager::dayTypeNames[CurDayType]); + Sched::dayTypeNames[CurDayType]); } break; case ReportFreq::Month: { @@ -2432,7 +2430,7 @@ namespace OutputProcessor { ? unitNameCustomEMS : ((units == Constant::Units::Invalid) ? "" : Constant::unitNames[(int)units]); - std::string schedString = (SchedPtr != 0) ? state.dataScheduleMgr->Schedule(SchedPtr).Name : ""; + std::string schedString = (sched != nullptr) ? sched->Name : ""; if (state.files.eso.good()) { print(state.files.eso, @@ -2624,7 +2622,7 @@ namespace OutputProcessor { } if (sql) { - sql->createSQLiteReportDataRecord(RptNum, Value, freq, MinVal, MinValDate, MaxVal, MaxValDate, state.dataGlobal->MinutesPerTimeStep); + sql->createSQLiteReportDataRecord(RptNum, Value, freq, MinVal, MinValDate, MaxVal, MaxValDate, state.dataGlobal->MinutesInTimeStep); } if ((freq == ReportFreq::EachCall) || (freq == ReportFreq::TimeStep) || (freq == ReportFreq::Hour)) { // -1, 0, 1 @@ -3019,7 +3017,7 @@ void SetupOutputVariable(EnergyPlusData &state, var->units = units; if (units == Constant::Units::customEMS) var->unitNameCustomEMS = customUnitName; var->freq = freq; - var->SchedPtr = 0; + var->sched = nullptr; var->ReportID = ++op->ReportNumberCounter; var->Which = &ActualVariable; var->ZoneMult = ZoneMult; @@ -3043,7 +3041,7 @@ void SetupOutputVariable(EnergyPlusData &state, // freq != ReportFreq::Hour if (freq == ReportFreq::Hour) { var->freq = op->reqVars[reqVarNum]->freq; - var->SchedPtr = op->reqVars[reqVarNum]->SchedPtr; + var->sched = op->reqVars[reqVarNum]->sched; } var->writeReportDictionaryItem(state); @@ -3134,10 +3132,10 @@ void SetupOutputVariable(EnergyPlusData &state, if (freq != ReportFreq::Hour) { var->freq = freq; - var->SchedPtr = 0; + var->sched = nullptr; } else { var->freq = op->reqVars[reqVarNum]->freq; - var->SchedPtr = op->reqVars[reqVarNum]->SchedPtr; + var->sched = op->reqVars[reqVarNum]->sched; } var->writeReportDictionaryItem(state); @@ -3161,7 +3159,6 @@ void UpdateDataandReport(EnergyPlusData &state, OutputProcessor::TimeStepType co // Using/Aliasing using namespace OutputProcessor; using General::EncodeMonDayHrMin; - using ScheduleManager::GetCurrentScheduleValue; // SUBROUTINE LOCAL VARIABLE DECLARATIONS: bool TimePrint(true); // True if the time needs to be printed @@ -3191,7 +3188,7 @@ void UpdateDataandReport(EnergyPlusData &state, OutputProcessor::TimeStepType co TimePrint = true; Real64 rxTime = (MinuteNow - StartMinute) / - double(state.dataGlobal->MinutesPerTimeStep); // (MinuteNow-StartMinute)/REAL(MinutesPerTimeStep,r64) - for execution time + double(state.dataGlobal->MinutesInTimeStep); // (MinuteNow-StartMinute)/REAL(MinutesPerTimeStep,r64) - for execution time if (rf->timeSeriesEnabled()) { // R and I data frames for TimeStepType::TimeStepZone @@ -3256,7 +3253,7 @@ void UpdateDataandReport(EnergyPlusData &state, OutputProcessor::TimeStepType co // End of "record keeping" Report if applicable if (!var->Report) continue; - if (var->SchedPtr > 0 && GetCurrentScheduleValue(state, var->SchedPtr) == 0.0) continue; + if (var->sched != nullptr && var->sched->getCurrentVal() == 0.0) continue; var->tsStored = true; if (!var->thisTSStored) { @@ -3285,7 +3282,7 @@ void UpdateDataandReport(EnergyPlusData &state, OutputProcessor::TimeStepType co op->TimeValue[(int)t_TimeStepTypeKey].CurMinute, StartMinute, state.dataEnvrn->DSTIndicator, - ScheduleManager::dayTypeNames[CurDayType]); + Sched::dayTypeNames[CurDayType]); op->LHourP = state.dataGlobal->HourOfDay; op->LStartMin = StartMinute; op->LEndMin = op->TimeValue[(int)t_TimeStepTypeKey].CurMinute; @@ -3351,7 +3348,7 @@ void UpdateDataandReport(EnergyPlusData &state, OutputProcessor::TimeStepType co if (var->timeStepType != TimeStepType::Zone && var->timeStepType != TimeStepType::System) continue; bool ReportNow = true; - if (var->SchedPtr > 0) ReportNow = (GetCurrentScheduleValue(state, var->SchedPtr) != 0.0); // SetReportNow(RVar%SchedPtr) + if (var->sched != nullptr) ReportNow = (var->sched->getCurrentVal() != 0.0); // SetReportNow(RVar%SchedPtr) if (!ReportNow || !var->Report) { var->TSValue = 0.0; } @@ -3383,7 +3380,7 @@ void UpdateDataandReport(EnergyPlusData &state, OutputProcessor::TimeStepType co op->TimeValue[(int)var->timeStepType].CurMinute, StartMinute, state.dataEnvrn->DSTIndicator, - ScheduleManager::dayTypeNames[CurDayType]); + Sched::dayTypeNames[CurDayType]); op->LHourP = state.dataGlobal->HourOfDay; op->LStartMin = StartMinute; op->LEndMin = op->TimeValue[(int)var->timeStepType].CurMinute; @@ -3427,7 +3424,7 @@ void UpdateDataandReport(EnergyPlusData &state, OutputProcessor::TimeStepType co -1, // EndMinute -1, // startMinute state.dataEnvrn->DSTIndicator, - ScheduleManager::dayTypeNames[CurDayType]); + Sched::dayTypeNames[CurDayType]); TimePrint = false; } @@ -3497,7 +3494,7 @@ void UpdateDataandReport(EnergyPlusData &state, OutputProcessor::TimeStepType co -1, // EndMinute -1, // StartMinute state.dataEnvrn->DSTIndicator, - ScheduleManager::dayTypeNames[CurDayType]); + Sched::dayTypeNames[CurDayType]); TimePrint = false; } if (rf->timeSeriesEnabled()) { @@ -4073,7 +4070,6 @@ Real64 GetInternalVariableValue(EnergyPlusData &state, // Using/Aliasing using namespace OutputProcessor; - using ScheduleManager::GetCurrentScheduleValue; // Return value Real64 resultVal; // value returned @@ -4095,7 +4091,7 @@ Real64 GetInternalVariableValue(EnergyPlusData &state, } else if (varType == VariableType::Meter) { resultVal = GetCurrentMeterValue(state, keyVarIndex); } else if (varType == VariableType::Schedule) { - resultVal = GetCurrentScheduleValue(state, keyVarIndex); + resultVal = state.dataSched->schedules[keyVarIndex]->getCurrentVal(); } else { resultVal = 0.0; } @@ -4124,7 +4120,6 @@ Real64 GetInternalVariableValueExternalInterface(EnergyPlusData &state, // Using/Aliasing using namespace OutputProcessor; - using ScheduleManager::GetCurrentScheduleValue; // Return value Real64 resultVal; // value returned @@ -4143,7 +4138,7 @@ Real64 GetInternalVariableValueExternalInterface(EnergyPlusData &state, } else if (varType == VariableType::Meter) { resultVal = GetCurrentMeterValue(state, keyVarIndex); } else if (varType == VariableType::Schedule) { - resultVal = GetCurrentScheduleValue(state, keyVarIndex); + resultVal = state.dataSched->schedules[keyVarIndex]->getCurrentVal(); } else { resultVal = 0.0; } @@ -4281,11 +4276,8 @@ void GetVariableKeyCountandType(EnergyPlusData &state, // When the variable is found, the variable type (varType) is set and the // number of associated keys is counted. - // Using/Aliasing using namespace OutputProcessor; - using ScheduleManager::GetScheduleIndex; - using ScheduleManager::GetScheduleType; - + // SUBROUTINE LOCAL VARIABLE DECLARATIONS: auto &op = state.dataOutputProcessor; @@ -4319,13 +4311,15 @@ void GetVariableKeyCountandType(EnergyPlusData &state, } else { // Search schedules if not found in integers, reals, or meters - // Use the GetScheduleIndex function // Schedules do not have keys, so only one will be found - int schedNum = GetScheduleIndex(state, nameUC); - if (schedNum > 0) { + auto *sched = Sched::GetSchedule(state, nameUC); + if (sched != nullptr) { numKeys = 1; varType = VariableType::Schedule; - units = static_cast(getEnumValue(Constant::unitNamesUC, Util::makeUPPER(GetScheduleType(state, schedNum)))); + if (sched->schedTypeNum != Sched::SchedNum_Invalid) { + std::string const &schedTypeName = state.dataSched->scheduleTypes[sched->schedTypeNum]->Name; + units = static_cast(getEnumValue(Constant::unitNamesUC, schedTypeName)); + } storeType = StoreType::Average; timeStepType = TimeStepType::Zone; } @@ -4360,7 +4354,6 @@ void GetVariableKeys(EnergyPlusData &state, // Using/Aliasing using namespace OutputProcessor; - using ScheduleManager::GetScheduleIndex; // SUBROUTINE LOCAL VARIABLE DECLARATIONS: std::string nameUC = Util::makeUPPER(varName); @@ -4397,7 +4390,7 @@ void GetVariableKeys(EnergyPlusData &state, if (size(keyOutVarNums) == 0) { ShowFatalError(state, "Invalid array size in GetVariableKeys"); } - keyOutVarNums(1) = GetScheduleIndex(state, varName); + keyOutVarNums(1) = Sched::GetScheduleNum(state, varName); keyNames(1) = "Environment"; } else { // do nothing diff --git a/src/EnergyPlus/OutputProcessor.hh b/src/EnergyPlus/OutputProcessor.hh index ccadcc8073f..d8234b9b17f 100644 --- a/src/EnergyPlus/OutputProcessor.hh +++ b/src/EnergyPlus/OutputProcessor.hh @@ -63,6 +63,7 @@ #include #include #include +#include // Third party Headers #include "re2/re2.h" @@ -444,7 +445,7 @@ namespace OutputProcessor { int maxValueDate = 0; // Date stamp of maximum int minValueDate = 0; // Date stamp of minimum int ReportID = 0; // Report variable ID number - int SchedPtr = 0; // If scheduled, this points to the schedule + Sched::Schedule *sched = nullptr; // If scheduled, this is schedule int ZoneMult = 1; // If metered, Zone Multiplier is applied int ZoneListMult = 1; // If metered, Zone List Multiplier is applied @@ -517,8 +518,7 @@ namespace OutputProcessor { std::string key = ""; // Could be blank or "*" std::string name = ""; // Name of Variable ReportFreq freq = ReportFreq::Hour; // Reporting Frequency - int SchedPtr = 0; // Index of the Schedule - std::string SchedName = ""; // Schedule Name + Sched::Schedule *sched = nullptr; // Schedule bool Used = false; // True when this combination (key, varname, frequency) has been set bool is_simple_string = true; // Whether the Key potentially includes a Regular Expression pattern @@ -942,6 +942,10 @@ struct OutputProcessorData : BaseGlobalStruct int maxNumEndUseSpaceTypes = 1; EPVector EndUseCategory; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/OutputReportPredefined.hh b/src/EnergyPlus/OutputReportPredefined.hh index 42820c0c763..ea774c43efc 100644 --- a/src/EnergyPlus/OutputReportPredefined.hh +++ b/src/EnergyPlus/OutputReportPredefined.hh @@ -1537,6 +1537,10 @@ struct OutputReportPredefinedData : BaseGlobalStruct Array1D CompSizeTableEntry; Array1D ShadowRelate; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/OutputReportTabular.cc b/src/EnergyPlus/OutputReportTabular.cc index bbf5530f5bc..772667c8e2e 100644 --- a/src/EnergyPlus/OutputReportTabular.cc +++ b/src/EnergyPlus/OutputReportTabular.cc @@ -1028,9 +1028,6 @@ void GetInputTabularTimeBins(EnergyPlusData &state) // REFERENCES: // na - // Using/Aliasing - using ScheduleManager::GetScheduleIndex; - // Locals // SUBROUTINE ARGUMENT DEFINITIONS: // na @@ -1056,6 +1053,8 @@ void GetInputTabularTimeBins(EnergyPlusData &state) Array1D_int objVarIDs; Array1D_string objNames; + static constexpr std::string_view routineName = "GetInputTabularTimeBins"; + auto &ort = state.dataOutRptTab; if (!state.files.outputControl.writeTabular(state)) { @@ -1099,20 +1098,17 @@ void GetInputTabularTimeBins(EnergyPlusData &state) state.dataIPShortCut->lAlphaFieldBlanks, state.dataIPShortCut->cAlphaFieldNames, state.dataIPShortCut->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, CurrentModuleObject, AlphArray(1)}; + ort->OutputTableBinned(iInObj).keyValue = AlphArray(1); ort->OutputTableBinned(iInObj).varOrMeter = AlphArray(2); // if a schedule has been specified assign - if (len(AlphArray(3)) > 0) { - ort->OutputTableBinned(iInObj).ScheduleName = AlphArray(3); - ort->OutputTableBinned(iInObj).scheduleIndex = GetScheduleIndex(state, AlphArray(3)); - if (ort->OutputTableBinned(iInObj).scheduleIndex == 0) { - ShowWarningError( - state, - format("{}: invalid {}=\"{}\" - not found.", CurrentModuleObject, state.dataIPShortCut->cAlphaFieldNames(3), AlphArray(3))); - } - } else { - ort->OutputTableBinned(iInObj).scheduleIndex = 0; // flag value for no schedule used + if (state.dataIPShortCut->lAlphaFieldBlanks(3)) { + } else if ((ort->OutputTableBinned(iInObj).sched = Sched::GetSchedule(state, AlphArray(3))) == nullptr) { + ShowWarningItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(3), AlphArray(3), ""); } + // validate the kind of variable - not used internally except for validation if (len(AlphArray(4)) > 0) { if (!(Util::SameString(AlphArray(4), "ENERGY") || Util::SameString(AlphArray(4), "DEMAND") || @@ -2831,7 +2827,8 @@ void GetInputFuelAndPollutionFactors(EnergyPlusData &state) Real64 curSourceFactor; bool fuelFactorUsed; bool fFScheduleUsed; - int ffScheduleIndex; + Sched::Schedule *ffSched = nullptr; + auto &ort = state.dataOutRptTab; // set the default factors for source energy - they will be overwritten if the user sets any values @@ -2863,7 +2860,7 @@ void GetInputFuelAndPollutionFactors(EnergyPlusData &state) // + gatherTotalsBEPS(5)*sourceFactorSteam & !steam // ) / largeConversionFactor - GetFuelFactorInfo(state, Constant::eFuel::NaturalGas, fuelFactorUsed, curSourceFactor, fFScheduleUsed, ffScheduleIndex); + GetFuelFactorInfo(state, Constant::eFuel::NaturalGas, fuelFactorUsed, curSourceFactor, fFScheduleUsed, &ffSched); if (fuelFactorUsed) { ort->sourceFactorNaturalGas = curSourceFactor; ort->fuelfactorsused(2) = true; @@ -2873,10 +2870,10 @@ void GetInputFuelAndPollutionFactors(EnergyPlusData &state) if (fFScheduleUsed) { ort->fuelFactorSchedulesUsed = true; ort->ffSchedUsed(2) = true; - ort->ffSchedIndex(2) = ffScheduleIndex; + ort->ffScheds(2) = ffSched; } - GetFuelFactorInfo(state, Constant::eFuel::FuelOilNo2, fuelFactorUsed, curSourceFactor, fFScheduleUsed, ffScheduleIndex); + GetFuelFactorInfo(state, Constant::eFuel::FuelOilNo2, fuelFactorUsed, curSourceFactor, fFScheduleUsed, &ffSched); if (fuelFactorUsed) { ort->sourceFactorFuelOil2 = curSourceFactor; ort->fuelfactorsused(7) = true; @@ -2886,10 +2883,10 @@ void GetInputFuelAndPollutionFactors(EnergyPlusData &state) if (fFScheduleUsed) { ort->fuelFactorSchedulesUsed = true; ort->ffSchedUsed(11) = true; - ort->ffSchedIndex(11) = ffScheduleIndex; + ort->ffScheds(11) = ffSched; } - GetFuelFactorInfo(state, Constant::eFuel::FuelOilNo1, fuelFactorUsed, curSourceFactor, fFScheduleUsed, ffScheduleIndex); + GetFuelFactorInfo(state, Constant::eFuel::FuelOilNo1, fuelFactorUsed, curSourceFactor, fFScheduleUsed, &ffSched); if (fuelFactorUsed) { ort->sourceFactorFuelOil1 = curSourceFactor; ort->fuelfactorsused(6) = true; @@ -2899,10 +2896,10 @@ void GetInputFuelAndPollutionFactors(EnergyPlusData &state) if (fFScheduleUsed) { ort->fuelFactorSchedulesUsed = true; ort->ffSchedUsed(10) = true; - ort->ffSchedIndex(10) = ffScheduleIndex; + ort->ffScheds(10) = ffSched; } - GetFuelFactorInfo(state, Constant::eFuel::Coal, fuelFactorUsed, curSourceFactor, fFScheduleUsed, ffScheduleIndex); + GetFuelFactorInfo(state, Constant::eFuel::Coal, fuelFactorUsed, curSourceFactor, fFScheduleUsed, &ffSched); if (fuelFactorUsed) { ort->sourceFactorCoal = curSourceFactor; ort->fuelfactorsused(5) = true; @@ -2912,10 +2909,10 @@ void GetInputFuelAndPollutionFactors(EnergyPlusData &state) if (fFScheduleUsed) { ort->fuelFactorSchedulesUsed = true; ort->ffSchedUsed(9) = true; - ort->ffSchedIndex(9) = ffScheduleIndex; + ort->ffScheds(9) = ffSched; } - GetFuelFactorInfo(state, Constant::eFuel::Electricity, fuelFactorUsed, curSourceFactor, fFScheduleUsed, ffScheduleIndex); + GetFuelFactorInfo(state, Constant::eFuel::Electricity, fuelFactorUsed, curSourceFactor, fFScheduleUsed, &ffSched); if (fuelFactorUsed) { ort->sourceFactorElectric = curSourceFactor; ort->fuelfactorsused(1) = true; @@ -2925,10 +2922,10 @@ void GetInputFuelAndPollutionFactors(EnergyPlusData &state) if (fFScheduleUsed) { ort->fuelFactorSchedulesUsed = true; ort->ffSchedUsed(1) = true; - ort->ffSchedIndex(1) = ffScheduleIndex; + ort->ffScheds(1) = ffSched; } - GetFuelFactorInfo(state, Constant::eFuel::Gasoline, fuelFactorUsed, curSourceFactor, fFScheduleUsed, ffScheduleIndex); + GetFuelFactorInfo(state, Constant::eFuel::Gasoline, fuelFactorUsed, curSourceFactor, fFScheduleUsed, &ffSched); if (fuelFactorUsed) { ort->sourceFactorGasoline = curSourceFactor; ort->fuelfactorsused(3) = true; @@ -2938,10 +2935,10 @@ void GetInputFuelAndPollutionFactors(EnergyPlusData &state) if (fFScheduleUsed) { ort->fuelFactorSchedulesUsed = true; ort->ffSchedUsed(6) = true; - ort->ffSchedIndex(6) = ffScheduleIndex; + ort->ffScheds(6) = ffSched; } - GetFuelFactorInfo(state, Constant::eFuel::Propane, fuelFactorUsed, curSourceFactor, fFScheduleUsed, ffScheduleIndex); + GetFuelFactorInfo(state, Constant::eFuel::Propane, fuelFactorUsed, curSourceFactor, fFScheduleUsed, &ffSched); if (fuelFactorUsed) { ort->sourceFactorPropane = curSourceFactor; ort->fuelfactorsused(8) = true; @@ -2951,10 +2948,10 @@ void GetInputFuelAndPollutionFactors(EnergyPlusData &state) if (fFScheduleUsed) { ort->fuelFactorSchedulesUsed = true; ort->ffSchedUsed(12) = true; - ort->ffSchedIndex(12) = ffScheduleIndex; + ort->ffScheds(12) = ffSched; } - GetFuelFactorInfo(state, Constant::eFuel::Diesel, fuelFactorUsed, curSourceFactor, fFScheduleUsed, ffScheduleIndex); + GetFuelFactorInfo(state, Constant::eFuel::Diesel, fuelFactorUsed, curSourceFactor, fFScheduleUsed, &ffSched); if (fuelFactorUsed) { ort->sourceFactorDiesel = curSourceFactor; ort->fuelfactorsused(4) = true; @@ -2964,40 +2961,40 @@ void GetInputFuelAndPollutionFactors(EnergyPlusData &state) if (fFScheduleUsed) { ort->fuelFactorSchedulesUsed = true; ort->ffSchedUsed(8) = true; - ort->ffSchedIndex(8) = ffScheduleIndex; + ort->ffScheds(8) = ffSched; } - GetFuelFactorInfo(state, Constant::eFuel::DistrictCooling, fuelFactorUsed, curSourceFactor, fFScheduleUsed, ffScheduleIndex); + GetFuelFactorInfo(state, Constant::eFuel::DistrictCooling, fuelFactorUsed, curSourceFactor, fFScheduleUsed, &ffSched); if (fuelFactorUsed) { ort->ffUsed(3) = true; } ort->SourceFactors(3) = curSourceFactor; if (fFScheduleUsed) { ort->ffSchedUsed(3) = true; - ort->ffSchedIndex(3) = ffScheduleIndex; + ort->ffScheds(3) = ffSched; } - GetFuelFactorInfo(state, Constant::eFuel::DistrictHeatingWater, fuelFactorUsed, curSourceFactor, fFScheduleUsed, ffScheduleIndex); + GetFuelFactorInfo(state, Constant::eFuel::DistrictHeatingWater, fuelFactorUsed, curSourceFactor, fFScheduleUsed, &ffSched); if (fuelFactorUsed) { ort->ffUsed(4) = true; } ort->SourceFactors(4) = curSourceFactor; if (fFScheduleUsed) { ort->ffSchedUsed(4) = true; - ort->ffSchedIndex(4) = ffScheduleIndex; + ort->ffScheds(4) = ffSched; } - GetFuelFactorInfo(state, Constant::eFuel::DistrictHeatingSteam, fuelFactorUsed, curSourceFactor, fFScheduleUsed, ffScheduleIndex); + GetFuelFactorInfo(state, Constant::eFuel::DistrictHeatingSteam, fuelFactorUsed, curSourceFactor, fFScheduleUsed, &ffSched); if (fuelFactorUsed) { ort->ffUsed(5) = true; } ort->SourceFactors(5) = curSourceFactor; if (fFScheduleUsed) { ort->ffSchedUsed(5) = true; - ort->ffSchedIndex(5) = ffScheduleIndex; + ort->ffScheds(5) = ffSched; } - GetFuelFactorInfo(state, Constant::eFuel::OtherFuel1, fuelFactorUsed, curSourceFactor, fFScheduleUsed, ffScheduleIndex); + GetFuelFactorInfo(state, Constant::eFuel::OtherFuel1, fuelFactorUsed, curSourceFactor, fFScheduleUsed, &ffSched); if (fuelFactorUsed) { ort->sourceFactorOtherFuel1 = curSourceFactor; ort->fuelfactorsused(11) = true; // should be source number @@ -3007,10 +3004,10 @@ void GetInputFuelAndPollutionFactors(EnergyPlusData &state) if (fFScheduleUsed) { ort->fuelFactorSchedulesUsed = true; ort->ffSchedUsed(13) = true; - ort->ffSchedIndex(13) = ffScheduleIndex; + ort->ffScheds(13) = ffSched; } - GetFuelFactorInfo(state, Constant::eFuel::OtherFuel2, fuelFactorUsed, curSourceFactor, fFScheduleUsed, ffScheduleIndex); + GetFuelFactorInfo(state, Constant::eFuel::OtherFuel2, fuelFactorUsed, curSourceFactor, fFScheduleUsed, &ffSched); if (fuelFactorUsed) { ort->sourceFactorOtherFuel2 = curSourceFactor; ort->fuelfactorsused(12) = true; // should be source number @@ -3020,7 +3017,7 @@ void GetInputFuelAndPollutionFactors(EnergyPlusData &state) if (fFScheduleUsed) { ort->fuelFactorSchedulesUsed = true; ort->ffSchedUsed(14) = true; - ort->ffSchedIndex(14) = ffScheduleIndex; + ort->ffScheds(14) = ffSched; } GetEnvironmentalImpactFactorInfo( @@ -3338,10 +3335,10 @@ void WriteTableOfContents(EnergyPlusData &state) } for (int iInput = 1; iInput <= ort->OutputTableBinnedCount; ++iInput) { if (ort->OutputTableBinned(iInput).numTables > 0) { - if (ort->OutputTableBinned(iInput).scheduleIndex == 0) { + if (ort->OutputTableBinned(iInput).sched == nullptr) { tbl_stream << "

" << ort->OutputTableBinned(iInput).varOrMeter << "

|\n"; } else { - tbl_stream << "

" << ort->OutputTableBinned(iInput).varOrMeter << " [" << ort->OutputTableBinned(iInput).ScheduleName + tbl_stream << "

" << ort->OutputTableBinned(iInput).varOrMeter << " [" << ort->OutputTableBinned(iInput).sched->Name << "]

|\n"; } for (int jTable = 1; jTable <= ort->OutputTableBinned(iInput).numTables; ++jTable) { @@ -3358,12 +3355,12 @@ void WriteTableOfContents(EnergyPlusData &state) ort->OutputTableBinned(iInput).varOrMeter, Constant::unitNames[(int)ort->OutputTableBinned(iInput).units]); } - if (ort->OutputTableBinned(iInput).scheduleIndex == 0) { + if (ort->OutputTableBinned(iInput).sched == nullptr) { tbl_stream << "BinObjVarID(curTable).namesOfObj) << "\">" << ort->BinObjVarID(curTable).namesOfObj << " | \n"; } else { tbl_stream << "OutputTableBinned(iInput).ScheduleName, + << MakeAnchorName(curName + ort->OutputTableBinned(iInput).sched->Name, ort->BinObjVarID(curTable).namesOfObj) << "\">" << ort->BinObjVarID(curTable).namesOfObj << " | \n"; } @@ -3436,9 +3433,6 @@ void GatherBinResultsForTimestep(EnergyPlusData &state, OutputProcessor::TimeSte // Gathers the data each timesetp and adds the length of the // timestep to the appropriate bin. - // Using/Aliasing - using ScheduleManager::GetCurrentScheduleValue; - // Locals // SUBROUTINE ARGUMENT DEFINITIONS: @@ -3467,18 +3461,10 @@ void GatherBinResultsForTimestep(EnergyPlusData &state, OutputProcessor::TimeSte for (int iInObj = 1; iInObj <= ort->OutputTableBinnedCount; ++iInObj) { // get values of array for current object being referenced - int const curScheduleIndex = ort->OutputTableBinned(iInObj).scheduleIndex; + auto *sched = ort->OutputTableBinned(iInObj).sched; // if a schedule was used, check if it was non-zero value - bool gatherThisTime = false; - if (curScheduleIndex != 0) { - if (GetCurrentScheduleValue(state, curScheduleIndex) != 0.0) { - gatherThisTime = true; - } else { - gatherThisTime = false; - } - } else { - gatherThisTime = true; - } + bool gatherThisTime = (sched == nullptr) || (sched->getCurrentVal() != 0.0); + if (gatherThisTime) { Real64 const &curIntervalStart = ort->OutputTableBinned(iInObj).intervalStart; Real64 const &curIntervalSize = ort->OutputTableBinned(iInObj).intervalSize; @@ -3496,7 +3482,7 @@ void GatherBinResultsForTimestep(EnergyPlusData &state, OutputProcessor::TimeSte Real64 curValue = GetInternalVariableValue(state, curTypeOfVar, ort->BinObjVarID(repIndex).varMeterNum); // per MJW when a summed variable is used divide it by the length of the time step if (ort->OutputTableBinned(iInObj).avgSum == OutputProcessor::StoreType::Sum) { // if it is a summed variable - curValue /= (elapsedTime * Constant::SecInHour); + curValue /= (elapsedTime * Constant::rSecsInHour); } // round the value to the number of signficant digits used in the final output report if (curIntervalSize < 1) { @@ -4041,7 +4027,6 @@ void GatherSourceEnergyEndUseResultsForTimestep(EnergyPlusData &state, using DataStringGlobals::CharComma; using DataStringGlobals::CharSpace; using DataStringGlobals::CharTab; - using ScheduleManager::GetCurrentScheduleValue; // Locals // SUBROUTINE ARGUMENT DEFINITIONS: @@ -4068,7 +4053,7 @@ void GatherSourceEnergyEndUseResultsForTimestep(EnergyPlusData &state, int const curMeterNumber = ort->meterNumTotalsBEPS(iResource); if (curMeterNumber > -1) { Real64 const curMeterValue = GetCurrentMeterValue(state, curMeterNumber) * - GetCurrentScheduleValue(state, ort->ffSchedIndex(iResource)) * ort->SourceFactors(iResource); + ort->ffScheds(iResource)->getCurrentVal() * ort->SourceFactors(iResource); ort->gatherTotalsBySourceBEPS(iResource) += curMeterValue; } } else { @@ -4084,7 +4069,7 @@ void GatherSourceEnergyEndUseResultsForTimestep(EnergyPlusData &state, int const curMeterNumber = ort->meterNumEndUseBEPS(iResource, jEndUse); if (curMeterNumber > -1) { Real64 const curMeterValue = GetCurrentMeterValue(state, curMeterNumber) * - GetCurrentScheduleValue(state, ort->ffSchedIndex(iResource)) * ort->SourceFactors(iResource); + ort->ffScheds(iResource)->getCurrentVal() * ort->SourceFactors(iResource); ort->gatherEndUseBySourceBEPS(iResource, jEndUse) += curMeterValue; } } else { @@ -6179,9 +6164,6 @@ void FillRemainingPredefinedEntries(EnergyPlusData &state) int iTotalAutoSizableFields = state.dataOutput->iTotalAutoSizableFields; int iTotalFieldsWithDefaults = state.dataOutput->iTotalFieldsWithDefaults; - using ScheduleManager::GetScheduleName; - using ScheduleManager::ScheduleAverageHoursPerWeek; - Real64 consumptionTotal; auto const &ort = state.dataOutRptTab; @@ -6207,7 +6189,7 @@ void FillRemainingPredefinedEntries(EnergyPlusData &state) PreDefTableEntry(state, state.dataOutRptPredefined->pdchInLtAvgHrSchd, thisLight.Name, - ScheduleAverageHoursPerWeek(state, thisLight.SchedPtr, StartOfWeek, state.dataEnvrn->CurrentYearIsLeapYear)); + thisLight.sched->getAverageWeeklyHoursFullLoad(state, StartOfWeek, state.dataEnvrn->CurrentYearIsLeapYear)); // average operating hours per week if (ort->gatherElapsedTimeBEPS > 0) { state.dataOutRptTab->HrsPerWeek = 24 * 7 * thisLight.SumTimeNotZeroCons / ort->gatherElapsedTimeBEPS; @@ -6216,7 +6198,7 @@ void FillRemainingPredefinedEntries(EnergyPlusData &state) // full load hours per week if ((thisLight.DesignLevel * ort->gatherElapsedTimeBEPS) > 0) { state.dataOutRptTab->HrsPerWeek = - 24 * 7 * thisLight.SumConsumption / (thisLight.DesignLevel * ort->gatherElapsedTimeBEPS * Constant::SecInHour); + 24 * 7 * thisLight.SumConsumption / (thisLight.DesignLevel * ort->gatherElapsedTimeBEPS * Constant::rSecsInHour); PreDefTableEntry(state, state.dataOutRptPredefined->pdchInLtFullLoadHrs, thisLight.Name, state.dataOutRptTab->HrsPerWeek); } PreDefTableEntry(state, state.dataOutRptPredefined->pdchInLtConsump, thisLight.Name, thisLight.SumConsumption * mult / 1000000000.0); @@ -6233,7 +6215,7 @@ void FillRemainingPredefinedEntries(EnergyPlusData &state) PreDefTableEntry(state, state.dataOutRptPredefined->pdchExLtAvgHrSchd, thisLight.Name, - ScheduleAverageHoursPerWeek(state, thisLight.SchedPtr, StartOfWeek, state.dataEnvrn->CurrentYearIsLeapYear)); + thisLight.sched->getAverageWeeklyHoursFullLoad(state, StartOfWeek, state.dataEnvrn->CurrentYearIsLeapYear)); } // average operating hours per week if (ort->gatherElapsedTimeBEPS > 0) { @@ -6243,7 +6225,7 @@ void FillRemainingPredefinedEntries(EnergyPlusData &state) // full load hours per week if ((thisLight.DesignLevel * ort->gatherElapsedTimeBEPS) > 0) { state.dataOutRptTab->HrsPerWeek = - 24 * 7 * thisLight.SumConsumption / (thisLight.DesignLevel * ort->gatherElapsedTimeBEPS * Constant::SecInHour); + 24 * 7 * thisLight.SumConsumption / (thisLight.DesignLevel * ort->gatherElapsedTimeBEPS * Constant::rSecsInHour); PreDefTableEntry(state, state.dataOutRptPredefined->pdchExLtFullLoadHrs, thisLight.Name, state.dataOutRptTab->HrsPerWeek); } PreDefTableEntry(state, state.dataOutRptPredefined->pdchExLtConsump, thisLight.Name, thisLight.SumConsumption / 1000000000.0); @@ -6416,7 +6398,7 @@ void FillRemainingPredefinedEntries(EnergyPlusData &state) PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaBzTmAboveUnocc, thisZone.Name, thisZonePreDefRep.TotVentTimeNonZeroUnocc); if (thisZone.isNominalOccupied && (thisZonePreDefRep.TotTimeOcc > 0.0)) { - Real64 totTimeOccSec = thisZonePreDefRep.TotTimeOcc * Constant::SecInHour; + Real64 totTimeOccSec = thisZonePreDefRep.TotTimeOcc * Constant::rSecsInHour; // Mechanical ventilation Real64 mechVent = thisZonePreDefRep.MechVentVolTotalOccStdDen / totTimeOccSec; PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzMechVent, thisZone.Name, mechVent, 4); @@ -6511,7 +6493,7 @@ void FillRemainingPredefinedEntries(EnergyPlusData &state) if (thisSysPreDefRep.TimeOccupiedTotal > 0.0) { // Average Outdoor Air During Occupancy by Airloop - Real64 totTimeOccSec = thisSysPreDefRep.TimeOccupiedTotal * Constant::SecInHour; + Real64 totTimeOccSec = thisSysPreDefRep.TimeOccupiedTotal * Constant::rSecsInHour; PreDefTableEntry( state, state.dataOutRptPredefined->pdchOaOccAlMechVent, thisPrimaryAirSys.Name, thisSysPreDefRep.MechVentTotalOcc / totTimeOccSec, 4); PreDefTableEntry( @@ -6536,7 +6518,7 @@ void FillRemainingPredefinedEntries(EnergyPlusData &state) int time = state.dataSysRpts->SysPreDefRep(sysNum).TimeAtOALimitOcc[static_cast(limitingFactorType)]; if (time > 0) { return state.dataSysRpts->SysPreDefRep(sysNum).MechVentTotAtLimitOcc[static_cast(limitingFactorType)] / - (time * Constant::SecInHour); + (time * Constant::rSecsInHour); } else { return 0.0; } @@ -6879,22 +6861,22 @@ void FillRemainingPredefinedEntries(EnergyPlusData &state) PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedGenData, "Total gross floor area [m2]", "-"); } // LEED schedule sub table - for (long iSch = 1; iSch <= state.dataScheduleMgr->NumSchedules; ++iSch) { - std::string curSchName = state.dataScheduleMgr->Schedule(iSch).Name; - std::string curSchType = ScheduleManager::GetScheduleType(state, iSch); - if (Util::SameString(curSchType, "FRACTION")) { - PreDefTableEntry(state, - state.dataOutRptPredefined->pdchLeedEflhEflh, - curSchName, - ScheduleManager::ScheduleAnnualFullLoadHours(state, iSch, StartOfWeek, state.dataEnvrn->CurrentYearIsLeapYear), - 0); - PreDefTableEntry(state, - state.dataOutRptPredefined->pdchLeedEflhNonZerHrs, - curSchName, - ScheduleManager::ScheduleHoursGT1perc(state, iSch, StartOfWeek, state.dataEnvrn->CurrentYearIsLeapYear), - 0); - } + for (auto *sched : state.dataSched->schedules) { + if (sched->schedTypeNum == -1) continue; + if (!Util::SameString(state.dataSched->scheduleTypes[sched->schedTypeNum]->Name, "FRACTION")) continue; + + PreDefTableEntry(state, + state.dataOutRptPredefined->pdchLeedEflhEflh, + sched->Name, + sched->getAnnualHoursFullLoad(state, StartOfWeek, state.dataEnvrn->CurrentYearIsLeapYear), + 0); + PreDefTableEntry(state, + state.dataOutRptPredefined->pdchLeedEflhNonZerHrs, + sched->Name, + sched->getAnnualHoursGreaterThan1Percent(state, StartOfWeek, state.dataEnvrn->CurrentYearIsLeapYear), + 0); } + // fill the LEED setpoint table ZoneTempPredictorCorrector::FillPredefinedTableOnThermostatSetpoints(state); ZoneTempPredictorCorrector::FillPredefinedTableOnThermostatSchedules(state); @@ -6968,6 +6950,7 @@ void WriteMonthlyTables(EnergyPlusData &state) rowHead(15) = "Minimum of Months"; rowHead(16) = "Maximum of Months"; + // Why is this a map? If the enum/integer is the independent variable/index, it should be a std::array. std::unordered_map aggString = { {AggType::SumOrAvg, ""}, {AggType::Maximum, " Maximum "}, @@ -7460,10 +7443,10 @@ void WriteTimeBinTables(EnergyPlusData &state) tableBody(numCols, 2) = "Total"; for (int iTable = 1; iTable <= curNumTables; ++iTable) { int const repIndex = firstReport + (iTable - 1); - if (ort->OutputTableBinned(iInObj).scheduleIndex == 0) { + if (ort->OutputTableBinned(iInObj).sched == nullptr) { repNameWithUnitsandscheduleName = curNameAndUnits; } else { - repNameWithUnitsandscheduleName = curNameAndUnits + " [" + ort->OutputTableBinned(iInObj).ScheduleName + ']'; + repNameWithUnitsandscheduleName = curNameAndUnits + " [" + ort->OutputTableBinned(iInObj).sched->Name + ']'; } if (produceTabular) { WriteReportHeaders( @@ -8193,7 +8176,7 @@ void WriteBEPSTable(EnergyPlusData &state) tableBody(1, 1) = RealToStr(ort->sourceFactorElectric, 3); } else if (ort->gatherTotalsBEPS(1) > SmallValue) { tableBody(1, 1) = "Effective Factor = " + RealToStr(ort->gatherTotalsBySourceBEPS(1) / ort->gatherTotalsBEPS(1), 3) + - " (calculated using schedule \"" + ScheduleManager::GetScheduleName(state, ort->ffSchedIndex(1)) + "\")"; + " (calculated using schedule \"" + ort->ffScheds(1)->Name + "\")"; } else { tableBody(1, 1) = "N/A"; } @@ -8202,7 +8185,7 @@ void WriteBEPSTable(EnergyPlusData &state) tableBody(1, 2) = RealToStr(ort->sourceFactorNaturalGas, 3); } else if (ort->gatherTotalsBEPS(2) > SmallValue) { tableBody(1, 2) = "Effective Factor = " + RealToStr(ort->gatherTotalsBySourceBEPS(2) / ort->gatherTotalsBEPS(2), 3) + - " (calculated using schedule \"" + ScheduleManager::GetScheduleName(state, ort->ffSchedIndex(2)) + "\")"; + " (calculated using schedule \"" + ort->ffScheds(2)->Name + "\")"; } else { tableBody(1, 2) = "N/A"; } @@ -8217,7 +8200,7 @@ void WriteBEPSTable(EnergyPlusData &state) tableBody(1, 6) = RealToStr(ort->sourceFactorGasoline, 3); } else if (ort->gatherTotalsBEPS(6) > SmallValue) { tableBody(1, 6) = "Effective Factor = " + RealToStr(ort->gatherTotalsBySourceBEPS(6) / ort->gatherTotalsBEPS(6), 3) + - " (calculated using schedule \"" + ScheduleManager::GetScheduleName(state, ort->ffSchedIndex(6)) + "\")"; + " (calculated using schedule \"" + ort->ffScheds(6)->Name + "\")"; } else { tableBody(1, 6) = "N/A"; } @@ -8226,7 +8209,7 @@ void WriteBEPSTable(EnergyPlusData &state) tableBody(1, 7) = RealToStr(ort->sourceFactorDiesel, 3); } else if (ort->gatherTotalsBEPS(8) > SmallValue) { tableBody(1, 7) = "Effective Factor = " + RealToStr(ort->gatherTotalsBySourceBEPS(8) / ort->gatherTotalsBEPS(8), 3) + - " (calculated using schedule \"" + ScheduleManager::GetScheduleName(state, ort->ffSchedIndex(8)) + "\")"; + " (calculated using schedule \"" + ort->ffScheds(8)->Name + "\")"; } else { tableBody(1, 7) = "N/A"; } @@ -8235,7 +8218,7 @@ void WriteBEPSTable(EnergyPlusData &state) tableBody(1, 8) = RealToStr(ort->sourceFactorCoal, 3); } else if (ort->gatherTotalsBEPS(9) > SmallValue) { tableBody(1, 8) = "Effective Factor = " + RealToStr(ort->gatherTotalsBySourceBEPS(9) / ort->gatherTotalsBEPS(9), 3) + - " (calculated using schedule \"" + ScheduleManager::GetScheduleName(state, ort->ffSchedIndex(9)) + "\")"; + " (calculated using schedule \"" + ort->ffScheds(9)->Name + "\")"; } else { tableBody(1, 8) = "N/A"; } @@ -8244,7 +8227,7 @@ void WriteBEPSTable(EnergyPlusData &state) tableBody(1, 9) = RealToStr(ort->sourceFactorFuelOil1, 3); } else if (ort->gatherTotalsBEPS(10) > SmallValue) { tableBody(1, 9) = "Effective Factor = " + RealToStr(ort->gatherTotalsBySourceBEPS(10) / ort->gatherTotalsBEPS(10), 3) + - " (calculated using schedule \"" + ScheduleManager::GetScheduleName(state, ort->ffSchedIndex(10)) + "\")"; + " (calculated using schedule \"" + ort->ffScheds(10)->Name + "\")"; } else { tableBody(1, 9) = "N/A"; } @@ -8253,7 +8236,7 @@ void WriteBEPSTable(EnergyPlusData &state) tableBody(1, 10) = RealToStr(ort->sourceFactorFuelOil2, 3); } else if (ort->gatherTotalsBEPS(11) > SmallValue) { tableBody(1, 10) = "Effective Factor = " + RealToStr(ort->gatherTotalsBySourceBEPS(11) / ort->gatherTotalsBEPS(11), 3) + - " (calculated using schedule \"" + ScheduleManager::GetScheduleName(state, ort->ffSchedIndex(11)) + "\")"; + " (calculated using schedule \"" + ort->ffScheds(11)->Name + "\")"; } else { tableBody(1, 10) = "N/A"; } @@ -8262,7 +8245,7 @@ void WriteBEPSTable(EnergyPlusData &state) tableBody(1, 11) = RealToStr(ort->sourceFactorPropane, 3); } else if (ort->gatherTotalsBEPS(12) > SmallValue) { tableBody(1, 11) = "Effective Factor = " + RealToStr(ort->gatherTotalsBySourceBEPS(12) / ort->gatherTotalsBEPS(12), 3) + - " (calculated using schedule \"" + ScheduleManager::GetScheduleName(state, ort->ffSchedIndex(12)) + "\")"; + " (calculated using schedule \"" + ort->ffScheds(12)->Name + "\")"; } else { tableBody(1, 11) = "N/A"; } @@ -8271,7 +8254,7 @@ void WriteBEPSTable(EnergyPlusData &state) tableBody(1, 12) = RealToStr(ort->sourceFactorOtherFuel1, 3); } else if (ort->gatherTotalsBEPS(13) > SmallValue) { tableBody(1, 12) = "Effective Factor = " + RealToStr(ort->gatherTotalsBySourceBEPS(13) / ort->gatherTotalsBEPS(13), 3) + - " (calculated using schedule \"" + ScheduleManager::GetScheduleName(state, ort->ffSchedIndex(13)) + "\")"; + " (calculated using schedule \"" + ort->ffScheds(13)->Name + "\")"; } else { tableBody(1, 12) = "N/A"; } @@ -8280,7 +8263,7 @@ void WriteBEPSTable(EnergyPlusData &state) tableBody(1, 13) = RealToStr(ort->sourceFactorOtherFuel2, 3); } else if (ort->gatherTotalsBEPS(14) > SmallValue) { tableBody(1, 13) = "Effective Factor = " + RealToStr(ort->gatherTotalsBySourceBEPS(14) / ort->gatherTotalsBEPS(14), 3) + - " (calculated using schedule \"" + ScheduleManager::GetScheduleName(state, ort->ffSchedIndex(14)) + "\")"; + " (calculated using schedule \"" + ort->ffScheds(14)->Name + "\")"; } else { tableBody(1, 13) = "N/A"; } @@ -10961,8 +10944,6 @@ void WriteVeriSumTable(EnergyPlusData &state) using DataSurfaces::OtherSideCondModeledExt; using DataSurfaces::SurfaceClass; using General::SafeDivide; - using ScheduleManager::GetScheduleName; - using ScheduleManager::ScheduleAverageHoursPerWeek; auto const &ort = state.dataOutRptTab; @@ -11496,7 +11477,7 @@ void WriteVeriSumTable(EnergyPlusData &state) auto const &thisZone = state.dataHeatBal->Zone(iZone); rowHead(iZone) = thisZone.Name; - if (state.dataHybridModel->HybridModelZone(iZone).InternalThermalMassCalc_T) { + if (state.dataHybridModel->hybridModelZones(iZone).InternalThermalMassCalc_T) { tableBody(1, iZone) = "Yes"; } else { tableBody(1, iZone) = "No"; @@ -14479,113 +14460,81 @@ void AllocateLoadComponentArrays(EnergyPlusData &state) if (!ort->AllocateLoadComponentArraysDoAllocate) { return; } + + Real64 timeStepsInDay = state.dataGlobal->TimeStepsInHour * Constant::rHoursInDay; + // For many of the following arrays the last dimension is the number of environments and is same as sizing arrays ort->radiantPulseTimestep.allocate({0, state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays}, state.dataGlobal->NumOfZones); ort->radiantPulseTimestep = 0; ort->radiantPulseReceived.allocate({0, state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays}, state.dataSurface->TotSurfaces); ort->radiantPulseReceived = 0.0; - ort->loadConvectedNormal.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, - {0, state.dataGlobal->NumOfTimeStepInHour * 24}, - state.dataSurface->TotSurfaces); + ort->loadConvectedNormal.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, {0, timeStepsInDay}, state.dataSurface->TotSurfaces); ort->loadConvectedNormal = 0.0; - ort->loadConvectedWithPulse.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, - {0, state.dataGlobal->NumOfTimeStepInHour * 24}, - state.dataSurface->TotSurfaces); + ort->loadConvectedWithPulse.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, {0, timeStepsInDay}, state.dataSurface->TotSurfaces); ort->loadConvectedWithPulse = 0.0; - ort->netSurfRadSeq.allocate( - state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, state.dataGlobal->NumOfTimeStepInHour * 24, state.dataSurface->TotSurfaces); + ort->netSurfRadSeq.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, timeStepsInDay, state.dataSurface->TotSurfaces); ort->netSurfRadSeq = 0.0; - ort->decayCurveCool.allocate(state.dataGlobal->NumOfTimeStepInHour * 24, state.dataSurface->TotSurfaces); + ort->decayCurveCool.allocate(timeStepsInDay, state.dataSurface->TotSurfaces); ort->decayCurveCool = 0.0; - ort->decayCurveHeat.allocate(state.dataGlobal->NumOfTimeStepInHour * 24, state.dataSurface->TotSurfaces); + ort->decayCurveHeat.allocate(timeStepsInDay, state.dataSurface->TotSurfaces); ort->decayCurveHeat = 0.0; - ort->ITABSFseq.allocate( - state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, state.dataGlobal->NumOfTimeStepInHour * 24, state.dataSurface->TotSurfaces); + ort->ITABSFseq.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, timeStepsInDay, state.dataSurface->TotSurfaces); ort->ITABSFseq = 0.0; - ort->TMULTseq.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, - state.dataGlobal->NumOfTimeStepInHour * 24, - state.dataViewFactor->NumOfRadiantEnclosures); + ort->TMULTseq.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, timeStepsInDay, state.dataViewFactor->NumOfRadiantEnclosures); ort->TMULTseq = 0.0; - ort->peopleInstantSeq.allocate( - state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, state.dataGlobal->NumOfTimeStepInHour * 24, state.dataGlobal->NumOfZones); + ort->peopleInstantSeq.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, timeStepsInDay, state.dataGlobal->NumOfZones); ort->peopleInstantSeq = 0.0; - ort->peopleLatentSeq.allocate( - state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, state.dataGlobal->NumOfTimeStepInHour * 24, state.dataGlobal->NumOfZones); + ort->peopleLatentSeq.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, timeStepsInDay, state.dataGlobal->NumOfZones); ort->peopleLatentSeq = 0.0; - ort->peopleRadSeq.allocate( - state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, state.dataGlobal->NumOfTimeStepInHour * 24, state.dataGlobal->NumOfZones); + ort->peopleRadSeq.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, timeStepsInDay, state.dataGlobal->NumOfZones); ort->peopleRadSeq = 0.0; - ort->lightInstantSeq.allocate( - state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, state.dataGlobal->NumOfTimeStepInHour * 24, state.dataGlobal->NumOfZones); + ort->lightInstantSeq.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, timeStepsInDay, state.dataGlobal->NumOfZones); ort->lightInstantSeq = 0.0; - ort->lightRetAirSeq.allocate( - state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, state.dataGlobal->NumOfTimeStepInHour * 24, state.dataGlobal->NumOfZones); + ort->lightRetAirSeq.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, timeStepsInDay, state.dataGlobal->NumOfZones); ort->lightRetAirSeq = 0.0; - ort->lightLWRadSeq.allocate( - state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, state.dataGlobal->NumOfTimeStepInHour * 24, state.dataGlobal->NumOfZones); + ort->lightLWRadSeq.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, timeStepsInDay, state.dataGlobal->NumOfZones); ort->lightLWRadSeq = 0.0; - ort->lightSWRadSeq.allocate( - state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, state.dataGlobal->NumOfTimeStepInHour * 24, state.dataSurface->TotSurfaces); + ort->lightSWRadSeq.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, timeStepsInDay, state.dataSurface->TotSurfaces); ort->lightSWRadSeq = 0.0; - ort->equipInstantSeq.allocate( - state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, state.dataGlobal->NumOfTimeStepInHour * 24, state.dataGlobal->NumOfZones); + ort->equipInstantSeq.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, timeStepsInDay, state.dataGlobal->NumOfZones); ort->equipInstantSeq = 0.0; - ort->equipLatentSeq.allocate( - state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, state.dataGlobal->NumOfTimeStepInHour * 24, state.dataGlobal->NumOfZones); + ort->equipLatentSeq.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, timeStepsInDay, state.dataGlobal->NumOfZones); ort->equipLatentSeq = 0.0; - ort->equipRadSeq.allocate( - state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, state.dataGlobal->NumOfTimeStepInHour * 24, state.dataGlobal->NumOfZones); + ort->equipRadSeq.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, timeStepsInDay, state.dataGlobal->NumOfZones); ort->equipRadSeq = 0.0; - ort->refrigInstantSeq.allocate( - state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, state.dataGlobal->NumOfTimeStepInHour * 24, state.dataGlobal->NumOfZones); + ort->refrigInstantSeq.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, timeStepsInDay, state.dataGlobal->NumOfZones); ort->refrigInstantSeq = 0.0; - ort->refrigRetAirSeq.allocate( - state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, state.dataGlobal->NumOfTimeStepInHour * 24, state.dataGlobal->NumOfZones); + ort->refrigRetAirSeq.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, timeStepsInDay, state.dataGlobal->NumOfZones); ort->refrigRetAirSeq = 0.0; - ort->refrigLatentSeq.allocate( - state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, state.dataGlobal->NumOfTimeStepInHour * 24, state.dataGlobal->NumOfZones); + ort->refrigLatentSeq.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, timeStepsInDay, state.dataGlobal->NumOfZones); ort->refrigLatentSeq = 0.0; - ort->waterUseInstantSeq.allocate( - state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, state.dataGlobal->NumOfTimeStepInHour * 24, state.dataGlobal->NumOfZones); + ort->waterUseInstantSeq.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, timeStepsInDay, state.dataGlobal->NumOfZones); ort->waterUseInstantSeq = 0.0; - ort->waterUseLatentSeq.allocate( - state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, state.dataGlobal->NumOfTimeStepInHour * 24, state.dataGlobal->NumOfZones); + ort->waterUseLatentSeq.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, timeStepsInDay, state.dataGlobal->NumOfZones); ort->waterUseLatentSeq = 0.0; - ort->hvacLossInstantSeq.allocate( - state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, state.dataGlobal->NumOfTimeStepInHour * 24, state.dataGlobal->NumOfZones); + ort->hvacLossInstantSeq.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, timeStepsInDay, state.dataGlobal->NumOfZones); ort->hvacLossInstantSeq = 0.0; - ort->hvacLossRadSeq.allocate( - state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, state.dataGlobal->NumOfTimeStepInHour * 24, state.dataGlobal->NumOfZones); + ort->hvacLossRadSeq.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, timeStepsInDay, state.dataGlobal->NumOfZones); ort->hvacLossRadSeq = 0.0; - ort->powerGenInstantSeq.allocate( - state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, state.dataGlobal->NumOfTimeStepInHour * 24, state.dataGlobal->NumOfZones); + ort->powerGenInstantSeq.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, timeStepsInDay, state.dataGlobal->NumOfZones); ort->powerGenInstantSeq = 0.0; - ort->powerGenRadSeq.allocate( - state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, state.dataGlobal->NumOfTimeStepInHour * 24, state.dataGlobal->NumOfZones); + ort->powerGenRadSeq.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, timeStepsInDay, state.dataGlobal->NumOfZones); ort->powerGenRadSeq = 0.0; - ort->infilInstantSeq.allocate( - state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, state.dataGlobal->NumOfTimeStepInHour * 24, state.dataGlobal->NumOfZones); + ort->infilInstantSeq.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, timeStepsInDay, state.dataGlobal->NumOfZones); ort->infilInstantSeq = 0.0; - ort->infilLatentSeq.allocate( - state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, state.dataGlobal->NumOfTimeStepInHour * 24, state.dataGlobal->NumOfZones); + ort->infilLatentSeq.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, timeStepsInDay, state.dataGlobal->NumOfZones); ort->infilLatentSeq = 0.0; - ort->zoneVentInstantSeq.allocate( - state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, state.dataGlobal->NumOfTimeStepInHour * 24, state.dataGlobal->NumOfZones); + ort->zoneVentInstantSeq.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, timeStepsInDay, state.dataGlobal->NumOfZones); ort->zoneVentInstantSeq = 0.0; - ort->zoneVentLatentSeq.allocate( - state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, state.dataGlobal->NumOfTimeStepInHour * 24, state.dataGlobal->NumOfZones); + ort->zoneVentLatentSeq.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, timeStepsInDay, state.dataGlobal->NumOfZones); ort->zoneVentLatentSeq = 0.0; - ort->interZoneMixInstantSeq.allocate( - state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, state.dataGlobal->NumOfTimeStepInHour * 24, state.dataGlobal->NumOfZones); + ort->interZoneMixInstantSeq.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, timeStepsInDay, state.dataGlobal->NumOfZones); ort->interZoneMixInstantSeq = 0.0; - ort->interZoneMixLatentSeq.allocate( - state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, state.dataGlobal->NumOfTimeStepInHour * 24, state.dataGlobal->NumOfZones); + ort->interZoneMixLatentSeq.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, timeStepsInDay, state.dataGlobal->NumOfZones); ort->interZoneMixLatentSeq = 0.0; - ort->feneCondInstantSeq.allocate( - state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, state.dataGlobal->NumOfTimeStepInHour * 24, state.dataGlobal->NumOfZones); + ort->feneCondInstantSeq.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, timeStepsInDay, state.dataGlobal->NumOfZones); ort->feneCondInstantSeq = 0.0; - ort->feneSolarRadSeq.allocate( - state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, state.dataGlobal->NumOfTimeStepInHour * 24, state.dataSurface->TotSurfaces); + ort->feneSolarRadSeq.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, timeStepsInDay, state.dataSurface->TotSurfaces); ort->feneSolarRadSeq = 0.0; ort->AllocateLoadComponentArraysDoAllocate = false; } @@ -14650,7 +14599,7 @@ void ComputeLoadComponentDecayCurve(EnergyPlusData &state) } if (state.dataOutRptTab->TimeOfPulseCLCDC == 0) state.dataOutRptTab->TimeOfPulseCLCDC = 1; for (state.dataOutRptTab->TimeStepCLCDC = state.dataOutRptTab->TimeOfPulseCLCDC; - state.dataOutRptTab->TimeStepCLCDC <= state.dataGlobal->NumOfTimeStepInHour * 24; + state.dataOutRptTab->TimeStepCLCDC <= state.dataGlobal->TimeStepsInHour * Constant::rHoursInDay; ++state.dataOutRptTab->TimeStepCLCDC) { if (ort->radiantPulseReceived(state.dataOutRptTab->CoolDesSelectedCLCDC, state.dataOutRptTab->SurfNumCLCDC) != 0.0) { diff = ort->loadConvectedWithPulse( @@ -14679,7 +14628,7 @@ void ComputeLoadComponentDecayCurve(EnergyPlusData &state) } if (state.dataOutRptTab->TimeOfPulseCLCDC == 0) state.dataOutRptTab->TimeOfPulseCLCDC = 1; for (state.dataOutRptTab->TimeStepCLCDC = state.dataOutRptTab->TimeOfPulseCLCDC; - state.dataOutRptTab->TimeStepCLCDC <= state.dataGlobal->NumOfTimeStepInHour * 24; + state.dataOutRptTab->TimeStepCLCDC <= state.dataGlobal->TimeStepsInHour * Constant::rHoursInDay; ++state.dataOutRptTab->TimeStepCLCDC) { if (ort->radiantPulseReceived(state.dataOutRptTab->HeatDesSelectedCLCDC, state.dataOutRptTab->SurfNumCLCDC) != 0.0) { diff = ort->loadConvectedWithPulse( @@ -14715,7 +14664,7 @@ void ComputeLoadComponentDecayCurve(EnergyPlusData &state) "Radiant to Convective Decay Curves for Cooling", thisZone.Name, state.dataSurface->Surface(kSurf).Name); - for (int jTime = 1; jTime <= min(state.dataGlobal->NumOfTimeStepInHour * 24, 36); ++jTime) { + for (int jTime = 1; jTime <= min(int(state.dataGlobal->TimeStepsInHour * Constant::iHoursInDay), 36); ++jTime) { print(state.files.eio, ",{:6.3F}", ort->decayCurveCool(jTime, kSurf)); } // put a line feed at the end of the line @@ -14729,7 +14678,7 @@ void ComputeLoadComponentDecayCurve(EnergyPlusData &state) "Radiant to Convective Decay Curves for Heating", thisZone.Name, state.dataSurface->Surface(kSurf).Name); - for (int jTime = 1; jTime <= min(state.dataGlobal->NumOfTimeStepInHour * 24, 36); ++jTime) { + for (int jTime = 1; jTime <= min(int(state.dataGlobal->TimeStepsInHour * Constant::iHoursInDay), 36); ++jTime) { print(state.files.eio, ",{:6.3F}", ort->decayCurveHeat(jTime, kSurf)); } // put a line feed at the end of the line @@ -14758,7 +14707,7 @@ void GatherComponentLoadsSurface(EnergyPlusData &state) if (state.dataGlobal->CompLoadReportIsReq && !state.dataGlobal->isPulseZoneSizing) { state.dataOutRptTab->TimeStepInDayGCLS = - (state.dataGlobal->HourOfDay - 1) * state.dataGlobal->NumOfTimeStepInHour + state.dataGlobal->TimeStep; + (state.dataGlobal->HourOfDay - 1) * state.dataGlobal->TimeStepsInHour + state.dataGlobal->TimeStep; ort->feneCondInstantSeq(state.dataSize->CurOverallSimDay, state.dataOutRptTab->TimeStepInDayGCLS, _) = 0.0; for (state.dataOutRptTab->iSurfGCLS = 1; state.dataOutRptTab->iSurfGCLS <= state.dataSurface->TotSurfaces; ++state.dataOutRptTab->iSurfGCLS) { state.dataOutRptTab->ZoneNumGCLS = state.dataSurface->Surface(state.dataOutRptTab->iSurfGCLS).Zone; @@ -14806,7 +14755,7 @@ void GatherComponentLoadsHVAC(EnergyPlusData &state) } auto &ort = state.dataOutRptTab; Real64 const TimeStepSysSec = state.dataHVACGlobal->TimeStepSysSec; - state.dataOutRptTab->TimeStepInDayGCLH = (state.dataGlobal->HourOfDay - 1) * state.dataGlobal->NumOfTimeStepInHour + state.dataGlobal->TimeStep; + state.dataOutRptTab->TimeStepInDayGCLH = (state.dataGlobal->HourOfDay - 1) * state.dataGlobal->TimeStepsInHour + state.dataGlobal->TimeStep; for (state.dataOutRptTab->iZoneGCLH = 1; state.dataOutRptTab->iZoneGCLH <= state.dataGlobal->NumOfZones; ++state.dataOutRptTab->iZoneGCLH) { ort->infilInstantSeq(state.dataSize->CurOverallSimDay, state.dataOutRptTab->TimeStepInDayGCLH, state.dataOutRptTab->iZoneGCLH) = ((state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGCLH).InfilHeatGain - @@ -14977,34 +14926,36 @@ void WriteLoadComponentSummaryTables(EnergyPlusData &state) bool produceSQLite = false; if (produceDualUnitsFlags(iUnitSystem, ort->unitsStyle, ort->unitsStyle_SQLite, unitsStyle_cur, produceTabular, produceSQLite)) break; + Real64 timeStepsInDay = state.dataGlobal->TimeStepsInHour * Constant::rHoursInDay; + // adjusted initilization location to after variable declaration for loops 2021-01-11 - peopleDelaySeqHeat.dimension(state.dataGlobal->NumOfTimeStepInHour * 24, 0.0); + peopleDelaySeqHeat.dimension(timeStepsInDay, 0.0); peopleDelaySeqHeat = 0.0; - peopleDelaySeqCool.allocate(state.dataGlobal->NumOfTimeStepInHour * 24); + peopleDelaySeqCool.allocate(timeStepsInDay); peopleDelaySeqCool = 0.0; - lightDelaySeqHeat.allocate(state.dataGlobal->NumOfTimeStepInHour * 24); + lightDelaySeqHeat.allocate(timeStepsInDay); lightDelaySeqHeat = 0.0; - lightDelaySeqCool.allocate(state.dataGlobal->NumOfTimeStepInHour * 24); + lightDelaySeqCool.allocate(timeStepsInDay); lightDelaySeqCool = 0.0; - equipDelaySeqHeat.allocate(state.dataGlobal->NumOfTimeStepInHour * 24); + equipDelaySeqHeat.allocate(timeStepsInDay); equipDelaySeqHeat = 0.0; - equipDelaySeqCool.allocate(state.dataGlobal->NumOfTimeStepInHour * 24); + equipDelaySeqCool.allocate(timeStepsInDay); equipDelaySeqCool = 0.0; - hvacLossDelaySeqHeat.allocate(state.dataGlobal->NumOfTimeStepInHour * 24); + hvacLossDelaySeqHeat.allocate(timeStepsInDay); hvacLossDelaySeqHeat = 0.0; - hvacLossDelaySeqCool.allocate(state.dataGlobal->NumOfTimeStepInHour * 24); + hvacLossDelaySeqCool.allocate(timeStepsInDay); hvacLossDelaySeqCool = 0.0; - powerGenDelaySeqHeat.allocate(state.dataGlobal->NumOfTimeStepInHour * 24); + powerGenDelaySeqHeat.allocate(timeStepsInDay); powerGenDelaySeqHeat = 0.0; - powerGenDelaySeqCool.allocate(state.dataGlobal->NumOfTimeStepInHour * 24); + powerGenDelaySeqCool.allocate(timeStepsInDay); powerGenDelaySeqCool = 0.0; - feneSolarDelaySeqHeat.allocate(state.dataGlobal->NumOfTimeStepInHour * 24); + feneSolarDelaySeqHeat.allocate(timeStepsInDay); feneSolarDelaySeqHeat = 0.0; - feneSolarDelaySeqCool.allocate(state.dataGlobal->NumOfTimeStepInHour * 24); + feneSolarDelaySeqCool.allocate(timeStepsInDay); feneSolarDelaySeqCool = 0.0; - surfDelaySeqHeat.allocate(state.dataGlobal->NumOfTimeStepInHour * 24, state.dataSurface->TotSurfaces); + surfDelaySeqHeat.allocate(timeStepsInDay, state.dataSurface->TotSurfaces); surfDelaySeqHeat = 0.0; - surfDelaySeqCool.allocate(state.dataGlobal->NumOfTimeStepInHour * 24, state.dataSurface->TotSurfaces); + surfDelaySeqCool.allocate(timeStepsInDay, state.dataSurface->TotSurfaces); surfDelaySeqCool = 0.0; // initialize arrays @@ -15603,7 +15554,7 @@ void GetDelaySequences(EnergyPlusData &state, if (!ort->initAdjFenDone) { state.dataOutRptTab->adjFenDone.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, - state.dataGlobal->NumOfTimeStepInHour * 24, + state.dataGlobal->TimeStepsInHour * Constant::iHoursInDay, state.dataGlobal->NumOfZones); state.dataOutRptTab->adjFenDone = false; ort->initAdjFenDone = true; @@ -15618,7 +15569,7 @@ void GetDelaySequences(EnergyPlusData &state, decayCurve = ort->decayCurveHeat; } - for (int kTimeStep = 1; kTimeStep <= state.dataGlobal->NumOfTimeStepInHour * 24; ++kTimeStep) { + for (int kTimeStep = 1; kTimeStep <= state.dataGlobal->TimeStepsInHour * Constant::iHoursInDay; ++kTimeStep) { Real64 peopleConvIntoZone = 0.0; Real64 equipConvIntoZone = 0.0; Real64 hvacLossConvIntoZone = 0.0; @@ -15721,7 +15672,7 @@ void ComputeTableBodyUsingMovingAvg(EnergyPlusData &state, resultCells = 0.; resCellsUsd = false; delayOpaque.allocate(LoadCompRow::GrdTot); - AvgData.allocate(state.dataGlobal->NumOfTimeStepInHour * 24); + AvgData.allocate(state.dataGlobal->TimeStepsInHour * Constant::iHoursInDay); if (desDaySelected != 0 && timeOfMax != 0) { // Don't update/average original array data diff --git a/src/EnergyPlus/OutputReportTabular.hh b/src/EnergyPlus/OutputReportTabular.hh index e0b30a2a535..d6973926fe9 100644 --- a/src/EnergyPlus/OutputReportTabular.hh +++ b/src/EnergyPlus/OutputReportTabular.hh @@ -269,8 +269,7 @@ namespace OutputReportTabular { OutputProcessor::StoreType avgSum = OutputProcessor::StoreType::Average; // Variable is Averaged=1 or Summed=2 OutputProcessor::TimeStepType stepType = OutputProcessor::TimeStepType::Zone; // Variable time step is Zone=1 or HVAC=2 Constant::Units units = Constant::Units::Invalid; // the units enumeration - std::string ScheduleName; // the name of the schedule - int scheduleIndex = 0; // index to the schedule specified - if no schedule use zero + Sched::Schedule *sched = nullptr; // index to the schedule specified - if no schedule use zero }; struct BinResultsType @@ -1044,7 +1043,7 @@ struct OutputReportTabularData : BaseGlobalStruct Array1D_bool ffUsed = Array1D_bool(OutputReportTabular::numResourceTypes, false); Array1D SourceFactors = Array1D(OutputReportTabular::numResourceTypes, 0.0); Array1D_bool ffSchedUsed = Array1D_bool(OutputReportTabular::numResourceTypes, false); - Array1D_int ffSchedIndex = Array1D_int(OutputReportTabular::numResourceTypes, 0); + Array1D ffScheds = Array1D(OutputReportTabular::numResourceTypes, nullptr); Array2D_int meterNumEndUseBEPS = Array2D_int(OutputReportTabular::numResourceTypes, static_cast(Constant::EndUse::Num), -1); Array3D_int meterNumEndUseSubBEPS; Array3D_int meterNumEndUseSpTypeBEPS; @@ -1331,6 +1330,10 @@ struct OutputReportTabularData : BaseGlobalStruct std::string curColHeadWithSI; std::string curColHead; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } @@ -1389,7 +1392,7 @@ struct OutputReportTabularData : BaseGlobalStruct this->ffUsed = Array1D_bool(OutputReportTabular::numResourceTypes, false); this->SourceFactors = Array1D(OutputReportTabular::numResourceTypes, 0.0); this->ffSchedUsed = Array1D_bool(OutputReportTabular::numResourceTypes, false); - this->ffSchedIndex = Array1D_int(OutputReportTabular::numResourceTypes, 0); + this->ffScheds = Array1D(OutputReportTabular::numResourceTypes, nullptr); this->meterNumEndUseBEPS = Array2D_int(OutputReportTabular::numResourceTypes, static_cast(Constant::EndUse::Num), 0); this->meterNumEndUseSubBEPS.deallocate(); this->meterNumEndUseSpTypeBEPS.deallocate(); diff --git a/src/EnergyPlus/OutputReportTabularAnnual.cc b/src/EnergyPlus/OutputReportTabularAnnual.cc index fe42ff37954..c34239d6440 100644 --- a/src/EnergyPlus/OutputReportTabularAnnual.cc +++ b/src/EnergyPlus/OutputReportTabularAnnual.cc @@ -337,10 +337,8 @@ void AnnualTable::gatherForTimestep(EnergyPlusData &state, OutputProcessor::Time bool activeMinMax = false; bool activeHoursShown = false; // if schedule is used and the current value is zero, don't gather values - if (m_scheduleNum != 0) { - if (ScheduleManager::GetCurrentScheduleValue(state, m_scheduleNum) == 0.0) { - return; - } + if (m_sched != nullptr && m_sched->getCurrentVal() == 0.0) { + return; } // loop through the fields std::vector::iterator fldStIt; @@ -1388,8 +1386,7 @@ void AnnualTable::clearTable() { m_name = ""; m_filter = ""; - m_scheduleName = ""; - m_scheduleNum = 0; + m_sched = nullptr; m_objectNames.clear(); m_annualFields.clear(); } @@ -1401,7 +1398,7 @@ std::vector AnnualTable::inspectTable() std::vector ret; ret.push_back(m_name); ret.push_back(m_filter); - ret.push_back(m_scheduleName); + ret.push_back(m_sched->Name); return ret; } diff --git a/src/EnergyPlus/OutputReportTabularAnnual.hh b/src/EnergyPlus/OutputReportTabularAnnual.hh index 3a991ddb4ba..6ed75da0773 100644 --- a/src/EnergyPlus/OutputReportTabularAnnual.hh +++ b/src/EnergyPlus/OutputReportTabularAnnual.hh @@ -92,18 +92,17 @@ namespace OutputReportTabularAnnual { { public: // Default Constructor - AnnualTable() : m_name(""), m_filter(""), m_scheduleName(""), m_scheduleNum(0){}; + AnnualTable() : m_name(""), m_filter("") {}; // Member Constructor - AnnualTable(EnergyPlusData &state, std::string name, std::string filter, std::string scheduleName) + AnnualTable(EnergyPlusData &state, std::string name, std::string filter, std::string schedName) { m_name = name; m_filter = filter; - m_scheduleName = scheduleName; - if (!m_scheduleName.empty()) { - m_scheduleNum = ScheduleManager::GetScheduleIndex(state, m_scheduleName); // index to the period schedule + if (!schedName.empty()) { + m_sched = Sched::GetSchedule(state, schedName); // index to the period schedule } else { - m_scheduleNum = 0; + m_sched = nullptr; } }; @@ -137,8 +136,7 @@ namespace OutputReportTabularAnnual { std::string m_name; // identifier std::string m_filter; - std::string m_scheduleName; - int m_scheduleNum; + Sched::Schedule *m_sched = nullptr; std::vector m_objectNames; // for each row of annual table std::vector m_annualFields; // for each column @@ -181,6 +179,10 @@ struct OutputReportTabularAnnualData : BaseGlobalStruct std::vector annualTables; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/OutputReports.cc b/src/EnergyPlus/OutputReports.cc index e8876f46e42..4e8b052278b 100644 --- a/src/EnergyPlus/OutputReports.cc +++ b/src/EnergyPlus/OutputReports.cc @@ -1043,10 +1043,10 @@ void DetailsForSurfaces(EnergyPlusData &state, int const RptType) // (1=Vertices *eiostream << "Shading Surface," << thisSurface.Name << "," << cSurfaceClass(thisSurface.Class) << "," << thisSurface.BaseSurfName << "," << AlgoName << ","; if (RptType == 10) { - if (thisSurface.SchedShadowSurfIndex > 0) { - ScheduleName = ScheduleManager::GetScheduleName(state, thisSurface.SchedShadowSurfIndex); - cSchedMin = format("{:.2R}", ScheduleManager::GetScheduleMinValue(state, thisSurface.SchedShadowSurfIndex)); - cSchedMax = format("{:.2R}", ScheduleManager::GetScheduleMaxValue(state, thisSurface.SchedShadowSurfIndex)); + if (thisSurface.shadowSurfSched != nullptr) { + ScheduleName = thisSurface.shadowSurfSched->Name; + cSchedMin = format("{:.2R}", thisSurface.shadowSurfSched->getMinVal(state)); + cSchedMax = format("{:.2R}", thisSurface.shadowSurfSched->getMinVal(state)); } else { ScheduleName = ""; cSchedMin = "0.0"; @@ -1060,10 +1060,10 @@ void DetailsForSurfaces(EnergyPlusData &state, int const RptType) // (1=Vertices } else if (RptType == 1) { *eiostream << fmt::to_string(thisSurface.Sides) << ","; } else { - if (thisSurface.SchedShadowSurfIndex > 0) { - ScheduleName = ScheduleManager::GetScheduleName(state, thisSurface.SchedShadowSurfIndex); - cSchedMin = format("{:.2R}", ScheduleManager::GetScheduleMinValue(state, thisSurface.SchedShadowSurfIndex)); - cSchedMax = format("{:.2R}", ScheduleManager::GetScheduleMaxValue(state, thisSurface.SchedShadowSurfIndex)); + if (thisSurface.shadowSurfSched != nullptr) { + ScheduleName = thisSurface.shadowSurfSched->Name; + cSchedMin = format("{:.2R}", thisSurface.shadowSurfSched->getMinVal(state)); + cSchedMax = format("{:.2R}", thisSurface.shadowSurfSched->getMinVal(state)); } else { ScheduleName = ""; cSchedMin = "0.0"; diff --git a/src/EnergyPlus/OutputReports.hh b/src/EnergyPlus/OutputReports.hh index 38bba0052a0..637b6ba8de2 100644 --- a/src/EnergyPlus/OutputReports.hh +++ b/src/EnergyPlus/OutputReports.hh @@ -81,6 +81,10 @@ struct OutputReportsData : BaseGlobalStruct bool optiondone = false; std::string lastoption; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/OutsideEnergySources.cc b/src/EnergyPlus/OutsideEnergySources.cc index 452a0703452..5dde8047756 100644 --- a/src/EnergyPlus/OutsideEnergySources.cc +++ b/src/EnergyPlus/OutsideEnergySources.cc @@ -146,6 +146,8 @@ void GetOutsideEnergySourcesInput(EnergyPlusData &state) // component arrays. Data items in the component arrays // are initialized. Output variables are set up. + static constexpr std::string_view routineName = "GetOutsideEnergySourcesInput"; + // GET NUMBER OF ALL EQUIPMENT TYPES int const NumDistrictUnitsHeatWater = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "DistrictHeating:Water"); int const NumDistrictUnitsCool = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "DistrictCooling"); @@ -204,6 +206,8 @@ void GetOutsideEnergySourcesInput(EnergyPlusData &state) state.dataIPShortCut->lAlphaFieldBlanks, state.dataIPShortCut->cAlphaFieldNames); + ErrorObjectHeader eoh{routineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1)}; + if (EnergySourceNum > 1) { GlobalNames::VerifyUniqueInterObjectName(state, state.dataOutsideEnergySrcs->EnergySourceUniqueNames, @@ -269,32 +273,15 @@ void GetOutsideEnergySourcesInput(EnergyPlusData &state) state.dataOutsideEnergySrcs->EnergySource(EnergySourceNum).EnergyTransfer = 0.0; state.dataOutsideEnergySrcs->EnergySource(EnergySourceNum).EnergyRate = 0.0; state.dataOutsideEnergySrcs->EnergySource(EnergySourceNum).EnergyType = EnergyType; - if (!state.dataIPShortCut->lAlphaFieldBlanks(4)) { - state.dataOutsideEnergySrcs->EnergySource(EnergySourceNum).CapFractionSchedNum = - ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(4)); - if (state.dataOutsideEnergySrcs->EnergySource(EnergySourceNum).CapFractionSchedNum == 0) { - ShowSevereError(state, - format("{}=\"{}\", is not valid", - state.dataIPShortCut->cCurrentModuleObject, - state.dataOutsideEnergySrcs->EnergySource(EnergySourceNum).Name)); - ShowContinueError(state, - format("{}=\"{}\" was not found.", state.dataIPShortCut->cAlphaFieldNames(4), state.dataIPShortCut->cAlphaArgs(4))); - ErrorsFound = true; - } - if (!ScheduleManager::CheckScheduleValueMinMax( - state, state.dataOutsideEnergySrcs->EnergySource(EnergySourceNum).CapFractionSchedNum, true, 0.0)) { - ShowWarningError(state, - format("{}=\"{}\", is not valid", - state.dataIPShortCut->cCurrentModuleObject, - state.dataOutsideEnergySrcs->EnergySource(EnergySourceNum).Name)); - ShowContinueError(state, - format("{}=\"{}\" should not have negative values.", - state.dataIPShortCut->cAlphaFieldNames(4), - state.dataIPShortCut->cAlphaArgs(4))); - ShowContinueError(state, "Negative values will be treated as zero, and the simulation continues."); - } - } else { - state.dataOutsideEnergySrcs->EnergySource(EnergySourceNum).CapFractionSchedNum = ScheduleManager::ScheduleAlwaysOn; + + if (state.dataIPShortCut->lAlphaFieldBlanks(4)) { + state.dataOutsideEnergySrcs->EnergySource(EnergySourceNum).capFractionSched = Sched::GetScheduleAlwaysOn(state); + } else if ((state.dataOutsideEnergySrcs->EnergySource(EnergySourceNum).capFractionSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(4))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(4), state.dataIPShortCut->cAlphaArgs(4)); + ErrorsFound = true; + } else if (!state.dataOutsideEnergySrcs->EnergySource(EnergySourceNum).capFractionSched->checkMinVal(state, Clusive::In, 0.0)) { + Sched::ShowWarningBadMin(state, eoh, state.dataIPShortCut->cAlphaFieldNames(4), state.dataIPShortCut->cAlphaArgs(4), Clusive::In, 0.0, + "Negative values will be treated as zero, and the simulation continues."); } } @@ -457,7 +444,7 @@ void OutsideEnergySourceSpecs::calculate(EnergyPlusData &state, bool runFlag, Re Real64 const LoopMaxMdot = state.dataPlnt->PlantLoop(LoopNum).MaxMassFlowRate; // apply power limit from input - Real64 CapFraction = ScheduleManager::GetCurrentScheduleValue(state, this->CapFractionSchedNum); + Real64 CapFraction = this->capFractionSched->getCurrentVal(); CapFraction = max(0.0, CapFraction); // ensure non negative Real64 const CurrentCap = this->NomCap * CapFraction; if (std::abs(MyLoad) > CurrentCap) { diff --git a/src/EnergyPlus/OutsideEnergySources.hh b/src/EnergyPlus/OutsideEnergySources.hh index e71d68a1e19..bc82b9e899e 100644 --- a/src/EnergyPlus/OutsideEnergySources.hh +++ b/src/EnergyPlus/OutsideEnergySources.hh @@ -72,7 +72,7 @@ namespace OutsideEnergySources { std::string Name; // user identifier Real64 NomCap = 0.0; // design nominal capacity of district service bool NomCapWasAutoSized = false; // ture if Nominal Capacity was autosize on input - int CapFractionSchedNum = 0; // capacity modifier schedule number + Sched::Schedule *capFractionSched = nullptr; // capacity modifier schedule number int InletNodeNum = 0; // Node number on the inlet side of the plant int OutletNodeNum = 0; // Node number on the inlet side of the plant Real64 EnergyTransfer = 0.0; // cooling energy provided in time step @@ -130,6 +130,10 @@ struct OutsideEnergySourcesData : BaseGlobalStruct Array1D EnergySource; std::unordered_map EnergySourceUniqueNames; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/PVWatts.cc b/src/EnergyPlus/PVWatts.cc index e53d76f6cd6..aa1f5044ae8 100644 --- a/src/EnergyPlus/PVWatts.cc +++ b/src/EnergyPlus/PVWatts.cc @@ -388,7 +388,7 @@ namespace PVWatts { Real64 TimeStepSysSec = state.dataHVACGlobal->TimeStepSysSec; // We only run this once for each zone time step. - const int NumTimeStepsToday_loc = state.dataGlobal->HourOfDay * state.dataGlobal->NumOfTimeStepInHour + state.dataGlobal->TimeStep; + const int NumTimeStepsToday_loc = state.dataGlobal->HourOfDay * state.dataGlobal->TimeStepsInHour + state.dataGlobal->TimeStep; if (NumTimeStepsToday_ != NumTimeStepsToday_loc) { NumTimeStepsToday_ = NumTimeStepsToday_loc; } else { @@ -402,7 +402,7 @@ namespace PVWatts { ssc_data_set_number(pvwattsData_, "month", state.dataEnvrn->Month); ssc_data_set_number(pvwattsData_, "day", state.dataEnvrn->DayOfMonth); ssc_data_set_number(pvwattsData_, "hour", state.dataGlobal->HourOfDay - 1); - ssc_data_set_number(pvwattsData_, "minute", (state.dataGlobal->TimeStep - 0.5) * state.dataGlobal->MinutesPerTimeStep); + ssc_data_set_number(pvwattsData_, "minute", (state.dataGlobal->TimeStep - 0.5) * state.dataGlobal->MinutesInTimeStep); // Weather Conditions ssc_data_set_number(pvwattsData_, "beam", state.dataEnvrn->BeamSolarRad); diff --git a/src/EnergyPlus/PackagedThermalStorageCoil.cc b/src/EnergyPlus/PackagedThermalStorageCoil.cc index c56067863b8..fdaf62aa3f9 100644 --- a/src/EnergyPlus/PackagedThermalStorageCoil.cc +++ b/src/EnergyPlus/PackagedThermalStorageCoil.cc @@ -203,12 +203,12 @@ void GetTESCoilInput(EnergyPlusData &state) using FluidProperties::GetFluidSpecificHeatTemperatureLimits; using GlobalNames::VerifyUniqueCoilName; using NodeInputManager::GetOnlySingleNode; - using ScheduleManager::GetScheduleIndex; using WaterManager::SetupTankDemandComponent; using WaterManager::SetupTankSupplyComponent; // SUBROUTINE PARAMETER DEFINITIONS: static constexpr std::string_view RoutineName("GetTESCoilInput: "); // include trailing blank space + static constexpr std::string_view routineName = "GetTESCoilInput"; // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int NumAlphas = 0; // Number of alphas in input @@ -239,6 +239,9 @@ void GetTESCoilInput(EnergyPlusData &state) state.dataIPShortCut->lAlphaFieldBlanks, state.dataIPShortCut->cAlphaFieldNames, state.dataIPShortCut->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1)}; + Util::IsNameEmpty(state, state.dataIPShortCut->cAlphaArgs(1), cCurrentModuleObject, ErrorsFound); // ErrorsFound will be set to True if problem was found, left untouched otherwise @@ -246,15 +249,12 @@ void GetTESCoilInput(EnergyPlusData &state) thisTESCoil.Name = state.dataIPShortCut->cAlphaArgs(1); if (state.dataIPShortCut->lAlphaFieldBlanks(2)) { - thisTESCoil.AvailSchedNum = ScheduleManager::ScheduleAlwaysOn; - } else { - thisTESCoil.AvailSchedNum = GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(2)); - if (thisTESCoil.AvailSchedNum == 0) { - ShowSevereError(state, format("{}{}=\"{}\", invalid", RoutineName, cCurrentModuleObject, thisTESCoil.Name)); - ShowContinueError(state, format("...{}=\"{}\".", state.dataIPShortCut->cAlphaFieldNames(2), state.dataIPShortCut->cAlphaArgs(2))); - ErrorsFound = true; - } + thisTESCoil.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((thisTESCoil.availSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(2), state.dataIPShortCut->cAlphaArgs(2)); + ErrorsFound = true; } + thisTESCoil.ModeControlType = static_cast(getEnumValue(modeControlStrings, state.dataIPShortCut->cAlphaArgs(3))); if (thisTESCoil.ModeControlType == PTSCCtrlType::Invalid) { ShowSevereError(state, format("{}{}=\"{}\", invalid", RoutineName, cCurrentModuleObject, thisTESCoil.Name)); @@ -262,17 +262,13 @@ void GetTESCoilInput(EnergyPlusData &state) ShowContinueError(state, "Available choices are ScheduledModes or EMSControlled"); ErrorsFound = true; } - if (state.dataIPShortCut->lAlphaFieldBlanks(4)) { - if (thisTESCoil.ModeControlType == PTSCCtrlType::ScheduledOpModes) { - ShowSevereError(state, format("{}{}=\"{}\", invalid", RoutineName, cCurrentModuleObject, thisTESCoil.Name)); - ShowContinueError(state, format("{} is blank but a schedule is needed", state.dataIPShortCut->cAlphaFieldNames(4))); + + if (thisTESCoil.ModeControlType == PTSCCtrlType::ScheduledOpModes) { + if (state.dataIPShortCut->lAlphaFieldBlanks(4)) { + ShowSevereEmptyField(state, eoh, state.dataIPShortCut->cAlphaFieldNames(4)); ErrorsFound = true; - } - } else { - thisTESCoil.ControlModeSchedNum = GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(4)); - if (thisTESCoil.ControlModeSchedNum == 0 && thisTESCoil.ModeControlType == PTSCCtrlType::ScheduledOpModes) { - ShowSevereError(state, format("{}{}=\"{}\", invalid", RoutineName, cCurrentModuleObject, thisTESCoil.Name)); - ShowContinueError(state, format("...{}=\"{}\".", state.dataIPShortCut->cAlphaFieldNames(4), state.dataIPShortCut->cAlphaArgs(4))); + } else if ((thisTESCoil.controlModeSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(4))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(4), state.dataIPShortCut->cAlphaArgs(4)); ErrorsFound = true; } } @@ -1462,14 +1458,10 @@ void GetTESCoilInput(EnergyPlusData &state) thisTESCoil.BasinHeaterSetpointTemp = state.dataIPShortCut->rNumericArgs(39); if (state.dataIPShortCut->lAlphaFieldBlanks(59)) { - thisTESCoil.BasinHeaterAvailSchedNum = ScheduleManager::ScheduleAlwaysOn; - } else { - thisTESCoil.BasinHeaterAvailSchedNum = GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(59)); - if (thisTESCoil.BasinHeaterAvailSchedNum == 0) { - ShowSevereError(state, format("{}{}=\"{}\", invalid", RoutineName, cCurrentModuleObject, thisTESCoil.Name)); - ShowContinueError(state, format("...{}=\"{}\".", state.dataIPShortCut->cAlphaFieldNames(59), state.dataIPShortCut->cAlphaArgs(59))); - ErrorsFound = true; - } + thisTESCoil.basinHeaterAvailSched = Sched::GetScheduleAlwaysOn(state); + } else if ((thisTESCoil.basinHeaterAvailSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(59))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(59), state.dataIPShortCut->cAlphaArgs(59)); + ErrorsFound = true; } if (state.dataIPShortCut->lAlphaFieldBlanks(60)) { @@ -1886,7 +1878,6 @@ void InitTESCoil(EnergyPlusData &state, int &TESCoilNum) // Using/Aliasing using PlantUtilities::ScanPlantLoopsForObject; - using ScheduleManager::GetCurrentScheduleValue; // SUBROUTINE LOCAL VARIABLE DECLARATIONS: auto &thisTESCoil = state.dataPackagedThermalStorageCoil->TESCoil(TESCoilNum); @@ -1999,9 +1990,9 @@ void InitTESCoil(EnergyPlusData &state, int &TESCoilNum) } // determine control mode - if (GetCurrentScheduleValue(state, thisTESCoil.AvailSchedNum) != 0.0) { + if (thisTESCoil.availSched->getCurrentVal() != 0.0) { if (thisTESCoil.ModeControlType == PTSCCtrlType::ScheduledOpModes) { - Real64 const tmpSchedValue = GetCurrentScheduleValue(state, thisTESCoil.ControlModeSchedNum); + Real64 const tmpSchedValue = thisTESCoil.controlModeSched->getCurrentVal(); // check if value is valid if (tmpSchedValue > static_cast(PTSCOperatingMode::Invalid) && tmpSchedValue < static_cast(PTSCOperatingMode::Num)) { thisTESCoil.CurControlMode = static_cast(tmpSchedValue); @@ -2376,11 +2367,11 @@ void SizeTESCoil(EnergyPlusData &state, int &TESCoilNum) state, thisTESCoil.StorageFluidName, Constant::CWInitConvTemp, thisTESCoil.StorageFluidIndex, calcTESWaterStorageTank); if (thisTESCoil.DischargeOnlyRatedDischargeCap > 0.0 && thisTESCoil.DischargeOnlyModeAvailable) { thisTESCoil.FluidStorageVolume = - (thisTESCoil.DischargeOnlyRatedDischargeCap * thisTESCoil.StorageCapacitySizingFactor * Constant::SecInHour) / + (thisTESCoil.DischargeOnlyRatedDischargeCap * thisTESCoil.StorageCapacitySizingFactor * Constant::rSecsInHour) / (rho * Cp * deltaT); } else { thisTESCoil.FluidStorageVolume = - (thisTESCoil.CoolingOnlyRatedTotCap * thisTESCoil.StorageCapacitySizingFactor * Constant::SecInHour) / (rho * Cp * deltaT); + (thisTESCoil.CoolingOnlyRatedTotCap * thisTESCoil.StorageCapacitySizingFactor * Constant::rSecsInHour) / (rho * Cp * deltaT); } BaseSizer::reportSizerOutput( state, "Coil:Cooling:DX:SingleSpeed:ThermalStorage", thisTESCoil.Name, "Fluid Storage Volume [m3]", thisTESCoil.FluidStorageVolume); @@ -2390,9 +2381,9 @@ void SizeTESCoil(EnergyPlusData &state, int &TESCoilNum) if (thisTESCoil.IceStorageCapacity == Constant::AutoCalculate) { if (thisTESCoil.DischargeOnlyRatedDischargeCap > 0.0 && thisTESCoil.DischargeOnlyModeAvailable) { thisTESCoil.IceStorageCapacity = - thisTESCoil.DischargeOnlyRatedDischargeCap * thisTESCoil.StorageCapacitySizingFactor * Constant::SecInHour; + thisTESCoil.DischargeOnlyRatedDischargeCap * thisTESCoil.StorageCapacitySizingFactor * Constant::rSecsInHour; } else { - thisTESCoil.IceStorageCapacity = thisTESCoil.CoolingOnlyRatedTotCap * thisTESCoil.StorageCapacitySizingFactor * Constant::SecInHour; + thisTESCoil.IceStorageCapacity = thisTESCoil.CoolingOnlyRatedTotCap * thisTESCoil.StorageCapacitySizingFactor * Constant::rSecsInHour; } BaseSizer::reportSizerOutput(state, "Coil:Cooling:DX:SingleSpeed:ThermalStorage", @@ -2437,8 +2428,6 @@ void CalcTESCoilOffMode(EnergyPlusData &state, int const TESCoilNum) // MODIFIED na // RE-ENGINEERED na - // Using/Aliasing - using ScheduleManager::GetCurrentScheduleValue; Real64 const TimeStepSysSec = state.dataHVACGlobal->TimeStepSysSec; // SUBROUTINE LOCAL VARIABLE DECLARATIONS: @@ -2446,7 +2435,7 @@ void CalcTESCoilOffMode(EnergyPlusData &state, int const TESCoilNum) // coil is off; just pass through conditions Real64 StandbyAncillaryPower = 0.0; - if (GetCurrentScheduleValue(state, thisTESCoil.AvailSchedNum) != 0.0) { + if (thisTESCoil.availSched->getCurrentVal() != 0.0) { StandbyAncillaryPower = thisTESCoil.AncillaryControlsPower; } @@ -4175,11 +4164,10 @@ void UpdateColdWeatherProtection(EnergyPlusData &state, int const TESCoilNum) // Using/Aliasing Real64 const TimeStepSysSec = state.dataHVACGlobal->TimeStepSysSec; - using ScheduleManager::GetCurrentScheduleValue; if ((state.dataLoopNodes->Node(state.dataPackagedThermalStorageCoil->TESCoil(TESCoilNum).StorageAmbientNodeNum).Temp < state.dataPackagedThermalStorageCoil->TESCoil(TESCoilNum).ColdWeatherMinimumTempLimit) && - (GetCurrentScheduleValue(state, state.dataPackagedThermalStorageCoil->TESCoil(TESCoilNum).AvailSchedNum) != 0.0)) { + (state.dataPackagedThermalStorageCoil->TESCoil(TESCoilNum).availSched->getCurrentVal() != 0.0)) { state.dataPackagedThermalStorageCoil->TESCoil(TESCoilNum).ElectColdWeatherPower = state.dataPackagedThermalStorageCoil->TESCoil(TESCoilNum).ColdWeatherAncillaryPower; @@ -4207,7 +4195,7 @@ void UpdateEvaporativeCondenserBasinHeater(EnergyPlusData &state, int const TESC CalcBasinHeaterPower(state, state.dataPackagedThermalStorageCoil->TESCoil(TESCoilNum).BasinHeaterPowerFTempDiff, - state.dataPackagedThermalStorageCoil->TESCoil(TESCoilNum).BasinHeaterAvailSchedNum, + state.dataPackagedThermalStorageCoil->TESCoil(TESCoilNum).basinHeaterAvailSched, state.dataPackagedThermalStorageCoil->TESCoil(TESCoilNum).BasinHeaterSetpointTemp, state.dataPackagedThermalStorageCoil->TESCoil(TESCoilNum).ElectEvapCondBasinHeaterPower); diff --git a/src/EnergyPlus/PackagedThermalStorageCoil.hh b/src/EnergyPlus/PackagedThermalStorageCoil.hh index 3f126290599..4f35ac23e7e 100644 --- a/src/EnergyPlus/PackagedThermalStorageCoil.hh +++ b/src/EnergyPlus/PackagedThermalStorageCoil.hh @@ -129,9 +129,9 @@ namespace PackagedThermalStorageCoil { { // Members std::string Name; // Name of TES cooling package - int AvailSchedNum; // pointer to availability schedule + Sched::Schedule *availSched = nullptr; // availability schedule PTSCCtrlType ModeControlType; // how are operation modes controlled - int ControlModeSchedNum; // pointer to control schedule if used + Sched::Schedule *controlModeSched = nullptr; // control schedule if used bool EMSControlModeOn; // if true, then EMS actuator has been used Real64 EMSControlModeValue; // value to use from EMS actuator for control mode PTSCOperatingMode CurControlMode = PTSCOperatingMode::Off; @@ -309,7 +309,7 @@ namespace PackagedThermalStorageCoil { Real64 EvapCondPumpElecNomPower; // Nominal power input to the evap condenser water circulation pump [W] Real64 EvapCondPumpElecEnergy; // Electric energy used by condenser water circulation pump [J] Real64 BasinHeaterPowerFTempDiff; // Basin heater power for evaporatively cooled condensers [W/K] - int BasinHeaterAvailSchedNum; // basin heater availability schedule pointer num + Sched::Schedule *basinHeaterAvailSched = nullptr; // basin heater availability schedule pointer num Real64 BasinHeaterSetpointTemp; // evap water basin temperature setpoint [C] EvapWaterSupply EvapWaterSupplyMode; // where does evap water come from std::string EvapWaterSupplyName; // name of water source e.g. water storage tank @@ -376,7 +376,7 @@ namespace PackagedThermalStorageCoil { // Default Constructor PackagedTESCoolingCoilStruct() - : AvailSchedNum(0), ModeControlType(PTSCCtrlType::Invalid), ControlModeSchedNum(0), EMSControlModeOn(false), EMSControlModeValue(0.0), + : ModeControlType(PTSCCtrlType::Invalid), EMSControlModeOn(false), EMSControlModeValue(0.0), ControlModeErrorIndex(0), RatedEvapAirVolFlowRate(0.0), RatedEvapAirMassFlowRate(0.0), EvapAirInletNodeNum(0), EvapAirOutletNodeNum(0), CoolingOnlyModeIsAvailable(false), CoolingOnlyRatedTotCap(0.0), CoolingOnlyRatedSHR(0.0), CoolingOnlyRatedCOP(0.0), CoolingOnlyCapFTempCurve(0), CoolingOnlyCapFTempObjectNum(0), CoolingOnlyCapFFlowCurve(0), CoolingOnlyCapFFlowObjectNum(0), @@ -417,7 +417,7 @@ namespace PackagedThermalStorageCoil { AncillaryControlsPower(0.0), ColdWeatherMinimumTempLimit(0.0), ColdWeatherAncillaryPower(0.0), CondAirInletNodeNum(0), CondAirOutletNodeNum(0), CondenserAirVolumeFlow(0.0), CondenserAirFlowSizingFactor(0.0), CondenserAirMassFlow(0.0), EvapCondEffect(0.0), CondInletTemp(0.0), EvapCondPumpElecNomPower(0.0), EvapCondPumpElecEnergy(0.0), BasinHeaterPowerFTempDiff(0.0), - BasinHeaterAvailSchedNum(0), BasinHeaterSetpointTemp(0.0), EvapWaterSupplyMode(EvapWaterSupply::WaterSupplyFromMains), + BasinHeaterSetpointTemp(0.0), EvapWaterSupplyMode(EvapWaterSupply::WaterSupplyFromMains), EvapWaterSupTankID(0), EvapWaterTankDemandARRID(0), CondensateCollectMode(CondensateAction::Discard), CondensateTankID(0), CondensateTankSupplyARRID(0), StorageMedia(MediaType::Invalid), StorageFluidIndex(0), FluidStorageVolume(0.0), IceStorageCapacity(0.0), StorageCapacitySizingFactor(0.0), MinimumFluidTankTempLimit(0.0), MaximumFluidTankTempLimit(100.0), RatedFluidTankTemp(0.0), @@ -502,6 +502,10 @@ struct PackagedThermalStorageCoilData : BaseGlobalStruct Array1D_bool MyEnvrnFlag; // flag for init once at start of environment Array1D_bool MyWarmupFlag; // flag for init after warmup complete + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/PhaseChangeModeling/HysteresisModel.cc b/src/EnergyPlus/PhaseChangeModeling/HysteresisModel.cc index 222beab8b28..fa5858c1c76 100644 --- a/src/EnergyPlus/PhaseChangeModeling/HysteresisModel.cc +++ b/src/EnergyPlus/PhaseChangeModeling/HysteresisModel.cc @@ -352,26 +352,25 @@ namespace Material { auto *mat = s_mat->materials(matNum); if (mat->group != Group::Regular) { - ShowSevereCustomMessage(state, eoh, format("Material {} is not a Regular material.", mat->Name)); + ShowSevereCustom(state, eoh, format("Material {} is not a Regular material.", mat->Name)); ErrorsFound = true; continue; } if (mat->hasPCM) { - ShowSevereCustomMessage( - state, eoh, format("Material {} already has {} properties defined.", mat->Name, s_ipsc->cCurrentModuleObject)); + ShowSevereCustom(state, eoh, format("Material {} already has {} properties defined.", mat->Name, s_ipsc->cCurrentModuleObject)); ErrorsFound = true; continue; } if (mat->hasEMPD) { - ShowSevereCustomMessage(state, eoh, format("Material {} already has EMPD properties defined.", mat->Name)); + ShowSevereCustom(state, eoh, format("Material {} already has EMPD properties defined.", mat->Name)); ErrorsFound = true; continue; } if (mat->hasHAMT) { - ShowSevereCustomMessage(state, eoh, format("Material {} already has HAMT properties defined.", mat->Name)); + ShowSevereCustom(state, eoh, format("Material {} already has HAMT properties defined.", mat->Name)); ErrorsFound = true; continue; } diff --git a/src/EnergyPlus/PhaseChangeModeling/HysteresisModel.hh b/src/EnergyPlus/PhaseChangeModeling/HysteresisModel.hh index d0e87ddef26..32071e263ea 100644 --- a/src/EnergyPlus/PhaseChangeModeling/HysteresisModel.hh +++ b/src/EnergyPlus/PhaseChangeModeling/HysteresisModel.hh @@ -143,6 +143,10 @@ struct HysteresisPhaseChangeData : BaseGlobalStruct bool getHysteresisModels = true; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/PhotovoltaicThermalCollectors.cc b/src/EnergyPlus/PhotovoltaicThermalCollectors.cc index 1dcca089a10..d0ecacfc360 100644 --- a/src/EnergyPlus/PhotovoltaicThermalCollectors.cc +++ b/src/EnergyPlus/PhotovoltaicThermalCollectors.cc @@ -186,6 +186,8 @@ namespace PhotovoltaicThermalCollectors { // PURPOSE OF THIS SUBROUTINE: // Get input for PVT Simple objects + static constexpr std::string_view routineName = "GetPVTSimpleCollectorsInput"; + int Item; // Item to be "gotten" int NumAlphas; // Number of Alphas for each GetObjectItem call int NumNumbers; // Number of Numbers for each GetObjectItem call @@ -206,20 +208,25 @@ namespace PhotovoltaicThermalCollectors { state.dataIPShortCut->lAlphaFieldBlanks, state.dataIPShortCut->cAlphaFieldNames, state.dataIPShortCut->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1)}; + auto &thisTmpSimplePVTperf = tmpSimplePVTperf(Item); thisTmpSimplePVTperf.Name = state.dataIPShortCut->cAlphaArgs(1); thisTmpSimplePVTperf.ThermEfficMode = static_cast(getEnumValue(ThermEfficTypeNamesUC, Util::makeUPPER(state.dataIPShortCut->cAlphaArgs(2)))); thisTmpSimplePVTperf.ThermalActiveFract = state.dataIPShortCut->rNumericArgs(1); thisTmpSimplePVTperf.ThermEffic = state.dataIPShortCut->rNumericArgs(2); - thisTmpSimplePVTperf.ThermEffSchedNum = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(3)); - if ((thisTmpSimplePVTperf.ThermEffSchedNum == 0) && (thisTmpSimplePVTperf.ThermEfficMode == ThermEfficEnum::SCHEDULED)) { - ShowSevereError(state, - format("GetPVTSimpleCollectorsInput: Invalid efficiency schedule name passed={}, object type={}, object name={}", - state.dataIPShortCut->cAlphaArgs(3), - state.dataIPShortCut->cCurrentModuleObject, - thisTmpSimplePVTperf.Name)); - ErrorsFound = true; + + + if (thisTmpSimplePVTperf.ThermEfficMode == ThermEfficEnum::SCHEDULED) { + if (state.dataIPShortCut->lAlphaFieldBlanks(3)) { + ShowSevereEmptyField(state, eoh, state.dataIPShortCut->cAlphaFieldNames(3)); + ErrorsFound = true; + } else if ((thisTmpSimplePVTperf.thermEffSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(3))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(3), state.dataIPShortCut->cAlphaArgs(3)); + ErrorsFound = true; + } } thisTmpSimplePVTperf.SurfEmissivity = state.dataIPShortCut->rNumericArgs(3); } @@ -229,7 +236,8 @@ namespace PhotovoltaicThermalCollectors { { // PURPOSE OF THIS SUBROUTINE: // Get input for BIPVT objects - + static constexpr std::string_view routineName = "GetBIPVTCollectorsInput"; + int Item; // Item to be "gotten" int NumAlphas; // Number of Alphas for each GetObjectItem call int NumNumbers; // Number of Numbers for each GetObjectItem call @@ -237,8 +245,6 @@ namespace PhotovoltaicThermalCollectors { int Found; bool ErrorsFound(false); // Set to true if errors in input, fatal at end of routine using DataSurfaces::OSCMData; - using ScheduleManager::GetScheduleIndex; - using ScheduleManager::ScheduleAlwaysOn; tmpBIPVTperf.allocate(NumBIPVTPerform); for (Item = 1; Item <= NumBIPVTPerform; ++Item) { @@ -254,6 +260,9 @@ namespace PhotovoltaicThermalCollectors { state.dataIPShortCut->lAlphaFieldBlanks, state.dataIPShortCut->cAlphaFieldNames, state.dataIPShortCut->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1)}; + auto &thisTmpBIPVTperf = tmpBIPVTperf(Item); thisTmpBIPVTperf.Name = state.dataIPShortCut->cAlphaArgs(1); thisTmpBIPVTperf.OSCMName = state.dataIPShortCut->cAlphaArgs(2); @@ -280,19 +289,13 @@ namespace PhotovoltaicThermalCollectors { thisTmpBIPVTperf.ThGlass = state.dataIPShortCut->rNumericArgs(11); thisTmpBIPVTperf.RIndGlass = state.dataIPShortCut->rNumericArgs(12); thisTmpBIPVTperf.ECoffGlass = state.dataIPShortCut->rNumericArgs(13); + if (state.dataIPShortCut->lAlphaFieldBlanks(3)) { - thisTmpBIPVTperf.SchedPtr = ScheduleAlwaysOn; - } else { - thisTmpBIPVTperf.SchedPtr = GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(3)); - if (thisTmpBIPVTperf.SchedPtr == 0) { - ShowSevereError(state, - format("GetBIPVTCollectorsInput: Invalid schedule name ={}, object type={}, object name={}", - state.dataIPShortCut->cAlphaArgs(3), - state.dataIPShortCut->cCurrentModuleObject, - thisTmpBIPVTperf.Name)); - ErrorsFound = true; - continue; - } + thisTmpBIPVTperf.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((thisTmpBIPVTperf.availSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(3))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(3), state.dataIPShortCut->cAlphaArgs(3)); + ErrorsFound = true; + continue; } } } @@ -1052,7 +1055,7 @@ namespace PhotovoltaicThermalCollectors { Eff = this->Simple.ThermEffic; } break; case ThermEfficEnum::SCHEDULED: { - Eff = ScheduleManager::GetCurrentScheduleValue(state, this->Simple.ThermEffSchedNum); + Eff = this->Simple.thermEffSched->getCurrentVal(); this->Simple.ThermEffic = Eff; } break; default: @@ -1190,7 +1193,6 @@ namespace PhotovoltaicThermalCollectors { // ??? static std::string const RoutineName("CalcBIPVTcollectors"); - using ScheduleManager::GetCurrentScheduleValue; int InletNode = this->HVACInletNodeNum; Real64 mdot = this->MassFlowRate; @@ -1202,7 +1204,7 @@ namespace PhotovoltaicThermalCollectors { Real64 Tcollector(Tinlet); this->OperatingMode = PVTMode::Heating; - if (this->HeatingUseful && this->BypassDamperOff && (GetCurrentScheduleValue(state, this->BIPVT.SchedPtr) > 0.0)) { + if (this->HeatingUseful && this->BypassDamperOff && (this->BIPVT.availSched->getCurrentVal() > 0.0)) { if ((state.dataLoopNodes->Node(this->HVACOutletNodeNum).TempSetPoint - Tinlet) > 0.1) { calculateBIPVTMaxHeatGain(state, @@ -1229,7 +1231,7 @@ namespace PhotovoltaicThermalCollectors { this->Report.BypassStatus = BypassFraction; if (PotentialHeatGain > 0.0) this->BIPVT.LastCollectorTemp = Tcollector; - } else if (this->CoolingUseful && this->BypassDamperOff && (GetCurrentScheduleValue(state, this->BIPVT.SchedPtr) > 0.0)) { + } else if (this->CoolingUseful && this->BypassDamperOff && (this->BIPVT.availSched->getCurrentVal() > 0.0)) { this->OperatingMode = PVTMode::Cooling; if ((Tinlet - state.dataLoopNodes->Node(this->HVACOutletNodeNum).TempSetPoint) > 0.1) { diff --git a/src/EnergyPlus/PhotovoltaicThermalCollectors.hh b/src/EnergyPlus/PhotovoltaicThermalCollectors.hh index 96e8be2d34c..ecb25b4187f 100644 --- a/src/EnergyPlus/PhotovoltaicThermalCollectors.hh +++ b/src/EnergyPlus/PhotovoltaicThermalCollectors.hh @@ -97,7 +97,7 @@ namespace PhotovoltaicThermalCollectors { Real64 ThermalActiveFract = 0.0; // fraction of surface area with active thermal collection ThermEfficEnum ThermEfficMode = ThermEfficEnum::FIXED; // setting for how therm effic is determined Real64 ThermEffic = 0.0; // fixed or current Therm efficiency - int ThermEffSchedNum = 0; // pointer to schedule for therm effic (if any) + Sched::Schedule *thermEffSched = nullptr; // pointer to schedule for therm effic (if any) Real64 SurfEmissivity = 0.0; // surface emittance in long wave IR Real64 LastCollectorTemp = 0.0; // store previous temperature }; @@ -107,7 +107,7 @@ namespace PhotovoltaicThermalCollectors { std::string Name; std::string OSCMName; // OtherSideConditionsModel int OSCMPtr = 0; // OtherSideConditionsModel index - int SchedPtr = 0; // Availablity schedule + Sched::Schedule *availSched = nullptr; // Availablity schedule Real64 PVEffGapWidth = 0.0; // Effective Gap Plenum Behind PV modules (m) Real64 PVCellTransAbsProduct = 0.0; // PV cell Transmittance-Absorptance prodiuct Real64 BackMatTranAbsProduct = 0.0; // Backing Material Normal Transmittance-Absorptance Product @@ -256,6 +256,10 @@ struct PhotovoltaicThermalCollectorsData : BaseGlobalStruct int NumPVT = 0; // count of all types of PVT in input file Array1D PVT; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/Photovoltaics.cc b/src/EnergyPlus/Photovoltaics.cc index c0915d7d42a..a8fe6e7799b 100644 --- a/src/EnergyPlus/Photovoltaics.cc +++ b/src/EnergyPlus/Photovoltaics.cc @@ -248,9 +248,9 @@ namespace Photovoltaics { using namespace DataHeatBalance; using PhotovoltaicThermalCollectors::GetPVTmodelIndex; - using ScheduleManager::GetScheduleIndex; using TranspiredCollector::GetTranspiredCollectorIndex; + static constexpr std::string_view routineName = "GetPVInput"; // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int PVnum; // working variable for do loop through pv arrays int SurfNum; // working variable for surface id in Heat Balance domain @@ -468,6 +468,9 @@ namespace Photovoltaics { state.dataIPShortCut->lAlphaFieldBlanks, state.dataIPShortCut->cAlphaFieldNames, state.dataIPShortCut->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1)}; + if (Util::IsNameEmpty(state, state.dataIPShortCut->cAlphaArgs(1), cCurrentModuleObject, ErrorsFound)) { continue; } @@ -495,12 +498,14 @@ namespace Photovoltaics { } tmpSimpleModuleParams(ModNum).PVEfficiency = state.dataIPShortCut->rNumericArgs(2); - tmpSimpleModuleParams(ModNum).EffSchedPtr = GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(3)); - if ((tmpSimpleModuleParams(ModNum).EffSchedPtr == 0) && (tmpSimpleModuleParams(ModNum).EfficencyInputMode == Efficiency::Scheduled)) { - ShowSevereError(state, format("Invalid {} = {}", state.dataIPShortCut->cAlphaFieldNames(3), state.dataIPShortCut->cAlphaArgs(3))); - ShowContinueError(state, format("Entered in {} = {}", cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, "Did not find schedule"); - ErrorsFound = true; + if (tmpSimpleModuleParams(ModNum).EfficencyInputMode == Efficiency::Scheduled) { + if (state.dataIPShortCut->lAlphaFieldBlanks(3)) { + ShowSevereEmptyField(state, eoh, state.dataIPShortCut->cAlphaFieldNames(3)); + ErrorsFound = true; + } else if ((tmpSimpleModuleParams(ModNum).effSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(3))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(3), state.dataIPShortCut->cAlphaArgs(3)); + ErrorsFound = true; + } } } } @@ -806,7 +811,6 @@ namespace Photovoltaics { // Using/Aliasing Real64 TimeStepSysSec = state.dataHVACGlobal->TimeStepSysSec; - using ScheduleManager::GetCurrentScheduleValue; // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int ThisSurf; // working index ptr to Surface arrays @@ -822,7 +826,7 @@ namespace Photovoltaics { Eff = state.dataPhotovoltaic->PVarray(thisPV).SimplePVModule.PVEfficiency; } break; case Efficiency::Scheduled: { // get from schedule - Eff = GetCurrentScheduleValue(state, state.dataPhotovoltaic->PVarray(thisPV).SimplePVModule.EffSchedPtr); + Eff = state.dataPhotovoltaic->PVarray(thisPV).SimplePVModule.effSched->getCurrentVal(); state.dataPhotovoltaic->PVarray(thisPV).SimplePVModule.PVEfficiency = Eff; } break; default: { @@ -949,8 +953,8 @@ namespace Photovoltaics { thisPVarray.SNLPVinto.IcDiffuse = state.dataHeatBal->SurfQRadSWOutIncident(ThisSurf) - state.dataHeatBal->SurfQRadSWOutIncidentBeam(ThisSurf); //(W/ m2)(was kJ/hr m2) thisPVarray.SNLPVinto.IncidenceAngle = - std::acos(state.dataHeatBal->SurfCosIncidenceAngle(ThisSurf)) / Constant::DegToRadians; // (deg) from dataHeatBalance - thisPVarray.SNLPVinto.ZenithAngle = std::acos(state.dataEnvrn->SOLCOS(3)) / Constant::DegToRadians; //(degrees), + std::acos(state.dataHeatBal->SurfCosIncidenceAngle(ThisSurf)) / Constant::DegToRad; // (deg) from dataHeatBalance + thisPVarray.SNLPVinto.ZenithAngle = std::acos(state.dataEnvrn->SOLCOS(3)) / Constant::DegToRad; //(degrees), thisPVarray.SNLPVinto.Tamb = state.dataSurface->SurfOutDryBulbTemp(ThisSurf); //(deg. C) thisPVarray.SNLPVinto.WindSpeed = state.dataSurface->SurfOutWindSpeed(ThisSurf); // (m/s) thisPVarray.SNLPVinto.Altitude = state.dataEnvrn->Elevation; // from DataEnvironment via USE @@ -1271,7 +1275,7 @@ namespace Photovoltaics { // if the cell temperature mode is 2, convert the timestep to seconds if (state.dataPhotovoltaicState->firstTime && state.dataPhotovoltaic->PVarray(PVnum).CellIntegrationMode == CellIntegration::DecoupledUllebergDynamic) { - state.dataPhotovoltaicState->PVTimeStep = double(state.dataGlobal->MinutesPerTimeStep) * 60.0; // Seconds per time step + state.dataPhotovoltaicState->PVTimeStep = double(state.dataGlobal->MinutesInTimeStep) * 60.0; // Seconds per time step } state.dataPhotovoltaicState->firstTime = false; @@ -1906,7 +1910,7 @@ namespace Photovoltaics { Real64 AbsoluteAirMass; if (SolZen < 89.9) { - Real64 const AM(1.0 / (std::cos(SolZen * Constant::DegToRadians) + 0.5057 * std::pow(96.08 - SolZen, -1.634))); + Real64 const AM(1.0 / (std::cos(SolZen * Constant::DegToRad) + 0.5057 * std::pow(96.08 - SolZen, -1.634))); AbsoluteAirMass = std::exp(-0.0001184 * Altitude) * AM; } else { Real64 constexpr AM(36.32); // evaluated above at SolZen = 89.9 issue #5528 diff --git a/src/EnergyPlus/Photovoltaics.hh b/src/EnergyPlus/Photovoltaics.hh index fecd98cf9ad..f336ee1c3b1 100644 --- a/src/EnergyPlus/Photovoltaics.hh +++ b/src/EnergyPlus/Photovoltaics.hh @@ -334,6 +334,10 @@ struct PhotovoltaicStateData : BaseGlobalStruct Real64 PVTimeStep; // internal timestep (in seconds) for cell temperature mode 3 Array1D_bool MyEnvrnFlag; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/PipeHeatTransfer.cc b/src/EnergyPlus/PipeHeatTransfer.cc index b894207c80e..3d21dc63e7c 100644 --- a/src/EnergyPlus/PipeHeatTransfer.cc +++ b/src/EnergyPlus/PipeHeatTransfer.cc @@ -207,14 +207,12 @@ void GetPipesHeatTransfer(EnergyPlusData &state) using NodeInputManager::GetOnlySingleNode; using namespace DataLoopNode; using OutAirNodeManager::CheckOutAirNodeNumber; - using ScheduleManager::GetScheduleIndex; static constexpr std::string_view routineName = "GetPipeHeatTransfer"; // SUBROUTINE PARAMETER DEFINITIONS: int constexpr NumPipeSections(20); int constexpr NumberOfDepthNodes(8); // Number of nodes in the cartesian grid-Should be an even # for now - Real64 const SecondsInHour(Constant::SecInHour); // SUBROUTINE LOCAL VARIABLE DECLARATIONS: bool ErrorsFound(false); // Set to true if errors in input, @@ -226,7 +224,6 @@ void GetPipesHeatTransfer(EnergyPlusData &state) int NumOfPipeHTInt; // Number of Pipe Heat Transfer objects int NumOfPipeHTExt; // Number of Pipe Heat Transfer objects int NumOfPipeHTUG; // Number of Pipe Heat Transfer objects - int NumSections; // total number of sections in pipe auto &s_ipsc = state.dataIPShortCut; auto &s_mat = state.dataMaterial; @@ -336,16 +333,16 @@ void GetPipesHeatTransfer(EnergyPlusData &state) case PipeIndoorBoundaryType::Schedule: state.dataPipeHT->PipeHT(Item).EnvironmentPtr = EnvrnPtr::ScheduleEnv; - state.dataPipeHT->PipeHT(Item).EnvrSchedule = s_ipsc->cAlphaArgs(7); - state.dataPipeHT->PipeHT(Item).EnvrSchedPtr = GetScheduleIndex(state, state.dataPipeHT->PipeHT(Item).EnvrSchedule); - state.dataPipeHT->PipeHT(Item).EnvrVelSchedule = s_ipsc->cAlphaArgs(8); - state.dataPipeHT->PipeHT(Item).EnvrVelSchedPtr = GetScheduleIndex(state, state.dataPipeHT->PipeHT(Item).EnvrVelSchedule); - if (state.dataPipeHT->PipeHT(Item).EnvrSchedPtr == 0) { + + + state.dataPipeHT->PipeHT(Item).envrSched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(7)); + state.dataPipeHT->PipeHT(Item).envrVelSched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(8)); + if (state.dataPipeHT->PipeHT(Item).envrSched == nullptr) { ShowSevereError(state, format("Invalid {}={}", s_ipsc->cAlphaFieldNames(7), s_ipsc->cAlphaArgs(7))); ShowContinueError(state, format("Entered in {}={}", s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); ErrorsFound = true; } - if (state.dataPipeHT->PipeHT(Item).EnvrVelSchedPtr == 0) { + if (state.dataPipeHT->PipeHT(Item).envrVelSched == nullptr) { ShowSevereError(state, format("Invalid {}={}", s_ipsc->cAlphaFieldNames(8), s_ipsc->cAlphaArgs(8))); ShowContinueError(state, format("Entered in {}={}", s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); ErrorsFound = true; @@ -643,7 +640,7 @@ void GetPipesHeatTransfer(EnergyPlusData &state) state.dataPipeHT->PipeHT(Item).SoilDiffusivity = state.dataPipeHT->PipeHT(Item).SoilConductivity / (state.dataPipeHT->PipeHT(Item).SoilDensity * state.dataPipeHT->PipeHT(Item).SoilCp); state.dataPipeHT->PipeHT(Item).SoilDiffusivityPerDay = - state.dataPipeHT->PipeHT(Item).SoilDiffusivity * SecondsInHour * Constant::HoursInDay; + state.dataPipeHT->PipeHT(Item).SoilDiffusivity * Constant::rSecsInDay; // Mesh the cartesian domain state.dataPipeHT->PipeHT(Item).NumDepthNodes = NumberOfDepthNodes; @@ -914,7 +911,6 @@ void PipeHTData::InitPipesHeatTransfer(EnergyPlusData &state, bool const FirstHV Real64 TimeStepSysSec = state.dataHVACGlobal->TimeStepSysSec; using FluidProperties::GetDensityGlycol; using FluidProperties::GetSpecificHeatGlycol; - using ScheduleManager::GetCurrentScheduleValue; // SUBROUTINE PARAMETER DEFINITIONS: static constexpr std::string_view RoutineName("InitPipesHeatTransfer"); @@ -1020,7 +1016,7 @@ void PipeHTData::InitPipesHeatTransfer(EnergyPlusData &state, bool const FirstHV state.dataPipeHT->nsvEnvironmentTemp = state.dataZoneTempPredictorCorrector->zoneHeatBalance(this->EnvrZonePtr).MAT; } break; case EnvrnPtr::ScheduleEnv: { - state.dataPipeHT->nsvEnvironmentTemp = GetCurrentScheduleValue(state, this->EnvrSchedPtr); + state.dataPipeHT->nsvEnvironmentTemp = this->envrSched->getCurrentVal(); } break; case EnvrnPtr::None: { // default to outside temp state.dataPipeHT->nsvEnvironmentTemp = state.dataEnvrn->OutDryBulbTemp; @@ -1777,9 +1773,6 @@ Real64 PipeHTData::OutsidePipeHeatTransCoef(EnergyPlusData &state) // Fundamentals of Heat and Mass Transfer: Incropera and DeWitt, 4th ed. // p. 369-370 (Eq. 7:55b) - // Using/Aliasing - using ScheduleManager::GetCurrentScheduleValue; - // Return value Real64 OutsidePipeHeatTransCoef; @@ -1823,8 +1816,8 @@ Real64 PipeHTData::OutsidePipeHeatTransCoef(EnergyPlusData &state) case DataPlant::PlantEquipmentType::PipeInterior: { switch (this->EnvironmentPtr) { case EnvrnPtr::ScheduleEnv: { - AirTemp = GetCurrentScheduleValue(state, this->EnvrSchedPtr); - AirVel = GetCurrentScheduleValue(state, this->EnvrVelSchedPtr); + AirTemp = this->envrSched->getCurrentVal(); + AirVel = this->envrVelSched->getCurrentVal(); } break; case EnvrnPtr::ZoneEnv: { AirTemp = state.dataZoneTempPredictorCorrector->zoneHeatBalance(this->EnvrZonePtr).MAT; @@ -1922,12 +1915,8 @@ Real64 PipeHTData::TBND(EnergyPlusData &state, // REFERENCES: See Module Level Description // Using/Aliasing - Real64 curSimTime = state.dataGlobal->DayOfSim * Constant::SecsInDay; - Real64 TBND; - - TBND = this->groundTempModel->getGroundTempAtTimeInSeconds(state, z, curSimTime); - - return TBND; + Real64 curSimTime = state.dataGlobal->DayOfSim * Constant::rSecsInDay; + return this->groundTempModel->getGroundTempAtTimeInSeconds(state, z, curSimTime); } void PipeHTData::oneTimeInit([[maybe_unused]] EnergyPlusData &state) diff --git a/src/EnergyPlus/PipeHeatTransfer.hh b/src/EnergyPlus/PipeHeatTransfer.hh index 3eb9c5f4de8..b4e9ae79264 100644 --- a/src/EnergyPlus/PipeHeatTransfer.hh +++ b/src/EnergyPlus/PipeHeatTransfer.hh @@ -107,8 +107,8 @@ namespace PipeHeatTransfer { std::string Name; std::string Construction; // construction object name std::string Environment; // keyword: 'Schedule', 'OutdoorAir', 'Zone' - std::string EnvrSchedule; // temperature schedule for environmental temp - std::string EnvrVelSchedule; // temperature schedule for environmental temp + Sched::Schedule *envrSched = nullptr; // temperature schedule for environmental temp + Sched::Schedule *envrVelSched = nullptr; // temperature schedule for environmental temp std::string EnvrAirNode; // outside air node providing environmental temp Real64 Length; // total pipe length [m] Real64 PipeID; // pipe inside diameter [m] @@ -120,8 +120,6 @@ namespace PipeHeatTransfer { // derived data int ConstructionNum; // construction ref number EnvrnPtr EnvironmentPtr; - int EnvrSchedPtr; // pointer to schedule used to set environmental temp - int EnvrVelSchedPtr; // pointer to schedule used to set environmental temp int EnvrZonePtr; // pointer to zone number used to set environmental temp int EnvrAirNodeNum; // pointer to outside air node used to set environmental temp int NumSections; // total number of nodes along pipe length @@ -200,7 +198,7 @@ namespace PipeHeatTransfer { // Default Constructor PipeHTData() : Length(0.0), PipeID(0.0), InletNodeNum(0), OutletNodeNum(0), Type(DataPlant::PlantEquipmentType::Invalid), ConstructionNum(0), - EnvironmentPtr(EnvrnPtr::None), EnvrSchedPtr(0), EnvrVelSchedPtr(0), EnvrZonePtr(0), EnvrAirNodeNum(0), NumSections(0), + EnvironmentPtr(EnvrnPtr::None), EnvrZonePtr(0), EnvrAirNodeNum(0), NumSections(0), FluidSpecHeat(0.0), FluidDensity(0.0), MaxFlowRate(0.0), InsideArea(0.0), OutsideArea(0.0), SectionArea(0.0), PipeHeatCapacity(0.0), PipeOD(0.0), PipeCp(0.0), PipeDensity(0.0), PipeConductivity(0.0), InsulationOD(0.0), InsulationCp(0.0), InsulationDensity(0.0), InsulationConductivity(0.0), InsulationThickness(0.0), InsulationResistance(0.0), CurrentSimTime(0.0), PreviousSimTime(0.0), @@ -286,10 +284,14 @@ struct PipeHeatTransferData : BaseGlobalStruct Array1D PipeHT; std::unordered_map PipeHTUniqueNames; - void init_state([[maybe_unused]] EnergyPlusData &state) override + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override { } + void init_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void clear_state() override { this->nsvNumOfPipeHT = 0; diff --git a/src/EnergyPlus/Pipes.hh b/src/EnergyPlus/Pipes.hh index 6dc05b9e964..6369747fd31 100644 --- a/src/EnergyPlus/Pipes.hh +++ b/src/EnergyPlus/Pipes.hh @@ -108,6 +108,10 @@ struct PipesData : BaseGlobalStruct EPVector LocalPipe; std::unordered_map LocalPipeUniqueNames; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/Plant/DataPlant.hh b/src/EnergyPlus/Plant/DataPlant.hh index 7a98fa1f2f1..2bafa8e200a 100644 --- a/src/EnergyPlus/Plant/DataPlant.hh +++ b/src/EnergyPlus/Plant/DataPlant.hh @@ -407,6 +407,10 @@ struct DataPlantData : BaseGlobalStruct std::array, static_cast(DataPlant::LoopSideLocation::Num)> VentRepCond; Array1D PlantCallingOrderInfo; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/Plant/EquipAndOperations.hh b/src/EnergyPlus/Plant/EquipAndOperations.hh index 281bf5a2ba6..d688108e9e1 100644 --- a/src/EnergyPlus/Plant/EquipAndOperations.hh +++ b/src/EnergyPlus/Plant/EquipAndOperations.hh @@ -52,6 +52,7 @@ #include #include #include +#include #include namespace EnergyPlus::DataPlant { @@ -261,8 +262,7 @@ struct OperationData std::string Name; // The name of each item in the list std::string TypeOf; // The 'keyWord' identifying each item in the list DataPlant::OpScheme Type; // Op scheme type (from keyword) - std::string Sched; // The name of the schedule associated with the list - int SchedPtr; // ALLOCATABLE to the schedule (for valid schedules) + Sched::Schedule *sched = nullptr; // schedule associated with the list bool Available; // TRUE = designated component or operation scheme available int NumEquipLists; // number of equipment lists int CurListPtr; // points to the current equipment list @@ -280,7 +280,7 @@ struct OperationData // Default Constructor OperationData() - : Type(DataPlant::OpScheme::Invalid), SchedPtr(0), Available(false), NumEquipLists(0), CurListPtr(0), EquipListNumForLastStage(0), + : Type(DataPlant::OpScheme::Invalid), Available(false), NumEquipLists(0), CurListPtr(0), EquipListNumForLastStage(0), ReferenceNodeNumber(0), ErlSimProgramMngr(0), ErlInitProgramMngr(0), initPluginLocation(-1), simPluginLocation(-1), EMSIntVarLoopDemandRate(0.0), MyEnvrnFlag(true) { diff --git a/src/EnergyPlus/Plant/PlantManager.cc b/src/EnergyPlus/Plant/PlantManager.cc index fe4308a50fc..7fc3ced99db 100644 --- a/src/EnergyPlus/Plant/PlantManager.cc +++ b/src/EnergyPlus/Plant/PlantManager.cc @@ -284,7 +284,6 @@ void GetPlantLoopData(EnergyPlusData &state) // calls the Input Processor to retrieve data from input file. // Using/Aliasing - using ScheduleManager::GetScheduleIndex; using SetPointManager::IsNodeOnSetPtManager; HVAC::CtrlVarType localTempSetPt = HVAC::CtrlVarType::Temp; using NodeInputManager::GetOnlySingleNode; @@ -2205,7 +2204,6 @@ void InitializeLoops(EnergyPlusData &state, bool const FirstHVACIteration) // tr // temperature changes. Branch levels for all branches are also set. // Using/Aliasing - using ScheduleManager::GetCurrentScheduleValue; using namespace DataSizing; using EMSManager::CheckIfNodeSetPointManagedByEMS; @@ -2522,9 +2520,6 @@ void ReInitPlantLoopsAtFirstHVACIteration(EnergyPlusData &state) // called from SimHVAC to reset mass flow rate requests // this contains all the initializations - // Using/Aliasing - using ScheduleManager::GetCurrentScheduleValue; - // SUBROUTINE PARAMETER DEFINITIONS: Real64 constexpr StartQuality(1.0); Real64 constexpr StartHumRat(0.0); @@ -2810,7 +2805,7 @@ void ReInitPlantLoopsAtFirstHVACIteration(EnergyPlusData &state) for (OpNum = 1; OpNum <= state.dataPlnt->PlantLoop(LoopNum).NumOpSchemes; ++OpNum) { // If the operating scheme is scheduled "OFF", go to next scheme state.dataPlnt->PlantLoop(LoopNum).OpScheme(OpNum).Available = - GetCurrentScheduleValue(state, state.dataPlnt->PlantLoop(LoopNum).OpScheme(OpNum).SchedPtr) > 0.0; + state.dataPlnt->PlantLoop(LoopNum).OpScheme(OpNum).sched->getCurrentVal() > 0.0; } } } @@ -2894,7 +2889,6 @@ void CheckPlantOnAbort(EnergyPlusData &state) if (!(allocated(state.dataPlnt->PlantLoop))) return; for (LoopNum = 1; LoopNum <= state.dataPlnt->TotNumLoops; ++LoopNum) { - int constexpr numLoopSides = 2; for (DataPlant::LoopSideLocation SideNum : DataPlant::LoopSideKeys) { if (!(state.dataPlnt->PlantLoop(LoopNum).LoopSide(SideNum).Splitter.Exists)) continue; diff --git a/src/EnergyPlus/Plant/PlantManager.hh b/src/EnergyPlus/Plant/PlantManager.hh index a132fd5b985..82ea32662e4 100644 --- a/src/EnergyPlus/Plant/PlantManager.hh +++ b/src/EnergyPlus/Plant/PlantManager.hh @@ -176,6 +176,10 @@ struct PlantMgrData : BaseGlobalStruct int newCallingIndex = 0; PlantManager::EmptyPlantComponent dummyPlantComponent; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/PlantCentralGSHP.cc b/src/EnergyPlus/PlantCentralGSHP.cc index 8b8c4ba8332..5c1a6da967a 100644 --- a/src/EnergyPlus/PlantCentralGSHP.cc +++ b/src/EnergyPlus/PlantCentralGSHP.cc @@ -553,6 +553,8 @@ void GetWrapperInput(EnergyPlusData &state) // PURPOSE OF THIS SUBROUTINE: // This routine will get the input required by the Wrapper model. + static constexpr std::string_view routineName = "GetWrapperInput"; + bool ErrorsFound(false); // True when input errors are found int NumAlphas; // Number of elements in the alpha array int NumNums; // Number of elements in the numeric array @@ -583,6 +585,8 @@ void GetWrapperInput(EnergyPlusData &state) state.dataIPShortCut->cAlphaFieldNames, state.dataIPShortCut->cNumericFieldNames); + ErrorObjectHeader eoh{routineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1)}; + state.dataPlantCentralGSHP->Wrapper(WrapperNum).Name = state.dataIPShortCut->cAlphaArgs(1); // initialize nth chiller heater index (including identical units) for current wrapper @@ -677,9 +681,8 @@ void GetWrapperInput(EnergyPlusData &state) state.dataPlantCentralGSHP->Wrapper(WrapperNum).AncillaryPower = state.dataIPShortCut->rNumericArgs(1); if (state.dataIPShortCut->lAlphaFieldBlanks(9)) { - state.dataPlantCentralGSHP->Wrapper(WrapperNum).SchedPtr = 0; - } else { - state.dataPlantCentralGSHP->Wrapper(WrapperNum).SchedPtr = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(9)); + } else if ((state.dataPlantCentralGSHP->Wrapper(WrapperNum).ancillaryPowerSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(9))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(9), state.dataIPShortCut->cAlphaArgs(9)); } int NumberOfComp = (NumAlphas - 9) / 3; @@ -700,23 +703,15 @@ void GetWrapperInput(EnergyPlusData &state) state.dataPlantCentralGSHP->Wrapper(WrapperNum).WrapperComp(Comp).WrapperPerformanceObjectType = state.dataIPShortCut->cAlphaArgs(loop); state.dataPlantCentralGSHP->Wrapper(WrapperNum).WrapperComp(Comp).WrapperComponentName = state.dataIPShortCut->cAlphaArgs(loop + 1); + if (state.dataIPShortCut->lAlphaFieldBlanks(loop + 2)) { - state.dataPlantCentralGSHP->Wrapper(WrapperNum).WrapperComp(Comp).CHSchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - state.dataPlantCentralGSHP->Wrapper(WrapperNum).WrapperComp(Comp).CHSchedPtr = - ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(loop + 2)); - if (state.dataPlantCentralGSHP->Wrapper(WrapperNum).WrapperComp(Comp).CHSchedPtr == 0) { - state.dataPlantCentralGSHP->Wrapper(WrapperNum).WrapperComp(Comp).CHSchedPtr = ScheduleManager::ScheduleAlwaysOn; - ShowWarningError(state, "Chiller Heater Modules Control Schedule Name not found"); - ShowContinueError(state, - format(" for {}= {}", - state.dataPlantCentralGSHP->Wrapper(WrapperNum).WrapperComp(Comp).WrapperPerformanceObjectType, - state.dataPlantCentralGSHP->Wrapper(WrapperNum).WrapperComp(Comp).WrapperComponentName)); - ShowContinueError( - state, format(" in the object {}= {}", state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, "The Control Schedule is treated as AlwaysOn instead."); - } + state.dataPlantCentralGSHP->Wrapper(WrapperNum).WrapperComp(Comp).chSched = Sched::GetScheduleAlwaysOn(state); + } else if ((state.dataPlantCentralGSHP->Wrapper(WrapperNum).WrapperComp(Comp).chSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(loop + 2))) == nullptr) { + state.dataPlantCentralGSHP->Wrapper(WrapperNum).WrapperComp(Comp).chSched = Sched::GetScheduleAlwaysOn(state); + ShowWarningItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(loop + 2), state.dataIPShortCut->cAlphaArgs(loop + 2), + "The Control Schedule is treated as AlwaysOn instead."); } + state.dataPlantCentralGSHP->Wrapper(WrapperNum).WrapperComp(Comp).WrapperIdenticalObjectNum = state.dataIPShortCut->rNumericArgs(1 + Comp); if (state.dataPlantCentralGSHP->Wrapper(WrapperNum).WrapperComp(Comp).WrapperPerformanceObjectType == @@ -1899,7 +1894,7 @@ void WrapperSpecs::CalcChillerModel(EnergyPlusData &state) Real64 CondMassFlowRate; // Condenser mass flow rate // Check whether this chiller heater needs to run - if (EvaporatorLoad > 0.0 && (ScheduleManager::GetCurrentScheduleValue(state, this->WrapperComp(CompNum).CHSchedPtr) > 0.0)) { + if (EvaporatorLoad > 0.0 && (this->WrapperComp(CompNum).chSched->getCurrentVal() > 0.0)) { IsLoadCoolRemaining = true; // Calculate density ratios to adjust mass flow rates from initialized ones @@ -1948,7 +1943,7 @@ void WrapperSpecs::CalcChillerModel(EnergyPlusData &state) // Chiller heater is on when cooling load for this chiller heater remains and chilled water available if (IsLoadCoolRemaining && (EvapMassFlowRate > 0) && - (ScheduleManager::GetCurrentScheduleValue(state, this->WrapperComp(CompNum).CHSchedPtr) > 0)) { + (this->WrapperComp(CompNum).chSched->getCurrentVal() > 0)) { // Indicate current mode is cooling-only mode. Simultaneous clg/htg mode will be set later CurrentMode = 1; @@ -2189,7 +2184,6 @@ void WrapperSpecs::CalcChillerHeaterModel(EnergyPlusData &state) // 1. DOE-2 Engineers Manual, Version 2.1A, November 1982, LBL-11353 static constexpr std::string_view RoutineName("CalcChillerHeaterModel"); - static constexpr std::string_view RoutineNameElecEIRChiller("CalcElectricEIRChillerModel"); bool IsLoadHeatRemaining; // Ture if heating load remains for this chiller heater bool NextCompIndicator(false); // Component indicator when identical chiller heaters exist @@ -2256,7 +2250,7 @@ void WrapperSpecs::CalcChillerHeaterModel(EnergyPlusData &state) Real64 EvapMassFlowRate; // Evaporator mass flow rate through this chiller heater // Check to see if this chiller heater needs to run - if (CondenserLoad > 0.0 && (ScheduleManager::GetCurrentScheduleValue(state, this->WrapperComp(CompNum).CHSchedPtr) > 0)) { + if (CondenserLoad > 0.0 && (this->WrapperComp(CompNum).chSched->getCurrentVal() > 0)) { IsLoadHeatRemaining = true; // Calculate density ratios to adjust mass flow rates from initialized ones @@ -2349,11 +2343,11 @@ void WrapperSpecs::CalcChillerHeaterModel(EnergyPlusData &state) } // End of system operation determinatoin if (IsLoadHeatRemaining && CondMassFlowRate > 0.0 && - (ScheduleManager::GetCurrentScheduleValue(state, this->WrapperComp(CompNum).CHSchedPtr) > 0)) { // System is on + (this->WrapperComp(CompNum).chSched->getCurrentVal() > 0)) { // System is on // Operation mode if (this->SimulHtgDominant) { if (this->ChillerHeater(ChillerHeaterNum).Report.QEvapSimul == 0.0) { - CurrentMode = 5; // No cooling necessary + CurrentMode = 5; // No cooling necessary // Why is this not an enum? } else { // Heat recovery mode. Both chilled water and hot water loops are connected. No condenser flow. CurrentMode = 3; } @@ -2588,7 +2582,7 @@ void WrapperSpecs::adjustChillerHeaterFlowTemp(EnergyPlusData &state, } Real64 -WrapperSpecs::setChillerHeaterCondTemp(EnergyPlusData &state, int const numChillerHeater, Real64 const condEnteringTemp, Real64 const condLeavingTemp) +WrapperSpecs::setChillerHeaterCondTemp([[maybe_unused]] EnergyPlusData &state, int const numChillerHeater, Real64 const condEnteringTemp, Real64 const condLeavingTemp) { Real64 setChillerHeaterCondTemp; if (this->ChillerHeater(numChillerHeater).CondMode == CondenserModeTemperature::EnteringCondenser) { @@ -2630,7 +2624,7 @@ Real64 WrapperSpecs::calcChillerCapFT(EnergyPlusData &state, int const numChille return chillCapFT; } -void WrapperSpecs::checkEvapOutletTemp(EnergyPlusData &state, +void WrapperSpecs::checkEvapOutletTemp([[maybe_unused]] EnergyPlusData &state, int const numChillerHeater, Real64 &evapOutletTemp, Real64 const lowTempLimitEout, @@ -2838,8 +2832,8 @@ void WrapperSpecs::CalcWrapperModel(EnergyPlusData &state, Real64 &MyLoad, int c HWOutletTemp = HWInletTemp; - if (ScheduleManager::GetCurrentScheduleValue(state, this->SchedPtr) > 0) { - WrapperElecPowerCool += (this->AncillaryPower * ScheduleManager::GetCurrentScheduleValue(state, this->SchedPtr)); + if (this->ancillaryPowerSched->getCurrentVal() > 0) { + WrapperElecPowerCool += (this->AncillaryPower * this->ancillaryPowerSched->getCurrentVal()); } state.dataLoopNodes->Node(this->CHWOutletNodeNum).Temp = CHWOutletTemp; @@ -3052,8 +3046,8 @@ void WrapperSpecs::CalcWrapperModel(EnergyPlusData &state, Real64 &MyLoad, int c } // Add ancilliary power if scheduled - if (ScheduleManager::GetCurrentScheduleValue(state, this->SchedPtr) > 0) { - WrapperElecPowerCool += (this->AncillaryPower * ScheduleManager::GetCurrentScheduleValue(state, this->SchedPtr)); + if (this->ancillaryPowerSched->getCurrentVal() > 0) { + WrapperElecPowerCool += (this->AncillaryPower * this->ancillaryPowerSched->getCurrentVal()); } // Electricity should be counted once for cooling in this mode @@ -3166,8 +3160,8 @@ void WrapperSpecs::CalcWrapperModel(EnergyPlusData &state, Real64 &MyLoad, int c } // Check if ancilliary power is used - if (ScheduleManager::GetCurrentScheduleValue(state, this->SchedPtr) > 0) { - WrapperElecPowerHeat += (this->AncillaryPower * ScheduleManager::GetCurrentScheduleValue(state, this->SchedPtr)); + if (this->ancillaryPowerSched->getCurrentVal() > 0) { + WrapperElecPowerHeat += (this->AncillaryPower * this->ancillaryPowerSched->getCurrentVal()); } // Electricity should be counted once @@ -3230,8 +3224,8 @@ void WrapperSpecs::CalcWrapperModel(EnergyPlusData &state, Real64 &MyLoad, int c CHWOutletTemp = CHWInletTemp; // Add ancilliary power if necessary - if (ScheduleManager::GetCurrentScheduleValue(state, this->SchedPtr) > 0) { - WrapperElecPowerHeat += (this->AncillaryPower * ScheduleManager::GetCurrentScheduleValue(state, this->SchedPtr)); + if (this->ancillaryPowerSched->getCurrentVal() > 0) { + WrapperElecPowerHeat += (this->AncillaryPower * this->ancillaryPowerSched->getCurrentVal()); } } // End of calculations diff --git a/src/EnergyPlus/PlantCentralGSHP.hh b/src/EnergyPlus/PlantCentralGSHP.hh index 1744470956f..b27e5f55e11 100644 --- a/src/EnergyPlus/PlantCentralGSHP.hh +++ b/src/EnergyPlus/PlantCentralGSHP.hh @@ -107,9 +107,9 @@ namespace PlantCentralGSHP { std::string WrapperComponentName; // Component name int WrapperPerformanceObjectIndex; // Component index in the input array int WrapperIdenticalObjectNum; // Number of identical objects - int CHSchedPtr; // Index to schedule + Sched::Schedule *chSched = nullptr; // schedule - WrapperComponentSpecs() : WrapperPerformanceObjectIndex(0), WrapperIdenticalObjectNum(0), CHSchedPtr(0) + WrapperComponentSpecs() : WrapperPerformanceObjectIndex(0), WrapperIdenticalObjectNum(0) { } }; @@ -331,8 +331,8 @@ namespace PlantCentralGSHP { { std::string Name; // User identifier bool VariableFlowCH; // True if all chiller heaters are variable flow control - int SchedPtr; // Schedule value for ancillary power control - int CHSchedPtr; // Schedule value for individual chiller heater control + Sched::Schedule *ancillaryPowerSched = nullptr; // Schedule value for ancillary power control + Sched::Schedule *chSched = nullptr; // Schedule value for individual chiller heater control CondenserType ControlMode; // SmartMixing or FullyMixing int CHWInletNodeNum; // Node number on the inlet side of the plant (Chilled Water side) int CHWOutletNodeNum; // Node number on the outlet side of the plant (Chilled Water side) @@ -376,7 +376,7 @@ namespace PlantCentralGSHP { bool mySizesReported; WrapperSpecs() - : VariableFlowCH(false), SchedPtr(0), CHSchedPtr(0), ControlMode(CondenserType::Invalid), CHWInletNodeNum(0), CHWOutletNodeNum(0), + : VariableFlowCH(false), ControlMode(CondenserType::Invalid), CHWInletNodeNum(0), CHWOutletNodeNum(0), HWInletNodeNum(0), HWOutletNodeNum(0), GLHEInletNodeNum(0), GLHEOutletNodeNum(0), NumOfComp(0), CHWMassFlowRate(0.0), HWMassFlowRate(0.0), GLHEMassFlowRate(0.0), CHWMassFlowRateMax(0.0), HWMassFlowRateMax(0.0), GLHEMassFlowRateMax(0.0), WrapperCoolingLoad(0.0), WrapperHeatingLoad(0.0), AncillaryPower(0.0), CoolSetPointErrDone(false), HeatSetPointErrDone(false), @@ -476,6 +476,10 @@ struct PlantCentralGSHPData : BaseGlobalStruct EPVector Wrapper; EPVector ChillerHeater; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/PlantChillers.cc b/src/EnergyPlus/PlantChillers.cc index b5ebfc224c5..47fc01dcda9 100644 --- a/src/EnergyPlus/PlantChillers.cc +++ b/src/EnergyPlus/PlantChillers.cc @@ -169,6 +169,7 @@ namespace PlantChillers { // required by the Electric Chiller model. static constexpr std::string_view RoutineName("GetElectricChillerInput: "); // include trailing blank space + static constexpr std::string_view routineName = "GetElectricChillerInput"; int NumAlphas; // Number of elements in the alpha array int NumNums; // Number of elements in the numeric array @@ -204,6 +205,9 @@ namespace PlantChillers { state.dataIPShortCut->lAlphaFieldBlanks, state.dataIPShortCut->cAlphaFieldNames, state.dataIPShortCut->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1)}; + Util::IsNameEmpty(state, state.dataIPShortCut->cAlphaArgs(1), state.dataIPShortCut->cCurrentModuleObject, ErrorsFound); // ErrorsFound will be set to True if problem was found, left untouched otherwise @@ -513,22 +517,10 @@ namespace PlantChillers { thisChiller.HeatRecCapacityFraction = 1.0; } - if (NumAlphas > 10) { - if (!state.dataIPShortCut->lAlphaFieldBlanks(11)) { - thisChiller.HeatRecInletLimitSchedNum = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(11)); - if (thisChiller.HeatRecInletLimitSchedNum == 0) { - ShowSevereError( - state, - format("{}{}=\"{}\"", RoutineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError( - state, format("Invalid {}={}", state.dataIPShortCut->cAlphaFieldNames(11), state.dataIPShortCut->cAlphaArgs(11))); - ErrorsFound = true; - } - } else { - thisChiller.HeatRecInletLimitSchedNum = 0; - } - } else { - thisChiller.HeatRecInletLimitSchedNum = 0; + if (NumAlphas <= 10 || state.dataIPShortCut->lAlphaFieldBlanks(11)) { + } else if ((thisChiller.heatRecInletLimitSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(11))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(11), state.dataIPShortCut->cAlphaArgs(11)); + ErrorsFound = true; } if (NumAlphas > 11) { @@ -592,18 +584,12 @@ namespace PlantChillers { } } - if (!state.dataIPShortCut->lAlphaFieldBlanks(10)) { - thisChiller.BasinHeaterSchedulePtr = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(10)); - if (thisChiller.BasinHeaterSchedulePtr == 0) { - ShowWarningError( - state, - format("{}, \"{}\" {} \"{}\" was not found. Basin heater operation will not be modeled and the simulation continues", - state.dataIPShortCut->cCurrentModuleObject, - thisChiller.Name, - state.dataIPShortCut->cAlphaFieldNames(10), - state.dataIPShortCut->cAlphaArgs(10))); - } + if (state.dataIPShortCut->lAlphaFieldBlanks(10)) { + } else if ((thisChiller.basinHeaterSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(10))) == nullptr) { + ShowWarningItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(10), state.dataIPShortCut->cAlphaArgs(10), + "Basin heater operation will not be modeled and the simulation continues"); } + if (NumAlphas > 12) { thisChiller.EndUseSubcategory = state.dataIPShortCut->cAlphaArgs(13); } else { @@ -1454,7 +1440,7 @@ namespace PlantChillers { if (this->CondenserType == DataPlant::CondenserType::EvapCooled) { CalcBasinHeaterPower( - state, this->BasinHeaterPowerFTempDiff, this->BasinHeaterSchedulePtr, this->BasinHeaterSetPointTemp, this->BasinHeaterPower); + state, this->BasinHeaterPowerFTempDiff, this->basinHeaterSched, this->BasinHeaterSetPointTemp, this->BasinHeaterPower); } this->PrintMessage = false; return; @@ -1707,7 +1693,7 @@ namespace PlantChillers { MyLoad = 0.0; if (this->CondenserType == DataPlant::CondenserType::EvapCooled) { CalcBasinHeaterPower( - state, this->BasinHeaterPowerFTempDiff, this->BasinHeaterSchedulePtr, this->BasinHeaterSetPointTemp, this->BasinHeaterPower); + state, this->BasinHeaterPowerFTempDiff, this->basinHeaterSched, this->BasinHeaterSetPointTemp, this->BasinHeaterPower); } this->PrintMessage = false; return; @@ -1831,7 +1817,7 @@ namespace PlantChillers { } if (this->QEvaporator == 0.0 && this->CondenserType == DataPlant::CondenserType::EvapCooled) { CalcBasinHeaterPower( - state, this->BasinHeaterPowerFTempDiff, this->BasinHeaterSchedulePtr, this->BasinHeaterSetPointTemp, this->BasinHeaterPower); + state, this->BasinHeaterPowerFTempDiff, this->basinHeaterSched, this->BasinHeaterSetPointTemp, this->BasinHeaterPower); } } // This is the end of the FlowLock Block @@ -1981,8 +1967,8 @@ namespace PlantChillers { QHeatRec = min(QHeatRec, this->HeatRecMaxCapacityLimit); } // check if limit on inlet is present and exceeded. - if (this->HeatRecInletLimitSchedNum > 0) { - Real64 HeatRecHighInletLimit = ScheduleManager::GetCurrentScheduleValue(state, this->HeatRecInletLimitSchedNum); + if (this->heatRecInletLimitSched != nullptr) { + Real64 HeatRecHighInletLimit = this->heatRecInletLimitSched->getCurrentVal(); if (this->HeatRecInletTemp > HeatRecHighInletLimit) { // shut down heat recovery QHeatRec = 0.0; } @@ -2231,6 +2217,7 @@ namespace PlantChillers { // Locals // PARAMETERS static constexpr std::string_view RoutineName("GetEngineDrivenChillerInput: "); // include trailing blank space + static constexpr std::string_view routineName = "GetEngineDrivenChillerInput"; int NumAlphas; // Number of elements in the alpha array int NumNums; // Number of elements in the numeric array @@ -2265,6 +2252,9 @@ namespace PlantChillers { state.dataIPShortCut->lAlphaFieldBlanks, state.dataIPShortCut->cAlphaFieldNames, state.dataIPShortCut->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1)}; + Util::IsNameEmpty(state, state.dataIPShortCut->cAlphaArgs(1), state.dataIPShortCut->cCurrentModuleObject, ErrorsFound); // ErrorsFound will be set to True if problem was found, left untouched otherwise @@ -2657,16 +2647,10 @@ namespace PlantChillers { } } - if (!state.dataIPShortCut->lAlphaFieldBlanks(16)) { - thisChiller.BasinHeaterSchedulePtr = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(16)); - if (thisChiller.BasinHeaterSchedulePtr == 0) { - ShowWarningError(state, - format("{}, \"{}\" TRIM(state.dataIPShortCut->cAlphaFieldNames(16)) \"{}\" was not found. Basin heater " - "operation will not be modeled and the simulation continues", - state.dataIPShortCut->cCurrentModuleObject, - thisChiller.Name, - state.dataIPShortCut->cAlphaArgs(16))); - } + if (state.dataIPShortCut->lAlphaFieldBlanks(16)) { + } else if ((thisChiller.basinHeaterSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(16))) == nullptr) { + ShowWarningItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(16), state.dataIPShortCut->cAlphaArgs(16), + "Basin heater operation will not be modeled and the simulation continues"); } if (NumNums > 30) { @@ -3544,7 +3528,7 @@ namespace PlantChillers { if (this->CondenserType == DataPlant::CondenserType::EvapCooled) { CalcBasinHeaterPower( - state, this->BasinHeaterPowerFTempDiff, this->BasinHeaterSchedulePtr, this->BasinHeaterSetPointTemp, this->BasinHeaterPower); + state, this->BasinHeaterPowerFTempDiff, this->basinHeaterSched, this->BasinHeaterSetPointTemp, this->BasinHeaterPower); } this->PrintMessage = false; return; @@ -3763,7 +3747,7 @@ namespace PlantChillers { MyLoad = 0.0; if (this->CondenserType == DataPlant::CondenserType::EvapCooled) { CalcBasinHeaterPower( - state, this->BasinHeaterPowerFTempDiff, this->BasinHeaterSchedulePtr, this->BasinHeaterSetPointTemp, this->BasinHeaterPower); + state, this->BasinHeaterPowerFTempDiff, this->basinHeaterSched, this->BasinHeaterSetPointTemp, this->BasinHeaterPower); } this->PrintMessage = false; return; @@ -3889,7 +3873,7 @@ namespace PlantChillers { } if (this->QEvaporator == 0.0 && this->CondenserType == DataPlant::CondenserType::EvapCooled) { CalcBasinHeaterPower( - state, this->BasinHeaterPowerFTempDiff, this->BasinHeaterSchedulePtr, this->BasinHeaterSetPointTemp, this->BasinHeaterPower); + state, this->BasinHeaterPowerFTempDiff, this->basinHeaterSched, this->BasinHeaterSetPointTemp, this->BasinHeaterPower); } } // This is the end of the FlowLock Block @@ -4289,6 +4273,7 @@ namespace PlantChillers { // EnergyPlus input processor static constexpr std::string_view RoutineName("GetGTChillerInput: "); // include trailing blank space + static constexpr std::string_view routineName = "GetGTChillerInput"; int NumAlphas; // Number of elements in the alpha array int NumNums; // Number of elements in the numeric array @@ -4322,6 +4307,9 @@ namespace PlantChillers { state.dataIPShortCut->lAlphaFieldBlanks, state.dataIPShortCut->cAlphaFieldNames, state.dataIPShortCut->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1)}; + Util::IsNameEmpty(state, state.dataIPShortCut->cAlphaArgs(1), state.dataIPShortCut->cCurrentModuleObject, ErrorsFound); // ErrorsFound will be set to True if problem was found, left untouched otherwise @@ -4678,16 +4666,10 @@ namespace PlantChillers { } } - if (!state.dataIPShortCut->lAlphaFieldBlanks(11)) { - thisChiller.BasinHeaterSchedulePtr = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(11)); - if (thisChiller.BasinHeaterSchedulePtr == 0) { - ShowWarningError(state, - format("{}, \"{}\" TRIM(state.dataIPShortCut->cAlphaFieldNames(11)) \"{}\" was not found. Basin heater " - "operation will not be modeled and the simulation continues", - state.dataIPShortCut->cCurrentModuleObject, - thisChiller.Name, - state.dataIPShortCut->cAlphaArgs(11))); - } + if (state.dataIPShortCut->lAlphaFieldBlanks(11)) { + } else if ((thisChiller.basinHeaterSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(11))) == nullptr) { + ShowWarningItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(11), state.dataIPShortCut->cAlphaArgs(11), + "Basin heater operation will not be modeled and the simulation continues"); } if (NumNums > 49) { @@ -5555,7 +5537,7 @@ namespace PlantChillers { if (this->CondenserType == DataPlant::CondenserType::EvapCooled) { CalcBasinHeaterPower( - state, this->BasinHeaterPowerFTempDiff, this->BasinHeaterSchedulePtr, this->BasinHeaterSetPointTemp, this->BasinHeaterPower); + state, this->BasinHeaterPowerFTempDiff, this->basinHeaterSched, this->BasinHeaterSetPointTemp, this->BasinHeaterPower); } this->PrintMessage = false; return; @@ -5760,7 +5742,7 @@ namespace PlantChillers { MyLoad = 0.0; if (this->CondenserType == DataPlant::CondenserType::EvapCooled) { CalcBasinHeaterPower( - state, this->BasinHeaterPowerFTempDiff, this->BasinHeaterSchedulePtr, this->BasinHeaterSetPointTemp, this->BasinHeaterPower); + state, this->BasinHeaterPowerFTempDiff, this->basinHeaterSched, this->BasinHeaterSetPointTemp, this->BasinHeaterPower); } this->PrintMessage = false; return; @@ -5878,7 +5860,7 @@ namespace PlantChillers { } if (this->QEvaporator == 0.0 && this->CondenserType == DataPlant::CondenserType::EvapCooled) { CalcBasinHeaterPower( - state, this->BasinHeaterPowerFTempDiff, this->BasinHeaterSchedulePtr, this->BasinHeaterSetPointTemp, this->BasinHeaterPower); + state, this->BasinHeaterPowerFTempDiff, this->basinHeaterSched, this->BasinHeaterSetPointTemp, this->BasinHeaterPower); } } // This is the end of the FlowLock Block @@ -6260,6 +6242,7 @@ namespace PlantChillers { // SUBROUTINE PARAMETER DEFINITIONS: static constexpr std::string_view RoutineName("GetConstCOPChillerInput: "); // include trailing blank space + static constexpr std::string_view routineName = "GetConstCOPChillerInput"; // include trailing blank space // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int NumAlphas; // Number of elements in the alpha array @@ -6296,6 +6279,8 @@ namespace PlantChillers { state.dataIPShortCut->lAlphaFieldBlanks, state.dataIPShortCut->cAlphaFieldNames, state.dataIPShortCut->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1)}; Util::IsNameEmpty(state, state.dataIPShortCut->cAlphaArgs(1), state.dataIPShortCut->cCurrentModuleObject, ErrorsFound); // ErrorsFound will be set to True if problem was found, left untouched otherwise @@ -6539,16 +6524,10 @@ namespace PlantChillers { } } - if (!state.dataIPShortCut->lAlphaFieldBlanks(8)) { - thisChiller.BasinHeaterSchedulePtr = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(8)); - if (thisChiller.BasinHeaterSchedulePtr == 0) { - ShowWarningError(state, - format("{}, \"{}\" TRIM(state.dataIPShortCut->cAlphaFieldNames(8)) \"{}\" was not found. Basin heater operation " - "will not be modeled and the simulation continues", - state.dataIPShortCut->cCurrentModuleObject, - thisChiller.Name, - state.dataIPShortCut->cAlphaArgs(8))); - } + if (state.dataIPShortCut->lAlphaFieldBlanks(8)) { + } else if ((thisChiller.basinHeaterSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(8))) == nullptr) { + ShowWarningItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(8), state.dataIPShortCut->cAlphaArgs(8), + "Basin heater operation will not be modeled and the simulation continues"); } if (!state.dataIPShortCut->lAlphaFieldBlanks(9)) { @@ -7238,7 +7217,7 @@ namespace PlantChillers { if (this->CondenserType == DataPlant::CondenserType::EvapCooled) { CalcBasinHeaterPower( - state, this->BasinHeaterPowerFTempDiff, this->BasinHeaterSchedulePtr, this->BasinHeaterSetPointTemp, this->BasinHeaterPower); + state, this->BasinHeaterPowerFTempDiff, this->basinHeaterSched, this->BasinHeaterSetPointTemp, this->BasinHeaterPower); } this->PrintMessage = false; return; @@ -7413,7 +7392,7 @@ namespace PlantChillers { MyLoad = 0.0; if (this->CondenserType == DataPlant::CondenserType::EvapCooled) { CalcBasinHeaterPower( - state, this->BasinHeaterPowerFTempDiff, this->BasinHeaterSchedulePtr, this->BasinHeaterSetPointTemp, this->BasinHeaterPower); + state, this->BasinHeaterPowerFTempDiff, this->basinHeaterSched, this->BasinHeaterSetPointTemp, this->BasinHeaterPower); } this->PrintMessage = false; return; @@ -7501,7 +7480,7 @@ namespace PlantChillers { } if (this->QEvaporator == 0.0 && this->CondenserType == DataPlant::CondenserType::EvapCooled) { CalcBasinHeaterPower( - state, this->BasinHeaterPowerFTempDiff, this->BasinHeaterSchedulePtr, this->BasinHeaterSetPointTemp, this->BasinHeaterPower); + state, this->BasinHeaterPowerFTempDiff, this->basinHeaterSched, this->BasinHeaterSetPointTemp, this->BasinHeaterPower); } } // This is the end of the FlowLock Block diff --git a/src/EnergyPlus/PlantChillers.hh b/src/EnergyPlus/PlantChillers.hh index a67380b0711..9d6c40c1421 100644 --- a/src/EnergyPlus/PlantChillers.hh +++ b/src/EnergyPlus/PlantChillers.hh @@ -102,7 +102,7 @@ namespace PlantChillers { Real64 SizFac; // sizing factor Real64 BasinHeaterPowerFTempDiff; // Basin heater capacity per degree C below setpoint (W/C) Real64 BasinHeaterSetPointTemp; // Setpoint temperature for basin heater operation (C) - int BasinHeaterSchedulePtr; // Pointer to basin heater schedule + Sched::Schedule *basinHeaterSched = nullptr; // basin heater schedule int ErrCount1; // for recurring error messages int ErrCount2; // for recurring error messages std::string MsgBuffer1; // - buffer to print warning messages on following time step @@ -151,7 +151,7 @@ namespace PlantChillers { EvapInletNodeNum(0), EvapOutletNodeNum(0), CondInletNodeNum(0), CondOutletNodeNum(0), EvapVolFlowRate(0.0), EvapVolFlowRateWasAutoSized(false), EvapMassFlowRateMax(0.0), CondVolFlowRate(0.0), CondVolFlowRateWasAutoSized(false), CondMassFlowRateMax(0.0), CWPlantLoc{}, CDPlantLoc{}, SizFac(0.0), BasinHeaterPowerFTempDiff(0.0), BasinHeaterSetPointTemp(0.0), - BasinHeaterSchedulePtr(0), ErrCount1(0), ErrCount2(0), MsgDataLast(0.0), PrintMessage(false), MsgErrorCount(0), CheckEquipName(true), + ErrCount1(0), ErrCount2(0), MsgDataLast(0.0), PrintMessage(false), MsgErrorCount(0), CheckEquipName(true), PossibleSubcooling(false), CondMassFlowIndex(0), FaultyChillerSWTFlag(false), FaultyChillerSWTIndex(0), FaultyChillerSWTOffset(0.0), FaultyChillerFoulingFlag(false), FaultyChillerFoulingIndex(0), FaultyChillerFoulingFactor(1.0), MyFlag(true), MyEnvrnFlag(true), TimeStepSysLast(0.0), CurrentEndTimeLast(0.0), CondMassFlowRate(0.0), EvapMassFlowRate(0.0), CondOutletTemp(0.0), @@ -204,7 +204,7 @@ namespace PlantChillers { Real64 HeatRecCapacityFraction; // user input for heat recovery capacity fraction [] Real64 HeatRecMaxCapacityLimit; // Capacity limit for Heat recovery, one time calc [W] int HeatRecSetPointNodeNum; // index for system node with the heat recover leaving setpoint - int HeatRecInletLimitSchedNum; // index for schedule for the inlet high limit for heat recovery operation + Sched::Schedule *heatRecInletLimitSched = nullptr; // schedule for the inlet high limit for heat recovery operation PlantLocation HRPlantLoc; // heat recovery water plant loop component index std::string EndUseSubcategory; // identifier use for the end use subcategory Real64 CondOutletHumRat; // kg/kg - condenser outlet humditiy ratio, air side @@ -227,7 +227,7 @@ namespace PlantChillers { : CapRatCoef(3, 0.0), PowerRatCoef(3, 0.0), FullLoadCoef(3, 0.0), TempLowLimitEvapOut(0.0), DesignHeatRecVolFlowRate(0.0), DesignHeatRecVolFlowRateWasAutoSized(false), DesignHeatRecMassFlowRate(0.0), HeatRecActive(false), HeatRecInletNodeNum(0), HeatRecOutletNodeNum(0), HeatRecCapacityFraction(0.0), HeatRecMaxCapacityLimit(0.0), HeatRecSetPointNodeNum(0), - HeatRecInletLimitSchedNum(0), HRPlantLoc{}, CondOutletHumRat(0.0), ActualCOP(0.0), QHeatRecovery(0.0), EnergyHeatRecovery(0.0), + HRPlantLoc{}, CondOutletHumRat(0.0), ActualCOP(0.0), QHeatRecovery(0.0), EnergyHeatRecovery(0.0), HeatRecInletTemp(0.0), HeatRecMdot(0.0), ChillerCondAvgTemp(0.0) { } @@ -521,6 +521,10 @@ struct PlantChillersData : BaseGlobalStruct EPVector GTChiller; EPVector ConstCOPChiller; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/PlantComponentTemperatureSources.cc b/src/EnergyPlus/PlantComponentTemperatureSources.cc index 03089902c9f..bc1cc503677 100644 --- a/src/EnergyPlus/PlantComponentTemperatureSources.cc +++ b/src/EnergyPlus/PlantComponentTemperatureSources.cc @@ -150,7 +150,7 @@ namespace PlantComponentTemperatureSources { // OK, so we can set up the inlet and boundary temperatures now this->InletTemp = state.dataLoopNodes->Node(this->InletNodeNum).Temp; if (this->tempSpecType == TempSpecType::Schedule) { - this->BoundaryTemp = ScheduleManager::GetCurrentScheduleValue(state, this->TempSpecScheduleNum); + this->BoundaryTemp = this->tempSpecSched->getCurrentVal(); } // Calculate specific heat @@ -455,6 +455,8 @@ namespace PlantComponentTemperatureSources { // N2 , \field Boundary Temperature // A5 ; \field Source Temperature Schedule Name + static constexpr std::string_view routineName = "GetWaterSourceInput"; + // LOCAL VARIABLES: int NumAlphas; // Number of elements in the alpha array int NumNums; // Number of elements in the numeric array @@ -489,6 +491,9 @@ namespace PlantComponentTemperatureSources { state.dataIPShortCut->lAlphaFieldBlanks, state.dataIPShortCut->cAlphaFieldNames, state.dataIPShortCut->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1)}; + Util::IsNameEmpty(state, state.dataIPShortCut->cAlphaArgs(1), cCurrentModuleObject, ErrorsFound); state.dataPlantCompTempSrc->WaterSource(SourceNum).Name = state.dataIPShortCut->cAlphaArgs(1); @@ -530,15 +535,8 @@ namespace PlantComponentTemperatureSources { state.dataPlantCompTempSrc->WaterSource(SourceNum).BoundaryTemp = state.dataIPShortCut->rNumericArgs(2); } else if (state.dataIPShortCut->cAlphaArgs(4) == "SCHEDULED") { state.dataPlantCompTempSrc->WaterSource(SourceNum).tempSpecType = TempSpecType::Schedule; - state.dataPlantCompTempSrc->WaterSource(SourceNum).TempSpecScheduleName = state.dataIPShortCut->cAlphaArgs(5); - state.dataPlantCompTempSrc->WaterSource(SourceNum).TempSpecScheduleNum = - ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(5)); - if (state.dataPlantCompTempSrc->WaterSource(SourceNum).TempSpecScheduleNum == 0) { - ShowSevereError(state, format("Input error for {}={}", cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, - format("Invalid schedule name in field {}={}", - state.dataIPShortCut->cAlphaFieldNames(5), - state.dataIPShortCut->cAlphaArgs(5))); + if ((state.dataPlantCompTempSrc->WaterSource(SourceNum).tempSpecSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(5))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(5), state.dataIPShortCut->cAlphaArgs(5)); ErrorsFound = true; } } else { diff --git a/src/EnergyPlus/PlantComponentTemperatureSources.hh b/src/EnergyPlus/PlantComponentTemperatureSources.hh index 86ffcc20826..d6c4cfb4055 100644 --- a/src/EnergyPlus/PlantComponentTemperatureSources.hh +++ b/src/EnergyPlus/PlantComponentTemperatureSources.hh @@ -88,8 +88,7 @@ namespace PlantComponentTemperatureSources { Real64 EMSOverrideValueMassFlowRateMax; // value to use if EMS is overriding max mass flow Real64 MassFlowRate; TempSpecType tempSpecType; // temperature specification type - std::string TempSpecScheduleName; - int TempSpecScheduleNum; + Sched::Schedule *tempSpecSched = nullptr; Real64 BoundaryTemp; Real64 OutletTemp; // may be different if the flow is off Real64 InletTemp; @@ -106,7 +105,7 @@ namespace PlantComponentTemperatureSources { WaterSourceSpecs() : InletNodeNum(0), OutletNodeNum(0), DesVolFlowRate(0.0), DesVolFlowRateWasAutoSized(false), MassFlowRateMax(0.0), EMSOverrideOnMassFlowRateMax(false), EMSOverrideValueMassFlowRateMax(0.0), MassFlowRate(0.0), tempSpecType(TempSpecType::Invalid), - TempSpecScheduleNum(0), BoundaryTemp(0.0), OutletTemp(0.0), InletTemp(0.0), HeatRate(0.0), HeatEnergy(0.0), plantLoc{}, SizFac(0.0), + BoundaryTemp(0.0), OutletTemp(0.0), InletTemp(0.0), HeatRate(0.0), HeatEnergy(0.0), plantLoc{}, SizFac(0.0), CheckEquipName(true), MyFlag(true), MyEnvironFlag(true), IsThisSized(false) { } @@ -153,6 +152,10 @@ struct PlantCompTempSrcData : BaseGlobalStruct bool getWaterSourceInput = true; EPVector WaterSource; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/PlantCondLoopOperation.cc b/src/EnergyPlus/PlantCondLoopOperation.cc index 9e5efcff68e..33209dd0fab 100644 --- a/src/EnergyPlus/PlantCondLoopOperation.cc +++ b/src/EnergyPlus/PlantCondLoopOperation.cc @@ -334,11 +334,9 @@ void GetPlantOperationInput(EnergyPlusData &state, bool &GetInputOK) // PlantEquipmentOperationSchemes // CondenserEquipmentOperationSchemes - // Using/Aliasing - using ScheduleManager::GetScheduleIndex; - // SUBROUTINE PARAMETER DEFINITIONS: static constexpr std::string_view RoutineName("GetPlantOperationInput: "); // include trailing blank space + static constexpr std::string_view routineName = "GetPlantOperationInput"; // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int LoopNum; // Loop counter (Plant or Cond) @@ -403,6 +401,9 @@ void GetPlantOperationInput(EnergyPlusData &state, bool &GetInputOK) state.dataIPShortCut->lAlphaFieldBlanks, state.dataIPShortCut->cAlphaFieldNames, state.dataIPShortCut->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, CurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1)}; + state.dataPlnt->PlantLoop(LoopNum).NumOpSchemes = (NumAlphas - 1) / 3; if (state.dataPlnt->PlantLoop(LoopNum).NumOpSchemes > 0) { state.dataPlnt->PlantLoop(LoopNum).OpScheme.clear(); @@ -455,17 +456,9 @@ void GetPlantOperationInput(EnergyPlusData &state, bool &GetInputOK) } state.dataPlnt->PlantLoop(LoopNum).OpScheme(Num).Name = state.dataIPShortCut->cAlphaArgs(Num * 3); - state.dataPlnt->PlantLoop(LoopNum).OpScheme(Num).Sched = state.dataIPShortCut->cAlphaArgs(Num * 3 + 1); - state.dataPlnt->PlantLoop(LoopNum).OpScheme(Num).SchedPtr = - GetScheduleIndex(state, state.dataPlnt->PlantLoop(LoopNum).OpScheme(Num).Sched); - if (state.dataPlnt->PlantLoop(LoopNum).OpScheme(Num).SchedPtr == 0) { - ShowSevereError(state, - format("{}Invalid {} = \"{}\", entered in {}= \"{}\".", - RoutineName, - state.dataIPShortCut->cAlphaFieldNames(Num * 3 + 1), - state.dataIPShortCut->cAlphaArgs(Num * 3 + 1), - CurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1))); + + if ((state.dataPlnt->PlantLoop(LoopNum).OpScheme(Num).sched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(Num * 3 + 1))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(Num * 3 + 1), state.dataIPShortCut->cAlphaArgs(Num * 3 + 1)); ErrorsFound = true; } } @@ -1361,12 +1354,13 @@ void FindCompSPInput(EnergyPlusData &state, // PlantEquipmentOperation:ComponentSetPoint // PlantEquipmentOperation:ThermalEnergyStorage + static constexpr std::string_view routineName = "FindCompSPInput"; + // Using/Aliasing using namespace DataLoopNode; using NodeInputManager::GetOnlySingleNode; using namespace DataSizing; using EMSManager::CheckIfNodeSetPointManagedByEMS; - using ScheduleManager::GetScheduleIndex; using SetPointManager::SetUpNewScheduledTESSetPtMgr; // SUBROUTINE LOCAL VARIABLE DECLARATIONS: @@ -1393,8 +1387,15 @@ void FindCompSPInput(EnergyPlusData &state, int NumNums; int IOStat; for (int Num = 1; Num <= NumSchemes; ++Num) { - state.dataInputProcessing->inputProcessor->getObjectItem( - state, CurrentModuleObject, Num, state.dataIPShortCut->cAlphaArgs, NumAlphas, state.dataIPShortCut->rNumericArgs, NumNums, IOStat); + state.dataInputProcessing->inputProcessor->getObjectItem(state, + CurrentModuleObject, + Num, + state.dataIPShortCut->cAlphaArgs, + NumAlphas, + state.dataIPShortCut->rNumericArgs, + NumNums, + IOStat); + if (Util::SameString(state.dataPlnt->PlantLoop(LoopNum).OpScheme(SchemeNum).Name, state.dataIPShortCut->cAlphaArgs(1))) break; if (Num == NumSchemes) { ShowSevereError(state, @@ -1412,29 +1413,24 @@ void FindCompSPInput(EnergyPlusData &state, state.dataPlnt->PlantLoop(LoopNum).OpScheme(SchemeNum).NumEquipLists = 1; state.dataPlnt->PlantLoop(LoopNum).OpScheme(SchemeNum).EquipList.allocate(1); state.dataPlnt->PlantLoop(LoopNum).OpScheme(SchemeNum).EquipList(1).NumComps = (NumAlphas - 1) / 5; - int ChargeSchedPtr; - int OnPeakSchedPtr; + Sched::Schedule *chargeSched = nullptr; + Sched::Schedule *onPeakSched = nullptr; + + ErrorObjectHeader eoh{routineName, CurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1)}; + if (CurrentModuleObject == "PlantEquipmentOperation:ThermalEnergyStorage") { // Read all of the additional parameters for ice storage control scheme and error check various parameters - std::string OnPeakSchedName = state.dataIPShortCut->cAlphaArgs(2); - OnPeakSchedPtr = GetScheduleIndex(state, OnPeakSchedName); - if (OnPeakSchedPtr == 0) { - ShowSevereError(state, - format("Could not find On Peak Schedule {} in {}{}\".", - OnPeakSchedName, - CurrentModuleObject, - state.dataPlnt->PlantLoop(LoopNum).OpScheme(SchemeNum).Name)); + onPeakSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(2)); + if (onPeakSched == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(2), state.dataIPShortCut->cAlphaArgs(2)); ErrorsFound = true; } - std::string ChargeSchedName = state.dataIPShortCut->cAlphaArgs(3); - ChargeSchedPtr = GetScheduleIndex(state, ChargeSchedName); - if (ChargeSchedPtr == 0) { - ShowSevereError(state, - format("Could not find Charging Availability Schedule {} in {}{}\".", - ChargeSchedName, - CurrentModuleObject, - state.dataPlnt->PlantLoop(LoopNum).OpScheme(SchemeNum).Name)); + + + chargeSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(3)); + if (chargeSched == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(3), state.dataIPShortCut->cAlphaArgs(3)); ErrorsFound = true; } NonChargCHWTemp = state.dataIPShortCut->rNumericArgs(1); @@ -1568,8 +1564,8 @@ void FindCompSPInput(EnergyPlusData &state, // detailed input that is necessary to get thermal energy storage to work from the simpler input. SetUpNewScheduledTESSetPtMgr( state, - OnPeakSchedPtr, - ChargeSchedPtr, + onPeakSched, + chargeSched, NonChargCHWTemp, OffPeakCHWTemp, CompOpType, @@ -2527,8 +2523,6 @@ void InitLoadDistribution(EnergyPlusData &state, bool const FirstHVACIteration) // Using/Aliasing using EMSManager::ManageEMS; - using ScheduleManager::GetCurrentScheduleValue; - using ScheduleManager::GetScheduleIndex; // SUBROUTINE LOCAL VARIABLE DECLARATIONS: DataPlant::LoopSideLocation LoopSidePtr; @@ -2831,7 +2825,7 @@ void InitLoadDistribution(EnergyPlusData &state, bool const FirstHVACIteration) continue; } - if (GetCurrentScheduleValue(state, this_op_scheme.SchedPtr) > 0.0) { + if (this_op_scheme.sched->getCurrentVal() > 0.0) { this_op_scheme.Available = true; for (int ListNum = 1, ListNum_end = this_op_scheme.NumEquipLists; ListNum <= ListNum_end; ++ListNum) { auto &this_equip_list = this_op_scheme.EquipList(ListNum); diff --git a/src/EnergyPlus/PlantCondLoopOperation.hh b/src/EnergyPlus/PlantCondLoopOperation.hh index 6061012b1b8..e1306e7bc39 100644 --- a/src/EnergyPlus/PlantCondLoopOperation.hh +++ b/src/EnergyPlus/PlantCondLoopOperation.hh @@ -185,6 +185,10 @@ struct PlantCondLoopOperationData : BaseGlobalStruct bool LoadSupervisoryChillerHeaterOpScheme = true; Array1D ChillerHeaterSupervisoryOperationSchemes; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/PlantHeatExchangerFluidToFluid.cc b/src/EnergyPlus/PlantHeatExchangerFluidToFluid.cc index 31d1dbb94b8..5af25287b9f 100644 --- a/src/EnergyPlus/PlantHeatExchangerFluidToFluid.cc +++ b/src/EnergyPlus/PlantHeatExchangerFluidToFluid.cc @@ -175,6 +175,7 @@ void GetFluidHeatExchangerInput(EnergyPlusData &state) // get input for heat exchanger model static constexpr std::string_view RoutineName("GetFluidHeatExchangerInput: "); + static constexpr std::string_view routineName = "GetFluidHeatExchangerInput"; bool ErrorsFound(false); int NumAlphas; // Number of elements in the alpha array @@ -222,20 +223,18 @@ void GetFluidHeatExchangerInput(EnergyPlusData &state) lAlphaFieldBlanks, cAlphaFieldNames, cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, cCurrentModuleObject, cAlphaArgs(1)}; + Util::IsNameEmpty(state, cAlphaArgs(1), cCurrentModuleObject, ErrorsFound); state.dataPlantHXFluidToFluid->FluidHX(CompLoop).Name = cAlphaArgs(1); if (lAlphaFieldBlanks(2)) { - state.dataPlantHXFluidToFluid->FluidHX(CompLoop).AvailSchedNum = ScheduleManager::ScheduleAlwaysOn; - } else { - state.dataPlantHXFluidToFluid->FluidHX(CompLoop).AvailSchedNum = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(2)); - if (state.dataPlantHXFluidToFluid->FluidHX(CompLoop).AvailSchedNum <= 0) { - ShowSevereError(state, format("{}{}=\"{}\", invalid entry.", RoutineName, cCurrentModuleObject, cAlphaArgs(1))); - ShowContinueError(state, format("Invalid {} = {}", cAlphaFieldNames(2), cAlphaArgs(2))); - ShowContinueError(state, "Schedule was not found "); - ErrorsFound = true; - } + state.dataPlantHXFluidToFluid->FluidHX(CompLoop).availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((state.dataPlantHXFluidToFluid->FluidHX(CompLoop).availSched = Sched::GetSchedule(state, cAlphaArgs(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(2), cAlphaArgs(2)); + ErrorsFound = true; } state.dataPlantHXFluidToFluid->FluidHX(CompLoop).DemandSideLoop.inletNodeNum = @@ -946,7 +945,7 @@ void HeatExchangerStruct::control(EnergyPlusData &state, Real64 MyLoad, bool Fir // check if available by schedule bool ScheduledOff; - Real64 AvailSchedValue = ScheduleManager::GetCurrentScheduleValue(state, this->AvailSchedNum); + Real64 AvailSchedValue = this->availSched->getCurrentVal(); if (AvailSchedValue <= 0) { ScheduledOff = true; } else { diff --git a/src/EnergyPlus/PlantHeatExchangerFluidToFluid.hh b/src/EnergyPlus/PlantHeatExchangerFluidToFluid.hh index bc9099c2b64..4549cd60ef3 100644 --- a/src/EnergyPlus/PlantHeatExchangerFluidToFluid.hh +++ b/src/EnergyPlus/PlantHeatExchangerFluidToFluid.hh @@ -154,7 +154,7 @@ namespace PlantHeatExchangerFluidToFluid { { // Members std::string Name; - int AvailSchedNum; + Sched::Schedule *availSched = nullptr; FluidHXType HeatExchangeModelType; Real64 UA; bool UAWasAutoSized; // true is UA was autosized on input @@ -186,7 +186,7 @@ namespace PlantHeatExchangerFluidToFluid { // Default Constructor HeatExchangerStruct() - : AvailSchedNum(0), HeatExchangeModelType(FluidHXType::Invalid), UA(0.0), UAWasAutoSized(false), controlMode(ControlType::Invalid), + : HeatExchangeModelType(FluidHXType::Invalid), UA(0.0), UAWasAutoSized(false), controlMode(ControlType::Invalid), SetPointNodeNum(0), TempControlTol(0.0), ControlSignalTemp(CtrlTempType::Invalid), MinOperationTemp(-99999.0), MaxOperationTemp(99999.0), ComponentType(DataPlant::PlantEquipmentType::Invalid), SizingFactor(1.0), HeatTransferRate(0.0), HeatTransferEnergy(0.0), Effectiveness(0.0), OperationStatus(0.0), DmdSideModulatSolvNoConvergeErrorCount(0), @@ -234,6 +234,10 @@ struct PlantHeatExchangerFluidToFluidData : BaseGlobalStruct bool GetInput = true; EPVector FluidHX; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/PlantLoadProfile.cc b/src/EnergyPlus/PlantLoadProfile.cc index fa976ca3efe..bb3e92821a1 100644 --- a/src/EnergyPlus/PlantLoadProfile.cc +++ b/src/EnergyPlus/PlantLoadProfile.cc @@ -251,7 +251,7 @@ void PlantProfileData::InitPlantProfile(EnergyPlusData &state) RoutineName); } - Real64 MaxFlowMultiplier = ScheduleManager::GetScheduleMaxValue(state, this->FlowRateFracSchedule); + Real64 MaxFlowMultiplier = this->flowRateFracSched->getMaxVal(state); PlantUtilities::InitComponentNodes( state, 0.0, this->PeakVolFlowRate * FluidDensityInit * MaxFlowMultiplier, this->InletNode, this->OutletNode); @@ -266,7 +266,7 @@ void PlantProfileData::InitPlantProfile(EnergyPlusData &state) if (!state.dataGlobal->BeginEnvrnFlag) this->Init = true; this->InletTemp = state.dataLoopNodes->Node(InletNode).Temp; - this->Power = ScheduleManager::GetCurrentScheduleValue(state, this->LoadSchedule); + this->Power = this->loadSched->getCurrentVal(); if (this->EMSOverridePower) this->Power = this->EMSPowerValue; @@ -286,7 +286,7 @@ void PlantProfileData::InitPlantProfile(EnergyPlusData &state) } // Get the scheduled mass flow rate - this->VolFlowRate = this->PeakVolFlowRate * ScheduleManager::GetCurrentScheduleValue(state, this->FlowRateFracSchedule); + this->VolFlowRate = this->PeakVolFlowRate * this->flowRateFracSched->getCurrentVal(); this->MassFlowRate = this->VolFlowRate * FluidDensityInit; @@ -375,6 +375,8 @@ void GetPlantProfileInput(EnergyPlusData &state) // PURPOSE OF THIS SUBROUTINE: // Gets the plant load profile input from the input file and sets up the objects. + static constexpr std::string_view routineName = "GetPlantProfileInput"; + // Using/Aliasing using namespace DataLoopNode; @@ -405,6 +407,9 @@ void GetPlantProfileInput(EnergyPlusData &state) _, state.dataIPShortCut->cAlphaFieldNames, state.dataIPShortCut->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1)}; + Util::IsNameEmpty(state, state.dataIPShortCut->cAlphaArgs(1), cCurrentModuleObject, ErrorsFound); state.dataPlantLoadProfile->PlantProfile(ProfileNum).Name = state.dataIPShortCut->cAlphaArgs(1); @@ -461,32 +466,17 @@ void GetPlantProfileInput(EnergyPlusData &state) ObjectIsNotParent); } - state.dataPlantLoadProfile->PlantProfile(ProfileNum).LoadSchedule = - ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(4)); - if (state.dataPlantLoadProfile->PlantProfile(ProfileNum).LoadSchedule == 0) { - ShowSevereError(state, - format("{}=\"{}\" The Schedule for {} called {} was not found.", - cCurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaFieldNames(4), - state.dataIPShortCut->cAlphaArgs(4))); + if ((state.dataPlantLoadProfile->PlantProfile(ProfileNum).loadSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(4))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(4), state.dataIPShortCut->cAlphaArgs(4)); ErrorsFound = true; } state.dataPlantLoadProfile->PlantProfile(ProfileNum).PeakVolFlowRate = state.dataIPShortCut->rNumericArgs(1); - state.dataPlantLoadProfile->PlantProfile(ProfileNum).FlowRateFracSchedule = - ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(5)); - - if (state.dataPlantLoadProfile->PlantProfile(ProfileNum).FlowRateFracSchedule == 0) { - ShowSevereError(state, - format("{}=\"{}\" The Schedule for {} called {} was not found.", - cCurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaFieldNames(5), - state.dataIPShortCut->cAlphaArgs(5))); + if ((state.dataPlantLoadProfile->PlantProfile(ProfileNum).flowRateFracSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(5))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(5), state.dataIPShortCut->cAlphaArgs(5)); ErrorsFound = true; } diff --git a/src/EnergyPlus/PlantLoadProfile.hh b/src/EnergyPlus/PlantLoadProfile.hh index cf37e9d0064..a6a0521211f 100644 --- a/src/EnergyPlus/PlantLoadProfile.hh +++ b/src/EnergyPlus/PlantLoadProfile.hh @@ -88,11 +88,11 @@ namespace PlantLoadProfile { Real64 InletTemp; // Inlet temperature (C) int OutletNode; Real64 OutletTemp; // Outlet temperature (C) - int LoadSchedule; // Pointer to schedule object + Sched::Schedule *loadSched = nullptr; // load schedule bool EMSOverridePower; // if true, then EMS is calling to override power level Real64 EMSPowerValue; // value EMS is directing to use for power [W] Real64 PeakVolFlowRate; // Peak volumetric flow rate, also water consumption rate (m3/s) - int FlowRateFracSchedule; // Pointer to schedule object + Sched::Schedule *flowRateFracSched = nullptr; // flow rate fraction schedule Real64 VolFlowRate; // Volumetric flow rate (m3/s) Real64 MassFlowRate; // Mass flow rate (kg/s) Real64 DegOfSubcooling = 0.0; // Degree of subcooling in steam outlet @@ -108,7 +108,7 @@ namespace PlantLoadProfile { // Default Constructor PlantProfileData() : Type(DataPlant::PlantEquipmentType::Invalid), plantLoc{}, Init(true), InitSizing(true), InletNode(0), InletTemp(0.0), OutletNode(0), - OutletTemp(0.0), LoadSchedule(0), EMSOverridePower(false), EMSPowerValue(0.0), PeakVolFlowRate(0.0), FlowRateFracSchedule(0), + OutletTemp(0.0), EMSOverridePower(false), EMSPowerValue(0.0), PeakVolFlowRate(0.0), VolFlowRate(0.0), MassFlowRate(0.0), EMSOverrideMassFlow(false), EMSMassFlowValue(0.0), Power(0.0), Energy(0.0), HeatingEnergy(0.0), CoolingEnergy(0.0) { @@ -150,6 +150,10 @@ struct PlantLoadProfileData : BaseGlobalStruct int NumOfPlantProfile = 0; Array1D PlantProfile; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/PlantLoopHeatPumpEIR.cc b/src/EnergyPlus/PlantLoopHeatPumpEIR.cc index b7bce4dd37f..44ea3392666 100644 --- a/src/EnergyPlus/PlantLoopHeatPumpEIR.cc +++ b/src/EnergyPlus/PlantLoopHeatPumpEIR.cc @@ -541,7 +541,7 @@ Real64 EIRPlantLoopHeatPump::heatingCapacityModifierASHP(EnergyPlusData &state) } } -void EIRPlantLoopHeatPump::setPartLoadAndCyclingRatio(EnergyPlusData &state, Real64 &partLoadRatio) +void EIRPlantLoopHeatPump::setPartLoadAndCyclingRatio([[maybe_unused ]] EnergyPlusData &state, Real64 &partLoadRatio) { // Initialize cycling ratio to 1.0 Real64 cyclingRatio = 1.0; @@ -713,7 +713,7 @@ void EIRPlantLoopHeatPump::calcHeatRecoveryHeatTransferASHP(EnergyPlusData &stat } } -void EIRPlantLoopHeatPump::setHeatRecoveryOperatingStatusASHP(EnergyPlusData &state, bool FirstHVACIteration) +void EIRPlantLoopHeatPump::setHeatRecoveryOperatingStatusASHP([[maybe_unused]] EnergyPlusData &state, [[maybe_unused]] bool FirstHVACIteration) { if (!this->running) { if (this->heatRecoveryAvailable) { diff --git a/src/EnergyPlus/PlantLoopHeatPumpEIR.hh b/src/EnergyPlus/PlantLoopHeatPumpEIR.hh index 6995689dec3..3ab29ef0a7e 100644 --- a/src/EnergyPlus/PlantLoopHeatPumpEIR.hh +++ b/src/EnergyPlus/PlantLoopHeatPumpEIR.hh @@ -430,6 +430,10 @@ struct EIRPlantLoopHeatPumpsData : BaseGlobalStruct std::vector heatPumps; bool getInputsPLHP = true; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } @@ -445,6 +449,10 @@ struct EIRFuelFiredHeatPumpsData : BaseGlobalStruct std::vector heatPumps; bool getInputsFFHP = true; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/PlantPipingSystemsManager.cc b/src/EnergyPlus/PlantPipingSystemsManager.cc index b52c9540d17..7c9844cfd32 100644 --- a/src/EnergyPlus/PlantPipingSystemsManager.cc +++ b/src/EnergyPlus/PlantPipingSystemsManager.cc @@ -206,11 +206,11 @@ namespace PlantPipingSystemsManager { // The time init should be done here before we DoOneTimeInits because the DoOneTimeInits // includes a ground temperature initialization, which is based on the Cur%CurSimTimeSeconds variable // which would be carried over from the previous environment - thisDomain.Cur.CurSimTimeStepSize = state.dataGlobal->TimeStepZone * Constant::SecInHour; + thisDomain.Cur.CurSimTimeStepSize = state.dataGlobal->TimeStepZone * Constant::rSecsInHour; thisDomain.Cur.CurSimTimeSeconds = - ((state.dataGlobal->DayOfSim - 1) * 24 + (state.dataGlobal->HourOfDay - 1) + + ((state.dataGlobal->DayOfSim - 1) * Constant::iHoursInDay + (state.dataGlobal->HourOfDay - 1) + (state.dataGlobal->TimeStep - 1) * state.dataGlobal->TimeStepZone + state.dataHVACGlobal->SysTimeElapsed) * - Constant::SecInHour; + Constant::rSecsInHour; // There are also some inits that are "close to one time" inits...( one-time in standalone, each envrn in E+ ) if ((state.dataGlobal->BeginSimFlag && thisDomain.BeginSimInit) || (state.dataGlobal->BeginEnvrnFlag && thisDomain.BeginSimEnvironment)) { @@ -4346,13 +4346,13 @@ namespace PlantPipingSystemsManager { Latitude_Radians = Constant::Pi / 180.0 * Latitude_Degrees; // The day of year at this point in the simulation - DayOfYear = int(this->Cur.CurSimTimeSeconds / Constant::SecsInDay); + DayOfYear = int(this->Cur.CurSimTimeSeconds / Constant::rSecsInDay); // The number of seconds into the current day - CurSecondsIntoToday = int(mod(this->Cur.CurSimTimeSeconds, Constant::SecsInDay)); + CurSecondsIntoToday = int(mod(this->Cur.CurSimTimeSeconds, Constant::rSecsInDay)); // The number of hours into today - HourOfDay = int(CurSecondsIntoToday / Constant::SecInHour); + HourOfDay = int(CurSecondsIntoToday / Constant::rSecsInHour); // For convenience convert to Kelvin once CurAirTempK = this->Cur.CurAirTemp + 273.15; diff --git a/src/EnergyPlus/PlantPipingSystemsManager.hh b/src/EnergyPlus/PlantPipingSystemsManager.hh index 2fe66bd9068..d59e58ccb38 100644 --- a/src/EnergyPlus/PlantPipingSystemsManager.hh +++ b/src/EnergyPlus/PlantPipingSystemsManager.hh @@ -1082,6 +1082,10 @@ struct PlantPipingSysMgrData : BaseGlobalStruct std::vector segments; std::unordered_map GroundDomainUniqueNames; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/PlantPressureSystem.hh b/src/EnergyPlus/PlantPressureSystem.hh index 7c490d773c7..98819aa5180 100644 --- a/src/EnergyPlus/PlantPressureSystem.hh +++ b/src/EnergyPlus/PlantPressureSystem.hh @@ -124,6 +124,10 @@ struct PlantPressureSysData : BaseGlobalStruct int ZeroKWarningCounter = 0; int MaxIterWarningCounter = 0; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/PlantUtilities.hh b/src/EnergyPlus/PlantUtilities.hh index 309cea0b34d..6b2b9824dec 100644 --- a/src/EnergyPlus/PlantUtilities.hh +++ b/src/EnergyPlus/PlantUtilities.hh @@ -231,6 +231,10 @@ struct PlantUtilitiesData : BaseGlobalStruct Array1D CriteriaChecks; // stores criteria information + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/PlantValves.hh b/src/EnergyPlus/PlantValves.hh index bce6571a534..26ed76d4df7 100644 --- a/src/EnergyPlus/PlantValves.hh +++ b/src/EnergyPlus/PlantValves.hh @@ -121,6 +121,10 @@ struct PlantValvesData : BaseGlobalStruct int NumTemperingValves = 0; EPVector TemperValve; // dimension to No. of TemperingValve objects + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/PluginManager.cc b/src/EnergyPlus/PluginManager.cc index ba34e2740f5..7de1ae14bf8 100644 --- a/src/EnergyPlus/PluginManager.cc +++ b/src/EnergyPlus/PluginManager.cc @@ -168,7 +168,7 @@ std::string pythonStringForUsage([[maybe_unused]] const EnergyPlusData &state) } #endif -void PluginManager::setupOutputVariables(EnergyPlusData &state) +void PluginManager::setupOutputVariables([[maybe_unused]] EnergyPlusData &state) { #if LINK_WITH_PYTHON // with the PythonPlugin:Variables all set in memory, we can now set them up as outputs as needed diff --git a/src/EnergyPlus/PluginManager.hh b/src/EnergyPlus/PluginManager.hh index 4f20bf54afc..18d3f742e61 100644 --- a/src/EnergyPlus/PluginManager.hh +++ b/src/EnergyPlus/PluginManager.hh @@ -252,6 +252,10 @@ struct PluginManagerData : BaseGlobalStruct bool eplusRunningViaPythonAPI = false; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/PollutionModule.cc b/src/EnergyPlus/PollutionModule.cc index a05573c2b94..136a766245d 100644 --- a/src/EnergyPlus/PollutionModule.cc +++ b/src/EnergyPlus/PollutionModule.cc @@ -138,9 +138,6 @@ void SetupPollutionCalculations(EnergyPlusData &state) // METHODOLOGY EMPLOYED: // Uses the status flags to trigger events. - // Using/Aliasing - using ScheduleManager::GetScheduleIndex; - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int NumPolluteRpt; int NumAlphas; @@ -304,41 +301,24 @@ void GetPollutionFactorInput(EnergyPlusData &state) pollCoeff.used = true; pollCoeff.sourceCoeff = ipsc->rNumericArgs(1); - if (!ipsc->lAlphaFieldBlanks(2)) { - pollCoeff.sourceSchedNum = ScheduleManager::GetScheduleIndex(state, ipsc->cAlphaArgs(2)); - if (pollCoeff.sourceSchedNum == 0) { - ShowSevereItemNotFound(state, eoh, ipsc->cAlphaFieldNames(2), ipsc->cAlphaArgs(2)); - ErrorsFound = true; - } else if (!ScheduleManager::CheckScheduleValueMinMax(state, pollCoeff.sourceSchedNum, true, 0.0)) { - ShowSevereError(state, - format("{}: {}, invalid {}=\"{}\" invalid values.", - ipsc->cCurrentModuleObject, - Constant::eFuelNames[(int)fuel], - ipsc->cAlphaFieldNames(2), - ipsc->cAlphaArgs(2))); - ShowContinueError(state, "Schedule values must be (>=0.)."); - ErrorsFound = true; - } + if (ipsc->lAlphaFieldBlanks(2)) { + } else if ((pollCoeff.sourceSched = Sched::GetSchedule(state, ipsc->cAlphaArgs(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, ipsc->cAlphaFieldNames(2), ipsc->cAlphaArgs(2)); + ErrorsFound = true; + } else if (!pollCoeff.sourceSched->checkMinVal(state, Clusive::In, 0.0)) { + Sched::ShowSevereBadMin(state, eoh, ipsc->cAlphaFieldNames(2), ipsc->cAlphaArgs(2), Clusive::In, 0.0); + ErrorsFound = true; } for (int iPollutant = 0; iPollutant < (int)Pollutant::Num; ++iPollutant) { pollCoeff.pollutantCoeffs[iPollutant] = ipsc->rNumericArgs(iPollutant + 2); - if (!ipsc->lAlphaFieldBlanks(iPollutant + 3)) { - - pollCoeff.pollutantSchedNums[iPollutant] = ScheduleManager::GetScheduleIndex(state, ipsc->cAlphaArgs(iPollutant + 3)); - if (pollCoeff.pollutantSchedNums[iPollutant] == 0) { - ShowSevereItemNotFound(state, eoh, ipsc->cAlphaFieldNames(iPollutant + 3), ipsc->cAlphaArgs(iPollutant + 3)); - ErrorsFound = true; - } else if (!ScheduleManager::CheckScheduleValueMinMax(state, pollCoeff.pollutantSchedNums[iPollutant], true, 0.0)) { - ShowSevereError(state, - format("{}: {}, invalid {}=\"{}\" invalid values.", - ipsc->cCurrentModuleObject, - Constant::eFuelNames[(int)fuel], - ipsc->cAlphaFieldNames(iPollutant + 3), - ipsc->cAlphaArgs(iPollutant + 3))); - ShowContinueError(state, "Schedule values must be (>=0.)."); - ErrorsFound = true; - } + if (ipsc->lAlphaFieldBlanks(iPollutant + 3)) { + } else if ((pollCoeff.pollutantScheds[iPollutant] = Sched::GetSchedule(state, ipsc->cAlphaArgs(iPollutant + 3))) == nullptr) { + ShowSevereItemNotFound(state, eoh, ipsc->cAlphaFieldNames(iPollutant + 3), ipsc->cAlphaArgs(iPollutant + 3)); + ErrorsFound = true; + } else if (!pollCoeff.pollutantScheds[iPollutant]->checkMinVal(state, Clusive::In, 0.0)) { + Sched::ShowSevereBadMin(state, eoh, ipsc->cAlphaFieldNames(iPollutant + 3), ipsc->cAlphaArgs(iPollutant + 3), Clusive::In, 0.0); + ErrorsFound = true; } } // for (iPollutant) @@ -612,8 +592,8 @@ void CalcPollution(EnergyPlusData &state) // Why are these two the exceptions? if (iPoll != (int)Pollutant::Water && iPoll != (int)Pollutant::NuclearLow) pollutantVal *= 0.001; - if (pollCoeff.pollutantSchedNums[iPoll] != 0) { - pollutantVal *= ScheduleManager::GetCurrentScheduleValue(state, pollCoeff.pollutantSchedNums[iPoll]); + if (pollCoeff.pollutantScheds[iPoll] != nullptr) { + pollutantVal *= pollCoeff.pollutantScheds[iPoll]->getCurrentVal(); } pollComp.pollutantVals[iPoll] = pm->facilityMeterFuelComponentVals[(int)pollFuelComp] * 1.0e-6 * pollutantVal; } @@ -636,8 +616,8 @@ void CalcPollution(EnergyPlusData &state) pollCompElecSurplusSold.sourceVal = pm->facilityMeterFuelComponentVals[(int)PollFuelComponent::ElectricitySurplusSold] * pollCoeffElec.sourceCoeff; - if (pollCoeffElec.sourceSchedNum != 0) { - Real64 pollCoeffElecSchedVal = ScheduleManager::GetCurrentScheduleValue(state, pollCoeffElec.sourceSchedNum); + if (pollCoeffElec.sourceSched != nullptr) { + Real64 pollCoeffElecSchedVal = pollCoeffElec.sourceSched->getCurrentVal(); pollCompElec.sourceVal *= pollCoeffElecSchedVal; pollCompElecPurchased.sourceVal *= pollCoeffElecSchedVal; pollCompElecSurplusSold.sourceVal *= pollCoeffElecSchedVal; @@ -647,8 +627,8 @@ void CalcPollution(EnergyPlusData &state) auto const &pollCoeffGas = pm->pollCoeffs[(int)PollFuel::NaturalGas]; auto &pollCompGas = pm->pollComps[(int)PollFuelComponent::NaturalGas]; pollCompGas.sourceVal = pm->facilityMeterVals[(int)PollFacilityMeter::NaturalGas] * pollCoeffGas.sourceCoeff; - if (pollCoeffGas.sourceSchedNum != 0) { - pollCompGas.sourceVal *= ScheduleManager::GetCurrentScheduleValue(state, pollCoeffGas.sourceSchedNum); + if (pollCoeffGas.sourceSched != nullptr) { + pollCompGas.sourceVal *= pollCoeffGas.sourceSched->getCurrentVal(); } for (PollFuel pollFuel : {PollFuel::FuelOil1, @@ -664,8 +644,8 @@ void CalcPollution(EnergyPlusData &state) auto &pollComp = pm->pollComps[(int)pollFuelComponent]; pollComp.sourceVal = pm->facilityMeterFuelComponentVals[(int)pollFuelComponent] * pollCoeff.sourceCoeff; - if (pollCoeff.sourceSchedNum != 0) { - pollComp.sourceVal *= ScheduleManager::GetCurrentScheduleValue(state, pollCoeff.sourceSchedNum); + if (pollCoeff.sourceSched != nullptr) { + pollComp.sourceVal *= pollCoeff.sourceSched->getCurrentVal(); } } // for (pollFuelComponent) } // CalcPollution() @@ -735,7 +715,7 @@ void GetFuelFactorInfo(EnergyPlusData &state, bool &fuelFactorUsed, // return value true if user has entered this fuel Real64 &fuelSourceFactor, // if used, the source factor bool &fuelFactorScheduleUsed, // if true, schedules for this fuel are used - int &ffScheduleIndex // if schedules for this fuel are used, return schedule index + Sched::Schedule **ffSched // if schedules for this fuel are used, return schedule index ) { @@ -756,7 +736,7 @@ void GetFuelFactorInfo(EnergyPlusData &state, fuelFactorUsed = false; fuelSourceFactor = 0.0; fuelFactorScheduleUsed = false; - ffScheduleIndex = 0; + *ffSched = nullptr; PollFuel pollFuel = fuel2pollFuel[(int)fuel]; auto const &pollCoeff = pm->pollCoeffs[(int)pollFuel]; @@ -764,11 +744,11 @@ void GetFuelFactorInfo(EnergyPlusData &state, if (pollCoeff.used) { fuelFactorUsed = true; fuelSourceFactor = pollCoeff.sourceCoeff; - if (pollCoeff.sourceSchedNum == 0) { + if (pollCoeff.sourceSched == nullptr) { fuelFactorScheduleUsed = false; } else { fuelFactorScheduleUsed = true; - ffScheduleIndex = pollCoeff.sourceSchedNum; + *ffSched = pollCoeff.sourceSched; } } else { fuelSourceFactor = pollFuelFactors[(int)pollFuel]; diff --git a/src/EnergyPlus/PollutionModule.hh b/src/EnergyPlus/PollutionModule.hh index 9f63d86c6ed..30f10f1edb3 100644 --- a/src/EnergyPlus/PollutionModule.hh +++ b/src/EnergyPlus/PollutionModule.hh @@ -320,8 +320,8 @@ namespace Pollution { bool used = false; Real64 sourceCoeff = 0.0; std::array pollutantCoeffs = {0.0}; - int sourceSchedNum = 0; - std::array pollutantSchedNums = {0}; + Sched::Schedule *sourceSched = nullptr; + std::array pollutantScheds = {0}; }; void CalculatePollution(EnergyPlusData &state); @@ -343,7 +343,7 @@ namespace Pollution { bool &fuelFactorUsed, // return value true if user has entered this fuel Real64 &fuelSourceFactor, // if used, the source factor bool &fuelFactorScheduleUsed, // if true, schedules for this fuel are used - int &ffScheduleIndex // if schedules for this fuel are used, return schedule index + Sched::Schedule **ffSched // if schedules for this fuel are used, return schedule pointer (need pointer to pointer to do this) ); void GetEnvironmentalImpactFactorInfo(EnergyPlusData &state, @@ -387,6 +387,10 @@ struct PollutionData : BaseGlobalStruct Real64 PurchCoolCOP = 0.0; Real64 SteamConvEffic = 0.0; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/PondGroundHeatExchanger.cc b/src/EnergyPlus/PondGroundHeatExchanger.cc index 2c760a70f8f..0288ae516a7 100644 --- a/src/EnergyPlus/PondGroundHeatExchanger.cc +++ b/src/EnergyPlus/PondGroundHeatExchanger.cc @@ -478,17 +478,17 @@ void PondGroundHeatExchangerData::CalcPondGroundHeatExchanger(EnergyPlusData &st Real64 Flux = this->CalcTotalFLux(state, this->PondTemp); Real64 PondTempStar = - this->PastBulkTemperature + 0.5 * Constant::SecInHour * state.dataHVACGlobal->TimeStepSys * Flux / (SpecificHeat * PondMass); + this->PastBulkTemperature + 0.5 * Constant::rSecsInHour * state.dataHVACGlobal->TimeStepSys * Flux / (SpecificHeat * PondMass); Real64 FluxStar = this->CalcTotalFLux(state, PondTempStar); Real64 PondTempStarStar = - this->PastBulkTemperature + 0.5 * Constant::SecInHour * state.dataHVACGlobal->TimeStepSys * FluxStar / (SpecificHeat * PondMass); + this->PastBulkTemperature + 0.5 * Constant::rSecsInHour * state.dataHVACGlobal->TimeStepSys * FluxStar / (SpecificHeat * PondMass); Real64 FluxStarStar = this->CalcTotalFLux(state, PondTempStarStar); Real64 PondTempStarStarStar = - this->PastBulkTemperature + Constant::SecInHour * state.dataHVACGlobal->TimeStepSys * FluxStarStar / (SpecificHeat * PondMass); + this->PastBulkTemperature + Constant::rSecsInHour * state.dataHVACGlobal->TimeStepSys * FluxStarStar / (SpecificHeat * PondMass); - this->PondTemp = this->PastBulkTemperature + Constant::SecInHour * state.dataHVACGlobal->TimeStepSys * + this->PondTemp = this->PastBulkTemperature + Constant::rSecsInHour * state.dataHVACGlobal->TimeStepSys * (Flux + 2.0 * FluxStar + 2.0 * FluxStarStar + this->CalcTotalFLux(state, PondTempStarStarStar)) / (6.0 * SpecificHeat * PondMass); } @@ -813,7 +813,7 @@ Real64 PondGroundHeatExchangerData::CalcEffectiveness(EnergyPlusData &state, _, "[C]", "[C]"); - if (this->ConsecutiveFrozen >= state.dataGlobal->NumOfTimeStepInHour * 30) { + if (this->ConsecutiveFrozen >= state.dataGlobal->TimeStepsInHour * 30) { ShowFatalError(state, format("GroundHeatExchanger:Pond=\"{}\" has been frozen for 30 consecutive hours. Program terminates.", this->Name)); } diff --git a/src/EnergyPlus/PondGroundHeatExchanger.hh b/src/EnergyPlus/PondGroundHeatExchanger.hh index c58af1868da..d31d7007332 100644 --- a/src/EnergyPlus/PondGroundHeatExchanger.hh +++ b/src/EnergyPlus/PondGroundHeatExchanger.hh @@ -159,6 +159,10 @@ struct PondGroundHeatExchangerData : BaseGlobalStruct int NumOfPondGHEs = 0; Array1D PondGHE; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/PoweredInductionUnits.cc b/src/EnergyPlus/PoweredInductionUnits.cc index 07523f92033..18326889d80 100644 --- a/src/EnergyPlus/PoweredInductionUnits.cc +++ b/src/EnergyPlus/PoweredInductionUnits.cc @@ -112,7 +112,6 @@ using HVAC::SmallAirVolFlow; using HVAC::SmallLoad; using HVAC::SmallMassFlow; using HVAC::SmallTempDiff; -using namespace ScheduleManager; using Psychrometrics::PsyCpAirFnW; using Psychrometrics::PsyHFnTdbW; using SteamCoils::SimulateSteamCoilComponents; @@ -275,6 +274,8 @@ void GetPIUs(EnergyPlusData &state) ++PIUNum; auto const &fields = instance.value(); + ErrorObjectHeader eoh{routineName, cCurrentModuleObject, instance.key()}; + GlobalNames::VerifyUniqueInterObjectName( state, state.dataPowerInductionUnits->PiuUniqueNames, Util::makeUPPER(instance.key()), cCurrentModuleObject, "Name", ErrorsFound); auto &thisPIU = state.dataPowerInductionUnits->PIU(PIUNum); @@ -286,19 +287,15 @@ void GetPIUs(EnergyPlusData &state) } else if (cCurrentModuleObject == "AirTerminal:SingleDuct:ParallelPIU:Reheat") { thisPIU.UnitType_Num = DataDefineEquip::ZnAirLoopEquipType::SingleDuct_ParallelPIU_Reheat; } - thisPIU.Sched = ip->getAlphaFieldValue(fields, objectSchemaProps, "availability_schedule_name"); - if (!thisPIU.Sched.empty()) { - thisPIU.SchedPtr = ScheduleManager::GetScheduleIndex(state, thisPIU.Sched); - if (thisPIU.SchedPtr == 0) { - ShowWarningError( - state, - format("GetPIUs {}=\"{}\", invalid Availability Schedule Name = {}", cCurrentModuleObject, thisPIU.Name, thisPIU.Sched)); - ShowContinueError(state, "Set the default as Always On. Simulation continues."); - thisPIU.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } - } else { - thisPIU.SchedPtr = ScheduleManager::ScheduleAlwaysOn; + + std::string schedName = ip->getAlphaFieldValue(fields, objectSchemaProps, "availability_schedule_name"); + if (schedName.empty()) { + thisPIU.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((thisPIU.availSched = Sched::GetSchedule(state, Util::makeUPPER(schedName))) == nullptr) { + ShowWarningItemNotFound(state, eoh, "Availability Schedule Name", schedName, "Set the default as Always On. Simulation continues."); + thisPIU.availSched = Sched::GetScheduleAlwaysOn(state); } + if (cCurrentModuleObject == "AirTerminal:SingleDuct:SeriesPIU:Reheat") { thisPIU.MaxTotAirVolFlow = ip->getRealFieldValue(fields, objectSchemaProps, "maximum_air_flow_rate"); } @@ -407,7 +404,6 @@ void GetPIUs(EnergyPlusData &state) // find fan type // test if Fan:SystemModel fan of this name exists - ErrorObjectHeader eoh{routineName, cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(8)}; if ((thisPIU.Fan_Index = Fans::GetFanIndex(state, thisPIU.FanName)) == 0) { ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(8), thisPIU.FanName); ErrorsFound = true; @@ -415,7 +411,7 @@ void GetPIUs(EnergyPlusData &state) // Assert that this is a constant volume fan? auto *fan = state.dataFans->fans(thisPIU.Fan_Index); thisPIU.fanType = fan->type; - thisPIU.FanAvailSchedPtr = fan->availSchedNum; + thisPIU.fanAvailSched = fan->availSched; } thisPIU.HCoil = ip->getAlphaFieldValue(fields, objectSchemaProps, "reheat_coil_name"); @@ -797,7 +793,7 @@ void InitPIU(EnergyPlusData &state, // Do the start of HVAC time step initializations if (FirstHVACIteration) { // check for upstream zero flow. If nonzero and schedule ON, set primary flow to max - if (GetCurrentScheduleValue(state, thisPIU.SchedPtr) > 0.0 && state.dataLoopNodes->Node(PriNode).MassFlowRate > 0.0) { + if (thisPIU.availSched->getCurrentVal() > 0.0 && state.dataLoopNodes->Node(PriNode).MassFlowRate > 0.0) { if (thisPIU.UnitType == "AirTerminal:SingleDuct:SeriesPIU:Reheat") { state.dataLoopNodes->Node(PriNode).MassFlowRate = thisPIU.MaxPriAirMassFlow; state.dataLoopNodes->Node(SecNode).MassFlowRate = max(0.0, thisPIU.MaxTotAirMassFlow - thisPIU.MaxPriAirMassFlow); @@ -810,7 +806,7 @@ void InitPIU(EnergyPlusData &state, state.dataLoopNodes->Node(SecNode).MassFlowRate = 0.0; } // reset the max and min avail flows - if (GetCurrentScheduleValue(state, thisPIU.SchedPtr) > 0.0 && state.dataLoopNodes->Node(PriNode).MassFlowRateMaxAvail > 0.0) { + if (thisPIU.availSched->getCurrentVal() > 0.0 && state.dataLoopNodes->Node(PriNode).MassFlowRateMaxAvail > 0.0) { if (thisPIU.UnitType == "AirTerminal:SingleDuct:SeriesPIU:Reheat") { state.dataLoopNodes->Node(PriNode).MassFlowRateMaxAvail = thisPIU.MaxPriAirMassFlow; state.dataLoopNodes->Node(PriNode).MassFlowRateMinAvail = thisPIU.MinPriAirMassFlow; @@ -1476,10 +1472,10 @@ void CalcSeriesPIU(EnergyPlusData &state, MinWaterFlow = state.dataLoopNodes->Node(thisPIU.HotControlNode).MassFlowRateMinAvail; } } - if (GetCurrentScheduleValue(state, thisPIU.SchedPtr) <= 0.0) { + if (thisPIU.availSched->getCurrentVal() <= 0.0) { UnitOn = false; } - if ((GetCurrentScheduleValue(state, thisPIU.FanAvailSchedPtr) <= 0.0 || state.dataHVACGlobal->TurnFansOff) && !state.dataHVACGlobal->TurnFansOn) { + if ((thisPIU.fanAvailSched->getCurrentVal() <= 0.0 || state.dataHVACGlobal->TurnFansOff) && !state.dataHVACGlobal->TurnFansOn) { UnitOn = false; } if (thisPIU.PriAirMassFlow <= SmallMassFlow || PriAirMassFlowMax <= SmallMassFlow) { @@ -1609,7 +1605,7 @@ void CalcSeriesPIU(EnergyPlusData &state, (state.dataLoopNodes->Node(thisPIU.HCoilInAirNode).Temp - state.dataLoopNodes->Node(ZoneNode).Temp); // check if heating coil is off - if (((!UnitOn) || (QActualHeating < SmallLoad) || (state.dataHeatBalFanSys->TempControlType(ZoneNum) == HVAC::ThermostatType::SingleCooling) || + if (((!UnitOn) || (QActualHeating < SmallLoad) || (state.dataHeatBalFanSys->TempControlType(ZoneNum) == HVAC::SetptType::SingleCool) || (thisPIU.PriAirMassFlow > PriAirMassFlowMin)) && (thisPIU.heatingOperatingMode != HeatOpModeType::StagedHeatFirstStage)) { // reheat is off during the first stage of heating thisPIU.heatingOperatingMode = HeatOpModeType::HeaterOff; @@ -1802,7 +1798,7 @@ void CalcParallelPIU(EnergyPlusData &state, MinWaterFlow = state.dataLoopNodes->Node(thisPIU.HotControlNode).MassFlowRateMinAvail; } } - if (GetCurrentScheduleValue(state, thisPIU.SchedPtr) <= 0.0) { + if (thisPIU.availSched->getCurrentVal() <= 0.0) { UnitOn = false; } if (thisPIU.PriAirMassFlow <= SmallMassFlow || PriAirMassFlowMax <= SmallMassFlow) { @@ -1959,7 +1955,7 @@ void CalcParallelPIU(EnergyPlusData &state, (state.dataLoopNodes->Node(thisPIU.HCoilInAirNode).Temp - state.dataLoopNodes->Node(ZoneNode).Temp); // check if heating coil is off - if (((!UnitOn) || (QActualHeating < SmallLoad) || (state.dataHeatBalFanSys->TempControlType(ZoneNum) == HVAC::ThermostatType::SingleCooling) || + if (((!UnitOn) || (QActualHeating < SmallLoad) || (state.dataHeatBalFanSys->TempControlType(ZoneNum) == HVAC::SetptType::SingleCool) || (thisPIU.PriAirMassFlow > PriAirMassFlowMin)) && (thisPIU.heatingOperatingMode != HeatOpModeType::StagedHeatFirstStage)) { // reheat is off during the first stage of heating thisPIU.heatingOperatingMode = HeatOpModeType::HeaterOff; @@ -2137,7 +2133,7 @@ void CalcVariableSpeedPIUCoolingBehavior(EnergyPlusData &state, Real64 const zoneLoad, Real64 const loadToHeatSetPt, Real64 const priAirMassFlowMin, - Real64 const priAirMassFlowMax) + [[maybe_unused]] Real64 const priAirMassFlowMax) { auto &thisPIU = state.dataPowerInductionUnits->PIU(piuNum); thisPIU.coolingOperatingMode = CoolOpModeType::CoolerOff; diff --git a/src/EnergyPlus/PoweredInductionUnits.hh b/src/EnergyPlus/PoweredInductionUnits.hh index 4f08c45596a..b49eac4d6bf 100644 --- a/src/EnergyPlus/PoweredInductionUnits.hh +++ b/src/EnergyPlus/PoweredInductionUnits.hh @@ -130,8 +130,7 @@ namespace PoweredInductionUnits { std::string Name; // name of unit std::string UnitType; // type of unit DataDefineEquip::ZnAirLoopEquipType UnitType_Num; // index for type of unit - std::string Sched; // availability schedule - int SchedPtr; // index to schedule + Sched::Schedule *availSched = nullptr; // availability schedule Real64 MaxTotAirVolFlow; // m3/s (series) Real64 MaxTotAirMassFlow; // kg/s (series) Real64 MaxPriAirVolFlow; // m3/s @@ -154,7 +153,7 @@ namespace PoweredInductionUnits { std::string FanName; // name of fan component HVAC::FanType fanType; // index for fan type int Fan_Index; // store index for this fan - int FanAvailSchedPtr; // index to fan availability schedule + Sched::Schedule *fanAvailSched = nullptr; // fan availability schedule HtgCoilType HCoilType; // index for heating coil type DataPlant::PlantEquipmentType HCoil_PlantType; std::string HCoil; // name of heating coil component @@ -207,11 +206,11 @@ namespace PoweredInductionUnits { int plenumIndex = 0; // Default Constructor PowIndUnitData() - : UnitType_Num(DataDefineEquip::ZnAirLoopEquipType::Invalid), SchedPtr(0), MaxTotAirVolFlow(0.0), MaxTotAirMassFlow(0.0), + : UnitType_Num(DataDefineEquip::ZnAirLoopEquipType::Invalid), MaxTotAirVolFlow(0.0), MaxTotAirMassFlow(0.0), MaxPriAirVolFlow(0.0), MaxPriAirMassFlow(0.0), MinPriAirFlowFrac(0.0), MinPriAirMassFlow(0.0), PriDamperPosition(0.0), MaxSecAirVolFlow(0.0), MaxSecAirMassFlow(0.0), FanOnFlowFrac(0.0), FanOnAirMassFlow(0.0), PriAirInNode(0), SecAirInNode(0), OutAirNode(0), HCoilInAirNode(0), ControlCompTypeNum(0), CompErrIndex(0), Mixer_Num(0), fanType(HVAC::FanType::Invalid), Fan_Index(0), - FanAvailSchedPtr(0), HCoilType(HtgCoilType::Invalid), HCoil_PlantType(DataPlant::PlantEquipmentType::Invalid), HCoil_Index(0), + HCoilType(HtgCoilType::Invalid), HCoil_PlantType(DataPlant::PlantEquipmentType::Invalid), HCoil_Index(0), HCoil_FluidIndex(0), MaxVolHotWaterFlow(0.0), MaxVolHotSteamFlow(0.0), MaxHotWaterFlow(0.0), MaxHotSteamFlow(0.0), MinVolHotWaterFlow(0.0), MinHotSteamFlow(0.0), MinVolHotSteamFlow(0.0), MinHotWaterFlow(0.0), HotControlNode(0), HotCoilOutNodeNum(0), HotControlOffset(0.0), HWplantLoc{}, ADUNum(0), InducesPlenumAir(false), HeatingRate(0.0), HeatingEnergy(0.0), SensCoolRate(0.0), @@ -321,6 +320,10 @@ struct PoweredInductionUnitsData : BaseGlobalStruct Array1D_bool MySizeFlag; Array1D_bool MyPlantScanFlag; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/PsychCacheData.hh b/src/EnergyPlus/PsychCacheData.hh index ffae5d320db..5275e091ffc 100644 --- a/src/EnergyPlus/PsychCacheData.hh +++ b/src/EnergyPlus/PsychCacheData.hh @@ -181,6 +181,10 @@ struct PsychrometricCacheData : BaseGlobalStruct std::array(PsychrometricFunction::Num)> NumIterations; #endif + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/Psychrometrics.hh b/src/EnergyPlus/Psychrometrics.hh index b3ebe4d2cb1..a6ece253d87 100644 --- a/src/EnergyPlus/Psychrometrics.hh +++ b/src/EnergyPlus/Psychrometrics.hh @@ -1702,11 +1702,15 @@ struct PsychrometricsData : BaseGlobalStruct bool ReportErrors = true; bool useInterpolationPsychTsatFnPb = false; - void init_state(EnergyPlusData &state) override + void init_constant_state(EnergyPlusData &state) override { Psychrometrics::InitializePsychRoutines(state); } + void init_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void clear_state() override { iPsyErrIndex.fill(0); diff --git a/src/EnergyPlus/Pumps.cc b/src/EnergyPlus/Pumps.cc index b22f78716f8..e48f616021b 100644 --- a/src/EnergyPlus/Pumps.cc +++ b/src/EnergyPlus/Pumps.cc @@ -220,13 +220,12 @@ void GetPumpInput(EnergyPlusData &state) using FluidProperties::GetDensityGlycol; using FluidProperties::GetSatDensityRefrig; using NodeInputManager::GetOnlySingleNode; - using ScheduleManager::CheckScheduleValueMinMax; - using ScheduleManager::GetScheduleIndex; // SUBROUTINE PARAMETER DEFINITIONS: Real64 constexpr StartTemp(100.0); // Standard Temperature across code to calculated Steam density static constexpr std::string_view RoutineName("GetPumpInput: "); - static constexpr std::string_view RoutineNameNoColon("GetPumpInput"); + static constexpr std::string_view routineName = "GetPumpInput"; + static constexpr std::array(PumpControlType::Num)> pumpCtrlTypeNamesUC{"CONTINUOUS", "INTERMITTENT"}; static constexpr std::array(ControlTypeVFD::Num)> controlTypeVFDNamesUC{"MANUALCONTROL", "PRESSURESETPOINTCONTROL"}; @@ -290,6 +289,8 @@ void GetPumpInput(EnergyPlusData &state) thisInput->cAlphaFieldNames, thisInput->cNumericFieldNames); + ErrorObjectHeader eoh{routineName, cCurrentModuleObject, thisInput->cAlphaArgs(1)}; + GlobalNames::VerifyUniqueInterObjectName( state, state.dataPumps->PumpUniqueNames, thisInput->cAlphaArgs(1), cCurrentModuleObject, thisInput->cAlphaFieldNames(1), ErrorsFound); thisPump.Name = thisInput->cAlphaArgs(1); @@ -328,13 +329,9 @@ void GetPumpInput(EnergyPlusData &state) } // Input the optional schedule for the pump - if (!thisInput->cAlphaArgs(5).empty()) { // Initialized to zero, don't get a schedule for an empty - thisPump.PumpScheduleIndex = GetScheduleIndex(state, thisInput->cAlphaArgs(5)); - if (thisPump.PumpScheduleIndex <= 0) { - ShowWarningError(state, - format("{}{}=\"{}\", Invalid {}", RoutineName, cCurrentModuleObject, thisPump.Name, thisInput->cAlphaFieldNames(5))); - ShowContinueError(state, format("Schedule named =[{}]. was not found and will not be used.", thisInput->cAlphaArgs(5))); - } + if (thisInput->lAlphaFieldBlanks(5)) { + } else if ((thisPump.sched = Sched::GetSchedule(state, thisInput->cAlphaArgs(5))) == nullptr) { + ShowWarningItemNotFound(state, eoh, thisInput->cAlphaFieldNames(5), thisInput->cAlphaArgs(1), ""); } thisPump.NomVolFlowRate = thisInput->rNumericArgs(1); @@ -407,52 +404,57 @@ void GetPumpInput(EnergyPlusData &state) thisPump.VFD.VFDControlType = static_cast(getEnumValue(controlTypeVFDNamesUC, Util::makeUPPER(state.dataIPShortCut->cAlphaArgs(7)))); switch (thisPump.VFD.VFDControlType) { + case ControlTypeVFD::VFDManual: { - thisPump.VFD.ManualRPMSchedIndex = GetScheduleIndex(state, thisInput->cAlphaArgs(8)); - if (thisPump.VFD.ManualRPMSchedIndex <= 0) { - ShowSevereError( - state, - format( - "{}{}=\"{}\", At least one scheduled VFD schedule input was invalid.", RoutineName, cCurrentModuleObject, thisPump.Name)); - ShowContinueError(state, "Verify that all of the pressure and rpm schedules referenced in the input fields actually exist."); + if ((thisPump.VFD.manualRPMSched = Sched::GetSchedule(state, thisInput->cAlphaArgs(8))) == nullptr) { + ShowSevereItemNotFound(state, eoh, thisInput->cAlphaFieldNames(8), thisInput->cAlphaArgs(8)); ErrorsFound = true; - } else if (!CheckScheduleValueMinMax(state, thisPump.VFD.ManualRPMSchedIndex, false, 0.0) || - !CheckScheduleValueMinMax(state, thisPump.VFD.ManualRPMSchedIndex, false, 0.0)) { - ShowSevereError( - state, - format("{}{}=\"{}\", A pump rpm schedule had zero value. Ensure all entries in the schedule are greater than zero.", - RoutineName, - cCurrentModuleObject, - thisPump.Name)); + } else if (!thisPump.VFD.manualRPMSched->checkMinVal(state, Clusive::Ex, 0.0)) { + Sched::ShowSevereBadMin(state, eoh, thisInput->cAlphaFieldNames(8), thisInput->cAlphaArgs(8), Clusive::Ex, 0.0); ErrorsFound = true; } } break; + case ControlTypeVFD::VFDAutomatic: { - thisPump.VFD.LowerPsetSchedIndex = GetScheduleIndex(state, thisInput->cAlphaArgs(9)); - thisPump.VFD.UpperPsetSchedIndex = GetScheduleIndex(state, thisInput->cAlphaArgs(10)); - thisPump.VFD.MinRPMSchedIndex = GetScheduleIndex(state, thisInput->cAlphaArgs(11)); - thisPump.VFD.MaxRPMSchedIndex = GetScheduleIndex(state, thisInput->cAlphaArgs(12)); - if (min(thisPump.VFD.LowerPsetSchedIndex, - thisPump.VFD.UpperPsetSchedIndex, - thisPump.VFD.MinRPMSchedIndex, - thisPump.VFD.MaxRPMSchedIndex) <= 0) { - ShowSevereError( - state, - format( - "{}{}=\"{}\", At least one scheduled VFD schedule input was invalid.", RoutineName, cCurrentModuleObject, thisPump.Name)); - ShowContinueError(state, "Verify that all of the pressure and rpm schedules referenced in the input fields actually exist."); + if (thisInput->lAlphaFieldBlanks(9)) { + ShowSevereEmptyField(state, eoh, thisInput->cAlphaFieldNames(9)); ErrorsFound = true; - } else if (!CheckScheduleValueMinMax(state, thisPump.VFD.MinRPMSchedIndex, false, 0.0) || - !CheckScheduleValueMinMax(state, thisPump.VFD.MaxRPMSchedIndex, false, 0.0)) { - ShowSevereError( - state, - format("{}{}=\"{}\", A pump rpm schedule had zero value. Ensure all entries in the schedule are greater than zero.", - RoutineName, - cCurrentModuleObject, - thisPump.Name)); + } else if ((thisPump.VFD.lowerPsetSched = Sched::GetSchedule(state, thisInput->cAlphaArgs(9))) == nullptr) { + ShowSevereItemNotFound(state, eoh, thisInput->cAlphaFieldNames(9), thisInput->cAlphaArgs(9)); + ErrorsFound = true; + } + + if (thisInput->lAlphaFieldBlanks(10)) { + ShowSevereEmptyField(state, eoh, thisInput->cAlphaFieldNames(10)); + ErrorsFound = true; + } else if ((thisPump.VFD.upperPsetSched = Sched::GetSchedule(state, thisInput->cAlphaArgs(10))) == nullptr) { + ShowSevereItemNotFound(state, eoh, thisInput->cAlphaFieldNames(10), thisInput->cAlphaArgs(10)); + ErrorsFound = true; + } + + if (thisInput->lAlphaFieldBlanks(11)) { + ShowSevereEmptyField(state, eoh, thisInput->cAlphaFieldNames(11)); + ErrorsFound = true; + } else if ((thisPump.VFD.minRPMSched = Sched::GetSchedule(state, thisInput->cAlphaArgs(11))) == nullptr) { + ShowSevereItemNotFound(state, eoh, thisInput->cAlphaFieldNames(11), thisInput->cAlphaArgs(11)); + ErrorsFound = true; + } else if (!thisPump.VFD.minRPMSched->checkMinVal(state, Clusive::Ex, 0.0)) { + Sched::ShowSevereBadMin(state, eoh, thisInput->cAlphaFieldNames(11), thisInput->cAlphaArgs(11), Clusive::Ex, 0.0); + ErrorsFound = true; + } + + if (thisInput->lAlphaFieldBlanks(12)) { + ShowSevereEmptyField(state, eoh, thisInput->cAlphaFieldNames(12)); + ErrorsFound = true; + } else if ((thisPump.VFD.maxRPMSched = Sched::GetSchedule(state, thisInput->cAlphaArgs(12))) == nullptr) { + ShowSevereItemNotFound(state, eoh, thisInput->cAlphaFieldNames(12), thisInput->cAlphaArgs(12)); + ErrorsFound = true; + } else if (!thisPump.VFD.maxRPMSched->checkMinVal(state, Clusive::Ex, 0.0)) { + Sched::ShowSevereBadMin(state, eoh, thisInput->cAlphaFieldNames(12), thisInput->cAlphaArgs(12), Clusive::Ex, 0.0); ErrorsFound = true; } } break; + default: { ShowSevereError(state, format("{}{}=\"{}\", VFD Control type entered is invalid. Use one of the key choice entries.", @@ -536,6 +538,8 @@ void GetPumpInput(EnergyPlusData &state) thisInput->cAlphaFieldNames, thisInput->cNumericFieldNames); + ErrorObjectHeader eoh{routineName, cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1)}; + GlobalNames::VerifyUniqueInterObjectName( state, state.dataPumps->PumpUniqueNames, thisInput->cAlphaArgs(1), cCurrentModuleObject, thisInput->cAlphaFieldNames(1), ErrorsFound); thisPump.Name = thisInput->cAlphaArgs(1); @@ -596,13 +600,9 @@ void GetPumpInput(EnergyPlusData &state) } // Input the optional schedule for the pump - if (!thisInput->cAlphaArgs(5).empty()) { // Initialized to zero, don't get a schedule for an empty - thisPump.PumpScheduleIndex = GetScheduleIndex(state, thisInput->cAlphaArgs(5)); - if (thisPump.PumpScheduleIndex <= 0) { - ShowWarningError(state, - format("{}{}=\"{}\", Invalid {}", RoutineName, cCurrentModuleObject, thisPump.Name, thisInput->cAlphaFieldNames(5))); - ShowContinueError(state, format("Schedule named =[{}]. was not found and will not be used.", thisInput->cAlphaArgs(5))); - } + if (thisInput->lAlphaFieldBlanks(5)) { // Initialized to zero, don't get a schedule for an empty + } else if ((thisPump.sched = Sched::GetSchedule(state, thisInput->cAlphaArgs(5))) == nullptr) { + ShowWarningItemNotFound(state, eoh, thisInput->cAlphaFieldNames(5), thisInput->cAlphaArgs(5), ""); } // Input pressure related data such as pressure curve and impeller size/rotational speed @@ -727,9 +727,9 @@ void GetPumpInput(EnergyPlusData &state) thisPump.PumpControl = PumpControlType::Intermittent; // Input the optional schedule for the pump - if (!thisInput->cAlphaArgs(4).empty()) { // Initialized to zero, don't get a schedule for an empty - thisPump.PumpScheduleIndex = GetScheduleIndex(state, thisInput->cAlphaArgs(4)); - if (thisPump.PumpScheduleIndex <= 0) { + if (thisInput->lAlphaFieldBlanks(4)) { + thisPump.sched = Sched::GetSchedule(state, thisInput->cAlphaArgs(4)); + if (thisPump.sched != nullptr) { ShowWarningError(state, format("{}{}=\"{}\", Invalid {}", RoutineName, cCurrentModuleObject, thisPump.Name, thisInput->cAlphaFieldNames(4))); ShowContinueError(state, format("Schedule named =[{}]. was not found and will not be used.", thisInput->cAlphaArgs(4))); @@ -779,7 +779,7 @@ void GetPumpInput(EnergyPlusData &state) thisPump.NomVolFlowRateWasAutoSized = true; } else { // Calc Condensate Pump Water Volume Flow Rate - SteamDensity = GetSatDensityRefrig(state, fluidNameSteam, StartTemp, 1.0, thisPump.FluidIndex, RoutineNameNoColon); + SteamDensity = GetSatDensityRefrig(state, fluidNameSteam, StartTemp, 1.0, thisPump.FluidIndex, routineName); TempWaterDensity = GetDensityGlycol(state, fluidNameWater, Constant::InitConvTemp, DummyWaterIndex, RoutineName); thisPump.NomVolFlowRate = (thisPump.NomSteamVolFlowRate * SteamDensity) / TempWaterDensity; } @@ -884,8 +884,8 @@ void GetPumpInput(EnergyPlusData &state) // Input the optional schedule for the pump if (!thisInput->cAlphaArgs(6).empty()) { // Initialized to zero, don't get a schedule for an empty - thisPump.PumpScheduleIndex = GetScheduleIndex(state, thisInput->cAlphaArgs(6)); - if (thisPump.PumpScheduleIndex <= 0) { + thisPump.sched = Sched::GetSchedule(state, thisInput->cAlphaArgs(6)); + if (thisPump.sched != nullptr) { ShowWarningError(state, format("{}{}=\"{}\", Invalid {}", RoutineName, cCurrentModuleObject, thisPump.Name, thisInput->cAlphaFieldNames(6))); ShowContinueError(state, format("Schedule named =[{}]. was not found and will not be used.", thisInput->cAlphaArgs(6))); @@ -977,6 +977,8 @@ void GetPumpInput(EnergyPlusData &state) thisInput->cAlphaFieldNames, thisInput->cNumericFieldNames); + ErrorObjectHeader eoh{routineName, cCurrentModuleObject, thisInput->cAlphaArgs(1)}; + GlobalNames::VerifyUniqueInterObjectName( state, state.dataPumps->PumpUniqueNames, thisInput->cAlphaArgs(1), cCurrentModuleObject, thisInput->cAlphaFieldNames(1), ErrorsFound); thisPump.Name = thisInput->cAlphaArgs(1); @@ -1029,13 +1031,9 @@ void GetPumpInput(EnergyPlusData &state) } // Input the optional schedule for the pump - if (!thisInput->cAlphaArgs(6).empty()) { // Initialized to zero, don't get a schedule for an empty - thisPump.PumpScheduleIndex = GetScheduleIndex(state, thisInput->cAlphaArgs(6)); - if (thisPump.PumpScheduleIndex <= 0) { - ShowWarningError(state, - format("{}{}=\"{}\", Invalid {}", RoutineName, cCurrentModuleObject, thisPump.Name, thisInput->cAlphaFieldNames(6))); - ShowContinueError(state, format("Schedule named =[{}]. was not found and will not be used.", thisInput->cAlphaArgs(6))); - } + if (thisInput->lAlphaFieldBlanks(6)) { + } else if ((thisPump.sched = Sched::GetSchedule(state, thisInput->cAlphaArgs(6))) == nullptr) { + ShowWarningItemNotFound(state, eoh, thisInput->cAlphaFieldNames(6), thisInput->cAlphaArgs(6), ""); } thisPump.NomVolFlowRate = thisInput->rNumericArgs(1); @@ -1582,7 +1580,6 @@ void SetupPumpMinMaxFlows(EnergyPlusData &state, int const LoopNum, int const Pu using FluidProperties::GetDensityGlycol; using PlantPressureSystem::ResolveLoopFlowVsPressure; using PlantUtilities::BoundValueToWithinTwoValues; - using ScheduleManager::GetCurrentScheduleValue; // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int InletNode; // pump inlet node number @@ -1609,8 +1606,8 @@ void SetupPumpMinMaxFlows(EnergyPlusData &state, int const LoopNum, int const Pu InletNodeMin = thisInNode.MassFlowRateMinAvail; // Retrive the pump speed fraction from the pump schedule - if (thisPump.PumpScheduleIndex != 0) { - PumpSchedFraction = GetCurrentScheduleValue(state, thisPump.PumpScheduleIndex); + if (thisPump.sched != nullptr) { + PumpSchedFraction = thisPump.sched->getCurrentVal(); PumpSchedFraction = BoundValueToWithinTwoValues(PumpSchedFraction, 0.0, 1.0); } else { PumpSchedFraction = 1.0; @@ -1646,7 +1643,7 @@ void SetupPumpMinMaxFlows(EnergyPlusData &state, int const LoopNum, int const Pu switch (thisPump.VFD.VFDControlType) { case ControlTypeVFD::VFDManual: { // Evaluate the schedule if it exists and put the fraction into a local variable - PumpSchedRPM = GetCurrentScheduleValue(state, thisPump.VFD.ManualRPMSchedIndex); + PumpSchedRPM = thisPump.VFD.manualRPMSched->getCurrentVal(); // Convert the RPM to rot/sec for calculation routine thisPump.RotSpeed = PumpSchedRPM / 60.0; // Resolve the new mass flow rate based on current pressure characteristics @@ -1760,7 +1757,6 @@ void CalcPumps(EnergyPlusData &state, int const PumpNum, Real64 const FlowReques using FluidProperties::GetSpecificHeatGlycol; using PlantUtilities::SetComponentFlowRate; - using ScheduleManager::GetCurrentScheduleValue; // SUBROUTINE PARAMETER DEFINITIONS: static constexpr std::string_view RoutineName("PlantPumps:CalcPumps: "); @@ -1831,8 +1827,8 @@ void CalcPumps(EnergyPlusData &state, int const PumpNum, Real64 const FlowReques // Get RPM value for reporting as output // RPM is calculated using pump affinity laws for rotation speed if (thisPumpPlant.UsePressureForPumpCalcs && thisPump.HasVFD) { - RotSpeed_Min = GetCurrentScheduleValue(state, thisPump.VFD.MinRPMSchedIndex); - RotSpeed_Max = GetCurrentScheduleValue(state, thisPump.VFD.MaxRPMSchedIndex); + RotSpeed_Min = thisPump.VFD.minRPMSched->getCurrentVal(); + RotSpeed_Max = thisPump.VFD.maxRPMSched->getCurrentVal(); if (thisPump.PumpMassFlowRateMaxRPM < DataBranchAirLoopPlant::MassFlowTolerance || thisPump.PumpMassFlowRateMinRPM < DataBranchAirLoopPlant::MassFlowTolerance) { thisPump.VFD.PumpActualRPM = 0.0; @@ -2330,7 +2326,6 @@ void GetRequiredMassFlowRate(EnergyPlusData &state, using PlantPressureSystem::ResolveLoopFlowVsPressure; using PlantUtilities::SetComponentFlowRate; - using ScheduleManager::GetCurrentScheduleValue; Real64 PumpMassFlowRateMaxPress(0.0); // Maximum mass flow rate associated with maximum pressure limit Real64 PumpMassFlowRateMinPress(0.0); // Minimum mass flow rate associated with minimum pressure limit @@ -2341,10 +2336,10 @@ void GetRequiredMassFlowRate(EnergyPlusData &state, auto &thisPump = state.dataPumps->PumpEquip(PumpNum); - RotSpeed_Min = GetCurrentScheduleValue(state, thisPump.VFD.MinRPMSchedIndex); - RotSpeed_Max = GetCurrentScheduleValue(state, thisPump.VFD.MaxRPMSchedIndex); - MinPress = GetCurrentScheduleValue(state, thisPump.VFD.LowerPsetSchedIndex); - MaxPress = GetCurrentScheduleValue(state, thisPump.VFD.UpperPsetSchedIndex); + RotSpeed_Min = thisPump.VFD.minRPMSched->getCurrentVal(); + RotSpeed_Max = thisPump.VFD.maxRPMSched->getCurrentVal(); + MinPress = thisPump.VFD.lowerPsetSched->getCurrentVal(); + MaxPress = thisPump.VFD.upperPsetSched->getCurrentVal(); // Calculate maximum and minimum mass flow rate associated with maximun and minimum RPM if (thisPump.plantLoc.loopNum > 0) { diff --git a/src/EnergyPlus/Pumps.hh b/src/EnergyPlus/Pumps.hh index 955c13a2169..7901de15000 100644 --- a/src/EnergyPlus/Pumps.hh +++ b/src/EnergyPlus/Pumps.hh @@ -113,11 +113,11 @@ namespace Pumps { { // Members std::string Name; - int ManualRPMSchedIndex = 0; - int LowerPsetSchedIndex = 0; - int UpperPsetSchedIndex = 0; - int MinRPMSchedIndex = 0; - int MaxRPMSchedIndex = 0; + Sched::Schedule *manualRPMSched = nullptr; + Sched::Schedule *lowerPsetSched = nullptr; + Sched::Schedule *upperPsetSched = nullptr; + Sched::Schedule *minRPMSched = nullptr; + Sched::Schedule *maxRPMSched = nullptr; ControlTypeVFD VFDControlType = ControlTypeVFD::Invalid; // VFDControlType Real64 MaxRPM = 0.0; // Maximum RPM range value - schedule limit Real64 MinRPM = 0.0; // Minimum RPM range value - schedule limit @@ -133,7 +133,7 @@ namespace Pumps { DataPlant::PlantEquipmentType TypeOf_Num = DataPlant::PlantEquipmentType::Invalid; // pump type of number in reference to the dataplant values PlantLocation plantLoc = {0, DataPlant::LoopSideLocation::Invalid, 0, 0}; PumpControlType PumpControl = PumpControlType::Invalid; // Integer equivalent of PumpControlType - int PumpScheduleIndex = 0; // Schedule Pointer + Sched::Schedule *sched = nullptr; // Schedule // availabilty? int InletNodeNum = 0; // Node number on the inlet side of the plant int OutletNodeNum = 0; // Node number on the outlet side of the plant PumpBankControlSeq SequencingScheme = PumpBankControlSeq::Invalid; // Optimal, Sequential, User-Defined @@ -249,6 +249,10 @@ struct PumpsData : BaseGlobalStruct EPVector PumpEquipReport; std::unordered_map PumpUniqueNames; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/PurchasedAirManager.cc b/src/EnergyPlus/PurchasedAirManager.cc index 3fd4bf0c89d..ec57ed1e503 100644 --- a/src/EnergyPlus/PurchasedAirManager.cc +++ b/src/EnergyPlus/PurchasedAirManager.cc @@ -112,7 +112,6 @@ namespace EnergyPlus::PurchasedAirManager { // humidity ratio are adjusted to meet the zone load. // Using/Aliasing -using namespace ScheduleManager; using Psychrometrics::PsyCpAirFnW; using Psychrometrics::PsyHFnTdbW; using Psychrometrics::PsyRhoAirFnPbTdbW; @@ -220,6 +219,8 @@ void GetPurchasedAir(EnergyPlusData &state) int CtrlZone; // zone index int NodeNum; // node index static constexpr std::string_view RoutineName("GetPurchasedAir: "); // include trailing blank space + static constexpr std::string_view routineName = "GetPurchasedAir"; + bool ErrorsFound(false); // If errors detected in input bool IsOANodeListed; // Flag for OA node name listed in OutdoorAir:Node or Nodelist bool UniqueNodeError; // Flag for non-unique node error(s) @@ -253,6 +254,8 @@ void GetPurchasedAir(EnergyPlusData &state) state.dataIPShortCut->cAlphaFieldNames, state.dataIPShortCut->cNumericFieldNames); + ErrorObjectHeader eoh{routineName, cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1)}; + state.dataPurchasedAirMgr->PurchAirNumericFields(PurchAirNum).FieldNames.allocate(NumNums); state.dataPurchasedAirMgr->PurchAirNumericFields(PurchAirNum).FieldNames = ""; state.dataPurchasedAirMgr->PurchAirNumericFields(PurchAirNum).FieldNames = state.dataIPShortCut->cNumericFieldNames; @@ -260,18 +263,11 @@ void GetPurchasedAir(EnergyPlusData &state) PurchAir(PurchAirNum).Name = state.dataIPShortCut->cAlphaArgs(1); // get optional availability schedule - PurchAir(PurchAirNum).AvailSched = state.dataIPShortCut->cAlphaArgs(2); if (state.dataIPShortCut->lAlphaFieldBlanks(2)) { - PurchAir(PurchAirNum).AvailSchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - PurchAir(PurchAirNum).AvailSchedPtr = GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(2)); - if (PurchAir(PurchAirNum).AvailSchedPtr == 0) { - ShowSevereError(state, format("{}{}=\"{} invalid data", RoutineName, cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError( - state, - format("Invalid-not found {}=\"{}\".", state.dataIPShortCut->cAlphaFieldNames(2), state.dataIPShortCut->cAlphaArgs(2))); - ErrorsFound = true; - } + PurchAir(PurchAirNum).availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((PurchAir(PurchAirNum).availSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(2), state.dataIPShortCut->cAlphaArgs(2)); + ErrorsFound = true; } // Purchased air supply air node is an outlet node PurchAir(PurchAirNum).ZoneSupplyAirNodeNum = GetOnlySingleNode(state, @@ -406,33 +402,21 @@ void GetPurchasedAir(EnergyPlusData &state) PurchAir(PurchAirNum).MaxCoolTotCap = state.dataIPShortCut->rNumericArgs(8); // get optional heating availability schedule - PurchAir(PurchAirNum).HeatSched = state.dataIPShortCut->cAlphaArgs(8); if (state.dataIPShortCut->lAlphaFieldBlanks(8)) { - PurchAir(PurchAirNum).HeatSchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - PurchAir(PurchAirNum).HeatSchedPtr = GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(8)); - if (PurchAir(PurchAirNum).HeatSchedPtr == 0) { - ShowSevereError(state, format("{}{}=\"{} invalid data", RoutineName, cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError( - state, - format("Invalid-not found {}=\"{}\".", state.dataIPShortCut->cAlphaFieldNames(8), state.dataIPShortCut->cAlphaArgs(8))); - ErrorsFound = true; - } + PurchAir(PurchAirNum).heatAvailSched = Sched::GetScheduleAlwaysOn(state); + } else if ((PurchAir(PurchAirNum).heatAvailSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(8))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(8), state.dataIPShortCut->cAlphaArgs(8)); + ErrorsFound = true; } + // get optional cooling availability schedule - PurchAir(PurchAirNum).CoolSched = state.dataIPShortCut->cAlphaArgs(9); if (state.dataIPShortCut->lAlphaFieldBlanks(9)) { - PurchAir(PurchAirNum).CoolSchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - PurchAir(PurchAirNum).CoolSchedPtr = GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(9)); - if (PurchAir(PurchAirNum).CoolSchedPtr == 0) { - ShowSevereError(state, format("{}{}=\"{} invalid data", RoutineName, cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError( - state, - format("Invalid-not found {}=\"{}\".", state.dataIPShortCut->cAlphaFieldNames(9), state.dataIPShortCut->cAlphaArgs(9))); - ErrorsFound = true; - } + PurchAir(PurchAirNum).coolAvailSched = Sched::GetScheduleAlwaysOn(state); + } else if ((PurchAir(PurchAirNum).coolAvailSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(9))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(9), state.dataIPShortCut->cAlphaArgs(9)); + ErrorsFound = true; } + // get Dehumidification control type if (Util::SameString(state.dataIPShortCut->cAlphaArgs(10), "None")) { PurchAir(PurchAirNum).DehumidCtrlType = HumControl::None; @@ -1315,21 +1299,23 @@ void InitPurchasedAir(EnergyPlusData &state, int const PurchAirNum, int const Co state.dataPurchasedAirMgr->InitPurchasedAirMyEnvrnFlag(PurchAirNum) = true; } + auto const &zoneTstatSetpt = state.dataHeatBalFanSys->zoneTstatSetpts(ControlledZoneNum); + // These initializations are done every iteration // check that supply air temps can meet the zone thermostat setpoints - if (PurchAir(PurchAirNum).MinCoolSuppAirTemp > state.dataHeatBalFanSys->ZoneThermostatSetPointHi(ControlledZoneNum) && - state.dataHeatBalFanSys->ZoneThermostatSetPointHi(ControlledZoneNum) != 0 && PurchAir(PurchAirNum).CoolingLimit == LimitType::NoLimit) { + if (PurchAir(PurchAirNum).MinCoolSuppAirTemp > zoneTstatSetpt.setptHi && + zoneTstatSetpt.setptHi != 0 && PurchAir(PurchAirNum).CoolingLimit == LimitType::NoLimit) { // Check if the unit is scheduled off UnitOn = true; // IF (PurchAir(PurchAirNum)%AvailSchedPtr > 0) THEN - if (GetCurrentScheduleValue(state, PurchAir(PurchAirNum).AvailSchedPtr) <= 0) { + if (PurchAir(PurchAirNum).availSched->getCurrentVal() <= 0) { UnitOn = false; } // END IF // Check if cooling available CoolOn = true; // IF (PurchAir(PurchAirNum)%CoolSchedPtr > 0) THEN - if (GetCurrentScheduleValue(state, PurchAir(PurchAirNum).CoolSchedPtr) <= 0) { + if (PurchAir(PurchAirNum).coolAvailSched->getCurrentVal() <= 0) { CoolOn = false; } // END IF @@ -1344,7 +1330,7 @@ void InitPurchasedAir(EnergyPlusData &state, int const PurchAirNum, int const Co format("..the minimum supply air temperature for cooling [{:.2R}] is greater than the zone cooling mean air " "temperature (MAT) setpoint [{:.2R}].", PurchAir(PurchAirNum).MinCoolSuppAirTemp, - state.dataHeatBalFanSys->ZoneThermostatSetPointHi(ControlledZoneNum))); + zoneTstatSetpt.setptHi)); ShowContinueError(state, "..For operative and comfort thermostat controls, the MAT setpoint is computed."); ShowContinueError(state, "..This error may indicate that the mean radiant temperature or another comfort factor is too warm."); ShowContinueError(state, "Unit availability is nominally ON and Cooling availability is nominally ON."); @@ -1364,19 +1350,20 @@ void InitPurchasedAir(EnergyPlusData &state, int const PurchAirNum, int const Co "C"); } } - if (PurchAir(PurchAirNum).MaxHeatSuppAirTemp < state.dataHeatBalFanSys->ZoneThermostatSetPointLo(ControlledZoneNum) && - state.dataHeatBalFanSys->ZoneThermostatSetPointLo(ControlledZoneNum) != 0 && PurchAir(PurchAirNum).HeatingLimit == LimitType::NoLimit) { + + if (PurchAir(PurchAirNum).MaxHeatSuppAirTemp < zoneTstatSetpt.setptLo && + zoneTstatSetpt.setptLo != 0 && PurchAir(PurchAirNum).HeatingLimit == LimitType::NoLimit) { // Check if the unit is scheduled off UnitOn = true; // IF (PurchAir(PurchAirNum)%AvailSchedPtr > 0) THEN - if (GetCurrentScheduleValue(state, PurchAir(PurchAirNum).AvailSchedPtr) <= 0) { + if (PurchAir(PurchAirNum).availSched->getCurrentVal() <= 0) { UnitOn = false; } // END IF // Check if heating and cooling available HeatOn = true; // IF (PurchAir(PurchAirNum)%HeatSchedPtr > 0) THEN - if (GetCurrentScheduleValue(state, PurchAir(PurchAirNum).HeatSchedPtr) <= 0) { + if (PurchAir(PurchAirNum).heatAvailSched->getCurrentVal() <= 0) { HeatOn = false; } // END IF @@ -1391,7 +1378,7 @@ void InitPurchasedAir(EnergyPlusData &state, int const PurchAirNum, int const Co format("..the maximum supply air temperature for heating [{:.2R}] is less than the zone mean air temperature " "heating setpoint [{:.2R}].", PurchAir(PurchAirNum).MaxHeatSuppAirTemp, - state.dataHeatBalFanSys->ZoneThermostatSetPointLo(ControlledZoneNum))); + zoneTstatSetpt.setptLo)); ShowContinueError(state, "..For operative and comfort thermostat controls, the MAT setpoint is computed."); ShowContinueError(state, "..This error may indicate that the mean radiant temperature or another comfort factor is too cold."); ShowContinueError(state, "Unit availability is nominally ON and Heating availability is nominally ON."); @@ -2155,20 +2142,20 @@ void CalcPurchAirLoads(EnergyPlusData &state, // Check if the unit is scheduled off // IF (PurchAir(PurchAirNum)%AvailSchedPtr > 0) THEN - if (GetCurrentScheduleValue(state, PurchAir(PurchAirNum).AvailSchedPtr) <= 0) { + if (PurchAir(PurchAirNum).availSched->getCurrentVal() <= 0) { UnitOn = false; } // END IF // Check if heating and cooling available HeatOn = true; // IF (PurchAir(PurchAirNum)%HeatSchedPtr > 0) THEN - if (GetCurrentScheduleValue(state, PurchAir(PurchAirNum).HeatSchedPtr) <= 0) { + if (PurchAir(PurchAirNum).heatAvailSched->getCurrentVal() <= 0) { HeatOn = false; } // END IF CoolOn = true; // IF (PurchAir(PurchAirNum)%CoolSchedPtr > 0) THEN - if (GetCurrentScheduleValue(state, PurchAir(PurchAirNum).CoolSchedPtr) <= 0) { + if (PurchAir(PurchAirNum).coolAvailSched->getCurrentVal() <= 0) { CoolOn = false; } // END IF @@ -2197,7 +2184,7 @@ void CalcPurchAirLoads(EnergyPlusData &state, // Check if cooling of the supply air stream is required // Cooling operation - if ((MinOASensOutput >= QZnCoolSP) && (state.dataHeatBalFanSys->TempControlType(ControlledZoneNum) != HVAC::ThermostatType::SingleHeating)) { + if ((MinOASensOutput >= QZnCoolSP) && (state.dataHeatBalFanSys->TempControlType(ControlledZoneNum) != HVAC::SetptType::SingleHeat)) { OperatingMode = OpMode::Cool; // Calculate supply mass flow, temp and humidity with the following constraints: // Min cooling supply temp @@ -2509,7 +2496,7 @@ void CalcPurchAirLoads(EnergyPlusData &state, // Heating or no-load operation } else { // Heating or no-load case if ((MinOASensOutput < QZnHeatSP) && - (state.dataHeatBalFanSys->TempControlType(ControlledZoneNum) != HVAC::ThermostatType::SingleCooling)) { + (state.dataHeatBalFanSys->TempControlType(ControlledZoneNum) != HVAC::SetptType::SingleCool)) { OperatingMode = OpMode::Heat; } else { // DeadBand mode shuts off heat recovery and economizer OperatingMode = OpMode::DeadBand; diff --git a/src/EnergyPlus/PurchasedAirManager.hh b/src/EnergyPlus/PurchasedAirManager.hh index d8c7ee1c36d..1b47aa829d6 100644 --- a/src/EnergyPlus/PurchasedAirManager.hh +++ b/src/EnergyPlus/PurchasedAirManager.hh @@ -146,8 +146,7 @@ namespace PurchasedAirManager { // Members std::string cObjectName; // Name of the object from IDD std::string Name; // Name or identifier of this piece of equipment - std::string AvailSched; // System availability schedule - int AvailSchedPtr; // Index to system availability schedule + Sched::Schedule *availSched = nullptr; // System availability schedule int ZoneSupplyAirNodeNum; // Node number of zone supply air node for purchased air int ZoneExhaustAirNodeNum; // Node number of zone exhaust air node for purchased air int PlenumExhaustAirNodeNum; // Node number of plenum exhaust air node @@ -168,10 +167,8 @@ namespace PurchasedAirManager { // or LimitFlowRateAndCapacity Real64 MaxCoolVolFlowRate; // Maximum cooling supply air flow [m3/s] Real64 MaxCoolTotCap; // Maximum cooling total capacity [W] - std::string HeatSched; // Heating availablity schedule - int HeatSchedPtr; // Index to heating availability schedule - std::string CoolSched; // Cooling availability schedule - int CoolSchedPtr; // Index to the cooling availability schedule + Sched::Schedule *heatAvailSched = nullptr; // Heating availability schedule + Sched::Schedule *coolAvailSched = nullptr; // Index to the cooling availability schedule HumControl DehumidCtrlType; // Dehumidification control type - ConstantSensibleHeatRatio, // Humidistat, or ConstantSupplyHumidityRatio Real64 CoolSHR; // Cooling sensible heat ratio @@ -187,7 +184,7 @@ namespace PurchasedAirManager { HeatRecovery HtRecType; // Outdoor air heat recovery type - None, Sensible, Enthalpy Real64 HtRecSenEff; // Sensible heat recovery effectiveness Real64 HtRecLatEff; // Latent heat recovery effectiveness - int OAFlowFracSchPtr; // Fraction schedule applied to total OA requirement + Sched::Schedule *oaFlowFracSched = nullptr; // Fraction schedule applied to total OA requirement Real64 MaxHeatMassFlowRate; // The maximum heating air mass flow rate [kg/s] Real64 MaxCoolMassFlowRate; // The maximum cooling air mass flow rate [kg/s] bool EMSOverrideMdotOn; // if true, then EMS is calling to override supply mass flow rate @@ -281,13 +278,13 @@ namespace PurchasedAirManager { // Default Constructor ZonePurchasedAir() - : AvailSchedPtr(0), ZoneSupplyAirNodeNum(0), ZoneExhaustAirNodeNum(0), PlenumExhaustAirNodeNum(0), ReturnPlenumIndex(0), + : ZoneSupplyAirNodeNum(0), ZoneExhaustAirNodeNum(0), PlenumExhaustAirNodeNum(0), ReturnPlenumIndex(0), PurchAirArrayIndex(0), ZoneRecircAirNodeNum(0), MaxHeatSuppAirTemp(0.0), MinCoolSuppAirTemp(0.0), MaxHeatSuppAirHumRat(0.0), MinCoolSuppAirHumRat(0.0), HeatingLimit(LimitType::Invalid), MaxHeatVolFlowRate(0.0), MaxHeatSensCap(0.0), - CoolingLimit(LimitType::Invalid), MaxCoolVolFlowRate(0.0), MaxCoolTotCap(0.0), HeatSchedPtr(0), CoolSchedPtr(0), + CoolingLimit(LimitType::Invalid), MaxCoolVolFlowRate(0.0), MaxCoolTotCap(0.0), DehumidCtrlType(HumControl::Invalid), CoolSHR(0.0), HumidCtrlType(HumControl::Invalid), OARequirementsPtr(0), DCVType(DCV::Invalid), EconomizerType(Econ::Invalid), OutdoorAir(false), OutdoorAirNodeNum(0), HtRecType(HeatRecovery::Invalid), HtRecSenEff(0.0), - HtRecLatEff(0.0), OAFlowFracSchPtr(0), MaxHeatMassFlowRate(0.0), MaxCoolMassFlowRate(0.0), EMSOverrideMdotOn(false), + HtRecLatEff(0.0), MaxHeatMassFlowRate(0.0), MaxCoolMassFlowRate(0.0), EMSOverrideMdotOn(false), EMSValueMassFlowRate(0.0), EMSOverrideOAMdotOn(false), EMSValueOAMassFlowRate(0.0), EMSOverrideSupplyTempOn(false), EMSValueSupplyTemp(0.0), EMSOverrideSupplyHumRatOn(false), EMSValueSupplyHumRat(0.0), MinOAMassFlowRate(0.0), OutdoorAirMassFlowRate(0.0), OutdoorAirVolFlowRateStdRho(0.0), SupplyAirMassFlowRate(0.0), SupplyAirVolFlowRateStdRho(0.0), @@ -408,6 +405,10 @@ struct PurchasedAirManagerData : BaseGlobalStruct Array1D TempPurchAirPlenumArrays; // Used to save the indices of scalable sizing object for zone HVAC + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/RefrigeratedCase.cc b/src/EnergyPlus/RefrigeratedCase.cc index ec4e4873db0..895c36e7eb4 100644 --- a/src/EnergyPlus/RefrigeratedCase.cc +++ b/src/EnergyPlus/RefrigeratedCase.cc @@ -306,9 +306,8 @@ void GetRefrigerationInput(EnergyPlusData &state) static constexpr std::string_view TrackMessage("from refrigerated case"); static constexpr std::string_view RoutineName("GetRefrigerationInput: "); static constexpr std::string_view TrackMessageAlt("GetInput in RefrigeratedCase"); - static constexpr std::string_view RoutineNameNoColon("GetRefrigerationInput"); + static constexpr std::string_view routineName = "GetRefrigerationInput"; - int constexpr AlwaysOn(-1); // -1 pointer sent to schedule manager returns a value of 1.0 // input in both watts and flow rate int constexpr NumWIAlphaFieldsBeforeZoneInput(9); // Used to cycle through zones on input for walk in coolers int constexpr NumWIAlphaFieldsPerZone(4); // Used to cycle through zones on input for walk in coolers @@ -503,7 +502,7 @@ void GetRefrigerationInput(EnergyPlusData &state) if (NumCompressorLists > 0) CompressorLists.allocate(NumCompressorLists); if (state.dataRefrigCase->NumSimulationTransferLoadLists > 0) TransferLoadList.allocate(state.dataRefrigCase->NumSimulationTransferLoadLists); - DayValues.allocate(state.dataGlobal->NumOfTimeStepInHour, 24); + DayValues.allocate(state.dataGlobal->TimeStepsInHour, Constant::iHoursInDay); state.dataRefrigCase->RefrigPresentInZone.dimension(state.dataGlobal->NumOfZones, false); state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, "Refrigeration:Case", MaxNumArgs, MaxNumAlphasCase, MaxNumNumbersCase); @@ -589,6 +588,8 @@ void GetRefrigerationInput(EnergyPlusData &state) cAlphaFieldNames, cNumericFieldNames); + ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)}; + ++NumDisplayCases; AlphaNum = 1; @@ -596,30 +597,14 @@ void GetRefrigerationInput(EnergyPlusData &state) RefrigCase(CaseNum).Name = Alphas(AlphaNum); AlphaNum = 2; - if (!lAlphaBlanks(AlphaNum)) { - RefrigCase(CaseNum).SchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(AlphaNum)); // convert schedule name to pointer - if (RefrigCase(CaseNum).SchedPtr == 0) { - ShowSevereError(state, - format("{}{}=\"{}\", invalid {} not found: {}", - RoutineName, - CurrentModuleObject, - RefrigCase(CaseNum).Name, - cAlphaFieldNames(AlphaNum), - Alphas(AlphaNum))); - ErrorsFound = true; - } // ptr == 0 - } else { // no schedule specified - RefrigCase(CaseNum).SchedPtr = AlwaysOn; - } // not blank - - // check availability schedule for values between 0 and 1 - if (RefrigCase(CaseNum).SchedPtr > 0) { - if (!ScheduleManager::CheckScheduleValueMinMax(state, RefrigCase(CaseNum).SchedPtr, ">=", 0.0, "<=", 1.0)) { - ShowSevereError(state, format("{}{}=\"{}\"", RoutineName, CurrentModuleObject, RefrigCase(CaseNum).Name)); - ShowContinueError(state, format("Error found in {} = {}", cAlphaFieldNames(AlphaNum), Alphas(AlphaNum))); - ShowContinueError(state, "schedule values must be (>=0., <=1.)"); - ErrorsFound = true; - } + if (lAlphaBlanks(AlphaNum)) { + RefrigCase(CaseNum).availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((RefrigCase(CaseNum).availSched = Sched::GetSchedule(state, Alphas(AlphaNum))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum)); + ErrorsFound = true; + } else if (!RefrigCase(CaseNum).availSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) { + Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum), Clusive::In, 0.0, Clusive::In, 1.0); + ErrorsFound = true; } // Get the Zone node number from the zone name entered by the user @@ -824,29 +809,13 @@ void GetRefrigerationInput(EnergyPlusData &state) } // blank input if (!lAlphaBlanks(6)) { - RefrigCase(CaseNum).LightingSchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(6)); // convert schedule name to pointer - if (RefrigCase(CaseNum).LightingSchedPtr == 0) { - ShowSevereError(state, - format("{}{}=\"{}\", invalid {} not found: {}", - RoutineName, - CurrentModuleObject, - RefrigCase(CaseNum).Name, - cAlphaFieldNames(6), - Alphas(6))); - ErrorsFound = true; - } // ptr == 0 - } else { // no schedule specified - RefrigCase(CaseNum).LightingSchedPtr = AlwaysOn; - } // not blank - - // check lighting schedule for values between 0 and 1 - if (RefrigCase(CaseNum).LightingSchedPtr > 0) { - if (!ScheduleManager::CheckScheduleValueMinMax(state, RefrigCase(CaseNum).LightingSchedPtr, ">=", 0.0, "<=", 1.0)) { - ShowSevereError(state, format("{}{}=\"{}\"", RoutineName, CurrentModuleObject, RefrigCase(CaseNum).Name)); - ShowContinueError(state, format("Error found in {} = {}", cAlphaFieldNames(6), Alphas(6))); - ShowContinueError(state, "schedule values must be (>=0., <=1.)"); - ErrorsFound = true; - } + RefrigCase(CaseNum).lightingSched = Sched::GetScheduleAlwaysOn(state); + } else if ((RefrigCase(CaseNum).lightingSched = Sched::GetSchedule(state, Alphas(6))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(6), Alphas(6)); + ErrorsFound = true; + } else if (!RefrigCase(CaseNum).lightingSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) { + Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(6), Alphas(6), Clusive::In, 0.0, Clusive::In, 1.0); + ErrorsFound = true; } NumNum = 12; @@ -1071,28 +1040,19 @@ void GetRefrigerationInput(EnergyPlusData &state) ErrorsFound = true; } - RefrigCase(CaseNum).DefrostSchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(9)); // convert schedule name to pointer - if (RefrigCase(CaseNum).DefrostSchedPtr == 0 && RefrigCase(CaseNum).defrostType != RefCaseDefrostType::None) { - ShowSevereError(state, - format("{}{}=\"{}\", invalid {} not found: {}", - RoutineName, - CurrentModuleObject, - RefrigCase(CaseNum).Name, - cAlphaFieldNames(9), - Alphas(9))); - ShowContinueError(state, format("required when {}=\"{}\".", cAlphaFieldNames(8), Alphas(8))); + if (RefrigCase(CaseNum).defrostType == RefCaseDefrostType::None) { + RefrigCase(CaseNum).defrostSched = Sched::GetScheduleAlwaysOff(state); + } else if (lAlphaBlanks(9)) { + ShowSevereEmptyField(state, eoh, cAlphaFieldNames(9)); + ErrorsFound = true; + } else if ((RefrigCase(CaseNum).defrostSched = Sched::GetSchedule(state, Alphas(9))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(9), Alphas(9)); + ErrorsFound = true; + } else if (!RefrigCase(CaseNum).defrostSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) { + Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(9), Alphas(9), Clusive::In, 0.0, Clusive::In, 1.0); ErrorsFound = true; } - - // check defrost schedule for values between 0 and 1 - if (RefrigCase(CaseNum).DefrostSchedPtr > 0) { - if (!ScheduleManager::CheckScheduleValueMinMax(state, RefrigCase(CaseNum).DefrostSchedPtr, ">=", 0.0, "<=", 1.0)) { - ShowSevereError(state, format("{}{}=\"{}\".", RoutineName, CurrentModuleObject, RefrigCase(CaseNum).Name)); - ShowContinueError(state, format("Error found in {} = {}", cAlphaFieldNames(9), Alphas(9))); - ShowContinueError(state, "schedule values must be (>=0., <=1.)"); - ErrorsFound = true; - } - } + // Note that next section counting number cycles and setting maxkgfrost not used now, but may be in the future. // count the number of defrost cycles @@ -1100,9 +1060,9 @@ void GetRefrigerationInput(EnergyPlusData &state) bool StartCycle = false; int NumDefCycles = 0; DayValues = 0.0; - ScheduleManager::GetScheduleValuesForDay(state, RefrigCase(CaseNum).DefrostSchedPtr, DayValues, 1); + RefrigCase(CaseNum).defrostSched->getDayVals(state, DayValues, 1); for (int HRNum = 1; HRNum <= 24; ++HRNum) { - for (int TSNum = 1; TSNum <= state.dataGlobal->NumOfTimeStepInHour; ++TSNum) { + for (int TSNum = 1; TSNum <= state.dataGlobal->TimeStepsInHour; ++TSNum) { if (DayValues(TSNum, HRNum) > 0.0) { if (!StartCycle) { ++NumDefCycles; @@ -1124,31 +1084,14 @@ void GetRefrigerationInput(EnergyPlusData &state) } // some defrost types do not use drip-down schedules, use same defrost schedule pointer in that case - if (!lAlphaBlanks(10)) { - RefrigCase(CaseNum).DefrostDripDownSchedPtr = - ScheduleManager::GetScheduleIndex(state, Alphas(10)); // convert schedule name to pointer - if (RefrigCase(CaseNum).DefrostDripDownSchedPtr == 0) { - ShowSevereError(state, - format("{}{}=\"{}\", invalid {} not found: {}", - RoutineName, - CurrentModuleObject, - RefrigCase(CaseNum).Name, - cAlphaFieldNames(10), - Alphas(10))); - ErrorsFound = true; - } - } else { - RefrigCase(CaseNum).DefrostDripDownSchedPtr = RefrigCase(CaseNum).DefrostSchedPtr; - } - - // check defrost drip-down schedule for values between 0 and 1 - if (RefrigCase(CaseNum).DefrostDripDownSchedPtr > 0 && (!lAlphaBlanks(10))) { - if (!ScheduleManager::CheckScheduleValueMinMax(state, RefrigCase(CaseNum).DefrostDripDownSchedPtr, ">=", 0.0, "<=", 1.0)) { - ShowSevereError(state, format("{}{}=\"{}\".", RoutineName, CurrentModuleObject, RefrigCase(CaseNum).Name)); - ShowContinueError(state, format("Error found in {} = {}", cAlphaFieldNames(10), Alphas(10))); - ShowContinueError(state, "schedule values must be (>=0., <=1.)"); - ErrorsFound = true; - } + if (lAlphaBlanks(10)) { + RefrigCase(CaseNum).defrostDripDownSched = RefrigCase(CaseNum).defrostSched; + } else if ((RefrigCase(CaseNum).defrostDripDownSched = Sched::GetSchedule(state, Alphas(10))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(10), Alphas(10)); + ErrorsFound = true; + } else if (!RefrigCase(CaseNum).defrostDripDownSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) { + Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(10), Alphas(10), Clusive::In, 0.0, Clusive::In, 1.0); + ErrorsFound = true; } if (Util::SameString(Alphas(11), "CaseTemperatureMethod")) { @@ -1280,20 +1223,10 @@ void GetRefrigerationInput(EnergyPlusData &state) CaseRAFraction(RefrigCase(CaseNum).ActualZoneNum).ZoneName = RefrigCase(CaseNum).ZoneName; } - RefrigCase(CaseNum).StockingSchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(13)); // convert schedule name to pointer - if (!lAlphaBlanks(13)) { - if (RefrigCase(CaseNum).StockingSchedPtr == 0) { - ShowSevereError(state, - format("{}{}=\"{}\", invalid {} not found: {}", - RoutineName, - CurrentModuleObject, - RefrigCase(CaseNum).Name, - cAlphaFieldNames(13), - Alphas(13))); - ErrorsFound = true; - } - } else { - RefrigCase(CaseNum).StockingSchedPtr = 0; + if (lAlphaBlanks(13)) { + } else if ((RefrigCase(CaseNum).stockingSched = Sched::GetSchedule(state, Alphas(13))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(13), Alphas(13)); + ErrorsFound = true; } // calculate sensible case load at design conditions @@ -1321,30 +1254,13 @@ void GetRefrigerationInput(EnergyPlusData &state) ErrorsFound = true; } - RefrigCase(CaseNum).CaseCreditFracSchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(14)); // convert schedule name to pointer - if (!lAlphaBlanks(14)) { - if (RefrigCase(CaseNum).CaseCreditFracSchedPtr == 0) { - ShowSevereError(state, - format("{}{}=\"{}\", invalid {} not found: {}", - RoutineName, - CurrentModuleObject, - RefrigCase(CaseNum).Name, - cAlphaFieldNames(14), - Alphas(14))); - ErrorsFound = true; - } - } else { - RefrigCase(CaseNum).CaseCreditFracSchedPtr = 0; - } - - // check case credit fraction schedule for values between 0 and 1 - if (RefrigCase(CaseNum).CaseCreditFracSchedPtr > 0) { - if (!ScheduleManager::CheckScheduleValueMinMax(state, RefrigCase(CaseNum).CaseCreditFracSchedPtr, ">=", 0.0, "<=", 1.0)) { - ShowSevereError(state, format("{}{}=\"{}\".", RoutineName, CurrentModuleObject, RefrigCase(CaseNum).Name)); - ShowContinueError(state, format("Error found in {} = {}", cAlphaFieldNames(14), Alphas(14))); - ShowContinueError(state, "schedule values must be (>=0., <=1.)"); - ErrorsFound = true; - } + if (lAlphaBlanks(14)) { + } else if ((RefrigCase(CaseNum).caseCreditFracSched = Sched::GetSchedule(state, Alphas(14))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(14), Alphas(14)); + ErrorsFound = true; + } else if (!RefrigCase(CaseNum).caseCreditFracSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) { + Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(14), Alphas(14), Clusive::In, 0.0, Clusive::In, 1.0); + ErrorsFound = true; } RefrigCase(CaseNum).DesignRatedCap = RefrigCase(CaseNum).RateTotCapPerLength * RefrigCase(CaseNum).Length; @@ -1410,34 +1326,21 @@ void GetRefrigerationInput(EnergyPlusData &state) lAlphaBlanks, cAlphaFieldNames, cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)}; + Util::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound); WalkIn(WalkInID).Name = Alphas(1); - if (!lAlphaBlanks(2)) { - WalkIn(WalkInID).SchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(2)); // convert schedule name to pointer - if (WalkIn(WalkInID).SchedPtr == 0) { - ShowSevereError(state, - format("{}{}=\"{}\", invalid {} not found: {}", - RoutineName, - CurrentModuleObject, - WalkIn(WalkInID).Name, - cAlphaFieldNames(2), - Alphas(2))); - ErrorsFound = true; - } // ptr == 0 - } else { // no schedule specified - WalkIn(WalkInID).SchedPtr = AlwaysOn; - } // not blank - - // check availability schedule for values between 0 and 1 - if (WalkIn(WalkInID).SchedPtr > 0) { - if (!ScheduleManager::CheckScheduleValueMinMax(state, WalkIn(WalkInID).SchedPtr, ">=", 0.0, "<=", 1.0)) { - ShowSevereError(state, format("{}{}=\"{}\"", RoutineName, CurrentModuleObject, WalkIn(WalkInID).Name)); - ShowContinueError(state, format("Error found in {} = {}", cAlphaFieldNames(2), Alphas(2))); - ShowContinueError(state, "schedule values must be (>=0., <=1.)"); - ErrorsFound = true; - } + if (lAlphaBlanks(2)) { + WalkIn(WalkInID).availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((WalkIn(WalkInID).availSched = Sched::GetSchedule(state, Alphas(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(2), Alphas(2)); + ErrorsFound = true; + } else if (!WalkIn(WalkInID).availSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) { + Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(2), Alphas(2), Clusive::In, 0.0, Clusive::In, 1.0); + ErrorsFound = true; } WalkIn(WalkInID).DesignRatedCap = Numbers(1); @@ -1474,31 +1377,14 @@ void GetRefrigerationInput(EnergyPlusData &state) } AlphaNum = 3; - if (!lAlphaBlanks(AlphaNum)) { - WalkIn(WalkInID).HeaterSchedPtr = - ScheduleManager::GetScheduleIndex(state, Alphas(AlphaNum)); // convert heater schedule name to pointer - if (WalkIn(WalkInID).HeaterSchedPtr == 0) { - ShowSevereError(state, - format("{}{}=\"{}\", invalid {} not found: {}", - RoutineName, - CurrentModuleObject, - WalkIn(WalkInID).Name, - cAlphaFieldNames(AlphaNum), - Alphas(AlphaNum))); - ErrorsFound = true; - } // ptr == 0 - } else { // no schedule specified - WalkIn(WalkInID).HeaterSchedPtr = AlwaysOn; - } // not blank - - // check heater schedule for values between 0 and 1 - if (WalkIn(WalkInID).HeaterSchedPtr > 0) { - if (!ScheduleManager::CheckScheduleValueMinMax(state, WalkIn(WalkInID).HeaterSchedPtr, ">=", 0.0, "<=", 1.0)) { - ShowSevereError(state, format("{}{}=\"{}\"", RoutineName, CurrentModuleObject, WalkIn(WalkInID).Name)); - ShowContinueError(state, format("Error found in {} = {}", cAlphaFieldNames(AlphaNum), Alphas(AlphaNum))); - ShowContinueError(state, "schedule values must be (>=0., <=1.)"); - ErrorsFound = true; - } + if (lAlphaBlanks(AlphaNum)) { + WalkIn(WalkInID).heaterSched = Sched::GetScheduleAlwaysOn(state); + } else if ((WalkIn(WalkInID).heaterSched = Sched::GetSchedule(state, Alphas(AlphaNum))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum)); + ErrorsFound = true; + } else if (!WalkIn(WalkInID).heaterSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) { + Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum), Clusive::In, 0.0, Clusive::In, 1.0); + ErrorsFound = true; } if (!lNumericBlanks(5) && Numbers(5) > 0.0) { @@ -1537,30 +1423,14 @@ void GetRefrigerationInput(EnergyPlusData &state) } AlphaNum = 4; - if (!lAlphaBlanks(AlphaNum)) { - WalkIn(WalkInID).LightingSchedPtr = - ScheduleManager::GetScheduleIndex(state, Alphas(AlphaNum)); // convert lighting schedule name to pointer - if (WalkIn(WalkInID).LightingSchedPtr == 0) { - ShowSevereError(state, - format("{}{}=\"{}\", invalid {} not found: {}", - RoutineName, - CurrentModuleObject, - WalkIn(WalkInID).Name, - cAlphaFieldNames(AlphaNum), - Alphas(AlphaNum))); - ErrorsFound = true; - } // ptr == 0 - } else { // no schedule specified - WalkIn(WalkInID).LightingSchedPtr = AlwaysOn; - } // schedule name not blank - // check Lighting schedule for values between 0 and 1 - if (WalkIn(WalkInID).LightingSchedPtr > 0) { - if (!ScheduleManager::CheckScheduleValueMinMax(state, WalkIn(WalkInID).LightingSchedPtr, ">=", 0.0, "<=", 1.0)) { - ShowSevereError(state, format("{}{}=\"{}\"", RoutineName, CurrentModuleObject, WalkIn(WalkInID).Name)); - ShowContinueError(state, format("Error found in {} = {}", cAlphaFieldNames(AlphaNum), Alphas(AlphaNum))); - ShowContinueError(state, "schedule values must be (>=0., <=1.)"); - ErrorsFound = true; - } + if (lAlphaBlanks(AlphaNum)) { + WalkIn(WalkInID).lightingSched = Sched::GetScheduleAlwaysOn(state); + } else if ((WalkIn(WalkInID).lightingSched = Sched::GetSchedule(state, Alphas(AlphaNum))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum)); + ErrorsFound = true; + } else if (!WalkIn(WalkInID).lightingSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) { + Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum), Clusive::In, 0.0, Clusive::In, 1.0); + ErrorsFound = true; } // Input walk-in cooler defrost information @@ -1602,53 +1472,29 @@ void GetRefrigerationInput(EnergyPlusData &state) // convert defrost schedule name to pointer AlphaNum = 7; - WalkIn(WalkInID).DefrostSchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(AlphaNum)); - if (WalkIn(WalkInID).DefrostSchedPtr == 0) { - ShowSevereError(state, - format("{}{}=\"{}\", invalid {} not found: {}", - RoutineName, - CurrentModuleObject, - WalkIn(WalkInID).Name, - cAlphaFieldNames(AlphaNum), - Alphas(AlphaNum))); + + if (lAlphaBlanks(AlphaNum)) { + ShowSevereEmptyField(state, eoh, cAlphaFieldNames(AlphaNum)); + ErrorsFound = true; + } else if ((WalkIn(WalkInID).defrostSched = Sched::GetSchedule(state, Alphas(AlphaNum))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum)); + ErrorsFound = true; + } else if (!WalkIn(WalkInID).defrostSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) { + Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum), Clusive::In, 0.0, Clusive::In, 1.0); ErrorsFound = true; - } - // check defrost schedule for values between 0 and 1 - if (WalkIn(WalkInID).DefrostSchedPtr > 0) { - if (!ScheduleManager::CheckScheduleValueMinMax(state, WalkIn(WalkInID).DefrostSchedPtr, ">=", 0.0, "<=", 1.0)) { - ShowSevereError(state, format("{}{} = \"{}\"", RoutineName, CurrentModuleObject, WalkIn(WalkInID).Name)); - ShowContinueError(state, format("Error found in {}={}", cAlphaFieldNames(AlphaNum), Alphas(AlphaNum))); - ShowContinueError(state, "schedule values must be (>=0., <=1.)"); - ErrorsFound = true; - } } // convert defrost drip-down schedule name to pointer // some defrost types do not use drip-down schedules, use same defrost schedule pointer in that case AlphaNum = 8; - if (!lAlphaBlanks(AlphaNum)) { - WalkIn(WalkInID).DefrostDripDownSchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(AlphaNum)); - if (WalkIn(WalkInID).DefrostDripDownSchedPtr == 0) { - ShowSevereError(state, - format("{}{}=\"{}\", invalid {} not found: {}", - RoutineName, - CurrentModuleObject, - WalkIn(WalkInID).Name, - cAlphaFieldNames(AlphaNum), - Alphas(AlphaNum))); - ErrorsFound = true; - } - // check schedule for values between 0 and 1 - if (WalkIn(WalkInID).DefrostDripDownSchedPtr > 0) { - if (!ScheduleManager::CheckScheduleValueMinMax(state, WalkIn(WalkInID).DefrostDripDownSchedPtr, ">=", 0.0, "<=", 1.0)) { - ShowSevereError(state, format("{}{}=\"{}\"", RoutineName, CurrentModuleObject, WalkIn(WalkInID).Name)); - ShowContinueError(state, format("Error found in {} = {}", cAlphaFieldNames(AlphaNum), Alphas(AlphaNum))); - ShowContinueError(state, "schedule values must be (>=0., <=1.)"); - ErrorsFound = true; - } - } - } else { // blank input so use drip down schedule for defrost - WalkIn(WalkInID).DefrostDripDownSchedPtr = WalkIn(WalkInID).DefrostSchedPtr; + if (lAlphaBlanks(AlphaNum)) { // blank input so use drip down schedule for defrost + WalkIn(WalkInID).defrostDripDownSched = WalkIn(WalkInID).defrostSched; + } else if ((WalkIn(WalkInID).defrostDripDownSched = Sched::GetSchedule(state, Alphas(AlphaNum))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum)); + ErrorsFound = true; + } else if (!WalkIn(WalkInID).defrostDripDownSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) { + Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum), Clusive::In, 0.0, Clusive::In, 1.0); + ErrorsFound = true; } if (WalkIn(WalkInID).defrostType == WalkinClrDefrostType::OffCycle || WalkIn(WalkInID).defrostType == WalkinClrDefrostType::None) { @@ -1690,20 +1536,10 @@ void GetRefrigerationInput(EnergyPlusData &state) // convert restocking schedule name to pointer, default of 0.1 is assigned inside walkin subroutine if blank AlphaNum = 9; if (lAlphaBlanks(AlphaNum)) { - WalkIn(WalkInID).StockingSchedPtr = 0; - } else { - WalkIn(WalkInID).StockingSchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(AlphaNum)); - if (WalkIn(WalkInID).StockingSchedPtr == 0) { - ShowSevereError(state, - format("{}{}=\"{}\", invalid {} not found: {}", - RoutineName, - CurrentModuleObject, - WalkIn(WalkInID).Name, - cAlphaFieldNames(AlphaNum), - Alphas(AlphaNum))); - ErrorsFound = true; - } - } // blank + } else if ((WalkIn(WalkInID).stockingSched = Sched::GetSchedule(state, Alphas(AlphaNum))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum)); + ErrorsFound = true; + } WalkIn(WalkInID).DesignRefrigInventory = 0.0; if (!lNumericBlanks(10)) WalkIn(WalkInID).DesignRefrigInventory = Numbers(10); @@ -1748,11 +1584,11 @@ void GetRefrigerationInput(EnergyPlusData &state) if (!allocated(WalkIn(WalkInID).SurfaceArea)) WalkIn(WalkInID).SurfaceArea.allocate(NumZones) = 0.0; if (!allocated(WalkIn(WalkInID).UValue)) WalkIn(WalkInID).UValue.allocate(NumZones) = 0.0; if (!allocated(WalkIn(WalkInID).UValueGlassDr)) WalkIn(WalkInID).UValueGlassDr.allocate(NumZones) = 0.0; - if (!allocated(WalkIn(WalkInID).GlassDoorOpenSchedPtr)) WalkIn(WalkInID).GlassDoorOpenSchedPtr.allocate(NumZones) = 0; + if (!allocated(WalkIn(WalkInID).glassDoorOpenScheds)) WalkIn(WalkInID).glassDoorOpenScheds.allocate(NumZones) = nullptr; // What is this? if (!allocated(WalkIn(WalkInID).AreaGlassDr)) WalkIn(WalkInID).AreaGlassDr.allocate(NumZones) = 0.0; if (!allocated(WalkIn(WalkInID).HeightGlassDr)) WalkIn(WalkInID).HeightGlassDr.allocate(NumZones) = 0.0; if (!allocated(WalkIn(WalkInID).UValueStockDr)) WalkIn(WalkInID).UValueStockDr.allocate(NumZones) = 0.0; - if (!allocated(WalkIn(WalkInID).StockDoorOpenSchedPtr)) WalkIn(WalkInID).StockDoorOpenSchedPtr.allocate(NumZones) = 0; + if (!allocated(WalkIn(WalkInID).stockDoorOpenScheds)) WalkIn(WalkInID).stockDoorOpenScheds.allocate(NumZones) = nullptr; // What is this? if (!allocated(WalkIn(WalkInID).StockDoorProtectType)) WalkIn(WalkInID).StockDoorProtectType.allocate(NumZones) = WIStockDoor::Invalid; if (!allocated(WalkIn(WalkInID).AreaStockDr)) WalkIn(WalkInID).AreaStockDr.allocate(NumZones) = 0.0; if (!allocated(WalkIn(WalkInID).HeightStockDr)) WalkIn(WalkInID).HeightStockDr.allocate(NumZones) = 0.0; @@ -1843,34 +1679,12 @@ void GetRefrigerationInput(EnergyPlusData &state) // convert door opening schedule name to pointer, default of 0.1 is assigned inside walkin subroutine if blank if (lAlphaBlanks(AStart + 1)) { - WalkIn(WalkInID).GlassDoorOpenSchedPtr(ZoneID) = 0; - } else { - WalkIn(WalkInID).GlassDoorOpenSchedPtr(ZoneID) = ScheduleManager::GetScheduleIndex(state, Alphas(AStart + 1)); - if (WalkIn(WalkInID).GlassDoorOpenSchedPtr(ZoneID) == 0) { - ShowSevereError(state, - format(R"({}{}="{}", Zone="{}", invalid {} not found: {})", - RoutineName, - CurrentModuleObject, - WalkIn(WalkInID).Name, - WalkIn(WalkInID).ZoneName(ZoneID), - cAlphaFieldNames(AStart + 1), - Alphas(AStart + 1))); - ErrorsFound = true; - } else { - // check schedule for values between 0 and 1 - if (!ScheduleManager::CheckScheduleValueMinMax( - state, WalkIn(WalkInID).GlassDoorOpenSchedPtr(ZoneID), ">=", 0.0, "<=", 1.0)) { - ShowSevereError(state, - format(R"({}{}="{}", Zone="{}")", - RoutineName, - CurrentModuleObject, - WalkIn(WalkInID).Name, - WalkIn(WalkInID).ZoneName(ZoneID))); - ShowContinueError(state, format("Error found in {} = {}", cAlphaFieldNames(AStart + 1), Alphas(AStart + 1))); - ShowContinueError(state, "schedule values must be (>=0., <=1.)"); - ErrorsFound = true; - } // schedule values outside range - } // have schedule pointer + } else if ((WalkIn(WalkInID).glassDoorOpenScheds(ZoneID) = Sched::GetSchedule(state, Alphas(AStart + 1))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(AStart + 1), Alphas(AStart + 1)); + ErrorsFound = true; + } else if (!WalkIn(WalkInID).glassDoorOpenScheds(ZoneID)->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) { + Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(AStart + 1), Alphas(AStart + 1), Clusive::In, 0.0, Clusive::In, 1.0); + ErrorsFound = true; } // blank on door opening schedule (AStart + 1) } // have glassdoor area facing zone (blank on lNumericBlanks(NStart+2)) @@ -1889,34 +1703,12 @@ void GetRefrigerationInput(EnergyPlusData &state) // convert door opening schedule name to pointer, default of 0.1 is assigned inside walkin subroutine if blank if (lAlphaBlanks(AStart + 2)) { - WalkIn(WalkInID).StockDoorOpenSchedPtr(ZoneID) = 0; - } else { - WalkIn(WalkInID).StockDoorOpenSchedPtr(ZoneID) = ScheduleManager::GetScheduleIndex(state, Alphas(AStart + 2)); - if (WalkIn(WalkInID).StockDoorOpenSchedPtr(ZoneID) == 0) { - ShowSevereError(state, - format(R"({}{}="{}", Zone="{}", invalid {} not found: {})", - RoutineName, - CurrentModuleObject, - WalkIn(WalkInID).Name, - WalkIn(WalkInID).ZoneName(ZoneID), - cAlphaFieldNames(AStart + 2), - Alphas(AStart + 2))); - ErrorsFound = true; - } else { - // check schedule for values between 0 and 1 - if (!ScheduleManager::CheckScheduleValueMinMax( - state, WalkIn(WalkInID).StockDoorOpenSchedPtr(ZoneID), ">=", 0.0, "<=", 1.0)) { - ShowSevereError(state, - format(R"({}{}="{}", Zone="{}")", - RoutineName, - CurrentModuleObject, - WalkIn(WalkInID).Name, - WalkIn(WalkInID).ZoneName(ZoneID))); - ShowContinueError(state, format("Error found in {} = {}", cAlphaFieldNames(AStart + 2), Alphas(AStart + 2))); - ShowContinueError(state, "schedule values must be (>=0., <=1.)"); - ErrorsFound = true; - } // schedule values outside range - } // have schedule pointer + } else if ((WalkIn(WalkInID).stockDoorOpenScheds(ZoneID) = Sched::GetSchedule(state, Alphas(AStart + 2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(AStart + 2), Alphas(AStart + 2)); + ErrorsFound = true; + } else if (!WalkIn(WalkInID).stockDoorOpenScheds(ZoneID)->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) { + Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(AStart + 2), Alphas(AStart + 2), Clusive::In, 0.0, Clusive::In, 1.0); + ErrorsFound = true; } // blank on door opening schedule (AStart + 2) if (lAlphaBlanks(AStart + 3) || Util::SameString(Alphas(AStart + 3), "AirCurtain")) { @@ -1963,36 +1755,23 @@ void GetRefrigerationInput(EnergyPlusData &state) lAlphaBlanks, cAlphaFieldNames, cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)}; + Util::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound); WarehouseCoil(CoilID).Name = Alphas(AlphaNum); // A2 ++AlphaNum; - if (!lAlphaBlanks(AlphaNum)) { - WarehouseCoil(CoilID).SchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(AlphaNum)); // convert schedule name to pointer - if (WarehouseCoil(CoilID).SchedPtr == 0) { - ShowSevereError(state, - format("{}{}=\"{}\", invalid {} not found: {}", - RoutineName, - CurrentModuleObject, - WarehouseCoil(CoilID).Name, - cAlphaFieldNames(AlphaNum), - Alphas(AlphaNum))); - ErrorsFound = true; - } // ptr == 0 - } else { // no schedule specified - WarehouseCoil(CoilID).SchedPtr = AlwaysOn; - } // not blank - - // check availability schedule for values between 0 and 1 - if (WarehouseCoil(CoilID).SchedPtr > 0) { - if (!ScheduleManager::CheckScheduleValueMinMax(state, WarehouseCoil(CoilID).SchedPtr, ">=", 0.0, "<=", 1.0)) { - ShowSevereError(state, format("{}{}=\"{}\"", RoutineName, CurrentModuleObject, WarehouseCoil(CoilID).Name)); - ShowContinueError(state, format("Error found in {} = {}", cAlphaFieldNames(AlphaNum), Alphas(AlphaNum))); - ShowContinueError(state, "schedule values must be (>=0., <=1.)"); - ErrorsFound = true; - } + if (lAlphaBlanks(AlphaNum)) { + WarehouseCoil(CoilID).availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((WarehouseCoil(CoilID).availSched = Sched::GetSchedule(state, Alphas(AlphaNum))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum)); + ErrorsFound = true; + } else if (!WarehouseCoil(CoilID).availSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) { + Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum), Clusive::In, 0.0, Clusive::In, 1.0); + ErrorsFound = true; } // Input capacity rating type @@ -2463,36 +2242,20 @@ void GetRefrigerationInput(EnergyPlusData &state) if (!lNumericBlanks(NumNum)) { WarehouseCoil(CoilID).HeaterPower = Numbers(NumNum); } else { - ShowSevereError(state, - std::string{RoutineName} + CurrentModuleObject + "=\"" + WarehouseCoil(CoilID).Name + "\", " + - cNumericFieldNames(NumNum) + " must be input "); + ShowSevereEmptyField(state, eoh, cNumericFieldNames(NumNum)); ErrorsFound = true; } ++AlphaNum; // A6 if (!lAlphaBlanks(AlphaNum)) { - WarehouseCoil(CoilID).HeaterSchedPtr = - ScheduleManager::GetScheduleIndex(state, Alphas(AlphaNum)); // convert heater schedule name to pointer - if (WarehouseCoil(CoilID).HeaterSchedPtr == 0) { - ShowSevereError(state, - format("{}{}=\"{}\", invalid {} not found: {}", - RoutineName, - CurrentModuleObject, - WarehouseCoil(CoilID).Name, - cAlphaFieldNames(AlphaNum), - Alphas(AlphaNum))); - ErrorsFound = true; - } else { // check heater schedule for values between 0 and 1 - if (!ScheduleManager::CheckScheduleValueMinMax(state, WarehouseCoil(CoilID).HeaterSchedPtr, ">=", 0.0, "<=", 1.0)) { - ShowSevereError(state, format("{}{}=\"{}\"", RoutineName, CurrentModuleObject, WarehouseCoil(CoilID).Name)); - ShowContinueError(state, format("Error found in {} = {}", cAlphaFieldNames(AlphaNum), Alphas(AlphaNum))); - ShowContinueError(state, "schedule values must be (>=0., <=1.)"); - ErrorsFound = true; - } // heater schedule ptr == 0 - } // htr sched == 0 - } else { // lalphaBlanks, no schedule specified - WarehouseCoil(CoilID).HeaterSchedPtr = AlwaysOn; - } // not blank + WarehouseCoil(CoilID).heaterAvailSched = Sched::GetScheduleAlwaysOn(state); + } else if ((WarehouseCoil(CoilID).heaterAvailSched = Sched::GetSchedule(state, Alphas(AlphaNum))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum)); + ErrorsFound = true; + } else if (!WarehouseCoil(CoilID).heaterAvailSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) { + Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum), Clusive::In, 0.0, Clusive::In, 1.0); + ErrorsFound = true; + } // Input fan control type ++AlphaNum; // A7 @@ -2583,50 +2346,30 @@ void GetRefrigerationInput(EnergyPlusData &state) // convert defrost schedule name to pointer ++AlphaNum; // A10 - WarehouseCoil(CoilID).DefrostSchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(AlphaNum)); - if (WarehouseCoil(CoilID).DefrostSchedPtr == 0) { - ShowSevereError(state, - format("{}{}=\"{}\", invalid {} not found: {}", - RoutineName, - CurrentModuleObject, - WarehouseCoil(CoilID).Name, - cAlphaFieldNames(AlphaNum), - Alphas(AlphaNum))); + if (lAlphaBlanks(AlphaNum)) { + ShowSevereEmptyField(state, eoh, cAlphaFieldNames(AlphaNum)); + ErrorsFound = true; + } else if ((WarehouseCoil(CoilID).defrostSched = Sched::GetSchedule(state, Alphas(AlphaNum))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum)); + ErrorsFound = true; + } else if (!WarehouseCoil(CoilID).defrostSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) { + Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum), Clusive::In, 0.0, Clusive::In, 1.0); ErrorsFound = true; - } else { // check defrost schedule for values between 0 and 1 - if (!ScheduleManager::CheckScheduleValueMinMax(state, WarehouseCoil(CoilID).DefrostSchedPtr, ">=", 0.0, "<=", 1.0)) { - ShowSevereError(state, format("{}{} = \"{}\"", RoutineName, CurrentModuleObject, WarehouseCoil(CoilID).Name)); - ShowContinueError(state, format("Error found in {}={}", cAlphaFieldNames(AlphaNum), Alphas(AlphaNum))); - ShowContinueError(state, "schedule values must be (>=0., <=1.)"); - ErrorsFound = true; - } // checkschedulevalueMinMax } // check for valid schedule name // convert defrost drip-down schedule name to pointer // some defrost types do not use drip-down schedules, use same defrost schedule pointer in that case ++AlphaNum; // A11 - if (!lAlphaBlanks(AlphaNum)) { - WarehouseCoil(CoilID).DefrostDripDownSchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(AlphaNum)); - if (WarehouseCoil(CoilID).DefrostDripDownSchedPtr == 0) { - ShowSevereError(state, - format("{}{}=\"{}\", invalid {} not found: {}", - RoutineName, - CurrentModuleObject, - WarehouseCoil(CoilID).Name, - cAlphaFieldNames(AlphaNum), - Alphas(AlphaNum))); - ErrorsFound = true; - } else { // check schedule for values between 0 and 1 - if (!ScheduleManager::CheckScheduleValueMinMax(state, WarehouseCoil(CoilID).DefrostDripDownSchedPtr, ">=", 0.0, "<=", 1.0)) { - ShowSevereError(state, format("{}{}=\"{}\"", RoutineName, CurrentModuleObject, WarehouseCoil(CoilID).Name)); - ShowContinueError(state, format("Error found in {} = {}", cAlphaFieldNames(AlphaNum), Alphas(AlphaNum))); - ShowContinueError(state, "schedule values must be (>=0., <=1.)"); - ErrorsFound = true; - } // Check schedule value between 0 and 1 - } // Check if drip down schedule name is valid - } else { // .not. lAlphaBlanks so use drip down schedule for defrost - WarehouseCoil(CoilID).DefrostDripDownSchedPtr = WarehouseCoil(CoilID).DefrostSchedPtr; - } // .not. lAlphaBlanks + if (lAlphaBlanks(AlphaNum)) { + WarehouseCoil(CoilID).defrostDripDownSched = WarehouseCoil(CoilID).defrostSched; + } else if ((WarehouseCoil(CoilID).defrostDripDownSched = Sched::GetSchedule(state, Alphas(AlphaNum))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum)); + ErrorsFound = true; + } else if (!WarehouseCoil(CoilID).defrostDripDownSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) { + Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum), Clusive::In, 0.0, Clusive::In, 1.0); + ErrorsFound = true; + } // check for valid schedule name + ++NumNum; // N14 if (WarehouseCoil(CoilID).defrostType == DefrostType::OffCycle || WarehouseCoil(CoilID).defrostType == DefrostType::None) { @@ -2712,36 +2455,23 @@ void GetRefrigerationInput(EnergyPlusData &state) lAlphaBlanks, cAlphaFieldNames, cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)}; + AlphaNum = 1; Util::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound); AirChillerSet(SetID).Name = Alphas(AlphaNum); AlphaNum = 2; - if (!lAlphaBlanks(AlphaNum)) { - AirChillerSet(SetID).SchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(AlphaNum)); // convert schedule name to pointer - if (AirChillerSet(SetID).SchedPtr == 0) { - ShowSevereError(state, - format("{}{}=\"{}\", invalid {} not found: {}", - RoutineName, - CurrentModuleObject, - AirChillerSet(SetID).Name, - cAlphaFieldNames(AlphaNum), - Alphas(AlphaNum))); - ErrorsFound = true; - } // ptr == 0 - } else { // no schedule specified - AirChillerSet(SetID).SchedPtr = AlwaysOn; - } // not blank - - // check availability schedule for values between 0 and 1 - if (AirChillerSet(SetID).SchedPtr > 0) { - if (!ScheduleManager::CheckScheduleValueMinMax(state, AirChillerSet(SetID).SchedPtr, ">=", 0.0, "<=", 1.0)) { - ShowSevereError(state, format("{}{}=\"{}\"", RoutineName, CurrentModuleObject, AirChillerSet(SetID).Name)); - ShowContinueError(state, format("Error found in {} = {}", cAlphaFieldNames(AlphaNum), Alphas(AlphaNum))); - ShowContinueError(state, "schedule values must be (>=0., <=1.)"); - ErrorsFound = true; - } + if (lAlphaBlanks(AlphaNum)) { + AirChillerSet(SetID).availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((AirChillerSet(SetID).availSched = Sched::GetSchedule(state, Alphas(AlphaNum))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum)); + ErrorsFound = true; + } else if (!AirChillerSet(SetID).availSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) { + Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum), Clusive::In, 0.0, Clusive::In, 1.0); + ErrorsFound = true; } ++AlphaNum; @@ -2937,6 +2667,8 @@ void GetRefrigerationInput(EnergyPlusData &state) lAlphaBlanks, cAlphaFieldNames, cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)}; Util::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound); RefrigRack(RackNum).Name = Alphas(1); @@ -3094,23 +2826,12 @@ void GetRefrigerationInput(EnergyPlusData &state) // Get outlet temperature schedule for variable flow case if (RefrigRack(RackNum).FlowType == CndsrFlowType::VariableFlow) { if (lAlphaBlanks(9)) { - RefrigRack(RackNum).OutletTempSchedPtr = 0; - } else { - RefrigRack(RackNum).OutletTempSchedPtr = - ScheduleManager::GetScheduleIndex(state, Alphas(9)); // convert schedule name to pointer - } - if (RefrigRack(RackNum).OutletTempSchedPtr == 0) { - ShowSevereError(state, - format("{}{}=\"{}\", invalid {} : {}", - RoutineName, - CurrentModuleObject, - RefrigRack(RackNum).Name, - cAlphaFieldNames(9), - Alphas(9))); - ShowContinueError(state, "A schedule with this name is not defined in this input data file."); + } else if ((RefrigRack(RackNum).outletTempSched = Sched::GetSchedule(state, Alphas(9))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(9), Alphas(9)); ErrorsFound = true; } } + // Get volumetric flow rate if applicable if (RefrigRack(RackNum).FlowType == CndsrFlowType::ConstantFlow) { RefrigRack(RackNum).DesVolFlowRate = Numbers(3); @@ -3140,28 +2861,12 @@ void GetRefrigerationInput(EnergyPlusData &state) // Get evaporative cooled condenser input if (lAlphaBlanks(10)) { - RefrigRack(RackNum).EvapSchedPtr = 0; - } else { - RefrigRack(RackNum).EvapSchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(10)); // convert schedule name to pointer - // check availability schedule for values >= 0 - if (RefrigRack(RackNum).EvapSchedPtr > 0) { - if (!ScheduleManager::CheckScheduleValueMinMax(state, RefrigRack(RackNum).EvapSchedPtr, true, 0.0)) { - ShowSevereError(state, format("{}{}=\"{}\" .", RoutineName, CurrentModuleObject, RefrigRack(RackNum).Name)); - ShowContinueError(state, format("Error found in {} = {}", cAlphaFieldNames(10), Alphas(10))); - ShowContinueError(state, "schedule values must be (>=0.)."); - ErrorsFound = true; - } - } else { - ShowSevereError(state, - format("{}{}=\"{}\", invalid {} = {}", - RoutineName, - CurrentModuleObject, - RefrigRack(RackNum).Name, - cAlphaFieldNames(10), - Alphas(10))); - ShowContinueError(state, "A schedule with this name is not defined in this input data file."); - ErrorsFound = true; - } + } else if ((RefrigRack(RackNum).evapAvailSched = Sched::GetSchedule(state, Alphas(10))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(10), Alphas(10)); + ErrorsFound = true; + } else if (!RefrigRack(RackNum).evapAvailSched->checkMinVal(state, Clusive::In, 0.0)) { + Sched::ShowSevereBadMin(state, eoh, cAlphaFieldNames(10), Alphas(10), Clusive::In, 0.0); + ErrorsFound = true; } RefrigRack(RackNum).EvapEffect = Numbers(7); @@ -3632,6 +3337,8 @@ void GetRefrigerationInput(EnergyPlusData &state) cAlphaFieldNames, cNumericFieldNames); + ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)}; + GlobalNames::VerifyUniqueInterObjectName( state, state.dataRefrigCase->UniqueCondenserNames, Alphas(1), CurrentModuleObject, cAlphaFieldNames(1), ErrorsFound); Condenser(CondNum).Name = Alphas(1); @@ -3847,29 +3554,13 @@ void GetRefrigerationInput(EnergyPlusData &state) } if (lAlphaBlanks(5)) { - Condenser(CondNum).EvapSchedPtr = 0; - } else { - Condenser(CondNum).EvapSchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(5)); // convert schedule name to pointer - // check availability schedule for values >= 0 - if (Condenser(CondNum).EvapSchedPtr > 0) { - if (!ScheduleManager::CheckScheduleValueMinMax(state, Condenser(CondNum).EvapSchedPtr, true, 0.0)) { - ShowSevereError(state, format("{}{}=\"{}\" .", RoutineName, CurrentModuleObject, Condenser(CondNum).Name)); - ShowContinueError(state, format("Error found in {} = {}", cAlphaFieldNames(5), Alphas(5))); - ShowContinueError(state, "schedule values must be (>=0.)."); - ErrorsFound = true; - } - } else { - ShowSevereError(state, - format("{}{}=\"{}\", invalid {} = {}", - RoutineName, - CurrentModuleObject, - Condenser(CondNum).Name, - cAlphaFieldNames(5), - Alphas(5))); - ShowContinueError(state, "A schedule with this name is not defined in this input data file."); - ErrorsFound = true; - } - } // Set Evap Schedule Pointer + } else if ((Condenser(CondNum).evapAvailSched = Sched::GetSchedule(state, Alphas(5))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(5), Alphas(5)); + ErrorsFound = true; + } else if (!Condenser(CondNum).evapAvailSched->checkMinVal(state, Clusive::In, 0.0)) { + Sched::ShowSevereBadMin(state, eoh, cAlphaFieldNames(5), Alphas(5), Clusive::In, 0.0); + ErrorsFound = true; + } Condenser(CondNum).EndUseSubcategory = ""; if (!lAlphaBlanks(6)) Condenser(CondNum).EndUseSubcategory = Alphas(6); @@ -3903,6 +3594,8 @@ void GetRefrigerationInput(EnergyPlusData &state) cAlphaFieldNames, cNumericFieldNames); + ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)}; + GlobalNames::VerifyUniqueInterObjectName( state, state.dataRefrigCase->UniqueCondenserNames, Alphas(1), CurrentModuleObject, cAlphaFieldNames(1), ErrorsFound); Condenser(CondNum).Name = Alphas(1); @@ -4010,20 +3703,8 @@ void GetRefrigerationInput(EnergyPlusData &state) // Get outlet temperature schedule for variable flow case if (Condenser(CondNum).FlowType == CndsrFlowType::VariableFlow) { if (lAlphaBlanks(5)) { - Condenser(CondNum).OutletTempSchedPtr = 0; - } else { - Condenser(CondNum).OutletTempSchedPtr = - ScheduleManager::GetScheduleIndex(state, Alphas(5)); // convert schedule name to pointer - } - if (Condenser(CondNum).OutletTempSchedPtr == 0) { - ShowSevereError(state, - format("{}{}=\"{}\", invalid {} = {}", - RoutineName, - CurrentModuleObject, - Condenser(CondNum).Name, - cAlphaFieldNames(5), - Alphas(5))); - ShowContinueError(state, "A schedule with this name is not defined in this input data file."); + } else if ((Condenser(CondNum).outletTempSched = Sched::GetSchedule(state, Alphas(5))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(5), Alphas(5)); ErrorsFound = true; } } // Outlet temperature schedule @@ -6851,7 +6532,7 @@ void GetRefrigerationInput(EnergyPlusData &state) GasCooler(TransSystem(TransRefrigSysNum).GasCoolerNum(1)).RatedOutletT, GasCooler(TransSystem(TransRefrigSysNum).GasCoolerNum(1)).RatedOutletP, RefrigIndex, - RoutineNameNoColon); + routineName); Compressor(CompNum).NomCap = Curve::CurveValue( state, Compressor(CompNum).TransCapacityCurvePtr, TransSystem(TransRefrigSysNum).TEvapDesignMT, GCOutletH); NominalTotalCompCapHP += Compressor(CompNum).NomCap; @@ -6949,7 +6630,7 @@ void GetRefrigerationInput(EnergyPlusData &state) // Check receiver temperature against minimum condensing temperature (from gas cooler input) and design evaporator temperatures TransSystem(TransRefrigSysNum).TReceiver = FluidProperties::GetSatTemperatureRefrig( - state, TransSystem(TransRefrigSysNum).RefrigerantName, TransSystem(TransRefrigSysNum).PReceiver, RefrigIndex, RoutineNameNoColon); + state, TransSystem(TransRefrigSysNum).RefrigerantName, TransSystem(TransRefrigSysNum).PReceiver, RefrigIndex, routineName); if (TransSystem(TransRefrigSysNum).TReceiver > GasCooler(TransSystem(TransRefrigSysNum).GasCoolerNum(NumGasCoolers)).MinCondTemp) { ShowWarningError(state, format("{}{}=\"{}: The receiver temperature ({:.2R}C) is greater than the minimum condensing temperature " @@ -10450,7 +10131,7 @@ void InitRefrigeration(EnergyPlusData &state) System(systemId).LSHXTransEnergy = 0.0; } - if (state.dataGlobal->NumOfTimeStepInHour > 0.0) state.dataRefrigCase->TimeStepFraction = 1.0 / double(state.dataGlobal->NumOfTimeStepInHour); + if (state.dataGlobal->TimeStepsInHour > 0.0) state.dataRefrigCase->TimeStepFraction = 1.0 / double(state.dataGlobal->TimeStepsInHour); state.dataRefrigCase->InitRefrigerationMyBeginEnvrnFlag = false; } // ( DataGlobals::BeginEnvrnFlag && MyBeginEnvrnFlag ) @@ -10886,7 +10567,7 @@ void RefrigRackData::CalcRackSystem(EnergyPlusData &state) // IF schedule exists, evap condenser can be scheduled OFF // Check schedule to determine evap condenser availability - if (this->EvapSchedPtr > 0 && ScheduleManager::GetCurrentScheduleValue(state, this->EvapSchedPtr) == 0) EvapAvail = false; + if (this->evapAvailSched != nullptr && this->evapAvailSched->getCurrentVal() == 0) EvapAvail = false; // Evaporative condensers will have their water flow shut off in cold months to avoid // 'spectacular' icing problems. Ideally, the user will use the evaporative schedule input @@ -11030,28 +10711,28 @@ void RefrigRackData::ReportRackSystem(EnergyPlusData &state, int const RackNum) // PURPOSE OF THIS SUBROUTINE: // To report compressor rack variables - Real64 LocalTimeStep = state.dataGlobal->TimeStepZone; - if (state.dataRefrigCase->UseSysTimeStep) LocalTimeStep = state.dataHVACGlobal->TimeStepSys; + Real64 localTimeStep = (state.dataRefrigCase->UseSysTimeStep) ? state.dataHVACGlobal->TimeStepSys : state.dataGlobal->TimeStepZone; + Real64 localTimeStepSec = localTimeStep * Constant::rSecsInHour; this->RackCompressorPower = state.dataRefrigCase->TotalCompressorPower; - this->RackElecConsumption = state.dataRefrigCase->TotalCompressorPower * LocalTimeStep * Constant::SecInHour; + this->RackElecConsumption = state.dataRefrigCase->TotalCompressorPower * localTimeStepSec; this->ActualCondenserFanPower = state.dataRefrigCase->TotalCondenserFanPower; - this->CondenserFanConsumption = state.dataRefrigCase->TotalCondenserFanPower * LocalTimeStep * Constant::SecInHour; + this->CondenserFanConsumption = state.dataRefrigCase->TotalCondenserFanPower * localTimeStepSec; this->RackCapacity = state.dataRefrigCase->TotalRackDeliveredCapacity; - this->RackCoolingEnergy = state.dataRefrigCase->TotalRackDeliveredCapacity * LocalTimeStep * Constant::SecInHour; + this->RackCoolingEnergy = state.dataRefrigCase->TotalRackDeliveredCapacity * localTimeStepSec; this->RackCompressorCOP = state.dataRefrigCase->CompressorCOPactual; this->SensHVACCreditHeatRate = state.dataRefrigCase->RackSenCreditToHVAC; - this->SensHVACCreditHeat = state.dataRefrigCase->RackSenCreditToHVAC * LocalTimeStep * Constant::SecInHour; + this->SensHVACCreditHeat = state.dataRefrigCase->RackSenCreditToHVAC * localTimeStepSec; this->SensZoneCreditHeatRate = state.dataRefrigCase->RackSenCreditToZone; - this->SensZoneCreditHeat = state.dataRefrigCase->RackSenCreditToZone * LocalTimeStep * Constant::SecInHour; + this->SensZoneCreditHeat = state.dataRefrigCase->RackSenCreditToZone * localTimeStepSec; this->EvapWaterConsumpRate = state.dataRefrigCase->TotalEvapWaterUseRate; - this->EvapWaterConsumption = state.dataRefrigCase->TotalEvapWaterUseRate * LocalTimeStep * Constant::SecInHour; + this->EvapWaterConsumption = state.dataRefrigCase->TotalEvapWaterUseRate * localTimeStepSec; this->ActualEvapPumpPower = state.dataRefrigCase->TotalCondenserPumpPower; - this->EvapPumpConsumption = state.dataRefrigCase->TotalCondenserPumpPower * LocalTimeStep * Constant::SecInHour; + this->EvapPumpConsumption = state.dataRefrigCase->TotalCondenserPumpPower * localTimeStepSec; this->BasinHeaterPower = state.dataRefrigCase->TotalBasinHeatPower; - this->BasinHeaterConsumption = state.dataRefrigCase->TotalBasinHeatPower * LocalTimeStep * Constant::SecInHour; + this->BasinHeaterConsumption = state.dataRefrigCase->TotalBasinHeatPower * localTimeStepSec; this->CondLoad = state.dataRefrigCase->TotalCondenserHeat; - this->CondEnergy = state.dataRefrigCase->TotalCondenserHeat * LocalTimeStep * Constant::SecInHour; + this->CondEnergy = state.dataRefrigCase->TotalCondenserHeat * localTimeStepSec; // Set total rack heat rejection used for heat reclaim. Do not allow heat reclaim on stand alone (indoor) display cases. if (this->HeatRejectionLocation == HeatRejLocation::Zone) { state.dataHeatBal->HeatReclaimRefrigeratedRack(RackNum).AvailCapacity = 0.0; @@ -11152,12 +10833,12 @@ void RefrigCaseData::CalculateCase(EnergyPlusData &state) // Absolute pointer to // case schedule should be coincident with the zone time step otherwise the simulation proceeds // Current value of case operating (availability) schedule - Real64 CaseSchedule = ScheduleManager::GetCurrentScheduleValue(state, this->SchedPtr); + Real64 CaseSchedule = this->availSched->getCurrentVal(); if (CaseSchedule <= 0) return; // get defrost schedule if (this->defrostType > RefCaseDefrostType::None) { - DefrostSchedule = ScheduleManager::GetCurrentScheduleValue(state, this->DefrostSchedPtr); - DefrostDripDownSchedule = ScheduleManager::GetCurrentScheduleValue(state, this->DefrostDripDownSchedPtr); + DefrostSchedule = this->defrostSched->getCurrentVal(); + DefrostDripDownSchedule = this->defrostDripDownSched->getCurrentVal(); // next statement In case user doesn't understand concept of drip down schedule DefrostDripDownSchedule = max(DefrostDripDownSchedule, DefrostSchedule); } else { @@ -11165,24 +10846,15 @@ void RefrigCaseData::CalculateCase(EnergyPlusData &state) // Absolute pointer to DefrostDripDownSchedule = 0.0; } - Real64 StockingSchedule(0.0); // Current value of product stocking schedule (W/m) - // get product stocking schedule and load due to product stocking, if no schedule exists load is 0 - if (this->StockingSchedPtr > 0) { - StockingSchedule = ScheduleManager::GetCurrentScheduleValue(state, this->StockingSchedPtr); - } else { - StockingSchedule = 0.0; - } + Real64 StockingSchedule = (this->stockingSched != nullptr) ? this->stockingSched->getCurrentVal() : 0.0; + // get lighting schedule and total load due to lighting - Real64 LightingSchedule = ScheduleManager::GetCurrentScheduleValue(state, this->LightingSchedPtr); + Real64 LightingSchedule = this->lightingSched->getCurrentVal(); // if case credit reduction fraction schedule exists, modify both sensible and latent case credits // according to schedule - used to account for variable case envelope, such as night covers. - if (this->CaseCreditFracSchedPtr != 0) { - CaseCreditFraction = ScheduleManager::GetCurrentScheduleValue(state, this->CaseCreditFracSchedPtr); - } else { - CaseCreditFraction = 1.0; - } + CaseCreditFraction = (this->caseCreditFracSched != nullptr) ? this->caseCreditFracSched->getCurrentVal() : 1.0; // CALCULATE AUX LOADS DUE TO LIGHTS, FAN AND STOCKING TotalLightingLoad = this->DesignLighting * LightingSchedule; @@ -11342,7 +11014,7 @@ void RefrigCaseData::CalculateCase(EnergyPlusData &state) // Absolute pointer to // Reduce defrost heat load on case by amount of ice melted during time step // However, don't reduce the defrost capacity applied - DefrostLoad_Actual = DefrostCap_Actual - FrostMeltedKg * IceMeltEnthalpy / state.dataGlobal->TimeStepZone / Constant::SecInHour; + DefrostLoad_Actual = DefrostCap_Actual - FrostMeltedKg * IceMeltEnthalpy / state.dataGlobal->TimeStepZone / Constant::rSecsInHour; if (!state.dataGlobal->WarmupFlag) { // avoid reverse dd test problems // keep running total of defrost energy above that needed to melt frost for use in evaluating @@ -11372,7 +11044,7 @@ void RefrigCaseData::CalculateCase(EnergyPlusData &state) // Absolute pointer to Real64 TotalLoad_Actual = SensibleLoadTotal + LatentLoad + DefrostLoad_Actual; // Rate needed to serve all stored energy during single time step (W) - Real64 StoredEnergyRate = this->StoredEnergy / state.dataGlobal->TimeStepZone / Constant::SecInHour; + Real64 StoredEnergyRate = this->StoredEnergy / state.dataGlobal->TimeStepZone / Constant::rSecsInHour; Real64 LoadRequested = TotalLoad_Actual + StoredEnergyRate; // prorate available cooling capacity for portion of time off due to drip down. @@ -11625,7 +11297,7 @@ void RefrigCondenserData::simulate(EnergyPlusData &state, if (this->FlowType == CndsrFlowType::VariableFlow && state.dataRefrigCase->TotalCondenserHeat > 0.0) { - this->OutletTemp = ScheduleManager::GetCurrentScheduleValue(state, this->OutletTempSchedPtr); + this->OutletTemp = this->outletTempSched->getCurrentVal(); if (this->OutletTemp == this->InletTemp) { @@ -11784,7 +11456,7 @@ void RefrigRackData::simulate(EnergyPlusData &state, RoutineName); if (this->FlowType == CndsrFlowType::VariableFlow && state.dataRefrigCase->TotalCondenserHeat > 0.0) { - this->OutletTemp = ScheduleManager::GetCurrentScheduleValue(state, this->OutletTempSchedPtr); + this->OutletTemp = this->outletTempSched->getCurrentVal(); if (this->OutletTemp == this->InletTemp) { @@ -11942,8 +11614,8 @@ void SimulateDetailedRefrigerationSystems(EnergyPlusData &state) auto &AirChillerSet = state.dataRefrigCase->AirChillerSet; auto &CoilSysCredit = state.dataRefrigCase->CoilSysCredit; - Real64 LocalTimeStep = state.dataGlobal->TimeStepZone; - if (state.dataRefrigCase->UseSysTimeStep) LocalTimeStep = state.dataHVACGlobal->TimeStepSys; + Real64 localTimeStep = (state.dataRefrigCase->UseSysTimeStep) ? state.dataHVACGlobal->TimeStepSys : state.dataGlobal->TimeStepZone; + Real64 localTimeStepSec = localTimeStep * Constant::rSecsInHour; // Cascade condenser assumes a constant approach delta T (Tcond - Tevap), not f(load) @@ -12306,9 +11978,9 @@ void SimulateDetailedRefrigerationSystems(EnergyPlusData &state) // Report variables thisSys.TotTransferLoad = thisSys.SumMechSCLoad - thisSys.SumMechSCBenefit + thisSys.SumSecondaryLoopLoad + thisSys.SumCascadeLoad; - thisSys.TotTransferEnergy = thisSys.TotTransferLoad * LocalTimeStep * Constant::SecInHour; - thisSys.PipeHeatEnergy = thisSys.PipeHeatLoad * LocalTimeStep * Constant::SecInHour; - thisSys.TotalCoolingEnergy = thisSys.TotalCoolingLoad * LocalTimeStep * Constant::SecInHour; + thisSys.TotTransferEnergy = thisSys.TotTransferLoad * localTimeStepSec; + thisSys.PipeHeatEnergy = thisSys.PipeHeatLoad * localTimeStepSec; + thisSys.TotalCoolingEnergy = thisSys.TotalCoolingLoad * localTimeStepSec; } //(((.NOT. UseSysTimeStep).AND.(.NOT. System(SysNum)%CoilFlag)).OR.((UseSysTimeStep).AND.(System(SysNum)%CoilFlag))).and.not // WarmupFlag } // SysNum = 1,NumRefrigSystems @@ -12325,7 +11997,7 @@ void SimulateDetailedRefrigerationSystems(EnergyPlusData &state) auto &coil = WarehouseCoil(CoilID); if (coil.ZoneNum != ZoneNum) continue; zoneCredit.SenCreditToZoneRate -= coil.SensCreditRate; - zoneCredit.SenCreditToZoneEnergy = zoneCredit.SenCreditToZoneRate * LocalTimeStep * Constant::SecInHour; + zoneCredit.SenCreditToZoneEnergy = zoneCredit.SenCreditToZoneRate * localTimeStepSec; zoneCredit.LatKgPerS_ToZoneRate -= coil.LatKgPerS_ToZone; zoneCredit.LatCreditToZoneRate -= coil.LatCreditRate; zoneCredit.LatCreditToZoneEnergy -= coil.LatCreditEnergy; @@ -12360,8 +12032,8 @@ void SimulateDetailedTransRefrigSystems(EnergyPlusData &state) auto &GasCooler = state.dataRefrigCase->GasCooler; auto &WalkIn = state.dataRefrigCase->WalkIn; - Real64 LocalTimeStep = state.dataGlobal->TimeStepZone; - if (state.dataRefrigCase->UseSysTimeStep) LocalTimeStep = state.dataHVACGlobal->TimeStepSys; + Real64 localTimeStep = (state.dataRefrigCase->UseSysTimeStep) ? state.dataHVACGlobal->TimeStepSys : state.dataGlobal->TimeStepZone; + Real64 localTimeStepSec = localTimeStep * Constant::rSecsInHour; // Do transcritical CO2 refrigeration system loop outside of iterative solution to initialize time step and // calculate case and and walk-ins (that won't change during balance of refrigeration system iterations) @@ -12546,8 +12218,8 @@ void SimulateDetailedTransRefrigSystems(EnergyPlusData &state) } // Reject heat to zone // Report variables - sys.PipeHeatEnergy = (sys.PipeHeatLoadMT + sys.PipeHeatLoadLT) * LocalTimeStep * Constant::SecInHour; - sys.TotalCoolingEnergy = (sys.TotalCoolingLoadMT + sys.TotalCoolingLoadMT) * LocalTimeStep * Constant::SecInHour; + sys.PipeHeatEnergy = (sys.PipeHeatLoadMT + sys.PipeHeatLoadLT) * localTimeStepSec; + sys.TotalCoolingEnergy = (sys.TotalCoolingLoadMT + sys.TotalCoolingLoadMT) * localTimeStepSec; } //(.NOT. UseSysTimeStep).AND. (.not. WarmupFlag) } // SysNum = 1,NumTransRefrigSystems @@ -12765,8 +12437,8 @@ void RefrigSystemData::CalculateCondensers(EnergyPlusData &state, int const SysN Real64 TotalLoadFromThisSystem(0.0); // total heat rejection load from the detailed system id'd in subroutine call [W] Real64 TotalLoadFromSystems; // total heat rejection load from all systems served by this condenser [W] - Real64 LocalTimeStep = state.dataGlobal->TimeStepZone; - if (state.dataRefrigCase->UseSysTimeStep) LocalTimeStep = state.dataHVACGlobal->TimeStepSys; + Real64 localTimeStep = (state.dataRefrigCase->UseSysTimeStep) ? state.dataHVACGlobal->TimeStepSys : state.dataGlobal->TimeStepZone; + Real64 localTimeStepSec = localTimeStep * Constant::rSecsInHour; // Initialize this condenser for this time step state.dataRefrigCase->TotalCondenserPumpPower = 0.0; @@ -12902,8 +12574,9 @@ void RefrigSystemData::CalculateCondensers(EnergyPlusData &state, int const SysN // Check schedule to determine evap condenser availability // IF schedule exists, evap condenser can be scheduled OFF - if ((condenser.CondenserType == DataHeatBalance::RefrigCondenserType::Evap) && (condenser.EvapSchedPtr > 0) && - (ScheduleManager::GetCurrentScheduleValue(state, condenser.EvapSchedPtr) == 0)) + if ((condenser.CondenserType == DataHeatBalance::RefrigCondenserType::Evap) && + (condenser.evapAvailSched != nullptr) && + (condenser.evapAvailSched->getCurrentVal() == 0)) EvapAvail = false; // Calculate condensing temperatures for air-cooled and evap-cooled @@ -13068,15 +12741,15 @@ void RefrigSystemData::CalculateCondensers(EnergyPlusData &state, int const SysN } // Condenser type = water, (evap or air), or cascade condenser.ActualFanPower = ActualFanPower; - condenser.FanElecEnergy = ActualFanPower * LocalTimeStep * Constant::SecInHour; + condenser.FanElecEnergy = ActualFanPower * localTimeStepSec; condenser.EvapWaterConsumpRate = state.dataRefrigCase->TotalEvapWaterUseRate; - condenser.EvapWaterConsumption = state.dataRefrigCase->TotalEvapWaterUseRate * LocalTimeStep * Constant::SecInHour; + condenser.EvapWaterConsumption = state.dataRefrigCase->TotalEvapWaterUseRate * localTimeStepSec; condenser.ActualEvapPumpPower = state.dataRefrigCase->TotalCondenserPumpPower; - condenser.EvapPumpConsumption = state.dataRefrigCase->TotalCondenserPumpPower * LocalTimeStep * Constant::SecInHour; + condenser.EvapPumpConsumption = state.dataRefrigCase->TotalCondenserPumpPower * localTimeStepSec; condenser.BasinHeaterPower = state.dataRefrigCase->TotalBasinHeatPower; - condenser.BasinHeaterConsumption = state.dataRefrigCase->TotalBasinHeatPower * LocalTimeStep * Constant::SecInHour; + condenser.BasinHeaterConsumption = state.dataRefrigCase->TotalBasinHeatPower * localTimeStepSec; condenser.CondLoad = state.dataRefrigCase->TotalCondenserHeat; - condenser.CondEnergy = state.dataRefrigCase->TotalCondenserHeat * LocalTimeStep * Constant::SecInHour; + condenser.CondEnergy = state.dataRefrigCase->TotalCondenserHeat * localTimeStepSec; condenser.CondCreditWarnIndex1 = CondCreditWarnIndex1; condenser.CondCreditWarnIndex2 = CondCreditWarnIndex2; condenser.CondCreditWarnIndex3 = CondCreditWarnIndex3; @@ -13084,11 +12757,11 @@ void RefrigSystemData::CalculateCondensers(EnergyPlusData &state, int const SysN condenser.CondCreditWarnIndex5 = CondCreditWarnIndex5; condenser.CondCreditWarnIndex6 = CondCreditWarnIndex6; condenser.CondCreditWarnIndex7 = CondCreditWarnIndex7; - condenser.ExternalEnergyRecovered = condenser.ExternalHeatRecoveredLoad * LocalTimeStep * Constant::SecInHour; - condenser.InternalEnergyRecovered = condenser.InternalHeatRecoveredLoad * LocalTimeStep * Constant::SecInHour; - condenser.TotalHeatRecoveredEnergy = condenser.TotalHeatRecoveredLoad * LocalTimeStep * Constant::SecInHour; + condenser.ExternalEnergyRecovered = condenser.ExternalHeatRecoveredLoad * localTimeStepSec; + condenser.InternalEnergyRecovered = condenser.InternalHeatRecoveredLoad * localTimeStepSec; + condenser.TotalHeatRecoveredEnergy = condenser.TotalHeatRecoveredLoad * localTimeStepSec; this->NetHeatRejectLoad = state.dataRefrigCase->TotalCondenserHeat * TotalLoadFromThisSystem / TotalLoadFromSystems; - this->NetHeatRejectEnergy = this->NetHeatRejectLoad * LocalTimeStep * Constant::SecInHour; + this->NetHeatRejectEnergy = this->NetHeatRejectLoad * localTimeStepSec; // set water system demand request (if needed) if (condenser.EvapWaterSupplyMode == WaterSupply::FromTank) { @@ -13151,9 +12824,9 @@ void TransRefrigSystemData::CalcGasCooler(EnergyPlusData &state, int const SysNu Real64 TotalLoadFromSystems; // Total heat rejection load from all systems served by this condenser [W] Real64 TotalLoadFromThisSystem(0.0); // Total heat rejection load from the detailed system identified in subroutine call [W] - Real64 LocalTimeStep = state.dataGlobal->TimeStepZone; - if (state.dataRefrigCase->UseSysTimeStep) LocalTimeStep = state.dataHVACGlobal->TimeStepSys; - + Real64 localTimeStep = (state.dataRefrigCase->UseSysTimeStep) ? state.dataHVACGlobal->TimeStepSys : state.dataGlobal->TimeStepZone; + Real64 localTimeStepSec = localTimeStep * Constant::rSecsInHour; + // Initialize this gas cooler for this time step ActualFanPower = 0.0; TotalCondDefrostCreditLocal = 0.0; @@ -13266,14 +12939,14 @@ void TransRefrigSystemData::CalcGasCooler(EnergyPlusData &state, int const SysNu } // fan speed control type cooler.ActualFanPower = ActualFanPower; - cooler.FanElecEnergy = ActualFanPower * LocalTimeStep * Constant::SecInHour; + cooler.FanElecEnergy = ActualFanPower * localTimeStepSec; cooler.GasCoolerLoad = TotalGasCoolerHeat; - cooler.GasCoolerEnergy = TotalGasCoolerHeat * LocalTimeStep * Constant::SecInHour; + cooler.GasCoolerEnergy = TotalGasCoolerHeat * localTimeStepSec; cooler.GasCoolerCreditWarnIndex = GasCoolerCreditWarnIndex; - cooler.InternalEnergyRecovered = cooler.InternalHeatRecoveredLoad * LocalTimeStep * Constant::SecInHour; - cooler.TotalHeatRecoveredEnergy = cooler.TotalHeatRecoveredLoad * LocalTimeStep * Constant::SecInHour; + cooler.InternalEnergyRecovered = cooler.InternalHeatRecoveredLoad * localTimeStepSec; + cooler.TotalHeatRecoveredEnergy = cooler.TotalHeatRecoveredLoad * localTimeStepSec; this->NetHeatRejectLoad = TotalGasCoolerHeat * TotalLoadFromThisSystem / TotalLoadFromSystems; - this->NetHeatRejectEnergy = this->NetHeatRejectLoad * LocalTimeStep * Constant::SecInHour; + this->NetHeatRejectEnergy = this->NetHeatRejectLoad * localTimeStepSec; } void RefrigSystemData::CalculateCompressors(EnergyPlusData &state) @@ -13335,13 +13008,12 @@ void RefrigSystemData::CalculateCompressors(EnergyPlusData &state) auto &Condenser = state.dataRefrigCase->Condenser; auto &Compressor = state.dataRefrigCase->Compressor; - Real64 LocalTimeStep = state.dataGlobal->TimeStepZone; - if (state.dataRefrigCase->UseSysTimeStep) LocalTimeStep = state.dataHVACGlobal->TimeStepSys; - Real64 const LocalTimeStepSec(LocalTimeStep * Constant::SecInHour); + Real64 localTimeStep = (state.dataRefrigCase->UseSysTimeStep) ? state.dataHVACGlobal->TimeStepSys : state.dataGlobal->TimeStepZone; + Real64 localTimeStepSec = localTimeStep * Constant::rSecsInHour; int CondID = this->CondenserNum(1); auto const &Condenser1 = Condenser(CondID); - Real64 const AccumLoad = max(0.0, (this->UnmetEnergy / LocalTimeStepSec)); // Load due to previously unmet compressor loads + Real64 const AccumLoad = max(0.0, (this->UnmetEnergy / localTimeStepSec)); // Load due to previously unmet compressor loads Real64 const NeededCapacity_base(this->TotalSystemLoad + AccumLoad + this->PipeHeatLoad + this->LSHXTrans); // Before dispatching compressors, zero sum of compressor outputs and zero each compressor @@ -13562,8 +13234,8 @@ void RefrigSystemData::CalculateCompressors(EnergyPlusData &state) this->TotCompCapacity += compressor.Capacity; this->RefMassFlowComps += compressor.MassFlow; this->TotCompPower += compressor.Power; - compressor.ElecConsumption = compressor.Power * LocalTimeStepSec; - compressor.CoolingEnergy = compressor.Capacity * LocalTimeStepSec; + compressor.ElecConsumption = compressor.Power * localTimeStepSec; + compressor.CoolingEnergy = compressor.Capacity * localTimeStepSec; compressor.LoadFactor = LFLastComp; break; // numcomps do } else { //>= needed capacity @@ -13581,8 +13253,8 @@ void RefrigSystemData::CalculateCompressors(EnergyPlusData &state) this->RefMassFlowHiStageComps += compressor.MassFlow; this->TotHiStageCompPower += compressor.Power; this->FlowRatioIntercooler = this->RefMassFlowComps / this->RefMassFlowHiStageComps; - compressor.ElecConsumption = compressor.Power * LocalTimeStepSec; - compressor.CoolingEnergy = compressor.Capacity * LocalTimeStepSec; + compressor.ElecConsumption = compressor.Power * localTimeStepSec; + compressor.CoolingEnergy = compressor.Capacity * localTimeStepSec; compressor.LoadFactor = LFLastComp; break; // numcomps do } else { //>= needed capacity @@ -13591,8 +13263,8 @@ void RefrigSystemData::CalculateCompressors(EnergyPlusData &state) this->TotHiStageCompPower += compressor.Power; } //>= needed capacity } // StageIndex - compressor.ElecConsumption = compressor.Power * LocalTimeStepSec; - compressor.CoolingEnergy = compressor.Capacity * LocalTimeStepSec; + compressor.ElecConsumption = compressor.Power * localTimeStepSec; + compressor.CoolingEnergy = compressor.Capacity * localTimeStepSec; compressor.LoadFactor = 1.0; } // NumComps } @@ -13621,13 +13293,13 @@ void RefrigSystemData::CalculateCompressors(EnergyPlusData &state) state.dataHeatBal->HeatReclaimRefrigCondenser(CondID).AvailTemperature = (TsatforPdisch + TCompOutEstimate) / 2.0; this->AverageCompressorCOP = this->TotCompCapacity / (this->TotCompPower + this->TotHiStageCompPower); - this->TotCompElecConsump = this->TotCompPower * LocalTimeStepSec; + this->TotCompElecConsump = this->TotCompPower * localTimeStepSec; if (this->NumStages == 2) { - this->TotHiStageCompElecConsump = this->TotHiStageCompPower * LocalTimeStepSec; + this->TotHiStageCompElecConsump = this->TotHiStageCompPower * localTimeStepSec; this->TotCompElecConsumpTwoStage = this->TotCompElecConsump + this->TotHiStageCompElecConsump; } - this->TotCompCoolingEnergy = this->TotCompCapacity * LocalTimeStepSec; - this->TotHiStageCompCoolingEnergy = this->TotHiStageCompCapacity * LocalTimeStepSec; + this->TotCompCoolingEnergy = this->TotCompCapacity * localTimeStepSec; + this->TotHiStageCompCoolingEnergy = this->TotHiStageCompCapacity * localTimeStepSec; } void TransRefrigSystemData::CalculateTransCompressors(EnergyPlusData &state) @@ -13718,20 +13390,20 @@ void TransRefrigSystemData::CalculateTransCompressors(EnergyPlusData &state) auto &Compressor = state.dataRefrigCase->Compressor; auto &GasCooler = state.dataRefrigCase->GasCooler; - Real64 LocalTimeStep = state.dataGlobal->TimeStepZone; - if (state.dataRefrigCase->UseSysTimeStep) LocalTimeStep = state.dataHVACGlobal->TimeStepSys; + Real64 localTimeStep = (state.dataRefrigCase->UseSysTimeStep) ? state.dataHVACGlobal->TimeStepSys : state.dataGlobal->TimeStepZone; + Real64 localTimeStepSec = localTimeStep * Constant::rSecsInHour; // Determine refrigerating capacity needed // Load due to previously unmet low temperature compressor loads (transcritical system) Real64 AccumLoadLT; NeededCapacityLT = 0.0; if (this->TransSysType == 2) { - AccumLoadLT = max(0.0, (this->UnmetEnergyLT / LocalTimeStep / Constant::SecInHour)); + AccumLoadLT = max(0.0, (this->UnmetEnergyLT / localTimeStep / Constant::rSecsInHour)); // localTimeStep / rSecsInHour? NeededCapacityLT = this->TotalSystemLoadLT + AccumLoadLT + this->PipeHeatLoadLT; } // (TransSystem(SysNum)%TransSysType == 2) // Load due to previously unmet medium temperature compressor loads (transcritical system) - Real64 AccumLoadMT = max(0.0, (this->UnmetEnergyMT / LocalTimeStep / Constant::SecInHour)); + Real64 AccumLoadMT = max(0.0, (this->UnmetEnergyMT / localTimeStep / Constant::rSecsInHour)); NeededCapacityMT = this->TotalSystemLoadMT + AccumLoadMT + this->PipeHeatLoadMT; // Determine refrigerant properties at receiver @@ -13817,8 +13489,8 @@ void TransRefrigSystemData::CalculateTransCompressors(EnergyPlusData &state) compressor.Power = Curve::CurveValue(state, compressor.ElecPowerCurvePtr, TsatforPsucLT, TsatforPdisLT); compressor.Capacity = CapacityCorrectionLT * Curve::CurveValue(state, compressor.CapacityCurvePtr, TsatforPsucLT, TsatforPdisLT); compressor.MassFlow = compressor.Capacity / TotalEnthalpyChangeActualLT; - compressor.ElecConsumption = compressor.Power * LocalTimeStep * Constant::SecInHour; - compressor.CoolingEnergy = compressor.Capacity * LocalTimeStep * Constant::SecInHour; + compressor.ElecConsumption = compressor.Power * localTimeStepSec; + compressor.CoolingEnergy = compressor.Capacity * localTimeStepSec; compressor.LoadFactor = 1.0; if ((this->TotCompCapacityLP + compressor.Capacity) >= NeededCapacityLT) { LFLastComp = (NeededCapacityLT - this->TotCompCapacityLP) / compressor.Capacity; @@ -13828,8 +13500,8 @@ void TransRefrigSystemData::CalculateTransCompressors(EnergyPlusData &state) this->TotCompCapacityLP += compressor.Capacity; this->RefMassFlowCompsLP += compressor.MassFlow; this->TotCompPowerLP += compressor.Power; - compressor.ElecConsumption = compressor.Power * LocalTimeStep * Constant::SecInHour; - compressor.CoolingEnergy = compressor.Capacity * LocalTimeStep * Constant::SecInHour; + compressor.ElecConsumption = compressor.Power * localTimeStepSec; + compressor.CoolingEnergy = compressor.Capacity * localTimeStepSec; compressor.LoadFactor = LFLastComp; break; } else { @@ -14014,8 +13686,8 @@ void TransRefrigSystemData::CalculateTransCompressors(EnergyPlusData &state) } // (GasCooler(SysNum)%TransOpFlag) // Mass flow through HP compressors is HP compressor refrigerating capacity divided by MT load, LT load and LP compressor power compressor.MassFlow = TotalRefMassFlow * compressor.Capacity / (NeededCapacityMT + NeededCapacityLT + this->TotCompPowerLP); - compressor.ElecConsumption = compressor.Power * LocalTimeStep * Constant::SecInHour; - compressor.CoolingEnergy = compressor.Capacity * LocalTimeStep * Constant::SecInHour; + compressor.ElecConsumption = compressor.Power * localTimeStepSec; + compressor.CoolingEnergy = compressor.Capacity * localTimeStepSec; compressor.LoadFactor = 1.0; // calculate load factor for last compressor added // assumes either cycling or part load eff = full load eff for last compressor @@ -14027,8 +13699,8 @@ void TransRefrigSystemData::CalculateTransCompressors(EnergyPlusData &state) this->TotCompCapacityHP += compressor.Capacity; this->RefMassFlowCompsHP += compressor.MassFlow; this->TotCompPowerHP += compressor.Power; - compressor.ElecConsumption = compressor.Power * LocalTimeStep * Constant::SecInHour; - compressor.CoolingEnergy = compressor.Capacity * LocalTimeStep * Constant::SecInHour; + compressor.ElecConsumption = compressor.Power * localTimeStepSec; + compressor.CoolingEnergy = compressor.Capacity * localTimeStepSec; compressor.LoadFactor = LFLastComp; break; } else { @@ -14043,8 +13715,8 @@ void TransRefrigSystemData::CalculateTransCompressors(EnergyPlusData &state) this->RefMassFlowComps = this->RefMassFlowCompsLP + this->RefMassFlowCompsHP; this->TotCompCapacity = this->TotCompCapacityHP + this->TotCompCapacityLP; this->AverageCompressorCOP = (this->TotCompCapacityHP - this->TotCompPowerLP) / (this->TotCompPowerLP + this->TotCompPowerHP); - this->TotCompElecConsump = (this->TotCompPowerLP + this->TotCompPowerHP) * LocalTimeStep * Constant::SecInHour; - this->TotCompCoolingEnergy = (this->TotCompCapacityLP + this->TotCompCapacityHP) * LocalTimeStep * Constant::SecInHour; + this->TotCompElecConsump = (this->TotCompPowerLP + this->TotCompPowerHP) * localTimeStepSec; + this->TotCompCoolingEnergy = (this->TotCompCapacityLP + this->TotCompCapacityHP) * localTimeStepSec; } void RefrigSystemData::CalculateSubcoolers(EnergyPlusData &state) @@ -14074,8 +13746,8 @@ void RefrigSystemData::CalculateSubcoolers(EnergyPlusData &state) auto &Condenser = state.dataRefrigCase->Condenser; auto &Subcooler = state.dataRefrigCase->Subcooler; - Real64 LocalTimeStep = state.dataGlobal->TimeStepZone; - if (state.dataRefrigCase->UseSysTimeStep) LocalTimeStep = state.dataHVACGlobal->TimeStepSys; + Real64 localTimeStep = (state.dataRefrigCase->UseSysTimeStep) ? state.dataHVACGlobal->TimeStepSys : state.dataGlobal->TimeStepZone; + Real64 localTimeStepSec = localTimeStep * Constant::rSecsInHour; // HCaseIn has to be recalculated as the starting point for the subcoolers here because // of the multiple number of iterations through this subroutine and because Tcondense is evolving. @@ -14137,7 +13809,7 @@ void RefrigSystemData::CalculateSubcoolers(EnergyPlusData &state) int SysProvideID = cooler.MechSourceSysID; System(SysProvideID).MechSCLoad(SubcoolerID) = mechSCLoad; cooler.MechSCTransLoad = mechSCLoad; - cooler.MechSCTransEnergy = mechSCLoad * LocalTimeStep * Constant::SecInHour; + cooler.MechSCTransEnergy = mechSCLoad * localTimeStepSec; // Reset inlet temperature for any LSHX that follows this mech subcooler TLiqInActualLocal = ControlTLiqOut; this->TCompIn = this->TEvapNeeded + CaseSuperheat; @@ -14152,7 +13824,7 @@ void RefrigSystemData::CalculateSubcoolers(EnergyPlusData &state) this->TCompIn = TVapInActual + SubcoolerSupHeat; this->HCaseIn -= SubcoolLoad / this->RefMassFlowtoLoads; this->LSHXTrans = SubcoolLoad; - this->LSHXTransEnergy = SubcoolLoad * LocalTimeStep * Constant::SecInHour; + this->LSHXTransEnergy = SubcoolLoad * localTimeStepSec; } break; default: break; @@ -15000,23 +14672,19 @@ void WalkInData::CalculateWalkIn(EnergyPlusData &state) // Absolute pointer to Real64 DensitySqRtFactor(0.0); // from ASHRAE 2010 eq 12 page 24.4 for door infiltration // Current value of WalkIn operating (availability) schedule - Real64 WalkInSchedule = ScheduleManager::GetCurrentScheduleValue(state, this->SchedPtr); + Real64 WalkInSchedule = this->availSched->getCurrentVal(); if (WalkInSchedule <= 0) return; // GET OTHER SCHEDULES - DefrostSchedule = ScheduleManager::GetCurrentScheduleValue(state, this->DefrostSchedPtr); - Real64 DefrostDripDownSchedule = ScheduleManager::GetCurrentScheduleValue(state, this->DefrostDripDownSchedPtr); + DefrostSchedule = this->defrostSched->getCurrentVal(); + Real64 DefrostDripDownSchedule = this->defrostDripDownSched->getCurrentVal(); // next statement In case user doesn't understand concept of drip down schedule DefrostDripDownSchedule = max(DefrostDripDownSchedule, DefrostSchedule); // next four values optional, so set to default before checking for schedule - Real64 StockingLoad(0.0); // Total load due to stocking WalkIn product (W) - Real64 LightingSchedule = 1.0; - Real64 HeaterSchedule = 1.0; - Real64 CircFanSchedule = 1.0; - if (this->StockingSchedPtr > 0) StockingLoad = ScheduleManager::GetCurrentScheduleValue(state, this->StockingSchedPtr); - if (this->LightingSchedPtr > 0) LightingSchedule = ScheduleManager::GetCurrentScheduleValue(state, this->LightingSchedPtr); - if (this->HeaterSchedPtr > 0) HeaterSchedule = ScheduleManager::GetCurrentScheduleValue(state, this->HeaterSchedPtr); - if (this->CircFanSchedPtr > 0) CircFanSchedule = ScheduleManager::GetCurrentScheduleValue(state, this->CircFanSchedPtr); + Real64 StockingLoad = (this->stockingSched != nullptr) ? this->stockingSched->getCurrentVal() : 0.0; + Real64 LightingSchedule = (this->lightingSched != nullptr) ? this->lightingSched->getCurrentVal() : 1.0; + Real64 HeaterSchedule = (this->heaterSched != nullptr) ? this->heaterSched->getCurrentVal() : 1.0; + Real64 CircFanSchedule = (this->circFanAvailSched != nullptr) ? this->circFanAvailSched->getCurrentVal() : 1.0; // Set local subroutine variables for convenience Real64 TWalkIn = this->Temperature; // WalkIn operating temperature (C) @@ -15110,8 +14778,8 @@ void WalkInData::CalculateWalkIn(EnergyPlusData &state) // Absolute pointer to DrArea = StockDoorArea; // if exists, get Stock Door Zone schedule Real64 DoorOpenFactor = DefaultWalkInDoorOpenFactor; - if (this->StockDoorOpenSchedPtr(ZoneID) > 0) - DoorOpenFactor = ScheduleManager::GetCurrentScheduleValue(state, this->StockDoorOpenSchedPtr(ZoneID)); + if (this->stockDoorOpenScheds(ZoneID) != nullptr) + DoorOpenFactor = this->stockDoorOpenScheds(ZoneID)->getCurrentVal(); FullFlowInfLoad = 0.221 * DrArea * (EnthalpyZoneAir - EnthalpyAirWalkIn) * DensityAirWalkIn * DensitySqRtFactor * std::sqrt(Gravity * DrHeight) * DensityFactorFm; @@ -15128,8 +14796,8 @@ void WalkInData::CalculateWalkIn(EnergyPlusData &state) // Absolute pointer to DrArea = GlassDoorArea; // get Glass Door Zone schedule Real64 DoorOpenFactor = DefaultWalkInDoorOpenFactor; // default value - if (this->GlassDoorOpenSchedPtr(ZoneID) > 0) - DoorOpenFactor = ScheduleManager::GetCurrentScheduleValue(state, this->GlassDoorOpenSchedPtr(ZoneID)); + if (this->glassDoorOpenScheds(ZoneID) != nullptr) + DoorOpenFactor = this->glassDoorOpenScheds(ZoneID)->getCurrentVal(); FullFlowInfLoad = 0.221 * DrArea * (EnthalpyZoneAir - EnthalpyAirWalkIn) * DensityAirWalkIn * DensitySqRtFactor * std::sqrt(Gravity * DrHeight) * DensityFactorFm; @@ -15245,7 +14913,7 @@ void WalkInData::CalculateWalkIn(EnergyPlusData &state) // Absolute pointer to // Reduce defrost heat load on walkin by amount of ice melted during time step Real64 FrostChangekg = min(AvailDefrostEnergy / IceMeltEnthalpy, StartFrostKg); if (FrostChangekg < StartFrostKg) { - DefrostLoad -= FrostChangekg * IceMeltEnthalpy / state.dataGlobal->TimeStepZone / Constant::SecInHour; + DefrostLoad -= FrostChangekg * IceMeltEnthalpy / state.dataGlobal->TimeStepZone / Constant::rSecsInHour; if (!state.dataGlobal->WarmupFlag) this->KgFrost = StartFrostKg - FrostChangekg; // DefrostSchedule not changed } else { // all frost melted during time step, so need to terminate defrost @@ -15270,7 +14938,7 @@ void WalkInData::CalculateWalkIn(EnergyPlusData &state) // Absolute pointer to } else { // Not temperature control type Real64 FrostChangekg = min(DefrostEnergy / IceMeltEnthalpy, StartFrostKg); // Reduce defrost heat load on walkin by amount of ice melted during time step - DefrostLoad -= FrostChangekg * IceMeltEnthalpy / state.dataGlobal->TimeStepZone / Constant::SecInHour; + DefrostLoad -= FrostChangekg * IceMeltEnthalpy / state.dataGlobal->TimeStepZone / Constant::rSecsInHour; if (!state.dataGlobal->WarmupFlag) this->KgFrost = StartFrostKg - FrostChangekg; // DefrostSchedule not changed } // Temperature termination control type @@ -15308,7 +14976,7 @@ void WalkInData::CalculateWalkIn(EnergyPlusData &state) // Absolute pointer to // run full out until the temperature is brought back down. // Rate needed to serve all stored energy during single time step (W) - Real64 StoredEnergyRate = this->StoredEnergy / state.dataGlobal->TimeStepZone / Constant::SecInHour; + Real64 StoredEnergyRate = this->StoredEnergy / state.dataGlobal->TimeStepZone / Constant::rSecsInHour; Real64 LoadRequested = LoadTotal + StoredEnergyRate; // Load necessary to meet current and all stored energy needs (W) Real64 LatentCapApplied; // Walk In latent capacity at specific operating conditions @@ -15437,8 +15105,8 @@ void SecondaryLoopData::CalculateSecondary(EnergyPlusData &state, int const Seco auto &WalkIn = state.dataRefrigCase->WalkIn; auto &WarehouseCoil = state.dataRefrigCase->WarehouseCoil; - Real64 LocalTimeStep = state.dataGlobal->TimeStepZone; - if (state.dataRefrigCase->UseSysTimeStep) LocalTimeStep = state.dataHVACGlobal->TimeStepSys; + Real64 localTimeStep = (state.dataRefrigCase->UseSysTimeStep) ? state.dataHVACGlobal->TimeStepSys : state.dataGlobal->TimeStepZone; + Real64 localTimeStepSec = localTimeStep * Constant::rSecsInHour; switch (this->FluidType) { case SecFluidType::AlwaysLiquid: { @@ -15606,7 +15274,7 @@ void SecondaryLoopData::CalculateSecondary(EnergyPlusData &state, int const Seco // (e.g. as it may be following defrost cycles on cases or walk-ins served by secondary loop) // save the unmet/stored load to be met in succeeding time steps. if (this->NumCoils == 0) { - StoredEnergyRate = max(0.0, (this->UnmetEnergy / state.dataGlobal->TimeStepZone / Constant::SecInHour)); + StoredEnergyRate = max(0.0, (this->UnmetEnergy / state.dataGlobal->TimeStepZone / Constant::rSecsInHour)); // Load necessary to meet current and all stored energy needs (W) Real64 LoadRequested = TotalLoad + StoredEnergyRate; if (this->MaxLoad > LoadRequested) { @@ -15637,16 +15305,16 @@ void SecondaryLoopData::CalculateSecondary(EnergyPlusData &state, int const Seco // Bug TotalCoolingLoad not set but used below } // no air coils on secondary loop this->PumpPowerTotal = TotalPumpPower; - this->PumpElecEnergyTotal = TotalPumpPower * LocalTimeStep * Constant::SecInHour; + this->PumpElecEnergyTotal = TotalPumpPower * localTimeStepSec; this->TotalRefrigLoad = RefrigerationLoad; - this->TotalRefrigEnergy = RefrigerationLoad * LocalTimeStep * Constant::SecInHour; - this->TotalCoolingEnergy = TotalCoolingLoad * LocalTimeStep * Constant::SecInHour; + this->TotalRefrigEnergy = RefrigerationLoad * localTimeStepSec; + this->TotalCoolingEnergy = TotalCoolingLoad * localTimeStepSec; this->FlowVolActual = VolFlowRate; this->HotDefrostCondCredit = TotalHotDefrostCondCredit; this->DistPipeHeatGain = distPipeHeatGain; - this->DistPipeHeatGainEnergy = distPipeHeatGain * LocalTimeStep * Constant::SecInHour; + this->DistPipeHeatGainEnergy = distPipeHeatGain * localTimeStepSec; this->ReceiverHeatGain = receiverHeatGain; - this->ReceiverHeatGainEnergy = receiverHeatGain * LocalTimeStep * Constant::SecInHour; + this->ReceiverHeatGainEnergy = receiverHeatGain * localTimeStepSec; } void SumZoneImpacts(EnergyPlusData &state) @@ -15824,7 +15492,7 @@ void SimAirChillerSet(EnergyPlusData &state, RemainingOutputToCoolingSP = state.dataZoneEnergyDemand->ZoneSysEnergyDemand(ZoneNum).RemainingOutputReqToCoolSP; // RemainingOutputToCoolingSP in Watts, < 0 for cooling demand - if (RemainingOutputToCoolingSP < 0.0 && state.dataHeatBalFanSys->TempControlType(ZoneNum) != HVAC::ThermostatType::SingleHeating) { + if (RemainingOutputToCoolingSP < 0.0 && state.dataHeatBalFanSys->TempControlType(ZoneNum) != HVAC::SetptType::SingleHeat) { AirChillerSet(AirChillerSetPtr).QZnReqSens = RemainingOutputToCoolingSP; } else { AirChillerSet(AirChillerSetPtr).QZnReqSens = 0.0; @@ -15868,7 +15536,7 @@ void AirChillerSetData::CalculateAirChillerSets(EnergyPlusData &state) // Note, all coils in a coil set are in the same zone // the coils may be served by different detailed systems // The coils are dispatched to meet the load specified in the previous time step in order listed in coilset object - AirChillerSetSchedule = ScheduleManager::GetCurrentScheduleValue(state, this->SchedPtr); + AirChillerSetSchedule = this->availSched->getCurrentVal(); if (AirChillerSetSchedule <= 0.0) return; QZNReqSens = this->QZnReqSens; @@ -16009,17 +15677,16 @@ void WarehouseCoilData::CalculateCoil(EnergyPlusData &state, Real64 const QZnReq static constexpr std::string_view TrackMessage("from RefrigeratedCase:CalculateCoil"); - Real64 CoilSchedule = ScheduleManager::GetCurrentScheduleValue(state, this->SchedPtr); // Current value of Coil operating (availability) schedule + Real64 CoilSchedule = this->availSched->getCurrentVal(); // Current value of Coil operating (availability) schedule if (CoilSchedule <= 0.0) return; - Real64 DefrostSchedule = ScheduleManager::GetCurrentScheduleValue(state, this->DefrostSchedPtr); // Coil defrost schedule, between 0 and 1 - Real64 DefrostDripDownSchedule = ScheduleManager::GetCurrentScheduleValue( - state, this->DefrostDripDownSchedPtr); // Coil drip-down schedule (allows coil to drain after defrost) + Real64 DefrostSchedule = this->defrostSched->getCurrentVal(); // Coil defrost schedule, between 0 and 1 + Real64 DefrostDripDownSchedule = this->defrostDripDownSched->getCurrentVal(); // Coil drip-down schedule (allows coil to drain after defrost) // next statement In case user doesn't understand concept of drip down schedule DefrostDripDownSchedule = max(DefrostDripDownSchedule, DefrostSchedule); // next value optional, so set to default before checking for schedule Real64 HeaterSchedule = 1.0; // zero to one - if (this->HeaterSchedPtr > 0) HeaterSchedule = ScheduleManager::GetCurrentScheduleValue(state, this->HeaterSchedPtr); + if (this->heaterAvailSched != nullptr) HeaterSchedule = this->heaterAvailSched->getCurrentVal(); // Set local subroutine variables for convenience FanSpeedCtrlType FanSpeedControlType = this->FanType; @@ -16311,7 +15978,7 @@ void WarehouseCoilData::CalculateCoil(EnergyPlusData &state, Real64 const QZnReq // Reduce defrost heat load on walkin by amount of ice melted during time step FrostChangekg = min(AvailDefrostEnergy / IceMeltEnthalpy, StartFrostKg); if (FrostChangekg < StartFrostKg) { - DefrostLoad -= FrostChangekg * IceMeltEnthalpy / state.dataHVACGlobal->TimeStepSys / Constant::SecInHour; + DefrostLoad -= FrostChangekg * IceMeltEnthalpy / state.dataHVACGlobal->TimeStepSys / Constant::rSecsInHour; if (!state.dataGlobal->WarmupFlag) this->KgFrost = StartFrostKg - FrostChangekg; // DefrostSchedule not changed because ice not all melted, temp term not triggered } else { // all frost melted during time step, so need to terminate defrost @@ -16339,7 +16006,7 @@ void WarehouseCoilData::CalculateCoil(EnergyPlusData &state, Real64 const QZnReq // Reduce defrost heat load on the zone by amount of ice melted during time step // But DefrostSchedule not changed FrostChangekg = max(0.0, min((DefrostEnergy / IceMeltEnthalpy), StartFrostKg)); - DefrostLoad -= FrostChangekg * IceMeltEnthalpy / state.dataHVACGlobal->TimeStepSys / Constant::SecInHour; + DefrostLoad -= FrostChangekg * IceMeltEnthalpy / state.dataHVACGlobal->TimeStepSys / Constant::rSecsInHour; if (!state.dataGlobal->WarmupFlag) this->KgFrost = StartFrostKg - FrostChangekg; } // Temperature termination vs. time-clock control type diff --git a/src/EnergyPlus/RefrigeratedCase.hh b/src/EnergyPlus/RefrigeratedCase.hh index 8f031c07130..45f0d36c39e 100644 --- a/src/EnergyPlus/RefrigeratedCase.hh +++ b/src/EnergyPlus/RefrigeratedCase.hh @@ -285,7 +285,7 @@ namespace RefrigeratedCase { std::string Name; // Name of refrigerated display case std::string ZoneName; // Zone or Location of Display Case int NumSysAttach = 0; // Number of systems attached to case, error if /=1 - int SchedPtr = 0; // Index to the correct availability schedule + Sched::Schedule *availSched = nullptr; // Availability schedule int ZoneNodeNum = 0; // Index to Zone Node int ActualZoneNum = 0; // Index to Zone int ZoneRANode = 0; // Node number of return node in zone @@ -305,7 +305,7 @@ namespace RefrigeratedCase { Real64 OperatingFanPower = 0.0; // Operating power of refrigerated case fan [W/m] Real64 RatedLightingPower = 0.0; // Rated (consis w RateTotCapPerLength) power of refrigerated case lights [W/m] Real64 LightingPower = 0.0; // Installed power of refrigerated case lights [W/m] - int LightingSchedPtr = 0; // Index to the correct case lighting schedule + Sched::Schedule *lightingSched = nullptr; // case lighting schedule Real64 AntiSweatPower = 0.0; // Rated power of refrigerated case anti-sweat heaters [W/m] Real64 MinimumASPower = 0.0; // Minimum power output of case anti-sweat heaters [W/m] ASHtrCtrlType AntiSweatControlType = ASHtrCtrlType::Invalid; // Type of anti-sweat heater control: @@ -314,12 +314,12 @@ namespace RefrigeratedCase { Real64 Height = 0.0; // case height for AS heater with heat balance control RefCaseDefrostType defrostType = RefCaseDefrostType::Invalid; // Case defrost control type, Off-cycle,Timed,Hot-gas,Electric Real64 DefrostPower = 0.0; // Rated power of refrigerated case defrost [W/m] - int DefrostSchedPtr = 0; // Index to the correct defrost schedule - int DefrostDripDownSchedPtr = 0; // Index to the correct fail-safe schedule + Sched::Schedule *defrostSched = nullptr; // defrost schedule + Sched::Schedule *defrostDripDownSched = nullptr; // correct fail-safe schedule Real64 Length = 0.0; // Length of refrigerated case [m] Real64 Temperature = 0.0; // Rated case temperature [C] Real64 RAFrac = 0.0; // HVAC under case return air fraction [0-1] - int StockingSchedPtr = 0; // Index to the correct product stocking schedule + Sched::Schedule *stockingSched = nullptr; // product stocking schedule Real64 LightingFractionToCase = 0.0; // Fraction of lighting energy that directly contributes to the // case cooling load. The remainder contributes to the zone load // (air heat balance). @@ -337,7 +337,7 @@ namespace RefrigeratedCase { Real64 DesignFanPower = 0.0; // Design power of case fan=Operatingpower*Length [W] Real64 StoredEnergy = 0.0; // Cumulative Stored Energy not met by evaporator [J] Real64 StoredEnergySaved = 0.0; // Cumulative Stored Energy not met by evaporator [J] - int CaseCreditFracSchedPtr = 0; // Index to the case credit reduction schedule + Sched::Schedule *caseCreditFracSched = nullptr; // case credit reduction schedule // Report Variables Real64 TotalCoolingLoad = 0.0; // Refrigerated case total cooling rate (W) Real64 TotalCoolingEnergy = 0.0; // Refrigerated case total cooling energy (J) @@ -456,7 +456,7 @@ namespace RefrigeratedCase { Real64 EvapPumpConsumption = 0.0; // Evaporative cooling water pump electric consumption (J) Real64 EvapWaterConsumpRate = 0.0; // Evaporative condenser water consumption rate (m3/s) Real64 EvapWaterConsumption = 0.0; // Evaporative condenser water consumption (m3) - int EvapSchedPtr = 0; // Index to the correct evap condenser availability schedule + Sched::Schedule *evapAvailSched = nullptr; // evap condenser availability schedule Real64 BasinHeaterPowerFTempDiff = 0.0; // Basin heater capacity per degree K below setpoint (W/K) Real64 BasinHeaterSetPointTemp = 2.0; // Setpoint temperature for basin heater operation (C) Real64 BasinHeaterPower = 0.0; // Power demand from basin heater (W) @@ -499,7 +499,7 @@ namespace RefrigeratedCase { int PlantTypeOfNum = 0; // Water-cooled condenser plant equipment type PlantLocation plantLoc; // Water-cooled condenser plant location Real64 OutletTemp = 0.0; // Water-cooling condenser outlet temperature (C) - int OutletTempSchedPtr = 0; // Schedule pointer for condenser outlet temp setting + Sched::Schedule *outletTempSched = nullptr; // Schedule for condenser outlet temp setting Real64 VolFlowRate = 0.0; // Water-cooled condenser volumetric flow rate (m3/s) Real64 DesVolFlowRate = 0.0; // Water-cooled condenser design volumetric flow rate (m3/s) Real64 MassFlowRate = 0.0; // Water-cooled condenser mass flow rate (kg/s) @@ -864,14 +864,14 @@ namespace RefrigeratedCase { int HighFlowWarnIndex = 0; // Water outlet high flow warning index int HighInletWarnIndex = 0; // Water inlet high temp warning index int InletNode = 0; // Water-cooled condenser inlet node number - int EvapSchedPtr = 0; // Index to the correct evap condenser availability schedule + Sched::Schedule *evapAvailSched = nullptr; // Evap condenser availability schedule WaterSupply EvapWaterSupplyMode = WaterSupply::FromMains; // Source of water for evap condenser cooling int EvapWaterSupTankID = 0; // TankID when evap condenser uses water from storage tank int EvapWaterTankDemandARRID = 0; // Demand index when evap condenser uses water from storage tank int OutletNode = 0; // Water-cooled condenser outlet node number int PlantTypeOfNum = 0; // Water-cooled condenser plant equipment type PlantLocation plantLoc; // Water-cooled condenser plant location - int OutletTempSchedPtr = 0; // Schedule pointer for condenser outlet temp setting + Sched::Schedule *outletTempSched = nullptr; // Schedule for condenser outlet temp setting int InletAirNodeNum = 0; // Inlet air node number, can be outside or in a zone int InletAirZoneNum = 0; // Inlet air zone number, if located in a zone FanSpeedCtrlType FanSpeedControlType = FanSpeedCtrlType::Invalid; // fixed, two-speed, or variable @@ -1183,19 +1183,19 @@ namespace RefrigeratedCase { std::string Name; // Name of walk in cooler Array1D_string ZoneName; // Names of zones exchanging energy with cooler - int CircFanSchedPtr = 0; // Index to the correct availability schedule - int DefrostDripDownSchedPtr = 0; // Index to the correct fail-safe schedule - int DefrostSchedPtr = 0; // Index to the correct defrost schedule + Sched::Schedule *circFanAvailSched = nullptr; // Index to the correct availability schedule + Sched::Schedule *defrostDripDownSched = nullptr; // fail-safe schedule + Sched::Schedule *defrostSched = nullptr; // defrost schedule DefrostCtrlType DefrostControlType = DefrostCtrlType::Invalid; // WalkIn defrost control type, Timed,Frost level WalkinClrDefrostType defrostType = WalkinClrDefrostType::Invalid; // WalkIn defrost type, Hot-gas,Electric, Hot-brine - int HeaterSchedPtr = 0; // Index to the correct availability schedule - int LightingSchedPtr = 0; // Index to the correct WalkIn lighting schedule + Sched::Schedule *heaterSched = nullptr; // heater availability schedule + Sched::Schedule *lightingSched = nullptr; // walkIn lighting schedule int NumSysAttach = 0; // Number of systems attached to WalkIn, error if /=1 int NumZones = 0; // Number of zones exchanging energy with WalkIn - int SchedPtr = 0; // Index to the correct availability schedule - int StockingSchedPtr = 0; // Index to the correct product stocking schedule - Array1D_int GlassDoorOpenSchedPtr; // Index to the door opening schedule - Array1D_int StockDoorOpenSchedPtr; // Index to the door opening schedule + Sched::Schedule *availSched = nullptr; // availability schedule + Sched::Schedule *stockingSched = nullptr; // product stocking schedule + Array1D glassDoorOpenScheds; // door opening schedule + Array1D stockDoorOpenScheds; // door opening schedule Array1D StockDoorProtectType; // Index to door protection type Array1D_int ZoneNodeNum; // Index to Zone Node Array1D_int ZoneNum; // Index to Zone @@ -1313,16 +1313,16 @@ namespace RefrigeratedCase { bool SecStatusLast = false; // Flag to show if this is the last coil on a particular secondary bool SysStatusFirst = false; // Flag to show if this is the first coil on a particular primary bool SysStatusLast = false; // Flag to show if this is the last coil on a particular primary - int CoilFanSchedPtr = 0; // Index to the correct availability schedule - int DefrostDripDownSchedPtr = 0; // Index to the correct fail-safe schedule - int DefrostSchedPtr = 0; // Index to the correct defrost schedule + Sched::Schedule *coilFanAvaildSched = nullptr; // availability schedule + Sched::Schedule *defrostDripDownSched = nullptr; // fail-safe schedule + Sched::Schedule *defrostSched = nullptr; // defrost schedule DefrostCtrlType DefrostControlType = DefrostCtrlType::Invalid; // Coil defrost control type, Timed,Frost level DefrostType defrostType = DefrostType::Invalid; // Coil defrost type, Hot-gas,Electric, Hot-brine FanSpeedCtrlType FanType = FanSpeedCtrlType::Invalid; // Index to coil fan type (fixed, two-speed, etc.) - int HeaterSchedPtr = 0; // Index to the correct availability schedule + Sched::Schedule *heaterAvailSched = nullptr; // availability schedule int NumSysAttach = 0; // Number of refrigerating systems cooling this coil (error check purpose) RatingType ratingType = RatingType::Invalid; // Indicates which type of manufacturer's rating is used - int SchedPtr = 0; // Index to the correct availability schedule + Sched::Schedule *availSched = nullptr; // availability schedule int SCIndex = 0; // IDs which of European standard conditions is used for rating int SecServeID = 0; // Index to the refrigeration system serving this coil SHRCorrectionType SHRCorrType = SHRCorrectionType::Invalid; // Index to type of correction for sensible heat ratio @@ -1426,7 +1426,7 @@ namespace RefrigeratedCase { Array1D_int CoilNum; // ID number of Individual Chiller in set int ChillerSetID = 0; // ID number for this set of chillers (all serving one zone, // but can be chilled by multi systems) - int SchedPtr = 0; // Schedule to take whole set off-line if needed + Sched::Schedule *availSched = nullptr; // Schedule to take whole set off-line if needed // availability? int NodeNumInlet = 0; // Node ID Number of inlet for chiller set as a whole, not identified for specific coils int NodeNumOutlet = 0; // Node ID Number of outlet for chiller set as a whole, not identified for specific coils int NumCoils = 0; // Number of individual chillers in set @@ -1626,6 +1626,10 @@ struct RefrigeratedCaseData : BaseGlobalStruct Real64 MyStepStartTimeSaved = 0.0; // Used to determine whether the system time step is a repetition Real64 TimeStepFraction = 0.0; // Used to calculate my current time + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/ReportCoilSelection.cc b/src/EnergyPlus/ReportCoilSelection.cc index defc4a2b2d2..cbfd75c5360 100644 --- a/src/EnergyPlus/ReportCoilSelection.cc +++ b/src/EnergyPlus/ReportCoilSelection.cc @@ -2006,9 +2006,9 @@ std::string ReportCoilSelection::getTimeText(EnergyPlusData &state, int const ti int timeStepIndex(0); int hourPrint; for (int hourCounter = 1; hourCounter <= 24; ++hourCounter) { - for (int timeStepCounter = 1; timeStepCounter <= state.dataGlobal->NumOfTimeStepInHour; ++timeStepCounter) { + for (int timeStepCounter = 1; timeStepCounter <= state.dataGlobal->TimeStepsInHour; ++timeStepCounter) { ++timeStepIndex; - minutes += state.dataGlobal->MinutesPerTimeStep; + minutes += state.dataGlobal->MinutesInTimeStep; if (minutes == 60) { minutes = 0; hourPrint = hourCounter; diff --git a/src/EnergyPlus/ReportCoilSelection.hh b/src/EnergyPlus/ReportCoilSelection.hh index 5c15590f019..f82eb37f236 100644 --- a/src/EnergyPlus/ReportCoilSelection.hh +++ b/src/EnergyPlus/ReportCoilSelection.hh @@ -456,6 +456,10 @@ struct ReportCoilSelectionData : BaseGlobalStruct std::unique_ptr coilSelectionReportObj; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/ResultsFramework.hh b/src/EnergyPlus/ResultsFramework.hh index d8af9cc1c8d..809a978de3b 100644 --- a/src/EnergyPlus/ResultsFramework.hh +++ b/src/EnergyPlus/ResultsFramework.hh @@ -574,6 +574,10 @@ struct ResultsFrameworkData : BaseGlobalStruct std::unique_ptr resultsFramework = std::make_unique(); + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/ReturnAirPathManager.hh b/src/EnergyPlus/ReturnAirPathManager.hh index 62fd1f16658..1237b4db415 100644 --- a/src/EnergyPlus/ReturnAirPathManager.hh +++ b/src/EnergyPlus/ReturnAirPathManager.hh @@ -74,6 +74,10 @@ struct ReturnAirPathMgr : BaseGlobalStruct bool GetInputFlag = true; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/RoomAirModelAirflowNetwork.cc b/src/EnergyPlus/RoomAirModelAirflowNetwork.cc index 01fbcadae2a..1abbb505382 100644 --- a/src/EnergyPlus/RoomAirModelAirflowNetwork.cc +++ b/src/EnergyPlus/RoomAirModelAirflowNetwork.cc @@ -831,14 +831,14 @@ namespace RoomAir { if (state.dataSurface->SurfWinHeatGain(SurfNum) >= 0.0) { state.dataSurface->SurfWinHeatGainRep(SurfNum) = state.dataSurface->SurfWinHeatGain(SurfNum); state.dataSurface->SurfWinHeatGainRepEnergy(SurfNum) = - state.dataSurface->SurfWinHeatGainRep(SurfNum) * state.dataGlobal->TimeStepZone * Constant::SecInHour; + state.dataSurface->SurfWinHeatGainRep(SurfNum) * state.dataGlobal->TimeStepZone * Constant::rSecsInHour; } else { state.dataSurface->SurfWinHeatLossRep(SurfNum) = -state.dataSurface->SurfWinHeatGain(SurfNum); state.dataSurface->SurfWinHeatLossRepEnergy(SurfNum) = - state.dataSurface->SurfWinHeatLossRep(SurfNum) * state.dataGlobal->TimeStepZone * Constant::SecInHour; + state.dataSurface->SurfWinHeatLossRep(SurfNum) * state.dataGlobal->TimeStepZone * Constant::rSecsInHour; } state.dataSurface->SurfWinHeatTransferRepEnergy(SurfNum) = - state.dataSurface->SurfWinHeatGain(SurfNum) * state.dataGlobal->TimeStepZone * Constant::SecInHour; + state.dataSurface->SurfWinHeatGain(SurfNum) * state.dataGlobal->TimeStepZone * Constant::rSecsInHour; } } diff --git a/src/EnergyPlus/RoomAirModelAirflowNetwork.hh b/src/EnergyPlus/RoomAirModelAirflowNetwork.hh index c2d5d907798..083ce7a114d 100644 --- a/src/EnergyPlus/RoomAirModelAirflowNetwork.hh +++ b/src/EnergyPlus/RoomAirModelAirflowNetwork.hh @@ -105,6 +105,10 @@ struct RoomAirModelAirflowNetworkData : BaseGlobalStruct bool OneTimeFlagConf = true; bool EnvrnFlag = true; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/RoomAirModelManager.cc b/src/EnergyPlus/RoomAirModelManager.cc index 629950b8f1a..404f41f001e 100644 --- a/src/EnergyPlus/RoomAirModelManager.cc +++ b/src/EnergyPlus/RoomAirModelManager.cc @@ -257,8 +257,6 @@ namespace RoomAir { // Using/Aliasing using DataZoneEquipment::EquipConfiguration; - using ScheduleManager::GetScheduleIndex; - // SUBROUTINE PARAMETER DEFINITIONS: static constexpr std::string_view routineName = "GetUserDefinedPatternData: "; @@ -323,20 +321,16 @@ namespace RoomAir { airPatternZoneInfo.Name = ipsc->cAlphaArgs(1); // Name of this Control Object airPatternZoneInfo.ZoneName = ipsc->cAlphaArgs(2); // Zone Name - airPatternZoneInfo.AvailSched = ipsc->cAlphaArgs(3); if (ipsc->lAlphaFieldBlanks(3)) { - airPatternZoneInfo.AvailSchedID = ScheduleManager::ScheduleAlwaysOn; - } else { - airPatternZoneInfo.AvailSchedID = GetScheduleIndex(state, ipsc->cAlphaArgs(3)); - if (airPatternZoneInfo.AvailSchedID == 0) { - ShowSevereItemNotFound(state, eoh, ipsc->cAlphaFieldNames(3), ipsc->cAlphaArgs(3)); - ErrorsFound = true; - } + airPatternZoneInfo.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((airPatternZoneInfo.availSched = Sched::GetSchedule(state, ipsc->cAlphaArgs(3))) == nullptr) { + ShowSevereItemNotFound(state, eoh, ipsc->cAlphaFieldNames(3), ipsc->cAlphaArgs(3)); + ErrorsFound = true; } - airPatternZoneInfo.PatternCntrlSched = ipsc->cAlphaArgs(4); // Schedule Name for Leading Pattern Control for this Zone - airPatternZoneInfo.PatternSchedID = GetScheduleIndex(state, ipsc->cAlphaArgs(4)); - if (airPatternZoneInfo.PatternSchedID == 0) { + + if (ipsc->lAlphaFieldBlanks(4)) { + } else if ((airPatternZoneInfo.patternSched = Sched::GetSchedule(state, ipsc->cAlphaArgs(4))) == nullptr) { ShowSevereItemNotFound(state, eoh, ipsc->cAlphaFieldNames(4), ipsc->cAlphaArgs(4)); ErrorsFound = true; } @@ -891,9 +885,6 @@ namespace RoomAir { // METHODOLOGY EMPLOYED: // Use input processor to get input from idf file - // Using/Aliasing - using namespace ScheduleManager; - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: constexpr std::string_view routineName = "GetDisplacementVentData"; int IOStat; @@ -941,7 +932,7 @@ namespace RoomAir { if (ipsc->lAlphaFieldBlanks(2)) { ShowSevereEmptyField(state, eoh, ipsc->cAlphaFieldNames(2)); ErrorsFound = true; - } else if ((zoneDV3N.SchedGainsPtr = GetScheduleIndex(state, ipsc->cAlphaArgs(2))) == 0) { + } else if ((zoneDV3N.gainsSched = Sched::GetSchedule(state, ipsc->cAlphaArgs(2))) == nullptr) { ShowSevereItemNotFound(state, eoh, ipsc->cAlphaFieldNames(2), ipsc->cAlphaArgs(2)); ErrorsFound = true; } @@ -966,9 +957,6 @@ namespace RoomAir { // METHODOLOGY EMPLOYED: // Use input processor to get input from idf file - // Using/Aliasing - using namespace ScheduleManager; - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: constexpr std::string_view routineName = "GetCrossVentData"; @@ -1015,7 +1003,7 @@ namespace RoomAir { if (ipsc->lAlphaFieldBlanks(2)) { ShowSevereEmptyField(state, eoh, ipsc->cAlphaFieldNames(2)); ErrorsFound = true; - } else if ((zoneCV.SchedGainsPtr = GetScheduleIndex(state, ipsc->cAlphaArgs(2))) == 0) { + } else if ((zoneCV.gainsSched = Sched::GetSchedule(state, ipsc->cAlphaArgs(2))) == nullptr) { ShowSevereItemNotFound(state, eoh, ipsc->cAlphaFieldNames(2), ipsc->cAlphaArgs(2)); ErrorsFound = true; } @@ -1086,9 +1074,6 @@ namespace RoomAir { // METHODOLOGY EMPLOYED: // Use input processor to get input from idf file - // Using/Aliasing - using namespace ScheduleManager; - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: constexpr std::string_view routineName = "GetUFADZoneData"; @@ -1252,7 +1237,6 @@ namespace RoomAir { // Using/Aliasing using InternalHeatGains::GetInternalGainDeviceIndex; - using ScheduleManager::GetScheduleIndex; // SUBROUTINE LOCAL VARIABLE DECLARATIONS: constexpr std::string_view routineName = "GetRoomAirflowNetworkData"; diff --git a/src/EnergyPlus/RoomAirModelUserTempPattern.cc b/src/EnergyPlus/RoomAirModelUserTempPattern.cc index 6a0738ea74e..45cdc3a3f9b 100644 --- a/src/EnergyPlus/RoomAirModelUserTempPattern.cc +++ b/src/EnergyPlus/RoomAirModelUserTempPattern.cc @@ -198,11 +198,10 @@ void CalcTempDistModel(EnergyPlusData &state, int const ZoneNum) // index number // Using/Aliasing using General::FindNumberInList; - using ScheduleManager::GetCurrentScheduleValue; auto &patternZoneInfo = state.dataRoomAir->AirPatternZoneInfo(ZoneNum); // first determine availability - Real64 AvailTest = GetCurrentScheduleValue(state, patternZoneInfo.AvailSchedID); + Real64 AvailTest = patternZoneInfo.availSched->getCurrentVal(); if ((AvailTest != 1.0) || (!patternZoneInfo.IsUsed)) { // model not to be used. Use complete mixing method @@ -217,7 +216,7 @@ void CalcTempDistModel(EnergyPlusData &state, int const ZoneNum) // index number } else { // choose pattern and call subroutine - int CurntPatternKey = GetCurrentScheduleValue(state, patternZoneInfo.PatternSchedID); + int CurntPatternKey = patternZoneInfo.patternSched->getCurrentVal(); int CurPatrnID = FindNumberInList(CurntPatternKey, state.dataRoomAir->AirPattern, &TemperaturePattern::PatrnID); diff --git a/src/EnergyPlus/RoomAirModelUserTempPattern.hh b/src/EnergyPlus/RoomAirModelUserTempPattern.hh index 20b0eda7a34..b2ce2f3ced1 100644 --- a/src/EnergyPlus/RoomAirModelUserTempPattern.hh +++ b/src/EnergyPlus/RoomAirModelUserTempPattern.hh @@ -124,6 +124,10 @@ struct RoomAirModelUserTempPatternData : BaseGlobalStruct Array1D_bool MyEnvrnFlag; // flag for init once at start of environment Array1D_bool SetupOutputFlag; // flag to set up output variable one-time if 2-grad model used + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/RuntimeLanguageProcessor.cc b/src/EnergyPlus/RuntimeLanguageProcessor.cc index 55dc9cd6380..9f2d3290d62 100644 --- a/src/EnergyPlus/RuntimeLanguageProcessor.cc +++ b/src/EnergyPlus/RuntimeLanguageProcessor.cc @@ -136,7 +136,7 @@ void InitializeRuntimeLanguage(EnergyPlusData &state) state.dataRuntimeLangProcessor->OnVariableNum = NewEMSVariable(state, "ON", 0, state.dataRuntimeLang->True); state.dataRuntimeLangProcessor->PiVariableNum = NewEMSVariable(state, "PI", 0, SetErlValueNumber(Constant::Pi)); state.dataRuntimeLangProcessor->TimeStepsPerHourVariableNum = - NewEMSVariable(state, "TIMESTEPSPERHOUR", 0, SetErlValueNumber(double(state.dataGlobal->NumOfTimeStepInHour))); + NewEMSVariable(state, "TIMESTEPSPERHOUR", 0, SetErlValueNumber(double(state.dataGlobal->TimeStepsInHour))); // Create dynamic built-in variables state.dataRuntimeLangProcessor->YearVariableNum = NewEMSVariable(state, "YEAR", 0); @@ -1967,11 +1967,11 @@ ErlValueType EvaluateExpression(EnergyPlusData &state, int const ExpressionNum, break; case ErlFunc::DegToRad: - ReturnValue = SetErlValueNumber(Operand(1).Number * Constant::DegToRadians); + ReturnValue = SetErlValueNumber(Operand(1).Number * Constant::DegToRad); break; case ErlFunc::RadToDeg: - ReturnValue = SetErlValueNumber(Operand(1).Number / Constant::DegToRadians); + ReturnValue = SetErlValueNumber(Operand(1).Number / Constant::DegToRad); break; case ErlFunc::Exp: @@ -2545,7 +2545,7 @@ ErlValueType EvaluateExpression(EnergyPlusData &state, int const ExpressionNum, case ErlFunc::TodayLiquidPrecip: { int iHour = (Operand(1).Number + 1); // Operand 1 is hour from 0:23 int iTimeStep = Operand(2).Number; - if ((iHour > 0) && (iHour <= 24) && (iTimeStep > 0) && (iTimeStep <= state.dataGlobal->NumOfTimeStepInHour)) { + if ((iHour > 0) && (iHour <= 24) && (iTimeStep > 0) && (iTimeStep <= state.dataGlobal->TimeStepsInHour)) { auto const &today = state.dataWeather->wvarsHrTsToday(iTimeStep, iHour); ReturnValue.initialized = true; ReturnValue.Type = Value::Number; @@ -2621,7 +2621,7 @@ ErlValueType EvaluateExpression(EnergyPlusData &state, int const ExpressionNum, case ErlFunc::TomorrowLiquidPrecip: { int iHour = (Operand(1).Number + 1); // Operand 1 is hour from 0:23 int iTimeStep = Operand(2).Number; - if ((iHour > 0) && (iHour <= Constant::HoursInDay) && (iTimeStep > 0) && (iTimeStep <= state.dataGlobal->NumOfTimeStepInHour)) { + if ((iHour > 0) && (iHour <= Constant::iHoursInDay) && (iTimeStep > 0) && (iTimeStep <= state.dataGlobal->TimeStepsInHour)) { auto const &tomorrow = state.dataWeather->wvarsHrTsTomorrow(iTimeStep, iHour); ReturnValue.initialized = true; ReturnValue.Type = Value::Number; diff --git a/src/EnergyPlus/RuntimeLanguageProcessor.hh b/src/EnergyPlus/RuntimeLanguageProcessor.hh index 9e223bcaf15..3149da0470d 100644 --- a/src/EnergyPlus/RuntimeLanguageProcessor.hh +++ b/src/EnergyPlus/RuntimeLanguageProcessor.hh @@ -225,6 +225,10 @@ struct RuntimeLanguageProcessorData : BaseGlobalStruct Array1D Token; Array1D PEToken; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/SQLiteProcedures.cc b/src/EnergyPlus/SQLiteProcedures.cc index 731e3ece0d8..5384d692636 100644 --- a/src/EnergyPlus/SQLiteProcedures.cc +++ b/src/EnergyPlus/SQLiteProcedures.cc @@ -184,13 +184,12 @@ void CreateSQLiteZoneExtendedOutput(EnergyPlusData &state) for (int groupNum = 1; groupNum <= state.dataHeatBal->NumOfZoneGroups; ++groupNum) { state.dataSQLiteProcedures->sqlite->addZoneGroupData(groupNum, state.dataHeatBal->ZoneGroup(groupNum)); } - for (int scheduleNumber = 1, numberOfSchedules = ScheduleManager::GetNumberOfSchedules(state); scheduleNumber <= numberOfSchedules; - ++scheduleNumber) { - state.dataSQLiteProcedures->sqlite->addScheduleData(scheduleNumber, - ScheduleManager::GetScheduleName(state, scheduleNumber), - ScheduleManager::GetScheduleType(state, scheduleNumber), - ScheduleManager::GetScheduleMinValue(state, scheduleNumber), - ScheduleManager::GetScheduleMaxValue(state, scheduleNumber)); + for (auto *sched : state.dataSched->schedules) { + state.dataSQLiteProcedures->sqlite->addScheduleData(sched->Num, + sched->Name, + (sched->schedTypeNum == -1) ? "" : state.dataSched->scheduleTypes[sched->schedTypeNum]->Name, + sched->getMinVal(state), + sched->getMaxVal(state)); } for (int surfaceNumber = 1; surfaceNumber <= state.dataSurface->TotSurfaces; ++surfaceNumber) { auto const &surface = state.dataSurface->Surface(surfaceNumber); @@ -2296,7 +2295,7 @@ bool SQLite::NominalLighting::insertIntoSQLite(sqlite3_stmt *insertStmt) sqliteBindInteger(insertStmt, 1, number); sqliteBindText(insertStmt, 2, name); sqliteBindForeignKey(insertStmt, 3, zonePtr); - sqliteBindForeignKey(insertStmt, 4, schedulePtr); + sqliteBindForeignKey(insertStmt, 4, sched->Num); sqliteBindDouble(insertStmt, 5, designLevel); sqliteBindDouble(insertStmt, 6, fractionReturnAir); sqliteBindDouble(insertStmt, 7, fractionRadiant); @@ -2316,13 +2315,13 @@ bool SQLite::NominalPeople::insertIntoSQLite(sqlite3_stmt *insertStmt) sqliteBindText(insertStmt, 2, name); sqliteBindForeignKey(insertStmt, 3, zonePtr); sqliteBindDouble(insertStmt, 4, numberOfPeople); - sqliteBindForeignKey(insertStmt, 5, numberOfPeoplePtr); - sqliteBindForeignKey(insertStmt, 6, activityLevelPtr); + sqliteBindForeignKey(insertStmt, 5, numberOfPeopleSched->Num); + sqliteBindForeignKey(insertStmt, 6, activityLevelSched->Num); sqliteBindDouble(insertStmt, 7, fractionRadiant); sqliteBindDouble(insertStmt, 8, fractionConvected); - sqliteBindForeignKey(insertStmt, 9, workEffPtr); - sqliteBindForeignKey(insertStmt, 10, clothingPtr); - sqliteBindForeignKey(insertStmt, 11, airVelocityPtr); + sqliteBindForeignKey(insertStmt, 9, workEffSched->Num); + sqliteBindForeignKey(insertStmt, 10, clothingSched->Num); + sqliteBindForeignKey(insertStmt, 11, airVelocitySched->Num); sqliteBindLogical(insertStmt, 12, fanger); sqliteBindLogical(insertStmt, 13, pierce); sqliteBindLogical(insertStmt, 14, ksu); @@ -2343,7 +2342,7 @@ bool SQLite::NominalElectricEquipment::insertIntoSQLite(sqlite3_stmt *insertStmt sqliteBindInteger(insertStmt, 1, number); sqliteBindText(insertStmt, 2, name); sqliteBindForeignKey(insertStmt, 3, zonePtr); - sqliteBindForeignKey(insertStmt, 4, schedulePtr); + sqliteBindForeignKey(insertStmt, 4, sched->Num); sqliteBindDouble(insertStmt, 5, designLevel); sqliteBindDouble(insertStmt, 6, fractionLatent); sqliteBindDouble(insertStmt, 7, fractionRadiant); @@ -2361,7 +2360,7 @@ bool SQLite::NominalGasEquipment::insertIntoSQLite(sqlite3_stmt *insertStmt) sqliteBindInteger(insertStmt, 1, number); sqliteBindText(insertStmt, 2, name); sqliteBindForeignKey(insertStmt, 3, zonePtr); - sqliteBindForeignKey(insertStmt, 4, schedulePtr); + sqliteBindForeignKey(insertStmt, 4, sched->Num); sqliteBindDouble(insertStmt, 5, designLevel); sqliteBindDouble(insertStmt, 6, fractionLatent); sqliteBindDouble(insertStmt, 7, fractionRadiant); @@ -2379,7 +2378,7 @@ bool SQLite::NominalSteamEquipment::insertIntoSQLite(sqlite3_stmt *insertStmt) sqliteBindInteger(insertStmt, 1, number); sqliteBindText(insertStmt, 2, name); sqliteBindForeignKey(insertStmt, 3, zonePtr); - sqliteBindForeignKey(insertStmt, 4, schedulePtr); + sqliteBindForeignKey(insertStmt, 4, sched->Num); sqliteBindDouble(insertStmt, 5, designLevel); sqliteBindDouble(insertStmt, 6, fractionLatent); sqliteBindDouble(insertStmt, 7, fractionRadiant); @@ -2397,7 +2396,7 @@ bool SQLite::NominalHotWaterEquipment::insertIntoSQLite(sqlite3_stmt *insertStmt sqliteBindInteger(insertStmt, 1, number); sqliteBindText(insertStmt, 2, name); sqliteBindForeignKey(insertStmt, 3, zonePtr); - sqliteBindForeignKey(insertStmt, 4, schedulePtr); + sqliteBindForeignKey(insertStmt, 4, sched->Num); sqliteBindDouble(insertStmt, 5, designLevel); sqliteBindDouble(insertStmt, 6, fractionLatent); sqliteBindDouble(insertStmt, 7, fractionRadiant); @@ -2415,7 +2414,7 @@ bool SQLite::NominalOtherEquipment::insertIntoSQLite(sqlite3_stmt *insertStmt) sqliteBindInteger(insertStmt, 1, number); sqliteBindText(insertStmt, 2, name); sqliteBindForeignKey(insertStmt, 3, zonePtr); - sqliteBindForeignKey(insertStmt, 4, schedulePtr); + sqliteBindForeignKey(insertStmt, 4, sched->Num); sqliteBindDouble(insertStmt, 5, designLevel); sqliteBindDouble(insertStmt, 6, fractionLatent); sqliteBindDouble(insertStmt, 7, fractionRadiant); @@ -2433,7 +2432,7 @@ bool SQLite::NominalBaseboardHeat::insertIntoSQLite(sqlite3_stmt *insertStmt) sqliteBindInteger(insertStmt, 1, number); sqliteBindText(insertStmt, 2, name); sqliteBindForeignKey(insertStmt, 3, zonePtr); - sqliteBindForeignKey(insertStmt, 4, schedPtr); + sqliteBindForeignKey(insertStmt, 4, sched->Num); sqliteBindDouble(insertStmt, 5, capatLowTemperature); sqliteBindDouble(insertStmt, 6, lowTemperature); sqliteBindDouble(insertStmt, 7, capatHighTemperature); @@ -2452,7 +2451,7 @@ bool SQLite::Infiltration::insertIntoSQLite(sqlite3_stmt *insertStmt) sqliteBindInteger(insertStmt, 1, number); sqliteBindText(insertStmt, 2, name); sqliteBindForeignKey(insertStmt, 3, zonePtr); - sqliteBindForeignKey(insertStmt, 4, schedPtr); + sqliteBindForeignKey(insertStmt, 4, sched->Num); sqliteBindDouble(insertStmt, 5, designLevel); int rc = sqliteStepCommand(insertStmt); @@ -2465,7 +2464,7 @@ bool SQLite::Ventilation::insertIntoSQLite(sqlite3_stmt *insertStmt) sqliteBindInteger(insertStmt, 1, number); sqliteBindText(insertStmt, 2, name); sqliteBindForeignKey(insertStmt, 3, zonePtr); - sqliteBindForeignKey(insertStmt, 4, schedPtr); + sqliteBindForeignKey(insertStmt, 4, sched->Num); sqliteBindDouble(insertStmt, 5, designLevel); int rc = sqliteStepCommand(insertStmt); diff --git a/src/EnergyPlus/SQLiteProcedures.hh b/src/EnergyPlus/SQLiteProcedures.hh index db4a46761c1..ca77ea43a2e 100644 --- a/src/EnergyPlus/SQLiteProcedures.hh +++ b/src/EnergyPlus/SQLiteProcedures.hh @@ -668,7 +668,7 @@ private: int const nominalLightingNumber, DataHeatBalance::LightsData const &nominalLightingData) : SQLiteData(errorStream, db), number(nominalLightingNumber), name(nominalLightingData.Name), zonePtr(nominalLightingData.ZonePtr), - schedulePtr(nominalLightingData.SchedPtr), designLevel(nominalLightingData.DesignLevel), + sched(nominalLightingData.sched), designLevel(nominalLightingData.DesignLevel), fractionReturnAir(nominalLightingData.FractionReturnAir), fractionRadiant(nominalLightingData.FractionRadiant), fractionShortWave(nominalLightingData.FractionShortWave), fractionReplaceable(nominalLightingData.FractionReplaceable), fractionConvected(nominalLightingData.FractionConvected), endUseSubcategory(nominalLightingData.EndUseSubcategory) @@ -681,7 +681,7 @@ private: int const number; std::string const &name; int const &zonePtr; - int const &schedulePtr; + Sched::Schedule const *sched; double const &designLevel; double const &fractionReturnAir; double const &fractionRadiant; @@ -699,10 +699,10 @@ private: int const nominalPeopleNumber, DataHeatBalance::PeopleData const &nominalPeopleData) : SQLiteData(errorStream, db), number(nominalPeopleNumber), name(nominalPeopleData.Name), zonePtr(nominalPeopleData.ZonePtr), - numberOfPeople(nominalPeopleData.NumberOfPeople), numberOfPeoplePtr(nominalPeopleData.NumberOfPeoplePtr), - activityLevelPtr(nominalPeopleData.ActivityLevelPtr), fractionRadiant(nominalPeopleData.FractionRadiant), - fractionConvected(nominalPeopleData.FractionConvected), workEffPtr(nominalPeopleData.WorkEffPtr), - clothingPtr(nominalPeopleData.ClothingPtr), airVelocityPtr(nominalPeopleData.AirVelocityPtr), fanger(nominalPeopleData.Fanger), + numberOfPeople(nominalPeopleData.NumberOfPeople), numberOfPeopleSched(nominalPeopleData.numberOfPeopleSched), + activityLevelSched(nominalPeopleData.activityLevelSched), fractionRadiant(nominalPeopleData.FractionRadiant), + fractionConvected(nominalPeopleData.FractionConvected), workEffSched(nominalPeopleData.workEffSched), + clothingSched(nominalPeopleData.clothingSched), airVelocitySched(nominalPeopleData.airVelocitySched), fanger(nominalPeopleData.Fanger), pierce(nominalPeopleData.Pierce), ksu(nominalPeopleData.KSU), mrtCalcType(nominalPeopleData.MRTCalcType), surfacePtr(nominalPeopleData.SurfacePtr), angleFactorListName(nominalPeopleData.AngleFactorListName), angleFactorListPtr(nominalPeopleData.AngleFactorListPtr), userSpecSensFrac(nominalPeopleData.UserSpecSensFrac), @@ -717,13 +717,13 @@ private: std::string const &name; int const &zonePtr; double const &numberOfPeople; - int const &numberOfPeoplePtr; - int const &activityLevelPtr; + Sched::Schedule const *numberOfPeopleSched; + Sched::Schedule const *activityLevelSched; double const &fractionRadiant; double const &fractionConvected; - int const &workEffPtr; - int const &clothingPtr; - int const &airVelocityPtr; + Sched::Schedule const *workEffSched; + Sched::Schedule const *clothingSched; + Sched::Schedule const *airVelocitySched; bool const &fanger; bool const &pierce; bool const &ksu; @@ -743,7 +743,7 @@ private: int const nominalElectricEquipmentNumber, DataHeatBalance::ZoneEquipData const &nominalElectricEquipmentData) : SQLiteData(errorStream, db), number(nominalElectricEquipmentNumber), name(nominalElectricEquipmentData.Name), - zonePtr(nominalElectricEquipmentData.ZonePtr), schedulePtr(nominalElectricEquipmentData.SchedPtr), + zonePtr(nominalElectricEquipmentData.ZonePtr), sched(nominalElectricEquipmentData.sched), designLevel(nominalElectricEquipmentData.DesignLevel), fractionLatent(nominalElectricEquipmentData.FractionLatent), fractionRadiant(nominalElectricEquipmentData.FractionRadiant), fractionLost(nominalElectricEquipmentData.FractionLost), fractionConvected(nominalElectricEquipmentData.FractionConvected), endUseSubcategory(nominalElectricEquipmentData.EndUseSubcategory) @@ -756,7 +756,7 @@ private: int const number; std::string const &name; int const &zonePtr; - int const &schedulePtr; + Sched::Schedule const *sched; double const &designLevel; double const &fractionLatent; double const &fractionRadiant; @@ -773,7 +773,7 @@ private: int const nominalGasEquipmentNumber, DataHeatBalance::ZoneEquipData const &nominalGasEquipmentData) : SQLiteData(errorStream, db), number(nominalGasEquipmentNumber), name(nominalGasEquipmentData.Name), - zonePtr(nominalGasEquipmentData.ZonePtr), schedulePtr(nominalGasEquipmentData.SchedPtr), + zonePtr(nominalGasEquipmentData.ZonePtr), sched(nominalGasEquipmentData.sched), designLevel(nominalGasEquipmentData.DesignLevel), fractionLatent(nominalGasEquipmentData.FractionLatent), fractionRadiant(nominalGasEquipmentData.FractionRadiant), fractionLost(nominalGasEquipmentData.FractionLost), fractionConvected(nominalGasEquipmentData.FractionConvected), endUseSubcategory(nominalGasEquipmentData.EndUseSubcategory) @@ -786,7 +786,7 @@ private: int const number; std::string const &name; int const &zonePtr; - int const &schedulePtr; + Sched::Schedule const *sched; double const &designLevel; double const &fractionLatent; double const &fractionRadiant; @@ -803,7 +803,7 @@ private: int const nominalSteamEquipmentNumber, DataHeatBalance::ZoneEquipData const &nominalSteamEquipmentData) : SQLiteData(errorStream, db), number(nominalSteamEquipmentNumber), name(nominalSteamEquipmentData.Name), - zonePtr(nominalSteamEquipmentData.ZonePtr), schedulePtr(nominalSteamEquipmentData.SchedPtr), + zonePtr(nominalSteamEquipmentData.ZonePtr), sched(nominalSteamEquipmentData.sched), designLevel(nominalSteamEquipmentData.DesignLevel), fractionLatent(nominalSteamEquipmentData.FractionLatent), fractionRadiant(nominalSteamEquipmentData.FractionRadiant), fractionLost(nominalSteamEquipmentData.FractionLost), fractionConvected(nominalSteamEquipmentData.FractionConvected), endUseSubcategory(nominalSteamEquipmentData.EndUseSubcategory) @@ -816,7 +816,7 @@ private: int const number; std::string const &name; int const &zonePtr; - int const &schedulePtr; + Sched::Schedule const *sched; double const &designLevel; double const &fractionLatent; double const &fractionRadiant; @@ -833,7 +833,7 @@ private: int const nominalHotWaterEquipmentNumber, DataHeatBalance::ZoneEquipData const &nominalHotWaterEquipmentData) : SQLiteData(errorStream, db), number(nominalHotWaterEquipmentNumber), name(nominalHotWaterEquipmentData.Name), - zonePtr(nominalHotWaterEquipmentData.ZonePtr), schedulePtr(nominalHotWaterEquipmentData.SchedPtr), + zonePtr(nominalHotWaterEquipmentData.ZonePtr), sched(nominalHotWaterEquipmentData.sched), designLevel(nominalHotWaterEquipmentData.DesignLevel), fractionLatent(nominalHotWaterEquipmentData.FractionLatent), fractionRadiant(nominalHotWaterEquipmentData.FractionRadiant), fractionLost(nominalHotWaterEquipmentData.FractionLost), fractionConvected(nominalHotWaterEquipmentData.FractionConvected), endUseSubcategory(nominalHotWaterEquipmentData.EndUseSubcategory) @@ -846,7 +846,7 @@ private: int const number; std::string const &name; int const &zonePtr; - int const &schedulePtr; + Sched::Schedule const *sched; double const &designLevel; double const &fractionLatent; double const &fractionRadiant; @@ -863,7 +863,7 @@ private: int const nominalOtherEquipmentNumber, DataHeatBalance::ZoneEquipData const &nominalOtherEquipmentData) : SQLiteData(errorStream, db), number(nominalOtherEquipmentNumber), name(nominalOtherEquipmentData.Name), - zonePtr(nominalOtherEquipmentData.ZonePtr), schedulePtr(nominalOtherEquipmentData.SchedPtr), + zonePtr(nominalOtherEquipmentData.ZonePtr), sched(nominalOtherEquipmentData.sched), designLevel(nominalOtherEquipmentData.DesignLevel), fractionLatent(nominalOtherEquipmentData.FractionLatent), fractionRadiant(nominalOtherEquipmentData.FractionRadiant), fractionLost(nominalOtherEquipmentData.FractionLost), fractionConvected(nominalOtherEquipmentData.FractionConvected), endUseSubcategory(nominalOtherEquipmentData.EndUseSubcategory) @@ -876,7 +876,7 @@ private: int const number; std::string const &name; int const &zonePtr; - int const &schedulePtr; + Sched::Schedule const *sched; double const &designLevel; double const &fractionLatent; double const &fractionRadiant; @@ -893,7 +893,7 @@ private: int const nominalBaseboardHeatNumber, DataHeatBalance::BBHeatData const &nominalBaseboardHeatData) : SQLiteData(errorStream, db), number(nominalBaseboardHeatNumber), name(nominalBaseboardHeatData.Name), - zonePtr(nominalBaseboardHeatData.ZonePtr), schedPtr(nominalBaseboardHeatData.SchedPtr), + zonePtr(nominalBaseboardHeatData.ZonePtr), sched(nominalBaseboardHeatData.sched), capatLowTemperature(nominalBaseboardHeatData.CapatLowTemperature), lowTemperature(nominalBaseboardHeatData.LowTemperature), capatHighTemperature(nominalBaseboardHeatData.CapatHighTemperature), highTemperature(nominalBaseboardHeatData.HighTemperature), fractionRadiant(nominalBaseboardHeatData.FractionRadiant), fractionConvected(nominalBaseboardHeatData.FractionConvected), @@ -907,7 +907,7 @@ private: int const number; std::string const &name; int const &zonePtr; - int const &schedPtr; + Sched::Schedule const *sched; double const &capatLowTemperature; double const &lowTemperature; double const &capatHighTemperature; @@ -925,7 +925,7 @@ private: int const infiltrationNumber, DataHeatBalance::InfiltrationData const &infiltrationData) : SQLiteData(errorStream, db), number(infiltrationNumber), name(infiltrationData.Name), zonePtr(infiltrationData.ZonePtr), - schedPtr(infiltrationData.SchedPtr), designLevel(infiltrationData.DesignLevel) + sched(infiltrationData.sched), designLevel(infiltrationData.DesignLevel) { } @@ -935,7 +935,7 @@ private: int const number; std::string const &name; int const &zonePtr; - int const &schedPtr; + Sched::Schedule const *sched; double const &designLevel; }; @@ -947,7 +947,7 @@ private: int const ventilationNumber, DataHeatBalance::VentilationData const &ventilationData) : SQLiteData(errorStream, db), number(ventilationNumber), name(ventilationData.Name), zonePtr(ventilationData.ZonePtr), - schedPtr(ventilationData.SchedPtr), designLevel(ventilationData.DesignLevel) + sched(ventilationData.sched), designLevel(ventilationData.DesignLevel) { } @@ -957,7 +957,7 @@ private: int const number; std::string const &name; int const &zonePtr; - int const &schedPtr; + Sched::Schedule const *sched; double const &designLevel; }; @@ -1012,6 +1012,10 @@ void CreateSQLiteZoneExtendedOutput(EnergyPlusData &state); struct SQLiteProceduresData : BaseGlobalStruct { std::unique_ptr sqlite; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/ScheduleManager.cc b/src/EnergyPlus/ScheduleManager.cc index 83184a58b25..2e1cefb6861 100644 --- a/src/EnergyPlus/ScheduleManager.cc +++ b/src/EnergyPlus/ScheduleManager.cc @@ -49,9 +49,9 @@ #include // ObjexxFCL Headers -#include -#include -#include +// #include +// #include +// #include #include // EnergyPlus Headers @@ -74,7 +74,7 @@ namespace EnergyPlus { -namespace ScheduleManager { +namespace Sched { // Module containing the Schedule Manager routines // MODULE INFORMATION: @@ -94,57 +94,208 @@ namespace ScheduleManager { // Proposal for Schedule Manager in EnergyPlus (Rick Strand) // MODULE PARAMETER DEFINITIONS - static constexpr std::string_view BlankString; - // Day types are 1-based for EMS and output and other uses, so add a dummy - constexpr std::array(DayType::Num)> dayTypeNames{"dummy", - "Sunday", - "Monday", - "Tuesday", - "Wednesday", - "Thursday", - "Friday", - "Saturday", - "Holiday", - "SummerDesignDay", - "WinterDesignDay", - "CustomDay1", - "CustomDay2"}; - - constexpr std::array(DayType::Num)> dayTypeNamesUC{"dummy", - "SUNDAY", - "MONDAY", - "TUESDAY", - "WEDNESDAY", - "THURSDAY", - "FRIDAY", - "SATURDAY", - "HOLIDAY", - "SUMMERDESIGNDAY", - "WINTERDESIGNDAY", - "CUSTOMDAY1", - "CUSTOMDAY2"}; - - int constexpr numScheduleTypeLimitUnitTypes = 14; - static constexpr std::array(numScheduleTypeLimitUnitTypes)> scheduleTypeLimitUnitTypes{"DIMENSIONLESS", - "TEMPERATURE", - "DELTATEMPERATURE", - "PRECIPITATIONRATE", - "ANGLE", - "CONVECTIONCOEFFICIENT", - "ACTIVITYLEVEL", - "VELOCITY", - "CAPACITY", - "POWER", - "AVAILABILITY", - "PERCENT", - "CONTROL", - "MODE"}; - - constexpr std::array(OutputReportLevel::Num)> outputScheduleReportLevelNames = {"Hourly", "Timestep"}; - constexpr std::array(OutputReportLevel::Num)> outputScheduleReportLevelNamesUC = {"HOURLY", "TIMESTEP"}; - constexpr std::array(ScheduleInterpolation::Num)> interpolationTypes = {"No", "Average", "Linear"}; - constexpr std::array(ScheduleInterpolation::Num)> interpolationTypesUC = {"NO", "AVERAGE", "LINEAR"}; + int GetScheduleTypeNum(EnergyPlusData &state, std::string const &name) + { + auto &s_sched = state.dataSched; + for (int i = 0; i < (int)s_sched->scheduleTypes.size(); ++i) if (s_sched->scheduleTypes[i]->Name == name) return i; + return -1; + } + + Real64 ScheduleBase::getMinVal(EnergyPlusData &state) + { + if (!isMinMaxSet) setMinMaxVals(state); + return minVal; + } + + Real64 ScheduleBase::getMaxVal(EnergyPlusData &state) + { + if (!isMinMaxSet) setMinMaxVals(state); + return maxVal; + } + + + // Day types are 1-based for EMS and output and other uses, so add a dummy + constexpr std::array dayTypeNames = { + "Unused", + "Sunday", + "Monday", + "Tuesday", + "Wednesday", + "Thursday", + "Friday", + "Saturday", + "Holiday", + "SummerDesignDay", + "WinterDesignDay", + "CustomDay1", + "CustomDay2"}; + + constexpr std::array dayTypeNamesUC = { + "UNUSED", + "SUNDAY", + "MONDAY", + "TUESDAY", + "WEDNESDAY", + "THURSDAY", + "FRIDAY", + "SATURDAY", + "HOLIDAY", + "SUMMERDESIGNDAY", + "WINTERDESIGNDAY", + "CUSTOMDAY1", + "CUSTOMDAY2"}; + + static constexpr std::array limitUnitNamesUC = { + "DIMENSIONLESS", + "TEMPERATURE", + "DELTATEMPERATURE", + "PRECIPITATIONRATE", + "ANGLE", + "CONVECTIONCOEFFICIENT", + "ACTIVITYLEVEL", + "VELOCITY", + "CAPACITY", + "POWER", + "AVAILABILITY", + "PERCENT", + "CONTROL", + "MODE"}; + + constexpr std::array reportLevelNames = {"Hourly", "Timestep"}; + constexpr std::array reportLevelNamesUC = {"HOURLY", "TIMESTEP"}; + constexpr std::array interpolationNames = {"No", "Average", "Linear"}; + constexpr std::array interpolationNamesUC = {"NO", "AVERAGE", "LINEAR"}; + + bool DaySchedule::checkValsForLimitViolations(EnergyPlusData &state) const + { + auto &s_sched = state.dataSched; + + if (this->schedTypeNum == SchedNum_Invalid) return false; + auto *schedType = s_sched->scheduleTypes[this->schedTypeNum]; + if (!schedType->isLimited) return false; + + for (int i = 0; i < Constant::iHoursInDay * state.dataGlobal->TimeStepsInHour; ++i) + if (this->tsVals[i] < schedType->minVal || this->tsVals[i] > schedType->maxVal) return true; + + return false; + } // ScheduleDay::checkValsForLimitViolations() + + bool DaySchedule::checkValsForBadIntegers(EnergyPlusData &state) const + { + auto &s_sched = state.dataSched; + if (this->schedTypeNum == SchedNum_Invalid) return false; + auto *schedType = s_sched->scheduleTypes[this->schedTypeNum]; + if (schedType->isReal) return false; + // Make sure each is integer + for (int i = 0; i < Constant::iHoursInDay * state.dataGlobal->TimeStepsInHour; ++i) + if (this->tsVals[i] != int(this->tsVals[i])) return true; + return false; + } // ScheduleDay::checkValsForBadIntegers() + + void DaySchedule::populateFromMinuteVals(EnergyPlusData &state, std::array const &minuteVals) + { + auto &s_glob = state.dataGlobal; + if (this->interpolation == Interpolation::Average) { + for (int hr = 0; hr < Constant::iHoursInDay; ++hr) { + int begMinute = 0; + int endMinute = s_glob->MinutesInTimeStep - 1; + for (int ts = 0; ts < s_glob->TimeStepsInHour; ++ts) { + this->tsVals[hr * s_glob->TimeStepsInHour + ts] = + std::accumulate(minuteVals.begin() + (hr * Constant::iMinutesInHour + begMinute), + minuteVals.begin() + (hr * Constant::iMinutesInHour + endMinute), + 0) / double(s_glob->MinutesInTimeStep); + this->sumTsVals += this->tsVals[hr * s_glob->TimeStepsInHour + ts]; + begMinute = endMinute + 1; + endMinute += s_glob->MinutesInTimeStep; + } + } + } else { + for (int hr = 0; hr < Constant::iHoursInDay; ++hr) { + int endMinute = s_glob->MinutesInTimeStep - 1; + for (int ts = 0; ts < s_glob->TimeStepsInHour; ++ts) { + this->tsVals[hr * s_glob->TimeStepsInHour + ts] = minuteVals[hr * Constant::iMinutesInHour + endMinute]; + this->sumTsVals += this->tsVals[hr * s_glob->TimeStepsInHour + ts]; + endMinute += s_glob->MinutesInTimeStep; + } + } + } + } // ScheduleDay::populateFromHrMinVals() + + ScheduleConstant *AddScheduleConstant(EnergyPlusData &state, std::string const &name) + { + auto &s_sched = state.dataSched; + + auto *sched = new ScheduleConstant; + sched->Name = name; + sched->Num = (int)s_sched->schedules.size(); + s_sched->schedules.push_back(sched); + s_sched->scheduleMap.insert_or_assign(Util::makeUPPER(sched->Name), sched->Num); + + sched->type = SchedType::Constant; + return sched; + } // AddScheduleConstant() + + ScheduleDetailed *AddScheduleDetailed(EnergyPlusData &state, std::string const &name) + { + auto &s_sched = state.dataSched; + + auto *sched = new ScheduleDetailed; + sched->Name = name; + + sched->Num = (int)s_sched->schedules.size(); + s_sched->schedules.push_back(sched); + s_sched->scheduleMap.insert_or_assign(Util::makeUPPER(sched->Name), sched->Num); + + sched->type = SchedType::Year; + return sched; + } // AddScheduleDetailed() + + DaySchedule *AddDaySchedule(EnergyPlusData &state, std::string const &name) + { + auto &s_glob = state.dataGlobal; + auto &s_sched = state.dataSched; + + auto *daySched = new DaySchedule; + daySched->Name = name; + + daySched->Num = (int)s_sched->daySchedules.size(); + s_sched->daySchedules.push_back(daySched); + s_sched->dayScheduleMap.insert_or_assign(Util::makeUPPER(daySched->Name), daySched->Num); + + daySched->tsVals.resize(Constant::iHoursInDay * s_glob->TimeStepsInHour); + + return daySched; + } // AddDaySchedule() + + WeekSchedule *AddWeekSchedule(EnergyPlusData &state, std::string const &name) + { + auto &s_sched = state.dataSched; + + auto *weekSched = new WeekSchedule; + weekSched->Name = name; + + weekSched->Num = (int)s_sched->weekSchedules.size(); + s_sched->weekSchedules.push_back(weekSched); + s_sched->weekScheduleMap.insert_or_assign(Util::makeUPPER(weekSched->Name), weekSched->Num); + + return weekSched; + } // AddWeekSchedule() + + + void InitConstantScheduleData(EnergyPlusData &state) + { + // Create ScheduleAlwaysOn and ScheduleAlwaysOff + // Create constant schedules + auto *schedOff = AddScheduleConstant(state, "Constant-0.0"); + assert(schedOff->Num == SchedNum_AlwaysOff); + schedOff->currentVal = 0.0; + + auto *schedOn = AddScheduleConstant(state, "Constant-1.0"); + assert(schedOn->Num == SchedNum_AlwaysOn); + schedOn->currentVal = 1.0; + } + void ProcessScheduleInput(EnergyPlusData &state) { // SUBROUTINE INFORMATION: @@ -169,15 +320,10 @@ namespace ScheduleManager { // Locals // SUBROUTINE PARAMETER DEFINITIONS: - constexpr std::string_view RoutineName = "ProcessScheduleInput: "; + constexpr std::string_view routineName = "ProcessScheduleInput"; // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - Array1D_int DaysInYear(366); - int LoopIndex; - int InLoopIndex; - int DayIndex; - int WeekIndex; Array1D_string Alphas; Array1D_string cAlphaFields; Array1D_string cNumericFields; @@ -187,59 +333,33 @@ namespace ScheduleManager { int NumAlphas; int NumNumbers; int Status; - int StartMonth; - int StartDay; + int EndMonth; int EndDay; int StartPointer; int EndPointer; int NumPointer; - int Count; - int CheckIndex; bool ErrorsFound(false); bool NumErrorFlag; - int SchedTypePtr; std::string CFld; // Character field for error message // CHARACTER(len=20) CFld1 ! Character field for error message - int NumHrDaySchedules; // Number of "hourly" dayschedules - int NumIntDaySchedules; // Number of "interval" dayschedules - int NumExternalInterfaceSchedules; // Number of "PtolemyServer ExternalInterface" "compact" Schedules - int NumExternalInterfaceFunctionalMockupUnitImportSchedules; // Number of "FunctionalMockupUnitImport ExternalInterface" - // "compact" Schedules ! added for FMU Import - int NumExternalInterfaceFunctionalMockupUnitExportSchedules; // Number of "FunctionalMockupUnitExport ExternalInterface" - // "compact" Schedules ! added for FMU Export - int NumLstDaySchedules; // Number of "list" dayschedules - int NumRegDaySchedules; // Number of hourly+interval+list dayschedules - int NumRegWeekSchedules; // Number of "regular" Weekschedules - int NumRegSchedules; // Number of "regular" Schedules - int NumCptWeekSchedules; // Number of "compact" WeekSchedules - int NumCptSchedules; // Number of "compact" Schedules - int NumCommaFileSchedules; // Number of Schedule:File schedules - int NumConstantSchedules; // Number of "constant" schedules - int NumCSVAllColumnsSchedules = 0; // Number of imported shading schedules - int NumCommaFileShading; // Number of shading csv schedules - int TS; // Counter for Num Of Time Steps in Hour - int Hr; // Hour Counter - Array2D MinuteValue; // Temporary for processing interval schedules - Array2D_bool SetMinuteValue; // Temporary for processing interval schedules + std::array minuteVals; // Temporary for processing interval schedules + std::array setMinuteVals; // Temporary for processing interval schedules int NumFields; - int SCount; // LOGICAL RptSchedule int RptLevel; - int CurMinute; int MinutesPerItem; int NumExpectedItems; int MaxNums; int MaxAlps; - int AddWeekSch; - int AddDaySch; - Array1D_bool AllDays(maxDayTypes); - Array1D_bool TheseDays(maxDayTypes); + std::array allDays; + std::array theseDays; bool ErrorHere; int SchNum; int WkCount; int DyCount; int NumField; + int Count; Weather::DateType PDateType; int PWeekDay; int ThruField; @@ -249,16 +369,9 @@ namespace ScheduleManager { std::string CurrentThrough; std::string LastFor; std::string errmsg; - int kdy; // for SCHEDULE:FILE int rowCnt; std::string subString; - int iDay; - int hDay; - int jHour; - int kDayType; - Real64 curHrVal; - std::string::size_type sPos; std::string CurrentModuleObject; // for ease in getting objects int MaxNums1; char ColumnSep; @@ -266,118 +379,118 @@ namespace ScheduleManager { int rowLimitCount; int skiprowCount; int curcolCount; - int numHourlyValues; int numerrors = 0; - int ifld; - int hrLimitCount; - if (state.dataScheduleMgr->ScheduleInputProcessed) { + auto const &s_glob = state.dataGlobal; + auto const &s_ip = state.dataInputProcessing->inputProcessor; + auto &s_sched = state.dataSched; + + if (s_sched->ScheduleInputProcessed) { return; } - state.dataScheduleMgr->ScheduleInputProcessed = true; + + s_sched->ScheduleInputProcessed = true; MaxNums = 1; // Need at least 1 number because it's used as a local variable in the Schedule Types loop MaxAlps = 0; CurrentModuleObject = "ScheduleTypeLimits"; - state.dataScheduleMgr->NumScheduleTypes = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject); - if (state.dataScheduleMgr->NumScheduleTypes > 0) { - state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, CurrentModuleObject, Count, NumAlphas, NumNumbers); + int NumScheduleTypes = s_ip->getNumObjectsFound(state, CurrentModuleObject); + if (NumScheduleTypes > 0) { + s_ip->getObjectDefMaxArgs(state, CurrentModuleObject, Count, NumAlphas, NumNumbers); MaxNums = max(MaxNums, NumNumbers); MaxAlps = max(MaxAlps, NumAlphas); } CurrentModuleObject = "Schedule:Day:Hourly"; - NumHrDaySchedules = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject); + int NumHrDaySchedules = s_ip->getNumObjectsFound(state, CurrentModuleObject); if (NumHrDaySchedules > 0) { - state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, CurrentModuleObject, Count, NumAlphas, NumNumbers); + s_ip->getObjectDefMaxArgs(state, CurrentModuleObject, Count, NumAlphas, NumNumbers); MaxNums = max(MaxNums, NumNumbers); MaxAlps = max(MaxAlps, NumAlphas); } CurrentModuleObject = "Schedule:Day:Interval"; - NumIntDaySchedules = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject); + int NumIntDaySchedules = s_ip->getNumObjectsFound(state, CurrentModuleObject); if (NumIntDaySchedules > 0) { - state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, CurrentModuleObject, Count, NumAlphas, NumNumbers); + s_ip->getObjectDefMaxArgs(state, CurrentModuleObject, Count, NumAlphas, NumNumbers); MaxNums = max(MaxNums, NumNumbers); MaxAlps = max(MaxAlps, NumAlphas); } CurrentModuleObject = "Schedule:Day:List"; - NumLstDaySchedules = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject); + int NumLstDaySchedules = s_ip->getNumObjectsFound(state, CurrentModuleObject); if (NumLstDaySchedules > 0) { - state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, CurrentModuleObject, Count, NumAlphas, NumNumbers); + s_ip->getObjectDefMaxArgs(state, CurrentModuleObject, Count, NumAlphas, NumNumbers); MaxNums = max(MaxNums, NumNumbers); MaxAlps = max(MaxAlps, NumAlphas); } CurrentModuleObject = "Schedule:Week:Daily"; - NumRegWeekSchedules = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject); + int NumRegWeekSchedules = s_ip->getNumObjectsFound(state, CurrentModuleObject); if (NumRegWeekSchedules > 0) { - state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, CurrentModuleObject, Count, NumAlphas, NumNumbers); + s_ip->getObjectDefMaxArgs(state, CurrentModuleObject, Count, NumAlphas, NumNumbers); MaxNums = max(MaxNums, NumNumbers); MaxAlps = max(MaxAlps, NumAlphas); } CurrentModuleObject = "Schedule:Week:Compact"; - NumCptWeekSchedules = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject); + int NumCptWeekSchedules = s_ip->getNumObjectsFound(state, CurrentModuleObject); if (NumCptWeekSchedules > 0) { - state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, CurrentModuleObject, Count, NumAlphas, NumNumbers); + s_ip->getObjectDefMaxArgs(state, CurrentModuleObject, Count, NumAlphas, NumNumbers); MaxNums = max(MaxNums, NumNumbers); MaxAlps = max(MaxAlps, NumAlphas); } CurrentModuleObject = "Schedule:Year"; - NumRegSchedules = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject); + int NumRegSchedules = s_ip->getNumObjectsFound(state, CurrentModuleObject); if (NumRegSchedules > 0) { - state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, CurrentModuleObject, Count, NumAlphas, NumNumbers); + s_ip->getObjectDefMaxArgs(state, CurrentModuleObject, Count, NumAlphas, NumNumbers); MaxNums = max(MaxNums, NumNumbers); MaxAlps = max(MaxAlps, NumAlphas); } CurrentModuleObject = "Schedule:Compact"; - NumCptSchedules = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject); + int NumCptSchedules = s_ip->getNumObjectsFound(state, CurrentModuleObject); if (NumCptSchedules > 0) { - state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, CurrentModuleObject, Count, NumAlphas, NumNumbers); + s_ip->getObjectDefMaxArgs(state, CurrentModuleObject, Count, NumAlphas, NumNumbers); MaxNums = max(MaxNums, NumNumbers); MaxAlps = max(MaxAlps, NumAlphas + 1); } CurrentModuleObject = "Schedule:File"; - NumCommaFileSchedules = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject); + int NumCommaFileSchedules = s_ip->getNumObjectsFound(state, CurrentModuleObject); if (NumCommaFileSchedules > 0) { - state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, CurrentModuleObject, Count, NumAlphas, NumNumbers); + s_ip->getObjectDefMaxArgs(state, CurrentModuleObject, Count, NumAlphas, NumNumbers); MaxNums = max(MaxNums, NumNumbers); MaxAlps = max(MaxAlps, NumAlphas); } CurrentModuleObject = "Schedule:Constant"; - NumConstantSchedules = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject); + int NumConstantSchedules = s_ip->getNumObjectsFound(state, CurrentModuleObject); if (NumConstantSchedules > 0) { - state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, CurrentModuleObject, Count, NumAlphas, NumNumbers); + s_ip->getObjectDefMaxArgs(state, CurrentModuleObject, Count, NumAlphas, NumNumbers); MaxNums = max(MaxNums, NumNumbers); MaxAlps = max(MaxAlps, NumAlphas); } CurrentModuleObject = "ExternalInterface:Schedule"; - NumExternalInterfaceSchedules = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject); + int NumExternalInterfaceSchedules = s_ip->getNumObjectsFound(state, CurrentModuleObject); // added for FMI if (NumExternalInterfaceSchedules > 0) { - state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, CurrentModuleObject, Count, NumAlphas, NumNumbers); + s_ip->getObjectDefMaxArgs(state, CurrentModuleObject, Count, NumAlphas, NumNumbers); MaxNums = max(MaxNums, NumNumbers); MaxAlps = max(MaxAlps, NumAlphas + 1); } // added for FMU Import CurrentModuleObject = "ExternalInterface:FunctionalMockupUnitImport:To:Schedule"; - NumExternalInterfaceFunctionalMockupUnitImportSchedules = - state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject); + int NumExternalInterfaceFunctionalMockupUnitImportSchedules = s_ip->getNumObjectsFound(state, CurrentModuleObject); if (NumExternalInterfaceFunctionalMockupUnitImportSchedules > 0) { - state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, CurrentModuleObject, Count, NumAlphas, NumNumbers); + s_ip->getObjectDefMaxArgs(state, CurrentModuleObject, Count, NumAlphas, NumNumbers); MaxNums = max(MaxNums, NumNumbers); MaxAlps = max(MaxAlps, NumAlphas + 1); } // added for FMU Export CurrentModuleObject = "ExternalInterface:FunctionalMockupUnitExport:To:Schedule"; - NumExternalInterfaceFunctionalMockupUnitExportSchedules = - state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject); + int NumExternalInterfaceFunctionalMockupUnitExportSchedules = s_ip->getNumObjectsFound(state, CurrentModuleObject); if (NumExternalInterfaceFunctionalMockupUnitExportSchedules > 0) { - state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, CurrentModuleObject, Count, NumAlphas, NumNumbers); + s_ip->getObjectDefMaxArgs(state, CurrentModuleObject, Count, NumAlphas, NumNumbers); MaxNums = max(MaxNums, NumNumbers); MaxAlps = max(MaxAlps, NumAlphas + 1); } CurrentModuleObject = "Output:Schedules"; - state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, CurrentModuleObject, Count, NumAlphas, NumNumbers); + s_ip->getObjectDefMaxArgs(state, CurrentModuleObject, Count, NumAlphas, NumNumbers); MaxNums = max(MaxNums, NumNumbers); MaxAlps = max(MaxAlps, NumAlphas); @@ -389,18 +502,14 @@ namespace ScheduleManager { lNumericBlanks.dimension(MaxNums, true); // Prescan to determine extra day and week schedules due to compact schedule input - AddWeekSch = 0; - AddDaySch = 0; CurrentModuleObject = "Schedule:Compact"; MaxNums1 = 0; - for (LoopIndex = 1; LoopIndex <= NumCptSchedules; ++LoopIndex) { - state.dataInputProcessing->inputProcessor->getObjectItem( - state, CurrentModuleObject, LoopIndex, Alphas, NumAlphas, Numbers, NumNumbers, Status); + + for (int LoopIndex = 1; LoopIndex <= NumCptSchedules; ++LoopIndex) { + s_ip->getObjectItem(state, CurrentModuleObject, LoopIndex, Alphas, NumAlphas, Numbers, NumNumbers, Status); // # 'THROUGH" => Number of additional week schedules // # 'FOR' => Number of additional day schedules for (Count = 3; Count <= NumAlphas; ++Count) { - if (has_prefix(Alphas(Count), "THROUGH")) ++AddWeekSch; - if (has_prefix(Alphas(Count), "FOR")) ++AddDaySch; if (has_prefix(Alphas(Count), "UNTIL")) ++MaxNums1; } } @@ -413,29 +522,11 @@ namespace ScheduleManager { Numbers.dimension(MaxNums, 0.0); // Maximum Numbers possible lNumericBlanks.dimension(MaxNums, true); } + // add week and day schedules for each FILE:COMMA schedule - AddWeekSch += NumCommaFileSchedules * 366; // number of days/year because need a week for each day - AddDaySch += NumCommaFileSchedules * 366; // number of days/year - AddWeekSch += NumConstantSchedules; - AddDaySch += NumConstantSchedules; - // add week and day schedules for each ExternalInterface:Schedule schedule - AddWeekSch += NumExternalInterfaceSchedules * 366; // number of days/year because need a week for each day - AddDaySch += NumExternalInterfaceSchedules; // one day schedule for ExternalInterface to update during run time - // added for FMU Import - // add week and day schedules for each ExternalInterface:FunctionalMockupUnitImport:Schedule - AddWeekSch += NumExternalInterfaceFunctionalMockupUnitImportSchedules * 366; // number of days/year - // because need a week for each day - AddDaySch += NumExternalInterfaceFunctionalMockupUnitImportSchedules; // one day schedule for ExternalInterface - // to update during run time - // added for FMU Export - // add week and day schedules for each ExternalInterface:FunctionalMockupUnitExport:Schedule - AddWeekSch += NumExternalInterfaceFunctionalMockupUnitExportSchedules * 366; // number of days/year - // because need a week for each day - AddDaySch += NumExternalInterfaceFunctionalMockupUnitExportSchedules; // one day schedule for ExternalInterface - // to update during run time CurrentModuleObject = "Schedule:File:Shading"; - NumCommaFileShading = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject); + int NumCommaFileShading = s_ip->getNumObjectsFound(state, CurrentModuleObject); NumAlphas = 0; NumNumbers = 0; if (NumCommaFileShading > 1) { @@ -444,18 +535,18 @@ namespace ScheduleManager { std::map::iterator schedule_file_shading_result; if (NumCommaFileShading != 0) { - state.dataInputProcessing->inputProcessor->getObjectItem(state, - CurrentModuleObject, - 1, - Alphas, - NumAlphas, - Numbers, - NumNumbers, - Status, - lNumericBlanks, - lAlphaBlanks, - cAlphaFields, - cNumericFields); + s_ip->getObjectItem(state, + CurrentModuleObject, + 1, + Alphas, + NumAlphas, + Numbers, + NumNumbers, + Status, + lNumericBlanks, + lAlphaBlanks, + cAlphaFields, + cNumericFields); std::string ShadingSunlitFracFileName = Alphas(1); std::string contextString = CurrentModuleObject + ", " + cAlphaFields(1) + ": "; @@ -466,21 +557,21 @@ namespace ScheduleManager { } if (state.dataEnvrn->CurrentYearIsLeapYear) { - rowLimitCount = 366 * 24 * state.dataGlobal->NumOfTimeStepInHour; + rowLimitCount = 366 * Constant::iHoursInDay * s_glob->TimeStepsInHour; } else { - rowLimitCount = 365 * 24 * state.dataGlobal->NumOfTimeStepInHour; + rowLimitCount = 365 * Constant::iHoursInDay * s_glob->TimeStepsInHour; } ColumnSep = CharComma; - schedule_file_shading_result = state.dataScheduleMgr->UniqueProcessedExternalFiles.find(state.files.TempFullFilePath.filePath); - if (schedule_file_shading_result == state.dataScheduleMgr->UniqueProcessedExternalFiles.end()) { + schedule_file_shading_result = s_sched->UniqueProcessedExternalFiles.find(state.files.TempFullFilePath.filePath); + if (schedule_file_shading_result == s_sched->UniqueProcessedExternalFiles.end()) { FileSystem::FileTypes const ext = FileSystem::getFileType(state.files.TempFullFilePath.filePath); if (FileSystem::is_flat_file_type(ext)) { auto const schedule_data = FileSystem::readFile(state.files.TempFullFilePath.filePath); CsvParser csvParser; skiprowCount = 1; // make sure to parse header row only for Schedule:File:Shading - auto it = state.dataScheduleMgr->UniqueProcessedExternalFiles.emplace(state.files.TempFullFilePath.filePath, + auto it = s_sched->UniqueProcessedExternalFiles.emplace(state.files.TempFullFilePath.filePath, csvParser.decode(schedule_data, ColumnSep, skiprowCount)); if (csvParser.hasErrors()) { for (const auto &[error, isContinued] : csvParser.errors()) { @@ -497,12 +588,12 @@ namespace ScheduleManager { } else if (FileSystem::is_all_json_type(ext)) { auto schedule_data = FileSystem::readJSON(state.files.TempFullFilePath.filePath); auto it = // (AUTO_OK_ITER) - state.dataScheduleMgr->UniqueProcessedExternalFiles.emplace(state.files.TempFullFilePath.filePath, std::move(schedule_data)); + s_sched->UniqueProcessedExternalFiles.emplace(state.files.TempFullFilePath.filePath, std::move(schedule_data)); schedule_file_shading_result = it.first; } else { ShowSevereError(state, - fmt::format(R"({}{}="{}", {}="{}" has an unknown file extension and cannot be read by this program.)", - RoutineName, + fmt::format(R"({}: {}="{}", {}="{}" has an unknown file extension and cannot be read by this program.)", + routineName, CurrentModuleObject, Alphas(1), cAlphaFields(3), @@ -513,13 +604,12 @@ namespace ScheduleManager { auto const &column_json = schedule_file_shading_result->second["values"].at(0); // assume there is at least 1 column rowCnt = column_json.size(); - NumCSVAllColumnsSchedules = - schedule_file_shading_result->second["header"].get>().size() - 1; // -1 to account for timestamp column + int NumCSVAllColumnsSchedules = schedule_file_shading_result->second["header"].get>().size() - 1; // -1 to account for timestamp column if (schedule_file_shading_result->second["header"].back().get() == "()") { ShowWarningError(state, - format("{}{}=\"{}\" Removing last column of the CSV since it has '()' for the surface name.", - RoutineName, + format("{}: {}=\"{}\" Removing last column of the CSV since it has '()' for the surface name.", + routineName, CurrentModuleObject, Alphas(1))); ShowContinueError(state, "This was a problem in E+ 22.2.0 and below, consider removing it from the file to suppress this warning."); @@ -530,9 +620,9 @@ namespace ScheduleManager { if (rowCnt != rowLimitCount) { if (rowCnt < rowLimitCount) { - ShowSevereError(state, format("{}{}=\"{}\" {} data values read.", RoutineName, CurrentModuleObject, Alphas(1), rowCnt)); + ShowSevereError(state, format("{}: {}=\"{}\" {} data values read.", routineName, CurrentModuleObject, Alphas(1), rowCnt)); } else if (rowCnt > rowLimitCount) { - ShowSevereError(state, format("{}{}=\"{}\" too many data values read.", RoutineName, CurrentModuleObject, Alphas(1))); + ShowSevereError(state, format("{}: {}=\"{}\" too many data values read.", routineName, CurrentModuleObject, Alphas(1))); } ShowContinueError( state, @@ -541,56 +631,19 @@ namespace ScheduleManager { } // schedule values have been filled into the CSVAllColumnNameAndValues map. - state.dataScheduleMgr->ScheduleFileShadingProcessed = true; + s_sched->ScheduleFileShadingProcessed = true; if (numerrors > 0) { ShowWarningError( state, - format("{}{}=\"{}\" {} records had errors - these values are set to 0.", RoutineName, CurrentModuleObject, Alphas(1), numerrors)); + format("{}:{}=\"{}\" {} records had errors - these values are set to 0.", routineName, CurrentModuleObject, Alphas(1), numerrors)); } } - // add week and day schedules for each ExternalInterface:FunctionalMockupUnitExport:Schedule - AddWeekSch += NumCSVAllColumnsSchedules * 366; // number of days/year - // because need a week for each day - AddDaySch += NumCSVAllColumnsSchedules * 366; - // to update during run time - - // include additional schedules in with count - NumRegDaySchedules = NumHrDaySchedules + NumIntDaySchedules + NumLstDaySchedules; - state.dataScheduleMgr->NumDaySchedules = NumRegDaySchedules + AddDaySch; - state.dataScheduleMgr->NumWeekSchedules = NumRegWeekSchedules + NumCptWeekSchedules + AddWeekSch; - state.dataScheduleMgr->NumSchedules = NumRegSchedules + NumCptSchedules + NumCommaFileSchedules + NumConstantSchedules + - NumExternalInterfaceSchedules + NumExternalInterfaceFunctionalMockupUnitImportSchedules + - NumExternalInterfaceFunctionalMockupUnitExportSchedules + NumCSVAllColumnsSchedules; //! Most initializations in the schedule data structures are taken care of in //! the definitions (see above) - state.dataScheduleMgr->ScheduleType.allocate({0, state.dataScheduleMgr->NumScheduleTypes}); - - state.dataScheduleMgr->DaySchedule.allocate({0, state.dataScheduleMgr->NumDaySchedules}); - state.dataScheduleMgr->UniqueDayScheduleNames.reserve(static_cast(state.dataScheduleMgr->NumDaySchedules)); - // Initialize - for (LoopIndex = 0; LoopIndex <= state.dataScheduleMgr->NumDaySchedules; ++LoopIndex) { - state.dataScheduleMgr->DaySchedule(LoopIndex).TSValue.allocate(state.dataGlobal->NumOfTimeStepInHour, 24); - for (Count = 1; Count <= 24; ++Count) { - for (TS = 1; TS <= state.dataGlobal->NumOfTimeStepInHour; ++TS) { - state.dataScheduleMgr->DaySchedule(LoopIndex).TSValue(TS, Count) = 0.0; - } - } - } - - state.dataScheduleMgr->WeekSchedule.allocate({0, state.dataScheduleMgr->NumWeekSchedules}); - state.dataScheduleMgr->UniqueWeekScheduleNames.reserve(static_cast(state.dataScheduleMgr->NumWeekSchedules)); - - state.dataScheduleMgr->Schedule.allocate({-1, state.dataScheduleMgr->NumSchedules}); - state.dataScheduleMgr->UniqueScheduleNames.reserve(static_cast(state.dataScheduleMgr->NumSchedules)); - state.dataScheduleMgr->Schedule(-1).ScheduleTypePtr = -1; - state.dataScheduleMgr->Schedule(-1).WeekSchedulePointer = 1; - state.dataScheduleMgr->Schedule(0).ScheduleTypePtr = 0; - state.dataScheduleMgr->Schedule(0).WeekSchedulePointer = 0; - print(state.files.audit.ensure_open(state, "ProcessScheduleInput", state.files.outputControl.audit), "{}\n", " Processing Schedule Input -- Start"); @@ -598,88 +651,74 @@ namespace ScheduleManager { //!! Get Schedule Types CurrentModuleObject = "ScheduleTypeLimits"; - for (LoopIndex = 1; LoopIndex <= state.dataScheduleMgr->NumScheduleTypes; ++LoopIndex) { - state.dataInputProcessing->inputProcessor->getObjectItem(state, - CurrentModuleObject, - LoopIndex, - Alphas, - NumAlphas, - Numbers, - NumNumbers, - Status, - lNumericBlanks, - lAlphaBlanks, - cAlphaFields, - cNumericFields); - Util::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound); - - state.dataScheduleMgr->ScheduleType(LoopIndex).Name = Alphas(1); - if (lNumericBlanks(1) || lNumericBlanks(2)) { - state.dataScheduleMgr->ScheduleType(LoopIndex).Limited = false; - } else if (!lNumericBlanks(1) && !lNumericBlanks(2)) { - state.dataScheduleMgr->ScheduleType(LoopIndex).Limited = true; + for (int Loop = 1; Loop <= NumScheduleTypes; ++Loop) { + s_ip->getObjectItem(state, + CurrentModuleObject, + Loop, + Alphas, + NumAlphas, + Numbers, + NumNumbers, + Status, + lNumericBlanks, + lAlphaBlanks, + cAlphaFields, + cNumericFields); + + ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)}; + + if (s_sched->scheduleTypeMap.find(Alphas(1)) != s_sched->scheduleTypeMap.end()) { + ShowSevereDuplicateName(state, eoh); + ErrorsFound = true; + continue; } + + auto *schedType = new ScheduleType; + schedType->Name = Alphas(1); + + schedType->Num = (int)s_sched->scheduleTypes.size(); + s_sched->scheduleTypes.push_back(schedType); + s_sched->scheduleTypeMap.insert_or_assign(schedType->Name, schedType->Num); + + schedType->isLimited = !lNumericBlanks(1) && !lNumericBlanks(2); + if (!lNumericBlanks(1)) { - state.dataScheduleMgr->ScheduleType(LoopIndex).Minimum = Numbers(1); + schedType->minVal = Numbers(1); } if (!lNumericBlanks(2)) { - state.dataScheduleMgr->ScheduleType(LoopIndex).Maximum = Numbers(2); + schedType->maxVal = Numbers(2); } - if (state.dataScheduleMgr->ScheduleType(LoopIndex).Limited) { + + if (schedType->isLimited) { if (Alphas(2) == "DISCRETE" || Alphas(2) == "INTEGER") { - state.dataScheduleMgr->ScheduleType(LoopIndex).IsReal = false; + schedType->isReal = false; + } else if (Alphas(2) == "CONTINUOUS" || Alphas(2) == "REAL") { + schedType->isReal = true; } else { - if (Alphas(2) != "CONTINUOUS" && Alphas(2) != "REAL") { - ShowWarningError(state, - format("{}{}=\"{}\", invalid {}={}", - RoutineName, - CurrentModuleObject, - state.dataScheduleMgr->ScheduleType(LoopIndex).Name, - cAlphaFields(2), - Alphas(2))); - ErrorsFound = true; - } - state.dataScheduleMgr->ScheduleType(LoopIndex).IsReal = true; + ShowSevereInvalidKey(state, eoh, cAlphaFields(2), Alphas(2)); + ErrorsFound = true; } } - if (NumAlphas >= 3) { - if (!lAlphaBlanks(3)) { - state.dataScheduleMgr->ScheduleType(LoopIndex).UnitType = getEnumValue(scheduleTypeLimitUnitTypes, Alphas(3)) + 1; - if (state.dataScheduleMgr->ScheduleType(LoopIndex).UnitType == 0) { - ShowWarningError( - state, - format("{}{}=\"{}\", {}=\"{}\" is invalid.", RoutineName, CurrentModuleObject, Alphas(1), cAlphaFields(3), Alphas(3))); - } + + if (NumAlphas >= 3 && !lAlphaBlanks(3)) { + schedType->limitUnits = static_cast(getEnumValue(limitUnitNamesUC, Alphas(3))); + if (schedType->limitUnits == LimitUnits::Invalid) { + ShowSevereInvalidKey(state, eoh, cAlphaFields(3), Alphas(3)); + ErrorsFound = true; } } - if (state.dataScheduleMgr->ScheduleType(LoopIndex).Limited) { - if (state.dataScheduleMgr->ScheduleType(LoopIndex).Minimum > state.dataScheduleMgr->ScheduleType(LoopIndex).Maximum) { - if (state.dataScheduleMgr->ScheduleType(LoopIndex).IsReal) { - ShowSevereError(state, - format("{}{}=\"{}\", {} [{:.2R}] > {} [{:.2R}].", - RoutineName, - CurrentModuleObject, - Alphas(1), - cNumericFields(1), - state.dataScheduleMgr->ScheduleType(LoopIndex).Minimum, - cNumericFields(2), - state.dataScheduleMgr->ScheduleType(LoopIndex).Maximum)); - ShowContinueError(state, " Other warning/severes about schedule values may appear."); - } else { - ShowSevereError(state, - format("{}{}=\"{}\", {} [{:.0R}] > {} [{:.0R}].", - RoutineName, - CurrentModuleObject, - Alphas(1), - cNumericFields(1), - state.dataScheduleMgr->ScheduleType(LoopIndex).Minimum, - cNumericFields(2), - state.dataScheduleMgr->ScheduleType(LoopIndex).Maximum)); - ShowContinueError(state, " Other warning/severes about schedule values may appear."); - } + + if (schedType->isLimited && schedType->minVal > schedType->maxVal) { + if (schedType->isReal) { + ShowSevereCustom(state, eoh, format("{} [{:.2R}] > {} [{:.2R}].", + cNumericFields(1), schedType->minVal, cNumericFields(2), schedType->maxVal)); + } else { + ShowSevereCustom(state, eoh, + format ("{} [{:.0R}] > {} [{:.0R}].", cNumericFields(1), schedType->minVal, cNumericFields(2), schedType->maxVal)); } + ShowContinueError(state, " Other warning/severes about schedule values may appear."); } - } + } // for (Loop) //!! Get Day Schedules (all types) @@ -687,474 +726,317 @@ namespace ScheduleManager { Count = 0; CurrentModuleObject = "Schedule:Day:Hourly"; - for (LoopIndex = 1; LoopIndex <= NumHrDaySchedules; ++LoopIndex) { - state.dataInputProcessing->inputProcessor->getObjectItem(state, - CurrentModuleObject, - LoopIndex, - Alphas, - NumAlphas, - Numbers, - NumNumbers, - Status, - lNumericBlanks, - lAlphaBlanks, - cAlphaFields, - cNumericFields); - GlobalNames::VerifyUniqueInterObjectName( - state, state.dataScheduleMgr->UniqueDayScheduleNames, Alphas(1), CurrentModuleObject, cAlphaFields(1), ErrorsFound); - ++Count; - state.dataScheduleMgr->DaySchedule(Count).Name = Alphas(1); - // Validate ScheduleType - if (state.dataScheduleMgr->NumScheduleTypes > 0) { - CheckIndex = Util::FindItemInList(Alphas(2), state.dataScheduleMgr->ScheduleType({1, state.dataScheduleMgr->NumScheduleTypes})); - if (CheckIndex == 0) { - if (!lAlphaBlanks(2)) { - ShowWarningError(state, - format("{}{}=\"{}\", {}=\"{}\" not found -- will not be validated", - RoutineName, - CurrentModuleObject, - Alphas(1), - cAlphaFields(2), - Alphas(2))); - } else { - ShowWarningError(state, - format("{}{}=\"{}\", Blank {} input -- will not be validated.", - RoutineName, - CurrentModuleObject, - Alphas(1), - cAlphaFields(2))); - } - } else { - state.dataScheduleMgr->DaySchedule(Count).ScheduleTypePtr = CheckIndex; - } + for (int Loop = 1; Loop <= NumHrDaySchedules; ++Loop) { + s_ip->getObjectItem(state, + CurrentModuleObject, + Loop, + Alphas, + NumAlphas, + Numbers, + NumNumbers, + Status, + lNumericBlanks, + lAlphaBlanks, + cAlphaFields, + cNumericFields); + + ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)}; + + if (s_sched->dayScheduleMap.find(Alphas(1)) != s_sched->dayScheduleMap.end()) { + ShowSevereDuplicateName(state, eoh); + ErrorsFound = true; + continue; } - for (Hr = 1; Hr <= 24; ++Hr) { - state.dataScheduleMgr->DaySchedule(Count).TSValue({1, state.dataGlobal->NumOfTimeStepInHour}, Hr) = Numbers(Hr); + + + auto *daySched = AddDaySchedule(state, Alphas(1)); + + // Validate ScheduleType + if (lAlphaBlanks(2)) { + } else if ((daySched->schedTypeNum = GetScheduleTypeNum(state, Alphas(2))) == SchedNum_Invalid) { + ShowWarningItemNotFound(state, eoh, cAlphaFields(2), Alphas(2)); + ShowContinueError(state, "Schedule will not be validated."); } - state.dataScheduleMgr->DaySchedule(Count).IntervalInterpolated = ScheduleInterpolation::No; - SchedTypePtr = state.dataScheduleMgr->DaySchedule(Count).ScheduleTypePtr; - if (state.dataScheduleMgr->ScheduleType(SchedTypePtr).Limited) { - if (any_lt(state.dataScheduleMgr->DaySchedule(Count).TSValue, state.dataScheduleMgr->ScheduleType(SchedTypePtr).Minimum) || - any_gt(state.dataScheduleMgr->DaySchedule(Count).TSValue, state.dataScheduleMgr->ScheduleType(SchedTypePtr).Maximum)) { - ShowWarningError(state, - format("{}{}=\"{}\", Values are outside of range for {}={}", - RoutineName, - CurrentModuleObject, - Alphas(1), - cAlphaFields(2), - Alphas(2))); + + daySched->interpolation = Interpolation::No; + + for (int hr = 0; hr < Constant::iHoursInDay; ++hr) { + for (int ts = 0; ts < s_glob->TimeStepsInHour; ++ts) { + daySched->tsVals[hr * s_glob->TimeStepsInHour + ts] = Numbers(hr+1); + daySched->sumTsVals += daySched->tsVals[hr * s_glob->TimeStepsInHour + ts]; } } - if (!state.dataScheduleMgr->ScheduleType(SchedTypePtr).IsReal) { - // Make sure each is integer - NumErrorFlag = false; // only show error message once - for (Hr = 1; Hr <= 24; ++Hr) { - for (TS = 1; TS <= state.dataGlobal->NumOfTimeStepInHour; ++TS) { - if (state.dataScheduleMgr->DaySchedule(Count).TSValue(TS, Hr) != - int(state.dataScheduleMgr->DaySchedule(Count).TSValue(TS, Hr))) { - if (!NumErrorFlag) { - ShowWarningError(state, - format("{}{}=\"{}\", One or more values are not integer as required by {}={}", - RoutineName, - CurrentModuleObject, - Alphas(1), - cAlphaFields(2), - Alphas(2))); - NumErrorFlag = true; - } - } - } - } + + if (daySched->checkValsForLimitViolations(state)) { + ShowWarningCustom(state, eoh, format("Values are outside of range for {}={}", cAlphaFields(2), Alphas(2))); } - } - MinuteValue.allocate(60, 24); - SetMinuteValue.allocate(60, 24); + if (daySched->checkValsForBadIntegers(state)) { + ShowWarningCustom(state, eoh, format("One or more values are not integer in {}={}", cAlphaFields(2), Alphas(2))); + } + + } // for (Loop) //!! Get "DaySchedule:Interval" CurrentModuleObject = "Schedule:Day:Interval"; - for (LoopIndex = 1; LoopIndex <= NumIntDaySchedules; ++LoopIndex) { - state.dataInputProcessing->inputProcessor->getObjectItem(state, - CurrentModuleObject, - LoopIndex, - Alphas, - NumAlphas, - Numbers, - NumNumbers, - Status, - lNumericBlanks, - lAlphaBlanks, - cAlphaFields, - cNumericFields); - GlobalNames::VerifyUniqueInterObjectName( - state, state.dataScheduleMgr->UniqueDayScheduleNames, Alphas(1), CurrentModuleObject, cAlphaFields(1), ErrorsFound); - ++Count; - state.dataScheduleMgr->DaySchedule(Count).Name = Alphas(1); + for (int Loop = 1; Loop <= NumIntDaySchedules; ++Loop) { + s_ip->getObjectItem(state, + CurrentModuleObject, + Loop, + Alphas, + NumAlphas, + Numbers, + NumNumbers, + Status, + lNumericBlanks, + lAlphaBlanks, + cAlphaFields, + cNumericFields); + + + ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)}; + + if (s_sched->dayScheduleMap.find(Alphas(1)) != s_sched->dayScheduleMap.end()) { + ShowSevereDuplicateName(state, eoh); + ErrorsFound = true; + continue; + } + + auto *daySched = AddDaySchedule(state, Alphas(1)); + // Validate ScheduleType - if (state.dataScheduleMgr->NumScheduleTypes > 0) { - CheckIndex = Util::FindItemInList(Alphas(2), state.dataScheduleMgr->ScheduleType({1, state.dataScheduleMgr->NumScheduleTypes})); - if (CheckIndex == 0) { - if (!lAlphaBlanks(2)) { - ShowWarningError(state, - format("{}{}=\"{}\", {}=\"{}\" not found -- will not be validated", - RoutineName, - CurrentModuleObject, - Alphas(1), - cAlphaFields(2), - Alphas(2))); - } else { - ShowWarningError(state, - format("{}{}=\"{}\", Blank {} input -- will not be validated.", - RoutineName, - CurrentModuleObject, - Alphas(1), - cAlphaFields(2))); - } - } else { - state.dataScheduleMgr->DaySchedule(Count).ScheduleTypePtr = CheckIndex; - } + if (lAlphaBlanks(2)) { + } else if ((daySched->schedTypeNum = GetScheduleTypeNum(state, Alphas(2))) == SchedNum_Invalid) { + ShowWarningItemNotFound(state, eoh, cAlphaFields(2), Alphas(2)); + ShowContinueError(state, "Schedule will not be validated."); } + NumFields = NumAlphas - 3; // check to see if numfield=0 if (NumFields == 0) { - ShowSevereError( - state, format("{}{}=\"{}\", Insufficient data entered for a full schedule day.", RoutineName, CurrentModuleObject, Alphas(1))); - ShowContinueError(state, format("...Number of interval fields = = [{}].", NumFields)); + ShowSevereCustom(state, eoh, format("Insufficient data entered for a full schedule day." + "Number of interval fields == [{}].", NumFields)); ErrorsFound = true; } // Depending on value of "Interpolate" field, the value for each time step in each hour gets processed: - state.dataScheduleMgr->DaySchedule(Count).IntervalInterpolated = - static_cast(getEnumValue(interpolationTypesUC, Alphas(3))); - if (state.dataScheduleMgr->DaySchedule(Count).IntervalInterpolated == ScheduleInterpolation::Invalid) { - ShowSevereError( - state, - format( - "{}{}=\"{}Invalid value for \"{}\" field=\"{}\"", RoutineName, CurrentModuleObject, Alphas(1), cAlphaFields(3), Alphas(3))); + daySched->interpolation = static_cast(getEnumValue(interpolationNamesUC, Alphas(3))); + if (daySched->interpolation == Interpolation::Invalid) { + ShowSevereInvalidKey(state, eoh, cAlphaFields(3), Alphas(3)); ErrorsFound = true; } + ProcessIntervalFields(state, Alphas({4, _}), Numbers, NumFields, NumNumbers, - MinuteValue, - SetMinuteValue, + minuteVals, + setMinuteVals, ErrorsFound, Alphas(1), CurrentModuleObject, - state.dataScheduleMgr->DaySchedule(Count).IntervalInterpolated); - if (state.dataScheduleMgr->DaySchedule(Count).IntervalInterpolated == ScheduleInterpolation::Average) { - for (Hr = 1; Hr <= 24; ++Hr) { - SCount = 1; - CurMinute = state.dataGlobal->MinutesPerTimeStep; - for (TS = 1; TS <= state.dataGlobal->NumOfTimeStepInHour; ++TS) { - state.dataScheduleMgr->DaySchedule(Count).TSValue(TS, Hr) = - sum(MinuteValue({SCount, CurMinute}, Hr)) / double(state.dataGlobal->MinutesPerTimeStep); - SCount = CurMinute + 1; - CurMinute += state.dataGlobal->MinutesPerTimeStep; - } - } - } else { - for (Hr = 1; Hr <= 24; ++Hr) { - CurMinute = state.dataGlobal->MinutesPerTimeStep; - for (TS = 1; TS <= state.dataGlobal->NumOfTimeStepInHour; ++TS) { - state.dataScheduleMgr->DaySchedule(Count).TSValue(TS, Hr) = MinuteValue(CurMinute, Hr); - CurMinute += state.dataGlobal->MinutesPerTimeStep; - } - } + daySched->interpolation); + + // Now parcel into TS Value.... tsVals.resize() was called in AddDaySchedule() + daySched->populateFromMinuteVals(state, minuteVals); + + if (daySched->checkValsForLimitViolations(state)) { + ShowWarningCustom(state, eoh, format("Values are outside of range for {}={}", cAlphaFields(2), Alphas(2))); } - SchedTypePtr = state.dataScheduleMgr->DaySchedule(Count).ScheduleTypePtr; - if (!state.dataScheduleMgr->ScheduleType(SchedTypePtr).IsReal) { - // Make sure each is integer - NumErrorFlag = false; // only show error message once - for (Hr = 1; Hr <= 24; ++Hr) { - for (TS = 1; TS <= state.dataGlobal->NumOfTimeStepInHour; ++TS) { - if (state.dataScheduleMgr->DaySchedule(Count).TSValue(TS, Hr) != - int(state.dataScheduleMgr->DaySchedule(Count).TSValue(TS, Hr))) { - if (!NumErrorFlag) { - ShowWarningError(state, - format("{}{}=\"{}\", , One or more values are not integer as required by {}={}", - RoutineName, - CurrentModuleObject, - Alphas(1), - cAlphaFields(2), - Alphas(2))); - NumErrorFlag = true; - } - } - } - } + if (daySched->checkValsForBadIntegers(state)) { + ShowWarningCustom(state, eoh, format("One or more values are not integer in {}={}", cAlphaFields(2), Alphas(2))); } } //!! Get "DaySchedule:List" CurrentModuleObject = "Schedule:Day:List"; - for (LoopIndex = 1; LoopIndex <= NumLstDaySchedules; ++LoopIndex) { - state.dataInputProcessing->inputProcessor->getObjectItem(state, - CurrentModuleObject, - LoopIndex, - Alphas, - NumAlphas, - Numbers, - NumNumbers, - Status, - lNumericBlanks, - lAlphaBlanks, - cAlphaFields, - cNumericFields); - GlobalNames::VerifyUniqueInterObjectName( - state, state.dataScheduleMgr->UniqueDayScheduleNames, Alphas(1), CurrentModuleObject, cAlphaFields(1), ErrorsFound); - ++Count; - state.dataScheduleMgr->DaySchedule(Count).Name = Alphas(1); + for (int Loop = 1; Loop <= NumLstDaySchedules; ++Loop) { + s_ip->getObjectItem(state, + CurrentModuleObject, + Loop, + Alphas, + NumAlphas, + Numbers, + NumNumbers, + Status, + lNumericBlanks, + lAlphaBlanks, + cAlphaFields, + cNumericFields); + + ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)}; + + if (s_sched->dayScheduleMap.find(Alphas(1)) != s_sched->dayScheduleMap.end()) { + ShowSevereDuplicateName(state, eoh); + ErrorsFound = true; + continue; + } + + auto *daySched = AddDaySchedule(state, Alphas(1)); + // Validate ScheduleType - if (state.dataScheduleMgr->NumScheduleTypes > 0) { - CheckIndex = Util::FindItemInList(Alphas(2), state.dataScheduleMgr->ScheduleType({1, state.dataScheduleMgr->NumScheduleTypes})); - if (CheckIndex == 0) { - if (!lAlphaBlanks(2)) { - ShowWarningError(state, - format("{}{}=\"{}\", {}=\"{}\" not found -- will not be validated", - RoutineName, - CurrentModuleObject, - Alphas(1), - cAlphaFields(2), - Alphas(2))); - } else { - ShowWarningError(state, - format("{}{}=\"{}\", Blank {} input -- will not be validated.", - RoutineName, - CurrentModuleObject, - Alphas(1), - cAlphaFields(2))); - } - } else { - state.dataScheduleMgr->DaySchedule(Count).ScheduleTypePtr = CheckIndex; - } + if (lAlphaBlanks(2)) { + } else if ((daySched->schedTypeNum = GetScheduleTypeNum(state, Alphas(2))) == SchedNum_Invalid) { + ShowWarningItemNotFound(state, eoh, cAlphaFields(2), Alphas(2)); + ShowContinueError(state, "Schedule will not be validated."); } // Depending on value of "Interpolate" field, the value for each time step in each hour gets processed: - if (Util::SameString(Alphas(3), "NO")) { - state.dataScheduleMgr->DaySchedule(Count).IntervalInterpolated = ScheduleInterpolation::No; - } else if (Util::SameString(Alphas(3), "AVERAGE")) { - state.dataScheduleMgr->DaySchedule(Count).IntervalInterpolated = ScheduleInterpolation::Average; - } else if (Util::SameString(Alphas(3), "LINEAR")) { - state.dataScheduleMgr->DaySchedule(Count).IntervalInterpolated = ScheduleInterpolation::Linear; - } else { - ShowSevereError( - state, - format( - "{}{}=\"{}Invalid value for \"{}\" field=\"{}\"", RoutineName, CurrentModuleObject, Alphas(1), cAlphaFields(3), Alphas(3))); - ErrorsFound = true; - } - + daySched->interpolation = static_cast(getEnumValue(interpolationNamesUC, Alphas(3))); + // check to see if there are any fields if (Numbers(1) <= 0.0) { - ShowSevereError( - state, format("{}{}=\"{}\", Insufficient data entered for a full schedule day.", RoutineName, CurrentModuleObject, Alphas(1))); - ShowContinueError(state, format("...Minutes per Item field = [{}].", Numbers(1))); + ShowSevereCustom(state, eoh, format("Insufficient data entered for a full schedule day." + "...Minutes per Item field = [{}].", Numbers(1))); ErrorsFound = true; continue; } if (NumNumbers < 25) { - ShowSevereError( - state, format("{}{}=\"{}\", Insufficient data entered for a full schedule day.", RoutineName, CurrentModuleObject, Alphas(1))); - ShowContinueError(state, - format("...Minutes per Item field = [{}] and only [{}] to apply to list fields.", Numbers(1), NumNumbers - 1)); + ShowSevereCustom(state, eoh, format("Insufficient data entered for a full schedule day." + "...Minutes per Item field = [{}] and only [{}] to apply to list fields.", Numbers(1), NumNumbers - 1)); ErrorsFound = true; continue; } + MinutesPerItem = int(Numbers(1)); NumExpectedItems = 1440 / MinutesPerItem; if ((NumNumbers - 1) != NumExpectedItems) { - ShowSevereError(state, - format("{}{}=\"{}, Number of Entered Items={}", - RoutineName, - CurrentModuleObject, - Alphas(1), - format("{} not equal number of expected items={}", NumNumbers - 1, NumExpectedItems))); - ShowContinueError(state, format("based on {} field value={}", cNumericFields(1), MinutesPerItem)); + ShowSevereCustom(state, eoh, format("Number of Entered Items={} not equal number of expected items={}" + "based on {}={}", NumNumbers - 1, NumExpectedItems, cNumericFields(1), MinutesPerItem)); ErrorsFound = true; continue; } if (mod(60, MinutesPerItem) != 0) { - ShowSevereError(state, format("{}{}=\"{}", RoutineName, CurrentModuleObject, Alphas(1))); - ShowContinueError(state, format("Requested {} field value ({}) not evenly divisible into 60", cNumericFields(1), MinutesPerItem)); + ShowSevereCustom(state, eoh, format("{}={} not evenly divisible into 60", cNumericFields(1), MinutesPerItem)); ErrorsFound = true; continue; } // Number of numbers in the Numbers list okay to process - Hr = 1; - CurMinute = MinutesPerItem; - SCount = 1; - for (NumFields = 2; NumFields <= NumNumbers; ++NumFields) { - MinuteValue({SCount, CurMinute}, Hr) = Numbers(NumFields); - SCount = CurMinute + 1; - CurMinute += MinutesPerItem; - if (CurMinute > 60) { - CurMinute = MinutesPerItem; - SCount = 1; - ++Hr; + int hr = 0; + int begMinute = 0; + int endMinute = MinutesPerItem - 1; + for (int NumFields = 2; NumFields <= NumNumbers; ++NumFields) { + std::fill(&minuteVals[hr * Constant::iMinutesInHour + begMinute], + &minuteVals[hr * Constant::iMinutesInHour + endMinute], + Numbers(NumFields)); + begMinute = endMinute + 1; + endMinute += MinutesPerItem; + if (endMinute >= 60) { + endMinute = MinutesPerItem - 1; + begMinute = 0; + ++hr; } } - // Now parcel into TS Value.... - - if (state.dataScheduleMgr->DaySchedule(Count).IntervalInterpolated == ScheduleInterpolation::Average) { - for (Hr = 1; Hr <= 24; ++Hr) { - SCount = 1; - CurMinute = state.dataGlobal->MinutesPerTimeStep; - for (TS = 1; TS <= state.dataGlobal->NumOfTimeStepInHour; ++TS) { - state.dataScheduleMgr->DaySchedule(Count).TSValue(TS, Hr) = - sum(MinuteValue({SCount, CurMinute}, Hr)) / double(state.dataGlobal->MinutesPerTimeStep); - SCount = CurMinute + 1; - CurMinute += state.dataGlobal->MinutesPerTimeStep; - } - } - } else { - for (Hr = 1; Hr <= 24; ++Hr) { - CurMinute = state.dataGlobal->MinutesPerTimeStep; - for (TS = 1; TS <= state.dataGlobal->NumOfTimeStepInHour; ++TS) { - state.dataScheduleMgr->DaySchedule(Count).TSValue(TS, Hr) = MinuteValue(CurMinute, Hr); - CurMinute += state.dataGlobal->MinutesPerTimeStep; - } - } - } + // Now parcel into TS Value.... tsVals.resize() was called in AddDaySchedule() + daySched->populateFromMinuteVals(state, minuteVals); - SchedTypePtr = state.dataScheduleMgr->DaySchedule(Count).ScheduleTypePtr; - if (state.dataScheduleMgr->ScheduleType(SchedTypePtr).Limited) { - if (any_lt(state.dataScheduleMgr->DaySchedule(Count).TSValue, state.dataScheduleMgr->ScheduleType(SchedTypePtr).Minimum) || - any_gt(state.dataScheduleMgr->DaySchedule(Count).TSValue, state.dataScheduleMgr->ScheduleType(SchedTypePtr).Maximum)) { - ShowWarningError(state, - format("{}{}=\"{}\", Values are outside of range for {}={}", - RoutineName, - CurrentModuleObject, - Alphas(1), - cAlphaFields(2), - Alphas(2))); - } + if (daySched->checkValsForLimitViolations(state)) { + ShowWarningCustom(state, eoh, format("Values are outside of range for {}={}", cAlphaFields(2), Alphas(2))); } - if (!state.dataScheduleMgr->ScheduleType(SchedTypePtr).IsReal) { - // Make sure each is integer - NumErrorFlag = false; // only show error message once - for (Hr = 1; Hr <= 24; ++Hr) { - for (TS = 1; TS <= state.dataGlobal->NumOfTimeStepInHour; ++TS) { - if (state.dataScheduleMgr->DaySchedule(Count).TSValue(TS, Hr) != - int(state.dataScheduleMgr->DaySchedule(Count).TSValue(TS, Hr))) { - if (!NumErrorFlag) { - ShowWarningError(state, - format("{}{}=\"{}\", , One or more values are not integer as required by {}={}", - RoutineName, - CurrentModuleObject, - Alphas(1), - cAlphaFields(2), - Alphas(2))); - NumErrorFlag = true; - } - } - } - } + + if (daySched->checkValsForBadIntegers(state)) { + ShowWarningCustom(state, eoh, format("One or more values are not integer for {}={}", cAlphaFields(2), Alphas(2))); } } //!! Get Week Schedules - regular CurrentModuleObject = "Schedule:Week:Daily"; - for (LoopIndex = 1; LoopIndex <= NumRegWeekSchedules; ++LoopIndex) { - state.dataInputProcessing->inputProcessor->getObjectItem(state, - CurrentModuleObject, - LoopIndex, - Alphas, - NumAlphas, - Numbers, - NumNumbers, - Status, - lNumericBlanks, - lAlphaBlanks, - cAlphaFields, - cNumericFields); - GlobalNames::VerifyUniqueInterObjectName( - state, state.dataScheduleMgr->UniqueWeekScheduleNames, Alphas(1), CurrentModuleObject, cAlphaFields(1), ErrorsFound); - state.dataScheduleMgr->WeekSchedule(LoopIndex).Name = Alphas(1); - // Rest of Alphas are processed into Pointers - for (InLoopIndex = 1; InLoopIndex <= maxDayTypes; ++InLoopIndex) { - DayIndex = Util::FindItemInList(Alphas(InLoopIndex + 1), state.dataScheduleMgr->DaySchedule({1, NumRegDaySchedules})); - if (DayIndex == 0) { - ShowSevereError(state, - format("{}{}=\"{}\", {} \"{}\" not Found", - RoutineName, - CurrentModuleObject, - Alphas(1), - cAlphaFields(InLoopIndex + 1), - Alphas(InLoopIndex + 1)), - OptionalOutputFileRef{state.files.audit}); - ErrorsFound = true; - } else { - state.dataScheduleMgr->WeekSchedule(LoopIndex).DaySchedulePointer(InLoopIndex) = DayIndex; - } + for (int Loop = 1; Loop <= NumRegWeekSchedules; ++Loop) { + s_ip->getObjectItem(state, + CurrentModuleObject, + Loop, + Alphas, + NumAlphas, + Numbers, + NumNumbers, + Status, + lNumericBlanks, + lAlphaBlanks, + cAlphaFields, + cNumericFields); + + ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)}; + + if (s_sched->weekScheduleMap.find(Alphas(1)) != s_sched->weekScheduleMap.end()) { + ShowSevereDuplicateName(state, eoh); + ErrorsFound = true; + continue; } + + auto *weekSched = AddWeekSchedule(state, Alphas(1)); + + // Rest of Alphas are processed into schedule nums + for (int iDayType = 1; iDayType < (int)DayType::Num; ++iDayType) { + if ((weekSched->dayScheds[iDayType] = GetDaySchedule(state, Alphas(iDayType + 1))) == nullptr) { + ShowSevereItemNotFoundAudit(state, eoh, cAlphaFields(iDayType + 1), Alphas(iDayType + 1)); + ErrorsFound = true; + } + } // for (iDayType) } //!! Get Week Schedules - compact Count = NumRegWeekSchedules; CurrentModuleObject = "Schedule:Week:Compact"; - for (LoopIndex = 1; LoopIndex <= NumCptWeekSchedules; ++LoopIndex) { - state.dataInputProcessing->inputProcessor->getObjectItem(state, - CurrentModuleObject, - LoopIndex, - Alphas, - NumAlphas, - Numbers, - NumNumbers, - Status, - lNumericBlanks, - lAlphaBlanks, - cAlphaFields, - cNumericFields); - if (Count > 0) { - GlobalNames::VerifyUniqueInterObjectName( - state, state.dataScheduleMgr->UniqueWeekScheduleNames, Alphas(1), CurrentModuleObject, cAlphaFields(1), ErrorsFound); - } - ++Count; - state.dataScheduleMgr->WeekSchedule(Count).Name = Alphas(1); - AllDays = false; - // Rest of Alphas are processed into Pointers - for (InLoopIndex = 2; InLoopIndex <= NumAlphas; InLoopIndex += 2) { - DayIndex = Util::FindItemInList(Alphas(InLoopIndex + 1), state.dataScheduleMgr->DaySchedule({1, NumRegDaySchedules})); - if (DayIndex == 0) { - ShowSevereError(state, - format("{}{}=\"{}\", {} \"{}\" not Found", - RoutineName, - CurrentModuleObject, - Alphas(1), - cAlphaFields(InLoopIndex + 1), - Alphas(InLoopIndex + 1)), - OptionalOutputFileRef{state.files.audit}); - ShowContinueError(state, format("ref: {} \"{}\"", cAlphaFields(InLoopIndex), Alphas(InLoopIndex))); + for (int Loop = 1; Loop <= NumCptWeekSchedules; ++Loop) { + s_ip->getObjectItem(state, + CurrentModuleObject, + Loop, + Alphas, + NumAlphas, + Numbers, + NumNumbers, + Status, + lNumericBlanks, + lAlphaBlanks, + cAlphaFields, + cNumericFields); + + ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)}; + + if (s_sched->weekScheduleMap.find(Alphas(1)) != s_sched->weekScheduleMap.end()) { + ShowSevereDuplicateName(state, eoh); + ErrorsFound = true; + continue; + } + + auto *weekSched = AddWeekSchedule(state, Alphas(1)); + + std::fill(allDays.begin(), allDays.end(), false); + // Rest of Alphas are processed into schedule indices + for (int idx = 2; idx <= NumAlphas; idx += 2) { + auto *daySched = GetDaySchedule(state, Alphas(idx + 1)); + if (daySched == nullptr) { + ShowSevereItemNotFoundAudit(state, eoh, cAlphaFields(idx + 1), Alphas(idx + 1)); + ShowContinueError(state, format("ref: {} \"{}\"", cAlphaFields(idx), Alphas(idx))); ErrorsFound = true; } else { - TheseDays = false; + std::fill(theseDays.begin(), theseDays.end(), false); ErrorHere = false; - ProcessForDayTypes(state, Alphas(InLoopIndex), TheseDays, AllDays, ErrorHere); + ProcessForDayTypes(state, Alphas(idx), theseDays, allDays, ErrorHere); if (ErrorHere) { - ShowContinueError(state, format("{}{}=\"{}", RoutineName, CurrentModuleObject, Alphas(1))); + ShowContinueError(state, format("{}: {}=\"{}", routineName, CurrentModuleObject, Alphas(1))); ErrorsFound = true; } else { - for (Hr = 1; Hr <= maxDayTypes; ++Hr) { - if (TheseDays(Hr)) { - state.dataScheduleMgr->WeekSchedule(Count).DaySchedulePointer(Hr) = DayIndex; + for (int iDayType = 1; iDayType < (int)DayType::Num; ++iDayType) { + if (theseDays[iDayType]) { + weekSched->dayScheds[iDayType] = daySched; } } } } } + // Have processed all named days, check to make sure all given - if (!all(AllDays)) { - ShowSevereError(state, format("{}{}=\"{}\", Missing some day assignments", RoutineName, CurrentModuleObject, Alphas(1))); + if (std::find(allDays.begin(), allDays.end(), false) != allDays.end()) { + ShowSevereError(state, format("{}: {}=\"{}\", Missing some day assignments", routineName, CurrentModuleObject, Alphas(1))); ErrorsFound = true; } } @@ -1165,122 +1047,104 @@ namespace ScheduleManager { //!! Get Regular Schedules CurrentModuleObject = "Schedule:Year"; - for (LoopIndex = 1; LoopIndex <= NumRegSchedules; ++LoopIndex) { - state.dataInputProcessing->inputProcessor->getObjectItem(state, - CurrentModuleObject, - LoopIndex, - Alphas, - NumAlphas, - Numbers, - NumNumbers, - Status, - lNumericBlanks, - lAlphaBlanks, - cAlphaFields, - cNumericFields); - GlobalNames::VerifyUniqueInterObjectName( - state, state.dataScheduleMgr->UniqueScheduleNames, Alphas(1), CurrentModuleObject, cAlphaFields(1), ErrorsFound); - state.dataScheduleMgr->Schedule(LoopIndex).Name = Alphas(1); - state.dataScheduleMgr->Schedule(LoopIndex).SchType = SchedType::ScheduleInput_year; + for (int Loop = 1; Loop <= NumRegSchedules; ++Loop) { + s_ip->getObjectItem(state, + CurrentModuleObject, + Loop, + Alphas, + NumAlphas, + Numbers, + NumNumbers, + Status, + lNumericBlanks, + lAlphaBlanks, + cAlphaFields, + cNumericFields); + + ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)}; + + if (s_sched->scheduleMap.find(Alphas(1)) != s_sched->scheduleMap.end()) { + ShowSevereDuplicateName(state, eoh); + ErrorsFound = true; + continue; + } + + auto *sched = AddScheduleDetailed(state, Alphas(1)); + // Validate ScheduleType - if (state.dataScheduleMgr->NumScheduleTypes > 0) { - CheckIndex = Util::FindItemInList(Alphas(2), state.dataScheduleMgr->ScheduleType({1, state.dataScheduleMgr->NumScheduleTypes})); - if (CheckIndex == 0) { - if (!lAlphaBlanks(2)) { - ShowWarningError(state, - format("{}{}=\"{}\", {}=\"{}\" not found -- will not be validated", - RoutineName, - CurrentModuleObject, - Alphas(1), - cAlphaFields(2), - Alphas(2))); - } else { - ShowWarningError(state, - format("{}{}=\"{}\", Blank {} input -- will not be validated.", - RoutineName, - CurrentModuleObject, - Alphas(1), - cAlphaFields(2))); - } - } else { - state.dataScheduleMgr->Schedule(LoopIndex).ScheduleTypePtr = CheckIndex; - } + if (lAlphaBlanks(2)) { + } else if ((sched->schedTypeNum = GetScheduleTypeNum(state, Alphas(2))) == 0) { + ShowWarningItemNotFound(state, eoh, cAlphaFields(2), Alphas(2)); + ShowContinueError(state, "Schedule will not be validated."); } - NumPointer = 0; - DaysInYear = 0; + + int NumPointer = 0; + + std::array daysInYear; + std::fill(daysInYear.begin(), daysInYear.end(), 0); + // Rest of Alphas (Weekschedules) are processed into Pointers - for (InLoopIndex = 3; InLoopIndex <= NumAlphas; ++InLoopIndex) { - WeekIndex = Util::FindItemInList(Alphas(InLoopIndex), state.dataScheduleMgr->WeekSchedule({1, NumRegWeekSchedules})); - if (WeekIndex == 0) { - ShowSevereError(state, - format("{}{}=\"{}\", {}=\"{}\" not found.", - RoutineName, - CurrentModuleObject, - Alphas(1), - cAlphaFields(InLoopIndex), - Alphas(InLoopIndex)), - OptionalOutputFileRef{state.files.audit}); + for (int idx = 3; idx <= NumAlphas; ++idx) { + auto *weekSched = GetWeekSchedule(state, Alphas(idx)); + if (weekSched == nullptr) { + ShowSevereItemNotFoundAudit(state, eoh, cAlphaFields(idx), Alphas(idx)); ErrorsFound = true; + continue; + } + + // Process for month, day + int StartMonth = int(Numbers(NumPointer + 1)); + int StartDay = int(Numbers(NumPointer + 2)); + int EndMonth = int(Numbers(NumPointer + 3)); + int EndDay = int(Numbers(NumPointer + 4)); + NumPointer += 4; + int StartPointer = General::OrdinalDay(StartMonth, StartDay, 1); + int EndPointer = General::OrdinalDay(EndMonth, EndDay, 1); + if (StartPointer <= EndPointer) { + for (int Count = StartPointer; Count <= EndPointer; ++Count) { + ++daysInYear[Count]; + sched->weekScheds[Count] = weekSched; + } } else { - // Process for month, day - StartMonth = int(Numbers(NumPointer + 1)); - StartDay = int(Numbers(NumPointer + 2)); - EndMonth = int(Numbers(NumPointer + 3)); - EndDay = int(Numbers(NumPointer + 4)); - NumPointer += 4; - StartPointer = General::OrdinalDay(StartMonth, StartDay, 1); - EndPointer = General::OrdinalDay(EndMonth, EndDay, 1); - if (StartPointer <= EndPointer) { - for (Count = StartPointer; Count <= EndPointer; ++Count) { - ++DaysInYear(Count); - state.dataScheduleMgr->Schedule(LoopIndex).WeekSchedulePointer(Count) = WeekIndex; - } - } else { - for (Count = StartPointer; Count <= 366; ++Count) { - ++DaysInYear(Count); - state.dataScheduleMgr->Schedule(LoopIndex).WeekSchedulePointer(Count) = WeekIndex; - } - for (Count = 1; Count <= EndPointer; ++Count) { - ++DaysInYear(Count); - state.dataScheduleMgr->Schedule(LoopIndex).WeekSchedulePointer(Count) = WeekIndex; - } + for (int Count = StartPointer; Count <= 366; ++Count) { + ++daysInYear[Count]; + sched->weekScheds[Count] = weekSched; + } + for (int Count = 1; Count <= EndPointer; ++Count) { + ++daysInYear[Count]; + sched->weekScheds[Count] = weekSched; } } } + // Perform Error checks on this item // Do special test for Feb 29. Make equal to Feb 28. - if (DaysInYear(60) == 0) { - DaysInYear(60) = DaysInYear(59); - state.dataScheduleMgr->Schedule(LoopIndex).WeekSchedulePointer(60) = - state.dataScheduleMgr->Schedule(LoopIndex).WeekSchedulePointer(59); - } - if (any_eq(DaysInYear, 0)) { - ShowSevereError(state, - format("{}{}=\"{}\" has missing days in its schedule pointers", - RoutineName, - CurrentModuleObject, - state.dataScheduleMgr->Schedule(LoopIndex).Name), - OptionalOutputFileRef{state.files.audit}); - ErrorsFound = true; + if (daysInYear[60] == 0) { + daysInYear[60] = daysInYear[59]; + sched->weekScheds[60] = sched->weekScheds[59]; } - if (any_gt(DaysInYear, 1)) { - ShowSevereError(state, - format("{}{}=\"{}\" has overlapping days in its schedule pointers", - RoutineName, - CurrentModuleObject, - state.dataScheduleMgr->Schedule(LoopIndex).Name), - OptionalOutputFileRef{state.files.audit}); - ErrorsFound = true; + + for (int iDay = 1; iDay <= 366; ++iDay) { + if (daysInYear[iDay] == 0) { + ShowSevereCustomAudit(state, eoh, "has missing days in its schedule pointers"); + ErrorsFound = true; + break; + } else if (daysInYear[iDay] > 1) { + ShowSevereCustomAudit(state, eoh, "has overlapping days in its schedule pointers"); + ErrorsFound = true; + break; + } } - if (state.dataGlobal->AnyEnergyManagementSystemInModel) { // setup constant schedules as actuators + // What does it mean to actuate a schedule? + if (s_glob->AnyEnergyManagementSystemInModel) { // setup constant schedules as actuators SetupEMSActuator(state, "Schedule:Year", - state.dataScheduleMgr->Schedule(LoopIndex).Name, + sched->Name, "Schedule Value", "[ ]", - state.dataScheduleMgr->Schedule(LoopIndex).EMSActuatedOn, - state.dataScheduleMgr->Schedule(LoopIndex).EMSValue); + sched->EMSActuatedOn, + sched->EMSVal); } } @@ -1305,49 +1169,47 @@ namespace ScheduleManager { // A5 , \field Complex Field #3 SchNum = NumRegSchedules; - AddWeekSch = NumRegWeekSchedules; - AddDaySch = NumRegDaySchedules; CurrentModuleObject = "Schedule:Compact"; - for (LoopIndex = 1; LoopIndex <= NumCptSchedules; ++LoopIndex) { - state.dataInputProcessing->inputProcessor->getObjectItem(state, - CurrentModuleObject, - LoopIndex, - Alphas, - NumAlphas, - Numbers, - NumNumbers, - Status, - lNumericBlanks, - lAlphaBlanks, - cAlphaFields, - cNumericFields); - GlobalNames::VerifyUniqueInterObjectName( - state, state.dataScheduleMgr->UniqueScheduleNames, Alphas(1), CurrentModuleObject, cAlphaFields(1), ErrorsFound); - ++SchNum; - state.dataScheduleMgr->Schedule(SchNum).Name = Alphas(1); - state.dataScheduleMgr->Schedule(SchNum).SchType = SchedType::ScheduleInput_compact; - // Validate ScheduleType - CheckIndex = Util::FindItemInList(Alphas(2), state.dataScheduleMgr->ScheduleType({1, state.dataScheduleMgr->NumScheduleTypes})); - if (CheckIndex == 0) { - if (!lAlphaBlanks(2)) { - ShowWarningError(state, - format("{}{}=\"{}\", {}=\"{}\" not found -- will not be validated", - RoutineName, - CurrentModuleObject, - Alphas(1), - cAlphaFields(2), - Alphas(2))); - } else { - ShowWarningError( - state, - format( - "{}{}=\"{}\", Blank {} input -- will not be validated.", RoutineName, CurrentModuleObject, Alphas(1), cAlphaFields(2))); - } - } else { - state.dataScheduleMgr->Schedule(SchNum).ScheduleTypePtr = CheckIndex; + for (int Loop = 1; Loop <= NumCptSchedules; ++Loop) { + s_ip->getObjectItem(state, + CurrentModuleObject, + Loop, + Alphas, + NumAlphas, + Numbers, + NumNumbers, + Status, + lNumericBlanks, + lAlphaBlanks, + cAlphaFields, + cNumericFields); + + + ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)}; + + if (s_sched->scheduleMap.find(Alphas(1)) != s_sched->scheduleMap.end()) { + ShowSevereDuplicateName(state, eoh); + ErrorsFound = true; + continue; } + + auto *sched = AddScheduleDetailed(state, Alphas(1)); + sched->type = SchedType::Compact; + + // Validate ScheduleType + if (lAlphaBlanks(2)) { + ShowWarningEmptyField(state, eoh, cAlphaFields(2)); + ShowContinueError(state, "Schedule will not be validated."); + + } else if ((sched->schedTypeNum = GetScheduleTypeNum(state, Alphas(2))) == SchedNum_Invalid) { + ShowWarningItemNotFound(state, eoh, cAlphaFields(2), Alphas(2)); + ShowContinueError(state, "Schedule will not be validated."); + } + NumPointer = 0; - DaysInYear = 0; + + std::array daysInYear; + std::fill(daysInYear.begin()+1, daysInYear.end(), 0); // Process the "complex" fields -- so named because they are not a 1:1 correspondence // as other objects are NumField = 3; @@ -1358,139 +1220,103 @@ namespace ScheduleManager { while (NumField < NumAlphas) { // Process "Through" if (!has_prefix(Alphas(NumField), "THROUGH:") && !has_prefix(Alphas(NumField), "THROUGH")) { - ShowSevereError(state, - format("{}{}=\"{}\", Expecting \"Through:\" date", - RoutineName, - CurrentModuleObject, - state.dataScheduleMgr->Schedule(SchNum).Name)); - ShowContinueError(state, format("Instead, found entry={}", Alphas(NumField))); + ShowSevereCustom(state, eoh, format("Expecting \"Through:\" date, instead found entry={}", Alphas(NumField))); ErrorsFound = true; goto Through_exit; - } else { - if (Alphas(NumField)[7] == ':') { - sPos = 8; - } else { - sPos = 7; - } - Alphas(NumField).erase(0, sPos); - strip(Alphas(NumField)); } + + + int sPos = (Alphas(NumField)[7] == ':') ? 8 : 7; + Alphas(NumField).erase(0, sPos); + strip(Alphas(NumField)); + CurrentThrough = Alphas(NumField); ErrorHere = false; ProcessDateString(state, Alphas(NumField), EndMonth, EndDay, PWeekDay, PDateType, ErrorHere); if (PDateType == Weather::DateType::NthDayInMonth || PDateType == Weather::DateType::LastDayInMonth) { - ShowSevereError(state, - format("{}{}=\"{}\", Invalid \"Through:\" date", - RoutineName, - CurrentModuleObject, - state.dataScheduleMgr->Schedule(SchNum).Name)); - ShowContinueError(state, format("Found entry={}", Alphas(NumField))); + ShowSevereCustom(state, eoh, format("Invalid \"Through:\" date, found entry={}", Alphas(NumField))); ErrorsFound = true; goto Through_exit; - } else if (ErrorHere) { - ShowSevereError(state, - format("{}{}=\"{}\", Invalid \"Through:\" date", - RoutineName, - CurrentModuleObject, - state.dataScheduleMgr->Schedule(SchNum).Name)); - ShowContinueError(state, format("Found entry={}", Alphas(NumField))); + } + + if (ErrorHere) { + ShowSevereCustom(state, eoh, "Invalid \"Through:\" date"); ErrorsFound = true; goto Through_exit; - } else { - EndPointer = General::OrdinalDay(EndMonth, EndDay, 1); - if (EndPointer == 366) { - if (FullYearSet) { - ShowSevereError(state, - format("{}{}=\"{}\", New \"Through\" entry when \"full year\" already set", - RoutineName, - CurrentModuleObject, - state.dataScheduleMgr->Schedule(SchNum).Name)); - ShowContinueError(state, format("\"Through\" field={}", CurrentThrough)); - ErrorsFound = true; - } - FullYearSet = true; + } + + EndPointer = General::OrdinalDay(EndMonth, EndDay, 1); + if (EndPointer == 366) { + if (FullYearSet) { + ShowSevereCustom(state, eoh, format("New \"Through\" entry when \"full year\" already set \"Through\" field={}", CurrentThrough)); + ErrorsFound = true; } + FullYearSet = true; } + ++WkCount; - ++AddWeekSch; - state.dataScheduleMgr->WeekSchedule(AddWeekSch).Name = format("{}_wk_{}", Alphas(1), WkCount); - state.dataScheduleMgr->WeekSchedule(AddWeekSch).Used = true; - for (Hr = StartPointer; Hr <= EndPointer; ++Hr) { - state.dataScheduleMgr->Schedule(SchNum).WeekSchedulePointer(Hr) = AddWeekSch; - ++DaysInYear(Hr); + + auto *weekSched = AddWeekSchedule(state, format("{}_wk_{}", Alphas(1), WkCount)); + weekSched->isUsed = true; + + for (int iDay = StartPointer; iDay <= EndPointer; ++iDay) { + sched->weekScheds[iDay] = weekSched; + ++daysInYear[iDay]; } + StartPointer = EndPointer + 1; ThruField = NumField; - AllDays = false; + std::fill(allDays.begin(), allDays.end(), false); ++NumField; + while (NumField < NumAlphas) { // Continues until next "Through" if (has_prefix(Alphas(NumField), "THROUGH")) goto For_exit; // "For" must be next, adds to "# Day Schedules" - if (has_prefix(Alphas(NumField), "FOR")) { - ++DyCount; - ++AddDaySch; - state.dataScheduleMgr->DaySchedule(AddDaySch).Name = format("{}_dy_{}", Alphas(1), DyCount); - state.dataScheduleMgr->DaySchedule(AddDaySch).ScheduleTypePtr = state.dataScheduleMgr->Schedule(SchNum).ScheduleTypePtr; - state.dataScheduleMgr->DaySchedule(AddDaySch).Used = true; - TheseDays = false; - ErrorHere = false; - LastFor = Alphas(NumField); - ProcessForDayTypes(state, Alphas(NumField), TheseDays, AllDays, ErrorHere); - if (ErrorHere) { - ShowContinueError(state, format("ref {}=\"{}\"", CurrentModuleObject, Alphas(1))); - ShowContinueError(state, format("ref Through field={}", Alphas(ThruField))); - ErrorsFound = true; - } else { - for (Hr = 1; Hr <= maxDayTypes; ++Hr) { - if (TheseDays(Hr)) { - state.dataScheduleMgr->WeekSchedule(AddWeekSch).DaySchedulePointer(Hr) = AddDaySch; - } - } - } - } else { - ShowSevereError( - state, - format( - "{}{}=\"{}\", Looking for \"For\" field, found={}", RoutineName, CurrentModuleObject, Alphas(1), Alphas(NumField))); + if (!has_prefix(Alphas(NumField), "FOR")) { + ShowSevereCustom(state, eoh, format("Looking for \"For\" field, found={}", Alphas(NumField))); ErrorsFound = true; - // CALL ShowSevereError(state, RoutineName//TRIM(CurrentModuleObject)//'="'//TRIM(Schedule(SchNum)%Name)// & - // '", Expecting "For:" day types') - // CALL ShowContinueError(state, 'Instead, found entry='//TRIM(Alphas(NumField))) goto Through_exit; + } + + ++DyCount; + + auto *daySched = AddDaySchedule(state, format("{}_dy_{}", Alphas(1), DyCount)); + + daySched->schedTypeNum = sched->schedTypeNum; + daySched->isUsed = true; + + std::fill(theseDays.begin(), theseDays.end(), false); + ErrorHere = false; + LastFor = Alphas(NumField); + ProcessForDayTypes(state, Alphas(NumField), theseDays, allDays, ErrorHere); + if (ErrorHere) { + ShowContinueError(state, format("ref {}=\"{}\"", CurrentModuleObject, Alphas(1))); + ShowContinueError(state, format("ref Through field={}", Alphas(ThruField))); + ErrorsFound = true; + } else { + for (int iDayType = 1; iDayType < (int)DayType::Num; ++iDayType) { + if (theseDays[iDayType]) { + weekSched->dayScheds[iDayType] = daySched; + } + } } + // Check for "Interpolate" ++NumField; - if (has_prefix(Alphas(NumField), "INTERPOLATE")) { + if (has_prefix(Alphas(NumField), "INTERPOLATE") || !has_prefix(Alphas(NumField), "UNTIL")) { if (has(Alphas(NumField), "NO")) { - state.dataScheduleMgr->DaySchedule(AddDaySch).IntervalInterpolated = ScheduleInterpolation::No; + daySched->interpolation = Interpolation::No; } else if (has(Alphas(NumField), "AVERAGE")) { - state.dataScheduleMgr->DaySchedule(AddDaySch).IntervalInterpolated = ScheduleInterpolation::Average; + daySched->interpolation = Interpolation::Average; } else if (has(Alphas(NumField), "LINEAR")) { - state.dataScheduleMgr->DaySchedule(AddDaySch).IntervalInterpolated = ScheduleInterpolation::Linear; + daySched->interpolation = Interpolation::Linear; } else { - ShowSevereError(state, - std::string{RoutineName} + CurrentModuleObject + "=\"" + Alphas(1) + "Invalid value for \"" + - cAlphaFields(NumField) + "\" field=\"" + Alphas(NumField) + "\""); + ShowSevereInvalidKey(state, eoh, cAlphaFields(NumField), Alphas(NumField)); ErrorsFound = true; } ++NumField; - } else { - if (!has_prefix(Alphas(NumField), "UNTIL")) { - if (has(Alphas(NumField), "NO")) { - state.dataScheduleMgr->DaySchedule(AddDaySch).IntervalInterpolated = ScheduleInterpolation::No; - } else if (has(Alphas(NumField), "AVERAGE")) { - state.dataScheduleMgr->DaySchedule(AddDaySch).IntervalInterpolated = ScheduleInterpolation::Average; - } else if (has(Alphas(NumField), "LINEAR")) { - state.dataScheduleMgr->DaySchedule(AddDaySch).IntervalInterpolated = ScheduleInterpolation::Linear; - } else { - ShowSevereError( - state, - format("{}{}=\"{}\", Illegal Field entered ={}", RoutineName, CurrentModuleObject, Alphas(1), Alphas(NumField))); - ErrorsFound = true; - } - ++NumField; - } } + NumNumbers = 0; xxcount = 0; UntilFld = NumField; @@ -1504,25 +1330,19 @@ namespace ScheduleManager { ++NumNumbers; Numbers(NumNumbers) = Util::ProcessNumber(Alphas(NumField), ErrorHere); if (ErrorHere) { - ShowSevereError(state, format("{}=\"{}\"", CurrentModuleObject, Alphas(1))); - ShowContinueError(state, - format("Until field=[{}] has illegal value field=[{}].", Alphas(NumField - 1), Alphas(NumField))); + ShowSevereCustom(state, eoh, format("Until field=[{}] has illegal value field=[{}].", Alphas(NumField - 1), Alphas(NumField))); ErrorsFound = true; } ++NumField; Alphas(UntilFld + xxcount) = Alphas(NumField); // Incase next is "until" } else { - ShowSevereError(state, - format("{}{}=\"{}\", Looking for \"Until\" field, found={}", - RoutineName, - CurrentModuleObject, - Alphas(1), - Alphas(NumField))); + ShowSevereCustom(state, eoh, format("Looking for \"Until\" field, found={}", Alphas(NumField))); ErrorsFound = true; goto Through_exit; } if (Alphas(NumField).empty()) break; } + // Process Untils, Numbers if (NumNumbers > 0) { NumFields = NumNumbers; @@ -1532,94 +1352,85 @@ namespace ScheduleManager { Numbers, NumFields, NumNumbers, - MinuteValue, - SetMinuteValue, + minuteVals, + setMinuteVals, ErrorHere, - state.dataScheduleMgr->DaySchedule(AddDaySch).Name, + daySched->Name, CurrentModuleObject + " DaySchedule Fields", - state.dataScheduleMgr->DaySchedule(AddDaySch).IntervalInterpolated); + daySched->interpolation); // Depending on value of "Interpolate" field, the value for each time step in each hour gets processed: if (ErrorHere) { ShowContinueError(state, format("ref {}=\"{}\"", CurrentModuleObject, Alphas(1))); ErrorsFound = true; } - if (state.dataScheduleMgr->DaySchedule(AddDaySch).IntervalInterpolated == - ScheduleInterpolation::No) { // No validation done on the value of the interpolation field - for (Hr = 1; Hr <= 24; ++Hr) { - CurMinute = state.dataGlobal->MinutesPerTimeStep; - for (TS = 1; TS <= state.dataGlobal->NumOfTimeStepInHour; ++TS) { - state.dataScheduleMgr->DaySchedule(AddDaySch).TSValue(TS, Hr) = MinuteValue(CurMinute, Hr); - CurMinute += state.dataGlobal->MinutesPerTimeStep; + + // No validation done on the value of the interpolation field + if (daySched->interpolation == Interpolation::No) { + for (int hr = 0; hr < Constant::iHoursInDay; ++hr) { + int curMinute = s_glob->MinutesInTimeStep - 1; + for (int ts = 0; ts < s_glob->TimeStepsInHour; ++ts) { + daySched->tsVals[hr * s_glob->TimeStepsInHour + ts] = minuteVals[hr * Constant::iMinutesInHour + curMinute]; + daySched->sumTsVals += daySched->tsVals[hr * s_glob->TimeStepsInHour + ts]; + curMinute += s_glob->MinutesInTimeStep; } } } else { - for (Hr = 1; Hr <= 24; ++Hr) { - SCount = 1; - CurMinute = state.dataGlobal->MinutesPerTimeStep; - for (TS = 1; TS <= state.dataGlobal->NumOfTimeStepInHour; ++TS) { - // tempval=SUM(MinuteValue(Hr,SCount:CurMinute))/REAL(MinutesPerTimeStep,r64) - state.dataScheduleMgr->DaySchedule(AddDaySch).TSValue(TS, Hr) = - sum(MinuteValue({SCount, CurMinute}, Hr)) / double(state.dataGlobal->MinutesPerTimeStep); - SCount = CurMinute + 1; - CurMinute += state.dataGlobal->MinutesPerTimeStep; + for (int hr = 0; hr < Constant::iHoursInDay; ++hr) { + int begMinute = 0; + int endMinute = s_glob->MinutesInTimeStep - 1; + for (int ts = 0; ts < s_glob->TimeStepsInHour; ++ts) { + daySched->tsVals[hr * s_glob->TimeStepsInHour + ts] = + std::accumulate(minuteVals.begin() + (hr * Constant::iMinutesInHour + begMinute), + minuteVals.begin() + (hr * Constant::iMinutesInHour + endMinute), + 0) / double(s_glob->MinutesInTimeStep); + daySched->sumTsVals += daySched->tsVals[hr * s_glob->TimeStepsInHour + ts]; + begMinute = endMinute + 1; + endMinute += s_glob->MinutesInTimeStep; } } } } } + For_exit:; - if (!all(AllDays)) { - ShowWarningError(state, - format("{}{}=\"{}\" has missing day types in Through={}", - RoutineName, - CurrentModuleObject, - state.dataScheduleMgr->Schedule(SchNum).Name, - CurrentThrough)); + if (std::find(allDays.begin(), allDays.end(), false) != allDays.end()) { + ShowWarningCustom(state, eoh, format("has missing day types in Through={}", CurrentThrough)); ShowContinueError(state, format("Last \"For\" field={}", LastFor)); - errmsg = "Missing day types=,"; - for (kdy = 1; kdy <= maxDayTypes; ++kdy) { - if (AllDays(kdy)) continue; + std::string errmsg = "Missing day types=,"; + for (int kDayType = 0; kDayType < (int)DayType::Num; ++kDayType) { + if (allDays[kDayType]) continue; errmsg.erase(errmsg.length() - 1); - errmsg += "\"" + static_cast(dayTypeNames[kdy]) + "\",-"; + errmsg = format("{} \"{}\",-", errmsg, dayTypeNames[kDayType]); } errmsg.erase(errmsg.length() - 2); ShowContinueError(state, errmsg); ShowContinueError(state, "Missing day types will have 0.0 as Schedule Values"); } } + Through_exit:; - if (DaysInYear(60) == 0) { - DaysInYear(60) = DaysInYear(59); - state.dataScheduleMgr->Schedule(LoopIndex).WeekSchedulePointer(60) = - state.dataScheduleMgr->Schedule(LoopIndex).WeekSchedulePointer(59); + if (daysInYear[60] == 0) { + daysInYear[60] = daysInYear[59]; + sched->weekScheds[60] = sched->weekScheds[59]; } - if (any_eq(DaysInYear, 0)) { - ShowSevereError(state, - format("{}{}=\"{}\" has missing days in its schedule pointers", - RoutineName, - CurrentModuleObject, - state.dataScheduleMgr->Schedule(SchNum).Name), - OptionalOutputFileRef{state.files.audit}); + + if (std::find(daysInYear.begin()+1, daysInYear.end(), 0) != daysInYear.end()) { + ShowSevereCustomAudit(state, eoh, "has missing days in its schedule pointers"); ErrorsFound = true; } - if (any_gt(DaysInYear, 1)) { - ShowSevereError(state, - format("{}{}=\"{}\" has overlapping days in its schedule pointers", - RoutineName, - CurrentModuleObject, - state.dataScheduleMgr->Schedule(SchNum).Name), - OptionalOutputFileRef{state.files.audit}); + if (std::find_if(daysInYear.begin()+1, daysInYear.end(), [](int i){ return i > 1; }) != daysInYear.end()) { + ShowSevereCustomAudit(state, eoh, "has overlapping days in its schedule pointers"); ErrorsFound = true; } - if (state.dataGlobal->AnyEnergyManagementSystemInModel) { // setup constant schedules as actuators + if (s_glob->AnyEnergyManagementSystemInModel) { // setup constant schedules as actuators SetupEMSActuator(state, "Schedule:Compact", - state.dataScheduleMgr->Schedule(SchNum).Name, + sched->Name, "Schedule Value", "[ ]", - state.dataScheduleMgr->Schedule(SchNum).EMSActuatedOn, - state.dataScheduleMgr->Schedule(SchNum).EMSValue); + sched->EMSActuatedOn, + sched->EMSVal); } } @@ -1672,46 +1483,40 @@ namespace ScheduleManager { // \maximum 60 // continue adding to SchNum,AddWeekSch,AddDaySch + CurrentModuleObject = "Schedule:File"; - for (LoopIndex = 1; LoopIndex <= NumCommaFileSchedules; ++LoopIndex) { - state.dataInputProcessing->inputProcessor->getObjectItem(state, - CurrentModuleObject, - LoopIndex, - Alphas, - NumAlphas, - Numbers, - NumNumbers, - Status, - lNumericBlanks, - lAlphaBlanks, - cAlphaFields, - cNumericFields); - GlobalNames::VerifyUniqueInterObjectName( - state, state.dataScheduleMgr->UniqueScheduleNames, Alphas(1), CurrentModuleObject, cAlphaFields(1), ErrorsFound); - ++SchNum; - state.dataScheduleMgr->Schedule(SchNum).Name = Alphas(1); - state.dataScheduleMgr->Schedule(SchNum).SchType = SchedType::ScheduleInput_file; + for (int Loop = 1; Loop <= NumCommaFileSchedules; ++Loop) { + s_ip->getObjectItem(state, + CurrentModuleObject, + Loop, + Alphas, + NumAlphas, + Numbers, + NumNumbers, + Status, + lNumericBlanks, + lAlphaBlanks, + cAlphaFields, + cNumericFields); + + ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)}; + + if (s_sched->scheduleMap.find(Alphas(1)) != s_sched->scheduleMap.end()) { + ShowSevereDuplicateName(state, eoh); + ErrorsFound = true; + continue; + } + + auto *sched = AddScheduleDetailed(state, Alphas(1)); + sched->type = SchedType::File; + // Validate ScheduleType - if (state.dataScheduleMgr->NumScheduleTypes > 0) { - CheckIndex = 0; - if (!lAlphaBlanks(2)) - CheckIndex = Util::FindItemInList(Alphas(2), state.dataScheduleMgr->ScheduleType({1, state.dataScheduleMgr->NumScheduleTypes})); - if (CheckIndex == 0) { - if (!lAlphaBlanks(2)) { - ShowWarningError(state, - format("ProcessScheduleInput: For {}=\"{}\", {}=\"{}\" not found -- will not be validated", - CurrentModuleObject, - Alphas(1), - cAlphaFields(2), - Alphas(2))); - } else { - ShowWarningError( - state, - format("For {}=\"{}\", Blank {} input -- will not be validated.", CurrentModuleObject, Alphas(1), cAlphaFields(2))); - } - } else { - state.dataScheduleMgr->Schedule(SchNum).ScheduleTypePtr = CheckIndex; - } + if (lAlphaBlanks(2)) { + ShowWarningEmptyField(state, eoh, cAlphaFields(2)); + ShowContinueError(state, "Schedule will not be validated."); + } else if ((sched->schedTypeNum = GetScheduleTypeNum(state, Alphas(2))) == SchedNum_Invalid) { + ShowWarningItemNotFound(state, eoh, cAlphaFields(2), Alphas(2)); + ShowContinueError(state, "Schedule will not be validated."); } // Numbers(1) - which column @@ -1720,10 +1525,8 @@ namespace ScheduleManager { skiprowCount = Numbers(2); if (Numbers(3) == 0) Numbers(3) = 8760.0; if (Numbers(3) != 8760 && Numbers(3) != 8784) { - ShowSevereError( - state, - format("{}{}=\"{}\", {} must = 8760 or 8784 (for a leap year)", RoutineName, CurrentModuleObject, Alphas(1), cNumericFields(3))); - ShowContinueError(state, format("..Value for field = {:.0T}, Schedule not processed.", Numbers(3))); + ShowSevereCustom(state, eoh, format("{} must = 8760 or 8784 (for a leap year). Value = {:.0T}, Schedule not processed.", + cNumericFields(3), Numbers(3))); ErrorsFound = true; continue; } @@ -1738,64 +1541,59 @@ namespace ScheduleManager { } else if (Util::SameString(Alphas(4), "space")) { ColumnSep = CharSpace; } else { - ShowSevereError( - state, format("{}{}=\"{}\", {} illegal value=\"{}\".", RoutineName, CurrentModuleObject, Alphas(1), cAlphaFields(4), Alphas(4))); - ShowContinueError(state, "..must be Comma, Semicolon, Tab, or Space."); + ShowSevereInvalidKey(state, eoh, cAlphaFields(4), Alphas(4), "..must be Comma, Semicolon, Tab, or Space."); ErrorsFound = true; continue; } // Depending on value of "Interpolate" field, the value for each time step in each hour gets processed: FileIntervalInterpolated = false; - if (lAlphaBlanks(5)) Alphas(5) = "NO"; - if (Alphas(5) != "NO" && Alphas(5) != "YES") { - ShowSevereError( - state, - format( - "{}{}=\"{}Invalid value for \"{}\" field=\"{}\"", RoutineName, CurrentModuleObject, Alphas(1), cAlphaFields(5), Alphas(5))); - ErrorsFound = true; - } else if (Alphas(5) != "YES") { // No validation done on the value of the interpolation field - FileIntervalInterpolated = false; - } else { - FileIntervalInterpolated = true; + + + if (!lAlphaBlanks(5)) { + if (BooleanSwitch bs = getYesNoValue(Alphas(5)); bs != BooleanSwitch::Invalid) { + FileIntervalInterpolated = static_cast(bs); + } else { + ShowSevereInvalidKey(state, eoh, cAlphaFields(5), Alphas(5)); + ErrorsFound = true; + } } - state.dataScheduleMgr->Schedule(SchNum).UseDaylightSaving = true; + sched->UseDaylightSaving = true; if ((Alphas(6)) == "NO") { - state.dataScheduleMgr->Schedule(SchNum).UseDaylightSaving = false; + sched->UseDaylightSaving = false; } // is it a sub-hourly schedule or not? - MinutesPerItem = 60; + int MinutesPerItem = 60; if (NumNumbers > 3) { MinutesPerItem = int(Numbers(4)); - NumExpectedItems = 1440 / MinutesPerItem; + // int NumExpectedItems = 1440 / MinutesPerItem; if (mod(60, MinutesPerItem) != 0) { - ShowSevereError(state, format("{}{}=\"{}", RoutineName, CurrentModuleObject, Alphas(1))); - ShowContinueError(state, format("Requested {} field value ({}) not evenly divisible into 60", cNumericFields(4), MinutesPerItem)); + ShowSevereCustom(state, eoh, format("Requested {} field value ({}) not evenly divisible into 60", cNumericFields(4), MinutesPerItem)); ErrorsFound = true; continue; } } - numHourlyValues = Numbers(3); - rowLimitCount = (Numbers(3) * 60.0) / MinutesPerItem; - hrLimitCount = 60 / MinutesPerItem; + int numHourlyValues = Numbers(3); + int rowLimitCount = (Numbers(3) * 60.0) / MinutesPerItem; + int hrLimitCount = 60 / MinutesPerItem; - std::string contextString = CurrentModuleObject + "=\"" + Alphas(1) + "\", " + cAlphaFields(3) + ": "; + std::string contextString = format("{}=\"{}\", {}: ", CurrentModuleObject, Alphas(1), cAlphaFields(3)); state.files.TempFullFilePath.filePath = CheckForActualFilePath(state, Alphas(3), contextString); // Setup file reading parameters if (state.files.TempFullFilePath.filePath.empty()) { ErrorsFound = true; } else { - auto result = state.dataScheduleMgr->UniqueProcessedExternalFiles.find(state.files.TempFullFilePath.filePath); - if (result == state.dataScheduleMgr->UniqueProcessedExternalFiles.end()) { + auto result = s_sched->UniqueProcessedExternalFiles.find(state.files.TempFullFilePath.filePath); + if (result == s_sched->UniqueProcessedExternalFiles.end()) { FileSystem::FileTypes const ext = FileSystem::getFileType(state.files.TempFullFilePath.filePath); if (FileSystem::is_flat_file_type(ext)) { auto const schedule_data = FileSystem::readFile(state.files.TempFullFilePath.filePath); CsvParser csvParser; - auto it = state.dataScheduleMgr->UniqueProcessedExternalFiles.emplace( + auto it = s_sched->UniqueProcessedExternalFiles.emplace( state.files.TempFullFilePath.filePath, csvParser.decode(schedule_data, ColumnSep, skiprowCount)); if (csvParser.hasErrors()) { for (const auto &[error, isContinued] : csvParser.errors()) { @@ -1810,17 +1608,11 @@ namespace ScheduleManager { } result = it.first; } else if (FileSystem::is_all_json_type(ext)) { - auto it = state.dataScheduleMgr->UniqueProcessedExternalFiles.emplace( + auto it = s_sched->UniqueProcessedExternalFiles.emplace( state.files.TempFullFilePath.filePath, FileSystem::readJSON(state.files.TempFullFilePath.filePath)); result = it.first; } else { - ShowSevereError(state, - fmt::format(R"({}{}="{}", {}="{}" has an unknown file extension and cannot be read by this program.)", - RoutineName, - CurrentModuleObject, - Alphas(1), - cAlphaFields(3), - Alphas(3))); + ShowSevereCustom(state, eoh, format("an unknown file extension and cannot be read by this program.)", cAlphaFields(3), Alphas(3))); ShowFatalError(state, "Program terminates due to previous condition."); } } @@ -1832,35 +1624,26 @@ namespace ScheduleManager { // schedule values have been filled into the hourlyFileValues array. if (numerrors > 0) { - ShowWarningError(state, - format("{}{}=\"{}\" {} records had errors - these values are set to 0.", - RoutineName, - CurrentModuleObject, - Alphas(1), - numerrors)); - ShowContinueError(state, "Use Output:Diagnostics,DisplayExtraWarnings; to see individual records in error."); + ShowWarningCustom(state, eoh, format("{} records had errors - these values are set to 0." + "Use Output:Diagnostics,DisplayExtraWarnings; to see individual records in error.", + numerrors)); } + if (rowCnt < rowLimitCount) { - ShowWarningError( - state, - format( - "{}{}=\"{}\" less than {} hourly values read from file.", RoutineName, CurrentModuleObject, Alphas(1), numHourlyValues)); - ShowContinueError(state, format("..Number read={}.", (rowCnt * 60) / MinutesPerItem)); + ShowWarningCustom(state, eoh, format("less than {} hourly values read from file." + "..Number read={}.", numHourlyValues, (rowCnt * 60) / MinutesPerItem)); } if (rowCnt < rowLimitCount) { - ShowWarningError( - state, format("{}{}=\"{}\" less than specified hourly values read from file.", RoutineName, CurrentModuleObject, Alphas(1))); - ShowContinueError(state, - format("..Specified Number of Hourly Values={} Actual number of hourly values included={}", - numHourlyValues, - (rowCnt * 60) / MinutesPerItem)); + ShowWarningCustom(state, eoh, format("less than specified hourly values read from file." + "..Specified Number of Hourly Values={} Actual number of hourly values included={}", + numHourlyValues, (rowCnt * 60) / MinutesPerItem)); } // process the data into the normal schedule data structures // note -- schedules are ALWAYS 366 days so some special measures have to be done at 29 Feb "day of year" (60) - iDay = 0; - hDay = 0; - ifld = 0; + int iDay = 0; + int hDay = 0; + int ifld = 0; while (true) { // create string of which day of year ++iDay; @@ -1868,55 +1651,65 @@ namespace ScheduleManager { if (iDay > 366) break; // increment both since a week schedule is being defined for each day so that a day is valid // no matter what the day type that is used in a design day. - ++AddWeekSch; - ++AddDaySch; + + // define day schedule + auto *daySched = AddDaySchedule(state, format("{}_dy_{}", Alphas(1), iDay)); + daySched->schedTypeNum = sched->schedTypeNum; + // define week schedule - state.dataScheduleMgr->WeekSchedule(AddWeekSch).Name = fmt::format("{}_wk_{}", Alphas(1), iDay); + auto *weekSched = AddWeekSchedule(state, format("{}_wk_{}", Alphas(1), iDay)); + // for all day types point the week schedule to the newly defined day schedule - for (kDayType = 1; kDayType <= maxDayTypes; ++kDayType) { - state.dataScheduleMgr->WeekSchedule(AddWeekSch).DaySchedulePointer(kDayType) = AddDaySch; + for (int kDayType = 1; kDayType < (int)DayType::Num; ++kDayType) { + weekSched->dayScheds[kDayType] = daySched; } - // day schedule - state.dataScheduleMgr->DaySchedule(AddDaySch).Name = fmt::format("{}_dy_{}", Alphas(1), iDay); - state.dataScheduleMgr->DaySchedule(AddDaySch).ScheduleTypePtr = state.dataScheduleMgr->Schedule(SchNum).ScheduleTypePtr; + // schedule is pointing to the week schedule - state.dataScheduleMgr->Schedule(SchNum).WeekSchedulePointer(iDay) = AddWeekSch; + sched->weekScheds[iDay] = weekSched; + if (MinutesPerItem == 60) { - for (jHour = 1; jHour <= 24; ++jHour) { - curHrVal = column_values[ifld]; // hourlyFileValues((hDay - 1) * 24 + jHour) + for (int hr = 0; hr < Constant::iHoursInDay; ++hr) { + Real64 curHrVal = column_values[ifld]; // hourlyFileValues((hDay - 1) * 24 + jHour) ++ifld; - for (TS = 1; TS <= state.dataGlobal->NumOfTimeStepInHour; ++TS) { - state.dataScheduleMgr->DaySchedule(AddDaySch).TSValue(TS, jHour) = curHrVal; + for (int ts = 0; ts < s_glob->TimeStepsInHour; ++ts) { + daySched->tsVals[hr * s_glob->TimeStepsInHour + ts] = curHrVal; + daySched->sumTsVals += daySched->tsVals[hr * s_glob->TimeStepsInHour + ts]; } } } else { // Minutes Per Item < 60 - for (Hr = 1; Hr <= 24; ++Hr) { - CurMinute = MinutesPerItem; - SCount = 1; - for (NumFields = 1; NumFields <= hrLimitCount; ++NumFields) { - MinuteValue({SCount, CurMinute}, Hr) = column_values[ifld]; + for (int hr = 0; hr < Constant::iHoursInDay; ++hr) { + int endMinute = MinutesPerItem - 1; + int begMinute = 0; + for (int NumFields = 1; NumFields <= hrLimitCount; ++NumFields) { + std::fill(&minuteVals[hr * Constant::iMinutesInHour + begMinute], + &minuteVals[hr * Constant::iMinutesInHour + endMinute], + column_values[ifld]); ++ifld; - SCount = CurMinute + 1; - CurMinute += MinutesPerItem; + begMinute = endMinute + 1; + endMinute += MinutesPerItem; } } if (FileIntervalInterpolated) { - for (Hr = 1; Hr <= 24; ++Hr) { - SCount = 1; - CurMinute = state.dataGlobal->MinutesPerTimeStep; - for (TS = 1; TS <= state.dataGlobal->NumOfTimeStepInHour; ++TS) { - state.dataScheduleMgr->DaySchedule(AddDaySch).TSValue(TS, Hr) = - sum(MinuteValue({SCount, CurMinute}, Hr)) / double(state.dataGlobal->MinutesPerTimeStep); - SCount = CurMinute + 1; - CurMinute += state.dataGlobal->MinutesPerTimeStep; + for (int hr = 0; hr < Constant::iHoursInDay; ++hr) { + int begMinute = 0; + int endMinute = s_glob->MinutesInTimeStep - 1; + for (int ts = 0; ts < s_glob->TimeStepsInHour; ++ts) { + daySched->tsVals[hr * s_glob->TimeStepsInHour + ts] = + std::accumulate(minuteVals.begin() + (hr * Constant::iMinutesInHour + begMinute), + minuteVals.begin() + (hr * Constant::iMinutesInHour + endMinute), + 0) / double(s_glob->MinutesInTimeStep); + daySched->sumTsVals += daySched->tsVals[hr * s_glob->TimeStepsInHour + ts]; + begMinute = endMinute + 1; + endMinute += s_glob->MinutesInTimeStep; } } } else { - for (Hr = 1; Hr <= 24; ++Hr) { - CurMinute = state.dataGlobal->MinutesPerTimeStep; - for (TS = 1; TS <= state.dataGlobal->NumOfTimeStepInHour; ++TS) { - state.dataScheduleMgr->DaySchedule(AddDaySch).TSValue(TS, Hr) = MinuteValue(CurMinute, Hr); - CurMinute += state.dataGlobal->MinutesPerTimeStep; + for (int hr = 0; hr < Constant::iHoursInDay; ++hr) { + int curMinute = s_glob->MinutesInTimeStep - 1; + for (int ts = 0; ts < s_glob->TimeStepsInHour; ++ts) { + daySched->tsVals[hr * s_glob->TimeStepsInHour + ts] = minuteVals[hr * Constant::iMinutesInHour + curMinute]; + daySched->sumTsVals += daySched->tsVals[hr * s_glob->TimeStepsInHour + ts]; + curMinute += s_glob->MinutesInTimeStep; } } } @@ -1924,20 +1717,19 @@ namespace ScheduleManager { if (iDay == 59 && rowCnt < 8784 * hrLimitCount) { // 28 Feb // Dup 28 Feb to 29 Feb (60) ++iDay; - state.dataScheduleMgr->Schedule(SchNum).WeekSchedulePointer(iDay) = - state.dataScheduleMgr->Schedule(SchNum).WeekSchedulePointer(iDay - 1); + sched->weekScheds[iDay] = sched->weekScheds[iDay - 1]; } } } - if (state.dataGlobal->AnyEnergyManagementSystemInModel) { // setup constant schedules as actuators + if (s_glob->AnyEnergyManagementSystemInModel) { // setup constant schedules as actuators SetupEMSActuator(state, "Schedule:File", - state.dataScheduleMgr->Schedule(SchNum).Name, + sched->Name, "Schedule Value", "[ ]", - state.dataScheduleMgr->Schedule(SchNum).EMSActuatedOn, - state.dataScheduleMgr->Schedule(SchNum).EMSValue); + sched->EMSActuatedOn, + sched->EMSVal); } } @@ -1955,394 +1747,332 @@ namespace ScheduleManager { if (column == 0) continue; // Skip timestamp column and any duplicate column, which will be 0 as well since it won't be found. auto const column_values = values_json.at(column).get>(); // (AUTO_OK_OBJ) - std::string curName = fmt::format("{}_shading", header); - GlobalNames::VerifyUniqueInterObjectName( - state, state.dataScheduleMgr->UniqueScheduleNames, curName, CurrentModuleObject, cAlphaFields(1), ErrorsFound); - ++SchNum; - state.dataScheduleMgr->Schedule(SchNum).Name = curName; - state.dataScheduleMgr->Schedule(SchNum).SchType = SchedType::ScheduleInput_file; + std::string curName = format("{}_shading", header); + std::string curNameUC = Util::makeUPPER(curName); - iDay = 0; - ifld = 0; + if (s_sched->scheduleMap.find(curNameUC) != s_sched->scheduleMap.end()) { + ShowSevereError(state, format("Duplicate schedule name {}", curName)); + ErrorsFound = true; + continue; + } + + auto *schedShading = AddScheduleDetailed(state, curName); + schedShading->type = SchedType::File; + + int iDay = 0; + int ifld = 0; while (true) { // create string of which day of year ++iDay; if (iDay > 366) { break; } - // increment both since a week schedule is being defined for each day so that a day is valid - // no matter what the day type that is used in a design day. - ++AddWeekSch; - ++AddDaySch; + + // day schedule + auto *daySched = AddDaySchedule(state, format("{}_dy_{}", curName, iDay)); + daySched->schedTypeNum = schedShading->schedTypeNum; + // define week schedule - state.dataScheduleMgr->WeekSchedule(AddWeekSch).Name = fmt::format("{}_wk_{}", curName, iDay); + auto *weekSched = AddWeekSchedule(state, format("{}_wk_{}", curName, iDay)); + // for all day types point the week schedule to the newly defined day schedule - for (kDayType = 1; kDayType <= maxDayTypes; ++kDayType) { - state.dataScheduleMgr->WeekSchedule(AddWeekSch).DaySchedulePointer(kDayType) = AddDaySch; + for (int kDayType = 1; kDayType < (int)DayType::Num; ++kDayType) { + weekSched->dayScheds[kDayType] = daySched; } - // day schedule - state.dataScheduleMgr->DaySchedule(AddDaySch).Name = fmt::format("{}_dy_{}", curName, iDay); - state.dataScheduleMgr->DaySchedule(AddDaySch).ScheduleTypePtr = state.dataScheduleMgr->Schedule(SchNum).ScheduleTypePtr; + // schedule is pointing to the week schedule - state.dataScheduleMgr->Schedule(SchNum).WeekSchedulePointer(iDay) = AddWeekSch; + schedShading->weekScheds[iDay] = weekSched; - for (jHour = 1; jHour <= 24; ++jHour) { - for (TS = 1; TS <= state.dataGlobal->NumOfTimeStepInHour; ++TS) { - state.dataScheduleMgr->DaySchedule(AddDaySch).TSValue(TS, jHour) = column_values[ifld]; + for (int hr = 0; hr < Constant::iHoursInDay; ++hr) { + for (int ts = 0; ts < s_glob->TimeStepsInHour; ++ts) { + daySched->tsVals[hr * s_glob->TimeStepsInHour + ts] = column_values[ifld]; ++ifld; } } + if (iDay == 59 && !state.dataEnvrn->CurrentYearIsLeapYear) { // 28 Feb // Dup 28 Feb to 29 Feb (60) ++iDay; - state.dataScheduleMgr->Schedule(SchNum).WeekSchedulePointer(iDay) = - state.dataScheduleMgr->Schedule(SchNum).WeekSchedulePointer(iDay - 1); + schedShading->weekScheds[iDay] = schedShading->weekScheds[iDay - 1]; } } } } - MinuteValue.deallocate(); - SetMinuteValue.deallocate(); - // Constant Schedules CurrentModuleObject = "Schedule:Constant"; - for (LoopIndex = 1; LoopIndex <= NumConstantSchedules; ++LoopIndex) { - state.dataInputProcessing->inputProcessor->getObjectItem(state, - CurrentModuleObject, - LoopIndex, - Alphas, - NumAlphas, - Numbers, - NumNumbers, - Status, - lNumericBlanks, - lAlphaBlanks, - cAlphaFields, - cNumericFields); - GlobalNames::VerifyUniqueInterObjectName( - state, state.dataScheduleMgr->UniqueScheduleNames, Alphas(1), CurrentModuleObject, cAlphaFields(1), ErrorsFound); - ++SchNum; - state.dataScheduleMgr->Schedule(SchNum).Name = Alphas(1); - state.dataScheduleMgr->Schedule(SchNum).SchType = SchedType::ScheduleInput_constant; + for (int Loop = 1; Loop <= NumConstantSchedules; ++Loop) { + s_ip->getObjectItem(state, + CurrentModuleObject, + Loop, + Alphas, + NumAlphas, + Numbers, + NumNumbers, + Status, + lNumericBlanks, + lAlphaBlanks, + cAlphaFields, + cNumericFields); + + ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)}; + + if (s_sched->scheduleMap.find(Alphas(1)) != s_sched->scheduleMap.end()) { + ShowSevereDuplicateName(state, eoh); + ErrorsFound = true; + continue; + } + + auto *sched = AddScheduleConstant(state, Alphas(1)); + // Validate ScheduleType - if (state.dataScheduleMgr->NumScheduleTypes > 0) { - CheckIndex = Util::FindItemInList(Alphas(2), state.dataScheduleMgr->ScheduleType({1, state.dataScheduleMgr->NumScheduleTypes})); - if (CheckIndex == 0) { - if (!lAlphaBlanks(2)) { - ShowWarningError(state, - format("{}{}=\"{}\", {}=\"{}\" not found -- will not be validated", - RoutineName, - CurrentModuleObject, - Alphas(1), - cAlphaFields(2), - Alphas(2))); - } else { - ShowWarningError(state, - format("{}{}=\"{}\", Blank {} input -- will not be validated.", - RoutineName, - CurrentModuleObject, - Alphas(1), - cAlphaFields(2))); - } - } else { - state.dataScheduleMgr->Schedule(SchNum).ScheduleTypePtr = CheckIndex; - } + if (lAlphaBlanks(2)) { // No warning here for constant schedules + } else if ((sched->schedTypeNum = GetScheduleTypeNum(state, Alphas(2))) == SchedNum_Invalid) { + ShowWarningItemNotFound(state, eoh, cAlphaFields(2), Alphas(2)); + ShowContinueError(state, "Schedule will not be validated."); + } - ++AddWeekSch; - ++AddDaySch; - // define week schedule - state.dataScheduleMgr->WeekSchedule(AddWeekSch).Name = Alphas(1) + "_wk_"; - // for all day types point the week schedule to the newly defined day schedule - for (kDayType = 1; kDayType <= maxDayTypes; ++kDayType) { - state.dataScheduleMgr->WeekSchedule(AddWeekSch).DaySchedulePointer(kDayType) = AddDaySch; - } - // day schedule - state.dataScheduleMgr->DaySchedule(AddDaySch).Name = Alphas(1) + "_dy_"; - state.dataScheduleMgr->DaySchedule(AddDaySch).ScheduleTypePtr = state.dataScheduleMgr->Schedule(SchNum).ScheduleTypePtr; - // schedule is pointing to the week schedule - state.dataScheduleMgr->Schedule(SchNum).WeekSchedulePointer = AddWeekSch; - curHrVal = Numbers(1); - state.dataScheduleMgr->DaySchedule(AddDaySch).TSValue = Numbers(1); - - if (state.dataGlobal->AnyEnergyManagementSystemInModel) { // setup constant schedules as actuators + + sched->currentVal = Numbers(1); + sched->tsVals.resize(Constant::iHoursInDay * s_glob->TimeStepsInHour); + for (int i = 0; i < Constant::iHoursInDay * s_glob->TimeStepsInHour; ++i) sched->tsVals[i] = sched->currentVal; + + if (s_glob->AnyEnergyManagementSystemInModel) { // setup constant schedules as actuators SetupEMSActuator(state, "Schedule:Constant", - state.dataScheduleMgr->Schedule(SchNum).Name, + sched->Name, "Schedule Value", "[ ]", - state.dataScheduleMgr->Schedule(SchNum).EMSActuatedOn, - state.dataScheduleMgr->Schedule(SchNum).EMSValue); + sched->EMSActuatedOn, + sched->EMSVal); } } CurrentModuleObject = "ExternalInterface:Schedule"; - for (LoopIndex = 1; LoopIndex <= NumExternalInterfaceSchedules; ++LoopIndex) { - - state.dataInputProcessing->inputProcessor->getObjectItem(state, - CurrentModuleObject, - LoopIndex, - Alphas, - NumAlphas, - Numbers, - NumNumbers, - Status, - lNumericBlanks, - lAlphaBlanks, - cAlphaFields, - cNumericFields); - GlobalNames::VerifyUniqueInterObjectName( - state, state.dataScheduleMgr->UniqueScheduleNames, Alphas(1), CurrentModuleObject, cAlphaFields(1), ErrorsFound); - ++SchNum; - state.dataScheduleMgr->Schedule(SchNum).Name = Alphas(1); - state.dataScheduleMgr->Schedule(SchNum).SchType = SchedType::ScheduleInput_external; + for (int Loop = 1; Loop <= NumExternalInterfaceSchedules; ++Loop) { + s_ip->getObjectItem(state, + CurrentModuleObject, + Loop, + Alphas, + NumAlphas, + Numbers, + NumNumbers, + Status, + lNumericBlanks, + lAlphaBlanks, + cAlphaFields, + cNumericFields); + + ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)}; + + if (s_sched->scheduleMap.find(Alphas(1)) != s_sched->scheduleMap.end()) { + ShowSevereDuplicateName(state, eoh); + ErrorsFound = true; + continue; + } + + auto *sched = AddScheduleDetailed(state, Alphas(1)); + sched->type = SchedType::External; // Validate ScheduleType - CheckIndex = Util::FindItemInList(Alphas(2), state.dataScheduleMgr->ScheduleType({1, state.dataScheduleMgr->NumScheduleTypes})); - if (CheckIndex == 0) { - if (!lAlphaBlanks(2)) { - ShowWarningError(state, - format("{}{}=\"{}\", {}=\"{}\" not found -- will not be validated", - RoutineName, - CurrentModuleObject, - Alphas(1), - cAlphaFields(2), - Alphas(2))); - } else { - ShowWarningError( - state, - format( - "{}{}=\"{}\", Blank {} input -- will not be validated.", RoutineName, CurrentModuleObject, Alphas(1), cAlphaFields(2))); - } - } else { - state.dataScheduleMgr->Schedule(SchNum).ScheduleTypePtr = CheckIndex; - } - ++AddWeekSch; - state.dataScheduleMgr->WeekSchedule(AddWeekSch).Name = Alphas(1); - state.dataScheduleMgr->WeekSchedule(AddWeekSch).Used = true; - for (Hr = 1; Hr <= 366; ++Hr) { - state.dataScheduleMgr->Schedule(SchNum).WeekSchedulePointer(Hr) = AddWeekSch; - } - ++AddDaySch; - state.dataScheduleMgr->DaySchedule(AddDaySch).Name = Alphas(1); - state.dataScheduleMgr->DaySchedule(AddDaySch).ScheduleTypePtr = state.dataScheduleMgr->Schedule(SchNum).ScheduleTypePtr; - state.dataScheduleMgr->DaySchedule(AddDaySch).Used = true; - for (Hr = 1; Hr <= maxDayTypes; ++Hr) { - state.dataScheduleMgr->WeekSchedule(AddWeekSch).DaySchedulePointer(Hr) = AddDaySch; - } + if (lAlphaBlanks(2)) { + } else if ((sched->schedTypeNum = GetScheduleTypeNum(state, Alphas(2))) == SchedNum_Invalid) { + ShowWarningItemNotFound(state, eoh, cAlphaFields(2), Alphas(2)); + ShowContinueError(state, "Schedule will not be validated."); + } + + // TODO: I'm not sure this Jazz is necessary + // Add day schedule + auto *daySched = AddDaySchedule(state, format("{}_xi_dy_", Alphas(1))); + daySched->isUsed = true; + daySched->schedTypeNum = sched->schedTypeNum; + // Initialize the ExternalInterface day schedule for the ExternalInterface compact schedule. // It will be overwritten during run time stepping after the warm up period if (NumNumbers < 1) { - ShowWarningError( - state, - format("{}{}=\"{}\", initial value is not numeric or is missing. Fix idf file.", RoutineName, CurrentModuleObject, Alphas(1))); + ShowWarningCustom(state, eoh, "Initial value is not numeric or is missing. Fix idf file."); NumErrorFlag = true; } - ExternalInterfaceSetSchedule(state, AddDaySch, Numbers(1)); - } + ExternalInterfaceSetSchedule(state, daySched->Num, Numbers(1)); + + auto *weekSched = AddWeekSchedule(state, format("{}_xi_wk_", Alphas(1))); + weekSched->isUsed = true; + for (int iDayType = 1; iDayType < (int)DayType::Num; ++iDayType) { + weekSched->dayScheds[iDayType] = daySched; + } + + for (int iDay = 1; iDay <= 366; ++iDay) { + sched->weekScheds[iDay] = weekSched; + } + } // for (Loop) + // added for FMU Import CurrentModuleObject = "ExternalInterface:FunctionalMockupUnitImport:To:Schedule"; - for (LoopIndex = 1; LoopIndex <= NumExternalInterfaceFunctionalMockupUnitImportSchedules; ++LoopIndex) { - - state.dataInputProcessing->inputProcessor->getObjectItem(state, - CurrentModuleObject, - LoopIndex, - Alphas, - NumAlphas, - Numbers, - NumNumbers, - Status, - lNumericBlanks, - lAlphaBlanks, - cAlphaFields, - cNumericFields); - - if (NumExternalInterfaceSchedules >= 1) { - GlobalNames::VerifyUniqueInterObjectName( - state, - state.dataScheduleMgr->UniqueScheduleNames, - Alphas(1), - CurrentModuleObject, - cAlphaFields(1) + "(defined as an ExternalInterface:Schedule and ExternalInterface:FunctionalMockupUnitImport:To:Schedule. This " - "will cause the schedule to be overwritten by PtolemyServer and FunctionalMockUpUnitImport)", - ErrorsFound); - } else { - GlobalNames::VerifyUniqueInterObjectName( - state, state.dataScheduleMgr->UniqueScheduleNames, Alphas(1), CurrentModuleObject, cAlphaFields(1), ErrorsFound); - } - ++SchNum; - state.dataScheduleMgr->Schedule(SchNum).Name = Alphas(1); - state.dataScheduleMgr->Schedule(SchNum).SchType = SchedType::ScheduleInput_external; + for (int Loop = 1; Loop <= NumExternalInterfaceFunctionalMockupUnitImportSchedules; ++Loop) { + s_ip->getObjectItem(state, + CurrentModuleObject, + Loop, + Alphas, + NumAlphas, + Numbers, + NumNumbers, + Status, + lNumericBlanks, + lAlphaBlanks, + cAlphaFields, + cNumericFields); + + ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)}; + + if (s_sched->scheduleMap.find(Alphas(1)) != s_sched->scheduleMap.end()) { + ShowSevereDuplicateName(state, eoh); + if (NumExternalInterfaceSchedules >= 1) { + ShowContinueError(state, + format("{} defined as an ExternalInterface:Schedule and ExternalInterface:FunctionalMockupUnitImport:To:Schedule." + "This will cause the schedule to be overwritten by PtolemyServer and FunctionalMockUpUnitImport)", + cAlphaFields(1))); - // Validate ScheduleType - CheckIndex = Util::FindItemInList(Alphas(2), state.dataScheduleMgr->ScheduleType({1, state.dataScheduleMgr->NumScheduleTypes})); - if (CheckIndex == 0) { - if (!lAlphaBlanks(2)) { - ShowWarningError(state, - format("{}{}=\"{}\", {}=\"{}\" not found -- will not be validated", - RoutineName, - CurrentModuleObject, - Alphas(1), - cAlphaFields(2), - Alphas(2))); - } else { - ShowWarningError( - state, - format( - "{}{}=\"{}\", Blank {} input -- will not be validated.", RoutineName, CurrentModuleObject, Alphas(1), cAlphaFields(2))); } - } else { - state.dataScheduleMgr->Schedule(SchNum).ScheduleTypePtr = CheckIndex; - } - ++AddWeekSch; - state.dataScheduleMgr->WeekSchedule(AddWeekSch).Name = Alphas(1); - state.dataScheduleMgr->WeekSchedule(AddWeekSch).Used = true; - for (Hr = 1; Hr <= 366; ++Hr) { - state.dataScheduleMgr->Schedule(SchNum).WeekSchedulePointer(Hr) = AddWeekSch; - } - ++AddDaySch; - state.dataScheduleMgr->DaySchedule(AddDaySch).Name = Alphas(1); - state.dataScheduleMgr->DaySchedule(AddDaySch).ScheduleTypePtr = state.dataScheduleMgr->Schedule(SchNum).ScheduleTypePtr; - state.dataScheduleMgr->DaySchedule(AddDaySch).Used = true; - for (Hr = 1; Hr <= maxDayTypes; ++Hr) { - state.dataScheduleMgr->WeekSchedule(AddWeekSch).DaySchedulePointer(Hr) = AddDaySch; + ErrorsFound = true; + continue; } + + auto *sched = AddScheduleDetailed(state, Alphas(1)); + sched->type = SchedType::External; + + // Validate ScheduleType + if (lAlphaBlanks(2)) { + } else if ((sched->schedTypeNum = GetScheduleTypeNum(state, Alphas(2))) == SchedNum_Invalid) { + ShowWarningItemNotFound(state, eoh, cAlphaFields(2), Alphas(2)); + ShowContinueError(state, "Schedule will not be validated."); + } + + // TODO: I'm not sure this Jazz is necessary + // Add day schedule + auto *daySched = AddDaySchedule(state, format("{}_xi_dy_", Alphas(1))); + daySched->isUsed = true; + daySched->schedTypeNum = sched->schedTypeNum; + // Initialize the ExternalInterface day schedule for the ExternalInterface compact schedule. // It will be overwritten during run time stepping after the warm up period if (NumNumbers < 1) { - ShowWarningError( - state, - format("{}{}=\"{}\", initial value is not numeric or is missing. Fix idf file.", RoutineName, CurrentModuleObject, Alphas(1))); + ShowWarningCustom(state, eoh, "Initial value is not numeric or is missing. Fix idf file."); NumErrorFlag = true; } - ExternalInterfaceSetSchedule(state, AddDaySch, Numbers(1)); + ExternalInterfaceSetSchedule(state, daySched->Num, Numbers(1)); + + auto *weekSched = AddWeekSchedule(state, format("{}_xi_wk_", Alphas(1))); + weekSched->isUsed = true; + for (int iDayType = 1; iDayType < (int)DayType::Num; ++iDayType) { + weekSched->dayScheds[iDayType] = daySched; + } + + for (int iDay = 1; iDay <= 366; ++iDay) { + sched->weekScheds[iDay] = weekSched; + } } // added for FMU Export CurrentModuleObject = "ExternalInterface:FunctionalMockupUnitExport:To:Schedule"; - for (LoopIndex = 1; LoopIndex <= NumExternalInterfaceFunctionalMockupUnitExportSchedules; ++LoopIndex) { - state.dataInputProcessing->inputProcessor->getObjectItem(state, - CurrentModuleObject, - LoopIndex, - Alphas, - NumAlphas, - Numbers, - NumNumbers, - Status, - lNumericBlanks, - lAlphaBlanks, - cAlphaFields, - cNumericFields); - - if (NumExternalInterfaceSchedules >= 1) { - GlobalNames::VerifyUniqueInterObjectName( - state, - state.dataScheduleMgr->UniqueScheduleNames, - Alphas(1), - CurrentModuleObject, - cAlphaFields(1) + "(defined as an ExternalInterface:Schedule and ExternalInterface:FunctionalMockupUnitExport:To:Schedule. This " - "will cause the schedule to be overwritten by PtolemyServer and FunctionalMockUpUnitExport)", - ErrorsFound); - } else { - GlobalNames::VerifyUniqueInterObjectName( - state, state.dataScheduleMgr->UniqueScheduleNames, Alphas(1), CurrentModuleObject, cAlphaFields(1), ErrorsFound); - } - - ++SchNum; - state.dataScheduleMgr->Schedule(SchNum).Name = Alphas(1); - state.dataScheduleMgr->Schedule(SchNum).SchType = SchedType::ScheduleInput_external; + for (int Loop = 1; Loop <= NumExternalInterfaceFunctionalMockupUnitExportSchedules; ++Loop) { + s_ip->getObjectItem(state, + CurrentModuleObject, + Loop, + Alphas, + NumAlphas, + Numbers, + NumNumbers, + Status, + lNumericBlanks, + lAlphaBlanks, + cAlphaFields, + cNumericFields); + + ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)}; + + if (s_sched->scheduleMap.find(Alphas(1)) != s_sched->scheduleMap.end()) { + ShowSevereDuplicateName(state, eoh); + if (NumExternalInterfaceSchedules >= 1) { + ShowContinueError(state, + format("{} defined as an ExternalInterface:Schedule and ExternalInterface:FunctionalMockupUnitImport:To:Schedule." + "This will cause the schedule to be overwritten by PtolemyServer and FunctionalMockUpUnitImport)", + cAlphaFields(1))); - // Validate ScheduleType - CheckIndex = Util::FindItemInList(Alphas(2), state.dataScheduleMgr->ScheduleType({1, state.dataScheduleMgr->NumScheduleTypes})); - if (CheckIndex == 0) { - if (!lAlphaBlanks(2)) { - ShowWarningError(state, - format("{}{}=\"{}\", {}=\"{}\" not found -- will not be validated", - RoutineName, - CurrentModuleObject, - Alphas(1), - cAlphaFields(2), - Alphas(2))); - } else { - ShowWarningError( - state, - format( - "{}{}=\"{}\", Blank {} input -- will not be validated.", RoutineName, CurrentModuleObject, Alphas(1), cAlphaFields(2))); } - } else { - state.dataScheduleMgr->Schedule(SchNum).ScheduleTypePtr = CheckIndex; - } - ++AddWeekSch; - state.dataScheduleMgr->WeekSchedule(AddWeekSch).Name = Alphas(1); - state.dataScheduleMgr->WeekSchedule(AddWeekSch).Used = true; - for (Hr = 1; Hr <= 366; ++Hr) { - state.dataScheduleMgr->Schedule(SchNum).WeekSchedulePointer(Hr) = AddWeekSch; - } - ++AddDaySch; - state.dataScheduleMgr->DaySchedule(AddDaySch).Name = Alphas(1); - state.dataScheduleMgr->DaySchedule(AddDaySch).ScheduleTypePtr = state.dataScheduleMgr->Schedule(SchNum).ScheduleTypePtr; - state.dataScheduleMgr->DaySchedule(AddDaySch).Used = true; - for (Hr = 1; Hr <= maxDayTypes; ++Hr) { - state.dataScheduleMgr->WeekSchedule(AddWeekSch).DaySchedulePointer(Hr) = AddDaySch; + ErrorsFound = true; + continue; } + + auto *sched = AddScheduleDetailed(state, Alphas(1)); + sched->type = SchedType::External; + + // Validate ScheduleType + if (lAlphaBlanks(2)) { + } else if ((sched->schedTypeNum = GetScheduleTypeNum(state, Alphas(2))) == SchedNum_Invalid) { + ShowWarningItemNotFound(state, eoh, cAlphaFields(2), Alphas(2)); + ShowContinueError(state, "Schedule will not be validated."); + } + + // TODO: I'm not sure this Jazz is necessary + // Add day schedule + auto *daySched = AddDaySchedule(state, format("{}_xi_dy_", Alphas(1))); + daySched->isUsed = true; + daySched->schedTypeNum = sched->schedTypeNum; + // Initialize the ExternalInterface day schedule for the ExternalInterface compact schedule. // It will be overwritten during run time stepping after the warm up period if (NumNumbers < 1) { - ShowWarningError( - state, - format("{}{}=\"{}\", initial value is not numeric or is missing. Fix idf file.", RoutineName, CurrentModuleObject, Alphas(1))); + ShowWarningCustom(state, eoh, "Initial value is not numeric or is missing. Fix idf file."); NumErrorFlag = true; } - ExternalInterfaceSetSchedule(state, AddDaySch, Numbers(1)); - } + ExternalInterfaceSetSchedule(state, daySched->Num, Numbers(1)); + + auto *weekSched = AddWeekSchedule(state, format("{}_xi_wk_", Alphas(1))); + weekSched->isUsed = true; + for (int iDayType = 1; iDayType < (int)DayType::Num; ++iDayType) { + weekSched->dayScheds[iDayType] = daySched; + } + + std::fill(sched->weekScheds.begin()+1, sched->weekScheds.end(), weekSched); + } // for (Loop) + // Validate by ScheduleLimitsType - for (SchNum = 1; SchNum <= state.dataScheduleMgr->NumSchedules; ++SchNum) { - NumPointer = state.dataScheduleMgr->Schedule(SchNum).ScheduleTypePtr; - if (!state.dataScheduleMgr->ScheduleType(NumPointer).Limited) continue; - if (CheckScheduleValueMinMax(state, - SchNum, - ">=", - state.dataScheduleMgr->ScheduleType(NumPointer).Minimum, - "<=", - state.dataScheduleMgr->ScheduleType(NumPointer).Maximum)) - continue; - ShowSevereError(state, - format("{}Schedule=\"{}\" has values outside its Schedule Type ({}) range", - RoutineName, - state.dataScheduleMgr->Schedule(SchNum).Name, - state.dataScheduleMgr->ScheduleType(NumPointer).Name)); - ShowContinueError(state, - format(" Minimum should be >={:.3R} and Maximum should be <={:.3R}", - state.dataScheduleMgr->ScheduleType(NumPointer).Minimum, - state.dataScheduleMgr->ScheduleType(NumPointer).Maximum)); - ErrorsFound = true; + for (auto *sched : s_sched->schedules) { + + if (sched->schedTypeNum == SchedNum_Invalid) continue; + + auto const *schedType = s_sched->scheduleTypes[sched->schedTypeNum]; + if (!schedType->isLimited) continue; + + if (!sched->checkMinMaxVals(state, Clusive::In, schedType->minVal, Clusive::In, schedType->maxVal)) { + ErrorObjectHeader eoh{routineName, "Schedule", sched->Name}; + ShowSevereBadMinMax(state, eoh, "", "", Clusive::In, schedType->minVal, Clusive::In, schedType->maxVal); + ErrorsFound = true; + } } if (ErrorsFound) { - ShowFatalError(state, format("{}Preceding Errors cause termination.", RoutineName)); + ShowFatalError(state, format("{}: Preceding Errors cause termination.", routineName)); } - if (state.dataScheduleMgr->NumScheduleTypes + state.dataScheduleMgr->NumDaySchedules + state.dataScheduleMgr->NumWeekSchedules + - state.dataScheduleMgr->NumSchedules > - 0) { // Report to EIO file + if (s_sched->scheduleTypes.size() + s_sched->daySchedules.size() + s_sched->weekSchedules.size() + s_sched->schedules.size() > 0) { CurrentModuleObject = "Output:Schedules"; - NumFields = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject); + NumFields = s_ip->getNumObjectsFound(state, CurrentModuleObject); // RptSchedule=.FALSE. RptLevel = 1; - for (Count = 1; Count <= NumFields; ++Count) { - state.dataInputProcessing->inputProcessor->getObjectItem( - state, CurrentModuleObject, Count, Alphas, NumAlphas, Numbers, NumNumbers, Status); + for (int Count = 1; Count <= NumFields; ++Count) { + s_ip->getObjectItem(state, CurrentModuleObject, Count, Alphas, NumAlphas, Numbers, NumNumbers, Status); // RptSchedule=.TRUE. + ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)}; + // IDD only allows Hourly or Timestep as valid values on the required field, anything else should be an error in the input processor - OutputReportLevel reportLevel = - static_cast(getEnumValue(outputScheduleReportLevelNamesUC, Alphas(1))); // NOLINT(modernize-use-auto) - if (reportLevel == OutputReportLevel::Invalid) { - ShowWarningError(state, format("{}Report for Schedules should specify \"HOURLY\" or \"TIMESTEP\" (\"DETAILED\")", RoutineName)); - ShowContinueError(state, "HOURLY report will be done"); - reportLevel = OutputReportLevel::Hourly; + ReportLevel reportLevel = static_cast(getEnumValue(reportLevelNamesUC, Alphas(1))); + if (reportLevel == ReportLevel::Invalid) { + ShowWarningInvalidKey(state, eoh, cAlphaFields(1), Alphas(1), "HOURLY report will be done"); + reportLevel = ReportLevel::Hourly; } ReportScheduleDetails(state, reportLevel); } @@ -2356,16 +2086,15 @@ namespace ScheduleManager { lNumericBlanks.deallocate(); print(state.files.audit, "{}\n", " Processing Schedule Input -- Complete"); - } + } // ProcessScheduleInput() void ReportScheduleDetails(EnergyPlusData &state, - OutputReportLevel const LevelOfDetail) // =1: hourly; =2: timestep; = 3: make IDF excerpt + ReportLevel const LevelOfDetail) // =1: hourly; =2: timestep; = 3: make IDF excerpt { // SUBROUTINE INFORMATION: // AUTHOR Linda K. Lawrie // DATE WRITTEN January 2003 // MODIFIED February 2008 - add IDF outputs (compact schedules) - // RE-ENGINEERED na // PURPOSE OF THIS SUBROUTINE: // This subroutine puts the details of the Schedules on the .eio file (Inits file). @@ -2388,32 +2117,35 @@ namespace ScheduleManager { Array2D_string RoundTSValue; std::string_view constexpr SchDFmtdata{",{}"}; - ShowMinute.allocate(state.dataGlobal->NumOfTimeStepInHour); - TimeHHMM.allocate(state.dataGlobal->NumOfTimeStepInHour * 24); - RoundTSValue.allocate(state.dataGlobal->NumOfTimeStepInHour, 24); + auto const &s_glob = state.dataGlobal; + auto const &s_sched = state.dataSched; + + ShowMinute.allocate(s_glob->TimeStepsInHour); + TimeHHMM.allocate(s_glob->TimeStepsInHour * Constant::iHoursInDay); + RoundTSValue.allocate(s_glob->TimeStepsInHour, Constant::iHoursInDay); ShowMinute = std::string{}; TimeHHMM = std::string{}; RoundTSValue = std::string{}; - int CurMinute = state.dataGlobal->MinutesPerTimeStep; - for (int Count = 1; Count <= state.dataGlobal->NumOfTimeStepInHour - 1; ++Count) { + int CurMinute = s_glob->MinutesInTimeStep; + for (int Count = 1; Count <= s_glob->TimeStepsInHour - 1; ++Count) { ShowMinute(Count) = format("{:02}", CurMinute); - CurMinute += state.dataGlobal->MinutesPerTimeStep; + CurMinute += s_glob->MinutesInTimeStep; } - ShowMinute(state.dataGlobal->NumOfTimeStepInHour) = "00"; + ShowMinute(s_glob->TimeStepsInHour) = "00"; switch (LevelOfDetail) { - case OutputReportLevel::Hourly: - case OutputReportLevel::TimeStep: + case ReportLevel::Hourly: + case ReportLevel::TimeStep: { NumF = 1; - for (int Hr = 1; Hr <= 24; ++Hr) { - if (LevelOfDetail == OutputReportLevel::TimeStep) { - for (int TS = 1; TS <= state.dataGlobal->NumOfTimeStepInHour - 1; ++TS) { - TimeHHMM(NumF) = format("{}:{}", HrField[Hr - 1], ShowMinute(TS)); + for (int hr = 0; hr < Constant::iHoursInDay; ++hr) { + if (LevelOfDetail == ReportLevel::TimeStep) { + for (int ts = 0; ts < s_glob->TimeStepsInHour - 1; ++ts) { + TimeHHMM(NumF) = format("{}:{}", HrField[hr], ShowMinute(ts)); ++NumF; } } - TimeHHMM(NumF) = format("{}:{}", HrField[Hr], ShowMinute(state.dataGlobal->NumOfTimeStepInHour)); + TimeHHMM(NumF) = format("{}:{}", HrField[hr], ShowMinute(s_glob->TimeStepsInHour)); ++NumF; } --NumF; @@ -2422,7 +2154,7 @@ namespace ScheduleManager { { std::string_view constexpr SchTFmt0("! Schedule Details Report={} =====================\n"); std::string_view constexpr SchDFmt{",{}"}; - print(state.files.eio, SchTFmt0, outputScheduleReportLevelNames[static_cast(LevelOfDetail)]); + print(state.files.eio, SchTFmt0, reportLevelNames[(int)LevelOfDetail]); std::string_view constexpr SchTFmt("! ,Name,Limited? {Yes/No},Minimum,Maximum,Continuous? {Yes/No - Discrete}"); print(state.files.eio, "{}\n", SchTFmt); @@ -2434,27 +2166,27 @@ namespace ScheduleManager { print(state.files.eio, "\n"); // SchWFmt Header (WeekSchedule) std::string SchWFmt("! ,Name"); - for (int Count = 1; Count <= maxDayTypes; ++Count) { - SchWFmt += "," + static_cast(dayTypeNames[Count]); + for (int Count = 1; Count < (int)DayType::Num; ++Count) { + SchWFmt = format("{},{}", SchWFmt, dayTypeNames[Count]); } print(state.files.eio, "{}\n", SchWFmt); std::string_view constexpr SchSFmt("! ,Name,ScheduleType,{Until Date,WeekSchedule}** Repeated until Dec 31"); print(state.files.eio, "{}\n", SchSFmt); } - for (int Count = 1; Count <= state.dataScheduleMgr->NumScheduleTypes; ++Count) { - if (state.dataScheduleMgr->ScheduleType(Count).Limited) { + for (auto const *schedType : s_sched->scheduleTypes) { + if (schedType->isLimited) { NoAverageLinear = "Average"; - Num1 = format("{:.2R}", state.dataScheduleMgr->ScheduleType(Count).Minimum); + Num1 = format("{:.2R}", schedType->minVal); strip(Num1); - Num2 = format("{:.2R}", state.dataScheduleMgr->ScheduleType(Count).Maximum); + Num2 = format("{:.2R}", schedType->maxVal); strip(Num2); - if (state.dataScheduleMgr->ScheduleType(Count).IsReal) { + if (schedType->isReal) { YesNo2 = "Yes"; } else { YesNo2 = "No"; - Num1 = fmt::to_string(static_cast(state.dataScheduleMgr->ScheduleType(Count).Minimum)); - Num2 = fmt::to_string(static_cast(state.dataScheduleMgr->ScheduleType(Count).Maximum)); + Num1 = fmt::to_string((int)schedType->minVal); + Num2 = fmt::to_string((int)schedType->maxVal); } } else { NoAverageLinear = "No"; @@ -2463,110 +2195,118 @@ namespace ScheduleManager { YesNo2 = "N/A"; } std::string_view constexpr SchTFmtdata("ScheduleTypeLimits,{},{},{},{},{}\n"); - print(state.files.eio, SchTFmtdata, state.dataScheduleMgr->ScheduleType(Count).Name, NoAverageLinear, Num1, Num2, YesNo2); + print(state.files.eio, SchTFmtdata, schedType->Name, NoAverageLinear, Num1, Num2, YesNo2); } - for (int Count = 1; Count <= state.dataScheduleMgr->NumDaySchedules; ++Count) { - NoAverageLinear = interpolationTypes[static_cast(state.dataScheduleMgr->DaySchedule(Count).IntervalInterpolated)]; - for (int Hr = 1; Hr <= 24; ++Hr) { - for (int TS = 1; TS <= state.dataGlobal->NumOfTimeStepInHour; ++TS) { - RoundTSValue(TS, Hr) = format("{:.2R}", state.dataScheduleMgr->DaySchedule(Count).TSValue(TS, Hr)); + for (auto *daySched : s_sched->daySchedules) { + + NoAverageLinear = interpolationNames[(int)daySched->interpolation]; + for (int hr = 0; hr < Constant::iHoursInDay; ++hr) { + for (int ts = 1; ts <= s_glob->TimeStepsInHour; ++ts) { + RoundTSValue(ts, hr) = format("{:.2R}", daySched->tsVals[hr * s_glob->TimeStepsInHour + ts]); } } std::string_view constexpr SchDFmtdata0("DaySchedule,{},{},{},{}"); print(state.files.eio, SchDFmtdata0, - state.dataScheduleMgr->DaySchedule(Count).Name, - state.dataScheduleMgr->ScheduleType(state.dataScheduleMgr->DaySchedule(Count).ScheduleTypePtr).Name, + daySched->Name, + s_sched->scheduleTypes[daySched->schedTypeNum]->Name, NoAverageLinear, "Values:"); + switch (LevelOfDetail) { - case OutputReportLevel::Hourly: - for (int Hr = 1; Hr <= 24; ++Hr) { - print(state.files.eio, SchDFmtdata, RoundTSValue(state.dataGlobal->NumOfTimeStepInHour, Hr)); + case ReportLevel::Hourly: { + for (int hr = 0; hr < Constant::iHoursInDay; ++hr) { + print(state.files.eio, SchDFmtdata, RoundTSValue(s_glob->TimeStepsInHour, hr)); } - break; - case OutputReportLevel::TimeStep: - for (int Hr = 1; Hr <= 24; ++Hr) { - for (int TS = 1; TS <= state.dataGlobal->NumOfTimeStepInHour; ++TS) { - print(state.files.eio, SchDFmtdata, RoundTSValue(TS, Hr)); + } break; + + case ReportLevel::TimeStep: { + for (int hr = 1; hr < Constant::iHoursInDay; ++hr) { + for (int ts = 0; ts < s_glob->TimeStepsInHour; ++ts) { + print(state.files.eio, SchDFmtdata, RoundTSValue(ts, hr)); } } - break; + } break; default: assert(false); } print(state.files.eio, "\n"); } - for (int Count = 1; Count <= state.dataScheduleMgr->NumWeekSchedules; ++Count) { + for (auto *weekSched : s_sched->weekSchedules) { + std::string_view constexpr SchWFmtdata("Schedule:Week:Daily,{}"); - print(state.files.eio, SchWFmtdata, state.dataScheduleMgr->WeekSchedule(Count).Name); - for (NumF = 1; NumF <= maxDayTypes; ++NumF) { - print(state.files.eio, - ",{}", - state.dataScheduleMgr->DaySchedule(state.dataScheduleMgr->WeekSchedule(Count).DaySchedulePointer(NumF)).Name); + print(state.files.eio, SchWFmtdata, weekSched->Name); + + for (int NumF = 0; NumF < (int)DayType::Num; ++NumF) { + print(state.files.eio, ",{}", weekSched->dayScheds[NumF]->Name); } print(state.files.eio, "\n"); } - for (int Count = 1; Count <= state.dataScheduleMgr->NumSchedules; ++Count) { - NumF = 1; - print(state.files.eio, - "Schedule,{},{}", - state.dataScheduleMgr->Schedule(Count).Name, - state.dataScheduleMgr->ScheduleType(state.dataScheduleMgr->Schedule(Count).ScheduleTypePtr).Name); + for (auto *sched : s_sched->schedules) { + + if (sched->type == SchedType::Constant) continue; + + auto *schedDetailed = dynamic_cast(sched); + assert(schedDetailed != nullptr); + + int NumF = 1; + print(state.files.eio, "Schedule,{},{}", schedDetailed->Name, s_sched->scheduleTypes[sched->schedTypeNum]->Name); while (NumF <= 366) { - int TS = state.dataScheduleMgr->Schedule(Count).WeekSchedulePointer(NumF); + + auto *weekSched = schedDetailed->weekScheds[NumF]; std::string_view constexpr ThruFmt(",Through {} {:02},{}"); - while (state.dataScheduleMgr->Schedule(Count).WeekSchedulePointer(NumF) == TS && NumF <= 366) { + while (schedDetailed->weekScheds[NumF] == weekSched && NumF <= 366) { if (NumF == 366) { General::InvOrdinalDay(NumF, PMon, PDay, 1); - print(state.files.eio, ThruFmt, Months[PMon - 1], PDay, state.dataScheduleMgr->WeekSchedule(TS).Name); + print(state.files.eio, ThruFmt, Months[PMon - 1], PDay, weekSched->Name); } ++NumF; if (NumF > 366) break; // compound If might have a problem unless this included. } if (NumF <= 366) { General::InvOrdinalDay(NumF - 1, PMon, PDay, 1); - print(state.files.eio, ThruFmt, Months[PMon - 1], PDay, state.dataScheduleMgr->WeekSchedule(TS).Name); + print(state.files.eio, ThruFmt, Months[PMon - 1], PDay, weekSched->Name); } } print(state.files.eio, "\n"); } - break; + } break; + default: break; } // So this section of the code was not accessible. The input processor would never have let anything but hourly or timestep on the object // This code is obviously not covered by any of our integration or unit tests. - // for (Count = 1; Count <= state.dataScheduleMgr->NumSchedules; ++Count) { + // for (Count = 1; Count <= s_sched->NumSchedules; ++Count) { // print(state.files.debug, "\n"); // print(state.files.debug, " Schedule:Compact,\n"); - // print(state.files.debug, " {}, !- Name\n", state.dataScheduleMgr->Schedule(Count).Name); + // print(state.files.debug, " {}, !- Name\n", s_sched->Schedule(Count).Name); // print(state.files.debug, // " {}, !- ScheduleTypeLimits\n", - // state.dataScheduleMgr->ScheduleType(state.dataScheduleMgr->Schedule(Count).ScheduleTypePtr).Name); + // s_sched->ScheduleType(s_sched->Schedule(Count).ScheduleTypePtr).Name); // NumF = 1; // while (NumF <= 366) { - // TS = state.dataScheduleMgr->Schedule(Count).WeekSchedulePointer(NumF); - // while (state.dataScheduleMgr->Schedule(Count).WeekSchedulePointer(NumF) == TS && NumF <= 366) { + // TS = s_sched->Schedule(Count).WeekSchedulePointer(NumF); + // while (s_sched->Schedule(Count).WeekSchedulePointer(NumF) == TS && NumF <= 366) { // if (NumF == 366) { // General::InvOrdinalDay(NumF, PMon, PDay, 1); // print(state.files.debug, " Through: {}/{},\n", PMon, PDay); // iDayP = 0; // for (DT = 2; DT <= 6; ++DT) { // print(state.files.debug, " For: {},\n", ValidDayTypes(DT)); - // iWeek = state.dataScheduleMgr->Schedule(Count).WeekSchedulePointer(NumF - 1); - // iDay = state.dataScheduleMgr->WeekSchedule(iWeek).DaySchedulePointer(DT); + // iWeek = s_sched->Schedule(Count).WeekSchedulePointer(NumF - 1); + // iDay = s_sched->WeekSchedule(iWeek).DaySchedulePointer(DT); // if (iDay != iDayP) { // for (Hr = 1; Hr <= 24; ++Hr) { // print(state.files.debug, // " Until: {}:{},{:.2R},\n", // Hr, - // ShowMinute(state.dataGlobal->NumOfTimeStepInHour), - // state.dataScheduleMgr->DaySchedule(iDay).TSValue(state.dataGlobal->NumOfTimeStepInHour, Hr)); + // ShowMinute(s_glob->NumOfTimeStepInHour), + // s_sched->DaySchedule(iDay).TSValue(s_glob->NumOfTimeStepInHour, Hr)); // } // } else { // print(state.files.debug, " Same as previous\n"); @@ -2575,15 +2315,15 @@ namespace ScheduleManager { // } // DT = 1; // print(state.files.debug, " For: {},\n", ValidDayTypes(DT)); - // iWeek = state.dataScheduleMgr->Schedule(Count).WeekSchedulePointer(NumF - 1); - // iDay = state.dataScheduleMgr->WeekSchedule(iWeek).DaySchedulePointer(DT); + // iWeek = s_sched->Schedule(Count).WeekSchedulePointer(NumF - 1); + // iDay = s_sched->WeekSchedule(iWeek).DaySchedulePointer(DT); // if (iDay != iDayP) { // for (Hr = 1; Hr <= 24; ++Hr) { // print(state.files.debug, // " Until: {}:{},{:.2R},\n", // Hr, - // ShowMinute(state.dataGlobal->NumOfTimeStepInHour), - // state.dataScheduleMgr->DaySchedule(iDay).TSValue(state.dataGlobal->NumOfTimeStepInHour, Hr)); + // ShowMinute(s_glob->NumOfTimeStepInHour), + // s_sched->DaySchedule(iDay).TSValue(s_glob->NumOfTimeStepInHour, Hr)); // } // } else { // print(state.files.debug, " Same as previous\n"); @@ -2591,15 +2331,15 @@ namespace ScheduleManager { // iDayP = iDay; // for (DT = 7; DT <= MaxDayTypes; ++DT) { // print(state.files.debug, " For: {},\n", ValidDayTypes(DT)); - // iWeek = state.dataScheduleMgr->Schedule(Count).WeekSchedulePointer(NumF - 1); - // iDay = state.dataScheduleMgr->WeekSchedule(iWeek).DaySchedulePointer(DT); + // iWeek = s_sched->Schedule(Count).WeekSchedulePointer(NumF - 1); + // iDay = s_sched->WeekSchedule(iWeek).DaySchedulePointer(DT); // if (iDay != iDayP) { // for (Hr = 1; Hr <= 24; ++Hr) { // print(state.files.debug, // " Until: {}:{},{:.2R},\n", // Hr, - // ShowMinute(state.dataGlobal->NumOfTimeStepInHour), - // state.dataScheduleMgr->DaySchedule(iDay).TSValue(state.dataGlobal->NumOfTimeStepInHour, Hr)); + // ShowMinute(s_glob->NumOfTimeStepInHour), + // s_sched->DaySchedule(iDay).TSValue(s_glob->NumOfTimeStepInHour, Hr)); // } // } else { // print(state.files.debug, " Same as previous\n"); @@ -2616,15 +2356,15 @@ namespace ScheduleManager { // iDayP = 0; // for (DT = 2; DT <= 6; ++DT) { // print(state.files.debug, " For: {},\n", ValidDayTypes(DT)); - // iWeek = state.dataScheduleMgr->Schedule(Count).WeekSchedulePointer(NumF - 1); - // iDay = state.dataScheduleMgr->WeekSchedule(iWeek).DaySchedulePointer(DT); + // iWeek = s_sched->Schedule(Count).WeekSchedulePointer(NumF - 1); + // iDay = s_sched->WeekSchedule(iWeek).DaySchedulePointer(DT); // if (iDay != iDayP) { // for (Hr = 1; Hr <= 24; ++Hr) { // print(state.files.debug, // " Until: {}:{},{:.2R},\n", // Hr, - // ShowMinute(state.dataGlobal->NumOfTimeStepInHour), - // state.dataScheduleMgr->DaySchedule(iDay).TSValue(state.dataGlobal->NumOfTimeStepInHour, Hr)); + // ShowMinute(s_glob->NumOfTimeStepInHour), + // s_sched->DaySchedule(iDay).TSValue(s_glob->NumOfTimeStepInHour, Hr)); // } // } else { // print(state.files.debug, " Same as previous\n"); @@ -2633,15 +2373,15 @@ namespace ScheduleManager { // } // DT = 1; // print(state.files.debug, " For: {},\n", ValidDayTypes(DT)); - // iWeek = state.dataScheduleMgr->Schedule(Count).WeekSchedulePointer(NumF - 1); - // iDay = state.dataScheduleMgr->WeekSchedule(iWeek).DaySchedulePointer(DT); + // iWeek = s_sched->Schedule(Count).WeekSchedulePointer(NumF - 1); + // iDay = s_sched->WeekSchedule(iWeek).DaySchedulePointer(DT); // if (iDay != iDayP) { // for (Hr = 1; Hr <= 24; ++Hr) { // print(state.files.debug, // " Until: {}:{},{:.2R},\n", // Hr, - // ShowMinute(state.dataGlobal->NumOfTimeStepInHour), - // state.dataScheduleMgr->DaySchedule(iDay).TSValue(state.dataGlobal->NumOfTimeStepInHour, Hr)); + // ShowMinute(s_glob->NumOfTimeStepInHour), + // s_sched->DaySchedule(iDay).TSValue(s_glob->NumOfTimeStepInHour, Hr)); // } // } else { // print(state.files.debug, " Same as previous\n"); @@ -2649,15 +2389,15 @@ namespace ScheduleManager { // iDayP = iDay; // for (DT = 7; DT <= MaxDayTypes; ++DT) { // print(state.files.debug, " For: {},\n", ValidDayTypes(DT)); - // iWeek = state.dataScheduleMgr->Schedule(Count).WeekSchedulePointer(NumF - 1); - // iDay = state.dataScheduleMgr->WeekSchedule(iWeek).DaySchedulePointer(DT); + // iWeek = s_sched->Schedule(Count).WeekSchedulePointer(NumF - 1); + // iDay = s_sched->WeekSchedule(iWeek).DaySchedulePointer(DT); // if (iDay != iDayP) { // for (Hr = 1; Hr <= 24; ++Hr) { // print(state.files.debug, // " Until: {}:{},{:.2R},\n", // Hr, - // ShowMinute(state.dataGlobal->NumOfTimeStepInHour), - // state.dataScheduleMgr->DaySchedule(iDay).TSValue(state.dataGlobal->NumOfTimeStepInHour, Hr)); + // ShowMinute(s_glob->NumOfTimeStepInHour), + // s_sched->DaySchedule(iDay).TSValue(s_glob->NumOfTimeStepInHour, Hr)); // } // } else { // print(state.files.debug, " Same as previous\n"); @@ -2671,15 +2411,14 @@ namespace ScheduleManager { ShowMinute.deallocate(); TimeHHMM.deallocate(); RoundTSValue.deallocate(); - } + } // ReportScheduleDetails() - Real64 GetCurrentScheduleValue(EnergyPlusData &state, int const ScheduleIndex) + Real64 GetCurrentScheduleValue(EnergyPlusData &state, int const schedNum) { // FUNCTION INFORMATION: // AUTHOR Linda K. Lawrie // DATE WRITTEN September 1997 // MODIFIED August 2011; adapt Autodesk changes (time reduction) - // RE-ENGINEERED na // PURPOSE OF THIS FUNCTION: // This function returns the hourly schedule value for the current day. @@ -2688,50 +2427,14 @@ namespace ScheduleManager { // Use internal Schedule data structure to return value. Note that missing values in // input will equate to 0 indices in arrays -- which has been set up to return legally with // 0.0 values. - - // REFERENCES: - // na - - // USE STATEMENTS: - // na - - // Return value - - // Locals - // FUNCTION ARGUMENT DEFINITIONS: - - // FUNCTION PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - - // FUNCTION LOCAL VARIABLE DECLARATIONS: - // na - - // Checking if valid index is passed is necessary - if (ScheduleIndex == ScheduleManager::ScheduleAlwaysOn) { - return 1.0; - } else if (ScheduleIndex == ScheduleManager::ScheduleAlwaysOff) { - return 0.0; - } else if (!state.dataScheduleMgr->Schedule(ScheduleIndex).EMSActuatedOn) { - return state.dataScheduleMgr->Schedule(ScheduleIndex) - .CurrentValue; // This block probably unecessary, UpdateScheduleValues already does it - } else { - return state.dataScheduleMgr->Schedule(ScheduleIndex).EMSValue; - } + return state.dataSched->schedules[schedNum]->getCurrentVal(); } - void UpdateScheduleValues(EnergyPlusData &state) + void UpdateScheduleVals(EnergyPlusData &state) { // SUBROUTINE INFORMATION: // AUTHOR Linda Lawrie // DATE WRITTEN August 2011; adapted from Autodesk (time reduction) - // MODIFIED na - // RE-ENGINEERED na // PURPOSE OF THIS SUBROUTINE: // This routine calculates all the scheduled values as a time reduction measure and @@ -2741,47 +2444,22 @@ namespace ScheduleManager { // Use internal Schedule data structure to calculate current value. Note that missing values in // input will equate to 0 indices in arrays -- which has been set up to return legally with // 0.0 values. - - // REFERENCES: - // na - - // Using/Aliasing - - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - // na - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS: - // na - - // DERIVED TYPE DEFINITIONS: - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - - if (!state.dataScheduleMgr->ScheduleInputProcessed) { - ProcessScheduleInput(state); - state.dataScheduleMgr->ScheduleInputProcessed = true; - } - - for (int ScheduleIndex = 1; ScheduleIndex <= state.dataScheduleMgr->NumSchedules; ++ScheduleIndex) { - if (state.dataScheduleMgr->Schedule(ScheduleIndex).EMSActuatedOn) { - state.dataScheduleMgr->Schedule(ScheduleIndex).CurrentValue = state.dataScheduleMgr->Schedule(ScheduleIndex).EMSValue; + auto const &s_sched = state.dataSched; + auto const &s_glob = state.dataGlobal; + + for (auto *sched : s_sched->schedules) { + if (sched->EMSActuatedOn) { + sched->currentVal = sched->EMSVal; } else { - state.dataScheduleMgr->Schedule(ScheduleIndex).CurrentValue = - LookUpScheduleValue(state, ScheduleIndex, state.dataGlobal->HourOfDay, state.dataGlobal->TimeStep); + sched->currentVal = sched->getHrTsVal(state, s_glob->HourOfDay, s_glob->TimeStep); } } } - Real64 LookUpScheduleValue(EnergyPlusData &state, - int const ScheduleIndex, - int const ThisHour, - int const ThisTimeStep // Negative => unspecified - ) + Real64 ScheduleDetailed::getHrTsVal(EnergyPlusData &state, + int hr, + int ts // Negative => unspecified + ) const { // FUNCTION INFORMATION: // AUTHOR Linda K. Lawrie @@ -2789,42 +2467,27 @@ namespace ScheduleManager { // PURPOSE OF THIS FUNCTION: // This function provides a method to look up schedule values for any hour, timestep, day // of the year (rather than just the "current time"). - - // Return value - Real64 scheduleValue(0.0); - - if (ScheduleIndex == ScheduleManager::ScheduleAlwaysOn) { - return 1.0; - } else if (ScheduleIndex == ScheduleManager::ScheduleAlwaysOff) { - return 0.0; - } - - if (!state.dataScheduleMgr->ScheduleInputProcessed) { - ProcessScheduleInput(state); - state.dataScheduleMgr->ScheduleInputProcessed = true; - } - - if (state.dataScheduleMgr->Schedule(ScheduleIndex).EMSActuatedOn) { - return state.dataScheduleMgr->Schedule(ScheduleIndex).EMSValue; - } + auto const &s_glob = state.dataGlobal; + + if (this->EMSActuatedOn) return this->EMSVal; // so, current date, but maybe TimeStep added // Hourly Value - if (ThisHour > 24) { - ShowFatalError(state, format("LookUpScheduleValue called with thisHour={}", ThisHour)); + if (hr > Constant::iHoursInDay) { + ShowFatalError(state, format("LookUpScheduleValue called with thisHour={}", hr)); } - int thisHour = ThisHour + state.dataEnvrn->DSTIndicator * state.dataScheduleMgr->Schedule(ScheduleIndex).UseDaylightSaving; + int thisHr = hr + state.dataEnvrn->DSTIndicator * this->UseDaylightSaving; int thisDayOfYear = state.dataEnvrn->DayOfYear_Schedule; int thisDayOfWeek = state.dataEnvrn->DayOfWeek; - int thisHolidayIndex = state.dataEnvrn->HolidayIndex; - if (thisHour > 24) { // In case HourOfDay is 24 and DSTIndicator is 1, you're actually the next day + int thisHolidayNum = state.dataEnvrn->HolidayIndex; + if (thisHr > Constant::iHoursInDay) { // In case HourOfDay is 24 and DSTIndicator is 1, you're actually the next day thisDayOfYear += 1; - thisHour -= 24; + thisHr -= Constant::iHoursInDay; thisDayOfWeek = state.dataEnvrn->DayOfWeekTomorrow; - thisHolidayIndex = state.dataEnvrn->HolidayIndexTomorrow; + thisHolidayNum = state.dataEnvrn->HolidayIndexTomorrow; } // In the case where DST is applied on 12/31 at 24:00, which is the case for a Southern Hemisphere location for eg @@ -2833,276 +2496,264 @@ namespace ScheduleManager { thisDayOfYear = 1; } - int WeekSchedulePointer = state.dataScheduleMgr->Schedule(ScheduleIndex).WeekSchedulePointer(thisDayOfYear); - int DaySchedulePointer; - - if (thisHolidayIndex > 0) { - DaySchedulePointer = state.dataScheduleMgr->WeekSchedule(WeekSchedulePointer).DaySchedulePointer(thisHolidayIndex); - } else { - DaySchedulePointer = state.dataScheduleMgr->WeekSchedule(WeekSchedulePointer).DaySchedulePointer(thisDayOfWeek); - } + auto const *weekSched = this->weekScheds[thisDayOfYear]; + auto const *daySched = (thisHolidayNum > 0) ? weekSched->dayScheds[thisHolidayNum] : weekSched->dayScheds[thisDayOfWeek]; // If Unspecified or equal to zero, use NumOfTimeStepInHour, otherwise use supplied - int thisTimeStep = ThisTimeStep > 0 ? ThisTimeStep : state.dataGlobal->NumOfTimeStepInHour; - scheduleValue = state.dataScheduleMgr->DaySchedule(DaySchedulePointer).TSValue(thisTimeStep, thisHour); + if (ts <= 0) ts = s_glob->TimeStepsInHour; + + return daySched->tsVals[(thisHr - 1) * s_glob->TimeStepsInHour + (ts - 1)]; + } // ScheduleDetailed::getHrTsVal() - return scheduleValue; + Real64 ScheduleConstant::getHrTsVal([[maybe_unused]] EnergyPlusData &state, + [[maybe_unused]] int hr, + [[maybe_unused]] int ts + ) const + { + return this->currentVal; + } // ScheduleConstant::getHrTsVal() + + Sched::Schedule *GetScheduleAlwaysOn(EnergyPlusData &state) + { + return state.dataSched->schedules[SchedNum_AlwaysOn]; } - int GetScheduleIndex(EnergyPlusData &state, std::string const &ScheduleName) + Sched::Schedule *GetScheduleAlwaysOff(EnergyPlusData &state) + { + return state.dataSched->schedules[SchedNum_AlwaysOff]; + } + + Sched::Schedule *GetSchedule(EnergyPlusData &state, std::string const &name) { // FUNCTION INFORMATION: // AUTHOR Linda K. Lawrie // DATE WRITTEN September 1997 - // MODIFIED na - // RE-ENGINEERED na // PURPOSE OF THIS FUNCTION: // This function returns the internal pointer to Schedule "ScheduleName". - - // Return value - int GetScheduleIndex; - - // FUNCTION LOCAL VARIABLE DECLARATIONS: - int DayCtr; - int WeekCtr; - - if (!state.dataScheduleMgr->ScheduleInputProcessed) { - ProcessScheduleInput(state); - state.dataScheduleMgr->ScheduleInputProcessed = true; - } - - if (state.dataScheduleMgr->NumSchedules > 0) { - GetScheduleIndex = Util::FindItemInList(ScheduleName, state.dataScheduleMgr->Schedule({1, state.dataScheduleMgr->NumSchedules})); - if (GetScheduleIndex > 0) { - if (!state.dataScheduleMgr->Schedule(GetScheduleIndex).Used) { - state.dataScheduleMgr->Schedule(GetScheduleIndex).Used = true; - for (WeekCtr = 1; WeekCtr <= 366; ++WeekCtr) { - if (state.dataScheduleMgr->Schedule(GetScheduleIndex).WeekSchedulePointer(WeekCtr) > 0) { - state.dataScheduleMgr->WeekSchedule(state.dataScheduleMgr->Schedule(GetScheduleIndex).WeekSchedulePointer(WeekCtr)).Used = - true; - for (DayCtr = 1; DayCtr <= maxDayTypes; ++DayCtr) { - state.dataScheduleMgr - ->DaySchedule(state.dataScheduleMgr - ->WeekSchedule(state.dataScheduleMgr->Schedule(GetScheduleIndex).WeekSchedulePointer(WeekCtr)) - .DaySchedulePointer(DayCtr)) - .Used = true; - } - } + auto &s_sched = state.dataSched; + + auto found = s_sched->scheduleMap.find(name); + if (found == s_sched->scheduleMap.end()) return nullptr; + + int schedNum = found->second; + + auto *sched = s_sched->schedules[schedNum]; + + if (sched->type != SchedType::Constant && !sched->isUsed) { + auto *schedDetailed = dynamic_cast(sched); + assert(schedDetailed != nullptr); + + schedDetailed->isUsed = true; + for (int iWeek = 1; iWeek <= 366; ++iWeek) { + if (auto *weekSched = schedDetailed->weekScheds[iWeek]; weekSched != nullptr) { + if (weekSched->isUsed) continue; + + weekSched->isUsed = true; + for (int iDayType = 1; iDayType < (int)DayType::Num; ++iDayType) { + auto *daySched = weekSched->dayScheds[iDayType]; + daySched->isUsed = true; } } } - } else { - GetScheduleIndex = 0; } + return sched; + } // GetSchedule() - return GetScheduleIndex; - } - - std::string GetScheduleType(EnergyPlusData &state, int const ScheduleIndex) + int GetScheduleNum(EnergyPlusData &state, std::string const &name) { - // FUNCTION INFORMATION: - // AUTHOR Jason Glazer - // DATE WRITTEN July 2007 - // MODIFIED na - // RE-ENGINEERED na - - // PURPOSE OF THIS FUNCTION: - // This function returns the internal pointer to Schedule "ScheduleName" (actually, it doesn't do that) - - // METHODOLOGY EMPLOYED: - // na - - // REFERENCES: - // na - - // USE STATEMENTS: - - // Return value - std::string TypeOfSchedule; - - // Locals - // FUNCTION ARGUMENT DEFINITIONS: + auto *sched = GetSchedule(state, name); + return (sched == nullptr) ? -1: sched->Num; + } - // FUNCTION PARAMETER DEFINITIONS: - // na - // INTERFACE BLOCK SPECIFICATIONS - // na + Sched::WeekSchedule *GetWeekSchedule(EnergyPlusData &state, std::string const &name) + { + auto &s_sched = state.dataSched; - // DERIVED TYPE DEFINITIONS - // na + auto found = s_sched->weekScheduleMap.find(name); + if (found == s_sched->weekScheduleMap.end()) return nullptr; - // FUNCTION LOCAL VARIABLE DECLARATIONS: - int curSchType; + int weekSchedNum = found->second; - if (!state.dataScheduleMgr->ScheduleInputProcessed) { - ProcessScheduleInput(state); - state.dataScheduleMgr->ScheduleInputProcessed = true; - } + auto *weekSched = s_sched->weekSchedules[weekSchedNum]; - if ((ScheduleIndex > 0) && (ScheduleIndex <= state.dataScheduleMgr->NumSchedules)) { - curSchType = state.dataScheduleMgr->Schedule(ScheduleIndex).ScheduleTypePtr; - if ((curSchType > 0) && (curSchType <= state.dataScheduleMgr->NumScheduleTypes)) { - TypeOfSchedule = state.dataScheduleMgr->ScheduleType(curSchType).Name; - } else { - TypeOfSchedule = ""; + if (!weekSched->isUsed) { + weekSched->isUsed = true; + for (int iDayType = 1; iDayType < (int)DayType::Num; ++iDayType) { + auto *daySched = weekSched->dayScheds[iDayType]; + if (daySched == nullptr) continue; + daySched->isUsed = true; } - } else { - TypeOfSchedule = ""; } - return TypeOfSchedule; + return weekSched; + } // GetWeekSchedule() + + int GetWeekScheduleNum(EnergyPlusData &state, std::string const &name) + { + auto *weekSched = GetWeekSchedule(state, name); + return (weekSched == nullptr) ? -1: weekSched->Num; } - int GetDayScheduleIndex(EnergyPlusData &state, std::string &ScheduleName) + Sched::DaySchedule *GetDaySchedule(EnergyPlusData &state, std::string const &name) { // FUNCTION INFORMATION: // AUTHOR Linda K. Lawrie - // DATE WRITTEN August 2003 - // MODIFIED na - // RE-ENGINEERED na + // DATE WRITTEN September 1997 // PURPOSE OF THIS FUNCTION: - // This function returns the internal pointer to Day Schedule "ScheduleName". + // This function returns the internal pointer to Schedule "ScheduleName". + auto &s_sched = state.dataSched; - // Return value - int GetDayScheduleIndex; + auto found = s_sched->dayScheduleMap.find(name); + if (found == s_sched->dayScheduleMap.end()) return nullptr; - if (!state.dataScheduleMgr->ScheduleInputProcessed) { - ProcessScheduleInput(state); - state.dataScheduleMgr->ScheduleInputProcessed = true; - } + int daySchedNum = found->second; + + auto *daySched = s_sched->daySchedules[daySchedNum]; + + daySched->isUsed = true; + + return daySched; + } // GetDaySchedule() - if (state.dataScheduleMgr->NumDaySchedules > 0) { - GetDayScheduleIndex = Util::FindItemInList(ScheduleName, state.dataScheduleMgr->DaySchedule({1, state.dataScheduleMgr->NumDaySchedules})); - if (GetDayScheduleIndex > 0) { - state.dataScheduleMgr->DaySchedule(GetDayScheduleIndex).Used = true; + int GetDayScheduleNum(EnergyPlusData &state, std::string const &name) + { + auto *daySched = GetDaySchedule(state, name); + return (daySched == nullptr) ? -1: daySched->Num; + } + + void DaySchedule::getDayVals(EnergyPlusData &state, + Array2S DayVals) const + { + auto const &s_glob = state.dataGlobal; + for (int hr = 0; hr < Constant::iHoursInDay; ++hr) { + for (int ts = 0; ts < s_glob->TimeStepsInHour; ++ts) { + DayVals(ts+1, hr+1) = this->tsVals[hr * s_glob->TimeStepsInHour + ts]; } - } else { - GetDayScheduleIndex = 0; } + } // ScheduleDay::getDayValues() - return GetDayScheduleIndex; + void ScheduleConstant::setMinMaxVals([[maybe_unused]] EnergyPlusData &state) + { + assert(!isMinMaxSet); + minVal = maxVal = currentVal; + isMinMaxSet = true; } - - void GetScheduleValuesForDay(EnergyPlusData &state, - int const ScheduleIndex, - Array2S DayValues, - ObjexxFCL::Optional_int_const JDay, - ObjexxFCL::Optional_int_const CurDayofWeek) + + void ScheduleConstant::getDayVals(EnergyPlusData &state, + Array2S DayValues, + [[maybe_unused]] int jDay, + [[maybe_unused]] int dayofWeek) { // SUBROUTINE INFORMATION: // AUTHOR Linda K. Lawrie // DATE WRITTEN September 1997 - // MODIFIED na - // RE-ENGINEERED na // PURPOSE OF THIS SUBROUTINE: // This subroutine returns an entire day's worth of schedule values. - // METHODOLOGY EMPLOYED: - // Use internal data to fill DayValues array. - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - int WeekSchedulePointer; - int DaySchedulePointer; - - if (!state.dataScheduleMgr->ScheduleInputProcessed) { - ProcessScheduleInput(state); - state.dataScheduleMgr->ScheduleInputProcessed = true; - } + auto const &s_glob = state.dataGlobal; + DayValues({1, s_glob->TimeStepsInHour}, {1, Constant::iHoursInDay}) = this->currentVal; + } // ScheduleConstant::getDayVals() - if (ScheduleIndex == ScheduleManager::ScheduleAlwaysOn) { - DayValues({1, state.dataGlobal->NumOfTimeStepInHour}, {1, 24}) = 1.0; - return; - } else if (ScheduleIndex == ScheduleManager::ScheduleAlwaysOff) { - DayValues({1, state.dataGlobal->NumOfTimeStepInHour}, {1, 24}) = 0.0; - return; + std::vector const &ScheduleConstant::getDayVals(EnergyPlusData &state, + [[maybe_unused]] int jDay, + [[maybe_unused]] int dayofWeek) + { + auto const &s_glob = state.dataGlobal; + if ((int)tsVals.size() != Constant::iHoursInDay * s_glob->TimeStepsInHour) { + this->tsVals.resize(Constant::iHoursInDay * s_glob->TimeStepsInHour); + std::fill(this->tsVals.begin(), this->tsVals.end(), this->currentVal); } + return this->tsVals; + } // ScheduleConstant::getDayVals() + std::vector const &ScheduleDetailed::getDayVals(EnergyPlusData &state, + int jDay, + int dayOfWeek) + { + // PURPOSE OF THIS SUBROUTINE: + // This subroutine returns an entire day's worth of schedule values. + auto const &s_env = state.dataEnvrn; + // Determine which Week Schedule is used - if (!present(JDay)) { - WeekSchedulePointer = state.dataScheduleMgr->Schedule(ScheduleIndex).WeekSchedulePointer(state.dataEnvrn->DayOfYear_Schedule); - } else { - WeekSchedulePointer = state.dataScheduleMgr->Schedule(ScheduleIndex).WeekSchedulePointer(JDay); - } + auto const *weekSched = this->weekScheds[(jDay == -1) ? state.dataEnvrn->DayOfYear_Schedule : jDay]; + DaySchedule *daySched = nullptr; // Now, which day? - if (!present(CurDayofWeek)) { - if (state.dataEnvrn->HolidayIndex > 0) { - DaySchedulePointer = state.dataScheduleMgr->WeekSchedule(WeekSchedulePointer).DaySchedulePointer(state.dataEnvrn->HolidayIndex); - } else { - DaySchedulePointer = state.dataScheduleMgr->WeekSchedule(WeekSchedulePointer).DaySchedulePointer(state.dataEnvrn->DayOfWeek); - } - } else if (CurDayofWeek <= 7 && state.dataEnvrn->HolidayIndex > 0) { - DaySchedulePointer = state.dataScheduleMgr->WeekSchedule(WeekSchedulePointer).DaySchedulePointer(state.dataEnvrn->HolidayIndex); + if (dayOfWeek == -1) { + daySched = weekSched->dayScheds[(s_env->HolidayIndex > 0) ? s_env->HolidayIndex : s_env->DayOfWeek]; + } else if (dayOfWeek <= 7 && s_env->HolidayIndex > 0) { + daySched = weekSched->dayScheds[s_env->HolidayIndex]; } else { - DaySchedulePointer = state.dataScheduleMgr->WeekSchedule(WeekSchedulePointer).DaySchedulePointer(CurDayofWeek); + daySched = weekSched->dayScheds[dayOfWeek]; } - // Return Values - DayValues({1, state.dataGlobal->NumOfTimeStepInHour}, {1, 24}) = state.dataScheduleMgr->DaySchedule(DaySchedulePointer).TSValue; - } + return daySched->getDayVals(state); + } // ScheduleDetailed::getDayVals() - void GetSingleDayScheduleValues(EnergyPlusData &state, - int const DayScheduleIndex, // Index of the DaySchedule for values - Array2S DayValues // Returned set of values - ) + void ScheduleDetailed::getDayVals(EnergyPlusData &state, + Array2S DayValues, + int jDay, + int dayOfWeek) { // SUBROUTINE INFORMATION: // AUTHOR Linda K. Lawrie - // DATE WRITTEN August 2003 - // MODIFIED na - // RE-ENGINEERED na + // DATE WRITTEN September 1997 // PURPOSE OF THIS SUBROUTINE: - // This subroutine returns an entire day's worth of schedule values for a specified Day Schedule Index item. - - // METHODOLOGY EMPLOYED: - // Use internal data to fill DayValues array. - - // REFERENCES: - // na - - // USE STATEMENTS: - // na - - // Argument array dimensioning - - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS - // na + // This subroutine returns an entire day's worth of schedule values. + auto const &s_env = state.dataEnvrn; + + // Determine which Week Schedule is used + auto const *weekSched = this->weekScheds[(jDay == -1) ? state.dataEnvrn->DayOfYear_Schedule : jDay]; - // DERIVED TYPE DEFINITIONS - // na + DaySchedule *daySched = nullptr; + // Now, which day? + if (dayOfWeek == -1) { + daySched = weekSched->dayScheds[(s_env->HolidayIndex > 0) ? s_env->HolidayIndex : s_env->DayOfWeek]; + } else if (dayOfWeek <= 7 && s_env->HolidayIndex > 0) { + daySched = weekSched->dayScheds[s_env->HolidayIndex]; + } else { + daySched = weekSched->dayScheds[dayOfWeek]; + } - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - // na + daySched->getDayVals(state, DayValues); + } // ScheduleDetailed::getDayVals() + + void GetScheduleValuesForDay(EnergyPlusData &state, + int const schedNum, + Array2S DayValues, + int jDay, + int dayOfWeek) + { + // SUBROUTINE INFORMATION: + // AUTHOR Linda K. Lawrie + // DATE WRITTEN September 1997 - if (!state.dataScheduleMgr->ScheduleInputProcessed) { - ProcessScheduleInput(state); - state.dataScheduleMgr->ScheduleInputProcessed = true; - } + // PURPOSE OF THIS SUBROUTINE: + // This subroutine returns an entire day's worth of schedule values. - // Return Values - DayValues({1, state.dataGlobal->NumOfTimeStepInHour}, {1, 24}) = state.dataScheduleMgr->DaySchedule(DayScheduleIndex).TSValue; + return state.dataSched->schedules[schedNum]->getDayVals(state, DayValues, jDay, dayOfWeek); + } + + void GetSingleDayScheduleValues([[maybe_unused]] EnergyPlusData &state, + int const daySchedNum, // Index of the DaySchedule for values + Array2S DayValues // Returned set of values + ) + { + state.dataSched->daySchedules[daySchedNum]->getDayVals(state, DayValues); } void ExternalInterfaceSetSchedule(EnergyPlusData &state, - int &ScheduleIndex, - Real64 &Value // The new value for the schedule + int schedNum, + Real64 value // The new value for the schedule ) { // FUNCTION INFORMATION: // AUTHOR Michael Wetter // DATE WRITTEN February 2010 - // MODIFIED na - // RE-ENGINEERED na // PURPOSE OF THIS SUBROUTINE: // This subroutine sets all values of the schedule referenced by 'ScheduleIndex' @@ -3111,34 +2762,13 @@ namespace ScheduleManager { // real-time data by referencing a schedule. This allows overwriting setpoint // for supervisory controls or internal gains obtained from real-time occupancy // measurements. - - // METHODOLOGY EMPLOYED: - // na - - // REFERENCES: - // na - - // Using/Aliasing - // Locals - // FUNCTION ARGUMENT DEFINITIONS: - - // FUNCTION PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - - // FUNCTION LOCAL VARIABLE DECLARATIONS: - int TS; // Counter for Num Of Time Steps in Hour - int Hr; // Hour Counter - - // Assign the value of the variable - for (Hr = 1; Hr <= 24; ++Hr) { - for (TS = 1; TS <= state.dataGlobal->NumOfTimeStepInHour; ++TS) { - state.dataScheduleMgr->DaySchedule(ScheduleIndex).TSValue(TS, Hr) = Value; + auto const &s_glob = state.dataGlobal; + auto const &s_sched = state.dataSched; + auto *daySched = s_sched->daySchedules[schedNum]; + + for (int hr = 0; hr < Constant::iHoursInDay; ++hr) { + for (int ts = 0; ts < s_glob->TimeStepsInHour; ++ts) { + daySched->tsVals[hr * s_glob->TimeStepsInHour + ts] = value; } } } @@ -3148,71 +2778,36 @@ namespace ScheduleManager { Array1S const Numbers, int const NumUntils, int const NumNumbers, - Array2A MinuteValue, - Array2A_bool SetMinuteValue, + std::array &minuteVals, + std::array &setMinuteVals, bool &ErrorsFound, std::string const &DayScheduleName, // Name (used for errors) std::string const &ErrContext, // Context (used for errors) - ScheduleInterpolation interpolationKind // enumeration on how to interpolate values in schedule + Interpolation interpolation // enumeration on how to interpolate values in schedule ) { // SUBROUTINE INFORMATION: // AUTHOR // DATE WRITTEN - // MODIFIED na - // RE-ENGINEERED na // PURPOSE OF THIS SUBROUTINE: // This subroutine processes the "interval" fields with/without optional "until" in front of // time (hh:mm). - // METHODOLOGY EMPLOYED: - // na. - - // REFERENCES: - // na - - // USE STATEMENTS: - // na - - // Argument array dimensioning - MinuteValue.dim(60, 24); - SetMinuteValue.dim(60, 24); - - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - int Count; - std::string::size_type Pos; int HHField; int MMField; - int Hr; - int Min; - int SHr; // starting hour - int SMin; // starting minute - int EHr; // ending hour - int EMin; // ending minute + int begHr = 0; // starting hour + int begMin = 0; // starting minute + int endHr = -1; // ending hour + int endMin = -1; // ending minute std::string::size_type sFld; int totalMinutes; Real64 incrementPerMinute; Real64 curValue; - MinuteValue = 0.0; - SetMinuteValue = false; - SHr = 1; - SMin = 1; - EHr = 0; - EMin = 0; + std::fill(minuteVals.begin(), minuteVals.end(), 0.0); + std::fill(setMinuteVals.begin(), setMinuteVals.end(), false); sFld = 0; Real64 StartValue = 0; @@ -3227,26 +2822,27 @@ namespace ScheduleManager { return; } - for (Count = 1; Count <= NumUntils; ++Count) { - Pos = index(Untils(Count), "UNTIL"); + for (int Count = 1; Count <= NumUntils; ++Count) { + std::string const &until = Untils(Count); + int Pos = index(until, "UNTIL"); if (Pos == 0) { - if (Untils(Count)[5] == ':') { + if (until[5] == ':') { sFld = 6; } else { sFld = 5; } - DecodeHHMMField(state, Untils(Count).substr(sFld), HHField, MMField, ErrorsFound, DayScheduleName, Untils(Count), interpolationKind); - } else if (Pos == std::string::npos) { - DecodeHHMMField(state, Untils(Count), HHField, MMField, ErrorsFound, DayScheduleName, Untils(Count), interpolationKind); + DecodeHHMMField(state, until.substr(sFld), HHField, MMField, ErrorsFound, DayScheduleName, until, interpolation); + } else if (Pos == (int)std::string::npos) { + DecodeHHMMField(state, until, HHField, MMField, ErrorsFound, DayScheduleName, until, interpolation); } else { // Until found but wasn't first field - ShowSevereError(state, format("ProcessScheduleInput: ProcessIntervalFields, Invalid \"Until\" field encountered={}", Untils(Count))); + ShowSevereError(state, format("ProcessScheduleInput: ProcessIntervalFields, Invalid \"Until\" field encountered={}", until)); ShowContinueError(state, format("Occurred in Day Schedule={}", DayScheduleName)); ErrorsFound = true; continue; } // Field decoded if (HHField < 0 || HHField > 24 || MMField < 0 || MMField > 60) { - ShowSevereError(state, format("ProcessScheduleInput: ProcessIntervalFields, Invalid \"Until\" field encountered={}", Untils(Count))); + ShowSevereError(state, format("ProcessScheduleInput: ProcessIntervalFields, Invalid \"Until\" field encountered={}", until)); ShowContinueError(state, format("Occurred in Day Schedule={}", DayScheduleName)); ErrorsFound = true; continue; @@ -3260,16 +2856,16 @@ namespace ScheduleManager { // Fill in values if (MMField == 0) { - EHr = HHField + 1; - EMin = 60; + endHr = HHField; + endMin = 59; } if (MMField < 60) { - EHr = HHField + 1; - EMin = MMField; + endHr = HHField; + endMin = MMField - 1; } - if (interpolationKind == ScheduleInterpolation::Linear) { - totalMinutes = (EHr - SHr) * 60 + (EMin - SMin) + 1; + if (interpolation == Interpolation::Linear) { + totalMinutes = (endHr - begHr) * Constant::iMinutesInHour + (endMin - begMin) + 1; if (totalMinutes == 0) totalMinutes = 1; // protect future division if (Count == 1) { StartValue = Numbers(Count); // assume first period is flat @@ -3282,9 +2878,9 @@ namespace ScheduleManager { curValue = StartValue + incrementPerMinute; } - if (SHr == EHr) { - for (Min = SMin; Min <= EMin; ++Min) { - if (SetMinuteValue(Min, SHr)) { + if (begHr == endHr) { + for (int iMin = begMin; iMin <= endMin; ++iMin) { + if (setMinuteVals[begHr * Constant::iMinutesInHour + iMin]) { ShowSevereError( state, format("ProcessScheduleInput: ProcessIntervalFields, Processing time fields, overlapping times detected, {}={}", @@ -3292,71 +2888,79 @@ namespace ScheduleManager { DayScheduleName)); ErrorsFound = true; goto UntilLoop_exit; - } - if (interpolationKind == ScheduleInterpolation::Linear) { - MinuteValue(Min, EHr) = curValue; + } else if (interpolation == Interpolation::Linear) { + minuteVals[begHr * Constant::iMinutesInHour + iMin] = curValue; curValue += incrementPerMinute; - SetMinuteValue(Min, SHr) = true; + setMinuteVals[begHr * Constant::iMinutesInHour + iMin] = true; } else { - MinuteValue(Min, SHr) = Numbers(Count); - SetMinuteValue(Min, SHr) = true; + minuteVals[begHr * Constant::iMinutesInHour + iMin] = Numbers(Count); + setMinuteVals[begHr * Constant::iMinutesInHour + iMin] = true; } } - SMin = EMin + 1; - if (SMin > 60) { - ++SHr; - SMin = 1; + + begMin = endMin + 1; + if (begMin >= 60) { + ++begHr; + begMin = 0; } - } else if (EHr < SHr) { + + } else if (endHr < begHr) { ShowSevereError(state, format("ProcessScheduleInput: ProcessIntervalFields, Processing time fields, overlapping times detected, {}={}", ErrContext, DayScheduleName)); ErrorsFound = true; + } else { - if (interpolationKind == ScheduleInterpolation::Linear) { - for (Min = SMin; Min <= 60; ++Min) { // for portion of starting hour - MinuteValue(Min, SHr) = curValue; + if (interpolation == Interpolation::Linear) { + for (int iMin = begMin; iMin < Constant::iMinutesInHour; ++iMin) { // for portion of starting hour + minuteVals[begHr * Constant::iMinutesInHour + iMin] = curValue; curValue += incrementPerMinute; - SetMinuteValue(Min, SHr) = true; + setMinuteVals[begHr * Constant::iMinutesInHour + iMin] = true; } - for (Hr = SHr + 1; Hr <= EHr - 1; ++Hr) { // for intermediate hours - for (Min = 1; Min <= 60; ++Min) { - MinuteValue(Min, Hr) = curValue; + + for (int iHr = begHr + 1; iHr <= endHr - 1; ++iHr) { // for intermediate hours + for (int iMin = 0; iMin < Constant::iMinutesInHour; ++iMin) { + minuteVals[iHr * Constant::iMinutesInHour + iMin] = curValue; curValue += incrementPerMinute; - SetMinuteValue(Min, Hr) = true; + setMinuteVals[iHr * Constant::iMinutesInHour + iMin] = true; } } - for (Min = 1; Min <= EMin; ++Min) { // for ending hour - MinuteValue(Min, EHr) = curValue; + + for (int iMin = 0; iMin <= endMin; ++iMin) { // for ending hour + minuteVals[endHr * Constant::iMinutesInHour + iMin] = curValue; curValue += incrementPerMinute; - SetMinuteValue(Min, EHr) = true; + setMinuteVals[endHr * Constant::iMinutesInHour + iMin] = true; } + } else { // either no interpolation or "average" interpolation (average just is when the interval does not match the timestep) - for (Min = SMin; Min <= 60; ++Min) { // for portion of starting hour - MinuteValue(Min, SHr) = Numbers(Count); - SetMinuteValue(Min, SHr) = true; + for (int iMin = begMin; iMin < Constant::iMinutesInHour; ++iMin) { // for portion of starting hour + minuteVals[begHr * Constant::iMinutesInHour + iMin] = Numbers(Count); + setMinuteVals[begHr * Constant::iMinutesInHour + iMin] = true; } - for (Hr = SHr + 1; Hr <= EHr - 1; ++Hr) { // for intermediate hours - MinuteValue(_, Hr) = Numbers(Count); - SetMinuteValue(_, Hr) = true; + for (int iHr = begHr + 1; iHr <= endHr - 1; ++iHr) { // for intermediate hours + for (int iMin = 0; iMin < Constant::iMinutesInHour; ++iMin) { + minuteVals[iHr * Constant::iMinutesInHour + iMin] = Numbers(Count); + setMinuteVals[iHr * Constant::iMinutesInHour + iMin] = true; + } } - for (Min = 1; Min <= EMin; ++Min) { // for ending hour - MinuteValue(Min, EHr) = Numbers(Count); - SetMinuteValue(Min, EHr) = true; + for (int iMin = 0; iMin <= endMin; ++iMin) { // for ending hour + minuteVals[endHr * Constant::iMinutesInHour + iMin] = Numbers(Count); + setMinuteVals[endHr * Constant::iMinutesInHour + iMin] = true; } } - SHr = EHr; - SMin = EMin + 1; - if (SMin > 60) { - ++SHr; - SMin = 1; + + begHr = endHr; + begMin = endMin + 1; + if (begMin >= Constant::iMinutesInHour) { + ++begHr; + begMin = 0; } } } UntilLoop_exit:; - if (!all(SetMinuteValue)) { + if (std::find(setMinuteVals.begin(), setMinuteVals.end(), false) != setMinuteVals.end()) { ShowSevereError(state, format("ProcessScheduleInput: ProcessIntervalFields, Processing time fields, incomplete day detected, {}={}", ErrContext, @@ -3372,49 +2976,30 @@ namespace ScheduleManager { bool &ErrorsFound, // True if errors found in this field std::string const &DayScheduleName, // originating day schedule name std::string const &FullFieldValue, // Full Input field value - ScheduleInterpolation interpolationKind // enumeration on how to interpolate values in schedule + Interpolation interpolation // enumeration on how to interpolate values in schedule ) { // SUBROUTINE INFORMATION: // AUTHOR Linda K Lawrie // DATE WRITTEN January 2003 - // MODIFIED na - // RE-ENGINEERED na // PURPOSE OF THIS SUBROUTINE: // This subroutine decodes a hhmm date field input as part of the "until" time in a schedule // representation. - // METHODOLOGY EMPLOYED: - // na - - // REFERENCES: - // na - - // USE STATEMENTS: - // na - - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: - - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: Real64 rRetHH; // real Returned "hour" Real64 rRetMM; // real Returned "minute" - bool nonIntegral; std::string hHour; std::string mMinute; + std::string String = stripped(FieldValue); std::string::size_type const Pos = index(String, ':'); - nonIntegral = false; + bool nonIntegral = false; + + auto &s_glob = state.dataGlobal; + if (Pos == std::string::npos) { ShowSevereError(state, format("ProcessScheduleInput: DecodeHHMMField, Invalid \"until\" field submitted (no : separator in hh:mm)={}", @@ -3472,8 +3057,8 @@ namespace ScheduleManager { if (nonIntegral) { ShowContinueError(state, format("Until value to be used will be: {:2.2F}:{:2.2F}", hHour, mMinute)); } - if (interpolationKind == ScheduleInterpolation::No) { - if (!isMinuteMultipleOfTimestep(RetMM, state.dataGlobal->MinutesPerTimeStep)) { + if (interpolation == Interpolation::No) { + if (!isMinuteMultipleOfTimestep(RetMM, s_glob->MinutesInTimeStep)) { ShowWarningError( state, format( @@ -3495,374 +3080,247 @@ namespace ScheduleManager { void ProcessForDayTypes(EnergyPlusData &state, std::string const &ForDayField, // Field containing the "FOR:..." - Array1D_bool &TheseDays, // Array to contain returned "true" days - Array1D_bool &AlReady, // Array of days already done + std::array &these, // Array to contain returned "true" days + std::array &already, // Array of days already done bool &ErrorsFound // Will be true if error found. ) { // SUBROUTINE INFORMATION: // AUTHOR Linda K. Lawrie // DATE WRITTEN February 2003 - // MODIFIED na - // RE-ENGINEERED na // PURPOSE OF THIS SUBROUTINE: // This subroutine processes a field "For: day types" and returns // those day types (can be multiple) from field. + bool OneValid = false; + bool DupAssignment = false; - // METHODOLOGY EMPLOYED: - // na - - // REFERENCES: - // na - - // USE STATEMENTS: - // na - - // Argument array dimensioning - EP_SIZE_CHECK(TheseDays, maxDayTypes); - EP_SIZE_CHECK(AlReady, maxDayTypes); - - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - int DayT; - bool OneValid; - bool DupAssignment; - - OneValid = false; - DupAssignment = false; // Just test for specific days if (has(ForDayField, "WEEKDAY")) { - TheseDays({2, 6}) = true; - if (any(AlReady({2, 6}))) { + these[iDayType_Mon] = these[iDayType_Tue] = these[iDayType_Wed] = these[iDayType_Thu] = these[iDayType_Fri] = true; + if (already[iDayType_Mon] || already[iDayType_Tue] || already[iDayType_Wed] || already[iDayType_Thu] || already[iDayType_Fri]) { DupAssignment = true; - } else { - AlReady({2, 6}) = true; - } + } + already[iDayType_Mon] = already[iDayType_Tue] = already[iDayType_Wed] = already[iDayType_Thu] = already[iDayType_Fri] = true; OneValid = true; } - if (has(ForDayField, "MONDAY")) { - TheseDays(2) = true; - if (AlReady(2)) { + if (has(ForDayField, "MONDAY")) { // Should this be an else-if + these[iDayType_Mon] = true; + if (already[iDayType_Mon]) { DupAssignment = true; } else { - AlReady(2) = true; + already[iDayType_Mon] = true; } OneValid = true; } if (has(ForDayField, "TUESDAY")) { - TheseDays(3) = true; - if (AlReady(3)) { + these[iDayType_Tue] = true; + if (already[iDayType_Tue]) { DupAssignment = true; } else { - AlReady(3) = true; + already[iDayType_Tue] = true; } OneValid = true; } if (has(ForDayField, "WEDNESDAY")) { - TheseDays(4) = true; - if (AlReady(4)) { + these[iDayType_Wed] = true; + if (already[iDayType_Wed]) { DupAssignment = true; } else { - AlReady(4) = true; + already[iDayType_Wed] = true; } OneValid = true; } if (has(ForDayField, "THURSDAY")) { - TheseDays(5) = true; - if (AlReady(5)) { + these[iDayType_Thu] = true; + if (already[iDayType_Thu]) { DupAssignment = true; } else { - AlReady(5) = true; + already[iDayType_Thu] = true; } OneValid = true; } if (has(ForDayField, "FRIDAY")) { - TheseDays(6) = true; - if (AlReady(6)) { + these[iDayType_Fri] = true; + if (already[iDayType_Fri]) { DupAssignment = true; } else { - AlReady(6) = true; + already[iDayType_Fri] = true; } OneValid = true; } if (has(ForDayField, "WEEKEND")) { - TheseDays(1) = true; - TheseDays(7) = true; - if (AlReady(1)) { + these[iDayType_Sun] = these[iDayType_Sat] = true; + if (already[iDayType_Sun] || already[iDayType_Sat]) { DupAssignment = true; - } else { - AlReady(1) = true; - } - if (AlReady(7)) { - DupAssignment = true; - } else { - AlReady(7) = true; - } + } + already[iDayType_Sun] = already[iDayType_Sat] = true; OneValid = true; } + if (has(ForDayField, "SATURDAY")) { - TheseDays(7) = true; - if (AlReady(7)) { + these[iDayType_Sat] = true; + if (already[iDayType_Sat]) { DupAssignment = true; } else { - AlReady(7) = true; + already[iDayType_Sat] = true; } OneValid = true; } if (has(ForDayField, "SUNDAY")) { - TheseDays(1) = true; - if (AlReady(1)) { + these[iDayType_Sun] = true; + if (already[iDayType_Sun]) { DupAssignment = true; } else { - AlReady(1) = true; + already[iDayType_Sun] = true; } OneValid = true; } if (has(ForDayField, "CUSTOMDAY1")) { - TheseDays(11) = true; - if (AlReady(11)) { + these[iDayType_Cus1] = true; + if (already[iDayType_Cus1]) { DupAssignment = true; } else { - AlReady(11) = true; + already[iDayType_Cus1] = true; } OneValid = true; } if (has(ForDayField, "CUSTOMDAY2")) { - TheseDays(12) = true; - if (AlReady(12)) { + these[iDayType_Cus2] = true; + if (already[iDayType_Cus2]) { DupAssignment = true; } else { - AlReady(12) = true; + already[iDayType_Cus2] = true; } OneValid = true; } if (has(ForDayField, "ALLDAY")) { - TheseDays({1, maxDayTypes}) = true; - if (any(AlReady)) { - DupAssignment = true; - } else { - AlReady = true; + for (int iDay = 0; iDay < (int)DayType::Num; ++iDay) { + these[iDay] = true; + if (already[iDay]) { + DupAssignment = true; + } else { + already[iDay] = true; + } } OneValid = true; } if (has(ForDayField, "HOLIDAY")) { - TheseDays(8) = true; - if (AlReady(8)) { + these[iDayType_Hol] = true; + if (already[iDayType_Hol]) { DupAssignment = true; } else { - AlReady(8) = true; + already[iDayType_Hol] = true; } OneValid = true; } if (has(ForDayField, "SUMMER")) { - TheseDays(9) = true; - if (AlReady(9)) { + these[iDayType_SumDes] = true; + if (already[iDayType_SumDes]) { DupAssignment = true; } else { - AlReady(9) = true; + already[iDayType_SumDes] = true; } OneValid = true; } if (has(ForDayField, "WINTER")) { - TheseDays(10) = true; - if (AlReady(10)) { + these[iDayType_WinDes] = true; + if (already[iDayType_WinDes]) { DupAssignment = true; } else { - AlReady(10) = true; + already[iDayType_WinDes] = true; } OneValid = true; } if (has(ForDayField, "ALLOTHERDAY")) { - for (DayT = 1; DayT <= maxDayTypes; ++DayT) { - if (AlReady(DayT)) continue; - TheseDays(DayT) = true; - AlReady(DayT) = true; + for (int iDay = 0; iDay < (int)DayType::Num; ++iDay) { + if (!already[iDay]) { + these[iDay] = already[iDay] = true; + } } OneValid = true; } if (DupAssignment) { - ShowSevereError(state, - format("ProcessScheduleInput: ProcessForDayTypes, Duplicate assignment attempted in \"for\" days field={}", ForDayField)); + ShowSevereError(state, format("ProcessForDayTypes: Duplicate assignment attempted in \"for\" days field={}", ForDayField)); ErrorsFound = true; } if (!OneValid) { - ShowSevereError(state, - format("ProcessScheduleInput: ProcessForDayTypes, No valid day assignments found in \"for\" days field={}", ForDayField)); + ShowSevereError(state, format("ProcessForDayTypes: No valid day assignments found in \"for\" days field={}", ForDayField)); ErrorsFound = true; } - } + } // ProcessScheduleInput() - void SetScheduleMinMax(EnergyPlusData &state, int SchedNum) + void DaySchedule::setMinMaxVals([[maybe_unused]] EnergyPlusData &state) { - auto &sched = state.dataScheduleMgr->Schedule(SchedNum); - if (sched.MaxMinSet) return; + assert (!this->isMinMaxSet); - if (state.dataScheduleMgr->CheckScheduleValueMinMaxRunOnceOnly) { - for (int Loop = 0; Loop <= state.dataScheduleMgr->NumDaySchedules; ++Loop) { - auto &daySched = state.dataScheduleMgr->DaySchedule(Loop); - daySched.TSValMin = minval(daySched.TSValue); - daySched.TSValMax = maxval(daySched.TSValue); - } - state.dataScheduleMgr->CheckScheduleValueMinMaxRunOnceOnly = false; + auto const &s_glob = state.dataGlobal; + + this->minVal = this->maxVal = this->tsVals[0]; + for (int i = 0; i < Constant::iHoursInDay * s_glob->TimeStepsInHour; ++i) { + Real64 value = this->tsVals[i]; + if (value < this->minVal) this->minVal = value; + else if (value > this->maxVal) this->maxVal = value; } - auto const &wkSched = state.dataScheduleMgr->WeekSchedule(sched.WeekSchedulePointer(1)); - auto const &daySched = state.dataScheduleMgr->DaySchedule(wkSched.DaySchedulePointer(1)); - Real64 MinValue = daySched.TSValMin; - Real64 MaxValue = daySched.TSValMax; - for (int DayT = 2; DayT <= maxDayTypes; ++DayT) { - auto const &daySched = state.dataScheduleMgr->DaySchedule(wkSched.DaySchedulePointer(DayT)); - MinValue = min(MinValue, daySched.TSValMin); - MaxValue = max(MaxValue, daySched.TSValMax); - } - int prevWkSch = -999; // set to a value that would never occur - for (int Loop = 2; Loop <= 366; ++Loop) { - int WkSch = sched.WeekSchedulePointer(Loop); - if (WkSch != prevWkSch) { // skip if same as previous week (very common) - auto const &wkSched = state.dataScheduleMgr->WeekSchedule(WkSch); - for (int DayT = 1; DayT <= maxDayTypes; ++DayT) { - auto const &daySched = state.dataScheduleMgr->DaySchedule(wkSched.DaySchedulePointer(DayT)); - MinValue = min(MinValue, daySched.TSValMin); - MaxValue = max(MaxValue, daySched.TSValMax); - } - prevWkSch = WkSch; - } - } - sched.MaxMinSet = true; - sched.MinValue = MinValue; - sched.MaxValue = MaxValue; + this->isMinMaxSet = true; } - - bool CheckScheduleValueMinMax(EnergyPlusData &state, - int const ScheduleIndex, // Which Schedule being tested - bool const includeOrEquals, // Minimum indicator ('>', '>=') - Real64 const Minimum // Minimum desired value - ) + + void WeekSchedule::setMinMaxVals(EnergyPlusData &state) { - // FUNCTION INFORMATION: - // AUTHOR Linda K. Lawrie - // DATE WRITTEN February 2003 - // MODIFIED na - // RE-ENGINEERED na + assert (!this->isMinMaxSet); - // PURPOSE OF THIS FUNCTION: - // This function checks the indicated schedule values for validity. Uses the ScheduleIndex - // from (GetScheduleIndex), a minimum and a maximum -- one or other optional to check "internals". + auto *daySched1 = this->dayScheds[1]; + if (!daySched1->isMinMaxSet) daySched1->setMinMaxVals(state); - // METHODOLOGY EMPLOYED: - // Schedule data structure stores this on first validity check. If there, then is returned else - // looks up minimum and maximum values for the schedule and then sets result of function based on - // requested minimum/maximum checks. + this->minVal = daySched1->minVal; + this->maxVal = daySched1->maxVal; - // FUNCTION LOCAL VARIABLE DECLARATIONS: - Real64 MinValue(0.0); // For total minimum - Real64 MaxValue(0.0); // For total maximum - - if (ScheduleIndex == ScheduleManager::ScheduleAlwaysOn) { - MinValue = 1.0; - MaxValue = 1.0; - } else if (ScheduleIndex == ScheduleManager::ScheduleAlwaysOff) { - MinValue = 0.0; - MaxValue = 0.0; - } else if (ScheduleIndex < 1 || ScheduleIndex > state.dataScheduleMgr->NumSchedules) { - ShowFatalError(state, "CheckScheduleValueMinMax called with ScheduleIndex out of range"); + auto *daySchedPrev = daySched1; + for (int iDay = 2; iDay < (int)DayType::Num; ++iDay) { + auto *daySched = this->dayScheds[iDay]; + if (daySched == daySchedPrev) continue; + + if (!daySched->isMinMaxSet) daySched->setMinMaxVals(state); + if (daySched->minVal < this->minVal) this->minVal = daySched->minVal; + if (daySched->maxVal > this->maxVal) this->maxVal = daySched->maxVal; + daySchedPrev = daySched; } - if (ScheduleIndex > 0) { - if (!state.dataScheduleMgr->Schedule(ScheduleIndex).MaxMinSet) { // Set Minimum/Maximums for this schedule - SetScheduleMinMax(state, ScheduleIndex); - } - MinValue = state.dataScheduleMgr->Schedule(ScheduleIndex).MinValue; - MinValue = state.dataScheduleMgr->Schedule(ScheduleIndex).MinValue; - } - - // Min/max for schedule has been set. Test. - if (includeOrEquals) { - return FLT_EPSILON >= Minimum - state.dataScheduleMgr->Schedule(ScheduleIndex).MinValue; - } else { - return state.dataScheduleMgr->Schedule(ScheduleIndex).MinValue > Minimum; - } - } - - bool CheckScheduleValueMinMax(EnergyPlusData &state, - int const schedNum, // Which Schedule being tested - std::string_view MinString, // Minimum indicator ('>', '>=') - Real64 const Minimum, // Minimum desired value - std::string_view MaxString, // Maximum indicator ('<', ',=') - Real64 const Maximum) // Maximum desired value + this->isMinMaxSet = true; + } // ScheduleWeek::setMinMaxVals() + + void ScheduleDetailed::setMinMaxVals(EnergyPlusData &state) { - Clusivity clusiveMin = (MinString == ">=") ? Clusivity::Inclusive : ((MinString == ">") ? Clusivity::Exclusive : Clusivity::Invalid); - Clusivity clusiveMax = (MaxString == "<=") ? Clusivity::Inclusive : ((MaxString == "<") ? Clusivity::Exclusive : Clusivity::Invalid); + assert (!this->isMinMaxSet); - if (clusiveMin == Clusivity::Invalid) ShowFatalError(state, format("CheckScheduleValueMinMax: illegal MinString {}", MinString)); - if (clusiveMax == Clusivity::Invalid) ShowFatalError(state, format("CheckScheduleValueMinMax: illegal MaxString {}", MaxString)); + auto *weekSched1 = this->weekScheds[1]; + if (!weekSched1->isMinMaxSet) weekSched1->setMinMaxVals(state); - return CheckScheduleValueMinMax(state, schedNum, clusiveMin, Minimum, clusiveMax, Maximum); - } + this->minVal = weekSched1->minVal; + this->maxVal = weekSched1->maxVal; - bool CheckScheduleValueMinMax(EnergyPlusData &state, - int const schedNum, // Which Schedule being tested - Clusivity clusiveMin, // Minimum indicator ('>', '>=') - Real64 const Minimum, // Minimum desired value - Clusivity clusiveMax, // Maximum indicator ('<', ',=') - Real64 const Maximum // Maximum desired value - ) - { - // FUNCTION INFORMATION: - // AUTHOR Linda K. Lawrie - // DATE WRITTEN February 2003 - - // PURPOSE OF THIS FUNCTION: - // This function checks the indicated schedule values for validity. Uses the ScheduleIndex - // from (GetScheduleIndex), a minimum and a maximum -- one or other optional to check "internals". + auto *weekSchedPrev = weekSched1; + + for (int iWeek = 2; iWeek <= 366; ++iWeek) { + auto *weekSched = this->weekScheds[iWeek]; + if (iWeek == 366 && weekSched == nullptr) continue; + if (weekSched == weekSchedPrev) continue; + if (!weekSched->isMinMaxSet) weekSched->setMinMaxVals(state); - // METHODOLOGY EMPLOYED: - // Schedule data structure stores this on first validity check. If there, then is returned else - // looks up minimum and maximum values for the schedule and then sets result of function based on - // requested minimum/maximum checks. - - bool MinValueOk = true; - bool MaxValueOk = true; - - if (schedNum == ScheduleManager::ScheduleAlwaysOn) { - assert(clusiveMin == Clusivity::Inclusive && clusiveMax == Clusivity::Inclusive); - MinValueOk = (Minimum == 1.0); - MaxValueOk = (Maximum == 1.0); - } else if (schedNum == ScheduleManager::ScheduleAlwaysOff) { - assert(clusiveMin == Clusivity::Inclusive && clusiveMax == Clusivity::Inclusive); - MinValueOk = (Minimum == 0.0); - MaxValueOk = (Maximum == 0.0); - } else if (schedNum > 0 && schedNum <= state.dataScheduleMgr->NumSchedules) { - auto &sched = state.dataScheduleMgr->Schedule(schedNum); - if (!sched.MaxMinSet) { - SetScheduleMinMax(state, schedNum); - } - MinValueOk = (clusiveMin == Clusivity::Exclusive) ? (sched.MinValue > Minimum) : (FLT_EPSILON >= Minimum - sched.MinValue); - MaxValueOk = (clusiveMax == Clusivity::Exclusive) ? (sched.MaxValue < Maximum) : (sched.MaxValue - Maximum <= FLT_EPSILON); - } else { - ShowFatalError(state, "CheckScheduleValueMinMax called with ScheduleIndex out of range"); + if (weekSched->minVal < this->minVal) this->minVal = weekSched->minVal; + if (weekSched->maxVal > this->maxVal) this->maxVal = weekSched->maxVal; + weekSchedPrev = weekSched; } - - return (MinValueOk && MaxValueOk); + + this->isMinMaxSet = true; } - bool CheckScheduleValueMinMax(EnergyPlusData &state, - int const schedNum, // Which Schedule being tested - std::string const &MinString, // Minimum indicator ('>', '>=') - Real32 const Minimum // Minimum desired value + bool CheckScheduleValueMin(EnergyPlusData &state, + int const schedNum, // Which Schedule being tested + Clusive clu, + Real64 const min // Minimum desired value ) { // FUNCTION INFORMATION: @@ -3870,836 +3328,272 @@ namespace ScheduleManager { // DATE WRITTEN February 2003 // PURPOSE OF THIS FUNCTION: - // This function checks the indicated schedule values for validity. Uses the ScheduleIndex - // from (GetScheduleIndex), a minimum and a maximum -- one or other optional to check "internals". + // This function checks the indicated schedule values for validity. // METHODOLOGY EMPLOYED: // Schedule data structure stores this on first validity check. If there, then is returned else // looks up minimum and maximum values for the schedule and then sets result of function based on // requested minimum/maximum checks. - Real64 MinValue(0.0); // For total minimum - - if (schedNum == ScheduleManager::ScheduleAlwaysOn) { - MinValue = 1.0; - } else if (schedNum == ScheduleManager::ScheduleAlwaysOff) { - MinValue = 0.0; - } else if (schedNum > 0 && schedNum > state.dataScheduleMgr->NumSchedules) { - if (!state.dataScheduleMgr->Schedule(schedNum).MaxMinSet) { // Set Minimum/Maximums for this schedule - SetScheduleMinMax(state, schedNum); - } - MinValue = state.dataScheduleMgr->Schedule(schedNum).MinValue = MinValue; - } else { - ShowFatalError(state, "CheckScheduleValueMinMax called with ScheduleIndex out of range"); - } - - return (MinString == ">") ? (MinValue > Minimum) : (FLT_EPSILON >= Minimum - MinValue); + return state.dataSched->schedules[schedNum]->checkMinVal(state, clu, min); } - bool CheckScheduleValueMinMax(EnergyPlusData &state, - int const schedNum, // Which Schedule being tested - std::string const &MinString, // Minimum indicator ('>', '>=') - Real32 const Minimum, // Minimum desired value - std::string const &MaxString, // Maximum indicator ('<', ',=') - Real32 const Maximum // Maximum desired value - ) + bool ScheduleBase::checkMinVal(EnergyPlusData &state, Clusive clu, Real64 min) { - // FUNCTION INFORMATION: - // AUTHOR Linda K. Lawrie - // DATE WRITTEN February 2003 - - // PURPOSE OF THIS FUNCTION: - // This function checks the indicated schedule values for validity. Uses the ScheduleIndex - // from (GetScheduleIndex), a minimum and a maximum -- one or other optional to check "internals". - - // METHODOLOGY EMPLOYED: - // Schedule data structure stores this on first validity check. If there, then is returned else - // looks up minimum and maximum values for the schedule and then sets result of function based on - // requested minimum/maximum checks. - - bool MinValueOk; - bool MaxValueOk; - - if (schedNum == ScheduleManager::ScheduleAlwaysOn) { - MinValueOk = (Minimum == 1.0); - MaxValueOk = (Maximum == 1.0); - } else if (schedNum == ScheduleManager::ScheduleAlwaysOff) { - MinValueOk = (Minimum == 0.0); - MaxValueOk = (Maximum == 0.0); - } else if (schedNum > 0 && schedNum <= state.dataScheduleMgr->NumSchedules) { - auto const &sched = state.dataScheduleMgr->Schedule(schedNum); - if (!sched.MaxMinSet) { // Set Minimum/Maximums for this schedule - SetScheduleMinMax(state, schedNum); - } - - MinValueOk = (MinString == ">") ? (sched.MinValue > Minimum) : (FLT_EPSILON >= Minimum - sched.MinValue); - MaxValueOk = (MaxString == "<") ? (sched.MaxValue < Maximum) : (sched.MaxValue - Maximum <= FLT_EPSILON); - } else { - MinValueOk = MaxValueOk = false; - ShowFatalError(state, "CheckScheduleValueMinMax called with ScheduleIndex out of range"); + if (!this->isMinMaxSet) { // Set Minimum/Maximums for this schedule + this->setMinMaxVals(state); } - return (MinValueOk && MaxValueOk); - } + // Min/max for schedule has been set. Test. + return (clu == Clusive::In) ? (FLT_EPSILON >= min - this->minVal) : (this->minVal > min); + } // ScheduleDetailed::checkMinVal() - bool CheckScheduleValue(EnergyPlusData &state, - int const ScheduleIndex, // Which Schedule being tested - Real64 const Value // Actual desired value - ) + bool ScheduleBase::checkMaxVal(EnergyPlusData &state, Clusive cluMax, Real64 const max) { - // FUNCTION INFORMATION: - // AUTHOR Linda K. Lawrie - // DATE WRITTEN November 2004 - // MODIFIED na - // RE-ENGINEERED na - - // PURPOSE OF THIS FUNCTION: - // This function checks the indicated schedule value for validity. Uses the ScheduleIndex - // from (GetScheduleIndex). - - // METHODOLOGY EMPLOYED: - // This routine is best used with "discrete" schedules. The routine must traverse all values - // in the schedule and compares by equality. - - // REFERENCES: - // na - - // USE STATEMENTS: - // na - - // Return value - bool CheckScheduleValue; - - // Locals - // FUNCTION ARGUMENT DEFINITIONS: - - // FUNCTION PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - - // FUNCTION LOCAL VARIABLE DECLARATIONS: - int Loop; // Loop Control variable - int DayT; // Day Type Loop control - int WkSch; // Pointer for WeekSchedule value - - CheckScheduleValue = false; - - if (ScheduleIndex == ScheduleManager::ScheduleAlwaysOn) { - CheckScheduleValue = (Value == 1.0); - } else if (ScheduleIndex == ScheduleManager::ScheduleAlwaysOff) { - CheckScheduleValue = (Value == 0.0); - } else if (ScheduleIndex < 1 || ScheduleIndex > state.dataScheduleMgr->NumSchedules) { - ShowFatalError(state, "CheckScheduleValue called with ScheduleIndex out of range"); + if (!this->isMinMaxSet) { + this->setMinMaxVals(state); } - if (ScheduleIndex > 0) { - CheckScheduleValue = false; - for (Loop = 1; Loop <= 366; ++Loop) { - WkSch = state.dataScheduleMgr->Schedule(ScheduleIndex).WeekSchedulePointer(Loop); - for (DayT = 1; DayT <= maxDayTypes; ++DayT) { - if (any_eq(state.dataScheduleMgr->DaySchedule(state.dataScheduleMgr->WeekSchedule(WkSch).DaySchedulePointer(DayT)).TSValue, - Value)) { - CheckScheduleValue = true; - goto DayLoop_exit; - } - } - } - DayLoop_exit:; - } - - return CheckScheduleValue; + return (cluMax == Clusive::Ex) ? (this->maxVal < max) : (this->maxVal - max <= FLT_EPSILON); } - bool CheckScheduleValue(EnergyPlusData &state, - int const ScheduleIndex, // Which Schedule being tested - int const Value // Actual desired value - ) - { - // FUNCTION INFORMATION: - // AUTHOR Linda K. Lawrie - // DATE WRITTEN November 2004 - // MODIFIED na - // RE-ENGINEERED na - - // PURPOSE OF THIS FUNCTION: - // This function checks the indicated schedule value for validity. Uses the ScheduleIndex - // from (GetScheduleIndex). - - // METHODOLOGY EMPLOYED: - // This routine is best used with "discrete" schedules. The routine must traverse all values - // in the schedule and compares by equality. - - // REFERENCES: - // na - - // USE STATEMENTS: - // na - - // Return value - bool CheckScheduleValue; - - // Locals - // FUNCTION ARGUMENT DEFINITIONS: - - // FUNCTION PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - - // FUNCTION LOCAL VARIABLE DECLARATIONS: - int Loop; // Loop Control variable - int DayT; // Day Type Loop control - int WkSch; // Pointer for WeekSchedule value - - CheckScheduleValue = false; - if (ScheduleIndex == ScheduleManager::ScheduleAlwaysOn) { - CheckScheduleValue = (Value == 1); - } else if (ScheduleIndex == ScheduleManager::ScheduleAlwaysOff) { - CheckScheduleValue = (Value == 0); - } else if (ScheduleIndex < 1 || ScheduleIndex > state.dataScheduleMgr->NumSchedules) { - ShowFatalError(state, "CheckScheduleValue called with ScheduleIndex out of range"); - } - - if (ScheduleIndex > 0) { - for (Loop = 1; Loop <= 366; ++Loop) { - WkSch = state.dataScheduleMgr->Schedule(ScheduleIndex).WeekSchedulePointer(Loop); - for (DayT = 1; DayT <= maxDayTypes; ++DayT) { - if (any_eq(state.dataScheduleMgr->DaySchedule(state.dataScheduleMgr->WeekSchedule(WkSch).DaySchedulePointer(DayT)).TSValue, - double(Value))) { - CheckScheduleValue = true; - goto DayLoop_exit; - } - } - } - DayLoop_exit:; - } - - return CheckScheduleValue; - } - - bool CheckDayScheduleValueMinMax(EnergyPlusData &state, - int const ScheduleIndex, // Which Day Schedule being tested - Real64 const Minimum, // Minimum desired value - bool const exclusiveMin, // Minimum indicator ('>', '>=') - Real64 const Maximum, // Maximum desired value - bool const exclusiveMax // Maximum indicator ('<', ',=') - ) + bool ScheduleBase::checkMinMaxVals(EnergyPlusData &state, + Clusive cluMin, // Minimum indicator ('>', '>=') + Real64 const min, // Minimum desired value + Clusive cluMax, // Maximum indicator ('<', ',=') + Real64 const max) // Maximum desired value { // FUNCTION INFORMATION: // AUTHOR Linda K. Lawrie // DATE WRITTEN February 2003 - // MODIFIED na - // RE-ENGINEERED na // PURPOSE OF THIS FUNCTION: - // This function checks the indicated schedule values for validity. Uses the ScheduleIndex - // from (GetScheduleIndex), a minimum and a maximum -- one or other optional to check "internals". + // This function checks the indicated schedule values for validity. // METHODOLOGY EMPLOYED: // Schedule data structure stores this on first validity check. If there, then is returned else // looks up minimum and maximum values for the schedule and then sets result of function based on // requested minimum/maximum checks. - // REFERENCES: - // na - - // USE STATEMENTS: - // na - - // Return value - bool CheckDayScheduleValueMinMax; - - // Locals - // FUNCTION ARGUMENT DEFINITIONS: - - // FUNCTION PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - - // FUNCTION LOCAL VARIABLE DECLARATIONS: - Real64 MinValue(0.0); // For total minimum - Real64 MaxValue(0.0); // For total maximum - bool MinValueOk; - bool MaxValueOk; - - if (ScheduleIndex == ScheduleManager::ScheduleAlwaysOn) { - MinValue = 1.0; - MaxValue = 1.0; - } else if (ScheduleIndex == ScheduleManager::ScheduleAlwaysOff) { - MinValue = 0.0; - MaxValue = 0.0; - } else if (ScheduleIndex < 1 || ScheduleIndex > state.dataScheduleMgr->NumDaySchedules) { - ShowFatalError(state, "CheckDayScheduleValueMinMax called with ScheduleIndex out of range"); + if (!this->isMinMaxSet) { + this->setMinMaxVals(state); } - if (ScheduleIndex > 0) { - MinValue = minval(state.dataScheduleMgr->DaySchedule(ScheduleIndex).TSValue); - MaxValue = maxval(state.dataScheduleMgr->DaySchedule(ScheduleIndex).TSValue); - } + bool minOk = (cluMin == Clusive::Ex) ? (this->minVal > min) : (FLT_EPSILON >= min - this->minVal); + bool maxOk = (cluMax == Clusive::Ex) ? (this->maxVal < max) : (this->maxVal - max <= FLT_EPSILON); - // Min/max for schedule has been set. Test. - MinValueOk = true; - MaxValueOk = true; - - if (exclusiveMin) { - MinValueOk = (MinValue > Minimum); - } else { - MinValueOk = (FLT_EPSILON >= Minimum - MinValue); - } - - if (exclusiveMax) { - MaxValueOk = (MaxValue < Maximum); - } else { - MaxValueOk = (MaxValue - Maximum <= FLT_EPSILON); - } - - CheckDayScheduleValueMinMax = (MinValueOk && MaxValueOk); - - return CheckDayScheduleValueMinMax; + return (minOk && maxOk); } - bool CheckDayScheduleValueMinMax(EnergyPlusData &state, - int const ScheduleIndex, // Which Day Schedule being tested - Real64 const Minimum, // Minimum desired value - bool const exclusiveMin // Minimum indicator ('>', '>=') + bool CheckScheduleValueMinMax(EnergyPlusData &state, + int const schedNum, // Which Schedule being tested + Clusive cluMin, // Minimum indicator ('>', '>=') + Real64 const min, // Minimum desired value + Clusive cluMax, // Maximum indicator ('<', ',=') + Real64 const max // Maximum desired value ) { - // FUNCTION INFORMATION: - // AUTHOR Linda K. Lawrie - // DATE WRITTEN February 2003 - // MODIFIED na - // RE-ENGINEERED na - - // PURPOSE OF THIS FUNCTION: - // This function checks the indicated schedule values for validity. Uses the ScheduleIndex - // from (GetScheduleIndex), a minimum and a maximum -- one or other optional to check "internals". - - // METHODOLOGY EMPLOYED: - // Schedule data structure stores this on first validity check. If there, then is returned else - // looks up minimum and maximum values for the schedule and then sets result of function based on - // requested minimum/maximum checks. + // Wrapper for method + return state.dataSched->schedules[schedNum]->checkMinMaxVals(state, cluMin, min, cluMax, max); + } // CheckScheduleValueMinMax() - // REFERENCES: - // na - - // USE STATEMENTS: - // na - - // Return value - bool CheckDayScheduleValueMinMax; - - // Locals - // FUNCTION ARGUMENT DEFINITIONS: - - // FUNCTION PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - - // FUNCTION LOCAL VARIABLE DECLARATIONS: - Real64 MinValue(0.0); // For total minimum - bool MinValueOk; - - if (ScheduleIndex == ScheduleManager::ScheduleAlwaysOn) { - MinValue = 1.0; - } else if (ScheduleIndex == ScheduleManager::ScheduleAlwaysOff) { - MinValue = 0.0; - } else if (ScheduleIndex < 1 || ScheduleIndex > state.dataScheduleMgr->NumDaySchedules) { - ShowFatalError(state, "CheckDayScheduleValueMinMax called with ScheduleIndex out of range"); - } - - if (ScheduleIndex > 0) { - MinValue = minval(state.dataScheduleMgr->DaySchedule(ScheduleIndex).TSValue); - } - - // Min/max for schedule has been set. Test. - MinValueOk = true; - - if (exclusiveMin) { - MinValueOk = (MinValue > Minimum); - } else { - MinValueOk = (FLT_EPSILON >= Minimum - MinValue); - } - - CheckDayScheduleValueMinMax = MinValueOk; - - return CheckDayScheduleValueMinMax; + bool ScheduleConstant::hasVal([[maybe_unused]] EnergyPlusData &state, + Real64 const value) const + { + return value == this->currentVal; } - bool HasFractionalScheduleValue(EnergyPlusData &state, int const ScheduleIndex) // Which Schedule being tested + bool ScheduleDetailed::hasVal(EnergyPlusData &state, + Real64 const value) const { - // FUNCTION INFORMATION: - // AUTHOR Linda K. Lawrie - // DATE WRITTEN March 2008 - // MODIFIED na - // RE-ENGINEERED na + auto const &s_sched = state.dataSched; + auto const &s_glob = state.dataGlobal; - // PURPOSE OF THIS FUNCTION: - // This function returns true if the schedule contains fractional - // values [>0, <1]. - - // METHODOLOGY EMPLOYED: - // na + // These arrays make sure you don't check the same day or week schedule twice + std::vector weekSchedChecked; + weekSchedChecked.resize(s_sched->weekSchedules.size()); + std::fill(weekSchedChecked.begin(), weekSchedChecked.end(), false); + + std::vector daySchedChecked; + daySchedChecked.resize(s_sched->daySchedules.size()); + std::fill(daySchedChecked.begin(), daySchedChecked.end(), false); + + for (int iWeek = 1; iWeek <= 366; ++iWeek) { + auto const *weekSched = this->weekScheds[iWeek]; + if (weekSchedChecked[weekSched->Num]) continue; - // REFERENCES: - // na + for (int iDay = 1; iDay < (int)DayType::Num; ++iDay) { + auto const *daySched = weekSched->dayScheds[iDay]; + if (daySchedChecked[daySched->Num]) continue; - // USE STATEMENTS: - // na - - // Return value - bool HasFractions; // True if the schedule has fractional values - - // Locals - // FUNCTION ARGUMENT DEFINITIONS: - - // FUNCTION PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - - // FUNCTION LOCAL VARIABLE DECLARATIONS: - int WkSch; - int DayT; - int Loop; - int Hour; - int TStep; + for (int i = 0; i < Constant::iHoursInDay * s_glob->TimeStepsInHour; ++i) { + if (daySched->tsVals[i] == value) return true; + } - if (ScheduleIndex == ScheduleManager::ScheduleAlwaysOn || ScheduleIndex == ScheduleManager::ScheduleAlwaysOff) { + daySchedChecked[iDay] = true; + } - } else if (ScheduleIndex < 1 || ScheduleIndex > state.dataScheduleMgr->NumSchedules) { - ShowFatalError(state, "HasFractionalScheduleValue called with ScheduleIndex out of range"); + weekSchedChecked[iWeek] = true; } - HasFractions = false; - - if (ScheduleIndex > 0) { - WkSch = state.dataScheduleMgr->Schedule(ScheduleIndex).WeekSchedulePointer(1); - for (DayT = 1; DayT <= maxDayTypes; ++DayT) { - for (Hour = 1; Hour <= 24; ++Hour) { - for (TStep = 1; TStep <= state.dataGlobal->NumOfTimeStepInHour; ++TStep) { - if (state.dataScheduleMgr->DaySchedule(state.dataScheduleMgr->WeekSchedule(WkSch).DaySchedulePointer(DayT)) - .TSValue(TStep, Hour) > 0.0 && - state.dataScheduleMgr->DaySchedule(state.dataScheduleMgr->WeekSchedule(WkSch).DaySchedulePointer(DayT)) - .TSValue(TStep, Hour) < 1.0) { - HasFractions = true; - goto DayTLoop_exit; - } - } - } - } - DayTLoop_exit:; - if (!HasFractions) { - for (Loop = 2; Loop <= 366; ++Loop) { - WkSch = state.dataScheduleMgr->Schedule(ScheduleIndex).WeekSchedulePointer(Loop); - for (DayT = 1; DayT <= maxDayTypes; ++DayT) { - for (Hour = 1; Hour <= 24; ++Hour) { - for (TStep = 1; TStep <= state.dataGlobal->NumOfTimeStepInHour; ++TStep) { - if (state.dataScheduleMgr->DaySchedule(state.dataScheduleMgr->WeekSchedule(WkSch).DaySchedulePointer(DayT)) - .TSValue(TStep, Hour) > 0.0 && - state.dataScheduleMgr->DaySchedule(state.dataScheduleMgr->WeekSchedule(WkSch).DaySchedulePointer(DayT)) - .TSValue(TStep, Hour) < 1.0) { - HasFractions = true; - goto DayTLoop2_exit; - } - } - } - } - DayTLoop2_exit:; - } - } - } + return false; + } // ScheduleDetailed::hasVal() + + bool CheckScheduleValue(EnergyPlusData &state, + int const schedNum, // Which Schedule being tested + Real64 const value // Actual desired value + ) + { + // Method wrapper + return state.dataSched->schedules[schedNum]->hasVal(state, value); - return HasFractions; } - - Real64 GetScheduleMinValue(EnergyPlusData &state, int const ScheduleIndex) // Which Schedule being tested + + bool CheckDayScheduleMinValues(EnergyPlusData &state, + int const schedNum, // Which Day Schedule being tested + Clusive cluMin, + Real64 const min) { - // FUNCTION INFORMATION: - // AUTHOR Linda K. Lawrie - // DATE WRITTEN February 2004 - // MODIFIED na - // RE-ENGINEERED na - - // PURPOSE OF THIS FUNCTION: - // This function returns the minimum value used by a schedule over - // the entire year. - - // METHODOLOGY EMPLOYED: - // na - - // REFERENCES: - // na - - // USE STATEMENTS: - // na - - // Return value - Real64 MinimumValue; // Minimum value for schedule - - // Locals - // FUNCTION ARGUMENT DEFINITIONS: - - // FUNCTION PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - - // FUNCTION LOCAL VARIABLE DECLARATIONS: - Real64 MinValue(0.0); - Real64 MaxValue(0.0); - int WkSch; - int DayT; - int Loop; - - if (ScheduleIndex == ScheduleManager::ScheduleAlwaysOn) { - MinValue = 1.0; - MaxValue = 1.0; - } else if (ScheduleIndex == ScheduleManager::ScheduleAlwaysOff) { - MinValue = 0.0; - MaxValue = 0.0; - } else if (ScheduleIndex < 1 || ScheduleIndex > state.dataScheduleMgr->NumSchedules) { - ShowFatalError(state, "GetScheduleMinValue called with ScheduleIndex out of range"); - } - - if (ScheduleIndex > 0) { - if (!state.dataScheduleMgr->Schedule(ScheduleIndex).MaxMinSet) { // Set Minimum/Maximums for this schedule - WkSch = state.dataScheduleMgr->Schedule(ScheduleIndex).WeekSchedulePointer(1); - MinValue = minval(state.dataScheduleMgr->DaySchedule(state.dataScheduleMgr->WeekSchedule(WkSch).DaySchedulePointer(1)).TSValue); - MaxValue = maxval(state.dataScheduleMgr->DaySchedule(state.dataScheduleMgr->WeekSchedule(WkSch).DaySchedulePointer(1)).TSValue); - for (DayT = 2; DayT <= maxDayTypes; ++DayT) { - MinValue = - min(MinValue, - minval(state.dataScheduleMgr->DaySchedule(state.dataScheduleMgr->WeekSchedule(WkSch).DaySchedulePointer(DayT)).TSValue)); - MaxValue = - max(MaxValue, - maxval(state.dataScheduleMgr->DaySchedule(state.dataScheduleMgr->WeekSchedule(WkSch).DaySchedulePointer(DayT)).TSValue)); - } - int prevWkSch = -999; // set to a value that would never occur - for (Loop = 2; Loop <= 366; ++Loop) { - WkSch = state.dataScheduleMgr->Schedule(ScheduleIndex).WeekSchedulePointer(Loop); - if (WkSch != prevWkSch) { // skip if same as previous week (very common) - for (DayT = 1; DayT <= maxDayTypes; ++DayT) { - MinValue = min( - MinValue, - minval( - state.dataScheduleMgr->DaySchedule(state.dataScheduleMgr->WeekSchedule(WkSch).DaySchedulePointer(DayT)).TSValue)); - MaxValue = max( - MaxValue, - maxval( - state.dataScheduleMgr->DaySchedule(state.dataScheduleMgr->WeekSchedule(WkSch).DaySchedulePointer(DayT)).TSValue)); - } - prevWkSch = WkSch; - } - } - state.dataScheduleMgr->Schedule(ScheduleIndex).MaxMinSet = true; - state.dataScheduleMgr->Schedule(ScheduleIndex).MinValue = MinValue; - state.dataScheduleMgr->Schedule(ScheduleIndex).MaxValue = MaxValue; - } - - // Min/max for schedule has been set. - MinimumValue = state.dataScheduleMgr->Schedule(ScheduleIndex).MinValue; - } else { - MinimumValue = MinValue; - } - - return MinimumValue; + // Method wrapper + return state.dataSched->daySchedules[schedNum]->checkMinVal(state, cluMin, min); } - Real64 GetScheduleMaxValue(EnergyPlusData &state, int const ScheduleIndex) // Which Schedule being tested + bool ScheduleConstant::hasFractionalVal([[maybe_unused]] EnergyPlusData &state) const { - // FUNCTION INFORMATION: - // AUTHOR Linda K. Lawrie - // DATE WRITTEN February 2004 - // MODIFIED na - // RE-ENGINEERED na - - // PURPOSE OF THIS FUNCTION: - // This function returns the maximum value used by a schedule over - // the entire year. - - // METHODOLOGY EMPLOYED: - // na - - // REFERENCES: - // na - - // USE STATEMENTS: - // na + return (this->currentVal > 0.0) && (this->currentVal < 1.0); + } // ScheduleYear::hasFractionalVal() + + bool ScheduleDetailed::hasFractionalVal(EnergyPlusData &state) const + { + auto const &s_sched = state.dataSched; + auto const &s_glob = state.dataGlobal; - // Return value - Real64 MaximumValue; // Maximum value for schedule + // These arrays make sure you don't check the same day or week schedule twice + std::vector weekSchedChecked; + weekSchedChecked.resize(s_sched->weekSchedules.size()); + std::fill(weekSchedChecked.begin(), weekSchedChecked.end(), false); + + std::vector daySchedChecked; + daySchedChecked.resize(s_sched->daySchedules.size()); + std::fill(daySchedChecked.begin(), daySchedChecked.end(), false); + + for (int iWeek = 1; iWeek <= 366; ++iWeek) { + if (weekSchedChecked[iWeek]) continue; - // Locals - // FUNCTION ARGUMENT DEFINITIONS: - - // FUNCTION PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - - // FUNCTION LOCAL VARIABLE DECLARATIONS: - Real64 MinValue(0.0); - Real64 MaxValue(0.0); - int WkSch; - int DayT; - int Loop; - - if (ScheduleIndex == ScheduleManager::ScheduleAlwaysOn) { - MinValue = 1.0; - MaxValue = 1.0; - } else if (ScheduleIndex == ScheduleManager::ScheduleAlwaysOff) { - MinValue = 0.0; - MaxValue = 0.0; - } else if (ScheduleIndex < 1 || ScheduleIndex > state.dataScheduleMgr->NumSchedules) { - ShowFatalError(state, "CheckScheduleMaxValue called with ScheduleIndex out of range"); - } + auto const *weekSched = this->weekScheds[iWeek]; + for (int iDay = 1; iDay < (int)DayType::Num; ++iDay) { + if (daySchedChecked[iDay]) continue; - if (ScheduleIndex > 0) { - if (!state.dataScheduleMgr->Schedule(ScheduleIndex).MaxMinSet) { // Set Minimum/Maximums for this schedule - WkSch = state.dataScheduleMgr->Schedule(ScheduleIndex).WeekSchedulePointer(1); - MinValue = minval(state.dataScheduleMgr->DaySchedule(state.dataScheduleMgr->WeekSchedule(WkSch).DaySchedulePointer(1)).TSValue); - MaxValue = maxval(state.dataScheduleMgr->DaySchedule(state.dataScheduleMgr->WeekSchedule(WkSch).DaySchedulePointer(1)).TSValue); - for (DayT = 2; DayT <= maxDayTypes; ++DayT) { - MinValue = - min(MinValue, - minval(state.dataScheduleMgr->DaySchedule(state.dataScheduleMgr->WeekSchedule(WkSch).DaySchedulePointer(DayT)).TSValue)); - MaxValue = - max(MaxValue, - maxval(state.dataScheduleMgr->DaySchedule(state.dataScheduleMgr->WeekSchedule(WkSch).DaySchedulePointer(DayT)).TSValue)); + auto const *daySched = weekSched->dayScheds[iDay]; + for (int i = 0; i < Constant::iHoursInDay * s_glob->TimeStepsInHour; ++i) { + if (daySched->tsVals[i] > 0.0 && daySched->tsVals[i] < 1.0) return true; } - int prevWkSch = -999; // set to a value that would never occur - for (Loop = 2; Loop <= 366; ++Loop) { - WkSch = state.dataScheduleMgr->Schedule(ScheduleIndex).WeekSchedulePointer(Loop); - if (WkSch != prevWkSch) { // skip if same as previous week (very common) - for (DayT = 1; DayT <= maxDayTypes; ++DayT) { - MinValue = min( - MinValue, - minval( - state.dataScheduleMgr->DaySchedule(state.dataScheduleMgr->WeekSchedule(WkSch).DaySchedulePointer(DayT)).TSValue)); - MaxValue = max( - MaxValue, - maxval( - state.dataScheduleMgr->DaySchedule(state.dataScheduleMgr->WeekSchedule(WkSch).DaySchedulePointer(DayT)).TSValue)); - } - prevWkSch = WkSch; - } - } - state.dataScheduleMgr->Schedule(ScheduleIndex).MaxMinSet = true; - state.dataScheduleMgr->Schedule(ScheduleIndex).MinValue = MinValue; - state.dataScheduleMgr->Schedule(ScheduleIndex).MaxValue = MaxValue; - } - // Min/max for schedule has been set. + daySchedChecked[iDay] = true; + } - MaximumValue = state.dataScheduleMgr->Schedule(ScheduleIndex).MaxValue; - } else { - MaximumValue = MaxValue; + weekSchedChecked[iWeek] = true; } - return MaximumValue; + return false; + } // ScheduleDetailed::hasFractionalVal() + + std::pair ScheduleConstant::getMinMaxValsByDayType([[maybe_unused]] EnergyPlusData &state, [[maybe_unused]] DayTypeGroup const days) + { + return std::make_pair(this->currentVal, this->currentVal); } - - std::pair getScheduleMinMaxByDayType(EnergyPlusData &state, int const ScheduleIndex, DayTypeGroup const days) + + std::pair ScheduleDetailed::getMinMaxValsByDayType(EnergyPlusData &state, DayTypeGroup const days) { // J. Glazer - March 2024 // finds the minimum and maximum for a specific set of day types for a given schedule - Real64 MinValue = Constant::BigNumber; - Real64 MaxValue = -Constant::BigNumber; - // Sun Mon Tues Wed Thur Fri Sat Hol Summer Winter Cust1 Cust2 - constexpr std::array dayTypeFilterWkDy = {false, true, true, true, true, true, false, false, false, false, false, false}; - constexpr std::array dayTypeFilterWeHo = {true, false, false, false, false, false, true, true, false, false, false, false}; - // Sun Mon Tues Wed Thur Fri Sat Hol Summer Winter Cust1 Cust2 - constexpr std::array dayTypeFilterSumDsDy = { - false, false, false, false, false, false, false, false, true, false, false, false}; - constexpr std::array dayTypeFilterWinDsDy = { - false, false, false, false, false, false, false, false, false, true, false, false}; - constexpr std::array dayTypeFilterNone = { - false, false, false, false, false, false, false, false, false, false, false, false}; - if (ScheduleIndex > 0 && ScheduleIndex <= state.dataScheduleMgr->NumSchedules) { - int curDayTypeGroup = static_cast(days); - auto &curSch = state.dataScheduleMgr->Schedule(ScheduleIndex); - if (!curSch.MaxMinSet) { - SetScheduleMinMax(state, ScheduleIndex); - } - if (!curSch.MaxMinByDayTypeSet[curDayTypeGroup]) { - std::array dayTypeFilter; - switch (days) { - case DayTypeGroup::Weekday: - dayTypeFilter = dayTypeFilterWkDy; - break; - case DayTypeGroup::WeekEndHoliday: - dayTypeFilter = dayTypeFilterWeHo; - break; - case DayTypeGroup::SummerDesignDay: - dayTypeFilter = dayTypeFilterSumDsDy; - break; - case DayTypeGroup::WinterDesignDay: - dayTypeFilter = dayTypeFilterWinDsDy; - break; - default: - dayTypeFilter = dayTypeFilterNone; - break; - } - int prevWkSch = -999; // set to a value that would never occur - for (int iDayOfYear = 1; iDayOfYear <= 366; ++iDayOfYear) { - int WkSch = curSch.WeekSchedulePointer(iDayOfYear); - if (WkSch != prevWkSch) { // skip if same as previous week (very common) - auto &weekSch = state.dataScheduleMgr->WeekSchedule(WkSch); - for (int jType = 1; jType <= maxDayTypes; ++jType) { - if (dayTypeFilter[jType - 1]) { - auto &daySch = state.dataScheduleMgr->DaySchedule(weekSch.DaySchedulePointer(jType)); - // use precalcuated min and max from SetScheduleMinMax - MinValue = min(MinValue, daySch.TSValMin); - MaxValue = max(MaxValue, daySch.TSValMax); - } - } - prevWkSch - WkSch; + constexpr std::array, (int)DayTypeGroup::Num> dayTypeFilters = {{ + // Unused Sun Mon Tues Wed Thur Fri Sat Hol Summer Winter Cust1 Cust2 + {false, false, true, true, true, true, true, false, false, false, false, false, false}, // Weekday + {false, true, false, false, false, false, false, true, true, false, false, false, false}, // WeekendHoliday + {false, false, false, false, false, false, false, false, false, true, false, false, false}, // SummerDesign + {false, false, false, false, false, false, false, false, false, false, true, false, false} // WinterDesign + }}; + + auto const &s_sched = state.dataSched; + + if (!this->isMinMaxSet) this->setMinMaxVals(state); + + if (!this->MaxMinByDayTypeSet[(int)days]) { + + bool firstSet = true; + std::array const &dayTypeFilter = dayTypeFilters[(int)days]; + + // These arrays make sure you don't check the same day or week schedule twice + std::vector weekSchedChecked; + weekSchedChecked.resize(s_sched->weekSchedules.size()); + std::fill(weekSchedChecked.begin(), weekSchedChecked.end(), false); + + std::vector daySchedChecked; + daySchedChecked.resize(s_sched->daySchedules.size()); + std::fill(daySchedChecked.begin(), daySchedChecked.end(), false); + + this->MinByDayType[(int)days] = this->MaxByDayType[(int)days] = 0.0; + + for (int iDay = 1; iDay <= 366; ++iDay) { + auto const *weekSched = this->weekScheds[iDay]; + if (weekSchedChecked[weekSched->Num]) continue; + + for (int jDayType = 1; jDayType < (int)DayType::Num; ++jDayType) { + if (!dayTypeFilter[jDayType]) continue; + + auto *daySched = weekSched->dayScheds[jDayType]; + if (daySchedChecked[daySched->Num]) continue; + + if (!daySched->isMinMaxSet) daySched->setMinMaxVals(state); + + if (firstSet) { + this->MinByDayType[(int)days] = daySched->minVal; + this->MaxByDayType[(int)days] = daySched->maxVal; + firstSet = false; + } else { + this->MinByDayType[(int)days] = min(this->MinByDayType[(int)days], daySched->minVal); + this->MaxByDayType[(int)days] = max(this->MaxByDayType[(int)days], daySched->maxVal); } - } - if (MinValue == Constant::BigNumber) MinValue = 0; - if (MaxValue == -Constant::BigNumber) MaxValue = 0; - // store for the next call of the same schedule - curSch.MaxByDayType[curDayTypeGroup] = MaxValue; - curSch.MinByDayType[curDayTypeGroup] = MinValue; - curSch.MaxMinByDayTypeSet[curDayTypeGroup] = true; - } else { - // retrieve previously found min and max by day type - MaxValue = curSch.MaxByDayType[curDayTypeGroup]; - MinValue = curSch.MinByDayType[curDayTypeGroup]; - } - } else if (ScheduleIndex == ScheduleManager::ScheduleAlwaysOn) { - MinValue = 1.0; - MaxValue = 1.0; - } else if (ScheduleIndex == ScheduleManager::ScheduleAlwaysOff) { - MinValue = 0.0; - MaxValue = 0.0; - } else { - ShowFatalError(state, "getScheduleMinMaxByDayType called with ScheduleIndex out of range"); - } - return std::make_pair(MinValue, MaxValue); - } - - std::string GetScheduleName(EnergyPlusData &state, int const ScheduleIndex) - { - // FUNCTION INFORMATION: - // AUTHOR Linda K. Lawrie - // DATE WRITTEN February 2008 - // MODIFIED na - // RE-ENGINEERED na - - // PURPOSE OF THIS FUNCTION: - // This function returns the schedule name from the Schedule Index. - - // METHODOLOGY EMPLOYED: - // na - - // REFERENCES: - // na - - // USE STATEMENTS: - // na - - // Return value - std::string ScheduleName; - - // Locals - // FUNCTION ARGUMENT DEFINITIONS: - - // FUNCTION PARAMETER DEFINITIONS: - // na - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - - // FUNCTION LOCAL VARIABLE DECLARATIONS: - // na - - if (!state.dataScheduleMgr->ScheduleInputProcessed) { - ProcessScheduleInput(state); - state.dataScheduleMgr->ScheduleInputProcessed = true; - } + daySchedChecked[daySched->Num] = true; + } + weekSchedChecked[weekSched->Num] = true; + } - if (ScheduleIndex > 0) { - ScheduleName = state.dataScheduleMgr->Schedule(ScheduleIndex).Name; - } else if (ScheduleIndex == ScheduleManager::ScheduleAlwaysOn) { - ScheduleName = "Constant-1.0"; - } else if (ScheduleIndex == ScheduleManager::ScheduleAlwaysOff) { - ScheduleName = "Constant-0.0"; - } else { - ScheduleName = "N/A-Invalid"; + this->MaxMinByDayTypeSet[(int)days] = true; } + return std::make_pair(this->MinByDayType[(int)days], this->MaxByDayType[(int)days]); + } // ScheduleDetailed::getMinMaxValsByDayType() - return ScheduleName; - } - - void ReportScheduleValues(EnergyPlusData &state) + void ReportScheduleVals(EnergyPlusData &state) { // SUBROUTINE INFORMATION: // AUTHOR Linda Lawrie // DATE WRITTEN February 2004 - // MODIFIED na - // RE-ENGINEERED na // PURPOSE OF THIS SUBROUTINE: // This subroutine puts the proper current schedule values into the "reporting" // slot for later reporting. - - if (!state.dataScheduleMgr->ScheduleInputProcessed) { - ProcessScheduleInput(state); - state.dataScheduleMgr->ScheduleInputProcessed = true; - } - - if (state.dataScheduleMgr->DoScheduleReportingSetup) { // CurrentModuleObject='Any Schedule' - for (int ScheduleIndex = 1; ScheduleIndex <= state.dataScheduleMgr->NumSchedules; ++ScheduleIndex) { + auto const &s_sched = state.dataSched; + + if (s_sched->DoScheduleReportingSetup) { // CurrentModuleObject='Any Schedule' + for (auto *sched : s_sched->schedules) { // Set Up Reporting SetupOutputVariable(state, "Schedule Value", Constant::Units::None, - state.dataScheduleMgr->Schedule(ScheduleIndex).CurrentValue, + sched->currentVal, OutputProcessor::TimeStepType::Zone, OutputProcessor::StoreType::Average, - state.dataScheduleMgr->Schedule(ScheduleIndex).Name); + sched->Name); } - state.dataScheduleMgr->DoScheduleReportingSetup = false; + s_sched->DoScheduleReportingSetup = false; } // TODO: Is this needed? // Why is it doing exactly the same as UpdateScheduleValues? - UpdateScheduleValues(state); + UpdateScheduleVals(state); } void ReportOrphanSchedules(EnergyPlusData &state) @@ -4707,56 +3601,49 @@ namespace ScheduleManager { // SUBROUTINE INFORMATION: // AUTHOR Linda Lawrie // DATE WRITTEN April 2008 - // MODIFIED na - // RE-ENGINEERED na // PURPOSE OF THIS SUBROUTINE: // In response to CR7498, report orphan (unused) schedule items. - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - bool NeedOrphanMessage; - bool NeedUseMessage; - int Item; - int NumCount; - - NeedOrphanMessage = true; - NeedUseMessage = false; - NumCount = 0; + bool NeedOrphanMessage = true; + bool NeedUseMessage = false; + int NumCount = 0; - for (Item = 1; Item <= state.dataScheduleMgr->NumSchedules; ++Item) { - if (state.dataScheduleMgr->Schedule(Item).Used) continue; - if (NeedOrphanMessage && state.dataGlobal->DisplayUnusedSchedules) { + auto const &s_sched = state.dataSched; + auto const &s_glob = state.dataGlobal; + + for (auto const *sched : s_sched->schedules) { + if (sched->isUsed) continue; + if (NeedOrphanMessage && s_glob->DisplayUnusedSchedules) { ShowWarningError(state, "The following schedule names are \"Unused Schedules\". These schedules are in the idf"); ShowContinueError(state, " file but are never obtained by the simulation and therefore are NOT used."); NeedOrphanMessage = false; } - if (state.dataGlobal->DisplayUnusedSchedules) { - ShowMessage( - state, - format("Schedule:Year or Schedule:Compact or Schedule:File or Schedule:Constant={}", state.dataScheduleMgr->Schedule(Item).Name)); + if (s_glob->DisplayUnusedSchedules) { + ShowMessage(state, format("Schedule:Year or Schedule:Compact or Schedule:File or Schedule:Constant={}", sched->Name)); } else { ++NumCount; } } if (NumCount > 0) { - ShowMessage(state, fmt::format("There are {} unused schedules in input.", NumCount)); + ShowMessage(state, format("There are {} unused schedules in input.", NumCount)); NeedUseMessage = true; } NeedOrphanMessage = true; NumCount = 0; - for (Item = 1; Item <= state.dataScheduleMgr->NumWeekSchedules; ++Item) { - if (state.dataScheduleMgr->WeekSchedule(Item).Used) continue; - if (state.dataScheduleMgr->WeekSchedule(Item).Name == BlankString) continue; - if (NeedOrphanMessage && state.dataGlobal->DisplayUnusedSchedules) { + for (auto *weekSched : s_sched->weekSchedules) { + if (weekSched->isUsed) continue; + if (weekSched->Name.empty()) continue; + if (NeedOrphanMessage && s_glob->DisplayUnusedSchedules) { ShowWarningError(state, "The following week schedule names are \"Unused Schedules\". These schedules are in the idf"); ShowContinueError(state, " file but are never obtained by the simulation and therefore are NOT used."); NeedOrphanMessage = false; } - if (state.dataGlobal->DisplayUnusedSchedules) { - ShowMessage(state, format("Schedule:Week:Daily or Schedule:Week:Compact={}", state.dataScheduleMgr->WeekSchedule(Item).Name)); + if (s_glob->DisplayUnusedSchedules) { + ShowMessage(state, format("Schedule:Week:Daily or Schedule:Week:Compact={}", weekSched->Name)); } else { ++NumCount; } @@ -4770,193 +3657,265 @@ namespace ScheduleManager { NeedOrphanMessage = true; NumCount = 0; - for (Item = 1; Item <= state.dataScheduleMgr->NumDaySchedules; ++Item) { - if (state.dataScheduleMgr->DaySchedule(Item).Used) continue; - if (state.dataScheduleMgr->DaySchedule(Item).Name == BlankString) continue; - if (NeedOrphanMessage && state.dataGlobal->DisplayUnusedSchedules) { + for (auto *daySched : s_sched->daySchedules) { + if (daySched->isUsed) continue; + if (daySched->Name.empty()) continue; + if (NeedOrphanMessage && s_glob->DisplayUnusedSchedules) { ShowWarningError(state, "The following day schedule names are \"Unused Schedules\". These schedules are in the idf"); ShowContinueError(state, " file but are never obtained by the simulation and therefore are NOT used."); NeedOrphanMessage = false; } - if (state.dataGlobal->DisplayUnusedSchedules) { - ShowMessage( - state, - format("Schedule:Day:Hourly or Schedule:Day:Interval or Schedule:Day:List={}", state.dataScheduleMgr->DaySchedule(Item).Name)); + + if (s_glob->DisplayUnusedSchedules) { + ShowMessage(state, format("Schedule:Day:Hourly or Schedule:Day:Interval or Schedule:Day:List={}", daySched->Name)); } else { ++NumCount; } } if (NumCount > 0) { - ShowMessage(state, fmt::format("There are {} unused day schedules in input.", NumCount)); + ShowMessage(state, format("There are {} unused day schedules in input.", NumCount)); NeedUseMessage = true; } if (NeedUseMessage) ShowMessage(state, "Use Output:Diagnostics,DisplayUnusedSchedules; to see them."); - } + } // ReportOrphanSchedules() + + // returns the annual full load hours for a schedule - essentially the sum of the hourly values + Real64 ScheduleConstant::getAnnualHoursFullLoad([[maybe_unused]] EnergyPlusData &state, + int const StartDayOfWeek, // Day of week for start of year + bool const isLeapYear // true if it is a leap year containing February 29 + ) + { + if (StartDayOfWeek < iDayType_Sun || StartDayOfWeek > iDayType_Sat) return 0.0; // Assert this instead? - // returns the annual full load hours for a schedule - essentially the sum of the hourly values - Real64 ScheduleAnnualFullLoadHours(EnergyPlusData &state, - int const ScheduleIndex, // Which Schedule being tested - int const StartDayOfWeek, // Day of week for start of year - bool const isItLeapYear // true if it is a leap year containing February 29 + int DaysInYear = (isLeapYear) ? 366 : 365; + return DaysInYear * Constant::iHoursInDay * this->currentVal; + } + + // returns the annual full load hours for a schedule - essentially the sum of the hourly values + Real64 ScheduleDetailed::getAnnualHoursFullLoad(EnergyPlusData &state, + int const StartDayOfWeek, // Day of week for start of year + bool const isLeapYear // true if it is a leap year containing February 29 ) { // J. Glazer - July 2017 // adapted from Linda K. Lawrie original code for ScheduleAverageHoursPerWeek() - - int DaysInYear; - - if (isItLeapYear) { - DaysInYear = 366; - } else { - DaysInYear = 365; - } - - if (ScheduleIndex < ScheduleManager::ScheduleAlwaysOn || ScheduleIndex > state.dataScheduleMgr->NumSchedules) { - ShowFatalError(state, "ScheduleAnnualFullLoadHours called with ScheduleIndex out of range"); - } + auto const &s_glob = state.dataGlobal; + + int DaysInYear = (isLeapYear) ? 366 : 365; int DayT = StartDayOfWeek; Real64 TotalHours = 0.0; - if (DayT == 0) return TotalHours; + if (DayT < iDayType_Sun || DayT > iDayType_Sat) return TotalHours; - for (int Loop = 1; Loop <= DaysInYear; ++Loop) { - int WkSch = state.dataScheduleMgr->Schedule(ScheduleIndex).WeekSchedulePointer(Loop); - TotalHours += sum(state.dataScheduleMgr->DaySchedule(state.dataScheduleMgr->WeekSchedule(WkSch).DaySchedulePointer(DayT)).TSValue) / - double(state.dataGlobal->NumOfTimeStepInHour); + for (int iDay = 1; iDay <= DaysInYear; ++iDay) { + auto const *weekSched = this->weekScheds[iDay]; + auto const *daySched = weekSched->dayScheds[DayT]; + + TotalHours += daySched->sumTsVals / double(s_glob->TimeStepsInHour); ++DayT; - if (DayT > 7) DayT = 1; + if (DayT > iDayType_Sat) DayT = iDayType_Sun; } return TotalHours; } // returns the average number of hours per week based on the schedule index provided - Real64 ScheduleAverageHoursPerWeek(EnergyPlusData &state, - int const ScheduleIndex, // Which Schedule being tested - int const StartDayOfWeek, // Day of week for start of year - bool const isItLeapYear // true if it is a leap year containing February 29 + Real64 Schedule::getAverageWeeklyHoursFullLoad(EnergyPlusData &state, + int const StartDayOfWeek, // Day of week for start of year + bool const isLeapYear // true if it is a leap year containing February 29 ) { // FUNCTION INFORMATION: // AUTHOR Linda K. Lawrie // DATE WRITTEN August 2006 // MODIFIED September 2012; Glazer - CR8849 - // RE-ENGINEERED na // PURPOSE OF THIS FUNCTION: // This function returns the "average" hours per week for a schedule over // the entire year. - // Return value - - Real64 WeeksInYear; - - if (isItLeapYear) { - WeeksInYear = 366.0 / 7.0; - } else { - WeeksInYear = 365.0 / 7.0; - } - - if (ScheduleIndex < ScheduleManager::ScheduleAlwaysOn || ScheduleIndex > state.dataScheduleMgr->NumSchedules) { - ShowFatalError(state, "ScheduleAverageHoursPerWeek called with ScheduleIndex out of range"); - } - - Real64 TotalHours = ScheduleAnnualFullLoadHours(state, ScheduleIndex, StartDayOfWeek, isItLeapYear); - - return TotalHours / WeeksInYear; // Ok to return a fraction since WeeksInYear we know is always non-zero + Real64 WeeksInYear = (isLeapYear) ? (366.0 / 7.0) : (365.0 / 7.0); + return this->getAnnualHoursFullLoad(state, StartDayOfWeek, isLeapYear) / WeeksInYear; } // returns the annual hours greater than 1% for a schedule - essentially the number of hours with any operation - Real64 ScheduleHoursGT1perc(EnergyPlusData &state, - int const ScheduleIndex, // Which Schedule being tested - int const StartDayOfWeek, // Day of week for start of year - bool const isItLeapYear // true if it is a leap year containing February 29 - ) + Real64 ScheduleDetailed::getAnnualHoursGreaterThan1Percent(EnergyPlusData &state, + int const StartDayOfWeek, // Day of week for start of year + bool const isItLeapYear // true if it is a leap year containing February 29 + ) { // J. Glazer - July 2017 // adapted from Linda K. Lawrie original code for ScheduleAverageHoursPerWeek() - - int DaysInYear; - - if (isItLeapYear) { - DaysInYear = 366; - } else { - DaysInYear = 365; - } - - if (ScheduleIndex < ScheduleManager::ScheduleAlwaysOn || ScheduleIndex > state.dataScheduleMgr->NumSchedules) { - ShowFatalError(state, "ScheduleHoursGT1perc called with ScheduleIndex out of range"); - } + auto const &s_glob = state.dataGlobal; + + int DaysInYear = (isItLeapYear) ? 366 : 365; int DayT = StartDayOfWeek; Real64 TotalHours = 0.0; - if (DayT == 0) return TotalHours; + if (DayT < iDayType_Sun || DayT > iDayType_Sat) return TotalHours; - for (int Loop = 1; Loop <= DaysInYear; ++Loop) { - int WkSch = state.dataScheduleMgr->Schedule(ScheduleIndex).WeekSchedulePointer(Loop); - for (int hrOfDay = 1; hrOfDay <= 24; ++hrOfDay) { - for (int TS = 1; TS <= state.dataGlobal->NumOfTimeStepInHour; ++TS) { - if (state.dataScheduleMgr->DaySchedule(state.dataScheduleMgr->WeekSchedule(WkSch).DaySchedulePointer(DayT)) - .TSValue(TS, hrOfDay)) { - TotalHours += state.dataGlobal->TimeStepZone; - } + for (int iDay = 1; iDay <= DaysInYear; ++iDay) { + auto const *weekSched = this->weekScheds[iDay]; + auto const *daySched = weekSched->dayScheds[DayT]; + for (int i = 0; i < Constant::iHoursInDay * s_glob->TimeStepsInHour; ++i) { + if (daySched->tsVals[i] > 0.0) { + TotalHours += s_glob->TimeStepZone; } } ++DayT; - if (DayT > 7) DayT = 1; + if (DayT > iDayType_Sat) DayT = iDayType_Sun; } return TotalHours; - } + } // ScheduleDetailed::getAnnualHoursGreaterThan1Percent() - int GetNumberOfSchedules(EnergyPlusData &state) + // returns the annual hours greater than 1% for a schedule - essentially the number of hours with any operation + Real64 ScheduleConstant::getAnnualHoursGreaterThan1Percent([[maybe_unused]] EnergyPlusData &state, + int const StartDayOfWeek, // Day of week for start of year + bool const isItLeapYear // true if it is a leap year containing February 29 + ) { - // FUNCTION INFORMATION: - // AUTHOR Greg Stark - // DATE WRITTEN September 2008 - // MODIFIED na - // RE-ENGINEERED na - - // PURPOSE OF THIS FUNCTION: - // This function returns the number of schedules. - - // METHODOLOGY EMPLOYED: - // na - - // REFERENCES: - // na - - // USE STATEMENTS: - // na - - // Return value - int NumberOfSchedules; - - // Locals - // FUNCTION ARGUMENT DEFINITIONS: - - // FUNCTION PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS - // na + int DaysInYear = (isItLeapYear) ? 366 : 365; - // DERIVED TYPE DEFINITIONS - // na + if (StartDayOfWeek < iDayType_Sun || StartDayOfWeek > iDayType_Sat) return 0.0; // Assert this instead? - // FUNCTION LOCAL VARIABLE DECLARATIONS: - // na - - NumberOfSchedules = state.dataScheduleMgr->NumSchedules; + return (this->currentVal > 0.0) ? (Constant::rHoursInDay * DaysInYear) : 0; + } // ScheduleConstant::getHoursGreaterThan1Percent() + + // returns the temperature value from a schedule at a certain time for the first day of the week in either January or July + std::tuple + ScheduleDetailed::getValAndCountOnDay(EnergyPlusData &state, bool const isSummer, DayType const dayOfWeek, int const hourOfDay) + { + // J.Glazer - Aug 2017 + + auto const &s_glob = state.dataGlobal; + + // determine month to use based on hemiphere and season + int month; + if (isSummer) { + month = (state.dataEnvrn->Latitude > 0.) ? 7 : 1; + } else { + month = (state.dataEnvrn->Latitude > 0.) ? 1 : 7; + } + + std::string monthName = (month == 1) ? "January" : "July"; + + int jdateSelect = General::nthDayOfWeekOfMonth(state, (int)dayOfWeek, 1, month); + + // determine number of days in year + int DaysInYear = (state.dataEnvrn->CurrentYearIsLeapYear) ? 366 : 365; + + // should adjust date if lands on a holiday but for now assume that it does not + + // adjust time of day for daylight savings time + int hourSelect = hourOfDay + state.dataWeather->DSTIndex(jdateSelect); + + // get the value at the selected time + int constexpr firstTimeStep = 1; + auto const *weekSched = this->weekScheds[jdateSelect]; + auto const *daySched = weekSched->dayScheds[(int)dayOfWeek]; + + Real64 value = daySched->tsVals[(hourSelect - 1) * state.dataGlobal->TimeStepsInHour + (firstTimeStep - 1)]; + int countOfSame = 0; + + // count the number of times with that same value + for (int jdateOfYear = 1; jdateOfYear <= DaysInYear; ++jdateOfYear) { + auto const *wSched = this->weekScheds[jdateOfYear]; + if (wSched == weekSched) { // if same week schedule can short circuit rest of testing and increment counter + ++countOfSame; + continue; + } + + auto const *dSched = wSched->dayScheds[(int)dayOfWeek]; + if (dSched == daySched) { // if same day schedule can short circuit rest of testing and increment counter + ++countOfSame; + continue; + } + + if (dSched->tsVals[(hourSelect - 1) * s_glob->TimeStepsInHour + (firstTimeStep - 1)] == value) { + ++countOfSame; + } + } + + return std::make_tuple(value, countOfSame, monthName); + } // ScheduleDetailed::getValAndCountOnDay() - return NumberOfSchedules; - } + // returns the temperature value from a schedule at a certain time for the first day of the week in either January or July + std::tuple + ScheduleConstant::getValAndCountOnDay(EnergyPlusData &state, bool const isSummer, [[maybe_unused]] DayType const dayOfWeek, [[maybe_unused]] int const hourOfDay) + { + // determine month to use based on hemiphere and season + int month; + if (isSummer) { + month = (state.dataEnvrn->Latitude > 0.) ? 7 : 1; + } else { + month = (state.dataEnvrn->Latitude > 0.) ? 1 : 7; + } + + std::string monthName = (month == 1) ? "January" : "July"; + int DaysInYear = (state.dataEnvrn->CurrentYearIsLeapYear) ? 366 : 365; + return std::make_tuple(this->currentVal, DaysInYear, monthName); + } // ScheduleConstant::getValAndCountOnDay() + + +void ShowSevereBadMin(EnergyPlusData &state, ErrorObjectHeader const &eoh, std::string_view fieldName, std::string_view fieldVal, Clusive cluMin, Real64 minVal, std::string_view msg) +{ + ShowSevereError(state, format("{}: {} = {}", eoh.routineName, eoh.objectType, eoh.objectName)); + ShowContinueError(state, format("{} = {}, schedule contains values that are {} {}", fieldName, fieldVal, + cluMin == Clusive::In ? "<" : "<=", minVal)); + if (!msg.empty()) ShowContinueError(state, format("{}", msg)); +} + +void ShowSevereBadMax(EnergyPlusData &state, ErrorObjectHeader const &eoh, std::string_view fieldName, std::string_view fieldVal, Clusive cluMax, Real64 maxVal, std::string_view msg) +{ + ShowSevereError(state, format("{}: {} = {}", eoh.routineName, eoh.objectType, eoh.objectName)); + ShowContinueError(state, format("{} = {}, schedule contains values that are {} {}", fieldName, fieldVal, + cluMax == Clusive::In ? ">" : ">=", maxVal)); + if (!msg.empty()) ShowContinueError(state, format("{}", msg)); +} + +void ShowSevereBadMinMax(EnergyPlusData &state, ErrorObjectHeader const &eoh, std::string_view fieldName, std::string_view fieldVal, Clusive cluMin, Real64 minVal, Clusive cluMax, Real64 maxVal, std::string_view msg) +{ + ShowSevereError(state, format("{}: {} = {}", eoh.routineName, eoh.objectType, eoh.objectName)); + ShowContinueError(state, format("{} = {}, schedule contains values that are {} {} and/or {} {}", fieldName, fieldVal, + cluMin == Clusive::In ? "<" : "<=", minVal, + cluMax == Clusive::In ? ">" : ">=", maxVal)); + if (!msg.empty()) ShowContinueError(state, format("{}", msg)); +} + + +void ShowWarningBadMin(EnergyPlusData &state, ErrorObjectHeader const &eoh, std::string_view fieldName, std::string_view fieldVal, Clusive cluMin, Real64 minVal, std::string_view msg) +{ + ShowWarningError(state, format("{}: {} = {}", eoh.routineName, eoh.objectType, eoh.objectName)); + ShowContinueError(state, format("{} = {}, schedule contains values that are {} {}", fieldName, fieldVal, + cluMin == Clusive::In ? "<" : "<=", minVal)); + if (!msg.empty()) ShowContinueError(state, format("{}", msg)); +} + +void ShowWarningBadMax(EnergyPlusData &state, ErrorObjectHeader const &eoh, std::string_view fieldName, std::string_view fieldVal, Clusive cluMax, Real64 maxVal, std::string_view msg) +{ + ShowWarningError(state, format("{}: {} = {}", eoh.routineName, eoh.objectType, eoh.objectName)); + ShowContinueError(state, format("{} = {}, schedule contains values that are {} {}", fieldName, fieldVal, + cluMax == Clusive::In ? ">" : ">=", maxVal)); + if (!msg.empty()) ShowContinueError(state, format("{}", msg)); +} + +void ShowWarningBadMinMax(EnergyPlusData &state, ErrorObjectHeader const &eoh, std::string_view fieldName, std::string_view fieldVal, Clusive cluMin, Real64 minVal, Clusive cluMax, Real64 maxVal, std::string_view msg) +{ + ShowWarningError(state, format("{}: {} = {}", eoh.routineName, eoh.objectType, eoh.objectName)); + ShowContinueError(state, format("{} = {}, schedule contains values that are {} {} and/or {} {}", fieldName, fieldVal, + cluMin == Clusive::In ? "<" : "<=", minVal, + cluMax == Clusive::In ? ">" : ">=", maxVal)); + if (!msg.empty()) ShowContinueError(state, format("{}", msg)); +} + + } // namespace ScheduleManager } // namespace EnergyPlus diff --git a/src/EnergyPlus/ScheduleManager.hh b/src/EnergyPlus/ScheduleManager.hh index 72343930f4a..a9bd5133e3d 100644 --- a/src/EnergyPlus/ScheduleManager.hh +++ b/src/EnergyPlus/ScheduleManager.hh @@ -51,8 +51,6 @@ // ObjexxFCL Headers #include #include -#include -#include #include #include @@ -60,22 +58,24 @@ #include #include #include +#include namespace EnergyPlus { // Forward declarations struct EnergyPlusData; -namespace ScheduleManager { - - constexpr int ScheduleAlwaysOn = -1; - constexpr int ScheduleAlwaysOff = 0; +namespace Sched { + constexpr int SchedNum_Invalid = -1; + constexpr int SchedNum_AlwaysOff = 0; + constexpr int SchedNum_AlwaysOn = 1; + enum class DayType { Invalid = -1, - Dummy = 0, - Sunday = 1, + Unused, // This is annoying. Will get rid of it later + Sunday, Monday, Tuesday, Wednesday, @@ -90,32 +90,44 @@ namespace ScheduleManager { Num }; - int constexpr maxDayTypes = static_cast(DayType::Num) - 1; - extern const std::array(DayType::Num)> dayTypeNames; - extern const std::array(DayType::Num)> dayTypeNamesUC; + constexpr int iDayType_Sun = (int)DayType::Sunday; + constexpr int iDayType_Mon = (int)DayType::Monday; + constexpr int iDayType_Tue = (int)DayType::Tuesday; + constexpr int iDayType_Wed = (int)DayType::Wednesday; + constexpr int iDayType_Thu = (int)DayType::Thursday; + constexpr int iDayType_Fri = (int)DayType::Friday; + constexpr int iDayType_Sat = (int)DayType::Saturday; + constexpr int iDayType_Hol = (int)DayType::Holiday; + constexpr int iDayType_SumDes = (int)DayType::SummerDesignDay; + constexpr int iDayType_WinDes = (int)DayType::WinterDesignDay; + constexpr int iDayType_Cus1 = (int)DayType::CustomDay1; + constexpr int iDayType_Cus2 = (int)DayType::CustomDay2; + + extern const std::array dayTypeNames; + extern const std::array dayTypeNamesUC; enum class DayTypeGroup { Invalid = -1, - Weekday = 1, + Weekday, WeekEndHoliday, SummerDesignDay, WinterDesignDay, Num }; - enum class SchedType : int + enum class SchedType { Invalid = -1, - ScheduleInput_year = 1, - ScheduleInput_compact = 2, - ScheduleInput_file = 3, - ScheduleInput_constant = 4, - ScheduleInput_external = 5, + Year, + Compact, + File, + Constant, + External, Num }; - enum class OutputReportLevel + enum class ReportLevel { Invalid = -1, Hourly, @@ -123,7 +135,7 @@ namespace ScheduleManager { Num }; - enum class ScheduleInterpolation + enum class Interpolation { Invalid = -1, No, // no interpolation @@ -132,128 +144,226 @@ namespace ScheduleManager { Num }; - enum class Clusivity - { + enum class LimitUnits { Invalid = -1, - Inclusive, - Exclusive, + Dimensionless, + Temperature, + DeltaTemperature, + PrecipitationRate, + Angle, + ConvectionCoefficient, + ActivityLevel, + Velocity, + Capacity, + Power, + Availability, + Percent, + Control, + Mode, Num }; - struct ScheduleTypeData + struct ScheduleType { // Members std::string Name; // Schedule Type Name - bool Limited; // True if this Schedule Type has limits - Real64 Minimum; // Minimum for limited schedule - Real64 Maximum; // Maximum for limited schedule - bool IsReal; // True if this is a "real" schedule, false if integer - int UnitType; // reference ScheduleTypeLimit table - - // Default Constructor - ScheduleTypeData() : Limited(false), Minimum(0.0), Maximum(0.0), IsReal(true), UnitType(0) - { - } + int Num; // index in vector, useful sometimes + bool isLimited = false; // True if this Schedule Type has limits + Real64 minVal = 0.0; // Minimum for limited schedule + Real64 maxVal = 0.0; // Maximum for limited schedule + bool isReal = true; // True if this is a "real" schedule, false if integer + LimitUnits limitUnits = LimitUnits::Invalid; }; - struct DayScheduleData + struct ScheduleBase { - // Members - std::string Name; // Day Schedule Name - int ScheduleTypePtr; // Index of Schedule Type - ScheduleInterpolation IntervalInterpolated; // Indicator for interval interpolation. If not "interpolated", False. Else True - bool Used; // Indicator for this schedule being "used". - Array2D TSValue; // Value array by simulation timestep - Real64 TSValMax; // maximum of all TSValue's - Real64 TSValMin; // minimum of all TSValue's - - // Default Constructor - DayScheduleData() : ScheduleTypePtr(0), IntervalInterpolated(ScheduleInterpolation::No), Used(false), TSValMax(0.0), TSValMin(0.0) - { - } + std::string Name; + int Num = SchedNum_Invalid; + bool isUsed = false; + + Real64 maxVal = 0.0; // maximum of all TSValue's + Real64 minVal = 0.0; // minimum of all TSValue's + bool isMinMaxSet = false; + + ScheduleBase() {}; + + virtual void can_instantiate() = 0; // abstract base class + + virtual void setMinMaxVals(EnergyPlusData &state) = 0; + Real64 getMinVal(EnergyPlusData &state); + Real64 getMaxVal(EnergyPlusData &state); + + bool checkMinMaxVals(EnergyPlusData &state, Clusive cluMin, Real64 const min, Clusive cluMax, Real64 const max); + bool checkMinVal(EnergyPlusData &state, Clusive cluMin, Real64 const min); + bool checkMaxVal(EnergyPlusData &state, Clusive cluMax, Real64 const max); + }; + + struct DaySchedule : ScheduleBase + { + int schedTypeNum = SchedNum_Invalid; // Index of Schedule Type + + Interpolation interpolation = Interpolation::No; // Indicator for interval interpolation. If not "interpolated", False. Else True + std::vector tsVals; // Value array by simulation timestep + Real64 sumTsVals = 0.0; + + DaySchedule() {} + virtual ~DaySchedule() {} + void can_instantiate() { assert(false); } // makes class concrete, but don't call this + + bool checkValsForLimitViolations(EnergyPlusData &state) const; + bool checkValsForBadIntegers(EnergyPlusData &state) const; + void populateFromMinuteVals(EnergyPlusData &state, std::array const &minVals); + void getDayVals(EnergyPlusData &state, Array2S DayVals) const; + std::vector const &getDayVals([[maybe_unused]] EnergyPlusData &state) const { return tsVals; } + void setMinMaxVals(EnergyPlusData &state); }; - struct WeekScheduleData + struct WeekSchedule : public ScheduleBase { // Members - std::string Name; // Week Schedule Name - bool Used; // Indicator for this schedule being "used". - Array1D_int DaySchedulePointer; // Index of Day Schedule - - // Default Constructor - WeekScheduleData() : Used(false), DaySchedulePointer(maxDayTypes, 0) - { - } + std::array dayScheds = {nullptr}; + + WeekSchedule() {} + virtual ~WeekSchedule() {} + void can_instantiate() { assert(false); } // makes class concrete, but don't call this + + void setMinMaxVals(EnergyPlusData &state); }; - struct ScheduleData + struct Schedule : public ScheduleBase + { + SchedType type = SchedType::Invalid; + + int schedTypeNum = SchedNum_Invalid; // Index of Schedule Type + bool EMSActuatedOn = false; // indicates if EMS computed + Real64 EMSVal = 0.0; // EMS value + + Real64 currentVal = 0.0; + + Schedule() { type = SchedType::Constant; } + + virtual ~Schedule() {}; + + Real64 getCurrentVal() const { return currentVal; } + + // Looks up a given Schedule value for an hour & timestep, minding whether DST is enabled or not + // Negative ts => unspecified, will use TimeStepsInHour + virtual Real64 getHrTsVal(EnergyPlusData &state, int hr, int ts = -1) const = 0; + virtual void getDayVals(EnergyPlusData &state, Array2S DayVals, int jDay = -1, int dayofWeek = -1) = 0; + virtual std::vector const &getDayVals(EnergyPlusData &state, int jDay = -1, int dayOfWeek = -1) = 0; + + virtual bool hasVal(EnergyPlusData &state, Real64 const val) const = 0; + virtual bool hasFractionalVal(EnergyPlusData &state) const = 0; + + virtual std::pair getMinMaxValsByDayType(EnergyPlusData &state, DayTypeGroup const days) = 0; + + Real64 getAverageWeeklyHoursFullLoad(EnergyPlusData &state, int const startDayOfWeek, bool const isLeapYear); + virtual Real64 getAnnualHoursFullLoad(EnergyPlusData &state, int const StartDayOfWeek, bool const isLeapYear) = 0; + virtual Real64 getAnnualHoursGreaterThan1Percent(EnergyPlusData &state, int const StartDayOfWeek, bool const isLeapYear) = 0; + virtual std::tuple getValAndCountOnDay(EnergyPlusData &state, bool const isSummer, DayType const dayOfWeek, int const hourOfDay) = 0; + }; + + struct ScheduleConstant : public Schedule + { + std::vector tsVals; + + ScheduleConstant() { type = SchedType::Constant; } + + virtual ~ScheduleConstant() {}; + + void can_instantiate() { assert(false); } // makes class concrete, but don't call this + + // Looks up a given Schedule value for an hour & timestep, minding whether DST is enabled or not + // Negative ts => unspecified, will use TimeStepsInHour + Real64 getHrTsVal(EnergyPlusData &state, int hr, int ts = -1) const; + + void getDayVals(EnergyPlusData &state, Array2S DayValues, int jDay = -1, int dayofWeek = -1); + std::vector const &getDayVals(EnergyPlusData &state, int jDay = -1, int dayOfWeek = -1); + + bool hasVal(EnergyPlusData &state, Real64 const val) const; + bool hasFractionalVal(EnergyPlusData &state) const; + + void setMinMaxVals(EnergyPlusData &state); + + std::pair getMinMaxValsByDayType(EnergyPlusData &state, DayTypeGroup const days); + + Real64 getAnnualHoursFullLoad(EnergyPlusData &state, int const StartDayOfWeek, bool const isLeapYear); + Real64 getAnnualHoursGreaterThan1Percent(EnergyPlusData &state, int const StartDayOfWeek, bool const isLeapYear); + + std::tuple getValAndCountOnDay(EnergyPlusData &state, bool const isSummer, DayType const dayOfWeek, int const hourOfDay); + }; + + struct ScheduleDetailed : public Schedule { // Members - std::string Name; // Schedule Name - int ScheduleTypePtr; // Index of Schedule Type - Array1D_int WeekSchedulePointer; // one created for each day of possible simulation - SchedType SchType = SchedType::Invalid; // what kind of object has been input. - bool Used; // Indicator for this schedule being "used". - bool MaxMinSet; // Max/min values have been stored for this schedule - Real64 MaxValue; // Maximum value for this schedule - Real64 MinValue; // Minimum value for this schedule - std::array(DayType::Num)> MaxMinByDayTypeSet{ - false}; // minimum and maximum values by daytype have been stored for this schedule - std::array(DayType::Num)> MinByDayType{0.0}; // minimum values by daytype for this schedule - std::array(DayType::Num)> MaxByDayType{0.0}; // maximum values by daytype for this schedule - Real64 CurrentValue; // For Reporting - bool EMSActuatedOn; // indicates if EMS computed - Real64 EMSValue; // EMS value - bool UseDaylightSaving; // Toggles between daylight saving option to be inclused as "No" or "Yes" (default) - - // Default Constructor - ScheduleData() - : ScheduleTypePtr(0), WeekSchedulePointer(366, 0), Used(false), MaxMinSet(false), MaxValue(0.0), MinValue(0.0), CurrentValue(0.0), - EMSActuatedOn(false), EMSValue(0.0), UseDaylightSaving(true) - { - } + std::array weekScheds = {nullptr}; // one created for each day of possible simulation + std::array MaxMinByDayTypeSet = {false}; // minimum and maximum values by daytype have been stored + std::array MinByDayType = {0.0}; // minimum values by daytype for this schedule + std::array MaxByDayType = {0.0}; // maximum values by daytype for this schedule + bool UseDaylightSaving = true; // Toggles between daylight saving option to be inclused as "No" or "Yes" (default) + + ScheduleDetailed() { type = SchedType::Year; } + + ~ScheduleDetailed() {} + + void can_instantiate() { assert(false); } // makes class concrete, but don't call this + + void getDayVals(EnergyPlusData &state, Array2S DayVals, int jDay = -1, int dayofWeek = -1); + std::vector const &getDayVals(EnergyPlusData &state, int jDay = -1, int dayOfWeek = -1); + + bool hasVal(EnergyPlusData &state, Real64 const val) const; + bool hasFractionalVal(EnergyPlusData &state) const; + + void setMinMaxVals(EnergyPlusData &state); + + // Looks up a given Schedule value for an hour & timestep, minding whether DST is enabled or not + // Negative ts => unspecified, will use TimeStepsInHour + Real64 getHrTsVal(EnergyPlusData &state, int hr, int ts = -1) const; + + std::pair getMinMaxValsByDayType(EnergyPlusData &state, DayTypeGroup const days); + + Real64 getAnnualHoursFullLoad(EnergyPlusData &state, int const StartDayOfWeek, bool const isLeapYear); + Real64 getAnnualHoursGreaterThan1Percent(EnergyPlusData &state, int const StartDayOfWeek, bool const isLeapYear); + + std::tuple getValAndCountOnDay(EnergyPlusData &state, bool const isSummer, DayType const dayOfWeek, int const hourOfDay); }; - // Functions + // Functions + ScheduleDetailed *AddScheduleDetailed(EnergyPlusData &state, std::string const &name); + ScheduleConstant *AddScheduleConstant(EnergyPlusData &state, std::string const &name); + DaySchedule *AddDaySchedule(EnergyPlusData &state, std::string const &name); + WeekSchedule *AddWeekSchedule(EnergyPlusData &state, std::string const &name); + void ProcessScheduleInput(EnergyPlusData &state); - void ReportScheduleDetails(EnergyPlusData &state, OutputReportLevel const LevelOfDetail); + void InitConstantScheduleData(EnergyPlusData &state); + + void ReportScheduleDetails(EnergyPlusData &state, ReportLevel const LevelOfDetail); // Returns the CurrentScheduleValue - Real64 GetCurrentScheduleValue(EnergyPlusData &state, int const ScheduleIndex); - + Real64 GetHrTsScheduleVal(EnergyPlusData &state, int const schedNum, int const hr, int const ts = -1); // Updates each schedule value to the current timestep - // Uses EMS value if actuated, otherwise calls LookUpScheduleValue with ThisHour=DataGlobals::HourOfDay, ThisTimeStep=DataGlobals::TimeStep - void UpdateScheduleValues(EnergyPlusData &state); - - // Looks up a given Schedule value for an hour & timestep, minding whether DST is enabled or not - Real64 LookUpScheduleValue(EnergyPlusData &state, - int const ScheduleIndex, - int const ThisHour, - int const ThisTimeStep = -1 // Negative => unspecified, will use NumOfTimeStepInHour - ); - - int GetScheduleIndex(EnergyPlusData &state, std::string const &ScheduleName); - - std::string GetScheduleType(EnergyPlusData &state, int const ScheduleIndex); - - int GetDayScheduleIndex(EnergyPlusData &state, std::string &ScheduleName); - - void GetScheduleValuesForDay(EnergyPlusData &state, - int const ScheduleIndex, - Array2S DayValues, - ObjexxFCL::Optional_int_const JDay = _, - ObjexxFCL::Optional_int_const CurDayofWeek = _); - void GetSingleDayScheduleValues(EnergyPlusData &state, - int const DayScheduleIndex, // Index of the DaySchedule for values - Array2S DayValues // Returned set of values - ); + // Uses EMS value if actuated, otherwise calls LookUpScheduleValue with ThisHour=DataGlobals::HourOfDay, ThisTimeStep=DataGlobals::TimeStep + void UpdateScheduleVals(EnergyPlusData &state); + + int GetScheduleTypeNum(EnergyPlusData &state, std::string const &name); + + int GetDayScheduleNum(EnergyPlusData &state, std::string const &name); + DaySchedule *GetDaySchedule(EnergyPlusData &state, std::string const &name); + + int GetWeekScheduleNum(EnergyPlusData &state, std::string const &name); + WeekSchedule *GetWeekSchedule(EnergyPlusData &state, std::string const &name); + + int GetScheduleNum(EnergyPlusData &state, std::string const &name); + Schedule *GetSchedule(EnergyPlusData &state, std::string const &name); + Schedule *GetScheduleAlwaysOn(EnergyPlusData &state); + Schedule *GetScheduleAlwaysOff(EnergyPlusData &state); void ExternalInterfaceSetSchedule(EnergyPlusData &state, - int &ScheduleIndex, - Real64 &Value // The new value for the schedule + int schedNum, + Real64 val // The new value for the schedule ); void ProcessIntervalFields(EnergyPlusData &state, @@ -261,179 +371,112 @@ namespace ScheduleManager { Array1S const Numbers, int const NumUntils, int const NumNumbers, - Array2A MinuteValue, - Array2A_bool SetMinuteValue, + std::array &minuteVals, + std::array &setMinuteVals, bool &ErrorsFound, std::string const &DayScheduleName, // Name (used for errors) std::string const &ErrContext, // Context (used for errors) - ScheduleInterpolation interpolationKind // enumeration on how to interpolate values in schedule + Interpolation interpolation // enumeration on how to interpolate values in schedule ); void DecodeHHMMField(EnergyPlusData &state, - std::string const &FieldValue, // Input field value + std::string const &FieldVal, // Input field value int &RetHH, // Returned "hour" int &RetMM, // Returned "minute" bool &ErrorsFound, // True if errors found in this field std::string const &DayScheduleName, // originating day schedule name std::string const &FullFieldValue, // Full Input field value - ScheduleInterpolation interpolationKind // enumeration on how to interpolate values in schedule + Interpolation interpolation // enumeration on how to interpolate values in schedule ); bool isMinuteMultipleOfTimestep(int minute, int numMinutesPerTimestep); void ProcessForDayTypes(EnergyPlusData &state, std::string const &ForDayField, // Field containing the "FOR:..." - Array1D_bool &TheseDays, // Array to contain returned "true" days - Array1D_bool &AlReady, // Array of days already done + std::array &theseDays, // Array to contain returned "true" days + std::array &allDays, // Array of days already done bool &ErrorsFound // Will be true if error found. ); - bool CheckScheduleValueMinMax(EnergyPlusData &state, - int const ScheduleIndex, // Which Schedule being tested - bool includeOrEquals, // Minimum indicator ('>', '>=') - Real64 const Minimum // Minimum desired value - ); - - bool CheckScheduleValueMinMax(EnergyPlusData &state, - int const ScheduleIndex, // Which Schedule being tested - std::string_view MinString, // Minimum indicator ('>', '>=') - Real64 const Minimum, // Minimum desired value - std::string_view MaxString, // Maximum indicator ('<', ',=') - Real64 const Maximum // Maximum desired value - ); - - bool CheckScheduleValueMinMax(EnergyPlusData &state, - int const ScheduleIndex, // Which Schedule being tested - Clusivity clusiveMin, // true ? '>' : '>=' - Real64 const Minimum, // Minimum desired value - Clusivity clusiveMax, // true ? '<' : '<=' - Real64 const Maximum // Maximum desired value - ); - - bool CheckScheduleValueMinMax(EnergyPlusData &state, - int const ScheduleIndex, // Which Schedule being tested - std::string const &MinString, // Minimum indicator ('>', '>=') - Real32 const Minimum // Minimum desired value - ); - - bool CheckScheduleValueMinMax(EnergyPlusData &state, - int const ScheduleIndex, // Which Schedule being tested - std::string const &MinString, // Minimum indicator ('>', '>=') - Real32 const Minimum, // Minimum desired value - std::string const &MaxString, // Maximum indicator ('<', ',=') - Real32 const Maximum // Maximum desired value - ); - - bool CheckScheduleValue(EnergyPlusData &state, - int const ScheduleIndex, // Which Schedule being tested - Real64 const Value // Actual desired value - ); - - bool CheckScheduleValue(EnergyPlusData &state, - int const ScheduleIndex, // Which Schedule being tested - int const Value // Actual desired value - ); - - bool CheckDayScheduleValueMinMax(EnergyPlusData &state, - int const ScheduleIndex, // Which Day Schedule being tested - Real64 const Minimum, // Minimum desired value - bool const exclusiveMin, // Minimum indicator ('>', '>=') - Real64 const Maximum, // Maximum desired value - bool const exclusiveMax // Maximum indicator ('<', ',=') - ); - - bool CheckDayScheduleValueMinMax(EnergyPlusData &state, - int const ScheduleIndex, // Which Day Schedule being tested - Real64 const Minimum, // Minimum desired value - bool const exclusiveMin // Minimum indicator ('>', '>=') - ); - - bool HasFractionalScheduleValue(EnergyPlusData &state, int const ScheduleIndex); // Which Schedule being tested - - Real64 GetScheduleMinValue(EnergyPlusData &state, int const ScheduleIndex); // Which Schedule being tested - - Real64 GetScheduleMaxValue(EnergyPlusData &state, int const ScheduleIndex); // Which Schedule being tested - - std::pair getScheduleMinMaxByDayType(EnergyPlusData &state, int const ScheduleIndex, DayTypeGroup const days); - - std::string GetScheduleName(EnergyPlusData &state, int const ScheduleIndex); - - void ReportScheduleValues(EnergyPlusData &state); + void ReportScheduleVals(EnergyPlusData &state); void ReportOrphanSchedules(EnergyPlusData &state); - Real64 ScheduleAnnualFullLoadHours(EnergyPlusData &state, - int const ScheduleIndex, // Which Schedule being tested - int const StartDayOfWeek, // Day of week for start of year - bool const isItLeapYear // true if it is a leap year containing February 29 - ); + void ShowSevereBadMin(EnergyPlusData &state, ErrorObjectHeader const &eoh, std::string_view schedField, std::string_view schedName, + Clusive cluMin, Real64 min, std::string_view msg = {}); - Real64 ScheduleAverageHoursPerWeek(EnergyPlusData &state, - int const ScheduleIndex, // Which Schedule being tested - int const StartDayOfWeek, // Day of week for start of year - bool const isItLeapYear // true if it is a leap year containing February 29 - ); + void ShowWarningBadMin(EnergyPlusData &state, ErrorObjectHeader const &eoh, std::string_view schedField, std::string_view schedName, + Clusive cluMin, Real64 min, std::string_view msg = {}); - Real64 ScheduleHoursGT1perc(EnergyPlusData &state, - int const ScheduleIndex, // Which Schedule being tested - int const StartDayOfWeek, // Day of week for start of year - bool const isItLeapYear // true if it is a leap year containing February 29 - ); + void ShowSevereBadMax(EnergyPlusData &state, ErrorObjectHeader const &eoh, std::string_view schedField, std::string_view schedName, + Clusive cluMax, Real64 max, std::string_view msg = {}); - int GetNumberOfSchedules(EnergyPlusData &state); + void ShowWarningBadMax(EnergyPlusData &state, ErrorObjectHeader const &eoh, std::string_view schedField, std::string_view schedName, + Clusive cluMax, Real64 max, std::string_view msg = {}); + + void ShowSevereBadMinMax(EnergyPlusData &state, ErrorObjectHeader const &eoh, std::string_view schedField, std::string_view schedName, + Clusive cluMin, Real64 min, Clusive cluMax, Real64 max, std::string_view msg = {}); -} // namespace ScheduleManager + void ShowWarningBadMinMax(EnergyPlusData &state, ErrorObjectHeader const &eoh, std::string_view schedField, std::string_view schedName, + Clusive cluMin, Real64 min, Clusive cluMax, Real64 max, std::string_view msg = {}); + +} // namespace Sched struct ScheduleManagerData : BaseGlobalStruct { - bool CheckScheduleValueMinMaxRunOnceOnly = true; + bool CheckScheduleValMinMaxRunOnceOnly = true; bool DoScheduleReportingSetup = true; - std::unordered_map UniqueDayScheduleNames; - std::unordered_map UniqueWeekScheduleNames; - std::unordered_map UniqueScheduleNames; std::map UniqueProcessedExternalFiles; - // Integer Variables for the Module - int NumScheduleTypes = 0; - int NumDaySchedules = 0; - int NumWeekSchedules = 0; - int NumSchedules = 0; - // Logical Variables for Module bool ScheduleInputProcessed = false; // This is false until the Schedule Input has been processed. bool ScheduleFileShadingProcessed = false; // This is false unless there is a Schedule:File:Shading object. // Object Data - Array1D ScheduleType; // Allowed Schedule Types - Array1D DaySchedule; // Day Schedule Storage - Array1D WeekSchedule; // Week Schedule Storage - Array1D Schedule; // Schedule Storage + std::vector scheduleTypes; // Allowed Schedule Types + std::vector schedules; // Year schedule + std::vector daySchedules; + std::vector weekSchedules; + + std::map scheduleTypeMap; + std::map scheduleMap; + std::map dayScheduleMap; + std::map weekScheduleMap; + + void init_constant_state(EnergyPlusData &state) override + { + Sched::InitConstantScheduleData(state); + } - void init_state([[maybe_unused]] EnergyPlusData &state) override + void init_state(EnergyPlusData &state) override { + Sched::ProcessScheduleInput(state); } void clear_state() override { - CheckScheduleValueMinMaxRunOnceOnly = true; - UniqueDayScheduleNames.clear(); - UniqueWeekScheduleNames.clear(); - UniqueScheduleNames.clear(); + CheckScheduleValMinMaxRunOnceOnly = true; UniqueProcessedExternalFiles.clear(); DoScheduleReportingSetup = true; - NumScheduleTypes = 0; - NumDaySchedules = 0; - NumWeekSchedules = 0; - NumSchedules = 0; - ScheduleInputProcessed = false; ScheduleFileShadingProcessed = false; - ScheduleType.clear(); // Allowed Schedule Types - DaySchedule.clear(); // Day Schedule Storage - WeekSchedule.clear(); // Week Schedule Storage - Schedule.clear(); // Schedule Storage + for (int i = 0; i < (int)scheduleTypes.size(); ++i) delete scheduleTypes[i]; + scheduleTypes.clear(); // Allowed Schedule Types + scheduleTypeMap.clear(); + + for (int i = 0; i < (int)schedules.size(); ++i) delete schedules[i]; + schedules.clear(); // Schedule Storage + scheduleMap.clear(); + + for (int i = 0; i < (int)daySchedules.size(); ++i) delete daySchedules[i]; + daySchedules.clear(); + dayScheduleMap.clear(); + + for (int i = 0; i < (int)weekSchedules.size(); ++i) delete weekSchedules[i]; + weekSchedules.clear(); + weekScheduleMap.clear(); } }; diff --git a/src/EnergyPlus/SetPointManager.cc b/src/EnergyPlus/SetPointManager.cc index 3a186e22279..d63269a0669 100644 --- a/src/EnergyPlus/SetPointManager.cc +++ b/src/EnergyPlus/SetPointManager.cc @@ -132,7 +132,6 @@ namespace EnergyPlus::SetPointManager { using namespace DataLoopNode; using namespace DataAirLoop; -using namespace ScheduleManager; using namespace Curve; using Psychrometrics::PsyCpAirFnW; using Psychrometrics::PsyHFnTdbW; @@ -350,9 +349,6 @@ void GetSetPointManagerInputData(EnergyPlusData &state, bool &ErrorsFound) using NodeInputManager::GetNodeNums; using NodeInputManager::GetOnlySingleNode; - using ScheduleManager::CheckScheduleValueMinMax; - using ScheduleManager::GetScheduleIndex; - // Locals // SUBROUTINE PARAMETER DEFINITIONS: static constexpr std::string_view routineName = "GetSetPointManagerInputs"; @@ -686,8 +682,7 @@ void GetSetPointManagerInputData(EnergyPlusData &state, bool &ErrorsFound) assert(spmS != nullptr); std::string schedName = ip->getAlphaFieldValue(fields, props, "schedule_name"); - spmS->schedNum = GetScheduleIndex(state, schedName); - if (spmS->schedNum == 0) { + if ((spmS->sched = Sched::GetSchedule(state, Util::makeUPPER(schedName))) == nullptr) { ShowSevereItemNotFound(state, eoh, "schedule_name", schedName); ErrorsFound = true; } @@ -705,15 +700,13 @@ void GetSetPointManagerInputData(EnergyPlusData &state, bool &ErrorsFound) } std::string schedHiName = ip->getAlphaFieldValue(fields, props, "high_setpoint_schedule_name"); - spmSD->schedNumHi = GetScheduleIndex(state, schedHiName); - if (spmSD->schedNumHi == 0) { + if ((spmSD->hiSched = Sched::GetSchedule(state, Util::makeUPPER(schedHiName))) == nullptr) { ShowSevereItemNotFound(state, eoh, "high_setpoint_schedule_name", schedHiName); ErrorsFound = true; } std::string schedLoName = ip->getAlphaFieldValue(fields, props, "low_setpoint_schedule_name"); - spmSD->schedNumLo = GetScheduleIndex(state, schedLoName); - if (spmSD->schedNumLo == 0) { + if ((spmSD->loSched = Sched::GetSchedule(state, Util::makeUPPER(schedLoName))) == nullptr) { ShowSevereItemNotFound(state, eoh, "low_setpoint_schedule_name", schedLoName); ErrorsFound = true; } @@ -740,21 +733,11 @@ void GetSetPointManagerInputData(EnergyPlusData &state, bool &ErrorsFound) // Get optional input: schedule and 2nd reset rule if (auto foundSched = fields.find("schedule_name"); foundSched != fields.end()) { std::string schedName = Util::makeUPPER(foundSched.value().get()); - spmOA->schedNum = GetScheduleIndex(state, schedName); - if (spmOA->schedNum == 0) { + if ((spmOA->sched = Sched::GetSchedule(state, Util::makeUPPER(schedName))) == nullptr) { ShowSevereItemNotFound(state, eoh, "schedule_name", schedName); ErrorsFound = true; - } - - Real64 minValSched = GetScheduleMinValue(state, spmOA->schedNum); - Real64 maxValSched = GetScheduleMaxValue(state, spmOA->schedNum); - if ((minValSched < 1.0) || (maxValSched > 2.0)) { - ShowSevereError(state, format("{}: {}=\"{}\", invalid field.", routineName, cCurrentModuleObject, name)); - ShowContinueError(state, "..Schedule Values for the Outdoor Reset Schedule must be either 1 or 2"); - ShowContinueError(state, format("..Minimum Schedule Value = {} ", minValSched)); - ShowContinueError(state, format("..Maximum Schedule Value = {} ", minValSched)); - ShowContinueError( - state, format("..Adjust the schedule values so that all of them are either 1 or 2 in schedule = \"{}\"", schedName)); + } else if (!spmOA->sched->checkMinMaxVals(state, Clusive::In, 1.0, Clusive::In, 2.0)) { + Sched::ShowSevereBadMinMax(state, eoh, "schedule_name", schedName, Clusive::In, 1.0, Clusive::In, 2.0); ErrorsFound = true; } @@ -765,8 +748,7 @@ void GetSetPointManagerInputData(EnergyPlusData &state, bool &ErrorsFound) spmOA->highSetPt2 = found.value().get(); if (auto found = fields.find("outdoor_high_temperature_2"); found != fields.end()) spmOA->high2 = found.value().get(); if (spmOA->high2 < spmOA->low2) { - ShowWarningError(state, format("{}: {}=\"{}\", invalid field.", routineName, cCurrentModuleObject, spmOA->Name)); - ShowContinueError(state, + ShowWarningCustom(state, eoh, format("...{}=[{:.1R}] is less than {}=[{:.1R}].", "outdoor_high_temperature_2", spmOA->high2, @@ -774,7 +756,7 @@ void GetSetPointManagerInputData(EnergyPlusData &state, bool &ErrorsFound) spmOA->low2)); } } else { // !foundSched - spmOA->schedNum = 0; + spmOA->sched = nullptr; spmOA->lowSetPt2 = 0.0; spmOA->low2 = 0.0; spmOA->highSetPt2 = 0.0; @@ -1057,8 +1039,7 @@ void GetSetPointManagerInputData(EnergyPlusData &state, bool &ErrorsFound) assert(spmRAB != nullptr); std::string schedName = ip->getAlphaFieldValue(fields, props, "temperature_setpoint_schedule_name"); - spmRAB->schedNum = GetScheduleIndex(state, schedName); - if (spmRAB->schedNum == 0) { + if ((spmRAB->sched = Sched::GetSchedule(state, Util::makeUPPER(schedName))) == nullptr) { ShowSevereItemNotFound(state, eoh, "temperature_setpoint_schedule_name", schedName); ErrorsFound = true; } @@ -1152,8 +1133,7 @@ void GetSetPointManagerInputData(EnergyPlusData &state, bool &ErrorsFound) std::string condenserEnteringTempSchedName = ip->getAlphaFieldValue(fields, props, "default_condenser_entering_water_temperature_schedule_name"); - spmCET->condenserEnteringTempSchedNum = GetScheduleIndex(state, condenserEnteringTempSchedName); - if (spmCET->condenserEnteringTempSchedNum == 0) { + if ((spmCET->condenserEnteringTempSched = Sched::GetSchedule(state, Util::makeUPPER(condenserEnteringTempSchedName))) == nullptr) { ShowSevereItemNotFound(state, eoh, "default_condenser_entering_water_temperature_schedule_name", condenserEnteringTempSchedName); ErrorsFound = true; } @@ -1311,8 +1291,7 @@ void GetSetPointManagerInputData(EnergyPlusData &state, bool &ErrorsFound) if (spmRWT->returnTempType == ReturnTempType::Scheduled) { std::string schedName = ip->getAlphaFieldValue(fields, props, "return_temperature_setpoint_scheduled_name"); - spmRWT->returnTempSchedNum = GetScheduleIndex(state, schedName); - if (spmRWT->returnTempSchedNum == 0) { + if ((spmRWT->returnTempSched = Sched::GetSchedule(state, Util::makeUPPER(schedName))) == nullptr) { ShowSevereItemNotFound(state, eoh, "return_temperature_setpoint_scheduled_name", schedName); ErrorsFound = true; } @@ -1698,8 +1677,7 @@ void InitSetPointManagers(EnergyPlusData &state) } // still need to validate... if (spmSZH->ctrlZoneNum == 0) { // didn't find - ShowSevereCustomMessage( - state, eoh, format("could not find Controlled Zone={}", state.dataHeatBal->Zone(spmSZH->ctrlZoneNum).Name)); + ShowSevereCustom(state, eoh, format("could not find Controlled Zone={}", state.dataHeatBal->Zone(spmSZH->ctrlZoneNum).Name)); ErrorsFound = true; } else { // make sure humidity controlled zone @@ -2164,7 +2142,7 @@ void InitSetPointManagers(EnergyPlusData &state) for (int ctrlNodeNum : spmS->ctrlNodeNums) { auto &node = state.dataLoopNodes->Node(ctrlNodeNum); - Real64 SchedValue = GetCurrentScheduleValue(state, spmS->schedNum); + Real64 SchedValue = spmS->sched->getCurrentVal(); // Initialize scheduled setpoints switch (spmS->ctrlVar) { case HVAC::CtrlVarType::Temp: { @@ -2206,8 +2184,8 @@ void InitSetPointManagers(EnergyPlusData &state) for (int ctrlNodeNum : spmSD->ctrlNodeNums) { auto &node = state.dataLoopNodes->Node(ctrlNodeNum); if (spmSD->ctrlVar == HVAC::CtrlVarType::Temp) { - node.TempSetPointHi = GetCurrentScheduleValue(state, spmSD->schedNumHi); - node.TempSetPointLo = GetCurrentScheduleValue(state, spmSD->schedNumLo); + node.TempSetPointHi = spmSD->hiSched->getCurrentVal(); + node.TempSetPointLo = spmSD->loSched->getCurrentVal(); node.TempSetPoint = (node.TempSetPointHi + node.TempSetPointLo) / 2.0; } } @@ -2469,7 +2447,7 @@ void InitSetPointManagers(EnergyPlusData &state) case SPMType::CondenserEnteringTemp: { auto *spmCER = dynamic_cast(spm); assert(spmCER != nullptr); - Real64 SchedValue = GetCurrentScheduleValue(state, spmCER->condenserEnteringTempSchedNum); + Real64 SchedValue = spmCER->condenserEnteringTempSched->getCurrentVal(); for (int ctrlNodeNum : spmCER->ctrlNodeNums) { if (spmCER->ctrlVar == HVAC::CtrlVarType::Temp) { state.dataLoopNodes->Node(ctrlNodeNum).TempSetPoint = SchedValue; @@ -2615,7 +2593,7 @@ void SimSetPointManagers(EnergyPlusData &state) } } // SimSetPointManagers() -void SPMScheduled::calculate(EnergyPlusData &state) +void SPMScheduled::calculate([[maybe_unused]] EnergyPlusData &state) { // SUBROUTINE INFORMATION: // AUTHOR Fred Buhl @@ -2623,10 +2601,10 @@ void SPMScheduled::calculate(EnergyPlusData &state) // PURPOSE OF THIS SUBROUTINE: // Set the setpoint using a simple schedule. - this->setPt = GetCurrentScheduleValue(state, this->schedNum); + this->setPt = this->sched->getCurrentVal(); } // SPMScheduled::calculate() -void SPMTESScheduled::calculate(EnergyPlusData &state) +void SPMTESScheduled::calculate([[maybe_unused]] EnergyPlusData &state) { // SUBROUTINE INFORMATION: // AUTHOR Rick Strand @@ -2641,8 +2619,8 @@ void SPMTESScheduled::calculate(EnergyPlusData &state) // Locals Real64 constexpr OnVal(0.5); - Real64 CurSchValOnPeak = GetCurrentScheduleValue(state, this->schedNum); - Real64 CurSchValCharge = GetCurrentScheduleValue(state, this->schedNumCharge); + Real64 CurSchValOnPeak = this->sched->getCurrentVal(); + Real64 CurSchValCharge = this->chargeSched->getCurrentVal(); // CtrlType bug // if (this->CompOpType == DataPlant::CtrlType::CoolingOp) { // this is some sort of chiller @@ -2661,7 +2639,7 @@ void SPMTESScheduled::calculate(EnergyPlusData &state) } } // SPMTESSScheduled::calculate() -void SPMScheduledDual::calculate(EnergyPlusData &state) + void SPMScheduledDual::calculate([[maybe_unused]] EnergyPlusData &state) { // SUBROUTINE INFORMATION: // AUTHOR Richard Liesen @@ -2669,18 +2647,18 @@ void SPMScheduledDual::calculate(EnergyPlusData &state) // PURPOSE OF THIS SUBROUTINE: // Set the both setpoint using a simple schedule. - this->setPtHi = GetCurrentScheduleValue(state, this->schedNumHi); - this->setPtLo = GetCurrentScheduleValue(state, this->schedNumLo); + this->setPtHi = this->hiSched->getCurrentVal(); + this->setPtLo = this->loSched->getCurrentVal(); } // SPMScheduledDual::calculate() void SPMOutsideAir::calculate(EnergyPlusData &state) { - Real64 SchedVal = (this->schedNum > 0) ? GetCurrentScheduleValue(state, this->schedNum) : 0.0; + Real64 SchedVal = (this->sched != nullptr) ? this->sched->getCurrentVal() : 0.0; if (SchedVal == 2.0) { this->setPt = interpSetPoint(this->low2, this->high2, state.dataEnvrn->OutDryBulbTemp, this->lowSetPt2, this->highSetPt2); } else { - if ((this->schedNum > 0) && (SchedVal != 1.0)) { // Since schedule is optional, only check this if the user entered a schedule + if ((this->sched != nullptr) && (SchedVal != 1.0)) { // Since schedule is optional, only check this if the user entered a schedule ++this->setPtErrorCount; if (this->setPtErrorCount <= 10) { ShowSevereError(state, @@ -3270,7 +3248,7 @@ void SPMReturnAirBypassFlow::calculate(EnergyPlusData &state) auto &mixerOutNode = state.dataLoopNodes->Node(this->mixOutNodeNum); auto &loopOutNode = state.dataLoopNodes->Node(this->sysOutNodeNum); - Real64 TempSetPt = GetCurrentScheduleValue(state, this->schedNum); + Real64 TempSetPt = this->sched->getCurrentVal(); Real64 TempSetPtMod = TempSetPt - (loopOutNode.Temp - mixerOutNode.Temp); Real64 SupFlow = mixerSupInNode.MassFlowRate; Real64 TempSup = mixerSupInNode.Temp; @@ -3536,13 +3514,12 @@ void SPMCondenserEnteringTemp::calculate(EnergyPlusData &state) // and two other curves to place boundary conditions on the optimal setpoint value. // Using/Aliasing - using ScheduleManager::GetCurrentScheduleValue; using namespace DataPlant; auto &dspm = state.dataSetPointManager; // Current timestep's condenser water entering setpoint - Real64 CondenserEnteringTempSetPoint = GetCurrentScheduleValue(state, this->condenserEnteringTempSchedNum); + Real64 CondenserEnteringTempSetPoint = this->condenserEnteringTempSched->getCurrentVal(); auto &supplyLoop = state.dataPlnt->PlantLoop(this->plantPloc.loopNum).LoopSide(LoopSideLocation::Supply); auto &supplyComp = supplyLoop.Branch(this->plantPloc.branchNum).Comp(this->plantPloc.compNum); @@ -3894,8 +3871,8 @@ void SPMReturnWaterTemp::calculate(EnergyPlusData &state) // greater than zero if the input type is scheduled, and the useReturnTempSetpoint flag is only // true if the input type is specified as such Real64 T_return_target = this->returnTempConstantTarget; - if (this->returnTempSchedNum > 0) { - T_return_target = GetCurrentScheduleValue(state, this->returnTempSchedNum); + if (this->returnTempSched != nullptr) { + T_return_target = this->returnTempSched->getCurrentVal(); } else if (this->returnTempType == ReturnTempType::Setpoint) { if (returnNode.TempSetPoint != SensedNodeFlagValue) { T_return_target = returnNode.TempSetPoint; @@ -4453,8 +4430,8 @@ HVAC::CtrlVarType GetHumidityRatioVariableType(EnergyPlusData &state, int const } // GetHumidityRatioVariableType() void SetUpNewScheduledTESSetPtMgr(EnergyPlusData &state, - int const SchedPtr, - int const SchedPtrCharge, + Sched::Schedule *sched, + Sched::Schedule *chargeSched, Real64 NonChargeCHWTemp, Real64 ChargeCHWTemp, DataPlant::CtrlType CompOpType, @@ -4479,8 +4456,8 @@ void SetUpNewScheduledTESSetPtMgr(EnergyPlusData &state, state.dataSetPointManager->spms.push_back(spm); state.dataSetPointManager->spmMap.insert_or_assign(spm->Name, state.dataSetPointManager->spms.size()); - spm->schedNum = SchedPtr; - spm->schedNumCharge = SchedPtrCharge; + spm->sched = sched; + spm->chargeSched = chargeSched; spm->nonChargeCHWTemp = NonChargeCHWTemp; spm->chargeCHWTemp = ChargeCHWTemp; spm->compOpType = CompOpType; diff --git a/src/EnergyPlus/SetPointManager.hh b/src/EnergyPlus/SetPointManager.hh index d3ddac62ea3..dca6544c9cb 100644 --- a/src/EnergyPlus/SetPointManager.hh +++ b/src/EnergyPlus/SetPointManager.hh @@ -166,15 +166,15 @@ namespace SetPointManager { struct SPMScheduled : SPMBase // Derived type for Scheduled Setpoint Manager data { - int schedNum = 0; + Sched::Schedule *sched = nullptr; void calculate(EnergyPlusData &state) override; }; struct SPMScheduledDual : SPMBase // Derived type for Scheduled Dual Setpoint Manager { - int schedNumHi = 0; - int schedNumLo = 0; + Sched::Schedule *hiSched = nullptr; + Sched::Schedule *loSched = nullptr; Real64 setPtHi = 0.0; Real64 setPtLo = 0.0; @@ -184,11 +184,12 @@ namespace SetPointManager { struct SPMOutsideAir : SPMBase // Derived type for Outside Air Setpoint Manager Data { // Members + Sched::Schedule *sched = nullptr; + Real64 lowSetPt1 = 0.0; // 1st setpoint at outside low Real64 low1 = 0.0; // 1st Outside low Real64 highSetPt1 = 0.0; // 1st setpoint at outside high Real64 high1 = 0.0; // 1st Outside high - int schedNum = 0; // Schedule index int invalidSchedValErrorIndex = 0; // index for recurring error when schedule is not 1 or 2 int setPtErrorCount = 0; // countfor recurring error when schedule is not 1 or 2 Real64 lowSetPt2 = 0.0; // 2nd setpoint at outside low (optional) @@ -288,7 +289,7 @@ namespace SetPointManager { struct SPMReturnAirBypassFlow : SPMBase { // Members - int schedNum = 0; // index of the above schedule + Sched::Schedule *sched = nullptr; Real64 FlowSetPt = 0; // mass flow rate setpoint (kg/s) int rabMixInNodeNum = 0; int supMixInNodeNum = 0; @@ -343,7 +344,7 @@ namespace SetPointManager { struct SPMCondenserEnteringTemp : SPMBase // derived type for SetpointManager:CondenserEnteringReset data { // Members - int condenserEnteringTempSchedNum = 0; // default condenser entering water temperature schedule Index + Sched::Schedule *condenserEnteringTempSched = nullptr; // default condenser entering water temperature schedule Index Real64 towerDesignInletAirWetBulbTemp = 0; // cooling tower design inlet air wetbulb temperature int minTowerDesignWetBulbCurveNum = 0; // minimum design wetbulb temperature curve name int minOAWetBulbCurveNum = 0; // minimum outside air wetbulb temperature curve name @@ -422,7 +423,7 @@ namespace SetPointManager { // Members int returnNodeNum = 0; // node ID for the plant supply-side return node int supplyNodeNum = 0; // node ID for the plant supply-side supply node - int returnTempSchedNum = 0; // the index in Schedules array for the scheduled return temperature; zero if not used + Sched::Schedule *returnTempSched = nullptr; // scheduled return temperature Real64 returnTempConstantTarget = 0.0; // the constant value used as the return temperature target; used if schedule index is zero Real64 currentSupplySetPt = 0.0; // the current supply setpoint temperature int plantLoopNum = 0; // the index for the plant loop for this manager, zero if not initialized @@ -437,8 +438,8 @@ namespace SetPointManager { struct SPMTESScheduled : SPMBase // Derived type for Scheduled TES Setpoint Manager data { // Members - int schedNum = 0; - int schedNumCharge = 0; + Sched::Schedule *sched = nullptr; // Default is AlwaysOff + Sched::Schedule *chargeSched = nullptr; // Default is AlwaysOff int ctrlNodeNum = 0; Real64 nonChargeCHWTemp = 0.0; Real64 chargeCHWTemp = 0.0; @@ -492,8 +493,8 @@ namespace SetPointManager { HVAC::CtrlVarType GetHumidityRatioVariableType(EnergyPlusData &state, int CtrlNodeNum); void SetUpNewScheduledTESSetPtMgr(EnergyPlusData &state, - int SchedPtr, - int SchedPtrCharge, + Sched::Schedule *onPeakSched, + Sched::Schedule *chargeSched, Real64 NonChargeCHWTemp, Real64 ChargeCHWTemp, DataPlant::CtrlType CompOpType, @@ -541,6 +542,10 @@ struct SetPointManagerData : BaseGlobalStruct Real64 CET_OptCondenserEnteringTemp = 0.0; Real64 CET_CurMinLift = 0.0; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/SimAirServingZones.cc b/src/EnergyPlus/SimAirServingZones.cc index 5a8ccc20e53..3ef45756f49 100644 --- a/src/EnergyPlus/SimAirServingZones.cc +++ b/src/EnergyPlus/SimAirServingZones.cc @@ -387,7 +387,7 @@ void GetAirPathData(EnergyPlusData &state) cAlphaFields = ""; lAlphaBlanks = true; - state.dataSimAirServingZones->NumOfTimeStepInDay = state.dataGlobal->NumOfTimeStepInHour * 24; + state.dataSimAirServingZones->NumOfTimeStepInDay = state.dataGlobal->TimeStepsInHour * Constant::iHoursInDay; state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, "NodeList", NumParams, NumAlphas, NumNumbers); NodeNums.dimension(NumParams, 0); @@ -5053,7 +5053,7 @@ void UpdateSysSizing(EnergyPlusData &state, Constant::CallIndicator const CallIn Real64 termunitsizingtemp; // (1.0+termunitsizing(ctrlzone)%inducrat) Real64 VozClg(0.0); // corrected (for ventilation efficiency) zone outside air flow rate [m3/s] - numOfTimeStepInDay = state.dataGlobal->NumOfTimeStepInHour * 24; + numOfTimeStepInDay = state.dataGlobal->TimeStepsInHour * Constant::iHoursInDay; // allocate scratch arrays if (!allocated(state.dataSize->SensCoolCapTemp)) { @@ -5176,7 +5176,7 @@ void UpdateSysSizing(EnergyPlusData &state, Constant::CallIndicator const CallIn } // End of begin day loop over primary air systems } break; case Constant::CallIndicator::DuringDay: { - TimeStepInDay = (state.dataGlobal->HourOfDay - 1) * state.dataGlobal->NumOfTimeStepInHour + + TimeStepInDay = (state.dataGlobal->HourOfDay - 1) * state.dataGlobal->TimeStepsInHour + state.dataGlobal->TimeStep; // calculate current zone time step index // Correct the zone return temperature in ZoneSizing for the case of induction units. The calc in @@ -6995,9 +6995,9 @@ void UpdateSysSizing(EnergyPlusData &state, Constant::CallIndicator const CallIn Minutes = 0; TimeStepIndex = 0; for (HourCounter = 1; HourCounter <= 24; ++HourCounter) { - for (TimeStepCounter = 1; TimeStepCounter <= state.dataGlobal->NumOfTimeStepInHour; ++TimeStepCounter) { + for (TimeStepCounter = 1; TimeStepCounter <= state.dataGlobal->TimeStepsInHour; ++TimeStepCounter) { ++TimeStepIndex; - Minutes += state.dataGlobal->MinutesPerTimeStep; + Minutes += state.dataGlobal->MinutesInTimeStep; if (Minutes == 60) { Minutes = 0; HourPrint = HourCounter; diff --git a/src/EnergyPlus/SimAirServingZones.hh b/src/EnergyPlus/SimAirServingZones.hh index b745e95c801..68e6137649a 100644 --- a/src/EnergyPlus/SimAirServingZones.hh +++ b/src/EnergyPlus/SimAirServingZones.hh @@ -278,6 +278,10 @@ struct SimAirServingZonesData : BaseGlobalStruct std::string ErrEnvironmentName; std::string ErrEnvironmentNameSolveWaterCoilController; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/SimulationManager.cc b/src/EnergyPlus/SimulationManager.cc index 4f5808e0f65..0613400694b 100644 --- a/src/EnergyPlus/SimulationManager.cc +++ b/src/EnergyPlus/SimulationManager.cc @@ -209,6 +209,7 @@ namespace SimulationManager { state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "RunPeriod:CustomRange") > 0 || state.dataSysVars->FullAnnualRun); state.dataErrTracking->AskForConnectionsReport = false; // set to false until sizing is finished + state.init_constant_state(state); state.init_state(state); CheckForMisMatchedEnvironmentSpecifications(state); @@ -332,7 +333,7 @@ namespace SimulationManager { if (state.dataSQLiteProcedures->sqlite) { state.dataSQLiteProcedures->sqlite->sqliteBegin(); - state.dataSQLiteProcedures->sqlite->updateSQLiteSimulationRecord(1, state.dataGlobal->NumOfTimeStepInHour); + state.dataSQLiteProcedures->sqlite->updateSQLiteSimulationRecord(1, state.dataGlobal->TimeStepsInHour); state.dataSQLiteProcedures->sqlite->sqliteCommit(); } @@ -453,7 +454,7 @@ namespace SimulationManager { state.dataGlobal->BeginHourFlag = true; state.dataGlobal->EndHourFlag = false; - for (state.dataGlobal->TimeStep = 1; state.dataGlobal->TimeStep <= state.dataGlobal->NumOfTimeStepInHour; + for (state.dataGlobal->TimeStep = 1; state.dataGlobal->TimeStep <= state.dataGlobal->TimeStepsInHour; ++state.dataGlobal->TimeStep) { if (state.dataGlobal->stopSimulation) break; @@ -465,8 +466,8 @@ namespace SimulationManager { Weather::UpdateUnderwaterBoundaries(state); } - if (state.dataEnvrn->varyingLocationSchedIndexLat > 0 || state.dataEnvrn->varyingLocationSchedIndexLong > 0 || - state.dataEnvrn->varyingOrientationSchedIndex > 0) { + if (state.dataEnvrn->varyingLocationLatSched != nullptr || state.dataEnvrn->varyingLocationLongSched != nullptr || + state.dataEnvrn->varyingOrientationSched != nullptr) { Weather::UpdateLocationAndOrientation(state); } @@ -480,7 +481,7 @@ namespace SimulationManager { // Note also that BeginTimeStepFlag, EndTimeStepFlag, and the // SubTimeStepFlags can/will be set/reset in the HVAC Manager. - if (state.dataGlobal->TimeStep == state.dataGlobal->NumOfTimeStepInHour) { + if (state.dataGlobal->TimeStep == state.dataGlobal->TimeStepsInHour) { state.dataGlobal->EndHourFlag = true; if (state.dataGlobal->HourOfDay == 24) { state.dataGlobal->EndDayFlag = true; @@ -764,63 +765,63 @@ namespace SimulationManager { state.dataIPShortCut->lAlphaFieldBlanks, state.dataIPShortCut->cAlphaFieldNames, state.dataIPShortCut->cNumericFieldNames); - state.dataGlobal->NumOfTimeStepInHour = Number(1); + state.dataGlobal->TimeStepsInHour = Number(1); if (state.dataSysVars->ciForceTimeStep) { - state.dataGlobal->NumOfTimeStepInHour = 2; // Force 30 minute time steps on CI + state.dataGlobal->TimeStepsInHour = 2; // Force 30 minute time steps on CI } - if (state.dataGlobal->NumOfTimeStepInHour <= 0 || state.dataGlobal->NumOfTimeStepInHour > 60) { - Alphas(1) = fmt::to_string(state.dataGlobal->NumOfTimeStepInHour); + if (state.dataGlobal->TimeStepsInHour <= 0 || state.dataGlobal->TimeStepsInHour > 60) { + Alphas(1) = fmt::to_string(state.dataGlobal->TimeStepsInHour); ShowWarningError(state, format("{}: Requested number ({}) invalid, Defaulted to 4", CurrentModuleObject, Alphas(1))); - state.dataGlobal->NumOfTimeStepInHour = 4; - } else if (mod(60, state.dataGlobal->NumOfTimeStepInHour) != 0) { + state.dataGlobal->TimeStepsInHour = 4; + } else if (mod(60, state.dataGlobal->TimeStepsInHour) != 0) { MinInt = 9999; for (Num = 1; Num <= 12; ++Num) { - if (std::abs(state.dataGlobal->NumOfTimeStepInHour - Div60[Num - 1]) > MinInt) continue; - MinInt = state.dataGlobal->NumOfTimeStepInHour - Div60[Num - 1]; + if (std::abs(state.dataGlobal->TimeStepsInHour - Div60[Num - 1]) > MinInt) continue; + MinInt = state.dataGlobal->TimeStepsInHour - Div60[Num - 1]; Which = Num; } ShowWarningError(state, format("{}: Requested number ({}) not evenly divisible into 60, defaulted to nearest ({}).", CurrentModuleObject, - state.dataGlobal->NumOfTimeStepInHour, + state.dataGlobal->TimeStepsInHour, Div60[Which - 1])); - state.dataGlobal->NumOfTimeStepInHour = Div60[Which - 1]; + state.dataGlobal->TimeStepsInHour = Div60[Which - 1]; } - if (CondFDAlgo && state.dataGlobal->NumOfTimeStepInHour < 20) { + if (CondFDAlgo && state.dataGlobal->TimeStepsInHour < 20) { ShowWarningError(state, format("{}: Requested number ({}) cannot be used when Conduction Finite Difference algorithm is selected.", CurrentModuleObject, - state.dataGlobal->NumOfTimeStepInHour)); + state.dataGlobal->TimeStepsInHour)); ShowContinueError(state, format("...{} is set to 20.", CurrentModuleObject)); - state.dataGlobal->NumOfTimeStepInHour = 20; + state.dataGlobal->TimeStepsInHour = 20; } - if (state.dataGlobal->NumOfTimeStepInHour < 4 && state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Zone") > 0) { + if (state.dataGlobal->TimeStepsInHour < 4 && state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Zone") > 0) { ShowWarningError(state, format("{}: Requested number ({}) is less than the suggested minimum of 4.", CurrentModuleObject, - state.dataGlobal->NumOfTimeStepInHour)); + state.dataGlobal->TimeStepsInHour)); ShowContinueError(state, format("Please see entry for {} in Input/Output Reference for discussion of considerations.", CurrentModuleObject)); } } else if (Num == 0 && state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Zone") > 0 && !CondFDAlgo) { ShowWarningError(state, format("No {} object found. Number of TimeSteps in Hour defaulted to 4.", CurrentModuleObject)); - state.dataGlobal->NumOfTimeStepInHour = 4; + state.dataGlobal->TimeStepsInHour = 4; } else if (Num == 0 && !CondFDAlgo) { - state.dataGlobal->NumOfTimeStepInHour = 4; + state.dataGlobal->TimeStepsInHour = 4; } else if (Num == 0 && state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Zone") > 0 && CondFDAlgo) { ShowWarningError(state, format("No {} object found. Number of TimeSteps in Hour defaulted to 20.", CurrentModuleObject)); ShowContinueError(state, "...Due to presence of Conduction Finite Difference Algorithm selection."); - state.dataGlobal->NumOfTimeStepInHour = 20; + state.dataGlobal->TimeStepsInHour = 20; } else if (Num == 0 && CondFDAlgo) { - state.dataGlobal->NumOfTimeStepInHour = 20; + state.dataGlobal->TimeStepsInHour = 20; } else { ShowSevereError(state, format("Too many {} Objects found.", CurrentModuleObject)); ErrorsFound = true; } - state.dataGlobal->TimeStepZone = 1.0 / double(state.dataGlobal->NumOfTimeStepInHour); - state.dataGlobal->MinutesPerTimeStep = state.dataGlobal->TimeStepZone * 60; - state.dataGlobal->TimeStepZoneSec = state.dataGlobal->TimeStepZone * Constant::SecInHour; + state.dataGlobal->TimeStepZone = 1.0 / double(state.dataGlobal->TimeStepsInHour); + state.dataGlobal->MinutesInTimeStep = state.dataGlobal->TimeStepZone * 60; + state.dataGlobal->TimeStepZoneSec = state.dataGlobal->TimeStepZone * Constant::rSecsInHour; CurrentModuleObject = "ConvergenceLimits"; Num = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject); @@ -838,8 +839,8 @@ namespace SimulationManager { state.dataIPShortCut->cAlphaFieldNames, state.dataIPShortCut->cNumericFieldNames); MinInt = int(Number(1)); - if (MinInt > state.dataGlobal->MinutesPerTimeStep) { - MinInt = state.dataGlobal->MinutesPerTimeStep; + if (MinInt > state.dataGlobal->MinutesInTimeStep) { + MinInt = state.dataGlobal->MinutesInTimeStep; } if (MinInt < 0 || MinInt > 60) { ShowWarningError( @@ -1182,10 +1183,10 @@ namespace SimulationManager { if (overrideTimestep) { ShowWarningError(state, "Due to PerformancePrecisionTradeoffs Override Mode, the Number of TimeSteps has been changed to 1."); - state.dataGlobal->NumOfTimeStepInHour = 1; - state.dataGlobal->TimeStepZone = 1.0 / double(state.dataGlobal->NumOfTimeStepInHour); - state.dataGlobal->MinutesPerTimeStep = state.dataGlobal->TimeStepZone * 60; - state.dataGlobal->TimeStepZoneSec = state.dataGlobal->TimeStepZone * Constant::SecInHour; + state.dataGlobal->TimeStepsInHour = 1; + state.dataGlobal->TimeStepZone = 1.0 / double(state.dataGlobal->TimeStepsInHour); + state.dataGlobal->MinutesInTimeStep = state.dataGlobal->TimeStepZone * Constant::rMinutesInHour; + state.dataGlobal->TimeStepZoneSec = state.dataGlobal->TimeStepZone * Constant::rSecsInHour; state.dataGlobal->OverrideTimestep = true; } if (overrideZoneAirHeatBalAlg) { @@ -1209,8 +1210,8 @@ namespace SimulationManager { ShowWarningError( state, "Due to PerformancePrecisionTradeoffs Override Mode, the minimum System TimeSteps has been changed to 1 hr."); int MinTimeStepSysOverrideValue = 60.0; - if (MinTimeStepSysOverrideValue > state.dataGlobal->MinutesPerTimeStep) { - MinTimeStepSysOverrideValue = state.dataGlobal->MinutesPerTimeStep; + if (MinTimeStepSysOverrideValue > state.dataGlobal->MinutesInTimeStep) { + MinTimeStepSysOverrideValue = state.dataGlobal->MinutesInTimeStep; } state.dataConvergeParams->MinTimeStepSys = MinTimeStepSysOverrideValue / 60.0; state.dataHVACGlobal->LimitNumSysSteps = int(state.dataGlobal->TimeStepZone / state.dataConvergeParams->MinTimeStepSys); @@ -1248,7 +1249,7 @@ namespace SimulationManager { print(state.files.eio, "{}\n", "! , #TimeSteps, Minutes per TimeStep {minutes}"); static constexpr std::string_view Format_731(" Timesteps per Hour, {:2}, {:2}\n"); - print(state.files.eio, Format_731, state.dataGlobal->NumOfTimeStepInHour, state.dataGlobal->MinutesPerTimeStep); + print(state.files.eio, Format_731, state.dataGlobal->TimeStepsInHour, state.dataGlobal->MinutesInTimeStep); print(state.files.eio, "{}\n", @@ -1321,7 +1322,7 @@ namespace SimulationManager { Alphas(2) = "ScriptF"; } Alphas(3) = overrideModeValue; - Alphas(4) = fmt::to_string(state.dataGlobal->NumOfTimeStepInHour); + Alphas(4) = fmt::to_string(state.dataGlobal->TimeStepsInHour); if (state.dataHeatBal->OverrideZoneAirSolutionAlgo) { Alphas(5) = "Yes"; } else { @@ -1390,7 +1391,7 @@ namespace SimulationManager { Util::appendPerfLog(state, "Zone Radiant Exchange Algorithm", "ScriptF"); } Util::appendPerfLog(state, "Override Mode", currentOverrideModeValue); - Util::appendPerfLog(state, "Number of Timesteps per Hour", fmt::to_string(state.dataGlobal->NumOfTimeStepInHour)); + Util::appendPerfLog(state, "Number of Timesteps per Hour", fmt::to_string(state.dataGlobal->TimeStepsInHour)); Util::appendPerfLog(state, "Minimum Number of Warmup Days", fmt::to_string(state.dataHeatBal->MinNumberOfWarmupDays)); Util::appendPerfLog(state, "SuppressAllBeginEnvironmentResets", bool_to_string(state.dataEnvrn->forceBeginEnvResetSuppress)); Util::appendPerfLog(state, "Minimum System Timestep", format("{:.1R}", state.dataConvergeParams->MinTimeStepSys * 60.0)); @@ -1905,7 +1906,7 @@ namespace SimulationManager { // do an end of day, end of environment time step state.dataGlobal->HourOfDay = 24; - state.dataGlobal->TimeStep = state.dataGlobal->NumOfTimeStepInHour; + state.dataGlobal->TimeStep = state.dataGlobal->TimeStepsInHour; state.dataGlobal->EndEnvrnFlag = true; if (state.dataSysVars->DeveloperFlag) diff --git a/src/EnergyPlus/SimulationManager.hh b/src/EnergyPlus/SimulationManager.hh index 86f23c4a5d7..4cc21a6df17 100644 --- a/src/EnergyPlus/SimulationManager.hh +++ b/src/EnergyPlus/SimulationManager.hh @@ -99,6 +99,11 @@ struct SimulationManagerData : BaseGlobalStruct bool RunControlInInput = false; bool PreP_Fatal = false; bool WarningOut = true; + + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state(EnergyPlusData &state) override { SimulationManager::OpenOutputFiles(state); diff --git a/src/EnergyPlus/SingleDuct.cc b/src/EnergyPlus/SingleDuct.cc index 69f03474ac6..072164de3d6 100644 --- a/src/EnergyPlus/SingleDuct.cc +++ b/src/EnergyPlus/SingleDuct.cc @@ -115,7 +115,6 @@ using HVAC::SmallMassFlow; using namespace DataSizing; using Psychrometrics::PsyCpAirFnW; using Psychrometrics::PsyRhoAirFnPbTdbW; -using namespace ScheduleManager; using namespace SteamCoils; static constexpr std::string_view fluidNameSteam("STEAM"); @@ -366,66 +365,62 @@ void GetSysInput(EnergyPlusData &state) cAlphaFields, cNumericFields); + ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)}; + state.dataSingleDuct->SysNumGSI = state.dataSingleDuct->SysIndexGSI; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysNum = state.dataSingleDuct->SysNumGSI; + + auto &airTerm = state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI); + airTerm.SysNum = state.dataSingleDuct->SysNumGSI; GlobalNames::VerifyUniqueInterObjectName( state, state.dataSingleDuct->SysUniqueNames, Alphas(1), CurrentModuleObject, cAlphaFields(1), ErrorsFound); - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName = Alphas(1); - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType = CurrentModuleObject; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysType_Num = SysType::SingleDuctVAVReheat; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp = Alphas(7); - if (Util::SameString(state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp, "Coil:Heating:Fuel")) { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp_Num = HeatingCoilType::Gas; - } else if (Util::SameString(state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp, "Coil:Heating:Electric")) { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp_Num = HeatingCoilType::Electric; - } else if (Util::SameString(state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp, "Coil:Heating:Water")) { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp_Num = HeatingCoilType::SimpleHeating; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp_PlantType = + airTerm.SysName = Alphas(1); + airTerm.sysType = CurrentModuleObject; + airTerm.SysType_Num = SysType::SingleDuctVAVReheat; + airTerm.ReheatComp = Alphas(7); + if (Util::SameString(airTerm.ReheatComp, "Coil:Heating:Fuel")) { + airTerm.ReheatComp_Num = HeatingCoilType::Gas; + } else if (Util::SameString(airTerm.ReheatComp, "Coil:Heating:Electric")) { + airTerm.ReheatComp_Num = HeatingCoilType::Electric; + } else if (Util::SameString(airTerm.ReheatComp, "Coil:Heating:Water")) { + airTerm.ReheatComp_Num = HeatingCoilType::SimpleHeating; + airTerm.ReheatComp_PlantType = DataPlant::PlantEquipmentType::CoilWaterSimpleHeating; - } else if (Util::SameString(state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp, "Coil:Heating:Steam")) { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp_Num = HeatingCoilType::SteamAirHeating; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp_PlantType = + } else if (Util::SameString(airTerm.ReheatComp, "Coil:Heating:Steam")) { + airTerm.ReheatComp_Num = HeatingCoilType::SteamAirHeating; + airTerm.ReheatComp_PlantType = DataPlant::PlantEquipmentType::CoilSteamAirHeating; - } else if (!state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp.empty()) { + } else if (!airTerm.ReheatComp.empty()) { ShowSevereError( - state, format("Illegal {} = {}.", cAlphaFields(8), state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp)); + state, format("Illegal {} = {}.", cAlphaFields(8), airTerm.ReheatComp)); ShowContinueError(state, format("Occurs in {} = {}", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); + airTerm.sysType, + airTerm.SysName)); ErrorsFound = true; } - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatName = Alphas(8); + airTerm.ReheatName = Alphas(8); ValidateComponent(state, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatName, + airTerm.ReheatComp, + airTerm.ReheatName, IsNotOK, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType); + airTerm.sysType); if (IsNotOK) { ShowContinueError(state, format("In {} = {}", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); + airTerm.sysType, + airTerm.SysName)); ErrorsFound = true; } - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).Schedule = Alphas(2); if (lAlphaBlanks(2)) { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SchedPtr = GetScheduleIndex(state, Alphas(2)); - if (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SchedPtr == 0) { - ShowSevereError(state, format("{} = {} not found.", cAlphaFields(2), Alphas(2))); - ShowContinueError(state, - format("Occurs in {} = {}", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); - ErrorsFound = true; - } + airTerm.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((airTerm.availSched = Sched::GetSchedule(state, Alphas(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(2), Alphas(2)); + ErrorsFound = true; } // For node connections, this object is both a parent and a non-parent, because the // VAV damper is not called out as a separate component, its nodes must be connected // as ObjectIsNotParent. But for the reheat coil, the nodes are connected as ObjectIsParent - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).OutletNodeNum = + airTerm.OutletNodeNum = GetOnlySingleNode(state, Alphas(3), ErrorsFound, @@ -436,7 +431,7 @@ void GetSysInput(EnergyPlusData &state) NodeInputManager::CompFluidStream::Primary, ObjectIsNotParent, cAlphaFields(3)); - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).InletNodeNum = + airTerm.InletNodeNum = GetOnlySingleNode(state, Alphas(4), ErrorsFound, @@ -447,116 +442,101 @@ void GetSysInput(EnergyPlusData &state) NodeInputManager::CompFluidStream::Primary, ObjectIsNotParent, cAlphaFields(4)); - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).MaxAirVolFlowRate = Numbers(1); + airTerm.MaxAirVolFlowRate = Numbers(1); if (Util::SameString(Alphas(5), "Constant")) { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneMinAirFracMethod = MinFlowFraction::Constant; + airTerm.ZoneMinAirFracMethod = MinFlowFraction::Constant; } else if (Util::SameString(Alphas(5), "FixedFlowRate")) { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneMinAirFracMethod = MinFlowFraction::Fixed; + airTerm.ZoneMinAirFracMethod = MinFlowFraction::Fixed; } else if (Util::SameString(Alphas(5), "Scheduled")) { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneMinAirFracMethod = MinFlowFraction::Scheduled; + airTerm.ZoneMinAirFracMethod = MinFlowFraction::Scheduled; } else { ShowSevereError(state, format("{} = {} not found.", cAlphaFields(5), Alphas(5))); ShowContinueError(state, format("Occurs in {} = {}", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); + airTerm.sysType, + airTerm.SysName)); ErrorsFound = true; } - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneMinAirFracDes = Numbers(2); + airTerm.ZoneMinAirFracDes = Numbers(2); if (lNumericBlanks(2)) { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ConstantMinAirFracSetByUser = false; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).DesignMinAirFrac = 0.0; + airTerm.ConstantMinAirFracSetByUser = false; + airTerm.DesignMinAirFrac = 0.0; } else { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ConstantMinAirFracSetByUser = true; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).DesignMinAirFrac = Numbers(2); - if (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneMinAirFracMethod == MinFlowFraction::Fixed) { + airTerm.ConstantMinAirFracSetByUser = true; + airTerm.DesignMinAirFrac = Numbers(2); + if (airTerm.ZoneMinAirFracMethod == MinFlowFraction::Fixed) { ShowWarningError(state, format("Since {} = {}, input for {} will be ignored.", cAlphaFields(5), Alphas(5), cNumericFields(2))); ShowContinueError(state, format("Occurs in {} = {}", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneMinAirFracDes = 0.0; + airTerm.sysType, + airTerm.SysName)); + airTerm.ZoneMinAirFracDes = 0.0; } } - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneFixedMinAir = Numbers(3); + airTerm.ZoneFixedMinAir = Numbers(3); if (lNumericBlanks(3)) { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).FixedMinAirSetByUser = false; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).DesignMinAirFrac = 0.0; + airTerm.FixedMinAirSetByUser = false; + airTerm.DesignMinAirFrac = 0.0; } else { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).FixedMinAirSetByUser = true; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).DesignMinAirFrac = Numbers(3); - if (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneMinAirFracMethod == MinFlowFraction::Constant) { + airTerm.FixedMinAirSetByUser = true; + airTerm.DesignMinAirFrac = Numbers(3); + if (airTerm.ZoneMinAirFracMethod == MinFlowFraction::Constant) { ShowWarningError(state, format("Since {} = {}, input for {} will be ignored.", cAlphaFields(5), Alphas(5), cNumericFields(3))); - ShowContinueError(state, - format("Occurs in {} = {}", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneFixedMinAir = 0.0; + ShowContinueError(state, format("Occurs in {} = {}", airTerm.sysType, airTerm.SysName)); + airTerm.ZoneFixedMinAir = 0.0; } } - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneMinAirFracSchPtr = GetScheduleIndex(state, Alphas(6)); - if ((state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneMinAirFracSchPtr == 0) && - (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneMinAirFracMethod == MinFlowFraction::Scheduled)) { - ShowSevereError(state, format("{} = {} not found.", cAlphaFields(6), Alphas(6))); - ShowContinueError(state, - format("Occurs in {} = {}", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); - ShowContinueError(state, "A valid schedule is required"); + if (airTerm.ZoneMinAirFracMethod != MinFlowFraction::Scheduled) { + } else if (lAlphaBlanks(6)) { + ShowSevereEmptyField(state, eoh, cAlphaFields(6)); + ErrorsFound = true; + } else if ((airTerm.zoneMinAirFracSched = Sched::GetSchedule(state, Alphas(6))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(6), Alphas(6)); + ErrorsFound = true; + } else if (!airTerm.zoneMinAirFracSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) { + Sched::ShowSevereBadMinMax(state, eoh, cAlphaFields(6), Alphas(6), Clusive::In, 0.0, Clusive::In, 1.0); ErrorsFound = true; - } else if ((state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneMinAirFracSchPtr > 0) && - (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneMinAirFracMethod == MinFlowFraction::Scheduled)) { - // check range of values in schedule - if (!CheckScheduleValueMinMax( - state, state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneMinAirFracSchPtr, ">=", 0.0, "<=", 1.0)) { - ShowSevereError(state, format("Error found in {} = {}", cAlphaFields(6), Alphas(6))); - ShowContinueError(state, - format("Occurs in {} = {}", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); - ShowContinueError(state, "Schedule values must be (>=0., <=1.)"); - } } // The reheat coil control node is necessary for hot water and steam reheat, but not necessary for // electric or gas reheat. - if (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp_Num != HeatingCoilType::Gas && - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp_Num != HeatingCoilType::Electric) { - if (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp_Num == HeatingCoilType::SteamAirHeating) { + if (airTerm.ReheatComp_Num != HeatingCoilType::Gas && + airTerm.ReheatComp_Num != HeatingCoilType::Electric) { + if (airTerm.ReheatComp_Num == HeatingCoilType::SteamAirHeating) { IsNotOK = false; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatControlNode = + airTerm.ReheatControlNode = GetCoilSteamInletNode(state, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatName, + airTerm.ReheatComp, + airTerm.ReheatName, IsNotOK); if (IsNotOK) { ShowContinueError(state, format("..Occurs in {} = {}", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); + airTerm.sysType, + airTerm.SysName)); ErrorsFound = true; } } else { IsNotOK = false; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatControlNode = + airTerm.ReheatControlNode = GetCoilWaterInletNode(state, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatName, + airTerm.ReheatComp, + airTerm.ReheatName, IsNotOK); if (IsNotOK) { ShowContinueError(state, format("..Occurs in {} = {}", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); + airTerm.sysType, + airTerm.SysName)); ErrorsFound = true; } } } - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatAirOutletNode = + airTerm.ReheatAirOutletNode = GetOnlySingleNode(state, Alphas(9), ErrorsFound, @@ -567,61 +547,61 @@ void GetSysInput(EnergyPlusData &state) NodeInputManager::CompFluidStream::Primary, ObjectIsParent, cAlphaFields(9)); - if (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp_Num == HeatingCoilType::SteamAirHeating) { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).MaxReheatSteamVolFlow = Numbers(4); - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).MinReheatSteamVolFlow = Numbers(5); + if (airTerm.ReheatComp_Num == HeatingCoilType::SteamAirHeating) { + airTerm.MaxReheatSteamVolFlow = Numbers(4); + airTerm.MinReheatSteamVolFlow = Numbers(5); } else { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).MaxReheatWaterVolFlow = Numbers(4); - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).MinReheatWaterVolFlow = Numbers(5); + airTerm.MaxReheatWaterVolFlow = Numbers(4); + airTerm.MinReheatWaterVolFlow = Numbers(5); } - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ControllerOffset = Numbers(6); + airTerm.ControllerOffset = Numbers(6); // Set default convergence tolerance - if (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ControllerOffset <= 0.0) { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ControllerOffset = 0.001; + if (airTerm.ControllerOffset <= 0.0) { + airTerm.ControllerOffset = 0.001; } if (Util::SameString(Alphas(10), "Reverse")) { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).DamperHeatingAction = Action::Reverse; + airTerm.DamperHeatingAction = Action::Reverse; } else if (Util::SameString(Alphas(10), "Normal")) { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).DamperHeatingAction = Action::Normal; + airTerm.DamperHeatingAction = Action::Normal; } else if (Util::SameString(Alphas(10), "ReverseWithLimits")) { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).DamperHeatingAction = Action::ReverseWithLimits; + airTerm.DamperHeatingAction = Action::ReverseWithLimits; } else { ShowSevereError(state, format("{} = {} not found.", cAlphaFields(10), Alphas(10))); ShowContinueError(state, format("Occurs in {} = {}", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); + airTerm.sysType, + airTerm.SysName)); ErrorsFound = true; } // Register component set data TestCompSet(state, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName, - state.dataLoopNodes->NodeID(state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).InletNodeNum), - state.dataLoopNodes->NodeID(state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatAirOutletNode), + airTerm.sysType, + airTerm.SysName, + state.dataLoopNodes->NodeID(airTerm.InletNodeNum), + state.dataLoopNodes->NodeID(airTerm.ReheatAirOutletNode), "Air Nodes"); for (ADUNum = 1; ADUNum <= (int)state.dataDefineEquipment->AirDistUnit.size(); ++ADUNum) { - if (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatAirOutletNode == + if (airTerm.ReheatAirOutletNode == state.dataDefineEquipment->AirDistUnit(ADUNum).OutletNodeNum) { state.dataDefineEquipment->AirDistUnit(ADUNum).InletNodeNum = - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).InletNodeNum; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ADUNum = ADUNum; + airTerm.InletNodeNum; + airTerm.ADUNum = ADUNum; break; } } // one assumes if there isn't one assigned, it's an error? - if (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ADUNum == 0) { + if (airTerm.ADUNum == 0) { ShowSevereError(state, format("{}No matching Air Distribution Unit, for System = [{},{}].", RoutineName, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); + airTerm.sysType, + airTerm.SysName)); ShowContinueError( state, format("...should have outlet node = {}", - state.dataLoopNodes->NodeID(state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatAirOutletNode))); + state.dataLoopNodes->NodeID(airTerm.ReheatAirOutletNode))); ErrorsFound = true; } else { @@ -629,34 +609,34 @@ void GetSysInput(EnergyPlusData &state) for (CtrlZone = 1; CtrlZone <= state.dataGlobal->NumOfZones; ++CtrlZone) { if (!state.dataZoneEquip->ZoneEquipConfig(CtrlZone).IsControlled) continue; for (SupAirIn = 1; SupAirIn <= state.dataZoneEquip->ZoneEquipConfig(CtrlZone).NumInletNodes; ++SupAirIn) { - if (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatAirOutletNode == + if (airTerm.ReheatAirOutletNode == state.dataZoneEquip->ZoneEquipConfig(CtrlZone).InletNode(SupAirIn)) { if (state.dataZoneEquip->ZoneEquipConfig(CtrlZone).AirDistUnitCool(SupAirIn).OutNode > 0) { ShowSevereError(state, "Error in connecting a terminal unit to a zone"); ShowContinueError(state, format("{} already connects to another zone", state.dataLoopNodes->NodeID( - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatAirOutletNode))); + airTerm.ReheatAirOutletNode))); ShowContinueError(state, format("Occurs for terminal unit {} = {}", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); + airTerm.sysType, + airTerm.SysName)); ShowContinueError(state, "Check terminal unit node names for errors"); ErrorsFound = true; } else { state.dataZoneEquip->ZoneEquipConfig(CtrlZone).AirDistUnitCool(SupAirIn).InNode = - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).InletNodeNum; + airTerm.InletNodeNum; state.dataZoneEquip->ZoneEquipConfig(CtrlZone).AirDistUnitCool(SupAirIn).OutNode = - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatAirOutletNode; - state.dataDefineEquipment->AirDistUnit(state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ADUNum) + airTerm.ReheatAirOutletNode; + state.dataDefineEquipment->AirDistUnit(airTerm.ADUNum) .TermUnitSizingNum = state.dataZoneEquip->ZoneEquipConfig(CtrlZone).AirDistUnitCool(SupAirIn).TermUnitSizingIndex; - state.dataDefineEquipment->AirDistUnit(state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ADUNum) + state.dataDefineEquipment->AirDistUnit(airTerm.ADUNum) .ZoneEqNum = CtrlZone; } - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).CtrlZoneNum = CtrlZone; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).CtrlZoneInNodeIndex = SupAirIn; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneFloorArea = + airTerm.CtrlZoneNum = CtrlZone; + airTerm.CtrlZoneInNodeIndex = SupAirIn; + airTerm.ZoneFloorArea = state.dataHeatBal->Zone(CtrlZone).FloorArea * state.dataHeatBal->Zone(CtrlZone).Multiplier * state.dataHeatBal->Zone(CtrlZone).ListMultiplier; } @@ -664,85 +644,76 @@ void GetSysInput(EnergyPlusData &state) } } if (Numbers(7) == Constant::AutoCalculate) { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).MaxAirVolFlowRateDuringReheat = Numbers(7); + airTerm.MaxAirVolFlowRateDuringReheat = Numbers(7); } else { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).MaxAirVolFlowRateDuringReheat = - Numbers(7) * state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneFloorArea; + airTerm.MaxAirVolFlowRateDuringReheat = + Numbers(7) * airTerm.ZoneFloorArea; } - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).MaxAirVolFractionDuringReheat = Numbers(8); + airTerm.MaxAirVolFractionDuringReheat = Numbers(8); - if (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).DamperHeatingAction != Action::ReverseWithLimits) { - if (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).MaxAirVolFlowRateDuringReheat > 0.0) { + if (airTerm.DamperHeatingAction != Action::ReverseWithLimits) { + if (airTerm.MaxAirVolFlowRateDuringReheat > 0.0) { ShowWarningError(state, format("Since {} = {}, input for {} will be ignored.", cAlphaFields(10), Alphas(10), cNumericFields(7))); ShowContinueError(state, format("Occurs in {} = {}", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); + airTerm.sysType, + airTerm.SysName)); } - if (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).MaxAirVolFractionDuringReheat > 0.0) { + if (airTerm.MaxAirVolFractionDuringReheat > 0.0) { ShowWarningError(state, format("Since {} = {}, input for {} will be ignored.", cAlphaFields(10), Alphas(10), cNumericFields(8))); ShowContinueError(state, format("Occurs in {} = {}", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); + airTerm.sysType, + airTerm.SysName)); } } // Maximum reheat air temperature, i.e. the maximum supply air temperature leaving the reheat coil if (!lNumericBlanks(9)) { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).MaxReheatTemp = Numbers(9); - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).MaxReheatTempSetByUser = true; + airTerm.MaxReheatTemp = Numbers(9); + airTerm.MaxReheatTempSetByUser = true; } else { // user does not specify maximum supply air temperature // sd_airterminal(SysNum)%MaxReheatTemp = 35.0D0 !C - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).MaxReheatTempSetByUser = false; + airTerm.MaxReheatTempSetByUser = false; } if (!lAlphaBlanks(11)) { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).OARequirementsPtr = + airTerm.OARequirementsPtr = Util::FindItemInList(Alphas(11), state.dataSize->OARequirements); - if (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).OARequirementsPtr == 0) { + if (airTerm.OARequirementsPtr == 0) { ShowSevereError(state, format("{} = {} not found.", cAlphaFields(11), Alphas(11))); ShowContinueError(state, format("Occurs in {} = {}", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); + airTerm.sysType, + airTerm.SysName)); ErrorsFound = true; } else { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).NoOAFlowInputFromUser = false; + airTerm.NoOAFlowInputFromUser = false; } } if (lAlphaBlanks(12)) { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneTurndownMinAirFrac = 1.0; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneTurndownMinAirFracSchExist = false; - } else { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneTurndownMinAirFracSchPtr = GetScheduleIndex(state, Alphas(12)); - if (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneTurndownMinAirFracSchPtr == 0) { - ShowSevereError(state, format("{} = {} not found.", cAlphaFields(12), Alphas(12))); - ShowContinueError(state, - format("Occurs in {} = {}", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); - ErrorsFound = true; - } - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneTurndownMinAirFracSchExist = true; + airTerm.ZoneTurndownMinAirFrac = 1.0; + } else if ((airTerm.zoneTurndownMinAirFracSched = Sched::GetSchedule(state, Alphas(12))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(12), Alphas(12)); + ErrorsFound = true; } - ValidateComponent(state, Alphas(7), Alphas(8), IsNotOK, state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType); + ValidateComponent(state, Alphas(7), Alphas(8), IsNotOK, airTerm.sysType); if (IsNotOK) { ShowContinueError(state, format("In {} = {}", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); + airTerm.sysType, + airTerm.SysName)); ErrorsFound = true; } // Add reheat coil to component sets array SetUpCompSets(state, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName, + airTerm.sysType, + airTerm.SysName, Alphas(7), Alphas(8), Alphas(3), @@ -752,17 +723,17 @@ void GetSysInput(EnergyPlusData &state) SetupOutputVariable(state, "Zone Air Terminal VAV Damper Position", Constant::Units::None, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).DamperPosition, + airTerm.DamperPosition, OutputProcessor::TimeStepType::System, OutputProcessor::StoreType::Average, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName); + airTerm.SysName); SetupOutputVariable(state, "Zone Air Terminal Minimum Air Flow Fraction", Constant::Units::None, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneMinAirFracReport, + airTerm.ZoneMinAirFracReport, OutputProcessor::TimeStepType::System, OutputProcessor::StoreType::Average, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName); + airTerm.SysName); } // end Number of Sys Loop @@ -784,66 +755,62 @@ void GetSysInput(EnergyPlusData &state) cAlphaFields, cNumericFields); + ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)}; state.dataSingleDuct->SysNumGSI = state.dataSingleDuct->SysIndexGSI + state.dataSingleDuct->NumVAVSysGSI; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysNum = state.dataSingleDuct->SysNumGSI; + + auto &airTerm = state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI); + airTerm.SysNum = state.dataSingleDuct->SysNumGSI; GlobalNames::VerifyUniqueInterObjectName( state, state.dataSingleDuct->SysUniqueNames, Alphas(1), CurrentModuleObject, cAlphaFields(1), ErrorsFound); - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName = Alphas(1); - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType = CurrentModuleObject; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysType_Num = SysType::SingleDuctCBVAVReheat; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp = Alphas(5); - if (Util::SameString(state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp, "Coil:Heating:Fuel")) { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp_Num = HeatingCoilType::Gas; - } else if (Util::SameString(state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp, "Coil:Heating:Electric")) { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp_Num = HeatingCoilType::Electric; - } else if (Util::SameString(state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp, "Coil:Heating:Water")) { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp_Num = HeatingCoilType::SimpleHeating; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp_PlantType = + airTerm.SysName = Alphas(1); + airTerm.sysType = CurrentModuleObject; + airTerm.SysType_Num = SysType::SingleDuctCBVAVReheat; + airTerm.ReheatComp = Alphas(5); + if (Util::SameString(airTerm.ReheatComp, "Coil:Heating:Fuel")) { + airTerm.ReheatComp_Num = HeatingCoilType::Gas; + } else if (Util::SameString(airTerm.ReheatComp, "Coil:Heating:Electric")) { + airTerm.ReheatComp_Num = HeatingCoilType::Electric; + } else if (Util::SameString(airTerm.ReheatComp, "Coil:Heating:Water")) { + airTerm.ReheatComp_Num = HeatingCoilType::SimpleHeating; + airTerm.ReheatComp_PlantType = DataPlant::PlantEquipmentType::CoilWaterSimpleHeating; - } else if (Util::SameString(state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp, "Coil:Heating:Steam")) { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp_Num = HeatingCoilType::SteamAirHeating; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp_PlantType = + } else if (Util::SameString(airTerm.ReheatComp, "Coil:Heating:Steam")) { + airTerm.ReheatComp_Num = HeatingCoilType::SteamAirHeating; + airTerm.ReheatComp_PlantType = DataPlant::PlantEquipmentType::CoilSteamAirHeating; - } else if (!state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp.empty()) { + } else if (!airTerm.ReheatComp.empty()) { ShowSevereError( - state, format("Illegal {} = {}.", cAlphaFields(5), state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp)); + state, format("Illegal {} = {}.", cAlphaFields(5), airTerm.ReheatComp)); ShowContinueError(state, format("Occurs in {} = {}", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); + airTerm.sysType, + airTerm.SysName)); ErrorsFound = true; } - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatName = Alphas(6); + airTerm.ReheatName = Alphas(6); ValidateComponent(state, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatName, + airTerm.ReheatComp, + airTerm.ReheatName, IsNotOK, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType); + airTerm.sysType); if (IsNotOK) { ShowContinueError(state, format("In {} = {}", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); + airTerm.sysType, + airTerm.SysName)); ErrorsFound = true; } - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).Schedule = Alphas(2); + if (lAlphaBlanks(2)) { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SchedPtr = GetScheduleIndex(state, Alphas(2)); - if (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SchedPtr == 0) { - ShowSevereError(state, format("{} = {} not found.", cAlphaFields(2), Alphas(2))); - ShowContinueError(state, - format("Occurs in {} = {}", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); - ErrorsFound = true; - } + airTerm.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((airTerm.availSched = Sched::GetSchedule(state, Alphas(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(2), Alphas(2)); + ErrorsFound = true; } // For node connections, this object is both a parent and a non-parent, because the // VAV damper is not called out as a separate component, its nodes must be connected // as ObjectIsNotParent. But for the reheat coil, the nodes are connected as ObjectIsParent - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).OutletNodeNum = + airTerm.OutletNodeNum = GetOnlySingleNode(state, Alphas(3), ErrorsFound, @@ -854,7 +821,7 @@ void GetSysInput(EnergyPlusData &state) NodeInputManager::CompFluidStream::Primary, ObjectIsNotParent, cAlphaFields(3)); - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).InletNodeNum = + airTerm.InletNodeNum = GetOnlySingleNode(state, Alphas(4), ErrorsFound, @@ -865,62 +832,62 @@ void GetSysInput(EnergyPlusData &state) NodeInputManager::CompFluidStream::Primary, ObjectIsNotParent, cAlphaFields(4)); - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).MaxAirVolFlowRate = Numbers(1); - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneMinAirFracDes = Numbers(2); - if (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneMinAirFracDes < 0.0) { + airTerm.MaxAirVolFlowRate = Numbers(1); + airTerm.ZoneMinAirFracDes = Numbers(2); + if (airTerm.ZoneMinAirFracDes < 0.0) { ShowWarningError(state, format("{} \"{}\"", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); + airTerm.sysType, + airTerm.SysName)); ShowContinueError(state, format("{} must be greater than or equal to 0. Resetting to 0 and the simulation continues.", cNumericFields(2))); - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneMinAirFracDes = 0.0; + airTerm.ZoneMinAirFracDes = 0.0; } - if (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneMinAirFracDes > 1.0) { + if (airTerm.ZoneMinAirFracDes > 1.0) { ShowWarningError(state, format("{} \"{}\"", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); + airTerm.sysType, + airTerm.SysName)); ShowContinueError(state, format("{} must be less than or equal to 1. Resetting to 1 and the simulation continues.", cNumericFields(2))); - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneMinAirFracDes = 1.0; + airTerm.ZoneMinAirFracDes = 1.0; } // The reheat coil control node is necessary for hot water and steam reheat, but not necessary for // electric or gas reheat. - if (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp_Num == HeatingCoilType::Gas || - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp_Num == HeatingCoilType::Electric) { + if (airTerm.ReheatComp_Num == HeatingCoilType::Gas || + airTerm.ReheatComp_Num == HeatingCoilType::Electric) { } else { - if (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp_Num == HeatingCoilType::SteamAirHeating) { + if (airTerm.ReheatComp_Num == HeatingCoilType::SteamAirHeating) { IsNotOK = false; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatControlNode = + airTerm.ReheatControlNode = GetCoilSteamInletNode(state, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatName, + airTerm.ReheatComp, + airTerm.ReheatName, IsNotOK); if (IsNotOK) { ShowContinueError(state, format("..Occurs in {} = {}", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); + airTerm.sysType, + airTerm.SysName)); ErrorsFound = true; } } else { IsNotOK = false; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatControlNode = + airTerm.ReheatControlNode = GetCoilWaterInletNode(state, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatName, + airTerm.ReheatComp, + airTerm.ReheatName, IsNotOK); if (IsNotOK) { ShowContinueError(state, format("..Occurs in {} = {}", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); + airTerm.sysType, + airTerm.SysName)); ErrorsFound = true; } } // END IF } - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatAirOutletNode = + airTerm.ReheatAirOutletNode = GetOnlySingleNode(state, Alphas(7), ErrorsFound, @@ -931,49 +898,49 @@ void GetSysInput(EnergyPlusData &state) NodeInputManager::CompFluidStream::Primary, ObjectIsParent, cAlphaFields(7)); - if (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp_Num == HeatingCoilType::SteamAirHeating) { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).MaxReheatSteamVolFlow = Numbers(3); - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).MinReheatSteamVolFlow = Numbers(4); + if (airTerm.ReheatComp_Num == HeatingCoilType::SteamAirHeating) { + airTerm.MaxReheatSteamVolFlow = Numbers(3); + airTerm.MinReheatSteamVolFlow = Numbers(4); } else { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).MaxReheatWaterVolFlow = Numbers(3); - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).MinReheatWaterVolFlow = Numbers(4); + airTerm.MaxReheatWaterVolFlow = Numbers(3); + airTerm.MinReheatWaterVolFlow = Numbers(4); } - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ControllerOffset = Numbers(5); + airTerm.ControllerOffset = Numbers(5); // Set default convergence tolerance - if (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ControllerOffset <= 0.0) { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ControllerOffset = 0.001; + if (airTerm.ControllerOffset <= 0.0) { + airTerm.ControllerOffset = 0.001; } - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).DamperHeatingAction = Action::Reverse; + airTerm.DamperHeatingAction = Action::Reverse; // Register component set data TestCompSet(state, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName, - state.dataLoopNodes->NodeID(state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).InletNodeNum), - state.dataLoopNodes->NodeID(state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatAirOutletNode), + airTerm.sysType, + airTerm.SysName, + state.dataLoopNodes->NodeID(airTerm.InletNodeNum), + state.dataLoopNodes->NodeID(airTerm.ReheatAirOutletNode), "Air Nodes"); for (ADUNum = 1; ADUNum <= (int)state.dataDefineEquipment->AirDistUnit.size(); ++ADUNum) { - if (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatAirOutletNode == + if (airTerm.ReheatAirOutletNode == state.dataDefineEquipment->AirDistUnit(ADUNum).OutletNodeNum) { state.dataDefineEquipment->AirDistUnit(ADUNum).InletNodeNum = - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).InletNodeNum; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ADUNum = ADUNum; + airTerm.InletNodeNum; + airTerm.ADUNum = ADUNum; break; } } // one assumes if there isn't one assigned, it's an error? - if (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ADUNum == 0) { + if (airTerm.ADUNum == 0) { ShowSevereError(state, format("{}No matching Air Distribution Unit, for System = [{},{}].", RoutineName, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); + airTerm.sysType, + airTerm.SysName)); ShowContinueError( state, format("...should have outlet node = {}", - state.dataLoopNodes->NodeID(state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatAirOutletNode))); + state.dataLoopNodes->NodeID(airTerm.ReheatAirOutletNode))); ErrorsFound = true; } else { @@ -981,33 +948,33 @@ void GetSysInput(EnergyPlusData &state) for (CtrlZone = 1; CtrlZone <= state.dataGlobal->NumOfZones; ++CtrlZone) { if (!state.dataZoneEquip->ZoneEquipConfig(CtrlZone).IsControlled) continue; for (SupAirIn = 1; SupAirIn <= state.dataZoneEquip->ZoneEquipConfig(CtrlZone).NumInletNodes; ++SupAirIn) { - if (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatAirOutletNode == + if (airTerm.ReheatAirOutletNode == state.dataZoneEquip->ZoneEquipConfig(CtrlZone).InletNode(SupAirIn)) { if (state.dataZoneEquip->ZoneEquipConfig(CtrlZone).AirDistUnitCool(SupAirIn).OutNode > 0) { ShowSevereError(state, "Error in connecting a terminal unit to a zone"); ShowContinueError(state, format("{} already connects to another zone", state.dataLoopNodes->NodeID( - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatAirOutletNode))); + airTerm.ReheatAirOutletNode))); ShowContinueError(state, format("Occurs for terminal unit {} = {}", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); + airTerm.sysType, + airTerm.SysName)); ShowContinueError(state, "Check terminal unit node names for errors"); ErrorsFound = true; } else { state.dataZoneEquip->ZoneEquipConfig(CtrlZone).AirDistUnitCool(SupAirIn).InNode = - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).InletNodeNum; + airTerm.InletNodeNum; state.dataZoneEquip->ZoneEquipConfig(CtrlZone).AirDistUnitCool(SupAirIn).OutNode = - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatAirOutletNode; - state.dataDefineEquipment->AirDistUnit(state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ADUNum) + airTerm.ReheatAirOutletNode; + state.dataDefineEquipment->AirDistUnit(airTerm.ADUNum) .TermUnitSizingNum = state.dataZoneEquip->ZoneEquipConfig(CtrlZone).AirDistUnitCool(SupAirIn).TermUnitSizingIndex; - state.dataDefineEquipment->AirDistUnit(state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ADUNum) + state.dataDefineEquipment->AirDistUnit(airTerm.ADUNum) .ZoneEqNum = CtrlZone; } - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).CtrlZoneNum = CtrlZone; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).CtrlZoneInNodeIndex = SupAirIn; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneFloorArea = + airTerm.CtrlZoneNum = CtrlZone; + airTerm.CtrlZoneInNodeIndex = SupAirIn; + airTerm.ZoneFloorArea = state.dataHeatBal->Zone(CtrlZone).FloorArea * state.dataHeatBal->Zone(CtrlZone).Multiplier * state.dataHeatBal->Zone(CtrlZone).ListMultiplier; } @@ -1015,43 +982,34 @@ void GetSysInput(EnergyPlusData &state) } } if (!lNumericBlanks(6)) { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).MaxReheatTemp = Numbers(6); - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).MaxReheatTempSetByUser = true; + airTerm.MaxReheatTemp = Numbers(6); + airTerm.MaxReheatTempSetByUser = true; } else { // user does not specify maximum supply air temperature // sd_airterminal(SysNum)%MaxReheatTemp = 35.0D0 !C - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).MaxReheatTempSetByUser = false; + airTerm.MaxReheatTempSetByUser = false; } - ValidateComponent(state, Alphas(5), Alphas(6), IsNotOK, state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType); + ValidateComponent(state, Alphas(5), Alphas(6), IsNotOK, airTerm.sysType); if (IsNotOK) { ShowContinueError(state, format("In {} = {}", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); + airTerm.sysType, + airTerm.SysName)); ErrorsFound = true; } if (lAlphaBlanks(8)) { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneTurndownMinAirFrac = 1.0; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneTurndownMinAirFracSchExist = false; - } else { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneTurndownMinAirFracSchPtr = GetScheduleIndex(state, Alphas(8)); - if (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneTurndownMinAirFracSchPtr == 0) { - ShowSevereError(state, format("{} = {} not found.", cAlphaFields(8), Alphas(8))); - ShowContinueError(state, - format("Occurs in {} = {}", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); - ErrorsFound = true; - } - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneTurndownMinAirFracSchExist = true; + airTerm.ZoneTurndownMinAirFrac = 1.0; + } else if ((airTerm.zoneTurndownMinAirFracSched = Sched::GetSchedule(state, Alphas(8))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(8), Alphas(8)); + ErrorsFound = true; } // Add reheat coil to component sets array SetUpCompSets(state, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName, + airTerm.sysType, + airTerm.SysName, Alphas(5), Alphas(6), Alphas(3), @@ -1061,10 +1019,10 @@ void GetSysInput(EnergyPlusData &state) SetupOutputVariable(state, "Zone Air Terminal VAV Damper Position", Constant::Units::None, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).DamperPosition, + airTerm.DamperPosition, OutputProcessor::TimeStepType::System, OutputProcessor::StoreType::Average, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName); + airTerm.SysName); } // end Number of VAVHeatandCool Sys Loop @@ -1086,64 +1044,62 @@ void GetSysInput(EnergyPlusData &state) cAlphaFields, cNumericFields); + ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)}; + state.dataSingleDuct->SysNumGSI = state.dataSingleDuct->SysIndexGSI + state.dataSingleDuct->NumVAVSysGSI + state.dataSingleDuct->NumCBVAVSysGSI; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysNum = state.dataSingleDuct->SysNumGSI; + auto &airTerm = state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI); + + airTerm.SysNum = state.dataSingleDuct->SysNumGSI; GlobalNames::VerifyUniqueInterObjectName( state, state.dataSingleDuct->SysUniqueNames, Alphas(1), CurrentModuleObject, cAlphaFields(1), ErrorsFound); - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName = Alphas(1); - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType = CurrentModuleObject; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysType_Num = SysType::SingleDuctConstVolReheat; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp = Alphas(5); - if (Util::SameString(state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp, "Coil:Heating:Fuel")) { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp_Num = HeatingCoilType::Gas; - } else if (Util::SameString(state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp, "Coil:Heating:Electric")) { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp_Num = HeatingCoilType::Electric; - } else if (Util::SameString(state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp, "Coil:Heating:Water")) { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp_Num = HeatingCoilType::SimpleHeating; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp_PlantType = + airTerm.SysName = Alphas(1); + airTerm.sysType = CurrentModuleObject; + airTerm.SysType_Num = SysType::SingleDuctConstVolReheat; + airTerm.ReheatComp = Alphas(5); + if (Util::SameString(airTerm.ReheatComp, "Coil:Heating:Fuel")) { + airTerm.ReheatComp_Num = HeatingCoilType::Gas; + } else if (Util::SameString(airTerm.ReheatComp, "Coil:Heating:Electric")) { + airTerm.ReheatComp_Num = HeatingCoilType::Electric; + } else if (Util::SameString(airTerm.ReheatComp, "Coil:Heating:Water")) { + airTerm.ReheatComp_Num = HeatingCoilType::SimpleHeating; + airTerm.ReheatComp_PlantType = DataPlant::PlantEquipmentType::CoilWaterSimpleHeating; - } else if (Util::SameString(state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp, "Coil:Heating:Steam")) { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp_Num = HeatingCoilType::SteamAirHeating; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp_PlantType = + } else if (Util::SameString(airTerm.ReheatComp, "Coil:Heating:Steam")) { + airTerm.ReheatComp_Num = HeatingCoilType::SteamAirHeating; + airTerm.ReheatComp_PlantType = DataPlant::PlantEquipmentType::CoilSteamAirHeating; } else { ShowSevereError( - state, format("Illegal {} = {}.", cAlphaFields(5), state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp)); + state, format("Illegal {} = {}.", cAlphaFields(5), airTerm.ReheatComp)); ShowContinueError(state, format("Occurs in {} = {}", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); + airTerm.sysType, + airTerm.SysName)); ErrorsFound = true; } - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatName = Alphas(6); + airTerm.ReheatName = Alphas(6); ValidateComponent(state, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatName, + airTerm.ReheatComp, + airTerm.ReheatName, IsNotOK, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType); + airTerm.sysType); if (IsNotOK) { ShowContinueError(state, format("In {} = {}", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); + airTerm.sysType, + airTerm.SysName)); ErrorsFound = true; } - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).Schedule = Alphas(2); + if (lAlphaBlanks(2)) { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SchedPtr = GetScheduleIndex(state, Alphas(2)); - if (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SchedPtr == 0) { - ShowSevereError(state, format("{} = {} not found.", cAlphaFields(2), Alphas(2))); - ShowContinueError(state, - format("Occurs in {} = {}", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); - ErrorsFound = true; - } + airTerm.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((airTerm.availSched = Sched::GetSchedule(state, Alphas(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(2), Alphas(2)); + ErrorsFound = true; } - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).OutletNodeNum = + + airTerm.OutletNodeNum = GetOnlySingleNode(state, Alphas(3), ErrorsFound, @@ -1154,7 +1110,7 @@ void GetSysInput(EnergyPlusData &state) NodeInputManager::CompFluidStream::Primary, ObjectIsParent, cAlphaFields(3)); - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).InletNodeNum = + airTerm.InletNodeNum = GetOnlySingleNode(state, Alphas(4), ErrorsFound, @@ -1167,95 +1123,95 @@ void GetSysInput(EnergyPlusData &state) cAlphaFields(4)); // The reheat coil control node is necessary for hot water reheat, but not necessary for // electric or gas reheat. - if (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp_Num == HeatingCoilType::Gas || - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp_Num == HeatingCoilType::Electric) { + if (airTerm.ReheatComp_Num == HeatingCoilType::Gas || + airTerm.ReheatComp_Num == HeatingCoilType::Electric) { } else { - if (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp_Num == HeatingCoilType::SteamAirHeating) { + if (airTerm.ReheatComp_Num == HeatingCoilType::SteamAirHeating) { IsNotOK = false; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatControlNode = + airTerm.ReheatControlNode = GetCoilSteamInletNode(state, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatName, + airTerm.ReheatComp, + airTerm.ReheatName, IsNotOK); if (IsNotOK) { ShowContinueError(state, format("..Occurs in {} = {}", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); + airTerm.sysType, + airTerm.SysName)); ErrorsFound = true; } } else { IsNotOK = false; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatControlNode = + airTerm.ReheatControlNode = GetCoilWaterInletNode(state, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatName, + airTerm.ReheatComp, + airTerm.ReheatName, IsNotOK); if (IsNotOK) { ShowContinueError(state, format("..Occurs in {} = {}", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); + airTerm.sysType, + airTerm.SysName)); ErrorsFound = true; } } } - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatAirOutletNode = - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).OutletNodeNum; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).MaxAirVolFlowRate = Numbers(1); - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneMinAirFracDes = 0.0; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneMinAirFracMethod = MinFlowFraction::MinFracNotUsed; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).DamperHeatingAction = Action::HeatingNotUsed; - if (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp_Num == HeatingCoilType::SteamAirHeating) { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).MaxReheatSteamVolFlow = Numbers(2); - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).MinReheatSteamVolFlow = Numbers(3); + airTerm.ReheatAirOutletNode = + airTerm.OutletNodeNum; + airTerm.MaxAirVolFlowRate = Numbers(1); + airTerm.ZoneMinAirFracDes = 0.0; + airTerm.ZoneMinAirFracMethod = MinFlowFraction::MinFracNotUsed; + airTerm.DamperHeatingAction = Action::HeatingNotUsed; + if (airTerm.ReheatComp_Num == HeatingCoilType::SteamAirHeating) { + airTerm.MaxReheatSteamVolFlow = Numbers(2); + airTerm.MinReheatSteamVolFlow = Numbers(3); } else { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).MaxReheatWaterVolFlow = Numbers(2); - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).MinReheatWaterVolFlow = Numbers(3); + airTerm.MaxReheatWaterVolFlow = Numbers(2); + airTerm.MinReheatWaterVolFlow = Numbers(3); } - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ControllerOffset = Numbers(4); + airTerm.ControllerOffset = Numbers(4); // Set default convergence tolerance - if (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ControllerOffset <= 0.0) { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ControllerOffset = 0.001; + if (airTerm.ControllerOffset <= 0.0) { + airTerm.ControllerOffset = 0.001; } // Maximum reheat air temperature, i.e. the maximum supply air temperature leaving the reheat coil if (!lNumericBlanks(5)) { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).MaxReheatTemp = Numbers(5); - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).MaxReheatTempSetByUser = true; + airTerm.MaxReheatTemp = Numbers(5); + airTerm.MaxReheatTempSetByUser = true; } else { // user does not specify maximum supply air temperature // sd_airterminal(SysNum)%MaxReheatTemp = 35.0D0 !C - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).MaxReheatTempSetByUser = false; + airTerm.MaxReheatTempSetByUser = false; } // Register component set data TestCompSet(state, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName, - state.dataLoopNodes->NodeID(state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).InletNodeNum), - state.dataLoopNodes->NodeID(state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).OutletNodeNum), + airTerm.sysType, + airTerm.SysName, + state.dataLoopNodes->NodeID(airTerm.InletNodeNum), + state.dataLoopNodes->NodeID(airTerm.OutletNodeNum), "Air Nodes"); for (ADUNum = 1; ADUNum <= (int)state.dataDefineEquipment->AirDistUnit.size(); ++ADUNum) { - if (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatAirOutletNode == + if (airTerm.ReheatAirOutletNode == state.dataDefineEquipment->AirDistUnit(ADUNum).OutletNodeNum) { state.dataDefineEquipment->AirDistUnit(ADUNum).InletNodeNum = - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).InletNodeNum; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ADUNum = ADUNum; + airTerm.InletNodeNum; + airTerm.ADUNum = ADUNum; break; } } // one assumes if there isn't one assigned, it's an error? - if (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ADUNum == 0) { + if (airTerm.ADUNum == 0) { ShowSevereError(state, format("{}No matching Air Distribution Unit, for System = [{},{}].", RoutineName, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); + airTerm.sysType, + airTerm.SysName)); ShowContinueError( state, format("...should have outlet node = {}", - state.dataLoopNodes->NodeID(state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatAirOutletNode))); + state.dataLoopNodes->NodeID(airTerm.ReheatAirOutletNode))); ErrorsFound = true; } else { @@ -1263,33 +1219,33 @@ void GetSysInput(EnergyPlusData &state) for (CtrlZone = 1; CtrlZone <= state.dataGlobal->NumOfZones; ++CtrlZone) { if (!state.dataZoneEquip->ZoneEquipConfig(CtrlZone).IsControlled) continue; for (SupAirIn = 1; SupAirIn <= state.dataZoneEquip->ZoneEquipConfig(CtrlZone).NumInletNodes; ++SupAirIn) { - if (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).OutletNodeNum == + if (airTerm.OutletNodeNum == state.dataZoneEquip->ZoneEquipConfig(CtrlZone).InletNode(SupAirIn)) { if (state.dataZoneEquip->ZoneEquipConfig(CtrlZone).AirDistUnitCool(SupAirIn).OutNode > 0) { ShowSevereError(state, "Error in connecting a terminal unit to a zone"); ShowContinueError(state, format("{} already connects to another zone", state.dataLoopNodes->NodeID( - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).OutletNodeNum))); + airTerm.OutletNodeNum))); ShowContinueError(state, format("Occurs for terminal unit {} = {}", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); + airTerm.sysType, + airTerm.SysName)); ShowContinueError(state, "Check terminal unit node names for errors"); ErrorsFound = true; } else { state.dataZoneEquip->ZoneEquipConfig(CtrlZone).AirDistUnitCool(SupAirIn).InNode = - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).InletNodeNum; + airTerm.InletNodeNum; state.dataZoneEquip->ZoneEquipConfig(CtrlZone).AirDistUnitCool(SupAirIn).OutNode = - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).OutletNodeNum; - state.dataDefineEquipment->AirDistUnit(state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ADUNum) + airTerm.OutletNodeNum; + state.dataDefineEquipment->AirDistUnit(airTerm.ADUNum) .TermUnitSizingNum = state.dataZoneEquip->ZoneEquipConfig(CtrlZone).AirDistUnitCool(SupAirIn).TermUnitSizingIndex; - state.dataDefineEquipment->AirDistUnit(state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ADUNum) + state.dataDefineEquipment->AirDistUnit(airTerm.ADUNum) .ZoneEqNum = CtrlZone; } - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).CtrlZoneNum = CtrlZone; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).CtrlZoneInNodeIndex = SupAirIn; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneFloorArea = + airTerm.CtrlZoneNum = CtrlZone; + airTerm.CtrlZoneInNodeIndex = SupAirIn; + airTerm.ZoneFloorArea = state.dataHeatBal->Zone(CtrlZone).FloorArea * state.dataHeatBal->Zone(CtrlZone).Multiplier * state.dataHeatBal->Zone(CtrlZone).ListMultiplier; } @@ -1297,19 +1253,19 @@ void GetSysInput(EnergyPlusData &state) } } - ValidateComponent(state, Alphas(5), Alphas(6), IsNotOK, state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType); + ValidateComponent(state, Alphas(5), Alphas(6), IsNotOK, airTerm.sysType); if (IsNotOK) { ShowContinueError(state, format("In {} = {}", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); + airTerm.sysType, + airTerm.SysName)); ErrorsFound = true; } // Add reheat coil to component sets array SetUpCompSets(state, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName, + airTerm.sysType, + airTerm.SysName, Alphas(5), Alphas(6), Alphas(4), @@ -1340,30 +1296,27 @@ void GetSysInput(EnergyPlusData &state) cAlphaFields, cNumericFields); + ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)}; + state.dataSingleDuct->SysNumGSI = state.dataSingleDuct->SysIndexGSI + state.dataSingleDuct->NumVAVSysGSI + state.dataSingleDuct->NumCBVAVSysGSI + state.dataSingleDuct->NumConstVolSys; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysNum = state.dataSingleDuct->SysNumGSI; + auto &airTerm = state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI); + + airTerm.SysNum = state.dataSingleDuct->SysNumGSI; GlobalNames::VerifyUniqueInterObjectName( state, state.dataSingleDuct->SysUniqueNames, Alphas(1), CurrentModuleObject, cAlphaFields(1), ErrorsFound); - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName = Alphas(1); - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType = CurrentModuleObject; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysType_Num = SysType::SingleDuctConstVolNoReheat; + airTerm.SysName = Alphas(1); + airTerm.sysType = CurrentModuleObject; + airTerm.SysType_Num = SysType::SingleDuctConstVolNoReheat; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).Schedule = Alphas(2); if (lAlphaBlanks(2)) { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SchedPtr = GetScheduleIndex(state, Alphas(2)); - if (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SchedPtr == 0) { - ShowSevereError(state, format("{} = {} not found.", cAlphaFields(2), Alphas(2))); - ShowContinueError(state, - format("Occurs in {} = {}", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); - ErrorsFound = true; - } + airTerm.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((airTerm.availSched = Sched::GetSchedule(state, Alphas(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(2), Alphas(2)); + ErrorsFound = true; } - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).InletNodeNum = + + airTerm.InletNodeNum = GetOnlySingleNode(state, Alphas(3), ErrorsFound, @@ -1374,7 +1327,7 @@ void GetSysInput(EnergyPlusData &state) NodeInputManager::CompFluidStream::Primary, ObjectIsNotParent, cAlphaFields(3)); - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).OutletNodeNum = + airTerm.OutletNodeNum = GetOnlySingleNode(state, Alphas(4), ErrorsFound, @@ -1386,48 +1339,48 @@ void GetSysInput(EnergyPlusData &state) ObjectIsNotParent, cAlphaFields(4)); - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).MaxAirVolFlowRate = Numbers(1); - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneMinAirFracDes = 0.0; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneMinAirFracMethod = MinFlowFraction::MinFracNotUsed; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).DamperHeatingAction = Action::HeatingNotUsed; + airTerm.MaxAirVolFlowRate = Numbers(1); + airTerm.ZoneMinAirFracDes = 0.0; + airTerm.ZoneMinAirFracMethod = MinFlowFraction::MinFracNotUsed; + airTerm.DamperHeatingAction = Action::HeatingNotUsed; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatControlNode = 0; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatAirOutletNode = - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).OutletNodeNum; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).MaxReheatWaterVolFlow = 0.0; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).MaxReheatSteamVolFlow = 0.0; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).MinReheatWaterVolFlow = 0.0; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).MinReheatSteamVolFlow = 0.0; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ControllerOffset = 0.000001; + airTerm.ReheatControlNode = 0; + airTerm.ReheatAirOutletNode = + airTerm.OutletNodeNum; + airTerm.MaxReheatWaterVolFlow = 0.0; + airTerm.MaxReheatSteamVolFlow = 0.0; + airTerm.MinReheatWaterVolFlow = 0.0; + airTerm.MinReheatSteamVolFlow = 0.0; + airTerm.ControllerOffset = 0.000001; // Register component set data TestCompSet(state, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName, - state.dataLoopNodes->NodeID(state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).InletNodeNum), - state.dataLoopNodes->NodeID(state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).OutletNodeNum), + airTerm.sysType, + airTerm.SysName, + state.dataLoopNodes->NodeID(airTerm.InletNodeNum), + state.dataLoopNodes->NodeID(airTerm.OutletNodeNum), "Air Nodes"); for (ADUNum = 1; ADUNum <= (int)state.dataDefineEquipment->AirDistUnit.size(); ++ADUNum) { - if (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).OutletNodeNum == + if (airTerm.OutletNodeNum == state.dataDefineEquipment->AirDistUnit(ADUNum).OutletNodeNum) { state.dataDefineEquipment->AirDistUnit(ADUNum).InletNodeNum = - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).InletNodeNum; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ADUNum = ADUNum; + airTerm.InletNodeNum; + airTerm.ADUNum = ADUNum; break; } } // one assumes if there isn't one assigned, it's an error? - if (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ADUNum == 0) { + if (airTerm.ADUNum == 0) { ShowSevereError(state, format("{}No matching Air Distribution Unit, for System = [{},{}].", RoutineName, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); + airTerm.sysType, + airTerm.SysName)); ShowContinueError( state, format("...should have outlet node = {}", - state.dataLoopNodes->NodeID(state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).OutletNodeNum))); + state.dataLoopNodes->NodeID(airTerm.OutletNodeNum))); ErrorsFound = true; } else { @@ -1435,33 +1388,33 @@ void GetSysInput(EnergyPlusData &state) for (CtrlZone = 1; CtrlZone <= state.dataGlobal->NumOfZones; ++CtrlZone) { if (!state.dataZoneEquip->ZoneEquipConfig(CtrlZone).IsControlled) continue; for (SupAirIn = 1; SupAirIn <= state.dataZoneEquip->ZoneEquipConfig(CtrlZone).NumInletNodes; ++SupAirIn) { - if (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).OutletNodeNum == + if (airTerm.OutletNodeNum == state.dataZoneEquip->ZoneEquipConfig(CtrlZone).InletNode(SupAirIn)) { if (state.dataZoneEquip->ZoneEquipConfig(CtrlZone).AirDistUnitCool(SupAirIn).OutNode > 0) { ShowSevereError(state, "Error in connecting a terminal unit to a zone"); ShowContinueError(state, format("{} already connects to another zone", state.dataLoopNodes->NodeID( - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).OutletNodeNum))); + airTerm.OutletNodeNum))); ShowContinueError(state, format("Occurs for terminal unit {} = {}", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); + airTerm.sysType, + airTerm.SysName)); ShowContinueError(state, "Check terminal unit node names for errors"); ErrorsFound = true; } else { state.dataZoneEquip->ZoneEquipConfig(CtrlZone).AirDistUnitCool(SupAirIn).InNode = - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).InletNodeNum; + airTerm.InletNodeNum; state.dataZoneEquip->ZoneEquipConfig(CtrlZone).AirDistUnitCool(SupAirIn).OutNode = - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).OutletNodeNum; - state.dataDefineEquipment->AirDistUnit(state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ADUNum) + airTerm.OutletNodeNum; + state.dataDefineEquipment->AirDistUnit(airTerm.ADUNum) .TermUnitSizingNum = state.dataZoneEquip->ZoneEquipConfig(CtrlZone).AirDistUnitCool(SupAirIn).TermUnitSizingIndex; - state.dataDefineEquipment->AirDistUnit(state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ADUNum) + state.dataDefineEquipment->AirDistUnit(airTerm.ADUNum) .ZoneEqNum = CtrlZone; } - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).CtrlZoneNum = CtrlZone; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).CtrlZoneInNodeIndex = SupAirIn; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneFloorArea = + airTerm.CtrlZoneNum = CtrlZone; + airTerm.CtrlZoneInNodeIndex = SupAirIn; + airTerm.ZoneFloorArea = state.dataHeatBal->Zone(CtrlZone).FloorArea * state.dataHeatBal->Zone(CtrlZone).Multiplier * state.dataHeatBal->Zone(CtrlZone).ListMultiplier; } @@ -1470,31 +1423,31 @@ void GetSysInput(EnergyPlusData &state) } if (lAlphaBlanks(5)) { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).NoOAFlowInputFromUser = true; + airTerm.NoOAFlowInputFromUser = true; } else { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).OARequirementsPtr = + airTerm.OARequirementsPtr = Util::FindItemInList(Alphas(5), state.dataSize->OARequirements); - if (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).OARequirementsPtr == 0) { + if (airTerm.OARequirementsPtr == 0) { ShowSevereError(state, format("{}{}=\"{}\", invalid data.", RoutineName, CurrentModuleObject, Alphas(1))); ShowContinueError(state, format("..invalid {}=\"{}\".", cAlphaFields(5), Alphas(5))); ErrorsFound = true; } else { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).NoOAFlowInputFromUser = false; + airTerm.NoOAFlowInputFromUser = false; } } if (lAlphaBlanks(6)) { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).OAPerPersonMode = + airTerm.OAPerPersonMode = DataZoneEquipment::PerPersonVentRateMode::DCVByCurrentLevel; } else { if (Alphas(6) == "CURRENTOCCUPANCY") { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).OAPerPersonMode = + airTerm.OAPerPersonMode = DataZoneEquipment::PerPersonVentRateMode::DCVByCurrentLevel; } else if (Alphas(6) == "DESIGNOCCUPANCY") { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).OAPerPersonMode = + airTerm.OAPerPersonMode = DataZoneEquipment::PerPersonVentRateMode::ByDesignLevel; } else { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).OAPerPersonMode = + airTerm.OAPerPersonMode = DataZoneEquipment::PerPersonVentRateMode::DCVByCurrentLevel; ShowWarningError(state, format("{}{}=\"{}\", invalid data.", RoutineName, CurrentModuleObject, Alphas(1))); ShowContinueError(state, @@ -1506,17 +1459,17 @@ void GetSysInput(EnergyPlusData &state) // model results related actuators SetupEMSActuator(state, "AirTerminal:SingleDuct:ConstantVolume:NoReheat", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName, + airTerm.SysName, "Mass Flow Rate", "[kg/s]", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).EMSOverrideAirFlow, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).EMSMassFlowRateValue); + airTerm.EMSOverrideAirFlow, + airTerm.EMSMassFlowRateValue); // model input related internal variables SetupEMSInternalVariable(state, "AirTerminal:SingleDuct:ConstantVolume:NoReheat Maximum Mass Flow Rate", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName, + airTerm.SysName, "[kg/s]", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).AirMassFlowRateMax); + airTerm.AirMassFlowRateMax); } } // End Number of Sys Loop @@ -1539,32 +1492,29 @@ void GetSysInput(EnergyPlusData &state) cAlphaFields, cNumericFields); + ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)}; state.dataSingleDuct->SysNumGSI = state.dataSingleDuct->SysIndexGSI + state.dataSingleDuct->NumVAVSysGSI + state.dataSingleDuct->NumCBVAVSysGSI + state.dataSingleDuct->NumConstVolSys + state.dataSingleDuct->NumCVNoReheatSysGSI; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysNum = state.dataSingleDuct->SysNumGSI; + auto &airTerm = state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI); + + airTerm.SysNum = state.dataSingleDuct->SysNumGSI; GlobalNames::VerifyUniqueInterObjectName( state, state.dataSingleDuct->SysUniqueNames, Alphas(1), CurrentModuleObject, cAlphaFields(1), ErrorsFound); - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName = Alphas(1); - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType = CurrentModuleObject; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysType_Num = SysType::SingleDuctVAVNoReheat; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp = ""; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatName = ""; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).Schedule = Alphas(2); + airTerm.SysName = Alphas(1); + airTerm.sysType = CurrentModuleObject; + airTerm.SysType_Num = SysType::SingleDuctVAVNoReheat; + airTerm.ReheatComp = ""; + airTerm.ReheatName = ""; + if (lAlphaBlanks(2)) { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SchedPtr = GetScheduleIndex(state, Alphas(2)); - if (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SchedPtr == 0) { - ShowSevereError(state, format("{} = {} not found.", cAlphaFields(2), Alphas(2))); - ShowContinueError(state, - format("Occurs in {} = {}", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); - ErrorsFound = true; - } + airTerm.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((airTerm.availSched = Sched::GetSchedule(state, Alphas(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(2), Alphas(2)); + ErrorsFound = true; } - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).OutletNodeNum = + + airTerm.OutletNodeNum = GetOnlySingleNode(state, Alphas(3), ErrorsFound, @@ -1575,7 +1525,7 @@ void GetSysInput(EnergyPlusData &state) NodeInputManager::CompFluidStream::Primary, ObjectIsNotParent, cAlphaFields(3)); - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).InletNodeNum = + airTerm.InletNodeNum = GetOnlySingleNode(state, Alphas(4), ErrorsFound, @@ -1586,118 +1536,107 @@ void GetSysInput(EnergyPlusData &state) NodeInputManager::CompFluidStream::Primary, ObjectIsNotParent, cAlphaFields(4)); - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).MaxAirVolFlowRate = Numbers(1); + airTerm.MaxAirVolFlowRate = Numbers(1); if (Util::SameString(Alphas(5), "Constant")) { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneMinAirFracMethod = MinFlowFraction::Constant; + airTerm.ZoneMinAirFracMethod = MinFlowFraction::Constant; } else if (Util::SameString(Alphas(5), "FixedFlowRate")) { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneMinAirFracMethod = MinFlowFraction::Fixed; + airTerm.ZoneMinAirFracMethod = MinFlowFraction::Fixed; } else if (Util::SameString(Alphas(5), "Scheduled")) { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneMinAirFracMethod = MinFlowFraction::Scheduled; + airTerm.ZoneMinAirFracMethod = MinFlowFraction::Scheduled; } else { ShowSevereError(state, format("{} = {} not found.", cAlphaFields(5), Alphas(5))); ShowContinueError(state, format("Occurs in {} = {}", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); + airTerm.sysType, + airTerm.SysName)); ErrorsFound = true; } - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneMinAirFracDes = Numbers(2); + airTerm.ZoneMinAirFracDes = Numbers(2); if (lNumericBlanks(2)) { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ConstantMinAirFracSetByUser = false; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneMinAirFracDes = 0.0; + airTerm.ConstantMinAirFracSetByUser = false; + airTerm.ZoneMinAirFracDes = 0.0; } else { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ConstantMinAirFracSetByUser = true; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneMinAirFracDes = Numbers(2); - if (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneMinAirFracMethod == MinFlowFraction::Fixed) { + airTerm.ConstantMinAirFracSetByUser = true; + airTerm.ZoneMinAirFracDes = Numbers(2); + if (airTerm.ZoneMinAirFracMethod == MinFlowFraction::Fixed) { ShowWarningError(state, format("Since {} = {}, input for {} will be ignored.", cAlphaFields(5), Alphas(5), cNumericFields(2))); ShowContinueError(state, format("Occurs in {} = {}", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneMinAirFracDes = 0.0; + airTerm.sysType, + airTerm.SysName)); + airTerm.ZoneMinAirFracDes = 0.0; } } - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneFixedMinAir = Numbers(3); + airTerm.ZoneFixedMinAir = Numbers(3); if (lNumericBlanks(3)) { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).FixedMinAirSetByUser = false; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).DesignFixedMinAir = 0.0; + airTerm.FixedMinAirSetByUser = false; + airTerm.DesignFixedMinAir = 0.0; } else { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).FixedMinAirSetByUser = true; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).DesignFixedMinAir = Numbers(3); - if (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneMinAirFracMethod == MinFlowFraction::Constant) { + airTerm.FixedMinAirSetByUser = true; + airTerm.DesignFixedMinAir = Numbers(3); + if (airTerm.ZoneMinAirFracMethod == MinFlowFraction::Constant) { ShowWarningError(state, format("Since {} = {}, input for {} will be ignored.", cAlphaFields(5), Alphas(5), cNumericFields(3))); ShowContinueError(state, format("Occurs in {} = {}", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneFixedMinAir = 0.0; + airTerm.sysType, + airTerm.SysName)); + airTerm.ZoneFixedMinAir = 0.0; } } - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneMinAirFracSchPtr = GetScheduleIndex(state, Alphas(6)); - if ((state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneMinAirFracSchPtr == 0) && - (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneMinAirFracMethod == MinFlowFraction::Scheduled)) { - ShowSevereError(state, format("{} = {} not found.", cAlphaFields(6), Alphas(6))); - ShowContinueError(state, - format("Occurs in {} = {}", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); - ShowContinueError(state, "A valid schedule is required"); + + if (airTerm.ZoneMinAirFracMethod != MinFlowFraction::Scheduled) { + } else if (lAlphaBlanks(6)) { + ShowSevereEmptyField(state, eoh, cAlphaFields(6)); + ErrorsFound = true; + } else if ((airTerm.zoneMinAirFracSched = Sched::GetSchedule(state, Alphas(6))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(6), Alphas(6)); + ErrorsFound = true; + } else if (!airTerm.zoneMinAirFracSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) { + Sched::ShowSevereBadMinMax(state, eoh, cAlphaFields(6), Alphas(6), Clusive::In, 0.0, Clusive::In, 1.0); ErrorsFound = true; - } else if ((state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneMinAirFracSchPtr > 0) && - (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneMinAirFracMethod == MinFlowFraction::Scheduled)) { - // check range of values in schedule - if (!CheckScheduleValueMinMax( - state, state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneMinAirFracSchPtr, ">=", 0.0, "<=", 1.0)) { - ShowSevereError(state, format("Error found in {} = {}", cAlphaFields(6), Alphas(6))); - ShowContinueError(state, - format("Occurs in {} = {}", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); - ShowContinueError(state, "Schedule values must be (>=0., <=1.)"); - } } - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatControlNode = 0; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatAirOutletNode = - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).OutletNodeNum; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).MaxReheatWaterVolFlow = 0.0; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).MaxReheatSteamVolFlow = 0.0; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).MinReheatWaterVolFlow = 0.0; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).MinReheatSteamVolFlow = 0.0; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ControllerOffset = 0.000001; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).DamperHeatingAction = Action::HeatingNotUsed; + airTerm.ReheatControlNode = 0; + airTerm.ReheatAirOutletNode = + airTerm.OutletNodeNum; + airTerm.MaxReheatWaterVolFlow = 0.0; + airTerm.MaxReheatSteamVolFlow = 0.0; + airTerm.MinReheatWaterVolFlow = 0.0; + airTerm.MinReheatSteamVolFlow = 0.0; + airTerm.ControllerOffset = 0.000001; + airTerm.DamperHeatingAction = Action::HeatingNotUsed; // Register component set data TestCompSet(state, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName, - state.dataLoopNodes->NodeID(state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).InletNodeNum), - state.dataLoopNodes->NodeID(state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).OutletNodeNum), + airTerm.sysType, + airTerm.SysName, + state.dataLoopNodes->NodeID(airTerm.InletNodeNum), + state.dataLoopNodes->NodeID(airTerm.OutletNodeNum), "Air Nodes"); for (ADUNum = 1; ADUNum <= (int)state.dataDefineEquipment->AirDistUnit.size(); ++ADUNum) { - if (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).OutletNodeNum == + if (airTerm.OutletNodeNum == state.dataDefineEquipment->AirDistUnit(ADUNum).OutletNodeNum) { state.dataDefineEquipment->AirDistUnit(ADUNum).InletNodeNum = - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).InletNodeNum; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ADUNum = ADUNum; + airTerm.InletNodeNum; + airTerm.ADUNum = ADUNum; break; } } // one assumes if there isn't one assigned, it's an error? - if (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ADUNum == 0) { + if (airTerm.ADUNum == 0) { ShowSevereError(state, format("{}No matching Air Distribution Unit, for System = [{},{}].", RoutineName, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); + airTerm.sysType, + airTerm.SysName)); ShowContinueError( state, format("...should have outlet node = {}", - state.dataLoopNodes->NodeID(state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatAirOutletNode))); + state.dataLoopNodes->NodeID(airTerm.ReheatAirOutletNode))); ErrorsFound = true; } else { @@ -1705,34 +1644,34 @@ void GetSysInput(EnergyPlusData &state) for (CtrlZone = 1; CtrlZone <= state.dataGlobal->NumOfZones; ++CtrlZone) { if (!state.dataZoneEquip->ZoneEquipConfig(CtrlZone).IsControlled) continue; for (SupAirIn = 1; SupAirIn <= state.dataZoneEquip->ZoneEquipConfig(CtrlZone).NumInletNodes; ++SupAirIn) { - if (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatAirOutletNode == + if (airTerm.ReheatAirOutletNode == state.dataZoneEquip->ZoneEquipConfig(CtrlZone).InletNode(SupAirIn)) { if (state.dataZoneEquip->ZoneEquipConfig(CtrlZone).AirDistUnitCool(SupAirIn).OutNode > 0) { ShowSevereError(state, "Error in connecting a terminal unit to a zone"); ShowContinueError(state, format("{} already connects to another zone", state.dataLoopNodes->NodeID( - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatAirOutletNode))); + airTerm.ReheatAirOutletNode))); ShowContinueError(state, format("Occurs for terminal unit {} = {}", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); + airTerm.sysType, + airTerm.SysName)); ShowContinueError(state, "Check terminal unit node names for errors"); ErrorsFound = true; } else { state.dataZoneEquip->ZoneEquipConfig(CtrlZone).AirDistUnitCool(SupAirIn).InNode = - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).InletNodeNum; + airTerm.InletNodeNum; state.dataZoneEquip->ZoneEquipConfig(CtrlZone).AirDistUnitCool(SupAirIn).OutNode = - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatAirOutletNode; - state.dataDefineEquipment->AirDistUnit(state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ADUNum) + airTerm.ReheatAirOutletNode; + state.dataDefineEquipment->AirDistUnit(airTerm.ADUNum) .TermUnitSizingNum = state.dataZoneEquip->ZoneEquipConfig(CtrlZone).AirDistUnitCool(SupAirIn).TermUnitSizingIndex; - state.dataDefineEquipment->AirDistUnit(state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ADUNum) + state.dataDefineEquipment->AirDistUnit(airTerm.ADUNum) .ZoneEqNum = CtrlZone; } - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).CtrlZoneNum = CtrlZone; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).CtrlZoneInNodeIndex = SupAirIn; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneFloorArea = + airTerm.CtrlZoneNum = CtrlZone; + airTerm.CtrlZoneInNodeIndex = SupAirIn; + airTerm.ZoneFloorArea = state.dataHeatBal->Zone(CtrlZone).FloorArea * state.dataHeatBal->Zone(CtrlZone).Multiplier * state.dataHeatBal->Zone(CtrlZone).ListMultiplier; } @@ -1740,51 +1679,42 @@ void GetSysInput(EnergyPlusData &state) } } if (!lAlphaBlanks(7)) { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).OARequirementsPtr = + airTerm.OARequirementsPtr = Util::FindItemInList(Alphas(7), state.dataSize->OARequirements); - if (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).OARequirementsPtr == 0) { + if (airTerm.OARequirementsPtr == 0) { ShowSevereError(state, format("{} = {} not found.", cAlphaFields(7), Alphas(7))); ShowContinueError(state, format("Occurs in {} = {}", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); + airTerm.sysType, + airTerm.SysName)); ErrorsFound = true; } else { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).NoOAFlowInputFromUser = false; + airTerm.NoOAFlowInputFromUser = false; } } if (lAlphaBlanks(8)) { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneTurndownMinAirFrac = 1.0; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneTurndownMinAirFracSchExist = false; - } else { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneTurndownMinAirFracSchPtr = GetScheduleIndex(state, Alphas(8)); - if (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneTurndownMinAirFracSchPtr == 0) { - ShowSevereError(state, format("{} = {} not found.", cAlphaFields(8), Alphas(8))); - ShowContinueError(state, - format("Occurs in {} = {}", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); - ErrorsFound = true; - } - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneTurndownMinAirFracSchExist = true; + airTerm.ZoneTurndownMinAirFrac = 1.0; + } else if ((airTerm.zoneTurndownMinAirFracSched = Sched::GetSchedule(state, Alphas(8))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(8), Alphas(8)); + ErrorsFound = true; } // Setup the Average damper Position output variable SetupOutputVariable(state, "Zone Air Terminal VAV Damper Position", Constant::Units::None, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).DamperPosition, + airTerm.DamperPosition, OutputProcessor::TimeStepType::System, OutputProcessor::StoreType::Average, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName); + airTerm.SysName); SetupOutputVariable(state, "Zone Air Terminal Minimum Air Flow Fraction", Constant::Units::None, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneMinAirFracReport, + airTerm.ZoneMinAirFracReport, OutputProcessor::TimeStepType::System, OutputProcessor::StoreType::Average, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName); + airTerm.SysName); } // end Number of Sys Loop @@ -1806,32 +1736,29 @@ void GetSysInput(EnergyPlusData &state) cAlphaFields, cNumericFields); + ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)}; state.dataSingleDuct->SysNumGSI = state.dataSingleDuct->SysIndexGSI + state.dataSingleDuct->NumVAVSysGSI + state.dataSingleDuct->NumCBVAVSysGSI + state.dataSingleDuct->NumConstVolSys + state.dataSingleDuct->NumCVNoReheatSysGSI + state.dataSingleDuct->NumNoRHVAVSysGSI; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysNum = state.dataSingleDuct->SysNumGSI; + auto &airTerm = state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI); + + airTerm.SysNum = state.dataSingleDuct->SysNumGSI; GlobalNames::VerifyUniqueInterObjectName( state, state.dataSingleDuct->SysUniqueNames, Alphas(1), CurrentModuleObject, cAlphaFields(1), ErrorsFound); - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName = Alphas(1); - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType = CurrentModuleObject; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysType_Num = SysType::SingleDuctCBVAVNoReheat; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp = ""; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatName = ""; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).Schedule = Alphas(2); + airTerm.SysName = Alphas(1); + airTerm.sysType = CurrentModuleObject; + airTerm.SysType_Num = SysType::SingleDuctCBVAVNoReheat; + airTerm.ReheatComp = ""; + airTerm.ReheatName = ""; + if (lAlphaBlanks(2)) { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SchedPtr = GetScheduleIndex(state, Alphas(2)); - if (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SchedPtr == 0) { - ShowSevereError(state, format("{} = {} not found.", cAlphaFields(2), Alphas(2))); - ShowContinueError(state, - format("Occurs in {} = {}", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); - ErrorsFound = true; - } + airTerm.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((airTerm.availSched = Sched::GetSchedule(state, Alphas(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(2), Alphas(2)); + ErrorsFound = true; } - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).OutletNodeNum = + + airTerm.OutletNodeNum = GetOnlySingleNode(state, Alphas(3), ErrorsFound, @@ -1842,7 +1769,7 @@ void GetSysInput(EnergyPlusData &state) NodeInputManager::CompFluidStream::Primary, ObjectIsNotParent, cAlphaFields(3)); - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).InletNodeNum = + airTerm.InletNodeNum = GetOnlySingleNode(state, Alphas(4), ErrorsFound, @@ -1853,64 +1780,64 @@ void GetSysInput(EnergyPlusData &state) NodeInputManager::CompFluidStream::Primary, ObjectIsNotParent, cAlphaFields(4)); - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).MaxAirVolFlowRate = Numbers(1); - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneMinAirFracDes = Numbers(2); - if (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneMinAirFracDes < 0.0) { + airTerm.MaxAirVolFlowRate = Numbers(1); + airTerm.ZoneMinAirFracDes = Numbers(2); + if (airTerm.ZoneMinAirFracDes < 0.0) { ShowWarningError(state, format("{} = \"{}", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); + airTerm.sysType, + airTerm.SysName)); ShowContinueError(state, format("{} must be greater than or equal to 0. Resetting to 0 and the simulation continues.", cNumericFields(2))); - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneMinAirFracDes = 0.0; + airTerm.ZoneMinAirFracDes = 0.0; } - if (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneMinAirFracDes > 1.0) { + if (airTerm.ZoneMinAirFracDes > 1.0) { ShowWarningError(state, format("{} = \"{}", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); + airTerm.sysType, + airTerm.SysName)); ShowContinueError(state, format("{} must be less than or equal to 1. Resetting to 1 and the simulation continues.", cNumericFields(2))); - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneMinAirFracDes = 1.0; + airTerm.ZoneMinAirFracDes = 1.0; } - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatControlNode = 0; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatAirOutletNode = - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).OutletNodeNum; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).MaxReheatWaterVolFlow = 0.0; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).MaxReheatSteamVolFlow = 0.0; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).MinReheatWaterVolFlow = 0.0; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).MinReheatSteamVolFlow = 0.0; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ControllerOffset = 0.000001; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).DamperHeatingAction = Action::HeatingNotUsed; + airTerm.ReheatControlNode = 0; + airTerm.ReheatAirOutletNode = + airTerm.OutletNodeNum; + airTerm.MaxReheatWaterVolFlow = 0.0; + airTerm.MaxReheatSteamVolFlow = 0.0; + airTerm.MinReheatWaterVolFlow = 0.0; + airTerm.MinReheatSteamVolFlow = 0.0; + airTerm.ControllerOffset = 0.000001; + airTerm.DamperHeatingAction = Action::HeatingNotUsed; // Register component set data TestCompSet(state, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName, - state.dataLoopNodes->NodeID(state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).InletNodeNum), - state.dataLoopNodes->NodeID(state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).OutletNodeNum), + airTerm.sysType, + airTerm.SysName, + state.dataLoopNodes->NodeID(airTerm.InletNodeNum), + state.dataLoopNodes->NodeID(airTerm.OutletNodeNum), "Air Nodes"); for (ADUNum = 1; ADUNum <= (int)state.dataDefineEquipment->AirDistUnit.size(); ++ADUNum) { - if (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).OutletNodeNum == + if (airTerm.OutletNodeNum == state.dataDefineEquipment->AirDistUnit(ADUNum).OutletNodeNum) { state.dataDefineEquipment->AirDistUnit(ADUNum).InletNodeNum = - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).InletNodeNum; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ADUNum = ADUNum; + airTerm.InletNodeNum; + airTerm.ADUNum = ADUNum; break; } } // one assumes if there isn't one assigned, it's an error? - if (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ADUNum == 0) { + if (airTerm.ADUNum == 0) { ShowSevereError(state, format("{}No matching Air Distribution Unit, for System = [{},{}].", RoutineName, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); + airTerm.sysType, + airTerm.SysName)); ShowContinueError( state, format("...should have outlet node = {}", - state.dataLoopNodes->NodeID(state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatAirOutletNode))); + state.dataLoopNodes->NodeID(airTerm.ReheatAirOutletNode))); ErrorsFound = true; } else { @@ -1918,33 +1845,33 @@ void GetSysInput(EnergyPlusData &state) for (CtrlZone = 1; CtrlZone <= state.dataGlobal->NumOfZones; ++CtrlZone) { if (!state.dataZoneEquip->ZoneEquipConfig(CtrlZone).IsControlled) continue; for (SupAirIn = 1; SupAirIn <= state.dataZoneEquip->ZoneEquipConfig(CtrlZone).NumInletNodes; ++SupAirIn) { - if (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatAirOutletNode == + if (airTerm.ReheatAirOutletNode == state.dataZoneEquip->ZoneEquipConfig(CtrlZone).InletNode(SupAirIn)) { if (state.dataZoneEquip->ZoneEquipConfig(CtrlZone).AirDistUnitCool(SupAirIn).OutNode > 0) { ShowSevereError(state, "Error in connecting a terminal unit to a zone"); ShowContinueError(state, format("{} already connects to another zone", state.dataLoopNodes->NodeID( - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatAirOutletNode))); + airTerm.ReheatAirOutletNode))); ShowContinueError(state, format("Occurs for terminal unit {} = {}", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); + airTerm.sysType, + airTerm.SysName)); ShowContinueError(state, "Check terminal unit node names for errors"); ErrorsFound = true; } else { state.dataZoneEquip->ZoneEquipConfig(CtrlZone).AirDistUnitCool(SupAirIn).InNode = - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).InletNodeNum; + airTerm.InletNodeNum; state.dataZoneEquip->ZoneEquipConfig(CtrlZone).AirDistUnitCool(SupAirIn).OutNode = - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatAirOutletNode; - state.dataDefineEquipment->AirDistUnit(state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ADUNum) + airTerm.ReheatAirOutletNode; + state.dataDefineEquipment->AirDistUnit(airTerm.ADUNum) .TermUnitSizingNum = state.dataZoneEquip->ZoneEquipConfig(CtrlZone).AirDistUnitCool(SupAirIn).TermUnitSizingIndex; - state.dataDefineEquipment->AirDistUnit(state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ADUNum) + state.dataDefineEquipment->AirDistUnit(airTerm.ADUNum) .ZoneEqNum = CtrlZone; } - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).CtrlZoneNum = CtrlZone; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).CtrlZoneInNodeIndex = SupAirIn; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneFloorArea = + airTerm.CtrlZoneNum = CtrlZone; + airTerm.CtrlZoneInNodeIndex = SupAirIn; + airTerm.ZoneFloorArea = state.dataHeatBal->Zone(CtrlZone).FloorArea * state.dataHeatBal->Zone(CtrlZone).Multiplier * state.dataHeatBal->Zone(CtrlZone).ListMultiplier; } @@ -1953,29 +1880,20 @@ void GetSysInput(EnergyPlusData &state) } if (lAlphaBlanks(5)) { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneTurndownMinAirFrac = 1.0; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneTurndownMinAirFracSchExist = false; - } else { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneTurndownMinAirFracSchPtr = GetScheduleIndex(state, Alphas(5)); - if (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneTurndownMinAirFracSchPtr == 0) { - ShowSevereError(state, format("{} = {} not found.", cAlphaFields(5), Alphas(5))); - ShowContinueError(state, - format("Occurs in {} = {}", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); - ErrorsFound = true; - } - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneTurndownMinAirFracSchExist = true; + airTerm.ZoneTurndownMinAirFrac = 1.0; + } else if ((airTerm.zoneTurndownMinAirFracSched = Sched::GetSchedule(state, Alphas(5))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(5), Alphas(5)); + ErrorsFound = true; } // Setup the Average damper Position output variable SetupOutputVariable(state, "Zone Air Terminal VAV Damper Position", Constant::Units::None, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).DamperPosition, + airTerm.DamperPosition, OutputProcessor::TimeStepType::System, OutputProcessor::StoreType::Average, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName); + airTerm.SysName); } // end Number of VAVHeatandCool:NoReheat Sys Loop @@ -2004,80 +1922,80 @@ void GetSysInput(EnergyPlusData &state) state.dataSingleDuct->NumCBVAVSysGSI + state.dataSingleDuct->NumConstVolSys + state.dataSingleDuct->NumCVNoReheatSysGSI + state.dataSingleDuct->NumNoRHVAVSysGSI + state.dataSingleDuct->NumNoRHCBVAVSysGSI; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysNum = state.dataSingleDuct->SysNumGSI; + auto &airTerm = state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI); + airTerm.SysNum = state.dataSingleDuct->SysNumGSI; GlobalNames::VerifyUniqueInterObjectName( state, state.dataSingleDuct->SysUniqueNames, Alphas(1), CurrentModuleObject, cAlphaFields(1), ErrorsFound); - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName = Alphas(1); - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType = CurrentModuleObject; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysType_Num = SysType::SingleDuctVAVReheatVSFan; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp = Alphas(7); - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatName = Alphas(8); + airTerm.SysName = Alphas(1); + airTerm.sysType = CurrentModuleObject; + airTerm.SysType_Num = SysType::SingleDuctVAVReheatVSFan; + airTerm.ReheatComp = Alphas(7); + airTerm.ReheatName = Alphas(8); IsNotOK = false; - if (Util::SameString(state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp, "Coil:Heating:Fuel")) { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp_Num = HeatingCoilType::Gas; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatAirOutletNode = + if (Util::SameString(airTerm.ReheatComp, "Coil:Heating:Fuel")) { + airTerm.ReheatComp_Num = HeatingCoilType::Gas; + airTerm.ReheatAirOutletNode = GetHeatingCoilOutletNode(state, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatName, + airTerm.ReheatComp, + airTerm.ReheatName, IsNotOK); - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatCoilMaxCapacity = + airTerm.ReheatCoilMaxCapacity = GetHeatingCoilCapacity(state, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatName, + airTerm.ReheatComp, + airTerm.ReheatName, IsNotOK); if (IsNotOK) ShowContinueError(state, format("Occurs for terminal unit {} = {}", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); - } else if (Util::SameString(state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp, "Coil:Heating:Electric")) { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp_Num = HeatingCoilType::Electric; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatAirOutletNode = + airTerm.sysType, + airTerm.SysName)); + } else if (Util::SameString(airTerm.ReheatComp, "Coil:Heating:Electric")) { + airTerm.ReheatComp_Num = HeatingCoilType::Electric; + airTerm.ReheatAirOutletNode = GetHeatingCoilOutletNode(state, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatName, + airTerm.ReheatComp, + airTerm.ReheatName, IsNotOK); - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatCoilMaxCapacity = + airTerm.ReheatCoilMaxCapacity = GetHeatingCoilCapacity(state, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatName, + airTerm.ReheatComp, + airTerm.ReheatName, IsNotOK); if (IsNotOK) ShowContinueError(state, format("Occurs for terminal unit {} = {}", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); - } else if (Util::SameString(state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp, "Coil:Heating:Water")) { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp_Num = HeatingCoilType::SimpleHeating; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp_PlantType = + airTerm.sysType, + airTerm.SysName)); + } else if (Util::SameString(airTerm.ReheatComp, "Coil:Heating:Water")) { + airTerm.ReheatComp_Num = HeatingCoilType::SimpleHeating; + airTerm.ReheatComp_PlantType = DataPlant::PlantEquipmentType::CoilWaterSimpleHeating; - } else if (Util::SameString(state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp, "Coil:Heating:Steam")) { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp_Num = HeatingCoilType::SteamAirHeating; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp_PlantType = + } else if (Util::SameString(airTerm.ReheatComp, "Coil:Heating:Steam")) { + airTerm.ReheatComp_Num = HeatingCoilType::SteamAirHeating; + airTerm.ReheatComp_PlantType = DataPlant::PlantEquipmentType::CoilSteamAirHeating; - } else if (!state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp.empty()) { + } else if (!airTerm.ReheatComp.empty()) { ShowSevereError( - state, format("Illegal {} = {}.", cAlphaFields(7), state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp)); + state, format("Illegal {} = {}.", cAlphaFields(7), airTerm.ReheatComp)); ShowContinueError(state, format("Occurs in {} = {}", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); + airTerm.sysType, + airTerm.SysName)); ErrorsFound = true; } ValidateComponent(state, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatName, + airTerm.ReheatComp, + airTerm.ReheatName, IsNotOK, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType); + airTerm.sysType); if (IsNotOK) { ShowContinueError(state, format("In {} = {}", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); + airTerm.sysType, + airTerm.SysName)); ErrorsFound = true; } - auto &airTerm = state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI); airTerm.fanType = static_cast(getEnumValue(HVAC::fanTypeNamesUC, Alphas(5))); if (airTerm.fanType != HVAC::FanType::VAV && airTerm.fanType != HVAC::FanType::SystemModel) { @@ -2100,40 +2018,32 @@ void GetSysInput(EnergyPlusData &state) dynamic_cast(state.dataFans->fans(airTerm.Fan_Index))->isSecondaryDriver = true; } - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).Schedule = Alphas(2); if (lAlphaBlanks(2)) { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SchedPtr = GetScheduleIndex(state, Alphas(2)); - if (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SchedPtr == 0) { - ShowSevereError(state, format("{} = {} not found.", cAlphaFields(2), Alphas(2))); - ShowContinueError(state, - format("Occurs in {} = {}", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); - ErrorsFound = true; - } + airTerm.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((airTerm.availSched = Sched::GetSchedule(state, Alphas(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(2), Alphas(2)); + ErrorsFound = true; } - AirTermSysInletNodeName = state.dataLoopNodes->NodeID(state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).InletNodeNum); + AirTermSysInletNodeName = state.dataLoopNodes->NodeID(airTerm.InletNodeNum); if (!Util::SameString(Alphas(3), AirTermSysInletNodeName)) { ShowWarningError(state, format("{}Invalid air terminal object air inlet node name in {} = {}", RoutineName, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); + airTerm.sysType, + airTerm.SysName)); ShowContinueError(state, format(" Specified air inlet node name is = {}.", Alphas(3))); ShowContinueError(state, format(" Expected air inlet node name is = {}.", AirTermSysInletNodeName)); // ErrorsFound = true; } - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).MaxAirVolFlowRate = Numbers(1); - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).MaxHeatAirVolFlowRate = Numbers(2); - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneMinAirFracDes = Numbers(3); + airTerm.MaxAirVolFlowRate = Numbers(1); + airTerm.MaxHeatAirVolFlowRate = Numbers(2); + airTerm.ZoneMinAirFracDes = Numbers(3); // The reheat coil control node is necessary for hot water reheat, but not necessary for // electric or gas reheat. - if (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp_Num == HeatingCoilType::Gas || - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp_Num == HeatingCoilType::Electric) { + if (airTerm.ReheatComp_Num == HeatingCoilType::Gas || + airTerm.ReheatComp_Num == HeatingCoilType::Electric) { // IF(.NOT. lAlphaBlanks(6)) THEN // CALL ShowWarningError(state, 'In '//TRIM(sd_airterminal(SysNum)%SysType)//' = ' // TRIM(sd_airterminal(SysNum)%SysName) & // // ' the '//TRIM(cAlphaFields(6))//' is not needed and will be ignored.') @@ -2145,18 +2055,18 @@ void GetSysInput(EnergyPlusData &state) // // ' the '//TRIM(cAlphaFields(6))//' is undefined') // ErrorsFound=.TRUE. // END IF - if (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp_Num == HeatingCoilType::SteamAirHeating) { + if (airTerm.ReheatComp_Num == HeatingCoilType::SteamAirHeating) { IsNotOK = false; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatControlNode = + airTerm.ReheatControlNode = GetCoilSteamInletNode(state, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatName, + airTerm.ReheatComp, + airTerm.ReheatName, IsNotOK); if (IsNotOK) { ShowContinueError(state, format("..Occurs in {} = {}", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); + airTerm.sysType, + airTerm.SysName)); ErrorsFound = true; } else { // A4, \field Unit supply air outlet node @@ -2164,16 +2074,16 @@ void GetSysInput(EnergyPlusData &state) // \note same as zone inlet node // \type alpha IsNotOK = false; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatAirOutletNode = + airTerm.ReheatAirOutletNode = GetCoilAirOutletNode(state, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatName, + airTerm.ReheatComp, + airTerm.ReheatName, IsNotOK); if (IsNotOK) { ShowContinueError(state, format("..Occurs in {} = {}", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); + airTerm.sysType, + airTerm.SysName)); ErrorsFound = true; } } @@ -2181,16 +2091,16 @@ void GetSysInput(EnergyPlusData &state) // DataLoopNode::NodeFluidType::Steam,DataLoopNode::NodeConnectionType::Actuator,1,ObjectIsParent) } else { IsNotOK = false; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatControlNode = + airTerm.ReheatControlNode = GetCoilWaterInletNode(state, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatName, + airTerm.ReheatComp, + airTerm.ReheatName, IsNotOK); if (IsNotOK) { ShowContinueError(state, format("..Occurs in {} = {}", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); + airTerm.sysType, + airTerm.SysName)); ErrorsFound = true; } else { // A4, \field Unit supply air outlet node @@ -2198,16 +2108,16 @@ void GetSysInput(EnergyPlusData &state) // \note same as zone inlet node // \type alpha IsNotOK = false; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatAirOutletNode = + airTerm.ReheatAirOutletNode = GetCoilOutletNode(state, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatName, + airTerm.ReheatComp, + airTerm.ReheatName, IsNotOK); if (IsNotOK) { ShowContinueError(state, format("..Occurs in {} = {}", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); + airTerm.sysType, + airTerm.SysName)); ErrorsFound = true; } } @@ -2223,60 +2133,60 @@ void GetSysInput(EnergyPlusData &state) // GetOnlySingleNode(state, Alphas(4),ErrorsFound,sd_airterminal(SysNum)%SysType,Alphas(1), & // DataLoopNode::NodeFluidType::Air,DataLoopNode::NodeConnectionType::Outlet,1,ObjectIsParent) AirTermSysOutletNodeName = - state.dataLoopNodes->NodeID(state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatAirOutletNode); + state.dataLoopNodes->NodeID(airTerm.ReheatAirOutletNode); if (!Util::SameString(Alphas(4), AirTermSysOutletNodeName)) { ShowWarningError(state, format("{}Invalid air terminal object air outlet node name in {} = {}", RoutineName, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); + airTerm.sysType, + airTerm.SysName)); ShowContinueError(state, format(" Specified air outlet node name is = {}.", Alphas(4))); ShowContinueError(state, format(" Expected air outlet node name is = {}.", AirTermSysOutletNodeName)); // ErrorsFound = true; } - if (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatComp_Num == HeatingCoilType::SteamAirHeating) { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).MaxReheatSteamVolFlow = Numbers(4); - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).MinReheatSteamVolFlow = Numbers(5); + if (airTerm.ReheatComp_Num == HeatingCoilType::SteamAirHeating) { + airTerm.MaxReheatSteamVolFlow = Numbers(4); + airTerm.MinReheatSteamVolFlow = Numbers(5); } else { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).MaxReheatWaterVolFlow = Numbers(4); - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).MinReheatWaterVolFlow = Numbers(5); + airTerm.MaxReheatWaterVolFlow = Numbers(4); + airTerm.MinReheatWaterVolFlow = Numbers(5); } - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ControllerOffset = Numbers(6); + airTerm.ControllerOffset = Numbers(6); // Set default convergence tolerance - if (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ControllerOffset <= 0.0) { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ControllerOffset = 0.001; + if (airTerm.ControllerOffset <= 0.0) { + airTerm.ControllerOffset = 0.001; } - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).DamperHeatingAction = Action::HeatingNotUsed; + airTerm.DamperHeatingAction = Action::HeatingNotUsed; // Register component set data TestCompSet(state, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName, - state.dataLoopNodes->NodeID(state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).InletNodeNum), - state.dataLoopNodes->NodeID(state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatAirOutletNode), + airTerm.sysType, + airTerm.SysName, + state.dataLoopNodes->NodeID(airTerm.InletNodeNum), + state.dataLoopNodes->NodeID(airTerm.ReheatAirOutletNode), "Air Nodes"); for (ADUNum = 1; ADUNum <= (int)state.dataDefineEquipment->AirDistUnit.size(); ++ADUNum) { - if (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatAirOutletNode == + if (airTerm.ReheatAirOutletNode == state.dataDefineEquipment->AirDistUnit(ADUNum).OutletNodeNum) { state.dataDefineEquipment->AirDistUnit(ADUNum).InletNodeNum = - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).InletNodeNum; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ADUNum = ADUNum; + airTerm.InletNodeNum; + airTerm.ADUNum = ADUNum; break; } } // one assumes if there isn't one assigned, it's an error? - if (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ADUNum == 0) { + if (airTerm.ADUNum == 0) { ShowSevereError(state, format("{}No matching Air Distribution Unit, for System = [{},{}].", RoutineName, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); + airTerm.sysType, + airTerm.SysName)); ShowContinueError( state, format("...should have outlet node = {}", - state.dataLoopNodes->NodeID(state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatAirOutletNode))); + state.dataLoopNodes->NodeID(airTerm.ReheatAirOutletNode))); ErrorsFound = true; } else { @@ -2286,7 +2196,7 @@ void GetSysInput(EnergyPlusData &state) for (CtrlZone = 1; CtrlZone <= state.dataGlobal->NumOfZones; ++CtrlZone) { if (!state.dataZoneEquip->ZoneEquipConfig(CtrlZone).IsControlled) continue; for (SupAirIn = 1; SupAirIn <= state.dataZoneEquip->ZoneEquipConfig(CtrlZone).NumInletNodes; ++SupAirIn) { - if (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatAirOutletNode == + if (airTerm.ReheatAirOutletNode == state.dataZoneEquip->ZoneEquipConfig(CtrlZone).InletNode(SupAirIn)) { IsNotOK = false; if (state.dataZoneEquip->ZoneEquipConfig(CtrlZone).AirDistUnitCool(SupAirIn).OutNode > 0) { @@ -2294,26 +2204,26 @@ void GetSysInput(EnergyPlusData &state) ShowContinueError(state, format("{} already connects to another zone", state.dataLoopNodes->NodeID( - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatAirOutletNode))); + airTerm.ReheatAirOutletNode))); ShowContinueError(state, format("Occurs for terminal unit {} = {}", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); + airTerm.sysType, + airTerm.SysName)); ShowContinueError(state, "Check terminal unit node names for errors"); ErrorsFound = true; } else { state.dataZoneEquip->ZoneEquipConfig(CtrlZone).AirDistUnitCool(SupAirIn).InNode = - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).InletNodeNum; + airTerm.InletNodeNum; state.dataZoneEquip->ZoneEquipConfig(CtrlZone).AirDistUnitCool(SupAirIn).OutNode = - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatAirOutletNode; - state.dataDefineEquipment->AirDistUnit(state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ADUNum) + airTerm.ReheatAirOutletNode; + state.dataDefineEquipment->AirDistUnit(airTerm.ADUNum) .TermUnitSizingNum = state.dataZoneEquip->ZoneEquipConfig(CtrlZone).AirDistUnitCool(SupAirIn).TermUnitSizingIndex; - state.dataDefineEquipment->AirDistUnit(state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ADUNum) + state.dataDefineEquipment->AirDistUnit(airTerm.ADUNum) .ZoneEqNum = CtrlZone; } - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).CtrlZoneNum = CtrlZone; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).CtrlZoneInNodeIndex = SupAirIn; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneFloorArea = + airTerm.CtrlZoneNum = CtrlZone; + airTerm.CtrlZoneInNodeIndex = SupAirIn; + airTerm.ZoneFloorArea = state.dataHeatBal->Zone(CtrlZone).FloorArea * state.dataHeatBal->Zone(CtrlZone).Multiplier * state.dataHeatBal->Zone(CtrlZone).ListMultiplier; } @@ -2324,51 +2234,42 @@ void GetSysInput(EnergyPlusData &state) ShowWarningError(state, "Did not Match Supply Air Outlet Node to any Zone Node"); ShowContinueError(state, format("..Occurs in {} = {}", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); + airTerm.sysType, + airTerm.SysName)); } if (lAlphaBlanks(9)) { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneTurndownMinAirFrac = 1.0; - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneTurndownMinAirFracSchExist = false; - } else { - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneTurndownMinAirFracSchPtr = GetScheduleIndex(state, Alphas(9)); - if (state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneTurndownMinAirFracSchPtr == 0) { - ShowSevereError(state, format("{} = {} not found.", cAlphaFields(9), Alphas(9))); - ShowContinueError(state, - format("Occurs in {} = {}", - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName)); - ErrorsFound = true; - } - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ZoneTurndownMinAirFracSchExist = true; - } + airTerm.ZoneTurndownMinAirFrac = 1.0; + } else if ((airTerm.zoneTurndownMinAirFracSched = Sched::GetSchedule(state, Alphas(9))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(9), Alphas(9)); + ErrorsFound = true; + } // Add reheat coil to component sets array SetUpCompSets(state, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName, + airTerm.sysType, + airTerm.SysName, Alphas(7), Alphas(8), - state.dataLoopNodes->NodeID(state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).OutletNodeNum), - state.dataLoopNodes->NodeID(state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).ReheatAirOutletNode)); + state.dataLoopNodes->NodeID(airTerm.OutletNodeNum), + state.dataLoopNodes->NodeID(airTerm.ReheatAirOutletNode)); // Add fan to component sets array SetUpCompSets(state, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).sysType, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName, + airTerm.sysType, + airTerm.SysName, Alphas(5), Alphas(6), - state.dataLoopNodes->NodeID(state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).InletNodeNum), - state.dataLoopNodes->NodeID(state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).OutletNodeNum)); + state.dataLoopNodes->NodeID(airTerm.InletNodeNum), + state.dataLoopNodes->NodeID(airTerm.OutletNodeNum)); // Setup the Average damper Position output variable SetupOutputVariable(state, "Zone Air Terminal VAV Damper Position", Constant::Units::None, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).DamperPosition, + airTerm.DamperPosition, OutputProcessor::TimeStepType::System, OutputProcessor::StoreType::Average, - state.dataSingleDuct->sd_airterminal(state.dataSingleDuct->SysNumGSI).SysName); + airTerm.SysName); } // common report variable for all single duct air terminals @@ -2524,8 +2425,8 @@ void SingleDuctAirTerminal::InitSys(EnergyPlusData &state, bool const FirstHVACI } // get current time step air terminal box turndown minimum flow fraction - if (this->ZoneTurndownMinAirFracSchExist) { - this->ZoneTurndownMinAirFrac = ScheduleManager::GetCurrentScheduleValue(state, this->ZoneTurndownMinAirFracSchPtr); + if (this->zoneTurndownMinAirFracSched != nullptr) { + this->ZoneTurndownMinAirFrac = this->zoneTurndownMinAirFracSched->getCurrentVal(); } else { this->ZoneTurndownMinAirFrac = 1.0; } @@ -2590,14 +2491,14 @@ void SingleDuctAirTerminal::InitSys(EnergyPlusData &state, bool const FirstHVACI // get current environment air terminal box turndown minimum flow fraction Real64 CurrentEnvZoneTurndownMinAirFrac = 1.0; - if (this->ZoneTurndownMinAirFracSchExist) { - CurrentEnvZoneTurndownMinAirFrac = ScheduleManager::GetScheduleMinValue(state, this->ZoneTurndownMinAirFracSchPtr); + if (this->zoneTurndownMinAirFracSched != nullptr) { + CurrentEnvZoneTurndownMinAirFrac = this->zoneTurndownMinAirFracSched->getCurrentVal(); } if ((this->SysType_Num == SysType::SingleDuctVAVReheat || this->SysType_Num == SysType::SingleDuctCBVAVReheat) || (this->SysType_Num == SysType::SingleDuctCBVAVNoReheat)) { // need the lowest schedule value if (this->ZoneMinAirFracMethod == MinFlowFraction::Scheduled) { - this->ZoneMinAirFracDes = GetScheduleMinValue(state, this->ZoneMinAirFracSchPtr); + this->ZoneMinAirFracDes = this->zoneMinAirFracSched->getCurrentVal(); } state.dataLoopNodes->Node(OutletNode).MassFlowRateMin = state.dataLoopNodes->Node(OutletNode).MassFlowRateMax * this->ZoneMinAirFracDes * CurrentEnvZoneTurndownMinAirFrac; @@ -2656,21 +2557,21 @@ void SingleDuctAirTerminal::InitSys(EnergyPlusData &state, bool const FirstHVACI } if (this->ZoneMinAirFracMethod == MinFlowFraction::Scheduled) { - this->ZoneMinAirFracDes = GetCurrentScheduleValue(state, this->ZoneMinAirFracSchPtr); + this->ZoneMinAirFracDes = this->zoneMinAirFracSched->getCurrentVal(); // now reset inlet node min avail state.dataLoopNodes->Node(InletNode).MassFlowRateMinAvail = this->AirMassFlowRateMax * this->ZoneMinAirFracDes * this->ZoneTurndownMinAirFrac; } if (FirstHVACIteration) { // The first time through set the mass flow rate to the Max - if ((state.dataLoopNodes->Node(InletNode).MassFlowRate > 0.0) && (GetCurrentScheduleValue(state, this->SchedPtr) > 0.0)) { + if ((state.dataLoopNodes->Node(InletNode).MassFlowRate > 0.0) && (this->availSched->getCurrentVal() > 0.0)) { if (!(state.afn->distribution_simulated && state.afn->AirflowNetworkFanActivated)) { state.dataLoopNodes->Node(InletNode).MassFlowRate = this->AirMassFlowRateMax; } } else { state.dataLoopNodes->Node(InletNode).MassFlowRate = 0.0; } - if ((state.dataLoopNodes->Node(InletNode).MassFlowRateMaxAvail > 0.0) && (GetCurrentScheduleValue(state, this->SchedPtr) > 0.0)) { + if ((state.dataLoopNodes->Node(InletNode).MassFlowRateMaxAvail > 0.0) && (this->availSched->getCurrentVal() > 0.0)) { if (!(state.afn->distribution_simulated && state.afn->AirflowNetworkFanActivated)) { if (this->SysType_Num == SysType::SingleDuctConstVolNoReheat) { if (this->NoOAFlowInputFromUser) { @@ -2692,7 +2593,7 @@ void SingleDuctAirTerminal::InitSys(EnergyPlusData &state, bool const FirstHVACI state.dataLoopNodes->Node(InletNode).MassFlowRateMaxAvail = 0.0; } - if ((state.dataLoopNodes->Node(InletNode).MassFlowRate > 0.0) && (GetCurrentScheduleValue(state, this->SchedPtr) > 0.0)) { + if ((state.dataLoopNodes->Node(InletNode).MassFlowRate > 0.0) && (this->availSched->getCurrentVal() > 0.0)) { if (!(state.afn->distribution_simulated && state.afn->AirflowNetworkFanActivated)) { state.dataLoopNodes->Node(InletNode).MassFlowRateMinAvail = this->AirMassFlowRateMax * this->ZoneMinAirFracDes * this->ZoneTurndownMinAirFrac; @@ -2709,7 +2610,7 @@ void SingleDuctAirTerminal::InitSys(EnergyPlusData &state, bool const FirstHVACI } else { if (this->SysType_Num == SysType::SingleDuctConstVolNoReheat) { if (!this->EMSOverrideAirFlow) { - if ((state.dataLoopNodes->Node(InletNode).MassFlowRateMaxAvail > 0.0) && (GetCurrentScheduleValue(state, this->SchedPtr) > 0.0)) { + if ((state.dataLoopNodes->Node(InletNode).MassFlowRateMaxAvail > 0.0) && (this->availSched->getCurrentVal() > 0.0)) { if (this->NoOAFlowInputFromUser) { if (state.dataLoopNodes->Node(InletNode).MassFlowRateMaxAvail < state.dataLoopNodes->Node(InletNode).MassFlowRateMax) { state.dataLoopNodes->Node(InletNode).MassFlowRate = state.dataLoopNodes->Node(InletNode).MassFlowRateMaxAvail; @@ -2967,8 +2868,8 @@ void SingleDuctAirTerminal::SizeSys(EnergyPlusData &state) } // get design day terminal unit turndown minimum flow fraction - if (this->ZoneTurndownMinAirFracSchExist) { - this->ZoneTurndownMinAirFrac = ScheduleManager::GetCurrentScheduleValue(state, this->ZoneTurndownMinAirFracSchPtr); + if (this->zoneTurndownMinAirFracSched != nullptr) { + this->ZoneTurndownMinAirFrac = this->zoneTurndownMinAirFracSched->getCurrentVal(); } else { this->ZoneTurndownMinAirFrac = 1.0; } @@ -3201,8 +3102,7 @@ void SingleDuctAirTerminal::SizeSys(EnergyPlusData &state) this->ZoneMinAirFracDes = min(1.0, SafeDivide(this->DesignFixedMinAir, this->MaxAirVolFlowRate)); } else { // use an average of min and max in schedule - this->ZoneMinAirFracDes = - (GetScheduleMinValue(state, this->ZoneMinAirFracSchPtr) + GetScheduleMaxValue(state, this->ZoneMinAirFracSchPtr)) / 2.0; + this->ZoneMinAirFracDes = (this->zoneMinAirFracSched->getMinVal(state) + this->zoneMinAirFracSched->getMaxVal(state)) / 2.0; } } @@ -3837,8 +3737,8 @@ void SingleDuctAirTerminal::SimVAV(EnergyPlusData &state, bool const FirstHVACIt // if the massflow is below the minimum or greater than the Max it is set to either the Min // or the Max as specified for the VAV model. if ((QTotLoad < 0.0) && (this->sd_airterminalInlet.AirMassFlowRateMaxAvail > 0.0) && - (state.dataHeatBalFanSys->TempControlType(ZoneNum) != HVAC::ThermostatType::SingleHeating) && - (GetCurrentScheduleValue(state, this->SchedPtr) > 0.0)) { + (state.dataHeatBalFanSys->TempControlType(ZoneNum) != HVAC::SetptType::SingleHeat) && + (this->availSched->getCurrentVal() > 0.0)) { // Calculate the flow required for cooling DeltaTemp = CpAirAvg * (this->sd_airterminalInlet.AirTemp - state.dataSingleDuct->ZoneTempSDAT); @@ -3877,8 +3777,8 @@ void SingleDuctAirTerminal::SimVAV(EnergyPlusData &state, bool const FirstHVACIt } } else if ((this->sd_airterminalInlet.AirMassFlowRateMaxAvail > 0.0) && - (QTotLoad >= 0.0 || state.dataHeatBalFanSys->TempControlType(ZoneNum) == HVAC::ThermostatType::SingleHeating) && - (GetCurrentScheduleValue(state, this->SchedPtr) > 0.0)) { + (QTotLoad >= 0.0 || state.dataHeatBalFanSys->TempControlType(ZoneNum) == HVAC::SetptType::SingleHeat) && + (this->availSched->getCurrentVal() > 0.0)) { // IF (sd_airterminal(SysNum)%DamperHeatingAction .EQ. ReverseAction .AND. this->sd_airterminalInlet%AirMassFlowRateMinAvail <= // SmallMassFlow) THEN // special case for heating: reverse action and damper allowed to close - set the minimum flow rate to a small but nonzero value @@ -3966,7 +3866,7 @@ void SingleDuctAirTerminal::SimVAV(EnergyPlusData &state, bool const FirstHVACIt // there's a heating requirement, and there's a thermostat with a heating setpoint // Reverse damper option is working only for water coils for now. if ((MassFlow > SmallMassFlow) && (QActualHeating > 0.0) && - (state.dataHeatBalFanSys->TempControlType(ZoneNum) != HVAC::ThermostatType::SingleCooling)) { + (state.dataHeatBalFanSys->TempControlType(ZoneNum) != HVAC::SetptType::SingleCool)) { // At this point we know that there is a heating requirement: i.e., the heating coil needs to // be activated (there's a zone heating load or there's a reheat requirement). There are 3 possible // situations: 1) the coil load can be met by variable temperature air (below the max heat temp) at @@ -4425,7 +4325,7 @@ void SingleDuctAirTerminal::SimCBVAV(EnergyPlusData &state, bool const FirstHVAC QActualHeating = QToHeatSetPt - MassFlow * CpAirZn * (this->sd_airterminalInlet.AirTemp - state.dataSingleDuct->ZoneTempSCBVAV); if ((MassFlow > SmallMassFlow) && (QActualHeating > 0.0) && - (state.dataHeatBalFanSys->TempControlType(ZoneNum) != HVAC::ThermostatType::SingleCooling)) { + (state.dataHeatBalFanSys->TempControlType(ZoneNum) != HVAC::SetptType::SingleCool)) { // VAVHeatandCool boxes operate at varying mass flow rates when reheating, VAV boxes operate at min flow // (MassFlow <= this->sd_airterminalInlet%AirMassFlowRateMinAvail) .AND. & // Per Fred Buhl, don't use DeadBandOrSetback to determine if heaters operate @@ -5155,7 +5055,7 @@ void SingleDuctAirTerminal::SimConstVol(EnergyPlusData &state, bool const FirstH // Now the massflow for reheating has been determined. If it is zero, or in SetBack, or the // system scheduled OFF then not operational and shut the system down. if ((MassFlow > SmallMassFlow) && (QActualHeating > 0.0) && - (state.dataHeatBalFanSys->TempControlType(ZoneNum) != HVAC::ThermostatType::SingleCooling)) { + (state.dataHeatBalFanSys->TempControlType(ZoneNum) != HVAC::SetptType::SingleCool)) { switch (this->ReheatComp_Num) { case HeatingCoilType::SimpleHeating: { // COIL:WATER:SIMPLEHEATING @@ -6478,22 +6378,21 @@ void SingleDuctAirTerminal::reportTerminalUnit(EnergyPlusData &state) OutputReportPredefined::PreDefTableEntry(state, orp->pdchAirTermTypeInp, adu.Name, this->sysType); OutputReportPredefined::PreDefTableEntry(state, orp->pdchAirTermPrimFlow, adu.Name, this->MaxAirVolFlowRate); OutputReportPredefined::PreDefTableEntry(state, orp->pdchAirTermSecdFlow, adu.Name, "n/a"); - if (this->ZoneMinAirFracSchPtr > 0) { - OutputReportPredefined::PreDefTableEntry( - state, orp->pdchAirTermMinFlowSch, adu.Name, ScheduleManager::GetScheduleName(state, this->ZoneMinAirFracSchPtr)); + if (this->zoneMinAirFracSched != nullptr) { + OutputReportPredefined::PreDefTableEntry(state, orp->pdchAirTermMinFlowSch, adu.Name, this->zoneMinAirFracSched->Name); } else { OutputReportPredefined::PreDefTableEntry(state, orp->pdchAirTermMinFlowSch, adu.Name, "n/a"); } OutputReportPredefined::PreDefTableEntry(state, orp->pdchAirTermMaxFlowReh, adu.Name, this->MaxAirVolFlowRateDuringReheat); std::string schName = "n/a"; if (this->OARequirementsPtr > 0) { - int minOAsch = state.dataSize->OARequirements(this->OARequirementsPtr).OAFlowFracSchPtr; - if (minOAsch > 0) schName = ScheduleManager::GetScheduleName(state, minOAsch); + auto const *minOASched = state.dataSize->OARequirements(this->OARequirementsPtr).oaFlowFracSched; + if (minOASched != nullptr) schName = minOASched->Name; } OutputReportPredefined::PreDefTableEntry(state, orp->pdchAirTermMinOAflowSch, adu.Name, schName); OutputReportPredefined::PreDefTableEntry(state, orp->pdchAirTermHeatCoilType, adu.Name, this->ReheatComp); OutputReportPredefined::PreDefTableEntry(state, orp->pdchAirTermCoolCoilType, adu.Name, "n/a"); - if ((int)this->fanType >= 0) { + if (this->fanType != HVAC::FanType::Invalid) { OutputReportPredefined::PreDefTableEntry(state, orp->pdchAirTermFanType, adu.Name, HVAC::fanTypeNames[(int)this->fanType]); } else { OutputReportPredefined::PreDefTableEntry(state, orp->pdchAirTermFanType, adu.Name, "n/a"); diff --git a/src/EnergyPlus/SingleDuct.hh b/src/EnergyPlus/SingleDuct.hh index 049d30498da..da974f1347f 100644 --- a/src/EnergyPlus/SingleDuct.hh +++ b/src/EnergyPlus/SingleDuct.hh @@ -134,8 +134,7 @@ namespace SingleDuct { std::string SysName; // Name of the Sys std::string sysType; // Type of Sys ie. VAV, Mixing, Inducing, etc. SysType SysType_Num; // Numeric Equivalent for System type - std::string Schedule; // Sys Operation Schedule - int SchedPtr; // Pointer to the correct schedule + Sched::Schedule *availSched = nullptr; // availability schedule std::string ReheatComp; // Type of the Reheat Coil Object HeatingCoilType ReheatComp_Num; // Numeric Equivalent in this module for Coil type int ReheatComp_Index; // Returned Index number from other routines @@ -155,7 +154,7 @@ namespace SingleDuct { Real64 ZoneMinAirFrac; // Fraction of supply air used as current minimum flow Real64 ZoneMinAirFracReport; // Fraction of supply air used as minimum flow for reporting (zero if terminal unit flow is zero) Real64 ZoneFixedMinAir; // Absolute minimum supply air flow - int ZoneMinAirFracSchPtr; // pointer to the schedule for min flow fraction + Sched::Schedule *zoneMinAirFracSched = nullptr; // schedule for min flow fraction bool ConstantMinAirFracSetByUser; // record if user left field blank for constant min fraction. bool FixedMinAirSetByUser; // record if user left field blank for constant min fraction. Real64 DesignMinAirFrac; // store user entered constant min flow fract for design @@ -206,9 +205,8 @@ namespace SingleDuct { DataZoneEquipment::PerPersonVentRateMode OAPerPersonMode; // mode for how per person rates are determined, DCV or design. bool EMSOverrideAirFlow; // if true, EMS is calling to override flow rate Real64 EMSMassFlowRateValue; // value EMS is directing to use for flow rate [kg/s] - int ZoneTurndownMinAirFracSchPtr; // pointer to the schedule for turndown minimum airflow fraction + Sched::Schedule *zoneTurndownMinAirFracSched = nullptr; // schedule for turndown minimum airflow fraction Real64 ZoneTurndownMinAirFrac; // turndown minimum airflow fraction value, multiplier of zone design minimum air flow - bool ZoneTurndownMinAirFracSchExist; // if true, if zone turndown min air frac schedule exist bool MyEnvrnFlag; bool MySizeFlag; bool GetGasElecHeatCoilCap; // Gets autosized value of coil capacity @@ -222,11 +220,11 @@ namespace SingleDuct { // Default Constructor SingleDuctAirTerminal() - : SysNum(-1), SysType_Num(SysType::Invalid), SchedPtr(0), ReheatComp_Num(HeatingCoilType::None), ReheatComp_Index(0), + : SysNum(-1), SysType_Num(SysType::Invalid), ReheatComp_Num(HeatingCoilType::None), ReheatComp_Index(0), ReheatComp_PlantType(DataPlant::PlantEquipmentType::Invalid), fanType(HVAC::FanType::Invalid), Fan_Index(0), ControlCompTypeNum(0), CompErrIndex(0), MaxAirVolFlowRate(0.0), AirMassFlowRateMax(0.0), MaxHeatAirVolFlowRate(0.0), HeatAirMassFlowRateMax(0.0), ZoneMinAirFracMethod(MinFlowFraction::Constant), ZoneMinAirFracDes(0.0), ZoneMinAirFrac(0.0), ZoneMinAirFracReport(0.0), - ZoneFixedMinAir(0.0), ZoneMinAirFracSchPtr(0), ConstantMinAirFracSetByUser(false), FixedMinAirSetByUser(false), DesignMinAirFrac(0.0), + ZoneFixedMinAir(0.0), ConstantMinAirFracSetByUser(false), FixedMinAirSetByUser(false), DesignMinAirFrac(0.0), DesignFixedMinAir(0.0), InletNodeNum(0), OutletNodeNum(0), ReheatControlNode(0), ReheatCoilOutletNode(0), ReheatCoilMaxCapacity(0.0), ReheatAirOutletNode(0), MaxReheatWaterVolFlow(0.0), MaxReheatSteamVolFlow(0.0), MaxReheatWaterFlow(0.0), MaxReheatSteamFlow(0.0), MinReheatWaterVolFlow(0.0), MinReheatSteamVolFlow(0.0), MinReheatWaterFlow(0.0), MinReheatSteamFlow(0.0), ControllerOffset(0.0), @@ -235,7 +233,7 @@ namespace SingleDuct { MaxAirVolFlowRateDuringReheat(0.0), MaxAirVolFractionDuringReheat(0.0), AirMassFlowDuringReheatMax(0.0), ZoneOutdoorAirMethod(0), OutdoorAirFlowRate(0.0), NoOAFlowInputFromUser(true), OARequirementsPtr(0), AirLoopNum(0), HWplantLoc{}, SecInNode(0), IterationLimit(0), IterationFailed(0), OAPerPersonMode(DataZoneEquipment::PerPersonVentRateMode::Invalid), EMSOverrideAirFlow(false), - EMSMassFlowRateValue(0.0), ZoneTurndownMinAirFracSchPtr(0), ZoneTurndownMinAirFrac(1.0), ZoneTurndownMinAirFracSchExist(false), + EMSMassFlowRateValue(0.0), ZoneTurndownMinAirFrac(1.0), MyEnvrnFlag(true), MySizeFlag(true), GetGasElecHeatCoilCap(true), PlantLoopScanFlag(true), MassFlow1(0.0), MassFlow2(0.0), MassFlow3(0.0), MassFlowDiff(0.0) { @@ -436,6 +434,10 @@ struct SingleDuctData : BaseGlobalStruct Real64 MinMassAirFlowSDAT = 0.0; // the air flow rate during heating for normal acting damper Real64 QZoneMax2SDAT = 0.0; // temporary variable + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/SizingAnalysisObjects.cc b/src/EnergyPlus/SizingAnalysisObjects.cc index ee6eb9d8ab8..d6e1dc9e7f4 100644 --- a/src/EnergyPlus/SizingAnalysisObjects.cc +++ b/src/EnergyPlus/SizingAnalysisObjects.cc @@ -323,10 +323,10 @@ int SizingLoggerFramework::SetupVariableSizingLog(EnergyPlusData &state, Real64 for (int i = 1; i <= state.dataWeather->NumOfEnvrn; ++i) { if (state.dataWeather->Environment(i).KindOfEnvrn == Constant::KindOfSim::DesignDay) { - tmpLog.ztStepCountByEnvrnMap[i] = HoursPerDay * state.dataGlobal->NumOfTimeStepInHour; + tmpLog.ztStepCountByEnvrnMap[i] = HoursPerDay * state.dataGlobal->TimeStepsInHour; } if (state.dataWeather->Environment(i).KindOfEnvrn == Constant::KindOfSim::RunPeriodDesign) { - tmpLog.ztStepCountByEnvrnMap[i] = HoursPerDay * state.dataGlobal->NumOfTimeStepInHour * state.dataWeather->Environment(i).TotalDays; + tmpLog.ztStepCountByEnvrnMap[i] = HoursPerDay * state.dataGlobal->TimeStepsInHour * state.dataWeather->Environment(i).TotalDays; } } @@ -379,7 +379,7 @@ ZoneTimestepObject SizingLoggerFramework::PrepareZoneTimestepStamp(EnergyPlusDat state.dataGlobal->HourOfDay, state.dataGlobal->TimeStep, *state.dataOutputProcessor->TimeValue[(int)OutputProcessor::TimeStepType::Zone].TimeStep, - state.dataGlobal->NumOfTimeStepInHour); + state.dataGlobal->TimeStepsInHour); return tmpztStepStamp; } diff --git a/src/EnergyPlus/SizingManager.cc b/src/EnergyPlus/SizingManager.cc index 0b76cbd122e..7d88ea52da8 100644 --- a/src/EnergyPlus/SizingManager.cc +++ b/src/EnergyPlus/SizingManager.cc @@ -334,12 +334,12 @@ void ManageSizing(EnergyPlusData &state) UpdateFacilitySizing(state, Constant::CallIndicator::BeginDay); } - for (state.dataGlobal->HourOfDay = 1; state.dataGlobal->HourOfDay <= 24; ++state.dataGlobal->HourOfDay) { // Begin hour loop ... + for (state.dataGlobal->HourOfDay = 1; state.dataGlobal->HourOfDay <= Constant::iHoursInDay; ++state.dataGlobal->HourOfDay) { // Begin hour loop ... state.dataGlobal->BeginHourFlag = true; state.dataGlobal->EndHourFlag = false; - for (state.dataGlobal->TimeStep = 1; state.dataGlobal->TimeStep <= state.dataGlobal->NumOfTimeStepInHour; + for (state.dataGlobal->TimeStep = 1; state.dataGlobal->TimeStep <= state.dataGlobal->TimeStepsInHour; ++state.dataGlobal->TimeStep) { // Begin time step (TINC) loop ... state.dataGlobal->BeginTimeStepFlag = true; @@ -351,9 +351,9 @@ void ManageSizing(EnergyPlusData &state) // Note also that BeginTimeStepFlag, EndTimeStepFlag, and the // SubTimeStepFlags can/will be set/reset in the HVAC Manager. - if (state.dataGlobal->TimeStep == state.dataGlobal->NumOfTimeStepInHour) { + if (state.dataGlobal->TimeStep == state.dataGlobal->TimeStepsInHour) { state.dataGlobal->EndHourFlag = true; - if (state.dataGlobal->HourOfDay == 24) { + if (state.dataGlobal->HourOfDay == Constant::iHoursInDay) { state.dataGlobal->EndDayFlag = true; if ((!state.dataGlobal->WarmupFlag) && (state.dataGlobal->DayOfSim == state.dataGlobal->NumOfDayInEnvrn)) { state.dataGlobal->EndEnvrnFlag = true; @@ -373,7 +373,7 @@ void ManageSizing(EnergyPlusData &state) if (!state.dataGlobal->WarmupFlag) { TimeStepInDay = - (state.dataGlobal->HourOfDay - 1) * state.dataGlobal->NumOfTimeStepInHour + state.dataGlobal->TimeStep; + (state.dataGlobal->HourOfDay - 1) * state.dataGlobal->TimeStepsInHour + state.dataGlobal->TimeStep; if (state.dataGlobal->HourOfDay == 1 && state.dataGlobal->TimeStep == 1) { state.dataSize->DesDayWeath(state.dataSize->CurOverallSimDay).DateString = fmt::format("{}/{}", state.dataEnvrn->Month, state.dataEnvrn->DayOfMonth); @@ -518,12 +518,12 @@ void ManageSizing(EnergyPlusData &state) UpdateSysSizing(state, Constant::CallIndicator::BeginDay); } - for (state.dataGlobal->HourOfDay = 1; state.dataGlobal->HourOfDay <= 24; ++state.dataGlobal->HourOfDay) { // Begin hour loop ... + for (state.dataGlobal->HourOfDay = 1; state.dataGlobal->HourOfDay <= Constant::iHoursInDay; ++state.dataGlobal->HourOfDay) { // Begin hour loop ... state.dataGlobal->BeginHourFlag = true; state.dataGlobal->EndHourFlag = false; - for (state.dataGlobal->TimeStep = 1; state.dataGlobal->TimeStep <= state.dataGlobal->NumOfTimeStepInHour; + for (state.dataGlobal->TimeStep = 1; state.dataGlobal->TimeStep <= state.dataGlobal->TimeStepsInHour; ++state.dataGlobal->TimeStep) { // Begin time step (TINC) loop ... state.dataGlobal->BeginTimeStepFlag = true; @@ -533,9 +533,9 @@ void ManageSizing(EnergyPlusData &state) // .TRUE. unless EndHourFlag is also .TRUE., etc. Note that the // EndEnvrnFlag and the EndSimFlag cannot be set during warmup. - if (state.dataGlobal->TimeStep == state.dataGlobal->NumOfTimeStepInHour) { + if (state.dataGlobal->TimeStep == state.dataGlobal->TimeStepsInHour) { state.dataGlobal->EndHourFlag = true; - if (state.dataGlobal->HourOfDay == 24) { + if (state.dataGlobal->HourOfDay == Constant::iHoursInDay) { state.dataGlobal->EndDayFlag = true; if ((!state.dataGlobal->WarmupFlag) && (state.dataGlobal->DayOfSim == state.dataGlobal->NumOfDayInEnvrn)) { state.dataGlobal->EndEnvrnFlag = true; @@ -2072,12 +2072,12 @@ void DetermineSystemPopulationDiversity(EnergyPlusData &state) state.dataEnvrn->DayOfWeek = dayOfWeekType; ++dayOfWeekType; if (dayOfWeekType > 7) dayOfWeekType = 1; - for (int hrOfDay = 1; hrOfDay <= 24; ++hrOfDay) { // loop over all hours in day + for (int hrOfDay = 1; hrOfDay <= Constant::iHoursInDay; ++hrOfDay) { // loop over all hours in day state.dataGlobal->HourOfDay = hrOfDay; // avoid crash in schedule manager - for (int TS = 1; TS <= state.dataGlobal->NumOfTimeStepInHour; ++TS) { // loop over all timesteps in hour + for (int TS = 1; TS <= state.dataGlobal->TimeStepsInHour; ++TS) { // loop over all timesteps in hour state.dataGlobal->TimeStep = TS; // avoid crash in schedule manager Real64 TSfraction(0.0); - if (state.dataGlobal->NumOfTimeStepInHour > 0.0) TSfraction = 1.0 / double(state.dataGlobal->NumOfTimeStepInHour); + if (state.dataGlobal->TimeStepsInHour > 0.0) TSfraction = 1.0 / double(state.dataGlobal->TimeStepsInHour); for (int AirLoopNum = 1; AirLoopNum <= state.dataHVACGlobal->NumPrimaryAirSys; ++AirLoopNum) { // loop over all the air systems int SysSizNum = Util::FindItemInList( FinalSysSizing(AirLoopNum).AirPriLoopName, state.dataSize->SysSizInput, &SystemSizingInputData::AirPriLoopName); @@ -2095,8 +2095,7 @@ void DetermineSystemPopulationDiversity(EnergyPlusData &state) (state.dataHeatBal->People(PeopleNum).NumberOfPeople * state.dataHeatBal->Zone(state.dataSize->FinalZoneSizing(CtrlZoneNum).ZoneNum).Multiplier * state.dataHeatBal->Zone(state.dataSize->FinalZoneSizing(CtrlZoneNum).ZoneNum).ListMultiplier); - Real64 schMultiplier = ScheduleManager::LookUpScheduleValue( - state, state.dataHeatBal->People(PeopleNum).NumberOfPeoplePtr, hrOfDay, TS); + Real64 schMultiplier = state.dataHeatBal->People(PeopleNum).numberOfPeopleSched->getHrTsVal(state, hrOfDay, TS); PeopleInZone = PeopleInZone * schMultiplier; TotConcurrentPeopleOnSys += PeopleInZone; } @@ -2172,10 +2171,6 @@ void GetOARequirements(EnergyPlusData &state) // This object requires only a name where the default values are assumed // if subsequent fields are not entered. - using ScheduleManager::CheckScheduleValueMinMax; - using ScheduleManager::GetScheduleIndex; - using ScheduleManager::GetScheduleMaxValue; - static constexpr std::string_view RoutineName("GetOARequirements: "); // include trailing blank space int NumAlphas; // Number of Alphas for each GetObjectItem call @@ -2326,25 +2321,10 @@ void ProcessInputOARequirements(EnergyPlusData &state, // This object requires only a name where the default values are assumed // if subsequent fields are not entered. - // REFERENCES: - // na - - using ScheduleManager::CheckScheduleValueMinMax; - using ScheduleManager::GetScheduleIndex; - using ScheduleManager::GetScheduleMaxValue; - - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - // na - - // SUBROUTINE PARAMETER DEFINITIONS: static constexpr std::string_view RoutineName("GetOARequirements: "); // include trailing blank space + static constexpr std::string_view routineName = "GetOARequirements"; - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na + ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)}; auto &thisOARequirements(state.dataSize->OARequirements(OAIndex)); @@ -2406,41 +2386,23 @@ void ProcessInputOARequirements(EnergyPlusData &state, } // Set default schedule - state.dataSize->OARequirements(OAIndex).OAFlowFracSchPtr = ScheduleManager::ScheduleAlwaysOn; - if (NumAlphas > 2) { - if (!lAlphaBlanks(3)) { - state.dataSize->OARequirements(OAIndex).OAFlowFracSchPtr = GetScheduleIndex(state, Alphas(3)); - if (state.dataSize->OARequirements(OAIndex).OAFlowFracSchPtr > 0) { - if (!CheckScheduleValueMinMax(state, state.dataSize->OARequirements(OAIndex).OAFlowFracSchPtr, ">=", 0.0, "<=", 1.0)) { - ShowSevereError(state, format("{}{}=\"{}\",", RoutineName, CurrentModuleObject, state.dataSize->OARequirements(OAIndex).Name)); - ShowContinueError(state, format("Error found in {} = {}", cAlphaFields(3), Alphas(3))); - ShowContinueError(state, "Schedule values must be (>=0., <=1.)"); - ErrorsFound = true; - } - } else { - ShowSevereError(state, format("{}{}=\"{}\",", RoutineName, CurrentModuleObject, state.dataSize->OARequirements(OAIndex).Name)); - ShowContinueError(state, format("...Not Found {}=\"{}\".", cAlphaFields(3), Alphas(3))); - ErrorsFound = true; - } - } + if (NumAlphas <= 2 || lAlphaBlanks(3)) { + state.dataSize->OARequirements(OAIndex).oaFlowFracSched = Sched::GetScheduleAlwaysOn(state); + } else if ((state.dataSize->OARequirements(OAIndex).oaFlowFracSched = Sched::GetSchedule(state, Alphas(3))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(3), Alphas(3)); + ErrorsFound = true; + } else if (!state.dataSize->OARequirements(OAIndex).oaFlowFracSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) { + Sched::ShowSevereBadMinMax(state, eoh, cAlphaFields(3), Alphas(3), Clusive::In, 0.0, Clusive::In, 1.0); + ErrorsFound = true; } - if (NumAlphas > 3) { - if (!lAlphaBlanks(4)) { - state.dataSize->OARequirements(OAIndex).OAPropCtlMinRateSchPtr = GetScheduleIndex(state, Alphas(4)); - if (state.dataSize->OARequirements(OAIndex).OAPropCtlMinRateSchPtr > 0) { - if (!CheckScheduleValueMinMax(state, state.dataSize->OARequirements(OAIndex).OAPropCtlMinRateSchPtr, ">=", 0.0, "<=", 1.0)) { - ShowSevereError(state, format("{}{}=\"{}\",", RoutineName, CurrentModuleObject, state.dataSize->OARequirements(OAIndex).Name)); - ShowContinueError(state, format("Error found in {} = {}", cAlphaFields(4), Alphas(4))); - ShowContinueError(state, "Schedule values must be (>=0., <=1.)"); - ErrorsFound = true; - } - } else { - ShowSevereError(state, format("{}{}=\"{}\",", RoutineName, CurrentModuleObject, state.dataSize->OARequirements(OAIndex).Name)); - ShowContinueError(state, format("...Not Found {}=\"{}\".", cAlphaFields(4), Alphas(4))); - ErrorsFound = true; - } - } + if (NumAlphas <= 3 || lAlphaBlanks(4)) { + } else if ((state.dataSize->OARequirements(OAIndex).oaPropCtlMinRateSched = Sched::GetSchedule(state, Alphas(4))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(4), Alphas(4)); + ErrorsFound = true; + } else if (!state.dataSize->OARequirements(OAIndex).oaPropCtlMinRateSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) { + Sched::ShowSevereBadMinMax(state, eoh, cAlphaFields(4), Alphas(4), Clusive::In, 0.0, Clusive::In, 1.0); + ErrorsFound = true; } } @@ -2462,12 +2424,9 @@ void GetZoneAirDistribution(EnergyPlusData &state) // This object requires only a name where the default values are assumed // if subsequent fields are not entered. - // Using/Aliasing - using ScheduleManager::CheckScheduleValueMinMax; - using ScheduleManager::GetScheduleIndex; - // SUBROUTINE PARAMETER DEFINITIONS: static constexpr std::string_view RoutineName("GetZoneAirDistribution: "); // include trailing blank space + static constexpr std::string_view routineName = "GetZoneAirDistribution"; // include trailing blank space // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int NumAlphas; // Number of Alphas for each GetObjectItem call @@ -2514,6 +2473,8 @@ void GetZoneAirDistribution(EnergyPlusData &state) lAlphaBlanks, cAlphaFields, cNumericFields); + + ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)}; Util::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound); state.dataSize->ZoneAirDistribution(ZADIndex).Name = Alphas(1); @@ -2550,25 +2511,13 @@ void GetZoneAirDistribution(EnergyPlusData &state) state.dataSize->ZoneAirDistribution(ZADIndex).ZoneVentilationEff = 0.0; } - if (NumAlphas > 1) { - if (!lAlphaBlanks(2)) { - state.dataSize->ZoneAirDistribution(ZADIndex).ZoneADEffSchName = Alphas(2); - state.dataSize->ZoneAirDistribution(ZADIndex).ZoneADEffSchPtr = GetScheduleIndex(state, Alphas(2)); - if (state.dataSize->ZoneAirDistribution(ZADIndex).ZoneADEffSchPtr > 0) { - if (!CheckScheduleValueMinMax(state, state.dataSize->ZoneAirDistribution(ZADIndex).ZoneADEffSchPtr, false, 0.0)) { - ShowSevereError( - state, format("{}{}=\"{}\",", RoutineName, CurrentModuleObject, state.dataSize->ZoneAirDistribution(ZADIndex).Name)); - ShowContinueError(state, format("Error found in {} = {}", cAlphaFields(2), Alphas(2))); - ShowContinueError(state, "Schedule values must be >0.0)"); - ErrorsFound = true; - } - } else { - ShowSevereError(state, - format("{}{}=\"{}\",", RoutineName, CurrentModuleObject, state.dataSize->ZoneAirDistribution(ZADIndex).Name)); - ShowContinueError(state, format("...Not Found {}=\"{}\".", cAlphaFields(2), Alphas(2))); - ErrorsFound = true; - } - } + if (NumAlphas <= 1 || lAlphaBlanks(2)) { + } else if ((state.dataSize->ZoneAirDistribution(ZADIndex).zoneADEffSched = Sched::GetSchedule(state, Alphas(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(2), Alphas(2)); + ErrorsFound = true; + } else if (!state.dataSize->ZoneAirDistribution(ZADIndex).zoneADEffSched->checkMinVal(state, Clusive::Ex, 0.0)) { + Sched::ShowSevereBadMin(state, eoh, cAlphaFields(2), Alphas(2), Clusive::Ex, 0.0); + ErrorsFound = true; } } @@ -2637,30 +2586,30 @@ void GetSizingParams(EnergyPlusData &state) state.dataSize->GlobalCoolSizingFactor = state.dataIPShortCut->rNumericArgs(2); } if (state.dataIPShortCut->lNumericFieldBlanks(3) || state.dataIPShortCut->rNumericArgs(3) <= 0.0) { - state.dataSize->NumTimeStepsInAvg = state.dataGlobal->NumOfTimeStepInHour; + state.dataSize->NumTimeStepsInAvg = state.dataGlobal->TimeStepsInHour; } else { state.dataSize->NumTimeStepsInAvg = int(state.dataIPShortCut->rNumericArgs(3)); } } else if (NumSizParams == 0) { state.dataSize->GlobalHeatSizingFactor = 1.0; state.dataSize->GlobalCoolSizingFactor = 1.0; - state.dataSize->NumTimeStepsInAvg = state.dataGlobal->NumOfTimeStepInHour; + state.dataSize->NumTimeStepsInAvg = state.dataGlobal->TimeStepsInHour; } else { ShowFatalError(state, format("{}: More than 1 occurrence of this object; only 1 allowed", cCurrentModuleObject)); } if (state.dataGlobal->OverrideTimestep) { - state.dataSize->NumTimeStepsInAvg = state.dataGlobal->NumOfTimeStepInHour; + state.dataSize->NumTimeStepsInAvg = state.dataGlobal->TimeStepsInHour; ShowWarningError(state, "Due to the use of the fast simulation mode, the time step for simulation and averaging window of sizing is overwritten to " "one hour. Original user inputs for averaging window and timestep are no longer used."); } - if (state.dataSize->NumTimeStepsInAvg < state.dataGlobal->NumOfTimeStepInHour) { + if (state.dataSize->NumTimeStepsInAvg < state.dataGlobal->TimeStepsInHour) { ShowWarningError(state, format("{}: note {} entered value=[{}] is less than 1 hour (i.e., {} timesteps).", cCurrentModuleObject, state.dataIPShortCut->cNumericFieldNames(3), state.dataSize->NumTimeStepsInAvg, - state.dataGlobal->NumOfTimeStepInHour)); + state.dataGlobal->TimeStepsInHour)); } cCurrentModuleObject = "OutputControl:Sizing:Style"; @@ -2721,7 +2670,7 @@ void GetZoneSizingInput(EnergyPlusData &state) // METHODOLOGY EMPLOYED: // Uses InputProcessor "Get" routines to obtain data. - // Using/Aliasing + static constexpr std::string_view routineName = "GetZoneSizingInput"; // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int ZoneSizIndex; // loop index @@ -2850,6 +2799,8 @@ void GetZoneSizingInput(EnergyPlusData &state) state.dataIPShortCut->cAlphaFieldNames, state.dataIPShortCut->cNumericFieldNames); + ErrorObjectHeader eoh{routineName, cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1)}; + for (Item1 = 1; Item1 <= SizingZoneObjects(Item).NumOfZones; ++Item1) { ++ZoneSizIndex; auto &zoneSizingIndex = state.dataSize->ZoneSizingInput(ZoneSizIndex); @@ -3306,44 +3257,31 @@ void GetZoneSizingInput(EnergyPlusData &state) (state.dataIPShortCut->cAlphaArgs(12) == "SUPPLYAIRHUMIDITYRATIO") ? SupplyAirHumidityRatio : HumidityRatioDifference; zoneSizingIndex.LatentHeatDesHumRat = state.dataIPShortCut->rNumericArgs(21); zoneSizingIndex.HeatDesHumRatDiff = state.dataIPShortCut->rNumericArgs(22); - if (NumAlphas > 12 && !state.dataIPShortCut->lAlphaFieldBlanks(13)) { - zoneSizingIndex.zoneRHDehumidifySchIndex = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(13)); - if (zoneSizingIndex.zoneRHDehumidifySchIndex == 0) { - ShowWarningError(state, - format("{} = \"{}\", invalid Zone Humidistat Dehumidification Set Point Schedule Name = {}. Schedule will " - "not be used and simulation continues.", - cCurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaArgs(13))); - } + + if (NumAlphas <= 12 || state.dataIPShortCut->lAlphaFieldBlanks(13)) { + } else if ((zoneSizingIndex.zoneRHDehumidifySched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(13))) == nullptr) { + ShowWarningItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(13), state.dataIPShortCut->cAlphaArgs(13), + "Schedule will not be used and simulation continues."); } - if (NumAlphas > 13 && !state.dataIPShortCut->lAlphaFieldBlanks(14)) { - zoneSizingIndex.zoneRHHumidifySchIndex = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(14)); - if (zoneSizingIndex.zoneRHHumidifySchIndex == 0) { - ShowWarningError(state, - format("{} = \"{}\", invalid Zone Humidistat Humidification Set Point Schedule Name = {}. Schedule will " - "not be used and simulation continues.", - cCurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaArgs(14))); - } else if (zoneSizingIndex.zoneRHDehumidifySchIndex) { - // check max and min of each schedule and compare RHHumidify > RHDehumidify and warn - Real64 maxHumidify = ScheduleManager::GetScheduleMaxValue(state, zoneSizingIndex.zoneRHHumidifySchIndex); - Real64 minDehumidify = ScheduleManager::GetScheduleMinValue(state, zoneSizingIndex.zoneRHDehumidifySchIndex); - if (maxHumidify > minDehumidify) { - ShowWarningError( - state, - format("{} = \"{}\", maximum value ({}%) of Zone Humidistat Humidification Set Point Schedule Name = {} is " - "greater than minimum value ({}%) of Zone Humidistat Dehumidifcation Set Point Schedule Name = {}. " - "Humidification set point will be limited by Dehumidification set point during zone sizing and simulation " - "continues.", - cCurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), - maxHumidify, - state.dataIPShortCut->cAlphaArgs(14), - minDehumidify, - state.dataIPShortCut->cAlphaArgs(13))); - } + + if (NumAlphas <= 13 || state.dataIPShortCut->lAlphaFieldBlanks(14)) { + } else if ((zoneSizingIndex.zoneRHHumidifySched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(14))) == nullptr) { + ShowWarningItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(14), state.dataIPShortCut->cAlphaArgs(14), + "Schedule will not be used and simulation continues."); + } else if (zoneSizingIndex.zoneRHDehumidifySched) { + // check max and min of each schedule and compare RHHumidify > RHDehumidify and warn + Real64 maxHumidify = zoneSizingIndex.zoneRHHumidifySched->getMaxVal(state); + Real64 minDehumidify = zoneSizingIndex.zoneRHDehumidifySched->getMinVal(state); + if (maxHumidify > minDehumidify) { + ShowWarningCustom(state, eoh, + format("Maximum value ({}%) of Zone Humidistat Humidification Set Point Schedule Name = {} is " + "greater than minimum value ({}%) of Zone Humidistat Dehumidifcation Set Point Schedule Name = {}. " + "Humidification set point will be limited by Dehumidification set point during zone sizing and " + "simulation continues.", + maxHumidify, + state.dataIPShortCut->cAlphaArgs(14), + minDehumidify, + state.dataIPShortCut->cAlphaArgs(13))); } } } @@ -4247,8 +4185,8 @@ void SetupZoneSizing(EnergyPlusData &state, bool &ErrorsFound) // do an end of day, end of environment time step - state.dataGlobal->HourOfDay = 24; - state.dataGlobal->TimeStep = state.dataGlobal->NumOfTimeStepInHour; + state.dataGlobal->HourOfDay = Constant::iHoursInDay; + state.dataGlobal->TimeStep = state.dataGlobal->TimeStepsInHour; state.dataGlobal->EndEnvrnFlag = true; Weather::ManageWeather(state); @@ -4564,7 +4502,7 @@ void ReportSysSizing(EnergyPlusData &state, // convert an index for the timestep of the day into a hour minute string in the format 00:00 std::string TimeIndexToHrMinString(EnergyPlusData &state, int timeIndex) { - int tMinOfDay = timeIndex * state.dataGlobal->MinutesPerTimeStep; + int tMinOfDay = timeIndex * state.dataGlobal->MinutesInTimeStep; int tHr = int(tMinOfDay / 60.); int tMin = tMinOfDay - tHr * 60; return format(PeakHrMinFmt, tHr, tMin); @@ -5281,7 +5219,7 @@ void GetAirTerminalSizing(EnergyPlusData &state) // Update the sizing for the entire facilty to gather values for reporting - Glazer January 2017 void UpdateFacilitySizing([[maybe_unused]] EnergyPlusData &state, Constant::CallIndicator const CallIndicator) { - int NumOfTimeStepInDay = state.dataGlobal->NumOfTimeStepInHour * 24; + int NumOfTimeStepInDay = state.dataGlobal->TimeStepsInHour * Constant::iHoursInDay; auto &CalcFacilitySizing = state.dataSize->CalcFacilitySizing; auto &CalcFinalFacilitySizing = state.dataSize->CalcFinalFacilitySizing; @@ -5340,7 +5278,7 @@ void UpdateFacilitySizing([[maybe_unused]] EnergyPlusData &state, Constant::Call CalcFacilitySizing(state.dataSize->CurOverallSimDay).HeatDDNum = state.dataSize->CurOverallSimDay; CalcFacilitySizing(state.dataSize->CurOverallSimDay).CoolDDNum = state.dataSize->CurOverallSimDay; } else if (CallIndicator == Constant::CallIndicator::DuringDay) { - int TimeStepInDay = (state.dataGlobal->HourOfDay - 1) * state.dataGlobal->NumOfTimeStepInHour + state.dataGlobal->TimeStep; + int TimeStepInDay = (state.dataGlobal->HourOfDay - 1) * state.dataGlobal->TimeStepsInHour + state.dataGlobal->TimeStep; // save the results of the ideal zone component calculation in the CalcZoneSizing sequence variables Real64 sumCoolLoad = 0.; Real64 sumHeatLoad = 0.; @@ -5470,7 +5408,7 @@ void UpdateTermUnitFinalZoneSizing(EnergyPlusData &state) thisTUFZSizing.DesCoolMassFlow = thisTUFZSizing.DesCoolVolFlow * thisFZSizing.DesCoolDens; thisTUFZSizing.DesCoolMassFlow = max(thisTUFZSizing.DesCoolMassFlow, minOACoolMassFlow); thisTUFZSizing.DesCoolMassFlowNoOA = thisTUFZSizing.DesCoolVolFlowNoOA * thisFZSizing.DesCoolDens; - for (int timeIndex = 1; timeIndex <= (state.dataGlobal->NumOfTimeStepInHour * 24); ++timeIndex) { + for (int timeIndex = 1; timeIndex <= (state.dataGlobal->TimeStepsInHour * Constant::iHoursInDay); ++timeIndex) { thisTUFZSizing.CoolFlowSeq(timeIndex) = thisTUSizing.applyTermUnitSizingCoolFlow(thisFZSizing.CoolFlowSeq(timeIndex), thisFZSizing.CoolFlowSeqNoOA(timeIndex)); thisTUFZSizing.CoolFlowSeq(timeIndex) = max(thisTUFZSizing.CoolFlowSeq(timeIndex), minOACoolMassFlow); @@ -5503,7 +5441,7 @@ void UpdateTermUnitFinalZoneSizing(EnergyPlusData &state) thisTUFZSizing.DesHeatMassFlow = thisTUFZSizing.DesHeatVolFlow * thisFZSizing.DesHeatDens; thisTUFZSizing.DesHeatMassFlow = max(thisTUFZSizing.DesHeatMassFlow, minOAHeatMassFlow); thisTUFZSizing.DesHeatMassFlowNoOA = thisTUFZSizing.DesHeatVolFlowNoOA * thisFZSizing.DesHeatDens; - for (int timeIndex = 1; timeIndex <= (state.dataGlobal->NumOfTimeStepInHour * 24); ++timeIndex) { + for (int timeIndex = 1; timeIndex <= (state.dataGlobal->TimeStepsInHour * Constant::iHoursInDay); ++timeIndex) { thisTUFZSizing.HeatFlowSeq(timeIndex) = thisTUSizing.applyTermUnitSizingHeatFlow(thisFZSizing.HeatFlowSeq(timeIndex), thisFZSizing.HeatFlowSeqNoOA(timeIndex)); thisTUFZSizing.HeatFlowSeq(timeIndex) = max(thisTUFZSizing.HeatFlowSeq(timeIndex), minOAHeatMassFlow); diff --git a/src/EnergyPlus/SizingManager.hh b/src/EnergyPlus/SizingManager.hh index edcd461b46d..130f82c0743 100644 --- a/src/EnergyPlus/SizingManager.hh +++ b/src/EnergyPlus/SizingManager.hh @@ -184,6 +184,10 @@ struct SizingManagerData : BaseGlobalStruct bool ReportSysSizingMyOneTimeFlag = true; bool runZeroingOnce = true; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/SolarCollectors.cc b/src/EnergyPlus/SolarCollectors.cc index 20efa9010b7..047d0bde665 100644 --- a/src/EnergyPlus/SolarCollectors.cc +++ b/src/EnergyPlus/SolarCollectors.cc @@ -974,14 +974,14 @@ namespace SolarCollectors { this->Tilt = state.dataSurface->Surface(SurfNum).Tilt; this->TiltR2V = std::abs(90.0 - Tilt); - this->CosTilt = std::cos(Tilt * Constant::DegToRadians); - this->SinTilt = std::sin(1.8 * Tilt * Constant::DegToRadians); + this->CosTilt = std::cos(Tilt * Constant::DegToRad); + this->SinTilt = std::sin(1.8 * Tilt * Constant::DegToRad); // Diffuse reflectance of the cover for solar radiation diffusely reflected back from the absober // plate to the cover. The diffuse solar radiation reflected back from the absober plate to the // cover is represented by the 60 degree equivalent incident angle. This diffuse reflectance is // used to calculate the transmittance - absorptance product (Duffie and Beckman, 1991) - Real64 Theta = 60.0 * Constant::DegToRadians; + Real64 Theta = 60.0 * Constant::DegToRad; Real64 TransSys = 0.0; Real64 RefSys = 0.0; Real64 AbsCover1 = 0.0; @@ -996,7 +996,7 @@ namespace SolarCollectors { // transmittance-absorptance product for sky diffuse radiation. Uses equivalent incident angle // of sky radiation (radians), and is calculated according to Brandemuehl and Beckman (1980): - Theta = (59.68 - 0.1388 * Tilt + 0.001497 * pow_2(Tilt)) * Constant::DegToRadians; + Theta = (59.68 - 0.1388 * Tilt + 0.001497 * pow_2(Tilt)) * Constant::DegToRad; this->CalcTransRefAbsOfCover(state, Theta, TransSys, RefSys, AbsCover1, AbsCover2); this->TauAlphaSkyDiffuse = TransSys * state.dataSolarCollectors->Parameters(ParamNum).AbsorOfAbsPlate / (1.0 - (1.0 - state.dataSolarCollectors->Parameters(ParamNum).AbsorOfAbsPlate) * this->RefDiffInnerCover); @@ -1005,7 +1005,7 @@ namespace SolarCollectors { // transmittance-absorptance product for ground diffuse radiation. Uses equivalent incident angle // of ground radiation (radians), and is calculated according to Brandemuehl and Beckman (1980): - Theta = (90.0 - 0.5788 * Tilt + 0.002693 * pow_2(Tilt)) * Constant::DegToRadians; + Theta = (90.0 - 0.5788 * Tilt + 0.002693 * pow_2(Tilt)) * Constant::DegToRad; this->CalcTransRefAbsOfCover(state, Theta, TransSys, RefSys, AbsCover1, AbsCover2); this->TauAlphaGndDiffuse = TransSys * state.dataSolarCollectors->Parameters(ParamNum).AbsorOfAbsPlate / (1.0 - (1.0 - state.dataSolarCollectors->Parameters(ParamNum).AbsorOfAbsPlate) * this->RefDiffInnerCover); @@ -1094,10 +1094,10 @@ namespace SolarCollectors { Real64 tilt = state.dataSurface->Surface(SurfNum).Tilt; // Equivalent incident angle of sky radiation (radians) - Real64 ThetaSky = (59.68 - 0.1388 * tilt + 0.001497 * pow_2(tilt)) * Constant::DegToRadians; + Real64 ThetaSky = (59.68 - 0.1388 * tilt + 0.001497 * pow_2(tilt)) * Constant::DegToRad; // Equivalent incident angle of ground radiation (radians) - Real64 ThetaGnd = (90.0 - 0.5788 * tilt + 0.002693 * pow_2(tilt)) * Constant::DegToRadians; + Real64 ThetaGnd = (90.0 - 0.5788 * tilt + 0.002693 * pow_2(tilt)) * Constant::DegToRad; incidentAngleModifier = (state.dataHeatBal->SurfQRadSWOutIncidentBeam(SurfNum) * state.dataSolarCollectors->Parameters(ParamNum).IAM(state, ThetaBeam) + @@ -1327,7 +1327,7 @@ namespace SolarCollectors { Real64 IAM; // cut off IAM for angles greater than 60 degrees. (CR 7534) - Real64 CutoffAngle = 60.0 * Constant::DegToRadians; + Real64 CutoffAngle = 60.0 * Constant::DegToRad; if (std::abs(IncidentAngle) > CutoffAngle) { // cut off, model curves not robust beyond cutoff // curves from FSEC/SRCC testing are only certified to 60 degrees, larger angles can cause numerical problems in curves IAM = 0.0; @@ -2064,7 +2064,7 @@ namespace SolarCollectors { // Grashof number Real64 GrNum = gravity * VolExpWater * DensOfWater * DensOfWater * PrOfWater * DeltaT * pow_3(Lc) / pow_2(VisOfWater); - Real64 CosTilt = std::cos(TiltR2V * Constant::DegToRadians); + Real64 CosTilt = std::cos(TiltR2V * Constant::DegToRad); Real64 RaNum; // Raleigh number Real64 NuL; // Nusselt number diff --git a/src/EnergyPlus/SolarCollectors.hh b/src/EnergyPlus/SolarCollectors.hh index 2ce8b0947e8..5e9e844e533 100644 --- a/src/EnergyPlus/SolarCollectors.hh +++ b/src/EnergyPlus/SolarCollectors.hh @@ -261,6 +261,10 @@ struct SolarCollectorsData : BaseGlobalStruct std::unordered_map UniqueParametersNames; std::unordered_map UniqueCollectorNames; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/SolarReflectionManager.cc b/src/EnergyPlus/SolarReflectionManager.cc index 8cbecf1b3c9..97343f0929a 100644 --- a/src/EnergyPlus/SolarReflectionManager.cc +++ b/src/EnergyPlus/SolarReflectionManager.cc @@ -90,7 +90,6 @@ namespace SolarReflectionManager { // Using/Aliasing using namespace DataHeatBalance; using namespace DataSurfaces; - using namespace ScheduleManager; using namespace DataEnvironment; using namespace DataVectorTypes; diff --git a/src/EnergyPlus/SolarReflectionManager.hh b/src/EnergyPlus/SolarReflectionManager.hh index b2de8fee820..73fda0e5c7b 100644 --- a/src/EnergyPlus/SolarReflectionManager.hh +++ b/src/EnergyPlus/SolarReflectionManager.hh @@ -176,6 +176,10 @@ struct SolarReflectionManagerData : BaseGlobalStruct Vector3 SurfVertToGndPt; // Vector from a vertex of possible obstructing surface to ground hit point (m) Vector3 SurfVert; // Surface vertex (m) + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/SolarShading.cc b/src/EnergyPlus/SolarShading.cc index 9aa58438b76..426064a2b39 100644 --- a/src/EnergyPlus/SolarShading.cc +++ b/src/EnergyPlus/SolarShading.cc @@ -382,7 +382,7 @@ void checkShadingSurfaceSchedules(EnergyPlusData &state) bool const anyPlugins = size(state.dataPluginManager->plugins) > 0; bool const runningByAPI = state.dataGlobal->eplusRunningViaAPI; bool const anyEMS = state.dataGlobal->AnyEnergyManagementSystemInModel; - if ((anyEMS && EMSManager::isScheduleManaged(state, thisSurface.SchedShadowSurfIndex)) || runningByAPI || anyPlugins) { + if ((anyEMS && EMSManager::isScheduleManaged(state, thisSurface.shadowSurfSched)) || runningByAPI || anyPlugins) { // Transmittance schedule definitely has an actuator or may have one via python plugin or API // Set not transparent so it won't be skipped during shading calcs thisSurface.IsTransparent = false; @@ -394,7 +394,7 @@ void checkShadingSurfaceSchedules(EnergyPlusData &state) ShowWarningError(state, format(R"(Shading Surface="{}", Transmittance Schedule Name="{}", is always transparent.)", thisSurface.Name, - state.dataScheduleMgr->Schedule(thisSurface.SchedShadowSurfIndex).Name)); + thisSurface.shadowSurfSched->Name)); ShowContinueError(state, "This shading surface will be ignored."); } } @@ -471,7 +471,7 @@ void GetShadowingInput(EnergyPlusData &state) state.dataIPShortCut->cAlphaArgs(aNum) = "Scheduled"; checkScheduledSurfacePresent(state); } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(aNum), "Imported")) { - if (state.dataScheduleMgr->ScheduleFileShadingProcessed) { + if (state.dataSched->ScheduleFileShadingProcessed) { state.dataSysVars->shadingMethod = ShadingMethod::Imported; state.dataIPShortCut->cAlphaArgs(aNum) = "Imported"; } else { @@ -738,16 +738,11 @@ void processShadowingInput(EnergyPlusData &state) } if (state.dataSysVars->shadingMethod == DataSystemVariables::ShadingMethod::Imported) { - int ExtShadingSchedNum; - for (int SurfNum = 1; SurfNum <= state.dataSurface->TotSurfaces; ++SurfNum) { - ExtShadingSchedNum = ScheduleManager::GetScheduleIndex(state, state.dataSurface->Surface(SurfNum).Name + "_shading"); - if (ExtShadingSchedNum != 0) { - state.dataSurface->Surface(SurfNum).SurfSchedExternalShadingFrac = true; - state.dataSurface->Surface(SurfNum).SurfExternalShadingSchInd = ExtShadingSchedNum; + for (auto &surf : state.dataSurface->Surface) { + if ((surf.surfExternalShadingSched = Sched::GetSchedule(state, surf.Name + "_shading")) != nullptr) { + surf.SurfSchedExternalShadingFrac = true; } else { - ShowWarningError(state, - format("processShadowingInput: sunlit fraction schedule not found for {} when using ImportedShading.", - state.dataSurface->Surface(SurfNum).Name)); + ShowWarningError(state, format("processShadowingInput: sunlit fraction schedule not found for {} when using ImportedShading.", surf.Name)); ShowContinueError(state, "These values are set to 1.0."); } } @@ -889,7 +884,7 @@ void AllocateModuleArrays(EnergyPlusData &state) state.dataSolarShading->SurfMultIsoSky.dimension(s_surf->TotSurfaces, 0.0); state.dataSolarShading->SurfMultCircumSolar.dimension(s_surf->TotSurfaces, 0.0); state.dataSolarShading->SurfMultHorizonZenith.dimension(s_surf->TotSurfaces, 0.0); - state.dataSolarShading->SurfWinRevealStatus.dimension(24, state.dataGlobal->NumOfTimeStepInHour, s_surf->TotSurfaces, 0); + state.dataSolarShading->SurfWinRevealStatus.dimension(24, state.dataGlobal->TimeStepsInHour, s_surf->TotSurfaces, 0); // Weiler-Atherton state.dataSolarShading->MAXHCArrayBounds = 2 * (s_surf->MaxVerticesPerSurface + 1); @@ -909,8 +904,8 @@ void AllocateModuleArrays(EnergyPlusData &state) state.dataSolarShading->XTEMP1.dimension(2 * (s_surf->MaxVerticesPerSurface + 1), 0.0); state.dataSolarShading->YTEMP1.dimension(2 * (s_surf->MaxVerticesPerSurface + 1), 0.0); - s_surf->SurfSunCosHourly.allocate(Constant::HoursInDay); - for (int hour = 1; hour <= Constant::HoursInDay; hour++) { + s_surf->SurfSunCosHourly.allocate(Constant::iHoursInDay); + for (int hour = 1; hour <= Constant::iHoursInDay; hour++) { s_surf->SurfSunCosHourly(hour) = 0.0; } s_surf->SurfSunlitArea.dimension(s_surf->TotSurfaces, 0.0); @@ -946,15 +941,15 @@ void AllocateModuleArrays(EnergyPlusData &state) s_surf->SurfWinInsideFrameCondensationFlag.dimension(s_surf->TotSurfaces, 0); s_surf->SurfWinInsideDividerCondensationFlag.dimension(s_surf->TotSurfaces, 0); - state.dataHeatBal->SurfSunlitFracHR.dimension(Constant::HoursInDay, s_surf->TotSurfaces, 0.0); - state.dataHeatBal->SurfSunlitFrac.dimension(Constant::HoursInDay, state.dataGlobal->NumOfTimeStepInHour, s_surf->TotSurfaces, 0.0); - state.dataHeatBal->SurfSunlitFracWithoutReveal.dimension(Constant::HoursInDay, state.dataGlobal->NumOfTimeStepInHour, s_surf->TotSurfaces, 0.0); + state.dataHeatBal->SurfSunlitFracHR.dimension(Constant::iHoursInDay, s_surf->TotSurfaces, 0.0); + state.dataHeatBal->SurfSunlitFrac.dimension(Constant::iHoursInDay, state.dataGlobal->TimeStepsInHour, s_surf->TotSurfaces, 0.0); + state.dataHeatBal->SurfSunlitFracWithoutReveal.dimension(Constant::iHoursInDay, state.dataGlobal->TimeStepsInHour, s_surf->TotSurfaces, 0.0); state.dataHeatBal->SurfWinBackSurfaces.dimension( - Constant::HoursInDay, state.dataGlobal->NumOfTimeStepInHour, state.dataBSDFWindow->MaxBkSurf, s_surf->TotSurfaces, 0); + Constant::iHoursInDay, state.dataGlobal->TimeStepsInHour, state.dataBSDFWindow->MaxBkSurf, s_surf->TotSurfaces, 0); state.dataHeatBal->SurfWinOverlapAreas.dimension( - Constant::HoursInDay, state.dataGlobal->NumOfTimeStepInHour, state.dataBSDFWindow->MaxBkSurf, s_surf->TotSurfaces, 0.0); - state.dataHeatBal->SurfCosIncAngHR.dimension(Constant::HoursInDay, s_surf->TotSurfaces, 0.0); - state.dataHeatBal->SurfCosIncAng.dimension(Constant::HoursInDay, state.dataGlobal->NumOfTimeStepInHour, s_surf->TotSurfaces, 0.0); + Constant::iHoursInDay, state.dataGlobal->TimeStepsInHour, state.dataBSDFWindow->MaxBkSurf, s_surf->TotSurfaces, 0.0); + state.dataHeatBal->SurfCosIncAngHR.dimension(Constant::iHoursInDay, s_surf->TotSurfaces, 0.0); + state.dataHeatBal->SurfCosIncAng.dimension(Constant::iHoursInDay, state.dataGlobal->TimeStepsInHour, s_surf->TotSurfaces, 0.0); state.dataHeatBal->ZoneTransSolar.dimension(state.dataViewFactor->NumOfSolarEnclosures, 0.0); state.dataHeatBal->ZoneBmSolFrExtWinsRep.dimension(state.dataViewFactor->NumOfSolarEnclosures, 0.0); @@ -2610,7 +2605,7 @@ void AnisoSkyViewFactors(EnergyPlusData &state) CosZenithAng = state.dataEnvrn->SOLCOS(3); ZenithAng = std::acos(CosZenithAng); - ZenithAngDeg = ZenithAng / Constant::DegToRadians; + ZenithAngDeg = ZenithAng / Constant::DegToRad; state.dataSolarShading->SurfAnisoSkyMult = 0.0; @@ -4769,7 +4764,6 @@ void CalcPerSolarBeam(EnergyPlusData &state, // Using/Aliasing - using ScheduleManager::LookUpScheduleValue; using WindowComplexManager::InitComplexWindows; using WindowComplexManager::UpdateComplexWindows; @@ -4809,7 +4803,7 @@ void CalcPerSolarBeam(EnergyPlusData &state, } } for (int hour = 1; hour <= 24; ++hour) { - for (int timestep = 1; timestep <= state.dataGlobal->NumOfTimeStepInHour; ++timestep) { + for (int timestep = 1; timestep <= state.dataGlobal->TimeStepsInHour; ++timestep) { for (int surfNum = firstSurf; surfNum <= lastSurf; ++surfNum) { state.dataHeatBal->SurfSunlitFrac(hour, timestep, surfNum) = 0.0; state.dataHeatBal->SurfCosIncAng(hour, timestep, surfNum) = 0.0; @@ -4818,7 +4812,7 @@ void CalcPerSolarBeam(EnergyPlusData &state, } } for (int hour = 1; hour <= 24; ++hour) { - for (int timestep = 1; timestep <= state.dataGlobal->NumOfTimeStepInHour; ++timestep) { + for (int timestep = 1; timestep <= state.dataGlobal->TimeStepsInHour; ++timestep) { for (int backSurfNum = 1; backSurfNum <= state.dataBSDFWindow->MaxBkSurf; ++backSurfNum) { for (int surfNum = firstSurf; surfNum <= lastSurf; ++surfNum) { state.dataHeatBal->SurfWinBackSurfaces(hour, timestep, backSurfNum, surfNum) = 0.0; @@ -4866,7 +4860,7 @@ void CalcPerSolarBeam(EnergyPlusData &state, if (!state.dataSysVars->DetailedSolarTimestepIntegration) { for (iHour = 1; iHour <= 24; ++iHour) { // Do for all hours - for (TS = 1; TS <= state.dataGlobal->NumOfTimeStepInHour; ++TS) { + for (TS = 1; TS <= state.dataGlobal->TimeStepsInHour; ++TS) { FigureSunCosines(state, iHour, TS, AvgEqOfTime, AvgSinSolarDeclin, AvgCosSolarDeclin); } } @@ -4877,7 +4871,7 @@ void CalcPerSolarBeam(EnergyPlusData &state, UpdateComplexWindows(state); if (!state.dataSysVars->DetailedSolarTimestepIntegration) { for (iHour = 1; iHour <= 24; ++iHour) { // Do for all hours. - for (TS = 1; TS <= state.dataGlobal->NumOfTimeStepInHour; ++TS) { + for (TS = 1; TS <= state.dataGlobal->TimeStepsInHour; ++TS) { FigureSolarBeamAtTimestep(state, iHour, TS); } // TimeStep Loop } // Hour Loop @@ -4914,7 +4908,7 @@ void FigureSunCosines(EnergyPlusData &state, auto &s_surf = state.dataSurface; - if (state.dataGlobal->NumOfTimeStepInHour != 1) { + if (state.dataGlobal->TimeStepsInHour != 1) { CurrentTime = double(iHour - 1) + double(iTimeStep) * (state.dataGlobal->TimeStepZone); } else { CurrentTime = double(iHour) + state.dataEnvrn->TS1TimeOffset; @@ -4923,7 +4917,7 @@ void FigureSunCosines(EnergyPlusData &state, // Save hourly values for use in DaylightingManager if (!state.dataSysVars->DetailedSolarTimestepIntegration) { - if (iTimeStep == state.dataGlobal->NumOfTimeStepInHour) s_surf->SurfSunCosHourly(iHour) = state.dataSolarShading->SUNCOS; + if (iTimeStep == state.dataGlobal->TimeStepsInHour) s_surf->SurfSunCosHourly(iHour) = state.dataSolarShading->SUNCOS; } else { s_surf->SurfSunCosHourly(iHour) = state.dataSolarShading->SUNCOS; } @@ -4944,7 +4938,6 @@ void FigureSolarBeamAtTimestep(EnergyPlusData &state, int const iHour, int const // This subroutine computes solar gain multipliers for beam solar using DataSystemVariables::ShadingMethod; - using ScheduleManager::LookUpScheduleValue; Real64 SurfArea; // Surface area. For walls, includes all window frame areas. Real64 Fac1WoShdg; // Intermediate calculation factor, without shading @@ -4965,7 +4958,7 @@ void FigureSolarBeamAtTimestep(EnergyPlusData &state, int const iHour, int const state.dataSolarShading->SUNCOS(2) * s_surf->Surface(SurfNum).OutNormVec(2) + state.dataSolarShading->SUNCOS(3) * s_surf->Surface(SurfNum).OutNormVec(3); if (!state.dataSysVars->DetailedSolarTimestepIntegration) { - if (iTimeStep == state.dataGlobal->NumOfTimeStepInHour) + if (iTimeStep == state.dataGlobal->TimeStepsInHour) state.dataHeatBal->SurfCosIncAngHR(iHour, SurfNum) = state.dataSolarShading->SurfSunCosTheta(SurfNum); } else { state.dataHeatBal->SurfCosIncAngHR(iHour, SurfNum) = state.dataSolarShading->SurfSunCosTheta(SurfNum); @@ -4976,9 +4969,9 @@ void FigureSolarBeamAtTimestep(EnergyPlusData &state, int const iHour, int const if ((state.dataSysVars->shadingMethod == ShadingMethod::Scheduled || state.dataSysVars->shadingMethod == ShadingMethod::Imported) && !state.dataGlobal->DoingSizing && state.dataGlobal->KindOfSim == Constant::KindOfSim::RunPeriodWeather) { for (int SurfNum = 1; SurfNum <= s_surf->TotSurfaces; ++SurfNum) { - if (s_surf->Surface(SurfNum).SurfSchedExternalShadingFrac) { - state.dataHeatBal->SurfSunlitFrac(iHour, iTimeStep, SurfNum) = - LookUpScheduleValue(state, s_surf->Surface(SurfNum).SurfExternalShadingSchInd, iHour, iTimeStep); + auto &surf = s_surf->Surface(SurfNum); + if (surf.SurfSchedExternalShadingFrac) { + state.dataHeatBal->SurfSunlitFrac(iHour, iTimeStep, SurfNum) = surf.surfExternalShadingSched->getHrTsVal(state, iHour, iTimeStep); } else { state.dataHeatBal->SurfSunlitFrac(iHour, iTimeStep, SurfNum) = 1.0; } @@ -4989,7 +4982,7 @@ void FigureSolarBeamAtTimestep(EnergyPlusData &state, int const iHour, int const if (s_surf->Surface(SurfNum).Area >= 1.e-10) { SurfArea = s_surf->Surface(SurfNum).NetAreaShadowCalc; if (!state.dataSysVars->DetailedSolarTimestepIntegration) { - if (iTimeStep == state.dataGlobal->NumOfTimeStepInHour) + if (iTimeStep == state.dataGlobal->TimeStepsInHour) state.dataHeatBal->SurfSunlitFracHR(iHour, SurfNum) = state.dataSolarShading->SurfSunlitArea(SurfNum) / SurfArea; } else { state.dataHeatBal->SurfSunlitFracHR(iHour, SurfNum) = state.dataSolarShading->SurfSunlitArea(SurfNum) / SurfArea; @@ -5881,12 +5874,6 @@ void SHDGSS(EnergyPlusData &state, // REFERENCES: // BLAST/IBLAST code, original author George Walton - // Using/Aliasing - using ScheduleManager::GetCurrentScheduleValue; - using ScheduleManager::GetScheduleMinValue; - using ScheduleManager::GetScheduleName; - using ScheduleManager::LookUpScheduleValue; - typedef Array2D::size_type size_type; int GSSNR; // General shadowing surface number int MainOverlapStatus; // Overlap status of the main overlap calculation not the check for @@ -5936,10 +5923,10 @@ void SHDGSS(EnergyPlusData &state, if (notHeatTransSurf) { if (surface.IsTransparent) continue; // No shadow if shading surface is transparent - if (surface.SchedShadowSurfIndex > 0) { - if (LookUpScheduleValue(state, surface.SchedShadowSurfIndex, iHour) == 1.0) continue; + if (surface.shadowSurfSched != nullptr) { + if (surface.shadowSurfSched->getHrTsVal(state, iHour) == 1.0) continue; if (!state.dataSolarShading->CalcSkyDifShading) { - if (LookUpScheduleValue(state, surface.SchedShadowSurfIndex, iHour, TS) == 1.0) continue; + if (surface.shadowSurfSched->getHrTsVal(state, iHour, TS) == 1.0) continue; } } } @@ -6028,9 +6015,10 @@ void SHDGSS(EnergyPlusData &state, } } HTRANS0(state, NS3, state.dataSolarShading->NumVertInShadowOrClippedSurface); - if (!state.dataSolarShading->CalcSkyDifShading) { + if (!state.dataSolarShading->CalcSkyDifShading && + surface.shadowSurfSched != nullptr) { if (iHour != 0) { - SchValue = LookUpScheduleValue(state, surface.SchedShadowSurfIndex, iHour, TS); + SchValue = surface.shadowSurfSched->getHrTsVal(state, iHour, TS); } else { SchValue = surface.SchedMinValue; } @@ -6324,7 +6312,6 @@ void CalcInteriorSolarDistribution(EnergyPlusData &state) using Dayltg::TransTDD; using General::POLYF; - using ScheduleManager::GetCurrentScheduleValue; using namespace DataWindowEquivalentLayer; Array1D CFBoverlap; // Sum of boverlap for each back surface @@ -8199,8 +8186,7 @@ void CalcInteriorSolarDistribution(EnergyPlusData &state) if (surf.SolarEnclIndex == enclosureNum) { Real64 AbsIntSurf = state.dataConstruction->Construct(surf.Construction).InsideAbsorpSolar; // SolarIntoZone = GetCurrentScheduleValue(SurfIncSolSSG(iSSG)%SchedPtr) * Surface(SurfNum)%Area - Real64 SolarIntoZone = - GetCurrentScheduleValue(state, s_surf->SurfIncSolSSG(iSSG).SchedPtr); // Solar radiation into zone to current surface + Real64 SolarIntoZone = s_surf->SurfIncSolSSG(iSSG).sched->getCurrentVal(); // Solar radiation into zone to current surface s_surf->SurfOpaqAI(SurfNum) = SolarIntoZone * AbsIntSurf; BABSZoneSSG += s_surf->SurfOpaqAI(SurfNum) * surf.Area; BTOTZoneSSG += SolarIntoZone * surf.Area; @@ -8430,7 +8416,6 @@ void CalcInteriorSolarDistributionWCESimple(EnergyPlusData &state) // gain into zone from exterior window, beam solar on exterior window transmitted as beam and/or diffuse // and interior beam from exterior window that is absorbed/transmitted by back surfaces - using ScheduleManager::GetCurrentScheduleValue; using namespace MultiLayerOptics; auto &s_surf = state.dataSurface; @@ -9249,7 +9234,7 @@ void SUN4(EnergyPlusData &state, // Compute the hour angle HrAngle = (15.0 * (12.0 - (CurrentTime + EqOfTime)) + (state.dataEnvrn->TimeZoneMeridian - state.dataEnvrn->Longitude)); - H = HrAngle * Constant::DegToRadians; + H = HrAngle * Constant::DegToRad; // Compute the cosine of the solar zenith angle. state.dataSolarShading->SUNCOS(3) = SinSolarDeclin * state.dataEnvrn->SinLatitude + CosSolarDeclin * state.dataEnvrn->CosLatitude * std::cos(H); @@ -9325,7 +9310,6 @@ void WindowShadingManager(EnergyPlusData &state) // Using/Aliasing using General::POLYF; - using ScheduleManager::GetCurrentScheduleValue; int IConst; // Construction @@ -9437,9 +9421,9 @@ void WindowShadingManager(EnergyPlusData &state) Real64 SetPoint2 = s_surf->WindowShadingControl(IShadingCtrl).SetPoint2; // Second control setpoint bool SchedAllowsControl = true; // True if control schedule is not specified or is specified and schedule value = 1 - int SchedulePtr = s_surf->WindowShadingControl(IShadingCtrl).Schedule; - if (SchedulePtr != 0) { - if (s_surf->WindowShadingControl(IShadingCtrl).ShadingControlIsScheduled && GetCurrentScheduleValue(state, SchedulePtr) <= 0.0) + auto const *sched = s_surf->WindowShadingControl(IShadingCtrl).sched; + if (sched != nullptr) { + if (s_surf->WindowShadingControl(IShadingCtrl).ShadingControlIsScheduled && sched->getCurrentVal() <= 0.0) SchedAllowsControl = false; } @@ -9845,7 +9829,7 @@ void WindowShadingManager(EnergyPlusData &state) } break; case SlatAngleControl::Scheduled: { // 'SCHEDULEDSLATANGLE' - slatAng = GetCurrentScheduleValue(state, s_surf->WindowShadingControl(IShadingCtrl).SlatAngleSchedule); + slatAng = s_surf->WindowShadingControl(IShadingCtrl).slatAngleSched->getCurrentVal(); slatAng = max(matBlind->MinSlatAngle, min(slatAng, matBlind->MaxSlatAngle)) * Constant::DegToRad; if ((slatAng <= state.dataSolarShading->ThetaSmall || slatAng >= state.dataSolarShading->ThetaBig) && @@ -10084,7 +10068,7 @@ int selectActiveWindowShadingControlIndex(EnergyPlusData &state, int curSurface) for (std::size_t listIndex = 0; listIndex < s_surf->Surface(curSurface).windowShadingControlList.size(); ++listIndex) { int wsc = s_surf->Surface(curSurface).windowShadingControlList[listIndex]; // pick the first WindowShadingControl that has a non-zero schedule value - if (ScheduleManager::GetCurrentScheduleValue(state, s_surf->WindowShadingControl(wsc).Schedule) > 0.0) { + if (s_surf->WindowShadingControl(wsc).sched->getCurrentVal() > 0.0) { return listIndex; } } @@ -10108,9 +10092,6 @@ void WindowGapAirflowControl(EnergyPlusData &state) // REFERENCES: // na - // Using/Aliasing - using ScheduleManager::GetCurrentScheduleValue; - auto &s_surf = state.dataSurface; for (int zoneNum = 1; zoneNum <= state.dataGlobal->NumOfZones; ++zoneNum) { for (int spaceNum : state.dataHeatBal->Zone(zoneNum).spaceIndexes) { @@ -10131,8 +10112,8 @@ void WindowGapAirflowControl(EnergyPlusData &state) } break; case WindowAirFlowControlType::Schedule: { if (s_surf->SurfWinAirflowHasSchedule(ISurf)) { - int SchedulePtr = s_surf->SurfWinAirflowSchedulePtr(ISurf); // Schedule pointer - Real64 ScheduleMult = GetCurrentScheduleValue(state, SchedulePtr); // Multiplier value from schedule + auto const *sched = s_surf->SurfWinAirflowScheds(ISurf); + Real64 ScheduleMult = sched->getCurrentVal(); // Multiplier value from schedule if (ScheduleMult < 0.0 || ScheduleMult > 1.0) { ShowFatalError( state, @@ -10232,9 +10213,9 @@ void SkyDifSolarShading(EnergyPlusData &state) state.dataSolarShading->SurfDifShdgRatioHoriz = 1.0; if (detailedShading) { state.dataSolarShading->SurfCurDifShdgRatioIsoSky.dimension(s_surf->TotSurfaces, 1.0); - state.dataSolarShading->SurfDifShdgRatioIsoSkyHRTS.allocate(state.dataGlobal->NumOfTimeStepInHour, 24, s_surf->TotSurfaces); + state.dataSolarShading->SurfDifShdgRatioIsoSkyHRTS.allocate(state.dataGlobal->TimeStepsInHour, 24, s_surf->TotSurfaces); state.dataSolarShading->SurfDifShdgRatioIsoSkyHRTS = 1.0; - state.dataSolarShading->SurfDifShdgRatioHorizHRTS.allocate(state.dataGlobal->NumOfTimeStepInHour, 24, s_surf->TotSurfaces); + state.dataSolarShading->SurfDifShdgRatioHorizHRTS.allocate(state.dataGlobal->TimeStepsInHour, 24, s_surf->TotSurfaces); state.dataSolarShading->SurfDifShdgRatioHorizHRTS = 1.0; } @@ -10374,9 +10355,9 @@ void SkyDifSolarShading(EnergyPlusData &state) if (state.dataSysVars->DetailedSkyDiffuseAlgorithm && s_surf->ShadingTransmittanceVaries && state.dataHeatBal->SolarDistribution != DataHeatBalance::Shadowing::Minimal) { for (int SurfNum = 1; SurfNum <= s_surf->TotSurfaces; ++SurfNum) { - state.dataSolarShading->SurfDifShdgRatioIsoSkyHRTS({1, state.dataGlobal->NumOfTimeStepInHour}, {1, 24}, SurfNum) = + state.dataSolarShading->SurfDifShdgRatioIsoSkyHRTS({1, state.dataGlobal->TimeStepsInHour}, {1, 24}, SurfNum) = state.dataSolarShading->SurfDifShdgRatioIsoSky(SurfNum); - state.dataSolarShading->SurfDifShdgRatioHorizHRTS({1, state.dataGlobal->NumOfTimeStepInHour}, {1, 24}, SurfNum) = + state.dataSolarShading->SurfDifShdgRatioHorizHRTS({1, state.dataGlobal->TimeStepsInHour}, {1, 24}, SurfNum) = state.dataSolarShading->SurfDifShdgRatioHoriz(SurfNum); } } @@ -10440,8 +10421,8 @@ void CalcWindowProfileAngles(EnergyPlusData &state) s_surf->SurfWinProfileAngVert(SurfNum) = 0.0; if (state.dataHeatBal->SurfCosIncAng(state.dataGlobal->HourOfDay, state.dataGlobal->TimeStep, SurfNum) <= 0.0) continue; - ElevWin = Constant::PiOvr2 - surf.Tilt * Constant::DegToRadians; - AzimWin = surf.Azimuth * Constant::DegToRadians; + ElevWin = Constant::PiOvr2 - surf.Tilt * Constant::DegToRad; + AzimWin = surf.Azimuth * Constant::DegToRad; ProfileAngHor = std::atan(sin_ElevSun / std::abs(cos_ElevSun * std::cos(AzimWin - AzimSun))) - ElevWin; @@ -10472,8 +10453,8 @@ void CalcWindowProfileAngles(EnergyPlusData &state) // Constrain to 0 to pi if (ProfileAngVert > Constant::Pi) ProfileAngVert = Constant::TwoPi - ProfileAngVert; - s_surf->SurfWinProfileAngHor(SurfNum) = ProfileAngHor / Constant::DegToRadians; - s_surf->SurfWinProfileAngVert(SurfNum) = ProfileAngVert / Constant::DegToRadians; + s_surf->SurfWinProfileAngHor(SurfNum) = ProfileAngHor / Constant::DegToRad; + s_surf->SurfWinProfileAngVert(SurfNum) = ProfileAngVert / Constant::DegToRad; s_surf->SurfWinTanProfileAngHor(SurfNum) = std::abs(std::tan(ProfileAngHor)); s_surf->SurfWinTanProfileAngVert(SurfNum) = std::abs(std::tan(ProfileAngVert)); } @@ -10582,9 +10563,9 @@ void CalcFrameDividerShadow(EnergyPlusData &state, auto &surf = s_surf->Surface(SurfNum); GlArea = surf.Area; - ElevWin = Constant::PiOvr2 - surf.Tilt * Constant::DegToRadians; + ElevWin = Constant::PiOvr2 - surf.Tilt * Constant::DegToRad; ElevSun = Constant::PiOvr2 - std::acos(state.dataSolarShading->SUNCOS(3)); - AzimWin = surf.Azimuth * Constant::DegToRadians; + AzimWin = surf.Azimuth * Constant::DegToRad; AzimSun = std::atan2(state.dataSolarShading->SUNCOS(1), state.dataSolarShading->SUNCOS(2)); ProfileAngHor = std::atan(std::sin(ElevSun) / std::abs(std::cos(ElevSun) * std::cos(AzimWin - AzimSun))) - ElevWin; @@ -11534,7 +11515,6 @@ void CalcWinTransDifSolInitialDistribution(EnergyPlusData &state) // determined here using revised code from SUBROUTINE InitIntSolarDistribution // Using/Aliasing - using ScheduleManager::GetCurrentScheduleValue; using namespace DataViewFactorInformation; using namespace DataWindowEquivalentLayer; @@ -12093,7 +12073,6 @@ void CalcInteriorWinTransDifSolInitialDistribution(EnergyPlusData &state, // determined here using revised code from SUBROUTINE InitIntSolarDistribution // Using/Aliasing - using ScheduleManager::GetCurrentScheduleValue; using namespace DataViewFactorInformation; // SUBROUTINE LOCAL VARIABLE DECLARATIONS: diff --git a/src/EnergyPlus/SolarShading.hh b/src/EnergyPlus/SolarShading.hh index 31878be083d..37376a971d0 100644 --- a/src/EnergyPlus/SolarShading.hh +++ b/src/EnergyPlus/SolarShading.hh @@ -511,6 +511,10 @@ struct SolarShadingData : BaseGlobalStruct std::vector cos_Theta; std::unique_ptr shd_stream; // Shading file stream + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/SplitterComponent.hh b/src/EnergyPlus/SplitterComponent.hh index 67473ee3827..077dc9683a4 100644 --- a/src/EnergyPlus/SplitterComponent.hh +++ b/src/EnergyPlus/SplitterComponent.hh @@ -135,6 +135,10 @@ struct SplitterComponentData : BaseGlobalStruct Array1D SplitterCond; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/StandardRatings.cc b/src/EnergyPlus/StandardRatings.cc index 62bf237ce76..c5239d33bd7 100644 --- a/src/EnergyPlus/StandardRatings.cc +++ b/src/EnergyPlus/StandardRatings.cc @@ -4157,7 +4157,7 @@ namespace StandardRatings { Real64 cop_low = q_low / p_low; Real64 cop_int = q_int / p_int; - Real64 cop_full = q_full / p_full; + Real64 cop_full = q_full / p_full; // About half of the variables in this function are unused // Low Speed Real64 cop_int_bin = cop_low + (cop_int - cop_low) / (q_int - q_low) * (bl - q_low); // Equation 11.101 (AHRI-2023) q = bl * n; // 11.92 --> n is missing in the print ? diff --git a/src/EnergyPlus/SteamBaseboardRadiator.cc b/src/EnergyPlus/SteamBaseboardRadiator.cc index aa6203b7481..5c3dd9ca124 100644 --- a/src/EnergyPlus/SteamBaseboardRadiator.cc +++ b/src/EnergyPlus/SteamBaseboardRadiator.cc @@ -128,7 +128,6 @@ namespace SteamBaseboardRadiator { // This subroutine simulates the steam baseboards or radiators. using PlantUtilities::SetComponentFlowRate; - using ScheduleManager::GetCurrentScheduleValue; // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int BaseboardNum; // index of unit in baseboard array @@ -180,7 +179,7 @@ namespace SteamBaseboardRadiator { .DesignObjectPtr)}; // Array that contains the design data for steam baseboard objects if (QZnReq > SmallLoad && !state.dataZoneEnergyDemand->CurDeadBandOrSetback(ControlledZoneNum) && - (GetCurrentScheduleValue(state, state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SchedPtr) > 0.0)) { + (state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).sched->getCurrentVal() > 0.0)) { // On the first HVAC iteration the system values are given to the controller, but after that // the demand limits are in place and there needs to be feedback to the Zone Equipment @@ -265,13 +264,13 @@ namespace SteamBaseboardRadiator { // REFERENCES: // HWBaseboardRadiator module + static constexpr std::string_view routineName = "GetSteamBaseboardInput"; + // Using/Aliasing using BranchNodeConnections::TestCompSet; using GlobalNames::VerifyUniqueBaseboardName; using NodeInputManager::GetOnlySingleNode; - using ScheduleManager::GetCurrentScheduleValue; - using ScheduleManager::GetScheduleIndex; using namespace DataSizing; // SUBROUTINE PARAMETER DEFINITIONS: @@ -333,6 +332,7 @@ namespace SteamBaseboardRadiator { state.dataIPShortCut->lAlphaFieldBlanks, state.dataIPShortCut->cAlphaFieldNames, state.dataIPShortCut->cNumericFieldNames); + Util::IsNameEmpty( state, state.dataIPShortCut->cAlphaArgs(1), state.dataSteamBaseboardRadiator->cCMO_BBRadiator_Steam_Design, ErrorsFound); state.dataSteamBaseboardRadiator->SteamBaseboardDesignNumericFields(BaseboardDesignNum).FieldNames.allocate(NumNumbers); @@ -517,6 +517,9 @@ namespace SteamBaseboardRadiator { state.dataIPShortCut->lAlphaFieldBlanks, state.dataIPShortCut->cAlphaFieldNames, state.dataIPShortCut->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, state.dataSteamBaseboardRadiator->cCMO_BBRadiator_Steam, state.dataIPShortCut->cAlphaArgs(1)}; + Util::IsNameEmpty(state, state.dataIPShortCut->cAlphaArgs(1), state.dataSteamBaseboardRadiator->cCMO_BBRadiator_Steam, ErrorsFound); state.dataSteamBaseboardRadiator->SteamBaseboardNumericFields(BaseboardNum).FieldNames.allocate(NumNumbers); state.dataSteamBaseboardRadiator->SteamBaseboardNumericFields(BaseboardNum).FieldNames = ""; @@ -543,22 +546,11 @@ namespace SteamBaseboardRadiator { .DesignObjectPtr)}; // Contains the design data for steam baseboard object // Get schedule - state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).Schedule = state.dataIPShortCut->cAlphaArgs(3); if (state.dataIPShortCut->lAlphaFieldBlanks(3)) { - state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SchedPtr = - GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(3)); - if (state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SchedPtr == 0) { - ShowSevereError(state, - format("{}{}=\"{}\", {}=\"{}\" not found.", - RoutineName, - state.dataSteamBaseboardRadiator->cCMO_BBRadiator_Steam, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaFieldNames(3), - state.dataIPShortCut->cAlphaArgs(3))); - ErrorsFound = true; - } + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).sched = Sched::GetScheduleAlwaysOn(state); + } else if ((state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).sched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(3))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(3), state.dataIPShortCut->cAlphaArgs(3)); + ErrorsFound = true; } // Get inlet node number @@ -1298,7 +1290,6 @@ namespace SteamBaseboardRadiator { using FluidProperties::GetSatEnthalpyRefrig; using FluidProperties::GetSatSpecificHeatRefrig; using HVAC::SmallLoad; - using ScheduleManager::GetCurrentScheduleValue; // Locals // SUBROUTINE ARGUMENT DEFINITIONS: @@ -1337,7 +1328,7 @@ namespace SteamBaseboardRadiator { SubcoolDeltaT = state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).DegOfSubcooling; if (QZnReq > SmallLoad && !state.dataZoneEnergyDemand->CurDeadBandOrSetback(ZoneNum) && SteamMassFlowRate > 0.0 && - GetCurrentScheduleValue(state, state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SchedPtr) > 0) { + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).sched->getCurrentVal() > 0) { // Unit is on EnthSteamInDry = GetSatEnthalpyRefrig( state, fluidNameSteam, SteamInletTemp, 1.0, state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).FluidIndex, RoutineName); @@ -1579,13 +1570,13 @@ namespace SteamBaseboardRadiator { // RE-ENGINEERED na state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).TotEnergy = - state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).TotPower * state.dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).TotPower * state.dataHVACGlobal->TimeStepSysSec; state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).Energy = state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).Power * state.dataHVACGlobal->TimeStepSysSec; state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).ConvEnergy = - state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).ConvPower * state.dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).ConvPower * state.dataHVACGlobal->TimeStepSysSec; state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).RadEnergy = - state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).RadPower * state.dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).RadPower * state.dataHVACGlobal->TimeStepSysSec; } void diff --git a/src/EnergyPlus/SteamBaseboardRadiator.hh b/src/EnergyPlus/SteamBaseboardRadiator.hh index 4610a904df8..4735b377f39 100644 --- a/src/EnergyPlus/SteamBaseboardRadiator.hh +++ b/src/EnergyPlus/SteamBaseboardRadiator.hh @@ -70,11 +70,10 @@ namespace SteamBaseboardRadiator { DataPlant::PlantEquipmentType EquipType; std::string designObjectName; // Design Object int DesignObjectPtr; - std::string Schedule; Array1D_string SurfaceName; Array1D_int SurfacePtr; int ZonePtr; - int SchedPtr; // Pointer to the correct schedule + Sched::Schedule *sched = nullptr; // availability? int SteamInletNode; // Inlet steam baseboard node int SteamOutletNode; // Outlet steam baseboard node int TotSurfToDistrib; // Total numbers of the surfaces that the radiant heat gets distributed @@ -124,7 +123,7 @@ namespace SteamBaseboardRadiator { // Default Constructor SteamBaseboardParams() - : EquipType(DataPlant::PlantEquipmentType::Invalid), DesignObjectPtr(0), ZonePtr(0), SchedPtr(0), SteamInletNode(0), SteamOutletNode(0), + : EquipType(DataPlant::PlantEquipmentType::Invalid), DesignObjectPtr(0), ZonePtr(0), SteamInletNode(0), SteamOutletNode(0), TotSurfToDistrib(0), FluidIndex(0), ControlCompTypeNum(0), CompErrIndex(0), DegOfSubcooling(0.0), SteamMassFlowRate(0.0), SteamMassFlowRateMax(0.0), SteamVolFlowRateMax(0.0), SteamOutletTemp(0.0), SteamInletTemp(0.0), SteamInletEnthalpy(0.0), SteamOutletEnthalpy(0.0), SteamInletPress(0.0), SteamOutletPress(0.0), SteamInletQuality(0.0), SteamOutletQuality(0.0), @@ -236,6 +235,10 @@ struct SteamBaseboardRadiatorData : BaseGlobalStruct Array1D SteamBaseboardDesignNumericFields; Array1D_string SteamBaseboardDesignNames; // Array that contains the names of Design objects + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/SteamCoils.cc b/src/EnergyPlus/SteamCoils.cc index 7362e912db3..3467cbf4fcb 100644 --- a/src/EnergyPlus/SteamCoils.cc +++ b/src/EnergyPlus/SteamCoils.cc @@ -99,7 +99,6 @@ namespace SteamCoils { using PlantUtilities::MyPlantSizingIndex; using PlantUtilities::ScanPlantLoopsForObject; - using namespace ScheduleManager; static constexpr std::string_view fluidNameSteam("STEAM"); constexpr std::array(CoilControlType::Num)> coilControlTypeNames = {"TEMPERATURESETPOINTCONTROL", @@ -219,6 +218,7 @@ namespace SteamCoils { // SUBROUTINE PARAMETER DEFINITIONS: static constexpr std::string_view RoutineName("GetSteamCoilInput: "); // include trailing blank space + static constexpr std::string_view routineName = "GetSteamCoilInput"; // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int CoilNum; // The SteamCoil that you are currently loading input into @@ -271,22 +271,20 @@ namespace SteamCoils { lAlphaBlanks, cAlphaFields, cNumericFields); + + ErrorObjectHeader eoh{routineName, CurrentModuleObject, AlphArray(1)}; Util::IsNameEmpty(state, AlphArray(1), CurrentModuleObject, ErrorsFound); // ErrorsFound will be set to True if problem was found, left untouched otherwise VerifyUniqueCoilName(state, CurrentModuleObject, AlphArray(1), ErrorsFound, CurrentModuleObject + " Name"); state.dataSteamCoils->SteamCoil(CoilNum).Name = AlphArray(1); - state.dataSteamCoils->SteamCoil(CoilNum).Schedule = AlphArray(2); + if (lAlphaBlanks(2)) { - state.dataSteamCoils->SteamCoil(CoilNum).SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - state.dataSteamCoils->SteamCoil(CoilNum).SchedPtr = GetScheduleIndex(state, AlphArray(2)); - if (state.dataSteamCoils->SteamCoil(CoilNum).SchedPtr == 0) { - ShowSevereError(state, format("{}{}=\"{}\", invalid data.", RoutineName, CurrentModuleObject, AlphArray(1))); - ShowContinueError(state, format("{} not found={}", cAlphaFields(2), AlphArray(2))); - ErrorsFound = true; - } + state.dataSteamCoils->SteamCoil(CoilNum).availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((state.dataSteamCoils->SteamCoil(CoilNum).availSched = Sched::GetSchedule(state, AlphArray(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(2), AlphArray(2)); + ErrorsFound = true; } state.dataSteamCoils->SteamCoil(CoilNum).SteamCoilTypeA = "Heating"; @@ -1108,7 +1106,7 @@ namespace SteamCoils { case CoilControlType::ZoneLoadControl: if ((CapacitanceAir > 0.0) && ((state.dataSteamCoils->SteamCoil(CoilNum).InletSteamMassFlowRate) > 0.0) && - (GetCurrentScheduleValue(state, state.dataSteamCoils->SteamCoil(CoilNum).SchedPtr) > 0.0 || + (state.dataSteamCoils->SteamCoil(CoilNum).availSched->getCurrentVal() > 0.0 || state.dataSteamCoils->MySizeFlag(CoilNum)) && (QCoilReq > 0.0)) { @@ -1223,7 +1221,7 @@ namespace SteamCoils { case CoilControlType::TemperatureSetPoint: // Control coil output to meet a Setpoint Temperature. if ((CapacitanceAir > 0.0) && ((state.dataSteamCoils->SteamCoil(CoilNum).InletSteamMassFlowRate) > 0.0) && - (GetCurrentScheduleValue(state, state.dataSteamCoils->SteamCoil(CoilNum).SchedPtr) > 0.0 || + (state.dataSteamCoils->SteamCoil(CoilNum).availSched->getCurrentVal() > 0.0 || state.dataSteamCoils->MySizeFlag(CoilNum)) && (std::abs(TempSetPoint - TempAirIn) > TempControlTol)) { @@ -1607,7 +1605,7 @@ namespace SteamCoils { ShowFatalError(state, format("CheckSteamCoilSchedule: Coil not found={}", CompName)); } CompIndex = CoilNum; - Value = GetCurrentScheduleValue(state, state.dataSteamCoils->SteamCoil(CoilNum).SchedPtr); // not scheduled? + Value = state.dataSteamCoils->SteamCoil(CoilNum).availSched->getCurrentVal(); // not scheduled? } else { CoilNum = CompIndex; if (CoilNum > state.dataSteamCoils->NumSteamCoils || CoilNum < 1) { @@ -1624,7 +1622,7 @@ namespace SteamCoils { CompName, state.dataSteamCoils->SteamCoil(CoilNum).Name)); } - Value = GetCurrentScheduleValue(state, state.dataSteamCoils->SteamCoil(CoilNum).SchedPtr); // not scheduled? + Value = state.dataSteamCoils->SteamCoil(CoilNum).availSched->getCurrentVal(); // not scheduled? } } @@ -2183,7 +2181,7 @@ namespace SteamCoils { if (Util::SameString(CoilType, "Coil:Heating:Steam")) { WhichCoil = Util::FindItem(CoilName, state.dataSteamCoils->SteamCoil); if (WhichCoil != 0) { - AvailSchIndex = state.dataSteamCoils->SteamCoil(WhichCoil).SchedPtr; + AvailSchIndex = state.dataSteamCoils->SteamCoil(WhichCoil).availSched->Num; } } else { WhichCoil = 0; diff --git a/src/EnergyPlus/SteamCoils.hh b/src/EnergyPlus/SteamCoils.hh index 4eeb18c25af..f566b2d72eb 100644 --- a/src/EnergyPlus/SteamCoils.hh +++ b/src/EnergyPlus/SteamCoils.hh @@ -80,8 +80,7 @@ namespace SteamCoils { std::string SteamCoilTypeA; // Type of SteamCoil ie. Heating or Cooling int SteamCoilType; // Type of SteamCoil ie. Heating or Cooling int SteamCoilModel; // Type of SteamCoil ie. Simple, Detailed, etc. - std::string Schedule; // SteamCoil Operation Schedule - int SchedPtr; // Pointer to the correct schedule + Sched::Schedule *availSched = nullptr; // operating schedule Real64 InletAirMassFlowRate; // MassFlow through the SteamCoil being Simulated [kg/s] Real64 OutletAirMassFlowRate; // MassFlow throught the SteamCoil being Simulated[kg/s] Real64 InletAirTemp; // Inlet Air Temperature Operating Condition [C] @@ -136,7 +135,7 @@ namespace SteamCoils { // Default Constructor SteamCoilEquipConditions() - : SteamCoilType(0), SteamCoilModel(0), SchedPtr(0), InletAirMassFlowRate(0.0), OutletAirMassFlowRate(0.0), InletAirTemp(0.0), + : SteamCoilType(0), SteamCoilModel(0), InletAirMassFlowRate(0.0), OutletAirMassFlowRate(0.0), InletAirTemp(0.0), OutletAirTemp(0.0), InletAirHumRat(0.0), OutletAirHumRat(0.0), InletAirEnthalpy(0.0), OutletAirEnthalpy(0.0), TotSteamCoilLoad(0.0), SenSteamCoilLoad(0.0), TotSteamHeatingCoilEnergy(0.0), TotSteamCoolingCoilEnergy(0.0), SenSteamCoolingCoilEnergy(0.0), TotSteamHeatingCoilRate(0.0), LoopLoss(0.0), TotSteamCoolingCoilRate(0.0), SenSteamCoolingCoilRate(0.0), LeavingRelHum(0.0), @@ -258,10 +257,10 @@ namespace SteamCoils { bool &ErrorFlag // set to true if problem ); - int GetSteamCoilAvailScheduleIndex(EnergyPlusData &state, - std::string const &CoilType, // must match coil types in this module - std::string const &CoilName, // must match coil names for the coil type - bool &ErrorsFound // set to true if problem + Sched::Schedule *GetSteamCoilAvailSchedule(EnergyPlusData &state, + std::string const &CoilType, // must match coil types in this module + std::string const &CoilName, // must match coil names for the coil type + bool &ErrorsFound // set to true if problem ); // sets data to a coil that is used as a regeneration air heating coil in @@ -289,6 +288,10 @@ struct SteamCoilsData : BaseGlobalStruct int ErrCount = 0; Array1D SteamCoil; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/SurfaceGeometry.cc b/src/EnergyPlus/SurfaceGeometry.cc index df57e759261..375c86fca48 100644 --- a/src/EnergyPlus/SurfaceGeometry.cc +++ b/src/EnergyPlus/SurfaceGeometry.cc @@ -231,7 +231,7 @@ namespace SurfaceGeometry { state.dataSurface->SurfWinMaxAirflow.dimension(NumSurfaces, 0); state.dataSurface->SurfWinAirflowControlType.dimension(NumSurfaces, DataSurfaces::WindowAirFlowControlType::Invalid); state.dataSurface->SurfWinAirflowHasSchedule.dimension(NumSurfaces, 0); - state.dataSurface->SurfWinAirflowSchedulePtr.dimension(NumSurfaces, 0); + state.dataSurface->SurfWinAirflowScheds.dimension(NumSurfaces, nullptr); state.dataSurface->SurfWinAirflowThisTS.dimension(NumSurfaces, 0); state.dataSurface->SurfWinTAirflowGapOutlet.dimension(NumSurfaces, 0); state.dataSurface->SurfWinWindowCalcIterationsRep.dimension(NumSurfaces, 0); @@ -278,21 +278,21 @@ namespace SurfaceGeometry { // these include building north axis and Building Rotation for Appendix G state.dataSurfaceGeometry->CosBldgRelNorth = - std::cos(-(state.dataHeatBal->BuildingAzimuth + state.dataHeatBal->BuildingRotationAppendixG) * Constant::DegToRadians); + std::cos(-(state.dataHeatBal->BuildingAzimuth + state.dataHeatBal->BuildingRotationAppendixG) * Constant::DegToRad); state.dataSurfaceGeometry->SinBldgRelNorth = - std::sin(-(state.dataHeatBal->BuildingAzimuth + state.dataHeatBal->BuildingRotationAppendixG) * Constant::DegToRadians); + std::sin(-(state.dataHeatBal->BuildingAzimuth + state.dataHeatBal->BuildingRotationAppendixG) * Constant::DegToRad); // these are only for Building Rotation for Appendix G when using world coordinate system - state.dataSurfaceGeometry->CosBldgRotAppGonly = std::cos(-state.dataHeatBal->BuildingRotationAppendixG * Constant::DegToRadians); - state.dataSurfaceGeometry->SinBldgRotAppGonly = std::sin(-state.dataHeatBal->BuildingRotationAppendixG * Constant::DegToRadians); + state.dataSurfaceGeometry->CosBldgRotAppGonly = std::cos(-state.dataHeatBal->BuildingRotationAppendixG * Constant::DegToRad); + state.dataSurfaceGeometry->SinBldgRotAppGonly = std::sin(-state.dataHeatBal->BuildingRotationAppendixG * Constant::DegToRad); state.dataSurfaceGeometry->CosZoneRelNorth.allocate(state.dataGlobal->NumOfZones); state.dataSurfaceGeometry->SinZoneRelNorth.allocate(state.dataGlobal->NumOfZones); for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) { - state.dataSurfaceGeometry->CosZoneRelNorth(ZoneNum) = std::cos(-state.dataHeatBal->Zone(ZoneNum).RelNorth * Constant::DegToRadians); - state.dataSurfaceGeometry->SinZoneRelNorth(ZoneNum) = std::sin(-state.dataHeatBal->Zone(ZoneNum).RelNorth * Constant::DegToRadians); + state.dataSurfaceGeometry->CosZoneRelNorth(ZoneNum) = std::cos(-state.dataHeatBal->Zone(ZoneNum).RelNorth * Constant::DegToRad); + state.dataSurfaceGeometry->SinZoneRelNorth(ZoneNum) = std::sin(-state.dataHeatBal->Zone(ZoneNum).RelNorth * Constant::DegToRad); } GetSurfaceData(state, ErrorsFound); @@ -894,8 +894,8 @@ namespace SurfaceGeometry { state.dataSurface->SurfShadowGlazingConstruct.allocate(state.dataSurface->TotSurfaces); state.dataSurface->SurfMaterialMovInsulExt.allocate(state.dataSurface->TotSurfaces); state.dataSurface->SurfMaterialMovInsulInt.allocate(state.dataSurface->TotSurfaces); - state.dataSurface->SurfSchedMovInsulExt.allocate(state.dataSurface->TotSurfaces); - state.dataSurface->SurfSchedMovInsulInt.allocate(state.dataSurface->TotSurfaces); + state.dataSurface->SurfMovInsulExtScheds.allocate(state.dataSurface->TotSurfaces); + state.dataSurface->SurfMovInsulIntScheds.allocate(state.dataSurface->TotSurfaces); for (int SurfNum = 1; SurfNum <= state.dataSurface->TotSurfaces; ++SurfNum) { state.dataSurface->SurfShadowRecSurfNum(SurfNum) = 0; state.dataSurface->SurfShadowDiffuseSolRefl(SurfNum) = 0.0; @@ -904,8 +904,8 @@ namespace SurfaceGeometry { state.dataSurface->SurfShadowGlazingConstruct(SurfNum) = 0; state.dataSurface->SurfMaterialMovInsulExt(SurfNum) = 0; state.dataSurface->SurfMaterialMovInsulInt(SurfNum) = 0; - state.dataSurface->SurfSchedMovInsulExt(SurfNum) = 0; - state.dataSurface->SurfSchedMovInsulInt(SurfNum) = 0; + state.dataSurface->SurfMovInsulExtScheds(SurfNum) = nullptr; + state.dataSurface->SurfMovInsulIntScheds(SurfNum) = nullptr; } state.dataSurface->SurfExtEcoRoof.allocate(state.dataSurface->TotSurfaces); state.dataSurface->SurfExtCavityPresent.allocate(state.dataSurface->TotSurfaces); @@ -1037,8 +1037,6 @@ namespace SurfaceGeometry { // Surface%Vertex(1:) using namespace Vectors; - using ScheduleManager::GetScheduleMaxValue; - using ScheduleManager::GetScheduleMinValue; using namespace DataErrorTracking; static constexpr std::string_view RoutineName("GetSurfaceData: "); @@ -1282,26 +1280,26 @@ namespace SurfaceGeometry { // Debug write(outputfiledebug,*) ' need to add ',NeedtoAddSurfaces+NeedToAddSubSurfaces if (NeedToAddSurfaces + NeedToAddSubSurfaces > 0) CurNewSurf = FirstTotalSurfaces; for (int SurfNum = 1; SurfNum <= FirstTotalSurfaces; ++SurfNum) { - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond != UnenteredAdjacentZoneSurface) continue; + auto &surfTemp = state.dataSurfaceGeometry->SurfaceTmp(SurfNum); + if (surfTemp.ExtBoundCond != UnenteredAdjacentZoneSurface) continue; // Need to add surface ++CurNewSurf; // Debug write(outputfiledebug,*) ' adding surface=',curnewsurf state.dataSurfaceGeometry->SurfaceTmp(CurNewSurf) = state.dataSurfaceGeometry->SurfaceTmp(SurfNum); // Basic parameters are the same for both surfaces. - Found = Util::FindItemInList( - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCondName, state.dataHeatBal->Zone, state.dataGlobal->NumOfZones); + Found = Util::FindItemInList(surfTemp.ExtBoundCondName, state.dataHeatBal->Zone, state.dataGlobal->NumOfZones); if (Found == 0) continue; state.dataSurfaceGeometry->SurfaceTmp(CurNewSurf).Zone = Found; state.dataSurfaceGeometry->SurfaceTmp(CurNewSurf).ZoneName = state.dataHeatBal->Zone(Found).Name; // Reverse Construction state.dataSurfaceGeometry->SurfaceTmp(CurNewSurf).Construction = - AssignReverseConstructionNumber(state, state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction, SurfError); + AssignReverseConstructionNumber(state, surfTemp.Construction, SurfError); state.dataSurfaceGeometry->SurfaceTmp(CurNewSurf).ConstructionStoredInputValue = state.dataSurfaceGeometry->SurfaceTmp(CurNewSurf).Construction; // Reverse Vertices - NVert = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides; - for (Vert = 1; Vert <= state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides; ++Vert) { - state.dataSurfaceGeometry->SurfaceTmp(CurNewSurf).Vertex(Vert) = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(NVert); + NVert = surfTemp.Sides; + for (Vert = 1; Vert <= surfTemp.Sides; ++Vert) { + state.dataSurfaceGeometry->SurfaceTmp(CurNewSurf).Vertex(Vert) = surfTemp.Vertex(NVert); --NVert; } if (state.dataSurfaceGeometry->SurfaceTmp(CurNewSurf).Sides > 2) { @@ -1328,10 +1326,10 @@ namespace SurfaceGeometry { Convect::GetSurfConvOrientation(state.dataSurfaceGeometry->SurfaceTmp(CurNewSurf).Tilt); // Sine and cosine of azimuth and tilt - state.dataSurfaceGeometry->SurfaceTmp(CurNewSurf).SinAzim = std::sin(SurfWorldAz * Constant::DegToRadians); - state.dataSurfaceGeometry->SurfaceTmp(CurNewSurf).CosAzim = std::cos(SurfWorldAz * Constant::DegToRadians); - state.dataSurfaceGeometry->SurfaceTmp(CurNewSurf).SinTilt = std::sin(SurfTilt * Constant::DegToRadians); - state.dataSurfaceGeometry->SurfaceTmp(CurNewSurf).CosTilt = std::cos(SurfTilt * Constant::DegToRadians); + state.dataSurfaceGeometry->SurfaceTmp(CurNewSurf).SinAzim = std::sin(SurfWorldAz * Constant::DegToRad); + state.dataSurfaceGeometry->SurfaceTmp(CurNewSurf).CosAzim = std::cos(SurfWorldAz * Constant::DegToRad); + state.dataSurfaceGeometry->SurfaceTmp(CurNewSurf).SinTilt = std::sin(SurfTilt * Constant::DegToRad); + state.dataSurfaceGeometry->SurfaceTmp(CurNewSurf).CosTilt = std::cos(SurfTilt * Constant::DegToRad); // Outward normal unit vector (pointing away from room) state.dataSurfaceGeometry->SurfaceTmp(CurNewSurf).OutNormVec = state.dataSurfaceGeometry->SurfaceTmp(CurNewSurf).NewellSurfaceNormalVector; @@ -1358,21 +1356,21 @@ namespace SurfaceGeometry { } // Change Name - state.dataSurfaceGeometry->SurfaceTmp(CurNewSurf).Name = "iz-" + state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name; + state.dataSurfaceGeometry->SurfaceTmp(CurNewSurf).Name = "iz-" + surfTemp.Name; // Debug write(outputfiledebug,*) ' new surf name=',TRIM(SurfaceTmp(CurNewSurf)%Name) // Debug write(outputfiledebug,*) ' new surf in zone=',TRIM(surfacetmp(curnewsurf)%zoneName) state.dataSurfaceGeometry->SurfaceTmp(CurNewSurf).ExtBoundCond = UnreconciledZoneSurface; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond = UnreconciledZoneSurface; - state.dataSurfaceGeometry->SurfaceTmp(CurNewSurf).ExtBoundCondName = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCondName = state.dataSurfaceGeometry->SurfaceTmp(CurNewSurf).Name; + surfTemp.ExtBoundCond = UnreconciledZoneSurface; + state.dataSurfaceGeometry->SurfaceTmp(CurNewSurf).ExtBoundCondName = surfTemp.Name; + surfTemp.ExtBoundCondName = state.dataSurfaceGeometry->SurfaceTmp(CurNewSurf).Name; if (state.dataSurfaceGeometry->SurfaceTmp(CurNewSurf).Class == SurfaceClass::Roof || state.dataSurfaceGeometry->SurfaceTmp(CurNewSurf).Class == SurfaceClass::Wall || state.dataSurfaceGeometry->SurfaceTmp(CurNewSurf).Class == SurfaceClass::Floor) { // base surface - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class == SurfaceClass::Roof) { + if (surfTemp.Class == SurfaceClass::Roof) { state.dataSurfaceGeometry->SurfaceTmp(CurNewSurf).Class = SurfaceClass::Floor; // Debug write(outputfiledebug,*) ' new surfaces is a floor' - } else if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class == SurfaceClass::Floor) { + } else if (surfTemp.Class == SurfaceClass::Floor) { state.dataSurfaceGeometry->SurfaceTmp(CurNewSurf).Class = SurfaceClass::Roof; // Debug write(outputfiledebug,*) ' new surfaces is a roof' } @@ -1381,12 +1379,11 @@ namespace SurfaceGeometry { // Debug write(outputfiledebug,*) ' basesurf, extboundcondname=',TRIM(SurfaceTmp(CurNewSurf)%ExtBoundCondName) } else { // subsurface - Found = Util::FindItemInList("iz-" + state.dataSurfaceGeometry->SurfaceTmp(SurfNum).BaseSurfName, + Found = Util::FindItemInList("iz-" + surfTemp.BaseSurfName, state.dataSurfaceGeometry->SurfaceTmp, FirstTotalSurfaces + CurNewSurf - 1); if (Found > 0) { - state.dataSurfaceGeometry->SurfaceTmp(CurNewSurf).BaseSurfName = - "iz-" + state.dataSurfaceGeometry->SurfaceTmp(SurfNum).BaseSurfName; + state.dataSurfaceGeometry->SurfaceTmp(CurNewSurf).BaseSurfName = "iz-" + surfTemp.BaseSurfName; state.dataSurfaceGeometry->SurfaceTmp(CurNewSurf).BaseSurf = Found; state.dataSurfaceGeometry->SurfaceTmp(Found).Area -= state.dataSurfaceGeometry->SurfaceTmp(CurNewSurf).Area; if (state.dataSurfaceGeometry->SurfaceTmp(CurNewSurf).Class == SurfaceClass::Window || @@ -1397,7 +1394,7 @@ namespace SurfaceGeometry { state.dataSurfaceGeometry->SurfaceTmp(Found).NetAreaShadowCalc -= state.dataSurfaceGeometry->SurfaceTmp(CurNewSurf).Area; } state.dataSurfaceGeometry->SurfaceTmp(CurNewSurf).ExtBoundCond = state.dataSurfaceGeometry->SurfaceTmp(Found).ExtBoundCond; - state.dataSurfaceGeometry->SurfaceTmp(CurNewSurf).ExtBoundCondName = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name; + state.dataSurfaceGeometry->SurfaceTmp(CurNewSurf).ExtBoundCondName = surfTemp.Name; state.dataSurfaceGeometry->SurfaceTmp(CurNewSurf).ExtSolar = state.dataSurfaceGeometry->SurfaceTmp(Found).ExtSolar; state.dataSurfaceGeometry->SurfaceTmp(CurNewSurf).ExtWind = state.dataSurfaceGeometry->SurfaceTmp(Found).ExtWind; state.dataSurfaceGeometry->SurfaceTmp(CurNewSurf).Zone = state.dataSurfaceGeometry->SurfaceTmp(Found).Zone; @@ -1406,10 +1403,7 @@ namespace SurfaceGeometry { // Debug write(outputfiledebug,*) ' subsurf, extboundcondname=',TRIM(SurfaceTmp(CurNewSurf)%ExtBoundCondName) // Debug write(outputfiledebug,*) ' subsurf, basesurf=',TRIM('iz-'//SurfaceTmp(SurfNum)%BaseSurfName) } else { - ShowSevereError(state, - format("{}Adding unentered subsurface, could not find base surface=iz-{}", - RoutineName, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).BaseSurfName)); + ShowSevereError(state, format("{}Adding unentered subsurface, could not find base surface=iz-{}", RoutineName, surfTemp.BaseSurfName)); SurfError = true; } } @@ -1419,34 +1413,33 @@ namespace SurfaceGeometry { // sub-surfaces can be defined. Loop through surfaces and match with the sub-surface // names. for (int SurfNum = 1; SurfNum <= state.dataSurface->TotSurfaces; ++SurfNum) { - if (!state.dataSurfaceGeometry->SurfaceTmp(SurfNum).HeatTransSurf) continue; + auto &surfTemp = state.dataSurfaceGeometry->SurfaceTmp(SurfNum); + if (!surfTemp.HeatTransSurf) continue; // why are we doing this again? this should have already been done. - if (Util::SameString(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).BaseSurfName, state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name)) { + if (Util::SameString(surfTemp.BaseSurfName, surfTemp.Name)) { Found = SurfNum; } else { - Found = Util::FindItemInList(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).BaseSurfName, - state.dataSurfaceGeometry->SurfaceTmp, - state.dataSurface->TotSurfaces); + Found = Util::FindItemInList(surfTemp.BaseSurfName, state.dataSurfaceGeometry->SurfaceTmp, state.dataSurface->TotSurfaces); } if (Found > 0) { - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).BaseSurf = Found; + surfTemp.BaseSurf = Found; if (SurfNum != Found) { // for subsurfaces - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).HeatTransSurf) ++state.dataSurfaceGeometry->SurfaceTmp(Found).NumSubSurfaces; - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class < SurfaceClass::Window || - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class > SurfaceClass::TDD_Diffuser) { - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class == SurfaceClass::None) { + if (surfTemp.HeatTransSurf) ++state.dataSurfaceGeometry->SurfaceTmp(Found).NumSubSurfaces; + if (surfTemp.Class < SurfaceClass::Window || + surfTemp.Class > SurfaceClass::TDD_Diffuser) { + if (surfTemp.Class == SurfaceClass::None) { ShowSevereError(state, format("{}Invalid SubSurface detected, Surface={}", RoutineName, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name)); + surfTemp.Name)); } else { ShowSevereError( state, format("{}Invalid SubSurface detected, Surface={}, class={} invalid class for subsurface", RoutineName, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, - state.dataSurfaceGeometry->BaseSurfCls(int(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class)))); + surfTemp.Name, + state.dataSurfaceGeometry->BaseSurfCls(int(surfTemp.Class)))); SurfError = true; } } @@ -1501,9 +1494,8 @@ namespace SurfaceGeometry { // Move all shading Surfaces to Front for (int SurfNum = 1; SurfNum <= state.dataSurface->TotSurfaces; ++SurfNum) { - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class != SurfaceClass::Detached_F && - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class != SurfaceClass::Detached_B && - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class != SurfaceClass::Shading) + auto &surfTemp = state.dataSurfaceGeometry->SurfaceTmp(SurfNum); + if (surfTemp.Class != SurfaceClass::Detached_F && surfTemp.Class != SurfaceClass::Detached_B && surfTemp.Class != SurfaceClass::Shading) continue; // A shading surface @@ -1521,20 +1513,21 @@ namespace SurfaceGeometry { for (int spaceNum : state.dataHeatBal->Zone(ZoneNum).spaceIndexes) { // Group air boundary surfaces first within each space for (int SurfNum = 1; SurfNum <= state.dataSurface->TotSurfaces; ++SurfNum) { + auto &surfTemp = state.dataSurfaceGeometry->SurfaceTmp(SurfNum); if (SurfaceTmpClassMoved(SurfNum)) continue; - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).spaceNum != spaceNum) continue; - int constNum = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction; + if (surfTemp.spaceNum != spaceNum) continue; + int constNum = surfTemp.Construction; if (constNum == 0) continue; if (!state.dataConstruction->Construct(constNum).TypeIsAirBoundary) continue; // An air boundary surface - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).IsAirBoundarySurf = true; + surfTemp.IsAirBoundarySurf = true; ++MovedSurfs; state.dataSurface->Surface(MovedSurfs) = state.dataSurfaceGeometry->SurfaceTmp(SurfNum); // If base Surface Type (Wall, Floor, Roof/Ceiling) - if ((state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class == state.dataSurfaceGeometry->BaseSurfIDs(1)) || - (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class == state.dataSurfaceGeometry->BaseSurfIDs(2)) || - (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class == state.dataSurfaceGeometry->BaseSurfIDs(3))) { + if ((surfTemp.Class == state.dataSurfaceGeometry->BaseSurfIDs(1)) || + (surfTemp.Class == state.dataSurfaceGeometry->BaseSurfIDs(2)) || + (surfTemp.Class == state.dataSurfaceGeometry->BaseSurfIDs(3))) { // Store list of moved surface numbers in reporting order. We use the old position, we'll reconcile later // We don't do it for Air Door/Air Windows yet, we want them listed below each base surf they belong to state.dataSurface->AllSurfaceListReportOrder.push_back(SurfNum); @@ -1548,12 +1541,13 @@ namespace SurfaceGeometry { for (const DataSurfaces::SurfaceClass Loop : state.dataSurfaceGeometry->BaseSurfIDs) { for (int SurfNum = 1; SurfNum <= state.dataSurface->TotSurfaces; ++SurfNum) { + auto &surfTemp = state.dataSurfaceGeometry->SurfaceTmp(SurfNum); if (SurfaceTmpClassMoved(SurfNum)) continue; - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Zone == 0) continue; + if (surfTemp.Zone == 0) continue; - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).spaceNum != spaceNum) continue; - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class != Loop) continue; + if (surfTemp.spaceNum != spaceNum) continue; + if (surfTemp.Class != Loop) continue; ++MovedSurfs; state.dataSurface->Surface(MovedSurfs) = state.dataSurfaceGeometry->SurfaceTmp(SurfNum); @@ -1577,10 +1571,11 @@ namespace SurfaceGeometry { // Internal mass goes next for (int SurfNum = 1; SurfNum <= state.dataSurface->TotSurfaces; ++SurfNum) { - if (SurfaceTmpClassMoved(SurfNum)) continue; - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).spaceNum != spaceNum) continue; - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class != SurfaceClass::IntMass) continue; + + auto &surfTemp = state.dataSurfaceGeometry->SurfaceTmp(SurfNum); + if (surfTemp.spaceNum != spaceNum) continue; + if (surfTemp.Class != SurfaceClass::IntMass) continue; ++MovedSurfs; state.dataSurface->Surface(MovedSurfs) = state.dataSurfaceGeometry->SurfaceTmp(SurfNum); oldToNewSurfNums(SurfNum) = MovedSurfs; @@ -3265,12 +3260,7 @@ namespace SurfaceGeometry { // This subroutine gets the Detached Shading Surface Data, // checks it for errors, etc. - // Using/Aliasing - using ScheduleManager::CheckScheduleValueMinMax; - using ScheduleManager::GetScheduleIndex; - using ScheduleManager::GetScheduleMaxValue; - using ScheduleManager::GetScheduleMinValue; - + static constexpr std::string_view routineName = "GetDetShdSurfaceData"; // SUBROUTINE PARAMETER DEFINITIONS: static Array1D_string const cModuleObjects(2, {"Shading:Site:Detailed", "Shading:Building:Detailed"}); @@ -3327,6 +3317,8 @@ namespace SurfaceGeometry { s_ipsc->cAlphaFieldNames, s_ipsc->cNumericFieldNames); + ErrorObjectHeader eoh{routineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)}; + if (GlobalNames::VerifyUniqueInterObjectName(state, state.dataSurfaceGeometry->UniqueSurfaceNames, s_ipsc->cAlphaArgs(1), @@ -3337,48 +3329,34 @@ namespace SurfaceGeometry { } ++SurfNum; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name = s_ipsc->cAlphaArgs(1); // Set the Surface Name in the Derived Type - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class = ClassItem; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).HeatTransSurf = false; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtSolar = true; + + auto &surfTemp = state.dataSurfaceGeometry->SurfaceTmp(SurfNum); + surfTemp.Name = s_ipsc->cAlphaArgs(1); // Set the Surface Name in the Derived Type + surfTemp.Class = ClassItem; + surfTemp.HeatTransSurf = false; + surfTemp.ExtSolar = true; // Base transmittance of a shadowing (sub)surface - if (!s_ipsc->lAlphaFieldBlanks(2)) { - // Schedule for a shadowing (sub)surface - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).SchedShadowSurfIndex = GetScheduleIndex(state, s_ipsc->cAlphaArgs(2)); - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).SchedShadowSurfIndex == 0) { - ShowSevereError(state, - format("{}=\"{}\", {} not found={}", - s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, - s_ipsc->cAlphaFieldNames(2), - s_ipsc->cAlphaArgs(2))); - ErrorsFound = true; - } + if (s_ipsc->lAlphaFieldBlanks(2)) { + surfTemp.shadowSurfSched = Sched::GetScheduleAlwaysOff(state); + } else if ((surfTemp.shadowSurfSched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2)); + ErrorsFound = true; + } else if (!surfTemp.shadowSurfSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) { + Sched::ShowSevereBadMinMax(state, eoh, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2), Clusive::In, 0.0, Clusive::In, 1.0); + ErrorsFound = true; } else { - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).SchedShadowSurfIndex = 0; - } - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).SchedShadowSurfIndex != 0) { - if (!CheckScheduleValueMinMax(state, state.dataSurfaceGeometry->SurfaceTmp(SurfNum).SchedShadowSurfIndex, ">=", 0.0, "<=", 1.0)) { - ShowSevereError(state, - format("{}=\"{}\", {}=\"{}\", values not in range [0,1].", - s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, - s_ipsc->cAlphaFieldNames(2), - s_ipsc->cAlphaArgs(2))); - ErrorsFound = true; - } - SchedMinValue = GetScheduleMinValue(state, state.dataSurfaceGeometry->SurfaceTmp(SurfNum).SchedShadowSurfIndex); - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).SchedMinValue = SchedMinValue; - SchedMaxValue = GetScheduleMaxValue(state, state.dataSurfaceGeometry->SurfaceTmp(SurfNum).SchedShadowSurfIndex); + SchedMinValue = surfTemp.shadowSurfSched->getMinVal(state); + surfTemp.SchedMinValue = SchedMinValue; + SchedMaxValue = surfTemp.shadowSurfSched->getCurrentVal(); if (SchedMinValue == 1.0) { // Set transparent for now, check for EMS actuators later in SolarShading::resetShadingSurfaceTransparency - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).IsTransparent = true; + surfTemp.IsTransparent = true; } if (SchedMinValue < 0.0) { ShowSevereError(state, format("{}=\"{}\", {}=\"{}\", has schedule values < 0.", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2))); ShowContinueError(state, "...Schedule values < 0 have no meaning for shading elements."); @@ -3390,7 +3368,7 @@ namespace SurfaceGeometry { ShowSevereError(state, format("{}=\"{}\", {}=\"{}\", has schedule values > 1.", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2))); ShowContinueError(state, "...Schedule values > 1 have no meaning for shading elements."); @@ -3401,43 +3379,43 @@ namespace SurfaceGeometry { } if (s_ipsc->lNumericFieldBlanks(1) || s_ipsc->rNumericArgs(1) == Constant::AutoCalculate) { numSides = (NumNumbers - 1) / 3; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides = numSides; + surfTemp.Sides = numSides; if (mod(NumNumbers - 1, 3) != 0) { ShowWarningError(state, format("{}=\"{}\", {}", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, format("{} not even multiple of 3. Will read in {}", s_ipsc->cNumericFieldNames(1), - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides))); + surfTemp.Sides))); } if (numSides < 3) { ShowSevereError(state, format("{}=\"{}\", {} (autocalculate) must be >= 3. Only {} provided.", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, s_ipsc->cNumericFieldNames(1), - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides)); + surfTemp.Sides)); ErrorsFound = true; continue; } } else { numSides = (NumNumbers - 1) / 3; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides = s_ipsc->rNumericArgs(1); - if (numSides > state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides) { + surfTemp.Sides = s_ipsc->rNumericArgs(1); + if (numSides > surfTemp.Sides) { ShowWarningError(state, format("{}=\"{}\", field {}={}", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, s_ipsc->cNumericFieldNames(1), - fmt::to_string(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides))); + fmt::to_string(surfTemp.Sides))); ShowContinueError( state, format("...but {} were entered. Only the indicated {} will be used.", numSides, s_ipsc->cNumericFieldNames(1))); } } - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex.allocate(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides); - GetVertices(state, SurfNum, state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides, s_ipsc->rNumericArgs({2, _})); - CheckConvexity(state, SurfNum, state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides); + surfTemp.Vertex.allocate(surfTemp.Sides); + GetVertices(state, SurfNum, surfTemp.Sides, s_ipsc->rNumericArgs({2, _})); + CheckConvexity(state, SurfNum, surfTemp.Sides); if (state.dataReportFlag->MakeMirroredDetachedShading) { MakeMirrorSurface(state, SurfNum); } @@ -3527,24 +3505,26 @@ namespace SurfaceGeometry { } ++SurfNum; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name = s_ipsc->cAlphaArgs(1); // Set the Surface Name in the Derived Type - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class = ClassItem; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).HeatTransSurf = false; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtSolar = true; + + auto &surfTemp = state.dataSurfaceGeometry->SurfaceTmp(SurfNum); + surfTemp.Name = s_ipsc->cAlphaArgs(1); // Set the Surface Name in the Derived Type + surfTemp.Class = ClassItem; + surfTemp.HeatTransSurf = false; + surfTemp.ExtSolar = true; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Azimuth = s_ipsc->rNumericArgs(1); - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class == SurfaceClass::Detached_B && !state.dataSurface->WorldCoordSystem) { - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Azimuth += state.dataHeatBal->BuildingAzimuth; + surfTemp.Azimuth = s_ipsc->rNumericArgs(1); + if (surfTemp.Class == SurfaceClass::Detached_B && !state.dataSurface->WorldCoordSystem) { + surfTemp.Azimuth += state.dataHeatBal->BuildingAzimuth; } - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class == SurfaceClass::Detached_B) { - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Azimuth += state.dataHeatBal->BuildingRotationAppendixG; + if (surfTemp.Class == SurfaceClass::Detached_B) { + surfTemp.Azimuth += state.dataHeatBal->BuildingRotationAppendixG; } - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Tilt = s_ipsc->rNumericArgs(2); - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).convOrientation = - Convect::GetSurfConvOrientation(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Tilt); + surfTemp.Tilt = s_ipsc->rNumericArgs(2); + surfTemp.convOrientation = + Convect::GetSurfConvOrientation(surfTemp.Tilt); - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides = 4; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex.allocate(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides); + surfTemp.Sides = 4; + surfTemp.Vertex.allocate(surfTemp.Sides); MakeRectangularVertices(state, SurfNum, @@ -3555,12 +3535,12 @@ namespace SurfaceGeometry { s_ipsc->rNumericArgs(7), state.dataSurfaceGeometry->RectSurfRefWorldCoordSystem); - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Area <= 0.0) { + if (surfTemp.Area <= 0.0) { ShowSevereError(state, format("{}=\"{}\", Surface Area <= 0.0; Entered Area={:.2T}", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Area)); + surfTemp.Name, + surfTemp.Area)); ErrorsFound = true; } @@ -3783,7 +3763,9 @@ namespace SurfaceGeometry { } ++SurfNum; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name = s_ipsc->cAlphaArgs(1); // Set the Surface Name in the Derived Type + + auto &surfTemp = state.dataSurfaceGeometry->SurfaceTmp(SurfNum); + surfTemp.Name = s_ipsc->cAlphaArgs(1); // Set the Surface Name in the Derived Type ArgPointer = 2; if (Item == 1) { if (s_ipsc->cAlphaArgs(2) == "CEILING") s_ipsc->cAlphaArgs(2) = "ROOF"; @@ -3792,35 +3774,35 @@ namespace SurfaceGeometry { ShowSevereError(state, format("{}=\"{}\", invalid {}=\"{}", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2))); ErrorsFound = true; } else { - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class = BaseSurfIDs(ClassItem); + surfTemp.Class = BaseSurfIDs(ClassItem); } ++ArgPointer; } else { - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class = BaseSurfIDs(ClassItem); + surfTemp.Class = BaseSurfIDs(ClassItem); } - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction = + surfTemp.Construction = Util::FindItemInList(s_ipsc->cAlphaArgs(ArgPointer), state.dataConstruction->Construct, state.dataHeatBal->TotConstructs); - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction == 0) { + if (surfTemp.Construction == 0) { ErrorsFound = true; ShowSevereError(state, format("{}=\"{}\", invalid {}=\"{}\".", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, s_ipsc->cAlphaFieldNames(ArgPointer), s_ipsc->cAlphaArgs(ArgPointer))); - } else if (state.dataConstruction->Construct(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction).TypeIsWindow) { + } else if (state.dataConstruction->Construct(surfTemp.Construction).TypeIsWindow) { ErrorsFound = true; ShowSevereError(state, format("{}=\"{}\", invalid {}=\"{}\" - has Window materials.", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, s_ipsc->cAlphaFieldNames(ArgPointer), s_ipsc->cAlphaArgs(ArgPointer))); if (Item == 1) { @@ -3829,30 +3811,30 @@ namespace SurfaceGeometry { ShowContinueError(state, format("...because Surface Type={}", BaseSurfCls(ClassItem))); } } else { - state.dataConstruction->Construct(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction).IsUsed = true; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ConstructionStoredInputValue = - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction; + state.dataConstruction->Construct(surfTemp.Construction).IsUsed = true; + surfTemp.ConstructionStoredInputValue = + surfTemp.Construction; } - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).HeatTransSurf = true; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).BaseSurf = SurfNum; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).BaseSurfName = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name; + surfTemp.HeatTransSurf = true; + surfTemp.BaseSurf = SurfNum; + surfTemp.BaseSurfName = surfTemp.Name; ++ArgPointer; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ZoneName = s_ipsc->cAlphaArgs(ArgPointer); + surfTemp.ZoneName = s_ipsc->cAlphaArgs(ArgPointer); ZoneNum = Util::FindItemInList( - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ZoneName, state.dataHeatBal->Zone, state.dataGlobal->NumOfZones); + surfTemp.ZoneName, state.dataHeatBal->Zone, state.dataGlobal->NumOfZones); if (ZoneNum != 0) { - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Zone = ZoneNum; + surfTemp.Zone = ZoneNum; } else { ShowSevereError(state, format("{}=\"{}\", invalid {}=\"{}\".", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, s_ipsc->cAlphaFieldNames(ArgPointer), s_ipsc->cAlphaArgs(ArgPointer))); - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class = SurfaceClass::Invalid; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ZoneName = "Unknown Zone"; + surfTemp.Class = SurfaceClass::Invalid; + surfTemp.ZoneName = "Unknown Zone"; ErrorsFound = true; } @@ -3861,25 +3843,25 @@ namespace SurfaceGeometry { int spaceNum = Util::FindItemInList(s_ipsc->cAlphaArgs(ArgPointer), state.dataHeatBal->space); if (spaceNum != 0) { - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).spaceNum = spaceNum; - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Zone != state.dataHeatBal->space(spaceNum).zoneNum) { + surfTemp.spaceNum = spaceNum; + if (surfTemp.Zone != state.dataHeatBal->space(spaceNum).zoneNum) { ShowSevereError(state, format("{}=\"{}\", invalid {}=\"{}\" is not in the same zone as the surface.", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, s_ipsc->cAlphaFieldNames(ArgPointer), s_ipsc->cAlphaArgs(ArgPointer))); - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class = SurfaceClass::Invalid; + surfTemp.Class = SurfaceClass::Invalid; ErrorsFound = true; } } else { ShowSevereError(state, format("{}=\"{}\", invalid {}=\"{}\" not found.", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, s_ipsc->cAlphaFieldNames(ArgPointer), s_ipsc->cAlphaArgs(ArgPointer))); - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class = SurfaceClass::Invalid; + surfTemp.Class = SurfaceClass::Invalid; ErrorsFound = true; } } @@ -3887,17 +3869,17 @@ namespace SurfaceGeometry { // can take place. The conditions are set with a 0, -1, or -2, or all of the // zone names have to be looked at and generate the interzone array number ++ArgPointer; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCondName = s_ipsc->cAlphaArgs(ArgPointer + 1); + surfTemp.ExtBoundCondName = s_ipsc->cAlphaArgs(ArgPointer + 1); if (Util::SameString(s_ipsc->cAlphaArgs(ArgPointer), "Outdoors")) { - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond = ExternalEnvironment; + surfTemp.ExtBoundCond = ExternalEnvironment; } else if (Util::SameString(s_ipsc->cAlphaArgs(ArgPointer), "Adiabatic")) { - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond = UnreconciledZoneSurface; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCondName = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name; + surfTemp.ExtBoundCond = UnreconciledZoneSurface; + surfTemp.ExtBoundCondName = surfTemp.Name; } else if (Util::SameString(s_ipsc->cAlphaArgs(ArgPointer), "Ground")) { - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond = Ground; + surfTemp.ExtBoundCond = Ground; if (state.dataSurfaceGeometry->NoGroundTempObjWarning) { if (!state.dataEnvrn->GroundTempInputs[(int)DataEnvironment::GroundTempType::BuildingSurface]) { @@ -3913,7 +3895,7 @@ namespace SurfaceGeometry { // Added for FCfactor method } else if (Util::SameString(s_ipsc->cAlphaArgs(ArgPointer), "GroundFCfactorMethod")) { - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond = GroundFCfactorMethod; + surfTemp.ExtBoundCond = GroundFCfactorMethod; if (state.dataSurfaceGeometry->NoFCGroundTempObjWarning) { if (!state.dataEnvrn->GroundTempInputs[(int)DataEnvironment::GroundTempType::FCFactorMethod]) { ShowSevereError(state, @@ -3927,53 +3909,53 @@ namespace SurfaceGeometry { state.dataSurfaceGeometry->NoFCGroundTempObjWarning = false; } } - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction > 0) { - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class == SurfaceClass::Wall && - !state.dataConstruction->Construct(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction).TypeIsCfactorWall) { + if (surfTemp.Construction > 0) { + if (surfTemp.Class == SurfaceClass::Wall && + !state.dataConstruction->Construct(surfTemp.Construction).TypeIsCfactorWall) { ShowSevereError(state, format("{}=\"{}\", invalid {}", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, s_ipsc->cAlphaFieldNames(ArgPointer))); ShowContinueError( state, format("Construction=\"{}\" is not type Construction:CfactorUndergroundWall.", - state.dataConstruction->Construct(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction).Name)); + state.dataConstruction->Construct(surfTemp.Construction).Name)); ErrorsFound = true; } - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class == SurfaceClass::Floor && - !state.dataConstruction->Construct(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction).TypeIsFfactorFloor) { + if (surfTemp.Class == SurfaceClass::Floor && + !state.dataConstruction->Construct(surfTemp.Construction).TypeIsFfactorFloor) { ShowSevereError(state, format("{}=\"{}\", invalid {}", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, s_ipsc->cAlphaFieldNames(ArgPointer))); ShowContinueError( state, format("Construction=\"{}\" is not type Construction:FfactorGroundFloor.", - state.dataConstruction->Construct(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction).Name)); + state.dataConstruction->Construct(surfTemp.Construction).Name)); ErrorsFound = true; } } } else if (Util::SameString(s_ipsc->cAlphaArgs(ArgPointer), "OtherSideCoefficients")) { Found = Util::FindItemInList( - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCondName, state.dataSurface->OSC, state.dataSurface->TotOSC); + surfTemp.ExtBoundCondName, state.dataSurface->OSC, state.dataSurface->TotOSC); if (Found == 0) { ShowSevereError(state, format("{}=\"{}\", invalid {}=\"{}\".", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, s_ipsc->cAlphaFieldNames(ArgPointer + 1), s_ipsc->cAlphaArgs(ArgPointer + 1))); ShowContinueError(state, " no OtherSideCoefficients of that name."); ErrorsFound = true; } else { - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).OSCPtr = Found; + surfTemp.OSCPtr = Found; if (state.dataSurface->OSC(Found).SurfFilmCoef > 0.0) { - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond = OtherSideCoefCalcExt; + surfTemp.ExtBoundCond = OtherSideCoefCalcExt; } else { - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond = OtherSideCoefNoCalcExt; + surfTemp.ExtBoundCond = OtherSideCoefNoCalcExt; } } @@ -3982,13 +3964,13 @@ namespace SurfaceGeometry { // this will be found on the second pass through the surface input // for flagging, set the value to UnreconciledZoneSurface // name (ExtBoundCondName) will be validated later. - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond = UnreconciledZoneSurface; + surfTemp.ExtBoundCond = UnreconciledZoneSurface; if (s_ipsc->lAlphaFieldBlanks(ArgPointer + 1)) { - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCondName = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name; + surfTemp.ExtBoundCondName = surfTemp.Name; ShowSevereError(state, format("{}=\"{}\", invalid {}=.", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, s_ipsc->cAlphaFieldNames(ArgPointer + 1))); ShowContinueError(state, format("..{}=\"Surface\" must be non-blank.", s_ipsc->cAlphaFieldNames(ArgPointer))); ShowContinueError(state, "..This surface will become an adiabatic surface - no doors/windows allowed."); @@ -3997,17 +3979,17 @@ namespace SurfaceGeometry { } else if (Util::SameString(s_ipsc->cAlphaArgs(ArgPointer), "Zone")) { // This is the code for an unmatched "other surface" // will be set up later. - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond = UnenteredAdjacentZoneSurface; + surfTemp.ExtBoundCond = UnenteredAdjacentZoneSurface; // check OutsideFaceEnvironment for legal zone Found = Util::FindItemInList( - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCondName, state.dataHeatBal->Zone, state.dataGlobal->NumOfZones); + surfTemp.ExtBoundCondName, state.dataHeatBal->Zone, state.dataGlobal->NumOfZones); ++NeedToAddSurfaces; if (Found == 0) { ShowSevereError(state, format("{}=\"{}\", invalid {}=\"{}\".", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, s_ipsc->cAlphaFieldNames(ArgPointer), s_ipsc->cAlphaArgs(ArgPointer))); ShowContinueError(state, "..Referenced as Zone for this surface."); @@ -4021,7 +4003,7 @@ namespace SurfaceGeometry { state, format("{}=\"{}\", using \"Foundation\" type Outside Boundary Condition requires specification of a weather file", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name)); + surfTemp.Name)); ShowContinueError(state, "Either place in.epw in the working directory or specify a weather file on the command line using -w " "/path/to/weather.epw"); @@ -4035,47 +4017,47 @@ namespace SurfaceGeometry { // Add default foundation if no other foundation object specified state.dataSurfaceGeometry->kivaManager.addDefaultFoundation(); } - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).OSCPtr = + surfTemp.OSCPtr = state.dataSurfaceGeometry->kivaManager.defaultIndex; // Reuse OSC pointer...shouldn't be used for non OSC surfaces anyway. } else { Found = - state.dataSurfaceGeometry->kivaManager.findFoundation(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCondName); + state.dataSurfaceGeometry->kivaManager.findFoundation(surfTemp.ExtBoundCondName); if (Found != (int)state.dataSurfaceGeometry->kivaManager.foundationInputs.size()) { - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).OSCPtr = Found; + surfTemp.OSCPtr = Found; } else { ShowSevereError(state, format("{}=\"{}\", invalid {}=\"{}\".", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, s_ipsc->cAlphaFieldNames(ArgPointer + 1), s_ipsc->cAlphaArgs(ArgPointer + 1))); ErrorsFound = true; } } - if (state.dataConstruction->Construct(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction).SourceSinkPresent) { + if (state.dataConstruction->Construct(surfTemp.Construction).SourceSinkPresent) { ShowSevereError(state, format("{}=\"{}\", construction may not have an internal source/sink", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name)); + surfTemp.Name)); ErrorsFound = true; } - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond = KivaFoundation; + surfTemp.ExtBoundCond = KivaFoundation; } else if (Util::SameString(s_ipsc->cAlphaArgs(ArgPointer), "OtherSideConditionsModel")) { Found = Util::FindItemInList( - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCondName, state.dataSurface->OSCM, state.dataSurface->TotOSCM); + surfTemp.ExtBoundCondName, state.dataSurface->OSCM, state.dataSurface->TotOSCM); if (Found == 0) { ShowSevereError(state, format("{}=\"{}\", invalid {}=\"{}\".", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, s_ipsc->cAlphaFieldNames(ArgPointer + 1), s_ipsc->cAlphaArgs(ArgPointer + 1))); ErrorsFound = true; } - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).OSCMPtr = Found; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond = OtherSideCondModeledExt; + surfTemp.OSCMPtr = Found; + surfTemp.ExtBoundCond = OtherSideCondModeledExt; } else if (Util::SameString(s_ipsc->cAlphaArgs(ArgPointer), "GroundSlabPreprocessorAverage") || Util::SameString(s_ipsc->cAlphaArgs(ArgPointer), "GroundSlabPreprocessorCore") || @@ -4087,7 +4069,7 @@ namespace SurfaceGeometry { ShowSevereError(state, format("{}=\"{}\", invalid {}=\"{}\".", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, s_ipsc->cAlphaFieldNames(ArgPointer), s_ipsc->cAlphaArgs(ArgPointer))); ShowContinueError(state, "The ExpandObjects program has not been run or is not in your EnergyPlus.exe folder."); @@ -4097,7 +4079,7 @@ namespace SurfaceGeometry { ShowSevereError(state, format("{}=\"{}\", invalid {}=\"{}\".", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, s_ipsc->cAlphaFieldNames(ArgPointer), s_ipsc->cAlphaArgs(ArgPointer))); ShowContinueError(state, @@ -4109,25 +4091,25 @@ namespace SurfaceGeometry { ArgPointer += 2; // Set the logical flag for the exterior solar if (Util::SameString(s_ipsc->cAlphaArgs(ArgPointer), "SunExposed")) { - if ((state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond != ExternalEnvironment) && - (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond != OtherSideCondModeledExt)) { + if ((surfTemp.ExtBoundCond != ExternalEnvironment) && + (surfTemp.ExtBoundCond != OtherSideCondModeledExt)) { ShowWarningError(state, format("{}=\"{}\", {}=\"{}\".", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, s_ipsc->cAlphaFieldNames(ArgPointer), s_ipsc->cAlphaArgs(ArgPointer))); ShowContinueError(state, "..This surface is not exposed to External Environment. Sun exposure has no effect."); } else { - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtSolar = true; + surfTemp.ExtSolar = true; } } else if (Util::SameString(s_ipsc->cAlphaArgs(ArgPointer), "NoSun")) { - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtSolar = false; + surfTemp.ExtSolar = false; } else { ShowSevereError(state, format("{}=\"{}\", invalid {}=\"{}\".", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, s_ipsc->cAlphaFieldNames(ArgPointer), s_ipsc->cAlphaArgs(ArgPointer))); ErrorsFound = true; @@ -4136,127 +4118,129 @@ namespace SurfaceGeometry { ++ArgPointer; // Set the logical flag for the exterior wind if (Util::SameString(s_ipsc->cAlphaArgs(ArgPointer), "WindExposed")) { - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtWind = true; + surfTemp.ExtWind = true; } else if (Util::SameString(s_ipsc->cAlphaArgs(ArgPointer), "NoWind")) { - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtWind = false; + surfTemp.ExtWind = false; } else { ShowSevereError(state, format("{}=\"{}\", invalid {}=\"{}\".", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, s_ipsc->cAlphaFieldNames(ArgPointer), s_ipsc->cAlphaArgs(ArgPointer))); ErrorsFound = true; } // Set the logical flag for the EcoRoof presented, this is only based on the flag in the construction type - // if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction > 0) - // state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtEcoRoof = - // state.dataConstruction->Construct(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction).TypeIsEcoRoof; + // if (surfTemp.Construction > 0) + // surfTemp.ExtEcoRoof = + // state.dataConstruction->Construct(surfTemp.Construction).TypeIsEcoRoof; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ViewFactorGround = s_ipsc->rNumericArgs(1); - if (s_ipsc->lNumericFieldBlanks(1)) state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ViewFactorGround = Constant::AutoCalculate; + surfTemp.ViewFactorGround = s_ipsc->rNumericArgs(1); + if (s_ipsc->lNumericFieldBlanks(1)) surfTemp.ViewFactorGround = Constant::AutoCalculate; if (s_ipsc->lNumericFieldBlanks(2) || s_ipsc->rNumericArgs(2) == Constant::AutoCalculate) { numSides = (SurfaceNumProp - 2) / 3; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides = numSides; + surfTemp.Sides = numSides; if (mod(SurfaceNumProp - 2, 3) != 0) { ShowWarningError(state, format("{}=\"{}\", {}", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, format("{} not even multiple of 3. Will read in {}", s_ipsc->cNumericFieldNames(2), - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides))); + surfTemp.Sides))); } if (numSides < 3) { ShowSevereError(state, format("{}=\"{}\", {} (autocalculate) must be >= 3. Only {} provided.", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, s_ipsc->cNumericFieldNames(2), - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides)); + surfTemp.Sides)); ErrorsFound = true; continue; } } else { numSides = (SurfaceNumProp - 2) / 3; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides = s_ipsc->rNumericArgs(2); - if (numSides > state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides) { + surfTemp.Sides = s_ipsc->rNumericArgs(2); + if (numSides > surfTemp.Sides) { ShowWarningError(state, format("{}=\"{}\", field {}={}", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, s_ipsc->cNumericFieldNames(2), - fmt::to_string(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides))); + fmt::to_string(surfTemp.Sides))); ShowContinueError( state, format("...but {} were entered. Only the indicated {} will be used.", numSides, s_ipsc->cNumericFieldNames(2))); } } - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex.allocate(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides); - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).NewVertex.allocate(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides); - GetVertices(state, SurfNum, state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides, s_ipsc->rNumericArgs({3, _})); - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Area <= 0.0) { + surfTemp.Vertex.allocate(surfTemp.Sides); + surfTemp.NewVertex.allocate(surfTemp.Sides); + GetVertices(state, SurfNum, surfTemp.Sides, s_ipsc->rNumericArgs({3, _})); + if (surfTemp.Area <= 0.0) { ShowSevereError(state, format("{}=\"{}\", Surface Area <= 0.0; Entered Area={:.2T}", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Area)); + surfTemp.Name, + surfTemp.Area)); ErrorsFound = true; } - CheckConvexity(state, SurfNum, state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides); + CheckConvexity(state, SurfNum, surfTemp.Sides); if (Util::SameString(s_ipsc->cAlphaArgs(5), "Surface")) { - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides != - static_cast(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex.size())) { + if (surfTemp.Sides != + static_cast(surfTemp.Vertex.size())) { ShowSevereError(state, format("{}=\"{}\", After CheckConvexity, mismatch between Sides ({}) and size of Vertex ({}).", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex.size())); + surfTemp.Name, + surfTemp.Sides, + surfTemp.Vertex.size())); ShowContinueError(state, "CheckConvexity is used to verify the convexity of a surface and detect collinear points."); ErrorsFound = true; } } - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction > 0) { + if (surfTemp.Construction > 0) { // Check wall height for the CFactor walls - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class == SurfaceClass::Wall && - state.dataConstruction->Construct(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction).TypeIsCfactorWall) { - if (std::abs(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Height - - state.dataConstruction->Construct(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction).Height) > 0.05) { + if (surfTemp.Class == SurfaceClass::Wall && + state.dataConstruction->Construct(surfTemp.Construction).TypeIsCfactorWall) { + if (std::abs(surfTemp.Height - + state.dataConstruction->Construct(surfTemp.Construction).Height) > 0.05) { ShowWarningError(state, format("{}=\"{}\", underground Wall Height = {:.2T}", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Height)); + surfTemp.Name, + surfTemp.Height)); ShowContinueError(state, "..which does not match its construction height."); } } // Check area and perimeter for the FFactor floors - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class == SurfaceClass::Floor && - state.dataConstruction->Construct(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction).TypeIsFfactorFloor) { - if (std::abs(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Area - - state.dataConstruction->Construct(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction).Area) > 0.1) { + if (surfTemp.Class == SurfaceClass::Floor && + state.dataConstruction->Construct(surfTemp.Construction).TypeIsFfactorFloor) { + if (std::abs(surfTemp.Area - + state.dataConstruction->Construct(surfTemp.Construction).Area) > 0.1) { ShowWarningError(state, format("{}=\"{}\", underground Floor Area = {:.2T}", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Area)); + surfTemp.Name, + surfTemp.Area)); ShowContinueError(state, "..which does not match its construction area."); } - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Perimeter < - state.dataConstruction->Construct(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction).PerimeterExposed - 0.1) { + if (surfTemp.Perimeter < + state.dataConstruction->Construct(surfTemp.Construction).PerimeterExposed - 0.1) { ShowWarningError(state, format("{}=\"{}\", underground Floor Perimeter = {:.2T}", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Perimeter)); + surfTemp.Name, + surfTemp.Perimeter)); ShowContinueError(state, "..which is less than its construction exposed perimeter."); } } } + // Not sure if it's better to add this or guard in SolarShading.cc + // surfTemp.shadowSurfSched = Sched::GetScheduleAlwaysOff(*state); } } // Item Looop // Check number of Vertex between base surface and Outside Boundary surface @@ -4445,53 +4429,55 @@ namespace SurfaceGeometry { } ++SurfNum; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name = s_ipsc->cAlphaArgs(1); // Set the Surface Name in the Derived Type - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class = BaseSurfIDs(ClassItem); // Set class number + + auto &surfTemp = state.dataSurfaceGeometry->SurfaceTmp(SurfNum); + surfTemp.Name = s_ipsc->cAlphaArgs(1); // Set the Surface Name in the Derived Type + surfTemp.Class = BaseSurfIDs(ClassItem); // Set class number - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction = + surfTemp.Construction = Util::FindItemInList(s_ipsc->cAlphaArgs(2), state.dataConstruction->Construct, state.dataHeatBal->TotConstructs); - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction == 0) { + if (surfTemp.Construction == 0) { ErrorsFound = true; ShowSevereError(state, format("{}=\"{}\", invalid {}=\"{}\".", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2))); - } else if (state.dataConstruction->Construct(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction).TypeIsWindow) { + } else if (state.dataConstruction->Construct(surfTemp.Construction).TypeIsWindow) { ErrorsFound = true; ShowSevereError(state, format("{}=\"{}\", invalid {}=\"{}\" - has Window materials.", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, s_ipsc->cAlphaFieldNames(3), s_ipsc->cAlphaArgs(2))); ShowContinueError(state, format("...because {}={}", s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2))); } else { - state.dataConstruction->Construct(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction).IsUsed = true; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ConstructionStoredInputValue = - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction; + state.dataConstruction->Construct(surfTemp.Construction).IsUsed = true; + surfTemp.ConstructionStoredInputValue = + surfTemp.Construction; } - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).HeatTransSurf = true; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).BaseSurf = SurfNum; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).BaseSurfName = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name; + surfTemp.HeatTransSurf = true; + surfTemp.BaseSurf = SurfNum; + surfTemp.BaseSurfName = surfTemp.Name; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ZoneName = s_ipsc->cAlphaArgs(3); + surfTemp.ZoneName = s_ipsc->cAlphaArgs(3); ZoneNum = Util::FindItemInList( - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ZoneName, state.dataHeatBal->Zone, state.dataGlobal->NumOfZones); + surfTemp.ZoneName, state.dataHeatBal->Zone, state.dataGlobal->NumOfZones); if (ZoneNum != 0) { - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Zone = ZoneNum; + surfTemp.Zone = ZoneNum; } else { ShowSevereError(state, format("{}=\"{}\", invalid {}=\"{}\".", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, s_ipsc->cAlphaFieldNames(3), s_ipsc->cAlphaArgs(3))); - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class = SurfaceClass::Invalid; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ZoneName = "Unknown Zone"; + surfTemp.Class = SurfaceClass::Invalid; + surfTemp.ZoneName = "Unknown Zone"; ErrorsFound = true; } @@ -4499,72 +4485,72 @@ namespace SurfaceGeometry { int spaceNum = Util::FindItemInList(s_ipsc->cAlphaArgs(4), state.dataHeatBal->space); if (spaceNum != 0) { - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).spaceNum = spaceNum; + surfTemp.spaceNum = spaceNum; } else { ShowSevereError(state, format("{}=\"{}\", invalid {}=\"{}\".", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, s_ipsc->cAlphaFieldNames(4), s_ipsc->cAlphaArgs(4))); - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class = SurfaceClass::Invalid; + surfTemp.Class = SurfaceClass::Invalid; ErrorsFound = true; } } - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond = ExtBoundCondition; - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction > 0) { - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class == SurfaceClass::Wall && - state.dataConstruction->Construct(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction).TypeIsCfactorWall && - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond == Ground) { - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond = GroundFCfactorMethod; - } else if (state.dataConstruction->Construct(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction).TypeIsCfactorWall) { + surfTemp.ExtBoundCond = ExtBoundCondition; + if (surfTemp.Construction > 0) { + if (surfTemp.Class == SurfaceClass::Wall && + state.dataConstruction->Construct(surfTemp.Construction).TypeIsCfactorWall && + surfTemp.ExtBoundCond == Ground) { + surfTemp.ExtBoundCond = GroundFCfactorMethod; + } else if (state.dataConstruction->Construct(surfTemp.Construction).TypeIsCfactorWall) { ErrorsFound = true; ShowSevereError(state, format("{}=\"{}\", Construction type is \"Construction:CfactorUndergroundWall\" but invalid for this object.", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name)); + surfTemp.Name)); } - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class == SurfaceClass::Floor && - state.dataConstruction->Construct(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction).TypeIsFfactorFloor && - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond == Ground) { - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond = GroundFCfactorMethod; - } else if (state.dataConstruction->Construct(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction).TypeIsFfactorFloor) { + if (surfTemp.Class == SurfaceClass::Floor && + state.dataConstruction->Construct(surfTemp.Construction).TypeIsFfactorFloor && + surfTemp.ExtBoundCond == Ground) { + surfTemp.ExtBoundCond = GroundFCfactorMethod; + } else if (state.dataConstruction->Construct(surfTemp.Construction).TypeIsFfactorFloor) { ErrorsFound = true; ShowSevereError(state, format("{}=\"{}\", Construction type is \"Construction:FfactorGroundFloor\" but invalid for this object.", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name)); + surfTemp.Name)); } } - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtSolar = false; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtWind = false; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ViewFactorGround = Constant::AutoCalculate; + surfTemp.ExtSolar = false; + surfTemp.ExtWind = false; + surfTemp.ViewFactorGround = Constant::AutoCalculate; - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond == ExternalEnvironment) { - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtSolar = true; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtWind = true; + if (surfTemp.ExtBoundCond == ExternalEnvironment) { + surfTemp.ExtSolar = true; + surfTemp.ExtWind = true; // Set the logical flag for the EcoRoof presented, this is only based on the flag in the construction type - // if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction > 0) - // state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtEcoRoof = - // state.dataConstruction->Construct(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction).TypeIsEcoRoof; + // if (surfTemp.Construction > 0) + // surfTemp.ExtEcoRoof = + // state.dataConstruction->Construct(surfTemp.Construction).TypeIsEcoRoof; - } else if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond == UnreconciledZoneSurface) { + } else if (surfTemp.ExtBoundCond == UnreconciledZoneSurface) { if (GettingIZSurfaces) { - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCondName = s_ipsc->cAlphaArgs(OtherSurfaceField); + surfTemp.ExtBoundCondName = s_ipsc->cAlphaArgs(OtherSurfaceField); Found = Util::FindItemInList( - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCondName, state.dataHeatBal->Zone, state.dataGlobal->NumOfZones); + surfTemp.ExtBoundCondName, state.dataHeatBal->Zone, state.dataGlobal->NumOfZones); // see if match to zone, then it's an unentered other surface, else reconciled later if (Found > 0) { ++NeedToAddSurfaces; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond = UnenteredAdjacentZoneSurface; + surfTemp.ExtBoundCond = UnenteredAdjacentZoneSurface; } } else { - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCondName = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name; + surfTemp.ExtBoundCondName = surfTemp.Name; } - } else if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond == Ground) { + } else if (surfTemp.ExtBoundCond == Ground) { if (state.dataSurfaceGeometry->NoGroundTempObjWarning) { if (!state.dataEnvrn->GroundTempInputs[(int)DataEnvironment::GroundTempType::BuildingSurface]) { @@ -4578,7 +4564,7 @@ namespace SurfaceGeometry { state.dataSurfaceGeometry->NoGroundTempObjWarning = false; } - } else if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond == GroundFCfactorMethod) { + } else if (surfTemp.ExtBoundCond == GroundFCfactorMethod) { if (state.dataSurfaceGeometry->NoFCGroundTempObjWarning) { if (!state.dataEnvrn->GroundTempInputs[(int)DataEnvironment::GroundTempType::FCFactorMethod]) { ShowSevereError(state, @@ -4595,22 +4581,22 @@ namespace SurfaceGeometry { } // ... End of the ExtBoundCond logical IF Block - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Azimuth = s_ipsc->rNumericArgs(1); - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Tilt = s_ipsc->rNumericArgs(2); - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).convOrientation = - Convect::GetSurfConvOrientation(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Tilt); + surfTemp.Azimuth = s_ipsc->rNumericArgs(1); + surfTemp.Tilt = s_ipsc->rNumericArgs(2); + surfTemp.convOrientation = + Convect::GetSurfConvOrientation(surfTemp.Tilt); if (!state.dataSurface->WorldCoordSystem) { if (ZoneNum != 0) { - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Azimuth += + surfTemp.Azimuth += state.dataHeatBal->BuildingAzimuth + state.dataHeatBal->Zone(ZoneNum).RelNorth; } } if (ZoneNum != 0) { - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Azimuth += state.dataHeatBal->BuildingRotationAppendixG; + surfTemp.Azimuth += state.dataHeatBal->BuildingRotationAppendixG; } - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides = 4; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex.allocate(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides); + surfTemp.Sides = 4; + surfTemp.Vertex.allocate(surfTemp.Sides); MakeRectangularVertices(state, SurfNum, @@ -4621,48 +4607,48 @@ namespace SurfaceGeometry { s_ipsc->rNumericArgs(7), state.dataSurfaceGeometry->RectSurfRefWorldCoordSystem); - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Area <= 0.0) { + if (surfTemp.Area <= 0.0) { ShowSevereError(state, format("{}=\"{}\", Surface Area <= 0.0; Entered Area={:.2T}", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Area)); + surfTemp.Name, + surfTemp.Area)); ErrorsFound = true; } // Check wall height for the CFactor walls - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class == SurfaceClass::Wall && - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond == GroundFCfactorMethod) { - if (std::abs(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Height - - state.dataConstruction->Construct(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction).Height) > 0.05) { + if (surfTemp.Class == SurfaceClass::Wall && + surfTemp.ExtBoundCond == GroundFCfactorMethod) { + if (std::abs(surfTemp.Height - + state.dataConstruction->Construct(surfTemp.Construction).Height) > 0.05) { ShowWarningError(state, format("{}=\"{}\", underground Wall Height = {:.2T}", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Height)); + surfTemp.Name, + surfTemp.Height)); ShowContinueError(state, "..which deos not match its construction height."); } } // Check area and perimeter for the FFactor floors - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class == SurfaceClass::Floor && - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond == GroundFCfactorMethod) { - if (std::abs(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Area - - state.dataConstruction->Construct(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction).Area) > 0.1) { + if (surfTemp.Class == SurfaceClass::Floor && + surfTemp.ExtBoundCond == GroundFCfactorMethod) { + if (std::abs(surfTemp.Area - + state.dataConstruction->Construct(surfTemp.Construction).Area) > 0.1) { ShowWarningError(state, format("{}=\"{}\", underground Floor Area = {:.2T}", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Area)); + surfTemp.Name, + surfTemp.Area)); ShowContinueError(state, "..which does not match its construction area."); } - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Perimeter < - state.dataConstruction->Construct(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction).PerimeterExposed - 0.1) { + if (surfTemp.Perimeter < + state.dataConstruction->Construct(surfTemp.Construction).PerimeterExposed - 0.1) { ShowWarningError(state, format("{}=\"{}\", underground Floor Perimeter = {:.2T}", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Perimeter)); + surfTemp.Name, + surfTemp.Perimeter)); ShowContinueError(state, "..which is less than its construction exposed perimeter."); } } @@ -4728,33 +4714,33 @@ namespace SurfaceGeometry { int n; int Vrt; - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Zone == 0 && - (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class != SurfaceClass::Detached_F && - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class != SurfaceClass::Detached_B)) + auto &surfTemp = state.dataSurfaceGeometry->SurfaceTmp(SurfNum); + + if (surfTemp.Zone == 0 && (surfTemp.Class != SurfaceClass::Detached_F && surfTemp.Class != SurfaceClass::Detached_B)) return; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Height = Height; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Width = Length; + surfTemp.Height = Height; + surfTemp.Width = Length; - SurfAzimuth = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Azimuth; - SurfTilt = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Tilt; - CosSurfAzimuth = std::cos(SurfAzimuth * Constant::DegToRadians); - SinSurfAzimuth = std::sin(SurfAzimuth * Constant::DegToRadians); - CosSurfTilt = std::cos(SurfTilt * Constant::DegToRadians); - SinSurfTilt = std::sin(SurfTilt * Constant::DegToRadians); + SurfAzimuth = surfTemp.Azimuth; + SurfTilt = surfTemp.Tilt; + CosSurfAzimuth = std::cos(SurfAzimuth * Constant::DegToRad); + SinSurfAzimuth = std::sin(SurfAzimuth * Constant::DegToRad); + CosSurfTilt = std::cos(SurfTilt * Constant::DegToRad); + SinSurfTilt = std::sin(SurfTilt * Constant::DegToRad); if (!SurfWorldCoordSystem) { - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Zone > 0) { - Xb = XCoord * state.dataSurfaceGeometry->CosZoneRelNorth(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Zone) - - YCoord * state.dataSurfaceGeometry->SinZoneRelNorth(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Zone) + - state.dataHeatBal->Zone(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Zone).OriginX; - Yb = XCoord * state.dataSurfaceGeometry->SinZoneRelNorth(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Zone) + - YCoord * state.dataSurfaceGeometry->CosZoneRelNorth(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Zone) + - state.dataHeatBal->Zone(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Zone).OriginY; + if (surfTemp.Zone > 0) { + Xb = XCoord * state.dataSurfaceGeometry->CosZoneRelNorth(surfTemp.Zone) - + YCoord * state.dataSurfaceGeometry->SinZoneRelNorth(surfTemp.Zone) + + state.dataHeatBal->Zone(surfTemp.Zone).OriginX; + Yb = XCoord * state.dataSurfaceGeometry->SinZoneRelNorth(surfTemp.Zone) + + YCoord * state.dataSurfaceGeometry->CosZoneRelNorth(surfTemp.Zone) + + state.dataHeatBal->Zone(surfTemp.Zone).OriginY; XLLC = Xb * state.dataSurfaceGeometry->CosBldgRelNorth - Yb * state.dataSurfaceGeometry->SinBldgRelNorth; YLLC = Xb * state.dataSurfaceGeometry->SinBldgRelNorth + Yb * state.dataSurfaceGeometry->CosBldgRelNorth; - ZLLC = ZCoord + state.dataHeatBal->Zone(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Zone).OriginZ; + ZLLC = ZCoord + state.dataHeatBal->Zone(surfTemp.Zone).OriginZ; } else { - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class == SurfaceClass::Detached_B) { + if (surfTemp.Class == SurfaceClass::Detached_B) { Xb = XCoord; Yb = YCoord; XLLC = Xb * state.dataSurfaceGeometry->CosBldgRelNorth - Yb * state.dataSurfaceGeometry->SinBldgRelNorth; @@ -4771,7 +4757,7 @@ namespace SurfaceGeometry { Xb = XCoord; Yb = YCoord; ZLLC = ZCoord; - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class != SurfaceClass::Detached_F) { + if (surfTemp.Class != SurfaceClass::Detached_F) { XLLC = Xb * state.dataSurfaceGeometry->CosBldgRotAppGonly - Yb * state.dataSurfaceGeometry->SinBldgRotAppGonly; YLLC = Xb * state.dataSurfaceGeometry->SinBldgRotAppGonly + Yb * state.dataSurfaceGeometry->CosBldgRotAppGonly; } else { @@ -4789,68 +4775,68 @@ namespace SurfaceGeometry { YY(3) = 0.0; YY(2) = 0.0; - for (n = 1; n <= state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides; ++n) { + for (n = 1; n <= surfTemp.Sides; ++n) { Vrt = n; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(Vrt).x = XLLC - XX(n) * CosSurfAzimuth - YY(n) * CosSurfTilt * SinSurfAzimuth; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(Vrt).y = YLLC + XX(n) * SinSurfAzimuth - YY(n) * CosSurfTilt * CosSurfAzimuth; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(Vrt).z = ZLLC + YY(n) * SinSurfTilt; - } - - CreateNewellAreaVector(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).NewellAreaVector); - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).GrossArea = VecLength(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).NewellAreaVector); - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Area = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).GrossArea; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).NetAreaShadowCalc = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Area; - CreateNewellSurfaceNormalVector(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).NewellSurfaceNormalVector); - DetermineAzimuthAndTilt(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex, + surfTemp.Vertex(Vrt).x = XLLC - XX(n) * CosSurfAzimuth - YY(n) * CosSurfTilt * SinSurfAzimuth; + surfTemp.Vertex(Vrt).y = YLLC + XX(n) * SinSurfAzimuth - YY(n) * CosSurfTilt * CosSurfAzimuth; + surfTemp.Vertex(Vrt).z = ZLLC + YY(n) * SinSurfTilt; + } + + CreateNewellAreaVector(surfTemp.Vertex, + surfTemp.Sides, + surfTemp.NewellAreaVector); + surfTemp.GrossArea = VecLength(surfTemp.NewellAreaVector); + surfTemp.Area = surfTemp.GrossArea; + surfTemp.NetAreaShadowCalc = surfTemp.Area; + CreateNewellSurfaceNormalVector(surfTemp.Vertex, + surfTemp.Sides, + surfTemp.NewellSurfaceNormalVector); + DetermineAzimuthAndTilt(surfTemp.Vertex, SurfAzimuth, SurfTilt, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).lcsx, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).lcsy, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).lcsz, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).NewellSurfaceNormalVector); - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Azimuth = SurfAzimuth; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Tilt = SurfTilt; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).convOrientation = - Convect::GetSurfConvOrientation(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Tilt); + surfTemp.lcsx, + surfTemp.lcsy, + surfTemp.lcsz, + surfTemp.NewellSurfaceNormalVector); + surfTemp.Azimuth = SurfAzimuth; + surfTemp.Tilt = SurfTilt; + surfTemp.convOrientation = + Convect::GetSurfConvOrientation(surfTemp.Tilt); // Sine and cosine of azimuth and tilt - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).SinAzim = SinSurfAzimuth; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).CosAzim = CosSurfAzimuth; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).SinTilt = SinSurfTilt; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).CosTilt = CosSurfTilt; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ViewFactorGround = 0.5 * (1.0 - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).CosTilt); + surfTemp.SinAzim = SinSurfAzimuth; + surfTemp.CosAzim = CosSurfAzimuth; + surfTemp.SinTilt = SinSurfTilt; + surfTemp.CosTilt = CosSurfTilt; + surfTemp.ViewFactorGround = 0.5 * (1.0 - surfTemp.CosTilt); // Outward normal unit vector (pointing away from room) - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).OutNormVec = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).NewellSurfaceNormalVector; + surfTemp.OutNormVec = surfTemp.NewellSurfaceNormalVector; for (n = 1; n <= 3; ++n) { - if (std::abs(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).OutNormVec(n) - 1.0) < 1.e-06) - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).OutNormVec(n) = +1.0; - if (std::abs(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).OutNormVec(n) + 1.0) < 1.e-06) - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).OutNormVec(n) = -1.0; - if (std::abs(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).OutNormVec(n)) < 1.e-06) - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).OutNormVec(n) = 0.0; + if (std::abs(surfTemp.OutNormVec(n) - 1.0) < 1.e-06) + surfTemp.OutNormVec(n) = +1.0; + if (std::abs(surfTemp.OutNormVec(n) + 1.0) < 1.e-06) + surfTemp.OutNormVec(n) = -1.0; + if (std::abs(surfTemp.OutNormVec(n)) < 1.e-06) + surfTemp.OutNormVec(n) = 0.0; } // Can perform tests on this surface here - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ViewFactorSky = 0.5 * (1.0 + state.dataSurfaceGeometry->SurfaceTmp(SurfNum).CosTilt); + surfTemp.ViewFactorSky = 0.5 * (1.0 + surfTemp.CosTilt); // The following IR view factors are modified in subr. SkyDifSolarShading if there are shadowing // surfaces - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ViewFactorSkyIR = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ViewFactorSky; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ViewFactorGroundIR = 0.5 * (1.0 - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).CosTilt); + surfTemp.ViewFactorSkyIR = surfTemp.ViewFactorSky; + surfTemp.ViewFactorGroundIR = 0.5 * (1.0 - surfTemp.CosTilt); - Perimeter = distance(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides), - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(1)); - for (Vrt = 2; Vrt <= state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides; ++Vrt) { + Perimeter = distance(surfTemp.Vertex(surfTemp.Sides), + surfTemp.Vertex(1)); + for (Vrt = 2; Vrt <= surfTemp.Sides; ++Vrt) { Perimeter += - distance(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(Vrt), state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(Vrt - 1)); + distance(surfTemp.Vertex(Vrt), surfTemp.Vertex(Vrt - 1)); } - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Perimeter = Perimeter; + surfTemp.Perimeter = Perimeter; // Call to transform vertices - TransformVertsByAspect(state, SurfNum, state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides); + TransformVertsByAspect(state, SurfNum, surfTemp.Sides); } void GetHTSubSurfaceData(EnergyPlusData &state, @@ -5004,108 +4990,111 @@ namespace SurfaceGeometry { continue; } + ++SurfNum; + + auto &surfTemp = state.dataSurfaceGeometry->SurfaceTmp(SurfNum); + if (SurfaceNumProp < 12) { ShowSevereError(state, format("{}=\"{}\", Too few number of numeric args=[{}].", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, SurfaceNumProp)); ErrorsFound = true; } - ++SurfNum; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name = s_ipsc->cAlphaArgs(1); // Set the Surface Name in the Derived Type + surfTemp.Name = s_ipsc->cAlphaArgs(1); // Set the Surface Name in the Derived Type ValidChk = Util::FindItemInList(s_ipsc->cAlphaArgs(2), SubSurfCls, 6); if (ValidChk == 0) { ShowSevereError(state, format("{}=\"{}\", invalid {}=\"{}", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2))); ErrorsFound = true; } else { - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class = SubSurfIDs(ValidChk); // Set class number + surfTemp.Class = SubSurfIDs(ValidChk); // Set class number } - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction = + surfTemp.Construction = Util::FindItemInList(s_ipsc->cAlphaArgs(3), state.dataConstruction->Construct, state.dataHeatBal->TotConstructs); - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction == 0) { + if (surfTemp.Construction == 0) { ShowSevereError(state, format("{}=\"{}\", invalid {}=\"{}\".", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, s_ipsc->cAlphaFieldNames(3), s_ipsc->cAlphaArgs(3))); ErrorsFound = true; continue; } else { - state.dataConstruction->Construct(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction).IsUsed = true; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ConstructionStoredInputValue = - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction; + state.dataConstruction->Construct(surfTemp.Construction).IsUsed = true; + surfTemp.ConstructionStoredInputValue = + surfTemp.Construction; } - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class == SurfaceClass::Window || - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class == SurfaceClass::GlassDoor || - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class == SurfaceClass::TDD_Diffuser || - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class == SurfaceClass::TDD_Dome) { + if (surfTemp.Class == SurfaceClass::Window || + surfTemp.Class == SurfaceClass::GlassDoor || + surfTemp.Class == SurfaceClass::TDD_Diffuser || + surfTemp.Class == SurfaceClass::TDD_Dome) { - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction != 0) { - auto &construction = state.dataConstruction->Construct(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction); + if (surfTemp.Construction != 0) { + auto &construction = state.dataConstruction->Construct(surfTemp.Construction); if (!construction.TypeIsWindow && !construction.TypeIsAirBoundary) { ErrorsFound = true; ShowSevereError(state, format("{}=\"{}\" has an opaque surface construction; it should have a window construction.", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name)); + surfTemp.Name)); } - if (state.dataConstruction->Construct(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction).SourceSinkPresent) { + if (state.dataConstruction->Construct(surfTemp.Construction).SourceSinkPresent) { ErrorsFound = true; ShowSevereError(state, format("{}=\"{}\": Windows are not allowed to have embedded sources/sinks", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name)); + surfTemp.Name)); } } - } else if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction != 0) { - if (state.dataConstruction->Construct(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction).TypeIsWindow) { + } else if (surfTemp.Construction != 0) { + if (state.dataConstruction->Construct(surfTemp.Construction).TypeIsWindow) { ErrorsFound = true; ShowSevereError(state, format("{}=\"{}\", invalid {}=\"{}\" - has Window materials.", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, s_ipsc->cAlphaFieldNames(3), s_ipsc->cAlphaArgs(3))); ShowContinueError(state, format("...because {}={}", s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2))); } } - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).HeatTransSurf = true; + surfTemp.HeatTransSurf = true; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).BaseSurfName = s_ipsc->cAlphaArgs(4); + surfTemp.BaseSurfName = s_ipsc->cAlphaArgs(4); // The subsurface inherits properties from the base surface // Exterior conditions, Zone, etc. // We can figure out the base surface though, because they've all been entered Found = Util::FindItemInList( - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).BaseSurfName, state.dataSurfaceGeometry->SurfaceTmp, state.dataSurface->TotSurfaces); + surfTemp.BaseSurfName, state.dataSurfaceGeometry->SurfaceTmp, state.dataSurface->TotSurfaces); if (Found > 0) { - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).BaseSurf = Found; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond = state.dataSurfaceGeometry->SurfaceTmp(Found).ExtBoundCond; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCondName = state.dataSurfaceGeometry->SurfaceTmp(Found).ExtBoundCondName; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtSolar = state.dataSurfaceGeometry->SurfaceTmp(Found).ExtSolar; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtWind = state.dataSurfaceGeometry->SurfaceTmp(Found).ExtWind; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Zone = state.dataSurfaceGeometry->SurfaceTmp(Found).Zone; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ZoneName = state.dataSurfaceGeometry->SurfaceTmp(Found).ZoneName; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).OSCPtr = state.dataSurfaceGeometry->SurfaceTmp(Found).OSCPtr; + surfTemp.BaseSurf = Found; + surfTemp.ExtBoundCond = state.dataSurfaceGeometry->SurfaceTmp(Found).ExtBoundCond; + surfTemp.ExtBoundCondName = state.dataSurfaceGeometry->SurfaceTmp(Found).ExtBoundCondName; + surfTemp.ExtSolar = state.dataSurfaceGeometry->SurfaceTmp(Found).ExtSolar; + surfTemp.ExtWind = state.dataSurfaceGeometry->SurfaceTmp(Found).ExtWind; + surfTemp.Zone = state.dataSurfaceGeometry->SurfaceTmp(Found).Zone; + surfTemp.ZoneName = state.dataSurfaceGeometry->SurfaceTmp(Found).ZoneName; + surfTemp.OSCPtr = state.dataSurfaceGeometry->SurfaceTmp(Found).OSCPtr; if (state.dataSurfaceGeometry->SurfaceTmp(Found).ExtBoundCond == UnreconciledZoneSurface && state.dataSurfaceGeometry->SurfaceTmp(Found).ExtBoundCondName == state.dataSurfaceGeometry->SurfaceTmp(Found).Name) { // Adiabatic surface, no windows or doors allowed ShowSevereError(state, format("{}=\"{}\", invalid {}=\"{}\".", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, s_ipsc->cAlphaFieldNames(4), s_ipsc->cAlphaArgs(4))); ShowContinueError(state, "... adiabatic surfaces cannot have windows or doors."); @@ -5117,23 +5106,23 @@ namespace SurfaceGeometry { ShowSevereError(state, format("{}=\"{}\", invalid {}=\"{}", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, s_ipsc->cAlphaFieldNames(4), s_ipsc->cAlphaArgs(4))); - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ZoneName = "Unknown Zone"; + surfTemp.ZoneName = "Unknown Zone"; ErrorsFound = true; } - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class == SurfaceClass::TDD_Dome || - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class == SurfaceClass::TDD_Diffuser) { - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond = ExternalEnvironment; + if (surfTemp.Class == SurfaceClass::TDD_Dome || + surfTemp.Class == SurfaceClass::TDD_Diffuser) { + surfTemp.ExtBoundCond = ExternalEnvironment; } - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond == ExternalEnvironment) { + if (surfTemp.ExtBoundCond == ExternalEnvironment) { if (!s_ipsc->lAlphaFieldBlanks(5)) { ShowWarningError(state, format("{}=\"{}\", invalid field {}", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, s_ipsc->cAlphaFieldNames(5))); ShowContinueError( state, @@ -5143,39 +5132,39 @@ namespace SurfaceGeometry { } } - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond == UnreconciledZoneSurface) { // "Surface" Base Surface + if (surfTemp.ExtBoundCond == UnreconciledZoneSurface) { // "Surface" Base Surface if (!s_ipsc->lAlphaFieldBlanks(5)) { - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCondName = s_ipsc->cAlphaArgs(5); + surfTemp.ExtBoundCondName = s_ipsc->cAlphaArgs(5); } else { ShowSevereError(state, format("{}=\"{}\", invalid blank {}", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, s_ipsc->cAlphaFieldNames(5))); ShowContinueError( state, format("...when Base surface uses \"Surface\" as {}, subsurfaces must also specify specific surfaces in the adjacent zone.", s_ipsc->cAlphaFieldNames(5))); - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCondName = + surfTemp.ExtBoundCondName = s_ipsc->cAlphaArgs(5); // putting it as blank will not confuse things later. ErrorsFound = true; } } - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond == UnenteredAdjacentZoneSurface) { // "Zone" - unmatched interior surface + if (surfTemp.ExtBoundCond == UnenteredAdjacentZoneSurface) { // "Zone" - unmatched interior surface ++NeedToAddSurfaces; // ignoring window5datafiles for now -- will need to add. } - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond == OtherSideCoefNoCalcExt || - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond == OtherSideCoefCalcExt) { + if (surfTemp.ExtBoundCond == OtherSideCoefNoCalcExt || + surfTemp.ExtBoundCond == OtherSideCoefCalcExt) { if (!s_ipsc->lAlphaFieldBlanks(5)) { // Otherside Coef special Name Found = Util::FindItemInList(s_ipsc->cAlphaArgs(5), state.dataSurface->OSC, state.dataSurface->TotOSC); if (Found == 0) { ShowSevereError(state, format("{}=\"{}\", invalid {}=\"{}\".", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, s_ipsc->cAlphaFieldNames(5), s_ipsc->cAlphaArgs(5))); ShowContinueError(state, "...base surface requires that this subsurface have OtherSideCoefficients -- not found."); @@ -5183,122 +5172,122 @@ namespace SurfaceGeometry { } else { // found // The following allows for a subsurface that has different characteristics than // the base surface with OtherSide Coeff -- do we want that or is it an error? - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).OSCPtr = Found; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCondName = s_ipsc->cAlphaArgs(5); + surfTemp.OSCPtr = Found; + surfTemp.ExtBoundCondName = s_ipsc->cAlphaArgs(5); if (state.dataSurface->OSC(Found).SurfFilmCoef > 0.0) { - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond = OtherSideCoefCalcExt; + surfTemp.ExtBoundCond = OtherSideCoefCalcExt; } else { - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond = OtherSideCoefNoCalcExt; + surfTemp.ExtBoundCond = OtherSideCoefNoCalcExt; } } } } - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond == OtherSideCondModeledExt) { - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond = ExternalEnvironment; + if (surfTemp.ExtBoundCond == OtherSideCondModeledExt) { + surfTemp.ExtBoundCond = ExternalEnvironment; } - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCondName == BlankString) { - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCondName = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name; + if (surfTemp.ExtBoundCondName == BlankString) { + surfTemp.ExtBoundCondName = surfTemp.Name; } - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ViewFactorGround = s_ipsc->rNumericArgs(1); - if (s_ipsc->lNumericFieldBlanks(1)) state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ViewFactorGround = Constant::AutoCalculate; + surfTemp.ViewFactorGround = s_ipsc->rNumericArgs(1); + if (s_ipsc->lNumericFieldBlanks(1)) surfTemp.ViewFactorGround = Constant::AutoCalculate; if (s_ipsc->lNumericFieldBlanks(3) || s_ipsc->rNumericArgs(3) == Constant::AutoCalculate) { s_ipsc->rNumericArgs(3) = (SurfaceNumProp - 3) / 3; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides = s_ipsc->rNumericArgs(3); + surfTemp.Sides = s_ipsc->rNumericArgs(3); if (mod(SurfaceNumProp - 3, 3) != 0) { ShowWarningError(state, format("{}=\"{}\", {}", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, format("{} not even multiple of 3. Will read in {}", s_ipsc->cNumericFieldNames(3), - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides))); + surfTemp.Sides))); } if (s_ipsc->rNumericArgs(3) < 3) { ShowSevereError(state, format("{}=\"{}\", {} (autocalculate) must be >= 3. Only {} provided.", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, s_ipsc->cNumericFieldNames(3), - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides)); + surfTemp.Sides)); ErrorsFound = true; continue; } } else { numSides = (SurfaceNumProp - 2) / 3; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides = s_ipsc->rNumericArgs(3); - if (numSides > state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides) { + surfTemp.Sides = s_ipsc->rNumericArgs(3); + if (numSides > surfTemp.Sides) { ShowWarningError(state, format("{}=\"{}\", field {}={}", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, s_ipsc->cNumericFieldNames(3), - fmt::to_string(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides))); + fmt::to_string(surfTemp.Sides))); ShowContinueError(state, format("...but {} were entered. Only the indicated {} will be used.", numSides, s_ipsc->cNumericFieldNames(3))); } } - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex.allocate(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides); - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class == SurfaceClass::Window || - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class == SurfaceClass::GlassDoor || - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class == SurfaceClass::Door) - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Multiplier = int(s_ipsc->rNumericArgs(2)); + surfTemp.Vertex.allocate(surfTemp.Sides); + if (surfTemp.Class == SurfaceClass::Window || + surfTemp.Class == SurfaceClass::GlassDoor || + surfTemp.Class == SurfaceClass::Door) + surfTemp.Multiplier = int(s_ipsc->rNumericArgs(2)); // Only windows, glass doors and doors can have Multiplier > 1: - if ((state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class != SurfaceClass::Window && - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class != SurfaceClass::GlassDoor && - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class != SurfaceClass::Door) && + if ((surfTemp.Class != SurfaceClass::Window && + surfTemp.Class != SurfaceClass::GlassDoor && + surfTemp.Class != SurfaceClass::Door) && s_ipsc->rNumericArgs(2) > 1.0) { ShowWarningError(state, format("{}=\"{}\", invalid {}=[{:.1T}].", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, s_ipsc->cNumericFieldNames(2), s_ipsc->rNumericArgs(2))); ShowContinueError(state, format("...because {}={} multiplier will be set to 1.0.", s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2))); - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Multiplier = 1.0; + surfTemp.Multiplier = 1.0; } - GetVertices(state, SurfNum, state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides, s_ipsc->rNumericArgs({4, _})); + GetVertices(state, SurfNum, surfTemp.Sides, s_ipsc->rNumericArgs({4, _})); - CheckConvexity(state, SurfNum, state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides); - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).windowShadingControlList.clear(); - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).activeWindowShadingControl = 0; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).HasShadeControl = false; + CheckConvexity(state, SurfNum, surfTemp.Sides); + surfTemp.windowShadingControlList.clear(); + surfTemp.activeWindowShadingControl = 0; + surfTemp.HasShadeControl = false; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).shadedConstructionList.clear(); - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).activeShadedConstruction = 0; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).shadedStormWinConstructionList.clear(); + surfTemp.shadedConstructionList.clear(); + surfTemp.activeShadedConstruction = 0; + surfTemp.shadedStormWinConstructionList.clear(); - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class == SurfaceClass::Window || - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class == SurfaceClass::GlassDoor || - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class == SurfaceClass::TDD_Diffuser || - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class == SurfaceClass::TDD_Dome) { + if (surfTemp.Class == SurfaceClass::Window || + surfTemp.Class == SurfaceClass::GlassDoor || + surfTemp.Class == SurfaceClass::TDD_Diffuser || + surfTemp.Class == SurfaceClass::TDD_Dome) { - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond == OtherSideCoefNoCalcExt || - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond == OtherSideCoefCalcExt) { + if (surfTemp.ExtBoundCond == OtherSideCoefNoCalcExt || + surfTemp.ExtBoundCond == OtherSideCoefCalcExt) { ShowSevereError(state, format("{}=\"{}\", Other side coefficients are not allowed with windows.", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name)); + surfTemp.Name)); ErrorsFound = true; } - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond == Ground) { + if (surfTemp.ExtBoundCond == Ground) { ShowSevereError(state, format("{}=\"{}\", Exterior boundary condition = Ground is not allowed with windows.", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name)); + surfTemp.Name)); ErrorsFound = true; } - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond == KivaFoundation) { + if (surfTemp.ExtBoundCond == KivaFoundation) { ShowSevereError(state, format("{}=\"{}\", Exterior boundary condition = Foundation is not allowed with windows.", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name)); + surfTemp.Name)); ErrorsFound = true; } @@ -5306,18 +5295,18 @@ namespace SurfaceGeometry { CheckWindowShadingControlFrameDivider(state, "GetHTSubSurfaceData", ErrorsFound, SurfNum, 6); - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides == 3) { // Triangular window + if (surfTemp.Sides == 3) { // Triangular window if (!s_ipsc->cAlphaArgs(6).empty()) { ShowWarningError(state, format("{}=\"{}\", invalid {}=\"{}\".", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, s_ipsc->cAlphaFieldNames(6), s_ipsc->cAlphaArgs(6))); ShowContinueError(state, ".. because it is a triangular window and cannot have a frame or divider or reveal reflection."); ShowContinueError(state, "Frame, divider and reveal reflection will be ignored for this window."); } - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).FrameDivider = 0; + surfTemp.FrameDivider = 0; } // End of check if window is triangular or rectangular } // check on non-opaquedoor subsurfaces @@ -5455,91 +5444,93 @@ namespace SurfaceGeometry { } ++SurfNum; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name = s_ipsc->cAlphaArgs(1); // Set the Surface Name in the Derived Type - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class = SubSurfIDs(ClassItem); // Set class number + auto &surfTemp = state.dataSurfaceGeometry->SurfaceTmp(SurfNum); + + surfTemp.Name = s_ipsc->cAlphaArgs(1); // Set the Surface Name in the Derived Type + surfTemp.Class = SubSurfIDs(ClassItem); // Set class number - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction = + surfTemp.Construction = Util::FindItemInList(s_ipsc->cAlphaArgs(2), state.dataConstruction->Construct, state.dataHeatBal->TotConstructs); - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction == 0) { + if (surfTemp.Construction == 0) { ErrorsFound = true; ShowSevereError(state, format("{}=\"{}\", invalid {}=\"{}\".", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2))); } else { - state.dataConstruction->Construct(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction).IsUsed = true; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ConstructionStoredInputValue = - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction; + state.dataConstruction->Construct(surfTemp.Construction).IsUsed = true; + surfTemp.ConstructionStoredInputValue = + surfTemp.Construction; } - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class == SurfaceClass::Window || - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class == SurfaceClass::GlassDoor) { + if (surfTemp.Class == SurfaceClass::Window || + surfTemp.Class == SurfaceClass::GlassDoor) { - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction != 0) { - auto &construction = state.dataConstruction->Construct(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction); + if (surfTemp.Construction != 0) { + auto &construction = state.dataConstruction->Construct(surfTemp.Construction); if (!construction.TypeIsWindow && !construction.TypeIsAirBoundary) { ErrorsFound = true; ShowSevereError(state, format("{}=\"{}\" has an opaque surface construction; it should have a window construction.", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name)); + surfTemp.Name)); } - if (state.dataConstruction->Construct(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction).SourceSinkPresent) { + if (state.dataConstruction->Construct(surfTemp.Construction).SourceSinkPresent) { ErrorsFound = true; ShowSevereError(state, format("{}=\"{}\": Windows are not allowed to have embedded sources/sinks", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name)); + surfTemp.Name)); } } - } else if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction != 0) { - if (state.dataConstruction->Construct(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction).TypeIsWindow) { + } else if (surfTemp.Construction != 0) { + if (state.dataConstruction->Construct(surfTemp.Construction).TypeIsWindow) { ErrorsFound = true; ShowSevereError(state, format("{}=\"{}\", invalid {}=\"{}\" - has Window materials.", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2))); } } - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).HeatTransSurf = true; + surfTemp.HeatTransSurf = true; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).BaseSurfName = s_ipsc->cAlphaArgs(3); + surfTemp.BaseSurfName = s_ipsc->cAlphaArgs(3); // The subsurface inherits properties from the base surface // Exterior conditions, Zone, etc. // We can figure out the base surface though, because they've all been entered - Found = Util::FindItemInList(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).BaseSurfName, + Found = Util::FindItemInList(surfTemp.BaseSurfName, state.dataSurfaceGeometry->SurfaceTmp, state.dataSurface->TotSurfaces); if (Found > 0) { - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).BaseSurf = Found; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond = state.dataSurfaceGeometry->SurfaceTmp(Found).ExtBoundCond; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCondName = state.dataSurfaceGeometry->SurfaceTmp(Found).ExtBoundCondName; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtSolar = state.dataSurfaceGeometry->SurfaceTmp(Found).ExtSolar; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtWind = state.dataSurfaceGeometry->SurfaceTmp(Found).ExtWind; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Tilt = state.dataSurfaceGeometry->SurfaceTmp(Found).Tilt; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).convOrientation = - Convect::GetSurfConvOrientation(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Tilt); - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Azimuth = state.dataSurfaceGeometry->SurfaceTmp(Found).Azimuth; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Zone = state.dataSurfaceGeometry->SurfaceTmp(Found).Zone; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ZoneName = state.dataSurfaceGeometry->SurfaceTmp(Found).ZoneName; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).OSCPtr = state.dataSurfaceGeometry->SurfaceTmp(Found).OSCPtr; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ViewFactorGround = state.dataSurfaceGeometry->SurfaceTmp(Found).ViewFactorGround; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ViewFactorSky = state.dataSurfaceGeometry->SurfaceTmp(Found).ViewFactorSky; + surfTemp.BaseSurf = Found; + surfTemp.ExtBoundCond = state.dataSurfaceGeometry->SurfaceTmp(Found).ExtBoundCond; + surfTemp.ExtBoundCondName = state.dataSurfaceGeometry->SurfaceTmp(Found).ExtBoundCondName; + surfTemp.ExtSolar = state.dataSurfaceGeometry->SurfaceTmp(Found).ExtSolar; + surfTemp.ExtWind = state.dataSurfaceGeometry->SurfaceTmp(Found).ExtWind; + surfTemp.Tilt = state.dataSurfaceGeometry->SurfaceTmp(Found).Tilt; + surfTemp.convOrientation = + Convect::GetSurfConvOrientation(surfTemp.Tilt); + surfTemp.Azimuth = state.dataSurfaceGeometry->SurfaceTmp(Found).Azimuth; + surfTemp.Zone = state.dataSurfaceGeometry->SurfaceTmp(Found).Zone; + surfTemp.ZoneName = state.dataSurfaceGeometry->SurfaceTmp(Found).ZoneName; + surfTemp.OSCPtr = state.dataSurfaceGeometry->SurfaceTmp(Found).OSCPtr; + surfTemp.ViewFactorGround = state.dataSurfaceGeometry->SurfaceTmp(Found).ViewFactorGround; + surfTemp.ViewFactorSky = state.dataSurfaceGeometry->SurfaceTmp(Found).ViewFactorSky; } else { ShowSevereError(state, format("{}=\"{}\", invalid {}=\"{}", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, s_ipsc->cAlphaFieldNames(3), s_ipsc->cAlphaArgs(3))); - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ZoneName = "Unknown Zone"; + surfTemp.ZoneName = "Unknown Zone"; ErrorsFound = true; continue; } @@ -5549,7 +5540,7 @@ namespace SurfaceGeometry { ShowSevereError(state, format("{}=\"{}\", invalid {}=\"{}\".", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, s_ipsc->cAlphaFieldNames(3), s_ipsc->cAlphaArgs(3))); ShowContinueError(state, "... adiabatic surfaces cannot have windows or doors."); @@ -5558,37 +5549,37 @@ namespace SurfaceGeometry { "Interzone surfaces for transmission to result."); } - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond == UnreconciledZoneSurface) { // "Surface" Base Surface + if (surfTemp.ExtBoundCond == UnreconciledZoneSurface) { // "Surface" Base Surface if (!GettingIZSurfaces) { ShowSevereError(state, format("{}=\"{}\", invalid use of object", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name)); + surfTemp.Name)); ShowContinueError( state, format( "...when Base surface uses \"Surface\" as {}, subsurfaces must also specify specific surfaces in the adjacent zone.", s_ipsc->cAlphaFieldNames(5))); ShowContinueError(state, format("...Please use {}:Interzone to enter this surface.", s_ipsc->cCurrentModuleObject)); - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCondName = + surfTemp.ExtBoundCondName = BlankString; // putting it as blank will not confuse things later. ErrorsFound = true; } } - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond == UnreconciledZoneSurface) { // "Surface" Base Surface + if (surfTemp.ExtBoundCond == UnreconciledZoneSurface) { // "Surface" Base Surface if (GettingIZSurfaces) { - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCondName = s_ipsc->cAlphaArgs(OtherSurfaceField); + surfTemp.ExtBoundCondName = s_ipsc->cAlphaArgs(OtherSurfaceField); IZFound = Util::FindItemInList( - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCondName, state.dataHeatBal->Zone, state.dataGlobal->NumOfZones); - if (IZFound > 0) state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond = UnenteredAdjacentZoneSurface; + surfTemp.ExtBoundCondName, state.dataHeatBal->Zone, state.dataGlobal->NumOfZones); + if (IZFound > 0) surfTemp.ExtBoundCond = UnenteredAdjacentZoneSurface; } else { // Interior Window - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCondName = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name; + surfTemp.ExtBoundCondName = surfTemp.Name; } } // This is the parent's property: - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond == + if (surfTemp.ExtBoundCond == UnenteredAdjacentZoneSurface) { // OtherZone - unmatched interior surface if (GettingIZSurfaces) { ++NeedToAddSubSurfaces; @@ -5596,7 +5587,7 @@ namespace SurfaceGeometry { ShowSevereError(state, format("{}=\"{}\", invalid Interzone Surface, specify {}:InterZone", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, s_ipsc->cCurrentModuleObject)); ShowContinueError(state, "...when base surface is an interzone surface, subsurface must also be an interzone surface."); ++NeedToAddSubSurfaces; @@ -5607,19 +5598,19 @@ namespace SurfaceGeometry { if (GettingIZSurfaces) { if (s_ipsc->lAlphaFieldBlanks(OtherSurfaceField)) { // blank -- set it up for unentered adjacent zone - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond == + if (surfTemp.ExtBoundCond == UnenteredAdjacentZoneSurface) { // already set but need Zone - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCondName = + surfTemp.ExtBoundCondName = state.dataSurfaceGeometry->SurfaceTmp(Found).ExtBoundCondName; // base surface has it - } else if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond == UnreconciledZoneSurface) { - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCondName = + } else if (surfTemp.ExtBoundCond == UnreconciledZoneSurface) { + surfTemp.ExtBoundCondName = state.dataSurfaceGeometry->SurfaceTmp(Found).ZoneName; // base surface has it - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond = UnenteredAdjacentZoneSurface; + surfTemp.ExtBoundCond = UnenteredAdjacentZoneSurface; } else { // not correct boundary condition for interzone subsurface ShowSevereError(state, format("{}=\"{}\", invalid Base Surface type for Interzone Surface", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name)); + surfTemp.Name)); ShowContinueError(state, "...when base surface is not an interzone surface, subsurface must also not be an interzone surface."); ErrorsFound = true; @@ -5627,78 +5618,78 @@ namespace SurfaceGeometry { } } - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond == OtherSideCondModeledExt) { - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond = ExternalEnvironment; + if (surfTemp.ExtBoundCond == OtherSideCondModeledExt) { + surfTemp.ExtBoundCond = ExternalEnvironment; } // SurfaceTmp(SurfNum)%ViewFactorGround = AutoCalculate - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides = 4; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex.allocate(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides); - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class == SurfaceClass::Window || - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class == SurfaceClass::GlassDoor || - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class == SurfaceClass::Door) - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Multiplier = int(s_ipsc->rNumericArgs(1)); + surfTemp.Sides = 4; + surfTemp.Vertex.allocate(surfTemp.Sides); + if (surfTemp.Class == SurfaceClass::Window || + surfTemp.Class == SurfaceClass::GlassDoor || + surfTemp.Class == SurfaceClass::Door) + surfTemp.Multiplier = int(s_ipsc->rNumericArgs(1)); // Only windows, glass doors and doors can have Multiplier > 1: - if ((state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class != SurfaceClass::Window && - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class != SurfaceClass::GlassDoor && - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class != SurfaceClass::Door) && + if ((surfTemp.Class != SurfaceClass::Window && + surfTemp.Class != SurfaceClass::GlassDoor && + surfTemp.Class != SurfaceClass::Door) && s_ipsc->rNumericArgs(1) > 1.0) { ShowWarningError(state, format("{}=\"{}\", invalid {}=[{:.1T}].", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, s_ipsc->cNumericFieldNames(1), s_ipsc->rNumericArgs(1))); ShowContinueError(state, format("...because {}={} multiplier will be set to 1.0.", s_ipsc->cAlphaFieldNames(1), s_ipsc->cAlphaArgs(1))); - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Multiplier = 1.0; + surfTemp.Multiplier = 1.0; } MakeRelativeRectangularVertices(state, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).BaseSurf, + surfTemp.BaseSurf, SurfNum, s_ipsc->rNumericArgs(2), s_ipsc->rNumericArgs(3), s_ipsc->rNumericArgs(4), s_ipsc->rNumericArgs(5)); - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Area <= 0.0) { + if (surfTemp.Area <= 0.0) { ShowSevereError(state, format("{}=\"{}\", Surface Area <= 0.0; Entered Area={:.2T}", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Area)); + surfTemp.Name, + surfTemp.Area)); ErrorsFound = true; } - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).windowShadingControlList.clear(); - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).activeWindowShadingControl = 0; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).HasShadeControl = false; + surfTemp.windowShadingControlList.clear(); + surfTemp.activeWindowShadingControl = 0; + surfTemp.HasShadeControl = false; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).shadedConstructionList.clear(); - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).activeShadedConstruction = 0; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).shadedStormWinConstructionList.clear(); + surfTemp.shadedConstructionList.clear(); + surfTemp.activeShadedConstruction = 0; + surfTemp.shadedStormWinConstructionList.clear(); InitialAssociateWindowShadingControlFenestration(state, ErrorsFound, SurfNum); - if (!GettingIZSurfaces && (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class == SurfaceClass::Window || - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class == SurfaceClass::GlassDoor)) { + if (!GettingIZSurfaces && (surfTemp.Class == SurfaceClass::Window || + surfTemp.Class == SurfaceClass::GlassDoor)) { - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond == OtherSideCoefNoCalcExt || - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond == OtherSideCoefCalcExt) { + if (surfTemp.ExtBoundCond == OtherSideCoefNoCalcExt || + surfTemp.ExtBoundCond == OtherSideCoefCalcExt) { ShowSevereError(state, format("{}=\"{}\", Other side coefficients are not allowed with windows.", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name)); + surfTemp.Name)); ErrorsFound = true; } - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond == Ground) { + if (surfTemp.ExtBoundCond == Ground) { ShowSevereError(state, format("{}=\"{}\", Exterior boundary condition = Ground is not allowed with windows.", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name)); + surfTemp.Name)); ErrorsFound = true; } @@ -5754,29 +5745,29 @@ namespace SurfaceGeometry { auto &s_ipsc = state.dataIPShortCut; auto &s_mat = state.dataMaterial; - for (std::size_t shadeControlIndex = 0; shadeControlIndex < state.dataSurfaceGeometry->SurfaceTmp(SurfNum).windowShadingControlList.size(); + auto &surfTemp = state.dataSurfaceGeometry->SurfaceTmp(SurfNum); + + for (std::size_t shadeControlIndex = 0; shadeControlIndex < surfTemp.windowShadingControlList.size(); ++shadeControlIndex) { - int WSCPtr = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).windowShadingControlList[shadeControlIndex]; + int WSCPtr = surfTemp.windowShadingControlList[shadeControlIndex]; ConstrNumSh = 0; - if (!ErrorsFound && state.dataSurfaceGeometry->SurfaceTmp(SurfNum).HasShadeControl) { - ConstrNumSh = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).shadedConstructionList[shadeControlIndex]; + if (!ErrorsFound && surfTemp.HasShadeControl) { + ConstrNumSh = surfTemp.shadedConstructionList[shadeControlIndex]; if (ConstrNumSh > 0) { - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).activeShadedConstruction = ConstrNumSh; - } else { - if (ANY_INTERIOR_SHADE_BLIND(state.dataSurface->WindowShadingControl(WSCPtr).ShadingType) || - ANY_EXTERIOR_SHADE_BLIND_SCREEN(state.dataSurface->WindowShadingControl(WSCPtr).ShadingType)) { - ShDevNum = state.dataSurface->WindowShadingControl(WSCPtr).ShadingDevice; - if (ShDevNum > 0) { - CreateShadedWindowConstruction(state, SurfNum, WSCPtr, ShDevNum, shadeControlIndex); - ConstrNumSh = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).activeShadedConstruction; - } + surfTemp.activeShadedConstruction = ConstrNumSh; + } else if (ANY_INTERIOR_SHADE_BLIND(state.dataSurface->WindowShadingControl(WSCPtr).ShadingType) || + ANY_EXTERIOR_SHADE_BLIND_SCREEN(state.dataSurface->WindowShadingControl(WSCPtr).ShadingType)) { + ShDevNum = state.dataSurface->WindowShadingControl(WSCPtr).ShadingDevice; + if (ShDevNum > 0) { + CreateShadedWindowConstruction(state, SurfNum, WSCPtr, ShDevNum, shadeControlIndex); + ConstrNumSh = surfTemp.activeShadedConstruction; } } } // Error checks for shades and blinds - ConstrNum = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction; + ConstrNum = surfTemp.Construction; if (!ErrorsFound && WSCPtr > 0 && ConstrNum > 0 && ConstrNumSh > 0) { if (ANY_INTERIOR_SHADE_BLIND(state.dataSurface->WindowShadingControl(WSCPtr).ShadingType)) { @@ -5799,7 +5790,7 @@ namespace SurfaceGeometry { ErrorsFound = true; ShowSevereError(state, format(" The glass and gas layers in the shaded and unshaded constructions do not match for window={}", - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name)); + surfTemp.Name)); ShowContinueError(state, format("Unshaded construction={}", state.dataConstruction->Construct(ConstrNum).Name)); ShowContinueError(state, format("Shaded construction={}", state.dataConstruction->Construct(ConstrNumSh).Name)); break; @@ -5827,7 +5818,7 @@ namespace SurfaceGeometry { ErrorsFound = true; ShowSevereError(state, format(" The glass and gas layers in the shaded and unshaded constructions do not match for window={}", - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name)); + surfTemp.Name)); ShowContinueError(state, format("Unshaded construction={}", state.dataConstruction->Construct(ConstrNum).Name)); ShowContinueError(state, format("Shaded construction={}", state.dataConstruction->Construct(ConstrNumSh).Name)); break; @@ -5837,13 +5828,13 @@ namespace SurfaceGeometry { if (ANY_BETWEENGLASS_SHADE_BLIND(state.dataSurface->WindowShadingControl(WSCPtr).ShadingType)) { // Divider not allowed with between-glass shade or blind - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).FrameDivider > 0) { - if (state.dataSurface->FrameDivider(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).FrameDivider).DividerWidth > 0.0) { + if (surfTemp.FrameDivider > 0) { + if (state.dataSurface->FrameDivider(surfTemp.FrameDivider).DividerWidth > 0.0) { ShowWarningError( - state, format("A divider cannot be specified for window {}", state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name)); + state, format("A divider cannot be specified for window {}", surfTemp.Name)); ShowContinueError(state, ", which has a between-glass shade or blind."); ShowContinueError(state, "Calculation will proceed without the divider for this window."); - state.dataSurface->FrameDivider(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).FrameDivider).DividerWidth = 0.0; + state.dataSurface->FrameDivider(surfTemp.FrameDivider).DividerWidth = 0.0; } } // Check consistency of gap widths between unshaded and shaded constructions @@ -5903,7 +5894,7 @@ namespace SurfaceGeometry { "are inconsistent with the gap widths for shaded window construction " + state.dataConstruction->Construct(ConstrNumSh).Name); ShowContinueError(state, - "for window " + state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name + + "for window " + surfTemp.Name + ", which has a between-glass blind."); ShowContinueError( state, @@ -5932,7 +5923,7 @@ namespace SurfaceGeometry { "are inconsistent with the gap widths for shaded window construction " + state.dataConstruction->Construct(ConstrNumSh).Name); ShowContinueError(state, - "for window " + state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name + + "for window " + surfTemp.Name + ", which has a between-glass shade."); ShowContinueError( state, @@ -5958,7 +5949,7 @@ namespace SurfaceGeometry { } } - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides != 3) { // Rectangular Window + if (surfTemp.Sides != 3) { // Rectangular Window // Initialize the FrameDivider number for this window. W5FrameDivider will be positive if // this window's construction came from the Window5 data file and that construction had an // associated frame or divider. It will be zero if the window's construction is not from the @@ -5966,32 +5957,32 @@ namespace SurfaceGeometry { // associated frame or divider. Note that if there is a FrameDivider candidate for this // window from the Window5 data file it is used instead of the window's input FrameDivider. - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction != 0) { - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).FrameDivider = - state.dataConstruction->Construct(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction).W5FrameDivider; + if (surfTemp.Construction != 0) { + surfTemp.FrameDivider = + state.dataConstruction->Construct(surfTemp.Construction).W5FrameDivider; // Warning if FrameAndDivider for this window is over-ridden by one from Window5 Data File - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).FrameDivider > 0 && !s_ipsc->lAlphaFieldBlanks(FrameField)) { + if (surfTemp.FrameDivider > 0 && !s_ipsc->lAlphaFieldBlanks(FrameField)) { ShowSevereError(state, format("{}=\"{}\", {}=\"{}\"", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, s_ipsc->cAlphaFieldNames(FrameField), s_ipsc->cAlphaArgs(FrameField))); ShowContinueError(state, format("will be replaced with FrameAndDivider from Window5 Data File entry {}", - state.dataConstruction->Construct(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction).Name)); + state.dataConstruction->Construct(surfTemp.Construction).Name)); } - if (!s_ipsc->lAlphaFieldBlanks(FrameField) && state.dataSurfaceGeometry->SurfaceTmp(SurfNum).FrameDivider == 0) { - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).FrameDivider = + if (!s_ipsc->lAlphaFieldBlanks(FrameField) && surfTemp.FrameDivider == 0) { + surfTemp.FrameDivider = Util::FindItemInList(s_ipsc->cAlphaArgs(FrameField), state.dataSurface->FrameDivider); - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).FrameDivider == 0) { - if (!state.dataConstruction->Construct(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction).WindowTypeEQL) { + if (surfTemp.FrameDivider == 0) { + if (!state.dataConstruction->Construct(surfTemp.Construction).WindowTypeEQL) { ShowSevereError(state, format("{}=\"{}\", invalid {}=\"{}\"", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, s_ipsc->cAlphaFieldNames(FrameField), s_ipsc->cAlphaArgs(FrameField))); ErrorsFound = true; @@ -5999,23 +5990,23 @@ namespace SurfaceGeometry { ShowSevereError(state, format("{}=\"{}\", invalid {}=\"{}\"", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, s_ipsc->cAlphaFieldNames(FrameField), s_ipsc->cAlphaArgs(FrameField))); ShowContinueError(state, "...Frame/Divider is not supported in Equivalent Layer Window model."); } } // Divider not allowed with between-glass shade or blind - for (int WSCPtr : state.dataSurfaceGeometry->SurfaceTmp(SurfNum).windowShadingControlList) { + for (int WSCPtr : surfTemp.windowShadingControlList) { if (!ErrorsFound && WSCPtr > 0 && ConstrNumSh > 0) { if (ANY_BETWEENGLASS_SHADE_BLIND(state.dataSurface->WindowShadingControl(WSCPtr).ShadingType)) { - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).FrameDivider > 0) { - if (state.dataSurface->FrameDivider(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).FrameDivider).DividerWidth > + if (surfTemp.FrameDivider > 0) { + if (state.dataSurface->FrameDivider(surfTemp.FrameDivider).DividerWidth > 0.0) { ShowSevereError(state, format("{}=\"{}\", invalid {}=\"{}\"", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, s_ipsc->cAlphaFieldNames(FrameField), s_ipsc->cAlphaArgs(FrameField))); ShowContinueError(state, @@ -6024,9 +6015,9 @@ namespace SurfaceGeometry { ShowContinueError( state, format("Divider width = [{:.2R}].", - state.dataSurface->FrameDivider(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).FrameDivider) + state.dataSurface->FrameDivider(surfTemp.FrameDivider) .DividerWidth)); - state.dataSurface->FrameDivider(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).FrameDivider).DividerWidth = + state.dataSurface->FrameDivider(surfTemp.FrameDivider).DividerWidth = 0.0; } } // End of check if window has divider @@ -6037,17 +6028,17 @@ namespace SurfaceGeometry { } // End of check if window has a construction } - if (state.dataConstruction->Construct(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction).WindowTypeEQL) { - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).FrameDivider > 0) { + if (state.dataConstruction->Construct(surfTemp.Construction).WindowTypeEQL) { + if (surfTemp.FrameDivider > 0) { // Equivalent Layer window does not have frame/divider model ShowSevereError(state, format("{}=\"{}\", invalid {}=\"{}\"", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, s_ipsc->cAlphaFieldNames(FrameField), s_ipsc->cAlphaArgs(FrameField))); ShowContinueError(state, "Frame/Divider is not supported in Equivalent Layer Window model."); - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).FrameDivider = 0; + surfTemp.FrameDivider = 0; } } } @@ -6084,14 +6075,14 @@ namespace SurfaceGeometry { auto &s_mat = state.dataMaterial; // Warning if window has multiplier > 1 and SolarDistribution = FullExterior or FullInteriorExterior - if ((state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class == SurfaceClass::Window || - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class == SurfaceClass::GlassDoor) && + auto &surfTemp = state.dataSurfaceGeometry->SurfaceTmp(SurfNum); + if ((surfTemp.Class == SurfaceClass::Window || surfTemp.Class == SurfaceClass::GlassDoor) && static_cast(state.dataHeatBal->SolarDistribution) > static_cast(DataHeatBalance::Shadowing::Minimal) && - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Multiplier > 1.0) { + surfTemp.Multiplier > 1.0) { if (state.dataGlobal->DisplayExtraWarnings) { ShowWarningError( state, - format("{}: A Multiplier > 1.0 for window/glass door {}", cRoutineName, state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name)); + format("{}: A Multiplier > 1.0 for window/glass door {}", cRoutineName, surfTemp.Name)); ShowContinueError(state, "in conjunction with SolarDistribution = FullExterior or FullInteriorExterior"); ShowContinueError(state, "can cause inaccurate shadowing on the window and/or"); ShowContinueError(state, "inaccurate interior solar distribution from the window."); @@ -6101,7 +6092,7 @@ namespace SurfaceGeometry { // Require that a construction referenced by a surface that is a window // NOT have a shading device layer; use WindowShadingControl to specify a shading device. - ConstrNum = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction; + ConstrNum = surfTemp.Construction; if (ConstrNum > 0) { NumShades = 0; for (Lay = 1; Lay <= state.dataConstruction->Construct(ConstrNum).TotLayers; ++Lay) { @@ -6121,10 +6112,10 @@ namespace SurfaceGeometry { // Disallow glass transmittance dirt factor for interior windows and glass doors - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond != ExternalEnvironment && - (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class == SurfaceClass::Window || - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class == SurfaceClass::GlassDoor)) { - ConstrNum = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction; + if (surfTemp.ExtBoundCond != ExternalEnvironment && + (surfTemp.Class == SurfaceClass::Window || + surfTemp.Class == SurfaceClass::GlassDoor)) { + ConstrNum = surfTemp.Construction; if (ConstrNum > 0) { for (Lay = 1; Lay <= state.dataConstruction->Construct(ConstrNum).TotLayers; ++Lay) { LayerPtr = state.dataConstruction->Construct(ConstrNum).LayerPoint(Lay); @@ -6147,9 +6138,9 @@ namespace SurfaceGeometry { // (2) if two glazing systems (separated by a mullion) on Data File, create a second window // and adjust the dimensions of the original and second windows to those on the Data File - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction != 0) { + if (surfTemp.Construction != 0) { - if (state.dataConstruction->Construct(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction).FromWindow5DataFile) { + if (state.dataConstruction->Construct(surfTemp.Construction).FromWindow5DataFile) { ModifyWindow(state, SurfNum, ErrorsFound, AddedSubSurfaces); @@ -6157,43 +6148,43 @@ namespace SurfaceGeometry { // Calculate net area for base surface (note that ModifyWindow, above, adjusts net area of // base surface for case where window construction is from Window5 Data File // In case there is in error in this window's base surface (i.e. none).. - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).BaseSurf > 0) { - state.dataSurfaceGeometry->SurfaceTmp(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).BaseSurf).Area -= - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Area; + if (surfTemp.BaseSurf > 0) { + state.dataSurfaceGeometry->SurfaceTmp(surfTemp.BaseSurf).Area -= + surfTemp.Area; // Subtract TDD:DIFFUSER area from other side interzone surface - if ((state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class == SurfaceClass::TDD_Diffuser) && - not_blank(state.dataSurfaceGeometry->SurfaceTmp(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).BaseSurf) + if ((surfTemp.Class == SurfaceClass::TDD_Diffuser) && + not_blank(state.dataSurfaceGeometry->SurfaceTmp(surfTemp.BaseSurf) .ExtBoundCondName)) { // Base surface is an interzone surface // Lookup interzone surface of the base surface // (Interzone surfaces have not been assigned yet, but all base surfaces should already be loaded.) Found = Util::FindItemInList( - state.dataSurfaceGeometry->SurfaceTmp(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).BaseSurf).ExtBoundCondName, + state.dataSurfaceGeometry->SurfaceTmp(surfTemp.BaseSurf).ExtBoundCondName, state.dataSurfaceGeometry->SurfaceTmp, SurfNum); - if (Found != 0) state.dataSurfaceGeometry->SurfaceTmp(Found).Area -= state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Area; + if (Found != 0) state.dataSurfaceGeometry->SurfaceTmp(Found).Area -= surfTemp.Area; } - if (state.dataSurfaceGeometry->SurfaceTmp(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).BaseSurf).Area <= 0.0) { + if (state.dataSurfaceGeometry->SurfaceTmp(surfTemp.BaseSurf).Area <= 0.0) { ShowSevereError(state, format("{}: Surface Openings have too much area for base surface={}", cRoutineName, - state.dataSurfaceGeometry->SurfaceTmp(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).BaseSurf).Name)); - ShowContinueError(state, format("Opening Surface creating error={}", state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name)); + state.dataSurfaceGeometry->SurfaceTmp(surfTemp.BaseSurf).Name)); + ShowContinueError(state, format("Opening Surface creating error={}", surfTemp.Name)); ErrorsFound = true; } // Net area of base surface with unity window multipliers (used in shadowing checks) // For Windows, Glass Doors and Doors, just one area is subtracted. For the rest, should be // full area. - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class == SurfaceClass::Window || - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class == SurfaceClass::GlassDoor) { - state.dataSurfaceGeometry->SurfaceTmp(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).BaseSurf).NetAreaShadowCalc -= - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Area / state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Multiplier; - } else if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class == SurfaceClass::Door) { // Door, TDD:Diffuser, TDD:DOME - state.dataSurfaceGeometry->SurfaceTmp(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).BaseSurf).NetAreaShadowCalc -= - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Area / state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Multiplier; + if (surfTemp.Class == SurfaceClass::Window || + surfTemp.Class == SurfaceClass::GlassDoor) { + state.dataSurfaceGeometry->SurfaceTmp(surfTemp.BaseSurf).NetAreaShadowCalc -= + surfTemp.Area / surfTemp.Multiplier; + } else if (surfTemp.Class == SurfaceClass::Door) { // Door, TDD:Diffuser, TDD:DOME + state.dataSurfaceGeometry->SurfaceTmp(surfTemp.BaseSurf).NetAreaShadowCalc -= + surfTemp.Area / surfTemp.Multiplier; } else { - state.dataSurfaceGeometry->SurfaceTmp(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).BaseSurf).NetAreaShadowCalc -= - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Area; + state.dataSurfaceGeometry->SurfaceTmp(surfTemp.BaseSurf).NetAreaShadowCalc -= + surfTemp.Area; } } } @@ -6263,15 +6254,16 @@ namespace SurfaceGeometry { // Tilt and Facing (Azimuth) will be same as the Base Surface - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Height = Height; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Width = Length; + auto &surfTemp = state.dataSurfaceGeometry->SurfaceTmp(SurfNum); + surfTemp.Height = Height; + surfTemp.Width = Length; - SurfAzimuth = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Azimuth; - SurfTilt = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Tilt; - CosSurfAzimuth = std::cos(SurfAzimuth * Constant::DegToRadians); - SinSurfAzimuth = std::sin(SurfAzimuth * Constant::DegToRadians); - CosSurfTilt = std::cos(SurfTilt * Constant::DegToRadians); - SinSurfTilt = std::sin(SurfTilt * Constant::DegToRadians); + SurfAzimuth = surfTemp.Azimuth; + SurfTilt = surfTemp.Tilt; + CosSurfAzimuth = std::cos(SurfAzimuth * Constant::DegToRad); + SinSurfAzimuth = std::sin(SurfAzimuth * Constant::DegToRad); + CosSurfTilt = std::cos(SurfTilt * Constant::DegToRad); + SinSurfTilt = std::sin(SurfTilt * Constant::DegToRad); BaseCosSurfAzimuth = state.dataSurfaceGeometry->SurfaceTmp(BaseSurfNum).CosAzim; BaseSinSurfAzimuth = state.dataSurfaceGeometry->SurfaceTmp(BaseSurfNum).SinAzim; BaseCosSurfTilt = state.dataSurfaceGeometry->SurfaceTmp(BaseSurfNum).CosTilt; @@ -6292,51 +6284,51 @@ namespace SurfaceGeometry { YY(3) = 0.0; YY(2) = 0.0; - for (n = 1; n <= state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides; ++n) { + for (n = 1; n <= surfTemp.Sides; ++n) { Vrt = n; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(Vrt).x = XLLC - XX(n) * CosSurfAzimuth - YY(n) * CosSurfTilt * SinSurfAzimuth; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(Vrt).y = YLLC + XX(n) * SinSurfAzimuth - YY(n) * CosSurfTilt * CosSurfAzimuth; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(Vrt).z = ZLLC + YY(n) * SinSurfTilt; - } - - CreateNewellAreaVector(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).NewellAreaVector); - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).GrossArea = VecLength(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).NewellAreaVector); - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Area = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).GrossArea; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).NetAreaShadowCalc = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Area; - CreateNewellSurfaceNormalVector(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).NewellSurfaceNormalVector); - DetermineAzimuthAndTilt(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex, + surfTemp.Vertex(Vrt).x = XLLC - XX(n) * CosSurfAzimuth - YY(n) * CosSurfTilt * SinSurfAzimuth; + surfTemp.Vertex(Vrt).y = YLLC + XX(n) * SinSurfAzimuth - YY(n) * CosSurfTilt * CosSurfAzimuth; + surfTemp.Vertex(Vrt).z = ZLLC + YY(n) * SinSurfTilt; + } + + CreateNewellAreaVector(surfTemp.Vertex, + surfTemp.Sides, + surfTemp.NewellAreaVector); + surfTemp.GrossArea = VecLength(surfTemp.NewellAreaVector); + surfTemp.Area = surfTemp.GrossArea; + surfTemp.NetAreaShadowCalc = surfTemp.Area; + CreateNewellSurfaceNormalVector(surfTemp.Vertex, + surfTemp.Sides, + surfTemp.NewellSurfaceNormalVector); + DetermineAzimuthAndTilt(surfTemp.Vertex, SurfAzimuth, SurfTilt, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).lcsx, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).lcsy, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).lcsz, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).NewellSurfaceNormalVector); - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Azimuth = SurfAzimuth; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Tilt = SurfTilt; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).convOrientation = - Convect::GetSurfConvOrientation(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Tilt); + surfTemp.lcsx, + surfTemp.lcsy, + surfTemp.lcsz, + surfTemp.NewellSurfaceNormalVector); + surfTemp.Azimuth = SurfAzimuth; + surfTemp.Tilt = SurfTilt; + surfTemp.convOrientation = + Convect::GetSurfConvOrientation(surfTemp.Tilt); // Sine and cosine of azimuth and tilt - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).SinAzim = SinSurfAzimuth; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).CosAzim = CosSurfAzimuth; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).SinTilt = SinSurfTilt; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).CosTilt = CosSurfTilt; - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class != SurfaceClass::Window && - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class != SurfaceClass::GlassDoor && - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class != SurfaceClass::Door) - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ViewFactorGround = 0.5 * (1.0 - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).CosTilt); + surfTemp.SinAzim = SinSurfAzimuth; + surfTemp.CosAzim = CosSurfAzimuth; + surfTemp.SinTilt = SinSurfTilt; + surfTemp.CosTilt = CosSurfTilt; + if (surfTemp.Class != SurfaceClass::Window && + surfTemp.Class != SurfaceClass::GlassDoor && + surfTemp.Class != SurfaceClass::Door) + surfTemp.ViewFactorGround = 0.5 * (1.0 - surfTemp.CosTilt); // Outward normal unit vector (pointing away from room) - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).OutNormVec = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).NewellSurfaceNormalVector; + surfTemp.OutNormVec = surfTemp.NewellSurfaceNormalVector; for (n = 1; n <= 3; ++n) { - if (std::abs(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).OutNormVec(n) - 1.0) < 1.e-06) - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).OutNormVec(n) = +1.0; - if (std::abs(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).OutNormVec(n) + 1.0) < 1.e-06) - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).OutNormVec(n) = -1.0; - if (std::abs(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).OutNormVec(n)) < 1.e-06) - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).OutNormVec(n) = 0.0; + if (std::abs(surfTemp.OutNormVec(n) - 1.0) < 1.e-06) + surfTemp.OutNormVec(n) = +1.0; + if (std::abs(surfTemp.OutNormVec(n) + 1.0) < 1.e-06) + surfTemp.OutNormVec(n) = -1.0; + if (std::abs(surfTemp.OutNormVec(n)) < 1.e-06) + surfTemp.OutNormVec(n) = 0.0; } // IF (SurfaceTmp(SurfNum)%Class == SurfaceClass::Roof .and. SurfTilt > 80.) THEN @@ -6350,29 +6342,29 @@ namespace SurfaceGeometry { // expected tilt of 180,'// & // ' for Surface='//TRIM(SurfaceTmp(SurfNum)%Name)// & // ', in Zone='//TRIM(SurfaceTmp(SurfNum)%ZoneName)), //, ENDIF, if, - // (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class, ==, SurfaceClass::Window, ||, - // state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class, ==, SurfaceClass::GlassDoor, ||, - // state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class, ==, SurfaceClass::Door), - // state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Area, *=, - // state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Multiplier;, //, Can, perform, tests, on, this, surface, here, - // state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ViewFactorSky, =, 0.5, *, (1.0, - // state.dataSurfaceGeometry->SurfaceTmp(SurfNum).CosTilt)); + // (surfTemp.Class, ==, SurfaceClass::Window, ||, + // surfTemp.Class, ==, SurfaceClass::GlassDoor, ||, + // surfTemp.Class, ==, SurfaceClass::Door), + // surfTemp.Area, *=, + // surfTemp.Multiplier;, //, Can, perform, tests, on, this, surface, here, + // surfTemp.ViewFactorSky, =, 0.5, *, (1.0, + // surfTemp.CosTilt)); // The following IR view factors are modified in subr. SkyDifSolarShading if there are shadowing // surfaces - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ViewFactorSkyIR = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ViewFactorSky; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ViewFactorGroundIR = 0.5 * (1.0 - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).CosTilt); + surfTemp.ViewFactorSkyIR = surfTemp.ViewFactorSky; + surfTemp.ViewFactorGroundIR = 0.5 * (1.0 - surfTemp.CosTilt); - Perimeter = distance(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides), - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(1)); - for (Vrt = 2; Vrt <= state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides; ++Vrt) { + Perimeter = distance(surfTemp.Vertex(surfTemp.Sides), + surfTemp.Vertex(1)); + for (Vrt = 2; Vrt <= surfTemp.Sides; ++Vrt) { Perimeter += - distance(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(Vrt), state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(Vrt - 1)); + distance(surfTemp.Vertex(Vrt), surfTemp.Vertex(Vrt - 1)); } - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Perimeter = Perimeter; + surfTemp.Perimeter = Perimeter; // Call to transform vertices - TransformVertsByAspect(state, SurfNum, state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides); + TransformVertsByAspect(state, SurfNum, surfTemp.Sides); } void GetAttShdSurfaceData(EnergyPlusData &state, @@ -6389,12 +6381,8 @@ namespace SurfaceGeometry { // This subroutine gets the HeatTransfer Surface Data, // checks it for errors, etc. - // Using/Aliasing - using ScheduleManager::CheckScheduleValueMinMax; - using ScheduleManager::GetScheduleIndex; - using ScheduleManager::GetScheduleMaxValue; - using ScheduleManager::GetScheduleMinValue; - + static constexpr std::string_view routineName = "GetAttShdSurfaceData"; + // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int IOStat; // IO Status when calling get input subroutine int NumAlphas; // Number of alpha names being passed @@ -6431,6 +6419,8 @@ namespace SurfaceGeometry { s_ipsc->cAlphaFieldNames, s_ipsc->cNumericFieldNames); + ErrorObjectHeader eoh{routineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)}; + if (GlobalNames::VerifyUniqueInterObjectName(state, state.dataSurfaceGeometry->UniqueSurfaceNames, s_ipsc->cAlphaArgs(1), @@ -6441,142 +6431,113 @@ namespace SurfaceGeometry { } ++SurfNum; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name = s_ipsc->cAlphaArgs(1); // Set the Surface Name in the Derived Type - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class = SurfaceClass::Shading; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).HeatTransSurf = false; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).BaseSurfName = s_ipsc->cAlphaArgs(2); + auto &surfTemp = state.dataSurfaceGeometry->SurfaceTmp(SurfNum); + + surfTemp.Name = s_ipsc->cAlphaArgs(1); // Set the Surface Name in the Derived Type + surfTemp.Class = SurfaceClass::Shading; + surfTemp.HeatTransSurf = false; + surfTemp.BaseSurfName = s_ipsc->cAlphaArgs(2); // The subsurface inherits properties from the base surface // Exterior conditions, Zone, etc. // We can figure out the base surface though, because they've all been entered Found = Util::FindItemInList( - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).BaseSurfName, state.dataSurfaceGeometry->SurfaceTmp, state.dataSurface->TotSurfaces); + surfTemp.BaseSurfName, state.dataSurfaceGeometry->SurfaceTmp, state.dataSurface->TotSurfaces); if (Found > 0) { // SurfaceTmp(SurfNum)%BaseSurf=Found - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond = state.dataSurfaceGeometry->SurfaceTmp(Found).ExtBoundCond; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtSolar = state.dataSurfaceGeometry->SurfaceTmp(Found).ExtSolar; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtWind = state.dataSurfaceGeometry->SurfaceTmp(Found).ExtWind; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Zone = + surfTemp.ExtBoundCond = state.dataSurfaceGeometry->SurfaceTmp(Found).ExtBoundCond; + surfTemp.ExtSolar = state.dataSurfaceGeometry->SurfaceTmp(Found).ExtSolar; + surfTemp.ExtWind = state.dataSurfaceGeometry->SurfaceTmp(Found).ExtWind; + surfTemp.Zone = state.dataSurfaceGeometry->SurfaceTmp(Found).Zone; // Necessary to do relative coordinates in GetVertices below - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ZoneName = + surfTemp.ZoneName = state.dataSurfaceGeometry->SurfaceTmp(Found).ZoneName; // Necessary to have surface drawn in OutputReports } else { ShowSevereError(state, format("{}=\"{}\", invalid {}=\"{}", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2))); ErrorsFound = true; } - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond == UnenteredAdjacentZoneSurface) { + if (surfTemp.ExtBoundCond == UnenteredAdjacentZoneSurface) { ShowSevereError(state, format("{}=\"{}\", invalid {}=\"{}", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2))); ShowContinueError(state, "...trying to attach a shading device to an interzone surface."); ErrorsFound = true; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond = + surfTemp.ExtBoundCond = ExternalEnvironment; // reset so program won't crash during "add surfaces" } - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond == UnreconciledZoneSurface) { + if (surfTemp.ExtBoundCond == UnreconciledZoneSurface) { ShowSevereError(state, format("{}=\"{}\", invalid {}=\"{}", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2))); ShowContinueError(state, "...trying to attach a shading device to an interior surface."); ErrorsFound = true; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond = + surfTemp.ExtBoundCond = ExternalEnvironment; // reset so program won't crash during "add surfaces" } - if (!s_ipsc->lAlphaFieldBlanks(3)) { - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).SchedShadowSurfIndex = GetScheduleIndex(state, s_ipsc->cAlphaArgs(3)); - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).SchedShadowSurfIndex == 0) { - ShowSevereError(state, - format("{}=\"{}\", {} not found=\"{}", - s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, - s_ipsc->cAlphaFieldNames(3), - s_ipsc->cAlphaArgs(3))); - ErrorsFound = true; - } + if (s_ipsc->lAlphaFieldBlanks(3)) { + surfTemp.shadowSurfSched = Sched::GetScheduleAlwaysOff(state); + } else if ((surfTemp.shadowSurfSched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(3))) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(3), s_ipsc->cAlphaArgs(3)); + ErrorsFound = true; + } else if (!surfTemp.shadowSurfSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) { + Sched::ShowSevereBadMinMax(state, eoh, s_ipsc->cAlphaFieldNames(3), s_ipsc->cAlphaArgs(3), Clusive::In, 0.0, Clusive::In, 1.0); + ErrorsFound = true; } else { - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).SchedShadowSurfIndex = 0; - } - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).SchedShadowSurfIndex != 0) { - if (!CheckScheduleValueMinMax(state, state.dataSurfaceGeometry->SurfaceTmp(SurfNum).SchedShadowSurfIndex, ">=", 0.0, "<=", 1.0)) { - ShowSevereError(state, - format("{}=\"{}\", {}=\"{}\", values not in range [0,1].", - s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, - s_ipsc->cAlphaFieldNames(3), - s_ipsc->cAlphaArgs(3))); - ErrorsFound = true; - } - SchedMinValue = GetScheduleMinValue(state, state.dataSurfaceGeometry->SurfaceTmp(SurfNum).SchedShadowSurfIndex); - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).SchedMinValue = SchedMinValue; - SchedMaxValue = GetScheduleMaxValue(state, state.dataSurfaceGeometry->SurfaceTmp(SurfNum).SchedShadowSurfIndex); + + SchedMinValue = surfTemp.shadowSurfSched->getMinVal(state); + surfTemp.SchedMinValue = SchedMinValue; + SchedMaxValue = surfTemp.shadowSurfSched->getMaxVal(state); if (SchedMinValue == 1.0) { // Set transparent for now, check for EMS actuators later in SolarShading::resetShadingSurfaceTransparency - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).IsTransparent = true; - } - if (SchedMinValue < 0.0) { - ShowSevereError(state, - format("{}=\"{}\", {}=\"{}\", has schedule values < 0.", - s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, - s_ipsc->cAlphaFieldNames(2), - s_ipsc->cAlphaArgs(2))); - ShowContinueError(state, "...Schedule values < 0 have no meaning for shading elements."); + surfTemp.IsTransparent = true; } if (SchedMaxValue > 0.0) { state.dataSolarShading->anyScheduledShadingSurface = true; } - if (SchedMaxValue > 1.0) { - ShowSevereError(state, - format("{}=\"{}\", {}=\"{}\", has schedule values > 1.", - s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, - s_ipsc->cAlphaFieldNames(2), - s_ipsc->cAlphaArgs(2))); - ShowContinueError(state, "...Schedule values > 1 have no meaning for shading elements."); - } - if (std::abs(SchedMinValue - SchedMaxValue) > Constant::OneMillionth) { + if (SchedMaxValue - SchedMinValue > Constant::OneMillionth) { state.dataSurface->ShadingTransmittanceVaries = true; } } + if (s_ipsc->lNumericFieldBlanks(1) || s_ipsc->rNumericArgs(1) == Constant::AutoCalculate) { s_ipsc->rNumericArgs(1) = (NumNumbers - 1) / 3; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides = s_ipsc->rNumericArgs(1); + surfTemp.Sides = s_ipsc->rNumericArgs(1); if (mod(NumNumbers - 1, 3) != 0) { ShowWarningError(state, format("{}=\"{}\", {}", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, format("{} not even multiple of 3. Will read in {}", s_ipsc->cNumericFieldNames(1), - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides))); + surfTemp.Sides))); } if (s_ipsc->rNumericArgs(1) < 3) { ShowSevereError(state, format("{}=\"{}\", {} (autocalculate) must be >= 3. Only {} provided.", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, s_ipsc->cNumericFieldNames(1), - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides)); + surfTemp.Sides)); ErrorsFound = true; continue; } } else { - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides = s_ipsc->rNumericArgs(1); + surfTemp.Sides = s_ipsc->rNumericArgs(1); } - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex.allocate(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides); - GetVertices(state, SurfNum, state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides, s_ipsc->rNumericArgs({2, _})); - CheckConvexity(state, SurfNum, state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides); + surfTemp.Vertex.allocate(surfTemp.Sides); + GetVertices(state, SurfNum, surfTemp.Sides, s_ipsc->rNumericArgs({2, _})); + CheckConvexity(state, SurfNum, surfTemp.Sides); // IF (SurfaceTmp(SurfNum)%Sides == 3) THEN // CALL ShowWarningError(state, TRIM(s_ipsc->cCurrentModuleObject)//'="'//TRIM(SurfaceTmp(SurfNum)%Name)// & // ' should not be triangular.') @@ -6584,9 +6545,9 @@ namespace SurfaceGeometry { // ErrorsFound=.TRUE. // ENDIF // Reset surface to be "detached" - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).BaseSurf = 0; + surfTemp.BaseSurf = 0; // SurfaceTmp(SurfNum)%BaseSurfName=' ' - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Zone = 0; + surfTemp.Zone = 0; // SurfaceTmp(SurfNum)%ZoneName=' ' if (state.dataReportFlag->MakeMirroredAttachedShading) { MakeMirrorSurface(state, SurfNum); @@ -6681,57 +6642,59 @@ namespace SurfaceGeometry { } ++SurfNum; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name = s_ipsc->cAlphaArgs(1); // Set the Surface Name in the Derived Type - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class = SurfaceClass::Shading; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).HeatTransSurf = false; + auto &surfTemp = state.dataSurfaceGeometry->SurfaceTmp(SurfNum); + + surfTemp.Name = s_ipsc->cAlphaArgs(1); // Set the Surface Name in the Derived Type + surfTemp.Class = SurfaceClass::Shading; + surfTemp.HeatTransSurf = false; // this object references a window or door.... Found = Util::FindItemInList(s_ipsc->cAlphaArgs(2), state.dataSurfaceGeometry->SurfaceTmp, state.dataSurface->TotSurfaces); if (Found > 0) { BaseSurfNum = state.dataSurfaceGeometry->SurfaceTmp(Found).BaseSurf; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).BaseSurfName = state.dataSurfaceGeometry->SurfaceTmp(Found).BaseSurfName; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond = state.dataSurfaceGeometry->SurfaceTmp(Found).ExtBoundCond; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtSolar = state.dataSurfaceGeometry->SurfaceTmp(Found).ExtSolar; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtWind = state.dataSurfaceGeometry->SurfaceTmp(Found).ExtWind; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Zone = + surfTemp.BaseSurfName = state.dataSurfaceGeometry->SurfaceTmp(Found).BaseSurfName; + surfTemp.ExtBoundCond = state.dataSurfaceGeometry->SurfaceTmp(Found).ExtBoundCond; + surfTemp.ExtSolar = state.dataSurfaceGeometry->SurfaceTmp(Found).ExtSolar; + surfTemp.ExtWind = state.dataSurfaceGeometry->SurfaceTmp(Found).ExtWind; + surfTemp.Zone = state.dataSurfaceGeometry->SurfaceTmp(Found).Zone; // Necessary to do relative coordinates in GetVertices below - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ZoneName = + surfTemp.ZoneName = state.dataSurfaceGeometry->SurfaceTmp(Found).ZoneName; // Necessary to have surface drawn in OutputReports } else { ShowSevereError(state, format("{}=\"{}\", invalid {}=\"{}", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2))); ErrorsFound = true; continue; } - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond == UnenteredAdjacentZoneSurface) { + if (surfTemp.ExtBoundCond == UnenteredAdjacentZoneSurface) { ShowSevereError(state, format("{}=\"{}\", invalid {}=\"{}", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2))); ShowContinueError(state, "...trying to attach a shading device to an interzone surface."); ErrorsFound = true; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond = + surfTemp.ExtBoundCond = ExternalEnvironment; // reset so program won't crash during "add surfaces" } - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond == UnreconciledZoneSurface) { + if (surfTemp.ExtBoundCond == UnreconciledZoneSurface) { ShowSevereError(state, format("{}=\"{}\", invalid {}=\"{}", s_ipsc->cCurrentModuleObject, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2))); ShowContinueError(state, "...trying to attach a shading device to an interior surface."); ErrorsFound = true; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond = + surfTemp.ExtBoundCond = ExternalEnvironment; // reset so program won't crash during "add surfaces" } - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).SchedShadowSurfIndex = 0; + surfTemp.shadowSurfSched = nullptr; //===== Overhang ===== @@ -6771,10 +6734,10 @@ namespace SurfaceGeometry { } TiltAngle = state.dataSurfaceGeometry->SurfaceTmp(Found).Tilt + s_ipsc->rNumericArgs(2); - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Tilt = TiltAngle; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).convOrientation = - Convect::GetSurfConvOrientation(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Tilt); - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Azimuth = state.dataSurfaceGeometry->SurfaceTmp(Found).Azimuth; + surfTemp.Tilt = TiltAngle; + surfTemp.convOrientation = + Convect::GetSurfConvOrientation(surfTemp.Tilt); + surfTemp.Azimuth = state.dataSurfaceGeometry->SurfaceTmp(Found).Azimuth; // Make it relative to surface origin..... Xp = state.dataSurfaceGeometry->SurfaceTmp(Found).Vertex(2).x - state.dataSurfaceGeometry->SurfaceTmp(BaseSurfNum).Vertex(2).x; @@ -6790,8 +6753,8 @@ namespace SurfaceGeometry { Yp * state.dataSurfaceGeometry->SurfaceTmp(BaseSurfNum).CosAzim * state.dataSurfaceGeometry->SurfaceTmp(BaseSurfNum).CosTilt + Zp * state.dataSurfaceGeometry->SurfaceTmp(BaseSurfNum).SinTilt; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides = 4; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex.allocate(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides); + surfTemp.Sides = 4; + surfTemp.Vertex.allocate(surfTemp.Sides); MakeRelativeRectangularVertices(state, BaseSurfNum, @@ -6805,8 +6768,8 @@ namespace SurfaceGeometry { // SurfaceTmp(SurfNum)%BaseSurfName=' ' // SurfaceTmp(SurfNum)%ZoneName=' ' - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).BaseSurf = 0; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Zone = 0; + surfTemp.BaseSurf = 0; + surfTemp.Zone = 0; // and mirror if (state.dataReportFlag->MakeMirroredAttachedShading) { @@ -6836,7 +6799,7 @@ namespace SurfaceGeometry { // for projection option: // N5, \field Left Depth as Fraction of Window/Door Width // \units m - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name + " Left"; + surfTemp.Name = surfTemp.Name + " Left"; Length = s_ipsc->rNumericArgs(2) + s_ipsc->rNumericArgs(3) + state.dataSurfaceGeometry->SurfaceTmp(Found).Height; if (Item == 3) { Depth = s_ipsc->rNumericArgs(5); @@ -6856,10 +6819,10 @@ namespace SurfaceGeometry { if (MakeFin) { TiltAngle = state.dataSurfaceGeometry->SurfaceTmp(Found).Tilt; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Tilt = TiltAngle; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).convOrientation = - Convect::GetSurfConvOrientation(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Tilt); - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Azimuth = + surfTemp.Tilt = TiltAngle; + surfTemp.convOrientation = + Convect::GetSurfConvOrientation(surfTemp.Tilt); + surfTemp.Azimuth = state.dataSurfaceGeometry->SurfaceTmp(Found).Azimuth - (180.0 - s_ipsc->rNumericArgs(4)); // Make it relative to surface origin..... @@ -6880,17 +6843,13 @@ namespace SurfaceGeometry { state.dataSurfaceGeometry->SurfaceTmp(BaseSurfNum).CosTilt + Zp * state.dataSurfaceGeometry->SurfaceTmp(BaseSurfNum).SinTilt; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).CosAzim = - std::cos(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Azimuth * Constant::DegToRadians); - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).SinAzim = - std::sin(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Azimuth * Constant::DegToRadians); - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).CosTilt = - std::cos(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Tilt * Constant::DegToRadians); - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).SinTilt = - std::sin(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Tilt * Constant::DegToRadians); + surfTemp.CosAzim = std::cos(surfTemp.Azimuth * Constant::DegToRad); + surfTemp.SinAzim = std::sin(surfTemp.Azimuth * Constant::DegToRad); + surfTemp.CosTilt = std::cos(surfTemp.Tilt * Constant::DegToRad); + surfTemp.SinTilt = std::sin(surfTemp.Tilt * Constant::DegToRad); - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides = 4; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex.allocate(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides); + surfTemp.Sides = 4; + surfTemp.Vertex.allocate(surfTemp.Sides); MakeRelativeRectangularVertices( state, BaseSurfNum, SurfNum, XLLC - s_ipsc->rNumericArgs(1), YLLC - s_ipsc->rNumericArgs(3), -Depth, Length); @@ -6899,8 +6858,8 @@ namespace SurfaceGeometry { // SurfaceTmp(SurfNum)%BaseSurfName=' ' // SurfaceTmp(SurfNum)%ZoneName=' ' - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).BaseSurf = 0; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Zone = 0; + surfTemp.BaseSurf = 0; + surfTemp.Zone = 0; // and mirror if (state.dataReportFlag->MakeMirroredAttachedShading) { @@ -6931,21 +6890,21 @@ namespace SurfaceGeometry { // \units m ++SurfNum; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name = - s_ipsc->cAlphaArgs(1) + " Right"; // Set the Surface Name in the Derived Type - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class = SurfaceClass::Shading; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).HeatTransSurf = false; + auto &surfTemp = state.dataSurfaceGeometry->SurfaceTmp(SurfNum); + surfTemp.Name = s_ipsc->cAlphaArgs(1) + " Right"; // Set the Surface Name in the Derived Type + surfTemp.Class = SurfaceClass::Shading; + surfTemp.HeatTransSurf = false; BaseSurfNum = state.dataSurfaceGeometry->SurfaceTmp(Found).BaseSurf; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).BaseSurfName = state.dataSurfaceGeometry->SurfaceTmp(Found).BaseSurfName; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond = state.dataSurfaceGeometry->SurfaceTmp(Found).ExtBoundCond; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtSolar = state.dataSurfaceGeometry->SurfaceTmp(Found).ExtSolar; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtWind = state.dataSurfaceGeometry->SurfaceTmp(Found).ExtWind; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Zone = + surfTemp.BaseSurfName = state.dataSurfaceGeometry->SurfaceTmp(Found).BaseSurfName; + surfTemp.ExtBoundCond = state.dataSurfaceGeometry->SurfaceTmp(Found).ExtBoundCond; + surfTemp.ExtSolar = state.dataSurfaceGeometry->SurfaceTmp(Found).ExtSolar; + surfTemp.ExtWind = state.dataSurfaceGeometry->SurfaceTmp(Found).ExtWind; + surfTemp.Zone = state.dataSurfaceGeometry->SurfaceTmp(Found).Zone; // Necessary to do relative coordinates in GetVertices below - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ZoneName = + surfTemp.ZoneName = state.dataSurfaceGeometry->SurfaceTmp(Found).ZoneName; // Necessary to have surface drawn in OutputReports - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).SchedShadowSurfIndex = 0; + surfTemp.shadowSurfSched = nullptr; Length = s_ipsc->rNumericArgs(7) + s_ipsc->rNumericArgs(8) + state.dataSurfaceGeometry->SurfaceTmp(Found).Height; if (Item == 3) { Depth = s_ipsc->rNumericArgs(10); @@ -6983,22 +6942,16 @@ namespace SurfaceGeometry { Zp * state.dataSurfaceGeometry->SurfaceTmp(BaseSurfNum).SinTilt; TiltAngle = state.dataSurfaceGeometry->SurfaceTmp(Found).Tilt; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Tilt = TiltAngle; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).convOrientation = - Convect::GetSurfConvOrientation(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Tilt); - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Azimuth = - state.dataSurfaceGeometry->SurfaceTmp(Found).Azimuth - (180.0 - s_ipsc->rNumericArgs(9)); - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).CosAzim = - std::cos(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Azimuth * Constant::DegToRadians); - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).SinAzim = - std::sin(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Azimuth * Constant::DegToRadians); - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).CosTilt = - std::cos(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Tilt * Constant::DegToRadians); - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).SinTilt = - std::sin(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Tilt * Constant::DegToRadians); - - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides = 4; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex.allocate(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides); + surfTemp.Tilt = TiltAngle; + surfTemp.convOrientation = Convect::GetSurfConvOrientation(surfTemp.Tilt); + surfTemp.Azimuth = state.dataSurfaceGeometry->SurfaceTmp(Found).Azimuth - (180.0 - s_ipsc->rNumericArgs(9)); + surfTemp.CosAzim = std::cos(surfTemp.Azimuth * Constant::DegToRad); + surfTemp.SinAzim = std::sin(surfTemp.Azimuth * Constant::DegToRad); + surfTemp.CosTilt = std::cos(surfTemp.Tilt * Constant::DegToRad); + surfTemp.SinTilt = std::sin(surfTemp.Tilt * Constant::DegToRad); + + surfTemp.Sides = 4; + surfTemp.Vertex.allocate(surfTemp.Sides); MakeRelativeRectangularVertices(state, BaseSurfNum, @@ -7012,8 +6965,8 @@ namespace SurfaceGeometry { // SurfaceTmp(SurfNum)%BaseSurfName=' ' // SurfaceTmp(SurfNum)%ZoneName=' ' - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).BaseSurf = 0; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Zone = 0; + surfTemp.BaseSurf = 0; + surfTemp.Zone = 0; // and mirror if (state.dataReportFlag->MakeMirroredAttachedShading) { @@ -7145,8 +7098,9 @@ namespace SurfaceGeometry { s_ipsc->cAlphaFieldNames(3), s_ipsc->cAlphaArgs(3))); ++SurfNum; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class = SurfaceClass::Invalid; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ZoneName = "Unknown Zone"; + auto &surfTemp = state.dataSurfaceGeometry->SurfaceTmp(SurfNum); + surfTemp.Class = SurfaceClass::Invalid; + surfTemp.ZoneName = "Unknown Zone"; ErrorsFound = true; errFlag = true; } @@ -7179,7 +7133,8 @@ namespace SurfaceGeometry { s_ipsc->cAlphaFieldNames(4), s_ipsc->cAlphaArgs(4))); ++SurfNum; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class = SurfaceClass::Invalid; + auto &surfTemp = state.dataSurfaceGeometry->SurfaceTmp(SurfNum); + surfTemp.Class = SurfaceClass::Invalid; ErrorsFound = true; errFlag = true; } @@ -7226,14 +7181,15 @@ namespace SurfaceGeometry { ++SurfNum; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction = state.dataSurface->IntMassObjects(Loop).Construction; + auto &surfTemp = state.dataSurfaceGeometry->SurfaceTmp(SurfNum); + surfTemp.Construction = state.dataSurface->IntMassObjects(Loop).Construction; if (!state.dataSurface->IntMassObjects(Loop).ZoneListActive && !state.dataSurface->IntMassObjects(Loop).spaceListActive) { - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Zone = state.dataSurface->IntMassObjects(Loop).ZoneOrZoneListPtr; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).spaceNum = state.dataSurface->IntMassObjects(Loop).spaceOrSpaceListPtr; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name = state.dataSurface->IntMassObjects(Loop).Name; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class = SurfaceClass::IntMass; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ZoneName = state.dataSurface->IntMassObjects(Loop).ZoneOrZoneListName; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).HeatTransSurf = true; + surfTemp.Zone = state.dataSurface->IntMassObjects(Loop).ZoneOrZoneListPtr; + surfTemp.spaceNum = state.dataSurface->IntMassObjects(Loop).spaceOrSpaceListPtr; + surfTemp.Name = state.dataSurface->IntMassObjects(Loop).Name; + surfTemp.Class = SurfaceClass::IntMass; + surfTemp.ZoneName = state.dataSurface->IntMassObjects(Loop).ZoneOrZoneListName; + surfTemp.HeatTransSurf = true; } else { if (state.dataSurface->IntMassObjects(Loop).ZoneListActive) { CheckCreatedZoneItemName( @@ -7247,7 +7203,7 @@ namespace SurfaceGeometry { state.dataSurface->IntMassObjects(Loop).Name, state.dataSurfaceGeometry->SurfaceTmp, SurfNum - 1, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, errFlag); ZoneNum = state.dataHeatBal->ZoneList(state.dataSurface->IntMassObjects(Loop).ZoneOrZoneListPtr).Zone(Item1); @@ -7255,44 +7211,44 @@ namespace SurfaceGeometry { spaceNum = state.dataHeatBal->spaceList(state.dataSurface->IntMassObjects(Loop).spaceOrSpaceListPtr).spaces(Item1); ZoneNum = state.dataHeatBal->space(spaceNum).zoneNum; const std::string spaceName = state.dataHeatBal->space(spaceNum).Name; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name = spaceName + ' ' + state.dataSurface->IntMassObjects(Loop).Name; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).spaceNum = spaceNum; + surfTemp.Name = spaceName + ' ' + state.dataSurface->IntMassObjects(Loop).Name; + surfTemp.spaceNum = spaceNum; } - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Zone = ZoneNum; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class = SurfaceClass::IntMass; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ZoneName = state.dataHeatBal->Zone(ZoneNum).Name; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).HeatTransSurf = true; + surfTemp.Zone = ZoneNum; + surfTemp.Class = SurfaceClass::IntMass; + surfTemp.ZoneName = state.dataHeatBal->Zone(ZoneNum).Name; + surfTemp.HeatTransSurf = true; if (errFlag) ErrorsFound = true; } if (state.dataSurface->IntMassObjects(Loop).Construction > 0) { if (state.dataConstruction->Construct(state.dataSurface->IntMassObjects(Loop).Construction).IsUsed) { - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ConstructionStoredInputValue = + surfTemp.ConstructionStoredInputValue = state.dataSurface->IntMassObjects(Loop).Construction; } } - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).GrossArea = state.dataSurface->IntMassObjects(Loop).GrossArea; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Area = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).GrossArea; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).NetAreaShadowCalc = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Area; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Width = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Area; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Height = 1.0; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Tilt = 90.0; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).convOrientation = - Convect::GetSurfConvOrientation(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Tilt); - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).CosTilt = 0.0; // Tuned Was std::cos( 90.0 * DegToRadians ) - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).SinTilt = 1.0; // Tuned Was std::sin( 90.0 * DegToRadians ) - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Azimuth = 0.0; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).CosAzim = 1.0; // Tuned Was std::cos( 0.0 ) - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).SinAzim = 0.0; // Tuned Was std::sin( 0.0 ) + surfTemp.GrossArea = state.dataSurface->IntMassObjects(Loop).GrossArea; + surfTemp.Area = surfTemp.GrossArea; + surfTemp.NetAreaShadowCalc = surfTemp.Area; + surfTemp.Width = surfTemp.Area; + surfTemp.Height = 1.0; + surfTemp.Tilt = 90.0; + surfTemp.convOrientation = + Convect::GetSurfConvOrientation(surfTemp.Tilt); + surfTemp.CosTilt = 0.0; // Tuned Was std::cos( 90.0 * DegToRadians ) + surfTemp.SinTilt = 1.0; // Tuned Was std::sin( 90.0 * DegToRadians ) + surfTemp.Azimuth = 0.0; + surfTemp.CosAzim = 1.0; // Tuned Was std::cos( 0.0 ) + surfTemp.SinAzim = 0.0; // Tuned Was std::sin( 0.0 ) // Outward normal unit vector (pointing away from room) - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).OutNormVec = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).lcsz; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ViewFactorSky = 0.5; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtSolar = false; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtWind = false; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).BaseSurf = SurfNum; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).BaseSurfName = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCondName = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond = UnreconciledZoneSurface; + surfTemp.OutNormVec = surfTemp.lcsz; + surfTemp.ViewFactorSky = 0.5; + surfTemp.ExtSolar = false; + surfTemp.ExtWind = false; + surfTemp.BaseSurf = SurfNum; + surfTemp.BaseSurfName = surfTemp.Name; + surfTemp.ExtBoundCondName = surfTemp.Name; + surfTemp.ExtBoundCond = UnreconciledZoneSurface; } } } @@ -8079,10 +8035,10 @@ namespace SurfaceGeometry { using DataLoopNode::ObjectIsParent; using NodeInputManager::GetOnlySingleNode; using OutAirNodeManager::CheckOutAirNodeNumber; - using ScheduleManager::GetScheduleIndex; // SUBROUTINE PARAMETER DEFINITIONS: static constexpr std::string_view RoutineName("GetSurfaceLocalEnvData: "); + static constexpr std::string_view routineName = "GetSurfaceLocalEnvData"; // INTERFACE BLOCK SPECIFICATIONS:na // DERIVED TYPE DEFINITIONS:na @@ -8123,6 +8079,9 @@ namespace SurfaceGeometry { s_ipsc->lAlphaFieldBlanks, s_ipsc->cAlphaFieldNames, s_ipsc->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)}; + Util::IsNameEmpty(state, s_ipsc->cAlphaArgs(1), s_ipsc->cCurrentModuleObject, ErrorsFound); SurfLocalEnv.Name = s_ipsc->cAlphaArgs(1); @@ -8147,24 +8106,10 @@ namespace SurfaceGeometry { } // Assign Sunlit Fraction Schedule number - if (!s_ipsc->lAlphaFieldBlanks(3)) { - int SunlitFracSchedNum = GetScheduleIndex(state, s_ipsc->cAlphaArgs(3)); - if (SunlitFracSchedNum == 0) { - ShowSevereError(state, - format("{} {} = \"{}\", object. Illegal value for \"{}\" has been found.", - RoutineName, - s_ipsc->cCurrentModuleObject, - SurfLocalEnv.Name, - s_ipsc->cAlphaFieldNames(3))); - ShowContinueError( - state, - format("{} entered value = \"{}\", no corresponding sunlit fraction schedule has been found in the input file.", - s_ipsc->cAlphaFieldNames(3), - s_ipsc->cAlphaArgs(3))); - ErrorsFound = true; - } else { - SurfLocalEnv.SunlitFracSchedPtr = SunlitFracSchedNum; - } + if (s_ipsc->lAlphaFieldBlanks(3)) { + } else if ((SurfLocalEnv.sunlitFracSched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(3))) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(3), s_ipsc->cAlphaArgs(3)); + ErrorsFound = true; } // Assign surrounding surfaces object number; @@ -8247,9 +8192,9 @@ namespace SurfaceGeometry { if (SurfLocalEnv.OutdoorAirNodePtr != 0) { surface.SurfLinkedOutAirNode = SurfLocalEnv.OutdoorAirNodePtr; } - if (SurfLocalEnv.SunlitFracSchedPtr != 0) { + if (SurfLocalEnv.sunlitFracSched != nullptr) { surface.SurfSchedExternalShadingFrac = true; - surface.SurfExternalShadingSchInd = SurfLocalEnv.SunlitFracSchedPtr; + surface.surfExternalShadingSched = SurfLocalEnv.sunlitFracSched; } if (SurfLocalEnv.SurroundingSurfsPtr != 0) { surface.SurfHasSurroundingSurfProperty = true; @@ -8282,12 +8227,13 @@ namespace SurfaceGeometry { // PURPOSE OF THIS SUBROUTINE: // load input data for surrounding surfaces properties for exterior surfaces + static constexpr std::string_view routineName = "GetSurfaceSrdSurfsData"; + // Using/Aliasing using namespace DataErrorTracking; using DataLoopNode::ObjectIsParent; using NodeInputManager::GetOnlySingleNode; using OutAirNodeManager::CheckOutAirNodeNumber; - using ScheduleManager::GetScheduleIndex; // INTERFACE BLOCK SPECIFICATIONS:na // DERIVED TYPE DEFINITIONS:na @@ -8327,6 +8273,9 @@ namespace SurfaceGeometry { s_ipsc->lAlphaFieldBlanks, s_ipsc->cAlphaFieldNames, s_ipsc->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)}; + Util::IsNameEmpty(state, s_ipsc->cAlphaArgs(1), s_ipsc->cCurrentModuleObject, ErrorsFound); // A1: Name @@ -8339,8 +8288,9 @@ namespace SurfaceGeometry { } // A2: sky temp sch name - if (!s_ipsc->lAlphaFieldBlanks(2)) { - SrdSurfsProp.SkyTempSchNum = GetScheduleIndex(state, s_ipsc->cAlphaArgs(2)); + if (s_ipsc->lAlphaFieldBlanks(2)) { + } else if ((SrdSurfsProp.skyTempSched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(2))) == nullptr) { + ShowWarningItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2)); } // N2: ground view factor @@ -8350,8 +8300,9 @@ namespace SurfaceGeometry { } // A3: ground temp sch name - if (!s_ipsc->lAlphaFieldBlanks(3)) { - SrdSurfsProp.GroundTempSchNum = GetScheduleIndex(state, s_ipsc->cAlphaArgs(3)); + if (s_ipsc->lAlphaFieldBlanks(3)) { + } else if ((SrdSurfsProp.groundTempSched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(3))) == nullptr) { + ShowWarningItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(3), s_ipsc->cAlphaArgs(3)); } // The object requires at least one srd surface input, each surface requires a set of 3 fields (2 Alpha fields Name and Temp @@ -8372,9 +8323,19 @@ namespace SurfaceGeometry { SrdSurfsProp.TotSurroundingSurface = NumNumeric - 2; SrdSurfsProp.SurroundingSurfs.allocate(SrdSurfsProp.TotSurroundingSurface); for (int SurfLoop = 1; SurfLoop <= SrdSurfsProp.TotSurroundingSurface; ++SurfLoop) { - SrdSurfsProp.SurroundingSurfs(SurfLoop).Name = s_ipsc->cAlphaArgs(SurfLoop * 2 + 2); - SrdSurfsProp.SurroundingSurfs(SurfLoop).ViewFactor = s_ipsc->rNumericArgs(SurfLoop + 2); - SrdSurfsProp.SurroundingSurfs(SurfLoop).TempSchNum = GetScheduleIndex(state, s_ipsc->cAlphaArgs(SurfLoop * 2 + 3)); + auto &surroundSurf = SrdSurfsProp.SurroundingSurfs(SurfLoop); + surroundSurf.Name = s_ipsc->cAlphaArgs(SurfLoop * 2 + 2); + surroundSurf.ViewFactor = s_ipsc->rNumericArgs(SurfLoop + 2); + + // Added checking + if (s_ipsc->lAlphaFieldBlanks(SurfLoop * 2 + 3)) { + ShowSevereEmptyField(state, eoh, s_ipsc->cAlphaFieldNames(SurfLoop * 2 + 3)); + ErrorsFound = true; + } else if ((surroundSurf.tempSched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(SurfLoop * 2 + 3))) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(SurfLoop * 2 + 3), s_ipsc->cAlphaArgs(SurfLoop * 2 + 3)); + ErrorsFound = true; + } + SrdSurfsProp.SurfsViewFactorSum += SrdSurfsProp.SurroundingSurfs(SurfLoop).ViewFactor; } } @@ -8383,6 +8344,8 @@ namespace SurfaceGeometry { void GetSurfaceGroundSurfsData(EnergyPlusData &state, bool &ErrorsFound) { + static constexpr std::string_view routineName = "GetSurfaceGroundSurfsData"; + auto &s_ipsc = state.dataIPShortCut; s_ipsc->cCurrentModuleObject = "SurfaceProperty:GroundSurfaces"; state.dataSurface->TotSurfPropGndSurfs = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, s_ipsc->cCurrentModuleObject); @@ -8390,55 +8353,64 @@ namespace SurfaceGeometry { if (instances == state.dataInputProcessing->inputProcessor->epJSON.end()) { if (state.dataSurface->TotSurfPropGndSurfs > 0) ErrorsFound = true; return; - } else { - auto &instancesValue = instances.value(); - for (auto instance = instancesValue.begin(); instance != instancesValue.end(); ++instance) { - auto const &fields = instance.value(); - std::string const &thisObjectName = instance.key(); - GroundSurfacesProperty thisGndSurfsObj; - thisGndSurfsObj.Name = Util::makeUPPER(thisObjectName); - state.dataInputProcessing->inputProcessor->markObjectAsUsed(s_ipsc->cCurrentModuleObject, thisObjectName); - auto groundSurfaces = fields.find("ground_surfaces"); - if (groundSurfaces != fields.end()) { - auto &groundSurfacesArray = groundSurfaces.value(); - thisGndSurfsObj.NumGndSurfs = groundSurfacesArray.size(); - for (auto &groundSurface : groundSurfacesArray) { - GroundSurfacesData thisGndSurf; - auto GndSurfName = groundSurface.find("ground_surface_name"); - if (GndSurfName != groundSurface.end()) { - std::string ground_surf_name = GndSurfName.value().get(); - if (!ground_surf_name.empty()) { - thisGndSurf.Name = Util::makeUPPER(ground_surf_name); - } - } - auto groundSurfViewFactor = groundSurface.find("ground_surface_view_factor"); - if (groundSurfViewFactor != groundSurface.end()) { - thisGndSurf.ViewFactor = groundSurfViewFactor.value().get(); - thisGndSurfsObj.IsGroundViewFactorSet = true; + } + + auto &instancesValue = instances.value(); + for (auto instance = instancesValue.begin(); instance != instancesValue.end(); ++instance) { + auto const &fields = instance.value(); + std::string const &thisObjectName = instance.key(); + + ErrorObjectHeader eoh{routineName, s_ipsc->cCurrentModuleObject, thisObjectName}; + + GroundSurfacesProperty thisGndSurfsObj; + thisGndSurfsObj.Name = Util::makeUPPER(thisObjectName); + state.dataInputProcessing->inputProcessor->markObjectAsUsed(s_ipsc->cCurrentModuleObject, thisObjectName); + auto groundSurfaces = fields.find("ground_surfaces"); + if (groundSurfaces != fields.end()) { + auto &groundSurfacesArray = groundSurfaces.value(); + thisGndSurfsObj.NumGndSurfs = groundSurfacesArray.size(); + for (auto &groundSurface : groundSurfacesArray) { + GroundSurfacesData thisGndSurf; + auto GndSurfName = groundSurface.find("ground_surface_name"); + if (GndSurfName != groundSurface.end()) { + std::string ground_surf_name = GndSurfName.value().get(); + if (!ground_surf_name.empty()) { + thisGndSurf.Name = Util::makeUPPER(ground_surf_name); } - auto TempSchName = groundSurface.find("ground_surface_temperature_schedule_name"); - if (TempSchName != groundSurface.end()) { - std::string gnd_surf_TempSchName = TempSchName.value().get(); - if (!gnd_surf_TempSchName.empty()) { - thisGndSurf.TempSchPtr = ScheduleManager::GetScheduleIndex(state, Util::makeUPPER(gnd_surf_TempSchName)); - } + } + auto groundSurfViewFactor = groundSurface.find("ground_surface_view_factor"); + if (groundSurfViewFactor != groundSurface.end()) { + thisGndSurf.ViewFactor = groundSurfViewFactor.value().get(); + thisGndSurfsObj.IsGroundViewFactorSet = true; + } + auto TempSchName = groundSurface.find("ground_surface_temperature_schedule_name"); + if (TempSchName != groundSurface.end()) { + std::string schedName = TempSchName.value().get(); + if (schedName.empty()) { + } else if ((thisGndSurf.tempSched = Sched::GetSchedule(state, Util::makeUPPER(schedName))) == nullptr) { + ShowSevereItemNotFound(state, eoh, "Ground Surface Temperature Schedule Name", schedName); + ErrorsFound = true; } - auto ReflSchName = groundSurface.find("ground_surface_reflectance_schedule_name"); - if (ReflSchName != groundSurface.end()) { - std::string gnd_surf_ReflSchName = ReflSchName.value().get(); - if (!gnd_surf_ReflSchName.empty()) { - thisGndSurf.ReflSchPtr = ScheduleManager::GetScheduleIndex(state, Util::makeUPPER(gnd_surf_ReflSchName)); - } + } + + auto ReflSchName = groundSurface.find("ground_surface_reflectance_schedule_name"); + if (ReflSchName != groundSurface.end()) { + std::string schedName = ReflSchName.value().get(); + if (schedName.empty()) { + } else if ((thisGndSurf.reflSched = Sched::GetSchedule(state, Util::makeUPPER(schedName))) == nullptr) { + ShowSevereItemNotFound(state, eoh, "Ground Surface Reflectance Schedule Name", schedName); + ErrorsFound = true; } - thisGndSurfsObj.GndSurfs.push_back(thisGndSurf); } + thisGndSurfsObj.GndSurfs.push_back(thisGndSurf); } - for (int gSurfNum = 1; gSurfNum <= thisGndSurfsObj.NumGndSurfs; gSurfNum++) { - thisGndSurfsObj.SurfsViewFactorSum += thisGndSurfsObj.GndSurfs(gSurfNum).ViewFactor; - } - state.dataSurface->GroundSurfsProperty.push_back(thisGndSurfsObj); } - } + for (int gSurfNum = 1; gSurfNum <= thisGndSurfsObj.NumGndSurfs; gSurfNum++) { + thisGndSurfsObj.SurfsViewFactorSum += thisGndSurfsObj.GndSurfs(gSurfNum).ViewFactor; + } + state.dataSurface->GroundSurfsProperty.push_back(thisGndSurfsObj); + } // for (instance) + // set report variables if (state.dataSurface->TotSurfPropGndSurfs > 0) { for (int Loop = 1; Loop <= state.dataSurface->TotSurfPropGndSurfs; Loop++) { @@ -8446,7 +8418,7 @@ namespace SurfaceGeometry { bool SetReflSchReportVar = true; auto &thisGndSurfsObj = state.dataSurface->GroundSurfsProperty(Loop); for (int gSurfNum = 1; gSurfNum <= thisGndSurfsObj.NumGndSurfs; gSurfNum++) { - if (thisGndSurfsObj.GndSurfs(gSurfNum).TempSchPtr != 0 && SetTempSchReportVar) { + if (thisGndSurfsObj.GndSurfs(gSurfNum).tempSched != nullptr && SetTempSchReportVar) { SetupOutputVariable(state, "Surfaces Property Ground Surfaces Average Temperature", Constant::Units::C, @@ -8456,7 +8428,7 @@ namespace SurfaceGeometry { thisGndSurfsObj.Name); SetTempSchReportVar = false; } - if (thisGndSurfsObj.GndSurfs(gSurfNum).ReflSchPtr != 0 && SetReflSchReportVar) { + if (thisGndSurfsObj.GndSurfs(gSurfNum).reflSched != nullptr && SetReflSchReportVar) { SetupOutputVariable(state, "Surfaces Property Ground Surfaces Average Reflectance", Constant::Units::None, @@ -8483,7 +8455,7 @@ namespace SurfaceGeometry { // PURPOSE OF THIS SUBROUTINE: // - // Using/Aliasing + static constexpr std::string_view routineName = "GetSurfaceHeatTransferAlgorithmOverrides"; // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int CountHTAlgoObjectsSingleSurf; @@ -8532,13 +8504,15 @@ namespace SurfaceGeometry { s_ipsc->lAlphaFieldBlanks, s_ipsc->cAlphaFieldNames, s_ipsc->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)}; Found = Util::FindItemInList(s_ipsc->cAlphaArgs(1), state.dataSurface->Surface, state.dataSurface->TotSurfaces); if (Found == 0) { ShowSevereError(state, format("{}=\"{}\", did not find matching surface.", s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); ErrorsFound = true; - } else if (state.dataSurface->Surface(Found).InsideHeatSourceTermSchedule || - state.dataSurface->Surface(Found).OutsideHeatSourceTermSchedule) { + } else if (state.dataSurface->Surface(Found).insideHeatSourceTermSched != nullptr || + state.dataSurface->Surface(Found).outsideHeatSourceTermSched != nullptr) { ShowSevereError(state, format("{}=\"{}\", multiple SurfaceProperty:HeatBalanceSourceTerm objects applied to the same surface.", s_ipsc->cCurrentModuleObject, @@ -8546,44 +8520,30 @@ namespace SurfaceGeometry { ErrorsFound = true; } - if (!s_ipsc->lAlphaFieldBlanks(2)) { - state.dataSurface->Surface(Found).InsideHeatSourceTermSchedule = ScheduleManager::GetScheduleIndex(state, s_ipsc->cAlphaArgs(2)); - if (state.dataSurface->Surface(Found).InsideHeatSourceTermSchedule == 0) { - ShowSevereError(state, - format("{}=\"{}\", cannot find the matching Schedule: {}=\"{}", - s_ipsc->cCurrentModuleObject, - s_ipsc->cAlphaArgs(1), - s_ipsc->cAlphaFieldNames(2), - s_ipsc->cAlphaArgs(2))); - ErrorsFound = true; - } else { - state.dataSurface->allInsideSourceSurfaceList.emplace_back(Found); - } + if (s_ipsc->lAlphaFieldBlanks(2)) { + } else if ((state.dataSurface->Surface(Found).insideHeatSourceTermSched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2)); + ErrorsFound = true; + } else { + state.dataSurface->allInsideSourceSurfaceList.emplace_back(Found); } - if (!s_ipsc->lAlphaFieldBlanks(3)) { - state.dataSurface->Surface(Found).OutsideHeatSourceTermSchedule = ScheduleManager::GetScheduleIndex(state, s_ipsc->cAlphaArgs(3)); - if (state.dataSurface->Surface(Found).OutsideHeatSourceTermSchedule == 0) { - ShowSevereError(state, - format("{}=\"{}\", cannot find the matching Schedule: {}=\"{}", - s_ipsc->cCurrentModuleObject, - s_ipsc->cAlphaArgs(1), - s_ipsc->cAlphaFieldNames(3), - s_ipsc->cAlphaArgs(3))); - ErrorsFound = true; - } else if (state.dataSurface->Surface(Found).OSCPtr > 0) { - ShowSevereError(state, - format("{}=\"SurfaceProperty:HeatBalanceSourceTerm\", cannot be specified for OtherSideCoefficient Surface={}", - s_ipsc->cCurrentModuleObject, - s_ipsc->cAlphaArgs(1))); - ErrorsFound = true; - } else { - state.dataSurface->allOutsideSourceSurfaceList.emplace_back(Found); - } + if (s_ipsc->lAlphaFieldBlanks(3)) { + } else if ((state.dataSurface->Surface(Found).outsideHeatSourceTermSched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(3))) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(3), s_ipsc->cAlphaArgs(3)); + ErrorsFound = true; + } else if (state.dataSurface->Surface(Found).OSCPtr > 0) { + ShowSevereError(state, + format("{}=\"SurfaceProperty:HeatBalanceSourceTerm\", cannot be specified for OtherSideCoefficient Surface={}", + s_ipsc->cCurrentModuleObject, + s_ipsc->cAlphaArgs(1))); + ErrorsFound = true; + } else { + state.dataSurface->allOutsideSourceSurfaceList.emplace_back(Found); } - if (state.dataSurface->Surface(Found).OutsideHeatSourceTermSchedule == 0 && - state.dataSurface->Surface(Found).InsideHeatSourceTermSchedule == 0) { + if (state.dataSurface->Surface(Found).outsideHeatSourceTermSched == nullptr && + state.dataSurface->Surface(Found).insideHeatSourceTermSched == nullptr) { ShowSevereError( state, format("{}=\"{}\", no schedule defined for additional heat source.", s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); ErrorsFound = true; @@ -9293,14 +9253,16 @@ namespace SurfaceGeometry { Vector const TestVector(0.0, 0.0, 1.0); Vector temp; + auto &surfTemp = state.dataSurfaceGeometry->SurfaceTmp(SurfNum); + if (NSides > state.dataSurface->MaxVerticesPerSurface) state.dataSurface->MaxVerticesPerSurface = NSides; Ptr = 1; for (n = 1; n <= NSides; ++n) { - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(n).x = Vertices(Ptr); + surfTemp.Vertex(n).x = Vertices(Ptr); ++Ptr; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(n).y = Vertices(Ptr); + surfTemp.Vertex(n).y = Vertices(Ptr); ++Ptr; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(n).z = Vertices(Ptr); + surfTemp.Vertex(n).z = Vertices(Ptr); ++Ptr; } @@ -9311,9 +9273,9 @@ namespace SurfaceGeometry { NSrc = NSides; NTar = 2; for (n = 1; n <= (NSides - 1) / 2; ++n) { - temp = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(NSrc); - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(NSrc) = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(NTar); - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(NTar) = temp; + temp = surfTemp.Vertex(NSrc); + surfTemp.Vertex(NSrc) = surfTemp.Vertex(NTar); + surfTemp.Vertex(NTar) = temp; --NSrc; ++NTar; } @@ -9334,9 +9296,9 @@ namespace SurfaceGeometry { NSrc = ThisCorner + 1; if (NSrc > NSides) NSrc = 1; for (n = 1; n <= NSides - 1; ++n) { - temp = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(NTar); - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(NTar) = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(NSrc); - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(NSrc) = temp; + temp = surfTemp.Vertex(NTar); + surfTemp.Vertex(NTar) = surfTemp.Vertex(NSrc); + surfTemp.Vertex(NSrc) = temp; ++NTar; ++NSrc; if (NTar > NSides) NTar = 1; @@ -9348,50 +9310,50 @@ namespace SurfaceGeometry { if (!state.dataSurface->WorldCoordSystem) { // Input in "relative" coordinates, use Building and Zone North Axes and Origins // to translate each point (including rotation for Appendix G) - ZoneNum = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Zone; + ZoneNum = surfTemp.Zone; if (ZoneNum > 0) { for (n = 1; n <= NSides; ++n) { - Xb = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(n).x * state.dataSurfaceGeometry->CosZoneRelNorth(ZoneNum) - - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(n).y * state.dataSurfaceGeometry->SinZoneRelNorth(ZoneNum) + + Xb = surfTemp.Vertex(n).x * state.dataSurfaceGeometry->CosZoneRelNorth(ZoneNum) - + surfTemp.Vertex(n).y * state.dataSurfaceGeometry->SinZoneRelNorth(ZoneNum) + state.dataHeatBal->Zone(ZoneNum).OriginX; - Yb = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(n).x * state.dataSurfaceGeometry->SinZoneRelNorth(ZoneNum) + - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(n).y * state.dataSurfaceGeometry->CosZoneRelNorth(ZoneNum) + + Yb = surfTemp.Vertex(n).x * state.dataSurfaceGeometry->SinZoneRelNorth(ZoneNum) + + surfTemp.Vertex(n).y * state.dataSurfaceGeometry->CosZoneRelNorth(ZoneNum) + state.dataHeatBal->Zone(ZoneNum).OriginY; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(n).x = + surfTemp.Vertex(n).x = Xb * state.dataSurfaceGeometry->CosBldgRelNorth - Yb * state.dataSurfaceGeometry->SinBldgRelNorth; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(n).y = + surfTemp.Vertex(n).y = Xb * state.dataSurfaceGeometry->SinBldgRelNorth + Yb * state.dataSurfaceGeometry->CosBldgRelNorth; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(n).z += state.dataHeatBal->Zone(ZoneNum).OriginZ; + surfTemp.Vertex(n).z += state.dataHeatBal->Zone(ZoneNum).OriginZ; } - } else if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class == SurfaceClass::Detached_B) { + } else if (surfTemp.Class == SurfaceClass::Detached_B) { for (n = 1; n <= NSides; ++n) { - Xb = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(n).x; - Yb = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(n).y; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(n).x = + Xb = surfTemp.Vertex(n).x; + Yb = surfTemp.Vertex(n).y; + surfTemp.Vertex(n).x = Xb * state.dataSurfaceGeometry->CosBldgRelNorth - Yb * state.dataSurfaceGeometry->SinBldgRelNorth; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(n).y = + surfTemp.Vertex(n).y = Xb * state.dataSurfaceGeometry->SinBldgRelNorth + Yb * state.dataSurfaceGeometry->CosBldgRelNorth; } } } else { // if world coordinate only need to rotate for Appendix G - ZoneNum = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Zone; + ZoneNum = surfTemp.Zone; if (ZoneNum > 0) { for (n = 1; n <= NSides; ++n) { - Xb = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(n).x; - Yb = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(n).y; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(n).x = + Xb = surfTemp.Vertex(n).x; + Yb = surfTemp.Vertex(n).y; + surfTemp.Vertex(n).x = Xb * state.dataSurfaceGeometry->CosBldgRotAppGonly - Yb * state.dataSurfaceGeometry->SinBldgRotAppGonly; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(n).y = + surfTemp.Vertex(n).y = Xb * state.dataSurfaceGeometry->SinBldgRotAppGonly + Yb * state.dataSurfaceGeometry->CosBldgRotAppGonly; } - } else if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class == SurfaceClass::Detached_B) { + } else if (surfTemp.Class == SurfaceClass::Detached_B) { for (n = 1; n <= NSides; ++n) { - Xb = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(n).x; - Yb = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(n).y; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(n).x = + Xb = surfTemp.Vertex(n).x; + Yb = surfTemp.Vertex(n).y; + surfTemp.Vertex(n).x = Xb * state.dataSurfaceGeometry->CosBldgRotAppGonly - Yb * state.dataSurfaceGeometry->SinBldgRotAppGonly; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(n).y = + surfTemp.Vertex(n).y = Xb * state.dataSurfaceGeometry->SinBldgRotAppGonly + Yb * state.dataSurfaceGeometry->CosBldgRotAppGonly; } } @@ -9423,8 +9385,8 @@ namespace SurfaceGeometry { ShowWarningError(state, format("{}Distance between two vertices < .01, possibly coincident. for Surface={}, in Zone={}", RoutineName, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ZoneName)); + surfTemp.Name, + surfTemp.ZoneName)); bool const printPoppedFirst = (poppedVertexIndex < keptVertexIndex) ? !(poppedVertexIndex == 1 && keptVertexIndex == nSides) : (poppedVertexIndex == nSides && keptVertexIndex == 1); @@ -9459,118 +9421,118 @@ namespace SurfaceGeometry { // No need to recompute perimeter, because it'll be done in the next iteration, until no popping or degenerate happens } - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Perimeter = Perimeter; + surfTemp.Perimeter = Perimeter; - CreateNewellSurfaceNormalVector(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).NewellSurfaceNormalVector); - CreateNewellAreaVector(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).NewellAreaVector); + CreateNewellSurfaceNormalVector(surfTemp.Vertex, + surfTemp.Sides, + surfTemp.NewellSurfaceNormalVector); + CreateNewellAreaVector(surfTemp.Vertex, + surfTemp.Sides, + surfTemp.NewellAreaVector); // For surfaces with subsurfaces, the following two areas are turned into net areas later by // subtracting subsurface areas - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).GrossArea = VecLength(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).NewellAreaVector); - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Area = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).GrossArea; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).NetAreaShadowCalc = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Area; - DetermineAzimuthAndTilt(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex, + surfTemp.GrossArea = VecLength(surfTemp.NewellAreaVector); + surfTemp.Area = surfTemp.GrossArea; + surfTemp.NetAreaShadowCalc = surfTemp.Area; + DetermineAzimuthAndTilt(surfTemp.Vertex, SurfWorldAz, SurfTilt, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).lcsx, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).lcsy, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).lcsz, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).NewellSurfaceNormalVector); - dotp = dot(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).NewellSurfaceNormalVector, TestVector); - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class == SurfaceClass::Roof && dotp < -0.000001) { + surfTemp.lcsx, + surfTemp.lcsy, + surfTemp.lcsz, + surfTemp.NewellSurfaceNormalVector); + dotp = dot(surfTemp.NewellSurfaceNormalVector, TestVector); + if (surfTemp.Class == SurfaceClass::Roof && dotp < -0.000001) { TiltString = format("{:.1R}", SurfTilt); ShowWarningError(state, format("{}Roof/Ceiling is upside down! Tilt angle=[{}], should be near 0, Surface=\"{}\", in Zone=\"{}\".", RoutineName, TiltString, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ZoneName)); + surfTemp.Name, + surfTemp.ZoneName)); ShowContinueError(state, "Automatic fix is attempted."); - ReverseAndRecalculate(state, SurfNum, state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides, SurfWorldAz, SurfTilt); - } else if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class == SurfaceClass::Roof && SurfTilt > 80.0) { + ReverseAndRecalculate(state, SurfNum, surfTemp.Sides, SurfWorldAz, SurfTilt); + } else if (surfTemp.Class == SurfaceClass::Roof && SurfTilt > 80.0) { TiltString = format("{:.1R}", SurfTilt); ShowWarningError( state, format("{}Roof/Ceiling is not oriented correctly! Tilt angle=[{}], should be near 0, Surface=\"{}\", in Zone=\"{}\".", RoutineName, TiltString, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ZoneName)); + surfTemp.Name, + surfTemp.ZoneName)); } - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class == SurfaceClass::Floor && dotp > 0.000001) { + if (surfTemp.Class == SurfaceClass::Floor && dotp > 0.000001) { TiltString = format("{:.1R}", SurfTilt); ShowWarningError(state, format("{}Floor is upside down! Tilt angle=[{}], should be near 180, Surface=\"{}\", in Zone=\"{}\".", RoutineName, TiltString, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ZoneName)); + surfTemp.Name, + surfTemp.ZoneName)); ShowContinueError(state, "Automatic fix is attempted."); - ReverseAndRecalculate(state, SurfNum, state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides, SurfWorldAz, SurfTilt); - } else if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class == SurfaceClass::Floor && SurfTilt < 158.2) { // slope/grade = 40%! + ReverseAndRecalculate(state, SurfNum, surfTemp.Sides, SurfWorldAz, SurfTilt); + } else if (surfTemp.Class == SurfaceClass::Floor && SurfTilt < 158.2) { // slope/grade = 40%! TiltString = format("{:.1R}", SurfTilt); ShowWarningError(state, format("{}Floor is not oriented correctly! Tilt angle=[{}], should be near 180, Surface=\"{}\", in Zone=\"{}\".", RoutineName, TiltString, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ZoneName)); + surfTemp.Name, + surfTemp.ZoneName)); } - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Azimuth = SurfWorldAz; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Tilt = SurfTilt; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).convOrientation = - Convect::GetSurfConvOrientation(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Tilt); + surfTemp.Azimuth = SurfWorldAz; + surfTemp.Tilt = SurfTilt; + surfTemp.convOrientation = + Convect::GetSurfConvOrientation(surfTemp.Tilt); // Sine and cosine of azimuth and tilt - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).SinAzim = std::sin(SurfWorldAz * Constant::DegToRadians); - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).CosAzim = std::cos(SurfWorldAz * Constant::DegToRadians); - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).SinTilt = std::sin(SurfTilt * Constant::DegToRadians); - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).CosTilt = std::cos(SurfTilt * Constant::DegToRadians); - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ViewFactorGround == Constant::AutoCalculate) { - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ViewFactorGround = - 0.5 * (1.0 - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).CosTilt); + surfTemp.SinAzim = std::sin(SurfWorldAz * Constant::DegToRad); + surfTemp.CosAzim = std::cos(SurfWorldAz * Constant::DegToRad); + surfTemp.SinTilt = std::sin(SurfTilt * Constant::DegToRad); + surfTemp.CosTilt = std::cos(SurfTilt * Constant::DegToRad); + if (surfTemp.ViewFactorGround == Constant::AutoCalculate) { + surfTemp.ViewFactorGround = + 0.5 * (1.0 - surfTemp.CosTilt); } // Outward normal unit vector (pointing away from room) - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).OutNormVec = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).NewellSurfaceNormalVector; + surfTemp.OutNormVec = surfTemp.NewellSurfaceNormalVector; for (n = 1; n <= 3; ++n) { - if (std::abs(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).OutNormVec(n) - 1.0) < 1.e-06) - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).OutNormVec(n) = +1.0; - if (std::abs(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).OutNormVec(n) + 1.0) < 1.e-06) - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).OutNormVec(n) = -1.0; - if (std::abs(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).OutNormVec(n)) < 1.e-06) - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).OutNormVec(n) = 0.0; - } - - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class == SurfaceClass::Window || - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class == SurfaceClass::GlassDoor || - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class == SurfaceClass::Door) - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Area *= state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Multiplier; + if (std::abs(surfTemp.OutNormVec(n) - 1.0) < 1.e-06) + surfTemp.OutNormVec(n) = +1.0; + if (std::abs(surfTemp.OutNormVec(n) + 1.0) < 1.e-06) + surfTemp.OutNormVec(n) = -1.0; + if (std::abs(surfTemp.OutNormVec(n)) < 1.e-06) + surfTemp.OutNormVec(n) = 0.0; + } + + if (surfTemp.Class == SurfaceClass::Window || + surfTemp.Class == SurfaceClass::GlassDoor || + surfTemp.Class == SurfaceClass::Door) + surfTemp.Area *= surfTemp.Multiplier; // Can perform tests on this surface here - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ViewFactorSky = 0.5 * (1.0 + state.dataSurfaceGeometry->SurfaceTmp(SurfNum).CosTilt); + surfTemp.ViewFactorSky = 0.5 * (1.0 + surfTemp.CosTilt); // The following IR view factors are modified in subr. SkyDifSolarShading if there are shadowing // surfaces - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ViewFactorSkyIR = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ViewFactorSky; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ViewFactorGroundIR = 0.5 * (1.0 - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).CosTilt); + surfTemp.ViewFactorSkyIR = surfTemp.ViewFactorSky; + surfTemp.ViewFactorGroundIR = 0.5 * (1.0 - surfTemp.CosTilt); // Call to transform vertices - TransformVertsByAspect(state, SurfNum, state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides); + TransformVertsByAspect(state, SurfNum, surfTemp.Sides); } else { ShowFatalError(state, - format("{}Called with less than 2 sides, Surface={}", RoutineName, state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name)); + format("{}Called with less than 2 sides, Surface={}", RoutineName, surfTemp.Name)); } // Preliminary Height/Width - temp = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(3) - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(2); + temp = surfTemp.Vertex(3) - surfTemp.Vertex(2); ThisWidth = VecLength(temp); - temp = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(2) - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(1); + temp = surfTemp.Vertex(2) - surfTemp.Vertex(1); ThisHeight = VecLength(temp); - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Height = ThisHeight; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Width = ThisWidth; + surfTemp.Height = ThisHeight; + surfTemp.Width = ThisWidth; } void ReverseAndRecalculate(EnergyPlusData &state, @@ -9619,48 +9581,50 @@ namespace SurfaceGeometry { // Object Data Array1D Vertices(NSides); // Vertices, in specified order + auto &surfTemp = state.dataSurfaceGeometry->SurfaceTmp(SurfNum); + for (n = 1; n <= NSides; ++n) { - Vertices(n) = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(n); + Vertices(n) = surfTemp.Vertex(n); } RevPtr = NSides; for (n = 1; n <= NSides; ++n) { - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(n) = Vertices(RevPtr); + surfTemp.Vertex(n) = Vertices(RevPtr); --RevPtr; } - print(state.files.debug, "Reversing Surface Name={}\n", state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name); + print(state.files.debug, "Reversing Surface Name={}\n", surfTemp.Name); for (n = 1; n <= NSides; ++n) { print(state.files.debug, "side={:5} abs coord vertex= {:18.13F} {:18.13F} {:18.13F}\n", n, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(n).x, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(n).y, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(n).z); + surfTemp.Vertex(n).x, + surfTemp.Vertex(n).y, + surfTemp.Vertex(n).z); } - CreateNewellSurfaceNormalVector(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).NewellSurfaceNormalVector); - DetermineAzimuthAndTilt(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex, + CreateNewellSurfaceNormalVector(surfTemp.Vertex, + surfTemp.Sides, + surfTemp.NewellSurfaceNormalVector); + DetermineAzimuthAndTilt(surfTemp.Vertex, SurfAzimuth, SurfTilt, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).lcsx, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).lcsy, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).lcsz, - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).NewellSurfaceNormalVector); - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class == SurfaceClass::Roof && SurfTilt > 80.0) { + surfTemp.lcsx, + surfTemp.lcsy, + surfTemp.lcsz, + surfTemp.NewellSurfaceNormalVector); + if (surfTemp.Class == SurfaceClass::Roof && SurfTilt > 80.0) { TiltString = format("{:.1R}", SurfTilt); ShowWarningError( state, format("{}Roof/Ceiling is still upside down! Tilt angle=[{}], should be near 0, please fix manually.", RoutineName, TiltString)); } - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class == SurfaceClass::Floor && SurfTilt < 158.2) { // 40% grade! + if (surfTemp.Class == SurfaceClass::Floor && SurfTilt < 158.2) { // 40% grade! ShowWarningError( state, format("{}Floor is still upside down! Tilt angle=[{}], should be near 180, please fix manually.", RoutineName, TiltString)); } } - void MakeMirrorSurface(EnergyPlusData &state, int &SurfNum) // In=>Surface to Mirror, Out=>new Surface index + void MakeMirrorSurface(EnergyPlusData &state, int &SurfNum) // In=>Surface to Mirror, Out=>new Surface index // This is not good { // SUBROUTINE INFORMATION: @@ -9677,9 +9641,11 @@ namespace SurfaceGeometry { auto &newSurface = state.dataSurfaceGeometry->SurfaceTmp(SurfNum + 1); newSurface = origSurface; + auto &surfTemp = state.dataSurfaceGeometry->SurfaceTmp(SurfNum); + int nVert = origSurface.Sides; // Reverse the vertices in the original surface. Add "MIR-" to name. - for (int Vert = 1; Vert <= state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides; ++Vert) { + for (int Vert = 1; Vert <= surfTemp.Sides; ++Vert) { newSurface.Vertex(Vert) = origSurface.Vertex(nVert); --nVert; } @@ -9701,10 +9667,10 @@ namespace SurfaceGeometry { newSurface.convOrientation = Convect::GetSurfConvOrientation(newSurface.Tilt); // Sine and cosine of azimuth and tilt - newSurface.SinAzim = std::sin(SurfWorldAz * Constant::DegToRadians); - newSurface.CosAzim = std::cos(SurfWorldAz * Constant::DegToRadians); - newSurface.SinTilt = std::sin(SurfTilt * Constant::DegToRadians); - newSurface.CosTilt = std::cos(SurfTilt * Constant::DegToRadians); + newSurface.SinAzim = std::sin(SurfWorldAz * Constant::DegToRad); + newSurface.CosAzim = std::cos(SurfWorldAz * Constant::DegToRad); + newSurface.SinTilt = std::sin(SurfTilt * Constant::DegToRad); + newSurface.CosTilt = std::cos(SurfTilt * Constant::DegToRad); // Outward normal unit vector (pointing away from room) newSurface.OutNormVec = newSurface.NewellSurfaceNormalVector; for (int n = 1; n <= 3; ++n) { @@ -9743,11 +9709,9 @@ namespace SurfaceGeometry { // Reads in the window shading control information // from the input data file, interprets it and puts it in the derived type - // Using/Aliasing - using ScheduleManager::GetScheduleIndex; - // SUBROUTINE PARAMETER DEFINITIONS: - + static constexpr std::string_view routineName = "GetWindowShadingControlData"; + int constexpr NumValidShadingTypes(9); static Array1D_string const cValidShadingTypes(NumValidShadingTypes, { @@ -9833,6 +9797,8 @@ namespace SurfaceGeometry { s_ipsc->cAlphaFieldNames, s_ipsc->cNumericFieldNames); + ErrorObjectHeader eoh{routineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)}; + ErrorInName = false; IsBlank = false; Util::VerifyName(state, @@ -9870,18 +9836,31 @@ namespace SurfaceGeometry { windowShadingControl.getInputShadedConstruction = Util::FindItemInList(s_ipsc->cAlphaArgs(4), state.dataConstruction->Construct, state.dataHeatBal->TotConstructs); windowShadingControl.ShadingDevice = Material::GetMaterialNum(state, s_ipsc->cAlphaArgs(9)); - windowShadingControl.Schedule = GetScheduleIndex(state, s_ipsc->cAlphaArgs(6)); + + if (s_ipsc->lAlphaFieldBlanks(6)) { + windowShadingControl.sched = Sched::GetScheduleAlwaysOff(state); + } else if ((windowShadingControl.sched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(6))) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(6), s_ipsc->cAlphaArgs(6)); + ErrorsFound = true; + } + windowShadingControl.SetPoint = s_ipsc->rNumericArgs(2); windowShadingControl.SetPoint2 = s_ipsc->rNumericArgs(3); windowShadingControl.ShadingControlIsScheduled = getYesNoValue(s_ipsc->cAlphaArgs(7)) == BooleanSwitch::Yes; windowShadingControl.GlareControlIsActive = getYesNoValue(s_ipsc->cAlphaArgs(8)) == BooleanSwitch::Yes; - windowShadingControl.SlatAngleSchedule = GetScheduleIndex(state, s_ipsc->cAlphaArgs(11)); + + if (s_ipsc->lAlphaFieldBlanks(11)) { + windowShadingControl.slatAngleSched = Sched::GetScheduleAlwaysOff(state); + } else if ((windowShadingControl.slatAngleSched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(11))) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(11), s_ipsc->cAlphaArgs(11)); + ErrorsFound = true; + } // store the string for now and associate it after daylighting control objects are read windowShadingControl.DaylightingControlName = s_ipsc->cAlphaArgs(12); windowShadingControl.multiSurfaceControl = - static_cast(getEnumValue(MultiSurfaceControlNamesUC, Util::makeUPPER(s_ipsc->cAlphaArgs(13)))); + static_cast(getEnumValue(MultiSurfaceControlNamesUC, s_ipsc->cAlphaArgs(13))); if (windowShadingControl.multiSurfaceControl == MultiSurfaceControl::Invalid) { windowShadingControl.multiSurfaceControl = MultiSurfaceControl::Sequential; @@ -10290,44 +10269,45 @@ namespace SurfaceGeometry { } // End of loop over window shading controls } - void InitialAssociateWindowShadingControlFenestration(EnergyPlusData &state, bool &ErrorsFound, int &SurfNum) + void InitialAssociateWindowShadingControlFenestration(EnergyPlusData &state, bool &ErrorsFound, int SurfNum) { + auto &surfTemp = state.dataSurfaceGeometry->SurfaceTmp(SurfNum); // J.Glazer 2018 - operates on SurfaceTmp array before final indices are known for windows and sets the activeWindowShadingControl for (int iShadeCtrl = 1; iShadeCtrl <= state.dataSurface->TotWinShadingControl; ++iShadeCtrl) { int curShadedConstruction = state.dataSurface->WindowShadingControl(iShadeCtrl).getInputShadedConstruction; for (int jFeneRef = 1; jFeneRef <= state.dataSurface->WindowShadingControl(iShadeCtrl).FenestrationCount; ++jFeneRef) { if (Util::SameString(state.dataSurface->WindowShadingControl(iShadeCtrl).FenestrationName(jFeneRef), - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name)) { + surfTemp.Name)) { state.dataGlobal->AndShadingControlInModel = true; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).HasShadeControl = true; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).windowShadingControlList.push_back(iShadeCtrl); - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).activeWindowShadingControl = iShadeCtrl; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).shadedConstructionList.push_back(curShadedConstruction); - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).activeShadedConstruction = curShadedConstruction; + surfTemp.HasShadeControl = true; + surfTemp.windowShadingControlList.push_back(iShadeCtrl); + surfTemp.activeWindowShadingControl = iShadeCtrl; + surfTemp.shadedConstructionList.push_back(curShadedConstruction); + surfTemp.activeShadedConstruction = curShadedConstruction; // check to make the window refenced is an exterior window - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond != ExternalEnvironment) { + if (surfTemp.ExtBoundCond != ExternalEnvironment) { ErrorsFound = true; ShowSevereError( state, format("InitialAssociateWindowShadingControlFenestration: \"{}\", invalid because it is not an exterior window.", - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name)); + surfTemp.Name)); ShowContinueError( state, format(".. It appears on WindowShadingControl object: \"{}", state.dataSurface->WindowShadingControl(iShadeCtrl).Name)); } // check to make sure the window is not using equivalent layer window construction - if (state.dataConstruction->Construct(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction).WindowTypeEQL) { + if (state.dataConstruction->Construct(surfTemp.Construction).WindowTypeEQL) { ErrorsFound = true; ShowSevereError(state, format("InitialAssociateWindowShadingControlFenestration: =\"{}\", invalid \".", - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name)); + surfTemp.Name)); ShowContinueError(state, ".. equivalent layer window model does not use shading control object."); ShowContinueError(state, ".. Shading control is set to none or zero, and simulation continues."); ShowContinueError( state, format(".. It appears on WindowShadingControl object: \"{}", state.dataSurface->WindowShadingControl(iShadeCtrl).Name)); - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).activeWindowShadingControl = 0; + surfTemp.activeWindowShadingControl = 0; } } } @@ -10621,9 +10601,6 @@ namespace SurfaceGeometry { // Reads in the window airflow control information from the input data file, // interprets it and puts it in the SurfaceWindow derived type - // Using/Aliasing - using ScheduleManager::GetScheduleIndex; - static constexpr std::string_view routineName = "GetWindowGapAirflowControlData"; int IOStat; // IO Status when calling get input subroutine @@ -10667,6 +10644,8 @@ namespace SurfaceGeometry { s_ipsc->cAlphaFieldNames, s_ipsc->cNumericFieldNames); + ErrorObjectHeader eoh{routineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)}; + SurfNum = Util::FindItemInList(s_ipsc->cAlphaArgs(1), state.dataSurface->Surface, state.dataSurface->TotSurfaces); if (SurfNum == 0) { ShowSevereError(state, format("{}=\"{}\" not found.", s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); @@ -10843,30 +10822,11 @@ namespace SurfaceGeometry { state.dataSurface->SurfWinMaxAirflow(SurfNum) = s_ipsc->rNumericArgs(1); if (s_ipsc->cAlphaArgs(4) == "SCHEDULEDONLY" && s_ipsc->cAlphaArgs(5) == "YES") { if (s_ipsc->lAlphaFieldBlanks(6)) { + ShowSevereEmptyField(state, eoh, s_ipsc->cAlphaFieldNames(6), s_ipsc->cAlphaFieldNames(4), s_ipsc->cAlphaArgs(4)); + ErrorsFound = true; + } else if ((state.dataSurface->SurfWinAirflowScheds(SurfNum) = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(6))) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(6), s_ipsc->cAlphaArgs(6)); ErrorsFound = true; - ShowSevereError(state, - format("{}=\"{}\", has {}=\"{}\"", - s_ipsc->cCurrentModuleObject, - s_ipsc->cAlphaArgs(1), - s_ipsc->cAlphaFieldNames(4), - s_ipsc->cAlphaArgs(4))); - ShowContinueError(state, - format("..and {}=\"{}\", but no {} specified.", - s_ipsc->cAlphaFieldNames(5), - s_ipsc->cAlphaArgs(5), - s_ipsc->cAlphaFieldNames(6))); - } else { - state.dataSurface->SurfWinAirflowHasSchedule(SurfNum) = true; - state.dataSurface->SurfWinAirflowSchedulePtr(SurfNum) = GetScheduleIndex(state, s_ipsc->cAlphaArgs(6)); - if (state.dataSurface->SurfWinAirflowSchedulePtr(SurfNum) == 0) { - ErrorsFound = true; - ShowSevereError(state, - format("{}=\"{}\", invalid {}=\"{}\"", - s_ipsc->cCurrentModuleObject, - s_ipsc->cAlphaArgs(1), - s_ipsc->cAlphaFieldNames(6), - s_ipsc->cAlphaArgs(6))); - } } } // Warning if associated window is an interior window @@ -11038,7 +10998,7 @@ namespace SurfaceGeometry { state.dataSurfaceGeometry->kivaManager.timestep = 3600.; // seconds } else { // if (Util::SameString(s_ipsc->cAlphaArgs( alpF ), "Timestep")) state.dataSurfaceGeometry->kivaManager.settings.timestepType = HeatBalanceKivaManager::KivaManager::Settings::TIMESTEP; - state.dataSurfaceGeometry->kivaManager.timestep = state.dataGlobal->MinutesPerTimeStep * 60.; + state.dataSurfaceGeometry->kivaManager.timestep = state.dataGlobal->MinutesInTimeStep * 60.; } } alpF++; @@ -11602,10 +11562,7 @@ namespace SurfaceGeometry { // \units C // \default 200 - // Using/Aliasing - - using ScheduleManager::GetScheduleIndex; - + static constexpr std::string_view routineName = "GetOSCData"; // Locals // SUBROUTINE ARGUMENT DEFINITIONS: @@ -11639,6 +11596,9 @@ namespace SurfaceGeometry { s_ipsc->lAlphaFieldBlanks, s_ipsc->cAlphaFieldNames, s_ipsc->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)}; + ErrorInName = false; IsBlank = false; Util::VerifyName( @@ -11660,21 +11620,10 @@ namespace SurfaceGeometry { state.dataSurface->OSC(OSCNum).ZoneAirTempCoef = s_ipsc->rNumericArgs(7); state.dataSurface->OSC(OSCNum).SinusoidPeriod = s_ipsc->rNumericArgs(8); - if ((!s_ipsc->lAlphaFieldBlanks(2)) && (NumAlphas != 1)) { // Const temp will come from schedule specified below. - state.dataSurface->OSC(OSCNum).ConstTempScheduleName = s_ipsc->cAlphaArgs(2); - if (!state.dataSurface->OSC(OSCNum).ConstTempScheduleName.empty()) { - state.dataSurface->OSC(OSCNum).ConstTempScheduleIndex = - GetScheduleIndex(state, state.dataSurface->OSC(OSCNum).ConstTempScheduleName); - if (state.dataSurface->OSC(OSCNum).ConstTempScheduleIndex == 0) { - ShowSevereError(state, - format("{}=\"{}\", invalid {}=\"{}", - s_ipsc->cCurrentModuleObject, - s_ipsc->cAlphaArgs(1), - s_ipsc->cAlphaFieldNames(2), - s_ipsc->cAlphaArgs(2))); - ErrorsFound = true; - } - } + if ((NumAlphas == 1) || s_ipsc->lAlphaFieldBlanks(2)) { // Const temp will come from schedule specified below. + } else if ((state.dataSurface->OSC(OSCNum).constTempSched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2)); + ErrorsFound = true; } if (!s_ipsc->lAlphaFieldBlanks(3)) { @@ -11748,7 +11697,7 @@ namespace SurfaceGeometry { } else { s_ipsc->cAlphaArgs(1) = "N/A"; } - if (state.dataSurface->OSC(Loop).ConstTempScheduleIndex != 0) { + if (state.dataSurface->OSC(Loop).constTempSched != nullptr) { s_ipsc->cAlphaArgs(2) = state.dataSurface->OSC(Loop).ConstTempScheduleName; constexpr std::string_view format = "Other Side Coefficients,{},{},{},{:.3R},{:.3R},{:.3R},{:.3R},{:.3R},{},{},{:.3R},{:.3R},{}\n"; print(state.files.eio, @@ -11961,10 +11910,8 @@ namespace SurfaceGeometry { // \type object-list // \object-list ScheduleNames - // Using/Aliasing - - using ScheduleManager::GetScheduleIndex; - + static constexpr std::string_view routineName = "GetMovableInsulationInput"; + // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int NAlphas; int NNums; @@ -11973,7 +11920,6 @@ namespace SurfaceGeometry { int NMatInsul; int SurfNum; int MaterNum; - int SchNum; enum class InsulationType { @@ -12002,36 +11948,45 @@ namespace SurfaceGeometry { s_ipsc->lAlphaFieldBlanks, s_ipsc->cAlphaFieldNames, s_ipsc->cNumericFieldNames); - SurfNum = Util::FindItemInList(s_ipsc->cAlphaArgs(2), state.dataSurface->Surface, state.dataSurface->TotSurfaces); - MaterNum = Material::GetMaterialNum(state, s_ipsc->cAlphaArgs(3)); - auto *thisMaterial = s_mat->materials(MaterNum); - SchNum = GetScheduleIndex(state, s_ipsc->cAlphaArgs(4)); + + ErrorObjectHeader eoh{routineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)}; + InsulationType insulationType = static_cast(getEnumValue(insulationTypeNamesUC, s_ipsc->cAlphaArgs(1))); if (insulationType == InsulationType::Invalid) { - ShowSevereError( - state, format("{}, {}=\"{}\", invalid data.", s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2))); - ShowContinueError(state, - format(" invalid {}=\"{}\", [should be Inside or Outside]", s_ipsc->cAlphaFieldNames(1), s_ipsc->cAlphaArgs(1))); + ShowSevereInvalidKey(state, eoh, s_ipsc->cAlphaFieldNames(1), s_ipsc->cAlphaArgs(1)); ErrorsFound = true; + continue; } - if (SurfNum == 0) { - ShowSevereError( - state, format("{}, {}=\"{}\", invalid data.", s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2))); - ShowContinueError(state, format(" invalid (not found) {}", s_ipsc->cAlphaFieldNames(2))); + + if ((SurfNum = Util::FindItemInList(s_ipsc->cAlphaArgs(2), state.dataSurface->Surface, state.dataSurface->TotSurfaces)) == 0) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2)); ErrorsFound = true; - } else { - if (MaterNum == 0) { - ShowSevereError( - state, - format("{}, {}=\"{}\", invalid data.", s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2))); - ShowContinueError(state, format(" invalid (not found) {}=\"{}\"", s_ipsc->cAlphaFieldNames(3), s_ipsc->cAlphaArgs(3))); - ErrorsFound = true; - } else { + continue; + } + + if ((MaterNum = Material::GetMaterialNum(state, s_ipsc->cAlphaArgs(3))) == 0) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(3), s_ipsc->cAlphaArgs(3)); + ErrorsFound = true; + continue; + } + + Sched::Schedule *sched = nullptr; + if (s_ipsc->lAlphaFieldBlanks(4)) { + ShowSevereEmptyField(state, eoh, s_ipsc->cAlphaFieldNames(4)); + ErrorsFound = true; + continue; + } else if ((sched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(4))) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(4), s_ipsc->cAlphaArgs(4)); + ErrorsFound = true; + continue; + } + + auto *thisMaterial = s_mat->materials(MaterNum); - Array1D_string const cMaterialGroupType({-1, 18}, - {"invalid", - "Material/Material:NoMass", - "Material:AirGap", + Array1D_string const cMaterialGroupType({-1, 18}, + {"invalid", + "Material/Material:NoMass", + "Material:AirGap", "WindowMaterial:Shade", "WindowMaterial:Glazing*", "WindowMaterial:Gas", @@ -12050,122 +12005,116 @@ namespace SurfaceGeometry { "WindowMaterial:Screen:EquivalentLayer", "WindowMaterial:Gap:EquivalentLayer"}); - Material::Group const MaterialLayerGroup = thisMaterial->group; - if ((MaterialLayerGroup == Material::Group::GlassSimple) || (MaterialLayerGroup == Material::Group::ShadeEQL) || - (MaterialLayerGroup == Material::Group::DrapeEQL) || (MaterialLayerGroup == Material::Group::BlindEQL) || - (MaterialLayerGroup == Material::Group::ScreenEQL) || (MaterialLayerGroup == Material::Group::WindowGapEQL)) { - ShowSevereError(state, format("Invalid movable insulation material for {}:", s_ipsc->cCurrentModuleObject)); - ShowSevereError( - state, - format("...Movable insulation material type specified = {}", cMaterialGroupType(static_cast(MaterialLayerGroup)))); - ShowSevereError(state, format("...Movable insulation material name specified = {}", s_ipsc->cAlphaArgs(3))); + Material::Group const MaterialLayerGroup = thisMaterial->group; + if ((MaterialLayerGroup == Material::Group::GlassSimple) || (MaterialLayerGroup == Material::Group::ShadeEQL) || + (MaterialLayerGroup == Material::Group::DrapeEQL) || (MaterialLayerGroup == Material::Group::BlindEQL) || + (MaterialLayerGroup == Material::Group::ScreenEQL) || (MaterialLayerGroup == Material::Group::WindowGapEQL)) { + ShowSevereError(state, format("Invalid movable insulation material for {}:", s_ipsc->cCurrentModuleObject)); + ShowSevereError( + state, + format("...Movable insulation material type specified = {}", cMaterialGroupType(static_cast(MaterialLayerGroup)))); + ShowSevereError(state, format("...Movable insulation material name specified = {}", s_ipsc->cAlphaArgs(3))); + ErrorsFound = true; + } + + switch (insulationType) { + case InsulationType::Outside: { + if (state.dataSurface->SurfMaterialMovInsulExt(SurfNum) > 0) { + ShowSevereError(state, + format("{}, {}=\"{}\", already assigned.", + s_ipsc->cCurrentModuleObject, + s_ipsc->cAlphaFieldNames(2), + s_ipsc->cAlphaArgs(2))); + ShowContinueError(state, + format("\"Outside\", was already assigned Material=\"{}\".", + s_mat->materials(state.dataSurface->SurfMaterialMovInsulExt(SurfNum))->Name)); + ShowContinueError(state, format("attempting to assign Material=\"{}\".", thisMaterial->Name)); + ErrorsFound = true; + } + + state.dataSurface->SurfMaterialMovInsulExt(SurfNum) = MaterNum; + state.dataSurface->SurfMovInsulExtScheds(SurfNum) = sched; + state.dataSurface->AnyMovableInsulation = true; + if (thisMaterial->Resistance <= 0.0) { + if (thisMaterial->Conductivity <= 0.0 || thisMaterial->Thickness <= 0.0) { + ShowSevereError(state, + format("{}, {}=\"{}\", invalid material.", + s_ipsc->cCurrentModuleObject, + s_ipsc->cAlphaFieldNames(2), + s_ipsc->cAlphaArgs(2))); + ShowContinueError(state, "\"Outside\", invalid material for movable insulation."); + ShowContinueError(state, + format("Material=\"{}\",Resistance=[{:.3R}], must be > 0 for use in Movable Insulation.", + thisMaterial->Name, + thisMaterial->Resistance)); ErrorsFound = true; + } else if (thisMaterial->Conductivity > 0.0) { + thisMaterial->Resistance = thisMaterial->Thickness / thisMaterial->Conductivity; } - if (SchNum == 0) { - ShowSevereError( - state, - format("{}, {}=\"{}\", invalid data.", s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2))); - ShowContinueError(state, format(" invalid (not found) {}=\"{}\"", s_ipsc->cAlphaFieldNames(4), s_ipsc->cAlphaArgs(4))); + } + + if (thisMaterial->Conductivity <= 0.0) { + if (thisMaterial->Resistance <= 0.0) { + ShowSevereError(state, + format("{}, {}=\"{}\", invalid material.", + s_ipsc->cCurrentModuleObject, + s_ipsc->cAlphaFieldNames(2), + s_ipsc->cAlphaArgs(2))); + ShowContinueError(state, "\"Outside\", invalid material for movable insulation."); + ShowContinueError(state, + format("Material=\"{}\",Conductivity=[{:.3R}], must be > 0 for use in Movable Insulation.", + thisMaterial->Name, + thisMaterial->Conductivity)); ErrorsFound = true; - } else { - { - switch (insulationType) { - case InsulationType::Outside: - if (state.dataSurface->SurfMaterialMovInsulExt(SurfNum) > 0) { - ShowSevereError(state, - format("{}, {}=\"{}\", already assigned.", - s_ipsc->cCurrentModuleObject, - s_ipsc->cAlphaFieldNames(2), - s_ipsc->cAlphaArgs(2))); - ShowContinueError(state, - format("\"Outside\", was already assigned Material=\"{}\".", - s_mat->materials(state.dataSurface->SurfMaterialMovInsulInt(SurfNum))->Name)); - ShowContinueError(state, format("attempting to assign Material=\"{}\".", thisMaterial->Name)); - ErrorsFound = true; - } - state.dataSurface->SurfMaterialMovInsulExt(SurfNum) = MaterNum; - state.dataSurface->SurfSchedMovInsulExt(SurfNum) = SchNum; - state.dataSurface->AnyMovableInsulation = true; - if (thisMaterial->Resistance <= 0.0) { - if (thisMaterial->Conductivity <= 0.0 || thisMaterial->Thickness <= 0.0) { - ShowSevereError(state, - format("{}, {}=\"{}\", invalid material.", - s_ipsc->cCurrentModuleObject, - s_ipsc->cAlphaFieldNames(2), - s_ipsc->cAlphaArgs(2))); - ShowContinueError(state, "\"Outside\", invalid material for movable insulation."); - ShowContinueError(state, - format("Material=\"{}\",Resistance=[{:.3R}], must be > 0 for use in Movable Insulation.", - thisMaterial->Name, - thisMaterial->Resistance)); - ErrorsFound = true; - } else if (thisMaterial->Conductivity > 0.0) { - thisMaterial->Resistance = thisMaterial->Thickness / thisMaterial->Conductivity; - } - } - if (thisMaterial->Conductivity <= 0.0) { - if (thisMaterial->Resistance <= 0.0) { - ShowSevereError(state, - format("{}, {}=\"{}\", invalid material.", - s_ipsc->cCurrentModuleObject, - s_ipsc->cAlphaFieldNames(2), - s_ipsc->cAlphaArgs(2))); - ShowContinueError(state, "\"Outside\", invalid material for movable insulation."); - ShowContinueError(state, - format("Material=\"{}\",Conductivity=[{:.3R}], must be > 0 for use in Movable Insulation.", - thisMaterial->Name, - thisMaterial->Conductivity)); - ErrorsFound = true; - } - } - break; - case InsulationType::Inside: - if (state.dataSurface->SurfMaterialMovInsulInt(SurfNum) > 0) { - ShowSevereError(state, - s_ipsc->cCurrentModuleObject + ", " + s_ipsc->cAlphaFieldNames(2) + "=\"" + - s_ipsc->cAlphaArgs(2) + "\", already assigned."); - ShowContinueError(state, - "\"Inside\", was already assigned Material=\"" + - s_mat->materials(state.dataSurface->SurfMaterialMovInsulInt(SurfNum))->Name + "\"."); - ShowContinueError(state, "attempting to assign Material=\"" + thisMaterial->Name + "\"."); - ErrorsFound = true; - } - state.dataSurface->SurfMaterialMovInsulInt(SurfNum) = MaterNum; - state.dataSurface->SurfSchedMovInsulInt(SurfNum) = SchNum; - state.dataSurface->AnyMovableInsulation = true; - if (thisMaterial->Resistance <= 0.0) { - if (thisMaterial->Conductivity <= 0.0 || thisMaterial->Thickness <= 0.0) { - ShowSevereError(state, - format("{}, {}=\"{}\", invalid material.", - s_ipsc->cCurrentModuleObject, - s_ipsc->cAlphaFieldNames(2), - s_ipsc->cAlphaArgs(2))); - ShowContinueError(state, "\"Inside\", invalid material for movable insulation."); - ShowContinueError(state, - format("Material=\"{}\",Resistance=[{:.3R}], must be > 0 for use in Movable Insulation.", - thisMaterial->Name, - thisMaterial->Resistance)); - ErrorsFound = true; - } else if (thisMaterial->Conductivity > 0.0) { - thisMaterial->Resistance = thisMaterial->Thickness / thisMaterial->Conductivity; - } - } - break; - default: - assert(false); - } - } - if (state.dataSurface->Surface(SurfNum).Class == SurfaceClass::Window) { - ShowSevereError( - state, format("{}, {}=\"{}\"", s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2))); - ShowContinueError(state, "invalid use on a Window. Use WindowShadingControl instead."); - ErrorsFound = true; - } } } + } break; + + case InsulationType::Inside: { + if (state.dataSurface->SurfMaterialMovInsulInt(SurfNum) > 0) { + ShowSevereError(state, + s_ipsc->cCurrentModuleObject + ", " + s_ipsc->cAlphaFieldNames(2) + "=\"" + + s_ipsc->cAlphaArgs(2) + "\", already assigned."); + ShowContinueError(state, + "\"Inside\", was already assigned Material=\"" + + s_mat->materials(state.dataSurface->SurfMaterialMovInsulInt(SurfNum))->Name + "\"."); + ShowContinueError(state, "attempting to assign Material=\"" + thisMaterial->Name + "\"."); + ErrorsFound = true; + } + + state.dataSurface->SurfMaterialMovInsulInt(SurfNum) = MaterNum; + state.dataSurface->SurfMovInsulIntScheds(SurfNum) = sched; + state.dataSurface->AnyMovableInsulation = true; + if (thisMaterial->Resistance <= 0.0) { + if (thisMaterial->Conductivity <= 0.0 || thisMaterial->Thickness <= 0.0) { + ShowSevereError(state, + format("{}, {}=\"{}\", invalid material.", + s_ipsc->cCurrentModuleObject, + s_ipsc->cAlphaFieldNames(2), + s_ipsc->cAlphaArgs(2))); + ShowContinueError(state, "\"Inside\", invalid material for movable insulation."); + ShowContinueError(state, + format("Material=\"{}\",Resistance=[{:.3R}], must be > 0 for use in Movable Insulation.", + thisMaterial->Name, + thisMaterial->Resistance)); + ErrorsFound = true; + } else if (thisMaterial->Conductivity > 0.0) { + thisMaterial->Resistance = thisMaterial->Thickness / thisMaterial->Conductivity; + } + } + } break; + default: { + assert(false); + } break; + } // switch (inulationType) + + if (state.dataSurface->Surface(SurfNum).Class == SurfaceClass::Window) { + ShowSevereError(state, format("{}, {}=\"{}\"", s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2))); + ShowContinueError(state, "invalid use on a Window. Use WindowShadingControl instead."); + ErrorsFound = true; } - } - } + } // for (Loop) + } // GetMovableInsulationData() // Calculates the volume (m3) of a zone using the surfaces as possible. void CalculateZoneVolume(EnergyPlusData &state) @@ -13156,10 +13105,10 @@ namespace SurfaceGeometry { // Retrieve base surface info Real64 const baseSurfWorldAz = state.dataSurface->Surface(ThisBaseSurface).Azimuth; Real64 const baseSurfTilt = state.dataSurface->Surface(ThisBaseSurface).Tilt; - Real64 const BaseCosAzimuth = std::cos(baseSurfWorldAz * Constant::DegToRadians); - Real64 const BaseSinAzimuth = std::sin(baseSurfWorldAz * Constant::DegToRadians); - Real64 const BaseCosTilt = std::cos(baseSurfTilt * Constant::DegToRadians); - Real64 const BaseSinTilt = std::sin(baseSurfTilt * Constant::DegToRadians); + Real64 const BaseCosAzimuth = std::cos(baseSurfWorldAz * Constant::DegToRad); + Real64 const BaseSinAzimuth = std::sin(baseSurfWorldAz * Constant::DegToRad); + Real64 const BaseCosTilt = std::cos(baseSurfTilt * Constant::DegToRad); + Real64 const BaseSinTilt = std::sin(baseSurfTilt * Constant::DegToRad); Real64 const BaseXLLC = state.dataSurface->Surface(ThisBaseSurface).Vertex(2).x; Real64 const BaseYLLC = state.dataSurface->Surface(ThisBaseSurface).Vertex(2).y; Real64 const BaseZLLC = state.dataSurface->Surface(ThisBaseSurface).Vertex(2).z; @@ -13634,9 +13583,10 @@ namespace SurfaceGeometry { // INTEGER :: loop ! DO loop index auto &s_mat = state.dataMaterial; + auto &surfTemp = state.dataSurfaceGeometry->SurfaceTmp(SurfNum); ShDevName = s_mat->materials(ShDevNum)->Name; - ConstrNum = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction; + ConstrNum = surfTemp.Construction; ConstrName = state.dataConstruction->Construct(ConstrNum).Name; if (ANY_INTERIOR_SHADE_BLIND(state.dataSurface->WindowShadingControl(WSCPtr).ShadingType)) { ConstrNameSh = ConstrName + ':' + ShDevName + ":INT"; @@ -13649,15 +13599,15 @@ namespace SurfaceGeometry { ConstrNewSh = Util::FindItemInList(ConstrNameSh, state.dataConstruction->Construct); if (ConstrNewSh > 0) { - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).shadedConstructionList[shadeControlIndex] = ConstrNewSh; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).activeShadedConstruction = ConstrNewSh; // set the active to the current for now + surfTemp.shadedConstructionList[shadeControlIndex] = ConstrNewSh; + surfTemp.activeShadedConstruction = ConstrNewSh; // set the active to the current for now } else { // Create new construction ConstrNewSh = state.dataHeatBal->TotConstructs + 1; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).shadedConstructionList[shadeControlIndex] = ConstrNewSh; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).activeShadedConstruction = ConstrNewSh; // set the active to the current for now + surfTemp.shadedConstructionList[shadeControlIndex] = ConstrNewSh; + surfTemp.activeShadedConstruction = ConstrNewSh; // set the active to the current for now state.dataHeatBal->TotConstructs = ConstrNewSh; state.dataConstruction->Construct.redimension(state.dataHeatBal->TotConstructs); state.dataHeatBal->NominalRforNominalUCalculation.redimension(state.dataHeatBal->TotConstructs); @@ -14010,6 +13960,8 @@ namespace SurfaceGeometry { std::string Const2Name; // Name of construction of second glazing system // unused1208 REAL(r64) :: AreaNew ! Sum of areas of the two glazing systems (m2) + auto &surfTemp = state.dataSurfaceGeometry->SurfaceTmp(SurfNum); + struct rectangularwindow { // Members @@ -14025,17 +13977,16 @@ namespace SurfaceGeometry { Vector TVect; rectangularwindow OriginalCoord; - IConst = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction; + IConst = surfTemp.Construction; // Height and width of original window - TVect = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(3) - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(2); + TVect = surfTemp.Vertex(3) - surfTemp.Vertex(2); W = VecLength(TVect); // SQRT((X(3)-X(2))**2 + (Y(3)-Y(2))**2 + (Z(3)-Z(2))**2) - TVect = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(2) - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(1); + TVect = surfTemp.Vertex(2) - surfTemp.Vertex(1); H = VecLength(TVect); // SQRT((X(1)-X(2))**2 + (Y(1)-Y(2))**2 + (Z(1)-Z(2))**2) // Save coordinates of original window in case Window 5 data overwrites. - OriginalCoord.Vertex({1, state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides}) = - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex({1, state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides}); + OriginalCoord.Vertex({1, surfTemp.Sides}) = surfTemp.Vertex({1, surfTemp.Sides}); // Height and width of first glazing system h1 = state.dataConstruction->Construct(IConst).W5FileGlazingSysHeight; @@ -14054,7 +14005,7 @@ namespace SurfaceGeometry { if (state.dataGlobal->DisplayExtraWarnings) { ShowWarningError(state, format("SurfaceGeometry: ModifyWindow: Window {} uses the Window5 Data File Construction {}", - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, state.dataConstruction->Construct(IConst).Name)); ShowContinueError(state, format("The height {:.3R}(m) or width (m) of this window differs by more than 10%{:.3R}", H, W)); ShowContinueError(state, @@ -14067,25 +14018,24 @@ namespace SurfaceGeometry { } // Calculate net area for base surface - state.dataSurfaceGeometry->SurfaceTmp(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).BaseSurf).Area -= - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Area; - if (state.dataSurfaceGeometry->SurfaceTmp(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).BaseSurf).Area <= 0.0) { + state.dataSurfaceGeometry->SurfaceTmp(surfTemp.BaseSurf).Area -= + surfTemp.Area; + if (state.dataSurfaceGeometry->SurfaceTmp(surfTemp.BaseSurf).Area <= 0.0) { ShowSevereError(state, format("Subsurfaces have too much area for base surface={}", - state.dataSurfaceGeometry->SurfaceTmp(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).BaseSurf).Name)); - ShowContinueError(state, format("Subsurface creating error={}", state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name)); + state.dataSurfaceGeometry->SurfaceTmp(surfTemp.BaseSurf).Name)); + ShowContinueError(state, format("Subsurface creating error={}", surfTemp.Name)); ErrorsFound = true; } // Net area of base surface with unity window multipliers (used in shadowing checks) - state.dataSurfaceGeometry->SurfaceTmp(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).BaseSurf).NetAreaShadowCalc -= - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Area / state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Multiplier; + state.dataSurfaceGeometry->SurfaceTmp(surfTemp.BaseSurf).NetAreaShadowCalc -= surfTemp.Area / surfTemp.Multiplier; } else { // Two glazing systems on Window5 data file for this window // if exterior window, okay. - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond == ExternalEnvironment) { + if (surfTemp.ExtBoundCond == ExternalEnvironment) { // There are two glazing systems (separated by a vertical or horizontal mullion) on the Window5 Data File. // Fill in geometry data for the second window (corresponding to the second glazing system on the data file. // The first glazing system is assumed to be at left for vertical mullion, at bottom for horizontal mullion. @@ -14096,7 +14046,7 @@ namespace SurfaceGeometry { if (state.dataGlobal->DisplayExtraWarnings) { ShowMessage(state, format("SurfaceGeometry: ModifyWindow: Window {} has been replaced with the Window 5/6 two glazing system=\"{}\".", - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, state.dataConstruction->Construct(IConst).Name)); ShowContinueError(state, "Note that originally entered dimensions are overridden."); } else { @@ -14106,13 +14056,13 @@ namespace SurfaceGeometry { // Allocate another window AddWindow(state, SurfNum, ErrorsFound, AddedSubSurfaces); - } else if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond > 0) { // Interior window, specified ! not external environment + } else if (surfTemp.ExtBoundCond > 0) { // Interior window, specified ! not external environment if (state.dataGlobal->DisplayExtraWarnings) { ShowWarningError( state, format("SurfaceGeometry: ModifyWindow: Interior Window {} has been replaced with the Window 5/6 two glazing system=\"{}\".", - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name, + surfTemp.Name, state.dataConstruction->Construct(IConst).Name)); ShowContinueError( state, "Please check to make sure interior window is correct. Note that originally entered dimensions are overridden."); @@ -14126,7 +14076,7 @@ namespace SurfaceGeometry { ShowSevereError(state, format("SurfaceGeometry: ModifyWindow: Interior Window {} is a window in an adjacent zone.", - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name)); + surfTemp.Name)); ShowContinueError( state, format("Attempted to add/reverse Window 5/6 multiple glazing system=\"{}\".", state.dataConstruction->Construct(IConst).Name)); @@ -14203,17 +14153,18 @@ namespace SurfaceGeometry { rectangularwindow NewCoord; rectangularwindow OriginalCoord; - IConst = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Construction; + auto &surfTemp = state.dataSurfaceGeometry->SurfaceTmp(SurfNum); + + IConst = surfTemp.Construction; // Height and width of original window - TVect = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(3) - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(2); + TVect = surfTemp.Vertex(3) - surfTemp.Vertex(2); W = VecLength(TVect); // SQRT((X(3)-X(2))**2 + (Y(3)-Y(2))**2 + (Z(3)-Z(2))**2) - TVect = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(2) - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(1); + TVect = surfTemp.Vertex(2) - surfTemp.Vertex(1); H = VecLength(TVect); // SQRT((X(1)-X(2))**2 + (Y(1)-Y(2))**2 + (Z(1)-Z(2))**2) // Save coordinates of original window in case Window 5 data overwrites. - OriginalCoord.Vertex({1, state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides}) = - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex({1, state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides}); + OriginalCoord.Vertex({1, surfTemp.Sides}) = surfTemp.Vertex({1, surfTemp.Sides}); // Height and width of first glazing system h1 = state.dataConstruction->Construct(IConst).W5FileGlazingSysHeight; @@ -14227,71 +14178,71 @@ namespace SurfaceGeometry { state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).Vertex.allocate(4); - state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).Name = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name + ":2"; + state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).Name = surfTemp.Name + ":2"; state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).Construction = IConst2; state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).ConstructionStoredInputValue = IConst2; - state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).Class = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class; - state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).Azimuth = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Azimuth; + state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).Class = surfTemp.Class; + state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).Azimuth = surfTemp.Azimuth; // Sine and cosine of azimuth and tilt - state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).SinAzim = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).SinAzim; - state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).CosAzim = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).CosAzim; - state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).SinTilt = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).SinTilt; - state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).CosTilt = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).CosTilt; + state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).SinAzim = surfTemp.SinAzim; + state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).CosAzim = surfTemp.CosAzim; + state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).SinTilt = surfTemp.SinTilt; + state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).CosTilt = surfTemp.CosTilt; // Outward normal unit vector (pointing away from room) - state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).Centroid = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Centroid; - state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).lcsx = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).lcsx; - state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).lcsy = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).lcsy; - state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).lcsz = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).lcsz; + state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).Centroid = surfTemp.Centroid; + state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).lcsx = surfTemp.lcsx; + state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).lcsy = surfTemp.lcsy; + state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).lcsz = surfTemp.lcsz; state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).NewellAreaVector = - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).NewellAreaVector; - state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).OutNormVec = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).OutNormVec; - state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).Reveal = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Reveal; - state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).Shape = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Shape; - state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).Sides = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides; - state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).Tilt = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Tilt; + surfTemp.NewellAreaVector; + state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).OutNormVec = surfTemp.OutNormVec; + state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).Reveal = surfTemp.Reveal; + state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).Shape = surfTemp.Shape; + state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).Sides = surfTemp.Sides; + state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).Tilt = surfTemp.Tilt; state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).convOrientation = - Convect::GetSurfConvOrientation(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Tilt); + Convect::GetSurfConvOrientation(surfTemp.Tilt); state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).HeatTransSurf = - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).HeatTransSurf; + surfTemp.HeatTransSurf; state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).BaseSurfName = - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).BaseSurfName; - state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).BaseSurf = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).BaseSurf; - state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).ZoneName = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ZoneName; - state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).Zone = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Zone; + surfTemp.BaseSurfName; + state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).BaseSurf = surfTemp.BaseSurf; + state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).ZoneName = surfTemp.ZoneName; + state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).Zone = surfTemp.Zone; state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).ExtBoundCondName = - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCondName; + surfTemp.ExtBoundCondName; state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).ExtBoundCond = - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtBoundCond; - state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).ExtSolar = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtSolar; - state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).ExtWind = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ExtWind; + surfTemp.ExtBoundCond; + state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).ExtSolar = surfTemp.ExtSolar; + state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).ExtWind = surfTemp.ExtWind; state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).ViewFactorGround = - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ViewFactorGround; + surfTemp.ViewFactorGround; state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).ViewFactorSky = - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ViewFactorSky; + surfTemp.ViewFactorSky; state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).ViewFactorGroundIR = - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ViewFactorGroundIR; + surfTemp.ViewFactorGroundIR; state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).ViewFactorSkyIR = - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ViewFactorSkyIR; - state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).OSCPtr = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).OSCPtr; - state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).SchedShadowSurfIndex = - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).SchedShadowSurfIndex; + surfTemp.ViewFactorSkyIR; + state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).OSCPtr = surfTemp.OSCPtr; + state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).shadowSurfSched = + surfTemp.shadowSurfSched; state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).activeWindowShadingControl = - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).activeWindowShadingControl; + surfTemp.activeWindowShadingControl; state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).windowShadingControlList = - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).windowShadingControlList; + surfTemp.windowShadingControlList; state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).HasShadeControl = - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).HasShadeControl; + surfTemp.HasShadeControl; state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).activeShadedConstruction = - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).activeShadedConstruction; + surfTemp.activeShadedConstruction; state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).windowShadingControlList = - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).windowShadingControlList; + surfTemp.windowShadingControlList; state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).shadedStormWinConstructionList = - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).shadedStormWinConstructionList; + surfTemp.shadedStormWinConstructionList; state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).FrameDivider = - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).FrameDivider; - state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).Multiplier = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Multiplier; + surfTemp.FrameDivider; + state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).Multiplier = surfTemp.Multiplier; state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).NetAreaShadowCalc = - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).NetAreaShadowCalc; + surfTemp.NetAreaShadowCalc; MulWidth = state.dataConstruction->Construct(IConst).W5FileMullionWidth; w2 = state.dataConstruction->Construct(IConst2).W5FileGlazingSysWidth; @@ -14301,21 +14252,21 @@ namespace SurfaceGeometry { // area of the two glazing systems. Note that for Surface(SurfNum)%Class = 'Window' the effect // of a window multiplier is included in the glazing area. Note that frame areas are subtracted later. - AreaNew = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Multiplier * (h1 * w1 + h2 * w2); // both glazing systems + AreaNew = surfTemp.Multiplier * (h1 * w1 + h2 * w2); // both glazing systems // Adjust net area for base surface - state.dataSurfaceGeometry->SurfaceTmp(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).BaseSurf).Area -= AreaNew; + state.dataSurfaceGeometry->SurfaceTmp(surfTemp.BaseSurf).Area -= AreaNew; // Net area of base surface with unity window multipliers (used in shadowing checks) - state.dataSurfaceGeometry->SurfaceTmp(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).BaseSurf).NetAreaShadowCalc -= - AreaNew / state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Multiplier; + state.dataSurfaceGeometry->SurfaceTmp(surfTemp.BaseSurf).NetAreaShadowCalc -= + AreaNew / surfTemp.Multiplier; // Reset area, etc. of original window - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Area = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Multiplier * (h1 * w1); - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).GrossArea = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Area; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).NetAreaShadowCalc = h1 * w1; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Perimeter = 2 * (h1 + w1); - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Height = h1; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Width = w1; + surfTemp.Area = surfTemp.Multiplier * (h1 * w1); + surfTemp.GrossArea = surfTemp.Area; + surfTemp.NetAreaShadowCalc = h1 * w1; + surfTemp.Perimeter = 2 * (h1 + w1); + surfTemp.Height = h1; + surfTemp.Width = w1; // Set area, etc. of new window state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).Area = state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).Multiplier * (h2 * w2); @@ -14326,11 +14277,11 @@ namespace SurfaceGeometry { state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).Height = h2; state.dataSurfaceGeometry->SurfaceTmp(state.dataSurface->TotSurfaces).Width = w2; - if (state.dataSurfaceGeometry->SurfaceTmp(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).BaseSurf).Area <= 0.0) { + if (state.dataSurfaceGeometry->SurfaceTmp(surfTemp.BaseSurf).Area <= 0.0) { ShowSevereError(state, format("SurfaceGeometry: ModifyWindow: Subsurfaces have too much area for base surface={}", - state.dataSurfaceGeometry->SurfaceTmp(state.dataSurfaceGeometry->SurfaceTmp(SurfNum).BaseSurf).Name)); - ShowContinueError(state, format("Subsurface (window) creating error={}", state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name)); + state.dataSurfaceGeometry->SurfaceTmp(surfTemp.BaseSurf).Name)); + ShowContinueError(state, format("Subsurface (window) creating error={}", surfTemp.Name)); ShowContinueError(state, format("This window has been replaced by two windows from the Window5 Data File of total area {:.2R} m2", AreaNew)); ErrorsFound = true; @@ -14398,8 +14349,8 @@ namespace SurfaceGeometry { NewCoord.Vertex(4).y = ya + (dx / W) * (yb - ya); NewCoord.Vertex(4).z = za + (dx / W) * (zb - za); - for (loop = 1; loop <= state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides; ++loop) { - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(loop) = NewCoord.Vertex(loop); + for (loop = 1; loop <= surfTemp.Sides; ++loop) { + surfTemp.Vertex(loop) = NewCoord.Vertex(loop); } // Right-hand glazing @@ -14519,8 +14470,8 @@ namespace SurfaceGeometry { NewCoord.Vertex(4).y = ya + (dx / W) * (yb - ya); NewCoord.Vertex(4).z = za + (dx / W) * (zb - za); - for (loop = 1; loop <= state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Sides; ++loop) { - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(loop) = NewCoord.Vertex(loop); + for (loop = 1; loop <= surfTemp.Sides; ++loop) { + surfTemp.Vertex(loop) = NewCoord.Vertex(loop); } // Top glazing @@ -14631,6 +14582,7 @@ namespace SurfaceGeometry { // get user input... auto &s_ipsc = state.dataIPShortCut; + auto &surfTemp = state.dataSurfaceGeometry->SurfaceTmp(SurfNum); if (state.dataSurfaceGeometry->firstTime) { if (state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject) == 1) { @@ -14667,9 +14619,9 @@ namespace SurfaceGeometry { if (state.dataSurfaceGeometry->noTransform) return; // check surface type. - if (!state.dataSurfaceGeometry->SurfaceTmp(SurfNum).HeatTransSurf) { + if (!surfTemp.HeatTransSurf) { // Site Shading do not get transformed. - if (state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Class == SurfaceClass::Detached_F) return; + if (surfTemp.Class == SurfaceClass::Detached_F) return; } // testing method of transforming x and y coordinates as follows @@ -14678,8 +14630,8 @@ namespace SurfaceGeometry { // try to first derotate it , transform by aspect and then rotate back. for (n = 1; n <= NSides; ++n) { - Xo = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(n).x; // world coordinates.... shifted by relative north angle... - Yo = state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(n).y; + Xo = surfTemp.Vertex(n).x; // world coordinates.... shifted by relative north angle... + Yo = surfTemp.Vertex(n).y; // next derotate the building XnoRot = Xo * state.dataSurfaceGeometry->CosBldgRelNorth + Yo * state.dataSurfaceGeometry->SinBldgRelNorth; YnoRot = Yo * state.dataSurfaceGeometry->CosBldgRelNorth - Xo * state.dataSurfaceGeometry->SinBldgRelNorth; @@ -14687,10 +14639,10 @@ namespace SurfaceGeometry { Xtrans = XnoRot * std::sqrt(NewAspectRatio / OldAspectRatio); Ytrans = YnoRot * std::sqrt(OldAspectRatio / NewAspectRatio); // rerotate - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(n).x = + surfTemp.Vertex(n).x = Xtrans * state.dataSurfaceGeometry->CosBldgRelNorth - Ytrans * state.dataSurfaceGeometry->SinBldgRelNorth; - state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Vertex(n).y = + surfTemp.Vertex(n).y = Xtrans * state.dataSurfaceGeometry->SinBldgRelNorth + Ytrans * state.dataSurfaceGeometry->CosBldgRelNorth; } } @@ -15171,10 +15123,10 @@ namespace SurfaceGeometry { DataHeatBalance::AirBoundaryMixingSpecs newAirBoundaryMixing; newAirBoundaryMixing.space1 = spaceNum1; newAirBoundaryMixing.space2 = spaceNum2; - newAirBoundaryMixing.scheduleIndex = state.dataConstruction->Construct(surf.Construction).AirBoundaryMixingSched; + newAirBoundaryMixing.sched = state.dataConstruction->Construct(surf.Construction).airBoundaryMixingSched; Real64 mixingVolume = state.dataConstruction->Construct(surf.Construction).AirBoundaryACH * min(state.dataHeatBal->space(spaceNum1).Volume, state.dataHeatBal->space(spaceNum2).Volume) / - Constant::SecInHour; + Constant::rSecsInHour; newAirBoundaryMixing.mixingVolumeFlowRate = mixingVolume; state.dataHeatBal->airBoundaryMixing.push_back(newAirBoundaryMixing); } @@ -15590,7 +15542,7 @@ namespace SurfaceGeometry { Real64 Diagonal1; // Length of diagonal of 4-sided figure from vertex 1 to vertex 3 (m) Real64 Diagonal2; // Length of diagonal of 4-sided figure from vertex 2 to vertex 4 (m) Real64 DotProd; // Dot product of two adjacent sides - to test for right angle - Real64 const cos89deg = std::cos(89.0 * Constant::DegToRadians); // tolerance for right angle + Real64 const cos89deg = std::cos(89.0 * Constant::DegToRad); // tolerance for right angle Vector Vect32; // normalized vector from vertex 3 to vertex 2 Vector Vect21; // normalized vector from vertex 2 to vertex 1 @@ -15666,10 +15618,10 @@ namespace SurfaceGeometry { SurfWorldAz = surf.Azimuth; SurfTilt = surf.Tilt; - BaseCosAzimuth = std::cos(SurfWorldAz * Constant::DegToRadians); - BaseSinAzimuth = std::sin(SurfWorldAz * Constant::DegToRadians); - BaseCosTilt = std::cos(SurfTilt * Constant::DegToRadians); - BaseSinTilt = std::sin(SurfTilt * Constant::DegToRadians); + BaseCosAzimuth = std::cos(SurfWorldAz * Constant::DegToRad); + BaseSinAzimuth = std::sin(SurfWorldAz * Constant::DegToRad); + BaseCosTilt = std::cos(SurfTilt * Constant::DegToRad); + BaseSinTilt = std::sin(SurfTilt * Constant::DegToRad); NumSurfSides = surf.Sides; // Calculate WidthMax and HeightMax diff --git a/src/EnergyPlus/SurfaceGeometry.hh b/src/EnergyPlus/SurfaceGeometry.hh index 1e26fbf4830..8d6e8b15835 100644 --- a/src/EnergyPlus/SurfaceGeometry.hh +++ b/src/EnergyPlus/SurfaceGeometry.hh @@ -292,7 +292,7 @@ namespace SurfaceGeometry { void GetWindowShadingControlData(EnergyPlusData &state, bool &ErrorsFound); // If errors found in input - void InitialAssociateWindowShadingControlFenestration(EnergyPlusData &state, bool &ErrorsFound, int &SurfNum); + void InitialAssociateWindowShadingControlFenestration(EnergyPlusData &state, bool &ErrorsFound, int SurfNum); void FinalAssociateWindowShadingControlFenestration(EnergyPlusData &state, bool &ErrorsFound); @@ -498,6 +498,10 @@ struct SurfaceGeometryData : BaseGlobalStruct Array1D B; int VertSize = 0; // size of X,Y,Z,A,B arrays + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/SurfaceGroundHeatExchanger.hh b/src/EnergyPlus/SurfaceGroundHeatExchanger.hh index ec9f8273977..60f834ac9b4 100644 --- a/src/EnergyPlus/SurfaceGroundHeatExchanger.hh +++ b/src/EnergyPlus/SurfaceGroundHeatExchanger.hh @@ -313,6 +313,10 @@ struct SurfaceGroundHeatExchangersData : BaseGlobalStruct Real64 TempBtm; // bottom surface temp Real64 TempTop; // top surface temp + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/SwimmingPool.cc b/src/EnergyPlus/SwimmingPool.cc index ca74f2ae0a9..32969dde333 100644 --- a/src/EnergyPlus/SwimmingPool.cc +++ b/src/EnergyPlus/SwimmingPool.cc @@ -160,6 +160,8 @@ void GetSwimmingPool(EnergyPlusData &state) // SUBROUTINE PARAMETER DEFINITIONS: static constexpr std::string_view RoutineName("GetSwimmingPool: "); // include trailing blank space + static constexpr std::string_view routineName = "GetSwimmingPool"; + Real64 constexpr MinCoverFactor(0.0); // minimum value for cover factors Real64 constexpr MaxCoverFactor(1.0); // maximum value for cover factors Real64 constexpr MinDepth(0.05); // minimum average pool depth (to avoid obvious input errors) @@ -223,6 +225,9 @@ void GetSwimmingPool(EnergyPlusData &state) lAlphaBlanks, cAlphaFields, cNumericFields); + + ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)}; + Util::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound); state.dataSwimmingPools->Pool(Item).Name = Alphas(1); @@ -247,29 +252,27 @@ void GetSwimmingPool(EnergyPlusData &state) ErrorsFound = true; } - state.dataSwimmingPools->Pool(Item).ActivityFactorSchedName = Alphas(3); - state.dataSwimmingPools->Pool(Item).ActivityFactorSchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(3)); - if ((state.dataSwimmingPools->Pool(Item).ActivityFactorSchedPtr == 0) && (!lAlphaBlanks(3))) { - ShowSevereError(state, format("{} not found: {}", cAlphaFields(3), Alphas(3))); - ShowContinueError(state, format("Occurs in {} = {}", CurrentModuleObject, Alphas(1))); + if (lAlphaBlanks(3)) { + } else if ((state.dataSwimmingPools->Pool(Item).activityFactorSched = Sched::GetSchedule(state, Alphas(3))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(3), Alphas(3)); ErrorsFound = true; } - state.dataSwimmingPools->Pool(Item).MakeupWaterSupplySchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(4)); - if ((state.dataSwimmingPools->Pool(Item).MakeupWaterSupplySchedPtr == 0) && (!lAlphaBlanks(4))) { - ShowSevereError(state, format("{} not found: {}", cAlphaFields(4), Alphas(4))); - ShowContinueError(state, format("Occurs in {} = {}", CurrentModuleObject, Alphas(1))); + if (lAlphaBlanks(4)) { + } else if ((state.dataSwimmingPools->Pool(Item).makeupWaterSupplySched = Sched::GetSchedule(state, Alphas(4))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(4), Alphas(4)); ErrorsFound = true; } - state.dataSwimmingPools->Pool(Item).CoverSchedName = Alphas(5); - state.dataSwimmingPools->Pool(Item).CoverSchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(5)); - if ((state.dataSwimmingPools->Pool(Item).CoverSchedPtr == 0) && (!lAlphaBlanks(5))) { - ShowSevereError(state, format("{} not found: {}", cAlphaFields(5), Alphas(5))); - ShowContinueError(state, format("Occurs in {} = {}", CurrentModuleObject, Alphas(1))); + if (lAlphaBlanks(5)) { + } else if ((state.dataSwimmingPools->Pool(Item).coverSched = Sched::GetSchedule(state, Alphas(5))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(5), Alphas(5)); + ErrorsFound = true; + } else if (!state.dataSwimmingPools->Pool(Item).coverSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) { + Sched::ShowSevereBadMinMax(state, eoh, cAlphaFields(5), Alphas(5), Clusive::In, 0.0, Clusive::In, 1.0); ErrorsFound = true; } - + state.dataSwimmingPools->Pool(Item).CoverEvapFactor = Numbers(2); if (state.dataSwimmingPools->Pool(Item).CoverEvapFactor < MinCoverFactor) { ShowWarningError(state, format("{}{}=\"{} has an evaporation cover factor less than zero.", RoutineName, CurrentModuleObject, Alphas(1))); @@ -356,19 +359,14 @@ void GetSwimmingPool(EnergyPlusData &state) state.dataSwimmingPools->Pool(Item).MiscPowerFactor = MinPowerFactor; } - state.dataSwimmingPools->Pool(Item).SetPtTempSchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(8)); - if ((state.dataSwimmingPools->Pool(Item).SetPtTempSchedPtr == 0) && (!lAlphaBlanks(8))) { - ShowSevereError(state, format("{} not found: {}", cAlphaFields(8), Alphas(8))); - ShowContinueError(state, format("Occurs in {} = {}", CurrentModuleObject, Alphas(1))); - ErrorsFound = true; - } if (lAlphaBlanks(8)) { - ShowSevereError(state, - format("{} left blank. This is NOT allowed as there must be a pool water setpoint temperature.", cAlphaFields(8))); - ShowContinueError(state, format("Occurs in {} = {}", CurrentModuleObject, Alphas(1))); + ShowSevereEmptyField(state, eoh, cAlphaFields(8)); + ErrorsFound = true; + } else if ((state.dataSwimmingPools->Pool(Item).setPtTempSched = Sched::GetSchedule(state, Alphas(8))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(8), Alphas(8)); ErrorsFound = true; } - + state.dataSwimmingPools->Pool(Item).MaxNumOfPeople = Numbers(8); if (state.dataSwimmingPools->Pool(Item).MaxNumOfPeople < 0.0) { ShowWarningError( @@ -377,19 +375,15 @@ void GetSwimmingPool(EnergyPlusData &state) state.dataSwimmingPools->Pool(Item).MaxNumOfPeople = 0.0; } - state.dataSwimmingPools->Pool(Item).PeopleSchedName = Alphas(9); - state.dataSwimmingPools->Pool(Item).PeopleSchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(9)); - if ((state.dataSwimmingPools->Pool(Item).PeopleSchedPtr == 0) && (!lAlphaBlanks(9))) { - ShowSevereError(state, format("{} not found: {}", cAlphaFields(9), Alphas(9))); - ShowContinueError(state, format("Occurs in {} = {}", CurrentModuleObject, Alphas(1))); + if (lAlphaBlanks(9)) { + } else if ((state.dataSwimmingPools->Pool(Item).peopleSched = Sched::GetSchedule(state, Alphas(9))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(9), Alphas(9)); ErrorsFound = true; } - state.dataSwimmingPools->Pool(Item).PeopleHeatGainSchedName = Alphas(10); - state.dataSwimmingPools->Pool(Item).PeopleHeatGainSchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(10)); - if ((state.dataSwimmingPools->Pool(Item).PeopleHeatGainSchedPtr == 0) && (!lAlphaBlanks(10))) { - ShowSevereError(state, format("{} not found: {}", cAlphaFields(10), Alphas(10))); - ShowContinueError(state, format("Occurs in {} = {}", CurrentModuleObject, Alphas(1))); + if (lAlphaBlanks(10)) { + } else if ((state.dataSwimmingPools->Pool(Item).peopleHeatGainSched = Sched::GetSchedule(state, Alphas(10))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(10), Alphas(10)); ErrorsFound = true; } } @@ -477,8 +471,8 @@ void SwimmingPoolData::initialize(EnergyPlusData &state, bool const FirstHVACIte Real64 constexpr MaxActivityFactor = 10.0; // Maximum value for activity factor (realistically) // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - Real64 HeatGainPerPerson = ScheduleManager::GetCurrentScheduleValue(state, this->PeopleHeatGainSchedPtr); - Real64 PeopleModifier = ScheduleManager::GetCurrentScheduleValue(state, this->PeopleSchedPtr); + Real64 HeatGainPerPerson = this->peopleHeatGainSched->getCurrentVal(); + Real64 PeopleModifier = this->peopleSched->getCurrentVal(); if (this->MyOneTimeFlag) { this->setupOutputVars(state); // Set up the output variables once here @@ -535,15 +529,15 @@ void SwimmingPoolData::initialize(EnergyPlusData &state, bool const FirstHVACIte this->WaterInletTemp = state.dataLoopNodes->Node(this->WaterInletNode).Temp; // get the schedule values for different scheduled parameters - if (this->ActivityFactorSchedPtr > 0) { - this->CurActivityFactor = ScheduleManager::GetCurrentScheduleValue(state, this->ActivityFactorSchedPtr); + if (this->activityFactorSched != nullptr) { + this->CurActivityFactor = this->activityFactorSched->getCurrentVal(); if (this->CurActivityFactor < MinActivityFactor) { this->CurActivityFactor = MinActivityFactor; ShowWarningError(state, format("{}: Swimming Pool =\"{} Activity Factor Schedule =\"{} has a negative value. This is not allowed.", RoutineName, this->Name, - this->ActivityFactorSchedName)); + this->activityFactorSched->Name)); ShowContinueError(state, "The activity factor has been reset to zero."); } if (this->CurActivityFactor > MaxActivityFactor) { @@ -552,7 +546,7 @@ void SwimmingPoolData::initialize(EnergyPlusData &state, bool const FirstHVACIte format("{}: Swimming Pool =\"{} Activity Factor Schedule =\"{} has a value larger than 10. This is not allowed.", RoutineName, this->Name, - this->ActivityFactorSchedName)); + this->activityFactorSched->Name)); ShowContinueError(state, "The activity factor has been reset to unity."); } } else { @@ -560,33 +554,33 @@ void SwimmingPoolData::initialize(EnergyPlusData &state, bool const FirstHVACIte this->CurActivityFactor = 1.0; } - this->CurSetPtTemp = ScheduleManager::GetCurrentScheduleValue(state, this->SetPtTempSchedPtr); + this->CurSetPtTemp = this->setPtTempSched->getCurrentVal(); - if (this->MakeupWaterSupplySchedPtr > 0) { - this->CurMakeupWaterTemp = ScheduleManager::GetCurrentScheduleValue(state, this->MakeupWaterSupplySchedPtr); + if (this->makeupWaterSupplySched != nullptr) { + this->CurMakeupWaterTemp = this->makeupWaterSupplySched->getCurrentVal(); } else { // use water main temperaure if no schedule present in input this->CurMakeupWaterTemp = state.dataEnvrn->WaterMainsTemp; } // determine the current heat gain from people - if (this->PeopleHeatGainSchedPtr > 0) { + if (this->peopleHeatGainSched != nullptr) { if (HeatGainPerPerson < 0.0) { ShowWarningError(state, format("{}: Swimming Pool =\"{} Heat Gain Schedule =\"{} has a negative value. This is not allowed.", RoutineName, this->Name, - this->PeopleHeatGainSchedName)); + this->peopleHeatGainSched->Name)); ShowContinueError(state, "The heat gain per person has been reset to zero."); HeatGainPerPerson = 0.0; } - if (this->PeopleSchedPtr > 0) { + if (this->peopleSched != nullptr) { if (PeopleModifier < 0.0) { ShowWarningError(state, format("{}: Swimming Pool =\"{} People Schedule =\"{} has a negative value. This is not allowed.", RoutineName, this->Name, - this->PeopleSchedName)); + this->peopleSched->Name)); ShowContinueError(state, "The number of people has been reset to zero."); PeopleModifier = 0.0; } @@ -600,14 +594,15 @@ void SwimmingPoolData::initialize(EnergyPlusData &state, bool const FirstHVACIte this->PeopleHeatGain = PeopleModifier * HeatGainPerPerson * this->MaxNumOfPeople; // once cover schedule value is established, define the current values of the cover heat transfer factors - if (this->CoverSchedPtr > 0) { - this->CurCoverSchedVal = ScheduleManager::GetCurrentScheduleValue(state, this->CoverSchedPtr); + if (this->coverSched != nullptr) { + this->CurCoverSchedVal = this->coverSched->getCurrentVal(); + // Why is this checking done here as opposed to where the schedule is first retrieved? if (this->CurCoverSchedVal > 1.0) { ShowWarningError(state, format("{}: Swimming Pool =\"{} Cover Schedule =\"{} has a value greater than 1.0 (100%). This is not allowed.", RoutineName, this->Name, - this->CoverSchedName)); + this->coverSched->Name)); ShowContinueError(state, "The cover has been reset to one or fully covered."); this->CurCoverSchedVal = 1.0; } else if (this->CurCoverSchedVal < 0.0) { @@ -615,7 +610,7 @@ void SwimmingPoolData::initialize(EnergyPlusData &state, bool const FirstHVACIte format("{}: Swimming Pool =\"{} Cover Schedule =\"{} has a negative value. This is not allowed.", RoutineName, this->Name, - this->CoverSchedName)); + this->coverSched->Name)); ShowContinueError(state, "The cover has been reset to zero or uncovered."); this->CurCoverSchedVal = 0.0; } diff --git a/src/EnergyPlus/SwimmingPool.hh b/src/EnergyPlus/SwimmingPool.hh index 2934261d176..579a10a61e7 100644 --- a/src/EnergyPlus/SwimmingPool.hh +++ b/src/EnergyPlus/SwimmingPool.hh @@ -81,13 +81,11 @@ namespace SwimmingPool { Real64 WaterMassFlowRateMax; // maximum water mass flow rate for pool, kg/s Real64 AvgDepth; // average depth of the pool, m Real64 ActivityFactor; // Activity factor for the pool - std::string ActivityFactorSchedName; // Activity factor schedule name - int ActivityFactorSchedPtr; // Activity factor schedule pointer + Sched::Schedule *activityFactorSched = nullptr; // Activity factor schedule Real64 CurActivityFactor; // Current activity factor value - int MakeupWaterSupplySchedPtr; // Index to schedule for make-up water + Sched::Schedule *makeupWaterSupplySched = nullptr; // schedule for make-up water Real64 CurMakeupWaterTemp; // Current makeup water temperature - std::string CoverSchedName; // Pool cover schedule name - int CoverSchedPtr; // Index to pool cover schedule + Sched::Schedule *coverSched = nullptr; // pool cover schedule Real64 CurCoverSchedVal; // Current cover schedule value based on schedule Real64 CoverEvapFactor; // Pool cover evaporation factor Real64 CoverConvFactor; // Pool cover convective factor @@ -99,13 +97,11 @@ namespace SwimmingPool { Real64 CurCoverLWRadFac; // Current pool cover long-wavelength radiation factor Real64 RadConvertToConvect; // LW and SW radiation converted to convective gain by pool cover in W/m2 Real64 MiscPowerFactor; // Pool miscellaneous power equipment consumption coefficient in W/(kg/s) - int SetPtTempSchedPtr; // Schedule pointer for water setpoint temperature + Sched::Schedule *setPtTempSched = nullptr; // Schedule for water setpoint temperature Real64 CurSetPtTemp; // Current water setpoint temperature Real64 MaxNumOfPeople; // Number of people in the pool as defined by user input - std::string PeopleSchedName; // Name of people schedule - int PeopleSchedPtr; // People schedule index - std::string PeopleHeatGainSchedName; // Name of people heat gain schedule - int PeopleHeatGainSchedPtr; // People heat gain schedule index + Sched::Schedule *peopleSched = nullptr; // People schedule + Sched::Schedule *peopleHeatGainSched = nullptr; // People heat gain schedule Real64 PeopleHeatGain; // Current heat gain from people int GlycolIndex; // index in fluid property routines for water Real64 WaterMass; // pool water mass @@ -142,11 +138,11 @@ namespace SwimmingPool { // Default Constructor SwimmingPoolData() : SurfacePtr(0), ZonePtr(0), WaterInletNode(0), WaterOutletNode(0), HWplantLoc{}, WaterVolFlowMax(0.0), WaterMassFlowRateMax(0.0), - AvgDepth(0.0), ActivityFactor(0.0), ActivityFactorSchedPtr(0), CurActivityFactor(0.0), MakeupWaterSupplySchedPtr(0), - CurMakeupWaterTemp(0.0), CoverSchedPtr(0), CurCoverSchedVal(0.0), CoverEvapFactor(0.0), CoverConvFactor(0.0), CoverSWRadFactor(0.0), + AvgDepth(0.0), ActivityFactor(0.0), CurActivityFactor(0.0), + CurMakeupWaterTemp(0.0), CurCoverSchedVal(0.0), CoverEvapFactor(0.0), CoverConvFactor(0.0), CoverSWRadFactor(0.0), CoverLWRadFactor(0.0), CurCoverEvapFac(0.0), CurCoverConvFac(0.0), CurCoverSWRadFac(0.0), CurCoverLWRadFac(0.0), - RadConvertToConvect(0.0), MiscPowerFactor(0.0), SetPtTempSchedPtr(0), CurSetPtTemp(23.0), MaxNumOfPeople(0.0), PeopleSchedPtr(0), - PeopleHeatGainSchedPtr(0), PeopleHeatGain(0.0), GlycolIndex(0), WaterMass(0.0), SatPressPoolWaterTemp(0.0), PartPressZoneAirTemp(0.0), + RadConvertToConvect(0.0), MiscPowerFactor(0.0), CurSetPtTemp(23.0), MaxNumOfPeople(0.0), + PeopleHeatGain(0.0), GlycolIndex(0), WaterMass(0.0), SatPressPoolWaterTemp(0.0), PartPressZoneAirTemp(0.0), PoolWaterTemp(23.0), WaterInletTemp(0.0), WaterOutletTemp(0.0), WaterMassFlowRate(0.0), MakeUpWaterMassFlowRate(0.0), MakeUpWaterMass(0.0), MakeUpWaterVolFlowRate(0.0), MakeUpWaterVol(0.0), HeatPower(0.0), HeatEnergy(0.0), MiscEquipPower(0.0), MiscEquipEnergy(0.0), RadConvertToConvectRep(0.0), EvapHeatLossRate(0.0), EvapEnergyLoss(0.0), MyOneTimeFlag(true), @@ -218,6 +214,10 @@ struct SwimmingPoolsData : BaseGlobalStruct bool getSwimmingPoolInput = true; Array1D Pool; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/SystemAvailabilityManager.cc b/src/EnergyPlus/SystemAvailabilityManager.cc index 52f0d52936b..17738e9fe8b 100644 --- a/src/EnergyPlus/SystemAvailabilityManager.cc +++ b/src/EnergyPlus/SystemAvailabilityManager.cc @@ -107,8 +107,6 @@ namespace Avail { // USE STATEMENTS: // Use statements for data only modules - using namespace ScheduleManager; - static constexpr std::array managerTypeNamesUC = {"AVAILABILITYMANAGER:SCHEDULED", "AVAILABILITYMANAGER:SCHEDULEDON", "AVAILABILITYMANAGER:SCHEDULEDOFF", @@ -425,8 +423,9 @@ namespace Avail { schedMgr.Name = cAlphaArgs(1); schedMgr.type = ManagerType::Scheduled; - schedMgr.SchedPtr = GetScheduleIndex(state, cAlphaArgs(2)); - if (schedMgr.SchedPtr == 0) { + if (lAlphaFieldBlanks(2)) { + ShowSevereEmptyField(state, eoh, cAlphaFieldNames(2)); + } else if ((schedMgr.availSched = Sched::GetSchedule(state, cAlphaArgs(2))) == nullptr) { ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(2), cAlphaArgs(2)); ErrorsFound = true; } @@ -469,8 +468,10 @@ namespace Avail { schedOnMgr.Name = cAlphaArgs(1); schedOnMgr.type = ManagerType::ScheduledOn; - schedOnMgr.SchedPtr = GetScheduleIndex(state, cAlphaArgs(2)); - if (schedOnMgr.SchedPtr == 0) { + if (lAlphaFieldBlanks(2)) { + ShowSevereEmptyField(state, eoh, cAlphaFieldNames(2)); + ErrorsFound = true; + } else if ((schedOnMgr.availSched = Sched::GetSchedule(state, cAlphaArgs(2))) == nullptr) { ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(2), cAlphaArgs(2)); ErrorsFound = true; } @@ -513,8 +514,10 @@ namespace Avail { schedOffMgr.Name = cAlphaArgs(1); schedOffMgr.type = ManagerType::ScheduledOff; - schedOffMgr.SchedPtr = GetScheduleIndex(state, cAlphaArgs(2)); - if (schedOffMgr.SchedPtr == 0) { + if (lAlphaFieldBlanks(2)) { + ShowSevereEmptyField(state, eoh, cAlphaFieldNames(2)); + ErrorsFound = true; + } else if ((schedOffMgr.availSched = Sched::GetSchedule(state, cAlphaArgs(2))) == nullptr) { ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(2), cAlphaArgs(2)); ErrorsFound = true; } @@ -558,17 +561,23 @@ namespace Avail { nightCycleMgr.Name = cAlphaArgs(1); nightCycleMgr.type = ManagerType::NightCycle; nightCycleMgr.TempTolRange = rNumericArgs(1); - CyclingTimeSteps = nint((rNumericArgs(2) / Constant::SecInHour) * double(state.dataGlobal->NumOfTimeStepInHour)); + CyclingTimeSteps = nint((rNumericArgs(2) / Constant::rSecsInHour) * double(state.dataGlobal->TimeStepsInHour)); CyclingTimeSteps = max(1, CyclingTimeSteps); nightCycleMgr.CyclingTimeSteps = CyclingTimeSteps; - nightCycleMgr.SchedPtr = GetScheduleIndex(state, cAlphaArgs(2)); - if (nightCycleMgr.SchedPtr == 0) { + + + if (lAlphaFieldBlanks(2)) { + ShowSevereEmptyField(state, eoh, cAlphaFieldNames(2)); + ErrorsFound = true; + } else if ((nightCycleMgr.availSched = Sched::GetSchedule(state, cAlphaArgs(2))) == nullptr) { ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(2), cAlphaArgs(2)); ErrorsFound = true; } - nightCycleMgr.FanSched = cAlphaArgs(3); - nightCycleMgr.FanSchedPtr = GetScheduleIndex(state, cAlphaArgs(3)); - if (nightCycleMgr.FanSchedPtr == 0) { + + if (lAlphaFieldBlanks(3)) { + ShowSevereEmptyField(state, eoh, cAlphaFieldNames(3)); + ErrorsFound = true; + } else if ((nightCycleMgr.fanSched = Sched::GetSchedule(state, cAlphaArgs(3))) == nullptr) { ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(3), cAlphaArgs(3)); ErrorsFound = true; } @@ -719,14 +728,19 @@ namespace Avail { auto &optimumStartMgr = state.dataAvail->OptimumStartData(SysAvailNum); optimumStartMgr.Name = cAlphaArgs(1); optimumStartMgr.type = ManagerType::OptimumStart; - optimumStartMgr.SchedPtr = GetScheduleIndex(state, cAlphaArgs(2)); - if (optimumStartMgr.SchedPtr == 0) { + + if (lAlphaFieldBlanks(2)) { + ShowSevereEmptyField(state, eoh, cAlphaFieldNames(2)); + ErrorsFound = true; + } else if ((optimumStartMgr.availSched = Sched::GetSchedule(state, cAlphaArgs(2))) == nullptr) { ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(2), cAlphaArgs(2)); ErrorsFound = true; } - optimumStartMgr.FanSched = cAlphaArgs(3); - optimumStartMgr.FanSchedPtr = GetScheduleIndex(state, cAlphaArgs(3)); - if (optimumStartMgr.FanSchedPtr == 0) { + + if (lAlphaFieldBlanks(3)) { + ShowSevereEmptyField(state, eoh, cAlphaFieldNames(3)); + ErrorsFound = true; + } else if ((optimumStartMgr.fanSched = Sched::GetSchedule(state, cAlphaArgs(3))) == nullptr) { ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(3), cAlphaArgs(3)); ErrorsFound = true; } @@ -1049,14 +1063,10 @@ namespace Avail { loTurnOffMgr.Temp = rNumericArgs(1); - if (!lAlphaFieldBlanks(3)) { - loTurnOffMgr.SchedPtr = GetScheduleIndex(state, cAlphaArgs(3)); - if (loTurnOffMgr.SchedPtr == 0) { - ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(3), cAlphaArgs(3)); - ErrorsFound = true; - } - } else { - loTurnOffMgr.SchedPtr = 0; + if (lAlphaFieldBlanks(3)) { + } else if ((loTurnOffMgr.availSched = Sched::GetSchedule(state, cAlphaArgs(3))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(3), cAlphaArgs(3)); + ErrorsFound = true; } SetupOutputVariable(state, @@ -1151,23 +1161,30 @@ namespace Avail { nightVentMgr.Name = cAlphaArgs(1); nightVentMgr.type = ManagerType::NightVent; - nightVentMgr.SchedPtr = GetScheduleIndex(state, cAlphaArgs(2)); - if (nightVentMgr.SchedPtr == 0) { + if (lAlphaFieldBlanks(2)) { + ShowSevereEmptyField(state, eoh, cAlphaFieldNames(2)); + ErrorsFound = true; + } else if ((nightVentMgr.availSched = Sched::GetSchedule(state, cAlphaArgs(2))) == nullptr) { ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(2), cAlphaArgs(2)); ErrorsFound = true; } - nightVentMgr.FanSched = cAlphaArgs(3); - nightVentMgr.FanSchedPtr = GetScheduleIndex(state, cAlphaArgs(3)); - if (nightVentMgr.FanSchedPtr == 0) { + + if (lAlphaFieldBlanks(3)) { + ShowSevereEmptyField(state, eoh, cAlphaFieldNames(3)); + ErrorsFound = true; + } else if ((nightVentMgr.fanSched = Sched::GetSchedule(state, cAlphaArgs(3))) == nullptr) { ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(3), cAlphaArgs(3)); ErrorsFound = true; } - nightVentMgr.VentTempSched = cAlphaArgs(4); - nightVentMgr.VentTempSchedPtr = GetScheduleIndex(state, cAlphaArgs(4)); - if (nightVentMgr.VentTempSchedPtr == 0) { + + if (lAlphaFieldBlanks(4)) { + ShowSevereEmptyField(state, eoh, cAlphaFieldNames(4)); + ErrorsFound = true; + } else if ((nightVentMgr.ventTempSched = Sched::GetSchedule(state, cAlphaArgs(4))) == nullptr) { ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(4), cAlphaArgs(4)); ErrorsFound = true; } + nightVentMgr.VentDelT = rNumericArgs(1); nightVentMgr.VentTempLowLim = rNumericArgs(2); nightVentMgr.VentFlowFrac = rNumericArgs(3); @@ -1747,7 +1764,7 @@ namespace Avail { // AvailStatus indicator accordingly. Mostly a useless algorithm // since the fan schedules can do the same thing. auto &availMgr = state.dataAvail->SchedData(SysAvailNum); - availMgr.availStatus = (GetCurrentScheduleValue(state, availMgr.SchedPtr) > 0.0) ? Status::CycleOn : Status::ForceOff; + availMgr.availStatus = (availMgr.availSched->getCurrentVal() > 0.0) ? Status::CycleOn : Status::ForceOff; return availMgr.availStatus; } @@ -1770,7 +1787,7 @@ namespace Avail { // AvailStatus indicator accordingly. If the schedule value is > 0 // the availability status is Status::CycleOn, ELSE the status is Status::NoAction. auto &availMgr = state.dataAvail->SchedOnData(SysAvailNum); - availMgr.availStatus = (GetCurrentScheduleValue(state, availMgr.SchedPtr) > 0.0) ? Status::CycleOn : Status::NoAction; + availMgr.availStatus = (availMgr.availSched->getCurrentVal() > 0.0) ? Status::CycleOn : Status::NoAction; return availMgr.availStatus; } @@ -1793,7 +1810,7 @@ namespace Avail { // AvailStatus indicator accordingly. If the schedule value is = 0 // the availability status is Status::ForceOff, ELSE the status is Status::NoAction. auto &availMgr = state.dataAvail->SchedOffData(SysAvailNum); - availMgr.availStatus = (GetCurrentScheduleValue(state, availMgr.SchedPtr) == 0.0) ? Status::ForceOff : Status::NoAction; + availMgr.availStatus = (availMgr.availSched->getCurrentVal() == 0.0) ? Status::ForceOff : Status::NoAction; return availMgr.availStatus; } @@ -1856,7 +1873,7 @@ namespace Avail { // CR 7913 changed to allow during warmup auto &nightCycleMgr = state.dataAvail->NightCycleData(SysAvailNum); - if ((GetCurrentScheduleValue(state, nightCycleMgr.SchedPtr) <= 0.0) || (GetCurrentScheduleValue(state, nightCycleMgr.FanSchedPtr) > 0.0)) { + if ((nightCycleMgr.availSched->getCurrentVal() <= 0.0) || (nightCycleMgr.fanSched->getCurrentVal() > 0.0)) { return nightCycleMgr.availStatus = Status::NoAction; // CR 8358 } @@ -1883,38 +1900,38 @@ namespace Avail { int ZoneNum = nightCycleMgr.CtrlZonePtrs(1); + auto const &zoneTstatSetpt = state.dataHeatBalFanSys->zoneTstatSetpts(ZoneNum); + switch (state.dataHeatBalFanSys->TempControlType(ZoneNum)) { // select on thermostat control - case HVAC::ThermostatType::SingleHeating: { - if (state.dataHeatBalFanSys->TempTstatAir(ZoneNum) < state.dataHeatBalFanSys->TempZoneThermostatSetPoint(ZoneNum) - TempTol) { + case HVAC::SetptType::SingleHeat: { + if (state.dataHeatBalFanSys->TempTstatAir(ZoneNum) < zoneTstatSetpt.setpt - TempTol) { availStatus = Status::CycleOn; } else { availStatus = Status::NoAction; } } break; - case HVAC::ThermostatType::SingleCooling: { - if (state.dataHeatBalFanSys->TempTstatAir(ZoneNum) > state.dataHeatBalFanSys->TempZoneThermostatSetPoint(ZoneNum) + TempTol) { + case HVAC::SetptType::SingleCool: { + if (state.dataHeatBalFanSys->TempTstatAir(ZoneNum) > zoneTstatSetpt.setpt + TempTol) { availStatus = Status::CycleOn; } else { availStatus = Status::NoAction; } } break; - case HVAC::ThermostatType::SingleHeatCool: { - if ((state.dataHeatBalFanSys->TempTstatAir(ZoneNum) < - state.dataHeatBalFanSys->TempZoneThermostatSetPoint(ZoneNum) - TempTol) || - (state.dataHeatBalFanSys->TempTstatAir(ZoneNum) > - state.dataHeatBalFanSys->TempZoneThermostatSetPoint(ZoneNum) + TempTol)) { + case HVAC::SetptType::SingleHeatCool: { + if ((state.dataHeatBalFanSys->TempTstatAir(ZoneNum) < zoneTstatSetpt.setpt - TempTol) || + (state.dataHeatBalFanSys->TempTstatAir(ZoneNum) > zoneTstatSetpt.setpt + TempTol)) { availStatus = Status::CycleOn; } else { availStatus = Status::NoAction; } } break; - case HVAC::ThermostatType::DualSetPointWithDeadBand: { - if ((state.dataHeatBalFanSys->TempTstatAir(ZoneNum) < state.dataHeatBalFanSys->ZoneThermostatSetPointLo(ZoneNum) - TempTol) || - (state.dataHeatBalFanSys->TempTstatAir(ZoneNum) > state.dataHeatBalFanSys->ZoneThermostatSetPointHi(ZoneNum) + TempTol)) { + case HVAC::SetptType::DualHeatCool: { + if ((state.dataHeatBalFanSys->TempTstatAir(ZoneNum) < zoneTstatSetpt.setptLo - TempTol) || + (state.dataHeatBalFanSys->TempTstatAir(ZoneNum) > zoneTstatSetpt.setptHi + TempTol)) { availStatus = Status::CycleOn; } else { availStatus = Status::NoAction; @@ -1980,39 +1997,34 @@ namespace Avail { ++ZoneInSysNum) { // loop over zones in system int ZoneNum = state.dataAirLoop->AirToZoneNodeInfo(PriAirSysNum).CoolCtrlZoneNums(ZoneInSysNum); + auto const &zoneTstatSetpt = state.dataHeatBalFanSys->zoneTstatSetpts(ZoneNum); switch (state.dataHeatBalFanSys->TempControlType(ZoneNum)) { - case HVAC::ThermostatType::SingleHeating: { - if (state.dataHeatBalFanSys->TempTstatAir(ZoneNum) < - state.dataHeatBalFanSys->TempZoneThermostatSetPoint(ZoneNum) - TempTol) { + case HVAC::SetptType::SingleHeat: { + if (state.dataHeatBalFanSys->TempTstatAir(ZoneNum) < zoneTstatSetpt.setpt - TempTol) { availStatus = Status::CycleOn; } else { availStatus = Status::NoAction; } } break; - case HVAC::ThermostatType::SingleCooling: { - if (state.dataHeatBalFanSys->TempTstatAir(ZoneNum) > - state.dataHeatBalFanSys->TempZoneThermostatSetPoint(ZoneNum) + TempTol) { + case HVAC::SetptType::SingleCool: { + if (state.dataHeatBalFanSys->TempTstatAir(ZoneNum) > zoneTstatSetpt.setpt + TempTol) { availStatus = Status::CycleOn; } else { availStatus = Status::NoAction; } } break; - case HVAC::ThermostatType::SingleHeatCool: { - if ((state.dataHeatBalFanSys->TempTstatAir(ZoneNum) < - state.dataHeatBalFanSys->TempZoneThermostatSetPoint(ZoneNum) - TempTol) || - (state.dataHeatBalFanSys->TempTstatAir(ZoneNum) > - state.dataHeatBalFanSys->TempZoneThermostatSetPoint(ZoneNum) + TempTol)) { + case HVAC::SetptType::SingleHeatCool: { + if ((state.dataHeatBalFanSys->TempTstatAir(ZoneNum) < zoneTstatSetpt.setpt - TempTol) || + (state.dataHeatBalFanSys->TempTstatAir(ZoneNum) > zoneTstatSetpt.setpt + TempTol)) { availStatus = Status::CycleOn; } else { availStatus = Status::NoAction; } } break; - case HVAC::ThermostatType::DualSetPointWithDeadBand: { - if ((state.dataHeatBalFanSys->TempTstatAir(ZoneNum) < - state.dataHeatBalFanSys->ZoneThermostatSetPointLo(ZoneNum) - TempTol) || - (state.dataHeatBalFanSys->TempTstatAir(ZoneNum) > - state.dataHeatBalFanSys->ZoneThermostatSetPointHi(ZoneNum) + TempTol)) { + case HVAC::SetptType::DualHeatCool: { + if ((state.dataHeatBalFanSys->TempTstatAir(ZoneNum) < zoneTstatSetpt.setptLo - TempTol) || + (state.dataHeatBalFanSys->TempTstatAir(ZoneNum) > zoneTstatSetpt.setptHi + TempTol)) { availStatus = Status::CycleOn; } else { availStatus = Status::NoAction; @@ -2100,19 +2112,21 @@ namespace Avail { Real64 const TempTolerance // temperature tolerance ) { + // Check if any zone temperature is above the cooling setpoint plus tolerance for (int Index = 1; Index <= NumZones; ++Index) { // loop over zones in list int ZoneNum = ZonePtrList(Index); - + auto const &zoneTstatSetpt = state.dataHeatBalFanSys->zoneTstatSetpts(ZoneNum); + switch (state.dataHeatBalFanSys->TempControlType(ZoneNum)) { - case HVAC::ThermostatType::SingleCooling: - case HVAC::ThermostatType::SingleHeatCool: - if (state.dataHeatBalFanSys->TempTstatAir(ZoneNum) > state.dataHeatBalFanSys->TempZoneThermostatSetPoint(ZoneNum) + TempTolerance) { + case HVAC::SetptType::SingleCool: + case HVAC::SetptType::SingleHeatCool: + if (state.dataHeatBalFanSys->TempTstatAir(ZoneNum) > zoneTstatSetpt.setpt + TempTolerance) { return true; // return on the first zone found } break; - case HVAC::ThermostatType::DualSetPointWithDeadBand: - if (state.dataHeatBalFanSys->TempTstatAir(ZoneNum) > state.dataHeatBalFanSys->ZoneThermostatSetPointHi(ZoneNum) + TempTolerance) { + case HVAC::SetptType::DualHeatCool: + if (state.dataHeatBalFanSys->TempTstatAir(ZoneNum) > zoneTstatSetpt.setptHi + TempTolerance) { return true; // return on the first zone found } break; @@ -2132,16 +2146,17 @@ namespace Avail { // Check if any zone temperature is below the heating setpoint less tolerance for (int Index = 1; Index <= NumZones; ++Index) { // loop over zones in list int ZoneNum = ZonePtrList(Index); - { - HVAC::ThermostatType const tstatType(state.dataHeatBalFanSys->TempControlType(ZoneNum)); + { // Why is this a new scope? + auto const &zoneTstatSetpt = state.dataHeatBalFanSys->zoneTstatSetpts(ZoneNum); + + HVAC::SetptType const tstatType(state.dataHeatBalFanSys->TempControlType(ZoneNum)); - if ((tstatType == HVAC::ThermostatType::SingleHeating) || (tstatType == HVAC::ThermostatType::SingleHeatCool)) { - if (state.dataHeatBalFanSys->TempTstatAir(ZoneNum) < - state.dataHeatBalFanSys->TempZoneThermostatSetPoint(ZoneNum) - TempTolerance) { + if ((tstatType == HVAC::SetptType::SingleHeat) || (tstatType == HVAC::SetptType::SingleHeatCool)) { + if (state.dataHeatBalFanSys->TempTstatAir(ZoneNum) < zoneTstatSetpt.setpt - TempTolerance) { return true; // return on the first zone found } - } else if (tstatType == HVAC::ThermostatType::DualSetPointWithDeadBand) { - if (state.dataHeatBalFanSys->TempTstatAir(ZoneNum) < state.dataHeatBalFanSys->ZoneThermostatSetPointLo(ZoneNum) - TempTolerance) { + } else if (tstatType == HVAC::SetptType::DualHeatCool) { + if (state.dataHeatBalFanSys->TempTstatAir(ZoneNum) < zoneTstatSetpt.setptLo - TempTolerance) { return true; // return on the first zone found } } @@ -2176,7 +2191,6 @@ namespace Avail { // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - int ScheduleIndex; Array2D DayValues; Array2D DayValuesTmr; int JDay; @@ -2260,13 +2274,12 @@ namespace Avail { if (state.dataGlobal->KickOffSimulation) { availStatus = Status::NoAction; } else { - ScheduleIndex = GetScheduleIndex(state, OptStartMgr.FanSched); JDay = state.dataEnvrn->DayOfYear; TmrJDay = JDay + 1; TmrDayOfWeek = state.dataEnvrn->DayOfWeekTomorrow; - DayValues.allocate(state.dataGlobal->NumOfTimeStepInHour, 24); - DayValuesTmr.allocate(state.dataGlobal->NumOfTimeStepInHour, 24); + DayValues.allocate(state.dataGlobal->TimeStepsInHour, Constant::iHoursInDay); + DayValuesTmr.allocate(state.dataGlobal->TimeStepsInHour, Constant::iHoursInDay); if (!allocated(state.dataAvail->OptStart)) { state.dataAvail->OptStart.allocate(state.dataGlobal->NumOfZones); } @@ -2286,16 +2299,16 @@ namespace Avail { } if (!state.dataGlobal->BeginDayFlag) state.dataAvail->BeginOfDayResetFlag = true; - GetScheduleValuesForDay(state, ScheduleIndex, DayValues); - GetScheduleValuesForDay(state, ScheduleIndex, DayValuesTmr, TmrJDay, TmrDayOfWeek); + OptStartMgr.fanSched->getDayVals(state, DayValues); + OptStartMgr.fanSched->getDayVals(state, DayValuesTmr, TmrJDay, TmrDayOfWeek); FanStartTime = 0.0; FanStartTimeTmr = 0.0; exitLoop = false; for (int I = 1; I <= 24; ++I) { - for (int J = 1; J <= state.dataGlobal->NumOfTimeStepInHour; ++J) { + for (int J = 1; J <= state.dataGlobal->TimeStepsInHour; ++J) { if (DayValues(J, I) <= 0.0) continue; - FanStartTime = I - 1 + 1.0 / state.dataGlobal->NumOfTimeStepInHour * J - 0.01; + FanStartTime = I - 1 + 1.0 / state.dataGlobal->TimeStepsInHour * J - 0.01; exitLoop = true; break; } @@ -2304,9 +2317,9 @@ namespace Avail { exitLoop = false; for (int I = 1; I <= 24; ++I) { - for (int J = 1; J <= state.dataGlobal->NumOfTimeStepInHour; ++J) { + for (int J = 1; J <= state.dataGlobal->TimeStepsInHour; ++J) { if (DayValuesTmr(J, I) <= 0.0) continue; - FanStartTimeTmr = I - 1 + 1.0 / state.dataGlobal->NumOfTimeStepInHour * J - 0.01; + FanStartTimeTmr = I - 1 + 1.0 / state.dataGlobal->TimeStepsInHour * J - 0.01; exitLoop = true; break; } @@ -2389,8 +2402,7 @@ namespace Avail { case ControlAlgorithm::ConstantTemperatureGradient: { if (OptStartMgr.optimumStartControlType == OptimumStartControlType::ControlZone) { ZoneNum = OptStartMgr.ZoneNum; - if ((!allocated(state.dataHeatBalFanSys->TempTstatAir)) || (!allocated(state.dataHeatBalFanSys->ZoneThermostatSetPointLo)) || - (!allocated(state.dataHeatBalFanSys->ZoneThermostatSetPointHi))) { + if (!allocated(state.dataHeatBalFanSys->TempTstatAir) || !allocated(state.dataHeatBalFanSys->zoneTstatSetpts)) { TempDiff = 0.0; } else { if (!CycleOnFlag) { @@ -2537,8 +2549,7 @@ namespace Avail { } else if (OptStartMgr.optimumStartControlType == OptimumStartControlType::MaximumOfZoneList) { NumOfZonesInList = OptStartMgr.NumOfZones; - if ((!allocated(state.dataHeatBalFanSys->TempTstatAir)) || (!allocated(state.dataHeatBalFanSys->ZoneThermostatSetPointLo)) || - (!allocated(state.dataHeatBalFanSys->ZoneThermostatSetPointHi))) { + if (!allocated(state.dataHeatBalFanSys->TempTstatAir) || !allocated(state.dataHeatBalFanSys->zoneTstatSetpts)) { TempDiff = 0.0; } else { if (!CycleOnFlag) { @@ -2699,8 +2710,7 @@ namespace Avail { if (OptStartMgr.optimumStartControlType == OptimumStartControlType::ControlZone) { ZoneNum = OptStartMgr.ZoneNum; - if ((!allocated(state.dataHeatBalFanSys->TempTstatAir)) || (!allocated(state.dataHeatBalFanSys->ZoneThermostatSetPointLo)) || - (!allocated(state.dataHeatBalFanSys->ZoneThermostatSetPointHi))) { + if (!allocated(state.dataHeatBalFanSys->TempTstatAir) || !allocated(state.dataHeatBalFanSys->zoneTstatSetpts)) { TempDiff = 0.0; } else { if (!CycleOnFlag) { @@ -2787,7 +2797,7 @@ namespace Avail { (ATGUpdateTemp2 - ATGUpdateTemp1) / (ATGUpdateTime2 - ATGUpdateTime1); } else { state.dataAvail->OptStart_AdaTempGradTrdHeat(NumPreDays) = - (ATGUpdateTemp2 - ATGUpdateTemp1) * state.dataGlobal->NumOfTimeStepInHour; + (ATGUpdateTemp2 - ATGUpdateTemp1) * state.dataGlobal->TimeStepsInHour; } } } @@ -2835,7 +2845,7 @@ namespace Avail { (ATGUpdateTemp2 - ATGUpdateTemp1) / (ATGUpdateTime2 - ATGUpdateTime1 + 24.0); } else { state.dataAvail->OptStart_AdaTempGradTrdHeat(NumPreDays) = - (ATGUpdateTemp2 - ATGUpdateTemp1) * state.dataGlobal->NumOfTimeStepInHour; + (ATGUpdateTemp2 - ATGUpdateTemp1) * state.dataGlobal->TimeStepsInHour; } } } @@ -2903,7 +2913,7 @@ namespace Avail { (ATGUpdateTemp1 - ATGUpdateTemp2) / (ATGUpdateTime2 - ATGUpdateTime1); } else { state.dataAvail->OptStart_AdaTempGradTrdCool(NumPreDays) = - (ATGUpdateTemp1 - ATGUpdateTemp2) * state.dataGlobal->NumOfTimeStepInHour; + (ATGUpdateTemp1 - ATGUpdateTemp2) * state.dataGlobal->TimeStepsInHour; } } } @@ -2942,7 +2952,7 @@ namespace Avail { (ATGUpdateTemp1 - ATGUpdateTemp2) / (ATGUpdateTime2 - ATGUpdateTime1 + 24.0); } else { state.dataAvail->OptStart_AdaTempGradTrdCool(NumPreDays) = - (ATGUpdateTemp1 - ATGUpdateTemp2) * state.dataGlobal->NumOfTimeStepInHour; + (ATGUpdateTemp1 - ATGUpdateTemp2) * state.dataGlobal->TimeStepsInHour; } } } @@ -2972,8 +2982,7 @@ namespace Avail { NumOfZonesInList = OptStartMgr.NumOfZones; ATGWCZoneNumHi = OptStartMgr.ZonePtrs(1); ATGWCZoneNumLo = OptStartMgr.ZonePtrs(1); - if ((!allocated(state.dataHeatBalFanSys->TempTstatAir)) || (!allocated(state.dataHeatBalFanSys->ZoneThermostatSetPointLo)) || - (!allocated(state.dataHeatBalFanSys->ZoneThermostatSetPointHi))) { + if (!allocated(state.dataHeatBalFanSys->TempTstatAir) || !allocated(state.dataHeatBalFanSys->zoneTstatSetpts)) { TempDiff = 0.0; } else { if (!CycleOnFlag) { @@ -3077,7 +3086,7 @@ namespace Avail { (ATGUpdateTemp2 - ATGUpdateTemp1) / (ATGUpdateTime2 - ATGUpdateTime1); } else { state.dataAvail->OptStart_AdaTempGradTrdHeat(NumPreDays) = - (ATGUpdateTemp2 - ATGUpdateTemp1) * state.dataGlobal->NumOfTimeStepInHour; + (ATGUpdateTemp2 - ATGUpdateTemp1) * state.dataGlobal->TimeStepsInHour; } } } @@ -3123,7 +3132,7 @@ namespace Avail { (ATGUpdateTemp2 - ATGUpdateTemp1) / (ATGUpdateTime2 - ATGUpdateTime1 + 24.0); } else { state.dataAvail->OptStart_AdaTempGradTrdHeat(NumPreDays) = - (ATGUpdateTemp2 - ATGUpdateTemp1) * state.dataGlobal->NumOfTimeStepInHour; + (ATGUpdateTemp2 - ATGUpdateTemp1) * state.dataGlobal->TimeStepsInHour; } } } @@ -3192,7 +3201,7 @@ namespace Avail { (ATGUpdateTemp1 - ATGUpdateTemp2) / (ATGUpdateTime2 - ATGUpdateTime1); } else { state.dataAvail->OptStart_AdaTempGradTrdCool(NumPreDays) = - (ATGUpdateTemp1 - ATGUpdateTemp2) * state.dataGlobal->NumOfTimeStepInHour; + (ATGUpdateTemp1 - ATGUpdateTemp2) * state.dataGlobal->TimeStepsInHour; } } } @@ -3239,7 +3248,7 @@ namespace Avail { (ATGUpdateTemp1 - ATGUpdateTemp2) / (ATGUpdateTime2 - ATGUpdateTime1 + 24.0); } else { state.dataAvail->OptStart_AdaTempGradTrdCool(NumPreDays) = - (ATGUpdateTemp1 - ATGUpdateTemp2) * state.dataGlobal->NumOfTimeStepInHour; + (ATGUpdateTemp1 - ATGUpdateTemp2) * state.dataGlobal->TimeStepsInHour; } } } @@ -3355,11 +3364,11 @@ namespace Avail { // check if night venting allowed: not allowed if avail sched is off or fan sched is on // CR 7913 changed to allow during warmup auto &nightVentMgr = state.dataAvail->NightVentData(SysAvailNum); - if ((GetCurrentScheduleValue(state, nightVentMgr.SchedPtr) <= 0.0) || (GetCurrentScheduleValue(state, nightVentMgr.FanSchedPtr) > 0.0)) { + if ((nightVentMgr.availSched->getCurrentVal() <= 0.0) || (nightVentMgr.fanSched->getCurrentVal() > 0.0)) { availStatus = Status::NoAction; } else { - VentTemp = GetCurrentScheduleValue(state, nightVentMgr.VentTempSchedPtr); + VentTemp = nightVentMgr.ventTempSched->getCurrentVal(); int ControlZoneNum = nightVentMgr.ZoneNum; if (isZoneEquipType) { @@ -3513,8 +3522,8 @@ namespace Avail { Status availStatus; // If applicability schedule is off, then availability manager is inactive, return no action auto &loTurnOffMgr = state.dataAvail->LoTurnOffData(SysAvailNum); - if (loTurnOffMgr.SchedPtr > 0) { - if (GetCurrentScheduleValue(state, loTurnOffMgr.SchedPtr) <= 0.0) { + if (loTurnOffMgr.availSched != nullptr) { + if (loTurnOffMgr.availSched->getCurrentVal() <= 0.0) { availStatus = Status::NoAction; loTurnOffMgr.availStatus = availStatus; return availStatus; @@ -3680,44 +3689,41 @@ namespace Avail { ErrorsFound = true; } - hybridVentMgr.ControlModeSchedPtr = GetScheduleIndex(state, ipsc->cAlphaArgs(4)); - if (hybridVentMgr.ControlModeSchedPtr == 0) { + if (ipsc->lAlphaFieldBlanks(4)) { + ShowSevereEmptyField(state, eoh, ipsc->cAlphaFieldNames(4)); + ErrorsFound = true; + } else if ((hybridVentMgr.controlModeSched = Sched::GetSchedule(state, ipsc->cAlphaArgs(4))) == nullptr) { ShowSevereItemNotFound(state, eoh, ipsc->cAlphaFieldNames(4), ipsc->cAlphaArgs(4)); ErrorsFound = true; } // Check schedule values - SchedMin = GetScheduleMinValue(state, hybridVentMgr.ControlModeSchedPtr); - SchedMax = GetScheduleMaxValue(state, hybridVentMgr.ControlModeSchedPtr); + SchedMin = hybridVentMgr.controlModeSched->getMinVal(state); + SchedMax = hybridVentMgr.controlModeSched->getMaxVal(state); if (SchedMin == 0 && SchedMax == 0) { - ShowWarningError(state, format("{}{}=\"{}\"", RoutineName, cCurrentModuleObject, ipsc->cAlphaArgs(1))); - ShowContinueError(state, - format("{}=\"{}\" specifies control mode 0 for all entries.", ipsc->cAlphaFieldNames(4), ipsc->cAlphaArgs(4))); - ShowContinueError(state, format("All zones using this {} have no hybrid ventilation control.", ipsc->cAlphaFieldNames(4))); + ShowWarningCustomField(state, eoh, ipsc->cAlphaFieldNames(4), ipsc->cAlphaArgs(4), + "Schedule specifies control mode 0 for all entries, " + "All zones using this schedule have no hybrid ventilation control."); } if (SchedMax > 7.0) { - ShowSevereError(state, format("{}{}=\"{}\"", RoutineName, cCurrentModuleObject, ipsc->cAlphaArgs(1))); - ShowContinueError( - state, format("{}=\"{}\", the maximum schedule value should be 7. However, ", ipsc->cAlphaFieldNames(4), ipsc->cAlphaArgs(4))); - ShowContinueError(state, format("the maximum entered value in the schedule is {:.1T}", SchedMax)); + ShowSevereCustomField(state, eoh, ipsc->cAlphaFieldNames(4), ipsc->cAlphaArgs(4), + format("Maximum value should be 7. However, the maximum value in the schedule is {:.1T}", SchedMax)); ErrorsFound = true; } + if (SchedMin < 0.0) { - ShowSevereError(state, format("{}{}=\"{}\"", RoutineName, cCurrentModuleObject, ipsc->cAlphaArgs(1))); - ShowContinueError(state, - format("{}=\"{}the minimum schedule value should be 0. However, ", ipsc->cAlphaFieldNames(4), ipsc->cAlphaArgs(4))); - ShowContinueError(state, format("the minimum entered value in the schedule is {:.1T}", SchedMin)); + ShowSevereCustomField(state, eoh, ipsc->cAlphaFieldNames(4), ipsc->cAlphaArgs(4), + format("Minimum value should be 0. However, the minimum value in the schedule is {:.1T}", SchedMin)); ErrorsFound = true; } + if (SchedMax == 7.0 && !state.dataContaminantBalance->Contaminant.CO2Simulation) { - ShowSevereError(state, format("{}{}=\"{}\"", RoutineName, cCurrentModuleObject, ipsc->cAlphaArgs(1))); - ShowContinueError(state, - format("{}=\"{}\", When the schedule value is 7, carbon dioxide (CO2) control is requested. ", - ipsc->cAlphaFieldNames(4), - ipsc->cAlphaArgs(4))); - ShowContinueError(state, "However, CO2 simulation is not enabled. Please use ZoneAirContaminantBalance object to simulate CO2."); + ShowSevereCustomField(state, eoh, ipsc->cAlphaFieldNames(4), ipsc->cAlphaArgs(4), + "When the schedule value is 7, carbon dioxide (CO2) control is requested." + "However, CO2 simulation is not enabled. Please use ZoneAirContaminantBalance object to simulate CO2."); ErrorsFound = true; } + // Read use weather rain indicator BooleanSwitch b = static_cast(getYesNoValue(ipsc->cAlphaArgs(5))); if (b == BooleanSwitch::Invalid) { @@ -3856,22 +3862,15 @@ namespace Avail { ErrorsFound = true; } - hybridVentMgr.MinOASched = ipsc->cAlphaArgs(6); - hybridVentMgr.MinOASchedPtr = GetScheduleIndex(state, ipsc->cAlphaArgs(6)); - if (hybridVentMgr.MinOASchedPtr == 0) { + + if (ipsc->lAlphaFieldBlanks(6)) { + ShowSevereEmptyField(state, eoh, ipsc->cAlphaFieldNames(6)); + ErrorsFound = true; + } else if ((hybridVentMgr.minOASched = Sched::GetSchedule(state, ipsc->cAlphaArgs(6))) == nullptr) { ShowSevereItemNotFound(state, eoh, ipsc->cAlphaFieldNames(6), ipsc->cAlphaArgs(6)); ErrorsFound = true; - } - SchedMin = GetScheduleMinValue(state, hybridVentMgr.MinOASchedPtr); - if (SchedMin < 0.0) { - ShowSevereError(state, - format(R"({}{}="{}", Schedule value must be >= 0 in {}="{}".)", - RoutineName, - cCurrentModuleObject, - ipsc->cAlphaArgs(1), - ipsc->cAlphaFieldNames(6), - ipsc->cAlphaArgs(6))); - ShowContinueError(state, format("The minimum schedule value is {:.1T}", SchedMin)); + } else if (!hybridVentMgr.minOASched->checkMinVal(state, Clusive::In, 0.0)) { + Sched::ShowSevereBadMin(state, eoh, ipsc->cAlphaFieldNames(6), ipsc->cAlphaArgs(6), Clusive::In, 0.0); ErrorsFound = true; } @@ -3922,109 +3921,80 @@ namespace Avail { } } - hybridVentMgr.ANControlTypeSchedPtr = GetScheduleIndex(state, ipsc->cAlphaArgs(8)); - if (hybridVentMgr.ANControlTypeSchedPtr > 0) { + if (ipsc->lAlphaFieldBlanks(8)) { + } else if ((hybridVentMgr.afnControlTypeSched = Sched::GetSchedule(state, ipsc->cAlphaArgs(8))) == nullptr) { + ShowSevereItemNotFound(state, eoh, ipsc->cAlphaFieldNames(8), ipsc->cAlphaArgs(8)); + ErrorsFound = true; + } else if (!hybridVentMgr.afnControlTypeSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) { + Sched::ShowSevereBadMinMax(state, eoh, ipsc->cAlphaFieldNames(8), ipsc->cAlphaArgs(8), Clusive::In, 0.0, Clusive::In, 1.0); + ErrorsFound = true; + } else { hybridVentMgr.Master = hybridVentMgr.ControlledZoneNum; - // Check schedule values - SchedMin = GetScheduleMinValue(state, hybridVentMgr.ANControlTypeSchedPtr); - SchedMax = GetScheduleMaxValue(state, hybridVentMgr.ANControlTypeSchedPtr); - hybridVentMgr.ANCtrlStatus = hybridVentMgr.ANControlTypeSchedPtr; - if (SchedMax > 1.0) { - ShowSevereError(state, format("{}{}=\"{}\"", RoutineName, cCurrentModuleObject, ipsc->cAlphaArgs(1))); - ShowContinueError(state, format(" For {}=\"{}\",", ipsc->cAlphaFieldNames(8), ipsc->cAlphaArgs(8))); - ShowContinueError(state, "the maximum schedule value should be 1. However, "); - ShowContinueError(state, format("the maximum entered value in the schedule is {:.1T}", SchedMax)); - ErrorsFound = true; - } - if (SchedMin < 0.0) { - ShowSevereError(state, format("{}{}=\"{}\"", RoutineName, cCurrentModuleObject, ipsc->cAlphaArgs(1))); - ShowContinueError(state, format("For {}=\"{}\",", ipsc->cAlphaFieldNames(8), ipsc->cAlphaArgs(8))); - ShowContinueError(state, "the minimum schedule value should be 0. However, "); - ShowContinueError(state, format("the minimum entered value in the schedule is {:.1T}", SchedMin)); - ErrorsFound = true; - } + hybridVentMgr.afnControlStatus = hybridVentMgr.afnControlTypeSched->getCurrentVal(); // this was ANControlTypeSchedPtr!! } - hybridVentMgr.SimpleControlTypeSchedPtr = GetScheduleIndex(state, ipsc->cAlphaArgs(9)); - if (hybridVentMgr.SimpleControlTypeSchedPtr > 0 && hybridVentMgr.ANControlTypeSchedPtr > 0) { - ShowWarningError(state, format("{}{}=\"{}\"", RoutineName, cCurrentModuleObject, ipsc->cAlphaArgs(1))); - ShowContinueError(state, format("The inputs for{} and {} are valid.", ipsc->cAlphaFieldNames(8), ipsc->cAlphaFieldNames(9))); - ShowContinueError(state, "But both objects cannot work at the same time. The Simple Airflow Control is disabled"); - hybridVentMgr.SimpleControlTypeSchedPtr = 0; - } else if (hybridVentMgr.SimpleControlTypeSchedPtr > 0) { - // Check schedule values - SchedMin = GetScheduleMinValue(state, hybridVentMgr.SimpleControlTypeSchedPtr); - SchedMax = GetScheduleMaxValue(state, hybridVentMgr.SimpleControlTypeSchedPtr); - if (SchedMax > 1.0) { - ShowSevereError(state, format("{}{}=\"{}\"", RoutineName, cCurrentModuleObject, ipsc->cAlphaArgs(1))); - ShowContinueError(state, format("For {}=\"{}\",", ipsc->cAlphaFieldNames(9), ipsc->cAlphaArgs(9))); - ShowContinueError(state, "the maximum schedule value should be 1. However, "); - ShowContinueError(state, format("the maximum entered value in the schedule is {:.1T}", SchedMax)); - ErrorsFound = true; - } - if (SchedMin < 0.0) { - ShowSevereError(state, format("{}{}=\"{}\"", RoutineName, cCurrentModuleObject, ipsc->cAlphaArgs(1))); - ShowContinueError(state, format("For {}=\"{}\",", ipsc->cAlphaFieldNames(9), ipsc->cAlphaArgs(9))); - ShowContinueError(state, "the minimum schedule value should be 0. However, "); - ShowContinueError(state, format("the minimum entered value in the schedule is {:.1T}", SchedMin)); - ErrorsFound = true; - } + if (ipsc->lAlphaFieldBlanks(9)) { + } else if ((hybridVentMgr.simpleControlTypeSched = Sched::GetSchedule(state, ipsc->cAlphaArgs(9))) == nullptr) { + ShowSevereItemNotFound(state, eoh, ipsc->cAlphaFieldNames(9), ipsc->cAlphaArgs(9)); + ErrorsFound = true; + } else if (hybridVentMgr.afnControlTypeSched != nullptr) { + ShowWarningCustom(state, eoh, format("{} and {} cannot be used at the same time, {} is disable", + ipsc->cAlphaFieldNames(8), ipsc->cAlphaFieldNames(9))); + hybridVentMgr.simpleControlTypeSched = nullptr; + } else if (!hybridVentMgr.simpleControlTypeSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) { + Sched::ShowSevereBadMinMax(state, eoh, ipsc->cAlphaFieldNames(9), ipsc->cAlphaArgs(9), Clusive::In, 0.0, Clusive::In, 1.0); + ErrorsFound = true; } - if (hybridVentMgr.SimpleControlTypeSchedPtr > 0) { + if (hybridVentMgr.simpleControlTypeSched != nullptr) { + hybridVentMgr.VentilationName = ipsc->cAlphaArgs(10); if (state.dataHeatBal->TotVentilation > 0) { hybridVentMgr.VentilationPtr = Util::FindItemInList(ipsc->cAlphaArgs(10), state.dataHeatBal->Ventilation); hybridVentMgr.Master = hybridVentMgr.VentilationPtr; - SchedMax = GetScheduleMaxValue(state, hybridVentMgr.SimpleControlTypeSchedPtr); - if (hybridVentMgr.VentilationPtr <= 0 && int(SchedMax) == 1) { - ShowSevereItemNotFound(state, eoh, ipsc->cAlphaFieldNames(10), ipsc->cAlphaArgs(10)); - ErrorsFound = true; - } // Otherwise check later - } - } - - // Check simple airflow object - if (hybridVentMgr.SimpleControlTypeSchedPtr > 0 && hybridVentMgr.VentilationPtr > 0) { - if (hybridVentMgr.ControlledZoneNum != state.dataHeatBal->Ventilation(hybridVentMgr.VentilationPtr).ZonePtr) { - ShowSevereError(state, format("{}{}=\"{}\"", RoutineName, cCurrentModuleObject, ipsc->cAlphaArgs(1))); - ShowContinueError(state, - format("The Zone name specified in the Ventilation object {}", - state.dataHeatBal->Zone(state.dataHeatBal->Ventilation(hybridVentMgr.VentilationPtr).ZonePtr).Name)); - ShowContinueError(state, format("is not equal to the {}=\"{}\".", ipsc->cAlphaFieldNames(3), ipsc->cAlphaArgs(3))); - ErrorsFound = true; - } - } + + if (hybridVentMgr.VentilationPtr <= 0) { + if (int(hybridVentMgr.simpleControlTypeSched->getMaxVal(state)) == 1) { + ShowSevereItemNotFound(state, eoh, ipsc->cAlphaFieldNames(10), ipsc->cAlphaArgs(10)); + ErrorsFound = true; + } - if (hybridVentMgr.SimpleControlTypeSchedPtr > 0 && - state.afn->simulation_control.type != AirflowNetwork::ControlType::NoMultizoneOrDistribution) { - ShowSevereError(state, format("{}{}=\"{}\"", RoutineName, cCurrentModuleObject, hybridVentMgr.Name)); - ShowContinueError(state, "The simple airflow objects are used for natural ventilation calculation."); - ShowContinueError(state, - "The Airflow Network model is not allowed to perform. Please set the control type = NoMultizoneOrDistribution"); - ErrorsFound = true; - } + if (state.afn->simulation_control.type == AirflowNetwork::ControlType::NoMultizoneOrDistribution) { + ShowWarningError(state, format("{}{}=\"{}\"", RoutineName, cCurrentModuleObject, hybridVentMgr.Name)); + ShowContinueError(state, "The Airflow Network model is not available for Hybrid Ventilation Control."); + } else if (state.afn->simulation_control.type == AirflowNetwork::ControlType::MultizoneWithDistributionOnlyDuringFanOperation) { + ShowWarningError(state, format("{}{}=\"{}\"", RoutineName, cCurrentModuleObject, hybridVentMgr.Name)); + ShowContinueError(state, "Please check the AirflowNetwork Control field in the AirflowNetwork:SimulationControl object."); + ShowContinueError(state, "The suggested choices are MultizoneWithDistribution or MultizoneWithoutDistribution."); + } + + } else { // hybridVentMgr.VentilationPtr > 0 + if (hybridVentMgr.ControlledZoneNum != state.dataHeatBal->Ventilation(hybridVentMgr.VentilationPtr).ZonePtr) { + ShowSevereError(state, format("{}{}=\"{}\"", RoutineName, cCurrentModuleObject, ipsc->cAlphaArgs(1))); + ShowContinueError(state, + format("The Zone name specified in the Ventilation object {}", + state.dataHeatBal->Zone(state.dataHeatBal->Ventilation(hybridVentMgr.VentilationPtr).ZonePtr).Name)); + ShowContinueError(state, format("is not equal to the {}=\"{}\".", ipsc->cAlphaFieldNames(3), ipsc->cAlphaArgs(3))); + ErrorsFound = true; + } - if (hybridVentMgr.SimpleControlTypeSchedPtr == 0) { - if (state.afn->simulation_control.type == AirflowNetwork::ControlType::NoMultizoneOrDistribution) { - ShowWarningError(state, format("{}{}=\"{}\"", RoutineName, cCurrentModuleObject, hybridVentMgr.Name)); - ShowContinueError(state, "The Airflow Network model is not available for Hybrid Ventilation Control."); - } else if (state.afn->simulation_control.type == AirflowNetwork::ControlType::MultizoneWithDistributionOnlyDuringFanOperation) { - ShowWarningError(state, format("{}{}=\"{}\"", RoutineName, cCurrentModuleObject, hybridVentMgr.Name)); - ShowContinueError(state, "Please check the AirflowNetwork Control field in the AirflowNetwork:SimulationControl object."); - ShowContinueError(state, "The suggested choices are MultizoneWithDistribution or MultizoneWithoutDistribution."); + if (state.afn->simulation_control.type != AirflowNetwork::ControlType::NoMultizoneOrDistribution) { + ShowSevereError(state, format("{}{}=\"{}\"", RoutineName, cCurrentModuleObject, hybridVentMgr.Name)); + ShowContinueError(state, "The simple airflow objects are used for natural ventilation calculation."); + ShowContinueError(state, + "The Airflow Network model is not allowed to perform. Please set the control type = NoMultizoneOrDistribution"); + ErrorsFound = true; + } + } } } - + // Disallow combination of simple control and OA control mode - SchedMax = GetScheduleMaxValue(state, hybridVentMgr.ControlModeSchedPtr); - if (hybridVentMgr.SimpleControlTypeSchedPtr > 0 && SchedMax == 4.0) { - ShowSevereError(state, format("{}{}=\"{}\"", RoutineName, cCurrentModuleObject, ipsc->cAlphaArgs(1))); - ShowContinueError(state, - format("The outdoor ventilation air control type defined in {} cannot work together with {}", - ipsc->cAlphaArgs(4), - ipsc->cAlphaFieldNames(9))); + if (hybridVentMgr.simpleControlTypeSched != nullptr && hybridVentMgr.controlModeSched->getMaxVal(state) == 4.0) { + ShowSevereCustom(state, eoh, format("The outdoor ventilation air control type defined in {} cannot work together with {}", + ipsc->cAlphaArgs(4), + ipsc->cAlphaFieldNames(9))); ErrorsFound = true; } @@ -4039,8 +4009,8 @@ namespace Avail { if (state.dataAvail->NumHybridVentSysAvailMgrs > 1) { for (int SysAvailNum = 2; SysAvailNum <= state.dataAvail->NumHybridVentSysAvailMgrs; ++SysAvailNum) { - if (state.dataAvail->HybridVentData(SysAvailNum - 1).ANControlTypeSchedPtr > 0) { - if (state.dataAvail->HybridVentData(SysAvailNum).SimpleControlTypeSchedPtr > 0) { + if (state.dataAvail->HybridVentData(SysAvailNum - 1).afnControlTypeSched != nullptr) { + if (state.dataAvail->HybridVentData(SysAvailNum).simpleControlTypeSched != nullptr) { ShowSevereError(state, format("The AirflowNetwork model is used for natural ventilation calculation in {}=\"{}\"", cCurrentModuleObject, @@ -4053,8 +4023,8 @@ namespace Avail { ErrorsFound = true; } } - if (state.dataAvail->HybridVentData(SysAvailNum - 1).SimpleControlTypeSchedPtr > 0) { - if (state.dataAvail->HybridVentData(SysAvailNum).ANControlTypeSchedPtr > 0) { + if (state.dataAvail->HybridVentData(SysAvailNum - 1).simpleControlTypeSched != nullptr) { + if (state.dataAvail->HybridVentData(SysAvailNum).afnControlTypeSched != nullptr) { ShowSevereError(state, format("The Airflow Network model is used for natural ventilation calculation in {}=\"{}\"", cCurrentModuleObject, @@ -4128,8 +4098,8 @@ namespace Avail { state.dataAvail->HybridVentData(SysAvailNum).Name); } - if (CheckScheduleValue(state, state.dataAvail->HybridVentData(SysAvailNum).ControlModeSchedPtr, (int)VentCtrlType::OperT80) || - CheckScheduleValue(state, state.dataAvail->HybridVentData(SysAvailNum).ControlModeSchedPtr, (int)VentCtrlType::OperT90)) { + if (state.dataAvail->HybridVentData(SysAvailNum).controlModeSched->hasVal(state, (int)VentCtrlType::OperT80) || + state.dataAvail->HybridVentData(SysAvailNum).controlModeSched->hasVal(state, (int)VentCtrlType::OperT90)) { SetupOutputVariable(state, "Hybrid Ventilation Operative Temperature", Constant::Units::C, @@ -4153,7 +4123,7 @@ namespace Avail { state.dataAvail->HybridVentData(SysAvailNum).Name); } - if (CheckScheduleValue(state, state.dataAvail->HybridVentData(SysAvailNum).ControlModeSchedPtr, (int)VentCtrlType::CO2)) { + if (state.dataAvail->HybridVentData(SysAvailNum).controlModeSched->hasVal(state, (int)VentCtrlType::CO2)) { SetupOutputVariable(state, "Hybrid Ventilation CO2 Concentration", Constant::Units::ppm, @@ -4189,7 +4159,6 @@ namespace Avail { bool ErrorsFound(false); // Set to true if errors in input, fatal at end of routine int AirLoopNum; // Air loop number int AirLoopCount; // Air loop name count - Real64 SchedMax; // Maximum value specified in a schedule int SysAvailIndex; // Hybrid Ventilation Sys Avail Manager index int ZoneEquipType; int HybridVentNum; @@ -4202,11 +4171,10 @@ namespace Avail { for (int SysAvailNum = 1; SysAvailNum <= state.dataAvail->NumHybridVentSysAvailMgrs; ++SysAvailNum) { auto &hybridVentMgr = state.dataAvail->HybridVentData(SysAvailNum); ErrorObjectHeader eoh{routineName, managerTypeNames[(int)ManagerType::HybridVent], hybridVentMgr.Name}; - if (hybridVentMgr.SimpleControlTypeSchedPtr > 0 && state.dataHeatBal->TotVentilation > 0 && hybridVentMgr.VentilationPtr == 0) { + if (hybridVentMgr.simpleControlTypeSched != nullptr && state.dataHeatBal->TotVentilation > 0 && hybridVentMgr.VentilationPtr == 0) { hybridVentMgr.VentilationPtr = Util::FindItemInList(hybridVentMgr.VentilationName, state.dataHeatBal->Ventilation); hybridVentMgr.Master = hybridVentMgr.VentilationPtr; - SchedMax = GetScheduleMaxValue(state, hybridVentMgr.SimpleControlTypeSchedPtr); - if (hybridVentMgr.VentilationPtr <= 0 && int(SchedMax) == 1) { + if (hybridVentMgr.VentilationPtr <= 0 && int(hybridVentMgr.simpleControlTypeSched->getMaxVal(state)) == 1) { ShowSevereItemNotFound(state, eoh, "ZoneVentilation Object Name", hybridVentMgr.VentilationName); ErrorsFound = true; } @@ -4281,15 +4249,14 @@ namespace Avail { ErrorsFound = true; } // check schedule value for adaptive temperature control - if (CheckScheduleValue(state, hybridVentMgr.ControlModeSchedPtr, 5.0) || - CheckScheduleValue(state, hybridVentMgr.ControlModeSchedPtr, 6.0)) { + if (hybridVentMgr.controlModeSched->hasVal(state, 5.0) || hybridVentMgr.controlModeSched->hasVal(state, 6.0)) { if (!state.dataHeatBal->AdaptiveComfortRequested_ASH55) { ShowSevereError(state, format("GetHybridVentilationInputs: AvailabilityManager:HybridVentilation =\"{}\"", hybridVentMgr.Name)); ShowContinueError(state, format("Ventilation Control Mode Schedule Name =\"{}\", When the schedule value is 5 or 6, operative " "temperature control is requested. ", - state.dataScheduleMgr->Schedule(hybridVentMgr.ControlModeSchedPtr).Name)); + hybridVentMgr.controlModeSched->Name)); ShowContinueError(state, "However, AdaptiveASH55 is not entered in the Thermal Comfort Model Type fields in the People object."); ErrorsFound = true; @@ -4327,7 +4294,7 @@ namespace Avail { for (int SysAvailNum = 1; SysAvailNum <= state.dataAvail->NumHybridVentSysAvailMgrs; ++SysAvailNum) { auto &hybridVentMgr = state.dataAvail->HybridVentData(SysAvailNum); - hybridVentMgr.ctrlType = static_cast(GetCurrentScheduleValue(state, hybridVentMgr.ControlModeSchedPtr)); + hybridVentMgr.ctrlType = static_cast(hybridVentMgr.controlModeSched->getCurrentVal()); // -1 means that the value will be determined inside CalcHybridVentSysAvailMgr. // IF the value is still -1, the program will stop. // hybridVentMgr.ctrlStatus = VentCtrlStatus::Invalid; // Not sure what this is for @@ -4496,7 +4463,7 @@ namespace Avail { } break; case VentCtrlType::OA: { - OASetPoint = GetCurrentScheduleValue(state, hybridVentMgr.MinOASchedPtr); + OASetPoint = hybridVentMgr.minOASched->getCurrentVal(); ACH = 0.0; HybridVentModeOA = true; if (!hybridVentMgr.HybridVentMgrConnectedToAirLoop) { @@ -4505,7 +4472,7 @@ namespace Avail { } } - if (hybridVentMgr.ANControlTypeSchedPtr > 0 && HybridVentModeOA) { + if (hybridVentMgr.afnControlTypeSched != nullptr && HybridVentModeOA) { state.afn->manage_balance(true); ACH = state.afn->zone_OA_change_rate(ZoneNum); } @@ -4594,24 +4561,25 @@ namespace Avail { if (hybridVentMgr.ctrlStatus == VentCtrlStatus::Open) { + auto const &zoneTstatSetpt = state.dataHeatBalFanSys->zoneTstatSetpts(ZoneNum); // Temperature and enthalpy control if (hybridVentMgr.ctrlType == VentCtrlType::Temp || hybridVentMgr.ctrlType == VentCtrlType::Enth) { switch (state.dataHeatBalFanSys->TempControlType(ZoneNum)) { - case HVAC::ThermostatType::SingleHeating: { - if (thisZoneHB.MAT < state.dataHeatBalFanSys->TempZoneThermostatSetPoint(ZoneNum)) { + case HVAC::SetptType::SingleHeat: { + if (thisZoneHB.MAT < zoneTstatSetpt.setpt) { hybridVentMgr.ctrlStatus = VentCtrlStatus::Close; } } break; - case HVAC::ThermostatType::SingleCooling: { - if (thisZoneHB.MAT > state.dataHeatBalFanSys->TempZoneThermostatSetPoint(ZoneNum)) { + case HVAC::SetptType::SingleCool: { + if (thisZoneHB.MAT > zoneTstatSetpt.setpt) { hybridVentMgr.ctrlStatus = VentCtrlStatus::Close; } } break; - case HVAC::ThermostatType::SingleHeatCool: { + case HVAC::SetptType::SingleHeatCool: { hybridVentMgr.ctrlStatus = VentCtrlStatus::Close; ++hybridVentMgr.SingleHCErrCount; if (hybridVentMgr.SingleHCErrCount < 2) { @@ -4631,9 +4599,9 @@ namespace Avail { } } break; - case HVAC::ThermostatType::DualSetPointWithDeadBand: { - if ((thisZoneHB.MAT < state.dataHeatBalFanSys->ZoneThermostatSetPointLo(ZoneNum)) || - (thisZoneHB.MAT > state.dataHeatBalFanSys->ZoneThermostatSetPointHi(ZoneNum))) { + + case HVAC::SetptType::DualHeatCool: { + if (thisZoneHB.MAT < zoneTstatSetpt.setptLo || thisZoneHB.MAT > zoneTstatSetpt.setptHi) { hybridVentMgr.ctrlStatus = VentCtrlStatus::Close; } @@ -4670,10 +4638,8 @@ namespace Avail { for (HStatZoneNum = 1; HStatZoneNum <= state.dataZoneCtrls->NumHumidityControlZones; ++HStatZoneNum) { if (state.dataZoneCtrls->HumidityControlZone(HStatZoneNum).ActualZoneNum == ZoneNum) { found = true; - ZoneRHHumidifyingSetPoint = - GetCurrentScheduleValue(state, state.dataZoneCtrls->HumidityControlZone(HStatZoneNum).HumidifyingSchedIndex); - ZoneRHDehumidifyingSetPoint = - GetCurrentScheduleValue(state, state.dataZoneCtrls->HumidityControlZone(HStatZoneNum).DehumidifyingSchedIndex); + ZoneRHHumidifyingSetPoint = state.dataZoneCtrls->HumidityControlZone(HStatZoneNum).humidifyingSched->getCurrentVal(); + ZoneRHDehumidifyingSetPoint = state.dataZoneCtrls->HumidityControlZone(HStatZoneNum).dehumidifyingSched->getCurrentVal(); if (ZoneAirRH > ZoneRHDehumidifyingSetPoint) { // Need dehumidification WSetPoint = PsyWFnTdbRhPb(state, thisZoneHB.MAT, (ZoneRHDehumidifyingSetPoint / 100.0), state.dataEnvrn->OutBaroPress); @@ -4736,13 +4702,13 @@ namespace Avail { } } - if (hybridVentMgr.ctrlStatus == VentCtrlStatus::Open && hybridVentMgr.ANControlTypeSchedPtr > 0 && hybridVentMgr.OpeningFactorFWS > 0) { + if (hybridVentMgr.ctrlStatus == VentCtrlStatus::Open && hybridVentMgr.afnControlTypeSched != nullptr && hybridVentMgr.OpeningFactorFWS > 0) { hybridVentMgr.WindModifier = CurveValue(state, hybridVentMgr.OpeningFactorFWS, WindExt); } // Set up flags to control simple airflow objects - if (hybridVentMgr.AirLoopNum > 0 && hybridVentMgr.SimpleControlTypeSchedPtr > 0) { - SimpleControlType = GetCurrentScheduleValue(state, hybridVentMgr.SimpleControlTypeSchedPtr); + if (hybridVentMgr.AirLoopNum > 0 && hybridVentMgr.simpleControlTypeSched != nullptr) { + SimpleControlType = hybridVentMgr.simpleControlTypeSched->getCurrentVal(); for (int ControlledZoneNum = 1; ControlledZoneNum <= state.dataGlobal->NumOfZones; ++ControlledZoneNum) { for (int zoneInNode = 1; zoneInNode <= state.dataZoneEquip->ZoneEquipConfig(ControlledZoneNum).NumInletNodes; ++zoneInNode) { if (hybridVentMgr.AirLoopNum == state.dataZoneEquip->ZoneEquipConfig(ControlledZoneNum).InletNodeAirLoopNum(zoneInNode)) { @@ -4777,8 +4743,8 @@ namespace Avail { } } } - } else if (hybridVentMgr.SimpleControlTypeSchedPtr > 0) { - SimpleControlType = GetCurrentScheduleValue(state, hybridVentMgr.SimpleControlTypeSchedPtr); + } else if (hybridVentMgr.simpleControlTypeSched != nullptr) { + SimpleControlType = hybridVentMgr.simpleControlTypeSched->getCurrentVal(); // Hybrid ventilation manager is applied to zone component // setup flag for ventilation objects for (i = 1; i <= state.dataHeatBal->TotVentilation; ++i) { @@ -4836,7 +4802,7 @@ namespace Avail { for (int SysAvailNum = 1; SysAvailNum <= state.dataAvail->NumHybridVentSysAvailMgrs; ++SysAvailNum) { if (state.dataAvail->HybridVentData(SysAvailNum).ControlledZoneNum == ZoneNum) { - if (state.dataAvail->HybridVentData(SysAvailNum).SimpleControlTypeSchedPtr > 0) { + if (state.dataAvail->HybridVentData(SysAvailNum).simpleControlTypeSched != nullptr) { VentControl = true; } } diff --git a/src/EnergyPlus/SystemAvailabilityManager.hh b/src/EnergyPlus/SystemAvailabilityManager.hh index 4361571aef9..4a494b170a2 100644 --- a/src/EnergyPlus/SystemAvailabilityManager.hh +++ b/src/EnergyPlus/SystemAvailabilityManager.hh @@ -56,6 +56,7 @@ #include #include #include +#include namespace EnergyPlus { @@ -146,7 +147,7 @@ namespace Avail { // Members std::string Name; // Name of the manager object ManagerType type = ManagerType::Invalid; // Integer equivalent of availability manager type - int SchedPtr = 0; // Schedule pointer + Sched::Schedule *availSched = nullptr; // Schedule pointer Status availStatus = Status::NoAction; // reports status of availability manager }; @@ -165,8 +166,7 @@ namespace Avail { struct SysAvailManagerNightCycle : SysAvailManager // Derived type for Night Cycle Sys Avail Managers { // Members - std::string FanSched; // Fan schedule name - int FanSchedPtr; // Fan schedule pointer + Sched::Schedule *fanSched = nullptr; // Fan schedule // Cycle On Control Zone, or Cycle On Any - Zone Fans Only Real64 TempTolRange; // range in degrees C of thermostat tolerance int CyclingTimeSteps; // period (in Loads time steps) system will cycle on. @@ -188,7 +188,7 @@ namespace Avail { // Default Constructor SysAvailManagerNightCycle() - : FanSchedPtr(0), TempTolRange(1.0), CyclingTimeSteps(1), NumOfCtrlZones(0), NumOfCoolingZones(0), NumOfHeatingZones(0), + : TempTolRange(1.0), CyclingTimeSteps(1), NumOfCtrlZones(0), NumOfCoolingZones(0), NumOfHeatingZones(0), NumOfHeatZnFanZones(0) { } @@ -198,8 +198,8 @@ namespace Avail { { // Members bool isSimulated; // true after availability manager is simulated - std::string FanSched; // Fan schedule name - int FanSchedPtr; // Fan schedule pointer + + Sched::Schedule *fanSched = nullptr; // Fan schedule std::string CtrlZoneName; // Name of the control zone int ZoneNum; // zone number of control zone std::string ZoneListName; // Zone List name @@ -240,7 +240,7 @@ namespace Avail { // Default Constructor SysAvailManagerOptimumStart() - : isSimulated(false), FanSchedPtr(0), ZoneNum(0), NumOfZones(0), MaxOptStartTime(6.0), controlAlgorithm(ControlAlgorithm::Invalid), + : isSimulated(false), ZoneNum(0), NumOfZones(0), MaxOptStartTime(6.0), controlAlgorithm(ControlAlgorithm::Invalid), ConstTGradCool(1.0), ConstTGradHeat(1.0), InitTGradCool(1.0), InitTGradHeat(1.0), AdaptiveTGradCool(1.0), AdaptiveTGradHeat(1.0), ConstStartTime(2.0), NumPreDays(1), NumHoursBeforeOccupancy(0.0), TempDiffHi(0.0), TempDiffLo(0.0), ATGWCZoneNumLo(0), ATGWCZoneNumHi(0), CycleOnFlag(false), ATGUpdateFlag1(false), ATGUpdateFlag2(false), FirstTimeATGFlag(true), OverNightStartFlag(false), @@ -296,10 +296,8 @@ namespace Avail { struct SysAvailManagerNightVent : SysAvailManager { // Members - std::string FanSched; // Fan schedule name - int FanSchedPtr; // Fan schedule pointer - std::string VentTempSched; // Ventilation temperature schedule - int VentTempSchedPtr; // Ventilation temperature schedule pointer + Sched::Schedule *fanSched = nullptr; // Fan schedule + Sched::Schedule *ventTempSched = nullptr; // Ventilation temperature schedule Real64 VentDelT; // Ventilation delta T [deltaC] Real64 VentTempLowLim; // ventilation temperature low limit std::string CtrlZoneName; // Name of the control zone @@ -307,7 +305,7 @@ namespace Avail { Real64 VentFlowFrac; // the night venting flow fraction // Default Constructor - SysAvailManagerNightVent() : FanSchedPtr(0), VentTempSchedPtr(0), VentDelT(0.0), VentTempLowLim(0.0), ZoneNum(0), VentFlowFrac(0.0) + SysAvailManagerNightVent() : VentDelT(0.0), VentTempLowLim(0.0), ZoneNum(0), VentFlowFrac(0.0) { } }; @@ -344,7 +342,7 @@ namespace Avail { std::string ControlZoneName; // Controlled zone name int NodeNumOfControlledZone; // Controlled zone node number int ControlledZoneNum; // Controlled zone number - int ControlModeSchedPtr; // Ventilation control mode schedule pointer + Sched::Schedule *controlModeSched = nullptr; // Ventilation control mode schedule VentCtrlType ctrlType = VentCtrlType::No; // hybrid ventilation control mode VentCtrlStatus ctrlStatus = VentCtrlStatus::NoAction; // Ventilation control type: Noaction, Close, Open Real64 MinOutdoorTemp; // Minimum Outdoor Temperature [C] @@ -355,8 +353,7 @@ namespace Avail { Real64 MaxOutdoorDewPoint; // Maximum Outdoor Dew Point Temperature [C] Real64 MaxWindSpeed; // Maximum Wind speed [m/s] bool UseRainIndicator; // Use WeatherFile Rain Indicators - std::string MinOASched; // Minimum Outdoor Ventilation Air Schedule Name - int MinOASchedPtr; // Minimum Outdoor Ventilation Air Schedule pointer + Sched::Schedule *minOASched = nullptr; // Minimum Outdoor Ventilation Air Schedule int DewPointNoRHErrCount; // Dewpoint control mode error count without a humidistat int DewPointNoRHErrIndex; // Dewpoint control mode error index without a humidistat int DewPointErrCount; // Dewpoint control mode error count without a valid humidistat @@ -366,8 +363,9 @@ namespace Avail { int SingleHCErrIndex; // Temperature and enthalpy control mode error index // with a singleHeatingCooling setpoint int OpeningFactorFWS; // Opening factor modifier as a function of wind speed - int ANControlTypeSchedPtr; // AirflowNetwork control type schedule pointer - int SimpleControlTypeSchedPtr; // Simple airflow object control type schedule pointer + + Sched::Schedule *afnControlTypeSched = nullptr; // AirflowNetwork control type schedule pointer + Sched::Schedule *simpleControlTypeSched = nullptr; // Simple airflow object control type schedule pointer int VentilationPtr; // Ventilation object name pointer std::string VentilationName; // Ventilation object name bool HybridVentMgrConnectedToAirLoop; // Flag to check whether hybrid ventilation @@ -383,16 +381,16 @@ namespace Avail { Real64 minAdaTem; // minimum adaptive temperature for adaptive temperature control [C] Real64 maxAdaTem; // maximum adaptive temperature for adaptive temperature control [C] - int ANCtrlStatus = 0; + int afnControlStatus = 0; int Master = 0; Real64 WindModifier = 0.0; // Default Constructor SysAvailManagerHybridVent() - : AirLoopNum(0), NodeNumOfControlledZone(0), ControlledZoneNum(0), ControlModeSchedPtr(0), MinOutdoorTemp(-100.0), MaxOutdoorTemp(100.0), + : AirLoopNum(0), NodeNumOfControlledZone(0), ControlledZoneNum(0), MinOutdoorTemp(-100.0), MaxOutdoorTemp(100.0), MinOutdoorEnth(0.1), MaxOutdoorEnth(300000.0), MinOutdoorDewPoint(-100.0), MaxOutdoorDewPoint(100.0), MaxWindSpeed(0.0), - UseRainIndicator(true), MinOASchedPtr(0), DewPointNoRHErrCount(0), DewPointNoRHErrIndex(0), DewPointErrCount(0), DewPointErrIndex(0), - SingleHCErrCount(0), SingleHCErrIndex(0), OpeningFactorFWS(0), ANControlTypeSchedPtr(0), SimpleControlTypeSchedPtr(0), + UseRainIndicator(true), DewPointNoRHErrCount(0), DewPointNoRHErrIndex(0), DewPointErrCount(0), DewPointErrIndex(0), + SingleHCErrCount(0), SingleHCErrIndex(0), OpeningFactorFWS(0), VentilationPtr(0), HybridVentMgrConnectedToAirLoop(true), SimHybridVentSysAvailMgr(false), OperativeTemp(0.0), CO2(0.0), MinOperTime(0.0), MinVentTime(0.0), TimeOperDuration(0.0), TimeVentDuration(0.0), minAdaTem(0.0), maxAdaTem(0.0) { @@ -626,6 +624,10 @@ struct SystemAvailabilityManagerData : BaseGlobalStruct Real64 TimeStepSysLast = 0.0; // last system time step // Hybrid ventilation control part + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/SystemReports.cc b/src/EnergyPlus/SystemReports.cc index e862f4ba56a..cd63e9354b8 100644 --- a/src/EnergyPlus/SystemReports.cc +++ b/src/EnergyPlus/SystemReports.cc @@ -5077,7 +5077,6 @@ void reportAirDistributionUnits(EnergyPlusData &state) auto &orp = state.dataOutRptPredefined; for (auto &adu : state.dataDefineEquipment->AirDistUnit) { - auto &airTerminal = adu.airTerminalPtr; constexpr int aduCompNum = 1; OutputReportPredefined::PreDefTableEntry(state, orp->pdchAirTermZoneName, adu.Name, state.dataHeatBal->Zone(adu.ZoneNum).Name); switch (adu.EquipTypeEnum(aduCompNum)) { diff --git a/src/EnergyPlus/SystemReports.hh b/src/EnergyPlus/SystemReports.hh index 7bfc1338eaa..9b29ff32983 100644 --- a/src/EnergyPlus/SystemReports.hh +++ b/src/EnergyPlus/SystemReports.hh @@ -415,6 +415,10 @@ struct SystemReportsData : BaseGlobalStruct Array1D CompTypeErrors = Array1D(100); Array1D LoopStack; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/TARCOGCommon.hh b/src/EnergyPlus/TARCOGCommon.hh index f5023ce4bf1..3035502d234 100644 --- a/src/EnergyPlus/TARCOGCommon.hh +++ b/src/EnergyPlus/TARCOGCommon.hh @@ -120,6 +120,10 @@ struct TARCOGCommonData : BaseGlobalStruct { Array1D vv = Array1D(TARCOGCommon::NMAX); + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/TARCOGGasses90.hh b/src/EnergyPlus/TARCOGGasses90.hh index ceca8e70e8e..4bde906ee6a 100644 --- a/src/EnergyPlus/TARCOGGasses90.hh +++ b/src/EnergyPlus/TARCOGGasses90.hh @@ -98,6 +98,10 @@ struct TARCOGGasses90Data : BaseGlobalStruct Array1D kpdown = Array1D(TARCOGGassesParams::maxgas); Array1D kdpdown = Array1D(TARCOGGassesParams::maxgas); + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/TARCOGMain.hh b/src/EnergyPlus/TARCOGMain.hh index 5f3e6b70c43..b6409165424 100644 --- a/src/EnergyPlus/TARCOGMain.hh +++ b/src/EnergyPlus/TARCOGMain.hh @@ -186,6 +186,10 @@ struct TARCOGMainData : BaseGlobalStruct Array1D CurGap = Array1D(TARCOGParams::MaxGap); Array1D GapDefMean = Array1D(TARCOGParams::MaxGap); + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/TARCOGOutput.hh b/src/EnergyPlus/TARCOGOutput.hh index 892fdfd9ef1..7116eee0ffc 100644 --- a/src/EnergyPlus/TARCOGOutput.hh +++ b/src/EnergyPlus/TARCOGOutput.hh @@ -305,6 +305,10 @@ struct TARCOGOutputData : BaseGlobalStruct int winID = 0; int iguID = 0; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/TarcogShading.cc b/src/EnergyPlus/TarcogShading.cc index b9350f56fbb..c118b45bbef 100644 --- a/src/EnergyPlus/TarcogShading.cc +++ b/src/EnergyPlus/TarcogShading.cc @@ -798,7 +798,7 @@ namespace TarcogShading { // A = dens0 * T0 * GravityConstant * ABS(cos(tilt)) * ABS(Tgap1 - Tgap2) / (Tgap1 * Tgap2) // bi...Bug fix #00005: - A = dens0 * T0 * Constant::GravityConstant * H * std::abs(cos_Tilt) * std::abs(Tgap1 - Tgap2) / (Tgap1 * Tgap2); + A = dens0 * T0 * Constant::Gravity * H * std::abs(cos_Tilt) * std::abs(Tgap1 - Tgap2) / (Tgap1 * Tgap2); if (A == 0.0) { qv1 = 0.0; @@ -1102,7 +1102,7 @@ namespace TarcogShading { // A = dens0 * T0 * gravity * ABS(cos(tilt)) * ABS(Tgap - Tenv) / (Tgap * Tenv) // bi...Bug fix #00005: - A = dens0 * T0 * Constant::GravityConstant * H * abs_cos_tilt * std::abs(Tgap - Tenv) / (Tgap * Tenv); + A = dens0 * T0 * Constant::Gravity * H * abs_cos_tilt * std::abs(Tgap - Tenv) / (Tgap * Tenv); // A = dens0 * T0 * GravityConstant * H * ABS(cos(tilt)) * (Tgap - Tenv) / (Tgap * Tenv) B1 = dens2 / 2; diff --git a/src/EnergyPlus/TarcogShading.hh b/src/EnergyPlus/TarcogShading.hh index 13cd21eb0d5..3a049e9ebe3 100644 --- a/src/EnergyPlus/TarcogShading.hh +++ b/src/EnergyPlus/TarcogShading.hh @@ -220,6 +220,10 @@ struct TarcogShadingData : BaseGlobalStruct Array1D_int iprop1 = Array1D_int(TARCOGGassesParams::maxgas); Array1D_int iprop2 = Array1D_int(TARCOGGassesParams::maxgas); + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/ThermalChimney.cc b/src/EnergyPlus/ThermalChimney.cc index 58b236f75c5..c0b8b901cdb 100644 --- a/src/EnergyPlus/ThermalChimney.cc +++ b/src/EnergyPlus/ThermalChimney.cc @@ -147,10 +147,7 @@ namespace ThermalChimney { // This subroutine obtains input data for ThermalChimney units and // stores it in the ThermalChimney data structure. - // Using/Aliasing - - using ScheduleManager::GetScheduleIndex; - + static constexpr std::string_view routineName = "GetThermalChimney"; // SUBROUTINE PARAMETER DEFINITIONS: Real64 constexpr FlowFractionTolerance(0.0001); // Smallest deviation from unity for the sum of all fractions @@ -188,6 +185,9 @@ namespace ThermalChimney { state.dataIPShortCut->lAlphaFieldBlanks, state.dataIPShortCut->cAlphaFieldNames, state.dataIPShortCut->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1)}; + if (Util::IsNameEmpty(state, state.dataIPShortCut->cAlphaArgs(1), cCurrentModuleObject, ErrorsFound)) { continue; } @@ -214,18 +214,11 @@ namespace ThermalChimney { } state.dataThermalChimneys->ThermalChimneySys(Loop).RealZoneName = state.dataIPShortCut->cAlphaArgs(2); - state.dataThermalChimneys->ThermalChimneySys(Loop).SchedName = state.dataIPShortCut->cAlphaArgs(3); if (state.dataIPShortCut->lAlphaFieldBlanks(3)) { - state.dataThermalChimneys->ThermalChimneySys(Loop).SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - state.dataThermalChimneys->ThermalChimneySys(Loop).SchedPtr = GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(3)); - if (state.dataThermalChimneys->ThermalChimneySys(Loop).SchedPtr == 0) { - ShowSevereError(state, format("{}=\"{} invalid data", cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError( - state, - format("Invalid-not found {}=\"{}\".", state.dataIPShortCut->cAlphaFieldNames(3), state.dataIPShortCut->cAlphaArgs(3))); - ErrorsFound = true; - } + state.dataThermalChimneys->ThermalChimneySys(Loop).availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((state.dataThermalChimneys->ThermalChimneySys(Loop).availSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(3))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(3), state.dataIPShortCut->cAlphaArgs(3)); + ErrorsFound = true; } state.dataThermalChimneys->ThermalChimneySys(Loop).AbsorberWallWidth = state.dataIPShortCut->rNumericArgs(1); @@ -674,8 +667,6 @@ namespace ThermalChimney { // PURPOSE OF THIS SUBROUTINE: // This subroutine simulates the components making up the ThermalChimney. - using ScheduleManager::GetCurrentScheduleValue; - int constexpr NTC(15); // Number of subregions in thermal chimney air channel for FINITE DIFFERENCE // To be obtained from other modules and subroutines @@ -958,7 +949,7 @@ namespace ThermalChimney { } state.dataThermalChimneys->ThermalChimneyReport(Loop).OutletAirTempThermalChim = ThermChimSubTemp(NTC) - Constant::Kelvin; - if (GetCurrentScheduleValue(state, state.dataThermalChimneys->ThermalChimneySys(Loop).SchedPtr) <= 0.0) { + if (state.dataThermalChimneys->ThermalChimneySys(Loop).availSched->getCurrentVal() <= 0.0) { for (int TCZoneNum = 1; TCZoneNum <= state.dataThermalChimneys->ThermalChimneySys(Loop).TotZoneToDistrib; ++TCZoneNum) { int tcZonePtr = state.dataThermalChimneys->ThermalChimneySys(Loop).ZonePtr(TCZoneNum); auto &thisTCZoneHB = state.dataZoneTempPredictorCorrector->zoneHeatBalance(tcZonePtr); diff --git a/src/EnergyPlus/ThermalChimney.hh b/src/EnergyPlus/ThermalChimney.hh index 797594f6756..11af3f443c5 100644 --- a/src/EnergyPlus/ThermalChimney.hh +++ b/src/EnergyPlus/ThermalChimney.hh @@ -70,8 +70,7 @@ namespace ThermalChimney { std::string Name; int RealZonePtr; std::string RealZoneName; - int SchedPtr; - std::string SchedName; + Sched::Schedule *availSched = nullptr; Real64 AbsorberWallWidth; Real64 AirOutletCrossArea; Real64 DischargeCoeff; @@ -87,7 +86,7 @@ namespace ThermalChimney { // Default Constructor ThermalChimneyData() - : RealZonePtr(0), SchedPtr(0), AbsorberWallWidth(0.0), AirOutletCrossArea(0.0), DischargeCoeff(0.0), TotZoneToDistrib(0), + : RealZonePtr(0), AbsorberWallWidth(0.0), AirOutletCrossArea(0.0), DischargeCoeff(0.0), TotZoneToDistrib(0), EMSOverrideOn(false), EMSAirFlowRateValue(0) { } @@ -148,6 +147,10 @@ struct ThermalChimneysData : BaseGlobalStruct EPVector ZnRptThermChim; EPVector ThermalChimneyReport; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/ThermalComfort.cc b/src/EnergyPlus/ThermalComfort.cc index c46a47475ec..453a4417b48 100644 --- a/src/EnergyPlus/ThermalComfort.cc +++ b/src/EnergyPlus/ThermalComfort.cc @@ -102,7 +102,6 @@ namespace ThermalComfort { // Using/Aliasing using DataHeatBalance::PeopleData; using Psychrometrics::PsyRhFnTdbWPb; - using ScheduleManager::GetCurrentScheduleValue; void ManageThermalComfort(EnergyPlusData &state, bool const InitializeOnly) // when called from ZTPC and calculations aren't needed { @@ -567,17 +566,16 @@ namespace ThermalComfort { // Metabolic rate of body (W/m2) state.dataThermalComforts->ActLevel = - GetCurrentScheduleValue(state, state.dataHeatBal->People(state.dataThermalComforts->PeopleNum).ActivityLevelPtr) / BodySurfArea; + state.dataHeatBal->People(state.dataThermalComforts->PeopleNum).activityLevelSched->getCurrentVal() / BodySurfArea; // Energy consumption by external work (W/m2) state.dataThermalComforts->WorkEff = - GetCurrentScheduleValue(state, state.dataHeatBal->People(state.dataThermalComforts->PeopleNum).WorkEffPtr) * - state.dataThermalComforts->ActLevel; + state.dataHeatBal->People(state.dataThermalComforts->PeopleNum).workEffSched->getCurrentVal() * state.dataThermalComforts->ActLevel; // Clothing unit Real64 IntermediateClothing; switch (state.dataHeatBal->People(state.dataThermalComforts->PeopleNum).clothingType) { case DataHeatBalance::ClothingType::InsulationSchedule: state.dataThermalComforts->CloUnit = - GetCurrentScheduleValue(state, state.dataHeatBal->People(state.dataThermalComforts->PeopleNum).ClothingPtr); + state.dataHeatBal->People(state.dataThermalComforts->PeopleNum).clothingSched->getCurrentVal(); break; case DataHeatBalance::ClothingType::DynamicAshrae55: state.dataThermalComforts->ThermalComfortData(state.dataThermalComforts->PeopleNum).ThermalComfortOpTemp = @@ -589,11 +587,9 @@ namespace ThermalComfort { state.dataThermalComforts->ThermalComfortData(state.dataThermalComforts->PeopleNum).ClothingValue; break; case DataHeatBalance::ClothingType::CalculationSchedule: - IntermediateClothing = - GetCurrentScheduleValue(state, state.dataHeatBal->People(state.dataThermalComforts->PeopleNum).ClothingMethodPtr); + IntermediateClothing = state.dataHeatBal->People(state.dataThermalComforts->PeopleNum).clothingMethodSched->getCurrentVal(); if (IntermediateClothing == 1.0) { - state.dataThermalComforts->CloUnit = - GetCurrentScheduleValue(state, state.dataHeatBal->People(state.dataThermalComforts->PeopleNum).ClothingPtr); + state.dataThermalComforts->CloUnit = state.dataHeatBal->People(state.dataThermalComforts->PeopleNum).clothingSched->getCurrentVal(); state.dataThermalComforts->ThermalComfortData(state.dataThermalComforts->PeopleNum).ClothingValue = state.dataThermalComforts->CloUnit; } else if (IntermediateClothing == 2.0) { @@ -605,8 +601,7 @@ namespace ThermalComfort { state.dataThermalComforts->CloUnit = state.dataThermalComforts->ThermalComfortData(state.dataThermalComforts->PeopleNum).ClothingValue; } else { - state.dataThermalComforts->CloUnit = - GetCurrentScheduleValue(state, state.dataHeatBal->People(state.dataThermalComforts->PeopleNum).ClothingPtr); + state.dataThermalComforts->CloUnit = state.dataHeatBal->People(state.dataThermalComforts->PeopleNum).clothingSched->getCurrentVal(); ShowWarningError(state, format("PEOPLE=\"{}\", Scheduled clothing value will be used rather than clothing calculation method.", state.dataHeatBal->People(state.dataThermalComforts->PeopleNum).Name)); @@ -626,8 +621,7 @@ namespace ThermalComfort { state.dataThermalComforts->AirVel = 0.2; } } else { - state.dataThermalComforts->AirVel = - GetCurrentScheduleValue(state, state.dataHeatBal->People(state.dataThermalComforts->PeopleNum).AirVelocityPtr); + state.dataThermalComforts->AirVel = state.dataHeatBal->People(state.dataThermalComforts->PeopleNum).airVelocitySched->getCurrentVal(); // Ensure air velocity within the reasonable range. Otherwise reccusive warnings is provided if (present(PNum) && (state.dataThermalComforts->AirVel < 0.1 || state.dataThermalComforts->AirVel > 0.5)) { if (state.dataHeatBal->People(state.dataThermalComforts->PeopleNum).AirVelErrIndex == 0) { @@ -839,18 +833,17 @@ namespace ThermalComfort { PsyRhFnTdbWPb(state, state.dataThermalComforts->AirTemp, thisZoneHB.airHumRatAvgComf, state.dataEnvrn->OutBaroPress); // Metabolic rate of body (W/m2) (var RM, M) state.dataThermalComforts->ActLevel = - GetCurrentScheduleValue(state, state.dataHeatBal->People(state.dataThermalComforts->PeopleNum).ActivityLevelPtr) / BodySurfAreaPierce; + state.dataHeatBal->People(state.dataThermalComforts->PeopleNum).activityLevelSched->getCurrentVal() / BodySurfAreaPierce; // Energy consumption by external work (W/m2) (var WME) state.dataThermalComforts->WorkEff = - GetCurrentScheduleValue(state, state.dataHeatBal->People(state.dataThermalComforts->PeopleNum).WorkEffPtr) * + state.dataHeatBal->People(state.dataThermalComforts->PeopleNum).workEffSched->getCurrentVal() * state.dataThermalComforts->ActLevel; // Clothing unit (var CLO) Real64 IntermediateClothing; switch (state.dataHeatBal->People(state.dataThermalComforts->PeopleNum).clothingType) { case DataHeatBalance::ClothingType::InsulationSchedule: - state.dataThermalComforts->CloUnit = - GetCurrentScheduleValue(state, state.dataHeatBal->People(state.dataThermalComforts->PeopleNum).ClothingPtr); + state.dataThermalComforts->CloUnit = state.dataHeatBal->People(state.dataThermalComforts->PeopleNum).clothingSched->getCurrentVal(); break; case DataHeatBalance::ClothingType::DynamicAshrae55: state.dataThermalComforts->ThermalComfortData(state.dataThermalComforts->PeopleNum).ThermalComfortOpTemp = @@ -860,10 +853,9 @@ namespace ThermalComfort { state.dataThermalComforts->CloUnit = state.dataThermalComforts->ThermalComfortData(state.dataThermalComforts->PeopleNum).ClothingValue; break; case DataHeatBalance::ClothingType::CalculationSchedule: - IntermediateClothing = GetCurrentScheduleValue(state, state.dataHeatBal->People(state.dataThermalComforts->PeopleNum).ClothingMethodPtr); + IntermediateClothing = state.dataHeatBal->People(state.dataThermalComforts->PeopleNum).clothingMethodSched->getCurrentVal(); if (IntermediateClothing == 1.0) { - state.dataThermalComforts->CloUnit = - GetCurrentScheduleValue(state, state.dataHeatBal->People(state.dataThermalComforts->PeopleNum).ClothingPtr); + state.dataThermalComforts->CloUnit = state.dataHeatBal->People(state.dataThermalComforts->PeopleNum).clothingSched->getCurrentVal(); state.dataThermalComforts->ThermalComfortData(state.dataThermalComforts->PeopleNum).ClothingValue = state.dataThermalComforts->CloUnit; } else if (IntermediateClothing == 2.0) { @@ -875,8 +867,7 @@ namespace ThermalComfort { state.dataThermalComforts->CloUnit = state.dataThermalComforts->ThermalComfortData(state.dataThermalComforts->PeopleNum).ClothingValue; } else { - state.dataThermalComforts->CloUnit = - GetCurrentScheduleValue(state, state.dataHeatBal->People(state.dataThermalComforts->PeopleNum).ClothingPtr); + state.dataThermalComforts->CloUnit = state.dataHeatBal->People(state.dataThermalComforts->PeopleNum).clothingSched->getCurrentVal(); ShowWarningError(state, "Scheduled clothing value will be used rather than clothing calculation method."); } break; @@ -884,8 +875,7 @@ namespace ThermalComfort { ShowSevereError(state, "Incorrect Clothing Type"); } // (var VEL) - state.dataThermalComforts->AirVel = - GetCurrentScheduleValue(state, state.dataHeatBal->People(state.dataThermalComforts->PeopleNum).AirVelocityPtr); + state.dataThermalComforts->AirVel = state.dataHeatBal->People(state.dataThermalComforts->PeopleNum).airVelocitySched->getCurrentVal(); // (var MET) state.dataThermalComforts->ActMet = state.dataThermalComforts->ActLevel / ActLevelConv; } @@ -1354,8 +1344,7 @@ namespace ThermalComfort { Real64 RelAirVel = CalcRelativeAirVelocity(state.dataThermalComforts->AirVel, state.dataThermalComforts->ActMet); Real64 PPD_AD = -1.0; if (state.dataThermalComforts->ActMet < 1.3 && state.dataThermalComforts->CloUnit < 0.7 && RelAirVel < 0.2) { - Real64 AnkleAirVel = - GetCurrentScheduleValue(state, state.dataHeatBal->People(state.dataThermalComforts->PeopleNum).AnkleAirVelocityPtr); + Real64 AnkleAirVel = state.dataHeatBal->People(state.dataThermalComforts->PeopleNum).ankleAirVelocitySched->getCurrentVal(); Real64 PMV = CalcFangerPMV(state, state.dataThermalComforts->AirTemp, state.dataThermalComforts->RadTemp, @@ -1484,15 +1473,14 @@ namespace ThermalComfort { state.dataThermalComforts->RelHum = PsyRhFnTdbWPb(state, state.dataThermalComforts->AirTemp, thisZoneHB.airHumRatAvgComf, state.dataEnvrn->OutBaroPress); state.dataThermalComforts->ActLevel = - GetCurrentScheduleValue(state, state.dataHeatBal->People(state.dataThermalComforts->PeopleNum).ActivityLevelPtr) / BodySurfArea; + state.dataHeatBal->People(state.dataThermalComforts->PeopleNum).activityLevelSched->getCurrentVal() / BodySurfArea; state.dataThermalComforts->WorkEff = - GetCurrentScheduleValue(state, state.dataHeatBal->People(state.dataThermalComforts->PeopleNum).WorkEffPtr) * + state.dataHeatBal->People(state.dataThermalComforts->PeopleNum).workEffSched->getCurrentVal() * state.dataThermalComforts->ActLevel; switch (state.dataHeatBal->People(state.dataThermalComforts->PeopleNum).clothingType) { case DataHeatBalance::ClothingType::InsulationSchedule: - state.dataThermalComforts->CloUnit = - GetCurrentScheduleValue(state, state.dataHeatBal->People(state.dataThermalComforts->PeopleNum).ClothingPtr); + state.dataThermalComforts->CloUnit = state.dataHeatBal->People(state.dataThermalComforts->PeopleNum).clothingSched->getCurrentVal(); break; case DataHeatBalance::ClothingType::DynamicAshrae55: state.dataThermalComforts->ThermalComfortData(state.dataThermalComforts->PeopleNum).ThermalComfortOpTemp = @@ -1504,11 +1492,10 @@ namespace ThermalComfort { state.dataThermalComforts->ThermalComfortData(state.dataThermalComforts->PeopleNum).ClothingValue; break; case DataHeatBalance::ClothingType::CalculationSchedule: - IntermediateClothing = - GetCurrentScheduleValue(state, state.dataHeatBal->People(state.dataThermalComforts->PeopleNum).ClothingMethodPtr); + IntermediateClothing = state.dataHeatBal->People(state.dataThermalComforts->PeopleNum).clothingMethodSched->getCurrentVal(); if (IntermediateClothing == 1.0) { state.dataThermalComforts->CloUnit = - GetCurrentScheduleValue(state, state.dataHeatBal->People(state.dataThermalComforts->PeopleNum).ClothingPtr); + state.dataHeatBal->People(state.dataThermalComforts->PeopleNum).clothingSched->getCurrentVal(); state.dataThermalComforts->ThermalComfortData(state.dataThermalComforts->PeopleNum).ClothingValue = state.dataThermalComforts->CloUnit; } else if (IntermediateClothing == 2.0) { @@ -1520,8 +1507,7 @@ namespace ThermalComfort { state.dataThermalComforts->CloUnit = state.dataThermalComforts->ThermalComfortData(state.dataThermalComforts->PeopleNum).ClothingValue; } else { - state.dataThermalComforts->CloUnit = - GetCurrentScheduleValue(state, state.dataHeatBal->People(state.dataThermalComforts->PeopleNum).ClothingPtr); + state.dataThermalComforts->CloUnit = state.dataHeatBal->People(state.dataThermalComforts->PeopleNum).clothingSched->getCurrentVal(); ShowWarningError(state, format("PEOPLE=\"{}\", Scheduled clothing value will be used rather than clothing calculation method.", state.dataHeatBal->People(state.dataThermalComforts->PeopleNum).Name)); @@ -1532,8 +1518,7 @@ namespace ThermalComfort { state, format("PEOPLE=\"{}\", Incorrect Clothing Type", state.dataHeatBal->People(state.dataThermalComforts->PeopleNum).Name)); } - state.dataThermalComforts->AirVel = - GetCurrentScheduleValue(state, state.dataHeatBal->People(state.dataThermalComforts->PeopleNum).AirVelocityPtr); + state.dataThermalComforts->AirVel = state.dataHeatBal->People(state.dataThermalComforts->PeopleNum).airVelocitySched->getCurrentVal(); state.dataThermalComforts->IntHeatProd = state.dataThermalComforts->ActLevel - state.dataThermalComforts->WorkEff; // THE FOLLOWING ARE TYPICAL VALUES SET FOR BLAST RUNS // STANDARD MAN: 70. KG WEIGHT, 1.8 M2 SURFACE AREA @@ -2295,7 +2280,7 @@ namespace ThermalComfort { for (iPeople = 1; iPeople <= state.dataHeatBal->TotPeople; ++iPeople) { state.dataThermalComforts->ZoneNum = state.dataHeatBal->People(iPeople).ZonePtr; NumberOccupants = state.dataHeatBal->People(iPeople).NumberOfPeople * - GetCurrentScheduleValue(state, state.dataHeatBal->People(iPeople).NumberOfPeoplePtr); + state.dataHeatBal->People(iPeople).numberOfPeopleSched->getCurrentVal(); if (NumberOccupants > 0) { state.dataThermalComforts->ThermalComfortInASH55(state.dataThermalComforts->ZoneNum).ZoneIsOccupied = true; } @@ -2518,25 +2503,25 @@ namespace ThermalComfort { state.dataThermalComforts->AnyZoneNotMetHeatingOccupied = 0.0; state.dataThermalComforts->AnyZoneNotMetCoolingOccupied = 0.0; for (iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) { + auto const &zoneTstatSetpt = state.dataHeatBalFanSys->zoneTstatSetpts(iZone); + SensibleLoadPredictedNoAdj = state.dataZoneEnergyDemand->ZoneSysEnergyDemand(iZone).TotalOutputRequired; state.dataThermalComforts->ThermalComfortSetPoint(iZone).notMetCooling = 0.0; state.dataThermalComforts->ThermalComfortSetPoint(iZone).notMetHeating = 0.0; state.dataThermalComforts->ThermalComfortSetPoint(iZone).notMetCoolingOccupied = 0.0; state.dataThermalComforts->ThermalComfortSetPoint(iZone).notMetHeatingOccupied = 0.0; - testHeating = (state.dataHeatBalFanSys->TempControlType(iZone) != HVAC::ThermostatType::SingleCooling); - testCooling = (state.dataHeatBalFanSys->TempControlType(iZone) != HVAC::ThermostatType::SingleHeating); + testHeating = (state.dataHeatBalFanSys->TempControlType(iZone) != HVAC::SetptType::SingleCool); + testCooling = (state.dataHeatBalFanSys->TempControlType(iZone) != HVAC::SetptType::SingleHeat); if (testHeating && (SensibleLoadPredictedNoAdj > 0)) { // heating if (state.dataRoomAir->AirModel(iZone).AirModel != RoomAir::RoomAirModel::Mixing) { - deltaT = state.dataHeatBalFanSys->TempTstatAir(iZone) - state.dataHeatBalFanSys->ZoneThermostatSetPointLo(iZone); + deltaT = state.dataHeatBalFanSys->TempTstatAir(iZone) - zoneTstatSetpt.setptLo; } else { if (state.dataZoneTempPredictorCorrector->NumOnOffCtrZone > 0) { - deltaT = state.dataZoneTempPredictorCorrector->zoneHeatBalance(iZone).ZTAV - - state.dataHeatBalFanSys->ZoneThermostatSetPointLoAver(iZone); + deltaT = state.dataZoneTempPredictorCorrector->zoneHeatBalance(iZone).ZTAV - zoneTstatSetpt.setptLoAver; } else { - deltaT = state.dataZoneTempPredictorCorrector->zoneHeatBalance(iZone).ZTAV - - state.dataHeatBalFanSys->ZoneThermostatSetPointLo(iZone); + deltaT = state.dataZoneTempPredictorCorrector->zoneHeatBalance(iZone).ZTAV - zoneTstatSetpt.setptLo; } } if (deltaT < deviationFromSetPtThresholdHtg) { @@ -2555,14 +2540,12 @@ namespace ThermalComfort { } } else if (testCooling && (SensibleLoadPredictedNoAdj < 0)) { // cooling if (state.dataRoomAir->AirModel(iZone).AirModel != RoomAir::RoomAirModel::Mixing) { - deltaT = state.dataHeatBalFanSys->TempTstatAir(iZone) - state.dataHeatBalFanSys->ZoneThermostatSetPointHi(iZone); + deltaT = state.dataHeatBalFanSys->TempTstatAir(iZone) - zoneTstatSetpt.setptHi; } else { if (state.dataZoneTempPredictorCorrector->NumOnOffCtrZone > 0) { - deltaT = state.dataZoneTempPredictorCorrector->zoneHeatBalance(iZone).ZTAV - - state.dataHeatBalFanSys->ZoneThermostatSetPointHiAver(iZone); + deltaT = state.dataZoneTempPredictorCorrector->zoneHeatBalance(iZone).ZTAV - zoneTstatSetpt.setptHiAver; } else { - deltaT = state.dataZoneTempPredictorCorrector->zoneHeatBalance(iZone).ZTAV - - state.dataHeatBalFanSys->ZoneThermostatSetPointHi(iZone); + deltaT = state.dataZoneTempPredictorCorrector->zoneHeatBalance(iZone).ZTAV - zoneTstatSetpt.setptHi; } } @@ -2881,7 +2864,7 @@ namespace ThermalComfort { if (state.dataThermalComforts->runningAverageASH >= 10.0 && state.dataThermalComforts->runningAverageASH <= 33.5) { // Calculate the comfort here (people/output handling loop) numOccupants = state.dataHeatBal->People(state.dataThermalComforts->PeopleNum).NumberOfPeople * - GetCurrentScheduleValue(state, state.dataHeatBal->People(state.dataThermalComforts->PeopleNum).NumberOfPeoplePtr); + state.dataHeatBal->People(state.dataThermalComforts->PeopleNum).numberOfPeopleSched->getCurrentVal(); tComf = 0.31 * state.dataThermalComforts->runningAverageASH + 17.8; state.dataThermalComforts->ThermalComfortData(state.dataThermalComforts->PeopleNum).TComfASH55 = tComf; if (numOccupants > 0) { @@ -3092,7 +3075,7 @@ namespace ThermalComfort { if (state.dataThermalComforts->runningAverageCEN >= 10.0 && state.dataThermalComforts->runningAverageCEN <= 30.0) { // Calculate the comfort here (people/output handling loop) numOccupants = state.dataHeatBal->People(state.dataThermalComforts->PeopleNum).NumberOfPeople * - GetCurrentScheduleValue(state, state.dataHeatBal->People(state.dataThermalComforts->PeopleNum).NumberOfPeoplePtr); + state.dataHeatBal->People(state.dataThermalComforts->PeopleNum).numberOfPeopleSched->getCurrentVal(); tComf = 0.33 * state.dataThermalComforts->runningAverageCEN + 18.8; state.dataThermalComforts->ThermalComfortData(state.dataThermalComforts->PeopleNum).TComfCEN15251 = tComf; if (numOccupants > 0) { diff --git a/src/EnergyPlus/ThermalComfort.hh b/src/EnergyPlus/ThermalComfort.hh index bf0ef945328..c3c52adc686 100644 --- a/src/EnergyPlus/ThermalComfort.hh +++ b/src/EnergyPlus/ThermalComfort.hh @@ -376,6 +376,10 @@ struct ThermalComfortsData : BaseGlobalStruct bool useEpwDataCEN = false; bool firstDaySet = false; // first day is set with initiate -- so do not update + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/ThermalEN673Calc.cc b/src/EnergyPlus/ThermalEN673Calc.cc index c1a4ef1bdd1..16d252539ed 100644 --- a/src/EnergyPlus/ThermalEN673Calc.cc +++ b/src/EnergyPlus/ThermalEN673Calc.cc @@ -412,7 +412,7 @@ namespace ThermalEN673Calc { standard, nperr, ErrorMessage); - Gr(i) = (Constant::GravityConstant * pow_3(gap(i)) * dT(i) * pow_2(dens)) / (Tm * pow_2(visc)); + Gr(i) = (Constant::Gravity * pow_3(gap(i)) * dT(i) * pow_2(dens)) / (Tm * pow_2(visc)); Ra(i) = Gr(i) * pr; Nu(i) = A * std::pow(Ra(i), n); if (Nu(i) < 1.0) { @@ -481,7 +481,7 @@ namespace ThermalEN673Calc { standard, nperr, ErrorMessage); - Gr(i) = (Constant::GravityConstant * pow_3(gap(i)) * dT(i) * pow_2(dens)) / (Tm * pow_2(visc)); + Gr(i) = (Constant::Gravity * pow_3(gap(i)) * dT(i) * pow_2(dens)) / (Tm * pow_2(visc)); Ra(i) = Gr(i) * pr; Nu(i) = A * std::pow(Ra(i), n); if (Nu(i) < 1.0) { diff --git a/src/EnergyPlus/ThermalISO15099Calc.cc b/src/EnergyPlus/ThermalISO15099Calc.cc index 2318fc0eaee..58c08a29439 100644 --- a/src/EnergyPlus/ThermalISO15099Calc.cc +++ b/src/EnergyPlus/ThermalISO15099Calc.cc @@ -2565,7 +2565,7 @@ void filmi(EnergyPlusData &state, // Calculate grashoff number: // The grashoff number is the Rayleigh Number (equation 5.29) in SPC142 divided by the Prandtl Number (prand): - gr = Constant::GravityConstant * pow_3(height) * delt * pow_2(dens) / (tmean * pow_2(visc)); + gr = Constant::Gravity * pow_3(height) * delt * pow_2(dens) / (tmean * pow_2(visc)); RaL = gr * pr; // write(*,*)' RaCrit,RaL,gr,pr ' @@ -2720,7 +2720,7 @@ void filmg(EnergyPlusData &state, // Calculate grashoff number: // The grashoff number is the Rayleigh Number (equation 5.29) in SPC142 divided by the Prandtl Number (prand): - ra = Constant::GravityConstant * pow_3(gap(i)) * delt * cp * pow_2(dens) / (tmean * visc * con); + ra = Constant::Gravity * pow_3(gap(i)) * delt * cp * pow_2(dens) / (tmean * visc * con); Rayleigh(i) = ra; // write(*,*) 'height,gap(i),asp',height,gap(i),asp // asp = 1 diff --git a/src/EnergyPlus/ThermalISO15099Calc.hh b/src/EnergyPlus/ThermalISO15099Calc.hh index 97acd49a3c0..8fdd764b73f 100644 --- a/src/EnergyPlus/ThermalISO15099Calc.hh +++ b/src/EnergyPlus/ThermalISO15099Calc.hh @@ -544,6 +544,10 @@ struct ThermalISO15099CalcData : BaseGlobalStruct int kFP = 0; std::string dynFormat; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/TranspiredCollector.cc b/src/EnergyPlus/TranspiredCollector.cc index aacbbd87e55..f5bd79487fe 100644 --- a/src/EnergyPlus/TranspiredCollector.cc +++ b/src/EnergyPlus/TranspiredCollector.cc @@ -141,8 +141,6 @@ namespace TranspiredCollector { // Using/Aliasing using HVAC::TempControlTol; - using ScheduleManager::GetCurrentScheduleValue; - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int UTSCNum(0); // local number index for UTSC @@ -188,7 +186,7 @@ namespace TranspiredCollector { auto &InletNode = UTSC_CI.InletNode; auto &ControlNode = UTSC_CI.ControlNode; UTSC_CI.IsOn = false; - if ((GetCurrentScheduleValue(state, UTSC_CI.SchedPtr) > 0.0) && + if ((UTSC_CI.availSched->getCurrentVal() > 0.0) && (UTSC_CI.InletMDot > 0.0)) { // availability Schedule | OA system is setting mass flow bool ControlLTSet(false); bool ControlLTSchedule(false); @@ -198,10 +196,9 @@ namespace TranspiredCollector { for (int i = InletNode.l(), e = InletNode.u(); i <= e; ++i) { if (state.dataLoopNodes->Node(InletNode(i)).Temp + TempControlTol < state.dataLoopNodes->Node(ControlNode(i)).TempSetPoint) ControlLTSet = true; - if (state.dataLoopNodes->Node(InletNode(i)).Temp + TempControlTol < GetCurrentScheduleValue(state, UTSC_CI.FreeHeatSetPointSchedPtr)) + if (state.dataLoopNodes->Node(InletNode(i)).Temp + TempControlTol < UTSC_CI.freeHeatSetPointSched->getCurrentVal()) ControlLTSchedule = true; - if (state.dataLoopNodes->Node(UTSC_CI.ZoneNode(i)).Temp + TempControlTol < - GetCurrentScheduleValue(state, UTSC_CI.FreeHeatSetPointSchedPtr)) + if (state.dataLoopNodes->Node(UTSC_CI.ZoneNode(i)).Temp + TempControlTol < UTSC_CI.freeHeatSetPointSched->getCurrentVal()) ZoneLTSchedule = true; } if (ControlLTSet || (ControlLTSchedule && ZoneLTSchedule)) @@ -233,13 +230,14 @@ namespace TranspiredCollector { // usual EnergyPlus input // Extensible UTSC object for underlying heat transfer surfaces and for multisystem + static constexpr std::string_view routineName = "GetTranspiredCollectorInput"; + // Using/Aliasing using BranchNodeConnections::TestCompSet; using DataLoopNode::ObjectIsNotParent; using DataSurfaces::OtherSideCondModeledExt; using DataSurfaces::SurfaceData; using NodeInputManager::GetOnlySingleNode; - using ScheduleManager::GetScheduleIndex; // SUBROUTINE LOCAL VARIABLE DECLARATIONS: @@ -315,6 +313,8 @@ namespace TranspiredCollector { state.dataIPShortCut->cAlphaFieldNames, state.dataIPShortCut->cNumericFieldNames); + ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)}; + // first handle alphas state.dataTranspiredCollector->UTSC(Item).Name = Alphas(1); @@ -423,19 +423,11 @@ namespace TranspiredCollector { } state.dataTranspiredCollector->UTSC(Item).OSCMPtr = Found; if (state.dataIPShortCut->lAlphaFieldBlanks(3)) { - state.dataTranspiredCollector->UTSC(Item).SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - state.dataTranspiredCollector->UTSC(Item).SchedPtr = GetScheduleIndex(state, Alphas(3)); - if (state.dataTranspiredCollector->UTSC(Item).SchedPtr == 0) { - ShowSevereError(state, - format("{}not found={} in {} ={}", - state.dataIPShortCut->cAlphaFieldNames(3), - Alphas(3), - CurrentModuleObject, - state.dataTranspiredCollector->UTSC(Item).Name)); - ErrorsFound = true; - continue; - } + state.dataTranspiredCollector->UTSC(Item).availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((state.dataTranspiredCollector->UTSC(Item).availSched = Sched::GetSchedule(state, Alphas(3))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(3), Alphas(3)); + ErrorsFound = true; + continue; } // now if UTSC(Item)%NumOASysAttached still not set, assume no multisystem @@ -494,14 +486,11 @@ namespace TranspiredCollector { ObjectIsNotParent); } // no splitter - state.dataTranspiredCollector->UTSC(Item).FreeHeatSetPointSchedPtr = GetScheduleIndex(state, Alphas(8)); - if (state.dataTranspiredCollector->UTSC(Item).FreeHeatSetPointSchedPtr == 0) { - ShowSevereError(state, - format("{} not found={} in {} ={}", - state.dataIPShortCut->cAlphaFieldNames(8), - Alphas(8), - CurrentModuleObject, - state.dataTranspiredCollector->UTSC(Item).Name)); + if (state.dataIPShortCut->lAlphaFieldBlanks(8)) { + ShowSevereEmptyField(state, eoh, state.dataIPShortCut->cAlphaFieldNames(8)); + ErrorsFound = true; + } else if ((state.dataTranspiredCollector->UTSC(Item).freeHeatSetPointSched = Sched::GetSchedule(state, Alphas(8))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(8), Alphas(8)); ErrorsFound = true; continue; } @@ -740,7 +729,7 @@ namespace TranspiredCollector { default: break; } - TiltRads = std::abs(AvgTilt) * Constant::DegToRadians; + TiltRads = std::abs(AvgTilt) * Constant::DegToRad; tempHdeltaNPL = std::sin(TiltRads) * state.dataTranspiredCollector->UTSC(Item).Height / 4.0; state.dataTranspiredCollector->UTSC(Item).HdeltaNPL = max(tempHdeltaNPL, state.dataTranspiredCollector->UTSC(Item).PlenGapThick); @@ -1439,7 +1428,7 @@ namespace TranspiredCollector { state.dataTranspiredCollector->UTSC(UTSCNum).PassiveACH = (MdotVent / RhoAir) * (1.0 / (state.dataTranspiredCollector->UTSC(UTSCNum).ProjArea * state.dataTranspiredCollector->UTSC(UTSCNum).PlenGapThick)) * - Constant::SecInHour; + Constant::rSecsInHour; state.dataTranspiredCollector->UTSC(UTSCNum).PassiveMdotVent = MdotVent; state.dataTranspiredCollector->UTSC(UTSCNum).PassiveMdotWind = VdotWind * RhoAir; state.dataTranspiredCollector->UTSC(UTSCNum).PassiveMdotTherm = VdotThermal * RhoAir; @@ -1945,7 +1934,7 @@ namespace TranspiredCollector { // SUBROUTINE LOCAL VARIABLE DECLARATIONS Real64 gnu901; // Nusselt number temporary variables for - Real64 tiltr = Tilt * Constant::DegToRadians; + Real64 tiltr = Tilt * Constant::DegToRad; Real64 Ra = Gr * Pr; // Rayleigh number if (Ra <= 1.0e4) { diff --git a/src/EnergyPlus/TranspiredCollector.hh b/src/EnergyPlus/TranspiredCollector.hh index 7bb83539fe8..36a9c2e3cdf 100644 --- a/src/EnergyPlus/TranspiredCollector.hh +++ b/src/EnergyPlus/TranspiredCollector.hh @@ -74,7 +74,7 @@ namespace TranspiredCollector { std::string Name; std::string OSCMName; // OtherSideConditionsModel int OSCMPtr; // OtherSideConditionsModel index - int SchedPtr; // Availablity schedule + Sched::Schedule *availSched = nullptr; // Availablity schedule Array1D_int InletNode; // Air system node "pointer", should be set to outdoor air Array1D_int OutletNode; // Air system node "pointer", outlet from UTSC Array1D_int ControlNode; // Air system node "pointer", should have mixed air setpoint @@ -96,7 +96,7 @@ namespace TranspiredCollector { Real64 Cv; // volume-based effectiveness of openings for wind-driven vent when Passive Real64 Cd; // discharge coefficient of openings for buoyancy-driven vent when Passive int NumOASysAttached; // =1 if no splitter, other wise set by Splitter object - int FreeHeatSetPointSchedPtr; // used for controlling seperately from usual setpoint managers. + Sched::Schedule *freeHeatSetPointSched = nullptr; // used for controlling seperately from usual setpoint managers. int VsucErrIndex; // data from elswhere and calculated Real64 ActualArea; // Overall Area of Collect with surface corrugations. @@ -140,9 +140,9 @@ namespace TranspiredCollector { // Default Constructor UTSCDataStruct() - : OSCMPtr(0), SchedPtr(0), Layout(0), Correlation(0), HoleDia(0.0), Pitch(0.0), LWEmitt(0.0), SolAbsorp(0.0), + : OSCMPtr(0), Layout(0), Correlation(0), HoleDia(0.0), Pitch(0.0), LWEmitt(0.0), SolAbsorp(0.0), CollRoughness(Material::SurfaceRoughness::VeryRough), PlenGapThick(0.0), PlenCrossArea(0.0), NumSurfs(0), Height(0.0), AreaRatio(0.0), - CollectThick(0.0), Cv(0.0), Cd(0.0), NumOASysAttached(0), FreeHeatSetPointSchedPtr(0), VsucErrIndex(0), ActualArea(0.0), ProjArea(0.0), + CollectThick(0.0), Cv(0.0), Cd(0.0), NumOASysAttached(0), VsucErrIndex(0), ActualArea(0.0), ProjArea(0.0), Centroid(0.0, 0.0, 0.0), Porosity(0.0), IsOn(false), Tplen(0.0), Tcoll(0.0), TplenLast(22.5), TcollLast(22.0), HrPlen(0.0), HcPlen(0.0), MdotVent(0.0), HdeltaNPL(0.0), TairHX(0.0), InletMDot(0.0), InletTempDB(0.0), Tilt(0.0), Azimuth(0.0), QdotSource(0.0), Isc(0.0), HXeff(0.0), Vsuction(0.0), PassiveACH(0.0), PassiveMdotVent(0.0), PassiveMdotWind(0.0), PassiveMdotTherm(0.0), PlenumVelocity(0.0), @@ -225,6 +225,10 @@ struct TranspiredCollectorData : BaseGlobalStruct Array1D_bool MyEnvrnFlag; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/UFADManager.cc b/src/EnergyPlus/UFADManager.cc index 6c5109731a2..57a199e82d6 100644 --- a/src/EnergyPlus/UFADManager.cc +++ b/src/EnergyPlus/UFADManager.cc @@ -800,7 +800,7 @@ namespace RoomAir { Real64 HeightComfort = zoneU.ComfortHeight; // height at which comfort temperature is calculated Real64 TempDiffCritRep = zoneU.TempTrigger; // Minimum temperature difference between upper and occupied subzones for reporting Real64 DiffArea = zoneU.DiffArea; // diffuser effective area [m2] - Real64 ThrowAngle = Constant::DegToRadians * zoneU.DiffAngle; // diffuser slot angle relative to vertical [radians] + Real64 ThrowAngle = Constant::DegToRad * zoneU.DiffAngle; // diffuser slot angle relative to vertical [radians] Real64 SourceHeight = 0.0; // height of plume sources above the floor [m] Real64 NumDiffusers = zoneU.DiffusersPerZone; Real64 PowerPerPlume = zoneU.PowerPerPlume; @@ -1226,7 +1226,7 @@ namespace RoomAir { Real64 HeightComfort = zoneU.ComfortHeight; // height at which comfort temperature is calculated Real64 TempDiffCritRep = zoneU.TempTrigger; // Minimum temperature difference between upper and occupied subzones for reporting Real64 DiffArea = zoneU.DiffArea; // diffuser effective area [m2] - Real64 ThrowAngle = Constant::DegToRadians * zoneU.DiffAngle; // diffuser slot angle relative to vertical [radians] + Real64 ThrowAngle = Constant::DegToRad * zoneU.DiffAngle; // diffuser slot angle relative to vertical [radians] Real64 SourceHeight = zoneU.HeatSrcHeight; // height of plume sources above the floor [m] Real64 NumDiffusers = zoneU.DiffusersPerZone; Real64 PowerPerPlume = zoneU.PowerPerPlume; diff --git a/src/EnergyPlus/UFADManager.hh b/src/EnergyPlus/UFADManager.hh index 5e8c57b4a31..50934876027 100644 --- a/src/EnergyPlus/UFADManager.hh +++ b/src/EnergyPlus/UFADManager.hh @@ -109,6 +109,10 @@ struct UFADManagerData : BaseGlobalStruct bool MyOneTimeFlag = true; Array1D_bool MySizeFlag; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/UnitHeater.cc b/src/EnergyPlus/UnitHeater.cc index 8acacf9750e..3b5c9c9ef87 100644 --- a/src/EnergyPlus/UnitHeater.cc +++ b/src/EnergyPlus/UnitHeater.cc @@ -116,7 +116,6 @@ namespace UnitHeater { using HVAC::SmallAirVolFlow; using HVAC::SmallLoad; using HVAC::SmallMassFlow; - using namespace ScheduleManager; using Psychrometrics::PsyCpAirFnW; using Psychrometrics::PsyHFnTdbW; using Psychrometrics::PsyRhoAirFnPbTdbW; @@ -292,22 +291,12 @@ namespace UnitHeater { Util::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound); state.dataUnitHeaters->UnitHeat(UnitHeatNum).Name = Alphas(1); - state.dataUnitHeaters->UnitHeat(UnitHeatNum).SchedName = Alphas(2); + if (lAlphaBlanks(2)) { - state.dataUnitHeaters->UnitHeat(UnitHeatNum).SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - state.dataUnitHeaters->UnitHeat(UnitHeatNum).SchedPtr = GetScheduleIndex(state, Alphas(2)); // convert schedule name to pointer - if (state.dataUnitHeaters->UnitHeat(UnitHeatNum).SchedPtr == 0) { - ShowSevereError(state, - format("{}{}: invalid {} entered ={} for {}={}", - RoutineName, - CurrentModuleObject, - cAlphaFields(2), - Alphas(2), - cAlphaFields(1), - Alphas(1))); - ErrorsFound = true; - } + state.dataUnitHeaters->UnitHeat(UnitHeatNum).availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((state.dataUnitHeaters->UnitHeat(UnitHeatNum).availSched = Sched::GetSchedule(state, Alphas(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(2), Alphas(2)); + ErrorsFound = true; } // Main air nodes (except outside air node): @@ -373,7 +362,7 @@ namespace UnitHeater { ShowContinueError(state, "...the unit heater flow rate is autosized while the fan flow rate is not."); ShowContinueError(state, "...this can lead to unexpected results where the fan flow rate is less than required."); } - unitHeat.FanAvailSchedPtr = fan->availSchedNum; + unitHeat.fanAvailSched = fan->availSched; } // Heating coil information: @@ -398,6 +387,7 @@ namespace UnitHeater { } } } + if (!errFlag) { state.dataUnitHeaters->UnitHeat(UnitHeatNum).HCoilTypeCh = Alphas(7); state.dataUnitHeaters->UnitHeat(UnitHeatNum).HCoilName = Alphas(8); @@ -436,36 +426,20 @@ namespace UnitHeater { } } - state.dataUnitHeaters->UnitHeat(UnitHeatNum).FanSchedPtr = GetScheduleIndex(state, Alphas(9)); - // Default to cycling fan when fan operating mode schedule is not present - if (!lAlphaBlanks(9) && state.dataUnitHeaters->UnitHeat(UnitHeatNum).FanSchedPtr == 0) { - ShowSevereError(state, - format("{} \"{}\" {} not found: {}", - CurrentModuleObject, - state.dataUnitHeaters->UnitHeat(UnitHeatNum).Name, - cAlphaFields(9), - Alphas(9))); - ErrorsFound = true; - } else if (lAlphaBlanks(9)) { + if (lAlphaBlanks(9)) { if (state.dataUnitHeaters->UnitHeat(UnitHeatNum).fanType == HVAC::FanType::OnOff || state.dataUnitHeaters->UnitHeat(UnitHeatNum).fanType == HVAC::FanType::SystemModel) { state.dataUnitHeaters->UnitHeat(UnitHeatNum).fanOp = HVAC::FanOp::Cycling; } else { state.dataUnitHeaters->UnitHeat(UnitHeatNum).fanOp = HVAC::FanOp::Continuous; } - } - - // Check fan's schedule for cycling fan operation if constant volume fan is used - if (state.dataUnitHeaters->UnitHeat(UnitHeatNum).FanSchedPtr > 0 && - state.dataUnitHeaters->UnitHeat(UnitHeatNum).fanType == HVAC::FanType::Constant) { - if (!CheckScheduleValueMinMax(state, state.dataUnitHeaters->UnitHeat(UnitHeatNum).FanSchedPtr, ">", 0.0, "<=", 1.0)) { - ShowSevereError(state, format("{} = {}", CurrentModuleObject, Alphas(1))); - ShowContinueError(state, format("For {} = {}", cAlphaFields(5), Alphas(5))); - ShowContinueError(state, "Fan operating mode must be continuous (fan operating mode schedule values > 0)."); - ShowContinueError(state, format("Error found in {} = {}", cAlphaFields(9), Alphas(9))); - ShowContinueError(state, "...schedule values must be (>0., <=1.)"); - ErrorsFound = true; - } + } else if ((state.dataUnitHeaters->UnitHeat(UnitHeatNum).fanOpModeSched = Sched::GetSchedule(state, Alphas(9))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(9), Alphas(9)); + ErrorsFound = true; + } else if (state.dataUnitHeaters->UnitHeat(UnitHeatNum).fanType == HVAC::FanType::Constant && + !state.dataUnitHeaters->UnitHeat(UnitHeatNum).fanOpModeSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) { + Sched::ShowSevereBadMinMax(state, eoh, cAlphaFields(9), Alphas(9), Clusive::In, 0.0, Clusive::In, 1.0); + ErrorsFound = true; } state.dataUnitHeaters->UnitHeat(UnitHeatNum).FanOperatesDuringNoHeating = Alphas(10); @@ -807,25 +781,26 @@ namespace UnitHeater { OutNode = state.dataUnitHeaters->UnitHeat(UnitHeatNum).AirOutNode; state.dataUnitHeaters->QZnReq = state.dataZoneEnergyDemand->ZoneSysEnergyDemand(ZoneNum).RemainingOutputReqToHeatSP; // zone load needed - if (state.dataUnitHeaters->UnitHeat(UnitHeatNum).FanSchedPtr > 0) { - if (GetCurrentScheduleValue(state, state.dataUnitHeaters->UnitHeat(UnitHeatNum).FanSchedPtr) == 0.0 && + if (state.dataUnitHeaters->UnitHeat(UnitHeatNum).fanOpModeSched != nullptr) { + if (state.dataUnitHeaters->UnitHeat(UnitHeatNum).fanOpModeSched->getCurrentVal() == 0.0 && state.dataUnitHeaters->UnitHeat(UnitHeatNum).fanType == HVAC::FanType::OnOff) { state.dataUnitHeaters->UnitHeat(UnitHeatNum).fanOp = HVAC::FanOp::Cycling; } else { state.dataUnitHeaters->UnitHeat(UnitHeatNum).fanOp = HVAC::FanOp::Continuous; } + if ((state.dataUnitHeaters->QZnReq < SmallLoad) || state.dataZoneEnergyDemand->CurDeadBandOrSetback(ZoneNum)) { // Unit is available, but there is no load on it or we are in setback/deadband if (!state.dataUnitHeaters->UnitHeat(UnitHeatNum).FanOffNoHeating && - GetCurrentScheduleValue(state, state.dataUnitHeaters->UnitHeat(UnitHeatNum).FanSchedPtr) > 0.0) { + state.dataUnitHeaters->UnitHeat(UnitHeatNum).fanOpModeSched->getCurrentVal() > 0.0) { state.dataUnitHeaters->UnitHeat(UnitHeatNum).fanOp = HVAC::FanOp::Continuous; } } } state.dataUnitHeaters->SetMassFlowRateToZero = false; - if (GetCurrentScheduleValue(state, state.dataUnitHeaters->UnitHeat(UnitHeatNum).SchedPtr) > 0) { - if ((GetCurrentScheduleValue(state, state.dataUnitHeaters->UnitHeat(UnitHeatNum).FanAvailSchedPtr) > 0 || + if (state.dataUnitHeaters->UnitHeat(UnitHeatNum).availSched->getCurrentVal() > 0) { + if ((state.dataUnitHeaters->UnitHeat(UnitHeatNum).fanAvailSched->getCurrentVal() > 0 || state.dataHVACGlobal->TurnFansOn) && !state.dataHVACGlobal->TurnFansOff) { if (state.dataUnitHeaters->UnitHeat(UnitHeatNum).FanOffNoHeating && @@ -1428,8 +1403,8 @@ namespace UnitHeater { if (fanOp != HVAC::FanOp::Cycling) { - if (GetCurrentScheduleValue(state, state.dataUnitHeaters->UnitHeat(UnitHeatNum).SchedPtr) <= 0 || - ((GetCurrentScheduleValue(state, state.dataUnitHeaters->UnitHeat(UnitHeatNum).FanAvailSchedPtr) <= 0 && + if (state.dataUnitHeaters->UnitHeat(UnitHeatNum).availSched->getCurrentVal() <= 0 || + ((state.dataUnitHeaters->UnitHeat(UnitHeatNum).fanAvailSched->getCurrentVal() <= 0 && !state.dataHVACGlobal->TurnFansOn) || state.dataHVACGlobal->TurnFansOff)) { // Case 1: OFF-->unit schedule says that it it not available @@ -1571,8 +1546,8 @@ namespace UnitHeater { } } else { // OnOff fan and cycling if ((state.dataUnitHeaters->QZnReq < SmallLoad) || (state.dataZoneEnergyDemand->CurDeadBandOrSetback(ZoneNum)) || - GetCurrentScheduleValue(state, state.dataUnitHeaters->UnitHeat(UnitHeatNum).SchedPtr) <= 0 || - ((GetCurrentScheduleValue(state, state.dataUnitHeaters->UnitHeat(UnitHeatNum).FanAvailSchedPtr) <= 0 && + state.dataUnitHeaters->UnitHeat(UnitHeatNum).availSched->getCurrentVal() <= 0 || + ((state.dataUnitHeaters->UnitHeat(UnitHeatNum).fanAvailSched->getCurrentVal() <= 0 && !state.dataHVACGlobal->TurnFansOn) || state.dataHVACGlobal->TurnFansOff)) { // Case 1: OFF-->unit schedule says that it it not available diff --git a/src/EnergyPlus/UnitHeater.hh b/src/EnergyPlus/UnitHeater.hh index d0a95f1011e..1a00bed2d63 100644 --- a/src/EnergyPlus/UnitHeater.hh +++ b/src/EnergyPlus/UnitHeater.hh @@ -86,15 +86,14 @@ namespace UnitHeater { // Members // Input data std::string Name; // name of unit - std::string SchedName; // availability schedule - int SchedPtr; // index to schedule + Sched::Schedule *availSched = nullptr;// availability schedule int AirInNode; // inlet air node number int AirOutNode; // outlet air node number HVAC::FanType fanType; // Fan type number (see DataHVACGlobals) std::string FanName; // name of fan int Fan_Index; - int FanSchedPtr; // index to fan operating mode schedule - int FanAvailSchedPtr; // index to fan availability schedule + Sched::Schedule *fanOpModeSched = nullptr; // fan operating mode schedule + Sched::Schedule *fanAvailSched = nullptr; // fan availability schedule int ControlCompTypeNum; int CompErrIndex; Real64 MaxAirVolFlow; // m3/s @@ -137,7 +136,7 @@ namespace UnitHeater { // Default Constructor UnitHeaterData() - : SchedPtr(0), AirInNode(0), AirOutNode(0), fanType(HVAC::FanType::Invalid), Fan_Index(0), FanSchedPtr(0), FanAvailSchedPtr(0), + : AirInNode(0), AirOutNode(0), fanType(HVAC::FanType::Invalid), Fan_Index(0), ControlCompTypeNum(0), CompErrIndex(0), MaxAirVolFlow(0.0), MaxAirMassFlow(0.0), FanOutletNode(0), HCoil_Index(0), HeatingCoilType(DataPlant::PlantEquipmentType::Invalid), HCoil_FluidIndex(0), MaxVolHotWaterFlow(0.0), MaxVolHotSteamFlow(0.0), MaxHotWaterFlow(0.0), MaxHotSteamFlow(0.0), MinVolHotWaterFlow(0.0), MinVolHotSteamFlow(0.0), MinHotWaterFlow(0.0), @@ -234,6 +233,10 @@ struct UnitHeatersData : BaseGlobalStruct int RefrigIndex = 0; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/UnitVentilator.cc b/src/EnergyPlus/UnitVentilator.cc index 3d9352d8a1a..691706269e9 100644 --- a/src/EnergyPlus/UnitVentilator.cc +++ b/src/EnergyPlus/UnitVentilator.cc @@ -280,14 +280,10 @@ namespace UnitVentilator { unitVent.Name = Alphas(1); if (lAlphaBlanks(2)) { - unitVent.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - unitVent.SchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(2)); // convert schedule name to pointer - if (unitVent.SchedPtr == 0) { - ShowSevereError(state, format("{}{}=\"{}\".", RoutineName, CurrentModuleObject, Alphas(1))); - ShowContinueError(state, format("not found: {}=\"{}\".", cAlphaFields(2), Alphas(2))); - ErrorsFound = true; - } + unitVent.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((unitVent.availSched = Sched::GetSchedule(state, Alphas(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(2), Alphas(2)); + ErrorsFound = true; } unitVent.MaxAirVolFlow = Numbers(1); @@ -295,10 +291,11 @@ namespace UnitVentilator { // Outside air information: unitVent.MinOutAirVolFlow = Numbers(2); - unitVent.MinOASchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(4)); // convert schedule name to pointer - if (unitVent.MinOASchedPtr == 0) { - ShowSevereError(state, format("{}{}=\"{}\".", RoutineName, CurrentModuleObject, unitVent.Name)); - ShowContinueError(state, format("not found: {}=\"{}\".", cAlphaFields(4), Alphas(4))); + if (lAlphaBlanks(4)) { + ShowSevereEmptyField(state, eoh, cAlphaFields(4)); + ErrorsFound = true; + } else if ((unitVent.minOASched = Sched::GetSchedule(state, Alphas(4))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(4), Alphas(4)); ErrorsFound = true; } @@ -306,35 +303,36 @@ namespace UnitVentilator { cCoolingCoilType = ""; cHeatingCoilType = ""; - { - unitVent.OAControlType = (OAControl)getEnumValue(OAControlNamesUC, Alphas(3)); - switch (unitVent.OAControlType) { - case OAControl::VariablePercent: - case OAControl::FixedAmount: { - unitVent.MaxOASchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(5)); // convert schedule name to pointer - if (unitVent.MaxOASchedPtr == 0) { - ShowSevereError(state, format("{}{}=\"{}\".", RoutineName, CurrentModuleObject, unitVent.Name)); - ShowContinueError(state, format("not found: {}=\"{}\".", cAlphaFields(5), Alphas(5))); - ErrorsFound = true; - } else if (!ScheduleManager::CheckScheduleValueMinMax(state, unitVent.MaxOASchedPtr, ">=", 0.0, "<=", 1.0)) { - ShowSevereError(state, format("{}{}=\"{}\".", RoutineName, CurrentModuleObject, unitVent.Name)); - ShowContinueError(state, format("out of range [0,1]: {}=\"{}\".", cAlphaFields(5), Alphas(5))); - ErrorsFound = true; - } - } break; - case OAControl::FixedTemperature: { - unitVent.TempSchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(5)); // convert schedule name to pointer - if (unitVent.TempSchedPtr == 0) { - ShowSevereError(state, format("{}{}=\"{}\".", RoutineName, CurrentModuleObject, unitVent.Name)); - ShowContinueError(state, format("not found: {}=\"{}\".", cAlphaFields(5), Alphas(5))); - ErrorsFound = true; - } - } break; - default: { - assert(false); - } break; + unitVent.OAControlType = static_cast(getEnumValue(OAControlNamesUC, Alphas(3))); + switch (unitVent.OAControlType) { + case OAControl::VariablePercent: + case OAControl::FixedAmount: { + if (lAlphaBlanks(5)) { + ShowSevereEmptyField(state, eoh, cAlphaFields(5)); + ErrorsFound = true; + } else if ((unitVent.maxOASched = Sched::GetSchedule(state, Alphas(5))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(5), Alphas(5)); + ErrorsFound = true; + } else if (!unitVent.maxOASched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) { + Sched::ShowSevereBadMinMax(state, eoh, cAlphaFields(5), Alphas(5), Clusive::In, 0.0, Clusive::In, 1.0); + ErrorsFound = true; } - } + } break; + + case OAControl::FixedTemperature: { + if (lAlphaBlanks(5)) { + ShowSevereEmptyField(state, eoh, cAlphaFields(5)); + ErrorsFound = true; + } else if ((unitVent.tempSched = Sched::GetSchedule(state, Alphas(5))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(5), Alphas(5)); + ErrorsFound = true; + } + } break; + + default: { + assert(false); + } break; + } // end (switch) // Main air nodes (except outside air node): // For node connections, this object is both a parent and a non-parent, because the @@ -411,7 +409,7 @@ namespace UnitVentilator { } else { auto *fan = state.dataFans->fans(unitVent.Fan_Index); unitVent.FanOutletNode = fan->outletNodeNum; - unitVent.FanAvailSchedPtr = fan->availSchedNum; // Get the fan's availability schedule + unitVent.fanAvailSched = fan->availSched; // Get the fan's availability schedule FanVolFlow = fan->maxAirFlowRate; if (FanVolFlow != DataSizing::AutoSize && unitVent.MaxAirVolFlow != DataSizing::AutoSize && FanVolFlow < unitVent.MaxAirVolFlow) { ShowSevereError(state, format("{}{}=\"{}\".", RoutineName, CurrentModuleObject, unitVent.Name)); @@ -497,7 +495,7 @@ namespace UnitVentilator { if (unitVent.OAControlType == OAControl::FixedAmount) { unitVent.OutAirVolFlow = unitVent.MinOutAirVolFlow; - unitVent.MaxOASchedPtr = unitVent.MinOASchedPtr; + unitVent.maxOASched = unitVent.minOASched; } if (!unitVent.ATMixerExists) { @@ -548,29 +546,16 @@ namespace UnitVentilator { unitVent.CoilOption = (CoilsUsed)getEnumValue(CoilsUsedNamesUC, Alphas(13)); - unitVent.FanSchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(14)); - // Default to cycling fan when fan mode schedule is not present - if (!lAlphaBlanks(14) && unitVent.FanSchedPtr == 0) { - ShowSevereError(state, format("{} \"{}\" {} not found: {}", CurrentModuleObject, unitVent.Name, cAlphaFields(14), Alphas(14))); + if (lAlphaBlanks(14)) { + unitVent.fanOp = (unitVent.fanType == HVAC::FanType::OnOff || unitVent.fanType == HVAC::FanType::SystemModel) ? + HVAC::FanOp::Cycling : HVAC::FanOp::Continuous; + } else if ((unitVent.fanOpModeSched = Sched::GetSchedule(state, Alphas(14))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(14), Alphas(14)); + ErrorsFound = true; + } else if ((unitVent.fanType == HVAC::FanType::Constant) && + !unitVent.fanOpModeSched->checkMinMaxVals(state, Clusive::Ex, 0.0, Clusive::In, 1.0)) { + Sched::ShowSevereBadMinMax(state, eoh, cAlphaFields(14), Alphas(14), Clusive::Ex, 0.0, Clusive::In, 1.0); ErrorsFound = true; - } else if (lAlphaBlanks(14)) { - if (unitVent.fanType == HVAC::FanType::OnOff || unitVent.fanType == HVAC::FanType::SystemModel) { - unitVent.fanOp = HVAC::FanOp::Cycling; - } else { - unitVent.fanOp = HVAC::FanOp::Continuous; - } - } - - // Check fan's schedule for cycling fan operation if constant volume fan is used - if (unitVent.FanSchedPtr > 0 && unitVent.fanType == HVAC::FanType::Constant) { - if (!ScheduleManager::CheckScheduleValueMinMax(state, unitVent.FanSchedPtr, ">", 0.0, "<=", 1.0)) { - ShowSevereError(state, format("{} = {}", CurrentModuleObject, Alphas(1))); - ShowContinueError(state, format("For {} = {}", cAlphaFields(11), Alphas(11))); - ShowContinueError(state, "Fan operating mode must be continuous (fan operating mode schedule values > 0)."); - ShowContinueError(state, format("Error found in {} = {}", cAlphaFields(14), Alphas(14))); - ShowContinueError(state, "...schedule values must be (>0., <=1.)"); - ErrorsFound = true; - } } // Get Coil information @@ -1173,16 +1158,12 @@ namespace UnitVentilator { state.dataUnitVentilators->QZnReq = state.dataZoneEnergyDemand->ZoneSysEnergyDemand(ZoneNum).RemainingOutputRequired; // zone load needed unitVent.FanPartLoadRatio = 0.0; - if (unitVent.FanSchedPtr > 0) { - if (ScheduleManager::GetCurrentScheduleValue(state, unitVent.FanSchedPtr) == 0.0) { - unitVent.fanOp = HVAC::FanOp::Cycling; - } else { - unitVent.fanOp = HVAC::FanOp::Continuous; - } + if (unitVent.fanOpModeSched != nullptr) { + unitVent.fanOp = (unitVent.fanOpModeSched->getCurrentVal() == 0.0) ? HVAC::FanOp::Cycling : HVAC::FanOp::Continuous; } - if (ScheduleManager::GetCurrentScheduleValue(state, unitVent.SchedPtr) > 0) { - if ((ScheduleManager::GetCurrentScheduleValue(state, unitVent.FanAvailSchedPtr) > 0 || state.dataHVACGlobal->TurnFansOn) && + if (unitVent.availSched->getCurrentVal() > 0) { + if ((unitVent.fanAvailSched->getCurrentVal() > 0 || state.dataHVACGlobal->TurnFansOn) && !state.dataHVACGlobal->TurnFansOff) { if ((std::abs(state.dataZoneEnergyDemand->ZoneSysEnergyDemand(ZoneNum).RemainingOutputRequired) < HVAC::SmallLoad) || (state.dataZoneEnergyDemand->CurDeadBandOrSetback(ZoneNum))) { @@ -2395,8 +2376,8 @@ namespace UnitVentilator { auto &outsideAirNode(state.dataLoopNodes->Node(unitVent.OutsideAirNode)); if ((std::abs(state.dataUnitVentilators->QZnReq) < HVAC::SmallLoad) || (state.dataZoneEnergyDemand->CurDeadBandOrSetback(ZoneNum)) || - (ScheduleManager::GetCurrentScheduleValue(state, unitVent.SchedPtr) <= 0) || - ((ScheduleManager::GetCurrentScheduleValue(state, unitVent.FanAvailSchedPtr) <= 0 && !state.dataHVACGlobal->TurnFansOn) || + (unitVent.availSched->getCurrentVal() <= 0) || + ((unitVent.fanAvailSched->getCurrentVal() <= 0 && !state.dataHVACGlobal->TurnFansOn) || state.dataHVACGlobal->TurnFansOff)) { // Unit is off or has no load upon it; set the flow rates to zero and then @@ -2439,8 +2420,7 @@ namespace UnitVentilator { state.dataUnitVentilators->HCoilOn = true; if (outsideAirNode.MassFlowRate > 0.0) { - MinOAFrac = ScheduleManager::GetCurrentScheduleValue(state, unitVent.MinOASchedPtr) * - (unitVent.MinOutAirMassFlow / outsideAirNode.MassFlowRate); + MinOAFrac = unitVent.minOASched->getCurrentVal() * (unitVent.MinOutAirMassFlow / outsideAirNode.MassFlowRate); } else { MinOAFrac = 0.0; } @@ -2475,10 +2455,11 @@ namespace UnitVentilator { } else { // Tinlet < Toutdoor - MaxOAFrac = ScheduleManager::GetCurrentScheduleValue(state, unitVent.MaxOASchedPtr); + MaxOAFrac = unitVent.maxOASched->getCurrentVal(); state.dataUnitVentilators->OAMassFlowRate = MaxOAFrac * outsideAirNode.MassFlowRate; } } break; + case OAControl::FixedTemperature: { // In heating mode, the outside air for "fixed temperature" attempts // to control the outside air fraction so that a desired temperature @@ -2487,7 +2468,7 @@ namespace UnitVentilator { // temperature), then this is possible. If not, the control will try // to maximize the amount of air coming from the source that is closer // in temperature to the desired temperature. - Tdesired = ScheduleManager::GetCurrentScheduleValue(state, unitVent.TempSchedPtr); + Tdesired = unitVent.tempSched->getCurrentVal(); Tinlet = inletNode.Temp; Toutdoor = outsideAirNode.Temp; MaxOAFrac = 1.0; @@ -2561,6 +2542,7 @@ namespace UnitVentilator { // is set to the minimum value state.dataUnitVentilators->OAMassFlowRate = MinOAFrac * outsideAirNode.MassFlowRate; } break; + case OAControl::FixedTemperature: { // In heating mode, the outside air for "fixed temperature" attempts // to control the outside air fraction so that a desired temperature @@ -2569,7 +2551,7 @@ namespace UnitVentilator { // temperature), then this is possible. If not, the control will try // to maximize the amount of air coming from the source that is closer // in temperature to the desired temperature. - Tdesired = ScheduleManager::GetCurrentScheduleValue(state, unitVent.TempSchedPtr); + Tdesired = unitVent.tempSched->getCurrentVal(); Tinlet = inletNode.Temp; Toutdoor = outsideAirNode.Temp; MaxOAFrac = 1.0; @@ -2700,8 +2682,7 @@ namespace UnitVentilator { Toutdoor = outsideAirNode.Temp; if (outsideAirNode.MassFlowRate > 0.0) { - MinOAFrac = ScheduleManager::GetCurrentScheduleValue(state, unitVent.MinOASchedPtr) * - (unitVent.MinOutAirMassFlow / outsideAirNode.MassFlowRate); + MinOAFrac = unitVent.minOASched->getCurrentVal() * (unitVent.MinOutAirMassFlow / outsideAirNode.MassFlowRate); } else { MinOAFrac = 0.0; } @@ -2726,13 +2707,14 @@ namespace UnitVentilator { UnitVentNum, MinOAFrac, outsideAirNode.MassFlowRate, - ScheduleManager::GetCurrentScheduleValue(state, unitVent.MaxOASchedPtr), + unitVent.maxOASched->getCurrentVal(), Tinlet, Toutdoor); } break; + case OAControl::FixedTemperature: { // This is basically the same algorithm as for the heating case... - Tdesired = ScheduleManager::GetCurrentScheduleValue(state, unitVent.TempSchedPtr); + Tdesired = unitVent.tempSched->getCurrentVal(); MaxOAFrac = 1.0; if (std::abs(Tinlet - Toutdoor) <= LowTempDiff) { // no difference in indoor and outdoor conditions-->set OA to minimum @@ -2799,19 +2781,21 @@ namespace UnitVentilator { // which is equal to the minimum value, regardless of all the other conditions. state.dataUnitVentilators->OAMassFlowRate = MinOAFrac * outsideAirNode.MassFlowRate; } break; + case OAControl::VariablePercent: { state.dataUnitVentilators->OAMassFlowRate = SetOAMassFlowRateForCoolingVariablePercent(state, UnitVentNum, MinOAFrac, outsideAirNode.MassFlowRate, - ScheduleManager::GetCurrentScheduleValue(state, unitVent.MaxOASchedPtr), + unitVent.maxOASched->getCurrentVal(), Tinlet, Toutdoor); } break; + case OAControl::FixedTemperature: { // This is basically the same algorithm as for the heating case... - Tdesired = ScheduleManager::GetCurrentScheduleValue(state, unitVent.TempSchedPtr); + Tdesired = unitVent.tempSched->getCurrentVal(); MaxOAFrac = 1.0; diff --git a/src/EnergyPlus/UnitVentilator.hh b/src/EnergyPlus/UnitVentilator.hh index 2dada2c6b8f..aba293bf71d 100644 --- a/src/EnergyPlus/UnitVentilator.hh +++ b/src/EnergyPlus/UnitVentilator.hh @@ -106,7 +106,7 @@ namespace UnitVentilator { struct UnitVentilatorData { std::string Name; // name of unit - int SchedPtr = 0; // index to schedule + Sched::Schedule *availSched = nullptr; int AirInNode = 0; // inlet air node number int AirOutNode = 0; // outlet air node number int FanOutletNode = 0; // outlet node number for fan exit @@ -114,17 +114,17 @@ namespace UnitVentilator { HVAC::FanType fanType = HVAC::FanType::Invalid; // Fan type number (see DataHVACGlobals) std::string FanName; // name of fan int Fan_Index = 0; - int FanSchedPtr = 0; // index to fan operating mode schedule - int FanAvailSchedPtr = 0; // index to fan availability schedule + Sched::Schedule *fanOpModeSched = nullptr; // index to fan operating mode schedule + Sched::Schedule *fanAvailSched = nullptr; HVAC::FanOp fanOp = HVAC::FanOp::Invalid; // mode of operation; 1=cycling fan, cycling coil, 2=continuous fan, cycling coil int ControlCompTypeNum = 0; int CompErrIndex = 0; Real64 MaxAirVolFlow = 0.0; // m3/s Real64 MaxAirMassFlow = 0.0; // kg/s OAControl OAControlType = OAControl::Invalid; // type of control; options are VARIABLE PERCENT and FIXED TEMPERATURE - int MinOASchedPtr = 0; // index to schedule - int MaxOASchedPtr = 0; // index to schedule - int TempSchedPtr = 0; // index to schedule + Sched::Schedule *minOASched = nullptr; + Sched::Schedule *maxOASched = nullptr; + Sched::Schedule *tempSched = nullptr; int OutsideAirNode = 0; // outside air node number int AirReliefNode = 0; // relief air node number int OAMixerOutNode = 0; // outlet node after the outside air mixer (inlet to coils if present) @@ -140,7 +140,7 @@ namespace UnitVentilator { int HCoil_Index = 0; DataPlant::PlantEquipmentType HeatingCoilType = DataPlant::PlantEquipmentType::Invalid; int HCoil_FluidIndex = 0; - int HCoilSchedPtr = 0; // index to schedule + Sched::Schedule *hCoilSched = nullptr; Real64 HCoilSchedValue = 0.0; Real64 MaxVolHotWaterFlow = 0.0; // m3/s Real64 MaxVolHotSteamFlow = 0.0; // m3/s @@ -162,7 +162,7 @@ namespace UnitVentilator { std::string CCoilPlantType; // type of cooling coil for plant DataPlant::PlantEquipmentType CoolingCoilType = DataPlant::PlantEquipmentType::Invalid; CoolCoilType CCoilType = CoolCoilType::Invalid; - int CCoilSchedPtr = 0; // index to schedule + Sched::Schedule *cCoilSched = nullptr; Real64 CCoilSchedValue = 0.0; Real64 MaxVolColdWaterFlow = 0.0; // m3/s Real64 MaxColdWaterFlow = 0.0; // kg/s @@ -314,6 +314,10 @@ struct UnitVentilatorsData : BaseGlobalStruct int ATMixerPriNode = 0; // primary air node of ATM Mixer int ZoneNode = 0; // zone node + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/UnitarySystem.cc b/src/EnergyPlus/UnitarySystem.cc index 9da1b5a1573..3a074a68133 100644 --- a/src/EnergyPlus/UnitarySystem.cc +++ b/src/EnergyPlus/UnitarySystem.cc @@ -451,7 +451,7 @@ namespace UnitarySystems { this->m_MySizingCheckFlag = false; if (AirLoopNum > 0) { state.dataAirLoop->AirLoopControlInfo(AirLoopNum).fanOp = this->m_FanOpMode; - state.dataAirLoop->AirLoopControlInfo(AirLoopNum).CycFanSchedPtr = this->m_FanOpModeSchedPtr; + state.dataAirLoop->AirLoopControlInfo(AirLoopNum).cycFanSched = this->m_fanOpModeSched; } else if (AirLoopNum < 0) { if (this->m_ControlType == UnitarySysCtrlType::CCMASHRAE) { ShowSevereError(state, format("{}: {}", this->UnitType, this->Name)); @@ -892,7 +892,7 @@ namespace UnitarySystems { // Init maximum available Heat Recovery flow rate if ((this->m_HeatRecActive) && (!this->m_MyPlantScanFlag)) { Real64 mdotHR = 0.0; - if (ScheduleManager::GetCurrentScheduleValue(state, this->m_SysAvailSchedPtr) > 0.0) { + if (this->m_sysAvailSched->getCurrentVal() > 0.0) { if (FirstHVACIteration) { mdotHR = this->m_DesignHeatRecMassFlowRate; } else { @@ -918,7 +918,7 @@ namespace UnitarySystems { // for DX systems, just read the inlet node flow rate and let air loop decide flow if (this->m_ControlType == UnitarySysCtrlType::Setpoint && this->m_sysType == SysType::Unitary) { - if (ScheduleManager::GetCurrentScheduleValue(state, this->m_SysAvailSchedPtr) > 0.0) { + if (this->m_sysAvailSched->getCurrentVal() > 0.0) { if (this->m_LastMode == CoolingMode) { if (this->m_MultiOrVarSpeedCoolCoil) { state.dataLoopNodes->Node(this->AirInNode).MassFlowRate = this->m_CoolMassFlowRate[this->m_NumOfSpeedCooling]; @@ -3739,19 +3739,12 @@ namespace UnitarySystems { bool isNotOK = false; - if (!input_data.availability_schedule_name.empty()) { - this->m_SysAvailSchedPtr = ScheduleManager::GetScheduleIndex(state, input_data.availability_schedule_name); - if (this->m_SysAvailSchedPtr == 0) { - ShowWarningError(state, - format("getUnitarySystemInputData {}=\"{}\", invalid Availability Schedule Name = {}", - cCurrentModuleObject, - this->Name, - input_data.availability_schedule_name)); - ShowContinueError(state, "Set the default as Always On. Simulation continues."); - this->m_SysAvailSchedPtr = ScheduleManager::ScheduleAlwaysOn; - } - } else { - this->m_SysAvailSchedPtr = ScheduleManager::ScheduleAlwaysOn; + if (input_data.availability_schedule_name.empty()) { + this->m_sysAvailSched = Sched::GetScheduleAlwaysOn(state); + } else if ((this->m_sysAvailSched = Sched::GetSchedule(state, input_data.availability_schedule_name)) == nullptr) { + ShowWarningItemNotFound(state, eoh, "Availability Schedule Name", input_data.availability_schedule_name, + "Set the default as Always On. Simulation continues."); + this->m_sysAvailSched = Sched::GetScheduleAlwaysOn(state); } if (!input_data.controlling_zone_or_thermostat_location.empty()) { // not required field @@ -4090,7 +4083,7 @@ namespace UnitarySystems { this->m_DesignFanVolFlowRate = FanVolFlowRate; FanInletNode = fan->inletNodeNum; FanOutletNode = fan->outletNodeNum; - this->m_FanAvailSchedPtr = fan->availSchedNum; + this->m_fanAvailSched = fan->availSched; } this->m_FanExists = true; @@ -4120,13 +4113,7 @@ namespace UnitarySystems { errorsFound = true; } - this->m_FanOpModeSchedPtr = ScheduleManager::GetScheduleIndex(state, input_data.supply_air_fan_operating_mode_schedule_name); - if (!input_data.supply_air_fan_operating_mode_schedule_name.empty() && this->m_FanOpModeSchedPtr == 0) { - ShowSevereError(state, format("{} = {}", cCurrentModuleObject, thisObjectName)); - ShowContinueError(state, format("Illegal Fan Operating Mode Schedule Name = {}", input_data.supply_air_fan_operating_mode_schedule_name)); - // ShowContinueError(state, format("Illegal {} = {}", cAlphaFields(iFanSchedAlphaNum), Alphas(iFanSchedAlphaNum))); - errorsFound = true; - } else if (this->m_FanOpModeSchedPtr == 0) { + if (input_data.supply_air_fan_operating_mode_schedule_name.empty()) { if (this->m_ControlType == UnitarySysCtrlType::Setpoint) { // Fan operating mode must be constant fan so that the coil outlet temp is proportional to PLR // Cycling fan always outputs the full load outlet air temp so should not be used with set point based control @@ -4134,39 +4121,20 @@ namespace UnitarySystems { } else { this->m_FanOpMode = HVAC::FanOp::Cycling; if (this->m_FanType != HVAC::FanType::OnOff && this->m_FanType != HVAC::FanType::SystemModel && this->m_FanExists) { - ShowSevereError(state, format("{} = {}", cCurrentModuleObject, thisObjectName)); - // ShowContinueError(state, format("{} = {}", cAlphaFields(iFanTypeAlphaNum), Alphas(iFanTypeAlphaNum))); - // ShowContinueError(state, format("Fan type must be Fan:OnOff of Fan:SystemModel when {} = - // Blank.", cAlphaFields(iFanSchedAlphaNum))); - ShowContinueError(state, - "Fan type must be Fan:OnOff or Fan:SystemModel when Supply Air Fan Operating Mode Schedule Name is blank."); + ShowSevereEmptyField(state, eoh, "Fan Operating Mode Schedule Name", + "Fan type must be Fan:OnOff or Fan:SystemModel when Supply Air Fan Operating Mode Schedule Name is blank."); errorsFound = true; } } - } else if (this->m_FanOpModeSchedPtr > 0 && this->m_ControlType == UnitarySysCtrlType::Setpoint) { - if (!ScheduleManager::CheckScheduleValueMinMax(state, this->m_FanOpModeSchedPtr, ">", 0.0, "<=", 1.0)) { - ShowSevereError(state, format("{} = {}", cCurrentModuleObject, thisObjectName)); - ShowContinueError(state, format("For {} = {}", loc_fanType, loc_m_FanName)); - ShowContinueError(state, "Fan operating mode must be continuous (fan operating mode schedule values > 0)."); - ShowContinueError( - state, - format("Error found in Supply Air Fan Operating Mode Schedule Name {}", input_data.supply_air_fan_operating_mode_schedule_name)); - ShowContinueError(state, "...schedule values must be (>0., <=1.)"); - errorsFound = true; - } - } - - // Check fan's schedule for cycling fan operation IF constant volume fan is used - if (this->m_FanOpModeSchedPtr > 0 && this->m_FanType == HVAC::FanType::Constant) { - if (!ScheduleManager::CheckScheduleValueMinMax(state, this->m_FanOpModeSchedPtr, ">", 0.0, "<=", 1.0)) { - ShowSevereError(state, format("{} = {}", cCurrentModuleObject, thisObjectName)); - ShowContinueError(state, "Fan operating mode must be continuous (fan operating mode schedule values > 0)."); - ShowContinueError( - state, - format("Error found in Supply Air Fan Operating Mode Schedule Name {}", input_data.supply_air_fan_operating_mode_schedule_name)); - ShowContinueError(state, "...schedule values must be (>0., <=1.)"); - errorsFound = true; - } + } else if ((this->m_fanOpModeSched = Sched::GetSchedule(state, input_data.supply_air_fan_operating_mode_schedule_name)) == nullptr) { + ShowSevereItemNotFound(state, eoh, "Fan Operating Mode Schedule Name", input_data.supply_air_fan_operating_mode_schedule_name); + // ShowContinueError(state, format("Illegal {} = {}", cAlphaFields(iFanSchedAlphaNum), Alphas(iFanSchedAlphaNum))); + errorsFound = true; + } else if ((this->m_ControlType == UnitarySysCtrlType::Setpoint || this->m_FanType == HVAC::FanType::Constant) && + !this->m_fanOpModeSched->checkMinMaxVals(state, Clusive::Ex, 0.0, Clusive::In, 1.0)) { + Sched::ShowSevereBadMinMax(state, eoh, "Supply Air Fan Operating Mode Schedule Name", input_data.supply_air_fan_operating_mode_schedule_name, + Clusive::Ex, 0.0, Clusive::In, 1.0); + errorsFound = true; } PrintMessage = true; @@ -4198,7 +4166,7 @@ namespace UnitarySystems { errFlag = false; } else { auto &thisHeatCoil = state.dataDXCoils->DXCoil(this->m_HeatingCoilIndex); - this->m_HeatingCoilAvailSchPtr = thisHeatCoil.SchedPtr; + this->m_heatingCoilAvailSched = thisHeatCoil.availSched; this->m_DesignHeatingCapacity = thisHeatCoil.RatedTotCap(1); if (this->m_DesignHeatingCapacity == DataSizing::AutoSize) this->m_RequestAutoSize = true; this->m_MaxHeatAirVolFlow = thisHeatCoil.RatedAirVolFlowRate(1); @@ -4228,7 +4196,7 @@ namespace UnitarySystems { } else { auto const &thisHeatCoil = state.dataVariableSpeedCoils->VarSpeedCoil(this->m_HeatingCoilIndex); this->m_NumOfSpeedHeating = thisHeatCoil.NumOfSpeeds; - this->m_HeatingCoilAvailSchPtr = ScheduleManager::ScheduleAlwaysOn; + this->m_heatingCoilAvailSched = Sched::GetScheduleAlwaysOn(state); this->m_MaxHeatAirVolFlow = thisHeatCoil.RatedAirVolFlowRate; if (this->m_MaxHeatAirVolFlow == DataSizing::AutoSize) { this->m_RequestAutoSize = true; @@ -4256,7 +4224,7 @@ namespace UnitarySystems { errFlag = false; } else { auto const &thisHeatCoil = state.dataDXCoils->DXCoil(this->m_HeatingCoilIndex); - this->m_HeatingCoilAvailSchPtr = thisHeatCoil.SchedPtr; + this->m_heatingCoilAvailSched = thisHeatCoil.availSched; this->m_MaxHeatAirVolFlow = thisHeatCoil.MSRatedAirVolFlowRate(1); if (this->m_MaxHeatAirVolFlow == DataSizing::AutoSize) this->m_RequestAutoSize = true; HeatingCoilInletNode = thisHeatCoil.AirInNode; @@ -4280,7 +4248,7 @@ namespace UnitarySystems { auto const &thisHeatCoil = state.dataHeatingCoils->HeatingCoil(this->m_HeatingCoilIndex); HeatingCoilInletNode = thisHeatCoil.AirInletNodeNum; HeatingCoilOutletNode = thisHeatCoil.AirOutletNodeNum; - this->m_HeatingCoilAvailSchPtr = thisHeatCoil.SchedPtr; + this->m_heatingCoilAvailSched = thisHeatCoil.availSched; this->m_DesignHeatingCapacity = thisHeatCoil.MSNominalCapacity(thisHeatCoil.NumOfStages); if (this->m_DesignHeatingCapacity == DataSizing::AutoSize) this->m_RequestAutoSize = true; } @@ -4301,7 +4269,7 @@ namespace UnitarySystems { auto const &thisHeatCoil = state.dataHeatingCoils->HeatingCoil(this->m_HeatingCoilIndex); this->m_DesignHeatingCapacity = thisHeatCoil.NominalCapacity; if (this->m_DesignHeatingCapacity == DataSizing::AutoSize) this->m_RequestAutoSize = true; - this->m_HeatingCoilAvailSchPtr = thisHeatCoil.SchedPtr; + this->m_heatingCoilAvailSched = thisHeatCoil.availSched; HeatingCoilInletNode = thisHeatCoil.AirInletNodeNum; HeatingCoilOutletNode = thisHeatCoil.AirOutletNodeNum; HeatingCoilPLFCurveIndex = thisHeatCoil.PLFCurveIndex; @@ -4325,7 +4293,7 @@ namespace UnitarySystems { errFlag = false; } else { auto const &thisHeatCoil = state.dataWaterCoils->WaterCoil(this->m_HeatingCoilIndex); - this->m_HeatingCoilAvailSchPtr = thisHeatCoil.SchedPtr; + this->m_heatingCoilAvailSched = thisHeatCoil.availSched; this->HeatCoilFluidInletNode = thisHeatCoil.WaterInletNodeNum; this->MaxHeatCoilFluidFlow = thisHeatCoil.MaxWaterVolFlowRate; if (this->MaxHeatCoilFluidFlow == DataSizing::AutoSize) { @@ -4351,7 +4319,7 @@ namespace UnitarySystems { errFlag = false; } else { auto const &thisHeatCoil = state.dataSteamCoils->SteamCoil(this->m_HeatingCoilIndex); - this->m_HeatingCoilAvailSchPtr = thisHeatCoil.SchedPtr; + this->m_heatingCoilAvailSched = thisHeatCoil.availSched; this->HeatCoilFluidInletNode = thisHeatCoil.SteamInletNodeNum; this->MaxHeatCoilFluidFlow = thisHeatCoil.MaxSteamVolFlowRate; if (this->MaxHeatCoilFluidFlow == DataSizing::AutoSize) { @@ -4390,7 +4358,7 @@ namespace UnitarySystems { errFlag = false; } else { auto const &thisHeatCoil = state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(this->m_HeatingCoilIndex); - this->m_HeatingCoilAvailSchPtr = ScheduleManager::ScheduleAlwaysOn; + this->m_heatingCoilAvailSched = Sched::GetScheduleAlwaysOn(state); this->m_DesignHeatingCapacity = thisHeatCoil.RatedCapHeat; this->m_MaxHeatAirVolFlow = thisHeatCoil.RatedAirVolFlowRate; if (this->m_MaxHeatAirVolFlow == DataSizing::AutoSize) this->m_RequestAutoSize = true; @@ -4414,7 +4382,7 @@ namespace UnitarySystems { errFlag = false; } else { auto const &thisHeatCoil = state.dataWaterToAirHeatPump->WatertoAirHP(this->m_HeatingCoilIndex); - this->m_HeatingCoilAvailSchPtr = ScheduleManager::ScheduleAlwaysOn; + this->m_heatingCoilAvailSched = Sched::GetScheduleAlwaysOn(state); this->m_DesignHeatingCapacity = thisHeatCoil.HeatingCapacity; HeatingCoilInletNode = thisHeatCoil.AirInletNodeNum; HeatingCoilOutletNode = thisHeatCoil.AirOutletNodeNum; @@ -4436,7 +4404,7 @@ namespace UnitarySystems { errFlag = false; } else { auto const &thisHeatCoil = state.dataUserDefinedComponents->UserCoil(this->m_HeatingCoilIndex); - this->m_HeatingCoilAvailSchPtr = ScheduleManager::ScheduleAlwaysOn; + this->m_heatingCoilAvailSched = Sched::GetScheduleAlwaysOn(state); // **** How to get this info **** // UnitarySystem( UnitarySysNum ).DesignHeatingCapacity = // GetWtoAHPCoilCapacity(CoolingCoilType, this->m_CoolingCoilName, errFlag ); @@ -4504,7 +4472,7 @@ namespace UnitarySystems { DXCoils::DisableLatentDegradation(state, this->m_CoolingCoilIndex); } auto &thisCoolCoil = state.dataDXCoils->DXCoil(this->m_CoolingCoilIndex); - this->m_CoolingCoilAvailSchPtr = thisCoolCoil.SchedPtr; + this->m_coolingCoilAvailSched = thisCoolCoil.availSched; this->m_DesignCoolingCapacity = thisCoolCoil.RatedTotCap(1); if (this->m_DesignCoolingCapacity == DataSizing::AutoSize) this->m_RequestAutoSize = true; this->m_MaxCoolAirVolFlow = thisCoolCoil.RatedAirVolFlowRate(1); @@ -4566,7 +4534,7 @@ namespace UnitarySystems { this->m_MaxCoolAirVolFlow = newCoil.performance.normalMode.ratedEvapAirFlowRate; if (this->m_DesignCoolingCapacity == DataSizing::AutoSize) this->m_RequestAutoSize = true; if (this->m_MaxCoolAirVolFlow == DataSizing::AutoSize) this->m_RequestAutoSize = true; - this->m_CoolingCoilAvailSchPtr = newCoil.availScheduleIndex; + this->m_coolingCoilAvailSched = newCoil.availSched; CoolingCoilInletNode = newCoil.evapInletNodeIndex; CoolingCoilOutletNode = newCoil.evapOutletNodeIndex; this->m_CondenserNodeNum = newCoil.condInletNodeIndex; @@ -4630,7 +4598,7 @@ namespace UnitarySystems { errorsFound = true; } else { auto &thisCoolCoil = state.dataDXCoils->DXCoil(this->m_CoolingCoilIndex); - this->m_CoolingCoilAvailSchPtr = thisCoolCoil.SchedPtr; + this->m_coolingCoilAvailSched = thisCoolCoil.availSched; this->m_DesignCoolingCapacity = thisCoolCoil.RatedTotCap(thisCoolCoil.NumCapacityStages); if (this->m_DesignCoolingCapacity == DataSizing::AutoSize) this->m_RequestAutoSize = true; this->m_MaxCoolAirVolFlow = thisCoolCoil.RatedAirVolFlowRate(1); @@ -4690,7 +4658,7 @@ namespace UnitarySystems { } auto const &newCoil = state.dataCoilCooingDX->coilCoolingDXs[childCCIndex]; - this->m_CoolingCoilAvailSchPtr = newCoil.availScheduleIndex; + this->m_coolingCoilAvailSched = newCoil.availSched; // thisSys.m_DesignCoolingCapacity = newCoil.performance.normalMode.ratedGrossTotalCap; // Get Coil:Cooling:DX coil air flow rate. Later fields will overwrite this IF input field is present @@ -4703,7 +4671,7 @@ namespace UnitarySystems { } else if (Util::SameString(ChildCoolingCoilType, "COIL:COOLING:DX:SINGLESPEED")) { - this->m_CoolingCoilAvailSchPtr = DXCoils::GetDXCoilAvailSchPtr(state, ChildCoolingCoilType, ChildCoolingCoilName, errFlag); + this->m_coolingCoilAvailSched = DXCoils::GetDXCoilAvailSched(state, ChildCoolingCoilType, ChildCoolingCoilName, errFlag); if (isNotOK) { ShowContinueError(state, format("Occurs in {} = {}", cCurrentModuleObject, thisObjectName)); errorsFound = true; @@ -4732,7 +4700,7 @@ namespace UnitarySystems { } } else if (Util::SameString(ChildCoolingCoilType, "COIL:COOLING:DX:VARIABLESPEED")) { - this->m_CoolingCoilAvailSchPtr = ScheduleManager::ScheduleAlwaysOn; + this->m_coolingCoilAvailSched = Sched::GetScheduleAlwaysOn(state); this->m_MaxCoolAirVolFlow = VariableSpeedCoils::GetCoilAirFlowRateVariableSpeed(state, ChildCoolingCoilType, ChildCoolingCoilName, errFlag); if (errFlag) { @@ -4822,8 +4790,8 @@ namespace UnitarySystems { errorsFound = true; } - this->m_CoolingCoilAvailSchPtr = - WaterCoils::GetWaterCoilAvailScheduleIndex(state, HVAC::cAllCoilTypes(ActualCoolCoilType), HXCoilName, errFlag); + this->m_coolingCoilAvailSched = + WaterCoils::GetWaterCoilAvailSched(state, HVAC::cAllCoilTypes(ActualCoolCoilType), HXCoilName, errFlag); this->MaxCoolCoilFluidFlow = WaterCoils::GetCoilMaxWaterFlowRate(state, HVAC::cAllCoilTypes(ActualCoolCoilType), HXCoilName, errFlag); // Get the Cooling Coil water Inlet Node number @@ -4891,7 +4859,7 @@ namespace UnitarySystems { CoolingCoilInletNode = thisCoolCoil.AirInletNodeNum; CoolingCoilOutletNode = thisCoolCoil.AirOutletNodeNum; this->m_CondenserNodeNum = thisCoolCoil.CondenserInletNodeNum; - this->m_CoolingCoilAvailSchPtr = ScheduleManager::ScheduleAlwaysOn; + this->m_coolingCoilAvailSched = Sched::GetScheduleAlwaysOn(state); this->m_NumOfSpeedCooling = thisCoolCoil.NumOfSpeeds; if (this->m_NumOfSpeedCooling > 1) { this->m_MultiOrVarSpeedCoolCoil = true; @@ -4938,7 +4906,7 @@ namespace UnitarySystems { errFlag = false; } else { auto const &thisCoolCoil = state.dataDXCoils->DXCoil(this->m_CoolingCoilIndex); - this->m_CoolingCoilAvailSchPtr = thisCoolCoil.SchedPtr; + this->m_coolingCoilAvailSched = thisCoolCoil.availSched; CoolingCoilInletNode = thisCoolCoil.AirInNode; CoolingCoilOutletNode = thisCoolCoil.AirOutNode; this->m_DesignCoolingCapacity = thisCoolCoil.MSRatedTotCap(thisCoolCoil.NumOfSpeeds); @@ -4975,7 +4943,7 @@ namespace UnitarySystems { errFlag = false; } else { auto const &thisCoolCoil = state.dataWaterCoils->WaterCoil(this->m_CoolingCoilIndex); - this->m_CoolingCoilAvailSchPtr = thisCoolCoil.SchedPtr; + this->m_coolingCoilAvailSched = thisCoolCoil.availSched; if (this->m_CoolingCoilType_Num == HVAC::Coil_CoolingWater) { this->m_MaxCoolAirVolFlow = thisCoolCoil.DesAirVolFlowRate; } @@ -5004,7 +4972,7 @@ namespace UnitarySystems { errFlag = false; } else { auto const &thisCoolCoil = state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(this->m_CoolingCoilIndex); - this->m_CoolingCoilAvailSchPtr = ScheduleManager::ScheduleAlwaysOn; + this->m_coolingCoilAvailSched = Sched::GetScheduleAlwaysOn(state); this->m_DesignCoolingCapacity = thisCoolCoil.RatedCapCoolTotal; // this isn't likely to work on getInput calls but is what happened before @@ -5054,7 +5022,7 @@ namespace UnitarySystems { errFlag = false; } else { auto const &thisCoolCoil = state.dataWaterToAirHeatPump->WatertoAirHP(this->m_CoolingCoilIndex); - this->m_CoolingCoilAvailSchPtr = ScheduleManager::ScheduleAlwaysOn; + this->m_coolingCoilAvailSched = Sched::GetScheduleAlwaysOn(state); this->m_DesignCoolingCapacity = thisCoolCoil.CoolingCapacity; CoolingCoilInletNode = thisCoolCoil.AirInletNodeNum; CoolingCoilOutletNode = thisCoolCoil.AirOutletNodeNum; @@ -5087,7 +5055,7 @@ namespace UnitarySystems { errFlag = false; } else { auto const &thisCoolCoil = state.dataUserDefinedComponents->UserCoil(this->m_CoolingCoilIndex); - this->m_CoolingCoilAvailSchPtr = ScheduleManager::ScheduleAlwaysOn; + this->m_coolingCoilAvailSched = Sched::GetScheduleAlwaysOn(state); // **** How to get this info **** // UnitarySystem( UnitarySysNum ).DesignCoolingCapacity = // GetWtoAHPCoilCapacity(CoolingCoilType, this->m_CoolingCoilName, errFlag ); @@ -5111,7 +5079,7 @@ namespace UnitarySystems { errFlag = false; } else { auto const &thisCoolCoil = state.dataPackagedThermalStorageCoil->TESCoil(this->m_CoolingCoilIndex); - this->m_CoolingCoilAvailSchPtr = ScheduleManager::ScheduleAlwaysOn; + this->m_coolingCoilAvailSched = Sched::GetScheduleAlwaysOn(state); this->m_MaxCoolAirVolFlow = thisCoolCoil.RatedEvapAirVolFlowRate; if (thisCoolCoil.CoolingOnlyModeIsAvailable) { this->m_DesignCoolingCapacity = thisCoolCoil.CoolingOnlyRatedTotCap; @@ -6067,8 +6035,8 @@ namespace UnitarySystems { } // Fan operating mode (cycling or constant) schedule. IF constant fan, then set AirFlowControl - if (this->m_FanOpModeSchedPtr > 0) { - if (!ScheduleManager::CheckScheduleValueMinMax(state, this->m_FanOpModeSchedPtr, ">=", 0.0, "<=", 0.0)) { + if (this->m_fanOpModeSched != nullptr) { + if (!this->m_fanOpModeSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 0.0)) { // set fan operating mode to continuous so sizing can set VS coil data this->m_FanOpMode = HVAC::FanOp::Continuous; // set air flow control mode: @@ -6445,8 +6413,8 @@ namespace UnitarySystems { } } - if (this->m_FanOpModeSchedPtr > 0) { - if (!ScheduleManager::CheckScheduleValueMinMax(state, this->m_FanOpModeSchedPtr, ">=", 0.0, "<=", 0.0)) { + if (this->m_fanOpModeSched != nullptr) { + if (!this->m_fanOpModeSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 0.0)) { // set air flow control mode: // m_AirFlowControl = UseCompFlow::On means operate at last cooling or heating air flow requested when compressor is off // m_AirFlowControl = UseCompFlow::Off means operate at no load air flow value specified by user @@ -8044,18 +8012,18 @@ namespace UnitarySystems { state.dataUnitarySystems->QToHeatSetPt = state.dataZoneEnergyDemand->ZoneSysEnergyDemand(this->ControlZoneNum) .SequencedOutputRequiredToHeatingSP(this->m_ZoneSequenceHeatingNum); if (state.dataUnitarySystems->QToHeatSetPt > 0.0 && state.dataUnitarySystems->QToCoolSetPt > 0.0 && - state.dataHeatBalFanSys->TempControlType(this->ControlZoneNum) != HVAC::ThermostatType::SingleCooling) { + state.dataHeatBalFanSys->TempControlType(this->ControlZoneNum) != HVAC::SetptType::SingleCool) { ZoneLoad = state.dataUnitarySystems->QToHeatSetPt; state.dataUnitarySystems->HeatingLoad = true; } else if (state.dataUnitarySystems->QToHeatSetPt > 0.0 && state.dataUnitarySystems->QToCoolSetPt > 0.0 && - state.dataHeatBalFanSys->TempControlType(this->ControlZoneNum) == HVAC::ThermostatType::SingleCooling) { + state.dataHeatBalFanSys->TempControlType(this->ControlZoneNum) == HVAC::SetptType::SingleCool) { ZoneLoad = 0.0; } else if (state.dataUnitarySystems->QToHeatSetPt < 0.0 && state.dataUnitarySystems->QToCoolSetPt < 0.0 && - state.dataHeatBalFanSys->TempControlType(this->ControlZoneNum) != HVAC::ThermostatType::SingleHeating) { + state.dataHeatBalFanSys->TempControlType(this->ControlZoneNum) != HVAC::SetptType::SingleHeat) { ZoneLoad = state.dataUnitarySystems->QToCoolSetPt; state.dataUnitarySystems->CoolingLoad = true; } else if (state.dataUnitarySystems->QToHeatSetPt < 0.0 && state.dataUnitarySystems->QToCoolSetPt < 0.0 && - state.dataHeatBalFanSys->TempControlType(this->ControlZoneNum) == HVAC::ThermostatType::SingleHeating) { + state.dataHeatBalFanSys->TempControlType(this->ControlZoneNum) == HVAC::SetptType::SingleHeat) { ZoneLoad = 0.0; } else if (state.dataUnitarySystems->QToHeatSetPt <= 0.0 && state.dataUnitarySystems->QToCoolSetPt >= 0.0) { ZoneLoad = 0.0; @@ -8075,10 +8043,10 @@ namespace UnitarySystems { this->m_sysType == SysType::PackagedWSHP) { // ZoneSysAvailManager is turning on sooner than PTUnit in UnitarySystem. Mimic PTUnit logic. if (state.dataUnitarySystems->QToCoolSetPt < 0.0 && - state.dataHeatBalFanSys->TempControlType(this->ControlZoneNum) != HVAC::ThermostatType::SingleHeating) { + state.dataHeatBalFanSys->TempControlType(this->ControlZoneNum) != HVAC::SetptType::SingleHeat) { ZoneLoad = state.dataUnitarySystems->QToCoolSetPt; } else if (state.dataUnitarySystems->QToHeatSetPt > 0.0 && - state.dataHeatBalFanSys->TempControlType(this->ControlZoneNum) != HVAC::ThermostatType::SingleCooling) { + state.dataHeatBalFanSys->TempControlType(this->ControlZoneNum) != HVAC::SetptType::SingleCool) { ZoneLoad = state.dataUnitarySystems->QToHeatSetPt; } else { ZoneLoad = 0.0; @@ -8400,7 +8368,7 @@ namespace UnitarySystems { std::string CompName = this->Name; int OutletNode = this->AirOutNode; - if (ScheduleManager::GetCurrentScheduleValue(state, this->m_SysAvailSchedPtr) <= 0.0) { + if (this->m_sysAvailSched->getCurrentVal() <= 0.0) { return; } if (this->m_EMSOverrideCoilSpeedNumOn) { @@ -8450,7 +8418,7 @@ namespace UnitarySystems { // determine if PLR=0 meets the load switch (state.dataHeatBalFanSys->TempControlType(this->ControlZoneNum)) { - case HVAC::ThermostatType::SingleHeating: { + case HVAC::SetptType::SingleHeat: { if (state.dataUnitarySystems->HeatingLoad && SensOutputOff > ZoneLoad && (state.dataUnitarySystems->MoistureLoad >= 0.0 || state.dataUnitarySystems->MoistureLoad > LatOutputOff)) return; @@ -8458,7 +8426,7 @@ namespace UnitarySystems { (state.dataUnitarySystems->MoistureLoad >= 0.0 || state.dataUnitarySystems->MoistureLoad > LatOutputOff)) return; } break; - case HVAC::ThermostatType::SingleCooling: { + case HVAC::SetptType::SingleCool: { if (state.dataUnitarySystems->CoolingLoad && SensOutputOff < ZoneLoad && (state.dataUnitarySystems->MoistureLoad >= 0.0 || state.dataUnitarySystems->MoistureLoad > LatOutputOff)) return; @@ -8466,8 +8434,8 @@ namespace UnitarySystems { (state.dataUnitarySystems->MoistureLoad >= 0.0 || state.dataUnitarySystems->MoistureLoad > LatOutputOff)) return; } break; - case HVAC::ThermostatType::SingleHeatCool: - case HVAC::ThermostatType::DualSetPointWithDeadBand: { + case HVAC::SetptType::SingleHeatCool: + case HVAC::SetptType::DualHeatCool: { if (state.dataUnitarySystems->HeatingLoad && SensOutputOff > ZoneLoad && (state.dataUnitarySystems->MoistureLoad >= 0.0 || state.dataUnitarySystems->MoistureLoad > LatOutputOff)) return; @@ -8522,7 +8490,7 @@ namespace UnitarySystems { FullSensibleOutput = SensOutputOff; switch (state.dataHeatBalFanSys->TempControlType(this->ControlZoneNum)) { - case HVAC::ThermostatType::SingleHeating: { + case HVAC::SetptType::SingleHeat: { if (state.dataUnitarySystems->HeatingLoad && SensOutputOff > ZoneLoad && (state.dataUnitarySystems->MoistureLoad >= 0.0 || state.dataUnitarySystems->MoistureLoad > LatOutputOff)) return; @@ -8530,7 +8498,7 @@ namespace UnitarySystems { (state.dataUnitarySystems->MoistureLoad >= 0.0 || state.dataUnitarySystems->MoistureLoad > LatOutputOff)) return; } break; - case HVAC::ThermostatType::SingleCooling: { + case HVAC::SetptType::SingleCool: { if (state.dataUnitarySystems->CoolingLoad && SensOutputOff < ZoneLoad && this->m_DehumidControlType_Num != DehumCtrlType::CoolReheat) return; if (state.dataUnitarySystems->CoolingLoad && SensOutputOff < ZoneLoad && @@ -8540,8 +8508,8 @@ namespace UnitarySystems { (state.dataUnitarySystems->MoistureLoad >= 0.0 || state.dataUnitarySystems->MoistureLoad > LatOutputOff)) return; } break; - case HVAC::ThermostatType::SingleHeatCool: - case HVAC::ThermostatType::DualSetPointWithDeadBand: { + case HVAC::SetptType::SingleHeatCool: + case HVAC::SetptType::DualHeatCool: { if (state.dataUnitarySystems->HeatingLoad && SensOutputOff > ZoneLoad && (state.dataUnitarySystems->MoistureLoad >= 0.0 || state.dataUnitarySystems->MoistureLoad > LatOutputOff)) return; @@ -8675,7 +8643,7 @@ namespace UnitarySystems { if ((state.dataUnitarySystems->HeatingLoad && this->m_NumOfSpeedHeating <= 1) || (state.dataUnitarySystems->CoolingLoad && this->m_NumOfSpeedCooling <= 1)) { switch (state.dataHeatBalFanSys->TempControlType(this->ControlZoneNum)) { - case HVAC::ThermostatType::SingleHeating: { + case HVAC::SetptType::SingleHeat: { if (state.dataUnitarySystems->HeatingLoad && SensOutputOn < ZoneLoad) { this->m_HeatingPartLoadFrac = 1.0; if (state.dataUnitarySystems->MoistureLoad >= 0.0 || state.dataUnitarySystems->MoistureLoad < LatOutputOn) return; @@ -8684,7 +8652,7 @@ namespace UnitarySystems { (state.dataUnitarySystems->MoistureLoad >= 0.0 || state.dataUnitarySystems->MoistureLoad < LatOutputOn)) return; } break; - case HVAC::ThermostatType::SingleCooling: { + case HVAC::SetptType::SingleCool: { if (state.dataUnitarySystems->CoolingLoad && SensOutputOn > ZoneLoad) { this->m_CoolingPartLoadFrac = 1.0; if (state.dataUnitarySystems->MoistureLoad >= 0.0 || state.dataUnitarySystems->MoistureLoad < LatOutputOn) return; @@ -8693,8 +8661,8 @@ namespace UnitarySystems { (state.dataUnitarySystems->MoistureLoad >= 0.0 || state.dataUnitarySystems->MoistureLoad < LatOutputOn)) return; } break; - case HVAC::ThermostatType::SingleHeatCool: - case HVAC::ThermostatType::DualSetPointWithDeadBand: { + case HVAC::SetptType::SingleHeatCool: + case HVAC::SetptType::DualHeatCool: { if (state.dataUnitarySystems->HeatingLoad && SensOutputOn < ZoneLoad) { this->m_HeatingPartLoadFrac = 1.0; if (state.dataUnitarySystems->MoistureLoad >= 0.0 || state.dataUnitarySystems->MoistureLoad > LatOutputOn) return; @@ -10186,8 +10154,8 @@ namespace UnitarySystems { } } - if (this->m_FanOpModeSchedPtr > 0) { - if (ScheduleManager::GetCurrentScheduleValue(state, this->m_FanOpModeSchedPtr) == 0.0) { + if (this->m_fanOpModeSched != nullptr) { + if (this->m_fanOpModeSched->getCurrentVal() == 0.0) { this->m_FanOpMode = HVAC::FanOp::Cycling; } else { this->m_FanOpMode = HVAC::FanOp::Continuous; @@ -10214,11 +10182,11 @@ namespace UnitarySystems { smallLoadTolerance = HVAC::SmallLoad; } if (QZnReq > smallLoadTolerance) { // no need to check deadband flag, QZnReq is correct. - if (state.dataHeatBalFanSys->TempControlType(this->ControlZoneNum) != HVAC::ThermostatType::SingleCooling) { + if (state.dataHeatBalFanSys->TempControlType(this->ControlZoneNum) != HVAC::SetptType::SingleCool) { state.dataUnitarySystems->HeatingLoad = true; } } else if (QZnReq < -smallLoadTolerance) { - if (state.dataHeatBalFanSys->TempControlType(this->ControlZoneNum) != HVAC::ThermostatType::SingleHeating) { + if (state.dataHeatBalFanSys->TempControlType(this->ControlZoneNum) != HVAC::SetptType::SingleHeat) { state.dataUnitarySystems->CoolingLoad = true; } } @@ -10251,7 +10219,7 @@ namespace UnitarySystems { CompressorOn); switch (state.dataHeatBalFanSys->TempControlType(this->ControlZoneNum)) { - case HVAC::ThermostatType::SingleHeating: + case HVAC::SetptType::SingleHeat: { state.dataUnitarySystems->CoolingLoad = false; // No heating load and constant fan pushes zone below heating set point if (SensOutputOff < 0.0 && state.dataUnitarySystems->QToHeatSetPt <= 0.0 && @@ -10260,8 +10228,9 @@ namespace UnitarySystems { state.dataUnitarySystems->CoolingLoad = false; ZoneLoad = state.dataUnitarySystems->QToHeatSetPt; } - break; - case HVAC::ThermostatType::SingleCooling: + } break; + + case HVAC::SetptType::SingleCool: { state.dataUnitarySystems->HeatingLoad = false; // No heating load and constant fan pushes zone above cooling set point if (SensOutputOff > 0.0 && state.dataUnitarySystems->QToCoolSetPt > 0.0 && @@ -10270,8 +10239,9 @@ namespace UnitarySystems { state.dataUnitarySystems->CoolingLoad = true; ZoneLoad = state.dataUnitarySystems->QToCoolSetPt; } - break; - case HVAC::ThermostatType::SingleHeatCool: + } break; + + case HVAC::SetptType::SingleHeatCool: { // zone temp above cooling and heating set point temps if (state.dataUnitarySystems->QToHeatSetPt < 0.0 && state.dataUnitarySystems->QToCoolSetPt < 0.0) { // zone pushed below heating set point @@ -10289,8 +10259,9 @@ namespace UnitarySystems { ZoneLoad = state.dataUnitarySystems->QToCoolSetPt; } } - break; - case HVAC::ThermostatType::DualSetPointWithDeadBand: + } break; + + case HVAC::SetptType::DualHeatCool: { // zone temp above cooling and heating set point temps if (state.dataUnitarySystems->QToHeatSetPt < 0.0 && state.dataUnitarySystems->QToCoolSetPt < 0.0) { // zone pushed into deadband @@ -10333,10 +10304,11 @@ namespace UnitarySystems { ZoneLoad = state.dataUnitarySystems->QToCoolSetPt; } } - break; - default: - break; - } + } break; + + default: { + } break; + } // switch // push iteration mode stack and set current mode this->m_IterationMode[2] = this->m_IterationMode[1]; @@ -11050,10 +11022,10 @@ namespace UnitarySystems { // BEGIN - refactor/move this to Init during FirstHVACIteration, need struct or module level global for turnFansOn and turnFansOff // If the unitary system is scheduled on or nightime cycle overrides fan schedule. Uses same logic as fan. - FanOn = (this->m_FanExists) ? ScheduleManager::GetCurrentScheduleValue(state, this->m_FanAvailSchedPtr) > 0 : true; + FanOn = (this->m_FanExists) ? (this->m_fanAvailSched->getCurrentVal() > 0) : true; // END - move this to Init during FirstHVACIteration - if (ScheduleManager::GetCurrentScheduleValue(state, this->m_SysAvailSchedPtr) > 0.0 && + if (this->m_sysAvailSched->getCurrentVal() > 0.0 && ((FanOn || state.dataHVACGlobal->TurnFansOn) && !state.dataHVACGlobal->TurnFansOff)) { if (this->m_ControlType == UnitarySysCtrlType::Setpoint) { // set point based equipment should use VAV terminal units to set the flow. @@ -12192,8 +12164,8 @@ namespace UnitarySystems { } // IF UnitarySystem is scheduled on and there is flow - if ((ScheduleManager::GetCurrentScheduleValue(state, this->m_SysAvailSchedPtr) > 0.0) && - ScheduleManager::GetCurrentScheduleValue(state, this->m_CoolingCoilAvailSchPtr) > 0.0 && + if ((this->m_sysAvailSched->getCurrentVal() > 0.0) && + this->m_coolingCoilAvailSched->getCurrentVal() > 0.0 && (state.dataLoopNodes->Node(InletNode).MassFlowRate > HVAC::SmallAirVolFlow)) { bool SensibleLoad = false; @@ -14008,8 +13980,8 @@ namespace UnitarySystems { } // IF DXHeatingSystem is scheduled on and there is flow - if (ScheduleManager::GetCurrentScheduleValue(state, this->m_SysAvailSchedPtr) > 0.0 && - ScheduleManager::GetCurrentScheduleValue(state, this->m_HeatingCoilAvailSchPtr) > 0.0 && + if (this->m_sysAvailSched->getCurrentVal() > 0.0 && + this->m_heatingCoilAvailSched->getCurrentVal() > 0.0 && state.dataLoopNodes->Node(InletNode).MassFlowRate > HVAC::SmallAirVolFlow) { bool SensibleLoad = false; @@ -14645,7 +14617,7 @@ namespace UnitarySystems { DesOutTemp -= this->m_FaultyCoilSATOffset; } - if ((ScheduleManager::GetCurrentScheduleValue(state, this->m_SysAvailSchedPtr) > 0.0) && (inletNode.MassFlowRate > HVAC::SmallAirVolFlow)) { + if ((this->m_sysAvailSched->getCurrentVal() > 0.0) && (inletNode.MassFlowRate > HVAC::SmallAirVolFlow)) { if (inletNode.Temp < (DesOutTemp - HVAC::TempControlTol)) { if (this->m_EMSOverrideSuppCoilSpeedNumOn) { diff --git a/src/EnergyPlus/UnitarySystem.hh b/src/EnergyPlus/UnitarySystem.hh index 1a4070299c7..f92e5fabe15 100644 --- a/src/EnergyPlus/UnitarySystem.hh +++ b/src/EnergyPlus/UnitarySystem.hh @@ -231,7 +231,7 @@ namespace UnitarySystems { int m_UnitarySysNum = -1; SysType m_sysType = SysType::Invalid; bool m_ThisSysInputShouldBeGotten = true; - int m_SysAvailSchedPtr = 0; // Pointer to the availability schedule + Sched::Schedule *m_sysAvailSched = nullptr; // availability schedule UnitarySysCtrlType m_ControlType = UnitarySysCtrlType::None; DehumCtrlType m_DehumidControlType_Num = DehumCtrlType::None; bool m_Humidistat = false; @@ -241,14 +241,14 @@ namespace UnitarySystems { bool m_setFaultModelInput = true; int m_FanIndex = 0; HVAC::FanPlace m_FanPlace = HVAC::FanPlace::Invalid; - int m_FanOpModeSchedPtr = 0; + Sched::Schedule *m_fanOpModeSched = nullptr; bool m_FanExists = false; HVAC::FanType m_FanType = HVAC::FanType::Invalid; bool m_RequestAutoSize = false; Real64 m_ActualFanVolFlowRate = 0.0; Real64 m_DesignFanVolFlowRate = 0.0; Real64 m_DesignMassFlowRate = 0.0; - int m_FanAvailSchedPtr = 0; + Sched::Schedule *m_fanAvailSched = nullptr; HVAC::FanOp m_FanOpMode = HVAC::FanOp::Invalid; int m_ATMixerIndex = 0; int m_ATMixerPriNode = 0; @@ -262,7 +262,7 @@ namespace UnitarySystems { int m_HeatingCoilType_Num = 0; bool m_DXHeatingCoil = false; int m_HeatingCoilIndex = 0; - int m_HeatingCoilAvailSchPtr = 0; + Sched::Schedule *m_heatingCoilAvailSched = nullptr; Real64 m_DesignHeatingCapacity = 0.0; Real64 m_MaxHeatAirVolFlow = 0.0; int m_NumOfSpeedHeating = 0; @@ -273,7 +273,7 @@ namespace UnitarySystems { bool m_CoolCoilExists = false; int m_CoolingCoilType_Num = 0; int m_NumOfSpeedCooling = 0; - int m_CoolingCoilAvailSchPtr = 0; + Sched::Schedule *m_coolingCoilAvailSched = nullptr; Real64 m_DesignCoolingCapacity = 0.0; Real64 m_MaxCoolAirVolFlow = 0.0; int m_CondenserNodeNum = 0; @@ -947,7 +947,7 @@ namespace UnitarySystems { int getEquipIndex() override; UnitarySys() = default; - ~UnitarySys() = default; + virtual ~UnitarySys() = default; }; int getDesignSpecMSHPIndex(EnergyPlusData &state, std::string_view objectName); @@ -1013,6 +1013,10 @@ struct UnitarySystemsData : BaseGlobalStruct bool getInputFlag = true; bool setupOutputOnce = true; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/UserDefinedComponents.hh b/src/EnergyPlus/UserDefinedComponents.hh index db9721013ac..1c37babc274 100644 --- a/src/EnergyPlus/UserDefinedComponents.hh +++ b/src/EnergyPlus/UserDefinedComponents.hh @@ -365,6 +365,10 @@ struct UserDefinedComponentsData : BaseGlobalStruct bool lDummy_EMSActuatedPlantComp = false; bool lDummy_GetUserDefComp = false; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/UtilityRoutines.cc b/src/EnergyPlus/UtilityRoutines.cc index e68b2f8047a..b99401f8191 100644 --- a/src/EnergyPlus/UtilityRoutines.cc +++ b/src/EnergyPlus/UtilityRoutines.cc @@ -1764,6 +1764,19 @@ void ShowSevereItemNotFound(EnergyPlusData &state, ErrorObjectHeader const &eoh, ShowContinueError(state, format("{} = {}, item not found.", fieldName, fieldVal)); } +void ShowSevereItemNotFoundAudit(EnergyPlusData &state, ErrorObjectHeader const &eoh, std::string_view fieldName, std::string_view fieldVal) +{ + ShowSevereError(state, format("{}: {} = {}", eoh.routineName, eoh.objectType, eoh.objectName), OptionalOutputFileRef{state.files.audit}); + ShowContinueError(state, format("{} = {}, item not found.", fieldName, fieldVal), OptionalOutputFileRef{state.files.audit}); +} + +void ShowSevereDuplicateAssignment(EnergyPlusData &state, ErrorObjectHeader const &eoh, std::string_view fieldName, std::string_view fieldVal, std::string_view prevVal) +{ + ShowSevereError(state, format("{}: {} = {}", eoh.routineName, eoh.objectType, eoh.objectName)); + ShowContinueError(state, format("{} = {}, field previously assigned to {}.", fieldName, fieldVal, prevVal)); +} + + void ShowSevereInvalidKey( EnergyPlusData &state, ErrorObjectHeader const &eoh, std::string_view fieldName, std::string_view fieldVal, std::string_view msg) { @@ -1778,24 +1791,67 @@ void ShowSevereInvalidBool(EnergyPlusData &state, ErrorObjectHeader const &eoh, ShowContinueError(state, format("{} = {}, invalid boolean (\"Yes\"/\"No\").", fieldName, fieldVal)); } -void ShowSevereCustomMessage(EnergyPlusData &state, ErrorObjectHeader const &eoh, std::string_view msg) +void ShowSevereCustom(EnergyPlusData &state, ErrorObjectHeader const &eoh, std::string_view msg) { ShowSevereError(state, format("{}: {} = {}", eoh.routineName, eoh.objectType, eoh.objectName)); ShowContinueError(state, format("{}", msg)); } +void ShowSevereCustomAudit(EnergyPlusData &state, ErrorObjectHeader const &eoh, std::string_view msg) +{ + ShowSevereError(state, format("{}: {} = {}", eoh.routineName, eoh.objectType, eoh.objectName), OptionalOutputFileRef{state.files.audit}); + ShowContinueError(state, format("{}", msg), OptionalOutputFileRef{state.files.audit}); +} + + +void ShowSevereCustomField(EnergyPlusData &state, ErrorObjectHeader const &eoh, std::string_view fieldName, std::string_view fieldValue, std::string_view msg) +{ + ShowSevereError(state, format("{}: {} = {}", eoh.routineName, eoh.objectType, eoh.objectName)); + ShowContinueError(state, format("{} = {}, {}", fieldName, fieldValue, msg)); +} + +void ShowSevereBadMin(EnergyPlusData &state, ErrorObjectHeader const &eoh, std::string_view fieldName, Real64 fieldVal, Clusive cluMin, Real64 minVal, std::string_view msg) +{ + ShowSevereError(state, format("{}: {} = {}", eoh.routineName, eoh.objectType, eoh.objectName)); + ShowContinueError(state, format("{} = {}, but must be {} {}", fieldName, fieldVal, cluMin == Clusive::In ? ">=" : ">", minVal)); + if (!msg.empty()) ShowContinueError(state, format("{}", msg)); +} + +void ShowSevereBadMax(EnergyPlusData &state, ErrorObjectHeader const &eoh, std::string_view fieldName, Real64 fieldVal, Clusive cluMax, Real64 maxVal, std::string_view msg) +{ + ShowSevereError(state, format("{}: {} = {}", eoh.routineName, eoh.objectType, eoh.objectName)); + ShowContinueError(state, format("{} = {}, but must be {} {}", fieldName, fieldVal, cluMax == Clusive::In ? "<=" : "<", maxVal)); + if (!msg.empty()) ShowContinueError(state, format("{}", msg)); +} + +void ShowSevereBadMinMax(EnergyPlusData &state, ErrorObjectHeader const &eoh, std::string_view fieldName, Real64 fieldVal, Clusive cluMin, Real64 minVal, Clusive cluMax, Real64 maxVal, std::string_view msg) +{ + ShowSevereError(state, format("{}: {} = {}", eoh.routineName, eoh.objectType, eoh.objectName)); + ShowContinueError(state, format("{} = {}, but must be {} {} and {} {}", fieldName, fieldVal, + cluMin == Clusive::In ? ">=" : ">", minVal, + cluMax == Clusive::In ? "<=" : "<", maxVal)); + if (!msg.empty()) ShowContinueError(state, format("{}", msg)); +} + + void ShowWarningItemNotFound(EnergyPlusData &state, ErrorObjectHeader const &eoh, std::string_view fieldName, std::string_view fieldVal) { ShowWarningError(state, format("{}: {} = {}", eoh.routineName, eoh.objectType, eoh.objectName)); ShowContinueError(state, format("{} = {}, item not found", fieldName, fieldVal)); } -void ShowWarningCustomMessage(EnergyPlusData &state, ErrorObjectHeader const &eoh, std::string_view msg) +void ShowWarningCustom(EnergyPlusData &state, ErrorObjectHeader const &eoh, std::string_view msg) { ShowWarningError(state, format("{}: {} = {}", eoh.routineName, eoh.objectType, eoh.objectName)); ShowContinueError(state, format("{}", msg)); } +void ShowWarningCustomField(EnergyPlusData &state, ErrorObjectHeader const &eoh, std::string_view fieldName, std::string_view fieldValue, std::string_view msg) +{ + ShowWarningError(state, format("{}: {} = {}", eoh.routineName, eoh.objectType, eoh.objectName)); + ShowContinueError(state, format("{} = {}, {}", fieldName, fieldValue, msg)); +} + void ShowWarningInvalidKey(EnergyPlusData &state, ErrorObjectHeader const &eoh, std::string_view fieldName, @@ -1822,19 +1878,61 @@ void ShowWarningEmptyField(EnergyPlusData &state, std::string_view depFieldName, std::string_view depFieldVal) { - ShowSevereError(state, format("{}: {} = {}", eoh.routineName, eoh.objectType, eoh.objectName)); - ShowContinueError(state, - format("{} cannot be empty{}, {} will be used.", - fieldName, - depFieldName.empty() ? "" : format(" when {} = {}", depFieldName, depFieldVal), - defaultVal)); + ShowWarningError(state, format("{}: {} = {}", eoh.routineName, eoh.objectType, eoh.objectName)); + ShowContinueError(state, format("{} is empty.", fieldName)); + + if (!depFieldName.empty()) ShowContinueError(state, format("Cannot be empty when {} = {}", depFieldName, depFieldVal)); + if (!defaultVal.empty()) ShowContinueError(state, format("{} will be used.", defaultVal)); } +void ShowWarningNonEmptyField(EnergyPlusData &state, + ErrorObjectHeader const &eoh, + std::string_view fieldName, + std::string_view depFieldName, + std::string_view depFieldValue) +{ + ShowWarningError(state, format("{}: {} = {}", eoh.routineName, eoh.objectType, eoh.objectName)); + ShowContinueError(state, format("{} is not empty.", fieldName)); + if (!depFieldName.empty()) ShowContinueError(state, format("{} is ignored when {} = {}.", fieldName, depFieldName, depFieldValue)); +} + + void ShowWarningItemNotFound( EnergyPlusData &state, ErrorObjectHeader const &eoh, std::string_view fieldName, std::string_view fieldVal, std::string_view defaultVal) { - ShowSevereError(state, format("{}: {} = {}", eoh.routineName, eoh.objectType, eoh.objectName)); - ShowContinueError(state, format("{} = {}, item not found, {} will be used.", fieldName, fieldVal, defaultVal)); + ShowWarningError(state, format("{}: {} = {}", eoh.routineName, eoh.objectType, eoh.objectName)); + if (defaultVal.empty()) { + ShowContinueError(state, format("{} = {}, item not found.", fieldName, fieldVal)); + } else { + ShowContinueError(state, format("{} = {}, item not found, {} will be used.", fieldName, fieldVal, defaultVal)); + } } +void ShowWarningBadMin(EnergyPlusData &state, ErrorObjectHeader const &eoh, std::string_view fieldName, Real64 fieldVal, Clusive cluMin, Real64 minVal, std::string_view msg) +{ + ShowWarningError(state, format("{}: {} = {}", eoh.routineName, eoh.objectType, eoh.objectName)); + ShowContinueError(state, format("{} = {}, but must be {} {}", fieldName, fieldVal, + cluMin == Clusive::In ? ">=" : ">", minVal)); + if (!msg.empty()) ShowContinueError(state, format("{}", msg)); +} + +void ShowWarningBadMax(EnergyPlusData &state, ErrorObjectHeader const &eoh, std::string_view fieldName, Real64 fieldVal, Clusive cluMax, Real64 maxVal, std::string_view msg) +{ + ShowWarningError(state, format("{}: {} = {}", eoh.routineName, eoh.objectType, eoh.objectName)); + ShowContinueError(state, format("{} = {}, but must be {} {}", fieldName, fieldVal, + cluMax == Clusive::In ? "<=" : "<", maxVal)); + ShowContinueError(state, format("{} = {}, but must be {} {}", fieldName, fieldVal, + cluMax == Clusive::In ? "<=" : "<", maxVal)); + if (!msg.empty()) ShowContinueError(state, format("{}", msg)); +} + +void ShowWarningBadMinMax(EnergyPlusData &state, ErrorObjectHeader const &eoh, std::string_view fieldName, Real64 fieldVal, Clusive cluMin, Real64 minVal, Clusive cluMax, Real64 maxVal, std::string_view msg) +{ + ShowWarningError(state, format("{}: {} = {}", eoh.routineName, eoh.objectType, eoh.objectName)); + ShowContinueError(state, format("{} = {}, but must be {} {} and {} {}", fieldName, fieldVal, + cluMin == Clusive::In ? ">=" : ">", minVal, + cluMax == Clusive::In ? "<=" : "<", maxVal)); + if (!msg.empty()) ShowContinueError(state, format("{}", msg)); +} + } // namespace EnergyPlus diff --git a/src/EnergyPlus/UtilityRoutines.hh b/src/EnergyPlus/UtilityRoutines.hh index e6bd1877768..b54b4a29827 100644 --- a/src/EnergyPlus/UtilityRoutines.hh +++ b/src/EnergyPlus/UtilityRoutines.hh @@ -286,20 +286,47 @@ void ShowSevereEmptyField(EnergyPlusData &state, std::string_view depFieldName = {}, std::string_view depFieldValue = {}); void ShowSevereItemNotFound(EnergyPlusData &state, ErrorObjectHeader const &eoh, std::string_view fieldName, std::string_view fieldValue); +void ShowSevereItemNotFoundAudit(EnergyPlusData &state, ErrorObjectHeader const &eoh, std::string_view fieldName, std::string_view fieldValue); + +void ShowSevereDuplicateAssignment(EnergyPlusData &state, ErrorObjectHeader const &eoh, std::string_view fieldName, std::string_view fieldValue, std::string_view prevValue); + void ShowSevereInvalidKey( EnergyPlusData &state, ErrorObjectHeader const &eoh, std::string_view fieldName, std::string_view fieldValue, std::string_view msg = {}); void ShowSevereInvalidBool(EnergyPlusData &state, ErrorObjectHeader const &eoh, std::string_view fieldName, std::string_view fieldValue); -void ShowSevereCustomMessage(EnergyPlusData &state, ErrorObjectHeader const &eoh, std::string_view msg); +void ShowSevereCustom(EnergyPlusData &state, ErrorObjectHeader const &eoh, std::string_view msg); +void ShowSevereCustomField(EnergyPlusData &state, ErrorObjectHeader const &eoh, std::string_view fieldName, std::string_view fieldValue, std::string_view msg); + +void ShowSevereCustomAudit(EnergyPlusData &state, ErrorObjectHeader const &eoh, std::string_view msg); + +enum class Clusive +{ + Invalid = -1, + In, + Ex, + Num +}; + +void ShowSevereBadMin(EnergyPlusData &state, ErrorObjectHeader const &eoh, std::string_view fieldName, Real64 fieldVal, Clusive cluMin, Real64 minVal, std::string_view msg = {}); +void ShowSevereBadMax(EnergyPlusData &state, ErrorObjectHeader const &eoh, std::string_view fieldName, Real64 fieldVal, Clusive cluMin, Real64 maxVal, std::string_view msg = {}); +void ShowSevereBadMinMax(EnergyPlusData &state, ErrorObjectHeader const &eoh, std::string_view fieldName, Real64 fieldVal, Clusive cluMin, Real64 minVal, Clusive cluMax, Real64 maxVal, std::string_view msg = {}); + void ShowWarningDuplicateName(EnergyPlusData &state, ErrorObjectHeader const &eoh); void ShowWarningEmptyField(EnergyPlusData &state, ErrorObjectHeader const &eoh, std::string_view fieldName, - std::string_view defaultValue, + std::string_view defaultValue = {}, std::string_view depFieldName = {}, std::string_view depFieldValue = {}); + +void ShowWarningNonEmptyField(EnergyPlusData &state, + ErrorObjectHeader const &eoh, + std::string_view fieldName, + std::string_view depFieldName = {}, + std::string_view depFieldValue = {}); + void ShowWarningItemNotFound( - EnergyPlusData &state, ErrorObjectHeader const &eoh, std::string_view fieldName, std::string_view fieldValue, std::string_view defaultValue); + EnergyPlusData &state, ErrorObjectHeader const &eoh, std::string_view fieldName, std::string_view fieldValue, std::string_view defaultValue = {}); void ShowWarningInvalidKey(EnergyPlusData &state, ErrorObjectHeader const &eoh, std::string_view fieldName, @@ -308,7 +335,8 @@ void ShowWarningInvalidKey(EnergyPlusData &state, std::string_view msg = {}); void ShowWarningInvalidBool( EnergyPlusData &state, ErrorObjectHeader const &eoh, std::string_view fieldName, std::string_view fieldValue, std::string_view defaultValue); -void ShowWarningCustomMessage(EnergyPlusData &state, ErrorObjectHeader const &eoh, std::string_view msg); +void ShowWarningCustom(EnergyPlusData &state, ErrorObjectHeader const &eoh, std::string_view msg); +void ShowWarningCustomField(EnergyPlusData &state, ErrorObjectHeader const &eoh, std::string_view fieldName, std::string_view fieldValue, std::string_view msg); namespace Util { @@ -334,6 +362,16 @@ namespace Util { return Util::FindItemInList(String, ListOfItems, ListOfItems.isize()); } + inline int FindIntInList(Array1_int &list, int item) { + auto it = std::find(list.begin(), list.end(), item); + return (it == list.end()) ? -1 : (it - list.begin()); + } + + inline int FindIntInList(std::vector &list, int item) { + auto it = std::find(list.begin(), list.end(), item); + return (it == list.end()) ? -1 : (it - list.begin()); + } + int FindItemInList(std::string_view const String, Array1S_string const ListOfItems, int NumItems); template int FindItemInList(std::string_view const str, InputIterator first, InputIterator last) @@ -765,6 +803,10 @@ struct UtilityRoutinesData : BaseGlobalStruct std::string appendPerfLog_valuesRow; bool GetMatrixInputFlag = true; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/VariableSpeedCoils.cc b/src/EnergyPlus/VariableSpeedCoils.cc index 324a94c8872..e897511d221 100644 --- a/src/EnergyPlus/VariableSpeedCoils.cc +++ b/src/EnergyPlus/VariableSpeedCoils.cc @@ -234,12 +234,12 @@ namespace VariableSpeedCoils { using Curve::GetCurveIndex; using OutAirNodeManager::CheckOutAirNodeNumber; - using ScheduleManager::GetScheduleIndex; using WaterManager::SetupTankDemandComponent; using WaterManager::SetupTankSupplyComponent; // SUBROUTINE PARAMETER DEFINITIONS: static constexpr std::string_view RoutineName("GetVarSpeedCoilInput: "); // include trailing blank space + static constexpr std::string_view routineName = "GetVarSpeedCoilInput"; // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int DXCoilNum; // The Water to Air HP that you are currently loading input into @@ -890,6 +890,9 @@ namespace VariableSpeedCoils { lAlphaBlanks, cAlphaFields, cNumericFields); + + ErrorObjectHeader eoh{routineName, CurrentModuleObject, AlphArray(1)}; + // ErrorsFound will be set to True if problem was found, left untouched otherwise VerifyUniqueCoilName(state, CurrentModuleObject, AlphArray(1), ErrorsFound, CurrentModuleObject + " Name"); @@ -1128,15 +1131,10 @@ namespace VariableSpeedCoils { } } - if (!lAlphaBlanks(10)) { - state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).BasinHeaterSchedulePtr = GetScheduleIndex(state, AlphArray(10)); - if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).BasinHeaterSchedulePtr == 0) { - ShowWarningError( - state, - format("{}{}=\"{}\", invalid", RoutineName, CurrentModuleObject, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name)); - ShowContinueError(state, format("...not found {}=\"{}\".", cAlphaFields(10), AlphArray(10))); - ShowContinueError(state, "Basin heater will be available to operate throughout the simulation."); - } + if (lAlphaBlanks(10)) { + } else if ((state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).basinHeaterSched = Sched::GetSchedule(state, AlphArray(10))) == nullptr) { + ShowWarningItemNotFound(state, eoh, cAlphaFields(10), AlphArray(10), + "Basin heater will be available to operate throughout the simulation."); } for (I = 1; I <= state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds; ++I) { @@ -6452,7 +6450,7 @@ namespace VariableSpeedCoils { // Calculate basin heater power CalcBasinHeaterPower(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).BasinHeaterPowerFTempDiff, - state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).BasinHeaterSchedulePtr, + state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).basinHeaterSched, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).BasinHeaterSetPointTemp, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).BasinHeaterPower); state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).BasinHeaterPower *= diff --git a/src/EnergyPlus/VariableSpeedCoils.hh b/src/EnergyPlus/VariableSpeedCoils.hh index 75b4f39f728..162ba2cfb3f 100644 --- a/src/EnergyPlus/VariableSpeedCoils.hh +++ b/src/EnergyPlus/VariableSpeedCoils.hh @@ -230,7 +230,7 @@ namespace VariableSpeedCoils { Real64 BasinHeaterPowerFTempDiff; // Basin heater capacity per degree C below setpoint (W/C) Real64 BasinHeaterSetPointTemp; // setpoint temperature for basin heater operation (C) Real64 BasinHeaterPower; // Basin heater power (W) - int BasinHeaterSchedulePtr; // Pointer to basin heater schedule + Sched::Schedule *basinHeaterSched = nullptr; // basin heater schedule Array1D EvapCondAirFlow; // Air flow rate through the evap condenser at high speed, volumetric flow rate // for water use calcs [m3/s] Array1D EvapCondEffect; // effectiveness of the evaporatively cooled condenser @@ -312,7 +312,7 @@ namespace VariableSpeedCoils { CondenserType(DataHeatBalance::RefrigCondenserType::Air), ReportEvapCondVars(false), EvapCondPumpElecNomPower(0.0), EvapCondPumpElecPower(0.0), EvapWaterConsumpRate(0.0), EvapCondPumpElecConsumption(0.0), EvapWaterConsump(0.0), BasinHeaterConsumption(0.0), BasinHeaterPowerFTempDiff(0.0), BasinHeaterSetPointTemp(0.0), BasinHeaterPower(0.0), - BasinHeaterSchedulePtr(0), EvapCondAirFlow(HVAC::MaxSpeedLevels, 0.0), EvapCondEffect(HVAC::MaxSpeedLevels, 0.0), + EvapCondAirFlow(HVAC::MaxSpeedLevels, 0.0), EvapCondEffect(HVAC::MaxSpeedLevels, 0.0), MSRatedEvapCondVolFlowPerRatedTotCap(HVAC::MaxSpeedLevels, 0.0), EvapWaterSupplyMode(101), EvapWaterSupTankID(0), EvapWaterTankDemandARRID(0), CondensateCollectMode(1001), CondensateTankID(0), CondensateTankSupplyARRID(0), CondensateVdot(0.0), CondensateVol(0.0), CondInletTemp(0.0), SupplyFanIndex(0), supplyFanType(HVAC::FanType::Invalid), SourceAirMassFlowRate(0.0), @@ -581,6 +581,10 @@ struct VariableSpeedCoilsData : BaseGlobalStruct Real64 CrankcaseHeatingPower_CalcVarSpeedCoilCooling = 0.0; // power due to crankcase heater Real64 CompAmbTemp_CalcVarSpeedCoilCooling = 0.0; // Ambient temperature at compressor + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/Vectors.cc b/src/EnergyPlus/Vectors.cc index 7317f6ffd62..6e5277f50b6 100644 --- a/src/EnergyPlus/Vectors.cc +++ b/src/EnergyPlus/Vectors.cc @@ -262,11 +262,11 @@ void DetermineAzimuthAndTilt(Array1D const &Surf, // Surface Definition } Real64 tlt = std::acos(NewellSurfaceNormalVector.z); - tlt /= Constant::DegToRadians; + tlt /= Constant::DegToRad; Real64 az = rotang_0; - az /= Constant::DegToRadians; + az /= Constant::DegToRad; az = mod(450.0 - az, 360.0); az += 90.0; if (az < 0.0) az += 360.0; diff --git a/src/EnergyPlus/Vectors.hh b/src/EnergyPlus/Vectors.hh index 7361482fd93..7d17e45c132 100644 --- a/src/EnergyPlus/Vectors.hh +++ b/src/EnergyPlus/Vectors.hh @@ -131,6 +131,10 @@ struct VectorsData : BaseGlobalStruct { Vectors::Vector p0 = Vectors::Vector(0.0, 0.0, 0.0); + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/VentilatedSlab.cc b/src/EnergyPlus/VentilatedSlab.cc index 5977ddd2751..6984424ab93 100644 --- a/src/EnergyPlus/VentilatedSlab.cc +++ b/src/EnergyPlus/VentilatedSlab.cc @@ -122,7 +122,6 @@ namespace VentilatedSlab { // Using/Aliasing using namespace DataLoopNode; using HVAC::SmallAirVolFlow; - using namespace ScheduleManager; using namespace Psychrometrics; static std::string const fluidNameSteam("STEAM"); @@ -230,7 +229,6 @@ namespace VentilatedSlab { auto &GetSteamCoilMaxFlowRate(SteamCoils::GetCoilMaxWaterFlowRate); auto &GetHXAssistedCoilFlowRate(HVACHXAssistedCoolingCoil::GetCoilMaxWaterFlowRate); using HVACHXAssistedCoolingCoil::GetHXCoilTypeAndName; - using ScheduleManager::GetScheduleIndex; using namespace DataLoopNode; using namespace DataSurfaceLists; @@ -329,14 +327,9 @@ namespace VentilatedSlab { ventSlab.Name = state.dataIPShortCut->cAlphaArgs(1); if (lAlphaBlanks(2)) { - ventSlab.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else if ((ventSlab.SchedPtr = GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(2))) == 0) { // convert schedule name to pointer - ShowSevereError(state, - format(R"({}="{}" invalid {}="{}" not found.)", - CurrentModuleObject, - ventSlab.Name, - cAlphaFields(2), - state.dataIPShortCut->cAlphaArgs(2))); + ventSlab.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((ventSlab.availSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(2), state.dataIPShortCut->cAlphaArgs(2)); ErrorsFound = true; } @@ -488,88 +481,62 @@ namespace VentilatedSlab { static_cast(getEnumValue(OutsideAirControlTypeNamesUC, Util::makeUPPER(state.dataIPShortCut->cAlphaArgs(5)))); switch (ventSlab.outsideAirControlType) { + case OutsideAirControlType::VariablePercent: { - ventSlab.MaxOASchedPtr = GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(7)); // convert schedule name to pointer - if (ventSlab.MaxOASchedPtr == 0) { - ShowSevereError(state, - format(R"({}="{}" invalid {}="{}" not found.)", - CurrentModuleObject, - ventSlab.Name, - cAlphaFields(7), - state.dataIPShortCut->cAlphaArgs(7))); + if (lAlphaBlanks(7)) { + ShowSevereEmptyField(state, eoh, state.dataIPShortCut->cAlphaFieldNames(7)); ErrorsFound = true; - } else if (!CheckScheduleValueMinMax(state, ventSlab.MaxOASchedPtr, ">=", 0.0, "<=", 1.0)) { - ShowSevereError(state, - format("{}=\"{}\" invalid {}=\"{}\" values out of range [0,1].", - CurrentModuleObject, - ventSlab.Name, - cAlphaFields(7), - state.dataIPShortCut->cAlphaArgs(7))); + } else if ((ventSlab.maxOASched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(7))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(7), state.dataIPShortCut->cAlphaArgs(7)); + ErrorsFound = true; + } else if (!ventSlab.maxOASched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) { + Sched::ShowSevereBadMinMax(state, eoh, cAlphaFields(7), state.dataIPShortCut->cAlphaArgs(7), + Clusive::In, 0.0, Clusive::In, 1.0); ErrorsFound = true; } - break; - } + } break; + case OutsideAirControlType::FixedOAControl: { - ventSlab.MaxOASchedPtr = GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(7)); // convert schedule name to pointer - if (ventSlab.MaxOASchedPtr == 0) { - ShowSevereError(state, - format(R"({}="{}" invalid {}="{}" not found.)", - CurrentModuleObject, - ventSlab.Name, - cAlphaFields(7), - state.dataIPShortCut->cAlphaArgs(7))); + + if (lAlphaBlanks(7)) { + ShowSevereEmptyField(state, eoh, state.dataIPShortCut->cAlphaFieldNames(7)); ErrorsFound = true; - } else if (!CheckScheduleValueMinMax(state, ventSlab.MaxOASchedPtr, true, 0.0)) { - ShowSevereError(state, - format("{}=\"{}\" invalid {}=\"{}\" values out of range (must be >=0).", - CurrentModuleObject, - ventSlab.Name, - cAlphaFields(7), - state.dataIPShortCut->cAlphaArgs(7))); + } else if ((ventSlab.maxOASched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(7))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(7), state.dataIPShortCut->cAlphaArgs(7)); + ErrorsFound = true; + } else if (!ventSlab.maxOASched->checkMinVal(state, Clusive::In, 0.0)) { + Sched::ShowSevereBadMin(state, eoh, cAlphaFields(7), state.dataIPShortCut->cAlphaArgs(7), Clusive::In, 0.0); ErrorsFound = true; } - break; - } + } break; + case OutsideAirControlType::FixedTemperature: { - ventSlab.TempSchedPtr = GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(7)); // convert schedule name to pointer - if (ventSlab.TempSchedPtr == 0) { - ShowSevereError(state, - format(R"({}="{}" invalid {}="{}" not found.)", - CurrentModuleObject, - ventSlab.Name, - cAlphaFields(7), - state.dataIPShortCut->cAlphaArgs(7))); + if (lAlphaBlanks(7)) { + ShowSevereEmptyField(state, eoh, cAlphaFields(7)); + ErrorsFound = true; + } else if ((ventSlab.tempSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(7))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(7), state.dataIPShortCut->cAlphaArgs(7)); ErrorsFound = true; } - break; - } + } break; + default: { ShowSevereError( state, format(R"({}="{}" invalid {}="{}".)", CurrentModuleObject, ventSlab.Name, cAlphaFields(5), state.dataIPShortCut->cAlphaArgs(5))); - } - } + } break; + } // switch (outsideAirControlType) - ventSlab.MinOASchedPtr = GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(6)); // convert schedule name to pointer - if (ventSlab.MinOASchedPtr == 0) { - ShowSevereError(state, - format(R"({}="{}" invalid {}="{}" not found.)", - CurrentModuleObject, - ventSlab.Name, - cAlphaFields(6), - state.dataIPShortCut->cAlphaArgs(6))); + if (lAlphaBlanks(6)) { + } else if ((ventSlab.minOASched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(6))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(6), state.dataIPShortCut->cAlphaArgs(6)); ErrorsFound = true; } // System Configuration: - ventSlab.SysConfg = - static_cast(getEnumValue(VentilatedSlabConfigNamesUC, Util::makeUPPER(state.dataIPShortCut->cAlphaArgs(8)))); - + ventSlab.SysConfg = static_cast(getEnumValue(VentilatedSlabConfigNamesUC, state.dataIPShortCut->cAlphaArgs(8))); if (ventSlab.SysConfg == VentilatedSlabConfig::Invalid) { - ShowSevereError( - state, - format(R"({}="{}" invalid {}="{}".)", CurrentModuleObject, ventSlab.Name, cAlphaFields(8), state.dataIPShortCut->cAlphaArgs(8))); - ShowContinueError(state, "Control reset to SLAB ONLY Configuration."); + ShowWarningInvalidKey(state, eoh, cAlphaFields(8), state.dataIPShortCut->cAlphaArgs(8), "Control reset to SLAB ONLY Configuration."); ventSlab.SysConfg = VentilatedSlabConfig::SlabOnly; } @@ -622,101 +589,58 @@ namespace VentilatedSlab { // Heating User Input Data For Ventilated Slab Control : // High Air Temp : - ventSlab.HotAirHiTempSchedPtr = GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(10)); - if ((ventSlab.HotAirHiTempSchedPtr == 0) && (!lAlphaBlanks(10))) { - ShowSevereError(state, - format(R"({}="{}" invalid {}="{}" not found.)", - CurrentModuleObject, - ventSlab.Name, - cAlphaFields(10), - state.dataIPShortCut->cAlphaArgs(10))); + if (lAlphaBlanks(10)) { + } else if ((ventSlab.hotAirHiTempSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(10))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(10), state.dataIPShortCut->cAlphaArgs(10)); ErrorsFound = true; } // Low Air Temp : - - ventSlab.HotAirLoTempSchedPtr = GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(11)); - if ((ventSlab.HotAirLoTempSchedPtr == 0) && (!lAlphaBlanks(11))) { - ShowSevereError(state, - format(R"({}="{}" invalid {}="{}" not found.)", - CurrentModuleObject, - ventSlab.Name, - cAlphaFields(11), - state.dataIPShortCut->cAlphaArgs(11))); + if (lAlphaBlanks(11)) { + } else if ((ventSlab.hotAirLoTempSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(11))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(11), state.dataIPShortCut->cAlphaArgs(11)); ErrorsFound = true; } - ventSlab.HotCtrlHiTempSchedPtr = GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(12)); - if ((ventSlab.HotCtrlHiTempSchedPtr == 0) && (!lAlphaBlanks(12))) { - ShowSevereError(state, - format(R"({}="{}" invalid {}="{}" not found.)", - CurrentModuleObject, - ventSlab.Name, - cAlphaFields(12), - state.dataIPShortCut->cAlphaArgs(12))); + if (lAlphaBlanks(12)) { + } else if ((ventSlab.hotCtrlHiTempSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(12))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(12), state.dataIPShortCut->cAlphaArgs(12)); ErrorsFound = true; } - ventSlab.HotCtrlLoTempSchedPtr = GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(13)); - if ((ventSlab.HotCtrlLoTempSchedPtr == 0) && (!lAlphaBlanks(13))) { - ShowSevereError(state, - format(R"({}="{}" invalid {}="{}" not found.)", - CurrentModuleObject, - ventSlab.Name, - cAlphaFields(13), - state.dataIPShortCut->cAlphaArgs(13))); + if (lAlphaBlanks(13)) { + } else if ((ventSlab.hotCtrlLoTempSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(13))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(13), state.dataIPShortCut->cAlphaArgs(13)); ErrorsFound = true; } // Cooling User Input Data For Ventilated Slab Control : // Cooling High Temp Sch. - ventSlab.ColdAirHiTempSchedPtr = GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(14)); - if ((ventSlab.ColdAirHiTempSchedPtr == 0) && (!lAlphaBlanks(14))) { - ShowSevereError(state, - format(R"({}="{}" invalid {}="{}" not found.)", - CurrentModuleObject, - ventSlab.Name, - cAlphaFields(14), - state.dataIPShortCut->cAlphaArgs(14))); + if (lAlphaBlanks(14)) { + } else if ((ventSlab.coldAirHiTempSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(14))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(14), state.dataIPShortCut->cAlphaArgs(14)); ErrorsFound = true; } // Cooling Low Temp Sch. - - ventSlab.ColdAirLoTempSchedPtr = GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(15)); - if ((ventSlab.ColdAirLoTempSchedPtr == 0) && (!lAlphaBlanks(15))) { - ShowSevereError(state, - format(R"({}="{}" invalid {}="{}" not found.)", - CurrentModuleObject, - ventSlab.Name, - cAlphaFields(15), - state.dataIPShortCut->cAlphaArgs(15))); + if (lAlphaBlanks(15)) { + } else if ((ventSlab.coldAirLoTempSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(15))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(15), state.dataIPShortCut->cAlphaArgs(15)); ErrorsFound = true; } // Cooling Control High Sch. - ventSlab.ColdCtrlHiTempSchedPtr = GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(16)); - if ((ventSlab.ColdCtrlHiTempSchedPtr == 0) && (!lAlphaBlanks(16))) { - ShowSevereError(state, - format(R"({}="{}" invalid {}="{}" not found.)", - CurrentModuleObject, - ventSlab.Name, - cAlphaFields(16), - state.dataIPShortCut->cAlphaArgs(16))); + if (lAlphaBlanks(16)) { + } else if ((ventSlab.coldCtrlHiTempSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(16))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(16), state.dataIPShortCut->cAlphaArgs(16)); ErrorsFound = true; } // Cooling Control Low Sch. - - ventSlab.ColdCtrlLoTempSchedPtr = GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(17)); - if ((ventSlab.ColdCtrlLoTempSchedPtr == 0) && (!lAlphaBlanks(17))) { - ShowSevereError(state, - format(R"({}="{}" invalid {}="{}" not found.)", - CurrentModuleObject, - ventSlab.Name, - cAlphaFields(17), - state.dataIPShortCut->cAlphaArgs(17))); + if (lAlphaBlanks(17)) { + } else if ((ventSlab.coldCtrlLoTempSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(17))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(17), state.dataIPShortCut->cAlphaArgs(17)); ErrorsFound = true; } @@ -987,17 +911,17 @@ namespace VentilatedSlab { } else { ventSlab.fanType = state.dataFans->fans(ventSlab.Fan_Index)->type; if (ventSlab.fanType != HVAC::FanType::Constant && ventSlab.fanType != HVAC::FanType::SystemModel) { - ShowSevereCustomMessage(state, - eoh, - format("Only fans of type Fan:ConstantVolume and Fan:SystemModel are supported. {} is of type {}", - ventSlab.FanName, - HVAC::fanTypeNames[(int)ventSlab.fanType])); + ShowSevereCustom(state, + eoh, + format("Only fans of type Fan:ConstantVolume and Fan:SystemModel are supported. {} is of type {}", + ventSlab.FanName, + HVAC::fanTypeNames[(int)ventSlab.fanType])); ErrorsFound = true; } } if (ventSlab.outsideAirControlType == OutsideAirControlType::FixedOAControl) { ventSlab.OutAirVolFlow = ventSlab.MinOutAirVolFlow; - ventSlab.MaxOASchedPtr = ventSlab.MinOASchedPtr; + ventSlab.maxOASched = ventSlab.minOASched; } // Add fan to component sets array @@ -1521,7 +1445,6 @@ namespace VentilatedSlab { using FluidProperties::GetDensityGlycol; using PlantUtilities::InitComponentNodes; using PlantUtilities::ScanPlantLoopsForObject; - using ScheduleManager::GetCurrentScheduleValue; // Locals // SUBROUTINE ARGUMENT DEFINITIONS: @@ -2617,7 +2540,6 @@ namespace VentilatedSlab { using HeatingCoils::CheckHeatingCoilSchedule; using HVACHXAssistedCoolingCoil::CheckHXAssistedCoolingCoilSchedule; using NodeInputManager::GetOnlySingleNode; - using ScheduleManager::GetCurrentScheduleValue; using SteamCoils::CheckSteamCoilSchedule; using WaterCoils::CheckWaterCoilSchedule; @@ -2833,15 +2755,15 @@ namespace VentilatedSlab { SetPointTemp = 0.0; // Suppress uninitialized warning ShowSevereError(state, format("Illegal control type in low temperature radiant system: {}", ventSlab.Name)); ShowFatalError(state, "Preceding condition causes termination."); - } - } + } break; + } // switch (ctrlType) // Load Check - AirTempHeatHi = GetCurrentScheduleValue(state, ventSlab.HotCtrlHiTempSchedPtr); - AirTempCoolLo = GetCurrentScheduleValue(state, ventSlab.ColdCtrlLoTempSchedPtr); + AirTempHeatHi = ventSlab.hotCtrlHiTempSched->getCurrentVal(); + AirTempCoolLo = ventSlab.coldCtrlLoTempSched->getCurrentVal(); - if (((SetPointTemp >= AirTempHeatHi) && (SetPointTemp <= AirTempCoolLo)) || (GetCurrentScheduleValue(state, ventSlab.SchedPtr) <= 0)) { + if (((SetPointTemp >= AirTempHeatHi) && (SetPointTemp <= AirTempCoolLo)) || (ventSlab.availSched->getCurrentVal() <= 0)) { // System is off or has no load upon it; set the flow rates to zero and then // simulate the components with the no flow conditions @@ -2914,15 +2836,15 @@ namespace VentilatedSlab { state.dataVentilatedSlab->OperatingMode = HeatingMode; // Check the setpoint and temperature span - SetPointTempHi = GetCurrentScheduleValue(state, ventSlab.HotCtrlHiTempSchedPtr); - SetPointTempLo = GetCurrentScheduleValue(state, ventSlab.HotCtrlLoTempSchedPtr); + SetPointTempHi = ventSlab.hotCtrlHiTempSched->getCurrentVal(); + SetPointTempLo = ventSlab.hotCtrlLoTempSched->getCurrentVal(); if (SetPointTempHi < SetPointTempLo) { ShowSevereError(state, format("Heating setpoint temperature mismatch in{}", ventSlab.Name)); ShowContinueError(state, "High setpoint temperature is less than low setpoint temperature--check your schedule input"); ShowFatalError(state, "Preceding condition causes termination."); } - AirTempHi = GetCurrentScheduleValue(state, ventSlab.HotAirHiTempSchedPtr); - AirTempLo = GetCurrentScheduleValue(state, ventSlab.HotAirLoTempSchedPtr); + AirTempHi = ventSlab.hotAirHiTempSched->getCurrentVal(); + AirTempLo = ventSlab.hotAirLoTempSched->getCurrentVal(); if (AirTempHi < AirTempLo) { ShowSevereError(state, format("Heating Air temperature mismatch in{}", ventSlab.Name)); @@ -2966,7 +2888,7 @@ namespace VentilatedSlab { state.dataVentilatedSlab->HCoilOn = true; if (state.dataLoopNodes->Node(OutsideAirNode).MassFlowRate > 0.0) { - MinOAFrac = GetCurrentScheduleValue(state, ventSlab.MinOASchedPtr) * + MinOAFrac = ventSlab.minOASched->getCurrentVal() * (ventSlab.MinOutAirMassFlow / state.dataLoopNodes->Node(OutsideAirNode).MassFlowRate); } else { MinOAFrac = 0.0; @@ -3008,14 +2930,14 @@ namespace VentilatedSlab { } else { // Tinlet < Toutdoor - MaxOAFrac = GetCurrentScheduleValue(state, ventSlab.MaxOASchedPtr); + MaxOAFrac = ventSlab.maxOASched->getCurrentVal(); state.dataVentilatedSlab->OAMassFlowRate = MaxOAFrac * state.dataLoopNodes->Node(OutsideAirNode).MassFlowRate; } break; } case OutsideAirControlType::FixedTemperature: { // This is basically the same algorithm as for the heating case... - Tdesired = GetCurrentScheduleValue(state, ventSlab.TempSchedPtr); + Tdesired = ventSlab.tempSched->getCurrentVal(); MaxOAFrac = 1.0; if (std::abs(Tinlet - Toutdoor) <= LowTempDiff) { // no difference in indoor and outdoor conditions-->set OA to minimum @@ -3068,7 +2990,7 @@ namespace VentilatedSlab { // In this control type, the outdoor air flow rate is fixed to the maximum value // which is equal to the minimum value, regardless of all the other conditions. if (state.dataLoopNodes->Node(OutsideAirNode).MassFlowRate > 0.0) { - MaxOAFrac = GetCurrentScheduleValue(state, ventSlab.MaxOASchedPtr); + MaxOAFrac = ventSlab.maxOASched->getCurrentVal(); } else { MaxOAFrac = 0.0; } @@ -3085,7 +3007,7 @@ namespace VentilatedSlab { } case OutsideAirControlType::FixedTemperature: { // This is basically the same algorithm as for the heating case... - Tdesired = GetCurrentScheduleValue(state, ventSlab.TempSchedPtr); + Tdesired = ventSlab.tempSched->getCurrentVal(); MaxOAFrac = 1.0; if (std::abs(Tinlet - Toutdoor) <= LowTempDiff) { // no difference in indoor and outdoor conditions-->set OA to minimum @@ -3180,16 +3102,16 @@ namespace VentilatedSlab { state.dataVentilatedSlab->OperatingMode = CoolingMode; - SetPointTempHi = GetCurrentScheduleValue(state, ventSlab.ColdCtrlHiTempSchedPtr); - SetPointTempLo = GetCurrentScheduleValue(state, ventSlab.ColdCtrlLoTempSchedPtr); + SetPointTempHi = ventSlab.coldCtrlHiTempSched->getCurrentVal(); + SetPointTempLo = ventSlab.coldCtrlLoTempSched->getCurrentVal(); if (SetPointTempHi < SetPointTempLo) { ShowSevereError(state, format("Cooling setpoint temperature mismatch in{}", ventSlab.Name)); ShowContinueError(state, "High setpoint temperature is less than low setpoint temperature--check your schedule input"); ShowFatalError(state, "Preceding condition causes termination."); } - AirTempHi = GetCurrentScheduleValue(state, ventSlab.ColdAirHiTempSchedPtr); - AirTempLo = GetCurrentScheduleValue(state, ventSlab.ColdAirLoTempSchedPtr); + AirTempHi = ventSlab.coldAirHiTempSched->getCurrentVal(); + AirTempLo = ventSlab.coldAirLoTempSched->getCurrentVal(); if (AirTempHi < AirTempLo) { ShowSevereError(state, format("Cooling Air temperature mismatch in{}", ventSlab.Name)); ShowContinueError(state, "High Air temperature is less than low Air temperature--check your schedule input"); @@ -3220,7 +3142,7 @@ namespace VentilatedSlab { state.dataVentilatedSlab->HCoilOn = false; if (state.dataLoopNodes->Node(OutsideAirNode).MassFlowRate > 0.0) { - MinOAFrac = GetCurrentScheduleValue(state, ventSlab.MinOASchedPtr) * + MinOAFrac = ventSlab.minOASched->getCurrentVal() * (ventSlab.MinOutAirMassFlow / state.dataLoopNodes->Node(OutsideAirNode).MassFlowRate); } else { MinOAFrac = 0.0; @@ -3243,7 +3165,7 @@ namespace VentilatedSlab { // In this control type, the outdoor air flow rate is fixed to the maximum value // which is equal to the minimum value, regardless of all the other conditions. if (state.dataLoopNodes->Node(OutsideAirNode).MassFlowRate > 0.0) { - MaxOAFrac = GetCurrentScheduleValue(state, ventSlab.MaxOASchedPtr); + MaxOAFrac = ventSlab.maxOASched->getCurrentVal(); } else { MaxOAFrac = 0.0; } @@ -3268,14 +3190,14 @@ namespace VentilatedSlab { } else { // Tinlet > Toutdoor - MaxOAFrac = GetCurrentScheduleValue(state, ventSlab.MaxOASchedPtr); + MaxOAFrac = ventSlab.maxOASched->getCurrentVal(); state.dataVentilatedSlab->OAMassFlowRate = MaxOAFrac * state.dataLoopNodes->Node(OutsideAirNode).MassFlowRate; } break; } case OutsideAirControlType::FixedTemperature: { // This is basically the same algorithm as for the heating case... - Tdesired = GetCurrentScheduleValue(state, ventSlab.TempSchedPtr); + Tdesired = ventSlab.tempSched->getCurrentVal(); MaxOAFrac = 1.0; if (std::abs(Tinlet - Toutdoor) <= LowTempDiff) { // no difference in indoor and outdoor conditions-->set OA to minimum @@ -3333,7 +3255,7 @@ namespace VentilatedSlab { // In this control type, the outdoor air flow rate is fixed to the maximum value // which is equal to the minimum value, regardless of all the other conditions. if (state.dataLoopNodes->Node(OutsideAirNode).MassFlowRate > 0.0) { - MaxOAFrac = GetCurrentScheduleValue(state, ventSlab.MaxOASchedPtr); + MaxOAFrac = ventSlab.maxOASched->getCurrentVal(); } else { MaxOAFrac = 0.0; } @@ -3348,7 +3270,7 @@ namespace VentilatedSlab { } case OutsideAirControlType::FixedTemperature: { // This is basically the same algorithm as for the heating case... - Tdesired = GetCurrentScheduleValue(state, ventSlab.TempSchedPtr); + Tdesired = ventSlab.tempSched->getCurrentVal(); MaxOAFrac = 1.0; diff --git a/src/EnergyPlus/VentilatedSlab.hh b/src/EnergyPlus/VentilatedSlab.hh index 7d2437567aa..8f518afaddf 100644 --- a/src/EnergyPlus/VentilatedSlab.hh +++ b/src/EnergyPlus/VentilatedSlab.hh @@ -133,7 +133,7 @@ namespace VentilatedSlab { // Members // Input data std::string Name; // name of system - int SchedPtr; // index to schedule + Sched::Schedule *availSched = nullptr; // schedule int ZonePtr; // Point to this zone in the Zone derived type // Variables for Delivery Config. Array1D_string ZName; // Name of zone the system is serving @@ -169,10 +169,10 @@ namespace VentilatedSlab { Real64 MaxAirVolFlow; // m3/s Real64 MaxAirMassFlow; // kg/s OutsideAirControlType outsideAirControlType; // type of control; options are VARIABLE PERCENT and FIXED TEMPERATURE - int MinOASchedPtr; // index to schedule - int MaxOASchedPtr; // index to schedule + Sched::Schedule *minOASched = nullptr; + Sched::Schedule *maxOASched = nullptr; // temperature (fixed temp.) - int TempSchedPtr; // index to schedule + Sched::Schedule *tempSched = nullptr; int OutsideAirNode; // outside air node number int AirReliefNode; // relief air node number int OAMixerOutNode; // outlet node after the outside air mixer (inlet to coils if present) @@ -189,7 +189,7 @@ namespace VentilatedSlab { int heatingCoil_Index; DataPlant::PlantEquipmentType heatingCoilType; int heatingCoil_FluidIndex; - int heatingCoilSchedPtr; // index to schedule + Sched::Schedule *heatingCoilSched = nullptr; // index to schedule Real64 heatingCoilSchedValue; Real64 MaxVolHotWaterFlow; // m3/s Real64 MaxVolHotSteamFlow; // m3/s @@ -203,13 +203,13 @@ namespace VentilatedSlab { int HotCoilOutNodeNum; // outlet of coil Real64 HotControlOffset; // control tolerance PlantLocation HWPlantLoc; // index for plant component for hot water coil - int HotAirHiTempSchedPtr; // Schedule index for the highest Air temperature - int HotAirLoTempSchedPtr; // Schedule index for the lowest Air temperature + Sched::Schedule *hotAirHiTempSched = nullptr; // Schedule for the highest Air temperature + Sched::Schedule *hotAirLoTempSched = nullptr; // Schedule for the lowest Air temperature // (where the lowest Air temperature is requested) - int HotCtrlHiTempSchedPtr; // Schedule index for the highest control temperature + Sched::Schedule *hotCtrlHiTempSched = nullptr; // Schedule for the highest control temperature // (where the lowest Air temperature is requested) // (where the highest Air temperature is requested) - int HotCtrlLoTempSchedPtr; // Schedule index for the lowest control temperature + Sched::Schedule *hotCtrlLoTempSched = nullptr; // Schedule for the lowest control temperature // (where the highest Air temperature is requested) bool coolingCoilPresent; // .TRUE. if ventilated slab has a cooling coil std::string coolingCoilName; // name of cooling coil @@ -221,7 +221,7 @@ namespace VentilatedSlab { CoolingCoilType cCoilType; // type of cooling coil: // 'Coil:Cooling:Water:DetailedGeometry' or // 'CoilSystem:Cooling:Water:HeatExchangerAssisted' - int coolingCoilSchedPtr; // index to schedule + Sched::Schedule *coolingCoilSched = nullptr; Real64 coolingCoilSchedValue; Real64 MaxVolColdWaterFlow; // m3/s Real64 MaxColdWaterFlow; // kg/s @@ -231,13 +231,13 @@ namespace VentilatedSlab { int ColdCoilOutNodeNum; // chilled water coil out nod Real64 ColdControlOffset; // control tolerance PlantLocation CWPlantLoc; // index for plant component for chilled water coil - int ColdAirHiTempSchedPtr; // Schedule index for the highest Air temperature - int ColdAirLoTempSchedPtr; // Schedule index for the lowest Air temperature + Sched::Schedule *coldAirHiTempSched = nullptr; // Schedule for the highest Air temperature + Sched::Schedule *coldAirLoTempSched = nullptr; // Schedule for the lowest Air temperature // (where the lowest Air temperature is requested) - int ColdCtrlHiTempSchedPtr; // Schedule index for the highest control temperature + Sched::Schedule *coldCtrlHiTempSched = nullptr; // Schedule for the highest control temperature // (where the lowest Air temperature is requested) // (where the highest Air temperature is requested) - int ColdCtrlLoTempSchedPtr; // Schedule index for the lowest control temperature + Sched::Schedule *coldCtrlLoTempSched = nullptr; // Schedule for the lowest control temperature // (where the highest Air temperature is requested) int CondErrIndex; // Error index for recurring warning messages int EnrgyImbalErrIndex; // Error index for recurring warning messages @@ -284,21 +284,21 @@ namespace VentilatedSlab { // Default Constructor VentilatedSlabData() - : SchedPtr(0), ZonePtr(0), NumOfSurfaces(0), TotalSurfaceArea(0.0), CoreDiameter(0.0), CoreLength(0.0), CoreNumbers(0.0), + : ZonePtr(0), NumOfSurfaces(0), TotalSurfaceArea(0.0), CoreDiameter(0.0), CoreLength(0.0), CoreNumbers(0.0), controlType(ControlType::Invalid), ReturnAirNode(0), RadInNode(0), ZoneAirInNode(0), FanOutletNode(0), MSlabInNode(0), MSlabOutNode(0), Fan_Index(0), fanType(HVAC::FanType::Invalid), ControlCompTypeNum(0), CompErrIndex(0), MaxAirVolFlow(0.0), MaxAirMassFlow(0.0), - outsideAirControlType(OutsideAirControlType::Invalid), MinOASchedPtr(0), MaxOASchedPtr(0), TempSchedPtr(0), OutsideAirNode(0), + outsideAirControlType(OutsideAirControlType::Invalid), OutsideAirNode(0), AirReliefNode(0), OAMixerOutNode(0), OutAirVolFlow(0.0), OutAirMassFlow(0.0), MinOutAirVolFlow(0.0), MinOutAirMassFlow(0.0), SysConfg(VentilatedSlabConfig::Invalid), coilOption(CoilType::Invalid), heatingCoilPresent(false), hCoilType(HeatingCoilType::Invalid), - heatingCoil_Index(0), heatingCoilType(DataPlant::PlantEquipmentType::Invalid), heatingCoil_FluidIndex(0), heatingCoilSchedPtr(0), + heatingCoil_Index(0), heatingCoilType(DataPlant::PlantEquipmentType::Invalid), heatingCoil_FluidIndex(0), heatingCoilSchedValue(0.0), MaxVolHotWaterFlow(0.0), MaxVolHotSteamFlow(0.0), MaxHotWaterFlow(0.0), MaxHotSteamFlow(0.0), MinHotSteamFlow(0.0), MinVolHotWaterFlow(0.0), MinVolHotSteamFlow(0.0), MinHotWaterFlow(0.0), HotControlNode(0), HotCoilOutNodeNum(0), - HotControlOffset(0.0), HWPlantLoc{}, HotAirHiTempSchedPtr(0), HotAirLoTempSchedPtr(0), HotCtrlHiTempSchedPtr(0), - HotCtrlLoTempSchedPtr(0), coolingCoilPresent(false), coolingCoil_Index(0), coolingCoilType(DataPlant::PlantEquipmentType::Invalid), - cCoilType(CoolingCoilType::Invalid), coolingCoilSchedPtr(0), coolingCoilSchedValue(0.0), MaxVolColdWaterFlow(0.0), + HotControlOffset(0.0), HWPlantLoc{}, + coolingCoilPresent(false), coolingCoil_Index(0), coolingCoilType(DataPlant::PlantEquipmentType::Invalid), + cCoilType(CoolingCoilType::Invalid), coolingCoilSchedValue(0.0), MaxVolColdWaterFlow(0.0), MaxColdWaterFlow(0.0), MinVolColdWaterFlow(0.0), MinColdWaterFlow(0.0), ColdControlNode(0), ColdCoilOutNodeNum(0), - ColdControlOffset(0.0), CWPlantLoc{}, ColdAirHiTempSchedPtr(0), ColdAirLoTempSchedPtr(0), ColdCtrlHiTempSchedPtr(0), - ColdCtrlLoTempSchedPtr(0), CondErrIndex(0), EnrgyImbalErrIndex(0), RadSurfNum(0), MSlabIn(0), MSlabOut(0), DirectHeatLossPower(0.0), + ColdControlOffset(0.0), CWPlantLoc{}, + CondErrIndex(0), EnrgyImbalErrIndex(0), RadSurfNum(0), MSlabIn(0), MSlabOut(0), DirectHeatLossPower(0.0), DirectHeatLossEnergy(0.0), DirectHeatGainPower(0.0), DirectHeatGainEnergy(0.0), TotalVentSlabRadPower(0.0), RadHeatingPower(0.0), RadHeatingEnergy(0.0), RadCoolingPower(0.0), RadCoolingEnergy(0.0), HeatCoilPower(0.0), HeatCoilEnergy(0.0), TotCoolCoilPower(0.0), TotCoolCoilEnergy(0.0), SensCoolCoilPower(0.0), SensCoolCoilEnergy(0.0), LateCoolCoilPower(0.0), LateCoolCoilEnergy(0.0), @@ -422,6 +422,10 @@ struct VentilatedSlabData : BaseGlobalStruct int EnergyImbalanceErrorCount = 0; // Counts for # times a temperature mismatch is found in the energy balance check bool FirstTimeFlag = true; // for setting size of AirTempOut array + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/WaterCoils.cc b/src/EnergyPlus/WaterCoils.cc index 959fb06816f..9aada9f14bb 100644 --- a/src/EnergyPlus/WaterCoils.cc +++ b/src/EnergyPlus/WaterCoils.cc @@ -134,7 +134,6 @@ using Psychrometrics::PsyWFnTdbH; using Psychrometrics::PsyWFnTdbRhPb; using Psychrometrics::PsyWFnTdbTwbPb; using Psychrometrics::PsyWFnTdpPb; -using namespace ScheduleManager; void SimulateWaterCoilComponents(EnergyPlusData &state, std::string_view CompName, @@ -250,6 +249,7 @@ void GetWaterCoilInput(EnergyPlusData &state) // SUBROUTINE PARAMETER DEFINITIONS: static constexpr std::string_view RoutineName("GetWaterCoilInput: "); // include trailing blank space + static constexpr std::string_view routineName = "GetWaterCoilInput"; // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int CoilNum; // The WaterCoil that you are currently loading input into @@ -323,6 +323,8 @@ void GetWaterCoilInput(EnergyPlusData &state) cAlphaFields, cNumericFields); + ErrorObjectHeader eoh{routineName, CurrentModuleObject, AlphArray(1)}; + state.dataWaterCoils->WaterCoilNumericFields(CoilNum).FieldNames.allocate(MaxNums); state.dataWaterCoils->WaterCoilNumericFields(CoilNum).FieldNames = ""; state.dataWaterCoils->WaterCoilNumericFields(CoilNum).FieldNames = cNumericFields; @@ -331,19 +333,13 @@ void GetWaterCoilInput(EnergyPlusData &state) // ErrorsFound will be set to True if problem was found, left untouched otherwise GlobalNames::VerifyUniqueCoilName(state, CurrentModuleObject, AlphArray(1), ErrorsFound, CurrentModuleObject + " Name"); auto &waterCoil = state.dataWaterCoils->WaterCoil(CoilNum); + waterCoil.Name = AlphArray(1); - waterCoil.Schedule = AlphArray(2); if (lAlphaBlanks(2)) { - waterCoil.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - waterCoil.SchedPtr = GetScheduleIndex(state, AlphArray(2)); - if (waterCoil.SchedPtr == 0) { - ShowSevereError( - state, - format( - "{}: invalid {} entered ={} for {}={}", CurrentModuleObject, cAlphaFields(2), AlphArray(2), cAlphaFields(1), AlphArray(1))); - ErrorsFound = true; - } + waterCoil.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((waterCoil.availSched = Sched::GetSchedule(state, AlphArray(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(2), AlphArray(2)); + ErrorsFound = true; } waterCoil.WaterCoilModelA = "SIMPLE"; @@ -493,6 +489,8 @@ void GetWaterCoilInput(EnergyPlusData &state) cAlphaFields, cNumericFields); + ErrorObjectHeader eoh{routineName, CurrentModuleObject, AlphArray(1)}; + state.dataWaterCoils->WaterCoilNumericFields(CoilNum).FieldNames.allocate(MaxNums); state.dataWaterCoils->WaterCoilNumericFields(CoilNum).FieldNames = ""; state.dataWaterCoils->WaterCoilNumericFields(CoilNum).FieldNames = cNumericFields; @@ -503,18 +501,12 @@ void GetWaterCoilInput(EnergyPlusData &state) auto &waterCoil = state.dataWaterCoils->WaterCoil(CoilNum); waterCoil.Name = AlphArray(1); - waterCoil.Schedule = AlphArray(2); + if (lAlphaBlanks(2)) { - waterCoil.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - waterCoil.SchedPtr = GetScheduleIndex(state, AlphArray(2)); - if (waterCoil.SchedPtr == 0) { - ShowSevereError( - state, - format( - "{}: invalid {} entered ={} for {}={}", CurrentModuleObject, cAlphaFields(2), AlphArray(2), cAlphaFields(1), AlphArray(1))); - ErrorsFound = true; - } + waterCoil.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((waterCoil.availSched = Sched::GetSchedule(state, AlphArray(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(2), AlphArray(2)); + ErrorsFound = true; } waterCoil.WaterCoilModelA = "DETAILED FLAT FIN"; @@ -706,6 +698,7 @@ void GetWaterCoilInput(EnergyPlusData &state) cAlphaFields, cNumericFields); + ErrorObjectHeader eoh{routineName, CurrentModuleObject, AlphArray(1)}; state.dataWaterCoils->WaterCoilNumericFields(CoilNum).FieldNames.allocate(MaxNums); state.dataWaterCoils->WaterCoilNumericFields(CoilNum).FieldNames = ""; state.dataWaterCoils->WaterCoilNumericFields(CoilNum).FieldNames = cNumericFields; @@ -716,18 +709,12 @@ void GetWaterCoilInput(EnergyPlusData &state) auto &waterCoil = state.dataWaterCoils->WaterCoil(CoilNum); waterCoil.Name = AlphArray(1); - waterCoil.Schedule = AlphArray(2); + if (lAlphaBlanks(2)) { - waterCoil.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - waterCoil.SchedPtr = GetScheduleIndex(state, AlphArray(2)); - if (waterCoil.SchedPtr == 0) { - ShowSevereError( - state, - format( - "{}: invalid {} entered ={} for {}={}", CurrentModuleObject, cAlphaFields(2), AlphArray(2), cAlphaFields(1), AlphArray(1))); - ErrorsFound = true; - } + waterCoil.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((waterCoil.availSched = Sched::GetSchedule(state, AlphArray(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(2), AlphArray(2)); + ErrorsFound = true; } waterCoil.WaterCoilModelA = "Cooling"; @@ -2843,7 +2830,7 @@ void CalcSimpleHeatingCoil(EnergyPlusData &state, // Also the coil has to be scheduled to be available if (((CapacitanceAir > 0.0) && (CapacitanceWater > 0.0)) && (CalcMode == state.dataWaterCoils->DesignCalc || state.dataWaterCoils->MySizeFlag(CoilNum) || - state.dataWaterCoils->MyUAAndFlowCalcFlag(CoilNum) || GetCurrentScheduleValue(state, waterCoil.SchedPtr) > 0.0)) { + state.dataWaterCoils->MyUAAndFlowCalcFlag(CoilNum) || waterCoil.availSched->getCurrentVal() > 0.0)) { if (UA <= 0.0) { ShowFatalError(state, format("UA is zero for COIL:Heating:Water {}", waterCoil.Name)); @@ -3093,7 +3080,7 @@ void CalcDetailFlatFinCoolingCoil(EnergyPlusData &state, } // If Coil is Scheduled ON then do the simulation - if (((GetCurrentScheduleValue(state, waterCoil.SchedPtr) > 0.0) && (WaterMassFlowRate > 0.0) && (AirMassFlow >= WaterCoils::MinAirMassFlow)) || + if (((waterCoil.availSched->getCurrentVal() > 0.0) && (WaterMassFlowRate > 0.0) && (AirMassFlow >= WaterCoils::MinAirMassFlow)) || (CalcMode == state.dataWaterCoils->DesignCalc)) { // transfer inputs to simulation variables and calculate // known thermodynamic functions @@ -3604,7 +3591,7 @@ void CoolingCoil(EnergyPlusData &state, } // If Coil is Scheduled ON then do the simulation - if (((GetCurrentScheduleValue(state, waterCoil.SchedPtr) > 0.0) && (waterCoil.InletWaterMassFlowRate > 0.0) && + if (((waterCoil.availSched->getCurrentVal() > 0.0) && (waterCoil.InletWaterMassFlowRate > 0.0) && (AirMassFlowRate >= WaterCoils::MinAirMassFlow) && (waterCoil.DesAirVolFlowRate > 0.0) && (waterCoil.MaxWaterMassFlowRate > 0.0)) || (CalcMode == state.dataWaterCoils->DesignCalc)) { @@ -5345,7 +5332,7 @@ void CheckWaterCoilSchedule(EnergyPlusData &state, std::string_view CompName, Re ShowFatalError(state, format("CheckWaterCoilSchedule: Coil not found={}", CompName)); } CompIndex = CoilNum; - Value = GetCurrentScheduleValue(state, state.dataWaterCoils->WaterCoil(CoilNum).SchedPtr); // not scheduled? + Value = state.dataWaterCoils->WaterCoil(CoilNum).availSched->getCurrentVal(); // not scheduled? } else { CoilNum = CompIndex; if (CoilNum > state.dataWaterCoils->NumWaterCoils || CoilNum < 1) { @@ -5363,7 +5350,7 @@ void CheckWaterCoilSchedule(EnergyPlusData &state, std::string_view CompName, Re CompName, waterCoil.Name)); } - Value = GetCurrentScheduleValue(state, waterCoil.SchedPtr); // not scheduled? + Value = waterCoil.availSched->getCurrentVal(); // not scheduled? } } @@ -6130,10 +6117,10 @@ void UpdateWaterToAirCoilPlantConnection(EnergyPlusData &state, } } -int GetWaterCoilAvailScheduleIndex(EnergyPlusData &state, - std::string const &CoilType, // must match coil types in this module - std::string const &CoilName, // must match coil names for the coil type - bool &ErrorsFound // set to true if problem +Sched::Schedule *GetWaterCoilAvailSched(EnergyPlusData &state, + std::string const &CoilType, // must match coil types in this module + std::string const &CoilName, // must match coil names for the coil type + bool &ErrorsFound // set to true if problem ) { @@ -6154,13 +6141,12 @@ int GetWaterCoilAvailScheduleIndex(EnergyPlusData &state, } int WhichCoil = 0; - int AvailSchIndex = 0; if (Util::SameString(CoilType, "Coil:Heating:Water") || Util::SameString(CoilType, "Coil:Cooling:Water") || Util::SameString(CoilType, "Coil:Cooling:Water:DetailedGeometry")) { WhichCoil = Util::FindItem(CoilName, state.dataWaterCoils->WaterCoil); if (WhichCoil != 0) { - AvailSchIndex = state.dataWaterCoils->WaterCoil(WhichCoil).SchedPtr; + return state.dataWaterCoils->WaterCoil(WhichCoil).availSched; } } else { WhichCoil = 0; @@ -6169,10 +6155,10 @@ int GetWaterCoilAvailScheduleIndex(EnergyPlusData &state, if (WhichCoil == 0) { ShowSevereError(state, format("GetCoilAvailScheduleIndex: Could not find Coil, Type=\"{}\" Name=\"{}\"", CoilType, CoilName)); ErrorsFound = true; - AvailSchIndex = 0; + return nullptr; } - return AvailSchIndex; + return nullptr; } void SetWaterCoilData(EnergyPlusData &state, diff --git a/src/EnergyPlus/WaterCoils.hh b/src/EnergyPlus/WaterCoils.hh index a3b61963fb5..fbc7764fca7 100644 --- a/src/EnergyPlus/WaterCoils.hh +++ b/src/EnergyPlus/WaterCoils.hh @@ -89,8 +89,7 @@ namespace WaterCoils { std::string WaterCoilModelA; // Type of WaterCoil ie. Simple, Detailed, etc. DataPlant::PlantEquipmentType WaterCoilType; // Type of WaterCoil ie. Heating or Cooling CoilModel WaterCoilModel; // Type of WaterCoil ie. Simple, Detailed, etc. - std::string Schedule; // WaterCoil Operation Schedule - int SchedPtr; // Pointer to the correct schedule + Sched::Schedule *availSched = nullptr; // availability schedule bool RequestingAutoSize; // True if this coil has appropriate autosize fields Real64 InletAirMassFlowRate; // MassFlow through the WaterCoil being Simulated [kg/s] Real64 OutletAirMassFlowRate; // MassFlow through the WaterCoil being Simulated[kg/s] @@ -222,7 +221,7 @@ namespace WaterCoils { // Default Constructor WaterCoilEquipConditions() - : WaterCoilType(DataPlant::PlantEquipmentType::Invalid), WaterCoilModel(CoilModel::Invalid), SchedPtr(0), RequestingAutoSize(false), + : WaterCoilType(DataPlant::PlantEquipmentType::Invalid), WaterCoilModel(CoilModel::Invalid), RequestingAutoSize(false), InletAirMassFlowRate(0.0), OutletAirMassFlowRate(0.0), InletAirTemp(0.0), OutletAirTemp(0.0), InletAirHumRat(0.0), OutletAirHumRat(0.0), InletAirEnthalpy(0.0), OutletAirEnthalpy(0.0), TotWaterCoilLoad(0.0), SenWaterCoilLoad(0.0), TotWaterHeatingCoilEnergy(0.0), TotWaterCoolingCoilEnergy(0.0), SenWaterCoolingCoilEnergy(0.0), DesWaterHeatingCoilRate(0.0), TotWaterHeatingCoilRate(0.0), @@ -504,11 +503,11 @@ namespace WaterCoils { bool &InitLoopEquip // If not zero, calculate the max load for operating conditions ); - int GetWaterCoilAvailScheduleIndex(EnergyPlusData &state, - std::string const &CoilType, // must match coil types in this module - std::string const &CoilName, // must match coil names for the coil type - bool &ErrorsFound // set to true if problem - ); + Sched::Schedule *GetWaterCoilAvailSched(EnergyPlusData &state, + std::string const &CoilType, // must match coil types in this module + std::string const &CoilName, // must match coil names for the coil type + bool &ErrorsFound // set to true if problem + ); // sets data to a coil that is used as a regeneration air heating coil in // desiccant dehumidification system @@ -595,6 +594,10 @@ struct WaterCoilsData : BaseGlobalStruct Array2D OrdPairSum = Array2D(10, 2); Array2D OrdPairSumMatrix = Array2D(10, 10); + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/WaterManager.cc b/src/EnergyPlus/WaterManager.cc index 5e5eed382f7..5e4b1b9dae5 100644 --- a/src/EnergyPlus/WaterManager.cc +++ b/src/EnergyPlus/WaterManager.cc @@ -162,12 +162,8 @@ namespace WaterManager { // MODIFIED na // RE-ENGINEERED na - using ScheduleManager::CheckScheduleValue; - using ScheduleManager::CheckScheduleValueMinMax; - using ScheduleManager::GetScheduleIndex; - using ScheduleManager::GetScheduleMaxValue; - using ScheduleManager::GetScheduleMinValue; - + static constexpr std::string_view routineName = "GetWaterManagerInput"; + // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int Item; // Item to be "gotten" int NumAlphas(0); // Number of Alphas for each GetObjectItem call @@ -242,6 +238,9 @@ namespace WaterManager { _, cAlphaFieldNames, cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, cCurrentModuleObject, cAlphaArgs(1)}; + state.dataWaterData->AnyWaterSystemsInModel = true; state.dataWaterData->WaterStorage(Item).Name = cAlphaArgs(1); Util::IsNameEmpty(state, cAlphaArgs(1), cCurrentModuleObject, ErrorsFound); @@ -321,24 +320,15 @@ namespace WaterManager { } if (state.dataWaterData->WaterStorage(Item).ThermalMode == DataWater::TankThermalMode::Scheduled) { - state.dataWaterData->WaterStorage(Item).TempSchedID = GetScheduleIndex(state, cAlphaArgs(7)); - if (state.dataWaterData->WaterStorage(Item).TempSchedID == 0) { - ShowSevereError(state, format("Invalid {}={}", cAlphaFieldNames(7), cAlphaArgs(7))); - ShowContinueError(state, format("Entered in {}={}", cCurrentModuleObject, cAlphaArgs(1))); + + if (lAlphaFieldBlanks(7)) { + ShowSevereEmptyField(state, eoh, cAlphaFieldNames(7)); ErrorsFound = true; - } - Real64 tmpMin = GetScheduleMinValue(state, state.dataWaterData->WaterStorage(Item).TempSchedID); - if (tmpMin < 0.0) { - ShowSevereError(state, format("Invalid {}={}", cAlphaFieldNames(7), cAlphaArgs(7))); - ShowContinueError(state, format("Entered in {}={}", cCurrentModuleObject, cAlphaArgs(1))); - ShowContinueError(state, format("Found storage tank temperature schedule value less than 0.0 in {}", objNameMsg)); + } else if ((state.dataWaterData->WaterStorage(Item).tempSched = Sched::GetSchedule(state, cAlphaArgs(7))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(7), cAlphaArgs(7)); ErrorsFound = true; - } - Real64 tmpMax = GetScheduleMaxValue(state, state.dataWaterData->WaterStorage(Item).TempSchedID); - if (tmpMax > 100.0) { - ShowSevereError(state, format("Invalid {}={}", cAlphaFieldNames(7), cAlphaArgs(7))); - ShowContinueError(state, format("Entered in {}={}", cCurrentModuleObject, cAlphaArgs(1))); - ShowContinueError(state, format("found storage tank temperature schedule value greater than 100.0 in {}", objNameMsg)); + } else if (!state.dataWaterData->WaterStorage(Item).tempSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 100.0)) { + Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(7), cAlphaArgs(7), Clusive::In, 0.0, Clusive::In, 100.0); ErrorsFound = true; } } @@ -355,13 +345,17 @@ namespace WaterManager { ShowContinueError(state, format("Entered in {}={}", cCurrentModuleObject, cAlphaArgs(1))); ErrorsFound = true; } - state.dataWaterData->WaterStorage(Item).AmbientTempSchedule = GetScheduleIndex(state, cAlphaArgs(9)); - if ((state.dataWaterData->WaterStorage(Item).AmbientTempSchedule == 0) && - (state.dataWaterData->WaterStorage(Item).AmbientTempIndicator == DataWater::AmbientTempType::Schedule)) { - ShowSevereError(state, format("Invalid {}={}", cAlphaFieldNames(9), cAlphaArgs(9))); - ShowContinueError(state, format("Entered in {}={}", cCurrentModuleObject, cAlphaArgs(1))); - ErrorsFound = true; + + if (state.dataWaterData->WaterStorage(Item).AmbientTempIndicator == DataWater::AmbientTempType::Schedule) { + if (lAlphaFieldBlanks(9)) { + ShowSevereEmptyField(state, eoh, cAlphaFieldNames(9)); + ErrorsFound = true; + } else if ((state.dataWaterData->WaterStorage(Item).ambientTempSched = Sched::GetSchedule(state, cAlphaArgs(9))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(9), cAlphaArgs(9)); + ErrorsFound = true; + } } + state.dataWaterData->WaterStorage(Item).ZoneID = Util::FindItemInList(cAlphaArgs(10), state.dataHeatBal->Zone); if ((state.dataWaterData->WaterStorage(Item).ZoneID == 0) && (state.dataWaterData->WaterStorage(Item).AmbientTempIndicator == DataWater::AmbientTempType::Zone)) { @@ -402,6 +396,9 @@ namespace WaterManager { _, cAlphaFieldNames, cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, cCurrentModuleObject, cAlphaArgs(1)}; + state.dataWaterData->RainCollector(Item).Name = cAlphaArgs(1); Util::IsNameEmpty(state, cAlphaArgs(1), cCurrentModuleObject, ErrorsFound); objNameMsg = cCurrentModuleObject + " Named " + cAlphaArgs(1); @@ -437,24 +434,17 @@ namespace WaterManager { } if (state.dataWaterData->RainCollector(Item).LossFactorMode == DataWater::RainLossFactor::Scheduled) { - state.dataWaterData->RainCollector(Item).LossFactorSchedID = GetScheduleIndex(state, cAlphaArgs(4)); - if (state.dataWaterData->RainCollector(Item).LossFactorSchedID == 0) { - ShowSevereError(state, format("Invalid {}={}", cAlphaFieldNames(4), cAlphaArgs(4))); - ShowContinueError(state, format("Entered in {}={}", cCurrentModuleObject, cAlphaArgs(1))); + if (lAlphaFieldBlanks(4)) { + ShowSevereEmptyField(state, eoh, cAlphaFieldNames(4)); ErrorsFound = true; - } - if (GetScheduleMinValue(state, state.dataWaterData->RainCollector(Item).LossFactorSchedID) < 0.0) { - ShowSevereError(state, format("Invalid {}={}", cAlphaFieldNames(4), cAlphaArgs(4))); - ShowContinueError(state, format("Entered in {}={}", cCurrentModuleObject, cAlphaArgs(1))); - ShowContinueError(state, - format("found rain water collection loss factor schedule value less than 0.0 in {}", objNameMsg)); + } else if ((state.dataWaterData->RainCollector(Item).lossFactorSched = Sched::GetSchedule(state, cAlphaArgs(4))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(4), cAlphaArgs(4)); ErrorsFound = true; - } - if (GetScheduleMaxValue(state, state.dataWaterData->RainCollector(Item).LossFactorSchedID) > 1.0) { - ShowWarningError(state, format("Potentially invalid {}={}", cAlphaFieldNames(4), cAlphaArgs(4))); - ShowContinueError(state, format("Entered in {}={}", cCurrentModuleObject, cAlphaArgs(1))); - ShowContinueError(state, "found rain water collection loss factor schedule value greater than 1.0, simulation continues"); - // allowing it to continue + } else if (!state.dataWaterData->RainCollector(Item).lossFactorSched->checkMinVal(state, Clusive::In, 0.0)) { + Sched::ShowSevereBadMin(state, eoh, cAlphaFieldNames(4), cAlphaArgs(4), Clusive::In, 0.0); + ErrorsFound = true; + } else if (!state.dataWaterData->RainCollector(Item).lossFactorSched->checkMaxVal(state, Clusive::In, 1.0)) { + Sched::ShowWarningBadMax(state, eoh, cAlphaFieldNames(4), cAlphaArgs(4), Clusive::In, 1.0, ""); } } state.dataWaterData->RainCollector(Item).MaxCollectRate = rNumericArgs(1); @@ -521,6 +511,9 @@ namespace WaterManager { lAlphaFieldBlanks, cAlphaFieldNames, cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, cCurrentModuleObject, cAlphaArgs(1)}; + state.dataWaterData->GroundwaterWell(Item).Name = cAlphaArgs(1); Util::IsNameEmpty(state, cAlphaArgs(1), cCurrentModuleObject, ErrorsFound); objNameMsg = cCurrentModuleObject + " Named " + cAlphaArgs(1); @@ -559,12 +552,14 @@ namespace WaterManager { // N8, \field water table depth state.dataWaterData->GroundwaterWell(Item).WaterTableDepth = rNumericArgs(8); // A4; \field water table depth schedule - state.dataWaterData->GroundwaterWell(Item).WaterTableDepthSchedID = GetScheduleIndex(state, cAlphaArgs(4)); - if ((state.dataWaterData->GroundwaterWell(Item).GroundwaterTableMode == DataWater::GroundWaterTable::Scheduled) && - (state.dataWaterData->GroundwaterWell(Item).WaterTableDepthSchedID == 0)) { - ShowSevereError(state, format("Invalid {}={}", cAlphaFieldNames(4), cAlphaArgs(4))); - ShowContinueError(state, format("Entered in {}={}", cCurrentModuleObject, cAlphaArgs(1))); - ErrorsFound = true; + if (state.dataWaterData->GroundwaterWell(Item).GroundwaterTableMode == DataWater::GroundWaterTable::Scheduled) { + if (lAlphaFieldBlanks(4)) { + ShowSevereEmptyField(state, eoh, cAlphaFieldNames(4)); + ErrorsFound = true; + } else if ((state.dataWaterData->GroundwaterWell(Item).waterTableDepthSched = Sched::GetSchedule(state, cAlphaArgs(4))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(4), cAlphaArgs(4)); + ErrorsFound = true; + } } } } //(NumGroundWaterWells > 0) @@ -656,6 +651,8 @@ namespace WaterManager { state.dataInputProcessing->inputProcessor->getObjectItem( state, cCurrentModuleObject, 1, cAlphaArgs, NumAlphas, rNumericArgs, NumNumbers, IOStatus); + ErrorObjectHeader eoh{routineName, cCurrentModuleObject, cAlphaArgs(1)}; + if (Util::SameString(cAlphaArgs(1), "ScheduleAndDesignLevel")) { state.dataWaterData->RainFall.ModeID = DataWater::RainfallMode::RainSchedDesign; } else { @@ -663,15 +660,16 @@ namespace WaterManager { ShowContinueError(state, "Only available option is ScheduleAndDesignLevel."); ErrorsFound = true; } - state.dataWaterData->RainFall.RainSchedID = GetScheduleIndex(state, cAlphaArgs(2)); - if ((state.dataWaterData->RainFall.RainSchedID == 0) && - (state.dataWaterData->RainFall.ModeID == DataWater::RainfallMode::RainSchedDesign)) { - ShowSevereError(state, format("Schedule not found for {} object", cCurrentModuleObject)); - ErrorsFound = true; - } else if ((state.dataWaterData->RainFall.RainSchedID != 0) && - (state.dataWaterData->RainFall.ModeID == DataWater::RainfallMode::RainSchedDesign)) { - if (!CheckScheduleValueMinMax(state, state.dataWaterData->RainFall.RainSchedID, true, 0.0)) { - ShowSevereError(state, format("Schedule={} for {} object has values < 0.", cAlphaArgs(2), cCurrentModuleObject)); + + if (state.dataWaterData->RainFall.ModeID == DataWater::RainfallMode::RainSchedDesign) { + if (lAlphaFieldBlanks(2)) { + ShowSevereEmptyField(state, eoh, cAlphaFieldNames(2)); + ErrorsFound = true; + } else if ((state.dataWaterData->RainFall.rainSched = Sched::GetSchedule(state, cAlphaArgs(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(2), cAlphaArgs(2)); + ErrorsFound = true; + } else if (!state.dataWaterData->RainFall.rainSched->checkMinVal(state, Clusive::In, 0.0)) { + Sched::ShowSevereBadMin(state, eoh, cAlphaFieldNames(2), cAlphaArgs(2), Clusive::In, 0.0); ErrorsFound = true; } } @@ -691,6 +689,9 @@ namespace WaterManager { state.dataWaterData->AnyIrrigationInModel = true; state.dataInputProcessing->inputProcessor->getObjectItem( state, cCurrentModuleObject, 1, cAlphaArgs, NumAlphas, rNumericArgs, NumNumbers, IOStatus); + + ErrorObjectHeader eoh{routineName, cCurrentModuleObject, cAlphaArgs(1)}; + if (Util::SameString(cAlphaArgs(1), "Schedule")) { state.dataWaterData->Irrigation.ModeID = DataWater::IrrigationMode::IrrSchedDesign; } else if (Util::SameString(cAlphaArgs(1), "SmartSchedule")) { @@ -702,16 +703,17 @@ namespace WaterManager { if (state.dataWaterData->RainFall.ModeID == DataWater::RainfallMode::None) { state.dataWaterData->RainFall.ModeID = DataWater::RainfallMode::EPWPrecipitation; } - state.dataWaterData->Irrigation.IrrSchedID = GetScheduleIndex(state, cAlphaArgs(2)); - if ((state.dataWaterData->Irrigation.IrrSchedID == 0) && - ((state.dataWaterData->Irrigation.ModeID == DataWater::IrrigationMode::IrrSchedDesign) || - state.dataWaterData->Irrigation.ModeID == DataWater::IrrigationMode::IrrSmartSched)) { - ShowSevereError(state, format("Schedule not found for {} object", cCurrentModuleObject)); - ErrorsFound = true; - } else if ((state.dataWaterData->Irrigation.IrrSchedID == 0) && - (state.dataWaterData->Irrigation.ModeID == DataWater::IrrigationMode::IrrSchedDesign)) { - if (!CheckScheduleValueMinMax(state, state.dataWaterData->Irrigation.IrrSchedID, true, 0.0)) { - ShowSevereError(state, format("Schedule={} for {} object has values < 0.", cAlphaArgs(2), cCurrentModuleObject)); + + if (state.dataWaterData->Irrigation.ModeID == DataWater::IrrigationMode::IrrSchedDesign || + state.dataWaterData->Irrigation.ModeID == DataWater::IrrigationMode::IrrSmartSched) { + if (lAlphaFieldBlanks(2)) { + ShowSevereEmptyField(state, eoh, cAlphaFieldNames(2)); + ErrorsFound = true; + } else if ((state.dataWaterData->Irrigation.irrSched = Sched::GetSchedule(state, cAlphaArgs(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(2), cAlphaArgs(2)); + ErrorsFound = true; + } else if (!state.dataWaterData->Irrigation.irrSched->checkMinVal(state, Clusive::In, 0.0)) { + Sched::ShowSevereBadMin(state, eoh, cAlphaFieldNames(2), cAlphaArgs(2), Clusive::In, 0.0); ErrorsFound = true; } } @@ -934,20 +936,18 @@ namespace WaterManager { // PURPOSE OF THIS SUBROUTINE: // update the current rate of precipitation - using ScheduleManager::GetCurrentScheduleValue; - Real64 schedRate; Real64 ScaleFactor; // when the site:precipitation exists, use the precipitation schedule if (state.dataWaterData->RainFall.ModeID == DataWater::RainfallMode::RainSchedDesign) { - schedRate = GetCurrentScheduleValue(state, state.dataWaterData->RainFall.RainSchedID); // m/hr + schedRate = state.dataWaterData->RainFall.rainSched->getCurrentVal(); // m/hr if (state.dataWaterData->RainFall.NomAnnualRain > 0.0) { ScaleFactor = state.dataWaterData->RainFall.DesignAnnualRain / state.dataWaterData->RainFall.NomAnnualRain; } else { ScaleFactor = 0.0; } - state.dataWaterData->RainFall.CurrentRate = schedRate * ScaleFactor / Constant::SecInHour; // convert to m/s + state.dataWaterData->RainFall.CurrentRate = schedRate * ScaleFactor / Constant::rSecsInHour; // convert to m/s } else { // placeholder: add EP checks for out of range precipitation value later -- yujie // when there's no site:precipitation but non-zero epw precipitation, uset the epw precipitation as the CurrentRate @@ -981,20 +981,19 @@ namespace WaterManager { // PURPOSE OF THIS SUBROUTINE: // update the current rate of irrigation - Real64 TimeStepSysSec = state.dataHVACGlobal->TimeStepSysSec; - using ScheduleManager::GetCurrentScheduleValue; + Real64 TimeStepSys = state.dataHVACGlobal->TimeStepSys; Real64 schedRate; state.dataWaterData->Irrigation.ScheduledAmount = 0.0; if (state.dataWaterData->Irrigation.ModeID == DataWater::IrrigationMode::IrrSchedDesign) { - schedRate = GetCurrentScheduleValue(state, state.dataWaterData->Irrigation.IrrSchedID); // m/hr - state.dataWaterData->Irrigation.ScheduledAmount = schedRate * TimeStepSysSec / Constant::SecInHour; // convert to m/timestep // LOL + schedRate = state.dataWaterData->Irrigation.irrSched->getCurrentVal(); // m/hr + state.dataWaterData->Irrigation.ScheduledAmount = schedRate * TimeStepSys; // convert to m/timestep } else if (state.dataWaterData->Irrigation.ModeID == DataWater::IrrigationMode::IrrSmartSched) { - schedRate = GetCurrentScheduleValue(state, state.dataWaterData->Irrigation.IrrSchedID); // m/hr - state.dataWaterData->Irrigation.ScheduledAmount = schedRate * TimeStepSysSec / Constant::SecInHour; // convert to m/timestep // LOL + schedRate = state.dataWaterData->Irrigation.irrSched->getCurrentVal(); // m/hr + state.dataWaterData->Irrigation.ScheduledAmount = schedRate * TimeStepSys; // convert to m/timestep } } @@ -1013,7 +1012,6 @@ namespace WaterManager { // Using/Aliasing Real64 TimeStepSysSec = state.dataHVACGlobal->TimeStepSysSec; - using ScheduleManager::GetCurrentScheduleValue; // SUBROUTINE LOCAL VARIABLE DECLARATIONS: Real64 OrigVdotDemandRequest(0.0); @@ -1170,7 +1168,7 @@ namespace WaterManager { switch (state.dataWaterData->WaterStorage(TankNum).ThermalMode) { case DataWater::TankThermalMode::Scheduled: { state.dataWaterData->WaterStorage(TankNum).Twater = - GetCurrentScheduleValue(state, state.dataWaterData->WaterStorage(TankNum).TempSchedID); + state.dataWaterData->WaterStorage(TankNum).tempSched->getCurrentVal(); state.dataWaterData->WaterStorage(TankNum).TouterSkin = state.dataWaterData->WaterStorage(TankNum).Twater; } break; case DataWater::TankThermalMode::ZoneCoupled: { @@ -1427,7 +1425,6 @@ namespace WaterManager { using DataEnvironment::OutWetBulbTempAt; Real64 TimeStepSysSec = state.dataHVACGlobal->TimeStepSysSec; - using ScheduleManager::GetCurrentScheduleValue; // SUBROUTINE LOCAL VARIABLE DECLARATIONS: Real64 LossFactor(0.0); @@ -1451,7 +1448,7 @@ namespace WaterManager { LossFactor = state.dataWaterData->RainCollector(RainColNum).LossFactor; } break; case DataWater::RainLossFactor::Scheduled: { - LossFactor = GetCurrentScheduleValue(state, state.dataWaterData->RainCollector(RainColNum).LossFactorSchedID); + LossFactor = state.dataWaterData->RainCollector(RainColNum).lossFactorSched->getCurrentVal(); } break; default: { assert(false); diff --git a/src/EnergyPlus/WaterManager.hh b/src/EnergyPlus/WaterManager.hh index 1443128d069..0b02ca21873 100644 --- a/src/EnergyPlus/WaterManager.hh +++ b/src/EnergyPlus/WaterManager.hh @@ -126,6 +126,10 @@ struct WaterManagerData : BaseGlobalStruct bool MyTankDemandCheckFlag; Real64 overflowTwater = 0.0; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/WaterThermalTanks.cc b/src/EnergyPlus/WaterThermalTanks.cc index 04c63046873..f5af93dfad4 100644 --- a/src/EnergyPlus/WaterThermalTanks.cc +++ b/src/EnergyPlus/WaterThermalTanks.cc @@ -628,22 +628,18 @@ void CalcWaterThermalTankZoneGains(EnergyPlusData &state) if (state.dataGlobal->DoingSizing) { // Initialize tank temperature to setpoint // (use HPWH or Desuperheater heating coil set point if applicable) - int SchIndex; + Sched::Schedule *sched = nullptr; if (Tank.HeatPumpNum > 0) { - SchIndex = state.dataWaterThermalTanks->HPWaterHeater(Tank.HeatPumpNum).SetPointTempSchedule; + sched = state.dataWaterThermalTanks->HPWaterHeater(Tank.HeatPumpNum).setptTempSched; } else if (Tank.DesuperheaterNum > 0) { - SchIndex = state.dataWaterThermalTanks->WaterHeaterDesuperheater(Tank.DesuperheaterNum).SetPointTempSchedule; + sched = state.dataWaterThermalTanks->WaterHeaterDesuperheater(Tank.DesuperheaterNum).setptTempSched; } else { - SchIndex = Tank.SetPointTempSchedule; + sched = Tank.setptTempSched; } - Real64 TankTemp; + Real64 TankTemp = (sched != nullptr) ? sched->getCurrentVal() : 20.0; + Real64 QLossToZone = 0.0; - if (SchIndex > 0) { - TankTemp = ScheduleManager::GetCurrentScheduleValue(state, SchIndex); - } else { - TankTemp = 20.0; - } switch (Tank.WaterThermalTankType) { case DataPlant::PlantEquipmentType::WtrHeaterMixed: { QLossToZone = max(Tank.OnCycLossCoeff * Tank.OnCycLossFracToZone, Tank.OffCycLossCoeff * Tank.OffCycLossFracToZone) * @@ -674,7 +670,7 @@ void CalcWaterThermalTankZoneGains(EnergyPlusData &state) bool getDesuperHtrInput(EnergyPlusData &state) { bool ErrorsFound = false; - static constexpr std::string_view RoutineName = "getDesuperHtrInput"; + static constexpr std::string_view routineName = "getDesuperHtrInput"; // Make local copies of IPShortCut because other getinputs might overwrite the ones in state <-- need to fix this idiom std::string cCurrentModuleObject = state.dataIPShortCut->cCurrentModuleObject; Array1D cAlphaArgs = state.dataIPShortCut->cAlphaArgs; @@ -701,6 +697,9 @@ bool getDesuperHtrInput(EnergyPlusData &state) lAlphaFieldBlanks, cAlphaFieldNames, cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, cCurrentModuleObject, cAlphaArgs(1)}; + Util::IsNameEmpty(state, cAlphaArgs(1), cCurrentModuleObject, ErrorsFound); // ErrorsFound will be set to True if problem was found, left untouched otherwise @@ -712,22 +711,17 @@ bool getDesuperHtrInput(EnergyPlusData &state) DesupHtr.Type = cCurrentModuleObject; // convert availability schedule name to pointer - if (!lAlphaFieldBlanks(2)) { - DesupHtr.AvailSchedPtr = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(2)); - if (DesupHtr.AvailSchedPtr == 0) { - ShowSevereError(state, format("Invalid, {} = {}", cAlphaFieldNames(2), cAlphaArgs(2))); - ShowContinueError(state, format("Entered in {}={}", cCurrentModuleObject, cAlphaArgs(1))); - ErrorsFound = true; - } - } else { - DesupHtr.AvailSchedPtr = ScheduleManager::ScheduleAlwaysOn; + if (lAlphaFieldBlanks(2)) { + DesupHtr.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((DesupHtr.availSched = Sched::GetSchedule(state, cAlphaArgs(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(2), cAlphaArgs(2)); + ErrorsFound = true; } // convert schedule name to pointer - DesupHtr.SetPointTempSchedule = ScheduleManager::GetScheduleIndex(state, cAlphaArgs(3)); - if (DesupHtr.SetPointTempSchedule == 0) { - ShowSevereError(state, format("Invalid, {} = {}", cAlphaFieldNames(3), cAlphaArgs(3))); - ShowContinueError(state, format("Entered in {}={}", cCurrentModuleObject, cAlphaArgs(1))); + if (lAlphaFieldBlanks(3)) { + } else if ((DesupHtr.setptTempSched = Sched::GetSchedule(state, cAlphaArgs(3))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(3), cAlphaArgs(3)); ErrorsFound = true; } @@ -759,7 +753,7 @@ bool getDesuperHtrInput(EnergyPlusData &state) ErrorsFound |= Curve::CheckCurveDims(state, DesupHtr.HEffFTemp, // Curve index {2}, // Valid dimensions - RoutineName, // Routine name + routineName, // Routine name cCurrentModuleObject, // Object Type DesupHtr.Name, // Object Name cAlphaFieldNames(4)); // Field Name @@ -1220,29 +1214,20 @@ bool getHPWaterHeaterInput(EnergyPlusData &state) // Availability Schedule // convert schedule name to pointer - if (!hpwhAlphaBlank[2]) { - HPWH.AvailSchedPtr = ScheduleManager::GetScheduleIndex(state, hpwhAlpha[2]); - if (HPWH.AvailSchedPtr == 0) { - ShowSevereError(state, format("{}=\"{}\", not found", state.dataIPShortCut->cCurrentModuleObject, HPWH.Name)); - ShowContinueError(state, format("{}=\"{}\".", hpwhAlphaFieldNames[2], hpwhAlpha[2])); - ErrorsFound = true; - } - } else { - HPWH.AvailSchedPtr = ScheduleManager::ScheduleAlwaysOn; + if (hpwhAlphaBlank[2]) { + HPWH.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((HPWH.availSched = Sched::GetSchedule(state, hpwhAlpha[2])) == nullptr) { + ShowSevereItemNotFound(state, eoh, hpwhAlphaFieldNames[2], hpwhAlpha[2]); + ErrorsFound = true; } // Compressor Setpoint Temperature Schedule // convert schedule name to pointer - if (!hpwhAlphaBlank[3]) { - HPWH.SetPointTempSchedule = ScheduleManager::GetScheduleIndex(state, hpwhAlpha[3]); - if (HPWH.SetPointTempSchedule == 0) { - ShowSevereError(state, format("{}=\"{}\", not found", state.dataIPShortCut->cCurrentModuleObject, HPWH.Name)); - ShowContinueError(state, format("{}=\"{}\".", hpwhAlphaFieldNames[3], hpwhAlpha[3])); - ErrorsFound = true; - } - } else { - ShowSevereError(state, format("{}=\"{}\", ", state.dataIPShortCut->cCurrentModuleObject, HPWH.Name)); - ShowContinueError(state, format("required {} is blank.", hpwhAlphaFieldNames[3])); + if (hpwhAlphaBlank[3]) { + ShowSevereEmptyField(state, eoh, hpwhAlphaFieldNames[3]); + ErrorsFound = true; + } else if ((HPWH.setptTempSched = Sched::GetSchedule(state, hpwhAlpha[3])) == nullptr) { + ShowSevereItemNotFound(state, eoh, hpwhAlphaFieldNames[3], hpwhAlpha[3]); ErrorsFound = true; } @@ -1341,44 +1326,28 @@ bool getHPWaterHeaterInput(EnergyPlusData &state) case WTTAmbientTemp::Schedule: { // Inlet Air Temperature Schedule - if (!hpwhAlphaBlank[11 + nAlphaOffset]) { - HPWH.AmbientTempSchedule = ScheduleManager::GetScheduleIndex(state, hpwhAlpha[11 + nAlphaOffset]); - if (HPWH.AmbientTempSchedule == 0) { - ShowSevereError(state, format("{}=\"{}\", not found", state.dataIPShortCut->cCurrentModuleObject, HPWH.Name)); - ShowContinueError(state, format("{}=\"{}\".", hpwhAlphaFieldNames[11 + nAlphaOffset], hpwhAlpha[11 + nAlphaOffset])); - ErrorsFound = true; - } - } else { - ShowSevereError(state, format("{}=\"{}\", ", state.dataIPShortCut->cCurrentModuleObject, HPWH.Name)); - ShowContinueError(state, format("required {} is blank.", hpwhAlphaFieldNames[11 + nAlphaOffset])); + if (hpwhAlphaBlank[11 + nAlphaOffset]) { + ShowSevereEmptyField(state, eoh, hpwhAlphaFieldNames[11 + nAlphaOffset]); + ErrorsFound = true; + } else if ((HPWH.ambientTempSched = Sched::GetSchedule(state, hpwhAlpha[11 + nAlphaOffset])) == nullptr) { + ShowSevereItemNotFound(state, eoh, hpwhAlphaFieldNames[11 + nAlphaOffset], hpwhAlpha[11 + nAlphaOffset]); ErrorsFound = true; } // Inlet Air Humidity Schedule - if (!hpwhAlphaBlank[12 + nAlphaOffset]) { - HPWH.AmbientRHSchedule = ScheduleManager::GetScheduleIndex(state, hpwhAlpha[12 + nAlphaOffset]); - if (HPWH.AmbientRHSchedule == 0) { - ShowSevereError(state, format("{}=\"{}\", not found", state.dataIPShortCut->cCurrentModuleObject, HPWH.Name)); - ShowContinueError(state, format("{}=\"{}\".", hpwhAlphaFieldNames[12 + nAlphaOffset], hpwhAlpha[12 + nAlphaOffset])); - ErrorsFound = true; - } else { - if (!ScheduleManager::CheckScheduleValueMinMax(state, HPWH.AmbientRHSchedule, ">=", 0.0, "<=", 1.0)) { - ShowSevereError(state, format("{}=\"{}\", invalid values", state.dataIPShortCut->cCurrentModuleObject, HPWH.Name)); - ShowContinueError(state, - format("{}=\"{}\", schedule values must be (>=0., <=1.)", - hpwhAlphaFieldNames[12 + nAlphaOffset], - hpwhAlpha[12 + nAlphaOffset])); - ErrorsFound = true; - } - } - } else { - ShowSevereError(state, format("{}=\"{}\", ", state.dataIPShortCut->cCurrentModuleObject, HPWH.Name)); - ShowContinueError(state, format("required {} is blank.", hpwhAlphaFieldNames[12 + nAlphaOffset])); + if (hpwhAlphaBlank[12 + nAlphaOffset]) { + ShowSevereEmptyField(state, eoh, hpwhAlphaFieldNames[12 + nAlphaOffset]); + ErrorsFound = true; + } else if ((HPWH.ambientRHSched = Sched::GetSchedule(state, hpwhAlpha[12 + nAlphaOffset])) == nullptr) { + ShowSevereItemNotFound(state, eoh, hpwhAlphaFieldNames[12 + nAlphaOffset], hpwhAlpha[12 + nAlphaOffset]); + ErrorsFound = true; + } else if (!HPWH.ambientRHSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) { + Sched::ShowSevereBadMinMax(state, eoh, hpwhAlphaFieldNames[12 + nAlphaOffset], hpwhAlpha[12 + nAlphaOffset], + Clusive::In, 0.0, Clusive::In, 1.0); ErrorsFound = true; } - - break; - } + } break; + case WTTAmbientTemp::ZoneAndOA: case WTTAmbientTemp::TempZone: { @@ -1563,24 +1532,18 @@ bool getHPWaterHeaterInput(EnergyPlusData &state) // Compressor Location HPWH.CrankcaseTempIndicator = static_cast(getEnumValue(CrankcaseHeaterControlTempNamesUC, Util::makeUPPER(hpwhAlpha[20 + nAlphaOffset]))); + switch (HPWH.CrankcaseTempIndicator) { case CrankcaseHeaterControlTemp::Schedule: { - if (!hpwhAlphaBlank[21 + nAlphaOffset]) { - // Compressor Ambient Temperature Schedule - HPWH.CrankcaseTempSchedule = ScheduleManager::GetScheduleIndex(state, hpwhAlpha[21 + nAlphaOffset]); - if (HPWH.CrankcaseTempSchedule == 0) { - ShowSevereError(state, format("{}=\"{}\", not found", state.dataIPShortCut->cCurrentModuleObject, HPWH.Name)); - ShowContinueError(state, format("{}=\"{}\".", hpwhAlphaFieldNames[21 + nAlphaOffset], hpwhAlpha[21 + nAlphaOffset])); - ErrorsFound = true; - } - } else { - ShowSevereError(state, format("{}=\"{}\", ", state.dataIPShortCut->cCurrentModuleObject, HPWH.Name)); - ShowContinueError(state, format("required {} is blank.", hpwhAlphaFieldNames[21 + nAlphaOffset])); + if (hpwhAlphaBlank[21 + nAlphaOffset]) { + ShowSevereEmptyField(state, eoh, hpwhAlphaFieldNames[21 + nAlphaOffset]); + ErrorsFound = true; + } else if ((HPWH.crankcaseTempSched = Sched::GetSchedule(state, hpwhAlpha[21 + nAlphaOffset])) == nullptr) { + ShowSevereItemNotFound(state, eoh, hpwhAlphaFieldNames[21 + nAlphaOffset], hpwhAlpha[21 + nAlphaOffset]); ErrorsFound = true; } - - break; - } + } break; + case CrankcaseHeaterControlTemp::Zone: { if (HPWH.InletAirConfiguration == WTTAmbientTemp::OutsideAir || HPWH.InletAirConfiguration == WTTAmbientTemp::Schedule) { ShowSevereError(state, @@ -2030,38 +1993,30 @@ bool getHPWaterHeaterInput(EnergyPlusData &state) } // only get the inlet air mixer schedule if the inlet air configuration is zone and outdoor air - if (!hpwhAlphaBlank[28 + nAlphaOffset] && HPWH.InletAirConfiguration == WTTAmbientTemp::ZoneAndOA) { - HPWH.InletAirMixerSchPtr = ScheduleManager::GetScheduleIndex(state, hpwhAlpha[28 + nAlphaOffset]); - if (HPWH.InletAirMixerSchPtr == 0) { - ShowSevereError(state, format("{}=\"{}\", not found", state.dataIPShortCut->cCurrentModuleObject, HPWH.Name)); - ShowContinueError(state, format("{}=\"{}\",", hpwhAlphaFieldNames[28 + nAlphaOffset], hpwhAlpha[28 + nAlphaOffset])); + if (HPWH.InletAirConfiguration == WTTAmbientTemp::ZoneAndOA) { + if (hpwhAlphaBlank[28 + nAlphaOffset]) { + ShowSevereEmptyField(state, eoh, hpwhAlphaFieldNames[28 + nAlphaOffset]); ErrorsFound = true; - } else { - bool ValidScheduleValue = ScheduleManager::CheckScheduleValueMinMax(state, HPWH.InletAirMixerSchPtr, ">=", 0.0, "<=", 1.0); - if (!ValidScheduleValue) { - ShowSevereError(state, format("{}=\"{}\", not found", state.dataIPShortCut->cCurrentModuleObject, HPWH.Name)); - ShowContinueError(state, - format("{} values out of range of 0 to 1, Schedule=\"{}\".", - hpwhAlphaFieldNames[28 + nAlphaOffset], - hpwhAlpha[28 + nAlphaOffset])); - ErrorsFound = true; - } - // set outlet air splitter schedule index equal to inlet air mixer schedule index - // (place holder for when zone pressurization/depressurization is allowed and different schedules can be used) - HPWH.OutletAirSplitterSchPtr = ScheduleManager::GetScheduleIndex(state, hpwhAlpha[28 + nAlphaOffset]); - } + // set outlet air splitter schedule index equal to inlet air mixer schedule index + // (place holder for when zone pressurization/depressurization is allowed and different schedules can be used) + } else if ((HPWH.inletAirMixerSched = HPWH.outletAirSplitterSched = Sched::GetSchedule(state, hpwhAlpha[28 + nAlphaOffset])) == nullptr) { + ShowSevereItemNotFound(state, eoh, hpwhAlphaFieldNames[28 + nAlphaOffset], hpwhAlpha[28 + nAlphaOffset]); + ErrorsFound = true; + } else if (!HPWH.inletAirMixerSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) { + Sched::ShowSevereBadMinMax(state, eoh, hpwhAlphaFieldNames[28 + nAlphaOffset], hpwhAlpha[28 + nAlphaOffset], + Clusive::In, 0.0, Clusive::In, 1.0); + ErrorsFound = true; + } } // set fan outlet node variable for use in setting Node(FanOutletNode)%MassFlowRateMax for fan object if (HPWH.fanPlace == HVAC::FanPlace::DrawThru) { if (HPWH.OutletAirSplitterNode != 0) { HPWH.FanOutletNode = HPWH.OutletAirSplitterNode; + } else if (HPWH.InletAirConfiguration == WTTAmbientTemp::OutsideAir) { + HPWH.FanOutletNode = HPWH.ExhaustAirNode; } else { - if (HPWH.InletAirConfiguration == WTTAmbientTemp::OutsideAir) { - HPWH.FanOutletNode = HPWH.ExhaustAirNode; - } else { - HPWH.FanOutletNode = HPWH.HeatPumpAirOutletNode; - } + HPWH.FanOutletNode = HPWH.HeatPumpAirOutletNode; } } else if (HPWH.fanPlace == HVAC::FanPlace::BlowThru) { // set fan outlet node variable for use in setting Node(FanOutletNode)%MassFlowRateMax for fan object @@ -2273,7 +2228,7 @@ bool getWaterHeaterMixedInputs(EnergyPlusData &state) { bool ErrorsFound = false; state.dataIPShortCut->cCurrentModuleObject = cMixedWHModuleObj; - static constexpr std::string_view RoutineName = "getWaterHeaterMixedInputs"; + static constexpr std::string_view routineName = "getWaterHeaterMixedInputs"; for (int WaterThermalTankNum = 1; WaterThermalTankNum <= state.dataWaterThermalTanks->numWaterHeaterMixed; ++WaterThermalTankNum) { int NumAlphas; @@ -2291,6 +2246,9 @@ bool getWaterHeaterMixedInputs(EnergyPlusData &state) state.dataIPShortCut->lAlphaFieldBlanks, state.dataIPShortCut->cAlphaFieldNames, state.dataIPShortCut->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1)}; + GlobalNames::VerifyUniqueInterObjectName(state, state.dataWaterThermalTanks->UniqueWaterThermalTankNames, state.dataIPShortCut->cAlphaArgs(1), @@ -2306,8 +2264,8 @@ bool getWaterHeaterMixedInputs(EnergyPlusData &state) Tank.FluidIndex = Tank.waterIndex; // default to always on - Tank.SourceSideAvailSchedNum = ScheduleManager::ScheduleAlwaysOn; - Tank.UseSideAvailSchedNum = ScheduleManager::ScheduleAlwaysOn; + Tank.sourceSideAvailSched = Sched::GetScheduleAlwaysOn(state); + Tank.useSideAvailSched = Sched::GetScheduleAlwaysOn(state); // A user field will be added in a later release Tank.EndUseSubcategoryName = "Water Heater"; @@ -2321,20 +2279,11 @@ bool getWaterHeaterMixedInputs(EnergyPlusData &state) Tank.Volume = 0.000001; // = 1 cm3 } - Tank.SetPointTempSchedule = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(2)); if (state.dataIPShortCut->lAlphaFieldBlanks(2)) { - ShowSevereError( - state, - format("{}{}=\"{}\", missing data.", RoutineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("blank field, missing {} is required", state.dataIPShortCut->cAlphaFieldNames(2))); + ShowSevereEmptyField(state, eoh, state.dataIPShortCut->cAlphaFieldNames(2)); ErrorsFound = true; - } else if (Tank.SetPointTempSchedule == 0) { - ShowSevereError(state, - format("{} = {}: {} not found = {}", - state.dataIPShortCut->cCurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaFieldNames(2), - state.dataIPShortCut->cAlphaArgs(2))); + } else if ((Tank.setptTempSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(2), state.dataIPShortCut->cAlphaArgs(2)); ErrorsFound = true; } @@ -2460,7 +2409,7 @@ bool getWaterHeaterMixedInputs(EnergyPlusData &state) ErrorsFound |= Curve::CheckCurveDims(state, Tank.PLFCurve, // Curve index {1}, // Valid dimensions - RoutineName, // Routine name + routineName, // Routine name state.dataIPShortCut->cCurrentModuleObject, // Object Type Tank.Name, // Object Name state.dataIPShortCut->cAlphaFieldNames(5)); // Field Name @@ -2520,19 +2469,17 @@ bool getWaterHeaterMixedInputs(EnergyPlusData &state) Tank.AmbientTempIndicator = static_cast(getEnumValue(TankAmbientTempNamesUC, Util::makeUPPER(state.dataIPShortCut->cAlphaArgs(8)))); switch (Tank.AmbientTempIndicator) { + case WTTAmbientTemp::Schedule: { - Tank.AmbientTempSchedule = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(9)); - if (Tank.AmbientTempSchedule == 0) { - ShowSevereError(state, - format("{} = {}: Ambient Temperature Schedule not found = {}", - state.dataIPShortCut->cCurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaArgs(9))); + if (state.dataIPShortCut->lAlphaFieldBlanks(9)) { + ShowSevereEmptyField(state, eoh, state.dataIPShortCut->cAlphaFieldNames(9)); + ErrorsFound = true; + } else if ((Tank.ambientTempSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(9))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(9), state.dataIPShortCut->cAlphaArgs(9)); ErrorsFound = true; } - - break; - } + } break; + case WTTAmbientTemp::TempZone: { Tank.AmbientTempZone = Util::FindItemInList(state.dataIPShortCut->cAlphaArgs(10), state.dataHeatBal->Zone); if (Tank.AmbientTempZone == 0) { @@ -2543,9 +2490,8 @@ bool getWaterHeaterMixedInputs(EnergyPlusData &state) state.dataIPShortCut->cAlphaArgs(10))); ErrorsFound = true; } - - break; - } + } break; + case WTTAmbientTemp::OutsideAir: { Tank.AmbientTempOutsideAirNode = NodeInputManager::GetOnlySingleNode(state, state.dataIPShortCut->cAlphaArgs(11), @@ -2590,33 +2536,21 @@ bool getWaterHeaterMixedInputs(EnergyPlusData &state) Tank.OnCycLossCoeff = state.dataIPShortCut->rNumericArgs(15); Tank.OnCycLossFracToZone = state.dataIPShortCut->rNumericArgs(16); - Real64 rho = FluidProperties::GetDensityGlycol(state, fluidNameWater, Constant::InitConvTemp, Tank.FluidIndex, RoutineName); + Real64 rho = FluidProperties::GetDensityGlycol(state, fluidNameWater, Constant::InitConvTemp, Tank.FluidIndex, routineName); Tank.MassFlowRateMax = state.dataIPShortCut->rNumericArgs(17) * rho; if ((state.dataIPShortCut->cAlphaArgs(14).empty()) && (state.dataIPShortCut->cAlphaArgs(15).empty())) { - if (!state.dataIPShortCut->cAlphaArgs(12).empty()) { - Tank.FlowRateSchedule = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(12)); - if (Tank.FlowRateSchedule == 0) { - ShowSevereError(state, - format("{} = {}: Flow Rate Schedule not found = {}", - state.dataIPShortCut->cCurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaArgs(12))); - ErrorsFound = true; - } + if (state.dataIPShortCut->lAlphaFieldBlanks(12)) { + } else if ((Tank.flowRateSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(12))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(12), state.dataIPShortCut->cAlphaArgs(12)); + ErrorsFound = true; } } - if (!state.dataIPShortCut->cAlphaArgs(13).empty()) { - Tank.UseInletTempSchedule = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(13)); - if (Tank.UseInletTempSchedule == 0) { - ShowSevereError(state, - format("{} = {}: Cold Water Supply Temperature Schedule not found = {}", - state.dataIPShortCut->cCurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaArgs(13))); - ErrorsFound = true; - } + if (state.dataIPShortCut->lAlphaFieldBlanks(13)) { + } else if ((Tank.useInletTempSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(13))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(13), state.dataIPShortCut->cAlphaArgs(13)); + ErrorsFound = true; } if (NumNums > 17) { @@ -2706,14 +2640,14 @@ bool getWaterHeaterMixedInputs(EnergyPlusData &state) state.dataIPShortCut->cAlphaArgs(1))); } - if (Tank.FlowRateSchedule > 0) { + if (Tank.flowRateSched != nullptr) { ShowWarningError(state, format("{} = {}: Use side nodes are specified; Use Flow Rate Fraction Schedule will not be used", state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); } - if (Tank.UseInletTempSchedule > 0) { + if (Tank.useInletTempSched != nullptr) { ShowWarningError(state, format("{} = {}: Use side nodes are specified; Cold Water Supply Temperature Schedule will not be used", state.dataIPShortCut->cCurrentModuleObject, @@ -2759,18 +2693,12 @@ bool getWaterHeaterMixedInputs(EnergyPlusData &state) Tank.SourceSideControlMode = SourceSideControl::IndirectHeatPrimarySetpoint; } - if (!state.dataIPShortCut->lAlphaFieldBlanks(19)) { - Tank.SourceSideAltSetpointSchedNum = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(19)); - if (Tank.SourceSideAltSetpointSchedNum == 0) { - ShowSevereError(state, - format("{} = {}: {} not found = {}", - state.dataIPShortCut->cCurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaFieldNames(19), - state.dataIPShortCut->cAlphaArgs(19))); - ErrorsFound = true; - } + if (state.dataIPShortCut->lAlphaFieldBlanks(19)) { + } else if ((Tank.sourceSideAltSetpointSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(19))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(19), state.dataIPShortCut->cAlphaArgs(19)); + ErrorsFound = true; } + if (NumAlphas > 19) { Tank.EndUseSubcategoryName = state.dataIPShortCut->cAlphaArgs(20); } @@ -2783,7 +2711,7 @@ bool getWaterHeaterMixedInputs(EnergyPlusData &state) bool getWaterHeaterStratifiedInput(EnergyPlusData &state) { bool ErrorsFound = false; - static constexpr std::string_view RoutineName = "getWaterHeaterStratifiedInput"; + static constexpr std::string_view routineName = "getWaterHeaterStratifiedInput"; state.dataIPShortCut->cCurrentModuleObject = cStratifiedWHModuleObj; //'WaterHeater:Stratified' @@ -2805,6 +2733,8 @@ bool getWaterHeaterStratifiedInput(EnergyPlusData &state) state.dataIPShortCut->lAlphaFieldBlanks, state.dataIPShortCut->cAlphaFieldNames, state.dataIPShortCut->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1)}; GlobalNames::VerifyUniqueInterObjectName(state, state.dataWaterThermalTanks->UniqueWaterThermalTankNames, state.dataIPShortCut->cAlphaArgs(1), @@ -2820,8 +2750,8 @@ bool getWaterHeaterStratifiedInput(EnergyPlusData &state) Tank.FluidIndex = Tank.waterIndex; // default to always on - Tank.SourceSideAvailSchedNum = ScheduleManager::ScheduleAlwaysOn; - Tank.UseSideAvailSchedNum = ScheduleManager::ScheduleAlwaysOn; + Tank.sourceSideAvailSched = Sched::GetScheduleAlwaysOn(state); + Tank.useSideAvailSched = Sched::GetScheduleAlwaysOn(state); Tank.EndUseSubcategoryName = state.dataIPShortCut->cAlphaArgs(2); @@ -2829,7 +2759,7 @@ bool getWaterHeaterStratifiedInput(EnergyPlusData &state) if (Tank.Volume == DataSizing::AutoSize) { Tank.VolumeWasAutoSized = true; } - Real64 rho = FluidProperties::GetDensityGlycol(state, fluidNameWater, Constant::InitConvTemp, Tank.FluidIndex, RoutineName); + Real64 rho = FluidProperties::GetDensityGlycol(state, fluidNameWater, Constant::InitConvTemp, Tank.FluidIndex, routineName); Tank.Mass = Tank.Volume * rho; Tank.Height = state.dataIPShortCut->rNumericArgs(2); if (Tank.Height == DataSizing::AutoSize) { @@ -2886,20 +2816,11 @@ bool getWaterHeaterStratifiedInput(EnergyPlusData &state) ErrorsFound = true; } - Tank.SetPointTempSchedule = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(5)); if (state.dataIPShortCut->lAlphaFieldBlanks(5)) { - ShowSevereError( - state, - format("{}{}=\"{}\", missing data.", RoutineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("blank field, missing {} is required", state.dataIPShortCut->cAlphaFieldNames(5))); + ShowSevereEmptyField(state, eoh, state.dataIPShortCut->cAlphaFieldNames(5)); ErrorsFound = true; - } else if (Tank.SetPointTempSchedule == 0) { - ShowSevereError(state, - format("{} = {}: {} not found = {}", - state.dataIPShortCut->cCurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaFieldNames(5), - state.dataIPShortCut->cAlphaArgs(5))); + } else if ((Tank.setptTempSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(5))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(5), state.dataIPShortCut->cAlphaArgs(5)); ErrorsFound = true; } @@ -2936,20 +2857,12 @@ bool getWaterHeaterStratifiedInput(EnergyPlusData &state) ErrorsFound = true; } - Tank.SetPointTempSchedule2 = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(6)); + if (state.dataIPShortCut->lAlphaFieldBlanks(6)) { - ShowSevereError( - state, - format("{}{}=\"{}\", missing data.", RoutineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, format("blank field, missing {} is required", state.dataIPShortCut->cAlphaFieldNames(6))); + ShowSevereEmptyField(state, eoh, state.dataIPShortCut->cAlphaFieldNames(6)); ErrorsFound = true; - } else if (Tank.SetPointTempSchedule2 == 0) { - ShowSevereError(state, - format("{} = {}: {} not found = {}", - state.dataIPShortCut->cCurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaFieldNames(6), - state.dataIPShortCut->cAlphaArgs(6))); + } else if ((Tank.setptTemp2Sched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(6))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(6), state.dataIPShortCut->cAlphaArgs(6)); ErrorsFound = true; } @@ -3063,18 +2976,15 @@ bool getWaterHeaterStratifiedInput(EnergyPlusData &state) switch (Tank.AmbientTempIndicator) { case WTTAmbientTemp::Schedule: { - Tank.AmbientTempSchedule = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(11)); - if (Tank.AmbientTempSchedule == 0) { - ShowSevereError(state, - format("{} = {}: Ambient Temperature Schedule not found = {}", - state.dataIPShortCut->cCurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaArgs(11))); + if (state.dataIPShortCut->lAlphaFieldBlanks(11)) { + ShowSevereEmptyField(state, eoh, state.dataIPShortCut->cAlphaFieldNames(11)); + ErrorsFound = true; + } else if ((Tank.ambientTempSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(11))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(11), state.dataIPShortCut->cAlphaArgs(11)); ErrorsFound = true; } - - break; - } + } break; + case WTTAmbientTemp::TempZone: { Tank.AmbientTempZone = Util::FindItemInList(state.dataIPShortCut->cAlphaArgs(12), state.dataHeatBal->Zone); if (Tank.AmbientTempZone == 0) { @@ -3133,33 +3043,21 @@ bool getWaterHeaterStratifiedInput(EnergyPlusData &state) Tank.OffCycFlueLossFracToZone = state.dataIPShortCut->rNumericArgs(21); // this is temporary until we know fluid type - rho = FluidProperties::GetDensityGlycol(state, fluidNameWater, Constant::InitConvTemp, Tank.FluidIndex, RoutineName); + rho = FluidProperties::GetDensityGlycol(state, fluidNameWater, Constant::InitConvTemp, Tank.FluidIndex, routineName); Tank.MassFlowRateMax = state.dataIPShortCut->rNumericArgs(22) * rho; if ((state.dataIPShortCut->cAlphaArgs(16).empty()) && (state.dataIPShortCut->cAlphaArgs(17).empty())) { - if (!state.dataIPShortCut->cAlphaArgs(14).empty()) { - Tank.FlowRateSchedule = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(14)); - if (Tank.FlowRateSchedule == 0) { - ShowSevereError(state, - format("{} = {}: Flow Rate Schedule not found = {}", - state.dataIPShortCut->cCurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaArgs(14))); - ErrorsFound = true; - } + if (state.dataIPShortCut->lAlphaFieldBlanks(14)) { + } else if ((Tank.flowRateSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(14))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(14), state.dataIPShortCut->cAlphaArgs(14)); + ErrorsFound = true; } } - if (!state.dataIPShortCut->cAlphaArgs(15).empty()) { - Tank.UseInletTempSchedule = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(15)); - if (Tank.UseInletTempSchedule == 0) { - ShowSevereError(state, - format("{} = {}: Cold Water Supply Temperature Schedule not found = {}", - state.dataIPShortCut->cCurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaArgs(15))); - ErrorsFound = true; - } + if (state.dataIPShortCut->lAlphaFieldBlanks(15)) { + } else if ((Tank.useInletTempSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(15))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(15), state.dataIPShortCut->cAlphaArgs(15)); + ErrorsFound = true; } if (NumNums > 22) { @@ -3313,14 +3211,14 @@ bool getWaterHeaterStratifiedInput(EnergyPlusData &state) state.dataIPShortCut->cAlphaArgs(1))); } - if (Tank.FlowRateSchedule > 0) { + if (Tank.flowRateSched != nullptr) { ShowWarningError(state, format("{} = {}: Use side nodes are specified; Use Flow Rate Fraction Schedule will not be used", state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); } - if (Tank.UseInletTempSchedule > 0) { + if (Tank.useInletTempSched != nullptr) { ShowWarningError(state, format("{} = {}: Use side nodes are specified; Cold Water Supply Temperature Schedule will not be used", state.dataIPShortCut->cCurrentModuleObject, @@ -3401,17 +3299,10 @@ bool getWaterHeaterStratifiedInput(EnergyPlusData &state) Tank.SourceSideControlMode = SourceSideControl::IndirectHeatPrimarySetpoint; } - if (!state.dataIPShortCut->lAlphaFieldBlanks(22)) { - Tank.SourceSideAltSetpointSchedNum = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(22)); - if (Tank.SourceSideAltSetpointSchedNum == 0) { - ShowSevereError(state, - format("{} = {}: {} not found = {}", - state.dataIPShortCut->cCurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaFieldNames(22), - state.dataIPShortCut->cAlphaArgs(22))); - ErrorsFound = true; - } + if (state.dataIPShortCut->lAlphaFieldBlanks(22)) { + } else if ((Tank.sourceSideAltSetpointSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(22))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(22), state.dataIPShortCut->cAlphaArgs(22)); + ErrorsFound = true; } } @@ -3420,6 +3311,7 @@ bool getWaterHeaterStratifiedInput(EnergyPlusData &state) bool getWaterTankMixedInput(EnergyPlusData &state) { + static constexpr std::string_view routineName = "getWaterTankMixedInput"; bool ErrorsFound = false; state.dataIPShortCut->cCurrentModuleObject = cMixedCWTankModuleObj; // 'ThermalStorage:ChilledWater:Mixed' @@ -3443,6 +3335,9 @@ bool getWaterTankMixedInput(EnergyPlusData &state) state.dataIPShortCut->lAlphaFieldBlanks, state.dataIPShortCut->cAlphaFieldNames, state.dataIPShortCut->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1)}; + GlobalNames::VerifyUniqueInterObjectName(state, state.dataWaterThermalTanks->UniqueWaterThermalTankNames, state.dataIPShortCut->cAlphaArgs(1), @@ -3469,11 +3364,10 @@ bool getWaterTankMixedInput(EnergyPlusData &state) Tank.Volume = 0.000001; // = 1 cm3 } - Tank.SetPointTempSchedule = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(2)); - if (Tank.SetPointTempSchedule == 0) { - ShowSevereError(state, format("Invalid, {} = {}", state.dataIPShortCut->cAlphaFieldNames(2), state.dataIPShortCut->cAlphaArgs(2))); - ShowContinueError(state, format("Entered in {}={}", state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - + if (state.dataIPShortCut->lAlphaFieldBlanks(2)) { + ShowSevereEmptyField(state, eoh, state.dataIPShortCut->cAlphaFieldNames(2)); + } else if ((Tank.setptTempSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(2), state.dataIPShortCut->cAlphaArgs(2)); ErrorsFound = true; } @@ -3516,17 +3410,14 @@ bool getWaterTankMixedInput(EnergyPlusData &state) switch (Tank.AmbientTempIndicator) { case WTTAmbientTemp::Schedule: { - Tank.AmbientTempSchedule = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(4)); - if (Tank.AmbientTempSchedule == 0) { - ShowSevereError(state, format("Invalid, {} = {}", state.dataIPShortCut->cAlphaFieldNames(4), state.dataIPShortCut->cAlphaArgs(4))); - ShowContinueError(state, - format("Entered in {} = {}", state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, "Schedule was not found."); + if (state.dataIPShortCut->lAlphaFieldBlanks(4)) { + ShowSevereEmptyField(state, eoh, state.dataIPShortCut->cAlphaFieldNames(4)); + } else if ((Tank.ambientTempSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(4))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(4), state.dataIPShortCut->cAlphaArgs(4)); ErrorsFound = true; } - - break; - } + } break; + case WTTAmbientTemp::TempZone: { Tank.AmbientTempZone = Util::FindItemInList(state.dataIPShortCut->cAlphaArgs(5), state.dataHeatBal->Zone); if (Tank.AmbientTempZone == 0) { @@ -3585,12 +3476,12 @@ bool getWaterTankMixedInput(EnergyPlusData &state) Tank.OnCycLossFracToZone = 1.0; Tank.MassFlowRateMax = 0.0; - Tank.FlowRateSchedule = 0; - Tank.UseInletTempSchedule = 0; + Tank.flowRateSched = nullptr; + Tank.useInletTempSched = nullptr; // default to always on - Tank.SourceSideAvailSchedNum = ScheduleManager::ScheduleAlwaysOn; - Tank.UseSideAvailSchedNum = ScheduleManager::ScheduleAlwaysOn; + Tank.sourceSideAvailSched = Sched::GetScheduleAlwaysOn(state); + Tank.useSideAvailSched = Sched::GetScheduleAlwaysOn(state); if ((state.dataIPShortCut->rNumericArgs(6) > 1) || (state.dataIPShortCut->rNumericArgs(6) < 0)) { ShowSevereError(state, @@ -3622,16 +3513,10 @@ bool getWaterTankMixedInput(EnergyPlusData &state) Tank.UseSidePlantLoc.loopSideNum = DataPlant::LoopSideLocation::Invalid; if (state.dataIPShortCut->lAlphaFieldBlanks(9)) { - Tank.UseSideAvailSchedNum = ScheduleManager::ScheduleAlwaysOn; - } else { - Tank.UseSideAvailSchedNum = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(9)); - if (Tank.UseSideAvailSchedNum == 0) { - ShowSevereError(state, format("Invalid, {} = {}", state.dataIPShortCut->cAlphaFieldNames(9), state.dataIPShortCut->cAlphaArgs(9))); - ShowContinueError(state, - format("Entered in {} = {}", state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, "Schedule was not found."); - ErrorsFound = true; - } + Tank.useSideAvailSched = Sched::GetScheduleAlwaysOn(state); + } else if ((Tank.useSideAvailSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(9))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(9), state.dataIPShortCut->cAlphaArgs(9)); + ErrorsFound = true; } Tank.SrcSidePlantLoc.loopSideNum = DataPlant::LoopSideLocation::Invalid; @@ -3646,17 +3531,12 @@ bool getWaterTankMixedInput(EnergyPlusData &state) } if (state.dataIPShortCut->lAlphaFieldBlanks(12)) { - Tank.SourceSideAvailSchedNum = ScheduleManager::ScheduleAlwaysOn; - } else { - Tank.SourceSideAvailSchedNum = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(12)); - if (Tank.SourceSideAvailSchedNum == 0) { - ShowSevereError(state, format("Invalid, {} = {}", state.dataIPShortCut->cAlphaFieldNames(12), state.dataIPShortCut->cAlphaArgs(12))); - ShowContinueError(state, - format("Entered in {} = {}", state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, "Schedule was not found."); - ErrorsFound = true; - } + Tank.sourceSideAvailSched = Sched::GetScheduleAlwaysOn(state); + } else if ((Tank.sourceSideAvailSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(12))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(12), state.dataIPShortCut->cAlphaArgs(12)); + ErrorsFound = true; } + if (state.dataIPShortCut->lNumericFieldBlanks(10)) { Tank.SizingRecoveryTime = 4.0; } else { @@ -3721,7 +3601,7 @@ bool getWaterTankMixedInput(EnergyPlusData &state) bool getWaterTankStratifiedInput(EnergyPlusData &state) { bool ErrorsFound = false; - static constexpr std::string_view RoutineName = "getWaterTankStratifiedInput"; + static constexpr std::string_view routineName = "getWaterTankStratifiedInput"; state.dataIPShortCut->cCurrentModuleObject = cStratifiedCWTankModuleObj; // 'ThermalStorage:ChilledWater:Stratified' @@ -3747,6 +3627,9 @@ bool getWaterTankStratifiedInput(EnergyPlusData &state) state.dataIPShortCut->lAlphaFieldBlanks, state.dataIPShortCut->cAlphaFieldNames, state.dataIPShortCut->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1)}; + GlobalNames::VerifyUniqueInterObjectName(state, state.dataWaterThermalTanks->UniqueWaterThermalTankNames, state.dataIPShortCut->cAlphaArgs(1), @@ -3767,7 +3650,7 @@ bool getWaterTankStratifiedInput(EnergyPlusData &state) if (Tank.Volume == DataSizing::AutoSize) { Tank.VolumeWasAutoSized = true; } - Real64 rho = FluidProperties::GetDensityGlycol(state, fluidNameWater, Constant::InitConvTemp, Tank.FluidIndex, RoutineName); + Real64 rho = FluidProperties::GetDensityGlycol(state, fluidNameWater, Constant::InitConvTemp, Tank.FluidIndex, routineName); Tank.Mass = Tank.Volume * rho; Tank.Height = state.dataIPShortCut->rNumericArgs(2); if (Tank.Height == DataSizing::AutoSize) { @@ -3811,11 +3694,11 @@ bool getWaterTankStratifiedInput(EnergyPlusData &state) Tank.TankTempLimit = 1.0; } - Tank.SetPointTempSchedule = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(3)); - if (Tank.SetPointTempSchedule == 0) { - ShowSevereError(state, format("Invalid, {} = {}", state.dataIPShortCut->cAlphaFieldNames(3), state.dataIPShortCut->cAlphaArgs(3))); - ShowContinueError(state, format("Entered in {} = {}", state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, "Schedule was not found."); + if (state.dataIPShortCut->lAlphaFieldBlanks(3)) { + ShowSevereEmptyField(state, eoh, state.dataIPShortCut->cAlphaFieldNames(3)); + ErrorsFound = true; + } else if ((Tank.setptTempSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(3))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(3), state.dataIPShortCut->cAlphaArgs(3)); ErrorsFound = true; } @@ -3833,7 +3716,7 @@ bool getWaterTankStratifiedInput(EnergyPlusData &state) } Tank.Efficiency = 1.0; - Tank.SetPointTempSchedule2 = 0; + Tank.setptTemp2Sched = nullptr; Tank.MaxCapacity2 = 0.0; Tank.HeaterHeight2 = 0.0; Tank.FuelType = Constant::eFuel::Electricity; @@ -3852,17 +3735,15 @@ bool getWaterTankStratifiedInput(EnergyPlusData &state) switch (Tank.AmbientTempIndicator) { case WTTAmbientTemp::Schedule: { - Tank.AmbientTempSchedule = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(5)); - if (Tank.AmbientTempSchedule == 0) { - ShowSevereError(state, format("Invalid, {} = {}", state.dataIPShortCut->cAlphaFieldNames(5), state.dataIPShortCut->cAlphaArgs(5))); - ShowContinueError(state, - format("Entered in {} = {}", state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, "Schedule was not found."); + if (state.dataIPShortCut->lAlphaFieldBlanks(5)) { + ShowSevereEmptyField(state, eoh, state.dataIPShortCut->cAlphaFieldNames(5)); + ErrorsFound = true; + } else if ((Tank.ambientTempSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(5))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(5), state.dataIPShortCut->cAlphaArgs(5)); ErrorsFound = true; } - - break; - } + } break; + case WTTAmbientTemp::TempZone: { Tank.AmbientTempZone = Util::FindItemInList(state.dataIPShortCut->cAlphaArgs(6), state.dataHeatBal->Zone); if (Tank.AmbientTempZone == 0) { @@ -3922,14 +3803,14 @@ bool getWaterTankStratifiedInput(EnergyPlusData &state) Tank.OffCycFlueLossFracToZone = 0.0; Tank.MassFlowRateMax = 0.0; - Tank.FlowRateSchedule = 0; - Tank.UseInletTempSchedule = 0; + Tank.flowRateSched = nullptr; + Tank.useInletTempSched = nullptr; Tank.UseEffectiveness = state.dataIPShortCut->rNumericArgs(9); Tank.UseInletHeight = state.dataIPShortCut->rNumericArgs(10); // default to always on - Tank.SourceSideAvailSchedNum = ScheduleManager::ScheduleAlwaysOn; - Tank.UseSideAvailSchedNum = ScheduleManager::ScheduleAlwaysOn; + Tank.sourceSideAvailSched = Sched::GetScheduleAlwaysOn(state); + Tank.useSideAvailSched = Sched::GetScheduleAlwaysOn(state); if (state.dataIPShortCut->rNumericArgs(10) == Constant::AutoCalculate) { Tank.UseInletHeight = Tank.Height; // top of tank @@ -4062,16 +3943,10 @@ bool getWaterTankStratifiedInput(EnergyPlusData &state) } if (state.dataIPShortCut->lAlphaFieldBlanks(10)) { - Tank.UseSideAvailSchedNum = ScheduleManager::ScheduleAlwaysOn; - } else { - Tank.UseSideAvailSchedNum = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(10)); - if (Tank.UseSideAvailSchedNum == 0) { - ShowSevereError(state, format("Invalid, {} = {}", state.dataIPShortCut->cAlphaFieldNames(10), state.dataIPShortCut->cAlphaArgs(10))); - ShowContinueError(state, - format("Entered in {} = {}", state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, "Schedule was not found."); - ErrorsFound = true; - } + Tank.useSideAvailSched = Sched::GetScheduleAlwaysOn(state); + } else if ((Tank.useSideAvailSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(10))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(10), state.dataIPShortCut->cAlphaArgs(10)); + ErrorsFound = true; } if (Tank.UseSidePlantLoc.loopSideNum == DataPlant::LoopSideLocation::Demand && Tank.SourceInletNode != 0) { @@ -4079,16 +3954,10 @@ bool getWaterTankStratifiedInput(EnergyPlusData &state) } if (state.dataIPShortCut->lAlphaFieldBlanks(13)) { - Tank.SourceSideAvailSchedNum = ScheduleManager::ScheduleAlwaysOn; - } else { - Tank.SourceSideAvailSchedNum = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(13)); - if (Tank.SourceSideAvailSchedNum == 0) { - ShowSevereError(state, format("Invalid, {} = {}", state.dataIPShortCut->cAlphaFieldNames(13), state.dataIPShortCut->cAlphaArgs(13))); - ShowContinueError(state, - format("Entered in {} = {}", state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, "Schedule was not found."); - ErrorsFound = true; - } + Tank.sourceSideAvailSched = Sched::GetScheduleAlwaysOn(state); + } else if ((Tank.sourceSideAvailSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(13))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(13), state.dataIPShortCut->cAlphaArgs(13)); + ErrorsFound = true; } // Validate inlet mode @@ -6197,21 +6066,21 @@ void WaterThermalTankData::initialize(EnergyPlusData &state, bool const FirstHVA // Initialize tank temperature to setpoint of first hour of warm up period // (use HPWH or Desuperheater heating coil set point if applicable) - int SchIndex; + Sched::Schedule *sched = nullptr; if (this->HeatPumpNum > 0) { state.dataWaterThermalTanks->HPWaterHeater(this->HeatPumpNum).Mode = TankOperatingMode::Floating; state.dataWaterThermalTanks->HPWaterHeater(this->HeatPumpNum).SaveMode = TankOperatingMode::Floating; state.dataWaterThermalTanks->HPWaterHeater(this->HeatPumpNum).SaveWHMode = TankOperatingMode::Floating; - SchIndex = state.dataWaterThermalTanks->HPWaterHeater(this->HeatPumpNum).SetPointTempSchedule; + sched = state.dataWaterThermalTanks->HPWaterHeater(this->HeatPumpNum).setptTempSched; } else if (this->DesuperheaterNum > 0) { state.dataWaterThermalTanks->WaterHeaterDesuperheater(this->DesuperheaterNum).Mode = TankOperatingMode::Floating; - SchIndex = state.dataWaterThermalTanks->WaterHeaterDesuperheater(this->DesuperheaterNum).SetPointTempSchedule; + sched = state.dataWaterThermalTanks->WaterHeaterDesuperheater(this->DesuperheaterNum).setptTempSched; } else { - SchIndex = this->SetPointTempSchedule; + sched = this->setptTempSched; } - if (SchIndex > 0) { - this->TankTemp = ScheduleManager::GetCurrentScheduleValue(state, SchIndex); + if (sched != nullptr) { + this->TankTemp = sched->getCurrentVal(); this->SavedTankTemp = this->TankTemp; if (this->Nodes > 0) { @@ -6267,19 +6136,19 @@ void WaterThermalTankData::initialize(EnergyPlusData &state, bool const FirstHVA // reInitialize tank temperature to setpoint of first hour (use HPWH or Desuperheater heating coil set point if applicable) // BG's interpretation here is that its better to reset initial condition to setpoint once warm up is over. // (otherwise with a dynamic storage model it is difficult for the user to see the initial performance if it isn't periodic.) - int SchIndex; + Sched::Schedule *sched = nullptr; if (this->HeatPumpNum > 0) { state.dataWaterThermalTanks->HPWaterHeater(this->HeatPumpNum).Mode = TankOperatingMode::Floating; - SchIndex = state.dataWaterThermalTanks->HPWaterHeater(this->HeatPumpNum).SetPointTempSchedule; + sched = state.dataWaterThermalTanks->HPWaterHeater(this->HeatPumpNum).setptTempSched; } else if (this->DesuperheaterNum > 0) { state.dataWaterThermalTanks->WaterHeaterDesuperheater(this->DesuperheaterNum).Mode = TankOperatingMode::Floating; - SchIndex = state.dataWaterThermalTanks->WaterHeaterDesuperheater(this->DesuperheaterNum).SetPointTempSchedule; + sched = state.dataWaterThermalTanks->WaterHeaterDesuperheater(this->DesuperheaterNum).setptTempSched; } else { - SchIndex = this->SetPointTempSchedule; + sched = this->setptTempSched; } - if (SchIndex > 0) { - this->TankTemp = ScheduleManager::GetCurrentScheduleValue(state, SchIndex); + if (sched != nullptr) { + this->TankTemp = sched->getCurrentVal(); this->SavedTankTemp = this->TankTemp; if (this->Nodes > 0) { @@ -6311,8 +6180,7 @@ void WaterThermalTankData::initialize(EnergyPlusData &state, bool const FirstHVA if (FirstHVACIteration) { // Get all scheduled values - int SchIndex = this->SetPointTempSchedule; - this->SetPointTemp = ScheduleManager::GetCurrentScheduleValue(state, SchIndex); + this->SetPointTemp = this->setptTempSched->getCurrentVal(); if (!this->IsChilledWaterTank) { if (this->SetPointTemp > this->TankTempLimit) { @@ -6350,18 +6218,15 @@ void WaterThermalTankData::initialize(EnergyPlusData &state, bool const FirstHVA } } - SchIndex = this->SetPointTempSchedule2; - if (SchIndex > 0) { - this->SetPointTemp2 = ScheduleManager::GetCurrentScheduleValue(state, SchIndex); + if (this->setptTemp2Sched != nullptr) { + this->SetPointTemp2 = this->setptTemp2Sched->getCurrentVal(); } switch (this->AmbientTempIndicator) { case WTTAmbientTemp::Schedule: { - SchIndex = this->AmbientTempSchedule; - this->AmbientTemp = ScheduleManager::GetCurrentScheduleValue(state, SchIndex); - - break; - } + this->AmbientTemp = this->ambientTempSched->getCurrentVal(); + } break; + case WTTAmbientTemp::TempZone: { this->AmbientTemp = state.dataZoneTempPredictorCorrector->zoneHeatBalance(this->AmbientTempZone).MAT; @@ -6377,27 +6242,17 @@ void WaterThermalTankData::initialize(EnergyPlusData &state, bool const FirstHVA if (this->UseInletNode == 0) { // Stand-alone operation - SchIndex = this->UseInletTempSchedule; - if (SchIndex > 0) { - this->UseInletTemp = ScheduleManager::GetCurrentScheduleValue(state, SchIndex); - } else { - this->UseInletTemp = state.dataEnvrn->WaterMainsTemp; - } - - SchIndex = this->FlowRateSchedule; - if (SchIndex > 0) { - this->UseMassFlowRate = ScheduleManager::GetCurrentScheduleValue(state, SchIndex) * this->MassFlowRateMax; + + this->UseInletTemp = (this->useInletTempSched != nullptr) ? this->useInletTempSched->getCurrentVal() : state.dataEnvrn->WaterMainsTemp; - this->VolFlowRate = this->UseMassFlowRate / Psychrometrics::RhoH2O(Constant::InitConvTemp); - } else { - this->UseMassFlowRate = this->MassFlowRateMax; - this->VolFlowRate = this->UseMassFlowRate / Psychrometrics::RhoH2O(Constant::InitConvTemp); - } + this->UseMassFlowRate = this->MassFlowRateMax; + if (this->flowRateSched != nullptr) this->UseMassFlowRate *= this->flowRateSched->getCurrentVal(); + this->VolFlowRate = this->UseMassFlowRate / Psychrometrics::RhoH2O(Constant::InitConvTemp); } if (this->HeatPumpNum > 0) { state.dataWaterThermalTanks->HPWaterHeater(this->HeatPumpNum).SetPointTemp = - ScheduleManager::GetCurrentScheduleValue(state, state.dataWaterThermalTanks->HPWaterHeater(this->HeatPumpNum).SetPointTempSchedule); + state.dataWaterThermalTanks->HPWaterHeater(this->HeatPumpNum).setptTempSched->getCurrentVal(); if (state.dataWaterThermalTanks->HPWaterHeater(this->HeatPumpNum).SetPointTemp >= this->TankTempLimit) { // HP setpoint temperature scheduled equal to or higher than tank temperature limit state.dataWaterThermalTanks->HPWaterHeater(this->HeatPumpNum).SetPointTemp = this->TankTempLimit - 1.0; @@ -6417,8 +6272,8 @@ void WaterThermalTankData::initialize(EnergyPlusData &state, bool const FirstHVA } if (this->DesuperheaterNum > 0) { - state.dataWaterThermalTanks->WaterHeaterDesuperheater(this->DesuperheaterNum).SetPointTemp = ScheduleManager::GetCurrentScheduleValue( - state, state.dataWaterThermalTanks->WaterHeaterDesuperheater(this->DesuperheaterNum).SetPointTempSchedule); + state.dataWaterThermalTanks->WaterHeaterDesuperheater(this->DesuperheaterNum).SetPointTemp = + state.dataWaterThermalTanks->WaterHeaterDesuperheater(this->DesuperheaterNum).setptTempSched->getCurrentVal(); } } // first HVAC Iteration @@ -6539,8 +6394,7 @@ void WaterThermalTankData::initialize(EnergyPlusData &state, bool const FirstHVA break; } case CrankcaseHeaterControlTemp::Schedule: { - state.dataHVACGlobal->HPWHCrankcaseDBTemp = - ScheduleManager::GetCurrentScheduleValue(state, state.dataWaterThermalTanks->HPWaterHeater(HPNum).CrankcaseTempSchedule); + state.dataHVACGlobal->HPWHCrankcaseDBTemp = state.dataWaterThermalTanks->HPWaterHeater(HPNum).crankcaseTempSched->getCurrentVal(); break; } default: @@ -6566,10 +6420,10 @@ void WaterThermalTankData::initialize(EnergyPlusData &state, bool const FirstHVA break; } case WTTAmbientTemp::ZoneAndOA: { - if (state.dataWaterThermalTanks->HPWaterHeater(HPNum).InletAirMixerSchPtr > 0) { + if (state.dataWaterThermalTanks->HPWaterHeater(HPNum).inletAirMixerSched != nullptr) { // schedule values are checked for boundary of 0 and 1 in GetWaterThermalTankInputFlag state.dataWaterThermalTanks->mixerInletAirSchedule = - ScheduleManager::GetCurrentScheduleValue(state, state.dataWaterThermalTanks->HPWaterHeater(HPNum).InletAirMixerSchPtr); + state.dataWaterThermalTanks->HPWaterHeater(HPNum).inletAirMixerSched->getCurrentVal(); } else { state.dataWaterThermalTanks->mixerInletAirSchedule = 0.0; } @@ -6587,9 +6441,8 @@ void WaterThermalTankData::initialize(EnergyPlusData &state, bool const FirstHVA break; } case WTTAmbientTemp::Schedule: { - HPInletDryBulbTemp = - ScheduleManager::GetCurrentScheduleValue(state, state.dataWaterThermalTanks->HPWaterHeater(HPNum).AmbientTempSchedule); - HPInletRelHum = ScheduleManager::GetCurrentScheduleValue(state, state.dataWaterThermalTanks->HPWaterHeater(HPNum).AmbientRHSchedule); + HPInletDryBulbTemp = state.dataWaterThermalTanks->HPWaterHeater(HPNum).ambientTempSched->getCurrentVal(); + HPInletRelHum = state.dataWaterThermalTanks->HPWaterHeater(HPNum).ambientRHSched->getCurrentVal(); HPInletHumRat = Psychrometrics::PsyWFnTdbRhPb(state, HPInletDryBulbTemp, HPInletRelHum, state.dataEnvrn->OutBaroPress, RoutineName); state.dataLoopNodes->Node(HPAirInletNode).Temp = HPInletDryBulbTemp; state.dataLoopNodes->Node(HPAirInletNode).HumRat = HPInletHumRat; @@ -8501,7 +8354,7 @@ void WaterThermalTankData::CalcDesuperheaterWaterHeater(EnergyPlusData &state, b DesupHtr.PumpEnergy = 0.0; // simulate only the water heater tank if the desuperheater coil is scheduled off - Real64 AvailSchedule = ScheduleManager::GetCurrentScheduleValue(state, DesupHtr.AvailSchedPtr); + Real64 AvailSchedule = DesupHtr.availSched->getCurrentVal(); if (AvailSchedule == 0.0) { DesupHtr.Mode = TankOperatingMode::Floating; this->CalcWaterThermalTank(state); @@ -8988,7 +8841,7 @@ void WaterThermalTankData::CalcHeatPumpWaterHeater(EnergyPlusData &state, bool c HeatPumpWaterHeaterData &HeatPump = state.dataWaterThermalTanks->HPWaterHeater(this->HeatPumpNum); // initialize local variables - int AvailSchedule = ScheduleManager::GetCurrentScheduleValue(state, HeatPump.AvailSchedPtr); + int AvailSchedule = HeatPump.availSched->getCurrentVal(); int HPAirInletNode = HeatPump.HeatPumpAirInletNode; int HPAirOutletNode = HeatPump.HeatPumpAirOutletNode; int OutdoorAirNode = HeatPump.OutsideAirNode; @@ -10029,8 +9882,8 @@ void WaterThermalTankData::CalcHeatPumpWaterHeater(EnergyPlusData &state, bool c } // Check schedule to divert air-side cooling to outdoors. - if (HeatPump.OutletAirSplitterSchPtr > 0) { - Real64 OutletAirSplitterSch = ScheduleManager::GetCurrentScheduleValue(state, HeatPump.OutletAirSplitterSchPtr); + if (HeatPump.outletAirSplitterSched != nullptr) { + Real64 OutletAirSplitterSch = HeatPump.outletAirSplitterSched->getCurrentVal(); state.dataLoopNodes->Node(HPAirOutletNode).MassFlowRate = state.dataWaterThermalTanks->mdotAir * state.dataWaterThermalTanks->hpPartLoadRatio * (1.0 - OutletAirSplitterSch); state.dataLoopNodes->Node(ExhaustAirNode).MassFlowRate = @@ -10340,7 +10193,7 @@ Real64 WaterThermalTankData::PLRResidualHPWH( return desTankTemp - NewTankTemp; } -bool WaterThermalTankData::SourceHeatNeed(EnergyPlusData &state, Real64 const OutletTemp, Real64 const DeadBandTemp, Real64 const SetPointTemp_loc) +bool WaterThermalTankData::SourceHeatNeed([[maybe_unused]] EnergyPlusData &state, Real64 const OutletTemp, Real64 const DeadBandTemp, Real64 const SetPointTemp_loc) { // FUNCTION INFORMATION: // AUTHOR Yueyue Zhou @@ -10371,7 +10224,7 @@ bool WaterThermalTankData::SourceHeatNeed(EnergyPlusData &state, Real64 const Ou } } else if (this->SourceSideControlMode == SourceSideControl::IndirectHeatAltSetpoint) { // get alternate setpoint - Real64 const AltSetpointTemp = ScheduleManager::GetCurrentScheduleValue(state, this->SourceSideAltSetpointSchedNum); + Real64 const AltSetpointTemp = this->sourceSideAltSetpointSched->getCurrentVal(); Real64 const AltDeadBandTemp = AltSetpointTemp - this->DeadBandDeltaTemp; if (OutletTemp < AltDeadBandTemp) { NeedsHeatOrCool = true; @@ -10481,11 +10334,11 @@ Real64 WaterThermalTankData::PlantMassFlowRatesFunc(EnergyPlusData &state, // evaluate Availability schedule, bool ScheduledAvail = true; if (WaterThermalTankSide == WaterHeaterSide::Use) { - if (ScheduleManager::GetCurrentScheduleValue(state, this->UseSideAvailSchedNum) == 0.0) { + if (this->useSideAvailSched->getCurrentVal() == 0.0) { ScheduledAvail = false; } } else if (WaterThermalTankSide == WaterHeaterSide::Source) { - if (ScheduleManager::GetCurrentScheduleValue(state, this->SourceSideAvailSchedNum) == 0.0) { + if (this->sourceSideAvailSched->getCurrentVal() == 0.0) { ScheduledAvail = false; } } @@ -11031,7 +10884,7 @@ void WaterThermalTankData::SizeTankForDemandSide(EnergyPlusData &state) Cp = FluidProperties::GetSpecificHeatGlycol(state, fluidNameWater, ((Tfinish + Tstart) / 2.0), this->waterIndex, RoutineName); } - tmpMaxCapacity = SumPeopleAllZones * this->Sizing.RecoveryCapacityPerPerson * (Tfinish - Tstart) * (1.0 / Constant::SecInHour) * rho * + tmpMaxCapacity = SumPeopleAllZones * this->Sizing.RecoveryCapacityPerPerson * (Tfinish - Tstart) * (1.0 / Constant::rSecsInHour) * rho * Cp; // m3/hr/person | delta T in K | 1 hr/ 3600 s | kg/m3 | J/Kg/k } @@ -11081,7 +10934,7 @@ void WaterThermalTankData::SizeTankForDemandSide(EnergyPlusData &state) rho = FluidProperties::GetDensityGlycol(state, fluidNameWater, ((Tfinish + Tstart) / 2.0), this->waterIndex, RoutineName); Cp = FluidProperties::GetSpecificHeatGlycol(state, fluidNameWater, ((Tfinish + Tstart) / 2.0), this->waterIndex, RoutineName); } - tmpMaxCapacity = SumFloorAreaAllZones * this->Sizing.RecoveryCapacityPerArea * (Tfinish - Tstart) * (1.0 / Constant::SecInHour) * rho * + tmpMaxCapacity = SumFloorAreaAllZones * this->Sizing.RecoveryCapacityPerArea * (Tfinish - Tstart) * (1.0 / Constant::rSecsInHour) * rho * Cp; // m2 | m3/hr/m2 | delta T in K | 1 hr/ 3600 s | kg/m3 | J/Kg/k } if (this->VolumeWasAutoSized && state.dataPlnt->PlantFirstSizesOkayToFinalize) { @@ -11126,7 +10979,7 @@ void WaterThermalTankData::SizeTankForDemandSide(EnergyPlusData &state) rho = FluidProperties::GetDensityGlycol(state, fluidNameWater, ((Tfinish + Tstart) / 2.0), this->waterIndex, RoutineName); Cp = FluidProperties::GetSpecificHeatGlycol(state, fluidNameWater, ((Tfinish + Tstart) / 2.0), this->waterIndex, RoutineName); } - tmpMaxCapacity = this->Sizing.NumberOfUnits * this->Sizing.RecoveryCapacityPerUnit * (Tfinish - Tstart) * (1.0 / Constant::SecInHour) * + tmpMaxCapacity = this->Sizing.NumberOfUnits * this->Sizing.RecoveryCapacityPerUnit * (Tfinish - Tstart) * (1.0 / Constant::rSecsInHour) * rho * Cp; // m3/hr/ea | delta T in K | 1 hr/ 3600 s | kg/m3 | J/Kg/k } @@ -11207,7 +11060,7 @@ void WaterThermalTankData::SizeTankForSupplySide(EnergyPlusData &state) if (this->Sizing.DesignMode == SizingMode::PeakDraw) { if (this->VolumeWasAutoSized) - tmpTankVolume = this->Sizing.TankDrawTime * this->UseDesignVolFlowRate * Constant::SecInHour; // hours | m3/s | (3600 s/1 hour) + tmpTankVolume = this->Sizing.TankDrawTime * this->UseDesignVolFlowRate * Constant::rSecsInHour; // hours | m3/s | (3600 s/1 hour) if (this->VolumeWasAutoSized && state.dataPlnt->PlantFirstSizesOkayToFinalize) { this->Volume = tmpTankVolume; if (state.dataPlnt->PlantFinalSizesOkayToReport) { @@ -11240,7 +11093,7 @@ void WaterThermalTankData::SizeTankForSupplySide(EnergyPlusData &state) Cp = FluidProperties::GetSpecificHeatGlycol(state, fluidNameWater, ((Tfinish + Tstart) / 2.0), this->waterIndex, RoutineName); } tmpMaxCapacity = (this->Volume * rho * Cp * (Tfinish - Tstart)) / - (this->Sizing.RecoveryTime * Constant::SecInHour); // m3 | kg/m3 | J/Kg/K | K | seconds + (this->Sizing.RecoveryTime * Constant::rSecsInHour); // m3 | kg/m3 | J/Kg/K | K | seconds } else { ShowFatalError( state, format("{}: Tank=\"{}\", requested sizing for max capacity but entered Recovery Time is zero.", RoutineName, this->Name)); @@ -11381,18 +11234,18 @@ void WaterThermalTankData::SizeDemandSidePlantConnections(EnergyPlusData &state) Real64 eff = this->UseEffectiveness; if ((Tpdesign >= 58.0) && (!this->IsChilledWaterTank)) { if (state.dataPlnt->PlantFirstSizesOkayToFinalize) { - this->UseDesignVolFlowRate = -1.0 * (TankVolume / (tankRecoverhours * Constant::SecInHour * eff)) * + this->UseDesignVolFlowRate = -1.0 * (TankVolume / (tankRecoverhours * Constant::rSecsInHour * eff)) * std::log((Tpdesign - Tfinish) / (Tpdesign - Tstart)); } else { - tmpUseDesignVolFlowRate = -1.0 * (TankVolume / (tankRecoverhours * Constant::SecInHour * eff)) * + tmpUseDesignVolFlowRate = -1.0 * (TankVolume / (tankRecoverhours * Constant::rSecsInHour * eff)) * std::log((Tpdesign - Tfinish) / (Tpdesign - Tstart)); } } else if ((Tpdesign <= 8.0) && (this->IsChilledWaterTank)) { if (state.dataPlnt->PlantFirstSizesOkayToFinalize) { - this->UseDesignVolFlowRate = -1.0 * (TankVolume / (tankRecoverhours * Constant::SecInHour * eff)) * + this->UseDesignVolFlowRate = -1.0 * (TankVolume / (tankRecoverhours * Constant::rSecsInHour * eff)) * std::log((Tpdesign - Tfinish) / (Tpdesign - Tstart)); } else { - tmpUseDesignVolFlowRate = -1.0 * (TankVolume / (tankRecoverhours * Constant::SecInHour * eff)) * + tmpUseDesignVolFlowRate = -1.0 * (TankVolume / (tankRecoverhours * Constant::rSecsInHour * eff)) * std::log((Tpdesign - Tfinish) / (Tpdesign - Tstart)); } } else { @@ -11468,18 +11321,18 @@ void WaterThermalTankData::SizeDemandSidePlantConnections(EnergyPlusData &state) if ((Tpdesign >= 58.0) && (!this->IsChilledWaterTank)) { if (state.dataPlnt->PlantFirstSizesOkayToFinalize) { - this->SourceDesignVolFlowRate = -1.0 * (TankVolume / (tankRecoverhours * Constant::SecInHour * eff)) * + this->SourceDesignVolFlowRate = -1.0 * (TankVolume / (tankRecoverhours * Constant::rSecsInHour * eff)) * std::log((Tpdesign - Tfinish) / (Tpdesign - Tstart)); } else { - tmpSourceDesignVolFlowRate = -1.0 * (TankVolume / (tankRecoverhours * Constant::SecInHour * eff)) * + tmpSourceDesignVolFlowRate = -1.0 * (TankVolume / (tankRecoverhours * Constant::rSecsInHour * eff)) * std::log((Tpdesign - Tfinish) / (Tpdesign - Tstart)); } } else if ((Tpdesign <= 8.0) && (this->IsChilledWaterTank)) { if (state.dataPlnt->PlantFirstSizesOkayToFinalize) { - this->SourceDesignVolFlowRate = -1.0 * (TankVolume / (tankRecoverhours * Constant::SecInHour * eff)) * + this->SourceDesignVolFlowRate = -1.0 * (TankVolume / (tankRecoverhours * Constant::rSecsInHour * eff)) * std::log((Tpdesign - Tfinish) / (Tpdesign - Tstart)); } else { - tmpSourceDesignVolFlowRate = -1.0 * (TankVolume / (tankRecoverhours * Constant::SecInHour * eff)) * + tmpSourceDesignVolFlowRate = -1.0 * (TankVolume / (tankRecoverhours * Constant::rSecsInHour * eff)) * std::log((Tpdesign - Tfinish) / (Tpdesign - Tstart)); } } else { @@ -11580,10 +11433,10 @@ void WaterThermalTankData::SizeStandAloneWaterHeater(EnergyPlusData &state) case SizingMode::PeakDraw: { // get draw rate from maximum in schedule Real64 rho = FluidProperties::GetDensityGlycol(state, fluidNameWater, Constant::InitConvTemp, this->waterIndex, RoutineName); - Real64 DrawDesignVolFlowRate = ScheduleManager::GetScheduleMaxValue(state, this->FlowRateSchedule) * this->MassFlowRateMax / rho; + Real64 DrawDesignVolFlowRate = this->flowRateSched->getCurrentVal() * this->MassFlowRateMax / rho; if (this->VolumeWasAutoSized) { - tmpTankVolume = this->Sizing.TankDrawTime * DrawDesignVolFlowRate * Constant::SecInHour; // hours | m3/s | (3600 s/1 hour) + tmpTankVolume = this->Sizing.TankDrawTime * DrawDesignVolFlowRate * Constant::rSecsInHour; // hours | m3/s | (3600 s/1 hour) this->Volume = tmpTankVolume; BaseSizer::reportSizerOutput(state, this->Type, this->Name, "Tank Volume [m3]", this->Volume); } @@ -11594,7 +11447,7 @@ void WaterThermalTankData::SizeStandAloneWaterHeater(EnergyPlusData &state) FluidProperties::GetSpecificHeatGlycol(state, fluidNameWater, ((Tfinish + Tstart) / 2.0), this->waterIndex, RoutineName); tmpMaxCapacity = (this->Volume * rho * Cp * (Tfinish - Tstart)) / - (this->Sizing.RecoveryTime * Constant::SecInHour); // m3 | kg/m3 | J/Kg/K | K | seconds + (this->Sizing.RecoveryTime * Constant::rSecsInHour); // m3 | kg/m3 | J/Kg/K | K | seconds } else { ShowFatalError( state, @@ -11756,7 +11609,7 @@ void WaterThermalTankData::SizeStandAloneWaterHeater(EnergyPlusData &state) if (this->MaxCapacityWasAutoSized) { Real64 rho = FluidProperties::GetDensityGlycol(state, fluidNameWater, ((Tfinish + Tstart) / 2.0), this->waterIndex, RoutineName); Real64 Cp = FluidProperties::GetSpecificHeatGlycol(state, fluidNameWater, ((Tfinish + Tstart) / 2.0), this->waterIndex, RoutineName); - tmpMaxCapacity = SumPeopleAllZones * this->Sizing.RecoveryCapacityPerPerson * (Tfinish - Tstart) * (1.0 / Constant::SecInHour) * rho * + tmpMaxCapacity = SumPeopleAllZones * this->Sizing.RecoveryCapacityPerPerson * (Tfinish - Tstart) * (1.0 / Constant::rSecsInHour) * rho * Cp; // m3/hr/person | delta T in K | 1 hr/ 3600 s | kg/m3 | J/Kg/k } @@ -11785,7 +11638,7 @@ void WaterThermalTankData::SizeStandAloneWaterHeater(EnergyPlusData &state) if (this->MaxCapacityWasAutoSized) { Real64 rho = FluidProperties::GetDensityGlycol(state, fluidNameWater, ((Tfinish + Tstart) / 2.0), this->waterIndex, RoutineName); Real64 Cp = FluidProperties::GetSpecificHeatGlycol(state, fluidNameWater, ((Tfinish + Tstart) / 2.0), this->waterIndex, RoutineName); - tmpMaxCapacity = SumFloorAreaAllZones * this->Sizing.RecoveryCapacityPerArea * (Tfinish - Tstart) * (1.0 / Constant::SecInHour) * + tmpMaxCapacity = SumFloorAreaAllZones * this->Sizing.RecoveryCapacityPerArea * (Tfinish - Tstart) * (1.0 / Constant::rSecsInHour) * rho * Cp; // m2 | m3/hr/m2 | delta T in K | 1 hr/ 3600 s | kg/m3 | J/Kg/k } if (this->VolumeWasAutoSized) { @@ -11806,7 +11659,7 @@ void WaterThermalTankData::SizeStandAloneWaterHeater(EnergyPlusData &state) Real64 rho = FluidProperties::GetDensityGlycol(state, fluidNameWater, ((Tfinish + Tstart) / 2.0), this->waterIndex, RoutineName); Real64 Cp = FluidProperties::GetSpecificHeatGlycol(state, fluidNameWater, ((Tfinish + Tstart) / 2.0), this->waterIndex, RoutineName); tmpMaxCapacity = this->Sizing.NumberOfUnits * this->Sizing.RecoveryCapacityPerUnit * (Tfinish - Tstart) * - (1.0 / Constant::SecInHour) * rho * Cp; // m3/hr/ea | delta T in K | 1 hr/ 3600 s | kg/m3 | J/Kg/k + (1.0 / Constant::rSecsInHour) * rho * Cp; // m3/hr/ea | delta T in K | 1 hr/ 3600 s | kg/m3 | J/Kg/k } if (this->VolumeWasAutoSized) { diff --git a/src/EnergyPlus/WaterThermalTanks.hh b/src/EnergyPlus/WaterThermalTanks.hh index db9657f0809..41bba0e2476 100644 --- a/src/EnergyPlus/WaterThermalTanks.hh +++ b/src/EnergyPlus/WaterThermalTanks.hh @@ -298,8 +298,8 @@ namespace WaterThermalTanks { std::string TankType; // Type of water heater (MIXED or STRATIFIED) used with heat pump DataPlant::PlantEquipmentType HPWHTankType; // Parameter for tank type (MIXED or STRATIFIED) bool StandAlone; // Flag for operation with no plant connections (no use nodes) - int AvailSchedPtr; // Index to Availability Schedule curve index - int SetPointTempSchedule; // Index to Setpoint Temperature Schedule curve + Sched::Schedule *availSched = nullptr; // Availability Schedule + Sched::Schedule *setptTempSched = nullptr; // Setpoint Temperature Schedule Real64 DeadBandTempDiff; // Dead band temperature difference (cut-in temperature) Real64 Capacity; // Heat Pump rated capacity (W) Real64 BackupElementCapacity; // Tank backup element capacity (W) @@ -341,8 +341,8 @@ namespace WaterThermalTanks { HVAC::FanPlace fanPlace; // Location of Fan int FanOutletNode; // Outlet node of heat pump water heater fan int WaterHeaterTankNum; // Index of Water Heater Tank - int OutletAirSplitterSchPtr; // Index to air-side outlet air splitter schedule - int InletAirMixerSchPtr; // Index to air-side inlet air mixer schedule + Sched::Schedule *outletAirSplitterSched = nullptr; // air-side outlet air splitter schedule + Sched::Schedule *inletAirMixerSched = nullptr; // air-side inlet air mixer schedule TankOperatingMode Mode = TankOperatingMode::Floating; // HP mode (0 = float, 1 = heating [-1 = venting na for HP]) TankOperatingMode SaveMode = TankOperatingMode::Floating; // HP mode on first iteration TankOperatingMode SaveWHMode = TankOperatingMode::Floating; // mode of water heater tank element (backup element) @@ -356,11 +356,11 @@ namespace WaterThermalTanks { int OutletAirSplitterNode; // Outlet air splitter node number of HP water heater Real64 SourceMassFlowRate; // Maximum mass flow rate on the source side (kg/s) WTTAmbientTemp InletAirConfiguration; // Identifies source of HPWH inlet air - int AmbientTempSchedule; // Schedule index pointer for ambient air temp at HPWH inlet - int AmbientRHSchedule; // Schedule index pointer for ambient air RH at HPWH inlet + Sched::Schedule *ambientTempSched = nullptr; // Schedule for ambient air temp at HPWH inlet + Sched::Schedule *ambientRHSched = nullptr; // Schedule for ambient air RH at HPWH inlet int AmbientTempZone; // Index of ambient zone for ambient air at HPWH inlet CrankcaseHeaterControlTemp CrankcaseTempIndicator; // Indicator for HPWH compressor/crankcase heater location - int CrankcaseTempSchedule; // Schedule index pointer where crankcase heater is located + Sched::Schedule *crankcaseTempSched = nullptr; // Schedule for crankcase heater int CrankcaseTempZone; // Index of zone where compressor/crankcase heater is located Real64 OffCycParaLoad; // Rate for off-cycle parasitic load (W) Real64 OnCycParaLoad; // Rate for on-cycle parasitic load (W) @@ -425,17 +425,17 @@ namespace WaterThermalTanks { // Default Constructor HeatPumpWaterHeaterData() : HPWHType(DataPlant::PlantEquipmentType::Invalid), HPWHTankType(DataPlant::PlantEquipmentType::Invalid), StandAlone(false), - AvailSchedPtr(0), SetPointTempSchedule(0), DeadBandTempDiff(0.0), Capacity(0.0), BackupElementCapacity(0.0), + DeadBandTempDiff(0.0), Capacity(0.0), BackupElementCapacity(0.0), BackupElementEfficiency(0.0), WHOnCycParaLoad(0.0), WHOffCycParaLoad(0.0), WHOnCycParaFracToTank(0.0), WHOffCycParaFracToTank(0.0), WHPLFCurve(0), OperatingAirFlowRate(0.0), OperatingAirMassFlowRate(0.0), OperatingWaterFlowRate(0.0), COP(0.0), SHR(0.0), RatedInletDBTemp(0.0), RatedInletWBTemp(0.0), RatedInletWaterTemp(0.0), FoundTank(false), HeatPumpAirInletNode(0), HeatPumpAirOutletNode(0), OutsideAirNode(0), ExhaustAirNode(0), CondWaterInletNode(0), CondWaterOutletNode(0), WHUseInletNode(0), WHUseOutletNode(0), WHUseSidePlantLoopNum(0), DXCoilNum(0), DXCoilTypeNum(0), DXCoilAirInletNode(0), DXCoilPLFFPLR(0), fanType(HVAC::FanType::Invalid), FanNum(0), fanPlace(HVAC::FanPlace::Invalid), FanOutletNode(0), WaterHeaterTankNum(0), - OutletAirSplitterSchPtr(0), InletAirMixerSchPtr(0), Power(0.0), Energy(0.0), HeatingPLR(0.0), SetPointTemp(0.0), + Power(0.0), Energy(0.0), HeatingPLR(0.0), SetPointTemp(0.0), MinAirTempForHPOperation(5.0), MaxAirTempForHPOperation(48.8888888889), InletAirMixerNode(0), OutletAirSplitterNode(0), - SourceMassFlowRate(0.0), InletAirConfiguration(WTTAmbientTemp::OutsideAir), AmbientTempSchedule(0), AmbientRHSchedule(0), - AmbientTempZone(0), CrankcaseTempIndicator(CrankcaseHeaterControlTemp::Schedule), CrankcaseTempSchedule(0), CrankcaseTempZone(0), + SourceMassFlowRate(0.0), InletAirConfiguration(WTTAmbientTemp::OutsideAir), + AmbientTempZone(0), CrankcaseTempIndicator(CrankcaseHeaterControlTemp::Schedule), CrankcaseTempZone(0), OffCycParaLoad(0.0), OnCycParaLoad(0.0), ParasiticTempIndicator(WTTAmbientTemp::OutsideAir), OffCycParaFuelRate(0.0), OnCycParaFuelRate(0.0), OffCycParaFuelEnergy(0.0), OnCycParaFuelEnergy(0.0), AirFlowRateAutoSized(false), WaterFlowRateAutoSized(false), HPSetPointError(0), HPSetPointErrIndex1(0), IterLimitErrIndex1(0), IterLimitExceededNum1(0), RegulaFalsiFailedIndex1(0), @@ -483,7 +483,7 @@ namespace WaterThermalTanks { Real64 TimeElapsed; // Fraction of the current hour that has elapsed (h) // Saved in order to identify the beginning of a new system time WTTAmbientTemp AmbientTempIndicator; // Indicator for ambient tank losses (SCHEDULE, ZONE, EXTERIOR) - int AmbientTempSchedule; // Schedule index pointer + Sched::Schedule *ambientTempSched = nullptr; // Schedule int AmbientTempZone; // Number of ambient zone around tank int AmbientTempOutsideAirNode; // Number of outside air node Real64 AmbientTemp; // Ambient temperature around tank (C) @@ -503,7 +503,7 @@ namespace WaterThermalTanks { Real64 MinCapacity; // Minimum capacity of auxiliary heater 1 (W) Real64 Efficiency; // Thermal efficiency of auxiliary heater 1 () int PLFCurve; // Part load factor curve as a function of part load ratio - int SetPointTempSchedule; // Schedule index pointer + Sched::Schedule *setptTempSched = nullptr; // Schedule Real64 SetPointTemp; // Setpoint temperature of auxiliary heater 1 (C) Real64 DeadBandDeltaTemp; // Deadband temperature difference of auxiliary heater 1 (deltaC) Real64 TankTempLimit; // Maximum tank temperature limit before venting (C) @@ -528,7 +528,7 @@ namespace WaterThermalTanks { DataBranchAirLoopPlant::ControlType UseBranchControlType; // Use side plant branch control type e.g active, passive, bypass int UseSidePlantSizNum; // index in plant sizing that the use side is on bool UseSideSeries; - int UseSideAvailSchedNum; // use side availability schedule + Sched::Schedule *useSideAvailSched = nullptr; // use side availability schedule Real64 UseSideLoadRequested; // hold MyLoad request from plant management. PlantLocation UseSidePlantLoc; int SourceInletNode; // Inlet node for the source side; hot water from supply @@ -544,16 +544,16 @@ namespace WaterThermalTanks { DataBranchAirLoopPlant::ControlType SourceBranchControlType; // source side plant branch control type e.g active, passive, bypass int SourceSidePlantSizNum; // index in plant sizing that the source side is on bool SourceSideSeries; - int SourceSideAvailSchedNum; // source side availability schedule. + Sched::Schedule *sourceSideAvailSched = nullptr; // source side availability schedule. PlantLocation SrcSidePlantLoc; SourceSideControl SourceSideControlMode; // flag for how source side flow is controlled - int SourceSideAltSetpointSchedNum; // schedule of alternate temperature setpoint values + Sched::Schedule *sourceSideAltSetpointSched = nullptr; // schedule of alternate temperature setpoint values Real64 SizingRecoveryTime; // sizing parameter for autosizing indirect water heaters (hr) Real64 MassFlowRateMax; // Maximum flow rate for scheduled DHW (kg/s) Real64 VolFlowRateMin; // Minimum flow rate for heater ignition (kg/s) Real64 MassFlowRateMin; // Minimum mass flow rate for heater ignition (kg/s) - int FlowRateSchedule; // Schedule index pointer - int UseInletTempSchedule; // Cold water supply temperature schedule index pointer + Sched::Schedule *flowRateSched = nullptr; // Schedule + Sched::Schedule *useInletTempSched = nullptr; // Cold water supply temperature schedule Real64 TankTemp; // Temperature of tank fluid (average, if stratified) (C) Real64 SavedTankTemp; // Tank temp that is carried from time step to time step (C) Real64 TankTempAvg; // Average tank temperature over the time step (C) @@ -572,7 +572,7 @@ namespace WaterThermalTanks { bool SavedHeaterOn2; Real64 AdditionalCond; // Additional destratification conductivity (W/m K) Real64 SetPointTemp2; // Setpoint temperature of auxiliary heater 2 (C) - int SetPointTempSchedule2; + Sched::Schedule *setptTemp2Sched = nullptr; Real64 DeadBandDeltaTemp2; Real64 MaxCapacity2; Real64 OffCycParaHeight; @@ -677,25 +677,25 @@ namespace WaterThermalTanks { // Default Constructor WaterThermalTankData() : WaterThermalTankType(DataPlant::PlantEquipmentType::Invalid), IsChilledWaterTank(false), Init(true), StandAlone(false), Volume(0.0), - VolumeWasAutoSized(false), Mass(0.0), TimeElapsed(0.0), AmbientTempIndicator(WTTAmbientTemp::OutsideAir), AmbientTempSchedule(0), + VolumeWasAutoSized(false), Mass(0.0), TimeElapsed(0.0), AmbientTempIndicator(WTTAmbientTemp::OutsideAir), AmbientTempZone(0), AmbientTempOutsideAirNode(0), AmbientTemp(0.0), AmbientZoneGain(0.0), LossCoeff(0.0), OffCycLossCoeff(0.0), OffCycLossFracToZone(0.0), OnCycLossCoeff(0.0), OnCycLossFracToZone(0.0), ControlType(HeaterControlMode::Cycle), StratifiedControlMode(PriorityControlMode::Invalid), MaxCapacity(0.0), MaxCapacityWasAutoSized(false), MinCapacity(0.0), - Efficiency(0.0), PLFCurve(0), SetPointTempSchedule(0), SetPointTemp(0.0), DeadBandDeltaTemp(0.0), TankTempLimit(0.0), + Efficiency(0.0), PLFCurve(0), SetPointTemp(0.0), DeadBandDeltaTemp(0.0), TankTempLimit(0.0), IgnitionDelay(0.0), OffCycParaLoad(0.0), OffCycParaFracToTank(0.0), OnCycParaLoad(0.0), OnCycParaFracToTank(0.0), UseCurrentFlowLock(DataPlant::FlowLock::Unlocked), UseInletNode(0), UseInletTemp(0.0), UseOutletNode(0), UseOutletTemp(0.0), UseMassFlowRate(0.0), UseEffectiveness(0.0), PlantUseMassFlowRateMax(0.0), SavedUseOutletTemp(0.0), UseDesignVolFlowRate(0.0), UseDesignVolFlowRateWasAutoSized(false), UseBranchControlType(DataBranchAirLoopPlant::ControlType::Passive), UseSidePlantSizNum(0), - UseSideSeries(true), UseSideAvailSchedNum(0), UseSideLoadRequested(0.0), UseSidePlantLoc{}, SourceInletNode(0), SourceInletTemp(0.0), + UseSideSeries(true), UseSideLoadRequested(0.0), UseSidePlantLoc{}, SourceInletNode(0), SourceInletTemp(0.0), SourceOutletNode(0), SourceOutletTemp(0.0), SourceMassFlowRate(0.0), SourceEffectiveness(0.0), PlantSourceMassFlowRateMax(0.0), SavedSourceOutletTemp(0.0), SourceDesignVolFlowRate(0.0), SourceDesignVolFlowRateWasAutoSized(false), SourceBranchControlType(DataBranchAirLoopPlant::ControlType::Passive), SourceSidePlantSizNum(0), SourceSideSeries(true), - SourceSideAvailSchedNum(0), SrcSidePlantLoc{}, SourceSideControlMode(SourceSideControl::IndirectHeatAltSetpoint), - SourceSideAltSetpointSchedNum(0), SizingRecoveryTime(0.0), MassFlowRateMax(0.0), VolFlowRateMin(0.0), MassFlowRateMin(0.0), - FlowRateSchedule(0), UseInletTempSchedule(0), TankTemp(0.0), SavedTankTemp(0.0), TankTempAvg(0.0), Height(0.0), + SrcSidePlantLoc{}, SourceSideControlMode(SourceSideControl::IndirectHeatAltSetpoint), + SizingRecoveryTime(0.0), MassFlowRateMax(0.0), VolFlowRateMin(0.0), MassFlowRateMin(0.0), + TankTemp(0.0), SavedTankTemp(0.0), TankTempAvg(0.0), Height(0.0), HeightWasAutoSized(false), Perimeter(0.0), Shape(TankShape::VertCylinder), HeaterHeight1(0.0), HeaterNode1(0), HeaterOn1(false), SavedHeaterOn1(false), HeaterHeight2(0.0), HeaterNode2(0), HeaterOn2(false), SavedHeaterOn2(false), AdditionalCond(0.0), - SetPointTemp2(0.0), SetPointTempSchedule2(0), DeadBandDeltaTemp2(0.0), MaxCapacity2(0.0), OffCycParaHeight(0.0), OnCycParaHeight(0.0), + SetPointTemp2(0.0), DeadBandDeltaTemp2(0.0), MaxCapacity2(0.0), OffCycParaHeight(0.0), OnCycParaHeight(0.0), SkinLossCoeff(0.0), SkinLossFracToZone(0.0), OffCycFlueLossCoeff(0.0), OffCycFlueLossFracToZone(0.0), UseInletHeight(0.0), UseOutletHeight(0.0), UseOutletHeightWasAutoSized(false), SourceInletHeight(0.0), SourceInletHeightWasAutoSized(false), SourceOutletHeight(0.0), UseInletStratNode(0), UseOutletStratNode(0), SourceInletStratNode(0), SourceOutletStratNode(0), @@ -884,8 +884,8 @@ namespace WaterThermalTanks { std::string Name; // Name of heat pump water heater desuperheater std::string Type; // Type of water heater desuperheating coil int InsuffTemperatureWarn; // Used for recurring error count on low source temperature - int AvailSchedPtr; // Index to Availability Schedule curve index - int SetPointTempSchedule; // Index to Setpoint Temperature Schedule curve + Sched::Schedule *availSched = nullptr; // Availability Schedule + Sched::Schedule *setptTempSched = nullptr; // Setpoint Temperature Schedule Real64 DeadBandTempDiff; // Dead band temperature difference (cut-in temperature) Real64 HeatReclaimRecoveryEff; // recovery efficiency of desuperheater (0.3 max) int WaterInletNode; // Desuperheater water inlet node @@ -945,7 +945,7 @@ namespace WaterThermalTanks { // Default Constructor WaterHeaterDesuperheaterData() - : InsuffTemperatureWarn(0), AvailSchedPtr(0), SetPointTempSchedule(0), DeadBandTempDiff(0.0), HeatReclaimRecoveryEff(0.0), + : InsuffTemperatureWarn(0), DeadBandTempDiff(0.0), HeatReclaimRecoveryEff(0.0), WaterInletNode(0), WaterOutletNode(0), RatedInletWaterTemp(0.0), RatedOutdoorAirTemp(0.0), MaxInletWaterTemp(0.0), TankTypeNum(DataPlant::PlantEquipmentType::Invalid), TankNum(0), StandAlone(false), HeaterRate(0.0), HeaterEnergy(0.0), PumpPower(0.0), PumpEnergy(0.0), PumpElecPower(0.0), PumpFracToWater(0.0), OperatingWaterFlowRate(0.0), HEffFTemp(0), HEffFTempOutput(0.0), @@ -1018,6 +1018,10 @@ struct WaterThermalTanksData : BaseGlobalStruct bool getWaterThermalTankInputFlag = true; // Calls to Water Heater from multiple places in code bool calcWaterThermalTankZoneGainsMyEnvrnFlag = true; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/WaterToAirHeatPump.hh b/src/EnergyPlus/WaterToAirHeatPump.hh index fa20d1e4711..b8f5ff1bae1 100644 --- a/src/EnergyPlus/WaterToAirHeatPump.hh +++ b/src/EnergyPlus/WaterToAirHeatPump.hh @@ -279,6 +279,10 @@ struct WaterToAirHeatPumpData : BaseGlobalStruct Real64 LoadSideInletHumRat_Init = 0.0; // rated conditions Real64 LoadSideAirInletEnth_Init = 0.0; // rated conditions + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/WaterToAirHeatPumpSimple.hh b/src/EnergyPlus/WaterToAirHeatPumpSimple.hh index a05490dd5f1..b5d6604a075 100644 --- a/src/EnergyPlus/WaterToAirHeatPumpSimple.hh +++ b/src/EnergyPlus/WaterToAirHeatPumpSimple.hh @@ -308,6 +308,10 @@ struct WaterToAirHeatPumpSimpleData : BaseGlobalStruct Real64 LoadSideInletEnth_Init = 0; // rated conditions Real64 CpAir_Init = 0; // rated conditions + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/WaterUse.cc b/src/EnergyPlus/WaterUse.cc index 9d3a86681f6..dcd754276aa 100644 --- a/src/EnergyPlus/WaterUse.cc +++ b/src/EnergyPlus/WaterUse.cc @@ -274,6 +274,8 @@ namespace WaterUse { // AUTHOR Peter Graham Ellis // DATE WRITTEN August 2006 + static constexpr std::string_view routineName = "GetWaterUseInput"; + bool ErrorsFound(false); // Set to true if errors in input, fatal at end of routine int IOStatus; // Used in GetObjectItem int NumAlphas; // Number of Alphas for each GetObjectItem call @@ -306,6 +308,8 @@ namespace WaterUse { state.dataIPShortCut->lAlphaFieldBlanks, state.dataIPShortCut->cAlphaFieldNames, state.dataIPShortCut->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1)}; Util::IsNameEmpty(state, state.dataIPShortCut->cAlphaArgs(1), state.dataIPShortCut->cCurrentModuleObject, ErrorsFound); thisWEq.Name = state.dataIPShortCut->cAlphaArgs(1); @@ -313,85 +317,46 @@ namespace WaterUse { thisWEq.PeakVolFlowRate = state.dataIPShortCut->rNumericArgs(1); - if ((NumAlphas > 2) && (!state.dataIPShortCut->lAlphaFieldBlanks(3))) { - thisWEq.FlowRateFracSchedule = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(3)); - // If no FlowRateFracSchedule, fraction defaults to 1.0 - - if (thisWEq.FlowRateFracSchedule == 0) { - ShowSevereError(state, - format("Invalid {} = {}", state.dataIPShortCut->cAlphaFieldNames(3), state.dataIPShortCut->cAlphaArgs(3))); - ShowContinueError(state, format("Entered in {} = {}", state.dataIPShortCut->cCurrentModuleObject, thisWEq.Name)); - ErrorsFound = true; - } + if ((NumAlphas <= 2) || (state.dataIPShortCut->lAlphaFieldBlanks(3))) { + } else if ((thisWEq.flowRateFracSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(3))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(3), state.dataIPShortCut->cAlphaArgs(3)); + ErrorsFound = true; } - if ((NumAlphas > 3) && (!state.dataIPShortCut->lAlphaFieldBlanks(4))) { - thisWEq.TargetTempSchedule = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(4)); - - if (thisWEq.TargetTempSchedule == 0) { - ShowSevereError(state, - format("Invalid {} = {}", state.dataIPShortCut->cAlphaFieldNames(4), state.dataIPShortCut->cAlphaArgs(4))); - ShowContinueError(state, format("Entered in {} = {}", state.dataIPShortCut->cCurrentModuleObject, thisWEq.Name)); - ErrorsFound = true; - } + if ((NumAlphas <= 3) || (state.dataIPShortCut->lAlphaFieldBlanks(4))) { + } else if ((thisWEq.targetTempSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(4))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(4), state.dataIPShortCut->cAlphaArgs(4)); + ErrorsFound = true; } - if ((NumAlphas > 4) && (!state.dataIPShortCut->lAlphaFieldBlanks(5))) { - thisWEq.HotTempSchedule = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(5)); - // If no HotTempSchedule, there is no hot water. - // HotTempSchedule is ignored if connected to a plant loop via WATER USE CONNECTIONS - - if (thisWEq.HotTempSchedule == 0) { - ShowSevereError(state, - format("Invalid {} = {}", state.dataIPShortCut->cAlphaFieldNames(5), state.dataIPShortCut->cAlphaArgs(5))); - ShowContinueError(state, format("Entered in {} = {}", state.dataIPShortCut->cCurrentModuleObject, thisWEq.Name)); - ErrorsFound = true; - } + if ((NumAlphas <= 4) || (state.dataIPShortCut->lAlphaFieldBlanks(5))) { + } else if ((thisWEq.hotTempSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(5))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(5), state.dataIPShortCut->cAlphaArgs(5)); + ErrorsFound = true; } - if ((NumAlphas > 5) && (!state.dataIPShortCut->lAlphaFieldBlanks(6))) { - thisWEq.ColdTempSchedule = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(6)); - // If no ColdTempSchedule, temperatures will be calculated by WATER MAINS TEMPERATURES object - - if (thisWEq.ColdTempSchedule == 0) { - ShowSevereError(state, - format("Invalid {} = {}", state.dataIPShortCut->cAlphaFieldNames(6), state.dataIPShortCut->cAlphaArgs(6))); - ShowContinueError(state, format("Entered in {} = {}", state.dataIPShortCut->cCurrentModuleObject, thisWEq.Name)); - ErrorsFound = true; - } + if ((NumAlphas <= 5) || (state.dataIPShortCut->lAlphaFieldBlanks(6))) { + } else if ((thisWEq.coldTempSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(6))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(6), state.dataIPShortCut->cAlphaArgs(6)); + ErrorsFound = true; } - if ((NumAlphas > 6) && (!state.dataIPShortCut->lAlphaFieldBlanks(7))) { - thisWEq.Zone = Util::FindItemInList(state.dataIPShortCut->cAlphaArgs(7), state.dataHeatBal->Zone); - - if (thisWEq.Zone == 0) { - ShowSevereError(state, - format("Invalid {} = {}", state.dataIPShortCut->cAlphaFieldNames(7), state.dataIPShortCut->cAlphaArgs(7))); - ShowContinueError(state, format("Entered in {} = {}", state.dataIPShortCut->cCurrentModuleObject, thisWEq.Name)); - ErrorsFound = true; - } + if ((NumAlphas <= 6) || (state.dataIPShortCut->lAlphaFieldBlanks(7))) { + } else if ((thisWEq.Zone = Util::FindItemInList(state.dataIPShortCut->cAlphaArgs(7), state.dataHeatBal->Zone)) == 0) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(7), state.dataIPShortCut->cAlphaArgs(7)); + ErrorsFound = true; } - if ((NumAlphas > 7) && (!state.dataIPShortCut->lAlphaFieldBlanks(8))) { - thisWEq.SensibleFracSchedule = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(8)); - - if (thisWEq.SensibleFracSchedule == 0) { - ShowSevereError(state, - format("Invalid {} = {}", state.dataIPShortCut->cAlphaFieldNames(8), state.dataIPShortCut->cAlphaArgs(8))); - ShowContinueError(state, format("Entered in {} = {}", state.dataIPShortCut->cCurrentModuleObject, thisWEq.Name)); - ErrorsFound = true; - } + if ((NumAlphas <= 7) || (state.dataIPShortCut->lAlphaFieldBlanks(8))) { + } else if ((thisWEq.sensibleFracSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(8))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(8), state.dataIPShortCut->cAlphaArgs(8)); + ErrorsFound = true; } - if ((NumAlphas > 8) && (!state.dataIPShortCut->lAlphaFieldBlanks(9))) { - thisWEq.LatentFracSchedule = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(9)); - - if (thisWEq.LatentFracSchedule == 0) { - ShowSevereError(state, - format("Invalid {}={}", state.dataIPShortCut->cAlphaFieldNames(9), state.dataIPShortCut->cAlphaArgs(9))); - ShowContinueError(state, format("Entered in {} = {}", state.dataIPShortCut->cCurrentModuleObject, thisWEq.Name)); - ErrorsFound = true; - } + if ((NumAlphas <= 8) || (state.dataIPShortCut->lAlphaFieldBlanks(9))) { + } else if ((thisWEq.latentFracSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(9))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(9), state.dataIPShortCut->cAlphaArgs(9)); + ErrorsFound = true; } } // WaterEquipNum @@ -419,6 +384,9 @@ namespace WaterUse { state.dataIPShortCut->lAlphaFieldBlanks, state.dataIPShortCut->cAlphaFieldNames, state.dataIPShortCut->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1)}; + Util::IsNameEmpty(state, state.dataIPShortCut->cAlphaArgs(1), state.dataIPShortCut->cCurrentModuleObject, ErrorsFound); auto &waterConnection = state.dataWaterUse->WaterConnections(WaterConnNum); waterConnection.Name = state.dataIPShortCut->cAlphaArgs(1); @@ -475,29 +443,16 @@ namespace WaterUse { waterConnection.TankSupplyID); } - if (!state.dataIPShortCut->lAlphaFieldBlanks(6)) { - waterConnection.HotTempSchedule = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(6)); - // If no HotTempSchedule, there is no hot water. - // HotTempSchedule is ignored if connected to a plant loop via WATER USE CONNECTIONS - - if (waterConnection.HotTempSchedule == 0) { - ShowSevereError(state, - format("Invalid {} = {}", state.dataIPShortCut->cAlphaFieldNames(6), state.dataIPShortCut->cAlphaArgs(6))); - ShowContinueError(state, format("Entered in {} = {}", state.dataIPShortCut->cCurrentModuleObject, waterConnection.Name)); - ErrorsFound = true; - } + if (state.dataIPShortCut->lAlphaFieldBlanks(6)) { + } else if ((waterConnection.hotTempSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(6))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(6), state.dataIPShortCut->cAlphaArgs(6)); + ErrorsFound = true; } - if (!state.dataIPShortCut->lAlphaFieldBlanks(7)) { - waterConnection.ColdTempSchedule = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(7)); - // If no ColdTempSchedule, temperatures will be calculated by WATER MAINS TEMPERATURES object - - if (waterConnection.ColdTempSchedule == 0) { - ShowSevereError(state, - format("Invalid {} = {}", state.dataIPShortCut->cAlphaFieldNames(7), state.dataIPShortCut->cAlphaArgs(7))); - ShowContinueError(state, format("Entered in {} = {}", state.dataIPShortCut->cCurrentModuleObject, waterConnection.Name)); - ErrorsFound = true; - } + if (state.dataIPShortCut->lAlphaFieldBlanks(7)) { + } else if ((waterConnection.coldTempSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(7))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(7), state.dataIPShortCut->cAlphaArgs(7)); + ErrorsFound = true; } if ((!state.dataIPShortCut->lAlphaFieldBlanks(8)) && (state.dataIPShortCut->cAlphaArgs(8) != "NONE")) { @@ -588,7 +543,7 @@ namespace WaterUse { for (auto &waterEquipment : state.dataWaterUse->WaterEquipment) { // set logical if either hot water temp or target temp schedule are missing (will use cold water otherwise) // if a connections object is used then don't need to hot temp schedule - waterEquipment.allowHotControl = (waterEquipment.TargetTempSchedule && waterEquipment.HotTempSchedule) || waterEquipment.Connections; + waterEquipment.allowHotControl = (waterEquipment.targetTempSched != nullptr && waterEquipment.hotTempSched != nullptr) || waterEquipment.Connections; } } @@ -1031,21 +986,12 @@ namespace WaterUse { } else { // Get water temperature conditions from the WATER USE EQUIPMENT schedules - if (this->ColdTempSchedule > 0) { - this->ColdTemp = ScheduleManager::GetCurrentScheduleValue(state, this->ColdTempSchedule); - } else { // If no ColdTempSchedule, use the mains temperature - this->ColdTemp = state.dataEnvrn->WaterMainsTemp; - } - - if (this->HotTempSchedule > 0) { - this->HotTemp = ScheduleManager::GetCurrentScheduleValue(state, this->HotTempSchedule); - } else { // If no HotTempSchedule, use all cold water - this->HotTemp = this->ColdTemp; - } + this->ColdTemp = (this->coldTempSched != nullptr) ? this->coldTempSched->getCurrentVal() : state.dataEnvrn->WaterMainsTemp; + this->HotTemp = (this->hotTempSched != nullptr) ? this->hotTempSched->getCurrentVal() : this->ColdTemp; } - if (this->TargetTempSchedule > 0) { - this->TargetTemp = ScheduleManager::GetCurrentScheduleValue(state, this->TargetTempSchedule); + if (this->targetTempSched != nullptr) { + this->TargetTemp = this->targetTempSched->getCurrentVal(); } else if (this->allowHotControl) { // If no TargetTempSchedule, but allowHotControl is set, use all hot water if applicable this->TargetTemp = this->HotTemp; } else { // If no TargetTempSchedule, use all cold water @@ -1053,21 +999,9 @@ namespace WaterUse { } // Get the requested total flow rate - if (this->Zone > 0) { - if (this->FlowRateFracSchedule > 0) { - this->TotalVolFlowRate = this->PeakVolFlowRate * ScheduleManager::GetCurrentScheduleValue(state, this->FlowRateFracSchedule) * - state.dataHeatBal->Zone(this->Zone).Multiplier * state.dataHeatBal->Zone(this->Zone).ListMultiplier; - } else { - this->TotalVolFlowRate = - this->PeakVolFlowRate * state.dataHeatBal->Zone(this->Zone).Multiplier * state.dataHeatBal->Zone(this->Zone).ListMultiplier; - } - } else { - if (this->FlowRateFracSchedule > 0) { - this->TotalVolFlowRate = this->PeakVolFlowRate * ScheduleManager::GetCurrentScheduleValue(state, this->FlowRateFracSchedule); - } else { - this->TotalVolFlowRate = this->PeakVolFlowRate; - } - } + this->TotalVolFlowRate = this->PeakVolFlowRate; + if (this->Zone > 0) this->TotalVolFlowRate *= state.dataHeatBal->Zone(this->Zone).Multiplier * state.dataHeatBal->Zone(this->Zone).ListMultiplier; + if (this->flowRateFracSched != nullptr) this->TotalVolFlowRate *= this->flowRateFracSched->getCurrentVal(); this->TotalMassFlowRate = this->TotalVolFlowRate * calcH2ODensity(state); @@ -1235,16 +1169,16 @@ namespace WaterUse { } else { auto &thisZoneHB = state.dataZoneTempPredictorCorrector->zoneHeatBalance(this->Zone); - if (this->SensibleFracSchedule == 0) { + if (this->sensibleFracSched == nullptr) { this->SensibleRate = 0.0; this->SensibleEnergy = 0.0; } else { - this->SensibleRate = ScheduleManager::GetCurrentScheduleValue(state, this->SensibleFracSchedule) * this->TotalMassFlowRate * + this->SensibleRate = this->sensibleFracSched->getCurrentVal() * this->TotalMassFlowRate * Psychrometrics::CPHW(Constant::InitConvTemp) * (this->MixedTemp - thisZoneHB.MAT); this->SensibleEnergy = this->SensibleRate * state.dataHVACGlobal->TimeStepSysSec; } - if (this->LatentFracSchedule == 0) { + if (this->latentFracSched == nullptr) { this->LatentRate = 0.0; this->LatentEnergy = 0.0; } else { @@ -1260,7 +1194,7 @@ namespace WaterUse { Real64 FlowMassMax = this->TotalMassFlowRate * state.dataHVACGlobal->TimeStepSysSec; // Max water in flow Real64 MoistureMassMax = min(ZoneMassMax, FlowMassMax); - this->MoistureMass = ScheduleManager::GetCurrentScheduleValue(state, this->LatentFracSchedule) * MoistureMassMax; + this->MoistureMass = this->latentFracSched->getCurrentVal() * MoistureMassMax; this->MoistureRate = this->MoistureMass / (state.dataHVACGlobal->TimeStepSysSec); this->LatentRate = this->MoistureRate * Psychrometrics::PsyHfgAirFnWTdb(ZoneHumRat, thisZoneHB.MAT); @@ -1291,8 +1225,8 @@ namespace WaterUse { if (this->SupplyTankNum > 0) { this->ColdSupplyTemp = state.dataWaterData->WaterStorage(this->SupplyTankNum).Twater; - } else if (this->ColdTempSchedule > 0) { - this->ColdSupplyTemp = ScheduleManager::GetCurrentScheduleValue(state, this->ColdTempSchedule); + } else if (this->coldTempSched != nullptr) { + this->ColdSupplyTemp = this->coldTempSched->getCurrentVal(); } else { this->ColdSupplyTemp = state.dataEnvrn->WaterMainsTemp; @@ -1303,13 +1237,7 @@ namespace WaterUse { // Set the hot water temperature if (this->StandAlone) { - if (this->HotTempSchedule > 0) { - this->HotTemp = ScheduleManager::GetCurrentScheduleValue(state, this->HotTempSchedule); - } else { - // If no HotTempSchedule, use all cold water - this->HotTemp = this->ColdTemp; - } - + this->HotTemp = (this->hotTempSched != nullptr) ? this->hotTempSched->getCurrentVal() : this->ColdTemp; } else { if (state.dataGlobal->BeginEnvrnFlag && this->Init) { diff --git a/src/EnergyPlus/WaterUse.hh b/src/EnergyPlus/WaterUse.hh index 6856c345130..f69b75231ea 100644 --- a/src/EnergyPlus/WaterUse.hh +++ b/src/EnergyPlus/WaterUse.hh @@ -89,7 +89,7 @@ namespace WaterUse { std::string EndUseSubcatName; int Connections = 0; // Index for WATER USE CONNECTIONS object Real64 PeakVolFlowRate = 0.0; // Peak volumetric flow rate, also water consumption rate (m3/s) - int FlowRateFracSchedule = 0; // Pointer to schedule object + Sched::Schedule *flowRateFracSched = nullptr; // pointer to schedule object // Now it is Real64 ColdVolFlowRate = 0.0; Real64 HotVolFlowRate = 0.0; Real64 TotalVolFlowRate = 0.0; // Volumetric flow rate, also water consumption rate (m3/s) @@ -97,9 +97,9 @@ namespace WaterUse { Real64 HotMassFlowRate = 0.0; Real64 TotalMassFlowRate = 0.0; // Mass flow rate (kg/s) Real64 DrainMassFlowRate = 0.0; - int ColdTempSchedule = 0; // Index for schedule object - int HotTempSchedule = 0; // Index for schedule object - int TargetTempSchedule = 0; // Index for schedule object + Sched::Schedule *coldTempSched = nullptr; // schedule object + Sched::Schedule *hotTempSched = nullptr; // schedule object + Sched::Schedule *targetTempSched = nullptr; // schedule object Real64 ColdTemp = 0.0; // Cold supply water temperature (C) Real64 HotTemp = 0.0; // Hot supply water temperature (C) Real64 TargetTemp = 0.0; // Target (mixed) water temperature (C) @@ -112,11 +112,11 @@ namespace WaterUse { int TargetCWTempErrorCount = 0; // - counter for target water temp error int TargetCWTempErrIndex = 0; // - index to recurring error structure for target water temp int Zone = 0; // Index for zone object - int SensibleFracSchedule = 0; // Pointer to schedule object + Sched::Schedule *sensibleFracSched = nullptr; // schedule object Real64 SensibleRate = 0.0; Real64 SensibleEnergy = 0.0; Real64 SensibleRateNoMultiplier = 0.0; - int LatentFracSchedule = 0; // Pointer to schedule object + Sched::Schedule *latentFracSched = nullptr; // schedule object Real64 LatentRate = 0.0; Real64 LatentEnergy = 0.0; Real64 LatentRateNoMultiplier = 0.0; @@ -180,8 +180,8 @@ namespace WaterUse { Real64 TotalVolFlowRate = 0.0; // Volumetric flow rate, also water consumption rate (m3/s) Real64 DrainVolFlowRate = 0.0; Real64 PeakMassFlowRate = 0.0; // Peak Mass flow rate for MassFlowRateMax - int ColdTempSchedule = 0; // Index for schedule object - int HotTempSchedule = 0; // Index for schedule object + Sched::Schedule *coldTempSched = nullptr; // schedule object + Sched::Schedule *hotTempSched = nullptr; // schedule object Real64 TankTemp = 0.0; // Cold supply water temperature (C) Real64 ColdSupplyTemp = 0.0; // cold from mains, schedule, or tank, depending Real64 ColdTemp = 0.0; // Cold supply water temperature (C) actual cold (could be reheated) @@ -255,6 +255,10 @@ struct WaterUseData : BaseGlobalStruct EPVector WaterEquipment; EPVector WaterConnections; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/WeatherManager.cc b/src/EnergyPlus/WeatherManager.cc index 3738697f0c8..75469bdf759 100644 --- a/src/EnergyPlus/WeatherManager.cc +++ b/src/EnergyPlus/WeatherManager.cc @@ -197,16 +197,18 @@ namespace Weather { ShowSevereItemNotFound(state, eoh, ipsc->cAlphaFieldNames(1), ipsc->cAlphaArgs(1)); errorsFound = true; } - underwaterBoundary.WaterTempScheduleIndex = ScheduleManager::GetScheduleIndex(state, ipsc->cAlphaArgs(2)); - if (underwaterBoundary.WaterTempScheduleIndex == 0) { + + if (ipsc->lAlphaFieldBlanks(2)) { + ShowSevereEmptyField(state, eoh, ipsc->cAlphaFieldNames(2)); + errorsFound = true; + } else if ((underwaterBoundary.waterTempSched = Sched::GetSchedule(state, ipsc->cAlphaArgs(2))) == nullptr) { ShowSevereItemNotFound(state, eoh, ipsc->cAlphaFieldNames(2), ipsc->cAlphaArgs(2)); errorsFound = true; } if (ipsc->lAlphaFieldBlanks(3)) { // that's OK, we can have a blank schedule, the water will just have no free stream velocity - underwaterBoundary.VelocityScheduleIndex = 0; - } else if ((underwaterBoundary.VelocityScheduleIndex = ScheduleManager::GetScheduleIndex(state, ipsc->cAlphaArgs(3))) == 0) { + } else if ((underwaterBoundary.velocitySched = Sched::GetSchedule(state, ipsc->cAlphaArgs(3))) == nullptr) { ShowSevereItemNotFound(state, eoh, ipsc->cAlphaFieldNames(3), ipsc->cAlphaArgs(3)); errorsFound = true; } @@ -248,10 +250,10 @@ namespace Weather { void UpdateUnderwaterBoundaries(EnergyPlusData &state) { for (auto &thisBoundary : state.dataWeather->underwaterBoundaries) { - Real64 const curWaterTemp = ScheduleManager::GetCurrentScheduleValue(state, thisBoundary.WaterTempScheduleIndex); // C + Real64 const curWaterTemp = thisBoundary.waterTempSched->getCurrentVal(); // C Real64 freeStreamVelocity = 0; - if (thisBoundary.VelocityScheduleIndex > 0) { - freeStreamVelocity = ScheduleManager::GetCurrentScheduleValue(state, thisBoundary.VelocityScheduleIndex); // m/s + if (thisBoundary.velocitySched != nullptr) { + freeStreamVelocity = thisBoundary.velocitySched->getCurrentVal(); // m/s } state.dataSurface->OSCM(thisBoundary.OSCMIndex).TConv = curWaterTemp; state.dataSurface->OSCM(thisBoundary.OSCMIndex).HConv = @@ -263,6 +265,8 @@ namespace Weather { void ReadVariableLocationOrientation(EnergyPlusData &state) { + static constexpr std::string_view routineName = "ReadVariableLocationOrientation"; + int NumAlpha = 0, NumNumber = 0, IOStat = 0; auto const &ipsc = state.dataIPShortCut; @@ -280,27 +284,41 @@ namespace Weather { ipsc->lAlphaFieldBlanks, ipsc->cAlphaFieldNames, ipsc->cNumericFieldNames); - state.dataEnvrn->varyingLocationSchedIndexLat = ScheduleManager::GetScheduleIndex(state, ipsc->cAlphaArgs(1)); - state.dataEnvrn->varyingLocationSchedIndexLong = ScheduleManager::GetScheduleIndex(state, ipsc->cAlphaArgs(2)); - state.dataEnvrn->varyingOrientationSchedIndex = ScheduleManager::GetScheduleIndex(state, ipsc->cAlphaArgs(3)); + + ErrorObjectHeader eoh{routineName, ipsc->cCurrentModuleObject, ""}; + + if (ipsc->lAlphaFieldBlanks(1)) { + } else if ((state.dataEnvrn->varyingLocationLatSched = Sched::GetSchedule(state, ipsc->cAlphaArgs(1))) == nullptr) { + ShowSevereItemNotFound(state, eoh, ipsc->cAlphaFieldNames(1), ipsc->cAlphaArgs(1)); + } + + if (ipsc->lAlphaFieldBlanks(2)) { + } else if ((state.dataEnvrn->varyingLocationLongSched = Sched::GetSchedule(state, ipsc->cAlphaArgs(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, ipsc->cAlphaFieldNames(2), ipsc->cAlphaArgs(2)); + } + + if (ipsc->lAlphaFieldBlanks(3)) { + } else if ((state.dataEnvrn->varyingOrientationSched = Sched::GetSchedule(state, ipsc->cAlphaArgs(3))) == nullptr) { + ShowSevereItemNotFound(state, eoh, ipsc->cAlphaFieldNames(3), ipsc->cAlphaArgs(3)); + } } void UpdateLocationAndOrientation(EnergyPlusData &state) { - if (state.dataEnvrn->varyingLocationSchedIndexLat > 0) { - state.dataEnvrn->Latitude = ScheduleManager::GetCurrentScheduleValue(state, state.dataEnvrn->varyingLocationSchedIndexLat); + if (state.dataEnvrn->varyingLocationLatSched != nullptr) { + state.dataEnvrn->Latitude = state.dataEnvrn->varyingLocationLatSched->getCurrentVal(); } - if (state.dataEnvrn->varyingLocationSchedIndexLong > 0) { - state.dataEnvrn->Longitude = ScheduleManager::GetCurrentScheduleValue(state, state.dataEnvrn->varyingLocationSchedIndexLong); + if (state.dataEnvrn->varyingLocationLongSched != nullptr) { + state.dataEnvrn->Longitude = state.dataEnvrn->varyingLocationLongSched->getCurrentVal(); } + CheckLocationValidity(state); - if (state.dataEnvrn->varyingOrientationSchedIndex > 0) { - state.dataHeatBal->BuildingAzimuth = - mod(ScheduleManager::GetCurrentScheduleValue(state, state.dataEnvrn->varyingOrientationSchedIndex), 360.0); + if (state.dataEnvrn->varyingOrientationSched != nullptr) { + state.dataHeatBal->BuildingAzimuth = mod(state.dataEnvrn->varyingOrientationSched->getCurrentVal(), 360.0); state.dataSurfaceGeometry->CosBldgRelNorth = - std::cos(-(state.dataHeatBal->BuildingAzimuth + state.dataHeatBal->BuildingRotationAppendixG) * Constant::DegToRadians); + std::cos(-(state.dataHeatBal->BuildingAzimuth + state.dataHeatBal->BuildingRotationAppendixG) * Constant::DegToRad); state.dataSurfaceGeometry->SinBldgRelNorth = - std::sin(-(state.dataHeatBal->BuildingAzimuth + state.dataHeatBal->BuildingRotationAppendixG) * Constant::DegToRadians); + std::sin(-(state.dataHeatBal->BuildingAzimuth + state.dataHeatBal->BuildingRotationAppendixG) * Constant::DegToRad); for (size_t SurfNum = 1; SurfNum < state.dataSurface->Surface.size(); ++SurfNum) { auto &surf = state.dataSurface->Surface(SurfNum); for (int n = 1; n <= surf.Sides; ++n) { @@ -316,8 +334,8 @@ namespace Weather { Vectors::DetermineAzimuthAndTilt( surf.NewVertex, SurfWorldAz, SurfTilt, surf.lcsx, surf.lcsy, surf.lcsz, surf.NewellSurfaceNormalVector); surf.Azimuth = SurfWorldAz; - surf.SinAzim = std::sin(SurfWorldAz * Constant::DegToRadians); - surf.CosAzim = std::cos(SurfWorldAz * Constant::DegToRadians); + surf.SinAzim = std::sin(SurfWorldAz * Constant::DegToRad); + surf.CosAzim = std::cos(SurfWorldAz * Constant::DegToRad); surf.OutNormVec = surf.NewellSurfaceNormalVector; } } @@ -688,7 +706,7 @@ namespace Weather { if (state.dataWeather->GetBranchInputOneTimeFlag) { SetupInterpolationValues(state); - state.dataWeather->TimeStepFraction = 1.0 / double(state.dataGlobal->NumOfTimeStepInHour); + state.dataWeather->TimeStepFraction = 1.0 / double(state.dataGlobal->TimeStepsInHour); state.dataEnvrn->rhoAirSTP = Psychrometrics::PsyRhoAirFnPbTdbW( state, DataEnvironment::StdPressureSeaLevel, DataPrecisionGlobals::constant_twenty, DataPrecisionGlobals::constant_zero); OpenWeatherFile(state, ErrorsFound); // moved here because of possibility of special days on EPW file @@ -696,7 +714,7 @@ namespace Weather { ReadUserWeatherInput(state); AllocateWeatherData(state); if (state.dataWeather->NumIntervalsPerHour != 1) { - if (state.dataWeather->NumIntervalsPerHour != state.dataGlobal->NumOfTimeStepInHour) { + if (state.dataWeather->NumIntervalsPerHour != state.dataGlobal->TimeStepsInHour) { ShowSevereError( state, format("{}Number of intervals per hour on Weather file does not match specified number of Time Steps Per Hour", RoutineName)); @@ -977,7 +995,7 @@ namespace Weather { kindOfRunPeriod, StDate, EnDate, - ScheduleManager::dayTypeNames[TWeekDay], + Sched::dayTypeNames[TWeekDay], fmt::to_string(envCurr.TotalDays), "Use RunPeriod Specified Day", AlpUseDST, @@ -1102,7 +1120,7 @@ namespace Weather { print(state.files.eio, EnvSpDyFormat, specialDay.Name, - ScheduleManager::dayTypeNames[specialDay.DayType], + Sched::dayTypeNames[specialDay.DayType], "WeatherFile", StDate, specialDay.Duration); @@ -1112,7 +1130,7 @@ namespace Weather { print(state.files.eio, EnvSpDyFormat, specialDay.Name, - ScheduleManager::dayTypeNames[specialDay.DayType], + Sched::dayTypeNames[specialDay.DayType], "InputFile", StDate, specialDay.Duration); @@ -1133,7 +1151,7 @@ namespace Weather { "SizingPeriod:DesignDay", StDate, EnDate, - ScheduleManager::dayTypeNames[desDayInput.DayType], + Sched::dayTypeNames[desDayInput.DayType], "1", "N/A", "N/A", @@ -1588,11 +1606,11 @@ namespace Weather { if (specialDay.dateType <= DateType::MonthDay) { JDay = General::OrdinalDay(specialDay.Month, specialDay.Day, state.dataWeather->LeapYearAdd); if (specialDay.Duration == 1 && state.dataWeather->Environment(state.dataWeather->Envrn).ApplyWeekendRule) { - if (state.dataWeather->WeekDayTypes(JDay) == static_cast(ScheduleManager::DayType::Sunday)) { + if (state.dataWeather->WeekDayTypes(JDay) == static_cast(Sched::DayType::Sunday)) { // Sunday, must go to Monday ++JDay; if (JDay == 366 && state.dataWeather->LeapYearAdd == 0) JDay = 1; - } else if (state.dataWeather->WeekDayTypes(JDay) == (int)ScheduleManager::DayType::Saturday) { + } else if (state.dataWeather->WeekDayTypes(JDay) == (int)Sched::DayType::Saturday) { ++JDay; if (JDay == 366 && state.dataWeather->LeapYearAdd == 0) JDay = 1; ++JDay; @@ -1700,7 +1718,7 @@ namespace Weather { // Counts set to 0 for each environment state.dataWeather->wvarsOutOfRangeCounts = Weather::WeatherVarCounts(); - state.dataWeather->IsRainThreshold = 0.8 / double(state.dataGlobal->NumOfTimeStepInHour); // [mm] + state.dataWeather->IsRainThreshold = 0.8 / double(state.dataGlobal->TimeStepsInHour); // [mm] if (!state.dataWeather->RPReadAllWeatherData) { printEnvrnStamp = true; // Set this to true so that on first non-warmup day (only) the environment header will print out @@ -1850,8 +1868,8 @@ namespace Weather { // at the end of each day find the min/max weather used for DOAS sizing if (state.dataGlobal->AirLoopHVACDOASUsedInSim) { if (envCurr.KindOfEnvrn == Constant::KindOfSim::RunPeriodDesign || envCurr.KindOfEnvrn == Constant::KindOfSim::DesignDay) { - for (int iHr = 1; iHr <= Constant::HoursInDay; ++iHr) { - for (int iTS = 1; iTS <= state.dataGlobal->NumOfTimeStepInHour; ++iTS) { + for (int iHr = 1; iHr <= Constant::iHoursInDay; ++iHr) { + for (int iTS = 1; iTS <= state.dataGlobal->TimeStepsInHour; ++iTS) { Real64 Tdb = state.dataWeather->wvarsHrTsToday(iTS, iHr).OutDryBulbTemp; Real64 Tdp = state.dataWeather->wvarsHrTsToday(iTS, iHr).OutDewPointTemp; if (Tdb > envCurr.maxCoolingOATSizing) { @@ -1994,7 +2012,7 @@ namespace Weather { state.dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state.dataEnvrn->Month, state.dataEnvrn->DayOfMonth, 1); } - ScheduleManager::UpdateScheduleValues(state); + Sched::UpdateScheduleVals(state); state.dataEnvrn->CurMnDyHr = format("{:02d}/{:02d} {:02d}", state.dataEnvrn->Month, state.dataEnvrn->DayOfMonth, (unsigned short)(state.dataGlobal->HourOfDay - 1)); @@ -2006,8 +2024,8 @@ namespace Weather { state.dataGlobal->WeightPreviousHour = 1.0 - state.dataGlobal->WeightNow; state.dataGlobal->CurrentTime = (state.dataGlobal->HourOfDay - 1) + state.dataGlobal->TimeStep * (state.dataWeather->TimeStepFraction); - state.dataGlobal->SimTimeSteps = (state.dataGlobal->DayOfSim - 1) * 24 * state.dataGlobal->NumOfTimeStepInHour + - (state.dataGlobal->HourOfDay - 1) * state.dataGlobal->NumOfTimeStepInHour + state.dataGlobal->TimeStep; + state.dataGlobal->SimTimeSteps = (state.dataGlobal->DayOfSim - 1) * 24 * state.dataGlobal->TimeStepsInHour + + (state.dataGlobal->HourOfDay - 1) * state.dataGlobal->TimeStepsInHour + state.dataGlobal->TimeStep; state.dataEnvrn->GroundTemp[(int)DataEnvironment::GroundTempType::BuildingSurface] = state.dataWeather->siteBuildingSurfaceGroundTempsPtr->getGroundTempAtTimeInMonths(state, 0, state.dataEnvrn->Month); @@ -2243,7 +2261,7 @@ namespace Weather { constexpr std::string_view routineName = "ReadEPlusWeatherForDay"; - Array1D wvarsHr = Array1D(Constant::HoursInDay); + Array1D wvarsHr = Array1D(Constant::iHoursInDay); auto &thisEnviron = state.dataWeather->Environment(Environ); @@ -2878,10 +2896,10 @@ namespace Weather { state.files.inputWeatherFile.backspace(); } - if (state.dataWeather->NumIntervalsPerHour == 1 && state.dataGlobal->NumOfTimeStepInHour > 1) { + if (state.dataWeather->NumIntervalsPerHour == 1 && state.dataGlobal->TimeStepsInHour > 1) { // Create interpolated weather for timestep orientation // First copy ts=1 (hourly) from data arrays to Wthr structure - for (int hour = 1; hour <= Constant::HoursInDay; ++hour) { + for (int hour = 1; hour <= Constant::iHoursInDay; ++hour) { wvarsHr(hour) = state.dataWeather->wvarsHrTsTomorrow(1, hour); } @@ -2894,15 +2912,15 @@ namespace Weather { state.dataWeather->LastHourSet = true; } - for (int hour = 1; hour <= Constant::HoursInDay; ++hour) { + for (int hour = 1; hour <= Constant::iHoursInDay; ++hour) { - int NextHr = (hour == Constant::HoursInDay) ? 1 : hour + 1; + int NextHr = (hour == Constant::iHoursInDay) ? 1 : hour + 1; state.dataWeather->wvarsNextHr.BeamSolarRad = wvarsHr(NextHr).BeamSolarRad; state.dataWeather->wvarsNextHr.DifSolarRad = wvarsHr(NextHr).DifSolarRad; state.dataWeather->wvarsNextHr.LiquidPrecip = wvarsHr(NextHr).LiquidPrecip; - for (int ts = 1; ts <= state.dataGlobal->NumOfTimeStepInHour; ++ts) { + for (int ts = 1; ts <= state.dataGlobal->TimeStepsInHour; ++ts) { Real64 wgtCurrHr = state.dataWeather->Interpolation(ts); Real64 wgtPrevHr = 1.0 - wgtCurrHr; @@ -2913,7 +2931,7 @@ namespace Weather { Real64 wgtPrevHrSolar; Real64 wgtNextHrSolar; - if (state.dataGlobal->NumOfTimeStepInHour == 1) { + if (state.dataGlobal->TimeStepsInHour == 1) { wgtNextHrSolar = 1.0 - wgtCurrHr; wgtPrevHrSolar = 0.0; } else if (wgtCurrHrSolar == 1.0) { @@ -2954,7 +2972,7 @@ namespace Weather { state.dataWeather->wvarsNextHr.BeamSolarRad * wgtNextHrSolar; tomorrowTs.LiquidPrecip = state.dataWeather->wvarsLastHr.LiquidPrecip * wgtPrevHr + wvarsH.LiquidPrecip * wgtCurrHr; - tomorrowTs.LiquidPrecip /= double(state.dataGlobal->NumOfTimeStepInHour); + tomorrowTs.LiquidPrecip /= double(state.dataGlobal->TimeStepsInHour); tomorrowTs.IsRain = tomorrowTs.LiquidPrecip >= state.dataWeather->IsRainThreshold; // Wthr%IsRain tomorrowTs.IsSnow = wvarsH.IsSnow; } // End of TS Loop @@ -2966,42 +2984,39 @@ namespace Weather { if (thisEnviron.WP_Type1 != 0) { switch (state.dataWeather->WPSkyTemperature(thisEnviron.WP_Type1).skyTempModel) { case SkyTempModel::ScheduleValue: { - Array2D tmp = Array2D(state.dataGlobal->NumOfTimeStepInHour, Constant::HoursInDay); + Array2D tmp = Array2D(state.dataGlobal->TimeStepsInHour, Constant::iHoursInDay); - ScheduleManager::GetScheduleValuesForDay(state, - state.dataWeather->WPSkyTemperature(thisEnviron.WP_Type1).SchedulePtr, - tmp, - state.dataWeather->TomorrowVariables.DayOfYear_Schedule, - state.dataWeather->CurDayOfWeek); + state.dataWeather->WPSkyTemperature(thisEnviron.WP_Type1).sched->getDayVals(state, + tmp, + state.dataWeather->TomorrowVariables.DayOfYear_Schedule, + state.dataWeather->CurDayOfWeek); - for (int iHr = 1; iHr <= Constant::HoursInDay; ++iHr) { - for (int iTS = 1; iTS <= state.dataGlobal->NumOfTimeStepInHour; ++iTS) { + for (int iHr = 1; iHr <= Constant::iHoursInDay; ++iHr) { + for (int iTS = 1; iTS <= state.dataGlobal->TimeStepsInHour; ++iTS) { state.dataWeather->wvarsHrTsTomorrow(iTS, iHr).SkyTemp = tmp(iTS, iHr); } } } break; case SkyTempModel::DryBulbDelta: { - Array2D tmp = Array2D(state.dataGlobal->NumOfTimeStepInHour, Constant::HoursInDay); - ScheduleManager::GetScheduleValuesForDay(state, - state.dataWeather->WPSkyTemperature(thisEnviron.WP_Type1).SchedulePtr, - tmp, - state.dataWeather->TomorrowVariables.DayOfYear_Schedule, - state.dataWeather->CurDayOfWeek); - - for (int hour = 1; hour <= Constant::HoursInDay; ++hour) { - for (int ts = 1; ts <= state.dataGlobal->NumOfTimeStepInHour; ++ts) { + Array2D tmp = Array2D(state.dataGlobal->TimeStepsInHour, Constant::iHoursInDay); + state.dataWeather->WPSkyTemperature(thisEnviron.WP_Type1).sched->getDayVals(state, + tmp, + state.dataWeather->TomorrowVariables.DayOfYear_Schedule, + state.dataWeather->CurDayOfWeek); + + for (int hour = 1; hour <= Constant::iHoursInDay; ++hour) { + for (int ts = 1; ts <= state.dataGlobal->TimeStepsInHour; ++ts) { auto &tomorrowTs = state.dataWeather->wvarsHrTsTomorrow(ts, hour); tomorrowTs.SkyTemp = tomorrowTs.OutDryBulbTemp - tmp(ts, hour); } } } break; case SkyTempModel::DewPointDelta: { - Array2D tmp = Array2D(state.dataGlobal->NumOfTimeStepInHour, Constant::HoursInDay); - ScheduleManager::GetScheduleValuesForDay(state, - state.dataWeather->WPSkyTemperature(thisEnviron.WP_Type1).SchedulePtr, - tmp, - state.dataWeather->TomorrowVariables.DayOfYear_Schedule, - state.dataWeather->CurDayOfWeek); + Array2D tmp = Array2D(state.dataGlobal->TimeStepsInHour, Constant::iHoursInDay); + state.dataWeather->WPSkyTemperature(thisEnviron.WP_Type1).sched->getDayVals(state, + tmp, + state.dataWeather->TomorrowVariables.DayOfYear_Schedule, + state.dataWeather->CurDayOfWeek); ForAllHrTs(state, [&state, &tmp](int iHr, int iTS) { auto &tomorrowTs = state.dataWeather->wvarsHrTsTomorrow(iTS, iHr); tomorrowTs.SkyTemp = tomorrowTs.OutDewPointTemp - tmp(iTS, iHr); @@ -3358,8 +3373,8 @@ namespace Weather { struct HourlyWeatherData { // Members - Array1D BeamSolarRad = Array1D(Constant::HoursInDay, 0.0); // Hourly direct normal solar irradiance - Array1D DifSolarRad = Array1D(Constant::HoursInDay, 0.0); // Hourly sky diffuse horizontal solar irradiance + Array1D BeamSolarRad = Array1D(Constant::iHoursInDay, 0.0); // Hourly direct normal solar irradiance + Array1D DifSolarRad = Array1D(Constant::iHoursInDay, 0.0); // Hourly sky diffuse horizontal solar irradiance }; // Object Data @@ -3492,7 +3507,7 @@ namespace Weather { print(state.files.eio, "{:.4R},", C); print(state.files.eio, "{:.1R},", AVSC); print(state.files.eio, "{:.2R},", designDay.EquationOfTime * 60.0); - print(state.files.eio, "{:.1R},", std::asin(designDay.SinSolarDeclinAngle) / Constant::DegToRadians); + print(state.files.eio, "{:.1R},", std::asin(designDay.SinSolarDeclinAngle) / Constant::DegToRad); // Why have a different string for "Schedule" here than the one used for input? Really, why? static constexpr std::array DesDaySolarModelStrings = { @@ -3606,8 +3621,8 @@ namespace Weather { } auto const &desDayModsEnvrn = state.dataWeather->desDayMods(EnvrnNum); - for (int hour = 1; hour <= Constant::HoursInDay; ++hour) { - for (int ts = 1; ts <= state.dataGlobal->NumOfTimeStepInHour; ++ts) { + for (int hour = 1; hour <= Constant::iHoursInDay; ++hour) { + for (int ts = 1; ts <= state.dataGlobal->TimeStepsInHour; ++ts) { auto const &desDayModsTS = desDayModsEnvrn(ts, hour); auto &tomorrowTs = state.dataWeather->wvarsHrTsTomorrow(ts, hour); if (desDayInput.dryBulbRangeType != DesDayDryBulbRangeType::Profile) { @@ -3675,7 +3690,7 @@ namespace Weather { // calc time = fractional hour of day Real64 CurTime; - if (state.dataGlobal->NumOfTimeStepInHour != 1) { + if (state.dataGlobal->TimeStepsInHour != 1) { CurTime = double(hour - 1) + double(ts) * state.dataWeather->TimeStepFraction; } else { CurTime = double(hour) + state.dataEnvrn->TS1TimeOffset; @@ -3766,37 +3781,37 @@ namespace Weather { // back-fill hour values from timesteps // hour values = integrated over hour ending at time of hour // insurance: hourly values not known to be needed - for (int hour = 1; hour <= Constant::HoursInDay; ++hour) { - int Hour1Ago = mod(hour + 22, Constant::HoursInDay) + 1; - auto const &tomorrowHr = state.dataWeather->wvarsHrTsTomorrow(state.dataGlobal->NumOfTimeStepInHour, hour); - auto const &tomorrowHr1Ago = state.dataWeather->wvarsHrTsTomorrow(state.dataGlobal->NumOfTimeStepInHour, Hour1Ago); + for (int hour = 1; hour <= Constant::iHoursInDay; ++hour) { + int Hour1Ago = mod(hour + 22, Constant::iHoursInDay) + 1; + auto const &tomorrowHr = state.dataWeather->wvarsHrTsTomorrow(state.dataGlobal->TimeStepsInHour, hour); + auto const &tomorrowHr1Ago = state.dataWeather->wvarsHrTsTomorrow(state.dataGlobal->TimeStepsInHour, Hour1Ago); Real64 BeamRad = (tomorrowHr1Ago.BeamSolarRad + tomorrowHr.BeamSolarRad) / 2.0; Real64 DiffRad = (tomorrowHr1Ago.DifSolarRad + tomorrowHr.DifSolarRad) / 2.0; - if (state.dataGlobal->NumOfTimeStepInHour > 1) { - for (int iTS = 1; iTS <= state.dataGlobal->NumOfTimeStepInHour - 1; ++iTS) { + if (state.dataGlobal->TimeStepsInHour > 1) { + for (int iTS = 1; iTS <= state.dataGlobal->TimeStepsInHour - 1; ++iTS) { BeamRad += state.dataWeather->wvarsHrTsTomorrow(iTS, hour).BeamSolarRad; DiffRad += state.dataWeather->wvarsHrTsTomorrow(iTS, hour).DifSolarRad; } } - Wthr.BeamSolarRad(hour) = BeamRad / state.dataGlobal->NumOfTimeStepInHour; - Wthr.DifSolarRad(hour) = DiffRad / state.dataGlobal->NumOfTimeStepInHour; + Wthr.BeamSolarRad(hour) = BeamRad / state.dataGlobal->TimeStepsInHour; + Wthr.DifSolarRad(hour) = DiffRad / state.dataGlobal->TimeStepsInHour; } if (envCurr.WP_Type1 != 0) { switch (state.dataWeather->WPSkyTemperature(envCurr.WP_Type1).skyTempModel) { case SkyTempModel::ScheduleValue: { - Array2D tmp = Array2D(state.dataGlobal->NumOfTimeStepInHour, Constant::HoursInDay); - ScheduleManager::GetSingleDayScheduleValues(state, state.dataWeather->WPSkyTemperature(envCurr.WP_Type1).SchedulePtr, tmp); + Array2D tmp = Array2D(state.dataGlobal->TimeStepsInHour, Constant::iHoursInDay); + state.dataWeather->WPSkyTemperature(envCurr.WP_Type1).sched->getDayVals(state, tmp); auto &desDayModsEnvrn = state.dataWeather->desDayMods(EnvrnNum); ForAllHrTs(state, [&state, &tmp, &desDayModsEnvrn](int iHr, int iTS) { state.dataWeather->wvarsHrTsTomorrow(iTS, iHr).SkyTemp = desDayModsEnvrn(iTS, iHr).SkyTemp = tmp(iTS, iHr); }); } break; case SkyTempModel::DryBulbDelta: { - Array2D tmp = Array2D(state.dataGlobal->NumOfTimeStepInHour, Constant::HoursInDay); - ScheduleManager::GetSingleDayScheduleValues(state, state.dataWeather->WPSkyTemperature(envCurr.WP_Type1).SchedulePtr, tmp); + Array2D tmp = Array2D(state.dataGlobal->TimeStepsInHour, Constant::iHoursInDay); + state.dataWeather->WPSkyTemperature(envCurr.WP_Type1).sched->getDayVals(state, tmp); auto &desDayModsEnvrn = state.dataWeather->desDayMods(EnvrnNum); ForAllHrTs(state, [&state, &tmp, &desDayModsEnvrn](int iHr, int iTS) { auto &tomorrowTS = state.dataWeather->wvarsHrTsTomorrow(iTS, iHr); @@ -3805,8 +3820,8 @@ namespace Weather { }); } break; case SkyTempModel::DewPointDelta: { - Array2D tmp = Array2D(state.dataGlobal->NumOfTimeStepInHour, Constant::HoursInDay); - ScheduleManager::GetSingleDayScheduleValues(state, state.dataWeather->WPSkyTemperature(envCurr.WP_Type1).SchedulePtr, tmp); + Array2D tmp = Array2D(state.dataGlobal->TimeStepsInHour, Constant::iHoursInDay); + state.dataWeather->WPSkyTemperature(envCurr.WP_Type1).sched->getDayVals(state, tmp); auto &desDayModsEnvrn = state.dataWeather->desDayMods(EnvrnNum); ForAllHrTs(state, [&state, &tmp, &desDayModsEnvrn](int iHr, int iTS) { auto &tomorrowTS = state.dataWeather->wvarsHrTsTomorrow(iTS, iHr); @@ -3850,7 +3865,7 @@ namespace Weather { AirMass = 1.0; } else { // note: COS( Zen) = SIN( Alt) - SunAltD = std::asin(CosZen) / Constant::DegToRadians; // altitude, degrees + SunAltD = std::asin(CosZen) / Constant::DegToRad; // altitude, degrees AirMass = 1.0 / (CosZen + 0.50572 * std::pow(6.07995 + SunAltD, -1.6364)); } return AirMass; @@ -3921,8 +3936,8 @@ namespace Weather { // Interpolation of data is done later after either setting up the design day (hourly // data) or reading in hourly weather data. - state.dataWeather->wvarsHrTsToday.allocate(state.dataGlobal->NumOfTimeStepInHour, Constant::HoursInDay); - state.dataWeather->wvarsHrTsTomorrow.allocate(state.dataGlobal->NumOfTimeStepInHour, Constant::HoursInDay); + state.dataWeather->wvarsHrTsToday.allocate(state.dataGlobal->TimeStepsInHour, Constant::iHoursInDay); + state.dataWeather->wvarsHrTsTomorrow.allocate(state.dataGlobal->TimeStepsInHour, Constant::iHoursInDay); } void CalculateDailySolarCoeffs(EnergyPlusData &state, @@ -4057,7 +4072,7 @@ namespace Weather { // COMPUTE THE HOUR ANGLE Real64 H = - (15.0 * (12.0 - (TimeValue + EqOfTime)) + (state.dataEnvrn->TimeZoneMeridian - state.dataEnvrn->Longitude)) * Constant::DegToRadians; + (15.0 * (12.0 - (TimeValue + EqOfTime)) + (state.dataEnvrn->TimeZoneMeridian - state.dataEnvrn->Longitude)) * Constant::DegToRad; Real64 COSH = std::cos(H); // COMPUTE THE COSINE OF THE SOLAR ZENITH ANGLE. // This is also the Sine of the Solar Altitude Angle @@ -4088,7 +4103,7 @@ namespace Weather { // Sun routines from IBLAST, authored by Walton. // COMPUTE THE HOUR ANGLE - if (state.dataGlobal->NumOfTimeStepInHour != 1) { + if (state.dataGlobal->TimeStepsInHour != 1) { state.dataWeather->HrAngle = (15.0 * (12.0 - (state.dataGlobal->CurrentTime + state.dataWeather->TodayVariables.EquationOfTime)) + (state.dataEnvrn->TimeZoneMeridian - state.dataEnvrn->Longitude)); } else { @@ -4097,7 +4112,7 @@ namespace Weather { (12.0 - ((state.dataGlobal->CurrentTime + state.dataEnvrn->TS1TimeOffset) + state.dataWeather->TodayVariables.EquationOfTime)) + (state.dataEnvrn->TimeZoneMeridian - state.dataEnvrn->Longitude)); } - Real64 H = state.dataWeather->HrAngle * Constant::DegToRadians; + Real64 H = state.dataWeather->HrAngle * Constant::DegToRad; // Compute the Cosine of the Solar Zenith (Altitude) Angle. Real64 CosZenith = state.dataEnvrn->SinLatitude * state.dataWeather->TodayVariables.SinSolarDeclinAngle + @@ -4114,8 +4129,8 @@ namespace Weather { CosAzimuth = min(1.0, CosAzimuth); Real64 SolarAzimuth = std::acos(CosAzimuth); - state.dataWeather->SolarAltitudeAngle = SolarAltitude / Constant::DegToRadians; - state.dataWeather->SolarAzimuthAngle = SolarAzimuth / Constant::DegToRadians; + state.dataWeather->SolarAltitudeAngle = SolarAltitude / Constant::DegToRad; + state.dataWeather->SolarAzimuthAngle = SolarAzimuth / Constant::DegToRad; if (state.dataWeather->HrAngle < 0.0) { state.dataWeather->SolarAzimuthAngle = 360.0 - state.dataWeather->SolarAzimuthAngle; } @@ -4332,7 +4347,7 @@ namespace Weather { // different, notify the user. If StdTimeMerid couldn't be calculated, // produce an error message. - if (state.dataEnvrn->varyingLocationSchedIndexLat > 0 || state.dataEnvrn->varyingLocationSchedIndexLong > 0) { + if (state.dataEnvrn->varyingLocationLatSched != nullptr || state.dataEnvrn->varyingLocationLongSched != nullptr) { // don't do any warnings, the building is moving } else if (StdTimeMerid >= -12.0 && StdTimeMerid <= 12.0) { if (state.dataEnvrn->TimeZoneNumber != StdTimeMerid) { @@ -4367,8 +4382,8 @@ namespace Weather { } else { state.dataEnvrn->TimeZoneMeridian = state.dataEnvrn->TimeZoneNumber * 15.0 - 360.0; } - state.dataEnvrn->SinLatitude = std::sin(Constant::DegToRadians * state.dataEnvrn->Latitude); - state.dataEnvrn->CosLatitude = std::cos(Constant::DegToRadians * state.dataEnvrn->Latitude); + state.dataEnvrn->SinLatitude = std::sin(Constant::DegToRad * state.dataEnvrn->Latitude); + state.dataEnvrn->CosLatitude = std::cos(Constant::DegToRad * state.dataEnvrn->Latitude); if (state.dataEnvrn->Latitude == 0.0 && state.dataEnvrn->Longitude == 0.0 && state.dataEnvrn->TimeZoneNumber == 0.0) { ShowWarningError(state, @@ -4635,7 +4650,7 @@ namespace Weather { } } - static int findYearForWeekday(int const month, int const day, ScheduleManager::DayType const weekday) + static int findYearForWeekday(int const month, int const day, Sched::DayType const weekday) { // Find a year that goes with a month/day and a weekday. A lookup table is used with the most recent year that includes // the date with the weekday specified. @@ -4647,7 +4662,7 @@ namespace Weather { return defaultYear[static_cast(weekday) - rem + 5]; // static_cast(weekday) - rem + 1 + 4 } - static int findLeapYearForWeekday(int const month, int const day, ScheduleManager::DayType const weekday) + static int findLeapYearForWeekday(int const month, int const day, Sched::DayType const weekday) { // Find a leap year that goes with a month/day and a weekday. A lookup table is used with the most recent year that includes // the date with the weekday specified. @@ -4914,7 +4929,7 @@ namespace Weather { // A2 , \field Day of Week for Start Day bool inputWeekday = false; if (!state.dataIPShortCut->lAlphaFieldBlanks(2)) { // Have input - int dayType = getEnumValue(ScheduleManager::dayTypeNamesUC, state.dataIPShortCut->cAlphaArgs(2)); + int dayType = getEnumValue(Sched::dayTypeNamesUC, state.dataIPShortCut->cAlphaArgs(2)); if (dayType < 1) { ShowWarningError(state, format("{}: object={}{} invalid (Day of Week) [{}] for Start is not valid, Sunday will be used.", @@ -4922,13 +4937,13 @@ namespace Weather { state.dataWeather->RunPeriodInput(i).title, state.dataIPShortCut->cAlphaFieldNames(2), state.dataIPShortCut->cAlphaArgs(2))); - runPeriodInput.startWeekDay = ScheduleManager::DayType::Sunday; + runPeriodInput.startWeekDay = Sched::DayType::Sunday; } else { - runPeriodInput.startWeekDay = static_cast(dayType); + runPeriodInput.startWeekDay = static_cast(dayType); inputWeekday = true; } } else { // No input, set the default as Sunday. This may get overriden below - runPeriodInput.startWeekDay = ScheduleManager::DayType::Sunday; + runPeriodInput.startWeekDay = Sched::DayType::Sunday; } // Validate the dates now that the weekday field has been looked at @@ -4953,7 +4968,7 @@ namespace Weather { runPeriodInput.startYear)); ErrorsFound = true; } else { // Start year is a leap year - ScheduleManager::DayType weekday = + Sched::DayType weekday = calculateDayOfWeek(state, runPeriodInput.startYear, runPeriodInput.startMonth, runPeriodInput.startDay); if (inputWeekday) { // Check for correctness of input if (weekday != runPeriodInput.startWeekDay) { @@ -4963,7 +4978,7 @@ namespace Weather { runPeriodInput.title, ipsc->cAlphaArgs(2), runPeriodInput.startYear, - ScheduleManager::dayTypeNamesUC[static_cast(weekday)])); + Sched::dayTypeNamesUC[static_cast(weekday)])); runPeriodInput.startWeekDay = weekday; } } else { // Set the weekday if it was not input @@ -4993,7 +5008,7 @@ namespace Weather { calculateDayOfWeek(state, runPeriodInput.startYear, runPeriodInput.startMonth, runPeriodInput.startDay); } } else { // Have an input starting year - ScheduleManager::DayType weekday = + Sched::DayType weekday = calculateDayOfWeek(state, runPeriodInput.startYear, runPeriodInput.startMonth, runPeriodInput.startDay); if (inputWeekday) { // Check for correctness of input if (weekday != runPeriodInput.startWeekDay) { @@ -5003,7 +5018,7 @@ namespace Weather { runPeriodInput.title, ipsc->cAlphaArgs(2), runPeriodInput.startYear, - ScheduleManager::dayTypeNamesUC[static_cast(weekday)])); + Sched::dayTypeNamesUC[static_cast(weekday)])); runPeriodInput.startWeekDay = weekday; } } else { // Set the weekday if it was not input @@ -5309,9 +5324,9 @@ namespace Weather { } // switch if (ipsc->lAlphaFieldBlanks(2)) { - runPerDesInput.dayOfWeek = (int)ScheduleManager::DayType::Monday; // Defaults to Monday + runPerDesInput.dayOfWeek = (int)Sched::DayType::Monday; // Defaults to Monday } else { - runPerDesInput.dayOfWeek = getEnumValue(ScheduleManager::dayTypeNamesUC, ipsc->cAlphaArgs(2)); + runPerDesInput.dayOfWeek = getEnumValue(Sched::dayTypeNamesUC, ipsc->cAlphaArgs(2)); if (runPerDesInput.dayOfWeek < 1 || runPerDesInput.dayOfWeek == 8) { ShowWarningError(state, format("{}: object={} {} invalid (Day of Week) [{} for Start is not Valid, Monday will be Used.", @@ -5319,7 +5334,7 @@ namespace Weather { runPerDesInput.title, ipsc->cAlphaFieldNames(1), ipsc->cAlphaArgs(1))); - runPerDesInput.dayOfWeek = (int)ScheduleManager::DayType::Monday; // Defaults to Monday + runPerDesInput.dayOfWeek = (int)Sched::DayType::Monday; // Defaults to Monday } } @@ -5440,11 +5455,11 @@ namespace Weather { } if (ipsc->lAlphaFieldBlanks(3)) { - runPerDesInput.dayOfWeek = (int)ScheduleManager::DayType::Monday; // Defaults to Monday + runPerDesInput.dayOfWeek = (int)Sched::DayType::Monday; // Defaults to Monday } else { - runPerDesInput.dayOfWeek = getEnumValue(ScheduleManager::dayTypeNamesUC, ipsc->cAlphaArgs(3)); - if (runPerDesInput.dayOfWeek < (int)ScheduleManager::DayType::Sunday || - runPerDesInput.dayOfWeek == (int)ScheduleManager::DayType::Holiday) { + runPerDesInput.dayOfWeek = getEnumValue(Sched::dayTypeNamesUC, ipsc->cAlphaArgs(3)); + if (runPerDesInput.dayOfWeek < (int)Sched::DayType::Sunday || + runPerDesInput.dayOfWeek == (int)Sched::DayType::Holiday) { // Sunday-Saturday, SummerDesignDay, WinterDesignDay, CustomDay1, and CustomDay2 are all valid. Holiday is not valid. // The input processor should trap invalid key choices, so this should never trip. assert(false); @@ -5583,7 +5598,7 @@ namespace Weather { ErrorsFound = true; } - int DayType = getEnumValue(ScheduleManager::dayTypeNamesUC, AlphArray(3)); + int DayType = getEnumValue(Sched::dayTypeNamesUC, AlphArray(3)); if (DayType == 0) { ShowSevereInvalidKey(state, eoh, ipsc->cAlphaFieldNames(3), AlphArray(3)); ErrorsFound = true; @@ -5788,7 +5803,7 @@ namespace Weather { state.dataWeather->DesDayInput.allocate(TotDesDays); // Allocate the array to the # of DD's state.dataWeather->desDayMods.allocate(TotDesDays); for (int iDD = 1; iDD <= TotDesDays; ++iDD) - state.dataWeather->desDayMods(iDD).allocate(state.dataGlobal->NumOfTimeStepInHour, Constant::HoursInDay); + state.dataWeather->desDayMods(iDD).allocate(state.dataGlobal->TimeStepsInHour, Constant::iHoursInDay); state.dataWeather->spSiteSchedules.dimension(TotDesDays, Weather::SPSiteSchedules()); @@ -5951,8 +5966,8 @@ namespace Weather { if (desDayInput.dryBulbRangeType == DesDayDryBulbRangeType::Default) { // Default dry-bulb temperature Range Real64 LastHrValue = DefaultTempRangeMult[23]; - for (int hour = 1; hour <= Constant::HoursInDay; ++hour) { - for (int ts = 1; ts <= state.dataGlobal->NumOfTimeStepInHour; ++ts) { + for (int hour = 1; hour <= Constant::iHoursInDay; ++hour) { + for (int ts = 1; ts <= state.dataGlobal->TimeStepsInHour; ++ts) { Real64 WNow = state.dataWeather->Interpolation(ts); Real64 WPrev = 1.0 - WNow; state.dataWeather->desDayMods(EnvrnNum)(ts, hour).OutDryBulbTemp = @@ -5964,24 +5979,23 @@ namespace Weather { } else if (ipsc->lAlphaFieldBlanks(4)) { ShowSevereEmptyField(state, eoh, ipsc->cAlphaFieldNames(4), ipsc->cAlphaFieldNames(3), "SCHEDULE"); ErrorsFound = true; - - } else if ((desDayInput.TempRangeSchPtr = ScheduleManager::GetDayScheduleIndex(state, ipsc->cAlphaArgs(4))) == 0) { + } else if ((desDayInput.tempRangeSched = Sched::GetDaySchedule(state, ipsc->cAlphaArgs(4))) == nullptr) { ShowSevereItemNotFound(state, eoh, ipsc->cAlphaFieldNames(4), ipsc->cAlphaArgs(4)); ErrorsFound = true; } else { - Array2D tmp = Array2D(state.dataGlobal->NumOfTimeStepInHour, Constant::HoursInDay); - ScheduleManager::GetSingleDayScheduleValues(state, desDayInput.TempRangeSchPtr, tmp); + Array2D tmp = Array2D(state.dataGlobal->TimeStepsInHour, Constant::iHoursInDay); + desDayInput.tempRangeSched->getDayVals(state, tmp); auto &desDayModEnvrn = state.dataWeather->desDayMods(EnvrnNum); - for (int iHr = 1; iHr <= Constant::HoursInDay; ++iHr) { - for (int iTS = 1; iTS <= state.dataGlobal->NumOfTimeStepInHour; ++iTS) { + for (int iHr = 1; iHr <= Constant::iHoursInDay; ++iHr) { + for (int iTS = 1; iTS <= state.dataGlobal->TimeStepsInHour; ++iTS) { desDayModEnvrn(iTS, iHr).OutDryBulbTemp = tmp(iTS, iHr); } } - if (std::find(state.dataWeather->spSiteSchedNums.begin(), state.dataWeather->spSiteSchedNums.end(), desDayInput.TempRangeSchPtr) == + if (std::find(state.dataWeather->spSiteSchedNums.begin(), state.dataWeather->spSiteSchedNums.end(), desDayInput.tempRangeSched->Num) == state.dataWeather->spSiteSchedNums.end()) { - state.dataWeather->spSiteSchedNums.emplace_back(desDayInput.TempRangeSchPtr); + state.dataWeather->spSiteSchedNums.emplace_back(desDayInput.tempRangeSched->Num); SetupOutputVariable(state, "Sizing Period Site Drybulb Temperature Range Modifier Schedule Value", unitType, @@ -5992,25 +6006,22 @@ namespace Weather { } if (desDayInput.dryBulbRangeType == DesDayDryBulbRangeType::Multiplier) { - if (!ScheduleManager::CheckDayScheduleValueMinMax(state, desDayInput.TempRangeSchPtr, 0.0, false, 1.0, false)) { - ShowSevereError(state, format("{}=\"{}\", invalid data.", ipsc->cCurrentModuleObject, desDayInput.Title)); - ShowContinueError(state, format("..invalid field: {}=\"{}\".", ipsc->cAlphaFieldNames(4), ipsc->cAlphaArgs(4))); - ShowContinueError(state, "..Specified [Schedule] Dry-bulb Range Multiplier Values are not within [0.0, 1.0]"); + if (!desDayInput.tempRangeSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) { + Sched::ShowSevereBadMinMax(state, eoh, ipsc->cAlphaFieldNames(4), ipsc->cAlphaArgs(4), + Clusive::In, 0.0, Clusive::In, 1.0); ErrorsFound = true; } } else if (desDayInput.dryBulbRangeType == DesDayDryBulbRangeType::Difference) { // delta, must be > 0.0 - if (!ScheduleManager::CheckDayScheduleValueMinMax(state, desDayInput.TempRangeSchPtr, 0.0, false)) { - ShowSevereError(state, format("{}=\"{}\", invalid data.", ipsc->cCurrentModuleObject, desDayInput.Title)); - ShowContinueError(state, format("..invalid field: {}=\"{}\".", ipsc->cAlphaFieldNames(4), ipsc->cAlphaArgs(4))); - ShowContinueError(state, "Some [Schedule] Dry-bulb Range Difference Values are < 0.0 [would make max larger]."); + if (!desDayInput.tempRangeSched->checkMinVal(state, Clusive::In, 0.0)) { + Sched::ShowSevereBadMin(state, eoh, ipsc->cAlphaFieldNames(4), ipsc->cAlphaArgs(4), Clusive::In, 0.0); ErrorsFound = true; } } auto const &desDayModsEnvrn = state.dataWeather->desDayMods(EnvrnNum); Real64 testval = std::numeric_limits::min(); - for (int iHr = 1; iHr <= Constant::HoursInDay; ++iHr) { - for (int iTS = 1; iTS <= state.dataGlobal->NumOfTimeStepInHour; ++iTS) { + for (int iHr = 1; iHr <= Constant::iHoursInDay; ++iHr) { + for (int iTS = 1; iTS <= state.dataGlobal->TimeStepsInHour; ++iTS) { if (desDayModsEnvrn(iTS, iHr).OutDryBulbTemp > testval) testval = desDayModsEnvrn(iTS, iHr).OutDryBulbTemp; } } @@ -6161,25 +6172,22 @@ namespace Weather { if (ipsc->lAlphaFieldBlanks(6)) { ShowSevereEmptyField(state, eoh, ipsc->cAlphaFieldNames(6), ipsc->cAlphaFieldNames(3), ipsc->cAlphaArgs(3)); ErrorsFound = true; - } else if ((desDayInput.HumIndSchPtr = ScheduleManager::GetDayScheduleIndex(state, ipsc->cAlphaArgs(6))) == 0) { - ShowWarningItemNotFound(state, - eoh, - ipsc->cAlphaFieldNames(6), - ipsc->cAlphaArgs(6), + } else if ((desDayInput.humIndSched = Sched::GetDaySchedule(state, ipsc->cAlphaArgs(6))) == nullptr) { + ShowWarningItemNotFound(state, eoh, ipsc->cAlphaFieldNames(6), ipsc->cAlphaArgs(6), "Default Humidity (constant for day using Humidity Indicator Temp)."); // reset HumIndType ? } else { - Array2D tmp = Array2D(state.dataGlobal->NumOfTimeStepInHour, Constant::HoursInDay); - ScheduleManager::GetSingleDayScheduleValues(state, desDayInput.HumIndSchPtr, tmp); + Array2D tmp = Array2D(state.dataGlobal->TimeStepsInHour, Constant::iHoursInDay); + desDayInput.humIndSched->getDayVals(state, tmp); auto &desDayModsEnvrn = state.dataWeather->desDayMods(EnvrnNum); - for (int iHr = 1; iHr <= Constant::HoursInDay; ++iHr) - for (int iTS = 1; iTS <= state.dataGlobal->NumOfTimeStepInHour; ++iTS) + for (int iHr = 1; iHr <= Constant::iHoursInDay; ++iHr) + for (int iTS = 1; iTS <= state.dataGlobal->TimeStepsInHour; ++iTS) desDayModsEnvrn(iTS, iHr).OutRelHum = tmp(iTS, iHr); - if (std::find(state.dataWeather->spSiteSchedNums.begin(), state.dataWeather->spSiteSchedNums.end(), desDayInput.HumIndSchPtr) == + if (std::find(state.dataWeather->spSiteSchedNums.begin(), state.dataWeather->spSiteSchedNums.end(), desDayInput.humIndSched->Num) == state.dataWeather->spSiteSchedNums.end()) { - state.dataWeather->spSiteSchedNums.emplace_back(desDayInput.HumIndSchPtr); + state.dataWeather->spSiteSchedNums.emplace_back(desDayInput.humIndSched->Num); SetupOutputVariable(state, "Sizing Period Site Humidity Condition Schedule Value", unitType, @@ -6191,27 +6199,23 @@ namespace Weather { switch (desDayInput.HumIndType) { case DesDayHumIndType::RelHumSch: { - if (!ScheduleManager::CheckDayScheduleValueMinMax(state, desDayInput.HumIndSchPtr, 0.0, false, 100.0, false)) { - ShowSevereError(state, format("{}=\"{}\", invalid data.", ipsc->cCurrentModuleObject, desDayInput.Title)); - ShowContinueError(state, format("..invalid field: {}=\"{}\".", ipsc->cAlphaFieldNames(6), ipsc->cAlphaArgs(6))); - ShowContinueError(state, "Specified [Scheduled] Relative Humidity Values are not within [0.0, 100.0]"); + if (!desDayInput.humIndSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 100.0)) { + Sched::ShowSevereBadMinMax(state, eoh, ipsc->cAlphaFieldNames(6), ipsc->cAlphaArgs(6), + Clusive::In, 0.0, Clusive::In, 100.0); ErrorsFound = true; } } break; case DesDayHumIndType::WBProfMul: { // multiplier: use schedule value, check 0 <= v <= 1 - if (!ScheduleManager::CheckDayScheduleValueMinMax(state, desDayInput.HumIndSchPtr, 0.0, false, 1.0, false)) { - ShowSevereError(state, format("{}=\"{}\", invalid data.", ipsc->cCurrentModuleObject, desDayInput.Title)); - ShowContinueError(state, format("..invalid field: {}=\"{}\".", ipsc->cAlphaFieldNames(6), ipsc->cAlphaArgs(6))); - ShowContinueError(state, "..Specified [Schedule] Wet-bulb Profile Range Multiplier Values are not within [0.0, 1.0]"); + if (!desDayInput.humIndSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) { + Sched::ShowSevereBadMinMax(state, eoh, ipsc->cAlphaFieldNames(6), ipsc->cAlphaArgs(6), + Clusive::In, 0.0, Clusive::In, 1.0); ErrorsFound = true; } } break; case DesDayHumIndType::WBProfDif: { - if (!ScheduleManager::CheckDayScheduleValueMinMax(state, desDayInput.HumIndSchPtr, 0.0, false)) { - ShowSevereError(state, format("{}=\"{}\", invalid data.", ipsc->cCurrentModuleObject, desDayInput.Title)); - ShowContinueError(state, format("..invalid field: {}=\"{}\".", ipsc->cAlphaFieldNames(6), ipsc->cAlphaArgs(6))); - ShowContinueError(state, "Some [Schedule] Wet-bulb Profile Difference Values are < 0.0 [would make max larger]."); + if (!desDayInput.humIndSched->checkMinVal(state, Clusive::In, 0.0)) { + Sched::ShowSevereBadMin(state, eoh, ipsc->cAlphaFieldNames(6), ipsc->cAlphaArgs(6), Clusive::In, 0.0); ErrorsFound = true; } } break; @@ -6223,8 +6227,8 @@ namespace Weather { } else if (desDayInput.HumIndType == DesDayHumIndType::WBProfDef) { // re WetBulbProfileDefaultMultipliers Real64 LastHrValue = DefaultTempRangeMult[23]; - for (int hour = 1; hour <= Constant::HoursInDay; ++hour) { - for (int ts = 1; ts <= state.dataGlobal->NumOfTimeStepInHour; ++ts) { + for (int hour = 1; hour <= Constant::iHoursInDay; ++hour) { + for (int ts = 1; ts <= state.dataGlobal->TimeStepsInHour; ++ts) { Real64 WNow = state.dataWeather->Interpolation(ts); Real64 WPrev = 1.0 - WNow; state.dataWeather->desDayMods(EnvrnNum)(ts, hour).OutRelHum = LastHrValue * WPrev + DefaultTempRangeMult[hour - 1] * WNow; @@ -6268,25 +6272,25 @@ namespace Weather { // A11, \field Beam Solar Day Schedule Name if (ipsc->lAlphaFieldBlanks(11)) { // should have entered beam schedule - ShowSevereEmptyField(state, eoh, ipsc->cAlphaFieldNames(11), "", ""); + ShowSevereEmptyField(state, eoh, ipsc->cAlphaFieldNames(11)); ErrorsFound = true; - } else if ((desDayInput.BeamSolarSchPtr = ScheduleManager::GetDayScheduleIndex(state, ipsc->cAlphaArgs(11))) == 0) { + } else if ((desDayInput.beamSolarSched = Sched::GetDaySchedule(state, ipsc->cAlphaArgs(11))) == nullptr) { ShowSevereItemNotFound(state, eoh, ipsc->cAlphaFieldNames(11), ipsc->cAlphaArgs(11)); ErrorsFound = true; } else { - Array2D tmp = Array2D(state.dataGlobal->NumOfTimeStepInHour, Constant::HoursInDay); - ScheduleManager::GetSingleDayScheduleValues(state, desDayInput.BeamSolarSchPtr, tmp); + Array2D tmp = Array2D(state.dataGlobal->TimeStepsInHour, Constant::iHoursInDay); + desDayInput.beamSolarSched->getDayVals(state, tmp); auto &desDayModsEnvrn = state.dataWeather->desDayMods(EnvrnNum); - for (int iHr = 1; iHr <= Constant::HoursInDay; ++iHr) - for (int iTS = 1; iTS <= state.dataGlobal->NumOfTimeStepInHour; ++iTS) + for (int iHr = 1; iHr <= Constant::iHoursInDay; ++iHr) + for (int iTS = 1; iTS <= state.dataGlobal->TimeStepsInHour; ++iTS) desDayModsEnvrn(iTS, iHr).BeamSolarRad = tmp(iTS, iHr); unitType = Constant::Units::W_m2; units = "[W/m2]"; if (std::find(state.dataWeather->spSiteSchedNums.begin(), state.dataWeather->spSiteSchedNums.end(), - desDayInput.BeamSolarSchPtr) == state.dataWeather->spSiteSchedNums.end()) { - state.dataWeather->spSiteSchedNums.emplace_back(desDayInput.BeamSolarSchPtr); + desDayInput.beamSolarSched->Num) == state.dataWeather->spSiteSchedNums.end()) { + state.dataWeather->spSiteSchedNums.emplace_back(desDayInput.beamSolarSched->Num); SetupOutputVariable(state, "Sizing Period Site Beam Solar Schedule Value", unitType, @@ -6296,10 +6300,8 @@ namespace Weather { ipsc->cAlphaArgs(11)); } - if (!ScheduleManager::CheckDayScheduleValueMinMax(state, desDayInput.BeamSolarSchPtr, 0.0, false)) { - ShowSevereError(state, format("{}=\"{}\", invalid data.", ipsc->cCurrentModuleObject, desDayInput.Title)); - ShowContinueError(state, format("..invalid field: {}=\"{}\".", ipsc->cAlphaFieldNames(11), ipsc->cAlphaArgs(11))); - ShowContinueError(state, "..Specified [Schedule] Values are not >= 0.0"); + if (!desDayInput.beamSolarSched->checkMinVal(state, Clusive::In, 0.0)) { + Sched::ShowSevereBadMin(state, eoh, ipsc->cAlphaFieldNames(11), ipsc->cAlphaArgs(11), Clusive::In, 0.0); ErrorsFound = true; } } @@ -6307,25 +6309,25 @@ namespace Weather { // A12, \field Diffuse Solar Day Schedule Name if (ipsc->lAlphaFieldBlanks(12)) { // should have entered diffuse schedule - ShowSevereEmptyField(state, eoh, ipsc->cAlphaFieldNames(12), "", ""); + ShowSevereEmptyField(state, eoh, ipsc->cAlphaFieldNames(12)); ErrorsFound = true; - } else if ((desDayInput.DiffuseSolarSchPtr = ScheduleManager::GetDayScheduleIndex(state, ipsc->cAlphaArgs(12))) == 0) { + } else if ((desDayInput.diffuseSolarSched = Sched::GetDaySchedule(state, ipsc->cAlphaArgs(12))) == nullptr) { ShowSevereItemNotFound(state, eoh, ipsc->cAlphaFieldNames(12), ipsc->cAlphaArgs(12)); ErrorsFound = true; } else { - Array2D tmp = Array2D(state.dataGlobal->NumOfTimeStepInHour, Constant::HoursInDay); - ScheduleManager::GetSingleDayScheduleValues(state, desDayInput.DiffuseSolarSchPtr, tmp); + Array2D tmp = Array2D(state.dataGlobal->TimeStepsInHour, Constant::iHoursInDay); + desDayInput.diffuseSolarSched->getDayVals(state, tmp); auto &desDayModsEnvrn = state.dataWeather->desDayMods(EnvrnNum); - for (int iHr = 1; iHr <= Constant::HoursInDay; ++iHr) - for (int iTS = 1; iTS <= state.dataGlobal->NumOfTimeStepInHour; ++iTS) + for (int iHr = 1; iHr <= Constant::iHoursInDay; ++iHr) + for (int iTS = 1; iTS <= state.dataGlobal->TimeStepsInHour; ++iTS) desDayModsEnvrn(iTS, iHr).DifSolarRad = tmp(iTS, iHr); units = "[W/m2]"; unitType = Constant::Units::W_m2; if (std::find(state.dataWeather->spSiteSchedNums.begin(), state.dataWeather->spSiteSchedNums.end(), - desDayInput.DiffuseSolarSchPtr) == state.dataWeather->spSiteSchedNums.end()) { - state.dataWeather->spSiteSchedNums.emplace_back(desDayInput.DiffuseSolarSchPtr); + desDayInput.diffuseSolarSched->Num) == state.dataWeather->spSiteSchedNums.end()) { + state.dataWeather->spSiteSchedNums.emplace_back(desDayInput.diffuseSolarSched->Num); SetupOutputVariable(state, "Sizing Period Site Diffuse Solar Schedule Value", unitType, @@ -6334,10 +6336,8 @@ namespace Weather { OutputProcessor::StoreType::Average, ipsc->cAlphaArgs(12)); } - if (!ScheduleManager::CheckDayScheduleValueMinMax(state, desDayInput.DiffuseSolarSchPtr, 0.0, false)) { - ShowSevereError(state, format("{}=\"{}\", invalid data.", ipsc->cCurrentModuleObject, desDayInput.Title)); - ShowContinueError(state, format("..invalid field: {}=\"{}\".", ipsc->cAlphaFieldNames(12), ipsc->cAlphaArgs(12))); - ShowContinueError(state, "..Specified [Schedule] Values are not >= 0.0"); + if (!desDayInput.diffuseSolarSched->checkMinVal(state, Clusive::In, 0.0)) { + Sched::ShowSevereBadMin(state, eoh, ipsc->cAlphaFieldNames(12), ipsc->cAlphaArgs(12), Clusive::In, 0.0); ErrorsFound = true; } } @@ -6404,7 +6404,7 @@ namespace Weather { } // A2, \field Day Type - desDayInput.DayType = getEnumValue(ScheduleManager::dayTypeNamesUC, ipsc->cAlphaArgs(2)); + desDayInput.DayType = getEnumValue(Sched::dayTypeNamesUC, ipsc->cAlphaArgs(2)); if (desDayInput.DayType <= 0) { ShowSevereInvalidKey(state, eoh, ipsc->cAlphaFieldNames(2), ipsc->cAlphaArgs(2)); ErrorsFound = true; @@ -6632,33 +6632,30 @@ namespace Weather { default: { // Bad inputs are trapped by input processor assert(false); - } - } + } break; + } // switch (skyTempModel) if (wpSkyTemp.IsSchedule) { - wpSkyTemp.ScheduleName = ipsc->cAlphaArgs(3); if (state.dataWeather->Environment(Found).KindOfEnvrn == Constant::KindOfSim::RunPeriodWeather || state.dataWeather->Environment(Found).KindOfEnvrn == Constant::KindOfSim::RunPeriodDesign) { - wpSkyTemp.ScheduleName = ipsc->cAlphaArgs(3); // See if it's a schedule. - Found = ScheduleManager::GetScheduleIndex(state, ipsc->cAlphaArgs(3)); - if (Found == 0) { + if ((wpSkyTemp.sched = Sched::GetSchedule(state, ipsc->cAlphaArgs(3))) == nullptr) { ShowSevereItemNotFound(state, eoh, ipsc->cAlphaFieldNames(3), ipsc->cAlphaArgs(3)); ErrorsFound = true; } else { wpSkyTemp.IsSchedule = true; - wpSkyTemp.SchedulePtr = Found; } } else { // See if it's a valid schedule. - Found = ScheduleManager::GetDayScheduleIndex(state, ipsc->cAlphaArgs(3)); - if (Found == 0) { +#ifdef GET_OUT + // How can a schedule be either a yearly schedule or a day schedule? + if ((wpSkyTemp.sched = Sched::GetDaySchedule(state, ipsc->cAlphaArgs(3))) == nullptr) { ShowSevereItemNotFound(state, eoh, ipsc->cAlphaFieldNames(3), ipsc->cAlphaArgs(3)); ErrorsFound = true; } else { if (envFound != 0) { if (std::find(state.dataWeather->spSiteSchedNums.begin(), state.dataWeather->spSiteSchedNums.end(), Found) == state.dataWeather->spSiteSchedNums.end()) { - state.dataWeather->spSiteSchedNums.emplace_back(Found); + state.dataWeather->spSiteSchedNums.emplace_back(wpSkyTemp.sched->Num); SetupOutputVariable(state, "Sizing Period Site Sky Temperature Schedule Value", unitType, @@ -6668,9 +6665,9 @@ namespace Weather { ipsc->cAlphaArgs(3)); } wpSkyTemp.IsSchedule = true; - wpSkyTemp.SchedulePtr = Found; } } +#endif // GET_OUT } } @@ -6884,13 +6881,15 @@ namespace Weather { switch (state.dataWeather->WaterMainsTempsMethod) { case WaterMainsTempCalcMethod::Schedule: { - state.dataWeather->WaterMainsTempsScheduleName = AlphArray(2); - state.dataWeather->WaterMainsTempsSchedule = ScheduleManager::GetScheduleIndex(state, AlphArray(2)); - if (state.dataWeather->WaterMainsTempsSchedule == 0) { + if (ipsc->lAlphaFieldBlanks(2)) { + ShowSevereEmptyField(state, eoh, ipsc->cAlphaFieldNames(2)); + ErrorsFound = true; + } else if ((state.dataWeather->waterMainsTempSched = Sched::GetSchedule(state, AlphArray(2))) == nullptr) { ShowSevereItemNotFound(state, eoh, ipsc->cAlphaFieldNames(2), AlphArray(2)); ErrorsFound = true; } } break; + case WaterMainsTempCalcMethod::Correlation: { if (NumNums == 0) { ShowSevereError(state, format("{}: Missing Annual Average and Maximum Difference fields.", ipsc->cCurrentModuleObject)); @@ -6936,7 +6935,7 @@ namespace Weather { switch (state.dataWeather->WaterMainsTempsMethod) { case WaterMainsTempCalcMethod::Schedule: - state.dataEnvrn->WaterMainsTemp = ScheduleManager::GetCurrentScheduleValue(state, state.dataWeather->WaterMainsTempsSchedule); + state.dataEnvrn->WaterMainsTemp = state.dataWeather->waterMainsTempSched->getCurrentVal(); break; case WaterMainsTempCalcMethod::Correlation: state.dataEnvrn->WaterMainsTemp = WaterMainsTempFromCorrelation( @@ -6992,7 +6991,7 @@ namespace Weather { // calculated water main temp (F) Real64 CurrentWaterMainsTemp = Tavg + Offset + - Ratio * (Tdiff / 2.0) * latitude_sign * std::sin((0.986 * (state.dataEnvrn->DayOfYear - 15.0 - Lag) - 90) * Constant::DegToRadians); + Ratio * (Tdiff / 2.0) * latitude_sign * std::sin((0.986 * (state.dataEnvrn->DayOfYear - 15.0 - Lag) - 90) * Constant::DegToRad); if (CurrentWaterMainsTemp < 32.0) CurrentWaterMainsTemp = 32.0; @@ -7156,7 +7155,7 @@ namespace Weather { ((state.dataEnvrn->DifSolarRad + state.dataEnvrn->BeamSolarRad) / (state.dataEnvrn->DifSolarRad + 0.0001) + Zeta) / (1.0 + Zeta); // Relative optical air mass Real64 const AirMass = (1.0 - 0.1 * state.dataEnvrn->Elevation / 1000.0) / - (SinSunAltitude + 0.15 / std::pow(SunAltitude / Constant::DegToRadians + 3.885, 1.253)); + (SinSunAltitude + 0.15 / std::pow(SunAltitude / Constant::DegToRad + 3.885, 1.253)); // In the following, 93.73 is the extraterrestrial luminous efficacy state.dataEnvrn->SkyBrightness = (state.dataEnvrn->DifSolarRad * 93.73) * AirMass / ExtraDirNormIll[state.dataEnvrn->Month - 1]; int ISkyClearness; // Sky clearness bin @@ -7833,7 +7832,7 @@ namespace Weather { if (CurCount <= state.dataWeather->NumDataPeriods) { auto &dataPeriod = state.dataWeather->DataPeriods(CurCount); dataPeriod.DayOfWeek = Line.substr(0, Pos); - dataPeriod.WeekDay = getEnumValue(ScheduleManager::dayTypeNamesUC, dataPeriod.DayOfWeek); + dataPeriod.WeekDay = getEnumValue(Sched::dayTypeNamesUC, dataPeriod.DayOfWeek); if (dataPeriod.WeekDay < 1 || dataPeriod.WeekDay > 7) { ShowSevereError(state, fmt::format("Weather File -- Invalid Start Day of Week for Data Period #{}, Invalid day={}", @@ -8079,41 +8078,41 @@ namespace Weather { int halfpoint = 0; - state.dataWeather->Interpolation.allocate(state.dataGlobal->NumOfTimeStepInHour); - state.dataWeather->SolarInterpolation.allocate(state.dataGlobal->NumOfTimeStepInHour); + state.dataWeather->Interpolation.allocate(state.dataGlobal->TimeStepsInHour); + state.dataWeather->SolarInterpolation.allocate(state.dataGlobal->TimeStepsInHour); state.dataWeather->Interpolation = 0.0; state.dataWeather->SolarInterpolation = 0.0; - for (int tloop = 1; tloop <= state.dataGlobal->NumOfTimeStepInHour; ++tloop) { + for (int tloop = 1; tloop <= state.dataGlobal->TimeStepsInHour; ++tloop) { state.dataWeather->Interpolation(tloop) = - (state.dataGlobal->NumOfTimeStepInHour == 1) ? 1.0 : min(1.0, (double(tloop) / double(state.dataGlobal->NumOfTimeStepInHour))); + (state.dataGlobal->TimeStepsInHour == 1) ? 1.0 : min(1.0, (double(tloop) / double(state.dataGlobal->TimeStepsInHour))); } - if (mod(state.dataGlobal->NumOfTimeStepInHour, 2) == 0) { + if (mod(state.dataGlobal->TimeStepsInHour, 2) == 0) { // even number of time steps. - halfpoint = state.dataGlobal->NumOfTimeStepInHour / 2; + halfpoint = state.dataGlobal->TimeStepsInHour / 2; state.dataWeather->SolarInterpolation(halfpoint) = 1.0; - Real64 tweight = 1.0 / double(state.dataGlobal->NumOfTimeStepInHour); - for (int tloop = halfpoint + 1, hpoint = 1; tloop <= state.dataGlobal->NumOfTimeStepInHour; ++tloop, ++hpoint) { + Real64 tweight = 1.0 / double(state.dataGlobal->TimeStepsInHour); + for (int tloop = halfpoint + 1, hpoint = 1; tloop <= state.dataGlobal->TimeStepsInHour; ++tloop, ++hpoint) { state.dataWeather->SolarInterpolation(tloop) = 1.0 - hpoint * tweight; } for (int tloop = halfpoint - 1, hpoint = 1; tloop >= 1; --tloop, ++hpoint) { state.dataWeather->SolarInterpolation(tloop) = 1.0 - hpoint * tweight; } } else { // odd number of time steps - if (state.dataGlobal->NumOfTimeStepInHour == 1) { + if (state.dataGlobal->TimeStepsInHour == 1) { state.dataWeather->SolarInterpolation(1) = 0.5; - } else if (state.dataGlobal->NumOfTimeStepInHour == 3) { + } else if (state.dataGlobal->TimeStepsInHour == 3) { state.dataWeather->SolarInterpolation(1) = 5.0 / 6.0; state.dataWeather->SolarInterpolation(2) = 5.0 / 6.0; state.dataWeather->SolarInterpolation(3) = 0.5; } else { - Real64 tweight = 1.0 / double(state.dataGlobal->NumOfTimeStepInHour); - halfpoint = state.dataGlobal->NumOfTimeStepInHour / 2; + Real64 tweight = 1.0 / double(state.dataGlobal->TimeStepsInHour); + halfpoint = state.dataGlobal->TimeStepsInHour / 2; Real64 tweight1 = 1.0 - tweight / 2.0; state.dataWeather->SolarInterpolation(halfpoint) = tweight1; state.dataWeather->SolarInterpolation(halfpoint + 1) = tweight1; - for (int tloop = halfpoint + 2, hpoint = 1; tloop <= state.dataGlobal->NumOfTimeStepInHour; ++tloop, ++hpoint) { + for (int tloop = halfpoint + 2, hpoint = 1; tloop <= state.dataGlobal->TimeStepsInHour; ++tloop, ++hpoint) { state.dataWeather->SolarInterpolation(tloop) = tweight1 - hpoint * tweight; } for (int tloop = halfpoint - 1, hpoint = 1; tloop >= 1; --tloop, ++hpoint) { @@ -8316,7 +8315,7 @@ namespace Weather { return {tyyyy, tmm, tdd}; } - ScheduleManager::DayType calculateDayOfWeek(EnergyPlusData &state, int const year, int const month, int const day) + Sched::DayType calculateDayOfWeek(EnergyPlusData &state, int const year, int const month, int const day) { // FUNCTION INFORMATION: @@ -8346,7 +8345,7 @@ namespace Weather { state.dataEnvrn->DayOfWeek = mod(day + (13 * (Gmm + 1) / 5) + Gyyyy + (Gyyyy / 4) + 6 * (Gyyyy / 100) + (Gyyyy / 400), 7); if (state.dataEnvrn->DayOfWeek == 0) state.dataEnvrn->DayOfWeek = 7; - return static_cast(state.dataEnvrn->DayOfWeek); + return static_cast(state.dataEnvrn->DayOfWeek); } int calculateDayOfYear(int const Month, int const Day, bool const leapYear) @@ -8572,7 +8571,7 @@ namespace Weather { case WaterMainsTempCalcMethod::Schedule: *eiostream << "Site Water Mains Temperature Information,"; *eiostream << waterMainsCalcMethodNames[static_cast(state.dataWeather->WaterMainsTempsMethod)] << "," - << state.dataWeather->WaterMainsTempsScheduleName << ","; + << state.dataWeather->waterMainsTempSched->Name << ","; *eiostream << format("{:.2R}", state.dataWeather->WaterMainsTempsAnnualAvgAirTemp) << "," << format("{:.2R}", state.dataWeather->WaterMainsTempsMaxDiffAirTemp) << ","; *eiostream << "NA\n"; @@ -8659,8 +8658,8 @@ namespace Weather { void ForAllHrTs(EnergyPlusData &state, std::function f) { - for (int iHr = 1; iHr <= Constant::HoursInDay; ++iHr) - for (int iTS = 1; iTS <= state.dataGlobal->NumOfTimeStepInHour; ++iTS) + for (int iHr = 1; iHr <= Constant::iHoursInDay; ++iHr) + for (int iTS = 1; iTS <= state.dataGlobal->TimeStepsInHour; ++iTS) f(iHr, iTS); } diff --git a/src/EnergyPlus/WeatherManager.hh b/src/EnergyPlus/WeatherManager.hh index 78dc5e60ae8..d9b2e112414 100644 --- a/src/EnergyPlus/WeatherManager.hh +++ b/src/EnergyPlus/WeatherManager.hh @@ -243,11 +243,10 @@ namespace Weather { int DSTIndicator = 0; // Daylight Saving Time Period Indicator (1=yes, 0=no) for this DesignDay DesDaySolarModel solarModel = DesDaySolarModel::ASHRAE_ClearSky; // Solar Model for creating solar values for design day. DesDayDryBulbRangeType dryBulbRangeType = DesDayDryBulbRangeType::Default; // Drybulb Range Type (see Parameters) - int TempRangeSchPtr = 0; // Schedule pointer to a day schedule for dry-bulb temperature range multipliers - int HumIndSchPtr = 0; // Schedule pointer to a day schedule that specifies - // relative humidity (%) or wet-bulb range multipliers per HumIndType - int BeamSolarSchPtr = 0; // Schedule pointer to a day schedule for beam solar - int DiffuseSolarSchPtr = 0; // Schedule pointer to a day schedule for diffuse solar + Sched::DaySchedule *tempRangeSched = nullptr; // day schedule for dry-bulb temperature range multipliers + Sched::DaySchedule *humIndSched = nullptr; // day schedule that specifies relative humidity (%) or wet-bulb range multipliers per HumIndType + Sched::DaySchedule *beamSolarSched = nullptr; // day schedule for beam solar + Sched::DaySchedule *diffuseSolarSched = nullptr; // day schedule for diffuse solar Real64 TauB = 0.0; // beam pseudo optical depth for ASHRAE tau model Real64 TauD = 0.0; // diffuse pseudo optical depth for ASHRAE tau model Real64 DailyWBRange = 0.0; // daily range of wetbulb (deltaC) @@ -289,7 +288,7 @@ namespace Weather { int endJulianDate = 2458119; // Calculated end date (Julian or ordinal) for a weather file run period int endYear = 2017; // entered in "consecutive"/real runperiod object int dayOfWeek = 1; // Day of Week that the RunPeriod will start on (User Input) - ScheduleManager::DayType startWeekDay = ScheduleManager::DayType::Sunday; // Day of the week that the RunPeriod will start on (User Input) + Sched::DayType startWeekDay = Sched::DayType::Sunday; // Day of the week that the RunPeriod will start on (User Input) bool useDST = false; // True if DaylightSavingTime is used for this RunPeriod bool useHolidays = false; // True if Holidays are used for this RunPeriod (from WeatherFile) bool applyWeekendRule = false; // True if "Weekend Rule" is to be applied to RunPeriod @@ -419,10 +418,9 @@ namespace Weather { { // Members std::string Name = ""; // Reference Name - std::string ScheduleName = ""; // Schedule Name or Algorithm Name bool IsSchedule = true; // Default is using Schedule SkyTempModel skyTempModel = SkyTempModel::ClarkAllen; - int SchedulePtr = 0; // pointer to schedule when used + Sched::Schedule *sched = nullptr; // schedule when used bool UsedForEnvrn = false; bool UseWeatherFileHorizontalIR = true; // If false, horizontal IR and sky temperature are calculated with WP models }; @@ -432,8 +430,8 @@ namespace Weather { std::string Name = ""; Real64 distanceFromLeadingEdge = 0.0; int OSCMIndex = 0; - int WaterTempScheduleIndex = 0; - int VelocityScheduleIndex = 0; + Sched::Schedule *waterTempSched = nullptr; + Sched::Schedule *velocitySched = nullptr; }; // Functions @@ -683,7 +681,7 @@ namespace Weather { GregorianDate computeGregorianDate(int jdate); - ScheduleManager::DayType calculateDayOfWeek(EnergyPlusData &state, int year, int month, int day); + Sched::DayType calculateDayOfWeek(EnergyPlusData &state, int year, int month, int day); int calculateDayOfYear(int Month, int Day, bool leapYear = false); @@ -803,10 +801,9 @@ struct WeatherManagerData : BaseGlobalStruct Real64 SnowGndRefModifierForDayltg = 1.0; // Modifier to ground reflectance during snow for daylighting Weather::WaterMainsTempCalcMethod WaterMainsTempsMethod = Weather::WaterMainsTempCalcMethod::FixedDefault; // Water mains temperature calculation method - int WaterMainsTempsSchedule = 0; // Water mains temperature schedule + Sched::Schedule *waterMainsTempSched = nullptr; // Water mains temperature schedule Real64 WaterMainsTempsAnnualAvgAirTemp = 0.0; // Annual average outdoor air temperature (C) Real64 WaterMainsTempsMaxDiffAirTemp = 0.0; // Maximum difference in monthly average outdoor air temperatures (deltaC) - std::string WaterMainsTempsScheduleName = ""; // water mains tempeature schedule name bool wthFCGroundTemps = false; int TotRunPers = 0; // Total number of Run Periods (Weather data) to Setup @@ -931,6 +928,10 @@ struct WeatherManagerData : BaseGlobalStruct // ProcessEPWHeader static vars std::string EPWHeaderTitle = ""; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/WindTurbine.cc b/src/EnergyPlus/WindTurbine.cc index ab1ee89df7d..54d40648dcf 100644 --- a/src/EnergyPlus/WindTurbine.cc +++ b/src/EnergyPlus/WindTurbine.cc @@ -206,10 +206,8 @@ namespace WindTurbine { // This subroutine gets input data for wind turbine components // and stores it in the wind turbine data structure. - // Using/Aliasing - - using ScheduleManager::GetScheduleIndex; - + static constexpr std::string_view routineName = "GetWindTurbineInput"; + // SUBROUTINE PARAMETER DEFINITIONS: static std::string const CurrentModuleObject("Generator:WindTurbine"); Real64 constexpr SysEffDefault(0.835); // Default value of overall system efficiency @@ -259,26 +257,20 @@ namespace WindTurbine { lAlphaBlanks, cAlphaFields, cNumericFields); + + ErrorObjectHeader eoh{routineName, CurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1)}; + Util::IsNameEmpty(state, state.dataIPShortCut->cAlphaArgs(1), CurrentModuleObject, ErrorsFound); auto &windTurbine = state.dataWindTurbine->WindTurbineSys(WindTurbineNum); windTurbine.Name = state.dataIPShortCut->cAlphaArgs(1); // Name of wind turbine - windTurbine.Schedule = state.dataIPShortCut->cAlphaArgs(2); // Get schedule if (lAlphaBlanks(2)) { - windTurbine.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - windTurbine.SchedPtr = GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(2)); - if (windTurbine.SchedPtr == 0) { - ShowSevereError(state, - format("{}=\"{}\" invalid {}=\"{}\" not found.", - CurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), - cAlphaFields(2), - state.dataIPShortCut->cAlphaArgs(2))); - ErrorsFound = true; - } + windTurbine.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((windTurbine.availSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(2), state.dataIPShortCut->cAlphaArgs(2)); + ErrorsFound = true; } // Select rotor type windTurbine.rotorType = @@ -912,7 +904,6 @@ namespace WindTurbine { using DataEnvironment::OutWetBulbTempAt; using Psychrometrics::PsyRhoAirFnPbTdbW; using Psychrometrics::PsyWFnTdbTwbPb; - using ScheduleManager::GetCurrentScheduleValue; Real64 constexpr MaxTheta(90.0); // Maximum of theta Real64 constexpr MaxDegree(360.0); // Maximum limit of outdoor air wind speed in m/s @@ -971,7 +962,7 @@ namespace WindTurbine { LocalWindSpeed /= windTurbine.WSFactor; // Check wind conditions for system operation - if (GetCurrentScheduleValue(state, windTurbine.SchedPtr) > 0 && LocalWindSpeed > windTurbine.CutInSpeed && + if (windTurbine.availSched->getCurrentVal() > 0 && LocalWindSpeed > windTurbine.CutInSpeed && LocalWindSpeed < windTurbine.CutOutSpeed) { // System is on @@ -1043,8 +1034,8 @@ namespace WindTurbine { InducedVel = LocalWindSpeed * 2.0 / 3.0; // Velocity components - Real64 const sin_AzimuthAng(std::sin(AzimuthAng * Constant::DegToRadians)); - Real64 const cos_AzimuthAng(std::cos(AzimuthAng * Constant::DegToRadians)); + Real64 const sin_AzimuthAng = std::sin(AzimuthAng * Constant::DegToRad); + Real64 const cos_AzimuthAng = std::cos(AzimuthAng * Constant::DegToRad); ChordalVel = RotorVel + InducedVel * cos_AzimuthAng; NormalVel = InducedVel * sin_AzimuthAng; RelFlowVel = std::sqrt(pow_2(ChordalVel) + pow_2(NormalVel)); @@ -1053,8 +1044,8 @@ namespace WindTurbine { AngOfAttack = std::atan((sin_AzimuthAng / ((RotorVel / LocalWindSpeed) / (InducedVel / LocalWindSpeed) + cos_AzimuthAng))); // Force coefficients - Real64 const sin_AngOfAttack(std::sin(AngOfAttack * Constant::DegToRadians)); - Real64 const cos_AngOfAttack(std::cos(AngOfAttack * Constant::DegToRadians)); + Real64 const sin_AngOfAttack = std::sin(AngOfAttack * Constant::DegToRad); + Real64 const cos_AngOfAttack = std::cos(AngOfAttack * Constant::DegToRad); TanForceCoeff = std::abs(windTurbine.LiftCoeff * sin_AngOfAttack - windTurbine.DragCoeff * cos_AngOfAttack); NorForceCoeff = windTurbine.LiftCoeff * cos_AngOfAttack + windTurbine.DragCoeff * sin_AngOfAttack; diff --git a/src/EnergyPlus/WindTurbine.hh b/src/EnergyPlus/WindTurbine.hh index cb8e5c1910d..5cb2c4a9f63 100644 --- a/src/EnergyPlus/WindTurbine.hh +++ b/src/EnergyPlus/WindTurbine.hh @@ -86,10 +86,9 @@ namespace WindTurbine { { // Members std::string Name; // The component name - std::string Schedule; // Available schedule RotorType rotorType = RotorType::Invalid; // Rotor type (HAWT or VAWT) ControlType controlType = ControlType::Invalid; // Control type - int SchedPtr = 0; // Schedule + Sched::Schedule *availSched = nullptr; int NumOfBlade = 0; // Blade number Real64 RatedRotorSpeed = 0.0; // Rated rotor speed in m/s Real64 RotorDiameter = 0.0; // Diameter of rotor in m @@ -166,6 +165,10 @@ struct WindTurbineData : BaseGlobalStruct bool MyOneTimeFlag = true; EPVector WindTurbineSys; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/WindowAC.cc b/src/EnergyPlus/WindowAC.cc index 21fc96df840..031dda73f86 100644 --- a/src/EnergyPlus/WindowAC.cc +++ b/src/EnergyPlus/WindowAC.cc @@ -114,7 +114,6 @@ namespace WindowAC { using HVAC::SmallAirVolFlow; using HVAC::SmallLoad; using HVAC::SmallMassFlow; - using namespace ScheduleManager; using Psychrometrics::PsyCpAirFnW; using Psychrometrics::PsyHFnTdbW; using Psychrometrics::PsyRhoAirFnPbTdbW; @@ -178,7 +177,7 @@ namespace WindowAC { RemainingOutputToCoolingSP = state.dataZoneEnergyDemand->ZoneSysEnergyDemand(ZoneNum).RemainingOutputReqToCoolSP; - if (RemainingOutputToCoolingSP < 0.0 && state.dataHeatBalFanSys->TempControlType(ZoneNum) != HVAC::ThermostatType::SingleHeating) { + if (RemainingOutputToCoolingSP < 0.0 && state.dataHeatBalFanSys->TempControlType(ZoneNum) != HVAC::SetptType::SingleHeat) { QZnReq = RemainingOutputToCoolingSP; } else { QZnReq = 0.0; @@ -302,17 +301,14 @@ namespace WindowAC { state.dataWindowAC->WindAC(WindACNum).Name = Alphas(1); state.dataWindowAC->WindAC(WindACNum).UnitType = state.dataWindowAC->WindowAC_UnitType; // 'ZoneHVAC:WindowAirConditioner' - state.dataWindowAC->WindAC(WindACNum).Sched = Alphas(2); + if (lAlphaBlanks(2)) { - state.dataWindowAC->WindAC(WindACNum).SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - state.dataWindowAC->WindAC(WindACNum).SchedPtr = GetScheduleIndex(state, Alphas(2)); // convert schedule name to pointer - if (state.dataWindowAC->WindAC(WindACNum).SchedPtr == 0) { - ShowSevereError(state, format("{}=\"{}\" invalid data.", CurrentModuleObject, state.dataWindowAC->WindAC(WindACNum).Name)); - ShowContinueError(state, format("invalid-not found {}=\"{}\".", cAlphaFields(2), Alphas(2))); - ErrorsFound = true; - } + state.dataWindowAC->WindAC(WindACNum).availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((state.dataWindowAC->WindAC(WindACNum).availSched = Sched::GetSchedule(state, Alphas(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(2), Alphas(2)); + ErrorsFound = true; } + state.dataWindowAC->WindAC(WindACNum).MaxAirVolFlow = Numbers(1); state.dataWindowAC->WindAC(WindACNum).OutAirVolFlow = Numbers(2); @@ -398,7 +394,7 @@ namespace WindowAC { ErrorsFound = true; } } - windAC.FanAvailSchedPtr = fan->availSchedNum; + windAC.fanAvailSched = fan->availSched; } state.dataWindowAC->WindAC(WindACNum).DXCoilName = Alphas(10); @@ -434,17 +430,11 @@ namespace WindowAC { ErrorsFound = true; } - state.dataWindowAC->WindAC(WindACNum).FanSchedPtr = GetScheduleIndex(state, Alphas(11)); - - // Default to cycling fan when fan mode schedule is not present - if (!lAlphaBlanks(11) && state.dataWindowAC->WindAC(WindACNum).FanSchedPtr == 0) { - ShowSevereError( - state, - format( - "{} \"{}\" {} not found: {}", CurrentModuleObject, state.dataWindowAC->WindAC(WindACNum).Name, cAlphaFields(11), Alphas(11))); - ErrorsFound = true; - } else if (lAlphaBlanks(11)) { + if (lAlphaBlanks(11)) { state.dataWindowAC->WindAC(WindACNum).fanOp = HVAC::FanOp::Cycling; + } else if ((state.dataWindowAC->WindAC(WindACNum).fanOpModeSched = Sched::GetSchedule(state, Alphas(11))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(11), Alphas(11)); + ErrorsFound = true; } state.dataWindowAC->WindAC(WindACNum).fanPlace = static_cast(getEnumValue(HVAC::fanPlaceNamesUC, Alphas(12))); @@ -809,8 +799,8 @@ namespace WindowAC { state.dataWindowAC->MyEnvrnFlag(WindACNum) = true; } - if (state.dataWindowAC->WindAC(WindACNum).FanSchedPtr > 0) { - if (GetCurrentScheduleValue(state, state.dataWindowAC->WindAC(WindACNum).FanSchedPtr) == 0.0) { + if (state.dataWindowAC->WindAC(WindACNum).fanOpModeSched != nullptr) { + if (state.dataWindowAC->WindAC(WindACNum).fanOpModeSched->getCurrentVal() == 0.0) { state.dataWindowAC->WindAC(WindACNum).fanOp = HVAC::FanOp::Cycling; } else { state.dataWindowAC->WindAC(WindACNum).fanOp = HVAC::FanOp::Continuous; @@ -822,8 +812,8 @@ namespace WindowAC { OutsideAirNode = state.dataWindowAC->WindAC(WindACNum).OutsideAirNode; AirRelNode = state.dataWindowAC->WindAC(WindACNum).AirReliefNode; // Set the inlet node mass flow rate - if (GetCurrentScheduleValue(state, state.dataWindowAC->WindAC(WindACNum).SchedPtr) <= 0.0 || - (GetCurrentScheduleValue(state, state.dataWindowAC->WindAC(WindACNum).FanAvailSchedPtr) <= 0.0 && !state.dataHVACGlobal->TurnFansOn) || + if (state.dataWindowAC->WindAC(WindACNum).availSched->getCurrentVal() <= 0.0 || + (state.dataWindowAC->WindAC(WindACNum).fanAvailSched->getCurrentVal() <= 0.0 && !state.dataHVACGlobal->TurnFansOn) || state.dataHVACGlobal->TurnFansOff) { state.dataWindowAC->WindAC(WindACNum).PartLoadFrac = 0.0; state.dataLoopNodes->Node(InletNode).MassFlowRate = 0.0; @@ -858,7 +848,7 @@ namespace WindowAC { // Constant fan systems are tested for ventilation load to determine if load to be met changes. if (state.dataWindowAC->WindAC(WindACNum).fanOp == HVAC::FanOp::Continuous && state.dataWindowAC->WindAC(WindACNum).PartLoadFrac > 0.0 && - (GetCurrentScheduleValue(state, state.dataWindowAC->WindAC(WindACNum).FanAvailSchedPtr) > 0.0 || state.dataHVACGlobal->TurnFansOn) && + (state.dataWindowAC->WindAC(WindACNum).fanAvailSched->getCurrentVal() > 0.0 || state.dataHVACGlobal->TurnFansOn) && !state.dataHVACGlobal->TurnFansOff) { CalcWindowACOutput(state, WindACNum, FirstHVACIteration, state.dataWindowAC->WindAC(WindACNum).fanOp, 0.0, false, NoCompOutput); diff --git a/src/EnergyPlus/WindowAC.hh b/src/EnergyPlus/WindowAC.hh index 311b122d99b..170f2d058c6 100644 --- a/src/EnergyPlus/WindowAC.hh +++ b/src/EnergyPlus/WindowAC.hh @@ -69,10 +69,10 @@ namespace WindowAC { // input data std::string Name; // name of unit int UnitType; // type of unit - std::string Sched; // availability schedule - int SchedPtr; // index to schedule - int FanSchedPtr; // index to fan operating mode schedule - int FanAvailSchedPtr; // index to fan availability schedule + + Sched::Schedule *availSched = nullptr; // availability schedule + Sched::Schedule *fanOpModeSched = nullptr; // fan operating mode schedule + Sched::Schedule *fanAvailSched = nullptr; // fan availability schedule Real64 MaxAirVolFlow; // m3/s Real64 MaxAirMassFlow; // kg/s Real64 OutAirVolFlow; // m3/s @@ -125,7 +125,7 @@ namespace WindowAC { // Default Constructor WindACData() - : UnitType(0), SchedPtr(0), FanSchedPtr(0), FanAvailSchedPtr(0), MaxAirVolFlow(0.0), MaxAirMassFlow(0.0), OutAirVolFlow(0.0), + : UnitType(0), MaxAirVolFlow(0.0), MaxAirMassFlow(0.0), OutAirVolFlow(0.0), OutAirMassFlow(0.0), AirInNode(0), AirOutNode(0), OutsideAirNode(0), AirReliefNode(0), MixedAirNode(0), OAMixIndex(0), fanType(HVAC::FanType::Invalid), FanIndex(0), DXCoilType_Num(0), DXCoilIndex(0), DXCoilNumOfSpeeds(0), CoilOutletNodeNum(0), fanPlace(HVAC::FanPlace::Invalid), MaxIterIndex1(0), MaxIterIndex2(0), ConvergenceTol(0.0), PartLoadFrac(0.0), @@ -236,6 +236,10 @@ struct WindowACData : BaseGlobalStruct Array1D_bool MyEnvrnFlag; // one time initialization flag Array1D_bool MyZoneEqFlag; // used to set up zone equipment availability managers + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/WindowComplexManager.cc b/src/EnergyPlus/WindowComplexManager.cc index 743972b9beb..d07c6b6426e 100644 --- a/src/EnergyPlus/WindowComplexManager.cc +++ b/src/EnergyPlus/WindowComplexManager.cc @@ -374,23 +374,23 @@ namespace WindowComplexManager { NBkSurf = state.dataBSDFWindow->ComplexWind(iSurf).NBkSurf; state.dataBSDFWindow->ComplexWind(iSurf).Geom(iState).SolBmGndWt.allocate( - 24, state.dataGlobal->NumOfTimeStepInHour, state.dataBSDFWindow->ComplexWind(iSurf).Geom(iState).NGnd); - state.dataBSDFWindow->ComplexWind(iSurf).Geom(iState).SolBmIndex.allocate(24, state.dataGlobal->NumOfTimeStepInHour); - state.dataBSDFWindow->ComplexWind(iSurf).Geom(iState).ThetaBm.allocate(24, state.dataGlobal->NumOfTimeStepInHour); - state.dataBSDFWindow->ComplexWind(iSurf).Geom(iState).PhiBm.allocate(24, state.dataGlobal->NumOfTimeStepInHour); - state.dataSurface->SurfaceWindow(iSurf).ComplexFen.State(iState).WinDirHemiTrans.allocate(24, state.dataGlobal->NumOfTimeStepInHour); - state.dataSurface->SurfaceWindow(iSurf).ComplexFen.State(iState).WinDirSpecTrans.allocate(24, state.dataGlobal->NumOfTimeStepInHour); - state.dataSurface->SurfaceWindow(iSurf).ComplexFen.State(iState).WinBmGndTrans.allocate(24, state.dataGlobal->NumOfTimeStepInHour); - state.dataSurface->SurfaceWindow(iSurf).ComplexFen.State(iState).WinBmFtAbs.allocate(24, state.dataGlobal->NumOfTimeStepInHour, NLayers); - state.dataSurface->SurfaceWindow(iSurf).ComplexFen.State(iState).WinBmGndAbs.allocate(24, state.dataGlobal->NumOfTimeStepInHour, NLayers); + 24, state.dataGlobal->TimeStepsInHour, state.dataBSDFWindow->ComplexWind(iSurf).Geom(iState).NGnd); + state.dataBSDFWindow->ComplexWind(iSurf).Geom(iState).SolBmIndex.allocate(24, state.dataGlobal->TimeStepsInHour); + state.dataBSDFWindow->ComplexWind(iSurf).Geom(iState).ThetaBm.allocate(24, state.dataGlobal->TimeStepsInHour); + state.dataBSDFWindow->ComplexWind(iSurf).Geom(iState).PhiBm.allocate(24, state.dataGlobal->TimeStepsInHour); + state.dataSurface->SurfaceWindow(iSurf).ComplexFen.State(iState).WinDirHemiTrans.allocate(24, state.dataGlobal->TimeStepsInHour); + state.dataSurface->SurfaceWindow(iSurf).ComplexFen.State(iState).WinDirSpecTrans.allocate(24, state.dataGlobal->TimeStepsInHour); + state.dataSurface->SurfaceWindow(iSurf).ComplexFen.State(iState).WinBmGndTrans.allocate(24, state.dataGlobal->TimeStepsInHour); + state.dataSurface->SurfaceWindow(iSurf).ComplexFen.State(iState).WinBmFtAbs.allocate(24, state.dataGlobal->TimeStepsInHour, NLayers); + state.dataSurface->SurfaceWindow(iSurf).ComplexFen.State(iState).WinBmGndAbs.allocate(24, state.dataGlobal->TimeStepsInHour, NLayers); state.dataSurface->SurfaceWindow(iSurf).ComplexFen.State(iState).WinToSurfBmTrans.allocate( - 24, state.dataGlobal->NumOfTimeStepInHour, NBkSurf); + 24, state.dataGlobal->TimeStepsInHour, NBkSurf); state.dataSurface->SurfaceWindow(iSurf).ComplexFen.State(iState).BkSurf.allocate(NBkSurf); for (KBkSurf = 1; KBkSurf <= NBkSurf; ++KBkSurf) { state.dataSurface->SurfaceWindow(iSurf).ComplexFen.State(iState).BkSurf(KBkSurf).WinDHBkRefl.allocate( - 24, state.dataGlobal->NumOfTimeStepInHour); + 24, state.dataGlobal->TimeStepsInHour); state.dataSurface->SurfaceWindow(iSurf).ComplexFen.State(iState).BkSurf(KBkSurf).WinDirBkAbs.allocate( - 24, state.dataGlobal->NumOfTimeStepInHour, NLayers); + 24, state.dataGlobal->TimeStepsInHour, NLayers); } } @@ -596,7 +596,7 @@ namespace WindowComplexManager { std::size_t lHT(0); // Linear index for ( Hour, TS ) std::size_t lHTI(0); // Linear index for ( Hour, TS, I ) for (int Hour = 1; Hour <= 24; ++Hour) { - for (int TS = 1; TS <= state.dataGlobal->NumOfTimeStepInHour; ++TS, ++lHT) { // [ lHT ] == ( Hour, TS ) + for (int TS = 1; TS <= state.dataGlobal->TimeStepsInHour; ++TS, ++lHT) { // [ lHT ] == ( Hour, TS ) SunDir = state.dataBSDFWindow->SUNCOSTS(TS, Hour); Theta = 0.0; Phi = 0.0; @@ -1012,7 +1012,7 @@ namespace WindowComplexManager { NPhis(1) = 1; NumElem = 1; for (I = 2; I <= NThetas; ++I) { - Thetas(I) = state.dataConstruction->Construct(IConst).BSDFInput.BasisMat(1, I) * Constant::DegToRadians; + Thetas(I) = state.dataConstruction->Construct(IConst).BSDFInput.BasisMat(1, I) * Constant::DegToRad; NPhis(I) = std::floor(state.dataConstruction->Construct(IConst).BSDFInput.BasisMat(2, I) + 0.001); if (NPhis(I) <= 0) ShowFatalError(state, "WindowComplexManager: incorrect input, no. phis must be positive."); NumElem += NPhis(I); @@ -1087,7 +1087,7 @@ namespace WindowComplexManager { NPhis = 1; // As insurance, define one phi for each theta NumElem = 1; for (I = 2; I <= NThetas; ++I) { - Thetas(I) = state.dataConstruction->Construct(IConst).BSDFInput.BasisMat(1, I) * Constant::DegToRadians; + Thetas(I) = state.dataConstruction->Construct(IConst).BSDFInput.BasisMat(1, I) * Constant::DegToRad; ++NumElem; } Basis.Phis.allocate(1, NThetas); @@ -1296,8 +1296,8 @@ namespace WindowComplexManager { // Define the central ray directions (in world coordinate system) state.dataSurface->SurfaceWindow(ISurf).ComplexFen.State(IState).NLayers = state.dataConstruction->Construct(IConst).BSDFInput.NumLayers; - Azimuth = Constant::DegToRadians * state.dataSurface->Surface(ISurf).Azimuth; - Tilt = Constant::DegToRadians * state.dataSurface->Surface(ISurf).Tilt; + Azimuth = Constant::DegToRad * state.dataSurface->Surface(ISurf).Azimuth; + Tilt = Constant::DegToRad * state.dataSurface->Surface(ISurf).Tilt; // For incoming grid @@ -1386,7 +1386,7 @@ namespace WindowComplexManager { V = HitPt - state.dataSurface->Surface(ISurf).Centroid; // vector array from window ctr to hit pt LeastHitDsq = magnitude_squared(V); // dist^2 window ctr to hit pt TmpHSurfDSq(1, NReflSurf) = LeastHitDsq; - if (!state.dataSurface->Surface(JSurf).HeatTransSurf && state.dataSurface->Surface(JSurf).SchedShadowSurfIndex != 0) { + if (!state.dataSurface->Surface(JSurf).HeatTransSurf && state.dataSurface->Surface(JSurf).shadowSurfSched != nullptr) { TransRSurf = 1.0; // If a shadowing surface may have a scheduled transmittance, // treat it here as completely transparent } else { @@ -1405,7 +1405,7 @@ namespace WindowComplexManager { break; } } - if (!state.dataSurface->Surface(JSurf).HeatTransSurf && state.dataSurface->Surface(JSurf).SchedShadowSurfIndex == 0) { + if (!state.dataSurface->Surface(JSurf).HeatTransSurf && state.dataSurface->Surface(JSurf).shadowSurfSched == nullptr) { // The new hit is opaque, so we can drop all the hits further away TmpHSurfNo(J, NReflSurf) = JSurf; TmpHitPt(J, NReflSurf) = HitPt; @@ -1433,7 +1433,7 @@ namespace WindowComplexManager { // A new closest hit. If it is opaque, drop the current hit list, // otherwise add it at the front LeastHitDsq = HitDsq; - if (!state.dataSurface->Surface(JSurf).HeatTransSurf && state.dataSurface->Surface(JSurf).SchedShadowSurfIndex != 0) { + if (!state.dataSurface->Surface(JSurf).HeatTransSurf && state.dataSurface->Surface(JSurf).shadowSurfSched != nullptr) { TransRSurf = 1.0; // New closest hit is transparent, keep the existing hit list for (I = TotHits; I >= 1; --I) { TmpHSurfNo(I + 1, NReflSurf) = TmpHSurfNo(I, NReflSurf); @@ -1898,13 +1898,13 @@ namespace WindowComplexManager { if (Sum2 > 0.0) { Hold = Sum1 / Sum2; for (I = 1; I <= 24; ++I) { - for (J = 1; J <= state.dataGlobal->NumOfTimeStepInHour; ++J) { + for (J = 1; J <= state.dataGlobal->TimeStepsInHour; ++J) { State.BkSurf(KBkSurf).WinDHBkRefl(I, J) = Hold; } } } else { for (I = 1; I <= 24; ++I) { - for (J = 1; J <= state.dataGlobal->NumOfTimeStepInHour; ++J) { + for (J = 1; J <= state.dataGlobal->TimeStepsInHour; ++J) { State.BkSurf(KBkSurf).WinDHBkRefl(I, J) = 0.0; } } @@ -1922,13 +1922,13 @@ namespace WindowComplexManager { if (Sum2 > 0.0) { Hold = Sum1 / Sum2; for (I = 1; I <= 24; ++I) { - for (J = 1; J <= state.dataGlobal->NumOfTimeStepInHour; ++J) { + for (J = 1; J <= state.dataGlobal->TimeStepsInHour; ++J) { State.BkSurf(KBkSurf).WinDirBkAbs(I, J, L) = Hold; } } } else { for (I = 1; I <= 24; ++I) { - for (J = 1; J <= state.dataGlobal->NumOfTimeStepInHour; ++J) { + for (J = 1; J <= state.dataGlobal->TimeStepsInHour; ++J) { State.BkSurf(KBkSurf).WinDirBkAbs(I, J, L) = 0.0; } } @@ -2241,8 +2241,8 @@ namespace WindowComplexManager { } // get window tilt and azimuth - Gamma = Constant::DegToRadians * state.dataSurface->Surface(ISurf).Tilt; - Alpha = Constant::DegToRadians * state.dataSurface->Surface(ISurf).Azimuth; + Gamma = Constant::DegToRad * state.dataSurface->Surface(ISurf).Tilt; + Alpha = Constant::DegToRad * state.dataSurface->Surface(ISurf).Azimuth; // get the corresponding local Theta, Phi for ray W6CoordsFromWorldVect(state, RayToFind, RadType, Gamma, Alpha, Theta, Phi); @@ -2488,7 +2488,6 @@ namespace WindowComplexManager { using namespace DataBSDFWindow; using Psychrometrics::PsyCpAirFnW; using Psychrometrics::PsyTdpFnWPb; - using ScheduleManager::GetCurrentScheduleValue; using TARCOGGassesParams::maxgas; using TARCOGMain::TARCOG90; using TARCOGParams::maxlay; diff --git a/src/EnergyPlus/WindowComplexManager.hh b/src/EnergyPlus/WindowComplexManager.hh index 6206b11f336..05f4dbcfd6b 100644 --- a/src/EnergyPlus/WindowComplexManager.hh +++ b/src/EnergyPlus/WindowComplexManager.hh @@ -375,6 +375,10 @@ struct WindowComplexManagerData : BaseGlobalStruct Array1D_int iMinDT = Array1D_int(1, 0); Array1D_int IDConst = Array1D_int(100, 0); + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/WindowEquivalentLayer.cc b/src/EnergyPlus/WindowEquivalentLayer.cc index d3a37c13004..43141a498e1 100644 --- a/src/EnergyPlus/WindowEquivalentLayer.cc +++ b/src/EnergyPlus/WindowEquivalentLayer.cc @@ -123,7 +123,7 @@ namespace EnergyPlus::WindowEquivalentLayer { using namespace DataHeatBalance; using namespace DataSurfaces; -constexpr std::array orientationNamesUC = {"HORIZONTAL", "VERTICAL"}; +// constexpr std::array orientationNamesUC = {"HORIZONTAL", "VERTICAL"}; void InitEquivalentLayerWindowCalculations(EnergyPlusData &state) { @@ -707,7 +707,6 @@ void EQLWindowSurfaceHeatBalance(EnergyPlusData &state, using Psychrometrics::PsyCpAirFnW; using Psychrometrics::PsyTdpFnWPb; - using ScheduleManager::GetCurrentScheduleValue; Real64 constexpr TOL(0.0001); // convergence tolerance @@ -1135,7 +1134,7 @@ void RB_BEAM(EnergyPlusData &state, Real64 TAUBB_EXPO; // exponent in the beam-beam transmittance model Real64 TAU_BT; // beam-total transmittance - THETA = min(89.99 * Constant::DegToRadians, xTHETA); + THETA = min(89.99 * Constant::DegToRad, xTHETA); if (TAU_BB0 > 0.9999) { TAU_BB = 1.0; @@ -1151,7 +1150,7 @@ void RB_BEAM(EnergyPlusData &state, TAU_BT = TAU_BT0 * std::pow(std::cos(THETA), TAUBT_EXPO); // always 0 - 1 Real64 const cos_TAU_BB0(std::cos(TAU_BB0 * Constant::PiOvr2)); - THETA_CUTOFF = Constant::DegToRadians * (90.0 - 25.0 * cos_TAU_BB0); + THETA_CUTOFF = Constant::DegToRad * (90.0 - 25.0 * cos_TAU_BB0); if (THETA >= THETA_CUTOFF) { TAU_BB = 0.0; } else { @@ -1290,7 +1289,7 @@ void IS_BEAM(EnergyPlusData &state, Real64 RHO_BT90; // beam-total reflectance at 90 deg incidence Real64 TAU_BT; // beam-total transmittance - Real64 const THETA(min(89.99 * Constant::DegToRadians, xTHETA)); // working incident angle, radians + Real64 const THETA(min(89.99 * Constant::DegToRad, xTHETA)); // working incident angle, radians Real64 const COSTHETA(std::cos(THETA)); RHO_W = RHO_BT0 / max(0.00001, 1.0 - TAU_BB0); @@ -1481,7 +1480,7 @@ void FM_BEAM(EnergyPlusData &state, Real64 RHO_BT90; // beam-total reflectance at 90 deg incidence Real64 TAU_BT; // beam-total transmittance - THETA = std::abs(max(-89.99 * Constant::DegToRadians, min(89.99 * Constant::DegToRadians, xTHETA))); + THETA = std::abs(max(-89.99 * Constant::DegToRad, min(89.99 * Constant::DegToRad, xTHETA))); // limit -89.99 - +89.99 // by symmetry, optical properties same at +/- theta Real64 const COSTHETA(std::cos(THETA)); @@ -1773,8 +1772,8 @@ void PD_BEAM(EnergyPlusData &state, Real64 TAUBF_BB_PERP; Real64 TAUBF_BD_PERP; - OMEGA_V = std::abs(max(-89.5 * Constant::DegToRadians, min(89.5 * Constant::DegToRadians, OHM_V_RAD))); - OMEGA_H = std::abs(max(-89.5 * Constant::DegToRadians, min(89.5 * Constant::DegToRadians, OHM_H_RAD))); + OMEGA_V = std::abs(max(-89.5 * Constant::DegToRad, min(89.5 * Constant::DegToRad, OHM_V_RAD))); + OMEGA_H = std::abs(max(-89.5 * Constant::DegToRad, min(89.5 * Constant::DegToRad, OHM_H_RAD))); // limit profile angles -89.5 - +89.5 // by symmetry, properties same for +/- profile angle @@ -3806,9 +3805,9 @@ void VB_SOL46_CURVE(EnergyPlusData &state, CORR = 1; // limit slat angle to +/- 90 deg - PHI = max(-Constant::DegToRadians * 90.0, min(Constant::DegToRadians * 90.0, PHIx)); + PHI = max(-Constant::DegToRad * 90.0, min(Constant::DegToRad * 90.0, PHIx)); // limit profile angle to +/- 89.5 deg - OMEGA = max(-Constant::DegToRadians * 89.5, min(Constant::DegToRadians * 89.5, OMEGAx)); + OMEGA = max(-Constant::DegToRad * 89.5, min(Constant::DegToRad * 89.5, OMEGAx)); SL_RAD = W / max(SL_WR, 0.0000001); SL_THETA = 2.0 * std::asin(0.5 * SL_WR); @@ -5919,7 +5918,7 @@ Real64 FRA(Real64 const TM, // mean gas temp, K CP = ACP + BCP * TM + BCP * TM * TM; VISC = AVISC + BVISC * TM + BVISC * TM * TM; - FRA = (Constant::GravityConstant * RHOGAS * RHOGAS * DT * T * T * T * CP) / (VISC * K * TM * Z * Z); + FRA = (Constant::Gravity * RHOGAS * RHOGAS * DT * T * T * T * CP) / (VISC * K * TM * Z * Z); return FRA; } @@ -6826,11 +6825,11 @@ bool Specular_OffNormal(Real64 const THETA, // solar beam angle of incidence, fr Specular_OffNormal = true; THETA1 = std::abs(THETA); - if (THETA1 > Constant::PiOvr2 - Constant::DegToRadians) { + if (THETA1 > Constant::PiOvr2 - Constant::DegToRad) { // theta > 89 deg RAT_TAU = 0.0; RAT_1MR = 0.0; - } else if (THETA1 >= Constant::DegToRadians) { + } else if (THETA1 >= Constant::DegToRad) { // theta >= 1 deg N2 = 1.526; KL = 55.0 * 0.006; @@ -7391,10 +7390,10 @@ bool VB_LWP(EnergyPlusData &state, RHOUFS_SLAT = 1.0 - L.LWP_MAT.EPSLF - L.LWP_MAT.TAUL; // upward surface // TODO: are there cases where 2 calls not needed (RHODFS_SLAT == RHOUFS_SLAT??) - VB_DIFF(state, L.S, L.W, Constant::DegToRadians * L.PHI_DEG, RHODFS_SLAT, RHOUFS_SLAT, L.LWP_MAT.TAUL, RHOLF, LLWP.TAUL); + VB_DIFF(state, L.S, L.W, Constant::DegToRad * L.PHI_DEG, RHODFS_SLAT, RHOUFS_SLAT, L.LWP_MAT.TAUL, RHOLF, LLWP.TAUL); LLWP.EPSLF = 1.0 - RHOLF - LLWP.TAUL; - VB_DIFF(state, L.S, L.W, -Constant::DegToRadians * L.PHI_DEG, RHODFS_SLAT, RHOUFS_SLAT, L.LWP_MAT.TAUL, RHOLB, TAULX); + VB_DIFF(state, L.S, L.W, -Constant::DegToRad * L.PHI_DEG, RHODFS_SLAT, RHOUFS_SLAT, L.LWP_MAT.TAUL, RHOLB, TAULX); LLWP.EPSLB = 1.0 - RHOLB - LLWP.TAUL; VB_LWP = true; @@ -7429,7 +7428,7 @@ bool VB_SWP(EnergyPlusData &state, L.S, L.W, SL_WR, - Constant::DegToRadians * L.PHI_DEG, + Constant::DegToRad * L.PHI_DEG, OMEGA, L.SWP_MAT.RHOSBDD, L.SWP_MAT.RHOSFDD, @@ -7442,7 +7441,7 @@ bool VB_SWP(EnergyPlusData &state, L.S, L.W, SL_WR, - -Constant::DegToRadians * L.PHI_DEG, + -Constant::DegToRad * L.PHI_DEG, OMEGA, L.SWP_MAT.RHOSBDD, L.SWP_MAT.RHOSFDD, @@ -7479,9 +7478,9 @@ bool VB_SWP(EnergyPlusData &state, SL_WR = VB_SLAT_RADIUS_RATIO(L.W, L.C); - VB_DIFF(state, L.S, L.W, Constant::DegToRadians * L.PHI_DEG, L.SWP_MAT.RHOSBDD, L.SWP_MAT.RHOSFDD, L.SWP_MAT.TAUS_DD, LSWP.RHOSFDD, LSWP.TAUS_DD); + VB_DIFF(state, L.S, L.W, Constant::DegToRad * L.PHI_DEG, L.SWP_MAT.RHOSBDD, L.SWP_MAT.RHOSFDD, L.SWP_MAT.TAUS_DD, LSWP.RHOSFDD, LSWP.TAUS_DD); - VB_DIFF(state, L.S, L.W, -Constant::DegToRadians * L.PHI_DEG, L.SWP_MAT.RHOSBDD, L.SWP_MAT.RHOSFDD, L.SWP_MAT.TAUS_DD, LSWP.RHOSBDD, TAUX); + VB_DIFF(state, L.S, L.W, -Constant::DegToRad * L.PHI_DEG, L.SWP_MAT.RHOSBDD, L.SWP_MAT.RHOSFDD, L.SWP_MAT.TAUS_DD, LSWP.RHOSBDD, TAUX); return true; } @@ -8342,7 +8341,7 @@ Real64 HCInWindowStandardRatings(EnergyPlusData &state, Real64 Nuint; // Nusselt number for interior surface convection TiltDeg = 90.0; - sineTilt = std::sin(TiltDeg * Constant::DegToRadians); // degrees as arg + sineTilt = std::sin(TiltDeg * Constant::DegToRad); // degrees as arg // Begin calculating for ISO 15099 method. // mean film temperature @@ -8355,7 +8354,7 @@ Real64 HCInWindowStandardRatings(EnergyPlusData &state, mu = 3.723E-6 + 4.94E-8 * TmeanFilmKelvin; // Table B.2 in ISO 15099 Cp = 1002.737 + 1.2324E-2 * TmeanFilmKelvin; // Table B.3 in ISO 15099 - RaH = (pow_2(rho) * pow_3(Height) * Constant::GravityConstant * Cp * std::abs(TSurfIn - TAirIn)) / + RaH = (pow_2(rho) * pow_3(Height) * Constant::Gravity * Cp * std::abs(TSurfIn - TAirIn)) / (TmeanFilmKelvin * mu * lambda); // eq 132 in ISO 15099 // eq. 135 in ISO 15099 (only need this one because tilt is 90 deg) diff --git a/src/EnergyPlus/WindowEquivalentLayer.hh b/src/EnergyPlus/WindowEquivalentLayer.hh index 04bd2232e4c..41477c45f82 100644 --- a/src/EnergyPlus/WindowEquivalentLayer.hh +++ b/src/EnergyPlus/WindowEquivalentLayer.hh @@ -818,6 +818,10 @@ struct WindowEquivalentLayerData : BaseGlobalStruct Real64 X1MRDiff = -1.0; Real64 XTAUDiff = -1.0; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/WindowManager.cc b/src/EnergyPlus/WindowManager.cc index 67875d0a3ed..5697383caf0 100644 --- a/src/EnergyPlus/WindowManager.cc +++ b/src/EnergyPlus/WindowManager.cc @@ -367,7 +367,7 @@ namespace Window { // handling of optical properties for (int IPhi = 1; IPhi <= 10; ++IPhi) { - CosPhiIndepVar(IPhi) = std::cos((IPhi - 1) * 10.0 * Constant::DegToRadians); + CosPhiIndepVar(IPhi) = std::cos((IPhi - 1) * 10.0 * Constant::DegToRad); } TotLay = thisConstruct.TotLayers; @@ -663,7 +663,7 @@ namespace Window { for (int IPhi = 1; IPhi <= TotalIPhi; ++IPhi) { // 10 degree increment for incident angle is only value for a construction without a layer = SpectralAndAngle Phi = double(IPhi - 1) * 10.0; - CosPhi = std::cos(Phi * Constant::DegToRadians); + CosPhi = std::cos(Phi * Constant::DegToRad); if (std::abs(CosPhi) < 0.0001) CosPhi = 0.0; // For each wavelength, get glass layer properties at this angle of incidence @@ -863,7 +863,7 @@ namespace Window { // When a construction has a layer = SpectralAndAngle, the 10 degree increment will be overridden. for (int IPhi = 1; IPhi <= TotalIPhi; ++IPhi) { Phi = double(IPhi - 1) * 10.0; - CosPhi = std::cos(Phi * Constant::DegToRadians); + CosPhi = std::cos(Phi * Constant::DegToRad); if (std::abs(CosPhi) < 0.0001) CosPhi = 0.0; // For each wavelength, get glass layer properties at this angle of incidence @@ -1467,7 +1467,7 @@ namespace Window { tvisPhiFit(IPhi) = 0.0; Phi = double(IPhi - 1) * 10.0; - CosPhi = std::cos(Phi * Constant::DegToRadians); + CosPhi = std::cos(Phi * Constant::DegToRad); if (std::abs(CosPhi) < 0.0001) CosPhi = 0.0; Real64 cos_pow(1.0); for (int CoefNum = 1; CoefNum <= 6; ++CoefNum) { @@ -2069,7 +2069,6 @@ namespace Window { using Psychrometrics::PsyCpAirFnW; using Psychrometrics::PsyTdpFnWPb; // unused0909 USE DataEnvironment, ONLY: CurMnDyHr - using ScheduleManager::GetCurrentScheduleValue; using WindowComplexManager::CalcComplexWindowThermal; using WindowEquivalentLayer::EQLWindowSurfaceHeatBalance; @@ -2207,7 +2206,7 @@ namespace Window { wm->nglface = 2 * wm->ngllayer; ShadeFlag = s_surf->SurfWinShadingFlag(SurfNum); wm->tilt = surf.Tilt; - wm->tiltr = wm->tilt * Constant::DegToRadians; + wm->tiltr = wm->tilt * Constant::DegToRad; SurfNumAdj = surf.ExtBoundCond; wm->hcin = state.dataHeatBalSurf->SurfHConvInt(SurfNum); // Room-side surface convective film conductance Real64 RefAirTemp = s_surf->Surface(SurfNum).getInsideAirTemperature(state, SurfNum); @@ -4095,9 +4094,6 @@ namespace Window { // Based on ISO/DIS 15099, "Thermal Performance of Windows, Doors and Shading Devices -- // Detailed Calculations" - // Using/Aliasing - using ScheduleManager::GetCurrentScheduleValue; - // Locals // SUBROUTINE ARGUMENT DEFINITIONS: // air flow or bottom for downward air flow (K) @@ -4900,7 +4896,7 @@ namespace Window { asp = 1.524 / wm->gaps[IGap - 1].width; } - wm->tiltr = wm->tilt * Constant::DegToRadians; + wm->tiltr = wm->tilt * Constant::DegToRad; ra = gr * pr; //! fw if (ra > 2.0e6): error that outside range of Rayleigh number? @@ -5707,7 +5703,7 @@ namespace Window { // SUBROUTINE ARGUMENT DEFINITIONS: // 0,10,20,...,80,90 degress - Real64 const DPhiR(10.0 * Constant::DegToRadians); // Half of 10-deg incidence angle increment (radians) + Real64 const DPhiR(10.0 * Constant::DegToRad); // Half of 10-deg incidence angle increment (radians) DiffuseAverage = 0.0; for (int IPhi = 1; IPhi <= 9; ++IPhi) { @@ -6622,7 +6618,7 @@ namespace Window { TiltDeg = 90.0; - sineTilt = std::sin(TiltDeg * Constant::DegToRadians); // degrees as arg + sineTilt = std::sin(TiltDeg * Constant::DegToRad); // degrees as arg while (iter < MaxIterations && errtemp > errtemptol) { for (int i = 1; i <= wm->nglface; ++i) { @@ -7514,14 +7510,14 @@ namespace Window { relativeAltitude.allocate(N, M); for (int j = 0; j <= N - 1; ++j) { - Real64 currAzimuth = (90.0 / N) * j * Constant::DegToRadians; + Real64 currAzimuth = (90.0 / N) * j * Constant::DegToRad; sunAzimuth.push_back(currAzimuth); // Azimuth angle of sun during integration sin_sunAzimuth.push_back(std::sin(currAzimuth)); cos_sunAzimuth.push_back(std::cos(currAzimuth)); } for (int i = 0; i <= M - 1; ++i) { - Real64 currAltitude = (90.0 / M) * i * Constant::DegToRadians; + Real64 currAltitude = (90.0 / M) * i * Constant::DegToRad; sunAltitude.push_back(currAltitude); // Altitude angle of sun during integration sin_sunAltitude.push_back(std::sin(currAltitude)); cos_sunAltitude.push_back(std::cos(currAltitude)); diff --git a/src/EnergyPlus/WindowManager.hh b/src/EnergyPlus/WindowManager.hh index 23936c62ea8..3b8338d4736 100644 --- a/src/EnergyPlus/WindowManager.hh +++ b/src/EnergyPlus/WindowManager.hh @@ -525,6 +525,10 @@ struct WindowManagerData : BaseGlobalStruct std::array LayerNum = {0}; // Glass layer number + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/WindowManagerExteriorData.cc b/src/EnergyPlus/WindowManagerExteriorData.cc index b40bd35e9e8..05b87b727a1 100644 --- a/src/EnergyPlus/WindowManagerExteriorData.cc +++ b/src/EnergyPlus/WindowManagerExteriorData.cc @@ -82,8 +82,8 @@ namespace Window { Real64 Phi = 0; // get window tilt and azimuth - Real64 Gamma = Constant::DegToRadians * state.dataSurface->Surface(t_SurfNum).Tilt; - Real64 Alpha = Constant::DegToRadians * state.dataSurface->Surface(t_SurfNum).Azimuth; + Real64 Gamma = Constant::DegToRad * state.dataSurface->Surface(t_SurfNum).Tilt; + Real64 Alpha = Constant::DegToRad * state.dataSurface->Surface(t_SurfNum).Azimuth; RayIdentificationType RadType = RayIdentificationType::Front_Incident; diff --git a/src/EnergyPlus/WindowManagerExteriorData.hh b/src/EnergyPlus/WindowManagerExteriorData.hh index 33bef56946f..35446e52367 100644 --- a/src/EnergyPlus/WindowManagerExteriorData.hh +++ b/src/EnergyPlus/WindowManagerExteriorData.hh @@ -166,6 +166,10 @@ struct WindowManagerExteriorData : BaseGlobalStruct { std::unique_ptr p_inst; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/WindowManagerExteriorThermal.cc b/src/EnergyPlus/WindowManagerExteriorThermal.cc index d4b1883ff26..ce57bd55b95 100644 --- a/src/EnergyPlus/WindowManagerExteriorThermal.cc +++ b/src/EnergyPlus/WindowManagerExteriorThermal.cc @@ -551,7 +551,7 @@ namespace Window { conductivity = matGlass->Conductivity; } else if (mat->group == Material::Group::Blind) { - auto const &surfShade = state.dataSurface->surfShades(m_SurfNum); + // auto const &surfShade = state.dataSurface->surfShades(m_SurfNum); auto const *matBlind = dynamic_cast(mat); assert(matBlind != nullptr); thickness = matBlind->SlatThickness; diff --git a/src/EnergyPlus/ZoneAirLoopEquipmentManager.hh b/src/EnergyPlus/ZoneAirLoopEquipmentManager.hh index fdedd91da9d..715fe854766 100644 --- a/src/EnergyPlus/ZoneAirLoopEquipmentManager.hh +++ b/src/EnergyPlus/ZoneAirLoopEquipmentManager.hh @@ -93,6 +93,10 @@ struct ZoneAirLoopEquipmentManagerData : BaseGlobalStruct bool InitAirDistUnitsFlag = true; // If TRUE, not all Air Distribution Units have been initialized int numADUInitialized = 0; // Count of ADUs that have been initialized + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/ZoneContaminantPredictorCorrector.cc b/src/EnergyPlus/ZoneContaminantPredictorCorrector.cc index 32863ffb574..bdc3c0df6b5 100644 --- a/src/EnergyPlus/ZoneContaminantPredictorCorrector.cc +++ b/src/EnergyPlus/ZoneContaminantPredictorCorrector.cc @@ -163,12 +163,11 @@ void GetZoneContaminanInputs(EnergyPlusData &state) // SUBROUTINE PARAMETER DEFINITIONS: static constexpr std::string_view RoutineName("GetSourcesAndSinks: "); + static constexpr std::string_view routineName = "GetSourcesAndSinks"; // SUBROUTINE LOCAL VARIABLE DECLARATIONS: Array1D_string AlphaName; Array1D IHGNumbers; - Real64 SchMin; - Real64 SchMax; int IOStat; int Loop; int ZonePtr; @@ -234,12 +233,16 @@ void GetZoneContaminanInputs(EnergyPlusData &state) state.dataIPShortCut->lAlphaFieldBlanks, state.dataIPShortCut->cAlphaFieldNames, state.dataIPShortCut->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, CurrentModuleObject, AlphaName(1)}; + Util::IsNameEmpty(state, AlphaName(1), CurrentModuleObject, ErrorsFound); - state.dataContaminantBalance->ZoneContamGenericConstant(Loop).Name = AlphaName(1); - state.dataContaminantBalance->ZoneContamGenericConstant(Loop).ZoneName = AlphaName(2); - state.dataContaminantBalance->ZoneContamGenericConstant(Loop).ActualZoneNum = Util::FindItemInList(AlphaName(2), state.dataHeatBal->Zone); - if (state.dataContaminantBalance->ZoneContamGenericConstant(Loop).ActualZoneNum == 0) { + auto &contam = state.dataContaminantBalance->ZoneContamGenericConstant(Loop); + contam.Name = AlphaName(1); + contam.ZoneName = AlphaName(2); + contam.ActualZoneNum = Util::FindItemInList(AlphaName(2), state.dataHeatBal->Zone); + if (contam.ActualZoneNum == 0) { ShowSevereError(state, format("{}{}=\"{}\", invalid {} entered={}", RoutineName, @@ -250,112 +253,44 @@ void GetZoneContaminanInputs(EnergyPlusData &state) ErrorsFound = true; } - state.dataContaminantBalance->ZoneContamGenericConstant(Loop).GCGenerateRateSchedPtr = ScheduleManager::GetScheduleIndex(state, AlphaName(3)); - if (state.dataContaminantBalance->ZoneContamGenericConstant(Loop).GCGenerateRateSchedPtr == 0) { - if (state.dataIPShortCut->lAlphaFieldBlanks(3)) { - ShowSevereError( - state, - format( - "{}{}=\"{}\", {} is required.", RoutineName, CurrentModuleObject, AlphaName(1), state.dataIPShortCut->cAlphaFieldNames(3))); - } else { - ShowSevereError(state, - format("{}{}=\"{}\", invalid {} entered={}", - RoutineName, - CurrentModuleObject, - AlphaName(1), - state.dataIPShortCut->cAlphaFieldNames(3), - AlphaName(3))); - } + if (state.dataIPShortCut->lAlphaFieldBlanks(3)) { + ShowSevereEmptyField(state, eoh, state.dataIPShortCut->cAlphaFieldNames(3)); + ErrorsFound = true; + } else if ((contam.generateRateSched = Sched::GetSchedule(state, AlphaName(3))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(3), AlphaName(3)); + ErrorsFound = true; + } else if (!contam.generateRateSched->checkMinVal(state, Clusive::In, 0.0)) { + Sched::ShowSevereBadMin(state, eoh, state.dataIPShortCut->cAlphaFieldNames(3), AlphaName(3), Clusive::In, 0.0); ErrorsFound = true; - } else { // check min/max on schedule - SchMin = - ScheduleManager::GetScheduleMinValue(state, state.dataContaminantBalance->ZoneContamGenericConstant(Loop).GCGenerateRateSchedPtr); - SchMax = - ScheduleManager::GetScheduleMaxValue(state, state.dataContaminantBalance->ZoneContamGenericConstant(Loop).GCGenerateRateSchedPtr); - if (SchMin < 0.0 || SchMax < 0.0) { - if (SchMin < 0.0) { - ShowSevereError(state, - format("{}{}=\"{}\", {}, minimum is < 0.0", - RoutineName, - CurrentModuleObject, - AlphaName(1), - state.dataIPShortCut->cAlphaFieldNames(3))); - ShowContinueError(state, format("Schedule=\"{}\". Minimum is [{:.1R}]. Values must be >= 0.0.", AlphaName(3), SchMin)); - ErrorsFound = true; - } - if (SchMax < 0.0) { - ShowSevereError(state, - format("{}{}=\"{}\", {}, maximum is < 0.0", - RoutineName, - CurrentModuleObject, - AlphaName(1), - state.dataIPShortCut->cAlphaFieldNames(3))); - ShowContinueError(state, format("Schedule=\"{}\". Maximum is [{:.1R}]. Values must be >= 0.0.", AlphaName(3), SchMax)); - ErrorsFound = true; - } - } } - state.dataContaminantBalance->ZoneContamGenericConstant(Loop).GCGenerateRate = IHGNumbers(1); - state.dataContaminantBalance->ZoneContamGenericConstant(Loop).GCRemovalCoef = IHGNumbers(2); + contam.GenerateRate = IHGNumbers(1); + contam.RemovalCoef = IHGNumbers(2); - state.dataContaminantBalance->ZoneContamGenericConstant(Loop).GCRemovalCoefSchedPtr = ScheduleManager::GetScheduleIndex(state, AlphaName(4)); - if (state.dataContaminantBalance->ZoneContamGenericConstant(Loop).GCRemovalCoefSchedPtr == 0) { - if (state.dataIPShortCut->lAlphaFieldBlanks(3)) { - ShowSevereError( - state, - format( - "{}{}=\"{}\", {} is required.", RoutineName, CurrentModuleObject, AlphaName(1), state.dataIPShortCut->cAlphaFieldNames(4))); - } else { - ShowSevereError(state, - format("{}{}=\"{}\", invalid {} entered={}", - RoutineName, - CurrentModuleObject, - AlphaName(1), - state.dataIPShortCut->cAlphaFieldNames(4), - AlphaName(4))); - } + if (state.dataIPShortCut->lAlphaFieldBlanks(4)) { + ShowSevereEmptyField(state, eoh, state.dataIPShortCut->cAlphaFieldNames(4)); + ErrorsFound = true; + } else if ((contam.removalCoefSched = Sched::GetSchedule(state, AlphaName(4))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(4), AlphaName(4)); + ErrorsFound = true; + } else if (!contam.removalCoefSched->checkMinVal(state, Clusive::In, 0.0)) { + Sched::ShowSevereBadMin(state, eoh, state.dataIPShortCut->cAlphaFieldNames(3), AlphaName(3), Clusive::In, 0.0); ErrorsFound = true; - } else { // check min/max on schedule - SchMin = ScheduleManager::GetScheduleMinValue(state, state.dataContaminantBalance->ZoneContamGenericConstant(Loop).GCRemovalCoefSchedPtr); - SchMax = ScheduleManager::GetScheduleMaxValue(state, state.dataContaminantBalance->ZoneContamGenericConstant(Loop).GCRemovalCoefSchedPtr); - if (SchMin < 0.0 || SchMax < 0.0) { - if (SchMin < 0.0) { - ShowSevereError(state, - format("{}{}=\"{}\", {}, minimum is < 0.0", - RoutineName, - CurrentModuleObject, - AlphaName(1), - state.dataIPShortCut->cAlphaFieldNames(4))); - ShowContinueError(state, format("Schedule=\"{}\". Minimum is [{:.1R}]. Values must be >= 0.0.", AlphaName(4), SchMin)); - ErrorsFound = true; - } - if (SchMax < 0.0) { - ShowSevereError(state, - format("{}{}=\"{}\", {}, maximum is < 0.0", - RoutineName, - CurrentModuleObject, - AlphaName(1), - state.dataIPShortCut->cAlphaFieldNames(4))); - ShowContinueError(state, format("Schedule=\"{}\". Maximum is [{:.1R}]. Values must be >= 0.0.", AlphaName(4), SchMax)); - ErrorsFound = true; - } - } } - if (state.dataContaminantBalance->ZoneContamGenericConstant(Loop).ActualZoneNum <= 0) continue; // Error, will be caught and terminated later + if (contam.ActualZoneNum <= 0) continue; // Error, will be caught and terminated later // Object report variables SetupOutputVariable(state, "Generic Air Contaminant Constant Source Generation Volume Flow Rate", Constant::Units::m3_s, - state.dataContaminantBalance->ZoneContamGenericConstant(Loop).GCGenRate, + contam.GenRate, OutputProcessor::TimeStepType::Zone, OutputProcessor::StoreType::Average, - state.dataContaminantBalance->ZoneContamGenericConstant(Loop).Name); + contam.Name); // Zone total report variables - ZonePtr = state.dataContaminantBalance->ZoneContamGenericConstant(Loop).ActualZoneNum; + ZonePtr = contam.ActualZoneNum; if (RepVarSet(ZonePtr)) { RepVarSet(ZonePtr) = false; SetupOutputVariable(state, @@ -368,7 +303,7 @@ void GetZoneContaminanInputs(EnergyPlusData &state) } SetupZoneInternalGain(state, ZonePtr, - state.dataContaminantBalance->ZoneContamGenericConstant(Loop).Name, + contam.Name, DataHeatBalance::IntGainType::ZoneContaminantSourceAndSinkGenericContam, nullptr, nullptr, @@ -376,7 +311,7 @@ void GetZoneContaminanInputs(EnergyPlusData &state) nullptr, nullptr, nullptr, - &state.dataContaminantBalance->ZoneContamGenericConstant(Loop).GCGenRate); + &contam.GenRate); } CurrentModuleObject = "SurfaceContaminantSourceAndSink:Generic:PressureDriven"; @@ -398,13 +333,18 @@ void GetZoneContaminanInputs(EnergyPlusData &state) state.dataIPShortCut->lAlphaFieldBlanks, state.dataIPShortCut->cAlphaFieldNames, state.dataIPShortCut->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, CurrentModuleObject, AlphaName(1)}; + Util::IsNameEmpty(state, AlphaName(1), CurrentModuleObject, ErrorsFound); - state.dataContaminantBalance->ZoneContamGenericPDriven(Loop).Name = AlphaName(1); - state.dataContaminantBalance->ZoneContamGenericPDriven(Loop).SurfName = AlphaName(2); - state.dataContaminantBalance->ZoneContamGenericPDriven(Loop).SurfNum = + auto &contam = state.dataContaminantBalance->ZoneContamGenericPDriven(Loop); + contam.Name = AlphaName(1); + + contam.SurfName = AlphaName(2); + contam.SurfNum = Util::FindItemInList(AlphaName(2), state.afn->MultizoneSurfaceData, &AirflowNetwork::MultizoneSurfaceProp::SurfName); - if (state.dataContaminantBalance->ZoneContamGenericPDriven(Loop).SurfNum == 0) { + if (contam.SurfNum == 0) { ShowSevereError(state, format("{}{}=\"{}\", invalid {} entered={}", RoutineName, @@ -416,9 +356,8 @@ void GetZoneContaminanInputs(EnergyPlusData &state) ErrorsFound = true; } // Ensure external surface - if (state.dataContaminantBalance->ZoneContamGenericPDriven(Loop).SurfNum > 0 && - state.dataSurface->Surface(state.afn->MultizoneSurfaceData(state.dataContaminantBalance->ZoneContamGenericPDriven(Loop).SurfNum).SurfNum) - .ExtBoundCond != DataSurfaces::ExternalEnvironment) { + if (contam.SurfNum > 0 && + state.dataSurface->Surface(state.afn->MultizoneSurfaceData(contam.SurfNum).SurfNum).ExtBoundCond != DataSurfaces::ExternalEnvironment) { ShowSevereError( state, format( @@ -426,51 +365,18 @@ void GetZoneContaminanInputs(EnergyPlusData &state) ErrorsFound = true; } - state.dataContaminantBalance->ZoneContamGenericPDriven(Loop).GCGenRateCoefSchedPtr = ScheduleManager::GetScheduleIndex(state, AlphaName(3)); - if (state.dataContaminantBalance->ZoneContamGenericPDriven(Loop).GCGenRateCoefSchedPtr == 0) { - if (state.dataIPShortCut->lAlphaFieldBlanks(3)) { - ShowSevereError( - state, - format( - "{}{}=\"{}\", {} is required.", RoutineName, CurrentModuleObject, AlphaName(1), state.dataIPShortCut->cAlphaFieldNames(3))); - } else { - ShowSevereError(state, - format("{}{}=\"{}\", invalid {} entered={}", - RoutineName, - CurrentModuleObject, - AlphaName(1), - state.dataIPShortCut->cAlphaFieldNames(3), - AlphaName(3))); - } + if (state.dataIPShortCut->lAlphaFieldBlanks(3)) { + ShowSevereEmptyField(state, eoh, state.dataIPShortCut->cAlphaFieldNames(3)); + ErrorsFound = true; + } else if ((contam.generateRateCoefSched = Sched::GetSchedule(state, AlphaName(3))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(3), AlphaName(3)); + ErrorsFound = true; + } else if (!contam.generateRateCoefSched->checkMinVal(state, Clusive::In, 0.0)) { + Sched::ShowSevereBadMin(state, eoh, state.dataIPShortCut->cAlphaFieldNames(3), AlphaName(3), Clusive::In, 0.0); ErrorsFound = true; - } else { // check min/max on schedule - SchMin = ScheduleManager::GetScheduleMinValue(state, state.dataContaminantBalance->ZoneContamGenericPDriven(Loop).GCGenRateCoefSchedPtr); - SchMax = ScheduleManager::GetScheduleMaxValue(state, state.dataContaminantBalance->ZoneContamGenericPDriven(Loop).GCGenRateCoefSchedPtr); - if (SchMin < 0.0 || SchMax < 0.0) { - if (SchMin < 0.0) { - ShowSevereError(state, - format("{}{}=\"{}\", {}, minimum is < 0.0", - RoutineName, - CurrentModuleObject, - AlphaName(1), - state.dataIPShortCut->cAlphaFieldNames(3))); - ShowContinueError(state, format("Schedule=\"{}\". Minimum is [{:.1R}]. Values must be >= 0.0.", AlphaName(3), SchMin)); - ErrorsFound = true; - } - if (SchMax < 0.0) { - ShowSevereError(state, - format("{}{}=\"{}\", {}, maximum is < 0.0", - RoutineName, - CurrentModuleObject, - AlphaName(1), - state.dataIPShortCut->cAlphaFieldNames(3))); - ShowContinueError(state, format("Schedule=\"{}\". Maximum is [{:.1R}]. Values must be >= 0.0.", AlphaName(3), SchMax)); - ErrorsFound = true; - } - } } - state.dataContaminantBalance->ZoneContamGenericPDriven(Loop).GCGenRateCoef = IHGNumbers(1); + contam.GenRateCoef = IHGNumbers(1); if (IHGNumbers(1) < 0.0) { ShowSevereError(state, format("{}Negative values are not allowed for {} in {} = {}", @@ -482,7 +388,7 @@ void GetZoneContaminanInputs(EnergyPlusData &state) ErrorsFound = true; } - state.dataContaminantBalance->ZoneContamGenericPDriven(Loop).GCExpo = IHGNumbers(2); + contam.Expo = IHGNumbers(2); if (IHGNumbers(2) <= 0.0) { ShowSevereError(state, format("{}Negative or zero value is not allowed for {} in {} = {}", @@ -508,15 +414,13 @@ void GetZoneContaminanInputs(EnergyPlusData &state) SetupOutputVariable(state, "Generic Air Contaminant Pressure Driven Generation Volume Flow Rate", Constant::Units::m3_s, - state.dataContaminantBalance->ZoneContamGenericPDriven(Loop).GCGenRate, + contam.GenRate, OutputProcessor::TimeStepType::Zone, OutputProcessor::StoreType::Average, - state.dataContaminantBalance->ZoneContamGenericPDriven(Loop).Name); + contam.Name); - if (state.dataContaminantBalance->ZoneContamGenericPDriven(Loop).SurfNum > 0) { - ZonePtr = state.dataSurface - ->Surface(state.afn->MultizoneSurfaceData(state.dataContaminantBalance->ZoneContamGenericPDriven(Loop).SurfNum).SurfNum) - .Zone; + if (contam.SurfNum > 0) { + ZonePtr = state.dataSurface->Surface(state.afn->MultizoneSurfaceData(contam.SurfNum).SurfNum).Zone; } else { ZonePtr = 0; } @@ -534,7 +438,7 @@ void GetZoneContaminanInputs(EnergyPlusData &state) if (ZonePtr > 0) SetupZoneInternalGain(state, ZonePtr, - state.dataContaminantBalance->ZoneContamGenericPDriven(Loop).Name, + contam.Name, DataHeatBalance::IntGainType::ZoneContaminantSourceAndSinkGenericContam, nullptr, nullptr, @@ -542,7 +446,7 @@ void GetZoneContaminanInputs(EnergyPlusData &state) nullptr, nullptr, nullptr, - &state.dataContaminantBalance->ZoneContamGenericPDriven(Loop).GCGenRate); + &contam.GenRate); } CurrentModuleObject = "ZoneContaminantSourceAndSink:Generic:CutoffModel"; @@ -564,12 +468,17 @@ void GetZoneContaminanInputs(EnergyPlusData &state) state.dataIPShortCut->lAlphaFieldBlanks, state.dataIPShortCut->cAlphaFieldNames, state.dataIPShortCut->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, CurrentModuleObject, AlphaName(1)}; + Util::IsNameEmpty(state, AlphaName(1), CurrentModuleObject, ErrorsFound); - state.dataContaminantBalance->ZoneContamGenericCutoff(Loop).Name = AlphaName(1); - state.dataContaminantBalance->ZoneContamGenericCutoff(Loop).ZoneName = AlphaName(2); - state.dataContaminantBalance->ZoneContamGenericCutoff(Loop).ActualZoneNum = Util::FindItemInList(AlphaName(2), state.dataHeatBal->Zone); - if (state.dataContaminantBalance->ZoneContamGenericCutoff(Loop).ActualZoneNum == 0) { + auto &contam = state.dataContaminantBalance->ZoneContamGenericCutoff(Loop); + contam.Name = AlphaName(1); + + contam.ZoneName = AlphaName(2); + contam.ActualZoneNum = Util::FindItemInList(AlphaName(2), state.dataHeatBal->Zone); + if (contam.ActualZoneNum == 0) { ShowSevereError(state, format("{}{}=\"{}\", invalid {} entered={}", RoutineName, @@ -580,52 +489,19 @@ void GetZoneContaminanInputs(EnergyPlusData &state) ErrorsFound = true; } - state.dataContaminantBalance->ZoneContamGenericCutoff(Loop).GCGenerateRateSchedPtr = ScheduleManager::GetScheduleIndex(state, AlphaName(3)); - if (state.dataContaminantBalance->ZoneContamGenericCutoff(Loop).GCGenerateRateSchedPtr == 0) { - if (state.dataIPShortCut->lAlphaFieldBlanks(3)) { - ShowSevereError( - state, - format( - "{}{}=\"{}\", {} is required.", RoutineName, CurrentModuleObject, AlphaName(1), state.dataIPShortCut->cAlphaFieldNames(3))); - } else { - ShowSevereError(state, - format("{}{}=\"{}\", invalid {} entered={}", - RoutineName, - CurrentModuleObject, - AlphaName(1), - state.dataIPShortCut->cAlphaFieldNames(3), - AlphaName(3))); - } + if (state.dataIPShortCut->lAlphaFieldBlanks(3)) { + ShowSevereEmptyField(state, eoh, state.dataIPShortCut->cAlphaFieldNames(3)); + ErrorsFound = true; + } else if ((contam.generateRateSched = Sched::GetSchedule(state, AlphaName(3))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(3), AlphaName(3)); + ErrorsFound = true; + } else if (!contam.generateRateSched->checkMinVal(state, Clusive::In, 0.0)) { + Sched::ShowSevereBadMin(state, eoh, state.dataIPShortCut->cAlphaFieldNames(3), AlphaName(3), Clusive::In, 0.0); ErrorsFound = true; - } else { // check min/max on schedule - SchMin = ScheduleManager::GetScheduleMinValue(state, state.dataContaminantBalance->ZoneContamGenericCutoff(Loop).GCGenerateRateSchedPtr); - SchMax = ScheduleManager::GetScheduleMaxValue(state, state.dataContaminantBalance->ZoneContamGenericCutoff(Loop).GCGenerateRateSchedPtr); - if (SchMin < 0.0 || SchMax < 0.0) { - if (SchMin < 0.0) { - ShowSevereError(state, - format("{}{}=\"{}\", {}, minimum is < 0.0", - RoutineName, - CurrentModuleObject, - AlphaName(1), - state.dataIPShortCut->cAlphaFieldNames(3))); - ShowContinueError(state, format("Schedule=\"{}\". Minimum is [{:.1R}]. Values must be >= 0.0.", AlphaName(3), SchMin)); - ErrorsFound = true; - } - if (SchMax < 0.0) { - ShowSevereError(state, - format("{}{}=\"{}\", {}, maximum is < 0.0", - RoutineName, - CurrentModuleObject, - AlphaName(1), - state.dataIPShortCut->cAlphaFieldNames(3))); - ShowContinueError(state, format("Schedule=\"{}\". Maximum is [{:.1R}]. Values must be >= 0.0.", AlphaName(3), SchMax)); - ErrorsFound = true; - } - } } - state.dataContaminantBalance->ZoneContamGenericCutoff(Loop).GCGenerateRate = IHGNumbers(1); - state.dataContaminantBalance->ZoneContamGenericCutoff(Loop).GCCutoffValue = IHGNumbers(2); + contam.GenerateRate = IHGNumbers(1); + contam.CutoffValue = IHGNumbers(2); if (IHGNumbers(1) < 0.0) { ShowSevereError(state, @@ -652,13 +528,13 @@ void GetZoneContaminanInputs(EnergyPlusData &state) SetupOutputVariable(state, "Generic Air Contaminant Cutoff Model Generation Volume Flow Rate", Constant::Units::m3_s, - state.dataContaminantBalance->ZoneContamGenericCutoff(Loop).GCGenRate, + contam.GenRate, OutputProcessor::TimeStepType::Zone, OutputProcessor::StoreType::Average, - state.dataContaminantBalance->ZoneContamGenericCutoff(Loop).Name); + contam.Name); // Zone total report variables - ZonePtr = state.dataContaminantBalance->ZoneContamGenericCutoff(Loop).ActualZoneNum; + ZonePtr = contam.ActualZoneNum; if (RepVarSet(ZonePtr)) { RepVarSet(ZonePtr) = false; SetupOutputVariable(state, @@ -671,7 +547,7 @@ void GetZoneContaminanInputs(EnergyPlusData &state) } SetupZoneInternalGain(state, ZonePtr, - state.dataContaminantBalance->ZoneContamGenericCutoff(Loop).Name, + contam.Name, DataHeatBalance::IntGainType::ZoneContaminantSourceAndSinkGenericContam, nullptr, nullptr, @@ -679,7 +555,7 @@ void GetZoneContaminanInputs(EnergyPlusData &state) nullptr, nullptr, nullptr, - &state.dataContaminantBalance->ZoneContamGenericCutoff(Loop).GCGenRate); + &contam.GenRate); } CurrentModuleObject = "ZoneContaminantSourceAndSink:Generic:DecaySource"; @@ -701,12 +577,17 @@ void GetZoneContaminanInputs(EnergyPlusData &state) state.dataIPShortCut->lAlphaFieldBlanks, state.dataIPShortCut->cAlphaFieldNames, state.dataIPShortCut->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, CurrentModuleObject, AlphaName(1)}; + + auto &contam = state.dataContaminantBalance->ZoneContamGenericDecay(Loop); + Util::IsNameEmpty(state, AlphaName(1), CurrentModuleObject, ErrorsFound); - state.dataContaminantBalance->ZoneContamGenericDecay(Loop).Name = AlphaName(1); + contam.Name = AlphaName(1); - state.dataContaminantBalance->ZoneContamGenericDecay(Loop).ZoneName = AlphaName(2); - state.dataContaminantBalance->ZoneContamGenericDecay(Loop).ActualZoneNum = Util::FindItemInList(AlphaName(2), state.dataHeatBal->Zone); - if (state.dataContaminantBalance->ZoneContamGenericDecay(Loop).ActualZoneNum == 0) { + contam.ZoneName = AlphaName(2); + contam.ActualZoneNum = Util::FindItemInList(AlphaName(2), state.dataHeatBal->Zone); + if (contam.ActualZoneNum == 0) { ShowSevereError(state, format("{}{}=\"{}\", invalid {} entered={}", RoutineName, @@ -717,52 +598,19 @@ void GetZoneContaminanInputs(EnergyPlusData &state) ErrorsFound = true; } - state.dataContaminantBalance->ZoneContamGenericDecay(Loop).GCEmiRateSchedPtr = ScheduleManager::GetScheduleIndex(state, AlphaName(3)); - if (state.dataContaminantBalance->ZoneContamGenericDecay(Loop).GCEmiRateSchedPtr == 0) { - if (state.dataIPShortCut->lAlphaFieldBlanks(3)) { - ShowSevereError( - state, - format( - "{}{}=\"{}\", {} is required.", RoutineName, CurrentModuleObject, AlphaName(1), state.dataIPShortCut->cAlphaFieldNames(3))); - } else { - ShowSevereError(state, - format("{}{}=\"{}\", invalid {} entered={}", - RoutineName, - CurrentModuleObject, - AlphaName(1), - state.dataIPShortCut->cAlphaFieldNames(3), - AlphaName(3))); - } + if (state.dataIPShortCut->lAlphaFieldBlanks(3)) { + ShowSevereEmptyField(state, eoh, state.dataIPShortCut->cAlphaFieldNames(3)); + ErrorsFound = true; + } else if ((contam.emitRateSched = Sched::GetSchedule(state, AlphaName(3))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(3), AlphaName(3)); + ErrorsFound = true; + } else if (!contam.emitRateSched->checkMinVal(state, Clusive::In, 0.0)) { + Sched::ShowSevereBadMin(state, eoh, state.dataIPShortCut->cAlphaFieldNames(3), AlphaName(3), Clusive::In, 0.0); ErrorsFound = true; - } else { // check min/max on schedule - SchMin = ScheduleManager::GetScheduleMinValue(state, state.dataContaminantBalance->ZoneContamGenericDecay(Loop).GCEmiRateSchedPtr); - SchMax = ScheduleManager::GetScheduleMaxValue(state, state.dataContaminantBalance->ZoneContamGenericDecay(Loop).GCEmiRateSchedPtr); - if (SchMin < 0.0 || SchMax < 0.0) { - if (SchMin < 0.0) { - ShowSevereError(state, - format("{}{}=\"{}\", {}, minimum is < 0.0", - RoutineName, - CurrentModuleObject, - AlphaName(1), - state.dataIPShortCut->cAlphaFieldNames(3))); - ShowContinueError(state, format("Schedule=\"{}\". Minimum is [{:.1R}]. Values must be >= 0.0.", AlphaName(3), SchMin)); - ErrorsFound = true; - } - if (SchMax < 0.0) { - ShowSevereError(state, - format("{}{}=\"{}\", {}, maximum is < 0.0", - RoutineName, - CurrentModuleObject, - AlphaName(1), - state.dataIPShortCut->cAlphaFieldNames(3))); - ShowContinueError(state, format("Schedule=\"{}\". Maximum is [{:.1R}]. Values must be >= 0.0.", AlphaName(3), SchMax)); - ErrorsFound = true; - } - } } - state.dataContaminantBalance->ZoneContamGenericDecay(Loop).GCInitEmiRate = IHGNumbers(1); - state.dataContaminantBalance->ZoneContamGenericDecay(Loop).GCDelayTime = IHGNumbers(2); + contam.InitEmitRate = IHGNumbers(1); + contam.DelayTime = IHGNumbers(2); if (IHGNumbers(1) < 0.0) { ShowSevereError(state, @@ -789,20 +637,20 @@ void GetZoneContaminanInputs(EnergyPlusData &state) SetupOutputVariable(state, "Generic Air Contaminant Decay Model Generation Volume Flow Rate", Constant::Units::m3_s, - state.dataContaminantBalance->ZoneContamGenericDecay(Loop).GCGenRate, + contam.GenRate, OutputProcessor::TimeStepType::Zone, OutputProcessor::StoreType::Average, - state.dataContaminantBalance->ZoneContamGenericDecay(Loop).Name); + contam.Name); SetupOutputVariable(state, "Generic Air Contaminant Decay Model Generation Emission Start Elapsed Time", Constant::Units::s, - state.dataContaminantBalance->ZoneContamGenericDecay(Loop).GCTime, + contam.Time, OutputProcessor::TimeStepType::Zone, OutputProcessor::StoreType::Average, - state.dataContaminantBalance->ZoneContamGenericDecay(Loop).Name); + contam.Name); // Zone total report variables - ZonePtr = state.dataContaminantBalance->ZoneContamGenericDecay(Loop).ActualZoneNum; + ZonePtr = contam.ActualZoneNum; if (RepVarSet(ZonePtr)) { RepVarSet(ZonePtr) = false; SetupOutputVariable(state, @@ -815,7 +663,7 @@ void GetZoneContaminanInputs(EnergyPlusData &state) } SetupZoneInternalGain(state, ZonePtr, - state.dataContaminantBalance->ZoneContamGenericDecay(Loop).Name, + contam.Name, DataHeatBalance::IntGainType::ZoneContaminantSourceAndSinkGenericContam, nullptr, nullptr, @@ -823,7 +671,7 @@ void GetZoneContaminanInputs(EnergyPlusData &state) nullptr, nullptr, nullptr, - &state.dataContaminantBalance->ZoneContamGenericDecay(Loop).GCGenRate); + &contam.GenRate); } CurrentModuleObject = "SurfaceContaminantSourceAndSink:Generic:BoundaryLayerDiffusion"; @@ -845,12 +693,16 @@ void GetZoneContaminanInputs(EnergyPlusData &state) state.dataIPShortCut->lAlphaFieldBlanks, state.dataIPShortCut->cAlphaFieldNames, state.dataIPShortCut->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, CurrentModuleObject, AlphaName(1)}; + Util::IsNameEmpty(state, AlphaName(1), CurrentModuleObject, ErrorsFound); - state.dataContaminantBalance->ZoneContamGenericBLDiff(Loop).Name = AlphaName(1); - state.dataContaminantBalance->ZoneContamGenericBLDiff(Loop).SurfName = AlphaName(2); - state.dataContaminantBalance->ZoneContamGenericBLDiff(Loop).SurfNum = Util::FindItemInList(AlphaName(2), state.dataSurface->Surface); - if (state.dataContaminantBalance->ZoneContamGenericBLDiff(Loop).SurfNum == 0) { + auto &contam = state.dataContaminantBalance->ZoneContamGenericBLDiff(Loop); + contam.Name = AlphaName(1); + contam.SurfName = AlphaName(2); + contam.SurfNum = Util::FindItemInList(AlphaName(2), state.dataSurface->Surface); + if (contam.SurfNum == 0) { ShowSevereError(state, format("{}{}=\"{}\", invalid {} entered={}", RoutineName, @@ -861,52 +713,19 @@ void GetZoneContaminanInputs(EnergyPlusData &state) ErrorsFound = true; } - state.dataContaminantBalance->ZoneContamGenericBLDiff(Loop).GCTranCoefSchedPtr = ScheduleManager::GetScheduleIndex(state, AlphaName(3)); - if (state.dataContaminantBalance->ZoneContamGenericBLDiff(Loop).GCTranCoefSchedPtr == 0) { - if (state.dataIPShortCut->lAlphaFieldBlanks(3)) { - ShowSevereError( - state, - format( - "{}{}=\"{}\", {} is required.", RoutineName, CurrentModuleObject, AlphaName(1), state.dataIPShortCut->cAlphaFieldNames(3))); - } else { - ShowSevereError(state, - format("{}{}=\"{}\", invalid {} entered={}", - RoutineName, - CurrentModuleObject, - AlphaName(1), - state.dataIPShortCut->cAlphaFieldNames(3), - AlphaName(3))); - } + if (state.dataIPShortCut->lAlphaFieldBlanks(3)) { + ShowSevereEmptyField(state, eoh, state.dataIPShortCut->cAlphaFieldNames(3)); + ErrorsFound = true; + } else if ((contam.transCoefSched = Sched::GetSchedule(state, AlphaName(3))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(3), AlphaName(3)); + ErrorsFound = true; + } else if (!contam.transCoefSched->checkMinVal(state, Clusive::In, 0.0)) { + Sched::ShowSevereBadMin(state, eoh, state.dataIPShortCut->cAlphaFieldNames(3), AlphaName(3), Clusive::In, 0.0); ErrorsFound = true; - } else { // check min/max on schedule - SchMin = ScheduleManager::GetScheduleMinValue(state, state.dataContaminantBalance->ZoneContamGenericBLDiff(Loop).GCTranCoefSchedPtr); - SchMax = ScheduleManager::GetScheduleMaxValue(state, state.dataContaminantBalance->ZoneContamGenericBLDiff(Loop).GCTranCoefSchedPtr); - if (SchMin < 0.0 || SchMax < 0.0) { - if (SchMin < 0.0) { - ShowSevereError(state, - format("{}{}=\"{}\", {}, minimum is < 0.0", - RoutineName, - CurrentModuleObject, - AlphaName(1), - state.dataIPShortCut->cAlphaFieldNames(3))); - ShowContinueError(state, format("Schedule=\"{}\". Minimum is [{:.1R}]. Values must be >= 0.0.", AlphaName(3), SchMin)); - ErrorsFound = true; - } - if (SchMax < 0.0) { - ShowSevereError(state, - format("{}{}=\"{}\", {}, maximum is < 0.0", - RoutineName, - CurrentModuleObject, - AlphaName(1), - state.dataIPShortCut->cAlphaFieldNames(3))); - ShowContinueError(state, format("Schedule=\"{}\". Maximum is [{:.1R}]. Values must be >= 0.0.", AlphaName(3), SchMax)); - ErrorsFound = true; - } - } } - state.dataContaminantBalance->ZoneContamGenericBLDiff(Loop).GCTranCoef = IHGNumbers(1); - state.dataContaminantBalance->ZoneContamGenericBLDiff(Loop).GCHenryCoef = IHGNumbers(2); + contam.TransCoef = IHGNumbers(1); + contam.HenryCoef = IHGNumbers(2); if (IHGNumbers(1) < 0.0) { ShowSevereError(state, format("{}Negative values are not allowed for {} in {} = {}", @@ -932,21 +751,21 @@ void GetZoneContaminanInputs(EnergyPlusData &state) SetupOutputVariable(state, "Generic Air Contaminant Boundary Layer Diffusion Generation Volume Flow Rate", Constant::Units::m3_s, - state.dataContaminantBalance->ZoneContamGenericBLDiff(Loop).GCGenRate, + contam.GenRate, OutputProcessor::TimeStepType::Zone, OutputProcessor::StoreType::Average, - state.dataContaminantBalance->ZoneContamGenericBLDiff(Loop).Name); - if (state.dataContaminantBalance->ZoneContamGenericBLDiff(Loop).SurfNum > 0) { + contam.Name); + if (contam.SurfNum > 0) { SetupOutputVariable(state, "Generic Air Contaminant Boundary Layer Diffusion Inside Face Concentration", Constant::Units::ppm, - state.dataSurface->SurfGenericContam(state.dataContaminantBalance->ZoneContamGenericBLDiff(Loop).SurfNum), + state.dataSurface->SurfGenericContam(contam.SurfNum), OutputProcessor::TimeStepType::Zone, OutputProcessor::StoreType::Average, - state.dataContaminantBalance->ZoneContamGenericBLDiff(Loop).SurfName); + contam.SurfName); } - ZonePtr = state.dataSurface->Surface(state.dataContaminantBalance->ZoneContamGenericBLDiff(Loop).SurfNum).Zone; + ZonePtr = state.dataSurface->Surface(contam.SurfNum).Zone; // Zone total report variables if (RepVarSet(ZonePtr)) { RepVarSet(ZonePtr) = false; @@ -960,7 +779,7 @@ void GetZoneContaminanInputs(EnergyPlusData &state) } SetupZoneInternalGain(state, ZonePtr, - state.dataContaminantBalance->ZoneContamGenericBLDiff(Loop).Name, + contam.Name, DataHeatBalance::IntGainType::ZoneContaminantSourceAndSinkGenericContam, nullptr, nullptr, @@ -968,7 +787,7 @@ void GetZoneContaminanInputs(EnergyPlusData &state) nullptr, nullptr, nullptr, - &state.dataContaminantBalance->ZoneContamGenericBLDiff(Loop).GCGenRate); + &contam.GenRate); } CurrentModuleObject = "SurfaceContaminantSourceAndSink:Generic:DepositionVelocitySink"; @@ -990,12 +809,16 @@ void GetZoneContaminanInputs(EnergyPlusData &state) state.dataIPShortCut->lAlphaFieldBlanks, state.dataIPShortCut->cAlphaFieldNames, state.dataIPShortCut->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, CurrentModuleObject, AlphaName(1)}; + Util::IsNameEmpty(state, AlphaName(1), CurrentModuleObject, ErrorsFound); - state.dataContaminantBalance->ZoneContamGenericDVS(Loop).Name = AlphaName(1); + auto &contam = state.dataContaminantBalance->ZoneContamGenericDVS(Loop); + contam.Name = AlphaName(1); - state.dataContaminantBalance->ZoneContamGenericDVS(Loop).SurfName = AlphaName(2); - state.dataContaminantBalance->ZoneContamGenericDVS(Loop).SurfNum = Util::FindItemInList(AlphaName(2), state.dataSurface->Surface); - if (state.dataContaminantBalance->ZoneContamGenericDVS(Loop).SurfNum == 0) { + contam.SurfName = AlphaName(2); + contam.SurfNum = Util::FindItemInList(AlphaName(2), state.dataSurface->Surface); + if (contam.SurfNum == 0) { ShowSevereError(state, format("{}{}=\"{}\", invalid {} entered={}", RoutineName, @@ -1006,51 +829,18 @@ void GetZoneContaminanInputs(EnergyPlusData &state) ErrorsFound = true; } - state.dataContaminantBalance->ZoneContamGenericDVS(Loop).GCDepoVeloPtr = ScheduleManager::GetScheduleIndex(state, AlphaName(3)); - if (state.dataContaminantBalance->ZoneContamGenericDVS(Loop).GCDepoVeloPtr == 0) { - if (state.dataIPShortCut->lAlphaFieldBlanks(3)) { - ShowSevereError( - state, - format( - "{}{}=\"{}\", {} is required.", RoutineName, CurrentModuleObject, AlphaName(1), state.dataIPShortCut->cAlphaFieldNames(3))); - } else { - ShowSevereError(state, - format("{}{}=\"{}\", invalid {} entered={}", - RoutineName, - CurrentModuleObject, - AlphaName(1), - state.dataIPShortCut->cAlphaFieldNames(3), - AlphaName(3))); - } + if (state.dataIPShortCut->lAlphaFieldBlanks(3)) { + ShowSevereEmptyField(state, eoh, state.dataIPShortCut->cAlphaFieldNames(3)); + ErrorsFound = true; + } else if ((contam.depoVeloSched = Sched::GetSchedule(state, AlphaName(3))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(3), AlphaName(3)); + ErrorsFound = true; + } else if (!contam.depoVeloSched->checkMinVal(state, Clusive::In, 0.0)) { + Sched::ShowSevereBadMin(state, eoh, state.dataIPShortCut->cAlphaFieldNames(3), AlphaName(3), Clusive::In, 0.0); ErrorsFound = true; - } else { // check min/max on schedule - SchMin = ScheduleManager::GetScheduleMinValue(state, state.dataContaminantBalance->ZoneContamGenericDVS(Loop).GCDepoVeloPtr); - SchMax = ScheduleManager::GetScheduleMaxValue(state, state.dataContaminantBalance->ZoneContamGenericDVS(Loop).GCDepoVeloPtr); - if (SchMin < 0.0 || SchMax < 0.0) { - if (SchMin < 0.0) { - ShowSevereError(state, - format("{}{}=\"{}\", {}, minimum is < 0.0", - RoutineName, - CurrentModuleObject, - AlphaName(1), - state.dataIPShortCut->cAlphaFieldNames(3))); - ShowContinueError(state, format("Schedule=\"{}\". Minimum is [{:.1R}]. Values must be >= 0.0.", AlphaName(3), SchMin)); - ErrorsFound = true; - } - if (SchMax < 0.0) { - ShowSevereError(state, - format("{}{}=\"{}\", {}, maximum is < 0.0", - RoutineName, - CurrentModuleObject, - AlphaName(1), - state.dataIPShortCut->cAlphaFieldNames(3))); - ShowContinueError(state, format("Schedule=\"{}\". Maximum is [{:.1R}]. Values must be >= 0.0.", AlphaName(3), SchMax)); - ErrorsFound = true; - } - } } - state.dataContaminantBalance->ZoneContamGenericDVS(Loop).GCDepoVelo = IHGNumbers(1); + contam.DepoVelo = IHGNumbers(1); if (IHGNumbers(1) < 0.0) { ShowSevereError(state, format("{}Negative values are not allowed for {} in {} = {}", @@ -1066,12 +856,12 @@ void GetZoneContaminanInputs(EnergyPlusData &state) SetupOutputVariable(state, "Generic Air Contaminant Deposition Velocity Removal Volume Flow Rate", Constant::Units::m3_s, - state.dataContaminantBalance->ZoneContamGenericDVS(Loop).GCGenRate, + contam.GenRate, OutputProcessor::TimeStepType::Zone, OutputProcessor::StoreType::Average, - state.dataContaminantBalance->ZoneContamGenericDVS(Loop).Name); + contam.Name); - ZonePtr = state.dataSurface->Surface(state.dataContaminantBalance->ZoneContamGenericDVS(Loop).SurfNum).Zone; + ZonePtr = state.dataSurface->Surface(contam.SurfNum).Zone; // Zone total report variables if (RepVarSet(ZonePtr)) { RepVarSet(ZonePtr) = false; @@ -1085,7 +875,7 @@ void GetZoneContaminanInputs(EnergyPlusData &state) } SetupZoneInternalGain(state, ZonePtr, - state.dataContaminantBalance->ZoneContamGenericDVS(Loop).Name, + contam.Name, DataHeatBalance::IntGainType::ZoneContaminantSourceAndSinkGenericContam, nullptr, nullptr, @@ -1093,7 +883,7 @@ void GetZoneContaminanInputs(EnergyPlusData &state) nullptr, nullptr, nullptr, - &state.dataContaminantBalance->ZoneContamGenericDVS(Loop).GCGenRate); + &contam.GenRate); } CurrentModuleObject = "ZoneContaminantSourceAndSink:Generic:DepositionRateSink"; @@ -1115,12 +905,17 @@ void GetZoneContaminanInputs(EnergyPlusData &state) state.dataIPShortCut->lAlphaFieldBlanks, state.dataIPShortCut->cAlphaFieldNames, state.dataIPShortCut->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, CurrentModuleObject, AlphaName(1)}; + Util::IsNameEmpty(state, AlphaName(1), CurrentModuleObject, ErrorsFound); - state.dataContaminantBalance->ZoneContamGenericDRS(Loop).Name = AlphaName(1); - state.dataContaminantBalance->ZoneContamGenericDRS(Loop).ZoneName = AlphaName(2); - state.dataContaminantBalance->ZoneContamGenericDRS(Loop).ActualZoneNum = Util::FindItemInList(AlphaName(2), state.dataHeatBal->Zone); - if (state.dataContaminantBalance->ZoneContamGenericDRS(Loop).ActualZoneNum == 0) { + auto &contam = state.dataContaminantBalance->ZoneContamGenericDRS(Loop); + contam.Name = AlphaName(1); + + contam.ZoneName = AlphaName(2); + contam.ActualZoneNum = Util::FindItemInList(AlphaName(2), state.dataHeatBal->Zone); + if (contam.ActualZoneNum == 0) { ShowSevereError(state, format("{}{}=\"{}\", invalid {} entered={}", RoutineName, @@ -1131,51 +926,18 @@ void GetZoneContaminanInputs(EnergyPlusData &state) ErrorsFound = true; } - state.dataContaminantBalance->ZoneContamGenericDRS(Loop).GCDepoRatePtr = ScheduleManager::GetScheduleIndex(state, AlphaName(3)); - if (state.dataContaminantBalance->ZoneContamGenericDRS(Loop).GCDepoRatePtr == 0) { - if (state.dataIPShortCut->lAlphaFieldBlanks(3)) { - ShowSevereError( - state, - format( - "{}{}=\"{}\", {} is required.", RoutineName, CurrentModuleObject, AlphaName(1), state.dataIPShortCut->cAlphaFieldNames(3))); - } else { - ShowSevereError(state, - format("{}{}=\"{}\", invalid {} entered={}", - RoutineName, - CurrentModuleObject, - AlphaName(1), - state.dataIPShortCut->cAlphaFieldNames(3), - AlphaName(3))); - } + if (state.dataIPShortCut->lAlphaFieldBlanks(3)) { + ShowSevereEmptyField(state, eoh, state.dataIPShortCut->cAlphaFieldNames(3)); + ErrorsFound = true; + } else if ((contam.depoRateSched = Sched::GetSchedule(state, AlphaName(3))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(3), AlphaName(3)); + ErrorsFound = true; + } else if (!contam.depoRateSched->checkMinVal(state, Clusive::In, 0.0)) { + Sched::ShowSevereBadMin(state, eoh, state.dataIPShortCut->cAlphaFieldNames(3), AlphaName(3), Clusive::In, 0.0); ErrorsFound = true; - } else { // check min/max on schedule - SchMin = ScheduleManager::GetScheduleMinValue(state, state.dataContaminantBalance->ZoneContamGenericDRS(Loop).GCDepoRatePtr); - SchMax = ScheduleManager::GetScheduleMaxValue(state, state.dataContaminantBalance->ZoneContamGenericDRS(Loop).GCDepoRatePtr); - if (SchMin < 0.0 || SchMax < 0.0) { - if (SchMin < 0.0) { - ShowSevereError(state, - format("{}{}=\"{}\", {}, minimum is < 0.0", - RoutineName, - CurrentModuleObject, - AlphaName(1), - state.dataIPShortCut->cAlphaFieldNames(3))); - ShowContinueError(state, format("Schedule=\"{}\". Minimum is [{:.1R}]. Values must be >= 0.0.", AlphaName(3), SchMin)); - ErrorsFound = true; - } - if (SchMax < 0.0) { - ShowSevereError(state, - format("{}{}=\"{}\", {}, maximum is < 0.0", - RoutineName, - CurrentModuleObject, - AlphaName(1), - state.dataIPShortCut->cAlphaFieldNames(3))); - ShowContinueError(state, format("Schedule=\"{}\". Maximum is [{:.1R}]. Values must be >= 0.0.", AlphaName(3), SchMax)); - ErrorsFound = true; - } - } } - state.dataContaminantBalance->ZoneContamGenericDRS(Loop).GCDepoRate = IHGNumbers(1); + contam.DepoRate = IHGNumbers(1); if (IHGNumbers(1) < 0.0) { ShowSevereError(state, @@ -1192,12 +954,12 @@ void GetZoneContaminanInputs(EnergyPlusData &state) SetupOutputVariable(state, "Generic Air Contaminant Deposition Rate Removal Volume Flow Rate", Constant::Units::m3_s, - state.dataContaminantBalance->ZoneContamGenericDRS(Loop).GCGenRate, + contam.GenRate, OutputProcessor::TimeStepType::Zone, OutputProcessor::StoreType::Average, - state.dataContaminantBalance->ZoneContamGenericDRS(Loop).Name); + contam.Name); - ZonePtr = state.dataContaminantBalance->ZoneContamGenericDRS(Loop).ActualZoneNum; + ZonePtr = contam.ActualZoneNum; // Zone total report variables if (RepVarSet(ZonePtr)) { RepVarSet(ZonePtr) = false; @@ -1211,7 +973,7 @@ void GetZoneContaminanInputs(EnergyPlusData &state) } SetupZoneInternalGain(state, ZonePtr, - state.dataContaminantBalance->ZoneContamGenericDRS(Loop).Name, + contam.Name, DataHeatBalance::IntGainType::ZoneContaminantSourceAndSinkGenericContam, nullptr, nullptr, @@ -1219,7 +981,7 @@ void GetZoneContaminanInputs(EnergyPlusData &state) nullptr, nullptr, nullptr, - &state.dataContaminantBalance->ZoneContamGenericDRS(Loop).GCGenRate); + &contam.GenRate); } RepVarSet.deallocate(); @@ -1244,21 +1006,14 @@ void GetZoneContaminanSetPoints(EnergyPlusData &state) // METHODOLOGY EMPLOYED: // Uses the status flags to trigger events. - // Using/Aliasing - - using ScheduleManager::CheckScheduleValue; - using ScheduleManager::CheckScheduleValueMinMax; - using ScheduleManager::GetScheduleIndex; - using ScheduleManager::GetScheduleMaxValue; - using ScheduleManager::GetScheduleMinValue; - + static constexpr std::string_view routineName = "GetZoneContaminantSetPoints"; + // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int ContControlledZoneNum; // The Splitter that you are currently loading input into int NumAlphas; int NumNums; int IOStat; bool ErrorsFound(false); - bool ValidScheduleType; struct NeededControlTypes { @@ -1304,13 +1059,16 @@ void GetZoneContaminanSetPoints(EnergyPlusData &state) state.dataIPShortCut->lAlphaFieldBlanks, state.dataIPShortCut->cAlphaFieldNames, state.dataIPShortCut->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1)}; + Util::IsNameEmpty(state, state.dataIPShortCut->cAlphaArgs(1), cCurrentModuleObject, ErrorsFound); - state.dataContaminantBalance->ContaminantControlledZone(ContControlledZoneNum).Name = state.dataIPShortCut->cAlphaArgs(1); - state.dataContaminantBalance->ContaminantControlledZone(ContControlledZoneNum).ZoneName = state.dataIPShortCut->cAlphaArgs(2); - state.dataContaminantBalance->ContaminantControlledZone(ContControlledZoneNum).ActualZoneNum = - Util::FindItemInList(state.dataIPShortCut->cAlphaArgs(2), state.dataHeatBal->Zone); - if (state.dataContaminantBalance->ContaminantControlledZone(ContControlledZoneNum).ActualZoneNum == 0) { + auto &controlledZone = state.dataContaminantBalance->ContaminantControlledZone(ContControlledZoneNum); + controlledZone.Name = state.dataIPShortCut->cAlphaArgs(1); + controlledZone.ZoneName = state.dataIPShortCut->cAlphaArgs(2); + controlledZone.ActualZoneNum = Util::FindItemInList(state.dataIPShortCut->cAlphaArgs(2), state.dataHeatBal->Zone); + if (controlledZone.ActualZoneNum == 0) { ShowSevereError(state, format("{}=\"{}\" invalid {}=\"{}\" not found.", cCurrentModuleObject, @@ -1322,161 +1080,76 @@ void GetZoneContaminanSetPoints(EnergyPlusData &state) // Zone(ContaminantControlledZone(ContControlledZoneNum)%ActualZoneNum)%TempControlledZoneIndex = ContControlledZoneNum } - state.dataContaminantBalance->ContaminantControlledZone(ContControlledZoneNum).AvaiSchedule = state.dataIPShortCut->cAlphaArgs(3); if (state.dataIPShortCut->lAlphaFieldBlanks(3)) { - state.dataContaminantBalance->ContaminantControlledZone(ContControlledZoneNum).AvaiSchedPtr = - ScheduleManager::ScheduleAlwaysOn; // (Returns 1.0) + controlledZone.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((controlledZone.availSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(3))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(3), state.dataIPShortCut->cAlphaArgs(3)); + ErrorsFound = true; + } else if (!controlledZone.availSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) { + Sched::ShowSevereBadMinMax(state, eoh, state.dataIPShortCut->cAlphaFieldNames(3), state.dataIPShortCut->cAlphaArgs(3), + Clusive::In, 0.0, Clusive::In, 1.0); + ErrorsFound = true; } else { - state.dataContaminantBalance->ContaminantControlledZone(ContControlledZoneNum).AvaiSchedPtr = - GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(3)); - if (state.dataContaminantBalance->ContaminantControlledZone(ContControlledZoneNum).AvaiSchedPtr == 0) { - ShowSevereError(state, - format("{}=\"{}\" invalid {}=\"{}\" not found.", - cCurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaFieldNames(3), - state.dataIPShortCut->cAlphaArgs(3))); - ErrorsFound = true; - } else { - // Check validity of control types. - ValidScheduleType = ScheduleManager::CheckScheduleValueMinMax( - state, state.dataContaminantBalance->ContaminantControlledZone(ContControlledZoneNum).AvaiSchedPtr, ">=", 0.0, "<=", 1.0); - if (!ValidScheduleType) { - ShowSevereError(state, - format("{}=\"{}\" invalid range {}=\"{}\"", - cCurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaFieldNames(3), - state.dataIPShortCut->cAlphaArgs(3))); - ShowContinueError(state, "..contains values outside of range [0,1]."); - ErrorsFound = true; - } else { - state.dataHeatBal->Zone(state.dataContaminantBalance->ContaminantControlledZone(ContControlledZoneNum).ActualZoneNum) - .ZoneContamControllerSchedIndex = state.dataContaminantBalance->ContaminantControlledZone(ContControlledZoneNum).AvaiSchedPtr; - } - } + state.dataHeatBal->Zone(controlledZone.ActualZoneNum).zoneContamControllerSched = controlledZone.availSched; } - state.dataContaminantBalance->ContaminantControlledZone(ContControlledZoneNum).SetPointSchedName = state.dataIPShortCut->cAlphaArgs(4); - state.dataContaminantBalance->ContaminantControlledZone(ContControlledZoneNum).SPSchedIndex = - GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(4)); - if (state.dataContaminantBalance->ContaminantControlledZone(ContControlledZoneNum).SPSchedIndex == 0) { - ShowSevereError(state, - format("{}=\"{}\" invalid {}=\"{}\" not found.", - cCurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaFieldNames(4), - state.dataIPShortCut->cAlphaArgs(4))); + if (state.dataIPShortCut->lAlphaFieldBlanks(4)) { + ShowSevereEmptyField(state, eoh, state.dataIPShortCut->cAlphaFieldNames(4)); + ErrorsFound = true; + } else if ((controlledZone.setptSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(4))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(4), state.dataIPShortCut->cAlphaArgs(4)); + ErrorsFound = true; + } else if (!controlledZone.setptSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 2000.0)) { + Sched::ShowSevereBadMinMax(state, eoh, state.dataIPShortCut->cAlphaFieldNames(4), state.dataIPShortCut->cAlphaArgs(4), + Clusive::In, 0.0, Clusive::In, 2000.0); ErrorsFound = true; - } else { - // Check validity of control types. - ValidScheduleType = ScheduleManager::CheckScheduleValueMinMax( - state, state.dataContaminantBalance->ContaminantControlledZone(ContControlledZoneNum).SPSchedIndex, ">=", 0.0, "<=", 2000.0); - if (!ValidScheduleType) { - ShowSevereError(state, - format("{}=\"{}\" invalid range {}=\"{}\"", - cCurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaFieldNames(4), - state.dataIPShortCut->cAlphaArgs(4))); - ShowContinueError(state, "..contains values outside of range [0,2000 ppm]."); - ErrorsFound = true; - } } - state.dataContaminantBalance->ContaminantControlledZone(ContControlledZoneNum).ZoneMinCO2SchedName = state.dataIPShortCut->cAlphaArgs(5); - state.dataContaminantBalance->ContaminantControlledZone(ContControlledZoneNum).ZoneMinCO2SchedIndex = - GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(5)); - if (state.dataContaminantBalance->ContaminantControlledZone(ContControlledZoneNum).ZoneMinCO2SchedIndex > 0) { - // Check validity of control types. - ValidScheduleType = ScheduleManager::CheckScheduleValueMinMax( - state, state.dataContaminantBalance->ContaminantControlledZone(ContControlledZoneNum).ZoneMinCO2SchedIndex, ">=", 0.0, "<=", 2000.0); - if (!ValidScheduleType) { - ShowSevereError(state, - format("{}=\"{}\" invalid range {}=\"{}\"", - cCurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaFieldNames(5), - state.dataIPShortCut->cAlphaArgs(5))); - ShowContinueError(state, "..contains values outside of range [0,2000 ppm]."); - ErrorsFound = true; - } else { - state.dataHeatBal->Zone(state.dataContaminantBalance->ContaminantControlledZone(ContControlledZoneNum).ActualZoneNum) - .ZoneMinCO2SchedIndex = state.dataContaminantBalance->ContaminantControlledZone(ContControlledZoneNum).ZoneMinCO2SchedIndex; - } + if (state.dataIPShortCut->lAlphaFieldBlanks(5)) { + ShowSevereEmptyField(state, eoh, state.dataIPShortCut->cAlphaFieldNames(5)); + ErrorsFound = true; + } else if ((controlledZone.zoneMinCO2Sched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(5))) == nullptr) { + ShowSevereEmptyField(state, eoh, state.dataIPShortCut->cAlphaFieldNames(5), state.dataIPShortCut->cAlphaArgs(5)); + ErrorsFound = true; + } else if (!controlledZone.zoneMinCO2Sched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 2000.0)) { + Sched::ShowSevereBadMinMax(state, eoh, state.dataIPShortCut->cAlphaFieldNames(5), state.dataIPShortCut->cAlphaArgs(5), + Clusive::In, 0.0, Clusive::In, 2000.0); + ErrorsFound = true; + } else { + state.dataHeatBal->Zone(controlledZone.ActualZoneNum).zoneMinCO2Sched = controlledZone.zoneMinCO2Sched; } - state.dataContaminantBalance->ContaminantControlledZone(ContControlledZoneNum).ZoneMaxCO2SchedName = state.dataIPShortCut->cAlphaArgs(6); - state.dataContaminantBalance->ContaminantControlledZone(ContControlledZoneNum).ZoneMaxCO2SchedIndex = - GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(6)); - if (state.dataContaminantBalance->ContaminantControlledZone(ContControlledZoneNum).ZoneMaxCO2SchedIndex > 0) { - // Check validity of control types. - ValidScheduleType = ScheduleManager::CheckScheduleValueMinMax( - state, state.dataContaminantBalance->ContaminantControlledZone(ContControlledZoneNum).ZoneMaxCO2SchedIndex, ">=", 0.0, "<=", 2000.0); - if (!ValidScheduleType) { - ShowSevereError(state, - format("{}=\"{}\" invalid range {}=\"{}\"", - cCurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaFieldNames(6), - state.dataIPShortCut->cAlphaArgs(6))); - ShowContinueError(state, "..contains values outside of range [0,2000 ppm]."); - ErrorsFound = true; - } else { - state.dataHeatBal->Zone(state.dataContaminantBalance->ContaminantControlledZone(ContControlledZoneNum).ActualZoneNum) - .ZoneMaxCO2SchedIndex = state.dataContaminantBalance->ContaminantControlledZone(ContControlledZoneNum).ZoneMaxCO2SchedIndex; - } + if (state.dataIPShortCut->lAlphaFieldBlanks(6)) { + ShowSevereEmptyField(state, eoh, state.dataIPShortCut->cAlphaFieldNames(6)); + ErrorsFound = true; + } else if ((controlledZone.zoneMaxCO2Sched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(6))) == nullptr) { + ShowSevereEmptyField(state, eoh, state.dataIPShortCut->cAlphaFieldNames(6), state.dataIPShortCut->cAlphaArgs(6)); + ErrorsFound = true; + } else if (!controlledZone.zoneMaxCO2Sched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 2000.0)) { + Sched::ShowSevereBadMinMax(state, eoh, state.dataIPShortCut->cAlphaFieldNames(6), state.dataIPShortCut->cAlphaArgs(6), + Clusive::In, 0.0, Clusive::In, 2000.0); + ErrorsFound = true; + } else { + state.dataHeatBal->Zone(controlledZone.ActualZoneNum).zoneMaxCO2Sched = controlledZone.zoneMaxCO2Sched; } - - if (NumAlphas > 6) { - state.dataContaminantBalance->ContaminantControlledZone(ContControlledZoneNum).GCAvaiSchedule = state.dataIPShortCut->cAlphaArgs(7); - if (state.dataIPShortCut->lAlphaFieldBlanks(7)) { - state.dataContaminantBalance->ContaminantControlledZone(ContControlledZoneNum).GCAvaiSchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - state.dataContaminantBalance->ContaminantControlledZone(ContControlledZoneNum).GCAvaiSchedPtr = - GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(7)); - if (state.dataContaminantBalance->ContaminantControlledZone(ContControlledZoneNum).AvaiSchedPtr == 0) { - ShowSevereError(state, - format("{}=\"{}\" invalid {}=\"{}\" not found.", - cCurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaFieldNames(3), - state.dataIPShortCut->cAlphaArgs(7))); - ErrorsFound = true; - } else { - // Check validity of control types. - ValidScheduleType = ScheduleManager::CheckScheduleValueMinMax( - state, state.dataContaminantBalance->ContaminantControlledZone(ContControlledZoneNum).GCAvaiSchedPtr, ">=", 0.0, "<=", 1.0); - if (!ValidScheduleType) { - ShowSevereError(state, - format("{}=\"{}\" invalid range {}=\"{}\"", - cCurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaFieldNames(3), - state.dataIPShortCut->cAlphaArgs(7))); - ShowContinueError(state, "..contains values outside of range [0,1]."); - ErrorsFound = true; - } - } - } - if (state.dataIPShortCut->lAlphaFieldBlanks(8)) { - ShowSevereError(state, format("{} \"{}\" is required, but blank.", cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(8))); - ErrorsFound = true; - } else { - state.dataContaminantBalance->ContaminantControlledZone(ContControlledZoneNum).GCSetPointSchedName = - state.dataIPShortCut->cAlphaArgs(8); - state.dataContaminantBalance->ContaminantControlledZone(ContControlledZoneNum).GCSPSchedIndex = - GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(8)); - if (state.dataContaminantBalance->ContaminantControlledZone(ContControlledZoneNum).GCSPSchedIndex == 0) { - ShowSevereError(state, - format("{}=\"{}\" invalid {}=\"{}\" not found.", - cCurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaFieldNames(8), - state.dataIPShortCut->cAlphaArgs(8))); - ErrorsFound = true; - } - } + + if (NumAlphas <= 6 || state.dataIPShortCut->lAlphaFieldBlanks(7)) { + controlledZone.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((controlledZone.availSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(7))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(7), state.dataIPShortCut->cAlphaArgs(7)); + ErrorsFound = true; + } else if (!controlledZone.availSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) { + Sched::ShowSevereBadMinMax(state, eoh, state.dataIPShortCut->cAlphaFieldNames(7), state.dataIPShortCut->cAlphaArgs(7), + Clusive::In, 0.0, Clusive::In, 1.0); + ErrorsFound = true; + } + + if (state.dataIPShortCut->lAlphaFieldBlanks(8)) { + ShowSevereEmptyField(state, eoh, state.dataIPShortCut->cAlphaArgs(8)); + ErrorsFound = true; + } else if ((controlledZone.setptSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(8))) == nullptr) { + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(8), state.dataIPShortCut->cAlphaArgs(8)); + ErrorsFound = true; } } // ContControlledZoneNum @@ -1507,13 +1180,11 @@ void InitZoneContSetPoints(EnergyPlusData &state) bool ErrorsFound(false); if (state.dataContaminantBalance->Contaminant.CO2Simulation) { - state.dataContaminantBalance->OutdoorCO2 = - ScheduleManager::GetCurrentScheduleValue(state, state.dataContaminantBalance->Contaminant.CO2OutdoorSchedPtr); + state.dataContaminantBalance->OutdoorCO2 = state.dataContaminantBalance->Contaminant.CO2OutdoorSched->getCurrentVal(); } if (state.dataContaminantBalance->Contaminant.GenericContamSimulation) { - state.dataContaminantBalance->OutdoorGC = - ScheduleManager::GetCurrentScheduleValue(state, state.dataContaminantBalance->Contaminant.GenericContamOutdoorSchedPtr); + state.dataContaminantBalance->OutdoorGC = state.dataContaminantBalance->Contaminant.genericOutdoorSched->getCurrentVal(); } if (state.dataZoneContaminantPredictorCorrector->MyOneTimeFlag) { @@ -1697,7 +1368,7 @@ void InitZoneContSetPoints(EnergyPlusData &state) } if (!state.dataContaminantBalance->ZoneContamGenericDecay.empty()) for (auto &e : state.dataContaminantBalance->ZoneContamGenericDecay) - e.GCTime = 0.0; + e.Time = 0.0; } state.dataZoneContaminantPredictorCorrector->MyEnvrnFlag = false; } @@ -1753,12 +1424,12 @@ void InitZoneContSetPoints(EnergyPlusData &state) if (state.dataContaminantBalance->Contaminant.CO2Simulation) { int ZoneNum = state.dataContaminantBalance->ContaminantControlledZone(Loop).ActualZoneNum; state.dataContaminantBalance->ZoneCO2SetPoint(ZoneNum) = - ScheduleManager::GetCurrentScheduleValue(state, state.dataContaminantBalance->ContaminantControlledZone(Loop).SPSchedIndex); + state.dataContaminantBalance->ContaminantControlledZone(Loop).setptSched->getCurrentVal(); } if (state.dataContaminantBalance->Contaminant.GenericContamSimulation) { int ZoneNum = state.dataContaminantBalance->ContaminantControlledZone(Loop).ActualZoneNum; state.dataContaminantBalance->ZoneGCSetPoint(ZoneNum) = - ScheduleManager::GetCurrentScheduleValue(state, state.dataContaminantBalance->ContaminantControlledZone(Loop).GCSPSchedIndex); + state.dataContaminantBalance->ContaminantControlledZone(Loop).setptSched->getCurrentVal(); } } @@ -1781,10 +1452,10 @@ void InitZoneContSetPoints(EnergyPlusData &state) // from constant model for (auto &con : state.dataContaminantBalance->ZoneContamGenericConstant) { int ZoneNum = con.ActualZoneNum; - GCGain = con.GCGenerateRate * ScheduleManager::GetCurrentScheduleValue(state, con.GCGenerateRateSchedPtr) - - con.GCRemovalCoef * ScheduleManager::GetCurrentScheduleValue(state, con.GCRemovalCoefSchedPtr) * + GCGain = con.GenerateRate * con.generateRateSched->getCurrentVal() - + con.RemovalCoef * con.removalCoefSched->getCurrentVal() * state.dataContaminantBalance->ZoneAirGC(ZoneNum) * 1.0e-6; - con.GCGenRate = GCGain; + con.GenRate = GCGain; } // from pressure driven model @@ -1794,37 +1465,36 @@ void InitZoneContSetPoints(EnergyPlusData &state) Pi = state.afn->AirflowNetworkNodeSimu(state.afn->MultizoneSurfaceData(SurfNum).NodeNums[0]).PZ; Pj = state.afn->AirflowNetworkNodeSimu(state.afn->MultizoneSurfaceData(SurfNum).NodeNums[1]).PZ; if (Pj >= Pi) { - GCGain = con.GCGenRateCoef * ScheduleManager::GetCurrentScheduleValue(state, con.GCGenRateCoefSchedPtr) * - std::pow(Pj - Pi, con.GCExpo); + GCGain = con.GenRateCoef * con.generateRateCoefSched->getCurrentVal() * std::pow(Pj - Pi, con.Expo); } else { GCGain = 0.0; } - con.GCGenRate = GCGain; + con.GenRate = GCGain; } } // from cutoff model for (auto &con : state.dataContaminantBalance->ZoneContamGenericCutoff) { int ZoneNum = con.ActualZoneNum; - if (state.dataContaminantBalance->ZoneAirGC(ZoneNum) < con.GCCutoffValue) { - GCGain = con.GCGenerateRate * ScheduleManager::GetCurrentScheduleValue(state, con.GCGenerateRateSchedPtr) * - (1.0 - state.dataContaminantBalance->ZoneAirGC(ZoneNum) / con.GCCutoffValue); + if (state.dataContaminantBalance->ZoneAirGC(ZoneNum) < con.CutoffValue) { + GCGain = con.GenerateRate * con.generateRateSched->getCurrentVal() * + (1.0 - state.dataContaminantBalance->ZoneAirGC(ZoneNum) / con.CutoffValue); } else { GCGain = 0.0; } - con.GCGenRate = GCGain; + con.GenRate = GCGain; } // From decay model for (auto &con : state.dataContaminantBalance->ZoneContamGenericDecay) { - int Sch = ScheduleManager::GetCurrentScheduleValue(state, con.GCEmiRateSchedPtr); - if (Sch == 0.0 || state.dataGlobal->BeginEnvrnFlag || state.dataGlobal->WarmupFlag) { - con.GCTime = 0.0; + int Sch = con.emitRateSched->getCurrentVal(); + if (Sch == 0 || state.dataGlobal->BeginEnvrnFlag || state.dataGlobal->WarmupFlag) { + con.Time = 0.0; } else { - con.GCTime += state.dataGlobal->TimeStepZoneSec; + con.Time += state.dataGlobal->TimeStepZoneSec; } - GCGain = con.GCInitEmiRate * Sch * std::exp(-con.GCTime / con.GCDelayTime); - con.GCGenRate = GCGain; + GCGain = con.InitEmitRate * Sch * std::exp(-con.Time / con.DelayTime); + con.GenRate = GCGain; } // From boudary layer diffusion @@ -1833,10 +1503,10 @@ void InitZoneContSetPoints(EnergyPlusData &state) int ZoneNum = state.dataSurface->Surface(SurfNum).Zone; // Surface concentration level for the Boundary Layer Diffusion Controlled Model Real64 Cs = state.dataSurface->SurfGenericContam(SurfNum); - Sch = ScheduleManager::GetCurrentScheduleValue(state, con.GCTranCoefSchedPtr); - GCGain = con.GCTranCoef * Sch * state.dataSurface->Surface(SurfNum).Area * state.dataSurface->Surface(SurfNum).Multiplier * - (Cs / con.GCHenryCoef - state.dataContaminantBalance->ZoneAirGC(ZoneNum)) * 1.0e-6; - con.GCGenRate = GCGain; + Sch = con.transCoefSched->getCurrentVal(); + GCGain = con.TransCoef * Sch * state.dataSurface->Surface(SurfNum).Area * state.dataSurface->Surface(SurfNum).Multiplier * + (Cs / con.HenryCoef - state.dataContaminantBalance->ZoneAirGC(ZoneNum)) * 1.0e-6; + con.GenRate = GCGain; // Surface concentration level based on steady-state assumption state.dataSurface->SurfGenericContam(SurfNum) = Cs - GCGain * 1.0e6 / state.dataSurface->Surface(SurfNum).Multiplier / state.dataSurface->Surface(SurfNum).Area; @@ -1846,18 +1516,18 @@ void InitZoneContSetPoints(EnergyPlusData &state) for (auto &con : state.dataContaminantBalance->ZoneContamGenericDVS) { int SurfNum = con.SurfNum; int ZoneNum = state.dataSurface->Surface(SurfNum).Zone; - Sch = ScheduleManager::GetCurrentScheduleValue(state, con.GCDepoVeloPtr); - GCGain = -con.GCDepoVelo * state.dataSurface->Surface(SurfNum).Area * Sch * state.dataContaminantBalance->ZoneAirGC(ZoneNum) * + Sch = con.depoVeloSched->getCurrentVal(); + GCGain = -con.DepoVelo * state.dataSurface->Surface(SurfNum).Area * Sch * state.dataContaminantBalance->ZoneAirGC(ZoneNum) * state.dataSurface->Surface(SurfNum).Multiplier * 1.0e-6; - con.GCGenRate = GCGain; + con.GenRate = GCGain; } // From deposition rate sink model for (auto &con : state.dataContaminantBalance->ZoneContamGenericDRS) { int ZoneNum = con.ActualZoneNum; - Sch = ScheduleManager::GetCurrentScheduleValue(state, con.GCDepoRatePtr); - GCGain = -con.GCDepoRate * state.dataHeatBal->Zone(ZoneNum).Volume * Sch * state.dataContaminantBalance->ZoneAirGC(ZoneNum) * 1.0e-6; - con.GCGenRate = GCGain; + Sch = con.depoRateSched->getCurrentVal(); + GCGain = -con.DepoRate * state.dataHeatBal->Zone(ZoneNum).Volume * Sch * state.dataContaminantBalance->ZoneAirGC(ZoneNum) * 1.0e-6; + con.GenRate = GCGain; } } } @@ -1890,6 +1560,7 @@ void PredictZoneContaminants(EnergyPlusData &state, Real64 ZoneAirGCSetPoint; // Zone generic contaminant setpoint Real64 GCGain; // Zone generic contaminant internal load + Real64 timeStepSysSec = state.dataHVACGlobal->TimeStepSysSec; // Update zone CO2 for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) { auto &thisZoneHB = state.dataZoneTempPredictorCorrector->zoneHeatBalance(ZoneNum); @@ -2001,7 +1672,7 @@ void PredictZoneContaminants(EnergyPlusData &state, // Check all the controlled zones to see if it matches the zone simulated for (auto const &contaminantControlledZone : state.dataContaminantBalance->ContaminantControlledZone) { if (contaminantControlledZone.ActualZoneNum == ZoneNum) { - if (ScheduleManager::GetCurrentScheduleValue(state, contaminantControlledZone.AvaiSchedPtr) > 0.0) { + if (contaminantControlledZone.availSched->getCurrentVal() > 0.0) { ZoneAirCO2SetPoint = state.dataContaminantBalance->ZoneCO2SetPoint(contaminantControlledZone.ActualZoneNum); if (contaminantControlledZone.EMSOverrideCO2SetPointOn) { ZoneAirCO2SetPoint = contaminantControlledZone.EMSOverrideCO2SetPointValue; @@ -2013,7 +1684,7 @@ void PredictZoneContaminants(EnergyPlusData &state, } if (!ControlledCO2ZoneFlag) { for (auto const &contaminantControlledZone : state.dataContaminantBalance->ContaminantControlledZone) { - if (ScheduleManager::GetCurrentScheduleValue(state, contaminantControlledZone.AvaiSchedPtr) > 0.0) { + if (contaminantControlledZone.availSched->getCurrentVal() > 0.0) { ZoneAirCO2SetPoint = state.dataContaminantBalance->ZoneCO2SetPoint(contaminantControlledZone.ActualZoneNum); if (contaminantControlledZone.EMSOverrideCO2SetPointOn) { ZoneAirCO2SetPoint = contaminantControlledZone.EMSOverrideCO2SetPointValue; @@ -2046,8 +1717,6 @@ void PredictZoneContaminants(EnergyPlusData &state, // Calculate Co2 from infiltration + humidity added from latent load to determine system added/subtracted moisture. Real64 CO2Gain = state.dataContaminantBalance->ZoneCO2Gain(ZoneNum) * RhoAir * 1.0e6; - Real64 SysTimeStepInSeconds = Constant::SecInHour * state.dataHVACGlobal->TimeStepSys; - // Calculate the coefficients for the 3rd Order derivative for final // zone CO2. The A, B, C coefficients are analogous to the CO2 balance. // Assume that the system will have flow @@ -2064,7 +1733,7 @@ void PredictZoneContaminants(EnergyPlusData &state, state.dataContaminantBalance->MixingMassFlowCO2(ZoneNum) + thisZoneHB.MDotOA * state.dataContaminantBalance->OutdoorCO2; A = thisZoneHB.OAMFL + thisZoneHB.VAMFL + thisZoneHB.EAMFL + thisZoneHB.CTMFL + thisZoneHB.MixingMassFlowZone + thisZoneHB.MDotOA; } - C = RhoAir * state.dataHeatBal->Zone(ZoneNum).Volume * state.dataHeatBal->Zone(ZoneNum).ZoneVolCapMultpCO2 / SysTimeStepInSeconds; + C = RhoAir * state.dataHeatBal->Zone(ZoneNum).Volume * state.dataHeatBal->Zone(ZoneNum).ZoneVolCapMultpCO2 / timeStepSysSec; // Use a 3rd Order derivative to predict zone moisture addition or removal and // smooth the changes using the zone air capacitance. Positive values of CO2 Load means that @@ -2117,7 +1786,7 @@ void PredictZoneContaminants(EnergyPlusData &state, // Check all the controlled zones to see if it matches the zone simulated for (auto const &contaminantControlledZone : state.dataContaminantBalance->ContaminantControlledZone) { if (contaminantControlledZone.ActualZoneNum == ZoneNum) { - if (ScheduleManager::GetCurrentScheduleValue(state, contaminantControlledZone.AvaiSchedPtr) > 0.0) { + if (contaminantControlledZone.availSched->getCurrentVal() > 0.0) { ZoneAirGCSetPoint = state.dataContaminantBalance->ZoneGCSetPoint(contaminantControlledZone.ActualZoneNum); if (contaminantControlledZone.EMSOverrideCO2SetPointOn) { ZoneAirGCSetPoint = contaminantControlledZone.EMSOverrideGCSetPointValue; @@ -2129,7 +1798,7 @@ void PredictZoneContaminants(EnergyPlusData &state, } if (!ControlledGCZoneFlag) { for (auto const &contaminantControlledZone : state.dataContaminantBalance->ContaminantControlledZone) { - if (ScheduleManager::GetCurrentScheduleValue(state, contaminantControlledZone.AvaiSchedPtr) > 0.0) { + if (contaminantControlledZone.availSched->getCurrentVal() > 0.0) { ZoneAirGCSetPoint = state.dataContaminantBalance->ZoneGCSetPoint(contaminantControlledZone.ActualZoneNum); if (contaminantControlledZone.EMSOverrideCO2SetPointOn) { ZoneAirGCSetPoint = contaminantControlledZone.EMSOverrideGCSetPointValue; @@ -2160,8 +1829,6 @@ void PredictZoneContaminants(EnergyPlusData &state, // to determine system added/subtracted moisture. GCGain = state.dataContaminantBalance->ZoneGCGain(ZoneNum) * RhoAir * 1.0e6; - Real64 SysTimeStepInSeconds = Constant::SecInHour * state.dataHVACGlobal->TimeStepSys; - // Calculate the coefficients for the 3rd Order derivative for final // zone GC. The A, B, C coefficients are analogous to the GC balance. // Assume that the system will have flow @@ -2179,7 +1846,7 @@ void PredictZoneContaminants(EnergyPlusData &state, A = thisZoneHB.OAMFL + thisZoneHB.VAMFL + thisZoneHB.EAMFL + thisZoneHB.CTMFL + thisZoneHB.MixingMassFlowZone + thisZoneHB.MDotOA; } C = RhoAir * state.dataHeatBal->Zone(ZoneNum).Volume * state.dataHeatBal->Zone(ZoneNum).ZoneVolCapMultpGenContam / - SysTimeStepInSeconds; + timeStepSysSec; // Use a 3rd Order derivative to predict zone moisture addition or removal and // smooth the changes using the zone air capacitance. Positive values of GC Load means that @@ -2353,25 +2020,23 @@ void InverseModelCO2(EnergyPlusData &state, Real64 BB(0.0); Real64 M_inf(0.0); // Reversely solved infiltration mass flow rate - Real64 SysTimeStepInSeconds(0.0); - SysTimeStepInSeconds = Constant::SecInHour * state.dataHVACGlobal->TimeStepSys; + Real64 timeStepSysSec = state.dataHVACGlobal->TimeStepSysSec; + + auto &hmZone = state.dataHybridModel->hybridModelZones(ZoneNum); + + state.dataHeatBal->Zone(ZoneNum).ZoneMeasuredCO2Concentration = hmZone.measuredCO2ConcSched->getCurrentVal(); - state.dataHeatBal->Zone(ZoneNum).ZoneMeasuredCO2Concentration = - ScheduleManager::GetCurrentScheduleValue(state, state.dataHybridModel->HybridModelZone(ZoneNum).ZoneMeasuredCO2ConcentrationSchedulePtr); - - if (state.dataEnvrn->DayOfYear >= state.dataHybridModel->HybridModelZone(ZoneNum).HybridStartDayOfYear && - state.dataEnvrn->DayOfYear <= state.dataHybridModel->HybridModelZone(ZoneNum).HybridEndDayOfYear) { + if (state.dataEnvrn->DayOfYear >= hmZone.HybridStartDayOfYear && + state.dataEnvrn->DayOfYear <= hmZone.HybridEndDayOfYear) { state.dataContaminantBalance->ZoneAirCO2(ZoneNum) = state.dataHeatBal->Zone(ZoneNum).ZoneMeasuredCO2Concentration; auto &thisZoneHB = state.dataZoneTempPredictorCorrector->zoneHeatBalance(ZoneNum); - if (state.dataHybridModel->HybridModelZone(ZoneNum).InfiltrationCalc_C && state.dataHVACGlobal->UseZoneTimeStepHistory) { + if (hmZone.InfiltrationCalc_C && state.dataHVACGlobal->UseZoneTimeStepHistory) { static constexpr std::string_view RoutineNameInfiltration("CalcAirFlowSimple:Infiltration"); // Conditionally calculate the CO2-dependent and CO2-independent terms. - if (state.dataHybridModel->HybridModelZone(ZoneNum).IncludeSystemSupplyParameters) { - state.dataHeatBal->Zone(ZoneNum).ZoneMeasuredSupplyAirFlowRate = ScheduleManager::GetCurrentScheduleValue( - state, state.dataHybridModel->HybridModelZone(ZoneNum).ZoneSupplyAirMassFlowRateSchedulePtr); - state.dataHeatBal->Zone(ZoneNum).ZoneMeasuredSupplyAirCO2Concentration = ScheduleManager::GetCurrentScheduleValue( - state, state.dataHybridModel->HybridModelZone(ZoneNum).ZoneSupplyAirCO2ConcentrationSchedulePtr); + if (hmZone.IncludeSystemSupplyParameters) { + state.dataHeatBal->Zone(ZoneNum).ZoneMeasuredSupplyAirFlowRate = hmZone.supplyAirMassFlowRateSched->getCurrentVal(); + state.dataHeatBal->Zone(ZoneNum).ZoneMeasuredSupplyAirCO2Concentration = hmZone.supplyAirCO2ConcSched->getCurrentVal(); Real64 SumSysM_HM = state.dataHeatBal->Zone(ZoneNum).ZoneMeasuredSupplyAirFlowRate; Real64 SumSysMxCO2_HM = state.dataHeatBal->Zone(ZoneNum).ZoneMeasuredSupplyAirFlowRate * @@ -2388,7 +2053,7 @@ void InverseModelCO2(EnergyPlusData &state, state.dataContaminantBalance->MixingMassFlowCO2(ZoneNum) + thisZoneHB.MDotOA * state.dataContaminantBalance->OutdoorCO2; } - Real64 CC = RhoAir * state.dataHeatBal->Zone(ZoneNum).Volume * state.dataHeatBal->Zone(ZoneNum).ZoneVolCapMultpCO2 / SysTimeStepInSeconds; + Real64 CC = RhoAir * state.dataHeatBal->Zone(ZoneNum).Volume * state.dataHeatBal->Zone(ZoneNum).ZoneVolCapMultpCO2 / timeStepSysSec; Real64 DD = (3.0 * state.dataContaminantBalance->CO2ZoneTimeMinus1Temp(ZoneNum) - (3.0 / 2.0) * state.dataContaminantBalance->CO2ZoneTimeMinus2Temp(ZoneNum) + (1.0 / 3.0) * state.dataContaminantBalance->CO2ZoneTimeMinus3Temp(ZoneNum)); @@ -2408,20 +2073,17 @@ void InverseModelCO2(EnergyPlusData &state, } // Add threshold for air change rate - Real64 ACH_inf = max(0.0, min(10.0, M_inf / (CpAir * AirDensity / Constant::SecInHour * state.dataHeatBal->Zone(ZoneNum).Volume))); - M_inf = ACH_inf * state.dataHeatBal->Zone(ZoneNum).Volume * AirDensity / Constant::SecInHour; + Real64 ACH_inf = max(0.0, min(10.0, M_inf / (CpAir * AirDensity / Constant::rSecsInHour * state.dataHeatBal->Zone(ZoneNum).Volume))); + M_inf = ACH_inf * state.dataHeatBal->Zone(ZoneNum).Volume * AirDensity / Constant::rSecsInHour; state.dataHeatBal->Zone(ZoneNum).MCPIHM = M_inf; state.dataHeatBal->Zone(ZoneNum).InfilOAAirChangeRateHM = ACH_inf; } // Hybrid Model calculate people count - if (state.dataHybridModel->HybridModelZone(ZoneNum).PeopleCountCalc_C && state.dataHVACGlobal->UseZoneTimeStepHistory) { - state.dataHeatBal->Zone(ZoneNum).ZonePeopleActivityLevel = - ScheduleManager::GetCurrentScheduleValue(state, state.dataHybridModel->HybridModelZone(ZoneNum).ZonePeopleActivityLevelSchedulePtr); - Real64 ActivityLevel = - ScheduleManager::GetCurrentScheduleValue(state, state.dataHybridModel->HybridModelZone(ZoneNum).ZonePeopleActivityLevelSchedulePtr); - Real64 CO2GenRate = - ScheduleManager::GetCurrentScheduleValue(state, state.dataHybridModel->HybridModelZone(ZoneNum).ZonePeopleCO2GenRateSchedulePtr); + if (hmZone.PeopleCountCalc_C && state.dataHVACGlobal->UseZoneTimeStepHistory) { + state.dataHeatBal->Zone(ZoneNum).ZonePeopleActivityLevel = hmZone.peopleActivityLevelSched ? hmZone.peopleActivityLevelSched->getCurrentVal() : 0.0; + Real64 ActivityLevel = hmZone.peopleActivityLevelSched ? hmZone.peopleActivityLevelSched->getCurrentVal() : 0.0; + Real64 CO2GenRate = hmZone.peopleCO2GenRateSched ? hmZone.peopleCO2GenRateSched->getCurrentVal() : 0.0; if (ActivityLevel <= 0.0) { ActivityLevel = 130.0; // 130.0 is the default people activity level [W] } @@ -2430,11 +2092,9 @@ void InverseModelCO2(EnergyPlusData &state, } // Conditionally calculate the CO2-dependent and CO2-independent terms. - if (state.dataHybridModel->HybridModelZone(ZoneNum).IncludeSystemSupplyParameters) { - state.dataHeatBal->Zone(ZoneNum).ZoneMeasuredSupplyAirFlowRate = ScheduleManager::GetCurrentScheduleValue( - state, state.dataHybridModel->HybridModelZone(ZoneNum).ZoneSupplyAirMassFlowRateSchedulePtr); - state.dataHeatBal->Zone(ZoneNum).ZoneMeasuredSupplyAirCO2Concentration = ScheduleManager::GetCurrentScheduleValue( - state, state.dataHybridModel->HybridModelZone(ZoneNum).ZoneSupplyAirCO2ConcentrationSchedulePtr); + if (hmZone.IncludeSystemSupplyParameters) { + state.dataHeatBal->Zone(ZoneNum).ZoneMeasuredSupplyAirFlowRate = hmZone.supplyAirMassFlowRateSched->getCurrentVal(); + state.dataHeatBal->Zone(ZoneNum).ZoneMeasuredSupplyAirCO2Concentration = hmZone.supplyAirCO2ConcSched->getCurrentVal(); Real64 SumSysM_HM = state.dataHeatBal->Zone(ZoneNum).ZoneMeasuredSupplyAirFlowRate; Real64 SumSysMxCO2_HM = state.dataHeatBal->Zone(ZoneNum).ZoneMeasuredSupplyAirFlowRate * @@ -2456,7 +2116,7 @@ void InverseModelCO2(EnergyPlusData &state, thisZoneHB.MDotOA * state.dataContaminantBalance->OutdoorCO2; } - Real64 CC = RhoAir * state.dataHeatBal->Zone(ZoneNum).Volume * state.dataHeatBal->Zone(ZoneNum).ZoneVolCapMultpCO2 / SysTimeStepInSeconds; + Real64 CC = RhoAir * state.dataHeatBal->Zone(ZoneNum).Volume * state.dataHeatBal->Zone(ZoneNum).ZoneVolCapMultpCO2 / timeStepSysSec; Real64 DD = (3.0 * state.dataContaminantBalance->CO2ZoneTimeMinus1Temp(ZoneNum) - (3.0 / 2.0) * state.dataContaminantBalance->CO2ZoneTimeMinus2Temp(ZoneNum) + (1.0 / 3.0) * state.dataContaminantBalance->CO2ZoneTimeMinus3Temp(ZoneNum)); @@ -2635,9 +2295,9 @@ void CorrectZoneContaminants(EnergyPlusData &state, ZoneMassFlowRate += node.MassFlowRate / ZoneMult; } - Real64 SysTimeStepInSeconds = Constant::SecInHour * state.dataHVACGlobal->TimeStepSys; + Real64 timeStepSysSec = state.dataHVACGlobal->TimeStepSysSec; auto &thisZoneHB = state.dataZoneTempPredictorCorrector->zoneHeatBalance(ZoneNum); - + // Calculate the coefficients for the 3rd order derivative for final // zone humidity ratio. The A, B, C coefficients are analogous to the // CO2 balance. There are 2 cases that should be considered, system operating and system shutdown. @@ -2665,7 +2325,7 @@ void CorrectZoneContaminants(EnergyPlusData &state, B = CO2Gain + (state.afn->exchangeData(ZoneNum).SumMHrCO + state.afn->exchangeData(ZoneNum).SumMMHrCO) + CO2MassFlowRate; A = ZoneMassFlowRate + state.afn->exchangeData(ZoneNum).SumMHr + state.afn->exchangeData(ZoneNum).SumMMHr; } - C = RhoAir * state.dataHeatBal->Zone(ZoneNum).Volume * state.dataHeatBal->Zone(ZoneNum).ZoneVolCapMultpCO2 / SysTimeStepInSeconds; + C = RhoAir * state.dataHeatBal->Zone(ZoneNum).Volume * state.dataHeatBal->Zone(ZoneNum).ZoneVolCapMultpCO2 / timeStepSysSec; } if (state.dataContaminantBalance->Contaminant.CO2Simulation) { @@ -2706,8 +2366,8 @@ void CorrectZoneContaminants(EnergyPlusData &state, state.dataContaminantBalance->ZoneAirCO2(ZoneNum) = zoneAirCO2Temp; if (state.dataHybridModel->FlagHybridModel) { - if ((state.dataHybridModel->HybridModelZone(ZoneNum).InfiltrationCalc_C || - state.dataHybridModel->HybridModelZone(ZoneNum).PeopleCountCalc_C) && + auto &hmZone = state.dataHybridModel->hybridModelZones(ZoneNum); + if ((hmZone.InfiltrationCalc_C || hmZone.PeopleCountCalc_C) && (!state.dataGlobal->WarmupFlag) && (!state.dataGlobal->DoingSizing)) { InverseModelCO2(state, ZoneNum, CO2Gain, CO2GainExceptPeople, ZoneMassFlowRate, CO2MassFlowRate, RhoAir); } @@ -2732,7 +2392,7 @@ void CorrectZoneContaminants(EnergyPlusData &state, B = GCGain + (state.afn->exchangeData(ZoneNum).SumMHrGC + state.afn->exchangeData(ZoneNum).SumMMHrGC) + GCMassFlowRate; A = ZoneMassFlowRate + state.afn->exchangeData(ZoneNum).SumMHr + state.afn->exchangeData(ZoneNum).SumMMHr; } - C = RhoAir * state.dataHeatBal->Zone(ZoneNum).Volume * state.dataHeatBal->Zone(ZoneNum).ZoneVolCapMultpGenContam / SysTimeStepInSeconds; + C = RhoAir * state.dataHeatBal->Zone(ZoneNum).Volume * state.dataHeatBal->Zone(ZoneNum).ZoneVolCapMultpGenContam / timeStepSysSec; } if (state.dataContaminantBalance->Contaminant.GenericContamSimulation) { diff --git a/src/EnergyPlus/ZoneContaminantPredictorCorrector.hh b/src/EnergyPlus/ZoneContaminantPredictorCorrector.hh index 0201ede7c4d..b76f3b63ddf 100644 --- a/src/EnergyPlus/ZoneContaminantPredictorCorrector.hh +++ b/src/EnergyPlus/ZoneContaminantPredictorCorrector.hh @@ -108,6 +108,10 @@ struct ZoneContaminantPredictorCorrectorData : BaseGlobalStruct bool MyEnvrnFlag = true; bool MyConfigOneTimeFlag = true; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/ZoneDehumidifier.cc b/src/EnergyPlus/ZoneDehumidifier.cc index 95ec5aa25d2..94766cb7a27 100644 --- a/src/EnergyPlus/ZoneDehumidifier.cc +++ b/src/EnergyPlus/ZoneDehumidifier.cc @@ -108,7 +108,6 @@ namespace ZoneDehumidifier { // Using/Aliasing using namespace DataLoopNode; - using namespace ScheduleManager; void SimZoneDehumidifier(EnergyPlusData &state, std::string const &CompName, // Name of the zone dehumidifier @@ -204,7 +203,7 @@ namespace ZoneDehumidifier { using WaterManager::SetupTankSupplyComponent; // SUBROUTINE PARAMETER DEFINITIONS: - static constexpr std::string_view RoutineName("GetZoneDehumidifierInput"); + static constexpr std::string_view routineName = "GetZoneDehumidifierInput"; static std::string const CurrentModuleObject("ZoneHVAC:Dehumidifier:DX"); Real64 constexpr RatedInletAirTemp(26.7); Real64 constexpr RatedInletAirRH(60.0); @@ -251,6 +250,9 @@ namespace ZoneDehumidifier { lAlphaBlanks, cAlphaFields, cNumericFields); + + ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)}; + Util::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound); // A1, \field Name @@ -259,16 +261,10 @@ namespace ZoneDehumidifier { // A2, \field Availability Schedule Name if (lAlphaBlanks(2)) { - state.dataZoneDehumidifier->ZoneDehumid(ZoneDehumidIndex).SchedPtr = ScheduleManager::ScheduleAlwaysOn; - } else { - state.dataZoneDehumidifier->ZoneDehumid(ZoneDehumidIndex).SchedPtr = - GetScheduleIndex(state, Alphas(2)); // Convert schedule name to pointer - if (state.dataZoneDehumidifier->ZoneDehumid(ZoneDehumidIndex).SchedPtr == 0) { - ShowSevereError(state, format("{} not found = {}", cAlphaFields(2), Alphas(2))); - ShowContinueError( - state, format("Occurs in {} = {}", CurrentModuleObject, state.dataZoneDehumidifier->ZoneDehumid(ZoneDehumidIndex).Name)); - ErrorsFound = true; - } + state.dataZoneDehumidifier->ZoneDehumid(ZoneDehumidIndex).availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((state.dataZoneDehumidifier->ZoneDehumid(ZoneDehumidIndex).availSched = Sched::GetSchedule(state, Alphas(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, cAlphaFields(2), Alphas(2)); + ErrorsFound = true; } // A3 , \field Air Inlet Node Name @@ -330,17 +326,9 @@ namespace ZoneDehumidifier { GetCurveIndex(state, Alphas(5)); // Convert curve name to index number if (state.dataZoneDehumidifier->ZoneDehumid(ZoneDehumidIndex).WaterRemovalCurveIndex == 0) { if (lAlphaBlanks(5)) { - ShowSevereError(state, - format("{}:{}=\"{}\" is required, missing for {} = {}", - RoutineName, - CurrentModuleObject, - cAlphaFields(5), - cAlphaFields(1), - state.dataZoneDehumidifier->ZoneDehumid(ZoneDehumidIndex).Name)); + ShowSevereEmptyField(state, eoh, cAlphaFields(5)); } else { - ShowSevereError(state, format("{} not found = {}", cAlphaFields(5), Alphas(5))); - ShowContinueError( - state, format("Occurs in {} = {}", CurrentModuleObject, state.dataZoneDehumidifier->ZoneDehumid(ZoneDehumidIndex).Name)); + ShowSevereItemNotFound(state, eoh, cAlphaFields(5), Alphas(5)); } ErrorsFound = true; } else { @@ -348,7 +336,7 @@ namespace ZoneDehumidifier { ErrorsFound |= Curve::CheckCurveDims(state, state.dataZoneDehumidifier->ZoneDehumid(ZoneDehumidIndex).WaterRemovalCurveIndex, // Curve index {2}, // Valid dimensions - RoutineName, // Routine name + routineName, // Routine name CurrentModuleObject, // Object Type state.dataZoneDehumidifier->ZoneDehumid(ZoneDehumidIndex).Name, // Object Name cAlphaFields(5)); // Field Name @@ -369,17 +357,9 @@ namespace ZoneDehumidifier { GetCurveIndex(state, Alphas(6)); // convert curve name to number if (state.dataZoneDehumidifier->ZoneDehumid(ZoneDehumidIndex).EnergyFactorCurveIndex == 0) { if (lAlphaBlanks(6)) { - ShowSevereError(state, - format("{}:{}=\"{}\" is required, missing for {} = {}", - RoutineName, - CurrentModuleObject, - cAlphaFields(6), - cAlphaFields(1), - state.dataZoneDehumidifier->ZoneDehumid(ZoneDehumidIndex).Name)); + ShowSevereEmptyField(state, eoh, cAlphaFields(6)); } else { - ShowSevereError(state, format("{} not found = {}", cAlphaFields(6), Alphas(6))); - ShowContinueError( - state, format("Occurs in {} = {}", CurrentModuleObject, state.dataZoneDehumidifier->ZoneDehumid(ZoneDehumidIndex).Name)); + ShowSevereItemNotFound(state, eoh, cAlphaFields(6), Alphas(6)); } ErrorsFound = true; } else { @@ -387,7 +367,7 @@ namespace ZoneDehumidifier { ErrorsFound |= Curve::CheckCurveDims(state, state.dataZoneDehumidifier->ZoneDehumid(ZoneDehumidIndex).EnergyFactorCurveIndex, // Curve index {2}, // Valid dimensions - RoutineName, // Routine name + routineName, // Routine name CurrentModuleObject, // Object Type state.dataZoneDehumidifier->ZoneDehumid(ZoneDehumidIndex).Name, // Object Name cAlphaFields(6)); // Field Name @@ -408,17 +388,9 @@ namespace ZoneDehumidifier { GetCurveIndex(state, Alphas(7)); // convert curve name to number if (state.dataZoneDehumidifier->ZoneDehumid(ZoneDehumidIndex).PartLoadCurveIndex == 0) { if (lAlphaBlanks(7)) { - ShowSevereError(state, - format("{}:{}=\"{}\" is required, missing for {} = {}", - RoutineName, - CurrentModuleObject, - cAlphaFields(7), - cAlphaFields(1), - state.dataZoneDehumidifier->ZoneDehumid(ZoneDehumidIndex).Name)); + ShowSevereEmptyField(state, eoh, cAlphaFields(7)); } else { - ShowSevereError(state, format("{} not found = {}", cAlphaFields(7), Alphas(7))); - ShowContinueError( - state, format("Occurs in {} = {}", CurrentModuleObject, state.dataZoneDehumidifier->ZoneDehumid(ZoneDehumidIndex).Name)); + ShowSevereItemNotFound(state, eoh, cAlphaFields(7), Alphas(7)); } ErrorsFound = true; } else { @@ -426,7 +398,7 @@ namespace ZoneDehumidifier { ErrorsFound |= Curve::CheckCurveDims(state, state.dataZoneDehumidifier->ZoneDehumid(ZoneDehumidIndex).PartLoadCurveIndex, // Curve index {1}, // Valid dimensions - RoutineName, // Routine name + routineName, // Routine name CurrentModuleObject, // Object Type state.dataZoneDehumidifier->ZoneDehumid(ZoneDehumidIndex).Name, // Object Name cAlphaFields(7)); // Field Name @@ -483,7 +455,7 @@ namespace ZoneDehumidifier { lNumericBlanks.deallocate(); if (ErrorsFound) { - ShowFatalError(state, format("{}:{}: Errors found in input.", RoutineName, CurrentModuleObject)); + ShowFatalError(state, format("{}:{}: Errors found in input.", routineName, CurrentModuleObject)); } for (ZoneDehumidIndex = 1; ZoneDehumidIndex <= NumDehumidifiers; ++ZoneDehumidIndex) { @@ -769,7 +741,7 @@ namespace ZoneDehumidifier { InletAirHumRat = state.dataLoopNodes->Node(AirInletNodeNum).HumRat; InletAirRH = 100.0 * PsyRhFnTdbWPb(state, InletAirTemp, InletAirHumRat, state.dataEnvrn->OutBaroPress, RoutineName); // RH in percent (%) - if (QZnDehumidReq < 0.0 && GetCurrentScheduleValue(state, state.dataZoneDehumidifier->ZoneDehumid(ZoneDehumNum).SchedPtr) > 0.0 && + if (QZnDehumidReq < 0.0 && state.dataZoneDehumidifier->ZoneDehumid(ZoneDehumNum).availSched->getCurrentVal() > 0.0 && InletAirTemp >= state.dataZoneDehumidifier->ZoneDehumid(ZoneDehumNum).MinInletAirTemp && InletAirTemp <= state.dataZoneDehumidifier->ZoneDehumid(ZoneDehumNum).MaxInletAirTemp) { // A dehumidification load is being requested and dehumidifier is available (schedule value > 0) @@ -808,7 +780,7 @@ namespace ZoneDehumidifier { WaterRemovalVolRate = WaterRemovalRateFactor * state.dataZoneDehumidifier->ZoneDehumid(ZoneDehumNum).RatedWaterRemoval; WaterRemovalMassRate = - WaterRemovalVolRate / (24.0 * Constant::SecInHour * 1000.0) * + WaterRemovalVolRate / (Constant::rSecsInDay * 1000.0) * RhoH2O(max((InletAirTemp - 11.0), 1.0)); //(L/d)/(24 hr/day *3600 sec/hr * 1000 L/m3) | Density of water, minimum temp = 1.0C if (WaterRemovalMassRate > 0.0) { @@ -990,7 +962,7 @@ namespace ZoneDehumidifier { state.dataLoopNodes->Node(AirInletNodeNum).MassFlowRate = 0.0; // If available but didn't operate, then set electric power = off cycle parasitic load. // Else, electric power = 0.0 - if (GetCurrentScheduleValue(state, state.dataZoneDehumidifier->ZoneDehumid(ZoneDehumNum).SchedPtr) > 0.0) { + if (state.dataZoneDehumidifier->ZoneDehumid(ZoneDehumNum).availSched->getCurrentVal() > 0.0) { ElectricPowerAvg = state.dataZoneDehumidifier->ZoneDehumid(ZoneDehumNum).OffCycleParasiticLoad; // off cycle parasitic is on entire timestep } else { diff --git a/src/EnergyPlus/ZoneDehumidifier.hh b/src/EnergyPlus/ZoneDehumidifier.hh index 1e62add786d..001b2e98dbe 100644 --- a/src/EnergyPlus/ZoneDehumidifier.hh +++ b/src/EnergyPlus/ZoneDehumidifier.hh @@ -76,7 +76,7 @@ namespace ZoneDehumidifier { // input data and others required during calculations std::string Name; // Name of unit std::string UnitType; // Type of unit - int SchedPtr = 0; // Index number to availability schedule + Sched::Schedule *availSched = nullptr; // availability schedule Real64 RatedWaterRemoval = 0.0; // Rated water removal [liters/day] Real64 RatedEnergyFactor = 0.0; // Rated energy factor [liters/kWh] Real64 RatedAirVolFlow = 0.0; // Rated air flow rate through the dehumidifier [m3/s] @@ -162,6 +162,10 @@ struct ZoneDehumidifierData : BaseGlobalStruct bool GetInputFlag = true; // Set to FALSE after first time input is "gotten" EPVector ZoneDehumid; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/ZoneEquipmentManager.cc b/src/EnergyPlus/ZoneEquipmentManager.cc index d321e8965c4..a1877479d29 100644 --- a/src/EnergyPlus/ZoneEquipmentManager.cc +++ b/src/EnergyPlus/ZoneEquipmentManager.cc @@ -182,7 +182,7 @@ void GetZoneEquipment(EnergyPlusData &state) state.dataZoneEquipmentManager->GetZoneEquipmentInputFlag = false; state.dataZoneEquip->ZoneEquipInputsFilled = true; - state.dataZoneEquipmentManager->NumOfTimeStepInDay = state.dataGlobal->NumOfTimeStepInHour * 24; + state.dataZoneEquipmentManager->NumOfTimeStepInDay = state.dataGlobal->TimeStepsInHour * Constant::iHoursInDay; int MaxNumOfEquipTypes = 0; for (int Counter = 1; Counter <= state.dataGlobal->NumOfZones; ++Counter) { @@ -584,19 +584,20 @@ void sizeZoneSpaceEquipmentPart2(EnergyPlusData &state, int zoneNodeNum = (spaceNum > 0) ? state.dataHeatBal->space(spaceNum).SystemZoneNodeNumber : state.dataHeatBal->Zone(zoneNum).SystemZoneNodeNumber; Real64 RetTemp = (returnNodeNum > 0) ? state.dataLoopNodes->Node(returnNodeNum).Temp : state.dataLoopNodes->Node(zoneNodeNum).Temp; - auto &zoneTstatSP = state.dataHeatBalFanSys->TempZoneThermostatSetPoint(zoneNum); + + auto &zoneTstatSetpt = state.dataHeatBalFanSys->zoneTstatSetpts(zoneNum); if (zsCalcSizing.HeatLoad > 0.0) { zsCalcSizing.HeatZoneRetTemp = RetTemp; - zsCalcSizing.HeatTstatTemp = (zoneTstatSP > 0.0) ? zoneTstatSP : state.dataHeatBalFanSys->ZoneThermostatSetPointLo(zoneNum); - zsCalcSizing.CoolTstatTemp = state.dataHeatBalFanSys->ZoneThermostatSetPointHi(zoneNum); + zsCalcSizing.HeatTstatTemp = (zoneTstatSetpt.setpt > 0.0) ? zoneTstatSetpt.setpt : zoneTstatSetpt.setptLo; + zsCalcSizing.CoolTstatTemp = zoneTstatSetpt.setptHi; } else if (zsCalcSizing.CoolLoad > 0.0) { zsCalcSizing.CoolZoneRetTemp = RetTemp; - zsCalcSizing.CoolTstatTemp = (zoneTstatSP > 0.0) ? zoneTstatSP : state.dataHeatBalFanSys->ZoneThermostatSetPointHi(zoneNum); - zsCalcSizing.HeatTstatTemp = state.dataHeatBalFanSys->ZoneThermostatSetPointLo(zoneNum); + zsCalcSizing.CoolTstatTemp = (zoneTstatSetpt.setpt > 0.0) ? zoneTstatSetpt.setpt : zoneTstatSetpt.setptHi; + zsCalcSizing.HeatTstatTemp = zoneTstatSetpt.setptLo; } else { zsCalcSizing.CoolZoneRetTemp = RetTemp; - zsCalcSizing.HeatTstatTemp = state.dataHeatBalFanSys->ZoneThermostatSetPointLo(zoneNum); - zsCalcSizing.CoolTstatTemp = state.dataHeatBalFanSys->ZoneThermostatSetPointHi(zoneNum); + zsCalcSizing.HeatTstatTemp = zoneTstatSetpt.setptLo; + zsCalcSizing.CoolTstatTemp = zoneTstatSetpt.setptHi; } } @@ -816,9 +817,9 @@ void SetUpZoneSizingArrays(EnergyPlusData &state) state.dataZoneEquipmentManager->AvgData.allocate(state.dataZoneEquipmentManager->NumOfTimeStepInDay); for (int DesDayNum = 1; DesDayNum <= state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays; ++DesDayNum) { auto &thisDesDayWeather = state.dataSize->DesDayWeath(DesDayNum); - thisDesDayWeather.Temp.allocate(state.dataGlobal->NumOfTimeStepInHour * 24); - thisDesDayWeather.HumRat.allocate(state.dataGlobal->NumOfTimeStepInHour * 24); - thisDesDayWeather.Press.allocate(state.dataGlobal->NumOfTimeStepInHour * 24); + thisDesDayWeather.Temp.allocate(state.dataGlobal->TimeStepsInHour * Constant::iHoursInDay); + thisDesDayWeather.HumRat.allocate(state.dataGlobal->TimeStepsInHour * Constant::iHoursInDay); + thisDesDayWeather.Press.allocate(state.dataGlobal->TimeStepsInHour * Constant::iHoursInDay); thisDesDayWeather.Temp = 0.0; thisDesDayWeather.HumRat = 0.0; thisDesDayWeather.Press = 0.0; @@ -1025,13 +1026,13 @@ void SetUpZoneSizingArrays(EnergyPlusData &state) if (state.dataHeatBal->People(PeopleNum).ZonePtr == CtrlZoneNum) { auto &people = state.dataHeatBal->People(PeopleNum); TotPeopleInZone += (people.NumberOfPeople * thisZone.Multiplier * thisZone.ListMultiplier); - Real64 SchMax = ScheduleManager::GetScheduleMaxValue(state, people.NumberOfPeoplePtr); + Real64 SchMax = people.numberOfPeopleSched->getCurrentVal(); if (SchMax > 0) { finalZoneSizing.ZonePeakOccupancy = TotPeopleInZone * SchMax; } else { finalZoneSizing.ZonePeakOccupancy = TotPeopleInZone; } - ZoneMinOccupancy += TotPeopleInZone * ScheduleManager::GetScheduleMinValue(state, people.NumberOfPeoplePtr); + ZoneMinOccupancy += TotPeopleInZone * people.numberOfPeopleSched->getMinVal(state); } } finalZoneSizing.TotalZoneFloorArea = (thisZone.FloorArea * thisZone.Multiplier * thisZone.ListMultiplier); @@ -1183,8 +1184,8 @@ void fillZoneSizingFromInput(EnergyPlusData &state, zoneSizing.zoneLatentSizing = zoneSizingInput.zoneLatentSizing; zoneSizing.zoneRHDehumidifySetPoint = zoneSizingInput.zoneRHDehumidifySetPoint; zoneSizing.zoneRHHumidifySetPoint = zoneSizingInput.zoneRHHumidifySetPoint; - zoneSizing.zoneRHDehumidifySchIndex = zoneSizingInput.zoneRHDehumidifySchIndex; - zoneSizing.zoneRHHumidifySchIndex = zoneSizingInput.zoneRHHumidifySchIndex; + zoneSizing.zoneRHDehumidifySched = zoneSizingInput.zoneRHDehumidifySched; + zoneSizing.zoneRHHumidifySched = zoneSizingInput.zoneRHHumidifySched; zoneSizing.ZnLatCoolDgnSAMethod = zoneSizingInput.ZnLatCoolDgnSAMethod; zoneSizing.ZnLatHeatDgnSAMethod = zoneSizingInput.ZnLatHeatDgnSAMethod; calcZoneSizing.ZnCoolDgnSAMethod = zoneSizingInput.ZnCoolDgnSAMethod; @@ -1216,8 +1217,8 @@ void fillZoneSizingFromInput(EnergyPlusData &state, calcZoneSizing.zoneLatentSizing = zoneSizingInput.zoneLatentSizing; calcZoneSizing.zoneRHDehumidifySetPoint = zoneSizingInput.zoneRHDehumidifySetPoint; calcZoneSizing.zoneRHHumidifySetPoint = zoneSizingInput.zoneRHHumidifySetPoint; - calcZoneSizing.zoneRHDehumidifySchIndex = zoneSizingInput.zoneRHDehumidifySchIndex; - calcZoneSizing.zoneRHHumidifySchIndex = zoneSizingInput.zoneRHHumidifySchIndex; + calcZoneSizing.zoneRHDehumidifySched = zoneSizingInput.zoneRHDehumidifySched; + calcZoneSizing.zoneRHHumidifySched = zoneSizingInput.zoneRHHumidifySched; calcZoneSizing.ZnLatCoolDgnSAMethod = zoneSizingInput.ZnLatCoolDgnSAMethod; calcZoneSizing.LatentCoolDesHumRat = zoneSizingInput.LatentCoolDesHumRat; calcZoneSizing.CoolDesHumRatDiff = zoneSizingInput.CoolDesHumRatDiff; @@ -1269,8 +1270,8 @@ void fillZoneSizingFromInput(EnergyPlusData &state, zsFinalSizing.zoneLatentSizing = zoneSizingInput.zoneLatentSizing; zsFinalSizing.zoneRHDehumidifySetPoint = zoneSizingInput.zoneRHDehumidifySetPoint; zsFinalSizing.zoneRHHumidifySetPoint = zoneSizingInput.zoneRHHumidifySetPoint; - zsFinalSizing.zoneRHDehumidifySchIndex = zoneSizingInput.zoneRHDehumidifySchIndex; - zsFinalSizing.zoneRHHumidifySchIndex = zoneSizingInput.zoneRHHumidifySchIndex; + zsFinalSizing.zoneRHDehumidifySched = zoneSizingInput.zoneRHDehumidifySched; + zsFinalSizing.zoneRHHumidifySched = zoneSizingInput.zoneRHHumidifySched; zsFinalSizing.ZnLatCoolDgnSAMethod = zoneSizingInput.ZnLatCoolDgnSAMethod; zsFinalSizing.LatentCoolDesHumRat = zoneSizingInput.LatentCoolDesHumRat; zsFinalSizing.CoolDesHumRatDiff = zoneSizingInput.CoolDesHumRatDiff; @@ -1310,8 +1311,8 @@ void fillZoneSizingFromInput(EnergyPlusData &state, zsCalcFinalSizing.zoneLatentSizing = zoneSizingInput.zoneLatentSizing; zsCalcFinalSizing.zoneRHDehumidifySetPoint = zoneSizingInput.zoneRHDehumidifySetPoint; zsCalcFinalSizing.zoneRHHumidifySetPoint = zoneSizingInput.zoneRHHumidifySetPoint; - zsCalcFinalSizing.zoneRHDehumidifySchIndex = zoneSizingInput.zoneRHDehumidifySchIndex; - zsCalcFinalSizing.zoneRHHumidifySchIndex = zoneSizingInput.zoneRHHumidifySchIndex; + zsCalcFinalSizing.zoneRHDehumidifySched = zoneSizingInput.zoneRHDehumidifySched; + zsCalcFinalSizing.zoneRHHumidifySched = zoneSizingInput.zoneRHHumidifySched; zsCalcFinalSizing.ZnLatCoolDgnSAMethod = zoneSizingInput.ZnLatCoolDgnSAMethod; zsCalcFinalSizing.LatentCoolDesHumRat = zoneSizingInput.LatentCoolDesHumRat; zsCalcFinalSizing.CoolDesHumRatDiff = zoneSizingInput.CoolDesHumRatDiff; @@ -1986,10 +1987,6 @@ void updateZoneSizingEndZoneSizingCalc1(EnergyPlusData &state, int const zoneNum } int numSpaces = 0; // Track this for averages later - bool heatDDNumAllSame = true; - bool coolDDNumAllSame = true; - int priorHeatDDNum = 0; - int priorCoolDDNum = 0; for (int spaceNum : state.dataHeatBal->Zone(zoneNum).spaceIndexes) { auto &spaceCFS = state.dataSize->CalcFinalSpaceSizing(spaceNum); ++numSpaces; @@ -2320,7 +2317,7 @@ std::string sizingPeakTimeStamp(EnergyPlusData &state, int timeStepIndex) int minute = 0; Real64 second = 0; - Real64 timeInSeconds = timeStepIndex * state.dataGlobal->MinutesPerTimeStep * minToSec; + Real64 timeInSeconds = timeStepIndex * state.dataGlobal->MinutesInTimeStep * minToSec; General::ParseTime(timeInSeconds, hour, minute, second); return format(PeakHrMinFmt, hour, minute); } @@ -2412,9 +2409,9 @@ void writeZszSpsz(EnergyPlusData &state, int Minutes = 0; int TimeStepIndex = 0; for (int HourCounter = 1; HourCounter <= 24; ++HourCounter) { - for (int TimeStepCounter = 1; TimeStepCounter <= state.dataGlobal->NumOfTimeStepInHour; ++TimeStepCounter) { + for (int TimeStepCounter = 1; TimeStepCounter <= state.dataGlobal->TimeStepsInHour; ++TimeStepCounter) { ++TimeStepIndex; - Minutes += state.dataGlobal->MinutesPerTimeStep; + Minutes += state.dataGlobal->MinutesInTimeStep; int HourPrint = HourCounter - 1; if (Minutes == 60) { Minutes = 0; @@ -3163,21 +3160,22 @@ void UpdateZoneSizing(EnergyPlusData &state, Constant::CallIndicator const CallI } } break; case Constant::CallIndicator::DuringDay: { - int timeStepInDay = (state.dataGlobal->HourOfDay - 1) * state.dataGlobal->NumOfTimeStepInHour + state.dataGlobal->TimeStep; + int timeStepInDay = (state.dataGlobal->HourOfDay - 1) * state.dataGlobal->TimeStepsInHour + state.dataGlobal->TimeStep; Real64 fracTimeStepZone = state.dataHVACGlobal->FracTimeStepZone; // save the results of the ideal zone component calculation in the CalcZoneSizing sequence variables for (int CtrlZoneNum = 1; CtrlZoneNum <= state.dataGlobal->NumOfZones; ++CtrlZoneNum) { if (!state.dataZoneEquip->ZoneEquipConfig(CtrlZoneNum).IsControlled) continue; + auto const &zoneTstatSetpt = state.dataHeatBalFanSys->zoneTstatSetpts(CtrlZoneNum); // auto &zoneSizing = state.dataSize->ZoneSizing(state.dataSize->CurOverallSimDay, CtrlZoneNum); // auto &calcZoneSizing = state.dataSize->CalcZoneSizing(state.dataSize->CurOverallSimDay, CtrlZoneNum); // auto const &zoneThermostatHi = state.dataHeatBalFanSys->ZoneThermostatSetPointHi(CtrlZoneNum); // auto const &zoneThermostatLo = state.dataHeatBalFanSys->ZoneThermostatSetPointLo(CtrlZoneNum); updateZoneSizingDuringDay(state.dataSize->ZoneSizing(state.dataSize->CurOverallSimDay, CtrlZoneNum), state.dataSize->CalcZoneSizing(state.dataSize->CurOverallSimDay, CtrlZoneNum), - state.dataHeatBalFanSys->ZoneThermostatSetPointHi(CtrlZoneNum), - state.dataHeatBalFanSys->ZoneThermostatSetPointLo(CtrlZoneNum), + zoneTstatSetpt.setptHi, + zoneTstatSetpt.setptLo, state.dataSize->FinalZoneSizing(CtrlZoneNum).ZoneSizThermSetPtHi, state.dataSize->FinalZoneSizing(CtrlZoneNum).ZoneSizThermSetPtLo, timeStepInDay, @@ -3186,8 +3184,8 @@ void UpdateZoneSizing(EnergyPlusData &state, Constant::CallIndicator const CallI for (int spaceNum : state.dataHeatBal->Zone(CtrlZoneNum).spaceIndexes) { updateZoneSizingDuringDay(state.dataSize->SpaceSizing(state.dataSize->CurOverallSimDay, spaceNum), state.dataSize->CalcSpaceSizing(state.dataSize->CurOverallSimDay, spaceNum), - state.dataHeatBalFanSys->ZoneThermostatSetPointHi(CtrlZoneNum), - state.dataHeatBalFanSys->ZoneThermostatSetPointLo(CtrlZoneNum), + zoneTstatSetpt.setptHi, + zoneTstatSetpt.setptLo, state.dataSize->FinalZoneSizing(CtrlZoneNum).ZoneSizThermSetPtHi, state.dataSize->FinalZoneSizing(CtrlZoneNum).ZoneSizThermSetPtLo, timeStepInDay, @@ -4555,41 +4553,30 @@ void updateSystemOutputRequired(EnergyPlusData &state, // re-evaluate if loads are now such that in dead band or set back switch (state.dataHeatBalFanSys->TempControlType(ZoneNum)) { - case HVAC::ThermostatType::Uncontrolled: + case HVAC::SetptType::Uncontrolled: { // uncontrolled zone; shouldn't ever get here, but who knows state.dataZoneEnergyDemand->CurDeadBandOrSetback(ZoneNum) = false; - break; - case HVAC::ThermostatType::SingleHeating: - if ((energy.RemainingOutputRequired - 1.0) < 0.0) { - state.dataZoneEnergyDemand->CurDeadBandOrSetback(ZoneNum) = true; - } else { - state.dataZoneEnergyDemand->CurDeadBandOrSetback(ZoneNum) = false; - } - break; - case HVAC::ThermostatType::SingleCooling: - if ((energy.RemainingOutputRequired + 1.0) > 0.0) { - state.dataZoneEnergyDemand->CurDeadBandOrSetback(ZoneNum) = true; - } else { - state.dataZoneEnergyDemand->CurDeadBandOrSetback(ZoneNum) = false; - } - break; - case HVAC::ThermostatType::SingleHeatCool: - if (energy.RemainingOutputReqToHeatSP < 0.0 && energy.RemainingOutputReqToCoolSP > 0.0) { - state.dataZoneEnergyDemand->CurDeadBandOrSetback(ZoneNum) = true; - } else { - state.dataZoneEnergyDemand->CurDeadBandOrSetback(ZoneNum) = false; - } - break; - case HVAC::ThermostatType::DualSetPointWithDeadBand: - if (energy.RemainingOutputReqToHeatSP < 0.0 && energy.RemainingOutputReqToCoolSP > 0.0) { - state.dataZoneEnergyDemand->CurDeadBandOrSetback(ZoneNum) = true; - } else { - state.dataZoneEnergyDemand->CurDeadBandOrSetback(ZoneNum) = false; - } - break; - default: - break; - } + } break; + + case HVAC::SetptType::SingleHeat: { + state.dataZoneEnergyDemand->CurDeadBandOrSetback(ZoneNum) = ((energy.RemainingOutputRequired - 1.0) < 0.0); + } break; + + case HVAC::SetptType::SingleCool: { + state.dataZoneEnergyDemand->CurDeadBandOrSetback(ZoneNum) = ((energy.RemainingOutputRequired + 1.0) > 0.0); + } break; + + case HVAC::SetptType::SingleHeatCool: { + state.dataZoneEnergyDemand->CurDeadBandOrSetback(ZoneNum) = (energy.RemainingOutputReqToHeatSP < 0.0 && energy.RemainingOutputReqToCoolSP > 0.0); + } break; + + case HVAC::SetptType::DualHeatCool: { + state.dataZoneEnergyDemand->CurDeadBandOrSetback(ZoneNum) = (energy.RemainingOutputReqToHeatSP < 0.0 && energy.RemainingOutputReqToCoolSP > 0.0); + } break; + + default: { + } break; + } // swtich if (EquipPriorityNum > -1) { // now store remaining load at the by sequence level @@ -4664,41 +4651,31 @@ void updateSystemOutputRequired(EnergyPlusData &state, // re-evaluate if loads are now such that in dead band or set back switch (state.dataHeatBalFanSys->TempControlType(ZoneNum)) { - case HVAC::ThermostatType::Uncontrolled: + case HVAC::SetptType::Uncontrolled: { // uncontrolled zone; shouldn't ever get here, but who knows state.dataZoneEnergyDemand->CurDeadBandOrSetback(ZoneNum) = false; - break; - case HVAC::ThermostatType::SingleHeating: - if ((energy.RemainingOutputRequired - 1.0) < 0.0) { - state.dataZoneEnergyDemand->CurDeadBandOrSetback(ZoneNum) = true; - } else { - state.dataZoneEnergyDemand->CurDeadBandOrSetback(ZoneNum) = false; - } - break; - case HVAC::ThermostatType::SingleCooling: - if ((energy.RemainingOutputRequired + 1.0) > 0.0) { - state.dataZoneEnergyDemand->CurDeadBandOrSetback(ZoneNum) = true; - } else { - state.dataZoneEnergyDemand->CurDeadBandOrSetback(ZoneNum) = false; - } - break; - case HVAC::ThermostatType::SingleHeatCool: - if (energy.RemainingOutputReqToHeatSP < 0.0 && energy.RemainingOutputReqToCoolSP > 0.0) { - state.dataZoneEnergyDemand->CurDeadBandOrSetback(ZoneNum) = true; - } else { - state.dataZoneEnergyDemand->CurDeadBandOrSetback(ZoneNum) = false; - } - break; - case HVAC::ThermostatType::DualSetPointWithDeadBand: - if (energy.RemainingOutputReqToHeatSP < 0.0 && energy.RemainingOutputReqToCoolSP > 0.0) { - state.dataZoneEnergyDemand->CurDeadBandOrSetback(ZoneNum) = true; - } else { - state.dataZoneEnergyDemand->CurDeadBandOrSetback(ZoneNum) = false; - } - break; - default: - break; - } + } break; + + case HVAC::SetptType::SingleHeat: { + state.dataZoneEnergyDemand->CurDeadBandOrSetback(ZoneNum) = ((energy.RemainingOutputRequired - 1.0) < 0.0); + } break; + + case HVAC::SetptType::SingleCool: { + state.dataZoneEnergyDemand->CurDeadBandOrSetback(ZoneNum) = ((energy.RemainingOutputRequired + 1.0) > 0.0); + } break; + + case HVAC::SetptType::SingleHeatCool: { + state.dataZoneEnergyDemand->CurDeadBandOrSetback(ZoneNum) = (energy.RemainingOutputReqToHeatSP < 0.0 && energy.RemainingOutputReqToCoolSP > 0.0); + } break; + + case HVAC::SetptType::DualHeatCool: { + state.dataZoneEnergyDemand->CurDeadBandOrSetback(ZoneNum) = (energy.RemainingOutputReqToHeatSP < 0.0 && energy.RemainingOutputReqToCoolSP > 0.0); + } break; + + default: { + } break; + + } // switch } break; case DataZoneEquipment::LoadDist::Uniform: @@ -5542,16 +5519,14 @@ void CalcAirFlowSimple(EnergyPlusData &state, Real64 hybridControlZoneMAT = state.dataZoneTempPredictorCorrector->zoneHeatBalance(hybridControlVentilation.ZonePtr).MixingMAT; // Check scheduled temperatures - if (hybridControlVentilation.MinIndoorTempSchedPtr > 0) { - hybridControlVentilation.MinIndoorTemperature = - ScheduleManager::GetCurrentScheduleValue(state, hybridControlVentilation.MinIndoorTempSchedPtr); + if (hybridControlVentilation.minIndoorTempSched != nullptr) { + hybridControlVentilation.MinIndoorTemperature = hybridControlVentilation.minIndoorTempSched->getCurrentVal(); } - if (hybridControlVentilation.MaxIndoorTempSchedPtr > 0) { - hybridControlVentilation.MaxIndoorTemperature = - ScheduleManager::GetCurrentScheduleValue(state, hybridControlVentilation.MaxIndoorTempSchedPtr); + if (hybridControlVentilation.maxIndoorTempSched != nullptr) { + hybridControlVentilation.MaxIndoorTemperature = hybridControlVentilation.maxIndoorTempSched->getCurrentVal(); } // Ensure the minimum indoor temperature <= the maximum indoor temperature - if (hybridControlVentilation.MinIndoorTempSchedPtr > 0 || hybridControlVentilation.MaxIndoorTempSchedPtr > 0) { + if (hybridControlVentilation.minIndoorTempSched != nullptr || hybridControlVentilation.maxIndoorTempSched != nullptr) { if (hybridControlVentilation.MinIndoorTemperature > hybridControlVentilation.MaxIndoorTemperature) { ++hybridControlVentilation.IndoorTempErrCount; if (hybridControlVentilation.IndoorTempErrCount < 2) { @@ -5571,16 +5546,14 @@ void CalcAirFlowSimple(EnergyPlusData &state, hybridControlVentilation.MinIndoorTemperature = hybridControlVentilation.MaxIndoorTemperature; } } - if (hybridControlVentilation.MinOutdoorTempSchedPtr > 0) { - hybridControlVentilation.MinOutdoorTemperature = - ScheduleManager::GetCurrentScheduleValue(state, hybridControlVentilation.MinOutdoorTempSchedPtr); + if (hybridControlVentilation.minOutdoorTempSched != nullptr) { + hybridControlVentilation.MinOutdoorTemperature = hybridControlVentilation.minOutdoorTempSched->getCurrentVal(); } - if (hybridControlVentilation.MaxOutdoorTempSchedPtr > 0) { - hybridControlVentilation.MaxOutdoorTemperature = - ScheduleManager::GetCurrentScheduleValue(state, hybridControlVentilation.MaxOutdoorTempSchedPtr); + if (hybridControlVentilation.maxOutdoorTempSched != nullptr) { + hybridControlVentilation.MaxOutdoorTemperature = hybridControlVentilation.maxOutdoorTempSched->getCurrentVal(); } // Ensure the minimum outdoor temperature <= the maximum outdoor temperature - if (hybridControlVentilation.MinOutdoorTempSchedPtr > 0 || hybridControlVentilation.MaxOutdoorTempSchedPtr > 0) { + if (hybridControlVentilation.minOutdoorTempSched != nullptr || hybridControlVentilation.maxOutdoorTempSched != nullptr) { if (hybridControlVentilation.MinOutdoorTemperature > hybridControlVentilation.MaxOutdoorTemperature) { ++hybridControlVentilation.OutdoorTempErrCount; if (hybridControlVentilation.OutdoorTempErrCount < 2) { @@ -5600,8 +5573,8 @@ void CalcAirFlowSimple(EnergyPlusData &state, hybridControlVentilation.MinIndoorTemperature = hybridControlVentilation.MaxIndoorTemperature; } } - if (hybridControlVentilation.DeltaTempSchedPtr > 0) { - hybridControlVentilation.DelTemperature = ScheduleManager::GetCurrentScheduleValue(state, hybridControlVentilation.DeltaTempSchedPtr); + if (hybridControlVentilation.deltaTempSched != nullptr) { + hybridControlVentilation.DelTemperature = hybridControlVentilation.deltaTempSched->getCurrentVal(); } // Skip this if the zone is below the minimum indoor temperature limit if ((hybridControlZoneMAT < hybridControlVentilation.MinIndoorTemperature) && (!thisVentilation.EMSSimpleVentOn)) continue; @@ -5624,7 +5597,7 @@ void CalcAirFlowSimple(EnergyPlusData &state, if (thisVentilation.ModelType == DataHeatBalance::VentilationModelType::DesignFlowRate) { // CR6845 if calculated < 0, don't propagate. - VVF = thisVentilation.DesignLevel * ScheduleManager::GetCurrentScheduleValue(state, thisVentilation.SchedPtr); + VVF = thisVentilation.DesignLevel * thisVentilation.sched->getCurrentVal(); if (thisVentilation.EMSSimpleVentOn) VVF = thisVentilation.EMSimpleVentFlowRate; @@ -5767,8 +5740,8 @@ void CalcAirFlowSimple(EnergyPlusData &state, } else { Cd = 0.40 + 0.0045 * std::abs(TempExt - thisMixingMAT); } - Qw = Cw * thisVentilation.OpenArea * ScheduleManager::GetCurrentScheduleValue(state, thisVentilation.OpenAreaSchedPtr) * WindSpeedExt; - Qst = Cd * thisVentilation.OpenArea * ScheduleManager::GetCurrentScheduleValue(state, thisVentilation.OpenAreaSchedPtr) * + Qw = Cw * thisVentilation.OpenArea * thisVentilation.openAreaSched->getCurrentVal() * WindSpeedExt; + Qst = Cd * thisVentilation.OpenArea * thisVentilation.openAreaSched->getCurrentVal() * std::sqrt(2.0 * 9.81 * thisVentilation.DH * std::abs(TempExt - thisMixingMAT) / (thisMixingMAT + 273.15)); VVF = std::sqrt(Qw * Qw + Qst * Qst); if (thisVentilation.EMSSimpleVentOn) VVF = thisVentilation.EMSimpleVentFlowRate; @@ -5806,8 +5779,8 @@ void CalcAirFlowSimple(EnergyPlusData &state, thisMixing.ReportFlag = false; // Get scheduled delta temperature - if (thisMixing.DeltaTempSchedPtr > 0) { - TD = ScheduleManager::GetCurrentScheduleValue(state, thisMixing.DeltaTempSchedPtr); + if (thisMixing.deltaTempSched != nullptr) { + TD = thisMixing.deltaTempSched->getCurrentVal(); } Real64 TZN = 0.0; // Temperature of this Zone/Space Real64 TZM = 0.0; // Temperature of From Zone/Space @@ -5846,9 +5819,9 @@ void CalcAirFlowSimple(EnergyPlusData &state, // Ensure the minimum indoor temperature <= the maximum indoor temperature Real64 MixingTmin = 0.0; Real64 MixingTmax = 0.0; - if (thisMixing.MinIndoorTempSchedPtr > 0) MixingTmin = ScheduleManager::GetCurrentScheduleValue(state, thisMixing.MinIndoorTempSchedPtr); - if (thisMixing.MaxIndoorTempSchedPtr > 0) MixingTmax = ScheduleManager::GetCurrentScheduleValue(state, thisMixing.MaxIndoorTempSchedPtr); - if (thisMixing.MinIndoorTempSchedPtr > 0 && thisMixing.MaxIndoorTempSchedPtr > 0) { + if (thisMixing.minIndoorTempSched != nullptr) MixingTmin = thisMixing.minIndoorTempSched->getCurrentVal(); + if (thisMixing.maxIndoorTempSched != nullptr) MixingTmax = thisMixing.maxIndoorTempSched->getCurrentVal(); + if (thisMixing.minIndoorTempSched != nullptr && thisMixing.maxIndoorTempSched != nullptr) { if (MixingTmin > MixingTmax) { ++thisMixing.IndoorTempErrCount; if (thisMixing.IndoorTempErrCount < 2) { @@ -5868,16 +5841,16 @@ void CalcAirFlowSimple(EnergyPlusData &state, MixingTmin = MixingTmax; } } - if (thisMixing.MinIndoorTempSchedPtr > 0) { + if (thisMixing.minIndoorTempSched != nullptr) { if (TZN < MixingTmin) MixingLimitFlag = true; } - if (thisMixing.MaxIndoorTempSchedPtr > 0) { + if (thisMixing.maxIndoorTempSched != nullptr) { if (TZN > MixingTmax) MixingLimitFlag = true; } // Ensure the minimum source temperature <= the maximum source temperature - if (thisMixing.MinSourceTempSchedPtr > 0) MixingTmin = ScheduleManager::GetCurrentScheduleValue(state, thisMixing.MinSourceTempSchedPtr); - if (thisMixing.MaxSourceTempSchedPtr > 0) MixingTmax = ScheduleManager::GetCurrentScheduleValue(state, thisMixing.MaxSourceTempSchedPtr); - if (thisMixing.MinSourceTempSchedPtr > 0 && thisMixing.MaxSourceTempSchedPtr > 0) { + if (thisMixing.minSourceTempSched != nullptr) MixingTmin = thisMixing.minSourceTempSched->getCurrentVal(); + if (thisMixing.maxSourceTempSched != nullptr) MixingTmax = thisMixing.maxSourceTempSched->getCurrentVal(); + if (thisMixing.minSourceTempSched != nullptr && thisMixing.maxSourceTempSched != nullptr) { if (MixingTmin > MixingTmax) { ++thisMixing.SourceTempErrCount; if (thisMixing.SourceTempErrCount < 2) { @@ -5897,19 +5870,19 @@ void CalcAirFlowSimple(EnergyPlusData &state, MixingTmin = MixingTmax; } } - if (thisMixing.MinSourceTempSchedPtr > 0) { + if (thisMixing.minSourceTempSched != nullptr) { if (TZM < MixingTmin) MixingLimitFlag = true; } - if (thisMixing.MaxSourceTempSchedPtr > 0) { + if (thisMixing.maxSourceTempSched != nullptr) { if (TZM > MixingTmax) MixingLimitFlag = true; } // Ensure the minimum outdoor temperature <= the maximum outdoor temperature Real64 TempExt = state.dataHeatBal->Zone(thisZoneNum).OutDryBulbTemp; - if (thisMixing.MinOutdoorTempSchedPtr > 0) - MixingTmin = ScheduleManager::GetCurrentScheduleValue(state, thisMixing.MinOutdoorTempSchedPtr); - if (thisMixing.MaxOutdoorTempSchedPtr > 0) - MixingTmax = ScheduleManager::GetCurrentScheduleValue(state, thisMixing.MaxOutdoorTempSchedPtr); - if (thisMixing.MinOutdoorTempSchedPtr > 0 && thisMixing.MaxOutdoorTempSchedPtr > 0) { + if (thisMixing.minOutdoorTempSched != nullptr) + MixingTmin = thisMixing.minOutdoorTempSched->getCurrentVal(); + if (thisMixing.maxOutdoorTempSched != nullptr) + MixingTmax = thisMixing.maxOutdoorTempSched->getCurrentVal(); + if (thisMixing.minOutdoorTempSched != nullptr && thisMixing.maxOutdoorTempSched != nullptr) { if (MixingTmin > MixingTmax) { ++thisMixing.OutdoorTempErrCount; if (thisMixing.OutdoorTempErrCount < 2) { @@ -5929,10 +5902,10 @@ void CalcAirFlowSimple(EnergyPlusData &state, MixingTmin = MixingTmax; } } - if (thisMixing.MinOutdoorTempSchedPtr > 0) { + if (thisMixing.minOutdoorTempSched != nullptr) { if (TempExt < MixingTmin) MixingLimitFlag = true; } - if (thisMixing.MaxOutdoorTempSchedPtr > 0) { + if (thisMixing.maxOutdoorTempSched != nullptr) { if (TempExt > MixingTmax) MixingLimitFlag = true; } } @@ -6050,8 +6023,8 @@ void CalcAirFlowSimple(EnergyPlusData &state, auto &fromZoneHB = state.dataZoneTempPredictorCorrector->zoneHeatBalance(fromZoneNum); Real64 TD = thisCrossMixing.DeltaTemperature; // Delta Temp limit // Get scheduled delta temperature - if (thisCrossMixing.DeltaTempSchedPtr > 0) { - TD = ScheduleManager::GetCurrentScheduleValue(state, thisCrossMixing.DeltaTempSchedPtr); + if (thisCrossMixing.deltaTempSched != nullptr) { + TD = thisCrossMixing.deltaTempSched->getCurrentVal(); } Real64 thisMCPxM = 0.0; Real64 thisMCPTxM = 0.0; @@ -6084,11 +6057,9 @@ void CalcAirFlowSimple(EnergyPlusData &state, // Ensure the minimum indoor temperature <= the maximum indoor temperature Real64 MixingTmin = 0.0; Real64 MixingTmax = 0.0; - if (thisCrossMixing.MinIndoorTempSchedPtr > 0) - MixingTmin = ScheduleManager::GetCurrentScheduleValue(state, thisCrossMixing.MinIndoorTempSchedPtr); - if (thisCrossMixing.MaxIndoorTempSchedPtr > 0) - MixingTmax = ScheduleManager::GetCurrentScheduleValue(state, thisCrossMixing.MaxIndoorTempSchedPtr); - if (thisCrossMixing.MinIndoorTempSchedPtr > 0 && thisCrossMixing.MaxIndoorTempSchedPtr > 0) { + if (thisCrossMixing.minIndoorTempSched != nullptr) MixingTmin = thisCrossMixing.minIndoorTempSched->getCurrentVal(); + if (thisCrossMixing.maxIndoorTempSched != nullptr) MixingTmax = thisCrossMixing.maxIndoorTempSched->getCurrentVal(); + if (thisCrossMixing.minIndoorTempSched != nullptr && thisCrossMixing.maxIndoorTempSched != nullptr) { if (MixingTmin > MixingTmax) { ++thisCrossMixing.IndoorTempErrCount; if (thisCrossMixing.IndoorTempErrCount < 2) { @@ -6108,18 +6079,16 @@ void CalcAirFlowSimple(EnergyPlusData &state, MixingTmin = MixingTmax; } } - if (thisCrossMixing.MinIndoorTempSchedPtr > 0) { + if (thisCrossMixing.minIndoorTempSched != nullptr) { if (TZN < MixingTmin) MixingLimitFlag = true; } - if (thisCrossMixing.MaxIndoorTempSchedPtr > 0) { + if (thisCrossMixing.maxIndoorTempSched != nullptr) { if (TZN > MixingTmax) MixingLimitFlag = true; } // Ensure the minimum source temperature <= the maximum source temperature - if (thisCrossMixing.MinSourceTempSchedPtr > 0) - MixingTmin = ScheduleManager::GetCurrentScheduleValue(state, thisCrossMixing.MinSourceTempSchedPtr); - if (thisCrossMixing.MaxSourceTempSchedPtr > 0) - MixingTmax = ScheduleManager::GetCurrentScheduleValue(state, thisCrossMixing.MaxSourceTempSchedPtr); - if (thisCrossMixing.MinSourceTempSchedPtr > 0 && thisCrossMixing.MaxSourceTempSchedPtr > 0) { + if (thisCrossMixing.minSourceTempSched != nullptr) MixingTmin = thisCrossMixing.minSourceTempSched->getCurrentVal(); + if (thisCrossMixing.maxSourceTempSched != nullptr) MixingTmax = thisCrossMixing.maxSourceTempSched->getCurrentVal(); + if (thisCrossMixing.minSourceTempSched != nullptr && thisCrossMixing.maxSourceTempSched != nullptr) { if (MixingTmin > MixingTmax) { ++thisCrossMixing.SourceTempErrCount; if (thisCrossMixing.SourceTempErrCount < 2) { @@ -6139,19 +6108,17 @@ void CalcAirFlowSimple(EnergyPlusData &state, MixingTmin = MixingTmax; } } - if (thisCrossMixing.MinSourceTempSchedPtr > 0) { + if (thisCrossMixing.minSourceTempSched != nullptr) { if (TZM < MixingTmin) MixingLimitFlag = true; } - if (thisCrossMixing.MaxSourceTempSchedPtr > 0) { + if (thisCrossMixing.maxSourceTempSched != nullptr) { if (TZM > MixingTmax) MixingLimitFlag = true; } // Ensure the minimum outdoor temperature <= the maximum outdoor temperature Real64 TempExt = state.dataHeatBal->Zone(thisZoneNum).OutDryBulbTemp; - if (thisCrossMixing.MinOutdoorTempSchedPtr > 0) - MixingTmin = ScheduleManager::GetCurrentScheduleValue(state, thisCrossMixing.MinOutdoorTempSchedPtr); - if (thisCrossMixing.MaxOutdoorTempSchedPtr > 0) - MixingTmax = ScheduleManager::GetCurrentScheduleValue(state, thisCrossMixing.MaxOutdoorTempSchedPtr); - if (thisCrossMixing.MinOutdoorTempSchedPtr > 0 && thisCrossMixing.MaxOutdoorTempSchedPtr > 0) { + if (thisCrossMixing.minOutdoorTempSched != nullptr) MixingTmin = thisCrossMixing.minOutdoorTempSched->getCurrentVal(); + if (thisCrossMixing.maxOutdoorTempSched != nullptr) MixingTmax = thisCrossMixing.maxOutdoorTempSched->getCurrentVal(); + if (thisCrossMixing.minOutdoorTempSched != nullptr && thisCrossMixing.maxOutdoorTempSched != nullptr) { if (MixingTmin > MixingTmax) { ++thisCrossMixing.OutdoorTempErrCount; if (thisCrossMixing.OutdoorTempErrCount < 2) { @@ -6171,10 +6138,10 @@ void CalcAirFlowSimple(EnergyPlusData &state, MixingTmin = MixingTmax; } } - if (thisCrossMixing.MinOutdoorTempSchedPtr > 0) { + if (thisCrossMixing.minOutdoorTempSched != nullptr) { if (TempExt < MixingTmin) MixingLimitFlag = true; } - if (thisCrossMixing.MaxOutdoorTempSchedPtr > 0) { + if (thisCrossMixing.maxOutdoorTempSched != nullptr) { if (TempExt > MixingTmax) MixingLimitFlag = true; } if (MixingLimitFlag) continue; @@ -6278,7 +6245,7 @@ void CalcAirFlowSimple(EnergyPlusData &state, } else { Real64 AirDensityZoneB = PsyRhoAirFnPbTdbW(state, state.dataEnvrn->OutBaroPress, TZoneB, HumRatZoneB, RoutineNameRefrigerationDoorMixing); - Real64 SchedDoorOpen = ScheduleManager::GetCurrentScheduleValue(state, state.dataHeatBal->RefDoorMixing(ZoneA).OpenSchedPtr(j)); + Real64 SchedDoorOpen = state.dataHeatBal->RefDoorMixing(ZoneA).openScheds(j)->getCurrentVal(); if (SchedDoorOpen == 0.0) continue; Real64 DoorHeight = state.dataHeatBal->RefDoorMixing(ZoneA).DoorHeight(j); Real64 DoorArea = state.dataHeatBal->RefDoorMixing(ZoneA).DoorArea(j); @@ -6399,7 +6366,7 @@ void CalcAirFlowSimple(EnergyPlusData &state, Real64 AirDensity = PsyRhoAirFnPbTdbW(state, state.dataEnvrn->OutBaroPress, TempExt, HumRatExt, RoutineNameInfiltration); Real64 CpAir = PsyCpAirFnW(HumRatExt); Real64 MCpI_temp = 0.0; - Real64 scheduleFrac = ScheduleManager::GetCurrentScheduleValue(state, thisInfiltration.SchedPtr); + Real64 scheduleFrac = thisInfiltration.sched->getCurrentVal(); if (scheduleFrac > 0.0) { // CR7751 should maybe use code below, indoor conditions instead of outdoor conditions // AirDensity = PsyRhoAirFnPbTdbW(state, OutBaroPress, MixingMAT(NZ), MixingHumRat(NZ)) @@ -6530,7 +6497,7 @@ void CalcAirFlowSimple(EnergyPlusData &state, pow_2(thisZoneAirBalance.ExhMassFlowRate) + pow_2(thisZoneAirBalance.ERVMassFlowRate) + pow_2(thisZoneAirBalance.InfMassFlowRate) + pow_2(AirDensity * thisZoneAirBalance.InducedAirRate * - ScheduleManager::GetCurrentScheduleValue(state, thisZoneAirBalance.InducedAirSchedPtr))) + + thisZoneAirBalance.inducedAirSched->getCurrentVal())) + thisZoneAirBalance.BalMassFlowRate; thisZoneHB.MDotCPOA = thisZoneHB.MDotOA * CpAir; } diff --git a/src/EnergyPlus/ZoneEquipmentManager.hh b/src/EnergyPlus/ZoneEquipmentManager.hh index b1114a23688..617066a5c97 100644 --- a/src/EnergyPlus/ZoneEquipmentManager.hh +++ b/src/EnergyPlus/ZoneEquipmentManager.hh @@ -272,6 +272,10 @@ struct ZoneEquipmentManagerData : BaseGlobalStruct bool InitZoneEquipmentEnvrnFlag = true; bool FirstPassZoneEquipFlag = true; // indicates first pass through zone equipment, used to reset selected ZoneEqSizing variables + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/ZonePlenum.hh b/src/EnergyPlus/ZonePlenum.hh index 168c8446774..cf0d9912c3a 100644 --- a/src/EnergyPlus/ZonePlenum.hh +++ b/src/EnergyPlus/ZonePlenum.hh @@ -192,6 +192,10 @@ struct ZonePlenumData : BaseGlobalStruct EPVector ZoneRetPlenCond; EPVector ZoneSupPlenCond; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/ZoneTempPredictorCorrector.cc b/src/EnergyPlus/ZoneTempPredictorCorrector.cc index 20783b681b4..76e18677aa9 100644 --- a/src/EnergyPlus/ZoneTempPredictorCorrector.cc +++ b/src/EnergyPlus/ZoneTempPredictorCorrector.cc @@ -145,33 +145,33 @@ enum class AdaptiveComfortModel Num }; -static constexpr std::array(HVAC::ThermostatType::Num)> ValidControlTypes = { +static constexpr std::array setptTypeNames = { "Uncontrolled", "ThermostatSetpoint:SingleHeating", "ThermostatSetpoint:SingleCooling", "ThermostatSetpoint:SingleHeatingOrCooling", "ThermostatSetpoint:DualSetpoint"}; -static constexpr std::array(HVAC::ThermostatType::Num)> ValidControlTypesUC = { +static constexpr std::array setptTypeNamesUC = { "UNCONTROLLED", "THERMOSTATSETPOINT:SINGLEHEATING", "THERMOSTATSETPOINT:SINGLECOOLING", "THERMOSTATSETPOINT:SINGLEHEATINGORCOOLING", "THERMOSTATSETPOINT:DUALSETPOINT"}; -static constexpr std::array(HVAC::ThermostatType::Num)> ValidComfortControlTypes = { +static constexpr std::array comfortSetptTypeNames = { "Uncontrolled", "ThermostatSetpoint:ThermalComfort:Fanger:SingleHeating", "ThermostatSetpoint:ThermalComfort:Fanger:SingleCooling", "ThermostatSetpoint:ThermalComfort:Fanger:SingleHeatingOrCooling", "ThermostatSetpoint:ThermalComfort:Fanger:DualSetpoint"}; -static constexpr std::array(HVAC::ThermostatType::Num)> ValidComfortControlTypesUC = { - "UNCONTROLLED", - "THERMOSTATSETPOINT:THERMALCOMFORT:FANGER:SINGLEHEATING", - "THERMOSTATSETPOINT:THERMALCOMFORT:FANGER:SINGLECOOLING", - "THERMOSTATSETPOINT:THERMALCOMFORT:FANGER:SINGLEHEATINGORCOOLING", - "THERMOSTATSETPOINT:THERMALCOMFORT:FANGER:DUALSETPOINT"}; +// static constexpr std::array comfortSetptTypeNamesUC = { +// "UNCONTROLLED", +// "THERMOSTATSETPOINT:THERMALCOMFORT:FANGER:SINGLEHEATING", +// "THERMOSTATSETPOINT:THERMALCOMFORT:FANGER:SINGLECOOLING", +// "THERMOSTATSETPOINT:THERMALCOMFORT:FANGER:SINGLEHEATINGORCOOLING", +// "THERMOSTATSETPOINT:THERMALCOMFORT:FANGER:DUALSETPOINT"}; Array1D_string const cZControlTypes(6, {"ZoneControl:Thermostat", @@ -262,32 +262,19 @@ void GetZoneAirSetPoints(EnergyPlusData &state) using General::CheckCreatedZoneItemName; using General::FindNumberInList; - using ScheduleManager::CheckScheduleValue; - using ScheduleManager::CheckScheduleValueMinMax; - using ScheduleManager::GetScheduleIndex; - using ScheduleManager::GetScheduleMaxValue; - using ScheduleManager::GetScheduleMinValue; - // SUBROUTINE PARAMETER DEFINITIONS: static constexpr std::string_view RoutineName("GetZoneAirSetpoints: "); + static constexpr std::string_view routineName = "GetZoneAirSetpoints"; // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int TempControlledZoneNum; // The Splitter that you are currently loading input into int NumAlphas; int NumNums; - int ControlTypeNum; int IOStat; bool ErrorsFound(false); bool errFlag; - int CTIndex; int HumidControlledZoneNum; // The Humidity Controller that information is being loaded into - bool ValidScheduleControlType; - bool ValidRadFractSched; // check for if radiative fraction schedule has valid numbers - bool ValidZoneOvercoolRangeSched; // check for if Zone Overcool range schedule has valid numbers - int SchedMin; - int SchedMax; int ActualZoneNum; - int SchedTypeIndex; int ComfortControlledZoneNum; // The Splitter that you are currently loading input into int i; @@ -305,15 +292,15 @@ void GetZoneAirSetPoints(EnergyPlusData &state) struct NeededControlTypes { // Members 4= the four control types + uncontrolled - std::array(HVAC::ThermostatType::Num)> MustHave = {false, false, false, false, false}; - std::array(HVAC::ThermostatType::Num)> DidHave = {false, false, false, false, false}; + std::array(HVAC::SetptType::Num)> MustHave = {false, false, false, false, false}; + std::array(HVAC::SetptType::Num)> DidHave = {false, false, false, false, false}; }; struct NeededComfortControlTypes { // Members 4= the four control types + uncontrolled - std::array(HVAC::ThermostatType::Num)> MustHave = {false, false, false, false, false}; - std::array(HVAC::ThermostatType::Num)> DidHave = {false, false, false, false, false}; + std::array(HVAC::SetptType::Num)> MustHave = {false, false, false, false, false}; + std::array(HVAC::SetptType::Num)> DidHave = {false, false, false, false, false}; }; // Object Data @@ -326,53 +313,44 @@ void GetZoneAirSetPoints(EnergyPlusData &state) "Dioxide Capacity Multiplier, Generic Contaminant Capacity Multiplier\n"); static constexpr std::string_view Format_701("Zone Volume Capacitance Multiplier,{:8.3F} ,{:8.3F},{:8.3F},{:8.3F}\n"); - auto &cCurrentModuleObject = state.dataIPShortCut->cCurrentModuleObject; + auto &s_ipsc = state.dataIPShortCut; + auto &s_ztpc = state.dataZoneTempPredictorCorrector; + auto &TStatObjects = state.dataZoneCtrls->TStatObjects; auto &Zone = state.dataHeatBal->Zone; auto &ZoneList = state.dataHeatBal->ZoneList; - auto &TempControlledZone = state.dataZoneCtrls->TempControlledZone; - auto &HumidityControlZone = state.dataZoneCtrls->HumidityControlZone; auto &ComfortTStatObjects = state.dataZoneCtrls->ComfortTStatObjects; - auto &ComfortControlledZone = state.dataZoneCtrls->ComfortControlledZone; int NumOfZones = state.dataGlobal->NumOfZones; - auto &StageControlledZone = state.dataZoneCtrls->StageControlledZone; - auto &SetPointSingleHeating = state.dataZoneTempPredictorCorrector->SetPointSingleHeating; - auto &SetPointSingleCooling = state.dataZoneTempPredictorCorrector->SetPointSingleCooling; - auto &cAlphaArgs = state.dataIPShortCut->cAlphaArgs; - auto &rNumericArgs = state.dataIPShortCut->rNumericArgs; - auto &lNumericFieldBlanks = state.dataIPShortCut->lNumericFieldBlanks; - auto &lAlphaFieldBlanks = state.dataIPShortCut->lAlphaFieldBlanks; - auto &cAlphaFieldNames = state.dataIPShortCut->cAlphaFieldNames; - auto &cNumericFieldNames = state.dataIPShortCut->cNumericFieldNames; - auto &inputProcessor = state.dataInputProcessing->inputProcessor; - auto &SetPointDualHeatCool = state.dataZoneTempPredictorCorrector->SetPointDualHeatCool; - - cCurrentModuleObject = cZControlTypes(static_cast(ZoneControlTypes::TStat)); + auto &s_ip = state.dataInputProcessing->inputProcessor; + + s_ipsc->cCurrentModuleObject = cZControlTypes(static_cast(ZoneControlTypes::TStat)); // Update Num in state and make local convenience copy - int NumTStatStatements = state.dataZoneCtrls->NumTStatStatements = inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); + int NumTStatStatements = state.dataZoneCtrls->NumTStatStatements = s_ip->getNumObjectsFound(state, s_ipsc->cCurrentModuleObject); TStatObjects.allocate(NumTStatStatements); // Pre-scan for use of Zone lists in TStat statements (i.e. Global application of TStat) state.dataZoneCtrls->NumTempControlledZones = 0; for (Item = 1; Item <= NumTStatStatements; ++Item) { - inputProcessor->getObjectItem(state, - cCurrentModuleObject, - Item, - cAlphaArgs, - NumAlphas, - rNumericArgs, - NumNums, - IOStat, - lNumericFieldBlanks, - lAlphaFieldBlanks, - cAlphaFieldNames, - cNumericFieldNames); - Util::IsNameEmpty(state, cAlphaArgs(1), cCurrentModuleObject, ErrorsFound); - - TStatObjects(Item).Name = cAlphaArgs(1); - Item1 = Util::FindItemInList(cAlphaArgs(2), Zone); + s_ip->getObjectItem(state, + s_ipsc->cCurrentModuleObject, + Item, + s_ipsc->cAlphaArgs, + NumAlphas, + s_ipsc->rNumericArgs, + NumNums, + IOStat, + s_ipsc->lNumericFieldBlanks, + s_ipsc->lAlphaFieldBlanks, + s_ipsc->cAlphaFieldNames, + s_ipsc->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)}; + Util::IsNameEmpty(state, s_ipsc->cAlphaArgs(1), s_ipsc->cCurrentModuleObject, ErrorsFound); + + TStatObjects(Item).Name = s_ipsc->cAlphaArgs(1); + Item1 = Util::FindItemInList(s_ipsc->cAlphaArgs(2), Zone); ZLItem = 0; - if (Item1 == 0 && state.dataHeatBal->NumOfZoneLists > 0) ZLItem = Util::FindItemInList(cAlphaArgs(2), ZoneList); + if (Item1 == 0 && state.dataHeatBal->NumOfZoneLists > 0) ZLItem = Util::FindItemInList(s_ipsc->cAlphaArgs(2), ZoneList); if (Item1 > 0) { TStatObjects(Item).TempControlledZoneStartPtr = state.dataZoneCtrls->NumTempControlledZones + 1; ++state.dataZoneCtrls->NumTempControlledZones; @@ -386,609 +364,472 @@ void GetZoneAirSetPoints(EnergyPlusData &state) TStatObjects(Item).ZoneListActive = true; TStatObjects(Item).ZoneOrZoneListPtr = ZLItem; } else { - ShowSevereError( - state, format("{}=\"{}\" invalid {}=\"{}\" not found.", cCurrentModuleObject, cAlphaArgs(1), cAlphaFieldNames(2), cAlphaArgs(2))); + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2)); ErrorsFound = true; } } if (ErrorsFound) { - ShowSevereError(state, format("GetZoneAirSetpoints: Errors with invalid names in {} objects.", cCurrentModuleObject)); + ShowSevereError(state, format("GetZoneAirSetpoints: Errors with invalid names in {} objects.", s_ipsc->cCurrentModuleObject)); ShowContinueError(state, "...These will not be read in. Other errors may occur."); state.dataZoneCtrls->NumTempControlledZones = 0; } if (state.dataZoneCtrls->NumTempControlledZones > 0) { - TempControlledZone.allocate(state.dataZoneCtrls->NumTempControlledZones); + state.dataZoneCtrls->TempControlledZone.allocate(state.dataZoneCtrls->NumTempControlledZones); TStatControlTypes.allocate(state.dataZoneCtrls->NumTempControlledZones); // Number of set point types CTSchedMapToControlledZone.dimension(state.dataZoneCtrls->NumTempControlledZones, 0); TempControlledZoneNum = 0; - state.dataZoneTempPredictorCorrector->NumOnOffCtrZone = 0; + s_ztpc->NumOnOffCtrZone = 0; for (Item = 1; Item <= NumTStatStatements; ++Item) { - inputProcessor->getObjectItem(state, - cCurrentModuleObject, - Item, - cAlphaArgs, - NumAlphas, - rNumericArgs, - NumNums, - IOStat, - lNumericFieldBlanks, - lAlphaFieldBlanks, - cAlphaFieldNames, - cNumericFieldNames); + s_ip->getObjectItem(state, + s_ipsc->cCurrentModuleObject, + Item, + s_ipsc->cAlphaArgs, + NumAlphas, + s_ipsc->rNumericArgs, + NumNums, + IOStat, + s_ipsc->lNumericFieldBlanks, + s_ipsc->lAlphaFieldBlanks, + s_ipsc->cAlphaFieldNames, + s_ipsc->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)}; + for (Item1 = 1; Item1 <= TStatObjects(Item).NumOfZones; ++Item1) { ++TempControlledZoneNum; + auto &tempZone = state.dataZoneCtrls->TempControlledZone(TempControlledZoneNum); + if (TStatObjects(Item).ZoneListActive) { - cAlphaArgs(2) = Zone(ZoneList(TStatObjects(Item).ZoneOrZoneListPtr).Zone(Item1)).Name; + s_ipsc->cAlphaArgs(2) = Zone(ZoneList(TStatObjects(Item).ZoneOrZoneListPtr).Zone(Item1)).Name; } int ZoneAssigned = - Util::FindItemInList(cAlphaArgs(2), TempControlledZone, &DataZoneControls::ZoneTempControls::ZoneName, TempControlledZoneNum - 1); + Util::FindItemInList(s_ipsc->cAlphaArgs(2), state.dataZoneCtrls->TempControlledZone, &DataZoneControls::ZoneTempControls::ZoneName, TempControlledZoneNum - 1); if (ZoneAssigned == 0) { - TempControlledZone(TempControlledZoneNum).ZoneName = cAlphaArgs(2); - TempControlledZone(TempControlledZoneNum).ActualZoneNum = Util::FindItemInList(cAlphaArgs(2), Zone); - if (TempControlledZone(TempControlledZoneNum).ActualZoneNum == 0) { - ShowSevereError( - state, - format( - "{}=\"{}\" invalid {}=\"{}\" not found.", cCurrentModuleObject, cAlphaArgs(1), cAlphaFieldNames(2), cAlphaArgs(2))); + tempZone.ZoneName = s_ipsc->cAlphaArgs(2); + tempZone.ActualZoneNum = Util::FindItemInList(s_ipsc->cAlphaArgs(2), Zone); + if (tempZone.ActualZoneNum == 0) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2)); ErrorsFound = true; } else { - Zone(TempControlledZone(TempControlledZoneNum).ActualZoneNum).TempControlledZoneIndex = TempControlledZoneNum; + Zone(tempZone.ActualZoneNum).TempControlledZoneIndex = TempControlledZoneNum; } } else { - TempControlledZone(TempControlledZoneNum).ZoneName = cAlphaArgs(2); // for continuity - ShowSevereError(state, - format("{}=\"{}\" invalid {}=\"{}\" zone previously assigned.", - cCurrentModuleObject, - cAlphaArgs(1), - cAlphaFieldNames(2), - cAlphaArgs(2))); - ShowContinueError(state, format("...Zone was previously assigned to Thermostat=\"{}\".", TempControlledZone(ZoneAssigned).Name)); + tempZone.ZoneName = s_ipsc->cAlphaArgs(2); // for continuity + ShowSevereDuplicateAssignment(state, eoh, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2), + state.dataZoneCtrls->TempControlledZone(ZoneAssigned).Name); ErrorsFound = true; continue; } if (!TStatObjects(Item).ZoneListActive) { - TempControlledZone(TempControlledZoneNum).Name = cAlphaArgs(1); + tempZone.Name = s_ipsc->cAlphaArgs(1); } else { CheckCreatedZoneItemName(state, RoutineName, - cCurrentModuleObject, + s_ipsc->cCurrentModuleObject, Zone(ZoneList(TStatObjects(Item).ZoneOrZoneListPtr).Zone(Item1)).Name, ZoneList(TStatObjects(Item).ZoneOrZoneListPtr).MaxZoneNameLength, TStatObjects(Item).Name, - TempControlledZone, + state.dataZoneCtrls->TempControlledZone, TempControlledZoneNum - 1, - TempControlledZone(TempControlledZoneNum).Name, + tempZone.Name, errFlag); if (errFlag) ErrorsFound = true; } - TempControlledZone(TempControlledZoneNum).ControlTypeSchedName = cAlphaArgs(3); - TempControlledZone(TempControlledZoneNum).CTSchedIndex = GetScheduleIndex(state, cAlphaArgs(3)); + tempZone.setptTypeSched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(3)); if (Item1 == 1) { // only show error on first of several if zone list - if (TempControlledZone(TempControlledZoneNum).CTSchedIndex == 0) { - ShowSevereError( - state, - format( - "{}=\"{}\" invalid {}=\"{}\" not found.", cCurrentModuleObject, cAlphaArgs(1), cAlphaFieldNames(3), cAlphaArgs(3))); + if (tempZone.setptTypeSched == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(3), s_ipsc->cAlphaArgs(3)); + ErrorsFound = true; + } else if (!tempZone.setptTypeSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 4.0)) { + Sched::ShowSevereBadMinMax(state, eoh, s_ipsc->cAlphaFieldNames(3), s_ipsc->cAlphaArgs(3), Clusive::In, 0.0, Clusive::In, 4.0); ErrorsFound = true; - } else { - // Check validity of control types. - ValidScheduleControlType = - CheckScheduleValueMinMax(state, TempControlledZone(TempControlledZoneNum).CTSchedIndex, ">=", 0.0, "<=", 4.0); - if (!ValidScheduleControlType) { - ShowSevereError( - state, - format("{}=\"{}\" invalid range {}=\"{}\"", cCurrentModuleObject, cAlphaArgs(1), cAlphaFieldNames(2), cAlphaArgs(2))); - ShowContinueError(state, "..contains values outside of range [0,4]."); - ErrorsFound = true; - } } } - if (lAlphaFieldBlanks(7)) { + if (s_ipsc->lAlphaFieldBlanks(7)) { NumAlphas = 5; - } else if (lAlphaFieldBlanks(9)) { + } else if (s_ipsc->lAlphaFieldBlanks(9)) { NumAlphas = 7; - } else if (lAlphaFieldBlanks(11)) { + } else if (s_ipsc->lAlphaFieldBlanks(11)) { NumAlphas = 9; } - TempControlledZone(TempControlledZoneNum).NumControlTypes = nint((NumAlphas - 3.0) / 2.0); - TempControlledZone(TempControlledZoneNum).ControlType.allocate(TempControlledZone(TempControlledZoneNum).NumControlTypes); - TempControlledZone(TempControlledZoneNum).ControlTypeName.allocate(TempControlledZone(TempControlledZoneNum).NumControlTypes); - TempControlledZone(TempControlledZoneNum).ControlTypeEnum.allocate(TempControlledZone(TempControlledZoneNum).NumControlTypes); - - for (ControlTypeNum = 1; ControlTypeNum <= TempControlledZone(TempControlledZoneNum).NumControlTypes; ++ControlTypeNum) { - - TempControlledZone(TempControlledZoneNum).ControlType(ControlTypeNum) = cAlphaArgs(nint(2.0 * ControlTypeNum - 1 + 3)); - TempControlledZone(TempControlledZoneNum).ControlTypeName(ControlTypeNum) = cAlphaArgs(nint(2.0 * ControlTypeNum + 3)); - - if (!TempControlledZone(TempControlledZoneNum).ControlType(ControlTypeNum).empty()) { - HVAC::ThermostatType ctrlType = static_cast( - getEnumValue(ValidControlTypesUC, TempControlledZone(TempControlledZoneNum).ControlType(ControlTypeNum))); - TempControlledZone(TempControlledZoneNum).ControlTypeEnum(ControlTypeNum) = ctrlType; - if (ctrlType == HVAC::ThermostatType::Invalid) { - ShowSevereError(state, - format("{}=\"{}\" invalid {}=\"{}\"", - cCurrentModuleObject, - cAlphaArgs(1), - cAlphaFieldNames(nint(2.0 * ControlTypeNum - 1 + 3)), - cAlphaArgs(nint(2.0 * ControlTypeNum - 1 + 3)))); - ErrorsFound = true; - } - } else { - ShowSevereError(state, - format("{}=\"{}\" invalid {}=\"\"", - cCurrentModuleObject, - cAlphaArgs(1), - cAlphaFieldNames(nint(2.0 * ControlTypeNum - 1 + 3)))); + int NumSetptTypes = nint((NumAlphas - 3.0) / 2.0); + + for (int iSetpt = 1; iSetpt <= NumSetptTypes; ++iSetpt) { + + HVAC::SetptType setptType = HVAC::SetptType::Invalid; + int spIdx = 2 * iSetpt - 1 + 3; + + if (s_ipsc->lAlphaFieldBlanks(spIdx)) { + ShowSevereEmptyField(state, eoh, s_ipsc->cAlphaFieldNames(spIdx)); ErrorsFound = true; + continue; + } else if ((setptType = static_cast(getEnumValue(setptTypeNamesUC, s_ipsc->cAlphaArgs(spIdx)))) == HVAC::SetptType::Invalid) { + ShowSevereInvalidKey(state, eoh, s_ipsc->cAlphaFieldNames(spIdx), s_ipsc->cAlphaArgs(spIdx)); + ErrorsFound = true; + continue; } + + tempZone.setpts[(int)setptType].Name = s_ipsc->cAlphaArgs(2 * iSetpt + 3); + tempZone.setpts[(int)setptType].isUsed = true; } + if (NumNums > 0) { - if (rNumericArgs(1) >= 0.0) { - TempControlledZone(TempControlledZoneNum).DeltaTCutSet = rNumericArgs(1); - if (rNumericArgs(1) > 0.0) state.dataZoneTempPredictorCorrector->NumOnOffCtrZone++; + if (s_ipsc->rNumericArgs(1) >= 0.0) { + tempZone.DeltaTCutSet = s_ipsc->rNumericArgs(1); + if (s_ipsc->rNumericArgs(1) > 0.0) s_ztpc->NumOnOffCtrZone++; } else { ShowSevereError( state, - format("{}=\"{} invalid {}=[{:.0T}].", cCurrentModuleObject, cAlphaArgs(1), cNumericFieldNames(1), rNumericArgs(1))); + format("{}=\"{} invalid {}=[{:.0T}].", s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1), s_ipsc->cNumericFieldNames(1), s_ipsc->rNumericArgs(1))); ShowContinueError(state, "..Allowable values must be greater or equal to 0"); ErrorsFound = true; } } - if (TempControlledZone(TempControlledZoneNum).DeltaTCutSet > 0.0) { - for (ControlTypeNum = 1; ControlTypeNum <= TempControlledZone(TempControlledZoneNum).NumControlTypes; ++ControlTypeNum) { - if (Util::SameString(TempControlledZone(TempControlledZoneNum).ControlType(ControlTypeNum), - "ThermostatSetpoint:SingleHeatingOrCooling")) { - ShowWarningError(state, - format("{}=\"{}: The choice of Temperature Difference Between Cutout And Setpoint will not be applied " - "to ThermostatSetpoint:SingleHeatingOrCooling.", - cCurrentModuleObject, - cAlphaArgs(1))); - } - } + + if (tempZone.DeltaTCutSet > 0.0 && + tempZone.setpts[(int)HVAC::SetptType::SingleHeatCool].Name != "") { + ShowWarningError(state, + format("{}=\"{}: The choice of Temperature Difference Between Cutout And Setpoint will not be applied " + "to ThermostatSetpoint:SingleHeatingOrCooling.", + s_ipsc->cCurrentModuleObject, + s_ipsc->cAlphaArgs(1))); } } } // NumTStatStatements } // Check on number of TempControlledZones - cCurrentModuleObject = ValidControlTypesUC[static_cast(HVAC::ThermostatType::SingleHeating)]; - state.dataZoneTempPredictorCorrector->NumSingleTempHeatingControls = inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); - - if (state.dataZoneTempPredictorCorrector->NumSingleTempHeatingControls > 0) - SetPointSingleHeating.allocate(state.dataZoneTempPredictorCorrector->NumSingleTempHeatingControls); - - for (int idx = 1; idx <= state.dataZoneTempPredictorCorrector->NumSingleTempHeatingControls; ++idx) { - inputProcessor->getObjectItem(state, - cCurrentModuleObject, - idx, - cAlphaArgs, - NumAlphas, - rNumericArgs, - NumNums, - IOStat, - lNumericFieldBlanks, - lAlphaFieldBlanks, - cAlphaFieldNames, - cNumericFieldNames); - Util::IsNameEmpty(state, cAlphaArgs(1), cCurrentModuleObject, ErrorsFound); - auto &singleHtgSetpoint = SetPointSingleHeating(idx); - singleHtgSetpoint.Name = cAlphaArgs(1); - singleHtgSetpoint.TempSchedName = cAlphaArgs(2); - singleHtgSetpoint.TempSchedIndex = GetScheduleIndex(state, cAlphaArgs(2)); - if (singleHtgSetpoint.TempSchedIndex == 0) { - ShowSevereError( - state, format("{}=\"{}\" invalid {}=\"{}\" not found.", cCurrentModuleObject, cAlphaArgs(1), cAlphaFieldNames(2), cAlphaArgs(2))); + s_ipsc->cCurrentModuleObject = setptTypeNamesUC[(int)HVAC::SetptType::SingleHeat]; + s_ztpc->NumTempControls[(int)HVAC::SetptType::SingleHeat] = s_ip->getNumObjectsFound(state, s_ipsc->cCurrentModuleObject); + + if (s_ztpc->NumTempControls[(int)HVAC::SetptType::SingleHeat] > 0) + s_ztpc->tempSetptScheds[(int)HVAC::SetptType::SingleHeat].allocate(s_ztpc->NumTempControls[(int)HVAC::SetptType::SingleHeat]); + + for (int idx = 1; idx <= s_ztpc->NumTempControls[(int)HVAC::SetptType::SingleHeat]; ++idx) { + s_ip->getObjectItem(state, + s_ipsc->cCurrentModuleObject, + idx, + s_ipsc->cAlphaArgs, + NumAlphas, + s_ipsc->rNumericArgs, + NumNums, + IOStat, + s_ipsc->lNumericFieldBlanks, + s_ipsc->lAlphaFieldBlanks, + s_ipsc->cAlphaFieldNames, + s_ipsc->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)}; + + Util::IsNameEmpty(state, s_ipsc->cAlphaArgs(1), s_ipsc->cCurrentModuleObject, ErrorsFound); + auto &setpt = s_ztpc->tempSetptScheds[(int)HVAC::SetptType::SingleHeat](idx); + setpt.Name = s_ipsc->cAlphaArgs(1); + + if (s_ipsc->lAlphaFieldBlanks(2)) { + ShowSevereEmptyField(state, eoh, s_ipsc->cAlphaFieldNames(2)); + ErrorsFound = true; + } else if ((setpt.heatSched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2)); ErrorsFound = true; } } // SingleTempHeatingControlNum - cCurrentModuleObject = ValidControlTypesUC[static_cast(HVAC::ThermostatType::SingleCooling)]; - state.dataZoneTempPredictorCorrector->NumSingleTempCoolingControls = inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); - - if (state.dataZoneTempPredictorCorrector->NumSingleTempCoolingControls > 0) - SetPointSingleCooling.allocate(state.dataZoneTempPredictorCorrector->NumSingleTempCoolingControls); - - for (int idx = 1; idx <= state.dataZoneTempPredictorCorrector->NumSingleTempCoolingControls; ++idx) { - inputProcessor->getObjectItem(state, - cCurrentModuleObject, - idx, - cAlphaArgs, - NumAlphas, - rNumericArgs, - NumNums, - IOStat, - lNumericFieldBlanks, - lAlphaFieldBlanks, - cAlphaFieldNames, - cNumericFieldNames); - Util::IsNameEmpty(state, cAlphaArgs(1), cCurrentModuleObject, ErrorsFound); - auto &singleClgSetpoint = SetPointSingleCooling(idx); - singleClgSetpoint.Name = cAlphaArgs(1); - singleClgSetpoint.TempSchedName = cAlphaArgs(2); - singleClgSetpoint.TempSchedIndex = GetScheduleIndex(state, cAlphaArgs(2)); - if (singleClgSetpoint.TempSchedIndex == 0) { - ShowSevereError( - state, format("{}=\"{}\" invalid {}=\"{}\" not found.", cCurrentModuleObject, cAlphaArgs(1), cAlphaFieldNames(2), cAlphaArgs(2))); + s_ipsc->cCurrentModuleObject = setptTypeNamesUC[(int)HVAC::SetptType::SingleCool]; + s_ztpc->NumTempControls[(int)HVAC::SetptType::SingleCool] = s_ip->getNumObjectsFound(state, s_ipsc->cCurrentModuleObject); + + if (s_ztpc->NumTempControls[(int)HVAC::SetptType::SingleCool] > 0) + s_ztpc->tempSetptScheds[(int)HVAC::SetptType::SingleCool].allocate(s_ztpc->NumTempControls[(int)HVAC::SetptType::SingleCool]); + + for (int idx = 1; idx <= s_ztpc->NumTempControls[(int)HVAC::SetptType::SingleCool]; ++idx) { + s_ip->getObjectItem(state, + s_ipsc->cCurrentModuleObject, + idx, + s_ipsc->cAlphaArgs, + NumAlphas, + s_ipsc->rNumericArgs, + NumNums, + IOStat, + s_ipsc->lNumericFieldBlanks, + s_ipsc->lAlphaFieldBlanks, + s_ipsc->cAlphaFieldNames, + s_ipsc->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)}; + + Util::IsNameEmpty(state, s_ipsc->cAlphaArgs(1), s_ipsc->cCurrentModuleObject, ErrorsFound); + auto &setpt = s_ztpc->tempSetptScheds[(int)HVAC::SetptType::SingleCool](idx); + setpt.Name = s_ipsc->cAlphaArgs(1); + + if (s_ipsc->lAlphaFieldBlanks(2)) { + ShowSevereEmptyField(state, eoh, s_ipsc->cAlphaFieldNames(2)); + ErrorsFound = true; + } else if ((setpt.coolSched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2)); ErrorsFound = true; } } // SingleTempCoolingControlNum - cCurrentModuleObject = ValidControlTypes[static_cast(HVAC::ThermostatType::SingleHeatCool)]; - state.dataZoneTempPredictorCorrector->NumSingleTempHeatCoolControls = inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); - - if (state.dataZoneTempPredictorCorrector->NumSingleTempHeatCoolControls > 0) - state.dataZoneTempPredictorCorrector->SetPointSingleHeatCool.allocate(state.dataZoneTempPredictorCorrector->NumSingleTempHeatCoolControls); - - for (int idx = 1; idx <= state.dataZoneTempPredictorCorrector->NumSingleTempHeatCoolControls; ++idx) { - inputProcessor->getObjectItem(state, - cCurrentModuleObject, - idx, - cAlphaArgs, - NumAlphas, - rNumericArgs, - NumNums, - IOStat, - lNumericFieldBlanks, - lAlphaFieldBlanks, - cAlphaFieldNames, - cNumericFieldNames); - auto &singleHeatCoolSetpoint = state.dataZoneTempPredictorCorrector->SetPointSingleHeatCool(idx); - singleHeatCoolSetpoint.Name = cAlphaArgs(1); - singleHeatCoolSetpoint.TempSchedName = cAlphaArgs(2); - singleHeatCoolSetpoint.TempSchedIndex = GetScheduleIndex(state, cAlphaArgs(2)); - if (singleHeatCoolSetpoint.TempSchedIndex == 0) { - ShowSevereError( - state, format("{}=\"{}\" invalid {}=\"{}\" not found.", cCurrentModuleObject, cAlphaArgs(1), cAlphaFieldNames(2), cAlphaArgs(2))); + s_ipsc->cCurrentModuleObject = setptTypeNames[(int)HVAC::SetptType::SingleHeatCool]; + s_ztpc->NumTempControls[(int)HVAC::SetptType::SingleHeatCool] = s_ip->getNumObjectsFound(state, s_ipsc->cCurrentModuleObject); + + if (s_ztpc->NumTempControls[(int)HVAC::SetptType::SingleHeatCool] > 0) + s_ztpc->tempSetptScheds[(int)HVAC::SetptType::SingleHeatCool].allocate(s_ztpc->NumTempControls[(int)HVAC::SetptType::SingleHeatCool]); + + for (int idx = 1; idx <= s_ztpc->NumTempControls[(int)HVAC::SetptType::SingleHeatCool]; ++idx) { + s_ip->getObjectItem(state, + s_ipsc->cCurrentModuleObject, + idx, + s_ipsc->cAlphaArgs, + NumAlphas, + s_ipsc->rNumericArgs, + NumNums, + IOStat, + s_ipsc->lNumericFieldBlanks, + s_ipsc->lAlphaFieldBlanks, + s_ipsc->cAlphaFieldNames, + s_ipsc->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)}; + + auto &setpt = s_ztpc->tempSetptScheds[(int)HVAC::SetptType::SingleHeatCool](idx); + setpt.Name = s_ipsc->cAlphaArgs(1); + + if (s_ipsc->lAlphaFieldBlanks(2)) { + ShowSevereEmptyField(state, eoh, s_ipsc->cAlphaFieldNames(2)); + ErrorsFound = true; + } else if ((setpt.heatSched = setpt.coolSched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2)); ErrorsFound = true; } } // SingleTempHeatCoolControlNum - cCurrentModuleObject = ValidControlTypes[static_cast(HVAC::ThermostatType::DualSetPointWithDeadBand)]; - state.dataZoneTempPredictorCorrector->NumDualTempHeatCoolControls = inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); + s_ipsc->cCurrentModuleObject = setptTypeNames[(int)HVAC::SetptType::DualHeatCool]; + s_ztpc->NumTempControls[(int)HVAC::SetptType::DualHeatCool] = s_ip->getNumObjectsFound(state, s_ipsc->cCurrentModuleObject); - if (state.dataZoneTempPredictorCorrector->NumDualTempHeatCoolControls > 0) - SetPointDualHeatCool.allocate(state.dataZoneTempPredictorCorrector->NumDualTempHeatCoolControls); + if (s_ztpc->NumTempControls[(int)HVAC::SetptType::DualHeatCool] > 0) + s_ztpc->tempSetptScheds[(int)HVAC::SetptType::DualHeatCool].allocate(s_ztpc->NumTempControls[(int)HVAC::SetptType::DualHeatCool]); - for (int idx = 1; idx <= state.dataZoneTempPredictorCorrector->NumDualTempHeatCoolControls; ++idx) { - inputProcessor->getObjectItem(state, - cCurrentModuleObject, - idx, - cAlphaArgs, + for (int idx = 1; idx <= s_ztpc->NumTempControls[(int)HVAC::SetptType::DualHeatCool]; ++idx) { + s_ip->getObjectItem(state, + s_ipsc->cCurrentModuleObject, + idx, + s_ipsc->cAlphaArgs, NumAlphas, - rNumericArgs, + s_ipsc->rNumericArgs, NumNums, IOStat, - lNumericFieldBlanks, - lAlphaFieldBlanks, - cAlphaFieldNames, - cNumericFieldNames); - Util::IsNameEmpty(state, cAlphaArgs(1), cCurrentModuleObject, ErrorsFound); - auto &dualHeatCoolSetpoint = SetPointDualHeatCool(idx); - dualHeatCoolSetpoint.Name = cAlphaArgs(1); - dualHeatCoolSetpoint.HeatTempSetptSchedName = cAlphaArgs(2); - dualHeatCoolSetpoint.HeatTempSchedIndex = GetScheduleIndex(state, cAlphaArgs(2)); - if (dualHeatCoolSetpoint.HeatTempSchedIndex == 0) { - ShowSevereError( - state, format("{}=\"{}\" invalid {}=\"{}\" not found.", cCurrentModuleObject, cAlphaArgs(1), cAlphaFieldNames(2), cAlphaArgs(2))); + s_ipsc->lNumericFieldBlanks, + s_ipsc->lAlphaFieldBlanks, + s_ipsc->cAlphaFieldNames, + s_ipsc->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)}; + Util::IsNameEmpty(state, s_ipsc->cAlphaArgs(1), s_ipsc->cCurrentModuleObject, ErrorsFound); + auto &setpt = s_ztpc->tempSetptScheds[(int)HVAC::SetptType::DualHeatCool](idx); + setpt.Name = s_ipsc->cAlphaArgs(1); + + if (s_ipsc->lAlphaFieldBlanks(2)) { + ShowSevereEmptyField(state, eoh, s_ipsc->cAlphaFieldNames(2)); + ErrorsFound = true; + } else if ((setpt.heatSched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2)); ErrorsFound = true; } - dualHeatCoolSetpoint.CoolTempSetptSchedName = cAlphaArgs(3); - dualHeatCoolSetpoint.CoolTempSchedIndex = GetScheduleIndex(state, cAlphaArgs(3)); - if (dualHeatCoolSetpoint.CoolTempSchedIndex == 0) { - ShowSevereError( - state, format("{}=\"{}\" invalid {}=\"{}\" not found.", cCurrentModuleObject, cAlphaArgs(1), cAlphaFieldNames(3), cAlphaArgs(3))); + + if (s_ipsc->lAlphaFieldBlanks(3)) { + ShowSevereEmptyField(state, eoh, s_ipsc->cAlphaFieldNames(3)); + ErrorsFound = true; + } else if ((setpt.coolSched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(3))) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(3), s_ipsc->cAlphaArgs(3)); ErrorsFound = true; } } // DualTempHeatCoolControlNum // Finish filling in Schedule pointing indexes - int setPointObjectArrayIndex; for (TempControlledZoneNum = 1; TempControlledZoneNum <= state.dataZoneCtrls->NumTempControlledZones; ++TempControlledZoneNum) { - for (int ct = 1; ct <= state.dataZoneCtrls->TempControlledZone(TempControlledZoneNum).NumControlTypes; ct++) { - switch (state.dataZoneCtrls->TempControlledZone(TempControlledZoneNum).ControlTypeEnum(ct)) { - case HVAC::ThermostatType::SingleHeating: - setPointObjectArrayIndex = Util::FindItem(TempControlledZone(TempControlledZoneNum).ControlTypeName(ct), SetPointSingleHeating); - TempControlledZone(TempControlledZoneNum).SchIndx_SingleHeatSetPoint = - state.dataZoneTempPredictorCorrector->SetPointSingleHeating(setPointObjectArrayIndex).TempSchedIndex; - break; - case HVAC::ThermostatType::SingleCooling: - setPointObjectArrayIndex = Util::FindItem(TempControlledZone(TempControlledZoneNum).ControlTypeName(ct), SetPointSingleCooling); - TempControlledZone(TempControlledZoneNum).SchIndx_SingleCoolSetPoint = - state.dataZoneTempPredictorCorrector->SetPointSingleCooling(setPointObjectArrayIndex).TempSchedIndex; - break; - case HVAC::ThermostatType::SingleHeatCool: - setPointObjectArrayIndex = Util::FindItem(TempControlledZone(TempControlledZoneNum).ControlTypeName(ct), - state.dataZoneTempPredictorCorrector->SetPointSingleHeatCool); - TempControlledZone(TempControlledZoneNum).SchIndx_SingleHeatCoolSetPoint = - state.dataZoneTempPredictorCorrector->SetPointSingleHeatCool(setPointObjectArrayIndex).TempSchedIndex; - break; - case HVAC::ThermostatType::DualSetPointWithDeadBand: - setPointObjectArrayIndex = Util::FindItem(TempControlledZone(TempControlledZoneNum).ControlTypeName(ct), - state.dataZoneTempPredictorCorrector->SetPointDualHeatCool); - TempControlledZone(TempControlledZoneNum).SchIndx_DualSetPointWDeadBandHeat = - state.dataZoneTempPredictorCorrector->SetPointDualHeatCool(setPointObjectArrayIndex).HeatTempSchedIndex; - TempControlledZone(TempControlledZoneNum).SchIndx_DualSetPointWDeadBandCool = - state.dataZoneTempPredictorCorrector->SetPointDualHeatCool(setPointObjectArrayIndex).CoolTempSchedIndex; - break; - default: - assert(false); + auto &tempZone = state.dataZoneCtrls->TempControlledZone(TempControlledZoneNum); + + for (HVAC::SetptType setptType : HVAC::setptTypes) { + auto &setpt = tempZone.setpts[(int)setptType]; + if (!setpt.isUsed) continue; + + int setptIdx = Util::FindItem(setpt.Name, s_ztpc->tempSetptScheds[(int)setptType]); + + if (setptType == HVAC::SetptType::SingleHeat || setptType == HVAC::SetptType::SingleHeatCool || setptType == HVAC::SetptType::DualHeatCool) { + setpt.heatSetptSched = s_ztpc->tempSetptScheds[(int)setptType](setptIdx).heatSched; + } + + if (setptType == HVAC::SetptType::SingleCool || setptType == HVAC::SetptType::SingleHeatCool || setptType == HVAC::SetptType::DualHeatCool) { + setpt.coolSetptSched = s_ztpc->tempSetptScheds[(int)setptType](setptIdx).coolSched; } } } // Now, Check the schedule values/indices for validity - for (TempControlledZoneNum = 1; TempControlledZoneNum <= state.dataZoneCtrls->NumTempControlledZones; ++TempControlledZoneNum) { + for (int TempControlledZoneNum = 1; TempControlledZoneNum <= state.dataZoneCtrls->NumTempControlledZones; ++TempControlledZoneNum) { + auto &tempZone = state.dataZoneCtrls->TempControlledZone(TempControlledZoneNum); - ActualZoneNum = TempControlledZone(TempControlledZoneNum).ActualZoneNum; - CTIndex = TempControlledZone(TempControlledZoneNum).CTSchedIndex; - if (CTIndex == 0) continue; // error will be caught elsewhere - SchedMin = GetScheduleMinValue(state, CTIndex); - SchedMax = GetScheduleMaxValue(state, CTIndex); + if (tempZone.setptTypeSched == nullptr) continue; // error will be caught elsewhere + + int SchedMin = tempZone.setptTypeSched->getMinVal(state); + int SchedMax = tempZone.setptTypeSched->getMaxVal(state); - if (SchedMin == 0 && SchedMax == 0) { - if (FindNumberInList(CTIndex, CTSchedMapToControlledZone, state.dataZoneCtrls->NumTempControlledZones) == 0) { - ShowSevereError(state, format("Control Type Schedule={}", TempControlledZone(TempControlledZoneNum).ControlTypeSchedName)); + if (SchedMin == (int)HVAC::SetptType::Uncontrolled && SchedMax == (int)HVAC::SetptType::Uncontrolled) { + if (FindNumberInList(tempZone.setptTypeSched->Num, CTSchedMapToControlledZone, state.dataZoneCtrls->NumTempControlledZones) == 0) { + ShowSevereError(state, format("Control Type Schedule={}", tempZone.setptTypeSched->Name)); ShowContinueError(state, "..specifies control type 0 for all entries."); ShowContinueError(state, "All zones using this Control Type Schedule have no heating or cooling available."); } - CTSchedMapToControlledZone(TempControlledZoneNum) = CTIndex; + CTSchedMapToControlledZone(TempControlledZoneNum) = tempZone.setptTypeSched->Num; } - for (ControlTypeNum = SchedMin; ControlTypeNum <= SchedMax; ++ControlTypeNum) { - - int TempIndex = 0; - switch (static_cast(ControlTypeNum)) { - case HVAC::ThermostatType::Uncontrolled: - break; - case HVAC::ThermostatType::SingleHeating: - TempIndex = TempControlledZone(TempControlledZoneNum).SchIndx_SingleHeatSetPoint; - if (TempIndex == 0) { - if (CheckScheduleValue(state, CTIndex, static_cast(HVAC::ThermostatType::SingleHeating))) { - ShowSevereError(state, format("Control Type Schedule={}", TempControlledZone(TempControlledZoneNum).ControlTypeSchedName)); - ShowContinueError(state, - format("..specifies control type 1 ({}) as the control type. Not valid for this zone.", - ValidControlTypes[static_cast(HVAC::ThermostatType::SingleHeating)])); - ShowContinueError(state, - format("..reference {}={}", - cZControlTypes(static_cast(ZoneControlTypes::TStat)), - TempControlledZone(TempControlledZoneNum).Name)); - ShowContinueError(state, format("..reference ZONE={}", TempControlledZone(TempControlledZoneNum).ZoneName)); - ErrorsFound = true; - } - } - break; - case HVAC::ThermostatType::SingleCooling: - TempIndex = TempControlledZone(TempControlledZoneNum).SchIndx_SingleCoolSetPoint; - if (TempIndex == 0) { - if (CheckScheduleValue(state, CTIndex, static_cast(HVAC::ThermostatType::SingleCooling))) { - ShowSevereError(state, format("Control Type Schedule={}", TempControlledZone(TempControlledZoneNum).ControlTypeSchedName)); - ShowContinueError(state, - format("..specifies control type 2 ({}) as the control type. Not valid for this zone.", - ValidControlTypes[static_cast(HVAC::ThermostatType::SingleCooling)])); - ShowContinueError(state, - format("..reference {}={}", - cZControlTypes(static_cast(ZoneControlTypes::TStat)), - TempControlledZone(TempControlledZoneNum).Name)); - ShowContinueError(state, format("..reference ZONE={}", TempControlledZone(TempControlledZoneNum).ZoneName)); - ErrorsFound = true; - } - } - break; - case HVAC::ThermostatType::SingleHeatCool: - TempIndex = TempControlledZone(TempControlledZoneNum).SchIndx_SingleHeatCoolSetPoint; - if (TempIndex == 0) { - if (CheckScheduleValue(state, CTIndex, static_cast(HVAC::ThermostatType::SingleHeatCool))) { - ShowSevereError(state, format("Schedule={}", TempControlledZone(TempControlledZoneNum).ControlTypeSchedName)); - ShowContinueError(state, - format("..specifies control type 3 ({}) as the control type. Not valid for this zone.", - ValidControlTypes[static_cast(HVAC::ThermostatType::SingleHeatCool)])); - ShowContinueError(state, - format("..reference {}={}", - cZControlTypes(static_cast(ZoneControlTypes::TStat)), - TempControlledZone(TempControlledZoneNum).Name)); - ShowContinueError(state, format("..reference ZONE={}", TempControlledZone(TempControlledZoneNum).ZoneName)); - ErrorsFound = true; - } - } - break; - case HVAC::ThermostatType::DualSetPointWithDeadBand: - TempIndex = TempControlledZone(TempControlledZoneNum) - .SchIndx_DualSetPointWDeadBandHeat; // using "Heat" as a sentinel that dualsetpoint is on this zone control object - if (TempIndex == 0) { - if (CheckScheduleValue(state, CTIndex, static_cast(HVAC::ThermostatType::DualSetPointWithDeadBand))) { - ShowSevereError(state, format("Schedule={}", TempControlledZone(TempControlledZoneNum).ControlTypeSchedName)); - ShowContinueError(state, - format("..specifies control type 4 ({}) as the control type. Not valid for this zone.", - ValidControlTypes[static_cast(HVAC::ThermostatType::DualSetPointWithDeadBand)])); - ShowContinueError(state, - format("..reference {}={}", - cZControlTypes(static_cast(ZoneControlTypes::TStat)), - TempControlledZone(TempControlledZoneNum).Name)); - ShowContinueError(state, format("..reference ZONE={}", TempControlledZone(TempControlledZoneNum).ZoneName)); - ErrorsFound = true; - } - } - break; - default: - ShowSevereError(state, - format("GetZoneAirSetpoints: Illegal control type for Zone={}, Found value={}, in Schedule={}", - Zone(ActualZoneNum).Name, - ControlTypeNum, - TempControlledZone(TempControlledZoneNum).ControlTypeSchedName)); - ShowContinueError(state, "..valid range values are [0,4]."); + for (HVAC::SetptType setptType : HVAC::setptTypes) { + auto const &setpt = tempZone.setpts[(int)setptType]; + if (!setpt.isUsed) continue; + + if (setpt.heatSetptSched == nullptr && + (setptType == HVAC::SetptType::SingleHeat || setptType == HVAC::SetptType::SingleHeatCool || setptType == HVAC::SetptType::DualHeatCool) && + tempZone.setptTypeSched->hasVal(state, (int)setptType)) { + ShowSevereError(state, format("Control Type Schedule={}", tempZone.setptTypeSched->Name)); + ShowContinueError(state, format("..specifies {} ({}) as the control type. Not valid for this zone.", (int)setptType, setptTypeNames[(int)setptType])); + ShowContinueError(state, format("..reference {}={}", cZControlTypes((int)ZoneControlTypes::TStat), tempZone.Name)); + ShowContinueError(state, format("..reference ZONE={}", tempZone.ZoneName)); ErrorsFound = true; - } - } + } + + if (setpt.coolSetptSched == nullptr && + (setptType == HVAC::SetptType::SingleCool || setptType == HVAC::SetptType::SingleHeatCool || setptType == HVAC::SetptType::DualHeatCool) && + tempZone.setptTypeSched->hasVal(state, (int)setptType)) { + ShowSevereError(state, format("Control Type Schedule={}", tempZone.setptTypeSched->Name)); + ShowContinueError(state, format("..specifies {} ({}) as the control type. Not valid for this zone.", (int)setptType, setptTypeNames[(int)setptType])); + ShowContinueError(state, format("..reference {}={}", cZControlTypes((int)ZoneControlTypes::TStat), tempZone.Name)); + ShowContinueError(state, format("..reference ZONE={}", tempZone.ZoneName)); + ErrorsFound = true; + } + } // for (setptType) } for (TempControlledZoneNum = 1; TempControlledZoneNum <= state.dataZoneCtrls->NumTempControlledZones; ++TempControlledZoneNum) { + auto &tempZone = state.dataZoneCtrls->TempControlledZone(TempControlledZoneNum); + ActualZoneNum = tempZone.ActualZoneNum; - ActualZoneNum = TempControlledZone(TempControlledZoneNum).ActualZoneNum; - CTIndex = TempControlledZone(TempControlledZoneNum).CTSchedIndex; - if (CTIndex == 0) continue; // error caught elsewhere -- would just be confusing here + if (tempZone.setptTypeSched == nullptr) continue; // error caught elsewhere -- would just be confusing here - for (ControlTypeNum = 1; ControlTypeNum <= 4; ++ControlTypeNum) { - if (TStatControlTypes(TempControlledZoneNum).MustHave[ControlTypeNum] && TStatControlTypes(TempControlledZoneNum).DidHave[ControlTypeNum]) + for (HVAC::SetptType setptType : HVAC::setptTypes) { + if (TStatControlTypes(TempControlledZoneNum).MustHave[(int)setptType] && TStatControlTypes(TempControlledZoneNum).DidHave[(int)setptType]) continue; - switch (static_cast(ControlTypeNum)) { - case HVAC::ThermostatType::SingleHeating: - if (!TStatControlTypes(TempControlledZoneNum).MustHave[ControlTypeNum]) continue; - ShowWarningError(state, format("Schedule={}", TempControlledZone(TempControlledZoneNum).ControlTypeSchedName)); - ShowContinueError(state, - format("...should include control type 1 ({}) but does not.", - ValidControlTypes[static_cast(HVAC::ThermostatType::SingleHeating)])); - ShowContinueError(state, - format("..reference {}={}", - cZControlTypes(static_cast(ZoneControlTypes::TStat)), - TempControlledZone(TempControlledZoneNum).Name)); - ShowContinueError(state, format("..reference ZONE={}", TempControlledZone(TempControlledZoneNum).ZoneName)); - break; - case HVAC::ThermostatType::SingleCooling: - if (!TStatControlTypes(TempControlledZoneNum).MustHave[ControlTypeNum]) continue; - ShowWarningError(state, format("Schedule={}", TempControlledZone(TempControlledZoneNum).ControlTypeSchedName)); - ShowContinueError(state, - format("...should include control type 2 ({}) but does not.", - ValidControlTypes[static_cast(HVAC::ThermostatType::SingleCooling)])); - ShowContinueError(state, - format("..reference {}={}", - cZControlTypes(static_cast(ZoneControlTypes::TStat)), - TempControlledZone(TempControlledZoneNum).Name)); - ShowContinueError(state, format("..reference ZONE={}", TempControlledZone(TempControlledZoneNum).ZoneName)); - break; - case HVAC::ThermostatType::SingleHeatCool: - if (!TStatControlTypes(TempControlledZoneNum).MustHave[ControlTypeNum]) continue; - ShowWarningError(state, format("Schedule={}", TempControlledZone(TempControlledZoneNum).ControlTypeSchedName)); - ShowContinueError(state, - format("...should include control type 3 ({}) but does not.", - ValidControlTypes[static_cast(HVAC::ThermostatType::SingleHeating)])); - ShowContinueError(state, - format("..reference {}={}", - cZControlTypes(static_cast(ZoneControlTypes::TStat)), - TempControlledZone(TempControlledZoneNum).Name)); - ShowContinueError(state, format("..reference ZONE={}", TempControlledZone(TempControlledZoneNum).ZoneName)); - break; - case HVAC::ThermostatType::DualSetPointWithDeadBand: - if (!TStatControlTypes(TempControlledZoneNum).MustHave[ControlTypeNum]) continue; - ShowWarningError(state, format("Schedule={}", TempControlledZone(TempControlledZoneNum).ControlTypeSchedName)); - ShowContinueError(state, - format("...should include control type 4 ({}) but does not.", - ValidControlTypes[static_cast(HVAC::ThermostatType::DualSetPointWithDeadBand)])); - ShowContinueError(state, - format("..reference {}={}", - cZControlTypes(static_cast(ZoneControlTypes::TStat)), - TempControlledZone(TempControlledZoneNum).Name)); - ShowContinueError(state, format("..reference ZONE={}", TempControlledZone(TempControlledZoneNum).ZoneName)); - break; - default: - break; - } + if (!TStatControlTypes(TempControlledZoneNum).MustHave[(int)setptType]) continue; + ShowWarningError(state, format("Schedule={}", tempZone.setptTypeSched->Name)); + ShowContinueError(state, format("...should include control type {} ({}) but does not.", (int)setptType, setptTypeNames[(int)setptType])); + ShowContinueError(state, format("..reference {}={}", cZControlTypes((int)ZoneControlTypes::TStat), tempZone.Name)); + ShowContinueError(state, format("..reference ZONE={}", tempZone.ZoneName)); } } if (allocated(TStatControlTypes)) TStatControlTypes.deallocate(); // This starts the Humidity Control Get Input section - cCurrentModuleObject = cZControlTypes(static_cast(ZoneControlTypes::HStat)); - state.dataZoneCtrls->NumHumidityControlZones = inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); + s_ipsc->cCurrentModuleObject = cZControlTypes(static_cast(ZoneControlTypes::HStat)); + state.dataZoneCtrls->NumHumidityControlZones = s_ip->getNumObjectsFound(state, s_ipsc->cCurrentModuleObject); if (state.dataZoneCtrls->NumHumidityControlZones > 0) { - HumidityControlZone.allocate(state.dataZoneCtrls->NumHumidityControlZones); - state.dataZoneTempPredictorCorrector->HumidityControlZoneUniqueNames.reserve( + state.dataZoneCtrls->HumidityControlZone.allocate(state.dataZoneCtrls->NumHumidityControlZones); + s_ztpc->HumidityControlZoneUniqueNames.reserve( static_cast(state.dataZoneCtrls->NumHumidityControlZones)); } for (HumidControlledZoneNum = 1; HumidControlledZoneNum <= state.dataZoneCtrls->NumHumidityControlZones; ++HumidControlledZoneNum) { - inputProcessor->getObjectItem(state, - cCurrentModuleObject, + s_ip->getObjectItem(state, + s_ipsc->cCurrentModuleObject, HumidControlledZoneNum, - cAlphaArgs, + s_ipsc->cAlphaArgs, NumAlphas, - rNumericArgs, + s_ipsc->rNumericArgs, NumNums, IOStat, - lNumericFieldBlanks, - lAlphaFieldBlanks, - cAlphaFieldNames, - cNumericFieldNames); - Util::IsNameEmpty(state, cAlphaArgs(1), cCurrentModuleObject, ErrorsFound); + s_ipsc->lNumericFieldBlanks, + s_ipsc->lAlphaFieldBlanks, + s_ipsc->cAlphaFieldNames, + s_ipsc->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)}; + + Util::IsNameEmpty(state, s_ipsc->cAlphaArgs(1), s_ipsc->cCurrentModuleObject, ErrorsFound); - HumidityControlZone(HumidControlledZoneNum).ControlName = cAlphaArgs(1); + auto &humidControlledZone = state.dataZoneCtrls->HumidityControlZone(HumidControlledZoneNum); + humidControlledZone.ControlName = s_ipsc->cAlphaArgs(1); GlobalNames::IntraObjUniquenessCheck(state, - cAlphaArgs(2), - cCurrentModuleObject, - cAlphaFieldNames(2), - state.dataZoneTempPredictorCorrector->HumidityControlZoneUniqueNames, + s_ipsc->cAlphaArgs(2), + s_ipsc->cCurrentModuleObject, + s_ipsc->cAlphaFieldNames(2), + s_ztpc->HumidityControlZoneUniqueNames, ErrorsFound); - HumidityControlZone(HumidControlledZoneNum).ZoneName = cAlphaArgs(2); - HumidityControlZone(HumidControlledZoneNum).ActualZoneNum = Util::FindItem(cAlphaArgs(2), Zone); - if (HumidityControlZone(HumidControlledZoneNum).ActualZoneNum == 0) { + humidControlledZone.ZoneName = s_ipsc->cAlphaArgs(2); + humidControlledZone.ActualZoneNum = Util::FindItem(s_ipsc->cAlphaArgs(2), Zone); + if (humidControlledZone.ActualZoneNum == 0) { ShowSevereError(state, - format("{}=\"{} invalid {}=\"{}\" not found.", cCurrentModuleObject, cAlphaArgs(1), cAlphaFieldNames(2), cAlphaArgs(2))); + format("{}=\"{} invalid {}=\"{}\" not found.", s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1), s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2))); ErrorsFound = true; } else { - state.dataHeatBal->Zone(HumidityControlZone(HumidControlledZoneNum).ActualZoneNum).humidityControlZoneIndex = HumidControlledZoneNum; + state.dataHeatBal->Zone(humidControlledZone.ActualZoneNum).humidityControlZoneIndex = HumidControlledZoneNum; } - HumidityControlZone(HumidControlledZoneNum).HumidifyingSched = cAlphaArgs(3); - HumidityControlZone(HumidControlledZoneNum).HumidifyingSchedIndex = GetScheduleIndex(state, cAlphaArgs(3)); - if (HumidityControlZone(HumidControlledZoneNum).HumidifyingSchedIndex == 0) { - ShowSevereError(state, - format("{}=\"{} invalid {}=\"{}\" not found.", cCurrentModuleObject, cAlphaArgs(1), cAlphaFieldNames(3), cAlphaArgs(3))); + + if (s_ipsc->lAlphaFieldBlanks(3)) { + ShowSevereEmptyField(state, eoh, s_ipsc->cAlphaFieldNames(3)); + ErrorsFound = true; + } else if ((humidControlledZone.humidifyingSched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(3))) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(3), s_ipsc->cAlphaArgs(3)); ErrorsFound = true; } - if (NumAlphas == 4) { - HumidityControlZone(HumidControlledZoneNum).DehumidifyingSched = cAlphaArgs(4); - HumidityControlZone(HumidControlledZoneNum).DehumidifyingSchedIndex = GetScheduleIndex(state, cAlphaArgs(4)); - if (HumidityControlZone(HumidControlledZoneNum).DehumidifyingSchedIndex == 0) { - ShowSevereError( - state, format("{}=\"{} invalid {}=\"{}\" not found.", cCurrentModuleObject, cAlphaArgs(1), cAlphaFieldNames(4), cAlphaArgs(4))); - ErrorsFound = true; - } - } else { - HumidityControlZone(HumidControlledZoneNum).DehumidifyingSched = cAlphaArgs(3); - HumidityControlZone(HumidControlledZoneNum).DehumidifyingSchedIndex = GetScheduleIndex(state, cAlphaArgs(3)); + + if (NumAlphas < 4 || s_ipsc->lAlphaFieldBlanks(4)) { + humidControlledZone.dehumidifyingSched = humidControlledZone.humidifyingSched; + } else if ((humidControlledZone.dehumidifyingSched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(4))) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(4), s_ipsc->cAlphaArgs(4)); + ErrorsFound = true; } } // HumidControlledZoneNum // Start to read Thermal comfort control objects - cCurrentModuleObject = cZControlTypes(static_cast(ZoneControlTypes::TCTStat)); - state.dataZoneCtrls->NumComfortTStatStatements = inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); + s_ipsc->cCurrentModuleObject = cZControlTypes(static_cast(ZoneControlTypes::TCTStat)); + state.dataZoneCtrls->NumComfortTStatStatements = s_ip->getNumObjectsFound(state, s_ipsc->cCurrentModuleObject); ComfortTStatObjects.allocate(state.dataZoneCtrls->NumComfortTStatStatements); // Pre-scan for use of Zone lists in TStat statements (i.e. Global application of TStat) state.dataZoneCtrls->NumComfortControlledZones = 0; errFlag = false; for (Item = 1; Item <= state.dataZoneCtrls->NumComfortTStatStatements; ++Item) { - inputProcessor->getObjectItem(state, - cCurrentModuleObject, + s_ip->getObjectItem(state, + s_ipsc->cCurrentModuleObject, Item, - cAlphaArgs, + s_ipsc->cAlphaArgs, NumAlphas, - rNumericArgs, + s_ipsc->rNumericArgs, NumNums, IOStat, - lNumericFieldBlanks, - lAlphaFieldBlanks, - cAlphaFieldNames, - cNumericFieldNames); - Util::IsNameEmpty(state, cAlphaArgs(1), cCurrentModuleObject, ErrorsFound); + s_ipsc->lNumericFieldBlanks, + s_ipsc->lAlphaFieldBlanks, + s_ipsc->cAlphaFieldNames, + s_ipsc->cNumericFieldNames); + Util::IsNameEmpty(state, s_ipsc->cAlphaArgs(1), s_ipsc->cCurrentModuleObject, ErrorsFound); - Item1 = Util::FindItemInList(cAlphaArgs(2), Zone); + Item1 = Util::FindItemInList(s_ipsc->cAlphaArgs(2), Zone); ZLItem = 0; - if (Item1 == 0 && state.dataHeatBal->NumOfZoneLists > 0) ZLItem = Util::FindItemInList(cAlphaArgs(2), ZoneList); - ComfortTStatObjects(Item).Name = cAlphaArgs(1); + if (Item1 == 0 && state.dataHeatBal->NumOfZoneLists > 0) ZLItem = Util::FindItemInList(s_ipsc->cAlphaArgs(2), ZoneList); + ComfortTStatObjects(Item).Name = s_ipsc->cAlphaArgs(1); if (Item1 > 0) { ComfortTStatObjects(Item).ComfortControlledZoneStartPtr = state.dataZoneCtrls->NumComfortControlledZones + 1; ++state.dataZoneCtrls->NumComfortControlledZones; @@ -1003,72 +844,69 @@ void GetZoneAirSetPoints(EnergyPlusData &state) ComfortTStatObjects(Item).ZoneOrZoneListPtr = ZLItem; } else { ShowSevereError( - state, format("{}=\"{}\" invalid {}=\"{}\" not found.", cCurrentModuleObject, cAlphaArgs(1), cAlphaFieldNames(2), cAlphaArgs(2))); + state, format("{}=\"{}\" invalid {}=\"{}\" not found.", s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1), s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2))); errFlag = true; ErrorsFound = true; } } if (errFlag) { - ShowSevereError(state, format("GetZoneAirSetpoints: Errors with invalid names in {} objects.", cCurrentModuleObject)); + ShowSevereError(state, format("GetZoneAirSetpoints: Errors with invalid names in {} objects.", s_ipsc->cCurrentModuleObject)); ShowContinueError(state, "...These will not be read in. Other errors may occur."); state.dataZoneCtrls->NumComfortControlledZones = 0; } if (state.dataZoneCtrls->NumComfortControlledZones > 0) { - ComfortControlledZone.allocate(state.dataZoneCtrls->NumComfortControlledZones); + state.dataZoneCtrls->ComfortControlledZone.allocate(state.dataZoneCtrls->NumComfortControlledZones); TComfortControlTypes.allocate(state.dataZoneCtrls->NumComfortControlledZones); // Number of set point types CCmSchedMapToControlledZone.dimension(state.dataZoneCtrls->NumComfortControlledZones, 0); ComfortControlledZoneNum = 0; for (Item = 1; Item <= state.dataZoneCtrls->NumComfortTStatStatements; ++Item) { - inputProcessor->getObjectItem(state, - cCurrentModuleObject, - Item, - cAlphaArgs, - NumAlphas, - rNumericArgs, - NumNums, - IOStat, - lNumericFieldBlanks, - lAlphaFieldBlanks, - cAlphaFieldNames, - cNumericFieldNames); + s_ip->getObjectItem(state, + s_ipsc->cCurrentModuleObject, + Item, + s_ipsc->cAlphaArgs, + NumAlphas, + s_ipsc->rNumericArgs, + NumNums, + IOStat, + s_ipsc->lNumericFieldBlanks, + s_ipsc->lAlphaFieldBlanks, + s_ipsc->cAlphaFieldNames, + s_ipsc->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)}; + for (Item1 = 1; Item1 <= ComfortTStatObjects(Item).NumOfZones; ++Item1) { ++ComfortControlledZoneNum; + + auto &comfortZone = state.dataZoneCtrls->ComfortControlledZone(ComfortControlledZoneNum); + if (ComfortTStatObjects(Item).ZoneListActive) { - cAlphaArgs(2) = state.dataHeatBal->Zone(ZoneList(ComfortTStatObjects(Item).ZoneOrZoneListPtr).Zone(Item1)).Name; + s_ipsc->cAlphaArgs(2) = state.dataHeatBal->Zone(ZoneList(ComfortTStatObjects(Item).ZoneOrZoneListPtr).Zone(Item1)).Name; } int ZoneAssigned = Util::FindItemInList( - cAlphaArgs(2), ComfortControlledZone, &DataZoneControls::ZoneComfortControls::ZoneName, ComfortControlledZoneNum - 1); + s_ipsc->cAlphaArgs(2), state.dataZoneCtrls->ComfortControlledZone, &DataZoneControls::ZoneComfortControls::ZoneName, ComfortControlledZoneNum - 1); if (ZoneAssigned == 0) { - ComfortControlledZone(ComfortControlledZoneNum).ZoneName = cAlphaArgs(2); - ComfortControlledZone(ComfortControlledZoneNum).ActualZoneNum = Util::FindItemInList(cAlphaArgs(2), Zone); - if (ComfortControlledZone(ComfortControlledZoneNum).ActualZoneNum == 0) { - ShowSevereError( - state, - format( - "{}=\"{}\" invalid {}=\"{}\" not found.", cCurrentModuleObject, cAlphaArgs(1), cAlphaFieldNames(2), cAlphaArgs(2))); + comfortZone.ZoneName = s_ipsc->cAlphaArgs(2); + comfortZone.ActualZoneNum = Util::FindItemInList(s_ipsc->cAlphaArgs(2), Zone); + if (comfortZone.ActualZoneNum == 0) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2)); ErrorsFound = true; } } else { - ComfortControlledZone(ComfortControlledZoneNum).ZoneName = cAlphaArgs(2); // for continuity - ShowSevereError(state, - format("{}=\"{}\" invalid {}=\"{}\" zone previously assigned.", - cCurrentModuleObject, - cAlphaArgs(1), - cAlphaFieldNames(2), - cAlphaArgs(2))); - ShowContinueError(state, - format("...Zone was previously assigned to Thermostat=\"{}\".", ComfortControlledZone(ZoneAssigned).Name)); + comfortZone.ZoneName = s_ipsc->cAlphaArgs(2); // for continuity + ShowSevereDuplicateAssignment(state, eoh, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2), + state.dataZoneCtrls->ComfortControlledZone(ZoneAssigned).Name); ErrorsFound = true; continue; } if (!ComfortTStatObjects(Item).ZoneListActive) { - ComfortControlledZone(ComfortControlledZoneNum).Name = cAlphaArgs(1); + comfortZone.Name = s_ipsc->cAlphaArgs(1); } else { - ComfortControlledZone(ComfortControlledZoneNum).Name = + comfortZone.Name = state.dataHeatBal->Zone(ZoneList(ComfortTStatObjects(Item).ZoneOrZoneListPtr).Zone(Item1)).Name + ' ' + ComfortTStatObjects(Item).Name; } @@ -1076,670 +914,425 @@ void GetZoneAirSetPoints(EnergyPlusData &state) // Read Fields A3 and A4 for averaging method IZoneCount = 0; for (i = 1; i <= state.dataHeatBal->TotPeople; ++i) { - if (ComfortControlledZone(ComfortControlledZoneNum).ActualZoneNum == state.dataHeatBal->People(i).ZonePtr) { + if (comfortZone.ActualZoneNum == state.dataHeatBal->People(i).ZonePtr) { ++IZoneCount; } } // Could not find a people object for this particular zone - if (IZoneCount == 0 && ComfortControlledZone(ComfortControlledZoneNum).ActualZoneNum > 0) { + if (IZoneCount == 0 && comfortZone.ActualZoneNum > 0) { ShowSevereError(state, format("{}=\"{} no PEOPLE in {}=\"{}\" - cannot use Comfort Control.", - cCurrentModuleObject, - cAlphaArgs(1), - cAlphaFieldNames(2), - cAlphaArgs(2))); + s_ipsc->cCurrentModuleObject, + s_ipsc->cAlphaArgs(1), + s_ipsc->cAlphaFieldNames(2), + s_ipsc->cAlphaArgs(2))); ErrorsFound = true; } - ComfortControlledZone(ComfortControlledZoneNum).AverageMethod = DataZoneControls::AverageMethod::NO; + comfortZone.AverageMethod = DataZoneControls::AverageMethod::NO; if (IZoneCount > 1) { - ComfortControlledZone(ComfortControlledZoneNum).AverageMethodName = cAlphaArgs(3); - if (Util::SameString(cAlphaArgs(3), "SpecificObject")) { - ComfortControlledZone(ComfortControlledZoneNum).AverageMethod = DataZoneControls::AverageMethod::SPE; + comfortZone.AverageMethodName = s_ipsc->cAlphaArgs(3); + if (Util::SameString(s_ipsc->cAlphaArgs(3), "SpecificObject")) { + comfortZone.AverageMethod = DataZoneControls::AverageMethod::SPE; } - if (Util::SameString(cAlphaArgs(3), "ObjectAverage")) { - ComfortControlledZone(ComfortControlledZoneNum).AverageMethod = DataZoneControls::AverageMethod::OBJ; + if (Util::SameString(s_ipsc->cAlphaArgs(3), "ObjectAverage")) { + comfortZone.AverageMethod = DataZoneControls::AverageMethod::OBJ; } - if (Util::SameString(cAlphaArgs(3), "PeopleAverage")) { - ComfortControlledZone(ComfortControlledZoneNum).AverageMethod = DataZoneControls::AverageMethod::PEO; + if (Util::SameString(s_ipsc->cAlphaArgs(3), "PeopleAverage")) { + comfortZone.AverageMethod = DataZoneControls::AverageMethod::PEO; } - if (ComfortControlledZone(ComfortControlledZoneNum).AverageMethod == DataZoneControls::AverageMethod::NO) { - ShowSevereError( - state, format("{}=\"{} invalid {}=\"{}\".", cCurrentModuleObject, cAlphaArgs(1), cAlphaFieldNames(3), cAlphaArgs(3))); - ShowContinueError(state, "Allowed keys are SpecificObject, ObjectAverage, or PeopleAverage"); + if (comfortZone.AverageMethod == DataZoneControls::AverageMethod::NO) { + ShowSevereInvalidKey(state, eoh, s_ipsc->cAlphaFieldNames(3), s_ipsc->cAlphaArgs(3)); ErrorsFound = true; } - if (ComfortControlledZone(ComfortControlledZoneNum).AverageMethod == DataZoneControls::AverageMethod::SPE) { - ComfortControlledZone(ComfortControlledZoneNum).AverageObjectName = cAlphaArgs(4); - if (Util::FindItem(cAlphaArgs(4), state.dataHeatBal->People) == 0) { - ShowSevereError( - state, format("{}=\"{} invalid {}=\"{}\".", cCurrentModuleObject, cAlphaArgs(1), cAlphaFieldNames(4), cAlphaArgs(4))); + if (comfortZone.AverageMethod == DataZoneControls::AverageMethod::SPE) { + comfortZone.AverageObjectName = s_ipsc->cAlphaArgs(4); + if (Util::FindItem(s_ipsc->cAlphaArgs(4), state.dataHeatBal->People) == 0) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(4), s_ipsc->cAlphaArgs(4)); ErrorsFound = true; } else { - ComfortControlledZone(ComfortControlledZoneNum).SpecificObjectNum = - Util::FindItem(cAlphaArgs(4), state.dataHeatBal->People); + comfortZone.SpecificObjectNum = Util::FindItem(s_ipsc->cAlphaArgs(4), state.dataHeatBal->People); } } } else { for (i = 1; i <= state.dataHeatBal->TotPeople; ++i) { - if (ComfortControlledZone(ComfortControlledZoneNum).ActualZoneNum == state.dataHeatBal->People(i).ZonePtr) break; + if (comfortZone.ActualZoneNum == state.dataHeatBal->People(i).ZonePtr) break; } - ComfortControlledZone(ComfortControlledZoneNum).SpecificObjectNum = i; + comfortZone.SpecificObjectNum = i; } // Check values used for thermal comfort calculation for (i = 1; i <= state.dataHeatBal->TotPeople; ++i) { - if (ComfortControlledZone(ComfortControlledZoneNum).ActualZoneNum == state.dataHeatBal->People(i).ZonePtr) { - // Check activity level - if (state.dataHeatBal->People(i).ActivityLevelPtr > 0) { - ValidScheduleControlType = - CheckScheduleValueMinMax(state, state.dataHeatBal->People(i).ActivityLevelPtr, ">=", 72.0, "<=", 909.0); - if (!ValidScheduleControlType) { - ShowSevereError(state, - "GetPeople Activity Level: Invalid activity level values entered for thermal comfort calculation"); - ShowContinueError(state, - format("Outside of range values [72,909], Reference object={}", state.dataHeatBal->People(i).Name)); - ErrorsFound = true; - } - } else { - ShowSevereError( - state, - format("GetPeople Activity Level: Activity level schedule is not found={}", state.dataHeatBal->People(i).Name)); - ShowContinueError(state, "Required when the zone has Thermal Comfort Controls."); - ErrorsFound = true; - } - // Check Work Efficiency - if (state.dataHeatBal->People(i).WorkEffPtr > 0) { - ValidScheduleControlType = CheckScheduleValueMinMax(state, state.dataHeatBal->People(i).WorkEffPtr, ">=", 0.0, "<=", 1.0); - if (!ValidScheduleControlType) { - ShowSevereError(state, - "GetPeople work efficiency: Invalid work efficiency values entered for thermal comfort calculation"); - ShowContinueError(state, - format("Outside of range values [0,1], Reference object={}", state.dataHeatBal->People(i).Name)); - ErrorsFound = true; - } - } else { - ShowSevereError( - state, - format("GetPeople work efficiency: Work efficiency schedule is not found={}", state.dataHeatBal->People(i).Name)); - ShowContinueError(state, "Required when the zone has Thermal Comfort Controls."); - ErrorsFound = true; - } - // Check Clothing Insulation - if (state.dataHeatBal->People(i).ClothingPtr > 0) { - ValidScheduleControlType = CheckScheduleValueMinMax(state, state.dataHeatBal->People(i).ClothingPtr, ">", 0.0, "<=", 2.0); - if (!ValidScheduleControlType) { - ShowSevereError( - state, - "GetPeople Clothing Insulation: Invalid Clothing Insulation values entered for thermal comfort calculation"); - ShowContinueError( - state, format("Outside of range values [0.0,2.0], Reference object={}", state.dataHeatBal->People(i).Name)); - ErrorsFound = true; - } - } else { - ShowSevereError(state, - format("GetPeople Clothing Insulation: Clothing Insulation schedule is not found={}", - state.dataHeatBal->People(i).Name)); - ShowContinueError(state, "Required when the zone has Thermal Comfort Controls."); - ErrorsFound = true; - } - // Check Air velocity - if (state.dataHeatBal->People(i).AirVelocityPtr <= 0) { - ShowSevereError( - state, format("GetPeople Air Velocity: Air velocity schedule is not found={}", state.dataHeatBal->People(i).Name)); - ShowContinueError(state, "Required when the zone has Thermal Comfort Controls."); - ErrorsFound = true; - } + auto &people = state.dataHeatBal->People(i); + + if (comfortZone.ActualZoneNum != people.ZonePtr) + continue; + + // Check activity level + if (people.activityLevelSched == nullptr) { + ShowSevereError(state, format("GetPeople Activity Level: Activity level schedule is not found={}", people.Name)); + ShowContinueError(state, "Required when the zone has Thermal Comfort Controls."); + ErrorsFound = true; + } else if (!people.activityLevelSched->checkMinMaxVals(state, Clusive::In, 72.0, Clusive::In, 909.0)) { + ShowSevereError(state, "GetPeople Activity Level: Invalid activity level values entered for thermal comfort calculation"); + ShowContinueError(state, format("Outside of range values [72,909], Reference object={}", people.Name)); + } + + // Check Work Efficiency + if (people.workEffSched == nullptr) { + ShowSevereError(state, format("GetPeople work efficiency: Work efficiency schedule is not found={}", people.Name)); + ShowContinueError(state, "Required when the zone has Thermal Comfort Controls."); + ErrorsFound = true; + } else if (!people.workEffSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) { + ShowSevereError(state, "GetPeople work efficiency: Invalid work efficiency values entered for thermal comfort calculation"); + ShowContinueError(state, format("Outside of range values [0,1], Reference object={}", people.Name)); + ErrorsFound = true; + } + + // Check Clothing Insulation + if (people.clothingSched == nullptr) { + ShowSevereError(state, format("GetPeople Clothing Insulation: Clothing Insulation schedule is not found={}", people.Name)); + ShowContinueError(state, "Required when the zone has Thermal Comfort Controls."); + ErrorsFound = true; + } else if (!people.clothingSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 2.0)) { + ShowSevereError(state, "GetPeople Clothing Insulation: Invalid Clothing Insulation values entered for thermal comfort calculation"); + ShowContinueError(state, format("Outside of range values [0.0,2.0], Reference object={}", people.Name)); + ErrorsFound = true; + } + + // Check Air velocity + if (people.airVelocitySched == nullptr) { + ShowSevereError(state, format("GetPeople Air Velocity: Air velocity schedule is not found={}", people.Name)); + ShowContinueError(state, "Required when the zone has Thermal Comfort Controls."); + ErrorsFound = true; } } // Read Max and Min temperature setpoint if (NumNums > 0) { - ComfortControlledZone(ComfortControlledZoneNum).TdbMinSetPoint = rNumericArgs(1); - if (rNumericArgs(1) > 50 || rNumericArgs(1) < 0) { + comfortZone.TdbMinSetPoint = s_ipsc->rNumericArgs(1); + if (s_ipsc->rNumericArgs(1) > 50 || s_ipsc->rNumericArgs(1) < 0) { ShowSevereError( state, - format("{}=\"{} invalid {}=[{:.0T}].", cCurrentModuleObject, cAlphaArgs(1), cNumericFieldNames(1), rNumericArgs(1))); + format("{}=\"{} invalid {}=[{:.0T}].", s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1), s_ipsc->cNumericFieldNames(1), s_ipsc->rNumericArgs(1))); ShowContinueError(state, "..Allowable values must be between 0 C and 50 C"); ErrorsFound = true; } } if (NumNums > 1) { - ComfortControlledZone(ComfortControlledZoneNum).TdbMaxSetPoint = rNumericArgs(2); - if (rNumericArgs(2) > 50 || rNumericArgs(2) < 0) { + comfortZone.TdbMaxSetPoint = s_ipsc->rNumericArgs(2); + if (s_ipsc->rNumericArgs(2) > 50 || s_ipsc->rNumericArgs(2) < 0) { ShowSevereError( state, - format("{}=\"{} invalid {}=[{:.0T}].", cCurrentModuleObject, cAlphaArgs(1), cNumericFieldNames(2), rNumericArgs(2))); + format("{}=\"{} invalid {}=[{:.0T}].", s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1), s_ipsc->cNumericFieldNames(2), s_ipsc->rNumericArgs(2))); ShowContinueError(state, "..Allowable values must be between 0 C and 50 C"); ErrorsFound = true; } } // Ensure MaxTemp >= MinTemp - if (ComfortControlledZone(ComfortControlledZoneNum).TdbMinSetPoint > ComfortControlledZone(ComfortControlledZoneNum).TdbMaxSetPoint) { - ShowSevereError(state, format("{}=\"{}", cCurrentModuleObject, cAlphaArgs(1))); - ShowContinueError(state, format("..{} > {}", cNumericFieldNames(1), cNumericFieldNames(2))); - ShowContinueError(state, format("..[{:.0T}] > [{:.0T}].", rNumericArgs(1), rNumericArgs(2))); + if (comfortZone.TdbMinSetPoint > comfortZone.TdbMaxSetPoint) { + ShowSevereError(state, format("{}=\"{}", s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); + ShowContinueError(state, format("..{} > {}", s_ipsc->cNumericFieldNames(1), s_ipsc->cNumericFieldNames(2))); + ShowContinueError(state, format("..[{:.0T}] > [{:.0T}].", s_ipsc->rNumericArgs(1), s_ipsc->rNumericArgs(2))); ErrorsFound = true; } // If MaxTemp = MinTemp, no thermal comfort control - if (ComfortControlledZone(ComfortControlledZoneNum).TdbMinSetPoint == - ComfortControlledZone(ComfortControlledZoneNum).TdbMaxSetPoint) { - ShowSevereError(state, format("{}=\"{}", cCurrentModuleObject, cAlphaArgs(1))); - ShowContinueError(state, format("..{} = {}", cNumericFieldNames(1), cNumericFieldNames(2))); + if (comfortZone.TdbMinSetPoint == comfortZone.TdbMaxSetPoint) { + ShowSevereError(state, format("{}=\"{}", s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); + ShowContinueError(state, format("..{} = {}", s_ipsc->cNumericFieldNames(1), s_ipsc->cNumericFieldNames(2))); ShowContinueError(state, "The zone will be controlled using this dry-bulb temperature setpoint."); } + // read Thermal comfort type schedule name - ComfortControlledZone(ComfortControlledZoneNum).ControlTypeSchedName = cAlphaArgs(5); - ComfortControlledZone(ComfortControlledZoneNum).ComfortSchedIndex = GetScheduleIndex(state, cAlphaArgs(5)); - if (ComfortControlledZone(ComfortControlledZoneNum).ComfortSchedIndex == 0) { - ShowSevereError( - state, - format("{}=\"{} invalid {}=\"{}\" not found.", cCurrentModuleObject, cAlphaArgs(1), cAlphaFieldNames(5), cAlphaArgs(5))); + if (s_ipsc->lAlphaFieldBlanks(5)) { + ShowSevereEmptyField(state, eoh, s_ipsc->cAlphaFieldNames(5)); + ErrorsFound = true; + } else if ((comfortZone.setptTypeSched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(5))) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(5), s_ipsc->cAlphaArgs(5)); + ErrorsFound = true; + } else if (!comfortZone.setptTypeSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 4.0)) { + Sched::ShowSevereBadMinMax(state, eoh, s_ipsc->cAlphaFieldNames(5), s_ipsc->cAlphaArgs(5), Clusive::In, 0.0, Clusive::In, 4.0); ErrorsFound = true; - } else { - // Check validity of control types. - ValidScheduleControlType = - CheckScheduleValueMinMax(state, ComfortControlledZone(ComfortControlledZoneNum).ComfortSchedIndex, ">=", 0.0, "<=", 4.0); - if (!ValidScheduleControlType) { - ShowSevereError( - state, - format("{}=\"{}\" invalid range {}=\"{}\"", cCurrentModuleObject, cAlphaArgs(1), cAlphaFieldNames(5), cAlphaArgs(5))); - ShowContinueError(state, "..contains values outside of range [0,4]."); - ErrorsFound = true; - } } - ComfortControlledZone(ComfortControlledZoneNum).NumControlTypes = nint((NumAlphas - 5.0) / 2.0); - ComfortControlledZone(ComfortControlledZoneNum).ControlType.allocate(ComfortControlledZone(ComfortControlledZoneNum).NumControlTypes); - ComfortControlledZone(ComfortControlledZoneNum) - .ControlTypeName.allocate(ComfortControlledZone(ComfortControlledZoneNum).NumControlTypes); - ComfortControlledZone(ComfortControlledZoneNum) - .ControlTypeSchIndx.allocate(ComfortControlledZone(ComfortControlledZoneNum).NumControlTypes); - - for (ControlTypeNum = 1; ControlTypeNum <= ComfortControlledZone(ComfortControlledZoneNum).NumControlTypes; ++ControlTypeNum) { - ComfortControlledZone(ComfortControlledZoneNum).ControlType(ControlTypeNum) = cAlphaArgs(nint(2.0 * ControlTypeNum - 1 + 5)); - ComfortControlledZone(ComfortControlledZoneNum).ControlTypeName(ControlTypeNum) = cAlphaArgs(nint(2.0 * ControlTypeNum + 5)); - if (ComfortControlledZone(ComfortControlledZoneNum).ControlType(ControlTypeNum) != "") { - CTIndex = getEnumValue(ValidComfortControlTypesUC, - Util::makeUPPER(ComfortControlledZone(ComfortControlledZoneNum).ControlType(ControlTypeNum))); - if (CTIndex == 0) { - ShowSevereError(state, - format("{}=\"{}\" invalid {}=\"{}\"", - cCurrentModuleObject, - cAlphaArgs(1), - cAlphaFieldNames(nint(2.0 * ControlTypeNum - 1 + 5)), - cAlphaArgs(nint(2.0 * ControlTypeNum - 1 + 5)))); - ErrorsFound = true; - } - if (CTIndex > 4) { // For Fanger control only for the time being - ShowSevereError(state, - format("{}=\"{}\" invalid {}=\"{}\"", - cCurrentModuleObject, - cAlphaArgs(1), - cAlphaFieldNames(nint(2.0 * ControlTypeNum - 1 + 5)), - cAlphaArgs(nint(2.0 * ControlTypeNum - 1 + 5)))); - ShowContinueError(state, "..Fanger is the only valid model."); - ErrorsFound = true; - } - } else { - ShowSevereError(state, - format("{}=\"{}\" invalid {}=\"\"", - cCurrentModuleObject, - cAlphaArgs(1), - cAlphaFieldNames(nint(2.0 * ControlTypeNum - 1 + 5)))); + + int NumSetptTypes = nint((NumAlphas - 5.0) / 2.0); + + for (int iSetptType = 1; iSetptType <= NumSetptTypes; ++iSetptType) { + + int ctIdx = 2 * iSetptType - 1 + 5; + + HVAC::SetptType setptType = HVAC::SetptType::Invalid; + if (s_ipsc->lAlphaFieldBlanks(ctIdx)) { + ShowSevereEmptyField(state, eoh, s_ipsc->cAlphaFieldNames(ctIdx)); + ErrorsFound = true; + continue; + } else if ((setptType = static_cast(getEnumValue(setptTypeNamesUC, s_ipsc->cAlphaArgs(ctIdx)))) + == HVAC::SetptType::Invalid) { + ShowSevereInvalidKey(state, eoh, s_ipsc->cAlphaFieldNames(ctIdx), s_ipsc->cAlphaFieldNames(ctIdx)); ErrorsFound = true; + continue; } - ComfortControlledZone(ComfortControlledZoneNum).ControlTypeSchIndx(ControlTypeNum) = 0; + + auto &setpt = comfortZone.setpts[(int)setptType]; + setpt.Name = s_ipsc->cAlphaArgs(nint(2.0 * iSetptType + 5)); + setpt.isUsed = true; } } } // NumComfortTStatStatements } // End of Thermal comfort control reading and checking - cCurrentModuleObject = ValidComfortControlTypes[static_cast(HVAC::ThermostatType::SingleHeating)]; - state.dataZoneTempPredictorCorrector->NumSingleFangerHeatingControls = inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); - - if (state.dataZoneTempPredictorCorrector->NumSingleFangerHeatingControls > 0) - state.dataZoneTempPredictorCorrector->SetPointSingleHeatingFanger.allocate( - state.dataZoneTempPredictorCorrector->NumSingleFangerHeatingControls); - - for (int idx = 1; idx <= state.dataZoneTempPredictorCorrector->NumSingleFangerHeatingControls; ++idx) { - inputProcessor->getObjectItem(state, - cCurrentModuleObject, - idx, - cAlphaArgs, - NumAlphas, - rNumericArgs, - NumNums, - IOStat, - lNumericFieldBlanks, - lAlphaFieldBlanks, - cAlphaFieldNames, - cNumericFieldNames); - Util::IsNameEmpty(state, cAlphaArgs(1), cCurrentModuleObject, ErrorsFound); - auto &singleSetpointHtgFanger = state.dataZoneTempPredictorCorrector->SetPointSingleHeatingFanger(idx); - singleSetpointHtgFanger.Name = cAlphaArgs(1); - singleSetpointHtgFanger.PMVSchedName = cAlphaArgs(2); - singleSetpointHtgFanger.PMVSchedIndex = GetScheduleIndex(state, cAlphaArgs(2)); - if (singleSetpointHtgFanger.PMVSchedIndex == 0) { - ShowSevereError( - state, format("{}=\"{}\" invalid {}=\"{}\" not found.", cCurrentModuleObject, cAlphaArgs(1), cAlphaFieldNames(2), cAlphaArgs(2))); + s_ipsc->cCurrentModuleObject = comfortSetptTypeNames[(int)HVAC::SetptType::SingleHeat]; + s_ztpc->NumComfortControls[(int)HVAC::SetptType::SingleHeat] = s_ip->getNumObjectsFound(state, s_ipsc->cCurrentModuleObject); + + if (s_ztpc->NumComfortControls[(int)HVAC::SetptType::SingleHeat] > 0) + s_ztpc->comfortSetptScheds[(int)HVAC::SetptType::SingleHeat].allocate(s_ztpc->NumComfortControls[(int)HVAC::SetptType::SingleHeat]); + + for (int idx = 1; idx <= s_ztpc->NumComfortControls[(int)HVAC::SetptType::SingleHeat]; ++idx) { + s_ip->getObjectItem(state, + s_ipsc->cCurrentModuleObject, + idx, + s_ipsc->cAlphaArgs, + NumAlphas, + s_ipsc->rNumericArgs, + NumNums, + IOStat, + s_ipsc->lNumericFieldBlanks, + s_ipsc->lAlphaFieldBlanks, + s_ipsc->cAlphaFieldNames, + s_ipsc->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)}; + + Util::IsNameEmpty(state, s_ipsc->cAlphaArgs(1), s_ipsc->cCurrentModuleObject, ErrorsFound); + auto &setpt = s_ztpc->comfortSetptScheds[(int)HVAC::SetptType::SingleHeat](idx); + setpt.Name = s_ipsc->cAlphaArgs(1); + + if (s_ipsc->lAlphaFieldBlanks(2)) { + ShowSevereEmptyField(state, eoh, s_ipsc->cAlphaFieldNames(2)); + ErrorsFound = true; + } else if ((setpt.heatSched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2)); + ErrorsFound = true; + } else if (!setpt.heatSched->checkMinMaxVals(state, Clusive::In, -3.0, Clusive::In, 3.0)) { + Sched::ShowSevereBadMinMax(state, eoh, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2), Clusive::In, -3.0, Clusive::In, 3.0); ErrorsFound = true; - } else { - ValidScheduleControlType = CheckScheduleValueMinMax(state, singleSetpointHtgFanger.PMVSchedIndex, ">=", -3.0, "<=", 3.0); - if (!ValidScheduleControlType) { - ShowSevereError( - state, - format( - "{}=\"{}\" invalid PMV values {}=\"{}\" entered.", cCurrentModuleObject, cAlphaArgs(1), cAlphaFieldNames(2), cAlphaArgs(2))); - ShowContinueError(state, "..Values outside of range [-3,+3]."); - ErrorsFound = true; - } } } // SingleFangerHeatingControlNum - cCurrentModuleObject = ValidComfortControlTypes[static_cast(HVAC::ThermostatType::SingleCooling)]; - state.dataZoneTempPredictorCorrector->NumSingleFangerCoolingControls = inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); + s_ipsc->cCurrentModuleObject = comfortSetptTypeNames[(int)HVAC::SetptType::SingleCool]; + s_ztpc->NumComfortControls[(int)HVAC::SetptType::SingleCool] = s_ip->getNumObjectsFound(state, s_ipsc->cCurrentModuleObject); - if (state.dataZoneTempPredictorCorrector->NumSingleFangerCoolingControls > 0) { - state.dataZoneTempPredictorCorrector->SetPointSingleCoolingFanger.allocate( - state.dataZoneTempPredictorCorrector->NumSingleFangerCoolingControls); + if (s_ztpc->NumComfortControls[(int)HVAC::SetptType::SingleCool] > 0) { + s_ztpc->comfortSetptScheds[(int)HVAC::SetptType::SingleCool].allocate(s_ztpc->NumComfortControls[(int)HVAC::SetptType::SingleCool]); } - for (int idx = 1; idx <= state.dataZoneTempPredictorCorrector->NumSingleFangerCoolingControls; ++idx) { - inputProcessor->getObjectItem(state, - cCurrentModuleObject, - idx, - cAlphaArgs, - NumAlphas, - rNumericArgs, - NumNums, - IOStat, - lNumericFieldBlanks, - lAlphaFieldBlanks, - cAlphaFieldNames, - cNumericFieldNames); - Util::IsNameEmpty(state, cAlphaArgs(1), cCurrentModuleObject, ErrorsFound); - auto &singleSetpointClgFanger = state.dataZoneTempPredictorCorrector->SetPointSingleCoolingFanger(idx); - singleSetpointClgFanger.Name = cAlphaArgs(1); - singleSetpointClgFanger.PMVSchedName = cAlphaArgs(2); - singleSetpointClgFanger.PMVSchedIndex = GetScheduleIndex(state, cAlphaArgs(2)); - if (singleSetpointClgFanger.PMVSchedIndex == 0) { - ShowSevereError( - state, format("{}=\"{}\" invalid {}=\"{}\" not found.", cCurrentModuleObject, cAlphaArgs(1), cAlphaFieldNames(2), cAlphaArgs(2))); + for (int idx = 1; idx <= s_ztpc->NumComfortControls[(int)HVAC::SetptType::SingleCool]; ++idx) { + s_ip->getObjectItem(state, + s_ipsc->cCurrentModuleObject, + idx, + s_ipsc->cAlphaArgs, + NumAlphas, + s_ipsc->rNumericArgs, + NumNums, + IOStat, + s_ipsc->lNumericFieldBlanks, + s_ipsc->lAlphaFieldBlanks, + s_ipsc->cAlphaFieldNames, + s_ipsc->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)}; + + Util::IsNameEmpty(state, s_ipsc->cAlphaArgs(1), s_ipsc->cCurrentModuleObject, ErrorsFound); + auto &setpt = s_ztpc->comfortSetptScheds[(int)HVAC::SetptType::SingleCool](idx); + setpt.Name = s_ipsc->cAlphaArgs(1); + + if (s_ipsc->lAlphaFieldBlanks(2)) { + ShowSevereEmptyField(state, eoh, s_ipsc->cAlphaFieldNames(2)); + ErrorsFound = true; + } else if ((setpt.coolSched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2)); + ErrorsFound = true; + } else if (!setpt.coolSched->checkMinMaxVals(state, Clusive::In, -3.0, Clusive::In, 3.0)) { + Sched::ShowSevereBadMinMax(state, eoh, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2), Clusive::In, -3.0, Clusive::In, 3.0); ErrorsFound = true; - } else { - ValidScheduleControlType = CheckScheduleValueMinMax(state, singleSetpointClgFanger.PMVSchedIndex, ">=", -3.0, "<=", 3.0); - if (!ValidScheduleControlType) { - ShowSevereError( - state, - format( - "{}=\"{}\" invalid PMV values {}=\"{}\" entered.", cCurrentModuleObject, cAlphaArgs(1), cAlphaFieldNames(2), cAlphaArgs(2))); - ShowContinueError(state, "..Values outside of range [-3,+3]."); - ErrorsFound = true; - } } } // SingleFangerCoolingControlNum - cCurrentModuleObject = ValidComfortControlTypes[static_cast(HVAC::ThermostatType::SingleHeatCool)]; - state.dataZoneTempPredictorCorrector->NumSingleFangerHeatCoolControls = inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); - - if (state.dataZoneTempPredictorCorrector->NumSingleFangerHeatCoolControls > 0) - state.dataZoneTempPredictorCorrector->SetPointSingleHeatCoolFanger.allocate( - state.dataZoneTempPredictorCorrector->NumSingleFangerHeatCoolControls); - - for (int idx = 1; idx <= state.dataZoneTempPredictorCorrector->NumSingleFangerHeatCoolControls; ++idx) { - inputProcessor->getObjectItem(state, - cCurrentModuleObject, - idx, - cAlphaArgs, - NumAlphas, - rNumericArgs, - NumNums, - IOStat, - lNumericFieldBlanks, - lAlphaFieldBlanks, - cAlphaFieldNames, - cNumericFieldNames); - Util::IsNameEmpty(state, cAlphaArgs(1), cCurrentModuleObject, ErrorsFound); - auto &singleSetpointHeatCoolFanger = state.dataZoneTempPredictorCorrector->SetPointSingleHeatCoolFanger(idx); - singleSetpointHeatCoolFanger.Name = cAlphaArgs(1); - singleSetpointHeatCoolFanger.PMVSchedName = cAlphaArgs(2); - singleSetpointHeatCoolFanger.PMVSchedIndex = GetScheduleIndex(state, cAlphaArgs(2)); - if (singleSetpointHeatCoolFanger.PMVSchedIndex == 0) { - ShowSevereError( - state, format("{}=\"{}\" invalid {}=\"{}\" not found.", cCurrentModuleObject, cAlphaArgs(1), cAlphaFieldNames(2), cAlphaArgs(2))); + s_ipsc->cCurrentModuleObject = comfortSetptTypeNames[(int)HVAC::SetptType::SingleHeatCool]; + s_ztpc->NumComfortControls[(int)HVAC::SetptType::SingleHeatCool] = s_ip->getNumObjectsFound(state, s_ipsc->cCurrentModuleObject); + + if (s_ztpc->NumComfortControls[(int)HVAC::SetptType::SingleHeatCool] > 0) + s_ztpc->comfortSetptScheds[(int)HVAC::SetptType::SingleHeatCool].allocate(s_ztpc->NumComfortControls[(int)HVAC::SetptType::SingleHeatCool]); + + for (int idx = 1; idx <= s_ztpc->NumComfortControls[(int)HVAC::SetptType::SingleHeatCool]; ++idx) { + s_ip->getObjectItem(state, + s_ipsc->cCurrentModuleObject, + idx, + s_ipsc->cAlphaArgs, + NumAlphas, + s_ipsc->rNumericArgs, + NumNums, + IOStat, + s_ipsc->lNumericFieldBlanks, + s_ipsc->lAlphaFieldBlanks, + s_ipsc->cAlphaFieldNames, + s_ipsc->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)}; + + Util::IsNameEmpty(state, s_ipsc->cAlphaArgs(1), s_ipsc->cCurrentModuleObject, ErrorsFound); + auto &setpt = s_ztpc->comfortSetptScheds[(int)HVAC::SetptType::SingleHeatCool](idx); + setpt.Name = s_ipsc->cAlphaArgs(1); + + if (s_ipsc->lAlphaFieldBlanks(2)) { + ShowSevereEmptyField(state, eoh, s_ipsc->cAlphaFieldNames(2)); + ErrorsFound = true; + } else if ((setpt.heatSched = setpt.coolSched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2)); + ErrorsFound = true; + } else if (!setpt.heatSched->checkMinMaxVals(state, Clusive::In, -3.0, Clusive::In, 3.0)) { + Sched::ShowSevereBadMinMax(state, eoh, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2), Clusive::In, -3.0, Clusive::In, 3.0); ErrorsFound = true; - } else { - ValidScheduleControlType = CheckScheduleValueMinMax(state, singleSetpointHeatCoolFanger.PMVSchedIndex, ">=", -3.0, "<=", 3.0); - if (!ValidScheduleControlType) { - ShowSevereError( - state, - format( - "{}=\"{}\" invalid PMV values {}=\"{}\" entered.", cCurrentModuleObject, cAlphaArgs(1), cAlphaFieldNames(2), cAlphaArgs(2))); - ShowContinueError(state, "..Values outside of range [-3,+3]."); - ErrorsFound = true; - } } } // SingleFangerHeatCoolControlNum - cCurrentModuleObject = ValidComfortControlTypes[static_cast(HVAC::ThermostatType::DualSetPointWithDeadBand)]; - state.dataZoneTempPredictorCorrector->NumDualFangerHeatCoolControls = inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); - - if (state.dataZoneTempPredictorCorrector->NumDualFangerHeatCoolControls > 0) - state.dataZoneTempPredictorCorrector->SetPointDualHeatCoolFanger.allocate( - state.dataZoneTempPredictorCorrector->NumDualFangerHeatCoolControls); - - for (int idx = 1; idx <= state.dataZoneTempPredictorCorrector->NumDualFangerHeatCoolControls; ++idx) { - inputProcessor->getObjectItem(state, - cCurrentModuleObject, - idx, - cAlphaArgs, - NumAlphas, - rNumericArgs, - NumNums, - IOStat, - lNumericFieldBlanks, - lAlphaFieldBlanks, - cAlphaFieldNames, - cNumericFieldNames); - Util::IsNameEmpty(state, cAlphaArgs(1), cCurrentModuleObject, ErrorsFound); - auto &dualSetpointHeatCoolFanger = state.dataZoneTempPredictorCorrector->SetPointDualHeatCoolFanger(idx); - dualSetpointHeatCoolFanger.Name = cAlphaArgs(1); - dualSetpointHeatCoolFanger.HeatPMVSetptSchedName = cAlphaArgs(2); - dualSetpointHeatCoolFanger.HeatPMVSchedIndex = GetScheduleIndex(state, cAlphaArgs(2)); - if (dualSetpointHeatCoolFanger.HeatPMVSchedIndex == 0) { - ShowSevereError( - state, format("{}=\"{}\" invalid {}=\"{}\" not found.", cCurrentModuleObject, cAlphaArgs(1), cAlphaFieldNames(2), cAlphaArgs(2))); + s_ipsc->cCurrentModuleObject = comfortSetptTypeNames[(int)HVAC::SetptType::DualHeatCool]; + s_ztpc->NumComfortControls[(int)HVAC::SetptType::DualHeatCool] = s_ip->getNumObjectsFound(state, s_ipsc->cCurrentModuleObject); + + if (s_ztpc->NumComfortControls[(int)HVAC::SetptType::DualHeatCool] > 0) + s_ztpc->comfortSetptScheds[(int)HVAC::SetptType::DualHeatCool].allocate(s_ztpc->NumComfortControls[(int)HVAC::SetptType::DualHeatCool]); + + for (int idx = 1; idx <= s_ztpc->NumComfortControls[(int)HVAC::SetptType::DualHeatCool]; ++idx) { + s_ip->getObjectItem(state, + s_ipsc->cCurrentModuleObject, + idx, + s_ipsc->cAlphaArgs, + NumAlphas, + s_ipsc->rNumericArgs, + NumNums, + IOStat, + s_ipsc->lNumericFieldBlanks, + s_ipsc->lAlphaFieldBlanks, + s_ipsc->cAlphaFieldNames, + s_ipsc->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)}; + + Util::IsNameEmpty(state, s_ipsc->cAlphaArgs(1), s_ipsc->cCurrentModuleObject, ErrorsFound); + auto &setpt = s_ztpc->comfortSetptScheds[(int)HVAC::SetptType::DualHeatCool](idx); + setpt.Name = s_ipsc->cAlphaArgs(1); + + if (s_ipsc->lAlphaFieldBlanks(2)) { + ShowSevereEmptyField(state, eoh, s_ipsc->cAlphaFieldNames(2)); + ErrorsFound = true; + } else if ((setpt.heatSched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2)); + ErrorsFound = true; + } else if (!setpt.heatSched->checkMinMaxVals(state, Clusive::In, -3.0, Clusive::In, 3.0)) { + Sched::ShowSevereBadMinMax(state, eoh, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2), Clusive::In, -3.0, Clusive::In, 3.0); ErrorsFound = true; } - dualSetpointHeatCoolFanger.CoolPMVSetptSchedName = cAlphaArgs(3); - dualSetpointHeatCoolFanger.CoolPMVSchedIndex = GetScheduleIndex(state, cAlphaArgs(3)); - if (dualSetpointHeatCoolFanger.CoolPMVSchedIndex == 0) { - ShowSevereError( - state, format("{}=\"{}\" invalid {}=\"{}\" not found.", cCurrentModuleObject, cAlphaArgs(1), cAlphaFieldNames(3), cAlphaArgs(3))); + + if (s_ipsc->lAlphaFieldBlanks(3)) { + ShowSevereEmptyField(state, eoh, s_ipsc->cAlphaFieldNames(3)); + ErrorsFound = true; + } else if ((setpt.coolSched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(3))) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(3), s_ipsc->cAlphaArgs(3)); + ErrorsFound = true; + } else if (!setpt.coolSched->checkMinMaxVals(state, Clusive::In, -3.0, Clusive::In, 3.0)) { + Sched::ShowSevereBadMinMax(state, eoh, s_ipsc->cAlphaFieldNames(3), s_ipsc->cAlphaArgs(3), Clusive::In, -3.0, Clusive::In, 3.0); ErrorsFound = true; - } else { - ValidScheduleControlType = CheckScheduleValueMinMax(state, dualSetpointHeatCoolFanger.HeatPMVSchedIndex, ">=", -3.0, "<=", 3.0); - if (!ValidScheduleControlType) { - ShowSevereError( - state, - format( - "{}=\"{}\" invalid PMV values {}=\"{}\" entered.", cCurrentModuleObject, cAlphaArgs(1), cAlphaFieldNames(2), cAlphaArgs(2))); - ShowContinueError(state, "..Values outside of range [-3,+3]."); - ErrorsFound = true; - } - ValidScheduleControlType = CheckScheduleValueMinMax(state, dualSetpointHeatCoolFanger.CoolPMVSchedIndex, ">=", -3.0, "<=", 3.0); - if (!ValidScheduleControlType) { - ShowSevereError( - state, - format( - "{}=\"{}\" invalid PMV values {}=\"{}\" entered.", cCurrentModuleObject, cAlphaArgs(1), cAlphaFieldNames(3), cAlphaArgs(3))); - ShowContinueError(state, "..Values outside of range [-3,+3]."); - ErrorsFound = true; - } } } // DualFangerHeatCoolControlNum // Finish filling in Schedule pointing indexes for Thermal Comfort Control for (ComfortControlledZoneNum = 1; ComfortControlledZoneNum <= state.dataZoneCtrls->NumComfortControlledZones; ++ComfortControlledZoneNum) { + auto &comfortZone = state.dataZoneCtrls->ComfortControlledZone(ComfortControlledZoneNum); + + for (HVAC::SetptType setptType : HVAC::setptTypes) { + auto &setpt = comfortZone.setpts[(int)setptType]; + if (!setpt.isUsed) continue; + + int setptIdx = Util::FindItem(setpt.Name, s_ztpc->comfortSetptScheds[(int)setptType]); + + if (setptType == HVAC::SetptType::SingleHeat || setptType == HVAC::SetptType::SingleHeatCool || setptType == HVAC::SetptType::DualHeatCool) { + setpt.heatSetptSched = s_ztpc->tempSetptScheds[(int)setptType](setptIdx).heatSched; + } - int ComfortIndex = Util::FindItem(ValidComfortControlTypes[static_cast(HVAC::ThermostatType::SingleHeating)], - ComfortControlledZone(ComfortControlledZoneNum).ControlType, - ComfortControlledZone(ComfortControlledZoneNum).NumControlTypes); - ComfortControlledZone(ComfortControlledZoneNum).SchIndx_SingleHeating = ComfortIndex; - if (ComfortIndex > 0) { - ComfortControlledZone(ComfortControlledZoneNum).ControlTypeSchIndx(ComfortIndex) = - Util::FindItem(ComfortControlledZone(ComfortControlledZoneNum).ControlTypeName(ComfortIndex), - state.dataZoneTempPredictorCorrector->SetPointSingleHeatingFanger); - TComfortControlTypes(ComfortControlledZoneNum).MustHave[static_cast(HVAC::ThermostatType::SingleHeating)] = true; - } - - ComfortIndex = Util::FindItem(ValidComfortControlTypes[static_cast(HVAC::ThermostatType::SingleCooling)], - ComfortControlledZone(ComfortControlledZoneNum).ControlType, - ComfortControlledZone(ComfortControlledZoneNum).NumControlTypes); - ComfortControlledZone(ComfortControlledZoneNum).SchIndx_SingleCooling = ComfortIndex; - if (ComfortIndex > 0) { - ComfortControlledZone(ComfortControlledZoneNum).ControlTypeSchIndx(ComfortIndex) = - Util::FindItem(ComfortControlledZone(ComfortControlledZoneNum).ControlTypeName(ComfortIndex), - state.dataZoneTempPredictorCorrector->SetPointSingleCoolingFanger); - TComfortControlTypes(ComfortControlledZoneNum).MustHave[static_cast(HVAC::ThermostatType::SingleCooling)] = true; - } - - ComfortIndex = Util::FindItem(ValidComfortControlTypes[static_cast(HVAC::ThermostatType::SingleHeatCool)], - ComfortControlledZone(ComfortControlledZoneNum).ControlType, - ComfortControlledZone(ComfortControlledZoneNum).NumControlTypes); - ComfortControlledZone(ComfortControlledZoneNum).SchIndx_SingleHeatCool = ComfortIndex; - if (ComfortIndex > 0) { - ComfortControlledZone(ComfortControlledZoneNum).ControlTypeSchIndx(ComfortIndex) = - Util::FindItem(ComfortControlledZone(ComfortControlledZoneNum).ControlTypeName(ComfortIndex), - state.dataZoneTempPredictorCorrector->SetPointSingleHeatCoolFanger); - TComfortControlTypes(ComfortControlledZoneNum).MustHave[static_cast(HVAC::ThermostatType::SingleHeatCool)] = true; - } - - ComfortIndex = Util::FindItem(ValidComfortControlTypes[static_cast(HVAC::ThermostatType::DualSetPointWithDeadBand)], - ComfortControlledZone(ComfortControlledZoneNum).ControlType, - ComfortControlledZone(ComfortControlledZoneNum).NumControlTypes); - ComfortControlledZone(ComfortControlledZoneNum).SchIndx_DualSetPointWithDeadBand = ComfortIndex; - if (ComfortIndex > 0) { - ComfortControlledZone(ComfortControlledZoneNum).ControlTypeSchIndx(ComfortIndex) = - Util::FindItem(ComfortControlledZone(ComfortControlledZoneNum).ControlTypeName(ComfortIndex), - state.dataZoneTempPredictorCorrector->SetPointDualHeatCoolFanger); - TComfortControlTypes(ComfortControlledZoneNum).MustHave[static_cast(HVAC::ThermostatType::DualSetPointWithDeadBand)] = true; + if (setptType == HVAC::SetptType::SingleCool || setptType == HVAC::SetptType::SingleHeatCool || setptType == HVAC::SetptType::DualHeatCool) { + setpt.coolSetptSched = s_ztpc->tempSetptScheds[(int)setptType](setptIdx).coolSched; + } + + TComfortControlTypes(ComfortControlledZoneNum).MustHave[(int)setptType] = true; } } // Now, Check the schedule values/indices for validity for Thermal Comfort Control for (ComfortControlledZoneNum = 1; ComfortControlledZoneNum <= state.dataZoneCtrls->NumComfortControlledZones; ++ComfortControlledZoneNum) { + auto &comfortZone = state.dataZoneCtrls->ComfortControlledZone(ComfortControlledZoneNum); + ActualZoneNum = comfortZone.ActualZoneNum; + if (comfortZone.setptTypeSched == nullptr) continue; - ActualZoneNum = ComfortControlledZone(ComfortControlledZoneNum).ActualZoneNum; - CTIndex = ComfortControlledZone(ComfortControlledZoneNum).ComfortSchedIndex; - if (CTIndex == 0) continue; // error will be caught elsewhere - SchedMin = GetScheduleMinValue(state, CTIndex); - SchedMax = GetScheduleMaxValue(state, CTIndex); + int SchedMin = comfortZone.setptTypeSched->getMinVal(state); + int SchedMax = comfortZone.setptTypeSched->getMaxVal(state); - if (SchedMin == 0 && SchedMax == 0) { - if (FindNumberInList(CTIndex, CCmSchedMapToControlledZone, state.dataZoneCtrls->NumComfortControlledZones) == 0) { - ShowWarningError(state, format("Control Type Schedule={}", ComfortControlledZone(ComfortControlledZoneNum).ControlTypeSchedName)); + if (SchedMin == (int)HVAC::SetptType::Uncontrolled && SchedMax == (int)HVAC::SetptType::Uncontrolled) { + if (FindNumberInList(comfortZone.setptTypeSched->Num, CCmSchedMapToControlledZone, state.dataZoneCtrls->NumComfortControlledZones) == 0) { + ShowWarningError(state, format("Control Type Schedule={}", comfortZone.setptTypeSched->Name)); ShowContinueError(state, "..specifies control type 0 for all entries."); ShowContinueError(state, "All zones using this Control Type Schedule have no thermal comfort control."); } - CCmSchedMapToControlledZone(ComfortControlledZoneNum) = CTIndex; - } - - for (ControlTypeNum = SchedMin; ControlTypeNum <= SchedMax; ++ControlTypeNum) { - - int ComfortIndex; - switch (static_cast(ControlTypeNum)) { - case HVAC::ThermostatType::Uncontrolled: - break; - case HVAC::ThermostatType::SingleHeating: - ComfortIndex = ComfortControlledZone(ComfortControlledZoneNum).SchIndx_SingleHeating; - TComfortControlTypes(ComfortControlledZoneNum).DidHave[static_cast(HVAC::ThermostatType::SingleHeating)] = true; - if (ComfortIndex != 0) { - SchedTypeIndex = ComfortControlledZone(ComfortControlledZoneNum).ControlTypeSchIndx(ComfortIndex); - if (SchedTypeIndex == 0) { - ShowSevereError(state, - format("GetZoneAirSetpoints: Could not find {} Schedule={}", - ValidComfortControlTypes[static_cast(HVAC::ThermostatType::SingleHeating)], - ComfortControlledZone(ComfortControlledZoneNum).ControlTypeName(ComfortIndex))); - ErrorsFound = true; - } - } else { // ComfortIndex = 0 - if (CheckScheduleValue(state, CTIndex, static_cast(HVAC::ThermostatType::SingleHeating))) { - ShowSevereError(state, - format("Control Type Schedule={}", ComfortControlledZone(ComfortControlledZoneNum).ControlTypeSchedName)); - ShowContinueError(state, - format("..specifies thermal control type 1 ({}) as the control type. Not valid for this zone.", - ValidComfortControlTypes[static_cast(HVAC::ThermostatType::SingleHeating)])); - ShowContinueError(state, - format("..reference {}={}", - cZControlTypes(static_cast(ZoneControlTypes::TCTStat)), - ComfortControlledZone(ComfortControlledZoneNum).Name)); - ShowContinueError(state, format("..reference ZONE={}", ComfortControlledZone(ComfortControlledZoneNum).ZoneName)); - ErrorsFound = true; - } - } - break; - case HVAC::ThermostatType::SingleCooling: - ComfortIndex = ComfortControlledZone(ComfortControlledZoneNum).SchIndx_SingleCooling; - TComfortControlTypes(ComfortControlledZoneNum).DidHave[static_cast(HVAC::ThermostatType::SingleCooling)] = true; - if (ComfortIndex != 0) { - SchedTypeIndex = ComfortControlledZone(ComfortControlledZoneNum).ControlTypeSchIndx(ComfortIndex); - if (SchedTypeIndex == 0) { - ShowSevereError(state, - format("GetZoneAirSetpoints: Could not find {} Schedule={}", - ValidComfortControlTypes[static_cast(HVAC::ThermostatType::SingleCooling)], - ComfortControlledZone(ComfortControlledZoneNum).ControlTypeName(ComfortIndex))); - ErrorsFound = true; - } - } else { // ComfortIndex = 0 - if (CheckScheduleValue(state, CTIndex, static_cast(HVAC::ThermostatType::SingleCooling))) { - ShowSevereError(state, - format("Control Type Schedule={}", ComfortControlledZone(ComfortControlledZoneNum).ControlTypeSchedName)); - ShowContinueError(state, - format("..specifies thermal control type 2 ({}) as the control type. Not valid for this zone.", - ValidComfortControlTypes[static_cast(HVAC::ThermostatType::SingleCooling)])); - ShowContinueError(state, - format("..reference {}={}", - cZControlTypes(static_cast(ZoneControlTypes::TCTStat)), - ComfortControlledZone(ComfortControlledZoneNum).Name)); - ShowContinueError(state, format("..reference ZONE={}", ComfortControlledZone(ComfortControlledZoneNum).ZoneName)); - ErrorsFound = true; - } - } - break; - case HVAC::ThermostatType::SingleHeatCool: - ComfortIndex = ComfortControlledZone(ComfortControlledZoneNum).SchIndx_SingleHeatCool; - TComfortControlTypes(ComfortControlledZoneNum).DidHave[static_cast(HVAC::ThermostatType::SingleHeatCool)] = true; - if (ComfortIndex != 0) { - SchedTypeIndex = ComfortControlledZone(ComfortControlledZoneNum).ControlTypeSchIndx(ComfortIndex); - if (SchedTypeIndex == 0) { - ShowSevereError(state, - format("GetZoneAirSetpoints: Could not find {} Schedule={}", - ValidComfortControlTypes[static_cast(HVAC::ThermostatType::SingleHeatCool)], - ComfortControlledZone(ComfortControlledZoneNum).ControlTypeName(ComfortIndex))); - ErrorsFound = true; - } - } else { // ComfortIndex = 0 - if (CheckScheduleValue(state, CTIndex, static_cast(HVAC::ThermostatType::SingleHeatCool))) { - ShowSevereError(state, format("Schedule={}", ComfortControlledZone(ComfortControlledZoneNum).ControlTypeSchedName)); - ShowContinueError(state, - format("..specifies thermal control type 3 ({}) as the control type. Not valid for this zone.", - ValidComfortControlTypes[static_cast(HVAC::ThermostatType::SingleHeatCool)])); - ShowContinueError(state, - format("..reference {}={}", - cZControlTypes(static_cast(ZoneControlTypes::TCTStat)), - ComfortControlledZone(ComfortControlledZoneNum).Name)); - ShowContinueError(state, format("..reference ZONE={}", ComfortControlledZone(ComfortControlledZoneNum).ZoneName)); - ErrorsFound = true; - } - } - break; - case HVAC::ThermostatType::DualSetPointWithDeadBand: - ComfortIndex = ComfortControlledZone(ComfortControlledZoneNum).SchIndx_DualSetPointWithDeadBand; - TComfortControlTypes(ComfortControlledZoneNum).DidHave[static_cast(HVAC::ThermostatType::DualSetPointWithDeadBand)] = true; - if (ComfortIndex != 0) { - SchedTypeIndex = ComfortControlledZone(ComfortControlledZoneNum).ControlTypeSchIndx(ComfortIndex); - if (SchedTypeIndex == 0) { - ShowSevereError(state, - format("GetZoneAirSetpoints: Could not find {} Schedule={}", - ValidComfortControlTypes[static_cast(HVAC::ThermostatType::DualSetPointWithDeadBand)], - ComfortControlledZone(ComfortControlledZoneNum).ControlTypeName(ComfortIndex))); - ErrorsFound = true; - } - } else { // ComfortIndex = 0 - if (CheckScheduleValue(state, CTIndex, static_cast(HVAC::ThermostatType::DualSetPointWithDeadBand))) { - ShowSevereError(state, format("Schedule={}", ComfortControlledZone(ComfortControlledZoneNum).ControlTypeSchedName)); - ShowContinueError(state, - format("..specifies thermal control type 4 ({}) as the control type. Not valid for this zone.", - ValidComfortControlTypes[static_cast(HVAC::ThermostatType::DualSetPointWithDeadBand)])); - ShowContinueError(state, - format("..reference {}={}", - cZControlTypes(static_cast(ZoneControlTypes::TCTStat)), - ComfortControlledZone(ComfortControlledZoneNum).Name)); - ShowContinueError(state, format("..reference ZONE={}", ComfortControlledZone(ComfortControlledZoneNum).ZoneName)); - ErrorsFound = true; - } - } - break; - default: - ShowSevereError(state, - format("GetZoneAirSetpoints: Illegal control type for Zone={}, Found value={}, in Schedule={}", - Zone(ActualZoneNum).Name, - ControlTypeNum, - ComfortControlledZone(ComfortControlledZoneNum).ControlTypeSchedName)); - ShowContinueError(state, "..valid range values are [0,4]."); + CCmSchedMapToControlledZone(ComfortControlledZoneNum) = comfortZone.setptTypeSched->Num; + } + + for (HVAC::SetptType setptType : HVAC::setptTypes) { + auto const &setpt = comfortZone.setpts[(int)setptType]; + if (!setpt.isUsed) continue; + + TComfortControlTypes(ComfortControlledZoneNum).DidHave[(int)setptType] = true; + + if (setpt.heatSetptSched == nullptr && + (setptType == HVAC::SetptType::SingleHeat || setptType == HVAC::SetptType::SingleHeatCool || setptType == HVAC::SetptType::DualHeatCool) && + comfortZone.setptTypeSched->hasVal(state, (int)setptType)) { + ShowSevereError(state, format("Control Type Schedule={}", comfortZone.setptTypeSched->Name)); + ShowContinueError(state, format("..specifies {} ({}) as the control type. Not valid for this zone.", (int)setptType, setptTypeNames[(int)setptType])); + ShowContinueError(state, format("..reference {}={}", cZControlTypes((int)ZoneControlTypes::TStat), comfortZone.Name)); + ShowContinueError(state, format("..reference ZONE={}", comfortZone.ZoneName)); ErrorsFound = true; - break; - } - } - } + } + + if (setpt.coolSetptSched == nullptr && + (setptType == HVAC::SetptType::SingleCool || setptType == HVAC::SetptType::SingleHeatCool || setptType == HVAC::SetptType::DualHeatCool) && + comfortZone.setptTypeSched->hasVal(state, (int)setptType)) { + ShowSevereError(state, format("Control Type Schedule={}", comfortZone.setptTypeSched->Name)); + ShowContinueError(state, format("..specifies {} ({}) as the control type. Not valid for this zone.", (int)setptType, setptTypeNames[(int)setptType])); + ShowContinueError(state, format("..reference {}={}", cZControlTypes((int)ZoneControlTypes::TStat), comfortZone.Name)); + ShowContinueError(state, format("..reference ZONE={}", comfortZone.ZoneName)); + ErrorsFound = true; + } + } // for (setptType) + } // for (ComfortControlledZoneNum) - for (ComfortControlledZoneNum = 1; ComfortControlledZoneNum <= state.dataZoneCtrls->NumComfortControlledZones; ++ComfortControlledZoneNum) { + for (int ComfortControlledZoneNum = 1; ComfortControlledZoneNum <= state.dataZoneCtrls->NumComfortControlledZones; ++ComfortControlledZoneNum) { - ActualZoneNum = ComfortControlledZone(ComfortControlledZoneNum).ActualZoneNum; - CTIndex = ComfortControlledZone(ComfortControlledZoneNum).ComfortSchedIndex; - if (CTIndex == 0) continue; // error caught elsewhere -- would just be confusing here + auto &comfortZone = state.dataZoneCtrls->ComfortControlledZone(ComfortControlledZoneNum); + ActualZoneNum = comfortZone.ActualZoneNum; + if (comfortZone.setptTypeSched == nullptr) continue; - for (ControlTypeNum = 1; ControlTypeNum <= 4; ++ControlTypeNum) { - if (TComfortControlTypes(ComfortControlledZoneNum).MustHave[ControlTypeNum] && - TComfortControlTypes(ComfortControlledZoneNum).DidHave[ControlTypeNum]) + for (HVAC::SetptType setptType : HVAC::setptTypes) { + if (TComfortControlTypes(ComfortControlledZoneNum).MustHave[(int)setptType] && + TComfortControlTypes(ComfortControlledZoneNum).DidHave[(int)setptType]) continue; - - switch (static_cast(ControlTypeNum)) { - case HVAC::ThermostatType::SingleHeating: - if (!TComfortControlTypes(ComfortControlledZoneNum).MustHave[ControlTypeNum]) continue; - ShowWarningError(state, format("Schedule={}", ComfortControlledZone(ComfortControlledZoneNum).ControlTypeSchedName)); - ShowContinueError(state, - format("...should include control type 1 ({}) but does not.", - ValidComfortControlTypes[static_cast(HVAC::ThermostatType::SingleHeating)])); - ShowContinueError(state, - format("..reference {}={}", - cZControlTypes(static_cast(ZoneControlTypes::TCTStat)), - ComfortControlledZone(ComfortControlledZoneNum).Name)); - ShowContinueError(state, format("..reference ZONE={}", ComfortControlledZone(ComfortControlledZoneNum).ZoneName)); - break; - case HVAC::ThermostatType::SingleCooling: - if (!TComfortControlTypes(ComfortControlledZoneNum).MustHave[ControlTypeNum]) continue; - ShowWarningError(state, format("Schedule={}", ComfortControlledZone(ComfortControlledZoneNum).ControlTypeSchedName)); - ShowContinueError(state, - format("...should include control type 2 ({}) but does not.", - ValidComfortControlTypes[static_cast(HVAC::ThermostatType::SingleCooling)])); - ShowContinueError(state, - format("..reference {}={}", - cZControlTypes(static_cast(ZoneControlTypes::TCTStat)), - ComfortControlledZone(ComfortControlledZoneNum).Name)); - ShowContinueError(state, format("..reference ZONE={}", ComfortControlledZone(ComfortControlledZoneNum).ZoneName)); - break; - case HVAC::ThermostatType::SingleHeatCool: - if (!TComfortControlTypes(ComfortControlledZoneNum).MustHave[ControlTypeNum]) continue; - ShowWarningError(state, format("Schedule={}", ComfortControlledZone(ComfortControlledZoneNum).ControlTypeSchedName)); - ShowContinueError(state, - format("...should include control type 3 ({}) but does not.", - ValidComfortControlTypes[static_cast(HVAC::ThermostatType::SingleHeatCool)])); - ShowContinueError(state, - format("..reference {}={}", - cZControlTypes(static_cast(ZoneControlTypes::TCTStat)), - ComfortControlledZone(ComfortControlledZoneNum).Name)); - ShowContinueError(state, format("..reference ZONE={}", ComfortControlledZone(ComfortControlledZoneNum).ZoneName)); - break; - case HVAC::ThermostatType::DualSetPointWithDeadBand: - if (!TComfortControlTypes(ComfortControlledZoneNum).MustHave[ControlTypeNum]) continue; - ShowWarningError(state, format("Schedule={}", ComfortControlledZone(ComfortControlledZoneNum).ControlTypeSchedName)); - ShowContinueError(state, - format("...should include control type 4 ({}) but does not.", - ValidComfortControlTypes[static_cast(HVAC::ThermostatType::DualSetPointWithDeadBand)])); - ShowContinueError(state, - format("..reference {}={}", - cZControlTypes(static_cast(ZoneControlTypes::TCTStat)), - ComfortControlledZone(ComfortControlledZoneNum).Name)); - ShowContinueError(state, format("..reference ZONE={}", ComfortControlledZone(ComfortControlledZoneNum).ZoneName)); - break; - default: - break; - } + + if (!TComfortControlTypes(ComfortControlledZoneNum).MustHave[(int)setptType]) continue; + + ShowWarningError(state, format("Schedule={}", comfortZone.setptTypeSched->Name)); + ShowContinueError(state, format("...should include control type {} ({}) but does not.", (int)setptType, comfortSetptTypeNames[(int)setptType])); + ShowContinueError(state, format("..reference {}={}", cZControlTypes((int)ZoneControlTypes::TCTStat), comfortZone.Name)); + ShowContinueError(state, format("...reference ZONE={}", comfortZone.ZoneName)); } } @@ -1755,8 +1348,8 @@ void GetZoneAirSetPoints(EnergyPlusData &state) Real64 ZoneVolCapMultpGenContam = 1.0; // Get the Zone Air Capacitance Multiplier for use in the Predictor-Corrector Procedure - cCurrentModuleObject = "ZoneCapacitanceMultiplier:ResearchSpecial"; - int NumZoneCapaMultiplier = inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); // Number of ZonesCapacityMultiplier object + s_ipsc->cCurrentModuleObject = "ZoneCapacitanceMultiplier:ResearchSpecial"; + int NumZoneCapaMultiplier = s_ip->getNumObjectsFound(state, s_ipsc->cCurrentModuleObject); // Number of ZonesCapacityMultiplier object if (NumZoneCapaMultiplier == 0) { // Assign default multiplier values to all zones for (int ZoneNum = 1; ZoneNum <= NumOfZones; ZoneNum++) { @@ -1772,52 +1365,52 @@ void GetZoneAirSetPoints(EnergyPlusData &state) // Added by S. Lee and R. Zhang in Oct. 2016. // Assign the user inputted multipliers to specified zones for (int ZoneCapNum = 1; ZoneCapNum <= NumZoneCapaMultiplier; ZoneCapNum++) { - inputProcessor->getObjectItem(state, - cCurrentModuleObject, - ZoneCapNum, - cAlphaArgs, - NumAlphas, - rNumericArgs, - NumNums, - IOStat, - lNumericFieldBlanks, - lAlphaFieldBlanks, - cAlphaFieldNames, - cNumericFieldNames); - - if (lAlphaFieldBlanks(2)) { + s_ip->getObjectItem(state, + s_ipsc->cCurrentModuleObject, + ZoneCapNum, + s_ipsc->cAlphaArgs, + NumAlphas, + s_ipsc->rNumericArgs, + NumNums, + IOStat, + s_ipsc->lNumericFieldBlanks, + s_ipsc->lAlphaFieldBlanks, + s_ipsc->cAlphaFieldNames, + s_ipsc->cNumericFieldNames); + + if (s_ipsc->lAlphaFieldBlanks(2)) { // default multiplier values for all the zones not specified (zone or zonelist name field is empty) - ZoneVolCapMultpSens = rNumericArgs(1); - ZoneVolCapMultpMoist = rNumericArgs(2); - ZoneVolCapMultpCO2 = rNumericArgs(3); - ZoneVolCapMultpGenContam = rNumericArgs(4); + ZoneVolCapMultpSens = s_ipsc->rNumericArgs(1); + ZoneVolCapMultpMoist = s_ipsc->rNumericArgs(2); + ZoneVolCapMultpCO2 = s_ipsc->rNumericArgs(3); + ZoneVolCapMultpGenContam = s_ipsc->rNumericArgs(4); } else { // multiplier values for the specified zone(s) int ZoneNum = 0; ZLItem = 0; - Item1 = Util::FindItemInList(cAlphaArgs(2), Zone); - if (Item1 == 0 && state.dataHeatBal->NumOfZoneLists > 0) ZLItem = Util::FindItemInList(cAlphaArgs(2), ZoneList); + Item1 = Util::FindItemInList(s_ipsc->cAlphaArgs(2), Zone); + if (Item1 == 0 && state.dataHeatBal->NumOfZoneLists > 0) ZLItem = Util::FindItemInList(s_ipsc->cAlphaArgs(2), ZoneList); if (Item1 > 0) { ZoneNum = Item1; Zone(ZoneNum).FlagCustomizedZoneCap = true; - Zone(ZoneNum).ZoneVolCapMultpSens = rNumericArgs(1); - Zone(ZoneNum).ZoneVolCapMultpMoist = rNumericArgs(2); - Zone(ZoneNum).ZoneVolCapMultpCO2 = rNumericArgs(3); - Zone(ZoneNum).ZoneVolCapMultpGenContam = rNumericArgs(4); + Zone(ZoneNum).ZoneVolCapMultpSens = s_ipsc->rNumericArgs(1); + Zone(ZoneNum).ZoneVolCapMultpMoist = s_ipsc->rNumericArgs(2); + Zone(ZoneNum).ZoneVolCapMultpCO2 = s_ipsc->rNumericArgs(3); + Zone(ZoneNum).ZoneVolCapMultpGenContam = s_ipsc->rNumericArgs(4); } else if (ZLItem > 0) { for (int ZonePtrNum = 1; ZonePtrNum < ZoneList(ZLItem).NumOfZones; ZonePtrNum++) { ZoneNum = ZoneList(ZLItem).Zone(ZonePtrNum); Zone(ZoneNum).FlagCustomizedZoneCap = true; - Zone(ZoneNum).ZoneVolCapMultpSens = rNumericArgs(1); - Zone(ZoneNum).ZoneVolCapMultpMoist = rNumericArgs(2); - Zone(ZoneNum).ZoneVolCapMultpCO2 = rNumericArgs(3); - Zone(ZoneNum).ZoneVolCapMultpGenContam = rNumericArgs(4); + Zone(ZoneNum).ZoneVolCapMultpSens = s_ipsc->rNumericArgs(1); + Zone(ZoneNum).ZoneVolCapMultpMoist = s_ipsc->rNumericArgs(2); + Zone(ZoneNum).ZoneVolCapMultpCO2 = s_ipsc->rNumericArgs(3); + Zone(ZoneNum).ZoneVolCapMultpGenContam = s_ipsc->rNumericArgs(4); } } else { ShowSevereError( state, - format("{}=\"{}\" invalid {}=\"{}\" not found.", cCurrentModuleObject, cAlphaArgs(1), cAlphaFieldNames(2), cAlphaArgs(2))); + format("{}=\"{}\" invalid {}=\"{}\" not found.", s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1), s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2))); ErrorsFound = true; } } @@ -1859,113 +1452,96 @@ void GetZoneAirSetPoints(EnergyPlusData &state) print(state.files.eio, Header); print(state.files.eio, Format_701, ZoneVolCapMultpSens, ZoneVolCapMultpMoist, ZoneVolCapMultpCO2, ZoneVolCapMultpGenContam); - cCurrentModuleObject = cZControlTypes(static_cast(ZoneControlTypes::OTTStat)); - state.dataZoneCtrls->NumOpTempControlledZones = inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); + s_ipsc->cCurrentModuleObject = cZControlTypes((int)ZoneControlTypes::OTTStat); + state.dataZoneCtrls->NumOpTempControlledZones = s_ip->getNumObjectsFound(state, s_ipsc->cCurrentModuleObject); if (state.dataZoneCtrls->NumOpTempControlledZones > 0) { state.dataZoneCtrls->AnyOpTempControl = true; for (int idx = 1; idx <= state.dataZoneCtrls->NumOpTempControlledZones; ++idx) { - inputProcessor->getObjectItem(state, - cCurrentModuleObject, - idx, - cAlphaArgs, - NumAlphas, - rNumericArgs, - NumNums, - IOStat, - lNumericFieldBlanks, - lAlphaFieldBlanks, - cAlphaFieldNames, - cNumericFieldNames); + s_ip->getObjectItem(state, + s_ipsc->cCurrentModuleObject, + idx, + s_ipsc->cAlphaArgs, + NumAlphas, + s_ipsc->rNumericArgs, + NumNums, + IOStat, + s_ipsc->lNumericFieldBlanks, + s_ipsc->lAlphaFieldBlanks, + s_ipsc->cAlphaFieldNames, + s_ipsc->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)}; + // find matching name of ZONECONTROL:THERMOSTAT object - found = Util::FindItem(cAlphaArgs(1), TStatObjects); + found = Util::FindItem(s_ipsc->cAlphaArgs(1), TStatObjects); if (found == 0) { // It might be in the TempControlledZones - found = Util::FindItem(cAlphaArgs(1), TempControlledZone); + found = Util::FindItem(s_ipsc->cAlphaArgs(1), state.dataZoneCtrls->TempControlledZone); if (found == 0) { // throw error ShowSevereError(state, format("{}={} invalid {} reference not found.", - cCurrentModuleObject, - cAlphaArgs(1), + s_ipsc->cCurrentModuleObject, + s_ipsc->cAlphaArgs(1), cZControlTypes(static_cast(ZoneControlTypes::TStat)))); ErrorsFound = true; } else { TempControlledZoneNum = found; - TempControlledZone(TempControlledZoneNum).OperativeTempControl = true; - if (Util::SameString(cAlphaArgs(2), "Scheduled")) { - TempControlledZone(TempControlledZoneNum).OpTempCntrlModeScheduled = true; + auto &tempZone = state.dataZoneCtrls->TempControlledZone(TempControlledZoneNum); + tempZone.OperativeTempControl = true; + if (Util::SameString(s_ipsc->cAlphaArgs(2), "Scheduled")) { + tempZone.OpTempCntrlModeScheduled = true; } - if ((!(Util::SameString(cAlphaArgs(2), "Scheduled"))) && (!(Util::SameString(cAlphaArgs(2), "Constant")))) { - ShowSevereError(state, - format("{}={} invalid {}=\"{}\".", cCurrentModuleObject, cAlphaArgs(1), cAlphaFieldNames(2), cAlphaArgs(2))); + if ((!(Util::SameString(s_ipsc->cAlphaArgs(2), "Scheduled"))) && (!(Util::SameString(s_ipsc->cAlphaArgs(2), "Constant")))) { + ShowSevereInvalidKey(state, eoh, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2)); ErrorsFound = true; } - TempControlledZone(TempControlledZoneNum).FixedRadiativeFraction = rNumericArgs(1); - TempControlledZone(TempControlledZoneNum).OpTempRadiativeFractionSched = GetScheduleIndex(state, cAlphaArgs(3)); - if ((TempControlledZone(TempControlledZoneNum).OpTempRadiativeFractionSched == 0) && - (TempControlledZone(TempControlledZoneNum).OpTempCntrlModeScheduled)) { // throw error - ShowSevereError( - state, - format("{}={} invalid {}=\"{}\" not found.", cCurrentModuleObject, cAlphaArgs(1), cAlphaFieldNames(3), cAlphaArgs(3))); - ErrorsFound = true; - } + tempZone.FixedRadiativeFraction = s_ipsc->rNumericArgs(1); - // check validity of fixed radiative fraction - if ((TempControlledZone(TempControlledZoneNum).FixedRadiativeFraction < 0.0) && - (!(TempControlledZone(TempControlledZoneNum).OpTempCntrlModeScheduled))) { - ShowSevereError(state, - format("{}={} invalid {}=[{:.2T}\" cannot be negative.", - cCurrentModuleObject, - cAlphaArgs(1), - cNumericFieldNames(1), - rNumericArgs(1))); - ErrorsFound = true; - } - if ((TempControlledZone(TempControlledZoneNum).FixedRadiativeFraction >= 0.9) && - (!(TempControlledZone(TempControlledZoneNum).OpTempCntrlModeScheduled))) { - ShowSevereError(state, - format("{}={} invalid {}=[{:.2T}\" cannot >= .9.", - cCurrentModuleObject, - cAlphaArgs(1), - cNumericFieldNames(1), - rNumericArgs(1))); - ErrorsFound = true; - } + if (tempZone.OpTempCntrlModeScheduled) { + if (s_ipsc->lAlphaFieldBlanks(3)) { + ShowSevereEmptyField(state, eoh, s_ipsc->cAlphaFieldNames(3)); + ErrorsFound = true; + } else if ((tempZone.opTempRadiativeFractionSched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(3))) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(3), s_ipsc->cAlphaArgs(3)); + ErrorsFound = true; + } else if (!tempZone.opTempRadiativeFractionSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::Ex, 0.9)) { + Sched::ShowSevereBadMinMax(state, eoh, s_ipsc->cAlphaFieldNames(3), s_ipsc->cAlphaArgs(3), Clusive::In, 0.0, Clusive::Ex, 0.9); + ErrorsFound = true; + } - // check schedule min max. - if (TempControlledZone(TempControlledZoneNum).OpTempCntrlModeScheduled) { - ValidRadFractSched = CheckScheduleValueMinMax( - state, TempControlledZone(TempControlledZoneNum).OpTempRadiativeFractionSched, ">=", 0.0, "<", 0.9); - if (!ValidRadFractSched) { - ShowSevereError( - state, - format("{}={} invalid values {}=[{}\".", cCurrentModuleObject, cAlphaArgs(1), cAlphaFieldNames(3), cAlphaArgs(3))); - ShowContinueError(state, "..Values outside of range [0.0,0.9)."); + } else { // !tempZone.OpTempCntrlModeScheduled + + if (tempZone.FixedRadiativeFraction < 0.0) { + ShowSevereBadMin(state, eoh, s_ipsc->cNumericFieldNames(1), s_ipsc->rNumericArgs(1), Clusive::In, 0.0); ErrorsFound = true; + } else if (tempZone.FixedRadiativeFraction >= 0.9) { + ShowSevereBadMax(state, eoh, s_ipsc->cNumericFieldNames(1), s_ipsc->rNumericArgs(1), Clusive::Ex, 0.9); + ErrorsFound = true; } } // added Jan, 2017 - Xuan Luo // read adaptive comfort model and calculate adaptive thermal comfort setpoint - if (TempControlledZone(TempControlledZoneNum).OperativeTempControl) { - if (NumAlphas >= 4 && !lAlphaFieldBlanks(4)) { + if (tempZone.OperativeTempControl) { + if (NumAlphas >= 4 && !s_ipsc->lAlphaFieldBlanks(4)) { int adaptiveComfortModelTypeIndex = - Util::FindItem(cAlphaArgs(4), AdaptiveComfortModelTypes, AdaptiveComfortModelTypes.isize()); + Util::FindItem(s_ipsc->cAlphaArgs(4), AdaptiveComfortModelTypes, AdaptiveComfortModelTypes.isize()); if (!adaptiveComfortModelTypeIndex) { ShowSevereError(state, format("{}={} invalid {}=\"{}\" not found.", - cCurrentModuleObject, - cAlphaArgs(1), - cAlphaFieldNames(4), - cAlphaArgs(4))); + s_ipsc->cCurrentModuleObject, + s_ipsc->cAlphaArgs(1), + s_ipsc->cAlphaFieldNames(4), + s_ipsc->cAlphaArgs(4))); ErrorsFound = true; } else if (adaptiveComfortModelTypeIndex != static_cast(AdaptiveComfortModel::ADAP_NONE)) { - TempControlledZone(TempControlledZoneNum).AdaptiveComfortTempControl = true; - TempControlledZone(TempControlledZoneNum).AdaptiveComfortModelTypeIndex = - Util::FindItem(cAlphaArgs(4), AdaptiveComfortModelTypes, AdaptiveComfortModelTypes.isize()); - if (!state.dataZoneTempPredictorCorrector->AdapComfortDailySetPointSchedule.initialized) { + tempZone.AdaptiveComfortTempControl = true; + tempZone.AdaptiveComfortModelTypeIndex = + Util::FindItem(s_ipsc->cAlphaArgs(4), AdaptiveComfortModelTypes, AdaptiveComfortModelTypes.isize()); + if (!s_ztpc->AdapComfortDailySetPointSchedule.initialized) { Array1D runningAverageASH(state.dataWeather->NumDaysInYear, 0.0); Array1D runningAverageCEN(state.dataWeather->NumDaysInYear, 0.0); CalculateMonthlyRunningAverageDryBulb(state, runningAverageASH, runningAverageCEN); @@ -1979,77 +1555,57 @@ void GetZoneAirSetPoints(EnergyPlusData &state) SetupOutputVariable(state, "Zone Thermostat Operative Temperature", Constant::Units::C, - state.dataHeatBal->ZnAirRpt(TempControlledZone(TempControlledZoneNum).ActualZoneNum).ThermOperativeTemp, + state.dataHeatBal->ZnAirRpt(tempZone.ActualZoneNum).ThermOperativeTemp, OutputProcessor::TimeStepType::Zone, OutputProcessor::StoreType::Average, - Zone(TempControlledZone(TempControlledZoneNum).ActualZoneNum).Name); + Zone(tempZone.ActualZoneNum).Name); } } else { for (Item = 1; Item <= TStatObjects(found).NumOfZones; ++Item) { TempControlledZoneNum = TStatObjects(found).TempControlledZoneStartPtr + Item - 1; if (state.dataZoneCtrls->NumTempControlledZones == 0) continue; - TempControlledZone(TempControlledZoneNum).OperativeTempControl = true; - if (Util::SameString(cAlphaArgs(2), "Scheduled")) { - TempControlledZone(TempControlledZoneNum).OpTempCntrlModeScheduled = true; + + auto &tempZone = state.dataZoneCtrls->TempControlledZone(TempControlledZoneNum); + tempZone.OperativeTempControl = true; + if (Util::SameString(s_ipsc->cAlphaArgs(2), "Scheduled")) { + tempZone.OpTempCntrlModeScheduled = true; } if (Item == 1) { - if ((!(Util::SameString(cAlphaArgs(2), "Scheduled"))) && (!(Util::SameString(cAlphaArgs(2), "Constant")))) { - ShowSevereError( - state, format("{}={} invalid {}=\"{}\".", cCurrentModuleObject, cAlphaArgs(1), cAlphaFieldNames(2), cAlphaArgs(2))); + if ((!(Util::SameString(s_ipsc->cAlphaArgs(2), "Scheduled"))) && (!(Util::SameString(s_ipsc->cAlphaArgs(2), "Constant")))) { + ShowSevereInvalidKey(state, eoh, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2)); ErrorsFound = true; } } - TempControlledZone(TempControlledZoneNum).FixedRadiativeFraction = rNumericArgs(1); - TempControlledZone(TempControlledZoneNum).OpTempRadiativeFractionSched = GetScheduleIndex(state, cAlphaArgs(3)); - if (Item == 1) { - if ((TempControlledZone(TempControlledZoneNum).OpTempRadiativeFractionSched == 0) && - (TempControlledZone(TempControlledZoneNum).OpTempCntrlModeScheduled)) { // throw error - ShowSevereError( - state, - format( - "{}={} invalid {}=\"{}\" not found.", cCurrentModuleObject, cAlphaArgs(1), cAlphaFieldNames(3), cAlphaArgs(3))); - ErrorsFound = true; - } - } + tempZone.FixedRadiativeFraction = s_ipsc->rNumericArgs(1); - // check validity of fixed radiative fraction - if (Item == 1) { - if ((TempControlledZone(TempControlledZoneNum).FixedRadiativeFraction < 0.0) && - (!(TempControlledZone(TempControlledZoneNum).OpTempCntrlModeScheduled))) { - ShowSevereError(state, - format("{}={} invalid {}=[{:.2T}\" cannot be negative.", - cCurrentModuleObject, - cAlphaArgs(1), - cNumericFieldNames(1), - rNumericArgs(1))); - ErrorsFound = true; - } - } - if (Item == 1) { - if ((TempControlledZone(TempControlledZoneNum).FixedRadiativeFraction >= 0.9) && - (!(TempControlledZone(TempControlledZoneNum).OpTempCntrlModeScheduled))) { - ShowSevereError(state, - format("{}={} invalid {}=[{:.2T}\" cannot >= .9.", - cCurrentModuleObject, - cAlphaArgs(1), - cNumericFieldNames(1), - rNumericArgs(1))); - ErrorsFound = true; + if (tempZone.OpTempCntrlModeScheduled) { + if (s_ipsc->lAlphaFieldBlanks(3)) { + if (Item == 1) { + ShowSevereEmptyField(state, eoh, s_ipsc->cAlphaFieldNames(3)); + ErrorsFound = true; + } + } else if ((tempZone.opTempRadiativeFractionSched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(3))) == nullptr) { + if (Item == 1) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(3), s_ipsc->cAlphaArgs(3)); + ErrorsFound = true; + } + } else if (!tempZone.opTempRadiativeFractionSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::Ex, 0.9)) { + if (Item == 1) { + Sched::ShowSevereBadMinMax(state, eoh, s_ipsc->cAlphaFieldNames(3), s_ipsc->cAlphaArgs(3), Clusive::In, 0.0, Clusive::Ex, 0.9); + ErrorsFound = true; + } } - } + + } else { // !tempZone.OpTempCntrlModeScheduled - // check schedule min max. - if (Item == 1) { - if (TempControlledZone(TempControlledZoneNum).OpTempCntrlModeScheduled) { - ValidRadFractSched = CheckScheduleValueMinMax( - state, TempControlledZone(TempControlledZoneNum).OpTempRadiativeFractionSched, ">=", 0.0, "<", 0.9); - if (!ValidRadFractSched) { - ShowSevereError( - state, - format( - "{}={} invalid values {}=[{}\".", cCurrentModuleObject, cAlphaArgs(1), cAlphaFieldNames(3), cAlphaArgs(3))); - ShowContinueError(state, "..Values outside of range [0.0,0.9)."); + // check validity of fixed radiative fraction + if (Item == 1) { + if (tempZone.FixedRadiativeFraction < 0.0) { + ShowSevereBadMin(state, eoh, s_ipsc->cNumericFieldNames(1), s_ipsc->rNumericArgs(1), Clusive::In, 0.0); + ErrorsFound = true; + } else if (tempZone.FixedRadiativeFraction >= 0.9) { + ShowSevereBadMax(state, eoh, s_ipsc->cNumericFieldNames(1), s_ipsc->rNumericArgs(1), Clusive::Ex, 0.9); ErrorsFound = true; } } @@ -2057,23 +1613,18 @@ void GetZoneAirSetPoints(EnergyPlusData &state) // added Jan, 2017 - Xuan Luo // read adaptive comfort model and calculate adaptive thermal comfort setpoint - if (TempControlledZone(TempControlledZoneNum).OperativeTempControl) { - if (NumAlphas >= 4 && !lAlphaFieldBlanks(4)) { + if (tempZone.OperativeTempControl) { + if (NumAlphas >= 4 && !s_ipsc->lAlphaFieldBlanks(4)) { int adaptiveComfortModelTypeIndex = - Util::FindItem(cAlphaArgs(4), AdaptiveComfortModelTypes, AdaptiveComfortModelTypes.isize()); + Util::FindItem(s_ipsc->cAlphaArgs(4), AdaptiveComfortModelTypes, AdaptiveComfortModelTypes.isize()); if (!adaptiveComfortModelTypeIndex) { - ShowSevereError(state, - format("{}={} invalid {}=\"{}\" not found.", - cCurrentModuleObject, - cAlphaArgs(1), - cAlphaFieldNames(4), - cAlphaArgs(4))); + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(4), s_ipsc->cAlphaArgs(4)); ErrorsFound = true; } else if (adaptiveComfortModelTypeIndex != static_cast(AdaptiveComfortModel::ADAP_NONE)) { - TempControlledZone(TempControlledZoneNum).AdaptiveComfortTempControl = true; - TempControlledZone(TempControlledZoneNum).AdaptiveComfortModelTypeIndex = - Util::FindItem(cAlphaArgs(4), AdaptiveComfortModelTypes, AdaptiveComfortModelTypes.isize()); - if (!state.dataZoneTempPredictorCorrector->AdapComfortDailySetPointSchedule.initialized) { + tempZone.AdaptiveComfortTempControl = true; + tempZone.AdaptiveComfortModelTypeIndex = + Util::FindItem(s_ipsc->cAlphaArgs(4), AdaptiveComfortModelTypes, AdaptiveComfortModelTypes.isize()); + if (!s_ztpc->AdapComfortDailySetPointSchedule.initialized) { Array1D runningAverageASH(state.dataWeather->NumDaysInYear, 0.0); Array1D runningAverageCEN(state.dataWeather->NumDaysInYear, 0.0); CalculateMonthlyRunningAverageDryBulb(state, runningAverageASH, runningAverageCEN); @@ -2087,488 +1638,400 @@ void GetZoneAirSetPoints(EnergyPlusData &state) SetupOutputVariable(state, "Zone Thermostat Operative Temperature", Constant::Units::C, - state.dataHeatBal->ZnAirRpt(TempControlledZone(TempControlledZoneNum).ActualZoneNum).ThermOperativeTemp, + state.dataHeatBal->ZnAirRpt(tempZone.ActualZoneNum).ThermOperativeTemp, OutputProcessor::TimeStepType::Zone, OutputProcessor::StoreType::Average, - Zone(TempControlledZone(TempControlledZoneNum).ActualZoneNum).Name); + Zone(tempZone.ActualZoneNum).Name); } // TStat Objects Loop } // found thermostat referene } // loop over NumOpTempControlledZones } // NumOpTempControlledZones > 0 // Overcool dehumidificaton GetInput starts here - cCurrentModuleObject = cZControlTypes(static_cast(ZoneControlTypes::TandHStat)); - state.dataZoneCtrls->NumTempAndHumidityControlledZones = inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); + s_ipsc->cCurrentModuleObject = cZControlTypes((int)ZoneControlTypes::TandHStat); + state.dataZoneCtrls->NumTempAndHumidityControlledZones = s_ip->getNumObjectsFound(state, s_ipsc->cCurrentModuleObject); if (state.dataZoneCtrls->NumTempAndHumidityControlledZones > 0) { state.dataZoneCtrls->AnyZoneTempAndHumidityControl = true; for (int idx = 1; idx <= state.dataZoneCtrls->NumTempAndHumidityControlledZones; ++idx) { - inputProcessor->getObjectItem(state, - cCurrentModuleObject, - idx, - cAlphaArgs, - NumAlphas, - rNumericArgs, - NumNums, - IOStat, - lNumericFieldBlanks, - lAlphaFieldBlanks, - cAlphaFieldNames, - cNumericFieldNames); + s_ip->getObjectItem(state, + s_ipsc->cCurrentModuleObject, + idx, + s_ipsc->cAlphaArgs, + NumAlphas, + s_ipsc->rNumericArgs, + NumNums, + IOStat, + s_ipsc->lNumericFieldBlanks, + s_ipsc->lAlphaFieldBlanks, + s_ipsc->cAlphaFieldNames, + s_ipsc->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)}; + // find matching name of ZONECONTROL:THERMOSTAT object - found = Util::FindItem(cAlphaArgs(1), TStatObjects); + found = Util::FindItem(s_ipsc->cAlphaArgs(1), TStatObjects); if (found == 0) { // It might be in the TempControlledZones - found = Util::FindItem(cAlphaArgs(1), TempControlledZone); + found = Util::FindItem(s_ipsc->cAlphaArgs(1), state.dataZoneCtrls->TempControlledZone); if (found == 0) { // throw error ShowSevereError(state, format("{}={} invalid {} reference not found.", - cCurrentModuleObject, - cAlphaArgs(1), + s_ipsc->cCurrentModuleObject, + s_ipsc->cAlphaArgs(1), cZControlTypes(static_cast(ZoneControlTypes::TStat)))); ErrorsFound = true; } else { TempControlledZoneNum = found; - TempControlledZone(TempControlledZoneNum).DehumidifyingSched = cAlphaArgs(2); - TempControlledZone(TempControlledZoneNum).DehumidifyingSchedIndex = GetScheduleIndex(state, cAlphaArgs(2)); - if (TempControlledZone(TempControlledZoneNum).DehumidifyingSchedIndex == 0) { - ShowSevereError( - state, - format("{}=\"{} invalid {}=\"{}\" not found.", cCurrentModuleObject, cAlphaArgs(1), cAlphaFieldNames(2), cAlphaArgs(2))); + auto &tempZone = state.dataZoneCtrls->TempControlledZone(TempControlledZoneNum); + + if (s_ipsc->lAlphaFieldBlanks(2)) { + ShowSevereEmptyField(state, eoh, s_ipsc->cAlphaFieldNames(2)); + ErrorsFound = true; + } else if ((tempZone.dehumidifyingSched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2)); ErrorsFound = true; } - TempControlledZone(TempControlledZoneNum).ZoneOvercoolControl = true; - if ((Util::SameString(cAlphaArgs(3), "None"))) { - TempControlledZone(TempControlledZoneNum).ZoneOvercoolControl = false; - } - if (Util::SameString(cAlphaArgs(4), "Scheduled")) { - TempControlledZone(TempControlledZoneNum).OvercoolCntrlModeScheduled = true; + + tempZone.ZoneOvercoolControl = true; + if ((Util::SameString(s_ipsc->cAlphaArgs(3), "None"))) { + tempZone.ZoneOvercoolControl = false; } - if ((!(Util::SameString(cAlphaArgs(4), "Scheduled"))) && (!(Util::SameString(cAlphaArgs(4), "Constant")))) { - ShowSevereError(state, - format("{}={} invalid {}=\"{}\".", cCurrentModuleObject, cAlphaArgs(1), cAlphaFieldNames(4), cAlphaArgs(4))); + if (Util::SameString(s_ipsc->cAlphaArgs(4), "Scheduled")) { + tempZone.OvercoolCntrlModeScheduled = true; + } else if (!Util::SameString(s_ipsc->cAlphaArgs(4), "Constant")) { + ShowSevereInvalidKey(state, eoh, s_ipsc->cAlphaFieldNames(4), s_ipsc->cAlphaArgs(4)); ErrorsFound = true; } - TempControlledZone(TempControlledZoneNum).ZoneOvercoolConstRange = rNumericArgs(1); - TempControlledZone(TempControlledZoneNum).ZoneOvercoolRangeSchedIndex = GetScheduleIndex(state, cAlphaArgs(4)); - if ((TempControlledZone(TempControlledZoneNum).ZoneOvercoolRangeSchedIndex == 0) && - (TempControlledZone(TempControlledZoneNum).OvercoolCntrlModeScheduled)) { // throw error - ShowSevereError( - state, - format("{}={} invalid {}=\"{}\" not found.", cCurrentModuleObject, cAlphaArgs(1), cAlphaFieldNames(5), cAlphaArgs(5))); - ErrorsFound = true; - } + tempZone.ZoneOvercoolConstRange = s_ipsc->rNumericArgs(1); - // check validity of zone Overcool constant range - if ((TempControlledZone(TempControlledZoneNum).ZoneOvercoolConstRange < 0.0) && - (!(TempControlledZone(TempControlledZoneNum).OvercoolCntrlModeScheduled))) { - ShowSevereError(state, - format("{}={} invalid {}=[{:.2T}\" cannot be negative.", - cCurrentModuleObject, - cAlphaArgs(1), - cNumericFieldNames(1), - rNumericArgs(1))); - ErrorsFound = true; - } - if ((TempControlledZone(TempControlledZoneNum).ZoneOvercoolConstRange > 3.0) && - (!(TempControlledZone(TempControlledZoneNum).OvercoolCntrlModeScheduled))) { - ShowSevereError(state, - format("{}={} invalid {}=[{:.2T}\" cannot be > 3.0", - cCurrentModuleObject, - cAlphaArgs(1), - cNumericFieldNames(1), - rNumericArgs(1))); - ErrorsFound = true; - } + if (tempZone.OvercoolCntrlModeScheduled) { + if (s_ipsc->lAlphaFieldBlanks(5)) { + ShowSevereEmptyField(state, eoh, s_ipsc->cAlphaFieldNames(5)); + ErrorsFound = true; + } else if ((tempZone.zoneOvercoolRangeSched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(5))) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(5), s_ipsc->cAlphaArgs(5)); + ErrorsFound = true; + } else if (!tempZone.zoneOvercoolRangeSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 3.0)) { + Sched::ShowSevereBadMinMax(state, eoh, s_ipsc->cAlphaFieldNames(5), s_ipsc->cAlphaArgs(5), Clusive::In, 0.0, Clusive::In, 3.0); + ErrorsFound = true; + } + } else { // !tempZone.OvercoolCntrlModeScheduled + + if (tempZone.ZoneOvercoolConstRange < 0.0) { + ShowSevereBadMin(state, eoh, s_ipsc->cNumericFieldNames(1), s_ipsc->rNumericArgs(1), Clusive::In, 0.0); + ErrorsFound = true; + } else if (tempZone.ZoneOvercoolConstRange > 3.0) { + ShowSevereBadMax(state, eoh, s_ipsc->cNumericFieldNames(1), s_ipsc->rNumericArgs(1), Clusive::In, 3.0); + ErrorsFound = true; + } - // check zone Overcool range schedule min/max values. - if (TempControlledZone(TempControlledZoneNum).OvercoolCntrlModeScheduled) { - ValidZoneOvercoolRangeSched = CheckScheduleValueMinMax( - state, TempControlledZone(TempControlledZoneNum).ZoneOvercoolRangeSchedIndex, ">=", 0.0, "<=", 3.0); - if (!ValidZoneOvercoolRangeSched) { - ShowSevereError( - state, - format("{}={} invalid values {}=[{}\".", cCurrentModuleObject, cAlphaArgs(1), cAlphaFieldNames(5), cAlphaArgs(5))); - ShowContinueError(state, "..Values outside of range [0.0,3.0]."); + // check Overcool Control Ratio limits + tempZone.ZoneOvercoolControlRatio = s_ipsc->rNumericArgs(2); + if (tempZone.ZoneOvercoolControlRatio < 0.0) { + ShowSevereBadMin(state, eoh, s_ipsc->cNumericFieldNames(2), s_ipsc->rNumericArgs(2), Clusive::In, 0.0); ErrorsFound = true; } } - // check Overcool Control Ratio limits - TempControlledZone(TempControlledZoneNum).ZoneOvercoolControlRatio = rNumericArgs(2); - if (TempControlledZone(TempControlledZoneNum).ZoneOvercoolControlRatio < 0.0) { - ShowSevereError(state, - format("{}={} invalid {}=[{:.2T}\" cannot be negative.", - cCurrentModuleObject, - cAlphaArgs(2), - cNumericFieldNames(2), - rNumericArgs(2))); - ErrorsFound = true; - } } + } else { - for (Item = 1; Item <= TStatObjects(found).NumOfZones; ++Item) { + for (int Item = 1; Item <= TStatObjects(found).NumOfZones; ++Item) { TempControlledZoneNum = TStatObjects(found).TempControlledZoneStartPtr + Item - 1; - TempControlledZone(TempControlledZoneNum).DehumidifyingSched = cAlphaArgs(2); - TempControlledZone(TempControlledZoneNum).DehumidifyingSchedIndex = GetScheduleIndex(state, cAlphaArgs(2)); - if (TempControlledZone(TempControlledZoneNum).DehumidifyingSchedIndex == 0) { - ShowSevereError( - state, - format("{}=\"{} invalid {}=\"{}\" not found.", cCurrentModuleObject, cAlphaArgs(1), cAlphaFieldNames(2), cAlphaArgs(2))); + + auto &tempZone = state.dataZoneCtrls->TempControlledZone(TempControlledZoneNum); + + if (s_ipsc->lAlphaFieldBlanks(2)) { + ShowSevereEmptyField(state, eoh, s_ipsc->cAlphaFieldNames(2)); + ErrorsFound = true; + } else if ((tempZone.dehumidifyingSched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(2))) == nullptr) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2)); ErrorsFound = true; } - TempControlledZone(TempControlledZoneNum).ZoneOvercoolControl = true; - if ((Util::SameString(cAlphaArgs(3), "None"))) { - TempControlledZone(TempControlledZoneNum).ZoneOvercoolControl = false; - } - if (Util::SameString(cAlphaArgs(4), "Scheduled")) { - TempControlledZone(TempControlledZoneNum).OvercoolCntrlModeScheduled = false; - } - if (Item == 1) { - if ((!(Util::SameString(cAlphaArgs(4), "Scheduled"))) && (!(Util::SameString(cAlphaArgs(4), "Constant")))) { - ShowSevereError( - state, format("{}={} invalid {}=\"{}\".", cCurrentModuleObject, cAlphaArgs(1), cAlphaFieldNames(4), cAlphaArgs(4))); - ErrorsFound = true; - } - } - TempControlledZone(TempControlledZoneNum).ZoneOvercoolConstRange = rNumericArgs(1); - TempControlledZone(TempControlledZoneNum).ZoneOvercoolRangeSchedIndex = GetScheduleIndex(state, cAlphaArgs(6)); - if (Item == 1) { - if ((TempControlledZone(TempControlledZoneNum).ZoneOvercoolRangeSchedIndex == 0) && - (TempControlledZone(TempControlledZoneNum).OvercoolCntrlModeScheduled)) { // throw error - ShowSevereError( - state, - format( - "{}={} invalid {}=\"{}\" not found.", cCurrentModuleObject, cAlphaArgs(1), cAlphaFieldNames(5), cAlphaArgs(5))); - ErrorsFound = true; - } + + tempZone.ZoneOvercoolControl = true; + if (Util::SameString(s_ipsc->cAlphaArgs(3), "None")) { + tempZone.ZoneOvercoolControl = false; } - // check validity of zone Overcool constant range - if (Item == 1) { - if ((TempControlledZone(TempControlledZoneNum).ZoneOvercoolConstRange < 0.0) && - (!(TempControlledZone(TempControlledZoneNum).OvercoolCntrlModeScheduled))) { - ShowSevereError(state, - format("{}={} invalid {}=[{:.2T}\" cannot be negative.", - cCurrentModuleObject, - cAlphaArgs(1), - cNumericFieldNames(1), - rNumericArgs(1))); + + if (Util::SameString(s_ipsc->cAlphaArgs(4), "Scheduled")) { + tempZone.OvercoolCntrlModeScheduled = false; + } else if (!Util::SameString(s_ipsc->cAlphaArgs(4), "Constant")) { + if (Item == 1) { + ShowSevereInvalidKey(state, eoh, s_ipsc->cAlphaFieldNames(4), s_ipsc->cAlphaArgs(4)); ErrorsFound = true; } } - if (Item == 1) { - if ((TempControlledZone(TempControlledZoneNum).ZoneOvercoolConstRange > 3.0) && - (!(TempControlledZone(TempControlledZoneNum).OvercoolCntrlModeScheduled))) { - ShowSevereError(state, - format("{}={} invalid {}=[{:.2T}\" cannot > 3.0", - cCurrentModuleObject, - cAlphaArgs(1), - cNumericFieldNames(1), - rNumericArgs(1))); - ErrorsFound = true; + + tempZone.ZoneOvercoolConstRange = s_ipsc->rNumericArgs(1); + + if (tempZone.OvercoolCntrlModeScheduled) { + if (s_ipsc->lAlphaFieldBlanks(6)) { + if (Item == 1) { + ShowSevereEmptyField(state, eoh, s_ipsc->cAlphaFieldNames(6)); + ErrorsFound = true; + } + } else if ((tempZone.zoneOvercoolRangeSched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(6))) == nullptr) { + if (Item == 1) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(6), s_ipsc->cAlphaArgs(6)); + ErrorsFound = true; + } + } else if (!tempZone.zoneOvercoolRangeSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 3.0)) { + if (Item == 1) { + Sched::ShowSevereBadMinMax(state, eoh, s_ipsc->cAlphaFieldNames(6), s_ipsc->cAlphaArgs(6), Clusive::In, 0.0, Clusive::In, 3.0); + ErrorsFound = true; + } } - } - // check zone Overcool range schedule min/max values. - if (Item == 1) { - if (TempControlledZone(TempControlledZoneNum).OvercoolCntrlModeScheduled) { - ValidZoneOvercoolRangeSched = CheckScheduleValueMinMax( - state, TempControlledZone(TempControlledZoneNum).ZoneOvercoolRangeSchedIndex, ">=", 0.0, "<=", 3.0); - if (!ValidZoneOvercoolRangeSched) { - ShowSevereError( - state, - format( - "{}={} invalid values {}=[{}\".", cCurrentModuleObject, cAlphaArgs(1), cAlphaFieldNames(5), cAlphaArgs(5))); - ShowContinueError(state, "..Values outside of range [0.0,3.0]."); + } else { // tempZone.OvercoolCntrlModeScheduled + if (Item == 1) { + if (tempZone.ZoneOvercoolConstRange < 0.0) { + ShowSevereBadMin(state, eoh, s_ipsc->cNumericFieldNames(1), s_ipsc->rNumericArgs(1), Clusive::In, 0.0); + ErrorsFound = true; + } else if (tempZone.ZoneOvercoolConstRange > 3.0) { + ShowSevereBadMax(state, eoh, s_ipsc->cNumericFieldNames(1), s_ipsc->rNumericArgs(1), Clusive::In, 3.0); ErrorsFound = true; } } } - TempControlledZone(TempControlledZoneNum).ZoneOvercoolControlRatio = rNumericArgs(2); + + tempZone.ZoneOvercoolControlRatio = s_ipsc->rNumericArgs(2); // check Overcool Control Ratio limits - if (Item == 1) { - if (TempControlledZone(TempControlledZoneNum).ZoneOvercoolControlRatio < 0.0) { - ShowSevereError(state, - format("{}={} invalid {}=[{:.2T}\" cannot be negative.", - cCurrentModuleObject, - cAlphaArgs(2), - cNumericFieldNames(2), - rNumericArgs(2))); + if (tempZone.ZoneOvercoolControlRatio < 0.0) { + if (Item == 1) { + ShowSevereBadMin(state, eoh, s_ipsc->cNumericFieldNames(2), s_ipsc->rNumericArgs(2), Clusive::In, 0.0); ErrorsFound = true; } } - } // TStat Objects Loop } // found thermostat reference } // loop over NumTempAndHumidityControlledZones } // NumTempAndHumidityControlledZones > 0 // Staged thermostat control inputs start - cCurrentModuleObject = cZControlTypes(static_cast(ZoneControlTypes::StagedDual)); - NumStageControlledZones = inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); + s_ipsc->cCurrentModuleObject = cZControlTypes((int)ZoneControlTypes::StagedDual); + NumStageControlledZones = s_ip->getNumObjectsFound(state, s_ipsc->cCurrentModuleObject); if (NumStageControlledZones > 0) state.dataZoneCtrls->StagedTStatObjects.allocate(NumStageControlledZones); // Pre-scan for use of Zone lists in TStat statements (i.e. Global application of TStat) - state.dataZoneTempPredictorCorrector->NumStageCtrZone = 0; + s_ztpc->NumStageCtrZone = 0; for (Item = 1; Item <= NumStageControlledZones; ++Item) { - inputProcessor->getObjectItem(state, - cCurrentModuleObject, - Item, - cAlphaArgs, - NumAlphas, - rNumericArgs, - NumNums, - IOStat, - lNumericFieldBlanks, - lAlphaFieldBlanks, - cAlphaFieldNames, - cNumericFieldNames); - Util::IsNameEmpty(state, cAlphaArgs(1), cCurrentModuleObject, ErrorsFound); - - state.dataZoneCtrls->StagedTStatObjects(Item).Name = cAlphaArgs(1); - Item1 = Util::FindItemInList(cAlphaArgs(2), Zone); + s_ip->getObjectItem(state, + s_ipsc->cCurrentModuleObject, + Item, + s_ipsc->cAlphaArgs, + NumAlphas, + s_ipsc->rNumericArgs, + NumNums, + IOStat, + s_ipsc->lNumericFieldBlanks, + s_ipsc->lAlphaFieldBlanks, + s_ipsc->cAlphaFieldNames, + s_ipsc->cNumericFieldNames); + Util::IsNameEmpty(state, s_ipsc->cAlphaArgs(1), s_ipsc->cCurrentModuleObject, ErrorsFound); + + state.dataZoneCtrls->StagedTStatObjects(Item).Name = s_ipsc->cAlphaArgs(1); + Item1 = Util::FindItemInList(s_ipsc->cAlphaArgs(2), Zone); ZLItem = 0; - if (Item1 == 0 && state.dataHeatBal->NumOfZoneLists > 0) ZLItem = Util::FindItemInList(cAlphaArgs(2), ZoneList); + if (Item1 == 0 && state.dataHeatBal->NumOfZoneLists > 0) ZLItem = Util::FindItemInList(s_ipsc->cAlphaArgs(2), ZoneList); if (Item1 > 0) { - state.dataZoneCtrls->StagedTStatObjects(Item).StageControlledZoneStartPtr = state.dataZoneTempPredictorCorrector->NumStageCtrZone + 1; - ++state.dataZoneTempPredictorCorrector->NumStageCtrZone; + state.dataZoneCtrls->StagedTStatObjects(Item).StageControlledZoneStartPtr = s_ztpc->NumStageCtrZone + 1; + ++s_ztpc->NumStageCtrZone; state.dataZoneCtrls->StagedTStatObjects(Item).NumOfZones = 1; state.dataZoneCtrls->StagedTStatObjects(Item).ZoneListActive = false; state.dataZoneCtrls->StagedTStatObjects(Item).ZoneOrZoneListPtr = Item1; } else if (ZLItem > 0) { - state.dataZoneCtrls->StagedTStatObjects(Item).TempControlledZoneStartPtr = state.dataZoneTempPredictorCorrector->NumStageCtrZone + 1; - state.dataZoneTempPredictorCorrector->NumStageCtrZone += ZoneList(ZLItem).NumOfZones; + state.dataZoneCtrls->StagedTStatObjects(Item).TempControlledZoneStartPtr = s_ztpc->NumStageCtrZone + 1; + s_ztpc->NumStageCtrZone += ZoneList(ZLItem).NumOfZones; state.dataZoneCtrls->StagedTStatObjects(Item).NumOfZones = ZoneList(ZLItem).NumOfZones; state.dataZoneCtrls->StagedTStatObjects(Item).ZoneListActive = true; state.dataZoneCtrls->StagedTStatObjects(Item).ZoneOrZoneListPtr = ZLItem; } else { ShowSevereError( - state, format("{}=\"{}\" invalid {}=\"{}\" not found.", cCurrentModuleObject, cAlphaArgs(1), cAlphaFieldNames(2), cAlphaArgs(2))); + state, format("{}=\"{}\" invalid {}=\"{}\" not found.", s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1), s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2))); ErrorsFound = true; } } if (ErrorsFound) { - ShowSevereError(state, format("GetStagedDualSetpoint: Errors with invalid names in {} objects.", cCurrentModuleObject)); + ShowSevereError(state, format("GetStagedDualSetpoint: Errors with invalid names in {} objects.", s_ipsc->cCurrentModuleObject)); ShowContinueError(state, "...These will not be read in. Other errors may occur."); - state.dataZoneTempPredictorCorrector->NumStageCtrZone = 0; + s_ztpc->NumStageCtrZone = 0; } - if (state.dataZoneTempPredictorCorrector->NumStageCtrZone > 0) { - StageControlledZone.allocate(state.dataZoneTempPredictorCorrector->NumStageCtrZone); + if (s_ztpc->NumStageCtrZone > 0) { + state.dataZoneCtrls->StageControlledZone.allocate(s_ztpc->NumStageCtrZone); state.dataZoneCtrls->StageZoneLogic.dimension(NumOfZones, false); StageControlledZoneNum = 0; for (Item = 1; Item <= NumStageControlledZones; ++Item) { - inputProcessor->getObjectItem(state, - cCurrentModuleObject, - Item, - cAlphaArgs, - NumAlphas, - rNumericArgs, - NumNums, - IOStat, - lNumericFieldBlanks, - lAlphaFieldBlanks, - cAlphaFieldNames, - cNumericFieldNames); + s_ip->getObjectItem(state, + s_ipsc->cCurrentModuleObject, + Item, + s_ipsc->cAlphaArgs, + NumAlphas, + s_ipsc->rNumericArgs, + NumNums, + IOStat, + s_ipsc->lNumericFieldBlanks, + s_ipsc->lAlphaFieldBlanks, + s_ipsc->cAlphaFieldNames, + s_ipsc->cNumericFieldNames); + + ErrorObjectHeader eoh{routineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)}; + for (Item1 = 1; Item1 <= state.dataZoneCtrls->StagedTStatObjects(Item).NumOfZones; ++Item1) { ++StageControlledZoneNum; + + auto &stageZone = state.dataZoneCtrls->StageControlledZone(StageControlledZoneNum); + if (state.dataZoneCtrls->StagedTStatObjects(Item).ZoneListActive) { - cAlphaArgs(2) = + s_ipsc->cAlphaArgs(2) = state.dataHeatBal->Zone(ZoneList(state.dataZoneCtrls->StagedTStatObjects(Item).ZoneOrZoneListPtr).Zone(Item1)).Name; } int ZoneAssigned = Util::FindItemInList( - cAlphaArgs(2), StageControlledZone, &DataZoneControls::ZoneStagedControls::ZoneName, StageControlledZoneNum - 1); + s_ipsc->cAlphaArgs(2), state.dataZoneCtrls->StageControlledZone, &DataZoneControls::ZoneStagedControls::ZoneName, StageControlledZoneNum - 1); if (ZoneAssigned == 0) { - StageControlledZone(StageControlledZoneNum).ZoneName = cAlphaArgs(2); - StageControlledZone(StageControlledZoneNum).ActualZoneNum = Util::FindItemInList(cAlphaArgs(2), Zone); - if (StageControlledZone(StageControlledZoneNum).ActualZoneNum == 0) { - ShowSevereError( - state, - format( - "{}=\"{}\" invalid {}=\"{}\" not found.", cCurrentModuleObject, cAlphaArgs(1), cAlphaFieldNames(2), cAlphaArgs(2))); + stageZone.ZoneName = s_ipsc->cAlphaArgs(2); + if ((stageZone.ActualZoneNum = Util::FindItemInList(s_ipsc->cAlphaArgs(2), Zone)) == 0) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2)); ErrorsFound = true; } else { // Zone(StageControlledZone(StageControlledZoneNum)%ActualZoneNum)%StageControlledZoneIndex = // StageControlledZoneNum } - state.dataZoneCtrls->StageZoneLogic(StageControlledZone(StageControlledZoneNum).ActualZoneNum) = true; + state.dataZoneCtrls->StageZoneLogic(stageZone.ActualZoneNum) = true; } else { - StageControlledZone(StageControlledZoneNum).ZoneName = cAlphaArgs(2); // for continuity + stageZone.ZoneName = s_ipsc->cAlphaArgs(2); // for continuity ShowSevereError(state, format("{}=\"{}\" invalid {}=\"{}\" zone previously assigned.", - cCurrentModuleObject, - cAlphaArgs(1), - cAlphaFieldNames(2), - cAlphaArgs(2))); - ShowContinueError(state, format("...Zone was previously assigned to Thermostat=\"{}\".", StageControlledZone(ZoneAssigned).Name)); + s_ipsc->cCurrentModuleObject, + s_ipsc->cAlphaArgs(1), + s_ipsc->cAlphaFieldNames(2), + s_ipsc->cAlphaArgs(2))); + ShowContinueError(state, format("...Zone was previously assigned to Setpt=\"{}\".", state.dataZoneCtrls->StageControlledZone(ZoneAssigned).Name)); ErrorsFound = true; continue; } if (!state.dataZoneCtrls->StagedTStatObjects(Item).ZoneListActive) { - StageControlledZone(StageControlledZoneNum).Name = cAlphaArgs(1); + stageZone.Name = s_ipsc->cAlphaArgs(1); } else { CheckCreatedZoneItemName( state, RoutineName, - cCurrentModuleObject, + s_ipsc->cCurrentModuleObject, state.dataHeatBal->Zone(ZoneList(state.dataZoneCtrls->StagedTStatObjects(Item).ZoneOrZoneListPtr).Zone(Item1)).Name, ZoneList(state.dataZoneCtrls->StagedTStatObjects(Item).ZoneOrZoneListPtr).MaxZoneNameLength, state.dataZoneCtrls->StagedTStatObjects(Item).Name, - StageControlledZone, + state.dataZoneCtrls->StageControlledZone, StageControlledZoneNum - 1, - StageControlledZone(StageControlledZoneNum).Name, + stageZone.Name, errFlag); if (errFlag) ErrorsFound = true; } - StageControlledZone(StageControlledZoneNum).NumOfHeatStages = rNumericArgs(1); - if (rNumericArgs(1) < 1 || rNumericArgs(1) > 4) { - ShowSevereError( - state, - format("{}=\"{}\" invalid range {}=\"{:.0R}\"", cCurrentModuleObject, cAlphaArgs(1), cNumericFieldNames(1), rNumericArgs(1))); - ShowContinueError(state, "..contains values outside of range [1,4]."); + stageZone.NumOfHeatStages = s_ipsc->rNumericArgs(1); + if (s_ipsc->rNumericArgs(1) < 1 || s_ipsc->rNumericArgs(1) > 4) { + ShowSevereBadMinMax(state, eoh, s_ipsc->cNumericFieldNames(1), s_ipsc->rNumericArgs(1), Clusive::In, 1, Clusive::In, 4); ErrorsFound = true; } - StageControlledZone(StageControlledZoneNum).HeatSetBaseSchedName = cAlphaArgs(3); - StageControlledZone(StageControlledZoneNum).HSBchedIndex = GetScheduleIndex(state, cAlphaArgs(3)); - if (Item1 == 1) { // only show error on first of several if zone list - if (StageControlledZone(StageControlledZoneNum).HSBchedIndex == 0) { - ShowSevereError( - state, - format( - "{}=\"{}\" invalid {}=\"{}\" not found.", cCurrentModuleObject, cAlphaArgs(1), cAlphaFieldNames(3), cAlphaArgs(3))); + if (s_ipsc->lAlphaFieldBlanks(3)) { + if (Item1 == 1) { + ShowSevereEmptyField(state, eoh, s_ipsc->cAlphaFieldNames(3)); + ErrorsFound = true; + } + } else if ((stageZone.heatSetptBaseSched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(3))) == nullptr) { + if (Item1 == 1) { + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(3), s_ipsc->cAlphaArgs(3)); ErrorsFound = true; } } - StageControlledZone(StageControlledZoneNum).HeatThroRange = rNumericArgs(2); - if (rNumericArgs(1) < 0.0) { - ShowSevereError(state, - format("{}=\"{}\" negative value is found at {}=\"{:.1R}\"", - cAlphaArgs(1), - cCurrentModuleObject, - cNumericFieldNames(2), - rNumericArgs(2))); - ShowContinueError(state, ".. The minimum value is 0."); + stageZone.HeatThroRange = s_ipsc->rNumericArgs(2); + if (s_ipsc->rNumericArgs(1) < 0.0) { + ShowSevereBadMin(state, eoh, s_ipsc->cNumericFieldNames(2), s_ipsc->rNumericArgs(2), Clusive::In, 0.0); ErrorsFound = true; } - if (StageControlledZone(StageControlledZoneNum).NumOfHeatStages > 0) { - StageControlledZone(StageControlledZoneNum).HeatTOffset.allocate(StageControlledZone(StageControlledZoneNum).NumOfHeatStages); - for (i = 1; i <= StageControlledZone(StageControlledZoneNum).NumOfHeatStages; ++i) { - StageControlledZone(StageControlledZoneNum).HeatTOffset(i) = rNumericArgs(2 + i); - if (rNumericArgs(2 + i) > 0.0) { - ShowSevereError(state, - format("{}=\"{}\" positive value is found at {}", - cCurrentModuleObject, - cAlphaArgs(1), - format("{}=\"{:.1R}\"", cNumericFieldNames(2 + i), rNumericArgs(2 + i)))); - ShowContinueError(state, ".. The maximum value is 0."); + if (stageZone.NumOfHeatStages > 0) { + stageZone.HeatTOffset.allocate(stageZone.NumOfHeatStages); + for (i = 1; i <= stageZone.NumOfHeatStages; ++i) { + stageZone.HeatTOffset(i) = s_ipsc->rNumericArgs(2 + i); + if (s_ipsc->lNumericFieldBlanks(2 + i)) { + ShowSevereEmptyField(state, eoh, s_ipsc->cNumericFieldNames(2 + i)); ErrorsFound = true; - } - if (lNumericFieldBlanks(2 + i)) { - ShowSevereError(state, - format("{} object ={}. The input of {} is required, but a blank is found.", - cCurrentModuleObject, - cAlphaArgs(1), - cNumericFieldNames(2 + i))); + } else if (s_ipsc->rNumericArgs(2 + i) > 0.0) { + ShowSevereBadMax(state, eoh, s_ipsc->cNumericFieldNames(2 + i), s_ipsc->rNumericArgs(2 + i), Clusive::In, 0.0); ErrorsFound = true; } + if (i > 1) { - if (rNumericArgs(2 + i) >= rNumericArgs(1 + i)) { - ShowSevereError(state, - format(R"({}="{}" The value at {}="{:.1R}" has to be less than )", - cCurrentModuleObject, - cAlphaArgs(1), - cNumericFieldNames(2 + i), - rNumericArgs(2 + i))); - ShowContinueError(state, format("{}=\"{:.1R}", cNumericFieldNames(1 + i), rNumericArgs(1 + i))); + if (s_ipsc->rNumericArgs(2 + i) >= s_ipsc->rNumericArgs(1 + i)) { + ShowSevereCustom(state, eoh, format("{} = {:.1R} must be less than than {}={:.1R}", + s_ipsc->cNumericFieldNames(2 + i), s_ipsc->rNumericArgs(2 + i), + s_ipsc->cNumericFieldNames(1 + i), s_ipsc->rNumericArgs(1 + i))); ErrorsFound = true; } } } } - StageControlledZone(StageControlledZoneNum).NumOfCoolStages = rNumericArgs(7); - if (rNumericArgs(7) < 1 || rNumericArgs(7) > 4) { - ShowSevereError( - state, - format("{}=\"{}\" invalid range {}=\"{:.0R}\"", cCurrentModuleObject, cAlphaArgs(1), cNumericFieldNames(7), rNumericArgs(7))); - ShowContinueError(state, "..contains values outside of range [1,4]."); + stageZone.NumOfCoolStages = s_ipsc->rNumericArgs(7); + if (s_ipsc->rNumericArgs(7) < 1 || s_ipsc->rNumericArgs(7) > 4) { + ShowSevereBadMinMax(state, eoh, s_ipsc->cNumericFieldNames(7), s_ipsc->rNumericArgs(7), Clusive::In, 1, Clusive::In, 4); ErrorsFound = true; } - StageControlledZone(StageControlledZoneNum).CoolSetBaseSchedName = cAlphaArgs(4); - StageControlledZone(StageControlledZoneNum).CSBchedIndex = GetScheduleIndex(state, cAlphaArgs(4)); - if (Item1 == 1) { // only show error on first of several if zone list - if (StageControlledZone(StageControlledZoneNum).CSBchedIndex == 0) { - ShowSevereError( - state, - format( - "{}=\"{}\" invalid {}=\"{}\" not found.", cCurrentModuleObject, cAlphaArgs(1), cAlphaFieldNames(4), cAlphaArgs(4))); + if (s_ipsc->lAlphaFieldBlanks(4)) { + if (Item1 == 1) { + ShowSevereEmptyField(state, eoh, s_ipsc->cAlphaFieldNames(4)); + ErrorsFound = true; + } + } else if ((stageZone.coolSetptBaseSched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(4))) == nullptr) { + if (Item1 == 1) { // only show error on first of several if zone list + ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(4), s_ipsc->cAlphaArgs(4)); ErrorsFound = true; } } - StageControlledZone(StageControlledZoneNum).CoolThroRange = rNumericArgs(8); - if (rNumericArgs(8) < 0.0) { - ShowSevereError(state, - format("{}=\"{}\" negative value is found at {}=\"{:.1R}\"", - cCurrentModuleObject, - cAlphaArgs(1), - cNumericFieldNames(8), - rNumericArgs(8))); - ShowContinueError(state, ".. The minumum value is 0."); + stageZone.CoolThroRange = s_ipsc->rNumericArgs(8); + if (s_ipsc->rNumericArgs(8) < 0.0) { + ShowSevereBadMin(state, eoh, s_ipsc->cNumericFieldNames(8), s_ipsc->rNumericArgs(8), Clusive::In, 0.0); ErrorsFound = true; } - if (StageControlledZone(StageControlledZoneNum).NumOfCoolStages > 0) { - StageControlledZone(StageControlledZoneNum).CoolTOffset.allocate(StageControlledZone(StageControlledZoneNum).NumOfCoolStages); - for (i = 1; i <= StageControlledZone(StageControlledZoneNum).NumOfCoolStages; ++i) { - StageControlledZone(StageControlledZoneNum).CoolTOffset(i) = rNumericArgs(8 + i); - if (rNumericArgs(8 + i) < 0.0) { - ShowSevereError(state, - format("{}=\"{}\" negative value is found at {}=\"{:.1R}\"", - cCurrentModuleObject, - cAlphaArgs(1), - cNumericFieldNames(8 + i), - rNumericArgs(8 + i))); - ShowContinueError(state, ".. The minimum value is 0."); + if (stageZone.NumOfCoolStages > 0) { + stageZone.CoolTOffset.allocate(stageZone.NumOfCoolStages); + for (i = 1; i <= stageZone.NumOfCoolStages; ++i) { + stageZone.CoolTOffset(i) = s_ipsc->rNumericArgs(8 + i); + if (s_ipsc->lNumericFieldBlanks(8 + i)) { + ShowSevereEmptyField(state, eoh, s_ipsc->cNumericFieldNames(8 + i)); ErrorsFound = true; - } - if (lNumericFieldBlanks(8 + i)) { - ShowSevereError(state, - format("{} object ={}. The input of {} is required, but a blank is found.", - cCurrentModuleObject, - cAlphaArgs(1), - cNumericFieldNames(8 + i))); + } else if (s_ipsc->rNumericArgs(8 + i) < 0.0) { + ShowSevereBadMin(state, eoh, s_ipsc->cNumericFieldNames(8 + i), s_ipsc->rNumericArgs(8 + i), Clusive::In, 0.0); ErrorsFound = true; } - if (i > 1) { - if (rNumericArgs(8 + i) <= rNumericArgs(7 + i)) { - ShowSevereError(state, - format("{}=\"{}\" The value at {}=\"{:.1R}\" has to be greater than ", - cCurrentModuleObject, - cAlphaArgs(1), - cNumericFieldNames(8 + i), - rNumericArgs(8 + i))); - ShowContinueError(state, format("{}=\"{:.1R}", cNumericFieldNames(7 + i), rNumericArgs(7 + i))); - ErrorsFound = true; - } + + if (i > 1 && s_ipsc->rNumericArgs(8 + i) <= s_ipsc->rNumericArgs(7 + i)) { + ShowSevereCustom(state, eoh, format("{} = {:.1R} must be greater than {} = {:.1R}", + s_ipsc->cNumericFieldNames(8 + i), s_ipsc->rNumericArgs(8 + i), + s_ipsc->cNumericFieldNames(7 + i), s_ipsc->rNumericArgs(7 + i))); + ErrorsFound = true; } } } } } // loop over NumStageControlledZones - if ((inputProcessor->getNumObjectsFound(state, "AirLoopHVAC:UnitaryHeatPump:AirToAir:MultiSpeed") == 0) && - (inputProcessor->getNumObjectsFound(state, "AirLoopHVAC:UnitarySystem") == 0) && - (inputProcessor->getNumObjectsFound(state, "SetpointManager:SingleZone:OneStageCooling") == 0) && - (inputProcessor->getNumObjectsFound(state, "SetpointManager:SingleZone:OneStageHeating") == 0)) { - ShowWarningError(state, format("{} is applicable to only selected HVAC objects which are missing from input.", cCurrentModuleObject)); + + + if ((s_ip->getNumObjectsFound(state, "AirLoopHVAC:UnitaryHeatPump:AirToAir:MultiSpeed") == 0) && + (s_ip->getNumObjectsFound(state, "AirLoopHVAC:UnitarySystem") == 0) && + (s_ip->getNumObjectsFound(state, "SetpointManager:SingleZone:OneStageCooling") == 0) && + (s_ip->getNumObjectsFound(state, "SetpointManager:SingleZone:OneStageHeating") == 0)) { + ShowWarningError(state, format("{} is applicable to only selected HVAC objects which are missing from input.", s_ipsc->cCurrentModuleObject)); ShowContinueError(state, "Model should include one or more of the following objects: "); ShowContinueError(state, "AirLoopHVAC:UnitaryHeatPump:AirToAir:MultiSpeed, AirLoopHVAC:UnitarySystem, "); ShowContinueError( @@ -2708,9 +2171,8 @@ void CalculateAdaptiveComfortSetPointSchl(EnergyPlusData &state, Array1D int constexpr summerDesignDayTypeIndex(9); Real64 GrossApproxAvgDryBulbDesignDay(0.0); - auto &AdapComfortDailySetPointSchedule = state.dataZoneTempPredictorCorrector->AdapComfortDailySetPointSchedule; - auto &AdapComfortSetPointSummerDesDay = state.dataZoneTempPredictorCorrector->AdapComfortSetPointSummerDesDay; - + auto &s_ztpc = state.dataZoneTempPredictorCorrector; + for (size_t i = 1; i <= state.dataWeather->DesDayInput.size(); i++) { // Summer design day if (state.dataWeather->DesDayInput(i).DayType == summerDesignDayTypeIndex) { @@ -2718,54 +2180,54 @@ void CalculateAdaptiveComfortSetPointSchl(EnergyPlusData &state, Array1D (state.dataWeather->DesDayInput(i).MaxDryBulb - state.dataWeather->DesDayInput(i).DailyDBRange)) / 2.0; if (GrossApproxAvgDryBulbDesignDay > 10 && GrossApproxAvgDryBulbDesignDay < 33.5) { - AdapComfortSetPointSummerDesDay[0] = 0.31 * GrossApproxAvgDryBulbDesignDay + 17.8; - AdapComfortSetPointSummerDesDay[1] = 0.31 * GrossApproxAvgDryBulbDesignDay + 20.3; - AdapComfortSetPointSummerDesDay[2] = 0.31 * GrossApproxAvgDryBulbDesignDay + 21.3; + s_ztpc->AdapComfortSetPointSummerDesDay[0] = 0.31 * GrossApproxAvgDryBulbDesignDay + 17.8; + s_ztpc->AdapComfortSetPointSummerDesDay[1] = 0.31 * GrossApproxAvgDryBulbDesignDay + 20.3; + s_ztpc->AdapComfortSetPointSummerDesDay[2] = 0.31 * GrossApproxAvgDryBulbDesignDay + 21.3; } if (GrossApproxAvgDryBulbDesignDay > 10 && GrossApproxAvgDryBulbDesignDay < 30) { - AdapComfortSetPointSummerDesDay[3] = 0.33 * GrossApproxAvgDryBulbDesignDay + 18.8; - AdapComfortSetPointSummerDesDay[4] = 0.33 * GrossApproxAvgDryBulbDesignDay + 20.8; - ; - AdapComfortSetPointSummerDesDay[5] = 0.33 * GrossApproxAvgDryBulbDesignDay + 21.8; + s_ztpc->AdapComfortSetPointSummerDesDay[3] = 0.33 * GrossApproxAvgDryBulbDesignDay + 18.8; + s_ztpc->AdapComfortSetPointSummerDesDay[4] = 0.33 * GrossApproxAvgDryBulbDesignDay + 20.8; + ; // What is this? + s_ztpc->AdapComfortSetPointSummerDesDay[5] = 0.33 * GrossApproxAvgDryBulbDesignDay + 21.8; ; - AdapComfortSetPointSummerDesDay[6] = 0.33 * GrossApproxAvgDryBulbDesignDay + 22.8; + s_ztpc->AdapComfortSetPointSummerDesDay[6] = 0.33 * GrossApproxAvgDryBulbDesignDay + 22.8; ; } } } - AdapComfortDailySetPointSchedule.ThermalComfortAdaptiveASH55_Central.allocate(state.dataWeather->NumDaysInYear); - AdapComfortDailySetPointSchedule.ThermalComfortAdaptiveASH55_Upper_90.allocate(state.dataWeather->NumDaysInYear); - AdapComfortDailySetPointSchedule.ThermalComfortAdaptiveASH55_Upper_80.allocate(state.dataWeather->NumDaysInYear); - AdapComfortDailySetPointSchedule.ThermalComfortAdaptiveCEN15251_Central.allocate(state.dataWeather->NumDaysInYear); - AdapComfortDailySetPointSchedule.ThermalComfortAdaptiveCEN15251_Upper_I.allocate(state.dataWeather->NumDaysInYear); - AdapComfortDailySetPointSchedule.ThermalComfortAdaptiveCEN15251_Upper_II.allocate(state.dataWeather->NumDaysInYear); - AdapComfortDailySetPointSchedule.ThermalComfortAdaptiveCEN15251_Upper_III.allocate(state.dataWeather->NumDaysInYear); + s_ztpc->AdapComfortDailySetPointSchedule.ThermalComfortAdaptiveASH55_Central.allocate(state.dataWeather->NumDaysInYear); + s_ztpc->AdapComfortDailySetPointSchedule.ThermalComfortAdaptiveASH55_Upper_90.allocate(state.dataWeather->NumDaysInYear); + s_ztpc->AdapComfortDailySetPointSchedule.ThermalComfortAdaptiveASH55_Upper_80.allocate(state.dataWeather->NumDaysInYear); + s_ztpc->AdapComfortDailySetPointSchedule.ThermalComfortAdaptiveCEN15251_Central.allocate(state.dataWeather->NumDaysInYear); + s_ztpc->AdapComfortDailySetPointSchedule.ThermalComfortAdaptiveCEN15251_Upper_I.allocate(state.dataWeather->NumDaysInYear); + s_ztpc->AdapComfortDailySetPointSchedule.ThermalComfortAdaptiveCEN15251_Upper_II.allocate(state.dataWeather->NumDaysInYear); + s_ztpc->AdapComfortDailySetPointSchedule.ThermalComfortAdaptiveCEN15251_Upper_III.allocate(state.dataWeather->NumDaysInYear); // Calculate the set points based on different models, set flag as -1 when running average temperature is not in the range. for (int day = 1; day <= state.dataWeather->NumDaysInYear; day++) { if (runningAverageASH(day) > 10 && runningAverageASH(day) < 33.5) { - AdapComfortDailySetPointSchedule.ThermalComfortAdaptiveASH55_Central(day) = 0.31 * runningAverageASH(day) + 17.8; - AdapComfortDailySetPointSchedule.ThermalComfortAdaptiveASH55_Upper_90(day) = 0.31 * runningAverageASH(day) + 20.3; - AdapComfortDailySetPointSchedule.ThermalComfortAdaptiveASH55_Upper_80(day) = 0.31 * runningAverageASH(day) + 21.3; + s_ztpc->AdapComfortDailySetPointSchedule.ThermalComfortAdaptiveASH55_Central(day) = 0.31 * runningAverageASH(day) + 17.8; + s_ztpc->AdapComfortDailySetPointSchedule.ThermalComfortAdaptiveASH55_Upper_90(day) = 0.31 * runningAverageASH(day) + 20.3; + s_ztpc->AdapComfortDailySetPointSchedule.ThermalComfortAdaptiveASH55_Upper_80(day) = 0.31 * runningAverageASH(day) + 21.3; } else { - AdapComfortDailySetPointSchedule.ThermalComfortAdaptiveASH55_Central(day) = -1; - AdapComfortDailySetPointSchedule.ThermalComfortAdaptiveASH55_Upper_90(day) = -1; - AdapComfortDailySetPointSchedule.ThermalComfortAdaptiveASH55_Upper_80(day) = -1; + s_ztpc->AdapComfortDailySetPointSchedule.ThermalComfortAdaptiveASH55_Central(day) = -1; + s_ztpc->AdapComfortDailySetPointSchedule.ThermalComfortAdaptiveASH55_Upper_90(day) = -1; + s_ztpc->AdapComfortDailySetPointSchedule.ThermalComfortAdaptiveASH55_Upper_80(day) = -1; } if (runningAverageCEN(day) > 10 && runningAverageCEN(day) < 30) { - AdapComfortDailySetPointSchedule.ThermalComfortAdaptiveCEN15251_Central(day) = 0.33 * runningAverageCEN(day) + 18.8; - AdapComfortDailySetPointSchedule.ThermalComfortAdaptiveCEN15251_Upper_I(day) = 0.33 * runningAverageCEN(day) + 20.8; - AdapComfortDailySetPointSchedule.ThermalComfortAdaptiveCEN15251_Upper_II(day) = 0.33 * runningAverageCEN(day) + 21.8; - AdapComfortDailySetPointSchedule.ThermalComfortAdaptiveCEN15251_Upper_III(day) = 0.33 * runningAverageCEN(day) + 22.8; + s_ztpc->AdapComfortDailySetPointSchedule.ThermalComfortAdaptiveCEN15251_Central(day) = 0.33 * runningAverageCEN(day) + 18.8; + s_ztpc->AdapComfortDailySetPointSchedule.ThermalComfortAdaptiveCEN15251_Upper_I(day) = 0.33 * runningAverageCEN(day) + 20.8; + s_ztpc->AdapComfortDailySetPointSchedule.ThermalComfortAdaptiveCEN15251_Upper_II(day) = 0.33 * runningAverageCEN(day) + 21.8; + s_ztpc->AdapComfortDailySetPointSchedule.ThermalComfortAdaptiveCEN15251_Upper_III(day) = 0.33 * runningAverageCEN(day) + 22.8; } else { - AdapComfortDailySetPointSchedule.ThermalComfortAdaptiveCEN15251_Central(day) = -1; - AdapComfortDailySetPointSchedule.ThermalComfortAdaptiveCEN15251_Upper_I(day) = -1; - AdapComfortDailySetPointSchedule.ThermalComfortAdaptiveCEN15251_Upper_II(day) = -1; - AdapComfortDailySetPointSchedule.ThermalComfortAdaptiveCEN15251_Upper_III(day) = -1; + s_ztpc->AdapComfortDailySetPointSchedule.ThermalComfortAdaptiveCEN15251_Central(day) = -1; + s_ztpc->AdapComfortDailySetPointSchedule.ThermalComfortAdaptiveCEN15251_Upper_I(day) = -1; + s_ztpc->AdapComfortDailySetPointSchedule.ThermalComfortAdaptiveCEN15251_Upper_II(day) = -1; + s_ztpc->AdapComfortDailySetPointSchedule.ThermalComfortAdaptiveCEN15251_Upper_III(day) = -1; } } - AdapComfortDailySetPointSchedule.initialized = true; + s_ztpc->AdapComfortDailySetPointSchedule.initialized = true; } void InitZoneAirSetPoints(EnergyPlusData &state) @@ -2791,29 +2253,22 @@ void InitZoneAirSetPoints(EnergyPlusData &state) bool FirstSurfFlag; int TRefFlag; // Flag for Reference Temperature process in Zones + auto &s_ztpc = state.dataZoneTempPredictorCorrector; + auto &s_hbfs = state.dataHeatBalFanSys; + auto &ZoneList = state.dataHeatBal->ZoneList; - auto &TempControlledZone = state.dataZoneCtrls->TempControlledZone; - auto &TempZoneThermostatSetPoint = state.dataHeatBalFanSys->TempZoneThermostatSetPoint; auto &TempControlType = state.dataHeatBalFanSys->TempControlType; auto &TempControlTypeRpt = state.dataHeatBalFanSys->TempControlTypeRpt; - auto &ComfortControlledZone = state.dataZoneCtrls->ComfortControlledZone; - auto &ZoneThermostatSetPointLo = state.dataHeatBalFanSys->ZoneThermostatSetPointLo; - auto &ZoneThermostatSetPointHi = state.dataHeatBalFanSys->ZoneThermostatSetPointHi; int NumOfZones = state.dataGlobal->NumOfZones; - if (state.dataZoneTempPredictorCorrector->InitZoneAirSetPointsOneTimeFlag) { - TempZoneThermostatSetPoint.dimension(NumOfZones, 0.0); - state.dataHeatBalFanSys->AdapComfortCoolingSetPoint.dimension(NumOfZones, 0.0); - ZoneThermostatSetPointHi.dimension(NumOfZones, 0.0); - ZoneThermostatSetPointLo.dimension(NumOfZones, 0.0); - state.dataHeatBalFanSys->ZoneThermostatSetPointHiAver.dimension(NumOfZones, 0.0); - state.dataHeatBalFanSys->ZoneThermostatSetPointLoAver.dimension(NumOfZones, 0.0); + if (s_ztpc->InitZoneAirSetPointsOneTimeFlag) { + s_hbfs->zoneTstatSetpts.allocate(NumOfZones); state.dataHeatBalFanSys->LoadCorrectionFactor.dimension(NumOfZones, 0.0); - TempControlType.dimension(NumOfZones, HVAC::ThermostatType::Uncontrolled); + TempControlType.dimension(NumOfZones, HVAC::SetptType::Uncontrolled); TempControlTypeRpt.dimension(NumOfZones, 0); if (state.dataZoneCtrls->NumComfortControlledZones > 0) { - state.dataHeatBalFanSys->ComfortControlType.dimension(NumOfZones, HVAC::ThermostatType::Uncontrolled); + state.dataHeatBalFanSys->ComfortControlType.dimension(NumOfZones, HVAC::SetptType::Uncontrolled); state.dataHeatBalFanSys->ComfortControlTypeRpt.dimension(NumOfZones, 0); state.dataHeatBalFanSys->ZoneComfortControlsFanger.allocate(NumOfZones); } @@ -2870,10 +2325,10 @@ void InitZoneAirSetPoints(EnergyPlusData &state) // CurrentModuleObject='Zone' for (int zoneNum = 1; zoneNum <= NumOfZones; ++zoneNum) { auto &thisZone = state.dataHeatBal->Zone(zoneNum); - state.dataZoneTempPredictorCorrector->zoneHeatBalance(zoneNum).setUpOutputVars(state, DataStringGlobals::zonePrefix, thisZone.Name); + s_ztpc->zoneHeatBalance(zoneNum).setUpOutputVars(state, DataStringGlobals::zonePrefix, thisZone.Name); if (state.dataHeatBal->doSpaceHeatBalanceSimulation) { for (int spaceNum : state.dataHeatBal->Zone(zoneNum).spaceIndexes) { - state.dataZoneTempPredictorCorrector->spaceHeatBalance(spaceNum).setUpOutputVars( + s_ztpc->spaceHeatBalance(spaceNum).setUpOutputVars( state, DataStringGlobals::spacePrefix, state.dataHeatBal->space(spaceNum).Name); } } @@ -2922,21 +2377,21 @@ void InitZoneAirSetPoints(EnergyPlusData &state) SetupOutputVariable(state, "Zone Thermostat Heating Setpoint Temperature", Constant::Units::C, - ZoneThermostatSetPointLo(zoneNum), + s_hbfs->zoneTstatSetpts(zoneNum).setptLo, OutputProcessor::TimeStepType::System, OutputProcessor::StoreType::Average, thisZone.Name); SetupOutputVariable(state, "Zone Thermostat Cooling Setpoint Temperature", Constant::Units::C, - ZoneThermostatSetPointHi(zoneNum), + s_hbfs->zoneTstatSetpts(zoneNum).setptHi, OutputProcessor::TimeStepType::System, OutputProcessor::StoreType::Average, thisZone.Name); SetupOutputVariable(state, "Zone Adaptive Comfort Operative Temperature Set Point", Constant::Units::C, - state.dataHeatBalFanSys->AdapComfortCoolingSetPoint(zoneNum), + s_hbfs->zoneTstatSetpts(zoneNum).setptAdapComfortCool, OutputProcessor::TimeStepType::Zone, OutputProcessor::StoreType::Average, thisZone.Name); @@ -2953,7 +2408,7 @@ void InitZoneAirSetPoints(EnergyPlusData &state) if (state.dataZoneCtrls->NumComfortControlledZones > 0) { // CurrentModuleObject='ZoneControl:Thermostat:ThermalComfort' for (int Loop = 1; Loop <= state.dataZoneCtrls->NumComfortControlledZones; ++Loop) { - int zoneNum = ComfortControlledZone(Loop).ActualZoneNum; + int zoneNum = state.dataZoneCtrls->ComfortControlledZone(Loop).ActualZoneNum; auto &thisZone = state.dataHeatBal->Zone(zoneNum); SetupOutputVariable(state, "Zone Thermal Comfort Control Type", @@ -3043,26 +2498,25 @@ void InitZoneAirSetPoints(EnergyPlusData &state) state.dataHeatBal->ZoneGroup(Loop).Name); } // Loop - state.dataZoneTempPredictorCorrector->InitZoneAirSetPointsOneTimeFlag = false; + s_ztpc->InitZoneAirSetPointsOneTimeFlag = false; } // Do the Begin Environment initializations - if (state.dataZoneTempPredictorCorrector->MyEnvrnFlag && state.dataGlobal->BeginEnvrnFlag) { - for (auto &thisZoneHB : state.dataZoneTempPredictorCorrector->zoneHeatBalance) { + if (s_ztpc->MyEnvrnFlag && state.dataGlobal->BeginEnvrnFlag) { + for (auto &thisZoneHB : s_ztpc->zoneHeatBalance) { thisZoneHB.beginEnvironmentInit(state); } if (state.dataHeatBal->doSpaceHeatBalance) { - for (auto &thisSpaceHB : state.dataZoneTempPredictorCorrector->spaceHeatBalance) { + for (auto &thisSpaceHB : s_ztpc->spaceHeatBalance) { thisSpaceHB.beginEnvironmentInit(state); } } - TempZoneThermostatSetPoint = 0.0; - state.dataHeatBalFanSys->AdapComfortCoolingSetPoint = 0.0; - ZoneThermostatSetPointHi = 0.0; - ZoneThermostatSetPointLo = 0.0; + + for (auto &zoneTstatSetpt : s_hbfs->zoneTstatSetpts) + zoneTstatSetpt.setpt = zoneTstatSetpt.setptAdapComfortCool = zoneTstatSetpt.setptLo = zoneTstatSetpt.setptHi = 0.0; state.dataHeatBalFanSys->LoadCorrectionFactor = 1.0; - TempControlType = HVAC::ThermostatType::Uncontrolled; + TempControlType = HVAC::SetptType::Uncontrolled; for (auto &e : state.dataZoneEnergyDemand->ZoneSysEnergyDemand) { e.beginEnvironmentInit(); } @@ -3089,143 +2543,147 @@ void InitZoneAirSetPoints(EnergyPlusData &state) state.dataHeatBalFanSys->PreviousMeasuredHumRat2 = 0.0; // Hybrid modeling state.dataHeatBalFanSys->PreviousMeasuredHumRat3 = 0.0; // Hybrid modeling - state.dataZoneTempPredictorCorrector->MyEnvrnFlag = false; + s_ztpc->MyEnvrnFlag = false; } if (!state.dataGlobal->BeginEnvrnFlag) { - state.dataZoneTempPredictorCorrector->MyEnvrnFlag = true; + s_ztpc->MyEnvrnFlag = true; } // Do the Begin Day initializations - if (state.dataZoneTempPredictorCorrector->MyDayFlag && state.dataGlobal->BeginDayFlag) { - state.dataZoneTempPredictorCorrector->MyDayFlag = false; + if (s_ztpc->MyDayFlag && state.dataGlobal->BeginDayFlag) { + s_ztpc->MyDayFlag = false; } if (!state.dataGlobal->BeginDayFlag) { - state.dataZoneTempPredictorCorrector->MyDayFlag = true; + s_ztpc->MyDayFlag = true; } for (int Loop = 1; Loop <= state.dataZoneCtrls->NumTempControlledZones; ++Loop) { - if (state.dataZoneEquip->ZoneEquipInputsFilled && !state.dataZoneTempPredictorCorrector->ControlledZonesChecked) { - if (!VerifyControlledZoneForThermostat(state, TempControlledZone(Loop).ZoneName)) { + auto &tempZone = state.dataZoneCtrls->TempControlledZone(Loop); + if (state.dataZoneEquip->ZoneEquipInputsFilled && !s_ztpc->ControlledZonesChecked) { + if (!VerifyControlledZoneForThermostat(state, tempZone.ZoneName)) { ShowSevereError(state, format("{}Zone=\"{}\" has specified a Thermostatic control but is not a controlled zone.", RoutineName, - TempControlledZone(Loop).ZoneName)); + tempZone.ZoneName)); ShowContinueError(state, "...must have a ZoneHVAC:EquipmentConnections specification for this zone."); - state.dataZoneTempPredictorCorrector->ErrorsFound = true; + s_ztpc->ErrorsFound = true; } } - if (TempControlledZone(Loop).ManageDemand) { - int ZoneNum = TempControlledZone(Loop).ActualZoneNum; + if (tempZone.ManageDemand) { + int ZoneNum = tempZone.ActualZoneNum; + auto &zoneTstatSetpt = s_hbfs->zoneTstatSetpts(ZoneNum); + switch (TempControlType(ZoneNum)) { - case HVAC::ThermostatType::SingleHeating: - if (TempZoneThermostatSetPoint(ZoneNum) > TempControlledZone(Loop).HeatingResetLimit) { - TempZoneThermostatSetPoint(ZoneNum) = TempControlledZone(Loop).HeatingResetLimit; - ZoneThermostatSetPointLo(ZoneNum) = TempZoneThermostatSetPoint(ZoneNum); - } - break; - case HVAC::ThermostatType::SingleCooling: - if (TempZoneThermostatSetPoint(ZoneNum) < TempControlledZone(Loop).CoolingResetLimit) { - TempZoneThermostatSetPoint(ZoneNum) = TempControlledZone(Loop).CoolingResetLimit; - ZoneThermostatSetPointHi(ZoneNum) = TempZoneThermostatSetPoint(ZoneNum); + case HVAC::SetptType::SingleHeat: { + if (zoneTstatSetpt.setpt > tempZone.HeatingResetLimit) { + zoneTstatSetpt.setptLo = zoneTstatSetpt.setpt = tempZone.HeatingResetLimit; } - break; - case HVAC::ThermostatType::SingleHeatCool: - if ((TempZoneThermostatSetPoint(ZoneNum) > TempControlledZone(Loop).HeatingResetLimit) || - (TempZoneThermostatSetPoint(ZoneNum) < TempControlledZone(Loop).CoolingResetLimit)) { - - TempControlType(ZoneNum) = HVAC::ThermostatType::DualSetPointWithDeadBand; - TempControlTypeRpt(ZoneNum) = static_cast(TempControlType(ZoneNum)); - ZoneThermostatSetPointLo(ZoneNum) = TempZoneThermostatSetPoint(ZoneNum); - ZoneThermostatSetPointHi(ZoneNum) = TempZoneThermostatSetPoint(ZoneNum); + } break; - if (ZoneThermostatSetPointLo(ZoneNum) > TempControlledZone(Loop).HeatingResetLimit) - ZoneThermostatSetPointLo(ZoneNum) = TempControlledZone(Loop).HeatingResetLimit; - if (ZoneThermostatSetPointHi(ZoneNum) < TempControlledZone(Loop).CoolingResetLimit) - ZoneThermostatSetPointHi(ZoneNum) = TempControlledZone(Loop).CoolingResetLimit; + case HVAC::SetptType::SingleCool: { + if (zoneTstatSetpt.setpt < tempZone.CoolingResetLimit) { + zoneTstatSetpt.setptHi = zoneTstatSetpt.setpt = tempZone.CoolingResetLimit; } - break; - case HVAC::ThermostatType::DualSetPointWithDeadBand: - if (ZoneThermostatSetPointLo(ZoneNum) > TempControlledZone(Loop).HeatingResetLimit) - ZoneThermostatSetPointLo(ZoneNum) = TempControlledZone(Loop).HeatingResetLimit; - if (ZoneThermostatSetPointHi(ZoneNum) < TempControlledZone(Loop).CoolingResetLimit) - ZoneThermostatSetPointHi(ZoneNum) = TempControlledZone(Loop).CoolingResetLimit; - break; - default: - break; - } + } break; + + case HVAC::SetptType::SingleHeatCool: { + if ((zoneTstatSetpt.setpt > tempZone.HeatingResetLimit) || (zoneTstatSetpt.setpt < tempZone.CoolingResetLimit)) { + + TempControlType(ZoneNum) = HVAC::SetptType::DualHeatCool; + TempControlTypeRpt(ZoneNum) = static_cast(TempControlType(ZoneNum)); + zoneTstatSetpt.setptHi = zoneTstatSetpt.setptLo = zoneTstatSetpt.setpt; + + if (zoneTstatSetpt.setptLo > tempZone.HeatingResetLimit) + zoneTstatSetpt.setptLo = tempZone.HeatingResetLimit; + if (zoneTstatSetpt.setptHi < tempZone.CoolingResetLimit) + zoneTstatSetpt.setptHi = tempZone.CoolingResetLimit; + } + } break; + + case HVAC::SetptType::DualHeatCool: { + if (zoneTstatSetpt.setptLo > tempZone.HeatingResetLimit) + zoneTstatSetpt.setptLo = tempZone.HeatingResetLimit; + if (zoneTstatSetpt.setptHi < tempZone.CoolingResetLimit) + zoneTstatSetpt.setptHi = tempZone.CoolingResetLimit; + } break; + + default: { + } break; + } // switch (setptType) } } for (int Loop = 1; Loop <= state.dataZoneCtrls->NumComfortControlledZones; ++Loop) { - if (state.dataZoneEquip->ZoneEquipInputsFilled && !state.dataZoneTempPredictorCorrector->ControlledZonesChecked) { - if (!VerifyControlledZoneForThermostat(state, ComfortControlledZone(Loop).ZoneName)) { + auto const &comfortZone = state.dataZoneCtrls->ComfortControlledZone(Loop); + if (state.dataZoneEquip->ZoneEquipInputsFilled && !s_ztpc->ControlledZonesChecked) { + if (!VerifyControlledZoneForThermostat(state, comfortZone.ZoneName)) { ShowSevereError(state, format("{}Zone=\"{}\" has specified a Comfort control but is not a controlled zone.", RoutineName, - ComfortControlledZone(Loop).ZoneName)); + comfortZone.ZoneName)); ShowContinueError(state, "...must have a ZoneHVAC:EquipmentConnections specification for this zone."); - state.dataZoneTempPredictorCorrector->ErrorsFound = true; + s_ztpc->ErrorsFound = true; } } - if (ComfortControlledZone(Loop).ManageDemand) { - int ZoneNum = ComfortControlledZone(Loop).ActualZoneNum; - - switch (state.dataHeatBalFanSys->ComfortControlType(ZoneNum)) { - case HVAC::ThermostatType::SingleHeating: - if (TempZoneThermostatSetPoint(ZoneNum) >= ComfortControlledZone(Loop).HeatingResetLimit) { - TempZoneThermostatSetPoint(ZoneNum) = ComfortControlledZone(Loop).HeatingResetLimit; - ZoneThermostatSetPointLo(ZoneNum) = TempZoneThermostatSetPoint(ZoneNum); - TempControlType(ZoneNum) = HVAC::ThermostatType::SingleHeating; + if (comfortZone.ManageDemand) { + int ZoneNum = comfortZone.ActualZoneNum; + auto &zoneTstatSetpt = s_hbfs->zoneTstatSetpts(ZoneNum); + switch (s_hbfs->ComfortControlType(ZoneNum)) { + case HVAC::SetptType::SingleHeat: { + if (zoneTstatSetpt.setpt >= comfortZone.HeatingResetLimit) { + zoneTstatSetpt.setptLo = zoneTstatSetpt.setpt = comfortZone.HeatingResetLimit; + TempControlType(ZoneNum) = HVAC::SetptType::SingleHeat; TempControlTypeRpt(ZoneNum) = static_cast(TempControlType(ZoneNum)); } - break; - case HVAC::ThermostatType::SingleCooling: - if (TempZoneThermostatSetPoint(ZoneNum) <= ComfortControlledZone(Loop).CoolingResetLimit) { - TempZoneThermostatSetPoint(ZoneNum) = ComfortControlledZone(Loop).CoolingResetLimit; - ZoneThermostatSetPointHi(ZoneNum) = TempZoneThermostatSetPoint(ZoneNum); - TempControlType(ZoneNum) = HVAC::ThermostatType::SingleCooling; + } break; + + case HVAC::SetptType::SingleCool: { + if (zoneTstatSetpt.setpt <= comfortZone.CoolingResetLimit) { + zoneTstatSetpt.setptHi = zoneTstatSetpt.setpt = comfortZone.CoolingResetLimit; + TempControlType(ZoneNum) = HVAC::SetptType::SingleCool; TempControlTypeRpt(ZoneNum) = static_cast(TempControlType(ZoneNum)); } - break; - case HVAC::ThermostatType::SingleHeatCool: - if ((TempZoneThermostatSetPoint(ZoneNum) >= ComfortControlledZone(Loop).HeatingResetLimit) || - (TempZoneThermostatSetPoint(ZoneNum) <= ComfortControlledZone(Loop).CoolingResetLimit)) { + } break; + + case HVAC::SetptType::SingleHeatCool: { + if ((zoneTstatSetpt.setpt >= comfortZone.HeatingResetLimit) || (zoneTstatSetpt.setpt <= comfortZone.CoolingResetLimit)) { - TempControlType(ZoneNum) = HVAC::ThermostatType::DualSetPointWithDeadBand; + TempControlType(ZoneNum) = HVAC::SetptType::DualHeatCool; TempControlTypeRpt(ZoneNum) = static_cast(TempControlType(ZoneNum)); - ZoneThermostatSetPointLo(ZoneNum) = TempZoneThermostatSetPoint(ZoneNum); - ZoneThermostatSetPointHi(ZoneNum) = TempZoneThermostatSetPoint(ZoneNum); + zoneTstatSetpt.setptLo = zoneTstatSetpt.setptHi = zoneTstatSetpt.setpt; - if (ZoneThermostatSetPointLo(ZoneNum) >= ComfortControlledZone(Loop).HeatingResetLimit) - ZoneThermostatSetPointLo(ZoneNum) = ComfortControlledZone(Loop).HeatingResetLimit; - if (ZoneThermostatSetPointHi(ZoneNum) <= ComfortControlledZone(Loop).CoolingResetLimit) - ZoneThermostatSetPointHi(ZoneNum) = ComfortControlledZone(Loop).CoolingResetLimit; + if (zoneTstatSetpt.setptLo >= comfortZone.HeatingResetLimit) + zoneTstatSetpt.setptLo = comfortZone.HeatingResetLimit; + if (zoneTstatSetpt.setptHi <= comfortZone.CoolingResetLimit) + zoneTstatSetpt.setptHi = comfortZone.CoolingResetLimit; } - break; - case HVAC::ThermostatType::DualSetPointWithDeadBand: - TempControlType(ZoneNum) = HVAC::ThermostatType::DualSetPointWithDeadBand; + } break; + + case HVAC::SetptType::DualHeatCool: { + TempControlType(ZoneNum) = HVAC::SetptType::DualHeatCool; TempControlTypeRpt(ZoneNum) = static_cast(TempControlType(ZoneNum)); - if (ZoneThermostatSetPointLo(ZoneNum) >= ComfortControlledZone(Loop).HeatingResetLimit) - ZoneThermostatSetPointLo(ZoneNum) = ComfortControlledZone(Loop).HeatingResetLimit; - if (ZoneThermostatSetPointHi(ZoneNum) <= ComfortControlledZone(Loop).CoolingResetLimit) - ZoneThermostatSetPointHi(ZoneNum) = ComfortControlledZone(Loop).CoolingResetLimit; - break; - default: - break; - } + if (zoneTstatSetpt.setptLo >= comfortZone.HeatingResetLimit) + zoneTstatSetpt.setptLo = comfortZone.HeatingResetLimit; + if (zoneTstatSetpt.setptHi <= comfortZone.CoolingResetLimit) + zoneTstatSetpt.setptHi = comfortZone.CoolingResetLimit; + } break; + + default: { + } break; + } // switch } // Demand manager } - if (state.dataZoneTempPredictorCorrector->ErrorsFound) { + if (s_ztpc->ErrorsFound) { ShowFatalError(state, "InitZoneAirSetpoints - program terminates due to previous condition."); } if (state.dataZoneEquip->ZoneEquipInputsFilled) { - state.dataZoneTempPredictorCorrector->ControlledZonesChecked = true; + s_ztpc->ControlledZonesChecked = true; } } @@ -3321,18 +2779,21 @@ void PredictSystemLoads(EnergyPlusData &state, // the type of system being simulated. // 3. Calculate zone energy requirements + auto &s_ztpc = state.dataZoneTempPredictorCorrector; + auto const &s_hbfs = state.dataHeatBalFanSys; + // Staged thermostat setpoint - if (state.dataZoneTempPredictorCorrector->NumStageCtrZone > 0) { - for (int RelativeZoneNum = 1; RelativeZoneNum <= state.dataZoneTempPredictorCorrector->NumStageCtrZone; ++RelativeZoneNum) { + if (s_ztpc->NumStageCtrZone > 0) { + for (int RelativeZoneNum = 1; RelativeZoneNum <= s_ztpc->NumStageCtrZone; ++RelativeZoneNum) { auto &thisStageControlZone = state.dataZoneCtrls->StageControlledZone(RelativeZoneNum); int ActualZoneNum = thisStageControlZone.ActualZoneNum; - auto &thisZoneHB = state.dataZoneTempPredictorCorrector->zoneHeatBalance(ActualZoneNum); - auto &thisZoneThermostatSetPointLo = state.dataHeatBalFanSys->ZoneThermostatSetPointLo(ActualZoneNum); - auto &thisZoneThermostatSetPointHi = state.dataHeatBalFanSys->ZoneThermostatSetPointHi(ActualZoneNum); + auto &thisZoneHB = s_ztpc->zoneHeatBalance(ActualZoneNum); + auto &zoneTstatSetpt = s_hbfs->zoneTstatSetpts(ActualZoneNum); Real64 ZoneT = thisZoneHB.MAT; // Zone temperature at previous time step if (ShortenTimeStepSys) ZoneT = thisZoneHB.XMPT; - thisStageControlZone.HeatSetPoint = ScheduleManager::GetCurrentScheduleValue(state, thisStageControlZone.HSBchedIndex); - thisStageControlZone.CoolSetPoint = ScheduleManager::GetCurrentScheduleValue(state, thisStageControlZone.CSBchedIndex); + thisStageControlZone.HeatSetPoint = thisStageControlZone.heatSetptBaseSched->getCurrentVal(); + thisStageControlZone.CoolSetPoint = thisStageControlZone.coolSetptBaseSched->getCurrentVal(); + if (thisStageControlZone.HeatSetPoint >= thisStageControlZone.CoolSetPoint) { ++thisStageControlZone.StageErrCount; if (thisStageControlZone.StageErrCount < 2) { @@ -3362,11 +2823,12 @@ void PredictSystemLoads(EnergyPlusData &state, } state.dataZoneEnergyDemand->ZoneSysEnergyDemand(ActualZoneNum).StageNum = Itemp; if (SetpointOffset >= 0.5 * thisStageControlZone.CoolThroRange) { - thisZoneThermostatSetPointHi = thisStageControlZone.CoolSetPoint - 0.5 * thisStageControlZone.CoolThroRange; + zoneTstatSetpt.setptHi = thisStageControlZone.CoolSetPoint - 0.5 * thisStageControlZone.CoolThroRange; } else { - thisZoneThermostatSetPointHi = thisStageControlZone.CoolSetPoint + 0.5 * thisStageControlZone.CoolThroRange; + zoneTstatSetpt.setptHi = thisStageControlZone.CoolSetPoint + 0.5 * thisStageControlZone.CoolThroRange; } - thisZoneThermostatSetPointLo = thisZoneThermostatSetPointHi; + zoneTstatSetpt.setptLo = zoneTstatSetpt.setptHi; + } else if (thisStageControlZone.HeatSetPoint > ZoneT) { // heating Real64 SetpointOffset = ZoneT - thisStageControlZone.HeatSetPoint; int Itemp = 0; @@ -3377,14 +2839,15 @@ void PredictSystemLoads(EnergyPlusData &state, } state.dataZoneEnergyDemand->ZoneSysEnergyDemand(ActualZoneNum).StageNum = Itemp; if (std::abs(SetpointOffset) >= 0.5 * thisStageControlZone.CoolThroRange) { - thisZoneThermostatSetPointLo = thisStageControlZone.HeatSetPoint + 0.5 * thisStageControlZone.HeatThroRange; + zoneTstatSetpt.setptLo = thisStageControlZone.HeatSetPoint + 0.5 * thisStageControlZone.HeatThroRange; } else { - thisZoneThermostatSetPointLo = thisStageControlZone.HeatSetPoint - 0.5 * thisStageControlZone.HeatThroRange; + zoneTstatSetpt.setptLo = thisStageControlZone.HeatSetPoint - 0.5 * thisStageControlZone.HeatThroRange; } - thisZoneThermostatSetPointHi = thisZoneThermostatSetPointLo; + zoneTstatSetpt.setptHi = zoneTstatSetpt.setptLo; + } else { - thisZoneThermostatSetPointHi = thisStageControlZone.CoolSetPoint + 0.5 * thisStageControlZone.CoolThroRange; - thisZoneThermostatSetPointLo = thisStageControlZone.HeatSetPoint - 0.5 * thisStageControlZone.HeatThroRange; + zoneTstatSetpt.setptHi = thisStageControlZone.CoolSetPoint + 0.5 * thisStageControlZone.CoolThroRange; + zoneTstatSetpt.setptLo = thisStageControlZone.HeatSetPoint - 0.5 * thisStageControlZone.HeatThroRange; state.dataZoneEnergyDemand->ZoneSysEnergyDemand(ActualZoneNum).StageNum = 0; } // SpaceHB TODO: For now, set space stagenum to zone stagenum - later need to see what space the thermostat is in @@ -3398,7 +2861,7 @@ void PredictSystemLoads(EnergyPlusData &state, } // Setpoint revision for onoff thermostat - if (state.dataZoneTempPredictorCorrector->NumOnOffCtrZone > 0) { + if (s_ztpc->NumOnOffCtrZone > 0) { Real64 TempTole = 0.02; Real64 Tprev; for (int RelativeZoneNum = 1; RelativeZoneNum <= state.dataZoneCtrls->NumTempControlledZones; ++RelativeZoneNum) { @@ -3411,10 +2874,9 @@ void PredictSystemLoads(EnergyPlusData &state, thisTempControlledZone.HeatModeLastSave = thisTempControlledZone.HeatModeLast; thisTempControlledZone.CoolModeLastSave = thisTempControlledZone.CoolModeLast; } - auto &thisTempZoneThermostatSetPoint = state.dataHeatBalFanSys->TempZoneThermostatSetPoint(thisTempControlledZone.ActualZoneNum); - auto &thisZoneHB = state.dataZoneTempPredictorCorrector->zoneHeatBalance(thisTempControlledZone.ActualZoneNum); - auto &thisZoneThermostatSetPointLo = state.dataHeatBalFanSys->ZoneThermostatSetPointLo(thisTempControlledZone.ActualZoneNum); - auto &thisZoneThermostatSetPointHi = state.dataHeatBalFanSys->ZoneThermostatSetPointHi(thisTempControlledZone.ActualZoneNum); + + auto &zoneTstatSetpt = s_hbfs->zoneTstatSetpts(thisTempControlledZone.ActualZoneNum); + auto &thisZoneHB = s_ztpc->zoneHeatBalance(thisTempControlledZone.ActualZoneNum); thisTempControlledZone.CoolOffFlag = false; thisTempControlledZone.HeatOffFlag = false; @@ -3426,105 +2888,109 @@ void PredictSystemLoads(EnergyPlusData &state, } switch (state.dataHeatBalFanSys->TempControlType(thisTempControlledZone.ActualZoneNum)) { - case HVAC::ThermostatType::SingleHeating: - thisTempZoneThermostatSetPoint = thisTempControlledZone.ZoneThermostatSetPointLo; - thisZoneThermostatSetPointLo = thisTempControlledZone.ZoneThermostatSetPointLo; + + case HVAC::SetptType::SingleHeat: { + zoneTstatSetpt.setpt = thisTempControlledZone.ZoneThermostatSetPointLo; + zoneTstatSetpt.setptLo = thisTempControlledZone.ZoneThermostatSetPointLo; if (Tprev < thisTempControlledZone.ZoneThermostatSetPointLo + TempTole) { - thisTempZoneThermostatSetPoint = thisTempControlledZone.ZoneThermostatSetPointLo + thisTempControlledZone.DeltaTCutSet; - thisZoneThermostatSetPointLo = thisTempZoneThermostatSetPoint; + zoneTstatSetpt.setpt = thisTempControlledZone.ZoneThermostatSetPointLo + thisTempControlledZone.DeltaTCutSet; + zoneTstatSetpt.setptLo = zoneTstatSetpt.setpt; } else if (Tprev > thisTempControlledZone.ZoneThermostatSetPointLo && (Tprev < thisTempControlledZone.ZoneThermostatSetPointLo + thisTempControlledZone.DeltaTCutSet - TempTole)) { - thisTempZoneThermostatSetPoint = thisTempControlledZone.ZoneThermostatSetPointLo + thisTempControlledZone.DeltaTCutSet; - thisZoneThermostatSetPointLo = thisTempZoneThermostatSetPoint; + zoneTstatSetpt.setpt = thisTempControlledZone.ZoneThermostatSetPointLo + thisTempControlledZone.DeltaTCutSet; + zoneTstatSetpt.setptLo = zoneTstatSetpt.setpt; } else { thisTempControlledZone.HeatOffFlag = true; } if (thisTempControlledZone.HeatModeLast && Tprev > thisTempControlledZone.ZoneThermostatSetPointLo) { - thisTempZoneThermostatSetPoint = thisTempControlledZone.ZoneThermostatSetPointLo; - thisZoneThermostatSetPointLo = thisTempControlledZone.ZoneThermostatSetPointLo; + zoneTstatSetpt.setpt = thisTempControlledZone.ZoneThermostatSetPointLo; + zoneTstatSetpt.setptLo = thisTempControlledZone.ZoneThermostatSetPointLo; thisTempControlledZone.HeatOffFlag = true; } - break; - case HVAC::ThermostatType::SingleCooling: - thisTempZoneThermostatSetPoint = thisTempControlledZone.ZoneThermostatSetPointHi; - thisZoneThermostatSetPointHi = thisTempControlledZone.ZoneThermostatSetPointHi; + } break; + + case HVAC::SetptType::SingleCool: { + zoneTstatSetpt.setpt = thisTempControlledZone.ZoneThermostatSetPointHi; + zoneTstatSetpt.setptHi = thisTempControlledZone.ZoneThermostatSetPointHi; if (Tprev > thisTempControlledZone.ZoneThermostatSetPointHi - TempTole) { - thisTempZoneThermostatSetPoint = thisTempControlledZone.ZoneThermostatSetPointHi - thisTempControlledZone.DeltaTCutSet; - thisZoneThermostatSetPointHi = thisTempZoneThermostatSetPoint; + zoneTstatSetpt.setpt = thisTempControlledZone.ZoneThermostatSetPointHi - thisTempControlledZone.DeltaTCutSet; + zoneTstatSetpt.setptHi = zoneTstatSetpt.setpt; } else if (Tprev < thisTempControlledZone.ZoneThermostatSetPointHi && Tprev > thisTempControlledZone.ZoneThermostatSetPointHi - thisTempControlledZone.DeltaTCutSet + TempTole) { - thisTempZoneThermostatSetPoint = thisTempControlledZone.ZoneThermostatSetPointHi - thisTempControlledZone.DeltaTCutSet; - thisZoneThermostatSetPointHi = thisTempZoneThermostatSetPoint; + zoneTstatSetpt.setpt = thisTempControlledZone.ZoneThermostatSetPointHi - thisTempControlledZone.DeltaTCutSet; + zoneTstatSetpt.setptHi = zoneTstatSetpt.setpt; } else { thisTempControlledZone.CoolOffFlag = true; } if (thisTempControlledZone.CoolModeLast && Tprev < thisTempControlledZone.ZoneThermostatSetPointHi) { - thisTempZoneThermostatSetPoint = thisTempControlledZone.ZoneThermostatSetPointHi; - thisZoneThermostatSetPointHi = thisTempControlledZone.ZoneThermostatSetPointHi; + zoneTstatSetpt.setpt = thisTempControlledZone.ZoneThermostatSetPointHi; + zoneTstatSetpt.setptHi = thisTempControlledZone.ZoneThermostatSetPointHi; thisTempControlledZone.CoolOffFlag = true; } - break; - case HVAC::ThermostatType::DualSetPointWithDeadBand: - thisZoneThermostatSetPointHi = thisTempControlledZone.ZoneThermostatSetPointHi; - thisZoneThermostatSetPointLo = thisTempControlledZone.ZoneThermostatSetPointLo; + } break; + + case HVAC::SetptType::DualHeatCool: { + zoneTstatSetpt.setptHi = thisTempControlledZone.ZoneThermostatSetPointHi; + zoneTstatSetpt.setptLo = thisTempControlledZone.ZoneThermostatSetPointLo; if (Tprev > thisTempControlledZone.ZoneThermostatSetPointHi - TempTole) { - thisZoneThermostatSetPointHi = thisTempControlledZone.ZoneThermostatSetPointHi - thisTempControlledZone.DeltaTCutSet; + zoneTstatSetpt.setptHi = thisTempControlledZone.ZoneThermostatSetPointHi - thisTempControlledZone.DeltaTCutSet; } else if (Tprev < thisTempControlledZone.ZoneThermostatSetPointHi && Tprev > thisTempControlledZone.ZoneThermostatSetPointHi - thisTempControlledZone.DeltaTCutSet + TempTole) { - thisZoneThermostatSetPointHi = thisTempControlledZone.ZoneThermostatSetPointHi - thisTempControlledZone.DeltaTCutSet; + zoneTstatSetpt.setptHi = thisTempControlledZone.ZoneThermostatSetPointHi - thisTempControlledZone.DeltaTCutSet; } else { thisTempControlledZone.CoolOffFlag = true; } if (thisTempControlledZone.CoolModeLast && Tprev < thisTempControlledZone.ZoneThermostatSetPointHi) { - thisZoneThermostatSetPointHi = thisTempControlledZone.ZoneThermostatSetPointHi; + zoneTstatSetpt.setptHi = thisTempControlledZone.ZoneThermostatSetPointHi; thisTempControlledZone.CoolOffFlag = true; } if (Tprev < thisTempControlledZone.ZoneThermostatSetPointLo + TempTole) { - thisZoneThermostatSetPointLo = thisTempControlledZone.ZoneThermostatSetPointLo + thisTempControlledZone.DeltaTCutSet; + zoneTstatSetpt.setptLo = thisTempControlledZone.ZoneThermostatSetPointLo + thisTempControlledZone.DeltaTCutSet; } else if (Tprev > thisTempControlledZone.ZoneThermostatSetPointLo && (Tprev < thisTempControlledZone.ZoneThermostatSetPointLo + thisTempControlledZone.DeltaTCutSet - TempTole)) { - thisZoneThermostatSetPointLo = thisTempControlledZone.ZoneThermostatSetPointLo + thisTempControlledZone.DeltaTCutSet; + zoneTstatSetpt.setptLo = thisTempControlledZone.ZoneThermostatSetPointLo + thisTempControlledZone.DeltaTCutSet; } else { thisTempControlledZone.HeatOffFlag = true; } if (thisTempControlledZone.HeatModeLast && Tprev > thisTempControlledZone.ZoneThermostatSetPointLo) { - thisZoneThermostatSetPointLo = thisTempControlledZone.ZoneThermostatSetPointLo; + zoneTstatSetpt.setptLo = thisTempControlledZone.ZoneThermostatSetPointLo; thisTempControlledZone.HeatOffFlag = true; } // check setpoint for both and provde an error message - if (thisZoneThermostatSetPointLo >= thisZoneThermostatSetPointHi) { + if (zoneTstatSetpt.setptLo >= zoneTstatSetpt.setptHi) { ShowSevereError(state, "DualSetPointWithDeadBand: When Temperature Difference Between Cutout And Setpoint is applied, the heating " "setpoint is greater than the cooling setpoint. "); ShowContinueErrorTimeStamp(state, format("occurs in Zone={}", state.dataHeatBal->Zone(thisTempControlledZone.ActualZoneNum).Name)); - ShowContinueError(state, format("Zone Heating ThermostatSetPoint={:.2R}", thisZoneThermostatSetPointLo)); - ShowContinueError(state, format("Zone Cooling ThermostatSetPoint={:.2R}", thisZoneThermostatSetPointHi)); + ShowContinueError(state, format("Zone Heating ThermostatSetPoint={:.2R}", zoneTstatSetpt.setptLo)); + ShowContinueError(state, format("Zone Cooling ThermostatSetPoint={:.2R}", zoneTstatSetpt.setptHi)); ShowFatalError(state, "Program terminates due to above conditions."); } - break; - default: - break; - } + } break; + + default: { + } break; + } // switch (setptType) } } } for (int zoneNum = 1; zoneNum <= state.dataGlobal->NumOfZones; ++zoneNum) { - auto &thisZoneHB = state.dataZoneTempPredictorCorrector->zoneHeatBalance(zoneNum); + auto &thisZoneHB = s_ztpc->zoneHeatBalance(zoneNum); thisZoneHB.predictSystemLoad(state, ShortenTimeStepSys, UseZoneTimeStepHistory, PriorTimeStep, zoneNum); for (int spaceNum : state.dataHeatBal->Zone(zoneNum).spaceIndexes) { if (state.dataHeatBal->doSpaceHeatBalance) { - state.dataZoneTempPredictorCorrector->spaceHeatBalance(spaceNum).predictSystemLoad( + s_ztpc->spaceHeatBalance(spaceNum).predictSystemLoad( state, ShortenTimeStepSys, UseZoneTimeStepHistory, PriorTimeStep, zoneNum, spaceNum); } else if (ShortenTimeStepSys) { - state.dataZoneTempPredictorCorrector->spaceHeatBalance(spaceNum).MAT = thisZoneHB.MAT; - state.dataZoneTempPredictorCorrector->spaceHeatBalance(spaceNum).airHumRat = thisZoneHB.airHumRat; + s_ztpc->spaceHeatBalance(spaceNum).MAT = thisZoneHB.MAT; + s_ztpc->spaceHeatBalance(spaceNum).airHumRat = thisZoneHB.airHumRat; } } } - if (state.dataZoneTempPredictorCorrector->NumOnOffCtrZone > 0) { + if (s_ztpc->NumOnOffCtrZone > 0) { for (int RelativeZoneNum = 1; RelativeZoneNum <= state.dataZoneCtrls->NumTempControlledZones; ++RelativeZoneNum) { auto &thisTempControlledZone = state.dataZoneCtrls->TempControlledZone(RelativeZoneNum); if (thisTempControlledZone.DeltaTCutSet > 0.0) { @@ -3671,24 +3137,19 @@ void CalcZoneAirTempSetPoints(EnergyPlusData &state) // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int RelativeZoneNum; int ActualZoneNum; - int TempControlSchedIndex; - int SetPointTempSchedIndexHot; - int SetPointTempSchedIndexCold; - int SchedNameIndex; Array2D DaySPValues; // Day room temp setpoint values - for optimum start int OccStartTime; // Occupancy start time - for optimum start Real64 DeltaT; // Temperature difference between cutout and setpoint + auto &s_hbfs = state.dataHeatBalFanSys; + auto &Zone = state.dataHeatBal->Zone; auto &TempControlledZone = state.dataZoneCtrls->TempControlledZone; - auto &TempZoneThermostatSetPoint = state.dataHeatBalFanSys->TempZoneThermostatSetPoint; auto &TempControlType = state.dataHeatBalFanSys->TempControlType; auto &TempControlTypeRpt = state.dataHeatBalFanSys->TempControlTypeRpt; - auto &ZoneThermostatSetPointLo = state.dataHeatBalFanSys->ZoneThermostatSetPointLo; - auto &ZoneThermostatSetPointHi = state.dataHeatBalFanSys->ZoneThermostatSetPointHi; int NumOfZones = state.dataGlobal->NumOfZones; - TempControlType = HVAC::ThermostatType::Uncontrolled; // Default + TempControlType = HVAC::SetptType::Uncontrolled; // Default // Place holder for occupied heating and cooling set points - for optimum start if (!allocated(state.dataZoneCtrls->OccRoomTSetPointHeat)) { @@ -3702,157 +3163,153 @@ void CalcZoneAirTempSetPoints(EnergyPlusData &state) DeltaT = 0.0; for (RelativeZoneNum = 1; RelativeZoneNum <= state.dataZoneCtrls->NumTempControlledZones; ++RelativeZoneNum) { - + auto &tempZone = state.dataZoneCtrls->TempControlledZone(RelativeZoneNum); // What if this zone not controlled??? - ActualZoneNum = TempControlledZone(RelativeZoneNum).ActualZoneNum; - TempControlSchedIndex = TempControlledZone(RelativeZoneNum).CTSchedIndex; - TempControlType(ActualZoneNum) = static_cast(ScheduleManager::GetCurrentScheduleValue(state, TempControlSchedIndex)); + ActualZoneNum = tempZone.ActualZoneNum; + TempControlType(ActualZoneNum) = static_cast(tempZone.setptTypeSched->getCurrentVal()); TempControlTypeRpt(ActualZoneNum) = static_cast(TempControlType(ActualZoneNum)); // Error detection for these values is done in the Get routine + auto &zoneTstatSetpt = s_hbfs->zoneTstatSetpts(tempZone.ActualZoneNum); + switch (TempControlType(ActualZoneNum)) { - case HVAC::ThermostatType::Uncontrolled: - break; - case HVAC::ThermostatType::SingleHeating: - SchedNameIndex = TempControlledZone(RelativeZoneNum).SchIndx_SingleHeatSetPoint; - TempZoneThermostatSetPoint(ActualZoneNum) = ScheduleManager::GetCurrentScheduleValue(state, SchedNameIndex); - TempControlledZone(RelativeZoneNum).ZoneThermostatSetPointLo = TempZoneThermostatSetPoint(ActualZoneNum); + case HVAC::SetptType::Uncontrolled: { + } break; + + case HVAC::SetptType::SingleHeat: { + zoneTstatSetpt.setpt = tempZone.setpts[(int)HVAC::SetptType::SingleHeat].heatSetptSched->getCurrentVal(); + tempZone.ZoneThermostatSetPointLo = zoneTstatSetpt.setpt; - AdjustAirSetPointsforOpTempCntrl(state, RelativeZoneNum, ActualZoneNum, TempZoneThermostatSetPoint(ActualZoneNum)); - ZoneThermostatSetPointLo(ActualZoneNum) = TempZoneThermostatSetPoint(ActualZoneNum); - break; - case HVAC::ThermostatType::SingleCooling: - SchedNameIndex = TempControlledZone(RelativeZoneNum).SchIndx_SingleCoolSetPoint; - TempZoneThermostatSetPoint(ActualZoneNum) = ScheduleManager::GetCurrentScheduleValue(state, SchedNameIndex); - TempControlledZone(RelativeZoneNum).ZoneThermostatSetPointHi = TempZoneThermostatSetPoint(ActualZoneNum); + AdjustAirSetPointsforOpTempCntrl(state, RelativeZoneNum, ActualZoneNum, zoneTstatSetpt.setpt); + zoneTstatSetpt.setptLo = zoneTstatSetpt.setpt; + } break; + + case HVAC::SetptType::SingleCool: { + zoneTstatSetpt.setpt = tempZone.setpts[(int)HVAC::SetptType::SingleCool].coolSetptSched->getCurrentVal(); + tempZone.ZoneThermostatSetPointHi = zoneTstatSetpt.setpt; // Added Jan 17 (X. Luo) // Adjust operative temperature based on adaptive comfort model - if ((TempControlledZone(RelativeZoneNum).AdaptiveComfortTempControl)) { - AdjustOperativeSetPointsforAdapComfort(state, RelativeZoneNum, TempZoneThermostatSetPoint(ActualZoneNum)); - state.dataHeatBalFanSys->AdapComfortCoolingSetPoint(ActualZoneNum) = TempZoneThermostatSetPoint(ActualZoneNum); + if (tempZone.AdaptiveComfortTempControl) { + AdjustOperativeSetPointsforAdapComfort(state, RelativeZoneNum, zoneTstatSetpt.setpt); + zoneTstatSetpt.setptAdapComfortCool = zoneTstatSetpt.setpt; } - AdjustAirSetPointsforOpTempCntrl(state, RelativeZoneNum, ActualZoneNum, TempZoneThermostatSetPoint(ActualZoneNum)); - ZoneThermostatSetPointHi(ActualZoneNum) = TempZoneThermostatSetPoint(ActualZoneNum); + AdjustAirSetPointsforOpTempCntrl(state, RelativeZoneNum, ActualZoneNum, zoneTstatSetpt.setpt); + zoneTstatSetpt.setptHi = zoneTstatSetpt.setpt; AdjustCoolingSetPointforTempAndHumidityControl(state, RelativeZoneNum, ActualZoneNum); - break; - case HVAC::ThermostatType::SingleHeatCool: - - SchedNameIndex = TempControlledZone(RelativeZoneNum).SchIndx_SingleHeatCoolSetPoint; - - TempZoneThermostatSetPoint(ActualZoneNum) = ScheduleManager::GetCurrentScheduleValue(state, SchedNameIndex); + } break; + + case HVAC::SetptType::SingleHeatCool: { + zoneTstatSetpt.setpt = tempZone.setpts[(int)HVAC::SetptType::SingleHeatCool].heatSetptSched->getCurrentVal(); // Added Jan 17 (X. Luo) // Adjust operative temperature based on adaptive comfort model - if ((TempControlledZone(RelativeZoneNum).AdaptiveComfortTempControl)) { - AdjustOperativeSetPointsforAdapComfort(state, RelativeZoneNum, TempZoneThermostatSetPoint(ActualZoneNum)); - state.dataHeatBalFanSys->AdapComfortCoolingSetPoint(ActualZoneNum) = TempZoneThermostatSetPoint(ActualZoneNum); + if (tempZone.AdaptiveComfortTempControl) { + AdjustOperativeSetPointsforAdapComfort(state, RelativeZoneNum, zoneTstatSetpt.setpt); + zoneTstatSetpt.setptAdapComfortCool = zoneTstatSetpt.setpt; } - AdjustAirSetPointsforOpTempCntrl(state, RelativeZoneNum, ActualZoneNum, TempZoneThermostatSetPoint(ActualZoneNum)); + AdjustAirSetPointsforOpTempCntrl(state, RelativeZoneNum, ActualZoneNum, zoneTstatSetpt.setpt); - ZoneThermostatSetPointHi(ActualZoneNum) = TempZoneThermostatSetPoint(ActualZoneNum); - ZoneThermostatSetPointLo(ActualZoneNum) = TempZoneThermostatSetPoint(ActualZoneNum); + zoneTstatSetpt.setptLo = zoneTstatSetpt.setptHi = zoneTstatSetpt.setpt; // Change the room set point to occupied set point during optimum start period-------------- if (allocated(state.dataAvail->OptStart)) { if (!allocated(DaySPValues)) { - DaySPValues.allocate(state.dataGlobal->NumOfTimeStepInHour, 24); + DaySPValues.allocate(state.dataGlobal->TimeStepsInHour, Constant::iHoursInDay); } if (state.dataAvail->OptStart(ActualZoneNum).ActualZoneNum == ActualZoneNum) { - ScheduleManager::GetScheduleValuesForDay(state, SetPointTempSchedIndexCold, DaySPValues); + tempZone.setpts[(int)HVAC::SetptType::SingleHeat].heatSetptSched->getDayVals(state, DaySPValues); OccStartTime = CEILING(state.dataAvail->OptStart(ActualZoneNum).OccStartTime) + 1; - TempZoneThermostatSetPoint(ActualZoneNum) = DaySPValues(1, OccStartTime); + zoneTstatSetpt.setpt = DaySPValues(1, OccStartTime); } if (state.dataAvail->OptStart(ActualZoneNum).OptStartFlag) { - ZoneThermostatSetPointHi(ActualZoneNum) = TempZoneThermostatSetPoint(ActualZoneNum); - ZoneThermostatSetPointLo(ActualZoneNum) = TempZoneThermostatSetPoint(ActualZoneNum); + zoneTstatSetpt.setptLo = zoneTstatSetpt.setptHi = zoneTstatSetpt.setpt; } } //-------------------------------------------------------------------------------------------- - break; - case HVAC::ThermostatType::DualSetPointWithDeadBand: - SetPointTempSchedIndexHot = TempControlledZone(RelativeZoneNum).SchIndx_DualSetPointWDeadBandHeat; - SetPointTempSchedIndexCold = TempControlledZone(RelativeZoneNum).SchIndx_DualSetPointWDeadBandCool; - - ZoneThermostatSetPointHi(ActualZoneNum) = ScheduleManager::GetCurrentScheduleValue(state, SetPointTempSchedIndexCold); - TempControlledZone(RelativeZoneNum).ZoneThermostatSetPointHi = ZoneThermostatSetPointHi(ActualZoneNum); + } break; + + case HVAC::SetptType::DualHeatCool: { + zoneTstatSetpt.setptHi = tempZone.setpts[(int)HVAC::SetptType::DualHeatCool].coolSetptSched->getCurrentVal(); + TempControlledZone(RelativeZoneNum).ZoneThermostatSetPointHi = zoneTstatSetpt.setptHi; // Added Jan 17 (X. Luo) // Adjust operative temperature based on adaptive comfort model if ((TempControlledZone(RelativeZoneNum).AdaptiveComfortTempControl)) { - AdjustOperativeSetPointsforAdapComfort(state, RelativeZoneNum, ZoneThermostatSetPointHi(ActualZoneNum)); - state.dataHeatBalFanSys->AdapComfortCoolingSetPoint(ActualZoneNum) = ZoneThermostatSetPointHi(ActualZoneNum); + AdjustOperativeSetPointsforAdapComfort(state, RelativeZoneNum, zoneTstatSetpt.setptHi); + zoneTstatSetpt.setptAdapComfortCool = zoneTstatSetpt.setptHi; } - AdjustAirSetPointsforOpTempCntrl(state, RelativeZoneNum, ActualZoneNum, ZoneThermostatSetPointHi(ActualZoneNum)); + AdjustAirSetPointsforOpTempCntrl(state, RelativeZoneNum, ActualZoneNum, zoneTstatSetpt.setptHi); - ZoneThermostatSetPointLo(ActualZoneNum) = ScheduleManager::GetCurrentScheduleValue(state, SetPointTempSchedIndexHot); - TempControlledZone(RelativeZoneNum).ZoneThermostatSetPointLo = ZoneThermostatSetPointLo(ActualZoneNum); - AdjustAirSetPointsforOpTempCntrl(state, RelativeZoneNum, ActualZoneNum, ZoneThermostatSetPointLo(ActualZoneNum)); + zoneTstatSetpt.setptLo = tempZone.setpts[(int)HVAC::SetptType::DualHeatCool].heatSetptSched->getCurrentVal(); + TempControlledZone(RelativeZoneNum).ZoneThermostatSetPointLo = zoneTstatSetpt.setptLo; + AdjustAirSetPointsforOpTempCntrl(state, RelativeZoneNum, ActualZoneNum, zoneTstatSetpt.setptLo); // Change the room set point to occupied set point during optimum start period-------------- if (allocated(state.dataAvail->OptStart)) { if (!allocated(DaySPValues)) { - DaySPValues.allocate(state.dataGlobal->NumOfTimeStepInHour, 24); + DaySPValues.allocate(state.dataGlobal->TimeStepsInHour, Constant::iHoursInDay); } if (state.dataAvail->OptStart(ActualZoneNum).ActualZoneNum == ActualZoneNum) { - ScheduleManager::GetScheduleValuesForDay(state, SetPointTempSchedIndexCold, DaySPValues); + // TODO: Why are we getting all day values if all we want is the value at (1, OccStartTime); + tempZone.setpts[(int)HVAC::SetptType::DualHeatCool].coolSetptSched->getDayVals(state, DaySPValues); OccStartTime = CEILING(state.dataAvail->OptStart(ActualZoneNum).OccStartTime) + 1; state.dataZoneCtrls->OccRoomTSetPointCool(ActualZoneNum) = DaySPValues(1, OccStartTime); - ScheduleManager::GetScheduleValuesForDay(state, SetPointTempSchedIndexHot, DaySPValues); + tempZone.setpts[(int)HVAC::SetptType::DualHeatCool].heatSetptSched->getDayVals(state, DaySPValues); state.dataZoneCtrls->OccRoomTSetPointHeat(ActualZoneNum) = DaySPValues(1, OccStartTime); } if (state.dataAvail->OptStart(ActualZoneNum).OptStartFlag) { - ZoneThermostatSetPointHi(ActualZoneNum) = state.dataZoneCtrls->OccRoomTSetPointCool(ActualZoneNum); - ZoneThermostatSetPointLo(ActualZoneNum) = state.dataZoneCtrls->OccRoomTSetPointHeat(ActualZoneNum); + zoneTstatSetpt.setptHi = state.dataZoneCtrls->OccRoomTSetPointCool(ActualZoneNum); + zoneTstatSetpt.setptLo = state.dataZoneCtrls->OccRoomTSetPointHeat(ActualZoneNum); } } //-------------------------------------------------------------------------------------------- AdjustCoolingSetPointforTempAndHumidityControl(state, RelativeZoneNum, ActualZoneNum); - break; - default: + } break; + + default: { ShowSevereError(state, format("CalcZoneAirTempSetpoints: Illegal control type for Zone={}, Found value={}, in Schedule={}", Zone(ActualZoneNum).Name, TempControlType(ActualZoneNum), - TempControlledZone(RelativeZoneNum).ControlTypeSchedName)); + tempZone.setptTypeSched->Name)); - break; - } + } break; + } // switch // Apply offset for faulty therostats if ((state.dataFaultsMgr->NumFaultyThermostat > 0) && (!state.dataGlobal->WarmupFlag) && (!state.dataGlobal->DoingSizing) && (!state.dataGlobal->KickOffSimulation)) { // loop through the FaultsThermostatOffset objects to find the one for the zone for (int iFault = 1; iFault <= state.dataFaultsMgr->NumFaultyThermostat; ++iFault) { - + // Why are we doing this here? if (Util::SameString(TempControlledZone(RelativeZoneNum).Name, state.dataFaultsMgr->FaultsThermostatOffset(iFault).FaultyThermostatName)) { // Check fault availability schedules - if (ScheduleManager::GetCurrentScheduleValue(state, state.dataFaultsMgr->FaultsThermostatOffset(iFault).availSchedNum) > 0.0) { + if (state.dataFaultsMgr->FaultsThermostatOffset(iFault).availSched->getCurrentVal() > 0.0) { // Check fault severity schedules to update the reference thermostat offset double rSchVal = 1.0; double offsetUpdated; - if (state.dataFaultsMgr->FaultsThermostatOffset(iFault).severitySchedNum >= 0) { - rSchVal = - ScheduleManager::GetCurrentScheduleValue(state, state.dataFaultsMgr->FaultsThermostatOffset(iFault).severitySchedNum); + if (state.dataFaultsMgr->FaultsThermostatOffset(iFault).severitySched != nullptr) { + rSchVal = state.dataFaultsMgr->FaultsThermostatOffset(iFault).severitySched->getCurrentVal(); } offsetUpdated = rSchVal * state.dataFaultsMgr->FaultsThermostatOffset(iFault).Offset; // Positive offset means the sensor reading is higher than the actual value - TempZoneThermostatSetPoint(ActualZoneNum) -= offsetUpdated; - ZoneThermostatSetPointLo(ActualZoneNum) -= offsetUpdated; - ZoneThermostatSetPointHi(ActualZoneNum) -= offsetUpdated; + zoneTstatSetpt.setpt -= offsetUpdated; + zoneTstatSetpt.setptLo -= offsetUpdated; + zoneTstatSetpt.setptHi -= offsetUpdated; } // Stop searching the FaultsThermostatOffset object for the zone @@ -3898,8 +3355,8 @@ void ZoneSpaceHeatBalanceData::calcPredictedHumidityRatio(EnergyPlusData &state, if (thisZone.humidityControlZoneIndex > 0) { auto &humidityControlZone = state.dataZoneCtrls->HumidityControlZone(thisZone.humidityControlZoneIndex); assert(humidityControlZone.ActualZoneNum == zoneNum); - ZoneRHHumidifyingSetPoint = ScheduleManager::GetCurrentScheduleValue(state, humidityControlZone.HumidifyingSchedIndex); - ZoneRHDehumidifyingSetPoint = ScheduleManager::GetCurrentScheduleValue(state, humidityControlZone.DehumidifyingSchedIndex); + ZoneRHHumidifyingSetPoint = humidityControlZone.humidifyingSched->getCurrentVal(); + ZoneRHDehumidifyingSetPoint = humidityControlZone.dehumidifyingSched->getCurrentVal(); // Apply EMS values to overwrite the humidistat values if (humidityControlZone.EMSOverrideHumidifySetPointOn) { @@ -3939,14 +3396,12 @@ void ZoneSpaceHeatBalanceData::calcPredictedHumidityRatio(EnergyPlusData &state, IsThermostatFound = true; // Check fault availability schedules - if (ScheduleManager::GetCurrentScheduleValue( - state, state.dataFaultsMgr->FaultsThermostatOffset(iFaultThermo).availSchedNum) > 0.0) { + if (state.dataFaultsMgr->FaultsThermostatOffset(iFaultThermo).availSched->getCurrentVal() > 0.0) { // Check fault severity schedules to update the reference thermostat offset double rSchVal = 1.0; - if (state.dataFaultsMgr->FaultsThermostatOffset(iFaultThermo).severitySchedNum >= 0) { - rSchVal = ScheduleManager::GetCurrentScheduleValue( - state, state.dataFaultsMgr->FaultsThermostatOffset(iFaultThermo).severitySchedNum); + if (state.dataFaultsMgr->FaultsThermostatOffset(iFaultThermo).severitySched != nullptr) { + rSchVal = state.dataFaultsMgr->FaultsThermostatOffset(iFaultThermo).severitySched->getCurrentVal(); } offsetThermostat = rSchVal * state.dataFaultsMgr->FaultsThermostatOffset(iFaultThermo).Offset; } @@ -3995,15 +3450,13 @@ void ZoneSpaceHeatBalanceData::calcPredictedHumidityRatio(EnergyPlusData &state, // For Humidistat Offset Type II: ThermostatOffsetIndependent // Check fault availability schedules - if (ScheduleManager::GetCurrentScheduleValue(state, state.dataFaultsMgr->FaultsHumidistatOffset(iFault).availSchedNum) > - 0.0) { + if (state.dataFaultsMgr->FaultsHumidistatOffset(iFault).availSched->getCurrentVal() > 0.0) { // Check fault severity schedules to update the reference humidistat offset double rSchVal = 1.0; double offsetUpdated; - if (state.dataFaultsMgr->FaultsHumidistatOffset(iFault).severitySchedNum >= 0) { - rSchVal = ScheduleManager::GetCurrentScheduleValue( - state, state.dataFaultsMgr->FaultsHumidistatOffset(iFault).severitySchedNum); + if (state.dataFaultsMgr->FaultsHumidistatOffset(iFault).severitySched != nullptr) { + rSchVal = state.dataFaultsMgr->FaultsHumidistatOffset(iFault).severitySched->getCurrentVal(); } offsetUpdated = rSchVal * state.dataFaultsMgr->FaultsHumidistatOffset(iFault).Offset; @@ -4052,12 +3505,10 @@ void ZoneSpaceHeatBalanceData::calcPredictedHumidityRatio(EnergyPlusData &state, if (ZoneSizNum > 0) { auto &zoneSizingInput = state.dataSize->ZoneSizingInput(ZoneSizNum); if (zoneSizingInput.zoneLatentSizing) { - ZoneRHDehumidifyingSetPoint = (zoneSizingInput.zoneRHDehumidifySchIndex) - ? ScheduleManager::GetCurrentScheduleValue(state, zoneSizingInput.zoneRHDehumidifySchIndex) - : zoneSizingInput.zoneRHDehumidifySetPoint; - ZoneRHHumidifyingSetPoint = (zoneSizingInput.zoneRHHumidifySchIndex) - ? ScheduleManager::GetCurrentScheduleValue(state, zoneSizingInput.zoneRHHumidifySchIndex) - : zoneSizingInput.zoneRHHumidifySetPoint; + ZoneRHDehumidifyingSetPoint = (zoneSizingInput.zoneRHDehumidifySched != nullptr) + ? zoneSizingInput.zoneRHDehumidifySched->getCurrentVal() : zoneSizingInput.zoneRHDehumidifySetPoint; + ZoneRHHumidifyingSetPoint = (zoneSizingInput.zoneRHHumidifySched != nullptr) + ? zoneSizingInput.zoneRHHumidifySched->getCurrentVal() : zoneSizingInput.zoneRHHumidifySetPoint; if (ZoneRHHumidifyingSetPoint > ZoneRHDehumidifyingSetPoint) ZoneRHHumidifyingSetPoint = ZoneRHDehumidifyingSetPoint; if (ZoneRHHumidifyingSetPoint == ZoneRHDehumidifyingSetPoint) SingleSetPoint = true; ControlledHumidZoneFlag = true; @@ -4217,13 +3668,14 @@ Real64 correctZoneAirTemps(EnergyPlusData &state, bool useZoneTimeStepHistory // if true then use zone timestep history, if false use system time step history ) { + auto &s_ztpc = state.dataZoneTempPredictorCorrector; Real64 maxTempChange = DataPrecisionGlobals::constant_zero; // Max absolute air temperature change between previous and current timestep for (int zoneNum = 1; zoneNum <= state.dataGlobal->NumOfZones; ++zoneNum) { - auto &thisZoneHB = state.dataZoneTempPredictorCorrector->zoneHeatBalance(zoneNum); + auto &thisZoneHB = s_ztpc->zoneHeatBalance(zoneNum); Real64 zoneTempChange = thisZoneHB.correctAirTemp(state, useZoneTimeStepHistory, zoneNum); auto &thisZone = state.dataHeatBal->Zone(zoneNum); for (int spaceNum : thisZone.spaceIndexes) { - auto &thisSpaceHB = state.dataZoneTempPredictorCorrector->spaceHeatBalance(spaceNum); + auto &thisSpaceHB = s_ztpc->spaceHeatBalance(spaceNum); if (state.dataHeatBal->doSpaceHeatBalanceSimulation && !state.dataGlobal->DoingSizing) { // Need space air temps to match zone temps for sizing Real64 spaceTempChange = thisSpaceHB.correctAirTemp(state, useZoneTimeStepHistory, zoneNum, spaceNum); @@ -4248,11 +3700,11 @@ Real64 correctZoneAirTemps(EnergyPlusData &state, maxTempChange = max(maxTempChange, zoneTempChange); CalcZoneComponentLoadSums( - state, zoneNum, &state.dataZoneTempPredictorCorrector->zoneHeatBalance(zoneNum), state.dataHeatBal->ZnAirRpt(zoneNum)); + state, zoneNum, &s_ztpc->zoneHeatBalance(zoneNum), state.dataHeatBal->ZnAirRpt(zoneNum)); if (state.dataHeatBal->doSpaceHeatBalanceSimulation) { for (int spaceNum : thisZone.spaceIndexes) { CalcZoneComponentLoadSums( - state, zoneNum, &state.dataZoneTempPredictorCorrector->spaceHeatBalance(spaceNum), state.dataHeatBal->spaceAirRpt(spaceNum)); + state, zoneNum, &s_ztpc->spaceHeatBalance(spaceNum), state.dataHeatBal->spaceAirRpt(spaceNum)); } } } @@ -4490,9 +3942,8 @@ Real64 ZoneSpaceHeatBalanceData::correctAirTemp( // Hybrid modeling start // SpaceHB TODO: For now, hybrid model is only for zones if (spaceNum == 0 && state.dataHybridModel->FlagHybridModel) { - if ((state.dataHybridModel->HybridModelZone(zoneNum).InfiltrationCalc_T || - state.dataHybridModel->HybridModelZone(zoneNum).InternalThermalMassCalc_T || - state.dataHybridModel->HybridModelZone(zoneNum).PeopleCountCalc_T) && + auto &hmZone = state.dataHybridModel->hybridModelZones(zoneNum); + if ((hmZone.InfiltrationCalc_T || hmZone.InternalThermalMassCalc_T || hmZone.PeopleCountCalc_T) && (!state.dataGlobal->WarmupFlag) && (!state.dataGlobal->DoingSizing)) { InverseModelTemperature(state, zoneNum, @@ -4567,12 +4018,12 @@ void PushZoneTimestepHistories(EnergyPlusData &state) // PURPOSE OF THIS SUBROUTINE: // push histories for timestep advancing - + auto &s_ztpc = state.dataZoneTempPredictorCorrector; for (int zoneNum = 1; zoneNum <= state.dataGlobal->NumOfZones; ++zoneNum) { - state.dataZoneTempPredictorCorrector->zoneHeatBalance(zoneNum).pushZoneTimestepHistory(state, zoneNum); + s_ztpc->zoneHeatBalance(zoneNum).pushZoneTimestepHistory(state, zoneNum); if (state.dataHeatBal->doSpaceHeatBalance) { for (int spaceNum : state.dataHeatBal->Zone(zoneNum).spaceIndexes) { - state.dataZoneTempPredictorCorrector->spaceHeatBalance(spaceNum).pushZoneTimestepHistory(state, zoneNum, spaceNum); + s_ztpc->spaceHeatBalance(spaceNum).pushZoneTimestepHistory(state, zoneNum, spaceNum); } } } @@ -4677,12 +4128,12 @@ void PushSystemTimestepHistories(EnergyPlusData &state) // PURPOSE OF THIS SUBROUTINE: // Push the temperature and humidity ratio histories back in time - + auto &s_ztpc = state.dataZoneTempPredictorCorrector; for (int zoneNum = 1; zoneNum <= state.dataGlobal->NumOfZones; ++zoneNum) { - state.dataZoneTempPredictorCorrector->zoneHeatBalance(zoneNum).pushSystemTimestepHistory(state, zoneNum); + s_ztpc->zoneHeatBalance(zoneNum).pushSystemTimestepHistory(state, zoneNum); if (state.dataHeatBal->doSpaceHeatBalance) { for (int spaceNum : state.dataHeatBal->Zone(zoneNum).spaceIndexes) { - state.dataZoneTempPredictorCorrector->spaceHeatBalance(spaceNum).pushSystemTimestepHistory(state, zoneNum, spaceNum); + s_ztpc->spaceHeatBalance(spaceNum).pushSystemTimestepHistory(state, zoneNum, spaceNum); } } } @@ -4771,12 +4222,12 @@ void RevertZoneTimestepHistories(EnergyPlusData &state) // PURPOSE OF THIS SUBROUTINE: // Revert the temperature and humidity ratio histories - + auto &s_ztpc = state.dataZoneTempPredictorCorrector; for (int zoneNum = 1; zoneNum <= state.dataGlobal->NumOfZones; ++zoneNum) { - state.dataZoneTempPredictorCorrector->zoneHeatBalance(zoneNum).revertZoneTimestepHistory(state, zoneNum); + s_ztpc->zoneHeatBalance(zoneNum).revertZoneTimestepHistory(state, zoneNum); if (state.dataHeatBal->doSpaceHeatBalance) { for (int spaceNum : state.dataHeatBal->Zone(zoneNum).spaceIndexes) { - state.dataZoneTempPredictorCorrector->spaceHeatBalance(spaceNum).revertZoneTimestepHistory(state, zoneNum, spaceNum); + s_ztpc->spaceHeatBalance(spaceNum).revertZoneTimestepHistory(state, zoneNum, spaceNum); } } } @@ -4918,7 +4369,7 @@ void ZoneSpaceHeatBalanceData::correctHumRat(EnergyPlusData &state, int const zo // Use a 3rd order derivative to predict final zone humidity ratio and // smooth the changes using the zone air capacitance. // auto &zoneAirHumRatTemp = this->ZoneAirHumRatTemp; - // auto &zoneW1 = state.dataZoneTempPredictorCorrector->zoneHeatBalance(ZoneNum).ZoneW1; + // auto &zoneW1 = s_ztpc->zoneHeatBalance(ZoneNum).ZoneW1; switch (state.dataHeatBal->ZoneAirSolutionAlgo) { case DataHeatBalance::SolutionAlgo::ThirdOrder: { this->airHumRatTemp = @@ -4956,11 +4407,11 @@ void ZoneSpaceHeatBalanceData::correctHumRat(EnergyPlusData &state, int const zo // HybridModel with measured humidity ratio begins // SpaceHB TODO: For now, hybrid model is only for zones if (spaceNum == 0 && state.dataHybridModel->FlagHybridModel) { - if ((state.dataHybridModel->HybridModelZone(zoneNum).InfiltrationCalc_H || - state.dataHybridModel->HybridModelZone(zoneNum).PeopleCountCalc_H) && + auto &hmZone = state.dataHybridModel->hybridModelZones(zoneNum); + if ((hmZone.InfiltrationCalc_H || hmZone.PeopleCountCalc_H) && (!state.dataGlobal->WarmupFlag) && (!state.dataGlobal->DoingSizing)) { Real64 LatentGainExceptPeople = 0.0; - if (state.dataHybridModel->HybridModelZone(zoneNum).PeopleCountCalc_H) { + if (hmZone.PeopleCountCalc_H) { LatentGainExceptPeople = this->latentGainExceptPeople + state.dataHeatBalFanSys->SumLatentHTRadSys(zoneNum) + state.dataHeatBalFanSys->SumLatentPool(zoneNum); } @@ -5140,31 +4591,29 @@ void InverseModelTemperature(EnergyPlusData &state, Real64 BB(0.0); Real64 FractionConvection(0.0); // Default convection portion of the sensible heat from people + auto &s_ztpc = state.dataZoneTempPredictorCorrector; auto &zone = state.dataHeatBal->Zone(ZoneNum); - auto &hybridModelZone = state.dataHybridModel->HybridModelZone(ZoneNum); - auto &thisZoneHB = state.dataZoneTempPredictorCorrector->zoneHeatBalance(ZoneNum); + auto &hmZone = state.dataHybridModel->hybridModelZones(ZoneNum); + auto &thisZoneHB = s_ztpc->zoneHeatBalance(ZoneNum); int ZoneMult = zone.Multiplier * zone.ListMultiplier; - zone.ZoneMeasuredTemperature = ScheduleManager::GetCurrentScheduleValue(state, hybridModelZone.ZoneMeasuredTemperatureSchedulePtr); + zone.ZoneMeasuredTemperature = (hmZone.measuredTempSched != nullptr) ? hmZone.measuredTempSched->getCurrentVal() : 0.0; zone.ZoneVolCapMultpSensHM = 1.0; // Initialize to 1.0 in case hybrid not active // HM calculation only HM calculation period start - if (state.dataEnvrn->DayOfYear >= hybridModelZone.HybridStartDayOfYear && state.dataEnvrn->DayOfYear <= hybridModelZone.HybridEndDayOfYear) { + if (state.dataEnvrn->DayOfYear >= hmZone.HybridStartDayOfYear && state.dataEnvrn->DayOfYear <= hmZone.HybridEndDayOfYear) { Real64 MultpHM(1.0); thisZoneHB.ZT = zone.ZoneMeasuredTemperature; // Array1D ZT -- Zone // Air Temperature Averaged over // the System Time Increment - if (hybridModelZone.InfiltrationCalc_T && state.dataHVACGlobal->UseZoneTimeStepHistory) { + if (hmZone.InfiltrationCalc_T && state.dataHVACGlobal->UseZoneTimeStepHistory) { static constexpr std::string_view RoutineNameInfiltration("CalcAirFlowSimple:Infiltration"); - if (hybridModelZone.IncludeSystemSupplyParameters) { - zone.ZoneMeasuredSupplyAirTemperature = - ScheduleManager::GetCurrentScheduleValue(state, hybridModelZone.ZoneSupplyAirTemperatureSchedulePtr); - zone.ZoneMeasuredSupplyAirFlowRate = - ScheduleManager::GetCurrentScheduleValue(state, hybridModelZone.ZoneSupplyAirMassFlowRateSchedulePtr); - zone.ZoneMeasuredSupplyAirHumidityRatio = - ScheduleManager::GetCurrentScheduleValue(state, hybridModelZone.ZoneSupplyAirHumidityRatioSchedulePtr); + if (hmZone.IncludeSystemSupplyParameters) { + zone.ZoneMeasuredSupplyAirTemperature = hmZone.supplyAirTempSched->getCurrentVal(); + zone.ZoneMeasuredSupplyAirFlowRate = hmZone.supplyAirMassFlowRateSched ? hmZone.supplyAirMassFlowRateSched->getCurrentVal() : 0.0; + zone.ZoneMeasuredSupplyAirHumidityRatio = hmZone.supplyAirHumRatSched ? hmZone.supplyAirHumRatSched->getCurrentVal() : 0.0; // Calculate the air humidity ratio at supply air inlet. Real64 CpAirInlet(0.0); CpAirInlet = Psychrometrics::PsyCpAirFnW(zone.ZoneMeasuredSupplyAirHumidityRatio); @@ -5196,8 +4645,8 @@ void InverseModelTemperature(EnergyPlusData &state, if (std::abs(delta_T) > 0.5) { M_inf = (BB + CC * DD - ((11.0 / 6.0) * CC + AA) * zone.ZoneMeasuredTemperature) / (CpAir * delta_T); } - Real64 ACH_inf = max(0.0, min(10.0, (M_inf / AirDensity) / zone.Volume * Constant::SecInHour)); - M_inf = (ACH_inf / Constant::SecInHour) * zone.Volume * AirDensity; + Real64 ACH_inf = max(0.0, min(10.0, (M_inf / AirDensity) / zone.Volume * Constant::rSecsInHour)); + M_inf = (ACH_inf / Constant::rSecsInHour) * zone.Volume * AirDensity; // Overwrite variable with inverse solution zone.MCPIHM = M_inf; @@ -5206,7 +4655,7 @@ void InverseModelTemperature(EnergyPlusData &state, } // Hybrid model infiltration calculation end // Hybrid modeling internal thermal mass calculation start - if (hybridModelZone.InternalThermalMassCalc_T && SumSysMCpT == 0 && thisZoneHB.ZT != state.dataHeatBalFanSys->PreviousMeasuredZT1(ZoneNum) && + if (hmZone.InternalThermalMassCalc_T && SumSysMCpT == 0 && thisZoneHB.ZT != state.dataHeatBalFanSys->PreviousMeasuredZT1(ZoneNum) && state.dataHVACGlobal->UseZoneTimeStepHistory) { // HM calculation only when SumSysMCpT =0, // TimeStepZone (not @ TimeStepSys) Real64 TempDepCoef = SumHA + SumMCp + SumSysMCp; @@ -5247,7 +4696,7 @@ void InverseModelTemperature(EnergyPlusData &state, thisZoneHB.ZT, thisZoneHB.airHumRat) * Psychrometrics::PsyCpAirFnW(thisZoneHB.airHumRat)) * - (state.dataGlobal->TimeStepZone * Constant::SecInHour); // Inverse equation + (state.dataGlobal->TimeStepZone * Constant::rSecsInHour); // Inverse equation } else { MultpHM = 1.0; // Default value 1.0 } @@ -5259,17 +4708,15 @@ void InverseModelTemperature(EnergyPlusData &state, } // Hybrid model internal thermal mass calcualtion end // Hybrid model people count calculation - if (hybridModelZone.PeopleCountCalc_T && state.dataHVACGlobal->UseZoneTimeStepHistory) { - zone.ZoneMeasuredTemperature = ScheduleManager::GetCurrentScheduleValue(state, hybridModelZone.ZoneMeasuredTemperatureSchedulePtr); - zone.ZonePeopleActivityLevel = ScheduleManager::GetCurrentScheduleValue(state, hybridModelZone.ZonePeopleActivityLevelSchedulePtr); - zone.ZonePeopleSensibleHeatFraction = - ScheduleManager::GetCurrentScheduleValue(state, hybridModelZone.ZonePeopleSensibleFractionSchedulePtr); - zone.ZonePeopleRadiantHeatFraction = - ScheduleManager::GetCurrentScheduleValue(state, hybridModelZone.ZonePeopleRadiationFractionSchedulePtr); + if (hmZone.PeopleCountCalc_T && state.dataHVACGlobal->UseZoneTimeStepHistory) { + zone.ZoneMeasuredTemperature = hmZone.measuredTempSched->getCurrentVal(); + zone.ZonePeopleActivityLevel = hmZone.peopleActivityLevelSched ? hmZone.peopleActivityLevelSched->getCurrentVal() : 0.0; + zone.ZonePeopleSensibleHeatFraction = hmZone.peopleSensibleFracSched ? hmZone.peopleSensibleFracSched->getCurrentVal() : 0.0; + zone.ZonePeopleRadiantHeatFraction = hmZone.peopleRadiantFracSched ? hmZone.peopleRadiantFracSched->getCurrentVal() : 0.0; Real64 FractionSensible = zone.ZonePeopleSensibleHeatFraction; Real64 FractionRadiation = zone.ZonePeopleRadiantHeatFraction; - Real64 ActivityLevel = ScheduleManager::GetCurrentScheduleValue(state, hybridModelZone.ZonePeopleActivityLevelSchedulePtr); + Real64 ActivityLevel = hmZone.peopleActivityLevelSched ? hmZone.peopleActivityLevelSched->getCurrentVal() : 0.0; if (FractionSensible <= 0.0) { FractionSensible = 0.6; @@ -5285,13 +4732,10 @@ void InverseModelTemperature(EnergyPlusData &state, ActivityLevel = 130.0; } - if (hybridModelZone.IncludeSystemSupplyParameters) { - zone.ZoneMeasuredSupplyAirTemperature = - ScheduleManager::GetCurrentScheduleValue(state, hybridModelZone.ZoneSupplyAirTemperatureSchedulePtr); - zone.ZoneMeasuredSupplyAirFlowRate = - ScheduleManager::GetCurrentScheduleValue(state, hybridModelZone.ZoneSupplyAirMassFlowRateSchedulePtr); - zone.ZoneMeasuredSupplyAirHumidityRatio = - ScheduleManager::GetCurrentScheduleValue(state, hybridModelZone.ZoneSupplyAirHumidityRatioSchedulePtr); + if (hmZone.IncludeSystemSupplyParameters) { + zone.ZoneMeasuredSupplyAirTemperature = hmZone.supplyAirTempSched->getCurrentVal(); + zone.ZoneMeasuredSupplyAirFlowRate = hmZone.supplyAirMassFlowRateSched ? hmZone.supplyAirMassFlowRateSched->getCurrentVal() : 0.0; + zone.ZoneMeasuredSupplyAirHumidityRatio = hmZone.supplyAirHumRatSched ? hmZone.supplyAirHumRatSched->getCurrentVal() : 0.0; // Calculate the air humidity ratio at supply air inlet. Real64 CpAirInlet = Psychrometrics::PsyCpAirFnW(zone.ZoneMeasuredSupplyAirHumidityRatio); @@ -5340,8 +4784,9 @@ void processInverseModelMultpHM(EnergyPlusData &state, Real64 constexpr minHMMultValue = 1.0; Real64 constexpr maxHMMultValue = 30.0; + auto &s_ztpc = state.dataZoneTempPredictorCorrector; auto &zone = state.dataHeatBal->Zone(zoneNum); - auto &thisZoneHB = state.dataZoneTempPredictorCorrector->zoneHeatBalance(zoneNum); + auto &thisZoneHB = s_ztpc->zoneHeatBalance(zoneNum); // Apply limits and generate warnings as needed if (multiplierHM < minHMMultValue) { // don't allow this to be less than minimum (potential for instability) @@ -5392,24 +4837,23 @@ void InverseModelHumidity(EnergyPlusData &state, Real64 ActivityLevel(0.0); Real64 TimeStepSysSec = state.dataHVACGlobal->TimeStepSysSec; + auto &s_ztpc = state.dataZoneTempPredictorCorrector; auto &zone = state.dataHeatBal->Zone(ZoneNum); - auto &hybridModelZone = state.dataHybridModel->HybridModelZone(ZoneNum); - auto &thisZoneHB = state.dataZoneTempPredictorCorrector->zoneHeatBalance(ZoneNum); + auto &hmZone = state.dataHybridModel->hybridModelZones(ZoneNum); + auto &thisZoneHB = s_ztpc->zoneHeatBalance(ZoneNum); // Get measured zone humidity ratio - zone.ZoneMeasuredHumidityRatio = ScheduleManager::GetCurrentScheduleValue(state, hybridModelZone.ZoneMeasuredHumidityRatioSchedulePtr); + zone.ZoneMeasuredHumidityRatio = hmZone.measuredHumRatSched->getCurrentVal(); - if (state.dataEnvrn->DayOfYear >= hybridModelZone.HybridStartDayOfYear && state.dataEnvrn->DayOfYear <= hybridModelZone.HybridEndDayOfYear) { + if (state.dataEnvrn->DayOfYear >= hmZone.HybridStartDayOfYear && state.dataEnvrn->DayOfYear <= hmZone.HybridEndDayOfYear) { thisZoneHB.airHumRat = zone.ZoneMeasuredHumidityRatio; // Hybrid Model calculate air infiltration rate - if (hybridModelZone.InfiltrationCalc_H && state.dataHVACGlobal->UseZoneTimeStepHistory) { + if (hmZone.InfiltrationCalc_H && state.dataHVACGlobal->UseZoneTimeStepHistory) { // Conditionally calculate the time dependent and time independent terms - if (hybridModelZone.IncludeSystemSupplyParameters) { - zone.ZoneMeasuredSupplyAirFlowRate = - ScheduleManager::GetCurrentScheduleValue(state, hybridModelZone.ZoneSupplyAirMassFlowRateSchedulePtr); - zone.ZoneMeasuredSupplyAirHumidityRatio = - ScheduleManager::GetCurrentScheduleValue(state, hybridModelZone.ZoneSupplyAirHumidityRatioSchedulePtr); + if (hmZone.IncludeSystemSupplyParameters) { + zone.ZoneMeasuredSupplyAirFlowRate = hmZone.supplyAirMassFlowRateSched->getCurrentVal(); + zone.ZoneMeasuredSupplyAirHumidityRatio = hmZone.supplyAirHumRatSched->getCurrentVal(); Real64 SumSysM_HM = zone.ZoneMeasuredSupplyAirFlowRate; Real64 SumSysMHumRat_HM = zone.ZoneMeasuredSupplyAirFlowRate * zone.ZoneMeasuredSupplyAirHumidityRatio; @@ -5441,19 +4885,17 @@ void InverseModelHumidity(EnergyPlusData &state, } // Add threshold for air change rate - Real64 ACH_inf = max(0.0, min(10.0, (M_inf / AirDensity) / zone.Volume * Constant::SecInHour)); - M_inf = (ACH_inf / Constant::SecInHour) * zone.Volume * AirDensity; + Real64 ACH_inf = max(0.0, min(10.0, (M_inf / AirDensity) / zone.Volume * Constant::rSecsInHour)); + M_inf = (ACH_inf / Constant::rSecsInHour) * zone.Volume * AirDensity; zone.MCPIHM = M_inf; zone.InfilOAAirChangeRateHM = ACH_inf; } // Hybrid Model calculate people count - if (hybridModelZone.PeopleCountCalc_H && state.dataHVACGlobal->UseZoneTimeStepHistory) { - zone.ZonePeopleActivityLevel = ScheduleManager::GetCurrentScheduleValue(state, hybridModelZone.ZonePeopleActivityLevelSchedulePtr); - zone.ZonePeopleSensibleHeatFraction = - ScheduleManager::GetCurrentScheduleValue(state, hybridModelZone.ZonePeopleSensibleFractionSchedulePtr); - zone.ZonePeopleRadiantHeatFraction = - ScheduleManager::GetCurrentScheduleValue(state, hybridModelZone.ZonePeopleRadiationFractionSchedulePtr); + if (hmZone.PeopleCountCalc_H && state.dataHVACGlobal->UseZoneTimeStepHistory) { + zone.ZonePeopleActivityLevel = hmZone.peopleActivityLevelSched ? hmZone.peopleActivityLevelSched->getCurrentVal() : 0.0; + zone.ZonePeopleSensibleHeatFraction = hmZone.peopleSensibleFracSched ? hmZone.peopleSensibleFracSched->getCurrentVal() : 0.0; + zone.ZonePeopleRadiantHeatFraction = hmZone.peopleRadiantFracSched ? hmZone.peopleRadiantFracSched->getCurrentVal() : 0.0; Real64 FractionSensible = zone.ZonePeopleSensibleHeatFraction; @@ -5467,11 +4909,9 @@ void InverseModelHumidity(EnergyPlusData &state, // Conditionally calculate the humidity-dependent and humidity-independent // terms. - if (hybridModelZone.IncludeSystemSupplyParameters) { - zone.ZoneMeasuredSupplyAirFlowRate = - ScheduleManager::GetCurrentScheduleValue(state, hybridModelZone.ZoneSupplyAirMassFlowRateSchedulePtr); - zone.ZoneMeasuredSupplyAirHumidityRatio = - ScheduleManager::GetCurrentScheduleValue(state, hybridModelZone.ZoneSupplyAirHumidityRatioSchedulePtr); + if (hmZone.IncludeSystemSupplyParameters) { + zone.ZoneMeasuredSupplyAirFlowRate = hmZone.supplyAirMassFlowRateSched->getCurrentVal(); + zone.ZoneMeasuredSupplyAirHumidityRatio = hmZone.supplyAirHumRatSched->getCurrentVal(); Real64 SumSysM_HM = zone.ZoneMeasuredSupplyAirFlowRate; Real64 SumSysMHumRat_HM = zone.ZoneMeasuredSupplyAirFlowRate * zone.ZoneMeasuredSupplyAirHumidityRatio; @@ -5648,12 +5088,13 @@ void ZoneSpaceHeatBalanceData::calcZoneOrSpaceSums(EnergyPlusData &state, SumHATOutput ZoneHeatBalanceData::calcSumHAT(EnergyPlusData &state, int const zoneNum, [[maybe_unused]] int const spaceNum) { + auto &s_ztpc = state.dataZoneTempPredictorCorrector; assert(zoneNum > 0); assert(spaceNum == 0); SumHATOutput zoneResults; // zone-level return values for (int zoneSpaceNum : state.dataHeatBal->Zone(zoneNum).spaceIndexes) { SumHATOutput spaceResults; // temporary return value from space-level calcSumHAT - spaceResults = state.dataZoneTempPredictorCorrector->spaceHeatBalance(zoneSpaceNum).calcSumHAT(state, zoneNum, zoneSpaceNum); + spaceResults = s_ztpc->spaceHeatBalance(zoneSpaceNum).calcSumHAT(state, zoneNum, zoneSpaceNum); zoneResults.sumIntGain += spaceResults.sumIntGain; zoneResults.sumHA += spaceResults.sumHA; zoneResults.sumHATsurf += spaceResults.sumHATsurf; @@ -5666,6 +5107,7 @@ SumHATOutput SpaceHeatBalanceData::calcSumHAT(EnergyPlusData &state, int const z { assert(zoneNum > 0); assert(spaceNum > 0); + auto &s_ztpc = state.dataZoneTempPredictorCorrector; auto &thisZone = state.dataHeatBal->Zone(zoneNum); auto &thisSpace = state.dataHeatBal->space(spaceNum); SumHATOutput results; // space-level return values @@ -5755,9 +5197,9 @@ SumHATOutput SpaceHeatBalanceData::calcSumHAT(EnergyPlusData &state, int const z } // determine supply air temperature as a weighted average of the inlet temperatures. // TODO: For now, use zone-level values for system flow - if (state.dataZoneTempPredictorCorrector->zoneHeatBalance(zoneNum).SumSysMCp > 0.0) { - results.sumHATref += HA * state.dataZoneTempPredictorCorrector->zoneHeatBalance(zoneNum).SumSysMCpT / - state.dataZoneTempPredictorCorrector->zoneHeatBalance(zoneNum).SumSysMCp; + if (s_ztpc->zoneHeatBalance(zoneNum).SumSysMCp > 0.0) { + results.sumHATref += HA * s_ztpc->zoneHeatBalance(zoneNum).SumSysMCpT / + s_ztpc->zoneHeatBalance(zoneNum).SumSysMCp; } else { // no system flow (yet) so just use zone air temperature #5906 results.sumHA += HA; @@ -6073,35 +5515,36 @@ void DetectOscillatingZoneTemp(EnergyPlusData &state) // MaxZoneTempDiff since ManageHVAC keeps shortening the timestep // until that is reached unless it goes to less than the // MinTimeStepSys. + auto &s_ztpc = state.dataZoneTempPredictorCorrector; // first time run allocate arrays and setup output variable - if (state.dataZoneTempPredictorCorrector->SetupOscillationOutputFlag) { - state.dataZoneTempPredictorCorrector->ZoneTempHist.allocate(4, state.dataGlobal->NumOfZones); - state.dataZoneTempPredictorCorrector->ZoneTempHist = 0.0; - state.dataZoneTempPredictorCorrector->ZoneTempOscillate.dimension(state.dataGlobal->NumOfZones, 0.0); - state.dataZoneTempPredictorCorrector->ZoneTempOscillateDuringOccupancy.dimension(state.dataGlobal->NumOfZones, 0.0); - state.dataZoneTempPredictorCorrector->ZoneTempOscillateInDeadband.dimension(state.dataGlobal->NumOfZones, 0.0); + if (s_ztpc->SetupOscillationOutputFlag) { + s_ztpc->ZoneTempHist.allocate(4, state.dataGlobal->NumOfZones); + s_ztpc->ZoneTempHist = 0.0; + s_ztpc->ZoneTempOscillate.dimension(state.dataGlobal->NumOfZones, 0.0); + s_ztpc->ZoneTempOscillateDuringOccupancy.dimension(state.dataGlobal->NumOfZones, 0.0); + s_ztpc->ZoneTempOscillateInDeadband.dimension(state.dataGlobal->NumOfZones, 0.0); // set up zone by zone variables, CurrentModuleObject='Zone' for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) { auto &zone = state.dataHeatBal->Zone(iZone); SetupOutputVariable(state, "Zone Oscillating Temperatures Time", Constant::Units::hr, - state.dataZoneTempPredictorCorrector->ZoneTempOscillate(iZone), + s_ztpc->ZoneTempOscillate(iZone), OutputProcessor::TimeStepType::System, OutputProcessor::StoreType::Sum, zone.Name); SetupOutputVariable(state, "Zone Oscillating Temperatures During Occupancy Time", Constant::Units::hr, - state.dataZoneTempPredictorCorrector->ZoneTempOscillateDuringOccupancy(iZone), + s_ztpc->ZoneTempOscillateDuringOccupancy(iZone), OutputProcessor::TimeStepType::System, OutputProcessor::StoreType::Sum, zone.Name); SetupOutputVariable(state, "Zone Oscillating Temperatures in Deadband Time", Constant::Units::hr, - state.dataZoneTempPredictorCorrector->ZoneTempOscillateInDeadband(iZone), + s_ztpc->ZoneTempOscillateInDeadband(iZone), OutputProcessor::TimeStepType::System, OutputProcessor::StoreType::Sum, zone.Name); @@ -6110,21 +5553,21 @@ void DetectOscillatingZoneTemp(EnergyPlusData &state) SetupOutputVariable(state, "Facility Any Zone Oscillating Temperatures Time", Constant::Units::hr, - state.dataZoneTempPredictorCorrector->AnyZoneTempOscillate, + s_ztpc->AnyZoneTempOscillate, OutputProcessor::TimeStepType::System, OutputProcessor::StoreType::Sum, "Facility"); SetupOutputVariable(state, "Facility Any Zone Oscillating Temperatures During Occupancy Time", Constant::Units::hr, - state.dataZoneTempPredictorCorrector->AnyZoneTempOscillateDuringOccupancy, + s_ztpc->AnyZoneTempOscillateDuringOccupancy, OutputProcessor::TimeStepType::System, OutputProcessor::StoreType::Sum, "Facility"); SetupOutputVariable(state, "Facility Any Zone Oscillating Temperatures in Deadband Time", Constant::Units::hr, - state.dataZoneTempPredictorCorrector->AnyZoneTempOscillateInDeadband, + s_ztpc->AnyZoneTempOscillateInDeadband, OutputProcessor::TimeStepType::System, OutputProcessor::StoreType::Sum, "Facility"); @@ -6135,13 +5578,13 @@ void DetectOscillatingZoneTemp(EnergyPlusData &state) ReportingThisVariable(state, "Facility Any Zone Oscillating Temperatures Time") || ReportingThisVariable(state, "Facility Any Zone Oscillating Temperatures During Occupancy Time") || ReportingThisVariable(state, "Facility Any Zone Oscillating Temperatures in Deadband Time")) { - state.dataZoneTempPredictorCorrector->OscillationVariablesNeeded = true; + s_ztpc->OscillationVariablesNeeded = true; } - state.dataZoneTempPredictorCorrector->SetupOscillationOutputFlag = false; + s_ztpc->SetupOscillationOutputFlag = false; } Real64 TimeStepSys = state.dataHVACGlobal->TimeStepSys; - if (state.dataZoneTempPredictorCorrector->OscillationVariablesNeeded) { + if (s_ztpc->OscillationVariablesNeeded) { // precalc the negative value for performance Real64 NegOscillateMagnitude = -HVAC::OscillateMagnitude; // assume no zone is oscillating @@ -6151,16 +5594,16 @@ void DetectOscillatingZoneTemp(EnergyPlusData &state) for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) { bool isOscillate = false; - state.dataZoneTempPredictorCorrector->ZoneTempHist(4, iZone) = state.dataZoneTempPredictorCorrector->ZoneTempHist(3, iZone); - state.dataZoneTempPredictorCorrector->ZoneTempHist(3, iZone) = state.dataZoneTempPredictorCorrector->ZoneTempHist(2, iZone); - state.dataZoneTempPredictorCorrector->ZoneTempHist(2, iZone) = state.dataZoneTempPredictorCorrector->ZoneTempHist(1, iZone); - state.dataZoneTempPredictorCorrector->ZoneTempHist(1, iZone) = state.dataZoneTempPredictorCorrector->zoneHeatBalance(iZone).ZT; + s_ztpc->ZoneTempHist(4, iZone) = s_ztpc->ZoneTempHist(3, iZone); + s_ztpc->ZoneTempHist(3, iZone) = s_ztpc->ZoneTempHist(2, iZone); + s_ztpc->ZoneTempHist(2, iZone) = s_ztpc->ZoneTempHist(1, iZone); + s_ztpc->ZoneTempHist(1, iZone) = s_ztpc->zoneHeatBalance(iZone).ZT; Real64 Diff34 = - state.dataZoneTempPredictorCorrector->ZoneTempHist(3, iZone) - state.dataZoneTempPredictorCorrector->ZoneTempHist(4, iZone); + s_ztpc->ZoneTempHist(3, iZone) - s_ztpc->ZoneTempHist(4, iZone); Real64 Diff23 = - state.dataZoneTempPredictorCorrector->ZoneTempHist(2, iZone) - state.dataZoneTempPredictorCorrector->ZoneTempHist(3, iZone); + s_ztpc->ZoneTempHist(2, iZone) - s_ztpc->ZoneTempHist(3, iZone); Real64 Diff12 = - state.dataZoneTempPredictorCorrector->ZoneTempHist(1, iZone) - state.dataZoneTempPredictorCorrector->ZoneTempHist(2, iZone); + s_ztpc->ZoneTempHist(1, iZone) - s_ztpc->ZoneTempHist(2, iZone); // roll out the conditionals for increased performance if (Diff12 > HVAC::OscillateMagnitude) { if (Diff23 < NegOscillateMagnitude) { @@ -6177,36 +5620,36 @@ void DetectOscillatingZoneTemp(EnergyPlusData &state) } } } - state.dataZoneTempPredictorCorrector->ZoneTempOscillateDuringOccupancy(iZone) = 0.0; - state.dataZoneTempPredictorCorrector->ZoneTempOscillateInDeadband(iZone) = 0.0; + s_ztpc->ZoneTempOscillateDuringOccupancy(iZone) = 0.0; + s_ztpc->ZoneTempOscillateInDeadband(iZone) = 0.0; if (isOscillate) { - state.dataZoneTempPredictorCorrector->ZoneTempOscillate(iZone) = TimeStepSys; + s_ztpc->ZoneTempOscillate(iZone) = TimeStepSys; isAnyZoneOscillating = true; if (allocated(state.dataThermalComforts->ThermalComfortInASH55)) { if (state.dataThermalComforts->ThermalComfortInASH55(iZone).ZoneIsOccupied) { - state.dataZoneTempPredictorCorrector->ZoneTempOscillateDuringOccupancy(iZone) = TimeStepSys; + s_ztpc->ZoneTempOscillateDuringOccupancy(iZone) = TimeStepSys; isAnyZoneOscillatingDuringOccupancy = true; } } if (state.dataZoneEnergyDemand->CurDeadBandOrSetback(iZone)) { - state.dataZoneTempPredictorCorrector->ZoneTempOscillateInDeadband(iZone) = TimeStepSys; + s_ztpc->ZoneTempOscillateInDeadband(iZone) = TimeStepSys; isAnyZoneOscillatingInDeadband = true; } } else { - state.dataZoneTempPredictorCorrector->ZoneTempOscillate(iZone) = 0.0; + s_ztpc->ZoneTempOscillate(iZone) = 0.0; } } // any zone variable - state.dataZoneTempPredictorCorrector->AnyZoneTempOscillate = (isAnyZoneOscillating) ? TimeStepSys : 0.0; - state.dataZoneTempPredictorCorrector->AnyZoneTempOscillateDuringOccupancy = (isAnyZoneOscillatingDuringOccupancy) ? TimeStepSys : 0.0; - state.dataZoneTempPredictorCorrector->AnyZoneTempOscillateInDeadband = (isAnyZoneOscillatingInDeadband) ? TimeStepSys : 0.0; + s_ztpc->AnyZoneTempOscillate = (isAnyZoneOscillating) ? TimeStepSys : 0.0; + s_ztpc->AnyZoneTempOscillateDuringOccupancy = (isAnyZoneOscillatingDuringOccupancy) ? TimeStepSys : 0.0; + s_ztpc->AnyZoneTempOscillateInDeadband = (isAnyZoneOscillatingInDeadband) ? TimeStepSys : 0.0; // annual/runperiod sum for _perflog.csv file - state.dataZoneTempPredictorCorrector->AnnualAnyZoneTempOscillate += state.dataZoneTempPredictorCorrector->AnyZoneTempOscillate; - state.dataZoneTempPredictorCorrector->AnnualAnyZoneTempOscillateDuringOccupancy += - state.dataZoneTempPredictorCorrector->AnyZoneTempOscillateDuringOccupancy; - state.dataZoneTempPredictorCorrector->AnnualAnyZoneTempOscillateInDeadband += - state.dataZoneTempPredictorCorrector->AnyZoneTempOscillateInDeadband; + s_ztpc->AnnualAnyZoneTempOscillate += s_ztpc->AnyZoneTempOscillate; + s_ztpc->AnnualAnyZoneTempOscillateDuringOccupancy += + s_ztpc->AnyZoneTempOscillateDuringOccupancy; + s_ztpc->AnnualAnyZoneTempOscillateInDeadband += + s_ztpc->AnyZoneTempOscillateInDeadband; } } @@ -6221,6 +5664,7 @@ void AdjustAirSetPointsforOpTempCntrl(EnergyPlusData &state, int const TempContr // This subroutine modifies the air temperature setpoint to effect operative temperature control // SUBROUTINE LOCAL VARIABLE DECLARATIONS: + auto &s_ztpc = state.dataZoneTempPredictorCorrector; Real64 thisMRTFraction; // local variable for fraction that MRT is in Op Temp definition if (!(state.dataZoneCtrls->AnyOpTempControl)) return; // do nothing to setpoint @@ -6230,11 +5674,10 @@ void AdjustAirSetPointsforOpTempCntrl(EnergyPlusData &state, int const TempContr // is operative temp radiative fraction scheduled or fixed? thisMRTFraction = (tempControlledZone.OpTempCntrlModeScheduled) - ? ScheduleManager::GetCurrentScheduleValue(state, tempControlledZone.OpTempRadiativeFractionSched) - : tempControlledZone.FixedRadiativeFraction; + ? tempControlledZone.opTempRadiativeFractionSched->getCurrentVal() : tempControlledZone.FixedRadiativeFraction; // get mean radiant temperature for zone - Real64 thisMRT = state.dataZoneTempPredictorCorrector->zoneHeatBalance(ActualZoneNum).MRT; + Real64 thisMRT = s_ztpc->zoneHeatBalance(ActualZoneNum).MRT; // modify setpoint for operative temperature control // trapping for MRT fractions between 0.0 and 0.9 during get input, so shouldn't be able to divide by zero here. @@ -6250,8 +5693,9 @@ void AdjustOperativeSetPointsforAdapComfort(EnergyPlusData &state, int const Tem // PURPOSE OF THIS SUBROUTINE: // This routine adjust the operative setpoints for each controlled adaptive thermal comfort models. + auto &s_ztpc = state.dataZoneTempPredictorCorrector; auto &tempControlledZone = state.dataZoneCtrls->TempControlledZone(TempControlledZoneID); - auto &AdapComfortDailySetPointSchedule = state.dataZoneTempPredictorCorrector->AdapComfortDailySetPointSchedule; + auto &AdapComfortDailySetPointSchedule = s_ztpc->AdapComfortDailySetPointSchedule; // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int originZoneAirSetPoint = ZoneAirSetPoint; @@ -6292,7 +5736,7 @@ void AdjustOperativeSetPointsforAdapComfort(EnergyPlusData &state, int const Tem int constexpr summerDesignDayTypeIndex(9); // Adjust summer design day set point if (state.dataWeather->DesDayInput(envrnDayNum).DayType == summerDesignDayTypeIndex) { - ZoneAirSetPoint = state.dataZoneTempPredictorCorrector->AdapComfortSetPointSummerDesDay[AdaptiveComfortModelTypeIndex - 2]; + ZoneAirSetPoint = s_ztpc->AdapComfortSetPointSummerDesDay[AdaptiveComfortModelTypeIndex - 2]; } } // If adaptive operative temperature not applicable, set back @@ -6322,77 +5766,62 @@ void CalcZoneAirComfortSetPoints(EnergyPlusData &state) int PeopleNum = 0; int ObjectCount = 0; Real64 PeopleCount = 0.0; - int SetPointComfortSchedIndex = 0; - int SchedTypeIndex = 0; + auto &s_ztpc = state.dataZoneTempPredictorCorrector; + auto &s_hbfs = state.dataHeatBalFanSys; // Call thermal comfort module to read zone control comfort object - if (state.dataZoneTempPredictorCorrector->CalcZoneAirComfortSetPointsFirstTimeFlag) { + if (s_ztpc->CalcZoneAirComfortSetPointsFirstTimeFlag) { ThermalComfort::ManageThermalComfort(state, true); - state.dataZoneTempPredictorCorrector->CalcZoneAirComfortSetPointsFirstTimeFlag = false; + s_ztpc->CalcZoneAirComfortSetPointsFirstTimeFlag = false; } - state.dataHeatBalFanSys->ComfortControlType = HVAC::ThermostatType::Uncontrolled; // Default + s_hbfs->ComfortControlType = HVAC::SetptType::Uncontrolled; // Default for (int RelativeZoneNum = 1; RelativeZoneNum <= state.dataZoneCtrls->NumComfortControlledZones; ++RelativeZoneNum) { - auto &comfortControlledZone = state.dataZoneCtrls->ComfortControlledZone(RelativeZoneNum); - int ActualZoneNum = comfortControlledZone.ActualZoneNum; + auto &comfortZone = state.dataZoneCtrls->ComfortControlledZone(RelativeZoneNum); + int ActualZoneNum = comfortZone.ActualZoneNum; auto &zone = state.dataHeatBal->Zone(ActualZoneNum); - auto &comfortControlType = state.dataHeatBalFanSys->ComfortControlType(ActualZoneNum); - auto &comfortControlTypeRpt = state.dataHeatBalFanSys->ComfortControlTypeRpt(ActualZoneNum); - auto &tempZoneThermostatSetPoint = state.dataHeatBalFanSys->TempZoneThermostatSetPoint(ActualZoneNum); + auto &zoneTstatSetpt = state.dataHeatBalFanSys->zoneTstatSetpts(ActualZoneNum); auto &zoneComfortControlsFanger = state.dataHeatBalFanSys->ZoneComfortControlsFanger(ActualZoneNum); - comfortControlType = - static_cast(ScheduleManager::GetCurrentScheduleValue(state, comfortControlledZone.ComfortSchedIndex)); - comfortControlTypeRpt = static_cast(comfortControlType); + s_hbfs->ComfortControlType(ActualZoneNum) = static_cast(comfortZone.setptTypeSched->getCurrentVal()); + s_hbfs->ComfortControlTypeRpt(ActualZoneNum) = (int)s_hbfs->ComfortControlType(ActualZoneNum); // Get PMV values - switch (comfortControlType) { - case HVAC::ThermostatType::Uncontrolled: + switch (s_hbfs->ComfortControlType(ActualZoneNum)) { + case HVAC::SetptType::Uncontrolled: { zoneComfortControlsFanger.LowPMV = -999.0; zoneComfortControlsFanger.HighPMV = -999.0; - break; - case HVAC::ThermostatType::SingleHeating: - zoneComfortControlsFanger.FangerType = static_cast(HVAC::ThermostatType::SingleHeating); - zoneComfortControlsFanger.LowPMV = ScheduleManager::GetCurrentScheduleValue( - state, - state.dataZoneTempPredictorCorrector - ->SetPointSingleHeatingFanger(comfortControlledZone.ControlTypeSchIndx(comfortControlledZone.SchIndx_SingleHeating)) - .PMVSchedIndex); + } break; + + case HVAC::SetptType::SingleHeat: { + zoneComfortControlsFanger.FangerType = (int)HVAC::SetptType::SingleHeat; + zoneComfortControlsFanger.LowPMV = comfortZone.setpts[(int)HVAC::SetptType::SingleHeat].heatSetptSched->getCurrentVal(); zoneComfortControlsFanger.HighPMV = -999.0; - break; - case HVAC::ThermostatType::SingleCooling: - zoneComfortControlsFanger.FangerType = static_cast(HVAC::ThermostatType::SingleCooling); + } break; + + case HVAC::SetptType::SingleCool: { + zoneComfortControlsFanger.FangerType = (int)HVAC::SetptType::SingleCool; zoneComfortControlsFanger.LowPMV = -999.0; - zoneComfortControlsFanger.HighPMV = ScheduleManager::GetCurrentScheduleValue( - state, - state.dataZoneTempPredictorCorrector - ->SetPointSingleCoolingFanger(comfortControlledZone.ControlTypeSchIndx(comfortControlledZone.SchIndx_SingleCooling)) - .PMVSchedIndex); - break; - case HVAC::ThermostatType::SingleHeatCool: - SetPointComfortSchedIndex = - state.dataZoneTempPredictorCorrector - ->SetPointSingleHeatCoolFanger(comfortControlledZone.ControlTypeSchIndx(comfortControlledZone.SchIndx_SingleHeatCool)) - .PMVSchedIndex; - zoneComfortControlsFanger.FangerType = static_cast(HVAC::ThermostatType::SingleHeatCool); - zoneComfortControlsFanger.LowPMV = ScheduleManager::GetCurrentScheduleValue(state, SetPointComfortSchedIndex); - zoneComfortControlsFanger.HighPMV = ScheduleManager::GetCurrentScheduleValue(state, SetPointComfortSchedIndex); - break; - case HVAC::ThermostatType::DualSetPointWithDeadBand: - SchedTypeIndex = comfortControlledZone.ControlTypeSchIndx(comfortControlledZone.SchIndx_DualSetPointWithDeadBand); - zoneComfortControlsFanger.FangerType = static_cast(HVAC::ThermostatType::DualSetPointWithDeadBand); - zoneComfortControlsFanger.LowPMV = ScheduleManager::GetCurrentScheduleValue( - state, state.dataZoneTempPredictorCorrector->SetPointDualHeatCoolFanger(SchedTypeIndex).HeatPMVSchedIndex); - zoneComfortControlsFanger.HighPMV = ScheduleManager::GetCurrentScheduleValue( - state, state.dataZoneTempPredictorCorrector->SetPointDualHeatCoolFanger(SchedTypeIndex).CoolPMVSchedIndex); + zoneComfortControlsFanger.HighPMV = comfortZone.setpts[(int)HVAC::SetptType::SingleCool].coolSetptSched->getCurrentVal(); + } break; + + case HVAC::SetptType::SingleHeatCool: { + zoneComfortControlsFanger.FangerType = (int)HVAC::SetptType::SingleHeatCool; + zoneComfortControlsFanger.LowPMV = zoneComfortControlsFanger.HighPMV = comfortZone.setpts[(int)HVAC::SetptType::SingleHeatCool].coolSetptSched->getCurrentVal(); + } break; + + case HVAC::SetptType::DualHeatCool: { + zoneComfortControlsFanger.FangerType = (int)HVAC::SetptType::DualHeatCool; + zoneComfortControlsFanger.LowPMV = comfortZone.setpts[(int)HVAC::SetptType::DualHeatCool].heatSetptSched->getCurrentVal(); + zoneComfortControlsFanger.HighPMV = comfortZone.setpts[(int)HVAC::SetptType::DualHeatCool].coolSetptSched->getCurrentVal(); if (zoneComfortControlsFanger.LowPMV > zoneComfortControlsFanger.HighPMV) { ++zoneComfortControlsFanger.DualPMVErrCount; if (zoneComfortControlsFanger.DualPMVErrCount < 2) { ShowWarningError(state, format("ThermostatSetpoint:ThermalComfort:Fanger:DualSetpoint: The heating PMV setpoint is above the " "cooling PMV setpoint in {}", - state.dataZoneTempPredictorCorrector->SetPointDualHeatCoolFanger(SchedTypeIndex).Name)); + comfortZone.setpts[(int)HVAC::SetptType::DualHeatCool].Name)); ShowContinueError(state, "The zone dual heating PMV setpoint is set to the dual cooling PMV setpoint."); ShowContinueErrorTimeStamp(state, "Occurrence info:"); } else { @@ -6404,39 +5833,42 @@ void CalcZoneAirComfortSetPoints(EnergyPlusData &state) } zoneComfortControlsFanger.LowPMV = zoneComfortControlsFanger.HighPMV; } - break; - default: + } break; + + default: { ShowSevereError(state, format("CalcZoneAirTempSetpoints: Illegal thermal control control type for Zone={}, Found value={}, in Schedule={}", zone.Name, - comfortControlTypeRpt, - comfortControlledZone.ControlTypeSchedName)); - break; - } + s_hbfs->ComfortControlTypeRpt(ActualZoneNum), + comfortZone.setptTypeSched->Name)); + } break; + } // switch // Check Average method - switch (comfortControlledZone.AverageMethod) { - case DataZoneControls::AverageMethod::NO: - PeopleNum = comfortControlledZone.SpecificObjectNum; - if (comfortControlType == HVAC::ThermostatType::SingleCooling) { + switch (comfortZone.AverageMethod) { + case DataZoneControls::AverageMethod::NO: { + PeopleNum = comfortZone.SpecificObjectNum; + if (s_hbfs->ComfortControlType(ActualZoneNum) == HVAC::SetptType::SingleCool) { GetComfortSetPoints(state, PeopleNum, RelativeZoneNum, zoneComfortControlsFanger.HighPMV, SetPointLo); } else { GetComfortSetPoints(state, PeopleNum, RelativeZoneNum, zoneComfortControlsFanger.LowPMV, SetPointLo); } - if (comfortControlType == HVAC::ThermostatType::DualSetPointWithDeadBand) + if (s_hbfs->ComfortControlType(ActualZoneNum) == HVAC::SetptType::DualHeatCool) GetComfortSetPoints(state, PeopleNum, RelativeZoneNum, zoneComfortControlsFanger.HighPMV, SetPointHi); - break; - case DataZoneControls::AverageMethod::SPE: - PeopleNum = comfortControlledZone.SpecificObjectNum; - if (comfortControlType == HVAC::ThermostatType::SingleCooling) { + } break; + + case DataZoneControls::AverageMethod::SPE: { + PeopleNum = comfortZone.SpecificObjectNum; + if (s_hbfs->ComfortControlType(ActualZoneNum) == HVAC::SetptType::SingleCool) { GetComfortSetPoints(state, PeopleNum, RelativeZoneNum, zoneComfortControlsFanger.HighPMV, SetPointLo); } else { GetComfortSetPoints(state, PeopleNum, RelativeZoneNum, zoneComfortControlsFanger.LowPMV, SetPointLo); } - if (comfortControlType == HVAC::ThermostatType::DualSetPointWithDeadBand) + if (s_hbfs->ComfortControlType(ActualZoneNum) == HVAC::SetptType::DualHeatCool) GetComfortSetPoints(state, PeopleNum, RelativeZoneNum, zoneComfortControlsFanger.HighPMV, SetPointHi); - break; - case DataZoneControls::AverageMethod::OBJ: + } break; + + case DataZoneControls::AverageMethod::OBJ: { SetPointLo = 0.0; SetPointHi = 0.0; for (int PeopleNum = 1; PeopleNum <= state.dataHeatBal->TotPeople; ++PeopleNum) { @@ -6444,26 +5876,27 @@ void CalcZoneAirComfortSetPoints(EnergyPlusData &state) ++ObjectCount; GetComfortSetPoints(state, PeopleNum, RelativeZoneNum, zoneComfortControlsFanger.LowPMV, Tset); SetPointLo += Tset; - if (comfortControlType == HVAC::ThermostatType::DualSetPointWithDeadBand) { + if (s_hbfs->ComfortControlType(ActualZoneNum) == HVAC::SetptType::DualHeatCool) { GetComfortSetPoints(state, PeopleNum, RelativeZoneNum, zoneComfortControlsFanger.HighPMV, Tset); SetPointHi += Tset; } } } SetPointLo /= ObjectCount; - if (comfortControlType == HVAC::ThermostatType::DualSetPointWithDeadBand) SetPointHi /= ObjectCount; - break; - case DataZoneControls::AverageMethod::PEO: + if (s_hbfs->ComfortControlType(ActualZoneNum) == HVAC::SetptType::DualHeatCool) SetPointHi /= ObjectCount; + } break; + + case DataZoneControls::AverageMethod::PEO: { SetPointLo = 0.0; SetPointHi = 0.0; for (int PeopleNum = 1; PeopleNum <= state.dataHeatBal->TotPeople; ++PeopleNum) { if (ActualZoneNum == state.dataHeatBal->People(PeopleNum).ZonePtr) { int NumberOccupants = state.dataHeatBal->People(PeopleNum).NumberOfPeople * - ScheduleManager::GetCurrentScheduleValue(state, state.dataHeatBal->People(PeopleNum).NumberOfPeoplePtr); + state.dataHeatBal->People(PeopleNum).numberOfPeopleSched->getCurrentVal(); PeopleCount += NumberOccupants; GetComfortSetPoints(state, PeopleNum, RelativeZoneNum, zoneComfortControlsFanger.LowPMV, Tset); SetPointLo += Tset * NumberOccupants; - if (comfortControlType == HVAC::ThermostatType::DualSetPointWithDeadBand) { + if (s_hbfs->ComfortControlType(ActualZoneNum) == HVAC::SetptType::DualHeatCool) { GetComfortSetPoints(state, PeopleNum, RelativeZoneNum, zoneComfortControlsFanger.HighPMV, Tset); SetPointHi += Tset * NumberOccupants; } @@ -6471,9 +5904,9 @@ void CalcZoneAirComfortSetPoints(EnergyPlusData &state) } if (PeopleCount > 0) { SetPointLo /= PeopleCount; - if (comfortControlType == HVAC::ThermostatType::DualSetPointWithDeadBand) SetPointHi /= PeopleCount; + if (s_hbfs->ComfortControlType(ActualZoneNum) == HVAC::SetptType::DualHeatCool) SetPointHi /= PeopleCount; } else { - if (comfortControlledZone.PeopleAverageErrIndex == 0) { + if (comfortZone.PeopleAverageErrIndex == 0) { ShowWarningMessage(state, format("ZoneControl:Thermostat:ThermalComfort: The total number of people in Zone = {} is zero. The People " "Average option is not used.", @@ -6484,7 +5917,7 @@ void CalcZoneAirComfortSetPoints(EnergyPlusData &state) ShowRecurringWarningErrorAtEnd(state, "ZoneControl:Thermostat:ThermalComfort: The total number of people in Zone = " + zone.Name + " is still zero. The People Average option is not used", - comfortControlledZone.PeopleAverageErrIndex, + comfortZone.PeopleAverageErrIndex, PeopleCount, PeopleCount); SetPointLo = 0.0; @@ -6494,92 +5927,97 @@ void CalcZoneAirComfortSetPoints(EnergyPlusData &state) ++ObjectCount; GetComfortSetPoints(state, PeopleNum, RelativeZoneNum, zoneComfortControlsFanger.LowPMV, Tset); SetPointLo += Tset; - if (comfortControlType == HVAC::ThermostatType::DualSetPointWithDeadBand) { + if (s_hbfs->ComfortControlType(ActualZoneNum) == HVAC::SetptType::DualHeatCool) { GetComfortSetPoints(state, PeopleNum, RelativeZoneNum, zoneComfortControlsFanger.HighPMV, Tset); SetPointHi += Tset; } } } SetPointLo /= ObjectCount; - if (comfortControlType == HVAC::ThermostatType::DualSetPointWithDeadBand) SetPointHi /= ObjectCount; + if (s_hbfs->ComfortControlType(ActualZoneNum) == HVAC::SetptType::DualHeatCool) SetPointHi /= ObjectCount; } - break; - default: - break; - } + } break; + + default: { + } break; + } // switch // Assign setpoint - switch (comfortControlType) { - case HVAC::ThermostatType::Uncontrolled: + switch (s_hbfs->ComfortControlType(ActualZoneNum)) { + + case HVAC::SetptType::Uncontrolled: { switch (state.dataHeatBalFanSys->TempControlType(ActualZoneNum)) { - case HVAC::ThermostatType::SingleHeating: - state.dataHeatBalFanSys->ZoneThermostatSetPointHi(ActualZoneNum) = 0.0; + case HVAC::SetptType::SingleHeat: + zoneTstatSetpt.setptHi = 0.0; break; - case HVAC::ThermostatType::SingleCooling: - state.dataHeatBalFanSys->ZoneThermostatSetPointLo(ActualZoneNum) = 0.0; + case HVAC::SetptType::SingleCool: + zoneTstatSetpt.setptLo = 0.0; break; default: break; } - break; - case HVAC::ThermostatType::SingleHeating: - if (SetPointLo < comfortControlledZone.TdbMinSetPoint) { - SetPointLo = comfortControlledZone.TdbMinSetPoint; - if (comfortControlledZone.TdbMinErrIndex < 2) { + } break; + + case HVAC::SetptType::SingleHeat: { + if (SetPointLo < comfortZone.TdbMinSetPoint) { + SetPointLo = comfortZone.TdbMinSetPoint; + if (comfortZone.TdbMinErrIndex < 2) { ShowWarningMessage(state, format("ThermostatSetpoint:ThermalComfort:Fanger:SingleHeating temperature is below the Minimum dry-bulb " "temperature setpoint {}", - comfortControlledZone.Name)); + comfortZone.Name)); ShowContinueError(state, "The zone heating setpoint is set to the Minimum dry-bulb temperature setpoint"); ShowContinueErrorTimeStamp(state, "Occurrence info:"); } ShowRecurringWarningErrorAtEnd(state, "ThermostatSetpoint:ThermalComfort:Fanger:SingleHeating temperature is still below the " "Minimum dry-bulb temperature setpoint ...", - comfortControlledZone.TdbMinErrIndex, + comfortZone.TdbMinErrIndex, SetPointLo, SetPointLo); } - tempZoneThermostatSetPoint = SetPointLo; - state.dataHeatBalFanSys->ZoneThermostatSetPointLo(ActualZoneNum) = tempZoneThermostatSetPoint; - state.dataHeatBalFanSys->TempControlType(ActualZoneNum) = HVAC::ThermostatType::SingleHeating; + zoneTstatSetpt.setpt = SetPointLo; + zoneTstatSetpt.setptLo = zoneTstatSetpt.setpt; + state.dataHeatBalFanSys->TempControlType(ActualZoneNum) = HVAC::SetptType::SingleHeat; state.dataHeatBalFanSys->TempControlTypeRpt(ActualZoneNum) = static_cast(state.dataHeatBalFanSys->TempControlType(ActualZoneNum)); - break; - case HVAC::ThermostatType::SingleCooling: - if (SetPointLo > comfortControlledZone.TdbMaxSetPoint) { - SetPointLo = comfortControlledZone.TdbMaxSetPoint; - if (comfortControlledZone.TdbMaxErrIndex == 0) { + } break; + + case HVAC::SetptType::SingleCool: { + if (SetPointLo > comfortZone.TdbMaxSetPoint) { + SetPointLo = comfortZone.TdbMaxSetPoint; + if (comfortZone.TdbMaxErrIndex == 0) { ShowWarningMessage(state, format("ThermostatSetpoint:ThermalComfort:Fanger:SingleCooling temperature is above the Maximum dry-bulb " "temperature setpoint {}", - comfortControlledZone.Name)); + comfortZone.Name)); ShowContinueError(state, "The zone cooling setpoint is set to the Maximum dry-bulb temperature setpoint"); ShowContinueErrorTimeStamp(state, "Occurrence info:"); } ShowRecurringWarningErrorAtEnd(state, "ThermostatSetpoint:ThermalComfort:Fanger:SingleCooling temperature is still above the " "Maximum dry-bulb temperature setpoint ...", - comfortControlledZone.TdbMaxErrIndex, + comfortZone.TdbMaxErrIndex, SetPointLo, SetPointLo); } - tempZoneThermostatSetPoint = SetPointLo; - state.dataHeatBalFanSys->ZoneThermostatSetPointHi(ActualZoneNum) = tempZoneThermostatSetPoint; - state.dataHeatBalFanSys->TempControlType(ActualZoneNum) = HVAC::ThermostatType::SingleCooling; + zoneTstatSetpt.setpt = SetPointLo; + zoneTstatSetpt.setptHi = zoneTstatSetpt.setpt; + state.dataHeatBalFanSys->TempControlType(ActualZoneNum) = HVAC::SetptType::SingleCool; state.dataHeatBalFanSys->TempControlTypeRpt(ActualZoneNum) = static_cast(state.dataHeatBalFanSys->TempControlType(ActualZoneNum)); - break; - case HVAC::ThermostatType::SingleHeatCool: - if (comfortControlledZone.TdbMaxSetPoint == comfortControlledZone.TdbMinSetPoint) { - SetPointLo = comfortControlledZone.TdbMaxSetPoint; - } - if (SetPointLo > comfortControlledZone.TdbMaxSetPoint) SetPointLo = comfortControlledZone.TdbMaxSetPoint; - if (SetPointLo < comfortControlledZone.TdbMinSetPoint) SetPointLo = comfortControlledZone.TdbMinSetPoint; - if (SetPointLo < comfortControlledZone.TdbMinSetPoint || SetPointLo > comfortControlledZone.TdbMaxSetPoint) { - if (comfortControlledZone.TdbHCErrIndex == 0) { + } break; + + case HVAC::SetptType::SingleHeatCool: { + if (comfortZone.TdbMaxSetPoint == comfortZone.TdbMinSetPoint) { + SetPointLo = comfortZone.TdbMaxSetPoint; + } + if (SetPointLo > comfortZone.TdbMaxSetPoint) SetPointLo = comfortZone.TdbMaxSetPoint; + if (SetPointLo < comfortZone.TdbMinSetPoint) SetPointLo = comfortZone.TdbMinSetPoint; + if (SetPointLo < comfortZone.TdbMinSetPoint || SetPointLo > comfortZone.TdbMaxSetPoint) { + if (comfortZone.TdbHCErrIndex == 0) { ShowWarningMessage(state, format("ThermostatSetpoint:ThermalComfort:Fanger:SingleHeatingOrCooling temperature is above the Maximum or " "below the Minimum dry-bulb temperature setpoint {}", - comfortControlledZone.Name)); + comfortZone.Name)); ShowContinueError(state, "The zone setpoint is set to the Maximum dry-bulb temperature setpoint if above or the Minimum " "dry-bulb temperature setpoint if below"); @@ -6588,67 +6026,70 @@ void CalcZoneAirComfortSetPoints(EnergyPlusData &state) ShowRecurringWarningErrorAtEnd(state, "ThermostatSetpoint:ThermalComfort:Fanger:SingleHeatingOrCooling temperature is still beyond " "the range between Maximum and Minimum dry-bulb temperature setpoint ...", - comfortControlledZone.TdbHCErrIndex, + comfortZone.TdbHCErrIndex, SetPointLo, SetPointLo); } - tempZoneThermostatSetPoint = SetPointLo; - state.dataHeatBalFanSys->ZoneThermostatSetPointHi(ActualZoneNum) = tempZoneThermostatSetPoint; - state.dataHeatBalFanSys->ZoneThermostatSetPointLo(ActualZoneNum) = tempZoneThermostatSetPoint; - state.dataHeatBalFanSys->TempControlType(ActualZoneNum) = HVAC::ThermostatType::SingleHeatCool; + + zoneTstatSetpt.setpt = SetPointLo; + zoneTstatSetpt.setptHi = zoneTstatSetpt.setptLo = zoneTstatSetpt.setpt; + state.dataHeatBalFanSys->TempControlType(ActualZoneNum) = HVAC::SetptType::SingleHeatCool; state.dataHeatBalFanSys->TempControlTypeRpt(ActualZoneNum) = static_cast(state.dataHeatBalFanSys->TempControlType(ActualZoneNum)); - break; - case HVAC::ThermostatType::DualSetPointWithDeadBand: - if (SetPointLo < comfortControlledZone.TdbMinSetPoint) { - SetPointLo = comfortControlledZone.TdbMinSetPoint; + } break; + + case HVAC::SetptType::DualHeatCool: { + if (SetPointLo < comfortZone.TdbMinSetPoint) { + SetPointLo = comfortZone.TdbMinSetPoint; - if (comfortControlledZone.TdbDualMinErrIndex == 0) { + if (comfortZone.TdbDualMinErrIndex == 0) { ShowWarningMessage(state, format("ThermostatSetpoint:ThermalComfort:Fanger:DualSetpoint temperature is below the Minimum dry-bulb " "temperature setpoint {}", - comfortControlledZone.Name)); + comfortZone.Name)); ShowContinueError(state, "The zone dual heating setpoint is set to the Minimum dry-bulb temperature setpoint"); ShowContinueErrorTimeStamp(state, "Occurrence info:"); } ShowRecurringWarningErrorAtEnd(state, "ThermostatSetpoint:ThermalComfort:Fanger:DualSetpoint temperature is still below the Minimum " "dry-bulb temperature setpoint ...", - comfortControlledZone.TdbDualMinErrIndex, + comfortZone.TdbDualMinErrIndex, SetPointLo, SetPointLo); } - if (SetPointHi > comfortControlledZone.TdbMaxSetPoint) { - SetPointHi = comfortControlledZone.TdbMaxSetPoint; - if (comfortControlledZone.TdbDualMaxErrIndex == 0) { + if (SetPointHi > comfortZone.TdbMaxSetPoint) { + SetPointHi = comfortZone.TdbMaxSetPoint; + if (comfortZone.TdbDualMaxErrIndex == 0) { ShowWarningMessage(state, format("ThermostatSetpoint:ThermalComfort:Fanger:DualSetpoint temperature is above the Maximum dry-bulb " "temperature setpoint in zone = {}", - comfortControlledZone.Name)); + comfortZone.Name)); ShowContinueError(state, "The zone dual cooling setpoint is set to the Maximum dry-bulb temperature setpoint"); ShowContinueErrorTimeStamp(state, "Occurrence info:"); } ShowRecurringWarningErrorAtEnd(state, "ThermostatSetpoint:ThermalComfort:Fanger:DualSetpoint temperature is still above the Maximum " "dry-bulb temperature setpoint ...", - comfortControlledZone.TdbDualMaxErrIndex, + comfortZone.TdbDualMaxErrIndex, SetPointLo, SetPointLo); } - state.dataHeatBalFanSys->ZoneThermostatSetPointLo(ActualZoneNum) = SetPointLo; - state.dataHeatBalFanSys->ZoneThermostatSetPointHi(ActualZoneNum) = SetPointHi; - state.dataHeatBalFanSys->TempControlType(ActualZoneNum) = HVAC::ThermostatType::DualSetPointWithDeadBand; + zoneTstatSetpt.setptLo = SetPointLo; + zoneTstatSetpt.setptHi = SetPointHi; + state.dataHeatBalFanSys->TempControlType(ActualZoneNum) = HVAC::SetptType::DualHeatCool; state.dataHeatBalFanSys->TempControlTypeRpt(ActualZoneNum) = static_cast(state.dataHeatBalFanSys->TempControlType(ActualZoneNum)); - break; - default: + } break; + + default: { ShowSevereError(state, format("CalcZoneAirComfortSetpoints: Illegal thermal control control type for Zone={}, Found value={}, in Schedule={}", zone.Name, - comfortControlTypeRpt, - comfortControlledZone.ControlTypeSchedName)); - } + s_hbfs->ComfortControlTypeRpt(ActualZoneNum), + comfortZone.setptTypeSched->Name)); + } break; + } // switch () } -} +} // CalcZoneAirComfortSetpoints() void GetComfortSetPoints(EnergyPlusData &state, int const PeopleNum, @@ -6676,6 +6117,8 @@ void GetComfortSetPoints(EnergyPlusData &state, Real64 PMVResult = 0.0; // Calculated PMV value int SolFla = 0; // feed back flag from SolveRoot + auto &s_ztpc = state.dataZoneTempPredictorCorrector; + auto &comfortControlledZone = state.dataZoneCtrls->ComfortControlledZone(ComfortControlNum); Real64 Tmin = comfortControlledZone.TdbMinSetPoint; Real64 Tmax = comfortControlledZone.TdbMaxSetPoint; @@ -6695,8 +6138,8 @@ void GetComfortSetPoints(EnergyPlusData &state, General::SolveRoot(state, Acc, MaxIter, SolFla, Tset, f, Tmin, Tmax); if (SolFla == -1) { if (!state.dataGlobal->WarmupFlag) { - ++state.dataZoneTempPredictorCorrector->IterLimitExceededNum1; - if (state.dataZoneTempPredictorCorrector->IterLimitExceededNum1 == 1) { + ++s_ztpc->IterLimitExceededNum1; + if (s_ztpc->IterLimitExceededNum1 == 1) { ShowWarningError( state, format("{}: Iteration limit exceeded calculating thermal comfort Fanger setpoint and non-converged setpoint is used", @@ -6704,15 +6147,15 @@ void GetComfortSetPoints(EnergyPlusData &state, } else { ShowRecurringWarningErrorAtEnd(state, comfortControlledZone.Name + ": Iteration limit exceeded calculating thermal comfort setpoint.", - state.dataZoneTempPredictorCorrector->IterLimitErrIndex1, + s_ztpc->IterLimitErrIndex1, Tset, Tset); } } } else if (SolFla == -2) { if (!state.dataGlobal->WarmupFlag) { - ++state.dataZoneTempPredictorCorrector->IterLimitExceededNum2; - if (state.dataZoneTempPredictorCorrector->IterLimitExceededNum2 == 1) { + ++s_ztpc->IterLimitExceededNum2; + if (s_ztpc->IterLimitExceededNum2 == 1) { ShowWarningError( state, format("{}: Solution is not found in calculating thermal comfort Fanger setpoint and the minimum setpoint is used", @@ -6721,7 +6164,7 @@ void GetComfortSetPoints(EnergyPlusData &state, ShowRecurringWarningErrorAtEnd( state, format("{}: Solution is not found in calculating thermal comfort Fanger setpoint.", comfortControlledZone.Name), - state.dataZoneTempPredictorCorrector->IterLimitErrIndex2, + s_ztpc->IterLimitErrIndex2, Tset, Tset); } @@ -6748,31 +6191,32 @@ void AdjustCoolingSetPointforTempAndHumidityControl(EnergyPlusData &state, // Alter the zone air cooling setpoint if the zone air relative humidity value exceeds the the zone dehumidifying relative humidity setpoint. Real64 ZoneOvercoolRange = 0.0; - auto &tempControlledZone = state.dataZoneCtrls->TempControlledZone(TempControlledZoneID); - if (!(state.dataZoneCtrls->AnyZoneTempAndHumidityControl)) return; // do nothing to setpoint - if (!(tempControlledZone.ZoneOvercoolControl)) return; // do nothing to setpoint + auto const &s_ztpc = state.dataZoneTempPredictorCorrector; + auto &tempZone = state.dataZoneCtrls->TempControlledZone(TempControlledZoneID); + auto &zoneTstatSetpt = state.dataHeatBalFanSys->zoneTstatSetpts(ActualZoneNum); + + if (!state.dataZoneCtrls->AnyZoneTempAndHumidityControl) return; // do nothing to setpoint + if (!tempZone.ZoneOvercoolControl) return; // do nothing to setpoint - if (tempControlledZone.OvercoolCntrlModeScheduled) { - ZoneOvercoolRange = ScheduleManager::GetCurrentScheduleValue(state, tempControlledZone.ZoneOvercoolRangeSchedIndex); + if (tempZone.OvercoolCntrlModeScheduled) { + ZoneOvercoolRange = tempZone.zoneOvercoolRangeSched->getCurrentVal(); } else { - ZoneOvercoolRange = tempControlledZone.ZoneOvercoolConstRange; + ZoneOvercoolRange = tempZone.ZoneOvercoolConstRange; } - Real64 ZoneOvercoolControlRatio = tempControlledZone.ZoneOvercoolControlRatio; + Real64 ZoneOvercoolControlRatio = tempZone.ZoneOvercoolControlRatio; // For Dual Setpoint thermostat the overcool range is limited by the temperature difference between cooling and heating setpoints - Real64 MaxAllowedOvercoolRange = - state.dataHeatBalFanSys->ZoneThermostatSetPointHi(ActualZoneNum) - state.dataHeatBalFanSys->ZoneThermostatSetPointLo(ActualZoneNum); + Real64 MaxAllowedOvercoolRange = zoneTstatSetpt.setptHi - zoneTstatSetpt.setptLo; if (MaxAllowedOvercoolRange > 0.0) { ZoneOvercoolRange = min(ZoneOvercoolRange, MaxAllowedOvercoolRange); } // Calculate difference between zone air relative humidity and the dehumidifying setpoint - Real64 RelativeHumidityDiff = state.dataZoneTempPredictorCorrector->zoneHeatBalance(ActualZoneNum).airRelHum - - ScheduleManager::GetCurrentScheduleValue(state, tempControlledZone.DehumidifyingSchedIndex); + Real64 RelativeHumidityDiff = s_ztpc->zoneHeatBalance(ActualZoneNum).airRelHum - tempZone.dehumidifyingSched->getCurrentVal(); if (RelativeHumidityDiff > 0.0 && ZoneOvercoolControlRatio > 0.0) { // proportionally reset the cooling setpoint temperature downward (zone Overcool) ZoneOvercoolRange = min(ZoneOvercoolRange, RelativeHumidityDiff / ZoneOvercoolControlRatio); - state.dataHeatBalFanSys->ZoneThermostatSetPointHi(ActualZoneNum) -= ZoneOvercoolRange; + zoneTstatSetpt.setptHi -= ZoneOvercoolRange; } } @@ -6785,90 +6229,90 @@ void OverrideAirSetPointsforEMSCntrl(EnergyPlusData &state) // PURPOSE OF THIS SUBROUTINE: // This subroutine overrides the air temperature setpoint based on EMS - - auto &ZoneThermostatSetPointLo = state.dataHeatBalFanSys->ZoneThermostatSetPointLo; - auto &ZoneThermostatSetPointHi = state.dataHeatBalFanSys->ZoneThermostatSetPointHi; + auto const &s_hbfs = state.dataHeatBalFanSys; for (int Loop = 1; Loop <= state.dataZoneCtrls->NumTempControlledZones; ++Loop) { - auto &tempControlledZone = state.dataZoneCtrls->TempControlledZone(Loop); - if (tempControlledZone.EMSOverrideHeatingSetPointOn) { - int ZoneNum = tempControlledZone.ActualZoneNum; - - switch (state.dataHeatBalFanSys->TempControlType(ZoneNum)) { - case HVAC::ThermostatType::SingleHeating: - state.dataHeatBalFanSys->TempZoneThermostatSetPoint(ZoneNum) = tempControlledZone.EMSOverrideHeatingSetPointValue; - ZoneThermostatSetPointLo(ZoneNum) = tempControlledZone.EMSOverrideHeatingSetPointValue; - break; - case HVAC::ThermostatType::SingleHeatCool: - state.dataHeatBalFanSys->TempZoneThermostatSetPoint(ZoneNum) = tempControlledZone.EMSOverrideHeatingSetPointValue; - ZoneThermostatSetPointLo(ZoneNum) = tempControlledZone.EMSOverrideHeatingSetPointValue; - break; - case HVAC::ThermostatType::DualSetPointWithDeadBand: - ZoneThermostatSetPointLo(ZoneNum) = tempControlledZone.EMSOverrideHeatingSetPointValue; - break; - default: - break; - } - } - if (tempControlledZone.EMSOverrideCoolingSetPointOn) { - int ZoneNum = tempControlledZone.ActualZoneNum; - + auto &tempZone = state.dataZoneCtrls->TempControlledZone(Loop); + if (tempZone.EMSOverrideHeatingSetPointOn) { + int ZoneNum = tempZone.ActualZoneNum; + auto &zoneTstatSetpt = s_hbfs->zoneTstatSetpts(ZoneNum); + switch (state.dataHeatBalFanSys->TempControlType(ZoneNum)) { - case HVAC::ThermostatType::SingleCooling: - state.dataHeatBalFanSys->TempZoneThermostatSetPoint(ZoneNum) = tempControlledZone.EMSOverrideCoolingSetPointValue; - ZoneThermostatSetPointHi(ZoneNum) = tempControlledZone.EMSOverrideCoolingSetPointValue; - break; - case HVAC::ThermostatType::SingleHeatCool: - state.dataHeatBalFanSys->TempZoneThermostatSetPoint(ZoneNum) = tempControlledZone.EMSOverrideCoolingSetPointValue; - ZoneThermostatSetPointHi(ZoneNum) = tempControlledZone.EMSOverrideCoolingSetPointValue; - break; - case HVAC::ThermostatType::DualSetPointWithDeadBand: - ZoneThermostatSetPointHi(ZoneNum) = tempControlledZone.EMSOverrideCoolingSetPointValue; - break; - default: - break; - } + case HVAC::SetptType::SingleHeat: + case HVAC::SetptType::SingleHeatCool: { + zoneTstatSetpt.setptLo = zoneTstatSetpt.setpt = tempZone.EMSOverrideHeatingSetPointValue; + } break; + + case HVAC::SetptType::DualHeatCool: { + zoneTstatSetpt.setptLo = tempZone.EMSOverrideHeatingSetPointValue; + } break; + + default: { + } break; + } // switch () + } + + if (tempZone.EMSOverrideCoolingSetPointOn) { + int ZoneNum = tempZone.ActualZoneNum; + auto &zoneTstatSetpt = s_hbfs->zoneTstatSetpts(ZoneNum); + + switch (s_hbfs->TempControlType(ZoneNum)) { + case HVAC::SetptType::SingleCool: + case HVAC::SetptType::SingleHeatCool: { + zoneTstatSetpt.setptHi = zoneTstatSetpt.setpt = tempZone.EMSOverrideCoolingSetPointValue; + } break; + + case HVAC::SetptType::DualHeatCool: { + zoneTstatSetpt.setptHi = tempZone.EMSOverrideCoolingSetPointValue; + } break; + + default: { + } break; + } // switch () } } for (int Loop = 1; Loop <= state.dataZoneCtrls->NumComfortControlledZones; ++Loop) { - auto &comfortControlledZone = state.dataZoneCtrls->ComfortControlledZone(Loop); - if (comfortControlledZone.EMSOverrideHeatingSetPointOn) { - int ZoneNum = comfortControlledZone.ActualZoneNum; - switch (state.dataHeatBalFanSys->ComfortControlType(ZoneNum)) { - case HVAC::ThermostatType::SingleHeating: - state.dataHeatBalFanSys->TempZoneThermostatSetPoint(ZoneNum) = comfortControlledZone.EMSOverrideHeatingSetPointValue; - ZoneThermostatSetPointLo(ZoneNum) = comfortControlledZone.EMSOverrideHeatingSetPointValue; - break; - case HVAC::ThermostatType::SingleHeatCool: - state.dataHeatBalFanSys->TempZoneThermostatSetPoint(ZoneNum) = comfortControlledZone.EMSOverrideHeatingSetPointValue; - ZoneThermostatSetPointLo(ZoneNum) = comfortControlledZone.EMSOverrideHeatingSetPointValue; - break; - case HVAC::ThermostatType::DualSetPointWithDeadBand: - ZoneThermostatSetPointLo(ZoneNum) = comfortControlledZone.EMSOverrideHeatingSetPointValue; - break; - default: - break; - } - } - - if (comfortControlledZone.EMSOverrideCoolingSetPointOn) { - int ZoneNum = comfortControlledZone.ActualZoneNum; - switch (static_cast(state.dataHeatBalFanSys->ComfortControlType(ZoneNum))) { - case HVAC::ThermostatType::SingleCooling: - state.dataHeatBalFanSys->TempZoneThermostatSetPoint(ZoneNum) = comfortControlledZone.EMSOverrideCoolingSetPointValue; - ZoneThermostatSetPointHi(ZoneNum) = comfortControlledZone.EMSOverrideCoolingSetPointValue; - break; - case HVAC::ThermostatType::SingleHeatCool: - state.dataHeatBalFanSys->TempZoneThermostatSetPoint(ZoneNum) = comfortControlledZone.EMSOverrideCoolingSetPointValue; - ZoneThermostatSetPointHi(ZoneNum) = comfortControlledZone.EMSOverrideCoolingSetPointValue; - break; - case HVAC::ThermostatType::DualSetPointWithDeadBand: - ZoneThermostatSetPointHi(ZoneNum) = comfortControlledZone.EMSOverrideCoolingSetPointValue; - break; - default: - break; - } + auto &comfortZone = state.dataZoneCtrls->ComfortControlledZone(Loop); + if (comfortZone.EMSOverrideHeatingSetPointOn) { + int ZoneNum = comfortZone.ActualZoneNum; + auto &zoneTstatSetpt = s_hbfs->zoneTstatSetpts(ZoneNum); + + switch (s_hbfs->ComfortControlType(ZoneNum)) { + case HVAC::SetptType::SingleHeat: + case HVAC::SetptType::SingleHeatCool: { + zoneTstatSetpt.setptLo = zoneTstatSetpt.setpt = comfortZone.EMSOverrideHeatingSetPointValue; + } break; + + case HVAC::SetptType::DualHeatCool: { + zoneTstatSetpt.setptLo = comfortZone.EMSOverrideHeatingSetPointValue; + } break; + + default: { + } break; + + } // switch () + } + + if (comfortZone.EMSOverrideCoolingSetPointOn) { + + int ZoneNum = comfortZone.ActualZoneNum; + auto &zoneTstatSetpt = s_hbfs->zoneTstatSetpts(ZoneNum); + + switch (static_cast(s_hbfs->ComfortControlType(ZoneNum))) { + case HVAC::SetptType::SingleCool: + case HVAC::SetptType::SingleHeatCool: { + zoneTstatSetpt.setptHi = zoneTstatSetpt.setpt = comfortZone.EMSOverrideCoolingSetPointValue; + } break; + + case HVAC::SetptType::DualHeatCool: { + zoneTstatSetpt.setptHi = comfortZone.EMSOverrideCoolingSetPointValue; + } break; + + default: { + } break; + + } // switch () } } } @@ -6878,239 +6322,154 @@ void FillPredefinedTableOnThermostatSetpoints(EnergyPlusData &state) { // J.Glazer - Aug 2017 using namespace OutputReportPredefined; + auto &s_ztpc = state.dataZoneTempPredictorCorrector; + std::vector uniqSch; uniqSch.reserve( - state.dataZoneTempPredictorCorrector->NumSingleTempHeatingControls + state.dataZoneTempPredictorCorrector->NumSingleTempCoolingControls + - state.dataZoneTempPredictorCorrector->NumSingleTempHeatCoolControls + state.dataZoneTempPredictorCorrector->NumDualTempHeatCoolControls * 2); + s_ztpc->NumTempControls[(int)HVAC::SetptType::SingleHeat] + + s_ztpc->NumTempControls[(int)HVAC::SetptType::SingleCool] + + s_ztpc->NumTempControls[(int)HVAC::SetptType::SingleHeatCool] + + s_ztpc->NumTempControls[(int)HVAC::SetptType::DualHeatCool] * 2); + Real64 setPointAt11; Real64 setPointAt23; int numDays; std::string monthAssumed; std::string monthAssumed2; - constexpr int wednesday = 4; - - for (int idx = 1; idx <= state.dataZoneTempPredictorCorrector->NumSingleTempHeatingControls; ++idx) { - auto &singleHtgSetpoint = state.dataZoneTempPredictorCorrector->SetPointSingleHeating(idx); - if (std::find(uniqSch.begin(), uniqSch.end(), singleHtgSetpoint.TempSchedIndex) == uniqSch.end()) { - uniqSch.emplace_back(singleHtgSetpoint.TempSchedIndex); - PreDefTableEntry(state, state.dataOutRptPredefined->pdChLeedSchStPtFirstObjUsed, singleHtgSetpoint.TempSchedName, singleHtgSetpoint.Name); - - std::tie(setPointAt11, numDays, monthAssumed) = temperatureAndCountInSch(state, singleHtgSetpoint.TempSchedIndex, false, wednesday, 11); - PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSchStPt11amWednesday, singleHtgSetpoint.TempSchedName, setPointAt11); - PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSchStPt11amWedCnt, singleHtgSetpoint.TempSchedName, numDays); - - std::tie(setPointAt23, numDays, monthAssumed) = temperatureAndCountInSch(state, singleHtgSetpoint.TempSchedIndex, false, wednesday, 23); - PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSchStPt11pmWednesday, singleHtgSetpoint.TempSchedName, setPointAt23); - PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSchStPt11pmWedCnt, singleHtgSetpoint.TempSchedName, numDays); - - PreDefTableEntry(state, state.dataOutRptPredefined->pdChLeedSchStPtMonthUsed, singleHtgSetpoint.TempSchedName, monthAssumed); - } - } - for (int idx = 1; idx <= state.dataZoneTempPredictorCorrector->NumSingleTempCoolingControls; ++idx) { - auto &singleClgSetpoint = state.dataZoneTempPredictorCorrector->SetPointSingleCooling(idx); - if (std::find(uniqSch.begin(), uniqSch.end(), singleClgSetpoint.TempSchedIndex) == uniqSch.end()) { - uniqSch.emplace_back(singleClgSetpoint.TempSchedIndex); - PreDefTableEntry(state, state.dataOutRptPredefined->pdChLeedSchStPtFirstObjUsed, singleClgSetpoint.TempSchedName, singleClgSetpoint.Name); - std::tie(setPointAt11, numDays, monthAssumed) = temperatureAndCountInSch(state, singleClgSetpoint.TempSchedIndex, true, wednesday, 11); - PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSchStPt11amWednesday, singleClgSetpoint.TempSchedName, setPointAt11); - PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSchStPt11amWedCnt, singleClgSetpoint.TempSchedName, numDays); - - std::tie(setPointAt23, numDays, monthAssumed) = temperatureAndCountInSch(state, singleClgSetpoint.TempSchedIndex, true, wednesday, 23); - PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSchStPt11pmWednesday, singleClgSetpoint.TempSchedName, setPointAt23); - PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSchStPt11pmWedCnt, singleClgSetpoint.TempSchedName, numDays); - - PreDefTableEntry(state, state.dataOutRptPredefined->pdChLeedSchStPtMonthUsed, singleClgSetpoint.TempSchedName, monthAssumed); - } - } - for (int idx = 1; idx <= state.dataZoneTempPredictorCorrector->NumSingleTempHeatCoolControls; ++idx) { - auto &singleHeatCoolSetpoint = state.dataZoneTempPredictorCorrector->SetPointSingleHeatCool(idx); - if (std::find(uniqSch.begin(), uniqSch.end(), singleHeatCoolSetpoint.TempSchedIndex) == uniqSch.end()) { - uniqSch.emplace_back(singleHeatCoolSetpoint.TempSchedIndex); - PreDefTableEntry( - state, state.dataOutRptPredefined->pdChLeedSchStPtFirstObjUsed, singleHeatCoolSetpoint.TempSchedName, singleHeatCoolSetpoint.Name); - - std::string schNm = singleHeatCoolSetpoint.TempSchedName + " (summer)"; - std::tie(setPointAt11, numDays, monthAssumed) = - temperatureAndCountInSch(state, singleHeatCoolSetpoint.TempSchedIndex, true, wednesday, 11); - PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSchStPt11amWednesday, schNm, setPointAt11); - PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSchStPt11amWedCnt, schNm, numDays); - - std::tie(setPointAt23, numDays, monthAssumed) = - temperatureAndCountInSch(state, singleHeatCoolSetpoint.TempSchedIndex, true, wednesday, 23); - PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSchStPt11pmWednesday, schNm, setPointAt23); - PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSchStPt11pmWedCnt, schNm, numDays); - - schNm = singleHeatCoolSetpoint.TempSchedName + " (winter)"; - std::tie(setPointAt11, numDays, monthAssumed2) = - temperatureAndCountInSch(state, singleHeatCoolSetpoint.TempSchedIndex, false, wednesday, 11); - PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSchStPt11amWednesday, schNm, setPointAt11); - PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSchStPt11amWedCnt, schNm, numDays); - - std::tie(setPointAt23, numDays, monthAssumed2) = - temperatureAndCountInSch(state, singleHeatCoolSetpoint.TempSchedIndex, false, wednesday, 23); - PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSchStPt11pmWednesday, schNm, setPointAt23); - PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSchStPt11pmWedCnt, schNm, numDays); - - PreDefTableEntry(state, - state.dataOutRptPredefined->pdChLeedSchStPtMonthUsed, - singleHeatCoolSetpoint.TempSchedName, - monthAssumed + " and " + monthAssumed2); - } - } - for (int idx = 1; idx <= state.dataZoneTempPredictorCorrector->NumDualTempHeatCoolControls; ++idx) { - auto &dualHeatCoolSetpoint = state.dataZoneTempPredictorCorrector->SetPointDualHeatCool(idx); - if (std::find(uniqSch.begin(), uniqSch.end(), dualHeatCoolSetpoint.HeatTempSchedIndex) == uniqSch.end()) { - uniqSch.emplace_back(dualHeatCoolSetpoint.HeatTempSchedIndex); - PreDefTableEntry(state, - state.dataOutRptPredefined->pdChLeedSchStPtFirstObjUsed, - dualHeatCoolSetpoint.HeatTempSetptSchedName, - dualHeatCoolSetpoint.Name); - - std::tie(setPointAt11, numDays, monthAssumed) = - temperatureAndCountInSch(state, dualHeatCoolSetpoint.HeatTempSchedIndex, false, wednesday, 11); - PreDefTableEntry( - state, state.dataOutRptPredefined->pdchLeedSchStPt11amWednesday, dualHeatCoolSetpoint.HeatTempSetptSchedName, setPointAt11); - PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSchStPt11amWedCnt, dualHeatCoolSetpoint.HeatTempSetptSchedName, numDays); - - std::tie(setPointAt23, numDays, monthAssumed) = - temperatureAndCountInSch(state, dualHeatCoolSetpoint.HeatTempSchedIndex, false, wednesday, 23); - PreDefTableEntry( - state, state.dataOutRptPredefined->pdchLeedSchStPt11pmWednesday, dualHeatCoolSetpoint.HeatTempSetptSchedName, setPointAt23); - PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSchStPt11pmWedCnt, dualHeatCoolSetpoint.HeatTempSetptSchedName, numDays); - - PreDefTableEntry(state, state.dataOutRptPredefined->pdChLeedSchStPtMonthUsed, dualHeatCoolSetpoint.HeatTempSetptSchedName, monthAssumed); - } - if (std::find(uniqSch.begin(), uniqSch.end(), dualHeatCoolSetpoint.CoolTempSchedIndex) == uniqSch.end()) { - uniqSch.emplace_back(dualHeatCoolSetpoint.CoolTempSchedIndex); - PreDefTableEntry(state, - state.dataOutRptPredefined->pdChLeedSchStPtFirstObjUsed, - dualHeatCoolSetpoint.CoolTempSetptSchedName, - dualHeatCoolSetpoint.Name); - - std::tie(setPointAt11, numDays, monthAssumed) = - temperatureAndCountInSch(state, dualHeatCoolSetpoint.CoolTempSchedIndex, true, wednesday, 11); - PreDefTableEntry( - state, state.dataOutRptPredefined->pdchLeedSchStPt11amWednesday, dualHeatCoolSetpoint.CoolTempSetptSchedName, setPointAt11); - PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSchStPt11amWedCnt, dualHeatCoolSetpoint.CoolTempSetptSchedName, numDays); - - std::tie(setPointAt23, numDays, monthAssumed) = - temperatureAndCountInSch(state, dualHeatCoolSetpoint.CoolTempSchedIndex, true, wednesday, 23); - PreDefTableEntry( - state, state.dataOutRptPredefined->pdchLeedSchStPt11pmWednesday, dualHeatCoolSetpoint.CoolTempSetptSchedName, setPointAt23); - PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSchStPt11pmWedCnt, dualHeatCoolSetpoint.CoolTempSetptSchedName, numDays); - - PreDefTableEntry(state, state.dataOutRptPredefined->pdChLeedSchStPtMonthUsed, dualHeatCoolSetpoint.CoolTempSetptSchedName, monthAssumed); - } + for (auto &setpt : s_ztpc->tempSetptScheds[(int)HVAC::SetptType::SingleHeat]) { + if (std::find(uniqSch.begin(), uniqSch.end(), setpt.heatSched->Num) != uniqSch.end()) continue; + + uniqSch.emplace_back(setpt.heatSched->Num); + PreDefTableEntry(state, state.dataOutRptPredefined->pdChLeedSchStPtFirstObjUsed, setpt.heatSched->Name, setpt.Name); + + std::tie(setPointAt11, numDays, monthAssumed) = setpt.heatSched->getValAndCountOnDay(state, false, Sched::DayType::Wednesday, 11); + PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSchStPt11amWednesday, setpt.heatSched->Name, setPointAt11); + PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSchStPt11amWedCnt, setpt.heatSched->Name, numDays); + + std::tie(setPointAt23, numDays, monthAssumed) = setpt.heatSched->getValAndCountOnDay(state, false, Sched::DayType::Wednesday, 23); + PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSchStPt11pmWednesday, setpt.heatSched->Name, setPointAt23); + PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSchStPt11pmWedCnt, setpt.heatSched->Name, numDays); + + PreDefTableEntry(state, state.dataOutRptPredefined->pdChLeedSchStPtMonthUsed, setpt.heatSched->Name, monthAssumed); } -} - -// returns the temperature value from a schedule at a certain time for the first day of the week in either January or July -std::tuple -temperatureAndCountInSch(EnergyPlusData &state, int const scheduleIndex, bool const isSummer, int const dayOfWeek, int const hourOfDay) -{ - // J.Glazer - Aug 2017 - - // determine month to use based on hemiphere and season - int monthToUse; - if (isSummer) { - if (state.dataEnvrn->Latitude > 0.) { - monthToUse = 7; // July - summer in northern hemisphere - } else { - monthToUse = 1; // January - summer in southern hemisphere - } - } else { - if (state.dataEnvrn->Latitude > 0.) { - monthToUse = 1; // January - winter in northern hemisphere - } else { - monthToUse = 7; // July - winter in southern hemisphere - } + + for (auto &setpt : s_ztpc->tempSetptScheds[(int)HVAC::SetptType::SingleCool]) { + if (std::find(uniqSch.begin(), uniqSch.end(), setpt.coolSched->Num) != uniqSch.end()) continue; + + uniqSch.emplace_back(setpt.coolSched->Num); + PreDefTableEntry(state, state.dataOutRptPredefined->pdChLeedSchStPtFirstObjUsed, setpt.coolSched->Name, setpt.Name); + + std::tie(setPointAt11, numDays, monthAssumed) = setpt.coolSched->getValAndCountOnDay(state, true, Sched::DayType::Wednesday, 11); + PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSchStPt11amWednesday, setpt.coolSched->Name, setPointAt11); + PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSchStPt11amWedCnt, setpt.coolSched->Name, numDays); + + std::tie(setPointAt23, numDays, monthAssumed) = setpt.coolSched->getValAndCountOnDay(state, true, Sched::DayType::Wednesday, 23); + PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSchStPt11pmWednesday, setpt.coolSched->Name, setPointAt23); + PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSchStPt11pmWedCnt, setpt.coolSched->Name, numDays); + + PreDefTableEntry(state, state.dataOutRptPredefined->pdChLeedSchStPtMonthUsed, setpt.coolSched->Name, monthAssumed); } - std::string monthName; - if (monthToUse == 1) { - monthName = "January"; - } else { - monthName = "July"; + + for (auto &setpt : s_ztpc->tempSetptScheds[(int)HVAC::SetptType::SingleHeatCool]) { + if (std::find(uniqSch.begin(), uniqSch.end(), setpt.heatSched->Num) != uniqSch.end()) continue; + + uniqSch.emplace_back(setpt.heatSched->Num); + PreDefTableEntry(state, state.dataOutRptPredefined->pdChLeedSchStPtFirstObjUsed, setpt.heatSched->Name, setpt.Name); + + std::string schNm = setpt.heatSched->Name + " (summer)"; + std::tie(setPointAt11, numDays, monthAssumed) = setpt.heatSched->getValAndCountOnDay(state, true, Sched::DayType::Wednesday, 11); + PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSchStPt11amWednesday, schNm, setPointAt11); + PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSchStPt11amWedCnt, schNm, numDays); + + std::tie(setPointAt23, numDays, monthAssumed) = setpt.heatSched->getValAndCountOnDay(state, true, Sched::DayType::Wednesday, 23); + PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSchStPt11pmWednesday, schNm, setPointAt23); + PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSchStPt11pmWedCnt, schNm, numDays); + + schNm = setpt.heatSched->Name + " (winter)"; + std::tie(setPointAt11, numDays, monthAssumed2) = setpt.heatSched->getValAndCountOnDay(state, false, Sched::DayType::Wednesday, 11); + PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSchStPt11amWednesday, schNm, setPointAt11); + PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSchStPt11amWedCnt, schNm, numDays); + + std::tie(setPointAt23, numDays, monthAssumed2) = setpt.heatSched->getValAndCountOnDay(state, false, Sched::DayType::Wednesday, 23); + PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSchStPt11pmWednesday, schNm, setPointAt23); + PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSchStPt11pmWedCnt, schNm, numDays); + + PreDefTableEntry(state, state.dataOutRptPredefined->pdChLeedSchStPtMonthUsed, setpt.heatSched->Name, monthAssumed + " and " + monthAssumed2); } + + for (auto &setpt : s_ztpc->tempSetptScheds[(int)HVAC::SetptType::DualHeatCool]) { + if (std::find(uniqSch.begin(), uniqSch.end(), setpt.heatSched->Num) == uniqSch.end()) { + uniqSch.emplace_back(setpt.heatSched->Num); + PreDefTableEntry(state, state.dataOutRptPredefined->pdChLeedSchStPtFirstObjUsed, setpt.heatSched->Name, setpt.Name); - int jdateSelect = General::nthDayOfWeekOfMonth(state, dayOfWeek, 1, monthToUse); + std::tie(setPointAt11, numDays, monthAssumed) = setpt.heatSched->getValAndCountOnDay(state, false, Sched::DayType::Wednesday, 11); + PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSchStPt11amWednesday, setpt.heatSched->Name, setPointAt11); + PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSchStPt11amWedCnt, setpt.heatSched->Name, numDays); - // determine number of days in year - int DaysInYear; - if (state.dataEnvrn->CurrentYearIsLeapYear) { - DaysInYear = 366; - } else { - DaysInYear = 365; - } + std::tie(setPointAt23, numDays, monthAssumed) = setpt.heatSched->getValAndCountOnDay(state, false, Sched::DayType::Wednesday, 23); + PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSchStPt11pmWednesday, setpt.heatSched->Name, setPointAt23); + PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSchStPt11pmWedCnt, setpt.heatSched->Name, numDays); - // should adjust date if lands on a holiday but for now assume that it does not + PreDefTableEntry(state, state.dataOutRptPredefined->pdChLeedSchStPtMonthUsed, setpt.heatSched->Name, monthAssumed); + } + + if (std::find(uniqSch.begin(), uniqSch.end(), setpt.coolSched->Num) == uniqSch.end()) { + uniqSch.emplace_back(setpt.coolSched->Num); + PreDefTableEntry(state, state.dataOutRptPredefined->pdChLeedSchStPtFirstObjUsed, setpt.coolSched->Name, setpt.Name); - // adjust time of day for daylight savings time - int hourSelect = hourOfDay + state.dataWeather->DSTIndex(jdateSelect); + std::tie(setPointAt11, numDays, monthAssumed) = setpt.coolSched->getValAndCountOnDay(state, true, Sched::DayType::Wednesday, 11); + PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSchStPt11amWednesday, setpt.coolSched->Name, setPointAt11); + PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSchStPt11amWedCnt, setpt.coolSched->Name, numDays); - // get the value at the selected time - int constexpr firstTimeStep = 1; - int weekSchIndexSelect = state.dataScheduleMgr->Schedule(scheduleIndex).WeekSchedulePointer(jdateSelect); - int daySchIndexSelect = state.dataScheduleMgr->WeekSchedule(weekSchIndexSelect).DaySchedulePointer(dayOfWeek); - Real64 valueAtSelectTime = state.dataScheduleMgr->DaySchedule(daySchIndexSelect).TSValue(firstTimeStep, hourSelect); - int countOfSame = 0; + std::tie(setPointAt23, numDays, monthAssumed) = setpt.coolSched->getValAndCountOnDay(state, true, Sched::DayType::Wednesday, 23); + PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSchStPt11pmWednesday, setpt.coolSched->Name, setPointAt23); + PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSchStPt11pmWedCnt, setpt.coolSched->Name, numDays); - // count the number of times with that same value - for (int jdateOfYear = 1; jdateOfYear <= DaysInYear; ++jdateOfYear) { - int wkSch = state.dataScheduleMgr->Schedule(scheduleIndex).WeekSchedulePointer(jdateOfYear); - if (wkSch == weekSchIndexSelect) { // if same week schedule can short circuit rest of testing and increment counter - ++countOfSame; - } else { - int daySch = state.dataScheduleMgr->WeekSchedule(wkSch).DaySchedulePointer(dayOfWeek); - if (daySch == daySchIndexSelect) { // if same day schedule can short circuit rest of testing and increment counter - ++countOfSame; - } else { - Real64 valueAt = state.dataScheduleMgr->DaySchedule(daySch).TSValue(firstTimeStep, hourSelect); - if (valueAt == valueAtSelectTime) { - ++countOfSame; - } - } + PreDefTableEntry(state, state.dataOutRptPredefined->pdChLeedSchStPtMonthUsed, setpt.coolSched->Name, monthAssumed); } } - - return std::make_tuple(valueAtSelectTime, countOfSame, monthName); } + void FillPredefinedTableOnThermostatSchedules(EnergyPlusData &state) { // add values to the System Summary tabular report related to schedules used by the thermostat objects // J.Glazer - March 2024 using OutputReportPredefined::PreDefTableEntry; auto &orp = state.dataOutRptPredefined; + for (int idx = 1; idx <= state.dataZoneCtrls->NumTempControlledZones; ++idx) { auto &tcz = state.dataZoneCtrls->TempControlledZone(idx); PreDefTableEntry(state, orp->pdchStatName, tcz.ZoneName, tcz.Name); - PreDefTableEntry(state, orp->pdchStatCtrlTypeSchd, tcz.ZoneName, tcz.ControlTypeSchedName); - for (int ctInx = 1; ctInx <= tcz.NumControlTypes; ++ctInx) { - PreDefTableEntry(state, orp->pdchStatSchdType1, tcz.ZoneName, HVAC::thermostatTypeNames[(int)tcz.ControlTypeEnum(ctInx)]); - PreDefTableEntry(state, orp->pdchStatSchdTypeName1, tcz.ZoneName, tcz.ControlTypeName(1)); - switch (tcz.ControlTypeEnum(ctInx)) { - case HVAC::ThermostatType::DualSetPointWithDeadBand: - PreDefTableEntry( - state, orp->pdchStatSchdHeatName, tcz.ZoneName, ScheduleManager::GetScheduleName(state, tcz.SchIndx_DualSetPointWDeadBandHeat)); - PreDefTableEntry( - state, orp->pdchStatSchdCoolName, tcz.ZoneName, ScheduleManager::GetScheduleName(state, tcz.SchIndx_DualSetPointWDeadBandCool)); - break; - case HVAC::ThermostatType::SingleHeatCool: - PreDefTableEntry( - state, orp->pdchStatSchdHeatName, tcz.ZoneName, ScheduleManager::GetScheduleName(state, tcz.SchIndx_SingleHeatCoolSetPoint)); - PreDefTableEntry( - state, orp->pdchStatSchdCoolName, tcz.ZoneName, ScheduleManager::GetScheduleName(state, tcz.SchIndx_SingleHeatCoolSetPoint)); - break; - case HVAC::ThermostatType::SingleCooling: - PreDefTableEntry( - state, orp->pdchStatSchdHeatName, tcz.ZoneName, ScheduleManager::GetScheduleName(state, tcz.SchIndx_SingleCoolSetPoint)); - break; - case HVAC::ThermostatType::SingleHeating: - PreDefTableEntry( - state, orp->pdchStatSchdCoolName, tcz.ZoneName, ScheduleManager::GetScheduleName(state, tcz.SchIndx_SingleHeatSetPoint)); - break; - } + PreDefTableEntry(state, orp->pdchStatCtrlTypeSchd, tcz.ZoneName, tcz.setptTypeSched->Name); + + for (HVAC::SetptType setptType : HVAC::setptTypes) { + auto &setpt = tcz.setpts[(int)setptType]; + + if (setpt.Name.empty()) continue; + + PreDefTableEntry(state, orp->pdchStatSchdType1, tcz.ZoneName, HVAC::setptTypeNames[(int)setptType]); + PreDefTableEntry(state, orp->pdchStatSchdTypeName1, tcz.ZoneName, setpt.Name); + switch (setptType) { + + case HVAC::SetptType::DualHeatCool: + case HVAC::SetptType::SingleHeatCool: { + PreDefTableEntry(state, orp->pdchStatSchdHeatName, tcz.ZoneName, setpt.heatSetptSched->Name); + PreDefTableEntry(state, orp->pdchStatSchdCoolName, tcz.ZoneName, setpt.coolSetptSched->Name); + } break; + + case HVAC::SetptType::SingleCool: { + PreDefTableEntry(state, orp->pdchStatSchdCoolName, tcz.ZoneName, setpt.coolSetptSched->Name); + } break; + + case HVAC::SetptType::SingleHeat: { + PreDefTableEntry(state, orp->pdchStatSchdHeatName, tcz.ZoneName, setpt.heatSetptSched->Name); + } break; + + default: { + } break; + } // switch () } } } @@ -7188,9 +6547,7 @@ void ZoneSpaceHeatBalanceData::calcPredictedSystemLoad(EnergyPlusData &state, Re assert(zoneNum > 0); auto const &thisZone = state.dataHeatBal->Zone(zoneNum); - Real64 const thisTempZoneThermostatSetPoint = state.dataHeatBalFanSys->TempZoneThermostatSetPoint(zoneNum); - Real64 const thisZoneThermostatSetPointLo = state.dataHeatBalFanSys->ZoneThermostatSetPointLo(zoneNum); - Real64 const thisZoneThermostatSetPointHi = state.dataHeatBalFanSys->ZoneThermostatSetPointHi(zoneNum); + auto const &zoneTstatSetpt = state.dataHeatBalFanSys->zoneTstatSetpts(zoneNum); bool thisDeadBandOrSetBack = false; Real64 ZoneSetPoint = 0.0; @@ -7198,120 +6555,121 @@ void ZoneSpaceHeatBalanceData::calcPredictedSystemLoad(EnergyPlusData &state, Re Real64 LoadToHeatingSetPoint = 0.0; Real64 LoadToCoolingSetPoint = 0.0; + auto &s_ztpc = state.dataZoneTempPredictorCorrector; + int zoneNodeNum = thisZone.SystemZoneNodeNumber; if (spaceNum > 0) { zoneNodeNum = state.dataHeatBal->space(spaceNum).SystemZoneNodeNumber; } switch (state.dataHeatBalFanSys->TempControlType(zoneNum)) { - case HVAC::ThermostatType::Uncontrolled: + case HVAC::SetptType::Uncontrolled: { // Uncontrolled Zone LoadToHeatingSetPoint = 0.0; LoadToCoolingSetPoint = 0.0; totalLoad = 0.0; - break; - case HVAC::ThermostatType::SingleHeating: + } break; + + case HVAC::SetptType::SingleHeat: { switch (state.dataHeatBal->ZoneAirSolutionAlgo) { case DataHeatBalance::SolutionAlgo::ThirdOrder: { - LoadToHeatingSetPoint = (this->tempDepLoad * thisTempZoneThermostatSetPoint - this->tempIndLoad); + LoadToHeatingSetPoint = (this->tempDepLoad * zoneTstatSetpt.setpt - this->tempIndLoad); break; } case DataHeatBalance::SolutionAlgo::AnalyticalSolution: { if (this->tempDepLoad == 0.0) { // B=0 - LoadToHeatingSetPoint = this->AirPowerCap * (thisTempZoneThermostatSetPoint - this->T1) - this->tempIndLoad; + LoadToHeatingSetPoint = this->AirPowerCap * (zoneTstatSetpt.setpt - this->T1) - this->tempIndLoad; } else { Real64 const exp_700_TA(std::exp(min(700.0, -this->tempDepLoad / this->AirPowerCap))); - LoadToHeatingSetPoint = - this->tempDepLoad * (thisTempZoneThermostatSetPoint - this->T1 * exp_700_TA) / (1.0 - exp_700_TA) - this->tempIndLoad; + LoadToHeatingSetPoint = this->tempDepLoad * (zoneTstatSetpt.setpt - this->T1 * exp_700_TA) / (1.0 - exp_700_TA) - this->tempIndLoad; } - break; - } + } break; + case DataHeatBalance::SolutionAlgo::EulerMethod: { - LoadToHeatingSetPoint = this->AirPowerCap * (thisTempZoneThermostatSetPoint - this->T1) + - this->tempDepLoad * (thisTempZoneThermostatSetPoint) - this->tempIndLoad; - break; - } + LoadToHeatingSetPoint = this->AirPowerCap * (zoneTstatSetpt.setpt - this->T1) + + this->tempDepLoad * (zoneTstatSetpt.setpt) - this->tempIndLoad; + } break; + default: { assert(false); - } - } + } break; + } // switch (Algo) + if (RAFNFrac > 0.0) LoadToHeatingSetPoint = LoadToHeatingSetPoint / RAFNFrac; totalLoad = LoadToHeatingSetPoint; - ZoneSetPoint = thisTempZoneThermostatSetPoint; + ZoneSetPoint = zoneTstatSetpt.setpt; LoadToCoolingSetPoint = LoadToHeatingSetPoint; // for consistency with the other cases, use LE instead of LT and don't subtract 1.0 Watt as a way of pushing the zero load // case over the threshold if ((totalLoad) <= 0.0) thisDeadBandOrSetBack = true; - - break; - case HVAC::ThermostatType::SingleCooling: + } break; + + case HVAC::SetptType::SingleCool: { switch (state.dataHeatBal->ZoneAirSolutionAlgo) { case DataHeatBalance::SolutionAlgo::ThirdOrder: { - LoadToCoolingSetPoint = this->tempDepLoad * thisTempZoneThermostatSetPoint - this->tempIndLoad; - break; - } + LoadToCoolingSetPoint = this->tempDepLoad * zoneTstatSetpt.setpt - this->tempIndLoad; + } break; + case DataHeatBalance::SolutionAlgo::AnalyticalSolution: { if (this->tempDepLoad == 0.0) { // B=0 - LoadToCoolingSetPoint = this->AirPowerCap * (thisTempZoneThermostatSetPoint - this->T1) - this->tempIndLoad; + LoadToCoolingSetPoint = this->AirPowerCap * (zoneTstatSetpt.setpt - this->T1) - this->tempIndLoad; } else { Real64 const exp_700_TA(std::exp(min(700.0, -this->tempDepLoad / this->AirPowerCap))); - LoadToCoolingSetPoint = - this->tempDepLoad * (thisTempZoneThermostatSetPoint - this->T1 * exp_700_TA) / (1.0 - exp_700_TA) - this->tempIndLoad; + LoadToCoolingSetPoint = this->tempDepLoad * (zoneTstatSetpt.setpt - this->T1 * exp_700_TA) / (1.0 - exp_700_TA) - this->tempIndLoad; } - break; - } + } break; + case DataHeatBalance::SolutionAlgo::EulerMethod: { - LoadToCoolingSetPoint = this->AirPowerCap * (thisTempZoneThermostatSetPoint - this->T1) + - this->tempDepLoad * thisTempZoneThermostatSetPoint - this->tempIndLoad; - break; - } + LoadToCoolingSetPoint = this->AirPowerCap * (zoneTstatSetpt.setpt - this->T1) + + this->tempDepLoad * zoneTstatSetpt.setpt - this->tempIndLoad; + } break; default: { assert(false); - } - } + } break; + } // swtich (Algo) + if (RAFNFrac > 0.0) LoadToHeatingSetPoint = LoadToHeatingSetPoint / RAFNFrac; if (thisZone.HasAdjustedReturnTempByITE && !(state.dataGlobal->BeginSimFlag)) { LoadToCoolingSetPoint = this->tempDepLoad * thisZone.AdjustedReturnTempByITE - this->tempIndLoad; } totalLoad = LoadToCoolingSetPoint; - ZoneSetPoint = thisTempZoneThermostatSetPoint; + ZoneSetPoint = zoneTstatSetpt.setpt; LoadToHeatingSetPoint = LoadToCoolingSetPoint; // for consistency with the other cases, use GE instead of GT and don't add 1.0 Watt as a way of pushing the zero load // case over the threshold if ((totalLoad) >= 0.0) thisDeadBandOrSetBack = true; - break; - case HVAC::ThermostatType::SingleHeatCool: + } break; + + case HVAC::SetptType::SingleHeatCool: { switch (state.dataHeatBal->ZoneAirSolutionAlgo) { case DataHeatBalance::SolutionAlgo::ThirdOrder: { - LoadToHeatingSetPoint = (this->tempDepLoad * (thisTempZoneThermostatSetPoint) - this->tempIndLoad); - LoadToCoolingSetPoint = (this->tempDepLoad * (thisTempZoneThermostatSetPoint) - this->tempIndLoad); - break; - } + LoadToHeatingSetPoint = (this->tempDepLoad * (zoneTstatSetpt.setpt) - this->tempIndLoad); + LoadToCoolingSetPoint = (this->tempDepLoad * (zoneTstatSetpt.setpt) - this->tempIndLoad); + } break; + case DataHeatBalance::SolutionAlgo::AnalyticalSolution: { if (this->tempDepLoad == 0.0) { // B=0 - LoadToHeatingSetPoint = this->AirPowerCap * (thisTempZoneThermostatSetPoint - this->T1) - this->tempIndLoad; - LoadToCoolingSetPoint = this->AirPowerCap * (thisTempZoneThermostatSetPoint - this->T1) - this->tempIndLoad; + LoadToHeatingSetPoint = this->AirPowerCap * (zoneTstatSetpt.setpt - this->T1) - this->tempIndLoad; + LoadToCoolingSetPoint = this->AirPowerCap * (zoneTstatSetpt.setpt - this->T1) - this->tempIndLoad; } else { Real64 const exp_700_TA(std::exp(min(700.0, -this->tempDepLoad / this->AirPowerCap))); - LoadToHeatingSetPoint = - this->tempDepLoad * (thisTempZoneThermostatSetPoint - this->T1 * exp_700_TA) / (1.0 - exp_700_TA) - this->tempIndLoad; - LoadToCoolingSetPoint = - this->tempDepLoad * (thisTempZoneThermostatSetPoint - this->T1 * exp_700_TA) / (1.0 - exp_700_TA) - this->tempIndLoad; + LoadToHeatingSetPoint = this->tempDepLoad * (zoneTstatSetpt.setpt - this->T1 * exp_700_TA) / (1.0 - exp_700_TA) - this->tempIndLoad; + LoadToCoolingSetPoint = this->tempDepLoad * (zoneTstatSetpt.setpt - this->T1 * exp_700_TA) / (1.0 - exp_700_TA) - this->tempIndLoad; } - break; - } + } break; + case DataHeatBalance::SolutionAlgo::EulerMethod: { - LoadToHeatingSetPoint = this->AirPowerCap * (thisTempZoneThermostatSetPoint - this->T1) + - this->tempDepLoad * thisTempZoneThermostatSetPoint - this->tempIndLoad; - LoadToCoolingSetPoint = this->AirPowerCap * (thisTempZoneThermostatSetPoint - this->T1) + - this->tempDepLoad * thisTempZoneThermostatSetPoint - this->tempIndLoad; - break; - } + LoadToHeatingSetPoint = this->AirPowerCap * (zoneTstatSetpt.setpt - this->T1) + + this->tempDepLoad * zoneTstatSetpt.setpt - this->tempIndLoad; + LoadToCoolingSetPoint = this->AirPowerCap * (zoneTstatSetpt.setpt - this->T1) + + this->tempDepLoad * zoneTstatSetpt.setpt - this->tempIndLoad; + } break; default: { assert(false); - } - } - ZoneSetPoint = thisTempZoneThermostatSetPoint; + } break; + } // swtich (Algo) + + ZoneSetPoint = zoneTstatSetpt.setpt; if (RAFNFrac > 0.0) LoadToHeatingSetPoint = LoadToHeatingSetPoint / RAFNFrac; if (RAFNFrac > 0.0) LoadToCoolingSetPoint = LoadToCoolingSetPoint / RAFNFrac; @@ -7332,14 +6690,14 @@ void ZoneSpaceHeatBalanceData::calcPredictedSystemLoad(EnergyPlusData &state, Re // First trap bad set-points if (LoadToHeatingSetPoint > LoadToCoolingSetPoint) { ShowSevereError(state, - "HVAC::ThermostatType::SingleHeatCool: Effective heating set-point higher than effective cooling set-point - use " + "HVAC::SetptType::SingleHeatCool: Effective heating set-point higher than effective cooling set-point - use " "DualSetPointWithDeadBand if using unmixed air model"); ShowContinueErrorTimeStamp(state, format("occurs in Zone={}", thisZone.Name)); ShowContinueError(state, format("LoadToHeatingSetPoint={:.3R}, LoadToCoolingSetPoint={:.3R}", LoadToHeatingSetPoint, LoadToCoolingSetPoint)); ShowContinueError(state, format("Zone TempDepZnLd={:.2R}", this->tempDepLoad)); ShowContinueError(state, format("Zone TempIndZnLd={:.2R}", this->tempIndLoad)); - ShowContinueError(state, format("Zone ThermostatSetPoint={:.2R}", thisTempZoneThermostatSetPoint)); + ShowContinueError(state, format("Zone ThermostatSetPoint={:.2R}", zoneTstatSetpt.setpt)); ShowFatalError(state, "Program terminates due to above conditions."); } @@ -7351,8 +6709,8 @@ void ZoneSpaceHeatBalanceData::calcPredictedSystemLoad(EnergyPlusData &state, Re totalLoad = 0.0; if (zoneNodeNum > 0) { ZoneSetPoint = state.dataLoopNodes->Node(zoneNodeNum).Temp; - ZoneSetPoint = max(ZoneSetPoint, thisZoneThermostatSetPointLo); // trap out of deadband - ZoneSetPoint = min(ZoneSetPoint, thisZoneThermostatSetPointHi); // trap out of deadband + ZoneSetPoint = max(ZoneSetPoint, zoneTstatSetpt.setptLo); // trap out of deadband + ZoneSetPoint = min(ZoneSetPoint, zoneTstatSetpt.setptHi); // trap out of deadband } thisDeadBandOrSetBack = true; } else { // this should never occur! @@ -7363,41 +6721,38 @@ void ZoneSpaceHeatBalanceData::calcPredictedSystemLoad(EnergyPlusData &state, Re format("LoadToHeatingSetPoint={:.3R}, LoadToCoolingSetPoint={:.3R}", LoadToHeatingSetPoint, LoadToCoolingSetPoint)); ShowContinueError(state, format("Zone TempDepZnLd={:.2R}", this->tempDepLoad)); ShowContinueError(state, format("Zone TempIndZnLd={:.2R}", this->tempIndLoad)); - ShowContinueError(state, format("Zone ThermostatSetPoint={:.2R}", thisTempZoneThermostatSetPoint)); + ShowContinueError(state, format("Zone ThermostatSetPoint={:.2R}", zoneTstatSetpt.setpt)); ShowFatalError(state, "Program terminates due to above conditions."); } - break; - case HVAC::ThermostatType::DualSetPointWithDeadBand: + } break; + + case HVAC::SetptType::DualHeatCool: { switch (state.dataHeatBal->ZoneAirSolutionAlgo) { case DataHeatBalance::SolutionAlgo::ThirdOrder: { - LoadToHeatingSetPoint = (this->tempDepLoad * (thisZoneThermostatSetPointLo) - this->tempIndLoad); - LoadToCoolingSetPoint = (this->tempDepLoad * (thisZoneThermostatSetPointHi) - this->tempIndLoad); - break; - } + LoadToHeatingSetPoint = (this->tempDepLoad * (zoneTstatSetpt.setptLo) - this->tempIndLoad); + LoadToCoolingSetPoint = (this->tempDepLoad * (zoneTstatSetpt.setptHi) - this->tempIndLoad); + } break; + case DataHeatBalance::SolutionAlgo::AnalyticalSolution: { if (this->tempDepLoad == 0.0) { // B=0 - LoadToHeatingSetPoint = this->AirPowerCap * (thisZoneThermostatSetPointLo - this->T1) - this->tempIndLoad; - LoadToCoolingSetPoint = this->AirPowerCap * (thisZoneThermostatSetPointHi - this->T1) - this->tempIndLoad; + LoadToHeatingSetPoint = this->AirPowerCap * (zoneTstatSetpt.setptLo - this->T1) - this->tempIndLoad; + LoadToCoolingSetPoint = this->AirPowerCap * (zoneTstatSetpt.setptHi - this->T1) - this->tempIndLoad; } else { Real64 const exp_700_TA(std::exp(min(700.0, -this->tempDepLoad / this->AirPowerCap))); - LoadToHeatingSetPoint = - this->tempDepLoad * (thisZoneThermostatSetPointLo - this->T1 * exp_700_TA) / (1.0 - exp_700_TA) - this->tempIndLoad; - LoadToCoolingSetPoint = - this->tempDepLoad * (thisZoneThermostatSetPointHi - this->T1 * exp_700_TA) / (1.0 - exp_700_TA) - this->tempIndLoad; + LoadToHeatingSetPoint = this->tempDepLoad * (zoneTstatSetpt.setptLo - this->T1 * exp_700_TA) / (1.0 - exp_700_TA) - this->tempIndLoad; + LoadToCoolingSetPoint = this->tempDepLoad * (zoneTstatSetpt.setptHi - this->T1 * exp_700_TA) / (1.0 - exp_700_TA) - this->tempIndLoad; } - break; - } + } break; + case DataHeatBalance::SolutionAlgo::EulerMethod: { - LoadToHeatingSetPoint = - this->AirPowerCap * (thisZoneThermostatSetPointLo - this->T1) + this->tempDepLoad * thisZoneThermostatSetPointLo - this->tempIndLoad; - LoadToCoolingSetPoint = - this->AirPowerCap * (thisZoneThermostatSetPointHi - this->T1) + this->tempDepLoad * thisZoneThermostatSetPointHi - this->tempIndLoad; - break; - } + LoadToHeatingSetPoint = this->AirPowerCap * (zoneTstatSetpt.setptLo - this->T1) + this->tempDepLoad * zoneTstatSetpt.setptLo - this->tempIndLoad; + LoadToCoolingSetPoint = this->AirPowerCap * (zoneTstatSetpt.setptHi - this->T1) + this->tempDepLoad * zoneTstatSetpt.setptHi - this->tempIndLoad; + } break; default: { assert(false); - } - } + } break; + } // switch (Algo) + if (RAFNFrac > 0.0) LoadToHeatingSetPoint = LoadToHeatingSetPoint / RAFNFrac; if (RAFNFrac > 0.0) LoadToCoolingSetPoint = LoadToCoolingSetPoint / RAFNFrac; @@ -7421,24 +6776,24 @@ void ZoneSpaceHeatBalanceData::calcPredictedSystemLoad(EnergyPlusData &state, Re format("LoadToHeatingSetPoint={:.3R}, LoadToCoolingSetPoint={:.3R}", LoadToHeatingSetPoint, LoadToCoolingSetPoint)); ShowContinueError(state, format("Zone TempDepZnLd={:.2R}", this->tempDepLoad)); ShowContinueError(state, format("Zone TempIndZnLd={:.2R}", this->tempIndLoad)); - ShowContinueError(state, format("Zone Heating ThermostatSetPoint={:.2R}", thisZoneThermostatSetPointLo)); - ShowContinueError(state, format("Zone Cooling ThermostatSetPoint={:.2R}", thisZoneThermostatSetPointHi)); + ShowContinueError(state, format("Zone Heating ThermostatSetPoint={:.2R}", zoneTstatSetpt.setptLo)); + ShowContinueError(state, format("Zone Cooling ThermostatSetPoint={:.2R}", zoneTstatSetpt.setptHi)); ShowFatalError(state, "Program terminates due to above conditions."); } if (LoadToHeatingSetPoint > 0.0 && LoadToCoolingSetPoint > 0.0) { totalLoad = LoadToHeatingSetPoint; - ZoneSetPoint = thisZoneThermostatSetPointLo; + ZoneSetPoint = zoneTstatSetpt.setptLo; } else if (LoadToHeatingSetPoint < 0.0 && LoadToCoolingSetPoint < 0.0) { totalLoad = LoadToCoolingSetPoint; - ZoneSetPoint = thisZoneThermostatSetPointHi; + ZoneSetPoint = zoneTstatSetpt.setptHi; } else if (LoadToHeatingSetPoint <= 0.0 && LoadToCoolingSetPoint >= 0.0) { // deadband includes zero loads // this turns out to cause instabilities sometimes? that lead to setpoint errors if predictor is off. totalLoad = 0.0; if (zoneNodeNum > 0) { ZoneSetPoint = state.dataLoopNodes->Node(zoneNodeNum).Temp; - ZoneSetPoint = max(ZoneSetPoint, thisZoneThermostatSetPointLo); // trap out of deadband - ZoneSetPoint = min(ZoneSetPoint, thisZoneThermostatSetPointHi); // trap out of deadband + ZoneSetPoint = max(ZoneSetPoint, zoneTstatSetpt.setptLo); // trap out of deadband + ZoneSetPoint = min(ZoneSetPoint, zoneTstatSetpt.setptHi); // trap out of deadband } thisDeadBandOrSetBack = true; } else { // this should never occur! @@ -7447,18 +6802,19 @@ void ZoneSpaceHeatBalanceData::calcPredictedSystemLoad(EnergyPlusData &state, Re ShowContinueErrorTimeStamp(state, format("occurs in Zone={}", thisZone.Name)); ShowContinueError(state, format("LoadToHeatingSetPoint={:.3R}, LoadToCoolingSetPoint={:.3R}", LoadToHeatingSetPoint, LoadToCoolingSetPoint)); - ShowContinueError(state, format("Zone Heating Set-point={:.2R}", thisZoneThermostatSetPointLo)); - ShowContinueError(state, format("Zone Cooling Set-point={:.2R}", thisZoneThermostatSetPointHi)); + ShowContinueError(state, format("Zone Heating Set-point={:.2R}", zoneTstatSetpt.setptLo)); + ShowContinueError(state, format("Zone Cooling Set-point={:.2R}", zoneTstatSetpt.setptHi)); ShowContinueError(state, format("Zone TempDepZnLd={:.2R}", this->tempDepLoad)); ShowContinueError(state, format("Zone TempIndZnLd={:.2R}", this->tempIndLoad)); - ShowContinueError(state, format("Zone ThermostatSetPoint={:.2R}", thisTempZoneThermostatSetPoint)); + ShowContinueError(state, format("Zone ThermostatSetPoint={:.2R}", zoneTstatSetpt.setpt)); ShowFatalError(state, "Program terminates due to above conditions."); } - break; - default: - break; - } + } break; + + default: { + } break; + } // swtich (setptType) int systemNodeNumber = 0; int stageNum = 0; @@ -7471,7 +6827,7 @@ void ZoneSpaceHeatBalanceData::calcPredictedSystemLoad(EnergyPlusData &state, Re stageNum = state.dataZoneEnergyDemand->ZoneSysEnergyDemand(zoneNum).StageNum; } // Staged control zone - if (state.dataZoneTempPredictorCorrector->NumStageCtrZone > 0) { + if (s_ztpc->NumStageCtrZone > 0) { if (state.dataZoneCtrls->StageZoneLogic(zoneNum)) { if (stageNum == 0) { // No load LoadToHeatingSetPoint = 0.0; @@ -7479,66 +6835,67 @@ void ZoneSpaceHeatBalanceData::calcPredictedSystemLoad(EnergyPlusData &state, Re totalLoad = 0.0; if (systemNodeNumber > 0) { ZoneSetPoint = state.dataLoopNodes->Node(systemNodeNumber).Temp; - ZoneSetPoint = max(ZoneSetPoint, thisZoneThermostatSetPointLo); // trap out of deadband - ZoneSetPoint = min(ZoneSetPoint, thisZoneThermostatSetPointHi); // trap out of deadband + ZoneSetPoint = max(ZoneSetPoint, zoneTstatSetpt.setptLo); // trap out of deadband + ZoneSetPoint = min(ZoneSetPoint, zoneTstatSetpt.setptHi); // trap out of deadband } thisDeadBandOrSetBack = true; + } else if (stageNum < 0) { // Cooling load switch (state.dataHeatBal->ZoneAirSolutionAlgo) { case DataHeatBalance::SolutionAlgo::ThirdOrder: { - LoadToCoolingSetPoint = (this->tempDepLoad * (thisZoneThermostatSetPointHi) - this->tempIndLoad); - break; - } + LoadToCoolingSetPoint = (this->tempDepLoad * (zoneTstatSetpt.setptHi) - this->tempIndLoad); + } break; + case DataHeatBalance::SolutionAlgo::AnalyticalSolution: { if (this->tempDepLoad == 0.0) { // B=0 - LoadToCoolingSetPoint = this->AirPowerCap * (thisZoneThermostatSetPointHi - this->T1) - this->tempIndLoad; + LoadToCoolingSetPoint = this->AirPowerCap * (zoneTstatSetpt.setptHi - this->T1) - this->tempIndLoad; } else { Real64 const exp_700_TA(std::exp(min(700.0, -this->tempDepLoad / this->AirPowerCap))); LoadToCoolingSetPoint = - this->tempDepLoad * (thisZoneThermostatSetPointHi - this->T1 * exp_700_TA) / (1.0 - exp_700_TA) - this->tempIndLoad; + this->tempDepLoad * (zoneTstatSetpt.setptHi - this->T1 * exp_700_TA) / (1.0 - exp_700_TA) - this->tempIndLoad; } - break; - } + } break; + case DataHeatBalance::SolutionAlgo::EulerMethod: { - LoadToCoolingSetPoint = this->AirPowerCap * (thisZoneThermostatSetPointHi - this->T1) + - this->tempDepLoad * thisZoneThermostatSetPointHi - this->tempIndLoad; - break; - } + LoadToCoolingSetPoint = this->AirPowerCap * (zoneTstatSetpt.setptHi - this->T1) + + this->tempDepLoad * zoneTstatSetpt.setptHi - this->tempIndLoad; + } break; default: { assert(false); - } - } + } break; + } // switch (Algo) + totalLoad = LoadToCoolingSetPoint; - ZoneSetPoint = thisZoneThermostatSetPointHi; + ZoneSetPoint = zoneTstatSetpt.setptHi; LoadToHeatingSetPoint = LoadToCoolingSetPoint; if ((totalLoad) >= 0.0) thisDeadBandOrSetBack = true; } else { // Heating load switch (state.dataHeatBal->ZoneAirSolutionAlgo) { case DataHeatBalance::SolutionAlgo::ThirdOrder: { - LoadToHeatingSetPoint = (this->tempDepLoad * thisZoneThermostatSetPointLo - this->tempIndLoad); - break; - } + LoadToHeatingSetPoint = (this->tempDepLoad * zoneTstatSetpt.setptLo - this->tempIndLoad); + } break; + case DataHeatBalance::SolutionAlgo::AnalyticalSolution: { if (this->tempDepLoad == 0.0) { // B=0 - LoadToHeatingSetPoint = this->AirPowerCap * (thisZoneThermostatSetPointLo - this->T1) - this->tempIndLoad; + LoadToHeatingSetPoint = this->AirPowerCap * (zoneTstatSetpt.setptLo - this->T1) - this->tempIndLoad; } else { Real64 const exp_700_TA(std::exp(min(700.0, -this->tempDepLoad / this->AirPowerCap))); LoadToHeatingSetPoint = - this->tempDepLoad * (thisZoneThermostatSetPointLo - this->T1 * exp_700_TA) / (1.0 - exp_700_TA) - this->tempIndLoad; + this->tempDepLoad * (zoneTstatSetpt.setptLo - this->T1 * exp_700_TA) / (1.0 - exp_700_TA) - this->tempIndLoad; } - break; - } + } break; + case DataHeatBalance::SolutionAlgo::EulerMethod: { - LoadToHeatingSetPoint = this->AirPowerCap * (thisZoneThermostatSetPointLo - this->T1) + - this->tempDepLoad * (thisZoneThermostatSetPointLo) - this->tempIndLoad; - break; - } + LoadToHeatingSetPoint = this->AirPowerCap * (zoneTstatSetpt.setptLo - this->T1) + + this->tempDepLoad * (zoneTstatSetpt.setptLo) - this->tempIndLoad; + } break; default: { assert(false); - } - } + } break; + } // switch (Algo) + totalLoad = LoadToHeatingSetPoint; - ZoneSetPoint = thisZoneThermostatSetPointLo; + ZoneSetPoint = zoneTstatSetpt.setptLo; LoadToCoolingSetPoint = LoadToHeatingSetPoint; if ((totalLoad) <= 0.0) thisDeadBandOrSetBack = true; } @@ -7553,7 +6910,7 @@ void ZoneSpaceHeatBalanceData::calcPredictedSystemLoad(EnergyPlusData &state, Re state.dataZoneEnergyDemand->Setback(zoneNum) = (ZoneSetPoint > this->setPointLast); this->setPointLast = ZoneSetPoint; - state.dataHeatBalFanSys->TempZoneThermostatSetPoint(zoneNum) = ZoneSetPoint; // needed to fix Issue # 5048 + state.dataHeatBalFanSys->zoneTstatSetpts(zoneNum).setpt = ZoneSetPoint; // needed to fix Issue # 5048 state.dataZoneEnergyDemand->DeadBandOrSetback(zoneNum) = thisDeadBandOrSetBack; state.dataZoneEnergyDemand->CurDeadBandOrSetback(zoneNum) = thisDeadBandOrSetBack; diff --git a/src/EnergyPlus/ZoneTempPredictorCorrector.hh b/src/EnergyPlus/ZoneTempPredictorCorrector.hh index 1e177c97455..dda5ffbf055 100644 --- a/src/EnergyPlus/ZoneTempPredictorCorrector.hh +++ b/src/EnergyPlus/ZoneTempPredictorCorrector.hh @@ -71,26 +71,11 @@ struct EnergyPlusData; namespace ZoneTempPredictorCorrector { - struct ZoneTempControl + struct ZoneSetptScheds { std::string Name; // Name of the zone - std::string TempSchedName; // Name of the schedule which determines the zone temp setpoint - int TempSchedIndex = 0; - std::string HeatTempSetptSchedName; - int HeatTempSchedIndex = 0; - std::string CoolTempSetptSchedName; - int CoolTempSchedIndex = 0; - }; - - struct ZoneComfortFangerControl - { - std::string Name; // Name of the zone - std::string PMVSchedName; // Name of the schedule which determines the zone temp setpoint - int PMVSchedIndex = 0; // Index to PMV dual set point schedule - std::string HeatPMVSetptSchedName; // Name of PMV heating set point schedule - int HeatPMVSchedIndex = 0; // Index to PMV heating set point schedule - std::string CoolPMVSetptSchedName; // Name of PMV cooling set point schedule - int CoolPMVSchedIndex = 0; // INdex to PMV cooling set point schedule + Sched::Schedule *heatSched = nullptr; + Sched::Schedule *coolSched = nullptr; }; struct AdaptiveComfortDailySetPointSchedule @@ -399,16 +384,8 @@ namespace ZoneTempPredictorCorrector { struct ZoneTempPredictorCorrectorData : BaseGlobalStruct { - int NumSingleTempHeatingControls = 0; - int NumSingleTempCoolingControls = 0; - int NumSingleTempHeatCoolControls = 0; - int NumDualTempHeatCoolControls = 0; - - // Number of Thermal comfort control types - int NumSingleFangerHeatingControls = 0; - int NumSingleFangerCoolingControls = 0; - int NumSingleFangerHeatCoolControls = 0; - int NumDualFangerHeatCoolControls = 0; + std::array NumTempControls = {0}; + std::array NumComfortControls = {0}; // Number of zone with staged controlled objects int NumStageCtrZone = 0; @@ -433,14 +410,8 @@ struct ZoneTempPredictorCorrectorData : BaseGlobalStruct // Object Data std::unordered_set HumidityControlZoneUniqueNames; - EPVector SetPointSingleHeating; - EPVector SetPointSingleCooling; - EPVector SetPointSingleHeatCool; - EPVector SetPointDualHeatCool; - EPVector SetPointSingleHeatingFanger; - EPVector SetPointSingleCoolingFanger; - EPVector SetPointSingleHeatCoolFanger; - EPVector SetPointDualHeatCoolFanger; + std::array, (int)HVAC::SetptType::Num> tempSetptScheds; + std::array, (int)HVAC::SetptType::Num> comfortSetptScheds; ZoneTempPredictorCorrector::AdaptiveComfortDailySetPointSchedule AdapComfortDailySetPointSchedule; std::array AdapComfortSetPointSummerDesDay = {-1}; @@ -459,6 +430,10 @@ struct ZoneTempPredictorCorrectorData : BaseGlobalStruct EPVector zoneHeatBalance; EPVector spaceHeatBalance; + void init_constant_state([[maybe_unused]] EnergyPlusData &state) override + { + } + void init_state([[maybe_unused]] EnergyPlusData &state) override { } diff --git a/src/EnergyPlus/api/EnergyPlusPgm.cc b/src/EnergyPlus/api/EnergyPlusPgm.cc index 800734bc67e..72219ee2be4 100644 --- a/src/EnergyPlus/api/EnergyPlusPgm.cc +++ b/src/EnergyPlus/api/EnergyPlusPgm.cc @@ -368,7 +368,7 @@ int wrapUpEnergyPlus(EnergyPlus::EnergyPlusData &state) state.dataInputProcessing->inputProcessor->reportOrphanRecordObjects(state); FluidProperties::ReportOrphanFluids(state); - ScheduleManager::ReportOrphanSchedules(state); + Sched::ReportOrphanSchedules(state); if (state.dataSQLiteProcedures->sqlite) { state.dataSQLiteProcedures->sqlite.reset(); } diff --git a/src/EnergyPlus/api/datatransfer.cc b/src/EnergyPlus/api/datatransfer.cc index 05dc9f8eac9..28eb9bc181b 100644 --- a/src/EnergyPlus/api/datatransfer.cc +++ b/src/EnergyPlus/api/datatransfer.cc @@ -928,7 +928,7 @@ int minutes(EnergyPlusState state) int numTimeStepsInHour([[maybe_unused]] EnergyPlusState state) { const auto *thisState = static_cast(state); - return thisState->dataGlobal->NumOfTimeStepInHour; + return thisState->dataGlobal->TimeStepsInHour; } int zoneTimeStepNum([[maybe_unused]] EnergyPlusState state) @@ -1021,8 +1021,8 @@ int todayWeatherIsRainAtTime(EnergyPlusState state, int hour, int timeStepNum) auto *thisState = static_cast(state); const int iHour = hour + 1; - if ((iHour > 0) && (iHour <= EnergyPlus::Constant::HoursInDay) && (timeStepNum > 0) && - (timeStepNum <= thisState->dataGlobal->NumOfTimeStepInHour)) { + if ((iHour > 0) && (iHour <= EnergyPlus::Constant::iHoursInDay) && (timeStepNum > 0) && + (timeStepNum <= thisState->dataGlobal->TimeStepsInHour)) { return (int)thisState->dataWeather->wvarsHrTsToday(timeStepNum, iHour).IsRain; } ShowSevereError(*thisState, "Invalid return from weather lookup, check hour and time step argument values are in range."); @@ -1035,8 +1035,8 @@ int todayWeatherIsSnowAtTime(EnergyPlusState state, int hour, int timeStepNum) auto *thisState = static_cast(state); const int iHour = hour + 1; - if ((iHour > 0) && (iHour <= EnergyPlus::Constant::HoursInDay) && (timeStepNum > 0) && - (timeStepNum <= thisState->dataGlobal->NumOfTimeStepInHour)) { + if ((iHour > 0) && (iHour <= EnergyPlus::Constant::iHoursInDay) && (timeStepNum > 0) && + (timeStepNum <= thisState->dataGlobal->TimeStepsInHour)) { return (int)thisState->dataWeather->wvarsHrTsToday(timeStepNum, iHour).IsSnow; } ShowSevereError(*thisState, "Invalid return from weather lookup, check hour and time step argument values are in range."); @@ -1049,8 +1049,8 @@ Real64 todayWeatherOutDryBulbAtTime(EnergyPlusState state, int hour, int timeSte auto *thisState = static_cast(state); const int iHour = hour + 1; - if ((iHour > 0) && (iHour <= EnergyPlus::Constant::HoursInDay) && (timeStepNum > 0) && - (timeStepNum <= thisState->dataGlobal->NumOfTimeStepInHour)) { + if ((iHour > 0) && (iHour <= EnergyPlus::Constant::iHoursInDay) && (timeStepNum > 0) && + (timeStepNum <= thisState->dataGlobal->TimeStepsInHour)) { return thisState->dataWeather->wvarsHrTsToday(timeStepNum, iHour).OutDryBulbTemp; } ShowSevereError(*thisState, "Invalid return from weather lookup, check hour and time step argument values are in range."); @@ -1062,8 +1062,8 @@ Real64 todayWeatherOutDewPointAtTime(EnergyPlusState state, int hour, int timeSt { auto *thisState = static_cast(state); int iHour = hour + 1; - if ((iHour > 0) && (iHour <= EnergyPlus::Constant::HoursInDay) && (timeStepNum > 0) && - (timeStepNum <= thisState->dataGlobal->NumOfTimeStepInHour)) { + if ((iHour > 0) && (iHour <= EnergyPlus::Constant::iHoursInDay) && (timeStepNum > 0) && + (timeStepNum <= thisState->dataGlobal->TimeStepsInHour)) { return thisState->dataWeather->wvarsHrTsToday(timeStepNum, iHour).OutDewPointTemp; } ShowSevereError(*thisState, "Invalid return from weather lookup, check hour and time step argument values are in range."); @@ -1075,8 +1075,8 @@ Real64 todayWeatherOutBarometricPressureAtTime(EnergyPlusState state, int hour, { auto *thisState = static_cast(state); int iHour = hour + 1; - if ((iHour > 0) && (iHour <= EnergyPlus::Constant::HoursInDay) && (timeStepNum > 0) && - (timeStepNum <= thisState->dataGlobal->NumOfTimeStepInHour)) { + if ((iHour > 0) && (iHour <= EnergyPlus::Constant::iHoursInDay) && (timeStepNum > 0) && + (timeStepNum <= thisState->dataGlobal->TimeStepsInHour)) { return thisState->dataWeather->wvarsHrTsToday(timeStepNum, iHour).OutBaroPress; } ShowSevereError(*thisState, "Invalid return from weather lookup, check hour and time step argument values are in range."); @@ -1088,8 +1088,8 @@ Real64 todayWeatherOutRelativeHumidityAtTime(EnergyPlusState state, int hour, in { auto *thisState = static_cast(state); const int iHour = hour + 1; - if ((iHour > 0) && (iHour <= EnergyPlus::Constant::HoursInDay) && (timeStepNum > 0) && - (timeStepNum <= thisState->dataGlobal->NumOfTimeStepInHour)) { + if ((iHour > 0) && (iHour <= EnergyPlus::Constant::iHoursInDay) && (timeStepNum > 0) && + (timeStepNum <= thisState->dataGlobal->TimeStepsInHour)) { return thisState->dataWeather->wvarsHrTsToday(timeStepNum, iHour).OutRelHum; } ShowSevereError(*thisState, "Invalid return from weather lookup, check hour and time step argument values are in range."); @@ -1101,8 +1101,8 @@ Real64 todayWeatherWindSpeedAtTime(EnergyPlusState state, int hour, int timeStep { auto *thisState = static_cast(state); const int iHour = hour + 1; - if ((iHour > 0) && (iHour <= EnergyPlus::Constant::HoursInDay) && (timeStepNum > 0) && - (timeStepNum <= thisState->dataGlobal->NumOfTimeStepInHour)) { + if ((iHour > 0) && (iHour <= EnergyPlus::Constant::iHoursInDay) && (timeStepNum > 0) && + (timeStepNum <= thisState->dataGlobal->TimeStepsInHour)) { return thisState->dataWeather->wvarsHrTsToday(timeStepNum, iHour).WindSpeed; } ShowSevereError(*thisState, "Invalid return from weather lookup, check hour and time step argument values are in range."); @@ -1114,8 +1114,8 @@ Real64 todayWeatherWindDirectionAtTime(EnergyPlusState state, int hour, int time { auto *thisState = static_cast(state); const int iHour = hour + 1; - if ((iHour > 0) && (iHour <= EnergyPlus::Constant::HoursInDay) && (timeStepNum > 0) && - (timeStepNum <= thisState->dataGlobal->NumOfTimeStepInHour)) { + if ((iHour > 0) && (iHour <= EnergyPlus::Constant::iHoursInDay) && (timeStepNum > 0) && + (timeStepNum <= thisState->dataGlobal->TimeStepsInHour)) { return thisState->dataWeather->wvarsHrTsToday(timeStepNum, iHour).WindDir; } ShowSevereError(*thisState, "Invalid return from weather lookup, check hour and time step argument values are in range."); @@ -1127,8 +1127,8 @@ Real64 todayWeatherSkyTemperatureAtTime(EnergyPlusState state, int hour, int tim { auto *thisState = static_cast(state); const int iHour = hour + 1; - if ((iHour > 0) && (iHour <= EnergyPlus::Constant::HoursInDay) && (timeStepNum > 0) && - (timeStepNum <= thisState->dataGlobal->NumOfTimeStepInHour)) { + if ((iHour > 0) && (iHour <= EnergyPlus::Constant::iHoursInDay) && (timeStepNum > 0) && + (timeStepNum <= thisState->dataGlobal->TimeStepsInHour)) { return thisState->dataWeather->wvarsHrTsToday(timeStepNum, iHour).SkyTemp; } ShowSevereError(*thisState, "Invalid return from weather lookup, check hour and time step argument values are in range."); @@ -1140,8 +1140,8 @@ Real64 todayWeatherHorizontalIRSkyAtTime(EnergyPlusState state, int hour, int ti { auto *thisState = static_cast(state); const int iHour = hour + 1; - if ((iHour > 0) && (iHour <= EnergyPlus::Constant::HoursInDay) && (timeStepNum > 0) && - (timeStepNum <= thisState->dataGlobal->NumOfTimeStepInHour)) { + if ((iHour > 0) && (iHour <= EnergyPlus::Constant::iHoursInDay) && (timeStepNum > 0) && + (timeStepNum <= thisState->dataGlobal->TimeStepsInHour)) { return thisState->dataWeather->wvarsHrTsToday(timeStepNum, iHour).HorizIRSky; } ShowSevereError(*thisState, "Invalid return from weather lookup, check hour and time step argument values are in range."); @@ -1153,8 +1153,8 @@ Real64 todayWeatherBeamSolarRadiationAtTime(EnergyPlusState state, int hour, int { auto *thisState = static_cast(state); const int iHour = hour + 1; - if ((iHour > 0) && (iHour <= EnergyPlus::Constant::HoursInDay) && (timeStepNum > 0) && - (timeStepNum <= thisState->dataGlobal->NumOfTimeStepInHour)) { + if ((iHour > 0) && (iHour <= EnergyPlus::Constant::iHoursInDay) && (timeStepNum > 0) && + (timeStepNum <= thisState->dataGlobal->TimeStepsInHour)) { return thisState->dataWeather->wvarsHrTsToday(timeStepNum, iHour).BeamSolarRad; } ShowSevereError(*thisState, "Invalid return from weather lookup, check hour and time step argument values are in range."); @@ -1166,8 +1166,8 @@ Real64 todayWeatherDiffuseSolarRadiationAtTime(EnergyPlusState state, int hour, { auto *thisState = static_cast(state); const int iHour = hour + 1; - if ((iHour > 0) && (iHour <= EnergyPlus::Constant::HoursInDay) && (timeStepNum > 0) && - (timeStepNum <= thisState->dataGlobal->NumOfTimeStepInHour)) { + if ((iHour > 0) && (iHour <= EnergyPlus::Constant::iHoursInDay) && (timeStepNum > 0) && + (timeStepNum <= thisState->dataGlobal->TimeStepsInHour)) { return thisState->dataWeather->wvarsHrTsToday(timeStepNum, iHour).DifSolarRad; } ShowSevereError(*thisState, "Invalid return from weather lookup, check hour and time step argument values are in range."); @@ -1179,8 +1179,8 @@ Real64 todayWeatherAlbedoAtTime(EnergyPlusState state, int hour, int timeStepNum { auto *thisState = static_cast(state); const int iHour = hour + 1; - if ((iHour > 0) && (iHour <= EnergyPlus::Constant::HoursInDay) && (timeStepNum > 0) && - (timeStepNum <= thisState->dataGlobal->NumOfTimeStepInHour)) { + if ((iHour > 0) && (iHour <= EnergyPlus::Constant::iHoursInDay) && (timeStepNum > 0) && + (timeStepNum <= thisState->dataGlobal->TimeStepsInHour)) { return thisState->dataWeather->wvarsHrTsToday(timeStepNum, iHour).Albedo; } ShowSevereError(*thisState, "Invalid return from weather lookup, check hour and time step argument values are in range."); @@ -1192,8 +1192,8 @@ Real64 todayWeatherLiquidPrecipitationAtTime(EnergyPlusState state, int hour, in { auto *thisState = static_cast(state); const int iHour = hour + 1; - if ((iHour > 0) && (iHour <= EnergyPlus::Constant::HoursInDay) && (timeStepNum > 0) && - (timeStepNum <= thisState->dataGlobal->NumOfTimeStepInHour)) { + if ((iHour > 0) && (iHour <= EnergyPlus::Constant::iHoursInDay) && (timeStepNum > 0) && + (timeStepNum <= thisState->dataGlobal->TimeStepsInHour)) { return thisState->dataWeather->wvarsHrTsToday(timeStepNum, iHour).LiquidPrecip; } ShowSevereError(*thisState, "Invalid return from weather lookup, check hour and time step argument values are in range."); @@ -1205,8 +1205,8 @@ int tomorrowWeatherIsRainAtTime(EnergyPlusState state, int hour, int timeStepNum { auto *thisState = static_cast(state); const int iHour = hour + 1; - if ((iHour > 0) && (iHour <= EnergyPlus::Constant::HoursInDay) && (timeStepNum > 0) && - (timeStepNum <= thisState->dataGlobal->NumOfTimeStepInHour)) { + if ((iHour > 0) && (iHour <= EnergyPlus::Constant::iHoursInDay) && (timeStepNum > 0) && + (timeStepNum <= thisState->dataGlobal->TimeStepsInHour)) { return (int)thisState->dataWeather->wvarsHrTsTomorrow(timeStepNum, iHour).IsRain; } ShowSevereError(*thisState, "Invalid return from weather lookup, check hour and time step argument values are in range."); @@ -1218,8 +1218,8 @@ int tomorrowWeatherIsSnowAtTime(EnergyPlusState state, int hour, int timeStepNum { auto *thisState = static_cast(state); const int iHour = hour + 1; - if ((iHour > 0) && (iHour <= EnergyPlus::Constant::HoursInDay) && (timeStepNum > 0) && - (timeStepNum <= thisState->dataGlobal->NumOfTimeStepInHour)) { + if ((iHour > 0) && (iHour <= EnergyPlus::Constant::iHoursInDay) && (timeStepNum > 0) && + (timeStepNum <= thisState->dataGlobal->TimeStepsInHour)) { return (int)thisState->dataWeather->wvarsHrTsTomorrow(timeStepNum, iHour).IsSnow; } ShowSevereError(*thisState, "Invalid return from weather lookup, check hour and time step argument values are in range."); @@ -1231,8 +1231,8 @@ Real64 tomorrowWeatherOutDryBulbAtTime(EnergyPlusState state, int hour, int time { auto *thisState = static_cast(state); const int iHour = hour + 1; - if ((iHour > 0) && (iHour <= EnergyPlus::Constant::HoursInDay) && (timeStepNum > 0) && - (timeStepNum <= thisState->dataGlobal->NumOfTimeStepInHour)) { + if ((iHour > 0) && (iHour <= EnergyPlus::Constant::iHoursInDay) && (timeStepNum > 0) && + (timeStepNum <= thisState->dataGlobal->TimeStepsInHour)) { return thisState->dataWeather->wvarsHrTsTomorrow(timeStepNum, iHour).OutDryBulbTemp; } ShowSevereError(*thisState, "Invalid return from weather lookup, check hour and time step argument values are in range."); @@ -1244,8 +1244,8 @@ Real64 tomorrowWeatherOutDewPointAtTime(EnergyPlusState state, int hour, int tim { auto *thisState = static_cast(state); const int iHour = hour + 1; - if ((iHour > 0) && (iHour <= EnergyPlus::Constant::HoursInDay) && (timeStepNum > 0) && - (timeStepNum <= thisState->dataGlobal->NumOfTimeStepInHour)) { + if ((iHour > 0) && (iHour <= EnergyPlus::Constant::iHoursInDay) && (timeStepNum > 0) && + (timeStepNum <= thisState->dataGlobal->TimeStepsInHour)) { return thisState->dataWeather->wvarsHrTsTomorrow(timeStepNum, iHour).OutDewPointTemp; } ShowSevereError(*thisState, "Invalid return from weather lookup, check hour and time step argument values are in range."); @@ -1257,8 +1257,8 @@ Real64 tomorrowWeatherOutBarometricPressureAtTime(EnergyPlusState state, int hou { auto *thisState = static_cast(state); const int iHour = hour + 1; - if ((iHour > 0) && (iHour <= EnergyPlus::Constant::HoursInDay) && (timeStepNum > 0) && - (timeStepNum <= thisState->dataGlobal->NumOfTimeStepInHour)) { + if ((iHour > 0) && (iHour <= EnergyPlus::Constant::iHoursInDay) && (timeStepNum > 0) && + (timeStepNum <= thisState->dataGlobal->TimeStepsInHour)) { return thisState->dataWeather->wvarsHrTsTomorrow(timeStepNum, iHour).OutBaroPress; } ShowSevereError(*thisState, "Invalid return from weather lookup, check hour and time step argument values are in range."); @@ -1270,8 +1270,8 @@ Real64 tomorrowWeatherOutRelativeHumidityAtTime(EnergyPlusState state, int hour, { auto *thisState = static_cast(state); const int iHour = hour + 1; - if ((iHour > 0) && (iHour <= EnergyPlus::Constant::HoursInDay) && (timeStepNum > 0) && - (timeStepNum <= thisState->dataGlobal->NumOfTimeStepInHour)) { + if ((iHour > 0) && (iHour <= EnergyPlus::Constant::iHoursInDay) && (timeStepNum > 0) && + (timeStepNum <= thisState->dataGlobal->TimeStepsInHour)) { return thisState->dataWeather->wvarsHrTsTomorrow(timeStepNum, iHour).OutRelHum; } ShowSevereError(*thisState, "Invalid return from weather lookup, check hour and time step argument values are in range."); @@ -1283,8 +1283,8 @@ Real64 tomorrowWeatherWindSpeedAtTime(EnergyPlusState state, int hour, int timeS { auto *thisState = static_cast(state); const int iHour = hour + 1; - if ((iHour > 0) && (iHour <= EnergyPlus::Constant::HoursInDay) && (timeStepNum > 0) && - (timeStepNum <= thisState->dataGlobal->NumOfTimeStepInHour)) { + if ((iHour > 0) && (iHour <= EnergyPlus::Constant::iHoursInDay) && (timeStepNum > 0) && + (timeStepNum <= thisState->dataGlobal->TimeStepsInHour)) { return thisState->dataWeather->wvarsHrTsTomorrow(timeStepNum, iHour).WindSpeed; } ShowSevereError(*thisState, "Invalid return from weather lookup, check hour and time step argument values are in range."); @@ -1296,8 +1296,8 @@ Real64 tomorrowWeatherWindDirectionAtTime(EnergyPlusState state, int hour, int t { auto *thisState = static_cast(state); const int iHour = hour + 1; - if ((iHour > 0) && (iHour <= EnergyPlus::Constant::HoursInDay) && (timeStepNum > 0) && - (timeStepNum <= thisState->dataGlobal->NumOfTimeStepInHour)) { + if ((iHour > 0) && (iHour <= EnergyPlus::Constant::iHoursInDay) && (timeStepNum > 0) && + (timeStepNum <= thisState->dataGlobal->TimeStepsInHour)) { return thisState->dataWeather->wvarsHrTsTomorrow(timeStepNum, iHour).WindDir; } ShowSevereError(*thisState, "Invalid return from weather lookup, check hour and time step argument values are in range."); @@ -1309,8 +1309,8 @@ Real64 tomorrowWeatherSkyTemperatureAtTime(EnergyPlusState state, int hour, int { auto *thisState = static_cast(state); const int iHour = hour + 1; - if ((iHour > 0) && (iHour <= EnergyPlus::Constant::HoursInDay) && (timeStepNum > 0) && - (timeStepNum <= thisState->dataGlobal->NumOfTimeStepInHour)) { + if ((iHour > 0) && (iHour <= EnergyPlus::Constant::iHoursInDay) && (timeStepNum > 0) && + (timeStepNum <= thisState->dataGlobal->TimeStepsInHour)) { return thisState->dataWeather->wvarsHrTsTomorrow(timeStepNum, iHour).SkyTemp; } ShowSevereError(*thisState, "Invalid return from weather lookup, check hour and time step argument values are in range."); @@ -1322,8 +1322,8 @@ Real64 tomorrowWeatherHorizontalIRSkyAtTime(EnergyPlusState state, int hour, int { auto *thisState = static_cast(state); const int iHour = hour + 1; - if ((iHour > 0) && (iHour <= EnergyPlus::Constant::HoursInDay) && (timeStepNum > 0) && - (timeStepNum <= thisState->dataGlobal->NumOfTimeStepInHour)) { + if ((iHour > 0) && (iHour <= EnergyPlus::Constant::iHoursInDay) && (timeStepNum > 0) && + (timeStepNum <= thisState->dataGlobal->TimeStepsInHour)) { return thisState->dataWeather->wvarsHrTsTomorrow(timeStepNum, iHour).HorizIRSky; } ShowSevereError(*thisState, "Invalid return from weather lookup, check hour and time step argument values are in range."); @@ -1335,8 +1335,8 @@ Real64 tomorrowWeatherBeamSolarRadiationAtTime(EnergyPlusState state, int hour, { auto *thisState = static_cast(state); const int iHour = hour + 1; - if ((iHour > 0) && (iHour <= EnergyPlus::Constant::HoursInDay) && (timeStepNum > 0) && - (timeStepNum <= thisState->dataGlobal->NumOfTimeStepInHour)) { + if ((iHour > 0) && (iHour <= EnergyPlus::Constant::iHoursInDay) && (timeStepNum > 0) && + (timeStepNum <= thisState->dataGlobal->TimeStepsInHour)) { return thisState->dataWeather->wvarsHrTsTomorrow(timeStepNum, iHour).BeamSolarRad; } ShowSevereError(*thisState, "Invalid return from weather lookup, check hour and time step argument values are in range."); @@ -1348,8 +1348,8 @@ Real64 tomorrowWeatherDiffuseSolarRadiationAtTime(EnergyPlusState state, int hou { auto *thisState = static_cast(state); const int iHour = hour + 1; - if ((iHour > 0) && (iHour <= EnergyPlus::Constant::HoursInDay) && (timeStepNum > 0) && - (timeStepNum <= thisState->dataGlobal->NumOfTimeStepInHour)) { + if ((iHour > 0) && (iHour <= EnergyPlus::Constant::iHoursInDay) && (timeStepNum > 0) && + (timeStepNum <= thisState->dataGlobal->TimeStepsInHour)) { return thisState->dataWeather->wvarsHrTsTomorrow(timeStepNum, iHour).DifSolarRad; } ShowSevereError(*thisState, "Invalid return from weather lookup, check hour and time step argument values are in range."); @@ -1361,8 +1361,8 @@ Real64 tomorrowWeatherAlbedoAtTime(EnergyPlusState state, int hour, int timeStep { auto *thisState = static_cast(state); const int iHour = hour + 1; - if ((iHour > 0) && (iHour <= EnergyPlus::Constant::HoursInDay) && (timeStepNum > 0) && - (timeStepNum <= thisState->dataGlobal->NumOfTimeStepInHour)) { + if ((iHour > 0) && (iHour <= EnergyPlus::Constant::iHoursInDay) && (timeStepNum > 0) && + (timeStepNum <= thisState->dataGlobal->TimeStepsInHour)) { return thisState->dataWeather->wvarsHrTsTomorrow(timeStepNum, iHour).Albedo; } ShowSevereError(*thisState, "Invalid return from weather lookup, check hour and time step argument values are in range."); @@ -1374,8 +1374,8 @@ Real64 tomorrowWeatherLiquidPrecipitationAtTime(EnergyPlusState state, const int { auto *thisState = static_cast(state); const int iHour = hour + 1; - if ((iHour > 0) && (iHour <= EnergyPlus::Constant::HoursInDay) && (timeStepNum > 0) && - (timeStepNum <= thisState->dataGlobal->NumOfTimeStepInHour)) { + if ((iHour > 0) && (iHour <= EnergyPlus::Constant::iHoursInDay) && (timeStepNum > 0) && + (timeStepNum <= thisState->dataGlobal->TimeStepsInHour)) { return thisState->dataWeather->wvarsHrTsTomorrow(timeStepNum, iHour).LiquidPrecip; } ShowSevereError(*thisState, "Invalid return from weather lookup, check hour and time step argument values are in range."); @@ -1386,5 +1386,5 @@ Real64 tomorrowWeatherLiquidPrecipitationAtTime(EnergyPlusState state, const int Real64 currentSimTime(EnergyPlusState state) { const auto *thisState = static_cast(state); - return (thisState->dataGlobal->DayOfSim - 1) * EnergyPlus::Constant::HoursInDay + currentTime(state); + return (thisState->dataGlobal->DayOfSim - 1) * EnergyPlus::Constant::iHoursInDay + currentTime(state); } diff --git a/tst/EnergyPlus/unit/AdvancedAFN.unit.cc b/tst/EnergyPlus/unit/AdvancedAFN.unit.cc index b5afa4a8a64..218dd4b010d 100644 --- a/tst/EnergyPlus/unit/AdvancedAFN.unit.cc +++ b/tst/EnergyPlus/unit/AdvancedAFN.unit.cc @@ -106,6 +106,10 @@ TEST_F(EnergyPlusFixture, AirflowNetwork_AdvancedTest_Test1) state->dataZoneTempPredictorCorrector->zoneHeatBalance(1).MAT = 22.0; state->dataZoneTempPredictorCorrector->zoneHeatBalance(1).MRT = 22.0; + state->dataHeatBalFanSys->TempControlType.allocate(1); + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::Uncontrolled; + state->dataHeatBalFanSys->zoneTstatSetpts.allocate(1); + TimeOpenElapsed = 5.0; TimeCloseElapsed = 0.0; state->afn->OccupantVentilationControl(1).MinTimeControlOnly = false; @@ -157,18 +161,14 @@ TEST_F(EnergyPlusFixture, AirflowNetwork_AdvancedTest_Test1) TimeCloseElapsed = 5.0; state->dataHeatBal->ZoneIntGain.allocate(1); state->dataHeatBal->ZoneIntGain(1).NOFOCC = 0.5; - state->dataHeatBalFanSys->TempControlType.allocate(1); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::Uncontrolled; - state->dataHeatBalFanSys->ZoneThermostatSetPointLo.allocate(1); - state->dataHeatBalFanSys->ZoneThermostatSetPointHi.allocate(1); state->afn->OccupantVentilationControl(1).calc(*state, 1, TimeOpenElapsed, TimeCloseElapsed, OpenStatus, OpenProbStatus, CloseProbStatus); EXPECT_EQ(1, OpenProbStatus); EXPECT_EQ(0, CloseProbStatus); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::DualSetPointWithDeadBand; - state->dataHeatBalFanSys->ZoneThermostatSetPointLo(1) = 22.0; - state->dataHeatBalFanSys->ZoneThermostatSetPointHi(1) = 28.0; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::DualHeatCool; + state->dataHeatBalFanSys->zoneTstatSetpts(1).setptLo = 22.0; + state->dataHeatBalFanSys->zoneTstatSetpts(1).setptHi = 28.0; state->afn->OccupantVentilationControl(1).calc(*state, 1, TimeOpenElapsed, TimeCloseElapsed, OpenStatus, OpenProbStatus, CloseProbStatus); EXPECT_EQ(1, OpenProbStatus); EXPECT_EQ(0, CloseProbStatus); diff --git a/tst/EnergyPlus/unit/AirLoopHVACDOAS.unit.cc b/tst/EnergyPlus/unit/AirLoopHVACDOAS.unit.cc index ea744bf82c8..62b17565201 100644 --- a/tst/EnergyPlus/unit/AirLoopHVACDOAS.unit.cc +++ b/tst/EnergyPlus/unit/AirLoopHVACDOAS.unit.cc @@ -90,7 +90,6 @@ using namespace EnergyPlus; using namespace DataSurfaces; using namespace DataHeatBalance; using namespace EnergyPlus::DataLoopNode; -using namespace EnergyPlus::ScheduleManager; using namespace OutAirNodeManager; using namespace HeatingCoils; @@ -4035,6 +4034,8 @@ TEST_F(EnergyPlusFixture, AirLoopHVACDOASTest) ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + state->dataIPShortCut->lNumericFieldBlanks.allocate(1000); state->dataIPShortCut->lAlphaFieldBlanks.allocate(1000); state->dataIPShortCut->cAlphaFieldNames.allocate(1000); @@ -4048,10 +4049,8 @@ TEST_F(EnergyPlusFixture, AirLoopHVACDOASTest) state->dataIPShortCut->cAlphaArgs = " "; state->dataIPShortCut->rNumericArgs = 0.0; - bool ErrorsFound = false; // Read objects - HeatBalanceManager::GetProjectControlData(*state, ErrorsFound); - EXPECT_FALSE(ErrorsFound); + bool ErrorsFound = false; HeatBalanceManager::GetZoneData(*state, ErrorsFound); EXPECT_FALSE(ErrorsFound); Material::GetWindowGlassSpectralData(*state, ErrorsFound); @@ -4132,7 +4131,8 @@ TEST_F(EnergyPlusFixture, AirLoopHVACDOASTest) state->dataEnvrn->OutBaroPress = 101325.0; - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; // set availability and fan schedule to 1 + auto *sched = Sched::GetSchedule(*state, "ALWAYS_ON"); + sched->currentVal = 1.0; // set availability and fan schedule to 1 thisAirLoopDOASObjec.SimAirLoopHVACDOAS(*state, true, index); @@ -4375,6 +4375,8 @@ TEST_F(EnergyPlusFixture, AirLoopHVACDOAS_TestOACompOutletNodeIndex) ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + MixedAir::GetOutsideAirSysInputs(*state); state->dataMixedAir->GetOASysInputFlag = false; MixedAir::GetOAMixerInputs(*state); @@ -8434,9 +8436,10 @@ TEST_F(EnergyPlusFixture, AirLoopHVACDOAS_ReportVariableResetTest) ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + bool ErrorsFound = false; // Read objects - HeatBalanceManager::GetProjectControlData(*state, ErrorsFound); EXPECT_FALSE(ErrorsFound); HeatBalanceManager::GetZoneData(*state, ErrorsFound); EXPECT_FALSE(ErrorsFound); @@ -8519,7 +8522,9 @@ TEST_F(EnergyPlusFixture, AirLoopHVACDOAS_ReportVariableResetTest) state->dataEnvrn->OutBaroPress = 101325.0; - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; + auto *sched = Sched::GetSchedule(*state, "ALWAYS_ON"); + sched->currentVal = 1.0; + // simulte the DOAS thisAirLoopDOASObjec.SimAirLoopHVACDOAS(*state, true, index); // verify doas air flow rate and heating rate @@ -8842,6 +8847,8 @@ TEST_F(EnergyPlusFixture, AirLoopHVACDOAS_TestOACompFanNoDrawAndBlow) ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + MixedAir::GetOutsideAirSysInputs(*state); state->dataMixedAir->GetOASysInputFlag = false; MixedAir::GetOAMixerInputs(*state); @@ -10063,7 +10070,8 @@ TEST_F(EnergyPlusFixture, AirLoopHVACDOAS_TestFanHeatAddeToCoolingCoilSize) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + state->dataGlobal->DDOnlySimulation = true; SimulationManager::ManageSimulation(*state); // run the design day over the warmup period (24 hrs, 25 days) @@ -10394,6 +10402,8 @@ TEST_F(EnergyPlusFixture, AirLoopHVACDOAS_TestOACompConnectionError) ASSERT_TRUE(process_idf(idf_objects)); compare_err_stream_substring("", true); + state->init_state(*state); + MixedAir::GetOutsideAirSysInputs(*state); state->dataMixedAir->GetOASysInputFlag = false; MixedAir::GetOAMixerInputs(*state); @@ -11625,6 +11635,8 @@ TEST_F(EnergyPlusFixture, AirLoopHVACDOAS_TestFanDrawThroughPlacement) ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + state->dataGlobal->DDOnlySimulation = true; SimulationManager::ManageSimulation(*state); // run the design day over the warmup period (24 hrs, 25 days) @@ -11663,7 +11675,8 @@ TEST_F(EnergyPlusFixture, AirLoopHVACDOAS_TestFanDrawThroughPlacement) state->dataEnvrn->OutBaroPress = 101325.0; - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; // set availability and fan schedule to 1 + auto *sched = Sched::GetSchedule(*state, "ALWAYS_ON"); + sched->currentVal = 1.0; // set availability and fan schedule to 1 thisAirLoopDOASObjec.SimAirLoopHVACDOAS(*state, true, index); diff --git a/tst/EnergyPlus/unit/AirTerminalSingleDuct.unit.cc b/tst/EnergyPlus/unit/AirTerminalSingleDuct.unit.cc index a3a0ea6871f..90a805ca7bb 100644 --- a/tst/EnergyPlus/unit/AirTerminalSingleDuct.unit.cc +++ b/tst/EnergyPlus/unit/AirTerminalSingleDuct.unit.cc @@ -87,7 +87,6 @@ using namespace EnergyPlus::HVACSingleDuctInduc; using namespace EnergyPlus::DataLoopNode; using namespace EnergyPlus::MixedAir; using namespace EnergyPlus::Psychrometrics; -using namespace EnergyPlus::ScheduleManager; using namespace EnergyPlus::SingleDuct; using namespace EnergyPlus::ZoneAirLoopEquipmentManager; using namespace EnergyPlus::DataDefineEquip; @@ -175,9 +174,10 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctCVReheat_GetInputTest) ASSERT_TRUE(process_idf(idf_objects)); - state->dataGlobal->NumOfTimeStepInHour = 1; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 60; // must initialize this to get schedules initialized - ProcessScheduleInput(*state); // read schedules + state->dataGlobal->TimeStepsInHour = 1; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 60; // must initialize this to get schedules initialized + + state->init_state(*state); GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); @@ -305,9 +305,9 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuct4PipeInduction_GetInputTest) process_idf(idf_objects); - state->dataGlobal->NumOfTimeStepInHour = 1; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 60; // must initialize this to get schedules initialized - ProcessScheduleInput(*state); // read schedules + state->dataGlobal->TimeStepsInHour = 1; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 60; // must initialize this to get schedules initialized + state->init_state(*state); GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); @@ -395,9 +395,9 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctVAVHeatCool_GetInputTest) process_idf(idf_objects); - state->dataGlobal->NumOfTimeStepInHour = 1; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 60; // must initialize this to get schedules initialized - ProcessScheduleInput(*state); // read schedules + state->dataGlobal->TimeStepsInHour = 1; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 60; // must initialize this to get schedules initialized + state->init_state(*state); GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); @@ -518,9 +518,9 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctVAVReheatVarSpeedFan_GetInputTest ASSERT_TRUE(process_idf(idf_objects)); - state->dataGlobal->NumOfTimeStepInHour = 1; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 60; // must initialize this to get schedules initialized - ProcessScheduleInput(*state); // read schedules + state->dataGlobal->TimeStepsInHour = 1; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 60; // must initialize this to get schedules initialized + state->init_state(*state); GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); @@ -616,9 +616,10 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctVAVReheat_NormalActionTest) ASSERT_TRUE(process_idf(idf_objects)); - state->dataGlobal->NumOfTimeStepInHour = 1; - state->dataGlobal->MinutesPerTimeStep = 60; - ProcessScheduleInput(*state); + state->dataGlobal->TimeStepsInHour = 1; + state->dataGlobal->MinutesInTimeStep = 60; + state->init_state(*state); + bool ErrorsFound(false); GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); @@ -640,7 +641,7 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctVAVReheat_NormalActionTest) int const OutletNode = state->dataSingleDuct->sd_airterminal(SysNum).OutletNodeNum; int const ZonePtr = state->dataSingleDuct->sd_airterminal(SysNum).CtrlZoneNum; int const ZoneAirNodeNum = thisZoneEquip.ZoneNode; - state->dataScheduleMgr->Schedule(state->dataSingleDuct->sd_airterminal(SysNum).SchedPtr).CurrentValue = 1.0; // unit is always available + state->dataSingleDuct->sd_airterminal(SysNum).availSched->currentVal = 1.0; // unit is always available // design maximum air mass flow rate Real64 MassFlowRateMaxAvail = state->dataSingleDuct->sd_airterminal(SysNum).MaxAirVolFlowRate * state->dataEnvrn->StdRhoAir; @@ -668,7 +669,7 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctVAVReheat_NormalActionTest) state->dataZoneEnergyDemand->ZoneSysEnergyDemand(1).RemainingOutputRequired = 1000.0; state->dataZoneEnergyDemand->ZoneSysEnergyDemand(1).RemainingOutputReqToHeatSP = 1000.0; state->dataHeatBalFanSys->TempControlType.allocate(1); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::DualSetPointWithDeadBand; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::DualHeatCool; // calc min air mass flow rate for Normal Damper Heating Action Real64 expectedMassFlowAirReheatMin = 0.2 * MassFlowRateMaxAvail; @@ -887,41 +888,43 @@ TEST_F(EnergyPlusFixture, SingleDuctVAVAirTerminals_GetInputs) ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + GetZoneAirLoopEquipment(*state); SingleDuct::GetSysInput(*state); // VAV Reheat get input test EXPECT_EQ("AirTerminal:SingleDuct:VAV:Reheat", state->dataSingleDuct->sd_airterminal(1).sysType); // VAV Reheat Type EXPECT_EQ("VAV REHEAT AT", state->dataSingleDuct->sd_airterminal(1).SysName); // VAV Reheat Name - EXPECT_TRUE(state->dataSingleDuct->sd_airterminal(1).ZoneTurndownMinAirFracSchExist); // turndown schdule exists + EXPECT_TRUE(state->dataSingleDuct->sd_airterminal(1).zoneTurndownMinAirFracSched != nullptr); // turndown schdule exists EXPECT_EQ(state->dataSingleDuct->sd_airterminal(1).ZoneTurndownMinAirFrac, 1.0); // initialized to 1.0 EXPECT_EQ(state->dataSingleDuct->sd_airterminal(1).ZoneMinAirFracDes, 0.3); // design minimum flow fraction // VAV change over bypass reheat get input test EXPECT_EQ("AirTerminal:SingleDuct:VAV:HeatAndCool:Reheat", state->dataSingleDuct->sd_airterminal(2).sysType); // VAV HeatCool Reheat Type EXPECT_EQ("VAV CBP GAS REHEAT AT", state->dataSingleDuct->sd_airterminal(2).SysName); // VAV HeatCool Reheat Name - EXPECT_TRUE(state->dataSingleDuct->sd_airterminal(2).ZoneTurndownMinAirFracSchExist); // turndown schdule exists + EXPECT_TRUE(state->dataSingleDuct->sd_airterminal(2).zoneTurndownMinAirFracSched != nullptr); // turndown schdule exists EXPECT_EQ(state->dataSingleDuct->sd_airterminal(2).ZoneTurndownMinAirFrac, 1.0); // initialized to 1.0 EXPECT_EQ(state->dataSingleDuct->sd_airterminal(2).ZoneMinAirFracDes, 0.20); // design minimum flow fraction // VAV No reheat get input test EXPECT_EQ("AirTerminal:SingleDuct:VAV:NoReheat", state->dataSingleDuct->sd_airterminal(3).sysType); // VAV No Reheat Type EXPECT_EQ("VAV NO REHEAT AT", state->dataSingleDuct->sd_airterminal(3).SysName); // VAV No Reheat Name - EXPECT_TRUE(state->dataSingleDuct->sd_airterminal(3).ZoneTurndownMinAirFracSchExist); // turndown schdule exists + EXPECT_TRUE(state->dataSingleDuct->sd_airterminal(3).zoneTurndownMinAirFracSched != nullptr); // turndown schdule exists EXPECT_EQ(state->dataSingleDuct->sd_airterminal(3).ZoneTurndownMinAirFrac, 1.0); // initialized to 1.0 EXPECT_EQ(state->dataSingleDuct->sd_airterminal(3).ZoneMinAirFracDes, 0.25); // design minimum flow fraction // VAV change over bypass no reheat get input test EXPECT_EQ("AirTerminal:SingleDuct:VAV:HeatAndCool:NoReheat", state->dataSingleDuct->sd_airterminal(4).sysType); // VAV HeatCool NoReheat Type EXPECT_EQ("VAV CBP NOREHEAT AT", state->dataSingleDuct->sd_airterminal(4).SysName); // VAV HeatCool NoReheat Name - EXPECT_TRUE(state->dataSingleDuct->sd_airterminal(4).ZoneTurndownMinAirFracSchExist); // turndown schdule exists + EXPECT_TRUE(state->dataSingleDuct->sd_airterminal(4).zoneTurndownMinAirFracSched != nullptr); // turndown schdule exists EXPECT_EQ(state->dataSingleDuct->sd_airterminal(4).ZoneTurndownMinAirFrac, 1.0); // initialized to 1.0 EXPECT_EQ(state->dataSingleDuct->sd_airterminal(4).ZoneMinAirFracDes, 0.15); // design minimum flow fraction // VAV reheat variable speed fan get input test EXPECT_EQ("AirTerminal:SingleDuct:VAV:Reheat:VariableSpeedFan", state->dataSingleDuct->sd_airterminal(5).sysType); // VAV Reheat VSFan Type EXPECT_EQ("VAV REHEAT VS FAN", state->dataSingleDuct->sd_airterminal(5).SysName); // VAV Reheat VSFan Name - EXPECT_TRUE(state->dataSingleDuct->sd_airterminal(5).ZoneTurndownMinAirFracSchExist); // turndown schdule exists + EXPECT_TRUE(state->dataSingleDuct->sd_airterminal(5).zoneTurndownMinAirFracSched != nullptr); // turndown schdule exists EXPECT_EQ(state->dataSingleDuct->sd_airterminal(5).ZoneTurndownMinAirFrac, 1.0); // initialized to 1.0 EXPECT_EQ(state->dataSingleDuct->sd_airterminal(5).ZoneMinAirFracDes, 0.10); // design minimum flow fraction } @@ -1016,10 +1019,10 @@ TEST_F(EnergyPlusFixture, SingleDuctVAVReheatAirTerminal_MinFlowTurnDownTest) bool ErrorsFound = false; bool FirstHVACIteration = true; - state->dataGlobal->NumOfTimeStepInHour = 1; - state->dataGlobal->MinutesPerTimeStep = 60; - ScheduleManager::ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; + state->dataGlobal->TimeStepsInHour = 1; + state->dataGlobal->MinutesInTimeStep = 60; + state->init_state(*state); + state->dataEnvrn->Month = 1; state->dataEnvrn->DayOfMonth = 21; state->dataGlobal->HourOfDay = 1; @@ -1029,10 +1032,10 @@ TEST_F(EnergyPlusFixture, SingleDuctVAVReheatAirTerminal_MinFlowTurnDownTest) state->dataEnvrn->HolidayIndex = 0; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); state->dataEnvrn->StdRhoAir = Psychrometrics::PsyRhoAirFnPbTdbW(*state, 101325.0, 20.0, 0.0); - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); state->dataZoneEnergyDemand->ZoneSysEnergyDemand.allocate(1); state->dataHeatBalFanSys->TempControlType.allocate(1); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::DualSetPointWithDeadBand; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::DualHeatCool; HeatBalanceManager::GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); DataZoneEquipment::GetZoneEquipmentData(*state); @@ -1042,7 +1045,7 @@ TEST_F(EnergyPlusFixture, SingleDuctVAVReheatAirTerminal_MinFlowTurnDownTest) // check VAV reheat air terminal inputs EXPECT_EQ("AirTerminal:SingleDuct:VAV:Reheat", state->dataSingleDuct->sd_airterminal(SysNum).sysType); // VAV Reheat Type EXPECT_EQ("VAV REHEAT AT", state->dataSingleDuct->sd_airterminal(SysNum).SysName); // VAV Reheat Name - EXPECT_TRUE(state->dataSingleDuct->sd_airterminal(SysNum).ZoneTurndownMinAirFracSchExist); // turndown schdule exists + EXPECT_TRUE(state->dataSingleDuct->sd_airterminal(SysNum).zoneTurndownMinAirFracSched != nullptr); // turndown schdule exists EXPECT_EQ(state->dataSingleDuct->sd_airterminal(SysNum).ZoneTurndownMinAirFrac, 1.0); // initialized to 1.0 EXPECT_EQ(state->dataSingleDuct->sd_airterminal(SysNum).ZoneMinAirFracDes, 0.3); // input from VAV reheat air terminal EXPECT_EQ(state->dataSingleDuct->sd_airterminal(SysNum).MaxAirVolFlowRate, 1.0); // input from VAV reheat air terminal @@ -1055,7 +1058,7 @@ TEST_F(EnergyPlusFixture, SingleDuctVAVReheatAirTerminal_MinFlowTurnDownTest) int ZoneNodeNum = Util::FindItemInList("ZONE 1 AIR NODE", state->dataLoopNodes->NodeID); int InletNodeNum = Util::FindItemInList("NODE 24", state->dataLoopNodes->NodeID); state->dataZoneEnergyDemand->ZoneSysEnergyDemand(1).RemainingOutputRequired = 2000.0; - state->dataSingleDuct->sd_airterminal(SysNum).ZoneTurndownMinAirFracSchPtr = 1; // + state->dataSingleDuct->sd_airterminal(SysNum).zoneTurndownMinAirFracSched = Sched::GetSchedule(*state, "TURNDOWNMINAIRFLOWSCH1"); state->dataLoopNodes->Node(InletNodeNum).MassFlowRate = SysMaxMassFlowRes; state->dataLoopNodes->Node(InletNodeNum).MassFlowRateMaxAvail = SysMaxMassFlowRes; state->dataGlobal->BeginEnvrnFlag = true; @@ -1080,7 +1083,7 @@ TEST_F(EnergyPlusFixture, SingleDuctVAVReheatAirTerminal_MinFlowTurnDownTest) state->dataSingleDuct->sd_airterminal(SysNum).ZoneTurndownMinAirFrac); // test with heating load and turndown fraction schedule value set 0.5 - state->dataSingleDuct->sd_airterminal(SysNum).ZoneTurndownMinAirFracSchPtr = 2; + state->dataSingleDuct->sd_airterminal(SysNum).zoneTurndownMinAirFracSched = Sched::GetSchedule(*state, "TURNDOWNMINAIRFLOWSCH2"); SysMinMassFlowRes = 1.0 * state->dataEnvrn->StdRhoAir * 0.30 * 0.5; // min flow rate at 0.5 turndown fraction state->dataLoopNodes->Node(InletNodeNum).MassFlowRate = SysMaxMassFlowRes; state->dataLoopNodes->Node(InletNodeNum).MassFlowRateMaxAvail = SysMaxMassFlowRes; @@ -1226,10 +1229,11 @@ TEST_F(EnergyPlusFixture, SingleDuctVAVReheatVSFanAirTerminal_MinFlowTurnDownTes bool ErrorsFound = false; bool FirstHVACIteration = true; - state->dataGlobal->NumOfTimeStepInHour = 1; - state->dataGlobal->MinutesPerTimeStep = 60; - ScheduleManager::ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; + state->dataGlobal->TimeStepsInHour = 1; + state->dataGlobal->MinutesInTimeStep = 60; + + state->init_state(*state); + state->dataEnvrn->Month = 1; state->dataEnvrn->DayOfMonth = 21; state->dataGlobal->HourOfDay = 1; @@ -1239,10 +1243,10 @@ TEST_F(EnergyPlusFixture, SingleDuctVAVReheatVSFanAirTerminal_MinFlowTurnDownTes state->dataEnvrn->HolidayIndex = 0; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); state->dataEnvrn->StdRhoAir = Psychrometrics::PsyRhoAirFnPbTdbW(*state, 101325.0, 20.0, 0.0); - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); state->dataZoneEnergyDemand->ZoneSysEnergyDemand.allocate(1); state->dataHeatBalFanSys->TempControlType.allocate(1); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::DualSetPointWithDeadBand; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::DualHeatCool; HeatBalanceManager::GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); DataZoneEquipment::GetZoneEquipmentData(*state); @@ -1254,7 +1258,7 @@ TEST_F(EnergyPlusFixture, SingleDuctVAVReheatVSFanAirTerminal_MinFlowTurnDownTes int InletNodeNum = Util::FindItemInList("SPACE1-1 ATU IN NODE", state->dataLoopNodes->NodeID); EXPECT_EQ("AirTerminal:SingleDuct:VAV:Reheat:VariableSpeedFan", state->dataSingleDuct->sd_airterminal(SysNum).sysType); // VAV Reheat Type EXPECT_EQ("VAV REHEAT VS FAN AT", state->dataSingleDuct->sd_airterminal(SysNum).SysName); // VAV Reheat Name - EXPECT_TRUE(state->dataSingleDuct->sd_airterminal(SysNum).ZoneTurndownMinAirFracSchExist); // turndown schdule exists + EXPECT_TRUE(state->dataSingleDuct->sd_airterminal(SysNum).zoneTurndownMinAirFracSched != nullptr); // turndown schdule exists EXPECT_EQ(state->dataSingleDuct->sd_airterminal(SysNum).ZoneTurndownMinAirFrac, 1.0); // initialized to 1.0 EXPECT_EQ(state->dataSingleDuct->sd_airterminal(SysNum).ZoneMinAirFracDes, 0.1); // input from VAV reheat air terminal EXPECT_EQ(state->dataSingleDuct->sd_airterminal(SysNum).MaxAirVolFlowRate, 1.0); // input from VAV reheat air terminal @@ -1265,7 +1269,7 @@ TEST_F(EnergyPlusFixture, SingleDuctVAVReheatVSFanAirTerminal_MinFlowTurnDownTes // test with heating load and turndown fraction schedule value set 1.0 state->dataZoneEnergyDemand->ZoneSysEnergyDemand(1).RemainingOutputRequired = 2000.0; - state->dataSingleDuct->sd_airterminal(SysNum).ZoneTurndownMinAirFracSchPtr = 1; // + state->dataSingleDuct->sd_airterminal(SysNum).zoneTurndownMinAirFracSched = Sched::GetSchedule(*state, "TURNDOWNMINAIRFLOWSCH1"); // state->dataLoopNodes->Node(InletNodeNum).MassFlowRate = SysMaxMassFlowRes; state->dataLoopNodes->Node(InletNodeNum).MassFlowRateMaxAvail = SysMaxMassFlowRes; state->dataGlobal->BeginEnvrnFlag = true; @@ -1290,7 +1294,7 @@ TEST_F(EnergyPlusFixture, SingleDuctVAVReheatVSFanAirTerminal_MinFlowTurnDownTes state->dataSingleDuct->sd_airterminal(SysNum).ZoneTurndownMinAirFrac); // test with heating load and turndown fraction schedule value set 0.5 - state->dataSingleDuct->sd_airterminal(SysNum).ZoneTurndownMinAirFracSchPtr = 2; + state->dataSingleDuct->sd_airterminal(SysNum).zoneTurndownMinAirFracSched = Sched::GetSchedule(*state, "TURNDOWNMINAIRFLOWSCH2"); SysMinMassFlowRes = 1.0 * state->dataEnvrn->StdRhoAir * 0.10 * 0.5; // min flow rate at 0.5 turndown fraction state->dataLoopNodes->Node(InletNodeNum).MassFlowRate = SysMaxMassFlowRes; state->dataLoopNodes->Node(InletNodeNum).MassFlowRateMaxAvail = SysMaxMassFlowRes; @@ -1403,10 +1407,11 @@ TEST_F(EnergyPlusFixture, SingleDuctVAVHeatCoolReheatAirTerminal_MinFlowTurnDown bool ErrorsFound = false; bool FirstHVACIteration = true; - state->dataGlobal->NumOfTimeStepInHour = 1; - state->dataGlobal->MinutesPerTimeStep = 60; - ScheduleManager::ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; + state->dataGlobal->TimeStepsInHour = 1; + state->dataGlobal->MinutesInTimeStep = 60; + + state->init_state(*state); + state->dataEnvrn->Month = 1; state->dataEnvrn->DayOfMonth = 21; state->dataGlobal->HourOfDay = 1; @@ -1416,10 +1421,10 @@ TEST_F(EnergyPlusFixture, SingleDuctVAVHeatCoolReheatAirTerminal_MinFlowTurnDown state->dataEnvrn->HolidayIndex = 0; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); state->dataEnvrn->StdRhoAir = Psychrometrics::PsyRhoAirFnPbTdbW(*state, 101325.0, 20.0, 0.0); - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); state->dataZoneEnergyDemand->ZoneSysEnergyDemand.allocate(1); state->dataHeatBalFanSys->TempControlType.allocate(1); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::DualSetPointWithDeadBand; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::DualHeatCool; HeatBalanceManager::GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); DataZoneEquipment::GetZoneEquipmentData(*state); @@ -1429,7 +1434,7 @@ TEST_F(EnergyPlusFixture, SingleDuctVAVHeatCoolReheatAirTerminal_MinFlowTurnDown // check VAV heatcool reheat air terminal inputs EXPECT_EQ("AirTerminal:SingleDuct:VAV:HeatAndCool:Reheat", state->dataSingleDuct->sd_airterminal(SysNum).sysType); // VAV HeatCool Reheat Type EXPECT_EQ("VAV CBP GAS REHEAT AT", state->dataSingleDuct->sd_airterminal(SysNum).SysName); // VAV HeatCool Reheat Name - EXPECT_TRUE(state->dataSingleDuct->sd_airterminal(SysNum).ZoneTurndownMinAirFracSchExist); // turndown schdule exists + EXPECT_TRUE(state->dataSingleDuct->sd_airterminal(SysNum).zoneTurndownMinAirFracSched != nullptr); // turndown schdule exists EXPECT_EQ(state->dataSingleDuct->sd_airterminal(SysNum).ZoneTurndownMinAirFrac, 1.0); // initialized to 1.0 EXPECT_EQ(state->dataSingleDuct->sd_airterminal(SysNum).ZoneMinAirFracDes, 0.2); // input from VAV HeatCool reheat air terminal EXPECT_EQ(state->dataSingleDuct->sd_airterminal(SysNum).MaxAirVolFlowRate, 1.0); // input from VAV HeatCool reheat air terminal @@ -1442,7 +1447,7 @@ TEST_F(EnergyPlusFixture, SingleDuctVAVHeatCoolReheatAirTerminal_MinFlowTurnDown int ZoneNodeNum = Util::FindItemInList("ZONE 1 AIR NODE", state->dataLoopNodes->NodeID); int InletNodeNum = Util::FindItemInList("NODE 7", state->dataLoopNodes->NodeID); state->dataZoneEnergyDemand->ZoneSysEnergyDemand(1).RemainingOutputRequired = 2000.0; - state->dataSingleDuct->sd_airterminal(SysNum).ZoneTurndownMinAirFracSchPtr = 1; // + state->dataSingleDuct->sd_airterminal(SysNum).zoneTurndownMinAirFracSched = Sched::GetSchedule(*state, "TURNDOWNMINAIRFLOWSCH1"); // state->dataLoopNodes->Node(InletNodeNum).MassFlowRate = SysMaxMassFlowRes; state->dataLoopNodes->Node(InletNodeNum).MassFlowRateMaxAvail = SysMaxMassFlowRes; state->dataGlobal->BeginEnvrnFlag = true; @@ -1467,7 +1472,7 @@ TEST_F(EnergyPlusFixture, SingleDuctVAVHeatCoolReheatAirTerminal_MinFlowTurnDown state->dataSingleDuct->sd_airterminal(SysNum).ZoneTurndownMinAirFrac); // test with heating load and turndown fraction schedule value set 0.5 - state->dataSingleDuct->sd_airterminal(SysNum).ZoneTurndownMinAirFracSchPtr = 2; + state->dataSingleDuct->sd_airterminal(SysNum).zoneTurndownMinAirFracSched = Sched::GetSchedule(*state, "TURNDOWNMINAIRFLOWSCH2"); SysMinMassFlowRes = 1.0 * state->dataEnvrn->StdRhoAir * 0.20 * 0.5; // min flow rate at 0.5 turndown fraction state->dataLoopNodes->Node(InletNodeNum).MassFlowRate = SysMaxMassFlowRes; state->dataLoopNodes->Node(InletNodeNum).MassFlowRateMaxAvail = SysMaxMassFlowRes; @@ -1591,10 +1596,10 @@ TEST_F(EnergyPlusFixture, SingleDuctVAVReheatVSFan_DamperPositionTest) bool ErrorsFound = false; bool FirstHVACIteration = true; - state->dataGlobal->NumOfTimeStepInHour = 1; - state->dataGlobal->MinutesPerTimeStep = 60; - ScheduleManager::ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; + state->dataGlobal->TimeStepsInHour = 1; + state->dataGlobal->MinutesInTimeStep = 60; + state->init_state(*state); + state->dataEnvrn->Month = 1; state->dataEnvrn->DayOfMonth = 21; state->dataGlobal->HourOfDay = 1; @@ -1604,10 +1609,10 @@ TEST_F(EnergyPlusFixture, SingleDuctVAVReheatVSFan_DamperPositionTest) state->dataEnvrn->HolidayIndex = 0; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); state->dataEnvrn->StdRhoAir = Psychrometrics::PsyRhoAirFnPbTdbW(*state, 101325.0, 20.0, 0.0); - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); state->dataZoneEnergyDemand->ZoneSysEnergyDemand.allocate(1); state->dataHeatBalFanSys->TempControlType.allocate(1); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::DualSetPointWithDeadBand; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::DualHeatCool; HeatBalanceManager::GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); DataZoneEquipment::GetZoneEquipmentData(*state); @@ -1738,10 +1743,10 @@ TEST_F(EnergyPlusFixture, VAVHeatCoolReheatAirTerminal_ZoneOAVolumeFlowRateTest) bool ErrorsFound = false; bool FirstHVACIteration = true; - state->dataGlobal->NumOfTimeStepInHour = 1; - state->dataGlobal->MinutesPerTimeStep = 60; - ScheduleManager::ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; + state->dataGlobal->TimeStepsInHour = 1; + state->dataGlobal->MinutesInTimeStep = 60; + state->init_state(*state); + state->dataEnvrn->Month = 1; state->dataEnvrn->DayOfMonth = 21; state->dataGlobal->HourOfDay = 1; @@ -1751,10 +1756,10 @@ TEST_F(EnergyPlusFixture, VAVHeatCoolReheatAirTerminal_ZoneOAVolumeFlowRateTest) state->dataEnvrn->HolidayIndex = 0; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); state->dataEnvrn->StdRhoAir = Psychrometrics::PsyRhoAirFnPbTdbW(*state, 101325.0, 20.0, 0.0); - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); state->dataZoneEnergyDemand->ZoneSysEnergyDemand.allocate(1); state->dataHeatBalFanSys->TempControlType.allocate(1); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::DualSetPointWithDeadBand; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::DualHeatCool; HeatBalanceManager::GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); DataZoneEquipment::GetZoneEquipmentData(*state); diff --git a/tst/EnergyPlus/unit/AirTerminalSingleDuctConstantVolumeNoReheat.unit.cc b/tst/EnergyPlus/unit/AirTerminalSingleDuctConstantVolumeNoReheat.unit.cc index c481ca3c9c6..462e47b6147 100644 --- a/tst/EnergyPlus/unit/AirTerminalSingleDuctConstantVolumeNoReheat.unit.cc +++ b/tst/EnergyPlus/unit/AirTerminalSingleDuctConstantVolumeNoReheat.unit.cc @@ -79,7 +79,6 @@ using namespace EnergyPlus::DataLoopNode; using namespace EnergyPlus::DataZoneEquipment; using namespace EnergyPlus::HeatBalanceManager; using namespace EnergyPlus::Psychrometrics; -using namespace EnergyPlus::ScheduleManager; using namespace EnergyPlus::SingleDuct; using namespace EnergyPlus::ZoneAirLoopEquipmentManager; @@ -149,9 +148,9 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctCVNoReheat_GetInput) ASSERT_TRUE(process_idf(idf_objects)); - state->dataGlobal->NumOfTimeStepInHour = 1; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 60; // must initialize this to get schedules initialized - ProcessScheduleInput(*state); // read schedules + state->dataGlobal->TimeStepsInHour = 1; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 60; // must initialize this to get schedules initialized + state->init_state(*state); GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); @@ -163,7 +162,7 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctCVNoReheat_GetInput) EXPECT_EQ("AirTerminal:SingleDuct:ConstantVolume:NoReheat", state->dataSingleDuct->sd_airterminal(1).sysType); // AT SD constant volume no reheat object type EXPECT_EQ("SDCVNOREHEATAT1", state->dataSingleDuct->sd_airterminal(1).SysName); // AT SD constant volume no reheat name - EXPECT_EQ("AVAILSCHEDULE", state->dataSingleDuct->sd_airterminal(1).Schedule); // AT SD constant volume no reheat availability schedule name + EXPECT_EQ("AVAILSCHEDULE", state->dataSingleDuct->sd_airterminal(1).availSched->Name); // AT SD constant volume no reheat availability schedule name EXPECT_EQ(0.50, state->dataSingleDuct->sd_airterminal(1).MaxAirVolFlowRate); // maximum volume flow Rate ASSERT_TRUE(state->dataSingleDuct->sd_airterminal(1).NoOAFlowInputFromUser); // no OA flow input from user EXPECT_EQ(DataZoneEquipment::PerPersonVentRateMode::DCVByCurrentLevel, @@ -231,9 +230,9 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctCVNoReheat_SimConstVolNoReheat) ASSERT_TRUE(process_idf(idf_objects)); - state->dataGlobal->NumOfTimeStepInHour = 1; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 60; // must initialize this to get schedules initialized - ProcessScheduleInput(*state); // read schedules + state->dataGlobal->TimeStepsInHour = 1; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 60; // must initialize this to get schedules initialized + state->init_state(*state); GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); @@ -245,7 +244,7 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctCVNoReheat_SimConstVolNoReheat) int constexpr SysNum(1); Real64 MassFlowRateMaxAvail = state->dataSingleDuct->sd_airterminal(SysNum).MaxAirVolFlowRate * state->dataEnvrn->StdRhoAir; state->dataSingleDuct->sd_airterminal(SysNum).sd_airterminalInlet.AirMassFlowRate = MassFlowRateMaxAvail; - state->dataScheduleMgr->Schedule(state->dataSingleDuct->sd_airterminal(SysNum).SchedPtr).CurrentValue = 1.0; // unit is always available + state->dataSingleDuct->sd_airterminal(SysNum).availSched->currentVal = 1.0; // unit is always available // run SimConstVolNoReheat() function state->dataSingleDuct->sd_airterminal(SysNum).SimConstVolNoReheat(*state); // check the TA outlet air mass flow rate @@ -314,9 +313,9 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctCVNoReheat_Sim) ASSERT_TRUE(process_idf(idf_objects)); - state->dataGlobal->NumOfTimeStepInHour = 1; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 60; // must initialize this to get schedules initialized - ProcessScheduleInput(*state); // read schedules + state->dataGlobal->TimeStepsInHour = 1; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 60; // must initialize this to get schedules initialized + state->init_state(*state); GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); @@ -334,7 +333,7 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctCVNoReheat_Sim) int const InletNode = state->dataSingleDuct->sd_airterminal(SysNum).InletNodeNum; int const ZonePtr = state->dataSingleDuct->sd_airterminal(SysNum).CtrlZoneNum; int const ZoneAirNodeNum = state->dataZoneEquip->ZoneEquipConfig(ZonePtr).ZoneNode; - state->dataScheduleMgr->Schedule(state->dataSingleDuct->sd_airterminal(SysNum).SchedPtr).CurrentValue = 1.0; // unit is always available + state->dataSingleDuct->sd_airterminal(SysNum).availSched->currentVal = 1.0; // unit is always available // design maximum air mass flow rate Real64 MassFlowRateMaxAvail = state->dataSingleDuct->sd_airterminal(SysNum).MaxAirVolFlowRate * state->dataEnvrn->StdRhoAir; @@ -504,9 +503,9 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctCVNoReheat_OASpecification) ASSERT_TRUE(process_idf(idf_objects)); - state->dataGlobal->NumOfTimeStepInHour = 1; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 60; // must initialize this to get schedules initialized - ProcessScheduleInput(*state); // read schedules + state->dataGlobal->TimeStepsInHour = 1; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 60; // must initialize this to get schedules initialized + state->init_state(*state); GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); @@ -578,7 +577,7 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctCVNoReheat_OASpecification) // Full occupancy 3 people, OA/person = 0.1, OA/zone = 0.5, OA Sched = 1.0 state->dataGlobal->HourOfDay = 12; - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); // Just set number of people directly, too many other things that have to be in place to call ManagerInternalHeatGains() state->dataHeatBal->ZoneIntGain(1).NOFOCC = 3.0; Real64 expectedMassFlow = 1.0 * ((3.0 * 0.1) + 0.5); @@ -596,7 +595,7 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctCVNoReheat_OASpecification) // 50% occupancy 1.5 people, OA/person = 0.1, OA/zone = 0.5, OA Sched = 1.0 state->dataGlobal->HourOfDay = 12; - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); // Just set number of people directly, too many other things that have to be in place to call ManagerInternalHeatGains() state->dataHeatBal->ZoneIntGain(1).NOFOCC = 1.5; expectedMassFlow = 1.0 * ((1.5 * 0.1) + 0.5); @@ -612,7 +611,7 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctCVNoReheat_OASpecification) // Nighttime OA Sched = 0.0 state->dataGlobal->HourOfDay = 24; - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); // Just set number of people directly, too many other things that have to be in place to call ManagerInternalHeatGains() state->dataHeatBal->ZoneIntGain(1).NOFOCC = 1.5; expectedMassFlow = 0.0 * ((1.5 * 0.1) + 0.5); @@ -689,9 +688,9 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctCVNoReheat_EMSOverrideAirFlow) ASSERT_TRUE(process_idf(idf_objects)); - state->dataGlobal->NumOfTimeStepInHour = 1; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 60; // must initialize this to get schedules initialized - ProcessScheduleInput(*state); // read schedules + state->dataGlobal->TimeStepsInHour = 1; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 60; // must initialize this to get schedules initialized + state->init_state(*state); GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); @@ -709,7 +708,7 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctCVNoReheat_EMSOverrideAirFlow) int const InletNode = state->dataSingleDuct->sd_airterminal(SysNum).InletNodeNum; int const ZonePtr = state->dataSingleDuct->sd_airterminal(SysNum).CtrlZoneNum; int const ZoneAirNodeNum = state->dataZoneEquip->ZoneEquipConfig(ZonePtr).ZoneNode; - state->dataScheduleMgr->Schedule(state->dataSingleDuct->sd_airterminal(SysNum).SchedPtr).CurrentValue = 1.0; // unit is always available + state->dataSingleDuct->sd_airterminal(SysNum).availSched->currentVal = 1.0; // unit is always available // design maximum air mass flow rate Real64 MassFlowRateMaxAvail = state->dataSingleDuct->sd_airterminal(SysNum).MaxAirVolFlowRate * state->dataEnvrn->StdRhoAir; EXPECT_EQ(1.0, state->dataSingleDuct->sd_airterminal(SysNum).MaxAirVolFlowRate); @@ -878,9 +877,9 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctCVNoReheat_OAVolumeFlowRateReport ASSERT_TRUE(process_idf(idf_objects)); - state->dataGlobal->NumOfTimeStepInHour = 1; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 60; // must initialize this to get schedules initialized - ProcessScheduleInput(*state); // read schedules + state->dataGlobal->TimeStepsInHour = 1; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 60; // must initialize this to get schedules initialized + state->init_state(*state); GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); @@ -955,7 +954,7 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctCVNoReheat_OAVolumeFlowRateReport // Full occupancy 3 people, OA/person = 0.1, OA/zone = 0.5, OA Sched = 1.0 state->dataGlobal->HourOfDay = 12; - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); // Just set number of people directly, too many other things that have to be in place to call ManagerInternalHeatGains() state->dataHeatBal->ZoneIntGain(1).NOFOCC = 3.0; Real64 expectedMassFlow = 1.0 * ((3.0 * 0.1) + 0.5); @@ -970,7 +969,7 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctCVNoReheat_OAVolumeFlowRateReport // 50% occupancy 1.5 people, OA/person = 0.1, OA/zone = 0.5, OA Sched = 1.0 state->dataGlobal->HourOfDay = 12; - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); // Just set number of people directly, too many other things that have to be in place to call ManagerInternalHeatGains() state->dataHeatBal->ZoneIntGain(1).NOFOCC = 1.5; expectedMassFlow = 1.0 * ((1.5 * 0.1) + 0.5); @@ -983,7 +982,7 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctCVNoReheat_OAVolumeFlowRateReport // Nighttime OA Sched = 0.0 state->dataGlobal->HourOfDay = 24; - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); // Just set number of people directly, too many other things that have to be in place to call ManagerInternalHeatGains() state->dataHeatBal->ZoneIntGain(1).NOFOCC = 1.5; expectedMassFlow = 0.0 * ((1.5 * 0.1) + 0.5); @@ -1057,9 +1056,9 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctCVNoReheat_SimSensibleOutPutTest) ASSERT_TRUE(process_idf(idf_objects)); - state->dataGlobal->NumOfTimeStepInHour = 1; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 60; // must initialize this to get schedules initialized - ProcessScheduleInput(*state); // read schedules + state->dataGlobal->TimeStepsInHour = 1; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 60; // must initialize this to get schedules initialized + state->init_state(*state); GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); @@ -1083,7 +1082,7 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctCVNoReheat_SimSensibleOutPutTest) int const ZonePtr = thisAirTerminal.CtrlZoneNum; int const ZoneAirNodeNum = state->dataZoneEquip->ZoneEquipConfig(ZonePtr).ZoneNode; - state->dataScheduleMgr->Schedule(thisAirTerminal.SchedPtr).CurrentValue = 1.0; // unit is always available + thisAirTerminal.availSched->currentVal = 1.0; // unit is always available ; // design maximum air mass flow rate Real64 MassFlowRateMaxAvail = thisAirTerminal.MaxAirVolFlowRate * state->dataEnvrn->StdRhoAir; diff --git a/tst/EnergyPlus/unit/AirTerminalSingleDuctMixer.unit.cc b/tst/EnergyPlus/unit/AirTerminalSingleDuctMixer.unit.cc index 752ccc73f3b..142dd0c3919 100644 --- a/tst/EnergyPlus/unit/AirTerminalSingleDuctMixer.unit.cc +++ b/tst/EnergyPlus/unit/AirTerminalSingleDuctMixer.unit.cc @@ -102,7 +102,6 @@ using namespace EnergyPlus::HeatBalanceManager; using namespace EnergyPlus::HVACVariableRefrigerantFlow; using namespace EnergyPlus::OutputReportPredefined; using namespace EnergyPlus::Psychrometrics; -using namespace EnergyPlus::ScheduleManager; using namespace EnergyPlus::SingleDuct; using namespace EnergyPlus::UnitVentilator; using namespace EnergyPlus::WaterCoils; @@ -346,9 +345,9 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctMixer_GetInputPTAC_InletSide) ASSERT_TRUE(process_idf(idf_objects)); - state->dataGlobal->NumOfTimeStepInHour = 1; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 60; // must initialize this to get schedules initialized - ProcessScheduleInput(*state); // read schedules + state->dataGlobal->TimeStepsInHour = 1; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 60; // must initialize this to get schedules initialized + state->init_state(*state); GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); @@ -596,11 +595,11 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctMixer_SimPTAC_ATMInletSide) ASSERT_TRUE(process_idf(idf_objects)); - state->dataGlobal->NumOfTimeStepInHour = 1; + state->dataGlobal->TimeStepsInHour = 1; state->dataGlobal->TimeStep = 1; - state->dataGlobal->MinutesPerTimeStep = 60; - ProcessScheduleInput(*state); // read schedules - InitializePsychRoutines(*state); + state->dataGlobal->MinutesInTimeStep = 60; + state->init_state(*state); + OutputReportPredefined::SetPredefinedTables(*state); GetZoneData(*state, ErrorsFound); @@ -681,7 +680,7 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctMixer_SimPTAC_ATMInletSide) state->dataGlobal->SysSizingCalc = true; state->dataHeatBalFanSys->TempControlType.allocate(1); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::DualSetPointWithDeadBand; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::DualHeatCool; state->dataZoneEnergyDemand->ZoneSysMoistureDemand.allocate(1); state->dataZoneEnergyDemand->ZoneSysMoistureDemand(1).RemainingOutputReqToDehumidSP = 0.0; state->dataZoneEnergyDemand->ZoneSysEnergyDemand.allocate(1); @@ -690,8 +689,8 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctMixer_SimPTAC_ATMInletSide) state->dataZoneEnergyDemand->ZoneSysEnergyDemand(1).RemainingOutputRequired = -5000.0; QZnReq = state->dataZoneEnergyDemand->ZoneSysEnergyDemand(1).RemainingOutputReqToCoolSP; - state->dataScheduleMgr->Schedule(state->dataUnitarySystems->unitarySys[0].m_SysAvailSchedPtr).CurrentValue = 1.0; // unit is always available - state->dataScheduleMgr->Schedule(state->dataUnitarySystems->unitarySys[0].m_FanAvailSchedPtr).CurrentValue = 1.0; // fan is always available + state->dataUnitarySystems->unitarySys[0].m_sysAvailSched->currentVal = 1.0; // unit is always available + state->dataUnitarySystems->unitarySys[0].m_fanAvailSched->currentVal = 1.0; // fan is always available // set secondary air mass flow rate to zero state->dataLoopNodes->Node(state->dataSingleDuct->SysATMixer(1).SecInNode).MassFlowRate = 0.0; @@ -949,11 +948,11 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctMixer_SimPTAC_ATMSupplySide) ASSERT_TRUE(process_idf(idf_objects)); - state->dataGlobal->NumOfTimeStepInHour = 1; + state->dataGlobal->TimeStepsInHour = 1; state->dataGlobal->TimeStep = 1; - state->dataGlobal->MinutesPerTimeStep = 60; - ProcessScheduleInput(*state); // read schedules - InitializePsychRoutines(*state); + state->dataGlobal->MinutesInTimeStep = 60; + state->init_state(*state); + OutputReportPredefined::SetPredefinedTables(*state); GetZoneData(*state, ErrorsFound); @@ -1035,7 +1034,7 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctMixer_SimPTAC_ATMSupplySide) state->dataGlobal->SysSizingCalc = true; state->dataHeatBalFanSys->TempControlType.allocate(1); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::DualSetPointWithDeadBand; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::DualHeatCool; state->dataZoneEnergyDemand->ZoneSysMoistureDemand.allocate(1); state->dataZoneEnergyDemand->ZoneSysMoistureDemand(1).RemainingOutputReqToDehumidSP = 0.0; state->dataZoneEnergyDemand->ZoneSysEnergyDemand.allocate(1); @@ -1044,8 +1043,8 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctMixer_SimPTAC_ATMSupplySide) state->dataZoneEnergyDemand->ZoneSysEnergyDemand(1).RemainingOutputRequired = -5000.0; QZnReq = state->dataZoneEnergyDemand->ZoneSysEnergyDemand(1).RemainingOutputReqToCoolSP; - state->dataScheduleMgr->Schedule(state->dataUnitarySystems->unitarySys[0].m_SysAvailSchedPtr).CurrentValue = 1.0; // unit is always available - state->dataScheduleMgr->Schedule(state->dataUnitarySystems->unitarySys[0].m_FanAvailSchedPtr).CurrentValue = 1.0; // fan is always available + state->dataUnitarySystems->unitarySys[0].m_sysAvailSched->currentVal = 1.0; // unit is always available + state->dataUnitarySystems->unitarySys[0].m_fanAvailSched->currentVal = 1.0; // fan is always available // set secondary air mass flow rate to zero state->dataLoopNodes->Node(state->dataSingleDuct->SysATMixer(1).SecInNode).MassFlowRate = 0.0; @@ -1388,11 +1387,11 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctMixer_SimPTHP_ATMInletSide) ASSERT_TRUE(process_idf(idf_objects)); - state->dataGlobal->NumOfTimeStepInHour = 1; + state->dataGlobal->TimeStepsInHour = 1; state->dataGlobal->TimeStep = 1; - state->dataGlobal->MinutesPerTimeStep = 60; - ProcessScheduleInput(*state); // read schedules - InitializePsychRoutines(*state); + state->dataGlobal->MinutesInTimeStep = 60; + state->init_state(*state); + OutputReportPredefined::SetPredefinedTables(*state); GetZoneData(*state, ErrorsFound); @@ -1474,7 +1473,7 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctMixer_SimPTHP_ATMInletSide) state->dataGlobal->SysSizingCalc = true; state->dataHeatBalFanSys->TempControlType.allocate(1); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::DualSetPointWithDeadBand; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::DualHeatCool; state->dataZoneEnergyDemand->ZoneSysMoistureDemand.allocate(1); state->dataZoneEnergyDemand->ZoneSysMoistureDemand(1).RemainingOutputReqToDehumidSP = 0.0; state->dataZoneEnergyDemand->ZoneSysEnergyDemand.allocate(1); @@ -1483,8 +1482,8 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctMixer_SimPTHP_ATMInletSide) state->dataZoneEnergyDemand->ZoneSysEnergyDemand(1).RemainingOutputRequired = -5000.0; QZnReq = state->dataZoneEnergyDemand->ZoneSysEnergyDemand(1).RemainingOutputReqToCoolSP; - state->dataScheduleMgr->Schedule(state->dataUnitarySystems->unitarySys[0].m_SysAvailSchedPtr).CurrentValue = 1.0; // unit is always available - state->dataScheduleMgr->Schedule(state->dataUnitarySystems->unitarySys[0].m_FanAvailSchedPtr).CurrentValue = 1.0; // fan is always available + state->dataUnitarySystems->unitarySys[0].m_sysAvailSched->currentVal = 1.0; // unit is always available + state->dataUnitarySystems->unitarySys[0].m_fanAvailSched->currentVal = 1.0; // fan is always available // set secondary air mass flow rate to zero state->dataLoopNodes->Node(state->dataSingleDuct->SysATMixer(1).SecInNode).MassFlowRate = 0.0; @@ -1826,11 +1825,11 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctMixer_SimPTHP_ATMSupplySide) ASSERT_TRUE(process_idf(idf_objects)); - state->dataGlobal->NumOfTimeStepInHour = 1; + state->dataGlobal->TimeStepsInHour = 1; state->dataGlobal->TimeStep = 1; - state->dataGlobal->MinutesPerTimeStep = 60; - ProcessScheduleInput(*state); // read schedules - InitializePsychRoutines(*state); + state->dataGlobal->MinutesInTimeStep = 60; + state->init_state(*state); + OutputReportPredefined::SetPredefinedTables(*state); GetZoneData(*state, ErrorsFound); @@ -1912,7 +1911,7 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctMixer_SimPTHP_ATMSupplySide) state->dataGlobal->SysSizingCalc = true; state->dataHeatBalFanSys->TempControlType.allocate(1); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::DualSetPointWithDeadBand; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::DualHeatCool; state->dataZoneEnergyDemand->ZoneSysMoistureDemand.allocate(1); state->dataZoneEnergyDemand->ZoneSysMoistureDemand(1).RemainingOutputReqToDehumidSP = 0.0; state->dataZoneEnergyDemand->ZoneSysEnergyDemand.allocate(1); @@ -1921,8 +1920,8 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctMixer_SimPTHP_ATMSupplySide) state->dataZoneEnergyDemand->ZoneSysEnergyDemand(1).RemainingOutputRequired = -5000.0; QZnReq = state->dataZoneEnergyDemand->ZoneSysEnergyDemand(1).RemainingOutputReqToCoolSP; - state->dataScheduleMgr->Schedule(state->dataUnitarySystems->unitarySys[0].m_SysAvailSchedPtr).CurrentValue = 1.0; // unit is always available - state->dataScheduleMgr->Schedule(state->dataUnitarySystems->unitarySys[0].m_FanAvailSchedPtr).CurrentValue = 1.0; // fan is always available + state->dataUnitarySystems->unitarySys[0].m_sysAvailSched->currentVal = 1.0; // unit is always available + state->dataUnitarySystems->unitarySys[0].m_fanAvailSched->currentVal = 1.0; // fan is always available // set secondary air mass flow rate to zero state->dataLoopNodes->Node(state->dataSingleDuct->SysATMixer(1).SecInNode).MassFlowRate = 0.0; @@ -2521,6 +2520,9 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctMixer_SimVRF_ATMInletSide) }); ASSERT_TRUE(process_idf(idf_objects)); + state->dataGlobal->TimeStepsInHour = 1; + state->dataGlobal->MinutesInTimeStep = 60; + state->init_state(*state); // set input variables state->dataEnvrn->OutBaroPress = 101325.0; @@ -2529,11 +2531,8 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctMixer_SimVRF_ATMInletSide) state->dataEnvrn->OutEnthalpy = Psychrometrics::PsyHFnTdbW(state->dataEnvrn->OutDryBulbTemp, state->dataEnvrn->OutHumRat); state->dataEnvrn->StdRhoAir = 1.20; - state->dataGlobal->NumOfTimeStepInHour = 1; state->dataGlobal->TimeStep = 1; - state->dataGlobal->MinutesPerTimeStep = 60; - ProcessScheduleInput(*state); // read schedules - InitializePsychRoutines(*state); + OutputReportPredefined::SetPredefinedTables(*state); GetZoneData(*state, ErrorsFound); @@ -2621,8 +2620,8 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctMixer_SimVRF_ATMInletSide) state->dataZoneEnergyDemand->ZoneSysEnergyDemand(1).RemainingOutputReqToCoolSP = -5000.0; QZnReq = state->dataZoneEnergyDemand->ZoneSysEnergyDemand(1).RemainingOutputReqToCoolSP; - state->dataScheduleMgr->Schedule(state->dataHVACVarRefFlow->VRFTU(VRFTUNum).SchedPtr).CurrentValue = 1.0; // unit is always available - state->dataScheduleMgr->Schedule(state->dataHVACVarRefFlow->VRFTU(VRFTUNum).FanAvailSchedPtr).CurrentValue = 1.0; // fan is always available + state->dataHVACVarRefFlow->VRFTU(VRFTUNum).availSched->currentVal = 1.0; // unit is always available + state->dataHVACVarRefFlow->VRFTU(VRFTUNum).fanAvailSched->currentVal = 1.0; // fan is always available // set secondary air mass flow rate to zero state->dataLoopNodes->Node(state->dataSingleDuct->SysATMixer(1).SecInNode).MassFlowRate = 0.0; @@ -3206,6 +3205,11 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctMixer_SimVRF_ATMSupplySide) ASSERT_TRUE(process_idf(idf_objects)); + state->dataGlobal->TimeStepsInHour = 1; + state->dataGlobal->TimeStep = 1; + state->dataGlobal->MinutesInTimeStep = 60; + state->init_state(*state); + // set input variables before input processing state->dataEnvrn->OutBaroPress = 101325.0; state->dataEnvrn->OutDryBulbTemp = 35.0; @@ -3213,11 +3217,6 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctMixer_SimVRF_ATMSupplySide) state->dataEnvrn->OutEnthalpy = Psychrometrics::PsyHFnTdbW(state->dataEnvrn->OutDryBulbTemp, state->dataEnvrn->OutHumRat); state->dataEnvrn->StdRhoAir = 1.20; - state->dataGlobal->NumOfTimeStepInHour = 1; - state->dataGlobal->TimeStep = 1; - state->dataGlobal->MinutesPerTimeStep = 60; - ProcessScheduleInput(*state); // read schedules - InitializePsychRoutines(*state); OutputReportPredefined::SetPredefinedTables(*state); GetZoneData(*state, ErrorsFound); @@ -3302,8 +3301,8 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctMixer_SimVRF_ATMSupplySide) state->dataZoneEnergyDemand->ZoneSysEnergyDemand(1).RemainingOutputReqToCoolSP = -4000.0; QZnReq = state->dataZoneEnergyDemand->ZoneSysEnergyDemand(1).RemainingOutputReqToCoolSP; - state->dataScheduleMgr->Schedule(state->dataHVACVarRefFlow->VRFTU(VRFTUNum).SchedPtr).CurrentValue = 1.0; // unit is always available - state->dataScheduleMgr->Schedule(state->dataHVACVarRefFlow->VRFTU(VRFTUNum).FanAvailSchedPtr).CurrentValue = 1.0; // fan is always available + state->dataHVACVarRefFlow->VRFTU(VRFTUNum).availSched->currentVal = 1.0; // unit is always available + state->dataHVACVarRefFlow->VRFTU(VRFTUNum).fanAvailSched->currentVal = 1.0; // fan is always available // set secondary air mass flow rate to zero state->dataLoopNodes->Node(state->dataSingleDuct->SysATMixer(1).SecInNode).MassFlowRate = 0.0; @@ -4978,10 +4977,11 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctMixer_SimVRFfluidCntrl_ATMInletSi ASSERT_TRUE(process_idf(idf_objects)); - state->dataGlobal->NumOfTimeStepInHour = 1; + state->dataGlobal->TimeStepsInHour = 1; state->dataGlobal->TimeStep = 1; - state->dataGlobal->MinutesPerTimeStep = 60; - ProcessScheduleInput(*state); // read schedules + state->dataGlobal->MinutesInTimeStep = 60; + state->init_state(*state); + OutputReportPredefined::SetPredefinedTables(*state); GetZoneData(*state, ErrorsFound); @@ -5075,8 +5075,8 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctMixer_SimVRFfluidCntrl_ATMInletSi state->dataZoneEnergyDemand->ZoneSysEnergyDemand(1).RemainingOutputReqToCoolSP = -5000.0; QZnReq = state->dataZoneEnergyDemand->ZoneSysEnergyDemand(1).RemainingOutputReqToCoolSP; - state->dataScheduleMgr->Schedule(state->dataHVACVarRefFlow->VRFTU(VRFTUNum).SchedPtr).CurrentValue = 1.0; // unit is always available - state->dataScheduleMgr->Schedule(state->dataHVACVarRefFlow->VRFTU(VRFTUNum).FanAvailSchedPtr).CurrentValue = 1.0; // fan is always available + state->dataHVACVarRefFlow->VRFTU(VRFTUNum).availSched->currentVal = 1.0; // unit is always available + state->dataHVACVarRefFlow->VRFTU(VRFTUNum).fanAvailSched->currentVal = 1.0; // fan is always available // set secondary air mass flow rate to zero state->dataLoopNodes->Node(state->dataSingleDuct->SysATMixer(1).SecInNode).MassFlowRate = 0.0; @@ -6756,11 +6756,11 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctMixer_SimVRFfluidCntrl_ATMSupplyS ASSERT_TRUE(process_idf(idf_objects)); - state->dataGlobal->NumOfTimeStepInHour = 1; + state->dataGlobal->TimeStepsInHour = 1; state->dataGlobal->TimeStep = 1; - state->dataGlobal->MinutesPerTimeStep = 60; - ProcessScheduleInput(*state); // read schedules - InitializePsychRoutines(*state); + state->dataGlobal->MinutesInTimeStep = 60; + state->init_state(*state); + OutputReportPredefined::SetPredefinedTables(*state); GetZoneData(*state, ErrorsFound); @@ -6851,8 +6851,8 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctMixer_SimVRFfluidCntrl_ATMSupplyS state->dataZoneEnergyDemand->ZoneSysEnergyDemand(1).RemainingOutputReqToCoolSP = -4000.0; QZnReq = state->dataZoneEnergyDemand->ZoneSysEnergyDemand(1).RemainingOutputReqToCoolSP; - state->dataScheduleMgr->Schedule(state->dataHVACVarRefFlow->VRFTU(VRFTUNum).SchedPtr).CurrentValue = 1.0; // unit is always available - state->dataScheduleMgr->Schedule(state->dataHVACVarRefFlow->VRFTU(VRFTUNum).FanAvailSchedPtr).CurrentValue = 1.0; // fan is always available + state->dataHVACVarRefFlow->VRFTU(VRFTUNum).availSched->currentVal = 1.0; // unit is always available + state->dataHVACVarRefFlow->VRFTU(VRFTUNum).fanAvailSched->currentVal = 1.0; // fan is always available state->dataHVACVarRefFlow->VRF(1).VRFCondCyclingRatio = 1.0; state->dataFans->fans(1)->set_size(*state); // add fan sizing @@ -7009,11 +7009,11 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctMixer_SimUnitVent_ATMInletSide) ASSERT_TRUE(process_idf(idf_objects)); - state->dataGlobal->NumOfTimeStepInHour = 1; + state->dataGlobal->TimeStepsInHour = 1; state->dataGlobal->TimeStep = 1; - state->dataGlobal->MinutesPerTimeStep = 60; - ProcessScheduleInput(*state); // read schedules - InitializePsychRoutines(*state); + state->dataGlobal->MinutesInTimeStep = 60; + state->init_state(*state); + OutputReportPredefined::SetPredefinedTables(*state); GetZoneData(*state, ErrorsFound); @@ -7098,11 +7098,9 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctMixer_SimUnitVent_ATMInletSide) state->dataZoneEnergyDemand->ZoneSysEnergyDemand(1).RemainingOutputRequired = 5000.0; state->dataUnitVentilators->QZnReq = state->dataZoneEnergyDemand->ZoneSysEnergyDemand(1).RemainingOutputRequired; - state->dataScheduleMgr->Schedule(state->dataUnitVentilators->UnitVent(UnitVentNum).SchedPtr).CurrentValue = 1.0; // unit is always available - state->dataScheduleMgr->Schedule(state->dataUnitVentilators->UnitVent(UnitVentNum).FanAvailSchedPtr).CurrentValue = - 1.0; // fan is always available - state->dataScheduleMgr->Schedule(state->dataUnitVentilators->UnitVent(UnitVentNum).MinOASchedPtr).CurrentValue = - 0.5; // min OA fraction is always available + state->dataUnitVentilators->UnitVent(UnitVentNum).availSched->currentVal = 1.0; // unit is always available + state->dataUnitVentilators->UnitVent(UnitVentNum).fanAvailSched->currentVal = 1.0; // fan is always available + state->dataUnitVentilators->UnitVent(UnitVentNum).minOASched->currentVal = 0.5; // min OA fraction is always available // set secondary air mass flow rate to zero state->dataLoopNodes->Node(state->dataSingleDuct->SysATMixer(1).SecInNode).MassFlowRate = 0.0; @@ -7257,11 +7255,11 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctMixer_SimUnitVent_ATMSupplySide) ASSERT_TRUE(process_idf(idf_objects)); - state->dataGlobal->NumOfTimeStepInHour = 1; + state->dataGlobal->TimeStepsInHour = 1; state->dataGlobal->TimeStep = 1; - state->dataGlobal->MinutesPerTimeStep = 60; - ProcessScheduleInput(*state); // read schedules - InitializePsychRoutines(*state); + state->dataGlobal->MinutesInTimeStep = 60; + state->init_state(*state); + OutputReportPredefined::SetPredefinedTables(*state); GetZoneData(*state, ErrorsFound); @@ -7346,11 +7344,9 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctMixer_SimUnitVent_ATMSupplySide) state->dataZoneEnergyDemand->ZoneSysEnergyDemand(ZoneNum).RemainingOutputRequired = 5000.0; QZnReq = state->dataZoneEnergyDemand->ZoneSysEnergyDemand(1).RemainingOutputRequired; - state->dataScheduleMgr->Schedule(state->dataUnitVentilators->UnitVent(UnitVentNum).SchedPtr).CurrentValue = 1.0; // unit is always available - state->dataScheduleMgr->Schedule(state->dataUnitVentilators->UnitVent(UnitVentNum).FanAvailSchedPtr).CurrentValue = - 1.0; // fan is always available - state->dataScheduleMgr->Schedule(state->dataUnitVentilators->UnitVent(UnitVentNum).MinOASchedPtr).CurrentValue = - 0.5; // min OA fraction is always available + state->dataUnitVentilators->UnitVent(UnitVentNum).availSched->currentVal = 1.0; // unit is always available + state->dataUnitVentilators->UnitVent(UnitVentNum).fanAvailSched->currentVal = 1.0; // fan is always available + state->dataUnitVentilators->UnitVent(UnitVentNum).minOASched->currentVal = 0.5; // min OA fraction is always available // set secondary air mass flow rate to zero state->dataLoopNodes->Node(state->dataSingleDuct->SysATMixer(1).SecInNode).MassFlowRate = 0.0; @@ -7513,6 +7509,8 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctMixer_GetInputDOASpecs) ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); @@ -7703,22 +7701,21 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctMixer_SimFCU_ATMInletSideTest) int ZoneNum(1); int FanCoilNum(1); + state->dataGlobal->TimeStepsInHour = 1; + state->dataGlobal->TimeStep = 1; + state->dataGlobal->MinutesInTimeStep = 60; + state->init_state(*state); + state->dataSize->CurZoneEqNum = 1; + state->dataEnvrn->OutBaroPress = 101325.0; state->dataEnvrn->StdRhoAir = Psychrometrics::PsyRhoAirFnPbTdbW(*state, state->dataEnvrn->OutBaroPress, 20.0, 0.0); state->dataWaterCoils->GetWaterCoilsInputFlag = true; - state->dataGlobal->NumOfTimeStepInHour = 1; - state->dataGlobal->TimeStep = 1; - state->dataGlobal->MinutesPerTimeStep = 60; - ProcessScheduleInput(*state); // read schedules - InitializePsychRoutines(*state); OutputReportPredefined::SetPredefinedTables(*state); GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); GetZoneEquipmentData(*state); - ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; GetFanCoilUnits(*state); auto &thisFanCoil(state->dataFanCoilUnits->FanCoil(1)); @@ -7810,7 +7807,7 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctMixer_SimFCU_ATMInletSideTest) state->dataEnvrn->DayOfWeek = 2; state->dataEnvrn->HolidayIndex = 0; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); - UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); state->dataSize->ZoneEqSizing.allocate(1); auto &zoneEqSizing(state->dataSize->ZoneEqSizing(1)); @@ -7818,7 +7815,7 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctMixer_SimFCU_ATMInletSideTest) state->dataZoneEnergyDemand->CurDeadBandOrSetback.allocate(1); state->dataZoneEnergyDemand->CurDeadBandOrSetback(1) = false; state->dataHeatBalFanSys->TempControlType.allocate(1); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::DualSetPointWithDeadBand; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::DualHeatCool; state->dataSize->ZoneSizingRunDone = true; state->dataSize->FinalZoneSizing.allocate(1); @@ -7949,14 +7946,6 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctMixer_FCU_NightCycleTest) std::string const idf_objects = delimited_string({ - " Schedule:Compact,", - " AlwaysOn, !- Name", - " Fraction, !- Schedule Type Limits Name", - " Through: 12/31, !- Field 1", - " For: AllDays, !- Field 2", - " Until: 24:00, !- Field 16", - " 1.0; !- Field 17", - " Schedule:Compact,", " FanAvailSched, !- Name", " Fraction, !- Schedule Type Limits Name", @@ -8050,7 +8039,7 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctMixer_FCU_NightCycleTest) " Fan:VariableVolume,", " FCU VarFan, !- Name", - " AlwaysOn, !- Availability Schedule Name", + " Constant-1.0, !- Availability Schedule Name", " 0.6045, !- Fan Total Efficiency", " 600.0, !- Pressure Rise {Pa}", " Autosize, !- Maximum Flow Rate {m3/s}", @@ -8070,7 +8059,7 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctMixer_FCU_NightCycleTest) " Coil:Cooling:Water,", " FCU Cooling Coil, !- Name", - " AlwaysOn, !- Availability Schedule Name", + " Constant-1.0, !- Availability Schedule Name", " Autosize, !- Design Water Flow Rate {m3/s}", " Autosize, !- Design Air Flow Rate {m3/s}", " Autosize, !- Design Inlet Water Temperature {C}", @@ -8087,7 +8076,7 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctMixer_FCU_NightCycleTest) " Coil:Heating:Water,", " FCU Heating Coil, !- Name", - " AlwaysOn, !- Availability Schedule Name", + " Constant-1.0, !- Availability Schedule Name", " Autosize, !- U-Factor Times Area Value {W/K}", " Autosize, !- Maximum Water Flow Rate {m3/s}", " Node 67, !- Water Inlet Node Name", @@ -8109,7 +8098,7 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctMixer_FCU_NightCycleTest) " AvailabilityManager:NightCycle,", " NightCycle AvailMgr, !- Name", - " AlwaysOn, !- Applicability Schedule Name", + " Constant-1.0, !- Applicability Schedule Name", " FanAvailSched, !- Fan Schedule Name", " CycleOnControlZone, !- Control Type", " 0.2, !- Thermostat Tolerance {deltaC}", @@ -8136,18 +8125,16 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctMixer_FCU_NightCycleTest) state->dataEnvrn->OutBaroPress = 101325.0; state->dataEnvrn->StdRhoAir = Psychrometrics::PsyRhoAirFnPbTdbW(*state, state->dataEnvrn->OutBaroPress, 20.0, 0.0); state->dataWaterCoils->GetWaterCoilsInputFlag = true; - state->dataGlobal->NumOfTimeStepInHour = 1; + state->dataGlobal->TimeStepsInHour = 1; state->dataGlobal->TimeStep = 1; - state->dataGlobal->MinutesPerTimeStep = 60; - ProcessScheduleInput(*state); // read schedules - InitializePsychRoutines(*state); + state->dataGlobal->MinutesInTimeStep = 60; + state->init_state(*state); + OutputReportPredefined::SetPredefinedTables(*state); GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); GetZoneEquipmentData(*state); - ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; GetFanCoilUnits(*state); Avail::GetSysAvailManagerInputs(*state); @@ -8242,7 +8229,7 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctMixer_FCU_NightCycleTest) state->dataEnvrn->DayOfWeek = 2; state->dataEnvrn->HolidayIndex = 0; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); - UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); state->dataSize->ZoneEqSizing.allocate(1); auto &zoneEqSizing(state->dataSize->ZoneEqSizing(1)); @@ -8250,7 +8237,7 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctMixer_FCU_NightCycleTest) state->dataZoneEnergyDemand->CurDeadBandOrSetback.allocate(1); state->dataZoneEnergyDemand->CurDeadBandOrSetback(1) = false; state->dataHeatBalFanSys->TempControlType.allocate(1); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::DualSetPointWithDeadBand; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::DualHeatCool; state->dataSize->ZoneSizingRunDone = true; state->dataSize->FinalZoneSizing.allocate(1); diff --git a/tst/EnergyPlus/unit/AirTerminalSingleDuctPIUReheat.unit.cc b/tst/EnergyPlus/unit/AirTerminalSingleDuctPIUReheat.unit.cc index 615b8a1176a..e610295108d 100644 --- a/tst/EnergyPlus/unit/AirTerminalSingleDuctPIUReheat.unit.cc +++ b/tst/EnergyPlus/unit/AirTerminalSingleDuctPIUReheat.unit.cc @@ -67,7 +67,6 @@ using namespace EnergyPlus::DataEnvironment; using namespace EnergyPlus::DataZoneEquipment; using namespace EnergyPlus::HeatBalanceManager; using namespace EnergyPlus::PoweredInductionUnits; -using namespace EnergyPlus::ScheduleManager; using namespace EnergyPlus::SimulationManager; using namespace EnergyPlus::ZoneAirLoopEquipmentManager; @@ -176,9 +175,9 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctSeriesPIUReheat_GetInputtest) ASSERT_TRUE(process_idf(idf_objects)); - state->dataGlobal->NumOfTimeStepInHour = 1; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 60; // must initialize this to get schedules initialized - ProcessScheduleInput(*state); // read schedules + state->dataGlobal->TimeStepsInHour = 1; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 60; // must initialize this to get schedules initialized + state->init_state(*state); GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); @@ -286,9 +285,9 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctSeriesPIU_SetADUInletNodeTest) ASSERT_TRUE(process_idf(idf_objects)); - state->dataGlobal->NumOfTimeStepInHour = 1; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 60; // must initialize this to get schedules initialized - ProcessScheduleInput(*state); // read schedules + state->dataGlobal->TimeStepsInHour = 1; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 60; // must initialize this to get schedules initialized + state->init_state(*state); GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); diff --git a/tst/EnergyPlus/unit/AirflowNetworkComponents.unit.cc b/tst/EnergyPlus/unit/AirflowNetworkComponents.unit.cc index 07854f82f6a..57e39dacc44 100644 --- a/tst/EnergyPlus/unit/AirflowNetworkComponents.unit.cc +++ b/tst/EnergyPlus/unit/AirflowNetworkComponents.unit.cc @@ -478,6 +478,7 @@ TEST_F(EnergyPlusFixture, AirflowNetwork_TestTriangularWindowWarning) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); state->afn->get_input(); std::string const error_string = delimited_string({ " ** Warning ** AirflowNetwork::Solver::get_input: AirflowNetwork:MultiZone:Surface=\"WINDOW1\".", @@ -1859,13 +1860,14 @@ TEST_F(EnergyPlusFixture, AirflowNetwork_UserDefinedDuctViewFactors) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); // Read objects HeatBalanceManager::GetHeatBalanceInput(*state); HeatBalanceManager::AllocateHeatBalArrays(*state); state->dataEnvrn->OutBaroPress = 101000; state->dataHVACGlobal->TimeStepSys = state->dataGlobal->TimeStepZone; - state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; // Read AirflowNetwork inputs state->afn->get_input(); @@ -2441,6 +2443,7 @@ TEST_F(EnergyPlusFixture, AirflowNetwork_TestPolygonalWindows) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); state->afn->get_input(); @@ -4373,6 +4376,7 @@ TEST_F(EnergyPlusFixture, AirflowNetwork_TestFanModel) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); state->dataIPShortCut->lNumericFieldBlanks.allocate(1000); state->dataIPShortCut->lAlphaFieldBlanks.allocate(1000); @@ -4410,20 +4414,20 @@ TEST_F(EnergyPlusFixture, AirflowNetwork_TestFanModel) // Read AirflowNetwork inputs state->afn->get_input(); - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; - state->dataScheduleMgr->Schedule(2).CurrentValue = 100.0; - state->dataScheduleMgr->Schedule(3).CurrentValue = 1.0; - state->dataScheduleMgr->Schedule(4).CurrentValue = 1.0; - state->dataScheduleMgr->Schedule(5).CurrentValue = 0.1; - state->dataScheduleMgr->Schedule(6).CurrentValue = 1.0; - state->dataScheduleMgr->Schedule(7).CurrentValue = 1.0; - state->dataScheduleMgr->Schedule(8).CurrentValue = 1.0; - state->dataScheduleMgr->Schedule(9).CurrentValue = 1.0; - state->dataScheduleMgr->Schedule(10).CurrentValue = 1.0; - state->dataScheduleMgr->Schedule(11).CurrentValue = 21.0; - state->dataScheduleMgr->Schedule(12).CurrentValue = 25.0; - state->dataScheduleMgr->Schedule(13).CurrentValue = 1.0; - state->dataScheduleMgr->Schedule(14).CurrentValue = 1.0; + Sched::GetSchedule(*state, "WINDOWVENTSCHED")->currentVal = 1.0; + Sched::GetSchedule(*state, "ACTIVITY SCH")->currentVal = 100.0; + Sched::GetSchedule(*state, "WORK EFF SCH")->currentVal = 1.0; + Sched::GetSchedule(*state, "CLOTHING SCH")->currentVal = 1.0; + Sched::GetSchedule(*state, "AIR VELO SCH")->currentVal = 0.1; + Sched::GetSchedule(*state, "HOUSE OCCUPANCY")->currentVal = 1.0; + Sched::GetSchedule(*state, "INTERMITTENT")->currentVal = 1.0; + Sched::GetSchedule(*state, "HOUSE LIGHTING")->currentVal = 1.0; + Sched::GetSchedule(*state, "REPORTSCH")->currentVal = 1.0; + Sched::GetSchedule(*state, "HVACAVAILSCHED")->currentVal = 1.0; + Sched::GetSchedule(*state, "DUAL HEATING SETPOINTS")->currentVal = 21.0; + Sched::GetSchedule(*state, "DUAL COOLING SETPOINTS")->currentVal = 25.0; + Sched::GetSchedule(*state, "DUAL ZONE CONTROL TYPE SCHED")->currentVal = 1.0; + Sched::GetSchedule(*state, "CYCLINGFANSCHEDULE")->currentVal = 1.0; state->afn->AirflowNetworkFanActivated = true; state->dataEnvrn->OutDryBulbTemp = -17.29025; diff --git a/tst/EnergyPlus/unit/AirflowNetworkConditions.unit.cc b/tst/EnergyPlus/unit/AirflowNetworkConditions.unit.cc index 1d142e5d7b6..a6792b0271c 100644 --- a/tst/EnergyPlus/unit/AirflowNetworkConditions.unit.cc +++ b/tst/EnergyPlus/unit/AirflowNetworkConditions.unit.cc @@ -76,7 +76,6 @@ using namespace AirflowNetwork; using namespace DataSurfaces; using namespace DataHeatBalance; using namespace EnergyPlus::DataLoopNode; -using namespace EnergyPlus::ScheduleManager; namespace EnergyPlus { @@ -161,6 +160,7 @@ TEST_F(EnergyPlusFixture, AirflowNetwork_TestDefaultBehaviourOfSimulationControl }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); state->afn->get_input(); // MultizoneZoneData has only 1 element so may be hardcoded @@ -216,7 +216,7 @@ TEST_F(EnergyPlusFixture, AirflowNetworkSimulationControl_DefaultSolver) state->dataHeatBal->People.allocate(state->dataHeatBal->TotPeople); state->dataHeatBal->People(1).ZonePtr = 1; state->dataHeatBal->People(1).NumberOfPeople = 100.0; - state->dataHeatBal->People(1).NumberOfPeoplePtr = 1; // From dataglobals, always returns a 1 for schedule value + state->dataHeatBal->People(1).numberOfPeopleSched = Sched::GetScheduleAlwaysOn(*state); // From dataglobals, always returns a 1 for schedule value state->dataHeatBal->People(1).AdaptiveCEN15251 = true; std::string const idf_objects = delimited_string({ @@ -267,7 +267,7 @@ TEST_F(EnergyPlusFixture, AirflowNetworkSimulationControl_DefaultSolver) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); state->afn->get_input(); EXPECT_ENUM_EQ(AirflowNetwork::SimulationControl::Solver::SkylineLU, state->afn->simulation_control.solver); @@ -312,7 +312,7 @@ TEST_F(EnergyPlusFixture, AirflowNetworkSimulationControl_SetSolver) state->dataHeatBal->People.allocate(state->dataHeatBal->TotPeople); state->dataHeatBal->People(1).ZonePtr = 1; state->dataHeatBal->People(1).NumberOfPeople = 100.0; - state->dataHeatBal->People(1).NumberOfPeoplePtr = 1; // From dataglobals, always returns a 1 for schedule value + state->dataHeatBal->People(1).numberOfPeopleSched = Sched::GetScheduleAlwaysOn(*state); // From dataglobals, always returns a 1 for schedule value state->dataHeatBal->People(1).AdaptiveCEN15251 = true; std::string const idf_objects = delimited_string({ @@ -365,6 +365,7 @@ TEST_F(EnergyPlusFixture, AirflowNetworkSimulationControl_SetSolver) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); state->afn->get_input(); @@ -509,6 +510,7 @@ TEST_F(EnergyPlusFixture, AirflowNetwork_TestWindPressureTable) // Load and verify the table ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); EXPECT_EQ(0, state->dataCurveManager->NumCurves); Curve::GetCurveInput(*state); state->dataCurveManager->GetCurvesInputFlag = false; @@ -592,6 +594,7 @@ TEST_F(EnergyPlusFixture, AirflowNetwork_TestWPCValue) // Load and verify the table ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); EXPECT_EQ(0, state->dataCurveManager->NumCurves); Curve::GetCurveInput(*state); state->dataCurveManager->GetCurvesInputFlag = false; @@ -1598,6 +1601,7 @@ TEST_F(EnergyPlusFixture, AirflowNetwork_TestExternalNodes) "ZoneAirHeatBalanceAlgorithm,", " AnalyticalSolution; !- Algorithm"}); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); bool errors = false; @@ -2322,6 +2326,7 @@ TEST_F(EnergyPlusFixture, AirflowNetwork_TestExternalNodesWithTables) "ZoneAirHeatBalanceAlgorithm,", " AnalyticalSolution; !- Algorithm"}); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); bool errors = false; @@ -2965,6 +2970,7 @@ TEST_F(EnergyPlusFixture, AirflowNetwork_TestExternalNodesWithNoInput) "ZoneAirHeatBalanceAlgorithm,", " AnalyticalSolution; !- Algorithm"}); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); bool errors = false; @@ -3674,6 +3680,7 @@ TEST_F(EnergyPlusFixture, AirflowNetwork_TestExternalNodesWithSymmetricTable) "ZoneAirHeatBalanceAlgorithm,", " AnalyticalSolution; !- Algorithm"}); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); bool errors = false; @@ -4328,6 +4335,7 @@ TEST_F(EnergyPlusFixture, AirflowNetwork_TestExternalNodesWithSymmetricCurve) "ZoneAirHeatBalanceAlgorithm,", " AnalyticalSolution; !- Algorithm"}); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); bool errors = false; @@ -5063,6 +5071,7 @@ TEST_F(EnergyPlusFixture, AirflowNetwork_TestExternalNodesWithLocalAirNode) "ZoneAirHeatBalanceAlgorithm,", " AnalyticalSolution; !- Algorithm"}); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); // Set up some environmental parameters state->dataEnvrn->OutBaroPress = 101325.0; @@ -5076,7 +5085,7 @@ TEST_F(EnergyPlusFixture, AirflowNetwork_TestExternalNodesWithLocalAirNode) HeatBalanceManager::GetHeatBalanceInput(*state); HeatBalanceManager::AllocateHeatBalArrays(*state); state->dataHVACGlobal->TimeStepSys = state->dataGlobal->TimeStepZone; - state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; Curve::GetCurveInput(*state); EXPECT_EQ(state->dataCurveManager->NumCurves, 2); @@ -5541,6 +5550,7 @@ TEST_F(EnergyPlusFixture, AirflowNetwork_BasicAdvancedSingleSided) -0.56146269488642231}; ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); bool errors = false; @@ -5996,6 +6006,7 @@ TEST_F(EnergyPlusFixture, AirflowNetwork_BasicAdvancedSingleSidedAvoidCrashTest) -0.56146269488642231}; ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); bool errors = false; diff --git a/tst/EnergyPlus/unit/AirflowNetworkHVAC.unit.cc b/tst/EnergyPlus/unit/AirflowNetworkHVAC.unit.cc index 00ecff66806..63d1bf488eb 100644 --- a/tst/EnergyPlus/unit/AirflowNetworkHVAC.unit.cc +++ b/tst/EnergyPlus/unit/AirflowNetworkHVAC.unit.cc @@ -97,7 +97,6 @@ using namespace AirflowNetwork; using namespace DataSurfaces; using namespace DataHeatBalance; using namespace EnergyPlus::DataLoopNode; -using namespace EnergyPlus::ScheduleManager; using namespace OutAirNodeManager; using namespace EnergyPlus::Fans; using namespace EnergyPlus::HVACStandAloneERV; @@ -198,12 +197,13 @@ TEST_F(EnergyPlusFixture, AirflowNetwork_TestZoneVentingSch) }); ASSERT_TRUE(process_idf(idf_objects)); + + state->init_state(*state); state->afn->get_input(); // MultizoneZoneData has only 1 element so may be hardcoded - auto GetIndex = Util::FindItemInList(state->afn->MultizoneZoneData(1).VentingSchName, - state->dataScheduleMgr->Schedule({1, state->dataScheduleMgr->NumSchedules})); - EXPECT_EQ(GetIndex, state->afn->MultizoneZoneData(1).VentingSchNum); + auto *ventingSched = Sched::GetSchedule(*state, state->afn->MultizoneZoneData(1).VentingSchName); + EXPECT_EQ(ventingSched, state->afn->MultizoneZoneData(1).ventingSched); state->dataHeatBal->Zone.deallocate(); state->dataSurface->Surface.deallocate(); @@ -2116,10 +2116,9 @@ TEST_F(EnergyPlusFixture, AirflowNetwork_TestPressureStat) state->dataIPShortCut->cAlphaArgs = " "; state->dataIPShortCut->rNumericArgs = 0.0; + state->init_state(*state); bool ErrorsFound = false; // Read objects - HeatBalanceManager::GetProjectControlData(*state, ErrorsFound); - EXPECT_FALSE(ErrorsFound); HeatBalanceManager::GetZoneData(*state, ErrorsFound); EXPECT_FALSE(ErrorsFound); Material::GetWindowGlassSpectralData(*state, ErrorsFound); @@ -2141,20 +2140,11 @@ TEST_F(EnergyPlusFixture, AirflowNetwork_TestPressureStat) Real64 PressureSet = 0.5; - state->dataScheduleMgr - ->Schedule(Util::FindItemInList("PRESSURE SETPOINT SCHEDULE", state->dataScheduleMgr->Schedule({1, state->dataScheduleMgr->NumSchedules}))) - .CurrentValue = PressureSet; // Pressure setpoint - state->dataScheduleMgr - ->Schedule(Util::FindItemInList("FANANDCOILAVAILSCHED", state->dataScheduleMgr->Schedule({1, state->dataScheduleMgr->NumSchedules}))) - .CurrentValue = 1.0; // set availability and fan schedule to 1 - state->dataScheduleMgr->Schedule(Util::FindItemInList("ON", state->dataScheduleMgr->Schedule({1, state->dataScheduleMgr->NumSchedules}))) - .CurrentValue = 1.0; // On - state->dataScheduleMgr - ->Schedule(Util::FindItemInList("VENTINGSCHED", state->dataScheduleMgr->Schedule({1, state->dataScheduleMgr->NumSchedules}))) - .CurrentValue = 25.55; // VentingSched - state->dataScheduleMgr - ->Schedule(Util::FindItemInList("WINDOWVENTSCHED", state->dataScheduleMgr->Schedule({1, state->dataScheduleMgr->NumSchedules}))) - .CurrentValue = 1.0; // WindowVentSched + Sched::GetSchedule(*state, "PRESSURE SETPOINT SCHEDULE")->currentVal = PressureSet; // Pressure setpoint + Sched::GetSchedule(*state, "FANANDCOILAVAILSCHED")->currentVal = 1.0; // set availability and fan schedule to 1 + Sched::GetSchedule(*state, "ON")->currentVal = 1.0; // On + Sched::GetSchedule(*state, "VENTINGSCHED")->currentVal = 25.55; // VentingSched + Sched::GetSchedule(*state, "WINDOWVENTSCHED")->currentVal = 1.0; // WindowVentSched state->afn->AirflowNetworkFanActivated = true; state->dataEnvrn->OutDryBulbTemp = -17.29025; @@ -2260,7 +2250,7 @@ TEST_F(EnergyPlusFixture, AirflowNetwork_TestPressureStat) state->dataZoneEquip->ZoneEquipConfig(3).IsControlled = false; state->dataZoneEquip->ZoneEquipConfig(4).IsControlled = false; state->dataHVACGlobal->TimeStepSys = 0.1; - state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; state->afn->AirflowNetworkLinkSimu(1).FLOW2 = 0.1; state->afn->AirflowNetworkLinkSimu(10).FLOW2 = 0.15; @@ -2293,42 +2283,8 @@ TEST_F(EnergyPlusFixture, AirflowNetwork_TestPressureStat) TEST_F(EnergyPlusFixture, AirflowNetwork_TestZoneVentingSchWithAdaptiveCtrl) { - // Unit test for #5490 - state->dataHeatBal->Zone.allocate(1); - state->dataHeatBal->Zone(1).Name = "SOFF"; - - state->dataSurface->Surface.allocate(2); - state->dataSurface->Surface(1).Name = "WINDOW 1"; - state->dataSurface->Surface(1).Zone = 1; - state->dataSurface->Surface(1).ZoneName = "SOFF"; - state->dataSurface->Surface(1).Azimuth = 0.0; - state->dataSurface->Surface(1).ExtBoundCond = 0; - state->dataSurface->Surface(1).HeatTransSurf = true; - state->dataSurface->Surface(1).Tilt = 90.0; - state->dataSurface->Surface(1).Sides = 4; - state->dataSurface->Surface(2).Name = "WINDOW 2"; - state->dataSurface->Surface(2).Zone = 1; - state->dataSurface->Surface(2).ZoneName = "SOFF"; - state->dataSurface->Surface(2).Azimuth = 180.0; - state->dataSurface->Surface(2).ExtBoundCond = 0; - state->dataSurface->Surface(2).HeatTransSurf = true; - state->dataSurface->Surface(2).Tilt = 90.0; - state->dataSurface->Surface(2).Sides = 4; - - SurfaceGeometry::AllocateSurfaceWindows(*state, 2); - state->dataSurface->Surface(1).OriginalClass = DataSurfaces::SurfaceClass::Window; - state->dataSurface->Surface(2).OriginalClass = DataSurfaces::SurfaceClass::Window; - state->dataGlobal->NumOfZones = 1; - - state->dataHeatBal->TotPeople = 1; // Total number of people statements - state->dataHeatBal->People.allocate(state->dataHeatBal->TotPeople); - state->dataHeatBal->People(1).ZonePtr = 1; - state->dataHeatBal->People(1).NumberOfPeople = 100.0; - state->dataHeatBal->People(1).NumberOfPeoplePtr = 1; // From dataglobals, always returns a 1 for schedule value - state->dataHeatBal->People(1).AdaptiveCEN15251 = true; - std::string const idf_objects = delimited_string({ "Schedule:Constant,OnSch,,1.0;", "Schedule:Constant,FreeRunningSeason,,0.0;", @@ -2377,6 +2333,41 @@ TEST_F(EnergyPlusFixture, AirflowNetwork_TestZoneVentingSchWithAdaptiveCtrl) }); ASSERT_TRUE(process_idf(idf_objects)); + // Have to do this up-front + state->init_state(*state); + + state->dataHeatBal->Zone.allocate(1); + state->dataHeatBal->Zone(1).Name = "SOFF"; + + state->dataSurface->Surface.allocate(2); + state->dataSurface->Surface(1).Name = "WINDOW 1"; + state->dataSurface->Surface(1).Zone = 1; + state->dataSurface->Surface(1).ZoneName = "SOFF"; + state->dataSurface->Surface(1).Azimuth = 0.0; + state->dataSurface->Surface(1).ExtBoundCond = 0; + state->dataSurface->Surface(1).HeatTransSurf = true; + state->dataSurface->Surface(1).Tilt = 90.0; + state->dataSurface->Surface(1).Sides = 4; + state->dataSurface->Surface(2).Name = "WINDOW 2"; + state->dataSurface->Surface(2).Zone = 1; + state->dataSurface->Surface(2).ZoneName = "SOFF"; + state->dataSurface->Surface(2).Azimuth = 180.0; + state->dataSurface->Surface(2).ExtBoundCond = 0; + state->dataSurface->Surface(2).HeatTransSurf = true; + state->dataSurface->Surface(2).Tilt = 90.0; + state->dataSurface->Surface(2).Sides = 4; + + SurfaceGeometry::AllocateSurfaceWindows(*state, 2); + state->dataSurface->Surface(1).OriginalClass = DataSurfaces::SurfaceClass::Window; + state->dataSurface->Surface(2).OriginalClass = DataSurfaces::SurfaceClass::Window; + state->dataGlobal->NumOfZones = 1; + + state->dataHeatBal->TotPeople = 1; // Total number of people statements + state->dataHeatBal->People.allocate(state->dataHeatBal->TotPeople); + state->dataHeatBal->People(1).ZonePtr = 1; + state->dataHeatBal->People(1).NumberOfPeople = 100.0; + state->dataHeatBal->People(1).numberOfPeopleSched = Sched::GetScheduleAlwaysOn(*state); // From dataglobals, always returns a 1 for schedule value + state->dataHeatBal->People(1).AdaptiveCEN15251 = true; state->afn->get_input(); @@ -2384,9 +2375,8 @@ TEST_F(EnergyPlusFixture, AirflowNetwork_TestZoneVentingSchWithAdaptiveCtrl) // changed index 2 to 1 because in new sorted scheedule MultizoneZone(1).VentingSchName ("FREERUNNINGSEASON") // has index 1 which is the .VentSchNum - auto GetIndex = Util::FindItemInList(state->afn->MultizoneZoneData(1).VentingSchName, - state->dataScheduleMgr->Schedule({1, state->dataScheduleMgr->NumSchedules})); - EXPECT_EQ(GetIndex, state->afn->MultizoneZoneData(1).VentingSchNum); + auto *ventingSched = Sched::GetSchedule(*state, state->afn->MultizoneZoneData(1).VentingSchName); + EXPECT_EQ(ventingSched, state->afn->MultizoneZoneData(1).ventingSched); state->dataHeatBal->Zone.deallocate(); state->dataSurface->Surface.deallocate(); @@ -5925,10 +5915,10 @@ TEST_F(EnergyPlusFixture, AirflowNetwork_MultiAirLoopTest) ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + bool ErrorsFound = false; // Read objects - HeatBalanceManager::GetProjectControlData(*state, ErrorsFound); - EXPECT_FALSE(ErrorsFound); HeatBalanceManager::GetZoneData(*state, ErrorsFound); EXPECT_FALSE(ErrorsFound); Material::GetWindowGlassSpectralData(*state, ErrorsFound); @@ -5950,12 +5940,12 @@ TEST_F(EnergyPlusFixture, AirflowNetwork_MultiAirLoopTest) Real64 PresssureSet = 0.5; // Assign values - state->dataScheduleMgr->Schedule(1).CurrentValue = 25.55; // WindowVentSched - state->dataScheduleMgr->Schedule(9).CurrentValue = 1.0; // FanAndCoilAvailSched - state->dataScheduleMgr->Schedule(14).CurrentValue = 1.0; // VentingSched - state->dataScheduleMgr->Schedule(16).CurrentValue = PresssureSet; // Pressure setpoint - state->dataScheduleMgr->Schedule(17).CurrentValue = 1.0; // HVACTemplate-Always 1 - state->dataScheduleMgr->Schedule(18).CurrentValue = 0.0; // HVACTemplate-Always 0 + Sched::GetSchedule(*state, "WINDOWVENTSCHED")->currentVal = 25.55; // WindowVentSched + Sched::GetSchedule(*state, "FANANDCOILAVAILSCHED")->currentVal = 1.0; // FanAndCoilAvailSched + Sched::GetSchedule(*state, "VENTINGSCHED")->currentVal = 1.0; // VentingSched + Sched::GetSchedule(*state, "PRESSURE SETPOINT SCHEDULE")->currentVal = PresssureSet; // Pressure setpoint + Sched::GetSchedule(*state, "HVACTEMPLATE-ALWAYS 1")->currentVal = 1.0; // HVACTemplate-Always 1 + Sched::GetSchedule(*state, "HVACTEMPLATE-ALWAYS 0")->currentVal = 0.0; // HVACTemplate-Always 0 state->afn->AirflowNetworkFanActivated = true; state->dataEnvrn->OutDryBulbTemp = -17.29025; @@ -6052,7 +6042,7 @@ TEST_F(EnergyPlusFixture, AirflowNetwork_MultiAirLoopTest) EXPECT_NEAR(state->afn->AirflowNetworkReportData(1).MultiZoneVentLatLossW, 0.969147, 0.001); // #8475 state->dataHVACGlobal->TimeStepSys = 0.1; - state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; state->dataHeatBal->Zone(1).Volume = 30.0; // Ventilation state->afn->update(); @@ -7624,12 +7614,14 @@ TEST_F(EnergyPlusFixture, AirflowNetwork_DuplicatedNodeNameTest) ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + // Read objects HeatBalanceManager::GetHeatBalanceInput(*state); HeatBalanceManager::AllocateHeatBalArrays(*state); state->dataEnvrn->OutBaroPress = 101000; state->dataHVACGlobal->TimeStepSys = state->dataGlobal->TimeStepZone; - state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; // Read AirflowNetwork inputs ASSERT_THROW(state->afn->get_input(), std::runtime_error); @@ -10423,10 +10415,10 @@ TEST_F(EnergyPlusFixture, DISABLED_AirLoopNumTest) ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + bool ErrorsFound = false; // Read objects - HeatBalanceManager::GetProjectControlData(*state, ErrorsFound); - EXPECT_FALSE(ErrorsFound); HeatBalanceManager::GetZoneData(*state, ErrorsFound); EXPECT_FALSE(ErrorsFound); Material::GetWindowGlassSpectralData(*state, ErrorsFound); @@ -10615,27 +10607,29 @@ TEST_F(EnergyPlusFixture, AirflowNetwork_TestZoneVentingAirBoundary) }); ASSERT_TRUE(process_idf(idf_objects)); + + state->init_state(*state); + state->afn->get_input(); // Expect warnings about the air boundary surface EXPECT_TRUE(has_err_output(false)); std::string const expectedErrString = delimited_string( {" ** Warning ** AirflowNetwork::Solver::get_input: AirflowNetwork:MultiZone:Surface=\"AIR WALL AULA 2\" is an air boundary surface.", " ** ~~~ ** Ventilation Control Mode = TEMPERATURE is not valid. Resetting to Constant.", - " ** Warning ** AirflowNetwork::Solver::get_input: AirflowNetwork:MultiZone:Surface=\"AIR WALL AULA 2\" is an air boundary surface.", - " ** ~~~ ** Venting Availability Schedule will be ignored, venting is always available."}); + " ** Warning ** AirflowNetwork::Solver::get_input: : AirflowNetwork:MultiZone:Surface = AIR WALL AULA 2", + " ** ~~~ ** Venting Availbility Schedule is not empty.", + " ** ~~~ ** Venting is always available for air-boundary surfaces."}); EXPECT_TRUE(compare_err_stream(expectedErrString, true)); // MultizoneSurfaceData(1) is connected to a normal heat transfer surface - // venting schedule should be non-zero and venting method should be ZoneLevel - auto GetIndex = Util::FindItemInList(state->afn->MultizoneSurfaceData(1).VentingSchName, - state->dataScheduleMgr->Schedule({1, state->dataScheduleMgr->NumSchedules})); - EXPECT_GT(GetIndex, 0); - EXPECT_EQ(GetIndex, state->afn->MultizoneSurfaceData(1).VentingSchNum); + auto *ventingSched = Sched::GetSchedule(*state, state->afn->MultizoneSurfaceData(1).VentingSchName); + EXPECT_EQ(ventingSched, state->afn->MultizoneSurfaceData(1).ventingSched); EXPECT_ENUM_EQ(state->afn->MultizoneSurfaceData(1).VentSurfCtrNum, AirflowNetwork::VentControlType::Temp); // MultizoneSurfaceData(2) is connected to an air boundary surface // venting schedule should be zero and venting method should be Constant - EXPECT_EQ(0, state->afn->MultizoneSurfaceData(2).VentingSchNum); + EXPECT_EQ(state->afn->MultizoneSurfaceData(2).ventingSched, Sched::GetScheduleAlwaysOn(*state)); EXPECT_ENUM_EQ(state->afn->MultizoneSurfaceData(2).VentSurfCtrNum, AirflowNetwork::VentControlType::Const); } @@ -14083,12 +14077,11 @@ TEST_F(EnergyPlusFixture, AirflowNetwork_TestIntraZoneLinkageZoneIndex) }); ASSERT_TRUE(process_idf(idf_objects)); - bool ErrorsFound = false; - state->dataGlobal->NumOfTimeStepInHour = 1; - state->dataGlobal->MinutesPerTimeStep = 60; + state->dataGlobal->TimeStepsInHour = 1; + state->dataGlobal->MinutesInTimeStep = 60; + state->init_state(*state); // Read objects - HeatBalanceManager::GetProjectControlData(*state, ErrorsFound); - EXPECT_FALSE(ErrorsFound); + bool ErrorsFound = false; HeatBalanceManager::GetZoneData(*state, ErrorsFound); EXPECT_FALSE(ErrorsFound); ZoneEquipmentManager::GetZoneEquipment(*state); @@ -14105,18 +14098,29 @@ TEST_F(EnergyPlusFixture, AirflowNetwork_TestIntraZoneLinkageZoneIndex) state->dataSurfaceGeometry->SinBldgRotAppGonly = 0.0; SurfaceGeometry::GetSurfaceData(*state, ErrorsFound); EXPECT_FALSE(ErrorsFound); - ScheduleManager::ProcessScheduleInput(*state); - state->dataScheduleMgr->Schedule(6).MinValue = 0.0; - state->dataScheduleMgr->Schedule(6).MaxValue = 2.0; - state->dataScheduleMgr->DaySchedule(1).TSValue = 150; - state->dataScheduleMgr->DaySchedule(1).TSValMax = 200; - state->dataScheduleMgr->DaySchedule(1).TSValMin = 0; - state->dataScheduleMgr->DaySchedule(2).TSValue = 1.0; - state->dataScheduleMgr->DaySchedule(3).TSValue = 1.0; - state->dataScheduleMgr->Schedule(2).MinValue = 0.0; - state->dataScheduleMgr->Schedule(2).MaxValue = 1.0; - state->dataScheduleMgr->Schedule(3).MinValue = 0.0; - state->dataScheduleMgr->Schedule(3).MaxValue = 1.0; + + auto *officeOccSched = Sched::GetSchedule(*state, "OFFICE OCCUPANCY"); + officeOccSched->minVal = 0.0; + officeOccSched->maxVal = 2.0; + + auto *activityDay1Sched = Sched::GetDaySchedule(*state, "ACTIVITY SCH_DY_1"); + std::fill(activityDay1Sched->tsVals.begin(), activityDay1Sched->tsVals.end(), 150); + activityDay1Sched->maxVal = 200; + activityDay1Sched->minVal = 0; + + auto *workEffDay1Sched = Sched::GetDaySchedule(*state, "WORK EFF SCH_DY_1"); + std::fill(workEffDay1Sched->tsVals.begin(), workEffDay1Sched->tsVals.end(), 1.0); + + auto *workEffSched = Sched::GetSchedule(*state, "WORK EFF SCH"); + workEffSched->minVal = 0.0; + workEffSched->maxVal = 1.0; + + auto *clothingDay1Sched = Sched::GetDaySchedule(*state, "CLOTHING SCH_DY_1"); + std::fill(clothingDay1Sched->tsVals.begin(), clothingDay1Sched->tsVals.end(), 1.0); + + auto *clothingSched = Sched::GetSchedule(*state, "CLOTHING SCH"); + clothingSched->minVal = 0.0; + clothingSched->maxVal = 1.0; InternalHeatGains::GetInternalHeatGainsInput(*state); HeatBalanceAirManager::GetRoomAirModelParameters(*state, ErrorsFound); @@ -14256,9 +14260,7 @@ TEST_F(EnergyPlusFixture, AirflowNetwork_TestReferenceConditionsLeftBlank) ASSERT_TRUE(process_idf(idf_objects)); - ErrorsFound = false; - HeatBalanceManager::GetProjectControlData(*state, ErrorsFound); - EXPECT_FALSE(ErrorsFound); + state->init_state(*state); ErrorsFound = false; HeatBalanceManager::GetZoneData(*state, ErrorsFound); @@ -14275,8 +14277,8 @@ TEST_F(EnergyPlusFixture, AirflowNetwork_TestReferenceConditionsLeftBlank) ErrorsFound = false; state->dataSurfaceGeometry->CosZoneRelNorth.allocate(1); state->dataSurfaceGeometry->SinZoneRelNorth.allocate(1); - state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); - state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); + state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); + state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); state->dataSurfaceGeometry->CosBldgRelNorth = 1.0; state->dataSurfaceGeometry->SinBldgRelNorth = 0.0; SurfaceGeometry::GetSurfaceData(*state, ErrorsFound); @@ -16210,10 +16212,9 @@ TEST_F(EnergyPlusFixture, AirflowNetwork_DuctSizingTest) state->dataIPShortCut->cAlphaArgs = " "; state->dataIPShortCut->rNumericArgs = 0.0; + state->init_state(*state); bool ErrorsFound = false; // Read objects - HeatBalanceManager::GetProjectControlData(*state, ErrorsFound); - EXPECT_FALSE(ErrorsFound); HeatBalanceManager::GetZoneData(*state, ErrorsFound); EXPECT_FALSE(ErrorsFound); Material::GetWindowGlassSpectralData(*state, ErrorsFound); @@ -16233,20 +16234,20 @@ TEST_F(EnergyPlusFixture, AirflowNetwork_DuctSizingTest) // Read AirflowNetwork inputs state->afn->get_input(); - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; - state->dataScheduleMgr->Schedule(2).CurrentValue = 100.0; - state->dataScheduleMgr->Schedule(3).CurrentValue = 1.0; - state->dataScheduleMgr->Schedule(4).CurrentValue = 1.0; - state->dataScheduleMgr->Schedule(5).CurrentValue = 0.1; - state->dataScheduleMgr->Schedule(6).CurrentValue = 1.0; - state->dataScheduleMgr->Schedule(7).CurrentValue = 1.0; - state->dataScheduleMgr->Schedule(8).CurrentValue = 1.0; - state->dataScheduleMgr->Schedule(9).CurrentValue = 1.0; - state->dataScheduleMgr->Schedule(10).CurrentValue = 1.0; - state->dataScheduleMgr->Schedule(11).CurrentValue = 21.0; - state->dataScheduleMgr->Schedule(12).CurrentValue = 25.0; - state->dataScheduleMgr->Schedule(13).CurrentValue = 1.0; - state->dataScheduleMgr->Schedule(14).CurrentValue = 1.0; + Sched::GetSchedule(*state, "WINDOWVENTSCHED")->currentVal = 1.0; + Sched::GetSchedule(*state, "ACTIVITY SCH")->currentVal = 100.0; + Sched::GetSchedule(*state, "WORK EFF SCH")->currentVal = 1.0; + Sched::GetSchedule(*state, "CLOTHING SCH")->currentVal = 1.0; + Sched::GetSchedule(*state, "AIR VELO SCH")->currentVal = 0.1; + Sched::GetSchedule(*state, "HOUSE OCCUPANCY")->currentVal = 1.0; + Sched::GetSchedule(*state, "INTERMITTENT")->currentVal = 1.0; + Sched::GetSchedule(*state, "HOUSE LIGHTING")->currentVal = 1.0; + Sched::GetSchedule(*state, "REPORTSCH")->currentVal = 1.0; + Sched::GetSchedule(*state, "HVACAVAILSCHED")->currentVal = 1.0; + Sched::GetSchedule(*state, "DUAL HEATING SETPOINTS")->currentVal = 21.0; + Sched::GetSchedule(*state, "DUAL COOLING SETPOINTS")->currentVal = 25.0; + Sched::GetSchedule(*state, "DUAL ZONE CONTROL TYPE SCHED")->currentVal = 1.0; + Sched::GetSchedule(*state, "CYCLINGFANSCHEDULE")->currentVal = 1.0; state->afn->AirflowNetworkFanActivated = true; state->dataEnvrn->OutDryBulbTemp = -17.29025; @@ -16392,6 +16393,8 @@ TEST_F(EnergyPlusFixture, AirflowNetwork_CheckMultistageHeatingCoil) ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + state->dataGlobal->NumOfZones = 1; state->dataHeatBal->Zone.allocate(1); state->dataHeatBal->Zone(1).Name = "ATTIC ZONE"; @@ -19760,6 +19763,8 @@ TEST_F(EnergyPlusFixture, AirflowNetwork_ZoneOrderTest) state->dataGlobal->DDOnlySimulation = true; + state->init_state(*state); + SimulationManager::ManageSimulation(*state); // run the design day over the warmup period (24 hrs, 25 days) // Crawlspace_Unit1 diff --git a/tst/EnergyPlus/unit/Autosizing/BaseClassSizing.unit.cc b/tst/EnergyPlus/unit/Autosizing/BaseClassSizing.unit.cc index e15bf616142..992f4f6edf2 100644 --- a/tst/EnergyPlus/unit/Autosizing/BaseClassSizing.unit.cc +++ b/tst/EnergyPlus/unit/Autosizing/BaseClassSizing.unit.cc @@ -288,9 +288,11 @@ TEST_F(EnergyPlusFixture, BaseSizer_GetCoilDesFlowT_NoPeak) EXPECT_DOUBLE_EQ(state->dataSize->FinalSysSizing(1).CoolSupTemp, designExitTemp); EXPECT_DOUBLE_EQ(0.002, designFlowValue); } + TEST_F(EnergyPlusFixture, BaseSizer_RequestSizingSystem) { - + state->init_state(*state); + std::string CompName; // component name std::string CompType; // component type std::string SizingString; // input field sizing description @@ -325,7 +327,6 @@ TEST_F(EnergyPlusFixture, BaseSizer_RequestSizingSystem) state->dataEnvrn->StdBaroPress = 101325.0; state->dataEnvrn->StdRhoAir = 1.1583684; - InitializePsychRoutines(*state); state->dataSize->DataFlowUsedForSizing = state->dataSize->FinalSysSizing(state->dataSize->CurSysNum).DesCoolVolFlow; // Need this to prevent crash in Sizers @@ -437,7 +438,8 @@ TEST_F(EnergyPlusFixture, BaseSizer_RequestSizingSystemWithFans) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + Fans::GetFanInput(*state); state->dataSize->CurZoneEqNum = 0; state->dataSize->CurSysNum = 0; @@ -502,7 +504,6 @@ TEST_F(EnergyPlusFixture, BaseSizer_RequestSizingSystemWithFans) state->dataEnvrn->StdBaroPress = 101325.0; state->dataEnvrn->StdRhoAir = 1.1583684; - InitializePsychRoutines(*state); state->dataSize->DataFlowUsedForSizing = state->dataSize->FinalSysSizing(state->dataSize->CurSysNum).DesCoolVolFlow; // Need this to prevent crash in Sizers @@ -571,6 +572,7 @@ TEST_F(EnergyPlusFixture, BaseSizer_RequestSizingSystemWithFans) TEST_F(EnergyPlusFixture, BaseSizer_RequestSizingZone) { + state->init_state(*state); int constexpr ZoneNum = 1; std::string CompName; // component name std::string CompType; // component type @@ -597,7 +599,6 @@ TEST_F(EnergyPlusFixture, BaseSizer_RequestSizingZone) state->dataSize->ZoneSizingRunDone = true; state->dataEnvrn->StdBaroPress = 101325.0; state->dataEnvrn->StdRhoAir = 1.1583684; - InitializePsychRoutines(*state); // Need this to prevent crash in Sizers state->dataSize->ZoneEqSizing.allocate(1); @@ -911,8 +912,8 @@ TEST_F(EnergyPlusFixture, BaseSizer_FanPeak) { // This is needed to compute time of Peak as a string - state->dataGlobal->NumOfTimeStepInHour = 4; - state->dataGlobal->MinutesPerTimeStep = 15; + state->dataGlobal->TimeStepsInHour = 4; + state->dataGlobal->MinutesInTimeStep = 15; // Setup the predefined tables, because that's where the info is written. EnergyPlus::OutputReportPredefined::SetPredefinedTables(*state); @@ -1472,6 +1473,7 @@ TEST_F(EnergyPlusFixture, BaseSizer_SupplyAirTempLessThanZoneTStatTest) ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); SimulationManager::ManageSimulation(*state); int CtrlZoneNum(1); diff --git a/tst/EnergyPlus/unit/Autosizing/CoolingAirFlowSizing.unit.cc b/tst/EnergyPlus/unit/Autosizing/CoolingAirFlowSizing.unit.cc index 1956e7e6459..ac0655a9864 100644 --- a/tst/EnergyPlus/unit/Autosizing/CoolingAirFlowSizing.unit.cc +++ b/tst/EnergyPlus/unit/Autosizing/CoolingAirFlowSizing.unit.cc @@ -123,8 +123,8 @@ TEST_F(AutoSizingFixture, CoolingAirFlowSizingGauntlet) state->dataSize->FinalZoneSizing(1).HeatDDNum = 2; state->dataSize->FinalZoneSizing(1).TimeStepNumAtCoolMax = 12; state->dataSize->FinalZoneSizing(1).TimeStepNumAtHeatMax = 6; - state->dataGlobal->NumOfTimeStepInHour = 1; - state->dataGlobal->MinutesPerTimeStep = 60; + state->dataGlobal->TimeStepsInHour = 1; + state->dataGlobal->MinutesInTimeStep = 60; state->dataEnvrn->TotDesDays = 2; state->dataWeather->DesDayInput.allocate(2); state->dataWeather->DesDayInput(1).Month = 7; diff --git a/tst/EnergyPlus/unit/Autosizing/CoolingCapacitySizing.unit.cc b/tst/EnergyPlus/unit/Autosizing/CoolingCapacitySizing.unit.cc index 90037ebe079..a25632371d2 100644 --- a/tst/EnergyPlus/unit/Autosizing/CoolingCapacitySizing.unit.cc +++ b/tst/EnergyPlus/unit/Autosizing/CoolingCapacitySizing.unit.cc @@ -80,6 +80,8 @@ TEST_F(AutoSizingFixture, CoolingCapacitySizingGauntlet) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + state->dataEnvrn->StdRhoAir = 1.2; // call simulate to trigger sizing call Fans::GetFanInput(*state); diff --git a/tst/EnergyPlus/unit/Autosizing/HeatingAirFlowSizing.unit.cc b/tst/EnergyPlus/unit/Autosizing/HeatingAirFlowSizing.unit.cc index 86278412559..cfe1d42fcd2 100644 --- a/tst/EnergyPlus/unit/Autosizing/HeatingAirFlowSizing.unit.cc +++ b/tst/EnergyPlus/unit/Autosizing/HeatingAirFlowSizing.unit.cc @@ -123,8 +123,8 @@ TEST_F(AutoSizingFixture, HeatingAirFlowSizingGauntlet) state->dataSize->FinalZoneSizing(1).HeatDDNum = 2; state->dataSize->FinalZoneSizing(1).TimeStepNumAtCoolMax = 12; state->dataSize->FinalZoneSizing(1).TimeStepNumAtHeatMax = 6; - state->dataGlobal->NumOfTimeStepInHour = 1; - state->dataGlobal->MinutesPerTimeStep = 60; + state->dataGlobal->TimeStepsInHour = 1; + state->dataGlobal->MinutesInTimeStep = 60; state->dataEnvrn->TotDesDays = 2; state->dataWeather->DesDayInput.allocate(2); state->dataWeather->DesDayInput(1).Month = 7; diff --git a/tst/EnergyPlus/unit/Autosizing/HeatingCapacitySizing.unit.cc b/tst/EnergyPlus/unit/Autosizing/HeatingCapacitySizing.unit.cc index 742889609a2..4137fbe65b6 100644 --- a/tst/EnergyPlus/unit/Autosizing/HeatingCapacitySizing.unit.cc +++ b/tst/EnergyPlus/unit/Autosizing/HeatingCapacitySizing.unit.cc @@ -80,6 +80,8 @@ TEST_F(AutoSizingFixture, HeatingCapacitySizingGauntlet) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + state->dataEnvrn->StdRhoAir = 1.2; // call simulate to trigger sizing call Fans::GetFanInput(*state); diff --git a/tst/EnergyPlus/unit/Autosizing/SystemAirFlowSizing.unit.cc b/tst/EnergyPlus/unit/Autosizing/SystemAirFlowSizing.unit.cc index 2c2441eedca..2f2d5bcdb85 100644 --- a/tst/EnergyPlus/unit/Autosizing/SystemAirFlowSizing.unit.cc +++ b/tst/EnergyPlus/unit/Autosizing/SystemAirFlowSizing.unit.cc @@ -120,8 +120,8 @@ TEST_F(AutoSizingFixture, SystemAirFlowSizingGauntlet) state->dataSize->FinalZoneSizing(1).HeatDDNum = 2; state->dataSize->FinalZoneSizing(1).TimeStepNumAtCoolMax = 12; state->dataSize->FinalZoneSizing(1).TimeStepNumAtHeatMax = 6; - state->dataGlobal->NumOfTimeStepInHour = 1; - state->dataGlobal->MinutesPerTimeStep = 60; + state->dataGlobal->TimeStepsInHour = 1; + state->dataGlobal->MinutesInTimeStep = 60; state->dataEnvrn->TotDesDays = 2; state->dataWeather->DesDayInput.allocate(2); state->dataWeather->DesDayInput(1).Month = 7; diff --git a/tst/EnergyPlus/unit/Autosizing/WaterHeatingCoilUASizing.unit.cc b/tst/EnergyPlus/unit/Autosizing/WaterHeatingCoilUASizing.unit.cc index 355a4cec876..d309446cf60 100644 --- a/tst/EnergyPlus/unit/Autosizing/WaterHeatingCoilUASizing.unit.cc +++ b/tst/EnergyPlus/unit/Autosizing/WaterHeatingCoilUASizing.unit.cc @@ -121,10 +121,10 @@ TEST_F(AutoSizingFixture, WaterHeatingCoilUASizingGauntlet) state->dataWaterCoils->WaterCoil(1).InletAirMassFlowRate = 0.2; state->dataWaterCoils->WaterCoil(1).InletWaterMassFlowRate = 0.8; state->dataWaterCoils->WaterCoil(1).WaterPlantLoc.loopNum = 1; - state->dataWaterCoils->WaterCoil(1).SchedPtr = -1; + state->dataWaterCoils->WaterCoil(1).availSched = nullptr; state->dataWaterCoils->MyUAAndFlowCalcFlag.allocate(1); state->dataWaterCoils->MySizeFlag.allocate(1); - state->dataScheduleMgr->Schedule.allocate(1); + // state->dataScheduleMgr->Schedule.allocate(1); // now allocate sizing arrays for testing autosized field state->dataSize->TermUnitSizing.allocate(1); diff --git a/tst/EnergyPlus/unit/BaseboardElectric.unit.cc b/tst/EnergyPlus/unit/BaseboardElectric.unit.cc index 2872b47864f..09f2f8fd792 100644 --- a/tst/EnergyPlus/unit/BaseboardElectric.unit.cc +++ b/tst/EnergyPlus/unit/BaseboardElectric.unit.cc @@ -85,6 +85,8 @@ TEST_F(EnergyPlusFixture, ExerciseBaseboardElectric) ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + state->dataZoneEquip->ZoneEquipConfig.allocate(1); state->dataZoneEquip->ZoneEquipConfig(1).ZoneNode = 1; state->dataLoopNodes->Node.allocate(1); diff --git a/tst/EnergyPlus/unit/BaseboardRadiator.unit.cc b/tst/EnergyPlus/unit/BaseboardRadiator.unit.cc index b275ef3df6c..6c1914adfa5 100644 --- a/tst/EnergyPlus/unit/BaseboardRadiator.unit.cc +++ b/tst/EnergyPlus/unit/BaseboardRadiator.unit.cc @@ -163,7 +163,7 @@ TEST_F(EnergyPlusFixture, BaseboardConvWater_SizingTest) " ZoneHVAC:Baseboard:Convective:Water,", " SPACE2-1 Baseboard, !- Name", - " always_on, !- Availability Schedule Name", + " CONSTANT-1.0, !- Availability Schedule Name", " SPACE2-1 Baseboard Inlet Node, !- Inlet Node Name", " SPACE2-1 Baseboard Outlet Node, !- Outlet Node Name", " HeatingDesignCapacity, !- Heating Design Capacity Method", @@ -193,7 +193,7 @@ TEST_F(EnergyPlusFixture, BaseboardConvWater_SizingTest) " ZoneHVAC:Baseboard:Convective:Water,", " SPACE3-1 Baseboard, !- Name", - " always_on, !- Availability Schedule Name", + " CONSTANT-1.0, !- Availability Schedule Name", " SPACE3-1 Baseboard Inlet Node, !- Inlet Node Name", " SPACE3-1 Baseboard Outlet Node, !- Outlet Node Name", " CapacityPerFloorArea, !- Heating Design Capacity Method", @@ -223,7 +223,7 @@ TEST_F(EnergyPlusFixture, BaseboardConvWater_SizingTest) " ZoneHVAC:Baseboard:Convective:Water,", " SPACE4-1 Baseboard, !- Name", - " always_on, !- Availability Schedule Name", + " CONSTANT-1.0, !- Availability Schedule Name", " SPACE4-1 Baseboard Inlet Node, !- Inlet Node Name", " SPACE4-1 Baseboard Outlet Node, !- Outlet Node Name", " FractionOfAutosizedHeatingCapacity, !- Heating Design Capacity Method", @@ -251,19 +251,6 @@ TEST_F(EnergyPlusFixture, BaseboardConvWater_SizingTest) " 0.0,0.0,0.0, !- X,Y,Z ==> Vertex 3 {m}", " 0.0,0.0,2.4; !- X,Y,Z ==> Vertex 4 {m}", - " ScheduleTypeLimits,", - " Fraction, !- Name", - " 0.0, !- Lower Limit Value", - " 1.0, !- Upper Limit Value", - " CONTINUOUS; !- Numeric Type", - - " Schedule:Compact,", - " always_on, !- Name", - " Fraction, !- Schedule Type Limits Name", - " Through: 12/31, !- Field 1", - " For: AllDays, !- Field 2", - " Until: 24:00,1.0; !- Field 3" - "SurfaceConvectionAlgorithm:Inside,TARP;", "SurfaceConvectionAlgorithm:Outside,DOE-2;", @@ -328,9 +315,10 @@ TEST_F(EnergyPlusFixture, BaseboardConvWater_SizingTest) ASSERT_TRUE(process_idf(idf_objects)); - state->dataGlobal->NumOfTimeStepInHour = 1; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 60; // must initialize this to get schedules initialized - ScheduleManager::ProcessScheduleInput(*state); // read schedules + state->dataGlobal->TimeStepsInHour = 1; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 60; // must initialize this to get schedules initialized + + state->init_state(*state); bool errorsFound(false); HeatBalanceManager::GetProjectControlData(*state, errorsFound); // read project control data @@ -349,12 +337,12 @@ TEST_F(EnergyPlusFixture, BaseboardConvWater_SizingTest) state->dataSurfaceGeometry->CosZoneRelNorth.allocate(3); state->dataSurfaceGeometry->SinZoneRelNorth.allocate(3); - state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); - state->dataSurfaceGeometry->CosZoneRelNorth(2) = std::cos(-state->dataHeatBal->Zone(2).RelNorth * Constant::DegToRadians); - state->dataSurfaceGeometry->CosZoneRelNorth(3) = std::cos(-state->dataHeatBal->Zone(3).RelNorth * Constant::DegToRadians); - state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); - state->dataSurfaceGeometry->SinZoneRelNorth(2) = std::sin(-state->dataHeatBal->Zone(2).RelNorth * Constant::DegToRadians); - state->dataSurfaceGeometry->SinZoneRelNorth(3) = std::sin(-state->dataHeatBal->Zone(3).RelNorth * Constant::DegToRadians); + state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); + state->dataSurfaceGeometry->CosZoneRelNorth(2) = std::cos(-state->dataHeatBal->Zone(2).RelNorth * Constant::DegToRad); + state->dataSurfaceGeometry->CosZoneRelNorth(3) = std::cos(-state->dataHeatBal->Zone(3).RelNorth * Constant::DegToRad); + state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); + state->dataSurfaceGeometry->SinZoneRelNorth(2) = std::sin(-state->dataHeatBal->Zone(2).RelNorth * Constant::DegToRad); + state->dataSurfaceGeometry->SinZoneRelNorth(3) = std::sin(-state->dataHeatBal->Zone(3).RelNorth * Constant::DegToRad); state->dataSurfaceGeometry->CosBldgRelNorth = 1.0; state->dataSurfaceGeometry->SinBldgRelNorth = 0.0; diff --git a/tst/EnergyPlus/unit/BoilerHotWater.unit.cc b/tst/EnergyPlus/unit/BoilerHotWater.unit.cc index 0073f22d5b1..dc51ccad6de 100644 --- a/tst/EnergyPlus/unit/BoilerHotWater.unit.cc +++ b/tst/EnergyPlus/unit/BoilerHotWater.unit.cc @@ -71,7 +71,6 @@ using namespace EnergyPlus::Psychrometrics; TEST_F(EnergyPlusFixture, Boiler_HotWaterSizingTest) { - state->dataFluidProps->init_state(*state); // unit test for autosizing boiler nominal capacity in Boiler:HotWater state->dataBoilers->Boiler.allocate(1); // Hardsized Hot Water Boiler @@ -116,7 +115,6 @@ TEST_F(EnergyPlusFixture, Boiler_HotWaterSizingTest) } TEST_F(EnergyPlusFixture, Boiler_HotWaterAutoSizeTempTest) { - state->dataFluidProps->init_state(*state); // unit test for checking hot water temperature for autosizing // boiler nominal capacity in Boiler:HotWater state->dataBoilers->Boiler.allocate(1); @@ -186,6 +184,7 @@ TEST_F(EnergyPlusFixture, Boiler_HotWater_BlankDesignWaterFlowRate) }); ASSERT_TRUE(process_idf(idf_objects)); + GetBoilerInput(*state); EXPECT_EQ(1, (int)state->dataBoilers->Boiler.size()); @@ -204,11 +203,9 @@ TEST_F(EnergyPlusFixture, Boiler_HotWater_BoilerEfficiency) state->dataPlnt->TotNumLoops = 2; state->dataEnvrn->OutBaroPress = 101325.0; state->dataEnvrn->StdRhoAir = 1.20; - state->dataGlobal->NumOfTimeStepInHour = 1; + state->dataGlobal->TimeStepsInHour = 1; state->dataGlobal->TimeStep = 1; - state->dataGlobal->MinutesPerTimeStep = 60; - - Psychrometrics::InitializePsychRoutines(*state); + state->dataGlobal->MinutesInTimeStep = 60; std::string const idf_objects = delimited_string({ "Boiler:HotWater,", diff --git a/tst/EnergyPlus/unit/BoilerSteam.unit.cc b/tst/EnergyPlus/unit/BoilerSteam.unit.cc index b012d0a56f1..70d13d2be3f 100644 --- a/tst/EnergyPlus/unit/BoilerSteam.unit.cc +++ b/tst/EnergyPlus/unit/BoilerSteam.unit.cc @@ -91,6 +91,9 @@ TEST_F(EnergyPlusFixture, BoilerSteam_GetInput) }); ASSERT_TRUE(process_idf(idf_objects, false)); + + state->init_state(*state); + GetBoilerInput(*state); auto &thisBoiler = state->dataBoilerSteam->Boiler((int)state->dataBoilerSteam->Boiler.size()); EXPECT_EQ(thisBoiler.Name, "STEAM BOILER PLANT BOILER"); @@ -131,6 +134,8 @@ TEST_F(EnergyPlusFixture, BoilerSteam_Simulate) ASSERT_TRUE(process_idf(idf_objects, false)); + state->init_state(*state); + BoilerSpecs *ptr = BoilerSteam::BoilerSpecs::factory(*state, "BOILER"); EXPECT_EQ(ptr->Name, "BOILER"); @@ -173,19 +178,6 @@ TEST_F(EnergyPlusFixture, BoilerSteam_Simulate) TEST_F(EnergyPlusFixture, BoilerSteam_BoilerEfficiency) { - - bool RunFlag(true); - Real64 MyLoad(1000000.0); - - state->dataPlnt->TotNumLoops = 2; - state->dataEnvrn->OutBaroPress = 101325.0; - state->dataEnvrn->StdRhoAir = 1.20; - state->dataGlobal->NumOfTimeStepInHour = 1; - state->dataGlobal->TimeStep = 1; - state->dataGlobal->MinutesPerTimeStep = 60; - - Psychrometrics::InitializePsychRoutines(*state); - std::string const idf_objects = delimited_string({ " Boiler:Steam, ", " Steam Boiler Plant Boiler, !- Name ", @@ -206,6 +198,18 @@ TEST_F(EnergyPlusFixture, BoilerSteam_BoilerEfficiency) EXPECT_TRUE(process_idf(idf_objects, false)); + state->dataGlobal->TimeStepsInHour = 1; + state->dataGlobal->MinutesInTimeStep = 60; + state->init_state(*state); + + bool RunFlag(true); + Real64 MyLoad(1000000.0); + + state->dataPlnt->TotNumLoops = 2; + state->dataEnvrn->OutBaroPress = 101325.0; + state->dataEnvrn->StdRhoAir = 1.20; + state->dataGlobal->TimeStep = 1; + state->dataPlnt->PlantLoop.allocate(state->dataPlnt->TotNumLoops); for (int l = 1; l <= state->dataPlnt->TotNumLoops; ++l) { auto &loopside(state->dataPlnt->PlantLoop(l).LoopSide(DataPlant::LoopSideLocation::Demand)); diff --git a/tst/EnergyPlus/unit/BranchNodeConnections.unit.cc b/tst/EnergyPlus/unit/BranchNodeConnections.unit.cc index f80e8e05e0b..06b7f77ef7e 100644 --- a/tst/EnergyPlus/unit/BranchNodeConnections.unit.cc +++ b/tst/EnergyPlus/unit/BranchNodeConnections.unit.cc @@ -1168,7 +1168,8 @@ TEST_F(EnergyPlusFixture, BranchNodeConnections_ReturnPlenumNodeCheckFailure) // OutputProcessor::TimeValue.allocate(2); state->dataGlobal->DDOnlySimulation = true; - GetProjectData(*state); + state->init_state(*state); + OutputReportPredefined::SetPredefinedTables(*state); SetPreConstructionInputParameters(*state); // establish array bounds for constructions early createFacilityElectricPowerServiceObject(*state); @@ -2189,7 +2190,8 @@ TEST_F(EnergyPlusFixture, BranchNodeConnections_ReturnPlenumNodeCheck) // OutputProcessor::TimeValue.allocate(2); state->dataGlobal->DDOnlySimulation = true; - GetProjectData(*state); + state->init_state(*state); + OutputReportPredefined::SetPredefinedTables(*state); SetPreConstructionInputParameters(*state); // establish array bounds for constructions early createFacilityElectricPowerServiceObject(*state); diff --git a/tst/EnergyPlus/unit/ChillerAbsorption.unit.cc b/tst/EnergyPlus/unit/ChillerAbsorption.unit.cc index 7bd0003246a..1a7e862141f 100644 --- a/tst/EnergyPlus/unit/ChillerAbsorption.unit.cc +++ b/tst/EnergyPlus/unit/ChillerAbsorption.unit.cc @@ -1784,6 +1784,8 @@ TEST_F(EnergyPlusFixture, ChillerAbsorption_Calc) ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + SimulationManager::ManageSimulation(*state); // run the design day // set conditions for test @@ -1840,11 +1842,11 @@ TEST_F(EnergyPlusFixture, ChillerAbsorption_Autosize) state->dataPlnt->TotNumLoops = 3; state->dataEnvrn->OutBaroPress = 101325.0; state->dataEnvrn->StdRhoAir = 1.20; - state->dataGlobal->NumOfTimeStepInHour = 4; + state->dataGlobal->TimeStepsInHour = 4; state->dataGlobal->TimeStep = 1; - state->dataGlobal->MinutesPerTimeStep = 15; + state->dataGlobal->MinutesInTimeStep = 15; state->dataHVACGlobal->TimeStepSys = 0.25; - state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; state->dataGlobal->SysSizingCalc = true; std::string const idf_objects = delimited_string({ @@ -1879,6 +1881,8 @@ TEST_F(EnergyPlusFixture, ChillerAbsorption_Autosize) }); EXPECT_TRUE(process_idf(idf_objects, false)); + state->init_state(*state); + state->dataPlnt->PlantLoop.allocate(state->dataPlnt->TotNumLoops); state->dataSize->NumPltSizInput = state->dataPlnt->TotNumLoops; state->dataSize->PlantSizData.allocate(state->dataPlnt->TotNumLoops); @@ -2074,7 +2078,6 @@ TEST_F(EnergyPlusFixture, ChillerAbsorption_Autosize) bool RunFlag(true); Real64 MyLoad(-20000.0); - Psychrometrics::InitializePsychRoutines(*state); thisChiller.initialize(*state, RunFlag, MyLoad); thisChiller.sizeChiller(*state); diff --git a/tst/EnergyPlus/unit/ChillerConstantCOP.unit.cc b/tst/EnergyPlus/unit/ChillerConstantCOP.unit.cc index f860da107b3..4ccc0ce386f 100644 --- a/tst/EnergyPlus/unit/ChillerConstantCOP.unit.cc +++ b/tst/EnergyPlus/unit/ChillerConstantCOP.unit.cc @@ -72,9 +72,9 @@ TEST_F(EnergyPlusFixture, ChillerConstantCOP_WaterCooled_Autosize) state->dataPlnt->TotNumLoops = 4; state->dataEnvrn->OutBaroPress = 101325.0; state->dataEnvrn->StdRhoAir = 1.20; - state->dataGlobal->NumOfTimeStepInHour = 1; + state->dataGlobal->TimeStepsInHour = 1; state->dataGlobal->TimeStep = 1; - state->dataGlobal->MinutesPerTimeStep = 60; + state->dataGlobal->MinutesInTimeStep = 60; std::string const idf_objects = delimited_string({ " Chiller:ConstantCOP,", @@ -100,6 +100,8 @@ TEST_F(EnergyPlusFixture, ChillerConstantCOP_WaterCooled_Autosize) EXPECT_TRUE(process_idf(idf_objects, false)); + state->init_state(*state); + state->dataPlnt->PlantLoop.allocate(state->dataPlnt->TotNumLoops); state->dataPlnt->PlantLoop.allocate(state->dataPlnt->TotNumLoops); for (int l = 1; l <= state->dataPlnt->TotNumLoops; ++l) { @@ -151,7 +153,6 @@ TEST_F(EnergyPlusFixture, ChillerConstantCOP_WaterCooled_Autosize) bool RunFlag(true); Real64 MyLoad(-20000.0); - Psychrometrics::InitializePsychRoutines(*state); thisChiller.initialize(*state, RunFlag, MyLoad); thisChiller.size(*state); @@ -206,9 +207,9 @@ TEST_F(EnergyPlusFixture, ChillerConstantCOP_Default_Des_Cond_Evap_Temps) state->dataPlnt->TotNumLoops = 12; state->dataEnvrn->OutBaroPress = 101325.0; state->dataEnvrn->StdRhoAir = 1.20; - state->dataGlobal->NumOfTimeStepInHour = 1; + state->dataGlobal->TimeStepsInHour = 1; state->dataGlobal->TimeStep = 1; - state->dataGlobal->MinutesPerTimeStep = 60; + state->dataGlobal->MinutesInTimeStep = 60; std::string const idf_objects = delimited_string({ " Chiller:ConstantCOP,", @@ -262,6 +263,8 @@ TEST_F(EnergyPlusFixture, ChillerConstantCOP_Default_Des_Cond_Evap_Temps) EXPECT_TRUE(process_idf(idf_objects, false)); + state->init_state(*state); + state->dataPlnt->PlantLoop.allocate(state->dataPlnt->TotNumLoops); for (int l = 1; l <= state->dataPlnt->TotNumLoops; ++l) { diff --git a/tst/EnergyPlus/unit/ChillerElectric.unit.cc b/tst/EnergyPlus/unit/ChillerElectric.unit.cc index 1eb1c9bfcc2..9bc62382722 100644 --- a/tst/EnergyPlus/unit/ChillerElectric.unit.cc +++ b/tst/EnergyPlus/unit/ChillerElectric.unit.cc @@ -71,9 +71,9 @@ TEST_F(EnergyPlusFixture, ChillerElectric_WaterCooled_Autosize) state->dataPlnt->TotNumLoops = 4; state->dataEnvrn->OutBaroPress = 101325.0; state->dataEnvrn->StdRhoAir = 1.20; - state->dataGlobal->NumOfTimeStepInHour = 1; + state->dataGlobal->TimeStepsInHour = 1; state->dataGlobal->TimeStep = 1; - state->dataGlobal->MinutesPerTimeStep = 60; + state->dataGlobal->MinutesInTimeStep = 60; std::string const idf_objects = delimited_string({ " Chiller:Electric,", @@ -108,6 +108,8 @@ TEST_F(EnergyPlusFixture, ChillerElectric_WaterCooled_Autosize) EXPECT_TRUE(process_idf(idf_objects, false)); + state->init_state(*state); + state->dataPlnt->PlantLoop.allocate(state->dataPlnt->TotNumLoops); state->dataPlnt->PlantLoop.allocate(state->dataPlnt->TotNumLoops); for (int l = 1; l <= state->dataPlnt->TotNumLoops; ++l) { @@ -163,7 +165,6 @@ TEST_F(EnergyPlusFixture, ChillerElectric_WaterCooled_Autosize) bool RunFlag(true); Real64 MyLoad(-20000.0); - Psychrometrics::InitializePsychRoutines(*state); auto &thisChiller = state->dataPlantChillers->ElectricChiller(1); thisChiller.initialize(*state, RunFlag, MyLoad); thisChiller.size(*state); @@ -203,11 +204,11 @@ TEST_F(EnergyPlusFixture, ChillerElectric_WaterCooled_Simulate) state->dataPlnt->TotNumLoops = 4; state->dataEnvrn->OutBaroPress = 101325.0; state->dataEnvrn->StdRhoAir = 1.20; - state->dataGlobal->NumOfTimeStepInHour = 1; + state->dataGlobal->TimeStepsInHour = 1; state->dataGlobal->TimeStep = 1; - state->dataGlobal->MinutesPerTimeStep = 60; + state->dataGlobal->MinutesInTimeStep = 60; state->dataHVACGlobal->TimeStepSys = 60; - state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; std::string const idf_objects = delimited_string({ " Chiller:Electric,", @@ -265,6 +266,8 @@ TEST_F(EnergyPlusFixture, ChillerElectric_WaterCooled_Simulate) EXPECT_TRUE(process_idf(idf_objects, false)); + state->init_state(*state); + state->dataPlnt->PlantLoop.allocate(state->dataPlnt->TotNumLoops); state->dataPlnt->PlantLoop.allocate(state->dataPlnt->TotNumLoops); for (int l = 1; l <= state->dataPlnt->TotNumLoops; ++l) { @@ -323,7 +326,6 @@ TEST_F(EnergyPlusFixture, ChillerElectric_WaterCooled_Simulate) bool RunFlag(true); Real64 MyLoad(-20000.0); - Psychrometrics::InitializePsychRoutines(*state); auto &thisChiller = state->dataPlantChillers->ElectricChiller(1); thisChiller.initialize(*state, RunFlag, MyLoad); thisChiller.size(*state); diff --git a/tst/EnergyPlus/unit/ChillerElectricEIR.unit.cc b/tst/EnergyPlus/unit/ChillerElectricEIR.unit.cc index e7da610059a..721009de2ef 100644 --- a/tst/EnergyPlus/unit/ChillerElectricEIR.unit.cc +++ b/tst/EnergyPlus/unit/ChillerElectricEIR.unit.cc @@ -199,9 +199,12 @@ TEST_F(EnergyPlusFixture, ChillerElectricEIR_AirCooledChiller) EXPECT_TRUE(process_idf(idf_objects, false)); - state->dataGlobal->NumOfTimeStepInHour = 1; + state->dataGlobal->TimeStepsInHour = 1; state->dataGlobal->TimeStep = 1; - state->dataGlobal->MinutesPerTimeStep = 60; + state->dataGlobal->MinutesInTimeStep = 60; + + state->init_state(*state); + state->dataPlnt->PlantLoop.allocate(state->dataPlnt->TotNumLoops); state->dataPlnt->PlantLoop.allocate(state->dataPlnt->TotNumLoops); for (int l = 1; l <= state->dataPlnt->TotNumLoops; ++l) { @@ -329,16 +332,17 @@ TEST_F(EnergyPlusFixture, ChillerElectricEIR_EvaporativelyCooled_Calculate) }); EXPECT_TRUE(process_idf(idf_objects, false)); + state->dataPlnt->TotNumLoops = 2; state->dataEnvrn->OutBaroPress = 101325.0; state->dataEnvrn->StdRhoAir = 1.20; - state->dataGlobal->NumOfTimeStepInHour = 1; + state->dataGlobal->TimeStepsInHour = 1; state->dataGlobal->TimeStep = 1; - state->dataGlobal->MinutesPerTimeStep = 60; - - Psychrometrics::InitializePsychRoutines(*state); + state->dataGlobal->MinutesInTimeStep = 60; + state->init_state(*state); + state->dataPlnt->PlantLoop.allocate(state->dataPlnt->TotNumLoops); state->dataPlnt->PlantLoop.allocate(state->dataPlnt->TotNumLoops); for (int l = 1; l <= state->dataPlnt->TotNumLoops; ++l) { @@ -418,15 +422,14 @@ TEST_F(EnergyPlusFixture, ChillerElectricEIR_WaterCooledChillerVariableSpeedCond state->dataPlnt->TotNumLoops = 2; state->dataEnvrn->OutBaroPress = 101325.0; state->dataEnvrn->StdRhoAir = 1.20; - state->dataGlobal->NumOfTimeStepInHour = 1; + state->dataGlobal->TimeStepsInHour = 1; state->dataGlobal->TimeStep = 1; - state->dataGlobal->MinutesPerTimeStep = 60; + state->dataGlobal->MinutesInTimeStep = 60; state->dataGlobal->HourOfDay = 1; state->dataEnvrn->DayOfWeek = 1; state->dataEnvrn->Month = 1; state->dataEnvrn->DayOfMonth = 1; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); - Psychrometrics::InitializePsychRoutines(*state); std::string const idf_objects = delimited_string({ "Chiller:Electric:EIR,", @@ -478,6 +481,8 @@ TEST_F(EnergyPlusFixture, ChillerElectricEIR_WaterCooledChillerVariableSpeedCond EXPECT_TRUE(process_idf(idf_objects, false)); + state->init_state(*state); + state->dataPlnt->PlantLoop.allocate(state->dataPlnt->TotNumLoops); state->dataPlnt->PlantLoop.allocate(state->dataPlnt->TotNumLoops); for (int l = 1; l <= state->dataPlnt->TotNumLoops; ++l) { @@ -532,7 +537,7 @@ TEST_F(EnergyPlusFixture, ChillerElectricEIR_WaterCooledChillerVariableSpeedCond thisChiller.size(*state); MyLoad = -thisChiller.RefCap; state->dataSize->PlantSizData(1).DesCapacity = std::abs(MyLoad) * 2; - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); // run through init again after sizing is complete to set mass flow rate state->dataGlobal->BeginEnvrnFlag = true; diff --git a/tst/EnergyPlus/unit/ChillerExhaustAbsorption.unit.cc b/tst/EnergyPlus/unit/ChillerExhaustAbsorption.unit.cc index 1aaeb633ec5..05bb5dcb030 100644 --- a/tst/EnergyPlus/unit/ChillerExhaustAbsorption.unit.cc +++ b/tst/EnergyPlus/unit/ChillerExhaustAbsorption.unit.cc @@ -301,6 +301,8 @@ TEST_F(EnergyPlusFixture, ExhAbsorption_GetInput_Test) ASSERT_TRUE(process_idf(idf_objects)); compare_err_stream(""); + state->init_state(*state); + GetExhaustAbsorberInput(*state); compare_err_stream(""); @@ -331,6 +333,7 @@ TEST_F(EnergyPlusFixture, ExhAbsorption_GetInput_Test) TEST_F(EnergyPlusFixture, ExhAbsorption_getDesignCapacities_Test) { + state->init_state(*state); state->dataPlnt->TotNumLoops = 3; state->dataPlnt->PlantLoop.allocate(state->dataPlnt->TotNumLoops); @@ -634,6 +637,8 @@ TEST_F(EnergyPlusFixture, ExhAbsorption_calcHeater_Fix_Test) ASSERT_TRUE(process_idf(idf_objects)); compare_err_stream(""); + state->init_state(*state); + GetExhaustAbsorberInput(*state); auto &thisChillerHeater = state->dataChillerExhaustAbsorption->ExhaustAbsorber(1); @@ -1121,6 +1126,8 @@ TEST_F(EnergyPlusFixture, ExhAbsorption_GetInput_Multiple_Objects_Test) ASSERT_TRUE(process_idf(idf_objects)); compare_err_stream(""); + state->init_state(*state); + GetExhaustAbsorberInput(*state); compare_err_stream(""); @@ -1430,6 +1437,8 @@ TEST_F(EnergyPlusFixture, ExhAbsorption_calcChiller_Err_Msg_Test) ASSERT_TRUE(process_idf(idf_objects)); compare_err_stream(""); + state->init_state(*state); + GetExhaustAbsorberInput(*state); auto &thisChillerHeater = state->dataChillerExhaustAbsorption->ExhaustAbsorber(1); diff --git a/tst/EnergyPlus/unit/ChillerGasAbsorption.unit.cc b/tst/EnergyPlus/unit/ChillerGasAbsorption.unit.cc index f2cf123a9e9..251877bd306 100644 --- a/tst/EnergyPlus/unit/ChillerGasAbsorption.unit.cc +++ b/tst/EnergyPlus/unit/ChillerGasAbsorption.unit.cc @@ -140,7 +140,8 @@ TEST_F(EnergyPlusFixture, GasAbsorption_GetInput_Test) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + GetGasAbsorberInput(*state); EXPECT_EQ(1u, state->dataChillerGasAbsorption->GasAbsorber.size()); @@ -171,6 +172,7 @@ TEST_F(EnergyPlusFixture, GasAbsorption_GetInput_Test) TEST_F(EnergyPlusFixture, GasAbsorption_getDesignCapacities_Test) { + state->init_state(*state); state->dataPlnt->TotNumLoops = 3; state->dataPlnt->PlantLoop.allocate(state->dataPlnt->TotNumLoops); @@ -317,7 +319,8 @@ TEST_F(EnergyPlusFixture, GasAbsorption_calculateHeater_Fix_Test) ASSERT_TRUE(process_idf(idf_objects)); compare_err_stream(""); - + state->init_state(*state); + GetGasAbsorberInput(*state); auto &thisChillerHeater = state->dataChillerGasAbsorption->GasAbsorber(1); diff --git a/tst/EnergyPlus/unit/ChillerReformulatedEIR.unit.cc b/tst/EnergyPlus/unit/ChillerReformulatedEIR.unit.cc index f3c9696983f..369e867eb48 100644 --- a/tst/EnergyPlus/unit/ChillerReformulatedEIR.unit.cc +++ b/tst/EnergyPlus/unit/ChillerReformulatedEIR.unit.cc @@ -76,15 +76,14 @@ TEST_F(EnergyPlusFixture, ChillerElectricReformulatedEIR_WaterCooledChillerVaria state->dataPlnt->TotNumLoops = 2; state->dataEnvrn->OutBaroPress = 101325.0; state->dataEnvrn->StdRhoAir = 1.20; - state->dataGlobal->NumOfTimeStepInHour = 1; + state->dataGlobal->TimeStepsInHour = 1; state->dataGlobal->TimeStep = 1; - state->dataGlobal->MinutesPerTimeStep = 60; + state->dataGlobal->MinutesInTimeStep = 60; state->dataGlobal->HourOfDay = 1; state->dataEnvrn->DayOfWeek = 1; state->dataEnvrn->Month = 1; state->dataEnvrn->DayOfMonth = 1; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); - Psychrometrics::InitializePsychRoutines(*state); std::string const idf_objects = delimited_string({ "Chiller:Electric:ReformulatedEIR,", @@ -134,6 +133,8 @@ TEST_F(EnergyPlusFixture, ChillerElectricReformulatedEIR_WaterCooledChillerVaria EXPECT_TRUE(process_idf(idf_objects, false)); + state->init_state(*state); + state->dataPlnt->PlantLoop.allocate(state->dataPlnt->TotNumLoops); state->dataPlnt->PlantLoop.allocate(state->dataPlnt->TotNumLoops); for (int l = 1; l <= state->dataPlnt->TotNumLoops; ++l) { @@ -189,7 +190,7 @@ TEST_F(EnergyPlusFixture, ChillerElectricReformulatedEIR_WaterCooledChillerVaria thisChiller.size(*state); MyLoad = -thisChiller.RefCap; state->dataSize->PlantSizData(1).DesCapacity = std::abs(MyLoad) * 2; - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); // run through init again after sizing is complete to set mass flow rate state->dataGlobal->BeginEnvrnFlag = true; diff --git a/tst/EnergyPlus/unit/Coils/CoilCoolingDX.unit.cc b/tst/EnergyPlus/unit/Coils/CoilCoolingDX.unit.cc index 7dafe1b8074..4b540e691de 100644 --- a/tst/EnergyPlus/unit/Coils/CoilCoolingDX.unit.cc +++ b/tst/EnergyPlus/unit/Coils/CoilCoolingDX.unit.cc @@ -71,6 +71,7 @@ TEST_F(CoilCoolingDXTest, CoilCoolingDXInput) { std::string idf_objects = this->getCoilObjectString("coolingCoil", false, 2); EXPECT_TRUE(process_idf(idf_objects, false)); + state->init_state(*state); int coilIndex = CoilCoolingDX::factory(*state, "coolingCoil"); auto const &thisCoil(state->dataCoilCooingDX->coilCoolingDXs[coilIndex]); EXPECT_EQ("COOLINGCOIL", thisCoil.name); @@ -144,6 +145,7 @@ TEST_F(CoilCoolingDXTest, CoilCoolingDXAlternateModePerformance) " 1.0, !- Active Fraction of Coil Face Area", " ,,,,,,,,,,,;"}); EXPECT_TRUE(process_idf(idf_objects, false)); + state->init_state(*state); int coilIndex = CoilCoolingDX::factory(*state, "Coil"); auto &thisCoil(state->dataCoilCooingDX->coilCoolingDXs[coilIndex]); @@ -280,6 +282,7 @@ TEST_F(CoilCoolingDXTest, CoilCoolingDXAlternateModePerformanceHitsSaturation) " 1.0, !- Active Fraction of Coil Face Area", " ,,,,,,,,,,,;"}); EXPECT_TRUE(process_idf(idf_objects, false)); + state->init_state(*state); int coilIndex = CoilCoolingDX::factory(*state, "Coil"); auto &thisCoil(state->dataCoilCooingDX->coilCoolingDXs[coilIndex]); @@ -395,7 +398,7 @@ TEST_F(EnergyPlusFixture, DISABLED_CoilDXCoolingVsMultiSpeed_CycFanCycCoil) Coil.DXCoilType_Num = HVAC::CoilDX_MultiSpeedCooling; Coil.DXCoilType = "Coil:Cooling:DX:MultiSpeed"; Coil.FuelType = Constant::eFuel::Electricity; - Coil.SchedPtr = ScheduleManager::ScheduleAlwaysOn; + Coil.availSched = Sched::GetScheduleAlwaysOn(*state); Coil.NumOfSpeeds = 2; Coil.MSRatedTotCap.allocate(Coil.NumOfSpeeds); Coil.MSRatedSHR.allocate(Coil.NumOfSpeeds); @@ -668,6 +671,7 @@ TEST_F(EnergyPlusFixture, DISABLED_CoilDXCoolingVsMultiSpeed_CycFanCycCoil) }); EXPECT_TRUE(process_idf(idf_objects, false)); + state->init_state(*state); int coilIndex = CoilCoolingDX::factory(*state, "Coil"); auto &thisCoil(state->dataCoilCooingDX->coilCoolingDXs[coilIndex]); @@ -811,7 +815,7 @@ TEST_F(EnergyPlusFixture, DISABLED_CoilDXCoolingVsMultiSpeed_ContFanCycCoil) Coil.DXCoilType_Num = HVAC::CoilDX_MultiSpeedCooling; Coil.DXCoilType = "Coil:Cooling:DX:MultiSpeed"; Coil.FuelType = Constant::eFuel::Electricity; - Coil.SchedPtr = ScheduleManager::ScheduleAlwaysOn; + Coil.availSched = Sched::GetScheduleAlwaysOn(*state); Coil.NumOfSpeeds = 2; Coil.MSRatedTotCap.allocate(Coil.NumOfSpeeds); Coil.MSRatedSHR.allocate(Coil.NumOfSpeeds); @@ -1085,6 +1089,7 @@ TEST_F(EnergyPlusFixture, DISABLED_CoilDXCoolingVsMultiSpeed_ContFanCycCoil) }); EXPECT_TRUE(process_idf(idf_objects, false)); + state->init_state(*state); int coilIndex = CoilCoolingDX::factory(*state, "Coil"); auto &thisCoil(state->dataCoilCooingDX->coilCoolingDXs[coilIndex]); @@ -1227,7 +1232,7 @@ TEST_F(EnergyPlusFixture, DISABLED_CoilDXMultiSpeed_SpeedCheck_CycFanCycCoil) Coil.DXCoilType_Num = HVAC::CoilDX_MultiSpeedCooling; Coil.DXCoilType = "Coil:Cooling:DX:MultiSpeed"; Coil.FuelType = Constant::eFuel::Electricity; - Coil.SchedPtr = ScheduleManager::ScheduleAlwaysOn; + Coil.availSched = Sched::GetScheduleAlwaysOn(*state); Coil.NumOfSpeeds = 2; Coil.MSRatedTotCap.allocate(Coil.NumOfSpeeds); Coil.MSRatedSHR.allocate(Coil.NumOfSpeeds); @@ -1458,7 +1463,7 @@ TEST_F(EnergyPlusFixture, DISABLED_CoilDXMultiSpeed_SpeedCheck_ContFanCycCoil) Coil.DXCoilType_Num = HVAC::CoilDX_MultiSpeedCooling; Coil.DXCoilType = "Coil:Cooling:DX:MultiSpeed"; Coil.FuelType = Constant::eFuel::Electricity; - Coil.SchedPtr = ScheduleManager::ScheduleAlwaysOn; + Coil.availSched = Sched::GetScheduleAlwaysOn(*state); Coil.NumOfSpeeds = 2; Coil.MSRatedTotCap.allocate(Coil.NumOfSpeeds); Coil.MSRatedSHR.allocate(Coil.NumOfSpeeds); @@ -1805,6 +1810,7 @@ TEST_F(CoilCoolingDXTest, CoilCoolingDX_LowerSpeedFlowSizingTest) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); int coilIndex = CoilCoolingDX::factory(*state, "DX Cooling Coil"); auto &this_dx_clg_coil = state->dataCoilCooingDX->coilCoolingDXs[coilIndex]; diff --git a/tst/EnergyPlus/unit/Coils/CoilCoolingDXCurveFitOperatingMode.unit.cc b/tst/EnergyPlus/unit/Coils/CoilCoolingDXCurveFitOperatingMode.unit.cc index 6266eab7d75..8a6c36ace5c 100644 --- a/tst/EnergyPlus/unit/Coils/CoilCoolingDXCurveFitOperatingMode.unit.cc +++ b/tst/EnergyPlus/unit/Coils/CoilCoolingDXCurveFitOperatingMode.unit.cc @@ -117,6 +117,8 @@ TEST_F(CoilCoolingDXTest, CoilCoolingDXCurveFitOperatingMode_Sizing) }); idf_objects += this->getSpeedObjectString("Coil Cooling DX Curve Fit Speed 1"); EXPECT_TRUE(process_idf(idf_objects, false)); + state->init_state(*state); + CoilCoolingDXCurveFitOperatingMode thisMode(*state, "Coil Cooling DX Curve Fit Operating Mode 1"); EXPECT_ENUM_EQ(CoilCoolingDXCurveFitOperatingMode::CondenserType::EVAPCOOLED, thisMode.condenserType); EXPECT_EQ(DataSizing::AutoSize, thisMode.ratedEvapAirFlowRate); @@ -260,6 +262,8 @@ TEST_F(CoilCoolingDXTest, CoilCoolingDXCurveFitCrankcaseHeaterCurve) idf_objects += this->getSpeedObjectString("Coil Cooling DX Curve Fit Speed 1"); EXPECT_TRUE(process_idf(idf_objects, false)); + state->init_state(*state); + int coilIndex = CoilCoolingDX::factory(*state, "Coil Cooling DX 1"); auto &thisCoil(state->dataCoilCooingDX->coilCoolingDXs[coilIndex]); EXPECT_EQ("COIL COOLING DX 1", thisCoil.name); diff --git a/tst/EnergyPlus/unit/Coils/CoilCoolingDXCurveFitPerformance.unit.cc b/tst/EnergyPlus/unit/Coils/CoilCoolingDXCurveFitPerformance.unit.cc index d11d0cf4c68..082e41aea17 100644 --- a/tst/EnergyPlus/unit/Coils/CoilCoolingDXCurveFitPerformance.unit.cc +++ b/tst/EnergyPlus/unit/Coils/CoilCoolingDXCurveFitPerformance.unit.cc @@ -59,6 +59,7 @@ TEST_F(CoilCoolingDXTest, CoilCoolingDXCurveFitPerformanceInput) { std::string idf_objects = this->getPerformanceObjectString("coilPerformance", false, 2); EXPECT_TRUE(process_idf(idf_objects, false)); + state->init_state(*state); CoilCoolingDXCurveFitPerformance thisPerf(*state, "coilPerformance"); EXPECT_EQ("COILPERFORMANCE", thisPerf.name); EXPECT_EQ("BASEOPERATINGMODE", thisPerf.normalMode.name); @@ -69,6 +70,7 @@ TEST_F(CoilCoolingDXTest, CoilCoolingDXCurveFitPerformanceInputAlternateMode) { std::string idf_objects = this->getPerformanceObjectString("coilPerformance", true, 2); EXPECT_TRUE(process_idf(idf_objects, false)); + state->init_state(*state); CoilCoolingDXCurveFitPerformance thisPerf(*state, "coilPerformance"); EXPECT_EQ("COILPERFORMANCE", thisPerf.name); EXPECT_EQ("BASEOPERATINGMODE", thisPerf.normalMode.name); diff --git a/tst/EnergyPlus/unit/CondenserLoopTowers.unit.cc b/tst/EnergyPlus/unit/CondenserLoopTowers.unit.cc index 41e89f21271..0c00c76e47b 100644 --- a/tst/EnergyPlus/unit/CondenserLoopTowers.unit.cc +++ b/tst/EnergyPlus/unit/CondenserLoopTowers.unit.cc @@ -148,19 +148,6 @@ TEST_F(EnergyPlusFixture, CondenserLoopTowers_MerkelNoCooling) " ScheduleTypeLimits,", " Any Number; !- Name", - " Schedule:Compact,", - " ALWAYS_ON, !- Name", - " On/Off, !- Schedule Type Limits Name", - " Through: 12/31, !- Field 1", - " For: AllDays, !- Field 2", - " Until: 24:00,1; !- Field 3", - - " ScheduleTypeLimits,", - " On/Off, !- Name", - " 0, !- Lower Limit Value", - " 1, !- Upper Limit Value", - " DISCRETE; !- Numeric Type", - " CoolingTower:VariableSpeed:Merkel,", " TowerWaterSys CoolTower1,!- Name", " TowerWaterSys Pump-TowerWaterSys CoolTowerNode, !- Water Inlet Node Name", @@ -298,7 +285,7 @@ TEST_F(EnergyPlusFixture, CondenserLoopTowers_MerkelNoCooling) " TowerWaterSys Loop Operation Scheme List, !- Name", " PlantEquipmentOperation:CoolingLoad, !- Control Scheme 1 Object Type", " TowerWaterSys Operation Scheme, !- Control Scheme 1 Name", - " ALWAYS_ON; !- Control Scheme 1 Schedule Name", + " CONSTANT-1.0; !- Control Scheme 1 Schedule Name", " PlantEquipmentOperation:CoolingLoad,", " TowerWaterSys Operation Scheme, !- Name", @@ -487,12 +474,13 @@ TEST_F(EnergyPlusFixture, CondenserLoopTowers_MerkelNoCooling) }); ASSERT_TRUE(process_idf(idf_objects)); - SimulationManager::PostIPProcessing(*state); bool ErrorsFound = false; state->dataGlobal->BeginSimFlag = true; - SimulationManager::GetProjectData(*state); + + state->init_state(*state); + OutputReportPredefined::SetPredefinedTables(*state); // OutputProcessor::TimeValue.allocate(2); @@ -602,19 +590,6 @@ TEST_F(EnergyPlusFixture, CondenserLoopTowers_SingleSpeedSizing) " ScheduleTypeLimits,", " Any Number; !- Name", - " Schedule:Compact,", - " ALWAYS_ON, !- Name", - " On/Off, !- Schedule Type Limits Name", - " Through: 12/31, !- Field 1", - " For: AllDays, !- Field 2", - " Until: 24:00,1; !- Field 3", - - " ScheduleTypeLimits,", - " On/Off, !- Name", - " 0, !- Lower Limit Value", - " 1, !- Upper Limit Value", - " DISCRETE; !- Numeric Type", - " CoolingTower:SingleSpeed,", " TowerWaterSys CoolTower1,!- Name", " TowerWaterSys Pump-TowerWaterSys CoolTowerNode, !- Water Inlet Node Name", @@ -692,7 +667,7 @@ TEST_F(EnergyPlusFixture, CondenserLoopTowers_SingleSpeedSizing) " TowerWaterSys Loop Operation Scheme List, !- Name", " PlantEquipmentOperation:CoolingLoad, !- Control Scheme 1 Object Type", " TowerWaterSys Operation Scheme, !- Control Scheme 1 Name", - " ALWAYS_ON; !- Control Scheme 1 Schedule Name", + " CONSTANT-1.0; !- Control Scheme 1 Schedule Name", " PlantEquipmentOperation:CoolingLoad,", " TowerWaterSys Operation Scheme, !- Name", @@ -881,12 +856,13 @@ TEST_F(EnergyPlusFixture, CondenserLoopTowers_SingleSpeedSizing) }); ASSERT_TRUE(process_idf(idf_objects)); - SimulationManager::PostIPProcessing(*state); bool ErrorsFound = false; state->dataGlobal->BeginSimFlag = true; - SimulationManager::GetProjectData(*state); + + state->init_state(*state); + OutputReportPredefined::SetPredefinedTables(*state); // OutputProcessor::TimeValue.allocate(2); @@ -1041,19 +1017,6 @@ TEST_F(EnergyPlusFixture, CondenserLoopTowers_SingleSpeedUserInputTowerSizing) " ScheduleTypeLimits,", " Any Number; !- Name", - " Schedule:Compact,", - " ALWAYS_ON, !- Name", - " On/Off, !- Schedule Type Limits Name", - " Through: 12/31, !- Field 1", - " For: AllDays, !- Field 2", - " Until: 24:00,1; !- Field 3", - - " ScheduleTypeLimits,", - " On/Off, !- Name", - " 0, !- Lower Limit Value", - " 1, !- Upper Limit Value", - " DISCRETE; !- Numeric Type", - " CoolingTower:SingleSpeed,", " TowerWaterSys CoolTower1,!- Name", " TowerWaterSys Pump-TowerWaterSys CoolTowerNode, !- Water Inlet Node Name", @@ -1130,7 +1093,7 @@ TEST_F(EnergyPlusFixture, CondenserLoopTowers_SingleSpeedUserInputTowerSizing) " TowerWaterSys Loop Operation Scheme List, !- Name", " PlantEquipmentOperation:CoolingLoad, !- Control Scheme 1 Object Type", " TowerWaterSys Operation Scheme, !- Control Scheme 1 Name", - " ALWAYS_ON; !- Control Scheme 1 Schedule Name", + " CONSTANT-1.0; !- Control Scheme 1 Schedule Name", " PlantEquipmentOperation:CoolingLoad,", " TowerWaterSys Operation Scheme, !- Name", @@ -1319,12 +1282,13 @@ TEST_F(EnergyPlusFixture, CondenserLoopTowers_SingleSpeedUserInputTowerSizing) }); ASSERT_TRUE(process_idf(idf_objects)); - SimulationManager::PostIPProcessing(*state); + + state->init_state(*state); bool ErrorsFound = false; state->dataGlobal->BeginSimFlag = true; - SimulationManager::GetProjectData(*state); + OutputReportPredefined::SetPredefinedTables(*state); // OutputProcessor::TimeValue.allocate(2); @@ -1455,19 +1419,6 @@ TEST_F(EnergyPlusFixture, CondenserLoopTowers_TwoSpeedUserInputTowerSizing) " ScheduleTypeLimits,", " Any Number; !- Name", - " Schedule:Compact,", - " ALWAYS_ON, !- Name", - " On/Off, !- Schedule Type Limits Name", - " Through: 12/31, !- Field 1", - " For: AllDays, !- Field 2", - " Until: 24:00,1; !- Field 3", - - " ScheduleTypeLimits,", - " On/Off, !- Name", - " 0, !- Lower Limit Value", - " 1, !- Upper Limit Value", - " DISCRETE; !- Numeric Type", - " CoolingTower:TwoSpeed,", " TowerWaterSys CoolTower1,!- Name", " TowerWaterSys Pump-TowerWaterSys CoolTowerNode, !- Water Inlet Node Name", @@ -1550,7 +1501,7 @@ TEST_F(EnergyPlusFixture, CondenserLoopTowers_TwoSpeedUserInputTowerSizing) " TowerWaterSys Loop Operation Scheme List, !- Name", " PlantEquipmentOperation:CoolingLoad, !- Control Scheme 1 Object Type", " TowerWaterSys Operation Scheme, !- Control Scheme 1 Name", - " ALWAYS_ON; !- Control Scheme 1 Schedule Name", + " CONSTANT-1.0; !- Control Scheme 1 Schedule Name", " PlantEquipmentOperation:CoolingLoad,", " TowerWaterSys Operation Scheme, !- Name", @@ -1739,12 +1690,12 @@ TEST_F(EnergyPlusFixture, CondenserLoopTowers_TwoSpeedUserInputTowerSizing) }); ASSERT_TRUE(process_idf(idf_objects)); - SimulationManager::PostIPProcessing(*state); + state->init_state(*state); + bool ErrorsFound = false; state->dataGlobal->BeginSimFlag = true; - SimulationManager::GetProjectData(*state); OutputReportPredefined::SetPredefinedTables(*state); // OutputProcessor::TimeValue.allocate(2); @@ -1890,19 +1841,6 @@ TEST_F(EnergyPlusFixture, CondenserLoopTowers_MerkelUserInputTowerSizing) " ScheduleTypeLimits,", " Any Number; !- Name", - " Schedule:Compact,", - " ALWAYS_ON, !- Name", - " On/Off, !- Schedule Type Limits Name", - " Through: 12/31, !- Field 1", - " For: AllDays, !- Field 2", - " Until: 24:00,1; !- Field 3", - - " ScheduleTypeLimits,", - " On/Off, !- Name", - " 0, !- Lower Limit Value", - " 1, !- Upper Limit Value", - " DISCRETE; !- Numeric Type", - " CoolingTower:VariableSpeed:Merkel,", " TowerWaterSys CoolTower1,!- Name", " TowerWaterSys Pump-TowerWaterSys CoolTowerNode, !- Water Inlet Node Name", @@ -2040,7 +1978,7 @@ TEST_F(EnergyPlusFixture, CondenserLoopTowers_MerkelUserInputTowerSizing) " TowerWaterSys Loop Operation Scheme List, !- Name", " PlantEquipmentOperation:CoolingLoad, !- Control Scheme 1 Object Type", " TowerWaterSys Operation Scheme, !- Control Scheme 1 Name", - " ALWAYS_ON; !- Control Scheme 1 Schedule Name", + " CONSTANT-1.0; !- Control Scheme 1 Schedule Name", " PlantEquipmentOperation:CoolingLoad,", " TowerWaterSys Operation Scheme, !- Name", @@ -2229,12 +2167,12 @@ TEST_F(EnergyPlusFixture, CondenserLoopTowers_MerkelUserInputTowerSizing) }); ASSERT_TRUE(process_idf(idf_objects)); - SimulationManager::PostIPProcessing(*state); + state->init_state(*state); + bool ErrorsFound = false; state->dataGlobal->BeginSimFlag = true; - SimulationManager::GetProjectData(*state); OutputReportPredefined::SetPredefinedTables(*state); // OutputProcessor::TimeValue.allocate(2); @@ -2373,19 +2311,6 @@ TEST_F(EnergyPlusFixture, CondenserLoopTowers_TwoSpeedTowerLowSpeedNomCapSizing) " ScheduleTypeLimits,", " Any Number; !- Name", - " Schedule:Compact,", - " ALWAYS_ON, !- Name", - " On/Off, !- Schedule Type Limits Name", - " Through: 12/31, !- Field 1", - " For: AllDays, !- Field 2", - " Until: 24:00,1; !- Field 3", - - " ScheduleTypeLimits,", - " On/Off, !- Name", - " 0, !- Lower Limit Value", - " 1, !- Upper Limit Value", - " DISCRETE; !- Numeric Type", - " CoolingTower:TwoSpeed,", " TowerWaterSys CoolTower1,!- Name", " TowerWaterSys Pump-TowerWaterSys CoolTowerNode, !- Water Inlet Node Name", @@ -2473,7 +2398,7 @@ TEST_F(EnergyPlusFixture, CondenserLoopTowers_TwoSpeedTowerLowSpeedNomCapSizing) " TowerWaterSys Loop Operation Scheme List, !- Name", " PlantEquipmentOperation:CoolingLoad, !- Control Scheme 1 Object Type", " TowerWaterSys Operation Scheme, !- Control Scheme 1 Name", - " ALWAYS_ON; !- Control Scheme 1 Schedule Name", + " CONSTANT-1.0; !- Control Scheme 1 Schedule Name", " PlantEquipmentOperation:CoolingLoad,", " TowerWaterSys Operation Scheme, !- Name", @@ -2662,12 +2587,12 @@ TEST_F(EnergyPlusFixture, CondenserLoopTowers_TwoSpeedTowerLowSpeedNomCapSizing) }); ASSERT_TRUE(process_idf(idf_objects)); - SimulationManager::PostIPProcessing(*state); + state->init_state(*state); + bool ErrorsFound = false; state->dataGlobal->BeginSimFlag = true; - SimulationManager::GetProjectData(*state); OutputReportPredefined::SetPredefinedTables(*state); // OutputProcessor::TimeValue.allocate(2); @@ -3053,10 +2978,11 @@ TEST_F(EnergyPlusFixture, CondenserLoopTowers_SingleSpeedUser_SizingError_Sizing }); ASSERT_TRUE(process_idf(idf_objects)); - SimulationManager::PostIPProcessing(*state); + state->init_state(*state); + state->dataGlobal->BeginSimFlag = true; - SimulationManager::GetProjectData(*state); + OutputReportPredefined::SetPredefinedTables(*state); // OutputProcessor::TimeValue.allocate(2); @@ -3445,10 +3371,10 @@ TEST_F(EnergyPlusFixture, CondenserLoopTowers_SingleSpeedUser_SizingError_UserSp }); ASSERT_TRUE(process_idf(idf_objects)); - SimulationManager::PostIPProcessing(*state); + state->init_state(*state); + state->dataGlobal->BeginSimFlag = true; - SimulationManager::GetProjectData(*state); OutputReportPredefined::SetPredefinedTables(*state); // OutputProcessor::TimeValue.allocate(2); @@ -3584,19 +3510,6 @@ TEST_F(EnergyPlusFixture, VSCoolingTowers_WaterOutletTempTest) " ScheduleTypeLimits,", " Any Number; !- Name", - " Schedule:Compact,", - " ALWAYS_ON, !- Name", - " On/Off, !- Schedule Type Limits Name", - " Through: 12/31, !- Field 1", - " For: AllDays, !- Field 2", - " Until: 24:00,1; !- Field 3", - - " ScheduleTypeLimits,", - " On/Off, !- Name", - " 0, !- Lower Limit Value", - " 1, !- Upper Limit Value", - " DISCRETE; !- Numeric Type", - " CoolingTower:VariableSpeed,", " CoolingTower Variable Speed, !- Name", " Tower Inlet Node, !- Water Inlet Node Name", @@ -3712,10 +3625,10 @@ TEST_F(EnergyPlusFixture, VSCoolingTowers_WaterOutletTempTest) " CoolingTower Loop Operation Scheme List, !- Name", " PlantEquipmentOperation:CoolingLoad, !- Control Scheme 1 Object Type", " CoolingTower Operation Scheme, !- Control Scheme 1 Name", - " ALWAYS_ON, !- Control Scheme 1 Schedule Name", + " CONSTANT-1.0, !- Control Scheme 1 Schedule Name", " PlantEquipmentOperation:ComponentSetpoint, !- Control Scheme 3 Object Type", " CoolingTower Loop Setpoint Operation Scheme, !- Control Scheme 3 Name", - " ALWAYS_ON; !- Control Scheme 3 Schedule Name", + " CONSTANT-1.0; !- Control Scheme 3 Schedule Name", " PlantEquipmentOperation:ComponentSetpoint,", " CoolingTower Loop Setpoint Operation Scheme, !- Name", @@ -3919,10 +3832,10 @@ TEST_F(EnergyPlusFixture, VSCoolingTowers_WaterOutletTempTest) }); ASSERT_TRUE(process_idf(idf_objects)); - SimulationManager::PostIPProcessing(*state); + state->init_state(*state); + state->dataGlobal->BeginSimFlag = true; - SimulationManager::GetProjectData(*state); OutputReportPredefined::SetPredefinedTables(*state); OutputProcessor::SetupTimePointers(*state, OutputProcessor::TimeStepType::Zone, state->dataGlobal->TimeStepZone); @@ -4176,6 +4089,9 @@ TEST_F(EnergyPlusFixture, CondenserLoopTowers_CoolingTowersDefaultValuesTest) }); ASSERT_TRUE(process_idf(idf_objects)); + + state->init_state(*state); + // cooling towers get input CondenserLoopTowers::GetTowerInput(*state); @@ -4294,6 +4210,9 @@ TEST_F(EnergyPlusFixture, CondenserLoopTowers_CalculateVariableTowerOutletTemp) }); ASSERT_TRUE(process_idf(idf_objects)); + + state->init_state(*state); + // cooling tower get input CondenserLoopTowers::GetTowerInput(*state); int index; @@ -4338,7 +4257,7 @@ TEST_F(EnergyPlusFixture, CondenserLoopTowers_checkMassFlowAndLoadTest) state->dataEnvrn->OutDryBulbTemp = 27.0; tower.WaterMassFlowRate = 0.0; tower.BasinHeaterPowerFTempDiff = 1.0; - tower.BasinHeaterSchedulePtr = 0; + tower.basinHeaterSched = nullptr; tower.BasinHeaterSetPointTemp = 26.0; tower.BasinHeaterPower = 1.0; expectedPower = 0.0; @@ -4353,7 +4272,7 @@ TEST_F(EnergyPlusFixture, CondenserLoopTowers_checkMassFlowAndLoadTest) state->dataEnvrn->OutDryBulbTemp = 27.0; tower.WaterMassFlowRate = 0.5; tower.BasinHeaterPowerFTempDiff = 1.0; - tower.BasinHeaterSchedulePtr = 0; + tower.basinHeaterSched = nullptr; tower.BasinHeaterSetPointTemp = 25.0; tower.BasinHeaterPower = 2.0; tower.FanPower = 1.0; @@ -4377,7 +4296,7 @@ TEST_F(EnergyPlusFixture, CondenserLoopTowers_checkMassFlowAndLoadTest) state->dataEnvrn->OutDryBulbTemp = 27.0; tower.WaterMassFlowRate = 0.5; tower.BasinHeaterPowerFTempDiff = 1.0; - tower.BasinHeaterSchedulePtr = 0; + tower.basinHeaterSched = nullptr; tower.BasinHeaterSetPointTemp = 25.0; tower.BasinHeaterPower = 3.0; expectedPower = 3.0; diff --git a/tst/EnergyPlus/unit/ConvectionCoefficients.unit.cc b/tst/EnergyPlus/unit/ConvectionCoefficients.unit.cc index 69790886002..7bdbd27baf1 100644 --- a/tst/EnergyPlus/unit/ConvectionCoefficients.unit.cc +++ b/tst/EnergyPlus/unit/ConvectionCoefficients.unit.cc @@ -584,6 +584,7 @@ TEST_F(ConvectionCoefficientsFixture, initExtConvCoeffAdjRatio) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); bool ErrorsFound(false); HeatBalanceManager::GetProjectControlData(*state, ErrorsFound); // read project control data @@ -804,7 +805,8 @@ TEST_F(ConvectionCoefficientsFixture, initIntConvCoeffAdjRatio) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + bool ErrorsFound(false); HeatBalanceManager::GetProjectControlData(*state, ErrorsFound); // read project control data EXPECT_FALSE(ErrorsFound); @@ -890,7 +892,8 @@ TEST_F(ConvectionCoefficientsFixture, DynamicIntConvSurfaceClassification) std::string const idf_objects = this->getIDFString(); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + bool errorsFound(false); HeatBalanceManager::GetProjectControlData(*state, errorsFound); // read project control data EXPECT_FALSE(errorsFound); // expect no errors @@ -1440,6 +1443,7 @@ TEST_F(ConvectionCoefficientsFixture, CalcBeausoleilMorrisonMixedAssistedWall) std::string const idf_objects = this->getIDFString(); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); state->dataEnvrn->OutBaroPress = 101325.0; @@ -1495,6 +1499,7 @@ TEST_F(ConvectionCoefficientsFixture, CalcBeausoleilMorrisonMixedOpposingWall) std::string const idf_objects = this->getIDFString(); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); state->dataEnvrn->OutBaroPress = 101325.0; @@ -1550,6 +1555,7 @@ TEST_F(ConvectionCoefficientsFixture, CalcBeausoleilMorrisonMixedStableFloor) std::string const idf_objects = this->getIDFString(); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); state->dataEnvrn->OutBaroPress = 101325.0; @@ -1605,6 +1611,7 @@ TEST_F(ConvectionCoefficientsFixture, CalcBeausoleilMorrisonMixedUnstableFloor) std::string const idf_objects = this->getIDFString(); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); state->dataEnvrn->OutBaroPress = 101325.0; @@ -1660,6 +1667,7 @@ TEST_F(ConvectionCoefficientsFixture, CalcBeausoleilMorrisonMixedStableCeiling) std::string const idf_objects = this->getIDFString(); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); state->dataEnvrn->OutBaroPress = 101325.0; @@ -1715,6 +1723,7 @@ TEST_F(ConvectionCoefficientsFixture, CalcBeausoleilMorrisonMixedUnstableCeiling std::string const idf_objects = this->getIDFString(); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); state->dataEnvrn->OutBaroPress = 101325.0; @@ -1913,6 +1922,7 @@ TEST_F(EnergyPlusFixture, AdaptiveModelSelections_ProperConstruction) "Default algorithms; !- Name"}); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); Convect::HcInt algo; @@ -2041,6 +2051,7 @@ TEST_F(EnergyPlusFixture, AdaptiveModelSelections_Implicit) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); state->dataHeatBalSurf->SurfTempInTmp.allocate(6); state->dataHeatBalSurf->SurfTempInTmp(1) = 15.0; @@ -2281,6 +2292,7 @@ TEST_F(EnergyPlusFixture, AdaptiveModelSelections_ExplicitSelection) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); state->dataHeatBalSurf->SurfTempInTmp.allocate(6); state->dataHeatBalSurf->SurfTempInTmp(1) = 15.0; @@ -2620,6 +2632,7 @@ TEST_F(ConvectionCoefficientsFixture, TestSetAdaptiveConvectionAlgoCoefficient) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); state->dataHeatBalSurf->SurfTempInTmp.allocate(6); state->dataHeatBalSurf->SurfTempInTmp(1) = 15.0; @@ -2783,6 +2796,7 @@ TEST_F(ConvectionCoefficientsFixture, TestBlockenWindward) std::string const idf_objects = this->getIDFString(); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); bool ErrorsFound(false); HeatBalanceManager::GetProjectControlData(*state, ErrorsFound); // read project control data @@ -2871,6 +2885,7 @@ TEST_F(ConvectionCoefficientsFixture, TestMultipleSurfaceConvectionArrayAllocati }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); state->dataSurface->surfIntConv.allocate(2); state->dataSurface->surfExtConv.allocate(2); @@ -2898,6 +2913,7 @@ TEST_F(ConvectionCoefficientsFixture, TestMultipleSurfaceConvectionArrayAllocati }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); state->dataSurface->surfIntConv.allocate(2); state->dataSurface->surfExtConv.allocate(2); @@ -2921,6 +2937,7 @@ TEST_F(ConvectionCoefficientsFixture, TestSurfaceConvectionArrayAllocation1) " 10; !- Convection Coefficient 2"}); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); state->dataSurface->Surface.allocate(2); state->dataSurface->Surface(1).Name = "FAKESURFACE"; @@ -2950,6 +2967,7 @@ TEST_F(ConvectionCoefficientsFixture, TestSurfaceConvectionArrayAllocation2) " 10; !- Convection Coefficient 2"}); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); state->dataSurface->Surface.allocate(2); state->dataSurface->Surface(1).Name = "FAKESURFACE"; @@ -3138,6 +3156,7 @@ TEST_F(ConvectionCoefficientsFixture, RoofPerimeter_PerfectSquare_Rotated) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); bool ErrorsFound = false; @@ -3360,6 +3379,7 @@ TEST_F(ConvectionCoefficientsFixture, RoofPerimeter_WeirderShape) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); bool ErrorsFound = false; @@ -3981,15 +4001,18 @@ TEST_F(ConvectionCoefficientsFixture, SurroundingSurfacesHRadCoefTest) bool ErrorsFound = false; ASSERT_TRUE(process_idf(idf_objects)); + state->dataGlobal->TimeStepsInHour = 1; + state->dataGlobal->MinutesInTimeStep = 60; + state->init_state(*state); + + state->dataGlobal->TimeStep = 1; + state->dataGlobal->TimeStepZone = 1; + state->dataGlobal->TimeStepZoneSec = 3600.0; + // set global and environmental variables state->dataGlobal->BeginSimFlag = true; state->dataGlobal->BeginEnvrnFlag = true; state->dataGlobal->HourOfDay = 15; - state->dataGlobal->TimeStep = 1; - state->dataGlobal->TimeStepZone = 1; - state->dataGlobal->TimeStepZoneSec = 3600.0; - state->dataGlobal->NumOfTimeStepInHour = 1; - state->dataGlobal->MinutesPerTimeStep = 60; state->dataEnvrn->Month = 7; state->dataEnvrn->DayOfMonth = 21; state->dataEnvrn->DSTIndicator = 0; @@ -3997,9 +4020,6 @@ TEST_F(ConvectionCoefficientsFixture, SurroundingSurfacesHRadCoefTest) state->dataEnvrn->HolidayIndex = 0; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); state->dataEnvrn->OutBaroPress = 101325; - // process schedules - ScheduleManager::ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; state->dataHeatBal->ZoneIntGain.allocate(1); // createFacilityElectricPowerServiceObject(*state); @@ -4017,7 +4037,7 @@ TEST_F(ConvectionCoefficientsFixture, SurroundingSurfacesHRadCoefTest) // reset sky and ground view factors HeatBalanceSurfaceManager::InitSurfacePropertyViewFactors(*state); // update schedule values for surrounding surfaces temperature - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); HeatBalanceSurfaceManager::GetSurroundingSurfacesTemperatureAverage(*state); // set outside face temperature of the exterior surfaces state->dataHeatBalSurf->SurfOutsideTempHist(1).dimension(state->dataSurface->TotSurfaces, 0.0); diff --git a/tst/EnergyPlus/unit/CoolTower.unit.cc b/tst/EnergyPlus/unit/CoolTower.unit.cc index a3c648d5900..582ca12d99a 100644 --- a/tst/EnergyPlus/unit/CoolTower.unit.cc +++ b/tst/EnergyPlus/unit/CoolTower.unit.cc @@ -84,6 +84,9 @@ TEST_F(EnergyPlusFixture, ExerciseCoolTower) " 200.0; !- Rated Power Consumption {W}"}); ASSERT_TRUE(process_idf(idf_objects, false)); + + state->init_state(*state); + state->dataHeatBal->Zone.allocate(1); state->dataHeatBal->Zone(1).Name = "ZONE 1"; state->dataZoneTempPredictorCorrector->zoneHeatBalance.allocate(1); diff --git a/tst/EnergyPlus/unit/DElightManager.unit.cc b/tst/EnergyPlus/unit/DElightManager.unit.cc index a728fb5beec..edb4a9693f8 100644 --- a/tst/EnergyPlus/unit/DElightManager.unit.cc +++ b/tst/EnergyPlus/unit/DElightManager.unit.cc @@ -303,12 +303,12 @@ TEST_F(EnergyPlusFixture, DElightManagerF_GetInputDElightComplexFenestration_Tes }); ASSERT_TRUE(process_idf(idf_objects)); + state->dataGlobal->TimeStepsInHour = 1; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 60; // must initialize this to get schedules initialized + state->init_state(*state); bool foundErrors = false; - HeatBalanceManager::GetProjectControlData(*state, foundErrors); // read project control data - EXPECT_FALSE(foundErrors); // expect no errors - Material::GetMaterialData(*state, foundErrors); // read material data EXPECT_FALSE(foundErrors); // expect no errors @@ -323,8 +323,8 @@ TEST_F(EnergyPlusFixture, DElightManagerF_GetInputDElightComplexFenestration_Tes state->dataSurfaceGeometry->CosZoneRelNorth.allocate(1); state->dataSurfaceGeometry->SinZoneRelNorth.allocate(1); - state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); - state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); + state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); + state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); state->dataSurfaceGeometry->CosBldgRelNorth = 1.0; state->dataSurfaceGeometry->SinBldgRelNorth = 0.0; @@ -334,10 +334,6 @@ TEST_F(EnergyPlusFixture, DElightManagerF_GetInputDElightComplexFenestration_Tes SurfaceGeometry::SetupZoneGeometry(*state, foundErrors); // this calls GetSurfaceData() EXPECT_FALSE(foundErrors); // expect no errors - state->dataGlobal->NumOfTimeStepInHour = 1; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 60; // must initialize this to get schedules initialized - ScheduleManager::ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; state->dataGlobal->TimeStep = 1; state->dataGlobal->HourOfDay = 1; state->dataEnvrn->Month = 1; @@ -347,7 +343,7 @@ TEST_F(EnergyPlusFixture, DElightManagerF_GetInputDElightComplexFenestration_Tes state->dataEnvrn->DayOfWeek = 2; state->dataEnvrn->HolidayIndex = 0; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); InternalHeatGains::GetInternalHeatGainsInput(*state); state->dataInternalHeatGains->GetInternalHeatGainsInputFlag = false; diff --git a/tst/EnergyPlus/unit/DOASEffectOnZoneSizing.unit.cc b/tst/EnergyPlus/unit/DOASEffectOnZoneSizing.unit.cc index 1bbf38ea6b6..83d54274b12 100644 --- a/tst/EnergyPlus/unit/DOASEffectOnZoneSizing.unit.cc +++ b/tst/EnergyPlus/unit/DOASEffectOnZoneSizing.unit.cc @@ -81,6 +81,7 @@ using namespace DataHeatBalance; TEST_F(EnergyPlusFixture, DOASEffectOnZoneSizing_CalcDOASSupCondsForSizing) { + state->init_state(*state); // locals Real64 OutDB; // outside air temperature [C] Real64 OutHR; // outside humidity ratio [kg Water / kg Dry Air] @@ -148,9 +149,7 @@ TEST_F(EnergyPlusFixture, DOASEffectOnZoneSizing_SizeZoneEquipment) state->dataZoneTempPredictorCorrector->zoneHeatBalance.allocate(2); state->dataZoneEquip->ZoneEquipConfig.allocate(2); state->dataHeatBalFanSys->TempControlType.allocate(2); - state->dataHeatBalFanSys->TempZoneThermostatSetPoint.allocate(2); - state->dataHeatBalFanSys->ZoneThermostatSetPointLo.allocate(2); - state->dataHeatBalFanSys->ZoneThermostatSetPointHi.allocate(2); + state->dataHeatBalFanSys->zoneTstatSetpts.allocate(2); state->dataZoneEnergyDemand->ZoneSysEnergyDemand.allocate(2); state->dataZoneEnergyDemand->ZoneSysMoistureDemand.allocate(2); state->dataZoneEnergyDemand->DeadBandOrSetback.allocate(2); @@ -159,19 +158,21 @@ TEST_F(EnergyPlusFixture, DOASEffectOnZoneSizing_SizeZoneEquipment) state->dataZoneEquip->ZoneEquipConfig(2).InletNode.allocate(2); state->dataZoneEquip->ZoneEquipConfig(1).ExhaustNode.allocate(1); state->dataZoneEquip->ZoneEquipConfig(2).ExhaustNode.allocate(1); + state->dataZoneEquip->ZoneEquipConfig(1).returnFlowSched = Sched::GetScheduleAlwaysOff(*state); + state->dataZoneEquip->ZoneEquipConfig(2).returnFlowSched = Sched::GetScheduleAlwaysOff(*state); state->dataHeatBalFanSys->ZoneMassBalanceFlag.allocate(2); state->dataGlobal->NumOfZones = 2; state->dataHeatBal->MassConservation.allocate(state->dataGlobal->NumOfZones); HeatBalanceManager::AllocateHeatBalArrays(*state); state->afn->AirflowNetworkNumOfExhFan = 0; - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::DualSetPointWithDeadBand; - state->dataHeatBalFanSys->TempControlType(2) = HVAC::ThermostatType::DualSetPointWithDeadBand; - state->dataHeatBalFanSys->TempZoneThermostatSetPoint(1) = 0.0; - state->dataHeatBalFanSys->TempZoneThermostatSetPoint(2) = 0.0; - state->dataHeatBalFanSys->ZoneThermostatSetPointLo(1) = 22.; - state->dataHeatBalFanSys->ZoneThermostatSetPointLo(2) = 22.; - state->dataHeatBalFanSys->ZoneThermostatSetPointHi(1) = 24.; - state->dataHeatBalFanSys->ZoneThermostatSetPointHi(2) = 24.; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::DualHeatCool; + state->dataHeatBalFanSys->TempControlType(2) = HVAC::SetptType::DualHeatCool; + state->dataHeatBalFanSys->zoneTstatSetpts(1).setpt = 0.0; + state->dataHeatBalFanSys->zoneTstatSetpts(2).setpt = 0.0; + state->dataHeatBalFanSys->zoneTstatSetpts(1).setptLo = 22.; + state->dataHeatBalFanSys->zoneTstatSetpts(2).setptLo = 22.; + state->dataHeatBalFanSys->zoneTstatSetpts(1).setptHi = 24.; + state->dataHeatBalFanSys->zoneTstatSetpts(2).setptHi = 24.; state->dataSize->CurOverallSimDay = 1; state->dataZoneEquip->ZoneEquipConfig(1).IsControlled = true; state->dataZoneEquip->ZoneEquipConfig(2).IsControlled = true; @@ -316,7 +317,7 @@ TEST_F(EnergyPlusFixture, DOASEffectOnZoneSizing_SizeZoneEquipment) TEST_F(EnergyPlusFixture, TestAutoCalcDOASControlStrategy) { - + state->init_state(*state); state->dataSize->NumZoneSizingInput = 2; state->dataSize->ZoneSizingInput.allocate(state->dataSize->NumZoneSizingInput); state->dataSize->ZoneSizingInput(1).AccountForDOAS = false; diff --git a/tst/EnergyPlus/unit/DXCoils.unit.cc b/tst/EnergyPlus/unit/DXCoils.unit.cc index fddcb1dd1c0..e6e072d61eb 100644 --- a/tst/EnergyPlus/unit/DXCoils.unit.cc +++ b/tst/EnergyPlus/unit/DXCoils.unit.cc @@ -82,7 +82,6 @@ using namespace DataAirSystems; using namespace DataSizing; using namespace Curve; using namespace OutputReportPredefined; -using namespace ScheduleManager; using namespace DataEnvironment; namespace EnergyPlus { @@ -306,9 +305,10 @@ TEST_F(EnergyPlusFixture, DXCoils_Test1) state->dataDXCoils->DXCoil(CoilIndex).MSWasteHeat(2) = 0; state->dataDXCoils->DXCoil(CoilIndex).MSWasteHeatFrac(1) = 0; state->dataDXCoils->DXCoil(CoilIndex).MSWasteHeatFrac(2) = 0; - state->dataDXCoils->DXCoil(CoilIndex).SchedPtr = 1; - state->dataScheduleMgr->Schedule.allocate(1); - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; + + state->dataDXCoils->DXCoil(CoilIndex).availSched = Sched::AddScheduleConstant(*state, "AVAIL SCHED"); + state->dataDXCoils->DXCoil(CoilIndex).availSched->currentVal = 1.0; + state->dataDXCoils->DXCoilOutletTemp.allocate(1); state->dataDXCoils->DXCoilOutletHumRat.allocate(1); state->dataDXCoils->DXCoilPartLoadRatio.allocate(1); @@ -451,14 +451,13 @@ TEST_F(EnergyPlusFixture, DXCoils_Test2) TEST_F(EnergyPlusFixture, TestMultiSpeedDefrostCOP) { // Test that the COP calculation is correct when the defrost is on. #4973 - using DXCoils::CalcMultiSpeedDXCoilHeating; using Psychrometrics::PsyHFnTdbW; using Psychrometrics::PsyRhoAirFnPbTdbW; int DXCoilNum; + state->init_state(*state); // Set up heating coil and curves. - state->dataDXCoils->NumDXCoils = 1; DXCoilNum = 1; state->dataDXCoils->DXCoil.allocate(state->dataDXCoils->NumDXCoils); @@ -466,7 +465,7 @@ TEST_F(EnergyPlusFixture, TestMultiSpeedDefrostCOP) Coil.DXCoilType = "Coil:Heating:DX:MultiSpeed"; Coil.DXCoilType_Num = HVAC::CoilDX_MultiSpeedHeating; - Coil.SchedPtr = ScheduleManager::ScheduleAlwaysOn; + Coil.availSched = Sched::GetScheduleAlwaysOn(*state); state->dataDXCoils->DXCoilNumericFields.allocate(state->dataDXCoils->NumDXCoils); state->dataHeatBal->HeatReclaimDXCoil.allocate(state->dataDXCoils->NumDXCoils); @@ -836,8 +835,9 @@ TEST_F(EnergyPlusFixture, TestSingleSpeedDefrostCOP) using Psychrometrics::PsyRhoAirFnPbTdbW; int DXCoilNum; - // Set up heating coil and curves. + state->init_state(*state); + // Set up heating coil and curves. state->dataDXCoils->NumDXCoils = 1; DXCoilNum = 1; state->dataDXCoils->DXCoil.allocate(state->dataDXCoils->NumDXCoils); @@ -854,7 +854,7 @@ TEST_F(EnergyPlusFixture, TestSingleSpeedDefrostCOP) Coil.Name = "DX Single Speed Heating Coil"; Coil.DXCoilType = "Coil:Heating:DX:SingleSpeed"; Coil.DXCoilType_Num = HVAC::CoilDX_HeatingEmpirical; - Coil.SchedPtr = ScheduleManager::ScheduleAlwaysOn; + Coil.availSched = Sched::GetScheduleAlwaysOn(*state); state->dataLoopNodes->Node.allocate(1); Coil.AirOutNode = 1; @@ -1128,8 +1128,7 @@ TEST_F(EnergyPlusFixture, DXCoilEvapCondPumpSizingTest) }); ASSERT_TRUE(process_idf(idf_objects)); - - ProcessScheduleInput(*state); + state->init_state(*state); GetCurveInput(*state); GetDXCoils(*state); @@ -1998,8 +1997,8 @@ TEST_F(EnergyPlusFixture, TestReadingCoilCoolingHeatingDX) }); ASSERT_TRUE(process_idf(idf_objects)); - - ProcessScheduleInput(*state); + state->init_state(*state); + GetCurveInput(*state); GetDXCoils(*state); VariableSpeedCoils::GetVarSpeedCoilInput(*state); @@ -2009,7 +2008,6 @@ TEST_F(EnergyPlusFixture, TestReadingCoilCoolingHeatingDX) state->dataEnvrn->OutDryBulbTemp = 20.0; state->dataEnvrn->OutHumRat = 0.008; state->dataEnvrn->StdRhoAir = Psychrometrics::PsyRhoAirFnPbTdbW(*state, state->dataEnvrn->OutBaroPress, 20.0, 0.0); - Psychrometrics::InitializePsychRoutines(*state); // Coil:Cooling:DX:SingleSpeed EXPECT_EQ(state->dataDXCoils->DXCoil(1).DXCoilType_Num, HVAC::CoilDX_CoolingSingleSpeed); @@ -2199,7 +2197,8 @@ TEST_F(EnergyPlusFixture, TestDXCoilIndoorOrOutdoor) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + // Run DXCoilNum = 1; state->dataDXCoils->DXCoil(DXCoilNum).AirInNode = 1; // "Outside Air Inlet Node 1" @@ -2395,6 +2394,7 @@ TEST_F(EnergyPlusFixture, TestMultiSpeedWasteHeat) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); // Case 1 test state->dataEnvrn->OutDryBulbTemp = 35; @@ -2424,8 +2424,8 @@ TEST_F(EnergyPlusFixture, TestMultiSpeedWasteHeat) state->dataDXCoils->DXCoil(1).InletAirHumRat = 0.005; state->dataDXCoils->DXCoil(1).InletAirEnthalpy = PsyHFnTdbW(25.0, 0.005); - state->dataDXCoils->DXCoil(1).SchedPtr = 1; - state->dataScheduleMgr->Schedule(state->dataDXCoils->DXCoil(1).SchedPtr).CurrentValue = 1.0; // enable the VRF condenser + state->dataDXCoils->DXCoil(1).availSched = Sched::GetSchedule(*state, "FANANDCOILAVAILSCHED"); + state->dataDXCoils->DXCoil(1).availSched->currentVal = 1.0; // enable the VRF condenser state->dataDXCoils->DXCoil(1).MSRatedCBF(1) = 0.1262; state->dataDXCoils->DXCoil(1).MSRatedCBF(2) = 0.0408; @@ -2543,8 +2543,8 @@ TEST_F(EnergyPlusFixture, DXCoil_ValidateADPFunction) }); ASSERT_TRUE(process_idf(idf_objects)); - - ProcessScheduleInput(*state); + state->init_state(*state); + GetCurveInput(*state); GetDXCoils(*state); SetPredefinedTables(*state); @@ -2795,7 +2795,8 @@ TEST_F(EnergyPlusFixture, TestMultiSpeedCoolingCrankcaseOutput) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + // Case 1 test GetDXCoils(*state); @@ -2883,8 +2884,8 @@ TEST_F(EnergyPlusFixture, BlankDefrostEIRCurveInput) }); ASSERT_TRUE(process_idf(idf_objects)); - - ProcessScheduleInput(*state); + state->init_state(*state); + GetCurveInput(*state); GetDXCoils(*state); @@ -2950,8 +2951,8 @@ TEST_F(EnergyPlusFixture, CurveOutputLimitWarning) }); ASSERT_TRUE(process_idf(idf_objects)); - - ProcessScheduleInput(*state); + state->init_state(*state); + GetCurveInput(*state); GetDXCoils(*state); @@ -3057,8 +3058,8 @@ TEST_F(EnergyPlusFixture, CoilHeatingDXSingleSpeed_MinOADBTempCompOperLimit) }); ASSERT_TRUE(process_idf(idf_objects)); - - ProcessScheduleInput(*state); + state->init_state(*state); + GetDXCoils(*state); ASSERT_EQ("HEATING COIL SINGLESPEED", state->dataDXCoils->DXCoil(1).Name); // Heating Coil Single Speed @@ -3170,8 +3171,8 @@ TEST_F(EnergyPlusFixture, CoilCoolingDXTwoSpeed_MinOADBTempCompOperLimit) }); ASSERT_TRUE(process_idf(idf_objects)); - - ProcessScheduleInput(*state); + state->init_state(*state); + GetDXCoils(*state); ASSERT_EQ("MAIN COOLING COIL 1", state->dataDXCoils->DXCoil(1).Name); // Cooling Coil Two Speed @@ -3294,8 +3295,8 @@ TEST_F(SQLiteFixture, DXCoils_TestComponentSizingOutput_TwoSpeed) }); ASSERT_TRUE(process_idf(idf_objects)); - - ScheduleManager::ProcessScheduleInput(*state); + state->init_state(*state); + DXCoils::GetDXCoils(*state); EXPECT_EQ(1, state->dataDXCoils->NumDXCoils); @@ -3325,7 +3326,6 @@ TEST_F(SQLiteFixture, DXCoils_TestComponentSizingOutput_TwoSpeed) state->dataEnvrn->OutDryBulbTemp = 20.0; state->dataEnvrn->OutHumRat = 0.008; state->dataEnvrn->StdRhoAir = Psychrometrics::PsyRhoAirFnPbTdbW(*state, state->dataEnvrn->StdBaroPress, 20.0, 0.0); - Psychrometrics::InitializePsychRoutines(*state); // Need this to prevent crash in Sizers state->dataSize->UnitarySysEqSizing.allocate(1); @@ -3522,8 +3522,8 @@ TEST_F(SQLiteFixture, DXCoils_TestComponentSizingOutput_SingleSpeed) }); ASSERT_TRUE(process_idf(idf_objects)); - - ScheduleManager::ProcessScheduleInput(*state); + state->init_state(*state); + DXCoils::GetDXCoils(*state); EXPECT_EQ(1, state->dataDXCoils->NumDXCoils); @@ -3554,7 +3554,6 @@ TEST_F(SQLiteFixture, DXCoils_TestComponentSizingOutput_SingleSpeed) state->dataEnvrn->OutDryBulbTemp = 20.0; state->dataEnvrn->OutHumRat = 0.008; state->dataEnvrn->StdRhoAir = Psychrometrics::PsyRhoAirFnPbTdbW(*state, state->dataEnvrn->StdBaroPress, 20.0, 0.0); - Psychrometrics::InitializePsychRoutines(*state); // Need this to prevent crash in Sizers state->dataSize->UnitarySysEqSizing.allocate(1); @@ -4014,7 +4013,8 @@ TEST_F(EnergyPlusFixture, TestMultiSpeedHeatingCoilSizingOutput) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + // get input GetDXCoils(*state); SetPredefinedTables(*state); @@ -4232,7 +4232,8 @@ TEST_F(EnergyPlusFixture, TestMultiSpeedCoolingCoilTabularReporting) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + // get input GetDXCoils(*state); // Setup the predefined tables @@ -4652,7 +4653,8 @@ TEST_F(EnergyPlusFixture, TestMultiSpeedCoilsAutoSizingOutput) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + // get input GetDXCoils(*state); SetPredefinedTables(*state); @@ -4662,7 +4664,6 @@ TEST_F(EnergyPlusFixture, TestMultiSpeedCoilsAutoSizingOutput) state->dataEnvrn->StdBaroPress = 101325.0; state->dataEnvrn->StdRhoAir = 1.2; - Psychrometrics::InitializePsychRoutines(*state); // set system sizing parameters state->dataSize->CurZoneEqNum = 0; @@ -4939,7 +4940,8 @@ TEST_F(EnergyPlusFixture, TestMultiSpeedCoolingCoilPartialAutoSizeOutput) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + // get input GetDXCoils(*state); SetPredefinedTables(*state); @@ -4949,7 +4951,6 @@ TEST_F(EnergyPlusFixture, TestMultiSpeedCoolingCoilPartialAutoSizeOutput) state->dataEnvrn->StdBaroPress = 101325.0; state->dataEnvrn->StdRhoAir = 1.2; - Psychrometrics::InitializePsychRoutines(*state); // set system sizing parameters state->dataSize->CurZoneEqNum = 0; @@ -5142,6 +5143,8 @@ TEST_F(EnergyPlusFixture, DXCoils_RatedInletAirWTest) TEST_F(EnergyPlusFixture, SingleSpeedDXCoolingCoilOutputTest) { + state->init_state(*state); + int DXCoilNum(1); state->dataDXCoils->NumDXCoils = 1; state->dataDXCoils->DXCoil.allocate(state->dataDXCoils->NumDXCoils); @@ -5164,7 +5167,7 @@ TEST_F(EnergyPlusFixture, SingleSpeedDXCoolingCoilOutputTest) auto &AirOutletNode = state->dataLoopNodes->Node(2); // set coil parameters Coil.DXCoilType_Num = HVAC::CoilDX_CoolingSingleSpeed; - Coil.SchedPtr = ScheduleManager::ScheduleAlwaysOn; + Coil.availSched = Sched::GetScheduleAlwaysOn(*state); Coil.RatedTotCap(1) = 17580.0; Coil.RatedCOP(1) = 3.0; Coil.RatedEIR(1) = 1.0 / Coil.RatedCOP(1); @@ -5226,7 +5229,6 @@ TEST_F(EnergyPlusFixture, SingleSpeedDXCoolingCoilOutputTest) state->dataEnvrn->WindDir = 0.0; state->dataEnvrn->StdBaroPress = DataEnvironment::StdPressureSeaLevel; state->dataEnvrn->StdRhoAir = Psychrometrics::PsyRhoAirFnPbTdbW(*state, state->dataEnvrn->StdBaroPress, 20.0, 0.0); - Psychrometrics::InitializePsychRoutines(*state); // run coil at full capacity Real64 PartLoadRatio(1.0); @@ -5296,7 +5298,8 @@ TEST_F(EnergyPlusFixture, SingleSpeedDXCoolingCoilOutputTest) TEST_F(EnergyPlusFixture, MultiSpeedDXCoolingCoilOutputTest) { - + state->init_state(*state); + int DXCoilNum(1); state->dataDXCoils->NumDXCoils = 1; state->dataHVACGlobal->MSHPMassFlowRateLow = 0.6; @@ -5318,7 +5321,7 @@ TEST_F(EnergyPlusFixture, MultiSpeedDXCoolingCoilOutputTest) Coil.DXCoilType_Num = HVAC::CoilDX_MultiSpeedCooling; Coil.DXCoilType = "Coil:Cooling:DX:MultiSpeed"; - Coil.SchedPtr = ScheduleManager::ScheduleAlwaysOn; + Coil.availSched = Sched::GetScheduleAlwaysOn(*state); Coil.NumOfSpeeds = 2; createSpeedsWithDefaults(Coil); @@ -5397,7 +5400,7 @@ TEST_F(EnergyPlusFixture, MultiSpeedDXCoolingCoilOutputTest) state->dataEnvrn->WindDir = 0.0; state->dataEnvrn->StdBaroPress = DataEnvironment::StdPressureSeaLevel; state->dataEnvrn->StdRhoAir = Psychrometrics::PsyRhoAirFnPbTdbW(*state, state->dataEnvrn->StdBaroPress, 20.0, 0.0); - Psychrometrics::InitializePsychRoutines(*state); + int SpeedNum = 2; HVAC::FanOp fanOp = HVAC::FanOp::Cycling; HVAC::CompressorOp compressorOp = HVAC::CompressorOp::On; @@ -5590,9 +5593,10 @@ TEST_F(EnergyPlusFixture, TwoSpeedDXCoilStandardRatingsTest) ASSERT_TRUE(process_idf(idf_objects)); - state->dataGlobal->NumOfTimeStepInHour = 1; - state->dataGlobal->MinutesPerTimeStep = 60; - ScheduleManager::ProcessScheduleInput(*state); + state->dataGlobal->TimeStepsInHour = 1; + state->dataGlobal->MinutesInTimeStep = 60; + state->init_state(*state); + state->dataEnvrn->StdRhoAir = 1.0; state->dataEnvrn->OutBaroPress = 101325.0; GetCurveInput(*state); @@ -5834,9 +5838,10 @@ TEST_F(EnergyPlusFixture, TwoSpeedDXCoilStandardRatings_Curve_Fix_Test) ASSERT_TRUE(process_idf(idf_objects)); - state->dataGlobal->NumOfTimeStepInHour = 1; - state->dataGlobal->MinutesPerTimeStep = 60; - ScheduleManager::ProcessScheduleInput(*state); + state->dataGlobal->TimeStepsInHour = 1; + state->dataGlobal->MinutesInTimeStep = 60; + state->init_state(*state); + state->dataEnvrn->StdRhoAir = 1.0; state->dataEnvrn->OutBaroPress = 101325.0; GetCurveInput(*state); @@ -6066,11 +6071,13 @@ TEST_F(EnergyPlusFixture, MSCoolingCoil_TestErrorMessageWithoutPLRobjects) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + ASSERT_THROW(GetDXCoils(*state), std::runtime_error); std::string const error_string = delimited_string({ - " ** Warning ** ProcessScheduleInput: Schedule:Compact=\"FANANDCOILAVAILSCHED\", Schedule Type Limits Name=\"FRACTION\" not found -- will " - "not be validated", + " ** Warning ** ProcessScheduleInput: Schedule:Compact = FANANDCOILAVAILSCHED", + " ** ~~~ ** Schedule Type Limits Name = FRACTION, item not found.", + " ** ~~~ ** Schedule will not be validated.", " ** Severe ** GetDXCoils: Coil:Cooling:DX:MultiSpeed=\"HEAT PUMP ACDXCOIL 1\", invalid", " ** ~~~ ** ...not found Speed 1 Part Load Fraction Correlation Curve Name=\"HPACCOOLPLFFPLR SPEED\".", " ** Severe ** GetDXCoils: Coil:Cooling:DX:MultiSpeed=\"HEAT PUMP ACDXCOIL 1\", invalid", @@ -6940,8 +6947,8 @@ TEST_F(EnergyPlusFixture, Test_DHW_End_Use_Cat_Removal) }); ASSERT_TRUE(process_idf(idf_objects)); - - ProcessScheduleInput(*state); + state->init_state(*state); + GetCurveInput(*state); GetDXCoils(*state); VariableSpeedCoils::GetVarSpeedCoilInput(*state); diff --git a/tst/EnergyPlus/unit/DataHeatBalance.unit.cc b/tst/EnergyPlus/unit/DataHeatBalance.unit.cc index b8b0ecaf334..ac27932d508 100644 --- a/tst/EnergyPlus/unit/DataHeatBalance.unit.cc +++ b/tst/EnergyPlus/unit/DataHeatBalance.unit.cc @@ -77,7 +77,6 @@ using namespace EnergyPlus::DataSurfaces; using namespace EnergyPlus::EMSManager; using namespace EnergyPlus::HeatBalanceManager; using namespace EnergyPlus::OutputProcessor; -using namespace EnergyPlus::ScheduleManager; using namespace EnergyPlus::SimulationManager; using namespace EnergyPlus::SurfaceGeometry; @@ -85,7 +84,6 @@ using namespace EnergyPlus::SurfaceGeometry; TEST_F(EnergyPlusFixture, DataHeatBalance_CheckConstructLayers) { - bool ErrorsFound(false); std::string const idf_objects = delimited_string({ @@ -805,12 +803,7 @@ TEST_F(EnergyPlusFixture, DataHeatBalance_CheckConstructLayers) ASSERT_TRUE(process_idf(idf_objects)); // OutputProcessor::TimeValue.allocate(2); - - ScheduleManager::ProcessScheduleInput(*state); // read schedules - - ErrorsFound = false; - GetProjectControlData(*state, ErrorsFound); // read project control data - EXPECT_FALSE(ErrorsFound); // expect no errors + state->init_state(*state); ErrorsFound = false; Material::GetMaterialData(*state, ErrorsFound); // read material data @@ -902,7 +895,8 @@ TEST_F(EnergyPlusFixture, DataHeatBalance_CheckConstructLayers) TEST_F(EnergyPlusFixture, DataHeatBalance_setUserTemperatureLocationPerpendicular) { - + state->init_state(*state); + Real64 userInputValue; Real64 expectedReturnValue; Real64 actualReturnValue; @@ -932,6 +926,7 @@ TEST_F(EnergyPlusFixture, DataHeatBalance_setUserTemperatureLocationPerpendicula TEST_F(EnergyPlusFixture, DataHeatBalance_setNodeSourceAndUserTemp) { + state->init_state(*state); int expectedNodeNumberAtSource; int expectedNodeNumberAtUserSpecifiedLocation; state->dataConstruction->Construct.allocate(1); @@ -992,6 +987,7 @@ TEST_F(EnergyPlusFixture, DataHeatBalance_setNodeSourceAndUserTemp) TEST_F(EnergyPlusFixture, DataHeatBalance_AssignReverseConstructionNumberTest) { + state->init_state(*state); int ConstrNum; int expectedResultRevConstrNum; int functionResultRevConstrNum; @@ -1039,7 +1035,7 @@ TEST_F(EnergyPlusFixture, DataHeatBalance_AssignReverseConstructionNumberTest) TEST_F(EnergyPlusFixture, DataHeatBalance_setThicknessPerpendicularTest) { - + state->init_state(*state); Real64 userInputValue; Real64 expectedReturnValue; Real64 actualReturnValue; @@ -1048,6 +1044,12 @@ TEST_F(EnergyPlusFixture, DataHeatBalance_setThicknessPerpendicularTest) auto &thisConstruct(state->dataConstruction->Construct(1)); thisConstruct.Name = "TestThisConstruction"; + std::string const error_string0 = + delimited_string({" ** Warning ** Version: missing in IDF, processing for EnergyPlus version=\"24.2\"", + " ** Warning ** ConstructionProperty:InternalHeatSource has a tube spacing that is less than 2 mm. This is not allowed.", + " ** ~~~ ** Construction=TestThisConstruction has this problem. The tube spacing has been reset to 0.15m (~6 " + "inches) for this construction.", + " ** ~~~ ** As per the Input Output Reference, tube spacing is only used for 2-D solutions and autosizing."}); std::string const error_string1 = delimited_string({" ** Warning ** ConstructionProperty:InternalHeatSource has a tube spacing that is less than 2 mm. This is not allowed.", " ** ~~~ ** Construction=TestThisConstruction has this problem. The tube spacing has been reset to 0.15m (~6 " @@ -1067,7 +1069,7 @@ TEST_F(EnergyPlusFixture, DataHeatBalance_setThicknessPerpendicularTest) expectedReturnValue = 0.075; actualReturnValue = thisConstruct.setThicknessPerpendicular(*state, userInputValue); EXPECT_NEAR(expectedReturnValue, actualReturnValue, 0.0001); - EXPECT_TRUE(compare_err_stream(error_string1, true)); + EXPECT_TRUE(compare_err_stream(error_string0, true)); // Test 2: User value is greater than zero but still too small--should be reset to the "default" value (warning messages produced) userInputValue = 0.0001; @@ -1098,6 +1100,7 @@ TEST_F(EnergyPlusFixture, DataHeatBalance_setThicknessPerpendicularTest) TEST_F(EnergyPlusFixture, DataHeatBalance_ComputeNominalUwithConvCoeffsTest) { + state->init_state(*state); Real64 expectedAnswer; Real64 actualAnswer; Real64 allowableTolerance = 0.00001; diff --git a/tst/EnergyPlus/unit/DataSizing.unit.cc b/tst/EnergyPlus/unit/DataSizing.unit.cc index f6d36b4073d..23b90bc5421 100644 --- a/tst/EnergyPlus/unit/DataSizing.unit.cc +++ b/tst/EnergyPlus/unit/DataSizing.unit.cc @@ -344,9 +344,16 @@ TEST_F(EnergyPlusFixture, OARequirements_calcDesignSpecificationOutdoorAir) state->dataGlobal->isEpJSON = true; state->dataInputProcessing->inputProcessor->initializeMaps(); + state->init_state(*state); + bool ErrorsFound = false; HeatBalanceManager::GetZoneData(*state, ErrorsFound); - compare_err_stream(""); + + std::string const error_string = delimited_string({ + " ** Warning ** Version: missing in IDF, processing for EnergyPlus version=\"24.2\"", + " ** Warning ** No Timestep object found. Number of TimeSteps in Hour defaulted to 4."}); + + EXPECT_TRUE(compare_err_stream(error_string, true)); EXPECT_FALSE(ErrorsFound); int zoneNum = 1; @@ -424,6 +431,7 @@ TEST_F(EnergyPlusFixture, OARequirements_calcDesignSpecificationOutdoorAir) TEST_F(EnergyPlusFixture, GetCoilDesFlowT_Test) { + state->init_state(*state); state->dataEnvrn->StdRhoAir = 1.1; state->dataSize->SysSizInput.allocate(1); state->dataSize->FinalSysSizing.allocate(1); diff --git a/tst/EnergyPlus/unit/DataSurfaces.unit.cc b/tst/EnergyPlus/unit/DataSurfaces.unit.cc index 47f73136b74..33fb90fd24b 100644 --- a/tst/EnergyPlus/unit/DataSurfaces.unit.cc +++ b/tst/EnergyPlus/unit/DataSurfaces.unit.cc @@ -178,8 +178,8 @@ TEST_F(EnergyPlusFixture, DataSurfaces_SetSurfaceOutBulbTempAtTest) state->dataSurfaceGeometry->CosZoneRelNorth.allocate(1); state->dataSurfaceGeometry->SinZoneRelNorth.allocate(1); - state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); - state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); + state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); + state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); state->dataSurfaceGeometry->CosBldgRelNorth = 1.0; state->dataSurfaceGeometry->SinBldgRelNorth = 0.0; @@ -402,45 +402,45 @@ TEST_F(EnergyPlusFixture, SurfaceTest_AverageHeightRectangle) s.Vertex = {Vector(0, 0, 0), Vector(1, 0, 0), Vector(1, 1, 0), Vector(0, 1, 0)}; Vectors::CreateNewellSurfaceNormalVector(s.Vertex, s.Vertex.size(), s.NewellSurfaceNormalVector); Vectors::DetermineAzimuthAndTilt(s.Vertex, s.Azimuth, s.Tilt, s.lcsx, s.lcsy, s.lcsz, s.NewellSurfaceNormalVector); - s.SinAzim = std::sin(s.Azimuth * Constant::DegToRadians); - s.CosAzim = std::cos(s.Azimuth * Constant::DegToRadians); - s.SinTilt = std::sin(s.Tilt * Constant::DegToRadians); + s.SinAzim = std::sin(s.Azimuth * Constant::DegToRad); + s.CosAzim = std::cos(s.Azimuth * Constant::DegToRad); + s.SinTilt = std::sin(s.Tilt * Constant::DegToRad); EXPECT_DOUBLE_EQ(s.get_average_height(*state), 0.0); s.Vertex = {Vector(0, 0, 0), Vector(1, 1, 0), Vector(1, 1, 1), Vector(0, 0, 1)}; Vectors::CreateNewellSurfaceNormalVector(s.Vertex, s.Vertex.size(), s.NewellSurfaceNormalVector); Vectors::DetermineAzimuthAndTilt(s.Vertex, s.Azimuth, s.Tilt, s.lcsx, s.lcsy, s.lcsz, s.NewellSurfaceNormalVector); - s.SinAzim = std::sin(s.Azimuth * Constant::DegToRadians); - s.CosAzim = std::cos(s.Azimuth * Constant::DegToRadians); - s.SinTilt = std::sin(s.Tilt * Constant::DegToRadians); + s.SinAzim = std::sin(s.Azimuth * Constant::DegToRad); + s.CosAzim = std::cos(s.Azimuth * Constant::DegToRad); + s.SinTilt = std::sin(s.Tilt * Constant::DegToRad); EXPECT_DOUBLE_EQ(s.get_average_height(*state), 1.0); s.Vertex = {Vector(0, 0, 0), Vector(1, 0, 0), Vector(1, 1, 1), Vector(0, 1, 1)}; Vectors::CreateNewellSurfaceNormalVector(s.Vertex, s.Vertex.size(), s.NewellSurfaceNormalVector); Vectors::DetermineAzimuthAndTilt(s.Vertex, s.Azimuth, s.Tilt, s.lcsx, s.lcsy, s.lcsz, s.NewellSurfaceNormalVector); - s.SinAzim = std::sin(s.Azimuth * Constant::DegToRadians); - s.CosAzim = std::cos(s.Azimuth * Constant::DegToRadians); - s.SinTilt = std::sin(s.Tilt * Constant::DegToRadians); + s.SinAzim = std::sin(s.Azimuth * Constant::DegToRad); + s.CosAzim = std::cos(s.Azimuth * Constant::DegToRad); + s.SinTilt = std::sin(s.Tilt * Constant::DegToRad); EXPECT_DOUBLE_EQ(s.get_average_height(*state), 1.0 / s.SinTilt); s.Vertex = {Vector(0, 0, 0), Vector(0, 1, 0), Vector(0, 1, 1), Vector(0, 0, 1)}; Vectors::CreateNewellSurfaceNormalVector(s.Vertex, s.Vertex.size(), s.NewellSurfaceNormalVector); Vectors::DetermineAzimuthAndTilt(s.Vertex, s.Azimuth, s.Tilt, s.lcsx, s.lcsy, s.lcsz, s.NewellSurfaceNormalVector); - s.SinAzim = std::sin(s.Azimuth * Constant::DegToRadians); - s.CosAzim = std::cos(s.Azimuth * Constant::DegToRadians); - s.SinTilt = std::sin(s.Tilt * Constant::DegToRadians); + s.SinAzim = std::sin(s.Azimuth * Constant::DegToRad); + s.CosAzim = std::cos(s.Azimuth * Constant::DegToRad); + s.SinTilt = std::sin(s.Tilt * Constant::DegToRad); EXPECT_DOUBLE_EQ(s.get_average_height(*state), 1.0); s.Vertex = {Vector(1, -1, 0), Vector(1, -1, -1), Vector(0, 0, -1), Vector(0, 0, 0)}; Vectors::CreateNewellSurfaceNormalVector(s.Vertex, s.Vertex.size(), s.NewellSurfaceNormalVector); Vectors::DetermineAzimuthAndTilt(s.Vertex, s.Azimuth, s.Tilt, s.lcsx, s.lcsy, s.lcsz, s.NewellSurfaceNormalVector); - s.SinAzim = std::sin(s.Azimuth * Constant::DegToRadians); - s.CosAzim = std::cos(s.Azimuth * Constant::DegToRadians); - s.SinTilt = std::sin(s.Tilt * Constant::DegToRadians); + s.SinAzim = std::sin(s.Azimuth * Constant::DegToRad); + s.CosAzim = std::cos(s.Azimuth * Constant::DegToRad); + s.SinTilt = std::sin(s.Tilt * Constant::DegToRad); EXPECT_DOUBLE_EQ(s.get_average_height(*state), 1.0); } @@ -456,18 +456,18 @@ TEST_F(EnergyPlusFixture, SurfaceTest_AverageHeightTriangle) s.Vertex = {Vector(0, 0, 0), Vector(1, 0, 0), Vector(1, 0, 1)}; Vectors::CreateNewellSurfaceNormalVector(s.Vertex, s.Vertex.size(), s.NewellSurfaceNormalVector); Vectors::DetermineAzimuthAndTilt(s.Vertex, s.Azimuth, s.Tilt, s.lcsx, s.lcsy, s.lcsz, s.NewellSurfaceNormalVector); - s.SinAzim = std::sin(s.Azimuth * Constant::DegToRadians); - s.CosAzim = std::cos(s.Azimuth * Constant::DegToRadians); - s.SinTilt = std::sin(s.Tilt * Constant::DegToRadians); + s.SinAzim = std::sin(s.Azimuth * Constant::DegToRad); + s.CosAzim = std::cos(s.Azimuth * Constant::DegToRad); + s.SinTilt = std::sin(s.Tilt * Constant::DegToRad); EXPECT_DOUBLE_EQ(s.get_average_height(*state), 0.5); s.Vertex = {Vector(0, 0, 0), Vector(0, 0, 1), Vector(1, 0, 0)}; Vectors::CreateNewellSurfaceNormalVector(s.Vertex, s.Vertex.size(), s.NewellSurfaceNormalVector); Vectors::DetermineAzimuthAndTilt(s.Vertex, s.Azimuth, s.Tilt, s.lcsx, s.lcsy, s.lcsz, s.NewellSurfaceNormalVector); - s.SinAzim = std::sin(s.Azimuth * Constant::DegToRadians); - s.CosAzim = std::cos(s.Azimuth * Constant::DegToRadians); - s.SinTilt = std::sin(s.Tilt * Constant::DegToRadians); + s.SinAzim = std::sin(s.Azimuth * Constant::DegToRad); + s.CosAzim = std::cos(s.Azimuth * Constant::DegToRad); + s.SinTilt = std::sin(s.Tilt * Constant::DegToRad); EXPECT_DOUBLE_EQ(s.get_average_height(*state), 0.5); } @@ -483,18 +483,18 @@ TEST_F(EnergyPlusFixture, SurfaceTest_AverageHeightL) s.Vertex = {Vector(0, 0, 0), Vector(0, 0, 1), Vector(0.5, 0, 1), Vector(0.5, 0, 0.5), Vector(1, 0, 0.5), Vector(1, 0, 0)}; Vectors::CreateNewellSurfaceNormalVector(s.Vertex, s.Vertex.size(), s.NewellSurfaceNormalVector); Vectors::DetermineAzimuthAndTilt(s.Vertex, s.Azimuth, s.Tilt, s.lcsx, s.lcsy, s.lcsz, s.NewellSurfaceNormalVector); - s.SinAzim = std::sin(s.Azimuth * Constant::DegToRadians); - s.CosAzim = std::cos(s.Azimuth * Constant::DegToRadians); - s.SinTilt = std::sin(s.Tilt * Constant::DegToRadians); + s.SinAzim = std::sin(s.Azimuth * Constant::DegToRad); + s.CosAzim = std::cos(s.Azimuth * Constant::DegToRad); + s.SinTilt = std::sin(s.Tilt * Constant::DegToRad); EXPECT_DOUBLE_EQ(s.get_average_height(*state), 0.75); s.Vertex = {Vector(0, 0, 0), Vector(0, 0, 1), Vector(1, 0, 1), Vector(1, 0, 0.5), Vector(0.5, 0, 0.5), Vector(0.5, 0, 0)}; Vectors::CreateNewellSurfaceNormalVector(s.Vertex, s.Vertex.size(), s.NewellSurfaceNormalVector); Vectors::DetermineAzimuthAndTilt(s.Vertex, s.Azimuth, s.Tilt, s.lcsx, s.lcsy, s.lcsz, s.NewellSurfaceNormalVector); - s.SinAzim = std::sin(s.Azimuth * Constant::DegToRadians); - s.CosAzim = std::cos(s.Azimuth * Constant::DegToRadians); - s.SinTilt = std::sin(s.Tilt * Constant::DegToRadians); + s.SinAzim = std::sin(s.Azimuth * Constant::DegToRad); + s.CosAzim = std::cos(s.Azimuth * Constant::DegToRad); + s.SinTilt = std::sin(s.Tilt * Constant::DegToRad); EXPECT_DOUBLE_EQ(s.get_average_height(*state), 0.75); } @@ -512,8 +512,8 @@ TEST_F(EnergyPlusFixture, SurfaceTest_HashMap) state->dataSurface->SurfWinStormWinConstr.dimension(numSurfs, 0); state->dataSurface->SurfMaterialMovInsulExt.dimension(numSurfs, 0); state->dataSurface->SurfMaterialMovInsulInt.dimension(numSurfs, 0); - state->dataSurface->SurfSchedMovInsulExt.dimension(numSurfs, 0); - state->dataSurface->SurfSchedMovInsulInt.dimension(numSurfs, 0); + state->dataSurface->SurfMovInsulExtScheds.dimension(numSurfs, nullptr); + state->dataSurface->SurfMovInsulIntScheds.dimension(numSurfs, nullptr); for (int SurfNum = 1; SurfNum <= numSurfs; SurfNum++) { state->dataSurface->Surface(SurfNum).set_representative_surface(*state, SurfNum); @@ -571,9 +571,9 @@ TEST_F(EnergyPlusFixture, SurfaceTest_Azimuth_non_conv) EXPECT_DOUBLE_EQ(s.Azimuth, 180.0); // Orignal code without PR 9907 fix would fail this one by getting an s.Azimuth of 0.0 EXPECT_DOUBLE_EQ(s.Tilt, 90.0); - s.SinAzim = std::sin(s.Azimuth * Constant::DegToRadians); - s.CosAzim = std::cos(s.Azimuth * Constant::DegToRadians); - s.SinTilt = std::sin(s.Tilt * Constant::DegToRadians); + s.SinAzim = std::sin(s.Azimuth * Constant::DegToRad); + s.CosAzim = std::cos(s.Azimuth * Constant::DegToRad); + s.SinTilt = std::sin(s.Tilt * Constant::DegToRad); EXPECT_NEAR(s.SinAzim, 0.0, 1e-15); EXPECT_DOUBLE_EQ(s.CosAzim, -1.0); @@ -594,9 +594,9 @@ TEST_F(EnergyPlusFixture, SurfaceTest_Azimuth_non_conv) EXPECT_DOUBLE_EQ(s.Azimuth, 180.0); EXPECT_DOUBLE_EQ(s.Tilt, 90.0); - s.SinAzim = std::sin(s.Azimuth * Constant::DegToRadians); - s.CosAzim = std::cos(s.Azimuth * Constant::DegToRadians); - s.SinTilt = std::sin(s.Tilt * Constant::DegToRadians); + s.SinAzim = std::sin(s.Azimuth * Constant::DegToRad); + s.CosAzim = std::cos(s.Azimuth * Constant::DegToRad); + s.SinTilt = std::sin(s.Tilt * Constant::DegToRad); EXPECT_NEAR(s.SinAzim, 0.0, 1e-15); EXPECT_DOUBLE_EQ(s.CosAzim, -1.0); diff --git a/tst/EnergyPlus/unit/DataZoneEquipment.unit.cc b/tst/EnergyPlus/unit/DataZoneEquipment.unit.cc index 2672e3fe368..f7a849487b3 100644 --- a/tst/EnergyPlus/unit/DataZoneEquipment.unit.cc +++ b/tst/EnergyPlus/unit/DataZoneEquipment.unit.cc @@ -71,7 +71,7 @@ using namespace EnergyPlus::DataZoneEquipment; TEST_F(EnergyPlusFixture, DataZoneEquipment_TestGetSystemNodeNumberForZone) { - + state->init_state(*state); state->dataGlobal->NumOfZones = 2; state->dataZoneEquip->ZoneEquipConfig.allocate(state->dataGlobal->NumOfZones); @@ -94,12 +94,11 @@ TEST_F(EnergyPlusFixture, DataZoneEquipment_TestGetSystemNodeNumberForZone) TEST_F(EnergyPlusFixture, DataZoneEquipment_TestCalcDesignSpecificationOutdoorAir) { // #6225 - + state->init_state(*state); state->dataHeatBal->Zone.allocate(1); state->dataSize->OARequirements.allocate(1); state->dataHeatBal->ZoneIntGain.allocate(1); state->dataHeatBal->People.allocate(1); - state->dataScheduleMgr->Schedule.allocate(2); state->dataContaminantBalance->ZoneCO2GainFromPeople.allocate(1); state->dataContaminantBalance->ZoneAirCO2.allocate(1); state->dataContaminantBalance->ZoneSysContDemand.allocate(1); @@ -108,10 +107,10 @@ TEST_F(EnergyPlusFixture, DataZoneEquipment_TestCalcDesignSpecificationOutdoorAi state->dataHeatBal->Zone(1).FloorArea = 10.0; state->dataHeatBal->Zone(1).TotOccupants = 5.0; - state->dataHeatBal->Zone(1).ZoneContamControllerSchedIndex = 1; + state->dataHeatBal->Zone(1).zoneContamControllerSched = Sched::AddScheduleConstant(*state, "ZONE CONTAM CONTROLLER"); state->dataHeatBal->People(1).ZonePtr = 1; state->dataHeatBal->TotPeople = 1; - state->dataHeatBal->People(1).ActivityLevelPtr = 2; + state->dataHeatBal->People(1).activityLevelSched = Sched::AddScheduleConstant(*state, "ACTIVITY LEVEL SCHED"); state->dataHeatBal->People(1).CO2RateFactor = 3.82e-8; state->dataHeatBal->People(1).NumberOfPeople = state->dataHeatBal->Zone(1).TotOccupants; @@ -125,8 +124,8 @@ TEST_F(EnergyPlusFixture, DataZoneEquipment_TestCalcDesignSpecificationOutdoorAi state->dataSize->OARequirements(1).OAFlowPerPerson = 0.002; state->dataSize->OARequirements(1).OAFlowPerArea = 0.003; state->dataHeatBal->ZoneIntGain(1).NOFOCC = 0.5; - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; - state->dataScheduleMgr->Schedule(2).CurrentValue = 131.881995; + state->dataHeatBal->Zone(1).zoneContamControllerSched->currentVal = 1.0; + state->dataHeatBal->People(1).activityLevelSched->currentVal = 131.881995; Real64 OAVolumeFlowRate; // Test ZOAM_ProportionalControlSchOcc @@ -154,7 +153,6 @@ TEST_F(EnergyPlusFixture, DataZoneEquipment_TestCalcDesignSpecificationOutdoorAi state->dataHeatBal->Zone.deallocate(); state->dataSize->OARequirements.deallocate(); state->dataHeatBal->ZoneIntGain.deallocate(); - state->dataScheduleMgr->Schedule.deallocate(); state->dataHeatBal->People.deallocate(); state->dataContaminantBalance->ZoneCO2GainFromPeople.deallocate(); state->dataContaminantBalance->ZoneAirCO2.deallocate(); @@ -386,9 +384,9 @@ TEST_F(EnergyPlusFixture, GetZoneEquipmentData_epJSON) state->dataIPShortCut->rNumericArgs.dimension(MaxNumeric, 0.0); state->dataIPShortCut->lNumericFieldBlanks.dimension(MaxNumeric, false); - state->dataGlobal->NumOfTimeStepInHour = 1; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 60; // must initialize this to get schedules initialized - ScheduleManager::ProcessScheduleInput(*state); // read schedules + state->dataGlobal->TimeStepsInHour = 1; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 60; // must initialize this to get schedules initialized + state->init_state(*state); bool ErrorsFound = false; HeatBalanceManager::GetZoneData(*state, ErrorsFound); @@ -407,22 +405,22 @@ TEST_F(EnergyPlusFixture, GetZoneEquipmentData_epJSON) EXPECT_ENUM_EQ(DataZoneEquipment::ZoneEquipType::ExhaustFan, thisZoneEquipList.EquipType(1)); EXPECT_EQ(1, thisZoneEquipList.CoolingPriority(1)); EXPECT_EQ(1, thisZoneEquipList.HeatingPriority(1)); - EXPECT_EQ(-1, thisZoneEquipList.SequentialCoolingFractionSchedPtr(1)); - EXPECT_EQ(-1, thisZoneEquipList.SequentialHeatingFractionSchedPtr(1)); + EXPECT_EQ(Sched::GetScheduleAlwaysOn(*state), thisZoneEquipList.sequentialCoolingFractionScheds(1)); + EXPECT_EQ(Sched::GetScheduleAlwaysOn(*state), thisZoneEquipList.sequentialHeatingFractionScheds(1)); EXPECT_EQ("ADU AIR TERMINAL SINGLE DUCT CONSTANT VOLUME NO REHEAT 1", thisZoneEquipList.EquipName(2)); EXPECT_EQ("ZONEHVAC:AIRDISTRIBUTIONUNIT", thisZoneEquipList.EquipTypeName(2)); EXPECT_ENUM_EQ(DataZoneEquipment::ZoneEquipType::AirDistributionUnit, thisZoneEquipList.EquipType(2)); EXPECT_EQ(3, thisZoneEquipList.CoolingPriority(2)); EXPECT_EQ(2, thisZoneEquipList.HeatingPriority(2)); - EXPECT_EQ(-1, thisZoneEquipList.SequentialCoolingFractionSchedPtr(2)); - EXPECT_EQ(-1, thisZoneEquipList.SequentialHeatingFractionSchedPtr(2)); + EXPECT_EQ(Sched::GetScheduleAlwaysOn(*state), thisZoneEquipList.sequentialCoolingFractionScheds(2)); + EXPECT_EQ(Sched::GetScheduleAlwaysOn(*state), thisZoneEquipList.sequentialHeatingFractionScheds(2)); EXPECT_EQ("ADU AIR TERMINAL SINGLE DUCT VAV REHEAT 1", thisZoneEquipList.EquipName(3)); EXPECT_EQ("ZONEHVAC:AIRDISTRIBUTIONUNIT", thisZoneEquipList.EquipTypeName(3)); EXPECT_ENUM_EQ(DataZoneEquipment::ZoneEquipType::AirDistributionUnit, thisZoneEquipList.EquipType(3)); EXPECT_EQ(2, thisZoneEquipList.CoolingPriority(3)); EXPECT_EQ(3, thisZoneEquipList.HeatingPriority(3)); - EXPECT_EQ(-1, thisZoneEquipList.SequentialCoolingFractionSchedPtr(3)); - EXPECT_EQ(-1, thisZoneEquipList.SequentialHeatingFractionSchedPtr(3)); + EXPECT_EQ(Sched::GetScheduleAlwaysOn(*state), thisZoneEquipList.sequentialCoolingFractionScheds(3)); + EXPECT_EQ(Sched::GetScheduleAlwaysOn(*state), thisZoneEquipList.sequentialHeatingFractionScheds(3)); } diff --git a/tst/EnergyPlus/unit/DaylightingManager.unit.cc b/tst/EnergyPlus/unit/DaylightingManager.unit.cc index 913ede27f08..84a2bf253f8 100644 --- a/tst/EnergyPlus/unit/DaylightingManager.unit.cc +++ b/tst/EnergyPlus/unit/DaylightingManager.unit.cc @@ -130,7 +130,8 @@ TEST_F(EnergyPlusFixture, DaylightingManager_GetInputDaylightingControls_Test) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + auto &dl = state->dataDayltg; bool foundErrors = false; @@ -243,7 +244,8 @@ TEST_F(EnergyPlusFixture, DaylightingManager_GetInputDaylightingControls_3RefPt_ }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + auto &dl = state->dataDayltg; bool foundErrors = false; @@ -340,7 +342,8 @@ TEST_F(EnergyPlusFixture, DaylightingManager_GetInputDayliteRefPt_Test) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + auto &dl = state->dataDayltg; bool foundErrors = false; @@ -404,7 +407,8 @@ TEST_F(EnergyPlusFixture, DaylightingManager_GetInputOutputIlluminanceMap_Test) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + auto &dl = state->dataDayltg; bool foundErrors = false; @@ -437,6 +441,7 @@ TEST_F(EnergyPlusFixture, DaylightingManager_GetInputOutputIlluminanceMap_Test) TEST_F(EnergyPlusFixture, DaylightingManager_doesDayLightingUseDElight_Test) { + state->init_state(*state); EXPECT_FALSE(doesDayLightingUseDElight(*state)); auto &dl = state->dataDayltg; @@ -854,14 +859,14 @@ TEST_F(EnergyPlusFixture, DaylightingManager_GetDaylParamInGeoTrans_Test) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->dataGlobal->TimeStepsInHour = 1; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 60; // must initialize this to get schedules initialized + state->init_state(*state); + auto &dl = state->dataDayltg; bool foundErrors = false; - HeatBalanceManager::GetProjectControlData(*state, foundErrors); // read project control data - EXPECT_FALSE(foundErrors); // expect no errors - Material::GetMaterialData(*state, foundErrors); // read material data EXPECT_FALSE(foundErrors); // expect no errors @@ -876,10 +881,10 @@ TEST_F(EnergyPlusFixture, DaylightingManager_GetDaylParamInGeoTrans_Test) state->dataSurfaceGeometry->CosZoneRelNorth.allocate(2); state->dataSurfaceGeometry->SinZoneRelNorth.allocate(2); - state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); - state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); - state->dataSurfaceGeometry->CosZoneRelNorth(2) = std::cos(-state->dataHeatBal->Zone(2).RelNorth * Constant::DegToRadians); - state->dataSurfaceGeometry->SinZoneRelNorth(2) = std::sin(-state->dataHeatBal->Zone(2).RelNorth * Constant::DegToRadians); + state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); + state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); + state->dataSurfaceGeometry->CosZoneRelNorth(2) = std::cos(-state->dataHeatBal->Zone(2).RelNorth * Constant::DegToRad); + state->dataSurfaceGeometry->SinZoneRelNorth(2) = std::sin(-state->dataHeatBal->Zone(2).RelNorth * Constant::DegToRad); state->dataSurfaceGeometry->CosBldgRelNorth = 1.0; state->dataSurfaceGeometry->SinBldgRelNorth = 0.0; @@ -890,11 +895,6 @@ TEST_F(EnergyPlusFixture, DaylightingManager_GetDaylParamInGeoTrans_Test) EXPECT_FALSE(foundErrors); // expect no errors HeatBalanceIntRadExchange::InitSolarViewFactors(*state); - int constexpr HoursInDay(24); - state->dataGlobal->NumOfTimeStepInHour = 1; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 60; // must initialize this to get schedules initialized - ScheduleManager::ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; state->dataGlobal->TimeStep = 1; state->dataGlobal->HourOfDay = 1; state->dataGlobal->PreviousHour = 1; @@ -905,7 +905,7 @@ TEST_F(EnergyPlusFixture, DaylightingManager_GetDaylParamInGeoTrans_Test) state->dataEnvrn->DayOfWeek = 2; state->dataEnvrn->HolidayIndex = 0; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); InternalHeatGains::GetInternalHeatGainsInput(*state); state->dataInternalHeatGains->GetInternalHeatGainsInputFlag = false; @@ -941,8 +941,8 @@ TEST_F(EnergyPlusFixture, DaylightingManager_GetDaylParamInGeoTrans_Test) state->dataGlobal->WeightNow = 1.0; state->dataGlobal->WeightPreviousHour = 0.0; - state->dataSurface->SurfSunCosHourly.allocate(HoursInDay); - for (int hour = 1; hour <= HoursInDay; hour++) { + state->dataSurface->SurfSunCosHourly.allocate(Constant::iHoursInDay); + for (int hour = 1; hour <= Constant::iHoursInDay; hour++) { state->dataSurface->SurfSunCosHourly(hour) = 0.0; } CalcDayltgCoefficients(*state); @@ -957,6 +957,7 @@ TEST_F(EnergyPlusFixture, DaylightingManager_GetDaylParamInGeoTrans_Test) TEST_F(EnergyPlusFixture, DaylightingManager_ProfileAngle_Test) { + state->init_state(*state); state->dataSurface->Surface.allocate(1); state->dataSurface->Surface(1).Tilt = 90.0; @@ -989,6 +990,8 @@ TEST_F(EnergyPlusFixture, DaylightingManager_ProfileAngle_Test) TEST_F(EnergyPlusFixture, AssociateWindowShadingControlWithDaylighting_Test) { + state->init_state(*state); + auto &dl = state->dataDayltg; state->dataGlobal->NumOfZones = 4; @@ -1019,6 +1022,8 @@ TEST_F(EnergyPlusFixture, AssociateWindowShadingControlWithDaylighting_Test) TEST_F(EnergyPlusFixture, CreateShadeDeploymentOrder_test) { + state->init_state(*state); + auto &dl = state->dataDayltg; state->dataSurface->TotWinShadingControl = 3; state->dataSurface->WindowShadingControl.allocate(state->dataSurface->TotWinShadingControl); @@ -1098,6 +1103,7 @@ TEST_F(EnergyPlusFixture, CreateShadeDeploymentOrder_test) TEST_F(EnergyPlusFixture, MapShadeDeploymentOrderToLoopNumber_Test) { + state->init_state(*state); auto &dl = state->dataDayltg; state->dataSurface->TotWinShadingControl = 3; state->dataSurface->WindowShadingControl.allocate(state->dataSurface->TotWinShadingControl); @@ -1416,9 +1422,9 @@ TEST_F(EnergyPlusFixture, DaylightingManager_DayltgInteriorIllum_LuminanceShadin auto &dl = state->dataDayltg; - state->dataGlobal->NumOfTimeStepInHour = 1; - ScheduleManager::ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; + state->dataGlobal->TimeStepsInHour = 1; + state->init_state(*state); + state->dataGlobal->TimeStep = 1; state->dataGlobal->HourOfDay = 10; state->dataGlobal->PreviousHour = 9; @@ -1429,8 +1435,6 @@ TEST_F(EnergyPlusFixture, DaylightingManager_DayltgInteriorIllum_LuminanceShadin state->dataEnvrn->HolidayIndex = 0; bool foundErrors = false; - HeatBalanceManager::GetProjectControlData(*state, foundErrors); // read project control data - EXPECT_FALSE(foundErrors); // expect no errors Material::GetMaterialData(*state, foundErrors); // read material data EXPECT_FALSE(foundErrors); // expect no errors @@ -1456,7 +1460,7 @@ TEST_F(EnergyPlusFixture, DaylightingManager_DayltgInteriorIllum_LuminanceShadin // Set the following values to make thisDaylightControl.SourceLumFromWinAtRefPt much larger than // luminance threshold of 2000 (WindowShadingControl SetPoint2) - for (int iHr = 1; iHr <= Constant::HoursInDay; ++iHr) { + for (int iHr = 1; iHr <= Constant::iHoursInDay; ++iHr) { dl->horIllum[iHr].sky = {8.0, 8.0, 8.0, 8.0}; } state->dataGlobal->WeightNow = 0.54; @@ -1468,7 +1472,7 @@ TEST_F(EnergyPlusFixture, DaylightingManager_DayltgInteriorIllum_LuminanceShadin int numExtWins = dl->enclDaylight(1).TotalExtWindows; int numRefPts = thisDaylgtCtrl.TotalDaylRefPoints; - for (int iHr = 1; iHr <= Constant::HoursInDay; ++iHr) { + for (int iHr = 1; iHr <= Constant::iHoursInDay; ++iHr) { for (int iWin = 1; iWin <= numExtWins; ++iWin) { for (int iRefPt = 1; iRefPt <= numRefPts; ++iRefPt) { for (int iWinCover = 0; iWinCover < (int)WinCover::Num; ++iWinCover) { @@ -1495,7 +1499,7 @@ TEST_F(EnergyPlusFixture, DaylightingManager_DayltgInteriorIllum_LuminanceShadin EXPECT_TRUE(state->dataSurface->SurfWinShadingFlag(ISurf) == WinShadingType::IntShade); // Set the following values to make thisDaylightControl.SourceLumFromWinAtRefPt 0 - for (int iHr = 1; iHr <= Constant::HoursInDay; ++iHr) { + for (int iHr = 1; iHr <= Constant::iHoursInDay; ++iHr) { dl->horIllum[iHr].sky = {100.0, 100.0, 100.0, 100.0}; } state->dataGlobal->WeightNow = 1.0; @@ -1503,7 +1507,7 @@ TEST_F(EnergyPlusFixture, DaylightingManager_DayltgInteriorIllum_LuminanceShadin state->dataEnvrn->HISKF = 100.0; state->dataEnvrn->SkyClearness = 6.0; - for (int iHr = 1; iHr <= Constant::HoursInDay; ++iHr) { + for (int iHr = 1; iHr <= Constant::iHoursInDay; ++iHr) { for (int iWin = 1; iWin <= numExtWins; ++iWin) { for (int iRefPt = 1; iRefPt <= numRefPts; ++iRefPt) { for (int iWinCover = 0; iWinCover < (int)WinCover::Num; ++iWinCover) { @@ -1743,11 +1747,11 @@ TEST_F(EnergyPlusFixture, DaylightingManager_DayltgInteriorIllum_Test) ASSERT_TRUE(process_idf(idf_objects)); + state->dataGlobal->TimeStepsInHour = 1; + state->init_state(*state); + auto &dl = state->dataDayltg; - state->dataGlobal->NumOfTimeStepInHour = 1; - ScheduleManager::ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; state->dataGlobal->TimeStep = 1; state->dataGlobal->HourOfDay = 10; state->dataGlobal->PreviousHour = 10; @@ -1758,8 +1762,6 @@ TEST_F(EnergyPlusFixture, DaylightingManager_DayltgInteriorIllum_Test) state->dataEnvrn->HolidayIndex = 0; bool foundErrors = false; - HeatBalanceManager::GetProjectControlData(*state, foundErrors); // read project control data - EXPECT_FALSE(foundErrors); // expect no errors Material::GetMaterialData(*state, foundErrors); // read material data EXPECT_FALSE(foundErrors); // expect no errors @@ -1782,7 +1784,7 @@ TEST_F(EnergyPlusFixture, DaylightingManager_DayltgInteriorIllum_Test) Dayltg::GetInputDayliteRefPt(*state, foundErrors); Dayltg::GetDaylightingParametersInput(*state); - for (int iHr = 1; iHr <= Constant::HoursInDay; ++iHr) { + for (int iHr = 1; iHr <= Constant::iHoursInDay; ++iHr) { dl->horIllum[iHr].sky = {100.0, 100.0, 100.0, 100.0}; } @@ -1795,7 +1797,7 @@ TEST_F(EnergyPlusFixture, DaylightingManager_DayltgInteriorIllum_Test) int numExtWins = dl->enclDaylight(1).TotalExtWindows; int numRefPts = thisDaylgtCtrl.TotalDaylRefPoints; - for (int iHr = 1; iHr <= Constant::HoursInDay; ++iHr) { + for (int iHr = 1; iHr <= Constant::iHoursInDay; ++iHr) { for (int iWin = 1; iWin <= numExtWins; ++iWin) { for (int iRefPt = 1; iRefPt <= numRefPts; ++iRefPt) { for (int iWinCover = 0; iWinCover < (int)WinCover::Num; ++iWinCover) { @@ -1855,7 +1857,6 @@ TEST_F(EnergyPlusFixture, DaylightingManager_DayltgInteriorIllum_Test) // yet with double rounding errors it throws a severe about sum of fraction > 1.0 TEST_F(EnergyPlusFixture, DaylightingManager_GetInputDaylightingControls_RoundingError) { - std::string const idf_objects = delimited_string({ "Zone,", " West Zone, !- Name", @@ -1986,7 +1987,8 @@ TEST_F(EnergyPlusFixture, DaylightingManager_GetInputDaylightingControls_Roundin }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + auto &dl = state->dataDayltg; bool foundErrors = false; @@ -2054,7 +2056,6 @@ TEST_F(EnergyPlusFixture, DaylightingManager_GetInputDaylightingControls_Roundin TEST_F(EnergyPlusFixture, DaylightingManager_GetInputDaylightingControls_NotAroundOne) { - std::string const idf_objects = delimited_string({ "Zone,", " West Zone, !- Name", @@ -2105,7 +2106,8 @@ TEST_F(EnergyPlusFixture, DaylightingManager_GetInputDaylightingControls_NotArou }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + auto &dl = state->dataDayltg; bool foundErrors = false; @@ -2551,14 +2553,14 @@ TEST_F(EnergyPlusFixture, DaylightingManager_OutputFormats) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->dataGlobal->TimeStepsInHour = 1; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 60; // must initialize this to get schedules initialized + state->init_state(*state); + auto &dl = state->dataDayltg; bool foundErrors = false; - HeatBalanceManager::GetProjectControlData(*state, foundErrors); // read project control data - EXPECT_FALSE(foundErrors); // expect no errors - Material::GetMaterialData(*state, foundErrors); // read material data EXPECT_FALSE(foundErrors); // expect no errors @@ -2577,10 +2579,10 @@ TEST_F(EnergyPlusFixture, DaylightingManager_OutputFormats) state->dataSurfaceGeometry->CosZoneRelNorth.allocate(2); state->dataSurfaceGeometry->SinZoneRelNorth.allocate(2); - state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); - state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); - state->dataSurfaceGeometry->CosZoneRelNorth(2) = std::cos(-state->dataHeatBal->Zone(2).RelNorth * Constant::DegToRadians); - state->dataSurfaceGeometry->SinZoneRelNorth(2) = std::sin(-state->dataHeatBal->Zone(2).RelNorth * Constant::DegToRadians); + state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); + state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); + state->dataSurfaceGeometry->CosZoneRelNorth(2) = std::cos(-state->dataHeatBal->Zone(2).RelNorth * Constant::DegToRad); + state->dataSurfaceGeometry->SinZoneRelNorth(2) = std::sin(-state->dataHeatBal->Zone(2).RelNorth * Constant::DegToRad); state->dataSurfaceGeometry->CosBldgRelNorth = 1.0; state->dataSurfaceGeometry->SinBldgRelNorth = 0.0; @@ -2591,11 +2593,6 @@ TEST_F(EnergyPlusFixture, DaylightingManager_OutputFormats) EXPECT_FALSE(foundErrors); // expect no errors HeatBalanceIntRadExchange::InitSolarViewFactors(*state); - int constexpr HoursInDay(24); - state->dataGlobal->NumOfTimeStepInHour = 1; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 60; // must initialize this to get schedules initialized - ScheduleManager::ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; state->dataGlobal->TimeStep = 1; state->dataGlobal->HourOfDay = 1; state->dataGlobal->PreviousHour = 1; @@ -2607,7 +2604,7 @@ TEST_F(EnergyPlusFixture, DaylightingManager_OutputFormats) state->dataEnvrn->HolidayIndex = 0; state->dataEnvrn->CurMnDy = "01/21"; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); InternalHeatGains::GetInternalHeatGainsInput(*state); state->dataInternalHeatGains->GetInternalHeatGainsInputFlag = false; @@ -2661,8 +2658,8 @@ TEST_F(EnergyPlusFixture, DaylightingManager_OutputFormats) state->dataGlobal->BeginSimFlag = true; state->dataGlobal->WeightNow = 1.0; state->dataGlobal->WeightPreviousHour = 0.0; - state->dataSurface->SurfSunCosHourly.allocate(HoursInDay); - for (int hour = 1; hour <= HoursInDay; hour++) { + state->dataSurface->SurfSunCosHourly.allocate(Constant::iHoursInDay); + for (int hour = 1; hour <= Constant::iHoursInDay; hour++) { state->dataSurface->SurfSunCosHourly(hour) = 0.0; } CalcDayltgCoefficients(*state); @@ -3337,11 +3334,10 @@ TEST_F(EnergyPlusFixture, DaylightingManager_TDD_NoDaylightingControls) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + bool foundErrors = false; - HeatBalanceManager::GetProjectControlData(*state, foundErrors); // read project control data - EXPECT_FALSE(foundErrors); // expect no errors - Material::GetMaterialData(*state, foundErrors); // read material data EXPECT_FALSE(foundErrors); // expect no errors @@ -3355,10 +3351,10 @@ TEST_F(EnergyPlusFixture, DaylightingManager_TDD_NoDaylightingControls) state->dataSurfaceGeometry->CosZoneRelNorth.allocate(2); state->dataSurfaceGeometry->SinZoneRelNorth.allocate(2); - state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); - state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); - state->dataSurfaceGeometry->CosZoneRelNorth(2) = std::cos(-state->dataHeatBal->Zone(2).RelNorth * Constant::DegToRadians); - state->dataSurfaceGeometry->SinZoneRelNorth(2) = std::sin(-state->dataHeatBal->Zone(2).RelNorth * Constant::DegToRadians); + state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); + state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); + state->dataSurfaceGeometry->CosZoneRelNorth(2) = std::cos(-state->dataHeatBal->Zone(2).RelNorth * Constant::DegToRad); + state->dataSurfaceGeometry->SinZoneRelNorth(2) = std::sin(-state->dataHeatBal->Zone(2).RelNorth * Constant::DegToRad); state->dataSurfaceGeometry->CosBldgRelNorth = 1.0; state->dataSurfaceGeometry->SinBldgRelNorth = 0.0; int constexpr HoursInDay(24); @@ -3388,6 +3384,7 @@ TEST_F(EnergyPlusFixture, DaylightingManager_TDD_NoDaylightingControls) TEST_F(EnergyPlusFixture, DaylightingManager_ReportillumMaps) { + state->init_state(*state); auto &dl = state->dataDayltg; int MapNum = 1; @@ -3423,6 +3420,7 @@ TEST_F(EnergyPlusFixture, DaylightingManager_ReportillumMaps) EXPECT_EQ(expectedResultName, dl->illumMaps(1).Name); EXPECT_EQ(expectedResultPtsHeader, dl->illumMaps(MapNum).pointsHeader); } + TEST_F(EnergyPlusFixture, DaylightingManager_DayltgIlluminanceMap) { std::string const idf_objects = delimited_string({ @@ -3697,7 +3695,8 @@ TEST_F(EnergyPlusFixture, DaylightingManager_DayltgIlluminanceMap) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + auto &dl = state->dataDayltg; SimulationManager::ManageSimulation(*state); @@ -3725,6 +3724,7 @@ TEST_F(EnergyPlusFixture, DaylightingManager_DayltgIlluminanceMap) TEST_F(EnergyPlusFixture, DaylightingManager_SteppedControl_LowDaylightConditions) { + state->init_state(*state); // Test for #9060 auto &dl = state->dataDayltg; @@ -3747,7 +3747,7 @@ TEST_F(EnergyPlusFixture, DaylightingManager_SteppedControl_LowDaylightCondition thisDaylightControl.DaylightMethod = DaylightingMethod::SplitFlux; thisDaylightControl.LightControlType = LtgCtrlType::Stepped; thisDaylightControl.LightControlProbability = 1.0; - thisDaylightControl.AvailSchedNum = -1; // Always Available + thisDaylightControl.availSched = Sched::GetScheduleAlwaysOn(*state); // Always Available thisDaylightControl.LightControlSteps = 4; dl->DaylIllum.allocate(nRefPts); diff --git a/tst/EnergyPlus/unit/DemandResponse.unit.cc b/tst/EnergyPlus/unit/DemandResponse.unit.cc index 01142a12478..6fcf9e8f044 100644 --- a/tst/EnergyPlus/unit/DemandResponse.unit.cc +++ b/tst/EnergyPlus/unit/DemandResponse.unit.cc @@ -67,7 +67,6 @@ namespace EnergyPlus { TEST_F(EnergyPlusFixture, DemandManagerGetInput) { // Test input processing for DemandManager:Ventilation - std::string const idf_objects = delimited_string({"DemandManager:Ventilation,", " Ventilation Manager,", " ,", @@ -81,14 +80,15 @@ TEST_F(EnergyPlusFixture, DemandManagerGetInput) " OA CONTROLLER 1;"}); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + state->dataMixedAir->NumOAControllers = 1; state->dataMixedAir->OAController.allocate(state->dataMixedAir->NumOAControllers); state->dataMixedAir->OAController(1).Name = "OA CONTROLLER 1"; GetDemandManagerInput(*state); auto &DemandMgr(state->dataDemandManager->DemandMgr); - EXPECT_EQ(ScheduleManager::ScheduleAlwaysOn, DemandMgr(1).AvailSchedule); + EXPECT_EQ(Sched::SchedNum_AlwaysOn, DemandMgr(1).availSched->Num); EXPECT_ENUM_EQ(ManagerLimit::Fixed, DemandMgr(1).LimitControl); EXPECT_DOUBLE_EQ(60.0, DemandMgr(1).LimitDuration); EXPECT_DOUBLE_EQ(0.2, DemandMgr(1).FixedRate); @@ -98,7 +98,6 @@ TEST_F(EnergyPlusFixture, DemandManagerGetInput) TEST_F(EnergyPlusFixture, DemandManagerAssignmentListGetInputTest) { - std::string const idf_objects = delimited_string({ " DemandManagerAssignmentList,", " Demand Manager, !- Name", @@ -156,10 +155,10 @@ TEST_F(EnergyPlusFixture, DemandManagerAssignmentListGetInputTest) ASSERT_TRUE(process_idf(idf_objects)); - state->dataGlobal->NumOfTimeStepInHour = 1; - state->dataGlobal->MinutesPerTimeStep = 60; - ScheduleManager::ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; + state->dataGlobal->TimeStepsInHour = 1; + state->dataGlobal->MinutesInTimeStep = 60; + state->init_state(*state); + ExteriorEnergyUse::GetExteriorEnergyUseInput(*state); GetDemandManagerInput(*state); diff --git a/tst/EnergyPlus/unit/DesiccantDehumidifiers.unit.cc b/tst/EnergyPlus/unit/DesiccantDehumidifiers.unit.cc index ab90e93809e..b3bbe3f65aa 100644 --- a/tst/EnergyPlus/unit/DesiccantDehumidifiers.unit.cc +++ b/tst/EnergyPlus/unit/DesiccantDehumidifiers.unit.cc @@ -2851,7 +2851,8 @@ TEST_F(EnergyPlusFixture, DesiccantDehum_OnOASystemTest) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + // OutputProcessor::TimeValue.allocate(2); state->dataGlobal->DDOnlySimulation = true; @@ -4054,7 +4055,8 @@ TEST_F(EnergyPlusFixture, DesiccantDehum_OnPrimaryAirSystemTest) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + // OutputProcessor::TimeValue.allocate(2); state->dataGlobal->DDOnlySimulation = true; @@ -5478,7 +5480,8 @@ TEST_F(EnergyPlusFixture, DesiccantDehum_RegenAirHeaterHWCoilSizingTest) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + // OutputProcessor::TimeValue.allocate(2); state->dataGlobal->DDOnlySimulation = true; @@ -6732,7 +6735,8 @@ TEST_F(EnergyPlusFixture, DesiccantDehum_VSCoolingCoilOnPrimaryAirSystemTest) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + // OutputProcessor::TimeValue.allocate(2); state->dataGlobal->DDOnlySimulation = true; diff --git a/tst/EnergyPlus/unit/DualDuct.unit.cc b/tst/EnergyPlus/unit/DualDuct.unit.cc index 92ec5afb979..fbaaed33b05 100644 --- a/tst/EnergyPlus/unit/DualDuct.unit.cc +++ b/tst/EnergyPlus/unit/DualDuct.unit.cc @@ -89,6 +89,8 @@ TEST_F(EnergyPlusFixture, TestDualDuctOAMassFlowRateUsingStdRhoAir) int numOfdd_airterminals = 2; + state->init_state(*state); + state->dataHeatBal->Zone.allocate(1); state->dataSize->OARequirements.allocate(1); state->dataAirLoop->AirLoopControlInfo.allocate(1); @@ -288,9 +290,9 @@ TEST_F(EnergyPlusFixture, TestDualDuctOAMassFlowRateUsingStdRhoAir) // // ASSERT_FALSE( process_idf( idf_objects ) ); // -// DataGlobals::NumOfTimeStepInHour = 1; // must initialize this to get schedules initialized -// DataGlobals::MinutesPerTimeStep = 60; // must initialize this to get schedules initialized -// ScheduleManager::ProcessScheduleInput(); // read schedules +// DataGlobals::TimeStepsInHour = 1; // must initialize this to get schedules initialized +// DataGlobals::MinutesInTimeStep = 60; // must initialize this to get schedules initialized +// state->init_state(*state); // // HeatBalanceManager::GetZoneData(*state, ErrorsFound ); // ASSERT_FALSE( ErrorsFound ); @@ -347,14 +349,15 @@ TEST_F(EnergyPlusFixture, DualDuctVAVAirTerminals_GetInputs) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + ZoneAirLoopEquipmentManager::GetZoneAirLoopEquipment(*state); DualDuct::GetDualDuctInput(*state); // dual duct VAV air terminal get input test EXPECT_ENUM_EQ(state->dataDualDuct->dd_airterminal(1).DamperType, DualDuctDamper::VariableVolume); // dual duct VAV Type EXPECT_EQ(state->dataDualDuct->dd_airterminal(1).Name, "VAV DUAL DUCT AT"); // dual duct VAV Name - EXPECT_TRUE(state->dataDualDuct->dd_airterminal(1).ZoneTurndownMinAirFracSchExist); // turndown schdule exists + EXPECT_TRUE(state->dataDualDuct->dd_airterminal(1).zoneTurndownMinAirFracSched != nullptr); // turndown schdule exists EXPECT_EQ(state->dataDualDuct->dd_airterminal(1).ZoneTurndownMinAirFrac, 1.0); // turndown fraction initialized to 1.0 EXPECT_EQ(state->dataDualDuct->dd_airterminal(1).ZoneMinAirFracDes, 0.3); // design minimum flow fraction } @@ -428,10 +431,10 @@ TEST_F(EnergyPlusFixture, DualDuctVAVAirTerminals_MinFlowTurnDownTest) bool ErrorsFound = false; bool FirstHVACIteration = true; - state->dataGlobal->NumOfTimeStepInHour = 1; - state->dataGlobal->MinutesPerTimeStep = 60; - ScheduleManager::ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; + state->dataGlobal->TimeStepsInHour = 1; + state->dataGlobal->MinutesInTimeStep = 60; + state->init_state(*state); + state->dataEnvrn->Month = 1; state->dataEnvrn->DayOfMonth = 21; state->dataGlobal->HourOfDay = 1; @@ -441,10 +444,10 @@ TEST_F(EnergyPlusFixture, DualDuctVAVAirTerminals_MinFlowTurnDownTest) state->dataEnvrn->HolidayIndex = 0; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); state->dataEnvrn->StdRhoAir = Psychrometrics::PsyRhoAirFnPbTdbW(*state, 101325.0, 20.0, 0.0); - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); state->dataZoneEnergyDemand->ZoneSysEnergyDemand.allocate(1); state->dataHeatBalFanSys->TempControlType.allocate(1); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::DualSetPointWithDeadBand; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::DualHeatCool; HeatBalanceManager::GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); DataZoneEquipment::GetZoneEquipmentData(*state); @@ -456,7 +459,7 @@ TEST_F(EnergyPlusFixture, DualDuctVAVAirTerminals_MinFlowTurnDownTest) // dual duct VAV air terminal get input test EXPECT_ENUM_EQ(thisDDAirTerminal.DamperType, DualDuctDamper::VariableVolume); // dual duct VAV Type EXPECT_EQ(thisDDAirTerminal.Name, "VAV DUAL DUCT AT"); // dual duct VAV Name - EXPECT_TRUE(thisDDAirTerminal.ZoneTurndownMinAirFracSchExist); // turndown schdule exists + EXPECT_TRUE(thisDDAirTerminal.zoneTurndownMinAirFracSched != nullptr); // turndown schdule exists EXPECT_EQ(thisDDAirTerminal.ZoneTurndownMinAirFrac, 1.0); // turndown fraction initialized to 1.0 EXPECT_EQ(thisDDAirTerminal.ZoneMinAirFracDes, 0.3); // design minimum flow fraction @@ -476,7 +479,7 @@ TEST_F(EnergyPlusFixture, DualDuctVAVAirTerminals_MinFlowTurnDownTest) Psychrometrics::PsyHFnTdbW(state->dataLoopNodes->Node(HotInNode).Temp, state->dataLoopNodes->Node(HotInNode).HumRat); // test with heating load and turndown fraction schedule value set 1.0 - state->dataDualDuct->dd_airterminal(DDNum).ZoneTurndownMinAirFracSchPtr = 1; // + state->dataDualDuct->dd_airterminal(DDNum).zoneTurndownMinAirFracSched = Sched::GetSchedule(*state, "TURNDOWNMINAIRFLOWSCH1"); // state->dataLoopNodes->Node(OutNode).MassFlowRate = SysMaxMassFlowRes; state->dataLoopNodes->Node(HotInNode).MassFlowRate = SysMaxMassFlowRes; state->dataLoopNodes->Node(HotInNode).MassFlowRateMaxAvail = SysMaxMassFlowRes; @@ -501,7 +504,7 @@ TEST_F(EnergyPlusFixture, DualDuctVAVAirTerminals_MinFlowTurnDownTest) EXPECT_EQ(0.0, state->dataLoopNodes->Node(ColdInNode).MassFlowRate); // test with heating load and turndown fraction schedule value set 0.5 - state->dataDualDuct->dd_airterminal(DDNum).ZoneTurndownMinAirFracSchPtr = 2; + state->dataDualDuct->dd_airterminal(DDNum).zoneTurndownMinAirFracSched = Sched::GetSchedule(*state, "TURNDOWNMINAIRFLOWSCH2"); SysMinMassFlowRes = 1.0 * state->dataEnvrn->StdRhoAir * 0.30 * 0.5; // min flow rate at 0.5 turndown fraction state->dataLoopNodes->Node(OutNode).MassFlowRate = SysMaxMassFlowRes; state->dataLoopNodes->Node(HotInNode).MassFlowRate = SysMaxMassFlowRes; @@ -530,15 +533,14 @@ TEST_F(EnergyPlusFixture, DualDuctVAVAirTerminals_MinFlowTurnDownTest) TEST_F(EnergyPlusFixture, DualDuctAirTerminal_reportTerminalUnit) { using namespace EnergyPlus::OutputReportPredefined; + state->init_state(*state); + auto &orp = *state->dataOutRptPredefined; SetPredefinedTables(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; - auto &sch = state->dataScheduleMgr->Schedule; - sch.allocate(5); - sch(1).Name = "schA"; - sch(2).Name = "schB"; + auto *schedA = Sched::AddScheduleConstant(*state, "schA"); + auto *schedB = Sched::AddScheduleConstant(*state, "schB"); auto &adu = state->dataDefineEquipment->AirDistUnit; adu.allocate(2); @@ -559,7 +561,7 @@ TEST_F(EnergyPlusFixture, DualDuctAirTerminal_reportTerminalUnit) ddat(1).ADUNum = 1; ddat(1).DamperType = DualDuctDamper::ConstantVolume; ddat(1).MaxAirVolFlowRate = 0.30; - ddat(1).ZoneTurndownMinAirFracSchPtr = 1; + ddat(1).zoneTurndownMinAirFracSched = schedA; ddat(1).OARequirementsPtr = 0; ddat(1).reportTerminalUnit(*state); @@ -594,12 +596,12 @@ TEST_F(EnergyPlusFixture, DualDuctAirTerminal_reportTerminalUnit) ddat(2).ADUNum = 2; ddat(2).DamperType = DualDuctDamper::VariableVolume; ddat(2).MaxAirVolFlowRate = 0.31; - ddat(2).ZoneTurndownMinAirFracSchPtr = 0; + ddat(2).zoneTurndownMinAirFracSched = nullptr; ddat(2).OARequirementsPtr = 1; auto &oa = state->dataSize->OARequirements; oa.allocate(1); - oa(1).OAFlowFracSchPtr = 2; + oa(1).oaFlowFracSched = schedB; ddat(2).reportTerminalUnit(*state); diff --git a/tst/EnergyPlus/unit/EMSManager.unit.cc b/tst/EnergyPlus/unit/EMSManager.unit.cc index 0fd6ebb8929..66587466f7e 100644 --- a/tst/EnergyPlus/unit/EMSManager.unit.cc +++ b/tst/EnergyPlus/unit/EMSManager.unit.cc @@ -91,6 +91,7 @@ using namespace EnergyPlus::PlantUtilities; TEST_F(EnergyPlusFixture, EMSManager_TestForUniqueEMSActuators) { + state->init_state(*state); state->dataRuntimeLang->EMSActuatorAvailable.allocate(100); std::string componentTypeName1("Chiller1"); @@ -134,7 +135,6 @@ TEST_F(EnergyPlusFixture, EMSManager_TestForUniqueEMSActuators) TEST_F(EnergyPlusFixture, Dual_NodeTempSetpoints) { - std::string const idf_objects = delimited_string({ "OutdoorAir:Node, Test node;", @@ -164,6 +164,7 @@ TEST_F(EnergyPlusFixture, Dual_NodeTempSetpoints) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); OutAirNodeManager::SetOutAirNodes(*state); @@ -206,6 +207,7 @@ TEST_F(EnergyPlusFixture, CheckActuatorInit) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); OutAirNodeManager::SetOutAirNodes(*state); EMSManager::GetEMSInput(*state); @@ -215,7 +217,6 @@ TEST_F(EnergyPlusFixture, CheckActuatorInit) TEST_F(EnergyPlusFixture, SupervisoryControl_PlantComponent_SetActuatedBranchFlowRate) { - // test EMS actuator for Plant Component // test SetActuatedBranchFlowRate for expected response @@ -238,7 +239,8 @@ TEST_F(EnergyPlusFixture, SupervisoryControl_PlantComponent_SetActuatedBranchFlo }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + // sets number of EMS objects EMSManager::CheckIfAnyEMS(*state); @@ -402,7 +404,8 @@ TEST_F(EnergyPlusFixture, SupervisoryControl_PlantComponent_SetComponentFlowRate }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + // sets number of EMS objects EMSManager::CheckIfAnyEMS(*state); @@ -708,7 +711,8 @@ TEST_F(EnergyPlusFixture, Test_EMSLogic) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + OutAirNodeManager::SetOutAirNodes(*state); EMSManager::CheckIfAnyEMS(*state); @@ -776,7 +780,8 @@ TEST_F(EnergyPlusFixture, Debug_EMSLogic) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + OutAirNodeManager::SetOutAirNodes(*state); EMSManager::CheckIfAnyEMS(*state); @@ -814,7 +819,8 @@ TEST_F(EnergyPlusFixture, TestAnyRanArgument) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + OutAirNodeManager::SetOutAirNodes(*state); NodeInputManager::SetupNodeVarsForReporting(*state); EMSManager::CheckIfAnyEMS(*state); @@ -853,7 +859,8 @@ TEST_F(EnergyPlusFixture, TestUnInitializedEMSVariable1) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + EMSManager::CheckIfAnyEMS(*state); state->dataEMSMgr->FinishProcessingUserInput = true; bool anyRan; @@ -909,7 +916,8 @@ TEST_F(EnergyPlusFixture, TestUnInitializedEMSVariable2) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + OutAirNodeManager::SetOutAirNodes(*state); EMSManager::CheckIfAnyEMS(*state); @@ -940,7 +948,6 @@ TEST_F(EnergyPlusFixture, TestUnInitializedEMSVariable2) TEST_F(EnergyPlusFixture, EMSManager_CheckIfAnyEMS_OutEMS) { - std::string const idf_objects = delimited_string({ " Output:EnergyManagementSystem, ", " Verbose, !- Actuator Availability Dictionary Reporting ", @@ -949,7 +956,8 @@ TEST_F(EnergyPlusFixture, EMSManager_CheckIfAnyEMS_OutEMS) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + CheckIfAnyEMS(*state); EXPECT_TRUE(state->dataGlobal->AnyEnergyManagementSystemInModel); } @@ -1091,7 +1099,8 @@ TEST_F(EnergyPlusFixture, EMSManager_TestFuntionCall) ASSERT_TRUE(process_idf(idf_objects)); state->dataGlobal->TimeStepZone = 0.25; - + state->init_state(*state); + EMSManager::CheckIfAnyEMS(*state); // get EMS input state->dataEMSMgr->FinishProcessingUserInput = true; bool ErrorsFound(false); @@ -1557,6 +1566,8 @@ TEST_F(EnergyPlusFixture, EMSManager_TestFuntionCall) TEST_F(EnergyPlusFixture, EMSManager_TestOANodeAsActuators) { + state->init_state(*state); + // EMSActuatorAvailable.allocate(100); state->dataLoopNodes->NumOfNodes = 3; state->dataRuntimeLang->numActuatorsUsed = 3; @@ -1596,6 +1607,8 @@ TEST_F(EnergyPlusFixture, EMSManager_TestOANodeAsActuators) } TEST_F(EnergyPlusFixture, EMSManager_TestWindowShadingControlExteriorScreenOption) { + state->init_state(*state); + // #7586 state->dataSurface->Surface.allocate(2); state->dataSurface->SurfaceWindow.allocate(2); @@ -1653,7 +1666,6 @@ TEST_F(EnergyPlusFixture, EMSManager_TestWindowShadingControlExteriorScreenOptio } TEST_F(EnergyPlusFixture, EMS_WeatherDataActuators) { - // GetNextEnvironment Will call ReadUserWeatherInput which calls inputProcessor, so let's use process_idf to create one Environment (Design Day) std::string const idf_objects = delimited_string({ @@ -1753,9 +1765,11 @@ TEST_F(EnergyPlusFixture, EMS_WeatherDataActuators) ASSERT_TRUE(process_idf(idf_objects)); state->dataGlobal->BeginSimFlag = true; - state->dataGlobal->NumOfTimeStepInHour = 4; + state->dataGlobal->TimeStepsInHour = 4; state->dataWeather->LocationGathered = false; + state->init_state(*state); + EMSManager::CheckIfAnyEMS(*state); bool available = false; bool errorsFound = false; @@ -1797,7 +1811,6 @@ TEST_F(EnergyPlusFixture, EMS_WeatherDataActuators) } TEST_F(EnergyPlusFixture, EMS_TodayTomorrowFunctions) { - // GetNextEnvironment Will call ReadUserWeatherInput which calls inputProcessor, so let's use process_idf to create one Environment (Design Day) std::string const idf_objects = delimited_string({ @@ -1881,8 +1894,9 @@ TEST_F(EnergyPlusFixture, EMS_TodayTomorrowFunctions) ASSERT_TRUE(process_idf(idf_objects)); state->dataGlobal->BeginSimFlag = true; - state->dataGlobal->NumOfTimeStepInHour = 4; + state->dataGlobal->TimeStepsInHour = 4; state->dataWeather->LocationGathered = false; + state->init_state(*state); EMSManager::CheckIfAnyEMS(*state); bool available = false; @@ -2209,7 +2223,8 @@ TEST_F(EnergyPlusFixture, EMS_ViewFactorToGround) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + state->dataEnvrn->Year = 2000; state->dataEnvrn->EndYear = 2000; @@ -2254,7 +2269,6 @@ TEST_F(EnergyPlusFixture, EMS_ViewFactorToGround) TEST_F(EnergyPlusFixture, EMSManager_TrendValue_to_Actuator) { - // Test for #10279 - Make sure that assigning the result of a TendVariable @TrendValue results in proper actuator behavior std::string const idf_objects = delimited_string({ "Schedule:Constant,", @@ -2303,25 +2317,27 @@ TEST_F(EnergyPlusFixture, EMSManager_TrendValue_to_Actuator) ASSERT_TRUE(process_idf(idf_objects)); - state->dataGlobal->TimeStepZone = 0.25; - + // Apparently this needs to be called before GetScheduleData, i.e., init_state() EMSManager::CheckIfAnyEMS(*state); // get EMS input EXPECT_TRUE(state->dataGlobal->AnyEnergyManagementSystemInModel); - state->dataEMSMgr->FinishProcessingUserInput = true; - - state->dataGlobal->NumOfTimeStepInHour = 4; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 15; // must initialize this to get schedules initialized + state->dataGlobal->TimeStepZone = 0.25; + + state->dataGlobal->TimeStepsInHour = 4; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 15; // must initialize this to get schedules initialized state->dataGlobal->TimeStepZone = 0.25; state->dataHVACGlobal->TimeStepSys = 0.25; - state->dataGlobal->TimeStepZoneSec = state->dataGlobal->TimeStepZone * Constant::SecInHour; - ScheduleManager::ProcessScheduleInput(*state); // read schedules + state->dataGlobal->TimeStepZoneSec = state->dataGlobal->TimeStepZone * Constant::rSecsInHour; + state->init_state(*state); + + state->dataEMSMgr->FinishProcessingUserInput = true; + + EXPECT_EQ(4, state->dataSched->schedules.size()); - EXPECT_EQ(2, state->dataScheduleMgr->NumSchedules); - auto &schDirect = state->dataScheduleMgr->Schedule(1); - EXPECT_EQ("ACTUATED SCHEDULE DIRECT", schDirect.Name); - auto &schIndirect = state->dataScheduleMgr->Schedule(2); - EXPECT_EQ("ACTUATED SCHEDULE INDIRECT", schIndirect.Name); + auto *schedDirect = Sched::GetSchedule(*state, "ACTUATED SCHEDULE DIRECT"); + auto *schedIndirect = Sched::GetSchedule(*state, "ACTUATED SCHEDULE INDIRECT"); + EXPECT_NE(schedDirect, nullptr); + EXPECT_NE(schedIndirect, nullptr); state->dataEnvrn->Month = 12; state->dataEnvrn->DayOfMonth = 31; @@ -2335,13 +2351,15 @@ TEST_F(EnergyPlusFixture, EMSManager_TrendValue_to_Actuator) state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); state->dataEnvrn->DSTIndicator = 0; // DST IS OFF - ScheduleManager::UpdateScheduleValues(*state); - EXPECT_EQ(18.0, schDirect.CurrentValue); - EXPECT_FALSE(schDirect.EMSActuatedOn); - EXPECT_EQ(0.0, schDirect.EMSValue); - EXPECT_EQ(18.0, schIndirect.CurrentValue); - EXPECT_FALSE(schIndirect.EMSActuatedOn); - EXPECT_EQ(0.0, schIndirect.EMSValue); + Sched::UpdateScheduleVals(*state); + + + EXPECT_EQ(18.0, schedDirect->currentVal); + EXPECT_FALSE(schedDirect->EMSActuatedOn); + EXPECT_EQ(0.0, schedDirect->EMSVal); + EXPECT_EQ(18.0, schedIndirect->currentVal); + EXPECT_FALSE(schedIndirect->EMSActuatedOn); + EXPECT_EQ(0.0, schedIndirect->EMSVal); EMSManager::InitEMS(*state, EMSManager::EMSCallFrom::BeginTimestepBeforePredictor); @@ -2502,13 +2520,13 @@ TEST_F(EnergyPlusFixture, EMSManager_TrendValue_to_Actuator) EXPECT_TRUE(resultValueErlVar.Value.Error.empty()); EXPECT_TRUE(resultValueErlVar.Value.initialized); - ScheduleManager::UpdateScheduleValues(*state); - EXPECT_EQ(45.0, schDirect.CurrentValue); - EXPECT_TRUE(schDirect.EMSActuatedOn); - EXPECT_EQ(45.0, schDirect.EMSValue); - EXPECT_EQ(45.0, schIndirect.CurrentValue); - EXPECT_TRUE(schIndirect.EMSActuatedOn); - EXPECT_EQ(45.0, schIndirect.EMSValue); + Sched::UpdateScheduleVals(*state); + EXPECT_EQ(45.0, schedDirect->currentVal); + EXPECT_TRUE(schedDirect->EMSActuatedOn); + EXPECT_EQ(45.0, schedDirect->EMSVal); + EXPECT_EQ(45.0, schedIndirect->currentVal); + EXPECT_TRUE(schedIndirect->EMSActuatedOn); + EXPECT_EQ(45.0, schedIndirect->EMSVal); EMSManager::UpdateEMSTrendVariables(*state); for (int i = 0; i < 12; ++i) { @@ -2579,11 +2597,11 @@ TEST_F(EnergyPlusFixture, EMSManager_TrendValue_to_Actuator) EXPECT_TRUE(resultValueErlVar.Value.Error.empty()); EXPECT_TRUE(resultValueErlVar.Value.initialized); - ScheduleManager::UpdateScheduleValues(*state); - EXPECT_EQ(45.0, schDirect.CurrentValue); - EXPECT_TRUE(schDirect.EMSActuatedOn); - EXPECT_EQ(45.0, schDirect.EMSValue); - EXPECT_EQ(45.0, schIndirect.CurrentValue); - EXPECT_TRUE(schIndirect.EMSActuatedOn); - EXPECT_EQ(45.0, schIndirect.EMSValue); + Sched::UpdateScheduleVals(*state); + EXPECT_EQ(45.0, schedDirect->currentVal); + EXPECT_TRUE(schedDirect->EMSActuatedOn); + EXPECT_EQ(45.0, schedDirect->EMSVal); + EXPECT_EQ(45.0, schedIndirect->currentVal); + EXPECT_TRUE(schedIndirect->EMSActuatedOn); + EXPECT_EQ(45.0, schedIndirect->EMSVal); } diff --git a/tst/EnergyPlus/unit/EcoRoofManager.unit.cc b/tst/EnergyPlus/unit/EcoRoofManager.unit.cc index 83e7935abf0..883a45119b3 100644 --- a/tst/EnergyPlus/unit/EcoRoofManager.unit.cc +++ b/tst/EnergyPlus/unit/EcoRoofManager.unit.cc @@ -76,6 +76,7 @@ namespace EnergyPlus { TEST_F(EnergyPlusFixture, EcoRoof_CalculateEcoRoofSolarTest) { + state->init_state(*state); Real64 resultRS; Real64 resultf1; Real64 expectedRS; @@ -186,6 +187,7 @@ TEST_F(EnergyPlusFixture, EcoRoofManager_UpdateSoilProps) "Until: 24:00,0.003; !- Field 5", }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); bool ErrorsFound = false; // Read objects @@ -229,6 +231,7 @@ TEST_F(EnergyPlusFixture, EcoRoofManager_UpdateSoilProps) TEST_F(EnergyPlusFixture, EcoRoofManager_initEcoRoofFirstTimeTest) { + state->init_state(*state); int surfNum = 1; int constrNum = 1; Real64 expectedAnswer; @@ -265,6 +268,7 @@ TEST_F(EnergyPlusFixture, EcoRoofManager_initEcoRoofFirstTimeTest) TEST_F(EnergyPlusFixture, EcoRoofManager_initEcoRoofTest) { + state->init_state(*state); int surfNum = 1; int constrNum = 1; Real64 expectedAnswer; diff --git a/tst/EnergyPlus/unit/EconomicTariff.unit.cc b/tst/EnergyPlus/unit/EconomicTariff.unit.cc index 3f070d90e93..6f96bf604ab 100644 --- a/tst/EnergyPlus/unit/EconomicTariff.unit.cc +++ b/tst/EnergyPlus/unit/EconomicTariff.unit.cc @@ -189,7 +189,7 @@ TEST_F(EnergyPlusFixture, EconomicTariff_GetInput_Test) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); UpdateUtilityBills(*state); // tariff @@ -255,6 +255,7 @@ TEST_F(EnergyPlusFixture, EconomicTariff_Water_DefaultConv_Test) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); // Create a water meter, can't use AddMeter because we would need to create a variable for that OutputProcessor::Meter *meter = new OutputProcessor::Meter("WATER:FACILITY"); @@ -298,6 +299,7 @@ TEST_F(EnergyPlusFixture, EconomicTariff_Water_CCF_Test) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); // Create a water meter OutputProcessor::Meter *meter = new Meter("WATER:FACILITY"); @@ -338,6 +340,7 @@ TEST_F(EnergyPlusFixture, EconomicTariff_Gas_CCF_Test) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); // Create a water meter OutputProcessor::Meter *meter = new Meter("NATURALGAS:FACILITY"); @@ -380,6 +383,7 @@ TEST_F(EnergyPlusFixture, EconomicTariff_Electric_CCF_Test) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); // Create a water meter OutputProcessor::Meter *meter = new Meter("ELECTRICITY:FACILITY"); @@ -407,6 +411,7 @@ TEST_F(EnergyPlusFixture, EconomicTariff_Electric_CCF_Test) TEST_F(EnergyPlusFixture, EconomicTariff_LEEDtariffReporting_Test) { + state->init_state(*state); state->dataOutputProcessor->meters.push_back(new Meter("ELECTRICITY:FACILITY")); state->dataOutputProcessor->meterMap.insert_or_assign("ELECTRICITY:FACILITY", state->dataOutputProcessor->meters.size() - 1); state->dataOutputProcessor->meters.push_back(new Meter("NATURALGAS:FACILITY")); @@ -587,12 +592,12 @@ TEST_F(EnergyPlusFixture, EconomicTariff_GatherForEconomics) ASSERT_TRUE(process_idf(idf_objects)); - state->dataGlobal->NumOfTimeStepInHour = 4; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 15; // must initialize this to get schedules initialized + state->dataGlobal->TimeStepsInHour = 4; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 15; // must initialize this to get schedules initialized state->dataGlobal->TimeStepZone = 0.25; - state->dataGlobal->TimeStepZoneSec = state->dataGlobal->TimeStepZone * Constant::SecInHour; + state->dataGlobal->TimeStepZoneSec = state->dataGlobal->TimeStepZone * Constant::rSecsInHour; - ScheduleManager::ProcessScheduleInput(*state); // read schedules + state->init_state(*state); ExteriorEnergyUse::ManageExteriorEnergyUse(*state); EXPECT_EQ(1, state->dataExteriorEnergyUse->NumExteriorLights); EXPECT_EQ(1000, state->dataExteriorEnergyUse->ExteriorLights(1).DesignLevel); @@ -606,11 +611,7 @@ TEST_F(EnergyPlusFixture, EconomicTariff_GatherForEconomics) EXPECT_EQ("SEASONAL_TARIFF", state->dataEconTariff->tariff(1).tariffName); EXPECT_ENUM_EQ(EconConv::KWH, state->dataEconTariff->tariff(1).convChoice); EXPECT_EQ(0, state->dataEconTariff->tariff(1).monthChgVal); - EXPECT_EQ("ELECTRICITY SEASON SCHEDULE", state->dataEconTariff->tariff(1).seasonSchedule); - - int seasonSchPtr = state->dataEconTariff->tariff(1).seasonSchIndex; - EXPECT_GT(seasonSchPtr, 0); - EXPECT_EQ("ELECTRICITY SEASON SCHEDULE", state->dataScheduleMgr->Schedule(seasonSchPtr).Name); + EXPECT_EQ("ELECTRICITY SEASON SCHEDULE", state->dataEconTariff->tariff(1).seasonSched->Name); // Two Simple Charges EXPECT_EQ(2, state->dataEconTariff->numChargeSimple); @@ -638,10 +639,9 @@ TEST_F(EnergyPlusFixture, EconomicTariff_GatherForEconomics) state->dataGlobal->TimeStep = 4; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); - ScheduleManager::UpdateScheduleValues(*state); - EXPECT_EQ(1.0, ScheduleManager::LookUpScheduleValue(*state, 1, state->dataGlobal->HourOfDay, state->dataGlobal->TimeStep)); - EXPECT_EQ(1.0, ScheduleManager::GetCurrentScheduleValue(*state, state->dataEconTariff->tariff(1).seasonSchIndex)); - EXPECT_EQ(1.0, state->dataScheduleMgr->Schedule(seasonSchPtr).CurrentValue); + Sched::UpdateScheduleVals(*state); + EXPECT_EQ(1.0, Sched::GetSchedule(*state, "ALWAYS ON DISCRETE")->getHrTsVal(*state, state->dataGlobal->HourOfDay, state->dataGlobal->TimeStep)); + EXPECT_EQ(1.0, state->dataEconTariff->tariff(1).seasonSched->getCurrentVal()); ExteriorEnergyUse::ManageExteriorEnergyUse(*state); @@ -670,8 +670,8 @@ TEST_F(EnergyPlusFixture, EconomicTariff_GatherForEconomics) state->dataGlobal->TimeStep = 1; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); - ScheduleManager::UpdateScheduleValues(*state); - EXPECT_EQ(3.0, ScheduleManager::GetCurrentScheduleValue(*state, state->dataEconTariff->tariff(1).seasonSchIndex)); + Sched::UpdateScheduleVals(*state); + EXPECT_EQ(3.0, state->dataEconTariff->tariff(1).seasonSched->getCurrentVal()); ExteriorEnergyUse::ManageExteriorEnergyUse(*state); @@ -688,6 +688,7 @@ TEST_F(EnergyPlusFixture, EconomicTariff_GatherForEconomics) TEST_F(EnergyPlusFixture, EconomicTariff_GatherForEconomics_ZeroMeterIndex) { + state->init_state(*state); // Test for PR #10521 and Issue #10519 state->dataEconTariff->numTariff = 1; state->dataEconTariff->tariff.allocate(state->dataEconTariff->numTariff); @@ -709,6 +710,7 @@ TEST_F(EnergyPlusFixture, EconomicTariff_GatherForEconomics_ZeroMeterIndex) TEST_F(EnergyPlusFixture, EconomicTariff_PushPopStack) { + state->init_state(*state); state->dataEconTariff->numTariff = 1; state->dataEconTariff->tariff.allocate(state->dataEconTariff->numTariff); @@ -810,6 +812,7 @@ TEST_F(EnergyPlusFixture, EconomicTariff_PushPopStack) TEST_F(EnergyPlusFixture, EconomicTariff_evaluateChargeSimple) { + state->init_state(*state); int curTariff = 6; state->dataEconTariff->tariff.allocate(curTariff); @@ -899,6 +902,7 @@ TEST_F(EnergyPlusFixture, EconomicTariff_evaluateChargeSimple) TEST_F(EnergyPlusFixture, EconomicTariff_evaluateChargeBlock) { + state->init_state(*state); int curTariff = 8; state->dataEconTariff->tariff.allocate(curTariff); @@ -1022,6 +1026,7 @@ TEST_F(EnergyPlusFixture, InputEconomics_UtilityCost_Variable_Test0) bool ErrorsFound = false; ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); GetInputEconomicsVariable(*state, ErrorsFound); @@ -1103,6 +1108,7 @@ TEST_F(EnergyPlusFixture, InputEconomics_UtilityCost_Variable_Test1) bool ErrorsFound = false; ASSERT_TRUE(process_idf(idf_objects1)); + state->init_state(*state); GetInputEconomicsVariable(*state, ErrorsFound); // Make sure variable input type "Energy" is processed as expected @@ -1181,6 +1187,7 @@ TEST_F(EnergyPlusFixture, InputEconomics_UtilityCost_Variable_Test2) bool ErrorsFound = false; ASSERT_TRUE(process_idf(idf_objects2)); + state->init_state(*state); GetInputEconomicsVariable(*state, ErrorsFound); // Make sure variable input type "Dimensionless" is processed as expected @@ -1259,6 +1266,7 @@ TEST_F(EnergyPlusFixture, InputEconomics_UtilityCost_Variable_Test3) bool ErrorsFound = false; ASSERT_TRUE(process_idf(idf_objects3)); + state->init_state(*state); GetInputEconomicsVariable(*state, ErrorsFound); // Make sure variable input type "Currency" is processed as expected @@ -1405,12 +1413,12 @@ TEST_F(SQLiteFixture, WriteEconomicTariffTable_DualUnits) ASSERT_TRUE(process_idf(idf_objects)); - state->dataGlobal->NumOfTimeStepInHour = 4; - state->dataGlobal->MinutesPerTimeStep = 15; + state->dataGlobal->TimeStepsInHour = 4; + state->dataGlobal->MinutesInTimeStep = 15; state->dataGlobal->TimeStepZone = 0.25; - state->dataGlobal->TimeStepZoneSec = state->dataGlobal->TimeStepZone * Constant::SecInHour; + state->dataGlobal->TimeStepZoneSec = state->dataGlobal->TimeStepZone * Constant::rSecsInHour; - ScheduleManager::ProcessScheduleInput(*state); + state->init_state(*state); ExteriorEnergyUse::ManageExteriorEnergyUse(*state); state->dataSQLiteProcedures->sqlite->createSQLiteSimulationsRecord(1, "EnergyPlus Version", "Current Time"); @@ -1442,7 +1450,7 @@ TEST_F(SQLiteFixture, WriteEconomicTariffTable_DualUnits) state->dataGlobal->TimeStep = 4; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); ExteriorEnergyUse::ManageExteriorEnergyUse(*state); state->dataGlobal->DoOutputReporting = true; @@ -1666,6 +1674,7 @@ TEST_F(EnergyPlusFixture, EconomicTariff_LEEDtariff_with_Custom_Meter) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); bool errors_found = false; diff --git a/tst/EnergyPlus/unit/ElectricBaseboardRadiator.unit.cc b/tst/EnergyPlus/unit/ElectricBaseboardRadiator.unit.cc index 2427377a5a5..c60e570d7c3 100644 --- a/tst/EnergyPlus/unit/ElectricBaseboardRadiator.unit.cc +++ b/tst/EnergyPlus/unit/ElectricBaseboardRadiator.unit.cc @@ -130,7 +130,7 @@ TEST_F(EnergyPlusFixture, RadConvElecBaseboard_Test1) " ZoneHVAC:Baseboard:RadiantConvective:Electric,", " SPACE2-1 Baseboard, !- Name", - " always_on, !- Availability Schedule Name", + " CONSTANT-1.0, !- Availability Schedule Name", " HeatingDesignCapacity, !- Heating Design Capacity Method", " 1000.0, !- Heating Design Capacity {W}", " , !- Heating Design Capacity Per Floor Area {W/m2}", @@ -160,7 +160,7 @@ TEST_F(EnergyPlusFixture, RadConvElecBaseboard_Test1) " ZoneHVAC:Baseboard:RadiantConvective:Electric,", " SPACE4-1 Baseboard, !- Name", - " always_on, !- Availability Schedule Name", + " CONSTANT-1.0, !- Availability Schedule Name", " HeatingDesignCapacity, !- Heating Design Capacity Method", " 1000.0, !- Heating Design Capacity {W}", " , !- Heating Design Capacity Per Floor Area {W/m2}", @@ -188,19 +188,6 @@ TEST_F(EnergyPlusFixture, RadConvElecBaseboard_Test1) " 0.0,0.0,0.0, !- X,Y,Z ==> Vertex 3 {m}", " 0.0,0.0,2.4; !- X,Y,Z ==> Vertex 4 {m}", - " ScheduleTypeLimits,", - " Fraction, !- Name", - " 0.0, !- Lower Limit Value", - " 1.0, !- Upper Limit Value", - " CONTINUOUS; !- Numeric Type", - - " Schedule:Compact,", - " always_on, !- Name", - " Fraction, !- Schedule Type Limits Name", - " Through: 12/31, !- Field 1", - " For: AllDays, !- Field 2", - " Until: 24:00,1.0; !- Field 3" - "SurfaceConvectionAlgorithm:Inside,TARP;", "SurfaceConvectionAlgorithm:Outside,DOE-2;", @@ -265,9 +252,9 @@ TEST_F(EnergyPlusFixture, RadConvElecBaseboard_Test1) ASSERT_TRUE(process_idf(idf_objects)); - state->dataGlobal->NumOfTimeStepInHour = 1; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 60; // must initialize this to get schedules initialized - ScheduleManager::ProcessScheduleInput(*state); // read schedules + state->dataGlobal->TimeStepsInHour = 1; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 60; // must initialize this to get schedules initialized + state->init_state(*state); bool errorsFound(false); HeatBalanceManager::GetProjectControlData(*state, errorsFound); // read project control data @@ -286,10 +273,10 @@ TEST_F(EnergyPlusFixture, RadConvElecBaseboard_Test1) state->dataSurfaceGeometry->CosZoneRelNorth.allocate(2); state->dataSurfaceGeometry->SinZoneRelNorth.allocate(2); - state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); - state->dataSurfaceGeometry->CosZoneRelNorth(2) = std::cos(-state->dataHeatBal->Zone(2).RelNorth * Constant::DegToRadians); - state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); - state->dataSurfaceGeometry->SinZoneRelNorth(2) = std::sin(-state->dataHeatBal->Zone(2).RelNorth * Constant::DegToRadians); + state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); + state->dataSurfaceGeometry->CosZoneRelNorth(2) = std::cos(-state->dataHeatBal->Zone(2).RelNorth * Constant::DegToRad); + state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); + state->dataSurfaceGeometry->SinZoneRelNorth(2) = std::sin(-state->dataHeatBal->Zone(2).RelNorth * Constant::DegToRad); state->dataSurfaceGeometry->CosBldgRelNorth = 1.0; state->dataSurfaceGeometry->SinBldgRelNorth = 0.0; @@ -402,7 +389,7 @@ TEST_F(EnergyPlusFixture, ElectricBaseboardRadConv_SizingTest) " ZoneHVAC:Baseboard:RadiantConvective:Electric,", " SPACE2-1 Baseboard, !- Name", - " always_on, !- Availability Schedule Name", + " CONSTANT-1.0, !- Availability Schedule Name", " HeatingDesignCapacity, !- Heating Design Capacity Method", " 1000.0, !- Heating Design Capacity {W}", " , !- Heating Design Capacity Per Floor Area {W/m2}", @@ -432,7 +419,7 @@ TEST_F(EnergyPlusFixture, ElectricBaseboardRadConv_SizingTest) " ZoneHVAC:Baseboard:RadiantConvective:Electric,", " SPACE3-1 Baseboard, !- Name", - " always_on, !- Availability Schedule Name", + " CONSTANT-1.0, !- Availability Schedule Name", " CapacityPerFloorArea, !- Heating Design Capacity Method", " , !- Heating Design Capacity {W}", " 30.0, !- Heating Design Capacity Per Floor Area {W/m2}", @@ -462,7 +449,7 @@ TEST_F(EnergyPlusFixture, ElectricBaseboardRadConv_SizingTest) " ZoneHVAC:Baseboard:RadiantConvective:Electric,", " SPACE4-1 Baseboard, !- Name", - " always_on, !- Availability Schedule Name", + " CONSTANT-1.0, !- Availability Schedule Name", " FractionOfAutosizedHeatingCapacity, !- Heating Design Capacity Method", " , !- Heating Design Capacity {W}", " , !- Heating Design Capacity Per Floor Area {W/m2}", @@ -490,19 +477,6 @@ TEST_F(EnergyPlusFixture, ElectricBaseboardRadConv_SizingTest) " 0.0,0.0,0.0, !- X,Y,Z ==> Vertex 3 {m}", " 0.0,0.0,2.4; !- X,Y,Z ==> Vertex 4 {m}", - " ScheduleTypeLimits,", - " Fraction, !- Name", - " 0.0, !- Lower Limit Value", - " 1.0, !- Upper Limit Value", - " CONTINUOUS; !- Numeric Type", - - " Schedule:Compact,", - " always_on, !- Name", - " Fraction, !- Schedule Type Limits Name", - " Through: 12/31, !- Field 1", - " For: AllDays, !- Field 2", - " Until: 24:00,1.0; !- Field 3" - "SurfaceConvectionAlgorithm:Inside,TARP;", "SurfaceConvectionAlgorithm:Outside,DOE-2;", @@ -567,9 +541,9 @@ TEST_F(EnergyPlusFixture, ElectricBaseboardRadConv_SizingTest) ASSERT_TRUE(process_idf(idf_objects)); - state->dataGlobal->NumOfTimeStepInHour = 1; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 60; // must initialize this to get schedules initialized - ScheduleManager::ProcessScheduleInput(*state); // read schedules + state->dataGlobal->TimeStepsInHour = 1; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 60; // must initialize this to get schedules initialized + state->init_state(*state); bool errorsFound(false); HeatBalanceManager::GetProjectControlData(*state, errorsFound); // read project control data @@ -588,12 +562,12 @@ TEST_F(EnergyPlusFixture, ElectricBaseboardRadConv_SizingTest) state->dataSurfaceGeometry->CosZoneRelNorth.allocate(3); state->dataSurfaceGeometry->SinZoneRelNorth.allocate(3); - state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); - state->dataSurfaceGeometry->CosZoneRelNorth(2) = std::cos(-state->dataHeatBal->Zone(2).RelNorth * Constant::DegToRadians); - state->dataSurfaceGeometry->CosZoneRelNorth(3) = std::cos(-state->dataHeatBal->Zone(3).RelNorth * Constant::DegToRadians); - state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); - state->dataSurfaceGeometry->SinZoneRelNorth(2) = std::sin(-state->dataHeatBal->Zone(2).RelNorth * Constant::DegToRadians); - state->dataSurfaceGeometry->SinZoneRelNorth(3) = std::sin(-state->dataHeatBal->Zone(3).RelNorth * Constant::DegToRadians); + state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); + state->dataSurfaceGeometry->CosZoneRelNorth(2) = std::cos(-state->dataHeatBal->Zone(2).RelNorth * Constant::DegToRad); + state->dataSurfaceGeometry->CosZoneRelNorth(3) = std::cos(-state->dataHeatBal->Zone(3).RelNorth * Constant::DegToRad); + state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); + state->dataSurfaceGeometry->SinZoneRelNorth(2) = std::sin(-state->dataHeatBal->Zone(2).RelNorth * Constant::DegToRad); + state->dataSurfaceGeometry->SinZoneRelNorth(3) = std::sin(-state->dataHeatBal->Zone(3).RelNorth * Constant::DegToRad); state->dataSurfaceGeometry->CosBldgRelNorth = 1.0; state->dataSurfaceGeometry->SinBldgRelNorth = 0.0; diff --git a/tst/EnergyPlus/unit/ElectricPowerServiceManager.unit.cc b/tst/EnergyPlus/unit/ElectricPowerServiceManager.unit.cc index ec4c23113c4..37977155eca 100644 --- a/tst/EnergyPlus/unit/ElectricPowerServiceManager.unit.cc +++ b/tst/EnergyPlus/unit/ElectricPowerServiceManager.unit.cc @@ -69,7 +69,6 @@ using namespace EnergyPlus; TEST_F(EnergyPlusFixture, ManageElectricPowerTest_BatteryDischargeTest) { - std::string const idf_objects = delimited_string({ "ElectricLoadCenter:Distribution,", " PV Array Load Center, !- Name", @@ -98,7 +97,7 @@ TEST_F(EnergyPlusFixture, ManageElectricPowerTest_BatteryDischargeTest) " ElectricLoadCenter:Storage:Battery,", " Kibam, !- Name", - " ALWAYS_ON, !- Availability Schedule Name", + " CONSTANT-1.0, !- Availability Schedule Name", " , !- Zone Name", " 0, !- Radiative Fraction", " 10, !- Number of Battery Modules in Parallel", @@ -145,7 +144,7 @@ TEST_F(EnergyPlusFixture, ManageElectricPowerTest_BatteryDischargeTest) " ElectricLoadCenter:Inverter:LookUpTable,", " PV Inverter, !- Name", - " ALWAYS_ON, !- Availability Schedule Name", + " CONSTANT-1.0, !- Availability Schedule Name", " , !- Zone Name", " 0.25, !- Radiative Fraction", " 14000, !- Rated Maximum Continuous Output Power {W}", @@ -163,7 +162,7 @@ TEST_F(EnergyPlusFixture, ManageElectricPowerTest_BatteryDischargeTest) " PV:ZN_1_FLR_1_SEC_1_Ceiling, !- Generator 1 Name", " Generator:Photovoltaic, !- Generator 1 Object Type", " 9000.0, !- Generator 1 Rated Electric Power Output {W}", - " ALWAYS_ON, !- Generator 1 Availability Schedule Name", + " CONSTANT-1.0, !- Generator 1 Availability Schedule Name", " ; !- Generator 1 Rated Thermal to Electrical Power Ratio", " Generator:Photovoltaic,", @@ -181,16 +180,10 @@ TEST_F(EnergyPlusFixture, ManageElectricPowerTest_BatteryDischargeTest) " Fixed, !- Conversion Efficiency Input Mode", " 0.20, !- Value for Cell Efficiency if Fixed", " ; !- Efficiency Schedule Name", - - " Schedule:Compact,", - " ALWAYS_ON, !- Name", - " On/Off, !- Schedule Type Limits Name", - " Through: 12/31, !- Field 1", - " For: AllDays, !- Field 2", - " Until: 24:00,1; !- Field 3", }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); createFacilityElectricPowerServiceObject(*state); state->dataElectPwrSvcMgr->facilityElectricServiceObj->elecLoadCenterObjs.emplace_back(new ElectPowerLoadCenter(*state, 1)); @@ -223,7 +216,6 @@ TEST_F(EnergyPlusFixture, ManageElectricPowerTest_BatteryDischargeTest) TEST_F(EnergyPlusFixture, ManageElectricPowerTest_UpdateLoadCenterRecords_Case1) { - std::string const idf_objects = delimited_string({ " ElectricLoadCenter:Distribution,", @@ -242,23 +234,17 @@ TEST_F(EnergyPlusFixture, ManageElectricPowerTest_UpdateLoadCenterRecords_Case1) " Test Gen 1, !- Generator 1 Name", " Generator:InternalCombustionEngine, !- Generator 1 Object Type", " 1000.0, !- Generator 1 Rated Electric Power Output {W}", - " ALWAYS_ON, !- Generator 1 Availability Schedule Name", + " CONSTANT-1.0, !- Generator 1 Availability Schedule Name", " , !- Generator 1 Rated Thermal to Electrical Power Ratio", " Test Gen 2, !- Generator 2 Name", " Generator:WindTurbine, !- Generator 2 Object Type", " 2000.0, !- Generator 2 Rated Electric Power Output {W}", - " ALWAYS_ON, !- Generator 2 Availability Schedule Name", + " CONSTANT-1.0, !- Generator 2 Availability Schedule Name", " ; !- Generator 2 Rated Thermal to Electrical Power Ratio", - - " Schedule:Compact,", - " ALWAYS_ON, !- Name", - " On/Off, !- Schedule Type Limits Name", - " Through: 12/31, !- Field 1", - " For: AllDays, !- Field 2", - " Until: 24:00,1; !- Field 3", }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); createFacilityElectricPowerServiceObject(*state); state->dataElectPwrSvcMgr->facilityElectricServiceObj->elecLoadCenterObjs.emplace_back(new ElectPowerLoadCenter(*state, 1)); @@ -286,7 +272,6 @@ TEST_F(EnergyPlusFixture, ManageElectricPowerTest_UpdateLoadCenterRecords_Case1) TEST_F(EnergyPlusFixture, ManageElectricPowerTest_UpdateLoadCenterRecords_Case2) { - std::string const idf_objects = delimited_string({ " ElectricLoadCenter:Distribution,", @@ -302,7 +287,7 @@ TEST_F(EnergyPlusFixture, ManageElectricPowerTest_UpdateLoadCenterRecords_Case2) " ElectricLoadCenter:Storage:Simple,", " Test Storage Bank,", - " ALWAYS_ON, !- availability schedule", + " CONSTANT-1.0, !- availability schedule", " , !- zone name", " , !- radiative fraction", " 1.0 , !- Nominal Energetic Efficiency for Charging", @@ -317,23 +302,17 @@ TEST_F(EnergyPlusFixture, ManageElectricPowerTest_UpdateLoadCenterRecords_Case2) " Test Gen 1, !- Generator 1 Name", " Generator:InternalCombustionEngine, !- Generator 1 Object Type", " 1000.0, !- Generator 1 Rated Electric Power Output {W}", - " ALWAYS_ON, !- Generator 1 Availability Schedule Name", + " CONSTANT-1.0, !- Generator 1 Availability Schedule Name", " , !- Generator 1 Rated Thermal to Electrical Power Ratio", " Test Gen 2, !- Generator 2 Name", " Generator:WindTurbine, !- Generator 2 Object Type", " 2000.0, !- Generator 2 Rated Electric Power Output {W}", - " ALWAYS_ON, !- Generator 2 Availability Schedule Name", + " CONSTANT-1.0, !- Generator 2 Availability Schedule Name", " ; !- Generator 2 Rated Thermal to Electrical Power Ratio", - - " Schedule:Compact,", - " ALWAYS_ON, !- Name", - " On/Off, !- Schedule Type Limits Name", - " Through: 12/31, !- Field 1", - " For: AllDays, !- Field 2", - " Until: 24:00,1; !- Field 3", }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); createFacilityElectricPowerServiceObject(*state); state->dataElectPwrSvcMgr->facilityElectricServiceObj->elecLoadCenterObjs.emplace_back(new ElectPowerLoadCenter(*state, 1)); @@ -368,7 +347,6 @@ TEST_F(EnergyPlusFixture, ManageElectricPowerTest_UpdateLoadCenterRecords_Case2) TEST_F(EnergyPlusFixture, ManageElectricPowerTest_UpdateLoadCenterRecords_Case3) { - std::string const idf_objects = delimited_string({ " ElectricLoadCenter:Distribution,", @@ -396,7 +374,7 @@ TEST_F(EnergyPlusFixture, ManageElectricPowerTest_UpdateLoadCenterRecords_Case3) " ElectricLoadCenter:Inverter:Simple,", " Test Inverter,", - " ALWAYS_ON, !- availability schedule", + " CONSTANT-1.0, !- availability schedule", " , !- zone name", " , !- radiative fraction", " 1.0 ; !- Inverter efficiency", @@ -406,27 +384,22 @@ TEST_F(EnergyPlusFixture, ManageElectricPowerTest_UpdateLoadCenterRecords_Case3) " Test Gen 1, !- Generator 1 Name", " Generator:InternalCombustionEngine, !- Generator 1 Object Type", " 1000.0, !- Generator 1 Rated Electric Power Output {W}", - " ALWAYS_ON, !- Generator 1 Availability Schedule Name", + " CONSTANT-1.0, !- Generator 1 Availability Schedule Name", " , !- Generator 1 Rated Thermal to Electrical Power Ratio", " Test Gen 2, !- Generator 2 Name", " Generator:WindTurbine, !- Generator 2 Object Type", " 2000.0, !- Generator 2 Rated Electric Power Output {W}", - " ALWAYS_ON, !- Generator 2 Availability Schedule Name", + " CONSTANT-1.0, !- Generator 2 Availability Schedule Name", " ; !- Generator 2 Rated Thermal to Electrical Power Ratio", - - " Schedule:Constant,", - " ALWAYS_ON, !- Name", - " On/Off, !- Schedule Type Limits Name", - " 1; !- Field 3", }); ASSERT_TRUE(process_idf(idf_objects)); // get availability schedule to work - state->dataGlobal->NumOfTimeStepInHour = 1; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 60; // must initialize this to get schedules initialized - ScheduleManager::ProcessScheduleInput(*state); // read schedules - state->dataScheduleMgr->ScheduleInputProcessed = true; + state->dataGlobal->TimeStepsInHour = 1; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 60; // must initialize this to get schedules initialized + state->init_state(*state); + state->dataEnvrn->Month = 1; state->dataEnvrn->DayOfMonth = 21; state->dataGlobal->HourOfDay = 1; @@ -435,7 +408,7 @@ TEST_F(EnergyPlusFixture, ManageElectricPowerTest_UpdateLoadCenterRecords_Case3) state->dataEnvrn->DayOfWeek = 2; state->dataEnvrn->HolidayIndex = 0; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); createFacilityElectricPowerServiceObject(*state); state->dataElectPwrSvcMgr->facilityElectricServiceObj->elecLoadCenterObjs.emplace_back(new ElectPowerLoadCenter(*state, 1)); @@ -462,7 +435,6 @@ TEST_F(EnergyPlusFixture, ManageElectricPowerTest_UpdateLoadCenterRecords_Case3) TEST_F(EnergyPlusFixture, ManageElectricPowerTest_UpdateLoadCenterRecords_Case4) { - std::string const idf_objects = delimited_string({ " ElectricLoadCenter:Distribution,", @@ -490,14 +462,14 @@ TEST_F(EnergyPlusFixture, ManageElectricPowerTest_UpdateLoadCenterRecords_Case4) " ElectricLoadCenter:Inverter:Simple,", " Test Inverter,", - " ALWAYS_ON, !- availability schedule", + " CONSTANT-1.0, !- availability schedule", " , !- zone name", " , !- radiative fraction", " 1.0 ; !- Inverter efficiency", " ElectricLoadCenter:Storage:Simple,", " Test Storage Bank,", - " ALWAYS_ON, !- availability schedule", + " CONSTANT-1.0, !- availability schedule", " , !- zone name", " , !- radiative fraction", " 1.0 , !- Nominal Energetic Efficiency for Charging", @@ -512,34 +484,23 @@ TEST_F(EnergyPlusFixture, ManageElectricPowerTest_UpdateLoadCenterRecords_Case4) " Test Gen 1, !- Generator 1 Name", " Generator:InternalCombustionEngine, !- Generator 1 Object Type", " 1000.0, !- Generator 1 Rated Electric Power Output {W}", - " ALWAYS_ON, !- Generator 1 Availability Schedule Name", + " CONSTANT-1.0, !- Generator 1 Availability Schedule Name", " , !- Generator 1 Rated Thermal to Electrical Power Ratio", " Test Gen 2, !- Generator 2 Name", " Generator:WindTurbine, !- Generator 2 Object Type", " 2000.0, !- Generator 2 Rated Electric Power Output {W}", - " ALWAYS_ON, !- Generator 2 Availability Schedule Name", + " CONSTANT-1.0, !- Generator 2 Availability Schedule Name", " ; !- Generator 2 Rated Thermal to Electrical Power Ratio", - - " Schedule:Compact,", - " ALWAYS_ON, !- Name", - " On/Off, !- Schedule Type Limits Name", - " Through: 12/31, !- Field 1", - " For: AllDays, !- Field 2", - " Until: 24:00,1; !- Field 3", }); ASSERT_TRUE(process_idf(idf_objects)); - state->dataGlobal->NumOfTimeStepInHour = 1; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 60; // must initialize this to get schedules initialized + state->dataGlobal->TimeStepsInHour = 1; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 60; // must initialize this to get schedules initialized + state->init_state(*state); createFacilityElectricPowerServiceObject(*state); state->dataElectPwrSvcMgr->facilityElectricServiceObj->elecLoadCenterObjs.emplace_back(new ElectPowerLoadCenter(*state, 1)); - // get availability schedule to work - state->dataGlobal->NumOfTimeStepInHour = 1; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 60; // must initialize this to get schedules initialized - ScheduleManager::ProcessScheduleInput(*state); // read schedules - state->dataScheduleMgr->ScheduleInputProcessed = true; state->dataEnvrn->Month = 1; state->dataEnvrn->DayOfMonth = 21; state->dataGlobal->HourOfDay = 1; @@ -548,7 +509,7 @@ TEST_F(EnergyPlusFixture, ManageElectricPowerTest_UpdateLoadCenterRecords_Case4) state->dataEnvrn->DayOfWeek = 2; state->dataEnvrn->HolidayIndex = 0; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); // Case 4 DCBussInverterDCStorage Inverter = 5000, state->dataElectPwrSvcMgr->facilityElectricServiceObj->elecLoadCenterObjs[0]->bussType = @@ -574,7 +535,6 @@ TEST_F(EnergyPlusFixture, ManageElectricPowerTest_UpdateLoadCenterRecords_Case4) TEST_F(EnergyPlusFixture, ManageElectricPowerTest_UpdateLoadCenterRecords_Case5) { - std::string const idf_objects = delimited_string({ " ElectricLoadCenter:Distribution,", @@ -590,14 +550,14 @@ TEST_F(EnergyPlusFixture, ManageElectricPowerTest_UpdateLoadCenterRecords_Case5) " ElectricLoadCenter:Inverter:Simple,", " Test Inverter,", - " ALWAYS_ON, !- availability schedule", + " CONSTANT-1.0, !- availability schedule", " , !- zone name", " , !- radiative fraction", " 1.0 ; !- Inverter efficiency", " ElectricLoadCenter:Storage:Simple,", " Test Storage Bank,", - " ALWAYS_ON, !- availability schedule", + " CONSTANT-1.0, !- availability schedule", " , !- zone name", " , !- radiative fraction", " 1.0 , !- Nominal Energetic Efficiency for Charging", @@ -612,29 +572,22 @@ TEST_F(EnergyPlusFixture, ManageElectricPowerTest_UpdateLoadCenterRecords_Case5) " Test Gen 1, !- Generator 1 Name", " Generator:InternalCombustionEngine, !- Generator 1 Object Type", " 1000.0, !- Generator 1 Rated Electric Power Output {W}", - " ALWAYS_ON, !- Generator 1 Availability Schedule Name", + " CONSTANT-1.0, !- Generator 1 Availability Schedule Name", " , !- Generator 1 Rated Thermal to Electrical Power Ratio", " Test Gen 2, !- Generator 2 Name", " Generator:WindTurbine, !- Generator 2 Object Type", " 2000.0, !- Generator 2 Rated Electric Power Output {W}", - " ALWAYS_ON, !- Generator 2 Availability Schedule Name", + " CONSTANT-1.0, !- Generator 2 Availability Schedule Name", " ; !- Generator 2 Rated Thermal to Electrical Power Ratio", - - " Schedule:Compact,", - " ALWAYS_ON, !- Name", - " On/Off, !- Schedule Type Limits Name", - " Through: 12/31, !- Field 1", - " For: AllDays, !- Field 2", - " Until: 24:00,1; !- Field 3", }); ASSERT_TRUE(process_idf(idf_objects)); // get availability schedule to work - state->dataGlobal->NumOfTimeStepInHour = 1; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 60; // must initialize this to get schedules initialized - ScheduleManager::ProcessScheduleInput(*state); // read schedules - state->dataScheduleMgr->ScheduleInputProcessed = true; + state->dataGlobal->TimeStepsInHour = 1; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 60; // must initialize this to get schedules initialized + state->init_state(*state); + state->dataEnvrn->Month = 1; state->dataEnvrn->DayOfMonth = 21; state->dataGlobal->HourOfDay = 1; @@ -643,7 +596,7 @@ TEST_F(EnergyPlusFixture, ManageElectricPowerTest_UpdateLoadCenterRecords_Case5) state->dataEnvrn->DayOfWeek = 2; state->dataEnvrn->HolidayIndex = 0; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); createFacilityElectricPowerServiceObject(*state); state->dataElectPwrSvcMgr->facilityElectricServiceObj->elecLoadCenterObjs.emplace_back(new ElectPowerLoadCenter(*state, 1)); @@ -678,7 +631,6 @@ TEST_F(EnergyPlusFixture, ManageElectricPowerTest_UpdateLoadCenterRecords_Case5) } TEST_F(EnergyPlusFixture, ManageElectricPowerTest_CheckOutputReporting) { - std::string const idf_objects = delimited_string({ " LoadProfile:Plant,", @@ -695,6 +647,7 @@ TEST_F(EnergyPlusFixture, ManageElectricPowerTest_CheckOutputReporting) state->dataHVACGlobal->TimeStepSys = 1.0; state->dataHVACGlobal->TimeStepSysSec = 3600.0; state->dataGlobal->TimeStepZoneSec = 3600.0; + state->init_state(*state); createFacilityElectricPowerServiceObject(*state); bool SimElecCircuitsFlag = false; @@ -706,7 +659,6 @@ TEST_F(EnergyPlusFixture, ManageElectricPowerTest_CheckOutputReporting) } TEST_F(EnergyPlusFixture, ManageElectricPowerTest_TransformerLossTest) { - std::string const idf_objects = delimited_string({ " ElectricLoadCenter:Distribution,", @@ -723,14 +675,14 @@ TEST_F(EnergyPlusFixture, ManageElectricPowerTest_TransformerLossTest) " ElectricLoadCenter:Inverter:Simple,", " Test Inverter,", - " Always_ON, !- availability schedule", + " CONSTANT-1.0, !- availability schedule", " , !- zone name", " , !- radiative fraction", " 1.0; !- Inverter efficiency", " ElectricLoadCenter:Storage:Simple,", " Test Storage Bank,", - " Always_ON, !- availability schedule", + " CONSTANT-1.0, !- availability schedule", " , !- zone name", " , !- radiative fraction", " 1.0, !- Nominal Energetic Efficiency for Charging", @@ -745,17 +697,17 @@ TEST_F(EnergyPlusFixture, ManageElectricPowerTest_TransformerLossTest) " Test Gen 1, !- Generator 1 Name", " Generator:InternalCombustionEngine, !- Generator 1 Object Type", " 1000.0, !- Generator 1 Rated Electric Power Output {W}", - " Always_ON, !- Generator 1 Availability Schedule Name", + " CONSTANT-1.0, !- Generator 1 Availability Schedule Name", " , !- Generator 1 Rated Thermal to Electrical Power Ratio", " Test Gen 2, !- Generator 2 Name", " Generator:WindTurbine, !- Generator 2 Object Type", " 2000.0, !- Generator 2 Rated Electric Power Output {W}", - " Always_ON, !- Generator 2 Availability Schedule Name", + " CONSTANT-1.0, !- Generator 2 Availability Schedule Name", " ; !- Generator 2 Rated Thermal to Electrical Power Ratio", " ElectricLoadCenter:Transformer,", " Transformer, !- Name", - " Always_ON, !- Availability Schedule Name", + " CONSTANT-1.0, !- Availability Schedule Name", " PowerOutToGrid, !- Transformer Usage", " , !- Zone Name", " , !- Radiative Fraction", @@ -772,33 +724,26 @@ TEST_F(EnergyPlusFixture, ManageElectricPowerTest_TransformerLossTest) " , !- Reference Temperature for Nameplate Efficiency {C}", " , !- Per Unit Load for Maximum Efficiency", " ; !- Consider Transformer Loss for Utility Cost", - - " Schedule:Compact,", - " Always_ON, !- Name", - " On/Off, !- Schedule Type Limits Name", - " Through: 12/31, !- Field 1", - " For: AllDays, !- Field 2", - " Until: 24:00,1; !- Field 3", }); ASSERT_TRUE(process_idf(idf_objects)); // get availability schedule to work - state->dataGlobal->NumOfTimeStepInHour = 1; - state->dataGlobal->MinutesPerTimeStep = 60; + state->dataGlobal->TimeStepsInHour = 1; + state->dataGlobal->MinutesInTimeStep = 60; + state->init_state(*state); + state->dataGlobal->HourOfDay = 1; state->dataGlobal->TimeStep = 1; state->dataEnvrn->Month = 1; state->dataEnvrn->DayOfMonth = 21; state->dataHVACGlobal->TimeStepSys = 1.0; - state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; state->dataEnvrn->DSTIndicator = 0; state->dataEnvrn->DayOfWeek = 2; state->dataEnvrn->HolidayIndex = 0; - ScheduleManager::ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); createFacilityElectricPowerServiceObject(*state); state->dataElectPwrSvcMgr->facilityElectricServiceObj->elecLoadCenterObjs.emplace_back(new ElectPowerLoadCenter(*state, 1)); @@ -814,7 +759,6 @@ TEST_F(EnergyPlusFixture, ManageElectricPowerTest_TransformerLossTest) // unused. Any other performance type shouldn't warn TEST_F(EnergyPlusFixture, ElectricLoadCenter_WarnAvailabilitySchedule_Photovoltaic_Simple) { - std::string const idf_objects = delimited_string({ "ElectricLoadCenter:Distribution,", " PV Electric Load Center, !- Name", @@ -936,14 +880,15 @@ TEST_F(EnergyPlusFixture, ElectricLoadCenter_WarnAvailabilitySchedule_Photovolta }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); createFacilityElectricPowerServiceObject(*state); state->dataElectPwrSvcMgr->facilityElectricServiceObj->elecLoadCenterObjs.emplace_back(new ElectPowerLoadCenter(*state, 1)); // Should warn only for SimplePV because SimplePV2 doesn't have a schedule, and the other one is a Perf One-Diode and not "Simple" std::string const error_string = delimited_string({ - " ** Warning ** GeneratorController constructor ElectricLoadCenter:Generators, Availability Schedule for Generator:Photovoltaics " - "'SIMPLEPV' of Type PhotovoltaicPerformance:Simple will be be ignored (runs all the time).", + " ** Warning ** GeneratorController constructor : GENERATOR:PHOTOVOLTAIC = SIMPLEPV", + " ** ~~~ ** Availability Schedule will be ignored (runs all the time).", " ** ~~~ ** To limit this Generator:Photovoltaic's output, please use the Inverter's availability schedule instead.", }); EXPECT_TRUE(compare_err_stream(error_string, true)); @@ -952,7 +897,6 @@ TEST_F(EnergyPlusFixture, ElectricLoadCenter_WarnAvailabilitySchedule_Photovolta // #7151: If an ElectricLoadCenter:Generators lists a Generator:PVWatts with an availability schedule, warn that it will be unused TEST_F(EnergyPlusFixture, ElectricLoadCenter_WarnAvailabilitySchedule_PVWatts) { - std::string const idf_objects = delimited_string({ "ElectricLoadCenter:Distribution,", " PVWatts Electric Load Center, !- Name", @@ -1024,14 +968,15 @@ TEST_F(EnergyPlusFixture, ElectricLoadCenter_WarnAvailabilitySchedule_PVWatts) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); createFacilityElectricPowerServiceObject(*state); state->dataElectPwrSvcMgr->facilityElectricServiceObj->elecLoadCenterObjs.emplace_back(new ElectPowerLoadCenter(*state, 1)); // Should warn only for PVWatts1 because PVWatts2 doesn't have a schedule std::string const error_string = delimited_string({ - " ** Warning ** GeneratorController constructor ElectricLoadCenter:Generators, Availability Schedule for Generator:PVWatts 'PVWATTS1' will " - "be be ignored (runs all the time).", + " ** Warning ** GeneratorController constructor : GENERATOR:PVWATTS = PVWATTS1", + " ** ~~~ ** Availability Schedule will be ignored (runs all the time)." }); EXPECT_TRUE(compare_err_stream(error_string, true)); } @@ -1078,6 +1023,7 @@ TEST_F(EnergyPlusFixture, Battery_LiIonNmc_Constructor) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); ElectricStorage battery1{*state, "Battery1"}; ASSERT_TRUE(Util::SameString(battery1.name(), "Battery1")); @@ -1121,10 +1067,12 @@ TEST_F(EnergyPlusFixture, Battery_LiIonNmc_Simulate) }); ASSERT_TRUE(process_idf(idf_objects)); + state->dataHVACGlobal->TimeStepSys = 0.25; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; + state->init_state(*state); + ElectricStorage battery{*state, "Battery1"}; - state->dataHVACGlobal->TimeStepSys = 0.25; - state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; state->dataEnvrn->OutDryBulbTemp = 23.0; Real64 socMin = 0.1; Real64 socMax = 0.95; @@ -1191,6 +1139,7 @@ TEST_F(EnergyPlusFixture, Battery_checkUserEfficiencyInputTest) // Fix for Defect #8867: EnergyPlus was allowing zero efficiency which led to a divide by zero in ElectricPowerServiceManager.cc. // Input is now tested to make sure that a zero value is not allowed. + state->init_state(*state); // Test 1: charging, charging efficiency zero-->gets reset to minimum (0.001) userInputEfficiencyCharge = 0.0; expectedResult = 0.001; @@ -1198,7 +1147,8 @@ TEST_F(EnergyPlusFixture, Battery_checkUserEfficiencyInputTest) functionResult = checkUserEfficiencyInput(*state, userInputEfficiencyCharge, "CHARGING", "Tatooine", errorsFound); EXPECT_NEAR(functionResult, expectedResult, 0.00001); std::string const error_string1 = - delimited_string({" ** Severe ** ElectricStorage charge efficiency was too low. This occurred for electric storage unit named Tatooine", + delimited_string({" ** Warning ** Version: missing in IDF, processing for EnergyPlus version=\"24.2\"", + " ** Severe ** ElectricStorage charge efficiency was too low. This occurred for electric storage unit named Tatooine", " ** ~~~ ** Please check your input value for this electric storage unit and fix the charge efficiency."}); EXPECT_TRUE(compare_err_stream(error_string1, true)); EXPECT_TRUE(errorsFound); @@ -1290,6 +1240,7 @@ TEST_F(EnergyPlusFixture, Battery_checkChargeDischargeVoltageCurves) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); Curve::GetCurveInput(*state); state->dataCurveManager->GetCurvesInputFlag = false; diff --git a/tst/EnergyPlus/unit/EquipAndOperations.unit.cc b/tst/EnergyPlus/unit/EquipAndOperations.unit.cc index 65a5879e066..dcc24468f8a 100644 --- a/tst/EnergyPlus/unit/EquipAndOperations.unit.cc +++ b/tst/EnergyPlus/unit/EquipAndOperations.unit.cc @@ -273,7 +273,8 @@ TEST_F(DistributeEquipOpTest, EvaluateChillerHeaterChangeoverOpSchemeTest) )IDF"; ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + auto &heatBranch1 = state->dataPlnt->PlantLoop(2).LoopSide(DataPlant::LoopSideLocation::Supply).Branch(1); auto &heatComp1 = state->dataPlnt->PlantLoop(2).LoopSide(DataPlant::LoopSideLocation::Supply).Branch(1).Comp(1); heatComp1.Type = DataPlant::PlantEquipmentType::HeatPumpEIRHeating; @@ -502,7 +503,8 @@ TEST_F(DistributeEquipOpTest, SupervisoryControlLogicForAirSourcePlantsTest) )IDF"; ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + auto &heatBranch1 = state->dataPlnt->PlantLoop(2).LoopSide(DataPlant::LoopSideLocation::Supply).Branch(1); auto &heatComp1 = state->dataPlnt->PlantLoop(2).LoopSide(DataPlant::LoopSideLocation::Supply).Branch(1).Comp(1); heatComp1.Type = DataPlant::PlantEquipmentType::HeatPumpEIRHeating; diff --git a/tst/EnergyPlus/unit/EvaporativeCoolers.unit.cc b/tst/EnergyPlus/unit/EvaporativeCoolers.unit.cc index 3361323ac7e..e8a06033003 100644 --- a/tst/EnergyPlus/unit/EvaporativeCoolers.unit.cc +++ b/tst/EnergyPlus/unit/EvaporativeCoolers.unit.cc @@ -77,6 +77,7 @@ namespace EnergyPlus { TEST_F(EnergyPlusFixture, EvapCoolers_SecondaryAirOutletCondition) { + state->init_state(*state); auto &EvapCond(state->dataEvapCoolers->EvapCond); EvapCond.allocate(1); @@ -104,8 +105,6 @@ TEST_F(EnergyPlusFixture, EvapCoolers_SecondaryAirOutletCondition) AirMassFlowSec = 2.0; QHXTotal = 10206.410750000941; - InitializePsychRoutines(*state); - // make the call for dry operating mode CalcSecondaryAirOutletCondition(*state, EvapCoolNum, OperatingMode, AirMassFlowSec, EDBTSec, EWBTSec, EHumRatSec, QHXTotal, QHXLatent); @@ -131,6 +130,7 @@ TEST_F(EnergyPlusFixture, EvapCoolers_SecondaryAirOutletCondition) TEST_F(EnergyPlusFixture, EvapCoolers_IndEvapCoolerOutletTemp) { + state->init_state(*state); auto &EvapCond(state->dataEvapCoolers->EvapCond); int constexpr EvapCoolNum(1); @@ -167,6 +167,7 @@ TEST_F(EnergyPlusFixture, EvapCoolers_IndEvapCoolerOutletTemp) TEST_F(EnergyPlusFixture, EvapCoolers_SizeIndEvapCoolerTest) { + state->init_state(*state); auto &EvapCond(state->dataEvapCoolers->EvapCond); int constexpr EvapCoolNum(1); @@ -260,6 +261,7 @@ TEST_F(EnergyPlusFixture, EvapCoolers_SizeIndEvapCoolerTest) TEST_F(EnergyPlusFixture, EvapCoolers_SizeDirEvapCoolerTest) { + state->init_state(*state); auto &EvapCond(state->dataEvapCoolers->EvapCond); int constexpr EvapCoolNum(1); @@ -327,6 +329,7 @@ TEST_F(EnergyPlusFixture, EvapCoolers_SizeDirEvapCoolerTest) TEST_F(EnergyPlusFixture, EvaporativeCoolers_CalcSecondaryAirOutletCondition) { + state->init_state(*state); auto &EvapCond(state->dataEvapCoolers->EvapCond); EvapCond.allocate(1); @@ -355,8 +358,6 @@ TEST_F(EnergyPlusFixture, EvaporativeCoolers_CalcSecondaryAirOutletCondition) AirMassFlowSec = 2.0; QHXTotal = 10206.410750000941; - InitializePsychRoutines(*state); - // make the call for dry operating mode EvaporativeCoolers::CalcSecondaryAirOutletCondition( *state, EvapCoolNum, OperatingMode, AirMassFlowSec, EDBTSec, EWBTSec, EHumRatSec, QHXTotal, QHXLatent); @@ -384,6 +385,7 @@ TEST_F(EnergyPlusFixture, EvaporativeCoolers_CalcSecondaryAirOutletCondition) TEST_F(EnergyPlusFixture, EvaporativeCoolers_CalcIndirectRDDEvapCoolerOutletTemp) { + state->init_state(*state); auto &EvapCond(state->dataEvapCoolers->EvapCond); state->dataEnvrn->OutBaroPress = 101325.0; @@ -419,6 +421,7 @@ TEST_F(EnergyPlusFixture, EvaporativeCoolers_CalcIndirectRDDEvapCoolerOutletTemp TEST_F(EnergyPlusFixture, EvaporativeCoolers_IndEvapCoolerPower) { + state->init_state(*state); auto &EvapCond(state->dataEvapCoolers->EvapCond); EvapCond.allocate(1); @@ -470,6 +473,7 @@ TEST_F(EnergyPlusFixture, EvaporativeCoolers_IndEvapCoolerPower) TEST_F(EnergyPlusFixture, EvaporativeCoolers_SizeEvapCooler) { + state->init_state(*state); auto &EvapCond(state->dataEvapCoolers->EvapCond); // one-time setup of evap cooler instance @@ -551,6 +555,7 @@ TEST_F(EnergyPlusFixture, EvaporativeCoolers_SizeEvapCooler) TEST_F(EnergyPlusFixture, DefaultAutosizeIndEvapCoolerTest) { + state->init_state(*state); int constexpr EvapCoolNum(1); Real64 PrimaryAirDesignFlow(0.0); @@ -649,6 +654,7 @@ TEST_F(EnergyPlusFixture, DefaultAutosizeIndEvapCoolerTest) TEST_F(EnergyPlusFixture, DefaultAutosizeDirEvapCoolerTest) { + state->init_state(*state); int constexpr EvapCoolNum(1); Real64 PrimaryAirDesignFlow(0.0); @@ -718,6 +724,7 @@ TEST_F(EnergyPlusFixture, DefaultAutosizeDirEvapCoolerTest) TEST_F(EnergyPlusFixture, DirectEvapCoolerResearchSpecialCalcTest) { + state->init_state(*state); auto &EvapCond(state->dataEvapCoolers->EvapCond); // one-time setup of evap cooler instance @@ -739,7 +746,7 @@ TEST_F(EnergyPlusFixture, DirectEvapCoolerResearchSpecialCalcTest) // set up the flow rates for a direct RDDSpecial thisEvapCooler.evapCoolerType = EvapCoolerType::DirectResearchSpecial; thisEvapCooler.Name = "MyDirectEvapCoolerRS"; - thisEvapCooler.SchedPtr = ScheduleManager::ScheduleAlwaysOn; + thisEvapCooler.availSched = Sched::GetScheduleAlwaysOn(*state); thisEvapCooler.PumpPowerModifierCurveIndex = 1; thisEvapCooler.DirectEffectiveness = 0.75; thisEvapCooler.DesVolFlowRate = 1.0; @@ -769,6 +776,7 @@ TEST_F(EnergyPlusFixture, DirectEvapCoolerResearchSpecialCalcTest) TEST_F(EnergyPlusFixture, EvaporativeCoolers_IndirectRDDEvapCoolerOperatingMode) { + state->init_state(*state); auto &EvapCond(state->dataEvapCoolers->EvapCond); state->dataEnvrn->OutBaroPress = 101325.0; @@ -815,6 +823,7 @@ TEST_F(EnergyPlusFixture, EvaporativeCoolers_IndirectRDDEvapCoolerOperatingMode) TEST_F(EnergyPlusFixture, DirectEvapCoolerAutosizeWithoutSysSizingRunDone) { + state->init_state(*state); int constexpr EvapCoolNum(1); state->dataSize->NumSysSizInput = 1; @@ -866,6 +875,7 @@ TEST_F(EnergyPlusFixture, DirectEvapCoolerAutosizeWithoutSysSizingRunDone) ASSERT_THROW(EvaporativeCoolers::SizeEvapCooler(*state, 1), std::runtime_error); std::string const error_string = delimited_string({ + " ** Warning ** Version: missing in IDF, processing for EnergyPlus version=\"24.2\"", " ** Severe ** For autosizing of EvaporativeCooler:Direct:ResearchSpecial DIRECTEVAPCOOLER, a system sizing run must be done.", " ** ~~~ ** The \"SimulationControl\" object did not have the field \"Do System Sizing Calculation\" set to Yes.", " ** Fatal ** Program terminates due to previously shown condition(s).", @@ -897,6 +907,7 @@ TEST_F(EnergyPlusFixture, EvapCoolerAirLoopPumpCycling) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); EvaporativeCoolers::GetEvapInput(*state); ASSERT_FALSE(ErrorsFound); diff --git a/tst/EnergyPlus/unit/EvaporativeFluidCoolers.unit.cc b/tst/EnergyPlus/unit/EvaporativeFluidCoolers.unit.cc index 1238b47808c..f7ef73fb6cf 100644 --- a/tst/EnergyPlus/unit/EvaporativeFluidCoolers.unit.cc +++ b/tst/EnergyPlus/unit/EvaporativeFluidCoolers.unit.cc @@ -169,7 +169,8 @@ TEST_F(EnergyPlusFixture, ExerciseSingleSpeedEvapFluidCooler) "25.6; !- Design Entering Air Wet-bulb Temperature {C}"}); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + EvapFluidCoolerSpecs *ptr = EvapFluidCoolerSpecs::factory(*state, DataPlant::PlantEquipmentType::EvapFluidCooler_SingleSpd, "BIG EVAPORATIVEFLUIDCOOLER"); @@ -254,7 +255,8 @@ TEST_F(EnergyPlusFixture, ExerciseTwoSpeedEvapFluidCooler) "3; !- Blowdown Concentration Ratio"}); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + EvapFluidCoolerSpecs *ptr = EvapFluidCoolerSpecs::factory(*state, DataPlant::PlantEquipmentType::EvapFluidCooler_TwoSpd, "CENTRAL TOWER"); PlantLocation pl{1, EnergyPlus::DataPlant::LoopSideLocation::Demand, 1, 1}; diff --git a/tst/EnergyPlus/unit/ExhaustSystem.unit.cc b/tst/EnergyPlus/unit/ExhaustSystem.unit.cc index c40636369dc..8d591047845 100644 --- a/tst/EnergyPlus/unit/ExhaustSystem.unit.cc +++ b/tst/EnergyPlus/unit/ExhaustSystem.unit.cc @@ -362,6 +362,9 @@ TEST_F(EnergyPlusFixture, ExhaustSystemInputTest) " CONTINUOUS; !- Numeric Type", }); + ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + // Preset some elements state->dataHeatBal->Zone.allocate(4); state->dataHeatBal->Zone(1).Name = "ZONE1"; @@ -378,9 +381,6 @@ TEST_F(EnergyPlusFixture, ExhaustSystemInputTest) // state->dataFans->fanObjs.emplace_back(new HVACFan::FanSystem(*state, "CentralExhaustFan1")); // state->dataFans->fanObjs.emplace_back(new HVACFan::FanSystem(*state, "CentralExhaustFan2")); - ASSERT_TRUE(process_idf(idf_objects)); - ScheduleManager::ProcessScheduleInput(*state); - // Call the processing codes ExhaustAirSystemManager::GetZoneExhaustControlInput(*state); @@ -432,6 +432,7 @@ TEST_F(EnergyPlusFixture, ExhaustSystemInputTest) TEST_F(EnergyPlusFixture, ZoneExhaustCtrl_CheckSupplyNode_Test) { + state->init_state(*state); // Preset some elements state->dataGlobal->NumOfZones = 4; state->dataHeatBal->Zone.allocate(state->dataGlobal->NumOfZones); @@ -578,7 +579,7 @@ TEST_F(EnergyPlusFixture, ZoneExhaustCtrl_CheckSupplyNode_Test) EXPECT_TRUE(NodeNotFound); - EXPECT_EQ(state->dataErrTracking->TotalWarningErrors, 0); + EXPECT_EQ(state->dataErrTracking->TotalWarningErrors, 1); EXPECT_EQ(state->dataErrTracking->TotalSevereErrors, 1); EXPECT_EQ(state->dataErrTracking->LastSevereError, "GetExhaustControlInput: ZoneHVAC:ExhaustControl="); } @@ -859,6 +860,9 @@ TEST_F(EnergyPlusFixture, ZoneExhaustCtrl_Test_CalcZoneHVACExhaustControl_Call) " CONTINUOUS; !- Numeric Type", }); + ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + // Preset some elements state->dataHeatBal->Zone.allocate(4); state->dataHeatBal->Zone(1).Name = "ZONE1"; @@ -869,9 +873,6 @@ TEST_F(EnergyPlusFixture, ZoneExhaustCtrl_Test_CalcZoneHVACExhaustControl_Call) state->dataSize->FinalZoneSizing.allocate(4); state->dataSize->FinalZoneSizing(2).MinOA = 0.25; - ASSERT_TRUE(process_idf(idf_objects)); - ScheduleManager::ProcessScheduleInput(*state); - // Call the processing codes ExhaustAirSystemManager::GetZoneExhaustControlInput(*state); ExhaustAirSystemManager::GetExhaustAirSystemInput(*state); diff --git a/tst/EnergyPlus/unit/ExteriorEnergyUse.unit.cc b/tst/EnergyPlus/unit/ExteriorEnergyUse.unit.cc index 1eb8e0cb3a4..7e19df14201 100644 --- a/tst/EnergyPlus/unit/ExteriorEnergyUse.unit.cc +++ b/tst/EnergyPlus/unit/ExteriorEnergyUse.unit.cc @@ -60,22 +60,20 @@ using namespace EnergyPlus; using namespace EnergyPlus::ExteriorEnergyUse; -using namespace EnergyPlus::ScheduleManager; TEST_F(EnergyPlusFixture, ExteriorEquipmentTest_Test1) { - + state->dataGlobal->TimeStepZone = 0.25; + state->dataGlobal->TimeStepZoneSec = state->dataGlobal->TimeStepZone * Constant::rSecsInHour; + state->init_state(*state); + state->dataExteriorEnergyUse->NumExteriorLights = 0; state->dataExteriorEnergyUse->NumExteriorEqs = 2; - state->dataGlobal->TimeStepZone = 0.25; - state->dataGlobal->TimeStepZoneSec = state->dataGlobal->TimeStepZone * Constant::SecInHour; state->dataExteriorEnergyUse->ExteriorEquipment.allocate(state->dataExteriorEnergyUse->NumExteriorEqs); state->dataExteriorEnergyUse->ExteriorEquipment(1).DesignLevel = 1000.0; state->dataExteriorEnergyUse->ExteriorEquipment(2).DesignLevel = 0.0; - state->dataExteriorEnergyUse->ExteriorEquipment(1).SchedPtr = - ScheduleManager::ScheduleAlwaysOn; // From dataglobals, always returns a 1 for schedule value - state->dataExteriorEnergyUse->ExteriorEquipment(2).SchedPtr = - ScheduleManager::ScheduleAlwaysOn; // From dataglobals, always returns a 1 for schedule value + state->dataExteriorEnergyUse->ExteriorEquipment(1).sched = Sched::GetScheduleAlwaysOn(*state); + state->dataExteriorEnergyUse->ExteriorEquipment(2).sched = Sched::GetScheduleAlwaysOn(*state); ReportExteriorEnergyUse(*state); EXPECT_EQ(1000.0, state->dataExteriorEnergyUse->ExteriorEquipment(1).Power); diff --git a/tst/EnergyPlus/unit/FanCoilUnits.unit.cc b/tst/EnergyPlus/unit/FanCoilUnits.unit.cc index cde523187e2..a50348e8b8c 100644 --- a/tst/EnergyPlus/unit/FanCoilUnits.unit.cc +++ b/tst/EnergyPlus/unit/FanCoilUnits.unit.cc @@ -95,7 +95,6 @@ using namespace EnergyPlus::HeatBalanceManager; using namespace EnergyPlus::OutputProcessor; using namespace EnergyPlus::OutputReportPredefined; using namespace EnergyPlus::Psychrometrics; -using namespace EnergyPlus::ScheduleManager; using namespace EnergyPlus::WaterCoils; namespace EnergyPlus { @@ -119,11 +118,9 @@ TEST_F(EnergyPlusFixture, MultiStage4PipeFanCoilHeatingTest) state->dataEnvrn->StdRhoAir = 1.20; state->dataWaterCoils->GetWaterCoilsInputFlag = true; state->dataGlobalNames->NumCoils = 0; - state->dataGlobal->NumOfTimeStepInHour = 1; + state->dataGlobal->TimeStepsInHour = 1; state->dataGlobal->TimeStep = 1; - state->dataGlobal->MinutesPerTimeStep = 60; - - InitializePsychRoutines(*state); + state->dataGlobal->MinutesInTimeStep = 60; std::string const idf_objects = delimited_string({ " Zone,", @@ -247,12 +244,13 @@ TEST_F(EnergyPlusFixture, MultiStage4PipeFanCoilHeatingTest) ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + GetZoneData(*state, ErrorsFound); + EXPECT_EQ("EAST ZONE", state->dataHeatBal->Zone(1).Name); GetZoneEquipmentData(*state); - ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; GetFanInput(*state); EXPECT_EQ((int)HVAC::FanType::OnOff, (int)state->dataFans->fans(1)->type); @@ -401,7 +399,7 @@ TEST_F(EnergyPlusFixture, MultiStage4PipeFanCoilHeatingTest) state->dataEnvrn->DayOfWeek = 2; state->dataEnvrn->HolidayIndex = 0; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); - UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); CalcMultiStage4PipeFanCoil(*state, FanCoilNum, ZoneNum, FirstHVACIteration, QZnReq, SpeedRatio, PartLoadRatio, QUnitOut); @@ -440,11 +438,9 @@ TEST_F(EnergyPlusFixture, MultiStage4PipeFanCoilCoolingTest) state->dataEnvrn->StdRhoAir = 1.20; state->dataWaterCoils->GetWaterCoilsInputFlag = true; state->dataGlobalNames->NumCoils = 0; - state->dataGlobal->NumOfTimeStepInHour = 1; + state->dataGlobal->TimeStepsInHour = 1; state->dataGlobal->TimeStep = 1; - state->dataGlobal->MinutesPerTimeStep = 60; - - InitializePsychRoutines(*state); + state->dataGlobal->MinutesInTimeStep = 60; std::string const idf_objects = delimited_string({ " Zone,", @@ -570,12 +566,11 @@ TEST_F(EnergyPlusFixture, MultiStage4PipeFanCoilCoolingTest) ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); GetZoneData(*state, ErrorsFound); EXPECT_EQ("EAST ZONE", state->dataHeatBal->Zone(1).Name); GetZoneEquipmentData(*state); - ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; GetFanInput(*state); EXPECT_EQ((int)HVAC::FanType::OnOff, (int)state->dataFans->fans(1)->type); @@ -724,7 +719,7 @@ TEST_F(EnergyPlusFixture, MultiStage4PipeFanCoilCoolingTest) state->dataEnvrn->DayOfWeek = 2; state->dataEnvrn->HolidayIndex = 0; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); - UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); CalcMultiStage4PipeFanCoil(*state, FanCoilNum, ZoneNum, FirstHVACIteration, QZnReq, SpeedRatio, PartLoadRatio, QUnitOut); @@ -761,11 +756,9 @@ TEST_F(EnergyPlusFixture, ConstantFanVariableFlowFanCoilHeatingTest) state->dataEnvrn->StdRhoAir = 1.20; state->dataWaterCoils->GetWaterCoilsInputFlag = true; state->dataGlobalNames->NumCoils = 0; - state->dataGlobal->NumOfTimeStepInHour = 1; + state->dataGlobal->TimeStepsInHour = 1; state->dataGlobal->TimeStep = 1; - state->dataGlobal->MinutesPerTimeStep = 60; - - InitializePsychRoutines(*state); + state->dataGlobal->MinutesInTimeStep = 60; std::string const idf_objects = delimited_string({ " Zone,", @@ -889,12 +882,12 @@ TEST_F(EnergyPlusFixture, ConstantFanVariableFlowFanCoilHeatingTest) ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + GetZoneData(*state, ErrorsFound); EXPECT_EQ("EAST ZONE", state->dataHeatBal->Zone(1).Name); GetZoneEquipmentData(*state); - ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; GetFanInput(*state); EXPECT_EQ((int)HVAC::FanType::OnOff, (int)state->dataFans->fans(1)->type); @@ -996,7 +989,7 @@ TEST_F(EnergyPlusFixture, ConstantFanVariableFlowFanCoilHeatingTest) } state->dataHeatBalFanSys->TempControlType.allocate(1); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::DualSetPointWithDeadBand; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::DualHeatCool; state->dataWaterCoils->WaterCoil(2).WaterPlantLoc.loopNum = 1; state->dataWaterCoils->WaterCoil(2).WaterPlantLoc.loopSideNum = DataPlant::LoopSideLocation::Demand; @@ -1069,7 +1062,7 @@ TEST_F(EnergyPlusFixture, ConstantFanVariableFlowFanCoilHeatingTest) state->dataEnvrn->DayOfWeek = 2; state->dataEnvrn->HolidayIndex = 0; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); - UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); // Normal heating simulation for fan coil with constant fan, variable water flow Sim4PipeFanCoil(*state, FanCoilNum, ZoneNum, FirstHVACIteration, QUnitOut, LatOutputProvided); @@ -1169,11 +1162,9 @@ TEST_F(EnergyPlusFixture, ElectricCoilFanCoilHeatingTest) state->dataEnvrn->StdRhoAir = 1.20; state->dataWaterCoils->GetWaterCoilsInputFlag = true; state->dataGlobalNames->NumCoils = 0; - state->dataGlobal->NumOfTimeStepInHour = 1; + state->dataGlobal->TimeStepsInHour = 1; state->dataGlobal->TimeStep = 1; - state->dataGlobal->MinutesPerTimeStep = 60; - - InitializePsychRoutines(*state); + state->dataGlobal->MinutesInTimeStep = 60; std::string const idf_objects = delimited_string({ " Zone,", @@ -1288,12 +1279,12 @@ TEST_F(EnergyPlusFixture, ElectricCoilFanCoilHeatingTest) ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + GetZoneData(*state, ErrorsFound); EXPECT_EQ("EAST ZONE", state->dataHeatBal->Zone(1).Name); GetZoneEquipmentData(*state); - ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; GetFanInput(*state); EXPECT_EQ((int)HVAC::FanType::OnOff, (int)state->dataFans->fans(1)->type); @@ -1385,7 +1376,7 @@ TEST_F(EnergyPlusFixture, ElectricCoilFanCoilHeatingTest) } state->dataHeatBalFanSys->TempControlType.allocate(1); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::DualSetPointWithDeadBand; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::DualHeatCool; state->dataWaterCoils->WaterCoil(1).WaterPlantLoc.loopNum = 1; state->dataWaterCoils->WaterCoil(1).WaterPlantLoc.loopSideNum = DataPlant::LoopSideLocation::Demand; @@ -1440,7 +1431,7 @@ TEST_F(EnergyPlusFixture, ElectricCoilFanCoilHeatingTest) state->dataEnvrn->DayOfWeek = 2; state->dataEnvrn->HolidayIndex = 0; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); - UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); // Normal heating simulation for fan coil with constant fan, electric heating Sim4PipeFanCoil(*state, FanCoilNum, ZoneNum, FirstHVACIteration, QUnitOut, LatOutputProvided); @@ -1486,11 +1477,9 @@ TEST_F(EnergyPlusFixture, ConstantFanVariableFlowFanCoilCoolingTest) state->dataEnvrn->StdRhoAir = 1.20; state->dataWaterCoils->GetWaterCoilsInputFlag = true; state->dataGlobalNames->NumCoils = 0; - state->dataGlobal->NumOfTimeStepInHour = 1; + state->dataGlobal->TimeStepsInHour = 1; state->dataGlobal->TimeStep = 1; - state->dataGlobal->MinutesPerTimeStep = 60; - - InitializePsychRoutines(*state); + state->dataGlobal->MinutesInTimeStep = 60; std::string const idf_objects = delimited_string({ " Zone,", @@ -1616,12 +1605,12 @@ TEST_F(EnergyPlusFixture, ConstantFanVariableFlowFanCoilCoolingTest) ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + GetZoneData(*state, ErrorsFound); EXPECT_EQ("EAST ZONE", state->dataHeatBal->Zone(1).Name); GetZoneEquipmentData(*state); - ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; GetFanInput(*state); EXPECT_EQ((int)HVAC::FanType::OnOff, (int)state->dataFans->fans(1)->type); @@ -1724,7 +1713,7 @@ TEST_F(EnergyPlusFixture, ConstantFanVariableFlowFanCoilCoolingTest) } state->dataHeatBalFanSys->TempControlType.allocate(1); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::DualSetPointWithDeadBand; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::DualHeatCool; state->dataWaterCoils->WaterCoil(2).WaterPlantLoc.loopNum = 1; state->dataWaterCoils->WaterCoil(2).WaterPlantLoc.loopSideNum = DataPlant::LoopSideLocation::Demand; @@ -1797,7 +1786,7 @@ TEST_F(EnergyPlusFixture, ConstantFanVariableFlowFanCoilCoolingTest) state->dataEnvrn->DayOfWeek = 2; state->dataEnvrn->HolidayIndex = 0; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); - UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); // normal cooling simulation for constant fan variable flow fan coil Sim4PipeFanCoil(*state, FanCoilNum, ZoneNum, FirstHVACIteration, QUnitOut, LatOutputProvided); EXPECT_NEAR(QZnReq, QUnitOut, 5.0); @@ -1854,13 +1843,11 @@ TEST_F(EnergyPlusFixture, FanCoil_ASHRAE90VariableFan) state->dataEnvrn->StdRhoAir = 1.20; state->dataWaterCoils->GetWaterCoilsInputFlag = true; state->dataGlobalNames->NumCoils = 0; - state->dataGlobal->NumOfTimeStepInHour = 1; + state->dataGlobal->TimeStepsInHour = 1; state->dataGlobal->TimeStep = 1; - state->dataGlobal->MinutesPerTimeStep = 60; + state->dataGlobal->MinutesInTimeStep = 60; state->dataSize->CurZoneEqNum = 1; - InitializePsychRoutines(*state); - std::string const idf_objects = delimited_string({ " Zone,", " EAST ZONE, !- Name", @@ -1988,12 +1975,12 @@ TEST_F(EnergyPlusFixture, FanCoil_ASHRAE90VariableFan) ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + GetZoneData(*state, ErrorsFound); EXPECT_EQ("EAST ZONE", state->dataHeatBal->Zone(1).Name); GetZoneEquipmentData(*state); - ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; GetFanInput(*state); EXPECT_EQ((int)HVAC::FanType::OnOff, (int)state->dataFans->fans(1)->type); @@ -2147,7 +2134,7 @@ TEST_F(EnergyPlusFixture, FanCoil_ASHRAE90VariableFan) state->dataEnvrn->DayOfWeek = 2; state->dataEnvrn->HolidayIndex = 0; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); - UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); state->dataSize->ZoneEqSizing.allocate(1); state->dataSize->ZoneEqSizing(state->dataSize->CurZoneEqNum).SizingMethod.allocate(HVAC::NumOfSizingTypes); @@ -2155,7 +2142,7 @@ TEST_F(EnergyPlusFixture, FanCoil_ASHRAE90VariableFan) state->dataZoneEnergyDemand->CurDeadBandOrSetback.allocate(1); state->dataZoneEnergyDemand->CurDeadBandOrSetback(1) = false; state->dataHeatBalFanSys->TempControlType.allocate(1); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::DualSetPointWithDeadBand; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::DualHeatCool; state->dataSize->ZoneSizingRunDone = true; state->dataSize->FinalZoneSizing.allocate(1); state->dataSize->FinalZoneSizing(state->dataSize->CurZoneEqNum).DesCoolVolFlow = 0.5; @@ -2262,7 +2249,6 @@ TEST_F(EnergyPlusFixture, FanCoil_ASHRAE90VariableFan) TEST_F(EnergyPlusFixture, Test_TightenWaterFlowLimits) { - using General::SolveRoot; int FanCoilNum(1); @@ -2274,11 +2260,9 @@ TEST_F(EnergyPlusFixture, Test_TightenWaterFlowLimits) state->dataEnvrn->StdRhoAir = 1.20; state->dataWaterCoils->GetWaterCoilsInputFlag = true; state->dataGlobalNames->NumCoils = 0; - state->dataGlobal->NumOfTimeStepInHour = 1; + state->dataGlobal->TimeStepsInHour = 1; state->dataGlobal->TimeStep = 1; - state->dataGlobal->MinutesPerTimeStep = 60; - - InitializePsychRoutines(*state); + state->dataGlobal->MinutesInTimeStep = 60; std::string const idf_objects = delimited_string({ " Zone, EAST ZONE, 0, 0, 0, 0, 1, 1, autocalculate, autocalculate;", @@ -2325,13 +2309,11 @@ TEST_F(EnergyPlusFixture, Test_TightenWaterFlowLimits) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); // OutputProcessor::TimeValue.allocate(2); GetZoneData(*state, ErrorsFound); GetZoneEquipmentData(*state); - ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; SetPredefinedTables(*state); GetFanInput(*state); GetFanCoilUnits(*state); @@ -2397,8 +2379,7 @@ TEST_F(EnergyPlusFixture, Test_TightenWaterFlowLimits) state->dataEnvrn->DayOfYear_Schedule = 1; state->dataEnvrn->DayOfWeek = 2; state->dataGlobal->HourOfDay = 1; - ProcessScheduleInput(*state); - UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); // fan coil can hit maximum iterations while trying to find the water mass flow rate to meet the load. In this case RegulaFalsi will return -1. // When this happens, this routine will find tighter limits on min/max water flow rate passed to RegulaFalsi @@ -2578,13 +2559,11 @@ TEST_F(EnergyPlusFixture, FanCoil_CyclingFanMode) state->dataEnvrn->StdRhoAir = 1.20; state->dataWaterCoils->GetWaterCoilsInputFlag = true; state->dataGlobalNames->NumCoils = 0; - state->dataGlobal->NumOfTimeStepInHour = 1; + state->dataGlobal->TimeStepsInHour = 1; state->dataGlobal->TimeStep = 1; - state->dataGlobal->MinutesPerTimeStep = 60; + state->dataGlobal->MinutesInTimeStep = 60; state->dataSize->CurZoneEqNum = 1; - InitializePsychRoutines(*state); - std::string const idf_objects = delimited_string({ " Zone,", " EAST ZONE, !- Name", @@ -2719,12 +2698,12 @@ TEST_F(EnergyPlusFixture, FanCoil_CyclingFanMode) ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + GetZoneData(*state, ErrorsFound); EXPECT_EQ("EAST ZONE", state->dataHeatBal->Zone(1).Name); GetZoneEquipmentData(*state); - ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; GetFanInput(*state); EXPECT_EQ((int)HVAC::FanType::OnOff, (int)state->dataFans->fans(1)->type); @@ -2878,7 +2857,7 @@ TEST_F(EnergyPlusFixture, FanCoil_CyclingFanMode) state->dataEnvrn->DayOfWeek = 2; state->dataEnvrn->HolidayIndex = 0; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); - UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); state->dataSize->ZoneEqSizing.allocate(1); state->dataSize->ZoneEqSizing(state->dataSize->CurZoneEqNum).SizingMethod.allocate(HVAC::NumOfSizingTypes); @@ -2886,7 +2865,7 @@ TEST_F(EnergyPlusFixture, FanCoil_CyclingFanMode) state->dataZoneEnergyDemand->CurDeadBandOrSetback.allocate(1); state->dataZoneEnergyDemand->CurDeadBandOrSetback(1) = false; state->dataHeatBalFanSys->TempControlType.allocate(1); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::DualSetPointWithDeadBand; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::DualHeatCool; state->dataSize->ZoneSizingRunDone = true; state->dataSize->FinalZoneSizing.allocate(1); state->dataSize->FinalZoneSizing(state->dataSize->CurZoneEqNum).DesCoolVolFlow = 0.5; @@ -2993,7 +2972,6 @@ TEST_F(EnergyPlusFixture, FanCoil_CyclingFanMode) TEST_F(EnergyPlusFixture, FanCoil_FanSystemModelCyclingFanMode) { - int FanCoilNum(1); int ZoneNum(1); bool FirstHVACIteration(false); @@ -3010,13 +2988,11 @@ TEST_F(EnergyPlusFixture, FanCoil_FanSystemModelCyclingFanMode) state->dataEnvrn->StdRhoAir = 1.20; state->dataWaterCoils->GetWaterCoilsInputFlag = true; state->dataGlobalNames->NumCoils = 0; - state->dataGlobal->NumOfTimeStepInHour = 1; + state->dataGlobal->TimeStepsInHour = 1; state->dataGlobal->TimeStep = 1; - state->dataGlobal->MinutesPerTimeStep = 60; + state->dataGlobal->MinutesInTimeStep = 60; state->dataSize->CurZoneEqNum = 1; - InitializePsychRoutines(*state); - std::string const idf_objects = delimited_string({ " Zone,", " EAST ZONE, !- Name", @@ -3164,13 +3140,12 @@ TEST_F(EnergyPlusFixture, FanCoil_FanSystemModelCyclingFanMode) ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + GetZoneData(*state, ErrorsFound); EXPECT_EQ("EAST ZONE", state->dataHeatBal->Zone(1).Name); GetZoneEquipmentData(*state); - ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; - GetFanCoilUnits(*state); auto &thisFanCoil(state->dataFanCoilUnits->FanCoil(1)); @@ -3306,7 +3281,7 @@ TEST_F(EnergyPlusFixture, FanCoil_FanSystemModelCyclingFanMode) state->dataEnvrn->DayOfWeek = 2; state->dataEnvrn->HolidayIndex = 0; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); - UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); state->dataSize->ZoneEqSizing.allocate(1); state->dataSize->ZoneEqSizing(state->dataSize->CurZoneEqNum).SizingMethod.allocate(HVAC::NumOfSizingTypes); @@ -3314,7 +3289,7 @@ TEST_F(EnergyPlusFixture, FanCoil_FanSystemModelCyclingFanMode) state->dataZoneEnergyDemand->CurDeadBandOrSetback.allocate(1); state->dataZoneEnergyDemand->CurDeadBandOrSetback(1) = false; state->dataHeatBalFanSys->TempControlType.allocate(1); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::DualSetPointWithDeadBand; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::DualHeatCool; state->dataSize->ZoneSizingRunDone = true; state->dataSize->FinalZoneSizing.allocate(1); state->dataSize->FinalZoneSizing(state->dataSize->CurZoneEqNum).DesCoolVolFlow = 0.5; @@ -3397,7 +3372,6 @@ TEST_F(EnergyPlusFixture, FanCoil_FanSystemModelCyclingFanMode) TEST_F(EnergyPlusFixture, FanCoil_ElecHeatCoilMultiSpeedFanCyclingFanMode) { - int FanCoilNum(1); int ZoneNum(1); bool FirstHVACIteration(false); @@ -3413,13 +3387,11 @@ TEST_F(EnergyPlusFixture, FanCoil_ElecHeatCoilMultiSpeedFanCyclingFanMode) state->dataEnvrn->StdRhoAir = 1.20; state->dataWaterCoils->GetWaterCoilsInputFlag = true; state->dataGlobalNames->NumCoils = 0; - state->dataGlobal->NumOfTimeStepInHour = 1; + state->dataGlobal->TimeStepsInHour = 1; state->dataGlobal->TimeStep = 1; - state->dataGlobal->MinutesPerTimeStep = 60; + state->dataGlobal->MinutesInTimeStep = 60; state->dataSize->CurZoneEqNum = 1; - InitializePsychRoutines(*state); - std::string const idf_objects = delimited_string({ " Zone,", " EAST ZONE, !- Name", @@ -3566,11 +3538,11 @@ TEST_F(EnergyPlusFixture, FanCoil_ElecHeatCoilMultiSpeedFanCyclingFanMode) ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + GetZoneData(*state, ErrorsFound); EXPECT_EQ("EAST ZONE", state->dataHeatBal->Zone(1).Name); GetZoneEquipmentData(*state); - ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; GetFanCoilUnits(*state); auto &thisFanCoil(state->dataFanCoilUnits->FanCoil(1)); EXPECT_ENUM_EQ(CCM::MultiSpeedFan, thisFanCoil.CapCtrlMeth_Num); @@ -3668,14 +3640,14 @@ TEST_F(EnergyPlusFixture, FanCoil_ElecHeatCoilMultiSpeedFanCyclingFanMode) state->dataEnvrn->DayOfWeek = 2; state->dataEnvrn->HolidayIndex = 0; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); - UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); state->dataSize->ZoneEqSizing.allocate(1); state->dataSize->ZoneEqSizing(state->dataSize->CurZoneEqNum).SizingMethod.allocate(HVAC::NumOfSizingTypes); state->dataSize->ZoneEqSizing(state->dataSize->CurZoneEqNum).SizingMethod = 0; state->dataZoneEnergyDemand->CurDeadBandOrSetback.allocate(1); state->dataZoneEnergyDemand->CurDeadBandOrSetback(1) = false; state->dataHeatBalFanSys->TempControlType.allocate(1); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::DualSetPointWithDeadBand; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::DualHeatCool; state->dataSize->ZoneSizingRunDone = true; state->dataSize->FinalZoneSizing.allocate(1); auto &fZoneSizing(state->dataSize->FinalZoneSizing(1)); @@ -3763,7 +3735,6 @@ TEST_F(EnergyPlusFixture, FanCoil_ElecHeatCoilMultiSpeedFanCyclingFanMode) TEST_F(EnergyPlusFixture, FanCoil_ElecHeatCoilMultiSpeedFanContFanMode) { - int FanCoilNum(1); int ZoneNum(1); bool FirstHVACIteration(false); @@ -3779,13 +3750,11 @@ TEST_F(EnergyPlusFixture, FanCoil_ElecHeatCoilMultiSpeedFanContFanMode) state->dataEnvrn->StdRhoAir = 1.20; state->dataWaterCoils->GetWaterCoilsInputFlag = true; state->dataGlobalNames->NumCoils = 0; - state->dataGlobal->NumOfTimeStepInHour = 1; + state->dataGlobal->TimeStepsInHour = 1; state->dataGlobal->TimeStep = 1; - state->dataGlobal->MinutesPerTimeStep = 60; + state->dataGlobal->MinutesInTimeStep = 60; state->dataSize->CurZoneEqNum = 1; - InitializePsychRoutines(*state); - std::string const idf_objects = delimited_string({ " Zone,", " EAST ZONE, !- Name", @@ -3932,11 +3901,11 @@ TEST_F(EnergyPlusFixture, FanCoil_ElecHeatCoilMultiSpeedFanContFanMode) ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + GetZoneData(*state, ErrorsFound); EXPECT_EQ("EAST ZONE", state->dataHeatBal->Zone(1).Name); GetZoneEquipmentData(*state); - ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; GetFanCoilUnits(*state); auto &thisFanCoil(state->dataFanCoilUnits->FanCoil(1)); EXPECT_ENUM_EQ(CCM::MultiSpeedFan, thisFanCoil.CapCtrlMeth_Num); @@ -4034,14 +4003,14 @@ TEST_F(EnergyPlusFixture, FanCoil_ElecHeatCoilMultiSpeedFanContFanMode) state->dataEnvrn->DayOfWeek = 2; state->dataEnvrn->HolidayIndex = 0; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); - UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); state->dataSize->ZoneEqSizing.allocate(1); state->dataSize->ZoneEqSizing(state->dataSize->CurZoneEqNum).SizingMethod.allocate(HVAC::NumOfSizingTypes); state->dataSize->ZoneEqSizing(state->dataSize->CurZoneEqNum).SizingMethod = 0; state->dataZoneEnergyDemand->CurDeadBandOrSetback.allocate(1); state->dataZoneEnergyDemand->CurDeadBandOrSetback(1) = false; state->dataHeatBalFanSys->TempControlType.allocate(1); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::DualSetPointWithDeadBand; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::DualHeatCool; state->dataSize->ZoneSizingRunDone = true; state->dataSize->FinalZoneSizing.allocate(1); auto &fZoneSizing(state->dataSize->FinalZoneSizing(1)); @@ -4129,7 +4098,6 @@ TEST_F(EnergyPlusFixture, FanCoil_ElecHeatCoilMultiSpeedFanContFanMode) TEST_F(EnergyPlusFixture, FanCoil_CalcFanCoilElecHeatCoilPLRResidual) { - int FanCoilNum(1); int ZoneNum(1); bool FirstHVACIteration(false); @@ -4145,13 +4113,11 @@ TEST_F(EnergyPlusFixture, FanCoil_CalcFanCoilElecHeatCoilPLRResidual) state->dataEnvrn->StdRhoAir = 1.20; state->dataWaterCoils->GetWaterCoilsInputFlag = true; state->dataGlobalNames->NumCoils = 0; - state->dataGlobal->NumOfTimeStepInHour = 1; + state->dataGlobal->TimeStepsInHour = 1; state->dataGlobal->TimeStep = 1; - state->dataGlobal->MinutesPerTimeStep = 60; + state->dataGlobal->MinutesInTimeStep = 60; state->dataSize->CurZoneEqNum = 1; - InitializePsychRoutines(*state); - std::string const idf_objects = delimited_string({ " Zone,", " EAST ZONE, !- Name", @@ -4298,11 +4264,11 @@ TEST_F(EnergyPlusFixture, FanCoil_CalcFanCoilElecHeatCoilPLRResidual) ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + GetZoneData(*state, ErrorsFound); EXPECT_EQ("EAST ZONE", state->dataHeatBal->Zone(1).Name); GetZoneEquipmentData(*state); - ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; GetFanCoilUnits(*state); auto &thisFanCoil(state->dataFanCoilUnits->FanCoil(1)); EXPECT_ENUM_EQ(CCM::MultiSpeedFan, thisFanCoil.CapCtrlMeth_Num); @@ -4400,14 +4366,14 @@ TEST_F(EnergyPlusFixture, FanCoil_CalcFanCoilElecHeatCoilPLRResidual) state->dataEnvrn->DayOfWeek = 2; state->dataEnvrn->HolidayIndex = 0; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); - UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); state->dataSize->ZoneEqSizing.allocate(1); state->dataSize->ZoneEqSizing(state->dataSize->CurZoneEqNum).SizingMethod.allocate(HVAC::NumOfSizingTypes); state->dataSize->ZoneEqSizing(state->dataSize->CurZoneEqNum).SizingMethod = 0; state->dataZoneEnergyDemand->CurDeadBandOrSetback.allocate(1); state->dataZoneEnergyDemand->CurDeadBandOrSetback(1) = false; state->dataHeatBalFanSys->TempControlType.allocate(1); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::DualSetPointWithDeadBand; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::DualHeatCool; state->dataSize->ZoneSizingRunDone = true; state->dataSize->FinalZoneSizing.allocate(1); auto &fZoneSizing(state->dataSize->FinalZoneSizing(1)); @@ -4474,7 +4440,6 @@ TEST_F(EnergyPlusFixture, FanCoil_CalcFanCoilElecHeatCoilPLRResidual) TEST_F(EnergyPlusFixture, FanCoil_ElectricHeatingCoilASHRAE90VariableFan) { - int FanCoilNum(1); int ZoneNum(1); bool FirstHVACIteration(false); @@ -4606,17 +4571,16 @@ TEST_F(EnergyPlusFixture, FanCoil_ElectricHeatingCoilASHRAE90VariableFan) state->dataEnvrn->StdRhoAir = 1.20; state->dataWaterCoils->GetWaterCoilsInputFlag = true; // NumCoils = 0; - state->dataGlobal->NumOfTimeStepInHour = 1; + state->dataGlobal->TimeStepsInHour = 1; state->dataGlobal->TimeStep = 1; - state->dataGlobal->MinutesPerTimeStep = 60; + state->dataGlobal->MinutesInTimeStep = 60; state->dataSize->CurZoneEqNum = 1; - InitializePsychRoutines(*state); + + state->init_state(*state); GetZoneData(*state, ErrorsFound); EXPECT_EQ("WEST ZONE", state->dataHeatBal->Zone(1).Name); GetZoneEquipmentData(*state); - ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; GetFanCoilUnits(*state); auto &thisFanCoil(state->dataFanCoilUnits->FanCoil(1)); EXPECT_ENUM_EQ(CCM::ASHRAE, thisFanCoil.CapCtrlMeth_Num); @@ -4704,12 +4668,12 @@ TEST_F(EnergyPlusFixture, FanCoil_ElectricHeatingCoilASHRAE90VariableFan) state->dataEnvrn->DayOfWeek = 2; state->dataEnvrn->HolidayIndex = 0; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); - UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); state->dataSize->ZoneEqSizing.allocate(1); state->dataZoneEnergyDemand->CurDeadBandOrSetback.allocate(1); state->dataZoneEnergyDemand->CurDeadBandOrSetback(1) = false; state->dataHeatBalFanSys->TempControlType.allocate(1); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::DualSetPointWithDeadBand; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::DualHeatCool; state->dataSize->ZoneSizingRunDone = true; state->dataGlobal->SysSizingCalc = true; thisFanCoil.DesignHeatingCapacity = 6000.0; diff --git a/tst/EnergyPlus/unit/Fans.unit.cc b/tst/EnergyPlus/unit/Fans.unit.cc index 8d4b76333a6..5a4f8d91499 100644 --- a/tst/EnergyPlus/unit/Fans.unit.cc +++ b/tst/EnergyPlus/unit/Fans.unit.cc @@ -64,6 +64,7 @@ using namespace EnergyPlus::Fans; TEST_F(EnergyPlusFixture, Fans_FanSizing) { + // state->init_state(*state); state->dataSize->CurZoneEqNum = 0; state->dataSize->CurSysNum = 0; state->dataSize->CurOASysNum = 0; @@ -100,6 +101,7 @@ TEST_F(EnergyPlusFixture, Fans_FanSizing) TEST_F(EnergyPlusFixture, Fans_ConstantVolume_EMSPressureRiseResetTest) { + state->init_state(*state); // set standard air density state->dataEnvrn->StdRhoAir = 1.0; @@ -114,7 +116,7 @@ TEST_F(EnergyPlusFixture, Fans_ConstantVolume_EMSPressureRiseResetTest) fan1->totalEff = 1.0; fan1->motorEff = 0.8; fan1->motorInAirFrac = 1.0; - fan1->availSchedNum = 0; + fan1->availSched = Sched::GetScheduleAlwaysOff(*state); fan1->maxAirFlowRate = 1.0; fan1->minAirMassFlowRate = 0.0; fan1->maxAirMassFlowRate = fan1->maxAirFlowRate; @@ -141,8 +143,10 @@ TEST_F(EnergyPlusFixture, Fans_ConstantVolume_EMSPressureRiseResetTest) Real64 Result2_FanPower = max(0.0, fan1->maxAirMassFlowRate * fan1->EMSPressureValue / (fan1->totalEff * fan1->rhoAirStdInit)); EXPECT_DOUBLE_EQ(Result2_FanPower, fan1->totalPower); // expects zero } + TEST_F(EnergyPlusFixture, Fans_OnOff_EMSPressureRiseResetTest) { + state->init_state(*state); // set standard air density state->dataEnvrn->StdRhoAir = 1.0; // set fan model inputs @@ -157,7 +161,7 @@ TEST_F(EnergyPlusFixture, Fans_OnOff_EMSPressureRiseResetTest) fan1->totalEff = 1.0; fan1->motorEff = 0.8; fan1->motorInAirFrac = 1.0; - fan1->availSchedNum = 0; + fan1->availSched = Sched::GetScheduleAlwaysOff(*state); fan1->maxAirFlowRate = 1.0; fan1->minAirMassFlowRate = 0.0; fan1->maxAirMassFlowRate = fan1->maxAirFlowRate; @@ -186,8 +190,10 @@ TEST_F(EnergyPlusFixture, Fans_OnOff_EMSPressureRiseResetTest) Real64 Result2_FanPower = max(0.0, fan1->maxAirMassFlowRate * fan1->EMSPressureValue / (fan1->totalEff * fan1->rhoAirStdInit)); EXPECT_DOUBLE_EQ(Result2_FanPower, fan1->totalPower); // expects zero } + TEST_F(EnergyPlusFixture, Fans_VariableVolume_EMSPressureRiseResetTest) { + state->init_state(*state); // set standard air density state->dataEnvrn->StdRhoAir = 1.0; // set fan model inputs @@ -200,7 +206,7 @@ TEST_F(EnergyPlusFixture, Fans_VariableVolume_EMSPressureRiseResetTest) fan1->totalEff = 1.0; fan1->motorEff = 0.8; fan1->motorInAirFrac = 1.0; - fan1->availSchedNum = 0; + fan1->availSched = Sched::GetScheduleAlwaysOff(*state); fan1->maxAirFlowRate = 1.0; fan1->minAirMassFlowRate = 0.0; fan1->maxAirMassFlowRate = fan1->maxAirFlowRate; diff --git a/tst/EnergyPlus/unit/FaultsManager.unit.cc b/tst/EnergyPlus/unit/FaultsManager.unit.cc index ad199ffcd75..39568aadfec 100644 --- a/tst/EnergyPlus/unit/FaultsManager.unit.cc +++ b/tst/EnergyPlus/unit/FaultsManager.unit.cc @@ -75,7 +75,6 @@ using namespace Curve; using namespace DataLoopNode; using namespace Fans; using namespace FaultsManager; -using namespace EnergyPlus::ScheduleManager; namespace EnergyPlus { @@ -85,7 +84,8 @@ TEST_F(EnergyPlusFixture, FaultsManager_FaultFoulingAirFilters_CheckFaultyAirFil // To check whether the fan curve specified in the FaultModel:Fouling:AirFilter object // covers the rated operational point of the corresponding fan // Return true if the curve covers the fan rated operational point - + state->init_state(*state); + int numFans = 2; bool TestResult; @@ -218,6 +218,7 @@ TEST_F(EnergyPlusFixture, FaultsManager_FaultFoulingAirFilters_CheckFaultyAirFil // Process inputs ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); state->dataEnvrn->StdRhoAir = 1.2; @@ -305,6 +306,7 @@ TEST_F(EnergyPlusFixture, FaultsManager_FaultFoulingAirFilters_CheckFaultyAirFil // Process inputs ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); state->dataEnvrn->StdRhoAir = 1.2; @@ -343,6 +345,8 @@ TEST_F(EnergyPlusFixture, FaultsManager_FaultFoulingAirFilters_CalFaultyFanAirFl double FanDesignFlowRateDec; double FanFaultyDeltaPressInc = 0.10; // Increase by 10% + state->init_state(*state); + // Allocate state->dataCurveManager->allocateCurveVector(1); @@ -421,6 +425,7 @@ TEST_F(EnergyPlusFixture, FaultsManager_TemperatureSensorOffset_CoilSAT) // Process inputs ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); // Readin inputs SetPointManager::GetSetPointManagerInputs(*state); @@ -442,6 +447,8 @@ TEST_F(EnergyPlusFixture, FaultsManager_FaultChillerSWTSensor_CalFaultChillerSWT // PURPOSE OF THIS SUBROUTINE: // To check CalFaultChillerSWT which calculates the mass flow rate and supply water temperature of a chiller with faulty SWT sensor. + state->init_state(*state); + bool FlagVariableFlow; // True if chiller is variable flow and false if it is constant flow Real64 FaultyChillerSWTOffset; // Faulty chiller SWT sensor offset Real64 Cp = 4500; // Local fluid specific heat @@ -484,12 +491,13 @@ TEST_F(EnergyPlusFixture, FaultsManager_CalFaultOffsetAct) { // PURPOSE OF THIS SUBROUTINE: // To check CalFaultOffsetAct which calculates the dynamic fault offset based on the fault availability schedule and severity schedule. + state->init_state(*state); Real64 OffsetAct; FaultProperties Fault; - Fault.availSchedNum = -1; - Fault.severitySchedNum = -1; + Fault.availSched = Sched::GetScheduleAlwaysOn(*state); + Fault.severitySched = Sched::GetScheduleAlwaysOn(*state); Fault.Offset = 10; // Run and Check @@ -611,8 +619,7 @@ TEST_F(EnergyPlusFixture, FaultsManager_EconomizerFaultGetInput) // Process inputs ASSERT_TRUE(process_idf(idf_objects)); - - ScheduleManager::ProcessScheduleInput(*state); // read schedules + state->init_state(*state); MixedAir::GetOAControllerInputs(*state); @@ -657,10 +664,14 @@ TEST_F(EnergyPlusFixture, FaultsManager_FoulingCoil_CoilNotFound) // Process inputs ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); ASSERT_THROW(FaultsManager::CheckAndReadFaults(*state), std::runtime_error); std::string const error_string = delimited_string({ + " ** Warning ** ProcessScheduleInput: Schedule:Compact = AVAILSCHED", + " ** ~~~ ** Schedule Type Limits Name is empty.", + " ** ~~~ ** Schedule will not be validated.", " ** Severe ** FaultModel:Fouling:Coil = \"FOULEDHEATINGCOIL\". Referenced Coil named \"NON EXISTENT COOLING COIL\" was not found.", " ** Fatal ** CheckAndReadFaults: Errors found in getting FaultModel input data. Preceding condition(s) cause termination.", " ...Summary of Errors that led to program termination:", @@ -722,10 +733,14 @@ TEST_F(EnergyPlusFixture, FaultsManager_FoulingCoil_BadCoilType) // Process inputs ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + ASSERT_THROW(FaultsManager::CheckAndReadFaults(*state), std::runtime_error); std::string const error_string = delimited_string({ + " ** Warning ** ProcessScheduleInput: Schedule:Compact = AVAILSCHED", + " ** ~~~ ** Schedule Type Limits Name is empty.", + " ** ~~~ ** Schedule will not be validated.", " ** Severe ** FaultModel:Fouling:Coil = \"FOULEDHEATINGCOIL\" invalid Coil Name = \"DETAILED PRE COOLING COIL\".", " ** ~~~ ** Coil was found but it is not one of the supported types (\"Coil:Cooling:Water\" or \"Coil:Heating:Water\").", " ** Fatal ** CheckAndReadFaults: Errors found in getting FaultModel input data. Preceding condition(s) cause termination.", @@ -839,15 +854,16 @@ TEST_F(EnergyPlusFixture, FaultsManager_FoulingCoil_AssignmentAndCalc) ASSERT_TRUE(process_idf(idf_objects)); state->dataHVACGlobal->TimeStepSys = 1; - state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; - state->dataGlobal->NumOfTimeStepInHour = 4; - state->dataGlobal->MinutesPerTimeStep = 60 / state->dataGlobal->NumOfTimeStepInHour; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; + state->dataGlobal->TimeStepsInHour = 4; + state->dataGlobal->MinutesInTimeStep = 60 / state->dataGlobal->TimeStepsInHour; - ScheduleManager::ProcessScheduleInput(*state); // read schedule data - int avaiSchedIndex = ScheduleManager::GetScheduleIndex(*state, "AVAILSCHED"); - EXPECT_EQ(1, avaiSchedIndex); - int severitySchedIndex = ScheduleManager::GetScheduleIndex(*state, "SEVERITYSCHED"); - EXPECT_EQ(2, severitySchedIndex); + state->init_state(*state); + + auto *avaiSched = Sched::GetSchedule(*state, "AVAILSCHED"); + EXPECT_NE(nullptr, avaiSched); + auto *severitySched = Sched::GetSchedule(*state, "SEVERITYSCHED"); + EXPECT_NE(nullptr, severitySched); // Readin inputs // SetPointManager::GetSetPointManagerInputs(); @@ -861,7 +877,7 @@ TEST_F(EnergyPlusFixture, FaultsManager_FoulingCoil_AssignmentAndCalc) state->dataGlobal->HourOfDay = 1; state->dataEnvrn->DayOfWeek = 1; state->dataEnvrn->DayOfYear_Schedule = 1; - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); EXPECT_EQ(2, state->dataFaultsMgr->NumFouledCoil); // This should also have called WaterCoil::GetWaterCoilInput @@ -882,9 +898,9 @@ TEST_F(EnergyPlusFixture, FaultsManager_FoulingCoil_AssignmentAndCalc) EXPECT_EQ(FaultIndex, state->dataWaterCoils->WaterCoil(CoilNum).FaultyCoilFoulingIndex); // Doesn't have an Availability Schedule - EXPECT_EQ(-1, state->dataFaultsMgr->FouledCoils(FaultIndex).availSchedNum); + EXPECT_EQ(state->dataFaultsMgr->FouledCoils(FaultIndex).availSched->Num, Sched::SchedNum_AlwaysOn); // Has a Severity Schedule - EXPECT_EQ(severitySchedIndex, state->dataFaultsMgr->FouledCoils(FaultIndex).severitySchedNum); + EXPECT_NE(nullptr, state->dataFaultsMgr->FouledCoils(FaultIndex).severitySched); EXPECT_ENUM_EQ(FaultsManager::FouledCoil::UARated, state->dataFaultsMgr->FouledCoils(FaultIndex).FoulingInputMethod); EXPECT_NEAR(3.32, state->dataFaultsMgr->FouledCoils(FaultIndex).UAFouled, 0.0001); @@ -909,9 +925,9 @@ TEST_F(EnergyPlusFixture, FaultsManager_FoulingCoil_AssignmentAndCalc) EXPECT_EQ(FaultIndex, state->dataWaterCoils->WaterCoil(CoilNum).FaultyCoilFoulingIndex); // Has an Availabity Schedule - EXPECT_EQ(avaiSchedIndex, state->dataFaultsMgr->FouledCoils(FaultIndex).availSchedNum); + EXPECT_NE(nullptr, state->dataFaultsMgr->FouledCoils(FaultIndex).availSched); // Has a Severity Schedule - EXPECT_EQ(severitySchedIndex, state->dataFaultsMgr->FouledCoils(FaultIndex).severitySchedNum); + EXPECT_NE(nullptr, state->dataFaultsMgr->FouledCoils(FaultIndex).severitySched); EXPECT_ENUM_EQ(FaultsManager::FouledCoil::FoulingFactor, state->dataFaultsMgr->FouledCoils(FaultIndex).FoulingInputMethod); EXPECT_NEAR(0.0005, state->dataFaultsMgr->FouledCoils(FaultIndex).Rfw, 0.0001); diff --git a/tst/EnergyPlus/unit/FiniteDifferenceGroundTemperatureModel.unit.cc b/tst/EnergyPlus/unit/FiniteDifferenceGroundTemperatureModel.unit.cc index 93ae904eea1..470e1ef4a99 100644 --- a/tst/EnergyPlus/unit/FiniteDifferenceGroundTemperatureModel.unit.cc +++ b/tst/EnergyPlus/unit/FiniteDifferenceGroundTemperatureModel.unit.cc @@ -277,7 +277,7 @@ TEST_F(EnergyPlusFixture, FiniteDiffGroundTempModel_GetWeather_Weather) // Read the project data, such as Timestep state->dataGlobal->BeginSimFlag = true; SimulationManager::GetProjectData(*state); - EXPECT_EQ(state->dataGlobal->NumOfTimeStepInHour, 4); + EXPECT_EQ(state->dataGlobal->TimeStepsInHour, 4); // Needed to avoid crash in SetupSimulation (from ElectricPowerServiceManager.hh) createFacilityElectricPowerServiceObject(*state); diff --git a/tst/EnergyPlus/unit/Fixtures/EnergyPlusFixture.cc b/tst/EnergyPlus/unit/Fixtures/EnergyPlusFixture.cc index 97f3bc54e4a..e76eb6e3cde 100644 --- a/tst/EnergyPlus/unit/Fixtures/EnergyPlusFixture.cc +++ b/tst/EnergyPlus/unit/Fixtures/EnergyPlusFixture.cc @@ -118,8 +118,8 @@ void EnergyPlusFixture::SetUp() state->dataUtilityRoutines->outputErrorHeader = false; - Psychrometrics::InitializePsychRoutines(*state); - createCoilSelectionReportObj(*state); + state->init_constant_state(*state); + createCoilSelectionReportObj(*state); // So random state->dataEnvrn->StdRhoAir = 1.2; } @@ -136,7 +136,8 @@ void EnergyPlusFixture::TearDown() state->files.mtr.del(); state->files.bnd.del(); state->files.shade.del(); - // state->clear_state(); + + state->clear_state(); delete this->state; } @@ -363,7 +364,11 @@ bool EnergyPlusFixture::process_idf(std::string_view const idf_snippet, bool use inputProcessor->initializeMaps(); SimulationManager::PostIPProcessing(*state); - state->init_state(*state); + // Can't do this here because many tests set TimeStepsInHour and + // other global settings manually, and init_state() has to be + // called after those. + + // state->init_state(*state); if (state->dataSQLiteProcedures->sqlite) { bool writeOutputToSQLite = false; diff --git a/tst/EnergyPlus/unit/FluidCoolers.unit.cc b/tst/EnergyPlus/unit/FluidCoolers.unit.cc index 63fcf45c3e8..27fee4d0ebb 100644 --- a/tst/EnergyPlus/unit/FluidCoolers.unit.cc +++ b/tst/EnergyPlus/unit/FluidCoolers.unit.cc @@ -66,7 +66,8 @@ using namespace EnergyPlus::DataSizing; TEST_F(EnergyPlusFixture, TwoSpeedFluidCoolerInput_Test1) { - + state->init_state(*state); + using DataSizing::AutoSize; int StringArraySize = 20; Array1D_string cNumericFieldNames; @@ -136,6 +137,7 @@ TEST_F(EnergyPlusFixture, TwoSpeedFluidCoolerInput_Test1) TEST_F(EnergyPlusFixture, TwoSpeedFluidCoolerInput_Test2) { + state->init_state(*state); using DataSizing::AutoSize; int StringArraySize = 20; @@ -195,6 +197,8 @@ TEST_F(EnergyPlusFixture, TwoSpeedFluidCoolerInput_Test2) TEST_F(EnergyPlusFixture, SingleSpeedFluidCoolerInput_Test3) { + state->init_state(*state); + using DataSizing::AutoSize; int StringArraySize = 20; Array1D_string cNumericFieldNames; @@ -275,6 +279,7 @@ TEST_F(EnergyPlusFixture, SingleSpeedFluidCoolerInput_Test4) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); GetFluidCoolerInput(*state); auto &thisFluidCooler = state->dataFluidCoolers->SimpleFluidCooler(FluidCoolerNum); @@ -285,6 +290,7 @@ TEST_F(EnergyPlusFixture, SingleSpeedFluidCoolerInput_Test4) TEST_F(EnergyPlusFixture, SingleSpeedFluidCoolerInput_Test5) { + state->init_state(*state); using DataSizing::AutoSize; int StringArraySize = 20; Array1D_string cNumericFieldNames; @@ -350,6 +356,7 @@ TEST_F(EnergyPlusFixture, SizeFunctionTestWhenPlantSizingIndexIsZero) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); GetFluidCoolerInput(*state); @@ -386,6 +393,7 @@ TEST_F(EnergyPlusFixture, ExerciseSingleSpeedFluidCooler) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); FluidCoolerspecs *ptr = FluidCoolerspecs::factory(*state, DataPlant::PlantEquipmentType::FluidCooler_SingleSpd, "DRY COOLER"); @@ -457,6 +465,7 @@ TEST_F(EnergyPlusFixture, ExerciseTwoSpeedFluidCooler) "; !- Low Fan Speed Fan Power Sizing Factor"}); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); FluidCoolerspecs *ptr = FluidCoolerspecs::factory(*state, DataPlant::PlantEquipmentType::FluidCooler_TwoSpd, "BIG FLUIDCOOLER"); diff --git a/tst/EnergyPlus/unit/FluidProperties.unit.cc b/tst/EnergyPlus/unit/FluidProperties.unit.cc index 0c883e902da..212f9a99933 100644 --- a/tst/EnergyPlus/unit/FluidProperties.unit.cc +++ b/tst/EnergyPlus/unit/FluidProperties.unit.cc @@ -62,7 +62,6 @@ using namespace EnergyPlus; TEST_F(EnergyPlusFixture, FluidProperties_GetDensityGlycol) { - std::string const idf_objects = delimited_string({"FluidProperties:GlycolConcentration,", " GLHXFluid, !- Name", " PropyleneGlycol, !- Glycol Type", @@ -72,7 +71,8 @@ TEST_F(EnergyPlusFixture, FluidProperties_GetDensityGlycol) ASSERT_TRUE(process_idf(idf_objects)); EXPECT_FALSE(has_err_output()); - + state->init_state(*state); + int FluidIndex = 0; EXPECT_NEAR(1037.89, FluidProperties::GetDensityGlycol(*state, "GLHXFLUID", -35.0, FluidIndex, "UnitTest"), 0.01); @@ -90,7 +90,6 @@ TEST_F(EnergyPlusFixture, FluidProperties_GetDensityGlycol) TEST_F(EnergyPlusFixture, FluidProperties_GetSpecificHeatGlycol) { - std::string const idf_objects = delimited_string({"FluidProperties:GlycolConcentration,", " GLHXFluid, !- Name", " PropyleneGlycol, !- Glycol Type", @@ -100,7 +99,8 @@ TEST_F(EnergyPlusFixture, FluidProperties_GetSpecificHeatGlycol) ASSERT_TRUE(process_idf(idf_objects)); EXPECT_FALSE(has_err_output()); - + state->init_state(*state); + int FluidIndex = 0; EXPECT_NEAR(3779, FluidProperties::GetSpecificHeatGlycol(*state, "GLHXFLUID", -35.0, FluidIndex, "UnitTest"), 0.01); diff --git a/tst/EnergyPlus/unit/FuelCellElectricGenerator.unit.cc b/tst/EnergyPlus/unit/FuelCellElectricGenerator.unit.cc index 340abc252a9..53cf2898994 100644 --- a/tst/EnergyPlus/unit/FuelCellElectricGenerator.unit.cc +++ b/tst/EnergyPlus/unit/FuelCellElectricGenerator.unit.cc @@ -77,7 +77,6 @@ using namespace EnergyPlus; TEST_F(EnergyPlusFixture, FuelCellTest) { - std::string const idf_objects = delimited_string({ "Material,", @@ -794,7 +793,8 @@ TEST_F(EnergyPlusFixture, FuelCellTest) ASSERT_TRUE(process_idf(idf_objects)); EXPECT_FALSE(has_err_output()); - + state->init_state(*state); + SimulationManager::ManageSimulation(*state); EXPECT_TRUE(has_err_output(true)); @@ -813,8 +813,7 @@ TEST_F(EnergyPlusFixture, FuelCellTest) EXPECT_EQ("GENERATOR FUEL CELL EXHAUST GAS TO WATER HEAT EXCHANGER 1", generatorController->compPlantName); EXPECT_EQ(0, generatorController->generatorIndex); - EXPECT_EQ("ALWAYS ON DISCRETE", generatorController->availSched); - EXPECT_GT(generatorController->availSchedPtr, 0); + EXPECT_EQ("ALWAYS ON DISCRETE", generatorController->availSched->Name); EXPECT_EQ(0, generatorController->nominalThermElectRatio); @@ -923,7 +922,7 @@ TEST_F(EnergyPlusFixture, FuelCellTest) EXPECT_ENUM_EQ(DataGenerators::WaterTemperatureMode::WaterInReformSchedule, waterSup.WaterTempMode); - ASSERT_GT(waterSup.SchedNum, 0); + ASSERT_NE(waterSup.sched, nullptr); // Auxiliary Heater EXPECT_EQ("GENERATOR FUEL CELL AUXILIARY HEATER 1", thisFC->NameFCAuxilHeat); @@ -1020,7 +1019,6 @@ TEST_F(EnergyPlusFixture, FuelCellTest) TEST_F(EnergyPlusFixture, DISABLED_FuelCellTest_Zero_Cp_Fix) { // state->clear_state(); - std::string const idf_objects = delimited_string({ "Material,", @@ -1740,6 +1738,8 @@ TEST_F(EnergyPlusFixture, DISABLED_FuelCellTest_Zero_Cp_Fix) process_err = has_err_output(true); EXPECT_FALSE(process_err); + state->init_state(*state); + SimulationManager::ManageSimulation(*state); bool simulation_err(false); simulation_err = has_err_output(false); @@ -1760,8 +1760,7 @@ TEST_F(EnergyPlusFixture, DISABLED_FuelCellTest_Zero_Cp_Fix) EXPECT_EQ("GENERATOR FUEL CELL EXHAUST GAS TO WATER HEAT EXCHANGER 1", generatorController->compPlantName); EXPECT_EQ(0, generatorController->generatorIndex); - EXPECT_EQ("ALWAYS ON DISCRETE", generatorController->availSched); - EXPECT_GT(generatorController->availSchedPtr, 0); + EXPECT_EQ("ALWAYS ON DISCRETE", generatorController->availSched->Name); EXPECT_EQ(0, generatorController->nominalThermElectRatio); @@ -1870,7 +1869,7 @@ TEST_F(EnergyPlusFixture, DISABLED_FuelCellTest_Zero_Cp_Fix) EXPECT_ENUM_EQ(DataGenerators::WaterTemperatureMode::WaterInReformSchedule, waterSup.WaterTempMode); - ASSERT_GT(waterSup.SchedNum, 0); + ASSERT_NE(waterSup.sched, nullptr); // Auxiliary Heater EXPECT_EQ("GENERATOR FUEL CELL AUXILIARY HEATER 1", thisFC->NameFCAuxilHeat); diff --git a/tst/EnergyPlus/unit/Furnaces.unit.cc b/tst/EnergyPlus/unit/Furnaces.unit.cc index c98b7c9e906..6dfbabc0bed 100644 --- a/tst/EnergyPlus/unit/Furnaces.unit.cc +++ b/tst/EnergyPlus/unit/Furnaces.unit.cc @@ -77,7 +77,6 @@ using namespace EnergyPlus; using namespace EnergyPlus::Furnaces; using namespace EnergyPlus::DataLoopNode; using namespace DataZoneEnergyDemands; -using namespace ScheduleManager; using namespace EnergyPlus::DataAirLoop; using namespace EnergyPlus::OutputProcessor; using namespace EnergyPlus::SimulationManager; @@ -93,7 +92,6 @@ TEST_F(EnergyPlusFixture, SetVSHPAirFlowTest_VSFurnaceFlowTest) Real64 PartLoadRatio(1.0); state->dataLoopNodes->Node.allocate(10); state->dataZoneEnergyDemand->CurDeadBandOrSetback.allocate(1); - state->dataScheduleMgr->Schedule.allocate(1); state->dataHVACGlobal->MSHPMassFlowRateLow = 0.0; state->dataHVACGlobal->MSHPMassFlowRateHigh = 0.0; @@ -117,7 +115,7 @@ TEST_F(EnergyPlusFixture, SetVSHPAirFlowTest_VSFurnaceFlowTest) state->dataFurnaces->Furnace(FurnaceNum).LastMode = Furnaces::ModeOfOperation::HeatingMode; state->dataFurnaces->Furnace(FurnaceNum).IdleMassFlowRate = 0.2; state->dataFurnaces->Furnace(FurnaceNum).IdleSpeedRatio = 0.2; - state->dataFurnaces->Furnace(FurnaceNum).FanAvailSchedPtr = ScheduleManager::ScheduleAlwaysOn; + state->dataFurnaces->Furnace(FurnaceNum).fanAvailSched = Sched::GetScheduleAlwaysOn(*state); state->dataFurnaces->Furnace(FurnaceNum).FurnaceInletNodeNum = 1; state->dataFurnaces->Furnace(FurnaceNum).HeatMassFlowRate(1) = 0.25; @@ -142,7 +140,7 @@ TEST_F(EnergyPlusFixture, SetVSHPAirFlowTest_VSFurnaceFlowTest) state->dataFurnaces->Furnace(FurnaceNum).NumOfSpeedHeating = 0; state->dataFurnaces->Furnace(FurnaceNum).NumOfSpeedCooling = 0; // Furnace( FurnaceNum ).SchedPtr = 0; // denotes incorrect schedule name in Furnace input ( returns 0.0 ) - state->dataFurnaces->Furnace(FurnaceNum).SchedPtr = -1; // denotes missing schedule name in Furnace input ( returns 1.0 ) + state->dataFurnaces->Furnace(FurnaceNum).sched = Sched::GetScheduleAlwaysOn(*state); // denotes missing schedule name in Furnace input ( returns 1.0 ) state->dataFurnaces->HeatingLoad = true; state->dataFurnaces->CoolingLoad = false; SetVSHPAirFlow(*state, FurnaceNum, PartLoadRatio, OnOffAirFlowRatio); @@ -1186,7 +1184,8 @@ TEST_F(EnergyPlusFixture, UnitaryHeatPumpAirToAir_MaxSuppAirTempTest) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + int CompIndex(0); int AirLoopNum(1); bool FirstHVACIteration(false); diff --git a/tst/EnergyPlus/unit/GroundHeatExchangers.unit.cc b/tst/EnergyPlus/unit/GroundHeatExchangers.unit.cc index cbb8b7c7eb3..53c1dac1807 100644 --- a/tst/EnergyPlus/unit/GroundHeatExchangers.unit.cc +++ b/tst/EnergyPlus/unit/GroundHeatExchangers.unit.cc @@ -71,12 +71,10 @@ using namespace EnergyPlus::DataSurfaces; using namespace EnergyPlus::GroundHeatExchangers; using namespace EnergyPlus::HeatBalanceManager; using namespace EnergyPlus::SizingManager; -using namespace EnergyPlus::ScheduleManager; using namespace EnergyPlus::PlantManager; TEST_F(EnergyPlusFixture, GroundHeatExchangerTest_Interpolate) { - // Initialization GLHESlinky thisGLHE; Real64 thisLNTTS; @@ -1280,8 +1278,8 @@ TEST_F(EnergyPlusFixture, GroundHeatExchangerTest_System_calcGFunction_UHF) // Setup ASSERT_TRUE(process_idf(idf_objects)); - ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; + state->init_state(*state); + GetPlantLoopData(*state); GetPlantInput(*state); SetupInitialPlantCallingOrder(*state); @@ -1734,8 +1732,8 @@ TEST_F(EnergyPlusFixture, GroundHeatExchangerTest_System_calcGFunction_UBHWT) // Setup ASSERT_TRUE(process_idf(idf_objects)); - ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; + state->init_state(*state); + GetPlantLoopData(*state); GetPlantInput(*state); SetupInitialPlantCallingOrder(*state); @@ -1841,7 +1839,8 @@ TEST_F(EnergyPlusFixture, GroundHeatExchangerTest_System_calc_pipe_conduction_re state->dataSysVars->DisableGLHECaching = true; ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + GetGroundHeatExchangerInput(*state); auto &thisGLHE(state->dataGroundHeatExchanger->verticalGLHE[0]); @@ -1903,7 +1902,8 @@ TEST_F(EnergyPlusFixture, GroundHeatExchangerTest_System_friction_factor) // Setup ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + GetGroundHeatExchangerInput(*state); auto &thisGLHE(state->dataGroundHeatExchanger->verticalGLHE[0]); @@ -2219,8 +2219,8 @@ TEST_F(EnergyPlusFixture, GroundHeatExchangerTest_System_calc_pipe_convection_re // Setup ASSERT_TRUE(process_idf(idf_objects)); - ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; + state->init_state(*state); + GetPlantLoopData(*state); GetPlantInput(*state); SetupInitialPlantCallingOrder(*state); @@ -2524,8 +2524,8 @@ TEST_F(EnergyPlusFixture, GroundHeatExchangerTest_System_calc_pipe_resistance) // Setup ASSERT_TRUE(process_idf(idf_objects)); - ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; + state->init_state(*state); + GetPlantLoopData(*state); GetPlantInput(*state); SetupInitialPlantCallingOrder(*state); @@ -2821,8 +2821,8 @@ TEST_F(EnergyPlusFixture, GroundHeatExchangerTest_System_calcBHGroutResistance_1 // Setup ASSERT_TRUE(process_idf(idf_objects)); - ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; + state->init_state(*state); + GetPlantLoopData(*state); GetPlantInput(*state); SetupInitialPlantCallingOrder(*state); @@ -3120,8 +3120,7 @@ TEST_F(EnergyPlusFixture, GroundHeatExchangerTest_System_calcBHGroutResistance_2 // Setup ASSERT_TRUE(process_idf(idf_objects)); - ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; + state->init_state(*state); GetPlantLoopData(*state); GetPlantInput(*state); SetupInitialPlantCallingOrder(*state); @@ -3419,8 +3418,8 @@ TEST_F(EnergyPlusFixture, GroundHeatExchangerTest_System_calcBHGroutResistance_3 // Setup ASSERT_TRUE(process_idf(idf_objects)); - ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; + state->init_state(*state); + GetPlantLoopData(*state); GetPlantInput(*state); SetupInitialPlantCallingOrder(*state); @@ -3718,8 +3717,7 @@ TEST_F(EnergyPlusFixture, GroundHeatExchangerTest_System_calcBHTotalInternalResi // Setup ASSERT_TRUE(process_idf(idf_objects)); - ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; + state->init_state(*state); GetPlantLoopData(*state); GetPlantInput(*state); SetupInitialPlantCallingOrder(*state); @@ -4017,8 +4015,7 @@ TEST_F(EnergyPlusFixture, GroundHeatExchangerTest_System_calcBHTotalInternalResi // Setup ASSERT_TRUE(process_idf(idf_objects)); - ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; + state->init_state(*state); GetPlantLoopData(*state); GetPlantInput(*state); SetupInitialPlantCallingOrder(*state); @@ -4316,8 +4313,8 @@ TEST_F(EnergyPlusFixture, GroundHeatExchangerTest_System_calcBHTotalInternalResi // Setup ASSERT_TRUE(process_idf(idf_objects)); - ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; + state->init_state(*state); + GetPlantLoopData(*state); GetPlantInput(*state); SetupInitialPlantCallingOrder(*state); @@ -4389,7 +4386,8 @@ TEST_F(EnergyPlusFixture, GroundHeatExchangerTest_GetVertProps) // Setup ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + GetGroundHeatExchangerInput(*state); // good object name @@ -4468,7 +4466,8 @@ TEST_F(EnergyPlusFixture, GroundHeatExchangerTest_GetSingleBH) // Setup ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + GetGroundHeatExchangerInput(*state); // good object name @@ -4541,7 +4540,8 @@ TEST_F(EnergyPlusFixture, GroundHeatExchangerTest_GetVertArray) // Setup ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + GetGroundHeatExchangerInput(*state); // good object name @@ -4626,7 +4626,8 @@ TEST_F(EnergyPlusFixture, GroundHeatExchangerTest_GetResponseFactor) // Setup ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + GetGroundHeatExchangerInput(*state); // good object name diff --git a/tst/EnergyPlus/unit/HVACControllers.unit.cc b/tst/EnergyPlus/unit/HVACControllers.unit.cc index d5888fb831b..758c7bd5aa4 100644 --- a/tst/EnergyPlus/unit/HVACControllers.unit.cc +++ b/tst/EnergyPlus/unit/HVACControllers.unit.cc @@ -71,7 +71,6 @@ using namespace EnergyPlus::MixedAir; using namespace EnergyPlus::HVACControllers; -using namespace EnergyPlus::ScheduleManager; using namespace EnergyPlus::SetPointManager; using namespace EnergyPlus::WaterCoils; @@ -130,6 +129,7 @@ TEST_F(EnergyPlusFixture, HVACControllers_ResetHumidityRatioCtrlVarType) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); GetSetPointManagerInputs(*state); // check specified control variable type is "HumidityRatio" @@ -206,7 +206,8 @@ TEST_F(EnergyPlusFixture, HVACControllers_TestTempAndHumidityRatioCtrlVarType) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + GetSetPointManagerInputs(*state); // check specified control variable type is "HumidityRatio" ASSERT_ENUM_EQ(HVAC::CtrlVarType::MaxHumRat, state->dataSetPointManager->spms(1)->ctrlVar); @@ -346,7 +347,8 @@ TEST_F(EnergyPlusFixture, HVACControllers_SchSetPointMgrsOrderTest) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + GetSetPointManagerInputs(*state); // There are two setpoint managers and are schedule type ASSERT_EQ(2, state->dataSetPointManager->spms.size()); // 2 schedule set point managers @@ -410,7 +412,8 @@ TEST_F(EnergyPlusFixture, HVACControllers_WaterCoilOnPrimaryLoopCheckTest) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + GetControllerInput(*state); ASSERT_EQ(state->dataWaterCoils->WaterCoil(1).Name, "CHILLED WATER COIL"); @@ -503,7 +506,8 @@ TEST_F(EnergyPlusFixture, HVACControllers_WaterCoilOnOutsideAirSystemCheckTest) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + GetControllerInput(*state); ASSERT_EQ(state->dataWaterCoils->WaterCoil(1).Name, "OA PREHEAT HW COIL"); @@ -635,7 +639,8 @@ TEST_F(EnergyPlusFixture, HVACControllers_CoilSystemCoolingWaterOnOutsideAirSyst }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + GetControllerInput(*state); ASSERT_EQ(state->dataWaterCoils->WaterCoil(1).Name, "DETAILED PRE COOLING COIL"); @@ -842,7 +847,7 @@ TEST_F(EnergyPlusFixture, HVACControllers_BlankAutosized) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); GetSetPointManagerInputs(*state); GetControllerInput(*state); @@ -917,7 +922,8 @@ TEST_F(EnergyPlusFixture, HVACControllers_MaxFlowZero) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + GetSetPointManagerInputs(*state); GetControllerInput(*state); diff --git a/tst/EnergyPlus/unit/HVACCooledBeam.unit.cc b/tst/EnergyPlus/unit/HVACCooledBeam.unit.cc index 82dabd45c5b..6c1d8b6ccbb 100644 --- a/tst/EnergyPlus/unit/HVACCooledBeam.unit.cc +++ b/tst/EnergyPlus/unit/HVACCooledBeam.unit.cc @@ -72,11 +72,8 @@ TEST_F(EnergyPlusFixture, HVACCooledBeam_reportTerminalUnit) SetPredefinedTables(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; - auto &sch = state->dataScheduleMgr->Schedule; - sch.allocate(5); - sch(1).Name = "schA"; - sch(2).Name = "schB"; + auto *schedA = Sched::AddScheduleConstant(*state, "schA"); + auto *schedB = Sched::AddScheduleConstant(*state, "schB"); auto &adu = state->dataDefineEquipment->AirDistUnit; adu.allocate(2); diff --git a/tst/EnergyPlus/unit/HVACDXHeatPumpSystem.unit.cc b/tst/EnergyPlus/unit/HVACDXHeatPumpSystem.unit.cc index 5a7e04344cd..83c9eed2225 100644 --- a/tst/EnergyPlus/unit/HVACDXHeatPumpSystem.unit.cc +++ b/tst/EnergyPlus/unit/HVACDXHeatPumpSystem.unit.cc @@ -100,6 +100,7 @@ TEST_F(EnergyPlusFixture, ExerciseHVACDXHeatPumpSystem) " Heat Pump 1 Evaporator Node; !- Evaporator Air Inlet Node Name"}); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); state->dataLoopNodes->NodeID.allocate(2); state->dataLoopNodes->Node.allocate(2); @@ -109,6 +110,7 @@ TEST_F(EnergyPlusFixture, ExerciseHVACDXHeatPumpSystem) state->dataDXCoils->GetCoilsInputFlag = false; state->dataDXCoils->DXCoil.allocate(1); state->dataDXCoils->DXCoil(1).Name = "HEAT PUMP DX HEATING COIL 1"; + state->dataDXCoils->DXCoil(1).availSched = Sched::GetScheduleAlwaysOn(*state); state->dataDXCoils->DXCoil(1).AirInNode = 1; state->dataDXCoils->DXCoil(1).AirOutNode = 2; state->dataDXCoils->DXCoil(1).DXCoilType = "COIL:HEATING:DX:SINGLESPEED"; diff --git a/tst/EnergyPlus/unit/HVACDXSystem.unit.cc b/tst/EnergyPlus/unit/HVACDXSystem.unit.cc index 9aa801a79fe..94130674b63 100644 --- a/tst/EnergyPlus/unit/HVACDXSystem.unit.cc +++ b/tst/EnergyPlus/unit/HVACDXSystem.unit.cc @@ -422,10 +422,11 @@ TEST_F(EnergyPlusFixture, VariableSpeedCoils_DOASDXCoilTest) ASSERT_TRUE(process_idf(idf_objects)); - state->dataGlobal->NumOfTimeStepInHour = 1; - state->dataGlobal->MinutesPerTimeStep = 60; + state->dataGlobal->TimeStepsInHour = 1; + state->dataGlobal->MinutesInTimeStep = 60; + state->init_state(*state); + state->dataZoneEquip->ZoneEquipInputsFilled = true; - ScheduleManager::ProcessScheduleInput(*state); std::string compName = "DX COOLING COIL SYSTEM"; bool zoneEquipment = false; @@ -556,10 +557,11 @@ TEST_F(EnergyPlusFixture, VariableSpeedCoils_RHControl) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->dataGlobal->TimeStepsInHour = 1; + state->dataGlobal->MinutesInTimeStep = 60; + state->init_state(*state); + std::string compName = "DX COOLING COIL SYSTEM"; - state->dataGlobal->NumOfTimeStepInHour = 1; - state->dataGlobal->MinutesPerTimeStep = 60; state->dataZoneEquip->ZoneEquipInputsFilled = true; state->dataGlobal->NumOfZones = 1; state->dataZoneEquip->ZoneEquipConfig.allocate(1); @@ -577,8 +579,7 @@ TEST_F(EnergyPlusFixture, VariableSpeedCoils_RHControl) state->dataAirSystemsData->PrimaryAirSystems(1).Branch(1).Comp(1).Name = compName; state->dataAirSystemsData->PrimaryAirSystems(1).Branch(1).Comp(1).CompType_Num = SimAirServingZones::CompType::DXSystem; OutputReportPredefined::SetPredefinedTables(*state); - ScheduleManager::ProcessScheduleInput(*state); - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; // Enable schedule without calling schedule manager + Sched::GetSchedule(*state, "AVAILSCHED")->currentVal = 1.0; // Enable schedule without calling schedule manager bool FirstHVACIteration = true; bool HXUnitOn = false; @@ -755,10 +756,11 @@ TEST_F(EnergyPlusFixture, VariableSpeedCoils_LatentDegradation_Test) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->dataGlobal->TimeStepsInHour = 1; + state->dataGlobal->MinutesInTimeStep = 60; + state->init_state(*state); + std::string compName = "DX COOLING COIL SYSTEM"; - state->dataGlobal->NumOfTimeStepInHour = 1; - state->dataGlobal->MinutesPerTimeStep = 60; state->dataZoneEquip->ZoneEquipInputsFilled = true; state->dataGlobal->NumOfZones = 1; state->dataZoneEquip->ZoneEquipConfig.allocate(1); @@ -776,8 +778,7 @@ TEST_F(EnergyPlusFixture, VariableSpeedCoils_LatentDegradation_Test) state->dataAirSystemsData->PrimaryAirSystems(1).Branch(1).Comp(1).Name = compName; state->dataAirSystemsData->PrimaryAirSystems(1).Branch(1).Comp(1).CompType_Num = SimAirServingZones::CompType::DXSystem; OutputReportPredefined::SetPredefinedTables(*state); - ScheduleManager::ProcessScheduleInput(*state); - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; // Enable schedule without calling schedule manager + Sched::GetSchedule(*state, "AVAILSCHED")->currentVal = 1.0; // Enable schedule without calling schedule manager bool FirstHVACIteration = true; bool HXUnitOn = false; @@ -1029,10 +1030,11 @@ TEST_F(EnergyPlusFixture, NewDXCoilModel_RHControl) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->dataGlobal->TimeStepsInHour = 1; + state->dataGlobal->MinutesInTimeStep = 60; + state->init_state(*state); + std::string compName = "DX COOLING COIL SYSTEM"; - state->dataGlobal->NumOfTimeStepInHour = 1; - state->dataGlobal->MinutesPerTimeStep = 60; state->dataZoneEquip->ZoneEquipInputsFilled = true; state->dataGlobal->NumOfZones = 1; state->dataZoneEquip->ZoneEquipConfig.allocate(1); @@ -1051,8 +1053,7 @@ TEST_F(EnergyPlusFixture, NewDXCoilModel_RHControl) state->dataAirSystemsData->PrimaryAirSystems(1).Branch(1).Comp(1).Name = compName; state->dataAirSystemsData->PrimaryAirSystems(1).Branch(1).Comp(1).CompType_Num = SimAirServingZones::CompType::DXSystem; OutputReportPredefined::SetPredefinedTables(*state); - ScheduleManager::ProcessScheduleInput(*state); - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; // Enable schedule without calling schedule manager + Sched::GetSchedule(*state, "AVAILSCHED")->currentVal = 1.0; // Enable schedule without calling schedule manager bool FirstHVACIteration = true; bool HXUnitOn = false; diff --git a/tst/EnergyPlus/unit/HVACFan.unit.cc b/tst/EnergyPlus/unit/HVACFan.unit.cc index 5303e1b3be6..62eb48f9130 100644 --- a/tst/EnergyPlus/unit/HVACFan.unit.cc +++ b/tst/EnergyPlus/unit/HVACFan.unit.cc @@ -91,6 +91,8 @@ TEST_F(EnergyPlusFixture, SystemFanObj_TestGetFunctions1) ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + Fans::GetFanInput(*state); state->dataSize->CurZoneEqNum = 0; state->dataSize->CurSysNum = 0; @@ -136,6 +138,9 @@ TEST_F(EnergyPlusFixture, SystemFanObj_FanSizing1) }); ASSERT_TRUE(process_idf(idf_objects)); + + state->init_state(*state); + state->dataEnvrn->StdRhoAir = 1.0; Fans::GetFanInput(*state); state->dataSize->CurZoneEqNum = 0; @@ -189,6 +194,8 @@ TEST_F(EnergyPlusFixture, SystemFanObj_TwoSpeedFanPowerCalc1) ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + Fans::GetFanInput(*state); state->dataSize->CurZoneEqNum = 0; state->dataSize->CurSysNum = 0; @@ -263,6 +270,9 @@ TEST_F(EnergyPlusFixture, SystemFanObj_TwoSpeedFanPowerCalc2) }); ASSERT_TRUE(process_idf(idf_objects)); + + state->init_state(*state); + Curve::GetCurveInput(*state); Fans::GetFanInput(*state); state->dataSize->CurZoneEqNum = 0; @@ -326,6 +336,8 @@ TEST_F(EnergyPlusFixture, SystemFanObj_TwoSpeedFanPowerCalc3) ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + Fans::GetFanInput(*state); state->dataSize->CurZoneEqNum = 0; state->dataSize->CurSysNum = 0; @@ -427,6 +439,9 @@ TEST_F(EnergyPlusFixture, SystemFanObj_TwoSpeedFanPowerCalc4) }); ASSERT_TRUE(process_idf(idf_objects)); + + state->init_state(*state); + Curve::GetCurveInput(*state); Fans::GetFanInput(*state); state->dataSize->CurZoneEqNum = 0; @@ -588,6 +603,8 @@ TEST_F(EnergyPlusFixture, SystemFanObj_DiscreteMode_noPowerFFlowCurve) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + Fans::GetFanInput(*state); state->dataSize->CurZoneEqNum = 0; state->dataSize->CurSysNum = 0; @@ -688,6 +705,7 @@ TEST_F(EnergyPlusFixture, SystemFanObj_DiscreteMode_EMSPressureRiseResetTest) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); EMSManager::CheckIfAnyEMS(*state); state->dataEMSMgr->FinishProcessingUserInput = true; diff --git a/tst/EnergyPlus/unit/HVACFourPipeBeam.unit.cc b/tst/EnergyPlus/unit/HVACFourPipeBeam.unit.cc index d966115504b..a82fb6cd92c 100644 --- a/tst/EnergyPlus/unit/HVACFourPipeBeam.unit.cc +++ b/tst/EnergyPlus/unit/HVACFourPipeBeam.unit.cc @@ -211,6 +211,8 @@ TEST_F(EnergyPlusFixture, Beam_FactoryAllAutosize) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + state->dataGlobal->NumOfZones = 1; state->dataHeatBal->Zone.allocate(state->dataGlobal->NumOfZones); @@ -308,13 +310,6 @@ TEST_F(EnergyPlusFixture, Beam_sizeandSimulateOneZone) " 4, !- Upper Limit Value", " DISCRETE; !- Numeric Type", - " Schedule:Compact,", - " ALWAYS_ON, !- Name", - " On/Off, !- Schedule Type Limits Name", - " Through: 12/31, !- Field 1", - " For: AllDays, !- Field 2", - " Until: 24:00,1; !- Field 3", - " Schedule:Compact,", " ACTIVITY_SCH, !- Name", " Any Number, !- Schedule Type Limits Name", @@ -902,7 +897,7 @@ TEST_F(EnergyPlusFixture, Beam_sizeandSimulateOneZone) " Fan:VariableVolume,", " CV_1_Fan, !- Name", - " always_on, !- Availability Schedule Name", + " CONSTANT-1.0, !- Availability Schedule Name", " 0.6045, !- Fan Total Efficiency", " 1017.592, !- Pressure Rise {Pa}", " AUTOSIZE, !- Maximum Flow Rate {m3/s}", @@ -922,7 +917,7 @@ TEST_F(EnergyPlusFixture, Beam_sizeandSimulateOneZone) " Coil:Heating:Water,", " CV_1_HeatC, !- Name", - " ALWAYS_ON, !- Availability Schedule Name", + " CONSTANT-1.0, !- Availability Schedule Name", " AUTOSIZE, !- U-Factor Times Area Value {W/K}", " AUTOSIZE, !- Maximum Water Flow Rate {m3/s}", " CV_1_HeatCDemand Inlet Node, !- Water Inlet Node Name", @@ -939,7 +934,7 @@ TEST_F(EnergyPlusFixture, Beam_sizeandSimulateOneZone) " Coil:Cooling:Water,", " CV_1_CoolC, !- Name", - " ALWAYS_ON, !- Availability Schedule Name", + " CONSTANT-1.0, !- Availability Schedule Name", " AUTOSIZE, !- Design Water Flow Rate {m3/s}", " AUTOSIZE, !- Design Air Flow Rate {m3/s}", " AUTOSIZE, !- Design Inlet Water Temperature {C}", @@ -1020,7 +1015,7 @@ TEST_F(EnergyPlusFixture, Beam_sizeandSimulateOneZone) " AvailabilityManager:Scheduled,", " CV_1 Avail, !- Name", - " always_on; !- Schedule Name", + " CONSTANT-1.0; !- Schedule Name", " NodeList,", " CV_1_OANode List, !- Name", @@ -1266,7 +1261,7 @@ TEST_F(EnergyPlusFixture, Beam_sizeandSimulateOneZone) " SOURCE Loop Operation, !- Name", " PlantEquipmentOperation:CoolingLoad, !- Control Scheme 1 Object Type", " SOURCE Purchased Only, !- Control Scheme 1 Name", - " Always_On; !- Control Scheme 1 Schedule Name", + " CONSTANT-1.0; !- Control Scheme 1 Schedule Name", " PlantEquipmentOperation:CoolingLoad,", " SOURCE Purchased Only, !- Name", @@ -1417,7 +1412,7 @@ TEST_F(EnergyPlusFixture, Beam_sizeandSimulateOneZone) " HeatSys1 Loop Operation, !- Name", " PlantEquipmentOperation:HeatingLoad, !- Control Scheme 1 Object Type", " HeatSys1 Purchased Only, !- Control Scheme 1 Name", - " Always_On; !- Control Scheme 1 Schedule Name", + " CONSTANT-1.0; !- Control Scheme 1 Schedule Name", " PlantEquipmentOperation:HeatingLoad,", " HeatSys1 Purchased Only, !- Name", @@ -1590,9 +1585,9 @@ TEST_F(EnergyPlusFixture, Beam_sizeandSimulateOneZone) " AirTerminal:SingleDuct:ConstantVolume:FourPipeBeam,", " Zone One 4pipe Beam, !- Name", - " ALWAYS_ON , !- Primary Air Availability Schedule Name", - " ALWAYS_ON , !- Cooling Availability Schedule Name", - " ALWAYS_ON , !- Heating Availability Schedule Name", + " CONSTANT-1.0 , !- Primary Air Availability Schedule Name", + " CONSTANT-1.0 , !- Cooling Availability Schedule Name", + " CONSTANT-1.0 , !- Heating Availability Schedule Name", " Zone One 4pipe Beam Inlet Node Name , !- Primary Air Inlet Node Name", " Zone One 4pipe Beam Outlet Node Name , !- Primary Air Outlet Node Name", " Zone One 4pipe Beam CW Inlet Node , !- Chilled Water Inlet Node Name", @@ -1721,11 +1716,11 @@ TEST_F(EnergyPlusFixture, Beam_sizeandSimulateOneZone) ASSERT_TRUE(process_idf(idf_objects)); SimulationManager::PostIPProcessing(*state); + state->init_state(*state); bool ErrorsFound = false; state->dataGlobal->BeginSimFlag = true; - SimulationManager::GetProjectData(*state); OutputReportPredefined::SetPredefinedTables(*state); HeatBalanceManager::SetPreConstructionInputParameters(*state); // establish array bounds for constructions early @@ -1887,13 +1882,6 @@ TEST_F(EnergyPlusFixture, Beam_fatalWhenSysSizingOff) " 4, !- Upper Limit Value", " DISCRETE; !- Numeric Type", - " Schedule:Compact,", - " ALWAYS_ON, !- Name", - " On/Off, !- Schedule Type Limits Name", - " Through: 12/31, !- Field 1", - " For: AllDays, !- Field 2", - " Until: 24:00,1; !- Field 3", - " Schedule:Compact,", " ACTIVITY_SCH, !- Name", " Any Number, !- Schedule Type Limits Name", @@ -2481,7 +2469,7 @@ TEST_F(EnergyPlusFixture, Beam_fatalWhenSysSizingOff) " Fan:VariableVolume,", " CV_1_Fan, !- Name", - " always_on, !- Availability Schedule Name", + " CONSTANT-1.0, !- Availability Schedule Name", " 0.6045, !- Fan Total Efficiency", " 1017.592, !- Pressure Rise {Pa}", " AUTOSIZE, !- Maximum Flow Rate {m3/s}", @@ -2501,7 +2489,7 @@ TEST_F(EnergyPlusFixture, Beam_fatalWhenSysSizingOff) " Coil:Heating:Water,", " CV_1_HeatC, !- Name", - " ALWAYS_ON, !- Availability Schedule Name", + " CONSTANT-1.0, !- Availability Schedule Name", " AUTOSIZE, !- U-Factor Times Area Value {W/K}", " AUTOSIZE, !- Maximum Water Flow Rate {m3/s}", " CV_1_HeatCDemand Inlet Node, !- Water Inlet Node Name", @@ -2518,7 +2506,7 @@ TEST_F(EnergyPlusFixture, Beam_fatalWhenSysSizingOff) " Coil:Cooling:Water,", " CV_1_CoolC, !- Name", - " ALWAYS_ON, !- Availability Schedule Name", + " CONSTANT-1.0, !- Availability Schedule Name", " AUTOSIZE, !- Design Water Flow Rate {m3/s}", " AUTOSIZE, !- Design Air Flow Rate {m3/s}", " AUTOSIZE, !- Design Inlet Water Temperature {C}", @@ -2599,7 +2587,7 @@ TEST_F(EnergyPlusFixture, Beam_fatalWhenSysSizingOff) " AvailabilityManager:Scheduled,", " CV_1 Avail, !- Name", - " always_on; !- Schedule Name", + " CONSTANT-1.0; !- Schedule Name", " NodeList,", " CV_1_OANode List, !- Name", @@ -2845,7 +2833,7 @@ TEST_F(EnergyPlusFixture, Beam_fatalWhenSysSizingOff) " SOURCE Loop Operation, !- Name", " PlantEquipmentOperation:CoolingLoad, !- Control Scheme 1 Object Type", " SOURCE Purchased Only, !- Control Scheme 1 Name", - " Always_On; !- Control Scheme 1 Schedule Name", + " CONSTANT-1.0; !- Control Scheme 1 Schedule Name", " PlantEquipmentOperation:CoolingLoad,", " SOURCE Purchased Only, !- Name", @@ -2996,7 +2984,7 @@ TEST_F(EnergyPlusFixture, Beam_fatalWhenSysSizingOff) " HeatSys1 Loop Operation, !- Name", " PlantEquipmentOperation:HeatingLoad, !- Control Scheme 1 Object Type", " HeatSys1 Purchased Only, !- Control Scheme 1 Name", - " Always_On; !- Control Scheme 1 Schedule Name", + " CONSTANT-1.0; !- Control Scheme 1 Schedule Name", " PlantEquipmentOperation:HeatingLoad,", " HeatSys1 Purchased Only, !- Name", @@ -3169,9 +3157,9 @@ TEST_F(EnergyPlusFixture, Beam_fatalWhenSysSizingOff) " AirTerminal:SingleDuct:ConstantVolume:FourPipeBeam,", " Zone One 4pipe Beam, !- Name", - " ALWAYS_ON , !- Primary Air Availability Schedule Name", - " ALWAYS_ON , !- Cooling Availability Schedule Name", - " ALWAYS_ON , !- Heating Availability Schedule Name", + " CONSTANT-1.0 , !- Primary Air Availability Schedule Name", + " CONSTANT-1.0 , !- Cooling Availability Schedule Name", + " CONSTANT-1.0 , !- Heating Availability Schedule Name", " Zone One 4pipe Beam Inlet Node Name , !- Primary Air Inlet Node Name", " Zone One 4pipe Beam Outlet Node Name , !- Primary Air Outlet Node Name", " Zone One 4pipe Beam CW Inlet Node , !- Chilled Water Inlet Node Name", @@ -3300,11 +3288,11 @@ TEST_F(EnergyPlusFixture, Beam_fatalWhenSysSizingOff) ASSERT_TRUE(process_idf(idf_objects)); SimulationManager::PostIPProcessing(*state); + state->init_state(*state); bool ErrorsFound = false; state->dataGlobal->BeginSimFlag = true; - SimulationManager::GetProjectData(*state); OutputReportPredefined::SetPredefinedTables(*state); HeatBalanceManager::SetPreConstructionInputParameters(*state); // establish array bounds for constructions early @@ -3381,13 +3369,6 @@ TEST_F(EnergyPlusFixture, Beam_sizeandSimulateHighOA) " 4, !- Upper Limit Value", " DISCRETE; !- Numeric Type", - " Schedule:Compact,", - " ALWAYS_ON, !- Name", - " On/Off, !- Schedule Type Limits Name", - " Through: 12/31, !- Field 1", - " For: AllDays, !- Field 2", - " Until: 24:00,1; !- Field 3", - " Schedule:Compact,", " ACTIVITY_SCH, !- Name", " Any Number, !- Schedule Type Limits Name", @@ -3978,7 +3959,7 @@ TEST_F(EnergyPlusFixture, Beam_sizeandSimulateHighOA) " Fan:VariableVolume,", " CV_1_Fan, !- Name", - " always_on, !- Availability Schedule Name", + " CONSTANT-1.0, !- Availability Schedule Name", " 0.6045, !- Fan Total Efficiency", " 1017.592, !- Pressure Rise {Pa}", " AUTOSIZE, !- Maximum Flow Rate {m3/s}", @@ -3998,7 +3979,7 @@ TEST_F(EnergyPlusFixture, Beam_sizeandSimulateHighOA) " Coil:Heating:Water,", " CV_1_HeatC, !- Name", - " ALWAYS_ON, !- Availability Schedule Name", + " CONSTANT-1.0, !- Availability Schedule Name", " AUTOSIZE, !- U-Factor Times Area Value {W/K}", " AUTOSIZE, !- Maximum Water Flow Rate {m3/s}", " CV_1_HeatCDemand Inlet Node, !- Water Inlet Node Name", @@ -4015,7 +3996,7 @@ TEST_F(EnergyPlusFixture, Beam_sizeandSimulateHighOA) " Coil:Cooling:Water,", " CV_1_CoolC, !- Name", - " ALWAYS_ON, !- Availability Schedule Name", + " CONSTANT-1.0, !- Availability Schedule Name", " AUTOSIZE, !- Design Water Flow Rate {m3/s}", " AUTOSIZE, !- Design Air Flow Rate {m3/s}", " AUTOSIZE, !- Design Inlet Water Temperature {C}", @@ -4096,7 +4077,7 @@ TEST_F(EnergyPlusFixture, Beam_sizeandSimulateHighOA) " AvailabilityManager:Scheduled,", " CV_1 Avail, !- Name", - " always_on; !- Schedule Name", + " CONSTANT-1.0; !- Schedule Name", " NodeList,", " CV_1_OANode List, !- Name", @@ -4342,7 +4323,7 @@ TEST_F(EnergyPlusFixture, Beam_sizeandSimulateHighOA) " SOURCE Loop Operation, !- Name", " PlantEquipmentOperation:CoolingLoad, !- Control Scheme 1 Object Type", " SOURCE Purchased Only, !- Control Scheme 1 Name", - " Always_On; !- Control Scheme 1 Schedule Name", + " CONSTANT-1.0; !- Control Scheme 1 Schedule Name", " PlantEquipmentOperation:CoolingLoad,", " SOURCE Purchased Only, !- Name", @@ -4493,7 +4474,7 @@ TEST_F(EnergyPlusFixture, Beam_sizeandSimulateHighOA) " HeatSys1 Loop Operation, !- Name", " PlantEquipmentOperation:HeatingLoad, !- Control Scheme 1 Object Type", " HeatSys1 Purchased Only, !- Control Scheme 1 Name", - " Always_On; !- Control Scheme 1 Schedule Name", + " CONSTANT-1.0; !- Control Scheme 1 Schedule Name", " PlantEquipmentOperation:HeatingLoad,", " HeatSys1 Purchased Only, !- Name", @@ -4666,9 +4647,9 @@ TEST_F(EnergyPlusFixture, Beam_sizeandSimulateHighOA) " AirTerminal:SingleDuct:ConstantVolume:FourPipeBeam,", " Zone One 4pipe Beam, !- Name", - " ALWAYS_ON , !- Primary Air Availability Schedule Name", - " ALWAYS_ON , !- Cooling Availability Schedule Name", - " ALWAYS_ON , !- Heating Availability Schedule Name", + " CONSTANT-1.0 , !- Primary Air Availability Schedule Name", + " CONSTANT-1.0 , !- Cooling Availability Schedule Name", + " CONSTANT-1.0 , !- Heating Availability Schedule Name", " Zone One 4pipe Beam Inlet Node Name , !- Primary Air Inlet Node Name", " Zone One 4pipe Beam Outlet Node Name , !- Primary Air Outlet Node Name", " Zone One 4pipe Beam CW Inlet Node , !- Chilled Water Inlet Node Name", @@ -4797,11 +4778,10 @@ TEST_F(EnergyPlusFixture, Beam_sizeandSimulateHighOA) ASSERT_TRUE(process_idf(idf_objects)); SimulationManager::PostIPProcessing(*state); - + state->init_state(*state); bool ErrorsFound = false; state->dataGlobal->BeginSimFlag = true; - SimulationManager::GetProjectData(*state); OutputReportPredefined::SetPredefinedTables(*state); HeatBalanceManager::SetPreConstructionInputParameters(*state); // establish array bounds for constructions early diff --git a/tst/EnergyPlus/unit/HVACHXAssistedCoolingCoil.unit.cc b/tst/EnergyPlus/unit/HVACHXAssistedCoolingCoil.unit.cc index 6537074d194..e02199907bf 100644 --- a/tst/EnergyPlus/unit/HVACHXAssistedCoolingCoil.unit.cc +++ b/tst/EnergyPlus/unit/HVACHXAssistedCoolingCoil.unit.cc @@ -433,7 +433,8 @@ TEST_F(EnergyPlusFixture, HXAssistCCUnitarySystem_VStest1) }); ASSERT_TRUE(process_idf(idf_objects)); // read idf objects - + state->init_state(*state); + HeatBalanceManager::GetZoneData(*state, ErrorsFound); // read zone data EXPECT_FALSE(ErrorsFound); // expect no errors @@ -503,10 +504,10 @@ TEST_F(EnergyPlusFixture, HXAssistCCUnitarySystem_VStest1) state->dataZoneEnergyDemand->ZoneSysMoistureDemand(ControlZoneNum).OutputRequiredToDehumidifyingSP; state->dataHeatBalFanSys->TempControlType.allocate(1); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::DualSetPointWithDeadBand; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::DualHeatCool; state->dataZoneEnergyDemand->CurDeadBandOrSetback.allocate(1); state->dataZoneEnergyDemand->CurDeadBandOrSetback(1) = false; - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; + Sched::GetSchedule(*state, "FANANDCOILAVAILSCHED")->currentVal = 1.0; state->dataGlobal->BeginEnvrnFlag = true; state->dataEnvrn->StdRhoAir = Psychrometrics::PsyRhoAirFnPbTdbW(*state, 101325.0, 20.0, 0.0); // initialize RhoAir state->dataLoopNodes->Node(InletNode).MassFlowRateMaxAvail = thisSys->m_MaxCoolAirVolFlow * state->dataEnvrn->StdRhoAir; @@ -1108,7 +1109,8 @@ TEST_F(EnergyPlusFixture, HXAssistCCUnitarySystem_NewDXCoil_Processing_Test) }); ASSERT_TRUE(process_idf(idf_objects)); // read idf objects - + state->init_state(*state); + HeatBalanceManager::GetZoneData(*state, ErrorsFound); // read zone data EXPECT_FALSE(ErrorsFound); // expect no errors diff --git a/tst/EnergyPlus/unit/HVACInterfaceManager.unit.cc b/tst/EnergyPlus/unit/HVACInterfaceManager.unit.cc index 2bd9dbce437..dab978e8d42 100644 --- a/tst/EnergyPlus/unit/HVACInterfaceManager.unit.cc +++ b/tst/EnergyPlus/unit/HVACInterfaceManager.unit.cc @@ -72,7 +72,7 @@ TEST_F(EnergyPlusFixture, ExcessiveHeatStorage_Test) using namespace HVACInterfaceManager; Real64 TankOutletTemp; state->dataHVACGlobal->TimeStepSys = 1; - state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; state->dataPlnt->TotNumLoops = 1; state->dataPlnt->PlantLoop.allocate(state->dataPlnt->TotNumLoops); // Set Up PlantLoop Variables diff --git a/tst/EnergyPlus/unit/HVACManager.unit.cc b/tst/EnergyPlus/unit/HVACManager.unit.cc index 14f6ee13dac..e1a07fb68eb 100644 --- a/tst/EnergyPlus/unit/HVACManager.unit.cc +++ b/tst/EnergyPlus/unit/HVACManager.unit.cc @@ -95,7 +95,7 @@ TEST_F(EnergyPlusFixture, CrossMixingReportTest) state->dataGlobal->NumOfZones = state->dataGlobal->NumOfZones; state->dataHeatBal->TotCrossMixing = NumOfCrossMixing; state->dataHVACGlobal->TimeStepSys = 1.0; - state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; state->dataZoneTempPredictorCorrector->zoneHeatBalance(1).MCPI = 0.0; state->dataZoneTempPredictorCorrector->zoneHeatBalance(2).MCPI = 0.0; state->dataZoneTempPredictorCorrector->zoneHeatBalance(1).MCPV = 0.0; @@ -194,9 +194,9 @@ TEST_F(EnergyPlusFixture, InfiltrationObjectLevelReport) ASSERT_TRUE(process_idf(idf_objects)); EXPECT_FALSE(has_err_output()); + state->init_state(*state); bool ErrorsFound(false); - ScheduleManager::ProcessScheduleInput(*state); GetZoneData(*state, ErrorsFound); AllocateHeatBalArrays(*state); GetSimpleAirModelInputs(*state, ErrorsFound); @@ -238,9 +238,9 @@ TEST_F(EnergyPlusFixture, InfiltrationObjectLevelReport) state->dataHeatBal->Zone(2).OutDryBulbTemp = 15.0; state->dataHeatBal->Zone(3).OutDryBulbTemp = 15.0; state->dataHeatBal->Zone(4).OutDryBulbTemp = 15.0; - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; + Sched::GetSchedule(*state, "ALWAYSON")->currentVal = 1.0; state->dataHVACGlobal->TimeStepSys = 1.0; - state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; state->dataGlobal->TimeStepZone = 1.0; state->dataGlobal->TimeStepZoneSec = 3600; @@ -389,7 +389,7 @@ TEST_F(EnergyPlusFixture, InfiltrationReportTest) state->dataGlobal->NumOfZones = state->dataGlobal->NumOfZones; state->dataHVACGlobal->TimeStepSys = 1.0; - state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; state->dataZoneTempPredictorCorrector->zoneHeatBalance(1).MCPI = 1.0; state->dataZoneTempPredictorCorrector->zoneHeatBalance(2).MCPI = 1.5; state->dataZoneTempPredictorCorrector->zoneHeatBalance(1).MCPV = 2.0; @@ -453,7 +453,7 @@ TEST_F(EnergyPlusFixture, ExfilAndExhaustReportTest) state->dataGlobal->NumOfZones = state->dataGlobal->NumOfZones; state->dataHVACGlobal->TimeStepSys = 1.0; - state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; state->dataZoneTempPredictorCorrector->zoneHeatBalance(1).MCPI = 1.0; state->dataZoneTempPredictorCorrector->zoneHeatBalance(2).MCPI = 1.5; state->dataZoneTempPredictorCorrector->zoneHeatBalance(1).MCPV = 2.0; diff --git a/tst/EnergyPlus/unit/HVACMultiSpeedHeatPump.unit.cc b/tst/EnergyPlus/unit/HVACMultiSpeedHeatPump.unit.cc index ecab9c6fdcd..e30e7235437 100644 --- a/tst/EnergyPlus/unit/HVACMultiSpeedHeatPump.unit.cc +++ b/tst/EnergyPlus/unit/HVACMultiSpeedHeatPump.unit.cc @@ -84,7 +84,6 @@ using namespace EnergyPlus::DataZoneEnergyDemands; using namespace EnergyPlus::HeatBalanceManager; using namespace EnergyPlus::HVACMultiSpeedHeatPump; using namespace EnergyPlus::MixedAir; -using namespace EnergyPlus::ScheduleManager; using namespace EnergyPlus::SimAirServingZones; using namespace EnergyPlus::SingleDuct; using namespace EnergyPlus::SplitterComponent; @@ -1259,9 +1258,9 @@ TEST_F(EnergyPlusFixture, HVACMultiSpeedHeatPump_ReportVariableInitTest) }); ASSERT_TRUE(process_idf(idf_objects)); - state->dataGlobal->NumOfTimeStepInHour = 1; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 60; // must initialize this to get schedules initialized - ProcessScheduleInput(*state); + state->dataGlobal->TimeStepsInHour = 1; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 60; // must initialize this to get schedules initialized + state->init_state(*state); HeatBalanceManager::GetZoneData(*state, ErrorsFound); // read zone data EXPECT_FALSE(ErrorsFound); // zones are specified in the idf snippet @@ -1331,8 +1330,9 @@ TEST_F(EnergyPlusFixture, HVACMultiSpeedHeatPump_ReportVariableInitTest) dxCoil.MSRatedAirMassFlowRate(i) = dxCoil.MSRatedAirVolFlowRate(i) * 1.2; } } - state->dataScheduleMgr->Schedule(17).CurrentValue = 1.0; - state->dataScheduleMgr->Schedule(9).CurrentValue = 1.0; + + Sched::GetSchedule(*state, "AC-24SCHED")->currentVal = 1.0; + Sched::GetSchedule(*state, "AC-25 SCHED")->currentVal = 1.0; state->dataEnvrn->StdRhoAir = 1.2; state->dataEnvrn->OutDryBulbTemp = 35.0; state->dataEnvrn->OutHumRat = 0.012; @@ -2138,9 +2138,9 @@ TEST_F(EnergyPlusFixture, HVACMSHP_UnitarySystemElectricityRateTest) }); ASSERT_TRUE(process_idf(idf_objects)); - state->dataGlobal->NumOfTimeStepInHour = 1; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 60; // must initialize this to get schedules initialized - ProcessScheduleInput(*state); + state->dataGlobal->TimeStepsInHour = 1; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 60; // must initialize this to get schedules initialized + state->init_state(*state); HeatBalanceManager::GetZoneData(*state, ErrorsFound); // read zone data EXPECT_FALSE(ErrorsFound); // zones are specified in the idf snippet @@ -2193,7 +2193,7 @@ TEST_F(EnergyPlusFixture, HVACMSHP_UnitarySystemElectricityRateTest) auto &dxClgCoilMain = state->dataDXCoils->DXCoil(1); auto &dxHtgCoilMain = state->dataDXCoils->DXCoil(2); auto &elecHtgCoilSupp = state->dataHeatingCoils->HeatingCoil(msHeatPump.SuppHeatCoilNum); - state->dataScheduleMgr->Schedule(11).CurrentValue = 1.0; + Sched::GetSchedule(*state, "AC-24SCHED")->currentVal = 1.0; state->dataEnvrn->StdRhoAir = 1.2; supplyFan->rhoAirStdInit = state->dataEnvrn->StdRhoAir; state->dataGlobal->DoCoilDirectSolutions = false; diff --git a/tst/EnergyPlus/unit/HVACSizingSimulationManager.unit.cc b/tst/EnergyPlus/unit/HVACSizingSimulationManager.unit.cc index 7fa8712c0ae..8ba0831ea32 100644 --- a/tst/EnergyPlus/unit/HVACSizingSimulationManager.unit.cc +++ b/tst/EnergyPlus/unit/HVACSizingSimulationManager.unit.cc @@ -119,8 +119,8 @@ class HVACSizingSimulationManagerTest : public EnergyPlusFixture SetupTimePointers(*state, OutputProcessor::TimeStepType::Zone, state->dataGlobal->TimeStepZone); // Set up Time pointer for HB/Zone Simulation SetupTimePointers(*state, OutputProcessor::TimeStepType::System, state->dataHVACGlobal->TimeStepSys); - state->dataGlobal->NumOfTimeStepInHour = 4; - state->dataWeather->TimeStepFraction = 1.0 / double(state->dataGlobal->NumOfTimeStepInHour); + state->dataGlobal->TimeStepsInHour = 4; + state->dataWeather->TimeStepFraction = 1.0 / double(state->dataGlobal->TimeStepsInHour); state->dataOutputProcessor->TimeValue[(int)OutputProcessor::TimeStepType::Zone].TimeStep = &state->dataGlobal->TimeStepZone; state->dataOutputProcessor->TimeValue[(int)OutputProcessor::TimeStepType::Zone].CurMinute = 0; // init @@ -136,8 +136,7 @@ class HVACSizingSimulationManagerTest : public EnergyPlusFixture TEST_F(HVACSizingSimulationManagerTest, WeatherFileDaysTest3) { - - FluidProperties::GetFluidPropertiesData(*state); + state->init_state(*state); // this test emulates two design days and two sizing weather file days periods // calls code related to coincident plant sizing with HVAC sizing simulation @@ -177,7 +176,7 @@ TEST_F(HVACSizingSimulationManagerTest, WeatherFileDaysTest3) state->dataGlobal->TimeStepZone = 15.0 / 60.0; state->dataHVACGlobal->NumOfSysTimeSteps = 3; state->dataHVACGlobal->TimeStepSys = state->dataGlobal->TimeStepZone / state->dataHVACGlobal->NumOfSysTimeSteps; - state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; // first HVAC Sizing Simulation DD emulation state->dataGlobal->KindOfSim = Constant::KindOfSim::HVACSizeDesignDay; @@ -189,7 +188,7 @@ TEST_F(HVACSizingSimulationManagerTest, WeatherFileDaysTest3) for (state->dataGlobal->HourOfDay = 1; state->dataGlobal->HourOfDay <= 24; ++state->dataGlobal->HourOfDay) { // Begin hour loop ... state->dataOutputProcessor->TimeValue[(int)OutputProcessor::TimeStepType::Zone].CurMinute = 0.0; state->dataOutputProcessor->TimeValue[(int)OutputProcessor::TimeStepType::System].CurMinute = 0.0; - for (state->dataGlobal->TimeStep = 1; state->dataGlobal->TimeStep <= state->dataGlobal->NumOfTimeStepInHour; ++state->dataGlobal->TimeStep) { + for (state->dataGlobal->TimeStep = 1; state->dataGlobal->TimeStep <= state->dataGlobal->TimeStepsInHour; ++state->dataGlobal->TimeStep) { for (int SysTimestepLoop = 1; SysTimestepLoop <= state->dataHVACGlobal->NumOfSysTimeSteps; ++SysTimestepLoop) { state->dataOutputProcessor->TimeValue[(int)OutputProcessor::TimeStepType::System].CurMinute += (*state->dataOutputProcessor->TimeValue[(int)OutputProcessor::TimeStepType::System].TimeStep) * 60.0; @@ -215,7 +214,7 @@ TEST_F(HVACSizingSimulationManagerTest, WeatherFileDaysTest3) for (state->dataGlobal->HourOfDay = 1; state->dataGlobal->HourOfDay <= 24; ++state->dataGlobal->HourOfDay) { // Begin hour loop ... state->dataOutputProcessor->TimeValue[(int)OutputProcessor::TimeStepType::Zone].CurMinute = 0.0; state->dataOutputProcessor->TimeValue[(int)OutputProcessor::TimeStepType::System].CurMinute = 0.0; - for (state->dataGlobal->TimeStep = 1; state->dataGlobal->TimeStep <= state->dataGlobal->NumOfTimeStepInHour; ++state->dataGlobal->TimeStep) { + for (state->dataGlobal->TimeStep = 1; state->dataGlobal->TimeStep <= state->dataGlobal->TimeStepsInHour; ++state->dataGlobal->TimeStep) { for (int SysTimestepLoop = 1; SysTimestepLoop <= state->dataHVACGlobal->NumOfSysTimeSteps; ++SysTimestepLoop) { state->dataOutputProcessor->TimeValue[(int)OutputProcessor::TimeStepType::System].CurMinute += (*state->dataOutputProcessor->TimeValue[(int)OutputProcessor::TimeStepType::System].TimeStep) * 60.0; @@ -243,7 +242,7 @@ TEST_F(HVACSizingSimulationManagerTest, WeatherFileDaysTest3) for (state->dataGlobal->HourOfDay = 1; state->dataGlobal->HourOfDay <= 24; ++state->dataGlobal->HourOfDay) { // Begin hour loop ... state->dataOutputProcessor->TimeValue[(int)OutputProcessor::TimeStepType::Zone].CurMinute = 0.0; state->dataOutputProcessor->TimeValue[(int)OutputProcessor::TimeStepType::System].CurMinute = 0.0; - for (state->dataGlobal->TimeStep = 1; state->dataGlobal->TimeStep <= state->dataGlobal->NumOfTimeStepInHour; + for (state->dataGlobal->TimeStep = 1; state->dataGlobal->TimeStep <= state->dataGlobal->TimeStepsInHour; ++state->dataGlobal->TimeStep) { for (int SysTimestepLoop = 1; SysTimestepLoop <= state->dataHVACGlobal->NumOfSysTimeSteps; ++SysTimestepLoop) { state->dataOutputProcessor->TimeValue[(int)OutputProcessor::TimeStepType::System].CurMinute += @@ -272,7 +271,7 @@ TEST_F(HVACSizingSimulationManagerTest, WeatherFileDaysTest3) for (state->dataGlobal->HourOfDay = 1; state->dataGlobal->HourOfDay <= 24; ++state->dataGlobal->HourOfDay) { // Begin hour loop ... state->dataOutputProcessor->TimeValue[(int)OutputProcessor::TimeStepType::Zone].CurMinute = 0.0; state->dataOutputProcessor->TimeValue[(int)OutputProcessor::TimeStepType::System].CurMinute = 0.0; - for (state->dataGlobal->TimeStep = 1; state->dataGlobal->TimeStep <= state->dataGlobal->NumOfTimeStepInHour; + for (state->dataGlobal->TimeStep = 1; state->dataGlobal->TimeStep <= state->dataGlobal->TimeStepsInHour; ++state->dataGlobal->TimeStep) { for (int SysTimestepLoop = 1; SysTimestepLoop <= state->dataHVACGlobal->NumOfSysTimeSteps; ++SysTimestepLoop) { state->dataOutputProcessor->TimeValue[(int)OutputProcessor::TimeStepType::System].CurMinute += @@ -373,7 +372,7 @@ TEST_F(HVACSizingSimulationManagerTest, WeatherFileDaysTest3) TEST_F(HVACSizingSimulationManagerTest, TopDownTestSysTimestep3) { - FluidProperties::GetFluidPropertiesData(*state); + state->init_state(*state); // this test emulates two design days and calls nearly all the OO code related // to coincident plant sizing with HVAC sizing simulation @@ -396,7 +395,7 @@ TEST_F(HVACSizingSimulationManagerTest, TopDownTestSysTimestep3) state->dataGlobal->TimeStepZone = 15.0 / 60.0; state->dataHVACGlobal->NumOfSysTimeSteps = 3; state->dataHVACGlobal->TimeStepSys = state->dataGlobal->TimeStepZone / state->dataHVACGlobal->NumOfSysTimeSteps; - state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; // first HVAC Sizing Simulation DD emulation state->dataGlobal->KindOfSim = Constant::KindOfSim::HVACSizeDesignDay; @@ -407,7 +406,7 @@ TEST_F(HVACSizingSimulationManagerTest, TopDownTestSysTimestep3) for (state->dataGlobal->HourOfDay = 1; state->dataGlobal->HourOfDay <= 24; ++state->dataGlobal->HourOfDay) { // Begin hour loop ... state->dataOutputProcessor->TimeValue[(int)OutputProcessor::TimeStepType::Zone].CurMinute = 0.0; state->dataOutputProcessor->TimeValue[(int)OutputProcessor::TimeStepType::System].CurMinute = 0.0; - for (state->dataGlobal->TimeStep = 1; state->dataGlobal->TimeStep <= state->dataGlobal->NumOfTimeStepInHour; ++state->dataGlobal->TimeStep) { + for (state->dataGlobal->TimeStep = 1; state->dataGlobal->TimeStep <= state->dataGlobal->TimeStepsInHour; ++state->dataGlobal->TimeStep) { for (int SysTimestepLoop = 1; SysTimestepLoop <= state->dataHVACGlobal->NumOfSysTimeSteps; ++SysTimestepLoop) { state->dataOutputProcessor->TimeValue[(int)OutputProcessor::TimeStepType::System].CurMinute += (*state->dataOutputProcessor->TimeValue[(int)OutputProcessor::TimeStepType::System].TimeStep) * 60.0; @@ -432,7 +431,7 @@ TEST_F(HVACSizingSimulationManagerTest, TopDownTestSysTimestep3) for (state->dataGlobal->HourOfDay = 1; state->dataGlobal->HourOfDay <= 24; ++state->dataGlobal->HourOfDay) { // Begin hour loop ... state->dataOutputProcessor->TimeValue[(int)OutputProcessor::TimeStepType::Zone].CurMinute = 0.0; state->dataOutputProcessor->TimeValue[(int)OutputProcessor::TimeStepType::System].CurMinute = 0.0; - for (state->dataGlobal->TimeStep = 1; state->dataGlobal->TimeStep <= state->dataGlobal->NumOfTimeStepInHour; ++state->dataGlobal->TimeStep) { + for (state->dataGlobal->TimeStep = 1; state->dataGlobal->TimeStep <= state->dataGlobal->TimeStepsInHour; ++state->dataGlobal->TimeStep) { for (int SysTimestepLoop = 1; SysTimestepLoop <= state->dataHVACGlobal->NumOfSysTimeSteps; ++SysTimestepLoop) { state->dataOutputProcessor->TimeValue[(int)OutputProcessor::TimeStepType::System].CurMinute += (*state->dataOutputProcessor->TimeValue[(int)OutputProcessor::TimeStepType::System].TimeStep) * 60.0; @@ -520,8 +519,7 @@ TEST_F(HVACSizingSimulationManagerTest, TopDownTestSysTimestep3) TEST_F(HVACSizingSimulationManagerTest, TopDownTestSysTimestep1) { - - FluidProperties::GetFluidPropertiesData(*state); + state->init_state(*state); // this test emulates two design days and calls nearly all the OO code related // to coincident plant sizing with HVAC sizing simulation @@ -546,7 +544,7 @@ TEST_F(HVACSizingSimulationManagerTest, TopDownTestSysTimestep1) state->dataGlobal->TimeStepZone = 15.0 / 60.0; state->dataHVACGlobal->NumOfSysTimeSteps = 1; state->dataHVACGlobal->TimeStepSys = state->dataGlobal->TimeStepZone / state->dataHVACGlobal->NumOfSysTimeSteps; - state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; // first HVAC Sizing Simulation DD emulation state->dataGlobal->KindOfSim = Constant::KindOfSim::HVACSizeDesignDay; @@ -557,7 +555,7 @@ TEST_F(HVACSizingSimulationManagerTest, TopDownTestSysTimestep1) for (state->dataGlobal->HourOfDay = 1; state->dataGlobal->HourOfDay <= 24; ++state->dataGlobal->HourOfDay) { // Begin hour loop ... state->dataOutputProcessor->TimeValue[(int)OutputProcessor::TimeStepType::Zone].CurMinute = 0.0; state->dataOutputProcessor->TimeValue[(int)OutputProcessor::TimeStepType::System].CurMinute = 0.0; - for (state->dataGlobal->TimeStep = 1; state->dataGlobal->TimeStep <= state->dataGlobal->NumOfTimeStepInHour; ++state->dataGlobal->TimeStep) { + for (state->dataGlobal->TimeStep = 1; state->dataGlobal->TimeStep <= state->dataGlobal->TimeStepsInHour; ++state->dataGlobal->TimeStep) { for (int SysTimestepLoop = 1; SysTimestepLoop <= state->dataHVACGlobal->NumOfSysTimeSteps; ++SysTimestepLoop) { state->dataOutputProcessor->TimeValue[(int)OutputProcessor::TimeStepType::System].CurMinute += @@ -584,7 +582,7 @@ TEST_F(HVACSizingSimulationManagerTest, TopDownTestSysTimestep1) for (state->dataGlobal->HourOfDay = 1; state->dataGlobal->HourOfDay <= 24; ++state->dataGlobal->HourOfDay) { // Begin hour loop ... state->dataOutputProcessor->TimeValue[(int)OutputProcessor::TimeStepType::Zone].CurMinute = 0.0; state->dataOutputProcessor->TimeValue[(int)OutputProcessor::TimeStepType::System].CurMinute = 0.0; - for (state->dataGlobal->TimeStep = 1; state->dataGlobal->TimeStep <= state->dataGlobal->NumOfTimeStepInHour; ++state->dataGlobal->TimeStep) { + for (state->dataGlobal->TimeStep = 1; state->dataGlobal->TimeStep <= state->dataGlobal->TimeStepsInHour; ++state->dataGlobal->TimeStep) { for (int SysTimestepLoop = 1; SysTimestepLoop <= state->dataHVACGlobal->NumOfSysTimeSteps; ++SysTimestepLoop) { state->dataOutputProcessor->TimeValue[(int)OutputProcessor::TimeStepType::System].CurMinute += @@ -611,9 +609,7 @@ TEST_F(HVACSizingSimulationManagerTest, TopDownTestSysTimestep1) TEST_F(HVACSizingSimulationManagerTest, VarySysTimesteps) { - - FluidProperties::GetFluidPropertiesData(*state); - + state->init_state(*state); // this test emulates two design days and calls nearly all the OO code related // to coincident plant sizing with HVAC sizing simulation // this test run varies the system timestep some to test irregular @@ -638,7 +634,7 @@ TEST_F(HVACSizingSimulationManagerTest, VarySysTimesteps) state->dataGlobal->TimeStepZone = 15.0 / 60.0; state->dataHVACGlobal->NumOfSysTimeSteps = 1; state->dataHVACGlobal->TimeStepSys = state->dataGlobal->TimeStepZone / state->dataHVACGlobal->NumOfSysTimeSteps; - state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; // first HVAC Sizing Simulation DD emulation state->dataGlobal->KindOfSim = Constant::KindOfSim::HVACSizeDesignDay; @@ -649,11 +645,11 @@ TEST_F(HVACSizingSimulationManagerTest, VarySysTimesteps) for (state->dataGlobal->HourOfDay = 1; state->dataGlobal->HourOfDay <= 24; ++state->dataGlobal->HourOfDay) { // Begin hour loop ... state->dataOutputProcessor->TimeValue[(int)OutputProcessor::TimeStepType::Zone].CurMinute = 0.0; state->dataOutputProcessor->TimeValue[(int)OutputProcessor::TimeStepType::System].CurMinute = 0.0; - for (state->dataGlobal->TimeStep = 1; state->dataGlobal->TimeStep <= state->dataGlobal->NumOfTimeStepInHour; ++state->dataGlobal->TimeStep) { + for (state->dataGlobal->TimeStep = 1; state->dataGlobal->TimeStep <= state->dataGlobal->TimeStepsInHour; ++state->dataGlobal->TimeStep) { state->dataHVACGlobal->NumOfSysTimeSteps = state->dataGlobal->TimeStep; state->dataHVACGlobal->TimeStepSys = state->dataGlobal->TimeStepZone / state->dataHVACGlobal->NumOfSysTimeSteps; - state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; for (int SysTimestepLoop = 1; SysTimestepLoop <= state->dataHVACGlobal->NumOfSysTimeSteps; ++SysTimestepLoop) { state->dataOutputProcessor->TimeValue[(int)OutputProcessor::TimeStepType::System].CurMinute += @@ -680,10 +676,10 @@ TEST_F(HVACSizingSimulationManagerTest, VarySysTimesteps) for (state->dataGlobal->HourOfDay = 1; state->dataGlobal->HourOfDay <= 24; ++state->dataGlobal->HourOfDay) { // Begin hour loop ... state->dataOutputProcessor->TimeValue[(int)OutputProcessor::TimeStepType::Zone].CurMinute = 0.0; state->dataOutputProcessor->TimeValue[(int)OutputProcessor::TimeStepType::System].CurMinute = 0.0; - for (state->dataGlobal->TimeStep = 1; state->dataGlobal->TimeStep <= state->dataGlobal->NumOfTimeStepInHour; ++state->dataGlobal->TimeStep) { + for (state->dataGlobal->TimeStep = 1; state->dataGlobal->TimeStep <= state->dataGlobal->TimeStepsInHour; ++state->dataGlobal->TimeStep) { state->dataHVACGlobal->NumOfSysTimeSteps = state->dataGlobal->TimeStep; state->dataHVACGlobal->TimeStepSys = state->dataGlobal->TimeStepZone / state->dataHVACGlobal->NumOfSysTimeSteps; - state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; for (int SysTimestepLoop = 1; SysTimestepLoop <= state->dataHVACGlobal->NumOfSysTimeSteps; ++SysTimestepLoop) { state->dataOutputProcessor->TimeValue[(int)OutputProcessor::TimeStepType::System].CurMinute += diff --git a/tst/EnergyPlus/unit/HVACStandaloneERV.unit.cc b/tst/EnergyPlus/unit/HVACStandaloneERV.unit.cc index 0c788ddb390..1642565cd40 100644 --- a/tst/EnergyPlus/unit/HVACStandaloneERV.unit.cc +++ b/tst/EnergyPlus/unit/HVACStandaloneERV.unit.cc @@ -70,7 +70,6 @@ using namespace DataHeatBalance; using namespace DataZoneEquipment; using namespace DataSizing; using namespace Fans; -using namespace ScheduleManager; TEST_F(EnergyPlusFixture, HVACStandAloneERV_Test1) { @@ -106,6 +105,8 @@ TEST_F(EnergyPlusFixture, HVACStandAloneERV_Test1) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + state->dataEnvrn->StdRhoAir = 1.0; state->dataZoneEquip->ZoneEquipConfig.allocate(1); state->dataZoneEquip->ZoneEquipConfig(1).ZoneName = "Zone 1"; @@ -120,10 +121,10 @@ TEST_F(EnergyPlusFixture, HVACStandAloneERV_Test1) state->dataHeatBal->People.allocate(state->dataHeatBal->TotPeople); state->dataHeatBal->People(1).ZonePtr = 1; state->dataHeatBal->People(1).NumberOfPeople = 100.0; - state->dataHeatBal->People(1).NumberOfPeoplePtr = ScheduleManager::ScheduleAlwaysOn; // From dataglobals, always returns a 1 for schedule value + state->dataHeatBal->People(1).numberOfPeopleSched = Sched::GetScheduleAlwaysOn(*state); state->dataHeatBal->People(2).ZonePtr = 1; state->dataHeatBal->People(2).NumberOfPeople = 200.0; - state->dataHeatBal->People(2).NumberOfPeoplePtr = ScheduleManager::ScheduleAlwaysOn; // From dataglobals, always returns a 1 for schedule value + state->dataHeatBal->People(2).numberOfPeopleSched = Sched::GetScheduleAlwaysOn(*state); state->dataHVACStandAloneERV->StandAloneERV.allocate(1); @@ -209,9 +210,9 @@ TEST_F(EnergyPlusFixture, HVACStandAloneERV_Test2) ASSERT_TRUE(process_idf(idf_objects)); state->dataEnvrn->StdRhoAir = 1.0; - state->dataGlobal->NumOfTimeStepInHour = 1; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 60; // must initialize this to get schedules initialized - ProcessScheduleInput(*state); // read schedules + state->dataGlobal->TimeStepsInHour = 1; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 60; // must initialize this to get schedules initialized + state->init_state(*state); GetFanInput(*state); @@ -237,10 +238,10 @@ TEST_F(EnergyPlusFixture, HVACStandAloneERV_Test2) state->dataHeatBal->People.allocate(state->dataHeatBal->TotPeople); state->dataHeatBal->People(1).ZonePtr = 1; state->dataHeatBal->People(1).NumberOfPeople = 10.0; - state->dataHeatBal->People(1).NumberOfPeoplePtr = ScheduleManager::ScheduleAlwaysOn; // always returns a 1 for schedule value + state->dataHeatBal->People(1).numberOfPeopleSched = Sched::GetScheduleAlwaysOn(*state); state->dataHeatBal->People(2).ZonePtr = 1; state->dataHeatBal->People(2).NumberOfPeople = 20.0; - state->dataHeatBal->People(2).NumberOfPeoplePtr = ScheduleManager::ScheduleAlwaysOn; // always returns a 1 for schedule value + state->dataHeatBal->People(2).numberOfPeopleSched = Sched::GetScheduleAlwaysOn(*state); state->dataHVACStandAloneERV->StandAloneERV.allocate(1); auto &erv = state->dataHVACStandAloneERV->StandAloneERV(1); diff --git a/tst/EnergyPlus/unit/HVACUnitaryBypassVAV.unit.cc b/tst/EnergyPlus/unit/HVACUnitaryBypassVAV.unit.cc index e53ed583850..dae8fd1185e 100644 --- a/tst/EnergyPlus/unit/HVACUnitaryBypassVAV.unit.cc +++ b/tst/EnergyPlus/unit/HVACUnitaryBypassVAV.unit.cc @@ -94,10 +94,14 @@ class CBVAVSys : public EnergyPlusFixture bool ErrorsFound = false; protected: - virtual void SetUp() + virtual void SetUp() // Please don't do this { EnergyPlusFixture::SetUp(); // Sets up the base fixture first. + state->init_state(*state); + + state->dataGlobal->TimeStepZone = 0; // Why do we need to override this? Why is it not okay to just set this? + state->dataGlobal->DayOfSim = 1; state->dataGlobal->HourOfDay = 1; @@ -120,7 +124,7 @@ class CBVAVSys : public EnergyPlusFixture state->dataZoneEquip->ZoneEquipConfig(1).ReturnNode(1) = 21; state->dataZoneEquip->ZoneEquipConfig(1).FixedReturnFlow.allocate(1); state->dataHeatBal->Zone(1).SystemZoneNodeNumber = state->dataZoneEquip->ZoneEquipConfig(1).ZoneNode; - state->dataZoneEquip->ZoneEquipConfig(1).ReturnFlowSchedPtrNum = ScheduleManager::ScheduleAlwaysOn; + state->dataZoneEquip->ZoneEquipConfig(1).returnFlowSched = Sched::GetScheduleAlwaysOn(*state); state->dataZoneEquip->ZoneEquipList(1).Name = "ZONEEQUIPMENT"; int maxEquipCount = 1; state->dataZoneEquip->ZoneEquipList(1).NumOfEquipTypes = maxEquipCount; @@ -190,7 +194,7 @@ class CBVAVSys : public EnergyPlusFixture auto &cbvav(state->dataHVACUnitaryBypassVAV->CBVAV(1)); cbvav.Name = "CBVAVAirLoop"; cbvav.UnitType = "AirLoopHVAC:UnitaryHeatCool:VAVChangeoverBypass"; - cbvav.SchedPtr = -1; + cbvav.availSched = Sched::GetScheduleAlwaysOn(*state); cbvav.ControlledZoneNodeNum.allocate(1); cbvav.ControlledZoneNodeNum(1) = 1; cbvav.DXCoolCoilIndexNum = 1; @@ -224,7 +228,7 @@ class CBVAVSys : public EnergyPlusFixture state->dataDXCoils->DXCoil(1).RatedEIR(1) = 0.3; state->dataDXCoils->DXCoil(1).RatedSHR.allocate(1); state->dataDXCoils->DXCoil(1).RatedSHR(1) = 0.7; - state->dataDXCoils->DXCoil(1).SchedPtr = -1; + state->dataDXCoils->DXCoil(1).availSched = Sched::GetScheduleAlwaysOn(*state); state->dataDXCoils->DXCoilOutletTemp.allocate(1); state->dataDXCoils->DXCoilOutletHumRat.allocate(1); state->dataDXCoils->DXCoilPartLoadRatio.allocate(1); @@ -281,7 +285,7 @@ class CBVAVSys : public EnergyPlusFixture cbvav.HeatingCoilOutletNode = state->dataHeatingCoils->HeatingCoil(1).AirOutletNodeNum; state->dataHeatingCoils->HeatingCoil(1).NominalCapacity = 10000.0; state->dataHeatingCoils->HeatingCoil(1).Efficiency = 1.0; - state->dataHeatingCoils->HeatingCoil(1).SchedPtr = -1; + state->dataHeatingCoils->HeatingCoil(1).availSched = Sched::GetScheduleAlwaysOn(*state); cbvav.CBVAVBoxOutletNode.allocate(1); cbvav.CBVAVBoxOutletNode(1) = 11; @@ -644,10 +648,11 @@ TEST_F(EnergyPlusFixture, UnitaryBypassVAV_GetInputZoneEquipment) ASSERT_TRUE(process_idf(idf_objects)); // read idf objects + state->init_state(*state); + bool ErrorsFound = false; bool firstHVACIteration = true; // Read objects - SimulationManager::GetProjectData(*state); HeatBalanceManager::GetProjectControlData(*state, ErrorsFound); EXPECT_FALSE(ErrorsFound); HeatBalanceManager::GetHeatBalanceInput(*state); @@ -753,7 +758,6 @@ TEST_F(CBVAVSys, UnitaryBypassVAV_AutoSize) TEST_F(CBVAVSys, UnitaryBypassVAV_NoOASys) { - // reference CBVAV data auto &cbvav(state->dataHVACUnitaryBypassVAV->CBVAV(1)); cbvav.FanVolFlow = 0.5; @@ -1649,12 +1653,13 @@ TEST_F(EnergyPlusFixture, UnitaryBypassVAV_ParentElectricityRateTest) ASSERT_TRUE(process_idf(idf_objects)); // read idf objects + state->init_state(*state); + int CBVAVNum = 1; bool HXUnitOn = false; bool ErrorsFound = false; bool firstHVACIteration = true; // get various objects - SimulationManager::GetProjectData(*state); HeatBalanceManager::GetProjectControlData(*state, ErrorsFound); EXPECT_FALSE(ErrorsFound); HeatBalanceManager::GetHeatBalanceInput(*state); @@ -1736,7 +1741,7 @@ TEST_F(EnergyPlusFixture, UnitaryBypassVAV_ParentElectricityRateTest) BypassVAV.changeOverTimer = -1.0; state->dataGlobal->DayOfSim = 15; state->dataGlobal->HourOfDay = 6; - state->dataScheduleMgr->Schedule(BypassVAV.SchedPtr).CurrentValue = 1.0; + BypassVAV.availSched->currentVal = 1.0; Real64 QUnitOut = 0.0; Real64 OnOffAirFlowRatio = 1; diff --git a/tst/EnergyPlus/unit/HVACVariableRefrigerantFlow.unit.cc b/tst/EnergyPlus/unit/HVACVariableRefrigerantFlow.unit.cc index c7f26710338..5655f84a493 100644 --- a/tst/EnergyPlus/unit/HVACVariableRefrigerantFlow.unit.cc +++ b/tst/EnergyPlus/unit/HVACVariableRefrigerantFlow.unit.cc @@ -111,7 +111,6 @@ using namespace EnergyPlus::HeatingCoils; using namespace EnergyPlus::GlobalNames; using namespace EnergyPlus::PlantManager; using namespace EnergyPlus::Psychrometrics; -using namespace EnergyPlus::ScheduleManager; using namespace EnergyPlus::SimulationManager; using namespace EnergyPlus::SizingManager; @@ -131,6 +130,8 @@ class AirLoopFixture : public EnergyPlusFixture { EnergyPlusFixture::SetUp(); // Sets up the base fixture first. + state->init_state(*state); + state->dataEnvrn->StdRhoAir = Psychrometrics::PsyRhoAirFnPbTdbW(*state, 101325.0, 20.0, 0.0); // initialize StdRhoAir state->dataEnvrn->OutBaroPress = 101325.0; state->dataSize->DesDayWeath.allocate(1); @@ -150,7 +151,7 @@ class AirLoopFixture : public EnergyPlusFixture state->dataLoopNodes->NodeID.allocate(50); state->dataHeatBalFanSys->TempControlType.allocate(numZones); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::DualSetPointWithDeadBand; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::DualHeatCool; state->dataHeatBal->Zone.allocate(numZones); state->dataZoneEquip->ZoneEquipConfig.allocate(numZones); state->dataZoneEquip->ZoneEquipList.allocate(numZones); @@ -244,7 +245,7 @@ class AirLoopFixture : public EnergyPlusFixture thisZoneEqConfig.ExhaustNode.allocate(NumZoneExhaustNodes); thisZoneEqConfig.ExhaustNode(1) = zoneExhNode1; thisZoneEqConfig.EquipListIndex = zoneNum; - thisZoneEqConfig.ReturnFlowSchedPtrNum = ScheduleManager::ScheduleAlwaysOn; + thisZoneEqConfig.returnFlowSched = Sched::GetScheduleAlwaysOn(*state); auto &thisZone(state->dataHeatBal->Zone(zoneNum)); thisZone.Name = "ZONE1"; @@ -355,9 +356,12 @@ class AirLoopFixture : public EnergyPlusFixture int condNodeNum = 1; + auto *sched1 = Sched::AddScheduleConstant(*state, "sch1"); + auto *sched2 = Sched::AddScheduleConstant(*state, "sch2"); + VRFCond.VRFSystemTypeNum = 1; VRFCond.VRFAlgorithmType = AlgorithmType::SysCurve; - VRFCond.SchedPtr = 1; + VRFCond.availSched = sched1; VRFCond.CoolingCapacity = 10000.0; VRFCond.CoolingCOP = 3.0; VRFCond.CoolingCombinationRatio = 1.0; @@ -400,10 +404,10 @@ class AirLoopFixture : public EnergyPlusFixture terminalUnitList.CoolingCoilPresent = true; terminalUnitList.HeatingCoilPresent.allocate(1); terminalUnitList.HeatingCoilPresent = true; - terminalUnitList.CoolingCoilAvailSchPtr.allocate(1); - terminalUnitList.CoolingCoilAvailSchPtr = Sch1; - terminalUnitList.HeatingCoilAvailSchPtr.allocate(1); - terminalUnitList.HeatingCoilAvailSchPtr = Sch1; + terminalUnitList.coolingCoilAvailScheds.allocate(1); + terminalUnitList.coolingCoilAvailScheds(1) = sched1; + terminalUnitList.heatingCoilAvailScheds.allocate(1); + terminalUnitList.heatingCoilAvailScheds(1) = sched1; terminalUnitList.CoolingCoilAvailable.allocate(1); terminalUnitList.HeatingCoilAvailable.allocate(1); @@ -431,7 +435,7 @@ class AirLoopFixture : public EnergyPlusFixture VRFTU.Name = "VRFTU1"; VRFTU.type = TUType::ConstantVolume; - VRFTU.SchedPtr = Sch1; + VRFTU.availSched = sched1; VRFTU.VRFSysNum = numVRFCond; VRFTU.TUListIndex = TUNum; VRFTU.IndexToTUInTUList = TUNum; @@ -454,8 +458,8 @@ class AirLoopFixture : public EnergyPlusFixture VRFTU.NoCoolHeatOutAirVolFlow = DataSizing::AutoSize; VRFTU.MinOperatingPLR = 0.1; VRFTU.fanType = HVAC::FanType::Invalid; - VRFTU.FanOpModeSchedPtr = Sch2; - VRFTU.FanAvailSchedPtr = Sch1; + VRFTU.fanOpModeSched = sched2; + VRFTU.fanAvailSched = sched1; VRFTU.FanIndex = 0; VRFTU.fanPlace = HVAC::FanPlace::Invalid; VRFTU.OAMixerName = "OAMixer1"; @@ -484,7 +488,7 @@ class AirLoopFixture : public EnergyPlusFixture state->dataDXCoils->DXCoil(1).RatedAirVolFlowRate = DataSizing::AutoSize; state->dataDXCoils->DXCoil(1).RatedTotCap = DataSizing::AutoSize; state->dataDXCoils->DXCoil(1).RatedSHR = DataSizing::AutoSize; - state->dataDXCoils->DXCoil(1).SchedPtr = Sch1; + state->dataDXCoils->DXCoil(1).availSched = sched1; state->dataDXCoils->DXCoil(1).CCapFTemp.allocate(1); state->dataDXCoils->DXCoil(1).CCapFTemp(1) = Sch1; state->dataDXCoils->DXCoil(1).CCapFFlow.allocate(1); @@ -502,16 +506,13 @@ class AirLoopFixture : public EnergyPlusFixture state->dataDXCoils->DXCoil(2).RatedAirVolFlowRate = DataSizing::AutoSize; state->dataDXCoils->DXCoil(2).RatedTotCap = DataSizing::AutoSize; state->dataDXCoils->DXCoil(2).RatedSHR = DataSizing::AutoSize; - state->dataDXCoils->DXCoil(2).SchedPtr = Sch1; + state->dataDXCoils->DXCoil(2).availSched = sched1; state->dataDXCoils->DXCoil(2).CCapFTemp.allocate(1); state->dataDXCoils->DXCoil(2).CCapFTemp(1) = Sch1; state->dataDXCoils->DXCoil(2).CCapFFlow.allocate(1); state->dataDXCoils->DXCoil(2).CCapFFlow(1) = Sch1; state->dataDXCoils->DXCoil(2).PLFFPLR.allocate(1); state->dataDXCoils->DXCoil(2).PLFFPLR(1) = Sch1; - - // set up schedules - state->dataScheduleMgr->Schedule.allocate(10); } virtual void TearDown() @@ -536,10 +537,10 @@ TEST_F(AirLoopFixture, VRF_SysModel_inAirloop) // node number set up in fixture EXPECT_EQ(ZoneInletAirNode, thisTU.VRFTUOutletNodeNum); - state->dataScheduleMgr->Schedule(state->dataHVACVarRefFlow->VRF(curSysNum).SchedPtr).CurrentValue = 1.0; // enable the VRF condenser - state->dataScheduleMgr->Schedule(thisTU.SchedPtr).CurrentValue = 1.0; // enable the terminal unit - state->dataScheduleMgr->Schedule(thisTU.FanAvailSchedPtr).CurrentValue = 1.0; // turn on fan - state->dataScheduleMgr->Schedule(thisTU.FanOpModeSchedPtr).CurrentValue = 1.0; // set constant fan operating mode + state->dataHVACVarRefFlow->VRF(curSysNum).availSched->currentVal = 1.0; // enable the VRF condenser + thisTU.availSched->currentVal = 1.0; // enable the terminal unit + thisTU.fanAvailSched->currentVal = 1.0; // turn on fan + thisTU.fanOpModeSched->currentVal = 1.0; // set constant fan operating mode state->dataZoneEnergyDemand->ZoneSysEnergyDemand(curZoneNum).RemainingOutputRequired = 0.0; // set load = 0 state->dataZoneEnergyDemand->ZoneSysEnergyDemand(curZoneNum).RemainingOutputReqToCoolSP = 0.0; @@ -2344,7 +2345,8 @@ TEST_F(EnergyPlusFixture, VRF_FluidTCtrl_VRFOU_Compressor) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + state->dataGlobal->BeginEnvrnFlag = true; state->dataSize->CurZoneEqNum = 1; state->dataEnvrn->OutBaroPress = 101325; // sea level @@ -2352,14 +2354,11 @@ TEST_F(EnergyPlusFixture, VRF_FluidTCtrl_VRFOU_Compressor) state->dataEnvrn->StdRhoAir = PsyRhoAirFnPbTdbW(*state, state->dataEnvrn->OutBaroPress, 20.0, 0.0); // Read in IDF - ProcessScheduleInput(*state); // read schedules Curve::GetCurveInput(*state); // read curves // test consecutive call to fluid properties getInput - FluidProperties::GetFluidPropertiesData(*state); // read refrigerant properties EXPECT_EQ(2, state->dataFluidProps->refrigs.isize()); EXPECT_EQ(1, state->dataFluidProps->glycols.isize()); - FluidProperties::GetFluidPropertiesData(*state); // should never happen but if it does it's safe EXPECT_EQ(2, state->dataFluidProps->refrigs.isize()); EXPECT_EQ(1, state->dataFluidProps->glycols.isize()); @@ -2599,7 +2598,8 @@ TEST_F(EnergyPlusFixture, VRF_FluidTCtrl_VRFOU_Coil) { // PURPOSE OF THIS TEST: // Test a group of methods related with the outdoor unit coil calculations in the VRF_FluidTCtrl model. - + state->init_state(*state); + using namespace HVACVariableRefrigerantFlow; // Allocate @@ -2632,7 +2632,6 @@ TEST_F(EnergyPlusFixture, VRF_FluidTCtrl_VRFOU_Coil) // Pre-process state->dataEnvrn->OutBaroPress = OutBaroPress; - InitializePsychRoutines(*state); // Run and Check: VRFOU_Cap { // Test the method VRFOU_Cap, which determines the VRF OU heat transfer rate, given refrigerant side temperature, @@ -2823,7 +2822,8 @@ TEST_F(EnergyPlusFixture, VRF_FluidTCtrl_GetCoilInput) " Dimensionless; !- Output Unit Type "}); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + // Run the method GetDXCoils(*state); @@ -2909,7 +2909,8 @@ TEST_F(EnergyPlusFixture, VRF_FluidTCtrl_CalcVRFIUAirFlow) // PURPOSE OF THIS TEST: // Test the method CalcVRFIUAirFlow, which analyzes the VRF Indoor Unit operations given zonal loads. // Calculated parameters includie: (1) Fan Speed Ratio, (2) SH/SC Degrees, and (3) Coil Inlet/Outlet conditions - + state->init_state(*state); + using namespace DXCoils; using namespace DataZoneEnergyDemands; using namespace EnergyPlus::Psychrometrics; @@ -2938,7 +2939,6 @@ TEST_F(EnergyPlusFixture, VRF_FluidTCtrl_CalcVRFIUAirFlow) FanSpdRatio = 0; Wout = 1; state->dataEnvrn->OutBaroPress = 101570; - InitializePsychRoutines(*state); state->dataDXCoils->DXCoil(CoolCoilIndex).C1Te = 0; state->dataDXCoils->DXCoil(CoolCoilIndex).C2Te = 0.804; @@ -3757,7 +3757,8 @@ TEST_F(EnergyPlusFixture, VRFTest_SysCurve) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + state->dataGlobal->BeginEnvrnFlag = true; state->dataSize->CurZoneEqNum = 1; state->dataEnvrn->OutBaroPress = 101325; // sea level @@ -3776,7 +3777,6 @@ TEST_F(EnergyPlusFixture, VRFTest_SysCurve) state->dataZoneEnergyDemand->ZoneSysEnergyDemand.allocate(1); state->dataZoneTempPredictorCorrector->zoneHeatBalance.allocate(1); - ProcessScheduleInput(*state); // read schedules GetCurveInput(*state); // read curves GetZoneData(*state, ErrorsFound); // read zone data EXPECT_FALSE(ErrorsFound); @@ -3784,11 +3784,10 @@ TEST_F(EnergyPlusFixture, VRFTest_SysCurve) GetZoneEquipmentData(*state); // read equipment list and connections ZoneInletAirNode = GetVRFTUZoneInletAirNode(*state, VRFTUNum); // trigger GetVRFInput by calling a mining function - state->dataScheduleMgr->Schedule(state->dataHVACVarRefFlow->VRF(VRFCond).SchedPtr).CurrentValue = 1.0; // enable the VRF condenser - state->dataScheduleMgr->Schedule(state->dataHVACVarRefFlow->VRFTU(VRFTUNum).SchedPtr).CurrentValue = 1.0; // enable the terminal unit - state->dataScheduleMgr->Schedule(state->dataHVACVarRefFlow->VRFTU(VRFTUNum).FanAvailSchedPtr).CurrentValue = 1.0; // turn on fan - state->dataScheduleMgr->Schedule(state->dataHVACVarRefFlow->VRFTU(VRFTUNum).FanOpModeSchedPtr).CurrentValue = - 0.0; // set cycling fan operating mode + state->dataHVACVarRefFlow->VRF(VRFCond).availSched->currentVal = 1.0; // enable the VRF condenser + state->dataHVACVarRefFlow->VRFTU(VRFTUNum).availSched->currentVal = 1.0; // enable the terminal unit + state->dataHVACVarRefFlow->VRFTU(VRFTUNum).fanAvailSched->currentVal = 1.0; // turn on fan + state->dataHVACVarRefFlow->VRFTU(VRFTUNum).fanOpModeSched->currentVal = 0.0; // set cycling fan operating mode // Test coil sizing @@ -4055,12 +4054,11 @@ TEST_F(EnergyPlusFixture, VRFTest_SysCurve) } // test other ThermostatPriority control types - state->dataHeatBalFanSys->ZoneThermostatSetPointHi.allocate(1); - state->dataHeatBalFanSys->ZoneThermostatSetPointHi = 24.0; - state->dataHeatBalFanSys->ZoneThermostatSetPointLo.allocate(1); - state->dataHeatBalFanSys->ZoneThermostatSetPointLo = 21.0; + state->dataHeatBalFanSys->zoneTstatSetpts.allocate(1); + state->dataHeatBalFanSys->zoneTstatSetpts(1).setptHi = 24.0; + state->dataHeatBalFanSys->zoneTstatSetpts(1).setptLo = 21.0; state->dataHeatBalFanSys->TempControlType.allocate(1); - state->dataHeatBalFanSys->TempControlType = HVAC::ThermostatType::DualSetPointWithDeadBand; + state->dataHeatBalFanSys->TempControlType = HVAC::SetptType::DualHeatCool; state->dataZoneTempPredictorCorrector->zoneHeatBalance.allocate(1); state->dataZoneTempPredictorCorrector->zoneHeatBalance(1).ZT = 25.0; state->dataLoopNodes->Node(state->dataHVACVarRefFlow->VRFTU(VRFTUNum).ZoneAirNode).Temp = 27.0; @@ -4179,8 +4177,7 @@ TEST_F(EnergyPlusFixture, VRFTest_SysCurve) 400.0; // set load equal to small value less than expected fan heat state->dataZoneEnergyDemand->ZoneSysEnergyDemand(CurZoneNum).RemainingOutputReqToCoolSP = 500.0; state->dataZoneEnergyDemand->ZoneSysEnergyDemand(CurZoneNum).RemainingOutputReqToHeatSP = 400.0; - state->dataScheduleMgr->Schedule(state->dataHVACVarRefFlow->VRFTU(VRFTUNum).FanOpModeSchedPtr).CurrentValue = - 1.0; // set constant fan operating mode + state->dataHVACVarRefFlow->VRFTU(VRFTUNum).fanOpModeSched->currentVal = 1.0; // set constant fan operating mode SimulateVRF(*state, state->dataHVACVarRefFlow->VRFTU(VRFTUNum).Name, FirstHVACIteration, @@ -4206,8 +4203,7 @@ TEST_F(EnergyPlusFixture, VRFTest_SysCurve) 800.0; // set load equal to small value less than expected fan heat state->dataZoneEnergyDemand->ZoneSysEnergyDemand(CurZoneNum).RemainingOutputReqToCoolSP = 900.0; state->dataZoneEnergyDemand->ZoneSysEnergyDemand(CurZoneNum).RemainingOutputReqToHeatSP = 800.0; - state->dataScheduleMgr->Schedule(state->dataHVACVarRefFlow->VRFTU(VRFTUNum).FanOpModeSchedPtr).CurrentValue = - 1.0; // set constant fan operating mode + state->dataHVACVarRefFlow->VRFTU(VRFTUNum).fanOpModeSched->currentVal = 1.0; // set constant fan operating mode SimulateVRF(*state, state->dataHVACVarRefFlow->VRFTU(VRFTUNum).Name, FirstHVACIteration, @@ -4246,8 +4242,7 @@ TEST_F(EnergyPlusFixture, VRFTest_SysCurve) EXPECT_EQ(state->dataLoopNodes->Node(state->dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUOutletNodeNum).MassFlowRate, 0.0); // flow should be = 0 at no load flow rate for constant fan mode in this example - state->dataScheduleMgr->Schedule(state->dataHVACVarRefFlow->VRFTU(VRFTUNum).FanOpModeSchedPtr).CurrentValue = - 0.0; // set cycling fan operating mode + state->dataHVACVarRefFlow->VRFTU(VRFTUNum).fanOpModeSched->currentVal = 0.0; // set cycling fan operating mode SimulateVRF(*state, state->dataHVACVarRefFlow->VRFTU(VRFTUNum).Name, FirstHVACIteration, @@ -4889,7 +4884,8 @@ TEST_F(EnergyPlusFixture, VRFTest_SysCurve_GetInputFailers) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + state->dataGlobal->BeginEnvrnFlag = true; state->dataSize->CurZoneEqNum = 1; state->dataEnvrn->OutBaroPress = 101325; // sea level @@ -4908,7 +4904,6 @@ TEST_F(EnergyPlusFixture, VRFTest_SysCurve_GetInputFailers) state->dataZoneEnergyDemand->ZoneSysEnergyDemand.allocate(1); state->dataZoneTempPredictorCorrector->zoneHeatBalance.allocate(1); - ProcessScheduleInput(*state); // read schedules GetCurveInput(*state); // read curves GetZoneData(*state, ErrorsFound); // read zone data EXPECT_FALSE(ErrorsFound); @@ -5739,7 +5734,10 @@ TEST_F(EnergyPlusFixture, VRFTest_SysCurve_WaterCooled) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->dataGlobal->TimeStepsInHour = 4; + state->dataGlobal->MinutesInTimeStep = 60 / state->dataGlobal->TimeStepsInHour; + state->init_state(*state); + state->dataGlobal->BeginEnvrnFlag = true; state->dataSize->CurZoneEqNum = 1; state->dataEnvrn->OutBaroPress = 101325; // sea level @@ -5759,11 +5757,9 @@ TEST_F(EnergyPlusFixture, VRFTest_SysCurve_WaterCooled) state->dataZoneTempPredictorCorrector->zoneHeatBalance.allocate(1); Array2D DummyArray; // Sky temperature - state->dataGlobal->NumOfTimeStepInHour = 4; - state->dataGlobal->MinutesPerTimeStep = 60 / state->dataGlobal->NumOfTimeStepInHour; - DummyArray.allocate(state->dataGlobal->NumOfTimeStepInHour, 24); + DummyArray.allocate(state->dataGlobal->TimeStepsInHour, Constant::iHoursInDay); DummyArray = 0.0; - ScheduleManager::GetScheduleValuesForDay(*state, 1, DummyArray, 58, 3); + Sched::GetSchedule(*state, "MAIN LOOP TEMP SCH")->getDayVals(*state, DummyArray, 58, 3); Curve::GetCurveInput(*state); // read curves HeatBalanceManager::GetZoneData(*state, ErrorsFound); // read zone data @@ -5780,11 +5776,10 @@ TEST_F(EnergyPlusFixture, VRFTest_SysCurve_WaterCooled) ZoneInletAirNode = GetVRFTUZoneInletAirNode(*state, VRFTUNum); // trigger GetVRFInput by calling a mining function state->dataAirLoop->AirLoopInputsFilled = true; - state->dataScheduleMgr->Schedule(state->dataHVACVarRefFlow->VRF(VRFCond).SchedPtr).CurrentValue = 1.0; // enable the VRF condenser - state->dataScheduleMgr->Schedule(state->dataHVACVarRefFlow->VRFTU(VRFTUNum).SchedPtr).CurrentValue = 1.0; // enable the terminal unit - state->dataScheduleMgr->Schedule(state->dataHVACVarRefFlow->VRFTU(VRFTUNum).FanAvailSchedPtr).CurrentValue = 1.0; // turn on fan - state->dataScheduleMgr->Schedule(state->dataHVACVarRefFlow->VRFTU(VRFTUNum).FanOpModeSchedPtr).CurrentValue = - 0.0; // set cycling fan operating mode + state->dataHVACVarRefFlow->VRF(VRFCond).availSched->currentVal = 1.0; // enable the VRF condenser + state->dataHVACVarRefFlow->VRFTU(VRFTUNum).availSched->currentVal = 1.0; // enable the terminal unit + state->dataHVACVarRefFlow->VRFTU(VRFTUNum).fanAvailSched->currentVal = 1.0; // turn on fan + state->dataHVACVarRefFlow->VRFTU(VRFTUNum).fanOpModeSched->currentVal = 0.0; // set cycling fan operating mode // Test coil sizing @@ -5952,10 +5947,9 @@ TEST_F(EnergyPlusFixture, VRFTest_SysCurve_WaterCooled) 0.0); // flow should be = 0 for cycling fan mode state->dataHeatBalFanSys->TempControlType.allocate(1); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::DualSetPointWithDeadBand; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::DualHeatCool; - state->dataScheduleMgr->Schedule(state->dataHVACVarRefFlow->VRFTU(VRFTUNum).FanOpModeSchedPtr).CurrentValue = - 1.0; // set constant fan operating mode + state->dataHVACVarRefFlow->VRFTU(VRFTUNum).fanOpModeSched->currentVal = 1.0; // set constant fan operating mode SimulateVRF(*state, state->dataHVACVarRefFlow->VRFTU(VRFTUNum).Name, FirstHVACIteration, @@ -6652,15 +6646,16 @@ TEST_F(EnergyPlusFixture, VRFTest_TU_NoLoad_OAMassFlowRateTest) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->dataGlobal->TimeStepsInHour = 1; + state->dataGlobal->MinutesInTimeStep = 60; + state->init_state(*state); + state->dataGlobal->BeginEnvrnFlag = true; state->dataSize->CurZoneEqNum = 1; state->dataEnvrn->OutBaroPress = 101325; // sea level state->dataZoneEquip->ZoneEquipInputsFilled = true; // denotes zone equipment has been read in state->dataEnvrn->StdRhoAir = PsyRhoAirFnPbTdbW(*state, state->dataEnvrn->OutBaroPress, 20.0, 0.0); state->dataGlobal->SysSizingCalc = true; - state->dataGlobal->NumOfTimeStepInHour = 1; - state->dataGlobal->MinutesPerTimeStep = 60; state->dataSize->ZoneEqSizing.allocate(1); Curve::GetCurveInput(*state); // read curves @@ -6679,10 +6674,9 @@ TEST_F(EnergyPlusFixture, VRFTest_TU_NoLoad_OAMassFlowRateTest) QZnReq = state->dataZoneEnergyDemand->ZoneSysEnergyDemand(CurZoneNum).RemainingOutputRequired; // No load state->dataZoneTempPredictorCorrector->zoneHeatBalance.allocate(1); // Initialize terminal unit - state->dataScheduleMgr->Schedule(state->dataHVACVarRefFlow->VRFTU(VRFTUNum).SchedPtr).CurrentValue = 1.0; // turn on TU - state->dataScheduleMgr->Schedule(state->dataHVACVarRefFlow->VRFTU(VRFTUNum).FanAvailSchedPtr).CurrentValue = 1.0; // turn on fan - state->dataScheduleMgr->Schedule(state->dataHVACVarRefFlow->VRFTU(VRFTUNum).FanOpModeSchedPtr).CurrentValue = - 1.0; // set continuous fan operating mode + state->dataHVACVarRefFlow->VRFTU(VRFTUNum).availSched->currentVal = 1.0; // turn on TU + state->dataHVACVarRefFlow->VRFTU(VRFTUNum).fanAvailSched->currentVal = 1.0; // turn on fan + state->dataHVACVarRefFlow->VRFTU(VRFTUNum).fanOpModeSched->currentVal = 1.0; // set continuous fan operating mode InitVRF(*state, VRFTUNum, ZoneNum, FirstHVACIteration, OnOffAirFlowRatio, QZnReq); // Initialize all VRFTU related parameters ASSERT_EQ((int)state->dataHVACVarRefFlow->VRFTU(VRFTUNum).fanOp, (int)HVAC::FanOp::Continuous); // continuous fan cycling coil operating mode // Set average OA flow rate when there in no load for cont. fan cyc. coil operating mode @@ -6691,12 +6685,12 @@ TEST_F(EnergyPlusFixture, VRFTest_TU_NoLoad_OAMassFlowRateTest) EXPECT_EQ(AverageOAMassFlow, state->dataLoopNodes->Node(OutsideAirNode).MassFlowRate); // test availability manager operation - state->dataScheduleMgr->Schedule(state->dataHVACVarRefFlow->VRFTU(VRFTUNum).FanAvailSchedPtr).CurrentValue = 0.0; // turn off fan + state->dataHVACVarRefFlow->VRFTU(VRFTUNum).fanAvailSched->currentVal = 0.0; // turn off fan SetAverageAirFlow(*state, VRFTUNum, PartLoadRatio, OnOffAirFlowRatio); EXPECT_EQ(0.0, state->dataLoopNodes->Node(OutsideAirNode).MassFlowRate); EXPECT_FALSE(state->dataHVACGlobal->TurnFansOn); EXPECT_FALSE(state->dataHVACGlobal->TurnFansOff); - EXPECT_EQ(0.0, state->dataScheduleMgr->Schedule(state->dataHVACVarRefFlow->VRFTU(VRFTUNum).FanAvailSchedPtr).CurrentValue); + EXPECT_EQ(0.0, state->dataHVACVarRefFlow->VRFTU(VRFTUNum).fanAvailSched->currentVal); // turn on "Turn Fan On" flag for availability manager, result should be the same as previous non-zero result state->dataHVACGlobal->TurnFansOn = true; @@ -6752,6 +6746,7 @@ TEST_F(EnergyPlusFixture, VRFTest_CondenserCalcTest) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); Curve::GetCurveInput(*state); int VRFCond = 1; @@ -8112,6 +8107,7 @@ TEST_F(EnergyPlusFixture, VRFTU_SupplementalHeatingCoilGetInput) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); // get zone data bool ErrorsFound(false); @@ -8158,7 +8154,8 @@ TEST_F(EnergyPlusFixture, VRFTU_CalcVRFSupplementalHeatingCoilElectric) { // PURPOSE OF THE TEST: // checks VRF terminal units supplemental electric heating coil calculation - + state->init_state(*state); + VRFTerminalUnitEquipment thisVRFTU; int VRFTUNum(1); @@ -8187,7 +8184,7 @@ TEST_F(EnergyPlusFixture, VRFTU_CalcVRFSupplementalHeatingCoilElectric) state->dataHeatingCoils->HeatingCoil(CoilNum).HCoilType_Num = thisVRFTU.SuppHeatCoilType_Num; state->dataHeatingCoils->HeatingCoil(CoilNum).AirInletNodeNum = thisVRFTU.SuppHeatCoilAirInletNode; state->dataHeatingCoils->HeatingCoil(CoilNum).AirOutletNodeNum = thisVRFTU.SuppHeatCoilAirOutletNode; - state->dataHeatingCoils->HeatingCoil(CoilNum).SchedPtr = ScheduleManager::ScheduleAlwaysOn; // fan is always on + state->dataHeatingCoils->HeatingCoil(CoilNum).availSched = Sched::GetScheduleAlwaysOn(*state); // fan is always on state->dataHeatingCoils->HeatingCoil(CoilNum).NominalCapacity = 10000.0; state->dataHeatingCoils->HeatingCoil(CoilNum).Efficiency = 1.0; state->dataHeatingCoils->CheckEquipName.dimension(state->dataHeatingCoils->NumHeatingCoils, true); @@ -8223,7 +8220,7 @@ TEST_F(EnergyPlusFixture, VRFTU_CalcVRFSupplementalHeatingCoilFuel) { // PURPOSE OF THE TEST: // checks VRF terminal units supplemental natural gas heating coil calculation - + state->init_state(*state); VRFTerminalUnitEquipment thisVRFTU; int VRFTUNum(1); @@ -8252,7 +8249,7 @@ TEST_F(EnergyPlusFixture, VRFTU_CalcVRFSupplementalHeatingCoilFuel) state->dataHeatingCoils->HeatingCoil(CoilNum).HCoilType_Num = thisVRFTU.SuppHeatCoilType_Num; state->dataHeatingCoils->HeatingCoil(CoilNum).AirInletNodeNum = thisVRFTU.SuppHeatCoilAirInletNode; state->dataHeatingCoils->HeatingCoil(CoilNum).AirOutletNodeNum = thisVRFTU.SuppHeatCoilAirOutletNode; - state->dataHeatingCoils->HeatingCoil(CoilNum).SchedPtr = ScheduleManager::ScheduleAlwaysOn; // fan is always on + state->dataHeatingCoils->HeatingCoil(CoilNum).availSched = Sched::GetScheduleAlwaysOn(*state); // fan is always on state->dataHeatingCoils->HeatingCoil(CoilNum).NominalCapacity = 10000.0; state->dataHeatingCoils->HeatingCoil(CoilNum).Efficiency = 1.0; state->dataHeatingCoils->CheckEquipName.dimension(state->dataHeatingCoils->NumHeatingCoils, true); @@ -8316,7 +8313,7 @@ TEST_F(EnergyPlusFixture, VRFTU_CalcVRFSupplementalHeatingCoilWater) state->dataWaterCoils->WaterCoil(CoilNum).WaterCoilModel = WaterCoils::CoilModel::HeatingSimple; state->dataWaterCoils->WaterCoil(CoilNum).WaterCoilType = DataPlant::PlantEquipmentType::CoilWaterSimpleHeating; state->dataWaterCoils->WaterCoil(CoilNum).WaterCoilTypeA = "Heating"; - state->dataWaterCoils->WaterCoil(CoilNum).SchedPtr = ScheduleManager::ScheduleAlwaysOn; + state->dataWaterCoils->WaterCoil(CoilNum).availSched = Sched::GetScheduleAlwaysOn(*state); state->dataWaterCoils->WaterCoil(CoilNum).WaterPlantLoc.loopNum = 1; // state->dataWaterCoils->WaterCoil(CoilNum).FuelType_Num = Constant::ResourceType::Natural_Gas; @@ -8434,7 +8431,7 @@ TEST_F(EnergyPlusFixture, VRFTU_CalcVRFSupplementalHeatingCoilSteam) state->dataSteamCoils->SteamCoil(CoilNum).Name = thisVRFTU.SuppHeatCoilName; state->dataSteamCoils->SteamCoil(CoilNum).plantLoc.loopNum = 1; state->dataSteamCoils->SteamCoil(CoilNum).SteamCoilTypeA = "Heating"; - state->dataSteamCoils->SteamCoil(CoilNum).SchedPtr = ScheduleManager::ScheduleAlwaysOn; + state->dataSteamCoils->SteamCoil(CoilNum).availSched = Sched::GetScheduleAlwaysOn(*state); state->dataSteamCoils->SteamCoil(CoilNum).InletSteamTemp = 100.0; state->dataSteamCoils->SteamCoil(CoilNum).InletSteamPress = 101325.0; state->dataSteamCoils->SteamCoil(CoilNum).DegOfSubcooling = 0.0; @@ -8515,7 +8512,7 @@ TEST_F(EnergyPlusFixture, VRFTU_SupplementalHeatingCoilCapacityLimitTest) { // PURPOSE OF THE TEST: // heating capacity limit calculation based on maximum supply air temperature - + state->init_state(*state); VRFTerminalUnitEquipment thisVRFTU; thisVRFTU.Name = "TU1"; @@ -10810,6 +10807,7 @@ TEST_F(EnergyPlusFixture, VRFFluidControl_FanSysModel_OnOffModeTest) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); SimulationManager::ManageSimulation(*state); @@ -11411,7 +11409,8 @@ TEST_F(EnergyPlusFixture, VRFTU_SysCurve_ReportOutputVerificationTest) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + state->dataGlobal->BeginEnvrnFlag = true; state->dataSize->CurZoneEqNum = 1; state->dataEnvrn->OutBaroPress = 101325; // sea level @@ -11429,17 +11428,16 @@ TEST_F(EnergyPlusFixture, VRFTU_SysCurve_ReportOutputVerificationTest) state->dataZoneEnergyDemand->ZoneSysEnergyDemand.allocate(1); state->dataZoneTempPredictorCorrector->zoneHeatBalance.allocate(1); - ProcessScheduleInput(*state); GetCurveInput(*state); GetZoneData(*state, ErrorsFound); EXPECT_FALSE(ErrorsFound); // get zone input and connections GetZoneEquipmentData(*state); ZoneInletAirNode = GetVRFTUZoneInletAirNode(*state, VRFTUNum); - state->dataScheduleMgr->Schedule(state->dataHVACVarRefFlow->VRF(VRFCond).SchedPtr).CurrentValue = 1.0; - state->dataScheduleMgr->Schedule(state->dataHVACVarRefFlow->VRFTU(VRFTUNum).SchedPtr).CurrentValue = 1.0; - state->dataScheduleMgr->Schedule(state->dataHVACVarRefFlow->VRFTU(VRFTUNum).FanAvailSchedPtr).CurrentValue = 1.0; - state->dataScheduleMgr->Schedule(state->dataHVACVarRefFlow->VRFTU(VRFTUNum).FanOpModeSchedPtr).CurrentValue = 0.0; + state->dataHVACVarRefFlow->VRF(VRFCond).availSched->currentVal = 1.0; + state->dataHVACVarRefFlow->VRFTU(VRFTUNum).availSched->currentVal = 1.0; + state->dataHVACVarRefFlow->VRFTU(VRFTUNum).fanAvailSched->currentVal = 1.0; + state->dataHVACVarRefFlow->VRFTU(VRFTUNum).fanOpModeSched->currentVal = 0.0; // set the zone cooling and heat requirements state->dataZoneEnergyDemand->ZoneSysEnergyDemand(CurZoneNum).RemainingOutputRequired = -5000.0; state->dataZoneEnergyDemand->ZoneSysEnergyDemand(CurZoneNum).RemainingOutputReqToCoolSP = -5000.0; @@ -13164,7 +13162,8 @@ TEST_F(EnergyPlusFixture, VRF_FluidTCtrl_ReportOutputVerificationTest) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + state->dataGlobal->BeginEnvrnFlag = true; state->dataSize->CurZoneEqNum = 1; state->dataEnvrn->OutBaroPress = 101325; // sea level @@ -13182,7 +13181,6 @@ TEST_F(EnergyPlusFixture, VRF_FluidTCtrl_ReportOutputVerificationTest) state->dataZoneEnergyDemand->ZoneSysEnergyDemand.allocate(1); state->dataZoneTempPredictorCorrector->zoneHeatBalance.allocate(1); - ProcessScheduleInput(*state); GetCurveInput(*state); GetZoneData(*state, ErrorsFound); EXPECT_FALSE(ErrorsFound); @@ -13190,10 +13188,10 @@ TEST_F(EnergyPlusFixture, VRF_FluidTCtrl_ReportOutputVerificationTest) GetZoneEquipmentData(*state); GetVRFInput(*state); state->dataHVACVarRefFlow->GetVRFInputFlag = false; - state->dataScheduleMgr->Schedule(state->dataHVACVarRefFlow->VRF(VRFCond).SchedPtr).CurrentValue = 1.0; - state->dataScheduleMgr->Schedule(state->dataHVACVarRefFlow->VRFTU(VRFTUNum).SchedPtr).CurrentValue = 1.0; - state->dataScheduleMgr->Schedule(state->dataHVACVarRefFlow->VRFTU(VRFTUNum).FanAvailSchedPtr).CurrentValue = 1.0; - state->dataScheduleMgr->Schedule(state->dataHVACVarRefFlow->VRFTU(VRFTUNum).FanOpModeSchedPtr).CurrentValue = 0.0; + state->dataHVACVarRefFlow->VRF(VRFCond).availSched->currentVal = 1.0; + state->dataHVACVarRefFlow->VRFTU(VRFTUNum).availSched->currentVal = 1.0; + state->dataHVACVarRefFlow->VRFTU(VRFTUNum).fanAvailSched->currentVal = 1.0; + state->dataHVACVarRefFlow->VRFTU(VRFTUNum).fanOpModeSched->currentVal = 0.0; // set the zone cooling and heat requirements state->dataZoneEnergyDemand->ZoneSysEnergyDemand(CurZoneNum).RemainingOutputRequired = -5000.0; state->dataZoneEnergyDemand->ZoneSysEnergyDemand(CurZoneNum).RemainingOutputReqToCoolSP = -5000.0; @@ -13346,6 +13344,7 @@ TEST_F(EnergyPlusFixture, VRFTest_CondenserCalcTest_HREIRFTHeat) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); Curve::GetCurveInput(*state); int VRFCond = 1; @@ -13417,7 +13416,7 @@ TEST_F(EnergyPlusFixture, VRFTest_CondenserCalcTest_HREIRFTHeat) state->dataGlobal->CurrentTime = 0.25; state->dataGlobal->TimeStepZone = 0.25; state->dataHVACGlobal->TimeStepSys = 0.25; - state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; state->dataHVACGlobal->SysTimeElapsed = 0.0; state->dataEnvrn->OutDryBulbTemp = 35.0; state->dataEnvrn->OutHumRat = 0.01; @@ -13934,9 +13933,9 @@ TEST_F(EnergyPlusFixture, VRF_BlowthroughFanPlacement_InputTest) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + bool ErrorsFound(false); - ProcessScheduleInput(*state); GetCurveInput(*state); GetZoneData(*state, ErrorsFound); EXPECT_FALSE(ErrorsFound); @@ -14520,11 +14519,11 @@ TEST_F(EnergyPlusFixture, VRF_MinPLR_and_EIRfPLRCruveMinPLRInputsTest) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + Real64 minEIRfLowPLRXInput(0.0); Real64 maxEIRfLowPLRXInput(0.0); bool ErrorsFound(false); - ProcessScheduleInput(*state); GetCurveInput(*state); GetZoneData(*state, ErrorsFound); EXPECT_FALSE(ErrorsFound); @@ -15227,6 +15226,9 @@ TEST_F(EnergyPlusFixture, VRFTest_TU_NotOnZoneHVACEquipmentList) }); ASSERT_TRUE(process_idf(idf_objects)); + state->dataGlobal->TimeStepsInHour = 1; + state->dataGlobal->MinutesInTimeStep = 60; + state->init_state(*state); state->dataGlobal->BeginEnvrnFlag = true; state->dataSize->CurZoneEqNum = 1; @@ -15234,8 +15236,6 @@ TEST_F(EnergyPlusFixture, VRFTest_TU_NotOnZoneHVACEquipmentList) state->dataZoneEquip->ZoneEquipInputsFilled = true; // denotes zone equipment has been read in state->dataEnvrn->StdRhoAir = PsyRhoAirFnPbTdbW(*state, state->dataEnvrn->OutBaroPress, 20.0, 0.0); state->dataGlobal->SysSizingCalc = true; - state->dataGlobal->NumOfTimeStepInHour = 1; - state->dataGlobal->MinutesPerTimeStep = 60; state->dataSize->ZoneEqSizing.allocate(1); Curve::GetCurveInput(*state); // read curves @@ -15254,8 +15254,7 @@ TEST_F(EnergyPlusFixture, VRFTest_TU_NotOnZoneHVACEquipmentList) QZnReq = state->dataZoneEnergyDemand->ZoneSysEnergyDemand(CurZoneNum).RemainingOutputRequired; // No load state->dataZoneTempPredictorCorrector->zoneHeatBalance.allocate(1); // Initialize terminal unit - state->dataScheduleMgr->Schedule(state->dataHVACVarRefFlow->VRFTU(VRFTUNum).FanOpModeSchedPtr).CurrentValue = - 1.0; // set continuous fan operating mode + state->dataHVACVarRefFlow->VRFTU(VRFTUNum).fanOpModeSched->currentVal = 1.0; // set continuous fan operating mode // Reset the err stream, which has warnings about curves values not equal to 1.0 (+ or - 10%) at rated conditions EXPECT_TRUE(has_err_output(true)); @@ -15850,7 +15849,8 @@ TEST_F(EnergyPlusFixture, VRFTU_FanOnOff_Power) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + state->dataGlobal->BeginEnvrnFlag = true; state->dataSize->CurZoneEqNum = 1; state->dataEnvrn->OutBaroPress = 101325; // sea level @@ -15868,17 +15868,16 @@ TEST_F(EnergyPlusFixture, VRFTU_FanOnOff_Power) state->dataZoneEnergyDemand->ZoneSysEnergyDemand.allocate(1); state->dataZoneTempPredictorCorrector->zoneHeatBalance.allocate(1); - ProcessScheduleInput(*state); GetCurveInput(*state); GetZoneData(*state, ErrorsFound); EXPECT_FALSE(ErrorsFound); // get zone input and connections GetZoneEquipmentData(*state); ZoneInletAirNode = GetVRFTUZoneInletAirNode(*state, VRFTUNum); - state->dataScheduleMgr->Schedule(state->dataHVACVarRefFlow->VRF(VRFCond).SchedPtr).CurrentValue = 1.0; - state->dataScheduleMgr->Schedule(state->dataHVACVarRefFlow->VRFTU(VRFTUNum).SchedPtr).CurrentValue = 1.0; - state->dataScheduleMgr->Schedule(state->dataHVACVarRefFlow->VRFTU(VRFTUNum).FanAvailSchedPtr).CurrentValue = 1.0; - state->dataScheduleMgr->Schedule(state->dataHVACVarRefFlow->VRFTU(VRFTUNum).FanOpModeSchedPtr).CurrentValue = 0.0; + state->dataHVACVarRefFlow->VRF(VRFCond).availSched->currentVal = 1.0; + state->dataHVACVarRefFlow->VRFTU(VRFTUNum).availSched->currentVal = 1.0; + state->dataHVACVarRefFlow->VRFTU(VRFTUNum).fanAvailSched->currentVal = 1.0; + state->dataHVACVarRefFlow->VRFTU(VRFTUNum).fanOpModeSched->currentVal = 0.0; // set the zone cooling and heat requirements state->dataZoneEnergyDemand->ZoneSysEnergyDemand(CurZoneNum).RemainingOutputRequired = -5000.0; state->dataZoneEnergyDemand->ZoneSysEnergyDemand(CurZoneNum).RemainingOutputReqToCoolSP = -5000.0; @@ -16000,6 +15999,7 @@ TEST_F(EnergyPlusFixture, VRF_Condenser_Calc_EIRFPLR_Bound_Test) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); Curve::GetCurveInput(*state); int VRFCond = 1; @@ -18143,7 +18143,8 @@ TEST_F(EnergyPlusFixture, VRF_FluidTCtrl_SupplementalHtgCoilTest) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + state->dataGlobal->BeginEnvrnFlag = true; state->dataEnvrn->OutBaroPress = 101325; @@ -18188,7 +18189,6 @@ TEST_F(EnergyPlusFixture, VRF_FluidTCtrl_SupplementalHtgCoilTest) state->dataZoneEnergyDemand->ZoneSysEnergyDemand(zone_num_TU2).RemainingOutputReqToHeatSP = 2500.0; state->dataZoneEnergyDemand->ZoneSysEnergyDemand(zone_num_TU2).RemainingOutputReqToCoolSP = 0.0; - ProcessScheduleInput(*state); GetCurveInput(*state); GetZoneData(*state, ErrorsFound); EXPECT_FALSE(ErrorsFound); @@ -18197,15 +18197,15 @@ TEST_F(EnergyPlusFixture, VRF_FluidTCtrl_SupplementalHtgCoilTest) GetVRFInput(*state); state->dataHVACVarRefFlow->GetVRFInputFlag = false; - state->dataScheduleMgr->Schedule(state->dataHVACVarRefFlow->VRF(VRFCond).SchedPtr).CurrentValue = 1.0; + state->dataHVACVarRefFlow->VRF(VRFCond).availSched->currentVal = 1.0; VRFTUNum = zone_num_TU1; - state->dataScheduleMgr->Schedule(state->dataHVACVarRefFlow->VRFTU(VRFTUNum).SchedPtr).CurrentValue = 1.0; - state->dataScheduleMgr->Schedule(state->dataHVACVarRefFlow->VRFTU(VRFTUNum).FanAvailSchedPtr).CurrentValue = 1.0; - state->dataScheduleMgr->Schedule(state->dataHVACVarRefFlow->VRFTU(VRFTUNum).FanOpModeSchedPtr).CurrentValue = 0.0; + state->dataHVACVarRefFlow->VRFTU(VRFTUNum).availSched->currentVal = 1.0; + state->dataHVACVarRefFlow->VRFTU(VRFTUNum).fanAvailSched->currentVal = 1.0; + state->dataHVACVarRefFlow->VRFTU(VRFTUNum).fanOpModeSched->currentVal = 0.0; VRFTUNum = zone_num_TU2; - state->dataScheduleMgr->Schedule(state->dataHVACVarRefFlow->VRFTU(VRFTUNum).SchedPtr).CurrentValue = 1.0; - state->dataScheduleMgr->Schedule(state->dataHVACVarRefFlow->VRFTU(VRFTUNum).FanAvailSchedPtr).CurrentValue = 1.0; - state->dataScheduleMgr->Schedule(state->dataHVACVarRefFlow->VRFTU(VRFTUNum).FanOpModeSchedPtr).CurrentValue = 0.0; + state->dataHVACVarRefFlow->VRFTU(VRFTUNum).availSched->currentVal = 1.0; + state->dataHVACVarRefFlow->VRFTU(VRFTUNum).fanAvailSched->currentVal = 1.0; + state->dataHVACVarRefFlow->VRFTU(VRFTUNum).fanOpModeSched->currentVal = 0.0; auto &TU1ZoneEquip(state->dataZoneEquip->ZoneEquipConfig(zone_num_TU1)); // set zone air node properties, for zone 1 @@ -20278,7 +20278,8 @@ TEST_F(EnergyPlusFixture, VRF_FluidTCtrl_offSupplementalHtgCoilTest) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + state->dataGlobal->BeginEnvrnFlag = true; state->dataEnvrn->OutBaroPress = 101325; @@ -20323,7 +20324,6 @@ TEST_F(EnergyPlusFixture, VRF_FluidTCtrl_offSupplementalHtgCoilTest) state->dataZoneEnergyDemand->ZoneSysEnergyDemand(zone_num_TU2).RemainingOutputReqToHeatSP = 2500.0; state->dataZoneEnergyDemand->ZoneSysEnergyDemand(zone_num_TU2).RemainingOutputReqToCoolSP = 0.0; - ProcessScheduleInput(*state); GetCurveInput(*state); GetZoneData(*state, ErrorsFound); EXPECT_FALSE(ErrorsFound); @@ -20335,15 +20335,15 @@ TEST_F(EnergyPlusFixture, VRF_FluidTCtrl_offSupplementalHtgCoilTest) state->dataHVACGlobal->OnOffFanPartLoadFraction = 1.0; state->dataHVACVarRefFlow->VRF(VRFCond).VRFCondCyclingRatio = 1.0; - state->dataScheduleMgr->Schedule(state->dataHVACVarRefFlow->VRF(VRFCond).SchedPtr).CurrentValue = 1.0; + state->dataHVACVarRefFlow->VRF(VRFCond).availSched->currentVal = 1.0; VRFTUNum = zone_num_TU1; - state->dataScheduleMgr->Schedule(state->dataHVACVarRefFlow->VRFTU(VRFTUNum).SchedPtr).CurrentValue = 1.0; - state->dataScheduleMgr->Schedule(state->dataHVACVarRefFlow->VRFTU(VRFTUNum).FanAvailSchedPtr).CurrentValue = 1.0; - state->dataScheduleMgr->Schedule(state->dataHVACVarRefFlow->VRFTU(VRFTUNum).FanOpModeSchedPtr).CurrentValue = 0.0; + state->dataHVACVarRefFlow->VRFTU(VRFTUNum).availSched->currentVal = 1.0; + state->dataHVACVarRefFlow->VRFTU(VRFTUNum).fanAvailSched->currentVal = 1.0; + state->dataHVACVarRefFlow->VRFTU(VRFTUNum).fanOpModeSched->currentVal = 0.0; VRFTUNum = zone_num_TU2; - state->dataScheduleMgr->Schedule(state->dataHVACVarRefFlow->VRFTU(VRFTUNum).SchedPtr).CurrentValue = 1.0; - state->dataScheduleMgr->Schedule(state->dataHVACVarRefFlow->VRFTU(VRFTUNum).FanAvailSchedPtr).CurrentValue = 1.0; - state->dataScheduleMgr->Schedule(state->dataHVACVarRefFlow->VRFTU(VRFTUNum).FanOpModeSchedPtr).CurrentValue = 0.0; + state->dataHVACVarRefFlow->VRFTU(VRFTUNum).availSched->currentVal = 1.0; + state->dataHVACVarRefFlow->VRFTU(VRFTUNum).fanAvailSched->currentVal = 1.0; + state->dataHVACVarRefFlow->VRFTU(VRFTUNum).fanOpModeSched->currentVal = 0.0; auto &TU1ZoneEquip(state->dataZoneEquip->ZoneEquipConfig(zone_num_TU1)); // set zone air node properties, for zone 1 @@ -22799,7 +22799,8 @@ TEST_F(EnergyPlusFixture, VRF_MixedTypes) const std::string idf_objects = vrfFluidCtrl + vrfFluidCtrl_HR + commonCurvesAndFansForFluidCtrlAndHR + vrfSys + r410a_objects; ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + state->dataGlobal->BeginEnvrnFlag = true; state->dataSize->CurZoneEqNum = 1; state->dataEnvrn->OutBaroPress = 101325; // sea level @@ -22807,9 +22808,7 @@ TEST_F(EnergyPlusFixture, VRF_MixedTypes) state->dataEnvrn->StdRhoAir = PsyRhoAirFnPbTdbW(*state, state->dataEnvrn->OutBaroPress, 20.0, 0.0); // Read in IDF - ProcessScheduleInput(*state); // read schedules Curve::GetCurveInput(*state); // read curves - FluidProperties::GetFluidPropertiesData(*state); // read refrigerant properties // set up ZoneEquipConfig data state->dataGlobal->NumOfZones = 1; @@ -22889,6 +22888,7 @@ TEST_F(EnergyPlusFixture, VRFHP_CondenserCalc_PLR_Issue_Test) )IDF"; ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); Curve::GetCurveInput(*state); int VRFCond = 1; @@ -24242,6 +24242,7 @@ TEST_F(EnergyPlusFixture, VRF_MultispeedFan_Test) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); SimulationManager::ManageSimulation(*state); @@ -25492,6 +25493,9 @@ TEST_F(EnergyPlusFixture, VRFTest_TU_HeatRecoveryCheck) }); ASSERT_TRUE(process_idf(idf_objects)); + state->dataGlobal->TimeStepsInHour = 1; + state->dataGlobal->MinutesInTimeStep = 60; + state->init_state(*state); state->dataGlobal->BeginEnvrnFlag = true; state->dataSize->CurZoneEqNum = 1; @@ -25499,8 +25503,6 @@ TEST_F(EnergyPlusFixture, VRFTest_TU_HeatRecoveryCheck) state->dataZoneEquip->ZoneEquipInputsFilled = true; // denotes zone equipment has been read in state->dataEnvrn->StdRhoAir = PsyRhoAirFnPbTdbW(*state, state->dataEnvrn->OutBaroPress, 20.0, 0.0); state->dataGlobal->SysSizingCalc = true; - state->dataGlobal->NumOfTimeStepInHour = 1; - state->dataGlobal->MinutesPerTimeStep = 60; state->dataSize->ZoneEqSizing.allocate(1); bool ErrorsFound = false; // function returns true on error diff --git a/tst/EnergyPlus/unit/HWBaseboardRadiator.unit.cc b/tst/EnergyPlus/unit/HWBaseboardRadiator.unit.cc index 978b4fb19f2..3ad1b071645 100644 --- a/tst/EnergyPlus/unit/HWBaseboardRadiator.unit.cc +++ b/tst/EnergyPlus/unit/HWBaseboardRadiator.unit.cc @@ -68,7 +68,6 @@ using namespace EnergyPlus; using namespace DataZoneEnergyDemands; -using namespace ScheduleManager; using namespace Psychrometrics; using namespace HWBaseboardRadiator; using namespace DataLoopNode; @@ -102,7 +101,7 @@ TEST_F(EnergyPlusFixture, HWBaseboardRadiator_CalcHWBaseboard) HWBaseboard(1).WaterInletNode = 1; HWBaseboard(1).WaterMassFlowRateMax = 0.40; HWBaseboard(1).AirMassFlowRateStd = 0.5; - HWBaseboard(1).SchedPtr = -1; + HWBaseboard(1).availSched = Sched::GetScheduleAlwaysOn(*state); HWBaseboard(1).plantLoc.loopNum = 1; HWBaseboard(1).UA = 370; HWBaseboard(1).QBBRadSource = 0.0; @@ -126,6 +125,7 @@ TEST_F(EnergyPlusFixture, HWBaseboardRadiator_CalcHWBaseboard) TEST_F(EnergyPlusFixture, HWBaseboardRadiator_HWBaseboardWaterFlowResetTest) { + state->init_state(*state); Real64 LoadMet; int BBNum; @@ -154,7 +154,7 @@ TEST_F(EnergyPlusFixture, HWBaseboardRadiator_HWBaseboardWaterFlowResetTest) HWBaseboard(1).WaterOutletNode = 2; HWBaseboard(1).WaterMassFlowRateMax = 0.40; HWBaseboard(1).AirMassFlowRateStd = 0.5; - HWBaseboard(1).SchedPtr = -1; + HWBaseboard(1).availSched = Sched::GetScheduleAlwaysOn(*state); HWBaseboard(1).plantLoc.loopNum = 1; HWBaseboard(1).plantLoc.loopSideNum = DataPlant::LoopSideLocation::Demand; HWBaseboard(1).plantLoc.branchNum = 1; @@ -291,7 +291,8 @@ TEST_F(EnergyPlusFixture, HWBaseboardRadiator_HWBaseboardWaterInputTest) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + errorFound = false; HeatBalanceManager::GetZoneData(*state, errorFound); EXPECT_FALSE(errorFound); @@ -309,8 +310,8 @@ TEST_F(EnergyPlusFixture, HWBaseboardRadiator_HWBaseboardWaterInputTest) errorFound = false; state->dataSurfaceGeometry->CosZoneRelNorth.allocate(1); state->dataSurfaceGeometry->SinZoneRelNorth.allocate(1); - state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); - state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); + state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); + state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); state->dataSurfaceGeometry->CosBldgRelNorth = 1.0; state->dataSurfaceGeometry->SinBldgRelNorth = 0.0; SurfaceGeometry::GetSurfaceData(*state, errorFound); diff --git a/tst/EnergyPlus/unit/HeatBalFiniteDiffManager.unit.cc b/tst/EnergyPlus/unit/HeatBalFiniteDiffManager.unit.cc index 4a4cfabbb58..a029a52f391 100644 --- a/tst/EnergyPlus/unit/HeatBalFiniteDiffManager.unit.cc +++ b/tst/EnergyPlus/unit/HeatBalFiniteDiffManager.unit.cc @@ -469,7 +469,7 @@ TEST_F(EnergyPlusFixture, HeatBalFiniteDiffManager_findAnySurfacesUsingConstruct state->dataHeatBalSurf->SurfOpaqInsFaceCondFlux.allocate(thisData->TotSurfaces); state->dataHeatBalSurf->SurfOpaqOutFaceCondFlux.allocate(thisData->TotSurfaces); state->dataGlobal->TimeStepZoneSec = 600.0; - state->dataGlobal->NumOfTimeStepInHour = 6; + state->dataGlobal->TimeStepsInHour = 6; // call the function for initialization of finite difference calculation std::string const error_string = delimited_string({" ** Severe ** InitialInitHeatBalFiniteDiff: Found Material that is too thin and/or too " diff --git a/tst/EnergyPlus/unit/HeatBalanceAirManager.unit.cc b/tst/EnergyPlus/unit/HeatBalanceAirManager.unit.cc index eb9143cfe47..b66d7377924 100644 --- a/tst/EnergyPlus/unit/HeatBalanceAirManager.unit.cc +++ b/tst/EnergyPlus/unit/HeatBalanceAirManager.unit.cc @@ -86,7 +86,8 @@ TEST_F(EnergyPlusFixture, HeatBalanceAirManager_RoomAirModelType_Test) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + state->dataGlobal->NumOfZones = 2; state->dataHeatBal->Zone.allocate(2); @@ -369,9 +370,14 @@ TEST_F(EnergyPlusFixture, HeatBalanceAirManager_GetInfiltrationAndVentilation) state->dataIPShortCut->lNumericFieldBlanks.dimension(MaxNumeric, false); bool ErrorsFound = false; + + state->init_state(*state); + HeatBalanceManager::GetHeatBalanceInput(*state); std::string const error_string = delimited_string( - {" ** Warning ** GetSurfaceData: Entered Space Floor Area(s) differ more than 5% from calculated Space Floor Area(s).", + {" ** Warning ** Version: missing in IDF, processing for EnergyPlus version=\"24.2\"", + " ** Warning ** No Timestep object found. Number of TimeSteps in Hour defaulted to 4.", + " ** Warning ** GetSurfaceData: Entered Space Floor Area(s) differ more than 5% from calculated Space Floor Area(s).", " ** ~~~ ** ...use Output:Diagnostics,DisplayExtraWarnings; to show more details on individual Spaces.", " ** Warning ** CalculateZoneVolume: 1 zone is not fully enclosed. For more details use: Output:Diagnostics,DisplayExtrawarnings; ", " ** Warning ** CalcApproximateViewFactors: Zero area for all other zone surfaces.", @@ -755,10 +761,14 @@ TEST_F(EnergyPlusFixture, HeatBalanceAirManager_GetMixingAndCrossMixing) state->dataIPShortCut->rNumericArgs.dimension(MaxNumeric, 0.0); state->dataIPShortCut->lNumericFieldBlanks.dimension(MaxNumeric, false); + state->init_state(*state); + bool ErrorsFound = false; HeatBalanceManager::GetHeatBalanceInput(*state); std::string const error_string = delimited_string( - {" ** Warning ** GetSurfaceData: Entered Space Floor Area(s) differ more than 5% from calculated Space Floor Area(s).", + {" ** Warning ** Version: missing in IDF, processing for EnergyPlus version=\"24.2\"", + " ** Warning ** No Timestep object found. Number of TimeSteps in Hour defaulted to 4.", + " ** Warning ** GetSurfaceData: Entered Space Floor Area(s) differ more than 5% from calculated Space Floor Area(s).", " ** ~~~ ** ...use Output:Diagnostics,DisplayExtraWarnings; to show more details on individual Spaces.", " ** Warning ** CalculateZoneVolume: 1 zone is not fully enclosed. For more details use: Output:Diagnostics,DisplayExtrawarnings; ", " ** Warning ** CalcApproximateViewFactors: Zero area for all other zone surfaces.", @@ -884,6 +894,7 @@ TEST_F(EnergyPlusFixture, HeatBalanceAirManager_GetMixingAndCrossMixing) TEST_F(EnergyPlusFixture, HeatBalanceAirManager_InitSimpleMixingConvectiveHeatGains_Test) { + state->init_state(*state); Real64 expectedResult1; Real64 expectedResult2; Real64 constexpr allowedTolerance = 0.00001; @@ -893,9 +904,9 @@ TEST_F(EnergyPlusFixture, HeatBalanceAirManager_InitSimpleMixingConvectiveHeatGa state->dataHeatBal->TotCrossMixing = 0; state->dataHeatBal->TotMixing = 3; state->dataHeatBal->Mixing.allocate(state->dataHeatBal->TotMixing); - state->dataHeatBal->Mixing(1).SchedPtr = -1; // this returns a value of one - state->dataHeatBal->Mixing(2).SchedPtr = -1; // this returns a value of one - state->dataHeatBal->Mixing(3).SchedPtr = -1; // this returns a value of one + state->dataHeatBal->Mixing(1).sched = Sched::GetScheduleAlwaysOn(*state); + state->dataHeatBal->Mixing(2).sched = Sched::GetScheduleAlwaysOn(*state); + state->dataHeatBal->Mixing(3).sched = Sched::GetScheduleAlwaysOn(*state); state->dataHeatBal->Mixing(1).EMSSimpleMixingOn = false; state->dataHeatBal->Mixing(2).EMSSimpleMixingOn = false; state->dataHeatBal->Mixing(3).EMSSimpleMixingOn = false; diff --git a/tst/EnergyPlus/unit/HeatBalanceKivaManager.unit.cc b/tst/EnergyPlus/unit/HeatBalanceKivaManager.unit.cc index 375927fd1f3..3349ef30b81 100644 --- a/tst/EnergyPlus/unit/HeatBalanceKivaManager.unit.cc +++ b/tst/EnergyPlus/unit/HeatBalanceKivaManager.unit.cc @@ -176,6 +176,9 @@ TEST_F(EnergyPlusFixture, HeatBalanceKiva_SetInitialBCs) }); ASSERT_TRUE(process_idf(idf_objects)); + state->dataGlobal->TimeStepsInHour = 1; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 60; // must initialize this to get schedules initialized + state->init_state(*state); bool ErrorsFound(false); // If errors detected in input HeatBalanceManager::GetZoneData(*state, ErrorsFound); @@ -187,14 +190,10 @@ TEST_F(EnergyPlusFixture, HeatBalanceKiva_SetInitialBCs) state->dataEnvrn->DayOfWeek = 1; // must initialize this to get schedules initialized state->dataGlobal->HourOfDay = 1; // must initialize this to get schedules initialized state->dataGlobal->TimeStep = 1; // must initialize this to get schedules initialized - state->dataGlobal->NumOfTimeStepInHour = 1; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 60; // must initialize this to get schedules initialized - ScheduleManager::ProcessScheduleInput(*state); // read schedules ZoneTempPredictorCorrector::GetZoneAirSetPoints(*state); - state->dataScheduleMgr->Schedule(state->dataZoneCtrls->TempControlledZone(DualZoneNum).CTSchedIndex).CurrentValue = - static_cast(HVAC::ThermostatType::DualSetPointWithDeadBand); + state->dataZoneCtrls->TempControlledZone(DualZoneNum).setptTypeSched->currentVal = (int)HVAC::SetptType::DualHeatCool; // Test Initial Indoor Temperature input of 15C with Cooling/Heating Setpoints of 24C/20C @@ -227,8 +226,8 @@ TEST_F(EnergyPlusFixture, HeatBalanceKiva_SetInitialBCs) // Test using default Initial Indoor Temperature with Cooling/Heating Setpoints of 100C/-100C - state->dataZoneCtrls->TempControlledZone(1).SchIndx_DualSetPointWDeadBandCool = 4; - state->dataZoneCtrls->TempControlledZone(1).SchIndx_DualSetPointWDeadBandHeat = 5; + state->dataZoneCtrls->TempControlledZone(1).setpts[(int)HVAC::SetptType::DualHeatCool].coolSetptSched = Sched::GetSchedule(*state, "CLGSETP_SCH_EXTREME"); + state->dataZoneCtrls->TempControlledZone(1).setpts[(int)HVAC::SetptType::DualHeatCool].heatSetptSched = Sched::GetSchedule(*state, "HTGSETP_SCH_EXTREME"); Real64 heatingSetpoint3 = -100.0; Real64 zoneAssumedTemperature3 = -9999; @@ -245,9 +244,8 @@ TEST_F(EnergyPlusFixture, HeatBalanceKiva_SetInitialBCs) // Test Initial Indoor Temperature input of 15C with Cooling/Heating Setpoints of 100C/-100C - state->dataZoneCtrls->TempControlledZone(1).SchIndx_DualSetPointWDeadBandCool = 4; - state->dataZoneCtrls->TempControlledZone(1).SchIndx_DualSetPointWDeadBandHeat = 5; - + state->dataZoneCtrls->TempControlledZone(1).setpts[(int)HVAC::SetptType::DualHeatCool].coolSetptSched = Sched::GetSchedule(*state, "CLGSETP_SCH_EXTREME"); + state->dataZoneCtrls->TempControlledZone(1).setpts[(int)HVAC::SetptType::DualHeatCool].heatSetptSched = Sched::GetSchedule(*state, "HTGSETP_SCH_EXTREME"); Real64 zoneAssumedTemperature4 = 15.0; HeatBalanceKivaManager::KivaInstanceMap kv4(*state, fnd, 0, {}, 0, zoneAssumedTemperature4, 1.0, 0, &km); @@ -694,6 +692,9 @@ TEST_F(EnergyPlusFixture, HeatBalanceKiva_setupKivaInstances_ThermalComfort) }); ASSERT_TRUE(process_idf(idf_objects)); + state->dataGlobal->TimeStepsInHour = 1; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 60; // must initialize this to get schedules initialized + state->init_state(*state); bool ErrorsFound(false); // If errors detected in input ASSERT_FALSE(ErrorsFound); @@ -702,9 +703,6 @@ TEST_F(EnergyPlusFixture, HeatBalanceKiva_setupKivaInstances_ThermalComfort) state->dataEnvrn->DayOfWeek = 1; // must initialize this to get schedules initialized state->dataGlobal->HourOfDay = 1; // must initialize this to get schedules initialized state->dataGlobal->TimeStep = 1; // must initialize this to get schedules initialized - state->dataGlobal->NumOfTimeStepInHour = 1; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 60; // must initialize this to get schedules initialized - ScheduleManager::ProcessScheduleInput(*state); // read schedules state->files.inputWeatherFilePath.filePath = configured_source_directory() / "tst/EnergyPlus/unit/Resources/HeatBalanceKivaManagerOSkyTest.epw"; HeatBalanceManager::GetHeatBalanceInput(*state); diff --git a/tst/EnergyPlus/unit/HeatBalanceManager.unit.cc b/tst/EnergyPlus/unit/HeatBalanceManager.unit.cc index 3af392c8063..6ac53f7d82f 100644 --- a/tst/EnergyPlus/unit/HeatBalanceManager.unit.cc +++ b/tst/EnergyPlus/unit/HeatBalanceManager.unit.cc @@ -90,7 +90,6 @@ using namespace EnergyPlus::HeatBalanceManager; using namespace EnergyPlus::DataHeatBalance; using namespace EnergyPlus::ZoneEquipmentManager; using namespace EnergyPlus::HeatBalanceAirManager; -using namespace EnergyPlus::ScheduleManager; using namespace EnergyPlus::DataHeatBalFanSys; using namespace EnergyPlus::DataZoneEquipment; using namespace EnergyPlus::DataLoopNode; @@ -127,6 +126,8 @@ TEST_F(EnergyPlusFixture, HeatBalanceManager_ZoneAirBalance_OutdoorAir) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + bool ErrorsFound = false; auto numZones = state->dataInputProcessing->inputProcessor->getNumObjectsFound(*state, "Zone"); state->dataHeatBalFanSys->ZoneReOrder.allocate(numZones); @@ -460,14 +461,11 @@ TEST_F(EnergyPlusFixture, HeatBalanceManager_ZoneAirMassFlowConservationData2) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); bool ErrorsFound(false); // If errors detected in input - // call to process input - ProcessScheduleInput(*state); - ErrorsFound = false; - GetProjectControlData(*state, ErrorsFound); // returns ErrorsFound false, ZoneAirMassFlowConservation never sets it - EXPECT_FALSE(ErrorsFound); + HeatBalanceManager::GetProjectControlData(*state, ErrorsFound); + EXPECT_TRUE(state->dataHeatBal->ZoneAirMassFlow.EnforceZoneMassBalance); EXPECT_ENUM_EQ(state->dataHeatBal->ZoneAirMassFlow.ZoneFlowAdjustment, DataHeatBalance::AdjustmentType::NoAdjustReturnAndMixing); EXPECT_ENUM_EQ(state->dataHeatBal->ZoneAirMassFlow.InfiltrationTreatment, DataHeatBalance::InfiltrationFlow::Adjust); @@ -500,7 +498,7 @@ TEST_F(EnergyPlusFixture, HeatBalanceManager_ZoneAirMassFlowConservationData2) state->dataZoneEquip->ZoneEquipConfig(1).ReturnNode(1) = 4; state->dataZoneEquip->ZoneEquipConfig(1).FixedReturnFlow.allocate(1); state->dataZoneEquip->ZoneEquipConfig(1).IsControlled = true; - state->dataZoneEquip->ZoneEquipConfig(1).ReturnFlowSchedPtrNum = ScheduleManager::ScheduleAlwaysOn; + state->dataZoneEquip->ZoneEquipConfig(1).returnFlowSched = Sched::GetScheduleAlwaysOn(*state); state->dataZoneEquip->ZoneEquipConfig(1).InletNodeAirLoopNum.allocate(1); state->dataZoneEquip->ZoneEquipConfig(1).InletNodeADUNum.allocate(1); state->dataZoneEquip->ZoneEquipConfig(1).AirDistUnitCool.allocate(1); @@ -526,7 +524,7 @@ TEST_F(EnergyPlusFixture, HeatBalanceManager_ZoneAirMassFlowConservationData2) state->dataZoneEquip->ZoneEquipConfig(2).ReturnNode(1) = 8; state->dataZoneEquip->ZoneEquipConfig(2).FixedReturnFlow.allocate(1); state->dataZoneEquip->ZoneEquipConfig(2).IsControlled = true; - state->dataZoneEquip->ZoneEquipConfig(2).ReturnFlowSchedPtrNum = ScheduleManager::ScheduleAlwaysOn; + state->dataZoneEquip->ZoneEquipConfig(2).returnFlowSched = Sched::GetScheduleAlwaysOn(*state); state->dataZoneEquip->ZoneEquipConfig(2).InletNodeAirLoopNum.allocate(1); state->dataZoneEquip->ZoneEquipConfig(2).InletNodeADUNum.allocate(1); state->dataZoneEquip->ZoneEquipConfig(2).AirDistUnitCool.allocate(1); @@ -1216,12 +1214,9 @@ TEST_F(EnergyPlusFixture, HeatBalanceManager_TestZonePropertyLocalEnv) " Until: 24:00, 90; !- Field 3"}); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); bool ErrorsFound = false; - ScheduleManager::ProcessScheduleInput(*state); - - HeatBalanceManager::GetProjectControlData(*state, ErrorsFound); - EXPECT_FALSE(ErrorsFound); HeatBalanceManager::GetZoneData(*state, ErrorsFound); EXPECT_FALSE(ErrorsFound); Material::GetMaterialData(*state, ErrorsFound); @@ -1269,10 +1264,11 @@ TEST_F(EnergyPlusFixture, HeatBalanceManager_TestZonePropertyLocalEnv) // Set up OutAirNodeManager::GetOutAirNodesInput(*state); state->dataEnvrn->OutBaroPress = 101325; - state->dataScheduleMgr->Schedule(1).CurrentValue = 25.0; - state->dataScheduleMgr->Schedule(2).CurrentValue = 20.0; - state->dataScheduleMgr->Schedule(3).CurrentValue = 1.5; - state->dataScheduleMgr->Schedule(4).CurrentValue = 90.0; + + Sched::GetSchedule(*state, "OUTDOORAIRNODEDRYBULB:0001")->currentVal = 25.0; + Sched::GetSchedule(*state, "OUTDOORAIRNODEWETBULB:0001")->currentVal = 20.0; + Sched::GetSchedule(*state, "OUTDOORAIRNODEWINDSPEED:0001")->currentVal = 1.5; + Sched::GetSchedule(*state, "OUTDOORAIRNODEWINDDIR:0001")->currentVal = 90.0; OutAirNodeManager::InitOutAirNodes(*state); @@ -1293,10 +1289,10 @@ TEST_F(EnergyPlusFixture, HeatBalanceManager_TestZonePropertyLocalEnv) EXPECT_EQ(90.0, state->dataHeatBal->Zone(1).WindDir); // Add a test for #7308 without inputs of schedule names - state->dataLoopNodes->Node(1).OutAirDryBulbSchedNum = 0; - state->dataLoopNodes->Node(1).OutAirWetBulbSchedNum = 0; - state->dataLoopNodes->Node(1).OutAirWindSpeedSchedNum = 0; - state->dataLoopNodes->Node(1).OutAirWindDirSchedNum = 0; + state->dataLoopNodes->Node(1).outAirDryBulbSched = nullptr; + state->dataLoopNodes->Node(1).outAirWetBulbSched = nullptr; + state->dataLoopNodes->Node(1).outAirWindSpeedSched = nullptr; + state->dataLoopNodes->Node(1).outAirWindDirSched = nullptr; state->dataEnvrn->OutDryBulbTemp = 25.0; state->dataEnvrn->OutWetBulbTemp = 20.0; state->dataEnvrn->WindSpeed = 1.5; @@ -1803,9 +1799,9 @@ TEST_F(EnergyPlusFixture, HeatBalanceManager_GetAirBoundaryConstructData) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + bool ErrorsFound(false); - ProcessScheduleInput(*state); // get constructions ErrorsFound = false; @@ -1821,7 +1817,7 @@ TEST_F(EnergyPlusFixture, HeatBalanceManager_GetAirBoundaryConstructData) EXPECT_FALSE(state->dataConstruction->Construct(constrNum).TypeIsAirBoundaryMixing); EXPECT_EQ(state->dataConstruction->Construct(constrNum).TotLayers, 0); EXPECT_EQ(state->dataConstruction->Construct(constrNum).AirBoundaryACH, 0.0); // Not processed for GroupedZone mixing option - EXPECT_EQ(state->dataConstruction->Construct(constrNum).AirBoundaryMixingSched, 0); + EXPECT_EQ(state->dataConstruction->Construct(constrNum).airBoundaryMixingSched, nullptr); EXPECT_EQ(state->dataHeatBal->NominalRforNominalUCalculation(constrNum), 0.0); constrNum = Util::FindItemInList(Util::makeUPPER("Air Boundary with Good Mixing Schedule"), state->dataConstruction->Construct); @@ -1831,7 +1827,7 @@ TEST_F(EnergyPlusFixture, HeatBalanceManager_GetAirBoundaryConstructData) EXPECT_TRUE(state->dataConstruction->Construct(constrNum).TypeIsAirBoundaryMixing); EXPECT_EQ(state->dataConstruction->Construct(constrNum).TotLayers, 0); EXPECT_EQ(state->dataConstruction->Construct(constrNum).AirBoundaryACH, 0.4); - EXPECT_EQ(state->dataConstruction->Construct(constrNum).AirBoundaryMixingSched, 1); + EXPECT_NE(state->dataConstruction->Construct(constrNum).airBoundaryMixingSched, nullptr); EXPECT_EQ(state->dataHeatBal->NominalRforNominalUCalculation(constrNum), 0.0); } @@ -1851,9 +1847,9 @@ TEST_F(EnergyPlusFixture, HeatBalanceManager_GetAirBoundaryConstructData2) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + bool ErrorsFound(false); - ProcessScheduleInput(*state); // skip call to get material data since this doesn't use IRT ErrorsFound = false; @@ -1865,8 +1861,8 @@ TEST_F(EnergyPlusFixture, HeatBalanceManager_GetAirBoundaryConstructData2) EXPECT_TRUE(ErrorsFound); std::string const error_string = - delimited_string({" ** Severe ** CreateAirBoundaryConstructionsConstruction:AirBoundary=\"AIR BOUNDARY WITH BAD MIXING SCHEDULE\", " - "invalid (not found) Simple Mixing Schedule Name=\"xyz\".", + delimited_string({" ** Severe ** CreateAirBoundaryConstructions: Construction:AirBoundary = Air Boundary with Bad Mixing Schedule", + " ** ~~~ ** Simple Mixing Schedule Name = xyz, item not found.", " ** Severe ** Errors found in creating the constructions defined with Construction:AirBoundary.", " ** Warning ** This building has no thermal mass which can cause an unstable solution.", " ** ~~~ ** Use Material object for all opaque material definitions except very light insulation layers."}); @@ -1881,7 +1877,7 @@ TEST_F(EnergyPlusFixture, HeatBalanceManager_GetAirBoundaryConstructData2) EXPECT_TRUE(state->dataConstruction->Construct(constrNum).TypeIsAirBoundaryMixing); EXPECT_EQ(state->dataConstruction->Construct(constrNum).TotLayers, 0); EXPECT_EQ(state->dataConstruction->Construct(constrNum).AirBoundaryACH, 0.1); - EXPECT_EQ(state->dataConstruction->Construct(constrNum).AirBoundaryMixingSched, 0); + EXPECT_EQ(state->dataConstruction->Construct(constrNum).airBoundaryMixingSched, nullptr); EXPECT_EQ(state->dataHeatBal->NominalRforNominalUCalculation(constrNum), 0.0); } @@ -2461,7 +2457,8 @@ TEST_F(EnergyPlusFixture, ReadIncidentSolarMultiplierInput_invalidSched) state->dataSurface->Surface(2).Construction = 2; GetIncidentSolarMultiplier(*state, ErrorsFound); std::string error_string = - delimited_string({" ** Severe ** Invalid Incident Solar Multiplier Schedule Name in SurfaceProperty:IncidentSolarMultiplier"}); + delimited_string({" ** Severe ** GetIncidentSolarMultiplier: SurfaceProperty:IncidentSolarMultiplier = ZN001:WALL001:WIN001", + " ** ~~~ ** Incident Solar Multiplier Schedule Name = WRONGSCHEDULE, item not found."}); EXPECT_TRUE(compare_err_stream(error_string, true)); } @@ -2576,14 +2573,14 @@ TEST_F(EnergyPlusFixture, ReadIncidentSolarMultiplierInput) ASSERT_TRUE(process_idf(idf_objects)); - bool ErrorsFound = false; - - state->dataGlobal->NumOfTimeStepInHour = 4; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 15; // must initialize this to get schedules initialized + state->dataGlobal->TimeStepsInHour = 4; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 15; // must initialize this to get schedules initialized state->dataGlobal->TimeStepZone = 0.25; - state->dataGlobal->TimeStepZoneSec = state->dataGlobal->TimeStepZone * Constant::SecInHour; + state->dataGlobal->TimeStepZoneSec = state->dataGlobal->TimeStepZone * Constant::rSecsInHour; - ScheduleManager::ProcessScheduleInput(*state); // read schedules + state->init_state(*state); + + bool ErrorsFound = false; state->dataEnvrn->Month = 5; state->dataEnvrn->DayOfMonth = 31; @@ -2593,7 +2590,7 @@ TEST_F(EnergyPlusFixture, ReadIncidentSolarMultiplierInput) state->dataEnvrn->HolidayIndex = 0; state->dataGlobal->TimeStep = 1; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 0); - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); Material::GetMaterialData(*state, ErrorsFound); EXPECT_FALSE(ErrorsFound); @@ -2611,9 +2608,9 @@ TEST_F(EnergyPlusFixture, ReadIncidentSolarMultiplierInput) GetIncidentSolarMultiplier(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); EXPECT_EQ(state->dataSurface->SurfIncSolMultiplier(2).Scaler, 0.6); - EXPECT_EQ(GetScheduleName(*state, state->dataSurface->SurfIncSolMultiplier(2).SchedPtr), "SOLARMULTCOMPACT"); + EXPECT_EQ(state->dataSurface->SurfIncSolMultiplier(2).sched->Name, "SOLARMULTCOMPACT"); - EXPECT_EQ(ScheduleManager::GetCurrentScheduleValue(*state, state->dataSurface->SurfIncSolMultiplier(2).SchedPtr), 0.1); + EXPECT_EQ(state->dataSurface->SurfIncSolMultiplier(2).sched->getCurrentVal(), 0.1); state->dataSurface->Surface(2).Class = DataSurfaces::SurfaceClass::Door; GetIncidentSolarMultiplier(*state, ErrorsFound); diff --git a/tst/EnergyPlus/unit/HeatBalanceMovableInsulation.unit.cc b/tst/EnergyPlus/unit/HeatBalanceMovableInsulation.unit.cc index 4ca640a2fb0..6919431322e 100644 --- a/tst/EnergyPlus/unit/HeatBalanceMovableInsulation.unit.cc +++ b/tst/EnergyPlus/unit/HeatBalanceMovableInsulation.unit.cc @@ -69,21 +69,20 @@ namespace EnergyPlus { TEST_F(EnergyPlusFixture, HeatBalanceMovableInsulation_EvalOutsideMovableInsulation) { + state->init_state(*state); auto &s_mat = state->dataMaterial; int SurfNum = 1; state->dataSurface->Surface.allocate(SurfNum); - state->dataSurface->SurfSchedMovInsulExt.allocate(SurfNum); + state->dataSurface->SurfMovInsulExtScheds.allocate(SurfNum); state->dataSurface->SurfMaterialMovInsulExt.allocate(SurfNum); - state->dataSurface->SurfSchedMovInsulExt(SurfNum) = 1; + state->dataSurface->SurfMovInsulExtScheds(SurfNum) = Sched::GetScheduleAlwaysOn(*state); state->dataSurface->SurfMaterialMovInsulExt(SurfNum) = 1; state->dataHeatBalSurf->SurfMovInsulExtPresent.allocate(SurfNum); state->dataHeatBalSurf->SurfMovInsulHExt.allocate(SurfNum); state->dataHeatBalSurf->SurfAbsSolarExt.allocate(SurfNum); state->dataHeatBalSurf->SurfAbsThermalExt.allocate(SurfNum); state->dataHeatBalSurf->SurfRoughnessExt.allocate(SurfNum); - state->dataScheduleMgr->Schedule.allocate(1); - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; state->dataHeatBalSurf->SurfMovInsulExtPresent(1) = true; state->dataHeatBalSurf->SurfMovInsulIndexList.push_back(1); @@ -150,20 +149,19 @@ TEST_F(EnergyPlusFixture, HeatBalanceMovableInsulation_EvalOutsideMovableInsulat TEST_F(EnergyPlusFixture, HeatBalanceMovableInsulation_EvalInsideMovableInsulation) { - + state->init_state(*state); + int SurfNum = 1; state->dataSurface->Surface.allocate(SurfNum); - state->dataSurface->SurfSchedMovInsulInt.allocate(SurfNum); + state->dataSurface->SurfMovInsulIntScheds.allocate(SurfNum); state->dataSurface->SurfMaterialMovInsulInt.allocate(SurfNum); - state->dataSurface->SurfSchedMovInsulInt(SurfNum) = 1; + state->dataSurface->SurfMovInsulIntScheds(SurfNum) = Sched::GetScheduleAlwaysOn(*state); state->dataSurface->SurfMaterialMovInsulInt(SurfNum) = 1; state->dataHeatBalSurf->SurfMovInsulIntPresent.allocate(SurfNum); state->dataHeatBalSurf->SurfMovInsulHInt.allocate(SurfNum); state->dataHeatBalSurf->SurfAbsSolarInt.allocate(SurfNum); state->dataHeatBalSurf->SurfAbsThermalInt.allocate(SurfNum); - state->dataScheduleMgr->Schedule.allocate(1); - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; state->dataHeatBalSurf->SurfMovInsulIndexList.push_back(1); auto *mat = new Material::MaterialShade; @@ -287,15 +285,14 @@ TEST_F(EnergyPlusFixture, SurfaceControlMovableInsulation_InvalidWindowSimpleGla }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); // set error to false bool ErrorsFound(false); // set zone data state->dataGlobal->NumOfZones = 1; state->dataHeatBal->Zone.allocate(1); state->dataHeatBal->Zone(1).Name = "ZONE ONE"; - // get schedule data - ScheduleManager::ProcessScheduleInput(*state); + // get materials data Material::GetMaterialData(*state, ErrorsFound); EXPECT_FALSE(ErrorsFound); @@ -317,13 +314,13 @@ TEST_F(EnergyPlusFixture, SurfaceControlMovableInsulation_InvalidWindowSimpleGla state->dataSurface->TotSurfaces = 1; state->dataSurface->Surface.allocate(1); state->dataSurface->SurfMaterialMovInsulExt.allocate(1); - state->dataSurface->SurfSchedMovInsulExt.allocate(1); + state->dataSurface->SurfMovInsulExtScheds.allocate(1); state->dataSurface->SurfMaterialMovInsulInt.allocate(1); - state->dataSurface->SurfSchedMovInsulInt.allocate(1); + state->dataSurface->SurfMovInsulIntScheds.allocate(1); state->dataSurface->SurfMaterialMovInsulExt = 0; - state->dataSurface->SurfSchedMovInsulExt = 0; + state->dataSurface->SurfMovInsulExtScheds(1) = nullptr; state->dataSurface->SurfMaterialMovInsulInt = 0; - state->dataSurface->SurfSchedMovInsulInt = 0; + state->dataSurface->SurfMovInsulIntScheds(1) = nullptr; state->dataSurfaceGeometry->SurfaceTmp.allocate(1); int SurfNum = 0; int TotHTSurfs = state->dataSurface->TotSurfaces = 1; diff --git a/tst/EnergyPlus/unit/HeatBalanceSurfaceManager.unit.cc b/tst/EnergyPlus/unit/HeatBalanceSurfaceManager.unit.cc index dbb84bbd90a..d9a627d85d4 100644 --- a/tst/EnergyPlus/unit/HeatBalanceSurfaceManager.unit.cc +++ b/tst/EnergyPlus/unit/HeatBalanceSurfaceManager.unit.cc @@ -89,7 +89,6 @@ #include "Fixtures/EnergyPlusFixture.hh" using namespace EnergyPlus::HeatBalanceSurfaceManager; -using namespace EnergyPlus::ScheduleManager; namespace EnergyPlus { @@ -110,7 +109,7 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_CalcOutsideSurfTemp) TempExt = 23.0; ErrorFlag = false; - state->dataGlobal->NumOfTimeStepInHour = 4; + state->dataGlobal->TimeStepsInHour = 4; state->dataGlobal->TimeStepZoneSec = 900.0; state->dataConstruction->Construct.allocate(ConstrNum); @@ -728,6 +727,7 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_TestSurfTempCalcHeatBalanceI }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); bool ErrorsFound = false; HeatBalanceManager::GetProjectControlData(*state, ErrorsFound); @@ -1265,17 +1265,16 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_TestSurfTempCalcHeatBalanceI }); ASSERT_TRUE(process_idf(idf_objects)); - + state->dataGlobal->TimeStepsInHour = 1; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 60; // must initialize this to get schedules initialized + state->init_state(*state); + bool ErrorsFound(false); // If errors detected in input - ASSERT_FALSE(ErrorsFound); state->dataEnvrn->DayOfYear_Schedule = 1; // must initialize this to get schedules initialized state->dataEnvrn->DayOfWeek = 1; // must initialize this to get schedules initialized state->dataGlobal->HourOfDay = 1; // must initialize this to get schedules initialized state->dataGlobal->TimeStep = 1; // must initialize this to get schedules initialized - state->dataGlobal->NumOfTimeStepInHour = 1; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 60; // must initialize this to get schedules initialized - ScheduleManager::ProcessScheduleInput(*state); // read schedules state->files.inputWeatherFilePath.filePath = configured_source_directory() / "tst/EnergyPlus/unit/Resources/HeatBalanceKivaManagerOSkyTest.epw"; state->dataWeather->WeatherFileExists = true; @@ -1347,8 +1346,8 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_TestSurfTempCalcHeatBalanceI state->dataHeatBal->ZoneWinHeatGainRep.allocate(1); state->dataHeatBal->ZoneWinHeatGainRepEnergy.allocate(1); - state->dataScheduleMgr->Schedule(1).CurrentValue = -0.1; - state->dataScheduleMgr->Schedule(2).CurrentValue = 0.1; + Sched::GetSchedule(*state, "CORE_BOTTOM OCCUPANCY")->currentVal = -0.1; + Sched::GetSchedule(*state, "CORE_BOTTOM ACTIVITY")->currentVal = 0.1; state->dataGlobal->BeginSimFlag = true; state->dataGlobal->KickOffSimulation = true; @@ -1790,10 +1789,9 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_TestSurfPropertyLocalEnv) " Until: 24:00, 90; !- Field 3"}); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); bool ErrorsFound = false; - ScheduleManager::ProcessScheduleInput(*state); - HeatBalanceManager::GetProjectControlData(*state, ErrorsFound); EXPECT_FALSE(ErrorsFound); HeatBalanceManager::GetZoneData(*state, ErrorsFound); @@ -1889,10 +1887,11 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_TestSurfPropertyLocalEnv) SolarShading::AllocateModuleArrays(*state); SolarShading::DetermineShadowingCombinations(*state); OutAirNodeManager::GetOutAirNodesInput(*state); - state->dataScheduleMgr->Schedule(1).CurrentValue = 25.0; - state->dataScheduleMgr->Schedule(2).CurrentValue = 20.0; - state->dataScheduleMgr->Schedule(3).CurrentValue = 1.5; - state->dataScheduleMgr->Schedule(4).CurrentValue = 90.0; + + Sched::GetSchedule(*state, "OUTDOORAIRNODEDRYBULB:0001")->currentVal = 25.0; + Sched::GetSchedule(*state, "OUTDOORAIRNODEWETBULB:0001")->currentVal = 20.0; + Sched::GetSchedule(*state, "OUTDOORAIRNODEWINDSPEED:0001")->currentVal = 1.5; + Sched::GetSchedule(*state, "OUTDOORAIRNODEWINDDIR:0001")->currentVal = 90.0; for (int loop = 1; loop <= state->dataSurface->TotSurfaces; ++loop) { state->dataHeatBalSurf->SurfOutsideTempHist(1)(loop) = 20.0; } @@ -2370,12 +2369,11 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_TestSurfPropertySrdSurfLWR) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + bool ErrorsFound = false; - - ScheduleManager::ProcessScheduleInput(*state); - - HeatBalanceManager::GetProjectControlData(*state, ErrorsFound); - EXPECT_FALSE(ErrorsFound); + HeatBalanceManager::GetProjectControlData(*state, ErrorsFound); // read project control data + EXPECT_FALSE(ErrorsFound); // expect no errors HeatBalanceManager::GetZoneData(*state, ErrorsFound); EXPECT_FALSE(ErrorsFound); Material::GetMaterialData(*state, ErrorsFound); @@ -2478,9 +2476,9 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_TestSurfPropertySrdSurfLWR) InitSurfaceHeatBalance(*state); state->dataSurface->SurfAirSkyRadSplit.allocate(6); - state->dataScheduleMgr->Schedule(1).CurrentValue = 25.0; // Srd Srfs Temp - state->dataScheduleMgr->Schedule(2).CurrentValue = 15.0; // Sky temp - state->dataScheduleMgr->Schedule(3).CurrentValue = 22.0; // Grd temp + Sched::GetSchedule(*state, "SURROUNDING TEMP SCH 1")->currentVal = 25.0; // Srd Srfs Temp + Sched::GetSchedule(*state, "SKY TEMP SCH")->currentVal = 15.0; // Sky temp + Sched::GetSchedule(*state, "GROUND TEMP SCH")->currentVal = 22.0; // Grd temp for (int SurfNum = 1; SurfNum <= 6; SurfNum++) { state->dataHeatBalSurf->SurfOutsideTempHist(1)(SurfNum) = 20; // Surf temp @@ -2942,10 +2940,11 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_TestSurfTempCalcHeatBalanceA " ; !- Outside Face Heat Source Term Schedule Name"}); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); bool ErrorsFound = false; - HeatBalanceManager::GetProjectControlData(*state, ErrorsFound); - EXPECT_FALSE(ErrorsFound); + HeatBalanceManager::GetProjectControlData(*state, ErrorsFound); // read project control data + EXPECT_FALSE(ErrorsFound); // expect no errors HeatBalanceManager::GetZoneData(*state, ErrorsFound); EXPECT_FALSE(ErrorsFound); Material::GetMaterialData(*state, ErrorsFound); @@ -3034,8 +3033,8 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_TestSurfTempCalcHeatBalanceA state->dataHeatBal->ZoneWinHeatGainRep.allocate(1); state->dataHeatBal->ZoneWinHeatGainRepEnergy.allocate(1); - state->dataScheduleMgr->Schedule(1).CurrentValue = -0.1; - state->dataScheduleMgr->Schedule(2).CurrentValue = 0.1; + Sched::GetSchedule(*state, "SCHE_Q_EVAP_COOL")->currentVal = -0.1; + Sched::GetSchedule(*state, "SCHE_Q_ADD_HEAT")->currentVal = 0.1; state->dataHeatBalSurf->SurfWinCoeffAdjRatio.dimension(6, 1.0); AllocateSurfaceHeatBalArrays(*state); @@ -3199,8 +3198,8 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_TestResilienceMetricReport) state->dataOutRptTab->displayThermalResilienceSummary = true; state->dataEnvrn->Month = 7; state->dataEnvrn->DayOfMonth = 1; - state->dataGlobal->NumOfTimeStepInHour = 4; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 15; // must initialize this to get schedules initialized + state->dataGlobal->TimeStepsInHour = 4; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 15; // must initialize this to get schedules initialized state->dataGlobal->TimeStep = 1; state->dataGlobal->TimeStepZone = 1; @@ -3212,26 +3211,27 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_TestResilienceMetricReport) state->dataZoneTempPredictorCorrector->zoneHeatBalance(1).ZTAV = 0.0; state->dataZoneTempPredictorCorrector->zoneHeatBalance(1).airHumRatAvg = 0.0; - state->dataHeatBalFanSys->ZoneThermostatSetPointLo.dimension(state->dataGlobal->NumOfZones, 22.0); - state->dataHeatBalFanSys->ZoneThermostatSetPointHi.dimension(state->dataGlobal->NumOfZones, 28.0); + state->dataHeatBalFanSys->zoneTstatSetpts.allocate(state->dataGlobal->NumOfZones); + for (auto &zoneTstatSetpt : state->dataHeatBalFanSys->zoneTstatSetpts) { + zoneTstatSetpt.setptLo = 22.0; + zoneTstatSetpt.setptHi = 28.0; + } state->dataHeatBal->TotPeople = 1; state->dataHeatBal->People.allocate(state->dataHeatBal->TotPeople); state->dataHeatBal->People(1).ZonePtr = 1; state->dataHeatBal->People(1).Pierce = true; state->dataHeatBal->People(1).NumberOfPeople = 2; - state->dataHeatBal->People(1).NumberOfPeoplePtr = 1; + state->dataHeatBal->People(1).numberOfPeopleSched = Sched::AddScheduleConstant(*state, "Occupancy"); state->dataHeatBal->People(1).ColdStressTempThresh = 15.0; state->dataHeatBal->People(1).HeatStressTempThresh = 29.5; - state->dataHeatBalFanSys->ZoneThermostatSetPointHi(1) = 27.5; - state->dataHeatBalFanSys->ZoneThermostatSetPointLo(1) = 15.0; - - state->dataScheduleMgr->Schedule.allocate(1); + state->dataHeatBalFanSys->zoneTstatSetpts(1).setptHi = 27.5; + state->dataHeatBalFanSys->zoneTstatSetpts(1).setptLo = 15.0; state->dataThermalComforts->ThermalComfortData.allocate(state->dataHeatBal->TotPeople); state->dataThermalComforts->ThermalComfortData(1).PierceSET = 31; - state->dataScheduleMgr->Schedule(1).CurrentValue = 0; + state->dataHeatBal->People(1).numberOfPeopleSched->currentVal = 0; // Heat Index Case 1: Zone T < 80 F; state->dataGlobal->HourOfDay = 1; @@ -3427,7 +3427,7 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_TestResilienceMetricReport) EXPECT_NEAR(0.0, state->dataHeatBal->Resilience(1).ZoneDiscomfortWtExceedOccupiedHourBins[3], 1e-8); // Very-hot Exceedance OccupiedHours state->dataThermalComforts->ThermalComfortData(1).PierceSET = 11.2; - state->dataScheduleMgr->Schedule(1).CurrentValue = 0.4; + state->dataHeatBal->People(1).numberOfPeopleSched->currentVal = 0.4; state->dataZoneTempPredictorCorrector->zoneHeatBalance(1).ZTAV = 31; state->dataThermalComforts->ThermalComfortData(1).FangerPMV = -3.5; for (int hour = 5; hour <= 7; hour++) { @@ -3478,7 +3478,7 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_TestResilienceMetricReport) state->dataThermalComforts->ThermalComfortData(1).PierceSET = 32; state->dataZoneTempPredictorCorrector->zoneHeatBalance(1).ZTAV = 28; - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; + state->dataHeatBal->People(1).numberOfPeopleSched->currentVal = 1.0; state->dataThermalComforts->ThermalComfortData(1).FangerPMV = -1.2; for (int hour = 8; hour <= 10; hour++) { state->dataGlobal->HourOfDay = hour; @@ -3574,7 +3574,7 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_TestResilienceMetricReport) state->dataThermalComforts->ThermalComfortData(1).PierceSET = 11.2; state->dataZoneTempPredictorCorrector->zoneHeatBalance(1).ZTAV = 30; - state->dataScheduleMgr->Schedule(1).CurrentValue = 0.4; + state->dataHeatBal->People(1).numberOfPeopleSched->currentVal = 0.4; state->dataThermalComforts->ThermalComfortData(1).FangerPMV = 1.2; for (int hour = 13; hour <= 18; hour++) { state->dataGlobal->HourOfDay = hour; @@ -3621,7 +3621,7 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_TestResilienceMetricReport) EXPECT_NEAR(3.0, state->dataHeatBal->Resilience(1).ZoneDiscomfortWtExceedOccupiedHourBins[2], 1e-8); // Warm Exceedance OccupiedHours EXPECT_NEAR(0.0, state->dataHeatBal->Resilience(1).ZoneDiscomfortWtExceedOccupiedHourBins[3], 1e-8); // Very-hot Exceedance OccupiedHours - state->dataScheduleMgr->Schedule(1).CurrentValue = 0; + state->dataHeatBal->People(1).numberOfPeopleSched->currentVal = 0; state->dataZoneTempPredictorCorrector->zoneHeatBalance(1).ZTAV = 12; state->dataThermalComforts->ThermalComfortData(1).FangerPMV = 1.2; for (int hour = 19; hour <= 20; hour++) { @@ -3674,7 +3674,7 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_TestResilienceMetricReport) state->dataContaminantBalance->ZoneAirCO2Avg.allocate(state->dataGlobal->NumOfZones); state->dataContaminantBalance->Contaminant.CO2Simulation = true; - state->dataScheduleMgr->Schedule(1).CurrentValue = 1; + state->dataHeatBal->People(1).numberOfPeopleSched->currentVal = 1; state->dataOutRptTab->displayCO2ResilienceSummary = true; state->dataContaminantBalance->ZoneAirCO2Avg(1) = 1100; ReportCO2Resilience(*state); @@ -3744,8 +3744,8 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_TestThermalResilienceReportR state->dataOutRptTab->displayThermalResilienceSummary = true; state->dataEnvrn->Month = 1; state->dataEnvrn->DayOfMonth = 1; - state->dataGlobal->NumOfTimeStepInHour = 4; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 15; // must initialize this to get schedules initialized + state->dataGlobal->TimeStepsInHour = 4; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 15; // must initialize this to get schedules initialized state->dataGlobal->TimeStep = 1; state->dataGlobal->TimeStepZone = 1; @@ -3758,8 +3758,12 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_TestThermalResilienceReportR state->dataZoneTempPredictorCorrector->zoneHeatBalance(1).airHumRatAvg = 0.0; state->dataHeatBal->Zone.allocate(state->dataGlobal->NumOfZones); - state->dataHeatBalFanSys->ZoneThermostatSetPointLo.dimension(state->dataGlobal->NumOfZones, 22.0); - state->dataHeatBalFanSys->ZoneThermostatSetPointHi.dimension(state->dataGlobal->NumOfZones, 28.0); + + state->dataHeatBalFanSys->zoneTstatSetpts.allocate(state->dataGlobal->NumOfZones); + for (auto &zoneTstatSetpt : state->dataHeatBalFanSys->zoneTstatSetpts) { + zoneTstatSetpt.setptLo = 22.0; + zoneTstatSetpt.setptHi = 28.0; + } state->dataHeatBalFanSys->ZoneHeatIndexHourBinsRepPeriod.allocate(state->dataGlobal->NumOfZones, state->dataWeather->TotThermalReportPers); state->dataHeatBalFanSys->ZoneHumidexHourBinsRepPeriod.allocate(state->dataGlobal->NumOfZones, state->dataWeather->TotThermalReportPers); @@ -3779,21 +3783,23 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_TestThermalResilienceReportR state->dataHeatBalFanSys->CrossedHeatThreshRepPeriod.allocate(state->dataGlobal->NumOfZones, state->dataWeather->TotThermalReportPers); state->dataHeatBalFanSys->CrossedColdThreshRepPeriod = false; state->dataHeatBalFanSys->CrossedHeatThreshRepPeriod = false; - state->dataHeatBalFanSys->ZoneThermostatSetPointLo.dimension(state->dataGlobal->NumOfZones, 22.0); - state->dataHeatBalFanSys->ZoneThermostatSetPointHi.dimension(state->dataGlobal->NumOfZones, 28.0); + + state->dataHeatBalFanSys->zoneTstatSetpts.allocate(state->dataGlobal->NumOfZones); + for (auto &zoneTstatSetpt : state->dataHeatBalFanSys->zoneTstatSetpts) { + zoneTstatSetpt.setptLo = 22.0; + zoneTstatSetpt.setptHi = 28.0; + } state->dataHeatBal->TotPeople = 1; state->dataHeatBal->People.allocate(state->dataHeatBal->TotPeople); state->dataHeatBal->People(1).ZonePtr = 1; state->dataHeatBal->People(1).Pierce = true; state->dataHeatBal->People(1).NumberOfPeople = 2; - state->dataHeatBal->People(1).NumberOfPeoplePtr = 1; + state->dataHeatBal->People(1).numberOfPeopleSched = Sched::AddScheduleConstant(*state, "Occupancy"); state->dataHeatBal->People(1).ColdStressTempThresh = 15.0; state->dataHeatBal->People(1).HeatStressTempThresh = 29.5; - state->dataHeatBalFanSys->ZoneThermostatSetPointHi(1) = 27.5; - state->dataHeatBalFanSys->ZoneThermostatSetPointLo(1) = 15.0; - - state->dataScheduleMgr->Schedule.allocate(1); + state->dataHeatBalFanSys->zoneTstatSetpts(1).setptHi = 27.5; + state->dataHeatBalFanSys->zoneTstatSetpts(1).setptLo = 15.0; state->dataThermalComforts->ThermalComfortData.allocate(state->dataHeatBal->TotPeople); state->dataHeatBalFanSys->ZoneLowSETHoursRepPeriod.allocate(state->dataGlobal->NumOfZones, state->dataWeather->TotThermalReportPers); @@ -3803,7 +3809,7 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_TestThermalResilienceReportR state->dataHeatBalFanSys->lowSETLongestStartRepPeriod.allocate(state->dataGlobal->NumOfZones, state->dataWeather->TotThermalReportPers); state->dataHeatBalFanSys->highSETLongestStartRepPeriod.allocate(state->dataGlobal->NumOfZones, state->dataWeather->TotThermalReportPers); state->dataThermalComforts->ThermalComfortData(1).PierceSET = 31; - state->dataScheduleMgr->Schedule(1).CurrentValue = 0; + state->dataHeatBal->People(1).numberOfPeopleSched->currentVal = 0; // --------------------------------------------------------------------- // Report Period I start @@ -3965,7 +3971,7 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_TestThermalResilienceReportR EXPECT_NEAR(0.0, state->dataHeatBalFanSys->ZoneDiscomfortWtExceedOccupiedHourBinsRepPeriod(1, 1)[3], 1e-8); // Very-hot Exceedance OccupiedHours state->dataThermalComforts->ThermalComfortData(1).PierceSET = 11.2; - state->dataScheduleMgr->Schedule(1).CurrentValue = 0.4; + state->dataHeatBal->People(1).numberOfPeopleSched->currentVal = 0.4; state->dataZoneTempPredictorCorrector->zoneHeatBalance(1).ZTAV = 31; state->dataThermalComforts->ThermalComfortData(1).FangerPMV = -3.5; for (int hour = 5; hour <= 7; hour++) { @@ -4018,7 +4024,7 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_TestThermalResilienceReportR state->dataThermalComforts->ThermalComfortData(1).PierceSET = 32; state->dataZoneTempPredictorCorrector->zoneHeatBalance(1).ZTAV = 28; - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; + state->dataHeatBal->People(1).numberOfPeopleSched->currentVal = 1.0; state->dataThermalComforts->ThermalComfortData(1).FangerPMV = -1.2; for (int hour = 8; hour <= 10; hour++) { state->dataGlobal->HourOfDay = hour; @@ -4085,7 +4091,7 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_TestThermalResilienceReportR state->dataThermalComforts->ThermalComfortData(1).PierceSET = 11.2; state->dataZoneTempPredictorCorrector->zoneHeatBalance(1).ZTAV = 30; - state->dataScheduleMgr->Schedule(1).CurrentValue = 0.4; + state->dataHeatBal->People(1).numberOfPeopleSched->currentVal = 0.4; state->dataThermalComforts->ThermalComfortData(1).FangerPMV = 1.2; for (int hour = 13; hour <= 18; hour++) { state->dataGlobal->HourOfDay = hour; @@ -4134,7 +4140,7 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_TestThermalResilienceReportR EXPECT_NEAR(3.0, state->dataHeatBalFanSys->ZoneDiscomfortWtExceedOccupiedHourBinsRepPeriod(1, 2)[2], 1e-8); // Warm Exceedance OccupiedHours EXPECT_NEAR(0.0, state->dataHeatBalFanSys->ZoneDiscomfortWtExceedOccupiedHourBinsRepPeriod(1, 2)[3], 1e-8); // Very-hot Exceedance OccupiedHours - state->dataScheduleMgr->Schedule(1).CurrentValue = 0; + state->dataHeatBal->People(1).numberOfPeopleSched->currentVal = 0; state->dataZoneTempPredictorCorrector->zoneHeatBalance(1).ZTAV = 12; state->dataThermalComforts->ThermalComfortData(1).FangerPMV = 1.2; for (int hour = 19; hour <= 20; hour++) { @@ -4235,8 +4241,8 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_TestCO2ResilienceReportRepPe state->dataGlobal->KindOfSim = Constant::KindOfSim::RunPeriodWeather; state->dataEnvrn->Month = 1; state->dataEnvrn->DayOfMonth = 1; - state->dataGlobal->NumOfTimeStepInHour = 4; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 15; // must initialize this to get schedules initialized + state->dataGlobal->TimeStepsInHour = 4; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 15; // must initialize this to get schedules initialized state->dataGlobal->TimeStep = 1; state->dataGlobal->TimeStepZone = 1; @@ -4248,7 +4254,7 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_TestCO2ResilienceReportRepPe state->dataHeatBal->People.allocate(state->dataHeatBal->TotPeople); state->dataHeatBal->People(1).ZonePtr = 1; state->dataHeatBal->People(1).NumberOfPeople = 2; - state->dataHeatBal->People(1).NumberOfPeoplePtr = 1; + state->dataHeatBal->People(1).numberOfPeopleSched = Sched::AddScheduleConstant(*state, "Occupancy"); int NoBins = 3; @@ -4261,9 +4267,8 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_TestCO2ResilienceReportRepPe state->dataContaminantBalance->ZoneAirCO2Avg.allocate(state->dataGlobal->NumOfZones); state->dataContaminantBalance->Contaminant.CO2Simulation = true; state->dataOutRptTab->displayCO2ResilienceSummary = true; - state->dataScheduleMgr->Schedule.allocate(1); - state->dataScheduleMgr->Schedule(1).CurrentValue = 0; + state->dataHeatBal->People(1).numberOfPeopleSched->currentVal = 0; state->dataContaminantBalance->ZoneAirCO2Avg(1) = 900; for (int hour = 1; hour <= 4; hour++) { state->dataGlobal->HourOfDay = hour; @@ -4279,7 +4284,7 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_TestCO2ResilienceReportRepPe EXPECT_NEAR(0.0, state->dataHeatBalFanSys->ZoneCO2LevelOccupiedHourBinsRepPeriod(1, 1)[1], 1e-8); EXPECT_NEAR(0.0, state->dataHeatBalFanSys->ZoneCO2LevelOccupiedHourBinsRepPeriod(1, 1)[2], 1e-8); - state->dataScheduleMgr->Schedule(1).CurrentValue = 0.4; + state->dataHeatBal->People(1).numberOfPeopleSched->currentVal = 0.4; state->dataContaminantBalance->ZoneAirCO2Avg(1) = 1100; for (int hour = 5; hour <= 7; hour++) { state->dataGlobal->HourOfDay = hour; @@ -4295,7 +4300,7 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_TestCO2ResilienceReportRepPe EXPECT_NEAR(3.0, state->dataHeatBalFanSys->ZoneCO2LevelOccupiedHourBinsRepPeriod(1, 1)[1], 1e-8); EXPECT_NEAR(0.0, state->dataHeatBalFanSys->ZoneCO2LevelOccupiedHourBinsRepPeriod(1, 1)[2], 1e-8); - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; + state->dataHeatBal->People(1).numberOfPeopleSched->currentVal = 1.0; state->dataContaminantBalance->ZoneAirCO2Avg(1) = 5500; state->dataGlobal->HourOfDay = 8; ReportCO2Resilience(*state); @@ -4310,7 +4315,7 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_TestCO2ResilienceReportRepPe EXPECT_NEAR(3.0, state->dataHeatBalFanSys->ZoneCO2LevelOccupiedHourBinsRepPeriod(1, 1)[1], 1e-8); EXPECT_NEAR(1.0, state->dataHeatBalFanSys->ZoneCO2LevelOccupiedHourBinsRepPeriod(1, 1)[2], 1e-8); - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; + state->dataHeatBal->People(1).numberOfPeopleSched->currentVal = 1.0; state->dataContaminantBalance->ZoneAirCO2Avg(1) = 2000; for (int hour = 9; hour <= 10; hour++) { state->dataGlobal->HourOfDay = hour; @@ -4326,7 +4331,7 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_TestCO2ResilienceReportRepPe EXPECT_NEAR(5.0, state->dataHeatBalFanSys->ZoneCO2LevelOccupiedHourBinsRepPeriod(1, 1)[1], 1e-8); EXPECT_NEAR(1.0, state->dataHeatBalFanSys->ZoneCO2LevelOccupiedHourBinsRepPeriod(1, 1)[2], 1e-8); - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; + state->dataHeatBal->People(1).numberOfPeopleSched->currentVal = 1.0; state->dataContaminantBalance->ZoneAirCO2Avg(1) = 1500; for (int hour = 13; hour <= 18; hour++) { state->dataGlobal->HourOfDay = hour; @@ -4389,8 +4394,8 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_TestVisualResilienceReportRe state->dataGlobal->KindOfSim = Constant::KindOfSim::RunPeriodWeather; state->dataEnvrn->Month = 1; state->dataEnvrn->DayOfMonth = 1; - state->dataGlobal->NumOfTimeStepInHour = 4; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 15; // must initialize this to get schedules initialized + state->dataGlobal->TimeStepsInHour = 4; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 15; // must initialize this to get schedules initialized state->dataGlobal->TimeStep = 1; state->dataGlobal->TimeStepZone = 1; @@ -4402,7 +4407,7 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_TestVisualResilienceReportRe state->dataHeatBal->People.allocate(state->dataHeatBal->TotPeople); state->dataHeatBal->People(1).ZonePtr = 1; state->dataHeatBal->People(1).NumberOfPeople = 2; - state->dataHeatBal->People(1).NumberOfPeoplePtr = 1; + state->dataHeatBal->People(1).numberOfPeopleSched = Sched::AddScheduleConstant(*state, "Occupancy"); state->dataDayltg->ZoneDaylight.allocate(state->dataGlobal->NumOfZones); int totDaylightingControls = state->dataGlobal->NumOfZones; @@ -4426,9 +4431,8 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_TestVisualResilienceReportRe } state->dataOutRptTab->displayVisualResilienceSummary = true; - state->dataScheduleMgr->Schedule.allocate(1); - state->dataScheduleMgr->Schedule(1).CurrentValue = 0; + state->dataHeatBal->People(1).numberOfPeopleSched->currentVal = 0; state->dataDayltg->daylightControl(1).refPts(1).illumSetPoint = 250; for (int hour = 1; hour <= 4; hour++) { state->dataGlobal->HourOfDay = hour; @@ -4448,7 +4452,7 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_TestVisualResilienceReportRe EXPECT_NEAR(0.0, state->dataHeatBalFanSys->ZoneLightingLevelOccupiedHourBinsRepPeriod(1, 1)[2], 1e-8); EXPECT_NEAR(0.0, state->dataHeatBalFanSys->ZoneLightingLevelOccupiedHourBinsRepPeriod(1, 1)[3], 1e-8); - state->dataScheduleMgr->Schedule(1).CurrentValue = 0.4; + state->dataHeatBal->People(1).numberOfPeopleSched->currentVal = 0.4; state->dataDayltg->daylightControl(1).refPts(1).illumSetPoint = 600; for (int hour = 5; hour <= 7; hour++) { state->dataGlobal->HourOfDay = hour; @@ -4468,7 +4472,7 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_TestVisualResilienceReportRe EXPECT_NEAR(0.0, state->dataHeatBalFanSys->ZoneLightingLevelOccupiedHourBinsRepPeriod(1, 1)[2], 1e-8); EXPECT_NEAR(3.0, state->dataHeatBalFanSys->ZoneLightingLevelOccupiedHourBinsRepPeriod(1, 1)[3], 1e-8); - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; + state->dataHeatBal->People(1).numberOfPeopleSched->currentVal = 1.0; state->dataDayltg->daylightControl(1).refPts(1).illumSetPoint = 70; for (int hour = 8; hour <= 10; hour++) { state->dataGlobal->HourOfDay = hour; @@ -4488,7 +4492,7 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_TestVisualResilienceReportRe EXPECT_NEAR(0.0, state->dataHeatBalFanSys->ZoneLightingLevelOccupiedHourBinsRepPeriod(1, 1)[2], 1e-8); EXPECT_NEAR(3.0, state->dataHeatBalFanSys->ZoneLightingLevelOccupiedHourBinsRepPeriod(1, 1)[3], 1e-8); - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; + state->dataHeatBal->People(1).numberOfPeopleSched->currentVal = 1.0; state->dataDayltg->daylightControl(1).refPts(1).illumSetPoint = 600; for (int hour = 13; hour <= 15; hour++) { state->dataGlobal->HourOfDay = hour; @@ -4508,7 +4512,7 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_TestVisualResilienceReportRe EXPECT_NEAR(0.0, state->dataHeatBalFanSys->ZoneLightingLevelOccupiedHourBinsRepPeriod(1, 2)[2], 1e-8); EXPECT_NEAR(3.0, state->dataHeatBalFanSys->ZoneLightingLevelOccupiedHourBinsRepPeriod(1, 2)[3], 1e-8); - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; + state->dataHeatBal->People(1).numberOfPeopleSched->currentVal = 1.0; state->dataDayltg->daylightControl(1).refPts(1).illumSetPoint = 70; for (int hour = 16; hour <= 18; hour++) { state->dataGlobal->HourOfDay = hour; @@ -4804,10 +4808,11 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_TestInitHBInterzoneWindow) " 1,1,1; !- X,Y,Z ==> Vertex 4 {m}"}); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + bool ErrorsFound = false; - - HeatBalanceManager::GetProjectControlData(*state, ErrorsFound); - EXPECT_FALSE(ErrorsFound); + HeatBalanceManager::GetProjectControlData(*state, ErrorsFound); // read project control data + EXPECT_FALSE(ErrorsFound); // expect no errors HeatBalanceManager::GetZoneData(*state, ErrorsFound); EXPECT_FALSE(ErrorsFound); Material::GetMaterialData(*state, ErrorsFound); @@ -4882,7 +4887,7 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_IncSolarMultiplier) state->dataSurface->surfShades.allocate(totSurf); state->dataConstruction->Construct.allocate(totConstructs); state->dataGlobal->TimeStepZoneSec = 900; - state->dataGlobal->NumOfTimeStepInHour = 6; + state->dataGlobal->TimeStepsInHour = 6; state->dataGlobal->HourOfDay = 1; state->dataGlobal->TimeStep = 1; @@ -4894,7 +4899,7 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_IncSolarMultiplier) state->dataSurface->SurfIncSolMultiplier.allocate(totSurf); state->dataSurface->SurfIncSolMultiplier(SurfNum).Name = "testing window surface"; state->dataSurface->SurfIncSolMultiplier(SurfNum).SurfaceIdx = SurfNum; - state->dataSurface->SurfIncSolMultiplier(SurfNum).SchedPtr = 0; + state->dataSurface->SurfIncSolMultiplier(SurfNum).sched = nullptr; state->dataSurface->Surface(SurfNum).Area = 100.0; @@ -5284,10 +5289,11 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_TestInitHBDaylightingNoExtWi std::string const idf_objects = idf_objects1 + idf_objects2; ASSERT_TRUE(process_idf(idf_objects)); - bool ErrorsFound = false; + state->init_state(*state); - HeatBalanceManager::GetProjectControlData(*state, ErrorsFound); - EXPECT_FALSE(ErrorsFound); + bool ErrorsFound = false; + HeatBalanceManager::GetProjectControlData(*state, ErrorsFound); // read project control data + EXPECT_FALSE(ErrorsFound); // expect no errors HeatBalanceManager::GetZoneData(*state, ErrorsFound); EXPECT_FALSE(ErrorsFound); Material::GetMaterialData(*state, ErrorsFound); @@ -5312,7 +5318,7 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_TestInitHBDaylightingNoExtWi state->dataGlobal->BeginSimFlag = true; state->dataGlobal->KickOffSimulation = true; state->dataGlobal->TimeStepZoneSec = 900; - state->dataGlobal->NumOfTimeStepInHour = 6; + state->dataGlobal->TimeStepsInHour = 6; state->dataGlobal->HourOfDay = 1; state->dataGlobal->TimeStep = 1; @@ -5868,10 +5874,12 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_TestTDDSurfWinHeatGain) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + bool ErrorsFound = false; - HeatBalanceManager::GetProjectControlData(*state, ErrorsFound); - EXPECT_FALSE(ErrorsFound); + HeatBalanceManager::GetProjectControlData(*state, ErrorsFound); // read project control data + EXPECT_FALSE(ErrorsFound); // expect no errors HeatBalanceManager::GetZoneData(*state, ErrorsFound); EXPECT_FALSE(ErrorsFound); Material::GetMaterialData(*state, ErrorsFound); @@ -5884,10 +5892,10 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_TestTDDSurfWinHeatGain) state->dataSurfaceGeometry->CosZoneRelNorth.allocate(2); state->dataSurfaceGeometry->SinZoneRelNorth.allocate(2); - state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); - state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); - state->dataSurfaceGeometry->CosZoneRelNorth(2) = std::cos(-state->dataHeatBal->Zone(2).RelNorth * Constant::DegToRadians); - state->dataSurfaceGeometry->SinZoneRelNorth(2) = std::sin(-state->dataHeatBal->Zone(2).RelNorth * Constant::DegToRadians); + state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); + state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); + state->dataSurfaceGeometry->CosZoneRelNorth(2) = std::cos(-state->dataHeatBal->Zone(2).RelNorth * Constant::DegToRad); + state->dataSurfaceGeometry->SinZoneRelNorth(2) = std::sin(-state->dataHeatBal->Zone(2).RelNorth * Constant::DegToRad); state->dataSurfaceGeometry->CosBldgRelNorth = 1.0; state->dataSurfaceGeometry->SinBldgRelNorth = 0.0; int const HoursInDay(24); @@ -6449,12 +6457,9 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_TestSurfPropertyViewFactorsI }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + bool ErrorsFound = false; - - ScheduleManager::ProcessScheduleInput(*state); - - HeatBalanceManager::GetProjectControlData(*state, ErrorsFound); - EXPECT_FALSE(ErrorsFound); HeatBalanceManager::GetZoneData(*state, ErrorsFound); EXPECT_FALSE(ErrorsFound); Material::GetMaterialData(*state, ErrorsFound); @@ -7008,12 +7013,11 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_TestSurfPropertySurfToGndLWR }); ASSERT_TRUE(process_idf(idf_objects)); - bool ErrorsFound = false; + state->init_state(*state); - ScheduleManager::ProcessScheduleInput(*state); - - HeatBalanceManager::GetProjectControlData(*state, ErrorsFound); - EXPECT_FALSE(ErrorsFound); + bool ErrorsFound = false; + HeatBalanceManager::GetProjectControlData(*state, ErrorsFound); // read project control data + EXPECT_FALSE(ErrorsFound); // expect no errors HeatBalanceManager::GetZoneData(*state, ErrorsFound); EXPECT_FALSE(ErrorsFound); Material::GetMaterialData(*state, ErrorsFound); @@ -7137,9 +7141,9 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_TestSurfPropertySurfToGndLWR // call to reset surface view factors InitSurfaceHeatBalance(*state); state->dataSurface->SurfAirSkyRadSplit.allocate(6); - state->dataScheduleMgr->Schedule(1).CurrentValue = 25.0; // Srd Srfs Temp - state->dataScheduleMgr->Schedule(2).CurrentValue = 15.0; // Sky temp - state->dataScheduleMgr->Schedule(3).CurrentValue = 22.0; // Grd temp + Sched::GetSchedule(*state, "SURROUNDING TEMP SCH 1")->currentVal = 25.0; // Srd Srfs Temp + Sched::GetSchedule(*state, "SKY TEMP SCH")->currentVal = 15.0; // Sky temp + Sched::GetSchedule(*state, "GROUND TEMP SCH")->currentVal = 22.0; // Grd temp for (int SurfNum = 1; SurfNum <= 6; SurfNum++) { state->dataHeatBalSurf->SurfOutsideTempHist(1)(SurfNum) = 20; // Surf temp @@ -7360,16 +7364,17 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_TestGroundSurfsAverageTemp) " autocalculate; !- Volume {m3}"}); ASSERT_TRUE(process_idf(idf_objects)); + state->dataGlobal->TimeStepZone = 1; + state->dataGlobal->TimeStepZoneSec = 3600.0; + state->dataGlobal->TimeStepsInHour = 1; + state->dataGlobal->MinutesInTimeStep = 60; + state->init_state(*state); // set global and environmental variables state->dataGlobal->BeginSimFlag = true; state->dataGlobal->BeginEnvrnFlag = true; state->dataGlobal->HourOfDay = 15; state->dataGlobal->TimeStep = 1; - state->dataGlobal->TimeStepZone = 1; - state->dataGlobal->TimeStepZoneSec = 3600.0; - state->dataGlobal->NumOfTimeStepInHour = 1; - state->dataGlobal->MinutesPerTimeStep = 60; state->dataEnvrn->Month = 7; state->dataEnvrn->DayOfMonth = 21; state->dataEnvrn->DSTIndicator = 0; @@ -7378,9 +7383,6 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_TestGroundSurfsAverageTemp) state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); state->dataEnvrn->OutBaroPress = 100000; - // update schedule values - ScheduleManager::ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; state->dataHeatBal->ZoneIntGain.allocate(1); createFacilityElectricPowerServiceObject(*state); @@ -7420,12 +7422,12 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_TestGroundSurfsAverageTemp) EXPECT_DOUBLE_EQ(0.1, GndSurfsProperty.GndSurfs(3).ViewFactor); EXPECT_DOUBLE_EQ(0.4, GndSurfsProperty.SurfsViewFactorSum); - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); // check ground temperature values - Real64 const Tgndsurf_grass = ScheduleManager::GetCurrentScheduleValue(*state, GndSurfsProperty.GndSurfs(1).TempSchPtr); - Real64 const Tgndsurf_parking = ScheduleManager::GetCurrentScheduleValue(*state, GndSurfsProperty.GndSurfs(2).TempSchPtr); - Real64 const Tgndsurf_lake = ScheduleManager::GetCurrentScheduleValue(*state, GndSurfsProperty.GndSurfs(3).TempSchPtr); + Real64 const Tgndsurf_grass = GndSurfsProperty.GndSurfs(1).tempSched->getCurrentVal(); + Real64 const Tgndsurf_parking = GndSurfsProperty.GndSurfs(2).tempSched->getCurrentVal(); + Real64 const Tgndsurf_lake = GndSurfsProperty.GndSurfs(3).tempSched->getCurrentVal(); EXPECT_DOUBLE_EQ(25.0, Tgndsurf_grass); EXPECT_DOUBLE_EQ(28.0, Tgndsurf_parking); EXPECT_DOUBLE_EQ(22.0, Tgndsurf_lake); @@ -7681,16 +7683,17 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_TestGroundSurfsAverageRefl) " autocalculate; !- Volume {m3}"}); ASSERT_TRUE(process_idf(idf_objects)); + state->dataGlobal->TimeStep = 1; + state->dataGlobal->TimeStepZone = 1; + state->dataGlobal->TimeStepZoneSec = 3600.0; + state->dataGlobal->TimeStepsInHour = 1; + state->dataGlobal->MinutesInTimeStep = 60; + state->init_state(*state); // set global and environmental variables state->dataGlobal->BeginSimFlag = true; state->dataGlobal->BeginEnvrnFlag = true; state->dataGlobal->HourOfDay = 15; - state->dataGlobal->TimeStep = 1; - state->dataGlobal->TimeStepZone = 1; - state->dataGlobal->TimeStepZoneSec = 3600.0; - state->dataGlobal->NumOfTimeStepInHour = 1; - state->dataGlobal->MinutesPerTimeStep = 60; state->dataEnvrn->Month = 7; state->dataEnvrn->DayOfMonth = 21; state->dataEnvrn->DSTIndicator = 0; @@ -7699,10 +7702,7 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_TestGroundSurfsAverageRefl) state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); state->dataEnvrn->OutBaroPress = 100000; - // update schedule values - ScheduleManager::ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; - + state->dataHeatBal->ZoneIntGain.allocate(1); createFacilityElectricPowerServiceObject(*state); HeatBalanceManager::SetPreConstructionInputParameters(*state); @@ -7741,12 +7741,12 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_TestGroundSurfsAverageRefl) EXPECT_DOUBLE_EQ(0.1, GndSurfsProperty.GndSurfs(3).ViewFactor); EXPECT_DOUBLE_EQ(0.4, GndSurfsProperty.SurfsViewFactorSum); - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); // check ground temperature values - Real64 const Rgndsurf_grass = ScheduleManager::GetCurrentScheduleValue(*state, GndSurfsProperty.GndSurfs(1).ReflSchPtr); - Real64 const Rgndsurf_parking = ScheduleManager::GetCurrentScheduleValue(*state, GndSurfsProperty.GndSurfs(2).ReflSchPtr); - Real64 const Rgndsurf_lake = ScheduleManager::GetCurrentScheduleValue(*state, GndSurfsProperty.GndSurfs(3).ReflSchPtr); + Real64 const Rgndsurf_grass = GndSurfsProperty.GndSurfs(1).reflSched->getCurrentVal(); + Real64 const Rgndsurf_parking = GndSurfsProperty.GndSurfs(2).reflSched->getCurrentVal(); + Real64 const Rgndsurf_lake = GndSurfsProperty.GndSurfs(3).reflSched->getCurrentVal(); EXPECT_DOUBLE_EQ(0.25, Rgndsurf_grass); EXPECT_DOUBLE_EQ(0.5, Rgndsurf_parking); EXPECT_DOUBLE_EQ(0.1, Rgndsurf_lake); @@ -8254,10 +8254,9 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_TestSurfPropertyViewFactorsR }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + bool ErrorsFound = false; - - ScheduleManager::ProcessScheduleInput(*state); - HeatBalanceManager::GetProjectControlData(*state, ErrorsFound); EXPECT_FALSE(ErrorsFound); HeatBalanceManager::GetZoneData(*state, ErrorsFound); @@ -8500,13 +8499,13 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_TestUpdateVariableAbsorptanc }); ASSERT_TRUE(process_idf(idf_objects)); + state->dataGlobal->TimeStepsInHour = 1; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 60; // must initialize this to get schedules initialized + state->init_state(*state); + Curve::GetCurveInput(*state); EXPECT_EQ(state->dataCurveManager->PerfCurve(1)->Name, "SOLAR_ABSORPTANCE_CURVE"); EXPECT_EQ(state->dataCurveManager->PerfCurve(2)->Name, "THERMAL_ABSORPTANCE_TABLE"); - state->dataGlobal->NumOfTimeStepInHour = 1; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 60; // must initialize this to get schedules initialized - ScheduleManager::ProcessScheduleInput(*state); // read schedules - state->dataScheduleMgr->ScheduleInputProcessed = true; state->dataEnvrn->Month = 1; state->dataEnvrn->DayOfMonth = 21; state->dataGlobal->HourOfDay = 1; @@ -8515,7 +8514,7 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_TestUpdateVariableAbsorptanc state->dataEnvrn->DayOfWeek = 2; state->dataEnvrn->HolidayIndex = 0; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); state->dataSurface->Surface.allocate(3); state->dataSurface->Surface(1).Name = "SURF_1_WALL_1"; state->dataSurface->Surface(1).Construction = 1; @@ -8544,7 +8543,7 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_TestUpdateVariableAbsorptanc mat2->Name = "WALL_2"; mat2->group = Material::Group::Regular; mat2->absorpVarCtrlSignal = Material::VariableAbsCtrlSignal::Scheduled; - mat2->absorpThermalVarSchedIdx = 1; + mat2->absorpThermalVarSched = Sched::GetSchedule(*state, "THERMAL_ABS_SCH"); s_mat->materials.push_back(mat2); state->dataCurveManager->allocateCurveVector(2); @@ -8869,15 +8868,17 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_SurroundingSurfacesTempTest) bool ErrorsFound = false; ASSERT_TRUE(process_idf(idf_objects)); + state->dataGlobal->TimeStepZone = 1; + state->dataGlobal->TimeStepZoneSec = 3600.0; + state->dataGlobal->TimeStepsInHour = 1; + state->dataGlobal->MinutesInTimeStep = 60; + state->init_state(*state); + // set global and environmental variables state->dataGlobal->BeginSimFlag = true; state->dataGlobal->BeginEnvrnFlag = true; state->dataGlobal->HourOfDay = 15; state->dataGlobal->TimeStep = 1; - state->dataGlobal->TimeStepZone = 1; - state->dataGlobal->TimeStepZoneSec = 3600.0; - state->dataGlobal->NumOfTimeStepInHour = 1; - state->dataGlobal->MinutesPerTimeStep = 60; state->dataEnvrn->Month = 7; state->dataEnvrn->DayOfMonth = 21; state->dataEnvrn->DSTIndicator = 0; @@ -8885,9 +8886,6 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_SurroundingSurfacesTempTest) state->dataEnvrn->HolidayIndex = 0; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); state->dataEnvrn->OutBaroPress = 101325; - // process schedules - ScheduleManager::ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; state->dataHeatBal->ZoneIntGain.allocate(1); createFacilityElectricPowerServiceObject(*state); @@ -8911,13 +8909,13 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_SurroundingSurfacesTempTest) int srdSurfsNum = state->dataSurface->Surface(surfNum).SurfSurroundingSurfacesNum; auto &srdSurfsProperty = state->dataSurface->SurroundingSurfsProperty(srdSurfsNum); // update schedule values for surrounding surfaces temperature - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); GetSurroundingSurfacesTemperatureAverage(*state); // calculate surrounding surfaces average temperature Real64 SrdSurfaceTemp = 0.0; Real64 SrdSurfaceTempSum = 0.0; for (auto &surdSurfs : srdSurfsProperty.SurroundingSurfs) { - SrdSurfaceTemp = ScheduleManager::GetCurrentScheduleValue(*state, surdSurfs.TempSchNum) + Constant::Kelvin; + SrdSurfaceTemp = surdSurfs.tempSched->getCurrentVal() + Constant::Kelvin; SrdSurfaceTempSum += surdSurfs.ViewFactor * pow_4(SrdSurfaceTemp); } Real64 srdSurfacesTemp_result = root_4(SrdSurfaceTempSum / surface.ViewFactorSrdSurfs) - Constant::Kelvin; diff --git a/tst/EnergyPlus/unit/HeatPumpWaterToWaterSimple.unit.cc b/tst/EnergyPlus/unit/HeatPumpWaterToWaterSimple.unit.cc index 1f37e659874..8e2c78060d2 100644 --- a/tst/EnergyPlus/unit/HeatPumpWaterToWaterSimple.unit.cc +++ b/tst/EnergyPlus/unit/HeatPumpWaterToWaterSimple.unit.cc @@ -735,10 +735,10 @@ TEST_F(EnergyPlusFixture, PlantLoopSourceSideTest) ASSERT_TRUE(process_idf(idf_objects)); SimulationManager::PostIPProcessing(*state); + state->init_state(*state); bool ErrorsFound = false; state->dataGlobal->BeginSimFlag = true; - SimulationManager::GetProjectData(*state); OutputReportPredefined::SetPredefinedTables(*state); HeatBalanceManager::SetPreConstructionInputParameters(*state); // establish array bounds for constructions early @@ -794,7 +794,7 @@ TEST_F(EnergyPlusFixture, PlantLoopSourceSideTest) state->dataGlobal->BeginHourFlag = true; state->dataGlobal->EndHourFlag = false; - for (state->dataGlobal->TimeStep = 1; state->dataGlobal->TimeStep <= state->dataGlobal->NumOfTimeStepInHour; + for (state->dataGlobal->TimeStep = 1; state->dataGlobal->TimeStep <= state->dataGlobal->TimeStepsInHour; ++state->dataGlobal->TimeStep) { state->dataGlobal->BeginTimeStepFlag = true; @@ -806,7 +806,7 @@ TEST_F(EnergyPlusFixture, PlantLoopSourceSideTest) // Note also that BeginTimeStepFlag, EndTimeStepFlag, and the // SubTimeStepFlags can/will be set/reset in the HVAC Manager. - if (state->dataGlobal->TimeStep == state->dataGlobal->NumOfTimeStepInHour) { + if (state->dataGlobal->TimeStep == state->dataGlobal->TimeStepsInHour) { state->dataGlobal->EndHourFlag = true; if (state->dataGlobal->HourOfDay == 24) { state->dataGlobal->EndDayFlag = true; @@ -1514,10 +1514,12 @@ TEST_F(EnergyPlusFixture, WWHP_AutosizeTest1) ASSERT_TRUE(process_idf(idf_objects)); SimulationManager::PostIPProcessing(*state); + state->init_state(*state); + bool ErrorsFound = false; state->dataGlobal->BeginSimFlag = true; - SimulationManager::GetProjectData(*state); + OutputReportPredefined::SetPredefinedTables(*state); HeatBalanceManager::SetPreConstructionInputParameters(*state); // establish array bounds for constructions early diff --git a/tst/EnergyPlus/unit/HeatRecovery.unit.cc b/tst/EnergyPlus/unit/HeatRecovery.unit.cc index d1155a8d8d3..89fbb176008 100644 --- a/tst/EnergyPlus/unit/HeatRecovery.unit.cc +++ b/tst/EnergyPlus/unit/HeatRecovery.unit.cc @@ -85,6 +85,7 @@ using namespace EnergyPlus::SimulationManager; TEST_F(EnergyPlusFixture, HeatRecovery_HRTest) { + state->init_state(*state); state->dataSize->CurZoneEqNum = 0; state->dataSize->CurSysNum = 0; state->dataSize->CurOASysNum = 0; @@ -117,7 +118,7 @@ TEST_F(EnergyPlusFixture, HeatRecovery_HRTest) state->dataHeatRecovery->ExchCond(ExchNum).SupOutletNode = 2; state->dataHeatRecovery->ExchCond(ExchNum).SecInletNode = 3; state->dataHeatRecovery->ExchCond(ExchNum).SecOutletNode = 4; - state->dataHeatRecovery->ExchCond(ExchNum).SchedPtr = -1; + state->dataHeatRecovery->ExchCond(ExchNum).availSched = Sched::GetScheduleAlwaysOn(*state); state->dataHeatRecovery->ExchCond(ExchNum).HeatEffectSensible100 = 0.75; state->dataHeatRecovery->ExchCond(ExchNum).HeatEffectLatent100 = 0.0; state->dataHeatRecovery->ExchCond(ExchNum).CoolEffectSensible100 = 0.75; @@ -504,7 +505,8 @@ TEST_F(EnergyPlusFixture, HeatRecoveryHXOnManinBranch_GetInputTest) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + GetReturnAirPathInput(*state); GetAirPathData(*state); ASSERT_ENUM_EQ(SimAirServingZones::CompType::HeatXchngr, state->dataAirSystemsData->PrimaryAirSystems(1).Branch(1).Comp(4).CompType_Num); @@ -3920,7 +3922,8 @@ TEST_F(EnergyPlusFixture, HeatRecoveryHXOnMainBranch_SimHeatRecoveryTest) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + // OutputProcessor::TimeValue.allocate(2); // ManageSimulation(*state); // run the design day @@ -4026,7 +4029,8 @@ TEST_F(EnergyPlusFixture, HeatRecovery_AirFlowSizing) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + // get heat recovery heat exchanger generic GetHeatRecoveryInput(*state); @@ -4145,8 +4149,8 @@ TEST_F(EnergyPlusFixture, HeatRecovery_HeatExchangerGenericCalcTest) }); ASSERT_TRUE(process_idf(idf_objects)); - - ScheduleManager::ProcessScheduleInput(*state); + state->init_state(*state); + // get OA Controller MixedAir::GetOAControllerInputs(*state); int OAContrllerNum = 1; @@ -4259,7 +4263,8 @@ TEST_F(EnergyPlusFixture, HeatRecovery_NominalAirFlowAutosizeTest) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + // get HR HX generic GetHeatRecoveryInput(*state); int ExchNum = 1; diff --git a/tst/EnergyPlus/unit/HeatingCoils.unit.cc b/tst/EnergyPlus/unit/HeatingCoils.unit.cc index c5c76e78a85..7f74daa0887 100644 --- a/tst/EnergyPlus/unit/HeatingCoils.unit.cc +++ b/tst/EnergyPlus/unit/HeatingCoils.unit.cc @@ -76,7 +76,8 @@ TEST_F(EnergyPlusFixture, HeatingCoils_FuelTypeInput) " Air Loop Outlet Node; !- Air Outlet Node Name"}); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + ASSERT_NO_THROW(HeatingCoils::GetHeatingCoilInput(*state)); EXPECT_ENUM_EQ(state->dataHeatingCoils->HeatingCoil(1).FuelType, Constant::eFuel::OtherFuel1); @@ -94,6 +95,7 @@ TEST_F(EnergyPlusFixture, HeatingCoils_FuelTypeInputError) " Air Loop Outlet Node; !- Air Outlet Node Name"}); EXPECT_FALSE(process_idf(idf_objects, false)); + state->init_state(*state); ASSERT_THROW(HeatingCoils::GetHeatingCoilInput(*state), std::runtime_error); std::string const error_string = delimited_string({ @@ -120,7 +122,7 @@ TEST_F(EnergyPlusFixture, HeatingCoils_FuelTypeCoal) " Air Loop Outlet Node; !- Air Outlet Node Name"}); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); ASSERT_NO_THROW(HeatingCoils::GetHeatingCoilInput(*state)); EXPECT_ENUM_EQ(state->dataHeatingCoils->HeatingCoil(1).FuelType, Constant::eFuel::Coal); @@ -138,6 +140,7 @@ TEST_F(EnergyPlusFixture, HeatingCoils_FuelTypePropaneGas) " Air Loop Outlet Node; !- Air Outlet Node Name"}); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); ASSERT_NO_THROW(HeatingCoils::GetHeatingCoilInput(*state)); @@ -147,6 +150,8 @@ TEST_F(EnergyPlusFixture, HeatingCoils_FuelTypePropaneGas) TEST_F(EnergyPlusFixture, HeatingCoils_OutletAirPropertiesTest) { // 7391 Test outlet air properties for MultiStageGasHeatingCoil + state->init_state(*state); + int CoilNum = 1; Real64 OffMassFlowrate = 0.2; Real64 OnMassFlowrate = 0.6; @@ -157,9 +162,7 @@ TEST_F(EnergyPlusFixture, HeatingCoils_OutletAirPropertiesTest) state->dataHeatingCoils->HeatingCoil(CoilNum).InletAirEnthalpy = Psychrometrics::PsyHFnTdbW( state->dataHeatingCoils->HeatingCoil(CoilNum).InletAirTemp, state->dataHeatingCoils->HeatingCoil(CoilNum).InletAirHumRat); state->dataEnvrn->OutBaroPress = 101325.0; - state->dataHeatingCoils->HeatingCoil(CoilNum).SchedPtr = 1; - state->dataScheduleMgr->Schedule.allocate(1); - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; + state->dataHeatingCoils->HeatingCoil(CoilNum).availSched = Sched::GetScheduleAlwaysOn(*state); state->dataHVACGlobal->MSHPMassFlowRateLow = OnMassFlowrate; state->dataHeatingCoils->HeatingCoil(CoilNum).MSNominalCapacity.allocate(1); state->dataHeatingCoils->HeatingCoil(CoilNum).MSNominalCapacity(1) = 10000; diff --git a/tst/EnergyPlus/unit/HighTempRadiantSystem.unit.cc b/tst/EnergyPlus/unit/HighTempRadiantSystem.unit.cc index 6f175d21ba8..8c42bc70444 100644 --- a/tst/EnergyPlus/unit/HighTempRadiantSystem.unit.cc +++ b/tst/EnergyPlus/unit/HighTempRadiantSystem.unit.cc @@ -95,7 +95,8 @@ TEST_F(EnergyPlusFixture, HighTempRadiantSystemTest_GetHighTempRadiantSystem) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + state->dataHeatBal->Zone.allocate(1); state->dataHeatBal->Zone(1).Name = "ZONE1"; state->dataSurface->Surface.allocate(1); @@ -109,8 +110,8 @@ TEST_F(EnergyPlusFixture, HighTempRadiantSystemTest_GetHighTempRadiantSystem) GetHighTempRadiantSystem(*state, ErrorsFound); std::string const error_string01 = - delimited_string({" ** Severe ** Heating Setpoint Temperature Schedule Name not found: RADIANT HEATING SETPOINTS", - " ** ~~~ ** Occurs for ZoneHVAC:HighTemperatureRadiant = ZONERADHEATER", + delimited_string({" ** Severe ** GetHighTempRadiantSystem: ZoneHVAC:HighTemperatureRadiant = ZONERADHEATER", + " ** ~~~ ** Heating Setpoint Temperature Schedule Name = RADIANT HEATING SETPOINTS, item not found.", " ** Severe ** Fraction of radiation distributed to surfaces and people sums up to less than 1 for ZONERADHEATER", " ** ~~~ ** This would result in some of the radiant energy delivered by the high temp radiant heater being lost.", " ** ~~~ ** The sum of all radiation fractions to surfaces = 0.80000", @@ -129,6 +130,7 @@ TEST_F(EnergyPlusFixture, HighTempRadiantSystemTest_GetHighTempRadiantSystem) TEST_F(EnergyPlusFixture, HighTempRadiantSystemTest_SizeHighTempRadiantSystemScalableFlagSetTest) { + state->init_state(*state); int RadSysNum; int SizingTypesNum; diff --git a/tst/EnergyPlus/unit/Humidifiers.unit.cc b/tst/EnergyPlus/unit/Humidifiers.unit.cc index c37958c73c6..603a15301b5 100644 --- a/tst/EnergyPlus/unit/Humidifiers.unit.cc +++ b/tst/EnergyPlus/unit/Humidifiers.unit.cc @@ -86,8 +86,7 @@ TEST_F(EnergyPlusFixture, Humidifiers_Sizing) thisHum.ThermalEffRated = 1.0; thisHum.FanPower = 0.0; thisHum.StandbyPower = 0.0; - thisHum.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - thisHum.SchedPtr = ScheduleManager::ScheduleAlwaysOn; + thisHum.availSched = Sched::GetScheduleAlwaysOn(*state); state->dataSize->FinalSysSizing.allocate(state->dataSize->CurSysNum); state->dataSize->FinalSysSizing(state->dataSize->CurSysNum).MixTempAtCoolPeak = 30.0; @@ -122,8 +121,7 @@ TEST_F(EnergyPlusFixture, Humidifiers_AutoSizing) thisHum.ThermalEffRated = 0.80; thisHum.FanPower = 0.0; thisHum.StandbyPower = 0.0; - thisHum.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - thisHum.SchedPtr = ScheduleManager::ScheduleAlwaysOn; + thisHum.availSched = Sched::GetScheduleAlwaysOn(*state); state->dataSize->FinalSysSizing.allocate(state->dataSize->CurSysNum); state->dataSize->FinalSysSizing(state->dataSize->CurSysNum).MixTempAtCoolPeak = 30.0; @@ -152,7 +150,7 @@ TEST_F(EnergyPlusFixture, Humidifiers_EnergyUse) HumidifierData thisHum; state->dataHVACGlobal->TimeStepSys = 0.25; - state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; state->dataSize->SysSizingRunDone = true; state->dataSize->CurSysNum = 1; @@ -167,8 +165,7 @@ TEST_F(EnergyPlusFixture, Humidifiers_EnergyUse) thisHum.ThermalEffRated = 1.0; thisHum.FanPower = 0.0; thisHum.StandbyPower = 0.0; - thisHum.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - thisHum.SchedPtr = ScheduleManager::ScheduleAlwaysOn; + thisHum.availSched = Sched::GetScheduleAlwaysOn(*state); state->dataSize->FinalSysSizing.allocate(state->dataSize->CurSysNum); state->dataSize->FinalSysSizing(state->dataSize->CurSysNum).MixTempAtCoolPeak = 20.0; @@ -231,7 +228,8 @@ TEST_F(EnergyPlusFixture, Humidifiers_GetHumidifierInput) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + GetHumidifierInput(*state); ASSERT_EQ(1, state->dataHumidifiers->NumHumidifiers); EXPECT_EQ(1, state->dataHumidifiers->Humidifier(1).EfficiencyCurvePtr); @@ -240,11 +238,11 @@ TEST_F(EnergyPlusFixture, Humidifiers_GetHumidifierInput) TEST_F(EnergyPlusFixture, Humidifiers_ThermalEfficiency) { // tests thermal efficiency modifier curve use - + state->init_state(*state); HumidifierData thisHum; state->dataHVACGlobal->TimeStepSys = 0.25; - state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; state->dataSize->SysSizingRunDone = true; state->dataSize->CurSysNum = 1; @@ -259,8 +257,7 @@ TEST_F(EnergyPlusFixture, Humidifiers_ThermalEfficiency) thisHum.ThermalEffRated = 0.80; thisHum.FanPower = 0.0; thisHum.StandbyPower = 0.0; - thisHum.SchedPtr = ScheduleManager::ScheduleAlwaysOn; - thisHum.SchedPtr = ScheduleManager::ScheduleAlwaysOn; + thisHum.availSched = Sched::GetScheduleAlwaysOn(*state); state->dataSize->FinalSysSizing.allocate(state->dataSize->CurSysNum); state->dataSize->FinalSysSizing(state->dataSize->CurSysNum).MixTempAtCoolPeak = 20.0; @@ -289,7 +286,8 @@ TEST_F(EnergyPlusFixture, Humidifiers_ThermalEfficiency) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + thisHum.EfficiencyCurvePtr = Curve::GetCurveIndex(*state, "THERMALEFFICIENCYFPLR"); thisHum.CalcGasSteamHumidifier(*state, 0.030); diff --git a/tst/EnergyPlus/unit/HybridModel.unit.cc b/tst/EnergyPlus/unit/HybridModel.unit.cc index 79351f7bf85..937fd3a8097 100644 --- a/tst/EnergyPlus/unit/HybridModel.unit.cc +++ b/tst/EnergyPlus/unit/HybridModel.unit.cc @@ -91,17 +91,16 @@ using namespace EnergyPlus::DataLoopNode; using namespace EnergyPlus::DataSurfaces; using namespace EnergyPlus::DataEnvironment; using namespace EnergyPlus::Psychrometrics; -using namespace EnergyPlus::ScheduleManager; using namespace EnergyPlus::RoomAir; using namespace EnergyPlus::HybridModel; using namespace EnergyPlus::DataPrecisionGlobals; TEST_F(EnergyPlusFixture, HybridModel_correctZoneAirTempsTest) { - + state->init_state(*state); // ZoneTempPredictorCorrector variable initialization state->dataHeatBal->Zone.allocate(1); - state->dataHybridModel->HybridModelZone.allocate(1); + state->dataHybridModel->hybridModelZones.allocate(1); state->dataHybridModel->FlagHybridModel = true; state->dataRoomAir->AirModel.allocate(1); state->dataRoomAir->ZTOC.allocate(1); @@ -117,7 +116,6 @@ TEST_F(EnergyPlusFixture, HybridModel_correctZoneAirTempsTest) state->dataHeatBalFanSys->PreviousMeasuredHumRat1.allocate(1); state->dataHeatBalFanSys->PreviousMeasuredHumRat2.allocate(1); state->dataHeatBalFanSys->PreviousMeasuredHumRat3.allocate(1); - state->dataScheduleMgr->Schedule.allocate(6); // CalcZoneComponentLoadSums variable initialization state->dataSurface->SurfaceWindow.allocate(1); @@ -183,7 +181,7 @@ TEST_F(EnergyPlusFixture, HybridModel_correctZoneAirTempsTest) state->dataHeatBal->Zone(1).Volume = 1061.88; state->dataGlobal->TimeStepZone = 10.0 / 60.0; // Zone timestep in hours state->dataHVACGlobal->TimeStepSys = 10.0 / 60.0; - state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; Real64 ZoneTempChange; @@ -194,16 +192,16 @@ TEST_F(EnergyPlusFixture, HybridModel_correctZoneAirTempsTest) state->dataEnvrn->DayOfYear = 1; // Case 1: Hybrid model internal thermal mass (free-floating) - - state->dataHybridModel->HybridModelZone(1).InternalThermalMassCalc_T = true; - state->dataHybridModel->HybridModelZone(1).InfiltrationCalc_T = false; - state->dataHybridModel->HybridModelZone(1).InfiltrationCalc_H = false; - state->dataHybridModel->HybridModelZone(1).InfiltrationCalc_C = false; - state->dataHybridModel->HybridModelZone(1).PeopleCountCalc_T = false; - state->dataHybridModel->HybridModelZone(1).PeopleCountCalc_H = false; - state->dataHybridModel->HybridModelZone(1).PeopleCountCalc_C = false; - state->dataHybridModel->HybridModelZone(1).HybridStartDayOfYear = 1; - state->dataHybridModel->HybridModelZone(1).HybridEndDayOfYear = 2; + auto &hmZone = state->dataHybridModel->hybridModelZones(1); + hmZone.InternalThermalMassCalc_T = true; + hmZone.InfiltrationCalc_T = false; + hmZone.InfiltrationCalc_H = false; + hmZone.InfiltrationCalc_C = false; + hmZone.PeopleCountCalc_T = false; + hmZone.PeopleCountCalc_H = false; + hmZone.PeopleCountCalc_C = false; + hmZone.HybridStartDayOfYear = 1; + hmZone.HybridEndDayOfYear = 2; thisZoneHB.MAT = 0.0; state->dataHeatBalFanSys->PreviousMeasuredZT1(1) = 0.1; state->dataHeatBalFanSys->PreviousMeasuredZT2(1) = 0.2; @@ -219,15 +217,15 @@ TEST_F(EnergyPlusFixture, HybridModel_correctZoneAirTempsTest) // Case 2: Hybrid model infiltration with measured temperature (free-floating) - state->dataHybridModel->HybridModelZone(1).InternalThermalMassCalc_T = false; - state->dataHybridModel->HybridModelZone(1).InfiltrationCalc_T = true; - state->dataHybridModel->HybridModelZone(1).InfiltrationCalc_H = false; - state->dataHybridModel->HybridModelZone(1).InfiltrationCalc_C = false; - state->dataHybridModel->HybridModelZone(1).PeopleCountCalc_T = false; - state->dataHybridModel->HybridModelZone(1).PeopleCountCalc_H = false; - state->dataHybridModel->HybridModelZone(1).PeopleCountCalc_C = false; - state->dataHybridModel->HybridModelZone(1).HybridStartDayOfYear = 1; - state->dataHybridModel->HybridModelZone(1).HybridEndDayOfYear = 2; + hmZone.InternalThermalMassCalc_T = false; + hmZone.InfiltrationCalc_T = true; + hmZone.InfiltrationCalc_H = false; + hmZone.InfiltrationCalc_C = false; + hmZone.PeopleCountCalc_T = false; + hmZone.PeopleCountCalc_H = false; + hmZone.PeopleCountCalc_C = false; + hmZone.HybridStartDayOfYear = 1; + hmZone.HybridEndDayOfYear = 2; thisZoneHB.MAT = 0.0; state->dataHeatBalFanSys->PreviousMeasuredZT1(1) = 0.02; state->dataHeatBalFanSys->PreviousMeasuredZT2(1) = 0.04; @@ -244,15 +242,15 @@ TEST_F(EnergyPlusFixture, HybridModel_correctZoneAirTempsTest) // Case 3: Hybrid model infiltration with measured humidity ratio (free-floating) - state->dataHybridModel->HybridModelZone(1).InternalThermalMassCalc_T = false; - state->dataHybridModel->HybridModelZone(1).InfiltrationCalc_T = false; - state->dataHybridModel->HybridModelZone(1).InfiltrationCalc_H = true; - state->dataHybridModel->HybridModelZone(1).InfiltrationCalc_C = false; - state->dataHybridModel->HybridModelZone(1).PeopleCountCalc_T = false; - state->dataHybridModel->HybridModelZone(1).PeopleCountCalc_H = false; - state->dataHybridModel->HybridModelZone(1).PeopleCountCalc_C = false; - state->dataHybridModel->HybridModelZone(1).HybridStartDayOfYear = 1; - state->dataHybridModel->HybridModelZone(1).HybridEndDayOfYear = 2; + hmZone.InternalThermalMassCalc_T = false; + hmZone.InfiltrationCalc_T = false; + hmZone.InfiltrationCalc_H = true; + hmZone.InfiltrationCalc_C = false; + hmZone.PeopleCountCalc_T = false; + hmZone.PeopleCountCalc_H = false; + hmZone.PeopleCountCalc_C = false; + hmZone.HybridStartDayOfYear = 1; + hmZone.HybridEndDayOfYear = 2; state->dataHeatBal->Zone(1).Volume = 4000; state->dataHeatBal->Zone(1).OutDryBulbTemp = -10.62; state->dataHeatBal->Zone(1).ZoneVolCapMultpMoist = 1.0; @@ -262,8 +260,8 @@ TEST_F(EnergyPlusFixture, HybridModel_correctZoneAirTempsTest) state->dataHeatBalFanSys->PreviousMeasuredHumRat1(1) = 0.0011186324286; state->dataHeatBalFanSys->PreviousMeasuredHumRat2(1) = 0.0011172070768; state->dataHeatBalFanSys->PreviousMeasuredHumRat3(1) = 0.0011155109625; - state->dataHybridModel->HybridModelZone(1).ZoneMeasuredHumidityRatioSchedulePtr = 1; - state->dataScheduleMgr->Schedule(state->dataHybridModel->HybridModelZone(1).ZoneMeasuredHumidityRatioSchedulePtr).CurrentValue = 0.001120003; + hmZone.measuredHumRatSched = Sched::AddScheduleConstant(*state, "Measured HumRat 1"); + hmZone.measuredHumRatSched->currentVal = 0.001120003; thisZoneHB.MCPV = 539.49; thisZoneHB.MCPTV = 270.10; state->dataEnvrn->OutBaroPress = 99500; @@ -273,15 +271,15 @@ TEST_F(EnergyPlusFixture, HybridModel_correctZoneAirTempsTest) // Case 4: Hybrid model people count with measured temperature (free-floating) - state->dataHybridModel->HybridModelZone(1).InternalThermalMassCalc_T = false; - state->dataHybridModel->HybridModelZone(1).InfiltrationCalc_T = false; - state->dataHybridModel->HybridModelZone(1).InfiltrationCalc_H = false; - state->dataHybridModel->HybridModelZone(1).InfiltrationCalc_C = false; - state->dataHybridModel->HybridModelZone(1).PeopleCountCalc_T = true; - state->dataHybridModel->HybridModelZone(1).PeopleCountCalc_H = false; - state->dataHybridModel->HybridModelZone(1).PeopleCountCalc_C = false; - state->dataHybridModel->HybridModelZone(1).HybridStartDayOfYear = 1; - state->dataHybridModel->HybridModelZone(1).HybridEndDayOfYear = 2; + hmZone.InternalThermalMassCalc_T = false; + hmZone.InfiltrationCalc_T = false; + hmZone.InfiltrationCalc_H = false; + hmZone.InfiltrationCalc_C = false; + hmZone.PeopleCountCalc_T = true; + hmZone.PeopleCountCalc_H = false; + hmZone.PeopleCountCalc_C = false; + hmZone.HybridStartDayOfYear = 1; + hmZone.HybridEndDayOfYear = 2; thisZoneHB.MAT = -2.89; state->dataHeatBalFanSys->PreviousMeasuredZT1(1) = -2.887415174; @@ -293,23 +291,23 @@ TEST_F(EnergyPlusFixture, HybridModel_correctZoneAirTempsTest) state->dataEnvrn->OutBaroPress = 98916.7; thisZoneHB.MCPV = 5163.5; // Assign TempDepCoef thisZoneHB.MCPTV = -15956.8; // Assign TempIndCoef - state->dataHybridModel->HybridModelZone(1).ZoneMeasuredTemperatureSchedulePtr = 1; - state->dataScheduleMgr->Schedule(state->dataHybridModel->HybridModelZone(1).ZoneMeasuredTemperatureSchedulePtr).CurrentValue = -2.923892218; + hmZone.measuredTempSched = Sched::AddScheduleConstant(*state, "Measured Temp 1"); + hmZone.measuredTempSched->currentVal = -2.923892218; ZoneTempChange = correctZoneAirTemps(*state, true); EXPECT_NEAR(0, state->dataHeatBal->Zone(1).NumOccHM, 0.1); // Need to initialize SumIntGain // Case 5: Hybrid model people count with measured humidity ratio (free-floating) - state->dataHybridModel->HybridModelZone(1).InternalThermalMassCalc_T = false; - state->dataHybridModel->HybridModelZone(1).InfiltrationCalc_T = false; - state->dataHybridModel->HybridModelZone(1).InfiltrationCalc_H = false; - state->dataHybridModel->HybridModelZone(1).InfiltrationCalc_C = false; - state->dataHybridModel->HybridModelZone(1).PeopleCountCalc_T = false; - state->dataHybridModel->HybridModelZone(1).PeopleCountCalc_H = true; - state->dataHybridModel->HybridModelZone(1).PeopleCountCalc_C = false; - state->dataHybridModel->HybridModelZone(1).HybridStartDayOfYear = 1; - state->dataHybridModel->HybridModelZone(1).HybridEndDayOfYear = 2; + hmZone.InternalThermalMassCalc_T = false; + hmZone.InfiltrationCalc_T = false; + hmZone.InfiltrationCalc_H = false; + hmZone.InfiltrationCalc_C = false; + hmZone.PeopleCountCalc_T = false; + hmZone.PeopleCountCalc_H = true; + hmZone.PeopleCountCalc_C = false; + hmZone.HybridStartDayOfYear = 1; + hmZone.HybridEndDayOfYear = 2; state->dataHeatBal->Zone(1).Volume = 4000; state->dataHeatBal->Zone(1).OutDryBulbTemp = -10.62; state->dataHeatBal->Zone(1).ZoneVolCapMultpMoist = 1.0; @@ -323,25 +321,24 @@ TEST_F(EnergyPlusFixture, HybridModel_correctZoneAirTempsTest) state->dataHeatBalFanSys->PreviousMeasuredHumRat1(1) = 0.002496356; state->dataHeatBalFanSys->PreviousMeasuredHumRat2(1) = 0.002489048; state->dataHeatBalFanSys->PreviousMeasuredHumRat3(1) = 0.002480404; - state->dataHybridModel->HybridModelZone(1).ZoneMeasuredHumidityRatioSchedulePtr = 1; - state->dataScheduleMgr->Schedule(state->dataHybridModel->HybridModelZone(1).ZoneMeasuredHumidityRatioSchedulePtr).CurrentValue = - 0.002506251487737; + hmZone.measuredHumRatSched = Sched::GetSchedule(*state, "MEASURED HUMRAT 1"); + hmZone.measuredHumRatSched->currentVal = 0.002506251487737; thisZoneHB.correctHumRat(*state, 1); EXPECT_NEAR(4, state->dataHeatBal->Zone(1).NumOccHM, 0.1); // Case 6: Hybrid model infiltration with measured temperature (with HVAC) - state->dataHybridModel->HybridModelZone(1).InternalThermalMassCalc_T = false; - state->dataHybridModel->HybridModelZone(1).InfiltrationCalc_T = true; - state->dataHybridModel->HybridModelZone(1).InfiltrationCalc_H = false; - state->dataHybridModel->HybridModelZone(1).InfiltrationCalc_C = false; - state->dataHybridModel->HybridModelZone(1).PeopleCountCalc_T = false; - state->dataHybridModel->HybridModelZone(1).PeopleCountCalc_H = false; - state->dataHybridModel->HybridModelZone(1).PeopleCountCalc_C = false; - state->dataHybridModel->HybridModelZone(1).IncludeSystemSupplyParameters = true; - state->dataHybridModel->HybridModelZone(1).HybridStartDayOfYear = 1; - state->dataHybridModel->HybridModelZone(1).HybridEndDayOfYear = 2; + hmZone.InternalThermalMassCalc_T = false; + hmZone.InfiltrationCalc_T = true; + hmZone.InfiltrationCalc_H = false; + hmZone.InfiltrationCalc_C = false; + hmZone.PeopleCountCalc_T = false; + hmZone.PeopleCountCalc_H = false; + hmZone.PeopleCountCalc_C = false; + hmZone.IncludeSystemSupplyParameters = true; + hmZone.HybridStartDayOfYear = 1; + hmZone.HybridEndDayOfYear = 2; thisZoneHB.MAT = 15.56; state->dataHeatBalFanSys->PreviousMeasuredZT1(1) = 15.56; state->dataHeatBalFanSys->PreviousMeasuredZT2(1) = 15.56; @@ -353,28 +350,28 @@ TEST_F(EnergyPlusFixture, HybridModel_correctZoneAirTempsTest) thisZoneHB.MCPTV = 60650; // Assign TempIndCoef state->dataEnvrn->OutBaroPress = 99500; state->dataEnvrn->OutHumRat = 0.00113669; - state->dataHybridModel->HybridModelZone(1).ZoneMeasuredTemperatureSchedulePtr = 1; - state->dataHybridModel->HybridModelZone(1).ZoneSupplyAirTemperatureSchedulePtr = 2; - state->dataHybridModel->HybridModelZone(1).ZoneSupplyAirMassFlowRateSchedulePtr = 3; - state->dataScheduleMgr->Schedule(state->dataHybridModel->HybridModelZone(1).ZoneMeasuredTemperatureSchedulePtr).CurrentValue = 15.56; - state->dataScheduleMgr->Schedule(state->dataHybridModel->HybridModelZone(1).ZoneSupplyAirTemperatureSchedulePtr).CurrentValue = 50; - state->dataScheduleMgr->Schedule(state->dataHybridModel->HybridModelZone(1).ZoneSupplyAirMassFlowRateSchedulePtr).CurrentValue = 0.7974274; + hmZone.measuredTempSched = Sched::GetSchedule(*state, "MEASURED TEMP 1"); + hmZone.supplyAirTempSched = Sched::AddScheduleConstant(*state, "Supply Temp 1"); + hmZone.supplyAirMassFlowRateSched = Sched::AddScheduleConstant(*state, "Mass Flow Rate 1"); + hmZone.measuredTempSched->currentVal = 15.56; + hmZone.supplyAirTempSched->currentVal = 50; + hmZone.supplyAirMassFlowRateSched->currentVal = 0.7974274; ZoneTempChange = correctZoneAirTemps(*state, true); EXPECT_NEAR(0.49, state->dataHeatBal->Zone(1).InfilOAAirChangeRateHM, 0.01); // Case 7: Hybrid model infiltration with measured humidity ratio (with HVAC) - state->dataHybridModel->HybridModelZone(1).InternalThermalMassCalc_T = false; - state->dataHybridModel->HybridModelZone(1).InfiltrationCalc_T = false; - state->dataHybridModel->HybridModelZone(1).InfiltrationCalc_H = true; - state->dataHybridModel->HybridModelZone(1).InfiltrationCalc_C = false; - state->dataHybridModel->HybridModelZone(1).PeopleCountCalc_T = false; - state->dataHybridModel->HybridModelZone(1).PeopleCountCalc_H = false; - state->dataHybridModel->HybridModelZone(1).PeopleCountCalc_C = false; - state->dataHybridModel->HybridModelZone(1).IncludeSystemSupplyParameters = true; - state->dataHybridModel->HybridModelZone(1).HybridStartDayOfYear = 1; - state->dataHybridModel->HybridModelZone(1).HybridEndDayOfYear = 2; + hmZone.InternalThermalMassCalc_T = false; + hmZone.InfiltrationCalc_T = false; + hmZone.InfiltrationCalc_H = true; + hmZone.InfiltrationCalc_C = false; + hmZone.PeopleCountCalc_T = false; + hmZone.PeopleCountCalc_H = false; + hmZone.PeopleCountCalc_C = false; + hmZone.IncludeSystemSupplyParameters = true; + hmZone.HybridStartDayOfYear = 1; + hmZone.HybridEndDayOfYear = 2; state->dataHeatBal->Zone(1).Volume = 4000; state->dataHeatBal->Zone(1).OutDryBulbTemp = -10.62; state->dataHeatBal->Zone(1).ZoneVolCapMultpMoist = 1.0; @@ -384,12 +381,12 @@ TEST_F(EnergyPlusFixture, HybridModel_correctZoneAirTempsTest) state->dataHeatBalFanSys->PreviousMeasuredHumRat1(1) = 0.007855718; state->dataHeatBalFanSys->PreviousMeasuredHumRat2(1) = 0.007852847; state->dataHeatBalFanSys->PreviousMeasuredHumRat3(1) = 0.007850236; - state->dataHybridModel->HybridModelZone(1).ZoneMeasuredHumidityRatioSchedulePtr = 1; - state->dataHybridModel->HybridModelZone(1).ZoneSupplyAirHumidityRatioSchedulePtr = 2; - state->dataHybridModel->HybridModelZone(1).ZoneSupplyAirMassFlowRateSchedulePtr = 3; - state->dataScheduleMgr->Schedule(state->dataHybridModel->HybridModelZone(1).ZoneMeasuredHumidityRatioSchedulePtr).CurrentValue = 0.00792; - state->dataScheduleMgr->Schedule(state->dataHybridModel->HybridModelZone(1).ZoneSupplyAirHumidityRatioSchedulePtr).CurrentValue = 0.015; - state->dataScheduleMgr->Schedule(state->dataHybridModel->HybridModelZone(1).ZoneSupplyAirMassFlowRateSchedulePtr).CurrentValue = 0.8345; + hmZone.measuredHumRatSched = Sched::GetSchedule(*state, "MEASURED HUMRAT 1"); + hmZone.supplyAirHumRatSched = Sched::AddScheduleConstant(*state, "Supply HumRat 1"); + hmZone.supplyAirMassFlowRateSched = Sched::AddScheduleConstant(*state, "Supply Mass Flow Rate 1"); + hmZone.measuredHumRatSched->currentVal = 0.00792; + hmZone.supplyAirHumRatSched->currentVal = 0.015; + hmZone.supplyAirMassFlowRateSched->currentVal = 0.8345; state->dataEnvrn->OutBaroPress = 99500; thisZoneHB.correctHumRat(*state, 1); @@ -397,16 +394,16 @@ TEST_F(EnergyPlusFixture, HybridModel_correctZoneAirTempsTest) // Case 8: Hybrid model people count with measured temperature (with HVAC) - state->dataHybridModel->HybridModelZone(1).InternalThermalMassCalc_T = false; - state->dataHybridModel->HybridModelZone(1).InfiltrationCalc_T = false; - state->dataHybridModel->HybridModelZone(1).InfiltrationCalc_H = false; - state->dataHybridModel->HybridModelZone(1).InfiltrationCalc_C = false; - state->dataHybridModel->HybridModelZone(1).PeopleCountCalc_T = true; - state->dataHybridModel->HybridModelZone(1).PeopleCountCalc_H = false; - state->dataHybridModel->HybridModelZone(1).PeopleCountCalc_C = false; - state->dataHybridModel->HybridModelZone(1).IncludeSystemSupplyParameters = true; - state->dataHybridModel->HybridModelZone(1).HybridStartDayOfYear = 1; - state->dataHybridModel->HybridModelZone(1).HybridEndDayOfYear = 2; + hmZone.InternalThermalMassCalc_T = false; + hmZone.InfiltrationCalc_T = false; + hmZone.InfiltrationCalc_H = false; + hmZone.InfiltrationCalc_C = false; + hmZone.PeopleCountCalc_T = true; + hmZone.PeopleCountCalc_H = false; + hmZone.PeopleCountCalc_C = false; + hmZone.IncludeSystemSupplyParameters = true; + hmZone.HybridStartDayOfYear = 1; + hmZone.HybridEndDayOfYear = 2; thisZoneHB.MAT = -2.89; state->dataHeatBalFanSys->PreviousMeasuredZT1(1) = 21.11; state->dataHeatBalFanSys->PreviousMeasuredZT2(1) = 21.11; @@ -417,33 +414,33 @@ TEST_F(EnergyPlusFixture, HybridModel_correctZoneAirTempsTest) state->dataEnvrn->OutBaroPress = 98916.7; thisZoneHB.MCPV = 6616; // Assign TempDepCoef thisZoneHB.MCPTV = 138483.2; // Assign TempIndCoef - state->dataHybridModel->HybridModelZone(1).ZoneMeasuredTemperatureSchedulePtr = 1; - state->dataHybridModel->HybridModelZone(1).ZoneSupplyAirTemperatureSchedulePtr = 2; - state->dataHybridModel->HybridModelZone(1).ZoneSupplyAirMassFlowRateSchedulePtr = 3; - state->dataHybridModel->HybridModelZone(1).ZonePeopleActivityLevelSchedulePtr = 4; - state->dataHybridModel->HybridModelZone(1).ZonePeopleSensibleFractionSchedulePtr = 5; - state->dataHybridModel->HybridModelZone(1).ZonePeopleRadiationFractionSchedulePtr = 6; - state->dataScheduleMgr->Schedule(state->dataHybridModel->HybridModelZone(1).ZoneMeasuredTemperatureSchedulePtr).CurrentValue = 21.11; - state->dataScheduleMgr->Schedule(state->dataHybridModel->HybridModelZone(1).ZoneSupplyAirTemperatureSchedulePtr).CurrentValue = 50; - state->dataScheduleMgr->Schedule(state->dataHybridModel->HybridModelZone(1).ZoneSupplyAirMassFlowRateSchedulePtr).CurrentValue = 1.446145794; - state->dataScheduleMgr->Schedule(state->dataHybridModel->HybridModelZone(1).ZonePeopleActivityLevelSchedulePtr).CurrentValue = 120; - state->dataScheduleMgr->Schedule(state->dataHybridModel->HybridModelZone(1).ZonePeopleSensibleFractionSchedulePtr).CurrentValue = 0.6; - state->dataScheduleMgr->Schedule(state->dataHybridModel->HybridModelZone(1).ZonePeopleRadiationFractionSchedulePtr).CurrentValue = 0.3; + hmZone.measuredTempSched = Sched::GetSchedule(*state, "MEASURED TEMP 1"); + hmZone.supplyAirTempSched = Sched::GetSchedule(*state, "SUPPLY TEMP 1"); + hmZone.supplyAirMassFlowRateSched = Sched::GetSchedule(*state, "SUPPLY MASS FLOW RATE 1"); + hmZone.peopleActivityLevelSched = Sched::AddScheduleConstant(*state, "People Activity Level 1"); + hmZone.peopleSensibleFracSched = Sched::AddScheduleConstant(*state, "People Sensible Fraction 1"); + hmZone.peopleRadiantFracSched = Sched::AddScheduleConstant(*state, "People Radiation Fraction 1"); + hmZone.measuredTempSched->currentVal = 21.11; + hmZone.supplyAirTempSched->currentVal = 50; + hmZone.supplyAirMassFlowRateSched->currentVal = 1.446145794; + hmZone.peopleActivityLevelSched->currentVal = 120; + hmZone.peopleSensibleFracSched->currentVal = 0.6; + hmZone.peopleRadiantFracSched->currentVal = 0.3; ZoneTempChange = correctZoneAirTemps(*state, true); EXPECT_NEAR(0, state->dataHeatBal->Zone(1).NumOccHM, 0.1); // Need to initialize SumIntGain // Case 9: Hybrid model people count with measured humidity ratio (with HVAC) - state->dataHybridModel->HybridModelZone(1).InternalThermalMassCalc_T = false; - state->dataHybridModel->HybridModelZone(1).InfiltrationCalc_T = false; - state->dataHybridModel->HybridModelZone(1).InfiltrationCalc_H = false; - state->dataHybridModel->HybridModelZone(1).InfiltrationCalc_C = false; - state->dataHybridModel->HybridModelZone(1).PeopleCountCalc_T = false; - state->dataHybridModel->HybridModelZone(1).PeopleCountCalc_H = true; - state->dataHybridModel->HybridModelZone(1).PeopleCountCalc_C = false; - state->dataHybridModel->HybridModelZone(1).IncludeSystemSupplyParameters = true; - state->dataHybridModel->HybridModelZone(1).HybridStartDayOfYear = 1; - state->dataHybridModel->HybridModelZone(1).HybridEndDayOfYear = 2; + hmZone.InternalThermalMassCalc_T = false; + hmZone.InfiltrationCalc_T = false; + hmZone.InfiltrationCalc_H = false; + hmZone.InfiltrationCalc_C = false; + hmZone.PeopleCountCalc_T = false; + hmZone.PeopleCountCalc_H = true; + hmZone.PeopleCountCalc_C = false; + hmZone.IncludeSystemSupplyParameters = true; + hmZone.HybridStartDayOfYear = 1; + hmZone.HybridEndDayOfYear = 2; state->dataHeatBal->Zone(1).Volume = 4000; state->dataHeatBal->Zone(1).OutDryBulbTemp = -10.62; state->dataHeatBal->Zone(1).ZoneVolCapMultpMoist = 1.0; @@ -453,18 +450,18 @@ TEST_F(EnergyPlusFixture, HybridModel_correctZoneAirTempsTest) state->dataHeatBalFanSys->PreviousMeasuredHumRat1(1) = 0.011085257; state->dataHeatBalFanSys->PreviousMeasuredHumRat2(1) = 0.011084959; state->dataHeatBalFanSys->PreviousMeasuredHumRat3(1) = 0.011072322; - state->dataHybridModel->HybridModelZone(1).ZoneMeasuredHumidityRatioSchedulePtr = 1; - state->dataHybridModel->HybridModelZone(1).ZoneSupplyAirHumidityRatioSchedulePtr = 2; - state->dataHybridModel->HybridModelZone(1).ZoneSupplyAirMassFlowRateSchedulePtr = 3; - state->dataHybridModel->HybridModelZone(1).ZonePeopleActivityLevelSchedulePtr = 4; - state->dataHybridModel->HybridModelZone(1).ZonePeopleSensibleFractionSchedulePtr = 5; - state->dataHybridModel->HybridModelZone(1).ZonePeopleRadiationFractionSchedulePtr = 6; - state->dataScheduleMgr->Schedule(state->dataHybridModel->HybridModelZone(1).ZoneMeasuredHumidityRatioSchedulePtr).CurrentValue = 0.01107774; - state->dataScheduleMgr->Schedule(state->dataHybridModel->HybridModelZone(1).ZoneSupplyAirHumidityRatioSchedulePtr).CurrentValue = 0.015; - state->dataScheduleMgr->Schedule(state->dataHybridModel->HybridModelZone(1).ZoneSupplyAirMassFlowRateSchedulePtr).CurrentValue = 1.485334886; - state->dataScheduleMgr->Schedule(state->dataHybridModel->HybridModelZone(1).ZonePeopleActivityLevelSchedulePtr).CurrentValue = 120; - state->dataScheduleMgr->Schedule(state->dataHybridModel->HybridModelZone(1).ZonePeopleSensibleFractionSchedulePtr).CurrentValue = 0.6; - state->dataScheduleMgr->Schedule(state->dataHybridModel->HybridModelZone(1).ZonePeopleRadiationFractionSchedulePtr).CurrentValue = 0.3; + hmZone.measuredHumRatSched = Sched::GetSchedule(*state, "MEASURED HUMRAT 1"); + hmZone.supplyAirHumRatSched = Sched::GetSchedule(*state, "SUPPLY HUMRAT 1"); + hmZone.supplyAirMassFlowRateSched = Sched::GetSchedule(*state, "SUPPLY MASS FLOW RATE 1"); + hmZone.peopleActivityLevelSched = Sched::GetSchedule(*state, "PEOPLE ACTIVITY LEVEL 1"); + hmZone.peopleSensibleFracSched = Sched::GetSchedule(*state, "PEOPLE SENSIBLE FRACTION 1"); + hmZone.peopleRadiantFracSched = Sched::GetSchedule(*state, "PEOPLE RADIATION FRACTION 1"); + hmZone.measuredHumRatSched->currentVal = 0.01107774; + hmZone.supplyAirHumRatSched->currentVal = 0.015; + hmZone.supplyAirMassFlowRateSched->currentVal = 1.485334886; + hmZone.peopleActivityLevelSched->currentVal = 120; + hmZone.peopleSensibleFracSched->currentVal = 0.6; + hmZone.peopleRadiantFracSched->currentVal = 0.3; state->dataEnvrn->OutBaroPress = 99500; thisZoneHB.correctHumRat(*state, 1); @@ -473,10 +470,11 @@ TEST_F(EnergyPlusFixture, HybridModel_correctZoneAirTempsTest) TEST_F(EnergyPlusFixture, HybridModel_CorrectZoneContaminantsTest) { - + state->init_state(*state); // ZoneContaminantPredictorCorrector variable initialization state->dataHeatBal->Zone.allocate(1); - state->dataHybridModel->HybridModelZone.allocate(1); + state->dataHybridModel->hybridModelZones.allocate(1); + state->dataHybridModel->FlagHybridModel = true; state->dataRoomAir->AirModel.allocate(1); state->dataRoomAir->ZTOC.allocate(1); @@ -493,7 +491,6 @@ TEST_F(EnergyPlusFixture, HybridModel_CorrectZoneContaminantsTest) state->dataContaminantBalance->CO2ZoneTimeMinus1.allocate(1); state->dataContaminantBalance->CO2ZoneTimeMinus2.allocate(1); state->dataContaminantBalance->CO2ZoneTimeMinus3.allocate(1); - state->dataScheduleMgr->Schedule.allocate(7); // CalcZoneComponentLoadSums variable initialization state->dataSurface->SurfaceWindow.allocate(1); @@ -511,6 +508,8 @@ TEST_F(EnergyPlusFixture, HybridModel_CorrectZoneContaminantsTest) state->dataZoneTempPredictorCorrector->zoneHeatBalance.allocate(1); state->dataZoneTempPredictorCorrector->spaceHeatBalance.allocate(1); auto &thisZoneHB = state->dataZoneTempPredictorCorrector->zoneHeatBalance(1); + auto &hmZone = state->dataHybridModel->hybridModelZones(1); + thisZoneHB.MixingMassFlowZone = 0.0; thisZoneHB.ZT = 0.0; state->dataContaminantBalance->AZ.allocate(1); @@ -556,7 +555,7 @@ TEST_F(EnergyPlusFixture, HybridModel_CorrectZoneContaminantsTest) state->dataHeatBal->Zone(1).Volume = 4000; state->dataGlobal->TimeStepZone = 10.0 / 60.0; // Zone timestep in hours state->dataHVACGlobal->TimeStepSys = 10.0 / 60.0; - state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; // Hybrid modeling trigger state->dataHybridModel->FlagHybridModel_TM = false; @@ -567,15 +566,15 @@ TEST_F(EnergyPlusFixture, HybridModel_CorrectZoneContaminantsTest) // Case 1: Hybrid model infiltration with measured CO2 concentration (free-floating) state->dataContaminantBalance->Contaminant.CO2Simulation = true; - state->dataHybridModel->HybridModelZone(1).InternalThermalMassCalc_T = false; - state->dataHybridModel->HybridModelZone(1).InfiltrationCalc_T = false; - state->dataHybridModel->HybridModelZone(1).InfiltrationCalc_H = false; - state->dataHybridModel->HybridModelZone(1).InfiltrationCalc_C = true; - state->dataHybridModel->HybridModelZone(1).PeopleCountCalc_T = false; - state->dataHybridModel->HybridModelZone(1).PeopleCountCalc_H = false; - state->dataHybridModel->HybridModelZone(1).PeopleCountCalc_C = false; - state->dataHybridModel->HybridModelZone(1).HybridStartDayOfYear = 1; - state->dataHybridModel->HybridModelZone(1).HybridEndDayOfYear = 2; + hmZone.InternalThermalMassCalc_T = false; + hmZone.InfiltrationCalc_T = false; + hmZone.InfiltrationCalc_H = false; + hmZone.InfiltrationCalc_C = true; + hmZone.PeopleCountCalc_T = false; + hmZone.PeopleCountCalc_H = false; + hmZone.PeopleCountCalc_C = false; + hmZone.HybridStartDayOfYear = 1; + hmZone.HybridEndDayOfYear = 2; state->dataHeatBal->Zone(1).ZoneVolCapMultpCO2 = 1.0; thisZoneHB.airHumRat = 0.001120003; state->dataContaminantBalance->OutdoorCO2 = 387.6064554; @@ -584,8 +583,8 @@ TEST_F(EnergyPlusFixture, HybridModel_CorrectZoneContaminantsTest) state->dataContaminantBalance->CO2ZoneTimeMinus1(1) = 388.595225; state->dataContaminantBalance->CO2ZoneTimeMinus2(1) = 389.084601; state->dataContaminantBalance->CO2ZoneTimeMinus3(1) = 388.997009; - state->dataHybridModel->HybridModelZone(1).ZoneMeasuredCO2ConcentrationSchedulePtr = 1; - state->dataScheduleMgr->Schedule(state->dataHybridModel->HybridModelZone(1).ZoneMeasuredCO2ConcentrationSchedulePtr).CurrentValue = 388.238646; + hmZone.measuredCO2ConcSched = Sched::AddScheduleConstant(*state, "Measured CO2"); + hmZone.measuredCO2ConcSched->currentVal = 388.238646; CorrectZoneContaminants(*state, true); EXPECT_NEAR(0.5, state->dataHeatBal->Zone(1).InfilOAAirChangeRateHM, 0.01); @@ -593,15 +592,15 @@ TEST_F(EnergyPlusFixture, HybridModel_CorrectZoneContaminantsTest) // Case 2: Hybrid model people count with measured CO2 concentration (free-floating) state->dataContaminantBalance->Contaminant.CO2Simulation = true; - state->dataHybridModel->HybridModelZone(1).InternalThermalMassCalc_T = false; - state->dataHybridModel->HybridModelZone(1).InfiltrationCalc_T = false; - state->dataHybridModel->HybridModelZone(1).InfiltrationCalc_H = false; - state->dataHybridModel->HybridModelZone(1).InfiltrationCalc_C = false; - state->dataHybridModel->HybridModelZone(1).PeopleCountCalc_T = false; - state->dataHybridModel->HybridModelZone(1).PeopleCountCalc_H = false; - state->dataHybridModel->HybridModelZone(1).PeopleCountCalc_C = true; - state->dataHybridModel->HybridModelZone(1).HybridStartDayOfYear = 1; - state->dataHybridModel->HybridModelZone(1).HybridEndDayOfYear = 2; + hmZone.InternalThermalMassCalc_T = false; + hmZone.InfiltrationCalc_T = false; + hmZone.InfiltrationCalc_H = false; + hmZone.InfiltrationCalc_C = false; + hmZone.PeopleCountCalc_T = false; + hmZone.PeopleCountCalc_H = false; + hmZone.PeopleCountCalc_C = true; + hmZone.HybridStartDayOfYear = 1; + hmZone.HybridEndDayOfYear = 2; state->dataHeatBal->Zone(1).Volume = 4000; state->dataHeatBal->Zone(1).ZoneVolCapMultpCO2 = 1.0; state->dataHeatBal->Zone(1).OutDryBulbTemp = -1.0394166434012677; @@ -614,23 +613,23 @@ TEST_F(EnergyPlusFixture, HybridModel_CorrectZoneContaminantsTest) state->dataContaminantBalance->CO2ZoneTimeMinus1(1) = 387.9962885; state->dataContaminantBalance->CO2ZoneTimeMinus2(1) = 387.676037; state->dataContaminantBalance->CO2ZoneTimeMinus3(1) = 387.2385685; - state->dataHybridModel->HybridModelZone(1).ZoneMeasuredCO2ConcentrationSchedulePtr = 1; - state->dataScheduleMgr->Schedule(state->dataHybridModel->HybridModelZone(1).ZoneMeasuredCO2ConcentrationSchedulePtr).CurrentValue = 389.8511796; + hmZone.measuredCO2ConcSched = Sched::AddScheduleConstant(*state, "Measured CO2"); + hmZone.measuredCO2ConcSched->currentVal = 389.8511796; CorrectZoneContaminants(*state, true); EXPECT_NEAR(4, state->dataHeatBal->Zone(1).NumOccHM, 0.1); // Case 3: Hybrid model infiltration with measured CO2 concentration (with HVAC) state->dataContaminantBalance->Contaminant.CO2Simulation = true; - state->dataHybridModel->HybridModelZone(1).InternalThermalMassCalc_T = false; - state->dataHybridModel->HybridModelZone(1).InfiltrationCalc_T = false; - state->dataHybridModel->HybridModelZone(1).InfiltrationCalc_H = false; - state->dataHybridModel->HybridModelZone(1).InfiltrationCalc_C = true; - state->dataHybridModel->HybridModelZone(1).PeopleCountCalc_T = false; - state->dataHybridModel->HybridModelZone(1).PeopleCountCalc_H = false; - state->dataHybridModel->HybridModelZone(1).PeopleCountCalc_C = false; - state->dataHybridModel->HybridModelZone(1).IncludeSystemSupplyParameters = true; - state->dataHybridModel->HybridModelZone(1).HybridStartDayOfYear = 1; - state->dataHybridModel->HybridModelZone(1).HybridEndDayOfYear = 2; + hmZone.InternalThermalMassCalc_T = false; + hmZone.InfiltrationCalc_T = false; + hmZone.InfiltrationCalc_H = false; + hmZone.InfiltrationCalc_C = true; + hmZone.PeopleCountCalc_T = false; + hmZone.PeopleCountCalc_H = false; + hmZone.PeopleCountCalc_C = false; + hmZone.IncludeSystemSupplyParameters = true; + hmZone.HybridStartDayOfYear = 1; + hmZone.HybridEndDayOfYear = 2; state->dataHeatBal->Zone(1).ZoneVolCapMultpCO2 = 1.0; thisZoneHB.ZT = 15.56; thisZoneHB.airHumRat = 0.00809; @@ -640,12 +639,12 @@ TEST_F(EnergyPlusFixture, HybridModel_CorrectZoneContaminantsTest) state->dataContaminantBalance->CO2ZoneTimeMinus1(1) = 388.54049; state->dataContaminantBalance->CO2ZoneTimeMinus2(1) = 389.0198771; state->dataContaminantBalance->CO2ZoneTimeMinus3(1) = 388.9201464; - state->dataHybridModel->HybridModelZone(1).ZoneMeasuredCO2ConcentrationSchedulePtr = 1; - state->dataHybridModel->HybridModelZone(1).ZoneSupplyAirCO2ConcentrationSchedulePtr = 2; - state->dataHybridModel->HybridModelZone(1).ZoneSupplyAirMassFlowRateSchedulePtr = 3; - state->dataScheduleMgr->Schedule(state->dataHybridModel->HybridModelZone(1).ZoneMeasuredCO2ConcentrationSchedulePtr).CurrentValue = 388.2075472; - state->dataScheduleMgr->Schedule(state->dataHybridModel->HybridModelZone(1).ZoneSupplyAirCO2ConcentrationSchedulePtr).CurrentValue = 388.54049; - state->dataScheduleMgr->Schedule(state->dataHybridModel->HybridModelZone(1).ZoneSupplyAirMassFlowRateSchedulePtr).CurrentValue = 0.898375186; + hmZone.measuredCO2ConcSched = Sched::GetSchedule(*state, "MEASURED CO2"); + hmZone.supplyAirCO2ConcSched = Sched::AddScheduleConstant(*state, "Supply CO2"); + hmZone.supplyAirMassFlowRateSched = Sched::AddScheduleConstant(*state, "Supply Mass Flow Rate"); + hmZone.measuredCO2ConcSched->currentVal = 388.2075472; + hmZone.supplyAirCO2ConcSched->currentVal = 388.54049; + hmZone.supplyAirMassFlowRateSched->currentVal = 0.898375186; CorrectZoneContaminants(*state, true); EXPECT_NEAR(0.5, state->dataHeatBal->Zone(1).InfilOAAirChangeRateHM, 0.01); @@ -653,16 +652,16 @@ TEST_F(EnergyPlusFixture, HybridModel_CorrectZoneContaminantsTest) // Case 4: Hybrid model people count with measured CO2 concentration (with HVAC) state->dataContaminantBalance->Contaminant.CO2Simulation = true; - state->dataHybridModel->HybridModelZone(1).InternalThermalMassCalc_T = false; - state->dataHybridModel->HybridModelZone(1).InfiltrationCalc_T = false; - state->dataHybridModel->HybridModelZone(1).InfiltrationCalc_H = false; - state->dataHybridModel->HybridModelZone(1).InfiltrationCalc_C = false; - state->dataHybridModel->HybridModelZone(1).PeopleCountCalc_T = false; - state->dataHybridModel->HybridModelZone(1).PeopleCountCalc_H = false; - state->dataHybridModel->HybridModelZone(1).PeopleCountCalc_C = true; - state->dataHybridModel->HybridModelZone(1).IncludeSystemSupplyParameters = true; - state->dataHybridModel->HybridModelZone(1).HybridStartDayOfYear = 1; - state->dataHybridModel->HybridModelZone(1).HybridEndDayOfYear = 2; + hmZone.InternalThermalMassCalc_T = false; + hmZone.InfiltrationCalc_T = false; + hmZone.InfiltrationCalc_H = false; + hmZone.InfiltrationCalc_C = false; + hmZone.PeopleCountCalc_T = false; + hmZone.PeopleCountCalc_H = false; + hmZone.PeopleCountCalc_C = true; + hmZone.IncludeSystemSupplyParameters = true; + hmZone.HybridStartDayOfYear = 1; + hmZone.HybridEndDayOfYear = 2; state->dataHeatBal->Zone(1).ZoneVolCapMultpCO2 = 1.0; thisZoneHB.ZT = 21.1; thisZoneHB.airHumRat = 0.01102; @@ -672,20 +671,20 @@ TEST_F(EnergyPlusFixture, HybridModel_CorrectZoneContaminantsTest) state->dataContaminantBalance->CO2ZoneTimeMinus1(1) = 387.2253194; state->dataContaminantBalance->CO2ZoneTimeMinus2(1) = 387.1898423; state->dataContaminantBalance->CO2ZoneTimeMinus3(1) = 387.4064128; - state->dataHybridModel->HybridModelZone(1).ZoneMeasuredCO2ConcentrationSchedulePtr = 1; - state->dataHybridModel->HybridModelZone(1).ZoneSupplyAirCO2ConcentrationSchedulePtr = 2; - state->dataHybridModel->HybridModelZone(1).ZoneSupplyAirMassFlowRateSchedulePtr = 3; - state->dataHybridModel->HybridModelZone(1).ZonePeopleActivityLevelSchedulePtr = 4; - state->dataHybridModel->HybridModelZone(1).ZonePeopleSensibleFractionSchedulePtr = 5; - state->dataHybridModel->HybridModelZone(1).ZonePeopleRadiationFractionSchedulePtr = 6; - state->dataHybridModel->HybridModelZone(1).ZonePeopleCO2GenRateSchedulePtr = 7; - state->dataScheduleMgr->Schedule(state->dataHybridModel->HybridModelZone(1).ZoneMeasuredCO2ConcentrationSchedulePtr).CurrentValue = 389.795807; - state->dataScheduleMgr->Schedule(state->dataHybridModel->HybridModelZone(1).ZoneSupplyAirCO2ConcentrationSchedulePtr).CurrentValue = 387.2253194; - state->dataScheduleMgr->Schedule(state->dataHybridModel->HybridModelZone(1).ZoneSupplyAirMassFlowRateSchedulePtr).CurrentValue = 1.427583795; - state->dataScheduleMgr->Schedule(state->dataHybridModel->HybridModelZone(1).ZonePeopleActivityLevelSchedulePtr).CurrentValue = 120; - state->dataScheduleMgr->Schedule(state->dataHybridModel->HybridModelZone(1).ZonePeopleSensibleFractionSchedulePtr).CurrentValue = 0.6; - state->dataScheduleMgr->Schedule(state->dataHybridModel->HybridModelZone(1).ZonePeopleRadiationFractionSchedulePtr).CurrentValue = 0.3; - state->dataScheduleMgr->Schedule(state->dataHybridModel->HybridModelZone(1).ZonePeopleCO2GenRateSchedulePtr).CurrentValue = 0.0000000382; + hmZone.measuredCO2ConcSched = Sched::GetSchedule(*state, "MEASURED CO2"); + hmZone.supplyAirCO2ConcSched = Sched::GetSchedule(*state, "SUPPLY CO2"); + hmZone.supplyAirMassFlowRateSched = Sched::GetSchedule(*state, "SUPPLY MASS FLOW RATE"); + hmZone.peopleActivityLevelSched = Sched::AddScheduleConstant(*state, "People Activity Level"); + hmZone.peopleSensibleFracSched = Sched::AddScheduleConstant(*state, "People Sensible Fraction"); + hmZone.peopleRadiantFracSched = Sched::AddScheduleConstant(*state, "People Radiation Fraction"); + hmZone.peopleCO2GenRateSched = Sched::AddScheduleConstant(*state, "People CO2 Gen Rate"); + hmZone.measuredCO2ConcSched->currentVal = 389.795807; + hmZone.supplyAirCO2ConcSched->currentVal = 387.2253194; + hmZone.supplyAirMassFlowRateSched->currentVal = 1.427583795; + hmZone.peopleActivityLevelSched->currentVal = 120; + hmZone.peopleSensibleFracSched->currentVal = 0.6; + hmZone.peopleRadiantFracSched->currentVal = 0.3; + hmZone.peopleCO2GenRateSched->currentVal = 0.0000000382; CorrectZoneContaminants(*state, true); EXPECT_NEAR(7.27, state->dataHeatBal->Zone(1).NumOccHM, 0.1); diff --git a/tst/EnergyPlus/unit/ICSCollector.unit.cc b/tst/EnergyPlus/unit/ICSCollector.unit.cc index 4087613f8a1..3b258312454 100644 --- a/tst/EnergyPlus/unit/ICSCollector.unit.cc +++ b/tst/EnergyPlus/unit/ICSCollector.unit.cc @@ -84,7 +84,7 @@ TEST_F(EnergyPlusFixture, ICSSolarCollectorTest_CalcPassiveExteriorBaffleGapTest int ConstrNum; int MatNum; - InitializePsychRoutines(*state); + state->init_state(*state); state->dataGlobal->BeginEnvrnFlag = true; state->dataEnvrn->OutBaroPress = 101325.0; diff --git a/tst/EnergyPlus/unit/IndoorGreen.unit.cc b/tst/EnergyPlus/unit/IndoorGreen.unit.cc index d978512846c..d73fb05dfdf 100644 --- a/tst/EnergyPlus/unit/IndoorGreen.unit.cc +++ b/tst/EnergyPlus/unit/IndoorGreen.unit.cc @@ -165,7 +165,8 @@ TEST_F(EnergyPlusFixture, IndoorGreen_CheckGetInputDataFunction) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + Material::GetMaterialData(*state, ErrorsFound); EXPECT_FALSE(ErrorsFound); @@ -177,8 +178,8 @@ TEST_F(EnergyPlusFixture, IndoorGreen_CheckGetInputDataFunction) state->dataSurfaceGeometry->CosZoneRelNorth.allocate(1); state->dataSurfaceGeometry->SinZoneRelNorth.allocate(1); - state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); - state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); + state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); + state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); state->dataSurfaceGeometry->CosBldgRelNorth = 1.0; state->dataSurfaceGeometry->SinBldgRelNorth = 0.0; @@ -186,15 +187,15 @@ TEST_F(EnergyPlusFixture, IndoorGreen_CheckGetInputDataFunction) EXPECT_FALSE(ErrorsFound); state->dataHVACGlobal->TimeStepSys = 1; - state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; - state->dataGlobal->NumOfTimeStepInHour = 1; - state->dataGlobal->MinutesPerTimeStep = 60 / state->dataGlobal->NumOfTimeStepInHour; + state->dataGlobal->TimeStepsInHour = 1; + state->dataGlobal->MinutesInTimeStep = 60 / state->dataGlobal->TimeStepsInHour; state->dataGlobal->TimeStep = 1; state->dataGlobal->HourOfDay = 1; state->dataEnvrn->DayOfWeek = 1; state->dataEnvrn->DayOfYear_Schedule = 1; - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); IndoorGreen::GetIndoorGreenInput(*state, ErrorsFound); // setup indoor living wall data EXPECT_FALSE(ErrorsFound); // expect no errors diff --git a/tst/EnergyPlus/unit/InternalHeatGains.unit.cc b/tst/EnergyPlus/unit/InternalHeatGains.unit.cc index d44e21eaff8..cb0de92fd44 100644 --- a/tst/EnergyPlus/unit/InternalHeatGains.unit.cc +++ b/tst/EnergyPlus/unit/InternalHeatGains.unit.cc @@ -114,11 +114,11 @@ TEST_F(EnergyPlusFixture, InternalHeatGains_OtherEquipment_CheckFuelType) ASSERT_TRUE(process_idf(idf_objects)); EXPECT_FALSE(has_err_output()); - bool ErrorsFound(false); + state->dataGlobal->TimeStepsInHour = 1; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 60; // must initialize this to get schedules initialized + state->init_state(*state); - state->dataGlobal->NumOfTimeStepInHour = 1; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 60; // must initialize this to get schedules initialized - ScheduleManager::ProcessScheduleInput(*state); // read schedules + bool ErrorsFound(false); HeatBalanceManager::GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); @@ -163,11 +163,11 @@ TEST_F(EnergyPlusFixture, InternalHeatGains_OtherEquipment_NegativeDesignLevel) ASSERT_TRUE(process_idf(idf_objects)); EXPECT_FALSE(has_err_output()); - bool ErrorsFound(false); + state->dataGlobal->TimeStepsInHour = 1; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 60; // must initialize this to get schedules initialized + state->init_state(*state); - state->dataGlobal->NumOfTimeStepInHour = 1; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 60; // must initialize this to get schedules initialized - ScheduleManager::ProcessScheduleInput(*state); // read schedules + bool ErrorsFound(false); HeatBalanceManager::GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); @@ -175,8 +175,7 @@ TEST_F(EnergyPlusFixture, InternalHeatGains_OtherEquipment_NegativeDesignLevel) ASSERT_THROW(InternalHeatGains::GetInternalHeatGainsInput(*state), std::runtime_error); std::string const error_string = delimited_string( - {" ** Warning ** ProcessScheduleInput: Schedule:Constant=\"SCHEDULE1\", Blank Schedule Type Limits Name input -- will not be validated.", - " ** Severe ** GetInternalHeatGains: OtherEquipment=\"OTHEREQ1\", Design Level is not allowed to be negative", + {" ** Severe ** GetInternalHeatGains: OtherEquipment=\"OTHEREQ1\", Design Level is not allowed to be negative", " ** ~~~ ** ... when a fuel type of FuelOilNo1 is specified.", " ** Fatal ** GetInternalHeatGains: Errors found in Getting Internal Gains Input, Program Stopped", " ...Summary of Errors that led to program termination:", @@ -212,15 +211,16 @@ TEST_F(EnergyPlusFixture, InternalHeatGains_OtherEquipment_BadFuelType) ASSERT_FALSE(process_idf(idf_objects, false)); // add false to supress error assertions EXPECT_TRUE(has_err_output(false)); + state->dataGlobal->TimeStepsInHour = 1; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 60; // must initialize this to get schedules initialized + state->init_state(*state); + std::string error_string = delimited_string({" ** Severe ** [OtherEquipment][OtherEq1][fuel_type] - \"Water\" - Failed to match against any enum values."}); EXPECT_TRUE(compare_err_stream(error_string, true)); bool ErrorsFound(false); - state->dataGlobal->NumOfTimeStepInHour = 1; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 60; // must initialize this to get schedules initialized - ScheduleManager::ProcessScheduleInput(*state); // read schedules HeatBalanceManager::GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); @@ -228,8 +228,7 @@ TEST_F(EnergyPlusFixture, InternalHeatGains_OtherEquipment_BadFuelType) ASSERT_THROW(InternalHeatGains::GetInternalHeatGainsInput(*state), std::runtime_error); error_string = delimited_string( - {" ** Warning ** ProcessScheduleInput: Schedule:Constant=\"SCHEDULE1\", Blank Schedule Type Limits Name input -- will not be validated.", - " ** Severe ** GetInternalHeatGains: OtherEquipment: invalid Fuel Type entered=WATER for Name=OTHEREQ1", + {" ** Severe ** GetInternalHeatGains: OtherEquipment: invalid Fuel Type entered=WATER for Name=OTHEREQ1", " ** Fatal ** GetInternalHeatGains: Errors found in Getting Internal Gains Input, Program Stopped", " ...Summary of Errors that led to program termination:", " ..... Reference severe error count=2", @@ -287,25 +286,27 @@ TEST_F(EnergyPlusFixture, InternalHeatGains_AllowBlankFieldsForAdaptiveComfortMo ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + bool ErrorsFound1(false); - ScheduleManager::ProcessScheduleInput(*state); // read schedules HeatBalanceManager::GetZoneData(*state, ErrorsFound1); ASSERT_FALSE(ErrorsFound1); - state->dataScheduleMgr->ScheduleInputProcessed = true; - state->dataScheduleMgr->Schedule(1).Used = true; - - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; - state->dataScheduleMgr->Schedule(1).MinValue = 1.0; - state->dataScheduleMgr->Schedule(1).MaxValue = 1.0; - state->dataScheduleMgr->Schedule(1).MaxMinSet = true; - state->dataScheduleMgr->Schedule(2).Used = true; - - state->dataScheduleMgr->Schedule(2).CurrentValue = 131.8; - state->dataScheduleMgr->Schedule(2).MinValue = 131.8; - state->dataScheduleMgr->Schedule(2).MaxValue = 131.8; - state->dataScheduleMgr->Schedule(2).MaxMinSet = true; + auto *occSched = Sched::GetSchedule(*state, "HOUSE OCCUPANCY"); + occSched->isUsed = true; + occSched->currentVal = 1.0; + occSched->minVal = 1.0; + occSched->maxVal = 1.0; + occSched->isMinMaxSet = true; + + auto *actSched = Sched::GetSchedule(*state, "ACTIVITY SCH"); + actSched->isUsed = true; + actSched->currentVal = 131.8; + actSched->minVal = 131.8; + actSched->maxVal = 131.8; + actSched->isMinMaxSet = true; + InternalHeatGains::GetInternalHeatGainsInput(*state); EXPECT_FALSE(state->dataInternalHeatGains->ErrorsFound); @@ -471,8 +472,9 @@ TEST_F(EnergyPlusFixture, InternalHeatGains_ElectricEquipITE_BeginEnvironmentRes EXPECT_FALSE(has_err_output()); bool ErrorsFound(false); - state->dataGlobal->NumOfTimeStepInHour = 1; - state->dataGlobal->MinutesPerTimeStep = 60; + state->dataGlobal->TimeStepsInHour = 1; + state->dataGlobal->MinutesInTimeStep = 60; + state->init_state(*state); HeatBalanceManager::GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); @@ -656,7 +658,8 @@ TEST_F(EnergyPlusFixture, InternalHeatGains_CheckZoneComponentLoadSubtotals) ASSERT_TRUE(process_idf(idf_objects)); EXPECT_FALSE(has_err_output()); - + state->init_state(*state); + bool ErrorsFound(false); HeatBalanceManager::GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); @@ -687,10 +690,10 @@ TEST_F(EnergyPlusFixture, InternalHeatGains_CheckZoneComponentLoadSubtotals) state->dataEnvrn->TotRunDesPersDays = 0; state->dataSize->CurOverallSimDay = 1; state->dataGlobal->HourOfDay = 1; - state->dataGlobal->NumOfTimeStepInHour = 10; + state->dataGlobal->TimeStepsInHour = 10; state->dataGlobal->TimeStep = 1; OutputReportTabular::AllocateLoadComponentArrays(*state); - int timeStepInDay = (state->dataGlobal->HourOfDay - 1) * state->dataGlobal->NumOfTimeStepInHour + state->dataGlobal->TimeStep; + int timeStepInDay = (state->dataGlobal->HourOfDay - 1) * state->dataGlobal->TimeStepsInHour + state->dataGlobal->TimeStep; state->dataGlobal->CompLoadReportIsReq = true; state->dataGlobal->isPulseZoneSizing = false; @@ -885,8 +888,9 @@ TEST_F(EnergyPlusFixture, InternalHeatGains_ElectricEquipITE_ApproachTemperature EXPECT_FALSE(has_err_output()); bool ErrorsFound(false); - state->dataGlobal->NumOfTimeStepInHour = 1; - state->dataGlobal->MinutesPerTimeStep = 60; + state->dataGlobal->TimeStepsInHour = 1; + state->dataGlobal->MinutesInTimeStep = 60; + state->init_state(*state); HeatBalanceManager::GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); @@ -1040,6 +1044,7 @@ TEST_F(EnergyPlusFixture, InternalHeatGains_ElectricEquipITE_DefaultCurves) ASSERT_TRUE(process_idf(idf_objects)); EXPECT_FALSE(has_err_output()); + state->init_state(*state); bool ErrorsFound(false); HeatBalanceManager::GetZoneData(*state, ErrorsFound); @@ -1326,17 +1331,18 @@ TEST_F(EnergyPlusFixture, InternalHeatGains_ZnRpt_Outputs) ASSERT_TRUE(process_idf(idf_objects)); EXPECT_FALSE(has_err_output()); + state->dataGlobal->TimeStepsInHour = 1; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 60; // must initialize this to get schedules initialized + state->init_state(*state); + bool ErrorsFound(false); - state->dataGlobal->NumOfTimeStepInHour = 1; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 60; // must initialize this to get schedules initialized - ScheduleManager::ProcessScheduleInput(*state); // read schedules state->dataEnvrn->DayOfYear_Schedule = 1; state->dataEnvrn->DayOfMonth = 1; state->dataEnvrn->DayOfWeek = 1; state->dataGlobal->HourOfDay = 1; state->dataGlobal->TimeStep = 1; - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); HeatBalanceManager::GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); @@ -1648,9 +1654,10 @@ TEST_F(EnergyPlusFixture, InternalHeatGains_AdjustedSupplyGoodInletNode) ASSERT_TRUE(process_idf(idf_objects)); bool ErrorsFound(false); - state->dataGlobal->NumOfTimeStepInHour = 1; - state->dataGlobal->MinutesPerTimeStep = 60; - + state->dataGlobal->TimeStepsInHour = 1; + state->dataGlobal->MinutesInTimeStep = 60; + state->init_state(*state); + HeatBalanceManager::GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); state->dataZoneTempPredictorCorrector->zoneHeatBalance.allocate(1); @@ -1870,8 +1877,9 @@ TEST_F(EnergyPlusFixture, InternalHeatGains_AdjustedSupplyBadInletNode) ASSERT_TRUE(process_idf(idf_objects)); bool ErrorsFound(false); - state->dataGlobal->NumOfTimeStepInHour = 1; - state->dataGlobal->MinutesPerTimeStep = 60; + state->dataGlobal->TimeStepsInHour = 1; + state->dataGlobal->MinutesInTimeStep = 60; + state->init_state(*state); HeatBalanceManager::GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); @@ -2096,8 +2104,9 @@ TEST_F(EnergyPlusFixture, InternalHeatGains_FlowControlWithApproachTemperaturesG ASSERT_TRUE(process_idf(idf_objects)); bool ErrorsFound(false); - state->dataGlobal->NumOfTimeStepInHour = 1; - state->dataGlobal->MinutesPerTimeStep = 60; + state->dataGlobal->TimeStepsInHour = 1; + state->dataGlobal->MinutesInTimeStep = 60; + state->init_state(*state); HeatBalanceManager::GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); @@ -2322,8 +2331,9 @@ TEST_F(EnergyPlusFixture, InternalHeatGains_FlowControlWithApproachTemperaturesB ASSERT_TRUE(process_idf(idf_objects)); bool ErrorsFound(false); - state->dataGlobal->NumOfTimeStepInHour = 1; - state->dataGlobal->MinutesPerTimeStep = 60; + state->dataGlobal->TimeStepsInHour = 1; + state->dataGlobal->MinutesInTimeStep = 60; + state->init_state(*state); HeatBalanceManager::GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); @@ -2548,8 +2558,9 @@ TEST_F(EnergyPlusFixture, InternalHeatGains_WarnMissingInletNode) ASSERT_TRUE(process_idf(idf_objects)); bool ErrorsFound(false); - state->dataGlobal->NumOfTimeStepInHour = 1; - state->dataGlobal->MinutesPerTimeStep = 60; + state->dataGlobal->TimeStepsInHour = 1; + state->dataGlobal->MinutesInTimeStep = 60; + state->init_state(*state); HeatBalanceManager::GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); @@ -2614,11 +2625,11 @@ TEST_F(EnergyPlusFixture, InternalHeatGains_GetHeatColdStressTemp) }); ASSERT_TRUE(process_idf(idf_objects)); + state->dataGlobal->TimeStepsInHour = 1; + state->dataGlobal->MinutesInTimeStep = 60; + state->init_state(*state); bool ErrorsFound(false); - state->dataGlobal->NumOfTimeStepInHour = 1; - state->dataGlobal->MinutesPerTimeStep = 60; - ScheduleManager::ProcessScheduleInput(*state); // read schedules HeatBalanceManager::GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); @@ -2726,8 +2737,9 @@ TEST_F(EnergyPlusFixture, ITEwithUncontrolledZoneTest) ASSERT_TRUE(process_idf(idf_objects)); bool ErrorsFound(false); - state->dataGlobal->NumOfTimeStepInHour = 1; - state->dataGlobal->MinutesPerTimeStep = 60; + state->dataGlobal->TimeStepsInHour = 1; + state->dataGlobal->MinutesInTimeStep = 60; + state->init_state(*state); HeatBalanceManager::GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); @@ -2864,8 +2876,9 @@ TEST_F(EnergyPlusFixture, ITE_Env_Class_Fix_41C) ASSERT_TRUE(process_idf(idf_objects)); bool ErrorsFound(false); - state->dataGlobal->NumOfTimeStepInHour = 1; - state->dataGlobal->MinutesPerTimeStep = 60; + state->dataGlobal->TimeStepsInHour = 1; + state->dataGlobal->MinutesInTimeStep = 60; + state->init_state(*state); state->dataGlobal->TimeStepZone = 1.0; @@ -3065,8 +3078,9 @@ TEST_F(EnergyPlusFixture, ITE_Env_Class_Fix_39C) ASSERT_TRUE(process_idf(idf_objects)); bool ErrorsFound(false); - state->dataGlobal->NumOfTimeStepInHour = 1; - state->dataGlobal->MinutesPerTimeStep = 60; + state->dataGlobal->TimeStepsInHour = 1; + state->dataGlobal->MinutesInTimeStep = 60; + state->init_state(*state); state->dataGlobal->TimeStepZone = 1.0; @@ -3273,8 +3287,9 @@ TEST_F(EnergyPlusFixture, ITE_Env_Class_Update_Class_H1) ASSERT_TRUE(process_idf(idf_objects)); bool ErrorsFound(false); - state->dataGlobal->NumOfTimeStepInHour = 1; - state->dataGlobal->MinutesPerTimeStep = 60; + state->dataGlobal->TimeStepsInHour = 1; + state->dataGlobal->MinutesInTimeStep = 60; + state->init_state(*state); state->dataGlobal->TimeStepZone = 1.0; diff --git a/tst/EnergyPlus/unit/LowTempRadiantSystem.unit.cc b/tst/EnergyPlus/unit/LowTempRadiantSystem.unit.cc index 6bf1a8c30dd..76ed9d347d8 100644 --- a/tst/EnergyPlus/unit/LowTempRadiantSystem.unit.cc +++ b/tst/EnergyPlus/unit/LowTempRadiantSystem.unit.cc @@ -88,7 +88,6 @@ using namespace EnergyPlus::DataSurfaces; using namespace EnergyPlus::DataSurfaceLists; using namespace EnergyPlus::HeatBalanceManager; using namespace EnergyPlus::PlantManager; -using namespace EnergyPlus::ScheduleManager; using namespace EnergyPlus::SizingManager; using namespace EnergyPlus::SurfaceGeometry; using namespace EnergyPlus::General; @@ -205,7 +204,7 @@ TEST_F(LowTempRadiantSystemTest, SizeLowTempRadiantElectric) TEST_F(LowTempRadiantSystemTest, SizeLowTempRadiantVariableFlow) { - FluidProperties::GetFluidPropertiesData(*state); + state->init_state(*state); SystemType = LowTempRadiantSystem::SystemType::HydronicSystem; state->dataLowTempRadSys->HydrRadSys(RadSysNum).Name = "LowTempVarFlow 1"; state->dataLowTempRadSys->HydrRadSys(RadSysNum).ZonePtr = 1; @@ -299,7 +298,7 @@ TEST_F(LowTempRadiantSystemTest, SizeLowTempRadiantVariableFlow) TEST_F(LowTempRadiantSystemTest, SizeCapacityLowTempRadiantVariableFlow) { - FluidProperties::GetFluidPropertiesData(*state); + state->init_state(*state); SystemType = LowTempRadiantSystem::SystemType::HydronicSystem; state->dataLowTempRadSys->HydrRadSys(RadSysNum).Name = "LowTempVarFlow 1"; state->dataLowTempRadSys->HydrRadSys(RadSysNum).ZonePtr = 1; @@ -376,7 +375,7 @@ TEST_F(LowTempRadiantSystemTest, SizeCapacityLowTempRadiantVariableFlow) TEST_F(LowTempRadiantSystemTest, SizeLowTempRadiantConstantFlow) { - FluidProperties::GetFluidPropertiesData(*state); + state->init_state(*state); SystemType = LowTempRadiantSystem::SystemType::ConstantFlowSystem; state->dataLowTempRadSys->CFloRadSys(RadSysNum).Name = "LowTempConstantFlow 1"; state->dataLowTempRadSys->CFloRadSys(RadSysNum).ZonePtr = 1; @@ -1123,7 +1122,8 @@ TEST_F(LowTempRadiantSystemTest, AutosizeLowTempRadiantVariableFlowTest) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + GetProjectControlData(*state, ErrorsFound); EXPECT_FALSE(ErrorsFound); @@ -1131,8 +1131,6 @@ TEST_F(LowTempRadiantSystemTest, AutosizeLowTempRadiantVariableFlowTest) EXPECT_FALSE(ErrorsFound); EXPECT_EQ("WEST ZONE", state->dataHeatBal->Zone(1).Name); - ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; HeatBalanceManager::SetPreConstructionInputParameters(*state); Material::GetMaterialData(*state, ErrorsFound); @@ -2010,7 +2008,8 @@ TEST_F(LowTempRadiantSystemTest, SimulateCapacityPerFloorAreaError) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + GetProjectControlData(*state, ErrorsFound); EXPECT_FALSE(ErrorsFound); @@ -2018,7 +2017,6 @@ TEST_F(LowTempRadiantSystemTest, SimulateCapacityPerFloorAreaError) EXPECT_FALSE(ErrorsFound); EXPECT_EQ("WEST ZONE", state->dataHeatBal->Zone(1).Name); - ProcessScheduleInput(*state); HeatBalanceManager::SetPreConstructionInputParameters(*state); Material::GetMaterialData(*state, ErrorsFound); EXPECT_FALSE(ErrorsFound); @@ -2064,7 +2062,7 @@ TEST_F(LowTempRadiantSystemTest, InitLowTempRadiantSystem) state->dataLowTempRadSys->CFloRadSys(RadSysNum).HotWaterInNode = 0; state->dataLowTempRadSys->CFloRadSys(RadSysNum).ColdWaterInNode = 0; state->dataGlobal->BeginTimeStepFlag = false; - state->dataLowTempRadSys->CFloRadSys(RadSysNum).VolFlowSchedPtr = 0; + state->dataLowTempRadSys->CFloRadSys(RadSysNum).volFlowSched = nullptr; state->dataLowTempRadSys->CFloRadSys(RadSysNum).EMSOverrideOnWaterMdot = false; state->dataLowTempRadSys->CFloRadSys(RadSysNum).WaterMassFlowRate = 1.0; state->dataLowTempRadSys->CFloRadSys(RadSysNum).HotDesignWaterMassFlowRate = 2.0; @@ -2114,7 +2112,7 @@ TEST_F(LowTempRadiantSystemTest, InitLowTempRadiantSystemCFloPump) state->dataLowTempRadSys->CFloRadSys(RadSysNum).HotWaterInNode = 0; state->dataLowTempRadSys->CFloRadSys(RadSysNum).ColdWaterInNode = 0; state->dataGlobal->BeginTimeStepFlag = false; - state->dataLowTempRadSys->CFloRadSys(RadSysNum).VolFlowSchedPtr = 0; + state->dataLowTempRadSys->CFloRadSys(RadSysNum).volFlowSched = nullptr; state->dataLowTempRadSys->CFloRadSys(RadSysNum).EMSOverrideOnWaterMdot = false; state->dataLowTempRadSys->CFloRadSys(RadSysNum).WaterMassFlowRate = 1.0; state->dataLowTempRadSys->CFloRadSys(RadSysNum).HotDesignWaterMassFlowRate = 2.0; @@ -2152,7 +2150,7 @@ TEST_F(LowTempRadiantSystemTest, InitLowTempRadiantSystemCFloPump) state->dataLowTempRadSys->CFloRadSys(RadSysNum).HotWaterInNode = 0; state->dataLowTempRadSys->CFloRadSys(RadSysNum).ColdWaterInNode = 0; state->dataGlobal->BeginTimeStepFlag = false; - state->dataLowTempRadSys->CFloRadSys(RadSysNum).VolFlowSchedPtr = 0; + state->dataLowTempRadSys->CFloRadSys(RadSysNum).volFlowSched = nullptr; state->dataLowTempRadSys->CFloRadSys(RadSysNum).EMSOverrideOnWaterMdot = false; state->dataLowTempRadSys->CFloRadSys(RadSysNum).WaterMassFlowRate = 1.0; state->dataLowTempRadSys->CFloRadSys(RadSysNum).HotDesignWaterMassFlowRate = 2.0; @@ -2197,7 +2195,7 @@ TEST_F(LowTempRadiantSystemTest, InitLowTempRadiantSystemCFloPump) state->dataLowTempRadSys->CFloRadSys(RadSysNum).HotWaterInNode = 0; state->dataLowTempRadSys->CFloRadSys(RadSysNum).ColdWaterInNode = 0; state->dataGlobal->BeginTimeStepFlag = false; - state->dataLowTempRadSys->CFloRadSys(RadSysNum).VolFlowSchedPtr = 0; + state->dataLowTempRadSys->CFloRadSys(RadSysNum).volFlowSched = nullptr; state->dataLowTempRadSys->CFloRadSys(RadSysNum).EMSOverrideOnWaterMdot = false; state->dataLowTempRadSys->CFloRadSys(RadSysNum).WaterMassFlowRate = 1.0; state->dataLowTempRadSys->CFloRadSys(RadSysNum).HotDesignWaterMassFlowRate = 2.0; @@ -2242,7 +2240,7 @@ TEST_F(LowTempRadiantSystemTest, InitLowTempRadiantSystemCFloPump) state->dataLowTempRadSys->CFloRadSys(RadSysNum).HotWaterInNode = 0; state->dataLowTempRadSys->CFloRadSys(RadSysNum).ColdWaterInNode = 0; state->dataGlobal->BeginTimeStepFlag = false; - state->dataLowTempRadSys->CFloRadSys(RadSysNum).VolFlowSchedPtr = 0; + state->dataLowTempRadSys->CFloRadSys(RadSysNum).volFlowSched = nullptr; state->dataLowTempRadSys->CFloRadSys(RadSysNum).EMSOverrideOnWaterMdot = false; state->dataLowTempRadSys->CFloRadSys(RadSysNum).WaterMassFlowRate = 1.0; state->dataLowTempRadSys->CFloRadSys(RadSysNum).HotDesignWaterMassFlowRate = 2.0; @@ -2339,7 +2337,8 @@ TEST_F(LowTempRadiantSystemTest, LowTempElecRadSurfaceGroupTest) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + state->dataHeatBal->Zone.allocate(2); state->dataHeatBal->Zone(1).Name = "WEST ZONE"; state->dataHeatBal->Zone(2).Name = "EAST ZONE"; @@ -2397,24 +2396,25 @@ TEST_F(LowTempRadiantSystemTest, CalcLowTempCFloRadiantSystem_OperationMode) state->dataLowTempRadSys->CFloRadSys(RadSysNum).SurfacePtr.allocate(1); state->dataLowTempRadSys->NumOfCFloLowTempRadSysDes = 1; state->dataLowTempRadSys->CflowRadiantSysDesign.allocate(state->dataLowTempRadSys->NumOfCFloLowTempRadSysDes); - state->dataScheduleMgr->Schedule.allocate(3); + state->dataZoneTempPredictorCorrector->zoneHeatBalance.allocate(1); - state->dataScheduleMgr->Schedule(1).CurrentValue = 1; - state->dataScheduleMgr->Schedule(2).CurrentValue = 22.0; - state->dataScheduleMgr->Schedule(3).CurrentValue = 25.0; state->dataZoneTempPredictorCorrector->zoneHeatBalance(1).MAT = 21.0; state->dataLowTempRadSys->CFloRadSys(RadSysNum).NumOfSurfaces = 0; state->dataLowTempRadSys->TotalNumOfRadSystems = 0; state->dataLowTempRadSys->CFloRadSys(RadSysNum).ZonePtr = 1; - state->dataLowTempRadSys->CFloRadSys(RadSysNum).SchedPtr = 1; + state->dataLowTempRadSys->CFloRadSys(RadSysNum).availSched = Sched::AddScheduleConstant(*state, "Avail"); state->dataLowTempRadSys->CFloRadSys(RadSysNum).controlType = LowTempRadiantControlTypes::MATControl; - state->dataLowTempRadSys->CFloRadSys(RadSysNum).HotCtrlHiTempSchedPtr = 2; - state->dataLowTempRadSys->CFloRadSys(RadSysNum).ColdCtrlLoTempSchedPtr = 3; + state->dataLowTempRadSys->CFloRadSys(RadSysNum).hotCtrlHiTempSched = Sched::AddScheduleConstant(*state, "Hi Temp"); + state->dataLowTempRadSys->CFloRadSys(RadSysNum).coldCtrlLoTempSched = Sched::AddScheduleConstant(*state, "Lo Temp"); state->dataLowTempRadSys->CFloRadSys(RadSysNum).SurfacePtr(1) = 1; + state->dataLowTempRadSys->CFloRadSys(RadSysNum).availSched->currentVal = 1; + state->dataLowTempRadSys->CFloRadSys(RadSysNum).hotCtrlHiTempSched->currentVal = 22.0; + state->dataLowTempRadSys->CFloRadSys(RadSysNum).coldCtrlLoTempSched->currentVal = 25.0; + state->dataLowTempRadSys->CFloRadSys(RadSysNum).HotWaterInNode = 0; state->dataLowTempRadSys->CFloRadSys(RadSysNum).ColdWaterInNode = 0; - state->dataLowTempRadSys->CFloRadSys(RadSysNum).VolFlowSchedPtr = 0; + state->dataLowTempRadSys->CFloRadSys(RadSysNum).volFlowSched = nullptr; state->dataLowTempRadSys->CFloRadSys(RadSysNum).EMSOverrideOnWaterMdot = false; state->dataLowTempRadSys->CFloRadSys(RadSysNum).WaterMassFlowRate = 1.0; state->dataLowTempRadSys->CFloRadSys(RadSysNum).HotDesignWaterMassFlowRate = 2.0; @@ -2459,22 +2459,22 @@ TEST_F(LowTempRadiantSystemTest, CalcLowTempHydrRadiantSystem_OperationMode) state->dataLowTempRadSys->HydronicRadiantSysDesign.allocate(state->dataLowTempRadSys->NumOfHydrLowTempRadSys); state->dataLowTempRadSys->HydrRadSys(RadSysNum).SurfacePtr.allocate(1); state->dataLowTempRadSys->HydrRadSys(RadSysNum).SurfacePtr(1) = 1; - state->dataScheduleMgr->Schedule.allocate(3); + state->dataZoneTempPredictorCorrector->zoneHeatBalance.allocate(1); - state->dataScheduleMgr->Schedule(1).CurrentValue = 1; - state->dataScheduleMgr->Schedule(2).CurrentValue = 22.0; - state->dataScheduleMgr->Schedule(3).CurrentValue = 25.0; state->dataZoneTempPredictorCorrector->zoneHeatBalance(1).MAT = 21.0; state->dataLowTempRadSys->HydrRadSys(RadSysNum).NumOfSurfaces = 0; state->dataLowTempRadSys->TotalNumOfRadSystems = 0; state->dataLowTempRadSys->HydrRadSys(RadSysNum).ZonePtr = 1; - state->dataLowTempRadSys->HydrRadSys(RadSysNum).SchedPtr = 1; + state->dataLowTempRadSys->HydrRadSys(RadSysNum).availSched = Sched::AddScheduleConstant(*state, "Avail"); + state->dataLowTempRadSys->HydrRadSys(RadSysNum).availSched->currentVal = 1; state->dataLowTempRadSys->HydrRadSys(RadSysNum).controlType = LowTempRadiantControlTypes::MATControl; DesignObjectNum = 1; state->dataLowTempRadSys->HydrRadSys(RadSysNum).DesignObjectPtr = 1; - state->dataLowTempRadSys->HydronicRadiantSysDesign(DesignObjectNum).HotSetptSchedPtr = 2; - state->dataLowTempRadSys->HydronicRadiantSysDesign(DesignObjectNum).ColdSetptSchedPtr = 3; + state->dataLowTempRadSys->HydronicRadiantSysDesign(DesignObjectNum).heatSetptSched = Sched::AddScheduleConstant(*state, "Hot Setpt"); + state->dataLowTempRadSys->HydronicRadiantSysDesign(DesignObjectNum).heatSetptSched->currentVal = 22.0; + state->dataLowTempRadSys->HydronicRadiantSysDesign(DesignObjectNum).coolSetptSched = Sched::AddScheduleConstant(*state, "Cold Setpt"); + state->dataLowTempRadSys->HydronicRadiantSysDesign(DesignObjectNum).coolSetptSched->currentVal = 25.0; state->dataLowTempRadSys->HydrRadSys(RadSysNum).HotWaterInNode = 0; state->dataLowTempRadSys->HydrRadSys(RadSysNum).ColdWaterInNode = 0; @@ -2597,12 +2597,12 @@ TEST_F(LowTempRadiantSystemTest, SizeRadSysTubeLengthTest) FuncCalc = state->dataLowTempRadSys->CFloRadSys(RadSysNum).sizeRadiantSystemTubeLength(*state); EXPECT_NEAR(FuncCalc, 2000.0, 0.1); } + TEST_F(LowTempRadiantSystemTest, LowTempRadConFlowSystemAutoSizeTempTest) { - + state->init_state(*state); Real64 Density; Real64 Cp; - FluidProperties::GetFluidPropertiesData(*state); SystemType = LowTempRadiantSystem::SystemType::ConstantFlowSystem; state->dataLowTempRadSys->CFloRadSys(RadSysNum).Name = "LowTempConstantFlow"; @@ -2687,6 +2687,7 @@ TEST_F(LowTempRadiantSystemTest, LowTempRadConFlowSystemAutoSizeTempTest) TEST_F(LowTempRadiantSystemTest, LowTempRadCalcRadSysHXEffectTermTest) { + state->init_state(*state); int RadSysNum; LowTempRadiantSystem::SystemType RadSysType; Real64 Temperature; @@ -2697,7 +2698,6 @@ TEST_F(LowTempRadiantSystemTest, LowTempRadCalcRadSysHXEffectTermTest) Real64 TubeDiameter; Real64 HXEffectFuncResult; int SurfNum; - FluidProperties::GetFluidPropertiesData(*state); // Set values of items that will stay constant for all calls to HX Effectiveness function RadSysNum = 1; @@ -3205,7 +3205,8 @@ TEST_F(LowTempRadiantSystemTest, calculateOperationalFractionMaxLimitTest) TEST_F(LowTempRadiantSystemTest, setOffTemperatureLowTemperatureRadiantSystemTest) { - + state->init_state(*state); + Real64 expectedResult; Real64 actualResult; Real64 acceptibleError = 0.001; @@ -3215,62 +3216,58 @@ TEST_F(LowTempRadiantSystemTest, setOffTemperatureLowTemperatureRadiantSystemTes state->dataLowTempRadSys->HydrRadSys.allocate(1); // Test 1: zeroFlow and no throttling range - scheduleIndex = -1; // this assigns a value of 1.0 throttlingRange = 0.0; state->dataLowTempRadSys->HydrRadSys(1).SetpointType = LowTempRadiantSetpointTypes::ZeroFlowPower; expectedResult = 1.0; actualResult = state->dataLowTempRadSys->HydrRadSys(1).setOffTemperatureLowTemperatureRadiantSystem( - *state, scheduleIndex, throttlingRange, state->dataLowTempRadSys->HydrRadSys(1).SetpointType); + *state, Sched::GetScheduleAlwaysOn(*state), throttlingRange, state->dataLowTempRadSys->HydrRadSys(1).SetpointType); EXPECT_NEAR(expectedResult, actualResult, acceptibleError); // Test 2: zeroFlow and positive throttling range - scheduleIndex = -1; // this assigns a value of 1.0 throttlingRange = 0.5; state->dataLowTempRadSys->HydrRadSys(1).SetpointType = LowTempRadiantSetpointTypes::ZeroFlowPower; expectedResult = 1.0; actualResult = state->dataLowTempRadSys->HydrRadSys(1).setOffTemperatureLowTemperatureRadiantSystem( - *state, scheduleIndex, throttlingRange, state->dataLowTempRadSys->HydrRadSys(1).SetpointType); + *state, Sched::GetScheduleAlwaysOn(*state), throttlingRange, state->dataLowTempRadSys->HydrRadSys(1).SetpointType); EXPECT_NEAR(expectedResult, actualResult, acceptibleError); // Test 3: zeroFlow and negative throttling range (cooling situation) - scheduleIndex = -1; // this assigns a value of 1.0 throttlingRange = -0.5; state->dataLowTempRadSys->HydrRadSys(1).SetpointType = LowTempRadiantSetpointTypes::ZeroFlowPower; expectedResult = 1.0; actualResult = state->dataLowTempRadSys->HydrRadSys(1).setOffTemperatureLowTemperatureRadiantSystem( - *state, scheduleIndex, throttlingRange, state->dataLowTempRadSys->HydrRadSys(1).SetpointType); + *state, Sched::GetScheduleAlwaysOn(*state), throttlingRange, state->dataLowTempRadSys->HydrRadSys(1).SetpointType); EXPECT_NEAR(expectedResult, actualResult, acceptibleError); // Test 4: halfFlow and no throttling range - scheduleIndex = -1; // this assigns a value of 1.0 throttlingRange = 0.0; state->dataLowTempRadSys->HydrRadSys(1).SetpointType = LowTempRadiantSetpointTypes::HalfFlowPower; expectedResult = 1.0; actualResult = state->dataLowTempRadSys->HydrRadSys(1).setOffTemperatureLowTemperatureRadiantSystem( - *state, scheduleIndex, throttlingRange, state->dataLowTempRadSys->HydrRadSys(1).SetpointType); + *state, Sched::GetScheduleAlwaysOn(*state), throttlingRange, state->dataLowTempRadSys->HydrRadSys(1).SetpointType); EXPECT_NEAR(expectedResult, actualResult, acceptibleError); // Test 5: halfFlow and positive throttling range - scheduleIndex = -1; // this assigns a value of 1.0 throttlingRange = 0.5; state->dataLowTempRadSys->HydrRadSys(1).SetpointType = LowTempRadiantSetpointTypes::HalfFlowPower; expectedResult = 1.25; actualResult = state->dataLowTempRadSys->HydrRadSys(1).setOffTemperatureLowTemperatureRadiantSystem( - *state, scheduleIndex, throttlingRange, state->dataLowTempRadSys->HydrRadSys(1).SetpointType); + *state, Sched::GetScheduleAlwaysOn(*state), throttlingRange, state->dataLowTempRadSys->HydrRadSys(1).SetpointType); EXPECT_NEAR(expectedResult, actualResult, acceptibleError); // Test 5: halfFlow and negative throttling range (cooling situation) - scheduleIndex = -1; // this assigns a value of 1.0 throttlingRange = -0.5; state->dataLowTempRadSys->HydrRadSys(1).SetpointType = LowTempRadiantSetpointTypes::HalfFlowPower; expectedResult = 0.75; actualResult = state->dataLowTempRadSys->HydrRadSys(1).setOffTemperatureLowTemperatureRadiantSystem( - *state, scheduleIndex, throttlingRange, state->dataLowTempRadSys->HydrRadSys(1).SetpointType); + *state, Sched::GetScheduleAlwaysOn(*state), throttlingRange, state->dataLowTempRadSys->HydrRadSys(1).SetpointType); EXPECT_NEAR(expectedResult, actualResult, acceptibleError); } TEST_F(LowTempRadiantSystemTest, errorCheckZonesAndConstructionsTest) { + state->init_state(*state); + bool actualErrorsFound; std::string const Alpha1("Zone Name"); std::string const Alpha2("An Amazing Zone"); @@ -3366,6 +3363,7 @@ TEST_F(LowTempRadiantSystemTest, errorCheckZonesAndConstructionsTest) TEST_F(LowTempRadiantSystemTest, calculateRunningMeanAverageTemperatureTest) { + state->init_state(*state); // This tests both calculateRunningMeanAverageTemperature and calculateCurrentDailyAverageODB // because calculateCurrentDailyAverageODB is called by calculateRunningMeanAverageTemperature Real64 expectedResult; @@ -3375,10 +3373,10 @@ TEST_F(LowTempRadiantSystemTest, calculateRunningMeanAverageTemperatureTest) auto &thisCFloSys(state->dataLowTempRadSys->CFloRadSys(1)); state->dataLowTempRadSys->CflowRadiantSysDesign.allocate(1); auto &thisRadSysDesign(state->dataLowTempRadSys->CflowRadiantSysDesign(1)); - state->dataGlobal->NumOfTimeStepInHour = 1; - state->dataWeather->wvarsHrTsToday.allocate(state->dataGlobal->NumOfTimeStepInHour, Constant::HoursInDay); - for (int hourNumber = 1; hourNumber <= Constant::HoursInDay; ++hourNumber) { - state->dataWeather->wvarsHrTsToday(state->dataGlobal->NumOfTimeStepInHour, hourNumber).OutDryBulbTemp = double(hourNumber); + state->dataGlobal->TimeStepsInHour = 1; + state->dataWeather->wvarsHrTsToday.allocate(state->dataGlobal->TimeStepsInHour, Constant::iHoursInDay); + for (int hourNumber = 1; hourNumber <= Constant::iHoursInDay; ++hourNumber) { + state->dataWeather->wvarsHrTsToday(state->dataGlobal->TimeStepsInHour, hourNumber).OutDryBulbTemp = double(hourNumber); } // Test 1: First day of the simulation and it's in warmup-->everything set to the same temperature @@ -3452,10 +3450,11 @@ TEST_F(LowTempRadiantSystemTest, calculateRunningMeanAverageTemperatureTest) TEST_F(LowTempRadiantSystemTest, updateOperatingModeHistoryTest) { + state->init_state(*state); int expectedResult; int resetResult = -9999; state->dataLowTempRadSys->HydrRadSys.allocate(1); - state->dataGlobal->NumOfTimeStepInHour = 6; + state->dataGlobal->TimeStepsInHour = 6; state->dataGlobal->DayOfSim = 2; state->dataGlobal->HourOfDay = 4; state->dataGlobal->TimeStep = 5; @@ -3473,9 +3472,9 @@ TEST_F(LowTempRadiantSystemTest, updateOperatingModeHistoryTest) thisRadSys.updateOperatingModeHistory(*state); expectedResult = 1; EXPECT_EQ(thisRadSys.lastDayOfSim, expectedResult); - expectedResult = Constant::HoursInDay; + expectedResult = Constant::iHoursInDay; EXPECT_EQ(thisRadSys.lastHourOfDay, expectedResult); - expectedResult = state->dataGlobal->NumOfTimeStepInHour; + expectedResult = state->dataGlobal->TimeStepsInHour; EXPECT_EQ(thisRadSys.lastTimeStep, expectedResult); EXPECT_EQ(thisRadSys.lastOperatingMode, LowTempRadiantSystem::CoolingMode); EXPECT_EQ(thisRadSys.OperatingMode, LowTempRadiantSystem::NotOperating); @@ -3494,7 +3493,7 @@ TEST_F(LowTempRadiantSystemTest, updateOperatingModeHistoryTest) EXPECT_EQ(thisRadSys.lastDayOfSim, expectedResult); expectedResult = 3; EXPECT_EQ(thisRadSys.lastHourOfDay, expectedResult); - expectedResult = state->dataGlobal->NumOfTimeStepInHour; + expectedResult = state->dataGlobal->TimeStepsInHour; EXPECT_EQ(thisRadSys.lastTimeStep, expectedResult); EXPECT_EQ(thisRadSys.lastOperatingMode, LowTempRadiantSystem::CoolingMode); EXPECT_EQ(thisRadSys.OperatingMode, LowTempRadiantSystem::NotOperating); @@ -3541,11 +3540,12 @@ TEST_F(LowTempRadiantSystemTest, updateOperatingModeHistoryTest) TEST_F(LowTempRadiantSystemTest, setOperatingModeBasedOnChangeoverDelayTest) { + state->init_state(*state); int expectedResult; state->dataLowTempRadSys->HydrRadSys.allocate(1); auto &thisRadSys(state->dataLowTempRadSys->HydrRadSys(1)); - state->dataGlobal->NumOfTimeStepInHour = 6; - state->dataGlobal->MinutesPerTimeStep = 10.0; + state->dataGlobal->TimeStepsInHour = 6; + state->dataGlobal->MinutesInTimeStep = 10.0; // Test 1: lastOperatingMode is NotOperating-->don't do anything to OperatingMode thisRadSys.lastOperatingMode = LowTempRadiantSystem::NotOperating; @@ -3572,7 +3572,7 @@ TEST_F(LowTempRadiantSystemTest, setOperatingModeBasedOnChangeoverDelayTest) // anything to OperatingMode thisRadSys.lastOperatingMode = LowTempRadiantSystem::HeatingMode; thisRadSys.OperatingMode = LowTempRadiantSystem::CoolingMode; - thisRadSys.schedPtrChangeoverDelay = 0; + thisRadSys.changeoverDelaySched = nullptr; thisRadSys.setOperatingModeBasedOnChangeoverDelay(*state); expectedResult = LowTempRadiantSystem::CoolingMode; EXPECT_EQ(thisRadSys.OperatingMode, expectedResult); @@ -3582,7 +3582,7 @@ TEST_F(LowTempRadiantSystemTest, setOperatingModeBasedOnChangeoverDelayTest) // to switch over yet-->change OperatingMode to NotOperating thisRadSys.lastOperatingMode = LowTempRadiantSystem::HeatingMode; thisRadSys.OperatingMode = LowTempRadiantSystem::CoolingMode; - thisRadSys.schedPtrChangeoverDelay = -1; + thisRadSys.changeoverDelaySched = Sched::GetScheduleAlwaysOn(*state); state->dataGlobal->DayOfSim = 2; state->dataGlobal->HourOfDay = 1; state->dataGlobal->TimeStep = 1; @@ -3611,6 +3611,7 @@ TEST_F(LowTempRadiantSystemTest, setOperatingModeBasedOnChangeoverDelayTest) TEST_F(LowTempRadiantSystemTest, getFluidToSlabHeatTransferInputTest) { + state->init_state(*state); state->dataLowTempRadSys->CFloRadSys.allocate(1); auto &thisCFloSys(state->dataLowTempRadSys->CFloRadSys(1)); state->dataLowTempRadSys->CflowRadiantSysDesign.allocate(1); @@ -3646,7 +3647,7 @@ TEST_F(LowTempRadiantSystemTest, getFluidToSlabHeatTransferInputTest) TEST_F(LowTempRadiantSystemTest, calculateUFromISOStandardTest) { - + state->init_state(*state); // Test of the ISO Standard 11855-2 Method for calculating the U-value for heat transfer // between the fluid being circulated through a radiant system and the radiant system // material that the pipe/tube is embedded within @@ -3814,7 +3815,8 @@ TEST_F(LowTempRadiantSystemTest, GetLowTempRadiantSystem_MultipleTypes) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + state->dataHeatBal->Zone.allocate(3); state->dataHeatBal->Zone(1).Name = "WEST ZONE"; state->dataHeatBal->Zone(2).Name = "EAST ZONE"; @@ -4637,7 +4639,8 @@ TEST_F(LowTempRadiantSystemTest, VariableFlowCoolingOnlyInputTest) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + GetProjectControlData(*state, ErrorsFound); EXPECT_FALSE(ErrorsFound); @@ -4645,7 +4648,6 @@ TEST_F(LowTempRadiantSystemTest, VariableFlowCoolingOnlyInputTest) EXPECT_FALSE(ErrorsFound); EXPECT_EQ("WEST ZONE", state->dataHeatBal->Zone(1).Name); - ProcessScheduleInput(*state); HeatBalanceManager::SetPreConstructionInputParameters(*state); Material::GetMaterialData(*state, ErrorsFound); EXPECT_FALSE(ErrorsFound); diff --git a/tst/EnergyPlus/unit/Material.unit.cc b/tst/EnergyPlus/unit/Material.unit.cc index 9c0b1786380..524b6b9c6a3 100644 --- a/tst/EnergyPlus/unit/Material.unit.cc +++ b/tst/EnergyPlus/unit/Material.unit.cc @@ -104,10 +104,9 @@ TEST_F(EnergyPlusFixture, GetMaterialDataReadVarAbsorptance) }); ASSERT_TRUE(process_idf(idf_objects)); - state->dataGlobal->NumOfTimeStepInHour = 1; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 60; // must initialize this to get schedules initialized - ScheduleManager::ProcessScheduleInput(*state); // read schedules - state->dataScheduleMgr->ScheduleInputProcessed = true; + state->dataGlobal->TimeStepsInHour = 1; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 60; // must initialize this to get schedules initialized + state->init_state(*state); auto &s_mat = state->dataMaterial; @@ -144,8 +143,8 @@ TEST_F(EnergyPlusFixture, GetMaterialDataReadVarAbsorptance) EXPECT_ENUM_EQ(mat2->absorpVarCtrlSignal, Material::VariableAbsCtrlSignal::SurfaceReceivedSolarRadiation); EXPECT_EQ(mat2->absorpSolarVarFuncIdx, 2); EXPECT_ENUM_EQ(mat3->absorpVarCtrlSignal, Material::VariableAbsCtrlSignal::Scheduled); - EXPECT_EQ(mat3->absorpThermalVarSchedIdx, 1); - EXPECT_EQ(mat3->absorpSolarVarSchedIdx, 1); + EXPECT_NE(mat3->absorpThermalVarSched, nullptr); + EXPECT_NE(mat3->absorpSolarVarSched, nullptr); std::string idf_objects_bad_inputs = delimited_string({ "MaterialProperty:VariableAbsorptance,", diff --git a/tst/EnergyPlus/unit/MicroCHPElectricGenerator.unit.cc b/tst/EnergyPlus/unit/MicroCHPElectricGenerator.unit.cc index c0dd0e25c32..bd6cf4d3f1e 100644 --- a/tst/EnergyPlus/unit/MicroCHPElectricGenerator.unit.cc +++ b/tst/EnergyPlus/unit/MicroCHPElectricGenerator.unit.cc @@ -275,6 +275,8 @@ TEST_F(EnergyPlusFixture, MicroCHPTest_InitGeneratorDynamics) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + state->dataPlnt->TotNumLoops = 1; state->dataPlnt->PlantLoop.allocate(1); diff --git a/tst/EnergyPlus/unit/MixedAir.unit.cc b/tst/EnergyPlus/unit/MixedAir.unit.cc index 01bdbee4868..1bda3f3c7ad 100644 --- a/tst/EnergyPlus/unit/MixedAir.unit.cc +++ b/tst/EnergyPlus/unit/MixedAir.unit.cc @@ -85,7 +85,6 @@ using namespace EnergyPlus::DataAirLoop; using namespace EnergyPlus::DataAirSystems; using namespace EnergyPlus::DataSizing; using namespace EnergyPlus::DataHeatBalance; -using namespace EnergyPlus::ScheduleManager; using namespace EnergyPlus::DataEnvironment; using namespace EnergyPlus::DataZoneEquipment; using namespace EnergyPlus::DataLoopNode; @@ -140,6 +139,7 @@ TEST_F(EnergyPlusFixture, MixedAir_ProcessOAControllerTest) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); bool ErrorsFound(false); // If errors detected in input int ControllerNum(0); // Controller number @@ -497,6 +497,8 @@ TEST_F(EnergyPlusFixture, MixedAir_HXBypassOptionTest) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + GetOAControllerInputs(*state); EXPECT_EQ(2, state->dataMixedAir->OAController(1).OANode); EXPECT_TRUE(OutAirNodeManager::CheckOutAirNodeNumber(*state, state->dataMixedAir->OAController(1).OANode)); @@ -718,9 +720,6 @@ TEST_F(EnergyPlusFixture, MixedAir_HXBypassOptionTest) TEST_F(EnergyPlusFixture, CO2ControlDesignOccupancyTest) { - state->dataContaminantBalance->Contaminant.CO2Simulation = true; - state->dataContaminantBalance->Contaminant.CO2OutdoorSchedPtr = 1; - std::string const idf_objects = delimited_string({ " OutdoorAir:Node,", " Outside Air Inlet Node; !- Name", @@ -808,6 +807,13 @@ TEST_F(EnergyPlusFixture, CO2ControlDesignOccupancyTest) ASSERT_TRUE(process_idf(idf_objects)); + state->dataGlobal->TimeStepsInHour = 4; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 15; // must initialize this to get schedules initialized + state->init_state(*state); + + state->dataContaminantBalance->Contaminant.CO2Simulation = true; + state->dataContaminantBalance->Contaminant.CO2OutdoorSched = Sched::GetSchedule(*state, "OCCUPY-1"); + state->dataAirLoop->AirLoopControlInfo.allocate(1); state->dataAirLoop->AirLoopControlInfo(1).LoopFlowRateSet = true; state->dataSize->OARequirements.allocate(1); @@ -816,15 +822,16 @@ TEST_F(EnergyPlusFixture, CO2ControlDesignOccupancyTest) oaRequirements.OAFlowMethod = OAFlowCalcMethod::Sum; oaRequirements.OAFlowPerPerson = 0.003149; oaRequirements.OAFlowPerArea = 0.000407; - + oaRequirements.oaFlowFracSched = Sched::GetScheduleAlwaysOn(*state); + state->dataSize->ZoneAirDistribution.allocate(1); state->dataSize->ZoneAirDistribution(1).Name = "CM DSZAD WEST ZONE"; - state->dataSize->ZoneAirDistribution(1).ZoneADEffSchPtr = 4; + state->dataSize->ZoneAirDistribution(1).zoneADEffSched = Sched::GetSchedule(*state, "ZONEADEFFSCH"); state->dataHeatBal->Zone.allocate(1); state->dataHeatBal->Zone(1).Name = "WEST ZONE"; state->dataHeatBal->Zone(1).FloorArea = 10.0; - state->dataHeatBal->Zone(1).ZoneContamControllerSchedIndex = 4; + state->dataHeatBal->Zone(1).zoneContamControllerSched = Sched::GetSchedule(*state, "ZONEADEFFSCH"); state->dataHeatBal->Zone(1).numSpaces = 1; state->dataHeatBal->Zone(1).spaceIndexes.emplace_back(1); state->dataGlobal->NumOfZones = 1; @@ -838,8 +845,6 @@ TEST_F(EnergyPlusFixture, CO2ControlDesignOccupancyTest) state->dataAirLoop->AirLoopFlow(1).OAFrac = 0.01; // DataAirLoop variable (AirloopHVAC) state->dataAirLoop->AirLoopFlow(1).OAMinFrac = 0.01; // DataAirLoop variable (AirloopHVAC) - state->dataGlobal->NumOfTimeStepInHour = 4; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 15; // must initialize this to get schedules initialized state->dataEnvrn->StdBaroPress = StdPressureSeaLevel; state->dataEnvrn->OutDryBulbTemp = 13.0; state->dataEnvrn->OutBaroPress = StdPressureSeaLevel; @@ -847,7 +852,6 @@ TEST_F(EnergyPlusFixture, CO2ControlDesignOccupancyTest) state->dataEnvrn->StdRhoAir = Psychrometrics::PsyRhoAirFnPbTdbW(*state, state->dataEnvrn->OutBaroPress, state->dataEnvrn->OutDryBulbTemp, state->dataEnvrn->OutHumRat); - ScheduleManager::ProcessScheduleInput(*state); InternalHeatGains::GetInternalHeatGainsInput(*state); GetOAControllerInputs(*state); @@ -858,13 +862,15 @@ TEST_F(EnergyPlusFixture, CO2ControlDesignOccupancyTest) EXPECT_NEAR(0.00314899, ventMechanical.VentMechZone(1).ZoneOAPeopleRate, 0.00001); EXPECT_NEAR(0.000407, ventMechanical.VentMechZone(1).ZoneOAAreaRate, 0.00001); - ventMechanical.SchPtr = 1; - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; + ventMechanical.sched = Sched::GetSchedule(*state, "OCCUPY-1"); + ventMechanical.sched->currentVal = 1.0; - ventMechanical.VentMechZone(1).ZoneADEffSchPtr = 2; - state->dataScheduleMgr->Schedule(2).CurrentValue = 1.0; + ventMechanical.VentMechZone(1).zoneADEffSched = Sched::GetSchedule(*state, "ACTSCHD"); + ventMechanical.VentMechZone(1).zoneADEffSched->currentVal = 1.0; + state->dataHeatBal->Zone(1).TotOccupants = 3; - state->dataScheduleMgr->Schedule(4).CurrentValue = 1.0; + Sched::GetSchedule(*state, "ZONEADEFFSCH")->currentVal = 1.0; + state->dataContaminantBalance->ZoneCO2GainFromPeople.allocate(1); state->dataContaminantBalance->ZoneCO2GainFromPeople(1) = 3.82E-8; state->dataContaminantBalance->OutdoorCO2 = 400; @@ -963,9 +969,6 @@ TEST_F(EnergyPlusFixture, CO2ControlDesignOccupancyTest) TEST_F(EnergyPlusFixture, CO2ControlDesignOccupancyTest3Zone) { - state->dataContaminantBalance->Contaminant.CO2Simulation = true; - state->dataContaminantBalance->Contaminant.CO2OutdoorSchedPtr = 1; - std::string const idf_objects = delimited_string({ " OutdoorAir:Node,", " Outside Air Inlet Node; !- Name", @@ -1080,6 +1083,10 @@ TEST_F(EnergyPlusFixture, CO2ControlDesignOccupancyTest3Zone) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + + state->dataContaminantBalance->Contaminant.CO2Simulation = true; + state->dataContaminantBalance->Contaminant.CO2OutdoorSched = Sched::GetSchedule(*state, "OCCUPY-1"); state->dataAirLoop->AirLoopControlInfo.allocate(1); state->dataAirLoop->AirLoopControlInfo(1).LoopFlowRateSet = true; @@ -1089,25 +1096,26 @@ TEST_F(EnergyPlusFixture, CO2ControlDesignOccupancyTest3Zone) oaRequirements.OAFlowMethod = OAFlowCalcMethod::Sum; oaRequirements.OAFlowPerPerson = 0.003149; oaRequirements.OAFlowPerArea = 0.000407; + oaRequirements.oaFlowFracSched = Sched::GetScheduleAlwaysOn(*state); state->dataSize->ZoneAirDistribution.allocate(1); state->dataSize->ZoneAirDistribution(1).Name = "CM DSZAD WEST ZONE"; - state->dataSize->ZoneAirDistribution(1).ZoneADEffSchPtr = 4; + state->dataSize->ZoneAirDistribution(1).zoneADEffSched = Sched::GetSchedule(*state, "ZONEADEFFSCH"); state->dataHeatBal->Zone.allocate(3); state->dataHeatBal->Zone(1).Name = "WEST ZONE"; state->dataHeatBal->Zone(1).FloorArea = 10.0; - state->dataHeatBal->Zone(1).ZoneContamControllerSchedIndex = 4; + state->dataHeatBal->Zone(1).zoneContamControllerSched = Sched::GetSchedule(*state, "ZONEADEFFSCH"); state->dataHeatBal->Zone(1).numSpaces = 1; state->dataHeatBal->Zone(1).spaceIndexes.emplace_back(1); state->dataHeatBal->Zone(2).Name = "NORTH ZONE"; state->dataHeatBal->Zone(2).FloorArea = 10.0; - state->dataHeatBal->Zone(2).ZoneContamControllerSchedIndex = 4; + state->dataHeatBal->Zone(2).zoneContamControllerSched = Sched::GetSchedule(*state, "ZONEADEFFSCH"); state->dataHeatBal->Zone(2).numSpaces = 1; state->dataHeatBal->Zone(2).spaceIndexes.emplace_back(2); state->dataHeatBal->Zone(3).Name = "EAST ZONE"; state->dataHeatBal->Zone(3).FloorArea = 10.0; - state->dataHeatBal->Zone(3).ZoneContamControllerSchedIndex = 4; + state->dataHeatBal->Zone(3).zoneContamControllerSched = Sched::GetSchedule(*state, "ZONEADEFFSCH"); state->dataHeatBal->Zone(3).numSpaces = 1; state->dataHeatBal->Zone(3).spaceIndexes.emplace_back(3); state->dataGlobal->NumOfZones = 3; @@ -1127,8 +1135,8 @@ TEST_F(EnergyPlusFixture, CO2ControlDesignOccupancyTest3Zone) state->dataAirLoop->AirLoopFlow(1).OAFrac = 0.01; // DataAirLoop variable (AirloopHVAC) state->dataAirLoop->AirLoopFlow(1).OAMinFrac = 0.01; // DataAirLoop variable (AirloopHVAC) - state->dataGlobal->NumOfTimeStepInHour = 4; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 15; // must initialize this to get schedules initialized + state->dataGlobal->TimeStepsInHour = 4; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 15; // must initialize this to get schedules initialized state->dataEnvrn->StdBaroPress = StdPressureSeaLevel; state->dataEnvrn->OutDryBulbTemp = 13.0; state->dataEnvrn->OutBaroPress = StdPressureSeaLevel; @@ -1136,7 +1144,6 @@ TEST_F(EnergyPlusFixture, CO2ControlDesignOccupancyTest3Zone) state->dataEnvrn->StdRhoAir = Psychrometrics::PsyRhoAirFnPbTdbW(*state, state->dataEnvrn->OutBaroPress, state->dataEnvrn->OutDryBulbTemp, state->dataEnvrn->OutHumRat); - ScheduleManager::ProcessScheduleInput(*state); InternalHeatGains::GetInternalHeatGainsInput(*state); GetOAControllerInputs(*state); @@ -1151,17 +1158,18 @@ TEST_F(EnergyPlusFixture, CO2ControlDesignOccupancyTest3Zone) EXPECT_NEAR(0.00314899, ventMechanical.VentMechZone(3).ZoneOAPeopleRate, 0.00001); EXPECT_NEAR(0.000407, ventMechanical.VentMechZone(3).ZoneOAAreaRate, 0.00001); - ventMechanical.SchPtr = 1; - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; + ventMechanical.sched = Sched::GetSchedule(*state, "OCCUPY-1"); + ventMechanical.sched->currentVal = 1.0; - ventMechanical.VentMechZone(1).ZoneADEffSchPtr = 2; - ventMechanical.VentMechZone(2).ZoneADEffSchPtr = 2; - ventMechanical.VentMechZone(3).ZoneADEffSchPtr = 2; - state->dataScheduleMgr->Schedule(2).CurrentValue = 1.0; + ventMechanical.VentMechZone(1).zoneADEffSched = Sched::GetSchedule(*state, "ACTSCHD"); + ventMechanical.VentMechZone(2).zoneADEffSched = Sched::GetSchedule(*state, "ACTSCHD"); + ventMechanical.VentMechZone(3).zoneADEffSched = Sched::GetSchedule(*state, "ACTSCHD"); + Sched::GetSchedule(*state, "ACTSCHD")->currentVal = 1.0; + state->dataHeatBal->Zone(1).TotOccupants = 3; state->dataHeatBal->Zone(2).TotOccupants = 3; state->dataHeatBal->Zone(3).TotOccupants = 3; - state->dataScheduleMgr->Schedule(4).CurrentValue = 1.0; + Sched::GetSchedule(*state, "ZONEADEFFSCH")->currentVal = 1.0; state->dataContaminantBalance->ZoneCO2GainFromPeople.allocate(3); state->dataContaminantBalance->ZoneCO2GainFromPeople(1) = 3.82E-8; state->dataContaminantBalance->ZoneCO2GainFromPeople(2) = 3.82E-8; @@ -1391,13 +1399,15 @@ TEST_F(EnergyPlusFixture, MissingDesignOccupancyTest) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); state->dataAirLoop->AirLoopControlInfo.allocate(1); state->dataAirLoop->AirLoopControlInfo(1).LoopFlowRateSet = true; state->dataSize->OARequirements.allocate(1); state->dataSize->ZoneAirDistribution.allocate(1); state->dataSize->ZoneAirDistribution(1).Name = "CM DSZAD WEST ZONE"; - state->dataSize->ZoneAirDistribution(1).ZoneADEffSchPtr = 4; + + state->dataSize->ZoneAirDistribution(1).zoneADEffSched = Sched::GetSchedule(*state, "ZONEADEFFSCH"); state->dataAirLoop->AirLoopFlow.allocate(1); state->dataAirLoop->AirLoopFlow(1).OAFrac = 0.01; // DataAirLoop variable (AirloopHVAC) @@ -1511,7 +1521,8 @@ TEST_F(EnergyPlusFixture, MixedAir_TestHXinOASystem) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + state->dataMixedAir->GetOASysInputFlag = true; state->dataGlobal->BeginEnvrnFlag = true; int AirloopNum = 1; @@ -1656,13 +1667,16 @@ TEST_F(EnergyPlusFixture, MixedAir_HumidifierOnOASystemTest) ASSERT_TRUE(process_idf(idf_objects)); - state->dataGlobal->NumOfTimeStepInHour = 1; - state->dataGlobal->MinutesPerTimeStep = 60 / state->dataGlobal->NumOfTimeStepInHour; + state->dataGlobal->TimeStepsInHour = 1; + state->dataGlobal->MinutesInTimeStep = 60 / state->dataGlobal->TimeStepsInHour; + state->init_state(*state); + state->dataGlobal->TimeStep = 1; state->dataGlobal->HourOfDay = 1; state->dataEnvrn->DayOfWeek = 1; state->dataEnvrn->DayOfYear_Schedule = 1; - ScheduleManager::UpdateScheduleValues(*state); + + Sched::UpdateScheduleVals(*state); state->dataMixedAir->GetOASysInputFlag = true; state->dataGlobal->BeginEnvrnFlag = true; @@ -1752,6 +1766,7 @@ TEST_F(EnergyPlusFixture, FreezingCheckTest) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); GetOAControllerInputs(*state); @@ -1802,7 +1817,7 @@ TEST_F(EnergyPlusFixture, FreezingCheckTest) ; // OA inlet (actuated) air nodes, dry air state->dataMixedAir->OAController(1).CoolCoilFreezeCheck = true; - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; + Sched::GetSchedule(*state, "OAFRACTIONSCHED")->currentVal = 1.0; state->dataMixedAir->OAController(OAControllerNum).CalcOAController(*state, AirLoopNum, true); @@ -1896,6 +1911,8 @@ TEST_F(EnergyPlusFixture, MixedAir_MissingHIghRHControlInputTest) compare_err_stream(""); // just for debugging + state->init_state(*state); + bool ErrorsFound(false); // If errors detected in input int ControllerNum(0); // Controller number int NumArg(0); @@ -2026,7 +2043,8 @@ TEST_F(EnergyPlusFixture, MixedAir_HIghRHControlTest) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + compare_err_stream(""); // just for debugging bool ErrorsFound(false); // If errors detected in input @@ -2197,6 +2215,7 @@ TEST_F(EnergyPlusFixture, OAControllerMixedAirSPTest) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); state->dataAirLoop->AirLoopFlow.allocate(1); state->dataAirLoop->AirLoopControlInfo.allocate(1); @@ -2347,6 +2366,8 @@ TEST_F(EnergyPlusFixture, MixedAir_MiscGetsPart1) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + GetOAControllerInputs(*state); EXPECT_EQ(1, GetNumOAMixers(*state)); @@ -5760,6 +5781,8 @@ TEST_F(EnergyPlusFixture, MixedAir_MiscGetsPart2) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + GetOAControllerInputs(*state); EXPECT_EQ(6, GetNumOAMixers(*state)); @@ -5843,7 +5866,8 @@ TEST_F(EnergyPlusFixture, MechVentController_VRPCap) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + Real64 SysMassFlow(0.0); // System supply mass flow rate [kg/s] Real64 OAMassFlow(0.0); // OA mass flow rate [kg/s] Real64 ExpectedOAMassFlow(0.8); // System design OA flow rate @@ -5952,7 +5976,8 @@ TEST_F(EnergyPlusFixture, MechVentController_VRPNoCap) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + Real64 OAMassFlow = 0.0; // OA mass flow rate [kg/s] bool ErrorsFound = false; @@ -6112,7 +6137,8 @@ TEST_F(EnergyPlusFixture, MechVentController_ACHflow) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + Real64 SysMassFlow(0.0); // System supply mass flow rate [kg/s] Real64 OAMassFlow(0.0); // OA mass flow rate [kg/s] Real64 ExpectedOAMassFlow(0.0027778); // System design OA flow rate @@ -6160,7 +6186,8 @@ TEST_F(EnergyPlusFixture, MechVentController_IAQPTests) " Zone, Zone 2;"}); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + bool ErrorsFound(false); GetZoneData(*state, ErrorsFound); EXPECT_FALSE(ErrorsFound); @@ -6193,10 +6220,10 @@ TEST_F(EnergyPlusFixture, MechVentController_IAQPTests) EXPECT_EQ(1.5, OAMassFlow); // Case 4 - System OA method = IndoorAirQualityProcedureCombined, SOAM_IAQPCOM, set zone OA schedules to alwaysoff - state->dataScheduleMgr->Schedule.allocate(1); - state->dataScheduleMgr->Schedule(1).CurrentValue = 0.0; - state->dataMixedAir->VentilationMechanical(1).VentMechZone(1).ZoneOASchPtr = 1; - state->dataMixedAir->VentilationMechanical(1).VentMechZone(2).ZoneOASchPtr = 1; + auto *sched = Sched::AddScheduleConstant(*state, "OCCUPY-1"); + sched->currentVal = 0.0; + state->dataMixedAir->VentilationMechanical(1).VentMechZone(1).zoneOASched = sched; + state->dataMixedAir->VentilationMechanical(1).VentMechZone(2).zoneOASched = sched; state->dataMixedAir->VentilationMechanical(1).SystemOAMethod = SysOAMethod::IAQPCOM; OAMassFlow = state->dataMixedAir->VentilationMechanical(1).CalcMechVentController(*state, SysMassFlow); @@ -6205,9 +6232,6 @@ TEST_F(EnergyPlusFixture, MechVentController_IAQPTests) TEST_F(EnergyPlusFixture, MechVentController_ZoneSumTests) { - state->dataContaminantBalance->Contaminant.CO2Simulation = true; - state->dataContaminantBalance->Contaminant.CO2OutdoorSchedPtr = 1; - std::string const idf_objects = delimited_string({" Controller:MechanicalVentilation,", " DCVObject, !- Name", " , !- Availability Schedule Name", @@ -6342,19 +6366,23 @@ TEST_F(EnergyPlusFixture, MechVentController_ZoneSumTests) " 600; !- Floor Area {m2}"}); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + + state->dataContaminantBalance->Contaminant.CO2Simulation = true; + state->dataContaminantBalance->Contaminant.CO2OutdoorSched = Sched::GetSchedule(*state, "ZONE 1 OA SCHEDULE"); bool ErrorsFound(false); GetZoneData(*state, ErrorsFound); EXPECT_FALSE(ErrorsFound); // Initialize schedule values - state->dataGlobal->NumOfTimeStepInHour = 1; - state->dataGlobal->MinutesPerTimeStep = 60 / state->dataGlobal->NumOfTimeStepInHour; + state->dataGlobal->TimeStepsInHour = 1; + state->dataGlobal->MinutesInTimeStep = 60 / state->dataGlobal->TimeStepsInHour; state->dataGlobal->TimeStep = 1; state->dataGlobal->HourOfDay = 1; state->dataEnvrn->DayOfWeek = 1; state->dataEnvrn->DayOfYear_Schedule = 100; - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); // Initialize zone areas and volumes - too many other things need to be set up to do these in the normal routines int NumZones(6); @@ -6401,16 +6429,16 @@ TEST_F(EnergyPlusFixture, MechVentController_ZoneSumTests) EXPECT_NEAR(1951.5, OAMassFlow, 0.00001); // Case 2 - Turn off Zone 4-6 - state->dataScheduleMgr->Schedule(4).CurrentValue = 0.0; - state->dataScheduleMgr->Schedule(5).CurrentValue = 0.0; - state->dataScheduleMgr->Schedule(6).CurrentValue = 0.0; + Sched::GetSchedule(*state, "ZONE 4 OA SCHEDULE")->currentVal = 0.0; + Sched::GetSchedule(*state, "ZONE 5 OA SCHEDULE")->currentVal = 0.0; + Sched::GetSchedule(*state, "ZONE 6 OA SCHEDULE")->currentVal = 0.0; OAMassFlow = state->dataMixedAir->VentilationMechanical(1).CalcMechVentController(*state, SysMassFlow); EXPECT_NEAR(41.0, OAMassFlow, 0.00001); // Case 3 - Turn off remaining zones - state->dataScheduleMgr->Schedule(1).CurrentValue = 0.0; - state->dataScheduleMgr->Schedule(2).CurrentValue = 0.0; - state->dataScheduleMgr->Schedule(3).CurrentValue = 0.0; + Sched::GetSchedule(*state, "ZONE 1 OA SCHEDULE")->currentVal = 0.0; + Sched::GetSchedule(*state, "ZONE 2 OA SCHEDULE")->currentVal = 0.0; + Sched::GetSchedule(*state, "ZONE 3 OA SCHEDULE")->currentVal = 0.0; OAMassFlow = state->dataMixedAir->VentilationMechanical(1).CalcMechVentController(*state, SysMassFlow); EXPECT_EQ(0.0, OAMassFlow); @@ -6419,10 +6447,6 @@ TEST_F(EnergyPlusFixture, MechVentController_ZoneSumTests) TEST_F(EnergyPlusFixture, CO2ControlDesignOARateTest) { - // Test a new feature: Proportional Demand Control Ventilation (DCV) Enhancements - state->dataContaminantBalance->Contaminant.CO2Simulation = true; - state->dataContaminantBalance->Contaminant.CO2OutdoorSchedPtr = 1; - std::string const idf_objects = delimited_string({ " OutdoorAir:Node,", " Outside Air Inlet Node; !- Name", @@ -6491,13 +6515,18 @@ TEST_F(EnergyPlusFixture, CO2ControlDesignOARateTest) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + + // Test a new feature: Proportional Demand Control Ventilation (DCV) Enhancements + state->dataContaminantBalance->Contaminant.CO2Simulation = true; + state->dataContaminantBalance->Contaminant.CO2OutdoorSched = Sched::GetSchedule(*state, "VENTSCHEDULE"); state->dataGlobal->CurrentTime = 0.25; state->dataContaminantBalance->ContaminantControlledZone.allocate(1); - state->dataContaminantBalance->ContaminantControlledZone(1).AvaiSchedPtr = 4; - state->dataContaminantBalance->ContaminantControlledZone(1).SPSchedIndex = 5; - state->dataContaminantBalance->ContaminantControlledZone(1).ZoneMinCO2SchedIndex = 6; - state->dataContaminantBalance->ContaminantControlledZone(1).ZoneMaxCO2SchedIndex = 7; + state->dataContaminantBalance->ContaminantControlledZone(1).availSched = Sched::GetSchedule(*state, "CO2AVAILSCHEDULE"); + state->dataContaminantBalance->ContaminantControlledZone(1).setptSched = Sched::GetSchedule(*state, "CO2SETPOINTSCHEDULE"); + state->dataContaminantBalance->ContaminantControlledZone(1).zoneMinCO2Sched = Sched::GetSchedule(*state, "CO2MINSCHEDULE"); + state->dataContaminantBalance->ContaminantControlledZone(1).zoneMaxCO2Sched = Sched::GetSchedule(*state, "CO2MAXSCHEDULE"); state->dataAirLoop->AirLoopControlInfo.allocate(1); state->dataAirLoop->AirLoopControlInfo(1).LoopFlowRateSet = true; @@ -6506,16 +6535,17 @@ TEST_F(EnergyPlusFixture, CO2ControlDesignOARateTest) state->dataSize->OARequirements(1).OAFlowMethod = OAFlowCalcMethod::Sum; state->dataSize->OARequirements(1).OAFlowPerPerson = 0.003149; state->dataSize->OARequirements(1).OAFlowPerArea = 0.000407; - state->dataSize->OARequirements(1).OAPropCtlMinRateSchPtr = 8; + state->dataSize->OARequirements(1).oaFlowFracSched = Sched::GetScheduleAlwaysOn(*state); + state->dataSize->OARequirements(1).oaPropCtlMinRateSched = Sched::GetSchedule(*state, "MINIMUM OUTDOOR AIR FLOW RATE SCHEDULE"); state->dataSize->ZoneAirDistribution.allocate(1); state->dataSize->ZoneAirDistribution(1).Name = "CM DSZAD WEST ZONE"; - state->dataSize->ZoneAirDistribution(1).ZoneADEffSchPtr = 4; + state->dataSize->ZoneAirDistribution(1).zoneADEffSched = Sched::GetSchedule(*state, "CO2AVAILSCHEDULE"); state->dataHeatBal->Zone.allocate(1); state->dataHeatBal->Zone(1).Name = "WEST ZONE"; state->dataHeatBal->Zone(1).FloorArea = 10.0; - state->dataHeatBal->Zone(1).ZoneContamControllerSchedIndex = 4; + state->dataHeatBal->Zone(1).zoneContamControllerSched = Sched::GetSchedule(*state, "CO2AVAILSCHEDULE"); state->dataAirLoop->AirLoopFlow.allocate(1); state->dataAirLoop->AirLoopFlow(1).OAFrac = 0.01; // DataAirLoop variable (AirloopHVAC) @@ -6532,19 +6562,20 @@ TEST_F(EnergyPlusFixture, CO2ControlDesignOARateTest) state->dataMixedAir->OAController(1).MixMassFlow = 1.7 * state->dataEnvrn->StdRhoAir; state->dataMixedAir->OAController(1).MaxOAMassFlowRate = 1.7 * state->dataEnvrn->StdRhoAir; state->dataAirLoop->AirLoopFlow(1).DesSupply = 1.7; - state->dataMixedAir->VentilationMechanical(1).SchPtr = 1; - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; + state->dataMixedAir->VentilationMechanical(1).sched = Sched::GetSchedule(*state, "VENTSCHEDULE"); + + Sched::GetSchedule(*state, "VENTSCHEDULE")->currentVal = 1.0; - state->dataMixedAir->VentilationMechanical(1).VentMechZone(1).ZoneADEffSchPtr = 2; - state->dataScheduleMgr->Schedule(2).CurrentValue = 1.0; + state->dataMixedAir->VentilationMechanical(1).VentMechZone(1).zoneADEffSched = Sched::GetSchedule(*state, "ZONEADEFFSCH"); + Sched::GetSchedule(*state, "ZONEADEFFSCH")->currentVal = 1.0; state->dataHeatBal->TotPeople = 1; state->dataHeatBal->People.allocate(1); state->dataHeatBal->People(1).Name = "WestPeople"; state->dataHeatBal->People(1).ZonePtr = 1; state->dataHeatBal->People(1).NumberOfPeople = 3; state->dataHeatBal->Zone(1).TotOccupants = 3; - state->dataScheduleMgr->Schedule(3).CurrentValue = 0.1; - state->dataScheduleMgr->Schedule(4).CurrentValue = 1.0; + Sched::GetSchedule(*state, "OAFRACTIONSCHED")->currentVal = 0.1; + Sched::GetSchedule(*state, "CO2AVAILSCHEDULE")->currentVal = 1.0; state->dataContaminantBalance->ZoneCO2GainFromPeople.allocate(1); state->dataContaminantBalance->ZoneCO2GainFromPeople(1) = 3.82E-8; state->dataContaminantBalance->OutdoorCO2 = 400; @@ -6564,12 +6595,12 @@ TEST_F(EnergyPlusFixture, CO2ControlDesignOARateTest) state->dataZoneEnergyDemand->ZoneSysEnergyDemand.allocate(1); state->dataHeatBal->ZoneIntGain.allocate(1); state->dataHeatBal->ZoneIntGain(1).NOFOCC = 0.1; - state->dataScheduleMgr->Schedule(5).CurrentValue = 900.0; - state->dataScheduleMgr->Schedule(6).CurrentValue = 300.0; - state->dataScheduleMgr->Schedule(7).CurrentValue = 900.0; - state->dataHeatBal->Zone(1).ZoneMinCO2SchedIndex = 6; - state->dataHeatBal->Zone(1).ZoneMaxCO2SchedIndex = 7; - state->dataScheduleMgr->Schedule(8).CurrentValue = 0.01; + Sched::GetSchedule(*state, "CO2SETPOINTSCHEDULE")->currentVal = 900.0; + Sched::GetSchedule(*state, "CO2MINSCHEDULE")->currentVal = 300.0; + Sched::GetSchedule(*state, "CO2MAXSCHEDULE")->currentVal = 900.0; + state->dataHeatBal->Zone(1).zoneMinCO2Sched = Sched::GetSchedule(*state, "CO2MINSCHEDULE"); + state->dataHeatBal->Zone(1).zoneMaxCO2Sched = Sched::GetSchedule(*state, "CO2MAXSCHEDULE"); + Sched::GetSchedule(*state, "MINIMUM OUTDOOR AIR FLOW RATE SCHEDULE")->currentVal = 0.01; state->dataMixedAir->OAController(1).CalcOAController(*state, 1, true); @@ -6826,7 +6857,8 @@ TEST_F(EnergyPlusFixture, MixedAir_OAControllerOrderInControllersListTest) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + GetOAControllerInputs(*state); GetOutsideAirSysInputs(*state); @@ -6909,6 +6941,8 @@ TEST_F(EnergyPlusFixture, OAController_ProportionalMinimum_HXBypassTest) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + GetOAControllerInputs(*state); EXPECT_EQ(2, state->dataMixedAir->OAController(1).OANode); EXPECT_TRUE(OutAirNodeManager::CheckOutAirNodeNumber(*state, state->dataMixedAir->OAController(1).OANode)); @@ -7091,6 +7125,8 @@ TEST_F(EnergyPlusFixture, OAController_FixedMinimum_MinimumLimitTypeTest) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + GetOutsideAirSysInputs(*state); EXPECT_EQ(1, state->dataAirLoop->NumOASystems); EXPECT_EQ("OA SYS", state->dataAirLoop->OutsideAirSys(1).Name); @@ -7294,6 +7330,8 @@ TEST_F(EnergyPlusFixture, OAController_HighExhaustMassFlowTest) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + GetOutsideAirSysInputs(*state); EXPECT_EQ(1, state->dataAirLoop->NumOASystems); EXPECT_EQ("OA SYS", state->dataAirLoop->OutsideAirSys(1).Name); @@ -7541,6 +7579,8 @@ TEST_F(EnergyPlusFixture, OAController_LowExhaustMassFlowTest) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + GetOutsideAirSysInputs(*state); EXPECT_EQ(1, state->dataAirLoop->NumOASystems); EXPECT_EQ("OA SYS", state->dataAirLoop->OutsideAirSys(1).Name); @@ -7749,6 +7789,8 @@ TEST_F(EnergyPlusFixture, MixedAir_TemperatureError) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + GetOAControllerInputs(*state); EXPECT_EQ(1, GetNumOAMixers(*state)); diff --git a/tst/EnergyPlus/unit/OutAirNodeManager.unit.cc b/tst/EnergyPlus/unit/OutAirNodeManager.unit.cc index 41105bf25dc..8e7ec9abe8d 100644 --- a/tst/EnergyPlus/unit/OutAirNodeManager.unit.cc +++ b/tst/EnergyPlus/unit/OutAirNodeManager.unit.cc @@ -67,7 +67,6 @@ TEST_F(EnergyPlusFixture, OutAirNodeManager_OATdbTwbOverrideTest) state->dataOutAirNodeMgr->NumOutsideAirNodes = 3; state->dataOutAirNodeMgr->OutsideAirNodeList.allocate(3); state->dataLoopNodes->Node.allocate(3); - state->dataScheduleMgr->Schedule.allocate(2); state->dataEnvrn->OutDryBulbTemp = 25.0; state->dataEnvrn->OutWetBulbTemp = 15.0; @@ -77,13 +76,14 @@ TEST_F(EnergyPlusFixture, OutAirNodeManager_OATdbTwbOverrideTest) state->dataEnvrn->OutHumRat = Psychrometrics::PsyWFnTdbTwbPb(*state, state->dataEnvrn->OutDryBulbTemp, state->dataEnvrn->OutWetBulbTemp, state->dataEnvrn->OutBaroPress); - state->dataScheduleMgr->Schedule(1).CurrentValue = 24.0; state->dataOutAirNodeMgr->OutsideAirNodeList(1) = 1; state->dataOutAirNodeMgr->OutsideAirNodeList(2) = 2; state->dataOutAirNodeMgr->OutsideAirNodeList(3) = 3; // Scheduled value state->dataLoopNodes->Node(1).IsLocalNode = true; - state->dataLoopNodes->Node(1).OutAirDryBulbSchedNum = 1; + state->dataLoopNodes->Node(1).outAirDryBulbSched = Sched::AddScheduleConstant(*state, "Out Air Dry Bulb"); + state->dataLoopNodes->Node(1).outAirDryBulbSched->currentVal = 24.0; + state->dataLoopNodes->Node(1).OutAirDryBulb = state->dataEnvrn->OutDryBulbTemp; state->dataLoopNodes->Node(1).OutAirWetBulb = state->dataEnvrn->OutWetBulbTemp; // EMS override value diff --git a/tst/EnergyPlus/unit/OutdoorAirUnit.unit.cc b/tst/EnergyPlus/unit/OutdoorAirUnit.unit.cc index 597d8498c8f..147362df63a 100644 --- a/tst/EnergyPlus/unit/OutdoorAirUnit.unit.cc +++ b/tst/EnergyPlus/unit/OutdoorAirUnit.unit.cc @@ -91,7 +91,6 @@ using namespace EnergyPlus::Fans; using namespace EnergyPlus::HeatBalanceManager; using namespace OutputReportPredefined; using namespace EnergyPlus::Psychrometrics; -using namespace EnergyPlus::ScheduleManager; using namespace EnergyPlus::SteamCoils; using namespace EnergyPlus::WaterCoils; @@ -287,7 +286,8 @@ TEST_F(EnergyPlusFixture, OutdoorAirUnit_AutoSize) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + state->dataGlobal->CurrentTime = 0.25; state->dataGlobal->BeginEnvrnFlag = true; state->dataSize->CurZoneEqNum = 1; @@ -302,7 +302,6 @@ TEST_F(EnergyPlusFixture, OutdoorAirUnit_AutoSize) state->dataZoneEnergyDemand->ZoneSysEnergyDemand.allocate(1); - ProcessScheduleInput(*state); // read schedules GetCurveInput(*state); // read curves GetZoneData(*state, ErrorsFound); // read zone data EXPECT_FALSE(ErrorsFound); @@ -334,9 +333,9 @@ TEST_F(EnergyPlusFixture, OutdoorAirUnit_AutoSize) ZoneInletNode = OutdoorAirUnit::GetOutdoorAirUnitZoneInletNode(*state, OAUnitNum); // schedule values will get reset to 0 if initialized before GetInput - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; // enable the VRF condenser - state->dataScheduleMgr->Schedule(2).CurrentValue = 1.0; // enable the terminal unit - state->dataScheduleMgr->Schedule(3).CurrentValue = 1.0; // turn on fan + Sched::GetSchedule(*state, "AVAILSCHED")->currentVal = 1.0; // enable the VRF condenser + Sched::GetSchedule(*state, "OAULOCTRLTEMP")->currentVal = 1.0; // enable the terminal unit + Sched::GetSchedule(*state, "OAUHICTRLTEMP")->currentVal = 1.0; // turn on fan int EAFanInletNode = state->dataFans->fans(2)->inletNodeNum; state->dataLoopNodes->Node(EAFanInletNode).MassFlowRate = 0.60215437; // zone exhaust flow rate state->dataLoopNodes->Node(EAFanInletNode).MassFlowRateMaxAvail = 0.60215437; // exhaust fan will not turn on unless max avail is set @@ -559,23 +558,20 @@ TEST_F(EnergyPlusFixture, OutdoorAirUnit_WaterCoolingCoilAutoSizeTest) }); ASSERT_TRUE(process_idf(idf_objects)); + state->dataGlobal->TimeStepsInHour = 1; + state->dataGlobal->MinutesInTimeStep = 60; + state->init_state(*state); state->dataEnvrn->OutBaroPress = 101325.0; state->dataGlobal->TimeStep = 1; - state->dataGlobal->NumOfTimeStepInHour = 1; - state->dataGlobal->MinutesPerTimeStep = 60; state->dataGlobal->DoingSizing = true; - InitializePsychRoutines(*state); - bool ErrorsFound(false); GetZoneData(*state, ErrorsFound); EXPECT_FALSE(ErrorsFound); EXPECT_EQ("THERMAL ZONE 1", state->dataHeatBal->Zone(1).Name); GetZoneEquipmentData(*state); - ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; Fans::GetFanInput(*state); OutdoorAirUnit::GetOutdoorAirUnitInputs(*state); @@ -637,13 +633,13 @@ TEST_F(EnergyPlusFixture, OutdoorAirUnit_WaterCoolingCoilAutoSizeTest) state->dataEnvrn->HolidayIndex = 0; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, state->dataGlobal->HourOfDay); - UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); state->dataSize->ZoneEqSizing.allocate(1); state->dataZoneEnergyDemand->CurDeadBandOrSetback.allocate(1); state->dataZoneEnergyDemand->CurDeadBandOrSetback(1) = false; state->dataHeatBalFanSys->TempControlType.allocate(1); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::DualSetPointWithDeadBand; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::DualHeatCool; state->dataSize->ZoneSizingRunDone = true; state->dataSize->CurZoneEqNum = 1; @@ -871,24 +867,21 @@ TEST_F(EnergyPlusFixture, OutdoorAirUnit_SteamHeatingCoilAutoSizeTest) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->dataGlobal->TimeStepsInHour = 1; + state->dataGlobal->MinutesInTimeStep = 60; + state->init_state(*state); + state->dataEnvrn->StdRhoAir = 1.20; state->dataEnvrn->OutBaroPress = 101325.0; state->dataGlobal->TimeStep = 1; - state->dataGlobal->NumOfTimeStepInHour = 1; - state->dataGlobal->MinutesPerTimeStep = 60; state->dataGlobal->DoingSizing = true; - InitializePsychRoutines(*state); - bool ErrorsFound(false); GetZoneData(*state, ErrorsFound); EXPECT_FALSE(ErrorsFound); EXPECT_EQ("THERMAL ZONE 1", state->dataHeatBal->Zone(1).Name); GetZoneEquipmentData(*state); - ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; Fans::GetFanInput(*state); OutdoorAirUnit::GetOutdoorAirUnitInputs(*state); @@ -950,13 +943,13 @@ TEST_F(EnergyPlusFixture, OutdoorAirUnit_SteamHeatingCoilAutoSizeTest) state->dataEnvrn->HolidayIndex = 0; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, state->dataGlobal->HourOfDay); - UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); state->dataSize->ZoneEqSizing.allocate(1); state->dataZoneEnergyDemand->CurDeadBandOrSetback.allocate(1); state->dataZoneEnergyDemand->CurDeadBandOrSetback(1) = false; state->dataHeatBalFanSys->TempControlType.allocate(1); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::DualSetPointWithDeadBand; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::DualHeatCool; state->dataSize->ZoneSizingRunDone = true; state->dataSize->CurZoneEqNum = 1; diff --git a/tst/EnergyPlus/unit/OutputFiles.unit.cc b/tst/EnergyPlus/unit/OutputFiles.unit.cc index 62a7f0d0747..7bf52d53cc7 100644 --- a/tst/EnergyPlus/unit/OutputFiles.unit.cc +++ b/tst/EnergyPlus/unit/OutputFiles.unit.cc @@ -276,6 +276,8 @@ TEST_F(EnergyPlusFixture, OutputControlFiles) " ** ~~~ ** See InputOutputReference document for more details.", " ************* Object=Building=Bldg", " ** ~~~ ** Object=GlobalGeometryRules", + " ** ~~~ ** Object=Timestep", + " ** ~~~ ** Object=Version" }); compare_err_stream(expected_error); diff --git a/tst/EnergyPlus/unit/OutputProcessor.unit.cc b/tst/EnergyPlus/unit/OutputProcessor.unit.cc index effaeb282d0..727f76c0cc4 100644 --- a/tst/EnergyPlus/unit/OutputProcessor.unit.cc +++ b/tst/EnergyPlus/unit/OutputProcessor.unit.cc @@ -662,7 +662,7 @@ namespace OutputProcessor { EndMinute, StartMinute, DSTIndicator, - ScheduleManager::dayTypeNames[CurDayType]); + Sched::dayTypeNames[CurDayType]); EXPECT_TRUE(compare_mtr_stream(delimited_string({"1,1,12,21, 0, 1, 0.00,10.00,WinterDesignDay"}, "\n"))); // TSMeter @@ -678,7 +678,7 @@ namespace OutputProcessor { EndMinute, StartMinute, DSTIndicator, - ScheduleManager::dayTypeNames[CurDayType]); + Sched::dayTypeNames[CurDayType]); EXPECT_TRUE(compare_mtr_stream(delimited_string({"1,1,12,21, 0, 1, 0.00,10.00,WinterDesignDay"}, "\n"))); // HRMeter @@ -694,7 +694,7 @@ namespace OutputProcessor { -1, // EndMinute -1, // StartMinute DSTIndicator, - ScheduleManager::dayTypeNames[CurDayType]); + Sched::dayTypeNames[CurDayType]); EXPECT_TRUE(compare_mtr_stream(delimited_string({"1,1,12,21, 0, 1, 0.00,60.00,WinterDesignDay"}, "\n"))); // DYMeter @@ -710,7 +710,7 @@ namespace OutputProcessor { -1, // EndMinute -1, // StartMinute DSTIndicator, - ScheduleManager::dayTypeNames[CurDayType]); + Sched::dayTypeNames[CurDayType]); EXPECT_TRUE(compare_mtr_stream(delimited_string({"1,1,12,21, 0,WinterDesignDay"}, "\n"))); // MNMeter @@ -778,7 +778,7 @@ namespace OutputProcessor { TEST_F(SQLiteFixture, OutputProcessor_writeReportMeterData) { auto &sql = state->dataSQLiteProcedures->sqlite; - state->dataGlobal->MinutesPerTimeStep = 10; + state->dataGlobal->MinutesInTimeStep = 10; sql->createSQLiteTimeIndexRecord(ReportFreq::Simulation, 1, 1, 0, 2017, false); sql->createSQLiteReportDictionaryRecord( @@ -1552,7 +1552,7 @@ namespace OutputProcessor { rVar.key = "keyedValue"; rVar.name = "variableName"; rVar.unitNameCustomEMS = ""; - rVar.SchedPtr = 0; + rVar.sched = nullptr; rVar.writeReportDictionaryItem(*state); EXPECT_TRUE(compare_eso_stream(delimited_string({"1,1,keyedValue,variableName [m3/s] !TimeStep"}, "\n"))); @@ -1564,19 +1564,16 @@ namespace OutputProcessor { rVar.writeReportDictionaryItem(*state); EXPECT_TRUE(compare_eso_stream(delimited_string({"2,1,keyedValue,variableName [m3/s] !TimeStep"}, "\n"))); - state->dataScheduleMgr->Schedule.allocate(1); - state->dataScheduleMgr->Schedule(1).Name = "scheduleName"; - rVar.ReportID = 3; rVar.storeType = StoreType::Average; - rVar.SchedPtr = 1; + rVar.sched = Sched::AddScheduleConstant(*state, "scheduleName"); rVar.writeReportDictionaryItem(*state); EXPECT_TRUE(compare_eso_stream(delimited_string({"3,1,keyedValue,variableName [m3/s] !TimeStep,scheduleName"}, "\n"))); rVar.ReportID = 4; rVar.timeStepType = TimeStepType::System; - rVar.SchedPtr = 0; + rVar.sched = nullptr; rVar.writeReportDictionaryItem(*state); EXPECT_TRUE(compare_eso_stream(delimited_string({"4,1,keyedValue,variableName [m3/s] !TimeStep"}, "\n"))); @@ -1597,13 +1594,13 @@ namespace OutputProcessor { rVar.ReportID = 8; rVar.storeType = StoreType::Average; - rVar.SchedPtr = 1; + rVar.sched = Sched::GetSchedule(*state, "SCHEDULENAME"); rVar.writeReportDictionaryItem(*state); EXPECT_TRUE(compare_eso_stream(delimited_string({"8,1,keyedValue,variableName [m3/s] !Each Call,scheduleName"}, "\n"))); rVar.ReportID = 9; - rVar.SchedPtr = 0; + rVar.sched = nullptr; rVar.timeStepType = TimeStepType::System; rVar.writeReportDictionaryItem(*state); @@ -1627,14 +1624,14 @@ namespace OutputProcessor { rVar.ReportID = 13; rVar.storeType = StoreType::Average; - rVar.SchedPtr = 1; + rVar.sched = Sched::GetSchedule(*state, "SCHEDULENAME"); rVar.writeReportDictionaryItem(*state); EXPECT_TRUE(op->freqTrackingVariables[(int)ReportFreq::Hour]); op->freqTrackingVariables[(int)ReportFreq::Hour] = false; EXPECT_TRUE(compare_eso_stream(delimited_string({"13,1,keyedValue,variableName [m3/s] !Hourly,scheduleName"}, "\n"))); rVar.ReportID = 14; - rVar.SchedPtr = 0; + rVar.sched = nullptr; rVar.timeStepType = TimeStepType::System; rVar.writeReportDictionaryItem(*state); EXPECT_TRUE(op->freqTrackingVariables[(int)ReportFreq::Hour]); @@ -1662,7 +1659,7 @@ namespace OutputProcessor { rVar.ReportID = 18; rVar.storeType = StoreType::Average; - rVar.SchedPtr = 1; + rVar.sched = Sched::GetSchedule(*state, "SCHEDULENAME"); rVar.writeReportDictionaryItem(*state); EXPECT_TRUE(op->freqTrackingVariables[(int)ReportFreq::Day]); op->freqTrackingVariables[(int)ReportFreq::Day] = false; @@ -1671,7 +1668,7 @@ namespace OutputProcessor { rVar.ReportID = 19; rVar.timeStepType = TimeStepType::System; - rVar.SchedPtr = 0; + rVar.sched = nullptr; rVar.writeReportDictionaryItem(*state); EXPECT_TRUE(op->freqTrackingVariables[(int)ReportFreq::Day]); op->freqTrackingVariables[(int)ReportFreq::Day] = false; @@ -1697,7 +1694,7 @@ namespace OutputProcessor { rVar.ReportID = 23; rVar.storeType = StoreType::Average; - rVar.SchedPtr = 1; + rVar.sched = Sched::GetSchedule(*state, "SCHEDULENAME"); rVar.writeReportDictionaryItem(*state); EXPECT_TRUE(op->freqTrackingVariables[(int)ReportFreq::Month]); op->freqTrackingVariables[(int)ReportFreq::Month] = false; @@ -1706,7 +1703,7 @@ namespace OutputProcessor { rVar.ReportID = 24; rVar.timeStepType = TimeStepType::System; - rVar.SchedPtr = 0; + rVar.sched = nullptr; rVar.writeReportDictionaryItem(*state); EXPECT_TRUE(op->freqTrackingVariables[(int)ReportFreq::Month]); op->freqTrackingVariables[(int)ReportFreq::Month] = false; @@ -1732,7 +1729,7 @@ namespace OutputProcessor { rVar.ReportID = 28; rVar.storeType = StoreType::Average; - rVar.SchedPtr = 1; + rVar.sched = Sched::GetSchedule(*state, "SCHEDULENAME"); rVar.writeReportDictionaryItem(*state); EXPECT_TRUE(op->freqTrackingVariables[(int)ReportFreq::Simulation]); op->freqTrackingVariables[(int)ReportFreq::Simulation] = false; @@ -1741,7 +1738,7 @@ namespace OutputProcessor { rVar.ReportID = 29; rVar.timeStepType = TimeStepType::System; - rVar.SchedPtr = 0; + rVar.sched = nullptr; rVar.writeReportDictionaryItem(*state); EXPECT_TRUE(op->freqTrackingVariables[(int)ReportFreq::Simulation]); op->freqTrackingVariables[(int)ReportFreq::Simulation] = false; @@ -2379,36 +2376,31 @@ namespace OutputProcessor { EXPECT_EQ("", op->reqVars[0]->key); EXPECT_EQ("SITE OUTDOOR AIR DRYBULB TEMPERATURE", op->reqVars[0]->name); EXPECT_EQ((int)ReportFreq::TimeStep, (int)op->reqVars[0]->freq); - EXPECT_EQ(0, op->reqVars[0]->SchedPtr); - EXPECT_EQ("", op->reqVars[0]->SchedName); + EXPECT_EQ(nullptr, op->reqVars[0]->sched); EXPECT_FALSE(op->reqVars[0]->Used); EXPECT_EQ("", op->reqVars[1]->key); EXPECT_EQ("SITE OUTDOOR AIR DRYBULB TEMPERATURE", op->reqVars[1]->name); EXPECT_EQ((int)ReportFreq::Hour, (int)op->reqVars[1]->freq); - EXPECT_EQ(0, op->reqVars[1]->SchedPtr); - EXPECT_EQ("", op->reqVars[1]->SchedName); + EXPECT_EQ(nullptr, op->reqVars[1]->sched); EXPECT_FALSE(op->reqVars[1]->Used); EXPECT_EQ("", op->reqVars[2]->key); EXPECT_EQ("SITE OUTDOOR AIR DRYBULB TEMPERATURE", op->reqVars[2]->name); EXPECT_EQ((int)ReportFreq::Day, (int)op->reqVars[2]->freq); - EXPECT_EQ(0, op->reqVars[2]->SchedPtr); - EXPECT_EQ("", op->reqVars[2]->SchedName); + EXPECT_EQ(nullptr, op->reqVars[2]->sched); EXPECT_FALSE(op->reqVars[2]->Used); EXPECT_EQ("", op->reqVars[3]->key); EXPECT_EQ("SITE OUTDOOR AIR DRYBULB TEMPERATURE", op->reqVars[3]->name); EXPECT_EQ((int)ReportFreq::Month, (int)op->reqVars[3]->freq); - EXPECT_EQ(0, op->reqVars[3]->SchedPtr); - EXPECT_EQ("", op->reqVars[3]->SchedName); + EXPECT_EQ(nullptr, op->reqVars[3]->sched); EXPECT_FALSE(op->reqVars[3]->Used); EXPECT_EQ("", op->reqVars[4]->key); EXPECT_EQ("SITE OUTDOOR AIR DRYBULB TEMPERATURE", op->reqVars[4]->name); EXPECT_EQ((int)ReportFreq::Simulation, (int)op->reqVars[4]->freq); - EXPECT_EQ(0, op->reqVars[4]->SchedPtr); - EXPECT_EQ("", op->reqVars[4]->SchedName); + EXPECT_EQ(nullptr, op->reqVars[4]->sched); EXPECT_FALSE(op->reqVars[4]->Used); } @@ -2439,43 +2431,37 @@ namespace OutputProcessor { EXPECT_EQ("", op->reqVars[0]->key); EXPECT_EQ("SITE OUTDOOR AIR DRYBULB TEMPERATURE", op->reqVars[0]->name); EXPECT_EQ((int)ReportFreq::TimeStep, (int)op->reqVars[0]->freq); - EXPECT_EQ(0, op->reqVars[0]->SchedPtr); - EXPECT_EQ("", op->reqVars[0]->SchedName); + EXPECT_EQ(nullptr, op->reqVars[0]->sched); EXPECT_TRUE(op->reqVars[0]->Used); EXPECT_EQ("", op->reqVars[1]->key); EXPECT_EQ("SITE OUTDOOR AIR DRYBULB TEMPERATURE", op->reqVars[1]->name); EXPECT_EQ((int)ReportFreq::Hour, (int)op->reqVars[1]->freq); - EXPECT_EQ(0, op->reqVars[1]->SchedPtr); - EXPECT_EQ("", op->reqVars[1]->SchedName); + EXPECT_EQ(nullptr, op->reqVars[1]->sched); EXPECT_TRUE(op->reqVars[1]->Used); EXPECT_EQ("", op->reqVars[2]->key); EXPECT_EQ("SITE OUTDOOR AIR DRYBULB TEMPERATURE", op->reqVars[2]->name); EXPECT_EQ((int)ReportFreq::Day, (int)op->reqVars[2]->freq); - EXPECT_EQ(0, op->reqVars[2]->SchedPtr); - EXPECT_EQ("", op->reqVars[2]->SchedName); + EXPECT_EQ(nullptr, op->reqVars[2]->sched); EXPECT_TRUE(op->reqVars[2]->Used); EXPECT_EQ("", op->reqVars[3]->key); EXPECT_EQ("SITE OUTDOOR AIR DRYBULB TEMPERATURE", op->reqVars[3]->name); EXPECT_EQ((int)ReportFreq::Month, (int)op->reqVars[3]->freq); - EXPECT_EQ(0, op->reqVars[3]->SchedPtr); - EXPECT_EQ("", op->reqVars[3]->SchedName); + EXPECT_EQ(nullptr, op->reqVars[3]->sched); EXPECT_TRUE(op->reqVars[3]->Used); EXPECT_EQ("", op->reqVars[4]->key); EXPECT_EQ("SITE OUTDOOR AIR DRYBULB TEMPERATURE", op->reqVars[4]->name); EXPECT_EQ((int)ReportFreq::Simulation, (int)op->reqVars[4]->freq); - EXPECT_EQ(0, op->reqVars[4]->SchedPtr); - EXPECT_EQ("", op->reqVars[4]->SchedName); + EXPECT_EQ(nullptr, op->reqVars[4]->sched); EXPECT_TRUE(op->reqVars[4]->Used); EXPECT_EQ("", op->reqVars[4]->key); EXPECT_EQ("SITE OUTDOOR AIR DRYBULB TEMPERATURE", op->reqVars[4]->name); EXPECT_EQ((int)ReportFreq::Simulation, (int)op->reqVars[4]->freq); - EXPECT_EQ(0, op->reqVars[4]->SchedPtr); - EXPECT_EQ("", op->reqVars[4]->SchedName); + EXPECT_EQ(nullptr, op->reqVars[4]->sched); EXPECT_TRUE(op->reqVars[4]->Used); } @@ -2714,36 +2700,31 @@ namespace OutputProcessor { EXPECT_EQ("", op->reqVars[0]->key); EXPECT_EQ("SITE OUTDOOR AIR DRYBULB TEMPERATURE", op->reqVars[0]->name); EXPECT_EQ((int)ReportFreq::TimeStep, (int)op->reqVars[0]->freq); - EXPECT_EQ(0, op->reqVars[0]->SchedPtr); - EXPECT_EQ("", op->reqVars[0]->SchedName); + EXPECT_EQ(nullptr, op->reqVars[0]->sched); EXPECT_TRUE(op->reqVars[0]->Used); EXPECT_EQ("", op->reqVars[1]->key); EXPECT_EQ("SITE OUTDOOR AIR DRYBULB TEMPERATURE", op->reqVars[1]->name); EXPECT_EQ((int)ReportFreq::Hour, (int)op->reqVars[1]->freq); - EXPECT_EQ(0, op->reqVars[1]->SchedPtr); - EXPECT_EQ("", op->reqVars[1]->SchedName); + EXPECT_EQ(nullptr, op->reqVars[1]->sched); EXPECT_TRUE(op->reqVars[1]->Used); EXPECT_EQ("", op->reqVars[2]->key); EXPECT_EQ("SITE OUTDOOR AIR DRYBULB TEMPERATURE", op->reqVars[2]->name); EXPECT_EQ((int)ReportFreq::Day, (int)op->reqVars[2]->freq); - EXPECT_EQ(0, op->reqVars[2]->SchedPtr); - EXPECT_EQ("", op->reqVars[2]->SchedName); + EXPECT_EQ(nullptr, op->reqVars[2]->sched); EXPECT_TRUE(op->reqVars[2]->Used); EXPECT_EQ("", op->reqVars[3]->key); EXPECT_EQ("SITE OUTDOOR AIR DRYBULB TEMPERATURE", op->reqVars[3]->name); EXPECT_EQ((int)ReportFreq::Month, (int)op->reqVars[3]->freq); - EXPECT_EQ(0, op->reqVars[3]->SchedPtr); - EXPECT_EQ("", op->reqVars[3]->SchedName); + EXPECT_EQ(nullptr, op->reqVars[3]->sched); EXPECT_TRUE(op->reqVars[3]->Used); EXPECT_EQ("", op->reqVars[4]->key); EXPECT_EQ("SITE OUTDOOR AIR DRYBULB TEMPERATURE", op->reqVars[4]->name); EXPECT_EQ((int)ReportFreq::Simulation, (int)op->reqVars[4]->freq); - EXPECT_EQ(0, op->reqVars[4]->SchedPtr); - EXPECT_EQ("", op->reqVars[4]->SchedName); + EXPECT_EQ(nullptr, op->reqVars[4]->sched); EXPECT_TRUE(op->reqVars[4]->Used); } @@ -2852,8 +2833,7 @@ namespace OutputProcessor { EXPECT_EQ("", op->reqVars[0]->key); EXPECT_EQ("SITE OUTDOOR AIR DRYBULB TEMPERATURE", op->reqVars[0]->name); EXPECT_EQ((int)ReportFreq::Simulation, (int)op->reqVars[0]->freq); - EXPECT_EQ(0, op->reqVars[0]->SchedPtr); - EXPECT_EQ("", op->reqVars[0]->SchedName); + EXPECT_EQ(nullptr, op->reqVars[0]->sched); EXPECT_EQ(true, op->reqVars[0]->Used); EXPECT_EQ((int)TimeStepType::Zone, (int)op->ddOutVars[0]->timeStepType); @@ -2969,6 +2949,7 @@ namespace OutputProcessor { std::string const idf_objects = delimited_string({"Output:Variable,*,Boiler NaturalGas Rate,runperiod;"}); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); GetReportVariableInput(*state); Real64 fuel_used = 999; @@ -3002,7 +2983,8 @@ namespace OutputProcessor { std::string const idf_objects = delimited_string({"Output:Variable,Boiler[13],Boiler NaturalGas Rate,runperiod;"}); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + GetReportVariableInput(*state); Real64 fuel_used = 999; SetupOutputVariable(*state, "Boiler NaturalGas Rate", Constant::Units::W, fuel_used, TimeStepType::System, StoreType::Average, "Boiler1"); @@ -3033,6 +3015,7 @@ namespace OutputProcessor { std::string const idf_objects = delimited_string({"Output:Variable,Boiler.*,Boiler NaturalGas Rate,runperiod;"}); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); GetReportVariableInput(*state); Real64 fuel_used = 999; @@ -3066,6 +3049,7 @@ namespace OutputProcessor { std::string const idf_objects = delimited_string({"Output:Variable,Zn003:Wall.*,AFN Linkage Node 1 to Node 2 Volume Flow Rate,timestep;"}); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); GetReportVariableInput(*state); Real64 vol_flow = 999; @@ -3139,6 +3123,7 @@ namespace OutputProcessor { delimited_string({"Output:Variable,(?i)Zn003:Wall.*,AFN Linkage Node 1 to Node 2 Volume Flow Rate,timestep;"}); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); GetReportVariableInput(*state); Real64 vol_flow = 999; @@ -3217,6 +3202,7 @@ namespace OutputProcessor { }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); auto const keyed_value = "Environment"; auto const var_name = "Site Outdoor Air Drybulb Temperature"; @@ -3233,36 +3219,31 @@ namespace OutputProcessor { EXPECT_EQ("", op->reqVars[0]->key); EXPECT_EQ("SITE OUTDOOR AIR DRYBULB TEMPERATURE", op->reqVars[0]->name); EXPECT_EQ((int)ReportFreq::TimeStep, (int)op->reqVars[0]->freq); - EXPECT_EQ(0, op->reqVars[0]->SchedPtr); - EXPECT_EQ("", op->reqVars[0]->SchedName); + EXPECT_EQ(nullptr, op->reqVars[0]->sched); EXPECT_EQ(true, op->reqVars[0]->Used); EXPECT_EQ("", op->reqVars[1]->key); EXPECT_EQ("SITE OUTDOOR AIR DRYBULB TEMPERATURE", op->reqVars[1]->name); EXPECT_EQ((int)ReportFreq::Hour, (int)op->reqVars[1]->freq); - EXPECT_EQ(0, op->reqVars[1]->SchedPtr); - EXPECT_EQ("", op->reqVars[1]->SchedName); + EXPECT_EQ(nullptr, op->reqVars[1]->sched); EXPECT_EQ(true, op->reqVars[1]->Used); EXPECT_EQ("", op->reqVars[2]->key); EXPECT_EQ("SITE OUTDOOR AIR DRYBULB TEMPERATURE", op->reqVars[2]->name); EXPECT_EQ((int)ReportFreq::Day, (int)op->reqVars[2]->freq); - EXPECT_EQ(0, op->reqVars[2]->SchedPtr); - EXPECT_EQ("", op->reqVars[2]->SchedName); + EXPECT_EQ(nullptr, op->reqVars[2]->sched); EXPECT_EQ(true, op->reqVars[2]->Used); EXPECT_EQ("", op->reqVars[3]->key); EXPECT_EQ("SITE OUTDOOR AIR DRYBULB TEMPERATURE", op->reqVars[3]->name); EXPECT_EQ((int)ReportFreq::Month, (int)op->reqVars[3]->freq); - EXPECT_EQ(0, op->reqVars[3]->SchedPtr); - EXPECT_EQ("", op->reqVars[3]->SchedName); + EXPECT_EQ(nullptr, op->reqVars[3]->sched); EXPECT_EQ(true, op->reqVars[3]->Used); EXPECT_EQ("", op->reqVars[4]->key); EXPECT_EQ("SITE OUTDOOR AIR DRYBULB TEMPERATURE", op->reqVars[4]->name); EXPECT_EQ((int)ReportFreq::Simulation, (int)op->reqVars[4]->freq); - EXPECT_EQ(0, op->reqVars[4]->SchedPtr); - EXPECT_EQ("", op->reqVars[4]->SchedName); + EXPECT_EQ(nullptr, op->reqVars[4]->sched); EXPECT_EQ(true, op->reqVars[4]->Used); } @@ -3272,6 +3253,7 @@ namespace OutputProcessor { std::string const idf_objects = delimited_string({"Output:Meter:MeterFileOnly,InteriorLights:Electricity:Zone:*,Monthly;"}); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); Real64 light_consumption = 0; for (int i = 1; i <= 5; ++i) { @@ -3340,6 +3322,7 @@ namespace OutputProcessor { }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); Real64 light_consumption = 0; SetupOutputVariable(*state, "Lights Electricity Energy", @@ -3631,6 +3614,7 @@ namespace OutputProcessor { }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); InitializeOutput(*state); @@ -3745,6 +3729,7 @@ namespace OutputProcessor { }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); state->dataGlobal->TimeStep = 4; state->dataGlobal->DayOfSim = 365; @@ -3756,9 +3741,9 @@ namespace OutputProcessor { state->dataEnvrn->HolidayIndex = 0; state->dataGlobal->HourOfDay = 24; state->dataGlobal->NumOfDayInEnvrn = 365; - state->dataGlobal->MinutesPerTimeStep = 10; + state->dataGlobal->MinutesInTimeStep = 10; - if (state->dataGlobal->TimeStep == state->dataGlobal->NumOfTimeStepInHour) { + if (state->dataGlobal->TimeStep == state->dataGlobal->TimeStepsInHour) { state->dataGlobal->EndHourFlag = true; if (state->dataGlobal->HourOfDay == 24) { state->dataGlobal->EndDayFlag = true; @@ -4037,6 +4022,7 @@ namespace OutputProcessor { }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); state->dataGlobal->TimeStep = 4; state->dataGlobal->DayOfSim = 365; @@ -4048,9 +4034,9 @@ namespace OutputProcessor { state->dataEnvrn->HolidayIndex = 0; state->dataGlobal->HourOfDay = 24; state->dataGlobal->NumOfDayInEnvrn = 365; - state->dataGlobal->MinutesPerTimeStep = 10; + state->dataGlobal->MinutesInTimeStep = 10; - if (state->dataGlobal->TimeStep == state->dataGlobal->NumOfTimeStepInHour) { + if (state->dataGlobal->TimeStep == state->dataGlobal->TimeStepsInHour) { state->dataGlobal->EndHourFlag = true; if (state->dataGlobal->HourOfDay == 24) { state->dataGlobal->EndDayFlag = true; @@ -4341,6 +4327,7 @@ namespace OutputProcessor { }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); state->dataGlobal->DayOfSim = 365; state->dataGlobal->DayOfSimChr = "365"; @@ -4351,9 +4338,9 @@ namespace OutputProcessor { state->dataEnvrn->HolidayIndex = 0; state->dataGlobal->HourOfDay = 24; state->dataGlobal->NumOfDayInEnvrn = 365; - state->dataGlobal->MinutesPerTimeStep = 10; + state->dataGlobal->MinutesInTimeStep = 10; - if (state->dataGlobal->TimeStep == state->dataGlobal->NumOfTimeStepInHour) { + if (state->dataGlobal->TimeStep == state->dataGlobal->TimeStepsInHour) { state->dataGlobal->EndHourFlag = true; if (state->dataGlobal->HourOfDay == 24) { state->dataGlobal->EndDayFlag = true; @@ -4584,6 +4571,7 @@ namespace OutputProcessor { }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); state->dataGlobal->TimeStep = 4; state->dataGlobal->DayOfSim = 365; @@ -4595,9 +4583,9 @@ namespace OutputProcessor { state->dataEnvrn->HolidayIndex = 0; state->dataGlobal->HourOfDay = 24; state->dataGlobal->NumOfDayInEnvrn = 365; - state->dataGlobal->MinutesPerTimeStep = 10; + state->dataGlobal->MinutesInTimeStep = 10; - if (state->dataGlobal->TimeStep == state->dataGlobal->NumOfTimeStepInHour) { + if (state->dataGlobal->TimeStep == state->dataGlobal->TimeStepsInHour) { state->dataGlobal->EndHourFlag = true; if (state->dataGlobal->HourOfDay == 24) { state->dataGlobal->EndDayFlag = true; @@ -4673,6 +4661,7 @@ namespace OutputProcessor { }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); state->dataGlobal->DayOfSim = 365; state->dataGlobal->DayOfSimChr = "365"; @@ -4683,9 +4672,9 @@ namespace OutputProcessor { state->dataEnvrn->HolidayIndex = 0; state->dataGlobal->HourOfDay = 24; state->dataGlobal->NumOfDayInEnvrn = 365; - state->dataGlobal->MinutesPerTimeStep = 10; + state->dataGlobal->MinutesInTimeStep = 10; - if (state->dataGlobal->TimeStep == state->dataGlobal->NumOfTimeStepInHour) { + if (state->dataGlobal->TimeStep == state->dataGlobal->TimeStepsInHour) { state->dataGlobal->EndHourFlag = true; if (state->dataGlobal->HourOfDay == 24) { state->dataGlobal->EndDayFlag = true; @@ -4757,6 +4746,7 @@ namespace OutputProcessor { }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); state->dataGlobal->DayOfSim = 365; state->dataGlobal->DayOfSimChr = "365"; @@ -4767,9 +4757,9 @@ namespace OutputProcessor { state->dataEnvrn->HolidayIndex = 0; state->dataGlobal->HourOfDay = 24; state->dataGlobal->NumOfDayInEnvrn = 365; - state->dataGlobal->MinutesPerTimeStep = 10; + state->dataGlobal->MinutesInTimeStep = 10; - if (state->dataGlobal->TimeStep == state->dataGlobal->NumOfTimeStepInHour) { + if (state->dataGlobal->TimeStep == state->dataGlobal->TimeStepsInHour) { state->dataGlobal->EndHourFlag = true; if (state->dataGlobal->HourOfDay == 24) { state->dataGlobal->EndDayFlag = true; @@ -4997,6 +4987,7 @@ namespace OutputProcessor { "Output:Meter, Meter Air System Hot Water Energy, Timestep;"}); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); bool errors_found = false; Real64 transferredenergy = 0; state->dataGlobal->NumOfZones = 1; @@ -5056,6 +5047,7 @@ namespace OutputProcessor { "Output:Meter,CustomMeter2,Hourly;"}); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); bool errors_found = false; @@ -5161,6 +5153,7 @@ namespace OutputProcessor { }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); bool errors_found = false; @@ -5244,6 +5237,7 @@ namespace OutputProcessor { }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); GetReportVariableInput(*state); @@ -5302,8 +5296,7 @@ namespace OutputProcessor { EXPECT_EQ("", op->reqVars[0]->key); EXPECT_EQ("SITE OUTDOOR AIR DRYBULB TEMPERATURE", op->reqVars[0]->name); EXPECT_EQ((int)ReportFreq::Simulation, (int)op->reqVars[0]->freq); - EXPECT_EQ(0, op->reqVars[0]->SchedPtr); - EXPECT_EQ("", op->reqVars[0]->SchedName); + EXPECT_EQ(nullptr, op->reqVars[0]->sched); EXPECT_EQ(true, op->reqVars[0]->Used); EXPECT_EQ((int)TimeStepType::Zone, (int)op->ddOutVars[0]->timeStepType); @@ -5378,6 +5371,7 @@ namespace OutputProcessor { }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); // Demonstrate that it's not unreasonable to reach the INT_MAX limit at all constexpr int numOfTimeStepInHour = 60; @@ -5392,10 +5386,10 @@ namespace OutputProcessor { state->dataEnvrn->DSTIndicator = 0; state->dataEnvrn->HolidayIndex = 0; state->dataGlobal->NumOfDayInEnvrn = 365; - state->dataGlobal->MinutesPerTimeStep = 1; - state->dataGlobal->NumOfTimeStepInHour = 60; + state->dataGlobal->MinutesInTimeStep = 1; + state->dataGlobal->TimeStepsInHour = 60; - Real64 timeStep = 1.0 / state->dataGlobal->NumOfTimeStepInHour; + Real64 timeStep = 1.0 / state->dataGlobal->TimeStepsInHour; SetupTimePointers(*state, TimeStepType::Zone, timeStep); SetupTimePointers(*state, TimeStepType::System, timeStep); @@ -5444,9 +5438,9 @@ namespace OutputProcessor { state->dataGlobal->EndDayFlag = false; for (state->dataGlobal->HourOfDay = 1; state->dataGlobal->HourOfDay <= 24; ++state->dataGlobal->HourOfDay) { - for (state->dataGlobal->TimeStep = 1; state->dataGlobal->TimeStep <= state->dataGlobal->NumOfTimeStepInHour; + for (state->dataGlobal->TimeStep = 1; state->dataGlobal->TimeStep <= state->dataGlobal->TimeStepsInHour; ++state->dataGlobal->TimeStep) { - if (state->dataGlobal->TimeStep == state->dataGlobal->NumOfTimeStepInHour) { + if (state->dataGlobal->TimeStep == state->dataGlobal->TimeStepsInHour) { state->dataGlobal->EndHourFlag = true; if (state->dataGlobal->HourOfDay == 24) { state->dataGlobal->EndDayFlag = true; diff --git a/tst/EnergyPlus/unit/OutputReportTabular.unit.cc b/tst/EnergyPlus/unit/OutputReportTabular.unit.cc index 68afb1ad5ec..9778a092ba5 100644 --- a/tst/EnergyPlus/unit/OutputReportTabular.unit.cc +++ b/tst/EnergyPlus/unit/OutputReportTabular.unit.cc @@ -508,7 +508,7 @@ TEST_F(EnergyPlusFixture, OutputReportTabularTest_AllocateLoadComponentArraysTes state->dataGlobal->NumOfZones = 4; state->dataViewFactor->NumOfRadiantEnclosures = 4; state->dataSurface->TotSurfaces = 7; - state->dataGlobal->NumOfTimeStepInHour = 4; + state->dataGlobal->TimeStepsInHour = 4; AllocateLoadComponentArrays(*state); @@ -518,127 +518,127 @@ TEST_F(EnergyPlusFixture, OutputReportTabularTest_AllocateLoadComponentArraysTes // radiantPulseReceived.allocate( { 0, TotDesDays + TotRunDesPersDays }, TotSurfaces ); EXPECT_EQ(state->dataOutRptTab->radiantPulseReceived.size(), 42u); - // loadConvectedNormal.allocate( TotDesDays + TotRunDesPersDays, { 0, NumOfTimeStepInHour * 24 }, TotSurfaces ); + // loadConvectedNormal.allocate( TotDesDays + TotRunDesPersDays, { 0, TimeStepsInHour * 24 }, TotSurfaces ); EXPECT_EQ(state->dataOutRptTab->loadConvectedNormal.size(), 3395u); - // loadConvectedWithPulse.allocate( TotDesDays + TotRunDesPersDays, { 0, NumOfTimeStepInHour * 24 }, TotSurfaces ); + // loadConvectedWithPulse.allocate( TotDesDays + TotRunDesPersDays, { 0, TimeStepsInHour * 24 }, TotSurfaces ); EXPECT_EQ(state->dataOutRptTab->loadConvectedWithPulse.size(), 3395u); - // netSurfRadSeq.allocate( TotDesDays + TotRunDesPersDays, NumOfTimeStepInHour * 24, TotSurfaces ); + // netSurfRadSeq.allocate( TotDesDays + TotRunDesPersDays, TimeStepsInHour * 24, TotSurfaces ); EXPECT_EQ(state->dataOutRptTab->netSurfRadSeq.size(), 3360u); - // decayCurveCool.allocate( NumOfTimeStepInHour * 24, TotSurfaces ); + // decayCurveCool.allocate( TimeStepsInHour * 24, TotSurfaces ); EXPECT_EQ(state->dataOutRptTab->decayCurveCool.size(), 672u); - // decayCurveHeat.allocate( NumOfTimeStepInHour * 24, TotSurfaces ); + // decayCurveHeat.allocate( TimeStepsInHour * 24, TotSurfaces ); EXPECT_EQ(state->dataOutRptTab->decayCurveHeat.size(), 672u); - // ITABSFseq.allocate( TotDesDays + TotRunDesPersDays, NumOfTimeStepInHour * 24, TotSurfaces ); + // ITABSFseq.allocate( TotDesDays + TotRunDesPersDays, TimeStepsInHour * 24, TotSurfaces ); EXPECT_EQ(state->dataOutRptTab->ITABSFseq.size(), 3360u); - // TMULTseq.allocate( TotDesDays + TotRunDesPersDays, NumOfTimeStepInHour * 24, NumOfZones ); + // TMULTseq.allocate( TotDesDays + TotRunDesPersDays, TimeStepsInHour * 24, NumOfZones ); EXPECT_EQ(state->dataOutRptTab->TMULTseq.size(), 1920u); - // peopleInstantSeq.allocate( TotDesDays + TotRunDesPersDays, NumOfTimeStepInHour * 24, NumOfZones ); + // peopleInstantSeq.allocate( TotDesDays + TotRunDesPersDays, TimeStepsInHour * 24, NumOfZones ); EXPECT_EQ(state->dataOutRptTab->peopleInstantSeq.size(), 1920u); - // peopleLatentSeq.allocate( TotDesDays + TotRunDesPersDays, NumOfTimeStepInHour * 24, NumOfZones ); + // peopleLatentSeq.allocate( TotDesDays + TotRunDesPersDays, TimeStepsInHour * 24, NumOfZones ); EXPECT_EQ(state->dataOutRptTab->peopleLatentSeq.size(), 1920u); - // peopleRadSeq.allocate( TotDesDays + TotRunDesPersDays, NumOfTimeStepInHour * 24, NumOfZones ); + // peopleRadSeq.allocate( TotDesDays + TotRunDesPersDays, TimeStepsInHour * 24, NumOfZones ); EXPECT_EQ(state->dataOutRptTab->peopleRadSeq.size(), 1920u); - // peopleDelaySeq.allocate( TotDesDays + TotRunDesPersDays, NumOfTimeStepInHour * 24, NumOfZones ); + // peopleDelaySeq.allocate( TotDesDays + TotRunDesPersDays, TimeStepsInHour * 24, NumOfZones ); // EXPECT_EQ( peopleDelaySeq.size(), 1920u ); - // lightInstantSeq.allocate( TotDesDays + TotRunDesPersDays, NumOfTimeStepInHour * 24, NumOfZones ); + // lightInstantSeq.allocate( TotDesDays + TotRunDesPersDays, TimeStepsInHour * 24, NumOfZones ); EXPECT_EQ(state->dataOutRptTab->lightInstantSeq.size(), 1920u); - // lightRetAirSeq.allocate( TotDesDays + TotRunDesPersDays, NumOfTimeStepInHour * 24, NumOfZones ); + // lightRetAirSeq.allocate( TotDesDays + TotRunDesPersDays, TimeStepsInHour * 24, NumOfZones ); EXPECT_EQ(state->dataOutRptTab->lightRetAirSeq.size(), 1920u); - // lightLWRadSeq.allocate( TotDesDays + TotRunDesPersDays, NumOfTimeStepInHour * 24, NumOfZones ); + // lightLWRadSeq.allocate( TotDesDays + TotRunDesPersDays, TimeStepsInHour * 24, NumOfZones ); EXPECT_EQ(state->dataOutRptTab->lightLWRadSeq.size(), 1920u); - // lightSWRadSeq.allocate( TotDesDays + TotRunDesPersDays, NumOfTimeStepInHour * 24, TotSurfaces ); + // lightSWRadSeq.allocate( TotDesDays + TotRunDesPersDays, TimeStepsInHour * 24, TotSurfaces ); EXPECT_EQ(state->dataOutRptTab->lightSWRadSeq.size(), 3360u); - // lightDelaySeq.allocate( TotDesDays + TotRunDesPersDays, NumOfTimeStepInHour * 24, NumOfZones ); + // lightDelaySeq.allocate( TotDesDays + TotRunDesPersDays, TimeStepsInHour * 24, NumOfZones ); // EXPECT_EQ( lightDelaySeq.size(), 1920u ); - // equipInstantSeq.allocate( TotDesDays + TotRunDesPersDays, NumOfTimeStepInHour * 24, NumOfZones ); + // equipInstantSeq.allocate( TotDesDays + TotRunDesPersDays, TimeStepsInHour * 24, NumOfZones ); EXPECT_EQ(state->dataOutRptTab->equipInstantSeq.size(), 1920u); - // equipLatentSeq.allocate( TotDesDays + TotRunDesPersDays, NumOfTimeStepInHour * 24, NumOfZones ); + // equipLatentSeq.allocate( TotDesDays + TotRunDesPersDays, TimeStepsInHour * 24, NumOfZones ); EXPECT_EQ(state->dataOutRptTab->equipLatentSeq.size(), 1920u); - // equipRadSeq.allocate( TotDesDays + TotRunDesPersDays, NumOfTimeStepInHour * 24, NumOfZones ); + // equipRadSeq.allocate( TotDesDays + TotRunDesPersDays, TimeStepsInHour * 24, NumOfZones ); EXPECT_EQ(state->dataOutRptTab->equipRadSeq.size(), 1920u); - // equipDelaySeq.allocate( TotDesDays + TotRunDesPersDays, NumOfTimeStepInHour * 24, NumOfZones ); + // equipDelaySeq.allocate( TotDesDays + TotRunDesPersDays, TimeStepsInHour * 24, NumOfZones ); // EXPECT_EQ( equipDelaySeq.size(), 1920u ); - // refrigInstantSeq.allocate( TotDesDays + TotRunDesPersDays, NumOfTimeStepInHour * 24, NumOfZones ); + // refrigInstantSeq.allocate( TotDesDays + TotRunDesPersDays, TimeStepsInHour * 24, NumOfZones ); EXPECT_EQ(state->dataOutRptTab->refrigInstantSeq.size(), 1920u); - // refrigRetAirSeq.allocate( TotDesDays + TotRunDesPersDays, NumOfTimeStepInHour * 24, NumOfZones ); + // refrigRetAirSeq.allocate( TotDesDays + TotRunDesPersDays, TimeStepsInHour * 24, NumOfZones ); EXPECT_EQ(state->dataOutRptTab->refrigRetAirSeq.size(), 1920u); - // refrigLatentSeq.allocate( TotDesDays + TotRunDesPersDays, NumOfTimeStepInHour * 24, NumOfZones ); + // refrigLatentSeq.allocate( TotDesDays + TotRunDesPersDays, TimeStepsInHour * 24, NumOfZones ); EXPECT_EQ(state->dataOutRptTab->refrigLatentSeq.size(), 1920u); - // waterUseInstantSeq.allocate( TotDesDays + TotRunDesPersDays, NumOfTimeStepInHour * 24, NumOfZones ); + // waterUseInstantSeq.allocate( TotDesDays + TotRunDesPersDays, TimeStepsInHour * 24, NumOfZones ); EXPECT_EQ(state->dataOutRptTab->waterUseInstantSeq.size(), 1920u); - // waterUseLatentSeq.allocate( TotDesDays + TotRunDesPersDays, NumOfTimeStepInHour * 24, NumOfZones ); + // waterUseLatentSeq.allocate( TotDesDays + TotRunDesPersDays, TimeStepsInHour * 24, NumOfZones ); EXPECT_EQ(state->dataOutRptTab->waterUseLatentSeq.size(), 1920u); - // hvacLossInstantSeq.allocate( TotDesDays + TotRunDesPersDays, NumOfTimeStepInHour * 24, NumOfZones ); + // hvacLossInstantSeq.allocate( TotDesDays + TotRunDesPersDays, TimeStepsInHour * 24, NumOfZones ); EXPECT_EQ(state->dataOutRptTab->hvacLossInstantSeq.size(), 1920u); - // hvacLossRadSeq.allocate( TotDesDays + TotRunDesPersDays, NumOfTimeStepInHour * 24, NumOfZones ); + // hvacLossRadSeq.allocate( TotDesDays + TotRunDesPersDays, TimeStepsInHour * 24, NumOfZones ); EXPECT_EQ(state->dataOutRptTab->hvacLossRadSeq.size(), 1920u); - // hvacLossDelaySeq.allocate( TotDesDays + TotRunDesPersDays, NumOfTimeStepInHour * 24, NumOfZones ); + // hvacLossDelaySeq.allocate( TotDesDays + TotRunDesPersDays, TimeStepsInHour * 24, NumOfZones ); // EXPECT_EQ( hvacLossDelaySeq.size(), 1920u ); - // powerGenInstantSeq.allocate( TotDesDays + TotRunDesPersDays, NumOfTimeStepInHour * 24, NumOfZones ); + // powerGenInstantSeq.allocate( TotDesDays + TotRunDesPersDays, TimeStepsInHour * 24, NumOfZones ); EXPECT_EQ(state->dataOutRptTab->powerGenInstantSeq.size(), 1920u); - // powerGenRadSeq.allocate( TotDesDays + TotRunDesPersDays, NumOfTimeStepInHour * 24, NumOfZones ); + // powerGenRadSeq.allocate( TotDesDays + TotRunDesPersDays, TimeStepsInHour * 24, NumOfZones ); EXPECT_EQ(state->dataOutRptTab->powerGenRadSeq.size(), 1920u); - // powerGenDelaySeq.allocate( TotDesDays + TotRunDesPersDays, NumOfTimeStepInHour * 24, NumOfZones ); + // powerGenDelaySeq.allocate( TotDesDays + TotRunDesPersDays, TimeStepsInHour * 24, NumOfZones ); // EXPECT_EQ( powerGenDelaySeq.size(), 1920u ); - // infilInstantSeq.allocate( TotDesDays + TotRunDesPersDays, NumOfTimeStepInHour * 24, NumOfZones ); + // infilInstantSeq.allocate( TotDesDays + TotRunDesPersDays, TimeStepsInHour * 24, NumOfZones ); EXPECT_EQ(state->dataOutRptTab->infilInstantSeq.size(), 1920u); - // infilLatentSeq.allocate( TotDesDays + TotRunDesPersDays, NumOfTimeStepInHour * 24, NumOfZones ); + // infilLatentSeq.allocate( TotDesDays + TotRunDesPersDays, TimeStepsInHour * 24, NumOfZones ); EXPECT_EQ(state->dataOutRptTab->infilLatentSeq.size(), 1920u); - // zoneVentInstantSeq.allocate( TotDesDays + TotRunDesPersDays, NumOfTimeStepInHour * 24, NumOfZones ); + // zoneVentInstantSeq.allocate( TotDesDays + TotRunDesPersDays, TimeStepsInHour * 24, NumOfZones ); EXPECT_EQ(state->dataOutRptTab->zoneVentInstantSeq.size(), 1920u); - // zoneVentLatentSeq.allocate( TotDesDays + TotRunDesPersDays, NumOfTimeStepInHour * 24, NumOfZones ); + // zoneVentLatentSeq.allocate( TotDesDays + TotRunDesPersDays, TimeStepsInHour * 24, NumOfZones ); EXPECT_EQ(state->dataOutRptTab->zoneVentLatentSeq.size(), 1920u); - // interZoneMixInstantSeq.allocate( TotDesDays + TotRunDesPersDays, NumOfTimeStepInHour * 24, NumOfZones ); + // interZoneMixInstantSeq.allocate( TotDesDays + TotRunDesPersDays, TimeStepsInHour * 24, NumOfZones ); EXPECT_EQ(state->dataOutRptTab->interZoneMixInstantSeq.size(), 1920u); - // interZoneMixLatentSeq.allocate( TotDesDays + TotRunDesPersDays, NumOfTimeStepInHour * 24, NumOfZones ); + // interZoneMixLatentSeq.allocate( TotDesDays + TotRunDesPersDays, TimeStepsInHour * 24, NumOfZones ); EXPECT_EQ(state->dataOutRptTab->interZoneMixLatentSeq.size(), 1920u); - // feneCondInstantSeq.allocate( TotDesDays + TotRunDesPersDays, NumOfTimeStepInHour * 24, NumOfZones ); + // feneCondInstantSeq.allocate( TotDesDays + TotRunDesPersDays, TimeStepsInHour * 24, NumOfZones ); EXPECT_EQ(state->dataOutRptTab->feneCondInstantSeq.size(), 1920u); - // feneSolarRadSeq.allocate( TotDesDays + TotRunDesPersDays, NumOfTimeStepInHour * 24, TotSurfaces ); + // feneSolarRadSeq.allocate( TotDesDays + TotRunDesPersDays, TimeStepsInHour * 24, TotSurfaces ); EXPECT_EQ(state->dataOutRptTab->feneSolarRadSeq.size(), 3360u); - // feneSolarDelaySeq.allocate( TotDesDays + TotRunDesPersDays, NumOfTimeStepInHour * 24, NumOfZones ); + // feneSolarDelaySeq.allocate( TotDesDays + TotRunDesPersDays, TimeStepsInHour * 24, NumOfZones ); // EXPECT_EQ( feneSolarDelaySeq.size(), 1920u ); - // surfDelaySeq.allocate( TotDesDays + TotRunDesPersDays, NumOfTimeStepInHour * 24, TotSurfaces ); + // surfDelaySeq.allocate( TotDesDays + TotRunDesPersDays, TimeStepsInHour * 24, TotSurfaces ); // EXPECT_EQ( surfDelaySeq.size(), 3360u ); } @@ -3641,7 +3641,7 @@ TEST_F(EnergyPlusFixture, OutputReportTabular_ConfirmResetBEPSGathering) state->dataGlobal->DoWeathSim = true; state->dataGlobal->TimeStepZone = 1.0; state->dataGlobal->TimeStepZoneSec = state->dataGlobal->TimeStepZone * 3600.0; - state->dataGlobal->MinutesPerTimeStep = state->dataGlobal->TimeStepZone * 60.0; + state->dataGlobal->MinutesInTimeStep = state->dataGlobal->TimeStepZone * 60.0; state->dataOutRptTab->displayTabularBEPS = true; // OutputProcessor::TimeValue.allocate(2); @@ -3811,7 +3811,7 @@ TEST_F(EnergyPlusFixture, OutputReportTabular_GatherHeatEmissionReport) state->dataOutRptTab->displayHeatEmissionsSummary = true; state->dataGlobal->DoWeathSim = true; state->dataHVACGlobal->TimeStepSys = 10.0; - state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; state->dataEnvrn->OutHumRat = 0.005; state->dataEnvrn->OutDryBulbTemp = 25.0; @@ -3893,9 +3893,10 @@ TEST_F(EnergyPlusFixture, OutputTableTimeBins_GetInput) "0.00, !- Interval Start", "0.20, !- Interval Size", "5, !- Interval Count", - "Always1; !- Schedule Name"}); + "Constant-1.0; !- Schedule Name"}); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + state->dataGlobal->DoWeathSim = true; GetInputTabularTimeBins(*state); @@ -3906,7 +3907,7 @@ TEST_F(EnergyPlusFixture, OutputTableTimeBins_GetInput) EXPECT_EQ(state->dataOutRptTab->OutputTableBinned(1).intervalStart, 0.0); EXPECT_EQ(state->dataOutRptTab->OutputTableBinned(1).intervalSize, 0.20); EXPECT_EQ(state->dataOutRptTab->OutputTableBinned(1).intervalCount, 5); - EXPECT_EQ(state->dataOutRptTab->OutputTableBinned(1).ScheduleName, "ALWAYS1"); + EXPECT_EQ(state->dataOutRptTab->OutputTableBinned(1).sched->Name, "Constant-1.0"); } // TEST_F( EnergyPlusFixture, FinAndOverhangCount ) @@ -6581,7 +6582,8 @@ TEST_F(EnergyPlusFixture, OutputReportTabularMonthly_invalidAggregationOrder) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + Real64 extLitUse; SetupOutputVariable(*state, @@ -6631,7 +6633,7 @@ TEST_F(EnergyPlusFixture, OutputReportTabularMonthly_invalidAggregationOrder) TEST_F(EnergyPlusFixture, OutputReportTabularTest_CollectPeakZoneConditions_test) { - Psychrometrics::InitializePsychRoutines(*state); + state->init_state(*state); createCoilSelectionReportObj(*state); CompLoadTablesType compLoad; @@ -6648,8 +6650,8 @@ TEST_F(EnergyPlusFixture, OutputReportTabularTest_CollectPeakZoneConditions_test state->dataWeather->DesDayInput(1).Month = 5; state->dataWeather->DesDayInput(1).DayOfMonth = 21; - state->dataGlobal->NumOfTimeStepInHour = 4; - state->dataGlobal->MinutesPerTimeStep = 15; + state->dataGlobal->TimeStepsInHour = 4; + state->dataGlobal->MinutesInTimeStep = 15; state->dataSize->CalcFinalZoneSizing.allocate(1); state->dataSize->CalcFinalZoneSizing(1).CoolOutTempSeq.allocate(96); @@ -6982,7 +6984,7 @@ TEST_F(EnergyPlusFixture, OutputReportTabularTest_GetDelaySequencesTwice_test) int iZone = 1; state->dataEnvrn->TotDesDays = 2; state->dataEnvrn->TotRunDesPersDays = 3; - state->dataGlobal->NumOfTimeStepInHour = 4; + state->dataGlobal->TimeStepsInHour = 4; state->dataGlobal->NumOfZones = 4; state->dataHeatBal->Zone.allocate(state->dataGlobal->NumOfZones); @@ -7002,41 +7004,41 @@ TEST_F(EnergyPlusFixture, OutputReportTabularTest_GetDelaySequencesTwice_test) state->dataSurface->Surface(1).RadEnclIndex = 1; Array1D peopleDelaySeq; - peopleDelaySeq.allocate(state->dataGlobal->NumOfTimeStepInHour * 24); + peopleDelaySeq.allocate(state->dataGlobal->TimeStepsInHour * 24); peopleDelaySeq = 0.; Array1D peopleDelaySeqCool; - peopleDelaySeqCool.allocate(state->dataGlobal->NumOfTimeStepInHour * 24); + peopleDelaySeqCool.allocate(state->dataGlobal->TimeStepsInHour * 24); peopleDelaySeqCool = 0.; Array1D equipDelaySeqCool; - equipDelaySeqCool.allocate(state->dataGlobal->NumOfTimeStepInHour * 24); + equipDelaySeqCool.allocate(state->dataGlobal->TimeStepsInHour * 24); equipDelaySeqCool = 0.; Array1D hvacLossDelaySeqCool; - hvacLossDelaySeqCool.allocate(state->dataGlobal->NumOfTimeStepInHour * 24); + hvacLossDelaySeqCool.allocate(state->dataGlobal->TimeStepsInHour * 24); hvacLossDelaySeqCool = 0.; Array1D powerGenDelaySeqCool; - powerGenDelaySeqCool.allocate(state->dataGlobal->NumOfTimeStepInHour * 24); + powerGenDelaySeqCool.allocate(state->dataGlobal->TimeStepsInHour * 24); powerGenDelaySeqCool = 0.; Array1D lightDelaySeqCool; - lightDelaySeqCool.allocate(state->dataGlobal->NumOfTimeStepInHour * 24); + lightDelaySeqCool.allocate(state->dataGlobal->TimeStepsInHour * 24); lightDelaySeqCool = 0.; Array1D feneSolarDelaySeqCool; - feneSolarDelaySeqCool.allocate(state->dataGlobal->NumOfTimeStepInHour * 24); + feneSolarDelaySeqCool.allocate(state->dataGlobal->TimeStepsInHour * 24); feneSolarDelaySeqCool = 0.; Array3D feneCondInstantSeq; feneCondInstantSeq.allocate(state->dataEnvrn->TotDesDays + state->dataEnvrn->TotRunDesPersDays, - state->dataGlobal->NumOfTimeStepInHour * 24, + state->dataGlobal->TimeStepsInHour * 24, state->dataViewFactor->NumOfRadiantEnclosures); feneCondInstantSeq = 0.0; Array2D surfDelaySeqCool; - surfDelaySeqCool.allocate(state->dataGlobal->NumOfTimeStepInHour * 24, state->dataSurface->TotSurfaces); + surfDelaySeqCool.allocate(state->dataGlobal->TimeStepsInHour * 24, state->dataSurface->TotSurfaces); surfDelaySeqCool = 0.0; AllocateLoadComponentArrays(*state); @@ -7113,6 +7115,8 @@ TEST_F(SQLiteFixture, OutputReportTabular_WriteLoadComponentSummaryTables_AirLoo // We ensure that if the Airloop peak matches the zone peak, we don't do the IP conversion twice TEST_F(SQLiteFixture, OutputReportTabular_WriteLoadComponentSummaryTables_AirLoop_IPConversion) { + state->init_state(*state); + state->dataSQLiteProcedures->sqlite->createSQLiteSimulationsRecord(1, "EnergyPlus Version", "Current Time"); OutputReportTabular::SetupUnitConversions(*state); @@ -7126,7 +7130,6 @@ TEST_F(SQLiteFixture, OutputReportTabular_WriteLoadComponentSummaryTables_AirLoo state->dataOutRptTab->displayFacilityComponentLoadSummary = true; state->dataGlobal->CompLoadReportIsReq = true; - Psychrometrics::InitializePsychRoutines(*state); createCoilSelectionReportObj(*state); // Two design days @@ -7139,8 +7142,8 @@ TEST_F(SQLiteFixture, OutputReportTabular_WriteLoadComponentSummaryTables_AirLoo state->dataWeather->DesDayInput(2).Month = 1; state->dataWeather->DesDayInput(2).DayOfMonth = 21; - state->dataGlobal->NumOfTimeStepInHour = 4; - state->dataGlobal->MinutesPerTimeStep = 15; + state->dataGlobal->TimeStepsInHour = 4; + state->dataGlobal->MinutesInTimeStep = 15; int numTimeStepInDay = 96; // One Zone @@ -7415,6 +7418,7 @@ TEST_F(EnergyPlusFixture, OutputReportTabularMonthlyPredefined_FindNeededOutputV }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); EXPECT_EQ(1, state->dataInputProcessing->inputProcessor->getNumObjectsFound(*state, "Output:Table:SummaryReports")); EXPECT_EQ(0, state->dataInputProcessing->inputProcessor->getNumObjectsFound(*state, "Output:Variable")); @@ -8138,7 +8142,7 @@ TEST_F(SQLiteFixture, OutputReportTabular_EndUseBySubcategorySQL) "General"); state->dataGlobal->DoWeathSim = true; state->dataGlobal->TimeStepZone = 1.0; - state->dataGlobal->MinutesPerTimeStep = state->dataGlobal->TimeStepZone * 60; + state->dataGlobal->MinutesInTimeStep = state->dataGlobal->TimeStepZone * 60; state->dataGlobal->TimeStepZoneSec = state->dataGlobal->TimeStepZone * 3600.0; state->dataOutRptTab->displayTabularBEPS = true; // OutputProcessor::TimeValue.allocate(2); @@ -8364,7 +8368,7 @@ TEST_F(EnergyPlusFixture, OutputReportTabularTest_GetDelaySequencesSurfaceOrder_ int iZone = 1; state->dataEnvrn->TotDesDays = 2; state->dataEnvrn->TotRunDesPersDays = 3; - state->dataGlobal->NumOfTimeStepInHour = 4; + state->dataGlobal->TimeStepsInHour = 4; state->dataGlobal->NumOfZones = 1; state->dataHeatBal->Zone.allocate(state->dataGlobal->NumOfZones); @@ -8382,41 +8386,41 @@ TEST_F(EnergyPlusFixture, OutputReportTabularTest_GetDelaySequencesSurfaceOrder_ state->dataSurface->Surface.allocate(state->dataSurface->TotSurfaces); Array1D peopleDelaySeq; - peopleDelaySeq.allocate(state->dataGlobal->NumOfTimeStepInHour * 24); + peopleDelaySeq.allocate(state->dataGlobal->TimeStepsInHour * 24); peopleDelaySeq = 0.; Array1D peopleDelaySeqCool; - peopleDelaySeqCool.allocate(state->dataGlobal->NumOfTimeStepInHour * 24); + peopleDelaySeqCool.allocate(state->dataGlobal->TimeStepsInHour * 24); peopleDelaySeqCool = 0.; Array1D equipDelaySeqCool; - equipDelaySeqCool.allocate(state->dataGlobal->NumOfTimeStepInHour * 24); + equipDelaySeqCool.allocate(state->dataGlobal->TimeStepsInHour * 24); equipDelaySeqCool = 0.; Array1D hvacLossDelaySeqCool; - hvacLossDelaySeqCool.allocate(state->dataGlobal->NumOfTimeStepInHour * 24); + hvacLossDelaySeqCool.allocate(state->dataGlobal->TimeStepsInHour * 24); hvacLossDelaySeqCool = 0.; Array1D powerGenDelaySeqCool; - powerGenDelaySeqCool.allocate(state->dataGlobal->NumOfTimeStepInHour * 24); + powerGenDelaySeqCool.allocate(state->dataGlobal->TimeStepsInHour * 24); powerGenDelaySeqCool = 0.; Array1D lightDelaySeqCool; - lightDelaySeqCool.allocate(state->dataGlobal->NumOfTimeStepInHour * 24); + lightDelaySeqCool.allocate(state->dataGlobal->TimeStepsInHour * 24); lightDelaySeqCool = 0.; Array1D feneSolarDelaySeqCool; - feneSolarDelaySeqCool.allocate(state->dataGlobal->NumOfTimeStepInHour * 24); + feneSolarDelaySeqCool.allocate(state->dataGlobal->TimeStepsInHour * 24); feneSolarDelaySeqCool = 0.; Array3D feneCondInstantSeq; feneCondInstantSeq.allocate(state->dataEnvrn->TotDesDays + state->dataEnvrn->TotRunDesPersDays, - state->dataGlobal->NumOfTimeStepInHour * 24, + state->dataGlobal->TimeStepsInHour * 24, state->dataViewFactor->NumOfRadiantEnclosures); feneCondInstantSeq = 0.0; Array2D surfDelaySeqCool; - surfDelaySeqCool.allocate(state->dataGlobal->NumOfTimeStepInHour * 24, state->dataSurface->TotSurfaces); + surfDelaySeqCool.allocate(state->dataGlobal->TimeStepsInHour * 24, state->dataSurface->TotSurfaces); surfDelaySeqCool = 0.0; AllocateLoadComponentArrays(*state); @@ -8541,9 +8545,9 @@ TEST_F(EnergyPlusFixture, OutputReportTabularTest_ConfirmConversionFactors) Real64 curSourceFactor; bool fuelFactorUsed; bool fFScheduleUsed; - int ffScheduleIndex; + Sched::Schedule *ffSched; - Pollution::GetFuelFactorInfo(*state, Constant::eFuel::DistrictHeatingSteam, fuelFactorUsed, curSourceFactor, fFScheduleUsed, ffScheduleIndex); + Pollution::GetFuelFactorInfo(*state, Constant::eFuel::DistrictHeatingSteam, fuelFactorUsed, curSourceFactor, fFScheduleUsed, &ffSched); EXPECT_EQ(curSourceFactor, 1.2); } @@ -8556,7 +8560,7 @@ TEST_F(EnergyPlusFixture, OutputReportTabular_GatherHeatGainReport) state->dataOutRptPredefined->reportName(state->dataOutRptPredefined->pdrSensibleGain).show = true; state->dataHVACGlobal->TimeStepSys = 10.0; - state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; state->dataGlobal->TimeStepZone = 20.0; @@ -8625,6 +8629,7 @@ TEST_F(EnergyPlusFixture, OutputReportTabularMonthly_8317_ValidateOutputTableMon }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); Real64 extLitUse; @@ -9672,7 +9677,7 @@ TEST_F(SQLiteFixture, ORT_EndUseBySubcategorySQL_DualUnits) state->dataGlobal->DoWeathSim = true; state->dataGlobal->TimeStepZone = 1.0; state->dataGlobal->TimeStepZoneSec = state->dataGlobal->TimeStepZone * 3600.0; - state->dataGlobal->MinutesPerTimeStep = 60; + state->dataGlobal->MinutesInTimeStep = 60; state->dataOutRptTab->displayTabularBEPS = true; // OutputProcessor::TimeValue.allocate(2); @@ -10257,14 +10262,14 @@ TEST_F(EnergyPlusFixture, OutputReportTabularTest_WarningMultiplePeopleObj) }); ASSERT_TRUE(process_idf(idf_objects)); + state->dataGlobal->TimeStepsInHour = 1; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 60; // must initialize this to get schedules initialized + state->init_state(*state); bool ErrorsFound = false; HeatBalanceManager::GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); - state->dataGlobal->NumOfTimeStepInHour = 1; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 60; // must initialize this to get schedules initialized - ScheduleManager::ProcessScheduleInput(*state); state->dataGlobal->NumOfZones = 1; state->dataHeatBal->Resilience.allocate(state->dataGlobal->NumOfZones); InternalHeatGains::GetInternalHeatGainsInput(*state); @@ -11675,6 +11680,7 @@ TEST_F(SQLiteFixture, DOASDirectToZone_ZoneMultiplierRemoved) std::string const idf_objects = idf_objects_1 + idf_objects_2 + idf_objects_3; ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); ManageSimulation(*state); // run the design days auto &finalSysSizing = state->dataSize->FinalSysSizing(1); @@ -12621,6 +12627,7 @@ TEST_F(SQLiteFixture, UpdateSizing_EndSysSizingCalc) std::string const idf_objects = idf_objects_1 + idf_objects_2 + idf_objects_3; ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); ManageSimulation(*state); // run the design days auto &finalSysSizing = state->dataSize->FinalSysSizing(1); @@ -13032,7 +13039,7 @@ TEST_F(SQLiteFixture, OutputReportTabular_DistrictHeating) state->dataGlobal->DoWeathSim = true; state->dataGlobal->TimeStepZone = 1.0; - state->dataGlobal->MinutesPerTimeStep = state->dataGlobal->TimeStepZone * 60; + state->dataGlobal->MinutesInTimeStep = state->dataGlobal->TimeStepZone * 60; state->dataGlobal->TimeStepZoneSec = state->dataGlobal->TimeStepZone * 3600.0; state->dataOutRptTab->displayTabularBEPS = true; // OutputProcessor::TimeValue.allocate(2); @@ -13480,7 +13487,7 @@ TEST_F(SQLiteFixture, ORT_EndUseBySubcategorySQL_IPUnitExceptElec) state->dataGlobal->DoWeathSim = true; state->dataGlobal->TimeStepZone = 1.0; state->dataGlobal->TimeStepZoneSec = state->dataGlobal->TimeStepZone * 3600.0; - state->dataGlobal->MinutesPerTimeStep = 60; + state->dataGlobal->MinutesInTimeStep = 60; state->dataOutRptTab->displayTabularBEPS = true; // OutputProcessor::TimeValue.allocate(2); diff --git a/tst/EnergyPlus/unit/OutputReportTabularAnnual.unit.cc b/tst/EnergyPlus/unit/OutputReportTabularAnnual.unit.cc index d76f2ddbcf0..ba005e5d330 100644 --- a/tst/EnergyPlus/unit/OutputReportTabularAnnual.unit.cc +++ b/tst/EnergyPlus/unit/OutputReportTabularAnnual.unit.cc @@ -71,7 +71,7 @@ TEST_F(EnergyPlusFixture, OutputReportTabularAnnual_GetInput) "Output:Table:Annual,", "Space Gains Annual Report, !- Name", "Filter1, !- Filter", - "Schedule2, !- Schedule Name", + "Constant-1.0, !- Schedule Name", "Zone People Total Heating Energy, !- Variable or Meter 1 Name", "SumOrAverage, !- Aggregation Type for Variable or Meter 1", "4, !- field Digits After Decimal 1", @@ -82,6 +82,7 @@ TEST_F(EnergyPlusFixture, OutputReportTabularAnnual_GetInput) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); state->dataGlobal->DoWeathSim = true; @@ -97,7 +98,7 @@ TEST_F(EnergyPlusFixture, OutputReportTabularAnnual_GetInput) EXPECT_EQ(tableParams[0], "SPACE GAINS ANNUAL REPORT"); // m_name EXPECT_EQ(tableParams[1], "FILTER1"); // m_filter - EXPECT_EQ(tableParams[2], "SCHEDULE2"); // m_scheduleName + EXPECT_EQ(tableParams[2], "Constant-1.0"); // m_scheduleName std::vector fieldSetParams = firstTable->inspectTableFieldSets(0); EXPECT_EQ(fieldSetParams[0], "ZONE PEOPLE TOTAL HEATING ENERGY"); @@ -129,7 +130,8 @@ TEST_F(EnergyPlusFixture, OutputReportTabularAnnual_SetupGathering) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + Real64 extLitPow; Real64 extLitUse; @@ -221,7 +223,8 @@ TEST_F(EnergyPlusFixture, OutputReportTabularAnnual_GatherResults) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + Real64 extLitPow; Real64 extLitUse; @@ -303,7 +306,7 @@ TEST_F(EnergyPlusFixture, OutputReportTabularAnnual_GatherResults_MinMaxHrsShown using namespace OutputProcessor; state->dataGlobal->TimeStepZone = 1.0; state->dataHVACGlobal->TimeStepSys = 1.0; - state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; Meter *meter1 = new Meter("HEATING:MYTH:VARIABLE"); meter1->units = Constant::Units::None; @@ -377,6 +380,7 @@ TEST_F(EnergyPlusFixture, OutputReportTabularAnnual_columnHeadersToTitleCase) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); Real64 facilUse; SetupOutputVariable(*state, @@ -441,6 +445,7 @@ TEST_F(EnergyPlusFixture, OutputReportTabularAnnual_invalidAggregationOrder) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); Real64 facilUse; SetupOutputVariable(*state, @@ -538,6 +543,7 @@ TEST_F(SQLiteFixture, OutputReportTabularAnnual_CurlyBraces) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); Meter *meter1 = new Meter("ELECTRICITY:FACILITY"); meter1->units = Constant::Units::None; @@ -581,7 +587,7 @@ TEST_F(EnergyPlusFixture, OutputReportTabularAnnual_WarnBlankVariable) "Output:Table:Annual,", "Space Gains Annual Report, !- Name", "Filter1, !- Filter", - "Schedule2, !- Schedule Name", + "Constant-1.0, !- Schedule Name", "Zone People Total Heating Energy, !- Variable or Meter 1 Name", "SumOrAverage, !- Aggregation Type for Variable or Meter 1", "4, !- field Digits After Decimal 1", @@ -592,7 +598,8 @@ TEST_F(EnergyPlusFixture, OutputReportTabularAnnual_WarnBlankVariable) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + state->dataGlobal->DoWeathSim = true; EXPECT_FALSE(state->dataOutRptTab->WriteTabularFiles); diff --git a/tst/EnergyPlus/unit/OutputReports.unit.cc b/tst/EnergyPlus/unit/OutputReports.unit.cc index 519d8c86360..b6a184f1278 100644 --- a/tst/EnergyPlus/unit/OutputReports.unit.cc +++ b/tst/EnergyPlus/unit/OutputReports.unit.cc @@ -140,8 +140,8 @@ TEST_F(EnergyPlusFixture, OutputReports_SurfaceDetailsReport) state->dataSurfaceGeometry->CosZoneRelNorth.allocate(1); state->dataSurfaceGeometry->SinZoneRelNorth.allocate(1); - state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); - state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); + state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); + state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); state->dataSurfaceGeometry->CosBldgRelNorth = 1.0; state->dataSurfaceGeometry->SinBldgRelNorth = 0.0; diff --git a/tst/EnergyPlus/unit/OutsideEnergySources.unit.cc b/tst/EnergyPlus/unit/OutsideEnergySources.unit.cc index 8eda2e0503b..4a2bf42c37f 100644 --- a/tst/EnergyPlus/unit/OutsideEnergySources.unit.cc +++ b/tst/EnergyPlus/unit/OutsideEnergySources.unit.cc @@ -87,6 +87,8 @@ TEST_F(EnergyPlusFixture, DistrictCoolingandHeating) }); ASSERT_TRUE(process_idf(idf_objects, false)); + state->init_state(*state); + GetOutsideEnergySourcesInput(*state); // GetOutsideEnergySourcesInput() finds DistrictHeating:Water, DistrictCooling, and DistrictHeating:Steam, respectively diff --git a/tst/EnergyPlus/unit/PVWatts.unit.cc b/tst/EnergyPlus/unit/PVWatts.unit.cc index 7094d4c4f98..eb687e23e2e 100644 --- a/tst/EnergyPlus/unit/PVWatts.unit.cc +++ b/tst/EnergyPlus/unit/PVWatts.unit.cc @@ -183,10 +183,10 @@ TEST_F(EnergyPlusFixture, PVWattsGenerator_Calc) state->dataGlobal->TimeStep = 1; state->dataGlobal->TimeStepZone = 1.0; state->dataHVACGlobal->TimeStepSys = 1.0; - state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; state->dataGlobal->BeginTimeStepFlag = true; - state->dataGlobal->MinutesPerTimeStep = 60; - state->dataGlobal->NumOfTimeStepInHour = 1; + state->dataGlobal->MinutesInTimeStep = 60; + state->dataGlobal->TimeStepsInHour = 1; Weather::AllocateWeatherData(*state); // gets us the albedo array initialized state->dataEnvrn->Year = 1986; state->dataEnvrn->Month = 6; @@ -304,11 +304,13 @@ TEST_F(EnergyPlusFixture, PVWattsInverter_Constructor) ",", ";"}); ASSERT_TRUE(process_idf(idfTxt)); + state->init_state(*state); + auto eplc(ElectPowerLoadCenter(*state, 1)); ASSERT_TRUE(eplc.inverterPresent); EXPECT_DOUBLE_EQ(eplc.inverterObj->pvWattsDCCapacity(), 4000.0); state->dataHVACGlobal->TimeStepSys = 1.0; - state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; eplc.inverterObj->simulate(*state, 884.018); EXPECT_NEAR(eplc.inverterObj->aCPowerOut(), 842.527, 0.001); } diff --git a/tst/EnergyPlus/unit/PackagedTerminalHeatPump.unit.cc b/tst/EnergyPlus/unit/PackagedTerminalHeatPump.unit.cc index 7487dcafe92..9e9f5f66c0e 100644 --- a/tst/EnergyPlus/unit/PackagedTerminalHeatPump.unit.cc +++ b/tst/EnergyPlus/unit/PackagedTerminalHeatPump.unit.cc @@ -108,7 +108,6 @@ using namespace EnergyPlus::Fans; using namespace EnergyPlus::HeatBalanceManager; using namespace EnergyPlus::HeatingCoils; using namespace EnergyPlus::Psychrometrics; -using namespace EnergyPlus::ScheduleManager; using namespace EnergyPlus::SimulationManager; using namespace EnergyPlus::SingleDuct; using namespace EnergyPlus::SizingManager; @@ -835,12 +834,11 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctMixer_SimPTAC_HeatingCoilTest) }); ASSERT_TRUE(process_idf(idf_objects)); + state->dataGlobal->TimeStepsInHour = 1; + state->dataGlobal->MinutesInTimeStep = 60; + state->init_state(*state); - state->dataGlobal->NumOfTimeStepInHour = 1; state->dataGlobal->TimeStep = 1; - state->dataGlobal->MinutesPerTimeStep = 60; - ProcessScheduleInput(*state); // read schedules - InitializePsychRoutines(*state); OutputReportPredefined::SetPredefinedTables(*state); GetZoneData(*state, ErrorsFound); @@ -879,9 +877,9 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctMixer_SimPTAC_HeatingCoilTest) Psychrometrics::PsyHFnTdbW(state->dataLoopNodes->Node(state->dataZoneEquip->ZoneEquipConfig(1).ZoneNode).Temp, state->dataLoopNodes->Node(state->dataZoneEquip->ZoneEquipConfig(1).ZoneNode).HumRat); - state->dataScheduleMgr->Schedule(thisSys.m_FanOpModeSchedPtr).CurrentValue = 1.0; // unit is always on - state->dataScheduleMgr->Schedule(thisSys.m_SysAvailSchedPtr).CurrentValue = 1.0; // unit is always available - state->dataScheduleMgr->Schedule(thisSys.m_FanAvailSchedPtr).CurrentValue = 1.0; // fan is always available + thisSys.m_fanOpModeSched->currentVal = 1.0; // unit is always on + thisSys.m_sysAvailSched->currentVal = 1.0; // unit is always available + thisSys.m_fanAvailSched->currentVal = 1.0; // fan is always available // initialize mass flow rates state->dataLoopNodes->Node(thisSys.AirInNode).MassFlowRate = HVACInletMassFlowRate; @@ -915,7 +913,7 @@ TEST_F(EnergyPlusFixture, AirTerminalSingleDuctMixer_SimPTAC_HeatingCoilTest) state->dataGlobal->SysSizingCalc = true; state->dataHeatBalFanSys->TempControlType.allocate(1); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::SingleHeating; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::SingleHeat; state->dataZoneEnergyDemand->ZoneSysEnergyDemand.allocate(1); state->dataZoneEnergyDemand->ZoneSysMoistureDemand.allocate(1); @@ -1188,12 +1186,11 @@ TEST_F(EnergyPlusFixture, SimPTAC_SZVAVTest) }); ASSERT_TRUE(process_idf(idf_objects)); - - state->dataGlobal->NumOfTimeStepInHour = 1; + state->dataGlobal->TimeStepsInHour = 1; + state->dataGlobal->MinutesInTimeStep = 60; + state->init_state(*state); + state->dataGlobal->TimeStep = 1; - state->dataGlobal->MinutesPerTimeStep = 60; - ProcessScheduleInput(*state); // read schedules - InitializePsychRoutines(*state); OutputReportPredefined::SetPredefinedTables(*state); GetZoneData(*state, ErrorsFound); @@ -1232,9 +1229,9 @@ TEST_F(EnergyPlusFixture, SimPTAC_SZVAVTest) state->dataHVACGlobal->TurnFansOff = false; state->dataHVACGlobal->TurnFansOn = true; - state->dataScheduleMgr->Schedule(thisSys.m_FanOpModeSchedPtr).CurrentValue = 1.0; // unit is always on - state->dataScheduleMgr->Schedule(thisSys.m_SysAvailSchedPtr).CurrentValue = 1.0; // unit is always available - state->dataScheduleMgr->Schedule(thisSys.m_FanAvailSchedPtr).CurrentValue = 1.0; // fan is always available + thisSys.m_fanOpModeSched->currentVal = 1.0; // unit is always on + thisSys.m_sysAvailSched->currentVal = 1.0; // unit is always available + thisSys.m_fanAvailSched->currentVal = 1.0; // fan is always available // set fan parameters state->dataFans->fans(1)->maxAirMassFlowRate = HVACInletMassFlowRate; @@ -1262,7 +1259,7 @@ TEST_F(EnergyPlusFixture, SimPTAC_SZVAVTest) state->dataGlobal->SysSizingCalc = false; state->dataHeatBalFanSys->TempControlType.allocate(1); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::SingleHeating; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::SingleHeat; state->dataZoneEnergyDemand->ZoneSysEnergyDemand.allocate(1); state->dataZoneEnergyDemand->ZoneSysMoistureDemand.allocate(1); @@ -3838,18 +3835,18 @@ TEST_F(EnergyPlusFixture, PTACDrawAirfromReturnNodeAndPlenum_Test) state->dataIPShortCut->cAlphaArgs = " "; state->dataIPShortCut->rNumericArgs = 0.0; + state->dataGlobal->TimeStepsInHour = 4; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 15; // must initialize this to get schedules initialized + state->init_state(*state); + bool ErrorsFound = false; // Read objects - SimulationManager::GetProjectData(*state); HeatBalanceManager::GetProjectControlData(*state, ErrorsFound); EXPECT_FALSE(ErrorsFound); - state->dataGlobal->NumOfTimeStepInHour = 4; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 15; // must initialize this to get schedules initialized state->dataGlobal->TimeStepZone = 0.25; - state->dataGlobal->TimeStepZoneSec = state->dataGlobal->TimeStepZone * Constant::SecInHour; + state->dataGlobal->TimeStepZoneSec = state->dataGlobal->TimeStepZone * Constant::rSecsInHour; state->dataGlobal->CurrentTime = 12.0; - ProcessScheduleInput(*state); // read schedules HeatBalanceManager::GetHeatBalanceInput(*state); HeatBalanceManager::AllocateHeatBalArrays(*state); @@ -3912,20 +3909,23 @@ TEST_F(EnergyPlusFixture, PTACDrawAirfromReturnNodeAndPlenum_Test) } GetZoneAirSetPoints(*state); state->dataHeatBalFanSys->TempControlType.allocate(6); - state->dataHeatBalFanSys->TempControlType = HVAC::ThermostatType::DualSetPointWithDeadBand; + state->dataHeatBalFanSys->TempControlType = HVAC::SetptType::DualHeatCool; EnergyPlus::OutputReportPredefined::SetPredefinedTables(*state); - for (int i = 1; i <= 14; ++i) { - state->dataScheduleMgr->Schedule(i).CurrentValue = 1.0; // WindowVentSched - } - state->dataScheduleMgr->Schedule(5).CurrentValue = 117; // activity level - state->dataScheduleMgr->Schedule(6).CurrentValue = 0.0; // shade transmittance - state->dataScheduleMgr->Schedule(7).CurrentValue = 18.0; // heating set point - state->dataScheduleMgr->Schedule(8).CurrentValue = 24.0; // cooling set point - state->dataScheduleMgr->Schedule(11).CurrentValue = 4.0; // dual Tstat sch - state->dataScheduleMgr->Schedule(12).CurrentValue = 21.1; // DOAS SAT - state->dataScheduleMgr->Schedule(13).CurrentValue = 0.0; // cyc fan sch, CyclingFanSch - state->dataScheduleMgr->Schedule(14).CurrentValue = 1.0; // constant fan sch, ContsFanSch + Sched::GetSchedule(*state, "OCCUPY-1")->currentVal = 1.0; + Sched::GetSchedule(*state, "LIGHTS-1")->currentVal = 1.0; + Sched::GetSchedule(*state, "EQUIP-1")->currentVal = 1.0; + Sched::GetSchedule(*state, "INFIL-SCH")->currentVal = 1.0; + Sched::GetSchedule(*state, "ACTSCHD")->currentVal = 117; + Sched::GetSchedule(*state, "SHADETRANSSCH")->currentVal = 0.0; // shade transmittance + Sched::GetSchedule(*state, "HTG-SETP-SCH")->currentVal = 18.0; // heating set point + Sched::GetSchedule(*state, "CLG-SETP-SCH")->currentVal = 24.0; // cooling set point + Sched::GetSchedule(*state, "HVACTEMPLATE-ALWAYS 4")->currentVal = 4.0; // dual Tstat sch + Sched::GetSchedule(*state, "ALWAYS 21.1")->currentVal = 21.1; // DOAS SAT + Sched::GetSchedule(*state, "CYCLINGFANSCH")->currentVal = 0.0; // cyc fan sch, CyclingFanSch + Sched::GetSchedule(*state, "CONTSFANSCH")->currentVal = 1.0; // constant fan sch, ContsFanSch + Sched::GetSchedule(*state, "FANAVAILSCHED")->currentVal = 1.0; // Fan availability + int oaNode = 36; // this node index may change based on component calling order state->dataLoopNodes->Node(oaNode).MassFlowRate = 0.26908 * 1.2; state->dataLoopNodes->Node(oaNode).Temp = state->dataEnvrn->OutDryBulbTemp; @@ -4289,8 +4289,8 @@ TEST_F(EnergyPlusFixture, PTAC_ZoneEquipment_NodeInputTest) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); - ProcessScheduleInput(*state); // read schedules GetZoneData(*state, errorsFound); ASSERT_FALSE(errorsFound); @@ -4557,9 +4557,9 @@ TEST_F(EnergyPlusFixture, ZonePTHP_ElectricityRateTest) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); bool errorsFound = false; - ProcessScheduleInput(*state); // read schedules GetZoneData(*state, errorsFound); ASSERT_FALSE(errorsFound); @@ -4634,10 +4634,10 @@ TEST_F(EnergyPlusFixture, ZonePTHP_ElectricityRateTest) // set thermostat type state->dataHeatBalFanSys->TempControlType.allocate(1); state->dataHeatBalFanSys->TempControlTypeRpt.allocate(1); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::DualSetPointWithDeadBand; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::DualHeatCool; // set the uni sys is always available - state->dataScheduleMgr->Schedule(state->dataUnitarySystems->unitarySys[0].m_SysAvailSchedPtr).CurrentValue = 1.0; - state->dataScheduleMgr->Schedule(state->dataUnitarySystems->unitarySys[0].m_FanAvailSchedPtr).CurrentValue = 1.0; + state->dataUnitarySystems->unitarySys[0].m_sysAvailSched->currentVal = 1.0; + state->dataUnitarySystems->unitarySys[0].m_fanAvailSched->currentVal = 1.0; bool HeatActive = true; bool CoolActive = false; @@ -4890,12 +4890,11 @@ TEST_F(EnergyPlusFixture, PTAC_AvailabilityManagerTest) )IDF"; ASSERT_TRUE(process_idf(idf_objects)); // read idf objects + state->dataGlobal->TimeStepsInHour = 1; + state->dataGlobal->MinutesInTimeStep = 60; + state->init_state(*state); - state->dataGlobal->NumOfTimeStepInHour = 1; state->dataGlobal->TimeStep = 1; - state->dataGlobal->MinutesPerTimeStep = 60; - ProcessScheduleInput(*state); // read schedules - InitializePsychRoutines(*state); OutputReportPredefined::SetPredefinedTables(*state); GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); @@ -4927,9 +4926,9 @@ TEST_F(EnergyPlusFixture, PTAC_AvailabilityManagerTest) state->dataLoopNodes->Node(state->dataZoneEquip->ZoneEquipConfig(1).ZoneNode).Enthalpy = Psychrometrics::PsyHFnTdbW(state->dataLoopNodes->Node(state->dataZoneEquip->ZoneEquipConfig(1).ZoneNode).Temp, state->dataLoopNodes->Node(state->dataZoneEquip->ZoneEquipConfig(1).ZoneNode).HumRat); - state->dataScheduleMgr->Schedule(thisSys.m_FanOpModeSchedPtr).CurrentValue = 1.0; - state->dataScheduleMgr->Schedule(thisSys.m_SysAvailSchedPtr).CurrentValue = 1.0; - state->dataScheduleMgr->Schedule(thisSys.m_FanAvailSchedPtr).CurrentValue = 1.0; + thisSys.m_fanOpModeSched->currentVal = 1.0; + thisSys.m_sysAvailSched->currentVal = 1.0; + thisSys.m_fanAvailSched->currentVal = 1.0; // initialize mass flow rates state->dataLoopNodes->Node(thisSys.AirInNode).MassFlowRate = HVACInletMassFlowRate; state->dataLoopNodes->Node(thisSys.m_OAMixerNodes[0]).MassFlowRate = PrimaryAirMassFlowRate; @@ -4953,7 +4952,7 @@ TEST_F(EnergyPlusFixture, PTAC_AvailabilityManagerTest) state->dataUnitarySystems->unitarySys[0].ControlZoneNum = 1; state->dataHeatBalFanSys->TempControlType.allocate(1); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::SingleHeating; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::SingleHeat; state->dataZoneEnergyDemand->ZoneSysEnergyDemand.allocate(1); state->dataZoneEnergyDemand->ZoneSysMoistureDemand.allocate(1); state->dataZoneEnergyDemand->ZoneSysEnergyDemand(1).RemainingOutputReqToHeatSP = 0.0; // set heating load to zero @@ -5015,9 +5014,9 @@ TEST_F(EnergyPlusFixture, PTAC_AvailabilityManagerTest) state->dataHeatBalFanSys->TempControlType.allocate(NumZones); state->dataHeatBalFanSys->TempControlTypeRpt.allocate(NumZones); state->dataHeatBalFanSys->TempTstatAir.allocate(NumZones); - state->dataHeatBalFanSys->TempZoneThermostatSetPoint.allocate(NumZones); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::SingleCooling; - state->dataHeatBalFanSys->TempZoneThermostatSetPoint(1) = 21.1; + state->dataHeatBalFanSys->zoneTstatSetpts.allocate(NumZones); + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::SingleCool; + state->dataHeatBalFanSys->zoneTstatSetpts(1).setpt = 21.1; state->dataHeatBalFanSys->TempTstatAir(1) = 21.1; // get system availability schedule Avail::GetSysAvailManagerListInputs(*state); @@ -5033,7 +5032,7 @@ TEST_F(EnergyPlusFixture, PTAC_AvailabilityManagerTest) // test 1: availability manager status to off state->dataHVACGlobal->TurnFansOn = false; state->dataHVACGlobal->TurnFansOff = true; - state->dataHeatBalFanSys->TempZoneThermostatSetPoint(1) = 21.10; + state->dataHeatBalFanSys->zoneTstatSetpts(1).setpt = 21.10; state->dataHeatBalFanSys->TempTstatAir(1) = 21.1; sysAvailMgr.availStatus = Avail::Status::NoAction; // run calc system availability requirement @@ -5054,11 +5053,11 @@ TEST_F(EnergyPlusFixture, PTAC_AvailabilityManagerTest) // test 2: availability manager status to on state->dataAvail->ZoneComp(zoneEquipType).ZoneCompAvailMgrs(1).StartTime = 0.0; state->dataAvail->ZoneComp(zoneEquipType).ZoneCompAvailMgrs(1).StopTime = 4.0; - state->dataHeatBalFanSys->TempZoneThermostatSetPoint(1) = 21.10; + state->dataHeatBalFanSys->zoneTstatSetpts(1).setpt = 21.10; state->dataHeatBalFanSys->TempTstatAir(1) = 21.5; sysAvailMgr.availStatus = Avail::Status::NoAction; - state->dataScheduleMgr->Schedule(1).CurrentValue = 1; - state->dataScheduleMgr->Schedule(2).CurrentValue = 0; + Sched::GetSchedule(*state, "FANAVAILSCHED")->currentVal = 1; + Sched::GetSchedule(*state, "FANCYCLING")->currentVal = 0; // run calc system availability requirement availStatus = Avail::CalcNCycSysAvailMgr(*state, SysAvailNum, PriAirSysNum, zoneEquipType, CompNum); // check that the availability manager is cycling On diff --git a/tst/EnergyPlus/unit/PhotovoltaicThermalCollectors.unit.cc b/tst/EnergyPlus/unit/PhotovoltaicThermalCollectors.unit.cc index 58f832bb704..2d4043971f6 100644 --- a/tst/EnergyPlus/unit/PhotovoltaicThermalCollectors.unit.cc +++ b/tst/EnergyPlus/unit/PhotovoltaicThermalCollectors.unit.cc @@ -69,6 +69,7 @@ using namespace EnergyPlus; TEST_F(EnergyPlusFixture, BIPVT_calc_k_taoalpha) { + state->init_state(*state); PhotovoltaicThermalCollectors::PVTCollectorStruct thisBIPVT; Real64 theta = 0.0; // lower value Real64 glass_thickness = 0.001; @@ -233,6 +234,8 @@ TEST_F(EnergyPlusFixture, BIPVT_calculateBIPVTMaxHeatGain) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + // bool foundErrors = false; // HeatBalanceManager::GetMaterialData(*state, foundErrors); // read material data // EXPECT_FALSE(foundErrors); // expect no errors diff --git a/tst/EnergyPlus/unit/PlantCentralGSHP.unit.cc b/tst/EnergyPlus/unit/PlantCentralGSHP.unit.cc index 4cdfdf1dea1..ec85ff95119 100644 --- a/tst/EnergyPlus/unit/PlantCentralGSHP.unit.cc +++ b/tst/EnergyPlus/unit/PlantCentralGSHP.unit.cc @@ -75,7 +75,7 @@ TEST_F(EnergyPlusFixture, ChillerHeater_Autosize) state->dataPlantCentralGSHP->Wrapper(1).WrapperComp(1).WrapperPerformanceObjectType = "CHILLERHEATERPERFORMANCE:ELECTRIC:EIR"; state->dataPlantCentralGSHP->Wrapper(1).WrapperComp(1).WrapperIdenticalObjectNum = 2; - state->dataPlantCentralGSHP->Wrapper(1).WrapperComp(1).CHSchedPtr = ScheduleManager::ScheduleAlwaysOn; + state->dataPlantCentralGSHP->Wrapper(1).WrapperComp(1).chSched = Sched::GetScheduleAlwaysOn(*state); state->dataPlantCentralGSHP->Wrapper(1).ChillerHeaterNums = 2; state->dataPlantCentralGSHP->Wrapper(1).ChillerHeater.allocate(2); // First test in SizeWrapper, so need to set that @@ -354,6 +354,8 @@ TEST_F(EnergyPlusFixture, Test_CentralHeatPumpSystem_Control_Schedule_fix) ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + // May not need for direct wrapper input processing call (need when caling factory) state->dataPlantCentralGSHP->getWrapperInputFlag = true; @@ -361,5 +363,5 @@ TEST_F(EnergyPlusFixture, Test_CentralHeatPumpSystem_Control_Schedule_fix) PlantCentralGSHP::GetWrapperInput(*state); // verify that under this scenario of not finding a schedule match, ScheduleAlwaysOn is the treated default - EXPECT_EQ(state->dataPlantCentralGSHP->Wrapper(1).WrapperComp(1).CHSchedPtr, ScheduleManager::ScheduleAlwaysOn); + EXPECT_EQ(state->dataPlantCentralGSHP->Wrapper(1).WrapperComp(1).chSched, Sched::GetScheduleAlwaysOn(*state)); } diff --git a/tst/EnergyPlus/unit/PlantComponentTemperatureSources.unit.cc b/tst/EnergyPlus/unit/PlantComponentTemperatureSources.unit.cc index 9fe6e990715..8390e6f7d98 100644 --- a/tst/EnergyPlus/unit/PlantComponentTemperatureSources.unit.cc +++ b/tst/EnergyPlus/unit/PlantComponentTemperatureSources.unit.cc @@ -72,6 +72,8 @@ TEST_F(EnergyPlusFixture, TestPlantComponentTemperatureSource) " ; !- Source Temperature Schedule Name"}); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + // Setup the plant itself manually state->dataPlnt->TotNumLoops = 1; state->dataPlnt->PlantLoop.allocate(1); @@ -116,10 +118,5 @@ TEST_F(EnergyPlusFixture, TestPlantComponentTemperatureSource) myLoad = 1696.55; waterSource1.simulate(*state, loc, firstHVACIteration, myLoad, runFlag); EXPECT_NEAR(0.05, waterSource1.MassFlowRate, 0.001); - - // Do this for scheduled temperature - // NumOfTimeStepInHour = 1; // must initialize this to get schedules initialized - // MinutesPerTimeStep = 60; // must initialize this to get schedules initialized - // ProcessScheduleInput(); // read schedules } } // namespace EnergyPlus diff --git a/tst/EnergyPlus/unit/PlantCondLoopOperation.unit.cc b/tst/EnergyPlus/unit/PlantCondLoopOperation.unit.cc index 1d23eb5efe9..fd8ae656deb 100644 --- a/tst/EnergyPlus/unit/PlantCondLoopOperation.unit.cc +++ b/tst/EnergyPlus/unit/PlantCondLoopOperation.unit.cc @@ -947,6 +947,8 @@ TEST_F(EnergyPlusFixture, ThermalEnergyStorageWithIceForceDualOp) EXPECT_TRUE(process_idf(idf_objects, false)); + state->init_state(*state); + // Setup the plant itself manually state->dataPlnt->TotNumLoops = 1; state->dataPlnt->PlantLoop.allocate(1); diff --git a/tst/EnergyPlus/unit/PlantHeatExchangerFluidToFluid.unit.cc b/tst/EnergyPlus/unit/PlantHeatExchangerFluidToFluid.unit.cc index 1ee0b3b5922..0293b2196c4 100644 --- a/tst/EnergyPlus/unit/PlantHeatExchangerFluidToFluid.unit.cc +++ b/tst/EnergyPlus/unit/PlantHeatExchangerFluidToFluid.unit.cc @@ -1060,11 +1060,12 @@ TEST_F(EnergyPlusFixture, PlantHXModulatedDualDeadDefectFileHi) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + bool ErrorsFound = false; state->dataGlobal->BeginSimFlag = true; - SimulationManager::GetProjectData(*state); - + OutputReportPredefined::SetPredefinedTables(*state); HeatBalanceManager::SetPreConstructionInputParameters(*state); // establish array bounds for constructions early // OutputProcessor::TimeValue.allocate(2); @@ -1116,7 +1117,7 @@ TEST_F(EnergyPlusFixture, PlantHXModulatedDualDeadDefectFileHi) state->dataGlobal->BeginHourFlag = true; state->dataGlobal->EndHourFlag = false; - for (state->dataGlobal->TimeStep = 1; state->dataGlobal->TimeStep <= state->dataGlobal->NumOfTimeStepInHour; + for (state->dataGlobal->TimeStep = 1; state->dataGlobal->TimeStep <= state->dataGlobal->TimeStepsInHour; ++state->dataGlobal->TimeStep) { state->dataGlobal->BeginTimeStepFlag = true; @@ -1128,7 +1129,7 @@ TEST_F(EnergyPlusFixture, PlantHXModulatedDualDeadDefectFileHi) // Note also that BeginTimeStepFlag, EndTimeStepFlag, and the // SubTimeStepFlags can/will be set/reset in the HVAC Manager. - if (state->dataGlobal->TimeStep == state->dataGlobal->NumOfTimeStepInHour) { + if (state->dataGlobal->TimeStep == state->dataGlobal->TimeStepsInHour) { state->dataGlobal->EndHourFlag = true; if (state->dataGlobal->HourOfDay == 24) { state->dataGlobal->EndDayFlag = true; @@ -2152,10 +2153,10 @@ TEST_F(EnergyPlusFixture, PlantHXModulatedDualDeadDefectFileLo) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); bool ErrorsFound = false; state->dataGlobal->BeginSimFlag = true; - SimulationManager::GetProjectData(*state); OutputReportPredefined::SetPredefinedTables(*state); HeatBalanceManager::SetPreConstructionInputParameters(*state); // establish array bounds for constructions early @@ -2208,7 +2209,7 @@ TEST_F(EnergyPlusFixture, PlantHXModulatedDualDeadDefectFileLo) state->dataGlobal->BeginHourFlag = true; state->dataGlobal->EndHourFlag = false; - for (state->dataGlobal->TimeStep = 1; state->dataGlobal->TimeStep <= state->dataGlobal->NumOfTimeStepInHour; + for (state->dataGlobal->TimeStep = 1; state->dataGlobal->TimeStep <= state->dataGlobal->TimeStepsInHour; ++state->dataGlobal->TimeStep) { state->dataGlobal->BeginTimeStepFlag = true; @@ -2220,7 +2221,7 @@ TEST_F(EnergyPlusFixture, PlantHXModulatedDualDeadDefectFileLo) // Note also that BeginTimeStepFlag, EndTimeStepFlag, and the // SubTimeStepFlags can/will be set/reset in the HVAC Manager. - if (state->dataGlobal->TimeStep == state->dataGlobal->NumOfTimeStepInHour) { + if (state->dataGlobal->TimeStep == state->dataGlobal->TimeStepsInHour) { state->dataGlobal->EndHourFlag = true; if (state->dataGlobal->HourOfDay == 24) { state->dataGlobal->EndDayFlag = true; @@ -2259,6 +2260,11 @@ TEST_F(EnergyPlusFixture, PlantHXModulatedDualDeadDefectFileLo) TEST_F(EnergyPlusFixture, PlantHXControlWithFirstHVACIteration) { + // get availability schedule to work + state->dataGlobal->TimeStepsInHour = 1; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 60; // must initialize this to get schedules initialized + state->init_state(*state); + // this unit test is for issue #4959. Added FirstHVACIteration to simulate and control routines // unit test checks that the change to logic for #4959 does work to affect node mass flow rate. The conditions are set up such that the demand // side inlet is too warm to cool the supply side, so previous behavior would shut down flow. Now if firstHVACIteration is true is should set @@ -2267,11 +2273,6 @@ TEST_F(EnergyPlusFixture, PlantHXControlWithFirstHVACIteration) state->dataPlantHXFluidToFluid->FluidHX.allocate(1); - // get availability schedule to work - state->dataGlobal->NumOfTimeStepInHour = 1; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 60; // must initialize this to get schedules initialized - ScheduleManager::ProcessScheduleInput(*state); // read schedules - state->dataScheduleMgr->ScheduleInputProcessed = true; state->dataEnvrn->Month = 1; state->dataEnvrn->DayOfMonth = 21; state->dataGlobal->HourOfDay = 1; @@ -2280,8 +2281,8 @@ TEST_F(EnergyPlusFixture, PlantHXControlWithFirstHVACIteration) state->dataEnvrn->DayOfWeek = 2; state->dataEnvrn->HolidayIndex = 0; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); - ScheduleManager::UpdateScheduleValues(*state); - state->dataPlantHXFluidToFluid->FluidHX(1).AvailSchedNum = -1; + Sched::UpdateScheduleVals(*state); + state->dataPlantHXFluidToFluid->FluidHX(1).availSched = Sched::GetScheduleAlwaysOn(*state); // setup four plant nodes for HX state->dataLoopNodes->Node.allocate(4); @@ -2368,13 +2369,13 @@ TEST_F(EnergyPlusFixture, PlantHXControl_CoolingSetpointOnOffWithComponentOverri // this unit test is for issue #5626. Fixed logic for CoolingSetpointOnOffWithComponentOverride. // unit test checks that the change for #5626 adjusts the temperature value used in central plant dispatch routines by the tolerance value. + // get availability schedule to work + state->dataGlobal->TimeStepsInHour = 1; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 60; // must initialize this to get schedules initialized + state->init_state(*state); + state->dataPlantHXFluidToFluid->FluidHX.allocate(1); - // get availability schedule to work - state->dataGlobal->NumOfTimeStepInHour = 1; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 60; // must initialize this to get schedules initialized - ScheduleManager::ProcessScheduleInput(*state); // read schedules - state->dataScheduleMgr->ScheduleInputProcessed = true; state->dataEnvrn->Month = 1; state->dataEnvrn->DayOfMonth = 21; state->dataGlobal->HourOfDay = 1; @@ -2383,8 +2384,8 @@ TEST_F(EnergyPlusFixture, PlantHXControl_CoolingSetpointOnOffWithComponentOverri state->dataEnvrn->DayOfWeek = 2; state->dataEnvrn->HolidayIndex = 0; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); - ScheduleManager::UpdateScheduleValues(*state); - state->dataPlantHXFluidToFluid->FluidHX(1).AvailSchedNum = -1; + Sched::UpdateScheduleVals(*state); + state->dataPlantHXFluidToFluid->FluidHX(1).availSched = Sched::GetScheduleAlwaysOn(*state); // setup four plant nodes for HX state->dataLoopNodes->Node.allocate(6); diff --git a/tst/EnergyPlus/unit/PlantLoadProfile.unit.cc b/tst/EnergyPlus/unit/PlantLoadProfile.unit.cc index 79596369112..6caa5addb15 100644 --- a/tst/EnergyPlus/unit/PlantLoadProfile.unit.cc +++ b/tst/EnergyPlus/unit/PlantLoadProfile.unit.cc @@ -103,6 +103,8 @@ TEST_F(EnergyPlusFixture, LoadProfile_GetInput) }); ASSERT_TRUE(process_idf(idf_objects, false)); + state->init_state(*state); + GetPlantProfileInput(*state); // Tests for LoadProfile on Water loop @@ -152,18 +154,17 @@ TEST_F(EnergyPlusFixture, LoadProfile_initandsimulate_Waterloop) thisLoadProfileWaterLoop.Name = "LOAD PROFILE WATER"; thisLoadProfileWaterLoop.FluidType = PlantLoopFluidType::Water; thisLoadProfileWaterLoop.PeakVolFlowRate = 0.002; - thisLoadProfileWaterLoop.LoadSchedule = 1; - thisLoadProfileWaterLoop.FlowRateFracSchedule = 2; + thisLoadProfileWaterLoop.loadSched = Sched::AddScheduleConstant(*state, "LOAD"); + thisLoadProfileWaterLoop.flowRateFracSched = Sched::AddScheduleConstant(*state, "FLOWRATEFRAC"); thisLoadProfileWaterLoop.InletNode = 1; thisLoadProfileWaterLoop.OutletNode = 2; thisLoadProfileWaterLoop.plantLoc = locWater; thisLoadProfileWaterLoop.plantLoc.loopNum = 1; - state->dataScheduleMgr->Schedule.allocate(2); - state->dataScheduleMgr->Schedule(thisLoadProfileWaterLoop.LoadSchedule).EMSActuatedOn = false; - state->dataScheduleMgr->Schedule(thisLoadProfileWaterLoop.LoadSchedule).CurrentValue = 10000; - state->dataScheduleMgr->Schedule(thisLoadProfileWaterLoop.FlowRateFracSchedule).EMSActuatedOn = false; - state->dataScheduleMgr->Schedule(thisLoadProfileWaterLoop.FlowRateFracSchedule).CurrentValue = 0.8; + thisLoadProfileWaterLoop.loadSched->EMSActuatedOn = false; + thisLoadProfileWaterLoop.loadSched->currentVal = 10000; + thisLoadProfileWaterLoop.flowRateFracSched->EMSActuatedOn = false; + thisLoadProfileWaterLoop.flowRateFracSched->currentVal = 0.8; // InitPlantProfile() thisLoadProfileWaterLoop.InitPlantProfile(*state); @@ -227,18 +228,17 @@ TEST_F(EnergyPlusFixture, LoadProfile_initandsimulate_Steamloop) thisLoadProfileSteamLoop.FluidType = PlantLoopFluidType::Steam; thisLoadProfileSteamLoop.PeakVolFlowRate = 0.008; thisLoadProfileSteamLoop.DegOfSubcooling = 3.0; - thisLoadProfileSteamLoop.LoadSchedule = 1; - thisLoadProfileSteamLoop.FlowRateFracSchedule = 2; + thisLoadProfileSteamLoop.loadSched = Sched::AddScheduleConstant(*state, "LOAD"); + thisLoadProfileSteamLoop.flowRateFracSched = Sched::AddScheduleConstant(*state, "FLOWRATEFRAC"); thisLoadProfileSteamLoop.InletNode = 1; thisLoadProfileSteamLoop.OutletNode = 2; thisLoadProfileSteamLoop.plantLoc = locSteam; thisLoadProfileSteamLoop.plantLoc.loopNum = 1; - state->dataScheduleMgr->Schedule.allocate(2); - state->dataScheduleMgr->Schedule(thisLoadProfileSteamLoop.LoadSchedule).EMSActuatedOn = false; - state->dataScheduleMgr->Schedule(thisLoadProfileSteamLoop.LoadSchedule).CurrentValue = 10000; - state->dataScheduleMgr->Schedule(thisLoadProfileSteamLoop.FlowRateFracSchedule).EMSActuatedOn = false; - state->dataScheduleMgr->Schedule(thisLoadProfileSteamLoop.FlowRateFracSchedule).CurrentValue = 0.8; + thisLoadProfileSteamLoop.loadSched->EMSActuatedOn = false; + thisLoadProfileSteamLoop.loadSched->currentVal = 10000; + thisLoadProfileSteamLoop.flowRateFracSched->EMSActuatedOn = false; + thisLoadProfileSteamLoop.flowRateFracSched->currentVal = 0.8; // InitPlantProfile() thisLoadProfileSteamLoop.InitPlantProfile(*state); diff --git a/tst/EnergyPlus/unit/PlantLoopHeatPumpEIR.unit.cc b/tst/EnergyPlus/unit/PlantLoopHeatPumpEIR.unit.cc index c09d3242191..a22288bd344 100644 --- a/tst/EnergyPlus/unit/PlantLoopHeatPumpEIR.unit.cc +++ b/tst/EnergyPlus/unit/PlantLoopHeatPumpEIR.unit.cc @@ -120,6 +120,7 @@ TEST_F(EnergyPlusFixture, ConstructionFullObjectsHeatingAndCooling_WaterSource) " 1,", " 1;"}); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); // call the factory with a valid name to trigger reading inputs EIRPlantLoopHeatPump::factory(*state, DataPlant::PlantEquipmentType::HeatPumpEIRHeating, "HP HEATING SIDE"); @@ -230,6 +231,7 @@ TEST_F(EnergyPlusFixture, HeatingConstructionFullObjectsNoCompanion) " 1,", " 1;"}); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); // call the factory with a valid name to trigger reading inputs EIRPlantLoopHeatPump::factory(*state, DataPlant::PlantEquipmentType::HeatPumpEIRHeating, "HP HEATING SIDE"); @@ -281,6 +283,7 @@ TEST_F(EnergyPlusFixture, CoolingConstructionFullObjectsNoCompanion) " 1,", " 1;"}); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); // call the factory with a valid name to trigger reading inputs EIRPlantLoopHeatPump::factory(*state, DataPlant::PlantEquipmentType::HeatPumpEIRCooling, "HP COOLING SIDE"); @@ -332,6 +335,7 @@ TEST_F(EnergyPlusFixture, CoolingConstructionFullObjectWithDefaults) " 1,", " 1;"}); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); // call the factory with a valid name to trigger reading inputs EIRPlantLoopHeatPump::factory(*state, DataPlant::PlantEquipmentType::HeatPumpEIRCooling, "HP COOLING SIDE"); @@ -376,6 +380,7 @@ TEST_F(EnergyPlusFixture, CoolingConstructionFullyAutoSized_WaterSource) " 1,", " 1;"}); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); // call the factory with a valid name to trigger reading inputs EIRPlantLoopHeatPump::factory(*state, DataPlant::PlantEquipmentType::HeatPumpEIRCooling, "HP COOLING SIDE"); @@ -421,6 +426,8 @@ TEST_F(EnergyPlusFixture, CatchErrorsOnBadCurves) " dummyCurveB,", " dummyCurveC;"}); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + // call the factory with a valid name to trigger reading inputs, it should throw for the bad curves EXPECT_THROW(EIRPlantLoopHeatPump::factory(*state, DataPlant::PlantEquipmentType::HeatPumpEIRCooling, "HP COOLING SIDE"), std::runtime_error); } @@ -453,6 +460,7 @@ TEST_F(EnergyPlusFixture, processInputForEIRPLHP_TestAirSourceDuplicateNodes) " 1,", " 1;"}); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); // set up the plant loops // first the load side @@ -522,6 +530,7 @@ TEST_F(EnergyPlusFixture, processInputForEIRPLHP_TestAirSourceOANode) "OutdoorAir:NodeList,", " node 3;"}); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); // set up the plant loops // first the load side @@ -581,6 +590,7 @@ TEST_F(EnergyPlusFixture, processInputForEIRPLHP_TestAirSourceNoOANode) " 1,", " 1;"}); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); // set up the plant loops // first the load side @@ -651,7 +661,8 @@ TEST_F(EnergyPlusFixture, Initialization) " 1,", " 1;"}); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + // set up the plant loops // first the load side state->dataPlnt->TotNumLoops = 2; @@ -773,7 +784,8 @@ TEST_F(EnergyPlusFixture, TestSizing_FullyAutosizedCoolingWithCompanion_WaterSou " 1,", " 1;"}); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + // call the factory with a valid name to trigger reading inputs EIRPlantLoopHeatPump::factory(*state, DataPlant::PlantEquipmentType::HeatPumpEIRCooling, "HP COOLING SIDE"); @@ -966,7 +978,8 @@ TEST_F(EnergyPlusFixture, TestSizing_FullyHardsizedHeatingWithCompanion) " 1,", " 1;"}); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + // call the factory with a valid name to trigger reading inputs EIRPlantLoopHeatPump::factory(*state, DataPlant::PlantEquipmentType::HeatPumpEIRCooling, "HP COOLING SIDE"); @@ -1109,7 +1122,8 @@ TEST_F(EnergyPlusFixture, TestSizing_WithCompanionNoPlantSizing) " 1,", " 1;"}); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + // call the factory with a valid name to trigger reading inputs EIRPlantLoopHeatPump::factory(*state, DataPlant::PlantEquipmentType::HeatPumpEIRCooling, "HP COOLING SIDE"); @@ -1225,7 +1239,8 @@ TEST_F(EnergyPlusFixture, TestSizing_NoCompanionNoPlantSizingError) " 1,", " 1;"}); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + // call the factory with a valid name to trigger reading inputs EIRPlantLoopHeatPump::factory(*state, DataPlant::PlantEquipmentType::HeatPumpEIRHeating, "HP HEATING SIDE"); @@ -1317,7 +1332,8 @@ TEST_F(EnergyPlusFixture, TestSizing_NoCompanionNoPlantSizingHardSized) " 1,", " 1;"}); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + // call the factory with a valid name to trigger reading inputs EIRPlantLoopHeatPump::factory(*state, DataPlant::PlantEquipmentType::HeatPumpEIRHeating, "HP HEATING SIDE"); @@ -1413,7 +1429,8 @@ TEST_F(EnergyPlusFixture, CoolingOutletSetpointWorker) " 1,", " 1;"}); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + // set up the plant loops // first the load side state->dataPlnt->TotNumLoops = 1; @@ -1495,6 +1512,7 @@ TEST_F(EnergyPlusFixture, HeatingOutletSetpointWorker) " 1,", " 1;"}); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); // set up the plant loops // first the load side @@ -1567,6 +1585,7 @@ TEST_F(EnergyPlusFixture, Initialization2_WaterSource) " 1,", " 1;"}); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); bool firstHVACIteration = true; // set up the plant loops @@ -1704,6 +1723,7 @@ TEST_F(EnergyPlusFixture, OnInitLoopEquipTopologyErrorCases) " 1,", " 1;"}); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); // set up a couple simple plant loops with one branch per loop-side and one component per branch state->dataPlnt->TotNumLoops = 2; @@ -1824,6 +1844,7 @@ TEST_F(EnergyPlusFixture, CoolingSimulate_WaterSource) " 1,", " 1;"}); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); // set up the plant loops // first the load side @@ -1961,7 +1982,8 @@ TEST_F(EnergyPlusFixture, HeatingSimulate_WaterSource) " 1,", " 1;"}); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + // set up the plant loops // first the load side state->dataPlnt->TotNumLoops = 2; @@ -2137,7 +2159,8 @@ TEST_F(EnergyPlusFixture, ConstructionFullObjectsHeatingAndCooling_AirSource) " 1,", " 1;"}); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + // call the factory with a valid name to trigger reading inputs EIRPlantLoopHeatPump::factory(*state, DataPlant::PlantEquipmentType::HeatPumpEIRHeating, "HP HEATING SIDE"); @@ -2199,7 +2222,8 @@ TEST_F(EnergyPlusFixture, CoolingSimulate_AirSource) " 1,", " 1;"}); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + // set up the plant loops // first the load side state->dataPlnt->TotNumLoops = 1; @@ -2319,7 +2343,8 @@ TEST_F(EnergyPlusFixture, HeatingSimulate_AirSource) " 1,", " 1;"}); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + // set up the plant loops // first the load side state->dataPlnt->TotNumLoops = 1; @@ -2455,7 +2480,8 @@ TEST_F(EnergyPlusFixture, CoolingConstructionFullyAutoSized_AirSource) " 1,", " 1;"}); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + // call the factory with a valid name to trigger reading inputs EIRPlantLoopHeatPump::factory(*state, DataPlant::PlantEquipmentType::HeatPumpEIRCooling, "HP COOLING SIDE"); @@ -2506,7 +2532,8 @@ TEST_F(EnergyPlusFixture, ClearState) " 1,", " 1;"}); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + // call the factory with a valid name to trigger reading inputs EIRPlantLoopHeatPump::factory(*state, DataPlant::PlantEquipmentType::HeatPumpEIRCooling, "HP COOLING SIDE"); EXPECT_EQ(state->dataEIRPlantLoopHeatPump->heatPumps.size(), 1u); @@ -2544,7 +2571,8 @@ TEST_F(EnergyPlusFixture, Initialization2_AirSource) " 1,", " 1;"}); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + bool firstHVACIteration = true; // set up the plant loops // first the load side @@ -2680,7 +2708,8 @@ TEST_F(EnergyPlusFixture, TestSizing_FullyAutosizedCoolingWithCompanion_AirSourc " 1,", " 1;"}); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + // call the factory with a valid name to trigger reading inputs EIRPlantLoopHeatPump::factory(*state, DataPlant::PlantEquipmentType::HeatPumpEIRCooling, "HP COOLING SIDE"); @@ -2849,7 +2878,8 @@ TEST_F(EnergyPlusFixture, TestSizing_HardsizedFlowAutosizedCoolingWithCompanion_ " 1,", " 1;"}); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + // call the factory with a valid name to trigger reading inputs EIRPlantLoopHeatPump::factory(*state, DataPlant::PlantEquipmentType::HeatPumpEIRCooling, "HP COOLING SIDE"); @@ -2983,7 +3013,8 @@ TEST_F(EnergyPlusFixture, TestSizing_AutosizedFlowWithCompanion_AirSource) " 1,", " 1;"}); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + // call the factory with a valid name to trigger reading inputs EIRPlantLoopHeatPump::factory(*state, DataPlant::PlantEquipmentType::HeatPumpEIRCooling, "HP COOLING SIDE"); @@ -3131,7 +3162,8 @@ TEST_F(EnergyPlusFixture, Test_DoPhysics) " 1.0;"}); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + // set up the plant loops // first the load side state->dataPlnt->TotNumLoops = 2; @@ -3191,7 +3223,7 @@ TEST_F(EnergyPlusFixture, Test_DoPhysics) PLHPPlantLoadSideComp.CurOpSchemeType = DataPlant::OpScheme::CoolingRB; state->dataHVACGlobal->TimeStepSys = 60; - state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; Real64 curLoad = -10000; @@ -3233,7 +3265,8 @@ TEST_F(EnergyPlusFixture, CoolingMetering) " 1,", " 1;"}); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + // set up the plant loops // first the load side state->dataPlnt->TotNumLoops = 2; @@ -3324,7 +3357,8 @@ TEST_F(EnergyPlusFixture, HeatingMetering) " 1,", " 1;"}); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + // set up the plant loops // first the load side state->dataPlnt->TotNumLoops = 2; @@ -3432,7 +3466,8 @@ TEST_F(EnergyPlusFixture, TestOperatingFlowRates_FullyAutosized_AirSource) " 1,", " 1;"}); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + bool firstHVACIteration = true; // set up the plant loops // first the load side @@ -3608,7 +3643,8 @@ TEST_F(EnergyPlusFixture, Test_Curve_Negative_Energy) " 1.0;"}); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + // set up the plant loops // first the load side state->dataPlnt->TotNumLoops = 2; @@ -3668,7 +3704,7 @@ TEST_F(EnergyPlusFixture, Test_Curve_Negative_Energy) PLHPPlantLoadSideComp.CurOpSchemeType = DataPlant::OpScheme::CoolingRB; state->dataHVACGlobal->TimeStepSys = 60; - state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; Real64 curLoad = -10000; @@ -3798,7 +3834,8 @@ TEST_F(EnergyPlusFixture, GAHP_HeatingConstructionFullObjectsNoCompanion) " 1,", " 1;"}); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + // call the factory with a valid name to trigger reading inputs EIRFuelFiredHeatPump::factory(*state, DataPlant::PlantEquipmentType::HeatPumpFuelFiredHeating, "FUEL FIRED HP HEATING SIDE"); @@ -3925,7 +3962,8 @@ TEST_F(EnergyPlusFixture, GAHP_HeatingConstructionFullObjectsNoCompanion_with_De " 1,", " 1;"}); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + // call the factory with a valid name to trigger reading inputs EIRFuelFiredHeatPump::factory(*state, DataPlant::PlantEquipmentType::HeatPumpFuelFiredHeating, "FUEL FIRED HP HEATING SIDE"); @@ -4052,7 +4090,8 @@ TEST_F(EnergyPlusFixture, GAHP_Initialization_Test) " 1,", " 1;"}); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + bool firstHVACIteration = true; // set up the plant loops // first the load side @@ -4238,7 +4277,8 @@ TEST_F(EnergyPlusFixture, GAHP_HeatingSimulate_AirSource) " 1;"}); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + // set up the plant loops // first the load side state->dataPlnt->TotNumLoops = 1; @@ -4458,8 +4498,10 @@ TEST_F(EnergyPlusFixture, GAHP_HeatingSimulate_AirSource_with_Defrost) ASSERT_TRUE(process_idf(idf_objects)); state->dataHVACGlobal->TimeStepSys = 0.25; - state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; + state->init_state(*state); + // set up the plant loops // first the load side state->dataPlnt->TotNumLoops = 1; @@ -4635,7 +4677,8 @@ TEST_F(EnergyPlusFixture, Test_HeatRecoveryGetInputs_AirSource) " 1,", " 1;"}); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + // call the factory with a valid name to trigger reading inputs EIRPlantLoopHeatPump::factory(*state, DataPlant::PlantEquipmentType::HeatPumpEIRCooling, "HP COOLING SIDE"); @@ -4702,7 +4745,8 @@ TEST_F(EnergyPlusFixture, Test_HeatRecoveryFlowSizing_AirSource) " 1,", " 1;"}); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + // call the factory with a valid name to trigger reading inputs EIRPlantLoopHeatPump::factory(*state, DataPlant::PlantEquipmentType::HeatPumpEIRCooling, "HP COOLING SIDE"); @@ -4847,7 +4891,8 @@ TEST_F(EnergyPlusFixture, CoolingwithHeatRecoverySimulate_AirSource) " 1,", " 1;"}); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + // call the factory with a valid name to trigger reading inputs EIRPlantLoopHeatPump::factory(*state, DataPlant::PlantEquipmentType::HeatPumpEIRCooling, "HP COOLING SIDE"); @@ -5064,7 +5109,8 @@ TEST_F(EnergyPlusFixture, HeatingwithHeatRecoverySimulate_AirSource) " 1,", " 1;"}); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + // call the factory with a valid name to trigger reading inputs EIRPlantLoopHeatPump::factory(*state, DataPlant::PlantEquipmentType::HeatPumpEIRCooling, "HP COOLING SIDE"); @@ -5270,7 +5316,8 @@ TEST_F(EnergyPlusFixture, CoolingSimulate_WSHP_SourceSideOutletTemp) " 1,", " 1;"}); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + // set up the plant loops // first the load side state->dataPlnt->TotNumLoops = 2; diff --git a/tst/EnergyPlus/unit/PlantManager.unit.cc b/tst/EnergyPlus/unit/PlantManager.unit.cc index 354af3d518d..29407ff8c4a 100644 --- a/tst/EnergyPlus/unit/PlantManager.unit.cc +++ b/tst/EnergyPlus/unit/PlantManager.unit.cc @@ -70,7 +70,6 @@ namespace PlantManager { using namespace DataPlant; using namespace DataLoopNode; using namespace DataSizing; - using namespace ScheduleManager; using namespace SetPointManager; TEST_F(EnergyPlusFixture, PlantManager_SizePlantLoopTest) @@ -205,7 +204,8 @@ namespace PlantManager { }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + // get input and checks if there are two setpointmanagers // for a TwoWayCommonPipe and one of them setpoints can be // a SetpointManager:OutdoorAirReset type. @@ -271,6 +271,8 @@ namespace UserDefinedComponents { }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + OutAirNodeManager::SetOutAirNodes(*state); EMSManager::CheckIfAnyEMS(*state); state->dataEMSMgr->FinishProcessingUserInput = true; diff --git a/tst/EnergyPlus/unit/PlantUtilities.unit.cc b/tst/EnergyPlus/unit/PlantUtilities.unit.cc index edb6bfccb56..5fe91e676f8 100644 --- a/tst/EnergyPlus/unit/PlantUtilities.unit.cc +++ b/tst/EnergyPlus/unit/PlantUtilities.unit.cc @@ -91,11 +91,7 @@ TEST_F(EnergyPlusFixture, PlantUtilities_RegisterPlantCompDesignFlowTest1) TEST_F(EnergyPlusFixture, TestRegulateCondenserCompFlowReqOp) { // test consecutive call to fluid properties getInput - FluidProperties::GetFluidPropertiesData(*state); - EXPECT_EQ(1, state->dataFluidProps->refrigs.isize()); - EXPECT_EQ(1, state->dataFluidProps->glycols.isize()); - - FluidProperties::GetFluidPropertiesData(*state); // should never happen but if it does it's safe + state->init_state(*state); EXPECT_EQ(1, state->dataFluidProps->refrigs.isize()); EXPECT_EQ(1, state->dataFluidProps->glycols.isize()); diff --git a/tst/EnergyPlus/unit/PoweredInductionUnits.unit.cc b/tst/EnergyPlus/unit/PoweredInductionUnits.unit.cc index 7809725dcd9..95569a785d6 100644 --- a/tst/EnergyPlus/unit/PoweredInductionUnits.unit.cc +++ b/tst/EnergyPlus/unit/PoweredInductionUnits.unit.cc @@ -169,11 +169,10 @@ TEST_F(EnergyPlusFixture, ParallelPIUTest1) }); ASSERT_TRUE(process_idf(idf_objects)); - - state->dataGlobal->NumOfTimeStepInHour = 1; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 60; // must initialize this to get schedules initialized - ScheduleManager::ProcessScheduleInput(*state); // read schedules - state->dataScheduleMgr->ScheduleInputProcessed = true; + state->dataGlobal->TimeStepsInHour = 1; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 60; // must initialize this to get schedules initialized + state->init_state(*state); + state->dataEnvrn->Month = 1; state->dataEnvrn->DayOfMonth = 21; state->dataGlobal->HourOfDay = 1; @@ -183,7 +182,7 @@ TEST_F(EnergyPlusFixture, ParallelPIUTest1) state->dataEnvrn->HolidayIndex = 0; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); state->dataEnvrn->StdRhoAir = Psychrometrics::PsyRhoAirFnPbTdbW(*state, 101325.0, 20.0, 0.0); - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); bool ErrorsFound = false; HeatBalanceManager::GetZoneData(*state, ErrorsFound); @@ -196,7 +195,7 @@ TEST_F(EnergyPlusFixture, ParallelPIUTest1) PoweredInductionUnits::GetPIUs(*state); EXPECT_TRUE(compare_err_stream("")); state->dataHeatBalFanSys->TempControlType.allocate(1); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::DualSetPointWithDeadBand; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::DualHeatCool; // node number table // 1 SPACE2-1 Air Node @@ -395,11 +394,10 @@ TEST_F(EnergyPlusFixture, SeriesPIUTest1) }); ASSERT_TRUE(process_idf(idf_objects)); - - state->dataGlobal->NumOfTimeStepInHour = 1; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 60; // must initialize this to get schedules initialized - ScheduleManager::ProcessScheduleInput(*state); // read schedules - state->dataScheduleMgr->ScheduleInputProcessed = true; + state->dataGlobal->TimeStepsInHour = 1; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 60; // must initialize this to get schedules initialized + state->init_state(*state); + state->dataEnvrn->Month = 1; state->dataEnvrn->DayOfMonth = 21; state->dataGlobal->HourOfDay = 1; @@ -409,7 +407,7 @@ TEST_F(EnergyPlusFixture, SeriesPIUTest1) state->dataEnvrn->HolidayIndex = 0; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); state->dataEnvrn->StdRhoAir = Psychrometrics::PsyRhoAirFnPbTdbW(*state, 101325.0, 20.0, 0.0); - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); bool ErrorsFound = false; HeatBalanceManager::GetZoneData(*state, ErrorsFound); @@ -422,7 +420,7 @@ TEST_F(EnergyPlusFixture, SeriesPIUTest1) PoweredInductionUnits::GetPIUs(*state); EXPECT_TRUE(compare_err_stream("")); state->dataHeatBalFanSys->TempControlType.allocate(1); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::DualSetPointWithDeadBand; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::DualHeatCool; // node number table // 1 SPACE2-1 Air Node @@ -670,11 +668,10 @@ TEST_F(EnergyPlusFixture, SeriesPIUZoneOAVolumeFlowRateTest) }); ASSERT_TRUE(process_idf(idf_objects)); - - state->dataGlobal->NumOfTimeStepInHour = 1; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 60; // must initialize this to get schedules initialized - ScheduleManager::ProcessScheduleInput(*state); // read schedules - state->dataScheduleMgr->ScheduleInputProcessed = true; + state->dataGlobal->TimeStepsInHour = 1; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 60; // must initialize this to get schedules initialized + state->init_state(*state); + state->dataEnvrn->Month = 1; state->dataEnvrn->DayOfMonth = 21; state->dataGlobal->HourOfDay = 1; @@ -684,7 +681,7 @@ TEST_F(EnergyPlusFixture, SeriesPIUZoneOAVolumeFlowRateTest) state->dataEnvrn->HolidayIndex = 0; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); state->dataEnvrn->StdRhoAir = Psychrometrics::PsyRhoAirFnPbTdbW(*state, 101325.0, 20.0, 0.0); - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); bool ErrorsFound = false; HeatBalanceManager::GetZoneData(*state, ErrorsFound); @@ -697,7 +694,7 @@ TEST_F(EnergyPlusFixture, SeriesPIUZoneOAVolumeFlowRateTest) PoweredInductionUnits::GetPIUs(*state); EXPECT_TRUE(compare_err_stream("")); state->dataHeatBalFanSys->TempControlType.allocate(1); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::DualSetPointWithDeadBand; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::DualHeatCool; state->dataZoneEnergyDemand->ZoneSysEnergyDemand.allocate(1); state->dataZoneEnergyDemand->CurDeadBandOrSetback.allocate(1); state->dataZoneEnergyDemand->CurDeadBandOrSetback(1) = false; @@ -1937,6 +1934,7 @@ TEST_F(EnergyPlusFixture, PIU_InducedAir_Plenums) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); // What we're testing for here is an initialization order issue, and this is why we rely on calling a high-level function such as ManageSizing // and not lower level ones @@ -2071,12 +2069,10 @@ TEST_F(EnergyPlusFixture, VSParallelPIUStagedHeat) }); ASSERT_TRUE(process_idf(idf_objects)); - - // Init - state->dataGlobal->NumOfTimeStepInHour = 1; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 60; // must initialize this to get schedules initialized - ScheduleManager::ProcessScheduleInput(*state); // read schedules - state->dataScheduleMgr->ScheduleInputProcessed = true; + state->dataGlobal->TimeStepsInHour = 1; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 60; // must initialize this to get schedules initialized + state->init_state(*state); + state->dataEnvrn->Month = 1; state->dataEnvrn->DayOfMonth = 21; state->dataGlobal->HourOfDay = 1; @@ -2086,7 +2082,7 @@ TEST_F(EnergyPlusFixture, VSParallelPIUStagedHeat) state->dataEnvrn->HolidayIndex = 0; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); state->dataEnvrn->StdRhoAir = Psychrometrics::PsyRhoAirFnPbTdbW(*state, 101325.0, 20.0, 0.0); - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); bool ErrorsFound = false; HeatBalanceManager::GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); @@ -2098,7 +2094,7 @@ TEST_F(EnergyPlusFixture, VSParallelPIUStagedHeat) PoweredInductionUnits::GetPIUs(*state); EXPECT_TRUE(compare_err_stream("")); state->dataHeatBalFanSys->TempControlType.allocate(1); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::DualSetPointWithDeadBand; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::DualHeatCool; state->dataZoneEnergyDemand->ZoneSysEnergyDemand.allocate(1); state->dataZoneEnergyDemand->CurDeadBandOrSetback.allocate(1); @@ -2270,12 +2266,10 @@ TEST_F(EnergyPlusFixture, VSParallelPIUModulatedHeat) }); ASSERT_TRUE(process_idf(idf_objects)); - - // Init - state->dataGlobal->NumOfTimeStepInHour = 1; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 60; // must initialize this to get schedules initialized - ScheduleManager::ProcessScheduleInput(*state); // read schedules - state->dataScheduleMgr->ScheduleInputProcessed = true; + state->dataGlobal->TimeStepsInHour = 1; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 60; // must initialize this to get schedules initialized + state->init_state(*state); + state->dataEnvrn->Month = 1; state->dataEnvrn->DayOfMonth = 21; state->dataGlobal->HourOfDay = 1; @@ -2285,7 +2279,7 @@ TEST_F(EnergyPlusFixture, VSParallelPIUModulatedHeat) state->dataEnvrn->HolidayIndex = 0; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); state->dataEnvrn->StdRhoAir = Psychrometrics::PsyRhoAirFnPbTdbW(*state, 101325.0, 20.0, 0.0); - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); bool ErrorsFound = false; HeatBalanceManager::GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); @@ -2297,7 +2291,7 @@ TEST_F(EnergyPlusFixture, VSParallelPIUModulatedHeat) PoweredInductionUnits::GetPIUs(*state); EXPECT_TRUE(compare_err_stream("")); state->dataHeatBalFanSys->TempControlType.allocate(1); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::DualSetPointWithDeadBand; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::DualHeatCool; state->dataZoneEnergyDemand->ZoneSysEnergyDemand.allocate(1); state->dataZoneEnergyDemand->CurDeadBandOrSetback.allocate(1); @@ -2509,12 +2503,10 @@ TEST_F(EnergyPlusFixture, VSSeriesPIUStagedHeat) }); ASSERT_TRUE(process_idf(idf_objects)); + state->dataGlobal->TimeStepsInHour = 1; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 60; // must initialize this to get schedules initialized + state->init_state(*state); - // Init - state->dataGlobal->NumOfTimeStepInHour = 1; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 60; // must initialize this to get schedules initialized - ScheduleManager::ProcessScheduleInput(*state); // read schedules - state->dataScheduleMgr->ScheduleInputProcessed = true; state->dataEnvrn->Month = 1; state->dataEnvrn->DayOfMonth = 21; state->dataGlobal->HourOfDay = 1; @@ -2524,7 +2516,7 @@ TEST_F(EnergyPlusFixture, VSSeriesPIUStagedHeat) state->dataEnvrn->HolidayIndex = 0; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); state->dataEnvrn->StdRhoAir = Psychrometrics::PsyRhoAirFnPbTdbW(*state, 101325.0, 20.0, 0.0); - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); bool ErrorsFound = false; HeatBalanceManager::GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); @@ -2536,7 +2528,7 @@ TEST_F(EnergyPlusFixture, VSSeriesPIUStagedHeat) PoweredInductionUnits::GetPIUs(*state); EXPECT_TRUE(compare_err_stream("")); state->dataHeatBalFanSys->TempControlType.allocate(1); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::DualSetPointWithDeadBand; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::DualHeatCool; state->dataZoneEnergyDemand->ZoneSysEnergyDemand.allocate(1); state->dataZoneEnergyDemand->CurDeadBandOrSetback.allocate(1); @@ -2712,12 +2704,10 @@ TEST_F(EnergyPlusFixture, VSSeriesPIUModulatedHeat) }); ASSERT_TRUE(process_idf(idf_objects)); - - // Init - state->dataGlobal->NumOfTimeStepInHour = 1; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 60; // must initialize this to get schedules initialized - ScheduleManager::ProcessScheduleInput(*state); // read schedules - state->dataScheduleMgr->ScheduleInputProcessed = true; + state->dataGlobal->TimeStepsInHour = 1; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 60; // must initialize this to get schedules initialized + state->init_state(*state); + state->dataEnvrn->Month = 1; state->dataEnvrn->DayOfMonth = 21; state->dataGlobal->HourOfDay = 1; @@ -2727,7 +2717,7 @@ TEST_F(EnergyPlusFixture, VSSeriesPIUModulatedHeat) state->dataEnvrn->HolidayIndex = 0; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); state->dataEnvrn->StdRhoAir = Psychrometrics::PsyRhoAirFnPbTdbW(*state, 101325.0, 20.0, 0.0); - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); bool ErrorsFound = false; HeatBalanceManager::GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); @@ -2739,7 +2729,7 @@ TEST_F(EnergyPlusFixture, VSSeriesPIUModulatedHeat) PoweredInductionUnits::GetPIUs(*state); EXPECT_TRUE(compare_err_stream("")); state->dataHeatBalFanSys->TempControlType.allocate(1); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::DualSetPointWithDeadBand; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::DualHeatCool; state->dataZoneEnergyDemand->ZoneSysEnergyDemand.allocate(1); state->dataZoneEnergyDemand->CurDeadBandOrSetback.allocate(1); @@ -2949,12 +2939,10 @@ TEST_F(EnergyPlusFixture, VSSeriesPIUCool) }); ASSERT_TRUE(process_idf(idf_objects)); - - // Init - state->dataGlobal->NumOfTimeStepInHour = 1; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 60; // must initialize this to get schedules initialized - ScheduleManager::ProcessScheduleInput(*state); // read schedules - state->dataScheduleMgr->ScheduleInputProcessed = true; + state->dataGlobal->TimeStepsInHour = 1; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 60; // must initialize this to get schedules initialized + state->init_state(*state); + state->dataEnvrn->Month = 1; state->dataEnvrn->DayOfMonth = 21; state->dataGlobal->HourOfDay = 1; @@ -2964,7 +2952,7 @@ TEST_F(EnergyPlusFixture, VSSeriesPIUCool) state->dataEnvrn->HolidayIndex = 0; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); state->dataEnvrn->StdRhoAir = Psychrometrics::PsyRhoAirFnPbTdbW(*state, 101325.0, 20.0, 0.0); - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); bool ErrorsFound = false; HeatBalanceManager::GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); @@ -2976,7 +2964,7 @@ TEST_F(EnergyPlusFixture, VSSeriesPIUCool) PoweredInductionUnits::GetPIUs(*state); EXPECT_TRUE(compare_err_stream("")); state->dataHeatBalFanSys->TempControlType.allocate(1); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::DualSetPointWithDeadBand; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::DualHeatCool; state->dataZoneEnergyDemand->ZoneSysEnergyDemand.allocate(1); state->dataZoneEnergyDemand->CurDeadBandOrSetback.allocate(1); @@ -3044,11 +3032,8 @@ TEST_F(EnergyPlusFixture, PIU_reportTerminalUnit) SetPredefinedTables(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; - auto &sch = state->dataScheduleMgr->Schedule; - sch.allocate(5); - sch(1).Name = "schA"; - sch(2).Name = "schB"; + Sched::AddScheduleConstant(*state, "SCHA"); + Sched::AddScheduleConstant(*state, "SCHB"); auto &adu = state->dataDefineEquipment->AirDistUnit; adu.allocate(2); diff --git a/tst/EnergyPlus/unit/Psychrometrics.unit.cc b/tst/EnergyPlus/unit/Psychrometrics.unit.cc index 2213c9858a0..adb84d8082c 100644 --- a/tst/EnergyPlus/unit/Psychrometrics.unit.cc +++ b/tst/EnergyPlus/unit/Psychrometrics.unit.cc @@ -51,6 +51,7 @@ // EnergyPlus Headers #include "Fixtures/EnergyPlusFixture.hh" #include +#include #include using namespace EnergyPlus; @@ -58,8 +59,7 @@ using namespace EnergyPlus::Psychrometrics; TEST_F(EnergyPlusFixture, Psychrometrics_PsyTsatFnHPb_Test) { - - InitializePsychRoutines(*state); + state->init_state(*state); // Test 1: TEMP. IS FROM 20 C TO 40 C Real64 H = 7.5223e4 - 1.78637e4; @@ -149,8 +149,7 @@ TEST_F(EnergyPlusFixture, Psychrometrics_PsyTsatFnHPb_Test) TEST_F(EnergyPlusFixture, Psychrometrics_PsyTsatFnPb_Test) { - - InitializePsychRoutines(*state); + state->init_state(*state); // Test 1: general Real64 PB = 101325.0; @@ -274,8 +273,7 @@ inline Real64 PsyCpAirFnWTdb(Real64 const dw, // humidity ratio {kgWater/kgDryAi TEST_F(EnergyPlusFixture, Psychrometrics_PsyCpAirFn_Test) { - - InitializePsychRoutines(*state); + state->init_state(*state); // Test 1: analytical PsyCpAirFnW is independent of temperature Real64 W = 0.0080; @@ -358,8 +356,7 @@ TEST_F(EnergyPlusFixture, Psychrometrics_PsyCpAirFn_Test) TEST_F(EnergyPlusFixture, Psychrometrics_CpAirValue_Test) { - - InitializePsychRoutines(*state); + state->init_state(*state); // Test 1: dry cooling process test, delta enthalpy vs cpair times delta T Real64 W1 = 0.0030; @@ -403,8 +400,7 @@ TEST_F(EnergyPlusFixture, Psychrometrics_CpAirValue_Test) TEST_F(EnergyPlusFixture, Psychrometrics_PsyTwbFnTdbWPb_Test) { - - InitializePsychRoutines(*state); + state->init_state(*state); // Test when wet bulb temperature is below zero Real64 TDB = 1; // C @@ -417,8 +413,7 @@ TEST_F(EnergyPlusFixture, Psychrometrics_PsyTwbFnTdbWPb_Test) TEST_F(EnergyPlusFixture, Psychrometrics_CpAirAverageValue_Test) { - - InitializePsychRoutines(*state); + state->init_state(*state); // Test 1: heating process, constant humidity ratio Real64 W1 = 0.0030; @@ -451,7 +446,7 @@ TEST_F(EnergyPlusFixture, Psychrometrics_Interpolation_Sample_Test) // Verify sample data for interpolation. // The sample data were extracted from the original psychrometric function PsyTsatFnPb every 64 Pa in the range of 64 Pa to 105,664 Pa. // The sample data for saturated temperature from tsat_fn_pb_tsat were compared to the results from the original psychrometric function. - InitializePsychRoutines(*state); + state->init_state(*state); Real64 tsat_psy; Real64 error = 0.0; int i; @@ -467,7 +462,7 @@ TEST_F(EnergyPlusFixture, Psychrometrics_Interpolation_Sample_Test) TEST_F(EnergyPlusFixture, Psychrometrics_CSpline_Test) { // compare the results of Tsat between CSpline interpolation and original psychrometric function for PsychTsatFnPb - InitializePsychRoutines(*state); + state->init_state(*state); Real64 tsat_psy; Real64 tsat_cspline; Real64 Press_test; @@ -491,7 +486,7 @@ TEST_F(EnergyPlusFixture, Psychrometrics_CSpline_Test) TEST_F(EnergyPlusFixture, Psychrometrics_PsyTwbFnTdbWPb_Test_Discontinuity) { // Test for #8599 - InitializePsychRoutines(*state); + state->init_state(*state); state->dataGlobal->WarmupFlag = true; @@ -506,5 +501,6 @@ TEST_F(EnergyPlusFixture, Psychrometrics_PsyTwbFnTdbWPb_Test_Discontinuity) Real64 expected_result = -0.1027; // expected result from psychrometrics chart EXPECT_NEAR(result, expected_result, 0.001); - EXPECT_FALSE(has_err_output()); + EXPECT_EQ(state->dataErrTracking->TotalSevereErrors, 0); + EXPECT_EQ(state->dataErrTracking->TotalWarningErrors, 1); // IDF version object } diff --git a/tst/EnergyPlus/unit/Pumps.unit.cc b/tst/EnergyPlus/unit/Pumps.unit.cc index 566d28741d3..efa2e3fa3a6 100644 --- a/tst/EnergyPlus/unit/Pumps.unit.cc +++ b/tst/EnergyPlus/unit/Pumps.unit.cc @@ -90,6 +90,7 @@ TEST_F(EnergyPlusFixture, HeaderedVariableSpeedPumpSizingPowerTest) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); Pumps::GetPumpInput(*state); Pumps::SizePump(*state, 1); EXPECT_NEAR(state->dataPumps->PumpEquip(1).NomPowerUse, 162.5, 0.0001); @@ -125,6 +126,7 @@ TEST_F(EnergyPlusFixture, HeaderedVariableSpeedPumpSizingPower22W_per_gpm) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); Pumps::GetPumpInput(*state); Pumps::SizePump(*state, 1); EXPECT_NEAR(state->dataPumps->PumpEquip(1).NomPowerUse, 348.7011, 0.0001); @@ -159,6 +161,7 @@ TEST_F(EnergyPlusFixture, HeaderedVariableSpeedPumpSizingPowerDefault) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); Pumps::GetPumpInput(*state); Pumps::SizePump(*state, 1); EXPECT_NEAR(state->dataPumps->PumpEquip(1).NomPowerUse, 255.4872, 0.0001); @@ -189,6 +192,7 @@ TEST_F(EnergyPlusFixture, HeaderedConstantSpeedPumpSizingPowerTest) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); Pumps::GetPumpInput(*state); Pumps::SizePump(*state, 1); EXPECT_NEAR(state->dataPumps->PumpEquip(1).NomPowerUse, 162.5, 0.0001); @@ -219,6 +223,7 @@ TEST_F(EnergyPlusFixture, HeaderedConstantSpeedPumpSizingPower19W_per_gpm) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); Pumps::GetPumpInput(*state); Pumps::SizePump(*state, 1); EXPECT_NEAR(state->dataPumps->PumpEquip(1).NomPowerUse, 301.1561, 0.0001); @@ -248,6 +253,7 @@ TEST_F(EnergyPlusFixture, HeaderedConstantSpeedPumpSizingPowerDefault) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); Pumps::GetPumpInput(*state); Pumps::SizePump(*state, 1); EXPECT_NEAR(state->dataPumps->PumpEquip(1).NomPowerUse, 255.4872, 0.0001); @@ -291,6 +297,7 @@ TEST_F(EnergyPlusFixture, VariableSpeedPumpSizingMinVolFlowRate) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); Pumps::GetPumpInput(*state); EXPECT_NEAR(state->dataPumps->PumpEquip(1).MinVolFlowRate, DataSizing::AutoSize, 0.000001); Pumps::SizePump(*state, 1); @@ -335,6 +342,7 @@ TEST_F(EnergyPlusFixture, VariableSpeedPumpSizingPowerPerPressureTest) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); Pumps::GetPumpInput(*state); Pumps::SizePump(*state, 1); EXPECT_NEAR(state->dataPumps->PumpEquip(1).NomPowerUse, 162.5, 0.0001); @@ -376,6 +384,7 @@ TEST_F(EnergyPlusFixture, VariableSpeedPumpSizingPowerDefault) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); Pumps::GetPumpInput(*state); Pumps::SizePump(*state, 1); EXPECT_NEAR(state->dataPumps->PumpEquip(1).NomPowerUse, 255.4872, 0.0001); @@ -416,6 +425,7 @@ TEST_F(EnergyPlusFixture, VariableSpeedPumpSizingPower22W_per_GPM) "0.0; !- Design Minimum Flow Rate Sizing Factor", }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); Pumps::GetPumpInput(*state); Pumps::SizePump(*state, 1); EXPECT_NEAR(state->dataPumps->PumpEquip(1).NomPowerUse, 348.7011, 0.0001); @@ -447,6 +457,7 @@ TEST_F(EnergyPlusFixture, ConstantSpeedPumpSizingPower19W_per_gpm) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); Pumps::GetPumpInput(*state); Pumps::SizePump(*state, 1); EXPECT_NEAR(state->dataPumps->PumpEquip(1).NomPowerUse, 301.1561, 0.0001); @@ -479,6 +490,7 @@ TEST_F(EnergyPlusFixture, ConstantSpeedPumpSizingPowerPerPressureTest) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); Pumps::GetPumpInput(*state); Pumps::SizePump(*state, 1); EXPECT_NEAR(state->dataPumps->PumpEquip(1).NomPowerUse, 162.5, 0.0001); @@ -510,6 +522,7 @@ TEST_F(EnergyPlusFixture, ConstantSpeedPumpSizingPowerDefaults) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); Pumps::GetPumpInput(*state); Pumps::SizePump(*state, 1); EXPECT_NEAR(state->dataPumps->PumpEquip(1).NomPowerUse, 255.4872, 0.0001); @@ -542,6 +555,7 @@ TEST_F(EnergyPlusFixture, CondensatePumpSizingPowerDefaults) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); Pumps::GetPumpInput(*state); Pumps::SizePump(*state, 1); EXPECT_NEAR(state->dataPumps->PumpEquip(1).NomPowerUse, 153.3, 0.1); @@ -574,6 +588,7 @@ TEST_F(EnergyPlusFixture, CondensatePumpSizingPower19W_per_gpm) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); Pumps::GetPumpInput(*state); Pumps::SizePump(*state, 1); EXPECT_NEAR(state->dataPumps->PumpEquip(1).NomPowerUse, 180.7, 0.1); @@ -605,6 +620,7 @@ TEST_F(EnergyPlusFixture, CondensatePumpSizingPowerTest) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); Pumps::GetPumpInput(*state); Pumps::SizePump(*state, 1); EXPECT_NEAR(state->dataPumps->PumpEquip(1).NomPowerUse, 97.5, 0.1); @@ -647,6 +663,7 @@ TEST_F(EnergyPlusFixture, VariableSpeedPump_MinFlowGreaterThanMax) " ; !- Design Minimum Flow Rate Fraction", }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); Pumps::GetPumpInput(*state); std::string const error_string = delimited_string({ @@ -698,6 +715,7 @@ TEST_F(EnergyPlusFixture, VariableSpeedPump_MinFlowEqualToMax) " ; !- Design Minimum Flow Rate Fraction", }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); Pumps::GetPumpInput(*state); std::string const error_string = delimited_string({ @@ -746,6 +764,7 @@ TEST_F(EnergyPlusFixture, HeaderedVariableSpeedPumpEMSPressureTest) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); Pumps::GetPumpInput(*state); Pumps::SizePump(*state, 1); Real64 massflowrate = 1.0; diff --git a/tst/EnergyPlus/unit/PurchasedAirManager.unit.cc b/tst/EnergyPlus/unit/PurchasedAirManager.unit.cc index 8ddad9c43a3..556e85921b9 100644 --- a/tst/EnergyPlus/unit/PurchasedAirManager.unit.cc +++ b/tst/EnergyPlus/unit/PurchasedAirManager.unit.cc @@ -99,10 +99,9 @@ class ZoneIdealLoadsTest : public EnergyPlusFixture { EnergyPlusFixture::SetUp(); // Sets up the base fixture first. - state->dataHeatBalFanSys->ZoneThermostatSetPointHi.allocate(1); - state->dataHeatBalFanSys->ZoneThermostatSetPointHi(1) = 23.9; // 75F - state->dataHeatBalFanSys->ZoneThermostatSetPointLo.allocate(1); - state->dataHeatBalFanSys->ZoneThermostatSetPointLo(1) = 23.0; // 73.4F + state->dataHeatBalFanSys->zoneTstatSetpts.allocate(1); + state->dataHeatBalFanSys->zoneTstatSetpts(1).setptHi = 23.9; // 75F + state->dataHeatBalFanSys->zoneTstatSetpts(1).setptLo = 23.0; // 73.4F state->dataSize->FinalZoneSizing.allocate(1); state->dataSize->ZoneEqSizing.allocate(1); @@ -125,7 +124,7 @@ class ZoneIdealLoadsTest : public EnergyPlusFixture state->dataHeatBal->RefrigCaseCredit.allocate(1); state->dataHeatBalFanSys->TempControlType.allocate(1); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::SingleHeating; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::SingleHeat; state->dataZoneEnergyDemand->CurDeadBandOrSetback.allocate(1); state->dataZoneEnergyDemand->DeadBandOrSetback.allocate(1); state->dataZoneEnergyDemand->DeadBandOrSetback(1) = false; @@ -287,7 +286,8 @@ TEST_F(EnergyPlusFixture, IdealLoadsAirSystem_GetInput) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + state->dataGlobal->DoWeathSim = true; GetPurchasedAir(*state); @@ -388,7 +388,8 @@ TEST_F(ZoneIdealLoadsTest, IdealLoads_PlenumTest) }); ASSERT_TRUE(process_idf(idf_objects)); // read idf objects - + state->init_state(*state); + state->dataGlobal->DoWeathSim = true; bool ErrorsFound = false; @@ -396,7 +397,6 @@ TEST_F(ZoneIdealLoadsTest, IdealLoads_PlenumTest) state->dataHeatBal->space(1).HTSurfaceFirst = 1; state->dataHeatBal->space(1).HTSurfaceLast = 1; - state->dataScheduleMgr->Schedule.allocate(1); state->dataEnvrn->StdRhoAir = 1.0; // Prevent divide by zero AllocateHeatBalArrays(*state); @@ -502,7 +502,8 @@ TEST_F(ZoneIdealLoadsTest, IdealLoads_ExhaustNodeTest) }); ASSERT_TRUE(process_idf(idf_objects)); // read idf objects - + state->init_state(*state); + state->dataGlobal->DoWeathSim = true; bool ErrorsFound = false; @@ -510,7 +511,6 @@ TEST_F(ZoneIdealLoadsTest, IdealLoads_ExhaustNodeTest) state->dataHeatBal->space(1).HTSurfaceFirst = 1; state->dataHeatBal->space(1).HTSurfaceLast = 1; - state->dataScheduleMgr->Schedule.allocate(1); state->dataEnvrn->StdRhoAir = 1.0; // Prevent divide by zero AllocateHeatBalArrays(*state); EXPECT_FALSE(ErrorsFound); // expect no errors @@ -627,14 +627,14 @@ TEST_F(ZoneIdealLoadsTest, IdealLoads_IntermediateOutputVarsTest) }); ASSERT_TRUE(process_idf(idf_objects)); // read idf objects - + state->init_state(*state); + state->dataGlobal->DoWeathSim = true; bool ErrorsFound = false; GetZoneData(*state, ErrorsFound); state->dataHeatBal->space(1).HTSurfaceFirst = 1; state->dataHeatBal->space(1).HTSurfaceLast = 1; - state->dataScheduleMgr->Schedule.allocate(1); state->dataEnvrn->StdRhoAir = 1.0; // Prevent divide by zero AllocateHeatBalArrays(*state); EXPECT_FALSE(ErrorsFound); // expect no errors @@ -799,6 +799,7 @@ TEST_F(ZoneIdealLoadsTest, IdealLoads_EMSOverrideTest) }); ASSERT_TRUE(process_idf(idf_objects)); // read idf objects + state->init_state(*state); state->dataGlobal->DoWeathSim = true; @@ -806,7 +807,6 @@ TEST_F(ZoneIdealLoadsTest, IdealLoads_EMSOverrideTest) GetZoneData(*state, ErrorsFound); state->dataHeatBal->space(1).HTSurfaceFirst = 1; state->dataHeatBal->space(1).HTSurfaceLast = 1; - state->dataScheduleMgr->Schedule.allocate(1); state->dataEnvrn->StdRhoAir = 1.0; // Prevent divide by zero AllocateHeatBalArrays(*state); EXPECT_FALSE(ErrorsFound); // expect no errors @@ -908,6 +908,7 @@ TEST_F(ZoneIdealLoadsTest, IdealLoads_NoCapacityTest) }); ASSERT_TRUE(process_idf(idf_objects)); // read idf objects + state->init_state(*state); state->dataGlobal->DoWeathSim = true; @@ -915,7 +916,6 @@ TEST_F(ZoneIdealLoadsTest, IdealLoads_NoCapacityTest) GetZoneData(*state, ErrorsFound); state->dataHeatBal->space(1).HTSurfaceFirst = 1; state->dataHeatBal->space(1).HTSurfaceLast = 1; - state->dataScheduleMgr->Schedule.allocate(1); state->dataEnvrn->StdRhoAir = 1.0; // Prevent divide by zero AllocateHeatBalArrays(*state); EXPECT_FALSE(ErrorsFound); // expect no errors @@ -1057,6 +1057,7 @@ TEST_F(ZoneIdealLoadsTest, IdealLoads_EMSOverrideTest_Revised) }); ASSERT_TRUE(process_idf(idf_objects)); // read idf objects + state->init_state(*state); state->dataGlobal->DoWeathSim = true; @@ -1064,7 +1065,6 @@ TEST_F(ZoneIdealLoadsTest, IdealLoads_EMSOverrideTest_Revised) GetZoneData(*state, ErrorsFound); state->dataHeatBal->space(1).HTSurfaceFirst = 1; state->dataHeatBal->space(1).HTSurfaceLast = 1; - state->dataScheduleMgr->Schedule.allocate(1); state->dataEnvrn->StdRhoAir = 1.0; // Prevent divide by zero AllocateHeatBalArrays(*state); EXPECT_FALSE(ErrorsFound); // expect no errors @@ -1229,6 +1229,7 @@ TEST_F(ZoneIdealLoadsTest, IdealLoads_EMSOverrideTest_Revised_ZeroFlow) }); ASSERT_TRUE(process_idf(idf_objects)); // read idf objects + state->init_state(*state); state->dataGlobal->DoWeathSim = true; @@ -1236,7 +1237,6 @@ TEST_F(ZoneIdealLoadsTest, IdealLoads_EMSOverrideTest_Revised_ZeroFlow) GetZoneData(*state, ErrorsFound); state->dataHeatBal->space(1).HTSurfaceFirst = 1; state->dataHeatBal->space(1).HTSurfaceLast = 1; - state->dataScheduleMgr->Schedule.allocate(1); AllocateHeatBalArrays(*state); EXPECT_FALSE(ErrorsFound); // expect no errors state->dataZoneEquip->ZoneEquipConfig.allocate(1); @@ -1403,12 +1403,12 @@ TEST_F(ZoneIdealLoadsTest, IdealLoads_Fix_SA_HumRat_Test) }); ASSERT_TRUE(process_idf(idf_objects)); // read idf objects + state->init_state(*state); state->dataGlobal->DoWeathSim = true; bool ErrorsFound = false; GetZoneData(*state, ErrorsFound); - state->dataScheduleMgr->Schedule.allocate(1); AllocateHeatBalArrays(*state); EXPECT_FALSE(ErrorsFound); // expect no errors state->dataZoneEquip->ZoneEquipConfig.allocate(1); @@ -1453,7 +1453,7 @@ TEST_F(ZoneIdealLoadsTest, IdealLoads_Fix_SA_HumRat_Test) int ControlledZoneNum = 1; state->dataZoneEnergyDemand->ZoneSysEnergyDemand(ControlledZoneNum).RemainingOutputReqToCoolSP = -1000.0; state->dataZoneEnergyDemand->ZoneSysMoistureDemand(ControlledZoneNum).RemainingOutputReqToDehumidSP = -0.0002; - state->dataHeatBalFanSys->TempControlType(ControlledZoneNum) = HVAC::ThermostatType::SingleCooling; + state->dataHeatBalFanSys->TempControlType(ControlledZoneNum) = HVAC::SetptType::SingleCool; state->dataLoopNodes->Node(1).Temp = 30; state->dataLoopNodes->Node(1).HumRat = 0.012; diff --git a/tst/EnergyPlus/unit/RefrigeratedCase.unit.cc b/tst/EnergyPlus/unit/RefrigeratedCase.unit.cc index ae91acad1de..f12a973dbc2 100644 --- a/tst/EnergyPlus/unit/RefrigeratedCase.unit.cc +++ b/tst/EnergyPlus/unit/RefrigeratedCase.unit.cc @@ -384,6 +384,7 @@ Schedule:Compact, )IDF"; ASSERT_TRUE(process_idf(fmt::format("{}\n{}", oneZoneBuildingWithIdealLoads, idf_objects))); // read idf objects + state->init_state(*state); state->dataZoneEquip->ZoneEquipInputsFilled = true; state->dataEnvrn->OutBaroPress = 101325.0; @@ -391,7 +392,7 @@ Schedule:Compact, HeatBalanceManager::GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); DataZoneEquipment::GetZoneEquipmentData(*state); - ScheduleManager::ProcessScheduleInput(*state); + // ZoneAirLoopEquipmentManager::GetZoneAirLoopEquipment(*state); InternalHeatGains::ManageInternalHeatGains(*state, true); RefrigeratedCase::ManageRefrigeratedCaseRacks(*state); @@ -479,14 +480,14 @@ Refrigeration:WalkIn, )IDF"; ASSERT_TRUE(process_idf(fmt::format("{}\n{}", oneZoneBuildingWithIdealLoads, idf_objects))); // read idf objects - + state->init_state(*state); + state->dataZoneEquip->ZoneEquipInputsFilled = true; state->dataEnvrn->OutBaroPress = 101325.0; bool ErrorsFound = false; HeatBalanceManager::GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); DataZoneEquipment::GetZoneEquipmentData(*state); - ScheduleManager::ProcessScheduleInput(*state); // ZoneAirLoopEquipmentManager::GetZoneAirLoopEquipment(*state); InternalHeatGains::ManageInternalHeatGains(*state, true); RefrigeratedCase::ManageRefrigeratedCaseRacks(*state); @@ -577,14 +578,14 @@ Refrigeration:WalkIn, )IDF"; ASSERT_TRUE(process_idf(fmt::format("{}\n{}", oneZoneBuildingWithIdealLoads, idf_objects))); // read idf objects - + state->init_state(*state); + state->dataZoneEquip->ZoneEquipInputsFilled = true; state->dataEnvrn->OutBaroPress = 101325.0; bool ErrorsFound = false; HeatBalanceManager::GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); DataZoneEquipment::GetZoneEquipmentData(*state); - ScheduleManager::ProcessScheduleInput(*state); // ZoneAirLoopEquipmentManager::GetZoneAirLoopEquipment(*state); InternalHeatGains::ManageInternalHeatGains(*state, true); RefrigeratedCase::ManageRefrigeratedCaseRacks(*state); @@ -735,14 +736,14 @@ Schedule:Compact, )IDF"; ASSERT_TRUE(process_idf(fmt::format("{}\n{}", oneZoneBuildingWithIdealLoads, idf_objects))); // read idf objects - + state->init_state(*state); + state->dataZoneEquip->ZoneEquipInputsFilled = true; state->dataEnvrn->OutBaroPress = 101325.0; bool ErrorsFound = false; HeatBalanceManager::GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); DataZoneEquipment::GetZoneEquipmentData(*state); - ScheduleManager::ProcessScheduleInput(*state); // ZoneAirLoopEquipmentManager::GetZoneAirLoopEquipment(*state); InternalHeatGains::ManageInternalHeatGains(*state, true); RefrigeratedCase::ManageRefrigeratedCaseRacks(*state); diff --git a/tst/EnergyPlus/unit/RoomAirflowNetwork.unit.cc b/tst/EnergyPlus/unit/RoomAirflowNetwork.unit.cc index 7522f82eb6a..843ce1433f4 100644 --- a/tst/EnergyPlus/unit/RoomAirflowNetwork.unit.cc +++ b/tst/EnergyPlus/unit/RoomAirflowNetwork.unit.cc @@ -169,7 +169,7 @@ TEST_F(RoomAirflowNetworkTest, RAFNTest) int ZoneNum = 1; int RoomAirNode; state->dataHVACGlobal->TimeStepSys = 15.0 / 60.0; - state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; state->dataEnvrn->OutBaroPress = 101325.0; state->dataHeatBal->Zone(ZoneNum).ZoneVolCapMultpSens = 1; @@ -554,10 +554,11 @@ TEST_F(EnergyPlusFixture, RoomAirInternalGains_InternalHeatGains_Check) ASSERT_TRUE(process_idf(idf_objects)); EXPECT_FALSE(has_err_output()); + state->dataGlobal->TimeStepsInHour = 1; + state->dataGlobal->MinutesInTimeStep = 60; + state->init_state(*state); + ErrorsFound = false; - state->dataGlobal->NumOfTimeStepInHour = 1; - state->dataGlobal->MinutesPerTimeStep = 60; - ScheduleManager::ProcessScheduleInput(*state); HeatBalanceManager::GetZoneData(*state, ErrorsFound); EXPECT_FALSE(ErrorsFound); @@ -574,8 +575,8 @@ TEST_F(EnergyPlusFixture, RoomAirInternalGains_InternalHeatGains_Check) ErrorsFound = false; state->dataSurfaceGeometry->CosZoneRelNorth.allocate(1); state->dataSurfaceGeometry->SinZoneRelNorth.allocate(1); - state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); - state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); + state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); + state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); state->dataSurfaceGeometry->CosBldgRelNorth = 1.0; state->dataSurfaceGeometry->SinBldgRelNorth = 0.0; SurfaceGeometry::GetSurfaceData(*state, ErrorsFound); diff --git a/tst/EnergyPlus/unit/RunPeriod.unit.cc b/tst/EnergyPlus/unit/RunPeriod.unit.cc index 83bd60ad4ed..66d8663a8d5 100644 --- a/tst/EnergyPlus/unit/RunPeriod.unit.cc +++ b/tst/EnergyPlus/unit/RunPeriod.unit.cc @@ -65,12 +65,11 @@ #include using namespace EnergyPlus; -using namespace EnergyPlus::ScheduleManager; TEST_F(EnergyPlusFixture, RunPeriod_Defaults) { Weather::RunPeriodData runperiod; - EXPECT_ENUM_EQ(ScheduleManager::DayType::Sunday, runperiod.startWeekDay); + EXPECT_ENUM_EQ(Sched::DayType::Sunday, runperiod.startWeekDay); EXPECT_EQ(1, runperiod.startMonth); EXPECT_EQ(1, runperiod.startDay); @@ -201,22 +200,22 @@ TEST_F(EnergyPlusFixture, RunPeriod_YearTests) Weather::GetRunPeriodData(*state, totalrps, errors_in_input); EXPECT_FALSE(errors_in_input); - EXPECT_ENUM_EQ(ScheduleManager::DayType::Monday, state->dataWeather->RunPeriodInput[0].startWeekDay); + EXPECT_ENUM_EQ(Sched::DayType::Monday, state->dataWeather->RunPeriodInput[0].startWeekDay); EXPECT_EQ(2016, state->dataWeather->RunPeriodInput[0].startYear); EXPECT_EQ(2457448, state->dataWeather->RunPeriodInput[0].startJulianDate); EXPECT_EQ(2457451, state->dataWeather->RunPeriodInput[0].endJulianDate); - EXPECT_ENUM_EQ(ScheduleManager::DayType::Wednesday, state->dataWeather->RunPeriodInput[1].startWeekDay); + EXPECT_ENUM_EQ(Sched::DayType::Wednesday, state->dataWeather->RunPeriodInput[1].startWeekDay); EXPECT_EQ(2012, state->dataWeather->RunPeriodInput[1].startYear); EXPECT_EQ(2455987, state->dataWeather->RunPeriodInput[1].startJulianDate); EXPECT_EQ(2455990, state->dataWeather->RunPeriodInput[1].endJulianDate); - EXPECT_ENUM_EQ(ScheduleManager::DayType::Thursday, state->dataWeather->RunPeriodInput[2].startWeekDay); + EXPECT_ENUM_EQ(Sched::DayType::Thursday, state->dataWeather->RunPeriodInput[2].startWeekDay); EXPECT_EQ(2015, state->dataWeather->RunPeriodInput[2].startYear); EXPECT_EQ(2457024, state->dataWeather->RunPeriodInput[2].startJulianDate); EXPECT_EQ(2457388, state->dataWeather->RunPeriodInput[2].endJulianDate); - EXPECT_ENUM_EQ(ScheduleManager::DayType::Sunday, state->dataWeather->RunPeriodInput[3].startWeekDay); + EXPECT_ENUM_EQ(Sched::DayType::Sunday, state->dataWeather->RunPeriodInput[3].startWeekDay); EXPECT_EQ(2017, state->dataWeather->RunPeriodInput[3].startYear); EXPECT_EQ(2457755, state->dataWeather->RunPeriodInput[3].startJulianDate); EXPECT_EQ(2458119, state->dataWeather->RunPeriodInput[3].endJulianDate); @@ -226,17 +225,17 @@ TEST_F(EnergyPlusFixture, RunPeriod_YearTests) EXPECT_EQ(startDays[i], state->dataWeather->RunPeriodInput[3].monWeekDay[i]); } - EXPECT_ENUM_EQ(ScheduleManager::DayType::Wednesday, state->dataWeather->RunPeriodInput[4].startWeekDay); + EXPECT_ENUM_EQ(Sched::DayType::Wednesday, state->dataWeather->RunPeriodInput[4].startWeekDay); EXPECT_EQ(2010, state->dataWeather->RunPeriodInput[4].startYear); EXPECT_EQ(2455427, state->dataWeather->RunPeriodInput[4].startJulianDate); EXPECT_EQ(2455562, state->dataWeather->RunPeriodInput[4].endJulianDate); - EXPECT_ENUM_EQ(ScheduleManager::DayType::Saturday, state->dataWeather->RunPeriodInput[5].startWeekDay); + EXPECT_ENUM_EQ(Sched::DayType::Saturday, state->dataWeather->RunPeriodInput[5].startWeekDay); EXPECT_EQ(1992, state->dataWeather->RunPeriodInput[5].startYear); EXPECT_EQ(2448682, state->dataWeather->RunPeriodInput[5].startJulianDate); EXPECT_EQ(2448988, state->dataWeather->RunPeriodInput[5].endJulianDate); - EXPECT_ENUM_EQ(ScheduleManager::DayType::Friday, state->dataWeather->RunPeriodInput[6].startWeekDay); + EXPECT_ENUM_EQ(Sched::DayType::Friday, state->dataWeather->RunPeriodInput[6].startWeekDay); EXPECT_EQ(2016, state->dataWeather->RunPeriodInput[6].startYear); EXPECT_EQ(2457389, state->dataWeather->RunPeriodInput[6].startJulianDate); EXPECT_EQ(2458940, state->dataWeather->RunPeriodInput[6].endJulianDate); diff --git a/tst/EnergyPlus/unit/SQLite.unit.cc b/tst/EnergyPlus/unit/SQLite.unit.cc index aba5b3a41a2..188f63200a4 100644 --- a/tst/EnergyPlus/unit/SQLite.unit.cc +++ b/tst/EnergyPlus/unit/SQLite.unit.cc @@ -628,7 +628,9 @@ TEST_F(SQLiteFixture, SQLiteProcedures_DaylightMaping) TEST_F(SQLiteFixture, SQLiteProcedures_createZoneExtendedOutput) { - auto const &zoneData0 = std::make_unique(); + state->init_state(*state); + + auto const &zoneData0 = std::make_unique(); // Why make_unique here? And why is this a reference? zoneData0->Name = "test zone 1"; zoneData0->CeilingHeight = 1; zoneData0->Volume = 1; @@ -738,10 +740,12 @@ TEST_F(SQLiteFixture, SQLiteProcedures_createZoneExtendedOutput) auto const lightingData0 = std::make_unique(); lightingData0->Name = "test lighting 1"; + lightingData0->sched = Sched::GetScheduleAlwaysOff(*state); + auto const lightingData1 = std::make_unique(); lightingData1->Name = "test lighting 2"; lightingData1->ZonePtr = 1; - lightingData1->SchedPtr = 1; + lightingData1->sched = Sched::AddScheduleConstant(*state, "SCHED-1"); lightingData1->DesignLevel = 2; lightingData1->FractionReturnAir = 2; lightingData1->FractionRadiant = 2; @@ -752,17 +756,23 @@ TEST_F(SQLiteFixture, SQLiteProcedures_createZoneExtendedOutput) auto const peopleData0 = std::make_unique(); peopleData0->Name = "test people 1"; + peopleData0->numberOfPeopleSched = Sched::GetScheduleAlwaysOff(*state); + peopleData0->activityLevelSched = Sched::GetScheduleAlwaysOff(*state); + peopleData0->workEffSched = Sched::GetScheduleAlwaysOff(*state); + peopleData0->clothingSched = Sched::GetScheduleAlwaysOff(*state); + peopleData0->airVelocitySched = Sched::GetScheduleAlwaysOff(*state); + auto const peopleData1 = std::make_unique(); peopleData1->Name = "test people 2"; peopleData1->ZonePtr = 1; peopleData1->NumberOfPeople = 2; - peopleData1->NumberOfPeoplePtr = 1; - peopleData1->ActivityLevelPtr = 1; + peopleData1->numberOfPeopleSched = Sched::GetSchedule(*state, "SCHED-1"); + peopleData1->activityLevelSched = Sched::GetSchedule(*state, "SCHED-1"); peopleData1->FractionRadiant = 2; peopleData1->FractionConvected = 2; - peopleData1->WorkEffPtr = 1; - peopleData1->ClothingPtr = 1; - peopleData1->AirVelocityPtr = 1; + peopleData1->workEffSched = Sched::GetSchedule(*state, "SCHED-1"); + peopleData1->clothingSched = Sched::GetSchedule(*state, "SCHED-1"); + peopleData1->airVelocitySched = Sched::GetSchedule(*state, "SCHED-1"); peopleData1->Fanger = true; peopleData1->Pierce = true; peopleData1->KSU = true; @@ -775,10 +785,12 @@ TEST_F(SQLiteFixture, SQLiteProcedures_createZoneExtendedOutput) auto const elecEquipData0 = std::make_unique(); elecEquipData0->Name = "test elecEquip 1"; + elecEquipData0->sched = Sched::GetScheduleAlwaysOff(*state); + auto const elecEquipData1 = std::make_unique(); elecEquipData1->Name = "test elecEquip 2"; elecEquipData1->ZonePtr = 1; - elecEquipData1->SchedPtr = 1; + elecEquipData1->sched = Sched::GetSchedule(*state, "SCHED-1"); elecEquipData1->DesignLevel = 2; elecEquipData1->FractionLatent = 2; elecEquipData1->FractionRadiant = 2; @@ -788,10 +800,11 @@ TEST_F(SQLiteFixture, SQLiteProcedures_createZoneExtendedOutput) auto const gasEquipData0 = std::make_unique(); gasEquipData0->Name = "test gasEquip 1"; + gasEquipData0->sched = Sched::GetScheduleAlwaysOff(*state); auto const gasEquipData1 = std::make_unique(); gasEquipData1->Name = "test gasEquip 2"; gasEquipData1->ZonePtr = 1; - gasEquipData1->SchedPtr = 1; + gasEquipData1->sched = Sched::GetSchedule(*state, "SCHED-1"); gasEquipData1->DesignLevel = 2; gasEquipData1->FractionLatent = 2; gasEquipData1->FractionRadiant = 2; @@ -801,10 +814,11 @@ TEST_F(SQLiteFixture, SQLiteProcedures_createZoneExtendedOutput) auto const steamEquipData0 = std::make_unique(); steamEquipData0->Name = "test steamEquip 1"; + steamEquipData0->sched = Sched::GetScheduleAlwaysOff(*state); auto const steamEquipData1 = std::make_unique(); steamEquipData1->Name = "test steamEquip 2"; steamEquipData1->ZonePtr = 1; - steamEquipData1->SchedPtr = 1; + steamEquipData1->sched = Sched::GetSchedule(*state, "SCHED-1"); steamEquipData1->DesignLevel = 2; steamEquipData1->FractionLatent = 2; steamEquipData1->FractionRadiant = 2; @@ -814,10 +828,11 @@ TEST_F(SQLiteFixture, SQLiteProcedures_createZoneExtendedOutput) auto const hwEquipData0 = std::make_unique(); hwEquipData0->Name = "test hwEquip 1"; + hwEquipData0->sched = Sched::GetScheduleAlwaysOff(*state); auto const hwEquipData1 = std::make_unique(); hwEquipData1->Name = "test hwEquip 2"; hwEquipData1->ZonePtr = 1; - hwEquipData1->SchedPtr = 1; + hwEquipData1->sched = Sched::GetSchedule(*state, "SCHED-1"); hwEquipData1->DesignLevel = 2; hwEquipData1->FractionLatent = 2; hwEquipData1->FractionRadiant = 2; @@ -827,10 +842,11 @@ TEST_F(SQLiteFixture, SQLiteProcedures_createZoneExtendedOutput) auto const otherEquipData0 = std::make_unique(); otherEquipData0->Name = "test otherEquip 1"; + otherEquipData0->sched = Sched::GetScheduleAlwaysOff(*state); auto const otherEquipData1 = std::make_unique(); otherEquipData1->Name = "test otherEquip 2"; otherEquipData1->ZonePtr = 1; - otherEquipData1->SchedPtr = 1; + otherEquipData1->sched = Sched::GetSchedule(*state, "SCHED-1"); otherEquipData1->DesignLevel = 2; otherEquipData1->FractionLatent = 2; otherEquipData1->FractionRadiant = 2; @@ -840,10 +856,11 @@ TEST_F(SQLiteFixture, SQLiteProcedures_createZoneExtendedOutput) auto const baseboardData0 = std::make_unique(); baseboardData0->Name = "test baseboard 1"; + baseboardData0->sched = Sched::GetScheduleAlwaysOff(*state); auto const baseboardData1 = std::make_unique(); baseboardData1->Name = "test baseboard 2"; baseboardData1->ZonePtr = 1; - baseboardData1->SchedPtr = 1; + baseboardData1->sched = Sched::GetSchedule(*state, "SCHED-1"); baseboardData1->CapatLowTemperature = 2; baseboardData1->LowTemperature = 2; baseboardData1->CapatHighTemperature = 2; @@ -854,18 +871,20 @@ TEST_F(SQLiteFixture, SQLiteProcedures_createZoneExtendedOutput) auto const infiltrationData0 = std::make_unique(); infiltrationData0->Name = "test infiltration 1"; + infiltrationData0->sched = Sched::GetScheduleAlwaysOff(*state); auto const infiltrationData1 = std::make_unique(); infiltrationData1->Name = "test infiltration 2"; infiltrationData1->ZonePtr = 1; - infiltrationData1->SchedPtr = 1; + infiltrationData1->sched = Sched::GetSchedule(*state, "SCHED-1"); infiltrationData1->DesignLevel = 2; auto const ventilationData0 = std::make_unique(); ventilationData0->Name = "test ventilation 1"; + ventilationData0->sched = Sched::GetScheduleAlwaysOff(*state); auto const ventilationData1 = std::make_unique(); ventilationData1->Name = "test ventilation 2"; ventilationData1->ZonePtr = 1; - ventilationData1->SchedPtr = 1; + ventilationData1->sched = Sched::GetSchedule(*state, "SCHED-1"); ventilationData1->DesignLevel = 2; auto const roomAirModelData0 = std::make_unique(); @@ -1009,62 +1028,62 @@ TEST_F(SQLiteFixture, SQLiteProcedures_createZoneExtendedOutput) ASSERT_EQ(2ul, lightings.size()); std::vector lighting0{"1", "test lighting 1", "", "", "0.0", "0.0", "0.0", "0.0", "0.0", "0.0", ""}; - std::vector lighting1{"2", "test lighting 2", "1", "1", "2.0", "2.0", "2.0", "2.0", "2.0", "2.0", "test"}; + std::vector lighting1{"2", "test lighting 2", "1", "2", "2.0", "2.0", "2.0", "2.0", "2.0", "2.0", "test"}; EXPECT_EQ(lighting0, lightings[0]); EXPECT_EQ(lighting1, lightings[1]); ASSERT_EQ(2ul, peoples.size()); std::vector people0{"1", "test people 1", "", "0", "", "", "0.0", "0.0", "", "", "", "0", "0", "0", "-1", "", "", "-1", "0.0", "0"}; - std::vector people1{"2", "test people 2", "1", "2", "1", "1", "2.0", "2.0", "1", "1", "1", "1", "1", "1", "1", + std::vector people1{"2", "test people 2", "1", "2", "2", "2", "2.0", "2.0", "2", "2", "2", "1", "1", "1", "1", "1", "test", "1", "2.0", "1"}; EXPECT_EQ(people0, peoples[0]); EXPECT_EQ(people1, peoples[1]); ASSERT_EQ(2ul, elecEquips.size()); std::vector elecEquip0{"1", "test elecEquip 1", "", "", "0.0", "0.0", "0.0", "0.0", "0.0", ""}; - std::vector elecEquip1{"2", "test elecEquip 2", "1", "1", "2.0", "2.0", "2.0", "2.0", "2.0", "test"}; + std::vector elecEquip1{"2", "test elecEquip 2", "1", "2", "2.0", "2.0", "2.0", "2.0", "2.0", "test"}; EXPECT_EQ(elecEquip0, elecEquips[0]); EXPECT_EQ(elecEquip1, elecEquips[1]); ASSERT_EQ(2ul, gasEquips.size()); std::vector gasEquip0{"1", "test gasEquip 1", "", "", "0.0", "0.0", "0.0", "0.0", "0.0", ""}; - std::vector gasEquip1{"2", "test gasEquip 2", "1", "1", "2.0", "2.0", "2.0", "2.0", "2.0", "test"}; + std::vector gasEquip1{"2", "test gasEquip 2", "1", "2", "2.0", "2.0", "2.0", "2.0", "2.0", "test"}; EXPECT_EQ(gasEquip0, gasEquips[0]); EXPECT_EQ(gasEquip1, gasEquips[1]); ASSERT_EQ(2ul, steamEquips.size()); std::vector steamEquip0{"1", "test steamEquip 1", "", "", "0.0", "0.0", "0.0", "0.0", "0.0", ""}; - std::vector steamEquip1{"2", "test steamEquip 2", "1", "1", "2.0", "2.0", "2.0", "2.0", "2.0", "test"}; + std::vector steamEquip1{"2", "test steamEquip 2", "1", "2", "2.0", "2.0", "2.0", "2.0", "2.0", "test"}; EXPECT_EQ(steamEquip0, steamEquips[0]); EXPECT_EQ(steamEquip1, steamEquips[1]); ASSERT_EQ(2ul, hwEquips.size()); std::vector hwEquip0{"1", "test hwEquip 1", "", "", "0.0", "0.0", "0.0", "0.0", "0.0", ""}; - std::vector hwEquip1{"2", "test hwEquip 2", "1", "1", "2.0", "2.0", "2.0", "2.0", "2.0", "test"}; + std::vector hwEquip1{"2", "test hwEquip 2", "1", "2", "2.0", "2.0", "2.0", "2.0", "2.0", "test"}; EXPECT_EQ(hwEquip0, hwEquips[0]); EXPECT_EQ(hwEquip1, hwEquips[1]); ASSERT_EQ(2ul, otherEquips.size()); std::vector otherEquip0{"1", "test otherEquip 1", "", "", "0.0", "0.0", "0.0", "0.0", "0.0", ""}; - std::vector otherEquip1{"2", "test otherEquip 2", "1", "1", "2.0", "2.0", "2.0", "2.0", "2.0", "test"}; + std::vector otherEquip1{"2", "test otherEquip 2", "1", "2", "2.0", "2.0", "2.0", "2.0", "2.0", "test"}; EXPECT_EQ(otherEquip0, otherEquips[0]); EXPECT_EQ(otherEquip1, otherEquips[1]); ASSERT_EQ(2ul, baseboards.size()); std::vector baseboard0{"1", "test baseboard 1", "", "", "0.0", "0.0", "0.0", "0.0", "0.0", "0.0", ""}; - std::vector baseboard1{"2", "test baseboard 2", "1", "1", "2.0", "2.0", "2.0", "2.0", "2.0", "2.0", "test"}; + std::vector baseboard1{"2", "test baseboard 2", "1", "2", "2.0", "2.0", "2.0", "2.0", "2.0", "2.0", "test"}; EXPECT_EQ(baseboard0, baseboards[0]); EXPECT_EQ(baseboard1, baseboards[1]); ASSERT_EQ(2ul, infiltrations.size()); std::vector infiltration0{"1", "test infiltration 1", "", "", "0.0"}; - std::vector infiltration1{"2", "test infiltration 2", "1", "1", "2.0"}; + std::vector infiltration1{"2", "test infiltration 2", "1", "2", "2.0"}; EXPECT_EQ(infiltration0, infiltrations[0]); EXPECT_EQ(infiltration1, infiltrations[1]); ASSERT_EQ(2ul, ventilations.size()); std::vector ventilation0{"1", "test ventilation 1", "", "", "0.0"}; - std::vector ventilation1{"2", "test ventilation 2", "1", "1", "2.0"}; + std::vector ventilation1{"2", "test ventilation 2", "1", "2", "2.0"}; EXPECT_EQ(ventilation0, ventilations[0]); EXPECT_EQ(ventilation1, ventilations[1]); diff --git a/tst/EnergyPlus/unit/SZVAVModel.unit.cc b/tst/EnergyPlus/unit/SZVAVModel.unit.cc index 0316d2a9067..6bbb3d6144e 100644 --- a/tst/EnergyPlus/unit/SZVAVModel.unit.cc +++ b/tst/EnergyPlus/unit/SZVAVModel.unit.cc @@ -94,7 +94,6 @@ using namespace EnergyPlus::HeatBalanceManager; using namespace EnergyPlus::OutputReportPredefined; using namespace EnergyPlus::DataPlant; using namespace EnergyPlus::Psychrometrics; -using namespace EnergyPlus::ScheduleManager; using namespace EnergyPlus::SZVAVModel; using namespace EnergyPlus::UnitarySystems; using namespace EnergyPlus::WaterCoils; @@ -168,7 +167,8 @@ TEST_F(EnergyPlusFixture, SZVAV_PTUnit_Testing) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + state->dataEnvrn->StdRhoAir = 1.0; state->dataSize->CurZoneEqNum = 0; @@ -231,9 +231,6 @@ TEST_F(EnergyPlusFixture, SZVAV_PTUnit_Testing) state->dataZoneEquip->ZoneEquipConfig.allocate(1); state->dataZoneEquip->ZoneEquipConfig(1).ZoneNode = 1; - state->dataScheduleMgr->Schedule.allocate(1); - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; - thisUnit.m_SimASHRAEModel = true; thisUnit.m_CoolingCoilUpstream = true; thisUnit.m_FanExists = true; @@ -250,8 +247,8 @@ TEST_F(EnergyPlusFixture, SZVAV_PTUnit_Testing) thisUnit.m_CoolingCoilIndex = 1; thisUnit.m_HeatingCoilIndex = 2; thisUnit.m_FanIndex = 1; - thisUnit.m_SysAvailSchedPtr = 1; - thisUnit.m_FanAvailSchedPtr = 1; + thisUnit.m_sysAvailSched = Sched::GetSchedule(*state, "ONSCHED"); + thisUnit.m_fanAvailSched = Sched::GetSchedule(*state, "ONSCHED"); thisUnit.m_FanPlace = HVAC::FanPlace::BlowThru; // ensure constant fan mode is used thisUnit.m_FanOpMode = HVAC::FanOp::Continuous; @@ -273,7 +270,6 @@ TEST_F(EnergyPlusFixture, SZVAV_PTUnit_Testing) state->dataEnvrn->OutDryBulbTemp = 30.0; state->dataEnvrn->OutBaroPress = 101325.0; OutputReportPredefined::SetPredefinedTables(*state); - Psychrometrics::InitializePsychRoutines(*state); createCoilSelectionReportObj(*state); int UnitNum = 0; @@ -315,7 +311,8 @@ TEST_F(EnergyPlusFixture, SZVAV_PTUnit_Testing) state->dataLoopNodes->Node(zoneNodeNum).Enthalpy = 52120.0; // turn the availability schedule on - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; + Sched::GetSchedule(*state, "ONSCHED")->currentVal = 1.0; + state->dataUnitarySystems->CoolingLoad = CoolingLoad; state->dataUnitarySystems->HeatingLoad = HeatingLoad; // set fan inlet max avail so fan doesn't shut down flow @@ -520,9 +517,9 @@ TEST_F(EnergyPlusFixture, SZVAV_FanCoilUnit_Testing) state->dataEnvrn->OutBaroPress = 101325.0; state->dataEnvrn->StdRhoAir = 1.20; state->dataWaterCoils->GetWaterCoilsInputFlag = true; - state->dataGlobal->NumOfTimeStepInHour = 1; + state->dataGlobal->TimeStepsInHour = 1; state->dataGlobal->TimeStep = 1; - state->dataGlobal->MinutesPerTimeStep = 60; + state->dataGlobal->MinutesInTimeStep = 60; state->dataSize->CurZoneEqNum = 1; std::string const idf_objects = delimited_string({ @@ -642,21 +639,20 @@ TEST_F(EnergyPlusFixture, SZVAV_FanCoilUnit_Testing) }); ASSERT_TRUE(process_idf(idf_objects)); + state->dataGlobal->TimeStepsInHour = 1; + state->dataGlobal->MinutesInTimeStep = 60; + state->init_state(*state); + state->dataEnvrn->StdRhoAir = 1.0; state->dataEnvrn->OutBaroPress = 101325.0; state->dataEnvrn->StdRhoAir = 1.20; state->dataWaterCoils->GetWaterCoilsInputFlag = true; - state->dataGlobal->NumOfTimeStepInHour = 1; state->dataGlobal->TimeStep = 1; - state->dataGlobal->MinutesPerTimeStep = 60; state->dataSize->CurZoneEqNum = 1; - InitializePsychRoutines(*state); GetZoneData(*state, ErrorsFound); EXPECT_EQ("WEST ZONE", state->dataHeatBal->Zone(1).Name); GetZoneEquipmentData(*state); - ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; GetFanCoilUnits(*state); auto &thisFanCoil(state->dataFanCoilUnits->FanCoil(1)); EXPECT_ENUM_EQ(CCM::ASHRAE, thisFanCoil.CapCtrlMeth_Num); @@ -742,7 +738,7 @@ TEST_F(EnergyPlusFixture, SZVAV_FanCoilUnit_Testing) state->dataEnvrn->DayOfWeek = 2; state->dataEnvrn->HolidayIndex = 0; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); - UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); state->dataSize->ZoneEqSizing.allocate(1); state->dataSize->ZoneSizingRunDone = true; thisFanCoil.DesignHeatingCapacity = 10000.0; diff --git a/tst/EnergyPlus/unit/ScheduleManager.unit.cc b/tst/EnergyPlus/unit/ScheduleManager.unit.cc index bfaee667d65..aeb952b8c69 100644 --- a/tst/EnergyPlus/unit/ScheduleManager.unit.cc +++ b/tst/EnergyPlus/unit/ScheduleManager.unit.cc @@ -70,120 +70,103 @@ #include using namespace EnergyPlus; -using namespace EnergyPlus::ScheduleManager; TEST_F(EnergyPlusFixture, ScheduleManager_isMinuteMultipleOfTimestep) { // EnergyPlus can accept 1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30, 60 timesteps per hour which correspond to // 60, 30, 20, 15, 12, 10, 5, 5, 4, 3, 2, 1 minutes per timestep - EXPECT_TRUE(isMinuteMultipleOfTimestep(0, 15)); - EXPECT_TRUE(isMinuteMultipleOfTimestep(15, 15)); - EXPECT_TRUE(isMinuteMultipleOfTimestep(30, 15)); - EXPECT_TRUE(isMinuteMultipleOfTimestep(45, 15)); - - EXPECT_FALSE(isMinuteMultipleOfTimestep(22, 15)); - EXPECT_FALSE(isMinuteMultipleOfTimestep(53, 15)); - - EXPECT_TRUE(isMinuteMultipleOfTimestep(0, 12)); - EXPECT_TRUE(isMinuteMultipleOfTimestep(12, 12)); - EXPECT_TRUE(isMinuteMultipleOfTimestep(24, 12)); - EXPECT_TRUE(isMinuteMultipleOfTimestep(36, 12)); - EXPECT_TRUE(isMinuteMultipleOfTimestep(48, 12)); - - EXPECT_FALSE(isMinuteMultipleOfTimestep(22, 12)); - EXPECT_FALSE(isMinuteMultipleOfTimestep(53, 12)); + EXPECT_TRUE(Sched::isMinuteMultipleOfTimestep(0, 15)); + EXPECT_TRUE(Sched::isMinuteMultipleOfTimestep(15, 15)); + EXPECT_TRUE(Sched::isMinuteMultipleOfTimestep(30, 15)); + EXPECT_TRUE(Sched::isMinuteMultipleOfTimestep(45, 15)); + + EXPECT_FALSE(Sched::isMinuteMultipleOfTimestep(22, 15)); + EXPECT_FALSE(Sched::isMinuteMultipleOfTimestep(53, 15)); + + EXPECT_TRUE(Sched::isMinuteMultipleOfTimestep(0, 12)); + EXPECT_TRUE(Sched::isMinuteMultipleOfTimestep(12, 12)); + EXPECT_TRUE(Sched::isMinuteMultipleOfTimestep(24, 12)); + EXPECT_TRUE(Sched::isMinuteMultipleOfTimestep(36, 12)); + EXPECT_TRUE(Sched::isMinuteMultipleOfTimestep(48, 12)); + + EXPECT_FALSE(Sched::isMinuteMultipleOfTimestep(22, 12)); + EXPECT_FALSE(Sched::isMinuteMultipleOfTimestep(53, 12)); } -TEST_F(EnergyPlusFixture, ScheduleManager_UpdateScheduleValues) +TEST_F(EnergyPlusFixture, ScheduleManager_UpdateScheduleVals) { - - state->dataScheduleMgr->ScheduleInputProcessed = true; + auto &s_glob = state->dataGlobal; + auto &s_sched = state->dataSched; state->dataEnvrn->DSTIndicator = 0; - state->dataScheduleMgr->NumSchedules = 1; - state->dataScheduleMgr->Schedule.allocate(1); - state->dataScheduleMgr->Schedule(1).WeekSchedulePointer.allocate(367); - state->dataScheduleMgr->WeekSchedule.allocate(3); - state->dataScheduleMgr->WeekSchedule(1).DaySchedulePointer.allocate(12); - state->dataScheduleMgr->WeekSchedule(2).DaySchedulePointer.allocate(12); - state->dataScheduleMgr->WeekSchedule(3).DaySchedulePointer.allocate(12); - state->dataGlobal->NumOfTimeStepInHour = 1; - state->dataScheduleMgr->DaySchedule.allocate(3); - state->dataScheduleMgr->DaySchedule(1).TSValue.allocate(1, 24); - state->dataScheduleMgr->DaySchedule(2).TSValue.allocate(1, 24); - state->dataScheduleMgr->DaySchedule(3).TSValue.allocate(1, 24); - - for (int ScheduleIndex = 1; ScheduleIndex <= state->dataScheduleMgr->NumSchedules; ScheduleIndex++) { - for (int i = 1; i <= 366; i++) { - int x = 1; - if (i > 250) { - x = 3; - } else if (i > 249) { - x = 2; - } - state->dataScheduleMgr->Schedule(ScheduleIndex).WeekSchedulePointer(i) = x; - } - } - for (int WeekSchedulePointer = 1; WeekSchedulePointer <= 3; WeekSchedulePointer++) { - for (int dayOfWeek = 1; dayOfWeek <= 12; dayOfWeek++) { - int y = 1; - if (WeekSchedulePointer == 2) y = 2; - if (WeekSchedulePointer == 3) y = 3; - state->dataScheduleMgr->WeekSchedule(WeekSchedulePointer).DaySchedulePointer(dayOfWeek) = y; - } - } - for (int daySchedulePointer = 1; daySchedulePointer <= 3; daySchedulePointer++) { - for (int whichHour = 1; whichHour <= 24; whichHour++) { - Real64 schVal = 1.0; - if (daySchedulePointer == 2) schVal = 2.0; - if (daySchedulePointer == 3) schVal = 3.0; - state->dataScheduleMgr->DaySchedule(daySchedulePointer).TSValue(1, whichHour) = schVal; - } - } + + auto *sched1 = Sched::AddScheduleDetailed(*state, "Detailed-1"); + + auto *weekSched1 = Sched::AddWeekSchedule(*state, "Week-1"); + auto *weekSched2 = Sched::AddWeekSchedule(*state, "Week-2"); + auto *weekSched3 = Sched::AddWeekSchedule(*state, "Week-3"); + + s_glob->TimeStepsInHour = 1; + + auto *daySched1 = Sched::AddDaySchedule(*state, "Day-1"); + auto *daySched2 = Sched::AddDaySchedule(*state, "Day-2"); + auto *daySched3 = Sched::AddDaySchedule(*state, "Day-3"); + + for (int i = 1; i <= 249; i++) sched1->weekScheds[i] = weekSched1; + sched1->weekScheds[250] = weekSched2; + for (int i = 251; i <= 366; i++) sched1->weekScheds[i] = weekSched3; + + std::fill(weekSched1->dayScheds.begin()+1, weekSched1->dayScheds.end(), daySched1); + std::fill(weekSched2->dayScheds.begin()+1, weekSched2->dayScheds.end(), daySched2); + std::fill(weekSched3->dayScheds.begin()+1, weekSched3->dayScheds.end(), daySched3); + + std::fill(daySched1->tsVals.begin(), daySched1->tsVals.end(), 1.0); + std::fill(daySched2->tsVals.begin(), daySched2->tsVals.end(), 2.0); + std::fill(daySched3->tsVals.begin(), daySched3->tsVals.end(), 3.0); state->dataEnvrn->HolidayIndex = 0; state->dataEnvrn->DayOfWeek = 1; state->dataEnvrn->DayOfWeekTomorrow = 2; - state->dataGlobal->TimeStep = 1; - state->dataGlobal->HourOfDay = 1; + s_glob->TimeStep = 1; + s_glob->HourOfDay = 1; // check day schedules - EXPECT_EQ(state->dataScheduleMgr->DaySchedule(1).TSValue(1, 1), 1.0); // day < 250 points to this schedule - EXPECT_EQ(state->dataScheduleMgr->DaySchedule(1).TSValue(1, 24), 1.0); + EXPECT_EQ(daySched1->tsVals[0 * s_glob->TimeStepsInHour], 1.0); // day < 250 points to this schedule + EXPECT_EQ(daySched1->tsVals[23 * s_glob->TimeStepsInHour], 1.0); - EXPECT_EQ(state->dataScheduleMgr->DaySchedule(2).TSValue(1, 1), 2.0); // day = 250 points to this schedule - EXPECT_EQ(state->dataScheduleMgr->DaySchedule(2).TSValue(1, 24), 2.0); + EXPECT_EQ(daySched2->tsVals[0 * s_glob->TimeStepsInHour], 2.0); // day = 250 points to this schedule + EXPECT_EQ(daySched2->tsVals[23 * s_glob->TimeStepsInHour], 2.0); - EXPECT_EQ(state->dataScheduleMgr->DaySchedule(3).TSValue(1, 1), 3.0); // day > 250 points to this schedule - EXPECT_EQ(state->dataScheduleMgr->DaySchedule(3).TSValue(1, 24), 3.0); + EXPECT_EQ(daySched3->tsVals[0 * s_glob->TimeStepsInHour], 3.0); // day > 250 points to this schedule + EXPECT_EQ(daySched3->tsVals[23 * s_glob->TimeStepsInHour], 3.0); // schedule values are 1 through day 249, 2 for day 250, and 3 for remainder of year state->dataEnvrn->DayOfYear_Schedule = 1; - UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); // expect 1.0 on day 1 - EXPECT_EQ(state->dataScheduleMgr->Schedule(1).CurrentValue, 1.0); + EXPECT_EQ(sched1->currentVal, 1.0); state->dataEnvrn->DayOfYear_Schedule = 250; - UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); // expect 2.0 on day 250 - EXPECT_EQ(state->dataScheduleMgr->Schedule(1).CurrentValue, 2.0); + EXPECT_EQ(sched1->currentVal, 2.0); // test end of day 250 with daylight savings time active - state->dataGlobal->HourOfDay = 24; + s_glob->HourOfDay = 24; state->dataEnvrn->DSTIndicator = 1; - UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); // expect a 3 on day 251, which on day 250 at midnight with DST of hour 1 of day 251 - EXPECT_EQ(state->dataScheduleMgr->Schedule(1).CurrentValue, 3.0); + EXPECT_EQ(sched1->currentVal, 3.0); - state->dataGlobal->HourOfDay = 2; + s_glob->HourOfDay = 2; state->dataEnvrn->DSTIndicator = 0; state->dataEnvrn->DayOfYear_Schedule = 251; - UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); // expect 3.0 for remainder of year regardless of DST - EXPECT_EQ(state->dataScheduleMgr->Schedule(1).CurrentValue, 3.0); - state->dataGlobal->HourOfDay = 24; + EXPECT_EQ(sched1->currentVal, 3.0); + s_glob->HourOfDay = 24; state->dataEnvrn->DSTIndicator = 1; - UpdateScheduleValues(*state); - EXPECT_EQ(state->dataScheduleMgr->Schedule(1).CurrentValue, 3.0); + Sched::UpdateScheduleVals(*state); + EXPECT_EQ(sched1->currentVal, 3.0); } TEST_F(EnergyPlusFixture, ScheduleAnnualFullLoadHours_test) @@ -238,23 +221,27 @@ TEST_F(EnergyPlusFixture, ScheduleAnnualFullLoadHours_test) ASSERT_TRUE(process_idf(idf_objects)); - state->dataGlobal->NumOfTimeStepInHour = 4; - state->dataGlobal->MinutesPerTimeStep = 15; + auto &s_glob = state->dataGlobal; + + s_glob->TimeStepsInHour = 4; + s_glob->MinutesInTimeStep = 15; - int onSchedIndex = GetScheduleIndex(*state, "ONSCHED"); - EXPECT_EQ(8760., ScheduleAnnualFullLoadHours(*state, onSchedIndex, 1, false)); + state->init_state(*state); + + auto *onSched = Sched::GetSchedule(*state, "ONSCHED"); + EXPECT_EQ(8760., onSched->getAnnualHoursFullLoad(*state, 1, false)); - int offSchedIndex = GetScheduleIndex(*state, "OFFSCHED"); - EXPECT_EQ(0., ScheduleAnnualFullLoadHours(*state, offSchedIndex, 1, false)); + auto *offSched = Sched::GetSchedule(*state, "OFFSCHED"); + EXPECT_EQ(0., offSched->getAnnualHoursFullLoad(*state, 1, false)); - int janOnSchedIndex = GetScheduleIndex(*state, "JANONSCHED"); - EXPECT_EQ(744., ScheduleAnnualFullLoadHours(*state, janOnSchedIndex, 1, false)); + auto *janOnSched = Sched::GetSchedule(*state, "JANONSCHED"); + EXPECT_EQ(744., janOnSched->getAnnualHoursFullLoad(*state, 1, false)); - int halfOnSchedIndex = GetScheduleIndex(*state, "HALFONSCHED"); - EXPECT_EQ(4380., ScheduleAnnualFullLoadHours(*state, halfOnSchedIndex, 1, false)); + auto *halfOnSched = Sched::GetSchedule(*state, "HALFONSCHED"); + EXPECT_EQ(4380., halfOnSched->getAnnualHoursFullLoad(*state, 1, false)); - int halfOnSched2Index = GetScheduleIndex(*state, "HALFONSCHED2"); - EXPECT_EQ(4380., ScheduleAnnualFullLoadHours(*state, halfOnSched2Index, 1, false)); + auto *halfOnSched2 = Sched::GetSchedule(*state, "HALFONSCHED2"); + EXPECT_EQ(4380., halfOnSched2->getAnnualHoursFullLoad(*state, 1, false)); } TEST_F(EnergyPlusFixture, ScheduleAverageHoursPerWeek_test) @@ -309,23 +296,27 @@ TEST_F(EnergyPlusFixture, ScheduleAverageHoursPerWeek_test) ASSERT_TRUE(process_idf(idf_objects)); - state->dataGlobal->NumOfTimeStepInHour = 4; - state->dataGlobal->MinutesPerTimeStep = 15; + auto &s_glob = state->dataGlobal; + + s_glob->TimeStepsInHour = 4; + s_glob->MinutesInTimeStep = 15; - int onSchedIndex = GetScheduleIndex(*state, "ONSCHED"); - EXPECT_EQ(168., ScheduleAverageHoursPerWeek(*state, onSchedIndex, 1, false)); + state->init_state(*state); - int offSchedIndex = GetScheduleIndex(*state, "OFFSCHED"); - EXPECT_EQ(0., ScheduleAverageHoursPerWeek(*state, offSchedIndex, 1, false)); + auto *onSched = Sched::GetSchedule(*state, "ONSCHED"); + EXPECT_EQ(168., onSched->getAverageWeeklyHoursFullLoad(*state, 1, false)); - int janOnSchedIndex = GetScheduleIndex(*state, "JANONSCHED"); - EXPECT_NEAR(14.3, ScheduleAverageHoursPerWeek(*state, janOnSchedIndex, 1, false), 0.1); + auto *offSched = Sched::GetSchedule(*state, "OFFSCHED"); + EXPECT_EQ(0., offSched->getAverageWeeklyHoursFullLoad(*state, 1, false)); - int halfOnSchedIndex = GetScheduleIndex(*state, "HALFONSCHED"); - EXPECT_EQ(84., ScheduleAverageHoursPerWeek(*state, halfOnSchedIndex, 1, false)); + auto *janOnSched = Sched::GetSchedule(*state, "JANONSCHED"); + EXPECT_NEAR(14.3, janOnSched->getAverageWeeklyHoursFullLoad(*state, 1, false), 0.1); - int halfOnSched2Index = GetScheduleIndex(*state, "HALFONSCHED2"); - EXPECT_EQ(84., ScheduleAverageHoursPerWeek(*state, halfOnSched2Index, 1, false)); + auto *halfOnSched = Sched::GetSchedule(*state, "HALFONSCHED"); + EXPECT_EQ(84., halfOnSched->getAverageWeeklyHoursFullLoad(*state, 1, false)); + + auto *halfOnSched2 = Sched::GetSchedule(*state, "HALFONSCHED2"); + EXPECT_EQ(84., halfOnSched2->getAverageWeeklyHoursFullLoad(*state, 1, false)); } TEST_F(EnergyPlusFixture, ScheduleHoursGT1perc_test) @@ -388,27 +379,31 @@ TEST_F(EnergyPlusFixture, ScheduleHoursGT1perc_test) ASSERT_TRUE(process_idf(idf_objects)); - state->dataGlobal->NumOfTimeStepInHour = 4; - state->dataGlobal->MinutesPerTimeStep = 15; - state->dataGlobal->TimeStepZone = 0.25; + auto &s_glob = state->dataGlobal; + + s_glob->TimeStepsInHour = 4; + s_glob->MinutesInTimeStep = 15; + s_glob->TimeStepZone = 0.25; - int onSchedIndex = GetScheduleIndex(*state, "ONSCHED"); - EXPECT_EQ(8760., ScheduleHoursGT1perc(*state, onSchedIndex, 1, false)); + state->init_state(*state); + + auto *onSched = Sched::GetSchedule(*state, "ONSCHED"); + EXPECT_EQ(8760., onSched->getAnnualHoursGreaterThan1Percent(*state, 1, false)); - int offSchedIndex = GetScheduleIndex(*state, "OFFSCHED"); - EXPECT_EQ(0., ScheduleHoursGT1perc(*state, offSchedIndex, 1, false)); + auto *offSched = Sched::GetSchedule(*state, "OFFSCHED"); + EXPECT_EQ(0., offSched->getAnnualHoursGreaterThan1Percent(*state, 1, false)); - int janOnSchedIndex = GetScheduleIndex(*state, "JANONSCHED"); - EXPECT_EQ(744., ScheduleHoursGT1perc(*state, janOnSchedIndex, 1, false)); + auto *janOnSched = Sched::GetSchedule(*state, "JANONSCHED"); + EXPECT_EQ(744., janOnSched->getAnnualHoursGreaterThan1Percent(*state, 1, false)); - int halfOnSchedIndex = GetScheduleIndex(*state, "HALFONSCHED"); - EXPECT_EQ(4380., ScheduleHoursGT1perc(*state, halfOnSchedIndex, 1, false)); + auto *halfOnSched = Sched::GetSchedule(*state, "HALFONSCHED"); + EXPECT_EQ(4380., halfOnSched->getAnnualHoursGreaterThan1Percent(*state, 1, false)); - int halfOnSched2Index = GetScheduleIndex(*state, "HALFONSCHED2"); - EXPECT_EQ(8760., ScheduleHoursGT1perc(*state, halfOnSched2Index, 1, false)); + auto *halfOnSched2 = Sched::GetSchedule(*state, "HALFONSCHED2"); + EXPECT_EQ(8760., halfOnSched2->getAnnualHoursGreaterThan1Percent(*state, 1, false)); - int halfOnSched3Index = GetScheduleIndex(*state, "HALFONSCHED3"); - EXPECT_EQ(4380., ScheduleHoursGT1perc(*state, halfOnSched3Index, 1, false)); + auto *halfOnSched3 = Sched::GetSchedule(*state, "HALFONSCHED3"); + EXPECT_EQ(4380., halfOnSched3->getAnnualHoursGreaterThan1Percent(*state, 1, false)); } TEST_F(EnergyPlusFixture, ScheduleDayInterval_SimpLinearInterp) @@ -463,71 +458,75 @@ TEST_F(EnergyPlusFixture, ScheduleDayInterval_SimpLinearInterp) ASSERT_TRUE(process_idf(idf_objects)); - state->dataGlobal->NumOfTimeStepInHour = 4; - state->dataGlobal->MinutesPerTimeStep = 15; - state->dataGlobal->TimeStepZone = 0.25; + auto &s_glob = state->dataGlobal; + + s_glob->TimeStepsInHour = 4; + s_glob->MinutesInTimeStep = 15; + s_glob->TimeStepZone = 0.25; + state->init_state(*state); + state->dataEnvrn->Month = 1; state->dataEnvrn->DayOfMonth = 1; - state->dataGlobal->HourOfDay = 1; - state->dataGlobal->TimeStep = 1; + s_glob->HourOfDay = 1; + s_glob->TimeStep = 1; state->dataEnvrn->DSTIndicator = 0; state->dataEnvrn->DayOfWeek = 2; state->dataEnvrn->HolidayIndex = 0; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); - int ASchedIndex = GetScheduleIndex(*state, "SCHYR_A"); // interpolate Linear - EXPECT_NEAR(0.001, LookUpScheduleValue(*state, ASchedIndex, 7, 4), 0.000001); + auto *ASched = Sched::GetSchedule(*state, "SCHYR_A"); // interpolate Linear + EXPECT_NEAR(0.001, ASched->getHrTsVal(*state, 7, 4), 0.000001); // interpolate over one hour - EXPECT_NEAR(25.001, LookUpScheduleValue(*state, ASchedIndex, 8, 1), 0.000001); - EXPECT_NEAR(50.001, LookUpScheduleValue(*state, ASchedIndex, 8, 2), 0.000001); - EXPECT_NEAR(75.001, LookUpScheduleValue(*state, ASchedIndex, 8, 3), 0.000001); - EXPECT_NEAR(100.001, LookUpScheduleValue(*state, ASchedIndex, 8, 4), 0.000001); + EXPECT_NEAR(25.001, ASched->getHrTsVal(*state, 8, 1), 0.000001); + EXPECT_NEAR(50.001, ASched->getHrTsVal(*state, 8, 2), 0.000001); + EXPECT_NEAR(75.001, ASched->getHrTsVal(*state, 8, 3), 0.000001); + EXPECT_NEAR(100.001, ASched->getHrTsVal(*state, 8, 4), 0.000001); // interpolate over two hours - EXPECT_NEAR(125.001, LookUpScheduleValue(*state, ASchedIndex, 9, 1), 0.000001); - EXPECT_NEAR(150.001, LookUpScheduleValue(*state, ASchedIndex, 9, 2), 0.000001); - EXPECT_NEAR(175.001, LookUpScheduleValue(*state, ASchedIndex, 9, 3), 0.000001); - EXPECT_NEAR(200.001, LookUpScheduleValue(*state, ASchedIndex, 9, 4), 0.000001); + EXPECT_NEAR(125.001, ASched->getHrTsVal(*state, 9, 1), 0.000001); + EXPECT_NEAR(150.001, ASched->getHrTsVal(*state, 9, 2), 0.000001); + EXPECT_NEAR(175.001, ASched->getHrTsVal(*state, 9, 3), 0.000001); + EXPECT_NEAR(200.001, ASched->getHrTsVal(*state, 9, 4), 0.000001); - EXPECT_NEAR(225.001, LookUpScheduleValue(*state, ASchedIndex, 10, 1), 0.000001); - EXPECT_NEAR(250.001, LookUpScheduleValue(*state, ASchedIndex, 10, 2), 0.000001); - EXPECT_NEAR(275.001, LookUpScheduleValue(*state, ASchedIndex, 10, 3), 0.000001); - EXPECT_NEAR(300.001, LookUpScheduleValue(*state, ASchedIndex, 10, 4), 0.000001); + EXPECT_NEAR(225.001, ASched->getHrTsVal(*state, 10, 1), 0.000001); + EXPECT_NEAR(250.001, ASched->getHrTsVal(*state, 10, 2), 0.000001); + EXPECT_NEAR(275.001, ASched->getHrTsVal(*state, 10, 3), 0.000001); + EXPECT_NEAR(300.001, ASched->getHrTsVal(*state, 10, 4), 0.000001); // interpolate over four hours - EXPECT_NEAR(325.001, LookUpScheduleValue(*state, ASchedIndex, 11, 1), 0.000001); - EXPECT_NEAR(350.001, LookUpScheduleValue(*state, ASchedIndex, 11, 2), 0.000001); - EXPECT_NEAR(375.001, LookUpScheduleValue(*state, ASchedIndex, 11, 3), 0.000001); - EXPECT_NEAR(400.001, LookUpScheduleValue(*state, ASchedIndex, 11, 4), 0.000001); + EXPECT_NEAR(325.001, ASched->getHrTsVal(*state, 11, 1), 0.000001); + EXPECT_NEAR(350.001, ASched->getHrTsVal(*state, 11, 2), 0.000001); + EXPECT_NEAR(375.001, ASched->getHrTsVal(*state, 11, 3), 0.000001); + EXPECT_NEAR(400.001, ASched->getHrTsVal(*state, 11, 4), 0.000001); - EXPECT_NEAR(525.001, LookUpScheduleValue(*state, ASchedIndex, 13, 1), 0.000001); - EXPECT_NEAR(550.001, LookUpScheduleValue(*state, ASchedIndex, 13, 2), 0.000001); - EXPECT_NEAR(575.001, LookUpScheduleValue(*state, ASchedIndex, 13, 3), 0.000001); - EXPECT_NEAR(600.001, LookUpScheduleValue(*state, ASchedIndex, 13, 4), 0.000001); + EXPECT_NEAR(525.001, ASched->getHrTsVal(*state, 13, 1), 0.000001); + EXPECT_NEAR(550.001, ASched->getHrTsVal(*state, 13, 2), 0.000001); + EXPECT_NEAR(575.001, ASched->getHrTsVal(*state, 13, 3), 0.000001); + EXPECT_NEAR(600.001, ASched->getHrTsVal(*state, 13, 4), 0.000001); // interpolate over one hour - decreasing - EXPECT_NEAR(675.001, LookUpScheduleValue(*state, ASchedIndex, 15, 1), 0.000001); - EXPECT_NEAR(650.001, LookUpScheduleValue(*state, ASchedIndex, 15, 2), 0.000001); - EXPECT_NEAR(625.001, LookUpScheduleValue(*state, ASchedIndex, 15, 3), 0.000001); - EXPECT_NEAR(600.001, LookUpScheduleValue(*state, ASchedIndex, 15, 4), 0.000001); + EXPECT_NEAR(675.001, ASched->getHrTsVal(*state, 15, 1), 0.000001); + EXPECT_NEAR(650.001, ASched->getHrTsVal(*state, 15, 2), 0.000001); + EXPECT_NEAR(625.001, ASched->getHrTsVal(*state, 15, 3), 0.000001); + EXPECT_NEAR(600.001, ASched->getHrTsVal(*state, 15, 4), 0.000001); // interpolate over four hours - decreasing - EXPECT_NEAR(375.001, LookUpScheduleValue(*state, ASchedIndex, 18, 1), 0.000001); - EXPECT_NEAR(350.001, LookUpScheduleValue(*state, ASchedIndex, 18, 2), 0.000001); - EXPECT_NEAR(325.001, LookUpScheduleValue(*state, ASchedIndex, 18, 3), 0.000001); - EXPECT_NEAR(300.001, LookUpScheduleValue(*state, ASchedIndex, 18, 4), 0.000001); + EXPECT_NEAR(375.001, ASched->getHrTsVal(*state, 18, 1), 0.000001); + EXPECT_NEAR(350.001, ASched->getHrTsVal(*state, 18, 2), 0.000001); + EXPECT_NEAR(325.001, ASched->getHrTsVal(*state, 18, 3), 0.000001); + EXPECT_NEAR(300.001, ASched->getHrTsVal(*state, 18, 4), 0.000001); - EXPECT_NEAR(275.001, LookUpScheduleValue(*state, ASchedIndex, 19, 1), 0.000001); - EXPECT_NEAR(250.001, LookUpScheduleValue(*state, ASchedIndex, 19, 2), 0.000001); - EXPECT_NEAR(225.001, LookUpScheduleValue(*state, ASchedIndex, 19, 3), 0.000001); - EXPECT_NEAR(200.001, LookUpScheduleValue(*state, ASchedIndex, 19, 4), 0.000001); + EXPECT_NEAR(275.001, ASched->getHrTsVal(*state, 19, 1), 0.000001); + EXPECT_NEAR(250.001, ASched->getHrTsVal(*state, 19, 2), 0.000001); + EXPECT_NEAR(225.001, ASched->getHrTsVal(*state, 19, 3), 0.000001); + EXPECT_NEAR(200.001, ASched->getHrTsVal(*state, 19, 4), 0.000001); } TEST_F(EnergyPlusFixture, ScheduleDayInterval_PartialHourLinearInterp) @@ -576,31 +575,35 @@ TEST_F(EnergyPlusFixture, ScheduleDayInterval_PartialHourLinearInterp) ASSERT_TRUE(process_idf(idf_objects)); - state->dataGlobal->NumOfTimeStepInHour = 4; - state->dataGlobal->MinutesPerTimeStep = 15; - state->dataGlobal->TimeStepZone = 0.25; + auto &s_glob = state->dataGlobal; + + s_glob->TimeStepsInHour = 4; + s_glob->MinutesInTimeStep = 15; + s_glob->TimeStepZone = 0.25; + + state->init_state(*state); state->dataEnvrn->Month = 1; state->dataEnvrn->DayOfMonth = 1; - state->dataGlobal->HourOfDay = 1; - state->dataGlobal->TimeStep = 1; + s_glob->HourOfDay = 1; + s_glob->TimeStep = 1; state->dataEnvrn->DSTIndicator = 0; state->dataEnvrn->DayOfWeek = 2; state->dataEnvrn->HolidayIndex = 0; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); - int ASchedIndex = GetScheduleIndex(*state, "SCHYR_A"); // interpolate Linear - EXPECT_NEAR(0.001, LookUpScheduleValue(*state, ASchedIndex, 7, 4), 0.000001); + auto *ASched = Sched::GetSchedule(*state, "SCHYR_A"); // interpolate Linear + EXPECT_NEAR(0.001, ASched->getHrTsVal(*state, 7, 4), 0.000001); // interpolate over first half hour - EXPECT_NEAR(25.001, LookUpScheduleValue(*state, ASchedIndex, 8, 1), 0.000001); - EXPECT_NEAR(50.001, LookUpScheduleValue(*state, ASchedIndex, 8, 2), 0.000001); + EXPECT_NEAR(25.001, ASched->getHrTsVal(*state, 8, 1), 0.000001); + EXPECT_NEAR(50.001, ASched->getHrTsVal(*state, 8, 2), 0.000001); // interpolate over second half hour - EXPECT_NEAR(75.001, LookUpScheduleValue(*state, ASchedIndex, 8, 3), 0.000001); - EXPECT_NEAR(100.001, LookUpScheduleValue(*state, ASchedIndex, 8, 4), 0.000001); + EXPECT_NEAR(75.001, ASched->getHrTsVal(*state, 8, 3), 0.000001); + EXPECT_NEAR(100.001, ASched->getHrTsVal(*state, 8, 4), 0.000001); } TEST_F(EnergyPlusFixture, ScheduleDayInterval_LinearInterpIntervalHittingIntervals) @@ -658,31 +661,35 @@ TEST_F(EnergyPlusFixture, ScheduleDayInterval_LinearInterpIntervalHittingInterva ASSERT_TRUE(process_idf(idf_objects)); - state->dataGlobal->NumOfTimeStepInHour = 4; - state->dataGlobal->MinutesPerTimeStep = 15; - state->dataGlobal->TimeStepZone = 0.25; + auto &s_glob = state->dataGlobal; + + s_glob->TimeStepsInHour = 4; + s_glob->MinutesInTimeStep = 15; + s_glob->TimeStepZone = 0.25; + state->init_state(*state); + state->dataEnvrn->Month = 1; state->dataEnvrn->DayOfMonth = 1; - state->dataGlobal->HourOfDay = 1; - state->dataGlobal->TimeStep = 1; + s_glob->HourOfDay = 1; + s_glob->TimeStep = 1; state->dataEnvrn->DSTIndicator = 0; state->dataEnvrn->DayOfWeek = 2; state->dataEnvrn->HolidayIndex = 0; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); - int ASchedIndex = GetScheduleIndex(*state, "2LLOYEAR"); // interpolate Linear + auto *ASched = Sched::GetSchedule(*state, "2LLOYEAR"); // interpolate Linear // Timesteps will go 1,2,3,4; Not 0,1,2,3, Hours to go as (actual hour+1) therefore 7:15 is 8,1 // Check for values specified in schedule (Lower and upper limits) - EXPECT_NEAR(0.1, LookUpScheduleValue(*state, ASchedIndex, 6, 4), 0.000001); // at 6:00 - EXPECT_NEAR(0.1, LookUpScheduleValue(*state, ASchedIndex, 17, 1), 0.000001); // at 16:15 - EXPECT_NEAR(0.1, LookUpScheduleValue(*state, ASchedIndex, 19, 1), 0.000001); // at 18:15 - EXPECT_NEAR(0.9, LookUpScheduleValue(*state, ASchedIndex, 24, 4), 0.000001); // at 24:00 + EXPECT_NEAR(0.1, ASched->getHrTsVal(*state, 6, 4), 0.000001); // at 6:00 + EXPECT_NEAR(0.1, ASched->getHrTsVal(*state, 17, 1), 0.000001); // at 16:15 + EXPECT_NEAR(0.1, ASched->getHrTsVal(*state, 19, 1), 0.000001); // at 18:15 + EXPECT_NEAR(0.9, ASched->getHrTsVal(*state, 24, 4), 0.000001); // at 24:00 // Interpolation check - EXPECT_NEAR(0.4199999, LookUpScheduleValue(*state, ASchedIndex, 7, 2), 0.000001); // Value at 06:30 - EXPECT_NEAR(0.1000000, LookUpScheduleValue(*state, ASchedIndex, 18, 3), 0.000001); // Value at 06:30 - EXPECT_NEAR(0.8304347, LookUpScheduleValue(*state, ASchedIndex, 24, 2), 0.000001); // Value at 06:30 + EXPECT_NEAR(0.4199999, ASched->getHrTsVal(*state, 7, 2), 0.000001); // Value at 06:30 + EXPECT_NEAR(0.1000000, ASched->getHrTsVal(*state, 18, 3), 0.000001); // Value at 06:30 + EXPECT_NEAR(0.8304347, ASched->getHrTsVal(*state, 24, 2), 0.000001); // Value at 06:30 } TEST_F(EnergyPlusFixture, ScheduleDayInterval_LinearInterpIntervalNotTimestep) @@ -731,31 +738,35 @@ TEST_F(EnergyPlusFixture, ScheduleDayInterval_LinearInterpIntervalNotTimestep) ASSERT_TRUE(process_idf(idf_objects)); - state->dataGlobal->NumOfTimeStepInHour = 4; - state->dataGlobal->MinutesPerTimeStep = 15; - state->dataGlobal->TimeStepZone = 0.25; + auto &s_glob = state->dataGlobal; + + s_glob->TimeStepsInHour = 4; + s_glob->MinutesInTimeStep = 15; + s_glob->TimeStepZone = 0.25; + state->init_state(*state); + state->dataEnvrn->Month = 1; state->dataEnvrn->DayOfMonth = 1; - state->dataGlobal->HourOfDay = 1; - state->dataGlobal->TimeStep = 1; + s_glob->HourOfDay = 1; + s_glob->TimeStep = 1; state->dataEnvrn->DSTIndicator = 0; state->dataEnvrn->DayOfWeek = 2; state->dataEnvrn->HolidayIndex = 0; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); - int ASchedIndex = GetScheduleIndex(*state, "SCHYR_A"); // interpolate Linear - EXPECT_NEAR(0.0, LookUpScheduleValue(*state, ASchedIndex, 7, 4), 0.000001); + auto *ASched = Sched::GetSchedule(*state, "SCHYR_A"); // interpolate Linear + EXPECT_NEAR(0.0, ASched->getHrTsVal(*state, 7, 4), 0.000001); // interpolate over first half hour - EXPECT_NEAR(25.0, LookUpScheduleValue(*state, ASchedIndex, 8, 1), 0.000001); - EXPECT_NEAR(50.0, LookUpScheduleValue(*state, ASchedIndex, 8, 2), 0.000001); + EXPECT_NEAR(25.0, ASched->getHrTsVal(*state, 8, 1), 0.000001); + EXPECT_NEAR(50.0, ASched->getHrTsVal(*state, 8, 2), 0.000001); // interpolate over second half hour - EXPECT_NEAR(75.0, LookUpScheduleValue(*state, ASchedIndex, 8, 3), 0.000001); - EXPECT_NEAR(100.0, LookUpScheduleValue(*state, ASchedIndex, 8, 4), 0.000001); + EXPECT_NEAR(75.0, ASched->getHrTsVal(*state, 8, 3), 0.000001); + EXPECT_NEAR(100.0, ASched->getHrTsVal(*state, 8, 4), 0.000001); } TEST_F(EnergyPlusFixture, ScheduleYearMaxItems) @@ -864,35 +875,38 @@ TEST_F(EnergyPlusFixture, Schedule_GetCurrentScheduleValue_DST) ASSERT_TRUE(process_idf(idf_objects)); - state->dataGlobal->NumOfTimeStepInHour = 4; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 15; // must initialize this to get schedules initialized - state->dataGlobal->TimeStepZone = 0.25; - state->dataGlobal->TimeStepZoneSec = state->dataGlobal->TimeStepZone * Constant::SecInHour; + auto &s_glob = state->dataGlobal; + + s_glob->TimeStepsInHour = 4; // must initialize this to get schedules initialized + s_glob->MinutesInTimeStep = 15; // must initialize this to get schedules initialized + s_glob->TimeStepZone = 0.25; + s_glob->TimeStepZoneSec = s_glob->TimeStepZone * Constant::rSecsInHour; - ScheduleManager::ProcessScheduleInput(*state); // read schedules + state->init_state(*state); state->dataEnvrn->Month = 5; state->dataEnvrn->DayOfMonth = 31; - state->dataGlobal->HourOfDay = 24; + s_glob->HourOfDay = 24; state->dataEnvrn->DayOfWeek = 4; state->dataEnvrn->DayOfWeekTomorrow = 5; state->dataEnvrn->HolidayIndex = 0; - state->dataGlobal->TimeStep = 1; + s_glob->TimeStep = 1; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); state->dataEnvrn->DSTIndicator = 0; // DST IS OFF - ScheduleManager::UpdateScheduleValues(*state); - EXPECT_EQ(1.0, ScheduleManager::LookUpScheduleValue(*state, 1, state->dataGlobal->HourOfDay, state->dataGlobal->TimeStep)); - EXPECT_EQ(1.0, state->dataScheduleMgr->Schedule(1).CurrentValue); - EXPECT_EQ(1.0, ScheduleManager::GetCurrentScheduleValue(*state, 1)); + Sched::UpdateScheduleVals(*state); + + auto *sched = Sched::GetSchedule(*state, "ELECTRICITY SEASON SCHEDULE"); + + EXPECT_EQ(1.0, sched->getHrTsVal(*state, s_glob->HourOfDay, s_glob->TimeStep)); + EXPECT_EQ(1.0, sched->currentVal); state->dataEnvrn->DSTIndicator = 1; // DST IS ON - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); // Since DST is on, you're actually on the next day, on 6/1 at 1:00 // so it **should** return 3.0 - EXPECT_EQ(3.0, state->dataScheduleMgr->Schedule(1).CurrentValue); - EXPECT_EQ(3.0, ScheduleManager::GetCurrentScheduleValue(*state, 1)); - EXPECT_EQ(3.0, ScheduleManager::LookUpScheduleValue(*state, 1, state->dataGlobal->HourOfDay, state->dataGlobal->TimeStep)); + EXPECT_EQ(3.0, sched->currentVal); + EXPECT_EQ(3.0, sched->getHrTsVal(*state, s_glob->HourOfDay, s_glob->TimeStep)); } TEST_F(EnergyPlusFixture, Schedule_GetCurrentScheduleValue_DST_SouthernHemisphere) @@ -912,41 +926,44 @@ TEST_F(EnergyPlusFixture, Schedule_GetCurrentScheduleValue_DST_SouthernHemispher }); ASSERT_TRUE(process_idf(idf_objects)); - - state->dataGlobal->NumOfTimeStepInHour = 4; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 15; // must initialize this to get schedules initialized - state->dataGlobal->TimeStepZone = 0.25; - state->dataGlobal->TimeStepZoneSec = state->dataGlobal->TimeStepZone * Constant::SecInHour; - - ScheduleManager::ProcessScheduleInput(*state); // read schedules - + + auto &s_glob = state->dataGlobal; + + s_glob->TimeStepsInHour = 4; // must initialize this to get schedules initialized + s_glob->MinutesInTimeStep = 15; // must initialize this to get schedules initialized + s_glob->TimeStepZone = 0.25; + s_glob->TimeStepZoneSec = s_glob->TimeStepZone * Constant::rSecsInHour; + + state->init_state(*state); + + auto *sched = Sched::GetSchedule(*state, "ELECTRICITY SEASON SCHEDULE"); + state->dataEnvrn->Month = 12; state->dataEnvrn->DayOfMonth = 31; - state->dataGlobal->HourOfDay = 24; + s_glob->HourOfDay = 24; state->dataEnvrn->DayOfWeek = 4; state->dataEnvrn->DayOfWeekTomorrow = 5; state->dataEnvrn->HolidayIndex = 0; - state->dataGlobal->TimeStep = 1; + s_glob->TimeStep = 1; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); state->dataEnvrn->DSTIndicator = 0; // DST IS OFF - ScheduleManager::UpdateScheduleValues(*state); - EXPECT_EQ(2.0, ScheduleManager::LookUpScheduleValue(*state, 1, state->dataGlobal->HourOfDay, state->dataGlobal->TimeStep)); - EXPECT_EQ(2.0, state->dataScheduleMgr->Schedule(1).CurrentValue); - EXPECT_EQ(2.0, ScheduleManager::GetCurrentScheduleValue(*state, 1)); + Sched::UpdateScheduleVals(*state); + EXPECT_EQ(2.0, sched->getHrTsVal(*state, s_glob->HourOfDay, s_glob->TimeStep)); + EXPECT_EQ(2.0, sched->currentVal); state->dataEnvrn->DSTIndicator = 1; // DST IS ON - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); // Since DST is on, you're actually on the next day, which in this specific case should be 1/1 at 0:15 // so it **should** return 1.0 - EXPECT_EQ(1.0, state->dataScheduleMgr->Schedule(1).CurrentValue); - EXPECT_EQ(1.0, ScheduleManager::GetCurrentScheduleValue(*state, 1)); - EXPECT_EQ(1.0, ScheduleManager::LookUpScheduleValue(*state, 1, state->dataGlobal->HourOfDay, state->dataGlobal->TimeStep)); + EXPECT_EQ(1.0, sched->currentVal); + EXPECT_EQ(1.0, sched->getHrTsVal(*state, s_glob->HourOfDay, s_glob->TimeStep)); } TEST_F(EnergyPlusFixture, Schedule_GetCurrentScheduleValue_DST_RampUp_Leap) { - + auto &s_sched = state->dataSched; + auto &s_glob = state->dataGlobal; // So here we'll mimic using a Schedule:Compact that ramps up constantly // Schedule:Compact, @@ -978,66 +995,60 @@ TEST_F(EnergyPlusFixture, Schedule_GetCurrentScheduleValue_DST_RampUp_Leap) state->dataWeather->LeapYearAdd = 1; int nDays = 366; - state->dataGlobal->NumOfTimeStepInHour = 4; - - state->dataScheduleMgr->ScheduleInputProcessed = true; - EXPECT_TRUE(state->dataScheduleMgr->ScheduleInputProcessed); - state->dataScheduleMgr->NumSchedules = 1; - state->dataScheduleMgr->Schedule.allocate(state->dataScheduleMgr->NumSchedules); - - state->dataScheduleMgr->Schedule(1).WeekSchedulePointer.allocate(nDays); - state->dataScheduleMgr->WeekSchedule.allocate(nDays); - state->dataScheduleMgr->DaySchedule.allocate(nDays); - - for (int ScheduleIndex = 1; ScheduleIndex <= state->dataScheduleMgr->NumSchedules; ScheduleIndex++) { - for (int day = 1; day <= nDays; ++day) { - // int DayOfWeek = ((day-1) % 7) + 1; - state->dataScheduleMgr->Schedule(ScheduleIndex).WeekSchedulePointer(day) = day; - state->dataScheduleMgr->WeekSchedule(day).DaySchedulePointer.allocate(7); - for (int d = 1; d <= 7; ++d) { - state->dataScheduleMgr->WeekSchedule(day).DaySchedulePointer(d) = day; - } - state->dataScheduleMgr->DaySchedule(day).TSValue.allocate(4, 24); - for (int whichHour = 1; whichHour <= 24; whichHour++) { - for (int TS = 1; TS <= state->dataGlobal->NumOfTimeStepInHour; ++TS) { - state->dataScheduleMgr->DaySchedule(day).TSValue(TS, whichHour) = whichHour + (day - 1) * 24; + s_glob->TimeStepsInHour = 4; + + auto *sched1 = Sched::AddScheduleDetailed(*state, "SCHED-1"); + + for (int i = 1; i <= 366; ++i) { + Sched::AddWeekSchedule(*state, format("WEEK_{}", i)); + Sched::AddDaySchedule(*state, format("DAY_{}", i)); + } + + for (int day = 1; day <= 366; ++day) { + // int DayOfWeek = ((day-1) % 7) + 1; + auto *weekSched = sched1->weekScheds[day] = Sched::GetWeekSchedule(*state, format("WEEK_{}", day)); + + for (int d = 1; d <= 7; ++d) { + auto *daySched = weekSched->dayScheds[d] = Sched::GetDaySchedule(*state, format("DAY_{}", day)); + + for (int hr = 0; hr < Constant::iHoursInDay; hr++) { + for (int ts = 0; ts < s_glob->TimeStepsInHour; ++ts) { + daySched->tsVals[hr * s_glob->TimeStepsInHour + ts] = (hr + 1) + (day - 1) * Constant::iHoursInDay; } } } } - EXPECT_EQ(366, state->dataScheduleMgr->Schedule(1).WeekSchedulePointer(366)); - EXPECT_EQ(366, state->dataScheduleMgr->WeekSchedule(366).DaySchedulePointer(2)); - EXPECT_EQ(8784.0, state->dataScheduleMgr->DaySchedule(366).TSValue(4, 24)); + EXPECT_EQ(365, sched1->weekScheds[366]->Num); + EXPECT_EQ(365, Sched::GetWeekSchedule(*state, format("WEEK_{}", 366))->dayScheds[2]->Num); + EXPECT_EQ(8784.0, Sched::GetDaySchedule(*state, format("DAY_{}", 366))->tsVals[23 * s_glob->TimeStepsInHour + 3]); - state->dataGlobal->NumOfTimeStepInHour = state->dataGlobal->NumOfTimeStepInHour; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 15; // must initialize this to get schedules initialized - state->dataGlobal->TimeStepZone = 0.25; - state->dataGlobal->TimeStepZoneSec = state->dataGlobal->TimeStepZone * Constant::SecInHour; + s_glob->TimeStepsInHour = s_glob->TimeStepsInHour; // must initialize this to get schedules initialized + s_glob->MinutesInTimeStep = 15; // must initialize this to get schedules initialized + s_glob->TimeStepZone = 0.25; + s_glob->TimeStepZoneSec = s_glob->TimeStepZone * Constant::rSecsInHour; state->dataEnvrn->Month = 12; state->dataEnvrn->DayOfMonth = 31; - state->dataGlobal->HourOfDay = 24; + s_glob->HourOfDay = 24; state->dataEnvrn->DayOfWeek = 2; state->dataEnvrn->DayOfWeekTomorrow = 3; state->dataEnvrn->HolidayIndex = 0; - state->dataGlobal->TimeStep = 1; + s_glob->TimeStep = 1; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); EXPECT_EQ(366, state->dataEnvrn->DayOfYear_Schedule); state->dataEnvrn->DSTIndicator = 0; // DST IS OFF - ScheduleManager::UpdateScheduleValues(*state); - EXPECT_EQ(8784.0, ScheduleManager::LookUpScheduleValue(*state, 1, state->dataGlobal->HourOfDay, state->dataGlobal->TimeStep)); - EXPECT_EQ(8784.0, state->dataScheduleMgr->Schedule(1).CurrentValue); - EXPECT_EQ(8784.0, ScheduleManager::GetCurrentScheduleValue(*state, 1)); + Sched::UpdateScheduleVals(*state); + EXPECT_EQ(8784.0, sched1->getHrTsVal(*state, s_glob->HourOfDay, s_glob->TimeStep)); + EXPECT_EQ(8784.0, sched1->currentVal); state->dataEnvrn->DSTIndicator = 1; // DST IS ON - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); // Since DST is on, you're actually on the next day, which in this specific case should be 1/1 at 0:15 // so it **should** return 1.0 - EXPECT_EQ(1.0, state->dataScheduleMgr->Schedule(1).CurrentValue); - EXPECT_EQ(1.0, ScheduleManager::GetCurrentScheduleValue(*state, 1)); - EXPECT_EQ(1.0, ScheduleManager::LookUpScheduleValue(*state, 1, state->dataGlobal->HourOfDay, state->dataGlobal->TimeStep)); + EXPECT_EQ(1.0, sched1->currentVal); + EXPECT_EQ(1.0, sched1->getHrTsVal(*state, s_glob->HourOfDay, s_glob->TimeStep)); Array1D_int EndDayOfMonth(12, {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}); @@ -1065,15 +1076,13 @@ TEST_F(EnergyPlusFixture, Schedule_GetCurrentScheduleValue_DST_RampUp_Leap) for (int hr = 1; hr <= 24; ++hr) { ++HourOfYear; - state->dataGlobal->HourOfDay = hr; + s_glob->HourOfDay = hr; for (int ts = 1; ts <= 4; ++ts) { - state->dataGlobal->TimeStep = ts; + s_glob->TimeStep = ts; - ScheduleManager::UpdateScheduleValues(*state); - EXPECT_EQ(HourOfYear, - ScheduleManager::LookUpScheduleValue(*state, 1, state->dataGlobal->HourOfDay, state->dataGlobal->TimeStep)); - EXPECT_EQ(HourOfYear, state->dataScheduleMgr->Schedule(1).CurrentValue); - EXPECT_EQ(HourOfYear, ScheduleManager::GetCurrentScheduleValue(*state, 1)); + Sched::UpdateScheduleVals(*state); + EXPECT_EQ(HourOfYear, sched1->getHrTsVal(*state, s_glob->HourOfDay, s_glob->TimeStep)); + EXPECT_EQ(HourOfYear, sched1->currentVal); } } } @@ -1105,19 +1114,17 @@ TEST_F(EnergyPlusFixture, Schedule_GetCurrentScheduleValue_DST_RampUp_Leap) for (int hr = 1; hr <= 24; ++hr) { ++HourOfYear; - state->dataGlobal->HourOfDay = hr; + s_glob->HourOfDay = hr; for (int ts = 1; ts <= 4; ++ts) { - state->dataGlobal->TimeStep = ts; + s_glob->TimeStep = ts; - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); int thisHourOfYear = HourOfYear + 1; if (thisHourOfYear > 8784.0) { thisHourOfYear = 1; } - EXPECT_EQ(thisHourOfYear, - ScheduleManager::LookUpScheduleValue(*state, 1, state->dataGlobal->HourOfDay, state->dataGlobal->TimeStep)); - EXPECT_EQ(thisHourOfYear, state->dataScheduleMgr->Schedule(1).CurrentValue); - EXPECT_EQ(thisHourOfYear, ScheduleManager::GetCurrentScheduleValue(*state, 1)); + EXPECT_EQ(thisHourOfYear, sched1->getHrTsVal(*state, s_glob->HourOfDay, s_glob->TimeStep)); + EXPECT_EQ(thisHourOfYear, sched1->currentVal); } } } @@ -1129,7 +1136,7 @@ TEST_F(EnergyPlusFixture, Schedule_GetCurrentScheduleValue_DST_RampUp_Leap) TEST_F(EnergyPlusFixture, Schedule_GetCurrentScheduleValue_DST_RampUp_NoLeap) { - + auto &s_glob = state->dataGlobal; // So here we'll mimic using a Schedule:Compact that ramps up constantly // Schedule:Compact, @@ -1162,17 +1169,12 @@ TEST_F(EnergyPlusFixture, Schedule_GetCurrentScheduleValue_DST_RampUp_NoLeap) // ScheduleManager always assume LeapYear really. int nDays = 365; - state->dataGlobal->NumOfTimeStepInHour = 4; + s_glob->TimeStepsInHour = 4; - state->dataScheduleMgr->ScheduleInputProcessed = true; - EXPECT_TRUE(state->dataScheduleMgr->ScheduleInputProcessed); - state->dataScheduleMgr->NumSchedules = 1; - state->dataScheduleMgr->Schedule.allocate(state->dataScheduleMgr->NumSchedules); + auto *sched1 = Sched::AddScheduleDetailed(*state, "SCHED-1"); - state->dataScheduleMgr->Schedule(1).WeekSchedulePointer.allocate(366); - state->dataScheduleMgr->Schedule(1).WeekSchedulePointer = -1; - state->dataScheduleMgr->WeekSchedule.allocate(366); - state->dataScheduleMgr->DaySchedule.allocate(nDays); // Here only creating 365 ScheduleDays + for (int i = 1; i <= 366; ++i) Sched::AddWeekSchedule(*state, format("WEEK_{}", i)); + for (int i = 1; i <= 365; ++i) Sched::AddDaySchedule(*state, format("DAY_{}", i)); Array1D_int EndDayOfMonth(12, {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}); @@ -1187,151 +1189,141 @@ TEST_F(EnergyPlusFixture, Schedule_GetCurrentScheduleValue_DST_RampUp_NoLeap) EXPECT_EQ(dayOfYear + 1, DayOfYear_Schedule); } - state->dataScheduleMgr->Schedule(1).WeekSchedulePointer(DayOfYear_Schedule) = DayOfYear_Schedule; - state->dataScheduleMgr->WeekSchedule(DayOfYear_Schedule).DaySchedulePointer.allocate(7); + auto *weekSched = sched1->weekScheds[DayOfYear_Schedule] = Sched::GetWeekSchedule(*state, format("WEEK_{}", DayOfYear_Schedule)); + auto *daySched = Sched::GetDaySchedule(*state, format("DAY_{}", dayOfYear)); for (int d = 1; d <= 7; ++d) { - state->dataScheduleMgr->WeekSchedule(DayOfYear_Schedule).DaySchedulePointer(d) = dayOfYear; + weekSched->dayScheds[d] = daySched; } - state->dataScheduleMgr->DaySchedule(dayOfYear).TSValue.allocate(4, 24); - for (int whichHour = 1; whichHour <= 24; whichHour++) { - for (int TS = 1; TS <= state->dataGlobal->NumOfTimeStepInHour; ++TS) { - state->dataScheduleMgr->DaySchedule(dayOfYear).TSValue(TS, whichHour) = whichHour + (dayOfYear - 1) * 24; + + for (int hr = 0; hr < Constant::iHoursInDay; hr++) { + for (int ts = 0; ts < s_glob->TimeStepsInHour; ++ts) { + daySched->tsVals[hr * s_glob->TimeStepsInHour + ts] = (hr + 1) + (dayOfYear - 1) * Constant::iHoursInDay; } } } } // Feb 28 - EXPECT_EQ(59, state->dataScheduleMgr->Schedule(1).WeekSchedulePointer(59)); - EXPECT_EQ(59, state->dataScheduleMgr->WeekSchedule(59).DaySchedulePointer(1)); - EXPECT_EQ(59 * 24.0, state->dataScheduleMgr->DaySchedule(59).TSValue(4, 24)); + EXPECT_EQ(58, sched1->weekScheds[59]->Num); + EXPECT_EQ(58, Sched::GetWeekSchedule(*state, "WEEK_59")->dayScheds[1]->Num); + EXPECT_EQ(59 * Constant::rHoursInDay, Sched::GetDaySchedule(*state, "DAY_59")->tsVals[23 * s_glob->TimeStepsInHour + 3]); // Feb 29: doesn't exist, and I default initialized everything above to -1 - EXPECT_EQ(-1, state->dataScheduleMgr->Schedule(1).WeekSchedulePointer(60)); + EXPECT_EQ(nullptr, sched1->weekScheds[60]); // ProcessSchedule would have treated the "Until: 3/1" to include the 2/29, so do that too. - state->dataScheduleMgr->Schedule(1).WeekSchedulePointer(60) = 61; + sched1->weekScheds[60] = Sched::GetWeekSchedule(*state, "WEEK_61"); // March 1 - EXPECT_EQ(61, state->dataScheduleMgr->Schedule(1).WeekSchedulePointer(61)); - EXPECT_EQ(60, state->dataScheduleMgr->WeekSchedule(61).DaySchedulePointer(1)); - EXPECT_EQ(60 * 24.0, state->dataScheduleMgr->DaySchedule(60).TSValue(4, 24)); + EXPECT_EQ(60, sched1->weekScheds[61]->Num); + EXPECT_EQ(59, sched1->weekScheds[61]->dayScheds[1]->Num); + EXPECT_EQ(60 * Constant::rHoursInDay, sched1->weekScheds[61]->dayScheds[1]->tsVals[23 * s_glob->TimeStepsInHour + 3]); - EXPECT_EQ(366, state->dataScheduleMgr->Schedule(1).WeekSchedulePointer(366)); - EXPECT_EQ(365, state->dataScheduleMgr->WeekSchedule(366).DaySchedulePointer(1)); - EXPECT_EQ(8760.0, state->dataScheduleMgr->DaySchedule(365).TSValue(4, 24)); + EXPECT_EQ(365, sched1->weekScheds[366]->Num); + EXPECT_EQ(364, sched1->weekScheds[366]->dayScheds[1]->Num); + EXPECT_EQ(8760.0, sched1->weekScheds[366]->dayScheds[1]->tsVals[23 * s_glob->TimeStepsInHour + 3]); - state->dataGlobal->NumOfTimeStepInHour = state->dataGlobal->NumOfTimeStepInHour; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 15; // must initialize this to get schedules initialized - state->dataGlobal->TimeStepZone = 0.25; - state->dataGlobal->TimeStepZoneSec = state->dataGlobal->TimeStepZone * Constant::SecInHour; + s_glob->TimeStepsInHour = s_glob->TimeStepsInHour; // must initialize this to get schedules initialized + s_glob->MinutesInTimeStep = 15; // must initialize this to get schedules initialized + s_glob->TimeStepZone = 0.25; + s_glob->TimeStepZoneSec = s_glob->TimeStepZone * Constant::rSecsInHour; state->dataEnvrn->Month = 12; state->dataEnvrn->DayOfMonth = 31; - state->dataGlobal->HourOfDay = 24; + s_glob->HourOfDay = 24; state->dataEnvrn->DayOfWeek = 1; state->dataEnvrn->DayOfWeekTomorrow = 2; state->dataEnvrn->HolidayIndex = 0; - state->dataGlobal->TimeStep = 1; + s_glob->TimeStep = 1; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); EXPECT_EQ(366, state->dataEnvrn->DayOfYear_Schedule); state->dataEnvrn->DSTIndicator = 0; // DST IS OFF - ScheduleManager::UpdateScheduleValues(*state); - EXPECT_EQ(8760.0, ScheduleManager::LookUpScheduleValue(*state, 1, state->dataGlobal->HourOfDay, state->dataGlobal->TimeStep)); - EXPECT_EQ(8760.0, state->dataScheduleMgr->Schedule(1).CurrentValue); - EXPECT_EQ(8760.0, ScheduleManager::GetCurrentScheduleValue(*state, 1)); + Sched::UpdateScheduleVals(*state); + EXPECT_EQ(8760.0, sched1->getHrTsVal(*state, s_glob->HourOfDay, s_glob->TimeStep)); + EXPECT_EQ(8760.0, sched1->currentVal); state->dataEnvrn->DSTIndicator = 1; // DST IS ON - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); // Since DST is on, you're actually on the next day, which in this specific case should be 1/1 at 0:15 // so it **should** return 1.0 - EXPECT_EQ(1.0, state->dataScheduleMgr->Schedule(1).CurrentValue); - EXPECT_EQ(1.0, ScheduleManager::GetCurrentScheduleValue(*state, 1)); - EXPECT_EQ(1.0, ScheduleManager::LookUpScheduleValue(*state, 1, state->dataGlobal->HourOfDay, state->dataGlobal->TimeStep)); - - { - state->dataEnvrn->DSTIndicator = 0; // DST IS OFF - state->dataEnvrn->DayOfWeek = 0; - state->dataEnvrn->DayOfWeekTomorrow = 1; - - Real64 HourOfYear = 0.0; - for (int month = 1; month <= 12; ++month) { - state->dataEnvrn->Month = month; - for (int day = 1; day <= EndDayOfMonth(month); ++day) { - state->dataEnvrn->DayOfMonth = day; - ++state->dataEnvrn->DayOfWeek; - if (state->dataEnvrn->DayOfWeek > 7) { - state->dataEnvrn->DayOfWeek = 1; - } - ++state->dataEnvrn->DayOfWeekTomorrow; - if (state->dataEnvrn->DayOfWeekTomorrow > 7) { - state->dataEnvrn->DayOfWeekTomorrow = 1; - } - - state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); + EXPECT_EQ(1.0, sched1->currentVal); + EXPECT_EQ(1.0, sched1->getHrTsVal(*state, s_glob->HourOfDay, s_glob->TimeStep)); - for (int hr = 1; hr <= 24; ++hr) { - ++HourOfYear; - state->dataGlobal->HourOfDay = hr; - for (int ts = 1; ts <= 4; ++ts) { - state->dataGlobal->TimeStep = ts; + state->dataEnvrn->DSTIndicator = 0; // DST IS OFF + state->dataEnvrn->DayOfWeek = 0; + state->dataEnvrn->DayOfWeekTomorrow = 1; + + Real64 HourOfYear = 0.0; + for (int month = 1; month <= 12; ++month) { + state->dataEnvrn->Month = month; + for (int day = 1; day <= EndDayOfMonth(month); ++day) { + state->dataEnvrn->DayOfMonth = day; + ++state->dataEnvrn->DayOfWeek; + if (state->dataEnvrn->DayOfWeek > 7) { + state->dataEnvrn->DayOfWeek = 1; + } + ++state->dataEnvrn->DayOfWeekTomorrow; + if (state->dataEnvrn->DayOfWeekTomorrow > 7) { + state->dataEnvrn->DayOfWeekTomorrow = 1; + } - ScheduleManager::UpdateScheduleValues(*state); - EXPECT_EQ(HourOfYear, - ScheduleManager::LookUpScheduleValue(*state, 1, state->dataGlobal->HourOfDay, state->dataGlobal->TimeStep)); - EXPECT_EQ(HourOfYear, state->dataScheduleMgr->Schedule(1).CurrentValue); - EXPECT_EQ(HourOfYear, ScheduleManager::GetCurrentScheduleValue(*state, 1)); - } + state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); + + for (int hr = 1; hr <= Constant::iHoursInDay; ++hr) { + ++HourOfYear; + s_glob->HourOfDay = hr; + for (int ts = 1; ts <= s_glob->TimeStepsInHour; ++ts) { + s_glob->TimeStep = ts; + + Sched::UpdateScheduleVals(*state); + EXPECT_EQ(HourOfYear, sched1->getHrTsVal(*state, s_glob->HourOfDay, s_glob->TimeStep)); + EXPECT_EQ(HourOfYear, sched1->currentVal); } } } - - EXPECT_EQ(8760.0, HourOfYear); } - - { - state->dataEnvrn->DSTIndicator = 1; // DST IS ON - state->dataEnvrn->DayOfWeek = 0; - state->dataEnvrn->DayOfWeekTomorrow = 1; - - Real64 HourOfYear = 0.0; - for (int month = 1; month <= 12; ++month) { - state->dataEnvrn->Month = month; - for (int day = 1; day <= EndDayOfMonth(month); ++day) { - state->dataEnvrn->DayOfMonth = day; - ++state->dataEnvrn->DayOfWeek; - if (state->dataEnvrn->DayOfWeek > 7) { - state->dataEnvrn->DayOfWeek = 1; - } - ++state->dataEnvrn->DayOfWeekTomorrow; - if (state->dataEnvrn->DayOfWeekTomorrow > 7) { - state->dataEnvrn->DayOfWeekTomorrow = 1; - } - - state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); - - for (int hr = 1; hr <= 24; ++hr) { - ++HourOfYear; - state->dataGlobal->HourOfDay = hr; - for (int ts = 1; ts <= 4; ++ts) { - state->dataGlobal->TimeStep = ts; - - ScheduleManager::UpdateScheduleValues(*state); - int thisHourOfYear = HourOfYear + 1; - if (thisHourOfYear > 8760.0) { - thisHourOfYear = 1; - } - EXPECT_EQ(thisHourOfYear, - ScheduleManager::LookUpScheduleValue(*state, 1, state->dataGlobal->HourOfDay, state->dataGlobal->TimeStep)); - EXPECT_EQ(thisHourOfYear, state->dataScheduleMgr->Schedule(1).CurrentValue); - EXPECT_EQ(thisHourOfYear, ScheduleManager::GetCurrentScheduleValue(*state, 1)); + + EXPECT_EQ(8760.0, HourOfYear); + + state->dataEnvrn->DSTIndicator = 1; // DST IS ON + state->dataEnvrn->DayOfWeek = 0; + state->dataEnvrn->DayOfWeekTomorrow = 1; + + HourOfYear = 0.0; + for (int month = 1; month <= 12; ++month) { + state->dataEnvrn->Month = month; + for (int day = 1; day <= EndDayOfMonth(month); ++day) { + state->dataEnvrn->DayOfMonth = day; + ++state->dataEnvrn->DayOfWeek; + if (state->dataEnvrn->DayOfWeek > 7) { + state->dataEnvrn->DayOfWeek = 1; + } + ++state->dataEnvrn->DayOfWeekTomorrow; + if (state->dataEnvrn->DayOfWeekTomorrow > 7) { + state->dataEnvrn->DayOfWeekTomorrow = 1; + } + + state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); + + for (int hr = 1; hr <= 24; ++hr) { + ++HourOfYear; + s_glob->HourOfDay = hr; + for (int ts = 1; ts <= 4; ++ts) { + s_glob->TimeStep = ts; + + Sched::UpdateScheduleVals(*state); + int thisHourOfYear = HourOfYear + 1; + if (thisHourOfYear > 8760.0) { + thisHourOfYear = 1; } + EXPECT_EQ(thisHourOfYear, sched1->getHrTsVal(*state, s_glob->HourOfDay, s_glob->TimeStep)); + EXPECT_EQ(thisHourOfYear, sched1->currentVal); } } } - - EXPECT_EQ(8760.0, HourOfYear); } + + EXPECT_EQ(8760.0, HourOfYear); } TEST_F(EnergyPlusFixture, ScheduleFileDSTtoggleOptionTest) @@ -1404,58 +1396,58 @@ TEST_F(EnergyPlusFixture, ScheduleFileDSTtoggleOptionTest) // This will process the provided idf chunk within the test fixture (must pass this step in order to proceed) ASSERT_TRUE(process_idf(idf_objects)); - state->dataGlobal->NumOfTimeStepInHour = 1; - state->dataGlobal->MinutesPerTimeStep = 60; - state->dataGlobal->TimeStep = 1; // Checking to see if omitting this is OK here + auto &s_glob = state->dataGlobal; + + s_glob->TimeStepsInHour = 1; + s_glob->MinutesInTimeStep = 60; + s_glob->TimeStep = 1; // Checking to see if omitting this is OK here + + state->init_state(*state); + state->dataEnvrn->DayOfWeek = 1; // Sunday state->dataEnvrn->DayOfWeekTomorrow = 2; // Monday state->dataEnvrn->DayOfYear_Schedule = 1; - state->dataGlobal->HourOfDay = 24; + s_glob->HourOfDay = 24; // Test 1 condition // "YES" Adjusts schedule for daylight savings - const int sch1idx = GetScheduleIndex(*state, "TEST1"); // Index of the IDF schedule object identified and stored into schdl1idx variable - ScheduleManager::ScheduleData &sch1 = - state->dataScheduleMgr->Schedule(sch1idx); // sch1 reference initialized that points to the specific schedule of interest - EXPECT_TRUE(sch1.UseDaylightSaving); // Checks that the member variable got set correctly. + auto const *sch1 = dynamic_cast(Sched::GetSchedule(*state, "TEST1")); + EXPECT_TRUE(sch1->UseDaylightSaving); // Checks that the member variable got set correctly. state->dataEnvrn->DSTIndicator = 1; // Tells the simulation that we're currently observing daylight savings - EXPECT_DOUBLE_EQ(ScheduleManager::LookUpScheduleValue(*state, sch1idx, state->dataGlobal->HourOfDay, state->dataGlobal->TimeStep), 0.0); + EXPECT_DOUBLE_EQ(sch1->getHrTsVal(*state, s_glob->HourOfDay, s_glob->TimeStep), 0.0); state->dataEnvrn->DSTIndicator = 0; // Tells the simulation that we're NOT currently observing daylight savings - EXPECT_DOUBLE_EQ(ScheduleManager::LookUpScheduleValue(*state, sch1idx, state->dataGlobal->HourOfDay, state->dataGlobal->TimeStep), 1.0); + EXPECT_DOUBLE_EQ(sch1->getHrTsVal(*state, s_glob->HourOfDay, s_glob->TimeStep), 1.0); // Test 2 condition // "NO" Does not adjust for daylight savings - const int sch2idx = GetScheduleIndex(*state, "TEST2"); - ScheduleManager::ScheduleData &sch2 = state->dataScheduleMgr->Schedule(sch2idx); - EXPECT_FALSE(sch2.UseDaylightSaving); + auto const *sch2 = dynamic_cast(Sched::GetSchedule(*state, "TEST2")); + EXPECT_FALSE(sch2->UseDaylightSaving); state->dataEnvrn->DSTIndicator = 1; // Tells the simulation that we're currently observing daylight savings - EXPECT_DOUBLE_EQ(ScheduleManager::LookUpScheduleValue(*state, sch2idx, state->dataGlobal->HourOfDay, state->dataGlobal->TimeStep), 1.0); + EXPECT_DOUBLE_EQ(sch2->getHrTsVal(*state, s_glob->HourOfDay, s_glob->TimeStep), 1.0); state->dataEnvrn->DSTIndicator = 0; // Tells the simulation that we're NOT currently observing daylight savings - EXPECT_DOUBLE_EQ(ScheduleManager::LookUpScheduleValue(*state, sch2idx, state->dataGlobal->HourOfDay, state->dataGlobal->TimeStep), 1.0); + EXPECT_DOUBLE_EQ(sch2->getHrTsVal(*state, s_glob->HourOfDay, s_glob->TimeStep), 1.0); // Test 3 condition // Default: "YES", changes schedule for daylight savings - const int sch3idx = GetScheduleIndex(*state, "TEST3"); - ScheduleManager::ScheduleData &sch3 = state->dataScheduleMgr->Schedule(sch3idx); - EXPECT_TRUE(sch3.UseDaylightSaving); + auto const *sch3 = dynamic_cast(Sched::GetSchedule(*state, "TEST3")); + EXPECT_TRUE(sch3->UseDaylightSaving); state->dataEnvrn->DSTIndicator = 1; // Tells the simulation that we're currently observing daylight savings - EXPECT_DOUBLE_EQ(ScheduleManager::LookUpScheduleValue(*state, sch3idx, state->dataGlobal->HourOfDay, state->dataGlobal->TimeStep), 0.0); + EXPECT_DOUBLE_EQ(sch3->getHrTsVal(*state, s_glob->HourOfDay, s_glob->TimeStep), 0.0); state->dataEnvrn->DSTIndicator = 0; // Tells the simulation that we're NOT currently observing daylight savings - EXPECT_DOUBLE_EQ(ScheduleManager::LookUpScheduleValue(*state, sch3idx, state->dataGlobal->HourOfDay, state->dataGlobal->TimeStep), 1.0); + EXPECT_DOUBLE_EQ(sch3->getHrTsVal(*state, s_glob->HourOfDay, s_glob->TimeStep), 1.0); // Test 4 condition // Default: "YES", changes schedule for daylight savings - const int sch4idx = GetScheduleIndex(*state, "TEST4"); // Index of the IDF schedule object identified - ScheduleManager::ScheduleData &sch4 = state->dataScheduleMgr->Schedule(sch4idx); // sch1 object initialized of type ScheduleData - EXPECT_TRUE(sch4.UseDaylightSaving); // Checks that the member variable got set correctly. + auto const *sch4 = dynamic_cast(Sched::GetSchedule(*state, "TEST4")); + EXPECT_TRUE(sch4->UseDaylightSaving); // Checks that the member variable got set correctly. state->dataEnvrn->DSTIndicator = 1; // Tells the simulation that we're currently observing daylight savings - EXPECT_DOUBLE_EQ(ScheduleManager::LookUpScheduleValue(*state, sch4idx, state->dataGlobal->HourOfDay, state->dataGlobal->TimeStep), 0.0); + EXPECT_DOUBLE_EQ(sch4->getHrTsVal(*state, s_glob->HourOfDay, s_glob->TimeStep), 0.0); state->dataEnvrn->DSTIndicator = 0; // Tells the simulation that we're NOT currently observing daylight savings - EXPECT_DOUBLE_EQ(ScheduleManager::LookUpScheduleValue(*state, sch4idx, state->dataGlobal->HourOfDay, state->dataGlobal->TimeStep), 1.0); + EXPECT_DOUBLE_EQ(sch4->getHrTsVal(*state, s_glob->HourOfDay, s_glob->TimeStep), 1.0); } TEST_F(EnergyPlusFixture, ScheduleFile_Blanks) @@ -1479,15 +1471,20 @@ TEST_F(EnergyPlusFixture, ScheduleFile_Blanks) }); ASSERT_TRUE(process_idf(idf_objects)); - state->dataGlobal->NumOfTimeStepInHour = 4; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 15; // must initialize this to get schedules initialized - state->dataGlobal->TimeStepZone = 0.25; - state->dataGlobal->TimeStepZoneSec = state->dataGlobal->TimeStepZone * Constant::SecInHour; + auto &s_glob = state->dataGlobal; + + s_glob->TimeStepsInHour = 4; // must initialize this to get schedules initialized + s_glob->MinutesInTimeStep = 15; // must initialize this to get schedules initialized + s_glob->TimeStepZone = 0.25; + s_glob->TimeStepZoneSec = s_glob->TimeStepZone * Constant::rSecsInHour; state->dataEnvrn->CurrentYearIsLeapYear = false; - ASSERT_THROW(ScheduleManager::ProcessScheduleInput(*state), EnergyPlus::FatalError); // read schedules + ASSERT_THROW(state->init_state(*state), EnergyPlus::FatalError); // read schedules const std::string expected_error = delimited_string({ + " ** Warning ** ProcessScheduleInput: Schedule:File = TEST1", + " ** ~~~ ** Schedule Type Limits Name is empty.", + " ** ~~~ ** Schedule will not be validated.", " ** Severe ** CsvParser - Line 3 - Expected 3 columns, got 2. Error in following line.", " ** ~~~ ** 1,,0.33", " ** ~~~ ** Error Occurred in " + scheduleFile.string(), @@ -1512,15 +1509,17 @@ TEST_F(EnergyPlusFixture, ShadowCalculation_CSV_extra_parenthesis) }); ASSERT_TRUE(process_idf(idf_objects)); - state->dataGlobal->NumOfTimeStepInHour = 4; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 15; // must initialize this to get schedules initialized - state->dataGlobal->TimeStepZone = 0.25; - state->dataGlobal->TimeStepZoneSec = state->dataGlobal->TimeStepZone * Constant::SecInHour; + auto &s_glob = state->dataGlobal; + auto &s_sched = state->dataSched; + + s_glob->TimeStepsInHour = 4; // must initialize this to get schedules initialized + s_glob->MinutesInTimeStep = 15; // must initialize this to get schedules initialized + s_glob->TimeStepZone = 0.25; + s_glob->TimeStepZoneSec = s_glob->TimeStepZone * Constant::rSecsInHour; + state->init_state(*state); + state->dataEnvrn->CurrentYearIsLeapYear = false; - EXPECT_FALSE(state->dataScheduleMgr->ScheduleFileShadingProcessed); - ScheduleManager::ProcessScheduleInput(*state); // read schedules - const std::string expected_error = delimited_string({ " ** Warning ** ProcessScheduleInput: Schedule:File:Shading=\"" + scheduleFile.string() + "\" Removing last column of the CSV since it has '()' for the surface name.", @@ -1528,13 +1527,13 @@ TEST_F(EnergyPlusFixture, ShadowCalculation_CSV_extra_parenthesis) }); compare_err_stream(expected_error); - EXPECT_TRUE(state->dataScheduleMgr->ScheduleFileShadingProcessed); - EXPECT_EQ(1, state->dataScheduleMgr->NumSchedules); - EXPECT_EQ(366, state->dataScheduleMgr->NumWeekSchedules); - EXPECT_EQ(366, state->dataScheduleMgr->NumDaySchedules); - EXPECT_EQ(1, state->dataScheduleMgr->UniqueProcessedExternalFiles.size()); + EXPECT_TRUE(s_sched->ScheduleFileShadingProcessed); + EXPECT_EQ(3, s_sched->schedules.size()); // AlwaysOn, AlwaysOff, plus file + EXPECT_EQ(365, s_sched->weekSchedules.size()); + EXPECT_EQ(365, s_sched->daySchedules.size()); + EXPECT_EQ(1, s_sched->UniqueProcessedExternalFiles.size()); - auto &[fPath, root] = *(state->dataScheduleMgr->UniqueProcessedExternalFiles.begin()); + auto &[fPath, root] = *(s_sched->UniqueProcessedExternalFiles.begin()); EXPECT_EQ(scheduleFile, fPath); EXPECT_EQ(2, root["header"].size()); const std::set expectedHeaders{"Surface Name", "EAST SIDE TREE"}; @@ -1553,31 +1552,32 @@ TEST_F(EnergyPlusFixture, ShadowCalculation_CSV_extra_parenthesis) EXPECT_EQ("12/31 24:00", root["values"].at(0).at(8760 * 4 - 1).get()); EXPECT_EQ(0.00000000, root["values"].at(1).at(8760 * 4 - 1).get()); - std::string curName = "EAST SIDE TREE_shading"; - EXPECT_EQ("EAST SIDE TREE_shading_wk_1", state->dataScheduleMgr->WeekSchedule(1).Name); - EXPECT_EQ("EAST SIDE TREE_shading_wk_59", state->dataScheduleMgr->WeekSchedule(59).Name); - EXPECT_EQ("EAST SIDE TREE_shading_wk_61", state->dataScheduleMgr->WeekSchedule(60).Name); - EXPECT_EQ("EAST SIDE TREE_shading_wk_62", state->dataScheduleMgr->WeekSchedule(61).Name); - EXPECT_EQ("EAST SIDE TREE_shading_wk_366", state->dataScheduleMgr->WeekSchedule(365).Name); - - EXPECT_EQ("EAST SIDE TREE_shading_dy_1", state->dataScheduleMgr->DaySchedule(1).Name); - EXPECT_EQ("EAST SIDE TREE_shading_dy_59", state->dataScheduleMgr->DaySchedule(59).Name); - EXPECT_EQ("EAST SIDE TREE_shading_dy_61", state->dataScheduleMgr->DaySchedule(60).Name); - EXPECT_EQ("EAST SIDE TREE_shading_dy_62", state->dataScheduleMgr->DaySchedule(61).Name); - EXPECT_EQ("EAST SIDE TREE_shading_dy_366", state->dataScheduleMgr->DaySchedule(365).Name); - - EXPECT_EQ(1, state->dataScheduleMgr->Schedule(1).WeekSchedulePointer(1)); - EXPECT_EQ(59, state->dataScheduleMgr->Schedule(1).WeekSchedulePointer(59)); - EXPECT_EQ(59, state->dataScheduleMgr->Schedule(1).WeekSchedulePointer(60)); // 29 Feb points to 28 Feb - EXPECT_EQ(365, state->dataScheduleMgr->Schedule(1).WeekSchedulePointer(366)); - - for (int iDay = 1; iDay <= 365; ++iDay) { - if (iDay <= 59) { - EXPECT_EQ(fmt::format("{}_wk_{}", curName, iDay), state->dataScheduleMgr->WeekSchedule(iDay).Name); - EXPECT_EQ(fmt::format("{}_dy_{}", curName, iDay), state->dataScheduleMgr->DaySchedule(iDay).Name); + EXPECT_EQ(Sched::GetWeekScheduleNum(*state, "EAST SIDE TREE_SHADING_WK_1"), 0); + EXPECT_EQ(Sched::GetWeekScheduleNum(*state, "EAST SIDE TREE_SHADING_WK_59"), 58); + EXPECT_EQ(Sched::GetWeekScheduleNum(*state, "EAST SIDE TREE_SHADING_WK_61"), 59); + EXPECT_EQ(Sched::GetWeekScheduleNum(*state, "EAST SIDE TREE_SHADING_WK_62"), 60); + EXPECT_EQ(Sched::GetWeekScheduleNum(*state, "EAST SIDE TREE_SHADING_WK_366"), 364); + + EXPECT_EQ(Sched::GetDayScheduleNum(*state, "EAST SIDE TREE_SHADING_DY_1"), 0); + EXPECT_EQ(Sched::GetDayScheduleNum(*state, "EAST SIDE TREE_SHADING_DY_59"), 58); + EXPECT_EQ(Sched::GetDayScheduleNum(*state, "EAST SIDE TREE_SHADING_DY_61"), 59); + EXPECT_EQ(Sched::GetDayScheduleNum(*state, "EAST SIDE TREE_SHADING_DY_62"), 60); + EXPECT_EQ(Sched::GetDayScheduleNum(*state, "EAST SIDE TREE_SHADING_DY_366"), 364); + + auto const *sched = dynamic_cast(Sched::GetSchedule(*state, "EAST SIDE TREE_SHADING")); + + EXPECT_EQ(0, sched->weekScheds[1]->Num); + EXPECT_EQ(58, sched->weekScheds[59]->Num); + EXPECT_EQ(58, sched->weekScheds[60]->Num); // 29 Feb points to 28 Feb + EXPECT_EQ(364, sched->weekScheds[366]->Num); + + for (int iDay = 0; iDay < 365; ++iDay) { + if (iDay <= 58) { + EXPECT_EQ(fmt::format("EAST SIDE TREE_shading_wk_{}", iDay+1), s_sched->weekSchedules[iDay]->Name); + EXPECT_EQ(fmt::format("EAST SIDE TREE_shading_dy_{}", iDay+1), s_sched->daySchedules[iDay]->Name); } else { - EXPECT_EQ(fmt::format("{}_wk_{}", curName, iDay + 1), state->dataScheduleMgr->WeekSchedule(iDay).Name); - EXPECT_EQ(fmt::format("{}_dy_{}", curName, iDay + 1), state->dataScheduleMgr->DaySchedule(iDay).Name); + EXPECT_EQ(fmt::format("EAST SIDE TREE_shading_wk_{}", iDay+2), s_sched->weekSchedules[iDay]->Name); + EXPECT_EQ(fmt::format("EAST SIDE TREE_shading_dy_{}", iDay+2), s_sched->daySchedules[iDay]->Name); } } @@ -1585,25 +1585,25 @@ TEST_F(EnergyPlusFixture, ShadowCalculation_CSV_extra_parenthesis) int iDay = 1; int TS = 1; int iHour = 1; - EXPECT_EQ(0.00000000, state->dataScheduleMgr->DaySchedule(iDay).TSValue(TS, iHour)); + EXPECT_EQ(0.00000000, s_sched->daySchedules[(iDay - 1)]->tsVals[(iHour - 1) * s_glob->TimeStepsInHour + (TS - 1)]); // 01/01 13:00 iDay = 1; TS = 4; iHour = 13; - EXPECT_EQ(0.96107882, state->dataScheduleMgr->DaySchedule(iDay).TSValue(TS, iHour)); + EXPECT_EQ(0.96107882, s_sched->daySchedules[(iDay - 1)]->tsVals[(iHour - 1) * s_glob->TimeStepsInHour + (TS - 1)]); // 12/31 16:15,0.19556231, iDay = 365; TS = 1; iHour = 17; - EXPECT_EQ(0.19556231, state->dataScheduleMgr->DaySchedule(iDay).TSValue(TS, iHour)); + EXPECT_EQ(0.19556231, s_sched->daySchedules[(iDay - 1)]->tsVals[(iHour - 1) * s_glob->TimeStepsInHour + (TS - 1)]); // 12/31 24:00 iDay = 365; TS = 4; iHour = 24; - EXPECT_EQ(0.00000000, state->dataScheduleMgr->DaySchedule(iDay).TSValue(TS, iHour)); + EXPECT_EQ(0.00000000, s_sched->daySchedules[(iDay - 1)]->tsVals[(iHour - 1) * s_glob->TimeStepsInHour + (TS - 1)]); } TEST_F(EnergyPlusFixture, getScheduleMinMaxByDayType_test) @@ -1667,59 +1667,63 @@ TEST_F(EnergyPlusFixture, getScheduleMinMaxByDayType_test) ASSERT_TRUE(process_idf(idf_objects)); - state->dataGlobal->NumOfTimeStepInHour = 4; - state->dataGlobal->MinutesPerTimeStep = 15; - state->dataGlobal->TimeStepZone = 0.25; + auto &s_glob = state->dataGlobal; + + s_glob->TimeStepsInHour = 4; + s_glob->MinutesInTimeStep = 15; + s_glob->TimeStepZone = 0.25; + state->init_state(*state); + Real64 schMin; Real64 schMax; - std::tie(schMin, schMax) = getScheduleMinMaxByDayType(*state, -1, DayTypeGroup::Weekday); + std::tie(schMin, schMax) = Sched::GetScheduleAlwaysOn(*state)->getMinMaxValsByDayType(*state, Sched::DayTypeGroup::Weekday); EXPECT_EQ(1.0, schMin); EXPECT_EQ(1.0, schMax); - std::tie(schMin, schMax) = getScheduleMinMaxByDayType(*state, 0, DayTypeGroup::Weekday); + std::tie(schMin, schMax) = Sched::GetScheduleAlwaysOff(*state)->getMinMaxValsByDayType(*state, Sched::DayTypeGroup::Weekday); EXPECT_EQ(0.0, schMin); EXPECT_EQ(0.0, schMax); - int index = GetScheduleIndex(*state, "HIGHLOW01"); + auto *sched = Sched::GetSchedule(*state, "HIGHLOW01"); - std::tie(schMin, schMax) = getScheduleMinMaxByDayType(*state, index, DayTypeGroup::Weekday); + std::tie(schMin, schMax) = sched->getMinMaxValsByDayType(*state, Sched::DayTypeGroup::Weekday); EXPECT_EQ(0.40, schMin); EXPECT_EQ(0.87, schMax); // repeat test to see if using cached values - std::tie(schMin, schMax) = getScheduleMinMaxByDayType(*state, index, DayTypeGroup::Weekday); + std::tie(schMin, schMax) = sched->getMinMaxValsByDayType(*state, Sched::DayTypeGroup::Weekday); EXPECT_EQ(0.40, schMin); EXPECT_EQ(0.87, schMax); - std::tie(schMin, schMax) = getScheduleMinMaxByDayType(*state, index, DayTypeGroup::WeekEndHoliday); + std::tie(schMin, schMax) = sched->getMinMaxValsByDayType(*state, Sched::DayTypeGroup::WeekEndHoliday); EXPECT_EQ(0.30, schMin); EXPECT_EQ(0.83, schMax); - std::tie(schMin, schMax) = getScheduleMinMaxByDayType(*state, index, DayTypeGroup::SummerDesignDay); + std::tie(schMin, schMax) = sched->getMinMaxValsByDayType(*state, Sched::DayTypeGroup::SummerDesignDay); EXPECT_EQ(0.85, schMin); EXPECT_EQ(0.95, schMax); - std::tie(schMin, schMax) = getScheduleMinMaxByDayType(*state, index, DayTypeGroup::WinterDesignDay); + std::tie(schMin, schMax) = sched->getMinMaxValsByDayType(*state, Sched::DayTypeGroup::WinterDesignDay); EXPECT_EQ(0.15, schMin); EXPECT_EQ(0.17, schMax); - index = GetScheduleIndex(*state, "HIGHLOW02"); + sched = Sched::GetSchedule(*state, "HIGHLOW02"); - std::tie(schMin, schMax) = getScheduleMinMaxByDayType(*state, index, DayTypeGroup::Weekday); + std::tie(schMin, schMax) = sched->getMinMaxValsByDayType(*state, Sched::DayTypeGroup::Weekday); EXPECT_EQ(0.21, schMin); EXPECT_EQ(0.73, schMax); - std::tie(schMin, schMax) = getScheduleMinMaxByDayType(*state, index, DayTypeGroup::WeekEndHoliday); + std::tie(schMin, schMax) = sched->getMinMaxValsByDayType(*state, Sched::DayTypeGroup::WeekEndHoliday); EXPECT_EQ(0.27, schMin); EXPECT_EQ(0.65, schMax); - std::tie(schMin, schMax) = getScheduleMinMaxByDayType(*state, index, DayTypeGroup::SummerDesignDay); + std::tie(schMin, schMax) = sched->getMinMaxValsByDayType(*state, Sched::DayTypeGroup::SummerDesignDay); EXPECT_EQ(0.76, schMin); EXPECT_EQ(0.85, schMax); - std::tie(schMin, schMax) = getScheduleMinMaxByDayType(*state, index, DayTypeGroup::WinterDesignDay); + std::tie(schMin, schMax) = sched->getMinMaxValsByDayType(*state, Sched::DayTypeGroup::WinterDesignDay); EXPECT_EQ(0.16, schMin); EXPECT_EQ(0.25, schMax); } diff --git a/tst/EnergyPlus/unit/SecondaryDXCoils.unit.cc b/tst/EnergyPlus/unit/SecondaryDXCoils.unit.cc index 0d1be41fe0d..09a54737c09 100644 --- a/tst/EnergyPlus/unit/SecondaryDXCoils.unit.cc +++ b/tst/EnergyPlus/unit/SecondaryDXCoils.unit.cc @@ -67,7 +67,6 @@ using namespace EnergyPlus; using namespace DXCoils; -using Psychrometrics::InitializePsychRoutines; using Psychrometrics::PsyHFnTdbW; using Psychrometrics::PsyRhoAirFnPbTdbW; using Psychrometrics::PsyTwbFnTdbWPb; @@ -143,6 +142,7 @@ TEST_F(EnergyPlusFixture, SecondaryDXCoolingCoilMultiSpeed_Test3) TEST_F(EnergyPlusFixture, SecondaryDXHeatingCoilSingleSpeed_Test4) { // tests secondary DX coil calculation of single speed heat pump + state->init_state(*state); int DXCoilNum; state->dataDXCoils->NumDXCoils = 1; @@ -169,7 +169,6 @@ TEST_F(EnergyPlusFixture, SecondaryDXHeatingCoilSingleSpeed_Test4) state->dataEnvrn->OutBaroPress = 101325.0; state->dataDXCoils->DXCoil(DXCoilNum).AirInNode = 2; state->dataLoopNodes->Node(state->dataDXCoils->DXCoil(DXCoilNum).AirInNode).Temp = 20.0; - InitializePsychRoutines(*state); CalcSecondaryDXCoils(*state, DXCoilNum); EXPECT_DOUBLE_EQ(-5000.0, state->dataDXCoils->DXCoil(DXCoilNum).SecCoilTotalHeatRemovalRate); @@ -214,10 +213,12 @@ TEST_F(EnergyPlusFixture, SecondaryDXHeatingCoilSingleSpeed_Test4) state->dataDXCoils->DXCoil.deallocate(); state->dataLoopNodes->Node.deallocate(); } + TEST_F(EnergyPlusFixture, SecondaryDXHeatingCoilMultiSpeed_Test5) { - // tests secondary DX coil calculation of multi speed heat pump + state->init_state(*state); + int DXCoilNum; state->dataDXCoils->NumDXCoils = 1; @@ -260,7 +261,6 @@ TEST_F(EnergyPlusFixture, SecondaryDXHeatingCoilMultiSpeed_Test5) state->dataEnvrn->OutBaroPress = 101325.0; state->dataDXCoils->DXCoil(DXCoilNum).AirInNode = 2; state->dataLoopNodes->Node(state->dataDXCoils->DXCoil(DXCoilNum).AirInNode).Temp = 20.0; - InitializePsychRoutines(*state); CalcSecondaryDXCoils(*state, DXCoilNum); EXPECT_DOUBLE_EQ(-5000.0, state->dataDXCoils->DXCoil(DXCoilNum).SecCoilTotalHeatRemovalRate); diff --git a/tst/EnergyPlus/unit/SetPointManager.unit.cc b/tst/EnergyPlus/unit/SetPointManager.unit.cc index b2786517313..43bb88cf1c9 100644 --- a/tst/EnergyPlus/unit/SetPointManager.unit.cc +++ b/tst/EnergyPlus/unit/SetPointManager.unit.cc @@ -189,6 +189,8 @@ TEST_F(EnergyPlusFixture, SetPointManager_DefineReturnWaterChWSetPointManager_Fl ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + EXPECT_EQ(2, state->dataFluidProps->glycols.isize()); const auto *glycol = state->dataFluidProps->glycols(2); EXPECT_EQ("ETHYLENEGLYCOL40PERCENT", glycol->Name); @@ -407,14 +409,15 @@ TEST_F(EnergyPlusFixture, SetPointManager_DefineCondEntSetPointManager) "For: AllDays, !- Field 2", "Until: 24:00,30.0; !- Field 3"}); ASSERT_TRUE(process_idf(idf_objects)); - state->dataGlobal->NumOfTimeStepInHour = 4; - state->dataGlobal->MinutesPerTimeStep = 60 / state->dataGlobal->NumOfTimeStepInHour; - ScheduleManager::ProcessScheduleInput(*state); + state->dataGlobal->TimeStepsInHour = 4; + state->dataGlobal->MinutesInTimeStep = 60 / state->dataGlobal->TimeStepsInHour; + state->init_state(*state); + state->dataGlobal->TimeStep = 1; state->dataGlobal->HourOfDay = 1; state->dataEnvrn->DayOfWeek = 1; state->dataEnvrn->DayOfYear_Schedule = 1; - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); // a few constants for convenience int constexpr evapOutletNodeNum = 1; @@ -465,7 +468,7 @@ TEST_F(EnergyPlusFixture, SetPointManager_DefineCondEntSetPointManager) thisSPM.minTowerDesignWetBulbCurveNum = Curve::GetCurveIndex(*state, "MINDSNWBCURVENAME"); thisSPM.minOAWetBulbCurveNum = Curve::GetCurveIndex(*state, "MINACTWBCURVENAME"); thisSPM.optCondenserEnteringTempCurveNum = Curve::GetCurveIndex(*state, "OPTCONDENTCURVENAME"); - thisSPM.condenserEnteringTempSchedNum = ScheduleManager::GetScheduleIndex(*state, "CONDENSER LOOP TEMP SCHEDULE"); + thisSPM.condenserEnteringTempSched = Sched::GetSchedule(*state, "CONDENSER LOOP TEMP SCHEDULE"); thisSPM.plantPloc = {chwLoopIndex, DataPlant::LoopSideLocation::Supply, chillerBranchChW, chillerCompIndex}; thisSPM.demandPloc = {condLoopIndex, DataPlant::LoopSideLocation::Demand, chillerBranchCW, chillerCompIndex}; @@ -611,40 +614,35 @@ TEST_F(EnergyPlusFixture, CalcScheduledTESSetPoint) spmTESS.nonChargeCHWTemp = 5; spmTESS.chargeCHWTemp = -5; - // indexes in Schedule - int constexpr OnSched = 1; - int constexpr OffSched = 2; - std::string const idf_contents(delimited_string({ - "Schedule:Constant,MyScheduleOn,,1;", - "Schedule:Constant,MyScheduleOff,,0;", - })); - ASSERT_TRUE(process_idf(idf_contents)); - state->dataGlobal->NumOfTimeStepInHour = 4; - state->dataGlobal->MinutesPerTimeStep = 60 / state->dataGlobal->NumOfTimeStepInHour; - ScheduleManager::ProcessScheduleInput(*state); + state->dataGlobal->TimeStepsInHour = 4; + state->dataGlobal->MinutesInTimeStep = 60 / state->dataGlobal->TimeStepsInHour; + + state->init_state(*state); + state->dataGlobal->TimeStep = 1; state->dataGlobal->HourOfDay = 1; state->dataEnvrn->DayOfWeek = 1; state->dataEnvrn->DayOfYear_Schedule = 1; - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); // CtrlType Bug // state->dataSetPointManager->SchTESSetPtMgr(schManNum).CompOpType = DataPlant::CtrlType::CoolingOp; spmTESS.compOpType = DataPlant::CtrlType::HeatingOp; - spmTESS.schedNum = OnSched; + spmTESS.sched = Sched::GetScheduleAlwaysOn(*state); + spmTESS.chargeSched = Sched::GetScheduleAlwaysOff(*state); spmTESS.calculate(*state); EXPECT_EQ(spmTESS.nonChargeCHWTemp, spmTESS.setPt); - spmTESS.schedNum = OffSched; - spmTESS.schedNumCharge = OffSched; + spmTESS.sched = Sched::GetScheduleAlwaysOff(*state); + spmTESS.chargeSched = Sched::GetScheduleAlwaysOff(*state); spmTESS.calculate(*state); EXPECT_EQ(spmTESS.nonChargeCHWTemp, spmTESS.setPt); - spmTESS.schedNum = OffSched; - spmTESS.schedNumCharge = OnSched; + spmTESS.sched = Sched::GetScheduleAlwaysOff(*state); + spmTESS.chargeSched = Sched::GetScheduleAlwaysOn(*state); spmTESS.calculate(*state); EXPECT_EQ(spmTESS.chargeCHWTemp, spmTESS.setPt); @@ -673,6 +671,9 @@ TEST_F(EnergyPlusFixture, SZRHOAFractionImpact) }); ASSERT_TRUE(process_idf(idf_objects)); + + state->init_state(*state); + bool ErrorsFound = false; state->dataGlobal->NumOfZones = 1; @@ -972,6 +973,8 @@ TEST_F(EnergyPlusFixture, MixedAirSetPointManager_SameRefAndSPNodeName) ASSERT_TRUE(process_idf(idf_objects)); // read idf objects + state->init_state(*state); + // GetInput should fail since reference and set point node names are the same bool ErrorsFound = false; SetPointManager::GetSetPointManagerInputData(*state, ErrorsFound); @@ -1286,9 +1289,10 @@ TEST_F(EnergyPlusFixture, ColdestSetPointMgrInSingleDuct) ASSERT_TRUE(process_idf(idf_objects)); bool ErrorsFound = false; - state->dataGlobal->NumOfTimeStepInHour = 1; - state->dataGlobal->MinutesPerTimeStep = 60; - ScheduleManager::ProcessScheduleInput(*state); + state->dataGlobal->TimeStepsInHour = 1; + state->dataGlobal->MinutesInTimeStep = 60; + + state->init_state(*state); HeatBalanceManager::GetZoneData(*state, ErrorsFound); // read zone data EXPECT_FALSE(ErrorsFound); // zones are specified in the idf snippet @@ -1374,6 +1378,8 @@ TEST_F(EnergyPlusFixture, SetPointManager_OutdoorAirResetMaxTempTest) ASSERT_TRUE(process_idf(idf_objects)); EXPECT_FALSE(ErrorsFound); // zones are specified in the idf snippet + state->init_state(*state); + SetPointManager::GetSetPointManagerInputs(*state); // check Set Point Manager get inputs int spmNum = SetPointManager::GetSetPointManagerIndex(*state, "HOT WATER LOOP SETPOINT MANAGER"); @@ -1433,6 +1439,8 @@ TEST_F(EnergyPlusFixture, SetPointManager_OutdoorAirResetMinTempTest) ASSERT_TRUE(process_idf(idf_objects)); EXPECT_FALSE(ErrorsFound); // zones are specified in the idf snippet + state->init_state(*state); + SetPointManager::GetSetPointManagerInputs(*state); // check Set Point Manager get inputs @@ -1490,6 +1498,9 @@ TEST_F(EnergyPlusFixture, SingZoneRhSetPtMgrZoneInletNodeTest) }); ASSERT_TRUE(process_idf(idf_objects)); + + state->init_state(*state); + state->dataGlobal->NumOfZones = 1; state->dataHeatBal->Zone.allocate(state->dataGlobal->NumOfZones); @@ -1557,6 +1568,9 @@ TEST_F(EnergyPlusFixture, SingZoneCoolHeatSetPtMgrZoneInletNodeTest) }); ASSERT_TRUE(process_idf(idf_objects)); + + state->init_state(*state); + state->dataGlobal->NumOfZones = 1; state->dataHeatBal->Zone.allocate(state->dataGlobal->NumOfZones); @@ -1625,6 +1639,9 @@ TEST_F(EnergyPlusFixture, SingZoneCoolHeatSetPtMgrSetPtTest) }); ASSERT_TRUE(process_idf(idf_objects)); + + state->init_state(*state); + state->dataGlobal->NumOfZones = 1; state->dataHeatBal->Zone.allocate(state->dataGlobal->NumOfZones); @@ -1724,6 +1741,7 @@ TEST_F(EnergyPlusFixture, SetPointManager_SystemNodeResetTempTest) ASSERT_TRUE(process_idf(idf_objects)); EXPECT_FALSE(ErrorsFound); + state->init_state(*state); // check Setpoint Manager inputs SetPointManager::GetSetPointManagerInputs(*state); @@ -1785,6 +1803,7 @@ TEST_F(EnergyPlusFixture, SetPointManager_SystemNodeResetHumRatTest) ASSERT_TRUE(process_idf(idf_objects)); EXPECT_FALSE(ErrorsFound); + state->init_state(*state); // check Setpoint Manager inputs SetPointManager::GetSetPointManagerInputs(*state); @@ -1901,8 +1920,10 @@ TEST_F(EnergyPlusFixture, SetPointManager_OutdoorAirResetCalculateSchedValTest) ASSERT_TRUE(process_idf(idf_objects)); EXPECT_FALSE(ErrorsFound); // zones are specified in the idf snippet - state->dataGlobal->NumOfTimeStepInHour = 1; - state->dataGlobal->MinutesPerTimeStep = 60; + state->dataGlobal->TimeStepsInHour = 1; + state->dataGlobal->MinutesInTimeStep = 60; + state->init_state(*state); + state->dataGlobal->HourOfDay = 1; state->dataGlobal->TimeStep = 1; state->dataGlobal->DayOfSim = 1; @@ -1911,7 +1932,6 @@ TEST_F(EnergyPlusFixture, SetPointManager_OutdoorAirResetCalculateSchedValTest) state->dataEnvrn->DayOfWeek = 1; state->dataEnvrn->HolidayIndex = 0; - ScheduleManager::ProcessScheduleInput(*state); SetPointManager::GetSetPointManagerInputs(*state); int spm1Num = SetPointManager::GetSetPointManagerIndex(*state, "OA RESET MANAGER 1"); @@ -1928,7 +1948,7 @@ TEST_F(EnergyPlusFixture, SetPointManager_OutdoorAirResetCalculateSchedValTest) // Set general data for all tests state->dataEnvrn->OutDryBulbTemp = 7.0; - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); // Test 1: First outdoor air reset setpoint manager--should use the first set of setpoint data expectedAnswer = 50.0; diff --git a/tst/EnergyPlus/unit/SimAirServingZones.unit.cc b/tst/EnergyPlus/unit/SimAirServingZones.unit.cc index cf5ec7c6e2e..59aada33520 100644 --- a/tst/EnergyPlus/unit/SimAirServingZones.unit.cc +++ b/tst/EnergyPlus/unit/SimAirServingZones.unit.cc @@ -462,7 +462,8 @@ TEST_F(EnergyPlusFixture, GetAirPathData_ControllerLockout1) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + SimAirServingZones::GetAirPathData(*state); // 2 controllers on this AHU for 2 water coils on the branch @@ -622,7 +623,8 @@ TEST_F(EnergyPlusFixture, GetAirPathData_ControllerLockout2) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + SimAirServingZones::GetAirPathData(*state); // 2 controllers on this AHU for 2 water coils in the OA system @@ -774,6 +776,8 @@ TEST_F(EnergyPlusFixture, InitAirLoops_1AirLoop2ADU) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + bool ErrorsFound = false; HeatBalanceManager::GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); @@ -1006,6 +1010,8 @@ TEST_F(EnergyPlusFixture, InitAirLoops_2AirLoop2ADU) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + bool ErrorsFound = false; HeatBalanceManager::GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); @@ -1036,7 +1042,6 @@ TEST_F(EnergyPlusFixture, InitAirLoops_2AirLoop2ADU) // this test checks whether an AirLoop with 0 airflow will raise the correct severe error TEST_F(EnergyPlusFixture, SizeAirLoopBranches_0Airflow) { - std::string const idf_objects = delimited_string({ "Zone,", " Space1; !- Name", @@ -1140,6 +1145,8 @@ TEST_F(EnergyPlusFixture, SizeAirLoopBranches_0Airflow) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + bool ErrorsFound = false; HeatBalanceManager::GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); @@ -1171,7 +1178,6 @@ TEST_F(EnergyPlusFixture, SizeAirLoopBranches_0Airflow) TEST_F(EnergyPlusFixture, InitAirLoops_2AirLoop3ADUa) { - std::string const idf_objects = delimited_string({ "Zone,", " Space1; !- Name", @@ -1407,6 +1413,8 @@ TEST_F(EnergyPlusFixture, InitAirLoops_2AirLoop3ADUa) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + bool ErrorsFound = false; HeatBalanceManager::GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); @@ -1437,7 +1445,6 @@ TEST_F(EnergyPlusFixture, InitAirLoops_2AirLoop3ADUa) TEST_F(EnergyPlusFixture, InitAirLoops_2AirLoop3ADUb) { - std::string const idf_objects = delimited_string({ "Zone,", " Space1; !- Name", @@ -1673,6 +1680,8 @@ TEST_F(EnergyPlusFixture, InitAirLoops_2AirLoop3ADUb) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + bool ErrorsFound = false; HeatBalanceManager::GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); @@ -1870,6 +1879,8 @@ TEST_F(EnergyPlusFixture, InitAirLoops_1AirLoop2Zones3ADU) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + bool ErrorsFound = false; HeatBalanceManager::GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); @@ -2415,7 +2426,8 @@ TEST_F(EnergyPlusFixture, DISABLED_AirLoop_ReturnFan_MinFlow) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + SimulationManager::ManageSimulation(*state); // run the design days int returnFanNode = diff --git a/tst/EnergyPlus/unit/SimulationManager.unit.cc b/tst/EnergyPlus/unit/SimulationManager.unit.cc index 954b4afae02..9016d1bd40d 100644 --- a/tst/EnergyPlus/unit/SimulationManager.unit.cc +++ b/tst/EnergyPlus/unit/SimulationManager.unit.cc @@ -71,6 +71,7 @@ TEST_F(EnergyPlusFixture, CheckThreading) }); EXPECT_FALSE(process_idf(idf_objects, false)); + state->init_state(*state); std::string const error_string = delimited_string({ " ** Severe ** Line: 1 Index: 14 - \"ProgramControl\" is not a valid Object Type.", @@ -112,6 +113,8 @@ TEST_F(EnergyPlusFixture, Test_PerformancePrecisionTradeoffs_DirectSolution_Mess EXPECT_TRUE(process_idf(idf_objects, false)); + state->init_state(*state); + std::string const error_string = delimited_string({ " ** Warning ** PerformancePrecisionTradeoffs: Coil Direct Solution simulation is selected.", }); @@ -186,7 +189,8 @@ TEST_F(EnergyPlusFixture, SimulationManager_OutputDebuggingData) state->init_state_called = false; EXPECT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + EXPECT_TRUE(state->dataReportFlag->DebugOutput); EXPECT_FALSE(state->dataReportFlag->EvenDuringWarmup); @@ -203,6 +207,7 @@ TEST_F(EnergyPlusFixture, SimulationManager_OutputDebuggingData) state->init_state_called = false; EXPECT_TRUE(process_idf(idf_objects)); + state->init_state(*state); EXPECT_FALSE(state->dataReportFlag->DebugOutput); EXPECT_TRUE(state->dataReportFlag->EvenDuringWarmup); @@ -227,6 +232,8 @@ TEST_F(EnergyPlusFixture, SimulationManager_OutputDebuggingData) compare_err_stream_substring("", true); // Input processor with throw a severe, so do not use assertions EXPECT_FALSE(process_idf(idf_objects, false)); + state->init_state(*state); + // Instead do it here, making sure to reset the stream { std::string const expectedError = delimited_string({ @@ -248,7 +255,8 @@ TEST_F(EnergyPlusFixture, SimulationManager_OutputDiagnostics_DefaultState) }); EXPECT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + EXPECT_FALSE(state->dataGlobal->DisplayAllWarnings); EXPECT_FALSE(state->dataGlobal->DisplayExtraWarnings); EXPECT_FALSE(state->dataGlobal->DisplayUnusedObjects); @@ -282,6 +290,7 @@ TEST_F(EnergyPlusFixture, SimulationManager_OutputDiagnostics_SimpleCase) }); EXPECT_TRUE(process_idf(idf_objects)); + state->init_state(*state); EXPECT_TRUE(state->dataGlobal->DisplayAllWarnings); EXPECT_TRUE(state->dataGlobal->DisplayExtraWarnings); @@ -320,6 +329,7 @@ TEST_F(EnergyPlusFixture, SimulationManager_OutputDiagnostics_AllKeys) }); EXPECT_TRUE(process_idf(idf_objects)); + state->init_state(*state); EXPECT_TRUE(state->dataGlobal->DisplayAllWarnings); EXPECT_TRUE(state->dataGlobal->DisplayExtraWarnings); @@ -351,6 +361,8 @@ TEST_F(EnergyPlusFixture, SimulationManager_OutputDiagnostics_Unicity) compare_err_stream_substring("", true); // Input processor will throw a severe, so do not use assertions EXPECT_FALSE(process_idf(idf_objects, false)); + state->init_state(*state); + // Instead do it here, making sure to reset the stream { std::string const expectedError = delimited_string({ @@ -387,6 +399,8 @@ TEST_F(EnergyPlusFixture, SimulationManager_OutputDiagnostics_UndocumentedFlags) // This will throw a warning in InputProcessor since these aren't supported keys, so do not use assertions EXPECT_FALSE(process_idf(idf_objects, false)); + state->init_state(*state); + const std::string expected_warning = delimited_string({ " ** Severe ** [Output:Diagnostics][Output:Diagnostics 1][diagnostics][0][key] - \"IgnoreSolarRadiation\" - Failed to match against " "any enum values.", @@ -435,6 +449,7 @@ TEST_F(EnergyPlusFixture, SimulationManager_OutputDiagnostics_HasEmpty) }); EXPECT_TRUE(process_idf(idf_objects)); + state->init_state(*state); EXPECT_FALSE(state->dataGlobal->DisplayAllWarnings); EXPECT_FALSE(state->dataGlobal->DisplayExtraWarnings); @@ -471,6 +486,7 @@ TEST_F(EnergyPlusFixture, SimulationManager_HVACSizingSimulationChoiceTest) }); EXPECT_TRUE(process_idf(idf_objects)); + state->init_state(*state); EXPECT_TRUE(state->dataGlobal->DoHVACSizingSimulation); // get a default value @@ -492,6 +508,7 @@ TEST_F(EnergyPlusFixture, Test_SimulationControl_ZeroSimulation) }); EXPECT_TRUE(process_idf(idf_objects)); + state->init_state(*state); ASSERT_THROW(SimulationManager::CheckForMisMatchedEnvironmentSpecifications(*state), std::runtime_error); // no error message from PerformancePrecisionTradeoffs objects @@ -522,7 +539,8 @@ TEST_F(EnergyPlusFixture, Test_SimulationControl_PureLoadCalc) }); EXPECT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + EXPECT_NO_THROW(SimulationManager::CheckForMisMatchedEnvironmentSpecifications(*state)); // no error message from PerformancePrecisionTradeoffs objects // diff --git a/tst/EnergyPlus/unit/SingleDuct.unit.cc b/tst/EnergyPlus/unit/SingleDuct.unit.cc index 3c448d7b1ee..3c351ea9e5f 100644 --- a/tst/EnergyPlus/unit/SingleDuct.unit.cc +++ b/tst/EnergyPlus/unit/SingleDuct.unit.cc @@ -124,10 +124,10 @@ TEST_F(EnergyPlusFixture, VAVNoReheatTerminalUnitSchedule) ASSERT_TRUE(process_idf(idf_objects)); - state->dataGlobal->NumOfTimeStepInHour = 1; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 60; // must initialize this to get schedules initialized - ScheduleManager::ProcessScheduleInput(*state); // read schedules - state->dataScheduleMgr->ScheduleInputProcessed = true; + state->dataGlobal->TimeStepsInHour = 1; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 60; // must initialize this to get schedules initialized + state->init_state(*state); + state->dataEnvrn->Month = 1; state->dataEnvrn->DayOfMonth = 21; state->dataGlobal->HourOfDay = 1; @@ -137,7 +137,7 @@ TEST_F(EnergyPlusFixture, VAVNoReheatTerminalUnitSchedule) state->dataEnvrn->HolidayIndex = 0; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); state->dataEnvrn->StdRhoAir = Psychrometrics::PsyRhoAirFnPbTdbW(*state, 101325.0, 20.0, 0.0); - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); bool ErrorsFound = false; HeatBalanceManager::GetZoneData(*state, ErrorsFound); @@ -147,7 +147,7 @@ TEST_F(EnergyPlusFixture, VAVNoReheatTerminalUnitSchedule) SingleDuct::GetSysInput(*state); EXPECT_TRUE(compare_err_stream("")); state->dataHeatBalFanSys->TempControlType.allocate(1); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::DualSetPointWithDeadBand; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::DualHeatCool; // node number table // 1 Zone 1 Air Node @@ -170,7 +170,7 @@ TEST_F(EnergyPlusFixture, VAVNoReheatTerminalUnitSchedule) state->dataZoneEnergyDemand->ZoneSysEnergyDemand(1).RemainingOutputRequired = 2000.0; // Heating load - expect min flow rate // First test - AlwaysOff Schedule - expecting no flow - state->dataSingleDuct->sd_airterminal(SysNum).SchedPtr = 1; + state->dataSingleDuct->sd_airterminal(SysNum).availSched = Sched::GetSchedule(*state, "ALWAYSOFF"); state->dataLoopNodes->Node(InletNodeNum).MassFlowRate = SysMinMassFlow; state->dataLoopNodes->Node(InletNodeNum).MassFlowRateMaxAvail = SysMaxMassFlow; state->dataGlobal->BeginEnvrnFlag = true; // Must be true for initial pass thru SingleDuct::InitSys for this terminal unit @@ -188,7 +188,7 @@ TEST_F(EnergyPlusFixture, VAVNoReheatTerminalUnitSchedule) // Reset flows and switch to AlwaysOn Schedule state->dataLoopNodes->Node(InletNodeNum).MassFlowRate = SysMinMassFlow; state->dataLoopNodes->Node(InletNodeNum).MassFlowRateMaxAvail = SysMaxMassFlow; - state->dataSingleDuct->sd_airterminal(SysNum).SchedPtr = 2; + state->dataSingleDuct->sd_airterminal(SysNum).availSched = Sched::GetSchedule(*state, "ALWAYSON"); FirstHVACIteration = true; state->dataSingleDuct->sd_airterminal(SysNum).InitSys(*state, FirstHVACIteration); // Run thru init once with FirstHVACIteration set to true FirstHVACIteration = false; @@ -202,7 +202,7 @@ TEST_F(EnergyPlusFixture, VAVNoReheatTerminalUnitSchedule) state->dataZoneEnergyDemand->ZoneSysEnergyDemand(1).RemainingOutputRequired = -2000.0; // Cooling load - expect max flow rate // First test - AlwaysOff Schedule - expecting no flow - state->dataSingleDuct->sd_airterminal(SysNum).SchedPtr = 1; + state->dataSingleDuct->sd_airterminal(SysNum).availSched = Sched::GetSchedule(*state, "ALWAYSOFF"); state->dataLoopNodes->Node(InletNodeNum).MassFlowRate = SysMinMassFlow; state->dataLoopNodes->Node(InletNodeNum).MassFlowRateMaxAvail = SysMaxMassFlow; state->dataGlobal->BeginEnvrnFlag = true; // Must be true for initial pass thru SingleDuct::InitSys for this terminal unit @@ -220,7 +220,7 @@ TEST_F(EnergyPlusFixture, VAVNoReheatTerminalUnitSchedule) // Reset flows and switch to AlwaysOn Schedule state->dataLoopNodes->Node(InletNodeNum).MassFlowRate = SysMinMassFlow; state->dataLoopNodes->Node(InletNodeNum).MassFlowRateMaxAvail = SysMaxMassFlow; - state->dataSingleDuct->sd_airterminal(SysNum).SchedPtr = 2; + state->dataSingleDuct->sd_airterminal(SysNum).availSched = Sched::GetSchedule(*state, "ALWAYSON"); FirstHVACIteration = true; state->dataSingleDuct->sd_airterminal(SysNum).InitSys(*state, FirstHVACIteration); // Run thru init once with FirstHVACIteration set to true FirstHVACIteration = false; @@ -299,10 +299,10 @@ TEST_F(EnergyPlusFixture, VAVReheatTerminalUnitSchedule) ASSERT_TRUE(process_idf(idf_objects)); - state->dataGlobal->NumOfTimeStepInHour = 1; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 60; // must initialize this to get schedules initialized - ScheduleManager::ProcessScheduleInput(*state); // read schedules - state->dataScheduleMgr->ScheduleInputProcessed = true; + state->dataGlobal->TimeStepsInHour = 1; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 60; // must initialize this to get schedules initialized + state->init_state(*state); + state->dataEnvrn->Month = 1; state->dataEnvrn->DayOfMonth = 21; state->dataGlobal->HourOfDay = 1; @@ -312,7 +312,7 @@ TEST_F(EnergyPlusFixture, VAVReheatTerminalUnitSchedule) state->dataEnvrn->HolidayIndex = 0; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); state->dataEnvrn->StdRhoAir = Psychrometrics::PsyRhoAirFnPbTdbW(*state, 101325.0, 20.0, 0.0); - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); bool ErrorsFound = false; HeatBalanceManager::GetZoneData(*state, ErrorsFound); @@ -322,7 +322,7 @@ TEST_F(EnergyPlusFixture, VAVReheatTerminalUnitSchedule) SingleDuct::GetSysInput(*state); EXPECT_TRUE(compare_err_stream("")); state->dataHeatBalFanSys->TempControlType.allocate(1); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::DualSetPointWithDeadBand; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::DualHeatCool; // node number table // 1 Zone 1 Air Node @@ -346,7 +346,7 @@ TEST_F(EnergyPlusFixture, VAVReheatTerminalUnitSchedule) state->dataZoneEnergyDemand->ZoneSysEnergyDemand(1).RemainingOutputRequired = 2000.0; // Heating load - expect min flow rate // First test - AlwaysOff Schedule - expecting no flow - state->dataSingleDuct->sd_airterminal(SysNum).SchedPtr = 1; + state->dataSingleDuct->sd_airterminal(SysNum).availSched = Sched::GetSchedule(*state, "ALWAYSOFF"); state->dataLoopNodes->Node(InletNodeNum).MassFlowRate = SysMinMassFlow; state->dataLoopNodes->Node(InletNodeNum).MassFlowRateMaxAvail = SysMaxMassFlow; state->dataGlobal->BeginEnvrnFlag = true; // Must be true for initial pass thru SingleDuct::InitSys for this terminal unit @@ -364,7 +364,7 @@ TEST_F(EnergyPlusFixture, VAVReheatTerminalUnitSchedule) // Reset flows and switch to AlwaysOn Schedule state->dataLoopNodes->Node(InletNodeNum).MassFlowRate = SysMinMassFlow; state->dataLoopNodes->Node(InletNodeNum).MassFlowRateMaxAvail = SysMaxMassFlow; - state->dataSingleDuct->sd_airterminal(SysNum).SchedPtr = 2; + state->dataSingleDuct->sd_airterminal(SysNum).availSched = Sched::GetSchedule(*state, "ALWAYSON"); FirstHVACIteration = true; state->dataSingleDuct->sd_airterminal(SysNum).InitSys(*state, FirstHVACIteration); // Run thru init once with FirstHVACIteration set to true FirstHVACIteration = false; @@ -378,7 +378,7 @@ TEST_F(EnergyPlusFixture, VAVReheatTerminalUnitSchedule) state->dataZoneEnergyDemand->ZoneSysEnergyDemand(1).RemainingOutputRequired = -2000.0; // Cooling load - expect max flow rate // First test - AlwaysOff Schedule - expecting no flow - state->dataSingleDuct->sd_airterminal(SysNum).SchedPtr = 1; + state->dataSingleDuct->sd_airterminal(SysNum).availSched = Sched::GetSchedule(*state, "ALWAYSOFF"); state->dataLoopNodes->Node(InletNodeNum).MassFlowRate = SysMinMassFlow; state->dataLoopNodes->Node(InletNodeNum).MassFlowRateMaxAvail = SysMaxMassFlow; state->dataGlobal->BeginEnvrnFlag = true; // Must be true for initial pass thru SingleDuct::InitSys for this terminal unit @@ -396,7 +396,7 @@ TEST_F(EnergyPlusFixture, VAVReheatTerminalUnitSchedule) // Reset flows and switch to AlwaysOn Schedule state->dataLoopNodes->Node(InletNodeNum).MassFlowRate = SysMinMassFlow; state->dataLoopNodes->Node(InletNodeNum).MassFlowRateMaxAvail = SysMaxMassFlow; - state->dataSingleDuct->sd_airterminal(SysNum).SchedPtr = 2; + state->dataSingleDuct->sd_airterminal(SysNum).availSched = Sched::GetSchedule(*state, "ALWAYSON"); FirstHVACIteration = true; state->dataSingleDuct->sd_airterminal(SysNum).InitSys(*state, FirstHVACIteration); // Run thru init once with FirstHVACIteration set to true FirstHVACIteration = false; @@ -1272,7 +1272,8 @@ TEST_F(EnergyPlusFixture, SingleDuct_ZeroFloorAreaTest) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + // OutputProcessor::TimeValue.allocate(2); ManageSimulation(*state); // run the design day over the warmup period (24 hrs, 25 days) @@ -2490,7 +2491,7 @@ TEST_F(EnergyPlusFixture, SingleDuct_VAVWaterCoilSizing) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); // OutputProcessor::TimeValue.allocate(2); ManageSimulation(*state); // run the design days @@ -2724,7 +2725,8 @@ TEST_F(EnergyPlusFixture, VAVReheatTerminal_SizeMinFrac) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + bool ErrorsFound = false; HeatBalanceManager::GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); @@ -2872,7 +2874,8 @@ TEST_F(EnergyPlusFixture, VAVConstantVolTU_NoReheat_Sizing) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + bool ErrorsFound = false; HeatBalanceManager::GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); @@ -2960,7 +2963,8 @@ TEST_F(EnergyPlusFixture, VAVConstantVolTU_Reheat_Sizing) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + bool ErrorsFound = false; HeatBalanceManager::GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); @@ -3024,11 +3028,8 @@ TEST_F(EnergyPlusFixture, SingleDuctAirTerminal_reportTerminalUnit) SetPredefinedTables(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; - auto &sch = state->dataScheduleMgr->Schedule; - sch.allocate(5); - sch(1).Name = "schA"; - sch(2).Name = "schB"; + auto *schA = Sched::AddScheduleConstant(*state, "schA"); + auto *schB = Sched::AddScheduleConstant(*state, "schB"); auto &adu = state->dataDefineEquipment->AirDistUnit; adu.allocate(2); @@ -3049,7 +3050,7 @@ TEST_F(EnergyPlusFixture, SingleDuctAirTerminal_reportTerminalUnit) sdat(1).ADUNum = 1; sdat(1).sysType = "AirTerminal:SingleDuct:ConstantVolume:NoReheat"; sdat(1).MaxAirVolFlowRate = 0.30; - sdat(1).ZoneMinAirFracSchPtr = 1; + sdat(1).zoneMinAirFracSched = schA; sdat(1).MaxAirVolFlowRateDuringReheat = 0.25; sdat(1).OARequirementsPtr = 0; sdat(1).ReheatComp = "watercoil"; @@ -3088,7 +3089,7 @@ TEST_F(EnergyPlusFixture, SingleDuctAirTerminal_reportTerminalUnit) sdat(2).ADUNum = 2; sdat(2).sysType = "AirTerminal:SingleDuct:ConstantVolume:Reheat"; sdat(2).MaxAirVolFlowRate = 0.31; - sdat(2).ZoneMinAirFracSchPtr = 0; + sdat(2).zoneMinAirFracSched = nullptr; sdat(2).MaxAirVolFlowRateDuringReheat = 0.26; sdat(2).OARequirementsPtr = 1; sdat(2).ReheatComp = "furncoil"; @@ -3097,7 +3098,7 @@ TEST_F(EnergyPlusFixture, SingleDuctAirTerminal_reportTerminalUnit) auto &oa = state->dataSize->OARequirements; oa.allocate(1); - oa(1).OAFlowFracSchPtr = 2; + oa(1).oaFlowFracSched = Sched::GetScheduleAlwaysOn(*state); sdat(2).reportTerminalUnit(*state); @@ -3112,7 +3113,7 @@ TEST_F(EnergyPlusFixture, SingleDuctAirTerminal_reportTerminalUnit) EXPECT_EQ("n/a", RetrievePreDefTableEntry(*state, orp.pdchAirTermSecdFlow, "ADU b")); EXPECT_EQ("n/a", RetrievePreDefTableEntry(*state, orp.pdchAirTermMinFlowSch, "ADU b")); EXPECT_EQ("0.26", RetrievePreDefTableEntry(*state, orp.pdchAirTermMaxFlowReh, "ADU b")); - EXPECT_EQ("schB", RetrievePreDefTableEntry(*state, orp.pdchAirTermMinOAflowSch, "ADU b")); + EXPECT_EQ("Constant-1.0", RetrievePreDefTableEntry(*state, orp.pdchAirTermMinOAflowSch, "ADU b")); EXPECT_EQ("furncoil", RetrievePreDefTableEntry(*state, orp.pdchAirTermHeatCoilType, "ADU b")); EXPECT_EQ("n/a", RetrievePreDefTableEntry(*state, orp.pdchAirTermCoolCoilType, "ADU b")); EXPECT_EQ("Fan:OnOff", RetrievePreDefTableEntry(*state, orp.pdchAirTermFanType, "ADU b")); diff --git a/tst/EnergyPlus/unit/SizeWaterHeatingCoil.unit.cc b/tst/EnergyPlus/unit/SizeWaterHeatingCoil.unit.cc index fb749b85c57..90f45baf16f 100644 --- a/tst/EnergyPlus/unit/SizeWaterHeatingCoil.unit.cc +++ b/tst/EnergyPlus/unit/SizeWaterHeatingCoil.unit.cc @@ -81,7 +81,6 @@ using namespace EnergyPlus::DataSizing; using namespace EnergyPlus::DataZoneEquipment; using namespace EnergyPlus::HeatBalanceManager; using namespace EnergyPlus::Psychrometrics; -using namespace EnergyPlus::ScheduleManager; using namespace EnergyPlus::SimAirServingZones; using namespace EnergyPlus::SingleDuct; using namespace EnergyPlus::SizingManager; @@ -100,7 +99,6 @@ TEST_F(EnergyPlusFixture, TestSizingRoutineForHotWaterCoils1) bool ErrorsFound(false); - InitializePsychRoutines(*state); state->dataEnvrn->StdRhoAir = 1.20; std::string const idf_objects = delimited_string({ @@ -217,6 +215,7 @@ TEST_F(EnergyPlusFixture, TestSizingRoutineForHotWaterCoils1) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); state->dataSize->FinalZoneSizing.allocate(1); state->dataSize->TermUnitFinalZoneSizing.allocate(1); @@ -244,8 +243,6 @@ TEST_F(EnergyPlusFixture, TestSizingRoutineForHotWaterCoils1) GetZoneAirDistribution(*state); // get zone air distribution objects GetZoneSizingInput(*state); GetZoneEquipmentData(*state); - ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; GetZoneAirLoopEquipment(*state); GetWaterCoilInput(*state); state->dataWaterCoils->GetWaterCoilsInputFlag = false; @@ -353,7 +350,6 @@ TEST_F(EnergyPlusFixture, TestSizingRoutineForHotWaterCoils2) bool ErrorsFound(false); - InitializePsychRoutines(*state); state->dataEnvrn->StdRhoAir = 1.20; std::string const idf_objects = delimited_string({ @@ -470,6 +466,7 @@ TEST_F(EnergyPlusFixture, TestSizingRoutineForHotWaterCoils2) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); state->dataSize->FinalZoneSizing.allocate(1); state->dataSize->TermUnitFinalZoneSizing.allocate(1); @@ -497,8 +494,6 @@ TEST_F(EnergyPlusFixture, TestSizingRoutineForHotWaterCoils2) GetZoneAirDistribution(*state); // get zone air distribution objects GetZoneSizingInput(*state); GetZoneEquipmentData(*state); - ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; GetZoneAirLoopEquipment(*state); GetWaterCoilInput(*state); state->dataWaterCoils->GetWaterCoilsInputFlag = false; @@ -605,7 +600,6 @@ TEST_F(EnergyPlusFixture, TestSizingRoutineForHotWaterCoils3) // with all inputs set by user except rated capacity is autosized bool ErrorsFound(false); - InitializePsychRoutines(*state); state->dataEnvrn->StdRhoAir = 1.20; std::string const idf_objects = delimited_string({ @@ -722,7 +716,8 @@ TEST_F(EnergyPlusFixture, TestSizingRoutineForHotWaterCoils3) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + state->dataSize->FinalZoneSizing.allocate(1); state->dataSize->TermUnitFinalZoneSizing.allocate(1); state->dataSize->CalcFinalZoneSizing.allocate(1); @@ -749,8 +744,6 @@ TEST_F(EnergyPlusFixture, TestSizingRoutineForHotWaterCoils3) GetZoneAirDistribution(*state); // get zone air distribution objects GetZoneSizingInput(*state); GetZoneEquipmentData(*state); - ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; GetZoneAirLoopEquipment(*state); GetWaterCoilInput(*state); state->dataWaterCoils->GetWaterCoilsInputFlag = false; @@ -857,7 +850,6 @@ TEST_F(EnergyPlusFixture, TestSizingRoutineForHotWaterCoils4) bool ErrorsFound(false); - InitializePsychRoutines(*state); state->dataEnvrn->StdRhoAir = 1.20; std::string const idf_objects = delimited_string({ @@ -974,7 +966,8 @@ TEST_F(EnergyPlusFixture, TestSizingRoutineForHotWaterCoils4) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + state->dataSize->FinalZoneSizing.allocate(1); state->dataSize->TermUnitFinalZoneSizing.allocate(1); state->dataSize->CalcFinalZoneSizing.allocate(1); @@ -1001,8 +994,6 @@ TEST_F(EnergyPlusFixture, TestSizingRoutineForHotWaterCoils4) GetZoneAirDistribution(*state); // get zone air distribution objects GetZoneSizingInput(*state); GetZoneEquipmentData(*state); - ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; GetZoneAirLoopEquipment(*state); GetWaterCoilInput(*state); state->dataWaterCoils->GetWaterCoilsInputFlag = false; @@ -1108,7 +1099,6 @@ TEST_F(EnergyPlusFixture, TestSizingRoutineForHotWaterCoils5) bool ErrorsFound(false); - InitializePsychRoutines(*state); state->dataEnvrn->StdRhoAir = 1.20; std::string const idf_objects = delimited_string({ @@ -1191,7 +1181,8 @@ TEST_F(EnergyPlusFixture, TestSizingRoutineForHotWaterCoils5) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + state->dataSize->FinalSysSizing.allocate(1); state->dataSize->UnitarySysEqSizing.allocate(1); state->dataAirSystemsData->PrimaryAirSystems.allocate(1); @@ -1213,8 +1204,6 @@ TEST_F(EnergyPlusFixture, TestSizingRoutineForHotWaterCoils5) } GetZoneData(*state, ErrorsFound); EXPECT_EQ("SPACE1-1", state->dataHeatBal->Zone(1).Name); - ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; GetWaterCoilInput(*state); state->dataWaterCoils->GetWaterCoilsInputFlag = false; state->dataWaterCoils->MySizeFlag(1) = true; @@ -1280,7 +1269,6 @@ TEST_F(EnergyPlusFixture, TestSizingRoutineForHotWaterCoils6) bool ErrorsFound(false); - InitializePsychRoutines(*state); state->dataEnvrn->StdRhoAir = 1.20; std::string const idf_objects = delimited_string({ @@ -1408,7 +1396,8 @@ TEST_F(EnergyPlusFixture, TestSizingRoutineForHotWaterCoils6) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + state->dataSize->TermUnitSizing.allocate(1); state->dataPlnt->TotNumLoops = 1; state->dataPlnt->PlantLoop.allocate(state->dataPlnt->TotNumLoops); @@ -1429,8 +1418,6 @@ TEST_F(EnergyPlusFixture, TestSizingRoutineForHotWaterCoils6) GetZoneAirDistribution(*state); // get zone air distribution objects GetZoneSizingInput(*state); GetZoneEquipmentData(*state); - ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; GetZoneAirLoopEquipment(*state); GetWaterCoilInput(*state); state->dataWaterCoils->GetWaterCoilsInputFlag = false; diff --git a/tst/EnergyPlus/unit/SizingAnalysisObjects.unit.cc b/tst/EnergyPlus/unit/SizingAnalysisObjects.unit.cc index 8678f9f1b36..ea1d12c1c54 100644 --- a/tst/EnergyPlus/unit/SizingAnalysisObjects.unit.cc +++ b/tst/EnergyPlus/unit/SizingAnalysisObjects.unit.cc @@ -83,7 +83,7 @@ class SizingAnalysisObjectsTest : public EnergyPlusFixture midLogVal = 75.0; hiLogVal = 100.0; - state->dataGlobal->NumOfTimeStepInHour = 4; // in DataGlobals + state->dataGlobal->TimeStepsInHour = 4; // in DataGlobals state->dataGlobal->TimeStepZone = 0.25; // setup weather manager state needed @@ -435,7 +435,7 @@ TEST_F(SizingAnalysisObjectsTest, DISABLED_LoggingSubStep4stepPerHour) state->dataGlobal->DayOfSim = 1; int HourofDay(0); state->dataHVACGlobal->TimeStepSys = 1.0 / (4.0 * 5.0); // fractional hours, duration - state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; Real64 zoneTimeStepDuration(0.25); int numTimeStepsInHour(4); diff --git a/tst/EnergyPlus/unit/SizingManager.unit.cc b/tst/EnergyPlus/unit/SizingManager.unit.cc index 356ac07dfef..be5b73fbf5c 100644 --- a/tst/EnergyPlus/unit/SizingManager.unit.cc +++ b/tst/EnergyPlus/unit/SizingManager.unit.cc @@ -71,6 +71,7 @@ using namespace EnergyPlus::DataSizing; TEST_F(EnergyPlusFixture, GetOARequirementsTest_DSOA1) { + state->init_state(*state); bool ErrorsFound(false); // If errors detected in input int OAIndex(0); // Zone number int NumAlphas(2); @@ -223,7 +224,7 @@ TEST_F(EnergyPlusFixture, GetOARequirementsTest_DSOA1) TEST_F(EnergyPlusFixture, SizingManagerTest_TimeIndexToHrMinString_test) { - state->dataGlobal->MinutesPerTimeStep = 15; + state->dataGlobal->MinutesInTimeStep = 15; EXPECT_EQ("00:00:00", TimeIndexToHrMinString(*state, 0)); EXPECT_EQ("00:15:00", TimeIndexToHrMinString(*state, 1)); @@ -232,7 +233,7 @@ TEST_F(EnergyPlusFixture, SizingManagerTest_TimeIndexToHrMinString_test) EXPECT_EQ("19:45:00", TimeIndexToHrMinString(*state, 79)); EXPECT_EQ("24:00:00", TimeIndexToHrMinString(*state, 96)); - state->dataGlobal->MinutesPerTimeStep = 3; + state->dataGlobal->MinutesInTimeStep = 3; EXPECT_EQ("00:00:00", TimeIndexToHrMinString(*state, 0)); EXPECT_EQ("00:03:00", TimeIndexToHrMinString(*state, 1)); @@ -298,7 +299,8 @@ TEST_F(EnergyPlusFixture, SizingManager_DOASControlStrategyDefaultSpecificationT }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + bool ErrorsFound(false); HeatBalanceManager::GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); @@ -367,7 +369,8 @@ TEST_F(EnergyPlusFixture, SizingManager_DOASControlStrategyDefaultSpecificationT }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + bool ErrorsFound(false); HeatBalanceManager::GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); @@ -551,10 +554,11 @@ TEST_F(EnergyPlusFixture, SizingManager_OverrideAvgWindowInSizing) }); EXPECT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + SimulationManager::GetProjectData(*state); EXPECT_TRUE(state->dataGlobal->OverrideTimestep); SizingManager::GetSizingParams(*state); - EXPECT_EQ(state->dataGlobal->NumOfTimeStepInHour, 1); + EXPECT_EQ(state->dataGlobal->TimeStepsInHour, 1); EXPECT_EQ(state->dataSize->NumTimeStepsInAvg, 1); } diff --git a/tst/EnergyPlus/unit/SolarShading.unit.cc b/tst/EnergyPlus/unit/SolarShading.unit.cc index 23d8830f682..b1fe6cb3fd8 100644 --- a/tst/EnergyPlus/unit/SolarShading.unit.cc +++ b/tst/EnergyPlus/unit/SolarShading.unit.cc @@ -626,15 +626,14 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_FigureSolarBeamAtTimestep) }); ASSERT_TRUE(process_idf(idf_objects)); - - SimulationManager::GetProjectData(*state); + state->init_state(*state); + bool FoundError = false; - HeatBalanceManager::GetProjectControlData(*state, FoundError); // read project control data - EXPECT_FALSE(FoundError); // expect no errors - + HeatBalanceManager::GetProjectControlData(*state, FoundError); + EXPECT_FALSE(FoundError); + HeatBalanceManager::SetPreConstructionInputParameters(*state); - ScheduleManager::ProcessScheduleInput(*state); // read schedules Material::GetMaterialData(*state, FoundError); EXPECT_FALSE(FoundError); @@ -653,8 +652,8 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_FigureSolarBeamAtTimestep) state->dataSurfaceGeometry->CosZoneRelNorth.allocate(1); state->dataSurfaceGeometry->SinZoneRelNorth.allocate(1); - state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); - state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); + state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); + state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); state->dataSurfaceGeometry->CosBldgRelNorth = 1.0; state->dataSurfaceGeometry->SinBldgRelNorth = 0.0; @@ -1030,15 +1029,14 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_ExternalShadingIO) }); ASSERT_TRUE(process_idf(idf_objects)); - - SimulationManager::GetProjectData(*state); + state->init_state(*state); + bool FoundError = false; HeatBalanceManager::GetProjectControlData(*state, FoundError); // read project control data EXPECT_FALSE(FoundError); // expect no errors HeatBalanceManager::SetPreConstructionInputParameters(*state); - ScheduleManager::ProcessScheduleInput(*state); // read schedules Material::GetMaterialData(*state, FoundError); EXPECT_FALSE(FoundError); @@ -1057,8 +1055,8 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_ExternalShadingIO) state->dataSurfaceGeometry->CosZoneRelNorth.allocate(1); state->dataSurfaceGeometry->SinZoneRelNorth.allocate(1); - state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); - state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); + state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); + state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); state->dataSurfaceGeometry->CosBldgRelNorth = 1.0; state->dataSurfaceGeometry->SinBldgRelNorth = 0.0; @@ -1087,14 +1085,14 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_ExternalShadingIO) SolarShading::SkyDifSolarShading(*state); state->dataSolarShading->CalcSkyDifShading = false; - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); state->dataBSDFWindow->SUNCOSTS(4, 9)(1) = 0.1; state->dataBSDFWindow->SUNCOSTS(4, 9)(2) = 0.1; state->dataBSDFWindow->SUNCOSTS(4, 9)(3) = 0.1; FigureSolarBeamAtTimestep(*state, state->dataGlobal->HourOfDay, state->dataGlobal->TimeStep); EXPECT_TRUE(state->dataSysVars->shadingMethod == DataSystemVariables::ShadingMethod::Scheduled); - EXPECT_DOUBLE_EQ(0.5432, ScheduleManager::LookUpScheduleValue(*state, 2, 9, 4)); + EXPECT_DOUBLE_EQ(0.5432, Sched::GetSchedule(*state, "EXTSHADINGSCH:ZN001:ROOF")->getHrTsVal(*state, 9, 4)); EXPECT_FALSE(state->dataSolarShading->SUNCOS(3) < 0.00001); EXPECT_DOUBLE_EQ(0.00001, DataEnvironment::SunIsUpValue); @@ -1443,15 +1441,11 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_DisableGroupSelfShading) }); ASSERT_TRUE(process_idf(idf_objects)); - - SimulationManager::GetProjectData(*state); + state->init_state(*state); + bool FoundError = false; - HeatBalanceManager::GetProjectControlData(*state, FoundError); // read project control data - EXPECT_FALSE(FoundError); // expect no errors - HeatBalanceManager::SetPreConstructionInputParameters(*state); - ScheduleManager::ProcessScheduleInput(*state); // read schedules Material::GetMaterialData(*state, FoundError); EXPECT_FALSE(FoundError); @@ -1474,8 +1468,8 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_DisableGroupSelfShading) state->dataSurfaceGeometry->CosZoneRelNorth.allocate(1); state->dataSurfaceGeometry->SinZoneRelNorth.allocate(1); - state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); - state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); + state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); + state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); state->dataSurfaceGeometry->CosBldgRelNorth = 1.0; state->dataSurfaceGeometry->SinBldgRelNorth = 0.0; @@ -1820,15 +1814,12 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_PolygonClippingDirect) }); ASSERT_TRUE(process_idf(idf_objects)); - - SimulationManager::GetProjectData(*state); + state->init_state(*state); + bool FoundError = false; HeatBalanceManager::GetProjectControlData(*state, FoundError); // read project control data - EXPECT_FALSE(FoundError); // expect no errors - HeatBalanceManager::SetPreConstructionInputParameters(*state); - ScheduleManager::ProcessScheduleInput(*state); // read schedules Material::GetMaterialData(*state, FoundError); EXPECT_FALSE(FoundError); @@ -1847,8 +1838,8 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_PolygonClippingDirect) state->dataSurfaceGeometry->CosZoneRelNorth.allocate(1); state->dataSurfaceGeometry->SinZoneRelNorth.allocate(1); - state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); - state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); + state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); + state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); state->dataSurfaceGeometry->CosBldgRelNorth = 1.0; state->dataSurfaceGeometry->SinBldgRelNorth = 0.0; @@ -2239,15 +2230,14 @@ WindowMaterial:SimpleGlazingSystem, )IDF"; ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); - SimulationManager::GetProjectData(*state); bool FoundError = false; HeatBalanceManager::GetProjectControlData(*state, FoundError); // read project control data EXPECT_FALSE(FoundError); // expect no errors HeatBalanceManager::SetPreConstructionInputParameters(*state); - ScheduleManager::ProcessScheduleInput(*state); // read schedules Material::GetMaterialData(*state, FoundError); EXPECT_FALSE(FoundError); @@ -2266,8 +2256,8 @@ WindowMaterial:SimpleGlazingSystem, state->dataSurfaceGeometry->CosZoneRelNorth.allocate(1); state->dataSurfaceGeometry->SinZoneRelNorth.allocate(1); - state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); - state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); + state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); + state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); state->dataSurfaceGeometry->CosBldgRelNorth = 1.0; state->dataSurfaceGeometry->SinBldgRelNorth = 0.0; @@ -2558,15 +2548,14 @@ WindowMaterial:SimpleGlazingSystem, )IDF"; ASSERT_TRUE(process_idf(idf_objects)); - - SimulationManager::GetProjectData(*state); + state->init_state(*state); + bool FoundError = false; HeatBalanceManager::GetProjectControlData(*state, FoundError); // read project control data EXPECT_FALSE(FoundError); // expect no errors HeatBalanceManager::SetPreConstructionInputParameters(*state); - ScheduleManager::ProcessScheduleInput(*state); // read schedules Material::GetMaterialData(*state, FoundError); EXPECT_FALSE(FoundError); @@ -2585,8 +2574,8 @@ WindowMaterial:SimpleGlazingSystem, state->dataSurfaceGeometry->CosZoneRelNorth.allocate(1); state->dataSurfaceGeometry->SinZoneRelNorth.allocate(1); - state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); - state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); + state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); + state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); state->dataSurfaceGeometry->CosBldgRelNorth = 1.0; state->dataSurfaceGeometry->SinBldgRelNorth = 0.0; @@ -2637,30 +2626,29 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_selectActiveWindowShadingControl) state->dataSurface->Surface(curSurface).windowShadingControlList.push_back(3); state->dataSurface->WindowShadingControl.allocate(3); - state->dataSurface->WindowShadingControl(1).Schedule = 1; - state->dataSurface->WindowShadingControl(2).Schedule = 2; - state->dataSurface->WindowShadingControl(3).Schedule = 3; + auto *sch1 = state->dataSurface->WindowShadingControl(1).sched = Sched::AddScheduleConstant(*state, "SCHED-1"); + auto *sch2 = state->dataSurface->WindowShadingControl(2).sched = Sched::AddScheduleConstant(*state, "SCHED-2"); + auto *sch3 = state->dataSurface->WindowShadingControl(3).sched = Sched::AddScheduleConstant(*state, "SCHED-3"); - state->dataScheduleMgr->Schedule.allocate(3); - state->dataScheduleMgr->Schedule(1).CurrentValue = 0; - state->dataScheduleMgr->Schedule(2).CurrentValue = 0; - state->dataScheduleMgr->Schedule(3).CurrentValue = 1; + sch1->currentVal = 0; + sch2->currentVal = 0; + sch3->currentVal = 1; curIndexActiveWindowShadingControl = selectActiveWindowShadingControlIndex(*state, curSurface); activeWindowShadingControl = state->dataSurface->Surface(curSurface).windowShadingControlList[curIndexActiveWindowShadingControl]; EXPECT_EQ(activeWindowShadingControl, 3); - state->dataScheduleMgr->Schedule(1).CurrentValue = 0; - state->dataScheduleMgr->Schedule(2).CurrentValue = 1; - state->dataScheduleMgr->Schedule(3).CurrentValue = 0; + sch1->currentVal = 0; + sch2->currentVal = 1; + sch3->currentVal = 0; curIndexActiveWindowShadingControl = selectActiveWindowShadingControlIndex(*state, curSurface); activeWindowShadingControl = state->dataSurface->Surface(curSurface).windowShadingControlList[curIndexActiveWindowShadingControl]; EXPECT_EQ(activeWindowShadingControl, 2); - state->dataScheduleMgr->Schedule(1).CurrentValue = 1; - state->dataScheduleMgr->Schedule(2).CurrentValue = 0; - state->dataScheduleMgr->Schedule(3).CurrentValue = 0; + sch1->currentVal = 1; + sch2->currentVal = 0; + sch3->currentVal = 0; curIndexActiveWindowShadingControl = selectActiveWindowShadingControlIndex(*state, curSurface); activeWindowShadingControl = state->dataSurface->Surface(curSurface).windowShadingControlList[curIndexActiveWindowShadingControl]; @@ -2739,7 +2727,7 @@ TEST_F(EnergyPlusFixture, WindowShadingManager_Lum_Test) state->dataEnvrn->SOLCOS = 0.5; state->dataGlobal->TimeStep = 1; state->dataGlobal->HourOfDay = 10; - state->dataGlobal->NumOfTimeStepInHour = NumTimeSteps; + state->dataGlobal->TimeStepsInHour = NumTimeSteps; state->dataHeatBal->SurfSunlitFrac.allocate(HoursInDay, NumTimeSteps, state->dataSurface->TotSurfaces); state->dataHeatBal->SurfCosIncAng.allocate(HoursInDay, NumTimeSteps, state->dataSurface->TotSurfaces); state->dataHeatBal->SurfCosIncAng = 45; @@ -3115,15 +3103,14 @@ TEST_F(EnergyPlusFixture, SolarShading_TestSurfsPropertyViewFactor) }); ASSERT_TRUE(process_idf(idf_objects)); - - SimulationManager::GetProjectData(*state); + state->init_state(*state); + bool FoundError = false; HeatBalanceManager::GetProjectControlData(*state, FoundError); // read project control data EXPECT_FALSE(FoundError); // expect no errors HeatBalanceManager::SetPreConstructionInputParameters(*state); - ScheduleManager::ProcessScheduleInput(*state); // read schedules Material::GetMaterialData(*state, FoundError); EXPECT_FALSE(FoundError); @@ -3142,8 +3129,8 @@ TEST_F(EnergyPlusFixture, SolarShading_TestSurfsPropertyViewFactor) state->dataSurfaceGeometry->CosZoneRelNorth.allocate(1); state->dataSurfaceGeometry->SinZoneRelNorth.allocate(1); - state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); - state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); + state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); + state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); state->dataSurfaceGeometry->CosBldgRelNorth = 1.0; state->dataSurfaceGeometry->SinBldgRelNorth = 0.0; @@ -3404,7 +3391,8 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_CTRANS) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + bool ErrorsFound = false; Material::GetMaterialData(*state, ErrorsFound); // read material data @@ -3856,15 +3844,14 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_Warn_Pixel_Count_and_TM_Schedule) }); ASSERT_TRUE(process_idf(idf_objects)); - - SimulationManager::GetProjectData(*state); + state->init_state(*state); + bool FoundError = false; HeatBalanceManager::GetProjectControlData(*state, FoundError); EXPECT_FALSE(FoundError); HeatBalanceManager::SetPreConstructionInputParameters(*state); - ScheduleManager::ProcessScheduleInput(*state); Material::GetMaterialData(*state, FoundError); EXPECT_FALSE(FoundError); @@ -3885,8 +3872,8 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_Warn_Pixel_Count_and_TM_Schedule) state->dataSurfaceGeometry->CosZoneRelNorth.allocate(1); state->dataSurfaceGeometry->SinZoneRelNorth.allocate(1); - state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); - state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); + state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); + state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); state->dataSurfaceGeometry->CosBldgRelNorth = 1.0; state->dataSurfaceGeometry->SinBldgRelNorth = 0.0; @@ -3967,15 +3954,15 @@ TEST_F(EnergyPlusFixture, ShadowCalculation_CSV) state->dataGlobal->BeginDayFlag = true; state->dataGlobal->WarmupFlag = false; state->dataGlobal->KindOfSim = Constant::KindOfSim::RunPeriodWeather; - state->dataGlobal->NumOfTimeStepInHour = NumTimeSteps; + state->dataGlobal->TimeStepsInHour = NumTimeSteps; state->dataEnvrn->Month = 1; state->dataEnvrn->DayOfMonth = 25; state->dataHeatBal->SurfSunlitFrac.allocate(HoursInDay, NumTimeSteps, state->dataSurface->TotSurfaces); for (int iHour = 1; iHour <= 24; ++iHour) { // Do for all hours. - for (int TS = 1; TS <= state->dataGlobal->NumOfTimeStepInHour; ++TS) { - if (TS == state->dataGlobal->NumOfTimeStepInHour) { + for (int TS = 1; TS <= state->dataGlobal->TimeStepsInHour; ++TS) { + if (TS == state->dataGlobal->TimeStepsInHour) { expected_values += fmt::format(" 01/25 {:02}:00,", iHour); } else { expected_values += fmt::format(" 01/25 {:02}:30,", iHour - 1); @@ -4178,15 +4165,14 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_PolygonOverlap) }); ASSERT_TRUE(process_idf(idf_objects)); - - SimulationManager::GetProjectData(*state); + state->init_state(*state); + bool FoundError = false; HeatBalanceManager::GetProjectControlData(*state, FoundError); // read project control data EXPECT_FALSE(FoundError); // expect no errors HeatBalanceManager::SetPreConstructionInputParameters(*state); - ScheduleManager::ProcessScheduleInput(*state); // read schedules Material::GetMaterialData(*state, FoundError); EXPECT_FALSE(FoundError); @@ -4212,8 +4198,8 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_PolygonOverlap) state->dataSurfaceGeometry->CosZoneRelNorth.allocate(1); state->dataSurfaceGeometry->SinZoneRelNorth.allocate(1); - state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); - state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); + state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); + state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); state->dataSurfaceGeometry->CosBldgRelNorth = 1.0; state->dataSurfaceGeometry->SinBldgRelNorth = 0.0; @@ -4259,20 +4245,14 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_PolygonOverlap) int treeSurfNum = Util::FindItemInList("ZN001:WALL-SOUTH:TREE", state->dataSurface->Surface); // Get shading surface schedule indexes - int overhangSchedNum = state->dataSurface->Surface(overhangSurfNum).SchedShadowSurfIndex; - int treeSchedNum = state->dataSurface->Surface(treeSurfNum).SchedShadowSurfIndex; - - // Use EMS to turn shading surfaces on and off - auto &overhangSchedEMSOn = state->dataScheduleMgr->Schedule(overhangSchedNum).EMSActuatedOn; - auto &treeSchedEMSOn = state->dataScheduleMgr->Schedule(treeSchedNum).EMSActuatedOn; - auto &overhangSchedEMSValue = state->dataScheduleMgr->Schedule(overhangSchedNum).EMSValue; - auto &treeSchedEMSValue = state->dataScheduleMgr->Schedule(treeSchedNum).EMSValue; + auto *overhangSched = dynamic_cast(state->dataSurface->Surface(overhangSurfNum).shadowSurfSched); + auto *treeSched = dynamic_cast(state->dataSurface->Surface(treeSurfNum).shadowSurfSched); // Overhang transparent, Tree transparent - overhangSchedEMSOn = true; - treeSchedEMSOn = true; - overhangSchedEMSValue = 1.0; - treeSchedEMSValue = 1.0; + overhangSched->EMSActuatedOn = true; + treeSched->EMSActuatedOn = true; + overhangSched->EMSVal = 1.0; + treeSched->EMSVal = 1.0; FigureSolarBeamAtTimestep(*state, state->dataGlobal->HourOfDay, state->dataGlobal->TimeStep); ReportSurfaceShading(*state); @@ -4280,10 +4260,10 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_PolygonOverlap) EXPECT_NEAR(1.0, state->dataSurface->SurfSunlitFrac(winSurfNum), 0.0001); // Overhang opaque, Tree transparent - overhangSchedEMSOn = true; - treeSchedEMSOn = true; - overhangSchedEMSValue = 0.0; - treeSchedEMSValue = 1.0; + overhangSched->EMSActuatedOn = true; + treeSched->EMSActuatedOn = true; + overhangSched->EMSVal = 0.0; + treeSched->EMSVal = 1.0; FigureSolarBeamAtTimestep(*state, state->dataGlobal->HourOfDay, state->dataGlobal->TimeStep); ReportSurfaceShading(*state); @@ -4293,10 +4273,10 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_PolygonOverlap) EXPECT_NEAR(0.76955, winSunLitFracOverhangOnly, 0.0001); // Overhang tranparent, Tree opaque - overhangSchedEMSOn = true; - treeSchedEMSOn = true; - overhangSchedEMSValue = 1.0; - treeSchedEMSValue = 0.0; + overhangSched->EMSActuatedOn = true; + treeSched->EMSActuatedOn = true; + overhangSched->EMSVal = 1.0; + treeSched->EMSVal = 0.0; FigureSolarBeamAtTimestep(*state, state->dataGlobal->HourOfDay, state->dataGlobal->TimeStep); ReportSurfaceShading(*state); @@ -4306,10 +4286,10 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_PolygonOverlap) EXPECT_NEAR(0.05484, winSunLitFracTreeOnly, 0.0001); // Overhang opaque, Tree opaque - overhangSchedEMSOn = true; - treeSchedEMSOn = true; - overhangSchedEMSValue = 0.0; - treeSchedEMSValue = 0.0; + overhangSched->EMSActuatedOn = true; + treeSched->EMSActuatedOn = true; + overhangSched->EMSVal = 0.0; + treeSched->EMSVal = 0.0; FigureSolarBeamAtTimestep(*state, state->dataGlobal->HourOfDay, state->dataGlobal->TimeStep); ReportSurfaceShading(*state); @@ -4320,8 +4300,8 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_PolygonOverlap) // Use the base transmittance schedules (no EMS override) // Overhang transmittance = 0.5, Tree transmittance = 0.8 - overhangSchedEMSOn = false; - treeSchedEMSOn = false; + overhangSched->EMSActuatedOn = false; + treeSched->EMSActuatedOn = false; FigureSolarBeamAtTimestep(*state, state->dataGlobal->HourOfDay, state->dataGlobal->TimeStep); ReportSurfaceShading(*state); @@ -4360,10 +4340,10 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_PolygonOverlap) state->dataSolarShading->CalcSkyDifShading = false; // Overhang transparent, Tree transparent - overhangSchedEMSOn = true; - treeSchedEMSOn = true; - overhangSchedEMSValue = 1.0; - treeSchedEMSValue = 1.0; + overhangSched->EMSActuatedOn = true; + treeSched->EMSActuatedOn = true; + overhangSched->EMSVal = 1.0; + treeSched->EMSVal = 1.0; FigureSolarBeamAtTimestep(*state, state->dataGlobal->HourOfDay, state->dataGlobal->TimeStep); ReportSurfaceShading(*state); @@ -4371,10 +4351,10 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_PolygonOverlap) EXPECT_NEAR(1.0, state->dataSurface->SurfSunlitFrac(winSurfNum), 0.0001); // Overhang opaque, Tree transparent - overhangSchedEMSOn = true; - treeSchedEMSOn = true; - overhangSchedEMSValue = 0.0; - treeSchedEMSValue = 1.0; + overhangSched->EMSActuatedOn = true; + treeSched->EMSActuatedOn = true; + overhangSched->EMSVal = 0.0; + treeSched->EMSVal = 1.0; FigureSolarBeamAtTimestep(*state, state->dataGlobal->HourOfDay, state->dataGlobal->TimeStep); ReportSurfaceShading(*state); @@ -4384,10 +4364,10 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_PolygonOverlap) EXPECT_NEAR(0.08560, winSunLitFracOverhangOnly, 0.0001); // Overhang tranparent, Tree opaque - overhangSchedEMSOn = true; - treeSchedEMSOn = true; - overhangSchedEMSValue = 1.0; - treeSchedEMSValue = 0.0; + overhangSched->EMSActuatedOn = true; + treeSched->EMSActuatedOn = true; + overhangSched->EMSVal = 1.0; + treeSched->EMSVal = 0.0; FigureSolarBeamAtTimestep(*state, state->dataGlobal->HourOfDay, state->dataGlobal->TimeStep); ReportSurfaceShading(*state); @@ -4397,10 +4377,10 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_PolygonOverlap) EXPECT_NEAR(0.60655, winSunLitFracTreeOnly, 0.0001); // Overhang opaque, Tree opaque - overhangSchedEMSOn = true; - treeSchedEMSOn = true; - overhangSchedEMSValue = 0.0; - treeSchedEMSValue = 0.0; + overhangSched->EMSActuatedOn = true; + treeSched->EMSActuatedOn = true; + overhangSched->EMSVal = 0.0; + treeSched->EMSVal = 0.0; FigureSolarBeamAtTimestep(*state, state->dataGlobal->HourOfDay, state->dataGlobal->TimeStep); ReportSurfaceShading(*state); wallSunLitFracOverhangTree = state->dataSurface->SurfSunlitFrac(wallSurfNum); @@ -4411,8 +4391,8 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_PolygonOverlap) // Use the base transmittance schedules (no EMS override) // Overhang transmittance = 0.5, Tree transmittance = 0.8 - overhangSchedEMSOn = false; - treeSchedEMSOn = false; + overhangSched->EMSActuatedOn = false; + treeSched->EMSActuatedOn = false; FigureSolarBeamAtTimestep(*state, state->dataGlobal->HourOfDay, state->dataGlobal->TimeStep); ReportSurfaceShading(*state); @@ -4611,15 +4591,14 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_PolygonOverlap2) }); ASSERT_TRUE(process_idf(idf_objects)); - - SimulationManager::GetProjectData(*state); + state->init_state(*state); + bool FoundError = false; HeatBalanceManager::GetProjectControlData(*state, FoundError); // read project control data EXPECT_FALSE(FoundError); // expect no errors HeatBalanceManager::SetPreConstructionInputParameters(*state); - ScheduleManager::ProcessScheduleInput(*state); // read schedules Material::GetMaterialData(*state, FoundError); EXPECT_FALSE(FoundError); @@ -4643,8 +4622,8 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_PolygonOverlap2) state->dataSurfaceGeometry->CosZoneRelNorth.allocate(1); state->dataSurfaceGeometry->SinZoneRelNorth.allocate(1); - state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); - state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); + state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); + state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); state->dataSurfaceGeometry->CosBldgRelNorth = 1.0; state->dataSurfaceGeometry->SinBldgRelNorth = 0.0; @@ -4689,20 +4668,14 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_PolygonOverlap2) int shade2SurfNum = Util::FindItemInList("ZN001:WALL-SOUTH:SHADE2", state->dataSurface->Surface); // Get shading surface schedule indexes - int shade1SchedNum = state->dataSurface->Surface(shade1SurfNum).SchedShadowSurfIndex; - int shade2SchedNum = state->dataSurface->Surface(shade2SurfNum).SchedShadowSurfIndex; - - // Use EMS to turn shading surfaces on and off - auto &shade1SchedEMSOn = state->dataScheduleMgr->Schedule(shade1SchedNum).EMSActuatedOn; - auto &shade2SchedEMSOn = state->dataScheduleMgr->Schedule(shade2SchedNum).EMSActuatedOn; - auto &shade1SchedEMSValue = state->dataScheduleMgr->Schedule(shade1SchedNum).EMSValue; - auto &shade2SchedEMSValue = state->dataScheduleMgr->Schedule(shade2SchedNum).EMSValue; + auto *shade1Sched = state->dataSurface->Surface(shade1SurfNum).shadowSurfSched; + auto *shade2Sched = state->dataSurface->Surface(shade2SurfNum).shadowSurfSched; // shade1 transparent, shade2 transparent - shade1SchedEMSOn = true; - shade2SchedEMSOn = true; - shade1SchedEMSValue = 1.0; - shade2SchedEMSValue = 1.0; + shade1Sched->EMSActuatedOn = true; + shade2Sched->EMSActuatedOn = true; + shade1Sched->EMSVal = 1.0; + shade2Sched->EMSVal = 1.0; // Gotten from running 1ZoneUncontrolled.idf with chicago weather on Jan 1 at 12 state->dataBSDFWindow->SUNCOSTS(state->dataGlobal->TimeStep, state->dataGlobal->HourOfDay)(1) = 0.20531446332266728; @@ -4715,10 +4688,10 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_PolygonOverlap2) EXPECT_NEAR(1.0, state->dataSurface->SurfSunlitFrac(winSurfNum), 0.0001); // shade1 opaque, shade2 transparent - shade1SchedEMSOn = true; - shade2SchedEMSOn = true; - shade1SchedEMSValue = 0.0; - shade2SchedEMSValue = 1.0; + shade1Sched->EMSActuatedOn = true; + shade2Sched->EMSActuatedOn = true; + shade1Sched->EMSVal = 0.0; + shade2Sched->EMSVal = 1.0; FigureSolarBeamAtTimestep(*state, state->dataGlobal->HourOfDay, state->dataGlobal->TimeStep); ReportSurfaceShading(*state); @@ -4728,10 +4701,10 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_PolygonOverlap2) EXPECT_NEAR(0.0, winSunLitFracShade1Only, 0.0001); // shade1 transparent, shade2 opaque - shade1SchedEMSOn = true; - shade2SchedEMSOn = true; - shade1SchedEMSValue = 1.0; - shade2SchedEMSValue = 0.0; + shade1Sched->EMSActuatedOn = true; + shade2Sched->EMSActuatedOn = true; + shade1Sched->EMSVal = 1.0; + shade2Sched->EMSVal = 0.0; FigureSolarBeamAtTimestep(*state, state->dataGlobal->HourOfDay, state->dataGlobal->TimeStep); ReportSurfaceShading(*state); @@ -4741,10 +4714,10 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_PolygonOverlap2) EXPECT_NEAR(0.0, winSunLitFracShade2Only, 0.0001); // shade1 opaque, shade2 opaque - shade1SchedEMSOn = true; - shade2SchedEMSOn = true; - shade1SchedEMSValue = 0.0; - shade2SchedEMSValue = 0.0; + shade1Sched->EMSActuatedOn = true; + shade2Sched->EMSActuatedOn = true; + shade1Sched->EMSVal = 0.0; + shade2Sched->EMSVal = 0.0; FigureSolarBeamAtTimestep(*state, state->dataGlobal->HourOfDay, state->dataGlobal->TimeStep); ReportSurfaceShading(*state); @@ -4755,8 +4728,8 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_PolygonOverlap2) // Use the base transmittance schedules (no EMS override) // shade1 transmittance = 0.5, shade2 transmittance = 0.8 - shade1SchedEMSOn = false; - shade2SchedEMSOn = false; + shade1Sched->EMSActuatedOn = false; + shade2Sched->EMSActuatedOn = false; FigureSolarBeamAtTimestep(*state, state->dataGlobal->HourOfDay, state->dataGlobal->TimeStep); ReportSurfaceShading(*state); @@ -4978,15 +4951,14 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_PolygonOverlap3) }); ASSERT_TRUE(process_idf(idf_objects)); - - SimulationManager::GetProjectData(*state); + state->init_state(*state); + bool FoundError = false; HeatBalanceManager::GetProjectControlData(*state, FoundError); // read project control data EXPECT_FALSE(FoundError); // expect no errors HeatBalanceManager::SetPreConstructionInputParameters(*state); - ScheduleManager::ProcessScheduleInput(*state); // read schedules Material::GetMaterialData(*state, FoundError); EXPECT_FALSE(FoundError); @@ -5010,8 +4982,8 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_PolygonOverlap3) state->dataSurfaceGeometry->CosZoneRelNorth.allocate(1); state->dataSurfaceGeometry->SinZoneRelNorth.allocate(1); - state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); - state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); + state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); + state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); state->dataSurfaceGeometry->CosBldgRelNorth = 1.0; state->dataSurfaceGeometry->SinBldgRelNorth = 0.0; @@ -5110,7 +5082,7 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_checkScheduledSurfacePresent) } TEST_F(EnergyPlusFixture, SolarShadingTest_CalcBeamSolarOnWinRevealSurface) { - state->dataGlobal->NumOfTimeStepInHour = 6; + state->dataGlobal->TimeStepsInHour = 6; state->dataSurface->FrameDivider.allocate(2); auto &frameDivider1 = state->dataSurface->FrameDivider(1); @@ -5545,22 +5517,21 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_CalcInteriorSolarDistribution_Detaile }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); - SimulationManager::GetProjectData(*state); bool FoundError = false; HeatBalanceManager::GetProjectControlData(*state, FoundError); // read project control data EXPECT_FALSE(FoundError); // expect no errors HeatBalanceManager::SetPreConstructionInputParameters(*state); - ScheduleManager::ProcessScheduleInput(*state); // read schedules HeatBalanceManager::GetHeatBalanceInput(*state); state->dataSurfaceGeometry->CosZoneRelNorth.allocate(1); state->dataSurfaceGeometry->SinZoneRelNorth.allocate(1); - state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); - state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); + state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); + state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); state->dataSurfaceGeometry->CosBldgRelNorth = 1.0; state->dataSurfaceGeometry->SinBldgRelNorth = 0.0; @@ -5917,22 +5888,21 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_CalcInteriorSolarDistribution_EQL) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); - SimulationManager::GetProjectData(*state); bool FoundError = false; HeatBalanceManager::GetProjectControlData(*state, FoundError); // read project control data EXPECT_FALSE(FoundError); // expect no errors HeatBalanceManager::SetPreConstructionInputParameters(*state); - ScheduleManager::ProcessScheduleInput(*state); // read schedules HeatBalanceManager::GetHeatBalanceInput(*state); state->dataSurfaceGeometry->CosZoneRelNorth.allocate(1); state->dataSurfaceGeometry->SinZoneRelNorth.allocate(1); - state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); - state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); + state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); + state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); state->dataSurfaceGeometry->CosBldgRelNorth = 1.0; state->dataSurfaceGeometry->SinBldgRelNorth = 0.0; @@ -6002,7 +5972,7 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_GetShadowingInputTest1) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->dataSolarShading->anyScheduledShadingSurface = false; // Test 1 of 6: Polygon Clipping and ConvexWeilerAtherton @@ -6035,7 +6005,7 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_GetShadowingInputTest2) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->dataSolarShading->anyScheduledShadingSurface = false; // Test 2 of 6: Polygon Clipping and SutherlandHodgman @@ -6068,7 +6038,6 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_GetShadowingInputTest3) }); ASSERT_TRUE(process_idf(idf_objects)); - state->dataSolarShading->anyScheduledShadingSurface = false; // Test 3 of 6: Polygon Clipping and SlaterBarskyandSutherlandHodgman @@ -6101,7 +6070,6 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_GetShadowingInputTest4) }); ASSERT_TRUE(process_idf(idf_objects)); - state->dataSolarShading->anyScheduledShadingSurface = false; // Test 4 of 6: Pixel Counting and ConvexWeilerAtherton @@ -6143,7 +6111,6 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_GetShadowingInputTest5) }); ASSERT_TRUE(process_idf(idf_objects)); - state->dataSolarShading->anyScheduledShadingSurface = false; // Test 5 of 6: Pixel Counting and SutherlandHodgman diff --git a/tst/EnergyPlus/unit/StandardRatings.unit.cc b/tst/EnergyPlus/unit/StandardRatings.unit.cc index 406d05f688f..c819774747f 100644 --- a/tst/EnergyPlus/unit/StandardRatings.unit.cc +++ b/tst/EnergyPlus/unit/StandardRatings.unit.cc @@ -101,7 +101,7 @@ TEST_F(EnergyPlusFixture, SingleSpeedHeatingCoilCurveTest) Coil.Name = "DX Single Speed Heating Coil"; Coil.DXCoilType = "Coil:Heating:DX:SingleSpeed"; Coil.DXCoilType_Num = HVAC::CoilDX_HeatingEmpirical; - Coil.SchedPtr = ScheduleManager::ScheduleAlwaysOn; + Coil.availSched = Sched::GetScheduleAlwaysOn(*state); Coil.RatedSHR(1) = 1.0; Coil.RatedTotCap(1) = 1600.0; Coil.RatedCOP(1) = 4.0; @@ -297,7 +297,7 @@ TEST_F(EnergyPlusFixture, SingleSpeedHeatingCoilCurveTest_PositiveCurve) Coil.Name = "DX Single Speed Heating Coil"; Coil.DXCoilType = "Coil:Heating:DX:SingleSpeed"; Coil.DXCoilType_Num = HVAC::CoilDX_HeatingEmpirical; - Coil.SchedPtr = ScheduleManager::ScheduleAlwaysOn; + Coil.availSched = Sched::GetScheduleAlwaysOn(*state); Coil.RatedSHR(1) = 1.0; Coil.RatedTotCap(1) = 1600.0; Coil.RatedCOP(1) = 4.0; @@ -484,7 +484,7 @@ TEST_F(EnergyPlusFixture, SingleSpeedHeatingCoilCurveTest2023) Coil.Name = "HeatingCoilDXSingleSpeedAutosize"; Coil.DXCoilType = "Coil:Heating:DX:SingleSpeed"; Coil.DXCoilType_Num = HVAC::CoilDX_HeatingEmpirical; - Coil.SchedPtr = ScheduleManager::ScheduleAlwaysOn; + Coil.availSched = Sched::GetScheduleAlwaysOn(*state); Coil.RatedSHR(1) = 1.0; Coil.RatedTotCap(1) = 1600.0; Coil.RatedCOP(1) = 3.8; // @@ -739,6 +739,8 @@ TEST_F(EnergyPlusFixture, SingleSpeedHeatingCurveTest2023_II) ASSERT_TRUE(process_idf(idf_objects1)); + state->init_state(*state); + GetDXCoils(*state); auto &Coil(state->dataDXCoils->DXCoil(1)); @@ -967,6 +969,8 @@ TEST_F(EnergyPlusFixture, MultiSpeedHeatingCoil_HSPFValueTest_2Speed) ASSERT_TRUE(process_idf(idf_objects1)); + state->init_state(*state); + GetDXCoils(*state); auto &Coil(state->dataDXCoils->DXCoil(1)); @@ -1430,6 +1434,8 @@ TEST_F(EnergyPlusFixture, SingleSpeedCoolingCoil_15000W_SameFanPower_SEER2_2023_ ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + GetDXCoils(*state); auto &thisCoil(state->dataDXCoils->DXCoil(1)); @@ -1697,6 +1703,8 @@ TEST_F(EnergyPlusFixture, SingleSpeedCoolingCoil_9000W_SEER2_2023_ValueTest) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + GetDXCoils(*state); auto &thisCoil(state->dataDXCoils->DXCoil(1)); @@ -1963,6 +1971,8 @@ TEST_F(EnergyPlusFixture, SingleSpeedCoolingCoil_18000W_SEER2_2023_ValueTest) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + GetDXCoils(*state); auto &thisCoil(state->dataDXCoils->DXCoil(1)); @@ -2219,6 +2229,8 @@ TEST_F(EnergyPlusFixture, SingleSpeedCoolingCoilAir_25000W_IEER_2022_ValueTest) ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + GetDXCoils(*state); auto &thisCoil(state->dataDXCoils->DXCoil(1)); @@ -2369,6 +2381,8 @@ TEST_F(EnergyPlusFixture, SingleSpeedCoolingCoilEvap_32000W_IEER_2022_ValueTest) ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + GetDXCoils(*state); auto &thisCoil(state->dataDXCoils->DXCoil(1)); @@ -2513,6 +2527,8 @@ TEST_F(EnergyPlusFixture, SingleSpeedCoolingCoilAir_AHRIExample_IEER_2022_ValueT ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + GetDXCoils(*state); auto &thisCoil(state->dataDXCoils->DXCoil(1)); @@ -2999,6 +3015,8 @@ TEST_F(EnergyPlusFixture, MultiSpeedCoolingCoil_02_Speed_4400W_SEER2_2023_ValueT ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + GetDXCoils(*state); auto &thisCoil(state->dataDXCoils->DXCoil(1)); @@ -3593,6 +3611,8 @@ TEST_F(EnergyPlusFixture, MultiSpeedCoolingCoil_03_Speed_12000W_SEER2_2023_Value ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + GetDXCoils(*state); auto &thisCoil(state->dataDXCoils->DXCoil(1)); @@ -4142,6 +4162,7 @@ TEST_F(EnergyPlusFixture, MultiSpeedCoolingCoil_04_Speed_17750W_SEER2_2023_Value }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); GetDXCoils(*state); @@ -4329,6 +4350,8 @@ TEST_F(EnergyPlusFixture, MultiSpeedCoolingCoil_02_Speeds_27717W_IEER_2022_Value }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + GetDXCoils(*state); auto &thisCoil(state->dataDXCoils->DXCoil(1)); auto &thisCoolPLFfPLR(state->dataCurveManager->PerfCurve(thisCoil.MSPLFFPLR(1))); @@ -4798,6 +4821,8 @@ TEST_F(EnergyPlusFixture, MultiSpeedCoolingCoil_03_Speeds_27717W_IEER_2022_Value ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + GetDXCoils(*state); auto &thisCoil(state->dataDXCoils->DXCoil(1)); auto &thisCoolPLFfPLR(state->dataCurveManager->PerfCurve(thisCoil.MSPLFFPLR(1))); @@ -5302,6 +5327,8 @@ TEST_F(EnergyPlusFixture, MultiSpeedCoolingCoil_04_Speeds_35500W_COP3_IEER_2022_ }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + GetDXCoils(*state); auto &thisCoil(state->dataDXCoils->DXCoil(1)); auto &thisCoolPLFfPLR(state->dataCurveManager->PerfCurve(thisCoil.MSPLFFPLR(1))); @@ -5556,6 +5583,8 @@ TEST_F(EnergyPlusFixture, MultiSpeedCoolingCoil_04_Speed_35500W_COP4_IEER_2022_V ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + GetDXCoils(*state); auto &thisCoil(state->dataDXCoils->DXCoil(1)); @@ -5706,6 +5735,8 @@ TEST_F(EnergyPlusFixture, VariableSpeedCooling_01_Speed_7200W_SEER2_2023_ValueTe ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + // get coil inputs EnergyPlus::VariableSpeedCoils::GetVarSpeedCoilInput(*state); EXPECT_EQ(state->dataVariableSpeedCoils->VarSpeedCoil(1).Name, "ZONE1PTHPDXCOOLCOIL"); @@ -5937,6 +5968,8 @@ TEST_F(EnergyPlusFixture, VariableSpeedCooling_02_Speed_7200W_SEER2_2023_ValueTe ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + // get coil inputs EnergyPlus::VariableSpeedCoils::GetVarSpeedCoilInput(*state); EXPECT_EQ(state->dataVariableSpeedCoils->VarSpeedCoil(1).Name, "ZONE1PTHPDXCOOLCOIL"); @@ -6177,6 +6210,7 @@ TEST_F(EnergyPlusFixture, VariableSpeedCooling_03_Speed_7200W_SEER2_2023_ValueTe }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); // get coil inputs EnergyPlus::VariableSpeedCoils::GetVarSpeedCoilInput(*state); EXPECT_EQ(state->dataVariableSpeedCoils->VarSpeedCoil(1).Name, "ZONE1PTHPDXCOOLCOIL"); @@ -6430,6 +6464,7 @@ TEST_F(EnergyPlusFixture, VariableSpeedCooling_04_Speed_7200W_SEER2_2023_ValueTe ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); // get coil inputs EnergyPlus::VariableSpeedCoils::GetVarSpeedCoilInput(*state); EXPECT_EQ(state->dataVariableSpeedCoils->VarSpeedCoil(1).Name, "ZONE1PTHPDXCOOLCOIL"); @@ -6720,6 +6755,8 @@ TEST_F(EnergyPlusFixture, VariableSpeedCooling_07_Speed_7200W_SEER2_2023_ValueTe }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + // get coil inputs EnergyPlus::VariableSpeedCoils::GetVarSpeedCoilInput(*state); EXPECT_EQ(state->dataVariableSpeedCoils->VarSpeedCoil(1).Name, "ZONE1PTHPDXCOOLCOIL"); @@ -7012,6 +7049,7 @@ TEST_F(EnergyPlusFixture, VariableSpeedCooling_07_Speed_14400W_SEER2_2023_ValueT ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); // get coil inputs EnergyPlus::VariableSpeedCoils::GetVarSpeedCoilInput(*state); EXPECT_EQ(state->dataVariableSpeedCoils->VarSpeedCoil(1).Name, "ZONE1PTHPDXCOOLCOIL"); @@ -7339,6 +7377,8 @@ TEST_F(EnergyPlusFixture, VariableSpeedCooling_10_Speed_7200W_SEER2_2023_ValueTe ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + // get coil inputs EnergyPlus::VariableSpeedCoils::GetVarSpeedCoilInput(*state); EXPECT_EQ(state->dataVariableSpeedCoils->VarSpeedCoil(1).Name, "ZONE1PTHPDXCOOLCOIL"); @@ -7666,6 +7706,8 @@ TEST_F(EnergyPlusFixture, VariableSpeedCooling_10_Speed_14400W_SEER2_2023_ValueT ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + // get coil inputs EnergyPlus::VariableSpeedCoils::GetVarSpeedCoilInput(*state); EXPECT_EQ(state->dataVariableSpeedCoils->VarSpeedCoil(1).Name, "ZONE1PTHPDXCOOLCOIL"); @@ -7875,6 +7917,8 @@ TEST_F(EnergyPlusFixture, VariableSpeedCooling_01_Speed_22000W_IEER_2022_ValueTe ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + // get coil inputs EnergyPlus::VariableSpeedCoils::GetVarSpeedCoilInput(*state); EXPECT_EQ(state->dataVariableSpeedCoils->VarSpeedCoil(1).Name, "DESICCANT DXSYSTEM VS COOLING COIL"); @@ -8128,6 +8172,8 @@ TEST_F(EnergyPlusFixture, VariableSpeedCooling_02_Speed_36000W_IEER_2022_ValueTe ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + // get coil inputs EnergyPlus::VariableSpeedCoils::GetVarSpeedCoilInput(*state); EXPECT_EQ(state->dataVariableSpeedCoils->VarSpeedCoil(1).Name, "HEAT PUMP ACDXCOIL 1"); @@ -8432,6 +8478,8 @@ TEST_F(EnergyPlusFixture, VariableSpeedCooling_03_Speed_36000W_IEER_2022_ValueTe ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + // get coil inputs EnergyPlus::VariableSpeedCoils::GetVarSpeedCoilInput(*state); EXPECT_EQ(state->dataVariableSpeedCoils->VarSpeedCoil(1).Name, "HEAT PUMP ACDXCOIL 1"); @@ -8698,6 +8746,8 @@ TEST_F(EnergyPlusFixture, VariableSpeedCooling_04_Speed_36000W_IEER_2022_ValueTe ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + // get coil inputs EnergyPlus::VariableSpeedCoils::GetVarSpeedCoilInput(*state); EXPECT_EQ(state->dataVariableSpeedCoils->VarSpeedCoil(1).Name, "SYS 4 HEAT PUMP AIR SOURCE COOLING COIL"); @@ -8989,6 +9039,8 @@ TEST_F(EnergyPlusFixture, VariableSpeedCooling_07_Speed_25001W_IEER_2022_ValueTe ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + // get coil inputs EnergyPlus::VariableSpeedCoils::GetVarSpeedCoilInput(*state); EXPECT_EQ(state->dataVariableSpeedCoils->VarSpeedCoil(1).Name, "ZONE1PTHPDXCOOLCOIL"); @@ -9321,6 +9373,7 @@ TEST_F(EnergyPlusFixture, VariableSpeedCooling_10_Speed_34582W_IEER_2022_ValueTe ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); // get coil inputs EnergyPlus::VariableSpeedCoils::GetVarSpeedCoilInput(*state); EXPECT_EQ(state->dataVariableSpeedCoils->VarSpeedCoil(1).Name, "ZONE1PTHPDXCOOLCOIL"); @@ -9657,6 +9710,7 @@ TEST_F(EnergyPlusFixture, VariableSpeedCooling_10_Speed_32000W_IEER_2022_ValueTe ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); // get coil inputs EnergyPlus::VariableSpeedCoils::GetVarSpeedCoilInput(*state); EXPECT_EQ(state->dataVariableSpeedCoils->VarSpeedCoil(1).Name, "ZONE1PTHPDXCOOLCOIL"); @@ -10006,6 +10060,7 @@ TEST_F(EnergyPlusFixture, VariableSpeedCooling_04_Speed_AutoSize_IEER_2022_Value ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); // get coil inputs EnergyPlus::VariableSpeedCoils::GetVarSpeedCoilInput(*state); EXPECT_EQ(state->dataVariableSpeedCoils->VarSpeedCoil(1).Name, "HEAT PUMP ACDXCOIL 1"); @@ -10269,6 +10324,7 @@ TEST_F(EnergyPlusFixture, TwoSpeedCoolingCoilAir_18000W_SEER2_2023_ValueTest) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); GetDXCoils(*state); auto &thisCoil(state->dataDXCoils->DXCoil(1)); @@ -10559,6 +10615,8 @@ TEST_F(EnergyPlusFixture, TwoSpeedCoolingCoilAir_12000W_SEER2_2023_ValueTest) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + GetDXCoils(*state); auto &thisCoil(state->dataDXCoils->DXCoil(1)); @@ -10838,6 +10896,7 @@ TEST_F(EnergyPlusFixture, TwoSpeedCoolingCoilAir_39000W_IEER_2022_ValueTest) ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); GetDXCoils(*state); auto &thisCoil(state->dataDXCoils->DXCoil(1)); @@ -11127,6 +11186,7 @@ TEST_F(EnergyPlusFixture, TwoSpeedCoolingCoilAir_54000W_IEER_2022_ValueTest) ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); GetDXCoils(*state); auto &thisCoil(state->dataDXCoils->DXCoil(1)); @@ -11424,6 +11484,7 @@ TEST_F(EnergyPlusFixture, TwoSpeedCoolingCoilAir_33000W_IEER_2022_ValueTest) ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); GetDXCoils(*state); auto &thisCoil(state->dataDXCoils->DXCoil(1)); @@ -11723,6 +11784,7 @@ TEST_F(EnergyPlusFixture, CurveFit_02_Speed_15000W_alternateMode_SEER2_2023_Valu }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); int coilIndex = CoilCoolingDX::factory(*state, "DX Cooling Coil"); auto &thisCoil(state->dataCoilCooingDX->coilCoolingDXs[coilIndex]); @@ -12044,6 +12106,7 @@ TEST_F(EnergyPlusFixture, CurveFit_03_Speed_5000W_SEER2_2023_ValueTest) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); int coilIndex = CoilCoolingDX::factory(*state, "Sys 2 Furnace DX Cool Cooling Coil"); auto &thisCoil(state->dataCoilCooingDX->coilCoolingDXs[coilIndex]); @@ -12347,6 +12410,7 @@ TEST_F(EnergyPlusFixture, CurveFit_02_Speed_30000W_alternateMode_IEER_2022_Value }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); int coilIndex = CoilCoolingDX::factory(*state, "DX Cooling Coil"); auto &thisCoil(state->dataCoilCooingDX->coilCoolingDXs[coilIndex]); @@ -12666,6 +12730,7 @@ TEST_F(EnergyPlusFixture, CurveFit_03_Speed_20000W_IEER_2022_ValueTest) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); int coilIndex = CoilCoolingDX::factory(*state, "Sys 2 Furnace DX Cool Cooling Coil"); auto &thisCoil(state->dataCoilCooingDX->coilCoolingDXs[coilIndex]); diff --git a/tst/EnergyPlus/unit/SurfaceGeometry.unit.cc b/tst/EnergyPlus/unit/SurfaceGeometry.unit.cc index 93de593d4f2..50ca190ebb3 100644 --- a/tst/EnergyPlus/unit/SurfaceGeometry.unit.cc +++ b/tst/EnergyPlus/unit/SurfaceGeometry.unit.cc @@ -55,6 +55,7 @@ #include #include #include +#include #include #include #include @@ -86,7 +87,7 @@ using namespace EnergyPlus::Material; TEST_F(EnergyPlusFixture, BaseSurfaceRectangularTest) { - + state->init_state(*state); // Test base surfaces for rectangular shape in ProcessSurfaceVertices state->dataSurface->TotSurfaces = 5; @@ -238,7 +239,6 @@ TEST_F(EnergyPlusFixture, BaseSurfaceRectangularTest) TEST_F(EnergyPlusFixture, DataSurfaces_SurfaceShape) { - bool ErrorsFound(false); std::string const idf_objects = delimited_string({ @@ -484,9 +484,7 @@ TEST_F(EnergyPlusFixture, DataSurfaces_SurfaceShape) }); ASSERT_TRUE(process_idf(idf_objects)); - - GetProjectControlData(*state, ErrorsFound); // read project control data - EXPECT_FALSE(ErrorsFound); // expect no errors + state->init_state(*state); GetMaterialData(*state, ErrorsFound); // read material data EXPECT_FALSE(ErrorsFound); // expect no errors @@ -500,8 +498,8 @@ TEST_F(EnergyPlusFixture, DataSurfaces_SurfaceShape) state->dataSurfaceGeometry->CosZoneRelNorth.allocate(1); state->dataSurfaceGeometry->SinZoneRelNorth.allocate(1); - state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); - state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); + state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); + state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); state->dataSurfaceGeometry->CosBldgRelNorth = 1.0; state->dataSurfaceGeometry->SinBldgRelNorth = 0.0; @@ -581,6 +579,7 @@ TEST_F(EnergyPlusFixture, DataSurfaces_SurfaceShape) TEST_F(EnergyPlusFixture, ConfirmCheckSubSurfAzTiltNorm) { + state->init_state(*state); SurfaceData BaseSurface; SurfaceData SubSurface; bool surfaceError; @@ -600,7 +599,8 @@ TEST_F(EnergyPlusFixture, ConfirmCheckSubSurfAzTiltNorm) SubSurface.NewellSurfaceNormalVector.z = 1.; checkSubSurfAzTiltNorm(*state, BaseSurface, SubSurface, surfaceError); EXPECT_FALSE(surfaceError); - EXPECT_FALSE(has_err_output()); + EXPECT_EQ(state->dataErrTracking->TotalSevereErrors, 0); + EXPECT_EQ(state->dataErrTracking->TotalWarningErrors, 1); // IDF version object // Case 2 - Base surface and subsurface face the opposite way - should be error message and surfaceError=true surfaceError = false; @@ -711,6 +711,7 @@ TEST_F(EnergyPlusFixture, SurfaceGeometry_MakeMirrorSurface) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); bool FoundError = false; GetMaterialData(*state, FoundError); @@ -772,6 +773,7 @@ TEST_F(EnergyPlusFixture, SurfaceGeometry_MakeMirrorSurface) TEST_F(EnergyPlusFixture, SurfacesGeometry_CalcSurfaceCentroid_NonconvexRealisticZ) { + state->init_state(*state); state->dataSurface->TotSurfaces = 10; state->dataSurface->Surface.allocate(state->dataSurface->TotSurfaces); @@ -805,7 +807,6 @@ TEST_F(EnergyPlusFixture, SurfacesGeometry_CalcSurfaceCentroid_NonconvexRealisti TEST_F(EnergyPlusFixture, MakeEquivalentRectangle) { - bool ErrorsFound(false); std::string const idf_objects = delimited_string({ @@ -949,6 +950,8 @@ TEST_F(EnergyPlusFixture, MakeEquivalentRectangle) // Prepare data for the test ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + GetMaterialData(*state, ErrorsFound); // read material data EXPECT_FALSE(ErrorsFound); GetConstructData(*state, ErrorsFound); // read construction data @@ -959,8 +962,8 @@ TEST_F(EnergyPlusFixture, MakeEquivalentRectangle) EXPECT_FALSE(ErrorsFound); state->dataSurfaceGeometry->CosZoneRelNorth.allocate(1); state->dataSurfaceGeometry->SinZoneRelNorth.allocate(1); - state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); - state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); + state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); + state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); state->dataSurfaceGeometry->CosBldgRelNorth = 1.0; state->dataSurfaceGeometry->SinBldgRelNorth = 0.0; GetSurfaceData(*state, ErrorsFound); // setup zone geometry and get zone data @@ -989,7 +992,6 @@ TEST_F(EnergyPlusFixture, MakeEquivalentRectangle) TEST_F(EnergyPlusFixture, SurfaceGeometryUnitTests_distance) { - DataVectorTypes::Vector a; DataVectorTypes::Vector b; @@ -2814,8 +2816,8 @@ TEST_F(EnergyPlusFixture, MakeRectangularVertices) state->dataSurfaceGeometry->CosZoneRelNorth.allocate(zoneNum); state->dataSurfaceGeometry->SinZoneRelNorth.allocate(zoneNum); - state->dataSurfaceGeometry->CosZoneRelNorth(zoneNum) = std::cos(-state->dataHeatBal->Zone(zoneNum).RelNorth * Constant::DegToRadians); - state->dataSurfaceGeometry->SinZoneRelNorth(zoneNum) = std::sin(-state->dataHeatBal->Zone(zoneNum).RelNorth * Constant::DegToRadians); + state->dataSurfaceGeometry->CosZoneRelNorth(zoneNum) = std::cos(-state->dataHeatBal->Zone(zoneNum).RelNorth * Constant::DegToRad); + state->dataSurfaceGeometry->SinZoneRelNorth(zoneNum) = std::sin(-state->dataHeatBal->Zone(zoneNum).RelNorth * Constant::DegToRad); state->dataSurfaceGeometry->CosBldgRelNorth = 1.0; state->dataSurfaceGeometry->SinBldgRelNorth = 0.0; @@ -2964,6 +2966,7 @@ TEST_F(EnergyPlusFixture, SurfaceGeometry_VertexNumberMismatchTest) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); state->dataGlobal->NumOfZones = 2; state->dataHeatBal->Zone.allocate(2); @@ -3697,12 +3700,12 @@ TEST_F(EnergyPlusFixture, SurfaceGeometry_isWindowShadingControlSimilar_Test) state->dataSurface->WindowShadingControl(1).ShadingType = WinShadingType::ExtShade; state->dataSurface->WindowShadingControl(1).ShadingDevice = 17; state->dataSurface->WindowShadingControl(1).shadingControlType = WindowShadingControlType::OnIfScheduled; - state->dataSurface->WindowShadingControl(1).Schedule = 83; + state->dataSurface->WindowShadingControl(1).sched = nullptr; state->dataSurface->WindowShadingControl(1).SetPoint = 200; state->dataSurface->WindowShadingControl(1).SetPoint2 = 170; state->dataSurface->WindowShadingControl(1).ShadingControlIsScheduled = true; state->dataSurface->WindowShadingControl(1).GlareControlIsActive = false; - state->dataSurface->WindowShadingControl(1).SlatAngleSchedule = 84; + state->dataSurface->WindowShadingControl(1).slatAngleSched = nullptr; state->dataSurface->WindowShadingControl(1).slatAngleControl = SlatAngleControl::BlockBeamSolar; state->dataSurface->WindowShadingControl(1).DaylightingControlName = "TheDaylightingControl"; state->dataSurface->WindowShadingControl(1).DaylightControlIndex = 7; @@ -3738,11 +3741,11 @@ TEST_F(EnergyPlusFixture, SurfaceGeometry_isWindowShadingControlSimilar_Test) EXPECT_TRUE(isWindowShadingControlSimilar(*state, 1, 2)); state->dataSurface->WindowShadingControl(2) = state->dataSurface->WindowShadingControl(1); - state->dataSurface->WindowShadingControl(2).Schedule = 91; + state->dataSurface->WindowShadingControl(2).sched = Sched::GetScheduleAlwaysOn(*state); EXPECT_TRUE(isWindowShadingControlSimilar(*state, 1, 2)); state->dataSurface->WindowShadingControl(2) = state->dataSurface->WindowShadingControl(1); - state->dataSurface->WindowShadingControl(2).SlatAngleSchedule = 76; + state->dataSurface->WindowShadingControl(2).slatAngleSched = Sched::GetScheduleAlwaysOff(*state); EXPECT_TRUE(isWindowShadingControlSimilar(*state, 1, 2)); state->dataSurface->WindowShadingControl(2) = state->dataSurface->WindowShadingControl(1); @@ -3823,12 +3826,12 @@ TEST_F(EnergyPlusFixture, SurfaceGeometry_CheckWindowShadingControlSimilarForWin state->dataSurface->WindowShadingControl(1).ShadingType = WinShadingType::ExtShade; state->dataSurface->WindowShadingControl(1).ShadingDevice = 17; state->dataSurface->WindowShadingControl(1).shadingControlType = WindowShadingControlType::OnIfScheduled; - state->dataSurface->WindowShadingControl(1).Schedule = 83; + state->dataSurface->WindowShadingControl(1).sched = nullptr; state->dataSurface->WindowShadingControl(1).SetPoint = 200; state->dataSurface->WindowShadingControl(1).SetPoint2 = 170; state->dataSurface->WindowShadingControl(1).ShadingControlIsScheduled = true; state->dataSurface->WindowShadingControl(1).GlareControlIsActive = false; - state->dataSurface->WindowShadingControl(1).SlatAngleSchedule = 84; + state->dataSurface->WindowShadingControl(1).slatAngleSched = nullptr; state->dataSurface->WindowShadingControl(1).slatAngleControl = SlatAngleControl::BlockBeamSolar; state->dataSurface->WindowShadingControl(1).DaylightingControlName = "TheDaylightingControl"; state->dataSurface->WindowShadingControl(1).DaylightControlIndex = 7; @@ -4105,6 +4108,7 @@ TEST_F(EnergyPlusFixture, SurfaceGeometry_HeatTransferAlgorithmTest) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); GetProjectControlData(*state, ErrorsFound); // read project control data EXPECT_FALSE(ErrorsFound); // expect no errors @@ -4121,8 +4125,8 @@ TEST_F(EnergyPlusFixture, SurfaceGeometry_HeatTransferAlgorithmTest) state->dataSurfaceGeometry->CosZoneRelNorth.allocate(2); state->dataSurfaceGeometry->SinZoneRelNorth.allocate(2); - state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); - state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); + state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); + state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); state->dataSurfaceGeometry->CosZoneRelNorth(2) = state->dataSurfaceGeometry->CosZoneRelNorth(1); state->dataSurfaceGeometry->SinZoneRelNorth(2) = state->dataSurfaceGeometry->SinZoneRelNorth(1); state->dataSurfaceGeometry->CosBldgRelNorth = 1.0; @@ -4221,6 +4225,7 @@ TEST_F(EnergyPlusFixture, SurfaceGeometry_SurfaceReferencesNonExistingSurface) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); // Read Material and Construction, and expect no errors GetMaterialData(*state, ErrorsFound); @@ -4580,6 +4585,7 @@ TEST_F(EnergyPlusFixture, SurfaceGeometry_InternalMassSurfacesCount) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); // Read Materials GetMaterialData(*state, ErrorsFound); @@ -4921,6 +4927,7 @@ TEST_F(EnergyPlusFixture, SurfaceGeometry_CreateInternalMassSurfaces) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); // Read Materials GetMaterialData(*state, ErrorsFound); @@ -4989,6 +4996,7 @@ TEST_F(EnergyPlusFixture, WorldCoord_with_RelativeRectSurfCoord_test1) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); bool ErrorsFound(false); @@ -5019,6 +5027,7 @@ TEST_F(EnergyPlusFixture, WorldCoord_with_RelativeRectSurfCoord_test2) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); bool ErrorsFound(false); @@ -5049,6 +5058,7 @@ TEST_F(EnergyPlusFixture, WorldCoord_with_RelativeRectSurfCoord_test3) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); bool ErrorsFound(false); @@ -5085,6 +5095,7 @@ TEST_F(EnergyPlusFixture, WorldCoord_with_RelativeRectSurfCoord_test4) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); bool ErrorsFound(false); @@ -5395,6 +5406,7 @@ TEST_F(EnergyPlusFixture, HeatBalanceIntRadExchange_SetupEnclosuresNoAirBoundari " 0,0,1; !- Vertex 1", }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); bool ErrorsFound = false; GetMaterialData(*state, ErrorsFound); // read material data @@ -5598,6 +5610,7 @@ TEST_F(EnergyPlusFixture, HeatBalanceIntRadExchange_SetupEnclosuresWithAirBounda }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); bool ErrorsFound = false; GetMaterialData(*state, ErrorsFound); // read material data @@ -5798,6 +5811,7 @@ TEST_F(EnergyPlusFixture, HeatBalanceIntRadExchange_SetupEnclosuresWithAirBounda }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); bool ErrorsFound = false; GetMaterialData(*state, ErrorsFound); // read material data @@ -6255,6 +6269,7 @@ TEST_F(EnergyPlusFixture, HeatBalanceIntRadExchange_SetupEnclosuresWithAirBounda }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); bool ErrorsFound = false; GetMaterialData(*state, ErrorsFound); // read material data @@ -6808,6 +6823,7 @@ TEST_F(EnergyPlusFixture, HeatBalanceIntRadExchange_SetupEnclosuresWithAirBounda }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); bool ErrorsFound = false; GetMaterialData(*state, ErrorsFound); // read material data @@ -7451,6 +7467,8 @@ TEST_F(EnergyPlusFixture, TwoZones_With_AirDoor) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + bool ErrorsFound = false; GetMaterialData(*state, ErrorsFound); // read material data @@ -7785,6 +7803,7 @@ TEST_F(EnergyPlusFixture, TwoZones_With_AirWindow) state->dataSurfaceGeometry->NoGroundTempObjWarning = false; ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); bool ErrorsFound = false; GetMaterialData(*state, ErrorsFound); // read material data @@ -8669,9 +8688,7 @@ TEST_F(EnergyPlusFixture, GetSurfaceData_SurfaceOrder) }); ASSERT_TRUE(process_idf(idf_objects)); - - GetProjectControlData(*state, ErrorsFound); // read project control data - EXPECT_FALSE(ErrorsFound); // expect no errors + state->init_state(*state); GetMaterialData(*state, ErrorsFound); // read material data EXPECT_FALSE(ErrorsFound); // expect no errors @@ -9654,6 +9671,7 @@ TEST_F(EnergyPlusFixture, GetSurfaceData_SurfaceOrder2) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); GetProjectControlData(*state, ErrorsFound); // read project control data EXPECT_FALSE(ErrorsFound); // expect no errors @@ -10507,6 +10525,7 @@ TEST_F(EnergyPlusFixture, GetSurfaceData_SurfaceOrder3) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); GetProjectControlData(*state, ErrorsFound); // read project control data EXPECT_FALSE(ErrorsFound); // expect no errors @@ -11274,6 +11293,7 @@ TEST_F(EnergyPlusFixture, GetSurfaceData_SurfaceOrder4) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); GetProjectControlData(*state, ErrorsFound); // read project control data EXPECT_FALSE(ErrorsFound); // expect no errors @@ -11662,6 +11682,7 @@ TEST_F(EnergyPlusFixture, Use_Gross_Roof_Area_for_Averge_Height) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); GetProjectControlData(*state, ErrorsFound); EXPECT_FALSE(ErrorsFound); @@ -11961,6 +11982,7 @@ TEST_F(EnergyPlusFixture, Use_Gross_Roof_Area_for_Averge_Height_with_Window) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); GetProjectControlData(*state, ErrorsFound); EXPECT_FALSE(ErrorsFound); @@ -12030,6 +12052,7 @@ TEST_F(EnergyPlusFixture, SurfaceGeometry_GetKivaFoundationTest) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); GetFoundationData(*state, ErrorsFound); std::string const error_string = delimited_string({ @@ -12058,6 +12081,7 @@ TEST_F(EnergyPlusFixture, SurfaceGeometry_GetKivaFoundationTest2) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); state->dataEnvrn->Elevation = 600.; @@ -12203,6 +12227,7 @@ TEST_F(EnergyPlusFixture, SurfaceGeometry_ZoneAndSpaceAreas) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); bool ErrorsFound = false; GetMaterialData(*state, ErrorsFound); // read material data @@ -12400,6 +12425,8 @@ TEST_F(EnergyPlusFixture, ZoneFloorAreaTest) // Prepare data for the test ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + GetMaterialData(*state, ErrorsFound); // read material data EXPECT_FALSE(ErrorsFound); GetConstructData(*state, ErrorsFound); // read construction data @@ -12410,8 +12437,8 @@ TEST_F(EnergyPlusFixture, ZoneFloorAreaTest) EXPECT_FALSE(ErrorsFound); state->dataSurfaceGeometry->CosZoneRelNorth.allocate(1); state->dataSurfaceGeometry->SinZoneRelNorth.allocate(1); - state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); - state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); + state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); + state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); state->dataSurfaceGeometry->CosBldgRelNorth = 1.0; state->dataSurfaceGeometry->SinBldgRelNorth = 0.0; GetSurfaceData(*state, ErrorsFound); // setup zone geometry and get zone data @@ -12577,7 +12604,8 @@ TEST_F(EnergyPlusFixture, SurfaceGeometry_GetSurfaceGroundSurfsTest) " autocalculate; !- Volume {m3}"}); ASSERT_TRUE(process_idf(idf_objects)); - ScheduleManager::ProcessScheduleInput(*state); + state->init_state(*state); + state->dataHeatBal->ZoneIntGain.allocate(1); createFacilityElectricPowerServiceObject(*state); @@ -12592,7 +12620,7 @@ TEST_F(EnergyPlusFixture, SurfaceGeometry_GetSurfaceGroundSurfsTest) state->dataGlobal->TimeStepZone = 1; state->dataGlobal->TimeStepZoneSec = 3600.0; state->dataGlobal->HourOfDay = 1; - state->dataGlobal->NumOfTimeStepInHour = 1; + state->dataGlobal->TimeStepsInHour = 1; state->dataGlobal->BeginSimFlag = true; state->dataGlobal->BeginEnvrnFlag = true; state->dataEnvrn->OutBaroPress = 100000; @@ -12689,6 +12717,7 @@ TEST_F(EnergyPlusFixture, SurfaceGeometry_GetVerticesDropDuplicates) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); state->dataGlobal->NumOfZones = 2; state->dataHeatBal->Zone.allocate(2); @@ -12833,6 +12862,7 @@ TEST_F(EnergyPlusFixture, SurfaceGeometry_GetVerticesDropDuplicates_Once) fmt::arg("max_y", max_y), fmt::arg("off_y", off_y)); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); state->dataGlobal->NumOfZones = 2; state->dataHeatBal->Zone.allocate(2); @@ -12965,6 +12995,7 @@ TEST_F(EnergyPlusFixture, Wrong_Window_Construction) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); GetProjectControlData(*state, ErrorsFound); // read project control data EXPECT_FALSE(ErrorsFound); // expect no errors @@ -12981,8 +13012,8 @@ TEST_F(EnergyPlusFixture, Wrong_Window_Construction) state->dataSurfaceGeometry->CosZoneRelNorth.allocate(1); state->dataSurfaceGeometry->SinZoneRelNorth.allocate(1); - state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); - state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); + state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); + state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); state->dataSurfaceGeometry->CosBldgRelNorth = 1.0; state->dataSurfaceGeometry->SinBldgRelNorth = 0.0; @@ -13179,6 +13210,7 @@ TEST_F(EnergyPlusFixture, CalculateZoneVolume_WithAirBoundaries) )IDF"; ASSERT_TRUE(process_idf(idf_objects)); bool ErrorsFound = false; + state->init_state(*state); GetMaterialData(*state, ErrorsFound); // read material data EXPECT_FALSE(ErrorsFound); // expect no errors @@ -13405,6 +13437,7 @@ TEST_F(EnergyPlusFixture, CalculatZoneVolume_WithoutAirBoundaries) )IDF"; ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); bool ErrorsFound = false; GetMaterialData(*state, ErrorsFound); // read material data @@ -13749,9 +13782,7 @@ TEST_F(EnergyPlusFixture, GetSurfaceData_ShadingSurfaceScheduleChecks) }); ASSERT_TRUE(process_idf(idf_objects)); - - SimulationManager::GetProjectData(*state); // read project data - ScheduleManager::ProcessScheduleInput(*state); + state->init_state(*state); GetMaterialData(*state, ErrorsFound); // read material data EXPECT_FALSE(ErrorsFound); // expect no errors @@ -13996,10 +14027,8 @@ TEST_F(EnergyPlusFixture, GetSurfaceData_ShadingSurfaceScheduleOutOfRange) }); ASSERT_TRUE(process_idf(idf_objects)); - - SimulationManager::GetProjectData(*state); // read project data - ScheduleManager::ProcessScheduleInput(*state); - + state->init_state(*state); + GetMaterialData(*state, ErrorsFound); // read material data EXPECT_FALSE(ErrorsFound); // expect no errors @@ -14013,30 +14042,14 @@ TEST_F(EnergyPlusFixture, GetSurfaceData_ShadingSurfaceScheduleOutOfRange) // EXPECT_THROW(GetSurfaceData(*state, ErrorsFound), std::runtime_error); EXPECT_TRUE(ErrorsFound); std::string const error_string = delimited_string( - {" ** Severe ** Shading:Building:Detailed=\"BUILDINGSHADE:TILTEDSHADESURFACE\", Transmittance Schedule Name=\"OUTOFRANGE\", values not in " - "range [0,1].", - " ** Severe ** Shading:Building:Detailed=\"BUILDINGSHADE:TILTEDSHADESURFACE\", Transmittance Schedule Name=\"OUTOFRANGE\", " - "has schedule values < 0.", - " ** ~~~ ** ...Schedule values < 0 have no meaning for shading elements.", - " ** Severe ** " - "Shading:Building:Detailed=\"BUILDINGSHADE:TILTEDSHADESURFACE\", Transmittance Schedule Name=\"OUTOFRANGE\", has schedule values > 1.", - " ** ~~~ ** ...Schedule values > 1 have no meaning for shading elements.", - " ** Severe ** " - "Shading:Zone:Detailed=\"ZONESHADE:LIVING:SOUTH:SHADE001\", Transmittance Schedule Name=\"OUTOFRANGE\", values not in range [0,1].", - " ** " - "Severe ** Shading:Zone:Detailed=\"ZONESHADE:LIVING:SOUTH:SHADE001\", Base Surface Name=\"LIVING:SOUTH\", has schedule values < 0.", - " ** " - " ~~~ ** ...Schedule values < 0 have no meaning for shading elements.", - " ** Severe ** " - "Shading:Zone:Detailed=\"ZONESHADE:LIVING:SOUTH:SHADE001\", Base Surface Name=\"LIVING:SOUTH\", has schedule values > 1.", - " ** ~~~ ** " - "...Schedule values > 1 have no meaning for shading elements.", + {" ** Severe ** GetDetShdSurfaceData: Shading:Building:Detailed = BUILDINGSHADE:TILTEDSHADESURFACE", + " ** ~~~ ** Transmittance Schedule Name = OUTOFRANGE, schedule contains values that are < 0 and/or > 1", + " ** Severe ** GetAttShdSurfaceData: Shading:Zone:Detailed = ZONESHADE:LIVING:SOUTH:SHADE001", + " ** ~~~ ** Transmittance Schedule Name = OUTOFRANGE, schedule contains values that are < 0 and/or > 1", " ** Fatal ** GetSurfaceData: Errors discovered, program terminates.", - " " - "...Summary of Errors that led to program termination:", - " ..... Reference severe error count=6", - " ..... Last severe error=Shading:Zone:Detailed=\"ZONESHADE:LIVING:SOUTH:SHADE001\", Base Surface Name=\"LIVING:SOUTH\", has schedule " - "values > 1."}); + " ...Summary of Errors that led to program termination:", + " ..... Reference severe error count=2", + " ..... Last severe error=GetAttShdSurfaceData: Shading:Zone:Detailed = ZONESHADE:LIVING:SOUTH:SHADE001"}); compare_err_stream(error_string); // compare_err_stream( "" ); // just for debugging @@ -14252,9 +14265,8 @@ TEST_F(EnergyPlusFixture, SurfaceGeometry_SurroundingSurfacesViewFactorTest) bool ErrorsFound = false; ASSERT_TRUE(process_idf(idf_objects)); - // process schedules - ScheduleManager::ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; + state->init_state(*state); + state->dataHeatBal->ZoneIntGain.allocate(1); createFacilityElectricPowerServiceObject(*state); HeatBalanceManager::SetPreConstructionInputParameters(*state); @@ -14483,7 +14495,8 @@ TEST_F(EnergyPlusFixture, ExtSolarForShadingTest) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + int TotSurfaces = 8; // Need to double the number of surfaces because E+ will add mirrored surfaces state->dataSurfaceGeometry->SurfaceTmp.allocate(TotSurfaces); // Allocate the Surface derived type appropriately state->dataSurface->Corner = LowerLeftCorner; diff --git a/tst/EnergyPlus/unit/SystemAvailabilityManager.unit.cc b/tst/EnergyPlus/unit/SystemAvailabilityManager.unit.cc index 78aad3323ad..0ae2b9e8c06 100644 --- a/tst/EnergyPlus/unit/SystemAvailabilityManager.unit.cc +++ b/tst/EnergyPlus/unit/SystemAvailabilityManager.unit.cc @@ -193,7 +193,10 @@ TEST_F(EnergyPlusFixture, SysAvailManager_OptimumStart) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->dataGlobal->TimeStepsInHour = 6; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 10; // must initialize this to get schedules initialized + state->init_state(*state); + state->dataHeatBal->NumOfZoneLists = 1; state->dataHeatBal->ZoneList.allocate(state->dataHeatBal->NumOfZoneLists); state->dataHeatBal->ZoneList(1).Name = "LIST_ZONES"; @@ -239,10 +242,6 @@ TEST_F(EnergyPlusFixture, SysAvailManager_OptimumStart) state->dataAirLoop->AirToZoneNodeInfo(3).CoolCtrlZoneNums.allocate(1); state->dataAirLoop->AirToZoneNodeInfo(3).CoolCtrlZoneNums(1) = 6; - state->dataGlobal->NumOfTimeStepInHour = 6; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 10; // must initialize this to get schedules initialized - ScheduleManager::ProcessScheduleInput(*state); // read schedules - state->dataScheduleMgr->ScheduleInputProcessed = true; state->dataEnvrn->Month = 1; state->dataEnvrn->DayOfMonth = 1; state->dataGlobal->HourOfDay = 1; @@ -253,7 +252,7 @@ TEST_F(EnergyPlusFixture, SysAvailManager_OptimumStart) state->dataEnvrn->DayOfWeekTomorrow = 2; state->dataEnvrn->HolidayIndex = 0; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); state->dataZoneEquip->ZoneEquipAvail.allocate(6); @@ -297,11 +296,12 @@ TEST_F(EnergyPlusFixture, SysAvailManager_OptimumStart) state->dataHeatBalFanSys->TempTstatAir(5) = 14.0; state->dataHeatBalFanSys->TempTstatAir(6) = 10.0; - state->dataHeatBalFanSys->ZoneThermostatSetPointLo.allocate(6); - state->dataHeatBalFanSys->ZoneThermostatSetPointHi.allocate(6); + state->dataHeatBalFanSys->zoneTstatSetpts.allocate(6); - state->dataHeatBalFanSys->ZoneThermostatSetPointLo = 19.0; // all zones use same set point temperature - state->dataHeatBalFanSys->ZoneThermostatSetPointHi = 24.0; + for (auto &zoneTstatSetpt : state->dataHeatBalFanSys->zoneTstatSetpts) { + zoneTstatSetpt.setptLo = 19.0; // all zones use same set point temperature + zoneTstatSetpt.setptHi = 24.0; + } state->dataZoneCtrls->OccRoomTSetPointHeat.allocate(6); state->dataZoneCtrls->OccRoomTSetPointCool.allocate(6); @@ -356,15 +356,15 @@ TEST_F(EnergyPlusFixture, SysAvailManager_OptimumStart) ZoneTempPredictorCorrector::GetZoneAirSetPoints(*state); state->dataHeatBalFanSys->TempControlType.allocate(state->dataGlobal->NumOfZones); state->dataHeatBalFanSys->TempControlTypeRpt.allocate(state->dataGlobal->NumOfZones); - state->dataHeatBalFanSys->TempZoneThermostatSetPoint.allocate(state->dataGlobal->NumOfZones); + state->dataHeatBalFanSys->zoneTstatSetpts.allocate(state->dataGlobal->NumOfZones); state->dataGlobal->CurrentTime = 19.0; // set the current time to 7 PM which is post-occupancy Avail::ManageSystemAvailability(*state); ZoneTempPredictorCorrector::CalcZoneAirTempSetPoints(*state); EXPECT_EQ((int)Avail::Status::NoAction, (int)state->dataAvail->OptimumStartData(1).availStatus); // avail manager should be set to no action - EXPECT_EQ(15.0, state->dataHeatBalFanSys->ZoneThermostatSetPointLo(1)); // 15.0C is the unoccupied heating setpoint - EXPECT_EQ(29.4, state->dataHeatBalFanSys->ZoneThermostatSetPointHi(1)); // 29.4C is the unoccupied cooling setpoint + EXPECT_EQ(15.0, state->dataHeatBalFanSys->zoneTstatSetpts(1).setptLo); // 15.0C is the unoccupied heating setpoint + EXPECT_EQ(29.4, state->dataHeatBalFanSys->zoneTstatSetpts(1).setptHi); // 29.4C is the unoccupied cooling setpoint } TEST_F(EnergyPlusFixture, SysAvailManager_NightCycle_ZoneOutOfTolerance) @@ -373,26 +373,24 @@ TEST_F(EnergyPlusFixture, SysAvailManager_NightCycle_ZoneOutOfTolerance) state->dataHeatBalFanSys->TempControlType.allocate(NumZones); state->dataHeatBalFanSys->TempControlTypeRpt.allocate(NumZones); state->dataHeatBalFanSys->TempTstatAir.allocate(NumZones); - state->dataHeatBalFanSys->TempZoneThermostatSetPoint.allocate(NumZones); - state->dataHeatBalFanSys->ZoneThermostatSetPointHi.allocate(NumZones); - state->dataHeatBalFanSys->ZoneThermostatSetPointLo.allocate(NumZones); + state->dataHeatBalFanSys->zoneTstatSetpts.allocate(NumZones); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::SingleCooling; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::SingleCool; state->dataHeatBalFanSys->TempTstatAir(1) = 30.0; - state->dataHeatBalFanSys->TempZoneThermostatSetPoint(1) = 25.0; + state->dataHeatBalFanSys->zoneTstatSetpts(1).setpt = 25.0; - state->dataHeatBalFanSys->TempControlType(2) = HVAC::ThermostatType::SingleHeatCool; + state->dataHeatBalFanSys->TempControlType(2) = HVAC::SetptType::SingleHeatCool; state->dataHeatBalFanSys->TempTstatAir(2) = 25.0; - state->dataHeatBalFanSys->TempZoneThermostatSetPoint(2) = 25.0; + state->dataHeatBalFanSys->zoneTstatSetpts(2).setpt = 25.0; - state->dataHeatBalFanSys->TempControlType(3) = HVAC::ThermostatType::SingleHeating; + state->dataHeatBalFanSys->TempControlType(3) = HVAC::SetptType::SingleHeat; state->dataHeatBalFanSys->TempTstatAir(3) = 10.0; - state->dataHeatBalFanSys->TempZoneThermostatSetPoint(3) = 20.0; + state->dataHeatBalFanSys->zoneTstatSetpts(3).setpt = 20.0; - state->dataHeatBalFanSys->TempControlType(4) = HVAC::ThermostatType::DualSetPointWithDeadBand; + state->dataHeatBalFanSys->TempControlType(4) = HVAC::SetptType::DualHeatCool; state->dataHeatBalFanSys->TempTstatAir(4) = 30.0; - state->dataHeatBalFanSys->ZoneThermostatSetPointHi(4) = 25.0; - state->dataHeatBalFanSys->ZoneThermostatSetPointLo(4) = 20.0; + state->dataHeatBalFanSys->zoneTstatSetpts(4).setptHi = 25.0; + state->dataHeatBalFanSys->zoneTstatSetpts(4).setptLo = 20.0; Real64 TempTol = 0.5; Array1D_int ZoneNumList; @@ -416,9 +414,7 @@ TEST_F(EnergyPlusFixture, SysAvailManager_NightCycle_ZoneOutOfTolerance) state->dataHeatBalFanSys->TempControlType.deallocate(); state->dataHeatBalFanSys->TempTstatAir.deallocate(); - state->dataHeatBalFanSys->TempZoneThermostatSetPoint.deallocate(); - state->dataHeatBalFanSys->ZoneThermostatSetPointHi.deallocate(); - state->dataHeatBalFanSys->ZoneThermostatSetPointLo.deallocate(); + state->dataHeatBalFanSys->zoneTstatSetpts.deallocate(); ZoneNumList.deallocate(); } @@ -433,16 +429,15 @@ TEST_F(EnergyPlusFixture, SysAvailManager_HybridVentilation_OT_CO2Control) state->dataContaminantBalance->ZoneCO2SetPoint.allocate(1); state->dataAirLoop->PriAirSysAvailMgr.allocate(1); state->dataAvail->SchedData.allocate(1); - state->dataScheduleMgr->Schedule.allocate(1); state->dataAvail->ZoneComp.allocate(DataZoneEquipment::NumValidSysAvailZoneComponents); state->dataHeatBalFanSys->TempControlType.allocate(1); state->dataHeatBalFanSys->TempControlTypeRpt.allocate(1); - state->dataHeatBalFanSys->TempZoneThermostatSetPoint.allocate(1); + state->dataHeatBalFanSys->zoneTstatSetpts.allocate(1); state->dataAvail->HybridVentData(1).Name = "HybridControl"; state->dataAvail->HybridVentData(1).ControlledZoneNum = 1; state->dataAvail->HybridVentData(1).AirLoopNum = 1; - state->dataAvail->HybridVentData(1).ControlModeSchedPtr = 1; + state->dataAvail->HybridVentData(1).controlModeSched = Sched::AddScheduleConstant(*state, "CONTROL MODE"); state->dataAvail->HybridVentData(1).UseRainIndicator = false; state->dataAvail->HybridVentData(1).MaxWindSpeed = 40.0; state->dataAvail->HybridVentData(1).MinOutdoorTemp = 15.0; @@ -451,7 +446,7 @@ TEST_F(EnergyPlusFixture, SysAvailManager_HybridVentilation_OT_CO2Control) state->dataAvail->HybridVentData(1).MaxOutdoorEnth = 30000.0; state->dataAvail->HybridVentData(1).MinOutdoorDewPoint = 15.0; state->dataAvail->HybridVentData(1).MaxOutdoorDewPoint = 35.0; - state->dataAvail->HybridVentData(1).MinOASched = 2; + state->dataAvail->HybridVentData(1).minOASched = Sched::AddScheduleConstant(*state, "MIN OA"); state->dataAvail->HybridVentData(1).MinOperTime = 10.0; state->dataAvail->HybridVentData(1).MinVentTime = 10.0; @@ -496,11 +491,11 @@ TEST_F(EnergyPlusFixture, SysAvailManager_HybridVentilation_OT_CO2Control) state->dataAirLoop->PriAirSysAvailMgr(1).availManagers(1).type = Avail::ManagerType::Scheduled; // Scheduled state->dataAirLoop->PriAirSysAvailMgr(1).availManagers(1).Name = "Avail 1"; state->dataAirLoop->PriAirSysAvailMgr(1).availManagers(1).Num = 1; - state->dataAvail->SchedData(1).SchedPtr = 1; - state->dataScheduleMgr->Schedule(1).CurrentValue = 1; + auto *availSched = state->dataAvail->SchedData(1).availSched = Sched::AddScheduleConstant(*state, "AVAIL"); + availSched->currentVal = 1; Avail::CalcHybridVentSysAvailMgr(*state, 1, 1); EXPECT_EQ((int)Avail::VentCtrlStatus::Close, (int)state->dataAvail->HybridVentData(1).ctrlStatus); // System operation - state->dataScheduleMgr->Schedule(1).CurrentValue = 0; + availSched->currentVal = 0; Avail::CalcHybridVentSysAvailMgr(*state, 1, 1); EXPECT_EQ((int)Avail::VentCtrlStatus::Open, (int)state->dataAvail->HybridVentData(1).ctrlStatus); // Vent open @@ -539,8 +534,8 @@ TEST_F(EnergyPlusFixture, SysAvailManager_HybridVentilation_OT_CO2Control) Avail::CalcHybridVentSysAvailMgr(*state, 1, 1); EXPECT_EQ((int)Avail::VentCtrlStatus::Close, (int)state->dataAvail->HybridVentData(1).ctrlStatus); // No change state->dataAvail->HybridVentData(1).TimeVentDuration = 11.0; - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::SingleHeating; - state->dataHeatBalFanSys->TempZoneThermostatSetPoint(1) = 25.0; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::SingleHeat; + state->dataHeatBalFanSys->zoneTstatSetpts(1).setpt = 25.0; Avail::CalcHybridVentSysAvailMgr(*state, 1, 1); EXPECT_EQ((int)Avail::VentCtrlStatus::Open, (int)state->dataAvail->HybridVentData(1).ctrlStatus); // Can change } @@ -595,11 +590,10 @@ TEST_F(EnergyPlusFixture, SysAvailManager_NightCycleGetInput) }); ASSERT_TRUE(process_idf(idf_objects)); - - state->dataGlobal->NumOfTimeStepInHour = 1; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 60; // must initialize this to get schedules initialized - ScheduleManager::ProcessScheduleInput(*state); // read schedules - state->dataScheduleMgr->ScheduleInputProcessed = true; + state->dataGlobal->TimeStepsInHour = 1; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 60; // must initialize this to get schedules initialized + state->init_state(*state); + // get system availability schedule Avail::GetSysAvailManagerInputs(*state); // check the three cycling run time control types @@ -628,16 +622,16 @@ TEST_F(EnergyPlusFixture, SysAvailManager_NightCycleZone_CalcNCycSysAvailMgr) state->dataHeatBalFanSys->TempControlType.allocate(NumZones); state->dataHeatBalFanSys->TempControlTypeRpt.allocate(NumZones); state->dataHeatBalFanSys->TempTstatAir.allocate(NumZones); - state->dataHeatBalFanSys->TempZoneThermostatSetPoint.allocate(NumZones); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::SingleCooling; - state->dataHeatBalFanSys->TempZoneThermostatSetPoint(1) = 25.0; + state->dataHeatBalFanSys->zoneTstatSetpts.allocate(NumZones); + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::SingleCool; + state->dataHeatBalFanSys->zoneTstatSetpts(1).setpt = 25.0; state->dataHeatBalFanSys->TempTstatAir(1) = 25.1; state->dataAvail->NightCycleData.allocate(NumZones); state->dataAvail->NightCycleData(1).Name = "System Avail"; state->dataAvail->NightCycleData(1).nightCycleControlType = Avail::NightCycleControlType::OnAny; - state->dataAvail->NightCycleData(1).SchedPtr = 1; - state->dataAvail->NightCycleData(1).FanSchedPtr = 2; + auto *availSched = state->dataAvail->NightCycleData(1).availSched = Sched::AddScheduleConstant(*state, "AVAIL"); + auto *fanSched = state->dataAvail->NightCycleData(1).fanSched = Sched::AddScheduleConstant(*state, "FAN"); state->dataAvail->NightCycleData(1).TempTolRange = 0.4; state->dataAvail->NightCycleData(1).CyclingTimeSteps = 4; state->dataAvail->NightCycleData(1).CtrlZoneListName = state->dataHeatBal->Zone(1).Name; @@ -647,9 +641,9 @@ TEST_F(EnergyPlusFixture, SysAvailManager_NightCycleZone_CalcNCycSysAvailMgr) state->dataAvail->NightCycleData(1).CoolingZoneListName = state->dataHeatBal->Zone(1).Name; state->dataAvail->NightCycleData(1).NumOfCoolingZones = NumZones; state->dataAvail->NightCycleData(1).CoolingZonePtrs = NumZones; - state->dataScheduleMgr->Schedule.allocate(2); - state->dataScheduleMgr->Schedule(1).CurrentValue = 1; - state->dataScheduleMgr->Schedule(2).CurrentValue = 0; + + availSched->currentVal = 1; + fanSched->currentVal = 0; // Cycling Run Time Control Type = FixedRunTime // and current time is within the run time period, starting time is less than stopping time @@ -749,9 +743,9 @@ TEST_F(EnergyPlusFixture, SysAvailManager_NightCycleSys_CalcNCycSysAvailMgr) state->dataHeatBalFanSys->TempControlType.allocate(NumZones); state->dataHeatBalFanSys->TempControlTypeRpt.allocate(NumZones); state->dataHeatBalFanSys->TempTstatAir.allocate(NumZones); - state->dataHeatBalFanSys->TempZoneThermostatSetPoint.allocate(NumZones); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::SingleCooling; - state->dataHeatBalFanSys->TempZoneThermostatSetPoint(1) = 25.0; + state->dataHeatBalFanSys->zoneTstatSetpts.allocate(NumZones); + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::SingleCool; + state->dataHeatBalFanSys->zoneTstatSetpts(1).setpt = 25.0; state->dataHeatBalFanSys->TempTstatAir(1) = 25.1; state->dataHeatBal->Zone.allocate(NumZones); state->dataHeatBal->Zone(1).Name = "SPACE1-1"; @@ -766,8 +760,8 @@ TEST_F(EnergyPlusFixture, SysAvailManager_NightCycleSys_CalcNCycSysAvailMgr) state->dataAvail->NightCycleData(1).Name = "System Avail"; state->dataAvail->NightCycleData(1).nightCycleControlType = Avail::NightCycleControlType::OnAny; - state->dataAvail->NightCycleData(1).SchedPtr = 1; - state->dataAvail->NightCycleData(1).FanSchedPtr = 2; + auto *availSched = state->dataAvail->NightCycleData(1).availSched = Sched::AddScheduleConstant(*state, "AVAIL"); + auto *fanSched = state->dataAvail->NightCycleData(1).fanSched = Sched::AddScheduleConstant(*state, "FAN"); state->dataAvail->NightCycleData(1).TempTolRange = 0.4; state->dataAvail->NightCycleData(1).CyclingTimeSteps = 4; state->dataAvail->NightCycleData(1).CtrlZoneListName = state->dataHeatBal->Zone(1).Name; @@ -777,9 +771,8 @@ TEST_F(EnergyPlusFixture, SysAvailManager_NightCycleSys_CalcNCycSysAvailMgr) state->dataAvail->NightCycleData(1).CoolingZoneListName = state->dataHeatBal->Zone(1).Name; state->dataAvail->NightCycleData(1).NumOfCoolingZones = NumZones; state->dataAvail->NightCycleData(1).CoolingZonePtrs = NumZones; - state->dataScheduleMgr->Schedule.allocate(2); - state->dataScheduleMgr->Schedule(1).CurrentValue = 1; - state->dataScheduleMgr->Schedule(2).CurrentValue = 0; + availSched->currentVal = 1; + fanSched->currentVal = 0; // Cycling Run Time Control Type = FixedRunTime // and current time is within the run time period, starting time is less than stopping time diff --git a/tst/EnergyPlus/unit/ThermalChimney.unit.cc b/tst/EnergyPlus/unit/ThermalChimney.unit.cc index 1d5c6e9cf51..c0b6c0c7338 100644 --- a/tst/EnergyPlus/unit/ThermalChimney.unit.cc +++ b/tst/EnergyPlus/unit/ThermalChimney.unit.cc @@ -79,7 +79,6 @@ using namespace EnergyPlus::DataHeatBalance; using namespace EnergyPlus::InternalHeatGains; using namespace EnergyPlus::HeatBalanceManager; using namespace EnergyPlus::OutputProcessor; -using namespace EnergyPlus::ScheduleManager; using namespace EnergyPlus::DataSurfaces; using namespace EnergyPlus::DataHeatBalSurface; using namespace SimulationManager; @@ -1101,6 +1100,7 @@ TEST_F(EnergyPlusFixture, ThermalChimney_EMSAirflow_Test) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); state->dataIPShortCut->lNumericFieldBlanks.allocate(1000); state->dataIPShortCut->lAlphaFieldBlanks.allocate(1000); @@ -1134,8 +1134,6 @@ TEST_F(EnergyPlusFixture, ThermalChimney_EMSAirflow_Test) state->dataSurfaceGeometry->SinBldgRotAppGonly = 0.0; SurfaceGeometry::GetSurfaceData(*state, localErrorsFound); EXPECT_FALSE(localErrorsFound); - ScheduleManager::ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; state->dataHeatBal->Zone(2).HasWindow = true; state->dataHeatBal->Zone(4).HasWindow = true; @@ -1160,7 +1158,7 @@ TEST_F(EnergyPlusFixture, ThermalChimney_EMSAirflow_Test) state->dataEnvrn->StdRhoAir = Psychrometrics::PsyRhoAirFnPbTdbW(*state, state->dataEnvrn->OutBaroPress, 20.0, 0.0); state->dataZoneTempPredictorCorrector->zoneHeatBalance.allocate(state->dataGlobal->NumOfZones); - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; + Sched::GetSchedule(*state, "THERMALCHIMNEYAVAIL")->currentVal = 1.0; state->dataHeatBal->ZnAirRpt.allocate(state->dataGlobal->NumOfZones); // No EMS ThermalChimney::GetThermalChimney(*state, localErrorsFound); diff --git a/tst/EnergyPlus/unit/ThermalComfort.unit.cc b/tst/EnergyPlus/unit/ThermalComfort.unit.cc index cab93f0451b..470371ea2b0 100644 --- a/tst/EnergyPlus/unit/ThermalComfort.unit.cc +++ b/tst/EnergyPlus/unit/ThermalComfort.unit.cc @@ -92,8 +92,7 @@ TEST_F(EnergyPlusFixture, ThermalComfort_CalcIfSetPointMetTest1) state->dataRoomAir->AirModel.allocate(state->dataGlobal->NumOfZones); state->dataRoomAir->AirModel(1).AirModel = RoomAir::RoomAirModel::Mixing; state->dataZoneTempPredictorCorrector->zoneHeatBalance.allocate(state->dataGlobal->NumOfZones); - state->dataHeatBalFanSys->ZoneThermostatSetPointLo.allocate(state->dataGlobal->NumOfZones); - state->dataHeatBalFanSys->ZoneThermostatSetPointHi.allocate(state->dataGlobal->NumOfZones); + state->dataHeatBalFanSys->zoneTstatSetpts.allocate(state->dataGlobal->NumOfZones); state->dataGlobal->TimeStepZone = 0.25; state->dataThermalComforts->ThermalComfortInASH55.allocate(state->dataGlobal->NumOfZones); state->dataThermalComforts->ThermalComfortInASH55(1).ZoneIsOccupied = true; @@ -101,11 +100,11 @@ TEST_F(EnergyPlusFixture, ThermalComfort_CalcIfSetPointMetTest1) // SingleHeatingSetPoint thermostat - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::SingleHeating; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::SingleHeat; // heating state->dataZoneTempPredictorCorrector->zoneHeatBalance(1).ZTAV = 21.1; // 70F - state->dataHeatBalFanSys->ZoneThermostatSetPointLo(1) = 22.2; // 72F + state->dataHeatBalFanSys->zoneTstatSetpts(1).setptLo = 22.2; // 72F state->dataZoneEnergyDemand->ZoneSysEnergyDemand(1).TotalOutputRequired = 500.0; // must be greater than zero CalcIfSetPointMet(*state); EXPECT_EQ(state->dataGlobal->TimeStepZone, state->dataThermalComforts->ThermalComfortSetPoint(1).notMetHeating); @@ -115,7 +114,7 @@ TEST_F(EnergyPlusFixture, ThermalComfort_CalcIfSetPointMetTest1) // cooling state->dataZoneTempPredictorCorrector->zoneHeatBalance(1).ZTAV = 25.0; // 77F - state->dataHeatBalFanSys->ZoneThermostatSetPointHi(1) = 23.9; // 75F + state->dataHeatBalFanSys->zoneTstatSetpts(1).setptHi = 23.9; // 75F state->dataZoneEnergyDemand->ZoneSysEnergyDemand(1).TotalOutputRequired = -500.0; // must be less than zero CalcIfSetPointMet(*state); EXPECT_EQ(0, state->dataThermalComforts->ThermalComfortSetPoint(1).notMetHeating); @@ -125,11 +124,11 @@ TEST_F(EnergyPlusFixture, ThermalComfort_CalcIfSetPointMetTest1) // SingleCoolingSetPoint thermostat - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::SingleCooling; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::SingleCool; // heating state->dataZoneTempPredictorCorrector->zoneHeatBalance(1).ZTAV = 21.1; // 70F - state->dataHeatBalFanSys->ZoneThermostatSetPointLo(1) = 22.2; // 72F + state->dataHeatBalFanSys->zoneTstatSetpts(1).setptLo = 22.2; // 72F state->dataZoneEnergyDemand->ZoneSysEnergyDemand(1).TotalOutputRequired = 500.0; // must be greater than zero CalcIfSetPointMet(*state); EXPECT_EQ(0, state->dataThermalComforts->ThermalComfortSetPoint(1).notMetHeating); @@ -139,7 +138,7 @@ TEST_F(EnergyPlusFixture, ThermalComfort_CalcIfSetPointMetTest1) // cooling state->dataZoneTempPredictorCorrector->zoneHeatBalance(1).ZTAV = 25.0; // 77F - state->dataHeatBalFanSys->ZoneThermostatSetPointHi(1) = 23.9; // 75F + state->dataHeatBalFanSys->zoneTstatSetpts(1).setptHi = 23.9; // 75F state->dataZoneEnergyDemand->ZoneSysEnergyDemand(1).TotalOutputRequired = -500.0; // must be less than zero CalcIfSetPointMet(*state); EXPECT_EQ(0, state->dataThermalComforts->ThermalComfortSetPoint(1).notMetHeating); @@ -149,11 +148,11 @@ TEST_F(EnergyPlusFixture, ThermalComfort_CalcIfSetPointMetTest1) // SingleHeatCoolSetPoint thermostat - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::SingleHeatCool; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::SingleHeatCool; // heating state->dataZoneTempPredictorCorrector->zoneHeatBalance(1).ZTAV = 21.1; // 70F - state->dataHeatBalFanSys->ZoneThermostatSetPointLo(1) = 22.2; // 72F + state->dataHeatBalFanSys->zoneTstatSetpts(1).setptLo = 22.2; // 72F state->dataZoneEnergyDemand->ZoneSysEnergyDemand(1).TotalOutputRequired = 500.0; // must be greater than zero CalcIfSetPointMet(*state); EXPECT_EQ(state->dataGlobal->TimeStepZone, state->dataThermalComforts->ThermalComfortSetPoint(1).notMetHeating); @@ -163,7 +162,7 @@ TEST_F(EnergyPlusFixture, ThermalComfort_CalcIfSetPointMetTest1) // cooling state->dataZoneTempPredictorCorrector->zoneHeatBalance(1).ZTAV = 25.0; // 77F - state->dataHeatBalFanSys->ZoneThermostatSetPointHi(1) = 23.9; // 75F + state->dataHeatBalFanSys->zoneTstatSetpts(1).setptHi = 23.9; // 75F state->dataZoneEnergyDemand->ZoneSysEnergyDemand(1).TotalOutputRequired = -500.0; // must be less than zero CalcIfSetPointMet(*state); EXPECT_EQ(0, state->dataThermalComforts->ThermalComfortSetPoint(1).notMetHeating); @@ -171,13 +170,13 @@ TEST_F(EnergyPlusFixture, ThermalComfort_CalcIfSetPointMetTest1) EXPECT_EQ(state->dataGlobal->TimeStepZone, state->dataThermalComforts->ThermalComfortSetPoint(1).notMetCooling); EXPECT_EQ(state->dataGlobal->TimeStepZone, state->dataThermalComforts->ThermalComfortSetPoint(1).notMetCoolingOccupied); - // DualSetPointWithDeadBand thermostat + // DualHeatCool thermostat - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::DualSetPointWithDeadBand; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::DualHeatCool; // heating state->dataZoneTempPredictorCorrector->zoneHeatBalance(1).ZTAV = 21.1; // 70F - state->dataHeatBalFanSys->ZoneThermostatSetPointLo(1) = 22.2; // 72F + state->dataHeatBalFanSys->zoneTstatSetpts(1).setptLo = 22.2; // 72F state->dataZoneEnergyDemand->ZoneSysEnergyDemand(1).TotalOutputRequired = 500.0; // must be greater than zero CalcIfSetPointMet(*state); EXPECT_EQ(state->dataGlobal->TimeStepZone, state->dataThermalComforts->ThermalComfortSetPoint(1).notMetHeating); @@ -187,7 +186,7 @@ TEST_F(EnergyPlusFixture, ThermalComfort_CalcIfSetPointMetTest1) // cooling state->dataZoneTempPredictorCorrector->zoneHeatBalance(1).ZTAV = 25.0; // 77F - state->dataHeatBalFanSys->ZoneThermostatSetPointHi(1) = 23.9; // 75F + state->dataHeatBalFanSys->zoneTstatSetpts(1).setptHi = 23.9; // 75F state->dataZoneEnergyDemand->ZoneSysEnergyDemand(1).TotalOutputRequired = -500.0; // must be less than zero CalcIfSetPointMet(*state); EXPECT_EQ(0, state->dataThermalComforts->ThermalComfortSetPoint(1).notMetHeating); @@ -932,22 +931,19 @@ TEST_F(EnergyPlusFixture, ThermalComfort_CalcIfSetPointMetWithCutoutTest) state->dataRoomAir->AirModel.allocate(state->dataGlobal->NumOfZones); state->dataRoomAir->AirModel(1).AirModel = RoomAir::RoomAirModel::Mixing; state->dataZoneTempPredictorCorrector->zoneHeatBalance.allocate(state->dataGlobal->NumOfZones); - state->dataHeatBalFanSys->ZoneThermostatSetPointLo.allocate(state->dataGlobal->NumOfZones); - state->dataHeatBalFanSys->ZoneThermostatSetPointHi.allocate(state->dataGlobal->NumOfZones); - state->dataHeatBalFanSys->ZoneThermostatSetPointLoAver.allocate(state->dataGlobal->NumOfZones); - state->dataHeatBalFanSys->ZoneThermostatSetPointHiAver.allocate(state->dataGlobal->NumOfZones); + state->dataHeatBalFanSys->zoneTstatSetpts.allocate(state->dataGlobal->NumOfZones); state->dataThermalComforts->ThermalComfortInASH55.allocate(state->dataGlobal->NumOfZones); state->dataThermalComforts->ThermalComfortInASH55(1).ZoneIsOccupied = true; state->dataGlobal->TimeStepZone = 0.25; state->dataHeatBal->Zone.allocate(state->dataGlobal->NumOfZones); state->dataZoneTempPredictorCorrector->NumOnOffCtrZone = 1; - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::DualSetPointWithDeadBand; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::DualHeatCool; // heating state->dataZoneTempPredictorCorrector->zoneHeatBalance(1).ZTAV = 21.1; // 70F - state->dataHeatBalFanSys->ZoneThermostatSetPointLo(1) = 22.2; // 72F - state->dataHeatBalFanSys->ZoneThermostatSetPointLoAver(1) = 22.2; // 72F + state->dataHeatBalFanSys->zoneTstatSetpts(1).setptLo = 22.2; // 72F + state->dataHeatBalFanSys->zoneTstatSetpts(1).setptLoAver = 22.2; // 72F state->dataZoneEnergyDemand->ZoneSysEnergyDemand(1).TotalOutputRequired = 500.0; // must be greater than zero CalcIfSetPointMet(*state); EXPECT_EQ(state->dataGlobal->TimeStepZone, state->dataThermalComforts->ThermalComfortSetPoint(1).notMetHeating); @@ -957,8 +953,8 @@ TEST_F(EnergyPlusFixture, ThermalComfort_CalcIfSetPointMetWithCutoutTest) // cooling state->dataZoneTempPredictorCorrector->zoneHeatBalance(1).ZTAV = 25.0; // 77F - state->dataHeatBalFanSys->ZoneThermostatSetPointHi(1) = 23.9; // 75F - state->dataHeatBalFanSys->ZoneThermostatSetPointHiAver(1) = 23.9; // 75F + state->dataHeatBalFanSys->zoneTstatSetpts(1).setptHi = 23.9; // 75F + state->dataHeatBalFanSys->zoneTstatSetpts(1).setptHiAver = 23.9; // 75F state->dataZoneEnergyDemand->ZoneSysEnergyDemand(1).TotalOutputRequired = -500.0; // must be less than zero CalcIfSetPointMet(*state); EXPECT_EQ(0, state->dataThermalComforts->ThermalComfortSetPoint(1).notMetHeating); @@ -982,7 +978,8 @@ TEST_F(EnergyPlusFixture, ThermalComfort_CalcIfSetPointMetWithCutoutTest) TEST_F(EnergyPlusFixture, ThermalComfort_CalcThermalComfortASH55) { - + state->init_state(*state); + // Set the data for the test state->dataHeatBal->TotPeople = 1; state->dataHeatBal->People.allocate(state->dataHeatBal->TotPeople); @@ -999,7 +996,7 @@ TEST_F(EnergyPlusFixture, ThermalComfort_CalcThermalComfortASH55) state->dataHeatBalFanSys->ZoneQElecBaseboardToPerson.allocate(state->dataGlobal->NumOfZones); state->dataHeatBal->People(1).ZonePtr = 1; - state->dataHeatBal->People(1).NumberOfPeoplePtr = -1; + state->dataHeatBal->People(1).numberOfPeopleSched = Sched::GetScheduleAlwaysOn(*state); state->dataHeatBal->People(1).NumberOfPeople = 5.0; state->dataHeatBal->People(1).NomMinNumberPeople = 5.0; state->dataHeatBal->People(1).NomMaxNumberPeople = 5.0; @@ -1015,7 +1012,7 @@ TEST_F(EnergyPlusFixture, ThermalComfort_CalcThermalComfortASH55) state->dataHeatBal->space.allocate(1); state->dataHeatBal->space(1).radiantEnclosureNum = 1; state->dataViewFactor->EnclRadInfo.allocate(1); - state->dataHeatBal->People(1).WorkEffPtr = 0; + state->dataHeatBal->People(1).workEffSched = Sched::GetScheduleAlwaysOff(*state); state->dataHeatBal->People(1).clothingType = ClothingType::InsulationSchedule; state->dataRoomAir->IsZoneDispVent3Node(1) = state->dataRoomAir->IsZoneUFAD(1) = false; @@ -1027,11 +1024,10 @@ TEST_F(EnergyPlusFixture, ThermalComfort_CalcThermalComfortASH55) Real64 BodySurfaceArea = 1.8258; state->dataEnvrn->OutBaroPress = 101325.; Real64 WorkEff = 0.0; - state->dataHeatBal->People(1).ActivityLevelPtr = 1; - state->dataHeatBal->People(1).ClothingPtr = 2; - state->dataHeatBal->People(1).AirVelocityPtr = 3; - state->dataHeatBal->People(1).AnkleAirVelocityPtr = 4; - state->dataScheduleMgr->Schedule.allocate(4); + auto *activitySched = state->dataHeatBal->People(1).activityLevelSched = Sched::AddScheduleConstant(*state, "ACTIVITY"); + auto *clothingSched = state->dataHeatBal->People(1).clothingSched = Sched::AddScheduleConstant(*state, "CLOTHING"); + auto *airVeloSched = state->dataHeatBal->People(1).airVelocitySched = Sched::AddScheduleConstant(*state, "AIR VELO"); + auto *ankleAirVeloSched = state->dataHeatBal->People(1).ankleAirVelocitySched = Sched::AddScheduleConstant(*state, "ANKLE AIR VELO"); // Part 1: Test SET calculations. // Reference: ANSI/ASHRAE Standard 55-2017 Appendix D - Table D3 Validation Table for SET Computer Model @@ -1062,12 +1058,12 @@ TEST_F(EnergyPlusFixture, ThermalComfort_CalcThermalComfortASH55) zoneHB1.MRT = RadTemp; state->dataViewFactor->EnclRadInfo(1).MRT = RadTemp; zoneHB1.airHumRatAvgComf = Psychrometrics::PsyWFnTdbRhPb(*state, zoneHB1.ZTAVComf, RelHum, state->dataEnvrn->OutBaroPress); - state->dataScheduleMgr->Schedule(1).CurrentValue = ActMet * BodySurfaceArea * ThermalComfort::ActLevelConv; - state->dataScheduleMgr->Schedule(2).CurrentValue = CloUnit; + activitySched->currentVal = ActMet * BodySurfaceArea * ThermalComfort::ActLevelConv; + clothingSched->currentVal = CloUnit; // Test 1 - Air velocity = 0.15 m/s. Real64 AirVel = 0.15; - state->dataScheduleMgr->Schedule(3).CurrentValue = AirVel; + airVeloSched->currentVal = AirVel; CalcThermalComfortCoolingEffectASH(*state); Real64 CoolingEffect = state->dataThermalComforts->ThermalComfortData(1).CoolingEffectASH55; Real64 StillAirVel = 0.1; @@ -1079,7 +1075,7 @@ TEST_F(EnergyPlusFixture, ThermalComfort_CalcThermalComfortASH55) // Test 2 - Air velocity = 1 m/s. AirVel = 1; - state->dataScheduleMgr->Schedule(3).CurrentValue = AirVel; + airVeloSched->currentVal = AirVel; CalcThermalComfortCoolingEffectASH(*state); CoolingEffect = state->dataThermalComforts->ThermalComfortData(1).CoolingEffectASH55; CoolingEffectSET = @@ -1093,8 +1089,8 @@ TEST_F(EnergyPlusFixture, ThermalComfort_CalcThermalComfortASH55) state->dataHeatBal->People(1).AnkleDraftASH55 = true; AirVel = 0.15; Real64 AnkleAirVel = 0.3; - state->dataScheduleMgr->Schedule(3).CurrentValue = AirVel; - state->dataScheduleMgr->Schedule(4).CurrentValue = AnkleAirVel; + airVeloSched->currentVal = AirVel; + ankleAirVeloSched->currentVal = AnkleAirVel; CalcThermalComfortAnkleDraftASH(*state); EXPECT_NEAR(state->dataThermalComforts->ThermalComfortData(1).AnkleDraftPPDASH55, 25.0, 0.1); } diff --git a/tst/EnergyPlus/unit/TranspiredCollector.unit.cc b/tst/EnergyPlus/unit/TranspiredCollector.unit.cc index a2aee98117b..d363bd06196 100644 --- a/tst/EnergyPlus/unit/TranspiredCollector.unit.cc +++ b/tst/EnergyPlus/unit/TranspiredCollector.unit.cc @@ -75,7 +75,6 @@ using namespace EnergyPlus::DataHeatBalSurface; using namespace EnergyPlus::DataSurfaces; using namespace EnergyPlus::DataZoneEquipment; using namespace EnergyPlus::Psychrometrics; -using namespace EnergyPlus::ScheduleManager; using namespace EnergyPlus::SurfaceGeometry; using namespace EnergyPlus::TranspiredCollector; using namespace EnergyPlus::HeatBalanceManager; @@ -194,10 +193,9 @@ TEST_F(EnergyPlusFixture, TranspiredCollectors_InitTranspiredCollectorTest) }); ASSERT_TRUE(process_idf(idf_objects)); - - state->dataGlobal->NumOfTimeStepInHour = 1; - state->dataGlobal->MinutesPerTimeStep = 60; - ScheduleManager::ProcessScheduleInput(*state); + state->dataGlobal->TimeStepsInHour = 1; + state->dataGlobal->MinutesInTimeStep = 60; + state->init_state(*state); GetProjectControlData(*state, ErrorsFound); // read project control data EXPECT_FALSE(ErrorsFound); @@ -214,8 +212,8 @@ TEST_F(EnergyPlusFixture, TranspiredCollectors_InitTranspiredCollectorTest) state->dataSurfaceGeometry->CosZoneRelNorth.allocate(1); state->dataSurfaceGeometry->SinZoneRelNorth.allocate(1); - state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); - state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); + state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); + state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); state->dataSurfaceGeometry->CosBldgRelNorth = 1.0; state->dataSurfaceGeometry->SinBldgRelNorth = 0.0; @@ -227,8 +225,6 @@ TEST_F(EnergyPlusFixture, TranspiredCollectors_InitTranspiredCollectorTest) SetSurfaceOutBulbTempAt(*state); - InitializePsychRoutines(*state); - GetTranspiredCollectorInput(*state); EXPECT_FALSE(ErrorsFound); diff --git a/tst/EnergyPlus/unit/UnitHeater.unit.cc b/tst/EnergyPlus/unit/UnitHeater.unit.cc index b5472f8f702..bae955c0a93 100644 --- a/tst/EnergyPlus/unit/UnitHeater.unit.cc +++ b/tst/EnergyPlus/unit/UnitHeater.unit.cc @@ -93,7 +93,6 @@ using namespace EnergyPlus::HeatBalanceManager; using namespace EnergyPlus::OutputProcessor; using namespace EnergyPlus::OutputReportPredefined; using namespace EnergyPlus::Psychrometrics; -using namespace EnergyPlus::ScheduleManager; using namespace EnergyPlus::SimulationManager; using namespace EnergyPlus::SizingManager; using namespace EnergyPlus::SurfaceGeometry; @@ -1100,10 +1099,9 @@ TEST_F(EnergyPlusFixture, UnitHeater_HWHeatingCoilUAAutoSizingTest) " ; !- Rated Ratio for Air and Water Convection", }); ASSERT_TRUE(process_idf(idf_objects)); - - state->dataGlobal->NumOfTimeStepInHour = 4; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 15; // must initialize this to get schedules initialized - ProcessScheduleInput(*state); // read schedule data + state->dataGlobal->TimeStepsInHour = 4; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 15; // must initialize this to get schedules initialized + state->init_state(*state); ErrorsFound = false; HeatBalanceManager::GetProjectControlData(*state, ErrorsFound); // read project control data @@ -1123,7 +1121,7 @@ TEST_F(EnergyPlusFixture, UnitHeater_HWHeatingCoilUAAutoSizingTest) state->dataLoopNodes->MoreNodeInfo.allocate(20); state->dataHVACGlobal->TimeStepSys = state->dataGlobal->TimeStepZone; - state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; SetupTimePointers(*state, OutputProcessor::TimeStepType::Zone, state->dataGlobal->TimeStepZone); SetupTimePointers(*state, OutputProcessor::TimeStepType::System, state->dataHVACGlobal->TimeStepSys); @@ -1289,9 +1287,9 @@ TEST_F(EnergyPlusFixture, UnitHeater_SimUnitHeaterTest) }); ASSERT_TRUE(process_idf(idf_objects)); - state->dataGlobal->NumOfTimeStepInHour = 4; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 15; // must initialize this to get schedules initialized - ProcessScheduleInput(*state); // read schedule data + state->dataGlobal->TimeStepsInHour = 4; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 15; // must initialize this to get schedules initialized + state->init_state(*state); ErrorsFound = false; HeatBalanceManager::GetZoneData(*state, ErrorsFound); // read zone data @@ -1355,7 +1353,7 @@ TEST_F(EnergyPlusFixture, UnitHeater_SimUnitHeaterTest) state->dataHVACGlobal->TurnFansOn = true; state->dataHVACGlobal->TurnFansOff = false; - state->dataScheduleMgr->Schedule(1).CurrentValue = 1; + Sched::GetSchedule(*state, "UNITHEATAVAILABILITY")->currentVal = 1; state->dataZoneEnergyDemand->CurDeadBandOrSetback.allocate(1); state->dataZoneEnergyDemand->CurDeadBandOrSetback(ZoneNum) = false; diff --git a/tst/EnergyPlus/unit/UnitaryHybridAirConditioner.unit.cc b/tst/EnergyPlus/unit/UnitaryHybridAirConditioner.unit.cc index 9928dfbfe8e..6334ad32a5a 100644 --- a/tst/EnergyPlus/unit/UnitaryHybridAirConditioner.unit.cc +++ b/tst/EnergyPlus/unit/UnitaryHybridAirConditioner.unit.cc @@ -91,7 +91,6 @@ using namespace EnergyPlus::DataAirLoop; using namespace EnergyPlus::DataAirSystems; using namespace EnergyPlus::DataSizing; using namespace EnergyPlus::DataHeatBalance; -using namespace EnergyPlus::ScheduleManager; using namespace EnergyPlus::DataEnvironment; using namespace EnergyPlus::DataZoneEquipment; using namespace EnergyPlus::DataLoopNode; @@ -113,7 +112,6 @@ using EnergyPlus::Curve::GetNormalPoint; using EnergyPlus::Psychrometrics::PsyHFnTdbRhPb; using EnergyPlus::Psychrometrics::PsyRhFnTdbWPb; using EnergyPlus::Psychrometrics::PsyWFnTdbRhPb; -using namespace EnergyPlus::ScheduleManager; using EnergyPlus::HybridEvapCoolingModel::CMode; using EnergyPlus::HybridEvapCoolingModel::CSetting; using EnergyPlus::HybridEvapCoolingModel::Model; @@ -126,6 +124,10 @@ TEST_F(EnergyPlusFixture, Test_UnitaryHybridAirConditioner_Unittest) ASSERT_TRUE(process_idf( delimited_string(read_lines_in_file(configured_source_directory() / "tst/EnergyPlus/unit/Resources/UnitaryHybridUnitTest_DOSA.idf")))); + state->dataGlobal->TimeStepsInHour = 1; + state->dataGlobal->MinutesInTimeStep = 60; + state->init_state(*state); + // setup environment bool ErrorsFound(false); GetZoneData(*state, ErrorsFound); @@ -133,9 +135,7 @@ TEST_F(EnergyPlusFixture, Test_UnitaryHybridAirConditioner_Unittest) // Initialize schedule values state->dataGlobal->TimeStep = 1; state->dataHVACGlobal->TimeStepSys = 1; - state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; - state->dataGlobal->NumOfTimeStepInHour = 1; - state->dataGlobal->MinutesPerTimeStep = 60; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; state->dataEnvrn->Month = 1; state->dataEnvrn->DayOfMonth = 21; state->dataGlobal->HourOfDay = 1; @@ -144,7 +144,7 @@ TEST_F(EnergyPlusFixture, Test_UnitaryHybridAirConditioner_Unittest) state->dataEnvrn->HolidayIndex = 0; state->dataGlobal->WarmupFlag = false; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); // Initialize zone areas and volumes - too many other things need to be set up to do these in the normal routines state->dataHeatBal->Zone(1).FloorArea = 232.26; state->dataEnvrn->StdRhoAir = 1.225; @@ -157,8 +157,7 @@ TEST_F(EnergyPlusFixture, Test_UnitaryHybridAirConditioner_Unittest) // Setup performance tables using namespace EnergyPlus::DataEnvironment; // process schedules - ProcessScheduleInput(*state); // read schedules - UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); // Get Unitary system GetInputZoneHybridUnitaryAirConditioners(*state, ErrorsFound); EXPECT_EQ(1, state->dataHybridUnitaryAC->ZoneHybridUnitaryAirConditioner.size()); @@ -390,9 +389,7 @@ TEST_F(EnergyPlusFixture, Test_UnitaryHybridAirConditioner_Unittest) // Setup performance tables using namespace EnergyPlus::DataEnvironment; - // process schedules - ProcessScheduleInput(*state); // read schedules - UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); // Get Unitary system: no, we don't want to do it twice! Otherwise the Output Variables will be duplicated // GetInputZoneHybridUnitaryAirConditioners(*state, ErrorsFound); EXPECT_EQ(1, state->dataHybridUnitaryAC->ZoneHybridUnitaryAirConditioner.size()); @@ -1255,7 +1252,8 @@ TEST_F(EnergyPlusFixture, Test_UnitaryHybridAirConditioner_ModelOperatingSetting "3.25; !- Output Value 1", }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + Curve::GetCurveInput(*state); state->dataCurveManager->GetCurvesInputFlag = false; EXPECT_EQ(8, state->dataCurveManager->NumCurves); @@ -1430,6 +1428,8 @@ TEST_F(EnergyPlusFixture, Test_UnitaryHybridAirConditioner_ValidateOptionalError }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + bool ErrorsFound = false; GetInputZoneHybridUnitaryAirConditioners(*state, ErrorsFound); // Design Specification Outdoor Air Object Name 'SZ DSOA SPACE2-1' is not defined in this model, thus an error is thrown @@ -1444,6 +1444,10 @@ TEST_F(EnergyPlusFixture, Test_UnitaryHybridAirConditioner_RuntimeFraction_Initi ASSERT_TRUE(process_idf( delimited_string(read_lines_in_file(configured_source_directory() / "tst/EnergyPlus/unit/Resources/UnitaryHybridUnitTest_DOSA.idf")))); + state->dataGlobal->TimeStepsInHour = 1; + state->dataGlobal->MinutesInTimeStep = 60; + state->init_state(*state); + // setup environment bool ErrorsFound(false); GetZoneData(*state, ErrorsFound); @@ -1451,9 +1455,8 @@ TEST_F(EnergyPlusFixture, Test_UnitaryHybridAirConditioner_RuntimeFraction_Initi // Initialize schedule values state->dataGlobal->TimeStep = 1; state->dataHVACGlobal->TimeStepSys = 1; - state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; - state->dataGlobal->NumOfTimeStepInHour = 1; - state->dataGlobal->MinutesPerTimeStep = 60; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; + state->dataEnvrn->Month = 1; state->dataEnvrn->DayOfMonth = 21; state->dataGlobal->HourOfDay = 1; @@ -1462,7 +1465,7 @@ TEST_F(EnergyPlusFixture, Test_UnitaryHybridAirConditioner_RuntimeFraction_Initi state->dataEnvrn->HolidayIndex = 0; state->dataGlobal->WarmupFlag = false; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); // Initialize zone areas and volumes - too many other things need to be set up to do these in the normal routines state->dataHeatBal->Zone(1).FloorArea = 232.26; state->dataEnvrn->StdRhoAir = 1.225; @@ -1474,9 +1477,7 @@ TEST_F(EnergyPlusFixture, Test_UnitaryHybridAirConditioner_RuntimeFraction_Initi // Setup performance tables using namespace EnergyPlus::DataEnvironment; - // process schedules - ProcessScheduleInput(*state); // read schedules - UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); // Get Unitary system GetInputZoneHybridUnitaryAirConditioners(*state, ErrorsFound); // All to get OA requirements diff --git a/tst/EnergyPlus/unit/UnitarySystem.unit.cc b/tst/EnergyPlus/unit/UnitarySystem.unit.cc index a1cc7eebea8..be656bd4f06 100644 --- a/tst/EnergyPlus/unit/UnitarySystem.unit.cc +++ b/tst/EnergyPlus/unit/UnitarySystem.unit.cc @@ -136,7 +136,7 @@ class ZoneUnitarySysTest : public EnergyPlusFixture state->dataZoneEquip->ZoneEquipConfig(1).ReturnNode(1) = 21; state->dataZoneEquip->ZoneEquipConfig(1).FixedReturnFlow.allocate(1); state->dataHeatBal->Zone(1).SystemZoneNodeNumber = state->dataZoneEquip->ZoneEquipConfig(1).ZoneNode; - state->dataZoneEquip->ZoneEquipConfig(1).ReturnFlowSchedPtrNum = ScheduleManager::ScheduleAlwaysOn; + state->dataZoneEquip->ZoneEquipConfig(1).returnFlowSched = Sched::GetScheduleAlwaysOn(*state); state->dataZoneEquip->ZoneEquipList(1).Name = "ZONE2EQUIPMENT"; int maxEquipCount = 1; state->dataZoneEquip->ZoneEquipList(1).NumOfEquipTypes = maxEquipCount; @@ -282,7 +282,6 @@ class AirloopUnitarySysTest : public EnergyPlusFixture state->dataHVACGlobal->NumPrimaryAirSys = 1; state->dataAirSystemsData->PrimaryAirSystems.allocate(1); state->dataAirLoop->AirLoopControlInfo.allocate(1); - Psychrometrics::InitializePsychRoutines(*state); state->dataLoopNodes->Node.allocate(30); state->dataHeatBal->HeatReclaimVS_DXCoil.allocate(4); } @@ -295,9 +294,7 @@ class AirloopUnitarySysTest : public EnergyPlusFixture TEST_F(AirloopUnitarySysTest, MultipleWaterCoolingCoilSizing) { - - FluidProperties::GetFluidPropertiesData(*state); - + state->init_state(*state); // Set up raw water coil sizes as coil-on-branch configuration then // test against sizing of same water coils in UnitarySystem @@ -367,6 +364,9 @@ TEST_F(AirloopUnitarySysTest, MultipleWaterCoolingCoilSizing) state->dataWaterCoils->WaterCoil(CoilNum).WaterOutletNodeNum = 2; state->dataWaterCoils->WaterCoil(CoilNum).AirInletNodeNum = 3; state->dataWaterCoils->WaterCoil(CoilNum).AirOutletNodeNum = 4; + + state->dataWaterCoils->WaterCoil(CoilNum).availSched = Sched::GetScheduleAlwaysOff(*state); + state->dataPlnt->PlantLoop(1).LoopSide(DataPlant::LoopSideLocation::Demand).Branch(1).Comp(1).NodeNumIn = state->dataWaterCoils->WaterCoil(CoilNum).WaterInletNodeNum; @@ -590,7 +590,7 @@ TEST_F(ZoneUnitarySysTest, Test_UnitarySystemModel_factory) Setpoint, !- Control Type East Zone, !- Controlling Zone or Thermostat Location None, !- Dehumidification Control Type - AlwaysOne, !- Availability Schedule Name + Constant-1.0, !- Availability Schedule Name Zone Exhaust Node, !- Air Inlet Node Name Zone 2 Inlet Node, !- Air Outlet Node Name Fan:OnOff, !- Supply Fan Object Type @@ -651,7 +651,7 @@ TEST_F(ZoneUnitarySysTest, Test_UnitarySystemModel_factory) Fan:OnOff, Supply Fan 1, !- Name - AlwaysOne, !- Availability Schedule Name + Constant-1.0, !- Availability Schedule Name 0.7, !- Fan Total Efficiency 600.0, !- Pressure Rise{ Pa } AutoSize, !- Maximum Flow Rate{ m3 / s } @@ -662,7 +662,7 @@ TEST_F(ZoneUnitarySysTest, Test_UnitarySystemModel_factory) Coil:Cooling:DX:MultiSpeed, DX Cooling Coil, !- Name - AlwaysOne, !- Availability Schedule Name + Constant-1.0, !- Availability Schedule Name Cooling Coil Air Inlet Node, !- Air Inlet Node Name Zone 2 Inlet Node, !- Air Outlet Node Name , !- Condenser Air Inlet Node Name @@ -724,13 +724,6 @@ TEST_F(ZoneUnitarySysTest, Test_UnitarySystemModel_factory) ScheduleTypeLimits, Any Number; !- Name - Schedule:Compact, - AlwaysOne, !- Name - Any Number, !- Schedule Type Limits Name - Through: 12/31, !- Field 1 - For: AllDays, !- Field 2 - Until: 24:00, 1.0; !- Field 3 - Schedule:Compact, Always 20C, !- Name Any Number, !- Schedule Type Limits Name @@ -773,6 +766,7 @@ TEST_F(ZoneUnitarySysTest, Test_UnitarySystemModel_factory) )IDF"; ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); // call the UnitarySystem factory std::string compName = "UNITARY SYSTEM MODEL"; @@ -793,10 +787,6 @@ TEST_F(ZoneUnitarySysTest, Test_UnitarySystemModel_factory) OutputReportPredefined::SetPredefinedTables(*state); - ScheduleManager::ProcessScheduleInput(*state); // read schedules - - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; // Enable schedule without calling schedule manager - state->dataGlobal->BeginEnvrnFlag = true; // act as if simulation is beginning // set up node conditions to test UnitarySystem set point based control @@ -867,7 +857,7 @@ TEST_F(ZoneUnitarySysTest, UnitarySystemModel_TwoSpeedDXCoolCoil_Only) Setpoint, !- Control Type East Zone, !- Controlling Zone or Thermostat Location None, !- Dehumidification Control Type - AlwaysOne, !- Availability Schedule Name + Constant-1.0, !- Availability Schedule Name Zone Exhaust Node, !- Air Inlet Node Name Zone 2 Inlet Node, !- Air Outlet Node Name Fan:OnOff, !- Supply Fan Object Type @@ -905,7 +895,7 @@ TEST_F(ZoneUnitarySysTest, UnitarySystemModel_TwoSpeedDXCoolCoil_Only) 80.0; !- Maximum Supply Air Temperature{ C } Fan:OnOff, Supply Fan 1, !- Name - AlwaysOne, !- Availability Schedule Name + Constant-1.0, !- Availability Schedule Name 0.7, !- Fan Total Efficiency 600.0, !- Pressure Rise{ Pa } autosize, !- Maximum Flow Rate{ m3 / s } @@ -942,12 +932,6 @@ TEST_F(ZoneUnitarySysTest, UnitarySystemModel_TwoSpeedDXCoolCoil_Only) EvaporativelyCooled; !- Condenser Type ScheduleTypeLimits, Any Number; !- Name - Schedule:Compact, - AlwaysOne, !- Name - Any Number, !- Schedule Type Limits Name - Through: 12/31, !- Field 1 - For: AllDays, !- Field 2 - Until: 24:00, 1.0; !- Field 3 Schedule:Compact, Always 20C, !- Name Any Number, !- Schedule Type Limits Name @@ -987,6 +971,7 @@ TEST_F(ZoneUnitarySysTest, UnitarySystemModel_TwoSpeedDXCoolCoil_Only) )IDF"; ASSERT_TRUE(process_idf(idf_objects)); // read idf objects + state->init_state(*state); // call the UnitarySystem factory std::string compName = "UNITARY SYSTEM MODEL"; @@ -1047,15 +1032,11 @@ TEST_F(ZoneUnitarySysTest, UnitarySystemModel_TwoSpeedDXCoolCoil_Only) state->dataLoopNodes->Node(1).HumRat = 0.00922; // 17C wb state->dataLoopNodes->Node(1).Enthalpy = 47597.03; // www.sugartech.com/psychro/index.php - ScheduleManager::ProcessScheduleInput(*state); // read schedules - // Cooling coil air inlet node = 3 state->dataLoopNodes->Node(3).MassFlowRateMax = thisSys->m_DesignMassFlowRate; // max at fan outlet so fan won't limit flow // Cooling coil air outlet node = 2 state->dataLoopNodes->Node(2).TempSetPoint = 17.0; - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; // Enable schedule without calling schedule manager - state->dataGlobal->BeginEnvrnFlag = true; // act as if simulation is beginning // COOLING mode @@ -1089,7 +1070,7 @@ TEST_F(ZoneUnitarySysTest, UnitarySystemModel_MultiSpeedDXCoolCoil_Only) Setpoint, !- Control Type East Zone, !- Controlling Zone or Thermostat Location None, !- Dehumidification Control Type - AlwaysOne, !- Availability Schedule Name + Constant-1.0, !- Availability Schedule Name Zone Exhaust Node, !- Air Inlet Node Name Zone 2 Inlet Node, !- Air Outlet Node Name Fan:OnOff, !- Supply Fan Object Type @@ -1149,7 +1130,7 @@ TEST_F(ZoneUnitarySysTest, UnitarySystemModel_MultiSpeedDXCoolCoil_Only) Fan:OnOff, Supply Fan 1, !- Name - AlwaysOne, !- Availability Schedule Name + Constant-1.0, !- Availability Schedule Name 0.7, !- Fan Total Efficiency 600.0, !- Pressure Rise{ Pa } autosize, !- Maximum Flow Rate{ m3 / s } @@ -1222,13 +1203,6 @@ TEST_F(ZoneUnitarySysTest, UnitarySystemModel_MultiSpeedDXCoolCoil_Only) ScheduleTypeLimits, Any Number; !- Name - Schedule:Compact, - AlwaysOne, !- Name - Any Number, !- Schedule Type Limits Name - Through: 12/31, !- Field 1 - For: AllDays, !- Field 2 - Until: 24:00, 1.0; !- Field 3 - Schedule:Compact, Always 20C, !- Name Any Number, !- Schedule Type Limits Name @@ -1271,6 +1245,7 @@ TEST_F(ZoneUnitarySysTest, UnitarySystemModel_MultiSpeedDXCoolCoil_Only) )IDF"; ASSERT_TRUE(process_idf(idf_objects)); // read idf objects + state->init_state(*state); // call the UnitarySystem factory std::string compName = "UNITARY SYSTEM MODEL"; @@ -1333,15 +1308,11 @@ TEST_F(ZoneUnitarySysTest, UnitarySystemModel_MultiSpeedDXCoolCoil_Only) state->dataLoopNodes->Node(1).HumRat = 0.00922; // 17C wb state->dataLoopNodes->Node(1).Enthalpy = 47597.03; // www.sugartech.com/psychro/index.php - ScheduleManager::ProcessScheduleInput(*state); // read schedules - // Cooling coil air inlet node = 3 state->dataLoopNodes->Node(3).MassFlowRateMax = thisSys->m_DesignMassFlowRate; // max at fan outlet so fan won't limit flow // Cooling coil air outlet node = 2 state->dataLoopNodes->Node(2).TempSetPoint = 17.0; - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; // Enable schedule without calling schedule manager - state->dataGlobal->BeginEnvrnFlag = true; // act as if simulation is beginning // COOLING mode @@ -1448,7 +1419,7 @@ TEST_F(ZoneUnitarySysTest, UnitarySystemModel_MultiStageGasHeatCoil_Only) Setpoint, !- Control Type East Zone, !- Controlling Zone or Thermostat Location None, !- Dehumidification Control Type - AlwaysOne, !- Availability Schedule Name + Constant-1.0, !- Availability Schedule Name Zone Exhaust Node, !- Air Inlet Node Name Zone 2 Inlet Node, !- Air Outlet Node Name Fan:OnOff, !- Supply Fan Object Type @@ -1506,7 +1477,7 @@ TEST_F(ZoneUnitarySysTest, UnitarySystemModel_MultiStageGasHeatCoil_Only) 1; !- Cooling Speed 2 Supply Air Flow Ratio Fan:OnOff, Supply Fan 1, !- Name - AlwaysOne, !- Availability Schedule Name + Constant-1.0, !- Availability Schedule Name 0.7, !- Fan Total Efficiency 600.0, !- Pressure Rise{ Pa } autosize, !- Maximum Flow Rate{ m3 / s } @@ -1516,7 +1487,7 @@ TEST_F(ZoneUnitarySysTest, UnitarySystemModel_MultiStageGasHeatCoil_Only) Heating Coil Air Inlet Node; !- Air Outlet Node Name Coil:Heating:Gas:MultiStage, Gas Heating Coil, !- Name - AlwaysOne, !- Availability Schedule Name + Constant-1.0, !- Availability Schedule Name Heating Coil Air Inlet Node, !- Air Inlet Node Name Zone 2 Inlet Node, !- Air Outlet Node Name , !- Temperature Setpoint Node Name @@ -1531,12 +1502,6 @@ TEST_F(ZoneUnitarySysTest, UnitarySystemModel_MultiStageGasHeatCoil_Only) 100; !- Stage 2 On Cycle Parasitic Electric Load{ W } ScheduleTypeLimits, Any Number; !- Name - Schedule:Compact, - AlwaysOne, !- Name - Any Number, !- Schedule Type Limits Name - Through: 12/31, !- Field 1 - For: AllDays, !- Field 2 - Until: 24:00, 1.0; !- Field 3 Schedule:Compact, Always 18C, !- Name Any Number, !- Schedule Type Limits Name @@ -1559,6 +1524,7 @@ TEST_F(ZoneUnitarySysTest, UnitarySystemModel_MultiStageGasHeatCoil_Only) )IDF"; ASSERT_TRUE(process_idf(idf_objects)); // read idf objects + state->init_state(*state); std::string compName = "UNITARY SYSTEM MODEL"; bool zoneEquipment = true; @@ -1612,15 +1578,11 @@ TEST_F(ZoneUnitarySysTest, UnitarySystemModel_MultiStageGasHeatCoil_Only) state->dataLoopNodes->Node(1).HumRat = 0.00922; // 17C wb state->dataLoopNodes->Node(1).Enthalpy = 47597.03; // www.sugartech.com/psychro/index.php - ScheduleManager::ProcessScheduleInput(*state); // read schedules - // Heating coil air inlet node = 3 state->dataLoopNodes->Node(3).MassFlowRateMax = thisSys->m_DesignMassFlowRate; // max at fan outlet so fan won't limit flow // Heating coil air outlet node = 2 state->dataLoopNodes->Node(2).TempSetPoint = 25.0; - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; // Enable schedule without calling schedule manager - state->dataGlobal->BeginEnvrnFlag = true; // act as if simulation is beginning // Heating mode @@ -1681,7 +1643,7 @@ TEST_F(ZoneUnitarySysTest, UnitarySystemModel_MultiStageElecHeatCoil_Only) Setpoint, !- Control Type East Zone, !- Controlling Zone or Thermostat Location None, !- Dehumidification Control Type - AlwaysOne, !- Availability Schedule Name + Constant-1.0, !- Availability Schedule Name Zone Exhaust Node, !- Air Inlet Node Name Zone 2 Inlet Node, !- Air Outlet Node Name Fan:OnOff, !- Supply Fan Object Type @@ -1741,7 +1703,7 @@ TEST_F(ZoneUnitarySysTest, UnitarySystemModel_MultiStageElecHeatCoil_Only) Fan:OnOff, Supply Fan 1, !- Name - AlwaysOne, !- Availability Schedule Name + Constant-1.0, !- Availability Schedule Name 0.7, !- Fan Total Efficiency 600.0, !- Pressure Rise{ Pa } autosize, !- Maximum Flow Rate{ m3 / s } @@ -1752,7 +1714,7 @@ TEST_F(ZoneUnitarySysTest, UnitarySystemModel_MultiStageElecHeatCoil_Only) Coil:Heating:Electric:MultiStage, Electric Heating Coil, !- Name - AlwaysOne, !- Availability Schedule Name + Constant-1.0, !- Availability Schedule Name Heating Coil Air Inlet Node, !- Air Inlet Node Name Zone 2 Inlet Node, !- Air Outlet Node Name , !- Temperature Setpoint Node Name @@ -1765,13 +1727,6 @@ TEST_F(ZoneUnitarySysTest, UnitarySystemModel_MultiStageElecHeatCoil_Only) ScheduleTypeLimits, Any Number; !- Name - Schedule:Compact, - AlwaysOne, !- Name - Any Number, !- Schedule Type Limits Name - Through: 12/31, !- Field 1 - For: AllDays, !- Field 2 - Until: 24:00, 1.0; !- Field 3 - Schedule:Compact, Always 18C, !- Name Any Number, !- Schedule Type Limits Name @@ -1796,6 +1751,7 @@ TEST_F(ZoneUnitarySysTest, UnitarySystemModel_MultiStageElecHeatCoil_Only) )IDF"; ASSERT_TRUE(process_idf(idf_objects)); // read idf objects + state->init_state(*state); std::string compName = "UNITARY SYSTEM MODEL"; bool zoneEquipment = true; @@ -1853,15 +1809,11 @@ TEST_F(ZoneUnitarySysTest, UnitarySystemModel_MultiStageElecHeatCoil_Only) state->dataLoopNodes->Node(1).HumRat = 0.00922; // 17C wb state->dataLoopNodes->Node(1).Enthalpy = 47597.03; // www.sugartech.com/psychro/index.php - ScheduleManager::ProcessScheduleInput(*state); // read schedules - // Heating coil air inlet node = 3 state->dataLoopNodes->Node(3).MassFlowRateMax = thisSys->m_DesignMassFlowRate; // max at fan outlet so fan won't limit flow // Heating coil air outlet node = 2 state->dataLoopNodes->Node(2).TempSetPoint = 25.0; - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; // Enable schedule without calling schedule manager - state->dataGlobal->BeginEnvrnFlag = true; // act as if simulation is beginning // Heating mode @@ -1928,7 +1880,7 @@ TEST_F(ZoneUnitarySysTest, UnitarySystemModel_MultiStageElecHeatCoil_Backup_Load Load, !- Control Type East Zone, !- Controlling Zone or Thermostat Location None, !- Dehumidification Control Type - AlwaysOne, !- Availability Schedule Name + Constant-1.0, !- Availability Schedule Name Zone Exhaust Node, !- Air Inlet Node Name Zone 2 Inlet Node, !- Air Outlet Node Name Fan:OnOff, !- Supply Fan Object Type @@ -1988,7 +1940,7 @@ TEST_F(ZoneUnitarySysTest, UnitarySystemModel_MultiStageElecHeatCoil_Backup_Load Fan:OnOff, Supply Fan 1, !- Name - AlwaysOne, !- Availability Schedule Name + Constant-1.0, !- Availability Schedule Name 0.7, !- Fan Total Efficiency 0.0, !- Pressure Rise{ Pa } autosize, !- Maximum Flow Rate{ m3 / s } @@ -1999,7 +1951,7 @@ TEST_F(ZoneUnitarySysTest, UnitarySystemModel_MultiStageElecHeatCoil_Backup_Load Coil:Heating:Electric:MultiStage, Electric Heating Coil, !- Name - AlwaysOne, !- Availability Schedule Name + Constant-1.0, !- Availability Schedule Name Heating Coil Air Inlet Node, !- Air Inlet Node Name Heating Coil Air Outlet Node, !- Air Outlet Node Name , !- Temperature Setpoint Node Name @@ -2011,7 +1963,7 @@ TEST_F(ZoneUnitarySysTest, UnitarySystemModel_MultiStageElecHeatCoil_Backup_Load Coil:Heating:Electric:MultiStage, Electric Backup Heating Coil, !- Name - AlwaysOne, !- Availability Schedule Name + Constant-1.0, !- Availability Schedule Name Heating Coil Air Outlet Node, !- Air Inlet Node Name Zone 2 Inlet Node, !- Air Outlet Node Name , !- Temperature Setpoint Node Name @@ -2024,13 +1976,6 @@ TEST_F(ZoneUnitarySysTest, UnitarySystemModel_MultiStageElecHeatCoil_Backup_Load ScheduleTypeLimits, Any Number; !- Name - Schedule:Compact, - AlwaysOne, !- Name - Any Number, !- Schedule Type Limits Name - Through: 12/31, !- Field 1 - For: AllDays, !- Field 2 - Until: 24:00, 1.0; !- Field 3 - Curve:Quadratic, Quadratic, !- Name 0.8, !- Coefficient1 Constant @@ -2042,6 +1987,7 @@ TEST_F(ZoneUnitarySysTest, UnitarySystemModel_MultiStageElecHeatCoil_Backup_Load )IDF"; ASSERT_TRUE(process_idf(idf_objects)); // read idf objects + state->init_state(*state); std::string compName = "UNITARY SYSTEM MODEL"; bool zoneEquipment = true; @@ -2081,7 +2027,7 @@ TEST_F(ZoneUnitarySysTest, UnitarySystemModel_MultiStageElecHeatCoil_Backup_Load state->dataZoneEnergyDemand->ZoneSysEnergyDemand(ControlZoneNum).RemainingOutputReqToCoolSP = 0; state->dataZoneEnergyDemand->ZoneSysEnergyDemand(ControlZoneNum).RemainingOutputReqToHeatSP = 0; state->dataZoneEnergyDemand->ZoneSysMoistureDemand(ControlZoneNum).RemainingOutputReqToDehumidSP = 0; - state->dataHeatBalFanSys->TempControlType(ControlZoneNum) = HVAC::ThermostatType::SingleHeating; + state->dataHeatBalFanSys->TempControlType(ControlZoneNum) = HVAC::SetptType::SingleHeat; thisSys->simulate(*state, thisSys->Name, @@ -2122,14 +2068,10 @@ TEST_F(ZoneUnitarySysTest, UnitarySystemModel_MultiStageElecHeatCoil_Backup_Load state->dataLoopNodes->Node(1).HumRat = 0.00922; // 17C wb state->dataLoopNodes->Node(1).Enthalpy = 47597.03; // www.sugartech.com/psychro/index.php - ScheduleManager::ProcessScheduleInput(*state); // read schedules - // Heating coil air inlet node = 3 state->dataLoopNodes->Node(3).MassFlowRateMax = thisSys->m_DesignMassFlowRate; // max at fan outlet so fan won't limit flow // Heating coil air outlet node = 2 - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; // Enable schedule without calling schedule manager - state->dataGlobal->BeginEnvrnFlag = true; // act as if simulation is beginning state->dataZoneEnergyDemand->ZoneSysEnergyDemand(ControlZoneNum).RemainingOutputRequired = 3000; @@ -2260,7 +2202,7 @@ AirLoopHVAC:UnitarySystem, Setpoint, !- Control Type East Zone, !- Controlling Zone or Thermostat Location None, !- Dehumidification Control Type - AlwaysOne, !- Availability Schedule Name + Constant-1.0, !- Availability Schedule Name Zone Exhaust Node, !- Air Inlet Node Name Zone 2 Inlet Node, !- Air Outlet Node Name Fan:OnOff, !- Supply Fan Object Type @@ -2320,7 +2262,7 @@ UnitarySystemPerformance:Multispeed, Fan:OnOff, Supply Fan 1, !- Name - AlwaysOne, !- Availability Schedule Name + Constant-1.0, !- Availability Schedule Name 0.7, !- Fan Total Efficiency 600.0, !- Pressure Rise{ Pa } autosize, !- Maximum Flow Rate{ m3 / s } @@ -2331,7 +2273,7 @@ Fan:OnOff, Coil:Heating:Electric:MultiStage, Electric Heating Coil, !- Name - AlwaysOne, !- Availability Schedule Name + Constant-1.0, !- Availability Schedule Name Heating Coil Air Inlet Node, !- Air Inlet Node Name Heating Coil Air Outlet Node, !- Air Outlet Node Name , !- Temperature Setpoint Node Name @@ -2343,7 +2285,7 @@ Coil:Heating:Electric:MultiStage, Coil:Heating:Electric:MultiStage, Electric Backup Heating Coil, !- Name - AlwaysOne, !- Availability Schedule Name + Constant-1.0, !- Availability Schedule Name Heating Coil Air Outlet Node, !- Air Inlet Node Name Zone 2 Inlet Node, !- Air Outlet Node Name , !- Temperature Setpoint Node Name @@ -2356,13 +2298,6 @@ Coil:Heating:Electric:MultiStage, ScheduleTypeLimits, Any Number; !- Name -Schedule:Compact, - AlwaysOne, !- Name - Any Number, !- Schedule Type Limits Name - Through: 12/31, !- Field 1 - For: AllDays, !- Field 2 - Until: 24:00, 1.0; !- Field 3 - Schedule:Compact, Always 18C, !- Name Any Number, !- Schedule Type Limits Name @@ -2387,6 +2322,7 @@ Curve:Quadratic, )IDF"; ASSERT_TRUE(process_idf(idf_objects)); // read idf objects + state->init_state(*state); std::string compName = "UNITARY SYSTEM MODEL"; bool zoneEquipment = true; @@ -2444,15 +2380,11 @@ Curve:Quadratic, state->dataLoopNodes->Node(1).HumRat = 0.00922; // 17C wb state->dataLoopNodes->Node(1).Enthalpy = 47597.03; // www.sugartech.com/psychro/index.php - ScheduleManager::ProcessScheduleInput(*state); // read schedules - // Heating coil air inlet node = 3 state->dataLoopNodes->Node(3).MassFlowRateMax = thisSys->m_DesignMassFlowRate; // max at fan outlet so fan won't limit flow // Heating coil air outlet node = 2 state->dataLoopNodes->Node(2).TempSetPoint = 25.0; - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; // Enable schedule without calling schedule manager - state->dataGlobal->BeginEnvrnFlag = true; // act as if simulation is beginning // Heating mode @@ -2548,7 +2480,7 @@ AirLoopHVAC:UnitarySystem, Load, !- Control Type East Zone, !- Controlling Zone or Thermostat Location None, !- Dehumidification Control Type - AlwaysOne, !- Availability Schedule Name + Constant-1.0, !- Availability Schedule Name Zone Exhaust Node, !- Air Inlet Node Name Zone 2 Inlet Node, !- Air Outlet Node Name Fan:OnOff, !- Supply Fan Object Type @@ -2608,7 +2540,7 @@ UnitarySystemPerformance:Multispeed, Fan:OnOff, Supply Fan 1, !- Name - AlwaysOne, !- Availability Schedule Name + Constant-1.0, !- Availability Schedule Name 0.7, !- Fan Total Efficiency 0.0, !- Pressure Rise{ Pa } autosize, !- Maximum Flow Rate{ m3 / s } @@ -2619,7 +2551,7 @@ Fan:OnOff, Coil:Heating:Electric:MultiStage, Electric Heating Coil, !- Name - AlwaysOne, !- Availability Schedule Name + Constant-1.0, !- Availability Schedule Name Heating Coil Air Inlet Node, !- Air Inlet Node Name Heating Coil Air Outlet Node, !- Air Outlet Node Name , !- Temperature Setpoint Node Name @@ -2631,7 +2563,7 @@ Coil:Heating:Electric:MultiStage, Coil:Heating:Electric:MultiStage, Electric Backup Heating Coil, !- Name - AlwaysOne, !- Availability Schedule Name + Constant-1.0, !- Availability Schedule Name Heating Coil Air Outlet Node, !- Air Inlet Node Name Zone 2 Inlet Node, !- Air Outlet Node Name , !- Temperature Setpoint Node Name @@ -2644,13 +2576,6 @@ Coil:Heating:Electric:MultiStage, ScheduleTypeLimits, Any Number; !- Name -Schedule:Compact, - AlwaysOne, !- Name - Any Number, !- Schedule Type Limits Name - Through: 12/31, !- Field 1 - For: AllDays, !- Field 2 - Until: 24:00, 1.0; !- Field 3 - Curve:Quadratic, Quadratic, !- Name 0.8, !- Coefficient1 Constant @@ -2662,6 +2587,7 @@ Curve:Quadratic, )IDF"; ASSERT_TRUE(process_idf(idf_objects)); // read idf objects + state->init_state(*state); std::string compName = "UNITARY SYSTEM MODEL"; bool zoneEquipment = true; @@ -2697,7 +2623,7 @@ Curve:Quadratic, state->dataHeatBalFanSys->TempControlType.allocate(1); state->dataZoneEnergyDemand->ZoneSysEnergyDemand(ControlZoneNum).RemainingOutputReqToCoolSP = 0; state->dataZoneEnergyDemand->ZoneSysMoistureDemand(ControlZoneNum).RemainingOutputReqToDehumidSP = 0; - state->dataHeatBalFanSys->TempControlType(ControlZoneNum) = HVAC::ThermostatType::SingleHeating; + state->dataHeatBalFanSys->TempControlType(ControlZoneNum) = HVAC::SetptType::SingleHeat; // set up node conditions to test UnitarySystem set point based control // Unitary system air inlet node = 1 @@ -2709,14 +2635,10 @@ Curve:Quadratic, state->dataLoopNodes->Node(1).HumRat = 0.00922; // 17C wb state->dataLoopNodes->Node(1).Enthalpy = 47597.03; // www.sugartech.com/psychro/index.php - ScheduleManager::ProcessScheduleInput(*state); // read schedules - // Heating coil air inlet node = 3 state->dataLoopNodes->Node(3).MassFlowRateMax = thisSys->m_DesignMassFlowRate; // max at fan outlet so fan won't limit flow // Heating coil air outlet node = 2 - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; // Enable schedule without calling schedule manager - state->dataGlobal->BeginEnvrnFlag = true; // act as if simulation is beginning state->dataZoneEnergyDemand->ZoneSysEnergyDemand(ControlZoneNum).RemainingOutputRequired = 5500; @@ -2794,7 +2716,7 @@ AirLoopHVAC:UnitarySystem, Setpoint, !- Control Type East Zone, !- Controlling Zone or Thermostat Location None, !- Dehumidification Control Type - AlwaysOne, !- Availability Schedule Name + Constant-1.0, !- Availability Schedule Name Zone Exhaust Node, !- Air Inlet Node Name Zone 2 Inlet Node, !- Air Outlet Node Name Fan:OnOff, !- Supply Fan Object Type @@ -2854,7 +2776,7 @@ UnitarySystemPerformance:Multispeed, Fan:OnOff, Supply Fan 1, !- Name - AlwaysOne, !- Availability Schedule Name + Constant-1.0, !- Availability Schedule Name 0.7, !- Fan Total Efficiency 600.0, !- Pressure Rise{ Pa } autosize, !- Maximum Flow Rate{ m3 / s } @@ -2865,7 +2787,7 @@ Fan:OnOff, Coil:Heating:Electric:MultiStage, Electric Heating Coil, !- Name - AlwaysOne, !- Availability Schedule Name + Constant-1.0, !- Availability Schedule Name Heating Coil Air Inlet Node, !- Air Inlet Node Name Heating Coil Air Outlet Node, !- Air Outlet Node Name , !- Temperature Setpoint Node Name @@ -2877,7 +2799,7 @@ Coil:Heating:Electric:MultiStage, Coil:Heating:Electric:MultiStage, Electric Backup Heating Coil, !- Name - AlwaysOne, !- Availability Schedule Name + Constant-1.0, !- Availability Schedule Name Heating Coil Air Outlet Node, !- Air Inlet Node Name Zone 2 Inlet Node, !- Air Outlet Node Name , !- Temperature Setpoint Node Name @@ -2890,13 +2812,6 @@ Coil:Heating:Electric:MultiStage, ScheduleTypeLimits, Any Number; !- Name -Schedule:Compact, - AlwaysOne, !- Name - Any Number, !- Schedule Type Limits Name - Through: 12/31, !- Field 1 - For: AllDays, !- Field 2 - Until: 24:00, 1.0; !- Field 3 - Schedule:Compact, Always 18C, !- Name Any Number, !- Schedule Type Limits Name @@ -2921,6 +2836,7 @@ Curve:Quadratic, )IDF"; ASSERT_TRUE(process_idf(idf_objects)); // read idf objects + state->init_state(*state); std::string compName = "UNITARY SYSTEM MODEL"; bool zoneEquipment = true; @@ -2977,13 +2893,9 @@ Curve:Quadratic, state->dataLoopNodes->Node(1).HumRat = 0.00922; // 17C wb state->dataLoopNodes->Node(1).Enthalpy = 47597.03; // www.sugartech.com/psychro/index.php - ScheduleManager::ProcessScheduleInput(*state); // read schedules - // Heating coil air inlet node = 3 state->dataLoopNodes->Node(3).MassFlowRateMax = thisSys->m_DesignMassFlowRate; // max at fan outlet so fan won't limit flow // Heating coil air outlet node = 2 - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; // Enable schedule without calling schedule manager - state->dataGlobal->BeginEnvrnFlag = true; // act as if simulation is beginning // Backup Heating coil air outlet node = 2 @@ -3021,7 +2933,6 @@ Curve:Quadratic, state->dataLoopNodes->Node(2).Temp = 24.0; state->dataLoopNodes->Node(3).Temp = 24.0; state->dataLoopNodes->Node(4).Temp = 24.0; - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; // Enable schedule without calling schedule manager state->dataLoopNodes->Node(1).HumRat = 0.00922; // 17C wb state->dataLoopNodes->Node(1).Enthalpy = 47597.03; // www.sugartech.com/psychro/index.php state->dataGlobal->BeginEnvrnFlag = true; // act as if simulation is beginning @@ -3066,7 +2977,7 @@ AirLoopHVAC:UnitarySystem, Setpoint, !- Control Type East Zone, !- Controlling Zone or Thermostat Location None, !- Dehumidification Control Type - AlwaysOne, !- Availability Schedule Name + Constant-1.0, !- Availability Schedule Name Zone Exhaust Node, !- Air Inlet Node Name Zone 2 Inlet Node, !- Air Outlet Node Name Fan:OnOff, !- Supply Fan Object Type @@ -3115,7 +3026,7 @@ AirLoopHVAC:UnitarySystem, Fan:OnOff, Supply Fan 1, !- Name - AlwaysOne, !- Availability Schedule Name + Constant-1.0, !- Availability Schedule Name 0.7, !- Fan Total Efficiency 600.0, !- Pressure Rise{ Pa } autosize, !- Maximum Flow Rate{ m3 / s } @@ -3126,7 +3037,7 @@ Fan:OnOff, Coil:Heating:Electric, Electric Heating Coil, !- Name - AlwaysOne, !- Availability Schedule Name + Constant-1.0, !- Availability Schedule Name 1.0, !- Efficiency autosize, !- Nominal Capacity Heating Coil Air Inlet Node, !- Air Inlet Node Name @@ -3136,13 +3047,6 @@ Coil:Heating:Electric, ScheduleTypeLimits, Any Number; !- Name -Schedule:Compact, - AlwaysOne, !- Name - Any Number, !- Schedule Type Limits Name - Through: 12/31, !- Field 1 - For: AllDays, !- Field 2 - Until: 24:00, 1.0; !- Field 3 - Schedule:Compact, Always 18C, !- Name Any Number, !- Schedule Type Limits Name @@ -3167,6 +3071,7 @@ Curve:Quadratic, )IDF"; ASSERT_TRUE(process_idf(idf_objects)); // read idf objects + state->init_state(*state); std::string compName = "UNITARY SYSTEM MODEL"; bool zoneEquipment = true; @@ -3220,15 +3125,11 @@ Curve:Quadratic, state->dataLoopNodes->Node(1).HumRat = 0.00922; // 17C wb state->dataLoopNodes->Node(1).Enthalpy = 47597.03; // www.sugartech.com/psychro/index.php - ScheduleManager::ProcessScheduleInput(*state); // read schedules - // Heating coil air inlet node = 3 state->dataLoopNodes->Node(3).MassFlowRateMax = thisSys->m_DesignMassFlowRate; // max at fan outlet so fan won't limit flow // Heating coil air outlet node = 2 state->dataLoopNodes->Node(2).TempSetPoint = 25.0; - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; // Enable schedule without calling schedule manager - state->dataGlobal->BeginEnvrnFlag = true; // act as if simulation is beginning // Heating mode @@ -3263,7 +3164,7 @@ AirLoopHVAC:UnitarySystem, Setpoint, !- Control Type East Zone, !- Controlling Zone or Thermostat Location None, !- Dehumidification Control Type - AlwaysOne, !- Availability Schedule Name + Constant-1.0, !- Availability Schedule Name Zone Exhaust Node, !- Air Inlet Node Name Zone 2 Inlet Node, !- Air Outlet Node Name Fan:OnOff, !- Supply Fan Object Type @@ -3323,7 +3224,7 @@ UnitarySystemPerformance:Multispeed, Fan:OnOff, Supply Fan 1, !- Name - AlwaysOne, !- Availability Schedule Name + Constant-1.0, !- Availability Schedule Name 0.7, !- Fan Total Efficiency 600.0, !- Pressure Rise{ Pa } autosize, !- Maximum Flow Rate{ m3 / s } @@ -3334,7 +3235,7 @@ Fan:OnOff, Coil:Heating:Gas:MultiStage, Gas Heating Coil, !- Name - AlwaysOne, !- Availability Schedule Name + Constant-1.0, !- Availability Schedule Name Heating Coil Air Inlet Node, !- Air Inlet Node Name Zone 2 Inlet Node, !- Air Outlet Node Name , !- Temperature Setpoint Node Name @@ -3351,13 +3252,6 @@ Coil:Heating:Gas:MultiStage, ScheduleTypeLimits, Any Number; !- Name -Schedule:Compact, - AlwaysOne, !- Name - Any Number, !- Schedule Type Limits Name - Through: 12/31, !- Field 1 - For: AllDays, !- Field 2 - Until: 24:00, 1.0; !- Field 3 - Schedule:Compact, Always 18C, !- Name Any Number, !- Schedule Type Limits Name @@ -3382,6 +3276,7 @@ Curve:Quadratic, )IDF"; ASSERT_TRUE(process_idf(idf_objects)); // read idf objects + state->init_state(*state); std::string compName = "UNITARY SYSTEM MODEL"; bool zoneEquipment = true; @@ -3435,15 +3330,11 @@ Curve:Quadratic, state->dataLoopNodes->Node(1).HumRat = 0.00922; // 17C wb state->dataLoopNodes->Node(1).Enthalpy = 47597.03; // www.sugartech.com/psychro/index.php - ScheduleManager::ProcessScheduleInput(*state); // read schedules - // Heating coil air inlet node = 3 state->dataLoopNodes->Node(3).MassFlowRateMax = thisSys->m_DesignMassFlowRate; // max at fan outlet so fan won't limit flow // Heating coil air outlet node = 2 state->dataLoopNodes->Node(2).TempSetPoint = 25.0; - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; // Enable schedule without calling schedule manager - state->dataGlobal->BeginEnvrnFlag = true; // act as if simulation is beginning // Heating mode @@ -3505,13 +3396,13 @@ AirLoopHVAC:UnitarySystem, Setpoint, !- Control Type East Zone, !- Controlling Zone or Thermostat Location None, !- Dehumidification Control Type - AlwaysOne, !- Availability Schedule Name + Constant-1.0, !- Availability Schedule Name Zone Exhaust Node, !- Air Inlet Node Name Zone 2 Inlet Node, !- Air Outlet Node Name Fan:OnOff, !- Supply Fan Object Type Supply Fan 1, !- Supply Fan Name BlowThrough, !- Fan Placement - AlwaysOne, !- Supply Air Fan Operating Mode Schedule Name + Constant-1.0, !- Supply Air Fan Operating Mode Schedule Name Coil:Heating:DX:VariableSpeed, !- Heating Coil Object Type DX Heating Coil, !- Heating Coil Name , !- DX Heating Coil Sizing Ratio @@ -3581,7 +3472,7 @@ UnitarySystemPerformance:Multispeed, Fan:OnOff, Supply Fan 1, !- Name - AlwaysOne, !- Availability Schedule Name + Constant-1.0, !- Availability Schedule Name 0.7, !- Fan Total Efficiency 600.0, !- Pressure Rise{ Pa } autosize, !- Maximum Flow Rate{ m3 / s } @@ -3858,13 +3749,6 @@ Coil:Heating:DX:VariableSpeed, ScheduleTypeLimits, Any Number; !- Name -Schedule:Compact, - AlwaysOne, !- Name - Any Number, !- Schedule Type Limits Name - Through: 12/31, !- Field 1 - For: AllDays, !- Field 2 - Until: 24:00, 1.0; !- Field 3 - Schedule:Compact, Always 16C, !- Name Any Number, !- Schedule Type Limits Name @@ -3927,6 +3811,7 @@ Curve:Biquadratic, )IDF"; ASSERT_TRUE(process_idf(idf_objects)); // read idf objects + state->init_state(*state); std::string compName = "UNITARY SYSTEM MODEL"; bool zoneEquipment = true; @@ -3997,8 +3882,6 @@ Curve:Biquadratic, // Heating coil air outlet node = 2 state->dataLoopNodes->Node(2).TempSetPoint = 16.0; - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; // Enable schedule without calling schedule manager - state->dataGlobal->BeginEnvrnFlag = true; // act as if simulation is beginning // COOLING mode @@ -4176,13 +4059,13 @@ AirLoopHVAC:UnitarySystem, Setpoint, !- Control Type East Zone, !- Controlling Zone or Thermostat Location None, !- Dehumidification Control Type - AlwaysOne, !- Availability Schedule Name + Constant-1.0, !- Availability Schedule Name Zone Exhaust Node, !- Air Inlet Node Name Zone 2 Inlet Node, !- Air Outlet Node Name Fan:OnOff, !- Supply Fan Object Type Supply Fan 1, !- Supply Fan Name BlowThrough, !- Fan Placement - AlwaysOne, !- Supply Air Fan Operating Mode Schedule Name + Constant-1.0, !- Supply Air Fan Operating Mode Schedule Name Coil:Heating:Water, !- Heating Coil Object Type Water Heating Coil, !- Heating Coil Name , !- DX Heating Coil Sizing Ratio @@ -4215,7 +4098,7 @@ AirLoopHVAC:UnitarySystem, Fan:OnOff, Supply Fan 1, !- Name - AlwaysOne, !- Availability Schedule Name + Constant-1.0, !- Availability Schedule Name 0.7, !- Fan Total Efficiency 600.0, !- Pressure Rise{ Pa } 1.6, !- Maximum Flow Rate{ m3 / s } @@ -4226,7 +4109,7 @@ Fan:OnOff, Coil:Cooling:Water, Water Cooling Coil, !- Name - AlwaysOne, !- Availability Schedule Namev + Constant-1.0, !- Availability Schedule Namev 0.0004, !- Design Water Flow Rate { m3 / s } 1.6000, !- Design Air Flow Rate { m3 / s } 7.22, !- Design Inlet Water Temperature { Cv } @@ -4243,7 +4126,7 @@ Coil:Cooling:Water, Coil:Heating:Water, Water Heating Coil, !- Name - AlwaysOne, !- Availability Schedule Name + Constant-1.0, !- Availability Schedule Name 300.0, !- U - Factor Times Area Value { W / K } 0.0006, !- Maximum Water Flow Rate { m3 / s } HWInletNode, !- Water Inlet Node Name @@ -4260,7 +4143,7 @@ Coil:Heating:Water, Coil:Heating:Water, Supp Water Heating Coil, !- Name - AlwaysOne, !- Availability Schedule Name + Constant-1.0, !- Availability Schedule Name 300.0, !- U - Factor Times Area Value { W / K } 0.0006, !- Maximum Water Flow Rate { m3 / s } SuppHWInletNode, !- Water Inlet Node Name @@ -4278,13 +4161,6 @@ Coil:Heating:Water, ScheduleTypeLimits, Any Number; !- Name -Schedule:Compact, - AlwaysOne, !- Name - Any Number, !- Schedule Type Limits Name - Through: 12/31, !- Field 1 - For: AllDays, !- Field 2 - Until: 24:00, 1.0; !- Field 3 - Schedule:Compact, Always 16C, !- Name Any Number, !- Schedule Type Limits Name @@ -4327,6 +4203,7 @@ SetpointManager:Scheduled, )IDF"; ASSERT_TRUE(process_idf(idf_objects)); // read idf objects + state->init_state(*state); std::string compName = "UNITARY SYSTEM MODEL"; bool zoneEquipment = true; @@ -4436,8 +4313,6 @@ SetpointManager:Scheduled, state->dataLoopNodes->Node(suppHeatingCoilWaterInletNodeIndex).Temp = 60.0; state->dataLoopNodes->Node(suppHeatingCoilWaterInletNodeIndex).Enthalpy = 251221.6; // www.peacesoftware.de/einigewerte/calc_dampf.php5 - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; // Enable schedule without calling schedule manager - state->dataGlobal->BeginEnvrnFlag = true; // act as if simulation is beginning // COOLING mode @@ -4611,13 +4486,13 @@ AirLoopHVAC:UnitarySystem, Setpoint, !- Control Type East Zone, !- Controlling Zone or Thermostat Location CoolReheat, !- Dehumidification Control Type - AlwaysOne, !- Availability Schedule Name + Constant-1.0, !- Availability Schedule Name Water Cooling Coil Air Inlet Node, !- Air Inlet Node Name Zone Inlet Node, !- Air Outlet Node Name Fan:OnOff, !- Supply Fan Object Type Supply Fan 1, !- Supply Fan Name DrawThrough, !- Fan Placement - AlwaysOne, !- Supply Air Fan Operating Mode Schedule Name + Constant-1.0, !- Supply Air Fan Operating Mode Schedule Name , !- Heating Coil Object Type , !- Heating Coil Name , !- DX Heating Coil Sizing Ratio @@ -4650,7 +4525,7 @@ AirLoopHVAC:UnitarySystem, Fan:OnOff, Supply Fan 1, !- Name - AlwaysOne, !- Availability Schedule Name + Constant-1.0, !- Availability Schedule Name 0.7, !- Fan Total Efficiency 600.0, !- Pressure Rise{ Pa } 1.6, !- Maximum Flow Rate{ m3 / s } @@ -4661,7 +4536,7 @@ Fan:OnOff, Coil:Cooling:Water, Water Cooling Coil, !- Name - AlwaysOne, !- Availability Schedule Namev + Constant-1.0, !- Availability Schedule Namev 0.0008, !- Design Water Flow Rate { m3 / s } 1.6000, !- Design Air Flow Rate { m3 / s } 7.22, !- Design Inlet Water Temperature { Cv } @@ -4679,13 +4554,6 @@ Coil:Cooling:Water, ScheduleTypeLimits, Any Number; !- Name -Schedule:Compact, - AlwaysOne, !- Name - Any Number, !- Schedule Type Limits Name - Through: 12/31, !- Field 1 - For: AllDays, !- Field 2 - Until: 24:00, 1.0; !- Field 3 - Schedule:Compact, Always 20C, !- Name Any Number, !- Schedule Type Limits Name @@ -4714,6 +4582,7 @@ SetpointManager:Scheduled, )IDF"; ASSERT_TRUE(process_idf(idf_objects)); // read idf objects + state->init_state(*state); std::string compName = "UNITARY SYSTEM MODEL"; bool zoneEquipment = true; @@ -4788,8 +4657,6 @@ SetpointManager:Scheduled, state->dataLoopNodes->Node(coolingCoilWaterInletNodeIndex).Temp = 6.0; state->dataLoopNodes->Node(coolingCoilWaterInletNodeIndex).Enthalpy = 25321.8; // www.peacesoftware.de/einigewerte/calc_dampf.php5 - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; // Enable schedule without calling schedule manager - state->dataGlobal->BeginEnvrnFlag = true; // act as if simulation is beginning // Case 0 - COOLING mode - no load, sensible or latent @@ -4978,6 +4845,7 @@ Schedule:Compact, )IDF"; ASSERT_TRUE(process_idf(idf_objects)); // read idf objects + state->init_state(*state); UnitarySys thisSys; state->dataUnitarySystems->numUnitarySystems = 1; @@ -4993,9 +4861,8 @@ Schedule:Compact, state->dataHVACGlobal->MSHPMassFlowRateLow = 0.0; state->dataHVACGlobal->MSHPMassFlowRateHigh = 0.0; - thisSys.m_SysAvailSchedPtr = ScheduleManager::GetScheduleIndex(*state, "FanAndCoilAvailSched"); // "Get" the schedule inputs - thisSys.m_FanAvailSchedPtr = ScheduleManager::GetScheduleIndex(*state, "FanAndCoilAvailSched"); - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; // set availability and fan schedule to 1 + thisSys.m_sysAvailSched = Sched::GetSchedule(*state, "FANANDCOILAVAILSCHED"); // "Get" the schedule inputs + thisSys.m_fanAvailSched = Sched::GetSchedule(*state, "FANANDCOILAVAILSCHED"); thisSys.m_HeatMassFlowRate.resize(4); thisSys.m_CoolMassFlowRate.resize(4); @@ -5005,7 +4872,7 @@ Schedule:Compact, thisSys.m_LastMode = UnitarySystems::HeatingMode; thisSys.MaxNoCoolHeatAirMassFlow = 0.2; thisSys.m_NoLoadAirFlowRateRatio = 0.2; - thisSys.m_FanAvailSchedPtr = ScheduleManager::ScheduleAlwaysOn; + thisSys.m_fanAvailSched = Sched::GetScheduleAlwaysOn(*state); thisSys.AirInNode = 1; thisSys.m_HeatMassFlowRate[1] = 0.25; @@ -5479,8 +5346,7 @@ TEST_F(EnergyPlusFixture, UnitarySystemModel_ConfirmUnitarySystemSizingTest) TEST_F(EnergyPlusFixture, UnitarySystemModel_CalcUnitaryHeatingSystem) { - - FluidProperties::GetFluidPropertiesData(*state); + state->init_state(*state); int AirLoopNum(1); bool FirstHVACIteration(false); HVAC::CompressorOp CompressorOn(HVAC::CompressorOp::On); @@ -5506,7 +5372,7 @@ TEST_F(EnergyPlusFixture, UnitarySystemModel_CalcUnitaryHeatingSystem) thisSys.m_LastMode = UnitarySystems::HeatingMode; thisSys.MaxNoCoolHeatAirMassFlow = 0.2; thisSys.m_NoLoadAirFlowRateRatio = 0.2; - thisSys.m_FanAvailSchedPtr = ScheduleManager::ScheduleAlwaysOn; + thisSys.m_fanAvailSched = Sched::GetScheduleAlwaysOn(*state); thisSys.AirInNode = 1; thisSys.m_HeatMassFlowRate[1] = 0.25; thisSys.m_MSHeatingSpeedRatio[1] = 0.25; @@ -5549,7 +5415,7 @@ TEST_F(EnergyPlusFixture, UnitarySystemModel_CalcUnitaryHeatingSystem) state->dataWaterCoils->CheckEquipName.allocate(1); state->dataWaterCoils->NumWaterCoils = 1; state->dataWaterCoils->GetWaterCoilsInputFlag = false; - state->dataWaterCoils->WaterCoil(1).SchedPtr = ScheduleManager::ScheduleAlwaysOn; + state->dataWaterCoils->WaterCoil(1).availSched = Sched::GetScheduleAlwaysOn(*state); state->dataWaterCoils->WaterCoil(1).Name = "Water Heating Coil"; state->dataWaterCoils->WaterCoil(1).WaterCoilType = DataPlant::PlantEquipmentType::CoilWaterSimpleHeating; state->dataWaterCoils->WaterCoil(1).DesAirVolFlowRate = 1.0; @@ -5621,8 +5487,8 @@ TEST_F(EnergyPlusFixture, UnitarySystemModel_CalcUnitaryHeatingSystem) TEST_F(EnergyPlusFixture, UnitarySystemModel_CalcUnitaryCoolingSystem) { + state->init_state(*state); - FluidProperties::GetFluidPropertiesData(*state); HVAC::CompressorOp CompressorOn(HVAC::CompressorOp::On); int AirLoopNum(1); bool FirstHVACIteration(false); @@ -5640,7 +5506,6 @@ TEST_F(EnergyPlusFixture, UnitarySystemModel_CalcUnitaryCoolingSystem) state->dataEnvrn->OutBaroPress = 101325.0; state->dataEnvrn->StdRhoAir = 1.20; - Psychrometrics::InitializePsychRoutines(*state); thisSys.m_MultiOrVarSpeedHeatCoil = true; thisSys.m_MultiOrVarSpeedCoolCoil = true; @@ -5654,7 +5519,7 @@ TEST_F(EnergyPlusFixture, UnitarySystemModel_CalcUnitaryCoolingSystem) thisSys.m_LastMode = UnitarySystems::HeatingMode; thisSys.MaxNoCoolHeatAirMassFlow = 0.2; thisSys.m_NoLoadAirFlowRateRatio = 0.2; - thisSys.m_FanAvailSchedPtr = ScheduleManager::ScheduleAlwaysOn; + thisSys.m_fanAvailSched = Sched::GetScheduleAlwaysOn(*state); thisSys.AirInNode = 1; thisSys.m_HeatMassFlowRate[1] = 0.25; thisSys.m_MSHeatingSpeedRatio[1] = 0.25; @@ -5693,7 +5558,7 @@ TEST_F(EnergyPlusFixture, UnitarySystemModel_CalcUnitaryCoolingSystem) state->dataWaterCoils->CheckEquipName.allocate(1); state->dataWaterCoils->NumWaterCoils = 1; state->dataWaterCoils->GetWaterCoilsInputFlag = false; - state->dataWaterCoils->WaterCoil(1).SchedPtr = ScheduleManager::ScheduleAlwaysOn; + state->dataWaterCoils->WaterCoil(1).availSched = Sched::GetScheduleAlwaysOn(*state); state->dataWaterCoils->WaterCoil(1).Name = "Water Cooling Coil"; state->dataWaterCoils->WaterCoil(1).WaterCoilType = DataPlant::PlantEquipmentType::CoilWaterCooling; state->dataWaterCoils->WaterCoil(1).WaterCoilModel = WaterCoils::CoilModel::CoolingSimple; @@ -5991,6 +5856,7 @@ Curve:Biquadratic, )IDF"; ASSERT_TRUE(process_idf(idf_objects)); // read idf objects + state->init_state(*state); HeatBalanceManager::GetZoneData(*state, ErrorsFound); // read zone data EXPECT_FALSE(ErrorsFound); // expect no errors @@ -6054,12 +5920,12 @@ Curve:Biquadratic, state->dataHeatBalFanSys->TempControlType.allocate(1); state->dataHeatBalFanSys->TempControlTypeRpt.allocate(1); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::DualSetPointWithDeadBand; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::DualHeatCool; state->dataZoneEnergyDemand->CurDeadBandOrSetback.allocate(1); // UnitarySystem does not care (or look at) if Tstat is in deadband // This line tests case where other zone equipment changes deadband status state->dataZoneEnergyDemand->CurDeadBandOrSetback(1) = true; - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; + Sched::GetSchedule(*state, "FANANDCOILAVAILSCHED")->currentVal = 1.0; // Enable schedule without calling schedule manager state->dataGlobal->BeginEnvrnFlag = true; state->dataEnvrn->StdRhoAir = Psychrometrics::PsyRhoAirFnPbTdbW(*state, 101325.0, 20.0, 0.0); // initialize RhoAir state->dataLoopNodes->Node(InletNode).MassFlowRateMaxAvail = thisSys->m_MaxCoolAirVolFlow * state->dataEnvrn->StdRhoAir; @@ -6637,6 +6503,7 @@ Curve:Biquadratic, )IDF"; ASSERT_TRUE(process_idf(idf_objects)); // read idf objects + state->init_state(*state); HeatBalanceManager::GetZoneData(*state, ErrorsFound); // read zone data EXPECT_FALSE(ErrorsFound); // expect no errors @@ -6999,6 +6866,7 @@ Curve:Biquadratic, )IDF"; ASSERT_TRUE(process_idf(idf_objects)); // read idf objects + state->init_state(*state); HeatBalanceManager::GetZoneData(*state, ErrorsFound); // read zone data EXPECT_FALSE(ErrorsFound); // expect no errors @@ -7067,9 +6935,10 @@ Curve:Biquadratic, state->dataHeatBalFanSys->TempControlType.allocate(1); state->dataHeatBalFanSys->TempControlTypeRpt.allocate(1); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::DualSetPointWithDeadBand; - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; // FanAndCoilAvailSchedule - state->dataScheduleMgr->Schedule(2).CurrentValue = 1.0; // ContinuousFanSchedule + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::DualHeatCool; + Sched::GetSchedule(*state, "FANANDCOILAVAILSCHED")->currentVal = 1.0; + Sched::GetSchedule(*state, "FANANDCOILAVAILSCHED")->currentVal = 1.0; + Sched::GetSchedule(*state, "CONTINUOUSFANSCHEDULE")->currentVal = 1.0; // ContinuousFanSchedule state->dataGlobal->BeginEnvrnFlag = true; state->dataEnvrn->StdRhoAir = Psychrometrics::PsyRhoAirFnPbTdbW(*state, 101325.0, 20.0, 0.0); // initialize RhoAir state->dataLoopNodes->Node(InletNode).MassFlowRateMaxAvail = thisSys->m_MaxCoolAirVolFlow * state->dataEnvrn->StdRhoAir; @@ -7495,6 +7364,7 @@ Curve:Biquadratic, )IDF"; ASSERT_TRUE(process_idf(idf_objects)); // read idf objects + state->init_state(*state); HeatBalanceManager::GetZoneData(*state, ErrorsFound); // read zone data EXPECT_FALSE(ErrorsFound); // expect no errors @@ -7560,8 +7430,8 @@ Curve:Biquadratic, state->dataHeatBalFanSys->TempControlType.allocate(1); state->dataHeatBalFanSys->TempControlTypeRpt.allocate(1); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::DualSetPointWithDeadBand; - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::DualHeatCool; + Sched::GetSchedule(*state, "FANANDCOILAVAILSCHED")->currentVal = 1.0; state->dataGlobal->BeginEnvrnFlag = true; state->dataEnvrn->StdRhoAir = Psychrometrics::PsyRhoAirFnPbTdbW(*state, 101325.0, 20.0, 0.0); // initialize RhoAir state->dataLoopNodes->Node(InletNode).MassFlowRateMaxAvail = thisSys->m_MaxCoolAirVolFlow * state->dataEnvrn->StdRhoAir; @@ -7829,6 +7699,7 @@ Curve:Biquadratic, )IDF"; ASSERT_TRUE(process_idf(idf_objects)); // read idf objects + state->init_state(*state); HeatBalanceManager::GetZoneData(*state, ErrorsFound); // read zone data EXPECT_FALSE(ErrorsFound); // expect no errors @@ -8012,6 +7883,7 @@ Curve:Biquadratic, )IDF"; ASSERT_TRUE(process_idf(idf_objects)); // read idf objects + state->init_state(*state); HeatBalanceManager::GetZoneData(*state, ErrorsFound); // read zone data EXPECT_FALSE(ErrorsFound); // expect no errors @@ -8457,9 +8329,9 @@ OutdoorAir:NodeList, ASSERT_TRUE(process_idf(idf_objects)); // read idf objects - state->dataGlobal->NumOfTimeStepInHour = 1; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 60; // must initialize this to get schedules initialized - ScheduleManager::ProcessScheduleInput(*state); + state->dataGlobal->TimeStepsInHour = 1; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 60; // must initialize this to get schedules initialized + state->init_state(*state); HeatBalanceManager::GetZoneData(*state, ErrorsFound); // read zone data EXPECT_FALSE(ErrorsFound); // expect no errors @@ -9223,8 +9095,8 @@ Curve:Biquadratic, )IDF"; ASSERT_TRUE(process_idf(idf_objects)); // read idf objects + state->init_state(*state); - SimulationManager::GetProjectData(*state); createFacilityElectricPowerServiceObject(*state); state->dataGlobal->BeginSimFlag = true; state->dataGlobal->DoingSizing = true; @@ -9370,7 +9242,6 @@ Curve:Biquadratic, TEST_F(EnergyPlusFixture, UnitarySystemModel_WaterToAirHeatPump_LoadControl) { - bool ErrorsFound(false); bool FirstHVACIteration(false); Real64 Qsens_sys(0.0); // UnitarySystem delivered sensible capacity wrt zone @@ -9685,6 +9556,7 @@ Curve:QuadLinear, )IDF"; ASSERT_TRUE(process_idf(idf_objects)); // read idf objects + state->init_state(*state); HeatBalanceManager::GetZoneData(*state, ErrorsFound); // read zone data EXPECT_FALSE(ErrorsFound); // expect no errors @@ -9780,8 +9652,8 @@ Curve:QuadLinear, state->dataHeatBalFanSys->TempControlType.allocate(1); state->dataHeatBalFanSys->TempControlTypeRpt.allocate(1); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::DualSetPointWithDeadBand; - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::DualHeatCool; +Sched::GetSchedule(*state, "FANANDCOILAVAILSCHED")->currentVal = 1.0; state->dataGlobal->BeginEnvrnFlag = true; state->dataEnvrn->StdRhoAir = Psychrometrics::PsyRhoAirFnPbTdbW(*state, 101325.0, 20.0, 0.0); // initialize RhoAir state->dataLoopNodes->Node(InletNode).MassFlowRateMaxAvail = thisSys->m_DesignFanVolFlowRate * state->dataEnvrn->StdRhoAir; @@ -10026,6 +9898,7 @@ Schedule:Compact, )IDF"; ASSERT_TRUE(process_idf(idf_objects)); // read idf objects + state->init_state(*state); HeatBalanceManager::GetZoneData(*state, ErrorsFound); // read zone data EXPECT_FALSE(ErrorsFound); // expect no errors @@ -10123,10 +9996,10 @@ Schedule:Compact, state->dataHeatBalFanSys->TempControlType.allocate(1); state->dataHeatBalFanSys->TempControlTypeRpt.allocate(1); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::DualSetPointWithDeadBand; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::DualHeatCool; // fill the schedule values - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; // availability - state->dataScheduleMgr->Schedule(2).CurrentValue = 1.0; // constant fan + Sched::GetSchedule(*state, "FANANDCOILAVAILSCHED")->currentVal = 1.0; // availability + Sched::GetSchedule(*state, "CONTINUOUSFANSCHEDULE")->currentVal = 1.0; // constant fan state->dataGlobal->BeginEnvrnFlag = true; state->dataEnvrn->StdRhoAir = Psychrometrics::PsyRhoAirFnPbTdbW(*state, 101325.0, 20.0, 0.0); // initialize RhoAir state->dataLoopNodes->Node(InletNode).MassFlowRateMaxAvail = thisSys->m_DesignFanVolFlowRate * state->dataEnvrn->StdRhoAir; @@ -11086,8 +10959,8 @@ Schedule:Compact, )IDF"; ASSERT_TRUE(process_idf(idf_objects)); // read idf objects + state->init_state(*state); - SimulationManager::GetProjectData(*state); createFacilityElectricPowerServiceObject(*state); state->dataGlobal->BeginSimFlag = true; state->dataGlobal->DoingSizing = true; @@ -11870,6 +11743,7 @@ TEST_F(EnergyPlusFixture, UnitarySystemModel_MultiSpeedCoils_SingleMode) }); ASSERT_TRUE(process_idf(idf_objects)); // read idf objects + state->init_state(*state); state->dataEnvrn->OutDryBulbTemp = 35.0; // initialize weather before input processing state->dataEnvrn->OutHumRat = 0.1; @@ -11927,7 +11801,7 @@ TEST_F(EnergyPlusFixture, UnitarySystemModel_MultiSpeedCoils_SingleMode) state->dataZoneEnergyDemand->ZoneSysMoistureDemand(thisSys->ControlZoneNum).SequencedOutputRequiredToDehumidSP.allocate(1); state->dataHeatBalFanSys->TempControlType.allocate(1); state->dataHeatBalFanSys->TempControlTypeRpt.allocate(1); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::DualSetPointWithDeadBand; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::DualHeatCool; InletNode = thisSys->AirInNode; OutletNode = thisSys->AirOutNode; @@ -11950,7 +11824,7 @@ TEST_F(EnergyPlusFixture, UnitarySystemModel_MultiSpeedCoils_SingleMode) thisSys->m_ZoneInletNode = state->dataZoneEquip->ZoneEquipConfig(1).InletNode(1); - state->dataScheduleMgr->Schedule(thisSys->m_SysAvailSchedPtr).CurrentValue = 1.0; + thisSys->m_sysAvailSched->currentVal = 1.0; state->dataSize->CurSysNum = 1; state->dataSize->UnitarySysEqSizing.allocate(1); @@ -13100,8 +12974,8 @@ Curve:Biquadratic, )IDF"; ASSERT_TRUE(process_idf(idf_objects)); // read idf objects + state->init_state(*state); - SimulationManager::GetProjectData(*state); createFacilityElectricPowerServiceObject(*state); state->dataGlobal->BeginSimFlag = true; @@ -13215,6 +13089,7 @@ TEST_F(EnergyPlusFixture, UnitarySystemModel_SizingWithFans) )IDF"; ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); Fans::GetFanInput(*state); @@ -13257,7 +13132,6 @@ TEST_F(EnergyPlusFixture, UnitarySystemModel_SizingWithFans) state->dataSize->NumSysSizInput = 1; state->dataEnvrn->StdBaroPress = 101325.0; - Psychrometrics::InitializePsychRoutines(*state); // Need this to prevent crash in Sizers state->dataSize->UnitarySysEqSizing.allocate(1); @@ -13457,6 +13331,7 @@ Coil:Heating:Electric, )IDF"; ASSERT_TRUE(process_idf(idf_objects)); // read idf objects + state->init_state(*state); bool ErrorsFound = false; HeatBalanceManager::GetZoneData(*state, ErrorsFound); @@ -13603,6 +13478,7 @@ Coil:Heating:Electric, )IDF"; ASSERT_TRUE(process_idf(idf_objects)); // read idf objects + state->init_state(*state); bool ErrorsFound = false; HeatBalanceManager::GetZoneData(*state, ErrorsFound); @@ -13726,6 +13602,7 @@ Coil:Heating:Electric, )IDF"; ASSERT_TRUE(process_idf(idf_objects)); // read idf objects + state->init_state(*state); bool ErrorsFound = false; HeatBalanceManager::GetZoneData(*state, ErrorsFound); @@ -13851,6 +13728,7 @@ Coil:Heating:Electric, )IDF"; ASSERT_TRUE(process_idf(idf_objects)); // read idf objects + state->init_state(*state); bool ErrorsFound = false; HeatBalanceManager::GetZoneData(*state, ErrorsFound); @@ -13968,6 +13846,8 @@ TEST_F(ZoneUnitarySysTest, UnitarySystemModel_FractionOfAutoSizedCoolingValueTes )IDF"; ASSERT_TRUE(process_idf(idf_objects)); // read idf objects + state->init_state(*state); + // call the UnitarySystem factory bool ErrorsFound = false; @@ -14117,6 +13997,7 @@ TEST_F(ZoneUnitarySysTest, UnitarySystemModel_FlowPerCoolingCapacityTest) )IDF"; ASSERT_TRUE(process_idf(idf_objects)); // read idf objects + state->init_state(*state); // call the UnitarySystem factory bool ErrorsFound = false; @@ -14291,6 +14172,7 @@ TEST_F(ZoneUnitarySysTest, UnitarySystemModel_getUnitarySystemInputDataTest) )IDF"; ASSERT_TRUE(process_idf(idf_objects)); // read idf objects + state->init_state(*state); // call the UnitarySystem factory bool ErrorsFound = false; @@ -14307,13 +14189,13 @@ TEST_F(ZoneUnitarySysTest, UnitarySystemModel_getUnitarySystemInputDataTest) EXPECT_ENUM_EQ(UnitarySys::UnitarySysCtrlType::Load, thisSys->m_ControlType); // checks control type EXPECT_ENUM_EQ(UnitarySys::DehumCtrlType::None, thisSys->m_DehumidControlType_Num); // checks Dehumidification Control type EXPECT_EQ(Util::FindItemInList("EAST ZONE", state->dataHeatBal->Zone), thisSys->ControlZoneNum); // checks zone ID - EXPECT_EQ(ScheduleManager::ScheduleAlwaysOn, thisSys->m_SysAvailSchedPtr); // checks availability schedule name + EXPECT_EQ(Sched::GetScheduleAlwaysOn(*state), thisSys->m_sysAvailSched); // checks availability schedule name EXPECT_EQ("NODE 29", state->dataLoopNodes->NodeID(thisSys->AirInNode)); // checks air inlet node name EXPECT_EQ("NODE 30", state->dataLoopNodes->NodeID(thisSys->AirOutNode)); // checks air outlet node name EXPECT_EQ((int)HVAC::FanType::OnOff, (int)thisSys->m_FanType); // checks fan object type "FAN:ONOFF" EXPECT_EQ("SUPPLY FAN", thisSys->m_FanName); // checks fan object name EXPECT_EQ((int)HVAC::FanPlace::DrawThru, (int)thisSys->m_FanPlace); // checks fan placement, "DrawThrough" - EXPECT_EQ(0, thisSys->m_FanOpModeSchedPtr); // checks Supply Air Fan Operating Mode Schedule Name + EXPECT_EQ(nullptr, thisSys->m_fanOpModeSched); // checks Supply Air Fan Operating Mode Schedule Name EXPECT_EQ("COIL:HEATING:WATER", thisSys->m_HeatingCoilTypeName); // checks heating coil object type EXPECT_EQ("WATER HEATING COIL", thisSys->m_HeatingCoilName); // checks heating coil object type EXPECT_EQ(1, thisSys->m_HeatingSizingRatio); // checks dx heating coil sizing ratio @@ -14553,6 +14435,7 @@ Curve:Biquadratic, )IDF"; ASSERT_TRUE(process_idf(idf_objects)); // read idf objects + state->init_state(*state); HeatBalanceManager::GetZoneData(*state, ErrorsFound); // read zone data EXPECT_FALSE(ErrorsFound); // expect no errors @@ -14577,10 +14460,8 @@ Curve:Biquadratic, // Issue 7777 std::string const error_string = delimited_string({ - " ** Warning ** getUnitarySystemInputData AirLoopHVAC:UnitarySystem=\"UNITARY SYSTEM MODEL\", invalid Availability Schedule Name = " - "FANANDCOILAVAILTEST", - " ** ~~~ ** Set the default as Always On. Simulation continues.", - }); + " ** Warning ** UnitarySys::processInputSpec: AirLoopHVAC:UnitarySystem = UNITARY SYSTEM MODEL", + " ** ~~~ ** Availability Schedule Name = FANANDCOILAVAILTEST, item not found, Set the default as Always On. Simulation continues. will be used."}); EXPECT_TRUE(compare_err_stream(error_string, true)); } @@ -14789,6 +14670,7 @@ Curve:Biquadratic, )IDF"; ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); bool ErrorsFound(false); HeatBalanceManager::GetZoneData(*state, ErrorsFound); @@ -16197,10 +16079,10 @@ Dimensionless; !- Output Unit Type )IDF"; ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + bool ErrorsFound = false; // Read objects - HeatBalanceManager::GetProjectControlData(*state, ErrorsFound); - EXPECT_FALSE(ErrorsFound); HeatBalanceManager::GetZoneData(*state, ErrorsFound); EXPECT_FALSE(ErrorsFound); Material::GetWindowGlassSpectralData(*state, ErrorsFound); @@ -16217,18 +16099,17 @@ Dimensionless; !- Output Unit Type SurfaceGeometry::GetSurfaceData(*state, ErrorsFound); EXPECT_FALSE(ErrorsFound); - ScheduleManager::ProcessScheduleInput(*state); // read schedules - - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; // Enable schedule without calling schedule manager - state->dataScheduleMgr->Schedule(6).CurrentValue = 1.0; // Enable schedule without calling schedule manager - state->dataScheduleMgr->Schedule(7).CurrentValue = 4.0; // Enable schedule without calling schedule manager + Sched::GetSchedule(*state, "HVACTEMPLATE-ALWAYS 1")->currentVal = 1.0; // Enable schedule without calling schedule manager + Sched::GetSchedule(*state, "LIGHTS-1")->currentVal = 1.0; // Enable schedule without calling schedule manager + auto *equipSched = Sched::GetSchedule(*state, "EQUIP-1"); + equipSched->currentVal = 4.0; // Enable schedule without calling schedule manager state->dataEnvrn->OutBaroPress = 101325; ZoneEquipmentManager::GetZoneEquipment(*state); SimAirServingZones::GetAirPathData(*state); - state->dataScheduleMgr->Schedule(7).MinValue = 4.0; // Enable schedule without calling schedule manager - state->dataScheduleMgr->Schedule(7).MaxValue = 4.0; // Enable schedule without calling schedule manager - state->dataScheduleMgr->Schedule(7).MaxMinSet = true; + equipSched->minVal = 4.0; // Enable schedule without calling schedule manager + equipSched->maxVal = 4.0; // Enable schedule without calling schedule manager + equipSched->isMinMaxSet = true; ZoneTempPredictorCorrector::GetZoneAirSetPoints(*state); std::string compName = "SYS 1 FURNACE DX COOL UNITARY SYSTEM"; @@ -16290,7 +16171,7 @@ Dimensionless; !- Output Unit Type state->dataZoneEnergyDemand->CurDeadBandOrSetback(1) = false; state->dataHeatBalFanSys->TempControlType.allocate(1); state->dataHeatBalFanSys->TempControlTypeRpt.allocate(1); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::DualSetPointWithDeadBand; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::DualHeatCool; auto &mixedAirNode = state->dataLoopNodes->Node(state->dataMixedAir->OAMixer(1).MixNode); mixedAirNode.Temp = 23.822; // 24C db mixedAirNode.HumRat = 0.0145946; // 17C wb @@ -16716,6 +16597,7 @@ Curve:Biquadratic, )IDF"; ASSERT_TRUE(process_idf(idf_objects)); // read idf objects + state->init_state(*state); bool ErrorsFound(false); HeatBalanceManager::GetZoneData(*state, ErrorsFound); // read zone data @@ -16997,6 +16879,7 @@ Curve:Biquadratic, )IDF"; ASSERT_TRUE(process_idf(idf_objects)); // read idf objects + state->init_state(*state); std::string compName = "UNITARY SYSTEM MODEL"; bool zoneEquipment = true; @@ -17305,7 +17188,8 @@ TEST_F(ZoneUnitarySysTest, UnitarySystemModel_MultiSpeedDXCoilsNoLoadFlowRateSiz )IDF"; ASSERT_TRUE(process_idf(idf_objects)); // read idf objects - + state->init_state(*state); + std::string compName = "UNITARY SYSTEM MODEL"; bool zoneEquipment = true; bool FirstHVACIteration = true; @@ -17699,7 +17583,7 @@ TEST_F(ZoneUnitarySysTest, UnitarySystemModel_MultiSpeedDXCoilsDirectSolutionTes )IDF"; ASSERT_TRUE(process_idf(idf_objects)); // read idf objects - + state->init_state(*state); bool ErrorsFound = false; std::string compName = "UNITARY SYSTEM MODEL"; @@ -17737,7 +17621,7 @@ TEST_F(ZoneUnitarySysTest, UnitarySystemModel_MultiSpeedDXCoilsDirectSolutionTes state->dataZoneEnergyDemand->CurDeadBandOrSetback(1) = false; state->dataHeatBalFanSys->TempControlType.allocate(1); state->dataHeatBalFanSys->TempControlTypeRpt.allocate(1); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::DualSetPointWithDeadBand; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::DualHeatCool; state->dataLoopNodes->Node(7).FluidType = DataLoopNode::NodeFluidType::Air; state->dataLoopNodes->Node(7).Temp = 24.0; // 24C db state->dataLoopNodes->Node(7).HumRat = 0.01522; // 17C wb @@ -17912,7 +17796,7 @@ TEST_F(ZoneUnitarySysTest, UnitarySystemModel_MultiSpeedDXCoilsDirectSolutionTes TEST_F(EnergyPlusFixture, UnitarySystemModel_reportUnitarySystemAncillaryPowerTest) { state->dataHVACGlobal->TimeStepSys = 0.25; - state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; state->dataLoopNodes->Node.allocate(2); UnitarySys thisSys; thisSys.AirInNode = 1; @@ -18247,6 +18131,7 @@ TEST_F(ZoneUnitarySysTest, UnitarySystemModel_CheckBadInputOutputNodes) )IDF"; ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); bool ErrorsFound = false; std::string compName = "UNITARY SYSTEM MODEL"; bool zoneEquipment = true; @@ -18272,13 +18157,13 @@ AirLoopHVAC:UnitarySystem, Setpoint, !- Control Type East Zone, !- Controlling Zone or Thermostat Location None, !- Dehumidification Control Type - AlwaysOne, !- Availability Schedule Name + Constant-1.0, !- Availability Schedule Name Zone Exhaust Node, !- Air Inlet Node Name Zone 2 Inlet Node, !- Air Outlet Node Name Fan:OnOff, !- Supply Fan Object Type Supply Fan 1, !- Supply Fan Name BlowThrough, !- Fan Placement - AlwaysZero, !- Supply Air Fan Operating Mode Schedule Name + Constant-0.0, !- Supply Air Fan Operating Mode Schedule Name , !- Heating Coil Object Type , !- Heating Coil Name , !- DX Heating Coil Sizing Ratio @@ -18311,7 +18196,7 @@ AirLoopHVAC:UnitarySystem, Fan:OnOff, Supply Fan 1, !- Name - AlwaysOne, !- Availability Schedule Name + Constant-1.0, !- Availability Schedule Name 0.7, !- Fan Total Efficiency 600.0, !- Pressure Rise{ Pa } autosize, !- Maximum Flow Rate{ m3 / s } @@ -18347,20 +18232,6 @@ Coil:Cooling:DX:SingleSpeed, ScheduleTypeLimits, Any Number; !- Name -Schedule:Compact, - AlwaysOne, !- Name - Any Number, !- Schedule Type Limits Name - Through: 12/31, !- Field 1 - For: AllDays, !- Field 2 - Until: 24:00, 1.0; !- Field 3 - -Schedule:Compact, - AlwaysZero, !- Name - Any Number, !- Schedule Type Limits Name - Through: 12/31, !- Field 1 - For: AllDays, !- Field 2 - Until: 24:00, 0.0; !- Field 3 - Schedule:Compact, Always 20C, !- Name Any Number, !- Schedule Type Limits Name @@ -18403,21 +18274,20 @@ Curve:Biquadratic, )IDF"; ASSERT_TRUE(process_idf(idf_objects)); // read idf objects - + state->init_state(*state); // call the UnitarySystem factory std::string compName = "UNITARY SYSTEM MODEL"; bool zoneEquipment = true; UnitarySystems::UnitarySys::factory(*state, HVAC::UnitarySysType::Unitary_AnyCoilType, compName, zoneEquipment, 0); UnitarySystems::UnitarySys *thisSys = &state->dataUnitarySystems->unitarySys[0]; - state->dataGlobal->NumOfTimeStepInHour = 1; - state->dataGlobal->MinutesPerTimeStep = 60; + state->dataGlobal->TimeStepsInHour = 1; + state->dataGlobal->MinutesInTimeStep = 60; state->dataZoneEquip->ZoneEquipInputsFilled = true; // indicate zone data is available thisSys->getUnitarySystemInputData(*state, compName, zoneEquipment, 0, ErrorsFound); // get UnitarySystem input from object above std::string const error_string = - delimited_string({" ** Severe ** AirLoopHVAC:UnitarySystem = UNITARY SYSTEM MODEL\n ** ~~~ ** For FAN:ONOFF = SUPPLY FAN 1\n ** " - "~~~ ** Fan operating mode must be continuous (fan operating mode schedule values > 0).\n ** ~~~ ** Error found in " - "Supply Air Fan Operating Mode Schedule Name ALWAYSZERO\n ** ~~~ ** ...schedule values must be (>0., <=1.)"}); + delimited_string({" ** Severe ** UnitarySys::processInputSpec: AirLoopHVAC:UnitarySystem = UNITARY SYSTEM MODEL", + " ** ~~~ ** Supply Air Fan Operating Mode Schedule Name = CONSTANT-0.0, schedule contains values that are <= 0 and/or > 1"}); EXPECT_TRUE(compare_err_stream(error_string, true)); } @@ -18431,7 +18301,7 @@ AirLoopHVAC:UnitarySystem, Setpoint, !- Control Type East Zone, !- Controlling Zone or Thermostat Location None, !- Dehumidification Control Type - AlwaysOne, !- Availability Schedule Name + Constant-1.0, !- Availability Schedule Name Zone Exhaust Node, !- Air Inlet Node Name Zone 2 Inlet Node, !- Air Outlet Node Name Fan:OnOff, !- Supply Fan Object Type @@ -18480,7 +18350,7 @@ AirLoopHVAC:UnitarySystem, Fan:OnOff, Supply Fan 1, !- Name - AlwaysOne, !- Availability Schedule Name + Constant-1.0, !- Availability Schedule Name 0.7, !- Fan Total Efficiency 600.0, !- Pressure Rise{ Pa } autosize, !- Maximum Flow Rate{ m3 / s } @@ -18491,7 +18361,7 @@ Fan:OnOff, Coil:Heating:Fuel, Fuel Heating Coil, !- Name - AlwaysOne, !- Availability Schedule Name + Constant-1.0, !- Availability Schedule Name NaturalGas, !- Fuel Type 1.0, !- Gas Burner Efficiency autosize, !- Nominal Capacity @@ -18501,13 +18371,6 @@ Coil:Heating:Fuel, ScheduleTypeLimits, Any Number; !- Name -Schedule:Compact, - AlwaysOne, !- Name - Any Number, !- Schedule Type Limits Name - Through: 12/31, !- Field 1 - For: AllDays, !- Field 2 - Until: 24:00, 1.0; !- Field 3 - Schedule:Compact, Always 18C, !- Name Any Number, !- Schedule Type Limits Name @@ -18532,7 +18395,7 @@ Curve:Quadratic, )IDF"; ASSERT_TRUE(process_idf(idf_objects)); // read idf objects - + state->init_state(*state); std::string compName = "UNITARY SYSTEM MODEL"; bool zoneEquipment = true; bool FirstHVACIteration = true; @@ -18585,15 +18448,11 @@ Curve:Quadratic, state->dataLoopNodes->Node(1).HumRat = 0.00922; // 17C wb state->dataLoopNodes->Node(1).Enthalpy = 47597.03; // www.sugartech.com/psychro/index.php - ScheduleManager::ProcessScheduleInput(*state); // read schedules - // Heating coil air inlet node = 3 state->dataLoopNodes->Node(3).MassFlowRateMax = thisSys->m_DesignMassFlowRate; // max at fan outlet so fan won't limit flow // Heating coil air outlet node = 2 state->dataLoopNodes->Node(2).TempSetPoint = 25.0; - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; // Enable schedule without calling schedule manager - state->dataGlobal->BeginEnvrnFlag = true; // act as if simulation is beginning // Heating mode @@ -18636,7 +18495,7 @@ AirLoopHVAC:UnitarySystem, Setpoint, !- Control Type East Zone, !- Controlling Zone or Thermostat Location None, !- Dehumidification Control Type - AlwaysOne, !- Availability Schedule Name + Constant-1.0, !- Availability Schedule Name Zone Exhaust Node, !- Air Inlet Node Name Zone 2 Inlet Node, !- Air Outlet Node Name Fan:OnOff, !- Supply Fan Object Type @@ -18685,7 +18544,7 @@ AirLoopHVAC:UnitarySystem, Fan:OnOff, Supply Fan 1, !- Name - AlwaysOne, !- Availability Schedule Name + Constant-1.0, !- Availability Schedule Name 0.7, !- Fan Total Efficiency 600.0, !- Pressure Rise{ Pa } autosize, !- Maximum Flow Rate{ m3 / s } @@ -18696,7 +18555,7 @@ Fan:OnOff, Coil:Heating:Electric, Electric Heating Coil, !- Name - AlwaysOne, !- Availability Schedule Name + Constant-1.0, !- Availability Schedule Name 1.0, !- Efficiency autosize, !- Nominal Capacity Heating Coil Air Inlet Node, !- Air Inlet Node Name @@ -18705,13 +18564,6 @@ Coil:Heating:Electric, ScheduleTypeLimits, Any Number; !- Name -Schedule:Compact, - AlwaysOne, !- Name - Any Number, !- Schedule Type Limits Name - Through: 12/31, !- Field 1 - For: AllDays, !- Field 2 - Until: 24:00, 1.0; !- Field 3 - Schedule:Compact, Always 18C, !- Name Any Number, !- Schedule Type Limits Name @@ -18736,7 +18588,7 @@ Curve:Quadratic, )IDF"; ASSERT_TRUE(process_idf(idf_objects)); // read idf objects - + state->init_state(*state); std::string compName = "UNITARY SYSTEM MODEL"; bool zoneEquipment = true; bool FirstHVACIteration = true; @@ -18789,15 +18641,11 @@ Curve:Quadratic, state->dataLoopNodes->Node(1).HumRat = 0.00922; // 17C wb state->dataLoopNodes->Node(1).Enthalpy = 47597.03; // www.sugartech.com/psychro/index.php - ScheduleManager::ProcessScheduleInput(*state); // read schedules - // Heating coil air inlet node = 3 state->dataLoopNodes->Node(3).MassFlowRateMax = thisSys->m_DesignMassFlowRate; // max at fan outlet so fan won't limit flow // Heating coil air outlet node = 2 state->dataLoopNodes->Node(2).TempSetPoint = 25.0; - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; // Enable schedule without calling schedule manager - state->dataGlobal->BeginEnvrnFlag = true; // act as if simulation is beginning // Heating mode @@ -18830,7 +18678,7 @@ AirLoopHVAC:UnitarySystem, Setpoint, !- Control Type East Zone, !- Controlling Zone or Thermostat Location None, !- Dehumidification Control Type - AlwaysOne, !- Availability Schedule Name + Constant-1.0, !- Availability Schedule Name Zone Exhaust Node, !- Air Inlet Node Name Zone 2 Inlet Node, !- Air Outlet Node Name Fan:OnOff, !- Supply Fan Object Type @@ -18879,7 +18727,7 @@ AirLoopHVAC:UnitarySystem, Fan:OnOff, Supply Fan 1, !- Name - AlwaysOne, !- Availability Schedule Name + Constant-1.0, !- Availability Schedule Name 0.7, !- Fan Total Efficiency 600.0, !- Pressure Rise{ Pa } autosize, !- Maximum Flow Rate{ m3 / s } @@ -18890,7 +18738,7 @@ Fan:OnOff, Coil:Heating:Desuperheater, Desuperheater Heating Coil, !- Name - AlwaysOne, !- Availability Schedule Name + Constant-1.0, !- Availability Schedule Name 0.3, !- Heat Reclaim Recovery Efficiency Heating Coil Air Inlet Node, !- Coil Air Inlet Node Name Zone 2 Inlet Node, !- Coil Air Outlet Node Name @@ -18902,13 +18750,6 @@ Coil:Heating:Desuperheater, ScheduleTypeLimits, Any Number; !- Name -Schedule:Compact, - AlwaysOne, !- Name - Any Number, !- Schedule Type Limits Name - Through: 12/31, !- Field 1 - For: AllDays, !- Field 2 - Until: 24:00, 1.0; !- Field 3 - Schedule:Compact, Always 18C, !- Name Any Number, !- Schedule Type Limits Name @@ -19037,7 +18878,7 @@ Schedule:Compact, )IDF"; ASSERT_TRUE(process_idf(idf_objects)); // read idf objects - + state->init_state(*state); state->dataZoneEquip->ZoneEquipInputsFilled = true; InternalHeatGains::ManageInternalHeatGains(*state, true); std::string compName = "UNITARY SYSTEM MODEL"; @@ -19097,16 +18938,12 @@ Schedule:Compact, state->dataLoopNodes->Node(thisSys->AirInNode).HumRat = 0.00922; // 17C wb state->dataLoopNodes->Node(thisSys->AirInNode).Enthalpy = 47597.03; // www.sugartech.com/psychro/index.php - ScheduleManager::ProcessScheduleInput(*state); // read schedules - // Heating coil air inlet node = 4 state->dataLoopNodes->Node(thisSys->HeatCoilInletNodeNum).MassFlowRateMax = thisSys->m_DesignMassFlowRate; // max at fan outlet so fan won't limit flow // Heating coil air outlet node = 5 state->dataLoopNodes->Node(thisSys->HeatCoilOutletNodeNum).TempSetPoint = 25.0; - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; // Enable schedule without calling schedule manager - state->dataGlobal->BeginEnvrnFlag = true; // act as if simulation is beginning // Heating mode @@ -19166,7 +19003,8 @@ TEST_F(EnergyPlusFixture, WaterCoil_getCoilWaterSystemInputDataTest) )IDF"; EXPECT_TRUE(process_idf(idf_objects, false)); - + state->init_state(*state); + bool zoneEquipment = false; state->dataZoneEquip->ZoneEquipInputsFilled = true; @@ -19253,6 +19091,7 @@ TEST_F(EnergyPlusFixture, DetailedWaterCoil_getCoilWaterSystemInputDataTest) )IDF"; EXPECT_TRUE(process_idf(idf_objects, false)); + state->init_state(*state); bool zoneEquipment = false; state->dataZoneEquip->ZoneEquipInputsFilled = true; @@ -19355,6 +19194,7 @@ TEST_F(EnergyPlusFixture, HXAssistedWaterCoil_getCoilWaterSystemInputDataTest) )IDF"; EXPECT_TRUE(process_idf(idf_objects, false)); + state->init_state(*state); bool zoneEquipment = false; state->dataZoneEquip->ZoneEquipInputsFilled = true; @@ -19433,6 +19273,7 @@ TEST_F(EnergyPlusFixture, CoilSystemCoolingWater_ControlStatusTest) )IDF"; EXPECT_TRUE(process_idf(idf_objects, false)); + state->init_state(*state); bool zoneEquipment = false; state->dataZoneEquip->ZoneEquipInputsFilled = true; @@ -19466,7 +19307,6 @@ TEST_F(EnergyPlusFixture, CoilSystemCoolingWater_ControlStatusTest) Real64 ColdWaterMassFlowRate(1.0); state->dataEnvrn->OutBaroPress = 101325.0; state->dataEnvrn->StdRhoAir = 1.0; - Psychrometrics::InitializePsychRoutines(*state); thisSys.m_MultiOrVarSpeedHeatCoil = false; thisSys.m_MultiOrVarSpeedCoolCoil = false; @@ -19474,7 +19314,7 @@ TEST_F(EnergyPlusFixture, CoilSystemCoolingWater_ControlStatusTest) thisSys.m_HeatMassFlowRate.resize(1); thisSys.m_CoolMassFlowRate.resize(1); thisSys.m_LastMode = UnitarySystems::CoolingMode; - thisSys.m_FanAvailSchedPtr = ScheduleManager::ScheduleAlwaysOn; + thisSys.m_fanAvailSched = Sched::GetScheduleAlwaysOn(*state); thisSys.m_FanOpMode = HVAC::FanOp::Cycling; // cooling load @@ -19498,7 +19338,7 @@ TEST_F(EnergyPlusFixture, CoilSystemCoolingWater_ControlStatusTest) state->dataWaterCoils->CheckEquipName.allocate(1); state->dataWaterCoils->GetWaterCoilsInputFlag = false; - state->dataWaterCoils->WaterCoil(1).SchedPtr = ScheduleManager::ScheduleAlwaysOn; + state->dataWaterCoils->WaterCoil(1).availSched = Sched::GetScheduleAlwaysOn(*state); state->dataWaterCoils->WaterCoil(1).WaterCoilType = DataPlant::PlantEquipmentType::CoilWaterCooling; state->dataWaterCoils->WaterCoil(1).WaterCoilModel = WaterCoils::CoilModel::CoolingSimple; state->dataWaterCoils->WaterCoil(1).DesAirVolFlowRate = 1.0; @@ -19680,6 +19520,7 @@ TEST_F(EnergyPlusFixture, CoilSystemCoolingWater_CalcTest) )IDF"; EXPECT_TRUE(process_idf(idf_objects, false)); + state->init_state(*state); bool zoneEquipment = false; state->dataZoneEquip->ZoneEquipInputsFilled = true; @@ -19715,7 +19556,6 @@ TEST_F(EnergyPlusFixture, CoilSystemCoolingWater_CalcTest) Real64 ColdWaterMassFlowRate(1.0); state->dataEnvrn->OutBaroPress = 101325.0; state->dataEnvrn->StdRhoAir = 1.0; - Psychrometrics::InitializePsychRoutines(*state); thisSys.m_MultiOrVarSpeedHeatCoil = false; thisSys.m_MultiOrVarSpeedCoolCoil = false; @@ -19726,7 +19566,7 @@ TEST_F(EnergyPlusFixture, CoilSystemCoolingWater_CalcTest) thisSys.m_LastMode = UnitarySystems::CoolingMode; thisSys.MaxNoCoolHeatAirMassFlow = 0.2; thisSys.m_NoLoadAirFlowRateRatio = 0.2; - thisSys.m_FanAvailSchedPtr = ScheduleManager::ScheduleAlwaysOn; + thisSys.m_fanAvailSched = Sched::GetScheduleAlwaysOn(*state); thisSys.m_FanOpMode = HVAC::FanOp::Cycling; // cooling load @@ -19750,7 +19590,7 @@ TEST_F(EnergyPlusFixture, CoilSystemCoolingWater_CalcTest) state->dataWaterCoils->CheckEquipName.allocate(1); state->dataWaterCoils->GetWaterCoilsInputFlag = false; - state->dataWaterCoils->WaterCoil(1).SchedPtr = ScheduleManager::ScheduleAlwaysOn; + state->dataWaterCoils->WaterCoil(1).availSched = Sched::GetScheduleAlwaysOn(*state); state->dataWaterCoils->WaterCoil(1).WaterCoilType = DataPlant::PlantEquipmentType::CoilWaterCooling; state->dataWaterCoils->WaterCoil(1).WaterCoilModel = WaterCoils::CoilModel::CoolingSimple; state->dataWaterCoils->WaterCoil(1).DesAirVolFlowRate = 1.0; @@ -19947,6 +19787,7 @@ TEST_F(EnergyPlusFixture, CoilSystemCoolingWater_HeatRecoveryLoop) )IDF"; EXPECT_TRUE(process_idf(idf_objects, false)); + state->init_state(*state); bool zoneEquipment = false; state->dataZoneEquip->ZoneEquipInputsFilled = true; @@ -19982,7 +19823,6 @@ TEST_F(EnergyPlusFixture, CoilSystemCoolingWater_HeatRecoveryLoop) Real64 ColdWaterMassFlowRate(1.0); state->dataEnvrn->OutBaroPress = 101325.0; state->dataEnvrn->StdRhoAir = 1.0; - Psychrometrics::InitializePsychRoutines(*state); thisSys.m_MultiOrVarSpeedHeatCoil = false; thisSys.m_MultiOrVarSpeedCoolCoil = false; @@ -19993,7 +19833,7 @@ TEST_F(EnergyPlusFixture, CoilSystemCoolingWater_HeatRecoveryLoop) thisSys.m_LastMode = UnitarySystems::CoolingMode; thisSys.MaxNoCoolHeatAirMassFlow = 0.2; thisSys.m_NoLoadAirFlowRateRatio = 0.2; - thisSys.m_FanAvailSchedPtr = ScheduleManager::ScheduleAlwaysOn; + thisSys.m_fanAvailSched = Sched::GetScheduleAlwaysOn(*state); thisSys.m_FanOpMode = HVAC::FanOp::Cycling; // cooling load @@ -20018,7 +19858,7 @@ TEST_F(EnergyPlusFixture, CoilSystemCoolingWater_HeatRecoveryLoop) state->dataWaterCoils->CheckEquipName.allocate(2); state->dataWaterCoils->GetWaterCoilsInputFlag = false; for (int i = 1; i <= 2; ++i) { - state->dataWaterCoils->WaterCoil(i).SchedPtr = ScheduleManager::ScheduleAlwaysOn; + state->dataWaterCoils->WaterCoil(i).availSched = Sched::GetScheduleAlwaysOn(*state); state->dataWaterCoils->WaterCoil(i).WaterCoilType = DataPlant::PlantEquipmentType::CoilWaterCooling; state->dataWaterCoils->WaterCoil(i).WaterCoilModel = WaterCoils::CoilModel::CoolingSimple; state->dataWaterCoils->WaterCoil(i).DesAirVolFlowRate = 1.0; @@ -20187,7 +20027,7 @@ TEST_F(EnergyPlusFixture, CoilSystemCoolingWater_HeatRecoveryLoop) TEST_F(AirloopUnitarySysTest, WSHPVariableSpeedCoilSizing) { - FluidProperties::GetFluidPropertiesData(*state); + state->init_state(*state); // test that correct CapFT inputs are used for the WSHP cooling coil state->dataEnvrn->OutBaroPress = 101325.0; state->dataEnvrn->StdRhoAir = Psychrometrics::PsyRhoAirFnPbTdbW(*state, state->dataEnvrn->OutBaroPress, 20.0, 0.0); @@ -20368,7 +20208,7 @@ TEST_F(ZoneUnitarySysTest, UnitarySystemModel_LowerSpeedFlowSizingTest) Load, !- Control Type East Zone, !- Controlling Zone or Thermostat Location None, !- Dehumidification Control Type - AlwaysOne, !- Availability Schedule Name + Constant-1.0, !- Availability Schedule Name Zone Exhaust Node, !- Air Inlet Node Name DX ClgCoil Air Outlet Node, !- Air Outlet Node Name Fan:OnOff, !- Supply Fan Object Type @@ -20417,7 +20257,7 @@ TEST_F(ZoneUnitarySysTest, UnitarySystemModel_LowerSpeedFlowSizingTest) Fan:OnOff, Zone Supply Air Fan, !- Name - AlwaysOne, !- Availability Schedule Name + Constant-1.0, !- Availability Schedule Name 0.5, !- Fan Total Efficiency 500.0, !- Pressure Rise{ Pa } autosize, !- Maximum Flow Rate{ m3 / s } @@ -20429,13 +20269,6 @@ TEST_F(ZoneUnitarySysTest, UnitarySystemModel_LowerSpeedFlowSizingTest) ScheduleTypeLimits, Any Number; !- Name - Schedule:Compact, - AlwaysOne, !- Name - Any Number, !- Schedule Type Limits Name - Through: 12/31, !- Field 1 - For: AllDays, !- Field 2 - Until: 24:00, 1.0; !- Field 3 - Coil:Cooling:DX, DX ClgCoil, !- Name DX ClgCoil Air Inlet Node, !- Evaporator Inlet Node Name @@ -20578,6 +20411,7 @@ Curve:Biquadratic, EIRFT, 1, 0, 0, 0, 0, 0, 0, 100, 0, 100, , , Temperature, Tem )IDF"; ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); std::string UnitarySysName = "UNITARY SYSTEM MODEL"; bool zoneEquipment = true; @@ -20651,7 +20485,7 @@ AirLoopHVAC:UnitarySystem, Load, !- Control Type East Zone, !- Controlling Zone or Thermostat Location None, !- Dehumidification Control Type - AlwaysOne, !- Availability Schedule Name + Constant-1.0, !- Availability Schedule Name Zone Exhaust Node, !- Air Inlet Node Name Zone 2 Inlet Node, !- Air Outlet Node Name Fan:OnOff, !- Supply Fan Object Type @@ -20711,7 +20545,7 @@ UnitarySystemPerformance:Multispeed, Fan:OnOff, Supply Fan 1, !- Name - AlwaysOne, !- Availability Schedule Name + Constant-1.0, !- Availability Schedule Name 0.7, !- Fan Total Efficiency 600.0, !- Pressure Rise{ Pa } autosize, !- Maximum Flow Rate{ m3 / s } @@ -20784,13 +20618,6 @@ Coil:Cooling:DX:MultiSpeed, ScheduleTypeLimits, Any Number; !- Name -Schedule:Compact, - AlwaysOne, !- Name - Any Number, !- Schedule Type Limits Name - Through: 12/31, !- Field 1 - For: AllDays, !- Field 2 - Until: 24:00, 1.0; !- Field 3 - Schedule:Compact, Always 20C, !- Name Any Number, !- Schedule Type Limits Name @@ -20832,7 +20659,7 @@ Curve:Biquadratic, Coil:Heating:Gas:MultiStage, Gas Heating Coil, !- Name - AlwaysOne, !- Availability Schedule Name + Constant-1.0, !- Availability Schedule Name Heating Coil Air Inlet Node, !- Air Inlet Node Name Zone 2 Inlet Node, !- Air Outlet Node Name , !- Temperature Setpoint Node Name @@ -20849,6 +20676,7 @@ Coil:Heating:Gas:MultiStage, )IDF"; ASSERT_TRUE(process_idf(idf_objects)); // read idf objects + state->init_state(*state); // call the UnitarySystem factory std::string compName = "UNITARY SYSTEM MODEL"; @@ -20892,7 +20720,7 @@ Coil:Heating:Gas:MultiStage, state->dataZoneEnergyDemand->ZoneSysEnergyDemand(ControlZoneNum).RemainingOutputReqToCoolSP = 0; state->dataZoneEnergyDemand->ZoneSysEnergyDemand(ControlZoneNum).RemainingOutputReqToHeatSP = 0; state->dataZoneEnergyDemand->ZoneSysMoistureDemand(ControlZoneNum).RemainingOutputReqToDehumidSP = 0; - state->dataHeatBalFanSys->TempControlType(ControlZoneNum) = HVAC::ThermostatType::DualSetPointWithDeadBand; + state->dataHeatBalFanSys->TempControlType(ControlZoneNum) = HVAC::SetptType::DualHeatCool; state->dataZoneCtrls->StageZoneLogic.allocate(1); state->dataZoneCtrls->StageZoneLogic(1) = true; @@ -20922,7 +20750,6 @@ Coil:Heating:Gas:MultiStage, state->dataLoopNodes->Node(4).MassFlowRateMax = thisSys->m_DesignMassFlowRate; // max at fan outlet so fan won't limit flow // Cooling coil air outlet node = 2 state->dataLoopNodes->Node(2).TempSetPoint = 17.0; - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; // Enable schedule without calling schedule manager state->dataGlobal->BeginEnvrnFlag = true; // act as if simulation is beginning thisSys->simulate(*state, thisSys->Name, @@ -20947,7 +20774,6 @@ Coil:Heating:Gas:MultiStage, state->dataZoneEnergyDemand->ZoneSysEnergyDemand(1).StageNum = 1; state->dataLoopNodes->Node(4).MassFlowRateMax = thisSys->m_DesignMassFlowRate; // max at fan outlet so fan won't limit flow // Cooling coil air outlet node = 2 - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; // Enable schedule without calling schedule manager state->dataGlobal->BeginEnvrnFlag = true; // act as if simulation is beginning thisSys->simulate(*state, @@ -20997,7 +20823,7 @@ TEST_F(EnergyPlusFixture, SetEconomizerStagingOperationSpeedTest) thisFan->totalEff = 0.7; thisFan->motorEff = 0.9; thisFan->motorInAirFrac = 1.0; - thisFan->availSchedNum = 0; + thisFan->availSched = Sched::GetScheduleAlwaysOff(*state); thisFan->minAirMassFlowRate = 0.0; thisFan->coeffs[0] = 0.0015302446; thisFan->coeffs[1] = 0.0052080574; @@ -21309,6 +21135,7 @@ Schedule:Constant, )IDF"; ASSERT_TRUE(process_idf(idf_objects)); // read idf objects + state->init_state(*state); HeatBalanceManager::GetZoneData(*state, ErrorsFound); // read zone data EXPECT_FALSE(ErrorsFound); // expect no errors @@ -21324,9 +21151,8 @@ Schedule:Constant, state->dataZoneCtrls->HumidityControlZone(1).ControlName = "East Zone"; state->dataZoneCtrls->HumidityControlZone(1).ZoneName = "East Zone"; state->dataZoneCtrls->HumidityControlZone(1).ActualZoneNum = 1; - state->dataZoneCtrls->HumidityControlZone(1).HumidifyingSchedIndex = ScheduleManager::GetScheduleIndex(*state, "Schedule_Constant_Humdifier"); - state->dataZoneCtrls->HumidityControlZone(1).DehumidifyingSchedIndex = - ScheduleManager::GetScheduleIndex(*state, "Schedule_Constant_Dehumidifier"); + state->dataZoneCtrls->HumidityControlZone(1).humidifyingSched = Sched::GetSchedule(*state, "SCHEDULE_CONSTANT_HUMDIFIER"); + state->dataZoneCtrls->HumidityControlZone(1).dehumidifyingSched = Sched::GetSchedule(*state, "SCHEDULE_CONSTANT_DEHUMIDIFIER"); std::string compName = "UNITARY SYSTEM MODEL"; bool zoneEquipment = true; @@ -21375,11 +21201,11 @@ Schedule:Constant, // set thermostat control type state->dataHeatBalFanSys->TempControlType.allocate(1); state->dataHeatBalFanSys->TempControlTypeRpt.allocate(1); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::DualSetPointWithDeadBand; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::DualHeatCool; state->dataZoneEnergyDemand->CurDeadBandOrSetback.allocate(1); state->dataZoneEnergyDemand->CurDeadBandOrSetback(1) = true; state->dataGlobal->BeginEnvrnFlag = true; - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; + Sched::GetSchedule(*state, "FANANDCOILAVAILSCHED")->currentVal = 1.0; state->dataEnvrn->StdRhoAir = Psychrometrics::PsyRhoAirFnPbTdbW(*state, 101325.0, 20.0, 0.0); // initialize RhoAir state->dataLoopNodes->Node(InletNode).MassFlowRateMaxAvail = thisSys->m_MaxCoolAirVolFlow * state->dataEnvrn->StdRhoAir; @@ -23759,6 +23585,7 @@ TEST_F(EnergyPlusFixture, UnitarySystemModel_MultiSpeedFanWSHP_Test) }); ASSERT_TRUE(process_idf(idf_objects)); // read idf objects + state->init_state(*state); bool FirstHVACIteration(false); diff --git a/tst/EnergyPlus/unit/VAVDefMinMaxFlow.unit.cc b/tst/EnergyPlus/unit/VAVDefMinMaxFlow.unit.cc index e4307f6da2d..20f9109c272 100644 --- a/tst/EnergyPlus/unit/VAVDefMinMaxFlow.unit.cc +++ b/tst/EnergyPlus/unit/VAVDefMinMaxFlow.unit.cc @@ -76,7 +76,6 @@ using namespace EnergyPlus::DataSizing; using namespace EnergyPlus::DataZoneEquipment; using namespace EnergyPlus::HeatBalanceManager; using namespace EnergyPlus::Psychrometrics; -using namespace EnergyPlus::ScheduleManager; using namespace EnergyPlus::SimAirServingZones; using namespace EnergyPlus::SingleDuct; using namespace EnergyPlus::SizingManager; @@ -122,8 +121,6 @@ TEST_F(EnergyPlusFixture, VAVDefMinMaxFlowTestSizing1) bool ErrorsFound(false); - InitializePsychRoutines(*state); - std::string const idf_objects = delimited_string({ " Zone,", " SPACE3-1, !- Name", @@ -230,7 +227,8 @@ TEST_F(EnergyPlusFixture, VAVDefMinMaxFlowTestSizing1) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + state->dataSize->FinalZoneSizing.allocate(1); state->dataSize->FinalZoneSizing(1).allocateMemberArrays(96); state->dataSize->NumAirTerminalSizingSpec = 1; @@ -244,8 +242,6 @@ TEST_F(EnergyPlusFixture, VAVDefMinMaxFlowTestSizing1) GetZoneAirDistribution(*state); // get zone air distribution objects GetZoneSizingInput(*state); GetZoneEquipmentData(*state); - ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; GetZoneAirLoopEquipment(*state); GetSysInput(*state); state->dataSize->ZoneSizingRunDone = true; @@ -316,8 +312,6 @@ TEST_F(EnergyPlusFixture, VAVDefMinMaxFlowTestSizing2) bool ErrorsFound(false); - InitializePsychRoutines(*state); - std::string const idf_objects = delimited_string({ " Zone,", " SPACE3-1, !- Name", @@ -424,7 +418,8 @@ TEST_F(EnergyPlusFixture, VAVDefMinMaxFlowTestSizing2) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + state->dataSize->FinalZoneSizing.allocate(1); state->dataSize->FinalZoneSizing(1).allocateMemberArrays(96); state->dataSize->TermUnitFinalZoneSizing.allocate(1); @@ -438,8 +433,6 @@ TEST_F(EnergyPlusFixture, VAVDefMinMaxFlowTestSizing2) GetZoneAirDistribution(*state); // get zone air distribution objects GetZoneSizingInput(*state); GetZoneEquipmentData(*state); - ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; GetZoneAirLoopEquipment(*state); GetSysInput(*state); state->dataSize->ZoneSizingRunDone = true; @@ -510,8 +503,6 @@ TEST_F(EnergyPlusFixture, VAVDefMinMaxFlowTestSizing3) bool ErrorsFound(false); - InitializePsychRoutines(*state); - std::string const idf_objects = delimited_string({ " Zone,", " SPACE3-1, !- Name", @@ -618,7 +609,8 @@ TEST_F(EnergyPlusFixture, VAVDefMinMaxFlowTestSizing3) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + state->dataSize->FinalZoneSizing.allocate(1); state->dataSize->FinalZoneSizing(1).allocateMemberArrays(96); state->dataSize->TermUnitFinalZoneSizing.allocate(1); @@ -631,8 +623,6 @@ TEST_F(EnergyPlusFixture, VAVDefMinMaxFlowTestSizing3) GetZoneAirDistribution(*state); // get zone air distribution objects GetZoneSizingInput(*state); GetZoneEquipmentData(*state); - ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; GetZoneAirLoopEquipment(*state); GetSysInput(*state); state->dataSize->ZoneSizingRunDone = true; @@ -705,8 +695,6 @@ TEST_F(EnergyPlusFixture, VAVDefMinMaxFlowTestSizing4) bool ErrorsFound(false); - InitializePsychRoutines(*state); - std::string const idf_objects = delimited_string({ " Zone,", " SPACE3-1, !- Name", @@ -813,7 +801,8 @@ TEST_F(EnergyPlusFixture, VAVDefMinMaxFlowTestSizing4) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + state->dataSize->FinalZoneSizing.allocate(1); state->dataSize->FinalZoneSizing(1).allocateMemberArrays(96); state->dataSize->TermUnitFinalZoneSizing.allocate(1); @@ -826,8 +815,6 @@ TEST_F(EnergyPlusFixture, VAVDefMinMaxFlowTestSizing4) // GetZoneAirDistribution(*state); // get zone air distribution objects // GetZoneSizingInput(*state); GetZoneEquipmentData(*state); - ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; GetZoneAirLoopEquipment(*state); GetSysInput(*state); state->dataSize->ZoneSizingRunDone = false; @@ -856,8 +843,6 @@ TEST_F(EnergyPlusFixture, VAVDefMinMaxFlowTestSizing5) bool ErrorsFound(false); - InitializePsychRoutines(*state); - std::string const idf_objects = delimited_string({ " Zone,", " SPACE3-1, !- Name", @@ -964,7 +949,7 @@ TEST_F(EnergyPlusFixture, VAVDefMinMaxFlowTestSizing5) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); state->dataSize->FinalZoneSizing.allocate(1); state->dataSize->FinalZoneSizing(1).allocateMemberArrays(96); state->dataSize->NumAirTerminalSizingSpec = 1; @@ -978,8 +963,6 @@ TEST_F(EnergyPlusFixture, VAVDefMinMaxFlowTestSizing5) GetZoneAirDistribution(*state); // get zone air distribution objects GetZoneSizingInput(*state); GetZoneEquipmentData(*state); - ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; GetZoneAirLoopEquipment(*state); GetSysInput(*state); state->dataSize->ZoneSizingRunDone = true; diff --git a/tst/EnergyPlus/unit/VentilatedSlab.unit.cc b/tst/EnergyPlus/unit/VentilatedSlab.unit.cc index 3e0e6779b31..68e28449824 100644 --- a/tst/EnergyPlus/unit/VentilatedSlab.unit.cc +++ b/tst/EnergyPlus/unit/VentilatedSlab.unit.cc @@ -72,7 +72,6 @@ using namespace EnergyPlus::DataLoopNode; using namespace EnergyPlus::DataSurfaces; using namespace EnergyPlus::DataSurfaceLists; using namespace EnergyPlus::HeatBalanceManager; -using namespace EnergyPlus::ScheduleManager; using namespace EnergyPlus::SurfaceGeometry; TEST_F(EnergyPlusFixture, VentilatedSlab_CalcVentilatedSlabCoilOutputTest) @@ -2345,12 +2344,12 @@ TEST_F(EnergyPlusFixture, VentilatedSlab_InitVentilatedSlabTest) " Hot Water Loop Setpoint Node List; !- Setpoint Node or NodeList Name", }); ASSERT_TRUE(process_idf(idf_objects)); + state->dataGlobal->TimeStepsInHour = 1; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 60; // must initialize this to get schedules initialized + state->init_state(*state); state->dataSize->CurZoneEqNum = 1; state->dataSize->ZoneEqSizing.allocate(1); - state->dataGlobal->NumOfTimeStepInHour = 1; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 60; // must initialize this to get schedules initialized - ProcessScheduleInput(*state); // read schedule data ErrorsFound = false; HeatBalanceManager::GetProjectControlData(*state, ErrorsFound); // read project control data diff --git a/tst/EnergyPlus/unit/WaterCoils.unit.cc b/tst/EnergyPlus/unit/WaterCoils.unit.cc index e11cbf8fe26..843cd4406d0 100644 --- a/tst/EnergyPlus/unit/WaterCoils.unit.cc +++ b/tst/EnergyPlus/unit/WaterCoils.unit.cc @@ -107,7 +107,6 @@ using namespace EnergyPlus::GlobalNames; using namespace EnergyPlus::HeatBalanceManager; using namespace EnergyPlus::MixedAir; using namespace EnergyPlus::Psychrometrics; -using namespace EnergyPlus::ScheduleManager; using namespace EnergyPlus::SizingManager; using namespace EnergyPlus::WaterCoils; using namespace EnergyPlus::Psychrometrics; @@ -155,7 +154,6 @@ class WaterCoilsTest : public EnergyPlusFixture state->dataSize->FinalZoneSizing.allocate(1); state->dataAirSystemsData->PrimaryAirSystems.allocate(1); state->dataAirLoop->AirLoopControlInfo.allocate(1); - InitializePsychRoutines(*state); } virtual void TearDown() @@ -442,7 +440,7 @@ TEST_F(WaterCoilsTest, CoilHeatingWaterUASizing) state->dataWaterCoils->WaterCoil(CoilNum).WaterPlantLoc.loopNum = 1; state->dataWaterCoils->WaterCoil(CoilNum).WaterCoilType = DataPlant::PlantEquipmentType::CoilWaterSimpleHeating; state->dataWaterCoils->WaterCoil(CoilNum).WaterCoilModel = WaterCoils::CoilModel::HeatingSimple; - state->dataWaterCoils->WaterCoil(CoilNum).SchedPtr = ScheduleManager::ScheduleAlwaysOn; + state->dataWaterCoils->WaterCoil(CoilNum).availSched = Sched::GetScheduleAlwaysOn(*state); state->dataWaterCoils->WaterCoil(CoilNum).RequestingAutoSize = true; state->dataWaterCoils->WaterCoil(CoilNum).DesAirVolFlowRate = AutoSize; @@ -598,7 +596,7 @@ TEST_F(WaterCoilsTest, CoilHeatingWaterLowAirFlowUASizing) state->dataWaterCoils->WaterCoil(CoilNum).WaterPlantLoc.loopNum = 1; state->dataWaterCoils->WaterCoil(CoilNum).WaterCoilType = DataPlant::PlantEquipmentType::CoilWaterSimpleHeating; state->dataWaterCoils->WaterCoil(CoilNum).WaterCoilModel = WaterCoils::CoilModel::HeatingSimple; - state->dataWaterCoils->WaterCoil(CoilNum).SchedPtr = ScheduleManager::ScheduleAlwaysOn; + state->dataWaterCoils->WaterCoil(CoilNum).availSched = Sched::GetScheduleAlwaysOn(*state); state->dataWaterCoils->WaterCoil(CoilNum).RequestingAutoSize = true; state->dataWaterCoils->WaterCoil(CoilNum).DesAirVolFlowRate = AutoSize; @@ -757,7 +755,7 @@ TEST_F(WaterCoilsTest, CoilHeatingWaterUASizingLowHwaterInletTemp) state->dataWaterCoils->WaterCoil(CoilNum).WaterPlantLoc.loopNum = 1; state->dataWaterCoils->WaterCoil(CoilNum).WaterCoilType = DataPlant::PlantEquipmentType::CoilWaterSimpleHeating; state->dataWaterCoils->WaterCoil(CoilNum).WaterCoilModel = WaterCoils::CoilModel::HeatingSimple; - state->dataWaterCoils->WaterCoil(CoilNum).SchedPtr = ScheduleManager::ScheduleAlwaysOn; + state->dataWaterCoils->WaterCoil(CoilNum).availSched = Sched::GetScheduleAlwaysOn(*state); state->dataWaterCoils->WaterCoil(CoilNum).RequestingAutoSize = true; state->dataWaterCoils->WaterCoil(CoilNum).DesAirVolFlowRate = AutoSize; @@ -831,8 +829,7 @@ TEST_F(WaterCoilsTest, CoilHeatingWaterUASizingLowHwaterInletTemp) TEST_F(WaterCoilsTest, CoilCoolingWaterSimpleSizing) { - InitializePsychRoutines(*state); - FluidProperties::GetFluidPropertiesData(*state); + state->init_state(*state); state->dataEnvrn->OutBaroPress = 101325.0; state->dataEnvrn->StdRhoAir = PsyRhoAirFnPbTdbW(*state, state->dataEnvrn->OutBaroPress, 20.0, 0.0); ShowMessage(*state, "Begin Test: state->dataWaterCoils->WaterCoilsTest, CoilCoolingWaterSimpleSizing"); @@ -934,8 +931,7 @@ TEST_F(WaterCoilsTest, CoilCoolingWaterSimpleSizing) TEST_F(WaterCoilsTest, CoilCoolingWaterDetailedSizing) { - InitializePsychRoutines(*state); - FluidProperties::GetFluidPropertiesData(*state); + state->init_state(*state); state->dataEnvrn->OutBaroPress = 101325.0; state->dataEnvrn->StdRhoAir = PsyRhoAirFnPbTdbW(*state, state->dataEnvrn->OutBaroPress, 20.0, 0.0); ShowMessage(*state, "Begin Test: state->dataWaterCoils->WaterCoilsTest, CoilCoolingWaterDetailedSizing"); @@ -1049,8 +1045,7 @@ TEST_F(WaterCoilsTest, CoilCoolingWaterDetailedSizing) TEST_F(WaterCoilsTest, CoilCoolingWaterDetailed_WarningMath) { - InitializePsychRoutines(*state); - FluidProperties::GetFluidPropertiesData(*state); + state->init_state(*state); state->dataEnvrn->OutBaroPress = 101325.0; state->dataEnvrn->StdRhoAir = PsyRhoAirFnPbTdbW(*state, state->dataEnvrn->OutBaroPress, 20.0, 0.0); @@ -1087,6 +1082,7 @@ TEST_F(WaterCoilsTest, CoilCoolingWaterDetailed_WarningMath) // set up water coil int CoilNum = 1; state->dataWaterCoils->WaterCoil(CoilNum).Name = "Test Detailed Water Cooling Coil"; + state->dataWaterCoils->WaterCoil(CoilNum).availSched = Sched::GetScheduleAlwaysOff(*state); state->dataWaterCoils->WaterCoil(CoilNum).WaterCoilType = DataPlant::PlantEquipmentType::CoilWaterDetailedFlatCooling; state->dataWaterCoils->WaterCoil(CoilNum).WaterCoilModel = WaterCoils::CoilModel::CoolingDetailed; @@ -1189,6 +1185,7 @@ TEST_F(WaterCoilsTest, CoilCoolingWaterDetailed_WarningMath) EXPECT_EQ(0.81060636699999999, state->dataWaterCoils->WaterCoil(CoilNum).MinAirFlowArea); std::string expected_error = delimited_string({ + " ** Warning ** Version: missing in IDF, processing for EnergyPlus version=\"24.2\"", " ** Warning ** Coil:Cooling:Water:DetailedGeometry in Coil =Test Detailed Water Cooling Coil", " ** ~~~ ** Air Flow Rate Velocity has greatly exceeded upper design guidelines of ~2.5 m/s", format(" ** ~~~ ** Air Mass Flow Rate[kg/s]={:.6T}", state->dataWaterCoils->WaterCoil(CoilNum).InletAirMassFlowRate), @@ -1233,8 +1230,7 @@ TEST_F(WaterCoilsTest, CoilCoolingWaterDetailed_WarningMath) TEST_F(WaterCoilsTest, CoilHeatingWaterSimpleSizing) { - InitializePsychRoutines(*state); - FluidProperties::GetFluidPropertiesData(*state); + state->init_state(*state); state->dataEnvrn->OutBaroPress = 101325.0; state->dataEnvrn->StdRhoAir = PsyRhoAirFnPbTdbW(*state, state->dataEnvrn->OutBaroPress, 20.0, 0.0); ShowMessage(*state, "Begin Test: state->dataWaterCoils->WaterCoilsTest, CoilHeatingWaterSimpleSizing"); @@ -1372,7 +1368,7 @@ TEST_F(WaterCoilsTest, HotWaterHeatingCoilAutoSizeTempTest) state->dataWaterCoils->WaterCoil(CoilNum).WaterPlantLoc.loopNum = 1; state->dataWaterCoils->WaterCoil(CoilNum).WaterCoilModel = WaterCoils::CoilModel::HeatingSimple; state->dataWaterCoils->WaterCoil(CoilNum).WaterCoilType = DataPlant::PlantEquipmentType::CoilWaterSimpleHeating; - state->dataWaterCoils->WaterCoil(CoilNum).SchedPtr = ScheduleManager::ScheduleAlwaysOn; + state->dataWaterCoils->WaterCoil(CoilNum).availSched = Sched::GetScheduleAlwaysOn(*state); state->dataWaterCoils->WaterCoil(CoilNum).RequestingAutoSize = true; state->dataWaterCoils->WaterCoil(CoilNum).DesAirVolFlowRate = AutoSize; @@ -1459,11 +1455,9 @@ TEST_F(WaterCoilsTest, FanCoilCoolingWaterFlowTest) state->dataEnvrn->StdRhoAir = 1.20; state->dataWaterCoils->GetWaterCoilsInputFlag = true; state->dataGlobalNames->NumCoils = 0; - state->dataGlobal->NumOfTimeStepInHour = 1; + state->dataGlobal->TimeStepsInHour = 1; state->dataGlobal->TimeStep = 1; - state->dataGlobal->MinutesPerTimeStep = 60; - - InitializePsychRoutines(*state); + state->dataGlobal->MinutesInTimeStep = 60; std::string const idf_objects = delimited_string({ " Zone,", @@ -1588,13 +1582,12 @@ TEST_F(WaterCoilsTest, FanCoilCoolingWaterFlowTest) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + GetZoneData(*state, ErrorsFound); EXPECT_EQ("EAST ZONE", state->dataHeatBal->Zone(1).Name); GetZoneEquipmentData(*state); - ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; GetFanInput(*state); EXPECT_EQ((int)HVAC::FanType::OnOff, (int)state->dataFans->fans(1)->type); @@ -1697,7 +1690,7 @@ TEST_F(WaterCoilsTest, FanCoilCoolingWaterFlowTest) } state->dataHeatBalFanSys->TempControlType.allocate(1); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::DualSetPointWithDeadBand; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::DualHeatCool; state->dataWaterCoils->WaterCoil(2).WaterPlantLoc.loopNum = 1; state->dataWaterCoils->WaterCoil(2).WaterPlantLoc.loopSideNum = DataPlant::LoopSideLocation::Demand; diff --git a/tst/EnergyPlus/unit/WaterManager.unit.cc b/tst/EnergyPlus/unit/WaterManager.unit.cc index 75a35d2a2e0..1bcf2e70afa 100644 --- a/tst/EnergyPlus/unit/WaterManager.unit.cc +++ b/tst/EnergyPlus/unit/WaterManager.unit.cc @@ -80,7 +80,8 @@ TEST_F(EnergyPlusFixture, WaterManager_NormalAnnualPrecipitation) "1;", }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + WaterManager::GetWaterManagerInput(*state); state->dataEnvrn->Year = 2000; state->dataEnvrn->EndYear = 2000; @@ -88,12 +89,12 @@ TEST_F(EnergyPlusFixture, WaterManager_NormalAnnualPrecipitation) state->dataGlobal->TimeStep = 2; state->dataGlobal->TimeStepZoneSec = 900; - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; + Sched::GetSchedule(*state, "PRECIPITATIONSCHD")->currentVal = 1.0; WaterManager::UpdatePrecipitation(*state); Real64 ExpectedNomAnnualRain = 0.80771; - Real64 ExpectedCurrentRate = 1.0 * (0.75 / 0.80771) / Constant::SecInHour; + Real64 ExpectedCurrentRate = 1.0 * (0.75 / 0.80771) / Constant::rSecsInHour; Real64 NomAnnualRain = state->dataWaterData->RainFall.NomAnnualRain; EXPECT_NEAR(NomAnnualRain, ExpectedNomAnnualRain, 0.000001); @@ -119,6 +120,7 @@ TEST_F(EnergyPlusFixture, WaterManager_UpdatePrecipitation) "1;", }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); WaterManager::GetWaterManagerInput(*state); state->dataGlobal->TimeStepZoneSec = 900; state->dataEnvrn->Year = 2000; @@ -126,7 +128,7 @@ TEST_F(EnergyPlusFixture, WaterManager_UpdatePrecipitation) state->dataEnvrn->Month = 1; state->dataGlobal->TimeStep = 2; - state->dataScheduleMgr->Schedule(1).CurrentValue = 2.0; + Sched::GetSchedule(*state, "PRECIPITATIONSCHD")->currentVal = 2.0; state->dataEnvrn->LiquidPrecipitation = 0.5; WaterManager::UpdatePrecipitation(*state); @@ -161,6 +163,7 @@ TEST_F(EnergyPlusFixture, WaterManager_ZeroAnnualPrecipitation) "1;", }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); WaterManager::GetWaterManagerInput(*state); state->dataEnvrn->Year = 2000; state->dataEnvrn->EndYear = 2000; @@ -168,7 +171,7 @@ TEST_F(EnergyPlusFixture, WaterManager_ZeroAnnualPrecipitation) state->dataGlobal->TimeStep = 2; state->dataGlobal->TimeStepZoneSec = 900; - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; + Sched::GetSchedule(*state, "PRECIPITATIONSCHD")->currentVal = 1.0; WaterManager::UpdatePrecipitation(*state); @@ -228,6 +231,7 @@ TEST_F(EnergyPlusFixture, WaterManager_Fill) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); WaterManager::GetWaterManagerInput(*state); state->dataWaterManager->GetInputFlag = false; @@ -248,7 +252,7 @@ TEST_F(EnergyPlusFixture, WaterManager_Fill) // Simulate a call for tank water that would produce 0.025m3 of draw in one timestep state->dataHVACGlobal->TimeStepSys = 10.0 / 60.0; - state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; state->dataWaterData->WaterStorage(TankNum).NumWaterDemands = 1; state->dataWaterData->WaterStorage(TankNum).VdotRequestDemand.allocate(1); Real64 draw = 0.025; @@ -362,6 +366,7 @@ TEST_F(EnergyPlusFixture, WaterManager_MainsWater_Meter_Test) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); WaterManager::GetWaterManagerInput(*state); state->dataWaterManager->GetInputFlag = false; diff --git a/tst/EnergyPlus/unit/WaterThermalTanks.unit.cc b/tst/EnergyPlus/unit/WaterThermalTanks.unit.cc index dcc74d48ce4..aed6d01209e 100644 --- a/tst/EnergyPlus/unit/WaterThermalTanks.unit.cc +++ b/tst/EnergyPlus/unit/WaterThermalTanks.unit.cc @@ -362,6 +362,7 @@ TEST_F(EnergyPlusFixture, HPWHZoneEquipSeqenceNumberWarning) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); bool ErrorsFound = false; HeatBalanceManager::GetZoneData(*state, ErrorsFound); @@ -539,6 +540,7 @@ TEST_F(EnergyPlusFixture, HPWHWrappedDummyNodeConfig) std::string const idf_objects = delimited_string(idf_lines); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); WaterThermalTanks::GetWaterThermalTankInput(*state); @@ -727,6 +729,7 @@ TEST_F(EnergyPlusFixture, HPWHEnergyBalance) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); state->dataEnvrn->StdRhoAir = 1.0; ASSERT_FALSE(WaterThermalTanks::GetWaterThermalTankInput(*state)); @@ -767,7 +770,7 @@ TEST_F(EnergyPlusFixture, HPWHEnergyBalance) state->dataGlobal->TimeStep = 1; state->dataGlobal->TimeStepZone = 10. / 60.; state->dataHVACGlobal->TimeStepSys = state->dataGlobal->TimeStepZone; - state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; state->dataHVACGlobal->SysTimeElapsed = 0.0; Tank.TimeElapsed = @@ -1037,6 +1040,7 @@ TEST_F(EnergyPlusFixture, HPWHSizing) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); state->dataEnvrn->StdRhoAir = 1.0; bool ErrorsFound = false; @@ -1046,7 +1050,7 @@ TEST_F(EnergyPlusFixture, HPWHSizing) HeatBalanceManager::GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); state->dataHVACGlobal->TimeStepSys = 1; - state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; state->dataEnvrn->OutBaroPress = 101325; SetPredefinedTables(*state); @@ -1239,6 +1243,7 @@ TEST_F(EnergyPlusFixture, HPWHOutdoorAirMissingNodeNameWarning) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); bool ErrorsFound = WaterThermalTanks::GetWaterThermalTankInput(*state); EXPECT_TRUE(ErrorsFound); @@ -1406,19 +1411,20 @@ TEST_F(EnergyPlusFixture, HPWHTestSPControl) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); state->dataEnvrn->StdRhoAir = 1.0; state->dataHVACGlobal->TimeStepSys = 1; - state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; - state->dataGlobal->NumOfTimeStepInHour = 1; - state->dataGlobal->MinutesPerTimeStep = 60 / state->dataGlobal->NumOfTimeStepInHour; + state->dataGlobal->TimeStepsInHour = 1; + state->dataGlobal->MinutesInTimeStep = 60 / state->dataGlobal->TimeStepsInHour; state->dataGlobal->TimeStep = 1; state->dataGlobal->HourOfDay = 1; state->dataEnvrn->DayOfWeek = 1; state->dataEnvrn->DayOfYear_Schedule = 1; SetPredefinedTables(*state); - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); EXPECT_FALSE(WaterThermalTanks::GetWaterThermalTankInput(*state)); @@ -1609,6 +1615,7 @@ TEST_F(EnergyPlusFixture, StratifiedTankUseEnergy) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); EXPECT_FALSE(WaterThermalTanks::GetWaterThermalTankInput(*state)); @@ -1625,7 +1632,7 @@ TEST_F(EnergyPlusFixture, StratifiedTankUseEnergy) state->dataGlobal->TimeStep = 1; state->dataGlobal->TimeStepZone = 10. / 60.; state->dataHVACGlobal->TimeStepSys = state->dataGlobal->TimeStepZone; - state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; state->dataHVACGlobal->SysTimeElapsed = 0.0; Tank.TimeElapsed = state->dataGlobal->HourOfDay + state->dataGlobal->TimeStep * state->dataGlobal->TimeStepZone + state->dataHVACGlobal->SysTimeElapsed; @@ -1706,6 +1713,9 @@ TEST_F(EnergyPlusFixture, StratifiedTankSourceTemperatures) }); ASSERT_TRUE(process_idf(idf_objects)); + state->dataGlobal->TimeStepsInHour = 1; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 60; // must initialize this to get schedules initialized + state->init_state(*state); bool ErrorsFound = false; HeatBalanceManager::GetZoneData(*state, ErrorsFound); // read zone data @@ -1713,11 +1723,6 @@ TEST_F(EnergyPlusFixture, StratifiedTankSourceTemperatures) InternalHeatGains::GetInternalHeatGainsInput(*state); - state->dataGlobal->NumOfTimeStepInHour = 1; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 60; // must initialize this to get schedules initialized - ScheduleManager::ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; - state->dataGlobal->TimeStep = 1; state->dataGlobal->HourOfDay = 1; state->dataEnvrn->Month = 7; @@ -1727,7 +1732,7 @@ TEST_F(EnergyPlusFixture, StratifiedTankSourceTemperatures) state->dataEnvrn->DayOfWeek = 2; state->dataEnvrn->HolidayIndex = 0; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); int TankNum(1); EXPECT_FALSE(WaterThermalTanks::GetWaterThermalTankInput(*state)); @@ -1755,7 +1760,7 @@ TEST_F(EnergyPlusFixture, StratifiedTankSourceTemperatures) state->dataGlobal->TimeStep = 1; state->dataGlobal->TimeStepZone = 15. / 60.; state->dataHVACGlobal->TimeStepSys = state->dataGlobal->TimeStepZone; - state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; state->dataHVACGlobal->SysTimeElapsed = 0.0; Tank.CalcWaterThermalTankStratified(*state); @@ -1822,6 +1827,7 @@ TEST_F(EnergyPlusFixture, MixedTankTimeNeededCalc) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); bool ErrorsFound = false; HeatBalanceManager::GetZoneData(*state, ErrorsFound); // read zone data @@ -1837,7 +1843,7 @@ TEST_F(EnergyPlusFixture, MixedTankTimeNeededCalc) state->dataGlobal->TimeStep = 1; state->dataGlobal->TimeStepZone = 1.0 / 60.0; // one-minute system time step state->dataHVACGlobal->TimeStepSys = state->dataGlobal->TimeStepZone; - state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; Tank.TankTemp = 60.0; Tank.AmbientTempZone = 20.0; Tank.AmbientTemp = 20.0; @@ -1934,6 +1940,7 @@ TEST_F(EnergyPlusFixture, StratifiedTankCalc) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); bool ErrorsFound = false; HeatBalanceManager::GetZoneData(*state, ErrorsFound); // read zone data @@ -1946,7 +1953,7 @@ TEST_F(EnergyPlusFixture, StratifiedTankCalc) state->dataGlobal->TimeStep = 1; state->dataGlobal->TimeStepZone = 20.0 / 60.0; state->dataHVACGlobal->TimeStepSys = state->dataGlobal->TimeStepZone; - state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; constexpr int TankNum = 1; WaterThermalTanks::WaterThermalTankData &Tank = state->dataWaterThermalTanks->WaterThermalTank(TankNum); for (auto &node : Tank.Node) { @@ -2129,6 +2136,7 @@ TEST_F(EnergyPlusFixture, StratifiedTankSourceFlowRateCalc) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); bool ErrorsFound = false; HeatBalanceManager::GetZoneData(*state, ErrorsFound); // read zone data @@ -2147,7 +2155,7 @@ TEST_F(EnergyPlusFixture, StratifiedTankSourceFlowRateCalc) state->dataGlobal->TimeStep = 1; state->dataGlobal->TimeStepZone = 20.0 / 60.0; state->dataHVACGlobal->TimeStepSys = state->dataGlobal->TimeStepZone; - state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; // Test a constant temperature source flow rate for (auto &node : Tank.Node) { @@ -2365,16 +2373,14 @@ TEST_F(EnergyPlusFixture, DesuperheaterTimeAdvanceCheck) }); ASSERT_TRUE(process_idf(idf_objects)); + state->dataGlobal->TimeStepsInHour = 1; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 60; // must initialize this to get schedules initialized + state->init_state(*state); bool ErrorsFound = false; HeatBalanceManager::GetZoneData(*state, ErrorsFound); // read zone data EXPECT_FALSE(ErrorsFound); - state->dataGlobal->NumOfTimeStepInHour = 1; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 60; // must initialize this to get schedules initialized - ScheduleManager::ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; - state->dataGlobal->TimeStep = 1; state->dataGlobal->HourOfDay = 1; state->dataEnvrn->Month = 7; @@ -2384,7 +2390,7 @@ TEST_F(EnergyPlusFixture, DesuperheaterTimeAdvanceCheck) state->dataEnvrn->DayOfWeek = 2; state->dataEnvrn->HolidayIndex = 0; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); int TankNum = 1; int DXNum = 1; @@ -2400,7 +2406,7 @@ TEST_F(EnergyPlusFixture, DesuperheaterTimeAdvanceCheck) state->dataGlobal->TimeStep = 1; state->dataGlobal->TimeStepZone = 1; state->dataHVACGlobal->TimeStepSys = state->dataGlobal->TimeStepZone; - state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; state->dataHVACGlobal->SysTimeElapsed = 0.0; // First iteration condition set (extreme) @@ -2643,16 +2649,14 @@ TEST_F(EnergyPlusFixture, StratifiedTank_GSHP_DesuperheaterSourceHeat) }); ASSERT_TRUE(process_idf(idf_objects)); + state->dataGlobal->TimeStepsInHour = 1; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 60; // must initialize this to get schedules initialized + state->init_state(*state); bool ErrorsFound = false; HeatBalanceManager::GetZoneData(*state, ErrorsFound); // read zone data EXPECT_FALSE(ErrorsFound); - state->dataGlobal->NumOfTimeStepInHour = 1; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 60; // must initialize this to get schedules initialized - ScheduleManager::ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; - state->dataGlobal->TimeStep = 1; state->dataGlobal->HourOfDay = 1; state->dataEnvrn->Month = 7; @@ -2663,7 +2667,7 @@ TEST_F(EnergyPlusFixture, StratifiedTank_GSHP_DesuperheaterSourceHeat) state->dataEnvrn->HolidayIndex = 0; state->dataEnvrn->OutBaroPress = 101325.0; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); state->dataPlnt->TotNumLoops = 1; int TankNum(1); int HPNum(1); @@ -2732,7 +2736,7 @@ TEST_F(EnergyPlusFixture, StratifiedTank_GSHP_DesuperheaterSourceHeat) state->dataGlobal->TimeStep = 1; state->dataGlobal->TimeStepZone = 1. / 60.; state->dataHVACGlobal->TimeStepSys = state->dataGlobal->TimeStepZone; - state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; state->dataHVACGlobal->SysTimeElapsed = 0.0; state->dataHeatBal->HeatReclaimSimple_WAHPCoil(1).AvailCapacity = 1000; state->dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(1).PartLoadRatio = 0.0; @@ -3035,16 +3039,15 @@ TEST_F(EnergyPlusFixture, Desuperheater_Multispeed_Coil_Test) }); ASSERT_TRUE(process_idf(idf_objects)); + state->dataGlobal->TimeStepsInHour = 1; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 60; // must initialize this to get schedules initialized + state->init_state(*state); + bool ErrorsFound = false; HeatBalanceManager::GetZoneData(*state, ErrorsFound); // read zone data EXPECT_FALSE(ErrorsFound); - state->dataGlobal->NumOfTimeStepInHour = 1; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 60; // must initialize this to get schedules initialized - ScheduleManager::ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; - state->dataGlobal->TimeStep = 1; state->dataGlobal->HourOfDay = 1; state->dataEnvrn->Month = 7; @@ -3054,7 +3057,7 @@ TEST_F(EnergyPlusFixture, Desuperheater_Multispeed_Coil_Test) state->dataEnvrn->DayOfWeek = 2; state->dataEnvrn->HolidayIndex = 0; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); int TankNum(1); int DXNum(1); @@ -3079,8 +3082,8 @@ TEST_F(EnergyPlusFixture, Desuperheater_Multispeed_Coil_Test) state->dataDXCoils->DXCoil(1).InletAirTemp = 27.0; state->dataDXCoils->DXCoil(1).InletAirHumRat = 0.005; state->dataDXCoils->DXCoil(1).InletAirEnthalpy = Psychrometrics::PsyHFnTdbW(27.0, 0.005); - state->dataDXCoils->DXCoil(1).SchedPtr = 1; - state->dataScheduleMgr->Schedule(state->dataDXCoils->DXCoil(1).SchedPtr).CurrentValue = 1.0; // enable the VRF condenser + state->dataDXCoils->DXCoil(1).availSched = Sched::GetSchedule(*state, "HOT WATER DEMAND SCHEDULE"); + state->dataDXCoils->DXCoil(1).availSched->currentVal = 1.0; // enable the VRF condenser state->dataDXCoils->DXCoil(1).MSRatedCBF(1) = 0.1262; state->dataDXCoils->DXCoil(1).MSRatedCBF(2) = 0.0408; @@ -3100,7 +3103,7 @@ TEST_F(EnergyPlusFixture, Desuperheater_Multispeed_Coil_Test) state->dataGlobal->TimeStep = 1; state->dataGlobal->TimeStepZone = 1; state->dataHVACGlobal->TimeStepSys = state->dataGlobal->TimeStepZone; - state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; state->dataHVACGlobal->SysTimeElapsed = 0.0; Tank.TankTemp = 45.0; Tank.AmbientTemp = 20.0; @@ -3199,11 +3202,9 @@ TEST_F(EnergyPlusFixture, MixedTankAlternateSchedule) ASSERT_TRUE(process_idf(idf_objects)); // Schedules setup - state->dataGlobal->NumOfTimeStepInHour = 1; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 60; // must initialize this to get schedules initialized - ScheduleManager::ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; - + state->dataGlobal->TimeStepsInHour = 1; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 60; // must initialize this to get schedules initialized + state->init_state(*state); state->dataGlobal->TimeStep = 1; state->dataGlobal->HourOfDay = 1; state->dataEnvrn->Month = 7; @@ -3213,7 +3214,7 @@ TEST_F(EnergyPlusFixture, MixedTankAlternateSchedule) state->dataEnvrn->DayOfWeek = 2; state->dataEnvrn->HolidayIndex = 0; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); EXPECT_FALSE(WaterThermalTanks::GetWaterThermalTankInput(*state)); @@ -3303,6 +3304,7 @@ TEST_F(EnergyPlusFixture, MixedTank_WarnPotentialFreeze) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); EXPECT_FALSE(WaterThermalTanks::GetWaterThermalTankInput(*state)); @@ -3313,7 +3315,7 @@ TEST_F(EnergyPlusFixture, MixedTank_WarnPotentialFreeze) state->dataGlobal->TimeStep = 1; state->dataGlobal->TimeStepZone = 1.0 / 60.0; // one-minute system time step state->dataHVACGlobal->TimeStepSys = state->dataGlobal->TimeStepZone; - state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; Tank.TankTemp = 2.0; Tank.AmbientTemp = -40; Tank.UseInletTemp = 3.0; @@ -3403,7 +3405,7 @@ TEST_F(EnergyPlusFixture, StratifiedTank_WarnPotentialFreeze) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); EXPECT_FALSE(WaterThermalTanks::GetWaterThermalTankInput(*state)); int TankNum(1); @@ -3413,7 +3415,7 @@ TEST_F(EnergyPlusFixture, StratifiedTank_WarnPotentialFreeze) state->dataGlobal->TimeStep = 1; state->dataGlobal->TimeStepZone = 1.0 / 60.0; // one-minute system time step state->dataHVACGlobal->TimeStepSys = state->dataGlobal->TimeStepZone; - state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; Tank.TankTemp = 2.0; for (auto &node : Tank.Node) { node.Temp = 2.0; @@ -3689,10 +3691,9 @@ TEST_F(EnergyPlusFixture, MultipleDesuperheaterSingleSource) ASSERT_TRUE(process_idf(idf_objects)); - state->dataGlobal->NumOfTimeStepInHour = 1; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 60; // must initialize this to get schedules initialized - ScheduleManager::ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; + state->dataGlobal->TimeStepsInHour = 1; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 60; // must initialize this to get schedules initialized + state->init_state(*state); state->dataGlobal->TimeStep = 1; state->dataGlobal->HourOfDay = 1; @@ -3703,14 +3704,14 @@ TEST_F(EnergyPlusFixture, MultipleDesuperheaterSingleSource) state->dataEnvrn->DayOfWeek = 2; state->dataEnvrn->HolidayIndex = 0; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); // Initiate tank conditions state->dataGlobal->HourOfDay = 0; state->dataGlobal->TimeStep = 1; state->dataGlobal->TimeStepZone = 1; state->dataHVACGlobal->TimeStepSys = state->dataGlobal->TimeStepZone; - state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; state->dataHVACGlobal->SysTimeElapsed = 0.0; int DXNum = 1; @@ -4213,7 +4214,7 @@ TEST_F(EnergyPlusFixture, HPWH_Both_Pumped_and_Wrapped_InputProcessing) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); EXPECT_TRUE(WaterThermalTanks::GetWaterThermalTankInput(*state)); EXPECT_EQ(state->dataWaterThermalTanks->HPWaterHeater.size(), 2u); @@ -4439,18 +4440,20 @@ TEST_F(EnergyPlusFixture, CrashCalcStandardRatings_HPWH_and_Standalone) }); ASSERT_TRUE(process_idf(idf_objects)); - state->dataEnvrn->StdRhoAir = 1.0; state->dataHVACGlobal->TimeStepSys = 1; - state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; - state->dataGlobal->NumOfTimeStepInHour = 1; - state->dataGlobal->MinutesPerTimeStep = 60 / state->dataGlobal->NumOfTimeStepInHour; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; + state->dataGlobal->TimeStepsInHour = 1; + state->dataGlobal->MinutesInTimeStep = 60 / state->dataGlobal->TimeStepsInHour; + state->init_state(*state); + + state->dataEnvrn->StdRhoAir = 1.0; state->dataGlobal->TimeStep = 1; state->dataGlobal->HourOfDay = 1; state->dataEnvrn->DayOfWeek = 1; state->dataEnvrn->DayOfYear_Schedule = 1; SetPredefinedTables(*state); - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); EXPECT_FALSE(WaterThermalTanks::GetWaterThermalTankInput(*state)); @@ -4733,7 +4736,8 @@ TEST_F(EnergyPlusFixture, HPWH_Wrapped_Stratified_Simultaneous) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + // This returns true if ErrorsFound EXPECT_FALSE(WaterThermalTanks::GetWaterThermalTankInput(*state)); @@ -5007,7 +5011,7 @@ TEST_F(EnergyPlusFixture, HPWH_Pumped_Stratified_Simultaneous) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); // This returns true if ErrorsFound EXPECT_FALSE(WaterThermalTanks::GetWaterThermalTankInput(*state)); @@ -5095,7 +5099,8 @@ TEST_F(EnergyPlusFixture, StratifiedTank_WarningNumberOfNodes_FalsePositiveBlank }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + bool ErrorsFound = false; HeatBalanceManager::GetZoneData(*state, ErrorsFound); // read zone data EXPECT_FALSE(ErrorsFound); @@ -5195,7 +5200,8 @@ TEST_F(EnergyPlusFixture, StratifiedTank_WarningNumberOfNodes_FalsePositiveZeroe " IndirectHeatPrimarySetpoint; !- Source Side Flow Control Mode"}); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + bool ErrorsFound = false; HeatBalanceManager::GetZoneData(*state, ErrorsFound); // read zone data EXPECT_FALSE(ErrorsFound); @@ -5294,7 +5300,8 @@ TEST_F(EnergyPlusFixture, StratifiedTank_WarningNumberOfNodes_ExpectedWarning) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + bool ErrorsFound = false; HeatBalanceManager::GetZoneData(*state, ErrorsFound); // read zone data EXPECT_FALSE(ErrorsFound); @@ -5341,7 +5348,7 @@ TEST_F(EnergyPlusFixture, PlantMassFlowRatesFuncTest) Real64 result; Real64 expected = 0.0; Real64 answerTolerance = 1.0e-35; - Tank.UseSideAvailSchedNum = -1; + Tank.useSideAvailSched = Sched::GetScheduleAlwaysOn(*state); result = Tank.PlantMassFlowRatesFunc(*state, inNodeNum, @@ -5598,6 +5605,7 @@ TEST_F(EnergyPlusFixture, MixedTank_PVT_Per_VolumeSizing_PerSolarCollectorArea) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); bool ErrorsFound = false; HeatBalanceManager::GetHeatBalanceInput(*state); // Gets materials, constructions, zones, surfaces, etc. @@ -5694,7 +5702,7 @@ TEST_F(EnergyPlusFixture, MixedTank_PVT_Per_VolumeSizing_PerSolarCollectorArea) state->dataGlobal->TimeStep = 1; state->dataGlobal->TimeStepZone = 1.0 / 60.0; // one-minute system time step state->dataHVACGlobal->TimeStepSys = state->dataGlobal->TimeStepZone; - state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; Tank.SavedTankTemp = 60.0; Tank.TankTemp = 60.0; Tank.AmbientTempZone = 20.0; diff --git a/tst/EnergyPlus/unit/WaterToAirHeatPump.unit.cc b/tst/EnergyPlus/unit/WaterToAirHeatPump.unit.cc index 9b46f887f3f..a372cf970ae 100644 --- a/tst/EnergyPlus/unit/WaterToAirHeatPump.unit.cc +++ b/tst/EnergyPlus/unit/WaterToAirHeatPump.unit.cc @@ -136,7 +136,8 @@ TEST_F(EnergyPlusFixture, WaterToAirHeatPumpTest_SimWaterToAir) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + auto *refrig = new FluidProperties::RefrigProps; refrig->Name = "R22"; state->dataFluidProps->refrigs.push_back(refrig); diff --git a/tst/EnergyPlus/unit/WaterToAirHeatPumpSimple.unit.cc b/tst/EnergyPlus/unit/WaterToAirHeatPumpSimple.unit.cc index 43a44b4d726..e84ec4586cb 100644 --- a/tst/EnergyPlus/unit/WaterToAirHeatPumpSimple.unit.cc +++ b/tst/EnergyPlus/unit/WaterToAirHeatPumpSimple.unit.cc @@ -362,7 +362,8 @@ TEST_F(EnergyPlusFixture, WaterToAirHeatPumpSimple_TestAirFlow) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + GetCurveInput(*state); GetSimpleWatertoAirHPInput(*state); @@ -717,7 +718,8 @@ TEST_F(EnergyPlusFixture, WaterToAirHeatPumpSimple_TestWaterFlowControl) }); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + GetCurveInput(*state); GetSimpleWatertoAirHPInput(*state); @@ -1598,6 +1600,8 @@ TEST_F(EnergyPlusFixture, EquationFit_Initialization) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); + std::string CurrentModuleObject = "Coil:Cooling:DX:VariableSpeed"; int num_coils = state->dataInputProcessing->inputProcessor->getNumObjectsFound(*state, CurrentModuleObject); ASSERT_EQ(0, num_coils); diff --git a/tst/EnergyPlus/unit/WaterUse.unit.cc b/tst/EnergyPlus/unit/WaterUse.unit.cc index 61cc656bb85..8db4dc2621d 100644 --- a/tst/EnergyPlus/unit/WaterUse.unit.cc +++ b/tst/EnergyPlus/unit/WaterUse.unit.cc @@ -418,10 +418,10 @@ TEST_F(EnergyPlusFixture, WaterUse_WaterTempWarnings) ASSERT_TRUE(process_idf(idf_objects)); state->dataGlobal->CurrentTime = 0.25; - state->dataGlobal->NumOfTimeStepInHour = 1; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 60; // must initialize this to get schedules initialized - ScheduleManager::ProcessScheduleInput(*state); // read schedules - state->dataScheduleMgr->ScheduleInputProcessed = true; + state->dataGlobal->TimeStepsInHour = 1; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 60; // must initialize this to get schedules initialized + state->init_state(*state); + state->dataEnvrn->Month = 1; state->dataEnvrn->DayOfMonth = 21; state->dataGlobal->HourOfDay = 1; @@ -431,7 +431,7 @@ TEST_F(EnergyPlusFixture, WaterUse_WaterTempWarnings) state->dataEnvrn->HolidayIndex = 0; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); state->dataEnvrn->StdRhoAir = Psychrometrics::PsyRhoAirFnPbTdbW(*state, 101325.0, 20.0, 0.0); - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); HeatBalanceManager::GetZoneData(*state, ErrorsFound); InternalHeatGains::GetInternalHeatGainsInput(*state); @@ -462,8 +462,8 @@ TEST_F(EnergyPlusFixture, WaterUse_WaterTempWarnings) // configuration allows hot water mixing. A target temp schedule exists with either a hot temp schedule or a connnections object EXPECT_TRUE(thisWaterEquipment.allowHotControl); - EXPECT_TRUE(thisWaterEquipment.TargetTempSchedule); - EXPECT_TRUE(thisWaterEquipment.HotTempSchedule || thisWaterEquipment.Connections); + EXPECT_NE(thisWaterEquipment.targetTempSched, nullptr); + EXPECT_TRUE(thisWaterEquipment.hotTempSched != nullptr || thisWaterEquipment.Connections); EXPECT_GT(thisWaterEquipment.HotMassFlowRate, 0.0); EXPECT_NEAR(thisWaterEquipment.ColdMassFlowRate + thisWaterEquipment.HotMassFlowRate, thisWaterEquipment.TotalMassFlowRate, 0.00000001); @@ -472,7 +472,7 @@ TEST_F(EnergyPlusFixture, WaterUse_WaterTempWarnings) thisWaterConnections.InitConnections(*state); // Set target temperature to 50C, above hot water temperature to trigger warning - state->dataScheduleMgr->Schedule(4).CurrentValue = 50; + Sched::GetSchedule(*state, "WATER EQUIPMENT TEMP SCHED")->currentVal = 50; thisWaterEquipment.WaterEquipmentType::CalcEquipmentFlowRates(*state); std::string const error_string2 = delimited_string({ @@ -490,7 +490,7 @@ TEST_F(EnergyPlusFixture, WaterUse_WaterTempWarnings) EXPECT_NEAR(thisWaterEquipment.ColdMassFlowRate + thisWaterEquipment.HotMassFlowRate, thisWaterEquipment.TotalMassFlowRate, 0.00000001); // Set target temperature to 0C, below cold water temperature to trigger warning - state->dataScheduleMgr->Schedule(4).CurrentValue = 0; + Sched::GetSchedule(*state, "WATER EQUIPMENT TEMP SCHED")->currentVal = 0; thisWaterEquipment.WaterEquipmentType::CalcEquipmentFlowRates(*state); std::string const error_string3 = delimited_string({ @@ -855,10 +855,10 @@ TEST_F(EnergyPlusFixture, WaterUse_Default_Target_Temperature_Test1) ASSERT_TRUE(process_idf(idf_objects)); - state->dataGlobal->NumOfTimeStepInHour = 1; - state->dataGlobal->MinutesPerTimeStep = 60; - ScheduleManager::ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; + state->dataGlobal->TimeStepsInHour = 1; + state->dataGlobal->MinutesInTimeStep = 60; + state->init_state(*state); + state->dataEnvrn->Month = 1; state->dataEnvrn->DayOfMonth = 21; state->dataGlobal->HourOfDay = 1; @@ -868,7 +868,7 @@ TEST_F(EnergyPlusFixture, WaterUse_Default_Target_Temperature_Test1) state->dataEnvrn->HolidayIndex = 0; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); state->dataEnvrn->StdRhoAir = Psychrometrics::PsyRhoAirFnPbTdbW(*state, 101325.0, 20.0, 0.0); - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); HeatBalanceManager::GetZoneData(*state, ErrorsFound); InternalHeatGains::GetInternalHeatGainsInput(*state); @@ -887,10 +887,10 @@ TEST_F(EnergyPlusFixture, WaterUse_Default_Target_Temperature_Test1) // The target temp will default to the hot water temperature if there exists either a hot temp schedule or a water use connnections object. EXPECT_TRUE(thisWaterEquipment.allowHotControl); - EXPECT_FALSE(thisWaterEquipment.TargetTempSchedule); + EXPECT_EQ(thisWaterEquipment.targetTempSched, nullptr); EXPECT_NEAR(thisWaterEquipment.TargetTemp, 45, 1e-5); - EXPECT_TRUE(thisWaterEquipment.HotTempSchedule || thisWaterEquipment.Connections); + EXPECT_TRUE(thisWaterEquipment.hotTempSched != nullptr || thisWaterEquipment.Connections); EXPECT_GT(thisWaterEquipment.HotMassFlowRate, 0.0); EXPECT_NEAR(thisWaterEquipment.ColdMassFlowRate, 0.0, 1e-5); EXPECT_NEAR(thisWaterEquipment.ColdMassFlowRate + thisWaterEquipment.HotMassFlowRate, thisWaterEquipment.TotalMassFlowRate, 1e-8); @@ -1230,10 +1230,10 @@ TEST_F(EnergyPlusFixture, WaterUse_Default_Target_Temperature_Test2) ASSERT_TRUE(process_idf(idf_objects)); - state->dataGlobal->NumOfTimeStepInHour = 1; - state->dataGlobal->MinutesPerTimeStep = 60; - ScheduleManager::ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; + state->dataGlobal->TimeStepsInHour = 1; + state->dataGlobal->MinutesInTimeStep = 60; + state->init_state(*state); + state->dataEnvrn->Month = 1; state->dataEnvrn->DayOfMonth = 21; state->dataGlobal->HourOfDay = 1; @@ -1243,7 +1243,7 @@ TEST_F(EnergyPlusFixture, WaterUse_Default_Target_Temperature_Test2) state->dataEnvrn->HolidayIndex = 0; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); state->dataEnvrn->StdRhoAir = Psychrometrics::PsyRhoAirFnPbTdbW(*state, 101325.0, 20.0, 0.0); - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); HeatBalanceManager::GetZoneData(*state, ErrorsFound); InternalHeatGains::GetInternalHeatGainsInput(*state); @@ -1257,10 +1257,10 @@ TEST_F(EnergyPlusFixture, WaterUse_Default_Target_Temperature_Test2) // A target temp will default to cold water temperature is there is neither a hot temp schedule nor a water use connnections object. EXPECT_FALSE(thisWaterEquipment.allowHotControl); - EXPECT_FALSE(thisWaterEquipment.TargetTempSchedule); + EXPECT_EQ(thisWaterEquipment.targetTempSched, nullptr); EXPECT_NEAR(thisWaterEquipment.TargetTemp, 15, 1e-5); - EXPECT_FALSE((thisWaterEquipment.TargetTempSchedule && thisWaterEquipment.HotTempSchedule) || thisWaterEquipment.Connections); + EXPECT_FALSE((thisWaterEquipment.targetTempSched != nullptr && thisWaterEquipment.hotTempSched != nullptr) || thisWaterEquipment.Connections); EXPECT_GT(thisWaterEquipment.ColdMassFlowRate, 0.0); EXPECT_NEAR(thisWaterEquipment.HotMassFlowRate, 0.0, 1e-5); diff --git a/tst/EnergyPlus/unit/WeatherManager.unit.cc b/tst/EnergyPlus/unit/WeatherManager.unit.cc index bbdcd682397..4856f11296c 100644 --- a/tst/EnergyPlus/unit/WeatherManager.unit.cc +++ b/tst/EnergyPlus/unit/WeatherManager.unit.cc @@ -77,7 +77,6 @@ #include using namespace EnergyPlus; -using namespace EnergyPlus::ScheduleManager; TEST_F(EnergyPlusFixture, SkyTempTest) { @@ -129,30 +128,34 @@ TEST_F(EnergyPlusFixture, SkyTempTest) }); ASSERT_TRUE(process_idf(idf_objects)); + state->dataGlobal->TimeStepsInHour = 4; + state->dataGlobal->MinutesInTimeStep = 60 / state->dataGlobal->TimeStepsInHour; + + state->init_state(*state); + Array2D TomorrowSkyTemp; // Sky temperature - state->dataGlobal->NumOfTimeStepInHour = 4; - state->dataGlobal->MinutesPerTimeStep = 60 / state->dataGlobal->NumOfTimeStepInHour; - TomorrowSkyTemp.allocate(state->dataGlobal->NumOfTimeStepInHour, 24); + TomorrowSkyTemp.allocate(state->dataGlobal->TimeStepsInHour, 24); TomorrowSkyTemp = 0.0; + auto *tSkySched = Sched::GetSchedule(*state, "TSKYSCHEDULE"); // Febuary 27 - ScheduleManager::GetScheduleValuesForDay(*state, 1, TomorrowSkyTemp, 58, 3); + tSkySched->getDayVals(*state, TomorrowSkyTemp, 58, 3); EXPECT_NEAR(2.27, TomorrowSkyTemp(1, 1), .001); // Febuary 28 - ScheduleManager::GetScheduleValuesForDay(*state, 1, TomorrowSkyTemp, 59, 4); + tSkySched->getDayVals(*state, TomorrowSkyTemp, 59, 4); EXPECT_NEAR(2.28, TomorrowSkyTemp(1, 1), .001); // March 1 - ScheduleManager::GetScheduleValuesForDay(*state, 1, TomorrowSkyTemp, 60, 5); + tSkySched->getDayVals(*state, TomorrowSkyTemp, 60, 5); EXPECT_NEAR(3.01, TomorrowSkyTemp(1, 1), .001); // Not March 2, this "Day" is ignored unless its a leap year, otherwise same data as March 1 - ScheduleManager::GetScheduleValuesForDay(*state, 1, TomorrowSkyTemp, 61, 6); + tSkySched->getDayVals(*state, TomorrowSkyTemp, 61, 6); EXPECT_NEAR(3.01, TomorrowSkyTemp(1, 1), .001); // March 2 - ScheduleManager::GetScheduleValuesForDay(*state, 1, TomorrowSkyTemp, 62, 6); + tSkySched->getDayVals(*state, TomorrowSkyTemp, 62, 6); EXPECT_NEAR(3.02, TomorrowSkyTemp(1, 1), .001); } @@ -318,7 +321,8 @@ TEST_F(EnergyPlusFixture, UnderwaterBoundaryConditionFullyPopulated) "Schedule:Constant, WaterVelocitySchedule, , 3.0;" "SurfaceProperty:OtherSideConditionsModel, UnderwaterSurfaceName, ConvectiveUnderwater;"}); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + // need to populate the OSCM array by calling the get input for it bool errorsFound = false; SurfaceGeometry::GetOSCMData(*state, errorsFound); @@ -331,8 +335,8 @@ TEST_F(EnergyPlusFixture, UnderwaterBoundaryConditionFullyPopulated) EXPECT_EQ(state->dataWeather->underwaterBoundaries[0].Name, "UNDERWATERSURFACENAME"); EXPECT_NEAR(state->dataWeather->underwaterBoundaries[0].distanceFromLeadingEdge, 31.4159, 0.0001); EXPECT_EQ(state->dataWeather->underwaterBoundaries[0].OSCMIndex, 1); - EXPECT_EQ(state->dataWeather->underwaterBoundaries[0].WaterTempScheduleIndex, 1); - EXPECT_EQ(state->dataWeather->underwaterBoundaries[0].VelocityScheduleIndex, 2); + EXPECT_EQ(state->dataWeather->underwaterBoundaries[0].waterTempSched->Name, "WATERTEMPSCHEDULE"); + EXPECT_EQ(state->dataWeather->underwaterBoundaries[0].velocitySched->Name, "WATERVELOCITYSCHEDULE"); } TEST_F(EnergyPlusFixture, UnderwaterBoundaryConditionMissingVelocityOK) @@ -342,7 +346,8 @@ TEST_F(EnergyPlusFixture, UnderwaterBoundaryConditionMissingVelocityOK) "Schedule:Constant, WaterTempSchedule, , 30;", "SurfaceProperty:OtherSideConditionsModel, UnderwaterSurfaceName, ConvectiveUnderwater;"}); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + // need to populate the OSCM array by calling the get input for it bool errorsFound = false; SurfaceGeometry::GetOSCMData(*state, errorsFound); @@ -355,8 +360,8 @@ TEST_F(EnergyPlusFixture, UnderwaterBoundaryConditionMissingVelocityOK) EXPECT_EQ(state->dataWeather->underwaterBoundaries[0].Name, "UNDERWATERSURFACENAME"); EXPECT_NEAR(state->dataWeather->underwaterBoundaries[0].distanceFromLeadingEdge, 31.4159, 0.0001); EXPECT_EQ(state->dataWeather->underwaterBoundaries[0].OSCMIndex, 1); - EXPECT_EQ(state->dataWeather->underwaterBoundaries[0].WaterTempScheduleIndex, 1); - EXPECT_EQ(state->dataWeather->underwaterBoundaries[0].VelocityScheduleIndex, 0); + EXPECT_NE(state->dataWeather->underwaterBoundaries[0].waterTempSched, nullptr); + EXPECT_EQ(state->dataWeather->underwaterBoundaries[0].velocitySched, nullptr); } TEST_F(EnergyPlusFixture, UnderwaterBoundaryConditionConvectionCoefficients) @@ -688,7 +693,7 @@ TEST_F(EnergyPlusFixture, ASHRAE_Tau2017ModelTest) bool ErrorsFound(false); state->dataEnvrn->TotDesDays = 2; - state->dataGlobal->NumOfTimeStepInHour = 0; + state->dataGlobal->TimeStepsInHour = 0; // setup environment state state->dataWeather->Environment.allocate(state->dataEnvrn->TotDesDays); state->dataWeather->DesignDay.allocate(state->dataEnvrn->TotDesDays); @@ -791,7 +796,7 @@ TEST_F(EnergyPlusFixture, WeatherManager_NoLocation) ASSERT_TRUE(process_idf(idf_objects)); state->dataGlobal->BeginSimFlag = false; - state->dataGlobal->NumOfTimeStepInHour = 4; + state->dataGlobal->TimeStepsInHour = 4; state->dataWeather->LocationGathered = false; bool Available{false}; @@ -874,8 +879,8 @@ TEST_F(SQLiteFixture, DesignDay_EnthalphyAtMaxDB) state->dataWeather->Environment(1).DesignDayNum = 1; state->dataWeather->Environment(1).WP_Type1 = 0; - state->dataGlobal->MinutesPerTimeStep = 60; - state->dataGlobal->NumOfTimeStepInHour = 1; + state->dataGlobal->MinutesInTimeStep = 60; + state->dataGlobal->TimeStepsInHour = 1; state->dataGlobal->BeginSimFlag = true; state->dataReportFlag->DoWeatherInitReporting = true; @@ -891,7 +896,7 @@ TEST_F(SQLiteFixture, DesignDay_EnthalphyAtMaxDB) unsigned n_RH_not100 = 0; for (int Hour = 1; Hour <= 24; ++Hour) { - for (int TS = 1; TS <= state->dataGlobal->NumOfTimeStepInHour; ++TS) { + for (int TS = 1; TS <= state->dataGlobal->TimeStepsInHour; ++TS) { EXPECT_GE(state->dataWeather->wvarsHrTsTomorrow(TS, Hour).OutRelHum, 0.); EXPECT_LE(state->dataWeather->wvarsHrTsTomorrow(TS, Hour).OutRelHum, 100.); if (state->dataWeather->wvarsHrTsTomorrow(TS, Hour).OutRelHum < 100.) { @@ -1145,7 +1150,7 @@ TEST_F(EnergyPlusFixture, IRHoriz_InterpretWeatherCalculateMissingIRHoriz) bool ErrorsFound(false); state->dataEnvrn->TotDesDays = 2; - state->dataGlobal->NumOfTimeStepInHour = 0; + state->dataGlobal->TimeStepsInHour = 0; // setup environment state state->dataWeather->Environment.allocate(state->dataEnvrn->TotDesDays); @@ -1157,7 +1162,7 @@ TEST_F(EnergyPlusFixture, IRHoriz_InterpretWeatherCalculateMissingIRHoriz) state->dataWeather->Envrn = 1; - state->dataGlobal->NumOfTimeStepInHour = 1; + state->dataGlobal->TimeStepsInHour = 1; state->dataWeather->Environment.allocate(1); state->dataWeather->Environment(1).skyTempModel = Weather::SkyTempModel::ClarkAllen; @@ -1220,6 +1225,8 @@ TEST_F(EnergyPlusFixture, Add_and_InterpolateWeatherInputOutputTest) bool ErrorsFound(false); ErrorsFound = false; + state->init_state(*state); + state->dataWeather->WeatherFileExists = true; state->files.inputWeatherFilePath.filePath = configured_source_directory() / "weather/USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw"; @@ -1249,7 +1256,7 @@ TEST_F(EnergyPlusFixture, Add_and_InterpolateWeatherInputOutputTest) state->dataWeather->Envrn = 1; - state->dataGlobal->NumOfTimeStepInHour = 4; + state->dataGlobal->TimeStepsInHour = 4; state->dataWeather->Environment.allocate(1); state->dataWeather->Environment(1).skyTempModel = Weather::SkyTempModel::ClarkAllen; state->dataWeather->Environment(1).StartMonth = 1; @@ -1319,6 +1326,8 @@ TEST_F(EnergyPlusFixture, Fix_first_hour_weather_data_interpolation_OutputTest) bool ErrorsFound(false); ErrorsFound = false; + state->init_state(*state); + state->dataWeather->WeatherFileExists = true; state->files.inputWeatherFilePath.filePath = configured_source_directory() / "weather/USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw"; @@ -1333,7 +1342,7 @@ TEST_F(EnergyPlusFixture, Fix_first_hour_weather_data_interpolation_OutputTest) // The added first hour processing will be called here: Weather::GetNextEnvironment(*state, Available, ErrorsFound); - state->dataGlobal->NumOfTimeStepInHour = 4; + state->dataGlobal->TimeStepsInHour = 4; state->dataWeather->Environment(1).skyTempModel = Weather::SkyTempModel::ClarkAllen; state->dataWeather->Environment(1).StartMonth = 1; state->dataWeather->Environment(1).StartDay = 1; @@ -1444,8 +1453,9 @@ TEST_F(EnergyPlusFixture, Fix_OpaqueSkyCover_Test) ASSERT_TRUE(process_idf(idf_objects)); SimulationManager::PostIPProcessing(*state); + state->init_state(*state); + bool ErrorsFound(false); - ErrorsFound = false; state->dataWeather->WeatherFileExists = true; state->files.inputWeatherFilePath.filePath = configured_source_directory() / "weather/USA_IL_University.of.Illinois-Willard.AP.725315_TMY3.epw"; @@ -1469,7 +1479,7 @@ TEST_F(EnergyPlusFixture, Fix_OpaqueSkyCover_Test) state->dataWeather->Envrn = 1; - state->dataGlobal->NumOfTimeStepInHour = 4; + state->dataGlobal->TimeStepsInHour = 4; state->dataWeather->Environment.allocate(1); state->dataWeather->Environment(1).skyTempModel = Weather::SkyTempModel::ClarkAllen; state->dataWeather->Environment(1).StartMonth = 1; @@ -1583,17 +1593,20 @@ TEST_F(EnergyPlusFixture, WeatherManager_SetRainFlag) // setting up start ------------------------------------------------------------------------------ ASSERT_TRUE(process_idf(idf_objects)); - SimulationManager::ManageSimulation(*state); - WaterManager::GetWaterManagerInput(*state); state->dataGlobal->DayOfSim = 2; // avoid array bounds problem in RecKeepHeatBalance state->dataWeather->Envrn = 1; - state->dataGlobal->NumOfTimeStepInHour = 4; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 15; // must initialize this to get schedules initialized + state->dataGlobal->TimeStepsInHour = 4; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 15; // must initialize this to get schedules initialized state->dataGlobal->TimeStepZone = 0.25; - state->dataGlobal->TimeStepZoneSec = state->dataGlobal->TimeStepZone * Constant::SecInHour; + state->dataGlobal->TimeStepZoneSec = state->dataGlobal->TimeStepZone * Constant::rSecsInHour; - ScheduleManager::ProcessScheduleInput(*state); // read schedules + state->init_state(*state); + SimulationManager::ManageSimulation(*state); + WaterManager::GetWaterManagerInput(*state); + + state->dataWeather->Envrn = 1; + state->dataEnvrn->Month = 5; state->dataEnvrn->DayOfMonth = 31; state->dataGlobal->HourOfDay = 24; @@ -1603,16 +1616,16 @@ TEST_F(EnergyPlusFixture, WeatherManager_SetRainFlag) state->dataGlobal->TimeStep = 1; state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); state->dataEnvrn->DSTIndicator = 0; // DST IS OFF - ScheduleManager::UpdateScheduleValues(*state); + Sched::UpdateScheduleVals(*state); - state->dataWeather->Interpolation.allocate(state->dataGlobal->NumOfTimeStepInHour); + state->dataWeather->Interpolation.allocate(state->dataGlobal->TimeStepsInHour); state->dataWeather->Interpolation = 0; // setting up end ------------------------------------------------------------------------------ // Need to instantiate some stuff to avoid a crash // Weather::ReadUserWeatherInput(*state); - state->dataWeather->wvarsHrTsToday.allocate(state->dataGlobal->NumOfTimeStepInHour, Constant::HoursInDay); + state->dataWeather->wvarsHrTsToday.allocate(state->dataGlobal->TimeStepsInHour, Constant::iHoursInDay); state->dataWeather->wvarsHrTsToday(1, 24).IsRain = false; state->dataEnvrn->RunPeriodEnvironment = true; Weather::SetCurrentWeather(*state); @@ -1626,7 +1639,7 @@ TEST_F(EnergyPlusFixture, WeatherManager_SetRainFlag) ASSERT_FALSE(state->dataEnvrn->IsRain); // site:precipitation overwritten of rain flag does not take effect during sizing period - state->dataGlobal->NumOfTimeStepInHour = 4; + state->dataGlobal->TimeStepsInHour = 4; state->dataWeather->wvarsHrTsToday(1, 24).IsRain = false; state->dataEnvrn->RunPeriodEnvironment = false; Weather::SetCurrentWeather(*state); @@ -1842,7 +1855,7 @@ TEST_F(EnergyPlusFixture, WeatherRunPeriod_WeatherFile_OK) state->files.inputWeatherFilePath.filePath = configured_source_directory() / "weather/USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw"; state->dataGlobal->BeginSimFlag = false; - state->dataGlobal->NumOfTimeStepInHour = 4; + state->dataGlobal->TimeStepsInHour = 4; state->dataWeather->LocationGathered = false; state->dataGlobal->DoWeathSim = true; @@ -1899,7 +1912,7 @@ TEST_F(EnergyPlusFixture, WeatherRunPeriod_WeatherFile_Missing) state->files.inputWeatherFilePath.filePath = "doesntnotexist.epw"; state->dataGlobal->BeginSimFlag = false; - state->dataGlobal->NumOfTimeStepInHour = 4; + state->dataGlobal->TimeStepsInHour = 4; state->dataWeather->LocationGathered = false; state->dataGlobal->DoWeathSim = true; @@ -2477,7 +2490,7 @@ TEST_F(EnergyPlusFixture, EPW_no_eol_at_end_of_file) state->files.inputWeatherFilePath.filePath = configured_source_directory() / "tst/EnergyPlus/unit/Resources/chicago_no_eol_at_end_of_file.epw"; state->dataGlobal->BeginSimFlag = false; - state->dataGlobal->NumOfTimeStepInHour = 4; + state->dataGlobal->TimeStepsInHour = 4; state->dataWeather->LocationGathered = false; state->dataGlobal->DoWeathSim = true; diff --git a/tst/EnergyPlus/unit/WindTurbine.unit.cc b/tst/EnergyPlus/unit/WindTurbine.unit.cc index 16cdd3704c3..4b1030cba09 100644 --- a/tst/EnergyPlus/unit/WindTurbine.unit.cc +++ b/tst/EnergyPlus/unit/WindTurbine.unit.cc @@ -88,6 +88,7 @@ TEST_F(EnergyPlusFixture, WindTurbineTest) " 21; !- Power Coefficient C6"}); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); WindTurbine::GetWindTurbineInput(*state); int index = 0; diff --git a/tst/EnergyPlus/unit/WindowAC.unit.cc b/tst/EnergyPlus/unit/WindowAC.unit.cc index 8051717dbf3..4cf3e65a018 100644 --- a/tst/EnergyPlus/unit/WindowAC.unit.cc +++ b/tst/EnergyPlus/unit/WindowAC.unit.cc @@ -435,10 +435,9 @@ TEST_F(EnergyPlusFixture, WindowAC_VStest1) }); ASSERT_TRUE(process_idf(idf_objects)); - - state->dataGlobal->NumOfTimeStepInHour = 6; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 10; // must initialize this to get schedules initialized - ScheduleManager::ProcessScheduleInput(*state); // read schedule data + state->dataGlobal->TimeStepsInHour = 6; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 10; // must initialize this to get schedules initialized + state->init_state(*state); bool errorsFound(false); HeatBalanceManager::GetProjectControlData(*state, errorsFound); // read project control data diff --git a/tst/EnergyPlus/unit/WindowEquivalentLayer.unit.cc b/tst/EnergyPlus/unit/WindowEquivalentLayer.unit.cc index f139375a41e..df3feb90a8f 100644 --- a/tst/EnergyPlus/unit/WindowEquivalentLayer.unit.cc +++ b/tst/EnergyPlus/unit/WindowEquivalentLayer.unit.cc @@ -88,7 +88,6 @@ using namespace EnergyPlus; using namespace EnergyPlus::DataZoneEquipment; using namespace EnergyPlus::HeatBalanceManager; -using namespace EnergyPlus::ScheduleManager; using namespace EnergyPlus::WindowEquivalentLayer; diff --git a/tst/EnergyPlus/unit/WindowManager.unit.cc b/tst/EnergyPlus/unit/WindowManager.unit.cc index c7fc9400de5..0bdbe9f32df 100644 --- a/tst/EnergyPlus/unit/WindowManager.unit.cc +++ b/tst/EnergyPlus/unit/WindowManager.unit.cc @@ -192,17 +192,16 @@ TEST_F(EnergyPlusFixture, WindowFrameTest) " autocalculate; !- Volume {m3}"}); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + createFacilityElectricPowerServiceObject(*state); HeatBalanceManager::SetPreConstructionInputParameters(*state); - Psychrometrics::InitializePsychRoutines(*state); - state->dataGlobal->TimeStep = 1; state->dataGlobal->TimeStepZone = 1; state->dataGlobal->TimeStepZoneSec = 60.0; state->dataGlobal->HourOfDay = 1; - state->dataGlobal->NumOfTimeStepInHour = 1; + state->dataGlobal->TimeStepsInHour = 1; state->dataGlobal->BeginSimFlag = true; state->dataGlobal->BeginEnvrnFlag = true; state->dataEnvrn->OutBaroPress = 100000; @@ -465,7 +464,8 @@ TEST_F(EnergyPlusFixture, WindowManager_RefAirTempTest) " autocalculate; !- Volume {m3}"}); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + state->dataHeatBal->ZoneIntGain.allocate(1); createFacilityElectricPowerServiceObject(*state); @@ -476,13 +476,11 @@ TEST_F(EnergyPlusFixture, WindowManager_RefAirTempTest) HeatBalanceManager::GetConstructData(*state, ErrorsFound); HeatBalanceManager::GetBuildingData(*state, ErrorsFound); - Psychrometrics::InitializePsychRoutines(*state); - state->dataGlobal->TimeStep = 1; state->dataGlobal->TimeStepZone = 1; state->dataGlobal->TimeStepZoneSec = 3600.0; state->dataGlobal->HourOfDay = 1; - state->dataGlobal->NumOfTimeStepInHour = 1; + state->dataGlobal->TimeStepsInHour = 1; state->dataGlobal->BeginSimFlag = true; state->dataGlobal->BeginEnvrnFlag = true; state->dataEnvrn->OutBaroPress = 100000; @@ -2521,14 +2519,14 @@ TEST_F(EnergyPlusFixture, SpectralAngularPropertyTest) state->dataSurfaceGeometry->CosZoneRelNorth.allocate(4); state->dataSurfaceGeometry->SinZoneRelNorth.allocate(4); - state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); - state->dataSurfaceGeometry->CosZoneRelNorth(2) = std::cos(-state->dataHeatBal->Zone(2).RelNorth * Constant::DegToRadians); - state->dataSurfaceGeometry->CosZoneRelNorth(3) = std::cos(-state->dataHeatBal->Zone(3).RelNorth * Constant::DegToRadians); - state->dataSurfaceGeometry->CosZoneRelNorth(4) = std::cos(-state->dataHeatBal->Zone(4).RelNorth * Constant::DegToRadians); - state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); - state->dataSurfaceGeometry->SinZoneRelNorth(2) = std::sin(-state->dataHeatBal->Zone(2).RelNorth * Constant::DegToRadians); - state->dataSurfaceGeometry->SinZoneRelNorth(3) = std::sin(-state->dataHeatBal->Zone(3).RelNorth * Constant::DegToRadians); - state->dataSurfaceGeometry->SinZoneRelNorth(4) = std::sin(-state->dataHeatBal->Zone(4).RelNorth * Constant::DegToRadians); + state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); + state->dataSurfaceGeometry->CosZoneRelNorth(2) = std::cos(-state->dataHeatBal->Zone(2).RelNorth * Constant::DegToRad); + state->dataSurfaceGeometry->CosZoneRelNorth(3) = std::cos(-state->dataHeatBal->Zone(3).RelNorth * Constant::DegToRad); + state->dataSurfaceGeometry->CosZoneRelNorth(4) = std::cos(-state->dataHeatBal->Zone(4).RelNorth * Constant::DegToRad); + state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); + state->dataSurfaceGeometry->SinZoneRelNorth(2) = std::sin(-state->dataHeatBal->Zone(2).RelNorth * Constant::DegToRad); + state->dataSurfaceGeometry->SinZoneRelNorth(3) = std::sin(-state->dataHeatBal->Zone(3).RelNorth * Constant::DegToRad); + state->dataSurfaceGeometry->SinZoneRelNorth(4) = std::sin(-state->dataHeatBal->Zone(4).RelNorth * Constant::DegToRad); state->dataSurfaceGeometry->CosBldgRelNorth = 1.0; state->dataSurfaceGeometry->SinBldgRelNorth = 0.0; @@ -2699,7 +2697,8 @@ TEST_F(EnergyPlusFixture, WindowManager_SrdLWRTest) " autocalculate; !- Volume {m3}"}); ASSERT_TRUE(process_idf(idf_objects)); - ScheduleManager::ProcessScheduleInput(*state); + state->init_state(*state); + state->dataHeatBal->ZoneIntGain.allocate(1); createFacilityElectricPowerServiceObject(*state); @@ -2714,7 +2713,7 @@ TEST_F(EnergyPlusFixture, WindowManager_SrdLWRTest) state->dataGlobal->TimeStepZone = 1; state->dataGlobal->TimeStepZoneSec = 3600.0; state->dataGlobal->HourOfDay = 1; - state->dataGlobal->NumOfTimeStepInHour = 1; + state->dataGlobal->TimeStepsInHour = 1; state->dataGlobal->BeginSimFlag = true; state->dataGlobal->BeginEnvrnFlag = true; state->dataEnvrn->OutBaroPress = 100000; @@ -2725,8 +2724,6 @@ TEST_F(EnergyPlusFixture, WindowManager_SrdLWRTest) EXPECT_TRUE(state->dataGlobal->AnyLocalEnvironmentsInModel); - Psychrometrics::InitializePsychRoutines(*state); - state->dataZoneEquip->ZoneEquipConfig.allocate(1); state->dataZoneEquip->ZoneEquipConfig(1).ZoneName = "Zone"; std::vector controlledZoneEquipConfigNums; @@ -2805,7 +2802,7 @@ TEST_F(EnergyPlusFixture, WindowManager_SrdLWRTest) Real64 inSurfTemp; Real64 outSurfTemp; - state->dataScheduleMgr->Schedule(1).CurrentValue = 25.0; // Srd Srfs Temp + Sched::GetSchedule(*state, "SURROUNDING TEMP SCH 1")->currentVal = 25.0; // Srd Srfs Temp // Calculate temperature based on supply flow rate HeatBalanceSurfaceManager::InitSurfacePropertyViewFactors(*state); @@ -7642,17 +7639,17 @@ TEST_F(EnergyPlusFixture, CFS_InteriorSolarDistribution_Test) " 2.500000, 0.790000, 0.053000, 0.063000; !- N1764"}); ASSERT_TRUE(process_idf(idf_objects)); - + state->init_state(*state); + createFacilityElectricPowerServiceObject(*state); HeatBalanceManager::SetPreConstructionInputParameters(*state); - Psychrometrics::InitializePsychRoutines(*state); state->dataGlobal->TimeStep = 1; state->dataGlobal->TimeStepZone = 1; state->dataGlobal->TimeStepZoneSec = 60.0; state->dataGlobal->HourOfDay = 1; - state->dataGlobal->NumOfTimeStepInHour = 1; + state->dataGlobal->TimeStepsInHour = 1; state->dataGlobal->BeginSimFlag = true; state->dataGlobal->BeginEnvrnFlag = true; state->dataEnvrn->OutBaroPress = 101325.0; diff --git a/tst/EnergyPlus/unit/WindowManagerExteriorThermal.unit.cc b/tst/EnergyPlus/unit/WindowManagerExteriorThermal.unit.cc index 04b4ec8b74f..7174f99a858 100644 --- a/tst/EnergyPlus/unit/WindowManagerExteriorThermal.unit.cc +++ b/tst/EnergyPlus/unit/WindowManagerExteriorThermal.unit.cc @@ -674,15 +674,14 @@ TEST_F(EnergyPlusFixture, test_GetWindowAssemblyNfrcForReport_withIDF) }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); - SimulationManager::GetProjectData(*state); bool FoundError = false; HeatBalanceManager::GetProjectControlData(*state, FoundError); // read project control data EXPECT_FALSE(FoundError); // expect no errors HeatBalanceManager::SetPreConstructionInputParameters(*state); - ScheduleManager::ProcessScheduleInput(*state); // read schedules Material::GetMaterialData(*state, FoundError); EXPECT_FALSE(FoundError); @@ -701,8 +700,8 @@ TEST_F(EnergyPlusFixture, test_GetWindowAssemblyNfrcForReport_withIDF) state->dataSurfaceGeometry->CosZoneRelNorth.allocate(1); state->dataSurfaceGeometry->SinZoneRelNorth.allocate(1); - state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); - state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRadians); + state->dataSurfaceGeometry->CosZoneRelNorth(1) = std::cos(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); + state->dataSurfaceGeometry->SinZoneRelNorth(1) = std::sin(-state->dataHeatBal->Zone(1).RelNorth * Constant::DegToRad); state->dataSurfaceGeometry->CosBldgRelNorth = 1.0; state->dataSurfaceGeometry->SinBldgRelNorth = 0.0; diff --git a/tst/EnergyPlus/unit/ZoneContaminantPredictorCorrector.unit.cc b/tst/EnergyPlus/unit/ZoneContaminantPredictorCorrector.unit.cc index ecb8a34cd0d..da0b5c1d32f 100644 --- a/tst/EnergyPlus/unit/ZoneContaminantPredictorCorrector.unit.cc +++ b/tst/EnergyPlus/unit/ZoneContaminantPredictorCorrector.unit.cc @@ -94,7 +94,8 @@ using namespace EnergyPlus::ZoneContaminantPredictorCorrector; TEST_F(EnergyPlusFixture, ZoneContaminantPredictorCorrector_AddMDotOATest) { - + state->init_state(*state); + state->dataHVACGlobal->ShortenTimeStepSys = false; state->dataHVACGlobal->UseZoneTimeStepHistory = false; @@ -163,7 +164,7 @@ TEST_F(EnergyPlusFixture, ZoneContaminantPredictorCorrector_AddMDotOATest) Real64 PriorTimeStep; state->dataHVACGlobal->TimeStepSys = 15.0 / 60.0; // System timestep in hours - state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; PriorTimeStep = state->dataHVACGlobal->TimeStepSys; state->dataZoneEquip->ZoneEquipConfig.allocate(1); @@ -198,9 +199,6 @@ TEST_F(EnergyPlusFixture, ZoneContaminantPredictorCorrector_AddMDotOATest) state->dataZoneTempPredictorCorrector->zoneHeatBalance.allocate(1); state->dataZoneTempPredictorCorrector->zoneHeatBalance(1).MDotOA = 0.001; - state->dataScheduleMgr->Schedule.allocate(1); - - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; state->dataHeatBal->ZoneAirSolutionAlgo = DataHeatBalance::SolutionAlgo::EulerMethod; @@ -224,7 +222,7 @@ TEST_F(EnergyPlusFixture, ZoneContaminantPredictorCorrector_AddMDotOATest) state->dataContaminantBalance->ContaminantControlledZone.allocate(1); - state->dataContaminantBalance->ContaminantControlledZone(1).AvaiSchedPtr = 1; + state->dataContaminantBalance->ContaminantControlledZone(1).availSched = Sched::GetScheduleAlwaysOn(*state); state->dataContaminantBalance->ContaminantControlledZone(1).ActualZoneNum = 1; state->dataContaminantBalance->ContaminantControlledZone(1).NumOfZones = 1; state->dataContaminantBalance->ZoneGCSetPoint(1) = 0.0025; @@ -240,6 +238,7 @@ TEST_F(EnergyPlusFixture, ZoneContaminantPredictorCorrector_AddMDotOATest) TEST_F(EnergyPlusFixture, ZoneContaminantPredictorCorrector_CorrectZoneContaminantsTest) { + state->init_state(*state); state->dataHVACGlobal->ShortenTimeStepSys = false; state->dataHVACGlobal->UseZoneTimeStepHistory = false; @@ -298,7 +297,7 @@ TEST_F(EnergyPlusFixture, ZoneContaminantPredictorCorrector_CorrectZoneContamina state->dataContaminantBalance->ZoneGC1(1) = state->dataContaminantBalance->OutdoorGC; state->dataHVACGlobal->TimeStepSys = 15.0 / 60.0; // System timestep in hours - state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; state->dataZoneEquip->ZoneEquipConfig.allocate(1); state->dataZoneEquip->ZoneEquipConfig(1).ZoneName = "Zone 1"; @@ -356,6 +355,7 @@ TEST_F(EnergyPlusFixture, ZoneContaminantPredictorCorrector_CorrectZoneContamina TEST_F(EnergyPlusFixture, ZoneContaminantPredictorCorrector_MultiZoneCO2ControlTest) { + state->init_state(*state); state->dataHVACGlobal->ShortenTimeStepSys = false; state->dataHVACGlobal->UseZoneTimeStepHistory = false; @@ -427,7 +427,7 @@ TEST_F(EnergyPlusFixture, ZoneContaminantPredictorCorrector_MultiZoneCO2ControlT Real64 PriorTimeStep; state->dataHVACGlobal->TimeStepSys = 15.0 / 60.0; // System timestep in hours - state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; PriorTimeStep = state->dataHVACGlobal->TimeStepSys; state->dataZoneEquip->ZoneEquipConfig.allocate(3); @@ -497,9 +497,6 @@ TEST_F(EnergyPlusFixture, ZoneContaminantPredictorCorrector_MultiZoneCO2ControlT state->dataZoneTempPredictorCorrector->zoneHeatBalance(1).MDotOA = 0.001; state->dataZoneTempPredictorCorrector->zoneHeatBalance(2).MDotOA = 0.001; state->dataZoneTempPredictorCorrector->zoneHeatBalance(3).MDotOA = 0.001; - state->dataScheduleMgr->Schedule.allocate(1); - - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; state->dataHeatBal->ZoneAirSolutionAlgo = DataHeatBalance::SolutionAlgo::EulerMethod; @@ -534,13 +531,13 @@ TEST_F(EnergyPlusFixture, ZoneContaminantPredictorCorrector_MultiZoneCO2ControlT state->dataContaminantBalance->ContaminantControlledZone.allocate(3); - state->dataContaminantBalance->ContaminantControlledZone(1).AvaiSchedPtr = 1; + state->dataContaminantBalance->ContaminantControlledZone(1).availSched = Sched::GetScheduleAlwaysOn(*state); state->dataContaminantBalance->ContaminantControlledZone(1).ActualZoneNum = 1; state->dataContaminantBalance->ContaminantControlledZone(1).NumOfZones = 1; - state->dataContaminantBalance->ContaminantControlledZone(2).AvaiSchedPtr = 1; + state->dataContaminantBalance->ContaminantControlledZone(2).availSched = Sched::GetScheduleAlwaysOn(*state); state->dataContaminantBalance->ContaminantControlledZone(2).ActualZoneNum = 2; state->dataContaminantBalance->ContaminantControlledZone(2).NumOfZones = 1; - state->dataContaminantBalance->ContaminantControlledZone(3).AvaiSchedPtr = 1; + state->dataContaminantBalance->ContaminantControlledZone(3).availSched = Sched::GetScheduleAlwaysOn(*state); state->dataContaminantBalance->ContaminantControlledZone(3).ActualZoneNum = 3; state->dataContaminantBalance->ContaminantControlledZone(3).NumOfZones = 1; @@ -552,6 +549,7 @@ TEST_F(EnergyPlusFixture, ZoneContaminantPredictorCorrector_MultiZoneCO2ControlT TEST_F(EnergyPlusFixture, ZoneContaminantPredictorCorrector_MultiZoneGCControlTest) { + state->init_state(*state); state->dataHVACGlobal->ShortenTimeStepSys = false; state->dataHVACGlobal->UseZoneTimeStepHistory = false; @@ -613,7 +611,7 @@ TEST_F(EnergyPlusFixture, ZoneContaminantPredictorCorrector_MultiZoneGCControlTe Real64 PriorTimeStep; state->dataHVACGlobal->TimeStepSys = 15.0 / 60.0; // System timestep in hours - state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; PriorTimeStep = state->dataHVACGlobal->TimeStepSys; state->dataZoneEquip->ZoneEquipConfig.allocate(3); @@ -683,9 +681,6 @@ TEST_F(EnergyPlusFixture, ZoneContaminantPredictorCorrector_MultiZoneGCControlTe state->dataZoneTempPredictorCorrector->zoneHeatBalance(1).MDotOA = 0.001; state->dataZoneTempPredictorCorrector->zoneHeatBalance(2).MDotOA = 0.001; state->dataZoneTempPredictorCorrector->zoneHeatBalance(3).MDotOA = 0.001; - state->dataScheduleMgr->Schedule.allocate(1); - - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; state->dataHeatBal->ZoneAirSolutionAlgo = DataHeatBalance::SolutionAlgo::EulerMethod; @@ -722,13 +717,13 @@ TEST_F(EnergyPlusFixture, ZoneContaminantPredictorCorrector_MultiZoneGCControlTe state->dataContaminantBalance->ContaminantControlledZone.allocate(3); - state->dataContaminantBalance->ContaminantControlledZone(1).AvaiSchedPtr = 1; + state->dataContaminantBalance->ContaminantControlledZone(1).availSched = Sched::GetScheduleAlwaysOn(*state); state->dataContaminantBalance->ContaminantControlledZone(1).ActualZoneNum = 1; state->dataContaminantBalance->ContaminantControlledZone(1).NumOfZones = 1; - state->dataContaminantBalance->ContaminantControlledZone(2).AvaiSchedPtr = 1; + state->dataContaminantBalance->ContaminantControlledZone(2).availSched = Sched::GetScheduleAlwaysOn(*state); state->dataContaminantBalance->ContaminantControlledZone(2).ActualZoneNum = 2; state->dataContaminantBalance->ContaminantControlledZone(2).NumOfZones = 1; - state->dataContaminantBalance->ContaminantControlledZone(3).AvaiSchedPtr = 1; + state->dataContaminantBalance->ContaminantControlledZone(3).availSched = Sched::GetScheduleAlwaysOn(*state); state->dataContaminantBalance->ContaminantControlledZone(3).ActualZoneNum = 3; state->dataContaminantBalance->ContaminantControlledZone(3).NumOfZones = 1; diff --git a/tst/EnergyPlus/unit/ZoneEquipmentManager.unit.cc b/tst/EnergyPlus/unit/ZoneEquipmentManager.unit.cc index 86ba25331bb..edc21bebcf7 100644 --- a/tst/EnergyPlus/unit/ZoneEquipmentManager.unit.cc +++ b/tst/EnergyPlus/unit/ZoneEquipmentManager.unit.cc @@ -93,7 +93,6 @@ using namespace EnergyPlus::HVACManager; TEST_F(EnergyPlusFixture, ZoneEquipmentManager_CalcZoneMassBalanceTest) { - std::string const idf_objects = delimited_string({ "Zone,", " Space; !- Name", @@ -135,6 +134,8 @@ TEST_F(EnergyPlusFixture, ZoneEquipmentManager_CalcZoneMassBalanceTest) ASSERT_TRUE(process_idf(idf_objects)); EXPECT_FALSE(has_err_output()); + state->init_state(*state); + bool ErrorsFound = false; GetZoneData(*state, ErrorsFound); AllocateHeatBalArrays(*state); @@ -179,7 +180,6 @@ TEST_F(EnergyPlusFixture, ZoneEquipmentManager_CalcZoneMassBalanceTest) TEST_F(EnergyPlusFixture, ZoneEquipmentManager_MultiCrossMixingTest) { - std::string const idf_objects = delimited_string({ " Zone,", " SPACE1-1, !- Name", @@ -389,8 +389,8 @@ TEST_F(EnergyPlusFixture, ZoneEquipmentManager_MultiCrossMixingTest) ASSERT_TRUE(process_idf(idf_objects)); EXPECT_FALSE(has_err_output()); + state->init_state(*state); bool ErrorsFound = false; - ScheduleManager::ProcessScheduleInput(*state); GetZoneData(*state, ErrorsFound); state->dataHeatBalFanSys->ZoneReOrder.allocate(state->dataGlobal->NumOfZones); @@ -412,12 +412,12 @@ TEST_F(EnergyPlusFixture, ZoneEquipmentManager_MultiCrossMixingTest) state->dataZoneTempPredictorCorrector->zoneHeatBalance(5).airHumRat = 0.001; state->dataHeatBal->AirFlowFlag = true; - state->dataScheduleMgr->Schedule(ScheduleManager::GetScheduleIndex(*state, "MIXINGAVAILSCHED")).CurrentValue = 1.0; - state->dataScheduleMgr->Schedule(ScheduleManager::GetScheduleIndex(*state, "MININDOORTEMP")).CurrentValue = 18.0; - state->dataScheduleMgr->Schedule(ScheduleManager::GetScheduleIndex(*state, "MAXINDOORTEMP")).CurrentValue = 100.0; - state->dataScheduleMgr->Schedule(ScheduleManager::GetScheduleIndex(*state, "DELTATEMP")).CurrentValue = 2.0; - state->dataScheduleMgr->Schedule(ScheduleManager::GetScheduleIndex(*state, "MINOUTDOORTEMP")).CurrentValue = -100.0; - state->dataScheduleMgr->Schedule(ScheduleManager::GetScheduleIndex(*state, "MAXOUTDOORTEMP")).CurrentValue = 100.0; + Sched::GetSchedule(*state, "MIXINGAVAILSCHED")->currentVal = 1.0; + Sched::GetSchedule(*state, "MININDOORTEMP")->currentVal = 18.0; + Sched::GetSchedule(*state, "MAXINDOORTEMP")->currentVal = 100.0; + Sched::GetSchedule(*state, "DELTATEMP")->currentVal = 2.0; + Sched::GetSchedule(*state, "MINOUTDOORTEMP")->currentVal = -100.0; + Sched::GetSchedule(*state, "MAXOUTDOORTEMP")->currentVal = 100.0; state->dataEnvrn->OutBaroPress = 101325.0; InitSimpleMixingConvectiveHeatGains(*state); @@ -444,7 +444,6 @@ TEST_F(EnergyPlusFixture, ZoneEquipmentManager_MultiCrossMixingTest) TEST_F(EnergyPlusFixture, ZoneEquipmentManager_CalcZoneMassBalanceTest2) { - std::string const idf_objects = delimited_string({ "Zone,", " Space; !- Name", @@ -498,6 +497,7 @@ TEST_F(EnergyPlusFixture, ZoneEquipmentManager_CalcZoneMassBalanceTest2) ASSERT_TRUE(process_idf(idf_objects)); EXPECT_FALSE(has_err_output()); + state->init_state(*state); bool ErrorsFound = false; GetZoneData(*state, ErrorsFound); AllocateHeatBalArrays(*state); @@ -583,7 +583,6 @@ TEST_F(EnergyPlusFixture, ZoneEquipmentManager_CalcZoneMassBalanceTest2) TEST_F(EnergyPlusFixture, ZoneEquipmentManager_CalcZoneMassBalanceTest3) { - std::string const idf_objects = delimited_string({ "Zone,", " Space; !- Name", @@ -632,6 +631,7 @@ TEST_F(EnergyPlusFixture, ZoneEquipmentManager_CalcZoneMassBalanceTest3) ASSERT_TRUE(process_idf(idf_objects)); EXPECT_FALSE(has_err_output()); + state->init_state(*state); bool ErrorsFound = false; GetZoneData(*state, ErrorsFound); AllocateHeatBalArrays(*state); @@ -680,7 +680,6 @@ TEST_F(EnergyPlusFixture, ZoneEquipmentManager_CalcZoneMassBalanceTest3) TEST_F(EnergyPlusFixture, ZoneEquipmentManager_CalcZoneMassBalanceTest4) { - std::string const idf_objects = delimited_string({ "Zone,", " Space; !- Name", @@ -732,6 +731,7 @@ TEST_F(EnergyPlusFixture, ZoneEquipmentManager_CalcZoneMassBalanceTest4) ASSERT_TRUE(process_idf(idf_objects)); EXPECT_FALSE(has_err_output()); + state->init_state(*state); bool ErrorsFound = false; GetZoneData(*state, ErrorsFound); AllocateHeatBalArrays(*state); @@ -841,7 +841,6 @@ TEST_F(EnergyPlusFixture, ZoneEquipmentManager_CalcZoneMassBalanceTest4) TEST_F(EnergyPlusFixture, ZoneEquipmentManager_DistributeSequentialLoad) { - std::string const idf_objects = delimited_string({ "Zone,", " Space; !- Name", @@ -925,6 +924,7 @@ TEST_F(EnergyPlusFixture, ZoneEquipmentManager_DistributeSequentialLoad) ASSERT_TRUE(process_idf(idf_objects)); EXPECT_FALSE(has_err_output()); + state->init_state(*state); bool ErrorsFound = false; GetZoneData(*state, ErrorsFound); AllocateHeatBalArrays(*state); @@ -1016,7 +1016,6 @@ TEST_F(EnergyPlusFixture, ZoneEquipmentManager_DistributeSequentialLoad) TEST_F(EnergyPlusFixture, ZoneEquipmentManager_DistributeUniformLoad) { - std::string const idf_objects = delimited_string({ "Zone,", " Space; !- Name", @@ -1100,6 +1099,7 @@ TEST_F(EnergyPlusFixture, ZoneEquipmentManager_DistributeUniformLoad) ASSERT_TRUE(process_idf(idf_objects)); EXPECT_FALSE(has_err_output()); + state->init_state(*state); bool ErrorsFound = false; GetZoneData(*state, ErrorsFound); AllocateHeatBalArrays(*state); @@ -1202,7 +1202,6 @@ TEST_F(EnergyPlusFixture, ZoneEquipmentManager_DistributeUniformLoad) TEST_F(EnergyPlusFixture, ZoneEquipmentManager_DistributeUniformPLR) { - std::string const idf_objects = delimited_string({ "Zone,", " Space; !- Name", @@ -1286,6 +1285,7 @@ TEST_F(EnergyPlusFixture, ZoneEquipmentManager_DistributeUniformPLR) ASSERT_TRUE(process_idf(idf_objects)); EXPECT_FALSE(has_err_output()); + state->init_state(*state); bool ErrorsFound = false; GetZoneData(*state, ErrorsFound); AllocateHeatBalArrays(*state); @@ -1425,7 +1425,6 @@ TEST_F(EnergyPlusFixture, ZoneEquipmentManager_DistributeUniformPLR) TEST_F(EnergyPlusFixture, ZoneEquipmentManager_DistributeSequentialUniformPLR) { - std::string const idf_objects = delimited_string({ "Zone,", " Space; !- Name", @@ -1509,6 +1508,7 @@ TEST_F(EnergyPlusFixture, ZoneEquipmentManager_DistributeSequentialUniformPLR) ASSERT_TRUE(process_idf(idf_objects)); EXPECT_FALSE(has_err_output()); + state->init_state(*state); bool ErrorsFound = false; GetZoneData(*state, ErrorsFound); AllocateHeatBalArrays(*state); @@ -1740,7 +1740,6 @@ TEST_F(EnergyPlusFixture, ZoneEquipmentManager_DistributeSequentialUniformPLR) TEST_F(EnergyPlusFixture, ZoneEquipmentManager_DistributeSequentialLoad_MixedEquip) { - std::string const idf_objects = delimited_string({ "Zone,", " Space; !- Name", @@ -1835,6 +1834,7 @@ TEST_F(EnergyPlusFixture, ZoneEquipmentManager_DistributeSequentialLoad_MixedEqu ASSERT_TRUE(process_idf(idf_objects)); EXPECT_FALSE(has_err_output()); + state->init_state(*state); bool ErrorsFound = false; GetZoneData(*state, ErrorsFound); AllocateHeatBalArrays(*state); @@ -1846,7 +1846,7 @@ TEST_F(EnergyPlusFixture, ZoneEquipmentManager_DistributeSequentialLoad_MixedEqu state->dataZoneEnergyDemand->CurDeadBandOrSetback(1) = false; state->dataZoneEnergyDemand->DeadBandOrSetback(1) = false; state->dataHeatBalFanSys->TempControlType.allocate(1); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::DualSetPointWithDeadBand; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::DualHeatCool; state->dataZoneEnergyDemand->ZoneSysEnergyDemand.allocate(1); state->dataZoneEnergyDemand->ZoneSysMoistureDemand.allocate(1); @@ -1939,7 +1939,6 @@ TEST_F(EnergyPlusFixture, ZoneEquipmentManager_DistributeSequentialLoad_MixedEqu TEST_F(EnergyPlusFixture, ZoneEquipmentManager_DistributeSequentialLoad_MixedEquip_WithFractions) { - std::string const idf_objects = delimited_string({ "Zone,", " Space; !- Name", @@ -2061,6 +2060,7 @@ TEST_F(EnergyPlusFixture, ZoneEquipmentManager_DistributeSequentialLoad_MixedEqu ASSERT_TRUE(process_idf(idf_objects)); EXPECT_FALSE(has_err_output()); + state->init_state(*state); bool ErrorsFound = false; GetZoneData(*state, ErrorsFound); AllocateHeatBalArrays(*state); @@ -2072,7 +2072,7 @@ TEST_F(EnergyPlusFixture, ZoneEquipmentManager_DistributeSequentialLoad_MixedEqu state->dataZoneEnergyDemand->CurDeadBandOrSetback(1) = false; state->dataZoneEnergyDemand->DeadBandOrSetback(1) = false; state->dataHeatBalFanSys->TempControlType.allocate(1); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::DualSetPointWithDeadBand; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::DualHeatCool; state->dataZoneEnergyDemand->ZoneSysEnergyDemand.allocate(1); state->dataZoneEnergyDemand->ZoneSysMoistureDemand.allocate(1); @@ -2087,11 +2087,11 @@ TEST_F(EnergyPlusFixture, ZoneEquipmentManager_DistributeSequentialLoad_MixedEqu auto &energy = state->dataZoneEnergyDemand->ZoneSysEnergyDemand(ZoneNum); auto &moisture = state->dataZoneEnergyDemand->ZoneSysMoistureDemand(ZoneNum); state->dataZoneEquipmentManager->PrioritySimOrder.allocate(NumEquip); - - state->dataScheduleMgr->Schedule(ScheduleManager::GetScheduleIndex(*state, "AIR TERMINAL 1 ADU COOLING FRACTION")).CurrentValue = 0.3; - state->dataScheduleMgr->Schedule(ScheduleManager::GetScheduleIndex(*state, "AIR TERMINAL 1 ADU HEATING FRACTION")).CurrentValue = 0.4; - state->dataScheduleMgr->Schedule(ScheduleManager::GetScheduleIndex(*state, "IDEAL SYSTEM A COOLING FRACTION")).CurrentValue = 0.5; - state->dataScheduleMgr->Schedule(ScheduleManager::GetScheduleIndex(*state, "IDEAL SYSTEM A HEATING FRACTION")).CurrentValue = 0.6; + + Sched::GetSchedule(*state, "AIR TERMINAL 1 ADU COOLING FRACTION")->currentVal = 0.3; + Sched::GetSchedule(*state, "AIR TERMINAL 1 ADU HEATING FRACTION")->currentVal = 0.4; + Sched::GetSchedule(*state, "IDEAL SYSTEM A COOLING FRACTION")->currentVal = 0.5; + Sched::GetSchedule(*state, "IDEAL SYSTEM A HEATING FRACTION")->currentVal = 0.6; // Sequential Test 1 - Heating, FirstHVACIteration = true energy.TotalOutputRequired = 1000.0; @@ -2161,6 +2161,7 @@ TEST_F(EnergyPlusFixture, ZoneEquipmentManager_DistributeSequentialLoad_MixedEqu TEST_F(EnergyPlusFixture, ZoneEquipmentManager_RezeroZoneSizingArrays) { + state->init_state(*state); state->dataEnvrn->TotDesDays = 12; state->dataEnvrn->TotRunDesPersDays = 3; @@ -2913,7 +2914,6 @@ TEST_F(EnergyPlusFixture, ZoneEquipmentManager_RezeroZoneSizingArrays) TEST_F(EnergyPlusFixture, ZoneEquipmentManager_ZoneMassBalance_wAdjustInfiltrationFlow) { - std::string const idf_objects = delimited_string({ "ZoneAirMassFlowConservation,", @@ -2996,7 +2996,7 @@ TEST_F(EnergyPlusFixture, ZoneEquipmentManager_ZoneMassBalance_wAdjustInfiltrati "ZoneMixing,", " RZone ZoneMixing, !- Name", " RZone, !- Zone Name", - " AlwaysOn, !- Schedule Name", + " Constant-1.0, !- Schedule Name", " Flow/Zone, !- Design Flow Rate Calculation Method", " 0.5, !- Design Flow Rate{m3/s}", " , !- Flow Rate per Zone Floor Area{m3/s-m2}", @@ -3008,7 +3008,7 @@ TEST_F(EnergyPlusFixture, ZoneEquipmentManager_ZoneMassBalance_wAdjustInfiltrati "ZoneInfiltration:DesignFlowRate,", " SZone Infiltration, !- Name", " SZone, !- Zone or ZoneList Name", - " AlwaysOn, !- Schedule Name", + " Constant-1.0, !- Schedule Name", " flow/zone, !- Design Flow Rate Calculation Method", " 0.05, !- Design Flow Rate{ m3 / s }", " , !- Flow per Zone Floor Area{ m3 / s - m2 }", @@ -3022,7 +3022,7 @@ TEST_F(EnergyPlusFixture, ZoneEquipmentManager_ZoneMassBalance_wAdjustInfiltrati "ZoneInfiltration:DesignFlowRate,", " RZone Infiltration, !- Name", " RZone, !- Zone or ZoneList Name", - " AlwaysOn, !- Schedule Name", + " Constant-1.0, !- Schedule Name", " flow/zone, !- Design Flow Rate Calculation Method", " 0.05, !- Design Flow Rate{ m3 / s }", " , !- Flow per Zone Floor Area{ m3 / s - m2 }", @@ -3032,21 +3032,15 @@ TEST_F(EnergyPlusFixture, ZoneEquipmentManager_ZoneMassBalance_wAdjustInfiltrati " 0, !- Temperature Term Coefficient", " 0, !- Velocity Term Coefficient", " 0; !- Velocity Squared Term Coefficient", - - "Schedule:Constant,", - "AlwaysOn,", - "Fraction,", - "1.0;", - }); ASSERT_TRUE(process_idf(idf_objects)); EXPECT_FALSE(has_err_output()); + state->init_state(*state); int ZoneNum; int NodeNum; bool ErrorsFound = false; - ScheduleManager::ProcessScheduleInput(*state); GetZoneData(*state, ErrorsFound); AllocateHeatBalArrays(*state); GetZoneEquipmentData(*state); @@ -3060,7 +3054,6 @@ TEST_F(EnergyPlusFixture, ZoneEquipmentManager_ZoneMassBalance_wAdjustInfiltrati EXPECT_ENUM_EQ(state->dataHeatBal->ZoneAirMassFlow.InfiltrationForZones, DataHeatBalance::InfiltrationZoneType::AllZones); GetSimpleAirModelInputs(*state, ErrorsFound); SetZoneMassConservationFlag(*state); - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; state->dataHeatBal->AirFlowFlag = 1; // set zone conditions state->dataEnvrn->StdRhoAir = 1.0; @@ -3158,7 +3151,6 @@ TEST_F(EnergyPlusFixture, ZoneEquipmentManager_ZoneMassBalance_wAdjustInfiltrati TEST_F(EnergyPlusFixture, ZoneAirMassFlowBalance_wAdjustReturnOnly) { - std::string const idf_objects = delimited_string({ "ZoneAirMassFlowConservation,", @@ -3241,7 +3233,7 @@ TEST_F(EnergyPlusFixture, ZoneAirMassFlowBalance_wAdjustReturnOnly) "ZoneMixing,", " RZone ZoneMixing, !- Name", " RZone, !- Zone Name", - " AlwaysOn, !- Schedule Name", + " Constant-1.0, !- Schedule Name", " Flow/Zone, !- Design Flow Rate Calculation Method", " 0.5, !- Design Flow Rate{m3/s}", " , !- Flow Rate per Zone Floor Area{m3/s-m2}", @@ -3253,7 +3245,7 @@ TEST_F(EnergyPlusFixture, ZoneAirMassFlowBalance_wAdjustReturnOnly) "ZoneInfiltration:DesignFlowRate,", " SZone Infiltration, !- Name", " SZone, !- Zone or ZoneList Name", - " AlwaysOn, !- Schedule Name", + " Constant-1.0, !- Schedule Name", " flow/zone, !- Design Flow Rate Calculation Method", " 0.05, !- Design Flow Rate{ m3 / s }", " , !- Flow per Zone Floor Area{ m3 / s - m2 }", @@ -3267,7 +3259,7 @@ TEST_F(EnergyPlusFixture, ZoneAirMassFlowBalance_wAdjustReturnOnly) "ZoneInfiltration:DesignFlowRate,", " RZone Infiltration, !- Name", " RZone, !- Zone or ZoneList Name", - " AlwaysOn, !- Schedule Name", + " Constant-1.0, !- Schedule Name", " flow/zone, !- Design Flow Rate Calculation Method", " 0.05, !- Design Flow Rate{ m3 / s }", " , !- Flow per Zone Floor Area{ m3 / s - m2 }", @@ -3277,20 +3269,14 @@ TEST_F(EnergyPlusFixture, ZoneAirMassFlowBalance_wAdjustReturnOnly) " 0, !- Temperature Term Coefficient", " 0, !- Velocity Term Coefficient", " 0; !- Velocity Squared Term Coefficient", - - "Schedule:Constant,", - "AlwaysOn,", - "Fraction,", - "1.0;", - }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); int ZoneNum; int NodeNum; bool ErrorsFound = false; - ScheduleManager::ProcessScheduleInput(*state); GetZoneData(*state, ErrorsFound); AllocateHeatBalArrays(*state); GetZoneEquipmentData(*state); @@ -3304,7 +3290,6 @@ TEST_F(EnergyPlusFixture, ZoneAirMassFlowBalance_wAdjustReturnOnly) EXPECT_ENUM_EQ(state->dataHeatBal->ZoneAirMassFlow.InfiltrationForZones, DataHeatBalance::InfiltrationZoneType::AllZones); GetSimpleAirModelInputs(*state, ErrorsFound); SetZoneMassConservationFlag(*state); - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; state->dataHeatBal->AirFlowFlag = 1; // set zone conditions state->dataEnvrn->StdRhoAir = 1.2; @@ -3419,7 +3404,6 @@ TEST_F(EnergyPlusFixture, ZoneAirMassFlowBalance_wAdjustReturnOnly) TEST_F(EnergyPlusFixture, ZoneAirMassFlowBalance_wAdjustReturnThenMixing) { - std::string const idf_objects = delimited_string({ "ZoneAirMassFlowConservation,", @@ -3502,7 +3486,7 @@ TEST_F(EnergyPlusFixture, ZoneAirMassFlowBalance_wAdjustReturnThenMixing) "ZoneMixing,", " RZone ZoneMixing, !- Name", " RZone, !- Zone Name", - " AlwaysOn, !- Schedule Name", + " Constant-1.0, !- Schedule Name", " Flow/Zone, !- Design Flow Rate Calculation Method", " 0.5, !- Design Flow Rate{m3/s}", " , !- Flow Rate per Zone Floor Area{m3/s-m2}", @@ -3514,7 +3498,7 @@ TEST_F(EnergyPlusFixture, ZoneAirMassFlowBalance_wAdjustReturnThenMixing) "ZoneInfiltration:DesignFlowRate,", " SZone Infiltration, !- Name", " SZone, !- Zone or ZoneList Name", - " AlwaysOn, !- Schedule Name", + " Constant-1.0, !- Schedule Name", " flow/zone, !- Design Flow Rate Calculation Method", " 0.05, !- Design Flow Rate{ m3 / s }", " , !- Flow per Zone Floor Area{ m3 / s - m2 }", @@ -3528,7 +3512,7 @@ TEST_F(EnergyPlusFixture, ZoneAirMassFlowBalance_wAdjustReturnThenMixing) "ZoneInfiltration:DesignFlowRate,", " RZone Infiltration, !- Name", " RZone, !- Zone or ZoneList Name", - " AlwaysOn, !- Schedule Name", + " Constant-1.0, !- Schedule Name", " flow/zone, !- Design Flow Rate Calculation Method", " 0.05, !- Design Flow Rate{ m3 / s }", " , !- Flow per Zone Floor Area{ m3 / s - m2 }", @@ -3538,20 +3522,14 @@ TEST_F(EnergyPlusFixture, ZoneAirMassFlowBalance_wAdjustReturnThenMixing) " 0, !- Temperature Term Coefficient", " 0, !- Velocity Term Coefficient", " 0; !- Velocity Squared Term Coefficient", - - "Schedule:Constant,", - "AlwaysOn,", - "Fraction,", - "1.0;", - }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); int ZoneNum; int NodeNum; bool ErrorsFound = false; - ScheduleManager::ProcessScheduleInput(*state); GetZoneData(*state, ErrorsFound); AllocateHeatBalArrays(*state); GetZoneEquipmentData(*state); @@ -3565,7 +3543,6 @@ TEST_F(EnergyPlusFixture, ZoneAirMassFlowBalance_wAdjustReturnThenMixing) EXPECT_ENUM_EQ(state->dataHeatBal->ZoneAirMassFlow.InfiltrationForZones, DataHeatBalance::InfiltrationZoneType::AllZones); GetSimpleAirModelInputs(*state, ErrorsFound); SetZoneMassConservationFlag(*state); - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; state->dataHeatBal->AirFlowFlag = 1; // set zone conditions state->dataEnvrn->StdRhoAir = 1.2; @@ -3692,7 +3669,6 @@ TEST_F(EnergyPlusFixture, ZoneAirMassFlowBalance_wAdjustReturnThenMixing) TEST_F(EnergyPlusFixture, ZoneAirMassFlowBalance_wAdjustMixingThenReturn) { - std::string const idf_objects = delimited_string({ "ZoneAirMassFlowConservation,", @@ -3775,7 +3751,7 @@ TEST_F(EnergyPlusFixture, ZoneAirMassFlowBalance_wAdjustMixingThenReturn) "ZoneMixing,", " RZone ZoneMixing, !- Name", " RZone, !- Zone Name", - " AlwaysOn, !- Schedule Name", + " Constant-1.0, !- Schedule Name", " Flow/Zone, !- Design Flow Rate Calculation Method", " 0.5, !- Design Flow Rate{m3/s}", " , !- Flow Rate per Zone Floor Area{m3/s-m2}", @@ -3787,7 +3763,7 @@ TEST_F(EnergyPlusFixture, ZoneAirMassFlowBalance_wAdjustMixingThenReturn) "ZoneInfiltration:DesignFlowRate,", " SZone Infiltration, !- Name", " SZone, !- Zone or ZoneList Name", - " AlwaysOn, !- Schedule Name", + " Constant-1.0, !- Schedule Name", " flow/zone, !- Design Flow Rate Calculation Method", " 0.05, !- Design Flow Rate{ m3 / s }", " , !- Flow per Zone Floor Area{ m3 / s - m2 }", @@ -3801,7 +3777,7 @@ TEST_F(EnergyPlusFixture, ZoneAirMassFlowBalance_wAdjustMixingThenReturn) "ZoneInfiltration:DesignFlowRate,", " RZone Infiltration, !- Name", " RZone, !- Zone or ZoneList Name", - " AlwaysOn, !- Schedule Name", + " Constant-1.0, !- Schedule Name", " flow/zone, !- Design Flow Rate Calculation Method", " 0.05, !- Design Flow Rate{ m3 / s }", " , !- Flow per Zone Floor Area{ m3 / s - m2 }", @@ -3811,20 +3787,14 @@ TEST_F(EnergyPlusFixture, ZoneAirMassFlowBalance_wAdjustMixingThenReturn) " 0, !- Temperature Term Coefficient", " 0, !- Velocity Term Coefficient", " 0; !- Velocity Squared Term Coefficient", - - "Schedule:Constant,", - "AlwaysOn,", - "Fraction,", - "1.0;", - }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); int ZoneNum; int NodeNum; bool ErrorsFound = false; - ScheduleManager::ProcessScheduleInput(*state); GetZoneData(*state, ErrorsFound); AllocateHeatBalArrays(*state); GetZoneEquipmentData(*state); @@ -3838,7 +3808,6 @@ TEST_F(EnergyPlusFixture, ZoneAirMassFlowBalance_wAdjustMixingThenReturn) EXPECT_ENUM_EQ(state->dataHeatBal->ZoneAirMassFlow.InfiltrationTreatment, DataHeatBalance::InfiltrationFlow::Adjust); GetSimpleAirModelInputs(*state, ErrorsFound); SetZoneMassConservationFlag(*state); - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; state->dataHeatBal->AirFlowFlag = 1; // set zone conditions state->dataEnvrn->StdRhoAir = 1.2; @@ -3957,7 +3926,6 @@ TEST_F(EnergyPlusFixture, ZoneAirMassFlowBalance_wAdjustMixingThenReturn) TEST_F(EnergyPlusFixture, ZoneAirMassFlowBalance_wSourceAndReceivingZone) { - std::string const idf_objects = delimited_string({ "ZoneAirMassFlowConservation,", @@ -4076,7 +4044,7 @@ TEST_F(EnergyPlusFixture, ZoneAirMassFlowBalance_wSourceAndReceivingZone) "ZoneMixing,", " RSZone ZoneMixing, !- Name", " RSZone, !- Zone Name", - " AlwaysOn, !- Schedule Name", + " Constant-1.0, !- Schedule Name", " Flow/Zone, !- Design Flow Rate Calculation Method", " 0.852323, !- Design Flow Rate{m3/s}", " , !- Flow Rate per Zone Floor Area{m3/s-m2}", @@ -4088,7 +4056,7 @@ TEST_F(EnergyPlusFixture, ZoneAirMassFlowBalance_wSourceAndReceivingZone) "ZoneMixing,", " RZone ZoneMixing, !- Name", " RZone, !- Zone Name", - " AlwaysOn, !- Schedule Name", + " Constant-1.0, !- Schedule Name", " Flow/Zone, !- Design Flow Rate Calculation Method", " 0.852323, !- Design Flow Rate{m3/s}", " , !- Flow Rate per Zone Floor Area{m3/s-m2}", @@ -4100,7 +4068,7 @@ TEST_F(EnergyPlusFixture, ZoneAirMassFlowBalance_wSourceAndReceivingZone) "ZoneInfiltration:DesignFlowRate,", " SZone Infiltration, !- Name", " SZone, !- Zone or ZoneList Name", - " AlwaysOn, !- Schedule Name", + " Constant-1.0, !- Schedule Name", " flow/zone, !- Design Flow Rate Calculation Method", " 0.05, !- Design Flow Rate{ m3 / s }", " , !- Flow per Zone Floor Area{ m3 / s - m2 }", @@ -4114,7 +4082,7 @@ TEST_F(EnergyPlusFixture, ZoneAirMassFlowBalance_wSourceAndReceivingZone) "ZoneInfiltration:DesignFlowRate,", " RZone Infiltration, !- Name", " RZone, !- Zone or ZoneList Name", - " AlwaysOn, !- Schedule Name", + " Constant-1.0, !- Schedule Name", " flow/zone, !- Design Flow Rate Calculation Method", " 0.05, !- Design Flow Rate{ m3 / s }", " , !- Flow per Zone Floor Area{ m3 / s - m2 }", @@ -4124,20 +4092,14 @@ TEST_F(EnergyPlusFixture, ZoneAirMassFlowBalance_wSourceAndReceivingZone) " 0, !- Temperature Term Coefficient", " 0, !- Velocity Term Coefficient", " 0; !- Velocity Squared Term Coefficient", - - "Schedule:Constant,", - "AlwaysOn,", - "Fraction,", - "1.0;", - }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); int ZoneNum; int NodeNum; bool ErrorsFound = false; - ScheduleManager::ProcessScheduleInput(*state); GetZoneData(*state, ErrorsFound); AllocateHeatBalArrays(*state); GetZoneEquipmentData(*state); @@ -4151,7 +4113,6 @@ TEST_F(EnergyPlusFixture, ZoneAirMassFlowBalance_wSourceAndReceivingZone) EXPECT_ENUM_EQ(state->dataHeatBal->ZoneAirMassFlow.InfiltrationForZones, DataHeatBalance::InfiltrationZoneType::AllZones); GetSimpleAirModelInputs(*state, ErrorsFound); SetZoneMassConservationFlag(*state); - state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; state->dataHeatBal->AirFlowFlag = 1; // set zone conditions state->dataEnvrn->StdRhoAir = 1.2; @@ -4226,7 +4187,6 @@ TEST_F(EnergyPlusFixture, ZoneAirMassFlowBalance_wSourceAndReceivingZone) TEST_F(EnergyPlusFixture, ZoneAirMassFlowBalance_ZoneMixingInfiltrationFlowsFlags) { - std::string const idf_objects = delimited_string({ "ZoneAirMassFlowConservation,", @@ -4345,7 +4305,7 @@ TEST_F(EnergyPlusFixture, ZoneAirMassFlowBalance_ZoneMixingInfiltrationFlowsFlag "ZoneMixing,", " RSZone ZoneMixing, !- Name", " RSZone, !- Zone Name", - " AlwaysOn, !- Schedule Name", + " Constant-1.0, !- Schedule Name", " Flow/Zone, !- Design Flow Rate Calculation Method", " 0.852323, !- Design Flow Rate{m3/s}", " , !- Flow Rate per Zone Floor Area{m3/s-m2}", @@ -4357,7 +4317,7 @@ TEST_F(EnergyPlusFixture, ZoneAirMassFlowBalance_ZoneMixingInfiltrationFlowsFlag "ZoneMixing,", " RZone ZoneMixing, !- Name", " RZone, !- Zone Name", - " AlwaysOn, !- Schedule Name", + " Constant-1.0, !- Schedule Name", " Flow/Zone, !- Design Flow Rate Calculation Method", " 0.852323, !- Design Flow Rate{m3/s}", " , !- Flow Rate per Zone Floor Area{m3/s-m2}", @@ -4365,18 +4325,12 @@ TEST_F(EnergyPlusFixture, ZoneAirMassFlowBalance_ZoneMixingInfiltrationFlowsFlag " , !- Air Changes per Hour{1/hr}", " RSZone, !- Source Zone Name", " 0.0; !- Delta Temperature{deltaC}", - - "Schedule:Constant,", - "AlwaysOn,", - "Fraction,", - "1.0;", - }); ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); bool ErrorsFound = false; - ScheduleManager::ProcessScheduleInput(*state); GetZoneData(*state, ErrorsFound); AllocateHeatBalArrays(*state); GetZoneEquipmentData(*state); @@ -4401,6 +4355,7 @@ TEST_F(EnergyPlusFixture, ZoneAirMassFlowBalance_ZoneMixingInfiltrationFlowsFlag TEST_F(EnergyPlusFixture, CalcAirFlowSimple_CO2andGCforRefrigerationDoorsTest) { + state->init_state(*state); state->dataGlobal->NumOfZones = 2; state->dataEnvrn->OutBaroPress = 101400.; @@ -4461,6 +4416,7 @@ TEST_F(EnergyPlusFixture, CalcAirFlowSimple_CO2andGCforRefrigerationDoorsTest) TEST_F(EnergyPlusFixture, CZoeEquipmentManager_CalcZoneLeavingConditions_Test) { + state->init_state(*state); state->dataGlobal->NumOfZones = 1; state->dataHeatBal->Zone.allocate(1); state->dataHeatBal->Zone(1).Name = "LIVING ZONE"; @@ -4536,7 +4492,9 @@ TEST_F(EnergyPlusFixture, CZoeEquipmentManager_CalcZoneLeavingConditions_Test) TEST_F(EnergyPlusFixture, ZoneEquipmentManager_SizeZoneEquipment_NoLoadTest) { - + state->dataGlobal->TimeStepsInHour = 1; + state->init_state(*state); + state->dataLoopNodes->Node.allocate(10); state->dataGlobal->NumOfZones = 1; state->dataSize->ZoneEqSizing.allocate(state->dataGlobal->NumOfZones); @@ -4548,9 +4506,7 @@ TEST_F(EnergyPlusFixture, ZoneEquipmentManager_SizeZoneEquipment_NoLoadTest) state->dataZoneTempPredictorCorrector->zoneHeatBalance.allocate(state->dataGlobal->NumOfZones); state->dataZoneEquip->ZoneEquipConfig.allocate(state->dataGlobal->NumOfZones); state->dataHeatBalFanSys->TempControlType.allocate(state->dataGlobal->NumOfZones); - state->dataHeatBalFanSys->TempZoneThermostatSetPoint.allocate(state->dataGlobal->NumOfZones); - state->dataHeatBalFanSys->ZoneThermostatSetPointLo.allocate(state->dataGlobal->NumOfZones); - state->dataHeatBalFanSys->ZoneThermostatSetPointHi.allocate(state->dataGlobal->NumOfZones); + state->dataHeatBalFanSys->zoneTstatSetpts.allocate(state->dataGlobal->NumOfZones); state->dataZoneEnergyDemand->ZoneSysEnergyDemand.allocate(state->dataGlobal->NumOfZones); state->dataZoneEnergyDemand->ZoneSysMoistureDemand.allocate(state->dataGlobal->NumOfZones); auto &zoneSysMoistureDemand = state->dataZoneEnergyDemand->ZoneSysMoistureDemand(1); @@ -4561,10 +4517,10 @@ TEST_F(EnergyPlusFixture, ZoneEquipmentManager_SizeZoneEquipment_NoLoadTest) state->dataHeatBalFanSys->ZoneMassBalanceFlag.allocate(state->dataGlobal->NumOfZones); state->dataHeatBal->MassConservation.allocate(state->dataGlobal->NumOfZones); HeatBalanceManager::AllocateHeatBalArrays(*state); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::DualSetPointWithDeadBand; - state->dataHeatBalFanSys->TempZoneThermostatSetPoint(1) = 22.; - state->dataHeatBalFanSys->ZoneThermostatSetPointLo(1) = 22.; - state->dataHeatBalFanSys->ZoneThermostatSetPointHi(1) = 24.; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::DualHeatCool; + state->dataHeatBalFanSys->zoneTstatSetpts(1).setpt = 22.; + state->dataHeatBalFanSys->zoneTstatSetpts(1).setptLo = 22.; + state->dataHeatBalFanSys->zoneTstatSetpts(1).setptHi = 24.; state->dataZoneEquip->ZoneEquipConfig(1).IsControlled = true; state->dataSize->CalcZoneSizing(1, 1).ZoneNum = 1; state->dataSize->CurOverallSimDay = 1; @@ -4584,6 +4540,8 @@ TEST_F(EnergyPlusFixture, ZoneEquipmentManager_SizeZoneEquipment_NoLoadTest) state->dataZoneEquip->ZoneEquipConfig(1).InletNode(2) = 2; state->dataZoneEquip->ZoneEquipConfig(1).ExhaustNode(1) = 3; state->dataZoneEquip->ZoneEquipConfig(1).NumReturnNodes = 0; + state->dataZoneEquip->ZoneEquipConfig(1).returnFlowSched = Sched::GetScheduleAlwaysOn(*state); + state->dataEnvrn->StdBaroPress = 101325.; state->dataSize->CalcFinalZoneSizing(1).MinOA = 0.1; state->dataSize->CalcFinalZoneSizing(1).OutTempAtHeatPeak = 28; @@ -4598,7 +4556,6 @@ TEST_F(EnergyPlusFixture, ZoneEquipmentManager_SizeZoneEquipment_NoLoadTest) SizeZoneEquipment(*state); UpdateZoneSizing(*state, Constant::CallIndicator::BeginDay); state->dataGlobal->HourOfDay = 1; - state->dataGlobal->NumOfTimeStepInHour = 1; state->dataGlobal->TimeStep = 1; state->dataSize->NumTimeStepsInAvg = 1; state->dataHVACGlobal->FracTimeStepZone = 1; @@ -4705,6 +4662,8 @@ TEST_F(EnergyPlusFixture, ZoneEquipmentManager_SizeZoneEquipment_NoLoadTest) TEST_F(EnergyPlusFixture, CalcAirFlowSimple_WindAndStackArea) { + state->init_state(*state); + state->dataGlobal->NumOfZones = 1; state->dataHeatBal->Zone.allocate(state->dataGlobal->NumOfZones); @@ -4743,7 +4702,7 @@ TEST_F(EnergyPlusFixture, CalcAirFlowSimple_WindAndStackArea) thisVentilation.OpenEff = Constant::AutoCalculate; thisVentilation.EffAngle = 135; // Effective angle thisVentilation.OpenArea = 1.0; - thisVentilation.OpenAreaSchedPtr = -1; // Always on + thisVentilation.openAreaSched = Sched::GetScheduleAlwaysOn(*state); // Always on thisVentilation.ZonePtr = 1; thisVentilation.DiscCoef = 0.5; @@ -4818,6 +4777,7 @@ TEST_F(EnergyPlusFixture, CalcAirFlowSimple_WindAndStackArea) TEST_F(EnergyPlusFixture, ZoneEquipmentManager_SizeZoneEquipment_DOASLoadTest) { + state->init_state(*state); state->dataLoopNodes->Node.allocate(10); state->dataGlobal->NumOfZones = 1; @@ -4834,9 +4794,7 @@ TEST_F(EnergyPlusFixture, ZoneEquipmentManager_SizeZoneEquipment_DOASLoadTest) state->dataZoneTempPredictorCorrector->zoneHeatBalance.allocate(state->dataGlobal->NumOfZones); state->dataZoneEquip->ZoneEquipConfig.allocate(state->dataGlobal->NumOfZones); state->dataHeatBalFanSys->TempControlType.allocate(state->dataGlobal->NumOfZones); - state->dataHeatBalFanSys->TempZoneThermostatSetPoint.allocate(state->dataGlobal->NumOfZones); - state->dataHeatBalFanSys->ZoneThermostatSetPointLo.allocate(state->dataGlobal->NumOfZones); - state->dataHeatBalFanSys->ZoneThermostatSetPointHi.allocate(state->dataGlobal->NumOfZones); + state->dataHeatBalFanSys->zoneTstatSetpts.allocate(state->dataGlobal->NumOfZones); state->dataZoneEnergyDemand->ZoneSysEnergyDemand.allocate(state->dataGlobal->NumOfZones); state->dataZoneEnergyDemand->ZoneSysMoistureDemand.allocate(state->dataGlobal->NumOfZones); auto &zoneSysMoistureDemand = state->dataZoneEnergyDemand->ZoneSysMoistureDemand(1); @@ -4847,10 +4805,10 @@ TEST_F(EnergyPlusFixture, ZoneEquipmentManager_SizeZoneEquipment_DOASLoadTest) state->dataHeatBalFanSys->ZoneMassBalanceFlag.allocate(state->dataGlobal->NumOfZones); state->dataHeatBal->MassConservation.allocate(state->dataGlobal->NumOfZones); HeatBalanceManager::AllocateHeatBalArrays(*state); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::DualSetPointWithDeadBand; - state->dataHeatBalFanSys->TempZoneThermostatSetPoint(1) = 23.5; - state->dataHeatBalFanSys->ZoneThermostatSetPointLo(1) = 22.5; - state->dataHeatBalFanSys->ZoneThermostatSetPointHi(1) = 23.5; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::DualHeatCool; + state->dataHeatBalFanSys->zoneTstatSetpts(1).setpt = 23.5; + state->dataHeatBalFanSys->zoneTstatSetpts(1).setptLo = 22.5; + state->dataHeatBalFanSys->zoneTstatSetpts(1).setptHi = 23.5; state->dataZoneEquip->ZoneEquipConfig(1).IsControlled = true; state->dataSize->CalcZoneSizing(1, 1).ZoneNum = 1; state->dataSize->CurOverallSimDay = 1; @@ -4870,6 +4828,7 @@ TEST_F(EnergyPlusFixture, ZoneEquipmentManager_SizeZoneEquipment_DOASLoadTest) state->dataZoneEquip->ZoneEquipConfig(1).InletNode(2) = 2; state->dataZoneEquip->ZoneEquipConfig(1).ExhaustNode(1) = 3; state->dataZoneEquip->ZoneEquipConfig(1).NumReturnNodes = 0; + state->dataZoneEquip->ZoneEquipConfig(1).returnFlowSched = Sched::GetScheduleAlwaysOn(*state); state->dataEnvrn->StdBaroPress = 101325.; state->dataEnvrn->StdRhoAir = 1.20; @@ -4887,7 +4846,7 @@ TEST_F(EnergyPlusFixture, ZoneEquipmentManager_SizeZoneEquipment_DOASLoadTest) SizeZoneEquipment(*state); UpdateZoneSizing(*state, Constant::CallIndicator::BeginDay); state->dataGlobal->HourOfDay = 1; - state->dataGlobal->NumOfTimeStepInHour = 1; + state->dataGlobal->TimeStepsInHour = 1; state->dataGlobal->TimeStep = 1; state->dataSize->NumTimeStepsInAvg = 1; state->dataHVACGlobal->FracTimeStepZone = 1; @@ -5020,6 +4979,7 @@ TEST_F(EnergyPlusFixture, ZoneAirLoopEquipmentGetInputTest) )IDF"; ASSERT_TRUE(process_idf(idf_objects)); + state->init_state(*state); int AirDistCompUnitNum = 1; ZoneAirLoopEquipmentManager::GetZoneAirLoopEquipment(*state); @@ -5037,6 +4997,7 @@ TEST_F(EnergyPlusFixture, ZoneAirLoopEquipmentGetInputTest) TEST_F(EnergyPlusFixture, SpaceHVACSplitterTest) { + state->init_state(*state); state->dataZoneEquip->zoneEquipSplitter.resize(1); auto &thisSplitter = state->dataZoneEquip->zoneEquipSplitter[0]; // Assume 3 spaces are served by this splitter @@ -5088,6 +5049,8 @@ TEST_F(EnergyPlusFixture, SpaceHVACSplitterTest) space2Energy.RemainingOutputRequired = -40.0; space3Energy.RemainingOutputRequired = 10.0; + state->dataHeatBalFanSys->zoneTstatSetpts.allocate(1); + int zone1Num = 1; int equipNum = 1; @@ -5138,7 +5101,7 @@ TEST_F(EnergyPlusFixture, SpaceHVACSplitterTest) state->dataZoneEquip->ZoneEquipList.allocate(1); state->dataZoneEquip->ZoneEquipList(1).LoadDistScheme = DataZoneEquipment::LoadDist::Sequential; state->dataHeatBalFanSys->TempControlType.allocate(1); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::DualSetPointWithDeadBand; + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::DualHeatCool; state->dataZoneEnergyDemand->CurDeadBandOrSetback.allocate(1); thisSplitter.distributeOutput(*state, zone1Num, sysOutputProvided, latOutputProvided, nonAirSysOutput, equipNum); @@ -5179,10 +5142,9 @@ TEST_F(EnergyPlusFixture, SpaceHVACSplitterTest) // Case 3 - Max Control thisSplitter.tstatControl = ZoneEquipTstatControl::Maximum; - state->dataHeatBalFanSys->ZoneThermostatSetPointLo.allocate(1); - state->dataHeatBalFanSys->ZoneThermostatSetPointHi.allocate(1); - state->dataHeatBalFanSys->ZoneThermostatSetPointLo(1) = 18.0; - state->dataHeatBalFanSys->ZoneThermostatSetPointHi(1) = 24.0; + state->dataHeatBalFanSys->zoneTstatSetpts.allocate(1); + state->dataHeatBalFanSys->zoneTstatSetpts(1).setptLo = 18.0; + state->dataHeatBalFanSys->zoneTstatSetpts(1).setptHi = 24.0; spaceHB1.T1 = 20.0; // Heating delta = 18-20=-2, cooling delta = 20-24=-4 spaceHB2.T1 = 16.0; // Heating delta = 18-16=2, cooling delta = 16-24=-8 - This zone is the winner, space2, splitSpace3 spaceHB3.T1 = 24.0; // Heating delta = 18-24=-6, cooling delta = 24-24=0 @@ -5200,6 +5162,7 @@ TEST_F(EnergyPlusFixture, SpaceHVACSplitterTest) TEST_F(EnergyPlusFixture, SpaceHVACMixerTest) { + state->init_state(*state); state->dataZoneEquip->zoneEquipMixer.resize(1); auto &thisMixer = state->dataZoneEquip->zoneEquipMixer[0]; // Assume 3 spaces are served by this mixter @@ -5289,7 +5252,6 @@ TEST_F(EnergyPlusFixture, SpaceHVACMixerTest) TEST_F(EnergyPlusFixture, ZoneEquipmentManager_GetZoneEquipmentTest) { - std::string const idf_objects = delimited_string({ "Zone,", " Space; !- Name", @@ -5331,6 +5293,7 @@ TEST_F(EnergyPlusFixture, ZoneEquipmentManager_GetZoneEquipmentTest) ASSERT_TRUE(process_idf(idf_objects)); EXPECT_FALSE(has_err_output()); + state->init_state(*state); bool ErrorsFound = false; // Test 0: The get flag should default to true @@ -5338,7 +5301,7 @@ TEST_F(EnergyPlusFixture, ZoneEquipmentManager_GetZoneEquipmentTest) // Test 1: This should return no errors and the get flag should now be false. // In addition, it should have populated arrays and set the time steps correctly. - state->dataGlobal->NumOfTimeStepInHour = 1; + state->dataGlobal->TimeStepsInHour = 1; GetZoneData(*state, ErrorsFound); AllocateHeatBalArrays(*state); GetZoneEquipment(*state); @@ -5352,13 +5315,15 @@ TEST_F(EnergyPlusFixture, ZoneEquipmentManager_GetZoneEquipmentTest) // The get flag should still be false and the number of time steps in a day should NOT change. // In essence, this tests to make sure that GetZoneEquipment doesn't do anything after the // first time it is called. - state->dataGlobal->NumOfTimeStepInHour = 2; + state->dataGlobal->TimeStepsInHour = 2; GetZoneEquipment(*state); EXPECT_FALSE(state->dataZoneEquipmentManager->GetZoneEquipmentInputFlag); EXPECT_EQ(state->dataZoneEquipmentManager->NumOfTimeStepInDay, 24); } + TEST_F(EnergyPlusFixture, SpaceReturnMixerTest) { + state->init_state(*state); state->dataZoneEquip->zoneReturnMixer.resize(1); auto &thisMixer = state->dataZoneEquip->zoneReturnMixer[0]; // Assume 3 spaces are served by this mixter @@ -5425,6 +5390,10 @@ TEST_F(EnergyPlusFixture, SpaceReturnMixerTest) spaceEquipConfig2.FixedReturnFlow.allocate(1); spaceEquipConfig3.FixedReturnFlow.allocate(1); + spaceEquipConfig1.returnFlowSched = Sched::GetScheduleAlwaysOff(*state); + spaceEquipConfig2.returnFlowSched = Sched::GetScheduleAlwaysOff(*state); + spaceEquipConfig3.returnFlowSched = Sched::GetScheduleAlwaysOff(*state); + spaceEquipConfig1.ZoneNode = 5; spaceEquipConfig2.ZoneNode = 6; spaceEquipConfig3.ZoneNode = 7; diff --git a/tst/EnergyPlus/unit/ZoneHVACEvaporativeCooler.unit.cc b/tst/EnergyPlus/unit/ZoneHVACEvaporativeCooler.unit.cc index dd05492006a..206c1a92acb 100644 --- a/tst/EnergyPlus/unit/ZoneHVACEvaporativeCooler.unit.cc +++ b/tst/EnergyPlus/unit/ZoneHVACEvaporativeCooler.unit.cc @@ -99,7 +99,7 @@ class ZoneHVACEvapCoolerUnitTest : public EnergyPlusFixture state->dataZoneEquip->ZoneEquipList.allocate(state->dataGlobal->NumOfZones); state->dataLoopNodes->Node.allocate(NumOfNodes); state->dataZoneEnergyDemand->ZoneSysEnergyDemand.allocate(1); - state->dataHeatBalFanSys->ZoneThermostatSetPointHi.allocate(1); + state->dataHeatBalFanSys->zoneTstatSetpts.allocate(1); state->dataZoneEquip->ZoneEquipConfig(1).ZoneName = "One Zone"; state->dataZoneEquip->ZoneEquipConfig(1).NumInletNodes = 1; @@ -191,9 +191,7 @@ TEST_F(ZoneHVACEvapCoolerUnitTest, DirectCelDekPad_CyclingUnit_Sim) }); ASSERT_TRUE(process_idf(idf_objects)); - - ScheduleManager::ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; + state->init_state(*state); Fans::GetFanInput(*state); ASSERT_FALSE(ErrorsFound); @@ -221,7 +219,7 @@ TEST_F(ZoneHVACEvapCoolerUnitTest, DirectCelDekPad_CyclingUnit_Sim) state->dataLoopNodes->Node(thisZoneEvapCooler.OAInletNodeNum).Enthalpy = Psychrometrics::PsyHFnTdbW(state->dataEnvrn->OutDryBulbTemp, state->dataEnvrn->OutHumRat); - state->dataHeatBalFanSys->ZoneThermostatSetPointHi(1) = 23.0; + state->dataHeatBalFanSys->zoneTstatSetpts(1).setptHi = 23.0; state->dataZoneEnergyDemand->ZoneSysEnergyDemand(1).RemainingOutputReqToHeatSP = 0.0; state->dataZoneEnergyDemand->ZoneSysEnergyDemand(1).RemainingOutputReqToCoolSP = -15000.0; @@ -317,9 +315,7 @@ TEST_F(ZoneHVACEvapCoolerUnitTest, DirectResearchSpecial_CyclingUnit_Sim) " ZoneEvapCool Inlet Node; !- Sensor Node Name", }); ASSERT_TRUE(process_idf(idf_objects)); - - ScheduleManager::ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; + state->init_state(*state); Fans::GetFanInput(*state); ASSERT_FALSE(ErrorsFound); @@ -347,13 +343,13 @@ TEST_F(ZoneHVACEvapCoolerUnitTest, DirectResearchSpecial_CyclingUnit_Sim) state->dataLoopNodes->Node(thisZoneEvapCooler.OAInletNodeNum).Enthalpy = Psychrometrics::PsyHFnTdbW(state->dataEnvrn->OutDryBulbTemp, state->dataEnvrn->OutHumRat); - state->dataHeatBalFanSys->ZoneThermostatSetPointHi(1) = 23.0; + state->dataHeatBalFanSys->zoneTstatSetpts(1).setptHi = 23.0; state->dataZoneEnergyDemand->ZoneSysEnergyDemand(1).RemainingOutputReqToHeatSP = 0.0; state->dataZoneEnergyDemand->ZoneSysEnergyDemand(1).RemainingOutputReqToCoolSP = -15000.0; state->dataZoneEquip->ZoneEquipList(1).EquipName(1) = thisZoneEvapCooler.Name; // Evap Cooler Unit Control Method = Zone Temperature Dead Band OnOff Cycling - EXPECT_EQ((int)thisZoneEvapCooler.fanOp, (int)HVAC::FanOp::Cycling); + EXPECT_ENUM_EQ(thisZoneEvapCooler.fanOp, HVAC::FanOp::Cycling); EXPECT_ENUM_EQ(thisZoneEvapCooler.ControlSchemeType, ControlType::ZoneTemperatureDeadBandOnOffCycling); EvaporativeCoolers::SimZoneEvaporativeCoolerUnit( *state, thisZoneEvapCooler.Name, ActualZoneNum, SensOutputProvided, LatOutputProvided, ZoneEquipIndex); @@ -448,9 +444,7 @@ TEST_F(ZoneHVACEvapCoolerUnitTest, IndirectWetCoil_CyclingUnit_Sim) }); ASSERT_TRUE(process_idf(idf_objects)); - - ScheduleManager::ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; + state->init_state(*state); Fans::GetFanInput(*state); ASSERT_FALSE(ErrorsFound); @@ -486,7 +480,7 @@ TEST_F(ZoneHVACEvapCoolerUnitTest, IndirectWetCoil_CyclingUnit_Sim) state->dataLoopNodes->Node(thisEvapCooler.SecondaryInletNode).Enthalpy = Psychrometrics::PsyHFnTdbW(state->dataEnvrn->OutDryBulbTemp, state->dataEnvrn->OutHumRat); - state->dataHeatBalFanSys->ZoneThermostatSetPointHi(1) = 23.0; + state->dataHeatBalFanSys->zoneTstatSetpts(1).setptHi = 23.0; state->dataZoneEnergyDemand->ZoneSysEnergyDemand(1).RemainingOutputReqToHeatSP = 0.0; state->dataZoneEnergyDemand->ZoneSysEnergyDemand(1).RemainingOutputReqToCoolSP = -15000.0; state->dataZoneEquip->ZoneEquipList(1).EquipName(1) = thisZoneEvapCooler.Name; @@ -586,9 +580,7 @@ TEST_F(ZoneHVACEvapCoolerUnitTest, RHcontrol) }); ASSERT_TRUE(process_idf(idf_objects)); - - ScheduleManager::ProcessScheduleInput(*state); - state->dataScheduleMgr->ScheduleInputProcessed = true; + state->init_state(*state); Fans::GetFanInput(*state); ASSERT_FALSE(ErrorsFound); @@ -618,7 +610,7 @@ TEST_F(ZoneHVACEvapCoolerUnitTest, RHcontrol) state->dataLoopNodes->Node(thisZoneEvapCooler.OAInletNodeNum).Enthalpy = Psychrometrics::PsyHFnTdbW(state->dataEnvrn->OutDryBulbTemp, state->dataEnvrn->OutHumRat); - state->dataHeatBalFanSys->ZoneThermostatSetPointHi(1) = 23.0; + state->dataHeatBalFanSys->zoneTstatSetpts(1).setptHi = 23.0; state->dataZoneEnergyDemand->ZoneSysEnergyDemand(1).RemainingOutputReqToHeatSP = 0.0; state->dataZoneEnergyDemand->ZoneSysEnergyDemand(1).RemainingOutputReqToCoolSP = -15000.0; state->dataZoneEquip->ZoneEquipList(1).EquipName(1) = thisZoneEvapCooler.Name; diff --git a/tst/EnergyPlus/unit/ZoneTempPredictorCorrector.unit.cc b/tst/EnergyPlus/unit/ZoneTempPredictorCorrector.unit.cc index 8502fb060a9..9649581faf6 100644 --- a/tst/EnergyPlus/unit/ZoneTempPredictorCorrector.unit.cc +++ b/tst/EnergyPlus/unit/ZoneTempPredictorCorrector.unit.cc @@ -93,7 +93,6 @@ using namespace EnergyPlus::DataLoopNode; using namespace EnergyPlus::DataSurfaces; using namespace EnergyPlus::DataEnvironment; using namespace EnergyPlus::Psychrometrics; -using namespace EnergyPlus::ScheduleManager; using namespace EnergyPlus::RoomAir; using namespace EnergyPlus::HybridModel; using namespace SimulationManager; @@ -102,8 +101,10 @@ TEST_F(EnergyPlusFixture, ZoneTempPredictorCorrector_CorrectZoneHumRatTest) { state->dataHVACGlobal->TimeStepSys = 15.0 / 60.0; // System timestep in hours - state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; + state->init_state(*state); + state->dataZoneEquip->ZoneEquipConfig.allocate(1); state->dataZoneEquip->ZoneEquipConfig(1).ZoneName = "Zone 1"; @@ -449,7 +450,12 @@ TEST_F(EnergyPlusFixture, ZoneTempPredictorCorrector_ReportingTest) ASSERT_TRUE(process_idf(idf_objects)); + state->dataGlobal->TimeStepsInHour = 1; // must initialize this to get schedules initialized + state->dataGlobal->MinutesInTimeStep = 60; // must initialize this to get schedules initialized + state->init_state(*state); + bool ErrorsFound(false); // If errors detected in input + GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); @@ -458,10 +464,6 @@ TEST_F(EnergyPlusFixture, ZoneTempPredictorCorrector_ReportingTest) int CoolHeatZoneNum(3); int DualZoneNum(4); - state->dataGlobal->NumOfTimeStepInHour = 1; // must initialize this to get schedules initialized - state->dataGlobal->MinutesPerTimeStep = 60; // must initialize this to get schedules initialized - ProcessScheduleInput(*state); // read schedules - GetZoneAirSetPoints(*state); state->dataZoneEnergyDemand->DeadBandOrSetback.allocate(state->dataZoneCtrls->NumTempControlledZones); @@ -469,10 +471,8 @@ TEST_F(EnergyPlusFixture, ZoneTempPredictorCorrector_ReportingTest) state->dataHeatBalFanSys->TempControlType.allocate(state->dataZoneCtrls->NumTempControlledZones); state->dataHeatBalFanSys->TempControlTypeRpt.allocate(state->dataZoneCtrls->NumTempControlledZones); state->dataZoneEnergyDemand->ZoneSysEnergyDemand.allocate(state->dataZoneCtrls->NumTempControlledZones); - state->dataHeatBalFanSys->TempZoneThermostatSetPoint.allocate(state->dataZoneCtrls->NumTempControlledZones); + state->dataHeatBalFanSys->zoneTstatSetpts.allocate(state->dataZoneCtrls->NumTempControlledZones); state->dataZoneEnergyDemand->Setback.allocate(state->dataZoneCtrls->NumTempControlledZones); - state->dataHeatBalFanSys->ZoneThermostatSetPointLo.allocate(state->dataZoneCtrls->NumTempControlledZones); - state->dataHeatBalFanSys->ZoneThermostatSetPointHi.allocate(state->dataZoneCtrls->NumTempControlledZones); state->dataZoneTempPredictorCorrector->zoneHeatBalance.allocate(state->dataGlobal->NumOfZones); state->dataZoneTempPredictorCorrector->spaceHeatBalance.allocate(state->dataGlobal->NumOfZones); @@ -486,83 +486,69 @@ TEST_F(EnergyPlusFixture, ZoneTempPredictorCorrector_ReportingTest) // extern int const SingleHeatingSetPoint; = 1 // extern int const SingleCoolingSetPoint; = 2 // extern int const SingleHeatCoolSetPoint; = 3 - // extern int const DualSetPointWithDeadBand; = 4 - state->dataScheduleMgr->Schedule(state->dataZoneCtrls->TempControlledZone(HeatZoneNum).CTSchedIndex).CurrentValue = - static_cast(HVAC::ThermostatType::SingleHeating); - state->dataScheduleMgr->Schedule(state->dataZoneCtrls->TempControlledZone(CoolZoneNum).CTSchedIndex).CurrentValue = - static_cast(HVAC::ThermostatType::SingleCooling); - state->dataScheduleMgr->Schedule(state->dataZoneCtrls->TempControlledZone(CoolHeatZoneNum).CTSchedIndex).CurrentValue = - static_cast(HVAC::ThermostatType::SingleHeatCool); - - state->dataScheduleMgr->Schedule(state->dataZoneCtrls->TempControlledZone(DualZoneNum).CTSchedIndex).CurrentValue = - 0; // simulate no thermostat or non-controlled zone + // extern int const DualHeatCool; = 4 + state->dataZoneCtrls->TempControlledZone(HeatZoneNum).setptTypeSched->currentVal = (int)HVAC::SetptType::SingleHeat; + state->dataZoneCtrls->TempControlledZone(CoolZoneNum).setptTypeSched->currentVal = (int)HVAC::SetptType::SingleCool; + state->dataZoneCtrls->TempControlledZone(CoolHeatZoneNum).setptTypeSched->currentVal = (int)HVAC::SetptType::SingleHeatCool; + state->dataZoneCtrls->TempControlledZone(DualZoneNum).setptTypeSched->currentVal = (int)HVAC::SetptType::Uncontrolled; state->dataZoneEnergyDemand->ZoneSysEnergyDemand(DualZoneNum).TotalOutputRequired = 0.0; // no load and no thermostat since control type is set to 0 above CalcZoneAirTempSetPoints(*state); state->dataZoneTempPredictorCorrector->zoneHeatBalance(DualZoneNum).calcPredictedSystemLoad(*state, 1.0, DualZoneNum); - EXPECT_EQ(0.0, - state->dataHeatBalFanSys->TempZoneThermostatSetPoint( - DualZoneNum)); // Set point initialized to 0 and never set since thermostat control type = 0 + EXPECT_EQ(0.0, state->dataHeatBalFanSys->zoneTstatSetpts(DualZoneNum).setpt); // Set point initialized to 0 and never set since thermostat control type = 0 - state->dataScheduleMgr->Schedule(state->dataZoneCtrls->TempControlledZone(DualZoneNum).CTSchedIndex).CurrentValue = - static_cast(HVAC::ThermostatType::DualSetPointWithDeadBand); // reset Tstat control schedule to dual thermostat control + state->dataZoneCtrls->TempControlledZone(DualZoneNum).setptTypeSched->currentVal = (int)HVAC::SetptType::DualHeatCool; // reset Tstat control schedule to dual thermostat control // set up a back calculated load // for the first few, TempIndZnLd() = 0.0 // LoadToHeatingSetPoint = ( TempDepZnLd( ZoneNum ) * ( TempZoneThermostatSetPoint( ZoneNum ) ) - TempIndZnLd( ZoneNum ) ); // LoadToCoolingSetPoint = ( TempDepZnLd( ZoneNum ) * ( TempZoneThermostatSetPoint( ZoneNum ) ) - TempIndZnLd( ZoneNum ) ); - int SetPointTempSchedIndex = state->dataZoneCtrls->TempControlledZone(HeatZoneNum).SchIndx_SingleHeatSetPoint; - state->dataScheduleMgr->Schedule(SetPointTempSchedIndex).CurrentValue = 20.0; + state->dataZoneCtrls->TempControlledZone(HeatZoneNum).setpts[(int)HVAC::SetptType::SingleHeat].heatSetptSched->currentVal = 20.0; state->dataZoneEnergyDemand->ZoneSysEnergyDemand(HeatZoneNum).TotalOutputRequired = -1000.0; // cooling load state->dataZoneTempPredictorCorrector->zoneHeatBalance(HeatZoneNum).tempDepLoad = state->dataZoneEnergyDemand->ZoneSysEnergyDemand(HeatZoneNum).TotalOutputRequired / - state->dataScheduleMgr->Schedule(SetPointTempSchedIndex).CurrentValue; + state->dataZoneCtrls->TempControlledZone(HeatZoneNum).setpts[(int)HVAC::SetptType::SingleHeat].heatSetptSched->currentVal; CalcZoneAirTempSetPoints(*state); state->dataZoneTempPredictorCorrector->zoneHeatBalance(HeatZoneNum).calcPredictedSystemLoad(*state, 1.0, HeatZoneNum); - EXPECT_EQ(20.0, state->dataHeatBalFanSys->TempZoneThermostatSetPoint(HeatZoneNum)); + EXPECT_EQ(20.0, state->dataHeatBalFanSys->zoneTstatSetpts(HeatZoneNum).setpt); EXPECT_EQ(-1000.0, state->dataZoneEnergyDemand->ZoneSysEnergyDemand(HeatZoneNum) .TotalOutputRequired); // TotalOutputRequired gets updated in CalcPredictedSystemLoad based on the load EXPECT_TRUE(state->dataZoneEnergyDemand->CurDeadBandOrSetback(HeatZoneNum)); // Tstat should show there is no load on a single heating SP - SetPointTempSchedIndex = state->dataZoneCtrls->TempControlledZone(HeatZoneNum).SchIndx_SingleHeatSetPoint; - state->dataScheduleMgr->Schedule(SetPointTempSchedIndex).CurrentValue = 21.0; + state->dataZoneCtrls->TempControlledZone(HeatZoneNum).setpts[(int)HVAC::SetptType::SingleHeat].heatSetptSched->currentVal = 21.0; state->dataZoneEnergyDemand->ZoneSysEnergyDemand(HeatZoneNum).TotalOutputRequired = 1000.0; // heating load state->dataZoneTempPredictorCorrector->zoneHeatBalance(HeatZoneNum).tempDepLoad = state->dataZoneEnergyDemand->ZoneSysEnergyDemand(HeatZoneNum).TotalOutputRequired / - state->dataScheduleMgr->Schedule(SetPointTempSchedIndex).CurrentValue; + state->dataZoneCtrls->TempControlledZone(HeatZoneNum).setpts[(int)HVAC::SetptType::SingleHeat].heatSetptSched->currentVal; - SetPointTempSchedIndex = state->dataZoneCtrls->TempControlledZone(CoolZoneNum).SchIndx_SingleCoolSetPoint; - state->dataScheduleMgr->Schedule(SetPointTempSchedIndex).CurrentValue = 23.0; + state->dataZoneCtrls->TempControlledZone(CoolZoneNum).setpts[(int)HVAC::SetptType::SingleCool].coolSetptSched->currentVal = 23.0; state->dataZoneEnergyDemand->ZoneSysEnergyDemand(CoolZoneNum).TotalOutputRequired = -3000.0; // cooling load state->dataZoneTempPredictorCorrector->zoneHeatBalance(CoolZoneNum).tempDepLoad = state->dataZoneEnergyDemand->ZoneSysEnergyDemand(CoolZoneNum).TotalOutputRequired / - state->dataScheduleMgr->Schedule(SetPointTempSchedIndex).CurrentValue; + state->dataZoneCtrls->TempControlledZone(CoolZoneNum).setpts[(int)HVAC::SetptType::SingleCool].coolSetptSched->currentVal; - SetPointTempSchedIndex = state->dataZoneCtrls->TempControlledZone(CoolHeatZoneNum).SchIndx_SingleHeatCoolSetPoint; - state->dataScheduleMgr->Schedule(SetPointTempSchedIndex).CurrentValue = 22.0; + state->dataZoneCtrls->TempControlledZone(CoolHeatZoneNum).setpts[(int)HVAC::SetptType::SingleHeatCool].heatSetptSched->currentVal = 22.0; state->dataZoneEnergyDemand->ZoneSysEnergyDemand(CoolHeatZoneNum).TotalOutputRequired = -4000.0; // cooling load state->dataZoneTempPredictorCorrector->zoneHeatBalance(CoolHeatZoneNum).tempDepLoad = state->dataZoneEnergyDemand->ZoneSysEnergyDemand(CoolHeatZoneNum).TotalOutputRequired / - state->dataScheduleMgr->Schedule(SetPointTempSchedIndex).CurrentValue; + state->dataZoneCtrls->TempControlledZone(CoolHeatZoneNum).setpts[(int)HVAC::SetptType::SingleHeatCool].heatSetptSched->currentVal; - SetPointTempSchedIndex = state->dataZoneCtrls->TempControlledZone(DualZoneNum).SchIndx_DualSetPointWDeadBandCool; - state->dataScheduleMgr->Schedule(SetPointTempSchedIndex).CurrentValue = 24.0; - SetPointTempSchedIndex = state->dataZoneCtrls->TempControlledZone(DualZoneNum).SchIndx_DualSetPointWDeadBandHeat; - state->dataScheduleMgr->Schedule(SetPointTempSchedIndex).CurrentValue = 20.0; + state->dataZoneCtrls->TempControlledZone(DualZoneNum).setpts[(int)HVAC::SetptType::DualHeatCool].coolSetptSched->currentVal = 24.0; + state->dataZoneCtrls->TempControlledZone(DualZoneNum).setpts[(int)HVAC::SetptType::DualHeatCool].heatSetptSched->currentVal = 20.0; state->dataZoneEnergyDemand->ZoneSysEnergyDemand(DualZoneNum).TotalOutputRequired = 2500.0; // heating load state->dataZoneTempPredictorCorrector->zoneHeatBalance(DualZoneNum).tempDepLoad = state->dataZoneEnergyDemand->ZoneSysEnergyDemand(DualZoneNum).TotalOutputRequired / - state->dataScheduleMgr->Schedule(SetPointTempSchedIndex).CurrentValue; + state->dataZoneCtrls->TempControlledZone(DualZoneNum).setpts[(int)HVAC::SetptType::DualHeatCool].heatSetptSched->currentVal; CalcZoneAirTempSetPoints(*state); state->dataZoneTempPredictorCorrector->zoneHeatBalance(HeatZoneNum).calcPredictedSystemLoad(*state, 1.0, HeatZoneNum); - EXPECT_EQ(21.0, state->dataHeatBalFanSys->TempZoneThermostatSetPoint(HeatZoneNum)); + EXPECT_EQ(21.0, state->dataHeatBalFanSys->zoneTstatSetpts(HeatZoneNum).setpt); EXPECT_FALSE(state->dataZoneEnergyDemand->CurDeadBandOrSetback(HeatZoneNum)); // Tstat should show there is load on a single heating SP EXPECT_EQ(1000.0, state->dataZoneEnergyDemand->ZoneSysEnergyDemand(HeatZoneNum) @@ -570,7 +556,7 @@ TEST_F(EnergyPlusFixture, ZoneTempPredictorCorrector_ReportingTest) state->dataZoneTempPredictorCorrector->zoneHeatBalance(CoolZoneNum).calcPredictedSystemLoad(*state, 1.0, CoolZoneNum); - EXPECT_EQ(23.0, state->dataHeatBalFanSys->TempZoneThermostatSetPoint(CoolZoneNum)); + EXPECT_EQ(23.0, state->dataHeatBalFanSys->zoneTstatSetpts(CoolZoneNum).setpt); EXPECT_FALSE(state->dataZoneEnergyDemand->CurDeadBandOrSetback(CoolZoneNum)); // Tstat should show there is load on a single cooling SP EXPECT_EQ(-3000.0, state->dataZoneEnergyDemand->ZoneSysEnergyDemand(CoolZoneNum) @@ -578,7 +564,7 @@ TEST_F(EnergyPlusFixture, ZoneTempPredictorCorrector_ReportingTest) state->dataZoneTempPredictorCorrector->zoneHeatBalance(CoolHeatZoneNum).calcPredictedSystemLoad(*state, 1.0, CoolHeatZoneNum); - ASSERT_EQ(22.0, state->dataHeatBalFanSys->TempZoneThermostatSetPoint(CoolHeatZoneNum)); + ASSERT_EQ(22.0, state->dataHeatBalFanSys->zoneTstatSetpts(CoolHeatZoneNum).setpt); EXPECT_FALSE( state->dataZoneEnergyDemand->CurDeadBandOrSetback(CoolHeatZoneNum)); // Tstat should show there is load on a single heating or cooling SP EXPECT_EQ(-4000.0, @@ -587,25 +573,24 @@ TEST_F(EnergyPlusFixture, ZoneTempPredictorCorrector_ReportingTest) state->dataZoneTempPredictorCorrector->zoneHeatBalance(DualZoneNum).calcPredictedSystemLoad(*state, 1.0, DualZoneNum); - EXPECT_EQ(20.0, state->dataHeatBalFanSys->TempZoneThermostatSetPoint(DualZoneNum)); + EXPECT_EQ(20.0, state->dataHeatBalFanSys->zoneTstatSetpts(DualZoneNum).setpt); EXPECT_FALSE(state->dataZoneEnergyDemand->CurDeadBandOrSetback(DualZoneNum)); // Tstat should show there is load on a dual SP EXPECT_EQ(2500.0, state->dataZoneEnergyDemand->ZoneSysEnergyDemand(DualZoneNum) .TotalOutputRequired); // TotalOutputRequired gets updated in CalcPredictedSystemLoad based on the load - SetPointTempSchedIndex = state->dataZoneCtrls->TempControlledZone(DualZoneNum).SchIndx_DualSetPointWDeadBandCool; - state->dataScheduleMgr->Schedule(SetPointTempSchedIndex).CurrentValue = 25.0; + state->dataZoneCtrls->TempControlledZone(DualZoneNum).setpts[(int)HVAC::SetptType::DualHeatCool].coolSetptSched->currentVal = 25.0; state->dataZoneEnergyDemand->ZoneSysEnergyDemand(DualZoneNum).TotalOutputRequired = 1000.0; // LoadToCoolingSetPoint = ( TempDepZnLd( ZoneNum ) * ( TempZoneThermostatSetPoint( ZoneNum ) ) - TempIndZnLd( ZoneNum ) ); state->dataZoneTempPredictorCorrector->zoneHeatBalance(DualZoneNum).tempDepLoad = state->dataZoneEnergyDemand->ZoneSysEnergyDemand(DualZoneNum).TotalOutputRequired / - state->dataScheduleMgr->Schedule(SetPointTempSchedIndex).CurrentValue; + state->dataZoneCtrls->TempControlledZone(DualZoneNum).setpts[(int)HVAC::SetptType::DualHeatCool].coolSetptSched->currentVal; state->dataZoneTempPredictorCorrector->zoneHeatBalance(DualZoneNum).tempIndLoad = 3500.0; // results in a cooling load CalcZoneAirTempSetPoints(*state); state->dataZoneTempPredictorCorrector->zoneHeatBalance(DualZoneNum).calcPredictedSystemLoad(*state, 1.0, DualZoneNum); - EXPECT_EQ(25.0, state->dataHeatBalFanSys->TempZoneThermostatSetPoint(DualZoneNum)); + EXPECT_EQ(25.0, state->dataHeatBalFanSys->zoneTstatSetpts(DualZoneNum).setpt); EXPECT_FALSE(state->dataZoneEnergyDemand->CurDeadBandOrSetback(DualZoneNum)); // Tstat should show there is load on a dual SP EXPECT_EQ(-2500.0, state->dataZoneEnergyDemand->ZoneSysEnergyDemand(DualZoneNum).TotalOutputRequired); // should show a cooling load } @@ -797,6 +782,8 @@ TEST_F(EnergyPlusFixture, ZoneTempPredictorCorrector_AdaptiveThermostat) ASSERT_TRUE(process_idf(idf_objects)); // Tstat should show if the idf is legel + state->init_state(*state); + int ZoneNum(4); int CoolZoneASHNum(1); int CoolZoneCENNum(2); @@ -937,6 +924,8 @@ TEST_F(EnergyPlusFixture, ZoneTempPredictorCorrector_calcZoneOrSpaceSums_SurfCon // DATE WRITTEN: Jan 2017 // #5906 Adaptive convection resulting in extremely low zone temperature which causes fatal error + state->init_state(*state); + int ZoneNum = 1; // Zone number state->dataHeatBal->ZoneIntGain.allocate(ZoneNum); @@ -1055,6 +1044,7 @@ TEST_F(EnergyPlusFixture, ZoneTempPredictorCorrector_EMSOverrideSetpointTest) // AUTHOR: L. Gu, FSEC // DATE WRITTEN: Jun. 2017 // #5870 EMS actuators for Zone Temperature Control not working + state->init_state(*state); state->dataZoneCtrls->NumTempControlledZones = 1; state->dataZoneCtrls->NumComfortControlledZones = 0; @@ -1067,14 +1057,12 @@ TEST_F(EnergyPlusFixture, ZoneTempPredictorCorrector_EMSOverrideSetpointTest) state->dataHeatBalFanSys->TempControlType.allocate(1); state->dataHeatBalFanSys->TempControlTypeRpt.allocate(1); - state->dataHeatBalFanSys->TempZoneThermostatSetPoint.allocate(1); - state->dataHeatBalFanSys->ZoneThermostatSetPointLo.allocate(1); - state->dataHeatBalFanSys->ZoneThermostatSetPointHi.allocate(1); - state->dataHeatBalFanSys->TempControlType(1) = HVAC::ThermostatType::DualSetPointWithDeadBand; + state->dataHeatBalFanSys->zoneTstatSetpts.allocate(1); + state->dataHeatBalFanSys->TempControlType(1) = HVAC::SetptType::DualHeatCool; OverrideAirSetPointsforEMSCntrl(*state); - EXPECT_EQ(23.0, state->dataHeatBalFanSys->ZoneThermostatSetPointLo(1)); - EXPECT_EQ(26.0, state->dataHeatBalFanSys->ZoneThermostatSetPointHi(1)); + EXPECT_EQ(23.0, state->dataHeatBalFanSys->zoneTstatSetpts(1).setptLo); + EXPECT_EQ(26.0, state->dataHeatBalFanSys->zoneTstatSetpts(1).setptHi); state->dataZoneCtrls->NumTempControlledZones = 0; state->dataZoneCtrls->NumComfortControlledZones = 1; @@ -1083,13 +1071,13 @@ TEST_F(EnergyPlusFixture, ZoneTempPredictorCorrector_EMSOverrideSetpointTest) state->dataZoneCtrls->ComfortControlledZone(1).ActualZoneNum = 1; state->dataZoneCtrls->ComfortControlledZone(1).EMSOverrideHeatingSetPointOn = true; state->dataZoneCtrls->ComfortControlledZone(1).EMSOverrideCoolingSetPointOn = true; - state->dataHeatBalFanSys->ComfortControlType(1) = HVAC::ThermostatType::DualSetPointWithDeadBand; + state->dataHeatBalFanSys->ComfortControlType(1) = HVAC::SetptType::DualHeatCool; state->dataZoneCtrls->ComfortControlledZone(1).EMSOverrideHeatingSetPointValue = 22; state->dataZoneCtrls->ComfortControlledZone(1).EMSOverrideCoolingSetPointValue = 25; OverrideAirSetPointsforEMSCntrl(*state); - EXPECT_EQ(22.0, state->dataHeatBalFanSys->ZoneThermostatSetPointLo(1)); - EXPECT_EQ(25.0, state->dataHeatBalFanSys->ZoneThermostatSetPointHi(1)); + EXPECT_EQ(22.0, state->dataHeatBalFanSys->zoneTstatSetpts(1).setptLo); + EXPECT_EQ(25.0, state->dataHeatBalFanSys->zoneTstatSetpts(1).setptHi); } TEST_F(EnergyPlusFixture, temperatureAndCountInSch_test) @@ -1133,9 +1121,10 @@ TEST_F(EnergyPlusFixture, temperatureAndCountInSch_test) ASSERT_TRUE(process_idf(idf_objects)); - state->dataGlobal->NumOfTimeStepInHour = 4; - state->dataGlobal->MinutesPerTimeStep = 15; + state->dataGlobal->TimeStepsInHour = 4; + state->dataGlobal->MinutesInTimeStep = 15; state->dataEnvrn->CurrentYearIsLeapYear = false; + state->init_state(*state); Real64 valueAtTime; int numDays; @@ -1143,52 +1132,52 @@ TEST_F(EnergyPlusFixture, temperatureAndCountInSch_test) constexpr int wednesday = 4; state->dataEnvrn->Latitude = 30.; // northern hemisphere - int sched1Index = GetScheduleIndex(*state, "SCHED1"); - std::tie(valueAtTime, numDays, monthAssumed) = temperatureAndCountInSch(*state, sched1Index, false, wednesday, 11); + auto *sched1 = Sched::GetSchedule(*state, "SCHED1"); + std::tie(valueAtTime, numDays, monthAssumed) = sched1->getValAndCountOnDay(*state, false, Sched::DayType::Wednesday, 11); EXPECT_EQ(20, valueAtTime); EXPECT_EQ(365, numDays); EXPECT_EQ("January", monthAssumed); // test month selected based on hemisphere and isSummer flag. - std::tie(valueAtTime, numDays, monthAssumed) = temperatureAndCountInSch(*state, sched1Index, true, wednesday, 11); + std::tie(valueAtTime, numDays, monthAssumed) = sched1->getValAndCountOnDay(*state, true, Sched::DayType::Wednesday, 11); EXPECT_EQ("July", monthAssumed); state->dataEnvrn->Latitude = -30.; // southern hemisphere - std::tie(valueAtTime, numDays, monthAssumed) = temperatureAndCountInSch(*state, sched1Index, false, wednesday, 11); + std::tie(valueAtTime, numDays, monthAssumed) = sched1->getValAndCountOnDay(*state, false, Sched::DayType::Wednesday, 11); EXPECT_EQ("July", monthAssumed); - std::tie(valueAtTime, numDays, monthAssumed) = temperatureAndCountInSch(*state, sched1Index, true, wednesday, 11); + std::tie(valueAtTime, numDays, monthAssumed) = sched1->getValAndCountOnDay(*state, true, Sched::DayType::Wednesday, 11); EXPECT_EQ("January", monthAssumed); state->dataEnvrn->Latitude = 30.; // northern hemisphere - int sched2Index = GetScheduleIndex(*state, "SCHED2"); - std::tie(valueAtTime, numDays, monthAssumed) = temperatureAndCountInSch(*state, sched2Index, false, wednesday, 11); + auto *sched2 = Sched::GetSchedule(*state, "SCHED2"); + std::tie(valueAtTime, numDays, monthAssumed) = sched2->getValAndCountOnDay(*state, false, Sched::DayType::Wednesday, 11); EXPECT_EQ(24, valueAtTime); EXPECT_EQ(31, numDays); EXPECT_EQ("January", monthAssumed); - std::tie(valueAtTime, numDays, monthAssumed) = temperatureAndCountInSch(*state, sched2Index, true, wednesday, 11); + std::tie(valueAtTime, numDays, monthAssumed) = sched2->getValAndCountOnDay(*state, true, Sched::DayType::Wednesday, 11); EXPECT_EQ(26, valueAtTime); EXPECT_EQ(334, numDays); EXPECT_EQ("July", monthAssumed); - int sched3Index = GetScheduleIndex(*state, "SCHED3"); - std::tie(valueAtTime, numDays, monthAssumed) = temperatureAndCountInSch(*state, sched3Index, false, wednesday, 11); + auto *sched3 = Sched::GetSchedule(*state, "SCHED3"); + std::tie(valueAtTime, numDays, monthAssumed) = sched3->getValAndCountOnDay(*state, false, Sched::DayType::Wednesday, 11); EXPECT_EQ(26, valueAtTime); EXPECT_EQ(365, numDays); EXPECT_EQ("January", monthAssumed); - std::tie(valueAtTime, numDays, monthAssumed) = temperatureAndCountInSch(*state, sched3Index, true, wednesday, 11); + std::tie(valueAtTime, numDays, monthAssumed) = sched3->getValAndCountOnDay(*state, true, Sched::DayType::Wednesday, 11); EXPECT_EQ(26, valueAtTime); EXPECT_EQ(365, numDays); EXPECT_EQ("July", monthAssumed); - std::tie(valueAtTime, numDays, monthAssumed) = temperatureAndCountInSch(*state, sched3Index, false, wednesday, 19); + std::tie(valueAtTime, numDays, monthAssumed) = sched3->getValAndCountOnDay(*state, false, Sched::DayType::Wednesday, 19); EXPECT_EQ(24, valueAtTime); EXPECT_EQ(31, numDays); @@ -1198,15 +1187,11 @@ TEST_F(EnergyPlusFixture, temperatureAndCountInSch_test) TEST_F(EnergyPlusFixture, SetPointWithCutoutDeltaT_test) { // On/Off thermostat - state->dataScheduleMgr->Schedule.allocate(3); - state->dataZoneCtrls->NumTempControlledZones = 1; // SingleHeatingSetPoint state->dataZoneCtrls->TempControlledZone.allocate(state->dataZoneCtrls->NumTempControlledZones); - state->dataHeatBalFanSys->TempZoneThermostatSetPoint.allocate(1); - state->dataHeatBalFanSys->ZoneThermostatSetPointLo.allocate(1); - state->dataHeatBalFanSys->ZoneThermostatSetPointHi.allocate(1); + state->dataHeatBalFanSys->zoneTstatSetpts.allocate(1); state->dataZoneEnergyDemand->ZoneSysEnergyDemand.allocate(1); state->dataZoneEnergyDemand->DeadBandOrSetback.allocate(1); state->dataHeatBal->Zone.allocate(1); @@ -1220,14 +1205,17 @@ TEST_F(EnergyPlusFixture, SetPointWithCutoutDeltaT_test) state->dataZoneCtrls->TempControlledZone(1).DeltaTCutSet = 2.0; state->dataZoneCtrls->TempControlledZone(1).ActualZoneNum = 1; - state->dataZoneCtrls->TempControlledZone(1).CTSchedIndex = 1; - state->dataScheduleMgr->Schedule(1).CurrentValue = 1; + auto *setptTypeSched = state->dataZoneCtrls->TempControlledZone(1).setptTypeSched = Sched::AddScheduleConstant(*state, "SETPT TYPE-1"); + state->dataZoneCtrls->TempControlledZone(1).setptTypeSched->currentVal = (int)HVAC::SetptType::SingleHeat; state->dataHeatBalFanSys->TempControlType.allocate(1); state->dataHeatBalFanSys->TempControlTypeRpt.allocate(1); - state->dataZoneCtrls->TempControlledZone(1).SchIndx_SingleHeatSetPoint = 3; - state->dataZoneTempPredictorCorrector->SetPointSingleHeating.allocate(1); - state->dataZoneTempPredictorCorrector->SetPointSingleHeating(1).TempSchedIndex = 3; - state->dataScheduleMgr->Schedule(3).CurrentValue = 22.0; + auto *heatSetptSched = Sched::AddScheduleConstant(*state, "HEAT SETPT-1"); + auto *coolSetptSched = Sched::AddScheduleConstant(*state, "COOL SETPT-1"); + + state->dataZoneCtrls->TempControlledZone(1).setpts[(int)HVAC::SetptType::SingleHeat].heatSetptSched = heatSetptSched; + state->dataZoneTempPredictorCorrector->tempSetptScheds[(int)HVAC::SetptType::SingleHeat].allocate(1); + state->dataZoneTempPredictorCorrector->tempSetptScheds[(int)HVAC::SetptType::SingleHeat](1).heatSched = heatSetptSched; + heatSetptSched->currentVal = 22.0; state->dataZoneTempPredictorCorrector->zoneHeatBalance.allocate(1); state->dataZoneTempPredictorCorrector->spaceHeatBalance.allocate(1); auto &thisZoneHB = state->dataZoneTempPredictorCorrector->zoneHeatBalance(1); @@ -1241,60 +1229,62 @@ TEST_F(EnergyPlusFixture, SetPointWithCutoutDeltaT_test) CalcZoneAirTempSetPoints(*state); PredictSystemLoads(*state, false, false, 0.01); - EXPECT_EQ(24.0, state->dataHeatBalFanSys->ZoneThermostatSetPointLo(1)); + EXPECT_EQ(24.0, state->dataHeatBalFanSys->zoneTstatSetpts(1).setptLo); thisZoneHB.MAT = 23.0; thisZoneHB.T1 = thisZoneHB.MAT; state->dataZoneCtrls->TempControlledZone(1).HeatModeLast = true; CalcZoneAirTempSetPoints(*state); PredictSystemLoads(*state, false, false, 0.01); - EXPECT_EQ(22.0, state->dataHeatBalFanSys->ZoneThermostatSetPointLo(1)); + EXPECT_EQ(22.0, state->dataHeatBalFanSys->zoneTstatSetpts(1).setptLo); state->dataZoneCtrls->TempControlledZone(1).HeatModeLast = false; // SingleCoolingSetPoint - state->dataScheduleMgr->Schedule(1).CurrentValue = 2; - state->dataZoneCtrls->TempControlledZone(1).SchIndx_SingleCoolSetPoint = 3; - state->dataZoneTempPredictorCorrector->SetPointSingleCooling.allocate(1); - state->dataZoneTempPredictorCorrector->SetPointSingleCooling(1).TempSchedIndex = 3; - state->dataScheduleMgr->Schedule(3).CurrentValue = 26.0; + setptTypeSched->currentVal = (int)HVAC::SetptType::SingleCool; + state->dataZoneCtrls->TempControlledZone(1).setpts[(int)HVAC::SetptType::SingleCool].coolSetptSched = coolSetptSched; + state->dataZoneTempPredictorCorrector->tempSetptScheds[(int)HVAC::SetptType::SingleCool].allocate(1); + state->dataZoneTempPredictorCorrector->tempSetptScheds[(int)HVAC::SetptType::SingleCool](1).coolSched = coolSetptSched; + coolSetptSched->currentVal = 26.0; thisZoneHB.MAT = 25.0; thisZoneHB.T1 = thisZoneHB.MAT; state->dataZoneCtrls->TempControlledZone(1).CoolModeLast = true; CalcZoneAirTempSetPoints(*state); PredictSystemLoads(*state, false, false, 0.01); - EXPECT_EQ(26.0, state->dataHeatBalFanSys->ZoneThermostatSetPointHi(1)); + EXPECT_EQ(26.0, state->dataHeatBalFanSys->zoneTstatSetpts(1).setptHi); state->dataZoneCtrls->TempControlledZone(1).CoolModeLast = false; thisZoneHB.MAT = 27.0; thisZoneHB.T1 = thisZoneHB.MAT; CalcZoneAirTempSetPoints(*state); PredictSystemLoads(*state, false, false, 0.01); - EXPECT_EQ(24.0, state->dataHeatBalFanSys->ZoneThermostatSetPointHi(1)); + EXPECT_EQ(24.0, state->dataHeatBalFanSys->zoneTstatSetpts(1).setptHi); // SingleHeatCoolSetPoint - state->dataScheduleMgr->Schedule(1).CurrentValue = 3; - state->dataZoneCtrls->TempControlledZone(1).SchIndx_SingleHeatCoolSetPoint = 3; - state->dataZoneTempPredictorCorrector->SetPointSingleHeatCool.allocate(1); - state->dataZoneTempPredictorCorrector->SetPointSingleHeatCool(1).TempSchedIndex = 3; - state->dataScheduleMgr->Schedule(3).CurrentValue = 24.0; + setptTypeSched->currentVal = (int)HVAC::SetptType::SingleHeatCool; + state->dataZoneCtrls->TempControlledZone(1).setpts[(int)HVAC::SetptType::SingleHeatCool].heatSetptSched = heatSetptSched; + state->dataZoneCtrls->TempControlledZone(1).setpts[(int)HVAC::SetptType::SingleHeatCool].coolSetptSched = heatSetptSched; + state->dataZoneTempPredictorCorrector->tempSetptScheds[(int)HVAC::SetptType::SingleHeatCool].allocate(1); + state->dataZoneTempPredictorCorrector->tempSetptScheds[(int)HVAC::SetptType::SingleHeatCool](1).heatSched = heatSetptSched; + state->dataZoneTempPredictorCorrector->tempSetptScheds[(int)HVAC::SetptType::SingleHeatCool](1).coolSched = heatSetptSched; + heatSetptSched->currentVal = 24.0; thisZoneHB.MAT = 25.0; thisZoneHB.T1 = thisZoneHB.MAT; CalcZoneAirTempSetPoints(*state); PredictSystemLoads(*state, false, false, 0.01); - EXPECT_EQ(24.0, state->dataHeatBalFanSys->ZoneThermostatSetPointLo(1)); - EXPECT_EQ(24.0, state->dataHeatBalFanSys->ZoneThermostatSetPointHi(1)); - - // DualSetPointWithDeadBand : Adjust cooling setpoint - state->dataZoneTempPredictorCorrector->SetPointDualHeatCool.allocate(1); - state->dataScheduleMgr->Schedule(1).CurrentValue = 4; - state->dataZoneCtrls->TempControlledZone(1).SchIndx_DualSetPointWDeadBandHeat = 2; - state->dataZoneCtrls->TempControlledZone(1).SchIndx_DualSetPointWDeadBandCool = 3; - state->dataZoneTempPredictorCorrector->SetPointDualHeatCool(1).HeatTempSchedIndex = 2; - state->dataZoneTempPredictorCorrector->SetPointDualHeatCool(1).CoolTempSchedIndex = 3; - state->dataScheduleMgr->Schedule(2).CurrentValue = 22.0; - state->dataScheduleMgr->Schedule(3).CurrentValue = 26.0; + EXPECT_EQ(24.0, state->dataHeatBalFanSys->zoneTstatSetpts(1).setptLo); + EXPECT_EQ(24.0, state->dataHeatBalFanSys->zoneTstatSetpts(1).setptHi); + + // DualHeatCool : Adjust cooling setpoint + state->dataZoneTempPredictorCorrector->tempSetptScheds[(int)HVAC::SetptType::DualHeatCool].allocate(1); + setptTypeSched->currentVal = (int)HVAC::SetptType::DualHeatCool; + state->dataZoneCtrls->TempControlledZone(1).setpts[(int)HVAC::SetptType::DualHeatCool].heatSetptSched = heatSetptSched; + state->dataZoneCtrls->TempControlledZone(1).setpts[(int)HVAC::SetptType::DualHeatCool].coolSetptSched = coolSetptSched; + state->dataZoneTempPredictorCorrector->tempSetptScheds[(int)HVAC::SetptType::DualHeatCool](1).heatSched = heatSetptSched; + state->dataZoneTempPredictorCorrector->tempSetptScheds[(int)HVAC::SetptType::DualHeatCool](1).coolSched = coolSetptSched; + heatSetptSched->currentVal = 22.0; + coolSetptSched->currentVal = 26.0; thisZoneHB.MAT = 25.0; thisZoneHB.T1 = thisZoneHB.MAT; @@ -1302,38 +1292,36 @@ TEST_F(EnergyPlusFixture, SetPointWithCutoutDeltaT_test) state->dataZoneCtrls->TempControlledZone(1).HeatModeLast = true; CalcZoneAirTempSetPoints(*state); PredictSystemLoads(*state, false, false, 0.01); - EXPECT_EQ(22.0, state->dataHeatBalFanSys->ZoneThermostatSetPointLo(1)); - EXPECT_EQ(26.0, state->dataHeatBalFanSys->ZoneThermostatSetPointHi(1)); + EXPECT_EQ(22.0, state->dataHeatBalFanSys->zoneTstatSetpts(1).setptLo); + EXPECT_EQ(26.0, state->dataHeatBalFanSys->zoneTstatSetpts(1).setptHi); state->dataZoneCtrls->TempControlledZone(1).HeatModeLast = false; - // DualSetPointWithDeadBand : Adjust heating setpoint + // DualHeatCool : Adjust heating setpoint thisZoneHB.MAT = 21.0; thisZoneHB.T1 = thisZoneHB.MAT; CalcZoneAirTempSetPoints(*state); PredictSystemLoads(*state, false, false, 0.01); - EXPECT_EQ(24.0, state->dataHeatBalFanSys->ZoneThermostatSetPointLo(1)); - EXPECT_EQ(26.0, state->dataHeatBalFanSys->ZoneThermostatSetPointHi(1)); + EXPECT_EQ(24.0, state->dataHeatBalFanSys->zoneTstatSetpts(1).setptLo); + EXPECT_EQ(26.0, state->dataHeatBalFanSys->zoneTstatSetpts(1).setptHi); - // DualSetPointWithDeadBand : Adjust cooling setpoint + // DualHeatCool : Adjust cooling setpoint state->dataZoneCtrls->TempControlledZone(1).CoolModeLast = true; thisZoneHB.MAT = 27.0; thisZoneHB.T1 = thisZoneHB.MAT; CalcZoneAirTempSetPoints(*state); PredictSystemLoads(*state, false, false, 0.01); - EXPECT_EQ(22.0, state->dataHeatBalFanSys->ZoneThermostatSetPointLo(1)); - EXPECT_EQ(24.0, state->dataHeatBalFanSys->ZoneThermostatSetPointHi(1)); + EXPECT_EQ(22.0, state->dataHeatBalFanSys->zoneTstatSetpts(1).setptLo); + EXPECT_EQ(24.0, state->dataHeatBalFanSys->zoneTstatSetpts(1).setptHi); } TEST_F(EnergyPlusFixture, TempAtPrevTimeStepWithCutoutDeltaT_test) { - state->dataScheduleMgr->Schedule.allocate(3); + state->init_state(*state); state->dataZoneCtrls->NumTempControlledZones = 1; // SingleHeatingSetPoint state->dataZoneCtrls->TempControlledZone.allocate(state->dataZoneCtrls->NumTempControlledZones); - state->dataHeatBalFanSys->TempZoneThermostatSetPoint.allocate(1); - state->dataHeatBalFanSys->ZoneThermostatSetPointLo.allocate(1); - state->dataHeatBalFanSys->ZoneThermostatSetPointHi.allocate(1); + state->dataHeatBalFanSys->zoneTstatSetpts.allocate(1); state->dataZoneEnergyDemand->ZoneSysEnergyDemand.allocate(1); state->dataZoneEnergyDemand->DeadBandOrSetback.allocate(1); state->dataHeatBal->Zone.allocate(1); @@ -1347,14 +1335,20 @@ TEST_F(EnergyPlusFixture, TempAtPrevTimeStepWithCutoutDeltaT_test) state->dataZoneCtrls->TempControlledZone(1).DeltaTCutSet = 2.0; state->dataZoneCtrls->TempControlledZone(1).ActualZoneNum = 1; - state->dataZoneCtrls->TempControlledZone(1).CTSchedIndex = 1; - state->dataScheduleMgr->Schedule(1).CurrentValue = 1; + + auto *setptTypeSched = Sched::AddScheduleConstant(*state, "SETPT TYPE-1"); + state->dataZoneCtrls->TempControlledZone(1).setptTypeSched = setptTypeSched; + setptTypeSched->currentVal = (int)HVAC::SetptType::SingleHeat; + + auto *heatSetptSched = Sched::AddScheduleConstant(*state, "HEAT SETPT-1"); + auto *coolSetptSched = Sched::AddScheduleConstant(*state, "COOL SETPT-1"); + state->dataHeatBalFanSys->TempControlType.allocate(1); state->dataHeatBalFanSys->TempControlTypeRpt.allocate(1); - state->dataZoneCtrls->TempControlledZone(1).SchIndx_SingleHeatSetPoint = 3; - state->dataZoneTempPredictorCorrector->SetPointSingleHeating.allocate(1); - state->dataZoneTempPredictorCorrector->SetPointSingleHeating(1).TempSchedIndex = 3; - state->dataScheduleMgr->Schedule(3).CurrentValue = 22.0; + state->dataZoneCtrls->TempControlledZone(1).setpts[(int)HVAC::SetptType::SingleHeat].heatSetptSched = heatSetptSched; + state->dataZoneTempPredictorCorrector->tempSetptScheds[(int)HVAC::SetptType::SingleHeat].allocate(1); + state->dataZoneTempPredictorCorrector->tempSetptScheds[(int)HVAC::SetptType::SingleHeat](1).heatSched = heatSetptSched; + heatSetptSched->currentVal = 22.0; state->dataZoneTempPredictorCorrector->spaceHeatBalance.allocate(1); state->dataZoneTempPredictorCorrector->zoneHeatBalance.allocate(1); auto &thisZoneHB = state->dataZoneTempPredictorCorrector->zoneHeatBalance(1); @@ -1368,56 +1362,58 @@ TEST_F(EnergyPlusFixture, TempAtPrevTimeStepWithCutoutDeltaT_test) CalcZoneAirTempSetPoints(*state); PredictSystemLoads(*state, false, false, 0.01); - EXPECT_EQ(24.0, state->dataHeatBalFanSys->ZoneThermostatSetPointLo(1)); + EXPECT_EQ(24.0, state->dataHeatBalFanSys->zoneTstatSetpts(1).setptLo); state->dataZoneCtrls->TempControlledZone(1).HeatModeLastSave = true; CalcZoneAirTempSetPoints(*state); PredictSystemLoads(*state, true, false, 0.01); - EXPECT_EQ(22.0, state->dataHeatBalFanSys->ZoneThermostatSetPointLo(1)); + EXPECT_EQ(22.0, state->dataHeatBalFanSys->zoneTstatSetpts(1).setptLo); // SingleCoolingSetPoint - state->dataScheduleMgr->Schedule(1).CurrentValue = 2; - state->dataZoneCtrls->TempControlledZone(1).SchIndx_SingleCoolSetPoint = 3; - state->dataZoneTempPredictorCorrector->SetPointSingleCooling.allocate(1); - state->dataZoneTempPredictorCorrector->SetPointSingleCooling(1).TempSchedIndex = 3; - state->dataScheduleMgr->Schedule(3).CurrentValue = 26.0; + setptTypeSched->currentVal = (int)HVAC::SetptType::SingleCool; + state->dataZoneCtrls->TempControlledZone(1).setpts[(int)HVAC::SetptType::SingleCool].coolSetptSched = coolSetptSched; + state->dataZoneTempPredictorCorrector->tempSetptScheds[(int)HVAC::SetptType::SingleCool].allocate(1); + state->dataZoneTempPredictorCorrector->tempSetptScheds[(int)HVAC::SetptType::SingleCool](1).coolSched = coolSetptSched; + coolSetptSched->currentVal = 26.0; thisZoneHB.MAT = 25.0; thisZoneHB.XMPT = 27; state->dataZoneCtrls->TempControlledZone(1).CoolModeLast = true; CalcZoneAirTempSetPoints(*state); PredictSystemLoads(*state, false, false, 0.01); - EXPECT_EQ(26.0, state->dataHeatBalFanSys->ZoneThermostatSetPointHi(1)); + EXPECT_EQ(26.0, state->dataHeatBalFanSys->zoneTstatSetpts(1).setptHi); state->dataZoneCtrls->TempControlledZone(1).CoolModeLast = false; state->dataZoneCtrls->TempControlledZone(1).CoolModeLastSave = true; CalcZoneAirTempSetPoints(*state); PredictSystemLoads(*state, true, false, 0.01); - EXPECT_EQ(24.0, state->dataHeatBalFanSys->ZoneThermostatSetPointHi(1)); + EXPECT_EQ(24.0, state->dataHeatBalFanSys->zoneTstatSetpts(1).setptHi); // SingleHeatCoolSetPoint - state->dataScheduleMgr->Schedule(1).CurrentValue = 3; - state->dataZoneCtrls->TempControlledZone(1).SchIndx_SingleHeatCoolSetPoint = 3; - state->dataZoneTempPredictorCorrector->SetPointSingleHeatCool.allocate(1); - state->dataZoneTempPredictorCorrector->SetPointSingleHeatCool(1).TempSchedIndex = 3; - state->dataScheduleMgr->Schedule(3).CurrentValue = 24.0; + setptTypeSched->currentVal = (int)HVAC::SetptType::SingleHeatCool; + state->dataZoneCtrls->TempControlledZone(1).setpts[(int)HVAC::SetptType::SingleHeatCool].heatSetptSched = heatSetptSched; + state->dataZoneCtrls->TempControlledZone(1).setpts[(int)HVAC::SetptType::SingleHeatCool].coolSetptSched = heatSetptSched; + state->dataZoneTempPredictorCorrector->tempSetptScheds[(int)HVAC::SetptType::SingleHeatCool].allocate(1); + state->dataZoneTempPredictorCorrector->tempSetptScheds[(int)HVAC::SetptType::SingleHeatCool](1).heatSched = heatSetptSched; + state->dataZoneTempPredictorCorrector->tempSetptScheds[(int)HVAC::SetptType::SingleHeatCool](1).coolSched = heatSetptSched; + heatSetptSched->currentVal = 24.0; thisZoneHB.MAT = 25.0; thisZoneHB.XMPT = thisZoneHB.MAT; CalcZoneAirTempSetPoints(*state); PredictSystemLoads(*state, false, false, 0.01); - EXPECT_EQ(24.0, state->dataHeatBalFanSys->ZoneThermostatSetPointLo(1)); - EXPECT_EQ(24.0, state->dataHeatBalFanSys->ZoneThermostatSetPointHi(1)); - - // DualSetPointWithDeadBand : Adjust cooling setpoint - state->dataZoneTempPredictorCorrector->SetPointDualHeatCool.allocate(1); - state->dataScheduleMgr->Schedule(1).CurrentValue = 4; - state->dataZoneCtrls->TempControlledZone(1).SchIndx_DualSetPointWDeadBandHeat = 2; - state->dataZoneCtrls->TempControlledZone(1).SchIndx_DualSetPointWDeadBandCool = 3; - state->dataZoneTempPredictorCorrector->SetPointDualHeatCool(1).HeatTempSchedIndex = 2; - state->dataZoneTempPredictorCorrector->SetPointDualHeatCool(1).CoolTempSchedIndex = 3; - state->dataScheduleMgr->Schedule(2).CurrentValue = 22.0; - state->dataScheduleMgr->Schedule(3).CurrentValue = 26.0; + EXPECT_EQ(24.0, state->dataHeatBalFanSys->zoneTstatSetpts(1).setptLo); + EXPECT_EQ(24.0, state->dataHeatBalFanSys->zoneTstatSetpts(1).setptHi); + + // DualHeatCool : Adjust cooling setpoint + setptTypeSched->currentVal = (int)HVAC::SetptType::DualHeatCool; + state->dataZoneTempPredictorCorrector->tempSetptScheds[(int)HVAC::SetptType::DualHeatCool].allocate(1); + state->dataZoneCtrls->TempControlledZone(1).setpts[(int)HVAC::SetptType::DualHeatCool].heatSetptSched = heatSetptSched; + state->dataZoneCtrls->TempControlledZone(1).setpts[(int)HVAC::SetptType::DualHeatCool].coolSetptSched = coolSetptSched; + state->dataZoneTempPredictorCorrector->tempSetptScheds[(int)HVAC::SetptType::DualHeatCool](1).heatSched = heatSetptSched; + state->dataZoneTempPredictorCorrector->tempSetptScheds[(int)HVAC::SetptType::DualHeatCool](1).coolSched = coolSetptSched; + heatSetptSched->currentVal = 22.0; + coolSetptSched->currentVal = 26.0; thisZoneHB.MAT = 25.0; thisZoneHB.XMPT = 21.0; @@ -1425,28 +1421,30 @@ TEST_F(EnergyPlusFixture, TempAtPrevTimeStepWithCutoutDeltaT_test) state->dataZoneCtrls->TempControlledZone(1).HeatModeLast = true; CalcZoneAirTempSetPoints(*state); PredictSystemLoads(*state, false, false, 0.01); - EXPECT_EQ(22.0, state->dataHeatBalFanSys->ZoneThermostatSetPointLo(1)); - EXPECT_EQ(26.0, state->dataHeatBalFanSys->ZoneThermostatSetPointHi(1)); + EXPECT_EQ(22.0, state->dataHeatBalFanSys->zoneTstatSetpts(1).setptLo); + EXPECT_EQ(26.0, state->dataHeatBalFanSys->zoneTstatSetpts(1).setptHi); state->dataZoneCtrls->TempControlledZone(1).HeatModeLast = false; - // DualSetPointWithDeadBand : Adjust heating setpoint + // DualHeatCool : Adjust heating setpoint state->dataZoneCtrls->TempControlledZone(1).HeatModeLastSave = true; CalcZoneAirTempSetPoints(*state); PredictSystemLoads(*state, true, false, 0.01); - EXPECT_EQ(24.0, state->dataHeatBalFanSys->ZoneThermostatSetPointLo(1)); - EXPECT_EQ(26.0, state->dataHeatBalFanSys->ZoneThermostatSetPointHi(1)); + EXPECT_EQ(24.0, state->dataHeatBalFanSys->zoneTstatSetpts(1).setptLo); + EXPECT_EQ(26.0, state->dataHeatBalFanSys->zoneTstatSetpts(1).setptHi); - // DualSetPointWithDeadBand : Adjust cooling setpoint + // DualHeatCool : Adjust cooling setpoint state->dataZoneCtrls->TempControlledZone(1).CoolModeLastSave = true; thisZoneHB.XMPT = 27.0; CalcZoneAirTempSetPoints(*state); PredictSystemLoads(*state, true, false, 0.01); - EXPECT_EQ(22.0, state->dataHeatBalFanSys->ZoneThermostatSetPointLo(1)); - EXPECT_EQ(24.0, state->dataHeatBalFanSys->ZoneThermostatSetPointHi(1)); + EXPECT_EQ(22.0, state->dataHeatBalFanSys->zoneTstatSetpts(1).setptLo); + EXPECT_EQ(24.0, state->dataHeatBalFanSys->zoneTstatSetpts(1).setptHi); } TEST_F(EnergyPlusFixture, ReportMoistLoadsZoneMultiplier_Test) { + state->init_state(*state); + int zoneNum = 1; state->dataZoneEnergyDemand->ZoneSysMoistureDemand.allocate(zoneNum); auto &thisZoneSysMoistureDemand = state->dataZoneEnergyDemand->ZoneSysMoistureDemand(zoneNum); @@ -1527,6 +1525,8 @@ TEST_F(EnergyPlusFixture, ReportMoistLoadsZoneMultiplier_Test) TEST_F(EnergyPlusFixture, ReportSensibleLoadsZoneMultiplier_Test) { + state->init_state(*state); + int zoneNum = 1; state->dataZoneEnergyDemand->ZoneSysEnergyDemand.allocate(zoneNum); auto &thisZoneSysEnergyDemand = state->dataZoneEnergyDemand->ZoneSysEnergyDemand(zoneNum); @@ -1654,9 +1654,11 @@ TEST_F(EnergyPlusFixture, ReportSensibleLoadsZoneMultiplier_Test) TEST_F(EnergyPlusFixture, DownInterpolate4HistoryValues_Test) { - Real64 PriorTimeStep = 0.25; state->dataHVACGlobal->TimeStepSys = 0.125; - state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::rSecsInHour; + state->init_state(*state); + + Real64 PriorTimeStep = 0.25; Real64 myVarValue = 5.0; Real64 HistoryValue1 = 1.0; Real64 HistoryValue2 = 2.0; @@ -1699,6 +1701,7 @@ TEST_F(EnergyPlusFixture, DownInterpolate4HistoryValues_Test) TEST_F(EnergyPlusFixture, HybridModel_processInverseModelMultpHMTest) { + state->init_state(*state); // Test added for fix to GitHub Issue #10508 Real64 calcHMmult; Real64 calcHMsum = 0.0; @@ -1768,7 +1771,8 @@ TEST_F(EnergyPlusFixture, HybridModel_processInverseModelMultpHMTest) EXPECT_NE(state->dataZoneTempPredictorCorrector->zoneHeatBalance(numZones).hmThermalMassMultErrIndex, 0); // This is now set, won't be zero anymore std::string const error_string = - delimited_string({" ** Warning ** Hybrid model thermal mass multiplier higher than the limit for Hybrid Zone", + delimited_string({" ** Warning ** Version: missing in IDF, processing for EnergyPlus version=\"24.2\"", + " ** Warning ** Hybrid model thermal mass multiplier higher than the limit for Hybrid Zone", " ** ~~~ ** This means that the ratio of the zone air heat capacity for the current time step to the", " ** ~~~ ** zone air heat storage is higher than the maximum limit of 30.0."}); EXPECT_TRUE(compare_err_stream(error_string, true)); @@ -1789,11 +1793,9 @@ TEST_F(EnergyPlusFixture, HybridModel_processInverseModelMultpHMTest) TEST_F(EnergyPlusFixture, FillPredefinedTableOnThermostatSchedules_Test) { + state->init_state(*state); using namespace EnergyPlus::OutputReportPredefined; - state->dataScheduleMgr->Schedule.allocate(5); - state->dataScheduleMgr->ScheduleInputProcessed = true; - auto &orp = *state->dataOutRptPredefined; auto &dzc = *state->dataZoneCtrls; @@ -1804,49 +1806,29 @@ TEST_F(EnergyPlusFixture, FillPredefinedTableOnThermostatSchedules_Test) dzc.TempControlledZone(1).ZoneName = "zoneA"; dzc.TempControlledZone(1).Name = "stat A"; - dzc.TempControlledZone(1).ControlTypeSchedName = "control schedule A"; - dzc.TempControlledZone(1).NumControlTypes = 1; - dzc.TempControlledZone(1).ControlTypeEnum.allocate(dzc.TempControlledZone(1).NumControlTypes); - dzc.TempControlledZone(1).ControlTypeName.allocate(dzc.TempControlledZone(1).NumControlTypes); - dzc.TempControlledZone(1).ControlTypeEnum(1) = HVAC::ThermostatType::SingleHeating; - dzc.TempControlledZone(1).ControlTypeName(1) = "control A"; - dzc.TempControlledZone(1).SchIndx_SingleHeatSetPoint = 1; - state->dataScheduleMgr->Schedule(1).Name = "schA"; + dzc.TempControlledZone(1).setptTypeSched = Sched::AddScheduleConstant(*state, "control schedule A"); + dzc.TempControlledZone(1).setpts[(int)HVAC::SetptType::SingleHeat].Name = "control A"; + dzc.TempControlledZone(1).setpts[(int)HVAC::SetptType::SingleHeat].heatSetptSched = Sched::AddScheduleConstant(*state, "schA"); dzc.TempControlledZone(2).ZoneName = "zoneB"; dzc.TempControlledZone(2).Name = "stat B"; - dzc.TempControlledZone(2).ControlTypeSchedName = "control schedule B"; - dzc.TempControlledZone(2).NumControlTypes = 1; - dzc.TempControlledZone(2).ControlTypeEnum.allocate(dzc.TempControlledZone(1).NumControlTypes); - dzc.TempControlledZone(2).ControlTypeName.allocate(dzc.TempControlledZone(1).NumControlTypes); - dzc.TempControlledZone(2).ControlTypeEnum(1) = HVAC::ThermostatType::SingleCooling; - dzc.TempControlledZone(2).ControlTypeName(1) = "control B"; - dzc.TempControlledZone(2).SchIndx_SingleCoolSetPoint = 2; - state->dataScheduleMgr->Schedule(2).Name = "schB"; + dzc.TempControlledZone(2).setptTypeSched = Sched::AddScheduleConstant(*state, "control schedule B"); + dzc.TempControlledZone(2).setpts[(int)HVAC::SetptType::SingleCool].Name = "control B"; + dzc.TempControlledZone(2).setpts[(int)HVAC::SetptType::SingleCool].coolSetptSched = Sched::AddScheduleConstant(*state, "schB"); dzc.TempControlledZone(3).ZoneName = "zoneC"; dzc.TempControlledZone(3).Name = "stat C"; - dzc.TempControlledZone(3).ControlTypeSchedName = "control schedule C"; - dzc.TempControlledZone(3).NumControlTypes = 1; - dzc.TempControlledZone(3).ControlTypeEnum.allocate(dzc.TempControlledZone(1).NumControlTypes); - dzc.TempControlledZone(3).ControlTypeName.allocate(dzc.TempControlledZone(1).NumControlTypes); - dzc.TempControlledZone(3).ControlTypeEnum(1) = HVAC::ThermostatType::SingleHeatCool; - dzc.TempControlledZone(3).ControlTypeName(1) = "control C"; - dzc.TempControlledZone(3).SchIndx_SingleHeatCoolSetPoint = 3; - state->dataScheduleMgr->Schedule(3).Name = "schC"; + dzc.TempControlledZone(3).setptTypeSched = Sched::AddScheduleConstant(*state, "control schedule C"); + dzc.TempControlledZone(3).setpts[(int)HVAC::SetptType::SingleHeatCool].Name = "control C"; + dzc.TempControlledZone(3).setpts[(int)HVAC::SetptType::SingleHeatCool].heatSetptSched = Sched::AddScheduleConstant(*state, "schC"); + dzc.TempControlledZone(3).setpts[(int)HVAC::SetptType::SingleHeatCool].coolSetptSched = Sched::GetSchedule(*state, "SCHC"); dzc.TempControlledZone(4).ZoneName = "zoneD"; dzc.TempControlledZone(4).Name = "stat D"; - dzc.TempControlledZone(4).ControlTypeSchedName = "control schedule D"; - dzc.TempControlledZone(4).NumControlTypes = 1; - dzc.TempControlledZone(4).ControlTypeEnum.allocate(dzc.TempControlledZone(1).NumControlTypes); - dzc.TempControlledZone(4).ControlTypeName.allocate(dzc.TempControlledZone(1).NumControlTypes); - dzc.TempControlledZone(4).ControlTypeEnum(1) = HVAC::ThermostatType::DualSetPointWithDeadBand; - dzc.TempControlledZone(4).ControlTypeName(1) = "control D"; - dzc.TempControlledZone(4).SchIndx_DualSetPointWDeadBandHeat = 4; - dzc.TempControlledZone(4).SchIndx_DualSetPointWDeadBandCool = 5; - state->dataScheduleMgr->Schedule(4).Name = "schD"; - state->dataScheduleMgr->Schedule(5).Name = "schE"; + dzc.TempControlledZone(4).setptTypeSched = Sched::AddScheduleConstant(*state, "control schedule D"); + dzc.TempControlledZone(4).setpts[(int)HVAC::SetptType::DualHeatCool].Name = "control D"; + dzc.TempControlledZone(4).setpts[(int)HVAC::SetptType::DualHeatCool].heatSetptSched = Sched::AddScheduleConstant(*state, "schD"); + dzc.TempControlledZone(4).setpts[(int)HVAC::SetptType::DualHeatCool].coolSetptSched = Sched::AddScheduleConstant(*state, "schE"); FillPredefinedTableOnThermostatSchedules(*state); @@ -1854,15 +1836,15 @@ TEST_F(EnergyPlusFixture, FillPredefinedTableOnThermostatSchedules_Test) EXPECT_EQ("control schedule A", RetrievePreDefTableEntry(*state, orp.pdchStatCtrlTypeSchd, "zoneA")); EXPECT_EQ("SingleHeating", RetrievePreDefTableEntry(*state, orp.pdchStatSchdType1, "zoneA")); EXPECT_EQ("control A", RetrievePreDefTableEntry(*state, orp.pdchStatSchdTypeName1, "zoneA")); - EXPECT_EQ("schA", RetrievePreDefTableEntry(*state, orp.pdchStatSchdCoolName, "zoneA")); - EXPECT_EQ("NOT FOUND", RetrievePreDefTableEntry(*state, orp.pdchStatSchdHeatName, "zoneA")); + EXPECT_EQ("schA", RetrievePreDefTableEntry(*state, orp.pdchStatSchdHeatName, "zoneA")); + EXPECT_EQ("NOT FOUND", RetrievePreDefTableEntry(*state, orp.pdchStatSchdCoolName, "zoneA")); EXPECT_EQ("stat B", RetrievePreDefTableEntry(*state, orp.pdchStatName, "zoneB")); EXPECT_EQ("control schedule B", RetrievePreDefTableEntry(*state, orp.pdchStatCtrlTypeSchd, "zoneB")); EXPECT_EQ("SingleCooling", RetrievePreDefTableEntry(*state, orp.pdchStatSchdType1, "zoneB")); EXPECT_EQ("control B", RetrievePreDefTableEntry(*state, orp.pdchStatSchdTypeName1, "zoneB")); - EXPECT_EQ("NOT FOUND", RetrievePreDefTableEntry(*state, orp.pdchStatSchdCoolName, "zoneB")); - EXPECT_EQ("schB", RetrievePreDefTableEntry(*state, orp.pdchStatSchdHeatName, "zoneB")); + EXPECT_EQ("NOT FOUND", RetrievePreDefTableEntry(*state, orp.pdchStatSchdHeatName, "zoneB")); + EXPECT_EQ("schB", RetrievePreDefTableEntry(*state, orp.pdchStatSchdCoolName, "zoneB")); EXPECT_EQ("stat C", RetrievePreDefTableEntry(*state, orp.pdchStatName, "zoneC")); EXPECT_EQ("control schedule C", RetrievePreDefTableEntry(*state, orp.pdchStatCtrlTypeSchd, "zoneC")); From d0b7ff98f8f5370e99669b2b40e67162c7285eef Mon Sep 17 00:00:00 2001 From: amirroth Date: Sat, 7 Dec 2024 15:50:45 -0500 Subject: [PATCH 2/3] First round of fixes --- src/EnergyPlus/AirflowNetwork/src/Solver.cpp | 2 +- src/EnergyPlus/Data/EnergyPlusData.cc | 13 +- src/EnergyPlus/DataRuntimeLanguage.hh | 7 +- src/EnergyPlus/DaylightingDevices.cc | 3 +- src/EnergyPlus/EMSManager.cc | 208 ++++++----------- src/EnergyPlus/EMSManager.hh | 1 + src/EnergyPlus/HeatBalanceAirManager.cc | 2 + src/EnergyPlus/InternalHeatGains.cc | 21 +- src/EnergyPlus/RefrigeratedCase.cc | 19 +- src/EnergyPlus/ScheduleManager.cc | 203 ++++++---------- src/EnergyPlus/ScheduleManager.hh | 26 ++- src/EnergyPlus/SystemAvailabilityManager.cc | 20 +- src/EnergyPlus/WeatherManager.cc | 219 +++++++++--------- src/EnergyPlus/WeatherManager.hh | 4 +- .../ZoneContaminantPredictorCorrector.cc | 13 +- src/EnergyPlus/ZoneTempPredictorCorrector.cc | 37 ++- .../unit/HVACVariableRefrigerantFlow.unit.cc | 5 +- tst/EnergyPlus/unit/WeatherManager.unit.cc | 20 +- 18 files changed, 354 insertions(+), 469 deletions(-) diff --git a/src/EnergyPlus/AirflowNetwork/src/Solver.cpp b/src/EnergyPlus/AirflowNetwork/src/Solver.cpp index d723f952b8d..26ddf6acdf7 100644 --- a/src/EnergyPlus/AirflowNetwork/src/Solver.cpp +++ b/src/EnergyPlus/AirflowNetwork/src/Solver.cpp @@ -3283,7 +3283,7 @@ namespace AirflowNetwork { case VentControlType::CEN15251: case VentControlType::NoVent: case VentControlType::ZoneLevel: { - MultizoneSurfaceData(i).ventSched = nullptr; + MultizoneSurfaceData(i).ventSched = Sched::GetScheduleAlwaysOff(m_state); MultizoneSurfaceData(i).VentSchName = ""; } break; default: diff --git a/src/EnergyPlus/Data/EnergyPlusData.cc b/src/EnergyPlus/Data/EnergyPlusData.cc index e4acd4bb0bd..e86c26da0c4 100644 --- a/src/EnergyPlus/Data/EnergyPlusData.cc +++ b/src/EnergyPlus/Data/EnergyPlusData.cc @@ -578,9 +578,11 @@ void EnergyPlusData::init_constant_state(EnergyPlusData &state) this->init_constant_state_called = true; - this->dataSimulationManager->init_constant_state(state); // GetProjectData - this->dataFluidProps->init_constant_state(state); // GetFluidPropertiesData - this->dataPsychrometrics->init_constant_state(state); // InitializePsychRoutines + // The order of these should not matter, but we are mirroring init_state() order which does matter. + this->dataSimulationManager->init_constant_state(state); + this->dataEMSMgr->init_constant_state(state); + this->dataFluidProps->init_constant_state(state); + this->dataPsychrometrics->init_constant_state(state); this->dataSched->init_constant_state(state); this->dataAirLoop->init_constant_state(state); @@ -629,7 +631,6 @@ void EnergyPlusData::init_constant_state(EnergyPlusData &state) this->dataDualDuct->init_constant_state(state); this->dataEIRFuelFiredHeatPump->init_constant_state(state); this->dataEIRPlantLoopHeatPump->init_constant_state(state); - this->dataEMSMgr->init_constant_state(state); this->dataEarthTube->init_constant_state(state); this->dataEcoRoofMgr->init_constant_state(state); this->dataEconLifeCycleCost->init_constant_state(state); @@ -842,9 +843,10 @@ void EnergyPlusData::init_state(EnergyPlusData &state) // objects that do not reference any other objects, like fluids, // schedules, curves, etc. this->dataSimulationManager->init_state(state); // GetProjectData + this->dataEMSMgr->init_state(state); // CheckIfAnyEMS this->dataFluidProps->init_state(state); // GetFluidPropertiesData this->dataPsychrometrics->init_state(state); // InitializePsychRoutines - this->dataSched->init_state(state); + this->dataSched->init_state(state); // GetScheduleData this->dataAirLoop->init_state(state); this->dataAirLoopHVACDOAS->init_state(state); @@ -892,7 +894,6 @@ void EnergyPlusData::init_state(EnergyPlusData &state) this->dataDualDuct->init_state(state); this->dataEIRFuelFiredHeatPump->init_state(state); this->dataEIRPlantLoopHeatPump->init_state(state); - this->dataEMSMgr->init_state(state); this->dataEarthTube->init_state(state); this->dataEcoRoofMgr->init_state(state); this->dataEconLifeCycleCost->init_state(state); diff --git a/src/EnergyPlus/DataRuntimeLanguage.hh b/src/EnergyPlus/DataRuntimeLanguage.hh index 96b320081b2..451d0c59e24 100644 --- a/src/EnergyPlus/DataRuntimeLanguage.hh +++ b/src/EnergyPlus/DataRuntimeLanguage.hh @@ -806,9 +806,7 @@ struct RuntimeLanguageData : BaseGlobalStruct DataRuntimeLanguage::ErlValueType True = DataRuntimeLanguage::ErlValueType( DataRuntimeLanguage::Value::Null, 0.0, "", 0, 0, false, 0, "", true); // special "True" Erl variable value instance, gets reset - // EMS Actuator fast duplicate check lookup support - std::unordered_set, DataRuntimeLanguage::EMSActuatorKey_hash> - EMSActuator_lookup; // Fast duplicate lookup structure + std::map, int> EMSActuatorAvailableMap; void init_constant_state([[maybe_unused]] EnergyPlusData &state) override { @@ -865,10 +863,11 @@ struct RuntimeLanguageData : BaseGlobalStruct this->EMSInternalVarsAvailable.deallocate(); this->EMSInternalVarsUsed.deallocate(); this->EMSProgramCallManager.deallocate(); - this->EMSActuator_lookup.clear(); this->Null = DataRuntimeLanguage::ErlValueType(DataRuntimeLanguage::Value::Null, 0.0, "", 0, 0, false, 0, "", true); this->False = DataRuntimeLanguage::ErlValueType(DataRuntimeLanguage::Value::Null, 0.0, "", 0, 0, false, 0, "", true); this->True = DataRuntimeLanguage::ErlValueType(DataRuntimeLanguage::Value::Null, 0.0, "", 0, 0, false, 0, "", true); + + this->EMSActuatorAvailableMap.clear(); } }; diff --git a/src/EnergyPlus/DaylightingDevices.cc b/src/EnergyPlus/DaylightingDevices.cc index 46e5f88843a..ef763fe0355 100644 --- a/src/EnergyPlus/DaylightingDevices.cc +++ b/src/EnergyPlus/DaylightingDevices.cc @@ -919,7 +919,8 @@ namespace Dayltg { state.dataDaylightingDevices->GetShelfInputErrorsFound = true; } - if (state.dataSurface->Surface(SurfNum).shadowSurfSched != nullptr) { + if (state.dataSurface->Surface(SurfNum).shadowSurfSched != nullptr && + state.dataSurface->Surface(SurfNum).shadowSurfSched != Sched::GetScheduleAlwaysOff(state)) { ShowSevereError(state, format("{} = {}: Outside shelf {} must not have a transmittance schedule.", cCurrentModuleObject, diff --git a/src/EnergyPlus/EMSManager.cc b/src/EnergyPlus/EMSManager.cc index 7c33814d603..dc0b10fc736 100644 --- a/src/EnergyPlus/EMSManager.cc +++ b/src/EnergyPlus/EMSManager.cc @@ -747,25 +747,16 @@ namespace EMSManager { thisEMSactuator.UniqueIDName = cAlphaArgs(2); thisEMSactuator.ControlTypeName = cAlphaArgs(4); - int ActuatorVariableNum; - bool FoundActuatorName = false; - for (ActuatorVariableNum = 1; ActuatorVariableNum <= state.dataRuntimeLang->numEMSActuatorsAvailable; ++ActuatorVariableNum) { - if (Util::SameString(state.dataRuntimeLang->EMSActuatorAvailable(ActuatorVariableNum).ComponentTypeName, cAlphaArgs(3))) { - if (Util::SameString(state.dataRuntimeLang->EMSActuatorAvailable(ActuatorVariableNum).UniqueIDName, cAlphaArgs(2))) { - if (Util::SameString(state.dataRuntimeLang->EMSActuatorAvailable(ActuatorVariableNum).ControlTypeName, cAlphaArgs(4))) { - FoundActuatorName = true; - break; - } - } - } - } + auto found = state.dataRuntimeLang->EMSActuatorAvailableMap.find(std::make_tuple(thisEMSactuator.ComponentTypeName, + thisEMSactuator.UniqueIDName, + thisEMSactuator.ControlTypeName)); + if (found != state.dataRuntimeLang->EMSActuatorAvailableMap.end()) { - if (FoundActuatorName) { // SetupNodeSetPointAsActuators has NOT been called yet at this point - thisEMSactuator.ActuatorVariableNum = ActuatorVariableNum; + thisEMSactuator.ActuatorVariableNum = found->second; thisEMSactuator.CheckedOkay = true; - int nHandle = state.dataRuntimeLang->EMSActuatorAvailable(ActuatorVariableNum).handleCount; + int nHandle = state.dataRuntimeLang->EMSActuatorAvailable(found->second).handleCount; if (nHandle > 0) { EnergyPlus::ShowWarningError(state, format("Seems like you already tried to get a Handle on this Actuator {}times.", nHandle)); @@ -776,7 +767,7 @@ namespace EMSManager { thisEMSactuator.UniqueIDName)); EnergyPlus::ShowContinueError(state, "You should take note that there is a risk of overwritting."); } - ++state.dataRuntimeLang->EMSActuatorAvailable(ActuatorVariableNum).handleCount; + ++state.dataRuntimeLang->EMSActuatorAvailable(found->second).handleCount; } } // ActuatorNum } @@ -1017,6 +1008,8 @@ namespace EMSManager { } // SensorNum + auto &s_lang = state.dataRuntimeLang; + // added for FMU for (int ActuatorNum = 1; ActuatorNum <= state.dataRuntimeLang->numActuatorsUsed + state.dataRuntimeLang->NumExternalInterfaceActuatorsUsed + state.dataRuntimeLang->NumExternalInterfaceFunctionalMockupUnitImportActuatorsUsed + @@ -1037,33 +1030,15 @@ namespace EMSManager { cCurrentModuleObject = "ExternalInterface:FunctionalMockupUnitExport:To:Actuator"; } - if (state.dataRuntimeLang->EMSActuatorUsed(ActuatorNum).CheckedOkay) continue; - FoundObjectType = false; - FoundObjectName = false; - FoundActuatorName = false; - for (ActuatorVariableNum = 1; ActuatorVariableNum <= state.dataRuntimeLang->numEMSActuatorsAvailable; ++ActuatorVariableNum) { - if (Util::SameString(state.dataRuntimeLang->EMSActuatorAvailable(ActuatorVariableNum).ComponentTypeName, - state.dataRuntimeLang->EMSActuatorUsed(ActuatorNum).ComponentTypeName)) { - FoundObjectType = true; - if (Util::SameString(state.dataRuntimeLang->EMSActuatorAvailable(ActuatorVariableNum).UniqueIDName, - state.dataRuntimeLang->EMSActuatorUsed(ActuatorNum).UniqueIDName)) { - FoundObjectName = true; - if (Util::SameString(state.dataRuntimeLang->EMSActuatorAvailable(ActuatorVariableNum).ControlTypeName, - state.dataRuntimeLang->EMSActuatorUsed(ActuatorNum).ControlTypeName)) { - FoundActuatorName = true; - break; - } - } - } - } - - if (!FoundObjectType) { + auto &actuatorUsed = state.dataRuntimeLang->EMSActuatorUsed(ActuatorNum); + if (actuatorUsed.CheckedOkay) continue; + + auto found = s_lang->EMSActuatorAvailableMap.find(std::make_tuple(actuatorUsed.ComponentTypeName, actuatorUsed.UniqueIDName, actuatorUsed.ControlTypeName)); + if (found == s_lang->EMSActuatorAvailableMap.end()) { if (reportErrors) { - ShowSevereError( - state, format("Invalid Actuated Component Type ={}", state.dataRuntimeLang->EMSActuatorUsed(ActuatorNum).ComponentTypeName)); - ShowContinueError(state, - format("Entered in {}={}", cCurrentModuleObject, state.dataRuntimeLang->EMSActuatorUsed(ActuatorNum).Name)); - ShowContinueError(state, "Component Type not found"); + ShowSevereError(state, format("Actuator {} = {} not found.", cCurrentModuleObject, actuatorUsed.Name)); + ShowContinueError(state, format("Combination of ObjectType = {}, ObjectName = {}, and ControlType = {} not available.", + actuatorUsed.ComponentTypeName, actuatorUsed.UniqueIDName, actuatorUsed.ControlTypeName)); if (state.dataRuntimeLang->OutputEDDFile) { ShowContinueError(state, "Review .edd file for valid component types."); } else { @@ -1071,65 +1046,28 @@ namespace EMSManager { } ErrorsFound = true; } - } - - if (!FoundObjectName) { - if (reportErrors) { - ShowSevereError( - state, - format("Invalid Actuated Component Unique Name ={}", state.dataRuntimeLang->EMSActuatorUsed(ActuatorNum).UniqueIDName)); - ShowContinueError(state, - format("Entered in {}={}", cCurrentModuleObject, state.dataRuntimeLang->EMSActuatorUsed(ActuatorNum).Name)); - ShowContinueError(state, "Component Unique key name not found "); - if (state.dataRuntimeLang->OutputEDDFile) { - ShowContinueError(state, "Review edd file for valid component names."); - } else { - ShowContinueError(state, "Use Output:EnergyManagementSystem object to create .edd file for valid component names."); - } - ErrorsFound = true; - } - } - if (!FoundActuatorName) { - if (reportErrors) { - ShowSevereError( - state, - format("Invalid Actuated Component Control Type ={}", state.dataRuntimeLang->EMSActuatorUsed(ActuatorNum).ControlTypeName)); - ShowContinueError(state, - format("Entered in {}={}", cCurrentModuleObject, state.dataRuntimeLang->EMSActuatorUsed(ActuatorNum).Name)); - ShowContinueError(state, "Control Type not found"); - if (state.dataRuntimeLang->OutputEDDFile) { - ShowContinueError(state, "Review edd file for valid component control types."); - } else { - ShowContinueError(state, "Use Output:EnergyManagementSystem object to create .edd file for valid component control types."); - } - ErrorsFound = true; - } } else { - state.dataRuntimeLang->EMSActuatorUsed(ActuatorNum).ActuatorVariableNum = ActuatorVariableNum; - state.dataRuntimeLang->EMSActuatorUsed(ActuatorNum).CheckedOkay = true; - int nHandle = state.dataRuntimeLang->EMSActuatorAvailable(ActuatorVariableNum).handleCount; + actuatorUsed.ActuatorVariableNum = found->second; + actuatorUsed.CheckedOkay = true; + int nHandle = s_lang->EMSActuatorAvailable(found->second).handleCount; if (nHandle > 0) { EnergyPlus::ShowWarningError(state, format("Seems like you already tried to get a Handle on this Actuator {}times.", nHandle)); - EnergyPlus::ShowContinueError(state, - format("Occurred for componentType='{}', controlType='{}', uniqueKey='{}'.", - state.dataRuntimeLang->EMSActuatorUsed(ActuatorNum).ComponentTypeName, - state.dataRuntimeLang->EMSActuatorUsed(ActuatorNum).ControlTypeName, - state.dataRuntimeLang->EMSActuatorUsed(ActuatorNum).UniqueIDName)); + EnergyPlus::ShowContinueError(state, format("Occurred for componentType='{}', controlType='{}', uniqueKey='{}'.", + actuatorUsed.ComponentTypeName, actuatorUsed.ControlTypeName, actuatorUsed.UniqueIDName)); EnergyPlus::ShowContinueError(state, "You should take note that there is a risk of overwritting."); } - ++state.dataRuntimeLang->EMSActuatorAvailable(ActuatorVariableNum).handleCount; + ++s_lang->EMSActuatorAvailable(found->second).handleCount; // Warn if actuator applied to an air boundary surface - if (Util::SameString(state.dataRuntimeLang->EMSActuatorUsed(ActuatorNum).ComponentTypeName, "AIRFLOW NETWORK WINDOW/DOOR OPENING")) { - int actuatedSurfNum = - Util::FindItemInList(state.dataRuntimeLang->EMSActuatorUsed(ActuatorNum).UniqueIDName, state.dataSurface->Surface); + if (Util::SameString(actuatorUsed.ComponentTypeName, "AIRFLOW NETWORK WINDOW/DOOR OPENING")) { + int actuatedSurfNum = Util::FindItemInList(actuatorUsed.UniqueIDName, state.dataSurface->Surface); if (actuatedSurfNum > 0) { if (state.dataSurface->Surface(actuatedSurfNum).IsAirBoundarySurf) { ShowWarningError( state, format("GetEMSInput: EnergyManagementSystem:Actuator={} actuates an opening attached to an air boundary surface.", - state.dataRuntimeLang->EMSActuatorUsed(ActuatorNum).Name)); + actuatorUsed.Name)); } } } @@ -2041,25 +1979,27 @@ void SetupEMSActuator(EnergyPlusData &state, // push size of ActuatorVariable and add a new one. // check for duplicates. - std::string const UpperCaseObjectType(Util::makeUPPER(cComponentTypeName)); - std::string const UpperCaseObjectName(Util::makeUPPER(cUniqueIDName)); - std::string const UpperCaseActuatorName(Util::makeUPPER(cControlTypeName)); - - DataRuntimeLanguage::EMSActuatorKey const key(UpperCaseObjectType, UpperCaseObjectName, UpperCaseActuatorName); - - if (state.dataRuntimeLang->EMSActuator_lookup.find(key) == state.dataRuntimeLang->EMSActuator_lookup.end()) { - if (state.dataRuntimeLang->numEMSActuatorsAvailable == 0) { - state.dataRuntimeLang->EMSActuatorAvailable.allocate(state.dataRuntimeLang->varsAvailableAllocInc); - state.dataRuntimeLang->numEMSActuatorsAvailable = 1; - state.dataRuntimeLang->maxEMSActuatorsAvailable = state.dataRuntimeLang->varsAvailableAllocInc; + auto &s_lang = state.dataRuntimeLang; + + std::string const objType = Util::makeUPPER(cComponentTypeName); + std::string const objName = Util::makeUPPER(cUniqueIDName); + std::string const actuatorName = Util::makeUPPER(cControlTypeName); + + // DataRuntimeLanguage::EMSActuatorKey const key(UpperCaseObjectType, UpperCaseObjectName, UpperCaseActuatorName); + auto found = s_lang->EMSActuatorAvailableMap.find(std::make_tuple(objType, objName, actuatorName)); + if (found == s_lang->EMSActuatorAvailableMap.end()) { + if (s_lang->numEMSActuatorsAvailable == 0) { + s_lang->EMSActuatorAvailable.allocate(s_lang->varsAvailableAllocInc); + s_lang->numEMSActuatorsAvailable = 1; + s_lang->maxEMSActuatorsAvailable = s_lang->varsAvailableAllocInc; } else { - if (state.dataRuntimeLang->numEMSActuatorsAvailable + 1 > state.dataRuntimeLang->maxEMSActuatorsAvailable) { - state.dataRuntimeLang->EMSActuatorAvailable.redimension(state.dataRuntimeLang->maxEMSActuatorsAvailable *= 2); + if (s_lang->numEMSActuatorsAvailable + 1 > s_lang->maxEMSActuatorsAvailable) { + s_lang->EMSActuatorAvailable.redimension(s_lang->maxEMSActuatorsAvailable *= 2); } - ++state.dataRuntimeLang->numEMSActuatorsAvailable; + ++s_lang->numEMSActuatorsAvailable; } - auto &actuator(state.dataRuntimeLang->EMSActuatorAvailable(state.dataRuntimeLang->numEMSActuatorsAvailable)); + auto &actuator = s_lang->EMSActuatorAvailable(s_lang->numEMSActuatorsAvailable); actuator.ComponentTypeName = cComponentTypeName; actuator.UniqueIDName = cUniqueIDName; actuator.ControlTypeName = cControlTypeName; @@ -2067,7 +2007,7 @@ void SetupEMSActuator(EnergyPlusData &state, actuator.Actuated = &lEMSActuated; // Pointer assigment actuator.RealValue = &rValue; // Pointer assigment actuator.PntrVarTypeUsed = DataRuntimeLanguage::PtrDataType::Real; - state.dataRuntimeLang->EMSActuator_lookup.insert(key); + s_lang->EMSActuatorAvailableMap.insert_or_assign(std::make_tuple(objType, objName, actuatorName), s_lang->numEMSActuatorsAvailable); } } @@ -2092,25 +2032,27 @@ void SetupEMSActuator(EnergyPlusData &state, // push size of ActuatorVariable and add a new one. // check for duplicates. - std::string const UpperCaseObjectType(Util::makeUPPER(cComponentTypeName)); - std::string const UpperCaseObjectName(Util::makeUPPER(cUniqueIDName)); - std::string const UpperCaseActuatorName(Util::makeUPPER(cControlTypeName)); + auto &s_lang = state.dataRuntimeLang; + + std::string const objType = Util::makeUPPER(cComponentTypeName); + std::string const objName = Util::makeUPPER(cUniqueIDName); + std::string const actuatorName = Util::makeUPPER(cControlTypeName); - DataRuntimeLanguage::EMSActuatorKey const key(UpperCaseObjectType, UpperCaseObjectName, UpperCaseActuatorName); + // DataRuntimeLanguage::EMSActuatorKey const key(UpperCaseObjectType, UpperCaseObjectName, UpperCaseActuatorName); - if (state.dataRuntimeLang->EMSActuator_lookup.find(key) == state.dataRuntimeLang->EMSActuator_lookup.end()) { - if (state.dataRuntimeLang->numEMSActuatorsAvailable == 0) { - state.dataRuntimeLang->EMSActuatorAvailable.allocate(state.dataRuntimeLang->varsAvailableAllocInc); - state.dataRuntimeLang->numEMSActuatorsAvailable = 1; - state.dataRuntimeLang->maxEMSActuatorsAvailable = state.dataRuntimeLang->varsAvailableAllocInc; + if (s_lang->EMSActuatorAvailableMap.find(std::make_tuple(objType, objName, actuatorName)) == s_lang->EMSActuatorAvailableMap.end()) { + if (s_lang->numEMSActuatorsAvailable == 0) { + s_lang->EMSActuatorAvailable.allocate(s_lang->varsAvailableAllocInc); + s_lang->numEMSActuatorsAvailable = 1; + s_lang->maxEMSActuatorsAvailable = s_lang->varsAvailableAllocInc; } else { - if (state.dataRuntimeLang->numEMSActuatorsAvailable + 1 > state.dataRuntimeLang->maxEMSActuatorsAvailable) { - state.dataRuntimeLang->EMSActuatorAvailable.redimension(state.dataRuntimeLang->maxEMSActuatorsAvailable *= 2); + if (s_lang->numEMSActuatorsAvailable + 1 > s_lang->maxEMSActuatorsAvailable) { + s_lang->EMSActuatorAvailable.redimension(s_lang->maxEMSActuatorsAvailable *= 2); } - ++state.dataRuntimeLang->numEMSActuatorsAvailable; + ++s_lang->numEMSActuatorsAvailable; } - auto &actuator(state.dataRuntimeLang->EMSActuatorAvailable(state.dataRuntimeLang->numEMSActuatorsAvailable)); + auto &actuator(s_lang->EMSActuatorAvailable(s_lang->numEMSActuatorsAvailable)); actuator.ComponentTypeName = cComponentTypeName; actuator.UniqueIDName = cUniqueIDName; actuator.ControlTypeName = cControlTypeName; @@ -2118,7 +2060,7 @@ void SetupEMSActuator(EnergyPlusData &state, actuator.Actuated = &lEMSActuated; // Pointer assigment actuator.IntValue = &iValue; // Pointer assigment actuator.PntrVarTypeUsed = DataRuntimeLanguage::PtrDataType::Integer; - state.dataRuntimeLang->EMSActuator_lookup.insert(key); + s_lang->EMSActuatorAvailableMap.insert_or_assign(std::make_tuple(objType, objName, actuatorName), s_lang->numEMSActuatorsAvailable); } } @@ -2143,25 +2085,27 @@ void SetupEMSActuator(EnergyPlusData &state, // push size of ActuatorVariable and add a new one. // check for duplicates. - std::string const UpperCaseObjectType(Util::makeUPPER(cComponentTypeName)); - std::string const UpperCaseObjectName(Util::makeUPPER(cUniqueIDName)); - std::string const UpperCaseActuatorName(Util::makeUPPER(cControlTypeName)); + auto &s_lang = state.dataRuntimeLang; + + std::string const objType = Util::makeUPPER(cComponentTypeName); + std::string const objName = Util::makeUPPER(cUniqueIDName); + std::string const actuatorName = Util::makeUPPER(cControlTypeName); - DataRuntimeLanguage::EMSActuatorKey const key(UpperCaseObjectType, UpperCaseObjectName, UpperCaseActuatorName); + // DataRuntimeLanguage::EMSActuatorKey const key(UpperCaseObjectType, UpperCaseObjectName, UpperCaseActuatorName); - if (state.dataRuntimeLang->EMSActuator_lookup.find(key) == state.dataRuntimeLang->EMSActuator_lookup.end()) { - if (state.dataRuntimeLang->numEMSActuatorsAvailable == 0) { - state.dataRuntimeLang->EMSActuatorAvailable.allocate(state.dataRuntimeLang->varsAvailableAllocInc); - state.dataRuntimeLang->numEMSActuatorsAvailable = 1; - state.dataRuntimeLang->maxEMSActuatorsAvailable = state.dataRuntimeLang->varsAvailableAllocInc; + if (s_lang->EMSActuatorAvailableMap.find(std::make_tuple(objType, objName, actuatorName)) == s_lang->EMSActuatorAvailableMap.end()) { + if (s_lang->numEMSActuatorsAvailable == 0) { + s_lang->EMSActuatorAvailable.allocate(s_lang->varsAvailableAllocInc); + s_lang->numEMSActuatorsAvailable = 1; + s_lang->maxEMSActuatorsAvailable = s_lang->varsAvailableAllocInc; } else { - if (state.dataRuntimeLang->numEMSActuatorsAvailable + 1 > state.dataRuntimeLang->maxEMSActuatorsAvailable) { - state.dataRuntimeLang->EMSActuatorAvailable.redimension(state.dataRuntimeLang->maxEMSActuatorsAvailable *= 2); + if (s_lang->numEMSActuatorsAvailable + 1 > s_lang->maxEMSActuatorsAvailable) { + s_lang->EMSActuatorAvailable.redimension(s_lang->maxEMSActuatorsAvailable *= 2); } - ++state.dataRuntimeLang->numEMSActuatorsAvailable; + ++s_lang->numEMSActuatorsAvailable; } - auto &actuator(state.dataRuntimeLang->EMSActuatorAvailable(state.dataRuntimeLang->numEMSActuatorsAvailable)); + auto &actuator(s_lang->EMSActuatorAvailable(s_lang->numEMSActuatorsAvailable)); actuator.ComponentTypeName = cComponentTypeName; actuator.UniqueIDName = cUniqueIDName; actuator.ControlTypeName = cControlTypeName; @@ -2169,7 +2113,7 @@ void SetupEMSActuator(EnergyPlusData &state, actuator.Actuated = &lEMSActuated; // Pointer assigment actuator.LogValue = &lValue; // Pointer assigment actuator.PntrVarTypeUsed = DataRuntimeLanguage::PtrDataType::Logical; - state.dataRuntimeLang->EMSActuator_lookup.insert(key); + s_lang->EMSActuatorAvailableMap.insert_or_assign(std::make_tuple(objType, objName, actuatorName), s_lang->numEMSActuatorsAvailable); } } diff --git a/src/EnergyPlus/EMSManager.hh b/src/EnergyPlus/EMSManager.hh index 22f9fe71b45..fc8097a64c2 100644 --- a/src/EnergyPlus/EMSManager.hh +++ b/src/EnergyPlus/EMSManager.hh @@ -207,6 +207,7 @@ struct EMSManagerData : BaseGlobalStruct void init_state([[maybe_unused]] EnergyPlusData &state) override { + EMSManager::CheckIfAnyEMS(state); } void clear_state() override diff --git a/src/EnergyPlus/HeatBalanceAirManager.cc b/src/EnergyPlus/HeatBalanceAirManager.cc index 192ac672497..77623684e1b 100644 --- a/src/EnergyPlus/HeatBalanceAirManager.cc +++ b/src/EnergyPlus/HeatBalanceAirManager.cc @@ -1881,6 +1881,8 @@ void GetSimpleAirModelInputs(EnergyPlusData &state, bool &ErrorsFound) // IF err thisVentilation.ModelType = DataHeatBalance::VentilationModelType::WindAndStack; + thisVentilation.sched = Sched::GetScheduleAlwaysOff(state); + thisVentilation.OpenArea = rNumericArgs(1); if (thisVentilation.OpenArea < 0.0) { ShowSevereError( diff --git a/src/EnergyPlus/InternalHeatGains.cc b/src/EnergyPlus/InternalHeatGains.cc index 26b5783975a..8123d87fb36 100644 --- a/src/EnergyPlus/InternalHeatGains.cc +++ b/src/EnergyPlus/InternalHeatGains.cc @@ -329,6 +329,12 @@ namespace InternalHeatGains { thisPeople.spaceIndex = spaceNum; thisPeople.ZonePtr = zoneNum; + // These are Constant-1.0 by default + thisPeople.workEffSched = Sched::GetScheduleAlwaysOn(state); + thisPeople.clothingSched = Sched::GetScheduleAlwaysOn(state); + thisPeople.clothingMethodSched = Sched::GetScheduleAlwaysOn(state); + thisPeople.airVelocitySched = Sched::GetScheduleAlwaysOn(state); + thisPeople.numberOfPeopleSched = Sched::GetSchedule(state, IHGAlphas(3)); SchMin = 0.0; SchMax = 0.0; @@ -711,8 +717,8 @@ namespace InternalHeatGains { } // switch (thisPeople.MRTCalcType) if (!IHGAlphaFieldBlanks(9)) { - thisPeople.workEffSched = Sched::GetSchedule(state, IHGAlphas(9)); - } + thisPeople.workEffSched = Sched::GetSchedule(state, IHGAlphas(9)); + } if (Item1 == 1) { if (IHGAlphaFieldBlanks(9)) { @@ -737,6 +743,7 @@ namespace InternalHeatGains { ClothingType::Invalid) { ShowSevereInvalidKey(state, eoh, IHGAlphaFieldNames(10), IHGAlphas(10)); ErrorsFound = true; + } else { switch (thisPeople.clothingType) { @@ -789,8 +796,10 @@ namespace InternalHeatGains { } - if (!IHGAlphaFieldBlanks(13)) { - thisPeople.airVelocitySched = Sched::GetSchedule(state, IHGAlphas(13)); + if (IHGAlphaFieldBlanks(13)) { + thisPeople.airVelocitySched = Sched::GetScheduleAlwaysOn(state); + } else { + thisPeople.airVelocitySched = Sched::GetSchedule(state, IHGAlphas(13)); } if (Item1 == 1) { @@ -810,7 +819,9 @@ namespace InternalHeatGains { } } - if (!IHGAlphaFieldBlanks(21)) { + if (IHGAlphaFieldBlanks(21)) { + thisPeople.ankleAirVelocitySched = Sched::GetScheduleAlwaysOn(state); + } else { thisPeople.ankleAirVelocitySched = Sched::GetSchedule(state, IHGAlphas(21)); } diff --git a/src/EnergyPlus/RefrigeratedCase.cc b/src/EnergyPlus/RefrigeratedCase.cc index b4d2f04008b..75d79569720 100644 --- a/src/EnergyPlus/RefrigeratedCase.cc +++ b/src/EnergyPlus/RefrigeratedCase.cc @@ -1059,18 +1059,13 @@ void GetRefrigerationInput(EnergyPlusData &state) // Flag for counting defrost cycles bool StartCycle = false; int NumDefCycles = 0; - DayValues = 0.0; - RefrigCase(CaseNum).defrostSched->getDayVals(state, DayValues, 1); - for (int HRNum = 1; HRNum <= 24; ++HRNum) { - for (int TSNum = 1; TSNum <= state.dataGlobal->TimeStepsInHour; ++TSNum) { - if (DayValues(TSNum, HRNum) > 0.0) { - if (!StartCycle) { - ++NumDefCycles; - StartCycle = true; - } - } else { - StartCycle = false; - } + std::vector const &dayVals = RefrigCase(CaseNum).defrostSched->getDayVals(state, 1); + for (int i = 0; i < Constant::iHoursInDay * state.dataGlobal->TimeStepsInHour; ++i) { + if (dayVals[i] == 0.0) { + StartCycle = false; + } else if (!StartCycle) { + ++NumDefCycles; + StartCycle = true; } } diff --git a/src/EnergyPlus/ScheduleManager.cc b/src/EnergyPlus/ScheduleManager.cc index 2a0844c461d..6c624c65fc5 100644 --- a/src/EnergyPlus/ScheduleManager.cc +++ b/src/EnergyPlus/ScheduleManager.cc @@ -96,7 +96,7 @@ namespace Sched { // MODULE PARAMETER DEFINITIONS int GetScheduleTypeNum(EnergyPlusData &state, std::string const &name) { - auto &s_sched = state.dataSched; + auto const &s_sched = state.dataSched; for (int i = 0; i < (int)s_sched->scheduleTypes.size(); ++i) if (s_sched->scheduleTypes[i]->Name == name) return i; return -1; } @@ -224,7 +224,7 @@ namespace Sched { ScheduleConstant *AddScheduleConstant(EnergyPlusData &state, std::string const &name) { - auto &s_sched = state.dataSched; + auto const &s_sched = state.dataSched; auto *sched = new ScheduleConstant; sched->Name = name; @@ -238,7 +238,7 @@ namespace Sched { ScheduleDetailed *AddScheduleDetailed(EnergyPlusData &state, std::string const &name) { - auto &s_sched = state.dataSched; + auto const &s_sched = state.dataSched; auto *sched = new ScheduleDetailed; sched->Name = name; @@ -270,7 +270,7 @@ namespace Sched { WeekSchedule *AddWeekSchedule(EnergyPlusData &state, std::string const &name) { - auto &s_sched = state.dataSched; + auto const &s_sched = state.dataSched; auto *weekSched = new WeekSchedule; weekSched->Name = name; @@ -382,7 +382,7 @@ namespace Sched { auto const &s_glob = state.dataGlobal; auto const &s_ip = state.dataInputProcessing->inputProcessor; - auto &s_sched = state.dataSched; + auto const &s_sched = state.dataSched; if (s_sched->ScheduleInputProcessed) { return; @@ -910,7 +910,7 @@ namespace Sched { continue; } - if (mod(60, MinutesPerItem) != 0) { + if (mod(Constant::iMinutesInHour, MinutesPerItem) != 0) { ShowSevereCustom(state, eoh, format("{}={} not evenly divisible into 60", cNumericFields(1), MinutesPerItem)); ErrorsFound = true; continue; @@ -926,7 +926,7 @@ namespace Sched { Numbers(NumFields)); begMinute = endMinute + 1; endMinute += MinutesPerItem; - if (endMinute >= 60) { + if (endMinute >= Constant::iMinutesInHour) { endMinute = MinutesPerItem - 1; begMinute = 0; ++hr; @@ -2133,7 +2133,7 @@ namespace Sched { NumF = 1; for (int hr = 0; hr < Constant::iHoursInDay; ++hr) { if (LevelOfDetail == ReportLevel::TimeStep) { - for (int ts = 0; ts < s_glob->TimeStepsInHour - 1; ++ts) { + for (int ts = 1; ts <= s_glob->TimeStepsInHour - 1; ++ts) { TimeHHMM(NumF) = format("{}:{}", HrField[hr], ShowMinute(ts)); ++NumF; } @@ -2195,8 +2195,8 @@ namespace Sched { NoAverageLinear = interpolationNames[(int)daySched->interpolation]; for (int hr = 0; hr < Constant::iHoursInDay; ++hr) { - for (int ts = 1; ts <= s_glob->TimeStepsInHour; ++ts) { - RoundTSValue(ts, hr) = format("{:.2R}", daySched->tsVals[hr * s_glob->TimeStepsInHour + ts]); + for (int ts = 0; ts < s_glob->TimeStepsInHour; ++ts) { + RoundTSValue(ts+1, hr+1) = format("{:.2R}", daySched->tsVals[hr * s_glob->TimeStepsInHour + ts]); } } std::string_view constexpr SchDFmtdata0("DaySchedule,{},{},{},{}"); @@ -2210,14 +2210,14 @@ namespace Sched { switch (LevelOfDetail) { case ReportLevel::Hourly: { for (int hr = 0; hr < Constant::iHoursInDay; ++hr) { - print(state.files.eio, SchDFmtdata, RoundTSValue(s_glob->TimeStepsInHour, hr)); + print(state.files.eio, SchDFmtdata, RoundTSValue(s_glob->TimeStepsInHour, hr+1)); } } break; case ReportLevel::TimeStep: { for (int hr = 1; hr < Constant::iHoursInDay; ++hr) { for (int ts = 0; ts < s_glob->TimeStepsInHour; ++ts) { - print(state.files.eio, SchDFmtdata, RoundTSValue(ts, hr)); + print(state.files.eio, SchDFmtdata, RoundTSValue(ts+1, hr+1)); } } } break; @@ -2232,7 +2232,7 @@ namespace Sched { std::string_view constexpr SchWFmtdata("Schedule:Week:Daily,{}"); print(state.files.eio, SchWFmtdata, weekSched->Name); - for (int NumF = 0; NumF < (int)DayType::Num; ++NumF) { + for (int NumF = 1; NumF < (int)DayType::Num; ++NumF) { print(state.files.eio, ",{}", weekSched->dayScheds[NumF]->Name); } print(state.files.eio, "\n"); @@ -2406,7 +2406,7 @@ namespace Sched { RoundTSValue.deallocate(); } // ReportScheduleDetails() - Real64 GetCurrentScheduleValue(EnergyPlusData &state, int const schedNum) + Real64 GetCurrentScheduleValue(EnergyPlusData const &state, int const schedNum) { // Wrapper for method return state.dataSched->schedules[schedNum]->getCurrentVal(); @@ -2512,7 +2512,7 @@ namespace Sched { // PURPOSE OF THIS FUNCTION: // This function returns the internal pointer to Schedule "ScheduleName". - auto &s_sched = state.dataSched; + auto const &s_sched = state.dataSched; auto found = s_sched->scheduleMap.find(name); if (found == s_sched->scheduleMap.end()) return nullptr; @@ -2550,7 +2550,7 @@ namespace Sched { Sched::WeekSchedule *GetWeekSchedule(EnergyPlusData &state, std::string const &name) { - auto &s_sched = state.dataSched; + auto const &s_sched = state.dataSched; auto found = s_sched->weekScheduleMap.find(name); if (found == s_sched->weekScheduleMap.end()) return nullptr; @@ -2584,7 +2584,7 @@ namespace Sched { // PURPOSE OF THIS FUNCTION: // This function returns the internal pointer to Schedule "ScheduleName". - auto &s_sched = state.dataSched; + auto const &s_sched = state.dataSched; auto found = s_sched->dayScheduleMap.find(name); if (found == s_sched->dayScheduleMap.end()) return nullptr; @@ -2604,17 +2604,6 @@ namespace Sched { return (daySched == nullptr) ? -1: daySched->Num; } - void DaySchedule::getDayVals(EnergyPlusData &state, - Array2S DayVals) const - { - auto const &s_glob = state.dataGlobal; - for (int hr = 0; hr < Constant::iHoursInDay; ++hr) { - for (int ts = 0; ts < s_glob->TimeStepsInHour; ++ts) { - DayVals(ts+1, hr+1) = this->tsVals[hr * s_glob->TimeStepsInHour + ts]; - } - } - } // ScheduleDay::getDayValues() - void ScheduleConstant::setMinMaxVals([[maybe_unused]] EnergyPlusData &state) { assert(!isMinMaxSet); @@ -2622,25 +2611,8 @@ namespace Sched { isMinMaxSet = true; } - void ScheduleConstant::getDayVals(EnergyPlusData &state, - Array2S DayValues, - [[maybe_unused]] int jDay, - [[maybe_unused]] int dayofWeek) - { - // SUBROUTINE INFORMATION: - // AUTHOR Linda K. Lawrie - // DATE WRITTEN September 1997 - // PURPOSE OF THIS SUBROUTINE: - // This subroutine returns an entire day's worth of schedule values. - - auto const &s_glob = state.dataGlobal; - DayValues({1, s_glob->TimeStepsInHour}, {1, Constant::iHoursInDay}) = this->currentVal; - } // ScheduleConstant::getDayVals() - - std::vector const &ScheduleConstant::getDayVals(EnergyPlusData &state, - [[maybe_unused]] int jDay, - [[maybe_unused]] int dayofWeek) + std::vector const &ScheduleConstant::getDayVals(EnergyPlusData &state, [[maybe_unused]] int jDay, [[maybe_unused]] int dayofWeek) { auto const &s_glob = state.dataGlobal; if ((int)tsVals.size() != Constant::iHoursInDay * s_glob->TimeStepsInHour) { @@ -2650,9 +2622,7 @@ namespace Sched { return this->tsVals; } // ScheduleConstant::getDayVals() - std::vector const &ScheduleDetailed::getDayVals(EnergyPlusData &state, - int jDay, - int dayOfWeek) + std::vector const &ScheduleDetailed::getDayVals(EnergyPlusData &state, int jDay, int dayOfWeek) { // PURPOSE OF THIS SUBROUTINE: // This subroutine returns an entire day's worth of schedule values. @@ -2674,54 +2644,6 @@ namespace Sched { return daySched->getDayVals(state); } // ScheduleDetailed::getDayVals() - void ScheduleDetailed::getDayVals(EnergyPlusData &state, - Array2S DayValues, - int jDay, - int dayOfWeek) - { - // SUBROUTINE INFORMATION: - // AUTHOR Linda K. Lawrie - // DATE WRITTEN September 1997 - - // PURPOSE OF THIS SUBROUTINE: - // This subroutine returns an entire day's worth of schedule values. - auto const &s_env = state.dataEnvrn; - - // Determine which Week Schedule is used - auto const *weekSched = this->weekScheds[(jDay == -1) ? state.dataEnvrn->DayOfYear_Schedule : jDay]; - - DaySchedule *daySched = nullptr; - // Now, which day? - if (dayOfWeek == -1) { - daySched = weekSched->dayScheds[(s_env->HolidayIndex > 0) ? s_env->HolidayIndex : s_env->DayOfWeek]; - } else if (dayOfWeek <= 7 && s_env->HolidayIndex > 0) { - daySched = weekSched->dayScheds[s_env->HolidayIndex]; - } else { - daySched = weekSched->dayScheds[dayOfWeek]; - } - - daySched->getDayVals(state, DayValues); - } // ScheduleDetailed::getDayVals() - - void GetScheduleValuesForDay(EnergyPlusData &state, - int const schedNum, - Array2S DayValues, - int jDay, - int dayOfWeek) - { - // Just a wrapper for the method - return state.dataSched->schedules[schedNum]->getDayVals(state, DayValues, jDay, dayOfWeek); - } - - void GetSingleDayScheduleValues([[maybe_unused]] EnergyPlusData &state, - int const daySchedNum, // Index of the DaySchedule for values - Array2S DayValues // Returned set of values - ) - { - // Just a wrapper for the method - state.dataSched->daySchedules[daySchedNum]->getDayVals(state, DayValues); - } - void ExternalInterfaceSetSchedule(EnergyPlusData &state, int schedNum, Real64 value // The new value for the schedule @@ -2819,13 +2741,13 @@ namespace Sched { continue; } // Field decoded - if (HHField < 0 || HHField > 24 || MMField < 0 || MMField > 60) { + if (HHField < 0 || HHField > Constant::iHoursInDay || MMField < 0 || MMField > Constant::iMinutesInHour) { ShowSevereError(state, format("ProcessScheduleInput: ProcessIntervalFields, Invalid \"Until\" field encountered={}", until)); ShowContinueError(state, format("Occurred in Day Schedule={}", DayScheduleName)); ErrorsFound = true; continue; } - if (HHField == 24 && MMField > 0 && MMField < 60) { + if (HHField == Constant::iHoursInDay && MMField > 0 && MMField < Constant::iMinutesInHour) { ShowWarningError(state, format("ProcessScheduleInput: ProcessIntervalFields, Invalid \"Until\" field encountered={}", Untils(Count))); ShowContinueError(state, format("Occurred in Day Schedule={}", DayScheduleName)); ShowContinueError(state, "Terminating the field at 24:00"); @@ -2834,10 +2756,9 @@ namespace Sched { // Fill in values if (MMField == 0) { - endHr = HHField; - endMin = 59; - } - if (MMField < 60) { + endHr = HHField - 1; + endMin = Constant::iMinutesInHour - 1; + } else if (MMField < Constant::iMinutesInHour) { endHr = HHField; endMin = MMField - 1; } @@ -2857,27 +2778,33 @@ namespace Sched { } if (begHr == endHr) { - for (int iMin = begMin; iMin <= endMin; ++iMin) { - if (setMinuteVals[begHr * Constant::iMinutesInHour + iMin]) { - ShowSevereError( - state, - format("ProcessScheduleInput: ProcessIntervalFields, Processing time fields, overlapping times detected, {}={}", - ErrContext, - DayScheduleName)); - ErrorsFound = true; - goto UntilLoop_exit; - } else if (interpolation == Interpolation::Linear) { + if (std::find(&setMinuteVals[begHr * Constant::iMinutesInHour + begMin], + &setMinuteVals[begHr * Constant::iMinutesInHour + endMin + 1], + true) != &setMinuteVals[begHr * Constant::iMinutesInHour + endMin + 1]) { + ShowSevereError(state, + format("ProcessScheduleInput: ProcessIntervalFields, Processing time fields, overlapping times detected, {}={}", + ErrContext, + DayScheduleName)); + ErrorsFound = true; + goto UntilLoop_exit; + + } else if (interpolation == Interpolation::Linear) { + for (int iMin = begMin; iMin <= endMin; ++iMin) { minuteVals[begHr * Constant::iMinutesInHour + iMin] = curValue; curValue += incrementPerMinute; setMinuteVals[begHr * Constant::iMinutesInHour + iMin] = true; - } else { - minuteVals[begHr * Constant::iMinutesInHour + iMin] = Numbers(Count); - setMinuteVals[begHr * Constant::iMinutesInHour + iMin] = true; } + } else { + std::fill(&minuteVals[begHr * Constant::iMinutesInHour + begMin], + &minuteVals[begHr * Constant::iMinutesInHour + endMin + 1], + Numbers(Count)); + std::fill(&setMinuteVals[begHr * Constant::iMinutesInHour + begMin], + &setMinuteVals[begHr * Constant::iMinutesInHour + endMin + 1], + true); } begMin = endMin + 1; - if (begMin >= 60) { + if (begMin >= Constant::iMinutesInHour) { ++begHr; begMin = 0; } @@ -2889,7 +2816,7 @@ namespace Sched { DayScheduleName)); ErrorsFound = true; - } else { + } else { // begHr < endHr if (interpolation == Interpolation::Linear) { for (int iMin = begMin; iMin < Constant::iMinutesInHour; ++iMin) { // for portion of starting hour minuteVals[begHr * Constant::iMinutesInHour + iMin] = curValue; @@ -2912,20 +2839,32 @@ namespace Sched { } } else { // either no interpolation or "average" interpolation (average just is when the interval does not match the timestep) - for (int iMin = begMin; iMin < Constant::iMinutesInHour; ++iMin) { // for portion of starting hour - minuteVals[begHr * Constant::iMinutesInHour + iMin] = Numbers(Count); - setMinuteVals[begHr * Constant::iMinutesInHour + iMin] = true; - } - for (int iHr = begHr + 1; iHr <= endHr - 1; ++iHr) { // for intermediate hours - for (int iMin = 0; iMin < Constant::iMinutesInHour; ++iMin) { - minuteVals[iHr * Constant::iMinutesInHour + iMin] = Numbers(Count); - setMinuteVals[iHr * Constant::iMinutesInHour + iMin] = true; - } - } - for (int iMin = 0; iMin <= endMin; ++iMin) { // for ending hour - minuteVals[endHr * Constant::iMinutesInHour + iMin] = Numbers(Count); - setMinuteVals[endHr * Constant::iMinutesInHour + iMin] = true; + // Fill values for first hour (which may not start at minute 0) + // For std::fill the end marker has to be 1 past the last position you want to fill + std::fill(&minuteVals[begHr * Constant::iMinutesInHour + begMin], + &minuteVals[begHr * Constant::iMinutesInHour + Constant::iMinutesInHour], + Numbers(Count)); + std::fill(&setMinuteVals[begHr * Constant::iMinutesInHour + begMin], + &setMinuteVals[begHr * Constant::iMinutesInHour + Constant::iMinutesInHour], + true); + + // Fill values for middle hours (which start at minute 0 and end in minute 59) + if ((begHr + 1) <= (endHr - 1)) { + std::fill(&minuteVals[(begHr + 1) * Constant::iMinutesInHour + 0], + &minuteVals[(endHr - 1) * Constant::iMinutesInHour + Constant::iMinutesInHour], + Numbers(Count)); + std::fill(&setMinuteVals[(begHr + 1) * Constant::iMinutesInHour + 0], + &setMinuteVals[(endHr - 1) * Constant::iMinutesInHour + Constant::iMinutesInHour], + true); } + + // Fill values for last hour (which starts at minute 0 but may end on minute that isn't 59) + std::fill(&minuteVals[endHr * Constant::iMinutesInHour + 0], + &minuteVals[endHr * Constant::iMinutesInHour + endMin + 1], + Numbers(Count)); + std::fill(&setMinuteVals[endHr * Constant::iMinutesInHour + 0], + &setMinuteVals[endHr * Constant::iMinutesInHour + endMin + 1], + true); } begHr = endHr; @@ -2975,7 +2914,7 @@ namespace Sched { std::string::size_type const Pos = index(String, ':'); bool nonIntegral = false; - auto &s_glob = state.dataGlobal; + auto const &s_glob = state.dataGlobal; if (Pos == std::string::npos) { ShowSevereError(state, format("ProcessScheduleInput: DecodeHHMMField, Invalid \"until\" field submitted (no : separator in hh:mm)={}", diff --git a/src/EnergyPlus/ScheduleManager.hh b/src/EnergyPlus/ScheduleManager.hh index a9bd5133e3d..2ad29eccd5b 100644 --- a/src/EnergyPlus/ScheduleManager.hh +++ b/src/EnergyPlus/ScheduleManager.hh @@ -197,8 +197,17 @@ namespace Sched { bool checkMinVal(EnergyPlusData &state, Clusive cluMin, Real64 const min); bool checkMaxVal(EnergyPlusData &state, Clusive cluMax, Real64 const max); }; + + struct DayOrYearSchedule : ScheduleBase + { + DayOrYearSchedule() {}; + virtual ~DayOrYearSchedule() {}; + + // virtual void getDayVals(EnergyPlusData &state, Array2S DayVals, int jDay = -1, int dayOfWeek = -1) = 0; + virtual std::vector const &getDayVals([[maybe_unused]] EnergyPlusData &state, int jDay = -1, int dayOfWeek = -1) = 0; + }; - struct DaySchedule : ScheduleBase + struct DaySchedule : DayOrYearSchedule { int schedTypeNum = SchedNum_Invalid; // Index of Schedule Type @@ -213,8 +222,8 @@ namespace Sched { bool checkValsForLimitViolations(EnergyPlusData &state) const; bool checkValsForBadIntegers(EnergyPlusData &state) const; void populateFromMinuteVals(EnergyPlusData &state, std::array const &minVals); - void getDayVals(EnergyPlusData &state, Array2S DayVals) const; - std::vector const &getDayVals([[maybe_unused]] EnergyPlusData &state) const { return tsVals; } + // void getDayVals(EnergyPlusData &state, Array2S DayVals, int jDay = -1, int dayOfWeek = -1); + std::vector const &getDayVals([[maybe_unused]] EnergyPlusData &state, int jDay = -1, int dayOfWeek = -1) { return tsVals; } void setMinMaxVals(EnergyPlusData &state); }; @@ -230,7 +239,7 @@ namespace Sched { void setMinMaxVals(EnergyPlusData &state); }; - struct Schedule : public ScheduleBase + struct Schedule : public DayOrYearSchedule { SchedType type = SchedType::Invalid; @@ -248,10 +257,7 @@ namespace Sched { // Looks up a given Schedule value for an hour & timestep, minding whether DST is enabled or not // Negative ts => unspecified, will use TimeStepsInHour - virtual Real64 getHrTsVal(EnergyPlusData &state, int hr, int ts = -1) const = 0; - virtual void getDayVals(EnergyPlusData &state, Array2S DayVals, int jDay = -1, int dayofWeek = -1) = 0; - virtual std::vector const &getDayVals(EnergyPlusData &state, int jDay = -1, int dayOfWeek = -1) = 0; - + virtual Real64 getHrTsVal(EnergyPlusData &state, int hr, int ts = -1) const = 0; virtual bool hasVal(EnergyPlusData &state, Real64 const val) const = 0; virtual bool hasFractionalVal(EnergyPlusData &state) const = 0; @@ -277,7 +283,7 @@ namespace Sched { // Negative ts => unspecified, will use TimeStepsInHour Real64 getHrTsVal(EnergyPlusData &state, int hr, int ts = -1) const; - void getDayVals(EnergyPlusData &state, Array2S DayValues, int jDay = -1, int dayofWeek = -1); + // void getDayVals(EnergyPlusData &state, Array2S DayValues, int jDay = -1, int dayofWeek = -1); std::vector const &getDayVals(EnergyPlusData &state, int jDay = -1, int dayOfWeek = -1); bool hasVal(EnergyPlusData &state, Real64 const val) const; @@ -308,7 +314,7 @@ namespace Sched { void can_instantiate() { assert(false); } // makes class concrete, but don't call this - void getDayVals(EnergyPlusData &state, Array2S DayVals, int jDay = -1, int dayofWeek = -1); + // void getDayVals(EnergyPlusData &state, Array2S DayVals, int jDay = -1, int dayofWeek = -1); std::vector const &getDayVals(EnergyPlusData &state, int jDay = -1, int dayOfWeek = -1); bool hasVal(EnergyPlusData &state, Real64 const val) const; diff --git a/src/EnergyPlus/SystemAvailabilityManager.cc b/src/EnergyPlus/SystemAvailabilityManager.cc index 17738e9fe8b..c743654453f 100644 --- a/src/EnergyPlus/SystemAvailabilityManager.cc +++ b/src/EnergyPlus/SystemAvailabilityManager.cc @@ -2299,16 +2299,16 @@ namespace Avail { } if (!state.dataGlobal->BeginDayFlag) state.dataAvail->BeginOfDayResetFlag = true; - OptStartMgr.fanSched->getDayVals(state, DayValues); - OptStartMgr.fanSched->getDayVals(state, DayValuesTmr, TmrJDay, TmrDayOfWeek); + std::vector const &dayVals = OptStartMgr.fanSched->getDayVals(state); + std::vector const &tmwDayVals = OptStartMgr.fanSched->getDayVals(state, TmrJDay, TmrDayOfWeek); FanStartTime = 0.0; FanStartTimeTmr = 0.0; exitLoop = false; - for (int I = 1; I <= 24; ++I) { - for (int J = 1; J <= state.dataGlobal->TimeStepsInHour; ++J) { - if (DayValues(J, I) <= 0.0) continue; - FanStartTime = I - 1 + 1.0 / state.dataGlobal->TimeStepsInHour * J - 0.01; + for (int hr = 0; hr < Constant::iHoursInDay; ++hr) { + for (int ts = 0; ts <= state.dataGlobal->TimeStepsInHour; ++ts) { + if (dayVals[hr * state.dataGlobal->TimeStepsInHour + ts] <= 0.0) continue; + FanStartTime = hr + (1.0 / state.dataGlobal->TimeStepsInHour) * (ts + 1) - 0.01; exitLoop = true; break; } @@ -2316,10 +2316,10 @@ namespace Avail { } exitLoop = false; - for (int I = 1; I <= 24; ++I) { - for (int J = 1; J <= state.dataGlobal->TimeStepsInHour; ++J) { - if (DayValuesTmr(J, I) <= 0.0) continue; - FanStartTimeTmr = I - 1 + 1.0 / state.dataGlobal->TimeStepsInHour * J - 0.01; + for (int hr = 0; hr < Constant::iHoursInDay; ++hr) { + for (int ts = 0; ts < state.dataGlobal->TimeStepsInHour; ++ts) { + if (tmwDayVals[hr * state.dataGlobal->TimeStepsInHour + ts] <= 0.0) continue; + FanStartTimeTmr = hr + (1.0 / state.dataGlobal->TimeStepsInHour) * (ts + 1) - 0.01; exitLoop = true; break; } diff --git a/src/EnergyPlus/WeatherManager.cc b/src/EnergyPlus/WeatherManager.cc index 514a73e9dd3..5c8174e9bbb 100644 --- a/src/EnergyPlus/WeatherManager.cc +++ b/src/EnergyPlus/WeatherManager.cc @@ -2984,44 +2984,46 @@ namespace Weather { if (thisEnviron.WP_Type1 != 0) { switch (state.dataWeather->WPSkyTemperature(thisEnviron.WP_Type1).skyTempModel) { case SkyTempModel::ScheduleValue: { - Array2D tmp = Array2D(state.dataGlobal->TimeStepsInHour, Constant::iHoursInDay); - - state.dataWeather->WPSkyTemperature(thisEnviron.WP_Type1).sched->getDayVals(state, - tmp, - state.dataWeather->TomorrowVariables.DayOfYear_Schedule, - state.dataWeather->CurDayOfWeek); - - for (int iHr = 1; iHr <= Constant::iHoursInDay; ++iHr) { - for (int iTS = 1; iTS <= state.dataGlobal->TimeStepsInHour; ++iTS) { - state.dataWeather->wvarsHrTsTomorrow(iTS, iHr).SkyTemp = tmp(iTS, iHr); + std::vector const &dayVals = + state.dataWeather->WPSkyTemperature(thisEnviron.WP_Type1).sched->getDayVals(state, + state.dataWeather->TomorrowVariables.DayOfYear_Schedule, + state.dataWeather->CurDayOfWeek); + + for (int hr = 0; hr < Constant::iHoursInDay; ++hr) { + for (int ts = 0; ts < state.dataGlobal->TimeStepsInHour; ++ts) { + state.dataWeather->wvarsHrTsTomorrow(ts+1, hr+1).SkyTemp = dayVals[hr * state.dataGlobal->TimeStepsInHour + ts]; } } } break; + case SkyTempModel::DryBulbDelta: { - Array2D tmp = Array2D(state.dataGlobal->TimeStepsInHour, Constant::iHoursInDay); - state.dataWeather->WPSkyTemperature(thisEnviron.WP_Type1).sched->getDayVals(state, - tmp, - state.dataWeather->TomorrowVariables.DayOfYear_Schedule, - state.dataWeather->CurDayOfWeek); + std::vector const &dayVals = + state.dataWeather->WPSkyTemperature(thisEnviron.WP_Type1).sched->getDayVals(state, + state.dataWeather->TomorrowVariables.DayOfYear_Schedule, + state.dataWeather->CurDayOfWeek); - for (int hour = 1; hour <= Constant::iHoursInDay; ++hour) { - for (int ts = 1; ts <= state.dataGlobal->TimeStepsInHour; ++ts) { - auto &tomorrowTs = state.dataWeather->wvarsHrTsTomorrow(ts, hour); - tomorrowTs.SkyTemp = tomorrowTs.OutDryBulbTemp - tmp(ts, hour); + for (int hr = 0; hr < Constant::iHoursInDay; ++hr) { + for (int ts = 0; ts < state.dataGlobal->TimeStepsInHour; ++ts) { + auto &tomorrowTs = state.dataWeather->wvarsHrTsTomorrow(ts+1, hr+1); + tomorrowTs.SkyTemp = tomorrowTs.OutDryBulbTemp - dayVals[hr * state.dataGlobal->TimeStepsInHour + ts]; } } } break; + case SkyTempModel::DewPointDelta: { - Array2D tmp = Array2D(state.dataGlobal->TimeStepsInHour, Constant::iHoursInDay); - state.dataWeather->WPSkyTemperature(thisEnviron.WP_Type1).sched->getDayVals(state, - tmp, - state.dataWeather->TomorrowVariables.DayOfYear_Schedule, - state.dataWeather->CurDayOfWeek); - ForAllHrTs(state, [&state, &tmp](int iHr, int iTS) { - auto &tomorrowTs = state.dataWeather->wvarsHrTsTomorrow(iTS, iHr); - tomorrowTs.SkyTemp = tomorrowTs.OutDewPointTemp - tmp(iTS, iHr); - }); + std::vector const &dayVals = + state.dataWeather->WPSkyTemperature(thisEnviron.WP_Type1).sched->getDayVals(state, + state.dataWeather->TomorrowVariables.DayOfYear_Schedule, + state.dataWeather->CurDayOfWeek); + + for (int hr = 0; hr < Constant::iHoursInDay; ++hr) { + for (int ts = 0; ts < state.dataGlobal->TimeStepsInHour; ++ts) { + auto &tomorrowTs = state.dataWeather->wvarsHrTsTomorrow(ts+1, hr+1); + tomorrowTs.SkyTemp = tomorrowTs.OutDewPointTemp - dayVals[hr * state.dataGlobal->TimeStepsInHour + ts]; + } + } } break; + default: break; } @@ -3547,9 +3549,9 @@ namespace Weather { case DesDayHumIndType::RelHumSch: { // nothing to do -- DDHumIndModifier already contains the scheduled Relative Humidity ConstantHumidityRatio = false; - ForAllHrTs(state, [&state, EnvrnNum](int iHr, int iTS) { - state.dataWeather->wvarsHrTsTomorrow(iTS, iHr).OutRelHum = state.dataWeather->desDayMods(EnvrnNum)(iTS, iHr).OutRelHum; - }); + for (int hr = 0; hr < Constant::iHoursInDay; ++hr) + for (int ts = 0; ts < state.dataGlobal->TimeStepsInHour; ++ts) + state.dataWeather->wvarsHrTsTomorrow(ts+1, hr+1).OutRelHum = state.dataWeather->desDayMods(EnvrnNum)(ts+1, hr+1).OutRelHum; } break; case DesDayHumIndType::WBProfDef: case DesDayHumIndType::WBProfDif: @@ -3565,45 +3567,55 @@ namespace Weather { int OSky; // Opaque Sky Cover (tenths) if (desDayInput.RainInd != 0) { OSky = 10; - ForAllHrTs(state, [&state](int iHr, int iTS) { - auto &ts = state.dataWeather->wvarsHrTsTomorrow(iTS, iHr); - ts.IsRain = true; - ts.LiquidPrecip = 3.0; - }); + for (int hr = 0; hr < Constant::iHoursInDay; ++hr) { + for (int ts = 0; ts < state.dataGlobal->TimeStepsInHour; ++ts) { + auto &wvars = state.dataWeather->wvarsHrTsTomorrow(ts+1, hr+1); + wvars.IsRain = true; + wvars.LiquidPrecip = 3.0; + } + } } else { OSky = 0; - ForAllHrTs(state, [&state](int iHr, int iTS) { - auto &ts = state.dataWeather->wvarsHrTsTomorrow(iTS, iHr); - ts.IsRain = false; - ts.LiquidPrecip = 0.0; - }); + for (int hr = 0; hr < Constant::iHoursInDay; ++hr) { + for (int ts = 0; ts < state.dataGlobal->TimeStepsInHour; ++ts) { + auto &wvars = state.dataWeather->wvarsHrTsTomorrow(ts+1, hr+1); + wvars.IsRain = false; + wvars.LiquidPrecip = 0.0; + } + } } Real64 GndReflet; // Ground Reflectivity if (desDayInput.SnowInd == 0) { GndReflet = 0.2; - ForAllHrTs(state, [&state](int iHr, int iTS) { - auto &ts = state.dataWeather->wvarsHrTsTomorrow(iTS, iHr); - ts.IsSnow = false; - }); + for (int hr = 0; hr < Constant::iHoursInDay; ++hr) { + for (int ts = 0; ts < state.dataGlobal->TimeStepsInHour; ++ts) { + auto &wvars = state.dataWeather->wvarsHrTsTomorrow(ts+1, hr+1); + wvars.IsSnow = false; + } + } } else { // Snow GndReflet = 0.7; - ForAllHrTs(state, [&state](int iHr, int iTS) { - auto &ts = state.dataWeather->wvarsHrTsTomorrow(iTS, iHr); - ts.IsSnow = true; - }); + for (int hr = 0; hr < Constant::iHoursInDay; ++hr) { + for (int ts = 0; ts < state.dataGlobal->TimeStepsInHour; ++ts) { + auto &wvars = state.dataWeather->wvarsHrTsTomorrow(ts+1, hr+1); + wvars.IsSnow = true; + } + } } // Some values are constant - ForAllHrTs(state, [&state, &desDayInput](int iHr, int iTS) { - auto &ts = state.dataWeather->wvarsHrTsTomorrow(iTS, iHr); - ts.OutBaroPress = desDayInput.PressBarom; - ts.WindSpeed = desDayInput.WindSpeed; - ts.WindDir = desDayInput.WindDir; - ts.Albedo = 0.0; - }); - + for (int hr = 0; hr < Constant::iHoursInDay; ++hr) { + for (int ts = 0; ts < state.dataGlobal->TimeStepsInHour; ++ts) { + auto &wvars = state.dataWeather->wvarsHrTsTomorrow(ts+1, hr+1); + wvars.OutBaroPress = desDayInput.PressBarom; + wvars.WindSpeed = desDayInput.WindSpeed; + wvars.WindDir = desDayInput.WindDir; + wvars.Albedo = 0.0; + } + } + // resolve daily ranges Real64 DBRange; // working copy of dry-bulb daily range, C (or 1 if input is difference) if (desDayInput.dryBulbRangeType == DesDayDryBulbRangeType::Difference) { @@ -3802,33 +3814,39 @@ namespace Weather { switch (state.dataWeather->WPSkyTemperature(envCurr.WP_Type1).skyTempModel) { case SkyTempModel::ScheduleValue: { - Array2D tmp = Array2D(state.dataGlobal->TimeStepsInHour, Constant::iHoursInDay); - state.dataWeather->WPSkyTemperature(envCurr.WP_Type1).sched->getDayVals(state, tmp); + std::vector const &dayVals = state.dataWeather->WPSkyTemperature(envCurr.WP_Type1).sched->getDayVals(state); auto &desDayModsEnvrn = state.dataWeather->desDayMods(EnvrnNum); - ForAllHrTs(state, [&state, &tmp, &desDayModsEnvrn](int iHr, int iTS) { - state.dataWeather->wvarsHrTsTomorrow(iTS, iHr).SkyTemp = desDayModsEnvrn(iTS, iHr).SkyTemp = tmp(iTS, iHr); - }); + for (int hr = 0; hr < Constant::iHoursInDay; ++hr) { + for (int ts = 0; ts < state.dataGlobal->TimeStepsInHour; ++ts) { + state.dataWeather->wvarsHrTsTomorrow(ts+1, hr+1).SkyTemp = desDayModsEnvrn(ts+1, hr+1).SkyTemp = dayVals[hr * state.dataGlobal->TimeStepsInHour]; + } + } } break; + case SkyTempModel::DryBulbDelta: { - Array2D tmp = Array2D(state.dataGlobal->TimeStepsInHour, Constant::iHoursInDay); - state.dataWeather->WPSkyTemperature(envCurr.WP_Type1).sched->getDayVals(state, tmp); + std::vector const &dayVals = state.dataWeather->WPSkyTemperature(envCurr.WP_Type1).sched->getDayVals(state); auto &desDayModsEnvrn = state.dataWeather->desDayMods(EnvrnNum); - ForAllHrTs(state, [&state, &tmp, &desDayModsEnvrn](int iHr, int iTS) { - auto &tomorrowTS = state.dataWeather->wvarsHrTsTomorrow(iTS, iHr); - desDayModsEnvrn(iTS, iHr).SkyTemp = tmp(iTS, iHr); - tomorrowTS.SkyTemp = tomorrowTS.OutDryBulbTemp - tmp(iTS, iHr); - }); + for (int hr = 0; hr < Constant::iHoursInDay; ++hr) { + for (int ts = 0; ts < state.dataGlobal->TimeStepsInHour; ++ts) { + auto &tomorrowTS = state.dataWeather->wvarsHrTsTomorrow(ts+1, hr+1); + desDayModsEnvrn(ts+1, hr+1).SkyTemp = dayVals[hr * state.dataGlobal->TimeStepsInHour + ts]; + tomorrowTS.SkyTemp = tomorrowTS.OutDryBulbTemp - dayVals[hr * state.dataGlobal->TimeStepsInHour + ts]; + } + } } break; + case SkyTempModel::DewPointDelta: { - Array2D tmp = Array2D(state.dataGlobal->TimeStepsInHour, Constant::iHoursInDay); - state.dataWeather->WPSkyTemperature(envCurr.WP_Type1).sched->getDayVals(state, tmp); + std::vector const &dayVals = state.dataWeather->WPSkyTemperature(envCurr.WP_Type1).sched->getDayVals(state); auto &desDayModsEnvrn = state.dataWeather->desDayMods(EnvrnNum); - ForAllHrTs(state, [&state, &tmp, &desDayModsEnvrn](int iHr, int iTS) { - auto &tomorrowTS = state.dataWeather->wvarsHrTsTomorrow(iTS, iHr); - desDayModsEnvrn(iTS, iHr).SkyTemp = tmp(iTS, iHr); - tomorrowTS.SkyTemp = tomorrowTS.OutDewPointTemp - tmp(iTS, iHr); - }); + for (int hr = 0; hr < Constant::iHoursInDay; ++hr) { + for (int ts = 0; ts < state.dataGlobal->TimeStepsInHour; ++ts) { + auto &tomorrowTS = state.dataWeather->wvarsHrTsTomorrow(ts+1, hr+1); + desDayModsEnvrn(ts+1, hr+1).SkyTemp = dayVals[hr * state.dataGlobal->TimeStepsInHour + ts]; + tomorrowTS.SkyTemp = tomorrowTS.OutDewPointTemp - dayVals[hr * state.dataGlobal->TimeStepsInHour + ts]; + } + } } break; + default: { } break; } // switch (skyTempModel) @@ -5984,12 +6002,11 @@ namespace Weather { ErrorsFound = true; } else { - Array2D tmp = Array2D(state.dataGlobal->TimeStepsInHour, Constant::iHoursInDay); - desDayInput.tempRangeSched->getDayVals(state, tmp); + std::vector const &dayVals = desDayInput.tempRangeSched->getDayVals(state); auto &desDayModEnvrn = state.dataWeather->desDayMods(EnvrnNum); - for (int iHr = 1; iHr <= Constant::iHoursInDay; ++iHr) { - for (int iTS = 1; iTS <= state.dataGlobal->TimeStepsInHour; ++iTS) { - desDayModEnvrn(iTS, iHr).OutDryBulbTemp = tmp(iTS, iHr); + for (int hr = 0; hr < Constant::iHoursInDay; ++hr) { + for (int ts = 0; ts <= state.dataGlobal->TimeStepsInHour; ++ts) { + desDayModEnvrn(ts+1, hr+1).OutDryBulbTemp = dayVals[hr * state.dataGlobal->TimeStepsInHour + ts]; } } @@ -6177,13 +6194,11 @@ namespace Weather { "Default Humidity (constant for day using Humidity Indicator Temp)."); // reset HumIndType ? } else { - Array2D tmp = Array2D(state.dataGlobal->TimeStepsInHour, Constant::iHoursInDay); - desDayInput.humIndSched->getDayVals(state, tmp); - + std::vector const &dayVals = desDayInput.humIndSched->getDayVals(state); auto &desDayModsEnvrn = state.dataWeather->desDayMods(EnvrnNum); - for (int iHr = 1; iHr <= Constant::iHoursInDay; ++iHr) - for (int iTS = 1; iTS <= state.dataGlobal->TimeStepsInHour; ++iTS) - desDayModsEnvrn(iTS, iHr).OutRelHum = tmp(iTS, iHr); + for (int hr = 0; hr < Constant::iHoursInDay; ++hr) + for (int ts = 0; ts < state.dataGlobal->TimeStepsInHour; ++ts) + desDayModsEnvrn(ts+1, hr+1).OutRelHum = dayVals[hr * state.dataGlobal->TimeStepsInHour + ts]; if (std::find(state.dataWeather->spSiteSchedNums.begin(), state.dataWeather->spSiteSchedNums.end(), desDayInput.humIndSched->Num) == state.dataWeather->spSiteSchedNums.end()) { @@ -6278,12 +6293,11 @@ namespace Weather { ShowSevereItemNotFound(state, eoh, ipsc->cAlphaFieldNames(11), ipsc->cAlphaArgs(11)); ErrorsFound = true; } else { - Array2D tmp = Array2D(state.dataGlobal->TimeStepsInHour, Constant::iHoursInDay); - desDayInput.beamSolarSched->getDayVals(state, tmp); + std::vector const &dayVals = desDayInput.beamSolarSched->getDayVals(state); auto &desDayModsEnvrn = state.dataWeather->desDayMods(EnvrnNum); - for (int iHr = 1; iHr <= Constant::iHoursInDay; ++iHr) - for (int iTS = 1; iTS <= state.dataGlobal->TimeStepsInHour; ++iTS) - desDayModsEnvrn(iTS, iHr).BeamSolarRad = tmp(iTS, iHr); + for (int hr = 0; hr < Constant::iHoursInDay; ++hr) + for (int ts = 0; ts < state.dataGlobal->TimeStepsInHour; ++ts) + desDayModsEnvrn(ts+1, hr+1).BeamSolarRad = dayVals[hr * state.dataGlobal->TimeStepsInHour + ts]; unitType = Constant::Units::W_m2; // units = "[W/m2]"; @@ -6315,12 +6329,11 @@ namespace Weather { ShowSevereItemNotFound(state, eoh, ipsc->cAlphaFieldNames(12), ipsc->cAlphaArgs(12)); ErrorsFound = true; } else { - Array2D tmp = Array2D(state.dataGlobal->TimeStepsInHour, Constant::iHoursInDay); - desDayInput.diffuseSolarSched->getDayVals(state, tmp); + std::vector const &dayVals = desDayInput.diffuseSolarSched->getDayVals(state); auto &desDayModsEnvrn = state.dataWeather->desDayMods(EnvrnNum); - for (int iHr = 1; iHr <= Constant::iHoursInDay; ++iHr) - for (int iTS = 1; iTS <= state.dataGlobal->TimeStepsInHour; ++iTS) - desDayModsEnvrn(iTS, iHr).DifSolarRad = tmp(iTS, iHr); + for (int hr = 0; hr < Constant::iHoursInDay; ++hr) + for (int ts = 0; ts < state.dataGlobal->TimeStepsInHour; ++ts) + desDayModsEnvrn(ts+1, hr+1).DifSolarRad = dayVals[hr * state.dataGlobal->TimeStepsInHour + ts]; // units = "[W/m2]"; unitType = Constant::Units::W_m2; @@ -6646,7 +6659,6 @@ namespace Weather { wpSkyTemp.IsSchedule = true; } } else { // See if it's a valid schedule. -#ifdef GET_OUT // How can a schedule be either a yearly schedule or a day schedule? if ((wpSkyTemp.sched = Sched::GetDaySchedule(state, ipsc->cAlphaArgs(3))) == nullptr) { ShowSevereItemNotFound(state, eoh, ipsc->cAlphaFieldNames(3), ipsc->cAlphaArgs(3)); @@ -6667,13 +6679,11 @@ namespace Weather { wpSkyTemp.IsSchedule = true; } } -#endif // GET_OUT } } - BooleanSwitch b; if (!wpSkyTemp.IsSchedule && !ipsc->lAlphaFieldBlanks(4)) { - if ((b = getYesNoValue(Util::makeUPPER(ipsc->cAlphaArgs(4)))) != BooleanSwitch::Invalid) { + if (BooleanSwitch b = getYesNoValue(ipsc->cAlphaArgs(4)); b != BooleanSwitch::Invalid) { wpSkyTemp.UseWeatherFileHorizontalIR = static_cast(b); } else { ShowSevereInvalidBool(state, eoh, ipsc->cAlphaFieldNames(4), ipsc->cAlphaArgs(4)); @@ -8649,13 +8659,6 @@ namespace Weather { } } - void ForAllHrTs(EnergyPlusData const &state, std::function f) - { - for (int iHr = 1; iHr <= Constant::iHoursInDay; ++iHr) - for (int iTS = 1; iTS <= state.dataGlobal->TimeStepsInHour; ++iTS) - f(iHr, iTS); - } - } // namespace Weather } // namespace EnergyPlus diff --git a/src/EnergyPlus/WeatherManager.hh b/src/EnergyPlus/WeatherManager.hh index c46e08414f8..6c7ec7ccedf 100644 --- a/src/EnergyPlus/WeatherManager.hh +++ b/src/EnergyPlus/WeatherManager.hh @@ -420,7 +420,7 @@ namespace Weather { std::string Name = ""; // Reference Name bool IsSchedule = true; // Default is using Schedule SkyTempModel skyTempModel = SkyTempModel::ClarkAllen; - Sched::Schedule *sched = nullptr; // schedule when used + Sched::DayOrYearSchedule *sched = nullptr; // schedule when used bool UsedForEnvrn = false; bool UseWeatherFileHorizontalIR = true; // If false, horizontal IR and sky temperature are calculated with WP models }; @@ -760,8 +760,6 @@ namespace Weather { Real64 SkyTemp = 0.0; }; - // Here's a fun little function - void ForAllHrTs(EnergyPlusData const &state, std::function f); } // namespace Weather struct WeatherManagerData : BaseGlobalStruct diff --git a/src/EnergyPlus/ZoneContaminantPredictorCorrector.cc b/src/EnergyPlus/ZoneContaminantPredictorCorrector.cc index 00a3e9fba5a..9e669f6d6a1 100644 --- a/src/EnergyPlus/ZoneContaminantPredictorCorrector.cc +++ b/src/EnergyPlus/ZoneContaminantPredictorCorrector.cc @@ -1106,8 +1106,7 @@ void GetZoneContaminanSetPoints(EnergyPlusData &state) } if (state.dataIPShortCut->lAlphaFieldBlanks(5)) { - ShowSevereEmptyField(state, eoh, state.dataIPShortCut->cAlphaFieldNames(5)); - ErrorsFound = true; + controlledZone.zoneMinCO2Sched = Sched::GetScheduleAlwaysOff(state); } else if ((controlledZone.zoneMinCO2Sched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(5))) == nullptr) { ShowSevereEmptyField(state, eoh, state.dataIPShortCut->cAlphaFieldNames(5), state.dataIPShortCut->cAlphaArgs(5)); ErrorsFound = true; @@ -1120,8 +1119,7 @@ void GetZoneContaminanSetPoints(EnergyPlusData &state) } if (state.dataIPShortCut->lAlphaFieldBlanks(6)) { - ShowSevereEmptyField(state, eoh, state.dataIPShortCut->cAlphaFieldNames(6)); - ErrorsFound = true; + controlledZone.zoneMaxCO2Sched = Sched::GetScheduleAlwaysOff(state); } else if ((controlledZone.zoneMaxCO2Sched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(6))) == nullptr) { ShowSevereEmptyField(state, eoh, state.dataIPShortCut->cAlphaFieldNames(6), state.dataIPShortCut->cAlphaArgs(6)); ErrorsFound = true; @@ -1133,7 +1131,12 @@ void GetZoneContaminanSetPoints(EnergyPlusData &state) state.dataHeatBal->Zone(controlledZone.ActualZoneNum).zoneMaxCO2Sched = controlledZone.zoneMaxCO2Sched; } - if (NumAlphas <= 6 || state.dataIPShortCut->lAlphaFieldBlanks(7)) { + if (NumAlphas <= 6) { + controlledZone.availSched = Sched::GetScheduleAlwaysOn(state); + continue; + } + + if (state.dataIPShortCut->lAlphaFieldBlanks(7)) { controlledZone.availSched = Sched::GetScheduleAlwaysOn(state); } else if ((controlledZone.availSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(7))) == nullptr) { ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(7), state.dataIPShortCut->cAlphaArgs(7)); diff --git a/src/EnergyPlus/ZoneTempPredictorCorrector.cc b/src/EnergyPlus/ZoneTempPredictorCorrector.cc index fc288ed826c..40bcc2381d5 100644 --- a/src/EnergyPlus/ZoneTempPredictorCorrector.cc +++ b/src/EnergyPlus/ZoneTempPredictorCorrector.cc @@ -166,12 +166,12 @@ static constexpr std::array comfort "ThermostatSetpoint:ThermalComfort:Fanger:SingleHeatingOrCooling", "ThermostatSetpoint:ThermalComfort:Fanger:DualSetpoint"}; -// static constexpr std::array comfortSetptTypeNamesUC = { -// "UNCONTROLLED", -// "THERMOSTATSETPOINT:THERMALCOMFORT:FANGER:SINGLEHEATING", -// "THERMOSTATSETPOINT:THERMALCOMFORT:FANGER:SINGLECOOLING", -// "THERMOSTATSETPOINT:THERMALCOMFORT:FANGER:SINGLEHEATINGORCOOLING", -// "THERMOSTATSETPOINT:THERMALCOMFORT:FANGER:DUALSETPOINT"}; +static constexpr std::array comfortSetptTypeNamesUC = { + "UNCONTROLLED", + "THERMOSTATSETPOINT:THERMALCOMFORT:FANGER:SINGLEHEATING", + "THERMOSTATSETPOINT:THERMALCOMFORT:FANGER:SINGLECOOLING", + "THERMOSTATSETPOINT:THERMALCOMFORT:FANGER:SINGLEHEATINGORCOOLING", + "THERMOSTATSETPOINT:THERMALCOMFORT:FANGER:DUALSETPOINT"}; Array1D_string const cZControlTypes(6, {"ZoneControl:Thermostat", @@ -1064,7 +1064,7 @@ void GetZoneAirSetPoints(EnergyPlusData &state) ShowSevereEmptyField(state, eoh, s_ipsc->cAlphaFieldNames(ctIdx)); ErrorsFound = true; continue; - } else if ((setptType = static_cast(getEnumValue(setptTypeNamesUC, s_ipsc->cAlphaArgs(ctIdx)))) + } else if ((setptType = static_cast(getEnumValue(comfortSetptTypeNamesUC, s_ipsc->cAlphaArgs(ctIdx)))) == HVAC::SetptType::Invalid) { ShowSevereInvalidKey(state, eoh, s_ipsc->cAlphaFieldNames(ctIdx), s_ipsc->cAlphaFieldNames(ctIdx)); ErrorsFound = true; @@ -1259,11 +1259,11 @@ void GetZoneAirSetPoints(EnergyPlusData &state) int setptIdx = Util::FindItem(setpt.Name, s_ztpc->comfortSetptScheds[(int)setptType]); if (setptType == HVAC::SetptType::SingleHeat || setptType == HVAC::SetptType::SingleHeatCool || setptType == HVAC::SetptType::DualHeatCool) { - setpt.heatSetptSched = s_ztpc->tempSetptScheds[(int)setptType](setptIdx).heatSched; + setpt.heatSetptSched = s_ztpc->comfortSetptScheds[(int)setptType](setptIdx).heatSched; } if (setptType == HVAC::SetptType::SingleCool || setptType == HVAC::SetptType::SingleHeatCool || setptType == HVAC::SetptType::DualHeatCool) { - setpt.coolSetptSched = s_ztpc->tempSetptScheds[(int)setptType](setptIdx).coolSched; + setpt.coolSetptSched = s_ztpc->comfortSetptScheds[(int)setptType](setptIdx).coolSched; } TComfortControlTypes(ComfortControlledZoneNum).MustHave[(int)setptType] = true; @@ -3133,7 +3133,6 @@ void CalcZoneAirTempSetPoints(EnergyPlusData &state) // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int RelativeZoneNum; int ActualZoneNum; - Array2D DaySPValues; // Day room temp setpoint values - for optimum start int OccStartTime; // Occupancy start time - for optimum start Real64 DeltaT; // Temperature difference between cutout and setpoint @@ -3215,13 +3214,10 @@ void CalcZoneAirTempSetPoints(EnergyPlusData &state) // Change the room set point to occupied set point during optimum start period-------------- if (allocated(state.dataAvail->OptStart)) { - if (!allocated(DaySPValues)) { - DaySPValues.allocate(state.dataGlobal->TimeStepsInHour, Constant::iHoursInDay); - } if (state.dataAvail->OptStart(ActualZoneNum).ActualZoneNum == ActualZoneNum) { - tempZone.setpts[(int)HVAC::SetptType::SingleHeat].heatSetptSched->getDayVals(state, DaySPValues); + OccStartTime = CEILING(state.dataAvail->OptStart(ActualZoneNum).OccStartTime) + 1; - zoneTstatSetpt.setpt = DaySPValues(1, OccStartTime); + zoneTstatSetpt.setpt = tempZone.setpts[(int)HVAC::SetptType::SingleHeat].heatSetptSched->getDayVals(state)[OccStartTime * state.dataGlobal->TimeStepsInHour]; } if (state.dataAvail->OptStart(ActualZoneNum).OptStartFlag) { @@ -3251,16 +3247,13 @@ void CalcZoneAirTempSetPoints(EnergyPlusData &state) // Change the room set point to occupied set point during optimum start period-------------- if (allocated(state.dataAvail->OptStart)) { - if (!allocated(DaySPValues)) { - DaySPValues.allocate(state.dataGlobal->TimeStepsInHour, Constant::iHoursInDay); - } if (state.dataAvail->OptStart(ActualZoneNum).ActualZoneNum == ActualZoneNum) { // TODO: Why are we getting all day values if all we want is the value at (1, OccStartTime); - tempZone.setpts[(int)HVAC::SetptType::DualHeatCool].coolSetptSched->getDayVals(state, DaySPValues); OccStartTime = CEILING(state.dataAvail->OptStart(ActualZoneNum).OccStartTime) + 1; - state.dataZoneCtrls->OccRoomTSetPointCool(ActualZoneNum) = DaySPValues(1, OccStartTime); - tempZone.setpts[(int)HVAC::SetptType::DualHeatCool].heatSetptSched->getDayVals(state, DaySPValues); - state.dataZoneCtrls->OccRoomTSetPointHeat(ActualZoneNum) = DaySPValues(1, OccStartTime); + state.dataZoneCtrls->OccRoomTSetPointCool(ActualZoneNum) = + tempZone.setpts[(int)HVAC::SetptType::DualHeatCool].coolSetptSched->getDayVals(state)[OccStartTime * state.dataGlobal->TimeStepsInHour]; + state.dataZoneCtrls->OccRoomTSetPointHeat(ActualZoneNum) = + tempZone.setpts[(int)HVAC::SetptType::DualHeatCool].heatSetptSched->getDayVals(state)[OccStartTime * state.dataGlobal->TimeStepsInHour]; } if (state.dataAvail->OptStart(ActualZoneNum).OptStartFlag) { diff --git a/tst/EnergyPlus/unit/HVACVariableRefrigerantFlow.unit.cc b/tst/EnergyPlus/unit/HVACVariableRefrigerantFlow.unit.cc index 8f3c808d767..a34edf3be39 100644 --- a/tst/EnergyPlus/unit/HVACVariableRefrigerantFlow.unit.cc +++ b/tst/EnergyPlus/unit/HVACVariableRefrigerantFlow.unit.cc @@ -5844,10 +5844,7 @@ TEST_F(EnergyPlusFixture, VRFTest_SysCurve_WaterCooled) state->dataZoneEnergyDemand->ZoneSysEnergyDemand.allocate(1); state->dataZoneTempPredictorCorrector->zoneHeatBalance.allocate(1); - Array2D DummyArray; // Sky temperature - DummyArray.allocate(state->dataGlobal->TimeStepsInHour, Constant::iHoursInDay); - DummyArray = 0.0; - Sched::GetSchedule(*state, "MAIN LOOP TEMP SCH")->getDayVals(*state, DummyArray, 58, 3); + Sched::GetSchedule(*state, "MAIN LOOP TEMP SCH")->getDayVals(*state, 58, 3); Curve::GetCurveInput(*state); // read curves HeatBalanceManager::GetZoneData(*state, ErrorsFound); // read zone data diff --git a/tst/EnergyPlus/unit/WeatherManager.unit.cc b/tst/EnergyPlus/unit/WeatherManager.unit.cc index ac0b96973b3..b9043c72eee 100644 --- a/tst/EnergyPlus/unit/WeatherManager.unit.cc +++ b/tst/EnergyPlus/unit/WeatherManager.unit.cc @@ -133,30 +133,22 @@ TEST_F(EnergyPlusFixture, SkyTempTest) state->init_state(*state); - Array2D TomorrowSkyTemp; // Sky temperature - TomorrowSkyTemp.allocate(state->dataGlobal->TimeStepsInHour, 24); - TomorrowSkyTemp = 0.0; - auto *tSkySched = Sched::GetSchedule(*state, "TSKYSCHEDULE"); // Febuary 27 - tSkySched->getDayVals(*state, TomorrowSkyTemp, 58, 3); - EXPECT_NEAR(2.27, TomorrowSkyTemp(1, 1), .001); + + EXPECT_NEAR(2.27, tSkySched->getDayVals(*state, 58, 3)[0 * state->dataGlobal->TimeStepsInHour + 0], .001); // Febuary 28 - tSkySched->getDayVals(*state, TomorrowSkyTemp, 59, 4); - EXPECT_NEAR(2.28, TomorrowSkyTemp(1, 1), .001); + EXPECT_NEAR(2.28, tSkySched->getDayVals(*state, 59, 4)[0 * state->dataGlobal->TimeStepsInHour + 0], .001); // March 1 - tSkySched->getDayVals(*state, TomorrowSkyTemp, 60, 5); - EXPECT_NEAR(3.01, TomorrowSkyTemp(1, 1), .001); + EXPECT_NEAR(3.01, tSkySched->getDayVals(*state, 60, 5)[0 * state->dataGlobal->TimeStepsInHour + 0], .001); // Not March 2, this "Day" is ignored unless its a leap year, otherwise same data as March 1 - tSkySched->getDayVals(*state, TomorrowSkyTemp, 61, 6); - EXPECT_NEAR(3.01, TomorrowSkyTemp(1, 1), .001); + EXPECT_NEAR(3.01, tSkySched->getDayVals(*state, 61, 6)[0 * state->dataGlobal->TimeStepsInHour + 0], .001); // March 2 - tSkySched->getDayVals(*state, TomorrowSkyTemp, 62, 6); - EXPECT_NEAR(3.02, TomorrowSkyTemp(1, 1), .001); + EXPECT_NEAR(3.02, tSkySched->getDayVals(*state, 62, 6)[0 * state->dataGlobal->TimeStepsInHour + 0], .001); } TEST_F(EnergyPlusFixture, SkyEmissivityTest) From 1272641cae472856fdfddaf4c1809b8d48e909dc Mon Sep 17 00:00:00 2001 From: amirroth Date: Sun, 8 Dec 2024 11:34:03 -0500 Subject: [PATCH 3/3] Fix EMS issues and several others --- src/EnergyPlus/DataRuntimeLanguage.hh | 2 +- src/EnergyPlus/EMSManager.cc | 52 +++++----- src/EnergyPlus/PlantCentralGSHP.cc | 1 + src/EnergyPlus/ScheduleManager.cc | 96 ++++++++++--------- src/EnergyPlus/WeatherManager.cc | 2 +- .../ZoneContaminantPredictorCorrector.cc | 4 +- ...HRAE901_RetailStripmall_STD2019_Denver.idf | 2 +- tst/EnergyPlus/unit/DataHeatBalance.unit.cc | 18 ++-- 8 files changed, 91 insertions(+), 86 deletions(-) diff --git a/src/EnergyPlus/DataRuntimeLanguage.hh b/src/EnergyPlus/DataRuntimeLanguage.hh index 451d0c59e24..d93d794f900 100644 --- a/src/EnergyPlus/DataRuntimeLanguage.hh +++ b/src/EnergyPlus/DataRuntimeLanguage.hh @@ -806,7 +806,7 @@ struct RuntimeLanguageData : BaseGlobalStruct DataRuntimeLanguage::ErlValueType True = DataRuntimeLanguage::ErlValueType( DataRuntimeLanguage::Value::Null, 0.0, "", 0, 0, false, 0, "", true); // special "True" Erl variable value instance, gets reset - std::map, int> EMSActuatorAvailableMap; + std::map, int> EMSActuatorAvailableMap; void init_constant_state([[maybe_unused]] EnergyPlusData &state) override { diff --git a/src/EnergyPlus/EMSManager.cc b/src/EnergyPlus/EMSManager.cc index dc0b10fc736..9a217dae344 100644 --- a/src/EnergyPlus/EMSManager.cc +++ b/src/EnergyPlus/EMSManager.cc @@ -1958,9 +1958,9 @@ namespace EMSManager { // ScheduleManager and OutputProcessor. Followed pattern used for SetupOutputVariable void SetupEMSActuator(EnergyPlusData &state, - std::string_view cComponentTypeName, - std::string_view cUniqueIDName, - std::string_view cControlTypeName, + std::string_view objType, + std::string_view objName, + std::string_view controlTypeName, std::string_view cUnits, bool &lEMSActuated, Real64 &rValue) @@ -1981,34 +1981,32 @@ void SetupEMSActuator(EnergyPlusData &state, auto &s_lang = state.dataRuntimeLang; - std::string const objType = Util::makeUPPER(cComponentTypeName); - std::string const objName = Util::makeUPPER(cUniqueIDName); - std::string const actuatorName = Util::makeUPPER(cControlTypeName); + auto tup = std::make_tuple(std::move(Util::makeUPPER(objType)), std::move(Util::makeUPPER(objName)), std::move(Util::makeUPPER(controlTypeName))); // DataRuntimeLanguage::EMSActuatorKey const key(UpperCaseObjectType, UpperCaseObjectName, UpperCaseActuatorName); - auto found = s_lang->EMSActuatorAvailableMap.find(std::make_tuple(objType, objName, actuatorName)); - if (found == s_lang->EMSActuatorAvailableMap.end()) { - if (s_lang->numEMSActuatorsAvailable == 0) { - s_lang->EMSActuatorAvailable.allocate(s_lang->varsAvailableAllocInc); - s_lang->numEMSActuatorsAvailable = 1; - s_lang->maxEMSActuatorsAvailable = s_lang->varsAvailableAllocInc; - } else { - if (s_lang->numEMSActuatorsAvailable + 1 > s_lang->maxEMSActuatorsAvailable) { - s_lang->EMSActuatorAvailable.redimension(s_lang->maxEMSActuatorsAvailable *= 2); - } - ++s_lang->numEMSActuatorsAvailable; + if (s_lang->EMSActuatorAvailableMap.find(tup) != s_lang->EMSActuatorAvailableMap.end()) + return; + + if (s_lang->numEMSActuatorsAvailable == 0) { + s_lang->EMSActuatorAvailable.allocate(s_lang->varsAvailableAllocInc); + s_lang->numEMSActuatorsAvailable = 1; + s_lang->maxEMSActuatorsAvailable = s_lang->varsAvailableAllocInc; + } else { + if (s_lang->numEMSActuatorsAvailable + 1 > s_lang->maxEMSActuatorsAvailable) { + s_lang->EMSActuatorAvailable.redimension(s_lang->maxEMSActuatorsAvailable *= 2); } - - auto &actuator = s_lang->EMSActuatorAvailable(s_lang->numEMSActuatorsAvailable); - actuator.ComponentTypeName = cComponentTypeName; - actuator.UniqueIDName = cUniqueIDName; - actuator.ControlTypeName = cControlTypeName; - actuator.Units = cUnits; - actuator.Actuated = &lEMSActuated; // Pointer assigment - actuator.RealValue = &rValue; // Pointer assigment - actuator.PntrVarTypeUsed = DataRuntimeLanguage::PtrDataType::Real; - s_lang->EMSActuatorAvailableMap.insert_or_assign(std::make_tuple(objType, objName, actuatorName), s_lang->numEMSActuatorsAvailable); + ++s_lang->numEMSActuatorsAvailable; } + + auto &actuator = s_lang->EMSActuatorAvailable(s_lang->numEMSActuatorsAvailable); + actuator.ComponentTypeName = objType; + actuator.UniqueIDName = objName; + actuator.ControlTypeName = controlTypeName; + actuator.Units = cUnits; + actuator.Actuated = &lEMSActuated; // Pointer assigment + actuator.RealValue = &rValue; // Pointer assigment + actuator.PntrVarTypeUsed = DataRuntimeLanguage::PtrDataType::Real; + s_lang->EMSActuatorAvailableMap.insert_or_assign(std::move(tup), s_lang->numEMSActuatorsAvailable); } void SetupEMSActuator(EnergyPlusData &state, diff --git a/src/EnergyPlus/PlantCentralGSHP.cc b/src/EnergyPlus/PlantCentralGSHP.cc index 4f071ab14ae..878e2571f16 100644 --- a/src/EnergyPlus/PlantCentralGSHP.cc +++ b/src/EnergyPlus/PlantCentralGSHP.cc @@ -681,6 +681,7 @@ void GetWrapperInput(EnergyPlusData &state) state.dataPlantCentralGSHP->Wrapper(WrapperNum).AncillaryPower = state.dataIPShortCut->rNumericArgs(1); if (state.dataIPShortCut->lAlphaFieldBlanks(9)) { + state.dataPlantCentralGSHP->Wrapper(WrapperNum).ancillaryPowerSched = Sched::GetScheduleAlwaysOff(state); } else if ((state.dataPlantCentralGSHP->Wrapper(WrapperNum).ancillaryPowerSched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(9))) == nullptr) { ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(9), state.dataIPShortCut->cAlphaArgs(9)); } diff --git a/src/EnergyPlus/ScheduleManager.cc b/src/EnergyPlus/ScheduleManager.cc index 6c624c65fc5..846a56f2d21 100644 --- a/src/EnergyPlus/ScheduleManager.cc +++ b/src/EnergyPlus/ScheduleManager.cc @@ -198,16 +198,15 @@ namespace Sched { auto &s_glob = state.dataGlobal; if (this->interpolation == Interpolation::Average) { for (int hr = 0; hr < Constant::iHoursInDay; ++hr) { - int begMinute = 0; - int endMinute = s_glob->MinutesInTimeStep - 1; + int begMin = 0; + int endMin = s_glob->MinutesInTimeStep - 1; for (int ts = 0; ts < s_glob->TimeStepsInHour; ++ts) { this->tsVals[hr * s_glob->TimeStepsInHour + ts] = - std::accumulate(minuteVals.begin() + (hr * Constant::iMinutesInHour + begMinute), - minuteVals.begin() + (hr * Constant::iMinutesInHour + endMinute), - 0) / double(s_glob->MinutesInTimeStep); + std::accumulate(&minuteVals[hr * Constant::iMinutesInHour + begMin], &minuteVals[hr * Constant::iMinutesInHour + endMin + 1], 0) / + double(s_glob->MinutesInTimeStep); this->sumTsVals += this->tsVals[hr * s_glob->TimeStepsInHour + ts]; - begMinute = endMinute + 1; - endMinute += s_glob->MinutesInTimeStep; + begMin = endMin + 1; + endMin += s_glob->MinutesInTimeStep; } } } else { @@ -230,7 +229,7 @@ namespace Sched { sched->Name = name; sched->Num = (int)s_sched->schedules.size(); s_sched->schedules.push_back(sched); - s_sched->scheduleMap.insert_or_assign(Util::makeUPPER(sched->Name), sched->Num); + s_sched->scheduleMap.insert_or_assign(std::move(Util::makeUPPER(sched->Name)), sched->Num); sched->type = SchedType::Constant; return sched; @@ -245,7 +244,7 @@ namespace Sched { sched->Num = (int)s_sched->schedules.size(); s_sched->schedules.push_back(sched); - s_sched->scheduleMap.insert_or_assign(Util::makeUPPER(sched->Name), sched->Num); + s_sched->scheduleMap.insert_or_assign(std::move(Util::makeUPPER(sched->Name)), sched->Num); sched->type = SchedType::Year; return sched; @@ -261,7 +260,7 @@ namespace Sched { daySched->Num = (int)s_sched->daySchedules.size(); s_sched->daySchedules.push_back(daySched); - s_sched->dayScheduleMap.insert_or_assign(Util::makeUPPER(daySched->Name), daySched->Num); + s_sched->dayScheduleMap.insert_or_assign(std::move(Util::makeUPPER(daySched->Name)), daySched->Num); daySched->tsVals.resize(Constant::iHoursInDay * s_glob->TimeStepsInHour); @@ -277,7 +276,7 @@ namespace Sched { weekSched->Num = (int)s_sched->weekSchedules.size(); s_sched->weekSchedules.push_back(weekSched); - s_sched->weekScheduleMap.insert_or_assign(Util::makeUPPER(weekSched->Name), weekSched->Num); + s_sched->weekScheduleMap.insert_or_assign(std::move(Util::makeUPPER(weekSched->Name)), weekSched->Num); return weekSched; } // AddWeekSchedule() @@ -1375,16 +1374,16 @@ namespace Sched { } } else { for (int hr = 0; hr < Constant::iHoursInDay; ++hr) { - int begMinute = 0; - int endMinute = s_glob->MinutesInTimeStep - 1; + int begMin = 0; + int endMin = s_glob->MinutesInTimeStep - 1; for (int ts = 0; ts < s_glob->TimeStepsInHour; ++ts) { daySched->tsVals[hr * s_glob->TimeStepsInHour + ts] = - std::accumulate(minuteVals.begin() + (hr * Constant::iMinutesInHour + begMinute), - minuteVals.begin() + (hr * Constant::iMinutesInHour + endMinute), + std::accumulate(&minuteVals[hr * Constant::iMinutesInHour + begMin], + &minuteVals[hr * Constant::iMinutesInHour + endMin + 1], 0) / double(s_glob->MinutesInTimeStep); daySched->sumTsVals += daySched->tsVals[hr * s_glob->TimeStepsInHour + ts]; - begMinute = endMinute + 1; - endMinute += s_glob->MinutesInTimeStep; + begMin = endMin + 1; + endMin += s_glob->MinutesInTimeStep; } } } @@ -1499,7 +1498,7 @@ namespace Sched { cNumericFields); ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)}; - + if (s_sched->scheduleMap.find(Alphas(1)) != s_sched->scheduleMap.end()) { ShowSevereDuplicateName(state, eoh); ErrorsFound = true; @@ -1564,11 +1563,11 @@ namespace Sched { } // is it a sub-hourly schedule or not? - int MinutesPerItem = 60; + int MinutesPerItem = Constant::iMinutesInHour; if (NumNumbers > 3) { MinutesPerItem = int(Numbers(4)); // int NumExpectedItems = 1440 / MinutesPerItem; - if (mod(60, MinutesPerItem) != 0) { + if (mod(Constant::iMinutesInHour, MinutesPerItem) != 0) { ShowSevereCustom(state, eoh, format("Requested {} field value ({}) not evenly divisible into 60", cNumericFields(4), MinutesPerItem)); ErrorsFound = true; continue; @@ -1576,8 +1575,8 @@ namespace Sched { } int numHourlyValues = Numbers(3); - int rowLimitCount = (Numbers(3) * 60.0) / MinutesPerItem; - int hrLimitCount = 60 / MinutesPerItem; + int rowLimitCount = (Numbers(3) * Constant::rMinutesInHour) / MinutesPerItem; + int hrLimitCount = Constant::iMinutesInHour / MinutesPerItem; std::string contextString = format("{}=\"{}\", {}: ", CurrentModuleObject, Alphas(1), cAlphaFields(3)); @@ -1630,7 +1629,7 @@ namespace Sched { if (rowCnt < rowLimitCount) { ShowWarningCustom(state, eoh, format("less than {} hourly values read from file." - "..Number read={}.", numHourlyValues, (rowCnt * 60) / MinutesPerItem)); + "..Number read={}.", numHourlyValues, (rowCnt * Constant::iMinutesInHour) / MinutesPerItem)); } // process the data into the normal schedule data structures @@ -1672,38 +1671,38 @@ namespace Sched { } } else { // Minutes Per Item < 60 for (int hr = 0; hr < Constant::iHoursInDay; ++hr) { - int endMinute = MinutesPerItem - 1; - int begMinute = 0; + int endMin = MinutesPerItem - 1; + int begMin = 0; for (int NumFields = 1; NumFields <= hrLimitCount; ++NumFields) { - std::fill(&minuteVals[hr * Constant::iMinutesInHour + begMinute], - &minuteVals[hr * Constant::iMinutesInHour + endMinute], + std::fill(&minuteVals[hr * Constant::iMinutesInHour + begMin], + &minuteVals[hr * Constant::iMinutesInHour + endMin + 1], column_values[ifld]); ++ifld; - begMinute = endMinute + 1; - endMinute += MinutesPerItem; + begMin = endMin + 1; + endMin += MinutesPerItem; } } if (FileIntervalInterpolated) { for (int hr = 0; hr < Constant::iHoursInDay; ++hr) { - int begMinute = 0; - int endMinute = s_glob->MinutesInTimeStep - 1; + int begMin = 0; + int endMin = s_glob->MinutesInTimeStep - 1; for (int ts = 0; ts < s_glob->TimeStepsInHour; ++ts) { daySched->tsVals[hr * s_glob->TimeStepsInHour + ts] = - std::accumulate(minuteVals.begin() + (hr * Constant::iMinutesInHour + begMinute), - minuteVals.begin() + (hr * Constant::iMinutesInHour + endMinute), + std::accumulate(&minuteVals[hr * Constant::iMinutesInHour + begMin], + &minuteVals[hr * Constant::iMinutesInHour + endMin + 1], 0) / double(s_glob->MinutesInTimeStep); daySched->sumTsVals += daySched->tsVals[hr * s_glob->TimeStepsInHour + ts]; - begMinute = endMinute + 1; - endMinute += s_glob->MinutesInTimeStep; + begMin = endMin + 1; + endMin += s_glob->MinutesInTimeStep; } } } else { for (int hr = 0; hr < Constant::iHoursInDay; ++hr) { - int curMinute = s_glob->MinutesInTimeStep - 1; + int curMin = s_glob->MinutesInTimeStep - 1; for (int ts = 0; ts < s_glob->TimeStepsInHour; ++ts) { - daySched->tsVals[hr * s_glob->TimeStepsInHour + ts] = minuteVals[hr * Constant::iMinutesInHour + curMinute]; + daySched->tsVals[hr * s_glob->TimeStepsInHour + ts] = minuteVals[hr * Constant::iMinutesInHour + curMin]; daySched->sumTsVals += daySched->tsVals[hr * s_glob->TimeStepsInHour + ts]; - curMinute += s_glob->MinutesInTimeStep; + curMin += s_glob->MinutesInTimeStep; } } } @@ -2777,7 +2776,19 @@ namespace Sched { curValue = StartValue + incrementPerMinute; } - if (begHr == endHr) { + if (begHr > endHr) { + if (begHr == endHr + 1 && begMin == 0 && endMin == Constant::iMinutesInHour - 1) { + ShowWarningError(state, format("ProcessScheduleInput: ProcessIntervalFields, Processing time fields, zero time interval detected, {}={}", + ErrContext, DayScheduleName)); + } else { + ShowSevereError(state, + format("ProcessScheduleInput: ProcessIntervalFields, Processing time fields, overlapping times detected, {}={}", + ErrContext, + DayScheduleName)); + ErrorsFound = true; + } + + } else if (begHr == endHr) { if (std::find(&setMinuteVals[begHr * Constant::iMinutesInHour + begMin], &setMinuteVals[begHr * Constant::iMinutesInHour + endMin + 1], true) != &setMinuteVals[begHr * Constant::iMinutesInHour + endMin + 1]) { @@ -2809,13 +2820,6 @@ namespace Sched { begMin = 0; } - } else if (endHr < begHr) { - ShowSevereError(state, - format("ProcessScheduleInput: ProcessIntervalFields, Processing time fields, overlapping times detected, {}={}", - ErrContext, - DayScheduleName)); - ErrorsFound = true; - } else { // begHr < endHr if (interpolation == Interpolation::Linear) { for (int iMin = begMin; iMin < Constant::iMinutesInHour; ++iMin) { // for portion of starting hour diff --git a/src/EnergyPlus/WeatherManager.cc b/src/EnergyPlus/WeatherManager.cc index 5c8174e9bbb..89b3a7a8047 100644 --- a/src/EnergyPlus/WeatherManager.cc +++ b/src/EnergyPlus/WeatherManager.cc @@ -6005,7 +6005,7 @@ namespace Weather { std::vector const &dayVals = desDayInput.tempRangeSched->getDayVals(state); auto &desDayModEnvrn = state.dataWeather->desDayMods(EnvrnNum); for (int hr = 0; hr < Constant::iHoursInDay; ++hr) { - for (int ts = 0; ts <= state.dataGlobal->TimeStepsInHour; ++ts) { + for (int ts = 0; ts < state.dataGlobal->TimeStepsInHour; ++ts) { desDayModEnvrn(ts+1, hr+1).OutDryBulbTemp = dayVals[hr * state.dataGlobal->TimeStepsInHour + ts]; } } diff --git a/src/EnergyPlus/ZoneContaminantPredictorCorrector.cc b/src/EnergyPlus/ZoneContaminantPredictorCorrector.cc index 9e669f6d6a1..013b404048f 100644 --- a/src/EnergyPlus/ZoneContaminantPredictorCorrector.cc +++ b/src/EnergyPlus/ZoneContaminantPredictorCorrector.cc @@ -1108,7 +1108,7 @@ void GetZoneContaminanSetPoints(EnergyPlusData &state) if (state.dataIPShortCut->lAlphaFieldBlanks(5)) { controlledZone.zoneMinCO2Sched = Sched::GetScheduleAlwaysOff(state); } else if ((controlledZone.zoneMinCO2Sched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(5))) == nullptr) { - ShowSevereEmptyField(state, eoh, state.dataIPShortCut->cAlphaFieldNames(5), state.dataIPShortCut->cAlphaArgs(5)); + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(5), state.dataIPShortCut->cAlphaArgs(5)); ErrorsFound = true; } else if (!controlledZone.zoneMinCO2Sched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 2000.0)) { Sched::ShowSevereBadMinMax(state, eoh, state.dataIPShortCut->cAlphaFieldNames(5), state.dataIPShortCut->cAlphaArgs(5), @@ -1121,7 +1121,7 @@ void GetZoneContaminanSetPoints(EnergyPlusData &state) if (state.dataIPShortCut->lAlphaFieldBlanks(6)) { controlledZone.zoneMaxCO2Sched = Sched::GetScheduleAlwaysOff(state); } else if ((controlledZone.zoneMaxCO2Sched = Sched::GetSchedule(state, state.dataIPShortCut->cAlphaArgs(6))) == nullptr) { - ShowSevereEmptyField(state, eoh, state.dataIPShortCut->cAlphaFieldNames(6), state.dataIPShortCut->cAlphaArgs(6)); + ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(6), state.dataIPShortCut->cAlphaArgs(6)); ErrorsFound = true; } else if (!controlledZone.zoneMaxCO2Sched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 2000.0)) { Sched::ShowSevereBadMinMax(state, eoh, state.dataIPShortCut->cAlphaFieldNames(6), state.dataIPShortCut->cAlphaArgs(6), diff --git a/testfiles/ASHRAE901_RetailStripmall_STD2019_Denver.idf b/testfiles/ASHRAE901_RetailStripmall_STD2019_Denver.idf index 21ca4ead73d..724fc52a0e8 100644 --- a/testfiles/ASHRAE901_RetailStripmall_STD2019_Denver.idf +++ b/testfiles/ASHRAE901_RetailStripmall_STD2019_Denver.idf @@ -852,7 +852,7 @@ Until: 24:00,23.89, !- Field 23 For: Sunday Holidays AllOtherDays, !- Field 25 Until: 8:00,29.44, !- Field 26 - Until: 8:00,26.67, !- Field 28 + Until: 8:00,26.67, !- Field 28 Is this supposed to be 9:00? Until: 23:00,23.89, !- Field 30 Until: 24:00,23.89; !- Field 32 diff --git a/tst/EnergyPlus/unit/DataHeatBalance.unit.cc b/tst/EnergyPlus/unit/DataHeatBalance.unit.cc index 97059096504..6145bdf3e05 100644 --- a/tst/EnergyPlus/unit/DataHeatBalance.unit.cc +++ b/tst/EnergyPlus/unit/DataHeatBalance.unit.cc @@ -855,7 +855,9 @@ TEST_F(EnergyPlusFixture, DataHeatBalance_CheckConstructLayers) GetEMSInput(*state); // check if EMS actuator is not setup because there is no blind/shade layer SetupWindowShadingControlActuators(*state); - EXPECT_EQ(state->dataRuntimeLang->numEMSActuatorsAvailable, 0); // no EMS actuator because there is shade/blind layer + + // init_state() checks for EMS so there will be actuators for schedules and materials already + EXPECT_EQ(state->dataRuntimeLang->numEMSActuatorsAvailable, 19); // add a blind layer in between glass state->dataConstruction->Construct(4).TotLayers = 5; @@ -884,13 +886,13 @@ TEST_F(EnergyPlusFixture, DataHeatBalance_CheckConstructLayers) state->dataSurface->surfShades(windowSurfNum).blind.movableSlats = true; // check if EMS actuator is available when blind layer is added SetupWindowShadingControlActuators(*state); - EXPECT_EQ(state->dataRuntimeLang->numEMSActuatorsAvailable, 2); - EXPECT_EQ(state->dataRuntimeLang->EMSActuatorAvailable(1).ComponentTypeName, "Window Shading Control"); - EXPECT_EQ(state->dataRuntimeLang->EMSActuatorAvailable(1).ControlTypeName, "Control Status"); - EXPECT_EQ(state->dataRuntimeLang->EMSActuatorAvailable(1).Units, "[ShadeStatus]"); - EXPECT_EQ(state->dataRuntimeLang->EMSActuatorAvailable(2).ComponentTypeName, "Window Shading Control"); - EXPECT_EQ(state->dataRuntimeLang->EMSActuatorAvailable(2).ControlTypeName, "Slat Angle"); - EXPECT_EQ(state->dataRuntimeLang->EMSActuatorAvailable(2).Units, "[degrees]"); + EXPECT_EQ(state->dataRuntimeLang->numEMSActuatorsAvailable, 21); + EXPECT_EQ(state->dataRuntimeLang->EMSActuatorAvailable(20).ComponentTypeName, "Window Shading Control"); + EXPECT_EQ(state->dataRuntimeLang->EMSActuatorAvailable(20).ControlTypeName, "Control Status"); + EXPECT_EQ(state->dataRuntimeLang->EMSActuatorAvailable(20).Units, "[ShadeStatus]"); + EXPECT_EQ(state->dataRuntimeLang->EMSActuatorAvailable(21).ComponentTypeName, "Window Shading Control"); + EXPECT_EQ(state->dataRuntimeLang->EMSActuatorAvailable(21).ControlTypeName, "Slat Angle"); + EXPECT_EQ(state->dataRuntimeLang->EMSActuatorAvailable(21).Units, "[degrees]"); } TEST_F(EnergyPlusFixture, DataHeatBalance_setUserTemperatureLocationPerpendicular)