From 828c430665a38620ce09a888a2864dc678a356fe Mon Sep 17 00:00:00 2001 From: brianlball Date: Fri, 16 Oct 2020 15:23:26 -0600 Subject: [PATCH 1/8] convert SteamCoil --- src/EnergyPlus/Data/CommonIncludes.hh | 1 + src/EnergyPlus/Data/EnergyPlusData.cc | 2 + src/EnergyPlus/Data/EnergyPlusData.hh | 2 + src/EnergyPlus/FaultsManager.cc | 12 +- src/EnergyPlus/OutputReportTabular.cc | 8 +- src/EnergyPlus/OutputReportTabular.hh | 4 +- src/EnergyPlus/PackagedTerminalHeatPump.cc | 3 +- src/EnergyPlus/SimulationManager.cc | 2 +- src/EnergyPlus/StateManagement.cc | 4 +- src/EnergyPlus/SteamCoils.cc | 858 ++++++++---------- src/EnergyPlus/SteamCoils.hh | 97 +- src/EnergyPlus/ThermalComfort.cc | 35 + src/EnergyPlus/ThermalComfort.hh | 4 + .../unit/HVACVariableRefrigerantFlow.unit.cc | 82 +- tst/EnergyPlus/unit/OutdoorAirUnit.unit.cc | 30 +- .../unit/OutputReportTabular.unit.cc | 2 +- 16 files changed, 511 insertions(+), 635 deletions(-) diff --git a/src/EnergyPlus/Data/CommonIncludes.hh b/src/EnergyPlus/Data/CommonIncludes.hh index 56870f93910..745f2cbe5b5 100644 --- a/src/EnergyPlus/Data/CommonIncludes.hh +++ b/src/EnergyPlus/Data/CommonIncludes.hh @@ -82,6 +82,7 @@ #include #include #include +#include #include #include #include diff --git a/src/EnergyPlus/Data/EnergyPlusData.cc b/src/EnergyPlus/Data/EnergyPlusData.cc index 0be774ebc5c..f4d05549820 100644 --- a/src/EnergyPlus/Data/EnergyPlusData.cc +++ b/src/EnergyPlus/Data/EnergyPlusData.cc @@ -84,6 +84,7 @@ namespace EnergyPlus { this->dataGlobal = std::unique_ptr(new DataGlobal); this->dataPipes = std::unique_ptr(new PipesData); this->dataPlantChillers = std::unique_ptr(new PlantChillersData); + this->dataSteamCoils = std::unique_ptr(new SteamCoilsData); this->dataSurfaceGroundHeatExchangers = std::unique_ptr(new SurfaceGroundHeatExchangersData); this->dataSwimmingPools = std::unique_ptr(new SwimmingPoolsData); this->dataSystemAvailabilityManager = std::unique_ptr(new SystemAvailabilityManagerData); @@ -146,6 +147,7 @@ namespace EnergyPlus { this->dataGlobal->clear_state(); this->dataPipes->clear_state(); this->dataPlantChillers->clear_state(); + this->dataSteamCoils->clear_state(); this->dataSurfaceGroundHeatExchangers->clear_state(); this->dataSwimmingPools->clear_state(); this->dataSystemAvailabilityManager->clear_state(); diff --git a/src/EnergyPlus/Data/EnergyPlusData.hh b/src/EnergyPlus/Data/EnergyPlusData.hh index 944319359f5..8b884f06d59 100644 --- a/src/EnergyPlus/Data/EnergyPlusData.hh +++ b/src/EnergyPlus/Data/EnergyPlusData.hh @@ -93,6 +93,7 @@ struct ExteriorEnergyUseData; struct FansData; struct PipesData; struct PlantChillersData; +struct SteamCoilsData; struct SurfaceGroundHeatExchangersData; struct SwimmingPoolsData; struct SystemAvailabilityManagerData; @@ -158,6 +159,7 @@ struct EnergyPlusData : BaseGlobalStruct { std::unique_ptr dataFans; std::unique_ptr dataPipes; std::unique_ptr dataPlantChillers; + std::unique_ptr dataSteamCoils; std::unique_ptr dataSurfaceGroundHeatExchangers; std::unique_ptr dataSwimmingPools; std::unique_ptr dataSystemAvailabilityManager; diff --git a/src/EnergyPlus/FaultsManager.cc b/src/EnergyPlus/FaultsManager.cc index 0f5fa6e8f4d..7fa4bb8817d 100644 --- a/src/EnergyPlus/FaultsManager.cc +++ b/src/EnergyPlus/FaultsManager.cc @@ -883,19 +883,19 @@ namespace FaultsManager { } else if (UtilityRoutines::SameString(SELECT_CASE_VAR, "Coil:Heating:Steam")) { // Read in coil input if not done yet - if (SteamCoils::GetSteamCoilsInputFlag) { + if (state.dataSteamCoils->GetSteamCoilsInputFlag) { SteamCoils::GetSteamCoilInput(state); - SteamCoils::GetSteamCoilsInputFlag = false; + state.dataSteamCoils->GetSteamCoilsInputFlag = false; } // Check the coil name and coil type - int CoilNum = UtilityRoutines::FindItemInList(FaultsCoilSATSensor(jFault_CoilSAT).CoilName, SteamCoils::SteamCoil); + int CoilNum = UtilityRoutines::FindItemInList(FaultsCoilSATSensor(jFault_CoilSAT).CoilName, state.dataSteamCoils->SteamCoil); if (CoilNum <= 0) { ShowSevereError(cFaultCurrentObject + " = \"" + cAlphaArgs(1) + "\" invalid " + cAlphaFieldNames(5) + " = \"" + cAlphaArgs(5) + "\" not found."); ErrorsFound = true; } else { - if (SteamCoils::SteamCoil(CoilNum).TypeOfCoil != SteamCoils::TemperatureSetPointControl) { + if (state.dataSteamCoils->SteamCoil(CoilNum).TypeOfCoil != state.dataSteamCoils->TemperatureSetPointControl) { // The fault model is only applicable to the coils controlled on leaving air temperature ShowWarningError(cFaultCurrentObject + " = \"" + cAlphaArgs(1) + "\" invalid " + cAlphaFieldNames(5) + " = \"" + cAlphaArgs(5) + @@ -903,8 +903,8 @@ namespace FaultsManager { "will not be applied."); } else { // Link the fault model with the coil that is controlled on leaving air temperature - SteamCoils::SteamCoil(CoilNum).FaultyCoilSATFlag = true; - SteamCoils::SteamCoil(CoilNum).FaultyCoilSATIndex = jFault_CoilSAT; + state.dataSteamCoils->SteamCoil(CoilNum).FaultyCoilSATFlag = true; + state.dataSteamCoils->SteamCoil(CoilNum).FaultyCoilSATIndex = jFault_CoilSAT; } } diff --git a/src/EnergyPlus/OutputReportTabular.cc b/src/EnergyPlus/OutputReportTabular.cc index 454b9fbd68e..b73f5f28a43 100644 --- a/src/EnergyPlus/OutputReportTabular.cc +++ b/src/EnergyPlus/OutputReportTabular.cc @@ -545,7 +545,7 @@ namespace OutputReportTabular { } // namespace // Functions - void clear_state() + void clear_state(EnergyPlusData &state) { GatherMonthlyResultsForTimestepRunOnce = true; UpdateTabularReportsGetInput = true; @@ -723,7 +723,7 @@ namespace OutputReportTabular { TOCEntries.deallocate(); UnitConv.deallocate(); - OutputReportTabular::ResetTabularReports(); + OutputReportTabular::ResetTabularReports(state); numPeopleAdaptive = 0; } @@ -15327,7 +15327,7 @@ namespace OutputReportTabular { //====================================================================================================================== //====================================================================================================================== - void ResetTabularReports() + void ResetTabularReports(EnergyPlusData &state) { // Jason Glazer - October 2015 // Reset all gathering arrays to zero for multi-year simulations @@ -15343,6 +15343,8 @@ namespace OutputReportTabular { ResetPeakDemandGathering(); ResetHeatGainGathering(); ResetRemainingPredefinedEntries(); + ThermalComfort::ResetThermalComfortSimpleASH55(state); + ThermalComfort::ResetSetPointMet(state); ResetAdaptiveComfort(); isFinalYear = true; } diff --git a/src/EnergyPlus/OutputReportTabular.hh b/src/EnergyPlus/OutputReportTabular.hh index 6ffc9847c79..6eb2ed57ee7 100644 --- a/src/EnergyPlus/OutputReportTabular.hh +++ b/src/EnergyPlus/OutputReportTabular.hh @@ -703,7 +703,7 @@ namespace OutputReportTabular { extern Array1D UnitConv; // Functions - void clear_state(); + void clear_state(EnergyPlusData &state); std::ofstream & open_tbl_stream(int const iStyle, std::string const & filename, bool output_to_file = true); @@ -961,7 +961,7 @@ namespace OutputReportTabular { //====================================================================================================================== //====================================================================================================================== - void ResetTabularReports(); + void ResetTabularReports(EnergyPlusData &state); void ResetMonthlyGathering(); diff --git a/src/EnergyPlus/PackagedTerminalHeatPump.cc b/src/EnergyPlus/PackagedTerminalHeatPump.cc index d62253c7988..3efd55a64b4 100644 --- a/src/EnergyPlus/PackagedTerminalHeatPump.cc +++ b/src/EnergyPlus/PackagedTerminalHeatPump.cc @@ -589,7 +589,6 @@ namespace PackagedTerminalHeatPump { using SteamCoils::GetSteamCoilIndex; auto &GetCoilMaxSteamFlowRate(SteamCoils::GetCoilMaxSteamFlowRate); using SteamCoils::GetTypeOfCoil; - using SteamCoils::ZoneLoadControl; using WaterCoils::GetCoilMaxWaterFlowRate; using WaterCoils::GetCoilWaterInletNode; auto &GetWaterCoilInletNode(WaterCoils::GetCoilInletNode); @@ -1848,7 +1847,7 @@ namespace PackagedTerminalHeatPump { ShowContinueError("...occurs in " + PTUnit(PTUnitNum).UnitType + " \"" + PTUnit(PTUnitNum).Name + "\""); ErrorsFound = true; } - if (GetTypeOfCoil(state, PTUnit(PTUnitNum).ACHeatCoilIndex, ACHeatCoilName, errFlag) != ZoneLoadControl) { + if (GetTypeOfCoil(state, PTUnit(PTUnitNum).ACHeatCoilIndex, ACHeatCoilName, errFlag) != state.dataSteamCoils->ZoneLoadControl) { if (errFlag) { ShowContinueError("...occurs in " + PTUnit(PTUnitNum).UnitType + " \"" + PTUnit(PTUnitNum).Name + "\""); ErrorsFound = true; diff --git a/src/EnergyPlus/SimulationManager.cc b/src/EnergyPlus/SimulationManager.cc index 45c7b7db208..eaed14d2991 100644 --- a/src/EnergyPlus/SimulationManager.cc +++ b/src/EnergyPlus/SimulationManager.cc @@ -584,7 +584,7 @@ namespace SimulationManager { // for simulations that last longer than a week, identify when the last year of the simulation is started if ((DayOfSim > 365) && ((NumOfDayInEnvrn - DayOfSim) == 364) && !WarmupFlag) { DisplayString("Starting last year of environment at: " + state.dataGlobal->DayOfSimChr); - ResetTabularReports(); + ResetTabularReports(state); } for (HourOfDay = 1; HourOfDay <= 24; ++HourOfDay) { // Begin hour loop ... diff --git a/src/EnergyPlus/StateManagement.cc b/src/EnergyPlus/StateManagement.cc index 4651c500f8f..59b6b31f8d6 100644 --- a/src/EnergyPlus/StateManagement.cc +++ b/src/EnergyPlus/StateManagement.cc @@ -211,7 +211,6 @@ #include #include #include -#include #include void EnergyPlus::clearAllStates(EnergyPlusData &state) @@ -333,7 +332,7 @@ void EnergyPlus::clearAllStates(EnergyPlusData &state) OutdoorAirUnit::clear_state(); OutputProcessor::clear_state(); OutputReportPredefined::clear_state(); - OutputReportTabular::clear_state(); + OutputReportTabular::clear_state(state); OutputReportTabularAnnual::clear_state(); OutsideEnergySources::clear_state(); PackagedTerminalHeatPump::clear_state(); @@ -378,7 +377,6 @@ void EnergyPlus::clearAllStates(EnergyPlusData &state) SolarCollectors::clear_state(); SolarShading::clear_state(); SplitterComponent::clear_state(); - SteamCoils::clear_state(); SurfaceGeometry::clear_state(); UtilityRoutines::clear_state(); EIRPlantLoopHeatPumps::EIRPlantLoopHeatPump::clear_state(); diff --git a/src/EnergyPlus/SteamCoils.cc b/src/EnergyPlus/SteamCoils.cc index 8ad7549a0c8..94a11e528da 100644 --- a/src/EnergyPlus/SteamCoils.cc +++ b/src/EnergyPlus/SteamCoils.cc @@ -96,18 +96,6 @@ namespace SteamCoils { // To encapsulate the data and algorithms required to // manage the SteamCoil System Component. - // METHODOLOGY EMPLOYED: - // na - - // REFERENCES: - // na - - // OTHER NOTES: - // na - - // USE STATEMENTS: - // Use statements for data only modules - // Using/Aliasing using namespace DataLoopNode; using namespace DataGlobals; using namespace DataHVACGlobals; @@ -120,58 +108,9 @@ namespace SteamCoils { using PlantUtilities::ScanPlantLoopsForObject; using namespace ScheduleManager; - // Data - // MODULE PARAMETER DEFINITIONS: - int const SteamCoil_AirHeating(2); - int const TemperatureSetPointControl(1); - int const ZoneLoadControl(3); static std::string const fluidNameSteam("STEAM"); static std::string const BlankString; - // DERIVED TYPE DEFINITIONS - - // INTERFACE DEFINITIONS - // MODULE VARIABLE DECLARATIONS: - int SteamIndex(0); - int NumSteamCoils(0); // The Number of SteamCoils found in the Input - Array1D_bool MySizeFlag; - Array1D_bool CoilWarningOnceFlag; - Array1D_bool CheckEquipName; - bool GetSteamCoilsInputFlag(true); // Flag set to make sure you get input once - bool MyOneTimeFlag(true); // one time initialization flag - - // Subroutine Specifications for the Module - // Driver/Manager Routines - - // Get Input routines for module - - // Initialization routines for module - - // Algorithms for the module - - // Update routine to check convergence and update nodes - - // Reporting routines for module - - // Utility routines for module - - // Object Data - Array1D SteamCoil; - - // MODULE SUBROUTINES: - - // Functions - void clear_state() - { - NumSteamCoils = 0; - MyOneTimeFlag = true; - GetSteamCoilsInputFlag = true; - SteamCoil.deallocate(); - MySizeFlag.deallocate(); - CoilWarningOnceFlag.deallocate(); - CheckEquipName.deallocate(); - } - void SimulateSteamCoilComponents(EnergyPlusData &state, std::string const &CompName, bool const FirstHVACIteration, @@ -202,30 +141,30 @@ namespace SteamCoils { Real64 QCoilReqLocal; // local required heating load optional // Obtains and Allocates SteamCoil related parameters from input file - if (GetSteamCoilsInputFlag) { // First time subroutine has been entered + if (state.dataSteamCoils->GetSteamCoilsInputFlag) { // First time subroutine has been entered GetSteamCoilInput(state); - GetSteamCoilsInputFlag = false; + state.dataSteamCoils->GetSteamCoilsInputFlag = false; } // Find the correct SteamCoilNumber with the Coil Name if (CompIndex == 0) { - CoilNum = UtilityRoutines::FindItemInList(CompName, SteamCoil); + CoilNum = UtilityRoutines::FindItemInList(CompName, state.dataSteamCoils->SteamCoil); if (CoilNum == 0) { ShowFatalError("SimulateSteamCoilComponents: Coil not found=" + CompName); } CompIndex = CoilNum; } else { CoilNum = CompIndex; - if (CoilNum > NumSteamCoils || CoilNum < 1) { + if (CoilNum > state.dataSteamCoils->NumSteamCoils || CoilNum < 1) { ShowFatalError("SimulateSteamCoilComponents: Invalid CompIndex passed=" + TrimSigDigits(CoilNum) + - ", Number of Steam Coils=" + TrimSigDigits(NumSteamCoils) + ", Coil name=" + CompName); + ", Number of Steam Coils=" + TrimSigDigits(state.dataSteamCoils->NumSteamCoils) + ", Coil name=" + CompName); } - if (CheckEquipName(CoilNum)) { - if (CompName != SteamCoil(CoilNum).Name) { + if (state.dataSteamCoils->CheckEquipName(CoilNum)) { + if (CompName != state.dataSteamCoils->SteamCoil(CoilNum).Name) { ShowFatalError("SimulateSteamCoilComponents: Invalid CompIndex passed=" + TrimSigDigits(CoilNum) + ", Coil name=" + CompName + - ", stored Coil Name for that index=" + SteamCoil(CoilNum).Name); + ", stored Coil Name for that index=" + state.dataSteamCoils->SteamCoil(CoilNum).Name); } - CheckEquipName(CoilNum) = false; + state.dataSteamCoils->CheckEquipName(CoilNum) = false; } } @@ -248,16 +187,16 @@ namespace SteamCoils { QCoilReqLocal = 0.0; } - if (SteamCoil(CoilNum).SteamCoilType_Num == SteamCoil_AirHeating) { + if (state.dataSteamCoils->SteamCoil(CoilNum).SteamCoilType_Num == state.dataSteamCoils->SteamCoil_AirHeating) { CalcSteamAirCoil(state, CoilNum, QCoilReqLocal, QCoilActualTemp, OpMode, PartLoadFrac); // Autodesk:OPTIONAL QCoilReq used without PRESENT check if (present(QCoilActual)) QCoilActual = QCoilActualTemp; } // Update the current SteamCoil to the outlet nodes - UpdateSteamCoil(CoilNum); + UpdateSteamCoil(state, CoilNum); // Report the current SteamCoil - ReportSteamCoil(CoilNum); + ReportSteamCoil(state, CoilNum); } // Get Input Section of the Module @@ -305,10 +244,10 @@ namespace SteamCoils { CurrentModuleObject = "Coil:Heating:Steam"; NumStmHeat = inputProcessor->getNumObjectsFound(CurrentModuleObject); - NumSteamCoils = NumStmHeat; - if (NumSteamCoils > 0) { - SteamCoil.allocate(NumSteamCoils); - CheckEquipName.dimension(NumSteamCoils, true); + state.dataSteamCoils->NumSteamCoils = NumStmHeat; + if (state.dataSteamCoils->NumSteamCoils > 0) { + state.dataSteamCoils->SteamCoil.allocate(state.dataSteamCoils->NumSteamCoils); + state.dataSteamCoils->CheckEquipName.dimension(state.dataSteamCoils->NumSteamCoils, true); } inputProcessor->getObjectDefMaxArgs(CurrentModuleObject, TotalArgs, NumAlphas, NumNums); @@ -341,55 +280,55 @@ namespace SteamCoils { // ErrorsFound will be set to True if problem was found, left untouched otherwise VerifyUniqueCoilName(CurrentModuleObject, AlphArray(1), ErrorsFound, CurrentModuleObject + " Name"); - SteamCoil(CoilNum).Name = AlphArray(1); - SteamCoil(CoilNum).Schedule = AlphArray(2); + state.dataSteamCoils->SteamCoil(CoilNum).Name = AlphArray(1); + state.dataSteamCoils->SteamCoil(CoilNum).Schedule = AlphArray(2); if (lAlphaBlanks(2)) { - SteamCoil(CoilNum).SchedPtr = ScheduleAlwaysOn; + state.dataSteamCoils->SteamCoil(CoilNum).SchedPtr = ScheduleAlwaysOn; } else { - SteamCoil(CoilNum).SchedPtr = GetScheduleIndex(state, AlphArray(2)); - if (SteamCoil(CoilNum).SchedPtr == 0) { + state.dataSteamCoils->SteamCoil(CoilNum).SchedPtr = GetScheduleIndex(state, AlphArray(2)); + if (state.dataSteamCoils->SteamCoil(CoilNum).SchedPtr == 0) { ShowSevereError(RoutineName + CurrentModuleObject + "=\"" + AlphArray(1) + "\", invalid data."); ShowContinueError(cAlphaFields(2) + " not found=" + AlphArray(2)); ErrorsFound = true; } } - SteamCoil(CoilNum).SteamCoilTypeA = "Heating"; - SteamCoil(CoilNum).SteamCoilType_Num = SteamCoil_AirHeating; - SteamCoil(CoilNum).Coil_PlantTypeNum = TypeOf_CoilSteamAirHeating; - SteamCoil(CoilNum).MaxSteamVolFlowRate = NumArray(1); - SteamCoil(CoilNum).DegOfSubcooling = NumArray(2); - SteamCoil(CoilNum).LoopSubcoolReturn = NumArray(3); + state.dataSteamCoils->SteamCoil(CoilNum).SteamCoilTypeA = "Heating"; + state.dataSteamCoils->SteamCoil(CoilNum).SteamCoilType_Num = state.dataSteamCoils->SteamCoil_AirHeating; + state.dataSteamCoils->SteamCoil(CoilNum).Coil_PlantTypeNum = TypeOf_CoilSteamAirHeating; + state.dataSteamCoils->SteamCoil(CoilNum).MaxSteamVolFlowRate = NumArray(1); + state.dataSteamCoils->SteamCoil(CoilNum).DegOfSubcooling = NumArray(2); + state.dataSteamCoils->SteamCoil(CoilNum).LoopSubcoolReturn = NumArray(3); - SteamCoil(CoilNum).SteamInletNodeNum = GetOnlySingleNode(state, + state.dataSteamCoils->SteamCoil(CoilNum).SteamInletNodeNum = GetOnlySingleNode(state, AlphArray(3), ErrorsFound, CurrentModuleObject, AlphArray(1), NodeType_Steam, NodeConnectionType_Inlet, 2, ObjectIsNotParent); - SteamCoil(CoilNum).SteamOutletNodeNum = GetOnlySingleNode(state, + state.dataSteamCoils->SteamCoil(CoilNum).SteamOutletNodeNum = GetOnlySingleNode(state, AlphArray(4), ErrorsFound, CurrentModuleObject, AlphArray(1), NodeType_Steam, NodeConnectionType_Outlet, 2, ObjectIsNotParent); - SteamCoil(CoilNum).AirInletNodeNum = GetOnlySingleNode(state, + state.dataSteamCoils->SteamCoil(CoilNum).AirInletNodeNum = GetOnlySingleNode(state, AlphArray(5), ErrorsFound, CurrentModuleObject, AlphArray(1), NodeType_Air, NodeConnectionType_Inlet, 1, ObjectIsNotParent); - SteamCoil(CoilNum).AirOutletNodeNum = GetOnlySingleNode(state, + state.dataSteamCoils->SteamCoil(CoilNum).AirOutletNodeNum = GetOnlySingleNode(state, AlphArray(6), ErrorsFound, CurrentModuleObject, AlphArray(1), NodeType_Air, NodeConnectionType_Outlet, 1, ObjectIsNotParent); { auto const SELECT_CASE_var(UtilityRoutines::MakeUPPERCase(AlphArray(7))); // TEMPERATURE SETPOINT CONTROL or ZONE LOAD CONTROLLED Coils if (SELECT_CASE_var == "TEMPERATURESETPOINTCONTROL") { - SteamCoil(CoilNum).TypeOfCoil = TemperatureSetPointControl; - SteamCoil(CoilNum).TempSetPointNodeNum = GetOnlySingleNode(state, + state.dataSteamCoils->SteamCoil(CoilNum).TypeOfCoil = state.dataSteamCoils->TemperatureSetPointControl; + state.dataSteamCoils->SteamCoil(CoilNum).TempSetPointNodeNum = GetOnlySingleNode(state, AlphArray(8), ErrorsFound, CurrentModuleObject, AlphArray(1), NodeType_Air, NodeConnectionType_Sensor, 1, ObjectIsNotParent); - if (SteamCoil(CoilNum).TempSetPointNodeNum == 0) { + if (state.dataSteamCoils->SteamCoil(CoilNum).TempSetPointNodeNum == 0) { ShowSevereError(RoutineName + cAlphaFields(8) + " not found for " + CurrentModuleObject + " = " + AlphArray(1)); ShowContinueError("..required for Temperature Setpoint Controlled Coils."); ErrorsFound = true; } } else if (SELECT_CASE_var == "ZONELOADCONTROL") { - SteamCoil(CoilNum).TypeOfCoil = ZoneLoadControl; + state.dataSteamCoils->SteamCoil(CoilNum).TypeOfCoil = state.dataSteamCoils->ZoneLoadControl; if (!lAlphaBlanks(8)) { ShowWarningError(RoutineName + "ZoneLoad Controlled Coil, so " + cAlphaFields(8) + " not needed"); ShowContinueError("for " + CurrentModuleObject + " = " + AlphArray(1)); - SteamCoil(CoilNum).TempSetPointNodeNum = 0; + state.dataSteamCoils->SteamCoil(CoilNum).TempSetPointNodeNum = 0; } } else { @@ -402,16 +341,16 @@ namespace SteamCoils { TestCompSet(CurrentModuleObject, AlphArray(1), AlphArray(3), AlphArray(4), "Steam Nodes"); TestCompSet(CurrentModuleObject, AlphArray(1), AlphArray(5), AlphArray(6), "Air Nodes"); - if (SteamIndex == 0 && CoilNum == 1) { - SteamIndex = FindRefrigerant(state, "Steam"); - if (SteamIndex == 0) { + if (state.dataSteamCoils->SteamIndex == 0 && CoilNum == 1) { + state.dataSteamCoils->SteamIndex = FindRefrigerant(state, "Steam"); + if (state.dataSteamCoils->SteamIndex == 0) { ShowSevereError(RoutineName + "Steam Properties for " + AlphArray(1) + " not found."); ShowContinueError("Steam Fluid Properties should have been included in the input file."); ErrorsFound = true; } } - SteamCoil(CoilNum).FluidIndex = SteamIndex; + state.dataSteamCoils->SteamCoil(CoilNum).FluidIndex = state.dataSteamCoils->SteamIndex; } for (CoilNum = 1; CoilNum <= NumStmHeat; ++CoilNum) { @@ -420,10 +359,10 @@ namespace SteamCoils { // CurrentModuleObject = "Coil:Heating:Steam" SetupOutputVariable(state, "Heating Coil Heating Energy", OutputProcessor::Unit::J, - SteamCoil(CoilNum).TotSteamHeatingCoilEnergy, + state.dataSteamCoils->SteamCoil(CoilNum).TotSteamHeatingCoilEnergy, "System", "Sum", - SteamCoil(CoilNum).Name, + state.dataSteamCoils->SteamCoil(CoilNum).Name, _, "ENERGYTRANSFER", "HEATINGCOILS", @@ -431,34 +370,34 @@ namespace SteamCoils { "System"); SetupOutputVariable(state, "Heating Coil Heating Rate", OutputProcessor::Unit::W, - SteamCoil(CoilNum).TotSteamHeatingCoilRate, + state.dataSteamCoils->SteamCoil(CoilNum).TotSteamHeatingCoilRate, "System", "Average", - SteamCoil(CoilNum).Name); + state.dataSteamCoils->SteamCoil(CoilNum).Name); SetupOutputVariable(state, "Heating Coil Steam Mass Flow Rate", OutputProcessor::Unit::kg_s, - SteamCoil(CoilNum).OutletSteamMassFlowRate, + state.dataSteamCoils->SteamCoil(CoilNum).OutletSteamMassFlowRate, "System", "Average", - SteamCoil(CoilNum).Name); + state.dataSteamCoils->SteamCoil(CoilNum).Name); SetupOutputVariable(state, "Heating Coil Steam Inlet Temperature", OutputProcessor::Unit::C, - SteamCoil(CoilNum).InletSteamTemp, + state.dataSteamCoils->SteamCoil(CoilNum).InletSteamTemp, "System", "Average", - SteamCoil(CoilNum).Name); + state.dataSteamCoils->SteamCoil(CoilNum).Name); SetupOutputVariable(state, "Heating Coil Steam Outlet Temperature", OutputProcessor::Unit::C, - SteamCoil(CoilNum).OutletSteamTemp, + state.dataSteamCoils->SteamCoil(CoilNum).OutletSteamTemp, "System", "Average", - SteamCoil(CoilNum).Name); + state.dataSteamCoils->SteamCoil(CoilNum).Name); SetupOutputVariable(state, "Heating Coil Steam Trap Loss Rate", OutputProcessor::Unit::W, - SteamCoil(CoilNum).LoopLoss, + state.dataSteamCoils->SteamCoil(CoilNum).LoopLoss, "System", "Average", - SteamCoil(CoilNum).Name); + state.dataSteamCoils->SteamCoil(CoilNum).Name); } if (ErrorsFound) { @@ -522,28 +461,28 @@ namespace SteamCoils { static Array1D_bool MyPlantScanFlag; bool errFlag; - if (MyOneTimeFlag) { + if (state.dataSteamCoils->MyOneTimeFlag) { // initialize the environment and sizing flags - MyEnvrnFlag.allocate(NumSteamCoils); - MySizeFlag.allocate(NumSteamCoils); - CoilWarningOnceFlag.allocate(NumSteamCoils); - MyPlantScanFlag.allocate(NumSteamCoils); + MyEnvrnFlag.allocate(state.dataSteamCoils->NumSteamCoils); + state.dataSteamCoils->MySizeFlag.allocate(state.dataSteamCoils->NumSteamCoils); + state.dataSteamCoils->CoilWarningOnceFlag.allocate(state.dataSteamCoils->NumSteamCoils); + MyPlantScanFlag.allocate(state.dataSteamCoils->NumSteamCoils); MyEnvrnFlag = true; - MySizeFlag = true; - CoilWarningOnceFlag = true; + state.dataSteamCoils->MySizeFlag = true; + state.dataSteamCoils->CoilWarningOnceFlag = true; MyPlantScanFlag = true; - MyOneTimeFlag = false; + state.dataSteamCoils->MyOneTimeFlag = false; } if (MyPlantScanFlag(CoilNum) && allocated(PlantLoop)) { errFlag = false; ScanPlantLoopsForObject(state, - SteamCoil(CoilNum).Name, - SteamCoil(CoilNum).Coil_PlantTypeNum, - SteamCoil(CoilNum).LoopNum, - SteamCoil(CoilNum).LoopSide, - SteamCoil(CoilNum).BranchNum, - SteamCoil(CoilNum).CompNum, + state.dataSteamCoils->SteamCoil(CoilNum).Name, + state.dataSteamCoils->SteamCoil(CoilNum).Coil_PlantTypeNum, + state.dataSteamCoils->SteamCoil(CoilNum).LoopNum, + state.dataSteamCoils->SteamCoil(CoilNum).LoopSide, + state.dataSteamCoils->SteamCoil(CoilNum).BranchNum, + state.dataSteamCoils->SteamCoil(CoilNum).CompNum, errFlag, _, _, @@ -556,51 +495,51 @@ namespace SteamCoils { MyPlantScanFlag(CoilNum) = false; } - if (!SysSizingCalc && MySizeFlag(CoilNum)) { + if (!SysSizingCalc && state.dataSteamCoils->MySizeFlag(CoilNum)) { // for each coil, do the sizing once. SizeSteamCoil(state, CoilNum); - MySizeFlag(CoilNum) = false; + state.dataSteamCoils->MySizeFlag(CoilNum) = false; } // Do the Begin Environment initializations if (BeginEnvrnFlag && MyEnvrnFlag(CoilNum)) { // Initialize all report variables to a known state at beginning of simulation - SteamCoil(CoilNum).TotSteamHeatingCoilEnergy = 0.0; - SteamCoil(CoilNum).TotSteamCoolingCoilEnergy = 0.0; - SteamCoil(CoilNum).SenSteamCoolingCoilEnergy = 0.0; - SteamCoil(CoilNum).TotSteamHeatingCoilRate = 0.0; - SteamCoil(CoilNum).TotSteamCoolingCoilRate = 0.0; - SteamCoil(CoilNum).SenSteamCoolingCoilRate = 0.0; + state.dataSteamCoils->SteamCoil(CoilNum).TotSteamHeatingCoilEnergy = 0.0; + state.dataSteamCoils->SteamCoil(CoilNum).TotSteamCoolingCoilEnergy = 0.0; + state.dataSteamCoils->SteamCoil(CoilNum).SenSteamCoolingCoilEnergy = 0.0; + state.dataSteamCoils->SteamCoil(CoilNum).TotSteamHeatingCoilRate = 0.0; + state.dataSteamCoils->SteamCoil(CoilNum).TotSteamCoolingCoilRate = 0.0; + state.dataSteamCoils->SteamCoil(CoilNum).SenSteamCoolingCoilRate = 0.0; // Initialize other module level variables - SteamCoil(CoilNum).InletAirMassFlowRate = 0.0; - SteamCoil(CoilNum).OutletAirMassFlowRate = 0.0; - SteamCoil(CoilNum).InletAirTemp = 0.0; - SteamCoil(CoilNum).OutletAirTemp = 0.0; - SteamCoil(CoilNum).InletAirHumRat = 0.0; - SteamCoil(CoilNum).OutletAirHumRat = 0.0; - SteamCoil(CoilNum).InletAirEnthalpy = 0.0; - SteamCoil(CoilNum).OutletAirEnthalpy = 0.0; - SteamCoil(CoilNum).TotSteamCoilLoad = 0.0; - SteamCoil(CoilNum).SenSteamCoilLoad = 0.0; - SteamCoil(CoilNum).LoopLoss = 0.0; - SteamCoil(CoilNum).LeavingRelHum = 0.0; - SteamCoil(CoilNum).DesiredOutletTemp = 0.0; - SteamCoil(CoilNum).DesiredOutletHumRat = 0.0; - SteamCoil(CoilNum).InletSteamTemp = 0.0; - SteamCoil(CoilNum).OutletSteamTemp = 0.0; - SteamCoil(CoilNum).InletSteamMassFlowRate = 0.0; - SteamCoil(CoilNum).OutletSteamMassFlowRate = 0.0; - SteamCoil(CoilNum).InletSteamEnthalpy = 0.0; - SteamCoil(CoilNum).OutletWaterEnthalpy = 0.0; - SteamCoil(CoilNum).InletSteamPress = 0.0; - SteamCoil(CoilNum).InletSteamQuality = 0.0; - SteamCoil(CoilNum).OutletSteamQuality = 0.0; + state.dataSteamCoils->SteamCoil(CoilNum).InletAirMassFlowRate = 0.0; + state.dataSteamCoils->SteamCoil(CoilNum).OutletAirMassFlowRate = 0.0; + state.dataSteamCoils->SteamCoil(CoilNum).InletAirTemp = 0.0; + state.dataSteamCoils->SteamCoil(CoilNum).OutletAirTemp = 0.0; + state.dataSteamCoils->SteamCoil(CoilNum).InletAirHumRat = 0.0; + state.dataSteamCoils->SteamCoil(CoilNum).OutletAirHumRat = 0.0; + state.dataSteamCoils->SteamCoil(CoilNum).InletAirEnthalpy = 0.0; + state.dataSteamCoils->SteamCoil(CoilNum).OutletAirEnthalpy = 0.0; + state.dataSteamCoils->SteamCoil(CoilNum).TotSteamCoilLoad = 0.0; + state.dataSteamCoils->SteamCoil(CoilNum).SenSteamCoilLoad = 0.0; + state.dataSteamCoils->SteamCoil(CoilNum).LoopLoss = 0.0; + state.dataSteamCoils->SteamCoil(CoilNum).LeavingRelHum = 0.0; + state.dataSteamCoils->SteamCoil(CoilNum).DesiredOutletTemp = 0.0; + state.dataSteamCoils->SteamCoil(CoilNum).DesiredOutletHumRat = 0.0; + state.dataSteamCoils->SteamCoil(CoilNum).InletSteamTemp = 0.0; + state.dataSteamCoils->SteamCoil(CoilNum).OutletSteamTemp = 0.0; + state.dataSteamCoils->SteamCoil(CoilNum).InletSteamMassFlowRate = 0.0; + state.dataSteamCoils->SteamCoil(CoilNum).OutletSteamMassFlowRate = 0.0; + state.dataSteamCoils->SteamCoil(CoilNum).InletSteamEnthalpy = 0.0; + state.dataSteamCoils->SteamCoil(CoilNum).OutletWaterEnthalpy = 0.0; + state.dataSteamCoils->SteamCoil(CoilNum).InletSteamPress = 0.0; + state.dataSteamCoils->SteamCoil(CoilNum).InletSteamQuality = 0.0; + state.dataSteamCoils->SteamCoil(CoilNum).OutletSteamQuality = 0.0; // More Environment initializations - AirInletNode = SteamCoil(CoilNum).AirInletNodeNum; - SteamInletNode = SteamCoil(CoilNum).SteamInletNodeNum; - ControlNode = SteamCoil(CoilNum).TempSetPointNodeNum; - AirOutletNode = SteamCoil(CoilNum).AirOutletNodeNum; + AirInletNode = state.dataSteamCoils->SteamCoil(CoilNum).AirInletNodeNum; + SteamInletNode = state.dataSteamCoils->SteamCoil(CoilNum).SteamInletNodeNum; + ControlNode = state.dataSteamCoils->SteamCoil(CoilNum).TempSetPointNodeNum; + AirOutletNode = state.dataSteamCoils->SteamCoil(CoilNum).AirOutletNodeNum; Node(SteamInletNode).Temp = 100.0; Node(SteamInletNode).Press = 101325.0; @@ -609,18 +548,18 @@ namespace SteamCoils { Node(SteamInletNode).Enthalpy = StartEnthSteam; Node(SteamInletNode).Quality = 1.0; Node(SteamInletNode).HumRat = 0.0; - SteamCoil(CoilNum).MaxSteamMassFlowRate = SteamDensity * SteamCoil(CoilNum).MaxSteamVolFlowRate; + state.dataSteamCoils->SteamCoil(CoilNum).MaxSteamMassFlowRate = SteamDensity * state.dataSteamCoils->SteamCoil(CoilNum).MaxSteamVolFlowRate; // Node(SteamInletNode)%MassFlowRate = SteamCoil(CoilNum)%MaxSteamMassFlowRate // Node(SteamInletNode)%MassFlowRateMinAvail = 0.0 // Node(SteamInletNode)%MassFlowRateMaxAvail = SteamCoil(CoilNum)%MaxSteamMassFlowRate InitComponentNodes(0.0, - SteamCoil(CoilNum).MaxSteamMassFlowRate, - SteamCoil(CoilNum).SteamInletNodeNum, - SteamCoil(CoilNum).SteamOutletNodeNum, - SteamCoil(CoilNum).LoopNum, - SteamCoil(CoilNum).LoopSide, - SteamCoil(CoilNum).BranchNum, - SteamCoil(CoilNum).CompNum); + state.dataSteamCoils->SteamCoil(CoilNum).MaxSteamMassFlowRate, + state.dataSteamCoils->SteamCoil(CoilNum).SteamInletNodeNum, + state.dataSteamCoils->SteamCoil(CoilNum).SteamOutletNodeNum, + state.dataSteamCoils->SteamCoil(CoilNum).LoopNum, + state.dataSteamCoils->SteamCoil(CoilNum).LoopSide, + state.dataSteamCoils->SteamCoil(CoilNum).BranchNum, + state.dataSteamCoils->SteamCoil(CoilNum).CompNum); MyEnvrnFlag(CoilNum) = false; } // End If for the Begin Environment initializations @@ -637,38 +576,38 @@ namespace SteamCoils { // Do the following initializations (every time step): This should be the info from // the previous components outlets or the node data in this section. - AirInletNode = SteamCoil(CoilNum).AirInletNodeNum; - SteamInletNode = SteamCoil(CoilNum).SteamInletNodeNum; - ControlNode = SteamCoil(CoilNum).TempSetPointNodeNum; - AirOutletNode = SteamCoil(CoilNum).AirOutletNodeNum; + AirInletNode = state.dataSteamCoils->SteamCoil(CoilNum).AirInletNodeNum; + SteamInletNode = state.dataSteamCoils->SteamCoil(CoilNum).SteamInletNodeNum; + ControlNode = state.dataSteamCoils->SteamCoil(CoilNum).TempSetPointNodeNum; + AirOutletNode = state.dataSteamCoils->SteamCoil(CoilNum).AirOutletNodeNum; // First set the conditions for the air into the coil model // If a temperature setpoint controlled coil must set the desired outlet temp everytime if (ControlNode == 0) { - SteamCoil(CoilNum).DesiredOutletTemp = 0.0; + state.dataSteamCoils->SteamCoil(CoilNum).DesiredOutletTemp = 0.0; } else if (ControlNode == AirOutletNode) { - SteamCoil(CoilNum).DesiredOutletTemp = Node(ControlNode).TempSetPoint; + state.dataSteamCoils->SteamCoil(CoilNum).DesiredOutletTemp = Node(ControlNode).TempSetPoint; } else { - SteamCoil(CoilNum).DesiredOutletTemp = Node(ControlNode).TempSetPoint - (Node(ControlNode).Temp - Node(AirOutletNode).Temp); + state.dataSteamCoils->SteamCoil(CoilNum).DesiredOutletTemp = Node(ControlNode).TempSetPoint - (Node(ControlNode).Temp - Node(AirOutletNode).Temp); } - SteamCoil(CoilNum).InletAirMassFlowRate = Node(AirInletNode).MassFlowRate; - SteamCoil(CoilNum).InletAirTemp = Node(AirInletNode).Temp; - SteamCoil(CoilNum).InletAirHumRat = Node(AirInletNode).HumRat; - SteamCoil(CoilNum).InletAirEnthalpy = Node(AirInletNode).Enthalpy; + state.dataSteamCoils->SteamCoil(CoilNum).InletAirMassFlowRate = Node(AirInletNode).MassFlowRate; + state.dataSteamCoils->SteamCoil(CoilNum).InletAirTemp = Node(AirInletNode).Temp; + state.dataSteamCoils->SteamCoil(CoilNum).InletAirHumRat = Node(AirInletNode).HumRat; + state.dataSteamCoils->SteamCoil(CoilNum).InletAirEnthalpy = Node(AirInletNode).Enthalpy; if (FirstHVACIteration) { - SteamCoil(CoilNum).InletSteamMassFlowRate = SteamCoil(CoilNum).MaxSteamMassFlowRate; + state.dataSteamCoils->SteamCoil(CoilNum).InletSteamMassFlowRate = state.dataSteamCoils->SteamCoil(CoilNum).MaxSteamMassFlowRate; } else { - SteamCoil(CoilNum).InletSteamMassFlowRate = Node(SteamInletNode).MassFlowRate; - } - SteamCoil(CoilNum).InletSteamTemp = Node(SteamInletNode).Temp; - SteamCoil(CoilNum).InletSteamEnthalpy = Node(SteamInletNode).Enthalpy; - SteamCoil(CoilNum).InletSteamPress = Node(SteamInletNode).Press; - SteamCoil(CoilNum).InletSteamQuality = Node(SteamInletNode).Quality; - SteamCoil(CoilNum).TotSteamHeatingCoilRate = 0.0; - SteamCoil(CoilNum).TotSteamCoolingCoilRate = 0.0; - SteamCoil(CoilNum).SenSteamCoolingCoilRate = 0.0; + state.dataSteamCoils->SteamCoil(CoilNum).InletSteamMassFlowRate = Node(SteamInletNode).MassFlowRate; + } + state.dataSteamCoils->SteamCoil(CoilNum).InletSteamTemp = Node(SteamInletNode).Temp; + state.dataSteamCoils->SteamCoil(CoilNum).InletSteamEnthalpy = Node(SteamInletNode).Enthalpy; + state.dataSteamCoils->SteamCoil(CoilNum).InletSteamPress = Node(SteamInletNode).Press; + state.dataSteamCoils->SteamCoil(CoilNum).InletSteamQuality = Node(SteamInletNode).Quality; + state.dataSteamCoils->SteamCoil(CoilNum).TotSteamHeatingCoilRate = 0.0; + state.dataSteamCoils->SteamCoil(CoilNum).TotSteamCoolingCoilRate = 0.0; + state.dataSteamCoils->SteamCoil(CoilNum).SenSteamCoolingCoilRate = 0.0; // Node(SteamInletNode)%MassFlowRateMaxAvail = MIN(Node(SteamInletNode)%MassFlowRateMaxAvail,& // SteamCoil(CoilNum)%MaxSteamMassFlowRate) } @@ -755,12 +694,12 @@ namespace SteamCoils { // If this is a steam coil // Find the appropriate steam Plant Sizing object - if (SteamCoil(CoilNum).MaxSteamVolFlowRate == AutoSize) { + if (state.dataSteamCoils->SteamCoil(CoilNum).MaxSteamVolFlowRate == AutoSize) { coilWasAutosized = true; // coil report PltSizSteamNum = MyPlantSizingIndex("steam heating coil", - SteamCoil(CoilNum).Name, - SteamCoil(CoilNum).SteamInletNodeNum, - SteamCoil(CoilNum).SteamOutletNodeNum, + state.dataSteamCoils->SteamCoil(CoilNum).Name, + state.dataSteamCoils->SteamCoil(CoilNum).SteamInletNodeNum, + state.dataSteamCoils->SteamCoil(CoilNum).SteamOutletNodeNum, ErrorsFound); } @@ -768,15 +707,15 @@ namespace SteamCoils { // If this is a central air system heating coil if (CurSysNum > 0) { // If the coil water volume flow rate needs autosizing, then do it - if (SteamCoil(CoilNum).MaxSteamVolFlowRate == AutoSize) { - CheckSysSizing("Coil:Heating:Steam", SteamCoil(CoilNum).Name); + if (state.dataSteamCoils->SteamCoil(CoilNum).MaxSteamVolFlowRate == AutoSize) { + CheckSysSizing("Coil:Heating:Steam", state.dataSteamCoils->SteamCoil(CoilNum).Name); - if (SteamCoil(CoilNum).DesiccantRegenerationCoil) { + if (state.dataSteamCoils->SteamCoil(CoilNum).DesiccantRegenerationCoil) { DataDesicRegCoil = true; - DataDesicDehumNum = SteamCoil(CoilNum).DesiccantDehumNum; - CompType = SteamCoil(CoilNum).SteamCoilType; - CompName = SteamCoil(CoilNum).Name; + DataDesicDehumNum = state.dataSteamCoils->SteamCoil(CoilNum).DesiccantDehumNum; + CompType = state.dataSteamCoils->SteamCoil(CoilNum).SteamCoilType; + CompName = state.dataSteamCoils->SteamCoil(CoilNum).Name; bPRINT = false; HeatingCoilDesAirInletTempSizer sizerHeatingDesInletTemp; bool ErrorsFound = false; @@ -847,29 +786,29 @@ namespace SteamCoils { // TempSteamIn=PlantSizData(PltSizSteamNum)%ExitTemp TempSteamIn = 100.0; // DSU? Should be from the PlantSizing object (ExitTemp) instead of hardwired to 100? // RefrigIndex is set during GetInput for this module - EnthSteamInDry = GetSatEnthalpyRefrig(state, fluidNameSteam, TempSteamIn, 1.0, SteamCoil(CoilNum).FluidIndex, RoutineName); - EnthSteamOutWet = GetSatEnthalpyRefrig(state, fluidNameSteam, TempSteamIn, 0.0, SteamCoil(CoilNum).FluidIndex, RoutineName); + EnthSteamInDry = GetSatEnthalpyRefrig(state, fluidNameSteam, TempSteamIn, 1.0, state.dataSteamCoils->SteamCoil(CoilNum).FluidIndex, RoutineName); + EnthSteamOutWet = GetSatEnthalpyRefrig(state, fluidNameSteam, TempSteamIn, 0.0, state.dataSteamCoils->SteamCoil(CoilNum).FluidIndex, RoutineName); LatentHeatSteam = EnthSteamInDry - EnthSteamOutWet; - SteamDensity = GetSatDensityRefrig(state, fluidNameSteam, TempSteamIn, 1.0, SteamCoil(CoilNum).FluidIndex, RoutineName); + SteamDensity = GetSatDensityRefrig(state, fluidNameSteam, TempSteamIn, 1.0, state.dataSteamCoils->SteamCoil(CoilNum).FluidIndex, RoutineName); // SteamCoil(CoilNum)%MaxSteamVolFlowRate = DesCoilLoad/(SteamDensity * LatentHeatSteam) // CpWater = GetSpecificHeatGlycol('WATER', & // TempSteamIn, & // PlantLoop(SteamCoil(CoilNum)%LoopNum)%FluidIndex, & // 'SizeSteamCoil') - CpWater = GetSatSpecificHeatRefrig(state, fluidNameSteam, TempSteamIn, 0.0, SteamCoil(CoilNum).FluidIndex, RoutineName); + CpWater = GetSatSpecificHeatRefrig(state, fluidNameSteam, TempSteamIn, 0.0, state.dataSteamCoils->SteamCoil(CoilNum).FluidIndex, RoutineName); - SteamCoil(CoilNum).MaxSteamVolFlowRate = - DesCoilLoad / (SteamDensity * (LatentHeatSteam + SteamCoil(CoilNum).DegOfSubcooling * CpWater)); + state.dataSteamCoils->SteamCoil(CoilNum).MaxSteamVolFlowRate = + DesCoilLoad / (SteamDensity * (LatentHeatSteam + state.dataSteamCoils->SteamCoil(CoilNum).DegOfSubcooling * CpWater)); // PlantSizData(PltSizSteamNum)%DeltaT*CPHW(PlantSizData(PltSizSteamNum)%ExitTemp))) } else { - SteamCoil(CoilNum).MaxSteamVolFlowRate = 0.0; - ShowWarningError("The design coil load is zero for COIL:Heating:Steam " + SteamCoil(CoilNum).Name); + state.dataSteamCoils->SteamCoil(CoilNum).MaxSteamVolFlowRate = 0.0; + ShowWarningError("The design coil load is zero for COIL:Heating:Steam " + state.dataSteamCoils->SteamCoil(CoilNum).Name); // CALL ShowContinueError('The autosize value for max Steam flow rate is zero') // CALL ShowContinueError('To change this, input a value for UA, change the heating design day, or lower') // CALL ShowContinueError(' the system heating design supply air temperature') } BaseSizer::reportSizerOutput( - "Coil:Heating:Steam", SteamCoil(CoilNum).Name, "Maximum Steam Flow Rate [m3/s]", SteamCoil(CoilNum).MaxSteamVolFlowRate); + "Coil:Heating:Steam", state.dataSteamCoils->SteamCoil(CoilNum).Name, "Maximum Steam Flow Rate [m3/s]", state.dataSteamCoils->SteamCoil(CoilNum).MaxSteamVolFlowRate); } DataDesicRegCoil = false; // reset all globals to 0 to ensure correct sizing for other child components // Coil report, set fan info for airloopnum @@ -878,7 +817,7 @@ namespace SteamCoils { int SupFanNum = DataAirSystems::PrimaryAirSystem(CurSysNum).SupFanNum; if (SupFanNum > 0) { coilSelectionReportObj->setCoilSupplyFanInfo(state, - SteamCoil(CoilNum).Name, + state.dataSteamCoils->SteamCoil(CoilNum).Name, "Coil:Heating:Steam", Fans::Fan(DataAirSystems::PrimaryAirSystem(CurSysNum).SupFanNum).FanName, DataAirSystems::structArrayLegacyFanModels, @@ -891,7 +830,7 @@ namespace SteamCoils { if (DataAirSystems::PrimaryAirSystem(CurSysNum).supFanVecIndex >= 0) { coilSelectionReportObj->setCoilSupplyFanInfo( state, - SteamCoil(CoilNum).Name, + state.dataSteamCoils->SteamCoil(CoilNum).Name, "Coil:Heating:Steam", HVACFan::fanObjs[DataAirSystems::PrimaryAirSystem(CurSysNum).supFanVecIndex]->name, DataAirSystems::objectVectorOOFanSystemModel, @@ -907,15 +846,15 @@ namespace SteamCoils { // if this is a zone coil } else if (CurZoneEqNum > 0) { - CheckZoneSizing("Coil:Heating:Steam", SteamCoil(CoilNum).Name); + CheckZoneSizing("Coil:Heating:Steam", state.dataSteamCoils->SteamCoil(CoilNum).Name); // autosize the coil steam volume flow rate if needed - if (SteamCoil(CoilNum).MaxSteamVolFlowRate == AutoSize) { + if (state.dataSteamCoils->SteamCoil(CoilNum).MaxSteamVolFlowRate == AutoSize) { // if coil is part of a terminal unit just use the terminal unit value if (TermUnitSingDuct || TermUnitPIU || TermUnitIU) { if (CurTermUnitSizingNum > 0) { - SteamCoil(CoilNum).MaxSteamVolFlowRate = TermUnitSizing(CurTermUnitSizingNum).MaxSTVolFlow; + state.dataSteamCoils->SteamCoil(CoilNum).MaxSteamVolFlowRate = TermUnitSizing(CurTermUnitSizingNum).MaxSTVolFlow; } else { - SteamCoil(CoilNum).MaxSteamVolFlowRate = 0.0; + state.dataSteamCoils->SteamCoil(CoilNum).MaxSteamVolFlowRate = 0.0; } // if coil is part of a zonal unit, calc coil load to get hot Steam flow rate DesCoilLoad = TermUnitSizing(CurTermUnitSizingNum).DesHeatingLoad; // coil report @@ -931,50 +870,50 @@ namespace SteamCoils { if (DesCoilLoad >= SmallLoad) { TempSteamIn = 100.0; // RefrigIndex is set during GetInput for this module - EnthSteamInDry = GetSatEnthalpyRefrig(state, fluidNameSteam, TempSteamIn, 1.0, SteamCoil(CoilNum).FluidIndex, RoutineName); - EnthSteamOutWet = GetSatEnthalpyRefrig(state, fluidNameSteam, TempSteamIn, 0.0, SteamCoil(CoilNum).FluidIndex, RoutineName); + EnthSteamInDry = GetSatEnthalpyRefrig(state, fluidNameSteam, TempSteamIn, 1.0, state.dataSteamCoils->SteamCoil(CoilNum).FluidIndex, RoutineName); + EnthSteamOutWet = GetSatEnthalpyRefrig(state, fluidNameSteam, TempSteamIn, 0.0, state.dataSteamCoils->SteamCoil(CoilNum).FluidIndex, RoutineName); LatentHeatSteam = EnthSteamInDry - EnthSteamOutWet; - SteamDensity = GetSatDensityRefrig(state, fluidNameSteam, TempSteamIn, 1.0, SteamCoil(CoilNum).FluidIndex, RoutineName); + SteamDensity = GetSatDensityRefrig(state, fluidNameSteam, TempSteamIn, 1.0, state.dataSteamCoils->SteamCoil(CoilNum).FluidIndex, RoutineName); // SteamCoil(CoilNum)%MaxSteamVolFlowRate = DesCoilLoad/(SteamDensity * LatentHeatSteam) // CpWater = GetSpecificHeatGlycol('WATER', & // TempSteamIn, & // PlantLoop(SteamCoil(CoilNum)%LoopNum)%FluidIndex, & // 'SizeSteamCoil') - CpWater = GetSatSpecificHeatRefrig(state, fluidNameSteam, TempSteamIn, 0.0, SteamCoil(CoilNum).FluidIndex, RoutineName); + CpWater = GetSatSpecificHeatRefrig(state, fluidNameSteam, TempSteamIn, 0.0, state.dataSteamCoils->SteamCoil(CoilNum).FluidIndex, RoutineName); - SteamCoil(CoilNum).MaxSteamVolFlowRate = - DesCoilLoad / (SteamDensity * (LatentHeatSteam + SteamCoil(CoilNum).DegOfSubcooling * CpWater)); + state.dataSteamCoils->SteamCoil(CoilNum).MaxSteamVolFlowRate = + DesCoilLoad / (SteamDensity * (LatentHeatSteam + state.dataSteamCoils->SteamCoil(CoilNum).DegOfSubcooling * CpWater)); // PlantSizData(PltSizSteamNum)%DeltaT*CPHW(PlantSizData(PltSizSteamNum)%ExitTemp))) } else { - SteamCoil(CoilNum).MaxSteamVolFlowRate = 0.0; + state.dataSteamCoils->SteamCoil(CoilNum).MaxSteamVolFlowRate = 0.0; } } // issue warning if hw coil has zero flow - if (SteamCoil(CoilNum).MaxSteamVolFlowRate == 0.0) { - ShowWarningError("The design coil load is zero for COIL:Heating:Steam " + SteamCoil(CoilNum).Name); + if (state.dataSteamCoils->SteamCoil(CoilNum).MaxSteamVolFlowRate == 0.0) { + ShowWarningError("The design coil load is zero for COIL:Heating:Steam " + state.dataSteamCoils->SteamCoil(CoilNum).Name); ShowContinueError("The autosize value for max Steam flow rate is zero"); // CALL ShowContinueError('To change this, input a value for UA, change the heating design day, or lower') // CALL ShowContinueError(' the system heating design supply air temperature') } BaseSizer::reportSizerOutput( - "Coil:Heating:Steam", SteamCoil(CoilNum).Name, "Maximum Steam Flow Rate [m3/s]", SteamCoil(CoilNum).MaxSteamVolFlowRate); + "Coil:Heating:Steam", state.dataSteamCoils->SteamCoil(CoilNum).Name, "Maximum Steam Flow Rate [m3/s]", state.dataSteamCoils->SteamCoil(CoilNum).MaxSteamVolFlowRate); } } // end zone coil ELSE - IF } else { // if there is no heating Plant Sizing object and autosizng was requested, issue an error message - if (SteamCoil(CoilNum).MaxSteamVolFlowRate == AutoSize) { + if (state.dataSteamCoils->SteamCoil(CoilNum).MaxSteamVolFlowRate == AutoSize) { ShowSevereError("Autosizing of Steam coil requires a heating loop Sizing:Plant object"); - ShowContinueError("Occurs in Steam coil object= " + SteamCoil(CoilNum).Name); + ShowContinueError("Occurs in Steam coil object= " + state.dataSteamCoils->SteamCoil(CoilNum).Name); ErrorsFound = true; } } // end of heating Plant Sizing existence IF - ELSE // save the design Steam volumetric flow rate for use by the Steam loop sizing algorithms - RegisterPlantCompDesignFlow(SteamCoil(CoilNum).SteamInletNodeNum, SteamCoil(CoilNum).MaxSteamVolFlowRate); + RegisterPlantCompDesignFlow(state.dataSteamCoils->SteamCoil(CoilNum).SteamInletNodeNum, state.dataSteamCoils->SteamCoil(CoilNum).MaxSteamVolFlowRate); coilSelectionReportObj->setCoilHeatingCapacity(state, - SteamCoil(CoilNum).Name, + state.dataSteamCoils->SteamCoil(CoilNum).Name, "Coil:Heating:Steam", DesCoilLoad, coilWasAutosized, @@ -985,33 +924,33 @@ namespace SteamCoils { 1.0, -999.0, -999.0); - coilSelectionReportObj->setCoilWaterFlowNodeNums(state, SteamCoil(CoilNum).Name, + coilSelectionReportObj->setCoilWaterFlowNodeNums(state, state.dataSteamCoils->SteamCoil(CoilNum).Name, "Coil:Heating:Steam", - SteamCoil(CoilNum).MaxSteamVolFlowRate, + state.dataSteamCoils->SteamCoil(CoilNum).MaxSteamVolFlowRate, coilWasAutosized, - SteamCoil(CoilNum).SteamInletNodeNum, - SteamCoil(CoilNum).SteamOutletNodeNum, - SteamCoil(CoilNum).LoopNum); - coilSelectionReportObj->setCoilWaterHeaterCapacityNodeNums(SteamCoil(CoilNum).Name, + state.dataSteamCoils->SteamCoil(CoilNum).SteamInletNodeNum, + state.dataSteamCoils->SteamCoil(CoilNum).SteamOutletNodeNum, + state.dataSteamCoils->SteamCoil(CoilNum).LoopNum); + coilSelectionReportObj->setCoilWaterHeaterCapacityNodeNums(state.dataSteamCoils->SteamCoil(CoilNum).Name, "Coil:Heating:Steam", DesCoilLoad, coilWasAutosized, - SteamCoil(CoilNum).SteamInletNodeNum, - SteamCoil(CoilNum).SteamOutletNodeNum, - SteamCoil(CoilNum).LoopNum); - coilSelectionReportObj->setCoilEntWaterTemp(SteamCoil(CoilNum).Name, "Coil:Heating:Steam", TempSteamIn); // coil report - coilSelectionReportObj->setCoilLvgWaterTemp(SteamCoil(CoilNum).Name, + state.dataSteamCoils->SteamCoil(CoilNum).SteamInletNodeNum, + state.dataSteamCoils->SteamCoil(CoilNum).SteamOutletNodeNum, + state.dataSteamCoils->SteamCoil(CoilNum).LoopNum); + coilSelectionReportObj->setCoilEntWaterTemp(state.dataSteamCoils->SteamCoil(CoilNum).Name, "Coil:Heating:Steam", TempSteamIn); // coil report + coilSelectionReportObj->setCoilLvgWaterTemp(state.dataSteamCoils->SteamCoil(CoilNum).Name, "Coil:Heating:Steam", - TempSteamIn - SteamCoil(CoilNum).DegOfSubcooling); // coil report - coilSelectionReportObj->setCoilWaterDeltaT(SteamCoil(CoilNum).Name, "Coil:Heating:Steam", SteamCoil(CoilNum).DegOfSubcooling); // coil report - SteamCoil(CoilNum).DesCoilCapacity = DesCoilLoad; - SteamCoil(CoilNum).DesAirVolFlow = DesVolFlow; + TempSteamIn - state.dataSteamCoils->SteamCoil(CoilNum).DegOfSubcooling); // coil report + coilSelectionReportObj->setCoilWaterDeltaT(state.dataSteamCoils->SteamCoil(CoilNum).Name, "Coil:Heating:Steam", state.dataSteamCoils->SteamCoil(CoilNum).DegOfSubcooling); // coil report + state.dataSteamCoils->SteamCoil(CoilNum).DesCoilCapacity = DesCoilLoad; + state.dataSteamCoils->SteamCoil(CoilNum).DesAirVolFlow = DesVolFlow; if (ErrorsFound) { ShowFatalError("Preceding Steam coil sizing errors cause program termination"); } // There is no standard rating for heating coils at this point, so fill with dummy flag values - coilSelectionReportObj->setRatedCoilConditions(SteamCoil(CoilNum).Name, + coilSelectionReportObj->setRatedCoilConditions(state.dataSteamCoils->SteamCoil(CoilNum).Name, "Coil:Heating:Steam", -999.0, -999.0, @@ -1057,10 +996,6 @@ namespace SteamCoils { // desired is input by the user, which is used to calculate water outlet temp. // Heat exchange is = Latent Heat + Sensible heat,coil effectivness is 1.0 - // REFERENCES: - // na - - // Using/Aliasing using DataGlobals::DoingSizing; using DataGlobals::KickOffSimulation; using DataGlobals::WarmupFlag; @@ -1068,20 +1003,9 @@ namespace SteamCoils { using FaultsManager::FaultsCoilSATSensor; using PlantUtilities::SetComponentFlowRate; - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: static std::string const RoutineName("CalcSteamAirCoil"); static std::string const RoutineNameSizeSteamCoil("SizeSteamCoil"); - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: static Real64 SteamMassFlowRate(0.0); static Real64 AirMassFlow(0.0); // [kg/sec] static Real64 TempAirIn(0.0); // [C] @@ -1109,35 +1033,35 @@ namespace SteamCoils { static Real64 CpWater(0.0); QCoilReq = QCoilRequested; - TempAirIn = SteamCoil(CoilNum).InletAirTemp; - Win = SteamCoil(CoilNum).InletAirHumRat; - TempSteamIn = SteamCoil(CoilNum).InletSteamTemp; - CoilPress = SteamCoil(CoilNum).InletSteamPress; - SubcoolDeltaTemp = SteamCoil(CoilNum).DegOfSubcooling; - TempSetPoint = SteamCoil(CoilNum).DesiredOutletTemp; + TempAirIn = state.dataSteamCoils->SteamCoil(CoilNum).InletAirTemp; + Win = state.dataSteamCoils->SteamCoil(CoilNum).InletAirHumRat; + TempSteamIn = state.dataSteamCoils->SteamCoil(CoilNum).InletSteamTemp; + CoilPress = state.dataSteamCoils->SteamCoil(CoilNum).InletSteamPress; + SubcoolDeltaTemp = state.dataSteamCoils->SteamCoil(CoilNum).DegOfSubcooling; + TempSetPoint = state.dataSteamCoils->SteamCoil(CoilNum).DesiredOutletTemp; // If there is a fault of coil SAT Sensor (zrp_Jul2016) - if (SteamCoil(CoilNum).FaultyCoilSATFlag && (!WarmupFlag) && (!DoingSizing) && (!KickOffSimulation)) { + if (state.dataSteamCoils->SteamCoil(CoilNum).FaultyCoilSATFlag && (!WarmupFlag) && (!DoingSizing) && (!KickOffSimulation)) { // calculate the sensor offset using fault information - int FaultIndex = SteamCoil(CoilNum).FaultyCoilSATIndex; - SteamCoil(CoilNum).FaultyCoilSATOffset = FaultsCoilSATSensor(FaultIndex).CalFaultOffsetAct(); + int FaultIndex = state.dataSteamCoils->SteamCoil(CoilNum).FaultyCoilSATIndex; + state.dataSteamCoils->SteamCoil(CoilNum).FaultyCoilSATOffset = FaultsCoilSATSensor(FaultIndex).CalFaultOffsetAct(); // update the TempSetPoint - TempSetPoint -= SteamCoil(CoilNum).FaultyCoilSATOffset; + TempSetPoint -= state.dataSteamCoils->SteamCoil(CoilNum).FaultyCoilSATOffset; } // adjust mass flow rates for cycling fan cycling coil operation if (FanOpMode == CycFanCycCoil) { if (PartLoadRatio > 0.0) { - AirMassFlow = SteamCoil(CoilNum).InletAirMassFlowRate / PartLoadRatio; - SteamMassFlowRate = min(SteamCoil(CoilNum).InletSteamMassFlowRate / PartLoadRatio, SteamCoil(CoilNum).MaxSteamMassFlowRate); + AirMassFlow = state.dataSteamCoils->SteamCoil(CoilNum).InletAirMassFlowRate / PartLoadRatio; + SteamMassFlowRate = min(state.dataSteamCoils->SteamCoil(CoilNum).InletSteamMassFlowRate / PartLoadRatio, state.dataSteamCoils->SteamCoil(CoilNum).MaxSteamMassFlowRate); QCoilReq /= PartLoadRatio; } else { AirMassFlow = 0.0; SteamMassFlowRate = 0.0; } } else { - AirMassFlow = SteamCoil(CoilNum).InletAirMassFlowRate; - SteamMassFlowRate = SteamCoil(CoilNum).InletSteamMassFlowRate; + AirMassFlow = state.dataSteamCoils->SteamCoil(CoilNum).InletAirMassFlowRate; + SteamMassFlowRate = state.dataSteamCoils->SteamCoil(CoilNum).InletSteamMassFlowRate; } if (AirMassFlow > 0.0) { // If the coil is operating @@ -1151,17 +1075,17 @@ namespace SteamCoils { // Also the coil has to be scheduled to be available // Control output to meet load QCoilReq. Load Controlled Coil. { - auto const SELECT_CASE_var(SteamCoil(CoilNum).TypeOfCoil); + auto const SELECT_CASE_var(state.dataSteamCoils->SteamCoil(CoilNum).TypeOfCoil); - if (SELECT_CASE_var == ZoneLoadControl) { - if ((CapacitanceAir > 0.0) && ((SteamCoil(CoilNum).InletSteamMassFlowRate) > 0.0) && - (GetCurrentScheduleValue(SteamCoil(CoilNum).SchedPtr) > 0.0 || MySizeFlag(CoilNum)) && (QCoilReq > 0.0)) { + if (SELECT_CASE_var == state.dataSteamCoils->ZoneLoadControl) { + if ((CapacitanceAir > 0.0) && ((state.dataSteamCoils->SteamCoil(CoilNum).InletSteamMassFlowRate) > 0.0) && + (GetCurrentScheduleValue(state.dataSteamCoils->SteamCoil(CoilNum).SchedPtr) > 0.0 || state.dataSteamCoils->MySizeFlag(CoilNum)) && (QCoilReq > 0.0)) { // Steam heat exchangers would not have effectivness, since all of the steam is // converted to water and only then the steam trap allows it to leave the heat // exchanger, subsequently heat exchange is latent heat + subcooling. - EnthSteamInDry = GetSatEnthalpyRefrig(state, fluidNameSteam, TempSteamIn, 1.0, SteamCoil(CoilNum).FluidIndex, RoutineName); - EnthSteamOutWet = GetSatEnthalpyRefrig(state, fluidNameSteam, TempSteamIn, 0.0, SteamCoil(CoilNum).FluidIndex, RoutineName); + EnthSteamInDry = GetSatEnthalpyRefrig(state, fluidNameSteam, TempSteamIn, 1.0, state.dataSteamCoils->SteamCoil(CoilNum).FluidIndex, RoutineName); + EnthSteamOutWet = GetSatEnthalpyRefrig(state, fluidNameSteam, TempSteamIn, 0.0, state.dataSteamCoils->SteamCoil(CoilNum).FluidIndex, RoutineName); LatentHeatSteam = EnthSteamInDry - EnthSteamOutWet; @@ -1170,11 +1094,11 @@ namespace SteamCoils { // PlantLoop(SteamCoil(CoilNum)%LoopNum)%FluidIndex, & // 'CalcSteamAirCoil') - CpWater = GetSatSpecificHeatRefrig(state, fluidNameSteam, TempSteamIn, 0.0, SteamCoil(CoilNum).FluidIndex, RoutineNameSizeSteamCoil); + CpWater = GetSatSpecificHeatRefrig(state, fluidNameSteam, TempSteamIn, 0.0, state.dataSteamCoils->SteamCoil(CoilNum).FluidIndex, RoutineNameSizeSteamCoil); // Max Heat Transfer - QSteamCoilMaxHT = SteamCoil(CoilNum).MaxSteamMassFlowRate * (LatentHeatSteam + SubcoolDeltaTemp * CpWater); - SteamCoil(CoilNum).OperatingCapacity = QSteamCoilMaxHT; + QSteamCoilMaxHT = state.dataSteamCoils->SteamCoil(CoilNum).MaxSteamMassFlowRate * (LatentHeatSteam + SubcoolDeltaTemp * CpWater); + state.dataSteamCoils->SteamCoil(CoilNum).OperatingCapacity = QSteamCoilMaxHT; // Determine the Max coil capacity and check for the same. if (QCoilReq > QSteamCoilMaxHT) { @@ -1187,12 +1111,12 @@ namespace SteamCoils { SteamMassFlowRate = QCoilCap / (LatentHeatSteam + SubcoolDeltaTemp * CpWater); SetComponentFlowRate(SteamMassFlowRate, - SteamCoil(CoilNum).SteamInletNodeNum, - SteamCoil(CoilNum).SteamOutletNodeNum, - SteamCoil(CoilNum).LoopNum, - SteamCoil(CoilNum).LoopSide, - SteamCoil(CoilNum).BranchNum, - SteamCoil(CoilNum).CompNum); + state.dataSteamCoils->SteamCoil(CoilNum).SteamInletNodeNum, + state.dataSteamCoils->SteamCoil(CoilNum).SteamOutletNodeNum, + state.dataSteamCoils->SteamCoil(CoilNum).LoopNum, + state.dataSteamCoils->SteamCoil(CoilNum).LoopSide, + state.dataSteamCoils->SteamCoil(CoilNum).BranchNum, + state.dataSteamCoils->SteamCoil(CoilNum).CompNum); // recalculate if mass flow rate changed in previous call. QCoilCap = SteamMassFlowRate * (LatentHeatSteam + SubcoolDeltaTemp * CpWater); @@ -1211,8 +1135,8 @@ namespace SteamCoils { // Temperature of air at outlet TempAirOut = TempAirIn + QCoilCap / (AirMassFlow * PsyCpAirFnW(Win)); - SteamCoil(CoilNum).OutletSteamMassFlowRate = SteamMassFlowRate; - SteamCoil(CoilNum).InletSteamMassFlowRate = SteamMassFlowRate; + state.dataSteamCoils->SteamCoil(CoilNum).OutletSteamMassFlowRate = SteamMassFlowRate; + state.dataSteamCoils->SteamCoil(CoilNum).InletSteamMassFlowRate = SteamMassFlowRate; //************************* Loop Losses ***************************** // Loop pressure return considerations included in steam coil since the pipes are @@ -1223,65 +1147,65 @@ namespace SteamCoils { // considering saturated state. // StdBaroPress=101325 - TempWaterAtmPress = GetSatTemperatureRefrig(state, fluidNameSteam, StdBaroPress, SteamCoil(CoilNum).FluidIndex, RoutineName); + TempWaterAtmPress = GetSatTemperatureRefrig(state, fluidNameSteam, StdBaroPress, state.dataSteamCoils->SteamCoil(CoilNum).FluidIndex, RoutineName); // Point 4 at atm - loop delta subcool during return journery back to pump - TempLoopOutToPump = TempWaterAtmPress - SteamCoil(CoilNum).LoopSubcoolReturn; + TempLoopOutToPump = TempWaterAtmPress - state.dataSteamCoils->SteamCoil(CoilNum).LoopSubcoolReturn; // Actual Steam Coil Outlet Enthalpy - EnthCoilOutlet = GetSatEnthalpyRefrig(state, fluidNameSteam, TempSteamIn, 0.0, SteamCoil(CoilNum).FluidIndex, RoutineName) - + EnthCoilOutlet = GetSatEnthalpyRefrig(state, fluidNameSteam, TempSteamIn, 0.0, state.dataSteamCoils->SteamCoil(CoilNum).FluidIndex, RoutineName) - CpWater * SubcoolDeltaTemp; // Enthalpy at Point 4 - EnthAtAtmPress = GetSatEnthalpyRefrig(state, fluidNameSteam, TempWaterAtmPress, 0.0, SteamCoil(CoilNum).FluidIndex, RoutineName); + EnthAtAtmPress = GetSatEnthalpyRefrig(state, fluidNameSteam, TempWaterAtmPress, 0.0, state.dataSteamCoils->SteamCoil(CoilNum).FluidIndex, RoutineName); // Reported value of coil outlet enthalpy at the node to match the node outlet temperature CpWater = - GetSatSpecificHeatRefrig(state, fluidNameSteam, TempLoopOutToPump, 0.0, SteamCoil(CoilNum).FluidIndex, RoutineNameSizeSteamCoil); + GetSatSpecificHeatRefrig(state, fluidNameSteam, TempLoopOutToPump, 0.0, state.dataSteamCoils->SteamCoil(CoilNum).FluidIndex, RoutineNameSizeSteamCoil); - EnthPumpInlet = EnthAtAtmPress - CpWater * SteamCoil(CoilNum).LoopSubcoolReturn; + EnthPumpInlet = EnthAtAtmPress - CpWater * state.dataSteamCoils->SteamCoil(CoilNum).LoopSubcoolReturn; - SteamCoil(CoilNum).OutletWaterEnthalpy = EnthPumpInlet; + state.dataSteamCoils->SteamCoil(CoilNum).OutletWaterEnthalpy = EnthPumpInlet; // Point 3-Point 5, EnergyLossToEnvironment = SteamMassFlowRate * (EnthCoilOutlet - EnthPumpInlet); // Loss to enviornment due to pressure drop - SteamCoil(CoilNum).LoopLoss = EnergyLossToEnvironment; + state.dataSteamCoils->SteamCoil(CoilNum).LoopLoss = EnergyLossToEnvironment; //************************* Loop Losses ***************************** } else { // Coil is not running. TempAirOut = TempAirIn; TempWaterOut = TempSteamIn; HeatingCoilLoad = 0.0; - SteamCoil(CoilNum).OutletWaterEnthalpy = SteamCoil(CoilNum).InletSteamEnthalpy; - SteamCoil(CoilNum).OutletSteamMassFlowRate = 0.0; - SteamCoil(CoilNum).OutletSteamQuality = 0.0; - SteamCoil(CoilNum).LoopLoss = 0.0; + state.dataSteamCoils->SteamCoil(CoilNum).OutletWaterEnthalpy = state.dataSteamCoils->SteamCoil(CoilNum).InletSteamEnthalpy; + state.dataSteamCoils->SteamCoil(CoilNum).OutletSteamMassFlowRate = 0.0; + state.dataSteamCoils->SteamCoil(CoilNum).OutletSteamQuality = 0.0; + state.dataSteamCoils->SteamCoil(CoilNum).LoopLoss = 0.0; TempLoopOutToPump = TempWaterOut; } - } else if (SELECT_CASE_var == TemperatureSetPointControl) { + } else if (SELECT_CASE_var == state.dataSteamCoils->TemperatureSetPointControl) { // Control coil output to meet a Setpoint Temperature. - if ((CapacitanceAir > 0.0) && ((SteamCoil(CoilNum).InletSteamMassFlowRate) > 0.0) && - (GetCurrentScheduleValue(SteamCoil(CoilNum).SchedPtr) > 0.0 || MySizeFlag(CoilNum)) && + if ((CapacitanceAir > 0.0) && ((state.dataSteamCoils->SteamCoil(CoilNum).InletSteamMassFlowRate) > 0.0) && + (GetCurrentScheduleValue(state.dataSteamCoils->SteamCoil(CoilNum).SchedPtr) > 0.0 || state.dataSteamCoils->MySizeFlag(CoilNum)) && (std::abs(TempSetPoint - TempAirIn) > TempControlTol)) { // Steam heat exchangers would not have effectivness, since all of the steam is // converted to water and only then the steam trap allows it to leave the heat // exchanger, subsequently heat exchange is latent heat + subcooling. - EnthSteamInDry = GetSatEnthalpyRefrig(state, fluidNameSteam, TempSteamIn, 1.0, SteamCoil(CoilNum).FluidIndex, RoutineName); - EnthSteamOutWet = GetSatEnthalpyRefrig(state, fluidNameSteam, TempSteamIn, 0.0, SteamCoil(CoilNum).FluidIndex, RoutineName); + EnthSteamInDry = GetSatEnthalpyRefrig(state, fluidNameSteam, TempSteamIn, 1.0, state.dataSteamCoils->SteamCoil(CoilNum).FluidIndex, RoutineName); + EnthSteamOutWet = GetSatEnthalpyRefrig(state, fluidNameSteam, TempSteamIn, 0.0, state.dataSteamCoils->SteamCoil(CoilNum).FluidIndex, RoutineName); LatentHeatSteam = EnthSteamInDry - EnthSteamOutWet; // CpWater = GetSpecificHeatGlycol('WATER', & // TempSteamIn, & // PlantLoop(SteamCoil(CoilNum)%LoopNum)%FluidIndex, & // 'CalcSteamAirCoil') - CpWater = GetSatSpecificHeatRefrig(state, fluidNameSteam, TempSteamIn, 0.0, SteamCoil(CoilNum).FluidIndex, RoutineNameSizeSteamCoil); + CpWater = GetSatSpecificHeatRefrig(state, fluidNameSteam, TempSteamIn, 0.0, state.dataSteamCoils->SteamCoil(CoilNum).FluidIndex, RoutineNameSizeSteamCoil); // Max Heat Transfer - QSteamCoilMaxHT = SteamCoil(CoilNum).MaxSteamMassFlowRate * (LatentHeatSteam + SubcoolDeltaTemp * CpWater); + QSteamCoilMaxHT = state.dataSteamCoils->SteamCoil(CoilNum).MaxSteamMassFlowRate * (LatentHeatSteam + SubcoolDeltaTemp * CpWater); // Coil Load in case of temperature setpoint QCoilCap = CapacitanceAir * (TempSetPoint - TempAirIn); @@ -1295,12 +1219,12 @@ namespace SteamCoils { // Steam Mass Flow Rate Required SteamMassFlowRate = 0.0; SetComponentFlowRate(SteamMassFlowRate, - SteamCoil(CoilNum).SteamInletNodeNum, - SteamCoil(CoilNum).SteamOutletNodeNum, - SteamCoil(CoilNum).LoopNum, - SteamCoil(CoilNum).LoopSide, - SteamCoil(CoilNum).BranchNum, - SteamCoil(CoilNum).CompNum); + state.dataSteamCoils->SteamCoil(CoilNum).SteamInletNodeNum, + state.dataSteamCoils->SteamCoil(CoilNum).SteamOutletNodeNum, + state.dataSteamCoils->SteamCoil(CoilNum).LoopNum, + state.dataSteamCoils->SteamCoil(CoilNum).LoopSide, + state.dataSteamCoils->SteamCoil(CoilNum).BranchNum, + state.dataSteamCoils->SteamCoil(CoilNum).CompNum); // Inlet equal to outlet when not required to run. TempWaterOut = TempSteamIn; @@ -1308,11 +1232,11 @@ namespace SteamCoils { HeatingCoilLoad = QCoilCap; // The HeatingCoilLoad is the change in the enthalpy of the water - SteamCoil(CoilNum).OutletWaterEnthalpy = SteamCoil(CoilNum).InletSteamEnthalpy; + state.dataSteamCoils->SteamCoil(CoilNum).OutletWaterEnthalpy = state.dataSteamCoils->SteamCoil(CoilNum).InletSteamEnthalpy; // Outlet flow rate set to inlet - SteamCoil(CoilNum).OutletSteamMassFlowRate = SteamMassFlowRate; - SteamCoil(CoilNum).InletSteamMassFlowRate = SteamMassFlowRate; + state.dataSteamCoils->SteamCoil(CoilNum).OutletSteamMassFlowRate = SteamMassFlowRate; + state.dataSteamCoils->SteamCoil(CoilNum).InletSteamMassFlowRate = SteamMassFlowRate; } else if (QCoilCap > QSteamCoilMaxHT) { // Setting to Maximum Coil Capacity @@ -1332,12 +1256,12 @@ namespace SteamCoils { // Steam Mass Flow Rate Required SteamMassFlowRate = QCoilCap / (LatentHeatSteam + SubcoolDeltaTemp * CpWater); SetComponentFlowRate(SteamMassFlowRate, - SteamCoil(CoilNum).SteamInletNodeNum, - SteamCoil(CoilNum).SteamOutletNodeNum, - SteamCoil(CoilNum).LoopNum, - SteamCoil(CoilNum).LoopSide, - SteamCoil(CoilNum).BranchNum, - SteamCoil(CoilNum).CompNum); + state.dataSteamCoils->SteamCoil(CoilNum).SteamInletNodeNum, + state.dataSteamCoils->SteamCoil(CoilNum).SteamOutletNodeNum, + state.dataSteamCoils->SteamCoil(CoilNum).LoopNum, + state.dataSteamCoils->SteamCoil(CoilNum).LoopSide, + state.dataSteamCoils->SteamCoil(CoilNum).BranchNum, + state.dataSteamCoils->SteamCoil(CoilNum).CompNum); // recalculate in case previous call changed mass flow rate QCoilCap = SteamMassFlowRate * (LatentHeatSteam + SubcoolDeltaTemp * CpWater); @@ -1347,9 +1271,9 @@ namespace SteamCoils { HeatingCoilLoad = QCoilCap; // The HeatingCoilLoad is the change in the enthalpy of the water - SteamCoil(CoilNum).OutletWaterEnthalpy = SteamCoil(CoilNum).InletSteamEnthalpy - HeatingCoilLoad / SteamMassFlowRate; - SteamCoil(CoilNum).OutletSteamMassFlowRate = SteamMassFlowRate; - SteamCoil(CoilNum).InletSteamMassFlowRate = SteamMassFlowRate; + state.dataSteamCoils->SteamCoil(CoilNum).OutletWaterEnthalpy = state.dataSteamCoils->SteamCoil(CoilNum).InletSteamEnthalpy - HeatingCoilLoad / SteamMassFlowRate; + state.dataSteamCoils->SteamCoil(CoilNum).OutletSteamMassFlowRate = SteamMassFlowRate; + state.dataSteamCoils->SteamCoil(CoilNum).InletSteamMassFlowRate = SteamMassFlowRate; } else { // Temp air out is temperature Setpoint @@ -1366,12 +1290,12 @@ namespace SteamCoils { // Steam Mass Flow Rate Required SteamMassFlowRate = QCoilCap / (LatentHeatSteam + SubcoolDeltaTemp * CpWater); SetComponentFlowRate(SteamMassFlowRate, - SteamCoil(CoilNum).SteamInletNodeNum, - SteamCoil(CoilNum).SteamOutletNodeNum, - SteamCoil(CoilNum).LoopNum, - SteamCoil(CoilNum).LoopSide, - SteamCoil(CoilNum).BranchNum, - SteamCoil(CoilNum).CompNum); + state.dataSteamCoils->SteamCoil(CoilNum).SteamInletNodeNum, + state.dataSteamCoils->SteamCoil(CoilNum).SteamOutletNodeNum, + state.dataSteamCoils->SteamCoil(CoilNum).LoopNum, + state.dataSteamCoils->SteamCoil(CoilNum).LoopSide, + state.dataSteamCoils->SteamCoil(CoilNum).BranchNum, + state.dataSteamCoils->SteamCoil(CoilNum).CompNum); // recalculate in case previous call changed mass flow rate QCoilCap = SteamMassFlowRate * (LatentHeatSteam + SubcoolDeltaTemp * CpWater); @@ -1380,8 +1304,8 @@ namespace SteamCoils { // Total Heat Transfer to air HeatingCoilLoad = QCoilCap; - SteamCoil(CoilNum).OutletSteamMassFlowRate = SteamMassFlowRate; - SteamCoil(CoilNum).InletSteamMassFlowRate = SteamMassFlowRate; + state.dataSteamCoils->SteamCoil(CoilNum).OutletSteamMassFlowRate = SteamMassFlowRate; + state.dataSteamCoils->SteamCoil(CoilNum).InletSteamMassFlowRate = SteamMassFlowRate; //************************* Loop Losses ***************************** // Loop pressure return considerations included in steam coil since the pipes are @@ -1393,50 +1317,50 @@ namespace SteamCoils { // considering saturated state. // StdBaroPress=101325 - TempWaterAtmPress = GetSatTemperatureRefrig(state, fluidNameSteam, StdBaroPress, SteamCoil(CoilNum).FluidIndex, RoutineName); + TempWaterAtmPress = GetSatTemperatureRefrig(state, fluidNameSteam, StdBaroPress, state.dataSteamCoils->SteamCoil(CoilNum).FluidIndex, RoutineName); // Point 4 at atm - loop delta subcool during return journery back to pump - TempLoopOutToPump = TempWaterAtmPress - SteamCoil(CoilNum).LoopSubcoolReturn; + TempLoopOutToPump = TempWaterAtmPress - state.dataSteamCoils->SteamCoil(CoilNum).LoopSubcoolReturn; // Actual Steam Coil Outlet Enthalpy - EnthCoilOutlet = GetSatEnthalpyRefrig(state, fluidNameSteam, TempSteamIn, 0.0, SteamCoil(CoilNum).FluidIndex, RoutineName) - + EnthCoilOutlet = GetSatEnthalpyRefrig(state, fluidNameSteam, TempSteamIn, 0.0, state.dataSteamCoils->SteamCoil(CoilNum).FluidIndex, RoutineName) - CpWater * SubcoolDeltaTemp; // Enthalpy at Point 4 - EnthAtAtmPress = GetSatEnthalpyRefrig(state, fluidNameSteam, TempWaterAtmPress, 0.0, SteamCoil(CoilNum).FluidIndex, RoutineName); + EnthAtAtmPress = GetSatEnthalpyRefrig(state, fluidNameSteam, TempWaterAtmPress, 0.0, state.dataSteamCoils->SteamCoil(CoilNum).FluidIndex, RoutineName); CpWater = - GetSatSpecificHeatRefrig(state, fluidNameSteam, TempLoopOutToPump, 0.0, SteamCoil(CoilNum).FluidIndex, RoutineNameSizeSteamCoil); + GetSatSpecificHeatRefrig(state, fluidNameSteam, TempLoopOutToPump, 0.0, state.dataSteamCoils->SteamCoil(CoilNum).FluidIndex, RoutineNameSizeSteamCoil); // Reported value of coil outlet enthalpy at the node to match the node outlet temperature - EnthPumpInlet = EnthAtAtmPress - CpWater * SteamCoil(CoilNum).LoopSubcoolReturn; + EnthPumpInlet = EnthAtAtmPress - CpWater * state.dataSteamCoils->SteamCoil(CoilNum).LoopSubcoolReturn; - SteamCoil(CoilNum).OutletWaterEnthalpy = EnthPumpInlet; + state.dataSteamCoils->SteamCoil(CoilNum).OutletWaterEnthalpy = EnthPumpInlet; // Point 3-Point 5, EnergyLossToEnvironment = SteamMassFlowRate * (EnthCoilOutlet - EnthPumpInlet); // Loss to enviornment due to pressure drop - SteamCoil(CoilNum).LoopLoss = EnergyLossToEnvironment; + state.dataSteamCoils->SteamCoil(CoilNum).LoopLoss = EnergyLossToEnvironment; //************************* Loop Losses ***************************** } } else { // If not running Conditions do not change across coil from inlet to outlet SteamMassFlowRate = 0.0; SetComponentFlowRate(SteamMassFlowRate, - SteamCoil(CoilNum).SteamInletNodeNum, - SteamCoil(CoilNum).SteamOutletNodeNum, - SteamCoil(CoilNum).LoopNum, - SteamCoil(CoilNum).LoopSide, - SteamCoil(CoilNum).BranchNum, - SteamCoil(CoilNum).CompNum); + state.dataSteamCoils->SteamCoil(CoilNum).SteamInletNodeNum, + state.dataSteamCoils->SteamCoil(CoilNum).SteamOutletNodeNum, + state.dataSteamCoils->SteamCoil(CoilNum).LoopNum, + state.dataSteamCoils->SteamCoil(CoilNum).LoopSide, + state.dataSteamCoils->SteamCoil(CoilNum).BranchNum, + state.dataSteamCoils->SteamCoil(CoilNum).CompNum); TempAirOut = TempAirIn; TempWaterOut = TempSteamIn; HeatingCoilLoad = 0.0; - SteamCoil(CoilNum).OutletWaterEnthalpy = SteamCoil(CoilNum).InletSteamEnthalpy; - SteamCoil(CoilNum).OutletSteamMassFlowRate = 0.0; - SteamCoil(CoilNum).OutletSteamQuality = 0.0; - SteamCoil(CoilNum).LoopLoss = 0.0; + state.dataSteamCoils->SteamCoil(CoilNum).OutletWaterEnthalpy = state.dataSteamCoils->SteamCoil(CoilNum).InletSteamEnthalpy; + state.dataSteamCoils->SteamCoil(CoilNum).OutletSteamMassFlowRate = 0.0; + state.dataSteamCoils->SteamCoil(CoilNum).OutletSteamQuality = 0.0; + state.dataSteamCoils->SteamCoil(CoilNum).LoopLoss = 0.0; TempLoopOutToPump = TempWaterOut; } } @@ -1447,22 +1371,22 @@ namespace SteamCoils { } // Set the outlet conditions - SteamCoil(CoilNum).TotSteamHeatingCoilRate = HeatingCoilLoad; - SteamCoil(CoilNum).OutletAirTemp = TempAirOut; - SteamCoil(CoilNum).OutletSteamTemp = TempLoopOutToPump; - SteamCoil(CoilNum).OutletSteamQuality = 0.0; + state.dataSteamCoils->SteamCoil(CoilNum).TotSteamHeatingCoilRate = HeatingCoilLoad; + state.dataSteamCoils->SteamCoil(CoilNum).OutletAirTemp = TempAirOut; + state.dataSteamCoils->SteamCoil(CoilNum).OutletSteamTemp = TempLoopOutToPump; + state.dataSteamCoils->SteamCoil(CoilNum).OutletSteamQuality = 0.0; QCoilActual = HeatingCoilLoad; // This SteamCoil does not change the moisture or Mass Flow across the component - SteamCoil(CoilNum).OutletAirHumRat = SteamCoil(CoilNum).InletAirHumRat; - SteamCoil(CoilNum).OutletAirMassFlowRate = SteamCoil(CoilNum).InletAirMassFlowRate; + state.dataSteamCoils->SteamCoil(CoilNum).OutletAirHumRat = state.dataSteamCoils->SteamCoil(CoilNum).InletAirHumRat; + state.dataSteamCoils->SteamCoil(CoilNum).OutletAirMassFlowRate = state.dataSteamCoils->SteamCoil(CoilNum).InletAirMassFlowRate; // Set the outlet enthalpys for air and water - SteamCoil(CoilNum).OutletAirEnthalpy = PsyHFnTdbW(SteamCoil(CoilNum).OutletAirTemp, SteamCoil(CoilNum).OutletAirHumRat); + state.dataSteamCoils->SteamCoil(CoilNum).OutletAirEnthalpy = PsyHFnTdbW(state.dataSteamCoils->SteamCoil(CoilNum).OutletAirTemp, state.dataSteamCoils->SteamCoil(CoilNum).OutletAirHumRat); } // Beginning of Update subroutines for the SteamCoil Module - void UpdateSteamCoil(int const CoilNum) + void UpdateSteamCoil(EnergyPlusData &state, int const CoilNum) { // SUBROUTINE INFORMATION: // AUTHOR Rahul Chillar @@ -1476,49 +1400,32 @@ namespace SteamCoils { // METHODOLOGY EMPLOYED: // Data is moved from the coil data structure to the coil outlet nodes. - // REFERENCES: - // na - - // Using/Aliasing using DataContaminantBalance::Contaminant; using PlantUtilities::SafeCopyPlantNode; - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int AirInletNode; int SteamInletNode; int AirOutletNode; int SteamOutletNode; - AirInletNode = SteamCoil(CoilNum).AirInletNodeNum; - SteamInletNode = SteamCoil(CoilNum).SteamInletNodeNum; - AirOutletNode = SteamCoil(CoilNum).AirOutletNodeNum; - SteamOutletNode = SteamCoil(CoilNum).SteamOutletNodeNum; + AirInletNode = state.dataSteamCoils->SteamCoil(CoilNum).AirInletNodeNum; + SteamInletNode = state.dataSteamCoils->SteamCoil(CoilNum).SteamInletNodeNum; + AirOutletNode = state.dataSteamCoils->SteamCoil(CoilNum).AirOutletNodeNum; + SteamOutletNode = state.dataSteamCoils->SteamCoil(CoilNum).SteamOutletNodeNum; // Set the outlet air nodes of the SteamCoil - Node(AirOutletNode).MassFlowRate = SteamCoil(CoilNum).OutletAirMassFlowRate; - Node(AirOutletNode).Temp = SteamCoil(CoilNum).OutletAirTemp; - Node(AirOutletNode).HumRat = SteamCoil(CoilNum).OutletAirHumRat; - Node(AirOutletNode).Enthalpy = SteamCoil(CoilNum).OutletAirEnthalpy; + Node(AirOutletNode).MassFlowRate = state.dataSteamCoils->SteamCoil(CoilNum).OutletAirMassFlowRate; + Node(AirOutletNode).Temp = state.dataSteamCoils->SteamCoil(CoilNum).OutletAirTemp; + Node(AirOutletNode).HumRat = state.dataSteamCoils->SteamCoil(CoilNum).OutletAirHumRat; + Node(AirOutletNode).Enthalpy = state.dataSteamCoils->SteamCoil(CoilNum).OutletAirEnthalpy; SafeCopyPlantNode(SteamInletNode, SteamOutletNode); // Set the outlet Steam nodes for the Coil // Node(SteamOutletNode)%MassFlowRate = SteamCoil(CoilNum)%OutletSteamMassFlowRate - Node(SteamOutletNode).Temp = SteamCoil(CoilNum).OutletSteamTemp; - Node(SteamOutletNode).Enthalpy = SteamCoil(CoilNum).OutletWaterEnthalpy; - Node(SteamOutletNode).Quality = SteamCoil(CoilNum).OutletSteamQuality; + Node(SteamOutletNode).Temp = state.dataSteamCoils->SteamCoil(CoilNum).OutletSteamTemp; + Node(SteamOutletNode).Enthalpy = state.dataSteamCoils->SteamCoil(CoilNum).OutletWaterEnthalpy; + Node(SteamOutletNode).Quality = state.dataSteamCoils->SteamCoil(CoilNum).OutletSteamQuality; // Node(SteamInletNode)%MassFlowRate = SteamCoil(CoilNum)%OutletSteamMassFlowRate // Set the outlet nodes for properties that just pass through & not used @@ -1557,7 +1464,7 @@ namespace SteamCoils { // Beginning of Reporting subroutines for the SteamCoil Module - void ReportSteamCoil(int const CoilNum) + void ReportSteamCoil(EnergyPlusData &state, int const CoilNum) { // SUBROUTINE INFORMATION: // AUTHOR Rahul Chillar @@ -1568,32 +1475,8 @@ namespace SteamCoils { // PURPOSE OF THIS SUBROUTINE: // This subroutine updates the report variable for the coils. - // METHODOLOGY EMPLOYED: - // na - - // REFERENCES: - // na - - // USE STATEMENTS: - // na - - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - // na - // Report the SteamCoil energy from this component - SteamCoil(CoilNum).TotSteamHeatingCoilEnergy = SteamCoil(CoilNum).TotSteamHeatingCoilRate * TimeStepSys * DataGlobalConstants::SecInHour(); + state.dataSteamCoils->SteamCoil(CoilNum).TotSteamHeatingCoilEnergy = state.dataSteamCoils->SteamCoil(CoilNum).TotSteamHeatingCoilRate * TimeStepSys * DataGlobalConstants::SecInHour(); } // End of Reporting subroutines for the SteamCoil Module @@ -1622,13 +1505,13 @@ namespace SteamCoils { int IndexNum; // returned air inlet node number of matched coil // Obtains and Allocates SteamCoil related parameters from input file - if (GetSteamCoilsInputFlag) { // First time subroutine has been entered + if (state.dataSteamCoils->GetSteamCoilsInputFlag) { // First time subroutine has been entered GetSteamCoilInput(state); - GetSteamCoilsInputFlag = false; + state.dataSteamCoils->GetSteamCoilsInputFlag = false; } if (CoilType == "COIL:HEATING:STEAM") { - IndexNum = UtilityRoutines::FindItemInList(CoilName, SteamCoil); + IndexNum = UtilityRoutines::FindItemInList(CoilName, state.dataSteamCoils->SteamCoil); } else { IndexNum = 0; } @@ -1660,30 +1543,30 @@ namespace SteamCoils { int CoilNum; // Obtains and Allocates SteamCoil related parameters from input file - if (GetSteamCoilsInputFlag) { // First time subroutine has been entered + if (state.dataSteamCoils->GetSteamCoilsInputFlag) { // First time subroutine has been entered GetSteamCoilInput(state); - GetSteamCoilsInputFlag = false; + state.dataSteamCoils->GetSteamCoilsInputFlag = false; } // Find the correct Coil number if (CompIndex == 0) { - CoilNum = UtilityRoutines::FindItemInList(CompName, SteamCoil); + CoilNum = UtilityRoutines::FindItemInList(CompName, state.dataSteamCoils->SteamCoil); if (CoilNum == 0) { ShowFatalError("CheckSteamCoilSchedule: Coil not found=" + CompName); } CompIndex = CoilNum; - Value = GetCurrentScheduleValue(SteamCoil(CoilNum).SchedPtr); // not scheduled? + Value = GetCurrentScheduleValue(state.dataSteamCoils->SteamCoil(CoilNum).SchedPtr); // not scheduled? } else { CoilNum = CompIndex; - if (CoilNum > NumSteamCoils || CoilNum < 1) { + if (CoilNum > state.dataSteamCoils->NumSteamCoils || CoilNum < 1) { ShowFatalError("SimulateSteamCoilComponents: Invalid CompIndex passed=" + TrimSigDigits(CoilNum) + - ", Number of Steam Coils=" + TrimSigDigits(NumSteamCoils) + ", Coil name=" + CompName); + ", Number of Steam Coils=" + TrimSigDigits(state.dataSteamCoils->NumSteamCoils) + ", Coil name=" + CompName); } - if (CompName != SteamCoil(CoilNum).Name) { + if (CompName != state.dataSteamCoils->SteamCoil(CoilNum).Name) { ShowFatalError("SimulateSteamCoilComponents: Invalid CompIndex passed=" + TrimSigDigits(CoilNum) + ", Coil name=" + CompName + - ", stored Coil Name for that index=" + SteamCoil(CoilNum).Name); + ", stored Coil Name for that index=" + state.dataSteamCoils->SteamCoil(CoilNum).Name); } - Value = GetCurrentScheduleValue(SteamCoil(CoilNum).SchedPtr); // not scheduled? + Value = GetCurrentScheduleValue(state.dataSteamCoils->SteamCoil(CoilNum).SchedPtr); // not scheduled? } } @@ -1713,13 +1596,13 @@ namespace SteamCoils { static int ErrCount(0); // Obtains and Allocates SteamCoil related parameters from input file - if (GetSteamCoilsInputFlag) { // First time subroutine has been entered + if (state.dataSteamCoils->GetSteamCoilsInputFlag) { // First time subroutine has been entered GetSteamCoilInput(state); - GetSteamCoilsInputFlag = false; + state.dataSteamCoils->GetSteamCoilsInputFlag = false; } if (UtilityRoutines::SameString(CoilType, "Coil:Heating:Steam")) { - WhichCoil = UtilityRoutines::FindItem(CoilName, SteamCoil); + WhichCoil = UtilityRoutines::FindItem(CoilName, state.dataSteamCoils->SteamCoil); if (WhichCoil != 0) { // coil does not specify MaxWaterFlowRate MaxWaterFlowRate = 0.0; @@ -1759,9 +1642,9 @@ namespace SteamCoils { Real64 MaxSteamFlowRate; // returned max steam flow rate of matched coil // Obtains and Allocates SteamCoil related parameters from input file - if (GetSteamCoilsInputFlag) { // First time subroutine has been entered + if (state.dataSteamCoils->GetSteamCoilsInputFlag) { // First time subroutine has been entered GetSteamCoilInput(state); - GetSteamCoilsInputFlag = false; + state.dataSteamCoils->GetSteamCoilsInputFlag = false; } if (CoilIndex == 0) { @@ -1769,7 +1652,7 @@ namespace SteamCoils { ErrorsFound = true; MaxSteamFlowRate = 0.0; } else { - MaxSteamFlowRate = SteamCoil(CoilIndex).MaxSteamVolFlowRate; + MaxSteamFlowRate = state.dataSteamCoils->SteamCoil(CoilIndex).MaxSteamVolFlowRate; } return MaxSteamFlowRate; @@ -1797,9 +1680,9 @@ namespace SteamCoils { int NodeNumber; // returned air inlet node number of matched coil // Obtains and Allocates SteamCoil related parameters from input file - if (GetSteamCoilsInputFlag) { // First time subroutine has been entered + if (state.dataSteamCoils->GetSteamCoilsInputFlag) { // First time subroutine has been entered GetSteamCoilInput(state); - GetSteamCoilsInputFlag = false; + state.dataSteamCoils->GetSteamCoilsInputFlag = false; } if (CoilIndex == 0) { @@ -1807,7 +1690,7 @@ namespace SteamCoils { ErrorsFound = true; NodeNumber = 0; } else { - NodeNumber = SteamCoil(CoilIndex).AirInletNodeNum; + NodeNumber = state.dataSteamCoils->SteamCoil(CoilIndex).AirInletNodeNum; } return NodeNumber; @@ -1843,25 +1726,10 @@ namespace SteamCoils { // Return value int NodeNumber; // returned air inlet node number of matched coil - // Locals - // FUNCTION ARGUMENT DEFINITIONS: - - // FUNCTION PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS: - // na - - // DERIVED TYPE DEFINITIONS: - // na - - // FUNCTION LOCAL VARIABLE DECLARATIONS: - // na - // Obtains and Allocates SteamCoil related parameters from input file - if (GetSteamCoilsInputFlag) { // First time subroutine has been entered + if (state.dataSteamCoils->GetSteamCoilsInputFlag) { // First time subroutine has been entered GetSteamCoilInput(state); - GetSteamCoilsInputFlag = false; + state.dataSteamCoils->GetSteamCoilsInputFlag = false; } if (CoilIndex == 0) { @@ -1869,7 +1737,7 @@ namespace SteamCoils { ErrorsFound = true; NodeNumber = 0; } else { - NodeNumber = SteamCoil(CoilIndex).AirOutletNodeNum; + NodeNumber = state.dataSteamCoils->SteamCoil(CoilIndex).AirOutletNodeNum; } return NodeNumber; @@ -1900,13 +1768,13 @@ namespace SteamCoils { int IndexNum; // returned air inlet node number of matched coil // Obtains and Allocates SteamCoil related parameters from input file - if (GetSteamCoilsInputFlag) { // First time subroutine has been entered + if (state.dataSteamCoils->GetSteamCoilsInputFlag) { // First time subroutine has been entered GetSteamCoilInput(state); - GetSteamCoilsInputFlag = false; + state.dataSteamCoils->GetSteamCoilsInputFlag = false; } if (UtilityRoutines::SameString(CoilType, "Coil:Heating:Steam")) { - IndexNum = UtilityRoutines::FindItem(CoilName, SteamCoil); + IndexNum = UtilityRoutines::FindItem(CoilName, state.dataSteamCoils->SteamCoil); } else { IndexNum = 0; } @@ -1914,7 +1782,7 @@ namespace SteamCoils { if (IndexNum == 0) { NodeNumber = 0; } else { - NodeNumber = SteamCoil(IndexNum).AirOutletNodeNum; + NodeNumber = state.dataSteamCoils->SteamCoil(IndexNum).AirOutletNodeNum; } return NodeNumber; @@ -1942,9 +1810,9 @@ namespace SteamCoils { int NodeNumber; // returned air inlet node number of matched coil // Obtains and Allocates SteamCoil related parameters from input file - if (GetSteamCoilsInputFlag) { // First time subroutine has been entered + if (state.dataSteamCoils->GetSteamCoilsInputFlag) { // First time subroutine has been entered GetSteamCoilInput(state); - GetSteamCoilsInputFlag = false; + state.dataSteamCoils->GetSteamCoilsInputFlag = false; } if (CoilIndex == 0) { @@ -1952,7 +1820,7 @@ namespace SteamCoils { ErrorsFound = true; NodeNumber = 0; } else { - NodeNumber = SteamCoil(CoilIndex).SteamInletNodeNum; + NodeNumber = state.dataSteamCoils->SteamCoil(CoilIndex).SteamInletNodeNum; } return NodeNumber; @@ -1983,13 +1851,13 @@ namespace SteamCoils { int IndexNum; // returned air inlet node number of matched coil // Obtains and Allocates SteamCoil related parameters from input file - if (GetSteamCoilsInputFlag) { // First time subroutine has been entered + if (state.dataSteamCoils->GetSteamCoilsInputFlag) { // First time subroutine has been entered GetSteamCoilInput(state); - GetSteamCoilsInputFlag = false; + state.dataSteamCoils->GetSteamCoilsInputFlag = false; } if (UtilityRoutines::SameString(CoilType, "Coil:Heating:Steam")) { - IndexNum = UtilityRoutines::FindItem(CoilName, SteamCoil); + IndexNum = UtilityRoutines::FindItem(CoilName, state.dataSteamCoils->SteamCoil); } else { IndexNum = 0; } @@ -1999,7 +1867,7 @@ namespace SteamCoils { ErrorsFound = true; NodeNumber = 0; } else { - NodeNumber = SteamCoil(IndexNum).SteamInletNodeNum; + NodeNumber = state.dataSteamCoils->SteamCoil(IndexNum).SteamInletNodeNum; } return NodeNumber; @@ -2027,9 +1895,9 @@ namespace SteamCoils { int NodeNumber; // returned air inlet node number of matched coil // Obtains and Allocates SteamCoil related parameters from input file - if (GetSteamCoilsInputFlag) { // First time subroutine has been entered + if (state.dataSteamCoils->GetSteamCoilsInputFlag) { // First time subroutine has been entered GetSteamCoilInput(state); - GetSteamCoilsInputFlag = false; + state.dataSteamCoils->GetSteamCoilsInputFlag = false; } if (CoilIndex == 0) { @@ -2037,7 +1905,7 @@ namespace SteamCoils { ErrorsFound = true; NodeNumber = 0; } else { - NodeNumber = SteamCoil(CoilIndex).SteamOutletNodeNum; + NodeNumber = state.dataSteamCoils->SteamCoil(CoilIndex).SteamOutletNodeNum; } return NodeNumber; @@ -2068,13 +1936,13 @@ namespace SteamCoils { int IndexNum; // returned air inlet node number of matched coil // Obtains and Allocates SteamCoil related parameters from input file - if (GetSteamCoilsInputFlag) { // First time subroutine has been entered + if (state.dataSteamCoils->GetSteamCoilsInputFlag) { // First time subroutine has been entered GetSteamCoilInput(state); - GetSteamCoilsInputFlag = false; + state.dataSteamCoils->GetSteamCoilsInputFlag = false; } if (UtilityRoutines::SameString(CoilType, "Coil:Heating:Steam")) { - IndexNum = UtilityRoutines::FindItem(CoilName, SteamCoil); + IndexNum = UtilityRoutines::FindItem(CoilName, state.dataSteamCoils->SteamCoil); } else { IndexNum = 0; } @@ -2084,7 +1952,7 @@ namespace SteamCoils { ErrorsFound = true; NodeNumber = 0; } else { - NodeNumber = SteamCoil(IndexNum).SteamOutletNodeNum; + NodeNumber = state.dataSteamCoils->SteamCoil(IndexNum).SteamOutletNodeNum; } return NodeNumber; @@ -2115,16 +1983,16 @@ namespace SteamCoils { int WhichCoil; // Obtains and Allocates SteamCoil related parameters from input file - if (GetSteamCoilsInputFlag) { // First time subroutine has been entered + if (state.dataSteamCoils->GetSteamCoilsInputFlag) { // First time subroutine has been entered GetSteamCoilInput(state); - GetSteamCoilsInputFlag = false; + state.dataSteamCoils->GetSteamCoilsInputFlag = false; } if (UtilityRoutines::SameString(CoilType, "Coil:Heating:Steam")) { - WhichCoil = UtilityRoutines::FindItem(CoilName, SteamCoil); + WhichCoil = UtilityRoutines::FindItem(CoilName, state.dataSteamCoils->SteamCoil); if (WhichCoil != 0) { // coil does not specify MaxWaterFlowRate - Capacity = SteamCoil(WhichCoil).OperatingCapacity; + Capacity = state.dataSteamCoils->SteamCoil(WhichCoil).OperatingCapacity; } } else { WhichCoil = 0; @@ -2166,9 +2034,9 @@ namespace SteamCoils { // 3 = ZoneLoadControl // Obtains and Allocates SteamCoil related parameters from input file - if (GetSteamCoilsInputFlag) { // First time subroutine has been entered + if (state.dataSteamCoils->GetSteamCoilsInputFlag) { // First time subroutine has been entered GetSteamCoilInput(state); - GetSteamCoilsInputFlag = false; + state.dataSteamCoils->GetSteamCoilsInputFlag = false; } if (CoilIndex == 0) { @@ -2176,7 +2044,7 @@ namespace SteamCoils { ErrorsFound = true; TypeOfCoil = 0; } else { - TypeOfCoil = SteamCoil(CoilIndex).TypeOfCoil; + TypeOfCoil = state.dataSteamCoils->SteamCoil(CoilIndex).TypeOfCoil; } return TypeOfCoil; @@ -2207,17 +2075,17 @@ namespace SteamCoils { int WhichCoil; // Obtains and Allocates SteamCoil related parameters from input file - if (GetSteamCoilsInputFlag) { // First time subroutine has been entered + if (state.dataSteamCoils->GetSteamCoilsInputFlag) { // First time subroutine has been entered GetSteamCoilInput(state); - GetSteamCoilsInputFlag = false; + state.dataSteamCoils->GetSteamCoilsInputFlag = false; } WhichCoil = 0; NodeNumber = 0; if (UtilityRoutines::SameString(CoilType, "Coil:Heating:Steam")) { - WhichCoil = UtilityRoutines::FindItem(CoilName, SteamCoil); + WhichCoil = UtilityRoutines::FindItem(CoilName, state.dataSteamCoils->SteamCoil); if (WhichCoil != 0) { - NodeNumber = SteamCoil(WhichCoil).TempSetPointNodeNum; + NodeNumber = state.dataSteamCoils->SteamCoil(WhichCoil).TempSetPointNodeNum; } } else { WhichCoil = 0; @@ -2257,18 +2125,18 @@ namespace SteamCoils { int WhichCoil; // Obtains and Allocates HeatingCoil related parameters from input file - if (GetSteamCoilsInputFlag) { // First time subroutine has been entered + if (state.dataSteamCoils->GetSteamCoilsInputFlag) { // First time subroutine has been entered GetSteamCoilInput(state); - GetSteamCoilsInputFlag = false; + state.dataSteamCoils->GetSteamCoilsInputFlag = false; } WhichCoil = 0; AvailSchIndex = 0; if (UtilityRoutines::SameString(CoilType, "Coil:Heating:Steam")) { - WhichCoil = UtilityRoutines::FindItem(CoilName, SteamCoil); + WhichCoil = UtilityRoutines::FindItem(CoilName, state.dataSteamCoils->SteamCoil); if (WhichCoil != 0) { - AvailSchIndex = SteamCoil(WhichCoil).SchedPtr; + AvailSchIndex = state.dataSteamCoils->SteamCoil(WhichCoil).SchedPtr; } } else { WhichCoil = 0; @@ -2303,24 +2171,24 @@ namespace SteamCoils { // Using/Aliasing using General::TrimSigDigits; - if (GetSteamCoilsInputFlag) { + if (state.dataSteamCoils->GetSteamCoilsInputFlag) { GetSteamCoilInput(state); - GetSteamCoilsInputFlag = false; + state.dataSteamCoils->GetSteamCoilsInputFlag = false; } - if (CoilNum <= 0 || CoilNum > NumSteamCoils) { + if (CoilNum <= 0 || CoilNum > state.dataSteamCoils->NumSteamCoils) { ShowSevereError("SetHeatingCoilData: called with heating coil Number out of range=" + TrimSigDigits(CoilNum) + " should be >0 and <" + - TrimSigDigits(NumSteamCoils)); + TrimSigDigits(state.dataSteamCoils->NumSteamCoils)); ErrorsFound = true; return; } if (present(DesiccantRegenerationCoil)) { - SteamCoil(CoilNum).DesiccantRegenerationCoil = DesiccantRegenerationCoil; + state.dataSteamCoils->SteamCoil(CoilNum).DesiccantRegenerationCoil = DesiccantRegenerationCoil; } if (present(DesiccantDehumIndex)) { - SteamCoil(CoilNum).DesiccantDehumNum = DesiccantDehumIndex; + state.dataSteamCoils->SteamCoil(CoilNum).DesiccantDehumNum = DesiccantDehumIndex; } } // End of Utility subroutines for the SteamCoil Module diff --git a/src/EnergyPlus/SteamCoils.hh b/src/EnergyPlus/SteamCoils.hh index 66f65d2af87..aff757c7e78 100644 --- a/src/EnergyPlus/SteamCoils.hh +++ b/src/EnergyPlus/SteamCoils.hh @@ -63,42 +63,6 @@ struct EnergyPlusData; namespace SteamCoils { - // Using/Aliasing - - // Data - // MODULE PARAMETER DEFINITIONS: - extern int const SteamCoil_AirHeating; - extern int const TemperatureSetPointControl; - extern int const ZoneLoadControl; - - // DERIVED TYPE DEFINITIONS - - // INTERFACE DEFINITIONS - // MODULE VARIABLE DECLARATIONS: - extern int SteamIndex; - extern int NumSteamCoils; // The Number of SteamCoils found in the Input - extern Array1D_bool MySizeFlag; - extern Array1D_bool CoilWarningOnceFlag; - extern Array1D_bool CheckEquipName; - extern bool GetSteamCoilsInputFlag; // Flag set to make sure you get input once - - // Subroutine Specifications for the Module - // Driver/Manager Routines - - // Get Input routines for module - - // Initialization routines for module - - // Algorithms for the module - - // Update routine to check convergence and update nodes - - // Reporting routines for module - - // Utility routines for module - - // Types - struct SteamCoilEquipConditions { // Members @@ -181,11 +145,6 @@ namespace SteamCoils { } }; - // Object Data - extern Array1D SteamCoil; - - // Functions - void SimulateSteamCoilComponents(EnergyPlusData &state, std::string const &CompName, bool const FirstHVACIteration, int &CompIndex, @@ -194,22 +153,12 @@ namespace SteamCoils { Optional_int_const FanOpMode = _, Optional PartLoadRatio = _); - // Get Input Section of the Module - void GetSteamCoilInput(EnergyPlusData &state); - // End of Get Input subroutines for the HB Module - - // Beginning Initialization Section of the Module - void InitSteamCoil(EnergyPlusData &state, int const CoilNum, bool const FirstHVACIteration); void SizeSteamCoil(EnergyPlusData &state, int const CoilNum); - // End Initialization Section of the Module - - // Begin Algorithm Section of the Module - void CalcSteamAirCoil(EnergyPlusData &state, int const CoilNum, Real64 const QCoilRequested, // requested coil load @@ -218,19 +167,9 @@ namespace SteamCoils { Real64 const PartLoadRatio // part-load ratio of heating coil ); - // Beginning of Update subroutines for the SteamCoil Module - - void UpdateSteamCoil(int const CoilNum); - - // End of Update subroutines for the SteamCoil Module - - // Beginning of Reporting subroutines for the SteamCoil Module + void UpdateSteamCoil(EnergyPlusData &state, int const CoilNum); - void ReportSteamCoil(int const CoilNum); - - // End of Reporting subroutines for the SteamCoil Module - - // Utility subroutines for the SteamCoil Module + void ReportSteamCoil(EnergyPlusData &state, int const CoilNum); int GetSteamCoilIndex(EnergyPlusData &state, std::string const &CoilType, // must match coil types in this module @@ -325,12 +264,38 @@ namespace SteamCoils { Optional_int DesiccantDehumIndex = _ // Index for the desiccant dehum system where this caoil is used ); - void clear_state(); +} // namespace SteamCoils - // End of Utility subroutines for the SteamCoil Module +struct SteamCoilsData : BaseGlobalStruct { -} // namespace SteamCoils + int const SteamCoil_AirHeating = 2; + int const TemperatureSetPointControl = 1; + int const ZoneLoadControl = 3; + int SteamIndex = 0; + int NumSteamCoils = 0; // The Number of SteamCoils found in the Input + Array1D_bool MySizeFlag; + Array1D_bool CoilWarningOnceFlag; + Array1D_bool CheckEquipName; + bool GetSteamCoilsInputFlag = true; // Flag set to make sure you get input once + bool MyOneTimeFlag = true; // one time initialization flag + + Array1D SteamCoil; + + void clear_state() override + { + NumSteamCoils = 0; + MyOneTimeFlag = true; + GetSteamCoilsInputFlag = true; + SteamCoil.deallocate(); + MySizeFlag.deallocate(); + CoilWarningOnceFlag.deallocate(); + CheckEquipName.deallocate(); + } + + // Default Constructor + SteamCoilsData() = default; +}; } // namespace EnergyPlus #endif diff --git a/src/EnergyPlus/ThermalComfort.cc b/src/EnergyPlus/ThermalComfort.cc index 7f5f69ecc57..c0066093f00 100644 --- a/src/EnergyPlus/ThermalComfort.cc +++ b/src/EnergyPlus/ThermalComfort.cc @@ -2155,6 +2155,22 @@ namespace ThermalComfort { } } + void ResetThermalComfortSimpleASH55(EnergyPlusData &state) + { + // Jason Glazer - October 2015 + // Reset thermal comfort table gathering arrays to zero for multi-year simulations + // so that only last year is reported in tabular reports + int iZone; + for (iZone = 1; iZone <= NumOfZones; ++iZone) { + state.dataThermalComforts->ThermalComfortInASH55(iZone).totalTimeNotWinter = 0.0; + state.dataThermalComforts->ThermalComfortInASH55(iZone).totalTimeNotSummer = 0.0; + state.dataThermalComforts->ThermalComfortInASH55(iZone).totalTimeNotEither = 0.0; + } + state.dataThermalComforts->TotalAnyZoneTimeNotSimpleASH55Winter = 0.0; + state.dataThermalComforts->TotalAnyZoneTimeNotSimpleASH55Summer = 0.0; + state.dataThermalComforts->TotalAnyZoneTimeNotSimpleASH55Either = 0.0; + } + void CalcIfSetPointMet(EnergyPlusData &state) { // SUBROUTINE INFORMATION: @@ -2320,6 +2336,25 @@ namespace ThermalComfort { } } + void ResetSetPointMet(EnergyPlusData &state) + { + // Jason Glazer - October 2015 + // Reset set point not met table gathering arrays to zero for multi-year simulations + // so that only last year is reported in tabular reports + int iZone; + for (iZone = 1; iZone <= NumOfZones; ++iZone) { + state.dataThermalComforts->ThermalComfortSetPoint(iZone).totalNotMetHeating = 0.0; + state.dataThermalComforts->ThermalComfortSetPoint(iZone).totalNotMetCooling = 0.0; + state.dataThermalComforts->ThermalComfortSetPoint(iZone).totalNotMetHeatingOccupied = 0.0; + state.dataThermalComforts->ThermalComfortSetPoint(iZone).totalNotMetCoolingOccupied = 0.0; + } + state.dataThermalComforts->TotalAnyZoneNotMetHeating = 0.0; + state.dataThermalComforts->TotalAnyZoneNotMetCooling = 0.0; + state.dataThermalComforts->TotalAnyZoneNotMetHeatingOccupied = 0.0; + state.dataThermalComforts->TotalAnyZoneNotMetCoolingOccupied = 0.0; + state.dataThermalComforts->TotalAnyZoneNotMetOccupied = 0.0; + } + void CalcThermalComfortAdaptiveASH55( EnergyPlusData &state, bool const initiate, // true if supposed to initiate diff --git a/src/EnergyPlus/ThermalComfort.hh b/src/EnergyPlus/ThermalComfort.hh index 28b9fdd8750..d4d42e6eb4c 100644 --- a/src/EnergyPlus/ThermalComfort.hh +++ b/src/EnergyPlus/ThermalComfort.hh @@ -196,8 +196,12 @@ namespace ThermalComfort { void CalcThermalComfortSimpleASH55(EnergyPlusData &state); + void ResetThermalComfortSimpleASH55(EnergyPlusData &state); + void CalcIfSetPointMet(EnergyPlusData &state); + void ResetSetPointMet(EnergyPlusData &state); + void CalcThermalComfortAdaptiveASH55( EnergyPlusData &state, bool const initiate, // true if supposed to initiate diff --git a/tst/EnergyPlus/unit/HVACVariableRefrigerantFlow.unit.cc b/tst/EnergyPlus/unit/HVACVariableRefrigerantFlow.unit.cc index 0f2563c56b2..e8df3b26b43 100644 --- a/tst/EnergyPlus/unit/HVACVariableRefrigerantFlow.unit.cc +++ b/tst/EnergyPlus/unit/HVACVariableRefrigerantFlow.unit.cc @@ -8164,32 +8164,32 @@ TEST_F(EnergyPlusFixture, VRFTU_CalcVRFSupplementalHeatingCoilSteam) int CoilNum(1); DataLoopNode::Node.allocate(4); - SteamCoils::NumSteamCoils = 1; - SteamCoils::SteamCoil.allocate(SteamCoils::NumSteamCoils); - SteamCoils::SteamCoil(CoilNum).Name = thisVRFTU.SuppHeatCoilName; - SteamCoils::SteamCoil(CoilNum).SteamCoilType_Num = SteamCoils::SteamCoil_AirHeating; - SteamCoils::SteamCoil(CoilNum).LoopNum = 1; - SteamCoils::SteamCoil(CoilNum).SteamCoilTypeA = "Heating"; - SteamCoils::SteamCoil(CoilNum).SchedPtr = DataGlobals::ScheduleAlwaysOn; - SteamCoils::SteamCoil(CoilNum).InletSteamTemp = 100.0; - SteamCoils::SteamCoil(CoilNum).InletSteamPress = 101325.0; - SteamCoils::SteamCoil(CoilNum).DegOfSubcooling = 0.0; - - SteamCoils::SteamCoil(CoilNum).AirInletNodeNum = thisVRFTU.SuppHeatCoilAirInletNode; - SteamCoils::SteamCoil(CoilNum).AirOutletNodeNum = thisVRFTU.SuppHeatCoilAirOutletNode; - SteamCoils::SteamCoil(CoilNum).SteamInletNodeNum = thisVRFTU.SuppHeatCoilFluidInletNode; - SteamCoils::SteamCoil(CoilNum).SteamOutletNodeNum = thisVRFTU.SuppHeatCoilFluidOutletNode; - SteamCoils::SteamCoil(CoilNum).MaxSteamVolFlowRate = 0.015; - SteamCoils::SteamCoil(CoilNum).LoopNum = 1; - SteamCoils::SteamCoil(CoilNum).LoopSide = 1; - SteamCoils::SteamCoil(CoilNum).BranchNum = 1; - SteamCoils::SteamCoil(CoilNum).CompNum = 1; - SteamCoils::SteamCoil(CoilNum).Coil_PlantTypeNum = DataPlant::TypeOf_CoilSteamAirHeating; - SteamCoils::SteamCoil(CoilNum).TypeOfCoil = SteamCoils::ZoneLoadControl; - SteamCoils::GetSteamCoilsInputFlag = false; - SteamCoils::CheckEquipName.dimension(SteamCoils::NumSteamCoils, true); - SteamCoils::MySizeFlag.allocate(CoilNum); - SteamCoils::MySizeFlag(CoilNum) = true; + state.dataSteamCoils->NumSteamCoils = 1; + state.dataSteamCoils->SteamCoil.allocate(state.dataSteamCoils->NumSteamCoils); + state.dataSteamCoils->SteamCoil(CoilNum).Name = thisVRFTU.SuppHeatCoilName; + state.dataSteamCoils->SteamCoil(CoilNum).SteamCoilType_Num = state.dataSteamCoils->SteamCoil_AirHeating; + state.dataSteamCoils->SteamCoil(CoilNum).LoopNum = 1; + state.dataSteamCoils->SteamCoil(CoilNum).SteamCoilTypeA = "Heating"; + state.dataSteamCoils->SteamCoil(CoilNum).SchedPtr = DataGlobals::ScheduleAlwaysOn; + state.dataSteamCoils->SteamCoil(CoilNum).InletSteamTemp = 100.0; + state.dataSteamCoils->SteamCoil(CoilNum).InletSteamPress = 101325.0; + state.dataSteamCoils->SteamCoil(CoilNum).DegOfSubcooling = 0.0; + + state.dataSteamCoils->SteamCoil(CoilNum).AirInletNodeNum = thisVRFTU.SuppHeatCoilAirInletNode; + state.dataSteamCoils->SteamCoil(CoilNum).AirOutletNodeNum = thisVRFTU.SuppHeatCoilAirOutletNode; + state.dataSteamCoils->SteamCoil(CoilNum).SteamInletNodeNum = thisVRFTU.SuppHeatCoilFluidInletNode; + state.dataSteamCoils->SteamCoil(CoilNum).SteamOutletNodeNum = thisVRFTU.SuppHeatCoilFluidOutletNode; + state.dataSteamCoils->SteamCoil(CoilNum).MaxSteamVolFlowRate = 0.015; + state.dataSteamCoils->SteamCoil(CoilNum).LoopNum = 1; + state.dataSteamCoils->SteamCoil(CoilNum).LoopSide = 1; + state.dataSteamCoils->SteamCoil(CoilNum).BranchNum = 1; + state.dataSteamCoils->SteamCoil(CoilNum).CompNum = 1; + state.dataSteamCoils->SteamCoil(CoilNum).Coil_PlantTypeNum = DataPlant::TypeOf_CoilSteamAirHeating; + state.dataSteamCoils->SteamCoil(CoilNum).TypeOfCoil = state.dataSteamCoils->ZoneLoadControl; + state.dataSteamCoils->GetSteamCoilsInputFlag = false; + state.dataSteamCoils->CheckEquipName.dimension(state.dataSteamCoils->NumSteamCoils, true); + state.dataSteamCoils->MySizeFlag.allocate(CoilNum); + state.dataSteamCoils->MySizeFlag(CoilNum) = true; NumPltSizInput = 1; PlantSizData.allocate(NumPltSizInput); @@ -8210,24 +8210,24 @@ TEST_F(EnergyPlusFixture, VRFTU_CalcVRFSupplementalHeatingCoilSteam) PlantLoop(1).Name = "SteamLoop"; PlantLoop(1).FluidName = "STEAM"; - PlantLoop(1).FluidIndex = SteamCoils::SteamIndex; - PlantLoop(1).LoopSide(1).Branch(1).Comp(1).Name = SteamCoils::SteamCoil(CoilNum).Name; + PlantLoop(1).FluidIndex = state.dataSteamCoils->SteamIndex; + PlantLoop(1).LoopSide(1).Branch(1).Comp(1).Name = state.dataSteamCoils->SteamCoil(CoilNum).Name; PlantLoop(1).LoopSide(1).Branch(1).Comp(1).TypeOf_Num = DataPlant::TypeOf_CoilSteamAirHeating; - PlantLoop(1).LoopSide(1).Branch(1).Comp(1).NodeNumIn = SteamCoils::SteamCoil(CoilNum).SteamInletNodeNum; + PlantLoop(1).LoopSide(1).Branch(1).Comp(1).NodeNumIn = state.dataSteamCoils->SteamCoil(CoilNum).SteamInletNodeNum; SysSizingCalc = true; DataGlobals::BeginEnvrnFlag = true; DataEnvironment::OutDryBulbTemp = 5.0; // init coil inlet condition - DataLoopNode::Node(SteamCoils::SteamCoil(CoilNum).AirInletNodeNum).MassFlowRate = 1.0; - DataLoopNode::Node(SteamCoils::SteamCoil(CoilNum).AirInletNodeNum).Temp = 15.0; - DataLoopNode::Node(SteamCoils::SteamCoil(CoilNum).AirInletNodeNum).HumRat = 0.0070; - DataLoopNode::Node(SteamCoils::SteamCoil(CoilNum).AirInletNodeNum).Enthalpy = - Psychrometrics::PsyHFnTdbW(DataLoopNode::Node(SteamCoils::SteamCoil(CoilNum).AirInletNodeNum).Temp, - DataLoopNode::Node(SteamCoils::SteamCoil(CoilNum).AirInletNodeNum).HumRat); + DataLoopNode::Node(state.dataSteamCoils->SteamCoil(CoilNum).AirInletNodeNum).MassFlowRate = 1.0; + DataLoopNode::Node(state.dataSteamCoils->SteamCoil(CoilNum).AirInletNodeNum).Temp = 15.0; + DataLoopNode::Node(state.dataSteamCoils->SteamCoil(CoilNum).AirInletNodeNum).HumRat = 0.0070; + DataLoopNode::Node(state.dataSteamCoils->SteamCoil(CoilNum).AirInletNodeNum).Enthalpy = + Psychrometrics::PsyHFnTdbW(DataLoopNode::Node(state.dataSteamCoils->SteamCoil(CoilNum).AirInletNodeNum).Temp, + DataLoopNode::Node(state.dataSteamCoils->SteamCoil(CoilNum).AirInletNodeNum).HumRat); - DataLoopNode::Node(SteamCoils::SteamCoil(CoilNum).SteamInletNodeNum).MassFlowRate = thisVRFTU.SuppHeatCoilFluidMaxFlow; - DataLoopNode::Node(SteamCoils::SteamCoil(CoilNum).SteamInletNodeNum).MassFlowRateMax = thisVRFTU.SuppHeatCoilFluidMaxFlow; + DataLoopNode::Node(state.dataSteamCoils->SteamCoil(CoilNum).SteamInletNodeNum).MassFlowRate = thisVRFTU.SuppHeatCoilFluidMaxFlow; + DataLoopNode::Node(state.dataSteamCoils->SteamCoil(CoilNum).SteamInletNodeNum).MassFlowRateMax = thisVRFTU.SuppHeatCoilFluidMaxFlow; bool FirstHVACIteration(true); Real64 SuppHeatCoilLoad = 20000.0; @@ -8235,15 +8235,15 @@ TEST_F(EnergyPlusFixture, VRFTU_CalcVRFSupplementalHeatingCoilSteam) thisVRFTU.CalcVRFSuppHeatingCoil(state, VRFTUNum, FirstHVACIteration, thisVRFTU.SuppHeatPartLoadRatio, SuppHeatCoilLoad); // check heating load delivered EXPECT_DOUBLE_EQ(20000.0, SuppHeatCoilLoad); - EXPECT_DOUBLE_EQ(20000.0, SteamCoils::SteamCoil(CoilNum).TotSteamHeatingCoilRate); - EXPECT_DOUBLE_EQ(20311.199999999997, SteamCoils::SteamCoil(CoilNum).OperatingCapacity); + EXPECT_DOUBLE_EQ(20000.0, state.dataSteamCoils->SteamCoil(CoilNum).TotSteamHeatingCoilRate); + EXPECT_DOUBLE_EQ(20311.199999999997, state.dataSteamCoils->SteamCoil(CoilNum).OperatingCapacity); // testing heating load larger than available capacity SuppHeatCoilLoad = 24000.0; thisVRFTU.CalcVRFSuppHeatingCoil(state, VRFTUNum, FirstHVACIteration, thisVRFTU.SuppHeatPartLoadRatio, SuppHeatCoilLoad); // delivered heating load can not exceed available operating capacity - EXPECT_DOUBLE_EQ(SteamCoils::SteamCoil(CoilNum).OperatingCapacity, SuppHeatCoilLoad); - EXPECT_DOUBLE_EQ(SteamCoils::SteamCoil(CoilNum).OperatingCapacity, SteamCoils::SteamCoil(CoilNum).TotSteamHeatingCoilRate); + EXPECT_DOUBLE_EQ(state.dataSteamCoils->SteamCoil(CoilNum).OperatingCapacity, SuppHeatCoilLoad); + EXPECT_DOUBLE_EQ(state.dataSteamCoils->SteamCoil(CoilNum).OperatingCapacity, state.dataSteamCoils->SteamCoil(CoilNum).TotSteamHeatingCoilRate); } TEST_F(EnergyPlusFixture, VRFTU_SupplementalHeatingCoilCapacityLimitTest) diff --git a/tst/EnergyPlus/unit/OutdoorAirUnit.unit.cc b/tst/EnergyPlus/unit/OutdoorAirUnit.unit.cc index 50547bd214c..5d0058be65a 100644 --- a/tst/EnergyPlus/unit/OutdoorAirUnit.unit.cc +++ b/tst/EnergyPlus/unit/OutdoorAirUnit.unit.cc @@ -901,18 +901,18 @@ TEST_F(EnergyPlusFixture, OutdoorAirUnit_SteamHeatingCoilAutoSizeTest) loopsidebranch.Comp.allocate(1); } - SteamCoil(1).LoopNum = 1; - SteamCoil(1).LoopSide = 1; - SteamCoil(1).BranchNum = 1; - SteamCoil(1).CompNum = 1; + state.dataSteamCoils->SteamCoil(1).LoopNum = 1; + state.dataSteamCoils->SteamCoil(1).LoopSide = 1; + state.dataSteamCoils->SteamCoil(1).BranchNum = 1; + state.dataSteamCoils->SteamCoil(1).CompNum = 1; PlantLoop(1).Name = "SteamLoop"; PlantLoop(1).FluidIndex = 0; PlantLoop(1).FluidName = "STEAM"; - PlantLoop(1).LoopSide(1).Branch(1).Comp(1).Name = SteamCoil(1).Name; + PlantLoop(1).LoopSide(1).Branch(1).Comp(1).Name = state.dataSteamCoils->SteamCoil(1).Name; PlantLoop(1).LoopSide(1).Branch(1).Comp(1).TypeOf_Num = TypeOf_CoilSteamAirHeating; - PlantLoop(1).LoopSide(1).Branch(1).Comp(1).NodeNumIn = SteamCoil(1).SteamInletNodeNum; - PlantLoop(1).LoopSide(1).Branch(1).Comp(1).NodeNumOut = SteamCoil(1).SteamOutletNodeNum; + PlantLoop(1).LoopSide(1).Branch(1).Comp(1).NodeNumIn = state.dataSteamCoils->SteamCoil(1).SteamInletNodeNum; + PlantLoop(1).LoopSide(1).Branch(1).Comp(1).NodeNumOut = state.dataSteamCoils->SteamCoil(1).SteamOutletNodeNum; PlantSizData(1).PlantLoopName = "SteamLoop"; PlantSizData(1).ExitTemp = 100.0; @@ -964,7 +964,7 @@ TEST_F(EnergyPlusFixture, OutdoorAirUnit_SteamHeatingCoilAutoSizeTest) int ZoneNum(1); InitOutdoorAirUnit(state, OAUnitNum, ZoneNum, FirstHVACIteration); - EXPECT_EQ(SteamCoil(1).MaxSteamVolFlowRate, OutAirUnit(OAUnitNum).OAEquip(1).MaxVolWaterFlow); + EXPECT_EQ(state.dataSteamCoils->SteamCoil(1).MaxSteamVolFlowRate, OutAirUnit(OAUnitNum).OAEquip(1).MaxVolWaterFlow); Real64 DesCoilInTemp = FinalZoneSizing(CurZoneEqNum).DesHeatCoilInTemp; Real64 DesCoilOutTemp = FinalZoneSizing(CurZoneEqNum).HeatDesTemp; @@ -975,15 +975,15 @@ TEST_F(EnergyPlusFixture, OutdoorAirUnit_SteamHeatingCoilAutoSizeTest) Real64 DesSteamCoilLoad = DesAirMassFlow * CpAirAvg * (DesCoilOutTemp - DesCoilInTemp); // do steam flow rate sizing calculation - Real64 EnthSteamIn = GetSatEnthalpyRefrig(state, "STEAM", DataGlobalConstants::SteamInitConvTemp(), 1.0, SteamCoil(1).FluidIndex, ""); - Real64 EnthSteamOut = GetSatEnthalpyRefrig(state, "STEAM", DataGlobalConstants::SteamInitConvTemp(), 0.0, SteamCoil(1).FluidIndex, ""); - Real64 SteamDensity = GetSatDensityRefrig(state, "STEAM", DataGlobalConstants::SteamInitConvTemp(), 1.0, SteamCoil(1).FluidIndex, ""); - Real64 CpOfCondensate = GetSatSpecificHeatRefrig(state, "STEAM", DataGlobalConstants::SteamInitConvTemp(), 0.0, SteamCoil(1).FluidIndex, ""); + Real64 EnthSteamIn = GetSatEnthalpyRefrig(state, "STEAM", DataGlobalConstants::SteamInitConvTemp(), 1.0, state.dataSteamCoils->SteamCoil(1).FluidIndex, ""); + Real64 EnthSteamOut = GetSatEnthalpyRefrig(state, "STEAM", DataGlobalConstants::SteamInitConvTemp(), 0.0, state.dataSteamCoils->SteamCoil(1).FluidIndex, ""); + Real64 SteamDensity = GetSatDensityRefrig(state, "STEAM", DataGlobalConstants::SteamInitConvTemp(), 1.0, state.dataSteamCoils->SteamCoil(1).FluidIndex, ""); + Real64 CpOfCondensate = GetSatSpecificHeatRefrig(state, "STEAM", DataGlobalConstants::SteamInitConvTemp(), 0.0, state.dataSteamCoils->SteamCoil(1).FluidIndex, ""); Real64 LatentHeatChange = EnthSteamIn - EnthSteamOut; - Real64 DesMaxSteamVolFlowRate = DesSteamCoilLoad / (SteamDensity * (LatentHeatChange + SteamCoil(1).DegOfSubcooling * CpOfCondensate)); + Real64 DesMaxSteamVolFlowRate = DesSteamCoilLoad / (SteamDensity * (LatentHeatChange + state.dataSteamCoils->SteamCoil(1).DegOfSubcooling * CpOfCondensate)); // check water coil water flow rate calc - EXPECT_EQ(DesSteamCoilLoad, SteamCoil(1).DesCoilCapacity); - EXPECT_EQ(DesMaxSteamVolFlowRate, SteamCoil(1).MaxSteamVolFlowRate); + EXPECT_EQ(DesSteamCoilLoad, state.dataSteamCoils->SteamCoil(1).DesCoilCapacity); + EXPECT_EQ(DesMaxSteamVolFlowRate, state.dataSteamCoils->SteamCoil(1).MaxSteamVolFlowRate); } } // namespace EnergyPlus diff --git a/tst/EnergyPlus/unit/OutputReportTabular.unit.cc b/tst/EnergyPlus/unit/OutputReportTabular.unit.cc index bff7296e882..cd453b45c94 100644 --- a/tst/EnergyPlus/unit/OutputReportTabular.unit.cc +++ b/tst/EnergyPlus/unit/OutputReportTabular.unit.cc @@ -8302,7 +8302,7 @@ TEST_F(EnergyPlusFixture, OutputReportTabularTest_ConfirmConversionFactors) TEST_F(EnergyPlusFixture, OutputReportTabular_GatherHeatGainReport) { - EnergyPlus::OutputReportTabular::clear_state(); + EnergyPlus::OutputReportTabular::clear_state(state); EnergyPlus::DataGlobals::DoWeathSim = true; EnergyPlus::OutputReportPredefined::pdrSensibleGain = 1; From 623a8acec703b130ec5d1d63fccac0c293768a74 Mon Sep 17 00:00:00 2001 From: brianlball Date: Fri, 16 Oct 2020 17:39:42 -0600 Subject: [PATCH 2/8] convert SteamBaseboard --- src/EnergyPlus/Data/CommonIncludes.hh | 1 + src/EnergyPlus/Data/EnergyPlusData.cc | 2 + src/EnergyPlus/Data/EnergyPlusData.hh | 2 + src/EnergyPlus/HeatBalanceSurfaceManager.cc | 60 +- src/EnergyPlus/SteamBaseboardRadiator.cc | 846 +++++++++----------- src/EnergyPlus/SteamBaseboardRadiator.hh | 94 ++- 6 files changed, 417 insertions(+), 588 deletions(-) diff --git a/src/EnergyPlus/Data/CommonIncludes.hh b/src/EnergyPlus/Data/CommonIncludes.hh index 745f2cbe5b5..724dd2e1ba4 100644 --- a/src/EnergyPlus/Data/CommonIncludes.hh +++ b/src/EnergyPlus/Data/CommonIncludes.hh @@ -82,6 +82,7 @@ #include #include #include +#include #include #include #include diff --git a/src/EnergyPlus/Data/EnergyPlusData.cc b/src/EnergyPlus/Data/EnergyPlusData.cc index f4d05549820..930bd3e1abe 100644 --- a/src/EnergyPlus/Data/EnergyPlusData.cc +++ b/src/EnergyPlus/Data/EnergyPlusData.cc @@ -84,6 +84,7 @@ namespace EnergyPlus { this->dataGlobal = std::unique_ptr(new DataGlobal); this->dataPipes = std::unique_ptr(new PipesData); this->dataPlantChillers = std::unique_ptr(new PlantChillersData); + this->dataSteamBaseboardRadiator = std::unique_ptr(new SteamBaseboardRadiatorData); this->dataSteamCoils = std::unique_ptr(new SteamCoilsData); this->dataSurfaceGroundHeatExchangers = std::unique_ptr(new SurfaceGroundHeatExchangersData); this->dataSwimmingPools = std::unique_ptr(new SwimmingPoolsData); @@ -147,6 +148,7 @@ namespace EnergyPlus { this->dataGlobal->clear_state(); this->dataPipes->clear_state(); this->dataPlantChillers->clear_state(); + this->dataSteamBaseboardRadiator->clear_state(); this->dataSteamCoils->clear_state(); this->dataSurfaceGroundHeatExchangers->clear_state(); this->dataSwimmingPools->clear_state(); diff --git a/src/EnergyPlus/Data/EnergyPlusData.hh b/src/EnergyPlus/Data/EnergyPlusData.hh index 8b884f06d59..016f2763c37 100644 --- a/src/EnergyPlus/Data/EnergyPlusData.hh +++ b/src/EnergyPlus/Data/EnergyPlusData.hh @@ -93,6 +93,7 @@ struct ExteriorEnergyUseData; struct FansData; struct PipesData; struct PlantChillersData; +struct SteamBaseboardRadiatorData; struct SteamCoilsData; struct SurfaceGroundHeatExchangersData; struct SwimmingPoolsData; @@ -159,6 +160,7 @@ struct EnergyPlusData : BaseGlobalStruct { std::unique_ptr dataFans; std::unique_ptr dataPipes; std::unique_ptr dataPlantChillers; + std::unique_ptr dataSteamBaseboardRadiator; std::unique_ptr dataSteamCoils; std::unique_ptr dataSurfaceGroundHeatExchangers; std::unique_ptr dataSwimmingPools; diff --git a/src/EnergyPlus/HeatBalanceSurfaceManager.cc b/src/EnergyPlus/HeatBalanceSurfaceManager.cc index 660520b2952..9d6d911d036 100644 --- a/src/EnergyPlus/HeatBalanceSurfaceManager.cc +++ b/src/EnergyPlus/HeatBalanceSurfaceManager.cc @@ -4702,10 +4702,6 @@ namespace HeatBalanceSurfaceManager { // radiant algorithm module. Finally, using this source value, redo // the inside and outside heat balances. - // REFERENCES: - // na - - // Using/Aliasing using CoolingPanelSimple::UpdateCoolingPanelSourceValAvg; using ElectricBaseboardRadiator::UpdateBBElecRadSourceValAvg; using HighTempRadiantSystem::UpdateHTRadSourceValAvg; @@ -4714,20 +4710,6 @@ namespace HeatBalanceSurfaceManager { using SteamBaseboardRadiator::UpdateBBSteamRadSourceValAvg; using SwimmingPool::UpdatePoolSourceValAvg; - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - // na - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS: - // na - - // DERIVED TYPE DEFINITIONS: - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: bool LowTempRadSysOn; // .TRUE. if a low temperature radiant system is running bool HighTempRadSysOn; // .TRUE. if a high temperature radiant system is running bool HWBaseboardSysOn; // .TRUE. if a water baseboard heater is running @@ -4740,7 +4722,7 @@ namespace HeatBalanceSurfaceManager { UpdateRadSysSourceValAvg(LowTempRadSysOn); UpdateHTRadSourceValAvg(HighTempRadSysOn); UpdateBBRadSourceValAvg(HWBaseboardSysOn); - UpdateBBSteamRadSourceValAvg(SteamBaseboardSysOn); + UpdateBBSteamRadSourceValAvg(state, SteamBaseboardSysOn); UpdateBBElecRadSourceValAvg(ElecBaseboardSysOn); UpdateCoolingPanelSourceValAvg(state, CoolingPanelSysOn); UpdatePoolSourceValAvg(state, SwimmingPoolOn); @@ -4779,20 +4761,6 @@ namespace HeatBalanceSurfaceManager { // Mechanical Systems in Heat Balance Based Energy Analysis Programs // on System Response and Control, Building Simulation '91, IBPSA, Nice, France. - // USE STATEMENTS: - // na - - // Locals - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS: - // na - - // DERIVED TYPE DEFINITIONS: - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int HistTermNum; // DO loop counter for history terms int SideNum; // DO loop counter for surfaces sides (inside, outside) int SurfNum; // Surface number DO loop counter @@ -4805,9 +4773,6 @@ namespace HeatBalanceSurfaceManager { static Array1D Tsrc1; // Temperature at source/sink (during first time step/series) static Array1D Tuser1; // Temperature at the user specified location (during first time step/series) static Array1D SumTime; // Amount of time that has elapsed from start of master history to - // the current time step - - // FLOW: // Tuned Assure safe to use shared linear indexing below assert(equal_dimensions(TH, THM)); @@ -5095,29 +5060,6 @@ namespace HeatBalanceSurfaceManager { // Calculates the current zone MRT for thermal comfort and radiation // calculation purposes. - // METHODOLOGY EMPLOYED: - // If you have to ask... - - // REFERENCES: - // na - - // USE STATEMENTS: - // na - - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS: - // na - - // DERIVED TYPE DEFINITIONS: - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - Real64 SumAET; // Intermediate calculational variable (area*emissivity*T) sum static Array1D SurfaceAE; // Product of area and emissivity for each surface int SurfNum; // Surface number diff --git a/src/EnergyPlus/SteamBaseboardRadiator.cc b/src/EnergyPlus/SteamBaseboardRadiator.cc index 2bdc2840951..a45f173a9fe 100644 --- a/src/EnergyPlus/SteamBaseboardRadiator.cc +++ b/src/EnergyPlus/SteamBaseboardRadiator.cc @@ -106,12 +106,6 @@ namespace SteamBaseboardRadiator { // 1. HWBaseboardRadiator module (ZoneHVAC:Baseboard:RadiantConvective:Water) // 2. SteamCoils module (Coil:Heating:Steam) - // OTHER NOTES: - // na - - // USE STATEMENTS: - // Use statements for data only modules - // Using/Aliasing using namespace DataGlobals; using DataHVACGlobals::SmallLoad; using DataHVACGlobals::SysTimeElapsed; @@ -131,58 +125,8 @@ namespace SteamBaseboardRadiator { using Psychrometrics::PsyCpAirFnW; using Psychrometrics::PsyRhoAirFnPbTdbW; - // Data - // MODULE PARAMETER DEFINITIONS - std::string const cCMO_BBRadiator_Steam("ZoneHVAC:Baseboard:RadiantConvective:Steam"); static std::string const fluidNameSteam("STEAM"); - // DERIVED TYPE DEFINITIONS - - // MODULE VARIABLE DECLARATIONS: - int NumSteamBaseboards(0); - int SteamIndex(0); - - Array1D QBBSteamRadSource; // Need to keep the last value in case we are still iterating - Array1D QBBSteamRadSrcAvg; // Need to keep the last value in case we are still iterating - Array1D ZeroSourceSumHATsurf; // Equal to the SumHATsurf for all the walls in a zone - // with no source - - // Record keeping variables used to calculate QBBRadSrcAvg locally - Array1D LastQBBSteamRadSrc; // Need to keep the last value in case we are still iterating - Array1D LastSysTimeElapsed; // Need to keep the last value in case we are still iterating - Array1D LastTimeStepSys; // Need to keep the last value in case we are still iterating - Array1D_bool MySizeFlag; - Array1D_bool CheckEquipName; - Array1D_bool SetLoopIndexFlag; // get loop number flag - bool GetInputFlag(true); // one time get input flag - bool MyOneTimeFlag(true); - bool ZoneEquipmentListChecked(false); - - // Object Data - Array1D SteamBaseboard; - Array1D SteamBaseboardNumericFields; - - void clear_state() - { - NumSteamBaseboards = 0; - SteamIndex = 0; - QBBSteamRadSource.clear(); - QBBSteamRadSrcAvg.clear(); - ZeroSourceSumHATsurf.clear(); - LastQBBSteamRadSrc.clear(); - LastSysTimeElapsed.clear(); - LastTimeStepSys.clear(); - MySizeFlag.clear(); - CheckEquipName.clear(); - SetLoopIndexFlag.clear(); - GetInputFlag = true; - MyOneTimeFlag = true; - ZoneEquipmentListChecked = false; - SteamBaseboard.clear(); - SteamBaseboardNumericFields.clear(); - } - // Functions - void SimSteamBaseboard(EnergyPlusData &state, std::string const &EquipName, int const ActualZoneNum, @@ -215,30 +159,30 @@ namespace SteamBaseboardRadiator { Real64 MinSteamFlow; static Real64 mdot(0.0); - if (GetInputFlag) { + if (state.dataSteamBaseboardRadiator->GetInputFlag) { GetSteamBaseboardInput(state); - GetInputFlag = false; + state.dataSteamBaseboardRadiator->GetInputFlag = false; } // Find the correct Baseboard Equipment if (CompIndex == 0) { - BaseboardNum = UtilityRoutines::FindItemInList(EquipName, SteamBaseboard, &SteamBaseboardParams::EquipID); + BaseboardNum = UtilityRoutines::FindItemInList(EquipName, state.dataSteamBaseboardRadiator->SteamBaseboard, &SteamBaseboardParams::EquipID); if (BaseboardNum == 0) { ShowFatalError("SimSteamBaseboard: Unit not found=" + EquipName); } CompIndex = BaseboardNum; } else { BaseboardNum = CompIndex; - if (BaseboardNum > NumSteamBaseboards || BaseboardNum < 1) { + if (BaseboardNum > state.dataSteamBaseboardRadiator->NumSteamBaseboards || BaseboardNum < 1) { ShowFatalError("SimSteamBaseboard: Invalid CompIndex passed=" + TrimSigDigits(BaseboardNum) + - ", Number of Units=" + TrimSigDigits(NumSteamBaseboards) + ", Entered Unit name=" + EquipName); + ", Number of Units=" + TrimSigDigits(state.dataSteamBaseboardRadiator->NumSteamBaseboards) + ", Entered Unit name=" + EquipName); } - if (CheckEquipName(BaseboardNum)) { - if (EquipName != SteamBaseboard(BaseboardNum).EquipID) { + if (state.dataSteamBaseboardRadiator->CheckEquipName(BaseboardNum)) { + if (EquipName != state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).EquipID) { ShowFatalError("SimSteamBaseboard: Invalid CompIndex passed=" + TrimSigDigits(BaseboardNum) + ", Unit name=" + EquipName + - ", stored Unit Name for that index=" + SteamBaseboard(BaseboardNum).EquipID); + ", stored Unit Name for that index=" + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).EquipID); } - CheckEquipName(BaseboardNum) = false; + state.dataSteamBaseboardRadiator->CheckEquipName(BaseboardNum) = false; } } @@ -249,66 +193,66 @@ namespace SteamBaseboardRadiator { QZnReq = ZoneSysEnergyDemand(ActualZoneNum).RemainingOutputReqToHeatSP; if (QZnReq > SmallLoad && !CurDeadBandOrSetback(ActualZoneNum) && - (GetCurrentScheduleValue(SteamBaseboard(BaseboardNum).SchedPtr) > 0.0)) { + (GetCurrentScheduleValue(state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SchedPtr) > 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 if (FirstHVACIteration) { - MaxSteamFlow = SteamBaseboard(BaseboardNum).SteamMassFlowRateMax; + MaxSteamFlow = state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SteamMassFlowRateMax; MinSteamFlow = 0.0; } else { - MaxSteamFlow = Node(SteamBaseboard(BaseboardNum).SteamInletNode).MassFlowRateMaxAvail; - MinSteamFlow = Node(SteamBaseboard(BaseboardNum).SteamInletNode).MassFlowRateMinAvail; + MaxSteamFlow = Node(state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SteamInletNode).MassFlowRateMaxAvail; + MinSteamFlow = Node(state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SteamInletNode).MassFlowRateMinAvail; } { - auto const SELECT_CASE_var(SteamBaseboard(BaseboardNum).EquipType); + auto const SELECT_CASE_var(state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).EquipType); if (SELECT_CASE_var == TypeOf_Baseboard_Rad_Conv_Steam) { // 'ZoneHVAC:Baseboard:RadiantConvective:Steam' ControlCompOutput(state, - SteamBaseboard(BaseboardNum).EquipID, - cCMO_BBRadiator_Steam, + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).EquipID, + state.dataSteamBaseboardRadiator->cCMO_BBRadiator_Steam, BaseboardNum, FirstHVACIteration, QZnReq, - SteamBaseboard(BaseboardNum).SteamInletNode, + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SteamInletNode, MaxSteamFlow, MinSteamFlow, - SteamBaseboard(BaseboardNum).Offset, - SteamBaseboard(BaseboardNum).ControlCompTypeNum, - SteamBaseboard(BaseboardNum).CompErrIndex, + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).Offset, + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).ControlCompTypeNum, + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).CompErrIndex, _, _, _, _, _, - SteamBaseboard(BaseboardNum).LoopNum, - SteamBaseboard(BaseboardNum).LoopSideNum, - SteamBaseboard(BaseboardNum).BranchNum); + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).LoopNum, + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).LoopSideNum, + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).BranchNum); } else { - ShowSevereError("SimSteamBaseboard: Errors in Baseboard=" + SteamBaseboard(BaseboardNum).EquipID); - ShowContinueError("Invalid or unimplemented equipment type=" + TrimSigDigits(SteamBaseboard(BaseboardNum).EquipType)); + ShowSevereError("SimSteamBaseboard: Errors in Baseboard=" + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).EquipID); + ShowContinueError("Invalid or unimplemented equipment type=" + TrimSigDigits(state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).EquipType)); ShowFatalError("Preceding condition causes termination."); } } - PowerMet = SteamBaseboard(BaseboardNum).TotPower; + PowerMet = state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).TotPower; } else { // baseboard is off, don't bother going into ControlCompOutput mdot = 0.0; SetComponentFlowRate(mdot, - SteamBaseboard(BaseboardNum).SteamInletNode, - SteamBaseboard(BaseboardNum).SteamOutletNode, - SteamBaseboard(BaseboardNum).LoopNum, - SteamBaseboard(BaseboardNum).LoopSideNum, - SteamBaseboard(BaseboardNum).BranchNum, - SteamBaseboard(BaseboardNum).CompNum); + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SteamInletNode, + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SteamOutletNode, + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).LoopNum, + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).LoopSideNum, + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).BranchNum, + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).CompNum); CalcSteamBaseboard(state, BaseboardNum, PowerMet); } - UpdateSteamBaseboard(BaseboardNum); + UpdateSteamBaseboard(state, BaseboardNum); - ReportSteamBaseboard(BaseboardNum); + ReportSteamBaseboard(state, BaseboardNum); } else { ShowFatalError("SimSteamBaseboard: Unit not found=" + EquipName); @@ -372,19 +316,19 @@ namespace SteamBaseboardRadiator { bool SteamMessageNeeded; SteamMessageNeeded = true; - NumSteamBaseboards = inputProcessor->getNumObjectsFound(cCMO_BBRadiator_Steam); + state.dataSteamBaseboardRadiator->NumSteamBaseboards = inputProcessor->getNumObjectsFound(state.dataSteamBaseboardRadiator->cCMO_BBRadiator_Steam); // Count total number of baseboard units - SteamBaseboard.allocate(NumSteamBaseboards); - CheckEquipName.dimension(NumSteamBaseboards, true); - SteamBaseboardNumericFields.allocate(NumSteamBaseboards); + state.dataSteamBaseboardRadiator->SteamBaseboard.allocate(state.dataSteamBaseboardRadiator->NumSteamBaseboards); + state.dataSteamBaseboardRadiator->CheckEquipName.dimension(state.dataSteamBaseboardRadiator->NumSteamBaseboards, true); + state.dataSteamBaseboardRadiator->SteamBaseboardNumericFields.allocate(state.dataSteamBaseboardRadiator->NumSteamBaseboards); // Get the data from the user input related to baseboard heaters - for (BaseboardNum = 1; BaseboardNum <= NumSteamBaseboards; ++BaseboardNum) { + for (BaseboardNum = 1; BaseboardNum <= state.dataSteamBaseboardRadiator->NumSteamBaseboards; ++BaseboardNum) { inputProcessor->getObjectItem(state, - cCMO_BBRadiator_Steam, + state.dataSteamBaseboardRadiator->cCMO_BBRadiator_Steam, BaseboardNum, cAlphaArgs, NumAlphas, @@ -395,165 +339,165 @@ namespace SteamBaseboardRadiator { lAlphaFieldBlanks, cAlphaFieldNames, cNumericFieldNames); - UtilityRoutines::IsNameEmpty(cAlphaArgs(1), cCMO_BBRadiator_Steam, ErrorsFound); - SteamBaseboardNumericFields(BaseboardNum).FieldNames.allocate(NumNumbers); - SteamBaseboardNumericFields(BaseboardNum).FieldNames = ""; - SteamBaseboardNumericFields(BaseboardNum).FieldNames = cNumericFieldNames; + UtilityRoutines::IsNameEmpty(cAlphaArgs(1), state.dataSteamBaseboardRadiator->cCMO_BBRadiator_Steam, ErrorsFound); + state.dataSteamBaseboardRadiator->SteamBaseboardNumericFields(BaseboardNum).FieldNames.allocate(NumNumbers); + state.dataSteamBaseboardRadiator->SteamBaseboardNumericFields(BaseboardNum).FieldNames = ""; + state.dataSteamBaseboardRadiator->SteamBaseboardNumericFields(BaseboardNum).FieldNames = cNumericFieldNames; // ErrorsFound will be set to True if problem was found, left untouched otherwise - VerifyUniqueBaseboardName(cCMO_BBRadiator_Steam, cAlphaArgs(1), ErrorsFound, cCMO_BBRadiator_Steam + " Name"); + VerifyUniqueBaseboardName(state.dataSteamBaseboardRadiator->cCMO_BBRadiator_Steam, cAlphaArgs(1), ErrorsFound, state.dataSteamBaseboardRadiator->cCMO_BBRadiator_Steam + " Name"); - SteamBaseboard(BaseboardNum).EquipID = cAlphaArgs(1); // Name of the baseboard - SteamBaseboard(BaseboardNum).EquipType = TypeOf_Baseboard_Rad_Conv_Steam; //'ZoneHVAC:Baseboard:RadiantConvective:Steam' + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).EquipID = cAlphaArgs(1); // Name of the baseboard + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).EquipType = TypeOf_Baseboard_Rad_Conv_Steam; //'ZoneHVAC:Baseboard:RadiantConvective:Steam' // Get schedule - SteamBaseboard(BaseboardNum).Schedule = cAlphaArgs(2); + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).Schedule = cAlphaArgs(2); if (lAlphaFieldBlanks(2)) { - SteamBaseboard(BaseboardNum).SchedPtr = ScheduleAlwaysOn; + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SchedPtr = ScheduleAlwaysOn; } else { - SteamBaseboard(BaseboardNum).SchedPtr = GetScheduleIndex(state, cAlphaArgs(2)); - if (SteamBaseboard(BaseboardNum).SchedPtr == 0) { - ShowSevereError(RoutineName + cCMO_BBRadiator_Steam + "=\"" + cAlphaArgs(1) + "\", " + cAlphaFieldNames(2) + "=\"" + + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SchedPtr = GetScheduleIndex(state, cAlphaArgs(2)); + if (state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SchedPtr == 0) { + ShowSevereError(RoutineName + state.dataSteamBaseboardRadiator->cCMO_BBRadiator_Steam + "=\"" + cAlphaArgs(1) + "\", " + cAlphaFieldNames(2) + "=\"" + cAlphaArgs(2) + "\" not found."); ErrorsFound = true; } } // Get inlet node number - SteamBaseboard(BaseboardNum).SteamInletNode = GetOnlySingleNode(state, - cAlphaArgs(3), ErrorsFound, cCMO_BBRadiator_Steam, cAlphaArgs(1), NodeType_Steam, NodeConnectionType_Inlet, 1, ObjectIsNotParent); + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SteamInletNode = GetOnlySingleNode(state, + cAlphaArgs(3), ErrorsFound, state.dataSteamBaseboardRadiator->cCMO_BBRadiator_Steam, cAlphaArgs(1), NodeType_Steam, NodeConnectionType_Inlet, 1, ObjectIsNotParent); // Get outlet node number - SteamBaseboard(BaseboardNum).SteamOutletNode = GetOnlySingleNode(state, - cAlphaArgs(4), ErrorsFound, cCMO_BBRadiator_Steam, cAlphaArgs(1), NodeType_Steam, NodeConnectionType_Outlet, 1, ObjectIsNotParent); - TestCompSet(cCMO_BBRadiator_Steam, cAlphaArgs(1), cAlphaArgs(3), cAlphaArgs(4), "Hot Steam Nodes"); + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SteamOutletNode = GetOnlySingleNode(state, + cAlphaArgs(4), ErrorsFound, state.dataSteamBaseboardRadiator->cCMO_BBRadiator_Steam, cAlphaArgs(1), NodeType_Steam, NodeConnectionType_Outlet, 1, ObjectIsNotParent); + TestCompSet(state.dataSteamBaseboardRadiator->cCMO_BBRadiator_Steam, cAlphaArgs(1), cAlphaArgs(3), cAlphaArgs(4), "Hot Steam Nodes"); // Determine steam baseboard radiator system heating design capacity sizing method if (UtilityRoutines::SameString(cAlphaArgs(iHeatCAPMAlphaNum), "HeatingDesignCapacity")) { - SteamBaseboard(BaseboardNum).HeatingCapMethod = HeatingDesignCapacity; + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).HeatingCapMethod = HeatingDesignCapacity; if (!lNumericFieldBlanks(iHeatDesignCapacityNumericNum)) { - SteamBaseboard(BaseboardNum).ScaledHeatingCapacity = rNumericArgs(iHeatDesignCapacityNumericNum); - if (SteamBaseboard(BaseboardNum).ScaledHeatingCapacity < 0.0 && SteamBaseboard(BaseboardNum).ScaledHeatingCapacity != AutoSize) { - ShowSevereError(cCMO_BBRadiator_Steam + " = " + SteamBaseboard(BaseboardNum).EquipID); + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).ScaledHeatingCapacity = rNumericArgs(iHeatDesignCapacityNumericNum); + if (state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).ScaledHeatingCapacity < 0.0 && state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).ScaledHeatingCapacity != AutoSize) { + ShowSevereError(state.dataSteamBaseboardRadiator->cCMO_BBRadiator_Steam + " = " + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).EquipID); ShowContinueError("Illegal " + cNumericFieldNames(iHeatDesignCapacityNumericNum) + " = " + TrimSigDigits(rNumericArgs(iHeatDesignCapacityNumericNum), 7)); ErrorsFound = true; } } else { - ShowSevereError(cCMO_BBRadiator_Steam + " = " + SteamBaseboard(BaseboardNum).EquipID); + ShowSevereError(state.dataSteamBaseboardRadiator->cCMO_BBRadiator_Steam + " = " + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).EquipID); ShowContinueError("Input for " + cAlphaFieldNames(iHeatCAPMAlphaNum) + " = " + cAlphaArgs(iHeatCAPMAlphaNum)); ShowContinueError("Blank field not allowed for " + cNumericFieldNames(iHeatDesignCapacityNumericNum)); ErrorsFound = true; } } else if (UtilityRoutines::SameString(cAlphaArgs(iHeatCAPMAlphaNum), "CapacityPerFloorArea")) { - SteamBaseboard(BaseboardNum).HeatingCapMethod = CapacityPerFloorArea; + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).HeatingCapMethod = CapacityPerFloorArea; if (!lNumericFieldBlanks(iHeatCapacityPerFloorAreaNumericNum)) { - SteamBaseboard(BaseboardNum).ScaledHeatingCapacity = rNumericArgs(iHeatCapacityPerFloorAreaNumericNum); - if (SteamBaseboard(BaseboardNum).ScaledHeatingCapacity <= 0.0) { - ShowSevereError(cCMO_BBRadiator_Steam + " = " + SteamBaseboard(BaseboardNum).EquipID); + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).ScaledHeatingCapacity = rNumericArgs(iHeatCapacityPerFloorAreaNumericNum); + if (state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).ScaledHeatingCapacity <= 0.0) { + ShowSevereError(state.dataSteamBaseboardRadiator->cCMO_BBRadiator_Steam + " = " + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).EquipID); ShowContinueError("Input for " + cAlphaFieldNames(iHeatCAPMAlphaNum) + " = " + cAlphaArgs(iHeatCAPMAlphaNum)); ShowContinueError("Illegal " + cNumericFieldNames(iHeatCapacityPerFloorAreaNumericNum) + " = " + TrimSigDigits(rNumericArgs(iHeatCapacityPerFloorAreaNumericNum), 7)); ErrorsFound = true; - } else if (SteamBaseboard(BaseboardNum).ScaledHeatingCapacity == AutoSize) { - ShowSevereError(cCMO_BBRadiator_Steam + " = " + SteamBaseboard(BaseboardNum).EquipID); + } else if (state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).ScaledHeatingCapacity == AutoSize) { + ShowSevereError(state.dataSteamBaseboardRadiator->cCMO_BBRadiator_Steam + " = " + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).EquipID); ShowContinueError("Input for " + cAlphaFieldNames(iHeatCAPMAlphaNum) + " = " + cAlphaArgs(iHeatCAPMAlphaNum)); ShowContinueError("Illegal " + cNumericFieldNames(iHeatCapacityPerFloorAreaNumericNum) + " = Autosize"); ErrorsFound = true; } } else { - ShowSevereError(cCMO_BBRadiator_Steam + " = " + SteamBaseboard(BaseboardNum).EquipID); + ShowSevereError(state.dataSteamBaseboardRadiator->cCMO_BBRadiator_Steam + " = " + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).EquipID); ShowContinueError("Input for " + cAlphaFieldNames(iHeatCAPMAlphaNum) + " = " + cAlphaArgs(iHeatCAPMAlphaNum)); ShowContinueError("Blank field not allowed for " + cNumericFieldNames(iHeatCapacityPerFloorAreaNumericNum)); ErrorsFound = true; } } else if (UtilityRoutines::SameString(cAlphaArgs(iHeatCAPMAlphaNum), "FractionOfAutosizedHeatingCapacity")) { - SteamBaseboard(BaseboardNum).HeatingCapMethod = FractionOfAutosizedHeatingCapacity; + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).HeatingCapMethod = FractionOfAutosizedHeatingCapacity; if (!lNumericFieldBlanks(iHeatFracOfAutosizedCapacityNumericNum)) { - SteamBaseboard(BaseboardNum).ScaledHeatingCapacity = rNumericArgs(iHeatFracOfAutosizedCapacityNumericNum); - if (SteamBaseboard(BaseboardNum).ScaledHeatingCapacity < 0.0) { - ShowSevereError(cCMO_BBRadiator_Steam + " = " + SteamBaseboard(BaseboardNum).EquipID); + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).ScaledHeatingCapacity = rNumericArgs(iHeatFracOfAutosizedCapacityNumericNum); + if (state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).ScaledHeatingCapacity < 0.0) { + ShowSevereError(state.dataSteamBaseboardRadiator->cCMO_BBRadiator_Steam + " = " + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).EquipID); ShowContinueError("Illegal " + cNumericFieldNames(iHeatFracOfAutosizedCapacityNumericNum) + " = " + TrimSigDigits(rNumericArgs(iHeatFracOfAutosizedCapacityNumericNum), 7)); ErrorsFound = true; } } else { - ShowSevereError(cCMO_BBRadiator_Steam + " = " + SteamBaseboard(BaseboardNum).EquipID); + ShowSevereError(state.dataSteamBaseboardRadiator->cCMO_BBRadiator_Steam + " = " + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).EquipID); ShowContinueError("Input for " + cAlphaFieldNames(iHeatCAPMAlphaNum) + " = " + cAlphaArgs(iHeatCAPMAlphaNum)); ShowContinueError("Blank field not allowed for " + cNumericFieldNames(iHeatFracOfAutosizedCapacityNumericNum)); ErrorsFound = true; } } else { - ShowSevereError(cCMO_BBRadiator_Steam + " = " + SteamBaseboard(BaseboardNum).EquipID); + ShowSevereError(state.dataSteamBaseboardRadiator->cCMO_BBRadiator_Steam + " = " + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).EquipID); ShowContinueError("Illegal " + cAlphaFieldNames(iHeatCAPMAlphaNum) + " = " + cAlphaArgs(iHeatCAPMAlphaNum)); ErrorsFound = true; } // Desired degree of cooling - SteamBaseboard(BaseboardNum).DegOfSubcooling = rNumericArgs(4); + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).DegOfSubcooling = rNumericArgs(4); // Maximum steam flow rate - SteamBaseboard(BaseboardNum).SteamVolFlowRateMax = rNumericArgs(5); - if (SteamBaseboard(BaseboardNum).SteamVolFlowRateMax >= MaxSteamFlowRate) { - ShowWarningError(RoutineName + cCMO_BBRadiator_Steam + "=\"" + cAlphaArgs(1) + "\", " + cNumericFieldNames(5) + + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SteamVolFlowRateMax = rNumericArgs(5); + if (state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SteamVolFlowRateMax >= MaxSteamFlowRate) { + ShowWarningError(RoutineName + state.dataSteamBaseboardRadiator->cCMO_BBRadiator_Steam + "=\"" + cAlphaArgs(1) + "\", " + cNumericFieldNames(5) + " was higher than the allowable maximum."); ShowContinueError("...reset to maximum value=[" + RoundSigDigits(MaxSteamFlowRate, 2) + "]."); - SteamBaseboard(BaseboardNum).SteamVolFlowRateMax = MaxSteamFlowRate; - } else if (SteamBaseboard(BaseboardNum).SteamVolFlowRateMax <= MinSteamFlowRate && - SteamBaseboard(BaseboardNum).SteamVolFlowRateMax != AutoSize) { - ShowWarningError(RoutineName + cCMO_BBRadiator_Steam + "=\"" + cAlphaArgs(1) + "\", " + cNumericFieldNames(2) + + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SteamVolFlowRateMax = MaxSteamFlowRate; + } else if (state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SteamVolFlowRateMax <= MinSteamFlowRate && + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SteamVolFlowRateMax != AutoSize) { + ShowWarningError(RoutineName + state.dataSteamBaseboardRadiator->cCMO_BBRadiator_Steam + "=\"" + cAlphaArgs(1) + "\", " + cNumericFieldNames(2) + " was less than the allowable minimum."); ShowContinueError("...reset to minimum value=[" + RoundSigDigits(MinSteamFlowRate, 2) + "]."); - SteamBaseboard(BaseboardNum).SteamVolFlowRateMax = MinSteamFlowRate; + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SteamVolFlowRateMax = MinSteamFlowRate; } - SteamBaseboard(BaseboardNum).Offset = rNumericArgs(6); + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).Offset = rNumericArgs(6); // Set default convergence tolerance - if (SteamBaseboard(BaseboardNum).Offset <= 0.0) { - SteamBaseboard(BaseboardNum).Offset = 0.001; - ShowWarningError(RoutineName + cCMO_BBRadiator_Steam + "=\"" + cAlphaArgs(1) + "\", " + cNumericFieldNames(6) + + if (state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).Offset <= 0.0) { + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).Offset = 0.001; + ShowWarningError(RoutineName + state.dataSteamBaseboardRadiator->cCMO_BBRadiator_Steam + "=\"" + cAlphaArgs(1) + "\", " + cNumericFieldNames(6) + " was less than the allowable minimum."); ShowContinueError("...reset to default value=[0.001]."); } // Fraction of radiant heat out of the total heating rate of the unit - SteamBaseboard(BaseboardNum).FracRadiant = rNumericArgs(7); - if (SteamBaseboard(BaseboardNum).FracRadiant < MinFraction) { - ShowWarningError(RoutineName + cCMO_BBRadiator_Steam + "=\"" + cAlphaArgs(1) + "\", " + cNumericFieldNames(7) + + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).FracRadiant = rNumericArgs(7); + if (state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).FracRadiant < MinFraction) { + ShowWarningError(RoutineName + state.dataSteamBaseboardRadiator->cCMO_BBRadiator_Steam + "=\"" + cAlphaArgs(1) + "\", " + cNumericFieldNames(7) + " was lower than the allowable minimum."); ShowContinueError("...reset to minimum value=[" + RoundSigDigits(MinFraction, 3) + "]."); - SteamBaseboard(BaseboardNum).FracRadiant = MinFraction; - } else if (SteamBaseboard(BaseboardNum).FracRadiant > MaxFraction) { - ShowWarningError(RoutineName + cCMO_BBRadiator_Steam + "=\"" + cAlphaArgs(1) + "\", " + cNumericFieldNames(7) + + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).FracRadiant = MinFraction; + } else if (state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).FracRadiant > MaxFraction) { + ShowWarningError(RoutineName + state.dataSteamBaseboardRadiator->cCMO_BBRadiator_Steam + "=\"" + cAlphaArgs(1) + "\", " + cNumericFieldNames(7) + " was higher than the allowable maximum."); ShowContinueError("...reset to maximum value=[" + RoundSigDigits(MaxFraction, 3) + "]."); - SteamBaseboard(BaseboardNum).FracRadiant = MaxFraction; + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).FracRadiant = MaxFraction; } // Remaining fraction is added to the zone as convective heat transfer - AllFracsSummed = SteamBaseboard(BaseboardNum).FracRadiant; + AllFracsSummed = state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).FracRadiant; if (AllFracsSummed > MaxFraction) { - ShowWarningError(RoutineName + cCMO_BBRadiator_Steam + "=\"" + cAlphaArgs(1) + + ShowWarningError(RoutineName + state.dataSteamBaseboardRadiator->cCMO_BBRadiator_Steam + "=\"" + cAlphaArgs(1) + "\", Fraction Radiant was higher than the allowable maximum."); - SteamBaseboard(BaseboardNum).FracRadiant = MaxFraction; - SteamBaseboard(BaseboardNum).FracConvect = 0.0; + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).FracRadiant = MaxFraction; + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).FracConvect = 0.0; } else { - SteamBaseboard(BaseboardNum).FracConvect = 1.0 - AllFracsSummed; + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).FracConvect = 1.0 - AllFracsSummed; } // Fraction of radiant heat addition to the people within the radiant heating capacity specified by the user - SteamBaseboard(BaseboardNum).FracDistribPerson = rNumericArgs(8); - if (SteamBaseboard(BaseboardNum).FracDistribPerson < MinFraction) { - ShowWarningError(RoutineName + cCMO_BBRadiator_Steam + "=\"" + cAlphaArgs(1) + "\", " + cNumericFieldNames(8) + + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).FracDistribPerson = rNumericArgs(8); + if (state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).FracDistribPerson < MinFraction) { + ShowWarningError(RoutineName + state.dataSteamBaseboardRadiator->cCMO_BBRadiator_Steam + "=\"" + cAlphaArgs(1) + "\", " + cNumericFieldNames(8) + " was lower than the allowable minimum."); ShowContinueError("...reset to minimum value=[" + RoundSigDigits(MinFraction, 3) + "]."); - SteamBaseboard(BaseboardNum).FracDistribPerson = MinFraction; + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).FracDistribPerson = MinFraction; } - if (SteamBaseboard(BaseboardNum).FracDistribPerson > MaxFraction) { - ShowWarningError(RoutineName + cCMO_BBRadiator_Steam + "=\"" + cAlphaArgs(1) + "\", " + cNumericFieldNames(8) + + if (state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).FracDistribPerson > MaxFraction) { + ShowWarningError(RoutineName + state.dataSteamBaseboardRadiator->cCMO_BBRadiator_Steam + "=\"" + cAlphaArgs(1) + "\", " + cNumericFieldNames(8) + " was higher than the allowable maximum."); ShowContinueError("...reset to maximum value=[" + RoundSigDigits(MaxFraction, 3) + "]."); - SteamBaseboard(BaseboardNum).FracDistribPerson = MaxFraction; + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).FracDistribPerson = MaxFraction; } - SteamBaseboard(BaseboardNum).TotSurfToDistrib = NumNumbers - 8; + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).TotSurfToDistrib = NumNumbers - 8; // IF (SteamBaseboard(BaseboardNum)%TotSurfToDistrib > MaxDistribSurfaces) THEN // CALL ShowWarningError(RoutineName//cCMO_BBRadiator_Steam//'="'//TRIM(cAlphaArgs(1))// & // '", the number of surface/radiant fraction groups entered was higher than the allowable maximum.') @@ -561,64 +505,64 @@ namespace SteamBaseboardRadiator { // '] will be processed.') // SteamBaseboard(BaseboardNum)%TotSurfToDistrib = MaxDistribSurfaces // END IF - if ((SteamBaseboard(BaseboardNum).TotSurfToDistrib < MinDistribSurfaces) && (SteamBaseboard(BaseboardNum).FracRadiant > MinFraction)) { - ShowSevereError(RoutineName + cCMO_BBRadiator_Steam + "=\"" + cAlphaArgs(1) + + if ((state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).TotSurfToDistrib < MinDistribSurfaces) && (state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).FracRadiant > MinFraction)) { + ShowSevereError(RoutineName + state.dataSteamBaseboardRadiator->cCMO_BBRadiator_Steam + "=\"" + cAlphaArgs(1) + "\", the number of surface/radiant fraction groups entered was less than the allowable minimum."); ShowContinueError("...the minimum that must be entered=[" + RoundSigDigits(MinDistribSurfaces) + "]."); ErrorsFound = true; - SteamBaseboard(BaseboardNum).TotSurfToDistrib = 0; + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).TotSurfToDistrib = 0; } // Allocate the surfaces and fractions - SteamBaseboard(BaseboardNum).SurfaceName.allocate(SteamBaseboard(BaseboardNum).TotSurfToDistrib); - SteamBaseboard(BaseboardNum).SurfaceName = ""; - SteamBaseboard(BaseboardNum).SurfacePtr.allocate(SteamBaseboard(BaseboardNum).TotSurfToDistrib); - SteamBaseboard(BaseboardNum).SurfacePtr = 0; - SteamBaseboard(BaseboardNum).FracDistribToSurf.allocate(SteamBaseboard(BaseboardNum).TotSurfToDistrib); - SteamBaseboard(BaseboardNum).FracDistribToSurf = 0.0; + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SurfaceName.allocate(state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).TotSurfToDistrib); + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SurfaceName = ""; + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SurfacePtr.allocate(state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).TotSurfToDistrib); + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SurfacePtr = 0; + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).FracDistribToSurf.allocate(state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).TotSurfToDistrib); + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).FracDistribToSurf = 0.0; // search zone equipment list structure for zone index for (int ctrlZone = 1; ctrlZone <= DataGlobals::NumOfZones; ++ctrlZone) { for (int zoneEquipTypeNum = 1; zoneEquipTypeNum <= DataZoneEquipment::ZoneEquipList(ctrlZone).NumOfEquipTypes; ++zoneEquipTypeNum) { if (DataZoneEquipment::ZoneEquipList(ctrlZone).EquipType_Num(zoneEquipTypeNum) == DataZoneEquipment::BBSteam_Num && - DataZoneEquipment::ZoneEquipList(ctrlZone).EquipName(zoneEquipTypeNum) == SteamBaseboard(BaseboardNum).EquipID) { - SteamBaseboard(BaseboardNum).ZonePtr = ctrlZone; + DataZoneEquipment::ZoneEquipList(ctrlZone).EquipName(zoneEquipTypeNum) == state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).EquipID) { + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).ZonePtr = ctrlZone; } } } - if (SteamBaseboard(BaseboardNum).ZonePtr <= 0) { - ShowSevereError(RoutineName + cCMO_BBRadiator_Steam + "=\"" + SteamBaseboard(BaseboardNum).EquipID + + if (state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).ZonePtr <= 0) { + ShowSevereError(RoutineName + state.dataSteamBaseboardRadiator->cCMO_BBRadiator_Steam + "=\"" + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).EquipID + "\" is not on any ZoneHVAC:EquipmentList."); ErrorsFound = true; continue; } - AllFracsSummed = SteamBaseboard(BaseboardNum).FracDistribPerson; - for (SurfNum = 1; SurfNum <= SteamBaseboard(BaseboardNum).TotSurfToDistrib; ++SurfNum) { - SteamBaseboard(BaseboardNum).SurfaceName(SurfNum) = cAlphaArgs(SurfNum + 5); - SteamBaseboard(BaseboardNum).SurfacePtr(SurfNum) = - HeatBalanceIntRadExchange::GetRadiantSystemSurface(cCMO_BBRadiator_Steam, - SteamBaseboard(BaseboardNum).EquipID, - SteamBaseboard(BaseboardNum).ZonePtr, - SteamBaseboard(BaseboardNum).SurfaceName(SurfNum), + AllFracsSummed = state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).FracDistribPerson; + for (SurfNum = 1; SurfNum <= state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).TotSurfToDistrib; ++SurfNum) { + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SurfaceName(SurfNum) = cAlphaArgs(SurfNum + 5); + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SurfacePtr(SurfNum) = + HeatBalanceIntRadExchange::GetRadiantSystemSurface(state.dataSteamBaseboardRadiator->cCMO_BBRadiator_Steam, + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).EquipID, + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).ZonePtr, + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SurfaceName(SurfNum), ErrorsFound); - SteamBaseboard(BaseboardNum).FracDistribToSurf(SurfNum) = rNumericArgs(SurfNum + 8); - if (SteamBaseboard(BaseboardNum).FracDistribToSurf(SurfNum) > MaxFraction) { - ShowWarningError(RoutineName + cCMO_BBRadiator_Steam + "=\"" + cAlphaArgs(1) + "\", " + cNumericFieldNames(SurfNum + 8) + + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).FracDistribToSurf(SurfNum) = rNumericArgs(SurfNum + 8); + if (state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).FracDistribToSurf(SurfNum) > MaxFraction) { + ShowWarningError(RoutineName + state.dataSteamBaseboardRadiator->cCMO_BBRadiator_Steam + "=\"" + cAlphaArgs(1) + "\", " + cNumericFieldNames(SurfNum + 8) + "was greater than the allowable maximum."); ShowContinueError("...reset to maximum value=[" + RoundSigDigits(MaxFraction, 1) + "]."); - SteamBaseboard(BaseboardNum).TotSurfToDistrib = MaxFraction; + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).TotSurfToDistrib = MaxFraction; } - if (SteamBaseboard(BaseboardNum).FracDistribToSurf(SurfNum) < MinFraction) { - ShowWarningError(RoutineName + cCMO_BBRadiator_Steam + "=\"" + cAlphaArgs(1) + "\", " + cNumericFieldNames(SurfNum + 8) + + if (state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).FracDistribToSurf(SurfNum) < MinFraction) { + ShowWarningError(RoutineName + state.dataSteamBaseboardRadiator->cCMO_BBRadiator_Steam + "=\"" + cAlphaArgs(1) + "\", " + cNumericFieldNames(SurfNum + 8) + "was less than the allowable minimum."); ShowContinueError("...reset to maximum value=[" + RoundSigDigits(MinFraction, 1) + "]."); - SteamBaseboard(BaseboardNum).TotSurfToDistrib = MinFraction; + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).TotSurfToDistrib = MinFraction; } - if (SteamBaseboard(BaseboardNum).SurfacePtr(SurfNum) != 0) { - Surface(SteamBaseboard(BaseboardNum).SurfacePtr(SurfNum)).IntConvSurfGetsRadiantHeat = true; + if (state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SurfacePtr(SurfNum) != 0) { + Surface(state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SurfacePtr(SurfNum)).IntConvSurfGetsRadiantHeat = true; } - AllFracsSummed += SteamBaseboard(BaseboardNum).FracDistribToSurf(SurfNum); + AllFracsSummed += state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).FracDistribToSurf(SurfNum); } // surfaces if (AllFracsSummed > (MaxFraction + 0.01)) { @@ -627,16 +571,16 @@ namespace SteamBaseboardRadiator { ErrorsFound = true; } if ((AllFracsSummed < (MaxFraction - 0.01)) && - (SteamBaseboard(BaseboardNum).FracRadiant > + (state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).FracRadiant > MinFraction)) { // User didn't distribute all of the | radiation warn that some will be lost - ShowWarningError(RoutineName + cCMO_BBRadiator_Steam + "=\"" + cAlphaArgs(1) + + ShowWarningError(RoutineName + state.dataSteamBaseboardRadiator->cCMO_BBRadiator_Steam + "=\"" + cAlphaArgs(1) + "\", Summed radiant fractions for people + surface groups < 1.0"); ShowContinueError("The rest of the radiant energy delivered by the baseboard heater will be lost"); } - if (SteamIndex == 0 && BaseboardNum == 1) { - SteamIndex = FindRefrigerant(state, "Steam"); - if (SteamIndex == 0) { + if (state.dataSteamBaseboardRadiator->SteamIndex == 0 && BaseboardNum == 1) { + state.dataSteamBaseboardRadiator->SteamIndex = FindRefrigerant(state, "Steam"); + if (state.dataSteamBaseboardRadiator->SteamIndex == 0) { ShowSevereError(RoutineName + "Steam Properties for " + cAlphaArgs(1) + " not found."); if (SteamMessageNeeded) ShowContinueError("Steam Fluid Properties should have been included in the input file."); ErrorsFound = true; @@ -644,41 +588,41 @@ namespace SteamBaseboardRadiator { } } - SteamBaseboard(BaseboardNum).FluidIndex = SteamIndex; + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).FluidIndex = state.dataSteamBaseboardRadiator->SteamIndex; } if (ErrorsFound) { - ShowFatalError(RoutineName + cCMO_BBRadiator_Steam + "Errors found getting input. Program terminates."); + ShowFatalError(RoutineName + state.dataSteamBaseboardRadiator->cCMO_BBRadiator_Steam + "Errors found getting input. Program terminates."); } // Setup Report variables for the Coils - for (BaseboardNum = 1; BaseboardNum <= NumSteamBaseboards; ++BaseboardNum) { + for (BaseboardNum = 1; BaseboardNum <= state.dataSteamBaseboardRadiator->NumSteamBaseboards; ++BaseboardNum) { // CurrentModuleObject='ZoneHVAC:Baseboard:RadiantConvective:Steam' SetupOutputVariable(state, "Baseboard Total Heating Rate", OutputProcessor::Unit::W, - SteamBaseboard(BaseboardNum).TotPower, + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).TotPower, "System", "Average", - SteamBaseboard(BaseboardNum).EquipID); + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).EquipID); SetupOutputVariable(state, "Baseboard Convective Heating Rate", OutputProcessor::Unit::W, - SteamBaseboard(BaseboardNum).ConvPower, + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).ConvPower, "System", "Average", - SteamBaseboard(BaseboardNum).EquipID); + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).EquipID); SetupOutputVariable(state, "Baseboard Radiant Heating Rate", OutputProcessor::Unit::W, - SteamBaseboard(BaseboardNum).RadPower, + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).RadPower, "System", "Average", - SteamBaseboard(BaseboardNum).EquipID); + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).EquipID); SetupOutputVariable(state, "Baseboard Total Heating Energy", OutputProcessor::Unit::J, - SteamBaseboard(BaseboardNum).TotEnergy, + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).TotEnergy, "System", "Sum", - SteamBaseboard(BaseboardNum).EquipID, + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).EquipID, _, "ENERGYTRANSFER", "BASEBOARD", @@ -686,22 +630,22 @@ namespace SteamBaseboardRadiator { "System"); SetupOutputVariable(state, "Baseboard Convective Heating Energy", OutputProcessor::Unit::J, - SteamBaseboard(BaseboardNum).ConvEnergy, + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).ConvEnergy, "System", "Sum", - SteamBaseboard(BaseboardNum).EquipID); + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).EquipID); SetupOutputVariable(state, "Baseboard Radiant Heating Energy", OutputProcessor::Unit::J, - SteamBaseboard(BaseboardNum).RadEnergy, + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).RadEnergy, "System", "Sum", - SteamBaseboard(BaseboardNum).EquipID); + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).EquipID); SetupOutputVariable(state, "Baseboard Steam Energy", OutputProcessor::Unit::J, - SteamBaseboard(BaseboardNum).Energy, + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).Energy, "System", "Sum", - SteamBaseboard(BaseboardNum).EquipID, + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).EquipID, _, "PLANTLOOPHEATINGDEMAND", "BASEBOARD", @@ -709,28 +653,28 @@ namespace SteamBaseboardRadiator { "System"); SetupOutputVariable(state, "Baseboard Steam Rate", OutputProcessor::Unit::W, - SteamBaseboard(BaseboardNum).Power, + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).Power, "System", "Average", - SteamBaseboard(BaseboardNum).EquipID); + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).EquipID); SetupOutputVariable(state, "Baseboard Steam Mass Flow Rate", OutputProcessor::Unit::kg_s, - SteamBaseboard(BaseboardNum).SteamMassFlowRate, + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SteamMassFlowRate, "System", "Average", - SteamBaseboard(BaseboardNum).EquipID); + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).EquipID); SetupOutputVariable(state, "Baseboard Steam Inlet Temperature", OutputProcessor::Unit::C, - SteamBaseboard(BaseboardNum).SteamInletTemp, + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SteamInletTemp, "System", "Average", - SteamBaseboard(BaseboardNum).EquipID); + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).EquipID); SetupOutputVariable(state, "Baseboard Steam Outlet Temperature", OutputProcessor::Unit::C, - SteamBaseboard(BaseboardNum).SteamOutletTemp, + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SteamOutletTemp, "System", "Average", - SteamBaseboard(BaseboardNum).EquipID); + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).EquipID); } } @@ -785,93 +729,93 @@ namespace SteamBaseboardRadiator { bool errFlag; // Do the one time initializations - if (MyOneTimeFlag) { + if (state.dataSteamBaseboardRadiator->MyOneTimeFlag) { // initialize the environment and sizing flags - MyEnvrnFlag.allocate(NumSteamBaseboards); - MySizeFlag.allocate(NumSteamBaseboards); - ZeroSourceSumHATsurf.dimension(NumOfZones, 0.0); - QBBSteamRadSource.dimension(NumSteamBaseboards, 0.0); - QBBSteamRadSrcAvg.dimension(NumSteamBaseboards, 0.0); - LastQBBSteamRadSrc.dimension(NumSteamBaseboards, 0.0); - LastSysTimeElapsed.dimension(NumSteamBaseboards, 0.0); - LastTimeStepSys.dimension(NumSteamBaseboards, 0.0); - SetLoopIndexFlag.allocate(NumSteamBaseboards); + MyEnvrnFlag.allocate(state.dataSteamBaseboardRadiator->NumSteamBaseboards); + state.dataSteamBaseboardRadiator->MySizeFlag.allocate(state.dataSteamBaseboardRadiator->NumSteamBaseboards); + state.dataSteamBaseboardRadiator->ZeroSourceSumHATsurf.dimension(NumOfZones, 0.0); + state.dataSteamBaseboardRadiator->QBBSteamRadSource.dimension(state.dataSteamBaseboardRadiator->NumSteamBaseboards, 0.0); + state.dataSteamBaseboardRadiator->QBBSteamRadSrcAvg.dimension(state.dataSteamBaseboardRadiator->NumSteamBaseboards, 0.0); + state.dataSteamBaseboardRadiator->LastQBBSteamRadSrc.dimension(state.dataSteamBaseboardRadiator->NumSteamBaseboards, 0.0); + state.dataSteamBaseboardRadiator->LastSysTimeElapsed.dimension(state.dataSteamBaseboardRadiator->NumSteamBaseboards, 0.0); + state.dataSteamBaseboardRadiator->LastTimeStepSys.dimension(state.dataSteamBaseboardRadiator->NumSteamBaseboards, 0.0); + state.dataSteamBaseboardRadiator->SetLoopIndexFlag.allocate(state.dataSteamBaseboardRadiator->NumSteamBaseboards); MyEnvrnFlag = true; - MySizeFlag = true; - MyOneTimeFlag = false; - SetLoopIndexFlag = true; + state.dataSteamBaseboardRadiator->MySizeFlag = true; + state.dataSteamBaseboardRadiator->MyOneTimeFlag = false; + state.dataSteamBaseboardRadiator->SetLoopIndexFlag = true; } - if (SteamBaseboard(BaseboardNum).ZonePtr <= 0) SteamBaseboard(BaseboardNum).ZonePtr = ZoneEquipConfig(ControlledZoneNumSub).ActualZoneNum; + if (state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).ZonePtr <= 0) state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).ZonePtr = ZoneEquipConfig(ControlledZoneNumSub).ActualZoneNum; // Need to check all units to see if they are on ZoneHVAC:EquipmentList or issue warning - if (!ZoneEquipmentListChecked && ZoneEquipInputsFilled) { - ZoneEquipmentListChecked = true; - for (Loop = 1; Loop <= NumSteamBaseboards; ++Loop) { - if (CheckZoneEquipmentList(cCMO_BBRadiator_Steam, SteamBaseboard(Loop).EquipID)) continue; - ShowSevereError("InitBaseboard: Unit=[" + cCMO_BBRadiator_Steam + ',' + SteamBaseboard(Loop).EquipID + + if (!state.dataSteamBaseboardRadiator->ZoneEquipmentListChecked && ZoneEquipInputsFilled) { + state.dataSteamBaseboardRadiator->ZoneEquipmentListChecked = true; + for (Loop = 1; Loop <= state.dataSteamBaseboardRadiator->NumSteamBaseboards; ++Loop) { + if (CheckZoneEquipmentList(state.dataSteamBaseboardRadiator->cCMO_BBRadiator_Steam, state.dataSteamBaseboardRadiator->SteamBaseboard(Loop).EquipID)) continue; + ShowSevereError("InitBaseboard: Unit=[" + state.dataSteamBaseboardRadiator->cCMO_BBRadiator_Steam + ',' + state.dataSteamBaseboardRadiator->SteamBaseboard(Loop).EquipID + "] is not on any ZoneHVAC:EquipmentList. It will not be simulated."); } } - if (SetLoopIndexFlag(BaseboardNum)) { + if (state.dataSteamBaseboardRadiator->SetLoopIndexFlag(BaseboardNum)) { if (allocated(PlantLoop)) { errFlag = false; ScanPlantLoopsForObject(state, - SteamBaseboard(BaseboardNum).EquipID, - SteamBaseboard(BaseboardNum).EquipType, - SteamBaseboard(BaseboardNum).LoopNum, - SteamBaseboard(BaseboardNum).LoopSideNum, - SteamBaseboard(BaseboardNum).BranchNum, - SteamBaseboard(BaseboardNum).CompNum, + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).EquipID, + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).EquipType, + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).LoopNum, + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).LoopSideNum, + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).BranchNum, + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).CompNum, errFlag, _, _, _, _, _); - SetLoopIndexFlag(BaseboardNum) = false; + state.dataSteamBaseboardRadiator->SetLoopIndexFlag(BaseboardNum) = false; if (errFlag) { ShowFatalError("InitSteamBaseboard: Program terminated for previous conditions."); } } } - if (!SysSizingCalc && MySizeFlag(BaseboardNum) && (!SetLoopIndexFlag(BaseboardNum))) { + if (!SysSizingCalc && state.dataSteamBaseboardRadiator->MySizeFlag(BaseboardNum) && (!state.dataSteamBaseboardRadiator->SetLoopIndexFlag(BaseboardNum))) { // For each coil, do the sizing once SizeSteamBaseboard(state, BaseboardNum); - MySizeFlag(BaseboardNum) = false; + state.dataSteamBaseboardRadiator->MySizeFlag(BaseboardNum) = false; } // Do the Begin Environment initializations if (BeginEnvrnFlag && MyEnvrnFlag(BaseboardNum)) { // Initialize - SteamInletNode = SteamBaseboard(BaseboardNum).SteamInletNode; + SteamInletNode = state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SteamInletNode; Node(SteamInletNode).Temp = 100.0; Node(SteamInletNode).Press = 101325.0; SteamDensity = GetSatDensityRefrig(state, fluidNameSteam, Node(SteamInletNode).Temp, 1.0, Node(SteamInletNode).FluidIndex, RoutineName); StartEnthSteam = GetSatEnthalpyRefrig(state, fluidNameSteam, Node(SteamInletNode).Temp, 1.0, Node(SteamInletNode).FluidIndex, RoutineName); - SteamBaseboard(BaseboardNum).SteamMassFlowRateMax = SteamDensity * SteamBaseboard(BaseboardNum).SteamVolFlowRateMax; + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SteamMassFlowRateMax = SteamDensity * state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SteamVolFlowRateMax; InitComponentNodes(0.0, - SteamBaseboard(BaseboardNum).SteamMassFlowRateMax, - SteamBaseboard(BaseboardNum).SteamInletNode, - SteamBaseboard(BaseboardNum).SteamOutletNode, - SteamBaseboard(BaseboardNum).LoopNum, - SteamBaseboard(BaseboardNum).LoopSideNum, - SteamBaseboard(BaseboardNum).BranchNum, - SteamBaseboard(BaseboardNum).CompNum); + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SteamMassFlowRateMax, + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SteamInletNode, + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SteamOutletNode, + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).LoopNum, + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).LoopSideNum, + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).BranchNum, + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).CompNum); Node(SteamInletNode).Enthalpy = StartEnthSteam; Node(SteamInletNode).Quality = 1.0; Node(SteamInletNode).HumRat = 0.0; // Initializes radiant sources - ZeroSourceSumHATsurf = 0.0; - QBBSteamRadSource = 0.0; - QBBSteamRadSrcAvg = 0.0; - LastQBBSteamRadSrc = 0.0; - LastSysTimeElapsed = 0.0; - LastTimeStepSys = 0.0; + state.dataSteamBaseboardRadiator->ZeroSourceSumHATsurf = 0.0; + state.dataSteamBaseboardRadiator->QBBSteamRadSource = 0.0; + state.dataSteamBaseboardRadiator->QBBSteamRadSrcAvg = 0.0; + state.dataSteamBaseboardRadiator->LastQBBSteamRadSrc = 0.0; + state.dataSteamBaseboardRadiator->LastSysTimeElapsed = 0.0; + state.dataSteamBaseboardRadiator->LastTimeStepSys = 0.0; MyEnvrnFlag(BaseboardNum) = false; } @@ -881,31 +825,31 @@ namespace SteamBaseboardRadiator { } if (BeginTimeStepFlag && FirstHVACIteration) { - ZoneNum = SteamBaseboard(BaseboardNum).ZonePtr; - ZeroSourceSumHATsurf(ZoneNum) = SumHATsurf(ZoneNum); - QBBSteamRadSrcAvg(BaseboardNum) = 0.0; - LastQBBSteamRadSrc(BaseboardNum) = 0.0; - LastSysTimeElapsed(BaseboardNum) = 0.0; - LastTimeStepSys(BaseboardNum) = 0.0; + ZoneNum = state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).ZonePtr; + state.dataSteamBaseboardRadiator->ZeroSourceSumHATsurf(ZoneNum) = SumHATsurf(ZoneNum); + state.dataSteamBaseboardRadiator->QBBSteamRadSrcAvg(BaseboardNum) = 0.0; + state.dataSteamBaseboardRadiator->LastQBBSteamRadSrc(BaseboardNum) = 0.0; + state.dataSteamBaseboardRadiator->LastSysTimeElapsed(BaseboardNum) = 0.0; + state.dataSteamBaseboardRadiator->LastTimeStepSys(BaseboardNum) = 0.0; } // Do the every time step initializations - SteamInletNode = SteamBaseboard(BaseboardNum).SteamInletNode; + SteamInletNode = state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SteamInletNode; ZoneNode = ZoneEquipConfig(ControlledZoneNumSub).ZoneNode; - SteamBaseboard(BaseboardNum).SteamMassFlowRate = Node(SteamInletNode).MassFlowRate; - SteamBaseboard(BaseboardNum).SteamInletTemp = Node(SteamInletNode).Temp; - SteamBaseboard(BaseboardNum).SteamInletEnthalpy = Node(SteamInletNode).Enthalpy; - SteamBaseboard(BaseboardNum).SteamInletPress = Node(SteamInletNode).Press; - SteamBaseboard(BaseboardNum).SteamInletQuality = Node(SteamInletNode).Quality; - - SteamBaseboard(BaseboardNum).TotPower = 0.0; - SteamBaseboard(BaseboardNum).Power = 0.0; - SteamBaseboard(BaseboardNum).ConvPower = 0.0; - SteamBaseboard(BaseboardNum).RadPower = 0.0; - SteamBaseboard(BaseboardNum).TotEnergy = 0.0; - SteamBaseboard(BaseboardNum).Energy = 0.0; - SteamBaseboard(BaseboardNum).ConvEnergy = 0.0; - SteamBaseboard(BaseboardNum).RadEnergy = 0.0; + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SteamMassFlowRate = Node(SteamInletNode).MassFlowRate; + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SteamInletTemp = Node(SteamInletNode).Temp; + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SteamInletEnthalpy = Node(SteamInletNode).Enthalpy; + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SteamInletPress = Node(SteamInletNode).Press; + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SteamInletQuality = Node(SteamInletNode).Quality; + + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).TotPower = 0.0; + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).Power = 0.0; + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).ConvPower = 0.0; + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).RadPower = 0.0; + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).TotEnergy = 0.0; + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).Energy = 0.0; + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).ConvEnergy = 0.0; + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).RadEnergy = 0.0; } void SizeSteamBaseboard(EnergyPlusData &state, int const BaseboardNum) @@ -973,7 +917,7 @@ namespace SteamBaseboardRadiator { int CapSizingMethod(0); // capacity sizing methods (HeatingDesignCapacity, CapacityPerFloorArea, and FractionOfAutosizedHeatingCapacity ) // Find the appropriate steam plant sizing object - PltSizSteamNum = PlantLoop(SteamBaseboard(BaseboardNum).LoopNum).PlantSizNum; + PltSizSteamNum = PlantLoop(state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).LoopNum).PlantSizNum; // PltSizSteamNum = MyPlantSizingIndex('Coil:Heating:Steam', SteamBaseboard(BaseboardNum)%EquipID, & // SteamBaseboard(BaseboardNum)%SteamInletNode, & // SteamBaseboard(BaseboardNum)%SteamOutletNode, ErrorsFound) @@ -984,54 +928,54 @@ namespace SteamBaseboardRadiator { if (CurZoneEqNum > 0) { - if (SteamBaseboard(BaseboardNum).SteamVolFlowRateMax == AutoSize) { + if (state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SteamVolFlowRateMax == AutoSize) { IsAutoSize = true; } if (!IsAutoSize && !ZoneSizingRunDone) { - if (SteamBaseboard(BaseboardNum).SteamVolFlowRateMax > 0.0) { - BaseSizer::reportSizerOutput(cCMO_BBRadiator_Steam, - SteamBaseboard(BaseboardNum).EquipID, + if (state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SteamVolFlowRateMax > 0.0) { + BaseSizer::reportSizerOutput(state.dataSteamBaseboardRadiator->cCMO_BBRadiator_Steam, + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).EquipID, "User-Specified Maximum Water Flow Rate [m3/s]", - SteamBaseboard(BaseboardNum).SteamVolFlowRateMax); + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SteamVolFlowRateMax); } } else { - CheckZoneSizing(cCMO_BBRadiator_Steam, SteamBaseboard(BaseboardNum).EquipID); + CheckZoneSizing(state.dataSteamBaseboardRadiator->cCMO_BBRadiator_Steam, state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).EquipID); - CompType = cCMO_BBRadiator_Steam; - CompName = SteamBaseboard(BaseboardNum).EquipID; + CompType = state.dataSteamBaseboardRadiator->cCMO_BBRadiator_Steam; + CompName = state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).EquipID; DataFracOfAutosizedHeatingCapacity = 1.0; - DataZoneNumber = SteamBaseboard(BaseboardNum).ZonePtr; + DataZoneNumber = state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).ZonePtr; SizingMethod = HeatingCapacitySizing; FieldNum = 1; PrintFlag = false; - SizingString = SteamBaseboardNumericFields(BaseboardNum).FieldNames(FieldNum) + " [W]"; - CapSizingMethod = SteamBaseboard(BaseboardNum).HeatingCapMethod; + SizingString = state.dataSteamBaseboardRadiator->SteamBaseboardNumericFields(BaseboardNum).FieldNames(FieldNum) + " [W]"; + CapSizingMethod = state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).HeatingCapMethod; ZoneEqSizing(CurZoneEqNum).SizingMethod(SizingMethod) = CapSizingMethod; if (CapSizingMethod == HeatingDesignCapacity || CapSizingMethod == CapacityPerFloorArea || CapSizingMethod == FractionOfAutosizedHeatingCapacity) { if (CapSizingMethod == HeatingDesignCapacity) { - if (SteamBaseboard(BaseboardNum).ScaledHeatingCapacity == AutoSize) { + if (state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).ScaledHeatingCapacity == AutoSize) { CheckZoneSizing(CompType, CompName); ZoneEqSizing(CurZoneEqNum).HeatingCapacity = true; ZoneEqSizing(CurZoneEqNum).DesHeatingLoad = FinalZoneSizing(CurZoneEqNum).NonAirSysDesHeatLoad; } - TempSize = SteamBaseboard(BaseboardNum).ScaledHeatingCapacity; + TempSize = state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).ScaledHeatingCapacity; } else if (CapSizingMethod == CapacityPerFloorArea) { ZoneEqSizing(CurZoneEqNum).HeatingCapacity = true; ZoneEqSizing(CurZoneEqNum).DesHeatingLoad = - SteamBaseboard(BaseboardNum).ScaledHeatingCapacity * Zone(DataZoneNumber).FloorArea; + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).ScaledHeatingCapacity * Zone(DataZoneNumber).FloorArea; TempSize = ZoneEqSizing(CurZoneEqNum).DesHeatingLoad; DataScalableCapSizingON = true; } else if (CapSizingMethod == FractionOfAutosizedHeatingCapacity) { CheckZoneSizing(CompType, CompName); ZoneEqSizing(CurZoneEqNum).HeatingCapacity = true; - DataFracOfAutosizedHeatingCapacity = SteamBaseboard(BaseboardNum).ScaledHeatingCapacity; + DataFracOfAutosizedHeatingCapacity = state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).ScaledHeatingCapacity; ZoneEqSizing(CurZoneEqNum).DesHeatingLoad = FinalZoneSizing(CurZoneEqNum).NonAirSysDesHeatLoad; TempSize = AutoSize; DataScalableCapSizingON = true; } else { - TempSize = SteamBaseboard(BaseboardNum).ScaledHeatingCapacity; + TempSize = state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).ScaledHeatingCapacity; } bool errorsFound = false; HeatingCapacitySizer sizerHeatingCapacity; @@ -1046,29 +990,29 @@ namespace SteamBaseboardRadiator { if (DesCoilLoad >= SmallLoad) { SteamInletTemp = 100.0; EnthSteamInDry = - GetSatEnthalpyRefrig(state, fluidNameSteam, SteamInletTemp, 1.0, SteamBaseboard(BaseboardNum).FluidIndex, RoutineName); + GetSatEnthalpyRefrig(state, fluidNameSteam, SteamInletTemp, 1.0, state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).FluidIndex, RoutineName); EnthSteamOutWet = - GetSatEnthalpyRefrig(state, fluidNameSteam, SteamInletTemp, 0.0, SteamBaseboard(BaseboardNum).FluidIndex, RoutineName); + GetSatEnthalpyRefrig(state, fluidNameSteam, SteamInletTemp, 0.0, state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).FluidIndex, RoutineName); LatentHeatSteam = EnthSteamInDry - EnthSteamOutWet; - SteamDensity = GetSatDensityRefrig(state, fluidNameSteam, SteamInletTemp, 1.0, SteamBaseboard(BaseboardNum).FluidIndex, RoutineName); - Cp = GetSatSpecificHeatRefrig(state, fluidNameSteam, SteamInletTemp, 0.0, SteamBaseboard(BaseboardNum).FluidIndex, RoutineName); + SteamDensity = GetSatDensityRefrig(state, fluidNameSteam, SteamInletTemp, 1.0, state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).FluidIndex, RoutineName); + Cp = GetSatSpecificHeatRefrig(state, fluidNameSteam, SteamInletTemp, 0.0, state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).FluidIndex, RoutineName); - SteamVolFlowRateMaxDes = DesCoilLoad / (SteamDensity * (LatentHeatSteam + SteamBaseboard(BaseboardNum).DegOfSubcooling * Cp)); + SteamVolFlowRateMaxDes = DesCoilLoad / (SteamDensity * (LatentHeatSteam + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).DegOfSubcooling * Cp)); } else { SteamVolFlowRateMaxDes = 0.0; } if (IsAutoSize) { - SteamBaseboard(BaseboardNum).SteamVolFlowRateMax = SteamVolFlowRateMaxDes; - BaseSizer::reportSizerOutput(cCMO_BBRadiator_Steam, - SteamBaseboard(BaseboardNum).EquipID, + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SteamVolFlowRateMax = SteamVolFlowRateMaxDes; + BaseSizer::reportSizerOutput(state.dataSteamBaseboardRadiator->cCMO_BBRadiator_Steam, + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).EquipID, "Design Size Maximum Steam Flow Rate [m3/s]", SteamVolFlowRateMaxDes); } else { // Hard size with sizing data - if (SteamBaseboard(BaseboardNum).SteamVolFlowRateMax > 0.0 && SteamVolFlowRateMaxDes > 0.0) { - SteamVolFlowRateMaxUser = SteamBaseboard(BaseboardNum).SteamVolFlowRateMax; - BaseSizer::reportSizerOutput(cCMO_BBRadiator_Steam, - SteamBaseboard(BaseboardNum).EquipID, + if (state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SteamVolFlowRateMax > 0.0 && SteamVolFlowRateMaxDes > 0.0) { + SteamVolFlowRateMaxUser = state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SteamVolFlowRateMax; + BaseSizer::reportSizerOutput(state.dataSteamBaseboardRadiator->cCMO_BBRadiator_Steam, + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).EquipID, "Design Size Maximum Steam Flow Rate [m3/s]", SteamVolFlowRateMaxDes, "User-Speicified Maximum Steam Flow Rate [m3/s]", @@ -1079,7 +1023,7 @@ namespace SteamBaseboardRadiator { AutoVsHardSizingThreshold) { ShowMessage("SizeSteamBaseboard: Potential issue with equipment sizing for " "ZoneHVAC:Baseboard:RadiantConvective:Steam=\"" + - SteamBaseboard(BaseboardNum).EquipID + "\"."); + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).EquipID + "\"."); ShowContinueError("User-Specified Maximum Steam Flow Rate of " + RoundSigDigits(SteamVolFlowRateMaxUser, 5) + " [m3/s]"); ShowContinueError("differs from Design Size Maximum Steam Flow Rate of " + @@ -1097,12 +1041,12 @@ namespace SteamBaseboardRadiator { // if there is no heating Sizing:Plant object and autosizng was requested, issue an error message // first error will be issued by MyPlantSizingIndex ShowSevereError("Autosizing of steam baseboard requires a heating loop Sizing:Plant object"); - ShowContinueError("Occurs in Baseboard Heater=" + SteamBaseboard(BaseboardNum).EquipID); + ShowContinueError("Occurs in Baseboard Heater=" + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).EquipID); ErrorsFound = true; } } - RegisterPlantCompDesignFlow(SteamBaseboard(BaseboardNum).SteamInletNode, SteamBaseboard(BaseboardNum).SteamVolFlowRateMax); + RegisterPlantCompDesignFlow(state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SteamInletNode, state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SteamVolFlowRateMax); if (ErrorsFound) { ShowFatalError("Preceding sizing errors cause program termination"); @@ -1163,28 +1107,28 @@ namespace SteamBaseboardRadiator { Real64 LatentHeatSteam; Real64 Cp; - ZoneNum = SteamBaseboard(BaseboardNum).ZonePtr; + ZoneNum = state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).ZonePtr; QZnReq = ZoneSysEnergyDemand(ZoneNum).RemainingOutputReqToHeatSP; - SteamInletTemp = Node(SteamBaseboard(BaseboardNum).SteamInletNode).Temp; + SteamInletTemp = Node(state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SteamInletNode).Temp; SteamOutletTemp = SteamInletTemp; - SteamMassFlowRate = Node(SteamBaseboard(BaseboardNum).SteamInletNode).MassFlowRate; - SubcoolDeltaT = SteamBaseboard(BaseboardNum).DegOfSubcooling; + SteamMassFlowRate = Node(state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SteamInletNode).MassFlowRate; + SubcoolDeltaT = state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).DegOfSubcooling; if (QZnReq > SmallLoad && !CurDeadBandOrSetback(ZoneNum) && SteamMassFlowRate > 0.0 && - GetCurrentScheduleValue(SteamBaseboard(BaseboardNum).SchedPtr) > 0) { + GetCurrentScheduleValue(state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SchedPtr) > 0) { // Unit is on - EnthSteamInDry = GetSatEnthalpyRefrig(state, fluidNameSteam, SteamInletTemp, 1.0, SteamBaseboard(BaseboardNum).FluidIndex, RoutineName); - EnthSteamOutWet = GetSatEnthalpyRefrig(state, fluidNameSteam, SteamInletTemp, 0.0, SteamBaseboard(BaseboardNum).FluidIndex, RoutineName); + EnthSteamInDry = GetSatEnthalpyRefrig(state, fluidNameSteam, SteamInletTemp, 1.0, state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).FluidIndex, RoutineName); + EnthSteamOutWet = GetSatEnthalpyRefrig(state, fluidNameSteam, SteamInletTemp, 0.0, state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).FluidIndex, RoutineName); LatentHeatSteam = EnthSteamInDry - EnthSteamOutWet; - Cp = GetSatSpecificHeatRefrig(state, fluidNameSteam, SteamInletTemp, 0.0, SteamBaseboard(BaseboardNum).FluidIndex, RoutineName); + Cp = GetSatSpecificHeatRefrig(state, fluidNameSteam, SteamInletTemp, 0.0, state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).FluidIndex, RoutineName); SteamBBHeat = SteamMassFlowRate * (LatentHeatSteam + SubcoolDeltaT * Cp); // Baseboard heating rate SteamOutletTemp = SteamInletTemp - SubcoolDeltaT; // Outlet temperature of steam // Estimate radiant heat addition - RadHeat = SteamBBHeat * SteamBaseboard(BaseboardNum).FracRadiant; // Radiant heating rate - QBBSteamRadSource(BaseboardNum) = RadHeat; // Radiant heat source which will be distributed to surfaces and people + RadHeat = SteamBBHeat * state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).FracRadiant; // Radiant heating rate + state.dataSteamBaseboardRadiator->QBBSteamRadSource(BaseboardNum) = RadHeat; // Radiant heat source which will be distributed to surfaces and people // Now, distribute the radiant energy of all systems to the appropriate surfaces, to people, and the air - DistributeBBSteamRadGains(); + DistributeBBSteamRadGains(state); // Now "simulate" the system by recalculating the heat balances HeatBalanceSurfaceManager::CalcHeatBalanceOutsideSurf(state, ZoneNum); HeatBalanceSurfaceManager::CalcHeatBalanceInsideSurf(state, ZoneNum); @@ -1199,32 +1143,32 @@ namespace SteamBaseboardRadiator { // should include this. // Actual system load that the unit should meet - LoadMet = (SumHATsurf(ZoneNum) - ZeroSourceSumHATsurf(ZoneNum)) + (SteamBBHeat * SteamBaseboard(BaseboardNum).FracConvect) + - (RadHeat * SteamBaseboard(BaseboardNum).FracDistribPerson); - SteamBaseboard(BaseboardNum).SteamOutletEnthalpy = SteamBaseboard(BaseboardNum).SteamInletEnthalpy - SteamBBHeat / SteamMassFlowRate; - SteamBaseboard(BaseboardNum).SteamOutletQuality = 0.0; + LoadMet = (SumHATsurf(ZoneNum) - state.dataSteamBaseboardRadiator->ZeroSourceSumHATsurf(ZoneNum)) + (SteamBBHeat * state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).FracConvect) + + (RadHeat * state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).FracDistribPerson); + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SteamOutletEnthalpy = state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SteamInletEnthalpy - SteamBBHeat / SteamMassFlowRate; + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SteamOutletQuality = 0.0; } else { SteamOutletTemp = SteamInletTemp; SteamBBHeat = 0.0; LoadMet = 0.0; RadHeat = 0.0; SteamMassFlowRate = 0.0; - QBBSteamRadSource(BaseboardNum) = 0.0; - SteamBaseboard(BaseboardNum).SteamOutletQuality = 0.0; - SteamBaseboard(BaseboardNum).SteamOutletEnthalpy = SteamBaseboard(BaseboardNum).SteamInletEnthalpy; + state.dataSteamBaseboardRadiator->QBBSteamRadSource(BaseboardNum) = 0.0; + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SteamOutletQuality = 0.0; + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SteamOutletEnthalpy = state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SteamInletEnthalpy; } - SteamBaseboard(BaseboardNum).SteamOutletTemp = SteamOutletTemp; - SteamBaseboard(BaseboardNum).SteamMassFlowRate = SteamMassFlowRate; - SteamBaseboard(BaseboardNum).SteamOutletEnthalpy = SteamBaseboard(BaseboardNum).SteamOutletEnthalpy; - SteamBaseboard(BaseboardNum).SteamOutletQuality = SteamBaseboard(BaseboardNum).SteamOutletQuality; - SteamBaseboard(BaseboardNum).TotPower = LoadMet; - SteamBaseboard(BaseboardNum).Power = SteamBBHeat; - SteamBaseboard(BaseboardNum).ConvPower = SteamBBHeat - RadHeat; - SteamBaseboard(BaseboardNum).RadPower = RadHeat; + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SteamOutletTemp = SteamOutletTemp; + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SteamMassFlowRate = SteamMassFlowRate; + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SteamOutletEnthalpy = state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SteamOutletEnthalpy; + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SteamOutletQuality = state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SteamOutletQuality; + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).TotPower = LoadMet; + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).Power = SteamBBHeat; + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).ConvPower = SteamBBHeat - RadHeat; + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).RadPower = RadHeat; } - void UpdateSteamBaseboard(int const BaseboardNum) + void UpdateSteamBaseboard(EnergyPlusData &state, int const BaseboardNum) { // SUBROUTINE INFORMATION: // AUTHOR Russ Taylor @@ -1240,52 +1184,35 @@ namespace SteamBaseboardRadiator { // The update subrotines both in high temperature radiant radiator // and convective only baseboard radiator are combined and modified. - // REFERENCES: - // na - - // Using/Aliasing using DataGlobals::BeginEnvrnFlag; using DataGlobals::TimeStepZone; using PlantUtilities::SafeCopyPlantNode; - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int SteamInletNode; int SteamOutletNode; // First, update the running average if necessary... - if (LastSysTimeElapsed(BaseboardNum) == SysTimeElapsed) { - QBBSteamRadSrcAvg(BaseboardNum) -= LastQBBSteamRadSrc(BaseboardNum) * LastTimeStepSys(BaseboardNum) / TimeStepZone; + if (state.dataSteamBaseboardRadiator->LastSysTimeElapsed(BaseboardNum) == SysTimeElapsed) { + state.dataSteamBaseboardRadiator->QBBSteamRadSrcAvg(BaseboardNum) -= state.dataSteamBaseboardRadiator->LastQBBSteamRadSrc(BaseboardNum) * state.dataSteamBaseboardRadiator->LastTimeStepSys(BaseboardNum) / TimeStepZone; } // Update the running average and the "last" values with the current values of the appropriate variables - QBBSteamRadSrcAvg(BaseboardNum) += QBBSteamRadSource(BaseboardNum) * TimeStepSys / TimeStepZone; + state.dataSteamBaseboardRadiator->QBBSteamRadSrcAvg(BaseboardNum) += state.dataSteamBaseboardRadiator->QBBSteamRadSource(BaseboardNum) * TimeStepSys / TimeStepZone; - LastQBBSteamRadSrc(BaseboardNum) = QBBSteamRadSource(BaseboardNum); - LastSysTimeElapsed(BaseboardNum) = SysTimeElapsed; - LastTimeStepSys(BaseboardNum) = TimeStepSys; + state.dataSteamBaseboardRadiator->LastQBBSteamRadSrc(BaseboardNum) = state.dataSteamBaseboardRadiator->QBBSteamRadSource(BaseboardNum); + state.dataSteamBaseboardRadiator->LastSysTimeElapsed(BaseboardNum) = SysTimeElapsed; + state.dataSteamBaseboardRadiator->LastTimeStepSys(BaseboardNum) = TimeStepSys; - SteamInletNode = SteamBaseboard(BaseboardNum).SteamInletNode; - SteamOutletNode = SteamBaseboard(BaseboardNum).SteamOutletNode; + SteamInletNode = state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SteamInletNode; + SteamOutletNode = state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SteamOutletNode; // Set the outlet air nodes of the Baseboard // Set the outlet water nodes for the Coil SafeCopyPlantNode(SteamInletNode, SteamOutletNode); - Node(SteamOutletNode).Temp = SteamBaseboard(BaseboardNum).SteamOutletTemp; - Node(SteamOutletNode).Enthalpy = SteamBaseboard(BaseboardNum).SteamOutletEnthalpy; + Node(SteamOutletNode).Temp = state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SteamOutletTemp; + Node(SteamOutletNode).Enthalpy = state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SteamOutletEnthalpy; } - void UpdateBBSteamRadSourceValAvg(bool &SteamBaseboardSysOn) // .TRUE. if the radiant system has run this zone time step + void UpdateBBSteamRadSourceValAvg(EnergyPlusData &state, bool &SteamBaseboardSysOn) // .TRUE. if the radiant system has run this zone time step { // SUBROUTINE INFORMATION: @@ -1307,47 +1234,28 @@ namespace SteamBaseboardRadiator { // see if the system was even on. If any average term is non-zero, then // one or more of the radiant systems was running. - // REFERENCES: - // na - - // USE STATEMENTS: - // na - - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int BaseboardNum; // DO loop counter for surface index // FLOW: SteamBaseboardSysOn = false; // If this was never allocated, then there are no radiant systems in this input file (just RETURN) - if (!allocated(QBBSteamRadSrcAvg)) return; + if (!allocated(state.dataSteamBaseboardRadiator->QBBSteamRadSrcAvg)) return; // If it was allocated, then we have to check to see if this was running at all... - for (BaseboardNum = 1; BaseboardNum <= NumSteamBaseboards; ++BaseboardNum) { - if (QBBSteamRadSrcAvg(BaseboardNum) != 0.0) { + for (BaseboardNum = 1; BaseboardNum <= state.dataSteamBaseboardRadiator->NumSteamBaseboards; ++BaseboardNum) { + if (state.dataSteamBaseboardRadiator->QBBSteamRadSrcAvg(BaseboardNum) != 0.0) { SteamBaseboardSysOn = true; break; // DO loop } } - QBBSteamRadSource = QBBSteamRadSrcAvg; + state.dataSteamBaseboardRadiator->QBBSteamRadSource = state.dataSteamBaseboardRadiator->QBBSteamRadSrcAvg; - DistributeBBSteamRadGains(); // QBBRadSource has been modified so we need to redistribute gains + DistributeBBSteamRadGains(state); // QBBRadSource has been modified so we need to redistribute gains } - void DistributeBBSteamRadGains() + void DistributeBBSteamRadGains(EnergyPlusData &state) { // SUBROUTINE INFORMATION: @@ -1368,10 +1276,6 @@ namespace SteamBaseboardRadiator { // Note that the energy radiated to people is assumed to affect them // but them it is assumed to be convected to the air. - // REFERENCES: - // na - - // Using/Aliasing using DataHeatBalance::Zone; using DataHeatBalFanSys::MaxRadHeatFlux; using DataHeatBalFanSys::QSteamBaseboardSurf; @@ -1379,64 +1283,51 @@ namespace SteamBaseboardRadiator { using DataSurfaces::Surface; using General::RoundSigDigits; - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: Real64 const SmallestArea(0.001); // Smallest area in meters squared (to avoid a divide by zero) - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int RadSurfNum; // Counter for surfaces receiving radiation from radiant heater int BaseboardNum; // Counter for the baseboard int SurfNum; // Pointer to the Surface derived type int ZoneNum; // Pointer to the Zone derived type Real64 ThisSurfIntensity; // temporary for W/m2 term for rad on a surface - // FLOW: - // Initialize arrays QSteamBaseboardSurf = 0.0; QSteamBaseboardToPerson = 0.0; - for (BaseboardNum = 1; BaseboardNum <= NumSteamBaseboards; ++BaseboardNum) { + for (BaseboardNum = 1; BaseboardNum <= state.dataSteamBaseboardRadiator->NumSteamBaseboards; ++BaseboardNum) { - ZoneNum = SteamBaseboard(BaseboardNum).ZonePtr; - QSteamBaseboardToPerson(ZoneNum) += QBBSteamRadSource(BaseboardNum) * SteamBaseboard(BaseboardNum).FracDistribPerson; + ZoneNum = state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).ZonePtr; + QSteamBaseboardToPerson(ZoneNum) += state.dataSteamBaseboardRadiator->QBBSteamRadSource(BaseboardNum) * state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).FracDistribPerson; - for (RadSurfNum = 1; RadSurfNum <= SteamBaseboard(BaseboardNum).TotSurfToDistrib; ++RadSurfNum) { - SurfNum = SteamBaseboard(BaseboardNum).SurfacePtr(RadSurfNum); + for (RadSurfNum = 1; RadSurfNum <= state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).TotSurfToDistrib; ++RadSurfNum) { + SurfNum = state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SurfacePtr(RadSurfNum); if (Surface(SurfNum).Area > SmallestArea) { ThisSurfIntensity = - (QBBSteamRadSource(BaseboardNum) * SteamBaseboard(BaseboardNum).FracDistribToSurf(RadSurfNum) / Surface(SurfNum).Area); + (state.dataSteamBaseboardRadiator->QBBSteamRadSource(BaseboardNum) * state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).FracDistribToSurf(RadSurfNum) / Surface(SurfNum).Area); QSteamBaseboardSurf(SurfNum) += ThisSurfIntensity; if (ThisSurfIntensity > MaxRadHeatFlux) { // CR 8074, trap for excessive intensity (throws off surface balance ) ShowSevereError("DistributeBBSteamRadGains: excessive thermal radiation heat flux intensity detected"); ShowContinueError("Surface = " + Surface(SurfNum).Name); ShowContinueError("Surface area = " + RoundSigDigits(Surface(SurfNum).Area, 3) + " [m2]"); - ShowContinueError("Occurs in " + cCMO_BBRadiator_Steam + " = " + SteamBaseboard(BaseboardNum).EquipID); + ShowContinueError("Occurs in " + state.dataSteamBaseboardRadiator->cCMO_BBRadiator_Steam + " = " + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).EquipID); ShowContinueError("Radiation intensity = " + RoundSigDigits(ThisSurfIntensity, 2) + " [W/m2]"); - ShowContinueError("Assign a larger surface area or more surfaces in " + cCMO_BBRadiator_Steam); + ShowContinueError("Assign a larger surface area or more surfaces in " + state.dataSteamBaseboardRadiator->cCMO_BBRadiator_Steam); ShowFatalError("DistributeBBSteamRadGains: excessive thermal radiation heat flux intensity detected"); } } else { // small surface ShowSevereError("DistributeBBSteamRadGains: surface not large enough to receive thermal radiation heat flux"); ShowContinueError("Surface = " + Surface(SurfNum).Name); ShowContinueError("Surface area = " + RoundSigDigits(Surface(SurfNum).Area, 3) + " [m2]"); - ShowContinueError("Occurs in " + cCMO_BBRadiator_Steam + " = " + SteamBaseboard(BaseboardNum).EquipID); - ShowContinueError("Assign a larger surface area or more surfaces in " + cCMO_BBRadiator_Steam); + ShowContinueError("Occurs in " + state.dataSteamBaseboardRadiator->cCMO_BBRadiator_Steam + " = " + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).EquipID); + ShowContinueError("Assign a larger surface area or more surfaces in " + state.dataSteamBaseboardRadiator->cCMO_BBRadiator_Steam); ShowFatalError("DistributeBBSteamRadGains: surface not large enough to receive thermal radiation heat flux"); } } } } - void ReportSteamBaseboard(int const BaseboardNum) + void ReportSteamBaseboard(EnergyPlusData &state, int const BaseboardNum) { // SUBROUTINE INFORMATION: @@ -1445,35 +1336,12 @@ namespace SteamBaseboardRadiator { // MODIFIED na // RE-ENGINEERED na - // PURPOSE OF THIS SUBROUTINE: - - // METHODOLOGY EMPLOYED: - // na - - // REFERENCES: - // na - - // Using/Aliasing using DataSurfaces::Surface; - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - - SteamBaseboard(BaseboardNum).TotEnergy = SteamBaseboard(BaseboardNum).TotPower * TimeStepSys * DataGlobalConstants::SecInHour(); - SteamBaseboard(BaseboardNum).Energy = SteamBaseboard(BaseboardNum).Power * TimeStepSys * DataGlobalConstants::SecInHour(); - SteamBaseboard(BaseboardNum).ConvEnergy = SteamBaseboard(BaseboardNum).ConvPower * TimeStepSys * DataGlobalConstants::SecInHour(); - SteamBaseboard(BaseboardNum).RadEnergy = SteamBaseboard(BaseboardNum).RadPower * TimeStepSys * DataGlobalConstants::SecInHour(); + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).TotEnergy = state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).TotPower * TimeStepSys * DataGlobalConstants::SecInHour(); + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).Energy = state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).Power * TimeStepSys * DataGlobalConstants::SecInHour(); + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).ConvEnergy = state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).ConvPower * TimeStepSys * DataGlobalConstants::SecInHour(); + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).RadEnergy = state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).RadPower * TimeStepSys * DataGlobalConstants::SecInHour(); } Real64 SumHATsurf(int const ZoneNum) // Zone number @@ -1545,7 +1413,7 @@ namespace SteamBaseboardRadiator { return SumHATsurf; } - void UpdateSteamBaseboardPlantConnection(int const BaseboardTypeNum, // type index + void UpdateSteamBaseboardPlantConnection(EnergyPlusData &state, int const BaseboardTypeNum, // type index std::string const &BaseboardName, // component name int const EP_UNUSED(EquipFlowCtrl), // Flow control mode for the equipment int const EP_UNUSED(LoopNum), // Plant loop index for where called from @@ -1587,22 +1455,22 @@ namespace SteamBaseboardRadiator { // Find the correct baseboard if (CompIndex == 0) { - BaseboardNum = UtilityRoutines::FindItemInList(BaseboardName, SteamBaseboard, &SteamBaseboardParams::EquipID); + BaseboardNum = UtilityRoutines::FindItemInList(BaseboardName, state.dataSteamBaseboardRadiator->SteamBaseboard, &SteamBaseboardParams::EquipID); if (BaseboardNum == 0) { ShowFatalError("UpdateSteamBaseboardPlantConnection: Specified baseboard not valid =" + BaseboardName); } CompIndex = BaseboardNum; } else { BaseboardNum = CompIndex; - if (BaseboardNum > NumSteamBaseboards || BaseboardNum < 1) { + if (BaseboardNum > state.dataSteamBaseboardRadiator->NumSteamBaseboards || BaseboardNum < 1) { ShowFatalError("UpdateSteamBaseboardPlantConnection: Invalid CompIndex passed=" + TrimSigDigits(BaseboardNum) + - ", Number of baseboards=" + TrimSigDigits(NumSteamBaseboards) + ", Entered baseboard name=" + BaseboardName); + ", Number of baseboards=" + TrimSigDigits(state.dataSteamBaseboardRadiator->NumSteamBaseboards) + ", Entered baseboard name=" + BaseboardName); } if (KickOffSimulation) { - if (BaseboardName != SteamBaseboard(BaseboardNum).EquipID) { + if (BaseboardName != state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).EquipID) { ShowFatalError("UpdateSteamBaseboardPlantConnection: Invalid CompIndex passed=" + TrimSigDigits(BaseboardNum) + ", baseboard name=" + BaseboardName + - ", stored baseboard Name for that index=" + SteamBaseboard(BaseboardNum).EquipID); + ", stored baseboard Name for that index=" + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).EquipID); } if (BaseboardTypeNum != TypeOf_Baseboard_Rad_Conv_Steam) { ShowFatalError("UpdateSteamBaseboardPlantConnection: Invalid CompIndex passed=" + TrimSigDigits(BaseboardNum) + @@ -1616,35 +1484,35 @@ namespace SteamBaseboardRadiator { return; } - PullCompInterconnectTrigger(SteamBaseboard(BaseboardNum).LoopNum, - SteamBaseboard(BaseboardNum).LoopSideNum, - SteamBaseboard(BaseboardNum).BranchNum, - SteamBaseboard(BaseboardNum).CompNum, - SteamBaseboard(BaseboardNum).BBLoadReSimIndex, - SteamBaseboard(BaseboardNum).LoopNum, - SteamBaseboard(BaseboardNum).LoopSideNum, + PullCompInterconnectTrigger(state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).LoopNum, + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).LoopSideNum, + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).BranchNum, + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).CompNum, + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).BBLoadReSimIndex, + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).LoopNum, + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).LoopSideNum, CriteriaType_HeatTransferRate, - SteamBaseboard(BaseboardNum).Power); - - PullCompInterconnectTrigger(SteamBaseboard(BaseboardNum).LoopNum, - SteamBaseboard(BaseboardNum).LoopSideNum, - SteamBaseboard(BaseboardNum).BranchNum, - SteamBaseboard(BaseboardNum).CompNum, - SteamBaseboard(BaseboardNum).BBLoadReSimIndex, - SteamBaseboard(BaseboardNum).LoopNum, - SteamBaseboard(BaseboardNum).LoopSideNum, + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).Power); + + PullCompInterconnectTrigger(state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).LoopNum, + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).LoopSideNum, + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).BranchNum, + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).CompNum, + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).BBLoadReSimIndex, + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).LoopNum, + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).LoopSideNum, CriteriaType_MassFlowRate, - SteamBaseboard(BaseboardNum).SteamMassFlowRate); - - PullCompInterconnectTrigger(SteamBaseboard(BaseboardNum).LoopNum, - SteamBaseboard(BaseboardNum).LoopSideNum, - SteamBaseboard(BaseboardNum).BranchNum, - SteamBaseboard(BaseboardNum).CompNum, - SteamBaseboard(BaseboardNum).BBLoadReSimIndex, - SteamBaseboard(BaseboardNum).LoopNum, - SteamBaseboard(BaseboardNum).LoopSideNum, + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SteamMassFlowRate); + + PullCompInterconnectTrigger(state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).LoopNum, + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).LoopSideNum, + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).BranchNum, + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).CompNum, + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).BBLoadReSimIndex, + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).LoopNum, + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).LoopSideNum, CriteriaType_Temperature, - SteamBaseboard(BaseboardNum).SteamOutletTemp); + state.dataSteamBaseboardRadiator->SteamBaseboard(BaseboardNum).SteamOutletTemp); } } // namespace SteamBaseboardRadiator diff --git a/src/EnergyPlus/SteamBaseboardRadiator.hh b/src/EnergyPlus/SteamBaseboardRadiator.hh index 90d52033ab6..89cfe9ce7dd 100644 --- a/src/EnergyPlus/SteamBaseboardRadiator.hh +++ b/src/EnergyPlus/SteamBaseboardRadiator.hh @@ -62,35 +62,6 @@ struct EnergyPlusData; namespace SteamBaseboardRadiator { - // Using/Aliasing - - // Data - // MODULE PARAMETER DEFINITIONS - extern std::string const cCMO_BBRadiator_Steam; - - // DERIVED TYPE DEFINITIONS - - // MODULE VARIABLE DECLARATIONS: - extern int NumSteamBaseboards; - extern int SteamIndex; - - extern Array1D QBBSteamRadSource; // Need to keep the last value in case we are still iterating - extern Array1D QBBSteamRadSrcAvg; // Need to keep the last value in case we are still iterating - extern Array1D ZeroSourceSumHATsurf; // Equal to the SumHATsurf for all the walls in a zone - // with no source - - // Record keeping variables used to calculate QBBRadSrcAvg locally - extern Array1D LastQBBSteamRadSrc; // Need to keep the last value in case we are still iterating - extern Array1D LastSysTimeElapsed; // Need to keep the last value in case we are still iterating - extern Array1D LastTimeStepSys; // Need to keep the last value in case we are still iterating - extern Array1D_bool MySizeFlag; - extern Array1D_bool CheckEquipName; - extern Array1D_bool SetLoopIndexFlag; // get loop number flag - - // SUBROUTINE SPECIFICATIONS FOR MODULE BaseboardRadiator - - // Types - struct SteamBaseboardParams { // Members @@ -168,12 +139,6 @@ namespace SteamBaseboardRadiator { } }; - // Object Data - extern Array1D SteamBaseboard; - extern Array1D SteamBaseboardNumericFields; - - // Functions - void SimSteamBaseboard(EnergyPlusData &state, std::string const &EquipName, int const ActualZoneNum, int const ControlledZoneNum, @@ -189,17 +154,17 @@ namespace SteamBaseboardRadiator { void CalcSteamBaseboard(EnergyPlusData &state, int &BaseboardNum, Real64 &LoadMet); - void UpdateSteamBaseboard(int const BaseboardNum); + void UpdateSteamBaseboard(EnergyPlusData &state, int const BaseboardNum); - void UpdateBBSteamRadSourceValAvg(bool &SteamBaseboardSysOn); // .TRUE. if the radiant system has run this zone time step + void UpdateBBSteamRadSourceValAvg(EnergyPlusData &state, bool &SteamBaseboardSysOn); // .TRUE. if the radiant system has run this zone time step - void DistributeBBSteamRadGains(); + void DistributeBBSteamRadGains(EnergyPlusData &state); - void ReportSteamBaseboard(int const BaseboardNum); + void ReportSteamBaseboard(EnergyPlusData &state, int const BaseboardNum); Real64 SumHATsurf(int const ZoneNum); // Zone number - void UpdateSteamBaseboardPlantConnection(int const BaseboardTypeNum, // type index + void UpdateSteamBaseboardPlantConnection(EnergyPlusData &state, int const BaseboardTypeNum, // type index std::string const &BaseboardName, // component name int const EquipFlowCtrl, // Flow control mode for the equipment int const LoopNum, // Plant loop index for where called from @@ -211,6 +176,55 @@ namespace SteamBaseboardRadiator { } // namespace SteamBaseboardRadiator +struct SteamBaseboardRadiatorData : BaseGlobalStruct { + + std::string const cCMO_BBRadiator_Steam = "ZoneHVAC:Baseboard:RadiantConvective:Steam"; + int NumSteamBaseboards = 0; + int SteamIndex = 0; + + Array1D QBBSteamRadSource; // Need to keep the last value in case we are still iterating + Array1D QBBSteamRadSrcAvg; // Need to keep the last value in case we are still iterating + Array1D ZeroSourceSumHATsurf; // Equal to the SumHATsurf for all the walls in a zone + // with no source + + // Record keeping variables used to calculate QBBRadSrcAvg locally + Array1D LastQBBSteamRadSrc; // Need to keep the last value in case we are still iterating + Array1D LastSysTimeElapsed; // Need to keep the last value in case we are still iterating + Array1D LastTimeStepSys; // Need to keep the last value in case we are still iterating + Array1D_bool MySizeFlag; + Array1D_bool CheckEquipName; + Array1D_bool SetLoopIndexFlag; // get loop number flag + + bool GetInputFlag = true; // one time get input flag + bool MyOneTimeFlag = true; + bool ZoneEquipmentListChecked = false; + + Array1D SteamBaseboard; + Array1D SteamBaseboardNumericFields; + + void clear_state() override + { + NumSteamBaseboards = 0; + SteamIndex = 0; + QBBSteamRadSource.clear(); + QBBSteamRadSrcAvg.clear(); + ZeroSourceSumHATsurf.clear(); + LastQBBSteamRadSrc.clear(); + LastSysTimeElapsed.clear(); + LastTimeStepSys.clear(); + MySizeFlag.clear(); + CheckEquipName.clear(); + SetLoopIndexFlag.clear(); + GetInputFlag = true; + MyOneTimeFlag = true; + ZoneEquipmentListChecked = false; + SteamBaseboard.clear(); + SteamBaseboardNumericFields.clear(); + } + + // Default Constructor + SteamBaseboardRadiatorData() = default; +}; } // namespace EnergyPlus #endif From 88bd14af034b0bf77dc21cf168492c0de3176afc Mon Sep 17 00:00:00 2001 From: brianlball Date: Fri, 16 Oct 2020 18:34:05 -0600 Subject: [PATCH 3/8] convert SplitterComponent --- src/EnergyPlus/Data/CommonIncludes.hh | 1 + src/EnergyPlus/Data/EnergyPlusData.cc | 2 + src/EnergyPlus/Data/EnergyPlusData.hh | 2 + src/EnergyPlus/GeneralRoutines.cc | 36 ++- src/EnergyPlus/SimAirServingZones.cc | 57 +--- src/EnergyPlus/SplitterComponent.cc | 371 ++++++++------------------ src/EnergyPlus/SplitterComponent.hh | 100 ++----- src/EnergyPlus/StateManagement.cc | 2 - 8 files changed, 160 insertions(+), 411 deletions(-) diff --git a/src/EnergyPlus/Data/CommonIncludes.hh b/src/EnergyPlus/Data/CommonIncludes.hh index 724dd2e1ba4..c618ac6bf4b 100644 --- a/src/EnergyPlus/Data/CommonIncludes.hh +++ b/src/EnergyPlus/Data/CommonIncludes.hh @@ -82,6 +82,7 @@ #include #include #include +#include #include #include #include diff --git a/src/EnergyPlus/Data/EnergyPlusData.cc b/src/EnergyPlus/Data/EnergyPlusData.cc index 930bd3e1abe..0edfe60c76e 100644 --- a/src/EnergyPlus/Data/EnergyPlusData.cc +++ b/src/EnergyPlus/Data/EnergyPlusData.cc @@ -84,6 +84,7 @@ namespace EnergyPlus { this->dataGlobal = std::unique_ptr(new DataGlobal); this->dataPipes = std::unique_ptr(new PipesData); this->dataPlantChillers = std::unique_ptr(new PlantChillersData); + this->dataSplitterComponent = std::unique_ptr(new SplitterComponentData); this->dataSteamBaseboardRadiator = std::unique_ptr(new SteamBaseboardRadiatorData); this->dataSteamCoils = std::unique_ptr(new SteamCoilsData); this->dataSurfaceGroundHeatExchangers = std::unique_ptr(new SurfaceGroundHeatExchangersData); @@ -148,6 +149,7 @@ namespace EnergyPlus { this->dataGlobal->clear_state(); this->dataPipes->clear_state(); this->dataPlantChillers->clear_state(); + this->dataSplitterComponent->clear_state(); this->dataSteamBaseboardRadiator->clear_state(); this->dataSteamCoils->clear_state(); this->dataSurfaceGroundHeatExchangers->clear_state(); diff --git a/src/EnergyPlus/Data/EnergyPlusData.hh b/src/EnergyPlus/Data/EnergyPlusData.hh index 016f2763c37..4fe016afe4f 100644 --- a/src/EnergyPlus/Data/EnergyPlusData.hh +++ b/src/EnergyPlus/Data/EnergyPlusData.hh @@ -93,6 +93,7 @@ struct ExteriorEnergyUseData; struct FansData; struct PipesData; struct PlantChillersData; +struct SplitterComponentData; struct SteamBaseboardRadiatorData; struct SteamCoilsData; struct SurfaceGroundHeatExchangersData; @@ -160,6 +161,7 @@ struct EnergyPlusData : BaseGlobalStruct { std::unique_ptr dataFans; std::unique_ptr dataPipes; std::unique_ptr dataPlantChillers; + std::unique_ptr dataSplitterComponent; std::unique_ptr dataSteamBaseboardRadiator; std::unique_ptr dataSteamCoils; std::unique_ptr dataSurfaceGroundHeatExchangers; diff --git a/src/EnergyPlus/GeneralRoutines.cc b/src/EnergyPlus/GeneralRoutines.cc index 90ab41ae972..1acffc824f8 100644 --- a/src/EnergyPlus/GeneralRoutines.cc +++ b/src/EnergyPlus/GeneralRoutines.cc @@ -1535,8 +1535,6 @@ void TestSupplyAirPathIntegrity(EnergyPlusData &state, bool &ErrFound) // Using/Aliasing using namespace DataLoopNode; - using SplitterComponent::NumSplitters; - using SplitterComponent::SplitterCond; auto &GetZoneSplitterInput(SplitterComponent::GetSplitterInput); using namespace DataZoneEquipment; using DataHVACGlobals::NumPrimaryAirSys; @@ -1630,25 +1628,25 @@ void TestSupplyAirPathIntegrity(EnergyPlusData &state, bool &ErrFound) } } else if (SELECT_CASE_var == "AIRLOOPHVAC:ZONESPLITTER") { - for (Count2 = 1; Count2 <= NumSplitters; ++Count2) { - if (SplitterCond(Count2).SplitterName != SupplyAirPath(BCount).ComponentName(Count)) continue; - if (Count == 1 && AirPathNodeName != NodeID(SplitterCond(Count2).InletNode)) { + for (Count2 = 1; Count2 <= state.dataSplitterComponent->NumSplitters; ++Count2) { + if (state.dataSplitterComponent->SplitterCond(Count2).SplitterName != SupplyAirPath(BCount).ComponentName(Count)) continue; + if (Count == 1 && AirPathNodeName != NodeID(state.dataSplitterComponent->SplitterCond(Count2).InletNode)) { ShowSevereError("Error in AirLoopHVAC:SupplyPath=" + SupplyAirPath(BCount).Name); - ShowContinueError("For AirLoopHVAC:ZoneSplitter=" + SplitterCond(Count2).SplitterName); + ShowContinueError("For AirLoopHVAC:ZoneSplitter=" + state.dataSplitterComponent->SplitterCond(Count2).SplitterName); ShowContinueError("Expected inlet node (supply air path)=" + AirPathNodeName); - ShowContinueError("Encountered node name (zone splitter)=" + NodeID(SplitterCond(Count2).InletNode)); + ShowContinueError("Encountered node name (zone splitter)=" + NodeID(state.dataSplitterComponent->SplitterCond(Count2).InletNode)); ErrFound = true; ++NumErr; } - print(state.files.bnd, " #Outlet Nodes on Supply Air Path Component,{}\n", SplitterCond(Count2).NumOutletNodes); - for (Count1 = 1; Count1 <= SplitterCond(Count2).NumOutletNodes; ++Count1) { + print(state.files.bnd, " #Outlet Nodes on Supply Air Path Component,{}\n", state.dataSplitterComponent->SplitterCond(Count2).NumOutletNodes); + for (Count1 = 1; Count1 <= state.dataSplitterComponent->SplitterCond(Count2).NumOutletNodes; ++Count1) { print(state.files.bnd, " Supply Air Path Component Nodes,{},{},{},{},{},{}\n", Count1, SupplyAirPath(BCount).ComponentType(Count), SupplyAirPath(BCount).ComponentName(Count), - NodeID(SplitterCond(Count2).InletNode), - NodeID(SplitterCond(Count2).OutletNode(Count1)), + NodeID(state.dataSplitterComponent->SplitterCond(Count2).InletNode), + NodeID(state.dataSplitterComponent->SplitterCond(Count2).OutletNode(Count1)), PrimaryAirLoopName); } } @@ -1691,7 +1689,7 @@ void TestSupplyAirPathIntegrity(EnergyPlusData &state, bool &ErrFound) } } - if (NumSplitters == 0) { + if (state.dataSplitterComponent->NumSplitters == 0) { if (inputProcessor->getNumObjectsFound("AirLoopHVAC:ZoneSplitter") > 0) { GetZoneSplitterInput(state); } @@ -1704,7 +1702,7 @@ void TestSupplyAirPathIntegrity(EnergyPlusData &state, bool &ErrFound) // now the reverse. is every zone splitter and supply plenum on supply air path FoundSupplyPlenum.dimension(state.dataZonePlenum->NumZoneSupplyPlenums, false); - FoundZoneSplitter.dimension(NumSplitters, false); + FoundZoneSplitter.dimension(state.dataSplitterComponent->NumSplitters, false); FoundNames.allocate(state.dataZonePlenum->NumZoneSupplyPlenums); for (Count1 = 1; Count1 <= state.dataZonePlenum->NumZoneSupplyPlenums; ++Count1) { for (BCount = 1; BCount <= NumSupplyAirPaths; ++BCount) { @@ -1725,15 +1723,15 @@ void TestSupplyAirPathIntegrity(EnergyPlusData &state, bool &ErrFound) } } FoundNames.deallocate(); - FoundNames.allocate(NumSplitters); - for (Count1 = 1; Count1 <= NumSplitters; ++Count1) { + FoundNames.allocate(state.dataSplitterComponent->NumSplitters); + for (Count1 = 1; Count1 <= state.dataSplitterComponent->NumSplitters; ++Count1) { for (BCount = 1; BCount <= NumSupplyAirPaths; ++BCount) { for (Count = 1; Count <= SupplyAirPath(BCount).NumOfComponents; ++Count) { - if (SplitterCond(Count1).SplitterName != SupplyAirPath(BCount).ComponentName(Count) || + if (state.dataSplitterComponent->SplitterCond(Count1).SplitterName != SupplyAirPath(BCount).ComponentName(Count) || SupplyAirPath(BCount).ComponentType(Count) != "AIRLOOPHVAC:ZONESPLITTER") continue; if (FoundZoneSplitter(Count1)) { - ShowSevereError("AirLoopHVAC:ZoneSplitter=\"" + SplitterCond(Count1).SplitterName + "\", duplicate entry."); + ShowSevereError("AirLoopHVAC:ZoneSplitter=\"" + state.dataSplitterComponent->SplitterCond(Count1).SplitterName + "\", duplicate entry."); ShowContinueError("already exists on AirLoopHVAC:SupplyPath=\"" + FoundNames(Count1) + "\"."); ErrFound = true; } else { @@ -1755,9 +1753,9 @@ void TestSupplyAirPathIntegrity(EnergyPlusData &state, bool &ErrFound) } if (!all(FoundZoneSplitter)) { - for (Count1 = 1; Count1 <= NumSplitters; ++Count1) { + for (Count1 = 1; Count1 <= state.dataSplitterComponent->NumSplitters; ++Count1) { if (FoundZoneSplitter(Count1)) continue; - ShowSevereError("AirLoopHVAC:ZoneSplitter=\"" + SplitterCond(Count1).SplitterName + "\", not found on any AirLoopHVAC:SupplyPath."); + ShowSevereError("AirLoopHVAC:ZoneSplitter=\"" + state.dataSplitterComponent->SplitterCond(Count1).SplitterName + "\", not found on any AirLoopHVAC:SupplyPath."); // ErrFound=.TRUE. } } diff --git a/src/EnergyPlus/SimAirServingZones.cc b/src/EnergyPlus/SimAirServingZones.cc index 837ed5dea7b..0f58b22600d 100644 --- a/src/EnergyPlus/SimAirServingZones.cc +++ b/src/EnergyPlus/SimAirServingZones.cc @@ -136,14 +136,6 @@ namespace SimAirServingZones { // Successive iteration forward from the return air inlet // to the supply air outlets. - // REFERENCES: - // None - - // OTHER NOTES: - // None - - // USE STATEMENTS - // Using/Aliasing using namespace DataLoopNode; using namespace DataAirLoop; using namespace DataGlobals; @@ -197,11 +189,6 @@ namespace SimAirServingZones { int const UnitarySystemModel(29); int const ZoneVRFasAirLoopEquip(30); - // DERIVED TYPE DEFINITIONS: - // na - - // MODULE VARIABLE DECLARATIONS: - bool GetAirLoopInputFlag(true); // Flag set to make sure you get input once int NumOfTimeStepInDay; // number of zone time steps in a day @@ -219,19 +206,6 @@ namespace SimAirServingZones { bool OutputSetupFlag(false); bool MyEnvrnFlag(true); } // namespace - // Subroutine Specifications for the Module - // Driver/Manager Routines - - // Get Input routines for module - - // Initialization routines for module - - // Simulation subroutines for the module - - // Reporting routines for module - - // MODULE SUBROUTINES: - //************************************************************************* // Functions void clear_state() @@ -266,28 +240,8 @@ namespace SimAirServingZones { // The subroutine performs the usual manager functions: it calls the // Get, Init, Sim, Update, and Report routines. - // METHODOLOGY EMPLOYED: - // not applicable: - - // REFERENCES: None - - // Using/Aliasing using MixedAir::ManageOutsideAirSystem; - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: none - - // INTERFACE BLOCK SPECIFICATIONS: none - // na - - // DERIVED TYPE DEFINITIONS: none - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: none - - // FLOW: - if (GetAirLoopInputFlag) { // First time subroutine has been entered GetAirPathData(state); // Get air loop descriptions from input file GetAirLoopInputFlag = false; @@ -1516,7 +1470,6 @@ namespace SimAirServingZones { using General::FindNumberInList; using Psychrometrics::PsyHFnTdbW; using Psychrometrics::PsyRhoAirFnPbTdbW; - using SplitterComponent::SplitterCond; using SplitterComponent::SplitterConditions; // using ZonePlenum::ZoneSupPlenCond; using ZonePlenum::ZoneSupplyPlenumConditions; @@ -1620,14 +1573,14 @@ namespace SimAirServingZones { for (CompNum = 1; CompNum <= SupplyAirPath(SupAirPath).NumOfComponents; ++CompNum) { if (UtilityRoutines::SameString(SupplyAirPath(SupAirPath).ComponentType(CompNum), "AirLoopHVAC:ZoneSplitter")) { SplitterNum = UtilityRoutines::FindItemInList( - SupplyAirPath(SupAirPath).ComponentName(CompNum), SplitterCond, &SplitterConditions::SplitterName); + SupplyAirPath(SupAirPath).ComponentName(CompNum), state.dataSplitterComponent->SplitterCond, &SplitterConditions::SplitterName); if (SplitterNum == 0) { ShowSevereError("AirLoopHVAC:ZoneSplitter not found=" + SupplyAirPath(SupAirPath).ComponentName(CompNum)); ShowContinueError("Occurs in AirLoopHVAC:SupplyPath=" + SupplyAirPath(SupAirPath).Name); ErrorsFound = true; } SupplyAirPath(SupAirPath).SplitterIndex(CompNum) = SplitterNum; - NumAllSupAirPathNodes += SplitterCond(SplitterNum).NumOutletNodes + 1; + NumAllSupAirPathNodes += state.dataSplitterComponent->SplitterCond(SplitterNum).NumOutletNodes + 1; } else if (UtilityRoutines::SameString(SupplyAirPath(SupAirPath).ComponentType(CompNum), "AirLoopHVAC:SupplyPlenum")) { PlenumNum = UtilityRoutines::FindItemInList(SupplyAirPath(SupAirPath).ComponentName(CompNum), state.dataZonePlenum->ZoneSupPlenCond, @@ -1651,15 +1604,15 @@ namespace SimAirServingZones { PlenumNum = SupplyAirPath(SupAirPath).PlenumIndex(CompNum); if (SplitterNum > 0) { ++SupAirPathNodeNum; - SupNode(SupAirPathNodeNum) = SplitterCond(SplitterNum).InletNode; + SupNode(SupAirPathNodeNum) = state.dataSplitterComponent->SplitterCond(SplitterNum).InletNode; if (CompNum == 1) { SupNodeType(SupAirPathNodeNum) = PathInlet; } else { SupNodeType(SupAirPathNodeNum) = CompInlet; } - for (SplitterOutNum = 1; SplitterOutNum <= SplitterCond(SplitterNum).NumOutletNodes; ++SplitterOutNum) { + for (SplitterOutNum = 1; SplitterOutNum <= state.dataSplitterComponent->SplitterCond(SplitterNum).NumOutletNodes; ++SplitterOutNum) { ++SupAirPathNodeNum; - SupNode(SupAirPathNodeNum) = SplitterCond(SplitterNum).OutletNode(SplitterOutNum); + SupNode(SupAirPathNodeNum) = state.dataSplitterComponent->SplitterCond(SplitterNum).OutletNode(SplitterOutNum); SupNodeType(SupAirPathNodeNum) = 0; } } else if (PlenumNum > 0) { diff --git a/src/EnergyPlus/SplitterComponent.cc b/src/EnergyPlus/SplitterComponent.cc index e7e27c756cd..a7cabe4c666 100644 --- a/src/EnergyPlus/SplitterComponent.cc +++ b/src/EnergyPlus/SplitterComponent.cc @@ -49,6 +49,7 @@ #include // EnergyPlus Headers +#include #include #include #include @@ -74,62 +75,9 @@ namespace SplitterComponent { // To encapsulate the data and algorithms required to // manage Air Path Splitter Components - // METHODOLOGY EMPLOYED: - - // REFERENCES: - - // OTHER NOTES: - - // USE STATEMENTS: - // Use statements for data only modules - // Using/Aliasing using namespace DataGlobals; using namespace DataLoopNode; - // Data - // MODULE PARAMETERS: - - // MODULE PARAMETER DEFINITIONS - // na - - // DERIVED TYPE DEFINITIONS - - // MODULE VARIABLE DECLARATIONS: - bool GetSplitterInputFlag(true); - // Public because Used by SimAirServingZones and the Direct Air Unit - int NumSplitters(0); // The Number of Splitters found in the Input - Array1D_bool CheckEquipName; - bool MyEnvrnFlag(true); - - // Subroutine Specifications for the Module - // Driver/Manager Routines - - // Get Input routines for module - - // Initialization routines for module - - // Algorithms for the module - - // Update routine to check convergence and update nodes - - // Reporting routines for module - - // Object Data - Array1D SplitterCond; - - // MODULE SUBROUTINES: - //************************************************************************* - - // Functions - void clear_state() - { - GetSplitterInputFlag = true; - NumSplitters = 0; - CheckEquipName.deallocate(); - SplitterCond.deallocate(); - MyEnvrnFlag = true; - } - void SimAirLoopSplitter(EnergyPlusData &state, std::string const &CompName, bool const FirstHVACIteration, bool const FirstCall, bool &SplitterInletChanged, int &CompIndex) { @@ -151,41 +99,39 @@ namespace SplitterComponent { // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int SplitterNum; // The Splitter that you are currently loading input for - // FLOW: - // Obtains and Allocates Splitter related parameters from input file - if (GetSplitterInputFlag) { // First time subroutine has been entered + if (state.dataSplitterComponent->GetSplitterInputFlag) { // First time subroutine has been entered GetSplitterInput(state); } // Find the correct SplitterNumber if (CompIndex == 0) { - SplitterNum = UtilityRoutines::FindItemInList(CompName, SplitterCond, &SplitterConditions::SplitterName); + SplitterNum = UtilityRoutines::FindItemInList(CompName, state.dataSplitterComponent->SplitterCond, &SplitterConditions::SplitterName); if (SplitterNum == 0) { ShowFatalError("SimAirLoopSplitter: Splitter not found=" + CompName); } CompIndex = SplitterNum; } else { SplitterNum = CompIndex; - if (SplitterNum > NumSplitters || SplitterNum < 1) { + if (SplitterNum > state.dataSplitterComponent->NumSplitters || SplitterNum < 1) { ShowFatalError("SimAirLoopSplitter: Invalid CompIndex passed=" + TrimSigDigits(SplitterNum) + - ", Number of Splitters=" + TrimSigDigits(NumSplitters) + ", Splitter name=" + CompName); + ", Number of Splitters=" + TrimSigDigits(state.dataSplitterComponent->NumSplitters) + ", Splitter name=" + CompName); } - if (CheckEquipName(SplitterNum)) { - if (CompName != SplitterCond(SplitterNum).SplitterName) { + if (state.dataSplitterComponent->CheckEquipName(SplitterNum)) { + if (CompName != state.dataSplitterComponent->SplitterCond(SplitterNum).SplitterName) { ShowFatalError("SimAirLoopSplitter: Invalid CompIndex passed=" + TrimSigDigits(SplitterNum) + ", Splitter name=" + CompName + - ", stored Splitter Name for that index=" + SplitterCond(SplitterNum).SplitterName); + ", stored Splitter Name for that index=" + state.dataSplitterComponent->SplitterCond(SplitterNum).SplitterName); } - CheckEquipName(SplitterNum) = false; + state.dataSplitterComponent->CheckEquipName(SplitterNum) = false; } } - InitAirLoopSplitter(SplitterNum, FirstHVACIteration, FirstCall); // Initialize all Splitter related parameters + InitAirLoopSplitter(state, SplitterNum, FirstHVACIteration, FirstCall); // Initialize all Splitter related parameters - CalcAirLoopSplitter(SplitterNum, FirstCall); + CalcAirLoopSplitter(state, SplitterNum, FirstCall); // Update the current Splitter to the outlet nodes - UpdateSplitter(SplitterNum, SplitterInletChanged, FirstCall); + UpdateSplitter(state, SplitterNum, SplitterInletChanged, FirstCall); // Report the current Splitter ReportSplitter(SplitterNum); @@ -239,14 +185,14 @@ namespace SplitterComponent { Array1D_bool lNumericBlanks; // Logical array, numeric field input BLANK = .TRUE. // RESET THE GETINPUT FLAG - GetSplitterInputFlag = false; + state.dataSplitterComponent->GetSplitterInputFlag = false; // Flow CurrentModuleObject = "AirLoopHVAC:ZoneSplitter"; - NumSplitters = inputProcessor->getNumObjectsFound(CurrentModuleObject); + state.dataSplitterComponent->NumSplitters = inputProcessor->getNumObjectsFound(CurrentModuleObject); - if (NumSplitters > 0) SplitterCond.allocate(NumSplitters); - CheckEquipName.dimension(NumSplitters, true); + if (state.dataSplitterComponent->NumSplitters > 0) state.dataSplitterComponent->SplitterCond.allocate(state.dataSplitterComponent->NumSplitters); + state.dataSplitterComponent->CheckEquipName.dimension(state.dataSplitterComponent->NumSplitters, true); inputProcessor->getObjectDefMaxArgs(CurrentModuleObject, NumParams, NumAlphas, NumNums); AlphArray.allocate(NumAlphas); @@ -256,7 +202,7 @@ namespace SplitterComponent { lNumericBlanks.dimension(NumNums, true); NumArray.dimension(NumNums, 0.0); - for (SplitterNum = 1; SplitterNum <= NumSplitters; ++SplitterNum) { + for (SplitterNum = 1; SplitterNum <= state.dataSplitterComponent->NumSplitters; ++SplitterNum) { inputProcessor->getObjectItem(state, CurrentModuleObject, SplitterNum, @@ -271,27 +217,27 @@ namespace SplitterComponent { cNumericFields); UtilityRoutines::IsNameEmpty(AlphArray(1), CurrentModuleObject, ErrorsFound); - SplitterCond(SplitterNum).SplitterName = AlphArray(1); - SplitterCond(SplitterNum).InletNode = GetOnlySingleNode(state, + state.dataSplitterComponent->SplitterCond(SplitterNum).SplitterName = AlphArray(1); + state.dataSplitterComponent->SplitterCond(SplitterNum).InletNode = GetOnlySingleNode(state, AlphArray(2), ErrorsFound, CurrentModuleObject, AlphArray(1), NodeType_Air, NodeConnectionType_Inlet, 1, ObjectIsNotParent); - SplitterCond(SplitterNum).NumOutletNodes = NumAlphas - 2; + state.dataSplitterComponent->SplitterCond(SplitterNum).NumOutletNodes = NumAlphas - 2; - SplitterCond(SplitterNum).OutletNode.allocate(SplitterCond(SplitterNum).NumOutletNodes); - SplitterCond(SplitterNum).OutletMassFlowRate.allocate(SplitterCond(SplitterNum).NumOutletNodes); - SplitterCond(SplitterNum).OutletMassFlowRateMaxAvail.allocate(SplitterCond(SplitterNum).NumOutletNodes); - SplitterCond(SplitterNum).OutletMassFlowRateMinAvail.allocate(SplitterCond(SplitterNum).NumOutletNodes); - SplitterCond(SplitterNum).OutletTemp.allocate(SplitterCond(SplitterNum).NumOutletNodes); - SplitterCond(SplitterNum).OutletHumRat.allocate(SplitterCond(SplitterNum).NumOutletNodes); - SplitterCond(SplitterNum).OutletEnthalpy.allocate(SplitterCond(SplitterNum).NumOutletNodes); - SplitterCond(SplitterNum).OutletPressure.allocate(SplitterCond(SplitterNum).NumOutletNodes); + state.dataSplitterComponent->SplitterCond(SplitterNum).OutletNode.allocate(state.dataSplitterComponent->SplitterCond(SplitterNum).NumOutletNodes); + state.dataSplitterComponent->SplitterCond(SplitterNum).OutletMassFlowRate.allocate(state.dataSplitterComponent->SplitterCond(SplitterNum).NumOutletNodes); + state.dataSplitterComponent->SplitterCond(SplitterNum).OutletMassFlowRateMaxAvail.allocate(state.dataSplitterComponent->SplitterCond(SplitterNum).NumOutletNodes); + state.dataSplitterComponent->SplitterCond(SplitterNum).OutletMassFlowRateMinAvail.allocate(state.dataSplitterComponent->SplitterCond(SplitterNum).NumOutletNodes); + state.dataSplitterComponent->SplitterCond(SplitterNum).OutletTemp.allocate(state.dataSplitterComponent->SplitterCond(SplitterNum).NumOutletNodes); + state.dataSplitterComponent->SplitterCond(SplitterNum).OutletHumRat.allocate(state.dataSplitterComponent->SplitterCond(SplitterNum).NumOutletNodes); + state.dataSplitterComponent->SplitterCond(SplitterNum).OutletEnthalpy.allocate(state.dataSplitterComponent->SplitterCond(SplitterNum).NumOutletNodes); + state.dataSplitterComponent->SplitterCond(SplitterNum).OutletPressure.allocate(state.dataSplitterComponent->SplitterCond(SplitterNum).NumOutletNodes); - SplitterCond(SplitterNum).InletMassFlowRate = 0.0; - SplitterCond(SplitterNum).InletMassFlowRateMaxAvail = 0.0; - SplitterCond(SplitterNum).InletMassFlowRateMinAvail = 0.0; + state.dataSplitterComponent->SplitterCond(SplitterNum).InletMassFlowRate = 0.0; + state.dataSplitterComponent->SplitterCond(SplitterNum).InletMassFlowRateMaxAvail = 0.0; + state.dataSplitterComponent->SplitterCond(SplitterNum).InletMassFlowRateMinAvail = 0.0; - for (NodeNum = 1; NodeNum <= SplitterCond(SplitterNum).NumOutletNodes; ++NodeNum) { + for (NodeNum = 1; NodeNum <= state.dataSplitterComponent->SplitterCond(SplitterNum).NumOutletNodes; ++NodeNum) { - SplitterCond(SplitterNum).OutletNode(NodeNum) = GetOnlySingleNode(state, AlphArray(2 + NodeNum), + state.dataSplitterComponent->SplitterCond(SplitterNum).OutletNode(NodeNum) = GetOnlySingleNode(state, AlphArray(2 + NodeNum), ErrorsFound, CurrentModuleObject, AlphArray(1), @@ -308,20 +254,20 @@ namespace SplitterComponent { } // end Number of Splitter Loop // Check for duplicate names specified in Zone Splitter - for (SplitterNum = 1; SplitterNum <= NumSplitters; ++SplitterNum) { - NodeNum = SplitterCond(SplitterNum).InletNode; - for (OutNodeNum1 = 1; OutNodeNum1 <= SplitterCond(SplitterNum).NumOutletNodes; ++OutNodeNum1) { - if (NodeNum != SplitterCond(SplitterNum).OutletNode(OutNodeNum1)) continue; - ShowSevereError(CurrentModuleObject + " = " + SplitterCond(SplitterNum).SplitterName + + for (SplitterNum = 1; SplitterNum <= state.dataSplitterComponent->NumSplitters; ++SplitterNum) { + NodeNum = state.dataSplitterComponent->SplitterCond(SplitterNum).InletNode; + for (OutNodeNum1 = 1; OutNodeNum1 <= state.dataSplitterComponent->SplitterCond(SplitterNum).NumOutletNodes; ++OutNodeNum1) { + if (NodeNum != state.dataSplitterComponent->SplitterCond(SplitterNum).OutletNode(OutNodeNum1)) continue; + ShowSevereError(CurrentModuleObject + " = " + state.dataSplitterComponent->SplitterCond(SplitterNum).SplitterName + " specifies an outlet node name the same as the inlet node."); ShowContinueError(".." + cAlphaFields(2) + '=' + NodeID(NodeNum)); ShowContinueError("..Outlet Node #" + TrimSigDigits(OutNodeNum1) + " is duplicate."); ErrorsFound = true; } - for (OutNodeNum1 = 1; OutNodeNum1 <= SplitterCond(SplitterNum).NumOutletNodes; ++OutNodeNum1) { - for (OutNodeNum2 = OutNodeNum1 + 1; OutNodeNum2 <= SplitterCond(SplitterNum).NumOutletNodes; ++OutNodeNum2) { - if (SplitterCond(SplitterNum).OutletNode(OutNodeNum1) != SplitterCond(SplitterNum).OutletNode(OutNodeNum2)) continue; - ShowSevereError(CurrentModuleObject + " = " + SplitterCond(SplitterNum).SplitterName + + for (OutNodeNum1 = 1; OutNodeNum1 <= state.dataSplitterComponent->SplitterCond(SplitterNum).NumOutletNodes; ++OutNodeNum1) { + for (OutNodeNum2 = OutNodeNum1 + 1; OutNodeNum2 <= state.dataSplitterComponent->SplitterCond(SplitterNum).NumOutletNodes; ++OutNodeNum2) { + if (state.dataSplitterComponent->SplitterCond(SplitterNum).OutletNode(OutNodeNum1) != state.dataSplitterComponent->SplitterCond(SplitterNum).OutletNode(OutNodeNum2)) continue; + ShowSevereError(CurrentModuleObject + " = " + state.dataSplitterComponent->SplitterCond(SplitterNum).SplitterName + " specifies duplicate outlet nodes in its outlet node list."); ShowContinueError("..Outlet Node #" + TrimSigDigits(OutNodeNum1) + " Name=" + NodeID(OutNodeNum1)); ShowContinueError("..Outlet Node #" + TrimSigDigits(OutNodeNum2) + " is duplicate."); @@ -342,13 +288,7 @@ namespace SplitterComponent { } } - // End of Get Input subroutines for the HB Module - //****************************************************************************** - - // Beginning Initialization Section of the Module - //****************************************************************************** - - void InitAirLoopSplitter(int const SplitterNum, bool const FirstHVACIteration, bool const FirstCall) + void InitAirLoopSplitter(EnergyPlusData &state, int const SplitterNum, bool const FirstHVACIteration, bool const FirstCall) { // SUBROUTINE INFORMATION: @@ -363,10 +303,6 @@ namespace SplitterComponent { // METHODOLOGY EMPLOYED: // Uses the status flags to trigger events. - // REFERENCES: - // na - - // Using/Aliasing using DataContaminantBalance::Contaminant; using DataContaminantBalance::OutdoorCO2; using DataContaminantBalance::OutdoorGC; @@ -374,35 +310,20 @@ namespace SplitterComponent { using DataEnvironment::OutHumRat; using Psychrometrics::PsyHFnTdbW; - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int InletNode; int OutletNode; int NodeNum; Real64 AirEnthalpy; // [J/kg] - // FLOW: - // Do the Begin Environment initializations - if (BeginEnvrnFlag && MyEnvrnFlag) { + if (BeginEnvrnFlag && state.dataSplitterComponent->MyEnvrnFlag) { // Calculate the air density and enthalpy for standard conditions... AirEnthalpy = PsyHFnTdbW(20.0, OutHumRat); // Initialize the inlet node to s standard set of conditions so that the // flows match around the loop & do not cause convergence problems. - InletNode = SplitterCond(SplitterNum).InletNode; + InletNode = state.dataSplitterComponent->SplitterCond(SplitterNum).InletNode; Node(InletNode).Temp = 20.0; Node(InletNode).HumRat = OutHumRat; Node(InletNode).Enthalpy = AirEnthalpy; @@ -414,15 +335,15 @@ namespace SplitterComponent { Node(InletNode).GenContam = OutdoorGC; } - MyEnvrnFlag = false; + state.dataSplitterComponent->MyEnvrnFlag = false; } if (!BeginEnvrnFlag) { - MyEnvrnFlag = true; + state.dataSplitterComponent->MyEnvrnFlag = true; } // Set the inlet node for the Splitter - InletNode = SplitterCond(SplitterNum).InletNode; + InletNode = state.dataSplitterComponent->SplitterCond(SplitterNum).InletNode; // Do the following initializations (every time step): This should be the info from // the previous components outlets or the node data in this section. @@ -439,15 +360,15 @@ namespace SplitterComponent { // correct flow and that is used and passed back upstream. if (FirstHVACIteration && FirstCall) { if (Node(InletNode).MassFlowRate > 0.0) { - for (NodeNum = 1; NodeNum <= SplitterCond(SplitterNum).NumOutletNodes; ++NodeNum) { - OutletNode = SplitterCond(SplitterNum).OutletNode(NodeNum); - Node(OutletNode).MassFlowRate = Node(InletNode).MassFlowRate / SplitterCond(SplitterNum).NumOutletNodes; + for (NodeNum = 1; NodeNum <= state.dataSplitterComponent->SplitterCond(SplitterNum).NumOutletNodes; ++NodeNum) { + OutletNode = state.dataSplitterComponent->SplitterCond(SplitterNum).OutletNode(NodeNum); + Node(OutletNode).MassFlowRate = Node(InletNode).MassFlowRate / state.dataSplitterComponent->SplitterCond(SplitterNum).NumOutletNodes; } } if (Node(InletNode).MassFlowRateMaxAvail > 0.0) { - for (NodeNum = 1; NodeNum <= SplitterCond(SplitterNum).NumOutletNodes; ++NodeNum) { - OutletNode = SplitterCond(SplitterNum).OutletNode(NodeNum); - Node(OutletNode).MassFlowRateMaxAvail = Node(InletNode).MassFlowRateMaxAvail / SplitterCond(SplitterNum).NumOutletNodes; + for (NodeNum = 1; NodeNum <= state.dataSplitterComponent->SplitterCond(SplitterNum).NumOutletNodes; ++NodeNum) { + OutletNode = state.dataSplitterComponent->SplitterCond(SplitterNum).OutletNode(NodeNum); + Node(OutletNode).MassFlowRateMaxAvail = Node(InletNode).MassFlowRateMaxAvail / state.dataSplitterComponent->SplitterCond(SplitterNum).NumOutletNodes; } } @@ -460,9 +381,9 @@ namespace SplitterComponent { // this IF is jumped over. if (Node(InletNode).MassFlowRateMaxAvail == 0.0) { - for (NodeNum = 1; NodeNum <= SplitterCond(SplitterNum).NumOutletNodes; ++NodeNum) { + for (NodeNum = 1; NodeNum <= state.dataSplitterComponent->SplitterCond(SplitterNum).NumOutletNodes; ++NodeNum) { - OutletNode = SplitterCond(SplitterNum).OutletNode(NodeNum); + OutletNode = state.dataSplitterComponent->SplitterCond(SplitterNum).OutletNode(NodeNum); Node(OutletNode).MassFlowRate = 0.0; Node(OutletNode).MassFlowRateMaxAvail = 0.0; Node(OutletNode).MassFlowRateMinAvail = 0.0; @@ -471,32 +392,26 @@ namespace SplitterComponent { // Pass the State Properties through every time. This is what mainly happens each time // through the splitter, - InletNode = SplitterCond(SplitterNum).InletNode; - SplitterCond(SplitterNum).InletTemp = Node(InletNode).Temp; - SplitterCond(SplitterNum).InletHumRat = Node(InletNode).HumRat; - SplitterCond(SplitterNum).InletEnthalpy = Node(InletNode).Enthalpy; - SplitterCond(SplitterNum).InletPressure = Node(InletNode).Press; + InletNode = state.dataSplitterComponent->SplitterCond(SplitterNum).InletNode; + state.dataSplitterComponent->SplitterCond(SplitterNum).InletTemp = Node(InletNode).Temp; + state.dataSplitterComponent->SplitterCond(SplitterNum).InletHumRat = Node(InletNode).HumRat; + state.dataSplitterComponent->SplitterCond(SplitterNum).InletEnthalpy = Node(InletNode).Enthalpy; + state.dataSplitterComponent->SplitterCond(SplitterNum).InletPressure = Node(InletNode).Press; } else { // On the second call from the ZoneEquipManager this is where the flows are passed back to // the splitter inlet. - for (NodeNum = 1; NodeNum <= SplitterCond(SplitterNum).NumOutletNodes; ++NodeNum) { + for (NodeNum = 1; NodeNum <= state.dataSplitterComponent->SplitterCond(SplitterNum).NumOutletNodes; ++NodeNum) { - OutletNode = SplitterCond(SplitterNum).OutletNode(NodeNum); - SplitterCond(SplitterNum).OutletMassFlowRate(NodeNum) = Node(OutletNode).MassFlowRate; - SplitterCond(SplitterNum).OutletMassFlowRateMaxAvail(NodeNum) = Node(OutletNode).MassFlowRateMaxAvail; - SplitterCond(SplitterNum).OutletMassFlowRateMinAvail(NodeNum) = Node(OutletNode).MassFlowRateMinAvail; + OutletNode = state.dataSplitterComponent->SplitterCond(SplitterNum).OutletNode(NodeNum); + state.dataSplitterComponent->SplitterCond(SplitterNum).OutletMassFlowRate(NodeNum) = Node(OutletNode).MassFlowRate; + state.dataSplitterComponent->SplitterCond(SplitterNum).OutletMassFlowRateMaxAvail(NodeNum) = Node(OutletNode).MassFlowRateMaxAvail; + state.dataSplitterComponent->SplitterCond(SplitterNum).OutletMassFlowRateMinAvail(NodeNum) = Node(OutletNode).MassFlowRateMinAvail; } } // For FirstCall } - // End Initialization Section of the Module - //****************************************************************************** - - // Begin Algorithm Section of the Module - //****************************************************************************** - - void CalcAirLoopSplitter(int const SplitterNum, bool const FirstCall) + void CalcAirLoopSplitter(EnergyPlusData &state, int const SplitterNum, bool const FirstCall) { // SUBROUTINE INFORMATION: @@ -511,47 +426,28 @@ namespace SplitterComponent { // METHODOLOGY EMPLOYED: // Needs description, as appropriate. - // REFERENCES: - // na - - // USE STATEMENTS: - // na - - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int OutletNodeNum; // The first time through the State properties are split and passed through if (FirstCall) { // Moisture balance to get outlet air humidity ratio - for (OutletNodeNum = 1; OutletNodeNum <= SplitterCond(SplitterNum).NumOutletNodes; ++OutletNodeNum) { - SplitterCond(SplitterNum).OutletHumRat(OutletNodeNum) = SplitterCond(SplitterNum).InletHumRat; + for (OutletNodeNum = 1; OutletNodeNum <= state.dataSplitterComponent->SplitterCond(SplitterNum).NumOutletNodes; ++OutletNodeNum) { + state.dataSplitterComponent->SplitterCond(SplitterNum).OutletHumRat(OutletNodeNum) = state.dataSplitterComponent->SplitterCond(SplitterNum).InletHumRat; } // "Momentum balance" to get outlet air pressure - for (OutletNodeNum = 1; OutletNodeNum <= SplitterCond(SplitterNum).NumOutletNodes; ++OutletNodeNum) { - SplitterCond(SplitterNum).OutletPressure(OutletNodeNum) = SplitterCond(SplitterNum).InletPressure; + for (OutletNodeNum = 1; OutletNodeNum <= state.dataSplitterComponent->SplitterCond(SplitterNum).NumOutletNodes; ++OutletNodeNum) { + state.dataSplitterComponent->SplitterCond(SplitterNum).OutletPressure(OutletNodeNum) = state.dataSplitterComponent->SplitterCond(SplitterNum).InletPressure; } // Energy balance to get outlet air enthalpy - for (OutletNodeNum = 1; OutletNodeNum <= SplitterCond(SplitterNum).NumOutletNodes; ++OutletNodeNum) { - SplitterCond(SplitterNum).OutletEnthalpy(OutletNodeNum) = SplitterCond(SplitterNum).InletEnthalpy; + for (OutletNodeNum = 1; OutletNodeNum <= state.dataSplitterComponent->SplitterCond(SplitterNum).NumOutletNodes; ++OutletNodeNum) { + state.dataSplitterComponent->SplitterCond(SplitterNum).OutletEnthalpy(OutletNodeNum) = state.dataSplitterComponent->SplitterCond(SplitterNum).InletEnthalpy; } // Set outlet temperatures equal to inlet temperature - for (OutletNodeNum = 1; OutletNodeNum <= SplitterCond(SplitterNum).NumOutletNodes; ++OutletNodeNum) { - SplitterCond(SplitterNum).OutletTemp(OutletNodeNum) = SplitterCond(SplitterNum).InletTemp; + for (OutletNodeNum = 1; OutletNodeNum <= state.dataSplitterComponent->SplitterCond(SplitterNum).NumOutletNodes; ++OutletNodeNum) { + state.dataSplitterComponent->SplitterCond(SplitterNum).OutletTemp(OutletNodeNum) = state.dataSplitterComponent->SplitterCond(SplitterNum).InletTemp; } } else { @@ -559,15 +455,15 @@ namespace SplitterComponent { // summed and then assigned upstream to the inlet node. // Overall Mass Continuity Equation to get inlet mass flow rates // Zero the inlet Totals before the Inlets are summed - SplitterCond(SplitterNum).InletMassFlowRate = 0.0; - SplitterCond(SplitterNum).InletMassFlowRateMaxAvail = 0.0; - SplitterCond(SplitterNum).InletMassFlowRateMinAvail = 0.0; + state.dataSplitterComponent->SplitterCond(SplitterNum).InletMassFlowRate = 0.0; + state.dataSplitterComponent->SplitterCond(SplitterNum).InletMassFlowRateMaxAvail = 0.0; + state.dataSplitterComponent->SplitterCond(SplitterNum).InletMassFlowRateMinAvail = 0.0; - for (OutletNodeNum = 1; OutletNodeNum <= SplitterCond(SplitterNum).NumOutletNodes; ++OutletNodeNum) { - SplitterCond(SplitterNum).InletMassFlowRate += SplitterCond(SplitterNum).OutletMassFlowRate(OutletNodeNum); + for (OutletNodeNum = 1; OutletNodeNum <= state.dataSplitterComponent->SplitterCond(SplitterNum).NumOutletNodes; ++OutletNodeNum) { + state.dataSplitterComponent->SplitterCond(SplitterNum).InletMassFlowRate += state.dataSplitterComponent->SplitterCond(SplitterNum).OutletMassFlowRate(OutletNodeNum); - SplitterCond(SplitterNum).InletMassFlowRateMaxAvail += SplitterCond(SplitterNum).OutletMassFlowRateMaxAvail(OutletNodeNum); - SplitterCond(SplitterNum).InletMassFlowRateMinAvail += SplitterCond(SplitterNum).OutletMassFlowRateMinAvail(OutletNodeNum); + state.dataSplitterComponent->SplitterCond(SplitterNum).InletMassFlowRateMaxAvail += state.dataSplitterComponent->SplitterCond(SplitterNum).OutletMassFlowRateMaxAvail(OutletNodeNum); + state.dataSplitterComponent->SplitterCond(SplitterNum).InletMassFlowRateMinAvail += state.dataSplitterComponent->SplitterCond(SplitterNum).OutletMassFlowRateMinAvail(OutletNodeNum); } // What happens if Splitter inlet mass flow rate is greater than max available @@ -580,7 +476,7 @@ namespace SplitterComponent { // Beginning of Update subroutines for the Splitter Module // ***************************************************************************** - void UpdateSplitter(int const SplitterNum, bool &SplitterInletChanged, bool const FirstCall) + void UpdateSplitter(EnergyPlusData &state, int const SplitterNum, bool &SplitterInletChanged, bool const FirstCall) { // SUBROUTINE INFORMATION: // AUTHOR Richard J. Liesen @@ -588,49 +484,28 @@ namespace SplitterComponent { // MODIFIED na // RE-ENGINEERED na - // PURPOSE OF THIS SUBROUTINE: - // This subroutine needs a description. - - // METHODOLOGY EMPLOYED: - // Needs description, as appropriate. - - // REFERENCES: - // na - - // Using/Aliasing using DataContaminantBalance::Contaminant; - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: Real64 const FlowRateToler(0.01); // Tolerance for mass flow rate convergence (in kg/s) - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int InletNode; int OutletNode; int NodeNum; // Set the inlet node for this splitter to be used throughout subroutine for either case - InletNode = SplitterCond(SplitterNum).InletNode; + InletNode = state.dataSplitterComponent->SplitterCond(SplitterNum).InletNode; // On the FirstCall the State properties are passed through and the mass flows are not dealt with // except for NO flow conditions if (FirstCall) { // Set the outlet nodes for properties that just pass through & not used - for (NodeNum = 1; NodeNum <= SplitterCond(SplitterNum).NumOutletNodes; ++NodeNum) { - OutletNode = SplitterCond(SplitterNum).OutletNode(NodeNum); - Node(OutletNode).Temp = SplitterCond(SplitterNum).OutletTemp(NodeNum); - Node(OutletNode).HumRat = SplitterCond(SplitterNum).OutletHumRat(NodeNum); - Node(OutletNode).Enthalpy = SplitterCond(SplitterNum).OutletEnthalpy(NodeNum); + for (NodeNum = 1; NodeNum <= state.dataSplitterComponent->SplitterCond(SplitterNum).NumOutletNodes; ++NodeNum) { + OutletNode = state.dataSplitterComponent->SplitterCond(SplitterNum).OutletNode(NodeNum); + Node(OutletNode).Temp = state.dataSplitterComponent->SplitterCond(SplitterNum).OutletTemp(NodeNum); + Node(OutletNode).HumRat = state.dataSplitterComponent->SplitterCond(SplitterNum).OutletHumRat(NodeNum); + Node(OutletNode).Enthalpy = state.dataSplitterComponent->SplitterCond(SplitterNum).OutletEnthalpy(NodeNum); Node(OutletNode).Quality = Node(InletNode).Quality; - Node(OutletNode).Press = SplitterCond(SplitterNum).OutletPressure(NodeNum); + Node(OutletNode).Press = state.dataSplitterComponent->SplitterCond(SplitterNum).OutletPressure(NodeNum); if (Contaminant.CO2Simulation) { Node(OutletNode).CO2 = Node(InletNode).CO2; } @@ -647,22 +522,16 @@ namespace SplitterComponent { // Set the outlet air nodes of the Splitter if the splitter results have changed // beyond the tolerance. - if (std::abs(Node(InletNode).MassFlowRate - SplitterCond(SplitterNum).InletMassFlowRate) > FlowRateToler) { + if (std::abs(Node(InletNode).MassFlowRate - state.dataSplitterComponent->SplitterCond(SplitterNum).InletMassFlowRate) > FlowRateToler) { SplitterInletChanged = true; } - Node(InletNode).MassFlowRate = SplitterCond(SplitterNum).InletMassFlowRate; - Node(InletNode).MassFlowRateMaxAvail = SplitterCond(SplitterNum).InletMassFlowRateMaxAvail; - Node(InletNode).MassFlowRateMinAvail = SplitterCond(SplitterNum).InletMassFlowRateMinAvail; + Node(InletNode).MassFlowRate = state.dataSplitterComponent->SplitterCond(SplitterNum).InletMassFlowRate; + Node(InletNode).MassFlowRateMaxAvail = state.dataSplitterComponent->SplitterCond(SplitterNum).InletMassFlowRateMaxAvail; + Node(InletNode).MassFlowRateMinAvail = state.dataSplitterComponent->SplitterCond(SplitterNum).InletMassFlowRateMinAvail; } // The FirstCall END IF } - // End of Update subroutines for the Splitter Module - // ***************************************************************************** - - // Beginning of Reporting subroutines for the Splitter Module - // ***************************************************************************** - void ReportSplitter(int const EP_UNUSED(SplitterNum)) { @@ -672,33 +541,6 @@ namespace SplitterComponent { // MODIFIED na // RE-ENGINEERED na - // PURPOSE OF THIS SUBROUTINE: - // This subroutine needs a description. - - // METHODOLOGY EMPLOYED: - // Needs description, as appropriate. - - // REFERENCES: - // na - - // USE STATEMENTS: - // na - - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - // na - // Write(*,*)=SplitterCond(SplitterNum)%SplitterPower Still needs to report the Splitter power from this component } @@ -727,19 +569,19 @@ namespace SplitterComponent { int WhichSplitter; // Obtains and Allocates AirLoopHVAC:ZoneSplitter related parameters from input file - if (GetSplitterInputFlag) { // First time subroutine has been entered + if (state.dataSplitterComponent->GetSplitterInputFlag) { // First time subroutine has been entered GetSplitterInput(state); - GetSplitterInputFlag = false; + state.dataSplitterComponent->GetSplitterInputFlag = false; } if (SplitterNum == 0) { - WhichSplitter = UtilityRoutines::FindItemInList(SplitterName, SplitterCond, &SplitterConditions::SplitterName); + WhichSplitter = UtilityRoutines::FindItemInList(SplitterName, state.dataSplitterComponent->SplitterCond, &SplitterConditions::SplitterName); } else { WhichSplitter = SplitterNum; } if (WhichSplitter != 0) { - SplitterOutletNumber = SplitterCond(WhichSplitter).NumOutletNodes; + SplitterOutletNumber = state.dataSplitterComponent->SplitterCond(WhichSplitter).NumOutletNodes; } if (WhichSplitter == 0) { @@ -777,23 +619,23 @@ namespace SplitterComponent { int i; // Obtains and Allocates AirLoopHVAC:ZoneSplitter related parameters from input file - if (GetSplitterInputFlag) { // First time subroutine has been entered + if (state.dataSplitterComponent->GetSplitterInputFlag) { // First time subroutine has been entered GetSplitterInput(state); - GetSplitterInputFlag = false; + state.dataSplitterComponent->GetSplitterInputFlag = false; } if (SplitterNum == 0) { - WhichSplitter = UtilityRoutines::FindItemInList(SplitterName, SplitterCond, &SplitterConditions::SplitterName); + WhichSplitter = UtilityRoutines::FindItemInList(SplitterName, state.dataSplitterComponent->SplitterCond, &SplitterConditions::SplitterName); } else { WhichSplitter = SplitterNum; } if (WhichSplitter != 0) { - SplitterNodeNumbers.allocate(SplitterCond(WhichSplitter).NumOutletNodes + 2); - SplitterNodeNumbers(1) = SplitterCond(WhichSplitter).InletNode; - SplitterNodeNumbers(2) = SplitterCond(WhichSplitter).NumOutletNodes; + SplitterNodeNumbers.allocate(state.dataSplitterComponent->SplitterCond(WhichSplitter).NumOutletNodes + 2); + SplitterNodeNumbers(1) = state.dataSplitterComponent->SplitterCond(WhichSplitter).InletNode; + SplitterNodeNumbers(2) = state.dataSplitterComponent->SplitterCond(WhichSplitter).NumOutletNodes; for (i = 1; i <= SplitterNodeNumbers(2); ++i) { - SplitterNodeNumbers(i + 2) = SplitterCond(WhichSplitter).OutletNode(i); + SplitterNodeNumbers(i + 2) = state.dataSplitterComponent->SplitterCond(WhichSplitter).OutletNode(i); } } @@ -805,9 +647,6 @@ namespace SplitterComponent { return SplitterNodeNumbers; } - // End of Reporting subroutines for the Splitter Module - // ***************************************************************************** - } // namespace SplitterComponent } // namespace EnergyPlus diff --git a/src/EnergyPlus/SplitterComponent.hh b/src/EnergyPlus/SplitterComponent.hh index f57cc4578fe..85531b16fa2 100644 --- a/src/EnergyPlus/SplitterComponent.hh +++ b/src/EnergyPlus/SplitterComponent.hh @@ -57,38 +57,10 @@ namespace EnergyPlus { -namespace SplitterComponent { - - // Using/Aliasing - - // Data - // MODULE PARAMETERS: - - // MODULE PARAMETER DEFINITIONS - // na - - // DERIVED TYPE DEFINITIONS - - // MODULE VARIABLE DECLARATIONS: - extern bool GetSplitterInputFlag; - // Public because Used by SimAirServingZones and the Direct Air Unit - extern int NumSplitters; // The Number of Splitters found in the Input - extern Array1D_bool CheckEquipName; - - // Subroutine Specifications for the Module - // Driver/Manager Routines +// Forward declarations +struct EnergyPlusData; - // Get Input routines for module - - // Initialization routines for module - - // Algorithms for the module - - // Update routine to check convergence and update nodes - - // Reporting routines for module - - // Types +namespace SplitterComponent { struct SplitterConditions // public because USEd by SimAirServingZones and the Direct Air Unit { @@ -120,51 +92,16 @@ namespace SplitterComponent { } }; - // Object Data - extern Array1D SplitterCond; - - // Functions - void clear_state(); - void SimAirLoopSplitter(EnergyPlusData &state, std::string const &CompName, bool const FirstHVACIteration, bool const FirstCall, bool &SplitterInletChanged, int &CompIndex); - //******************************* - - // Get Input Section of the Module - //****************************************************************************** - void GetSplitterInput(EnergyPlusData &state); - // End of Get Input subroutines for the HB Module - //****************************************************************************** - - // Beginning Initialization Section of the Module - //****************************************************************************** - - void InitAirLoopSplitter(int const SplitterNum, bool const FirstHVACIteration, bool const FirstCall); - - // End Initialization Section of the Module - //****************************************************************************** - - // Begin Algorithm Section of the Module - //****************************************************************************** - - void CalcAirLoopSplitter(int const SplitterNum, bool const FirstCall); - - // End Algorithm Section of the Module - // ***************************************************************************** + void InitAirLoopSplitter(EnergyPlusData &state, int const SplitterNum, bool const FirstHVACIteration, bool const FirstCall); - // Beginning of Update subroutines for the Splitter Module - // ***************************************************************************** + void CalcAirLoopSplitter(EnergyPlusData &state, int const SplitterNum, bool const FirstCall); - void UpdateSplitter(int const SplitterNum, bool &SplitterInletChanged, bool const FirstCall); - - // End of Update subroutines for the Splitter Module - // ***************************************************************************** - - // Beginning of Reporting subroutines for the Splitter Module - // ***************************************************************************** + void UpdateSplitter(EnergyPlusData &state, int const SplitterNum, bool &SplitterInletChanged, bool const FirstCall); void ReportSplitter(int const SplitterNum); @@ -180,11 +117,30 @@ namespace SplitterComponent { bool &ErrorsFound // set to true if problem ); - // End of Reporting subroutines for the Splitter Module - // ***************************************************************************** - } // namespace SplitterComponent +struct SplitterComponentData : BaseGlobalStruct { + + bool GetSplitterInputFlag = true; + // Public because Used by SimAirServingZones and the Direct Air Unit + int NumSplitters = 0; // The Number of Splitters found in the Input + Array1D_bool CheckEquipName; + bool MyEnvrnFlag = true; + + Array1D SplitterCond; + + void clear_state() override + { + GetSplitterInputFlag = true; + NumSplitters = 0; + CheckEquipName.deallocate(); + SplitterCond.deallocate(); + MyEnvrnFlag = true; + } + + // Default Constructor + SplitterComponentData() = default; +}; } // namespace EnergyPlus #endif diff --git a/src/EnergyPlus/StateManagement.cc b/src/EnergyPlus/StateManagement.cc index 59b6b31f8d6..83a8540b37e 100644 --- a/src/EnergyPlus/StateManagement.cc +++ b/src/EnergyPlus/StateManagement.cc @@ -210,7 +210,6 @@ #include #include #include -#include #include void EnergyPlus::clearAllStates(EnergyPlusData &state) @@ -376,7 +375,6 @@ void EnergyPlus::clearAllStates(EnergyPlusData &state) SizingManager::clear_state(); SolarCollectors::clear_state(); SolarShading::clear_state(); - SplitterComponent::clear_state(); SurfaceGeometry::clear_state(); UtilityRoutines::clear_state(); EIRPlantLoopHeatPumps::EIRPlantLoopHeatPump::clear_state(); From 65617ad8d4b708f3df31b74beaa37286cc1a2e05 Mon Sep 17 00:00:00 2001 From: brianlball Date: Sat, 17 Oct 2020 10:24:06 -0600 Subject: [PATCH 4/8] convert SolarShading --- src/EnergyPlus/Data/CommonIncludes.hh | 1 + src/EnergyPlus/Data/EnergyPlusData.cc | 2 + src/EnergyPlus/Data/EnergyPlusData.hh | 2 + src/EnergyPlus/SimulationManager.cc | 6 +- src/EnergyPlus/SolarShading.cc | 2231 ++++++++-------------- src/EnergyPlus/SolarShading.hh | 340 ++-- src/EnergyPlus/StateManagement.cc | 2 - src/EnergyPlus/UtilityRoutines.cc | 4 +- tst/EnergyPlus/unit/SolarShading.unit.cc | 28 +- 9 files changed, 1028 insertions(+), 1588 deletions(-) diff --git a/src/EnergyPlus/Data/CommonIncludes.hh b/src/EnergyPlus/Data/CommonIncludes.hh index c618ac6bf4b..d95e98952a8 100644 --- a/src/EnergyPlus/Data/CommonIncludes.hh +++ b/src/EnergyPlus/Data/CommonIncludes.hh @@ -82,6 +82,7 @@ #include #include #include +#include #include #include #include diff --git a/src/EnergyPlus/Data/EnergyPlusData.cc b/src/EnergyPlus/Data/EnergyPlusData.cc index 0edfe60c76e..c4637e32e2f 100644 --- a/src/EnergyPlus/Data/EnergyPlusData.cc +++ b/src/EnergyPlus/Data/EnergyPlusData.cc @@ -84,6 +84,7 @@ namespace EnergyPlus { this->dataGlobal = std::unique_ptr(new DataGlobal); this->dataPipes = std::unique_ptr(new PipesData); this->dataPlantChillers = std::unique_ptr(new PlantChillersData); + this->dataSolarShading = std::unique_ptr(new SolarShadingData); this->dataSplitterComponent = std::unique_ptr(new SplitterComponentData); this->dataSteamBaseboardRadiator = std::unique_ptr(new SteamBaseboardRadiatorData); this->dataSteamCoils = std::unique_ptr(new SteamCoilsData); @@ -149,6 +150,7 @@ namespace EnergyPlus { this->dataGlobal->clear_state(); this->dataPipes->clear_state(); this->dataPlantChillers->clear_state(); + this->dataSolarShading->clear_state(); this->dataSplitterComponent->clear_state(); this->dataSteamBaseboardRadiator->clear_state(); this->dataSteamCoils->clear_state(); diff --git a/src/EnergyPlus/Data/EnergyPlusData.hh b/src/EnergyPlus/Data/EnergyPlusData.hh index 4fe016afe4f..bfac5bdc4be 100644 --- a/src/EnergyPlus/Data/EnergyPlusData.hh +++ b/src/EnergyPlus/Data/EnergyPlusData.hh @@ -93,6 +93,7 @@ struct ExteriorEnergyUseData; struct FansData; struct PipesData; struct PlantChillersData; +struct SolarShadingData; struct SplitterComponentData; struct SteamBaseboardRadiatorData; struct SteamCoilsData; @@ -161,6 +162,7 @@ struct EnergyPlusData : BaseGlobalStruct { std::unique_ptr dataFans; std::unique_ptr dataPipes; std::unique_ptr dataPlantChillers; + std::unique_ptr dataSolarShading; std::unique_ptr dataSplitterComponent; std::unique_ptr dataSteamBaseboardRadiator; std::unique_ptr dataSteamCoils; diff --git a/src/EnergyPlus/SimulationManager.cc b/src/EnergyPlus/SimulationManager.cc index eaed14d2991..a5b84746a20 100644 --- a/src/EnergyPlus/SimulationManager.cc +++ b/src/EnergyPlus/SimulationManager.cc @@ -1906,8 +1906,6 @@ namespace SimulationManager { using OutputProcessor::NumVarMeterArrays; using OutputReportTabular::maxUniqueKeyCount; using OutputReportTabular::MonthlyFieldSetInputCount; - using SolarShading::MAXHCArrayBounds; - using SolarShading::maxNumberOfFigures; using namespace DataRuntimeLanguage; using DataBranchNodeConnections::MaxNumOfNodeConnections; using DataBranchNodeConnections::NumOfNodeConnections; @@ -1953,8 +1951,8 @@ namespace SimulationManager { print(state.files.audit, variable_fmt, "NumEnergyMeters", NumEnergyMeters); print(state.files.audit, variable_fmt, "NumVarMeterArrays", NumVarMeterArrays); print(state.files.audit, variable_fmt, "maxUniqueKeyCount", maxUniqueKeyCount); - print(state.files.audit, variable_fmt, "maxNumberOfFigures", maxNumberOfFigures); - print(state.files.audit, variable_fmt, "MAXHCArrayBounds", MAXHCArrayBounds); + print(state.files.audit, variable_fmt, "maxNumberOfFigures", state.dataSolarShading->maxNumberOfFigures); + print(state.files.audit, variable_fmt, "MAXHCArrayBounds", state.dataSolarShading->MAXHCArrayBounds); print(state.files.audit, variable_fmt, "MaxVerticesPerSurface", MaxVerticesPerSurface); print(state.files.audit, variable_fmt, "NumReportList", NumReportList); print(state.files.audit, variable_fmt, "InstMeterCacheSize", InstMeterCacheSize); diff --git a/src/EnergyPlus/SolarShading.cc b/src/EnergyPlus/SolarShading.cc index 4eef7effa01..243d9e597ea 100644 --- a/src/EnergyPlus/SolarShading.cc +++ b/src/EnergyPlus/SolarShading.cc @@ -132,10 +132,6 @@ namespace SolarShading { // TARP Manual, NIST Publication. // Passive Solar Extension of the BLAST Program, CERL/UIUC Publication. - // OTHER NOTES: - // na - - // Using/Aliasing using namespace DataGlobals; using namespace DataEnvironment; using namespace DataHeatBalance; @@ -152,120 +148,7 @@ namespace SolarShading { using namespace FenestrationCommon; using namespace SingleLayerOptics; - // Data - // MODULE PARAMETER DEFINITIONS: - // General Parameters... - Real64 const SmallIncrement(1.0e-10); // Small increment added for shading/sunlit area calculations. - Real64 const HCMULT(100000.0); // Multiplier used to change meters to .01 millimeters for homogeneous coordinates. - // Homogeneous Coordinates are represented in integers (64 bit). This changes the surface coordinates from meters - // to .01 millimeters -- making that the resolution for shadowing, polygon clipping, etc. - Real64 const sqHCMULT(HCMULT *HCMULT); // Square of HCMult used in Homogeneous coordinates - Real64 const sqHCMULT_fac(0.5 / sqHCMULT); // ( 0.5 / sqHCMULT ) factor - Real64 const kHCMULT(1.0 / (HCMULT * HCMULT)); // half of inverse square of HCMult used in Homogeneous coordinates - - // Parameters for use with the variable OverlapStatus... - int const NoOverlap(1); - int const FirstSurfWithinSecond(2); - int const SecondSurfWithinFirst(3); - int const PartialOverlap(4); - int const TooManyVertices(5); - int const TooManyFigures(6); - Array1D_string const - cOverLapStatus(6, {"No-Overlap", "1st-Surf-within-2nd", "2nd-Surf-within-1st", "Partial-Overlap", "Too-Many-Vertices", "Too-Many-Figures"}); - - // DERIVED TYPE DEFINITIONS: - // INTERFACE BLOCK SPECIFICATIONS: - // na - - // MODULE VARIABLE DECLARATIONS: - int MaxHCV(15); // Maximum number of HC vertices - // (needs to be based on maxnumvertices) - int MaxHCS(15000); // 200 ! Maximum number of HC surfaces (was 56) - // Following are initially set in AllocateModuleArrays - int MAXHCArrayBounds(0); // Bounds based on Max Number of Vertices in surfaces - int MAXHCArrayIncrement(0); // Increment based on Max Number of Vertices in surfaces - // The following variable should be re-engineered to lower in module hierarchy but need more analysis - int NVS; // Number of vertices of the shadow/clipped surface - int NumVertInShadowOrClippedSurface; - int CurrentSurfaceBeingShadowed; - int CurrentShadowingSurface; - int OverlapStatus; // Results of overlap calculation: - // 1=No overlap; 2=NS1 completely within NS2 - // 3=NS2 completely within NS1; 4=Partial overlap - - Array1D CTHETA; // Cosine of angle of incidence of sun's rays on surface NS - int FBKSHC; // HC location of first back surface - int FGSSHC; // HC location of first general shadowing surface - int FINSHC; // HC location of first back surface overlap - int FRVLHC; // HC location of first reveal surface - int FSBSHC; // HC location of first subsurface - int LOCHCA(0); // Location of highest data in the HC arrays - int NBKSHC; // Number of back surfaces in the HC arrays - int NGSSHC; // Number of general shadowing surfaces in the HC arrays - int NINSHC; // Number of back surface overlaps in the HC arrays - int NRVLHC; // Number of reveal surfaces in HC array - int NSBSHC; // Number of subsurfaces in the HC arrays - bool CalcSkyDifShading; // True when sky diffuse solar shading is - int ShadowingCalcFrequency(0); // Frequency for Shadowing Calculations - int ShadowingDaysLeft(0); // Days left in current shadowing period - bool debugging(false); - namespace { - // These were static variables within different functions. They were pulled out into the namespace - // to facilitate easier unit testing of those functions. - // These are purposefully not in the header file as an extern variable. No one outside of this should - // use these. They are cleared by clear_state() for use by unit tests, but normal simulations should be unaffected. - // This is purposefully in an anonymous namespace so nothing outside this implementation file can use it. - bool MustAllocSolarShading(true); - bool GetInputFlag(true); - bool firstTime(true); - std::vector penumbraIDs; - } // namespace - std::unique_ptr shd_stream; // Shading file stream - Array1D_int HCNS; // Surface number of back surface HC figures - Array1D_int HCNV; // Number of vertices of each HC figure - Array2D HCA; // 'A' homogeneous coordinates of sides - Array2D HCB; // 'B' homogeneous coordinates of sides - Array2D HCC; // 'C' homogeneous coordinates of sides - Array2D HCX; // 'X' homogeneous coordinates of vertices of figure. - Array2D HCY; // 'Y' homogeneous coordinates of vertices of figure. - Array3D_int WindowRevealStatus; - Array1D HCAREA; // Area of each HC figure. Sign Convention: Base Surface - // - Positive, Shadow - Negative, Overlap between two shadows - // - positive, etc., so that sum of HC areas=base sunlit area - Array1D HCT; // Transmittance of each HC figure - Array1D ISABSF; // For simple interior solar distribution (in which all beam - // radiation entering zone is assumed to strike the floor), - // fraction of beam radiation absorbed by each floor surface - Array1D SAREA; // Sunlit area of heat transfer surface HTS - // Excludes multiplier for windows - // Shadowing combinations data structure...See ShadowingCombinations type - int NumTooManyFigures(0); - int NumTooManyVertices(0); - int NumBaseSubSurround(0); - Array1D SUNCOS(3); // Direction cosines of solar position - Real64 XShadowProjection; // X projection of a shadow (formerly called C) - Real64 YShadowProjection; // Y projection of a shadow (formerly called S) - Array1D XTEMP; // Temporary 'X' values for HC vertices of the overlap - Array1D XVC; // X-vertices of the clipped figure - Array1D XVS; // X-vertices of the shadow - Array1D YTEMP; // Temporary 'Y' values for HC vertices of the overlap - Array1D YVC; // Y-vertices of the clipped figure - Array1D YVS; // Y-vertices of the shadow - Array1D ZVC; // Z-vertices of the clipped figure - // Used in Sutherland Hodman poly clipping - Array1D ATEMP; // Temporary 'A' values for HC vertices of the overlap - Array1D BTEMP; // Temporary 'B' values for HC vertices of the overlap - Array1D CTEMP; // Temporary 'C' values for HC vertices of the overlap - Array1D XTEMP1; // Temporary 'X' values for HC vertices of the overlap - Array1D YTEMP1; // Temporary 'Y' values for HC vertices of the overlap - int maxNumberOfFigures(0); - -#ifdef EP_NO_OPENGL - bool penumbra = false; -#else - std::unique_ptr penumbra = nullptr; -#endif int const NPhi = 6; // Number of altitude angle steps for sky integration int const NTheta = 24; // Number of azimuth angle steps for sky integration @@ -280,98 +163,6 @@ namespace SolarShading { std::vector sin_Theta; std::vector cos_Theta; - // SUBROUTINE SPECIFICATIONS FOR MODULE SolarShading - - // Object Data - Array1D TrackTooManyFigures; - Array1D TrackTooManyVertices; - Array1D TrackBaseSubSurround; - - bool InitComplexOnce = true; - bool ShadowOneTimeFlag = true; - bool CHKSBSOneTimeFlag = true; - bool ORDERFirstTimeFlag = true; - bool TooManyFiguresMessage = false; - bool TooManyVerticesMessage = false; - bool SHDBKSOneTimeFlag = true; - bool SHDGSSOneTimeFlag = true; - - // Functions - void clear_state() - { - MaxHCV = 15; - MaxHCS = 1500; - MAXHCArrayBounds = 0; - MAXHCArrayIncrement = 0; - NVS = 0; - NumVertInShadowOrClippedSurface = 0; - CurrentSurfaceBeingShadowed = 0; - CurrentShadowingSurface = 0; - OverlapStatus = 0; - CTHETA.deallocate(); - FBKSHC = 0; - FGSSHC = 0; - FINSHC = 0; - FRVLHC = 0; - FSBSHC = 0; - LOCHCA = 0; - NBKSHC = 0; - NGSSHC = 0; - NINSHC = 0; - NRVLHC = 0; - NSBSHC = 0; - CalcSkyDifShading = false; - ShadowingCalcFrequency = 0; // Frequency for Shadowing Calculations - ShadowingDaysLeft = 0; // Days left in current shadowing period - debugging = false; - MustAllocSolarShading = true; - GetInputFlag = true; - firstTime = true; - HCNS.deallocate(); - HCNV.deallocate(); - HCA.deallocate(); - HCB.deallocate(); - HCC.deallocate(); - HCX.deallocate(); - HCY.deallocate(); - WindowRevealStatus.deallocate(); - HCAREA.deallocate(); - HCT.deallocate(); - ISABSF.deallocate(); - SAREA.deallocate(); - NumTooManyFigures = 0; - NumTooManyVertices = 0; - NumBaseSubSurround = 0; - XShadowProjection = 0.0; - YShadowProjection = 0.0; - XTEMP.deallocate(); - XVC.deallocate(); - XVS.deallocate(); - YTEMP.deallocate(); - YVC.deallocate(); - YVS.deallocate(); - ZVC.deallocate(); - ATEMP.deallocate(); - BTEMP.deallocate(); - CTEMP.deallocate(); - XTEMP1.deallocate(); - YTEMP1.deallocate(); - maxNumberOfFigures = 0; - TrackTooManyFigures.deallocate(); - TrackTooManyVertices.deallocate(); - TrackBaseSubSurround.deallocate(); - DBZoneIntWin.deallocate(); - ISABSF.deallocate(); - InitComplexOnce = true; - ShadowOneTimeFlag = true; - CHKSBSOneTimeFlag = true; - ORDERFirstTimeFlag = true; - TooManyFiguresMessage = false; - TooManyVerticesMessage = false; - SHDBKSOneTimeFlag = true; - SHDGSSOneTimeFlag = true; - } - void InitSolarCalculations(EnergyPlusData &state) { @@ -388,25 +179,6 @@ namespace SolarShading { // All shadowing calculations have been grouped under this routine to // allow segmentation separating it from the hourly loads calculation. - // REFERENCES: - // na - - // USE STATEMENTS: - // na - - // Locals - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - - // FLOW: #ifdef EP_Count_Calls ++NumInitSolar_Calls; #endif @@ -420,26 +192,26 @@ namespace SolarShading { shd_stream = std::unique_ptr(new std::iostream(nullptr)); } - if (GetInputFlag) { + if (state.dataSolarShading->GetInputFlag) { GetShadowingInput(state); - GetInputFlag = false; - MaxHCV = (((max(15, MaxVerticesPerSurface) + 16) / 16) * 16) - 1; // Assure MaxHCV+1 is multiple of 16 for 128 B alignment - assert((MaxHCV + 1) % 16 == 0); + state.dataSolarShading->GetInputFlag = false; + state.dataSolarShading->MaxHCV = (((max(15, MaxVerticesPerSurface) + 16) / 16) * 16) - 1; // Assure MaxHCV+1 is multiple of 16 for 128 B alignment + assert((state.dataSolarShading->MaxHCV + 1) % 16 == 0); } - if (firstTime) DisplayString("Allocate Solar Module Arrays"); + if (state.dataSolarShading->firstTime) DisplayString("Allocate Solar Module Arrays"); AllocateModuleArrays(state); if (SolarDistribution != FullInteriorExterior) { - if (firstTime) DisplayString("Computing Interior Solar Absorption Factors"); + if (state.dataSolarShading->firstTime) DisplayString("Computing Interior Solar Absorption Factors"); ComputeIntSolarAbsorpFactors(state); } - if (firstTime) DisplayString("Determining Shadowing Combinations"); + if (state.dataSolarShading->firstTime) DisplayString("Determining Shadowing Combinations"); DetermineShadowingCombinations(state); shd_stream.reset(); // Done writing to shd file - if (firstTime) DisplayString("Computing Window Shade Absorption Factors"); + if (state.dataSolarShading->firstTime) DisplayString("Computing Window Shade Absorption Factors"); ComputeWinShadeAbsorpFactors(state); if (CalcSolRefl) { @@ -447,12 +219,12 @@ namespace SolarShading { InitSolReflRecSurf(state); } - if (firstTime) DisplayString("Proceeding with Initializing Solar Calculations"); + if (state.dataSolarShading->firstTime) DisplayString("Proceeding with Initializing Solar Calculations"); } if (BeginEnvrnFlag) { - CTHETA = 0.0; - SAREA = 0.0; + state.dataSolarShading->CTHETA = 0.0; + state.dataSolarShading->SAREA = 0.0; SurfSunlitArea = 0.0; SurfSunlitFrac = 0.0; SunlitFracHR = 0.0; @@ -513,7 +285,7 @@ namespace SolarShading { SurfInitialDifSolInAbsReport = 0.0; SurfWinInitialDifSolInTransReport = 0.0; - WindowRevealStatus = 0; + state.dataSolarShading->WindowRevealStatus = 0; ZoneTransSolarEnergy = 0.0; ZoneBmSolFrExtWinsRepEnergy = 0.0; ZoneBmSolFrIntWinsRepEnergy = 0.0; @@ -586,7 +358,7 @@ namespace SolarShading { cos_Theta.push_back(std::cos(Theta)); } - firstTime = false; + state.dataSolarShading->firstTime = false; } void GetShadowingInput(EnergyPlusData &state) @@ -647,22 +419,22 @@ namespace SolarShading { lAlphaFieldBlanks, cAlphaFieldNames, cNumericFieldNames); - ShadowingCalcFrequency = rNumericArgs(1); + state.dataSolarShading->ShadowingCalcFrequency = rNumericArgs(1); } - if (ShadowingCalcFrequency <= 0) { + if (state.dataSolarShading->ShadowingCalcFrequency <= 0) { // Set to default value - ShadowingCalcFrequency = 20; + state.dataSolarShading->ShadowingCalcFrequency = 20; } - if (ShadowingCalcFrequency > 31) { + if (state.dataSolarShading->ShadowingCalcFrequency > 31) { ShowWarningError(cCurrentModuleObject + ": suspect " + cNumericFieldNames(1)); ShowContinueError("Value entered=[" + RoundSigDigits(rNumericArgs(1), 0) + "], Shadowing Calculations will be inaccurate."); } if (rNumericArgs(2) > 199.0) { - MaxHCS = rNumericArgs(2); + state.dataSolarShading->MaxHCS = rNumericArgs(2); } else { - MaxHCS = 15000; + state.dataSolarShading->MaxHCS = 15000; } int aNum = 1; @@ -707,7 +479,7 @@ namespace SolarShading { } }; if (Pumbra::Penumbra::isValidContext()) { - penumbra = std::unique_ptr(new Pumbra::Penumbra(error_callback, pixelRes)); + state.dataSolarShading->penumbra = std::unique_ptr(new Pumbra::Penumbra(error_callback, pixelRes)); } else { ShowWarningError("No GPU found (required for PixelCounting)"); ShowContinueError("PolygonClipping will be used instead"); @@ -940,7 +712,7 @@ namespace SolarShading { ShowContinueError("Simulation has been reset to use DetailedSkyDiffuseModeling. Simulation continues."); DetailedSkyDiffuseAlgorithm = true; cAlphaArgs(2) = "DetailedSkyDiffuseModeling"; - if (ShadowingCalcFrequency > 1) { + if (state.dataSolarShading->ShadowingCalcFrequency > 1) { ShowContinueError("Better accuracy may be gained by setting the " + cNumericFieldNames(1) + " to 1 in the " + cCurrentModuleObject + " object."); } @@ -965,8 +737,8 @@ namespace SolarShading { "Shadowing/Sun Position Calculations Annual Simulations,{},{},{},{},{},{},{},{},{},{}\n", cAlphaArgs(1), cAlphaArgs(2), - ShadowingCalcFrequency, - MaxHCS, + state.dataSolarShading->ShadowingCalcFrequency, + state.dataSolarShading->MaxHCS, cAlphaArgs(3), pixelRes, cAlphaArgs(4), @@ -998,8 +770,8 @@ namespace SolarShading { // FLOW: - CTHETA.dimension(TotSurfaces, 0.0); - SAREA.dimension(TotSurfaces, 0.0); + state.dataSolarShading->CTHETA.dimension(TotSurfaces, 0.0); + state.dataSolarShading->SAREA.dimension(TotSurfaces, 0.0); SurfSunlitArea.dimension(TotSurfaces, 0.0); SurfSunlitFrac.dimension(TotSurfaces, 0.0); SunlitFracHR.dimension(24, TotSurfaces, 0.0); @@ -1105,25 +877,25 @@ namespace SolarShading { SurfInitialDifSolInAbsReport.dimension(TotSurfaces, 0.0); SurfWinInitialDifSolInTransReport.dimension(TotSurfaces, 0.0); SurfSWInAbsTotalReport.dimension(TotSurfaces, 0.0); - WindowRevealStatus.dimension(NumOfTimeStepInHour, 24, TotSurfaces, 0); + state.dataSolarShading->WindowRevealStatus.dimension(NumOfTimeStepInHour, 24, TotSurfaces, 0); // Weiler-Atherton - MAXHCArrayBounds = 2 * (MaxVerticesPerSurface + 1); - MAXHCArrayIncrement = MaxVerticesPerSurface + 1; - XTEMP.dimension(2 * (MaxVerticesPerSurface + 1), 0.0); - YTEMP.dimension(2 * (MaxVerticesPerSurface + 1), 0.0); - XVC.dimension(MaxVerticesPerSurface + 1, 0.0); - XVS.dimension(MaxVerticesPerSurface + 1, 0.0); - YVC.dimension(MaxVerticesPerSurface + 1, 0.0); - YVS.dimension(MaxVerticesPerSurface + 1, 0.0); - ZVC.dimension(MaxVerticesPerSurface + 1, 0.0); + state.dataSolarShading->MAXHCArrayBounds = 2 * (MaxVerticesPerSurface + 1); + state.dataSolarShading->MAXHCArrayIncrement = MaxVerticesPerSurface + 1; + state.dataSolarShading->XTEMP.dimension(2 * (MaxVerticesPerSurface + 1), 0.0); + state.dataSolarShading->YTEMP.dimension(2 * (MaxVerticesPerSurface + 1), 0.0); + state.dataSolarShading->XVC.dimension(MaxVerticesPerSurface + 1, 0.0); + state.dataSolarShading->XVS.dimension(MaxVerticesPerSurface + 1, 0.0); + state.dataSolarShading->YVC.dimension(MaxVerticesPerSurface + 1, 0.0); + state.dataSolarShading->YVS.dimension(MaxVerticesPerSurface + 1, 0.0); + state.dataSolarShading->ZVC.dimension(MaxVerticesPerSurface + 1, 0.0); // Sutherland-Hodgman - ATEMP.dimension(2 * (MaxVerticesPerSurface + 1), 0.0); - BTEMP.dimension(2 * (MaxVerticesPerSurface + 1), 0.0); - CTEMP.dimension(2 * (MaxVerticesPerSurface + 1), 0.0); - XTEMP1.dimension(2 * (MaxVerticesPerSurface + 1), 0.0); - YTEMP1.dimension(2 * (MaxVerticesPerSurface + 1), 0.0); + state.dataSolarShading->ATEMP.dimension(2 * (MaxVerticesPerSurface + 1), 0.0); + state.dataSolarShading->BTEMP.dimension(2 * (MaxVerticesPerSurface + 1), 0.0); + state.dataSolarShading->CTEMP.dimension(2 * (MaxVerticesPerSurface + 1), 0.0); + state.dataSolarShading->XTEMP1.dimension(2 * (MaxVerticesPerSurface + 1), 0.0); + state.dataSolarShading->YTEMP1.dimension(2 * (MaxVerticesPerSurface + 1), 0.0); // energy SurfWinTransSolarEnergy.dimension(TotSurfaces, 0.0); @@ -2766,7 +2538,7 @@ namespace SolarShading { } } - void CHKSBS(int const HTS, // Heat transfer surface number of the general receiving surf + void CHKSBS(EnergyPlusData &state, int const HTS, // Heat transfer surface number of the general receiving surf int const GRSNR, // Surface number of general receiving surface int const SBSNR // Surface number of subsurface ) @@ -2782,9 +2554,6 @@ namespace SolarShading { // Checks that a subsurface is completely // enclosed by its base surface. - // METHODOLOGY EMPLOYED: - // na - // REFERENCES: // BLAST/IBLAST code, original author George Walton @@ -2802,23 +2571,9 @@ namespace SolarShading { // Computer Graphics 21(4), 119-126 (1987) [also in the Proceedings of SIGGRAPH 1987] //--- using adapted routine from Triangulation code -- EnergyPlus. - // USE STATEMENTS: - // na - - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: // MSG - for error message static Array1D_string const MSG(4, {"misses", "", "within", "overlaps"}); - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int N; // Loop Control int NVT; // Number of vertices static Array1D XVT; // X Vertices of @@ -2844,53 +2599,53 @@ namespace SolarShading { Real64 BMAX; // INTEGER M - if (CHKSBSOneTimeFlag) { + if (state.dataSolarShading->CHKSBSOneTimeFlag) { XVT.allocate(MaxVerticesPerSurface + 1); YVT.allocate(MaxVerticesPerSurface + 1); ZVT.allocate(MaxVerticesPerSurface + 1); XVT = 0.0; YVT = 0.0; ZVT = 0.0; - CHKSBSOneTimeFlag = false; + state.dataSolarShading->CHKSBSOneTimeFlag = false; } NS1 = 1; NS2 = 2; NS3 = 3; - HCT(1) = 0.0; - HCT(2) = 0.0; + state.dataSolarShading->HCT(1) = 0.0; + state.dataSolarShading->HCT(2) = 0.0; // Put coordinates of base surface into clockwise sequence on the x'-y' plane. XVT = 0.0; YVT = 0.0; ZVT = 0.0; - XVS = 0.0; - YVS = 0.0; + state.dataSolarShading->XVS = 0.0; + state.dataSolarShading->YVS = 0.0; CTRANS(GRSNR, HTS, NVT, XVT, YVT, ZVT); for (N = 1; N <= NVT; ++N) { - XVS(N) = XVT(NVT + 1 - N); - YVS(N) = YVT(NVT + 1 - N); + state.dataSolarShading->XVS(N) = XVT(NVT + 1 - N); + state.dataSolarShading->YVS(N) = YVT(NVT + 1 - N); } - HTRANS1(NS2, NVT); + HTRANS1(state, NS2, NVT); // Put coordinates of the subsurface into clockwise sequence. - NVS = Surface(SBSNR).Sides; - for (N = 1; N <= NVS; ++N) { - XVS(N) = ShadeV(SBSNR).XV(NVS + 1 - N); - YVS(N) = ShadeV(SBSNR).YV(NVS + 1 - N); + state.dataSolarShading->NVS = Surface(SBSNR).Sides; + for (N = 1; N <= state.dataSolarShading->NVS; ++N) { + state.dataSolarShading->XVS(N) = ShadeV(SBSNR).XV(state.dataSolarShading->NVS + 1 - N); + state.dataSolarShading->YVS(N) = ShadeV(SBSNR).YV(state.dataSolarShading->NVS + 1 - N); } - HTRANS1(NS1, NVS); + HTRANS1(state, NS1, state.dataSolarShading->NVS); // Determine the overlap condition. - DeterminePolygonOverlap(NS1, NS2, NS3); + DeterminePolygonOverlap(state, NS1, NS2, NS3); // Print error condition if necessary. - if (OverlapStatus != FirstSurfWithinSecond) { + if (state.dataSolarShading->OverlapStatus != state.dataSolarShading->FirstSurfWithinSecond) { Out = false; // C COMPUTE COMPONENTS OF VECTOR // C NORMAL TO BASE SURFACE. @@ -3005,10 +2760,10 @@ namespace SolarShading { // FirstSurroundError=.FALSE. // ENDIF if (Out) { - TrackBaseSubSurround.redimension(++NumBaseSubSurround); - TrackBaseSubSurround(NumBaseSubSurround).SurfIndex1 = GRSNR; - TrackBaseSubSurround(NumBaseSubSurround).SurfIndex2 = SBSNR; - TrackBaseSubSurround(NumBaseSubSurround).MiscIndex = OverlapStatus; + state.dataSolarShading->TrackBaseSubSurround.redimension(++state.dataSolarShading->NumBaseSubSurround); + state.dataSolarShading->TrackBaseSubSurround(state.dataSolarShading->NumBaseSubSurround).SurfIndex1 = GRSNR; + state.dataSolarShading->TrackBaseSubSurround(state.dataSolarShading->NumBaseSubSurround).SurfIndex2 = SBSNR; + state.dataSolarShading->TrackBaseSubSurround(state.dataSolarShading->NumBaseSubSurround).MiscIndex = state.dataSolarShading->OverlapStatus; // CALL ShowRecurringWarningErrorAtEnd('Base surface does not surround subsurface (CHKSBS), Overlap Status='// & // TRIM(cOverLapStatus(OverlapStatus)), & // TrackBaseSubSurround(GRSNR)%ErrIndex1) @@ -3017,7 +2772,7 @@ namespace SolarShading { // TrackBaseSubSurround(SBSNR)%ErrIndex2) if (shd_stream) { *shd_stream << "==== Base does not Surround subsurface details ====\n"; - *shd_stream << "Surface=" << Surface(GRSNR).Name << ' ' << cOverLapStatus(OverlapStatus) << '\n'; + *shd_stream << "Surface=" << Surface(GRSNR).Name << ' ' << state.dataSolarShading->cOverLapStatus(state.dataSolarShading->OverlapStatus) << '\n'; *shd_stream << "Surface#=" << std::setw(5) << GRSNR << " NSides=" << std::setw(5) << Surface(GRSNR).Sides << '\n'; *shd_stream << std::fixed << std::setprecision(2); for (N = 1; N <= Surface(GRSNR).Sides; ++N) { @@ -3056,8 +2811,6 @@ namespace SolarShading { // Determine if a point is inside a simple 2d polygon. For a simple polygon (one whose // boundary never crosses itself). The polygon does not need to be convex. - // Methodology employed: - // // References: // M Shimrat, Position of Point Relative to Polygon, ACM Algorithm 112, @@ -3070,21 +2823,8 @@ namespace SolarShading { // Return value bool inside; // return value, true=inside, false = not inside - // Argument array dimensioning EP_SIZE_CHECK(polygon_3d, nsides); - // Locals - // Function argument definitions: - - // Function parameter definitions: - - // Interface block specifications: - // na - - // Derived type definitions: - // na - - // Function local variable declarations: int i; int ip1; @@ -3170,10 +2910,10 @@ namespace SolarShading { Real64 TestFractSum; Real64 HorizAreaSum; - if (!allocated(ISABSF)) { - ISABSF.allocate(TotSurfaces); + if (!allocated(state.dataSolarShading->ISABSF)) { + state.dataSolarShading->ISABSF.allocate(TotSurfaces); } - ISABSF = 0.0; + state.dataSolarShading->ISABSF = 0.0; for (int enclosureNum = 1; enclosureNum <= DataViewFactorInformation::NumOfSolarEnclosures; ++enclosureNum) { auto &thisEnclosure(DataViewFactorInformation::ZoneSolarInfo(enclosureNum)); @@ -3208,7 +2948,7 @@ namespace SolarShading { int ConstrNum = Surface(SurfNum).Construction; // last minute V3.1 if (state.dataConstruction->Construct(ConstrNum).TransDiff <= 0.0) { // Opaque surface - if (AreaSum > 0.0) ISABSF(SurfNum) = Surface(SurfNum).Area * state.dataConstruction->Construct(ConstrNum).InsideAbsorpSolar / AreaSum; + if (AreaSum > 0.0) state.dataSolarShading->ISABSF(SurfNum) = Surface(SurfNum).Area * state.dataConstruction->Construct(ConstrNum).InsideAbsorpSolar / AreaSum; } else { // Window (floor windows are assumed to have no shading device and no divider, // and assumed to be non-switchable) if (SurfWinStormWinFlag(SurfNum) == 1) ConstrNum = Surface(SurfNum).StormWinConstruction; @@ -3222,11 +2962,11 @@ namespace SolarShading { AbsDiffTotWin += state.dataConstruction->Construct(ConstrNum).AbsDiffBackEQL(Lay); } } - if (AreaSum > 0.0) ISABSF(SurfNum) = Surface(SurfNum).Area * AbsDiffTotWin / AreaSum; + if (AreaSum > 0.0) state.dataSolarShading->ISABSF(SurfNum) = Surface(SurfNum).Area * AbsDiffTotWin / AreaSum; } } // CR 8229 test ISABSF for problems - TestFractSum += ISABSF(SurfNum); + TestFractSum += state.dataSolarShading->ISABSF(SurfNum); } if (TestFractSum <= 0.0) { @@ -3252,7 +2992,7 @@ namespace SolarShading { for (int const SurfNum : thisEnclosure.SurfacePtr) { int ConstrNum = Surface(SurfNum).Construction; if (state.dataConstruction->Construct(ConstrNum).TransDiff <= 0.0) { // Opaque surface - if (AreaSum > 0.0) ISABSF(SurfNum) = Surface(SurfNum).Area * state.dataConstruction->Construct(ConstrNum).InsideAbsorpSolar / AreaSum; + if (AreaSum > 0.0) state.dataSolarShading->ISABSF(SurfNum) = Surface(SurfNum).Area * state.dataConstruction->Construct(ConstrNum).InsideAbsorpSolar / AreaSum; } else { // Window (floor windows are assumed to have no shading device and no divider, // and assumed to be non-switchable) if (SurfWinStormWinFlag(SurfNum) == 1) ConstrNum = Surface(SurfNum).StormWinConstruction; @@ -3267,7 +3007,7 @@ namespace SolarShading { } } - if (AreaSum > 0.0) ISABSF(SurfNum) = Surface(SurfNum).Area * AbsDiffTotWin / AreaSum; + if (AreaSum > 0.0) state.dataSolarShading->ISABSF(SurfNum) = Surface(SurfNum).Area * AbsDiffTotWin / AreaSum; } } } @@ -3276,7 +3016,7 @@ namespace SolarShading { } // enclosure loop } - void CLIP(int const NVT, Array1D &XVT, Array1D &YVT, Array1D &ZVT) + void CLIP(EnergyPlusData &state, int const NVT, Array1D &XVT, Array1D &YVT, Array1D &ZVT) { // SUBROUTINE INFORMATION: @@ -3290,30 +3030,9 @@ namespace SolarShading { // none of it lies below the plane of the receiving surface polygon. This // prevents the casting of 'false' shadows. - // METHODOLOGY EMPLOYED: - // na - // REFERENCES: // BLAST/IBLAST code, original author George Walton - // USE STATEMENTS: - // na - - // Argument array dimensioning - - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int NABOVE(0); // Number of vertices of shadow casting surface. above the plane of receiving surface int NEXT(0); // First vertex above plane of receiving surface int NON(0); // Number of vertices of shadow casting surface. on plane of receiving surface @@ -3325,7 +3044,7 @@ namespace SolarShading { // Determine if the shadow casting surface. is above, below, or intersects with the plane of the receiving surface - NumVertInShadowOrClippedSurface = NVS; + state.dataSolarShading->NumVertInShadowOrClippedSurface = state.dataSolarShading->NVS; for (int N = 1; N <= NVT; ++N) { Real64 const ZVT_N(ZVT(N)); if (ZVT_N > 0.0) { @@ -3337,23 +3056,23 @@ namespace SolarShading { if (NABOVE + NON == NVT) { // Rename the unclipped shadow casting surface. - NVS = NVT; - NumVertInShadowOrClippedSurface = NVT; + state.dataSolarShading->NVS = NVT; + state.dataSolarShading->NumVertInShadowOrClippedSurface = NVT; for (int N = 1; N <= NVT; ++N) { - XVC(N) = XVT(N); - YVC(N) = YVT(N); - ZVC(N) = ZVT(N); + state.dataSolarShading->XVC(N) = XVT(N); + state.dataSolarShading->YVC(N) = YVT(N); + state.dataSolarShading->ZVC(N) = ZVT(N); } } else if (NABOVE == 0) { // Totally submerged shadow casting surface. - NVS = 0; - NumVertInShadowOrClippedSurface = 0; + state.dataSolarShading->NVS = 0; + state.dataSolarShading->NumVertInShadowOrClippedSurface = 0; } else { // Remove (clip) that portion of the shadow casting surface. which is below the receiving surface - NVS = NABOVE + 2; - NumVertInShadowOrClippedSurface = NABOVE + 2; + state.dataSolarShading->NVS = NABOVE + 2; + state.dataSolarShading->NumVertInShadowOrClippedSurface = NABOVE + 2; Real64 ZVT_N, ZVT_P(ZVT(1)); XVT(NVT + 1) = XVT(1); YVT(NVT + 1) = YVT(1); @@ -3375,17 +3094,17 @@ namespace SolarShading { // Renumber the vertices of the clipped shadow casting surface. so they are still counter-clockwise sequential. - XVC(1) = XOUT; //? Verify that the IN and OUT values were ever set? - YVC(1) = YOUT; - ZVC(1) = 0.0; - XVC(NVS) = XIN; - YVC(NVS) = YIN; - ZVC(NVS) = 0.0; + state.dataSolarShading->XVC(1) = XOUT; //? Verify that the IN and OUT values were ever set? + state.dataSolarShading->YVC(1) = YOUT; + state.dataSolarShading->ZVC(1) = 0.0; + state.dataSolarShading->XVC(state.dataSolarShading->NVS) = XIN; + state.dataSolarShading->YVC(state.dataSolarShading->NVS) = YIN; + state.dataSolarShading->ZVC(state.dataSolarShading->NVS) = 0.0; for (int N = 1; N <= NABOVE; ++N) { if (NEXT > NVT) NEXT = 1; - XVC(N + 1) = XVT(NEXT); - YVC(N + 1) = YVT(NEXT); - ZVC(N + 1) = ZVT(NEXT); + state.dataSolarShading->XVC(N + 1) = XVT(NEXT); + state.dataSolarShading->YVC(N + 1) = YVT(NEXT); + state.dataSolarShading->ZVC(N + 1) = ZVT(NEXT); ++NEXT; } } @@ -3410,31 +3129,10 @@ namespace SolarShading { // of surface NS to coordinates in the plane of the receiving surface NGRS. // See subroutine 'CalcCoordinateTransformation' SurfaceGeometry Module. - // METHODOLOGY EMPLOYED: - // na - // REFERENCES: // BLAST/IBLAST code, original author George Walton // NECAP subroutine 'SHADOW' - // USE STATEMENTS: - // na - - // Argument array dimensioning - - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: Real64 Xdif; // Intermediate Result Real64 Ydif; // Intermediate Result Real64 Zdif; // Intermediate Result @@ -3469,7 +3167,7 @@ namespace SolarShading { } } - void HTRANS(int const I, // Mode selector: 0 - Compute H.C. of sides + void HTRANS(EnergyPlusData &state, int const I, // Mode selector: 0 - Compute H.C. of sides int const NS, // Figure Number int const NumVertices // Number of vertices ) @@ -3519,45 +3217,34 @@ namespace SolarShading { // SUBROUTINE ARGUMENT DEFINITIONS: // 1 - Compute H.C. of vertices & sides - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - - if (NS > 2 * MaxHCS) { - ShowFatalError("Solar Shading: HTrans: Too many Figures (>" + TrimSigDigits(MaxHCS) + ')'); + if (NS > 2 * state.dataSolarShading->MaxHCS) { + ShowFatalError("Solar Shading: HTrans: Too many Figures (>" + TrimSigDigits(state.dataSolarShading->MaxHCS) + ')'); } - HCNV(NS) = NumVertices; + state.dataSolarShading->HCNV(NS) = NumVertices; // Tuned Linear indexing - assert(equal_dimensions(HCX, HCY)); - assert(equal_dimensions(HCX, HCA)); - assert(equal_dimensions(HCX, HCB)); - assert(equal_dimensions(HCX, HCC)); - auto const l1(HCX.index(NS, 1)); + assert(equal_dimensions(state.dataSolarShading->HCX, state.dataSolarShading->HCY)); + assert(equal_dimensions(state.dataSolarShading->HCX, state.dataSolarShading->HCA)); + assert(equal_dimensions(state.dataSolarShading->HCX, state.dataSolarShading->HCB)); + assert(equal_dimensions(state.dataSolarShading->HCX, state.dataSolarShading->HCC)); + auto const l1(state.dataSolarShading->HCX.index(NS, 1)); if (I != 0) { // Transform vertices of figure ns. // See comment at top of module regarding HCMULT auto l(l1); for (int N = 1; N <= NumVertices; ++N, ++l) { // [ l ] == ( NS, N ) - HCX[l] = nint64(XVS(N) * HCMULT); - HCY[l] = nint64(YVS(N) * HCMULT); + state.dataSolarShading->HCX[l] = nint64(state.dataSolarShading->XVS(N) * state.dataSolarShading->HCMULT); + state.dataSolarShading->HCY[l] = nint64(state.dataSolarShading->YVS(N) * state.dataSolarShading->HCMULT); } } // Establish extra point for finding lines between points. - auto l(HCX.index(NS, NumVertices + 1)); - Int64 HCX_m(HCX[l] = HCX[l1]); // [ l ] == ( NS, NumVertices + 1 ), [ l1 ] == ( NS, 1 ) - Int64 HCY_m(HCY[l] = HCY[l1]); // [ l ] == ( NS, NumVertices + 1 ), [ l1 ] == ( NS, 1 ) + auto l(state.dataSolarShading->HCX.index(NS, NumVertices + 1)); + Int64 HCX_m(state.dataSolarShading->HCX[l] = state.dataSolarShading->HCX[l1]); // [ l ] == ( NS, NumVertices + 1 ), [ l1 ] == ( NS, 1 ) + Int64 HCY_m(state.dataSolarShading->HCY[l] = state.dataSolarShading->HCY[l1]); // [ l ] == ( NS, NumVertices + 1 ), [ l1 ] == ( NS, 1 ) // Determine lines between points. l = l1; @@ -3568,11 +3255,11 @@ namespace SolarShading { for (int N = 1; N <= NumVertices; ++N, ++l, ++m) { // [ l ] == ( NS, N ), [ m ] == ( NS, N + 1 ) HCX_l = HCX_m; HCY_l = HCY_m; - HCX_m = HCX[m]; - HCY_m = HCY[m]; - HCA[l] = HCY_l - HCY_m; - HCB[l] = HCX_m - HCX_l; - SUM += HCC[l] = (HCY_m * HCX_l) - (HCX_m * HCY_l); + HCX_m = state.dataSolarShading->HCX[m]; + HCY_m = state.dataSolarShading->HCY[m]; + state.dataSolarShading->HCA[l] = HCY_l - HCY_m; + state.dataSolarShading->HCB[l] = HCX_m - HCX_l; + SUM += state.dataSolarShading->HCC[l] = (HCY_m * HCX_l) - (HCX_m * HCY_l); } // Compute area of polygon. @@ -3580,11 +3267,11 @@ namespace SolarShading { // DO N = 1, NumVertices // SUM = SUM + HCX(N,NS)*HCY(N+1,NS) - HCY(N,NS)*HCX(N+1,NS) ! Since HCX and HCY integerized, value of SUM should be ok // END DO - HCAREA(NS) = SUM * sqHCMULT_fac; + state.dataSolarShading->HCAREA(NS) = SUM * state.dataSolarShading->sqHCMULT_fac; // HCAREA(NS)=0.5d0*SUM*(kHCMULT) } - void HTRANS0(int const NS, // Figure Number + void HTRANS0(EnergyPlusData &state, int const NS, // Figure Number int const NumVertices // Number of vertices ) { @@ -3593,24 +3280,24 @@ namespace SolarShading { // Locals - if (NS > 2 * MaxHCS) { - ShowFatalError("Solar Shading: HTrans0: Too many Figures (>" + TrimSigDigits(MaxHCS) + ')'); + if (NS > 2 * state.dataSolarShading->MaxHCS) { + ShowFatalError("Solar Shading: HTrans0: Too many Figures (>" + TrimSigDigits(state.dataSolarShading->MaxHCS) + ')'); } - HCNV(NS) = NumVertices; + state.dataSolarShading->HCNV(NS) = NumVertices; // Tuned Linear indexing - assert(equal_dimensions(HCX, HCY)); - assert(equal_dimensions(HCX, HCA)); - assert(equal_dimensions(HCX, HCB)); - assert(equal_dimensions(HCX, HCC)); + assert(equal_dimensions(state.dataSolarShading->HCX, state.dataSolarShading->HCY)); + assert(equal_dimensions(state.dataSolarShading->HCX, state.dataSolarShading->HCA)); + assert(equal_dimensions(state.dataSolarShading->HCX, state.dataSolarShading->HCB)); + assert(equal_dimensions(state.dataSolarShading->HCX, state.dataSolarShading->HCC)); - auto const l1(HCX.index(NS, 1)); + auto const l1(state.dataSolarShading->HCX.index(NS, 1)); - auto l(HCX.index(NS, NumVertices + 1)); - Int64 HCX_m(HCX[l] = HCX[l1]); // [ l1 ] == ( NS, 1 ) - Int64 HCY_m(HCY[l] = HCY[l1]); // [ l1 ] == ( NS, 1 ) + auto l(state.dataSolarShading->HCX.index(NS, NumVertices + 1)); + Int64 HCX_m(state.dataSolarShading->HCX[l] = state.dataSolarShading->HCX[l1]); // [ l1 ] == ( NS, 1 ) + Int64 HCY_m(state.dataSolarShading->HCY[l] = state.dataSolarShading->HCY[l1]); // [ l1 ] == ( NS, 1 ) l = l1; auto m(l1 + 1u); @@ -3620,48 +3307,48 @@ namespace SolarShading { for (int N = 1; N <= NumVertices; ++N, ++l, ++m) { // [ l ] == ( NS, N ), [ m ] == ( NS, N + 1 ) HCX_l = HCX_m; HCY_l = HCY_m; - HCX_m = HCX[m]; - HCY_m = HCY[m]; - HCA[l] = HCY_l - HCY_m; - HCB[l] = HCX_m - HCX_l; - SUM += HCC[l] = (HCY_m * HCX_l) - (HCX_m * HCY_l); + HCX_m = state.dataSolarShading->HCX[m]; + HCY_m = state.dataSolarShading->HCY[m]; + state.dataSolarShading->HCA[l] = HCY_l - HCY_m; + state.dataSolarShading->HCB[l] = HCX_m - HCX_l; + SUM += state.dataSolarShading->HCC[l] = (HCY_m * HCX_l) - (HCX_m * HCY_l); } - HCAREA(NS) = SUM * sqHCMULT_fac; + state.dataSolarShading->HCAREA(NS) = SUM * state.dataSolarShading->sqHCMULT_fac; } - void HTRANS1(int const NS, // Figure Number + void HTRANS1(EnergyPlusData &state, int const NS, // Figure Number int const NumVertices // Number of vertices ) { // Using/Aliasing using General::TrimSigDigits; - if (NS > 2 * MaxHCS) { - ShowFatalError("Solar Shading: HTrans1: Too many Figures (>" + TrimSigDigits(MaxHCS) + ')'); + if (NS > 2 * state.dataSolarShading->MaxHCS) { + ShowFatalError("Solar Shading: HTrans1: Too many Figures (>" + TrimSigDigits(state.dataSolarShading->MaxHCS) + ')'); } - HCNV(NS) = NumVertices; + state.dataSolarShading->HCNV(NS) = NumVertices; // Tuned Linear indexing - assert(equal_dimensions(HCX, HCY)); - assert(equal_dimensions(HCX, HCA)); - assert(equal_dimensions(HCX, HCB)); - assert(equal_dimensions(HCX, HCC)); + assert(equal_dimensions(state.dataSolarShading->HCX, state.dataSolarShading->HCY)); + assert(equal_dimensions(state.dataSolarShading->HCX, state.dataSolarShading->HCA)); + assert(equal_dimensions(state.dataSolarShading->HCX, state.dataSolarShading->HCB)); + assert(equal_dimensions(state.dataSolarShading->HCX, state.dataSolarShading->HCC)); - auto const l1(HCX.index(NS, 1)); + auto const l1(state.dataSolarShading->HCX.index(NS, 1)); // only in HTRANS1 auto l(l1); for (int N = 1; N <= NumVertices; ++N, ++l) { // [ l ] == ( NS, N ) - HCX[l] = nint64(XVS(N) * HCMULT); - HCY[l] = nint64(YVS(N) * HCMULT); + state.dataSolarShading->HCX[l] = nint64(state.dataSolarShading->XVS(N) * state.dataSolarShading->HCMULT); + state.dataSolarShading->HCY[l] = nint64(state.dataSolarShading->YVS(N) * state.dataSolarShading->HCMULT); } - l = HCX.index(NS, NumVertices + 1); - Int64 HCX_m(HCX[l] = HCX[l1]); // [ l1 ] == ( NS, 1 ) - Int64 HCY_m(HCY[l] = HCY[l1]); + l = state.dataSolarShading->HCX.index(NS, NumVertices + 1); + Int64 HCX_m(state.dataSolarShading->HCX[l] = state.dataSolarShading->HCX[l1]); // [ l1 ] == ( NS, 1 ) + Int64 HCY_m(state.dataSolarShading->HCY[l] = state.dataSolarShading->HCY[l1]); l = l1; auto m(l1 + 1u); @@ -3671,17 +3358,17 @@ namespace SolarShading { for (int N = 1; N <= NumVertices; ++N, ++l, ++m) { // [ l ] == ( NS, N ), [ m ] == ( NS, N + 1 ) HCX_l = HCX_m; HCY_l = HCY_m; - HCX_m = HCX[m]; - HCY_m = HCY[m]; - HCA[l] = HCY_l - HCY_m; - HCB[l] = HCX_m - HCX_l; - SUM += HCC[l] = (HCY_m * HCX_l) - (HCX_m * HCY_l); + HCX_m = state.dataSolarShading->HCX[m]; + HCY_m = state.dataSolarShading->HCY[m]; + state.dataSolarShading->HCA[l] = HCY_l - HCY_m; + state.dataSolarShading->HCB[l] = HCX_m - HCX_l; + SUM += state.dataSolarShading->HCC[l] = (HCY_m * HCX_l) - (HCX_m * HCY_l); } - HCAREA(NS) = SUM * sqHCMULT_fac; + state.dataSolarShading->HCAREA(NS) = SUM * state.dataSolarShading->sqHCMULT_fac; } - void INCLOS(int const N1, // Figure number of figure 1 + void INCLOS(EnergyPlusData &state, int const N1, // Figure number of figure 1 int const N1NumVert, // Number of vertices of figure 1 int const N2, // Figure number of figure 2 int const N2NumVert, // Number of vertices of figure 2 @@ -3707,22 +3394,6 @@ namespace SolarShading { // REFERENCES: // BLAST/IBLAST code, original author George Walton - // USE STATEMENTS: - // na - - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int K; // Vertex number of the overlap int M; // Side number of figure N2 int N; // Vertex number of figure N1 @@ -3738,7 +3409,7 @@ namespace SolarShading { // Eliminate cases where vertex N is to the left of side M. for (M = 1; M <= N2NumVert; ++M) { - HFunct = HCX(N1, N) * HCA(N2, M) + HCY(N1, N) * HCB(N2, M) + HCC(N2, M); + HFunct = state.dataSolarShading->HCX(N1, N) * state.dataSolarShading->HCA(N2, M) + state.dataSolarShading->HCY(N1, N) * state.dataSolarShading->HCB(N2, M) + state.dataSolarShading->HCC(N2, M); if (HFunct > 0.0) { CycleMainLoop = true; // Set to cycle to the next value of N break; // M DO loop @@ -3752,7 +3423,7 @@ namespace SolarShading { if (NumVerticesOverlap != 0) { for (K = 1; K <= NumVerticesOverlap; ++K) { - if ((XTEMP(K) == HCX(N1, N)) && (YTEMP(K) == HCY(N1, N))) { + if ((state.dataSolarShading->XTEMP(K) == state.dataSolarShading->HCX(N1, N)) && (state.dataSolarShading->YTEMP(K) == state.dataSolarShading->HCY(N1, N))) { CycleMainLoop = true; // Set to cycle to the next value of N break; // K DO loop } @@ -3763,12 +3434,12 @@ namespace SolarShading { // Record enclosed vertices in temporary arrays. ++NumVerticesOverlap; - XTEMP(NumVerticesOverlap) = HCX(N1, N); - YTEMP(NumVerticesOverlap) = HCY(N1, N); + state.dataSolarShading->XTEMP(NumVerticesOverlap) = state.dataSolarShading->HCX(N1, N); + state.dataSolarShading->YTEMP(NumVerticesOverlap) = state.dataSolarShading->HCY(N1, N); } } - void INTCPT(int const NV1, // Number of vertices of figure NS1 + void INTCPT(EnergyPlusData &state, int const NV1, // Number of vertices of figure NS1 int const NV2, // Number of vertices of figure NS2 int &NV3, // Number of vertices of figure NS3 int const NS1, // Number of the figure being overlapped @@ -3795,23 +3466,6 @@ namespace SolarShading { // REFERENCES: // BLAST/IBLAST code, original author George Walton - // USE STATEMENTS: - // na - - // Locals - - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: Real64 W; // Normalization factor Real64 XUntrunc; // Untruncated X coordinate Real64 YUntrunc; // Untruncated Y coordinate @@ -3827,13 +3481,13 @@ namespace SolarShading { // Eliminate cases where sides N and M do not intersect. - I1 = HCA(NS1, N) * HCX(NS2, M) + HCB(NS1, N) * HCY(NS2, M) + HCC(NS1, N); - I2 = HCA(NS1, N) * HCX(NS2, M + 1) + HCB(NS1, N) * HCY(NS2, M + 1) + HCC(NS1, N); + I1 = state.dataSolarShading->HCA(NS1, N) * state.dataSolarShading->HCX(NS2, M) + state.dataSolarShading->HCB(NS1, N) * state.dataSolarShading->HCY(NS2, M) + state.dataSolarShading->HCC(NS1, N); + I2 = state.dataSolarShading->HCA(NS1, N) * state.dataSolarShading->HCX(NS2, M + 1) + state.dataSolarShading->HCB(NS1, N) * state.dataSolarShading->HCY(NS2, M + 1) + state.dataSolarShading->HCC(NS1, N); if (I1 >= 0 && I2 >= 0) continue; if (I1 <= 0 && I2 <= 0) continue; - I1 = HCA(NS2, M) * HCX(NS1, N) + HCB(NS2, M) * HCY(NS1, N) + HCC(NS2, M); - I2 = HCA(NS2, M) * HCX(NS1, N + 1) + HCB(NS2, M) * HCY(NS1, N + 1) + HCC(NS2, M); + I1 = state.dataSolarShading->HCA(NS2, M) * state.dataSolarShading->HCX(NS1, N) + state.dataSolarShading->HCB(NS2, M) * state.dataSolarShading->HCY(NS1, N) + state.dataSolarShading->HCC(NS2, M); + I2 = state.dataSolarShading->HCA(NS2, M) * state.dataSolarShading->HCX(NS1, N + 1) + state.dataSolarShading->HCB(NS2, M) * state.dataSolarShading->HCY(NS1, N + 1) + state.dataSolarShading->HCC(NS2, M); if (I1 >= 0 && I2 >= 0) continue; if (I1 <= 0 && I2 <= 0) continue; @@ -3841,25 +3495,25 @@ namespace SolarShading { KK = NV3; ++NV3; - W = HCB(NS2, M) * HCA(NS1, N) - HCA(NS2, M) * HCB(NS1, N); - XUntrunc = (HCC(NS2, M) * HCB(NS1, N) - HCB(NS2, M) * HCC(NS1, N)) / W; - YUntrunc = (HCA(NS2, M) * HCC(NS1, N) - HCC(NS2, M) * HCA(NS1, N)) / W; - if (NV3 > isize(XTEMP)) { + W = state.dataSolarShading->HCB(NS2, M) * state.dataSolarShading->HCA(NS1, N) - state.dataSolarShading->HCA(NS2, M) * state.dataSolarShading->HCB(NS1, N); + XUntrunc = (state.dataSolarShading->HCC(NS2, M) * state.dataSolarShading->HCB(NS1, N) - state.dataSolarShading->HCB(NS2, M) * state.dataSolarShading->HCC(NS1, N)) / W; + YUntrunc = (state.dataSolarShading->HCA(NS2, M) * state.dataSolarShading->HCC(NS1, N) - state.dataSolarShading->HCC(NS2, M) * state.dataSolarShading->HCA(NS1, N)) / W; + if (NV3 > isize(state.dataSolarShading->XTEMP)) { // write(outputfiledebug,*) 'nv3=',nv3,' SIZE(xtemp)=',SIZE(xtemp) - XTEMP.redimension(isize(XTEMP) + 10, 0.0); - YTEMP.redimension(isize(YTEMP) + 10, 0.0); + state.dataSolarShading->XTEMP.redimension(isize(state.dataSolarShading->XTEMP) + 10, 0.0); + state.dataSolarShading->YTEMP.redimension(isize(state.dataSolarShading->YTEMP) + 10, 0.0); } - XTEMP(NV3) = nint64(XUntrunc); - YTEMP(NV3) = nint64(YUntrunc); + state.dataSolarShading->XTEMP(NV3) = nint64(XUntrunc); + state.dataSolarShading->YTEMP(NV3) = nint64(YUntrunc); // Eliminate near-duplicate points. if (KK != 0) { - auto const x(XTEMP(NV3)); - auto const y(YTEMP(NV3)); + auto const x(state.dataSolarShading->XTEMP(NV3)); + auto const y(state.dataSolarShading->YTEMP(NV3)); for (K = 1; K <= KK; ++K) { - if (std::abs(x - XTEMP(K)) > 2.0) continue; - if (std::abs(y - YTEMP(K)) > 2.0) continue; + if (std::abs(x - state.dataSolarShading->XTEMP(K)) > 2.0) continue; + if (std::abs(y - state.dataSolarShading->YTEMP(K)) > 2.0) continue; NV3 = KK; break; // K DO loop } @@ -4030,28 +3684,28 @@ namespace SolarShading { } } - void CLIPRECT(int const NS2, int const NV1, int &NV3) { + void CLIPRECT(EnergyPlusData &state, int const NS2, int const NV1, int &NV3) { // Polygon clipping by line segment clipping for rectangles // Reference: // Slater, M., Barsky, B.A. // 2D line and polygon clipping based on space subdivision. // The Visual Computer 10, 407–422 (1994). bool INTFLAG = false; - auto l(HCA.index(NS2, 1)); + auto l(state.dataSolarShading->HCA.index(NS2, 1)); Real64 maxX, minX, maxY, minY; - if (HCX[l] > HCX[l+2]) { - maxX = HCX[l]; - minX = HCX[l+2]; + if (state.dataSolarShading->HCX[l] > state.dataSolarShading->HCX[l+2]) { + maxX = state.dataSolarShading->HCX[l]; + minX = state.dataSolarShading->HCX[l+2]; } else { - maxX = HCX[l+2]; - minX = HCX[l]; + maxX = state.dataSolarShading->HCX[l+2]; + minX = state.dataSolarShading->HCX[l]; } - if (HCY[l] > HCY[l+2]) { - maxY = HCY[l]; - minY = HCY[l+2]; + if (state.dataSolarShading->HCY[l] > state.dataSolarShading->HCY[l+2]) { + maxY = state.dataSolarShading->HCY[l]; + minY = state.dataSolarShading->HCY[l+2]; } else { - maxY = HCY[l+2]; - minY = HCY[l]; + maxY = state.dataSolarShading->HCY[l+2]; + minY = state.dataSolarShading->HCY[l]; } Real64 arrx[20]; //Temp array for output X @@ -4059,10 +3713,10 @@ namespace SolarShading { int arrc = 0; //Number of items in output for (int j = 0; j < NV1; ++j) { - Real64 x_1 = XTEMP[j]; - Real64 y_1 = YTEMP[j]; - Real64 x_2 = XTEMP[(j+1) % NV1]; - Real64 y_2 = YTEMP[(j+1) % NV1]; + Real64 x_1 = state.dataSolarShading->XTEMP[j]; + Real64 y_1 = state.dataSolarShading->YTEMP[j]; + Real64 x_2 = state.dataSolarShading->XTEMP[(j+1) % NV1]; + Real64 y_2 = state.dataSolarShading->YTEMP[(j+1) % NV1]; Real64 x1 = x_1, x2 = x_2, y1 = y_1, y2 = y_2; bool visible = false; @@ -4123,8 +3777,8 @@ namespace SolarShading { } if (edgeCount == 0) { //On inside if (i != arrc) { - XTEMP[incr] = currX; - YTEMP[incr] = currY; + state.dataSolarShading->XTEMP[incr] = currX; + state.dataSolarShading->YTEMP[incr] = currY; incr ++; } continue; @@ -4166,24 +3820,24 @@ namespace SolarShading { bool insideFlag = true; for (int j = 0; j < NV1; ++j) { - if ((ATEMP[j] * cornerX) + (cornerY * BTEMP[j]) + CTEMP[j] > 0.0) { + if ((state.dataSolarShading->ATEMP[j] * cornerX) + (cornerY * state.dataSolarShading->BTEMP[j]) + state.dataSolarShading->CTEMP[j] > 0.0) { insideFlag = false; break; } } - if (insideFlag && (incr == 0 || ((neq(cornerX, XTEMP[incr-1]) || neq(cornerY, YTEMP[incr-1])) && (neq(cornerX, XTEMP[0]) || neq(cornerY, YTEMP[0]))))) + if (insideFlag && (incr == 0 || ((neq(cornerX, state.dataSolarShading->XTEMP[incr-1]) || neq(cornerY, state.dataSolarShading->YTEMP[incr-1])) && (neq(cornerX, state.dataSolarShading->XTEMP[0]) || neq(cornerY, state.dataSolarShading->YTEMP[0]))))) { - XTEMP[incr] = cornerX; - YTEMP[incr] = cornerY; + state.dataSolarShading->XTEMP[incr] = cornerX; + state.dataSolarShading->YTEMP[incr] = cornerY; incr ++; added ++; } } if (jumpCount > 2 && (added == jumpCount && edgeCount == 1)) { if (i != arrc) { - XTEMP[incr] = currX; - YTEMP[incr] = currY; + state.dataSolarShading->XTEMP[incr] = currX; + state.dataSolarShading->YTEMP[incr] = currY; incr ++; } break; @@ -4191,8 +3845,8 @@ namespace SolarShading { } } if (i != arrc) { - XTEMP[incr] = currX; - YTEMP[incr] = currY; + state.dataSolarShading->XTEMP[incr] = currX; + state.dataSolarShading->YTEMP[incr] = currY; incr ++; } LastEdgeIndex = EdgeIndex; @@ -4203,8 +3857,8 @@ namespace SolarShading { } else { if (NV3 == 1) { - XTEMP[0] = arrx[0]; - YTEMP[0] = arry[0]; + state.dataSolarShading->XTEMP[0] = arrx[0]; + state.dataSolarShading->YTEMP[0] = arry[0]; } if (NV3 == 0) { double cornerXs[4] = {minX, minX, maxX, maxX}; double cornerYs[4] = {minY, maxY, maxY, minY}; @@ -4212,15 +3866,15 @@ namespace SolarShading { Real64 cornerY = cornerYs[0]; bool insideFlag = true; for (int j = 0; j < NV1; ++j) { - if ((ATEMP[j] * cornerX) + (cornerY * BTEMP[j]) + CTEMP[j] >= 0.0) { + if ((state.dataSolarShading->ATEMP[j] * cornerX) + (cornerY * state.dataSolarShading->BTEMP[j]) + state.dataSolarShading->CTEMP[j] >= 0.0) { insideFlag = false; break; } } if (insideFlag) { for (int i1 = 0; i1 < 4; i1++){ - XTEMP[i1] = cornerXs[i1]; - YTEMP[i1] = cornerYs[i1]; + state.dataSolarShading->XTEMP[i1] = cornerXs[i1]; + state.dataSolarShading->YTEMP[i1] = cornerYs[i1]; } NV3 = 4; INTFLAG = true; @@ -4230,36 +3884,36 @@ namespace SolarShading { // update homogenous edges A,B,C if (NV3 > 0) { - Real64 const X_0(XTEMP[0]); - Real64 const Y_0(YTEMP[0]); + Real64 const X_0(state.dataSolarShading->XTEMP[0]); + Real64 const Y_0(state.dataSolarShading->YTEMP[0]); Real64 XP_0 = X_0, XP_1; Real64 YP_0 = Y_0, YP_1; for (int P = 0; P < NV3-1; ++P) { - XP_1 = XTEMP[P + 1]; - YP_1 = YTEMP[P + 1]; + XP_1 = state.dataSolarShading->XTEMP[P + 1]; + YP_1 = state.dataSolarShading->YTEMP[P + 1]; - ATEMP[P] = YP_0 - YP_1; - BTEMP[P] = XP_1 - XP_0; - CTEMP[P] = XP_0 * YP_1 - YP_0 * XP_1; + state.dataSolarShading->ATEMP[P] = YP_0 - YP_1; + state.dataSolarShading->BTEMP[P] = XP_1 - XP_0; + state.dataSolarShading->CTEMP[P] = XP_0 * YP_1 - YP_0 * XP_1; XP_0 = XP_1; YP_0 = YP_1; } - ATEMP[NV3-1] = YP_1 - Y_0; - BTEMP[NV3-1] = X_0 - XP_1; - CTEMP[NV3-1] = XP_1 * Y_0 - YP_1 * X_0; + state.dataSolarShading->ATEMP[NV3-1] = YP_1 - Y_0; + state.dataSolarShading->BTEMP[NV3-1] = X_0 - XP_1; + state.dataSolarShading->CTEMP[NV3-1] = XP_1 * Y_0 - YP_1 * X_0; } //Determine overlap status if (NV3 < 3) { // Determine overlap status - OverlapStatus = NoOverlap; + state.dataSolarShading->OverlapStatus = state.dataSolarShading->NoOverlap; } else if (!INTFLAG) { - OverlapStatus = FirstSurfWithinSecond; + state.dataSolarShading->OverlapStatus = state.dataSolarShading->FirstSurfWithinSecond; } } - void CLIPPOLY(int const NS1, // Figure number of figure 1 (The subject polygon) + void CLIPPOLY(EnergyPlusData &state, int const NS1, // Figure number of figure 1 (The subject polygon) int const NS2, // Figure number of figure 2 (The clipping polygon) int const NV1, // Number of vertices of figure 1 int const NV2, // Number of vertices of figure 2 @@ -4280,27 +3934,9 @@ namespace SolarShading { // METHODOLOGY EMPLOYED: // The Sutherland-Hodgman algorithm for polygon clipping is employed. - // METHODOLOGY EMPLOYED: - - // REFERENCES: - - // Using/Aliasing using General::ReallocateRealArray; using General::SafeDivide; - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: typedef Array2D::size_type size_type; bool INTFLAG; // For overlap status int S; // Test vertex @@ -4316,18 +3952,18 @@ namespace SolarShading { #endif // Tuned Linear indexing - assert(equal_dimensions(HCX, HCY)); - assert(equal_dimensions(HCX, HCA)); - assert(equal_dimensions(HCX, HCB)); - assert(equal_dimensions(HCX, HCC)); + assert(equal_dimensions(state.dataSolarShading->HCX, state.dataSolarShading->HCY)); + assert(equal_dimensions(state.dataSolarShading->HCX, state.dataSolarShading->HCA)); + assert(equal_dimensions(state.dataSolarShading->HCX, state.dataSolarShading->HCB)); + assert(equal_dimensions(state.dataSolarShading->HCX, state.dataSolarShading->HCC)); // Populate the arrays with the original polygon - for (size_type j = 0, l = HCX.index(NS1, 1), e = NV1; j < e; ++j, ++l) { - XTEMP[j] = HCX[l]; // [ l ] == ( NS1, j+1 ) - YTEMP[j] = HCY[l]; - ATEMP[j] = HCA[l]; - BTEMP[j] = HCB[l]; - CTEMP[j] = HCC[l]; + for (size_type j = 0, l = state.dataSolarShading->HCX.index(NS1, 1), e = NV1; j < e; ++j, ++l) { + state.dataSolarShading->XTEMP[j] = state.dataSolarShading->HCX[l]; // [ l ] == ( NS1, j+1 ) + state.dataSolarShading->YTEMP[j] = state.dataSolarShading->HCY[l]; + state.dataSolarShading->ATEMP[j] = state.dataSolarShading->HCA[l]; + state.dataSolarShading->BTEMP[j] = state.dataSolarShading->HCB[l]; + state.dataSolarShading->CTEMP[j] = state.dataSolarShading->HCC[l]; } NVOUT = NV1; // First point-loop is the length of the subject polygon. @@ -4337,34 +3973,34 @@ namespace SolarShading { //Check if clipping polygon is rectangle if (DataSystemVariables::SlaterBarsky) { - auto l1(HCA.index(NS2, 1)); - bool rectFlag = ((NV2 == 4) && (((((HCX[l1] == HCX[l1 + 1] && HCY[l1] != HCY[l1 + 1]) && - ((HCY[l1 + 2] == HCY[l1 + 1] && HCY[l1 + 3] == HCY[l1]))) && - HCX[l1 + 2] == HCX[l1 + 3]) || - ((((HCY[l1] == HCY[l1 + 1] && HCX[l1] != HCX[l1 + 1]) && - (HCX[l1 + 2] == HCX[l1 + 1] && HCX[l1 + 3] == HCX[l1])) && - (HCY[l1 + 2] == HCY[l1 + 3])))))); + auto l1(state.dataSolarShading->HCA.index(NS2, 1)); + bool rectFlag = ((NV2 == 4) && (((((state.dataSolarShading->HCX[l1] == state.dataSolarShading->HCX[l1 + 1] && state.dataSolarShading->HCY[l1] != state.dataSolarShading->HCY[l1 + 1]) && + ((state.dataSolarShading->HCY[l1 + 2] == state.dataSolarShading->HCY[l1 + 1] && state.dataSolarShading->HCY[l1 + 3] == state.dataSolarShading->HCY[l1]))) && + state.dataSolarShading->HCX[l1 + 2] == state.dataSolarShading->HCX[l1 + 3]) || + ((((state.dataSolarShading->HCY[l1] == state.dataSolarShading->HCY[l1 + 1] && state.dataSolarShading->HCX[l1] != state.dataSolarShading->HCX[l1 + 1]) && + (state.dataSolarShading->HCX[l1 + 2] == state.dataSolarShading->HCX[l1 + 1] && state.dataSolarShading->HCX[l1 + 3] == state.dataSolarShading->HCX[l1])) && + (state.dataSolarShading->HCY[l1 + 2] == state.dataSolarShading->HCY[l1 + 3])))))); if (rectFlag) { - CLIPRECT(NS2, NV1, NV3); + CLIPRECT(state, NS2, NV1, NV3); return; } } - auto l(HCA.index(NS2, 1)); + auto l(state.dataSolarShading->HCA.index(NS2, 1)); for (int E = 1; E <= NV2; ++E, ++l) { // Loop over edges of the clipping polygon for (int P = 1; P <= NVOUT; ++P) { - XTEMP1(P) = XTEMP(P); - YTEMP1(P) = YTEMP(P); + state.dataSolarShading->XTEMP1(P) = state.dataSolarShading->XTEMP(P); + state.dataSolarShading->YTEMP1(P) = state.dataSolarShading->YTEMP(P); } S = NVOUT; - Real64 const HCA_E(HCA[l]); - Real64 const HCB_E(HCB[l]); - Real64 const HCC_E(HCC[l]); - Real64 XTEMP1_S(XTEMP1(S)); - Real64 YTEMP1_S(YTEMP1(S)); + Real64 const HCA_E(state.dataSolarShading->HCA[l]); + Real64 const HCB_E(state.dataSolarShading->HCB[l]); + Real64 const HCC_E(state.dataSolarShading->HCC[l]); + Real64 XTEMP1_S(state.dataSolarShading->XTEMP1(S)); + Real64 YTEMP1_S(state.dataSolarShading->YTEMP1(S)); for (int P = 1; P <= NVOUT; ++P) { - Real64 const XTEMP1_P(XTEMP1(P)); - Real64 const YTEMP1_P(YTEMP1(P)); + Real64 const XTEMP1_P(state.dataSolarShading->XTEMP1(P)); + Real64 const YTEMP1_P(state.dataSolarShading->YTEMP1(P)); HFunct = XTEMP1_P * HCA_E + YTEMP1_P * HCB_E + HCC_E; // S is constant within this block if (HFunct <= 0.0) { // Vertex is not in the clipping plane @@ -4374,27 +4010,27 @@ namespace SolarShading { // Find/store the intersection of the clip edge and the line connecting S and P KK = NVTEMP; ++NVTEMP; - Real64 const ATEMP_S(ATEMP(S)); - Real64 const BTEMP_S(BTEMP(S)); - Real64 const CTEMP_S(CTEMP(S)); + Real64 const ATEMP_S(state.dataSolarShading->ATEMP(S)); + Real64 const BTEMP_S(state.dataSolarShading->BTEMP(S)); + Real64 const CTEMP_S(state.dataSolarShading->CTEMP(S)); W = HCB_E * ATEMP_S - HCA_E * BTEMP_S; if (W != 0.0) { Real64 const W_inv(1.0 / W); - XTEMP(NVTEMP) = nint64((HCC_E * BTEMP_S - HCB_E * CTEMP_S) * W_inv); - YTEMP(NVTEMP) = nint64((HCA_E * CTEMP_S - HCC_E * ATEMP_S) * W_inv); + state.dataSolarShading->XTEMP(NVTEMP) = nint64((HCC_E * BTEMP_S - HCB_E * CTEMP_S) * W_inv); + state.dataSolarShading->YTEMP(NVTEMP) = nint64((HCA_E * CTEMP_S - HCC_E * ATEMP_S) * W_inv); } else { - XTEMP(NVTEMP) = SafeDivide(HCC_E * BTEMP_S - HCB_E * CTEMP_S, W); - YTEMP(NVTEMP) = SafeDivide(HCA_E * CTEMP_S - HCC_E * ATEMP_S, W); + state.dataSolarShading->XTEMP(NVTEMP) = SafeDivide(HCC_E * BTEMP_S - HCB_E * CTEMP_S, W); + state.dataSolarShading->YTEMP(NVTEMP) = SafeDivide(HCA_E * CTEMP_S - HCC_E * ATEMP_S, W); } INTFLAG = true; if (E == NV2) { // Remove near-duplicates on last edge if (KK != 0) { - auto const x(XTEMP(NVTEMP)); - auto const y(YTEMP(NVTEMP)); + auto const x(state.dataSolarShading->XTEMP(NVTEMP)); + auto const y(state.dataSolarShading->YTEMP(NVTEMP)); for (int K = 1; K <= KK; ++K) { - if (std::abs(x - XTEMP(K)) > 2.0) continue; - if (std::abs(y - YTEMP(K)) > 2.0) continue; + if (std::abs(x - state.dataSolarShading->XTEMP(K)) > 2.0) continue; + if (std::abs(y - state.dataSolarShading->YTEMP(K)) > 2.0) continue; NVTEMP = KK; break; // K loop } @@ -4404,28 +4040,28 @@ namespace SolarShading { KK = NVTEMP; ++NVTEMP; - if (NVTEMP > MAXHCArrayBounds) { - int const NewArrayBounds(MAXHCArrayBounds + MAXHCArrayIncrement); - XTEMP.redimension(NewArrayBounds, 0.0); - YTEMP.redimension(NewArrayBounds, 0.0); - XTEMP1.redimension(NewArrayBounds, 0.0); - YTEMP1.redimension(NewArrayBounds, 0.0); - ATEMP.redimension(NewArrayBounds, 0.0); - BTEMP.redimension(NewArrayBounds, 0.0); - CTEMP.redimension(NewArrayBounds, 0.0); - MAXHCArrayBounds = NewArrayBounds; + if (NVTEMP > state.dataSolarShading->MAXHCArrayBounds) { + int const NewArrayBounds(state.dataSolarShading->MAXHCArrayBounds + state.dataSolarShading->MAXHCArrayIncrement); + state.dataSolarShading->XTEMP.redimension(NewArrayBounds, 0.0); + state.dataSolarShading->YTEMP.redimension(NewArrayBounds, 0.0); + state.dataSolarShading->XTEMP1.redimension(NewArrayBounds, 0.0); + state.dataSolarShading->YTEMP1.redimension(NewArrayBounds, 0.0); + state.dataSolarShading->ATEMP.redimension(NewArrayBounds, 0.0); + state.dataSolarShading->BTEMP.redimension(NewArrayBounds, 0.0); + state.dataSolarShading->CTEMP.redimension(NewArrayBounds, 0.0); + state.dataSolarShading->MAXHCArrayBounds = NewArrayBounds; } - XTEMP(NVTEMP) = XTEMP1_P; - YTEMP(NVTEMP) = YTEMP1_P; + state.dataSolarShading->XTEMP(NVTEMP) = XTEMP1_P; + state.dataSolarShading->YTEMP(NVTEMP) = YTEMP1_P; if (E == NV2) { // Remove near-duplicates on last edge if (KK != 0) { - auto const x(XTEMP(NVTEMP)); - auto const y(YTEMP(NVTEMP)); + auto const x(state.dataSolarShading->XTEMP(NVTEMP)); + auto const y(state.dataSolarShading->YTEMP(NVTEMP)); for (int K = 1; K <= KK; ++K) { - if (std::abs(x - XTEMP(K)) > 2.0) continue; - if (std::abs(y - YTEMP(K)) > 2.0) continue; + if (std::abs(x - state.dataSolarShading->XTEMP(K)) > 2.0) continue; + if (std::abs(y - state.dataSolarShading->YTEMP(K)) > 2.0) continue; NVTEMP = KK; break; // K loop } @@ -4438,27 +4074,27 @@ namespace SolarShading { if (NVTEMP < 2 * (MaxVerticesPerSurface + 1)) { // avoid assigning to element outside of XTEMP array size KK = NVTEMP; ++NVTEMP; - Real64 const ATEMP_S(ATEMP(S)); - Real64 const BTEMP_S(BTEMP(S)); - Real64 const CTEMP_S(CTEMP(S)); + Real64 const ATEMP_S(state.dataSolarShading->ATEMP(S)); + Real64 const BTEMP_S(state.dataSolarShading->BTEMP(S)); + Real64 const CTEMP_S(state.dataSolarShading->CTEMP(S)); W = HCB_E * ATEMP_S - HCA_E * BTEMP_S; if (W != 0.0) { Real64 const W_inv(1.0 / W); - XTEMP(NVTEMP) = nint64((HCC_E * BTEMP_S - HCB_E * CTEMP_S) * W_inv); - YTEMP(NVTEMP) = nint64((HCA_E * CTEMP_S - HCC_E * ATEMP_S) * W_inv); + state.dataSolarShading->XTEMP(NVTEMP) = nint64((HCC_E * BTEMP_S - HCB_E * CTEMP_S) * W_inv); + state.dataSolarShading->YTEMP(NVTEMP) = nint64((HCA_E * CTEMP_S - HCC_E * ATEMP_S) * W_inv); } else { - XTEMP(NVTEMP) = SafeDivide(HCC_E * BTEMP_S - HCB_E * CTEMP_S, W); - YTEMP(NVTEMP) = SafeDivide(HCA_E * CTEMP_S - HCC_E * ATEMP_S, W); + state.dataSolarShading->XTEMP(NVTEMP) = SafeDivide(HCC_E * BTEMP_S - HCB_E * CTEMP_S, W); + state.dataSolarShading->YTEMP(NVTEMP) = SafeDivide(HCA_E * CTEMP_S - HCC_E * ATEMP_S, W); } INTFLAG = true; if (E == NV2) { // Remove near-duplicates on last edge if (KK != 0) { - auto const x(XTEMP(NVTEMP)); - auto const y(YTEMP(NVTEMP)); + auto const x(state.dataSolarShading->XTEMP(NVTEMP)); + auto const y(state.dataSolarShading->YTEMP(NVTEMP)); for (int K = 1; K <= KK; ++K) { - if (std::abs(x - XTEMP(K)) > 2.0) continue; - if (std::abs(y - YTEMP(K)) > 2.0) continue; + if (std::abs(x - state.dataSolarShading->XTEMP(K)) > 2.0) continue; + if (std::abs(y - state.dataSolarShading->YTEMP(K)) > 2.0) continue; NVTEMP = KK; break; // K loop } @@ -4478,22 +4114,22 @@ namespace SolarShading { if (E != NV2) { if (NVOUT > 2) { // Compute HC values for edges of output polygon - Real64 const X_1(XTEMP(1)); - Real64 const Y_1(YTEMP(1)); + Real64 const X_1(state.dataSolarShading->XTEMP(1)); + Real64 const Y_1(state.dataSolarShading->YTEMP(1)); Real64 X_P(X_1), X_P1; Real64 Y_P(Y_1), Y_P1; for (int P = 1; P < NVOUT; ++P) { - X_P1 = XTEMP(P + 1); - Y_P1 = YTEMP(P + 1); - ATEMP(P) = Y_P - Y_P1; - BTEMP(P) = X_P1 - X_P; - CTEMP(P) = X_P * Y_P1 - Y_P * X_P1; + X_P1 = state.dataSolarShading->XTEMP(P + 1); + Y_P1 = state.dataSolarShading->YTEMP(P + 1); + state.dataSolarShading->ATEMP(P) = Y_P - Y_P1; + state.dataSolarShading->BTEMP(P) = X_P1 - X_P; + state.dataSolarShading->CTEMP(P) = X_P * Y_P1 - Y_P * X_P1; X_P = X_P1; Y_P = Y_P1; } - ATEMP(NVOUT) = Y_P1 - Y_1; - BTEMP(NVOUT) = X_1 - X_P1; - CTEMP(NVOUT) = X_P1 * Y_1 - Y_P1 * X_1; + state.dataSolarShading->ATEMP(NVOUT) = Y_P1 - Y_1; + state.dataSolarShading->BTEMP(NVOUT) = X_1 - X_P1; + state.dataSolarShading->CTEMP(NVOUT) = X_P1 * Y_1 - Y_P1 * X_1; } } @@ -4502,13 +4138,13 @@ namespace SolarShading { NV3 = NVOUT; if (NV3 < 3) { // Determine overlap status - OverlapStatus = NoOverlap; + state.dataSolarShading->OverlapStatus = state.dataSolarShading->NoOverlap; } else if (!INTFLAG) { - OverlapStatus = FirstSurfWithinSecond; + state.dataSolarShading->OverlapStatus = state.dataSolarShading->FirstSurfWithinSecond; } } - void MULTOL(int const NNN, // argument + void MULTOL(EnergyPlusData &state, int const NNN, // argument int const LOC0, // Location in the homogeneous coordinate array int const NRFIGS // Number of figures overlapped ) @@ -4525,54 +4161,35 @@ namespace SolarShading { // 'LOC0+1' through 'LOC0+NRFIGS'. For example, if NS2 // is a shadow, overlap with previous shadows. - // METHODOLOGY EMPLOYED: - // na // REFERENCES: // BLAST/IBLAST code, original author George Walton - // USE STATEMENTS: - // na - - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - // first figure overlapped (minus 1) - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int I; // Loop Control int NS1; // Number of the figure being overlapped int NS2; // Number of the figure doing overlapping int NS3; // Location to place results of overlap - maxNumberOfFigures = max(maxNumberOfFigures, NRFIGS); + state.dataSolarShading->maxNumberOfFigures = max(state.dataSolarShading->maxNumberOfFigures, NRFIGS); NS2 = NNN; for (I = 1; I <= NRFIGS; ++I) { NS1 = LOC0 + I; - NS3 = LOCHCA + 1; + NS3 = state.dataSolarShading->LOCHCA + 1; - DeterminePolygonOverlap(NS1, NS2, NS3); // Find overlap of figure NS2 on figure NS1. + DeterminePolygonOverlap(state, NS1, NS2, NS3); // Find overlap of figure NS2 on figure NS1. // Process overlap cases: - if (OverlapStatus == NoOverlap) continue; + if (state.dataSolarShading->OverlapStatus == state.dataSolarShading->NoOverlap) continue; - if ((OverlapStatus == TooManyVertices) || (OverlapStatus == TooManyFigures)) break; + if ((state.dataSolarShading->OverlapStatus == state.dataSolarShading->TooManyVertices) || (state.dataSolarShading->OverlapStatus == state.dataSolarShading->TooManyFigures)) break; - LOCHCA = NS3; // Increment h.c. arrays pointer. + state.dataSolarShading->LOCHCA = NS3; // Increment h.c. arrays pointer. } } - void ORDER(int const NV3, // Number of vertices of figure NS3 + void ORDER(EnergyPlusData &state, int const NV3, // Number of vertices of figure NS3 int const NS3 // Location to place results of overlap ) { @@ -4596,22 +4213,6 @@ namespace SolarShading { // REFERENCES: // BLAST/IBLAST code, original author George Walton - // USE STATEMENTS: - // na - - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: static Array1D SLOPE; // Slopes from left-most vertex to others Real64 DELTAX; // Difference between X coordinates of two vertices Real64 DELTAY; // Difference between Y coordinates of two vertices @@ -4627,18 +4228,18 @@ namespace SolarShading { int N; // Vertex number int P; // Location of first slope to be sorted - if (ORDERFirstTimeFlag) { + if (state.dataSolarShading->ORDERFirstTimeFlag) { SLOPE.allocate(max(10, MaxVerticesPerSurface + 1)); - ORDERFirstTimeFlag = false; + state.dataSolarShading->ORDERFirstTimeFlag = false; } // Determine left-most vertex. - XMIN = XTEMP(1); - YXMIN = YTEMP(1); + XMIN = state.dataSolarShading->XTEMP(1); + YXMIN = state.dataSolarShading->YTEMP(1); for (N = 2; N <= NV3; ++N) { - if (XTEMP(N) >= XMIN) continue; - XMIN = XTEMP(N); - YXMIN = YTEMP(N); + if (state.dataSolarShading->XTEMP(N) >= XMIN) continue; + XMIN = state.dataSolarShading->XTEMP(N); + YXMIN = state.dataSolarShading->YTEMP(N); } // Determine slopes from left-most vertex to all others. Identify @@ -4648,31 +4249,31 @@ namespace SolarShading { M = 0; for (N = 1; N <= NV3; ++N) { - DELTAX = XTEMP(N) - XMIN; - DELTAY = YTEMP(N) - YXMIN; + DELTAX = state.dataSolarShading->XTEMP(N) - XMIN; + DELTAY = state.dataSolarShading->YTEMP(N) - YXMIN; if (std::abs(DELTAX) > 0.5) { ++M; SLOPE(M) = DELTAY / DELTAX; - XTEMP(M) = XTEMP(N); - YTEMP(M) = YTEMP(N); + state.dataSolarShading->XTEMP(M) = state.dataSolarShading->XTEMP(N); + state.dataSolarShading->YTEMP(M) = state.dataSolarShading->YTEMP(N); } else if (DELTAY > 0.5) { P = 2; - HCX(NS3, 2) = nint64(XTEMP(N)); - HCY(NS3, 2) = nint64(YTEMP(N)); + state.dataSolarShading->HCX(NS3, 2) = nint64(state.dataSolarShading->XTEMP(N)); + state.dataSolarShading->HCY(NS3, 2) = nint64(state.dataSolarShading->YTEMP(N)); } else if (DELTAY < -0.5) { - HCX(NS3, NV3) = nint64(XTEMP(N)); - HCY(NS3, NV3) = nint64(YTEMP(N)); + state.dataSolarShading->HCX(NS3, NV3) = nint64(state.dataSolarShading->XTEMP(N)); + state.dataSolarShading->HCY(NS3, NV3) = nint64(state.dataSolarShading->YTEMP(N)); } else { - HCX(NS3, 1) = nint64(XMIN); - HCY(NS3, 1) = nint64(YXMIN); + state.dataSolarShading->HCX(NS3, 1) = nint64(XMIN); + state.dataSolarShading->HCY(NS3, 1) = nint64(YXMIN); } } @@ -4684,14 +4285,14 @@ namespace SolarShading { IM1 = I - 1; for (J = 1; J <= IM1; ++J) { if (SLOPE(I) <= SLOPE(J)) continue; - SAVEX = XTEMP(I); - SAVEY = YTEMP(I); + SAVEX = state.dataSolarShading->XTEMP(I); + SAVEY = state.dataSolarShading->YTEMP(I); SAVES = SLOPE(I); - XTEMP(I) = XTEMP(J); - YTEMP(I) = YTEMP(J); + state.dataSolarShading->XTEMP(I) = state.dataSolarShading->XTEMP(J); + state.dataSolarShading->YTEMP(I) = state.dataSolarShading->YTEMP(J); SLOPE(I) = SLOPE(J); - XTEMP(J) = SAVEX; - YTEMP(J) = SAVEY; + state.dataSolarShading->XTEMP(J) = SAVEX; + state.dataSolarShading->YTEMP(J) = SAVEY; SLOPE(J) = SAVES; } } @@ -4700,12 +4301,12 @@ namespace SolarShading { // Place sequenced points in the homogeneous coordinate arrays. for (N = 1; N <= M; ++N) { - HCX(NS3, N + P) = nint64(XTEMP(N)); - HCY(NS3, N + P) = nint64(YTEMP(N)); + state.dataSolarShading->HCX(NS3, N + P) = nint64(state.dataSolarShading->XTEMP(N)); + state.dataSolarShading->HCY(NS3, N + P) = nint64(state.dataSolarShading->YTEMP(N)); } } - void DeterminePolygonOverlap(int const NS1, // Number of the figure being overlapped + void DeterminePolygonOverlap(EnergyPlusData &state, int const NS1, // Number of the figure being overlapped int const NS2, // Number of the figure doing overlapping int const NS3 // Location to place results of overlap ) @@ -4747,19 +4348,6 @@ namespace SolarShading { using DataSystemVariables::SutherlandHodgman; using General::RoundSigDigits; - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int N; // Loop index int NV1; // Number of vertices of figure NS1 int NV2; // Number of vertices of figure NS2 @@ -4772,51 +4360,51 @@ namespace SolarShading { ++NumDetPolyOverlap_Calls; #endif - if (NS3 > MaxHCS) { + if (NS3 > state.dataSolarShading->MaxHCS) { - OverlapStatus = TooManyFigures; + state.dataSolarShading->OverlapStatus = state.dataSolarShading->TooManyFigures; - if (!TooManyFiguresMessage && !DisplayExtraWarnings) { - ShowWarningError("DeterminePolygonOverlap: Too many figures [>" + RoundSigDigits(MaxHCS) + + if (!state.dataSolarShading->TooManyFiguresMessage && !DisplayExtraWarnings) { + ShowWarningError("DeterminePolygonOverlap: Too many figures [>" + RoundSigDigits(state.dataSolarShading->MaxHCS) + "] detected in an overlap calculation. Use Output:Diagnostics,DisplayExtraWarnings; for more details."); - TooManyFiguresMessage = true; + state.dataSolarShading->TooManyFiguresMessage = true; } if (DisplayExtraWarnings) { - TrackTooManyFigures.redimension(++NumTooManyFigures); - TrackTooManyFigures(NumTooManyFigures).SurfIndex1 = CurrentShadowingSurface; - TrackTooManyFigures(NumTooManyFigures).SurfIndex2 = CurrentSurfaceBeingShadowed; + state.dataSolarShading->TrackTooManyFigures.redimension(++state.dataSolarShading->NumTooManyFigures); + state.dataSolarShading->TrackTooManyFigures(state.dataSolarShading->NumTooManyFigures).SurfIndex1 = state.dataSolarShading->CurrentShadowingSurface; + state.dataSolarShading->TrackTooManyFigures(state.dataSolarShading->NumTooManyFigures).SurfIndex2 = state.dataSolarShading->CurrentSurfaceBeingShadowed; } return; } - OverlapStatus = PartialOverlap; - NV1 = HCNV(NS1); - NV2 = HCNV(NS2); + state.dataSolarShading->OverlapStatus = state.dataSolarShading->PartialOverlap; + NV1 = state.dataSolarShading->HCNV(NS1); + NV2 = state.dataSolarShading->HCNV(NS2); NV3 = 0; if (!SutherlandHodgman) { - INCLOS(NS1, NV1, NS2, NV2, NV3, NIN1); // Find vertices of NS1 within NS2. + INCLOS(state, NS1, NV1, NS2, NV2, NV3, NIN1); // Find vertices of NS1 within NS2. if (NIN1 >= NV1) { - OverlapStatus = FirstSurfWithinSecond; + state.dataSolarShading->OverlapStatus = state.dataSolarShading->FirstSurfWithinSecond; } else { - INCLOS(NS2, NV2, NS1, NV1, NV3, NIN2); // Find vertices of NS2 within NS1. + INCLOS(state, NS2, NV2, NS1, NV1, NV3, NIN2); // Find vertices of NS2 within NS1. if (NIN2 >= NV2) { - OverlapStatus = SecondSurfWithinFirst; + state.dataSolarShading->OverlapStatus = state.dataSolarShading->SecondSurfWithinFirst; } else { - INTCPT(NV1, NV2, NV3, NS1, NS2); // Find intercepts of NS1 & NS2. + INTCPT(state, NV1, NV2, NV3, NS1, NS2); // Find intercepts of NS1 & NS2. if (NV3 < 3) { // Overlap must have 3 or more vertices - OverlapStatus = NoOverlap; + state.dataSolarShading->OverlapStatus = state.dataSolarShading->NoOverlap; return; } } @@ -4824,70 +4412,70 @@ namespace SolarShading { } else { // simple polygon clipping - CLIPPOLY(NS1, NS2, NV1, NV2, NV3); + CLIPPOLY(state, NS1, NS2, NV1, NV2, NV3); } - if (NV3 < MaxHCV && NS3 <= MaxHCS) { + if (NV3 < state.dataSolarShading->MaxHCV && NS3 <= state.dataSolarShading->MaxHCS) { if (!SutherlandHodgman) { - ORDER(NV3, NS3); // Put vertices in clockwise order. + ORDER(state, NV3, NS3); // Put vertices in clockwise order. } else { - assert(equal_dimensions(HCX, HCY)); - auto l(HCX.index(NS3, 1)); + assert(equal_dimensions(state.dataSolarShading->HCX, state.dataSolarShading->HCY)); + auto l(state.dataSolarShading->HCX.index(NS3, 1)); for (N = 1; N <= NV3; ++N, ++l) { - HCX[l] = nint64(XTEMP(N)); // [ l ] == ( N, NS3 ) - HCY[l] = nint64(YTEMP(N)); + state.dataSolarShading->HCX[l] = nint64(state.dataSolarShading->XTEMP(N)); // [ l ] == ( N, NS3 ) + state.dataSolarShading->HCY[l] = nint64(state.dataSolarShading->YTEMP(N)); } } - HTRANS0(NS3, NV3); // Determine h.c. values of sides. + HTRANS0(state, NS3, NV3); // Determine h.c. values of sides. // Skip overlaps of negligible area. - if (std::abs(HCAREA(NS3)) * HCMULT < std::abs(HCAREA(NS1))) { - OverlapStatus = NoOverlap; + if (std::abs(state.dataSolarShading->HCAREA(NS3)) * state.dataSolarShading->HCMULT < std::abs(state.dataSolarShading->HCAREA(NS1))) { + state.dataSolarShading->OverlapStatus = state.dataSolarShading->NoOverlap; } else { - if (HCAREA(NS1) * HCAREA(NS2) > 0.0) HCAREA(NS3) = -HCAREA(NS3); // Determine sign of area of overlap - Real64 const HCT_1(HCT(NS1)); - Real64 const HCT_2(HCT(NS2)); + if (state.dataSolarShading->HCAREA(NS1) * state.dataSolarShading->HCAREA(NS2) > 0.0) state.dataSolarShading->HCAREA(NS3) = -state.dataSolarShading->HCAREA(NS3); // Determine sign of area of overlap + Real64 const HCT_1(state.dataSolarShading->HCT(NS1)); + Real64 const HCT_2(state.dataSolarShading->HCT(NS2)); Real64 HCT_3(HCT_2 * HCT_1); // Determine transmission of overlap if (HCT_2 >= 0.5 && HCT_1 >= 0.5) { if (HCT_2 != 1.0 && HCT_1 != 1.0) { HCT_3 = 1.0 - HCT_3; } } - HCT(NS3) = HCT_3; + state.dataSolarShading->HCT(NS3) = HCT_3; } - } else if (NV3 > MaxHCV) { + } else if (NV3 > state.dataSolarShading->MaxHCV) { - OverlapStatus = TooManyVertices; + state.dataSolarShading->OverlapStatus = state.dataSolarShading->TooManyVertices; - if (!TooManyVerticesMessage && !DisplayExtraWarnings) { - ShowWarningError("DeterminePolygonOverlap: Too many vertices [>" + RoundSigDigits(MaxHCV) + + if (!state.dataSolarShading->TooManyVerticesMessage && !DisplayExtraWarnings) { + ShowWarningError("DeterminePolygonOverlap: Too many vertices [>" + RoundSigDigits(state.dataSolarShading->MaxHCV) + "] detected in an overlap calculation. Use Output:Diagnostics,DisplayExtraWarnings; for more details."); - TooManyVerticesMessage = true; + state.dataSolarShading->TooManyVerticesMessage = true; } if (DisplayExtraWarnings) { - TrackTooManyVertices.redimension(++NumTooManyVertices); - TrackTooManyVertices(NumTooManyVertices).SurfIndex1 = CurrentShadowingSurface; - TrackTooManyVertices(NumTooManyVertices).SurfIndex2 = CurrentSurfaceBeingShadowed; + state.dataSolarShading->TrackTooManyVertices.redimension(++state.dataSolarShading->NumTooManyVertices); + state.dataSolarShading->TrackTooManyVertices(state.dataSolarShading->NumTooManyVertices).SurfIndex1 = state.dataSolarShading->CurrentShadowingSurface; + state.dataSolarShading->TrackTooManyVertices(state.dataSolarShading->NumTooManyVertices).SurfIndex2 = state.dataSolarShading->CurrentSurfaceBeingShadowed; } - } else if (NS3 > MaxHCS) { + } else if (NS3 > state.dataSolarShading->MaxHCS) { - OverlapStatus = TooManyFigures; + state.dataSolarShading->OverlapStatus = state.dataSolarShading->TooManyFigures; - if (!TooManyFiguresMessage && !DisplayExtraWarnings) { - ShowWarningError("DeterminePolygonOverlap: Too many figures [>" + RoundSigDigits(MaxHCS) + + if (!state.dataSolarShading->TooManyFiguresMessage && !DisplayExtraWarnings) { + ShowWarningError("DeterminePolygonOverlap: Too many figures [>" + RoundSigDigits(state.dataSolarShading->MaxHCS) + "] detected in an overlap calculation. Use Output:Diagnostics,DisplayExtraWarnings; for more details."); - TooManyFiguresMessage = true; + state.dataSolarShading->TooManyFiguresMessage = true; } if (DisplayExtraWarnings) { - TrackTooManyFigures.redimension(++NumTooManyFigures); - TrackTooManyFigures(NumTooManyFigures).SurfIndex1 = CurrentShadowingSurface; - TrackTooManyFigures(NumTooManyFigures).SurfIndex2 = CurrentSurfaceBeingShadowed; + state.dataSolarShading->TrackTooManyFigures.redimension(++state.dataSolarShading->NumTooManyFigures); + state.dataSolarShading->TrackTooManyFigures(state.dataSolarShading->NumTooManyFigures).SurfIndex1 = state.dataSolarShading->CurrentShadowingSurface; + state.dataSolarShading->TrackTooManyFigures(state.dataSolarShading->NumTooManyFigures).SurfIndex2 = state.dataSolarShading->CurrentSurfaceBeingShadowed; } } } @@ -4909,9 +4497,6 @@ namespace SolarShading { // This subroutine manages computation of solar gain multipliers for beam radiation. These // are calculated for a period of days depending on the input "Shadowing Calculations". - // METHODOLOGY EMPLOYED: - // na - // REFERENCES: // BLAST/IBLAST code, original author George Walton @@ -4925,23 +4510,11 @@ namespace SolarShading { using WindowComplexManager::InitComplexWindows; using WindowComplexManager::UpdateComplexWindows; - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: - - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int iHour; // Hour index number int TS; // TimeStep Loop Countergit - if (InitComplexOnce) InitComplexWindows(state); - InitComplexOnce = false; + if (state.dataSolarShading->InitComplexOnce) InitComplexWindows(state); + state.dataSolarShading->InitComplexOnce = false; if (KickOffSizing || KickOffSimulation) return; // Skip solar calcs for these Initialization steps. @@ -4954,7 +4527,7 @@ namespace SolarShading { SunlitFracHR = 0.0; SunlitFrac = 0.0; SunlitFracWithoutReveal = 0.0; - CTHETA = 0.0; + state.dataSolarShading->CTHETA = 0.0; CosIncAngHR = 0.0; CosIncAng = 0.0; AOSurf = 0.0; @@ -4968,7 +4541,7 @@ namespace SolarShading { SunlitFracHR(HourOfDay, {1, TotSurfaces}) = 0.0; SunlitFrac(TimeStep, HourOfDay, {1, TotSurfaces}) = 0.0; SunlitFracWithoutReveal(TimeStep, HourOfDay, {1, TotSurfaces}) = 0.0; - CTHETA({1, TotSurfaces}) = 0.0; + state.dataSolarShading->CTHETA({1, TotSurfaces}) = 0.0; CosIncAngHR(HourOfDay, {1, TotSurfaces}) = 0.0; CosIncAng(TimeStep, HourOfDay, {1, TotSurfaces}) = 0.0; AOSurf({1, TotSurfaces}) = 0.0; @@ -4983,11 +4556,11 @@ namespace SolarShading { if (!DetailedSolarTimestepIntegration) { for (iHour = 1; iHour <= 24; ++iHour) { // Do for all hours for (TS = 1; TS <= NumOfTimeStepInHour; ++TS) { - FigureSunCosines(iHour, TS, AvgEqOfTime, AvgSinSolarDeclin, AvgCosSolarDeclin); + FigureSunCosines(state, iHour, TS, AvgEqOfTime, AvgSinSolarDeclin, AvgCosSolarDeclin); } } } else { - FigureSunCosines(HourOfDay, TimeStep, AvgEqOfTime, AvgSinSolarDeclin, AvgCosSolarDeclin); + FigureSunCosines(state, HourOfDay, TimeStep, AvgEqOfTime, AvgSinSolarDeclin, AvgCosSolarDeclin); } // Initialize/update the Complex Fenestration geometry and optical properties UpdateComplexWindows(state); @@ -5002,7 +4575,7 @@ namespace SolarShading { } } - void FigureSunCosines(int const iHour, + void FigureSunCosines(EnergyPlusData &state, int const iHour, int const iTimeStep, Real64 const EqOfTime, // value of Equation of Time for period Real64 const SinSolarDeclin, // value of Sine of Solar Declination for period @@ -5023,26 +4596,10 @@ namespace SolarShading { // Given hour, timestep, equation of time, solar declination sine, and solar declination cosine, // determine sun directions for use elsewhere - // REFERENCES: - // na - // Using/Aliasing using DataGlobals::TimeStepZone; using DataSystemVariables::DetailedSolarTimestepIntegration; - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS: - // na - - // DERIVED TYPE DEFINITIONS: - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: Real64 CurrentTime; // Current Time for passing to Solar Position Routine if (NumOfTimeStepInHour != 1) { @@ -5050,16 +4607,16 @@ namespace SolarShading { } else { CurrentTime = double(iHour) + TS1TimeOffset; } - SUN4(CurrentTime, EqOfTime, SinSolarDeclin, CosSolarDeclin); + SUN4(state, CurrentTime, EqOfTime, SinSolarDeclin, CosSolarDeclin); // Save hourly values for use in DaylightingManager if (!DetailedSolarTimestepIntegration) { - if (iTimeStep == NumOfTimeStepInHour) SUNCOSHR(iHour, {1, 3}) = SUNCOS; + if (iTimeStep == NumOfTimeStepInHour) SUNCOSHR(iHour, {1, 3}) = state.dataSolarShading->SUNCOS; } else { - SUNCOSHR(iHour, {1, 3}) = SUNCOS; + SUNCOSHR(iHour, {1, 3}) = state.dataSolarShading->SUNCOS; } // Save timestep values for use in WindowComplexManager - SUNCOSTS(iTimeStep, iHour, {1, 3}) = SUNCOS; + SUNCOSTS(iTimeStep, iHour, {1, 3}) = state.dataSolarShading->SUNCOS; } void FigureSolarBeamAtTimestep(EnergyPlusData &state, int const iHour, int const iTimeStep) @@ -5074,13 +4631,6 @@ namespace SolarShading { // PURPOSE OF THIS SUBROUTINE: // This subroutine computes solar gain multipliers for beam solar - // METHODOLOGY EMPLOYED: - // na - - // REFERENCES: - // na - - // Using/Aliasing using DataSystemVariables::DetailedSkyDiffuseAlgorithm; using DataSystemVariables::DetailedSolarTimestepIntegration; using DataSystemVariables::ReportExtShadingSunlitFrac; @@ -5088,39 +4638,27 @@ namespace SolarShading { using DataSystemVariables::shadingMethod; using ScheduleManager::LookUpScheduleValue; - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: - - // INTERFACE BLOCK SPECIFICATIONS: - // na - - // DERIVED TYPE DEFINITIONS: - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS Real64 SurfArea; // Surface area. For walls, includes all window frame areas. Real64 Fac1WoShdg; // Intermediate calculation factor, without shading Real64 Fac1WithShdg; // Intermediate calculation factor, with shading Real64 FracIlluminated; // Fraction of surface area illuminated by a sky patch // Recover the sun direction from the array stored in previous loop - SUNCOS = SUNCOSTS(iTimeStep, iHour, {1, 3}); + state.dataSolarShading->SUNCOS = SUNCOSTS(iTimeStep, iHour, {1, 3}); - CTHETA = 0.0; + state.dataSolarShading->CTHETA = 0.0; - if (SUNCOS(3) < SunIsUpValue) return; + if (state.dataSolarShading->SUNCOS(3) < SunIsUpValue) return; for (int SurfNum = 1; SurfNum <= TotSurfaces; ++SurfNum) { - CTHETA(SurfNum) = - SUNCOS(1) * Surface(SurfNum).OutNormVec(1) + SUNCOS(2) * Surface(SurfNum).OutNormVec(2) + SUNCOS(3) * Surface(SurfNum).OutNormVec(3); + state.dataSolarShading->CTHETA(SurfNum) = + state.dataSolarShading->SUNCOS(1) * Surface(SurfNum).OutNormVec(1) + state.dataSolarShading->SUNCOS(2) * Surface(SurfNum).OutNormVec(2) + state.dataSolarShading->SUNCOS(3) * Surface(SurfNum).OutNormVec(3); if (!DetailedSolarTimestepIntegration) { - if (iTimeStep == NumOfTimeStepInHour) CosIncAngHR(iHour, SurfNum) = CTHETA(SurfNum); + if (iTimeStep == NumOfTimeStepInHour) CosIncAngHR(iHour, SurfNum) = state.dataSolarShading->CTHETA(SurfNum); } else { - CosIncAngHR(iHour, SurfNum) = CTHETA(SurfNum); + CosIncAngHR(iHour, SurfNum) = state.dataSolarShading->CTHETA(SurfNum); } - CosIncAng(iTimeStep, iHour, SurfNum) = CTHETA(SurfNum); + CosIncAng(iTimeStep, iHour, SurfNum) = state.dataSolarShading->CTHETA(SurfNum); } if ((shadingMethod == ShadingMethod::Scheduled || shadingMethod == ShadingMethod::Imported) && !DoingSizing && state.dataGlobal->KindOfSim == DataGlobalConstants::KindOfSim::RunPeriodWeather){ @@ -5137,11 +4675,11 @@ namespace SolarShading { if (Surface(SurfNum).Area >= 1.e-10) { SurfArea = Surface(SurfNum).NetAreaShadowCalc; if (!DetailedSolarTimestepIntegration) { - if (iTimeStep == NumOfTimeStepInHour) SunlitFracHR(iHour, SurfNum) = SAREA(SurfNum) / SurfArea; + if (iTimeStep == NumOfTimeStepInHour) SunlitFracHR(iHour, SurfNum) = state.dataSolarShading->SAREA(SurfNum) / SurfArea; } else { - SunlitFracHR(iHour, SurfNum) = SAREA(SurfNum) / SurfArea; + SunlitFracHR(iHour, SurfNum) = state.dataSolarShading->SAREA(SurfNum) / SurfArea; } - SunlitFrac(iTimeStep, iHour, SurfNum) = SAREA(SurfNum) / SurfArea; + SunlitFrac(iTimeStep, iHour, SurfNum) = state.dataSolarShading->SAREA(SurfNum) / SurfArea; if (SunlitFrac(iTimeStep, iHour, SurfNum) < 1.e-5) SunlitFrac(iTimeStep, iHour, SurfNum) = 0.0; } // Added check @@ -5158,16 +4696,16 @@ namespace SolarShading { WoShdgHoriz = 0.; for (int IPhi = 0; IPhi < NPhi; ++IPhi) { // Loop over patch altitude values - SUNCOS(3) = sin_Phi[IPhi]; + state.dataSolarShading->SUNCOS(3) = sin_Phi[IPhi]; for (int ITheta = 0; ITheta < NTheta; ++ITheta) { // Loop over patch azimuth values - SUNCOS(1) = cos_Phi[IPhi] * cos_Theta[ITheta]; - SUNCOS(2) = cos_Phi[IPhi] * sin_Theta[ITheta]; + state.dataSolarShading->SUNCOS(1) = cos_Phi[IPhi] * cos_Theta[ITheta]; + state.dataSolarShading->SUNCOS(2) = cos_Phi[IPhi] * sin_Theta[ITheta]; for (int SurfNum = 1; SurfNum <= TotSurfaces; ++SurfNum) { if (!Surface(SurfNum).ShadowingSurf && !Surface(SurfNum).HeatTransSurf) continue; - CTHETA(SurfNum) = SUNCOS(1) * Surface(SurfNum).OutNormVec(1) + SUNCOS(2) * Surface(SurfNum).OutNormVec(2) + - SUNCOS(3) * Surface(SurfNum).OutNormVec(3); + state.dataSolarShading->CTHETA(SurfNum) = state.dataSolarShading->SUNCOS(1) * Surface(SurfNum).OutNormVec(1) + state.dataSolarShading->SUNCOS(2) * Surface(SurfNum).OutNormVec(2) + + state.dataSolarShading->SUNCOS(3) * Surface(SurfNum).OutNormVec(3); } SHADOW(state, iHour, iTimeStep); // Determine sunlit areas and solar multipliers for all surfaces. @@ -5179,14 +4717,14 @@ namespace SolarShading { (Surface(SurfNum).ExtBoundCond != ExternalEnvironment && Surface(SurfNum).ExtBoundCond != OtherSideCondModeledExt))) continue; - if (CTHETA(SurfNum) < 0.0) continue; + if (state.dataSolarShading->CTHETA(SurfNum) < 0.0) continue; - Fac1WoShdg = cos_Phi[IPhi] * DThetaDPhi * CTHETA(SurfNum); + Fac1WoShdg = cos_Phi[IPhi] * DThetaDPhi * state.dataSolarShading->CTHETA(SurfNum); SurfArea = Surface(SurfNum).NetAreaShadowCalc; if (SurfArea > Eps) { - FracIlluminated = SAREA(SurfNum) / SurfArea; + FracIlluminated = state.dataSolarShading->SAREA(SurfNum) / SurfArea; } else { - FracIlluminated = SAREA(SurfNum) / (SurfArea + Eps); + FracIlluminated = state.dataSolarShading->SAREA(SurfNum) / (SurfArea + Eps); } Fac1WithShdg = Fac1WoShdg * FracIlluminated; WithShdgIsoSky(SurfNum) += Fac1WithShdg; @@ -5243,7 +4781,7 @@ namespace SolarShading { if (Surface(SurfNum).Class == SurfaceClass_Window && Surface(SurfNum).ExtBoundCond == ExternalEnvironment && SunlitFrac(iTimeStep, iHour, SurfNum) > 0.0 && Surface(SurfNum).FrameDivider > 0) - CalcFrameDividerShadow(SurfNum, Surface(SurfNum).FrameDivider, iHour); + CalcFrameDividerShadow(state, SurfNum, Surface(SurfNum).FrameDivider, iHour); } } @@ -5275,17 +4813,6 @@ namespace SolarShading { using namespace DataErrorTracking; using General::TrimSigDigits; - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: Array1D_int GSS; // List of shadowing surfaces numbers for a receiving surface Array1D_int BKS; // List of back surface numbers for a receiving surface Array1D_int SBS; // List of subsurfaces for a receiving surface @@ -5316,21 +4843,21 @@ namespace SolarShading { CastingSurface.dimension(TotSurfaces, false); - HCA.dimension(2 * MaxHCS, MaxHCV + 1, 0); - HCB.dimension(2 * MaxHCS, MaxHCV + 1, 0); - HCC.dimension(2 * MaxHCS, MaxHCV + 1, 0); - HCX.dimension(2 * MaxHCS, MaxHCV + 1, 0); - HCY.dimension(2 * MaxHCS, MaxHCV + 1, 0); - HCAREA.dimension(2 * MaxHCS, 0.0); - HCNS.dimension(2 * MaxHCS, 0); - HCNV.dimension(2 * MaxHCS, 0); - HCT.dimension(2 * MaxHCS, 0.0); + state.dataSolarShading->HCA.dimension(2 * state.dataSolarShading->MaxHCS, state.dataSolarShading->MaxHCV + 1, 0); + state.dataSolarShading->HCB.dimension(2 * state.dataSolarShading->MaxHCS, state.dataSolarShading->MaxHCV + 1, 0); + state.dataSolarShading->HCC.dimension(2 * state.dataSolarShading->MaxHCS, state.dataSolarShading->MaxHCV + 1, 0); + state.dataSolarShading->HCX.dimension(2 * state.dataSolarShading->MaxHCS, state.dataSolarShading->MaxHCV + 1, 0); + state.dataSolarShading->HCY.dimension(2 * state.dataSolarShading->MaxHCS, state.dataSolarShading->MaxHCV + 1, 0); + state.dataSolarShading->HCAREA.dimension(2 * state.dataSolarShading->MaxHCS, 0.0); + state.dataSolarShading->HCNS.dimension(2 * state.dataSolarShading->MaxHCS, 0); + state.dataSolarShading->HCNV.dimension(2 * state.dataSolarShading->MaxHCS, 0); + state.dataSolarShading->HCT.dimension(2 * state.dataSolarShading->MaxHCS, 0.0); GSS.dimension(MaxGSS, 0); BKS.dimension(MaxGSS, 0); SBS.dimension(MaxGSS, 0); - penumbraIDs.clear(); + state.dataSolarShading->penumbraIDs.clear(); HTS = 0; @@ -5350,7 +4877,7 @@ namespace SolarShading { HTS = GRSNR; #ifndef EP_NO_OPENGL - if (penumbra) { + if (state.dataSolarShading->penumbra) { bool skipSurface = Surface(GRSNR).MirroredSurf; // Penumbra doesn't need mirrored surfaces TODO: Don't bother creating them in the first place? // Skip interior surfaces if the other side has already been added to penumbra @@ -5401,7 +4928,7 @@ namespace SolarShading { rPoly.push_back(vPrev.z); Pumbra::Surface rSurf(rPoly); - penumbra->addSurface(rSurf); + state.dataSolarShading->penumbra->addSurface(rSurf); } } else { @@ -5440,8 +4967,8 @@ namespace SolarShading { pSurf.addHole(subPoly); } } - Surface(GRSNR).PenumbraID = penumbra->addSurface(pSurf); - penumbraIDs.push_back(Surface(GRSNR).PenumbraID); + Surface(GRSNR).PenumbraID = state.dataSolarShading->penumbra->addSurface(pSurf); + state.dataSolarShading->penumbraIDs.push_back(Surface(GRSNR).PenumbraID); } } #endif @@ -5526,7 +5053,7 @@ namespace SolarShading { if (Surface(SBSNR).BaseSurf != GRSNR) continue; // Ignore subsurfaces of other surfaces and other surfaces if (state.dataConstruction->Construct(Surface(SBSNR).Construction).TransDiff > 0.0) HasWindow = true; // Check for window - CHKSBS(HTS, GRSNR, SBSNR); // Check that the receiving surface completely encloses the subsurface; + CHKSBS(state, HTS, GRSNR, SBSNR); // Check that the receiving surface completely encloses the subsurface; // severe error if not ++NSBS; if (NSBS > MaxSBS) { @@ -5557,7 +5084,7 @@ namespace SolarShading { // interior windows. Was removed to allow such beam solar but then somehow was put back in. // IF (Surface(BackSurfaceNumber)%BaseSurf /= BackSurfaceNumber) CYCLE ! Not for subsurfaces of Back Surface - if (!penumbra) { + if (!state.dataSolarShading->penumbra) { CHKBKS(BackSurfaceNumber, GRSNR); // CHECK FOR CONVEX ZONE; severe error if not } ++NBKS; @@ -5600,7 +5127,7 @@ namespace SolarShading { SBS.deallocate(); BKS.deallocate(); - if (!penumbra) { + if (!state.dataSolarShading->penumbra) { if (shd_stream) { *shd_stream << "Shadowing Combinations\n"; if (SolarDistribution == MinimalShadowing) { @@ -5690,8 +5217,8 @@ namespace SolarShading { CastingSurface.deallocate(); #ifndef EP_NO_OPENGL - if (penumbra && penumbra->getNumSurfaces() > 0) { - penumbra->setModel(); + if (state.dataSolarShading->penumbra && state.dataSolarShading->penumbra->getNumSurfaces() > 0) { + state.dataSolarShading->penumbra->setModel(); } #endif } @@ -5712,28 +5239,9 @@ namespace SolarShading { // This subroutine is a driving routine for calculations of shadows // and sunlit areas used in computing the solar beam flux multipliers. - // METHODOLOGY EMPLOYED: - // na - // REFERENCES: // BLAST/IBLAST code, original author George Walton - // USE STATEMENTS: - // na - - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS: - // na - - // DERIVED TYPE DEFINITIONS: - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: Real64 XS; // Intermediate result Real64 YS; // Intermediate result Real64 ZS; // Intermediate result @@ -5751,14 +5259,14 @@ namespace SolarShading { Real64 SurfArea; // Surface area. For walls, includes all window frame areas. // For windows, includes divider area - if (ShadowOneTimeFlag) { + if (state.dataSolarShading->ShadowOneTimeFlag) { XVT.allocate(MaxVerticesPerSurface + 1); YVT.allocate(MaxVerticesPerSurface + 1); ZVT.allocate(MaxVerticesPerSurface + 1); XVT = 0.0; YVT = 0.0; ZVT = 0.0; - ShadowOneTimeFlag = false; + state.dataSolarShading->ShadowOneTimeFlag = false; } #ifdef EP_Count_Calls @@ -5769,14 +5277,14 @@ namespace SolarShading { } #endif - SAREA = 0.0; + state.dataSolarShading->SAREA = 0.0; #ifndef EP_NO_OPENGL - if (penumbra) { - Real64 ElevSun = DataGlobalConstants::PiOvr2() - std::acos(SUNCOS(3)); - Real64 AzimSun = std::atan2(SUNCOS(1), SUNCOS(2)); - penumbra->setSunPosition(AzimSun, ElevSun); - penumbra->submitPSSA(); + if (state.dataSolarShading->penumbra) { + Real64 ElevSun = DataGlobalConstants::PiOvr2() - std::acos(state.dataSolarShading->SUNCOS(3)); + Real64 AzimSun = std::atan2(state.dataSolarShading->SUNCOS(1), state.dataSolarShading->SUNCOS(2)); + state.dataSolarShading->penumbra->setSunPosition(AzimSun, ElevSun); + state.dataSolarShading->penumbra->submitPSSA(); } #endif @@ -5784,48 +5292,48 @@ namespace SolarShading { if (!ShadowComb(GRSNR).UseThisSurf) continue; - SAREA(GRSNR) = 0.0; + state.dataSolarShading->SAREA(GRSNR) = 0.0; NGSS = ShadowComb(GRSNR).NumGenSurf; - NGSSHC = 0; + state.dataSolarShading->NGSSHC = 0; NBKS = ShadowComb(GRSNR).NumBackSurf; - NBKSHC = 0; + state.dataSolarShading->NBKSHC = 0; NSBS = ShadowComb(GRSNR).NumSubSurf; - NRVLHC = 0; - NSBSHC = 0; - LOCHCA = 1; + state.dataSolarShading->NRVLHC = 0; + state.dataSolarShading->NSBSHC = 0; + state.dataSolarShading->LOCHCA = 1; // Temporarily determine the old heat transfer surface number (HTS) HTS = GRSNR; - if (CTHETA(GRSNR) < SunIsUpValue) { //.001) THEN ! Receiving surface is not in the sun + if (state.dataSolarShading->CTHETA(GRSNR) < SunIsUpValue) { //.001) THEN ! Receiving surface is not in the sun - SAREA(HTS) = 0.0; + state.dataSolarShading->SAREA(HTS) = 0.0; SHDSBS(state, iHour, GRSNR, NBKS, NSBS, HTS, TS); } else if ((NGSS <= 0) && (NSBS <= 0)) { // Simple surface--no shaders or subsurfaces - SAREA(HTS) = Surface(GRSNR).NetAreaShadowCalc; + state.dataSolarShading->SAREA(HTS) = Surface(GRSNR).NetAreaShadowCalc; } else { // Surface in sun and either shading surfaces or subsurfaces present (or both) #ifndef EP_NO_OPENGL auto id = Surface(HTS).PenumbraID; - if (penumbra && id >= 0) { + if (state.dataSolarShading->penumbra && id >= 0) { // SAREA(HTS) = buildingPSSF.at(id) / CTHETA(HTS); - SAREA(HTS) = penumbra->fetchPSSA(id) / CTHETA(HTS); + state.dataSolarShading->SAREA(HTS) = state.dataSolarShading->penumbra->fetchPSSA(id) / state.dataSolarShading->CTHETA(HTS); // SAREA(HTS) = penumbra->fetchPSSA(Surface(HTS).PenumbraID)/CTHETA(HTS); for (int SS = 1; SS <= NSBS; ++SS) { auto HTSS = ShadowComb(HTS).SubSurf(SS); id = Surface(HTSS).PenumbraID; if (id >= 0) { // SAREA(HTSS) = buildingPSSF.at(id) / CTHETA(HTSS); - SAREA(HTSS) = penumbra->fetchPSSA(id) / CTHETA(HTSS); + state.dataSolarShading->SAREA(HTSS) = state.dataSolarShading->penumbra->fetchPSSA(id) / state.dataSolarShading->CTHETA(HTSS); // SAREA(HTSS) = penumbra->fetchPSSA(Surface(HTSS).PenumbraID)/CTHETA(HTSS); - if (SAREA(HTSS) > 0.0) { - if (iHour > 0 && TS > 0) SunlitFracWithoutReveal(TS, iHour, HTSS) = SAREA(HTSS) / Surface(HTSS).Area; + if (state.dataSolarShading->SAREA(HTSS) > 0.0) { + if (iHour > 0 && TS > 0) SunlitFracWithoutReveal(TS, iHour, HTSS) = state.dataSolarShading->SAREA(HTSS) / Surface(HTSS).Area; } } } - } else if (!penumbra) { + } else if (!state.dataSolarShading->penumbra) { #else { #endif @@ -5833,37 +5341,37 @@ namespace SolarShading { if (Surface(GRSNR).ShadowingSurf) NGRS = GRSNR; // Compute the X and Y displacements of a shadow. - XS = Surface(NGRS).lcsx.x * SUNCOS(1) + Surface(NGRS).lcsx.y * SUNCOS(2) + Surface(NGRS).lcsx.z * SUNCOS(3); - YS = Surface(NGRS).lcsy.x * SUNCOS(1) + Surface(NGRS).lcsy.y * SUNCOS(2) + Surface(NGRS).lcsy.z * SUNCOS(3); - ZS = Surface(NGRS).lcsz.x * SUNCOS(1) + Surface(NGRS).lcsz.y * SUNCOS(2) + Surface(NGRS).lcsz.z * SUNCOS(3); + XS = Surface(NGRS).lcsx.x * state.dataSolarShading->SUNCOS(1) + Surface(NGRS).lcsx.y * state.dataSolarShading->SUNCOS(2) + Surface(NGRS).lcsx.z * state.dataSolarShading->SUNCOS(3); + YS = Surface(NGRS).lcsy.x * state.dataSolarShading->SUNCOS(1) + Surface(NGRS).lcsy.y * state.dataSolarShading->SUNCOS(2) + Surface(NGRS).lcsy.z * state.dataSolarShading->SUNCOS(3); + ZS = Surface(NGRS).lcsz.x * state.dataSolarShading->SUNCOS(1) + Surface(NGRS).lcsz.y * state.dataSolarShading->SUNCOS(2) + Surface(NGRS).lcsz.z * state.dataSolarShading->SUNCOS(3); if (std::abs(ZS) > 1.e-4) { - XShadowProjection = XS / ZS; - YShadowProjection = YS / ZS; - if (std::abs(XShadowProjection) < 1.e-8) XShadowProjection = 0.0; - if (std::abs(YShadowProjection) < 1.e-8) YShadowProjection = 0.0; + state.dataSolarShading->XShadowProjection = XS / ZS; + state.dataSolarShading->YShadowProjection = YS / ZS; + if (std::abs(state.dataSolarShading->XShadowProjection) < 1.e-8) state.dataSolarShading->XShadowProjection = 0.0; + if (std::abs(state.dataSolarShading->YShadowProjection) < 1.e-8) state.dataSolarShading->YShadowProjection = 0.0; } else { - XShadowProjection = 0.0; - YShadowProjection = 0.0; + state.dataSolarShading->XShadowProjection = 0.0; + state.dataSolarShading->YShadowProjection = 0.0; } CTRANS(GRSNR, NGRS, NVT, XVT, YVT, ZVT); // Transform coordinates of the receiving surface to 2-D form // Re-order its vertices to clockwise sequential. for (N = 1; N <= NVT; ++N) { - XVS(N) = XVT(NVT + 1 - N); - YVS(N) = YVT(NVT + 1 - N); + state.dataSolarShading->XVS(N) = XVT(NVT + 1 - N); + state.dataSolarShading->YVS(N) = YVT(NVT + 1 - N); } - HTRANS1(1, NVT); // Transform to homogeneous coordinates. + HTRANS1(state, 1, NVT); // Transform to homogeneous coordinates. - HCAREA(1) = -HCAREA(1); // Compute (+) gross surface area. - HCT(1) = 1.0; + state.dataSolarShading->HCAREA(1) = -state.dataSolarShading->HCAREA(1); // Compute (+) gross surface area. + state.dataSolarShading->HCT(1) = 1.0; SHDGSS(state, NGRS, iHour, TS, GRSNR, NGSS, HTS); // Determine shadowing on surface. - if (!CalcSkyDifShading) { - SHDBKS(Surface(GRSNR).BaseSurf, GRSNR, NBKS, HTS); // Determine possible back surfaces. + if (!state.dataSolarShading->CalcSkyDifShading) { + SHDBKS(state, Surface(GRSNR).BaseSurf, GRSNR, NBKS, HTS); // Determine possible back surfaces. } } @@ -5871,9 +5379,9 @@ namespace SolarShading { // Error checking: require that 0 <= SAREA <= AREA. + or - .01*AREA added for round-off errors SurfArea = Surface(GRSNR).NetAreaShadowCalc; - SAREA(HTS) = max(0.0, SAREA(HTS)); + state.dataSolarShading->SAREA(HTS) = max(0.0, state.dataSolarShading->SAREA(HTS)); - SAREA(HTS) = min(SAREA(HTS), SurfArea); + state.dataSolarShading->SAREA(HTS) = min(state.dataSolarShading->SAREA(HTS), SurfArea); } // ...end of surface in sun/surface with shaders and/or subsurfaces IF-THEN block // NOTE: @@ -5882,7 +5390,7 @@ namespace SolarShading { } } - void SHDBKS(int const NGRS, // Number of the general receiving surface + void SHDBKS(EnergyPlusData &state, int const NGRS, // Number of the general receiving surface int const CurSurf, int const NBKS, // Number of back surfaces int const HTS // Heat transfer surface number of the general receiving surf @@ -5899,28 +5407,9 @@ namespace SolarShading { // This is the driving subroutine for computing // the sunlit areas for back surfaces. - // METHODOLOGY EMPLOYED: - // na - // REFERENCES: // BLAST/IBLAST code, original author George Walton - // USE STATEMENTS: - // na - - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: typedef Array2D::size_type size_type; int I; int M; @@ -5937,28 +5426,28 @@ namespace SolarShading { // Tuned Linear indexing - assert(equal_dimensions(HCX, HCY)); - assert(equal_dimensions(HCX, HCA)); + assert(equal_dimensions(state.dataSolarShading->HCX, state.dataSolarShading->HCY)); + assert(equal_dimensions(state.dataSolarShading->HCX, state.dataSolarShading->HCA)); - if (SHDBKSOneTimeFlag) { + if (state.dataSolarShading->SHDBKSOneTimeFlag) { XVT.allocate(MaxVerticesPerSurface + 1); YVT.allocate(MaxVerticesPerSurface + 1); ZVT.allocate(MaxVerticesPerSurface + 1); XVT = 0.0; YVT = 0.0; ZVT = 0.0; - SHDBKSOneTimeFlag = false; + state.dataSolarShading->SHDBKSOneTimeFlag = false; } - if ((NBKS <= 0) || (SAREA(HTS) <= 0.0) || (OverlapStatus == TooManyVertices) || (OverlapStatus == TooManyFigures)) return; + if ((NBKS <= 0) || (state.dataSolarShading->SAREA(HTS) <= 0.0) || (state.dataSolarShading->OverlapStatus == state.dataSolarShading->TooManyVertices) || (state.dataSolarShading->OverlapStatus == state.dataSolarShading->TooManyFigures)) return; - FBKSHC = LOCHCA + 1; + state.dataSolarShading->FBKSHC = state.dataSolarShading->LOCHCA + 1; for (I = 1; I <= NBKS; ++I) { // Loop through all back surfaces associated with the receiving surface BackSurfaceNumber = ShadowComb(CurSurf).BackSurf(I); - if (CTHETA(BackSurfaceNumber) > -SunIsUpValue) continue; //-0.001) CYCLE ! go to next back surface since inside of this surface + if (state.dataSolarShading->CTHETA(BackSurfaceNumber) > -SunIsUpValue) continue; //-0.001) CYCLE ! go to next back surface since inside of this surface // cannot be in sun if the outside can be // Transform coordinates of back surface from general system to the @@ -5970,51 +5459,51 @@ namespace SolarShading { // become clockwise sequential. for (N = 1; N <= NVT; ++N) { - XVS(N) = XVT(N) - XShadowProjection * ZVT(N); - YVS(N) = YVT(N) - YShadowProjection * ZVT(N); + state.dataSolarShading->XVS(N) = XVT(N) - state.dataSolarShading->XShadowProjection * ZVT(N); + state.dataSolarShading->YVS(N) = YVT(N) - state.dataSolarShading->YShadowProjection * ZVT(N); } // Transform to the homogeneous coordinate system. - NS3 = LOCHCA + 1; - HCT(NS3) = 0.0; - HTRANS1(NS3, NVT); + NS3 = state.dataSolarShading->LOCHCA + 1; + state.dataSolarShading->HCT(NS3) = 0.0; + HTRANS1(state, NS3, NVT); // Adjust near-duplicate points. - NVR = HCNV(1); - auto l3(HCX.index(NS3, 1)); + NVR = state.dataSolarShading->HCNV(1); + auto l3(state.dataSolarShading->HCX.index(NS3, 1)); for (N = 1; N <= NVT; ++N, ++l3) { - auto const x3(HCX[l3]); // [ l3 ] == ( NS3, N ) - auto const y3(HCY[l3]); + auto const x3(state.dataSolarShading->HCX[l3]); // [ l3 ] == ( NS3, N ) + auto const y3(state.dataSolarShading->HCY[l3]); size_type l1(0); for (M = 1; M <= NVR; ++M, ++l1) { - if (std::abs(HCX[l1] - x3) > 6) continue; // [ l1 ] == ( 1, M ) - if (std::abs(HCY[l1] - y3) > 6) continue; - HCX[l3] = HCX[l1]; - HCY[l3] = HCY[l1]; + if (std::abs(state.dataSolarShading->HCX[l1] - x3) > 6) continue; // [ l1 ] == ( 1, M ) + if (std::abs(state.dataSolarShading->HCY[l1] - y3) > 6) continue; + state.dataSolarShading->HCX[l3] = state.dataSolarShading->HCX[l1]; + state.dataSolarShading->HCY[l3] = state.dataSolarShading->HCY[l1]; break; } } - HTRANS0(NS3, NVT); + HTRANS0(state, NS3, NVT); // Determine area of overlap of projected back surface and receiving surface. NS1 = 1; NS2 = NS3; - HCT(NS3) = 1.0; - DeterminePolygonOverlap(NS1, NS2, NS3); + state.dataSolarShading->HCT(NS3) = 1.0; + DeterminePolygonOverlap(state, NS1, NS2, NS3); - if (OverlapStatus == NoOverlap) continue; // to next back surface - if ((OverlapStatus == TooManyVertices) || (OverlapStatus == TooManyFigures)) break; // back surfaces DO loop + if (state.dataSolarShading->OverlapStatus == state.dataSolarShading->NoOverlap) continue; // to next back surface + if ((state.dataSolarShading->OverlapStatus == state.dataSolarShading->TooManyVertices) || (state.dataSolarShading->OverlapStatus == state.dataSolarShading->TooManyFigures)) break; // back surfaces DO loop // Increment back surface count. - LOCHCA = NS3; - HCNS(LOCHCA) = BackSurfaceNumber; - HCAREA(LOCHCA) = -HCAREA(LOCHCA); - NBKSHC = LOCHCA - FBKSHC + 1; + state.dataSolarShading->LOCHCA = NS3; + state.dataSolarShading->HCNS(state.dataSolarShading->LOCHCA) = BackSurfaceNumber; + state.dataSolarShading->HCAREA(state.dataSolarShading->LOCHCA) = -state.dataSolarShading->HCAREA(state.dataSolarShading->LOCHCA); + state.dataSolarShading->NBKSHC = state.dataSolarShading->LOCHCA - state.dataSolarShading->FBKSHC + 1; } } @@ -6037,9 +5526,6 @@ namespace SolarShading { // PURPOSE OF THIS SUBROUTINE: // This subroutine determines the shadows on a general receiving surface. - // METHODOLOGY EMPLOYED: - // na - // REFERENCES: // BLAST/IBLAST code, original author George Walton @@ -6051,19 +5537,6 @@ namespace SolarShading { using ScheduleManager::GetScheduleName; using ScheduleManager::LookUpScheduleValue; - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: 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 @@ -6076,20 +5549,20 @@ namespace SolarShading { int NS3; // Location to place results of overlap Real64 SchValue; // Value for Schedule of shading transmittence - if (SHDGSSOneTimeFlag) { + if (state.dataSolarShading->SHDGSSOneTimeFlag) { XVT.dimension(MaxVerticesPerSurface + 1, 0.0); YVT.dimension(MaxVerticesPerSurface + 1, 0.0); ZVT.dimension(MaxVerticesPerSurface + 1, 0.0); - SHDGSSOneTimeFlag = false; + state.dataSolarShading->SHDGSSOneTimeFlag = false; } - FGSSHC = LOCHCA + 1; - MainOverlapStatus = NoOverlap; // Set to ensure that the value from the last surface is not saved - OverlapStatus = NoOverlap; + state.dataSolarShading->FGSSHC = state.dataSolarShading->LOCHCA + 1; + MainOverlapStatus = state.dataSolarShading->NoOverlap; // Set to ensure that the value from the last surface is not saved + state.dataSolarShading->OverlapStatus = state.dataSolarShading->NoOverlap; if (NGSS <= 0) { // IF NO S.S., receiving surface FULLY SUNLIT. - SAREA(HTS) = HCAREA(1); // Surface fully sunlit + state.dataSolarShading->SAREA(HTS) = state.dataSolarShading->HCAREA(1); // Surface fully sunlit } else { @@ -6100,7 +5573,7 @@ namespace SolarShading { GSSNR = GenSurf(I); - if (CTHETA(GSSNR) > sunIsUp) continue; //.001) CYCLE ! NO SHADOW IF GSS IN SUNLIGHT. + if (state.dataSolarShading->CTHETA(GSSNR) > sunIsUp) continue; //.001) CYCLE ! NO SHADOW IF GSS IN SUNLIGHT. auto const &surface(Surface(GSSNR)); bool const notHeatTransSurf(!surface.HeatTransSurf); @@ -6116,7 +5589,7 @@ namespace SolarShading { 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 (!CalcSkyDifShading) { + if (!state.dataSolarShading->CalcSkyDifShading) { if (LookUpScheduleValue(state, surface.SchedShadowSurfIndex, iHour, TS) == 1.0) continue; } } @@ -6148,58 +5621,58 @@ namespace SolarShading { // For shadowing subsurface coordinates of shadow casting surface are relative to the receiving surface // project shadow to the receiving surface - NVS = surface.Sides; + state.dataSolarShading->NVS = surface.Sides; auto const &XV(ShadeV(GSSNR).XV); auto const &YV(ShadeV(GSSNR).YV); auto const &ZV(ShadeV(GSSNR).ZV); - for (int N = 1; N <= NVS; ++N) { - XVS(N) = XV(N) - XShadowProjection * ZV(N); - YVS(N) = YV(N) - YShadowProjection * ZV(N); + for (int N = 1; N <= state.dataSolarShading->NVS; ++N) { + state.dataSolarShading->XVS(N) = XV(N) - state.dataSolarShading->XShadowProjection * ZV(N); + state.dataSolarShading->YVS(N) = YV(N) - state.dataSolarShading->YShadowProjection * ZV(N); } } else { // Transform coordinates of shadow casting surface from general system to the system relative to the receiving surface int NVT; CTRANS(GSSNR, NGRS, NVT, XVT, YVT, ZVT); - CLIP(NVT, XVT, YVT, ZVT); // Clip portions of the shadow casting surface which are behind the receiving surface + CLIP(state, NVT, XVT, YVT, ZVT); // Clip portions of the shadow casting surface which are behind the receiving surface - if (NumVertInShadowOrClippedSurface <= 2) continue; + if (state.dataSolarShading->NumVertInShadowOrClippedSurface <= 2) continue; // Project shadow from shadow casting surface along sun's rays to receiving surface Shadow vertices // become clockwise sequential - for (int N = 1; N <= NumVertInShadowOrClippedSurface; ++N) { - XVS(N) = XVC(N) - XShadowProjection * ZVC(N); - YVS(N) = YVC(N) - YShadowProjection * ZVC(N); + for (int N = 1; N <= state.dataSolarShading->NumVertInShadowOrClippedSurface; ++N) { + state.dataSolarShading->XVS(N) = state.dataSolarShading->XVC(N) - state.dataSolarShading->XShadowProjection * state.dataSolarShading->ZVC(N); + state.dataSolarShading->YVS(N) = state.dataSolarShading->YVC(N) - state.dataSolarShading->YShadowProjection * state.dataSolarShading->ZVC(N); } } // Transform to the homogeneous coordinate system. - NS3 = LOCHCA + 1; - HTRANS1(NS3, NVS); + NS3 = state.dataSolarShading->LOCHCA + 1; + HTRANS1(state, NS3, state.dataSolarShading->NVS); // Adjust near-duplicate points. - assert(equal_dimensions(HCX, HCY)); - assert(HCX.index(1, 1) == 0u); - size_type j(HCX.index(NS3, 1)); - size_type NVR(HCNV(1)); - for (int N = 1; N <= NumVertInShadowOrClippedSurface; ++N, ++j) { // Tuned Logic change: break after 1st "close" point found - auto const HCX_N(HCX[j]); // [ j ] == ( NS3, N ) - auto const HCY_N(HCY[j]); + assert(equal_dimensions(state.dataSolarShading->HCX, state.dataSolarShading->HCY)); + assert(state.dataSolarShading->HCX.index(1, 1) == 0u); + size_type j(state.dataSolarShading->HCX.index(NS3, 1)); + size_type NVR(state.dataSolarShading->HCNV(1)); + for (int N = 1; N <= state.dataSolarShading->NumVertInShadowOrClippedSurface; ++N, ++j) { // Tuned Logic change: break after 1st "close" point found + auto const HCX_N(state.dataSolarShading->HCX[j]); // [ j ] == ( NS3, N ) + auto const HCY_N(state.dataSolarShading->HCY[j]); for (size_type l = 0; l < NVR; ++l) { // [ l ] == ( 1, l+1 ) - auto const delX(std::abs(HCX[l] - HCX_N)); + auto const delX(std::abs(state.dataSolarShading->HCX[l] - HCX_N)); if (delX > 6) continue; - auto const delY(std::abs(HCY[l] - HCY_N)); + auto const delY(std::abs(state.dataSolarShading->HCY[l] - HCY_N)); if (delY > 6) continue; - if (delX > 0) HCX[j] = HCX[l]; // [ j ] == ( NS3, N ) - if (delY > 0) HCY[j] = HCY[l]; + if (delX > 0) state.dataSolarShading->HCX[j] = state.dataSolarShading->HCX[l]; // [ j ] == ( NS3, N ) + if (delY > 0) state.dataSolarShading->HCY[j] = state.dataSolarShading->HCY[l]; break; } } - HTRANS0(NS3, NumVertInShadowOrClippedSurface); - if (!CalcSkyDifShading) { + HTRANS0(state, NS3, state.dataSolarShading->NumVertInShadowOrClippedSurface); + if (!state.dataSolarShading->CalcSkyDifShading) { if (iHour != 0) { SchValue = LookUpScheduleValue(state, surface.SchedShadowSurfIndex, iHour, TS); } else { @@ -6209,30 +5682,30 @@ namespace SolarShading { SchValue = surface.SchedMinValue; } - HCT(NS3) = SchValue; + state.dataSolarShading->HCT(NS3) = SchValue; // Determine overlap of shadow with receiving surface - CurrentShadowingSurface = I; - CurrentSurfaceBeingShadowed = GSSNR; + state.dataSolarShading->CurrentShadowingSurface = I; + state.dataSolarShading->CurrentSurfaceBeingShadowed = GSSNR; NS1 = 1; NS2 = NS3; - DeterminePolygonOverlap(NS1, NS2, NS3); + DeterminePolygonOverlap(state, NS1, NS2, NS3); // Next statement is special to deal with transmitting shading devices - if (OverlapStatus == FirstSurfWithinSecond && SchValue > 0.0) OverlapStatus = PartialOverlap; - MainOverlapStatus = OverlapStatus; + if (state.dataSolarShading->OverlapStatus == state.dataSolarShading->FirstSurfWithinSecond && SchValue > 0.0) state.dataSolarShading->OverlapStatus = state.dataSolarShading->PartialOverlap; + MainOverlapStatus = state.dataSolarShading->OverlapStatus; ExitLoopStatus = MainOverlapStatus; - if (MainOverlapStatus == NoOverlap) { // No overlap of general surface shadow and receiving surface + if (MainOverlapStatus == state.dataSolarShading->NoOverlap) { // No overlap of general surface shadow and receiving surface // Continue - } else if ((MainOverlapStatus == FirstSurfWithinSecond) || (MainOverlapStatus == TooManyVertices) || - (MainOverlapStatus == TooManyFigures)) { + } else if ((MainOverlapStatus == state.dataSolarShading->FirstSurfWithinSecond) || (MainOverlapStatus == state.dataSolarShading->TooManyVertices) || + (MainOverlapStatus == state.dataSolarShading->TooManyFigures)) { goto ShadowingSurfaces_exit; - } else if ((MainOverlapStatus == SecondSurfWithinFirst) || (MainOverlapStatus == PartialOverlap)) { + } else if ((MainOverlapStatus == state.dataSolarShading->SecondSurfWithinFirst) || (MainOverlapStatus == state.dataSolarShading->PartialOverlap)) { // Determine overlaps with previous shadows. - LOCHCA = NS3; - NGSSHC = LOCHCA - FGSSHC + 1; - if (NGSSHC > 1) MULTOL(LOCHCA, FGSSHC - 1, NGSSHC - 1); // HOYT - Remove this call + state.dataSolarShading->LOCHCA = NS3; + state.dataSolarShading->NGSSHC = state.dataSolarShading->LOCHCA - state.dataSolarShading->FGSSHC + 1; + if (state.dataSolarShading->NGSSHC > 1) MULTOL(state, state.dataSolarShading->LOCHCA, state.dataSolarShading->FGSSHC - 1, state.dataSolarShading->NGSSHC - 1); // HOYT - Remove this call } else { goto ShadowingSurfaces_exit; } @@ -6243,39 +5716,39 @@ namespace SolarShading { // Compute sunlit area of surface (excluding effects of subsurfs). - if (ExitLoopStatus == FirstSurfWithinSecond) { // Surface fully shaded - SAREA(HTS) = 0.0; - LOCHCA = FGSSHC; + if (ExitLoopStatus == state.dataSolarShading->FirstSurfWithinSecond) { // Surface fully shaded + state.dataSolarShading->SAREA(HTS) = 0.0; + state.dataSolarShading->LOCHCA = state.dataSolarShading->FGSSHC; - } else if ((ExitLoopStatus == TooManyVertices) || (ExitLoopStatus == TooManyFigures)) { // Array limits exceeded, estimate - SAREA(HTS) = 0.25 * HCAREA(1); + } else if ((ExitLoopStatus == state.dataSolarShading->TooManyVertices) || (ExitLoopStatus == state.dataSolarShading->TooManyFigures)) { // Array limits exceeded, estimate + state.dataSolarShading->SAREA(HTS) = 0.25 * state.dataSolarShading->HCAREA(1); } else { // Compute the sunlit area here. // Call UnionShadow(FGSSHC,LOCHCA) - NGSSHC = LOCHCA - FGSSHC + 1; - if (NGSSHC <= 0) { - SAREA(HTS) = HCAREA(1); // Surface fully sunlit + state.dataSolarShading->NGSSHC = state.dataSolarShading->LOCHCA - state.dataSolarShading->FGSSHC + 1; + if (state.dataSolarShading->NGSSHC <= 0) { + state.dataSolarShading->SAREA(HTS) = state.dataSolarShading->HCAREA(1); // Surface fully sunlit } else { - Real64 A(HCAREA(1)); // Area - for (int i = FGSSHC, e = FGSSHC + NGSSHC - 1; i <= e; ++i) { - A += HCAREA(i) * (1.0 - HCT(i)); + Real64 A(state.dataSolarShading->HCAREA(1)); // Area + for (int i = state.dataSolarShading->FGSSHC, e = state.dataSolarShading->FGSSHC + state.dataSolarShading->NGSSHC - 1; i <= e; ++i) { + A += state.dataSolarShading->HCAREA(i) * (1.0 - state.dataSolarShading->HCT(i)); } - SAREA(HTS) = A; - if (SAREA(HTS) <= 0.0) { // Surface fully shaded - SAREA(HTS) = 0.0; - LOCHCA = FGSSHC; + state.dataSolarShading->SAREA(HTS) = A; + if (state.dataSolarShading->SAREA(HTS) <= 0.0) { // Surface fully shaded + state.dataSolarShading->SAREA(HTS) = 0.0; + state.dataSolarShading->LOCHCA = state.dataSolarShading->FGSSHC; } } } } - NGSSHC = LOCHCA - FGSSHC + 1; + state.dataSolarShading->NGSSHC = state.dataSolarShading->LOCHCA - state.dataSolarShading->FGSSHC + 1; } - void CalcInteriorSolarOverlaps(int const iHour, // Hour Index + void CalcInteriorSolarOverlaps(EnergyPlusData &state, int const iHour, // Hour Index int const NBKS, // Number of back surfaces associated with this GRSNR (in general, only int const HTSS, // Surface number of the subsurface (exterior window) int const GRSNR, // General receiving surface number (base surface of the exterior window) @@ -6321,12 +5794,12 @@ namespace SolarShading { // Tuned Linear indexing - assert(equal_dimensions(HCX, HCY)); - assert(equal_dimensions(HCX, HCA)); - assert(equal_dimensions(HCX, HCB)); - assert(equal_dimensions(HCX, HCC)); + assert(equal_dimensions(state.dataSolarShading->HCX, state.dataSolarShading->HCY)); + assert(equal_dimensions(state.dataSolarShading->HCX, state.dataSolarShading->HCA)); + assert(equal_dimensions(state.dataSolarShading->HCX, state.dataSolarShading->HCB)); + assert(equal_dimensions(state.dataSolarShading->HCX, state.dataSolarShading->HCC)); - if (SAREA(HTSS) > 0.0) { + if (state.dataSolarShading->SAREA(HTSS) > 0.0) { UseSimpleDistribution = false; @@ -6344,46 +5817,46 @@ namespace SolarShading { // IF(Surface(HTSS)%Reveal > 0.0) NRVLHC = 1 // Changing the line to the following avoids incorrect calculation when window is not shaded // only by reveal (FCW 6/28/02). - if (WindowRevealStatus(TS, iHour, HTSS) == WindowShadedOnlyByReveal) NRVLHC = 1; - if (NRVLHC > 0) { - for (int I = 1; I <= NRVLHC; ++I) { - int const iS(FSBSHC - 1 + I); - int const iR(FRVLHC - 1 + I); - HCT(iS) = HCT(iR); - HCNV(iS) = HCNV(iR); - HCAREA(iS) = HCAREA(iR); - size_type lS(HCX.index(iS, 1)); - size_type lR(HCX.index(iR, 1)); - for (int J = 1; J <= MaxHCV; ++J, ++lS, ++lR) { // [ lS ] == ( iS, J ), [ lR ] == ( iR, J ) - HCX[lS] = HCX[lR]; - HCY[lS] = HCY[lR]; - HCA[lS] = HCA[lR]; - HCB[lS] = HCB[lR]; - HCC[lS] = HCC[lR]; + if (state.dataSolarShading->WindowRevealStatus(TS, iHour, HTSS) == WindowShadedOnlyByReveal) state.dataSolarShading->NRVLHC = 1; + if (state.dataSolarShading->NRVLHC > 0) { + for (int I = 1; I <= state.dataSolarShading->NRVLHC; ++I) { + int const iS(state.dataSolarShading->FSBSHC - 1 + I); + int const iR(state.dataSolarShading->FRVLHC - 1 + I); + state.dataSolarShading->HCT(iS) = state.dataSolarShading->HCT(iR); + state.dataSolarShading->HCNV(iS) = state.dataSolarShading->HCNV(iR); + state.dataSolarShading->HCAREA(iS) = state.dataSolarShading->HCAREA(iR); + size_type lS(state.dataSolarShading->HCX.index(iS, 1)); + size_type lR(state.dataSolarShading->HCX.index(iR, 1)); + for (int J = 1; J <= state.dataSolarShading->MaxHCV; ++J, ++lS, ++lR) { // [ lS ] == ( iS, J ), [ lR ] == ( iR, J ) + state.dataSolarShading->HCX[lS] = state.dataSolarShading->HCX[lR]; + state.dataSolarShading->HCY[lS] = state.dataSolarShading->HCY[lR]; + state.dataSolarShading->HCA[lS] = state.dataSolarShading->HCA[lR]; + state.dataSolarShading->HCB[lS] = state.dataSolarShading->HCB[lR]; + state.dataSolarShading->HCC[lS] = state.dataSolarShading->HCC[lR]; } } - NSBSHC = NRVLHC; + state.dataSolarShading->NSBSHC = state.dataSolarShading->NRVLHC; } } // Check for array space. - if (FSBSHC + NBKSHC > MaxHCS) UseSimpleDistribution = true; + if (state.dataSolarShading->FSBSHC + state.dataSolarShading->NBKSHC > state.dataSolarShading->MaxHCS) UseSimpleDistribution = true; if (!UseSimpleDistribution) { // Compute overlaps std::map pssas; #ifndef EP_NO_OPENGL - if (penumbra) { + if (state.dataSolarShading->penumbra) { // Add back surfaces to array std::vector pbBackSurfaces; for (auto bkSurfNum : ShadowComb(GRSNR).BackSurf) { if (bkSurfNum == 0) continue; - if (CTHETA(bkSurfNum) < SunIsUpValue) { + if (state.dataSolarShading->CTHETA(bkSurfNum) < SunIsUpValue) { pbBackSurfaces.push_back(Surface(bkSurfNum).PenumbraID); } } - pssas = penumbra->calculateInteriorPSSAs({(unsigned)Surface(HTSS).PenumbraID}, pbBackSurfaces); + pssas = state.dataSolarShading->penumbra->calculateInteriorPSSAs({(unsigned)Surface(HTSS).PenumbraID}, pbBackSurfaces); //penumbra->renderInteriorScene({(unsigned)Surface(HTSS).PenumbraID}, pbBackSurfaces); JBKS = 0; @@ -6392,7 +5865,7 @@ namespace SolarShading { if (pssas[Surface(bkSurfNum).PenumbraID] > 0) { ++JBKS; BackSurfaces(TS, iHour, JBKS, HTSS) = bkSurfNum; - Real64 OverlapArea = pssas[Surface(bkSurfNum).PenumbraID]/CTHETA(HTSS); + Real64 OverlapArea = pssas[Surface(bkSurfNum).PenumbraID]/state.dataSolarShading->CTHETA(HTSS); OverlapAreas(TS, iHour, JBKS, HTSS) = OverlapArea * SurfWinGlazedFrac(HTSS); } } @@ -6400,34 +5873,34 @@ namespace SolarShading { } #endif - if (!penumbra) { + if (!state.dataSolarShading->penumbra) { - FINSHC = FSBSHC + NSBSHC; + state.dataSolarShading->FINSHC = state.dataSolarShading->FSBSHC + state.dataSolarShading->NSBSHC; JBKS = 0; - for (int IBKS = 1; IBKS <= NBKSHC; ++IBKS) { // Loop over back surfaces to GRSNR this hour. NBKSHC is the number of + for (int IBKS = 1; IBKS <= state.dataSolarShading->NBKSHC; ++IBKS) { // Loop over back surfaces to GRSNR this hour. NBKSHC is the number of // back surfaces that would receive beam radiation from the base surface, GRSNR, // if the base surface was transparent. In general, some (at least one) or all of these // will receive beam radiation from the exterior window subsurface, HTSS, of GRSNR, // depending on the size of HTSS and its location on GRSNR - BackSurfNum = HCNS(FBKSHC - 1 + IBKS); + BackSurfNum = state.dataSolarShading->HCNS(state.dataSolarShading->FBKSHC - 1 + IBKS); // Determine if this back surface number can receive beam radiation from the // exterior window, HTSS, this hour, i.e., overlap area is positive - LOCHCA = FINSHC - 1; + state.dataSolarShading->LOCHCA = state.dataSolarShading->FINSHC - 1; - MULTOL(FBKSHC - 1 + IBKS, FSBSHC - 1, NSBSHC); + MULTOL(state, state.dataSolarShading->FBKSHC - 1 + IBKS, state.dataSolarShading->FSBSHC - 1, state.dataSolarShading->NSBSHC); // Compute overlap area for this back surface - NINSHC = LOCHCA - FINSHC + 1; - if (NINSHC <= 0) continue; - Real64 OverlapArea = HCAREA(FINSHC); - for (int J = 2; J <= NINSHC; ++J) { - OverlapArea += HCAREA(FINSHC - 1 + J) * (1.0 - HCT(FINSHC - 1 + J)); + state.dataSolarShading->NINSHC = state.dataSolarShading->LOCHCA - state.dataSolarShading->FINSHC + 1; + if (state.dataSolarShading->NINSHC <= 0) continue; + Real64 OverlapArea = state.dataSolarShading->HCAREA(state.dataSolarShading->FINSHC); + for (int J = 2; J <= state.dataSolarShading->NINSHC; ++J) { + OverlapArea += state.dataSolarShading->HCAREA(state.dataSolarShading->FINSHC - 1 + J) * (1.0 - state.dataSolarShading->HCT(state.dataSolarShading->FINSHC - 1 + J)); } if (OverlapArea > 0.001) { @@ -6774,7 +6247,7 @@ namespace SolarShading { int iSSG; // scheduled surface gains counter Real64 SolarIntoZone; // Solar radiation into zone to current surface - if (MustAllocSolarShading) { + if (state.dataSolarShading->MustAllocSolarShading) { DBZoneIntWin.allocate(NumOfZones); IntBeamAbsByShadFac.allocate(TotSurfaces); ExtBeamAbsByShadFac.allocate(TotSurfaces); @@ -6782,7 +6255,7 @@ namespace SolarShading { WinTransDifSolar.allocate(TotSurfaces); WinTransDifSolarGnd.allocate(TotSurfaces); WinTransDifSolarSky.allocate(TotSurfaces); - MustAllocSolarShading = false; + state.dataSolarShading->MustAllocSolarShading = false; } #ifdef EP_Count_Calls @@ -8592,7 +8065,7 @@ namespace SolarShading { for (int const FloorNum : thisEnclosure.SurfacePtr) { // In following, ISABSF is zero except for nominal floor surfaces - if (ISABSF(FloorNum) <= 0.0 || FloorNum == SurfNum) continue; // Keep only floor surfaces + if (state.dataSolarShading->ISABSF(FloorNum) <= 0.0 || FloorNum == SurfNum) continue; // Keep only floor surfaces int FlConstrNum = Surface(FloorNum).Construction; BTOTWinZone = TBm * SunLitFract * Surface(SurfNum).Area * CosInc * InOutProjSLFracMult; //[m2] @@ -8600,7 +8073,7 @@ namespace SolarShading { if (state.dataConstruction->Construct(FlConstrNum).TransDiff <= 0.0) { // Opaque surface - AISurf(FloorNum) += BTOTWinZone * ISABSF(FloorNum) / Surface(FloorNum).Area; //[-] + AISurf(FloorNum) += BTOTWinZone * state.dataSolarShading->ISABSF(FloorNum) / Surface(FloorNum).Area; //[-] } else if (state.dataConstruction->Construct(FlConstrNum).TypeIsAirBoundaryInteriorWindow) { TransBeamWin = 1.0; AbsBeamWinEQL = 0.0; @@ -8625,11 +8098,11 @@ namespace SolarShading { // (see ComputeIntSolarAbsorpFactors). for (Lay = 1; Lay <= state.dataConstruction->Construct(FlConstrNum).TotGlassLayers; ++Lay) { AWinSurf(Lay, FloorNum) += state.dataConstruction->Construct(FlConstrNum).AbsDiffBack(Lay) / AbsBeamTotWin * BTOTWinZone * - ISABSF(FloorNum) / Surface(FloorNum).Area; //[-] + state.dataSolarShading->ISABSF(FloorNum) / Surface(FloorNum).Area; //[-] } } - BABSZone += BTOTWinZone * ISABSF(FloorNum); //[m2] + BABSZone += BTOTWinZone * state.dataSolarShading->ISABSF(FloorNum); //[m2] int AdjSurfNum = Surface(FloorNum).ExtBoundCond; if (state.dataConstruction->Construct(FlConstrNum).TransDiff > 0.0 && AdjSurfNum > 0) { @@ -8640,9 +8113,9 @@ namespace SolarShading { // Contribution (assumed diffuse) to adjacent zone of beam radiation passing // through this window - DBZoneIntWin(adjEnclosureNum) += BTOTWinZone * ISABSF(FloorNum) * state.dataConstruction->Construct(FlConstrNum).TransDiff / AbsBeamTotWin; + DBZoneIntWin(adjEnclosureNum) += BTOTWinZone * state.dataSolarShading->ISABSF(FloorNum) * state.dataConstruction->Construct(FlConstrNum).TransDiff / AbsBeamTotWin; - BABSZone += BTOTWinZone * ISABSF(FloorNum) * state.dataConstruction->Construct(FlConstrNum).TransDiff / AbsBeamTotWin; + BABSZone += BTOTWinZone * state.dataSolarShading->ISABSF(FloorNum) * state.dataConstruction->Construct(FlConstrNum).TransDiff / AbsBeamTotWin; } } // End of loop over floor sections @@ -8683,7 +8156,7 @@ namespace SolarShading { SurfBmIncInsSurfAmountRepEnergy(SurfNum) = SurfBmIncInsSurfAmountRep(SurfNum) * TimeStepZoneSec; SurfBmIncInsSurfIntensRep(SurfNum) = SurfBmIncInsSurfAmountRep(SurfNum) / (Surface(SurfNum).Area + SurfWinDividerArea(SurfNum)); } else { // Simple interior solar distribution. All beam falls on floor. - if (ISABSF(SurfNum) > 0.0 && Surface(SurfNum).HeatTransSurf) { + if (state.dataSolarShading->ISABSF(SurfNum) > 0.0 && Surface(SurfNum).HeatTransSurf) { if (thisEnclosure.FloorArea > 0.0) { // spread onto all floor surfaces, these may or may not be called "floor" SurfBmIncInsSurfIntensRep(SurfNum) = BeamSolarRad * BTOTZone / thisEnclosure.FloorArea; @@ -8826,12 +8299,6 @@ namespace SolarShading { // PURPOSE OF THIS SUBROUTINE: // Calculates solar energy absorbed on exterior opaque surfaces - // METHODOLOGY EMPLOYED: - // na - - // REFERENCES: - // na - using namespace DataDaylightingDevices; for (int ZoneNum = 1; ZoneNum <= NumOfZones; ++ZoneNum) { @@ -8886,12 +8353,6 @@ namespace SolarShading { // PURPOSE OF THIS SUBROUTINE: // Calculates solar distribution - // METHODOLOGY EMPLOYED: - // na - - // REFERENCES: - // na - CalcAbsorbedOnExteriorOpaqueSurfaces(state); if (state.dataWindowManager->winOpticalModel->isSimplifiedModel()) { @@ -8915,7 +8376,7 @@ namespace SolarShading { using namespace DataDaylightingDevices; using namespace MultiLayerOptics; - if (MustAllocSolarShading) { + if (state.dataSolarShading->MustAllocSolarShading) { DBZoneIntWin.allocate(NumOfZones); } @@ -9098,14 +8559,14 @@ namespace SolarShading { for (int const FloorNum : thisEnclosure.SurfacePtr) { // In following, ISABSF is zero except for nominal floor surfaces if (!Surface(FloorNum).HeatTransSurf) continue; - if (ISABSF(FloorNum) <= 0.0 || FloorNum == SurfNum) continue; // Keep only floor surfaces + if (state.dataSolarShading->ISABSF(FloorNum) <= 0.0 || FloorNum == SurfNum) continue; // Keep only floor surfaces Real64 BTOTWinZone = TBm * SunLitFract * Surface(SurfNum).Area * CosInc * window.InOutProjSLFracMult(HourOfDay); //[m2] if (state.dataConstruction->Construct(Surface(FloorNum).Construction).TransDiff <= 0.0) { // Opaque surface - AISurf(FloorNum) += BTOTWinZone * ISABSF(FloorNum) / Surface(FloorNum).Area; //[-] + AISurf(FloorNum) += BTOTWinZone * state.dataSolarShading->ISABSF(FloorNum) / Surface(FloorNum).Area; //[-] } } } @@ -9233,22 +8694,22 @@ namespace SolarShading { // Calculate sky diffuse shading if (BeginSimFlag) { - CalcSkyDifShading = true; + state.dataSolarShading->CalcSkyDifShading = true; SkyDifSolarShading(state); // Calculate factors for shading of sky diffuse solar - CalcSkyDifShading = false; + state.dataSolarShading->CalcSkyDifShading = false; } if (BeginEnvrnFlag) { - ShadowingDaysLeft = 0; + state.dataSolarShading->ShadowingDaysLeft = 0; } - if (ShadowingDaysLeft <= 0 || DetailedSolarTimestepIntegration) { + if (state.dataSolarShading->ShadowingDaysLeft <= 0 || DetailedSolarTimestepIntegration) { if (!DetailedSolarTimestepIntegration) { // Perform calculations. - ShadowingDaysLeft = ShadowingCalcFrequency; - if (DayOfSim + ShadowingDaysLeft > NumOfDayInEnvrn) { - ShadowingDaysLeft = NumOfDayInEnvrn - DayOfSim + 1; + state.dataSolarShading->ShadowingDaysLeft = state.dataSolarShading->ShadowingCalcFrequency; + if (DayOfSim + state.dataSolarShading->ShadowingDaysLeft > NumOfDayInEnvrn) { + state.dataSolarShading->ShadowingDaysLeft = NumOfDayInEnvrn - DayOfSim + 1; } // Calculate average Equation of Time, Declination Angle for this period @@ -9265,7 +8726,7 @@ namespace SolarShading { PerDayOfYear = DayOfYear; SumDec = 0.0; SumET = 0.0; - for (Count = 1; Count <= ShadowingDaysLeft; ++Count) { + for (Count = 1; Count <= state.dataSolarShading->ShadowingDaysLeft; ++Count) { SUN3(PerDayOfYear, SinDec, EqTime); SumDec += SinDec; SumET += EqTime; @@ -9273,9 +8734,9 @@ namespace SolarShading { } // Compute Period Values - AvgSinSolarDeclin = SumDec / double(ShadowingDaysLeft); + AvgSinSolarDeclin = SumDec / double(state.dataSolarShading->ShadowingDaysLeft); AvgCosSolarDeclin = std::sqrt(1.0 - pow_2(AvgSinSolarDeclin)); - AvgEqOfTime = SumET / double(ShadowingDaysLeft); + AvgEqOfTime = SumET / double(state.dataSolarShading->ShadowingDaysLeft); } else { SUN3(DayOfYear, AvgSinSolarDeclin, AvgEqOfTime); AvgCosSolarDeclin = std::sqrt(1.0 - pow_2(AvgSinSolarDeclin)); @@ -9299,7 +8760,7 @@ namespace SolarShading { } if (!WarmupFlag) { - --ShadowingDaysLeft; + --state.dataSolarShading->ShadowingDaysLeft; } // Recalculate daylighting coefficients if storm window has been added @@ -9309,7 +8770,7 @@ namespace SolarShading { } } - void SHDRVL(int const HTSS, // Heat transfer surface number of the subsurface + void SHDRVL(EnergyPlusData &state, int const HTSS, // Heat transfer surface number of the subsurface int const SBSNR, // Subsurface number int const Hour, int const TS) @@ -9324,32 +8785,15 @@ namespace SolarShading { // PURPOSE OF THIS SUBROUTINE: // This subroutine computes the shadowing from a reveal onto a subsurface. - // METHODOLOGY EMPLOYED: - // na - // REFERENCES: // BLAST/IBLAST code, original author George Walton - // USE STATEMENTS: - // na - - // Locals int NVS; // Number of verticies - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: int const None(0); // for use with RevealStatus int const EntireWindowShadedByReveal(1); // for use with RevealStatus int const WindowShadedOnlyByReveal(2); // for use with RevealStatus - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: Real64 A; // Area Real64 R; // Depth of the reveal (m) int I; // Loop control @@ -9367,8 +8811,8 @@ namespace SolarShading { RevealStatus = None; RevealStatusSet = false; - if (!CalcSkyDifShading) { - WindowRevealStatus(TS, Hour, SBSNR) = None; + if (!state.dataSolarShading->CalcSkyDifShading) { + state.dataSolarShading->WindowRevealStatus(TS, Hour, SBSNR) = None; } R = Surface(SBSNR).Reveal; @@ -9379,8 +8823,8 @@ namespace SolarShading { if (!RevealStatusSet) { - FRVLHC = LOCHCA + 1; - ++LOCHCA; + state.dataSolarShading->FRVLHC = state.dataSolarShading->LOCHCA + 1; + ++state.dataSolarShading->LOCHCA; NVS = Surface(SBSNR).Sides; // Currently (06May02) windows are either rectangles (NVS=4) or triangles (NVS=3) @@ -9390,14 +8834,14 @@ namespace SolarShading { // Determine vertices of reveal. // Project the subsurface up to the plane of the wall. - XVT(1) = ShadeV(SBSNR).XV(1) + R * max(XShadowProjection, 0.0); - XVT(2) = ShadeV(SBSNR).XV(2) + R * max(XShadowProjection, 0.0); - XVT(3) = ShadeV(SBSNR).XV(3) + R * min(XShadowProjection, 0.0); - XVT(4) = ShadeV(SBSNR).XV(4) + R * min(XShadowProjection, 0.0); - YVT(1) = ShadeV(SBSNR).YV(1) + R * min(YShadowProjection, 0.0); - YVT(2) = ShadeV(SBSNR).YV(2) + R * max(YShadowProjection, 0.0); - YVT(3) = ShadeV(SBSNR).YV(3) + R * max(YShadowProjection, 0.0); - YVT(4) = ShadeV(SBSNR).YV(4) + R * min(YShadowProjection, 0.0); + XVT(1) = ShadeV(SBSNR).XV(1) + R * max(state.dataSolarShading->XShadowProjection, 0.0); + XVT(2) = ShadeV(SBSNR).XV(2) + R * max(state.dataSolarShading->XShadowProjection, 0.0); + XVT(3) = ShadeV(SBSNR).XV(3) + R * min(state.dataSolarShading->XShadowProjection, 0.0); + XVT(4) = ShadeV(SBSNR).XV(4) + R * min(state.dataSolarShading->XShadowProjection, 0.0); + YVT(1) = ShadeV(SBSNR).YV(1) + R * min(state.dataSolarShading->YShadowProjection, 0.0); + YVT(2) = ShadeV(SBSNR).YV(2) + R * max(state.dataSolarShading->YShadowProjection, 0.0); + YVT(3) = ShadeV(SBSNR).YV(3) + R * max(state.dataSolarShading->YShadowProjection, 0.0); + YVT(4) = ShadeV(SBSNR).YV(4) + R * min(state.dataSolarShading->YShadowProjection, 0.0); // Check for complete shadowing. @@ -9410,17 +8854,17 @@ namespace SolarShading { // Re-order vertices to clockwise. for (N = 1; N <= NVS; ++N) { - XVS(N) = XVT(NVS + 1 - N); - YVS(N) = YVT(NVS + 1 - N); + state.dataSolarShading->XVS(N) = XVT(NVS + 1 - N); + state.dataSolarShading->YVS(N) = YVT(NVS + 1 - N); } // Transform to homogeneous coordinates - HTRANS1(FRVLHC, NVS); - HCAREA(FRVLHC) = -HCAREA(FRVLHC); - HCT(FRVLHC) = 1.0; + HTRANS1(state, state.dataSolarShading->FRVLHC, NVS); + state.dataSolarShading->HCAREA(state.dataSolarShading->FRVLHC) = -state.dataSolarShading->HCAREA(state.dataSolarShading->FRVLHC); + state.dataSolarShading->HCT(state.dataSolarShading->FRVLHC) = 1.0; - if (HCAREA(FRVLHC) <= 0.0) { + if (state.dataSolarShading->HCAREA(state.dataSolarShading->FRVLHC) <= 0.0) { RevealStatus = EntireWindowShadedByReveal; RevealStatusSet = true; } @@ -9431,42 +8875,42 @@ namespace SolarShading { // Project window to outside plane of parent surface for (N = 1; N <= 3; ++N) { - XVT(N) = ShadeV(SBSNR).XV(N) + R * XShadowProjection; - YVT(N) = ShadeV(SBSNR).YV(N) + R * YShadowProjection; + XVT(N) = ShadeV(SBSNR).XV(N) + R * state.dataSolarShading->XShadowProjection; + YVT(N) = ShadeV(SBSNR).YV(N) + R * state.dataSolarShading->YShadowProjection; } // Find the overlap between the original window and the projected window // Put XVT,YVT in clockwise order for (N = 1; N <= NVS; ++N) { - XVS(N) = XVT(NVS + 1 - N); - YVS(N) = YVT(NVS + 1 - N); + state.dataSolarShading->XVS(N) = XVT(NVS + 1 - N); + state.dataSolarShading->YVS(N) = YVT(NVS + 1 - N); } // Transform to homogeneous coordinates - NS1 = LOCHCA + 1; - LOCHCA = NS1; - HTRANS1(NS1, NVS); + NS1 = state.dataSolarShading->LOCHCA + 1; + state.dataSolarShading->LOCHCA = NS1; + HTRANS1(state, NS1, NVS); // Put XV,YV in clockwise order for (N = 1; N <= NVS; ++N) { - XVS(N) = ShadeV(SBSNR).XV(NVS + 1 - N); - YVS(N) = ShadeV(SBSNR).YV(NVS + 1 - N); + state.dataSolarShading->XVS(N) = ShadeV(SBSNR).XV(NVS + 1 - N); + state.dataSolarShading->YVS(N) = ShadeV(SBSNR).YV(NVS + 1 - N); } // Transform to homogenous coordinates - NS2 = LOCHCA + 1; - LOCHCA = NS2; - HTRANS1(NS2, NVS); - HCT(FRVLHC) = 1.0; + NS2 = state.dataSolarShading->LOCHCA + 1; + state.dataSolarShading->LOCHCA = NS2; + HTRANS1(state, NS2, NVS); + state.dataSolarShading->HCT(state.dataSolarShading->FRVLHC) = 1.0; // Find overlap - DeterminePolygonOverlap(NS1, NS2, FRVLHC); - if (OverlapStatus == NoOverlap) { + DeterminePolygonOverlap(state, NS1, NS2, state.dataSolarShading->FRVLHC); + if (state.dataSolarShading->OverlapStatus == state.dataSolarShading->NoOverlap) { RevealStatus = EntireWindowShadedByReveal; RevealStatusSet = true; } @@ -9477,19 +8921,19 @@ namespace SolarShading { // Check for no shadows on window. - if (NSBSHC <= 1) { + if (state.dataSolarShading->NSBSHC <= 1) { RevealStatus = WindowShadedOnlyByReveal; RevealStatusSet = true; } else { // Reduce all previous shadows to size of reveal opening. - LOCHCA = FRVLHC; - MULTOL(LOCHCA, FSBSHC, NSBSHC - 1); - if ((OverlapStatus == TooManyVertices) || (OverlapStatus == TooManyFigures)) { + state.dataSolarShading->LOCHCA = state.dataSolarShading->FRVLHC; + MULTOL(state, state.dataSolarShading->LOCHCA, state.dataSolarShading->FSBSHC, state.dataSolarShading->NSBSHC - 1); + if ((state.dataSolarShading->OverlapStatus == state.dataSolarShading->TooManyVertices) || (state.dataSolarShading->OverlapStatus == state.dataSolarShading->TooManyFigures)) { RevealStatus = None; RevealStatusSet = true; } else { - NRVLHC = LOCHCA - FRVLHC + 1; - if (NRVLHC <= 1) { + state.dataSolarShading->NRVLHC = state.dataSolarShading->LOCHCA - state.dataSolarShading->FRVLHC + 1; + if (state.dataSolarShading->NRVLHC <= 1) { RevealStatus = WindowShadedOnlyByReveal; RevealStatusSet = true; } @@ -9499,21 +8943,21 @@ namespace SolarShading { if (!RevealStatusSet) { // Compute sunlit area. - A = HCAREA(FRVLHC); - for (I = 2; I <= NRVLHC; ++I) { - A += HCAREA(FRVLHC - 1 + I) * (1.0 - HCT(FRVLHC - 1 + I)); + A = state.dataSolarShading->HCAREA(state.dataSolarShading->FRVLHC); + for (I = 2; I <= state.dataSolarShading->NRVLHC; ++I) { + A += state.dataSolarShading->HCAREA(state.dataSolarShading->FRVLHC - 1 + I) * (1.0 - state.dataSolarShading->HCT(state.dataSolarShading->FRVLHC - 1 + I)); } - SAREA(HTSS) = A; + state.dataSolarShading->SAREA(HTSS) = A; } - if ((RevealStatus == EntireWindowShadedByReveal) || (SAREA(HTSS) < 0.0)) { - SAREA(HTSS) = 0.0; // Window entirely shaded by reveal. + if ((RevealStatus == EntireWindowShadedByReveal) || (state.dataSolarShading->SAREA(HTSS) < 0.0)) { + state.dataSolarShading->SAREA(HTSS) = 0.0; // Window entirely shaded by reveal. } else if (RevealStatus == WindowShadedOnlyByReveal) { - SAREA(HTSS) = HCAREA(FRVLHC); // Window shaded only by reveal. + state.dataSolarShading->SAREA(HTSS) = state.dataSolarShading->HCAREA(state.dataSolarShading->FRVLHC); // Window shaded only by reveal. } - if (!CalcSkyDifShading) { - WindowRevealStatus(TS, Hour, SBSNR) = RevealStatus; + if (!state.dataSolarShading->CalcSkyDifShading) { + state.dataSolarShading->WindowRevealStatus(TS, Hour, SBSNR) = RevealStatus; } } @@ -9542,28 +8986,9 @@ namespace SolarShading { // revises the base surface area accordingly. It also computes // the effect of transparent subsurfaces. - // METHODOLOGY EMPLOYED: - // na - // REFERENCES: // BLAST/IBLAST code, original author George Walton - // USE STATEMENTS: - // na - - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: Real64 A; // Area int I; // Loop control int J; // Loop control @@ -9578,7 +9003,7 @@ namespace SolarShading { if (NSBS > 0) { // Action taken only if subsurfaces present - FSBSHC = LOCHCA + 1; + state.dataSolarShading->FSBSHC = state.dataSolarShading->LOCHCA + 1; for (I = 1; I <= NSBS; ++I) { // Do for all subsurfaces (sbs). @@ -9588,71 +9013,71 @@ namespace SolarShading { K = Surface(SBSNR).Construction; - if (!penumbra) { - if ((OverlapStatus != TooManyVertices) && (OverlapStatus != TooManyFigures) && (SAREA(HTS) > 0.0)) { + if (!state.dataSolarShading->penumbra) { + if ((state.dataSolarShading->OverlapStatus != state.dataSolarShading->TooManyVertices) && (state.dataSolarShading->OverlapStatus != state.dataSolarShading->TooManyFigures) && (state.dataSolarShading->SAREA(HTS) > 0.0)) { // Re-order vertices to clockwise sequential; compute homogeneous coordinates. - NVS = Surface(SBSNR).Sides; - for (N = 1; N <= NVS; ++N) { - XVS(N) = ShadeV(SBSNR).XV(NVS + 1 - N); - YVS(N) = ShadeV(SBSNR).YV(NVS + 1 - N); + state.dataSolarShading->NVS = Surface(SBSNR).Sides; + for (N = 1; N <= state.dataSolarShading->NVS; ++N) { + state.dataSolarShading->XVS(N) = ShadeV(SBSNR).XV(state.dataSolarShading->NVS + 1 - N); + state.dataSolarShading->YVS(N) = ShadeV(SBSNR).YV(state.dataSolarShading->NVS + 1 - N); } - LOCHCA = FSBSHC; - HTRANS1(LOCHCA, NVS); - HCAREA(LOCHCA) = -HCAREA(LOCHCA); - HCT(LOCHCA) = 1.0; - NSBSHC = LOCHCA - FSBSHC + 1; + state.dataSolarShading->LOCHCA = state.dataSolarShading->FSBSHC; + HTRANS1(state, state.dataSolarShading->LOCHCA, state.dataSolarShading->NVS); + state.dataSolarShading->HCAREA(state.dataSolarShading->LOCHCA) = -state.dataSolarShading->HCAREA(state.dataSolarShading->LOCHCA); + state.dataSolarShading->HCT(state.dataSolarShading->LOCHCA) = 1.0; + state.dataSolarShading->NSBSHC = state.dataSolarShading->LOCHCA - state.dataSolarShading->FSBSHC + 1; // Determine sunlit area of subsurface due to shadows on general receiving surface. - if (NGSSHC > 0) { - MULTOL(LOCHCA, FGSSHC - 1, NGSSHC); - if ((OverlapStatus != TooManyVertices) && (OverlapStatus != TooManyFigures)) NSBSHC = LOCHCA - FSBSHC + 1; + if (state.dataSolarShading->NGSSHC > 0) { + MULTOL(state, state.dataSolarShading->LOCHCA, state.dataSolarShading->FGSSHC - 1, state.dataSolarShading->NGSSHC); + if ((state.dataSolarShading->OverlapStatus != state.dataSolarShading->TooManyVertices) && (state.dataSolarShading->OverlapStatus != state.dataSolarShading->TooManyFigures)) state.dataSolarShading->NSBSHC = state.dataSolarShading->LOCHCA - state.dataSolarShading->FSBSHC + 1; } } - if ((OverlapStatus == TooManyVertices) || (OverlapStatus == TooManyFigures) || - (SAREA(HTS) <= 0.0)) { // General receiving surface totally shaded. + if ((state.dataSolarShading->OverlapStatus == state.dataSolarShading->TooManyVertices) || (state.dataSolarShading->OverlapStatus == state.dataSolarShading->TooManyFigures) || + (state.dataSolarShading->SAREA(HTS) <= 0.0)) { // General receiving surface totally shaded. - SAREA(HTSS) = 0.0; + state.dataSolarShading->SAREA(HTSS) = 0.0; if (iHour > 0 && TS > 0) SunlitFracWithoutReveal(TS, iHour, HTSS) = 0.0; - } else if ((NGSSHC <= 0) || (NSBSHC == 1)) { // No shadows. + } else if ((state.dataSolarShading->NGSSHC <= 0) || (state.dataSolarShading->NSBSHC == 1)) { // No shadows. - SAREA(HTSS) = HCAREA(FSBSHC); - SAREA(HTS) -= SAREA(HTSS); // Revise sunlit area of general receiving surface. + state.dataSolarShading->SAREA(HTSS) = state.dataSolarShading->HCAREA(state.dataSolarShading->FSBSHC); + state.dataSolarShading->SAREA(HTS) -= state.dataSolarShading->SAREA(HTSS); // Revise sunlit area of general receiving surface. // TH. This is a bug. SunLitFracWithoutReveal should be a ratio of area // IF(IHour > 0 .AND. TS > 0) SunLitFracWithoutReveal(HTSS,IHour,TS) = & // Surface(HTSS)%NetAreaShadowCalc // new code fixed part of CR 7596. TH 5/29/2009 - if (iHour > 0 && TS > 0) SunlitFracWithoutReveal(TS, iHour, HTSS) = SAREA(HTSS) / Surface(HTSS).NetAreaShadowCalc; + if (iHour > 0 && TS > 0) SunlitFracWithoutReveal(TS, iHour, HTSS) = state.dataSolarShading->SAREA(HTSS) / Surface(HTSS).NetAreaShadowCalc; - SHDRVL(HTSS, SBSNR, iHour, TS); // Determine shadowing from reveal. + SHDRVL(state, HTSS, SBSNR, iHour, TS); // Determine shadowing from reveal. - if ((OverlapStatus == TooManyVertices) || (OverlapStatus == TooManyFigures)) SAREA(HTSS) = 0.0; + if ((state.dataSolarShading->OverlapStatus == state.dataSolarShading->TooManyVertices) || (state.dataSolarShading->OverlapStatus == state.dataSolarShading->TooManyFigures)) state.dataSolarShading->SAREA(HTSS) = 0.0; } else { // Compute area. - A = HCAREA(FSBSHC); - for (J = 2; J <= NSBSHC; ++J) { - A += HCAREA(FSBSHC - 1 + J) * (1.0 - HCT(FSBSHC - 1 + J)); + A = state.dataSolarShading->HCAREA(state.dataSolarShading->FSBSHC); + for (J = 2; J <= state.dataSolarShading->NSBSHC; ++J) { + A += state.dataSolarShading->HCAREA(state.dataSolarShading->FSBSHC - 1 + J) * (1.0 - state.dataSolarShading->HCT(state.dataSolarShading->FSBSHC - 1 + J)); } - SAREA(HTSS) = A; - if (SAREA(HTSS) > 0.0) { + state.dataSolarShading->SAREA(HTSS) = A; + if (state.dataSolarShading->SAREA(HTSS) > 0.0) { - SAREA(HTS) -= SAREA(HTSS); // Revise sunlit area of general receiving surface. + state.dataSolarShading->SAREA(HTS) -= state.dataSolarShading->SAREA(HTSS); // Revise sunlit area of general receiving surface. - if (iHour > 0 && TS > 0) SunlitFracWithoutReveal(TS, iHour, HTSS) = SAREA(HTSS) / Surface(HTSS).Area; + if (iHour > 0 && TS > 0) SunlitFracWithoutReveal(TS, iHour, HTSS) = state.dataSolarShading->SAREA(HTSS) / Surface(HTSS).Area; - SHDRVL(HTSS, SBSNR, iHour, TS); // Determine shadowing from reveal. + SHDRVL(state, HTSS, SBSNR, iHour, TS); // Determine shadowing from reveal. - if ((OverlapStatus == TooManyVertices) || (OverlapStatus == TooManyFigures)) SAREA(HTSS) = 0.0; + if ((state.dataSolarShading->OverlapStatus == state.dataSolarShading->TooManyVertices) || (state.dataSolarShading->OverlapStatus == state.dataSolarShading->TooManyFigures)) state.dataSolarShading->SAREA(HTSS) = 0.0; } else { // General receiving surface totally shaded. - SAREA(HTSS) = 0.0; + state.dataSolarShading->SAREA(HTSS) = 0.0; } } } @@ -9660,18 +9085,18 @@ namespace SolarShading { // Determine transmittance and absorptances of sunlit window. if (state.dataConstruction->Construct(K).TransDiff > 0.0) { - if (!CalcSkyDifShading) { // Overlaps calculation is only done for beam solar + if (!state.dataSolarShading->CalcSkyDifShading) { // Overlaps calculation is only done for beam solar // shading, not for sky diffuse solar shading - CalcInteriorSolarOverlaps(iHour, NBKS, HTSS, CurSurf, TS); + CalcInteriorSolarOverlaps(state, iHour, NBKS, HTSS, CurSurf, TS); } } // Error checking. SurfArea = Surface(SBSNR).NetAreaShadowCalc; - SAREA(HTSS) = max(0.0, SAREA(HTSS)); + state.dataSolarShading->SAREA(HTSS) = max(0.0, state.dataSolarShading->SAREA(HTSS)); - SAREA(HTSS) = min(SAREA(HTSS), SurfArea); + state.dataSolarShading->SAREA(HTSS) = min(state.dataSolarShading->SAREA(HTSS), SurfArea); } // End of subsurface loop } @@ -9761,7 +9186,7 @@ namespace SolarShading { EqOfTimeCoef(9) * (pow_2(pow_2(CosX) - pow_2(SineX)) - pow_2(SineX * CosX * 2.0)); } - void SUN4(Real64 const CurrentTime, // Time to use in shadowing calculations + void SUN4(EnergyPlusData &state, Real64 const CurrentTime, // Time to use in shadowing calculations Real64 const EqOfTime, // Equation of time for current day Real64 const SinSolarDeclin, // Sine of the Solar declination (current day) Real64 const CosSolarDeclin // Cosine of the Solar declination (current day) @@ -9778,28 +9203,9 @@ namespace SolarShading { // This subroutine computes solar direction cosines for a given hour. These // cosines are used in the shadowing calculations. - // METHODOLOGY EMPLOYED: - // na - // REFERENCES: // BLAST/IBLAST code, original author George Walton - // USE STATEMENTS: - // na - - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: Real64 H; // Hour angle (before noon = +) (in radians) Real64 HrAngle; // Basic hour angle @@ -9808,15 +9214,15 @@ namespace SolarShading { H = HrAngle * DataGlobalConstants::DegToRadians(); // Compute the cosine of the solar zenith angle. - SUNCOS(3) = SinSolarDeclin * SinLatitude + CosSolarDeclin * CosLatitude * std::cos(H); - SUNCOS(2) = 0.0; - SUNCOS(1) = 0.0; + state.dataSolarShading->SUNCOS(3) = SinSolarDeclin * SinLatitude + CosSolarDeclin * CosLatitude * std::cos(H); + state.dataSolarShading->SUNCOS(2) = 0.0; + state.dataSolarShading->SUNCOS(1) = 0.0; - if (SUNCOS(3) < SunIsUpValue) return; // Return if sun not above horizon. + if (state.dataSolarShading->SUNCOS(3) < SunIsUpValue) return; // Return if sun not above horizon. // Compute other direction cosines. - SUNCOS(2) = SinSolarDeclin * CosLatitude - CosSolarDeclin * SinLatitude * std::cos(H); - SUNCOS(1) = CosSolarDeclin * std::sin(H); + state.dataSolarShading->SUNCOS(2) = SinSolarDeclin * CosLatitude - CosSolarDeclin * SinLatitude * std::cos(H); + state.dataSolarShading->SUNCOS(1) = CosSolarDeclin * std::sin(H); } void WindowShadingManager(EnergyPlusData &state) @@ -10496,23 +9902,10 @@ namespace SolarShading { // horizon brightening component. // Calculates sky and ground IR view factors assuming sky IR is isotropic and // shadowing surfaces are opaque to IR. - // REFERENCES: - // na // Using/Aliasing using DataSystemVariables::DetailedSkyDiffuseAlgorithm; - // Locals - // SUBROUTINE PARAMETER DEFINITIONS: - - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - int SrdSurfsNum; // Srd surface counter Real64 Fac1WoShdg; // Intermediate calculation factor, without shading Real64 FracIlluminated; // Fraction of surface area illuminated by a sky patch @@ -10532,7 +9925,7 @@ namespace SolarShading { // FLOW: // Initialize Surfaces Arrays - SAREA = 0.0; + state.dataSolarShading->SAREA = 0.0; WithShdgIsoSky.dimension(TotSurfaces, 0.0); WoShdgIsoSky.dimension(TotSurfaces, 0.0); WithShdgHoriz.dimension(TotSurfaces, 0.0); @@ -10594,11 +9987,11 @@ namespace SolarShading { } for (int IPhi = 0; IPhi < NPhi; ++IPhi) { // Loop over patch altitude values - SUNCOS(3) = sin_Phi[IPhi]; + state.dataSolarShading->SUNCOS(3) = sin_Phi[IPhi]; for (int ITheta = 0; ITheta < NTheta; ++ITheta) { // Loop over patch azimuth values - SUNCOS(1) = cos_Phi[IPhi] * cos_Theta[ITheta]; - SUNCOS(2) = cos_Phi[IPhi] * sin_Theta[ITheta]; + state.dataSolarShading->SUNCOS(1) = cos_Phi[IPhi] * cos_Theta[ITheta]; + state.dataSolarShading->SUNCOS(2) = cos_Phi[IPhi] * sin_Theta[ITheta]; for (int SurfNum = 1; SurfNum <= TotSurfaces; ++SurfNum) { // Cosine of angle of incidence on surface of solar // radiation from patch @@ -10606,8 +9999,8 @@ namespace SolarShading { if (!ShadowingSurf && !Surface(SurfNum).HeatTransSurf) continue; - CTHETA(SurfNum) = SUNCOS(1) * Surface(SurfNum).OutNormVec(1) + SUNCOS(2) * Surface(SurfNum).OutNormVec(2) + - SUNCOS(3) * Surface(SurfNum).OutNormVec(3); + state.dataSolarShading->CTHETA(SurfNum) = state.dataSolarShading->SUNCOS(1) * Surface(SurfNum).OutNormVec(1) + state.dataSolarShading->SUNCOS(2) * Surface(SurfNum).OutNormVec(2) + + state.dataSolarShading->SUNCOS(3) * Surface(SurfNum).OutNormVec(3); } SHADOW(state, 24, 0); @@ -10620,14 +10013,14 @@ namespace SolarShading { (Surface(SurfNum).ExtBoundCond != ExternalEnvironment && Surface(SurfNum).ExtBoundCond != OtherSideCondModeledExt))) continue; - if (CTHETA(SurfNum) < 0.0) continue; + if (state.dataSolarShading->CTHETA(SurfNum) < 0.0) continue; - Fac1WoShdg = cos_Phi[IPhi] * DThetaDPhi * CTHETA(SurfNum); + Fac1WoShdg = cos_Phi[IPhi] * DThetaDPhi * state.dataSolarShading->CTHETA(SurfNum); SurfArea = Surface(SurfNum).NetAreaShadowCalc; if (SurfArea > Eps) { - FracIlluminated = SAREA(SurfNum) / SurfArea; + FracIlluminated = state.dataSolarShading->SAREA(SurfNum) / SurfArea; } else { - FracIlluminated = SAREA(SurfNum) / (SurfArea + Eps); + FracIlluminated = state.dataSolarShading->SAREA(SurfNum) / (SurfArea + Eps); } Fac1WithShdg = Fac1WoShdg * FracIlluminated; WithShdgIsoSky(SurfNum) += Fac1WithShdg; @@ -10714,16 +10107,6 @@ namespace SolarShading { // Called by CalcPerSolarBeam for wholly or partially sunlit exterior windows // Calculates horizontal and vertical beam solar profile angles - // REFERENCES: na - // USE STATEMENTS: na - - // Locals - // SUBROUTINE PARAMETER DEFINITIONS: na - // INTERFACE BLOCK SPECIFICATIONS: na - // DERIVED TYPE DEFINITIONS: na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - Real64 ElevSun; // Sun elevation; angle between sun and horizontal Real64 ElevWin; // Window elevation: angle between window outward normal and horizontal Real64 AzimWin; // Window azimuth (radians) @@ -10807,7 +10190,7 @@ namespace SolarShading { } } - void CalcFrameDividerShadow(int const SurfNum, // Surface number + void CalcFrameDividerShadow(EnergyPlusData &state, int const SurfNum, // Surface number int const FrDivNum, // Frame/divider number int const HourNum // Hour number ) @@ -10837,17 +10220,6 @@ namespace SolarShading { // these portions is assumed to be transmitted into the zone unchanged. // The shadowing of diffuse solar radiation by projections is not considered. - // REFERENCES: na - // USE STATEMENTS: na - - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: na - // INTERFACE BLOCK SPECIFICATIONS: na - // DERIVED TYPE DEFINITIONS: na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: Real64 ElevSun; // Sun elevation; angle between sun and horizontal Real64 ElevWin; // Window elevation: angle between window outward normal and horizontal Real64 AzimWin; // Window azimuth (radians) @@ -10916,9 +10288,9 @@ namespace SolarShading { GlArea = Surface(SurfNum).Area; ElevWin = DataGlobalConstants::PiOvr2() - Surface(SurfNum).Tilt * DataGlobalConstants::DegToRadians(); - ElevSun = DataGlobalConstants::PiOvr2() - std::acos(SUNCOS(3)); + ElevSun = DataGlobalConstants::PiOvr2() - std::acos(state.dataSolarShading->SUNCOS(3)); AzimWin = Surface(SurfNum).Azimuth * DataGlobalConstants::DegToRadians(); - AzimSun = std::atan2(SUNCOS(1), SUNCOS(2)); + 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; if (std::abs(ElevWin) < 0.1) { // Near-vertical window @@ -10929,7 +10301,7 @@ namespace SolarShading { WinNormCrossBase(1) = -std::sin(ElevWin) * std::cos(ThWin); WinNormCrossBase(2) = std::sin(ElevWin) * std::sin(ThWin); WinNormCrossBase(3) = std::cos(ElevWin); - SunPrime = SUNCOS - WinNormCrossBase * dot(SUNCOS, WinNormCrossBase); + SunPrime = state.dataSolarShading->SUNCOS - WinNormCrossBase * dot(state.dataSolarShading->SUNCOS, WinNormCrossBase); ProfileAngVert = std::abs(std::acos(dot(WinNorm, SunPrime) / magnitude(SunPrime))); } // Constrain to 0 to pi @@ -11598,7 +10970,7 @@ namespace SolarShading { } } - void ReportSurfaceErrors() + void ReportSurfaceErrors(EnergyPlusData &state) { // SUBROUTINE INFORMATION: @@ -11611,30 +10983,11 @@ namespace SolarShading { // This subroutine reports some recurring type errors that can get mixed up with more important // errors in the error file. - // METHODOLOGY EMPLOYED: - // na - - // REFERENCES: - // na - - // Using/Aliasing using namespace DataErrorTracking; // for error tracking using General::RoundSigDigits; - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - // na - - // SUBROUTINE PARAMETER DEFINITIONS: static Array1D_string const MSG(4, {"misses", "", "within", "overlaps"}); - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int Loop1; int Loop2; int Count; @@ -11642,13 +10995,13 @@ namespace SolarShading { Array1D_bool SurfErrorReported; Array1D_bool SurfErrorReported2; - if (NumTooManyFigures + NumTooManyVertices + NumBaseSubSurround > 0) { + if (state.dataSolarShading->NumTooManyFigures + state.dataSolarShading->NumTooManyVertices + state.dataSolarShading->NumBaseSubSurround > 0) { ShowMessage(""); ShowMessage("===== Recurring Surface Error Summary ====="); ShowMessage("The following surface error messages occurred."); ShowMessage(""); - if (NumBaseSubSurround > 0) { + if (state.dataSolarShading->NumBaseSubSurround > 0) { ShowMessage("Base Surface does not surround subsurface errors occuring..."); ShowMessage( "Check that the GlobalGeometryRules object is expressing the proper starting corner and direction [CounterClockwise/Clockwise]"); @@ -11657,29 +11010,29 @@ namespace SolarShading { SurfErrorReported.dimension(TotSurfaces, false); TotCount = 0; - for (Loop1 = 1; Loop1 <= NumBaseSubSurround; ++Loop1) { + for (Loop1 = 1; Loop1 <= state.dataSolarShading->NumBaseSubSurround; ++Loop1) { Count = 0; - if (SurfErrorReported(TrackBaseSubSurround(Loop1).SurfIndex1)) continue; - for (Loop2 = 1; Loop2 <= NumBaseSubSurround; ++Loop2) { - if (TrackBaseSubSurround(Loop1).SurfIndex1 == TrackBaseSubSurround(Loop2).SurfIndex1 && - TrackBaseSubSurround(Loop1).MiscIndex == TrackBaseSubSurround(Loop2).MiscIndex) { + if (SurfErrorReported(state.dataSolarShading->TrackBaseSubSurround(Loop1).SurfIndex1)) continue; + for (Loop2 = 1; Loop2 <= state.dataSolarShading->NumBaseSubSurround; ++Loop2) { + if (state.dataSolarShading->TrackBaseSubSurround(Loop1).SurfIndex1 == state.dataSolarShading->TrackBaseSubSurround(Loop2).SurfIndex1 && + state.dataSolarShading->TrackBaseSubSurround(Loop1).MiscIndex == state.dataSolarShading->TrackBaseSubSurround(Loop2).MiscIndex) { ++Count; } } TotCount += Count; TotalWarningErrors += Count - 1; ShowWarningError("Base surface does not surround subsurface (CHKSBS), Overlap Status=" + - cOverLapStatus(TrackBaseSubSurround(Loop1).MiscIndex)); + state.dataSolarShading->cOverLapStatus(state.dataSolarShading->TrackBaseSubSurround(Loop1).MiscIndex)); ShowContinueError(" The base surround errors occurred " + std::to_string(Count) + " times."); - for (Loop2 = 1; Loop2 <= NumBaseSubSurround; ++Loop2) { - if (TrackBaseSubSurround(Loop1).SurfIndex1 == TrackBaseSubSurround(Loop2).SurfIndex1 && - TrackBaseSubSurround(Loop1).MiscIndex == TrackBaseSubSurround(Loop2).MiscIndex) { - ShowContinueError("Surface \"" + Surface(TrackBaseSubSurround(Loop1).SurfIndex1).Name + "\" " + - MSG(TrackBaseSubSurround(Loop1).MiscIndex) + " SubSurface \"" + - Surface(TrackBaseSubSurround(Loop2).SurfIndex2).Name + "\""); + for (Loop2 = 1; Loop2 <= state.dataSolarShading->NumBaseSubSurround; ++Loop2) { + if (state.dataSolarShading->TrackBaseSubSurround(Loop1).SurfIndex1 == state.dataSolarShading->TrackBaseSubSurround(Loop2).SurfIndex1 && + state.dataSolarShading->TrackBaseSubSurround(Loop1).MiscIndex == state.dataSolarShading->TrackBaseSubSurround(Loop2).MiscIndex) { + ShowContinueError("Surface \"" + Surface(state.dataSolarShading->TrackBaseSubSurround(Loop1).SurfIndex1).Name + "\" " + + MSG(state.dataSolarShading->TrackBaseSubSurround(Loop1).MiscIndex) + " SubSurface \"" + + Surface(state.dataSolarShading->TrackBaseSubSurround(Loop2).SurfIndex2).Name + "\""); } } - SurfErrorReported(TrackBaseSubSurround(Loop1).SurfIndex1) = true; + SurfErrorReported(state.dataSolarShading->TrackBaseSubSurround(Loop1).SurfIndex1) = true; } if (TotCount > 0) { ShowMessage(""); @@ -11690,36 +11043,36 @@ namespace SolarShading { SurfErrorReported2.allocate(TotSurfaces); SurfErrorReported = false; TotCount = 0; - if (NumTooManyVertices > 0) { - ShowMessage("Too many vertices [>=" + RoundSigDigits(MaxHCV) + "] in shadow overlap errors occurring..."); + if (state.dataSolarShading->NumTooManyVertices > 0) { + ShowMessage("Too many vertices [>=" + RoundSigDigits(state.dataSolarShading->MaxHCV) + "] in shadow overlap errors occurring..."); ShowMessage("These occur throughout the year and may occur several times for the same surfaces. You may be able to reduce them by " "adding Output:Diagnostics,DoNotMirrorDetachedShading;"); } - for (Loop1 = 1; Loop1 <= NumTooManyVertices; ++Loop1) { + for (Loop1 = 1; Loop1 <= state.dataSolarShading->NumTooManyVertices; ++Loop1) { Count = 0; SurfErrorReported2 = false; - if (SurfErrorReported(TrackTooManyVertices(Loop1).SurfIndex1)) continue; - for (Loop2 = 1; Loop2 <= NumTooManyVertices; ++Loop2) { - if (TrackTooManyVertices(Loop1).SurfIndex1 == TrackTooManyVertices(Loop2).SurfIndex1) { + if (SurfErrorReported(state.dataSolarShading->TrackTooManyVertices(Loop1).SurfIndex1)) continue; + for (Loop2 = 1; Loop2 <= state.dataSolarShading->NumTooManyVertices; ++Loop2) { + if (state.dataSolarShading->TrackTooManyVertices(Loop1).SurfIndex1 == state.dataSolarShading->TrackTooManyVertices(Loop2).SurfIndex1) { ++Count; } } TotCount += Count; TotalWarningErrors += Count - 1; ShowMessage(""); - ShowWarningError("Too many vertices [>=" + RoundSigDigits(MaxHCV) + "] in a shadow overlap"); - ShowContinueError("Overlapping figure=" + Surface(TrackTooManyVertices(Loop1).SurfIndex1).Name + ", Surface Class=[" + - cSurfaceClass(Surface(TrackTooManyVertices(Loop1).SurfIndex1).Class) + ']'); + ShowWarningError("Too many vertices [>=" + RoundSigDigits(state.dataSolarShading->MaxHCV) + "] in a shadow overlap"); + ShowContinueError("Overlapping figure=" + Surface(state.dataSolarShading->TrackTooManyVertices(Loop1).SurfIndex1).Name + ", Surface Class=[" + + cSurfaceClass(Surface(state.dataSolarShading->TrackTooManyVertices(Loop1).SurfIndex1).Class) + ']'); ShowContinueError(" This error occurred " + std::to_string(Count) + " times."); - for (Loop2 = 1; Loop2 <= NumTooManyVertices; ++Loop2) { - if (TrackTooManyVertices(Loop1).SurfIndex1 == TrackTooManyVertices(Loop2).SurfIndex1) { - if (SurfErrorReported2(TrackTooManyVertices(Loop2).SurfIndex2)) continue; - ShowContinueError("Figure being Overlapped=" + Surface(TrackTooManyVertices(Loop2).SurfIndex2).Name + ", Surface Class=[" + - cSurfaceClass(Surface(TrackTooManyVertices(Loop2).SurfIndex2).Class) + ']'); - SurfErrorReported2(TrackTooManyVertices(Loop2).SurfIndex2) = true; + for (Loop2 = 1; Loop2 <= state.dataSolarShading->NumTooManyVertices; ++Loop2) { + if (state.dataSolarShading->TrackTooManyVertices(Loop1).SurfIndex1 == state.dataSolarShading->TrackTooManyVertices(Loop2).SurfIndex1) { + if (SurfErrorReported2(state.dataSolarShading->TrackTooManyVertices(Loop2).SurfIndex2)) continue; + ShowContinueError("Figure being Overlapped=" + Surface(state.dataSolarShading->TrackTooManyVertices(Loop2).SurfIndex2).Name + ", Surface Class=[" + + cSurfaceClass(Surface(state.dataSolarShading->TrackTooManyVertices(Loop2).SurfIndex2).Class) + ']'); + SurfErrorReported2(state.dataSolarShading->TrackTooManyVertices(Loop2).SurfIndex2) = true; } } - SurfErrorReported(TrackTooManyVertices(Loop1).SurfIndex1) = true; + SurfErrorReported(state.dataSolarShading->TrackTooManyVertices(Loop1).SurfIndex1) = true; } if (TotCount > 0) { ShowMessage(""); @@ -11729,36 +11082,36 @@ namespace SolarShading { SurfErrorReported = false; TotCount = 0; - if (NumTooManyFigures > 0) { - ShowMessage("Too many figures [>=" + RoundSigDigits(MaxHCS) + "] in shadow overlap errors occurring..."); + if (state.dataSolarShading->NumTooManyFigures > 0) { + ShowMessage("Too many figures [>=" + RoundSigDigits(state.dataSolarShading->MaxHCS) + "] in shadow overlap errors occurring..."); ShowMessage("These occur throughout the year and may occur several times for the same surfaces. You may be able to reduce them by " "adding OutputDiagnostics,DoNotMirrorDetachedShading;"); } - for (Loop1 = 1; Loop1 <= NumTooManyFigures; ++Loop1) { + for (Loop1 = 1; Loop1 <= state.dataSolarShading->NumTooManyFigures; ++Loop1) { Count = 0; SurfErrorReported2 = false; - if (SurfErrorReported(TrackTooManyFigures(Loop1).SurfIndex1)) continue; - for (Loop2 = 1; Loop2 <= NumTooManyFigures; ++Loop2) { - if (TrackTooManyFigures(Loop1).SurfIndex1 == TrackTooManyFigures(Loop2).SurfIndex1) { + if (SurfErrorReported(state.dataSolarShading->TrackTooManyFigures(Loop1).SurfIndex1)) continue; + for (Loop2 = 1; Loop2 <= state.dataSolarShading->NumTooManyFigures; ++Loop2) { + if (state.dataSolarShading->TrackTooManyFigures(Loop1).SurfIndex1 == state.dataSolarShading->TrackTooManyFigures(Loop2).SurfIndex1) { ++Count; } } TotCount += Count; TotalWarningErrors += Count - 1; ShowMessage(""); - ShowWarningError("Too many figures [>=" + RoundSigDigits(MaxHCS) + "] in a shadow overlap"); - ShowContinueError("Overlapping figure=" + Surface(TrackTooManyFigures(Loop1).SurfIndex1).Name + ", Surface Class=[" + - cSurfaceClass(Surface(TrackTooManyFigures(Loop1).SurfIndex1).Class) + ']'); + ShowWarningError("Too many figures [>=" + RoundSigDigits(state.dataSolarShading->MaxHCS) + "] in a shadow overlap"); + ShowContinueError("Overlapping figure=" + Surface(state.dataSolarShading->TrackTooManyFigures(Loop1).SurfIndex1).Name + ", Surface Class=[" + + cSurfaceClass(Surface(state.dataSolarShading->TrackTooManyFigures(Loop1).SurfIndex1).Class) + ']'); ShowContinueError(" This error occurred " + std::to_string(Count) + " times."); - for (Loop2 = 1; Loop2 <= NumTooManyFigures; ++Loop2) { - if (TrackTooManyFigures(Loop1).SurfIndex1 == TrackTooManyFigures(Loop2).SurfIndex1) { - if (SurfErrorReported2(TrackTooManyFigures(Loop2).SurfIndex2)) continue; - ShowContinueError("Figure being Overlapped=" + Surface(TrackTooManyFigures(Loop2).SurfIndex2).Name + ", Surface Class=[" + - cSurfaceClass(Surface(TrackTooManyFigures(Loop2).SurfIndex2).Class) + ']'); - SurfErrorReported2(TrackTooManyFigures(Loop2).SurfIndex2) = true; + for (Loop2 = 1; Loop2 <= state.dataSolarShading->NumTooManyFigures; ++Loop2) { + if (state.dataSolarShading->TrackTooManyFigures(Loop1).SurfIndex1 == state.dataSolarShading->TrackTooManyFigures(Loop2).SurfIndex1) { + if (SurfErrorReported2(state.dataSolarShading->TrackTooManyFigures(Loop2).SurfIndex2)) continue; + ShowContinueError("Figure being Overlapped=" + Surface(state.dataSolarShading->TrackTooManyFigures(Loop2).SurfIndex2).Name + ", Surface Class=[" + + cSurfaceClass(Surface(state.dataSolarShading->TrackTooManyFigures(Loop2).SurfIndex2).Class) + ']'); + SurfErrorReported2(state.dataSolarShading->TrackTooManyFigures(Loop2).SurfIndex2) = true; } } - SurfErrorReported(TrackTooManyFigures(Loop1).SurfIndex1) = true; + SurfErrorReported(state.dataSolarShading->TrackTooManyFigures(Loop1).SurfIndex1) = true; } if (TotCount > 0) { ShowMessage(""); @@ -12890,7 +12243,7 @@ namespace SolarShading { Geom.AveRhoVisOverlap.dimension(Geom.Trn.NBasis, 0.0); // First to calculate and store coordinates of the window surface - LOCHCA = 1; + state.dataSolarShading->LOCHCA = 1; int BaseSurf = Surface(ISurf).BaseSurf; // Base surface number // Base surface contains current window surface (ISurf). @@ -12902,13 +12255,13 @@ namespace SolarShading { // surface area. Since both projections are equal to zero, then simply // compy these values into XVS and YVS arrays for (N = 1; N <= NVT; ++N) { - XVS(N) = XVT(N); - YVS(N) = YVT(N); + state.dataSolarShading->XVS(N) = XVT(N); + state.dataSolarShading->YVS(N) = YVT(N); } // This calculates the area stored in XVS and YVS // CALL HTRANS(1,LOCHCA,NVT) - HTRANS1(LOCHCA, NVT); + HTRANS1(state, state.dataSolarShading->LOCHCA, NVT); // HCAREA(LOCHCA) = -HCAREA(LOCHCA) // Calculation of overlap areas for each outgoing basis direction @@ -12946,33 +12299,33 @@ namespace SolarShading { // become clockwise sequential. for (N = 1; N <= NVT; ++N) { - XVS(N) = XVT(N) - XShadowProjection * ZVT(N); - YVS(N) = YVT(N) - YShadowProjection * ZVT(N); + state.dataSolarShading->XVS(N) = XVT(N) - XShadowProjection * ZVT(N); + state.dataSolarShading->YVS(N) = YVT(N) - YShadowProjection * ZVT(N); } // Transform to the homogeneous coordinate system. - NS3 = LOCHCA + 1; + NS3 = state.dataSolarShading->LOCHCA + 1; // NS3 = LOCHCA - HCT(NS3) = 0.0; + state.dataSolarShading->HCT(NS3) = 0.0; // CALL HTRANS(1,NS3,NVT) - HTRANS1(NS3, NVT); + HTRANS1(state, NS3, NVT); // Determine area of overlap of projected back surface and receiving surface. NS1 = 1; NS2 = NS3; - HCT(NS3) = 1.0; - DeterminePolygonOverlap(NS1, NS2, NS3); + state.dataSolarShading->HCT(NS3) = 1.0; + DeterminePolygonOverlap(state, NS1, NS2, NS3); - if (OverlapStatus == NoOverlap) continue; // to next back surface - if ((OverlapStatus == TooManyVertices) || (OverlapStatus == TooManyFigures)) break; // back surfaces DO loop + if (state.dataSolarShading->OverlapStatus == state.dataSolarShading->NoOverlap) continue; // to next back surface + if ((state.dataSolarShading->OverlapStatus == state.dataSolarShading->TooManyVertices) || (state.dataSolarShading->OverlapStatus == state.dataSolarShading->TooManyFigures)) break; // back surfaces DO loop - LOCHCA = NS3; - HCNS(LOCHCA) = BackSurfaceNumber; - HCAREA(LOCHCA) = -HCAREA(LOCHCA); + state.dataSolarShading->LOCHCA = NS3; + state.dataSolarShading->HCNS(state.dataSolarShading->LOCHCA) = BackSurfaceNumber; + state.dataSolarShading->HCAREA(state.dataSolarShading->LOCHCA) = -state.dataSolarShading->HCAREA(state.dataSolarShading->LOCHCA); - Geom.AOverlap(KBkSurf, IRay) = HCAREA(LOCHCA); + Geom.AOverlap(KBkSurf, IRay) = state.dataSolarShading->HCAREA(state.dataSolarShading->LOCHCA); } // DO KBkSurf = 1 , NBkSurf // If some of back surfaces is contained in base surface, then need to substract shadow of subsurface @@ -13022,7 +12375,7 @@ namespace SolarShading { } // DO IRay = 1, Geom%Trn%NBasis // Reset back shadowing counter since complex windows do not need it anymore - LOCHCA = 1; + state.dataSolarShading->LOCHCA = 1; } void TimestepInitComplexFenestration(EnergyPlusData &state) diff --git a/src/EnergyPlus/SolarShading.hh b/src/EnergyPlus/SolarShading.hh index 9ac6f9a97dc..d0bdd3a8f8c 100644 --- a/src/EnergyPlus/SolarShading.hh +++ b/src/EnergyPlus/SolarShading.hh @@ -63,6 +63,7 @@ // EnergyPlus Headers #include +#include #include #include #include @@ -79,108 +80,7 @@ namespace SolarShading { using DataBSDFWindow::BSDFWindowGeomDescr; using DataVectorTypes::Vector; - // Data - // MODULE PARAMETER DEFINITIONS: - // General Parameters... - extern Real64 const SmallIncrement; // Small increment added for shading/sunlit area calculations. - extern Real64 const HCMULT; // Multiplier used to change meters to .01 millimeters for homogeneous coordinates. - // Homogeneous Coordinates are represented in integers (64 bit). This changes the surface coordinates from meters - // to .01 millimeters -- making that the resolution for shadowing, polygon clipping, etc. - extern Real64 const sqHCMULT; // Square of HCMult used in Homogeneous coordinates - extern Real64 const sqHCMULT_fac; // ( 0.5 / sqHCMULT ) factor - extern Real64 const kHCMULT; // half of inverse square of HCMult used in Homogeneous coordinates - - // Parameters for use with the variable OverlapStatus... - extern int const NoOverlap; - extern int const FirstSurfWithinSecond; - extern int const SecondSurfWithinFirst; - extern int const PartialOverlap; - extern int const TooManyVertices; - extern int const TooManyFigures; - extern Array1D_string const cOverLapStatus; - - // DERIVED TYPE DEFINITIONS: - // INTERFACE BLOCK SPECIFICATIONS: - // na - - // MODULE VARIABLE DECLARATIONS: - extern int MaxHCV; // Maximum number of HC vertices - // (needs to be based on maxnumvertices) - extern int MaxHCS; // 200 ! Maximum number of HC surfaces (was 56) - // Following are initially set in AllocateModuleArrays - extern int MAXHCArrayBounds; // Bounds based on Max Number of Vertices in surfaces - extern int MAXHCArrayIncrement; // Increment based on Max Number of Vertices in surfaces - // The following variable should be re-engineered to lower in module hierarchy but need more analysis - extern int NVS; // Number of vertices of the shadow/clipped surface - extern int NumVertInShadowOrClippedSurface; - extern int CurrentSurfaceBeingShadowed; - extern int CurrentShadowingSurface; - extern int OverlapStatus; // Results of overlap calculation: - // 1=No overlap; 2=NS1 completely within NS2 - // 3=NS2 completely within NS1; 4=Partial overlap - - extern Array1D CTHETA; // Cosine of angle of incidence of sun's rays on surface NS - extern int FBKSHC; // HC location of first back surface - extern int FGSSHC; // HC location of first general shadowing surface - extern int FINSHC; // HC location of first back surface overlap - extern int FRVLHC; // HC location of first reveal surface - extern int FSBSHC; // HC location of first subsurface - extern int LOCHCA; // Location of highest data in the HC arrays - extern int NBKSHC; // Number of back surfaces in the HC arrays - extern int NGSSHC; // Number of general shadowing surfaces in the HC arrays - extern int NINSHC; // Number of back surface overlaps in the HC arrays - extern int NRVLHC; // Number of reveal surfaces in HC array - extern int NSBSHC; // Number of subsurfaces in the HC arrays - extern bool CalcSkyDifShading; // True when sky diffuse solar shading is - extern int ShadowingCalcFrequency; // Frequency for Shadowing Calculations - extern int ShadowingDaysLeft; // Days left in current shadowing period - extern bool debugging; extern std::unique_ptr os; // Shading file stream - extern Array1D_int HCNS; // Surface number of back surface HC figures - extern Array1D_int HCNV; // Number of vertices of each HC figure - extern Array2D HCA; // 'A' homogeneous coordinates of sides - extern Array2D HCB; // 'B' homogeneous coordinates of sides - extern Array2D HCC; // 'C' homogeneous coordinates of sides - extern Array2D HCX; // 'X' homogeneous coordinates of vertices of figure. - extern Array2D HCY; // 'Y' homogeneous coordinates of vertices of figure. - extern Array3D_int WindowRevealStatus; - extern Array1D HCAREA; // Area of each HC figure. Sign Convention: Base Surface - // - Positive, Shadow - Negative, Overlap between two shadows - // - positive, etc., so that sum of HC areas=base sunlit area - extern Array1D HCT; // Transmittance of each HC figure - extern Array1D ISABSF; // For simple interior solar distribution (in which all beam - // radiation entering zone is assumed to strike the floor), - // fraction of beam radiation absorbed by each floor surface - extern Array1D SAREA; // Sunlit area of heat transfer surface HTS - // Excludes multiplier for windows - // Shadowing combinations data structure...See ShadowingCombinations type - extern int NumTooManyFigures; - extern int NumTooManyVertices; - extern int NumBaseSubSurround; - extern Array1D SUNCOS; // Direction cosines of solar position - extern Real64 XShadowProjection; // X projection of a shadow (formerly called C) - extern Real64 YShadowProjection; // Y projection of a shadow (formerly called S) - extern Array1D XTEMP; // Temporary 'X' values for HC vertices of the overlap - extern Array1D XVC; // X-vertices of the clipped figure - extern Array1D XVS; // X-vertices of the shadow - extern Array1D YTEMP; // Temporary 'Y' values for HC vertices of the overlap - extern Array1D YVC; // Y-vertices of the clipped figure - extern Array1D YVS; // Y-vertices of the shadow - extern Array1D ZVC; // Z-vertices of the clipped figure - // Used in Sutherland Hodman poly clipping - extern Array1D ATEMP; // Temporary 'A' values for HC vertices of the overlap - extern Array1D BTEMP; // Temporary 'B' values for HC vertices of the overlap - extern Array1D CTEMP; // Temporary 'C' values for HC vertices of the overlap - extern Array1D XTEMP1; // Temporary 'X' values for HC vertices of the overlap - extern Array1D YTEMP1; // Temporary 'Y' values for HC vertices of the overlap - extern int maxNumberOfFigures; - - // SUBROUTINE SPECIFICATIONS FOR MODULE SolarShading -#ifdef EP_NO_OPENGL - extern bool penumbra; -#else - extern std::unique_ptr penumbra; -#endif // Types @@ -197,14 +97,6 @@ namespace SolarShading { } }; - // Object Data - extern Array1D TrackTooManyFigures; - extern Array1D TrackTooManyVertices; - extern Array1D TrackBaseSubSurround; - - // Functions - void clear_state(); - void InitSolarCalculations(EnergyPlusData &state); void GetShadowingInput(EnergyPlusData &state); @@ -223,7 +115,7 @@ namespace SolarShading { bool &CannotShade // TRUE if shadow casting surface cannot shade receiving surface. ); - void CHKSBS(int const HTS, // Heat transfer surface number of the general receiving surf + void CHKSBS(EnergyPlusData &state, int const HTS, // Heat transfer surface number of the general receiving surf int const GRSNR, // Surface number of general receiving surface int const SBSNR // Surface number of subsurface ); @@ -237,7 +129,7 @@ namespace SolarShading { void ComputeIntSolarAbsorpFactors(EnergyPlusData &state); - void CLIP(int const NVT, Array1D &XVT, Array1D &YVT, Array1D &ZVT); + void CLIP(EnergyPlusData &state, int const NVT, Array1D &XVT, Array1D &YVT, Array1D &ZVT); void CTRANS(int const NS, // Surface number whose vertex coordinates are being transformed int const NGRS, // Base surface number for surface NS @@ -246,20 +138,20 @@ namespace SolarShading { Array1D &YVT, Array1D &ZVT); - void HTRANS(int const I, // Mode selector: 0 - Compute H.C. of sides + void HTRANS(EnergyPlusData &state, int const I, // Mode selector: 0 - Compute H.C. of sides int const NS, // Figure Number int const NumVertices // Number of vertices ); - void HTRANS0(int const NS, // Figure Number + void HTRANS0(EnergyPlusData &state, int const NS, // Figure Number int const NumVertices // Number of vertices ); - void HTRANS1(int const NS, // Figure Number + void HTRANS1(EnergyPlusData &state, int const NS, // Figure Number int const NumVertices // Number of vertices ); - void INCLOS(int const N1, // Figure number of figure 1 + void INCLOS(EnergyPlusData &state, int const N1, // Figure number of figure 1 int const N1NumVert, // Number of vertices of figure 1 int const N2, // Figure number of figure 2 int const N2NumVert, // Number of vertices of figure 2 @@ -267,30 +159,30 @@ namespace SolarShading { int &NIN // Number of vertices of figure 1 within figure 2 ); - void INTCPT(int const NV1, // Number of vertices of figure NS1 + void INTCPT(EnergyPlusData &state, int const NV1, // Number of vertices of figure NS1 int const NV2, // Number of vertices of figure NS2 int &NV3, // Number of vertices of figure NS3 int const NS1, // Number of the figure being overlapped int const NS2 // Number of the figure doing overlapping ); - void CLIPPOLY(int const NS1, // Figure number of figure 1 (The subject polygon) + void CLIPPOLY(EnergyPlusData &state, int const NS1, // Figure number of figure 1 (The subject polygon) int const NS2, // Figure number of figure 2 (The clipping polygon) int const NV1, // Number of vertices of figure 1 int const NV2, // Number of vertices of figure 2 int &NV3 // Number of vertices of figure 3 ); - void MULTOL(int const NNN, // argument + void MULTOL(EnergyPlusData &state, int const NNN, // argument int const LOC0, // Location in the homogeneous coordinate array int const NRFIGS // Number of figures overlapped ); - void ORDER(int const NV3, // Number of vertices of figure NS3 + void ORDER(EnergyPlusData &state, int const NV3, // Number of vertices of figure NS3 int const NS3 // Location to place results of overlap ); - void DeterminePolygonOverlap(int const NS1, // Number of the figure being overlapped + void DeterminePolygonOverlap(EnergyPlusData &state, int const NS1, // Number of the figure being overlapped int const NS2, // Number of the figure doing overlapping int const NS3 // Location to place results of overlap ); @@ -301,7 +193,7 @@ namespace SolarShading { Real64 const AvgCosSolarDeclin // Average value of Cosine of Solar Declination for period ); - void FigureSunCosines(int const iHour, + void FigureSunCosines(EnergyPlusData &state, int const iHour, int const iTimeStep, Real64 const EqOfTime, // value of Equation of Time for period Real64 const SinSolarDeclin, // value of Sine of Solar Declination for period @@ -317,7 +209,7 @@ namespace SolarShading { int const TS // Time Step ); - void SHDBKS(int const NGRS, // Number of the general receiving surface + void SHDBKS(EnergyPlusData &state, int const NGRS, // Number of the general receiving surface int const CurSurf, int const NBKS, // Number of back surfaces int const HTS // Heat transfer surface number of the general receiving surf @@ -332,7 +224,7 @@ namespace SolarShading { int const HTS // Heat transfer surface number of the general receiving surf ); - void CalcInteriorSolarOverlaps(int const iHour, // Hour Index + void CalcInteriorSolarOverlaps(EnergyPlusData &state, int const iHour, // Hour Index int const NBKS, // Number of back surfaces associated with this GRSNR (in general, only int const HTSS, // Surface number of the subsurface (exterior window) int const GRSNR, // General receiving surface number (base surface of the exterior window) @@ -357,7 +249,7 @@ namespace SolarShading { void PerformSolarCalculations(EnergyPlusData &state); - void SHDRVL(int const HTSS, // Heat transfer surface number of the subsurface + void SHDRVL(EnergyPlusData &state, int const HTSS, // Heat transfer surface number of the subsurface int const SBSNR, // Subsurface number int const Hour, int const TS); @@ -376,7 +268,7 @@ namespace SolarShading { Real64 &EquationOfTime // Equation of Time (Degrees) ); - void SUN4(Real64 const CurrentTime, // Time to use in shadowing calculations + void SUN4(EnergyPlusData &state, Real64 const CurrentTime, // Time to use in shadowing calculations Real64 const EqOfTime, // Equation of time for current day Real64 const SinSolarDeclin, // Sine of the Solar declination (current day) Real64 const CosSolarDeclin // Cosine of the Solar declination (current day) @@ -392,7 +284,7 @@ namespace SolarShading { void CalcWindowProfileAngles(); - void CalcFrameDividerShadow(int const SurfNum, // Surface number + void CalcFrameDividerShadow(EnergyPlusData &state, int const SurfNum, // Surface number int const FrDivNum, // Frame/divider number int const HourNum // Hour number ); @@ -401,7 +293,7 @@ namespace SolarShading { void ReportSurfaceShading(); - void ReportSurfaceErrors(); + void ReportSurfaceErrors(EnergyPlusData &state); void ComputeWinShadeAbsorpFactors(EnergyPlusData &state); @@ -424,6 +316,200 @@ namespace SolarShading { } // namespace SolarShading +struct SolarShadingData : BaseGlobalStruct { + + Real64 const SmallIncrement = 1.0e-10; // Small increment added for shading/sunlit area calculations. + Real64 const HCMULT = 100000.0; // Multiplier used to change meters to .01 millimeters for homogeneous coordinates. + // Homogeneous Coordinates are represented in integers (64 bit). This changes the surface coordinates from meters + // to .01 millimeters -- making that the resolution for shadowing, polygon clipping, etc. + Real64 const sqHCMULT = (HCMULT *HCMULT); // Square of HCMult used in Homogeneous coordinates + Real64 const sqHCMULT_fac = (0.5 / sqHCMULT); // ( 0.5 / sqHCMULT ) factor + Real64 const kHCMULT = (1.0 / (HCMULT * HCMULT)); // half of inverse square of HCMult used in Homogeneous coordinates + + // Parameters for use with the variable OverlapStatus... + int const NoOverlap = 1; + int const FirstSurfWithinSecond = 2; + int const SecondSurfWithinFirst = 3; + int const PartialOverlap = 4; + int const TooManyVertices = 5; + int const TooManyFigures = 6; + Array1D_string const cOverLapStatus; + int MaxHCV = 15; // Maximum number of HC vertices + // (needs to be based on maxnumvertices) + int MaxHCS = 15000; // 200 ! Maximum number of HC surfaces (was 56) + // Following are initially set in AllocateModuleArrays + int MAXHCArrayBounds = 0; // Bounds based on Max Number of Vertices in surfaces + int MAXHCArrayIncrement = 0; // Increment based on Max Number of Vertices in surfaces + // The following variable should be re-engineered to lower in module hierarchy but need more analysis + int NVS; // Number of vertices of the shadow/clipped surface + int NumVertInShadowOrClippedSurface; + int CurrentSurfaceBeingShadowed; + int CurrentShadowingSurface; + int OverlapStatus; // Results of overlap calculation: + // 1=No overlap; 2=NS1 completely within NS2 + // 3=NS2 completely within NS1; 4=Partial overlap + + Array1D CTHETA; // Cosine of angle of incidence of sun's rays on surface NS + int FBKSHC; // HC location of first back surface + int FGSSHC; // HC location of first general shadowing surface + int FINSHC; // HC location of first back surface overlap + int FRVLHC; // HC location of first reveal surface + int FSBSHC; // HC location of first subsurface + int LOCHCA = 0; // Location of highest data in the HC arrays + int NBKSHC; // Number of back surfaces in the HC arrays + int NGSSHC; // Number of general shadowing surfaces in the HC arrays + int NINSHC; // Number of back surface overlaps in the HC arrays + int NRVLHC; // Number of reveal surfaces in HC array + int NSBSHC; // Number of subsurfaces in the HC arrays + bool CalcSkyDifShading; // True when sky diffuse solar shading is + int ShadowingCalcFrequency = 0; // Frequency for Shadowing Calculations + int ShadowingDaysLeft = 0; // Days left in current shadowing period + + Array1D_int HCNS; // Surface number of back surface HC figures + Array1D_int HCNV; // Number of vertices of each HC figure + Array2D HCA; // 'A' homogeneous coordinates of sides + Array2D HCB; // 'B' homogeneous coordinates of sides + Array2D HCC; // 'C' homogeneous coordinates of sides + Array2D HCX; // 'X' homogeneous coordinates of vertices of figure. + Array2D HCY; // 'Y' homogeneous coordinates of vertices of figure. + Array3D_int WindowRevealStatus; + Array1D HCAREA; // Area of each HC figure. Sign Convention: Base Surface + // - Positive, Shadow - Negative, Overlap between two shadows + // - positive, etc., so that sum of HC areas=base sunlit area + Array1D HCT; // Transmittance of each HC figure + Array1D ISABSF; // For simple interior solar distribution (in which all beam + // radiation entering zone is assumed to strike the floor), + // fraction of beam radiation absorbed by each floor surface + Array1D SAREA; // Sunlit area of heat transfer surface HTS + // Excludes multiplier for windows + // Shadowing combinations data structure...See ShadowingCombinations type + int NumTooManyFigures = 0; + int NumTooManyVertices = 0; + int NumBaseSubSurround = 0; + Array1D SUNCOS; // Direction cosines of solar position + Real64 XShadowProjection; // X projection of a shadow (formerly called C) + Real64 YShadowProjection; // Y projection of a shadow (formerly called S) + Array1D XTEMP; // Temporary 'X' values for HC vertices of the overlap + Array1D XVC; // X-vertices of the clipped figure + Array1D XVS; // X-vertices of the shadow + Array1D YTEMP; // Temporary 'Y' values for HC vertices of the overlap + Array1D YVC; // Y-vertices of the clipped figure + Array1D YVS; // Y-vertices of the shadow + Array1D ZVC; // Z-vertices of the clipped figure + // Used in Sutherland Hodman poly clipping + Array1D ATEMP; // Temporary 'A' values for HC vertices of the overlap + Array1D BTEMP; // Temporary 'B' values for HC vertices of the overlap + Array1D CTEMP; // Temporary 'C' values for HC vertices of the overlap + Array1D XTEMP1; // Temporary 'X' values for HC vertices of the overlap + Array1D YTEMP1; // Temporary 'Y' values for HC vertices of the overlap + int maxNumberOfFigures = 0; + + #ifdef EP_NO_OPENGL + bool penumbra = false; + #else + std::unique_ptr penumbra = nullptr; + #endif + + bool MustAllocSolarShading = true; + bool GetInputFlag = true; + bool firstTime = true; + bool debugging = false; + std::vector penumbraIDs; + + bool InitComplexOnce = true; + bool ShadowOneTimeFlag = true; + bool CHKSBSOneTimeFlag = true; + bool ORDERFirstTimeFlag = true; + bool TooManyFiguresMessage = false; + bool TooManyVerticesMessage = false; + bool SHDBKSOneTimeFlag = true; + bool SHDGSSOneTimeFlag = true; + + Array1D TrackTooManyFigures; + Array1D TrackTooManyVertices; + Array1D TrackBaseSubSurround; + + void clear_state() override + { + MaxHCV = 15; + MaxHCS = 1500; + MAXHCArrayBounds = 0; + MAXHCArrayIncrement = 0; + NVS = 0; + NumVertInShadowOrClippedSurface = 0; + CurrentSurfaceBeingShadowed = 0; + CurrentShadowingSurface = 0; + OverlapStatus = 0; + CTHETA.deallocate(); + FBKSHC = 0; + FGSSHC = 0; + FINSHC = 0; + FRVLHC = 0; + FSBSHC = 0; + LOCHCA = 0; + NBKSHC = 0; + NGSSHC = 0; + NINSHC = 0; + NRVLHC = 0; + NSBSHC = 0; + CalcSkyDifShading = false; + ShadowingCalcFrequency = 0; // Frequency for Shadowing Calculations + ShadowingDaysLeft = 0; // Days left in current shadowing period + debugging = false; + MustAllocSolarShading = true; + GetInputFlag = true; + firstTime = true; + HCNS.deallocate(); + HCNV.deallocate(); + HCA.deallocate(); + HCB.deallocate(); + HCC.deallocate(); + HCX.deallocate(); + HCY.deallocate(); + WindowRevealStatus.deallocate(); + HCAREA.deallocate(); + HCT.deallocate(); + ISABSF.deallocate(); + SAREA.deallocate(); + NumTooManyFigures = 0; + NumTooManyVertices = 0; + NumBaseSubSurround = 0; + XShadowProjection = 0.0; + YShadowProjection = 0.0; + XTEMP.deallocate(); + XVC.deallocate(); + XVS.deallocate(); + YTEMP.deallocate(); + YVC.deallocate(); + YVS.deallocate(); + ZVC.deallocate(); + ATEMP.deallocate(); + BTEMP.deallocate(); + CTEMP.deallocate(); + XTEMP1.deallocate(); + YTEMP1.deallocate(); + maxNumberOfFigures = 0; + TrackTooManyFigures.deallocate(); + TrackTooManyVertices.deallocate(); + TrackBaseSubSurround.deallocate(); + DataSurfaces::DBZoneIntWin.deallocate(); + ISABSF.deallocate(); + InitComplexOnce = true; + ShadowOneTimeFlag = true; + CHKSBSOneTimeFlag = true; + ORDERFirstTimeFlag = true; + TooManyFiguresMessage = false; + TooManyVerticesMessage = false; + SHDBKSOneTimeFlag = true; + SHDGSSOneTimeFlag = true; + } + + // Default Constructor + SolarShadingData() : + SUNCOS(3), + cOverLapStatus(6, {"No-Overlap", "1st-Surf-within-2nd", "2nd-Surf-within-1st", "Partial-Overlap", "Too-Many-Vertices", "Too-Many-Figures"}) + {} +}; } // namespace EnergyPlus #endif diff --git a/src/EnergyPlus/StateManagement.cc b/src/EnergyPlus/StateManagement.cc index 83a8540b37e..028ccf2a4f2 100644 --- a/src/EnergyPlus/StateManagement.cc +++ b/src/EnergyPlus/StateManagement.cc @@ -209,7 +209,6 @@ #include #include #include -#include #include void EnergyPlus::clearAllStates(EnergyPlusData &state) @@ -374,7 +373,6 @@ void EnergyPlus::clearAllStates(EnergyPlusData &state) SizingAnalysisObjects_clear_state(); // SizingAnalysisObjects does not have a namespace SizingManager::clear_state(); SolarCollectors::clear_state(); - SolarShading::clear_state(); SurfaceGeometry::clear_state(); UtilityRoutines::clear_state(); EIRPlantLoopHeatPumps::EIRPlantLoopHeatPump::clear_state(); diff --git a/src/EnergyPlus/UtilityRoutines.cc b/src/EnergyPlus/UtilityRoutines.cc index 1e44bdb8f20..2ec8f1eef6c 100644 --- a/src/EnergyPlus/UtilityRoutines.cc +++ b/src/EnergyPlus/UtilityRoutines.cc @@ -694,7 +694,7 @@ namespace UtilityRoutines { ReportSurfaces(state); } - ReportSurfaceErrors(); + ReportSurfaceErrors(state); CheckPlantOnAbort(); ShowRecurringErrors(); SummarizeErrors(); @@ -870,7 +870,7 @@ namespace UtilityRoutines { sqlite->updateSQLiteSimulationRecord(true, true); } - ReportSurfaceErrors(); + ReportSurfaceErrors(state); ShowRecurringErrors(); SummarizeErrors(); CloseMiscOpenFiles(state); diff --git a/tst/EnergyPlus/unit/SolarShading.unit.cc b/tst/EnergyPlus/unit/SolarShading.unit.cc index 210df5759db..8a15ccdad9c 100644 --- a/tst/EnergyPlus/unit/SolarShading.unit.cc +++ b/tst/EnergyPlus/unit/SolarShading.unit.cc @@ -102,7 +102,7 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_CalcPerSolarBeamTest) SunlitFracHR.allocate(24, TotSurfaces); SunlitFrac.allocate(NumTimeSteps, 24, TotSurfaces); SunlitFracWithoutReveal.allocate(NumTimeSteps, 24, TotSurfaces); - CTHETA.allocate(TotSurfaces); + state.dataSolarShading->CTHETA.allocate(TotSurfaces); CosIncAngHR.allocate(24, TotSurfaces); CosIncAng.allocate(NumTimeSteps, 24, TotSurfaces); AOSurf.allocate(TotSurfaces); @@ -157,7 +157,7 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_CalcPerSolarBeamTest) SunlitFracHR.deallocate(); SunlitFrac.deallocate(); SunlitFracWithoutReveal.deallocate(); - CTHETA.deallocate(); + state.dataSolarShading->CTHETA.deallocate(); CosIncAngHR.deallocate(); CosIncAng.deallocate(); AOSurf.deallocate(); @@ -666,10 +666,10 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_FigureSolarBeamAtTimestep) DataSystemVariables::DetailedSkyDiffuseAlgorithm = true; SolarDistribution = FullExterior; - CalcSkyDifShading = true; + state.dataSolarShading->CalcSkyDifShading = true; SolarShading::InitSolarCalculations(state); SolarShading::SkyDifSolarShading(state); - CalcSkyDifShading = false; + state.dataSolarShading->CalcSkyDifShading = false; FigureSolarBeamAtTimestep(state, DataGlobals::HourOfDay, DataGlobals::TimeStep); @@ -1011,7 +1011,7 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_ExternalShadingIO) ASSERT_TRUE(process_idf(idf_objects)); - SolarShading::clear_state(); + state.dataSolarShading->clear_state(); SimulationManager::GetProjectData(state); bool FoundError = false; @@ -1065,10 +1065,10 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_ExternalShadingIO) DataSystemVariables::shadingMethod = DataSystemVariables::ShadingMethod::Scheduled; SolarDistribution = FullExterior; - CalcSkyDifShading = true; + state.dataSolarShading->CalcSkyDifShading = true; SolarShading::InitSolarCalculations(state); SolarShading::SkyDifSolarShading(state); - CalcSkyDifShading = false; + state.dataSolarShading->CalcSkyDifShading = false; ScheduleManager::UpdateScheduleValues(state); DataBSDFWindow::SUNCOSTS(4, 9, 1) = 0.1; @@ -1078,10 +1078,10 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_ExternalShadingIO) EXPECT_TRUE(DataSystemVariables::shadingMethod == DataSystemVariables::ShadingMethod::Scheduled); EXPECT_DOUBLE_EQ(0.5432, ScheduleManager::LookUpScheduleValue(state, 2, 9, 4)); - EXPECT_FALSE(SolarShading::SUNCOS(3) < 0.00001); + EXPECT_FALSE(state.dataSolarShading->SUNCOS(3) < 0.00001); EXPECT_DOUBLE_EQ(0.00001, DataEnvironment::SunIsUpValue); ; - EXPECT_FALSE(SolarShading::SUNCOS(3) < DataEnvironment::SunIsUpValue); + EXPECT_FALSE(state.dataSolarShading->SUNCOS(3) < DataEnvironment::SunIsUpValue); int surfNum = UtilityRoutines::FindItemInList("ZN001:WALL-SOUTH", DataSurfaces::Surface); EXPECT_DOUBLE_EQ(1, SunlitFrac(4, 9, surfNum)); @@ -1089,7 +1089,7 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_ExternalShadingIO) EXPECT_DOUBLE_EQ(1, SunlitFrac(4, 9, surfNum)); surfNum = UtilityRoutines::FindItemInList("ZN001:ROOF", DataSurfaces::Surface); EXPECT_DOUBLE_EQ(0.5432, SunlitFrac(4, 9, surfNum)); - SolarShading::clear_state(); + state.dataSolarShading->clear_state(); } TEST_F(EnergyPlusFixture, SolarShadingTest_DisableGroupSelfShading) @@ -1422,7 +1422,7 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_DisableGroupSelfShading) ASSERT_TRUE(process_idf(idf_objects)); - SolarShading::clear_state(); + state.dataSolarShading->clear_state(); SimulationManager::GetProjectData(state); bool FoundError = false; @@ -1849,10 +1849,10 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_PolygonClippingDirect) SolarDistribution = FullExterior; DataSystemVariables::SlaterBarsky = true; - CalcSkyDifShading = true; + state.dataSolarShading->CalcSkyDifShading = true; SolarShading::InitSolarCalculations(state); SolarShading::SkyDifSolarShading(state); - CalcSkyDifShading = false; + state.dataSolarShading->CalcSkyDifShading = false; FigureSolarBeamAtTimestep(state, DataGlobals::HourOfDay, DataGlobals::TimeStep); int surfNum = UtilityRoutines::FindItemInList("ZN001:WALL-SOUTH:WIN001", DataSurfaces::Surface); @@ -2557,7 +2557,7 @@ BeginSimFlag = true; HeatBalanceManager::InitHeatBalance(state); EXPECT_FALSE(FoundError); -if (SolarShading::penumbra) { +if (state.dataSolarShading->penumbra) { SolarShading::AllocateModuleArrays(state); SolarShading::DetermineShadowingCombinations(state); From 5656d4da56cfb98c5e813bb7e7a0d0b23e7495f7 Mon Sep 17 00:00:00 2001 From: brianlball Date: Sat, 17 Oct 2020 12:15:03 -0600 Subject: [PATCH 5/8] reorder warning --- src/EnergyPlus/SolarShading.hh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/EnergyPlus/SolarShading.hh b/src/EnergyPlus/SolarShading.hh index d0bdd3a8f8c..794c1dd9786 100644 --- a/src/EnergyPlus/SolarShading.hh +++ b/src/EnergyPlus/SolarShading.hh @@ -506,8 +506,8 @@ struct SolarShadingData : BaseGlobalStruct { // Default Constructor SolarShadingData() : - SUNCOS(3), - cOverLapStatus(6, {"No-Overlap", "1st-Surf-within-2nd", "2nd-Surf-within-1st", "Partial-Overlap", "Too-Many-Vertices", "Too-Many-Figures"}) + cOverLapStatus(6, {"No-Overlap", "1st-Surf-within-2nd", "2nd-Surf-within-1st", "Partial-Overlap", "Too-Many-Vertices", "Too-Many-Figures"}), + SUNCOS(3) {} }; } // namespace EnergyPlus From 09c0997694bf343f6b9be4c52d09f97bbaabaca0 Mon Sep 17 00:00:00 2001 From: brianlball Date: Sat, 17 Oct 2020 13:11:57 -0600 Subject: [PATCH 6/8] convert SolarReflectionManager --- src/EnergyPlus/Data/CommonIncludes.hh | 1 + src/EnergyPlus/Data/EnergyPlusData.cc | 1 + src/EnergyPlus/Data/EnergyPlusData.hh | 2 + src/EnergyPlus/DaylightingManager.cc | 31 +-- src/EnergyPlus/SolarReflectionManager.cc | 269 +++++++++-------------- src/EnergyPlus/SolarReflectionManager.hh | 42 ++-- src/EnergyPlus/SolarShading.cc | 4 +- 7 files changed, 139 insertions(+), 211 deletions(-) diff --git a/src/EnergyPlus/Data/CommonIncludes.hh b/src/EnergyPlus/Data/CommonIncludes.hh index d95e98952a8..6dbce4b7895 100644 --- a/src/EnergyPlus/Data/CommonIncludes.hh +++ b/src/EnergyPlus/Data/CommonIncludes.hh @@ -82,6 +82,7 @@ #include #include #include +#include #include #include #include diff --git a/src/EnergyPlus/Data/EnergyPlusData.cc b/src/EnergyPlus/Data/EnergyPlusData.cc index c4637e32e2f..1d20b0c1584 100644 --- a/src/EnergyPlus/Data/EnergyPlusData.cc +++ b/src/EnergyPlus/Data/EnergyPlusData.cc @@ -84,6 +84,7 @@ namespace EnergyPlus { this->dataGlobal = std::unique_ptr(new DataGlobal); this->dataPipes = std::unique_ptr(new PipesData); this->dataPlantChillers = std::unique_ptr(new PlantChillersData); + this->dataSolarReflectionManager = std::unique_ptr(new SolarReflectionManagerData); this->dataSolarShading = std::unique_ptr(new SolarShadingData); this->dataSplitterComponent = std::unique_ptr(new SplitterComponentData); this->dataSteamBaseboardRadiator = std::unique_ptr(new SteamBaseboardRadiatorData); diff --git a/src/EnergyPlus/Data/EnergyPlusData.hh b/src/EnergyPlus/Data/EnergyPlusData.hh index bfac5bdc4be..6f8dfc5ac48 100644 --- a/src/EnergyPlus/Data/EnergyPlusData.hh +++ b/src/EnergyPlus/Data/EnergyPlusData.hh @@ -93,6 +93,7 @@ struct ExteriorEnergyUseData; struct FansData; struct PipesData; struct PlantChillersData; +struct SolarReflectionManagerData; struct SolarShadingData; struct SplitterComponentData; struct SteamBaseboardRadiatorData; @@ -162,6 +163,7 @@ struct EnergyPlusData : BaseGlobalStruct { std::unique_ptr dataFans; std::unique_ptr dataPipes; std::unique_ptr dataPlantChillers; + std::unique_ptr dataSolarReflectionManager; std::unique_ptr dataSolarShading; std::unique_ptr dataSplitterComponent; std::unique_ptr dataSteamBaseboardRadiator; diff --git a/src/EnergyPlus/DaylightingManager.cc b/src/EnergyPlus/DaylightingManager.cc index 55f0bfcec36..18dd0292808 100644 --- a/src/EnergyPlus/DaylightingManager.cc +++ b/src/EnergyPlus/DaylightingManager.cc @@ -3400,26 +3400,9 @@ namespace DaylightingManager { // METHODOLOGY EMPLOYED: // switch as need to serve both reference points and map points based on calledFrom - // REFERENCES: - // na - - // Using/Aliasing using DataSystemVariables::DetailedSkyDiffuseAlgorithm; using General::BlindBeamBeamTrans; using General::POLYF; - using SolarReflectionManager::SolReflRecSurf; - - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS: - // na - - // DERIVED TYPE DEFINITIONS: - // na if (SUNCOSHR(iHour, 3) < SunIsUpValue) return; @@ -3892,10 +3875,10 @@ namespace DaylightingManager { // Receiving surface number corresponding this window RecSurfNum = Surface(IWin2).ShadowSurfRecSurfNum; if (RecSurfNum > 0) { // interior windows do not apply - if (SolReflRecSurf(RecSurfNum).NumPossibleObs > 0) { + if (state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).NumPossibleObs > 0) { // This window has associated obstructions that could reflect beam onto the window - for (int loop = 1, loop_end = SolReflRecSurf(RecSurfNum).NumPossibleObs; loop <= loop_end; ++loop) { - ReflSurfNum = SolReflRecSurf(RecSurfNum).PossibleObsSurfNums(loop); + for (int loop = 1, loop_end = state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).NumPossibleObs; loop <= loop_end; ++loop) { + ReflSurfNum = state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).PossibleObsSurfNums(loop); ReflSurfNumX = ReflSurfNum; // Each shadowing surface has a "mirror" duplicate surface facing in the opposite direction. // The following gets the correct side of a shadowing surface for reflection. @@ -3928,8 +3911,8 @@ namespace DaylightingManager { ReflDistance = std::sqrt(ReflDistanceSq); // Is ray from ref. pt. to reflection point (HitPtRefl) obstructed? hitObsRefl = false; - for (int loop2 = 1, loop2_end = SolReflRecSurf(RecSurfNum).NumPossibleObs; loop2 <= loop2_end; ++loop2) { - int const ObsSurfNum = SolReflRecSurf(RecSurfNum).PossibleObsSurfNums(loop2); + for (int loop2 = 1, loop2_end = state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).NumPossibleObs; loop2 <= loop2_end; ++loop2) { + int const ObsSurfNum = state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).PossibleObsSurfNums(loop2); if (ObsSurfNum == ReflSurfNum || ObsSurfNum == Surface(ReflSurfNum).BaseSurf) continue; PierceSurface(ObsSurfNum, RREF2, SunVecMir, ReflDistance, HitPtObs, hitObs); // ReflDistance cutoff added if (hitObs) { // => Could skip distance check (unless < vs <= ReflDistance really matters) @@ -3949,8 +3932,8 @@ namespace DaylightingManager { ReflSurfRecNum = Surface(ReflSurfNum).ShadowSurfRecSurfNum; if (ReflSurfRecNum > 0) { // Loop over possible obstructions for this reflecting window - for (int loop2 = 1, loop2_end = SolReflRecSurf(ReflSurfRecNum).NumPossibleObs; loop2 <= loop2_end; ++loop2) { - int const ObsSurfNum = SolReflRecSurf(ReflSurfRecNum).PossibleObsSurfNums(loop2); + for (int loop2 = 1, loop2_end = state.dataSolarReflectionManager->SolReflRecSurf(ReflSurfRecNum).NumPossibleObs; loop2 <= loop2_end; ++loop2) { + int const ObsSurfNum = state.dataSolarReflectionManager->SolReflRecSurf(ReflSurfRecNum).PossibleObsSurfNums(loop2); PierceSurface(ObsSurfNum, HitPtRefl, RAYCOS, HitPtObs, hitObs); if (hitObs) break; } diff --git a/src/EnergyPlus/SolarReflectionManager.cc b/src/EnergyPlus/SolarReflectionManager.cc index 5fa2cfb4975..a30573cf7da 100644 --- a/src/EnergyPlus/SolarReflectionManager.cc +++ b/src/EnergyPlus/SolarReflectionManager.cc @@ -95,25 +95,6 @@ namespace SolarReflectionManager { using namespace DataVectorTypes; - // Data - // MODULE PARAMETER DEFINITIONS:na - - // DERIVED TYPE DEFINITIONS: - - // MODULE VARIABLE DECLARATIONS: - int TotSolReflRecSurf(0); // Total number of exterior surfaces that can receive reflected solar - int TotPhiReflRays(0); // Number of rays in altitude angle (-90 to 90 deg) for diffuse refl calc - int TotThetaReflRays(0); // Number of rays in azimuth angle (0 to 180 deg) for diffuse refl calc - - // SUBROUTINE SPECIFICATIONS FOR MODULE ExteriorSolarReflectionManager - - // Object Data - Array1D SolReflRecSurf; - - // MODULE SUBROUTINES: - - // Functions - void InitSolReflRecSurf(EnergyPlusData &state) { @@ -201,10 +182,10 @@ namespace SolarReflectionManager { // and solar collectors on shading surfaces that need this. // shading surfaces have ExtSolar = False, so they are not included in TotSolReflRecSurf - TotSolReflRecSurf = 0; + state.dataSolarReflectionManager->TotSolReflRecSurf = 0; for (SurfNum = 1; SurfNum <= TotSurfaces; ++SurfNum) { if (Surface(SurfNum).ExtSolar) { - ++TotSolReflRecSurf; + ++state.dataSolarReflectionManager->TotSolReflRecSurf; } } @@ -231,7 +212,7 @@ namespace SolarReflectionManager { // Surface(SurfNum)%ShadowSurfPossibleReflector = .TRUE. // END DO - if (TotSolReflRecSurf == 0) { + if (state.dataSolarReflectionManager->TotSolReflRecSurf == 0) { ShowWarningError("Calculation of solar reflected from obstructions has been requested but there"); ShowContinueError("are no building surfaces that can receive reflected solar. Calculation will not be done."); CalcSolRefl = false; @@ -240,12 +221,12 @@ namespace SolarReflectionManager { // Should this be moved up front? if (IgnoreSolarRadiation) { - TotSolReflRecSurf = 0; + state.dataSolarReflectionManager->TotSolReflRecSurf = 0; CalcSolRefl = false; return; } - SolReflRecSurf.allocate(TotSolReflRecSurf); + state.dataSolarReflectionManager->SolReflRecSurf.allocate(state.dataSolarReflectionManager->TotSolReflRecSurf); ReflFacBmToDiffSolObs.dimension(24, TotSurfaces, 0.0); ReflFacBmToDiffSolGnd.dimension(24, TotSurfaces, 0.0); @@ -261,8 +242,8 @@ namespace SolarReflectionManager { Surface(SurfNum).ShadowSurfRecSurfNum = 0; if (Surface(SurfNum).ExtSolar) { ++RecSurfNum; - SolReflRecSurf(RecSurfNum).SurfNum = SurfNum; - SolReflRecSurf(RecSurfNum).SurfName = Surface(SurfNum).Name; + state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).SurfNum = SurfNum; + state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).SurfName = Surface(SurfNum).Name; Surface(SurfNum).ShadowSurfRecSurfNum = RecSurfNum; // Warning if any receiving surface vertex is below ground level, taken to be at Z = 0 in absolute coords @@ -278,33 +259,33 @@ namespace SolarReflectionManager { // Get MaxRecPts for allocating SolReflRecSurf arrays that depend on number of receiving points MaxRecPts = 1; - for (RecSurfNum = 1; RecSurfNum <= TotSolReflRecSurf; ++RecSurfNum) { - SolReflRecSurf(RecSurfNum).NumRecPts = Surface(SolReflRecSurf(RecSurfNum).SurfNum).Sides; - if (SolReflRecSurf(RecSurfNum).NumRecPts > MaxRecPts) MaxRecPts = SolReflRecSurf(RecSurfNum).NumRecPts; + for (RecSurfNum = 1; RecSurfNum <= state.dataSolarReflectionManager->TotSolReflRecSurf; ++RecSurfNum) { + state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).NumRecPts = Surface( state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).SurfNum).Sides; + if (state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).NumRecPts > MaxRecPts) MaxRecPts = state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).NumRecPts; } MaxReflRays = AltAngStepsForSolReflCalc * AzimAngStepsForSolReflCalc; - for (RecSurfNum = 1; RecSurfNum <= TotSolReflRecSurf; ++RecSurfNum) { - SolReflRecSurf(RecSurfNum).NormVec = 0.0; - SolReflRecSurf(RecSurfNum).RecPt.dimension(MaxRecPts, zero3); - SolReflRecSurf(RecSurfNum).RayVec.dimension(MaxReflRays, zero3); - SolReflRecSurf(RecSurfNum).CosIncAngRay.dimension(MaxReflRays, 0.0); - SolReflRecSurf(RecSurfNum).dOmegaRay.dimension(MaxReflRays, 0.0); - SolReflRecSurf(RecSurfNum).HitPt.dimension(MaxReflRays, MaxRecPts, zero3); - SolReflRecSurf(RecSurfNum).HitPtSurfNum.dimension(MaxReflRays, MaxRecPts, 0.0); - SolReflRecSurf(RecSurfNum).HitPtSolRefl.dimension(MaxReflRays, MaxRecPts, 0.0); - SolReflRecSurf(RecSurfNum).RecPtHitPtDis.dimension(MaxReflRays, MaxRecPts, 0.0); - SolReflRecSurf(RecSurfNum).HitPtNormVec.dimension(MaxReflRays, MaxRecPts, zero3); - SolReflRecSurf(RecSurfNum).PossibleObsSurfNums.dimension(TotSurfaces, 0); + for (RecSurfNum = 1; RecSurfNum <= state.dataSolarReflectionManager->TotSolReflRecSurf; ++RecSurfNum) { + state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).NormVec = 0.0; + state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).RecPt.dimension(MaxRecPts, zero3); + state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).RayVec.dimension(MaxReflRays, zero3); + state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).CosIncAngRay.dimension(MaxReflRays, 0.0); + state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).dOmegaRay.dimension(MaxReflRays, 0.0); + state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).HitPt.dimension(MaxReflRays, MaxRecPts, zero3); + state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).HitPtSurfNum.dimension(MaxReflRays, MaxRecPts, 0.0); + state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).HitPtSolRefl.dimension(MaxReflRays, MaxRecPts, 0.0); + state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).RecPtHitPtDis.dimension(MaxReflRays, MaxRecPts, 0.0); + state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).HitPtNormVec.dimension(MaxReflRays, MaxRecPts, zero3); + state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).PossibleObsSurfNums.dimension(TotSurfaces, 0); } - for (RecSurfNum = 1; RecSurfNum <= TotSolReflRecSurf; ++RecSurfNum) { - SurfNum = SolReflRecSurf(RecSurfNum).SurfNum; + for (RecSurfNum = 1; RecSurfNum <= state.dataSolarReflectionManager->TotSolReflRecSurf; ++RecSurfNum) { + SurfNum = state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).SurfNum; // Outward norm to receiving surface - SolReflRecSurf(RecSurfNum).NormVec = Surface(SurfNum).OutNormVec; + state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).NormVec = Surface(SurfNum).OutNormVec; RecVec = Surface(SurfNum).Vertex(1); // Loop over all surfaces and find those that can be obstructing surfaces for this receiving surf - SolReflRecSurf(RecSurfNum).NumPossibleObs = 0; + state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).NumPossibleObs = 0; for (ObsSurfNum = 1; ObsSurfNum <= TotSurfaces; ++ObsSurfNum) { // Exclude the receiving surface itself and its base surface (if it has one) if (ObsSurfNum == SurfNum || ObsSurfNum == Surface(SurfNum).BaseSurf) continue; @@ -321,7 +302,7 @@ namespace SolarReflectionManager { ObsBehindRec = true; for (loop = 1; loop <= Surface(ObsSurfNum).Sides; ++loop) { ObsVec = Surface(ObsSurfNum).Vertex(loop); - DotProd = dot(SolReflRecSurf(RecSurfNum).NormVec, ObsVec - RecVec); + DotProd = dot(state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).NormVec, ObsVec - RecVec); // CR8251 IF(DotProd > 0.01d0) THEN ! This obstructing-surface vertex is not behind receiving surface if (DotProd > 1.0e-6) { // This obstructing-surface vertex is not behind receiving surface ObsBehindRec = false; @@ -339,7 +320,7 @@ namespace SolarReflectionManager { for (loopA = 1; loopA <= Surface(SurfNum).Sides; ++loopA) { for (loopB = 1; loopB <= Surface(ObsSurfNum).Sides; ++loopB) { VecAB = (Surface(ObsSurfNum).Vertex(loopB) - Surface(SurfNum).Vertex(loopA)); - if (dot(VecAB, SolReflRecSurf(RecSurfNum).NormVec) > 0.0 && dot(VecAB, Surface(ObsSurfNum).OutNormVec) < 0.0) { + if (dot(VecAB, state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).NormVec) > 0.0 && dot(VecAB, Surface(ObsSurfNum).OutNormVec) < 0.0) { ObsHasView = true; break; } @@ -350,16 +331,16 @@ namespace SolarReflectionManager { } // This is a possible obstructing surface for this receiving surface - ++SolReflRecSurf(RecSurfNum).NumPossibleObs; - SolReflRecSurf(RecSurfNum).PossibleObsSurfNums(SolReflRecSurf(RecSurfNum).NumPossibleObs) = ObsSurfNum; + ++state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).NumPossibleObs; + state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).PossibleObsSurfNums(state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).NumPossibleObs) = ObsSurfNum; } // Get coordinates of receiving points on this receiving surface. The number of receiving points // is equal to the number of surface vertices (3 or higher). - NumRecPts = SolReflRecSurf(RecSurfNum).NumRecPts; + NumRecPts = state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).NumRecPts; for (J = 1; J <= NumRecPts; ++J) { - SolReflRecSurf(RecSurfNum).RecPt(J) = 0.0; + state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).RecPt(J) = 0.0; for (K = 1; K <= NumRecPts; ++K) { if (NumRecPts == 3) { // Receiving surface is a triangle VertexWt = 0.2; @@ -368,9 +349,9 @@ namespace SolarReflectionManager { VertexWt = 1.0 / (2.0 * NumRecPts); if (K == J) VertexWt = (NumRecPts + 1.0) / (2.0 * NumRecPts); } - SolReflRecSurf(RecSurfNum).RecPt(J).x += VertexWt * Surface(SurfNum).Vertex(K).x; - SolReflRecSurf(RecSurfNum).RecPt(J).y += VertexWt * Surface(SurfNum).Vertex(K).y; - SolReflRecSurf(RecSurfNum).RecPt(J).z += VertexWt * Surface(SurfNum).Vertex(K).z; + state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).RecPt(J).x += VertexWt * Surface(SurfNum).Vertex(K).x; + state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).RecPt(J).y += VertexWt * Surface(SurfNum).Vertex(K).y; + state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).RecPt(J).z += VertexWt * Surface(SurfNum).Vertex(K).z; } } @@ -381,18 +362,18 @@ namespace SolarReflectionManager { // azimuth Theta and create ray unit vector at each Phi,Theta pair in front of the surface. // Phi = 0 at the horizon; Phi = Pi/2 at the zenith - PhiSurf = std::asin(SolReflRecSurf(RecSurfNum).NormVec.z); + PhiSurf = std::asin(state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).NormVec.z); Real64 const tan_PhiSurf = std::tan(PhiSurf); Real64 const sin_PhiSurf = std::sin(PhiSurf); Real64 const cos_PhiSurf = std::cos(PhiSurf); - if (std::abs(SolReflRecSurf(RecSurfNum).NormVec.x) > 1.0e-5 || std::abs(SolReflRecSurf(RecSurfNum).NormVec.y) > 1.0e-5) { - ThetaSurf = std::atan2(SolReflRecSurf(RecSurfNum).NormVec.y, SolReflRecSurf(RecSurfNum).NormVec.x); + if (std::abs(state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).NormVec.x) > 1.0e-5 || std::abs(state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).NormVec.y) > 1.0e-5) { + ThetaSurf = std::atan2(state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).NormVec.y, state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).NormVec.x); } else { ThetaSurf = 0.0; } - SolReflRecSurf(RecSurfNum).PhiNormVec = PhiSurf; - SolReflRecSurf(RecSurfNum).ThetaNormVec = ThetaSurf; + state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).PhiNormVec = PhiSurf; + state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).ThetaNormVec = ThetaSurf; PhiMin = max(-DataGlobalConstants::PiOvr2(), PhiSurf - DataGlobalConstants::PiOvr2()); PhiMax = min(DataGlobalConstants::PiOvr2(), PhiSurf + DataGlobalConstants::PiOvr2()); DPhi = (PhiMax - PhiMin) / AltAngStepsForSolReflCalc; @@ -439,13 +420,13 @@ namespace SolarReflectionManager { CosIncAngRay = SPhi * sin_PhiSurf + CPhi * cos_PhiSurf * std::cos(Theta - ThetaSurf); if (CosIncAngRay < 0.0) continue; // Ray is behind receiving surface (although there shouldn't be any) ++RayNum; - SolReflRecSurf(RecSurfNum).RayVec(RayNum) = URay; - SolReflRecSurf(RecSurfNum).CosIncAngRay(RayNum) = CosIncAngRay; - SolReflRecSurf(RecSurfNum).dOmegaRay(RayNum) = dOmega; + state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).RayVec(RayNum) = URay; + state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).CosIncAngRay(RayNum) = CosIncAngRay; + state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).dOmegaRay(RayNum) = dOmega; } // End of azimuth loop } // End of altitude loop - SolReflRecSurf(RecSurfNum).NumReflRays = RayNum; + state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).NumReflRays = RayNum; } // End of loop over receiving surfaces @@ -453,11 +434,11 @@ namespace SolarReflectionManager { // (hit point = point that ray intersects nearest obstruction, or, if ray is downgoing and hits no // obstructions, point that ray intersects ground plane). - for (RecSurfNum = 1; RecSurfNum <= TotSolReflRecSurf; ++RecSurfNum) { - SurfNum = SolReflRecSurf(RecSurfNum).SurfNum; - for (RecPtNum = 1; RecPtNum <= SolReflRecSurf(RecSurfNum).NumRecPts; ++RecPtNum) { - RecPt = SolReflRecSurf(RecSurfNum).RecPt(RecPtNum); - for (RayNum = 1; RayNum <= SolReflRecSurf(RecSurfNum).NumReflRays; ++RayNum) { + for (RecSurfNum = 1; RecSurfNum <= state.dataSolarReflectionManager->TotSolReflRecSurf; ++RecSurfNum) { + SurfNum = state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).SurfNum; + for (RecPtNum = 1; RecPtNum <= state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).NumRecPts; ++RecPtNum) { + RecPt = state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).RecPt(RecPtNum); + for (RayNum = 1; RayNum <= state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).NumReflRays; ++RayNum) { // Loop over possible obstructions. If ray hits one or more obstructions get hit point on closest obstruction. // If ray hits no obstructions and is going upward set HitPointSurfNum = 0. // If ray hits no obstructions and is going downward set HitPointSurfNum = -1 and get hit point on ground. @@ -465,10 +446,10 @@ namespace SolarReflectionManager { NearestHitSurfNum = 0; NearestHitDistance = 1.0e+8; ObsSurfNumToSkip = 0; - RayVec = SolReflRecSurf(RecSurfNum).RayVec(RayNum); - for (loop1 = 1; loop1 <= SolReflRecSurf(RecSurfNum).NumPossibleObs; ++loop1) { + RayVec = state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).RayVec(RayNum); + for (loop1 = 1; loop1 <= state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).NumPossibleObs; ++loop1) { // Surface number of this obstruction - ObsSurfNum = SolReflRecSurf(RecSurfNum).PossibleObsSurfNums(loop1); + ObsSurfNum = state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).PossibleObsSurfNums(loop1); // If a window was hit previously (see below), ObsSurfNumToSkip was set to the window's base surface in order // to remove that surface from consideration as a hit surface for this ray if (ObsSurfNum == ObsSurfNumToSkip) continue; @@ -507,9 +488,9 @@ namespace SolarReflectionManager { if (TotObstructionsHit > 0) { // One or more obstructions were hit by this ray - SolReflRecSurf(RecSurfNum).HitPtSurfNum(RayNum, RecPtNum) = NearestHitSurfNum; - SolReflRecSurf(RecSurfNum).RecPtHitPtDis(RayNum, RecPtNum) = NearestHitDistance; - SolReflRecSurf(RecSurfNum).HitPt(RayNum, RecPtNum) = NearestHitPt; + state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).HitPtSurfNum(RayNum, RecPtNum) = NearestHitSurfNum; + state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).RecPtHitPtDis(RayNum, RecPtNum) = NearestHitDistance; + state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).HitPt(RayNum, RecPtNum) = NearestHitPt; // For hit surface, calculate unit normal vector pointing into the hemisphere // containing the receiving point Vec1 = (Surface(NearestHitSurfNum).Vertex(1) - Surface(NearestHitSurfNum).Vertex(3)); @@ -517,29 +498,29 @@ namespace SolarReflectionManager { VNorm = cross(Vec1, Vec2); VNorm.normalize(); // Do Handle magnitude==0 if (dot(VNorm, -RayVec) < 0.0) VNorm = -VNorm; - SolReflRecSurf(RecSurfNum).HitPtNormVec(RayNum, RecPtNum) = VNorm; + state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).HitPtNormVec(RayNum, RecPtNum) = VNorm; // Get solar and visible beam-to-diffuse reflectance at nearest hit point ObsConstrNum = Surface(NearestHitSurfNum).Construction; if (ObsConstrNum > 0) { // Exterior building surface is nearest hit if (!state.dataConstruction->Construct(ObsConstrNum).TypeIsWindow) { // Obstruction is not a window, i.e., is an opaque surface - SolReflRecSurf(RecSurfNum).HitPtSolRefl(RayNum, RecPtNum) = 1.0 - state.dataConstruction->Construct(ObsConstrNum).OutsideAbsorpSolar; + state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).HitPtSolRefl(RayNum, RecPtNum) = 1.0 - state.dataConstruction->Construct(ObsConstrNum).OutsideAbsorpSolar; } else { // Obstruction is a window. Assume it is bare so that there is no beam-to-diffuse reflection // (beam-to-beam reflection is calculated in subroutine CalcBeamSolSpecularReflFactors). - SolReflRecSurf(RecSurfNum).HitPtSolRefl(RayNum, RecPtNum) = 0.0; + state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).HitPtSolRefl(RayNum, RecPtNum) = 0.0; } } else { // Shading surface is nearest hit - SolReflRecSurf(RecSurfNum).HitPtSolRefl(RayNum, RecPtNum) = Surface(NearestHitSurfNum).ShadowSurfDiffuseSolRefl; + state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).HitPtSolRefl(RayNum, RecPtNum) = Surface(NearestHitSurfNum).ShadowSurfDiffuseSolRefl; } } else { // No obstructions were hit by this ray - SolReflRecSurf(RecSurfNum).HitPtSurfNum(RayNum, RecPtNum) = 0; + state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).HitPtSurfNum(RayNum, RecPtNum) = 0; // If ray is going downward find the hit point on the ground plane if the receiving point // is above ground level; note that GroundLevelZ is <= 0.0 - if (RayVec(3) < 0.0 && SolReflRecSurf(RecSurfNum).RecPt(RecPtNum).z > GroundLevelZ) { + if (RayVec(3) < 0.0 && state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).RecPt(RecPtNum).z > GroundLevelZ) { // Ray hits ground Alfa = std::acos(-RayVec.z); Beta = std::atan2(RayVec.y, RayVec.x); @@ -547,11 +528,11 @@ namespace SolarReflectionManager { GroundHitPt.z = GroundLevelZ; GroundHitPt.x = RecPt.x + HorDis * std::cos(Beta); GroundHitPt.y = RecPt.y + HorDis * std::sin(Beta); - SolReflRecSurf(RecSurfNum).HitPt(RayNum, RecPtNum) = GroundHitPt; - SolReflRecSurf(RecSurfNum).HitPtSurfNum(RayNum, RecPtNum) = -1; - SolReflRecSurf(RecSurfNum).RecPtHitPtDis(RayNum, RecPtNum) = (RecPt(3) - GroundLevelZ) / (-RayVec(3)); - SolReflRecSurf(RecSurfNum).HitPtSolRefl(RayNum, RecPtNum) = GndReflectance; - SolReflRecSurf(RecSurfNum).HitPtNormVec(RayNum, RecPtNum) = unit_z; + state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).HitPt(RayNum, RecPtNum) = GroundHitPt; + state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).HitPtSurfNum(RayNum, RecPtNum) = -1; + state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).RecPtHitPtDis(RayNum, RecPtNum) = (RecPt(3) - GroundLevelZ) / (-RayVec(3)); + state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).HitPtSolRefl(RayNum, RecPtNum) = GndReflectance; + state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).HitPtNormVec(RayNum, RecPtNum) = unit_z; } // End of check if ray hits ground } // End of check if obstruction hit } // End of RayNum loop @@ -561,7 +542,7 @@ namespace SolarReflectionManager { //===================================================================================================== - void CalcBeamSolDiffuseReflFactors() + void CalcBeamSolDiffuseReflFactors(EnergyPlusData &state) { // SUBROUTINE INFORMATION: @@ -576,23 +557,11 @@ namespace SolarReflectionManager { // METHODOLOGY EMPLOYED: call worker routine depending on solar calculation method - // REFERENCES: na - - // USE STATEMENTS: na - // Using/Aliasing using DataGlobals::HourOfDay; using DataSystemVariables::DetailedSolarTimestepIntegration; - // Locals - // SUBROUTINE PARAMETER DEFINITIONS: na - // INTERFACE BLOCK SPECIFICATIONS: na - // DERIVED TYPE DEFINITIONS: na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: static int IHr(0); // Hour number - // FLOW: - if (!DetailedSolarTimestepIntegration) { if (BeginSimFlag) { DisplayString("Calculating Beam-to-Diffuse Exterior Solar Reflection Factors"); @@ -602,16 +571,16 @@ namespace SolarReflectionManager { ReflFacBmToDiffSolObs = 0.0; ReflFacBmToDiffSolGnd = 0.0; for (IHr = 1; IHr <= 24; ++IHr) { - FigureBeamSolDiffuseReflFactors(IHr); + FigureBeamSolDiffuseReflFactors(state, IHr); } // End of IHr loop } else { // timestep integrated solar, use current hour of day ReflFacBmToDiffSolObs(HourOfDay, {1, TotSurfaces}) = 0.0; ReflFacBmToDiffSolGnd(HourOfDay, {1, TotSurfaces}) = 0.0; - FigureBeamSolDiffuseReflFactors(HourOfDay); + FigureBeamSolDiffuseReflFactors(state, HourOfDay); } } - void FigureBeamSolDiffuseReflFactors(int const iHour) + void FigureBeamSolDiffuseReflFactors(EnergyPlusData &state, int const iHour) { // SUBROUTINE INFORMATION: @@ -624,28 +593,6 @@ namespace SolarReflectionManager { // Calculates factors for irradiance on exterior heat transfer surfaces due to // beam-to-diffuse solar reflection from obstructions and ground. - // METHODOLOGY EMPLOYED: - // - - // REFERENCES: - // na - - // USE STATEMENTS: - // na - - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS: - // na - - // DERIVED TYPE DEFINITIONS: - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: static Vector3 SunVec(0.0); // Unit vector to sun static int RecSurfNum(0); // Receiving surface number static int SurfNum(0); // Heat transfer surface number corresponding to RecSurfNum @@ -681,15 +628,15 @@ namespace SolarReflectionManager { SunVec = SUNCOSHR(iHour, {1, 3}); // loop through each surface that can receive beam solar reflected as diffuse solar from other surfaces - for (RecSurfNum = 1; RecSurfNum <= TotSolReflRecSurf; ++RecSurfNum) { - SurfNum = SolReflRecSurf(RecSurfNum).SurfNum; + for (RecSurfNum = 1; RecSurfNum <= state.dataSolarReflectionManager->TotSolReflRecSurf; ++RecSurfNum) { + SurfNum = state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).SurfNum; - for (RecPtNum = 1; RecPtNum <= SolReflRecSurf(RecSurfNum).NumRecPts; ++RecPtNum) { + for (RecPtNum = 1; RecPtNum <= state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).NumRecPts; ++RecPtNum) { ReflBmToDiffSolObs(RecPtNum) = 0.0; ReflBmToDiffSolGnd(RecPtNum) = 0.0; - for (RayNum = 1; RayNum <= SolReflRecSurf(RecSurfNum).NumReflRays; ++RayNum) { - HitPtSurfNum = SolReflRecSurf(RecSurfNum).HitPtSurfNum(RayNum, RecPtNum); + for (RayNum = 1; RayNum <= state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).NumReflRays; ++RayNum) { + HitPtSurfNum = state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).HitPtSurfNum(RayNum, RecPtNum); // Skip rays that do not hit an obstruction or ground. // (Note that if a downgoing ray does not hit an obstruction it will have HitPtSurfNum = 0 @@ -732,10 +679,10 @@ namespace SolarReflectionManager { } // Does an obstruction block the vector from this ray's hit point to the sun? - OriginThisRay = SolReflRecSurf(RecSurfNum).HitPt(RayNum, RecPtNum); + OriginThisRay = state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).HitPt(RayNum, RecPtNum); // Note: if sun is in back of hit surface relative to receiving point, CosIncBmAtHitPt will be < 0 - CosIncBmAtHitPt = dot(SolReflRecSurf(RecSurfNum).HitPtNormVec(RayNum, RecPtNum), SunVec); + CosIncBmAtHitPt = dot(state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).HitPtNormVec(RayNum, RecPtNum), SunVec); if (CosIncBmAtHitPt <= 0.0) continue; // CR 7872 - TH 4/6/2010. The shading surfaces should point to the receiveing heat transfer surface @@ -799,20 +746,20 @@ namespace SolarReflectionManager { // and use of MAX in following gives zero beam solar reflecting at hit point. // BmReflSolRadiance = MAX(0.0d0,CosIncBmAtHitPt)*SolReflRecSurf(RecSurfNum)%HitPtSolRefl(RecPtNum,RayNum) - BmReflSolRadiance = CosIncBmAtHitPt * SolReflRecSurf(RecSurfNum).HitPtSolRefl(RayNum, RecPtNum); + BmReflSolRadiance = CosIncBmAtHitPt * state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).HitPtSolRefl(RayNum, RecPtNum); if (BmReflSolRadiance > 0.0) { // Contribution to reflection factor from this hit point if (HitPtSurfNum > 0) { // Ray hits an obstruction - dReflBeamToDiffSol = BmReflSolRadiance * SolReflRecSurf(RecSurfNum).dOmegaRay(RayNum) * - SolReflRecSurf(RecSurfNum).CosIncAngRay(RayNum) / DataGlobalConstants::Pi(); + dReflBeamToDiffSol = BmReflSolRadiance * state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).dOmegaRay(RayNum) * + state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).CosIncAngRay(RayNum) / DataGlobalConstants::Pi(); ReflBmToDiffSolObs(RecPtNum) += dReflBeamToDiffSol; } else { // Ray hits ground (in this case we do not multiply by BmReflSolRadiance since // ground reflectance and cos of incidence angle of sun on // ground is taken into account later when ReflFacBmToDiffSolGnd is used) - dReflBeamToDiffSol = SolReflRecSurf(RecSurfNum).dOmegaRay(RayNum) * SolReflRecSurf(RecSurfNum).CosIncAngRay(RayNum) / DataGlobalConstants::Pi(); + dReflBeamToDiffSol = state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).dOmegaRay(RayNum) * state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).CosIncAngRay(RayNum) / DataGlobalConstants::Pi(); ReflBmToDiffSolGnd(RecPtNum) += dReflBeamToDiffSol; } } @@ -822,7 +769,7 @@ namespace SolarReflectionManager { // Average over receiving points ReflFacBmToDiffSolObs(iHour, SurfNum) = 0.0; ReflFacBmToDiffSolGnd(iHour, SurfNum) = 0.0; - NumRecPts = SolReflRecSurf(RecSurfNum).NumRecPts; + NumRecPts = state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).NumRecPts; for (RecPtNum = 1; RecPtNum <= NumRecPts; ++RecPtNum) { ReflFacBmToDiffSolObs(iHour, SurfNum) += ReflBmToDiffSolObs(RecPtNum); ReflFacBmToDiffSolGnd(iHour, SurfNum) += ReflBmToDiffSolGnd(RecPtNum); @@ -963,15 +910,15 @@ namespace SolarReflectionManager { // Unit vector to sun SunVec = SUNCOSHR(iHour, {1, 3}); - for (int RecSurfNum = 1; RecSurfNum <= TotSolReflRecSurf; ++RecSurfNum) { - int const SurfNum = SolReflRecSurf(RecSurfNum).SurfNum; // Heat transfer surface number corresponding to RecSurfNum - if (SolReflRecSurf(RecSurfNum).NumPossibleObs > 0) { + for (int RecSurfNum = 1; RecSurfNum <= state.dataSolarReflectionManager->TotSolReflRecSurf; ++RecSurfNum) { + int const SurfNum = state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).SurfNum; // Heat transfer surface number corresponding to RecSurfNum + if (state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).NumPossibleObs > 0) { ReflBmToBmSolObs = 0.0; ReflFacTimesCosIncSum = 0.0; - int const NumRecPts = SolReflRecSurf(RecSurfNum).NumRecPts; + int const NumRecPts = state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).NumRecPts; // Find possible reflecting surfaces for this receiving surface - for (int loop = 1, loop_end = SolReflRecSurf(RecSurfNum).NumPossibleObs; loop <= loop_end; ++loop) { - int const ReflSurfNum = SolReflRecSurf(RecSurfNum).PossibleObsSurfNums(loop); // Reflecting surface number + for (int loop = 1, loop_end = state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).NumPossibleObs; loop <= loop_end; ++loop) { + int const ReflSurfNum = state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).PossibleObsSurfNums(loop); // Reflecting surface number // Keep windows; keep shading surfaces with specular reflectance if ((Surface(ReflSurfNum).Class == SurfaceClass_Window && Surface(ReflSurfNum).ExtSolar) || (Surface(ReflSurfNum).ShadowSurfGlazingFrac > 0.0 && Surface(ReflSurfNum).ShadowingSurf)) { @@ -985,19 +932,19 @@ namespace SolarReflectionManager { // Get sun position unit vector for mirror image of sun in reflecting surface SunVecMir = SunVec - 2.0 * dot(SunVec, ReflNorm) * ReflNorm; // Angle of incidence of reflected beam on receiving surface - CosIncAngRec = dot(SolReflRecSurf(RecSurfNum).NormVec, SunVecMir); + CosIncAngRec = dot(state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).NormVec, SunVecMir); if (CosIncAngRec <= 0.0) continue; for (int RecPtNum = 1; RecPtNum <= NumRecPts; ++RecPtNum) { // See if ray from receiving point to mirrored sun hits the reflecting surface - RecPt = SolReflRecSurf(RecSurfNum).RecPt(RecPtNum); + RecPt = state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).RecPt(RecPtNum); PierceSurface(ReflSurfNum, RecPt, SunVecMir, HitPtRefl, hitRefl); if (hitRefl) { // Reflecting surface was hit ReflDistanceSq = distance_squared(HitPtRefl, RecPt); ReflDistance = std::sqrt(ReflDistanceSq); // Determine if ray from receiving point to hit point is obstructed hitObsRefl = false; - for (int loop2 = 1, loop2_end = SolReflRecSurf(RecSurfNum).NumPossibleObs; loop2 <= loop2_end; ++loop2) { - int const ObsSurfNum = SolReflRecSurf(RecSurfNum).PossibleObsSurfNums(loop2); + for (int loop2 = 1, loop2_end = state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).NumPossibleObs; loop2 <= loop2_end; ++loop2) { + int const ObsSurfNum = state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).PossibleObsSurfNums(loop2); if (ObsSurfNum == ReflSurfNum || ObsSurfNum == Surface(ReflSurfNum).BaseSurf) continue; PierceSurface(ObsSurfNum, RecPt, SunVecMir, ReflDistance, HitPtObs, hitObs); // ReflDistance cutoff added if (hitObs) { // => Could skip distance check (unless < vs <= ReflDistance really matters) @@ -1018,8 +965,8 @@ namespace SolarReflectionManager { .ShadowSurfRecSurfNum; // Receiving surface number corresponding to a reflecting surface number if (ReflSurfRecNum > 0) { // Loop over possible obstructions for this window - for (int loop2 = 1, loop2_end = SolReflRecSurf(ReflSurfRecNum).NumPossibleObs; loop2 <= loop2_end; ++loop2) { - int const ObsSurfNum = SolReflRecSurf(ReflSurfRecNum).PossibleObsSurfNums(loop2); + for (int loop2 = 1, loop2_end = state.dataSolarReflectionManager->SolReflRecSurf(ReflSurfRecNum).NumPossibleObs; loop2 <= loop2_end; ++loop2) { + int const ObsSurfNum = state.dataSolarReflectionManager->SolReflRecSurf(ReflSurfRecNum).PossibleObsSurfNums(loop2); PierceSurface(ObsSurfNum, HitPtRefl, SunVec, HitPtObs, hitObs); if (hitObs) break; } @@ -1055,7 +1002,7 @@ namespace SolarReflectionManager { POLYF(std::abs(CosIncAngRefl), state.dataConstruction->Construct(ConstrNumRefl).ReflSolBeamFrontCoef); } // Angle of incidence of reflected beam on receiving surface - CosIncAngRec = dot(SolReflRecSurf(RecSurfNum).NormVec, SunVecMir); + CosIncAngRec = dot(state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).NormVec, SunVecMir); ReflFac = SpecReflectance * CosIncAngRec; // Contribution to specular reflection factor ReflBmToBmSolObs(RecPtNum) += ReflFac; @@ -1083,7 +1030,7 @@ namespace SolarReflectionManager { //================================================================================================= - void CalcSkySolDiffuseReflFactors() + void CalcSkySolDiffuseReflFactors(EnergyPlusData &state) { // SUBROUTINE INFORMATION: @@ -1156,13 +1103,13 @@ namespace SolarReflectionManager { ReflSkySolObs = 0.0; ReflSkySolGnd = 0.0; - for (RecSurfNum = 1; RecSurfNum <= TotSolReflRecSurf; ++RecSurfNum) { - SurfNum = SolReflRecSurf(RecSurfNum).SurfNum; - for (RecPtNum = 1; RecPtNum <= SolReflRecSurf(RecSurfNum).NumRecPts; ++RecPtNum) { + for (RecSurfNum = 1; RecSurfNum <= state.dataSolarReflectionManager->TotSolReflRecSurf; ++RecSurfNum) { + SurfNum = state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).SurfNum; + for (RecPtNum = 1; RecPtNum <= state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).NumRecPts; ++RecPtNum) { ReflSkySolObs(RecPtNum) = 0.0; ReflSkySolGnd(RecPtNum) = 0.0; - for (RayNum = 1; RayNum <= SolReflRecSurf(RecSurfNum).NumReflRays; ++RayNum) { - HitPtSurfNum = SolReflRecSurf(RecSurfNum).HitPtSurfNum(RayNum, RecPtNum); + for (RayNum = 1; RayNum <= state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).NumReflRays; ++RayNum) { + HitPtSurfNum = state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).HitPtSurfNum(RayNum, RecPtNum); // Skip rays that do not hit an obstruction or ground. // (Note that if a downgoing ray does not hit an obstruction it will have HitPtSurfNum = 0 // if the receiving point is below ground level (see subr. InitSolReflRecSurf); this means @@ -1172,7 +1119,7 @@ namespace SolarReflectionManager { // not handle a sloped ground plane or a horizontal ground plane whose level is different // from one side of the building to another.) if (HitPtSurfNum == 0) continue; // Ray hits sky or obstruction with receiving pt. below ground level - HitPtRefl = SolReflRecSurf(RecSurfNum).HitPt(RayNum, RecPtNum); + HitPtRefl = state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).HitPt(RayNum, RecPtNum); if (HitPtSurfNum > 0) { // Ray hits an obstruction // Skip hit points on daylighting shelves, from which solar reflection is separately calculated @@ -1183,7 +1130,7 @@ namespace SolarReflectionManager { // The following gets the correct side of a shading surface in order to get the right value // of DifShdgRatioIsoSky (the two sides can have different sky shadowing). if (Surface(HitPtSurfNum).ShadowingSurf) { - if (dot(SolReflRecSurf(RecSurfNum).RayVec(RayNum), Surface(HitPtSurfNum).OutNormVec) > 0.0) { + if (dot(state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).RayVec(RayNum), Surface(HitPtSurfNum).OutNormVec) > 0.0) { if (HitPtSurfNum + 1 < TotSurfaces) HitPtSurfNumX = HitPtSurfNum + 1; if (Surface(HitPtSurfNumX).Shelf > 0) continue; } @@ -1191,13 +1138,13 @@ namespace SolarReflectionManager { if (!DetailedSkyDiffuseAlgorithm || !ShadingTransmittanceVaries || SolarDistribution == MinimalShadowing) { SkyReflSolRadiance = Surface(HitPtSurfNumX).ViewFactorSky * DifShdgRatioIsoSky(HitPtSurfNumX) * - SolReflRecSurf(RecSurfNum).HitPtSolRefl(RayNum, RecPtNum); + state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).HitPtSolRefl(RayNum, RecPtNum); } else { SkyReflSolRadiance = Surface(HitPtSurfNumX).ViewFactorSky * DifShdgRatioIsoSkyHRTS(1, 1, HitPtSurfNumX) * - SolReflRecSurf(RecSurfNum).HitPtSolRefl(RayNum, RecPtNum); + state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).HitPtSolRefl(RayNum, RecPtNum); } dReflSkySol = - SkyReflSolRadiance * SolReflRecSurf(RecSurfNum).dOmegaRay(RayNum) * SolReflRecSurf(RecSurfNum).CosIncAngRay(RayNum) / DataGlobalConstants::Pi(); + SkyReflSolRadiance * state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).dOmegaRay(RayNum) * state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).CosIncAngRay(RayNum) / DataGlobalConstants::Pi(); ReflSkySolObs(RecPtNum) += dReflSkySol; } else { // Ray hits ground; @@ -1244,7 +1191,7 @@ namespace SolarReflectionManager { } // End of azimuth loop } // End of altitude loop ReflSkySolGnd(RecPtNum) += - dReflSkyGnd * SolReflRecSurf(RecSurfNum).dOmegaRay(RayNum) * SolReflRecSurf(RecSurfNum).CosIncAngRay(RayNum) / DataGlobalConstants::Pi(); + dReflSkyGnd * state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).dOmegaRay(RayNum) * state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).CosIncAngRay(RayNum) / DataGlobalConstants::Pi(); } // End of check if ray from receiving point hits obstruction or ground } // End of loop over rays from receiving point } // End of loop over receiving points @@ -1252,7 +1199,7 @@ namespace SolarReflectionManager { // Average over receiving points ReflFacSkySolObs(SurfNum) = 0.0; ReflFacSkySolGnd(SurfNum) = 0.0; - NumRecPts = SolReflRecSurf(RecSurfNum).NumRecPts; + NumRecPts = state.dataSolarReflectionManager->SolReflRecSurf(RecSurfNum).NumRecPts; for (RecPtNum = 1; RecPtNum <= NumRecPts; ++RecPtNum) { ReflFacSkySolObs(SurfNum) += ReflSkySolObs(RecPtNum); ReflFacSkySolGnd(SurfNum) += ReflSkySolGnd(RecPtNum); diff --git a/src/EnergyPlus/SolarReflectionManager.hh b/src/EnergyPlus/SolarReflectionManager.hh index be9c853c6e7..aebf8692bc8 100644 --- a/src/EnergyPlus/SolarReflectionManager.hh +++ b/src/EnergyPlus/SolarReflectionManager.hh @@ -65,22 +65,6 @@ struct EnergyPlusData; namespace SolarReflectionManager { - // Using/Aliasing - - // Data - // MODULE PARAMETER DEFINITIONS:na - - // DERIVED TYPE DEFINITIONS: - - // MODULE VARIABLE DECLARATIONS: - extern int TotSolReflRecSurf; // Total number of exterior surfaces that can receive reflected solar - extern int TotPhiReflRays; // Number of rays in altitude angle (-90 to 90 deg) for diffuse refl calc - extern int TotThetaReflRays; // Number of rays in azimuth angle (0 to 180 deg) for diffuse refl calc - - // SUBROUTINE SPECIFICATIONS FOR MODULE ExteriorSolarReflectionManager - - // Types - struct SolReflRecSurfData { // Members @@ -113,18 +97,13 @@ namespace SolarReflectionManager { } }; - // Object Data - extern Array1D SolReflRecSurf; - - // Functions - void InitSolReflRecSurf(EnergyPlusData &state); //===================================================================================================== - void CalcBeamSolDiffuseReflFactors(); + void CalcBeamSolDiffuseReflFactors(EnergyPlusData &state); - void FigureBeamSolDiffuseReflFactors(int const iHour); + void FigureBeamSolDiffuseReflFactors(EnergyPlusData &state, int const iHour); //================================================================================================= @@ -134,10 +113,25 @@ namespace SolarReflectionManager { //================================================================================================= - void CalcSkySolDiffuseReflFactors(); + void CalcSkySolDiffuseReflFactors(EnergyPlusData &state); } // namespace SolarReflectionManager +struct SolarReflectionManagerData : BaseGlobalStruct { + + int TotSolReflRecSurf = 0; // Total number of exterior surfaces that can receive reflected solar + int TotPhiReflRays = 0; // Number of rays in altitude angle (-90 to 90 deg) for diffuse refl calc + int TotThetaReflRays = 0; // Number of rays in azimuth angle (0 to 180 deg) for diffuse refl calc + + Array1D SolReflRecSurf; + + void clear_state() override + { + } + + // Default Constructor + SolarReflectionManagerData() = default; +}; } // namespace EnergyPlus #endif diff --git a/src/EnergyPlus/SolarShading.cc b/src/EnergyPlus/SolarShading.cc index 243d9e597ea..8ec979b103a 100644 --- a/src/EnergyPlus/SolarShading.cc +++ b/src/EnergyPlus/SolarShading.cc @@ -8750,9 +8750,9 @@ namespace SolarShading { // Calculate factors for solar reflection if (CalcSolRefl) { - CalcBeamSolDiffuseReflFactors(); + CalcBeamSolDiffuseReflFactors(state); CalcBeamSolSpecularReflFactors(state); - if (BeginSimFlag) CalcSkySolDiffuseReflFactors(); + if (BeginSimFlag) CalcSkySolDiffuseReflFactors(state); } // Calculate daylighting coefficients From 2ce42a9bb65475f9616ac47c10fd1be6d762a288 Mon Sep 17 00:00:00 2001 From: brianlball Date: Sat, 17 Oct 2020 15:57:36 -0600 Subject: [PATCH 7/8] remove extern std::unique_ptr os; // Shading file stream doesnt seem to be used --- src/EnergyPlus/SolarShading.hh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/EnergyPlus/SolarShading.hh b/src/EnergyPlus/SolarShading.hh index 794c1dd9786..6d58e0b52f2 100644 --- a/src/EnergyPlus/SolarShading.hh +++ b/src/EnergyPlus/SolarShading.hh @@ -80,10 +80,6 @@ namespace SolarShading { using DataBSDFWindow::BSDFWindowGeomDescr; using DataVectorTypes::Vector; - extern std::unique_ptr os; // Shading file stream - - // Types - struct SurfaceErrorTracking { // Members From 9d0c42f39f0f9701e7dbd0d12e2f2cd9ef7c0475 Mon Sep 17 00:00:00 2001 From: brianlball Date: Sat, 17 Oct 2020 17:01:37 -0600 Subject: [PATCH 8/8] convert SolarCollectors --- src/EnergyPlus/Data/CommonIncludes.hh | 1 + src/EnergyPlus/Data/EnergyPlusData.cc | 2 + src/EnergyPlus/Data/EnergyPlusData.hh | 2 + src/EnergyPlus/GeneralRoutines.cc | 7 +- src/EnergyPlus/SolarCollectors.cc | 333 ++++++++++++-------------- src/EnergyPlus/SolarCollectors.hh | 43 ++-- src/EnergyPlus/StateManagement.cc | 2 - src/EnergyPlus/WaterThermalTanks.cc | 8 +- 8 files changed, 196 insertions(+), 202 deletions(-) diff --git a/src/EnergyPlus/Data/CommonIncludes.hh b/src/EnergyPlus/Data/CommonIncludes.hh index 6dbce4b7895..cca462b50f5 100644 --- a/src/EnergyPlus/Data/CommonIncludes.hh +++ b/src/EnergyPlus/Data/CommonIncludes.hh @@ -82,6 +82,7 @@ #include #include #include +#include #include #include #include diff --git a/src/EnergyPlus/Data/EnergyPlusData.cc b/src/EnergyPlus/Data/EnergyPlusData.cc index 1d20b0c1584..bddd329f6a1 100644 --- a/src/EnergyPlus/Data/EnergyPlusData.cc +++ b/src/EnergyPlus/Data/EnergyPlusData.cc @@ -84,6 +84,7 @@ namespace EnergyPlus { this->dataGlobal = std::unique_ptr(new DataGlobal); this->dataPipes = std::unique_ptr(new PipesData); this->dataPlantChillers = std::unique_ptr(new PlantChillersData); + this->dataSolarCollectors = std::unique_ptr(new SolarCollectorsData); this->dataSolarReflectionManager = std::unique_ptr(new SolarReflectionManagerData); this->dataSolarShading = std::unique_ptr(new SolarShadingData); this->dataSplitterComponent = std::unique_ptr(new SplitterComponentData); @@ -151,6 +152,7 @@ namespace EnergyPlus { this->dataGlobal->clear_state(); this->dataPipes->clear_state(); this->dataPlantChillers->clear_state(); + this->dataSolarCollectors->clear_state(); this->dataSolarShading->clear_state(); this->dataSplitterComponent->clear_state(); this->dataSteamBaseboardRadiator->clear_state(); diff --git a/src/EnergyPlus/Data/EnergyPlusData.hh b/src/EnergyPlus/Data/EnergyPlusData.hh index 6f8dfc5ac48..d1a1e20e308 100644 --- a/src/EnergyPlus/Data/EnergyPlusData.hh +++ b/src/EnergyPlus/Data/EnergyPlusData.hh @@ -93,6 +93,7 @@ struct ExteriorEnergyUseData; struct FansData; struct PipesData; struct PlantChillersData; +struct SolarCollectorsData; struct SolarReflectionManagerData; struct SolarShadingData; struct SplitterComponentData; @@ -163,6 +164,7 @@ struct EnergyPlusData : BaseGlobalStruct { std::unique_ptr dataFans; std::unique_ptr dataPipes; std::unique_ptr dataPlantChillers; + std::unique_ptr dataSolarCollectors; std::unique_ptr dataSolarReflectionManager; std::unique_ptr dataSolarShading; std::unique_ptr dataSplitterComponent; diff --git a/src/EnergyPlus/GeneralRoutines.cc b/src/EnergyPlus/GeneralRoutines.cc index 1acffc824f8..db41e0bc22f 100644 --- a/src/EnergyPlus/GeneralRoutines.cc +++ b/src/EnergyPlus/GeneralRoutines.cc @@ -1047,7 +1047,6 @@ void CalcPassiveExteriorBaffleGap(EnergyPlusData &state, using Psychrometrics::PsyCpAirFnW; using Psychrometrics::PsyRhoAirFnPbTdbW; using Psychrometrics::PsyWFnTdbTwbPb; - using SolarCollectors::Collector; // Argument array dimensioning @@ -1173,12 +1172,12 @@ void CalcPassiveExteriorBaffleGap(EnergyPlusData &state, ICSULossbottom = 0.40; ICSWaterTemp = 20.0; } else { - if (!Collector.allocated()) { + if (!state.dataSolarCollectors->Collector.allocated()) { ICSULossbottom = 0.40; ICSWaterTemp = 20.0; } else { - ICSULossbottom = Collector(CollectorNum).UbLoss; - ICSWaterTemp = Collector(CollectorNum).TempOfWater; + ICSULossbottom = state.dataSolarCollectors->Collector(CollectorNum).UbLoss; + ICSWaterTemp = state.dataSolarCollectors->Collector(CollectorNum).TempOfWater; MyICSEnvrnFlag = false; } } diff --git a/src/EnergyPlus/SolarCollectors.cc b/src/EnergyPlus/SolarCollectors.cc index f538f0fd6ef..6d763d811d0 100644 --- a/src/EnergyPlus/SolarCollectors.cc +++ b/src/EnergyPlus/SolarCollectors.cc @@ -94,38 +94,15 @@ namespace SolarCollectors { static std::string const fluidNameWater("WATER"); - Array1D_bool CheckEquipName; - - // MODULE VARIABLE DECLARATIONS: - int NumOfCollectors(0); - int NumOfParameters(0); - bool GetInputFlag(true); - - Array1D Parameters; - Array1D Collector; - std::unordered_map UniqueParametersNames; - std::unordered_map UniqueCollectorNames; - - void clear_state() - { - NumOfCollectors = 0; - NumOfParameters = 0; - GetInputFlag = true; - Parameters.deallocate(); - Collector.deallocate(); - UniqueCollectorNames.clear(); - UniqueParametersNames.clear(); - } - PlantComponent *CollectorData::factory(EnergyPlusData &state, std::string const &objectName) { // Process the input data - if (GetInputFlag) { + if (state.dataSolarCollectors->GetInputFlag) { GetSolarCollectorInput(state); - GetInputFlag = false; + state.dataSolarCollectors->GetInputFlag = false; } // Now look for this particular object - for (auto &thisSC : Collector) { + for (auto &thisSC : state.dataSolarCollectors->Collector) { if (thisSC.Name == objectName) { return &thisSC; } @@ -200,11 +177,11 @@ namespace SolarCollectors { lAlphaBlanks.dimension(MaxAlphas, true); lNumericBlanks.dimension(MaxNumbers, true); - NumOfCollectors = NumFlatPlateUnits + NumOfICSUnits; - NumOfParameters = NumOfFlatPlateParam + NumOfICSParam; + state.dataSolarCollectors->NumOfCollectors = NumFlatPlateUnits + NumOfICSUnits; + state.dataSolarCollectors->NumOfParameters = NumOfFlatPlateParam + NumOfICSParam; - if (NumOfParameters > 0) { - Parameters.allocate(NumOfParameters); + if (state.dataSolarCollectors->NumOfParameters > 0) { + state.dataSolarCollectors->Parameters.allocate(state.dataSolarCollectors->NumOfParameters); CurrentModuleParamObject = "SolarCollectorPerformance:FlatPlate"; @@ -226,16 +203,16 @@ namespace SolarCollectors { // Collector module parameters name GlobalNames::VerifyUniqueInterObjectName( - UniqueParametersNames, DataIPShortCuts::cAlphaArgs(1), CurrentModuleObject, DataIPShortCuts::cAlphaFieldNames(1), ErrorsFound); - Parameters(ParametersNum).Name = DataIPShortCuts::cAlphaArgs(1); + state.dataSolarCollectors->UniqueParametersNames, DataIPShortCuts::cAlphaArgs(1), CurrentModuleObject, DataIPShortCuts::cAlphaFieldNames(1), ErrorsFound); + state.dataSolarCollectors->Parameters(ParametersNum).Name = DataIPShortCuts::cAlphaArgs(1); // NOTE: This values serves mainly as a reference. The area of the associated surface object is used in all calculations. - Parameters(ParametersNum).Area = DataIPShortCuts::rNumericArgs(1); + state.dataSolarCollectors->Parameters(ParametersNum).Area = DataIPShortCuts::rNumericArgs(1); { auto const SELECT_CASE_var(DataIPShortCuts::cAlphaArgs(2)); if (SELECT_CASE_var == "WATER") { - Parameters(ParametersNum).TestFluid = FluidEnum::WATER; + state.dataSolarCollectors->Parameters(ParametersNum).TestFluid = FluidEnum::WATER; // CASE('AIR') // Parameters(ParametersNum)%TestFluid = AIR } else { @@ -246,7 +223,7 @@ namespace SolarCollectors { } if (DataIPShortCuts::rNumericArgs(2) > 0.0) { - Parameters(ParametersNum).TestMassFlowRate = DataIPShortCuts::rNumericArgs(2) * Psychrometrics::RhoH2O(DataGlobalConstants::InitConvTemp()); + state.dataSolarCollectors->Parameters(ParametersNum).TestMassFlowRate = DataIPShortCuts::rNumericArgs(2) * Psychrometrics::RhoH2O(DataGlobalConstants::InitConvTemp()); } else { ShowSevereError(CurrentModuleParamObject + " = " + DataIPShortCuts::cAlphaArgs(1) + ": flow rate must be greater than zero for " + DataIPShortCuts::cNumericFieldNames(2)); @@ -256,11 +233,11 @@ namespace SolarCollectors { { auto const SELECT_CASE_var(DataIPShortCuts::cAlphaArgs(3)); if (SELECT_CASE_var == "INLET") { - Parameters(ParametersNum).TestType = TestTypeEnum::INLET; + state.dataSolarCollectors->Parameters(ParametersNum).TestType = TestTypeEnum::INLET; } else if (SELECT_CASE_var == "AVERAGE") { - Parameters(ParametersNum).TestType = TestTypeEnum::AVERAGE; + state.dataSolarCollectors->Parameters(ParametersNum).TestType = TestTypeEnum::AVERAGE; } else if (SELECT_CASE_var == "OUTLET") { - Parameters(ParametersNum).TestType = TestTypeEnum::OUTLET; + state.dataSolarCollectors->Parameters(ParametersNum).TestType = TestTypeEnum::OUTLET; } else { ShowSevereError(CurrentModuleParamObject + " = " + DataIPShortCuts::cAlphaArgs(1) + ": " + DataIPShortCuts::cAlphaArgs(3) + " is not supported for " + DataIPShortCuts::cAlphaFieldNames(3)); @@ -269,34 +246,34 @@ namespace SolarCollectors { } // Efficiency equation coefficients - Parameters(ParametersNum).eff0 = DataIPShortCuts::rNumericArgs(3); - Parameters(ParametersNum).eff1 = DataIPShortCuts::rNumericArgs(4); + state.dataSolarCollectors->Parameters(ParametersNum).eff0 = DataIPShortCuts::rNumericArgs(3); + state.dataSolarCollectors->Parameters(ParametersNum).eff1 = DataIPShortCuts::rNumericArgs(4); if (NumNumbers > 4) { - Parameters(ParametersNum).eff2 = DataIPShortCuts::rNumericArgs(5); + state.dataSolarCollectors->Parameters(ParametersNum).eff2 = DataIPShortCuts::rNumericArgs(5); } else { - Parameters(ParametersNum).eff2 = 0.0; + state.dataSolarCollectors->Parameters(ParametersNum).eff2 = 0.0; } // Incident angle modifier coefficients if (NumNumbers > 5) { - Parameters(ParametersNum).iam1 = DataIPShortCuts::rNumericArgs(6); + state.dataSolarCollectors->Parameters(ParametersNum).iam1 = DataIPShortCuts::rNumericArgs(6); } else { - Parameters(ParametersNum).iam1 = 0.0; + state.dataSolarCollectors->Parameters(ParametersNum).iam1 = 0.0; } if (NumNumbers > 6) { - Parameters(FlatPlateParamNum).iam2 = DataIPShortCuts::rNumericArgs(7); + state.dataSolarCollectors->Parameters(FlatPlateParamNum).iam2 = DataIPShortCuts::rNumericArgs(7); } else { - Parameters(ParametersNum).iam2 = 0.0; + state.dataSolarCollectors->Parameters(ParametersNum).iam2 = 0.0; } } // ParametersNum if (ErrorsFound) ShowFatalError("Errors in " + CurrentModuleParamObject + " input."); } - if (NumOfCollectors > 0) { - Collector.allocate(NumOfCollectors); + if (state.dataSolarCollectors->NumOfCollectors > 0) { + state.dataSolarCollectors->Collector.allocate(state.dataSolarCollectors->NumOfCollectors); CurrentModuleObject = "SolarCollector:FlatPlate:Water"; @@ -308,19 +285,19 @@ namespace SolarCollectors { state, CurrentModuleObject, CollectorNum, DataIPShortCuts::cAlphaArgs, NumAlphas, DataIPShortCuts::rNumericArgs, NumNumbers, IOStatus); // Collector name - GlobalNames::VerifyUniqueInterObjectName(UniqueCollectorNames, DataIPShortCuts::cAlphaArgs(1), CurrentModuleObject, ErrorsFound); - Collector(CollectorNum).Name = DataIPShortCuts::cAlphaArgs(1); - Collector(CollectorNum).TypeNum = DataPlant::TypeOf_SolarCollectorFlatPlate; // parameter assigned in DataPlant !DSU + GlobalNames::VerifyUniqueInterObjectName(state.dataSolarCollectors->UniqueCollectorNames, DataIPShortCuts::cAlphaArgs(1), CurrentModuleObject, ErrorsFound); + state.dataSolarCollectors->Collector(CollectorNum).Name = DataIPShortCuts::cAlphaArgs(1); + state.dataSolarCollectors->Collector(CollectorNum).TypeNum = DataPlant::TypeOf_SolarCollectorFlatPlate; // parameter assigned in DataPlant !DSU // Get parameters object - int ParametersNum = UtilityRoutines::FindItemInList(DataIPShortCuts::cAlphaArgs(2), Parameters); + int ParametersNum = UtilityRoutines::FindItemInList(DataIPShortCuts::cAlphaArgs(2), state.dataSolarCollectors->Parameters); if (ParametersNum == 0) { ShowSevereError(CurrentModuleObject + " = " + DataIPShortCuts::cAlphaArgs(1) + ": " + CurrentModuleParamObject + " object called " + DataIPShortCuts::cAlphaArgs(2) + " not found."); ErrorsFound = true; } else { - Collector(CollectorNum).Parameters = ParametersNum; + state.dataSolarCollectors->Collector(CollectorNum).Parameters = ParametersNum; } // Get surface object @@ -351,7 +328,7 @@ namespace SolarCollectors { // Check to make sure other solar collectors are not using the same surface // NOTE: Must search over all solar collector types for (int CollectorNum2 = 1; CollectorNum2 <= NumFlatPlateUnits; ++CollectorNum2) { - if (Collector(CollectorNum2).Surface == SurfNum) { + if (state.dataSolarCollectors->Collector(CollectorNum2).Surface == SurfNum) { ShowSevereError(CurrentModuleObject + " = " + DataIPShortCuts::cAlphaArgs(1) + ": Surface " + DataIPShortCuts::cAlphaArgs(3) + " is referenced by more than one " + CurrentModuleObject); ErrorsFound = true; @@ -359,19 +336,19 @@ namespace SolarCollectors { } } // CollectorNum2 - Collector(CollectorNum).Surface = SurfNum; + state.dataSolarCollectors->Collector(CollectorNum).Surface = SurfNum; } // Give warning if surface area and gross area do not match within tolerance - if (SurfNum > 0 && ParametersNum > 0 && Parameters(ParametersNum).Area > 0.0 && - std::abs(Parameters(ParametersNum).Area - DataSurfaces::Surface(SurfNum).Area) / DataSurfaces::Surface(SurfNum).Area > 0.01) { + if (SurfNum > 0 && ParametersNum > 0 && state.dataSolarCollectors->Parameters(ParametersNum).Area > 0.0 && + std::abs(state.dataSolarCollectors->Parameters(ParametersNum).Area - DataSurfaces::Surface(SurfNum).Area) / DataSurfaces::Surface(SurfNum).Area > 0.01) { ShowWarningError(CurrentModuleObject + " = " + DataIPShortCuts::cAlphaArgs(1) + ": Gross Area of solar collector parameters and surface object differ by more than 1%."); ShowContinueError("Area of surface object will be used in all calculations."); } - Collector(CollectorNum).InletNode = NodeInputManager::GetOnlySingleNode(state, DataIPShortCuts::cAlphaArgs(4), + state.dataSolarCollectors->Collector(CollectorNum).InletNode = NodeInputManager::GetOnlySingleNode(state, DataIPShortCuts::cAlphaArgs(4), ErrorsFound, CurrentModuleObject, DataIPShortCuts::cAlphaArgs(1), @@ -379,7 +356,7 @@ namespace SolarCollectors { DataLoopNode::NodeConnectionType_Inlet, 1, DataLoopNode::ObjectIsNotParent); - Collector(CollectorNum).OutletNode = NodeInputManager::GetOnlySingleNode(state, DataIPShortCuts::cAlphaArgs(5), + state.dataSolarCollectors->Collector(CollectorNum).OutletNode = NodeInputManager::GetOnlySingleNode(state, DataIPShortCuts::cAlphaArgs(5), ErrorsFound, CurrentModuleObject, DataIPShortCuts::cAlphaArgs(1), @@ -389,11 +366,11 @@ namespace SolarCollectors { DataLoopNode::ObjectIsNotParent); if (NumNumbers > 0) { - Collector(CollectorNum).VolFlowRateMax = + state.dataSolarCollectors->Collector(CollectorNum).VolFlowRateMax = DataIPShortCuts::rNumericArgs(1); // Max volumetric flow rate used for plant sizing calculation } else { - Collector(CollectorNum).VolFlowRateMax = 0.0; // Max vol flow rate is not specified; no flow for plant sizing calculation - Collector(CollectorNum).MassFlowRateMax = 999999.9; // But...set a very high value so that it demands as much as possible + state.dataSolarCollectors->Collector(CollectorNum).VolFlowRateMax = 0.0; // Max vol flow rate is not specified; no flow for plant sizing calculation + state.dataSolarCollectors->Collector(CollectorNum).MassFlowRateMax = 999999.9; // But...set a very high value so that it demands as much as possible } BranchNodeConnections::TestCompSet(CurrentModuleObject, @@ -426,19 +403,19 @@ namespace SolarCollectors { // Collector module parameters name GlobalNames::VerifyUniqueInterObjectName( - UniqueParametersNames, DataIPShortCuts::cAlphaArgs(1), CurrentModuleObject, DataIPShortCuts::cAlphaFieldNames(1), ErrorsFound); - Parameters(ParametersNum).Name = DataIPShortCuts::cAlphaArgs(1); + state.dataSolarCollectors->UniqueParametersNames, DataIPShortCuts::cAlphaArgs(1), CurrentModuleObject, DataIPShortCuts::cAlphaFieldNames(1), ErrorsFound); + state.dataSolarCollectors->Parameters(ParametersNum).Name = DataIPShortCuts::cAlphaArgs(1); // NOTE: currently the only available choice is RectangularTank. In the future progressive tube type will be // added if (UtilityRoutines::SameString(DataIPShortCuts::cAlphaArgs(2), "RectangularTank")) { - Parameters(ParametersNum).ICSType_Num = TankTypeEnum::ICSRectangularTank; + state.dataSolarCollectors->Parameters(ParametersNum).ICSType_Num = TankTypeEnum::ICSRectangularTank; } else { ShowSevereError(DataIPShortCuts::cAlphaFieldNames(2) + " not found=" + DataIPShortCuts::cAlphaArgs(2) + " in " + - CurrentModuleParamObject + " =" + Parameters(ParametersNum).Name); + CurrentModuleParamObject + " =" + state.dataSolarCollectors->Parameters(ParametersNum).Name); ErrorsFound = true; } // NOTE: This collector gross area is used in all the calculations. - Parameters(ParametersNum).Area = DataIPShortCuts::rNumericArgs(1); + state.dataSolarCollectors->Parameters(ParametersNum).Area = DataIPShortCuts::rNumericArgs(1); if (DataIPShortCuts::rNumericArgs(1) <= 0.0) { ShowSevereError(CurrentModuleParamObject + " = " + DataIPShortCuts::cAlphaArgs(1)); ShowContinueError("Illegal " + DataIPShortCuts::cNumericFieldNames(1) + " = " + @@ -446,7 +423,7 @@ namespace SolarCollectors { ShowContinueError(" Collector gross area must be always gretaer than zero."); ErrorsFound = true; } - Parameters(ParametersNum).Volume = DataIPShortCuts::rNumericArgs(2); + state.dataSolarCollectors->Parameters(ParametersNum).Volume = DataIPShortCuts::rNumericArgs(2); if (DataIPShortCuts::rNumericArgs(2) <= 0.0) { ShowSevereError(CurrentModuleParamObject + " = " + DataIPShortCuts::cAlphaArgs(1)); ShowContinueError("Illegal " + DataIPShortCuts::cNumericFieldNames(2) + " = " + @@ -455,39 +432,39 @@ namespace SolarCollectors { ErrorsFound = true; } // Note: this value is used to calculate the heat loss through the bottom and side of the collector - Parameters(ParametersNum).ULossBottom = DataIPShortCuts::rNumericArgs(3); - Parameters(ParametersNum).ULossSide = DataIPShortCuts::rNumericArgs(4); - Parameters(ParametersNum).AspectRatio = DataIPShortCuts::rNumericArgs(5); - Parameters(ParametersNum).SideHeight = DataIPShortCuts::rNumericArgs(6); - Parameters(ParametersNum).ThermalMass = DataIPShortCuts::rNumericArgs(7); - Parameters(ParametersNum).NumOfCovers = DataIPShortCuts::rNumericArgs(8); - Parameters(ParametersNum).CoverSpacing = DataIPShortCuts::rNumericArgs(9); - - if (Parameters(ParametersNum).NumOfCovers == 2) { + state.dataSolarCollectors->Parameters(ParametersNum).ULossBottom = DataIPShortCuts::rNumericArgs(3); + state.dataSolarCollectors->Parameters(ParametersNum).ULossSide = DataIPShortCuts::rNumericArgs(4); + state.dataSolarCollectors->Parameters(ParametersNum).AspectRatio = DataIPShortCuts::rNumericArgs(5); + state.dataSolarCollectors->Parameters(ParametersNum).SideHeight = DataIPShortCuts::rNumericArgs(6); + state.dataSolarCollectors->Parameters(ParametersNum).ThermalMass = DataIPShortCuts::rNumericArgs(7); + state.dataSolarCollectors->Parameters(ParametersNum).NumOfCovers = DataIPShortCuts::rNumericArgs(8); + state.dataSolarCollectors->Parameters(ParametersNum).CoverSpacing = DataIPShortCuts::rNumericArgs(9); + + if (state.dataSolarCollectors->Parameters(ParametersNum).NumOfCovers == 2) { // Outer cover refractive index - Parameters(ParametersNum).RefractiveIndex(1) = DataIPShortCuts::rNumericArgs(10); + state.dataSolarCollectors->Parameters(ParametersNum).RefractiveIndex(1) = DataIPShortCuts::rNumericArgs(10); // Outer cover extinction coefficient times thickness of the cover - Parameters(ParametersNum).ExtCoefTimesThickness(1) = DataIPShortCuts::rNumericArgs(11); + state.dataSolarCollectors->Parameters(ParametersNum).ExtCoefTimesThickness(1) = DataIPShortCuts::rNumericArgs(11); // Outer cover Emissivity - Parameters(ParametersNum).EmissOfCover(1) = DataIPShortCuts::rNumericArgs(12); + state.dataSolarCollectors->Parameters(ParametersNum).EmissOfCover(1) = DataIPShortCuts::rNumericArgs(12); if (!DataIPShortCuts::lNumericFieldBlanks(13) || !DataIPShortCuts::lNumericFieldBlanks(14) || !DataIPShortCuts::lNumericFieldBlanks(15)) { - Parameters(ParametersNum).RefractiveIndex(2) = DataIPShortCuts::rNumericArgs(13); - Parameters(ParametersNum).ExtCoefTimesThickness(2) = DataIPShortCuts::rNumericArgs(14); - Parameters(ParametersNum).EmissOfCover(2) = DataIPShortCuts::rNumericArgs(15); + state.dataSolarCollectors->Parameters(ParametersNum).RefractiveIndex(2) = DataIPShortCuts::rNumericArgs(13); + state.dataSolarCollectors->Parameters(ParametersNum).ExtCoefTimesThickness(2) = DataIPShortCuts::rNumericArgs(14); + state.dataSolarCollectors->Parameters(ParametersNum).EmissOfCover(2) = DataIPShortCuts::rNumericArgs(15); } else { ShowSevereError(CurrentModuleParamObject + " = " + DataIPShortCuts::cAlphaArgs(1)); ShowContinueError("Illegal input for one of the three inputs of the inner cover optical properties"); ErrorsFound = true; } - } else if (Parameters(ParametersNum).NumOfCovers == 1) { + } else if (state.dataSolarCollectors->Parameters(ParametersNum).NumOfCovers == 1) { // Outer cover refractive index - Parameters(ParametersNum).RefractiveIndex(1) = DataIPShortCuts::rNumericArgs(10); + state.dataSolarCollectors->Parameters(ParametersNum).RefractiveIndex(1) = DataIPShortCuts::rNumericArgs(10); // Outer cover extinction coefficient times thickness of the cover - Parameters(ParametersNum).ExtCoefTimesThickness(1) = DataIPShortCuts::rNumericArgs(11); + state.dataSolarCollectors->Parameters(ParametersNum).ExtCoefTimesThickness(1) = DataIPShortCuts::rNumericArgs(11); // Outer cover emissivity - Parameters(ParametersNum).EmissOfCover(1) = DataIPShortCuts::rNumericArgs(12); + state.dataSolarCollectors->Parameters(ParametersNum).EmissOfCover(1) = DataIPShortCuts::rNumericArgs(12); } else { ShowSevereError(CurrentModuleParamObject + " = " + DataIPShortCuts::cAlphaArgs(1)); ShowContinueError("Illegal " + DataIPShortCuts::cNumericFieldNames(8) + " = " + @@ -495,9 +472,9 @@ namespace SolarCollectors { ErrorsFound = true; } // Solar absorptance of the absorber plate - Parameters(ParametersNum).AbsorOfAbsPlate = DataIPShortCuts::rNumericArgs(16); + state.dataSolarCollectors->Parameters(ParametersNum).AbsorOfAbsPlate = DataIPShortCuts::rNumericArgs(16); // thermal emmissivity of the absorber plate - Parameters(ParametersNum).EmissOfAbsPlate = DataIPShortCuts::rNumericArgs(17); + state.dataSolarCollectors->Parameters(ParametersNum).EmissOfAbsPlate = DataIPShortCuts::rNumericArgs(17); } // end of ParametersNum @@ -524,35 +501,35 @@ namespace SolarCollectors { // Collector name GlobalNames::VerifyUniqueInterObjectName( - UniqueCollectorNames, DataIPShortCuts::cAlphaArgs(1), CurrentModuleObject, DataIPShortCuts::cAlphaFieldNames(1), ErrorsFound); - Collector(CollectorNum).Name = DataIPShortCuts::cAlphaArgs(1); - Collector(CollectorNum).TypeNum = DataPlant::TypeOf_SolarCollectorICS; // parameter assigned in DataPlant + state.dataSolarCollectors->UniqueCollectorNames, DataIPShortCuts::cAlphaArgs(1), CurrentModuleObject, DataIPShortCuts::cAlphaFieldNames(1), ErrorsFound); + state.dataSolarCollectors->Collector(CollectorNum).Name = DataIPShortCuts::cAlphaArgs(1); + state.dataSolarCollectors->Collector(CollectorNum).TypeNum = DataPlant::TypeOf_SolarCollectorICS; // parameter assigned in DataPlant - Collector(CollectorNum).InitICS = true; + state.dataSolarCollectors->Collector(CollectorNum).InitICS = true; // Get parameters object - int ParametersNum = UtilityRoutines::FindItemInList(DataIPShortCuts::cAlphaArgs(2), Parameters); + int ParametersNum = UtilityRoutines::FindItemInList(DataIPShortCuts::cAlphaArgs(2), state.dataSolarCollectors->Parameters); if (ParametersNum == 0) { ShowSevereError(CurrentModuleObject + " = " + DataIPShortCuts::cAlphaArgs(1) + ": " + CurrentModuleParamObject + " object called " + DataIPShortCuts::cAlphaArgs(2) + " not found."); ErrorsFound = true; } else { - Collector(CollectorNum).Parameters = ParametersNum; + state.dataSolarCollectors->Collector(CollectorNum).Parameters = ParametersNum; } if (ParametersNum > 0) { // Calculate constant collector parameters only once - Real64 Perimeter = 2.0 * std::sqrt(Parameters(ParametersNum).Area) * - (std::sqrt(Parameters(ParametersNum).AspectRatio) + 1.0 / std::sqrt(Parameters(ParametersNum).AspectRatio)); - Collector(CollectorNum).Length = std::sqrt(Parameters(ParametersNum).Area / Parameters(ParametersNum).AspectRatio); + Real64 Perimeter = 2.0 * std::sqrt(state.dataSolarCollectors->Parameters(ParametersNum).Area) * + (std::sqrt(state.dataSolarCollectors->Parameters(ParametersNum).AspectRatio) + 1.0 / std::sqrt(state.dataSolarCollectors->Parameters(ParametersNum).AspectRatio)); + state.dataSolarCollectors->Collector(CollectorNum).Length = std::sqrt(state.dataSolarCollectors->Parameters(ParametersNum).Area / state.dataSolarCollectors->Parameters(ParametersNum).AspectRatio); // calculate the collector side heat transfer area and loss coefficient - Collector(CollectorNum).ICSType_Num = Parameters(ParametersNum).ICSType_Num; - Collector(CollectorNum).Area = Parameters(ParametersNum).Area; - Collector(CollectorNum).Volume = Parameters(ParametersNum).Volume; - Collector(CollectorNum).SideArea = Perimeter * Parameters(ParametersNum).SideHeight; - Collector(CollectorNum).AreaRatio = Collector(CollectorNum).SideArea / Collector(CollectorNum).Area; + state.dataSolarCollectors->Collector(CollectorNum).ICSType_Num = state.dataSolarCollectors->Parameters(ParametersNum).ICSType_Num; + state.dataSolarCollectors->Collector(CollectorNum).Area = state.dataSolarCollectors->Parameters(ParametersNum).Area; + state.dataSolarCollectors->Collector(CollectorNum).Volume = state.dataSolarCollectors->Parameters(ParametersNum).Volume; + state.dataSolarCollectors->Collector(CollectorNum).SideArea = Perimeter * state.dataSolarCollectors->Parameters(ParametersNum).SideHeight; + state.dataSolarCollectors->Collector(CollectorNum).AreaRatio = state.dataSolarCollectors->Collector(CollectorNum).SideArea / state.dataSolarCollectors->Collector(CollectorNum).Area; } // Get surface object int SurfNum = UtilityRoutines::FindItemInList(DataIPShortCuts::cAlphaArgs(3), DataSurfaces::Surface); @@ -581,8 +558,8 @@ namespace SolarCollectors { // Check to make sure other solar collectors are not using the same surface // NOTE: Must search over all solar collector types - for (int CollectorNum2 = 1; CollectorNum2 <= NumOfCollectors; ++CollectorNum2) { - if (Collector(CollectorNum2).Surface == SurfNum) { + for (int CollectorNum2 = 1; CollectorNum2 <= state.dataSolarCollectors->NumOfCollectors; ++CollectorNum2) { + if (state.dataSolarCollectors->Collector(CollectorNum2).Surface == SurfNum) { ShowSevereError(CurrentModuleObject + " = " + DataIPShortCuts::cAlphaArgs(1) + ": Surface " + DataIPShortCuts::cAlphaArgs(3) + " is referenced by more than one " + CurrentModuleObject); ErrorsFound = true; @@ -590,12 +567,12 @@ namespace SolarCollectors { } } // ICSNum2 - Collector(CollectorNum).Surface = SurfNum; + state.dataSolarCollectors->Collector(CollectorNum).Surface = SurfNum; } // Give warning if surface area and gross area do not match within tolerance - if (SurfNum > 0 && ParametersNum > 0 && Parameters(ParametersNum).Area > 0.0 && - std::abs(Parameters(ParametersNum).Area - DataSurfaces::Surface(SurfNum).Area) / DataSurfaces::Surface(SurfNum).Area > 0.01) { + if (SurfNum > 0 && ParametersNum > 0 && state.dataSolarCollectors->Parameters(ParametersNum).Area > 0.0 && + std::abs(state.dataSolarCollectors->Parameters(ParametersNum).Area - DataSurfaces::Surface(SurfNum).Area) / DataSurfaces::Surface(SurfNum).Area > 0.01) { ShowWarningError(CurrentModuleObject + " = " + DataIPShortCuts::cAlphaArgs(1) + ": "); ShowContinueError("Gross area of solar collector parameters and surface object differ by more than 1%."); @@ -604,32 +581,32 @@ namespace SolarCollectors { ShowContinueError("surface is assumed to be fully shaded when it is not."); } - Collector(CollectorNum).BCType = DataIPShortCuts::cAlphaArgs(4); + state.dataSolarCollectors->Collector(CollectorNum).BCType = DataIPShortCuts::cAlphaArgs(4); if (UtilityRoutines::SameString(DataIPShortCuts::cAlphaArgs(4), "AmbientAir")) { - Collector(CollectorNum).OSCMName = ""; + state.dataSolarCollectors->Collector(CollectorNum).OSCMName = ""; } else if (UtilityRoutines::SameString(DataIPShortCuts::cAlphaArgs(4), "OtherSideConditionsModel")) { - Collector(CollectorNum).OSCMName = DataIPShortCuts::cAlphaArgs(5); - Collector(CollectorNum).OSCM_ON = true; - int Found = UtilityRoutines::FindItemInList(Collector(CollectorNum).OSCMName, DataSurfaces::OSCM); + state.dataSolarCollectors->Collector(CollectorNum).OSCMName = DataIPShortCuts::cAlphaArgs(5); + state.dataSolarCollectors->Collector(CollectorNum).OSCM_ON = true; + int Found = UtilityRoutines::FindItemInList(state.dataSolarCollectors->Collector(CollectorNum).OSCMName, DataSurfaces::OSCM); if (Found == 0) { - ShowSevereError(DataIPShortCuts::cAlphaFieldNames(5) + " not found=" + Collector(CollectorNum).OSCMName + " in " + - CurrentModuleObject + " =" + Collector(CollectorNum).Name); + ShowSevereError(DataIPShortCuts::cAlphaFieldNames(5) + " not found=" + state.dataSolarCollectors->Collector(CollectorNum).OSCMName + " in " + + CurrentModuleObject + " =" + state.dataSolarCollectors->Collector(CollectorNum).Name); ErrorsFound = true; } } else { - ShowSevereError(DataIPShortCuts::cAlphaFieldNames(5) + " not found=" + Collector(CollectorNum).BCType + " in " + - CurrentModuleObject + " =" + Collector(CollectorNum).Name); + ShowSevereError(DataIPShortCuts::cAlphaFieldNames(5) + " not found=" + state.dataSolarCollectors->Collector(CollectorNum).BCType + " in " + + CurrentModuleObject + " =" + state.dataSolarCollectors->Collector(CollectorNum).Name); ErrorsFound = true; } - if (Collector(CollectorNum).OSCM_ON) { + if (state.dataSolarCollectors->Collector(CollectorNum).OSCM_ON) { // get index of ventilated cavity object int VentCavIndex = 0; SolarCollectors::CollectorData::GetExtVentedCavityIndex(SurfNum, VentCavIndex); - Collector(CollectorNum).VentCavIndex = VentCavIndex; + state.dataSolarCollectors->Collector(CollectorNum).VentCavIndex = VentCavIndex; } - Collector(CollectorNum).InletNode = NodeInputManager::GetOnlySingleNode(state, DataIPShortCuts::cAlphaArgs(6), + state.dataSolarCollectors->Collector(CollectorNum).InletNode = NodeInputManager::GetOnlySingleNode(state, DataIPShortCuts::cAlphaArgs(6), ErrorsFound, CurrentModuleObject, DataIPShortCuts::cAlphaArgs(1), @@ -637,7 +614,7 @@ namespace SolarCollectors { DataLoopNode::NodeConnectionType_Inlet, 1, DataLoopNode::ObjectIsNotParent); - Collector(CollectorNum).OutletNode = NodeInputManager::GetOnlySingleNode(state, DataIPShortCuts::cAlphaArgs(7), + state.dataSolarCollectors->Collector(CollectorNum).OutletNode = NodeInputManager::GetOnlySingleNode(state, DataIPShortCuts::cAlphaArgs(7), ErrorsFound, CurrentModuleObject, DataIPShortCuts::cAlphaArgs(1), @@ -647,11 +624,11 @@ namespace SolarCollectors { DataLoopNode::ObjectIsNotParent); if (NumNumbers > 0) { - Collector(CollectorNum).VolFlowRateMax = + state.dataSolarCollectors->Collector(CollectorNum).VolFlowRateMax = DataIPShortCuts::rNumericArgs(1); // Max volumetric flow rate used for plant sizing calculation } else { - Collector(CollectorNum).VolFlowRateMax = 0.0; // Max vol flow rate is not specified; no flow for plant sizing calculation - Collector(CollectorNum).MassFlowRateMax = 999999.9; // But...set a very high value so that it demands as much as possible + state.dataSolarCollectors->Collector(CollectorNum).VolFlowRateMax = 0.0; // Max vol flow rate is not specified; no flow for plant sizing calculation + state.dataSolarCollectors->Collector(CollectorNum).MassFlowRateMax = 999999.9; // But...set a very high value so that it demands as much as possible } BranchNodeConnections::TestCompSet(CurrentModuleObject, @@ -664,8 +641,8 @@ namespace SolarCollectors { if (ErrorsFound) ShowFatalError("Errors in " + CurrentModuleObject + " input."); - if (NumOfCollectors > 0) { - CheckEquipName.dimension(NumOfCollectors, true); + if (state.dataSolarCollectors->NumOfCollectors > 0) { + state.dataSolarCollectors->CheckEquipName.dimension(state.dataSolarCollectors->NumOfCollectors, true); } } } @@ -883,30 +860,30 @@ namespace SolarCollectors { Real64 AbsCover1 = 0.0; Real64 AbsCover2 = 0.0; Real64 RefSysDiffuse = 0.0; - this->CalcTransRefAbsOfCover(Theta, TransSys, RefSys, AbsCover1, AbsCover2, true, RefSysDiffuse); + this->CalcTransRefAbsOfCover(state, Theta, TransSys, RefSys, AbsCover1, AbsCover2, true, RefSysDiffuse); this->RefDiffInnerCover = RefSysDiffuse; // transmittance-absorptance product normal incident: Theta = 0.0; - this->CalcTransRefAbsOfCover(Theta, TransSys, RefSys, AbsCover1, AbsCover2); - this->TauAlphaNormal = TransSys * SolarCollectors::Parameters(ParamNum).AbsorOfAbsPlate / - (1.0 - (1.0 - SolarCollectors::Parameters(ParamNum).AbsorOfAbsPlate) * this->RefDiffInnerCover); + this->CalcTransRefAbsOfCover(state, Theta, TransSys, RefSys, AbsCover1, AbsCover2); + this->TauAlphaNormal = TransSys * state.dataSolarCollectors->Parameters(ParamNum).AbsorOfAbsPlate / + (1.0 - (1.0 - state.dataSolarCollectors->Parameters(ParamNum).AbsorOfAbsPlate) * this->RefDiffInnerCover); // 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)) * DataGlobalConstants::DegToRadians(); - this->CalcTransRefAbsOfCover(Theta, TransSys, RefSys, AbsCover1, AbsCover2); - this->TauAlphaSkyDiffuse = TransSys * SolarCollectors::Parameters(ParamNum).AbsorOfAbsPlate / - (1.0 - (1.0 - SolarCollectors::Parameters(ParamNum).AbsorOfAbsPlate) * this->RefDiffInnerCover); + 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); this->CoversAbsSkyDiffuse(1) = AbsCover1; this->CoversAbsSkyDiffuse(2) = AbsCover2; // 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)) * DataGlobalConstants::DegToRadians(); - this->CalcTransRefAbsOfCover(Theta, TransSys, RefSys, AbsCover1, AbsCover2); - this->TauAlphaGndDiffuse = TransSys * SolarCollectors::Parameters(ParamNum).AbsorOfAbsPlate / - (1.0 - (1.0 - SolarCollectors::Parameters(ParamNum).AbsorOfAbsPlate) * this->RefDiffInnerCover); + 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); this->CoversAbsGndDiffuse(1) = AbsCover1; this->CoversAbsGndDiffuse(2) = AbsCover2; @@ -997,9 +974,9 @@ namespace SolarCollectors { // Equivalent incident angle of ground radiation (radians) Real64 ThetaGnd = (90.0 - 0.5788 * tilt + 0.002693 * pow_2(tilt)) * DataGlobalConstants::DegToRadians(); - incidentAngleModifier = (DataHeatBalance::SurfQRadSWOutIncidentBeam(SurfNum) * SolarCollectors::Parameters(ParamNum).IAM(ThetaBeam) + - DataHeatBalance::SurfQRadSWOutIncidentSkyDiffuse(SurfNum) * SolarCollectors::Parameters(ParamNum).IAM(ThetaSky) + - DataHeatBalance::SurfQRadSWOutIncidentGndDiffuse(SurfNum) * SolarCollectors::Parameters(ParamNum).IAM(ThetaGnd)) / + incidentAngleModifier = (DataHeatBalance::SurfQRadSWOutIncidentBeam(SurfNum) * state.dataSolarCollectors->Parameters(ParamNum).IAM(ThetaBeam) + + DataHeatBalance::SurfQRadSWOutIncidentSkyDiffuse(SurfNum) * state.dataSolarCollectors->Parameters(ParamNum).IAM(ThetaSky) + + DataHeatBalance::SurfQRadSWOutIncidentGndDiffuse(SurfNum) * state.dataSolarCollectors->Parameters(ParamNum).IAM(ThetaGnd)) / DataHeatBalance::SurfQRadSWOutIncident(SurfNum); } else { incidentAngleModifier = 0.0; @@ -1022,7 +999,7 @@ namespace SolarCollectors { Real64 mCpA = massFlowRate * Cp / area; // = MassFlowRateTest * Cp / Area (tested area) - Real64 mCpATest = SolarCollectors::Parameters(ParamNum).TestMassFlowRate * Cp / SolarCollectors::Parameters(this->Parameters).Area; + Real64 mCpATest = state.dataSolarCollectors->Parameters(ParamNum).TestMassFlowRate * Cp / state.dataSolarCollectors->Parameters(this->Parameters).Area; int Iteration = 1; @@ -1047,33 +1024,33 @@ namespace SolarCollectors { // Modify coefficients depending on test correlation type { - auto const SELECT_CASE_var(SolarCollectors::Parameters(ParamNum).TestType); + auto const SELECT_CASE_var(state.dataSolarCollectors->Parameters(ParamNum).TestType); if (SELECT_CASE_var == TestTypeEnum::INLET) { - FRULpTest = SolarCollectors::Parameters(ParamNum).eff1 + - SolarCollectors::Parameters(ParamNum).eff2 * (inletTemp - DataSurfaces::Surface(SurfNum).OutDryBulbTemp); + FRULpTest = state.dataSolarCollectors->Parameters(ParamNum).eff1 + + state.dataSolarCollectors->Parameters(ParamNum).eff2 * (inletTemp - DataSurfaces::Surface(SurfNum).OutDryBulbTemp); TestTypeMod = 1.0; } else if (SELECT_CASE_var == TestTypeEnum::AVERAGE) { FRULpTest = - SolarCollectors::Parameters(ParamNum).eff1 + - SolarCollectors::Parameters(ParamNum).eff2 * ((inletTemp + outletTemp) * 0.5 - DataSurfaces::Surface(SurfNum).OutDryBulbTemp); + state.dataSolarCollectors->Parameters(ParamNum).eff1 + + state.dataSolarCollectors->Parameters(ParamNum).eff2 * ((inletTemp + outletTemp) * 0.5 - DataSurfaces::Surface(SurfNum).OutDryBulbTemp); TestTypeMod = 1.0 / (1.0 - FRULpTest / (2.0 * mCpATest)); } else if (SELECT_CASE_var == TestTypeEnum::OUTLET) { - FRULpTest = SolarCollectors::Parameters(ParamNum).eff1 + - SolarCollectors::Parameters(ParamNum).eff2 * (outletTemp - DataSurfaces::Surface(SurfNum).OutDryBulbTemp); + FRULpTest = state.dataSolarCollectors->Parameters(ParamNum).eff1 + + state.dataSolarCollectors->Parameters(ParamNum).eff2 * (outletTemp - DataSurfaces::Surface(SurfNum).OutDryBulbTemp); TestTypeMod = 1.0 / (1.0 - FRULpTest / mCpATest); } } // FR * tau * alpha at normal incidence = Y-intercept of collector efficiency - Real64 FRTAN = SolarCollectors::Parameters(ParamNum).eff0 * TestTypeMod; + Real64 FRTAN = state.dataSolarCollectors->Parameters(ParamNum).eff0 * TestTypeMod; // FR * ULoss = 1st order coefficient of collector efficiency - Real64 FRUL = SolarCollectors::Parameters(ParamNum).eff1 * TestTypeMod; + Real64 FRUL = state.dataSolarCollectors->Parameters(ParamNum).eff1 * TestTypeMod; // FR * ULoss / T = 2nd order coefficient of collector efficiency - Real64 FRULT = SolarCollectors::Parameters(ParamNum).eff2 * TestTypeMod; + Real64 FRULT = state.dataSolarCollectors->Parameters(ParamNum).eff2 * TestTypeMod; FRULpTest *= TestTypeMod; if (massFlowRate > 0.0) { // Calculate efficiency and heat transfer with flow @@ -1157,7 +1134,7 @@ namespace SolarCollectors { } } - if (SolarCollectors::Parameters(ParamNum).TestType == TestTypeEnum::INLET) + if (state.dataSolarCollectors->Parameters(ParamNum).TestType == TestTypeEnum::INLET) break; // Inlet temperature test correlations do not need to iterate if (Iteration > 100) { @@ -1277,7 +1254,7 @@ namespace SolarCollectors { // Calculate transmittance-absorptance product of the system // Incident angle of beam radiation (radians) Real64 ThetaBeam = std::acos(DataHeatBalance::SurfCosIncidenceAngle(SurfNum)); - this->CalcTransAbsorProduct(ThetaBeam); + this->CalcTransAbsorProduct(state, ThetaBeam); Real64 inletTemp = this->InletTemp; @@ -1292,7 +1269,7 @@ namespace SolarCollectors { state, DataPlant::PlantLoop(this->WLoopNum).FluidName, inletTemp, DataPlant::PlantLoop(this->WLoopNum).FluidIndex, RoutineName); // calculate heat transfer coefficients and covers temperature: - this->CalcHeatTransCoeffAndCoverTemp(); + this->CalcHeatTransCoeffAndCoverTemp(state); // Calc convection heat transfer coefficient between the absorber plate and water: @@ -1310,13 +1287,13 @@ namespace SolarCollectors { Real64 a3; // constant term of ODE for absorber temperature // Gross area of collector (m2) - Real64 area = SolarCollectors::Parameters(ParamNum).Area; + Real64 area = state.dataSolarCollectors->Parameters(ParamNum).Area; - if (SolarCollectors::Parameters(ParamNum).ThermalMass > 0.0) { + if (state.dataSolarCollectors->Parameters(ParamNum).ThermalMass > 0.0) { AbsPlateMassFlag = true; // thermal mass of the absorber plate [J/K] - Real64 ap = SolarCollectors::Parameters(ParamNum).ThermalMass * area; + Real64 ap = state.dataSolarCollectors->Parameters(ParamNum).ThermalMass * area; a1 = -area * (hConvCoefA2W + this->UTopLoss) / ap; a2 = area * hConvCoefA2W / ap; a3 = area * (this->TauAlpha * DataHeatBalance::SurfQRadSWOutIncident(SurfNum) + this->UTopLoss * TempOutdoorAir) / ap; @@ -1328,7 +1305,7 @@ namespace SolarCollectors { } // thermal mass of the collector water [J/K] - Real64 aw = SolarCollectors::Parameters(ParamNum).Volume * Rhow * Cpw; + Real64 aw = state.dataSolarCollectors->Parameters(ParamNum).Volume * Rhow * Cpw; // coefficient of ODE for water temperature Tp Real64 b1 = area * hConvCoefA2W / aw; @@ -1442,7 +1419,7 @@ namespace SolarCollectors { } } - void CollectorData::CalcTransAbsorProduct(Real64 const IncidAngle) + void CollectorData::CalcTransAbsorProduct(EnergyPlusData &state, Real64 const IncidAngle) { // SUBROUTINE INFORMATION: @@ -1477,10 +1454,10 @@ namespace SolarCollectors { if (DataHeatBalance::SurfQRadSWOutIncident(SurfNum) > 0.0) { // cover system transmittance and reflectance from outer to inner cover - this->CalcTransRefAbsOfCover(IncidAngle, TransSys, ReflSys, AbsCover1, AbsCover2); + this->CalcTransRefAbsOfCover(state, IncidAngle, TransSys, ReflSys, AbsCover1, AbsCover2); - TuaAlphaBeam = TransSys * SolarCollectors::Parameters(ParamNum).AbsorOfAbsPlate / - (1.0 - (1.0 - SolarCollectors::Parameters(ParamNum).AbsorOfAbsPlate) * this->RefDiffInnerCover); + TuaAlphaBeam = TransSys * state.dataSolarCollectors->Parameters(ParamNum).AbsorOfAbsPlate / + (1.0 - (1.0 - state.dataSolarCollectors->Parameters(ParamNum).AbsorOfAbsPlate) * this->RefDiffInnerCover); this->TauAlphaBeam = max(0.0, TuaAlphaBeam); @@ -1494,16 +1471,16 @@ namespace SolarCollectors { DataHeatBalance::SurfQRadSWOutIncidentGndDiffuse(SurfNum) * this->TauAlphaGndDiffuse) / DataHeatBalance::SurfQRadSWOutIncident(SurfNum); - if (SolarCollectors::Parameters(ParamNum).NumOfCovers == 1) { + if (state.dataSolarCollectors->Parameters(ParamNum).NumOfCovers == 1) { // calc total solar radiation weighted cover absorptance this->CoverAbs(1) = (DataHeatBalance::SurfQRadSWOutIncidentBeam(SurfNum) * CoversAbsBeam(1) + DataHeatBalance::SurfQRadSWOutIncidentSkyDiffuse(SurfNum) * this->CoversAbsSkyDiffuse(1) + DataHeatBalance::SurfQRadSWOutIncidentGndDiffuse(SurfNum) * this->CoversAbsGndDiffuse(1)) / DataHeatBalance::SurfQRadSWOutIncident(SurfNum); - } else if (SolarCollectors::Parameters(ParamNum).NumOfCovers == 2) { + } else if (state.dataSolarCollectors->Parameters(ParamNum).NumOfCovers == 2) { // Num = 1 represents outer cover and Num = 2 represents inner cover - for (int Num = 1; Num <= SolarCollectors::Parameters(ParamNum).NumOfCovers; ++Num) { + for (int Num = 1; Num <= state.dataSolarCollectors->Parameters(ParamNum).NumOfCovers; ++Num) { this->CoverAbs(Num) = (DataHeatBalance::SurfQRadSWOutIncidentBeam(SurfNum) * CoversAbsBeam(Num) + DataHeatBalance::SurfQRadSWOutIncidentSkyDiffuse(SurfNum) * this->CoversAbsSkyDiffuse(Num) + DataHeatBalance::SurfQRadSWOutIncidentGndDiffuse(SurfNum) * this->CoversAbsGndDiffuse(Num)) / @@ -1517,7 +1494,7 @@ namespace SolarCollectors { this->TauAlpha = TuaAlpha; } - void CollectorData::CalcTransRefAbsOfCover(Real64 const IncidentAngle, // Angle of incidence (radians) + void CollectorData::CalcTransRefAbsOfCover(EnergyPlusData &state, Real64 const IncidentAngle, // Angle of incidence (radians) Real64 &TransSys, // cover system solar transmittance Real64 &ReflSys, // cover system solar reflectance Real64 &AbsCover1, // Inner cover solar absorbtance @@ -1575,16 +1552,16 @@ namespace SolarCollectors { int ParamNum = this->Parameters; Real64 const sin_IncAngle(std::sin(IncidentAngle)); - for (int nCover = 1; nCover <= SolarCollectors::Parameters(ParamNum).NumOfCovers; ++nCover) { + for (int nCover = 1; nCover <= state.dataSolarCollectors->Parameters(ParamNum).NumOfCovers; ++nCover) { // refractive index of collector cover - Real64 CoverRefrIndex = SolarCollectors::Parameters(ParamNum).RefractiveIndex(nCover); + Real64 CoverRefrIndex = state.dataSolarCollectors->Parameters(ParamNum).RefractiveIndex(nCover); // angle of refraction Real64 RefrAngle = std::asin(sin_IncAngle * AirRefIndex / CoverRefrIndex); // transmitted component with absorption only considered: - TransAbsOnly(nCover) = std::exp(-SolarCollectors::Parameters(ParamNum).ExtCoefTimesThickness(nCover) / std::cos(RefrAngle)); + TransAbsOnly(nCover) = std::exp(-state.dataSolarCollectors->Parameters(ParamNum).ExtCoefTimesThickness(nCover) / std::cos(RefrAngle)); // parallel reflected component of unpolarized solar radiation Real64 ParaRad; @@ -1618,7 +1595,7 @@ namespace SolarCollectors { // solar absorptance of the individual cover AbsCover1 = 0.5 * (AbsorPerp(1) + AbsorPara(1)); - if (SolarCollectors::Parameters(ParamNum).NumOfCovers == 2) AbsCover2 = 0.5 * (AbsorPerp(2) + AbsorPara(2)); + if (state.dataSolarCollectors->Parameters(ParamNum).NumOfCovers == 2) AbsCover2 = 0.5 * (AbsorPerp(2) + AbsorPara(2)); // calculate from outer to inner cover: TransSys = @@ -1636,7 +1613,7 @@ namespace SolarCollectors { } } - void CollectorData::CalcHeatTransCoeffAndCoverTemp() // Collector object number + void CollectorData::CalcHeatTransCoeffAndCoverTemp(EnergyPlusData &state) // Collector object number { // SUBROUTINE INFORMATION: // AUTHOR Bereket A Nigusse, FSEC/UCF @@ -1663,7 +1640,7 @@ namespace SolarCollectors { Real64 hRadCoefC2O = 0.0; // radiation coeff. between outer covers and the ambient [W/m2C] int ParamNum = this->Parameters; - int NumCovers = SolarCollectors::Parameters(ParamNum).NumOfCovers; + int NumCovers = state.dataSolarCollectors->Parameters(ParamNum).NumOfCovers; int SurfNum = this->Surface; Real64 TempAbsPlate = this->SavedTempOfAbsPlate; // absorber plate average temperature [C] @@ -1671,10 +1648,10 @@ namespace SolarCollectors { Real64 TempOuterCover = this->SavedTempOfOuterCover; // outer cover average temperature [C] Real64 TempOutdoorAir = DataSurfaces::Surface(SurfNum).OutDryBulbTemp; // outdoor air temperature [C] - Real64 EmissOfAbsPlate = SolarCollectors::Parameters(ParamNum).EmissOfAbsPlate; // emissivity of absorber plate - Real64 EmissOfOuterCover = SolarCollectors::Parameters(ParamNum).EmissOfCover(1); // emissivity of outer cover - Real64 EmissOfInnerCover = SolarCollectors::Parameters(ParamNum).EmissOfCover(2); // emissivity of inner cover - Real64 AirGapDepth = SolarCollectors::Parameters(ParamNum).CoverSpacing; // characteristic length [m] + Real64 EmissOfAbsPlate = state.dataSolarCollectors->Parameters(ParamNum).EmissOfAbsPlate; // emissivity of absorber plate + Real64 EmissOfOuterCover = state.dataSolarCollectors->Parameters(ParamNum).EmissOfCover(1); // emissivity of outer cover + Real64 EmissOfInnerCover = state.dataSolarCollectors->Parameters(ParamNum).EmissOfCover(2); // emissivity of inner cover + Real64 AirGapDepth = state.dataSolarCollectors->Parameters(ParamNum).CoverSpacing; // characteristic length [m] { auto const SELECT_CASE_var(NumCovers); @@ -1762,13 +1739,13 @@ namespace SolarCollectors { // calculate the side loss coefficient. Adds the insulation resistance and the combined // convection-radiation coefficients in series. Real64 hRadConvOut = 5.7 + 3.8 * DataSurfaces::Surface(SurfNum).WindSpeed; - this->UsLoss = 1.0 / (1.0 / (SolarCollectors::Parameters(ParamNum).ULossSide * this->AreaRatio) + 1.0 / (hRadConvOut * this->AreaRatio)); + this->UsLoss = 1.0 / (1.0 / (state.dataSolarCollectors->Parameters(ParamNum).ULossSide * this->AreaRatio) + 1.0 / (hRadConvOut * this->AreaRatio)); // the bottom loss coefficient calculation depends on the boundary condition if (this->OSCM_ON) { // OtherSideConditionsModel - this->UbLoss = SolarCollectors::Parameters(ParamNum).ULossBottom; + this->UbLoss = state.dataSolarCollectors->Parameters(ParamNum).ULossBottom; } else { // AmbientAir - this->UbLoss = 1.0 / (1.0 / SolarCollectors::Parameters(ParamNum).ULossBottom + 1.0 / hRadConvOut); + this->UbLoss = 1.0 / (1.0 / state.dataSolarCollectors->Parameters(ParamNum).ULossBottom + 1.0 / hRadConvOut); } // Calculate current timestep covers temperature diff --git a/src/EnergyPlus/SolarCollectors.hh b/src/EnergyPlus/SolarCollectors.hh index aa904a81283..e92037f95ca 100644 --- a/src/EnergyPlus/SolarCollectors.hh +++ b/src/EnergyPlus/SolarCollectors.hh @@ -64,11 +64,6 @@ struct EnergyPlusData; namespace SolarCollectors { - extern Array1D_bool CheckEquipName; - - extern int NumOfParameters; - extern int NumOfCollectors; - enum struct FluidEnum { WATER, @@ -237,7 +232,7 @@ namespace SolarCollectors { void simulate(EnergyPlusData &EP_UNUSED(state), const PlantLocation &calledFromLocation, bool FirstHVACIteration, Real64 &CurLoad, bool RunFlag) override; - void CalcTransRefAbsOfCover(Real64 IncidentAngle, // Angle of incidence (radians) + void CalcTransRefAbsOfCover(EnergyPlusData &state, Real64 IncidentAngle, // Angle of incidence (radians) Real64 &TransSys, // cover system solar transmittance Real64 &ReflSys, // cover system solar reflectance Real64 &AbsCover1, // Inner cover solar absorbtance @@ -250,9 +245,9 @@ namespace SolarCollectors { void CalcICSSolarCollector(EnergyPlusData &state); - void CalcTransAbsorProduct(Real64 IncidAngle); + void CalcTransAbsorProduct(EnergyPlusData &state, Real64 IncidAngle); - void CalcHeatTransCoeffAndCoverTemp(); + void CalcHeatTransCoeffAndCoverTemp(EnergyPlusData &state); static void ICSCollectorAnalyticalSolution(Real64 SecInTimeStep, // seconds in a time step Real64 a1, // coefficient of ODE for Tp @@ -289,16 +284,36 @@ namespace SolarCollectors { void report(); }; - // Object Data - extern Array1D Parameters; - extern Array1D Collector; - - // Functions - void clear_state(); void GetSolarCollectorInput(EnergyPlusData &state); } // namespace SolarCollectors +struct SolarCollectorsData : BaseGlobalStruct { + + Array1D_bool CheckEquipName; + int NumOfCollectors = 0; + int NumOfParameters = 0; + bool GetInputFlag = true; + + Array1D Parameters; + Array1D Collector; + std::unordered_map UniqueParametersNames; + std::unordered_map UniqueCollectorNames; + + void clear_state() override + { + NumOfCollectors = 0; + NumOfParameters = 0; + GetInputFlag = true; + Parameters.deallocate(); + Collector.deallocate(); + UniqueCollectorNames.clear(); + UniqueParametersNames.clear(); + } + + // Default Constructor + SolarCollectorsData() = default; +}; } // namespace EnergyPlus #endif diff --git a/src/EnergyPlus/StateManagement.cc b/src/EnergyPlus/StateManagement.cc index 028ccf2a4f2..8cebb53b40d 100644 --- a/src/EnergyPlus/StateManagement.cc +++ b/src/EnergyPlus/StateManagement.cc @@ -208,7 +208,6 @@ #include #include #include -#include #include void EnergyPlus::clearAllStates(EnergyPlusData &state) @@ -372,7 +371,6 @@ void EnergyPlus::clearAllStates(EnergyPlusData &state) SingleDuct::clear_state(); SizingAnalysisObjects_clear_state(); // SizingAnalysisObjects does not have a namespace SizingManager::clear_state(); - SolarCollectors::clear_state(); SurfaceGeometry::clear_state(); UtilityRoutines::clear_state(); EIRPlantLoopHeatPumps::EIRPlantLoopHeatPump::clear_state(); diff --git a/src/EnergyPlus/WaterThermalTanks.cc b/src/EnergyPlus/WaterThermalTanks.cc index 9ae85f4b334..6114da7f951 100644 --- a/src/EnergyPlus/WaterThermalTanks.cc +++ b/src/EnergyPlus/WaterThermalTanks.cc @@ -10679,8 +10679,8 @@ namespace WaterThermalTanks { } else if (SELECT_CASE_var == SizeEnum::PerSolarColArea) { this->Sizing.TotalSolarCollectorArea = 0.0; - for (int CollectorNum = 1; CollectorNum <= SolarCollectors::NumOfCollectors; ++CollectorNum) { - this->Sizing.TotalSolarCollectorArea += DataSurfaces::Surface(SolarCollectors::Collector(CollectorNum).Surface).Area; + for (int CollectorNum = 1; CollectorNum <= state.dataSolarCollectors->NumOfCollectors; ++CollectorNum) { + this->Sizing.TotalSolarCollectorArea += DataSurfaces::Surface(state.dataSolarCollectors->Collector(CollectorNum).Surface).Area; } if (this->VolumeWasAutoSized) tmpTankVolume = this->Sizing.TotalSolarCollectorArea * this->Sizing.TankCapacityPerCollectorArea; @@ -11196,8 +11196,8 @@ namespace WaterThermalTanks { } } else if (SELECT_CASE_var == SizeEnum::PerSolarColArea) { this->Sizing.TotalSolarCollectorArea = 0.0; - for (int CollectorNum = 1; CollectorNum <= SolarCollectors::NumOfCollectors; ++CollectorNum) { - this->Sizing.TotalSolarCollectorArea += DataSurfaces::Surface(SolarCollectors::Collector(CollectorNum).Surface).Area; + for (int CollectorNum = 1; CollectorNum <= state.dataSolarCollectors->NumOfCollectors; ++CollectorNum) { + this->Sizing.TotalSolarCollectorArea += DataSurfaces::Surface(state.dataSolarCollectors->Collector(CollectorNum).Surface).Area; } if (this->VolumeWasAutoSized) tmpTankVolume = this->Sizing.TotalSolarCollectorArea * this->Sizing.TankCapacityPerCollectorArea;