diff --git a/src/EnergyPlus/HeatBalanceSurfaceManager.cc b/src/EnergyPlus/HeatBalanceSurfaceManager.cc index f045b33f107..94d38826152 100644 --- a/src/EnergyPlus/HeatBalanceSurfaceManager.cc +++ b/src/EnergyPlus/HeatBalanceSurfaceManager.cc @@ -226,7 +226,7 @@ namespace HeatBalanceSurfaceManager { using HeatBalanceAirManager::ManageAirHeatBalance; using HeatBalFiniteDiffManager::SurfaceFD; - using OutputReportTabular::GatherComponentLoadsSurface; // for writing tabular compoonent loads output reports + using OutputReportTabular::GatherComponentLoadsSurface; // for writing tabular component loads output reports using ThermalComfort::ManageThermalComfort; int SurfNum; diff --git a/src/EnergyPlus/Plant/PlantManager.cc b/src/EnergyPlus/Plant/PlantManager.cc index 70f2d27c47d..6e0076879a3 100644 --- a/src/EnergyPlus/Plant/PlantManager.cc +++ b/src/EnergyPlus/Plant/PlantManager.cc @@ -109,6 +109,7 @@ #include #include #include +#include #include #include #include @@ -1440,6 +1441,7 @@ namespace EnergyPlus { this_comp.TypeOf_Num = TypeOf_PlantComponentUserDefined; this_comp.GeneralEquipType = GenEquipTypes_PlantComponent; this_comp.CurOpSchemeType = UnknownStatusOpSchemeType; + this_comp.compPtr = UserDefinedComponents::UserPlantComponentStruct::factory(CompNames(CompNum)); } else if (UtilityRoutines::SameString(this_comp_type, "Coil:UserDefined")) { this_comp.TypeOf_Num = TypeOf_CoilUserDefined; this_comp.GeneralEquipType = GenEquipTypes_PlantComponent; diff --git a/src/EnergyPlus/PlantLoopEquip.cc b/src/EnergyPlus/PlantLoopEquip.cc index 5a1962b7503..c7d423ba5c3 100644 --- a/src/EnergyPlus/PlantLoopEquip.cc +++ b/src/EnergyPlus/PlantLoopEquip.cc @@ -192,7 +192,6 @@ namespace PlantLoopEquip { using HWBaseboardRadiator::UpdateHWBaseboardPlantConnection; using RefrigeratedCase::SimRefrigCondenser; using SteamBaseboardRadiator::UpdateSteamBaseboardPlantConnection; - using UserDefinedComponents::SimUserDefinedPlantComponent; using WaterCoils::UpdateWaterToAirCoilPlantConnection; // SUBROUTINE LOCAL VARIABLE DECLARATIONS: @@ -934,15 +933,7 @@ namespace PlantLoopEquip { } else if (GeneralEquipType == GenEquipTypes_PlantComponent) { if (EquipTypeNum == TypeOf_PlantComponentUserDefined) { - - SimUserDefinedPlantComponent( - LoopNum, LoopSideNum, sim_component.TypeOf, sim_component.Name, EquipNum, InitLoopEquip, CurLoad, MaxLoad, MinLoad, OptLoad); - if (InitLoopEquip) { - sim_component.MaxLoad = MaxLoad; - sim_component.MinLoad = MinLoad; - sim_component.OptLoad = OptLoad; - sim_component.CompNum = EquipNum; - } + sim_component.compPtr->simulate(sim_component_location, FirstHVACIteration, CurLoad, RunFlag); } else if (EquipTypeNum == TypeOf_WaterSource) { sim_component.compPtr->simulate(sim_component_location, FirstHVACIteration, CurLoad, RunFlag); diff --git a/src/EnergyPlus/RuntimeLanguageProcessor.cc b/src/EnergyPlus/RuntimeLanguageProcessor.cc index db77bd46ecd..2db323cf395 100644 --- a/src/EnergyPlus/RuntimeLanguageProcessor.cc +++ b/src/EnergyPlus/RuntimeLanguageProcessor.cc @@ -977,7 +977,7 @@ namespace RuntimeLanguageProcessor { WriteTrace(StackNum, InstructionNum, ReturnValue, seriousErrorFound); } else if (SELECT_CASE_var == KeywordWhile) { - // evaluate expresssion at while, skip to past endwhile if not true + // evaluate expression at while, skip to past endwhile if not true ExpressionNum = ErlStack(StackNum).Instruction(InstructionNum).Argument1; InstructionNum2 = ErlStack(StackNum).Instruction(InstructionNum).Argument2; ReturnValue = EvaluateExpression(ExpressionNum, seriousErrorFound); diff --git a/src/EnergyPlus/SingleDuct.cc b/src/EnergyPlus/SingleDuct.cc index 90b3d08f4c2..8e6de415495 100644 --- a/src/EnergyPlus/SingleDuct.cc +++ b/src/EnergyPlus/SingleDuct.cc @@ -5452,7 +5452,7 @@ namespace SingleDuct { NumATMixers = inputProcessor->getNumObjectsFound(cCurrentModuleObject); SysATMixer.allocate(NumATMixers); - // Need air disribution units first + // Need air distribution units first ZoneAirLoopEquipmentManager::GetZoneAirLoopEquipment(); for (ATMixerNum = 1; ATMixerNum <= NumATMixers; ++ATMixerNum) { diff --git a/src/EnergyPlus/UserDefinedComponents.cc b/src/EnergyPlus/UserDefinedComponents.cc index 1e66b6e0855..2624e5ebb7f 100644 --- a/src/EnergyPlus/UserDefinedComponents.cc +++ b/src/EnergyPlus/UserDefinedComponents.cc @@ -59,7 +59,6 @@ #include #include #include -#include #include #include #include @@ -71,6 +70,7 @@ #include #include #include +#include #include #include #include @@ -92,33 +92,6 @@ namespace UserDefinedComponents { // PURPOSE OF THIS MODULE: // Collect component models for custom program with Erl. - // METHODOLOGY EMPLOYED: - // na - - // REFERENCES: - // na - - // OTHER NOTES: - // na - - // Using/Aliasing - using namespace DataPrecisionGlobals; - using DataGlobals::BeginEnvrnFlag; - using DataGlobals::emsCallFromUserDefinedComponentModel; - using DataGlobals::NumOfZones; - using namespace DataPlant; - using namespace DataLoopNode; - using namespace DataRuntimeLanguage; - using DataWater::WaterStorage; - - // Data - // MODULE PARAMETER DEFINITIONS: - // na - - // DERIVED TYPE DEFINITIONS: - - // MODULE VARIABLE DECLARATIONS: - int NumUserPlantComps(0); int NumUserCoils(0); int NumUserZoneAir(0); @@ -128,30 +101,109 @@ namespace UserDefinedComponents { Array1D_bool CheckUserCoilName; Array1D_bool CheckUserZoneAirName; Array1D_bool CheckUserAirTerminal; - bool GetInput(true); - // SUBROUTINE SPECIFICATIONS FOR MODULE : + bool GetInput(true); + bool GetPlantCompInput(true); - // Object Data Array1D UserPlantComp; Array1D UserCoil; Array1D UserZoneAirHVAC; Array1D UserAirTerminal; - // Functions - - void SimUserDefinedPlantComponent(int const LoopNum, // plant loop sim call originated from - int const LoopSideNum, // plant loop side sim call originated from - std::string const &EP_UNUSED(EquipType), // type of equipment, 'PlantComponent:UserDefined' - std::string const &EquipName, // user name for component - int &CompIndex, - bool &InitLoopEquip, - Real64 const MyLoad, - Real64 &MaxCap, - Real64 &MinCap, - Real64 &OptCap) + void clear_state() + { + NumUserPlantComps = 0; + NumUserCoils = 0; + NumUserZoneAir = 0; + NumUserAirTerminals = 0; + + CheckUserPlantCompName.deallocate(); + CheckUserCoilName.deallocate(); + CheckUserZoneAirName.deallocate(); + CheckUserAirTerminal.deallocate(); + + UserPlantComp.deallocate(); + UserCoil.deallocate(); + UserZoneAirHVAC.deallocate(); + UserAirTerminal.deallocate(); + } + + PlantComponent *UserPlantComponentStruct::factory(std::string const &objectName) + { + // Process the input data + if (GetPlantCompInput) { + GetUserDefinedPlantComponents(); + GetPlantCompInput = false; + } + // Now look for this particular object + for (auto &thisComp : UserPlantComp) { + if (thisComp.Name == objectName) { + return &thisComp; + } + } + // If we didn't find it, fatal + ShowFatalError("LocalUserDefinedPlantComponentFactory: Error getting inputs for object named: " + objectName); // LCOV_EXCL_LINE + // Shut up the compiler + return nullptr; // LCOV_EXCL_LINE + } + + void UserPlantComponentStruct::onInitLoopEquip(const PlantLocation &calledFromLocation) + { + bool anyEMSRan; + Real64 myLoad = 0.0; + int thisLoop = 0; + + this->initialize(calledFromLocation.loopNum, myLoad); + + for (int loop = 1; loop <= this->NumPlantConnections; ++loop) { + if (calledFromLocation.loopNum != this->Loop(loop).LoopNum) continue; + if (calledFromLocation.loopSideNum != this->Loop(loop).LoopSideNum) continue; + thisLoop = loop; + } + + if (thisLoop > 0) { + if (this->Loop(thisLoop).ErlInitProgramMngr > 0) { + EMSManager::ManageEMS(DataGlobals::emsCallFromUserDefinedComponentModel, anyEMSRan, this->Loop(thisLoop).ErlInitProgramMngr); + } + + PlantUtilities::InitComponentNodes(this->Loop(thisLoop).MassFlowRateMin, + this->Loop(thisLoop).MassFlowRateMax, + this->Loop(thisLoop).InletNodeNum, + this->Loop(thisLoop).OutletNodeNum, + this->Loop(thisLoop).LoopNum, + this->Loop(thisLoop).LoopSideNum, + this->Loop(thisLoop).BranchNum, + this->Loop(thisLoop).CompNum); + + PlantUtilities::RegisterPlantCompDesignFlow(this->Loop(thisLoop).InletNodeNum, this->Loop(thisLoop).DesignVolumeFlowRate); + + } else { + // throw warning + ShowFatalError("SimUserDefinedPlantComponent: did not find where called from loop number called from =" + + General::TrimSigDigits(calledFromLocation.loopNum) + + " , loop side called from =" + General::TrimSigDigits(calledFromLocation.loopSideNum)); + } + } + + void UserPlantComponentStruct::getDesignCapacities(const PlantLocation &calledFromLocation, Real64 &MaxLoad, Real64 &MinLoad, Real64 &OptLoad) { + int thisLoop = 0; + for (int loop = 1; loop <= this->NumPlantConnections; ++loop) { + if (calledFromLocation.loopNum != this->Loop(loop).LoopNum) continue; + if (calledFromLocation.loopSideNum != this->Loop(loop).LoopSideNum) continue; + thisLoop = loop; + } + + MinLoad = this->Loop(thisLoop).MinLoad; + MaxLoad = this->Loop(thisLoop).MaxLoad; + OptLoad = this->Loop(thisLoop).OptLoad; + } + void UserPlantComponentStruct::UserPlantComponentStruct::simulate(const EnergyPlus::PlantLocation &calledFromLocation, + bool EP_UNUSED(FirstHVACIteration), + Real64 &CurLoad, + bool EP_UNUSED(RunFlag)) + { // SUBROUTINE INFORMATION: // AUTHOR B. Griffith // DATE WRITTEN Jan 2012 @@ -161,109 +213,32 @@ namespace UserDefinedComponents { // PURPOSE OF THIS SUBROUTINE: // User Defined plant generic component - // METHODOLOGY EMPLOYED: - // This routine to be called from PlantLoopEquipment. - - // Using/Aliasing - using EMSManager::ManageEMS; - using General::TrimSigDigits; - using PlantUtilities::InitComponentNodes; - using PlantUtilities::RegisterPlantCompDesignFlow; - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - - int CompNum; - int ThisLoop; - int Loop; - - // Autodesk:Uninit Initialize variables used uninitialized - ThisLoop = 0; // Autodesk:Uninit Force default initialization - - if (GetInput) { - GetUserDefinedComponents(); - GetInput = false; + if (DataGlobals::BeginEnvrnFlag) { + this->onInitLoopEquip(calledFromLocation); } - // Find the correct Equipment - if (CompIndex == 0) { - CompNum = UtilityRoutines::FindItemInList(EquipName, UserPlantComp); - if (CompNum == 0) { - ShowFatalError("SimUserDefinedPlantComponent: User Defined Plant Component not found"); - } - CompIndex = CompNum; - } else { - CompNum = CompIndex; - if (CompNum < 1 || CompNum > NumUserPlantComps) { - ShowFatalError("SimUserDefinedPlantComponent: Invalid CompIndex passed=" + TrimSigDigits(CompNum) + - ", Number of units =" + TrimSigDigits(NumUserPlantComps) + ", Entered Unit name = " + EquipName); - } - if (CheckUserPlantCompName(CompNum)) { - if (EquipName != UserPlantComp(CompNum).Name) { - ShowFatalError("SimUserDefinedPlantComponent: Invalid CompIndex passed=" + TrimSigDigits(CompNum) + ", Unit name=" + EquipName + - ", stored unit name for that index=" + UserPlantComp(CompNum).Name); - } - CheckUserPlantCompName(CompNum) = false; - } - } bool anyEMSRan; - if (InitLoopEquip || BeginEnvrnFlag) { - InitPlantUserComponent(CompNum, LoopNum, MyLoad); - // find loop connection number from LoopNum and LoopSide - ThisLoop = 0; - for (Loop = 1; Loop <= UserPlantComp(CompNum).NumPlantConnections; ++Loop) { - if (LoopNum != UserPlantComp(CompNum).Loop(Loop).LoopNum) continue; - if (LoopSideNum != UserPlantComp(CompNum).Loop(Loop).LoopSideNum) continue; - ThisLoop = Loop; - } - if (ThisLoop > 0) { - if (UserPlantComp(CompNum).Loop(ThisLoop).ErlInitProgramMngr > 0) { - ManageEMS(emsCallFromUserDefinedComponentModel, anyEMSRan, UserPlantComp(CompNum).Loop(ThisLoop).ErlInitProgramMngr); - } - // now interface sizing related values with rest of E+ - MinCap = UserPlantComp(CompNum).Loop(ThisLoop).MinLoad; - MaxCap = UserPlantComp(CompNum).Loop(ThisLoop).MaxLoad; - OptCap = UserPlantComp(CompNum).Loop(ThisLoop).OptLoad; - - InitComponentNodes(UserPlantComp(CompNum).Loop(ThisLoop).MassFlowRateMin, - UserPlantComp(CompNum).Loop(ThisLoop).MassFlowRateMax, - UserPlantComp(CompNum).Loop(ThisLoop).InletNodeNum, - UserPlantComp(CompNum).Loop(ThisLoop).OutletNodeNum, - UserPlantComp(CompNum).Loop(ThisLoop).LoopNum, - UserPlantComp(CompNum).Loop(ThisLoop).LoopSideNum, - UserPlantComp(CompNum).Loop(ThisLoop).BranchNum, - UserPlantComp(CompNum).Loop(ThisLoop).CompNum); - - RegisterPlantCompDesignFlow(UserPlantComp(CompNum).Loop(ThisLoop).InletNodeNum, - UserPlantComp(CompNum).Loop(ThisLoop).DesignVolumeFlowRate); - - } else { - // throw warning - ShowFatalError("SimUserDefinedPlantComponent: did not find where called from loop number called from =" + TrimSigDigits(LoopNum) + - " , loop side called from =" + TrimSigDigits(LoopSideNum)); - } - return; - } + int thisLoop = 0; - ThisLoop = 0; - for (Loop = 1; Loop <= UserPlantComp(CompNum).NumPlantConnections; ++Loop) { - if (LoopNum != UserPlantComp(CompNum).Loop(Loop).LoopNum) continue; - if (LoopSideNum != UserPlantComp(CompNum).Loop(Loop).LoopSideNum) continue; - ThisLoop = Loop; + for (int loop = 1; loop <= this->NumPlantConnections; ++loop) { + if (calledFromLocation.loopNum != this->Loop(loop).LoopNum) continue; + if (calledFromLocation.loopSideNum != this->Loop(loop).LoopSideNum) continue; + thisLoop = loop; } - InitPlantUserComponent(CompNum, ThisLoop, MyLoad); + this->initialize(thisLoop, CurLoad); - if (ThisLoop > 0) { - if (UserPlantComp(CompNum).Loop(ThisLoop).ErlSimProgramMngr > 0) { - ManageEMS(emsCallFromUserDefinedComponentModel, anyEMSRan, UserPlantComp(CompNum).Loop(ThisLoop).ErlSimProgramMngr); + if (thisLoop > 0) { + if (this->Loop(thisLoop).ErlSimProgramMngr > 0) { + EMSManager::ManageEMS(DataGlobals::emsCallFromUserDefinedComponentModel, anyEMSRan, this->Loop(thisLoop).ErlSimProgramMngr); } } - if (UserPlantComp(CompNum).ErlSimProgramMngr > 0) { - ManageEMS(emsCallFromUserDefinedComponentModel, anyEMSRan, UserPlantComp(CompNum).ErlSimProgramMngr); + if (this->ErlSimProgramMngr > 0) { + EMSManager::ManageEMS(DataGlobals::emsCallFromUserDefinedComponentModel, anyEMSRan, this->ErlSimProgramMngr); } - ReportPlantUserComponent(CompNum, ThisLoop); + this->report(thisLoop); } void SimCoilUserDefined(std::string const &EquipName, // user name for component @@ -279,25 +254,11 @@ namespace UserDefinedComponents { // MODIFIED na // RE-ENGINEERED na - // PURPOSE OF THIS SUBROUTINE: - // - - // Using/Aliasing - using EMSManager::ManageEMS; - using General::TrimSigDigits; - using PlantUtilities::InitComponentNodes; - using PlantUtilities::RegisterPlantCompDesignFlow; - using PlantUtilities::SetComponentFlowRate; - using Psychrometrics::PsyHFnTdbW; - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - Real64 EnthInlet; - Real64 EnthOutlet; int CompNum; - if (GetInput) { - GetUserDefinedComponents(); - GetInput = false; + if (GetPlantCompInput) { + GetUserDefinedPlantComponents(); + GetPlantCompInput = false; } // Find the correct Equipment @@ -310,61 +271,56 @@ namespace UserDefinedComponents { } else { CompNum = CompIndex; if (CompNum < 1 || CompNum > NumUserCoils) { - ShowFatalError("SimUserDefinedPlantComponent: Invalid CompIndex passed=" + TrimSigDigits(CompNum) + - ", Number of units =" + TrimSigDigits(NumUserCoils) + ", Entered Unit name = " + EquipName); + ShowFatalError("SimUserDefinedPlantComponent: Invalid CompIndex passed=" + General::TrimSigDigits(CompNum) + + ", Number of units =" + General::TrimSigDigits(NumUserCoils) + ", Entered Unit name = " + EquipName); } if (CheckUserCoilName(CompNum)) { if (EquipName != UserCoil(CompNum).Name) { - ShowFatalError("SimUserDefinedPlantComponent: Invalid CompIndex passed=" + TrimSigDigits(CompNum) + ", Unit name=" + EquipName + - ", stored unit name for that index=" + UserCoil(CompNum).Name); + ShowFatalError("SimUserDefinedPlantComponent: Invalid CompIndex passed=" + General::TrimSigDigits(CompNum) + + ", Unit name=" + EquipName + ", stored unit name for that index=" + UserCoil(CompNum).Name); } CheckUserCoilName(CompNum) = false; } } bool anyEMSRan; - if (BeginEnvrnFlag) { + if (DataGlobals::BeginEnvrnFlag) { if (UserCoil(CompNum).ErlInitProgramMngr > 0) { - ManageEMS(emsCallFromUserDefinedComponentModel, anyEMSRan, UserCoil(CompNum).ErlInitProgramMngr); + EMSManager::ManageEMS(DataGlobals::emsCallFromUserDefinedComponentModel, anyEMSRan, UserCoil(CompNum).ErlInitProgramMngr); } if (UserCoil(CompNum).PlantIsConnected) { - InitComponentNodes(UserCoil(CompNum).Loop.MassFlowRateMin, - UserCoil(CompNum).Loop.MassFlowRateMax, - UserCoil(CompNum).Loop.InletNodeNum, - UserCoil(CompNum).Loop.OutletNodeNum, - UserCoil(CompNum).Loop.LoopNum, - UserCoil(CompNum).Loop.LoopSideNum, - UserCoil(CompNum).Loop.BranchNum, - UserCoil(CompNum).Loop.CompNum); + PlantUtilities::InitComponentNodes(UserCoil(CompNum).Loop.MassFlowRateMin, + UserCoil(CompNum).Loop.MassFlowRateMax, + UserCoil(CompNum).Loop.InletNodeNum, + UserCoil(CompNum).Loop.OutletNodeNum, + UserCoil(CompNum).Loop.LoopNum, + UserCoil(CompNum).Loop.LoopSideNum, + UserCoil(CompNum).Loop.BranchNum, + UserCoil(CompNum).Loop.CompNum); - RegisterPlantCompDesignFlow(UserCoil(CompNum).Loop.InletNodeNum, UserCoil(CompNum).Loop.DesignVolumeFlowRate); + PlantUtilities::RegisterPlantCompDesignFlow(UserCoil(CompNum).Loop.InletNodeNum, UserCoil(CompNum).Loop.DesignVolumeFlowRate); } } - InitCoilUserDefined(CompNum); + UserCoil(CompNum).initialize(); if (UserCoil(CompNum).ErlSimProgramMngr > 0) { - ManageEMS(emsCallFromUserDefinedComponentModel, anyEMSRan, UserCoil(CompNum).ErlSimProgramMngr); + EMSManager::ManageEMS(DataGlobals::emsCallFromUserDefinedComponentModel, anyEMSRan, UserCoil(CompNum).ErlSimProgramMngr); } - ReportCoilUserDefined(CompNum); + UserCoil(CompNum).report(); - if (AirLoopNum != -1) { // IF the sysem is not an equipment of outdoor air unit + if (AirLoopNum != -1) { // IF the system is not an equipment of outdoor air unit // determine if heating or cooling on primary air stream - if (Node(UserCoil(CompNum).Air(1).InletNodeNum).Temp < Node(UserCoil(CompNum).Air(1).OutletNodeNum).Temp) { - HeatingActive = true; - } else { - HeatingActive = false; - } - - EnthInlet = PsyHFnTdbW(Node(UserCoil(CompNum).Air(1).InletNodeNum).Temp, Node(UserCoil(CompNum).Air(1).InletNodeNum).HumRat); - EnthOutlet = PsyHFnTdbW(Node(UserCoil(CompNum).Air(1).OutletNodeNum).Temp, Node(UserCoil(CompNum).Air(1).OutletNodeNum).HumRat); - if (EnthInlet > EnthOutlet) { - CoolingActive = true; - } else { - CoolingActive = false; - } + HeatingActive = + DataLoopNode::Node(UserCoil(CompNum).Air(1).InletNodeNum).Temp < DataLoopNode::Node(UserCoil(CompNum).Air(1).OutletNodeNum).Temp; + + Real64 EnthInlet = Psychrometrics::PsyHFnTdbW(DataLoopNode::Node(UserCoil(CompNum).Air(1).InletNodeNum).Temp, + DataLoopNode::Node(UserCoil(CompNum).Air(1).InletNodeNum).HumRat); + Real64 EnthOutlet = Psychrometrics::PsyHFnTdbW(DataLoopNode::Node(UserCoil(CompNum).Air(1).OutletNodeNum).Temp, + DataLoopNode::Node(UserCoil(CompNum).Air(1).OutletNodeNum).HumRat); + CoolingActive = EnthInlet > EnthOutlet; } } @@ -382,24 +338,7 @@ namespace UserDefinedComponents { // MODIFIED na // RE-ENGINEERED na - // PURPOSE OF THIS SUBROUTINE: - // - - // Using/Aliasing - using EMSManager::ManageEMS; - using General::TrimSigDigits; - using PlantUtilities::InitComponentNodes; - using PlantUtilities::RegisterPlantCompDesignFlow; - using PlantUtilities::SetComponentFlowRate; - using Psychrometrics::PsyHFnTdbW; - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int CompNum; - int Loop; - Real64 AirMassFlow; - Real64 MinHumRat; - Real64 SpecHumOut; - Real64 SpecHumIn; if (GetInput) { GetUserDefinedComponents(); @@ -416,62 +355,63 @@ namespace UserDefinedComponents { } else { CompNum = CompIndex; if (CompNum < 1 || CompNum > NumUserZoneAir) { - ShowFatalError("SimUserDefinedPlantComponent: Invalid CompIndex passed=" + TrimSigDigits(CompNum) + - ", Number of units =" + TrimSigDigits(NumUserZoneAir) + ", Entered Unit name = " + CompName); + ShowFatalError("SimUserDefinedPlantComponent: Invalid CompIndex passed=" + General::TrimSigDigits(CompNum) + + ", Number of units =" + General::TrimSigDigits(NumUserZoneAir) + ", Entered Unit name = " + CompName); } if (CheckUserZoneAirName(CompNum)) { if (CompName != UserZoneAirHVAC(CompNum).Name) { - ShowFatalError("SimUserDefinedPlantComponent: Invalid CompIndex passed=" + TrimSigDigits(CompNum) + ", Unit name=" + CompName + - ", stored unit name for that index=" + UserZoneAirHVAC(CompNum).Name); + ShowFatalError("SimUserDefinedPlantComponent: Invalid CompIndex passed=" + General::TrimSigDigits(CompNum) + + ", Unit name=" + CompName + ", stored unit name for that index=" + UserZoneAirHVAC(CompNum).Name); } CheckUserZoneAirName(CompNum) = false; } } bool anyEMSRan; - if (BeginEnvrnFlag) { - InitZoneAirUserDefined(CompNum, ZoneNum); + if (DataGlobals::BeginEnvrnFlag) { + UserZoneAirHVAC(CompNum).initialize(ZoneNum); if (UserZoneAirHVAC(CompNum).ErlInitProgramMngr > 0) { - ManageEMS(emsCallFromUserDefinedComponentModel, anyEMSRan, UserZoneAirHVAC(CompNum).ErlInitProgramMngr); + EMSManager::ManageEMS(DataGlobals::emsCallFromUserDefinedComponentModel, anyEMSRan, UserZoneAirHVAC(CompNum).ErlInitProgramMngr); } if (UserZoneAirHVAC(CompNum).NumPlantConnections > 0) { - for (Loop = 1; Loop <= UserZoneAirHVAC(CompNum).NumPlantConnections; ++Loop) { - - InitComponentNodes(UserZoneAirHVAC(CompNum).Loop(Loop).MassFlowRateMin, - UserZoneAirHVAC(CompNum).Loop(Loop).MassFlowRateMax, - UserZoneAirHVAC(CompNum).Loop(Loop).InletNodeNum, - UserZoneAirHVAC(CompNum).Loop(Loop).OutletNodeNum, - UserZoneAirHVAC(CompNum).Loop(Loop).LoopNum, - UserZoneAirHVAC(CompNum).Loop(Loop).LoopSideNum, - UserZoneAirHVAC(CompNum).Loop(Loop).BranchNum, - UserZoneAirHVAC(CompNum).Loop(Loop).CompNum); - - RegisterPlantCompDesignFlow(UserZoneAirHVAC(CompNum).Loop(Loop).InletNodeNum, - UserZoneAirHVAC(CompNum).Loop(Loop).DesignVolumeFlowRate); + for (int Loop = 1; Loop <= UserZoneAirHVAC(CompNum).NumPlantConnections; ++Loop) { + + PlantUtilities::InitComponentNodes(UserZoneAirHVAC(CompNum).Loop(Loop).MassFlowRateMin, + UserZoneAirHVAC(CompNum).Loop(Loop).MassFlowRateMax, + UserZoneAirHVAC(CompNum).Loop(Loop).InletNodeNum, + UserZoneAirHVAC(CompNum).Loop(Loop).OutletNodeNum, + UserZoneAirHVAC(CompNum).Loop(Loop).LoopNum, + UserZoneAirHVAC(CompNum).Loop(Loop).LoopSideNum, + UserZoneAirHVAC(CompNum).Loop(Loop).BranchNum, + UserZoneAirHVAC(CompNum).Loop(Loop).CompNum); + + PlantUtilities::RegisterPlantCompDesignFlow(UserZoneAirHVAC(CompNum).Loop(Loop).InletNodeNum, + UserZoneAirHVAC(CompNum).Loop(Loop).DesignVolumeFlowRate); } } } // BeginEnvrnFlag - InitZoneAirUserDefined(CompNum, ZoneNum); + UserZoneAirHVAC(CompNum).initialize(ZoneNum); if (UserZoneAirHVAC(CompNum).ErlSimProgramMngr > 0) { - ManageEMS(emsCallFromUserDefinedComponentModel, anyEMSRan, UserZoneAirHVAC(CompNum).ErlSimProgramMngr); + EMSManager::ManageEMS(DataGlobals::emsCallFromUserDefinedComponentModel, anyEMSRan, UserZoneAirHVAC(CompNum).ErlSimProgramMngr); } - ReportZoneAirUserDefined(CompNum); + UserZoneAirHVAC(CompNum).report(); // calculate delivered capacity - AirMassFlow = - min(Node(UserZoneAirHVAC(CompNum).ZoneAir.InletNodeNum).MassFlowRate, Node(UserZoneAirHVAC(CompNum).ZoneAir.OutletNodeNum).MassFlowRate); + Real64 AirMassFlow = min(DataLoopNode::Node(UserZoneAirHVAC(CompNum).ZoneAir.InletNodeNum).MassFlowRate, + DataLoopNode::Node(UserZoneAirHVAC(CompNum).ZoneAir.OutletNodeNum).MassFlowRate); // calculate sensible load met using delta enthalpy at a constant (minimum) humidity ratio) - MinHumRat = min(Node(UserZoneAirHVAC(CompNum).ZoneAir.InletNodeNum).HumRat, Node(UserZoneAirHVAC(CompNum).ZoneAir.OutletNodeNum).HumRat); - SensibleOutputProvided = AirMassFlow * (PsyHFnTdbW(Node(UserZoneAirHVAC(CompNum).ZoneAir.OutletNodeNum).Temp, MinHumRat) - - PsyHFnTdbW(Node(UserZoneAirHVAC(CompNum).ZoneAir.InletNodeNum).Temp, MinHumRat)); - - // CR9155 Remove specific humidity calculations - SpecHumOut = Node(UserZoneAirHVAC(CompNum).ZoneAir.OutletNodeNum).HumRat; - SpecHumIn = Node(UserZoneAirHVAC(CompNum).ZoneAir.InletNodeNum).HumRat; + Real64 MinHumRat = min(DataLoopNode::Node(UserZoneAirHVAC(CompNum).ZoneAir.InletNodeNum).HumRat, + DataLoopNode::Node(UserZoneAirHVAC(CompNum).ZoneAir.OutletNodeNum).HumRat); + SensibleOutputProvided = + AirMassFlow * (Psychrometrics::PsyHFnTdbW(DataLoopNode::Node(UserZoneAirHVAC(CompNum).ZoneAir.OutletNodeNum).Temp, MinHumRat) - + Psychrometrics::PsyHFnTdbW(DataLoopNode::Node(UserZoneAirHVAC(CompNum).ZoneAir.InletNodeNum).Temp, MinHumRat)); + + Real64 SpecHumOut = DataLoopNode::Node(UserZoneAirHVAC(CompNum).ZoneAir.OutletNodeNum).HumRat; + Real64 SpecHumIn = DataLoopNode::Node(UserZoneAirHVAC(CompNum).ZoneAir.InletNodeNum).HumRat; LatentOutputProvided = AirMassFlow * (SpecHumOut - SpecHumIn); // Latent rate, kg/s (dehumid = negative) } @@ -488,16 +428,7 @@ namespace UserDefinedComponents { // PURPOSE OF THIS SUBROUTINE: // simulation call for generic air terminal - // Using/Aliasing - using EMSManager::ManageEMS; - using General::TrimSigDigits; - using PlantUtilities::InitComponentNodes; - using PlantUtilities::RegisterPlantCompDesignFlow; - using PlantUtilities::SetComponentFlowRate; - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int CompNum; - int Loop; if (GetInput) { GetUserDefinedComponents(); @@ -514,148 +445,93 @@ namespace UserDefinedComponents { } else { CompNum = CompIndex; if (CompNum < 1 || CompNum > NumUserAirTerminals) { - ShowFatalError("SimUserDefinedPlantComponent: Invalid CompIndex passed=" + TrimSigDigits(CompNum) + - ", Number of units =" + TrimSigDigits(NumUserAirTerminals) + ", Entered Unit name = " + CompName); + ShowFatalError("SimUserDefinedPlantComponent: Invalid CompIndex passed=" + General::TrimSigDigits(CompNum) + + ", Number of units =" + General::TrimSigDigits(NumUserAirTerminals) + ", Entered Unit name = " + CompName); } if (CheckUserAirTerminal(CompNum)) { if (CompName != UserAirTerminal(CompNum).Name) { - ShowFatalError("SimUserDefinedPlantComponent: Invalid CompIndex passed=" + TrimSigDigits(CompNum) + ", Unit name=" + CompName + - ", stored unit name for that index=" + UserAirTerminal(CompNum).Name); + ShowFatalError("SimUserDefinedPlantComponent: Invalid CompIndex passed=" + General::TrimSigDigits(CompNum) + + ", Unit name=" + CompName + ", stored unit name for that index=" + UserAirTerminal(CompNum).Name); } CheckUserAirTerminal(CompNum) = false; } } bool anyEMSRan; - if (BeginEnvrnFlag) { - InitAirTerminalUserDefined(CompNum, ZoneNum); + if (DataGlobals::BeginEnvrnFlag) { + UserAirTerminal(CompNum).initialize(ZoneNum); if (UserAirTerminal(CompNum).ErlInitProgramMngr > 0) { - ManageEMS(emsCallFromUserDefinedComponentModel, anyEMSRan, UserAirTerminal(CompNum).ErlInitProgramMngr); + EMSManager::ManageEMS(DataGlobals::emsCallFromUserDefinedComponentModel, anyEMSRan, UserAirTerminal(CompNum).ErlInitProgramMngr); } if (UserAirTerminal(CompNum).NumPlantConnections > 0) { - for (Loop = 1; Loop <= UserAirTerminal(CompNum).NumPlantConnections; ++Loop) { - - InitComponentNodes(UserAirTerminal(CompNum).Loop(Loop).MassFlowRateMin, - UserAirTerminal(CompNum).Loop(Loop).MassFlowRateMax, - UserAirTerminal(CompNum).Loop(Loop).InletNodeNum, - UserAirTerminal(CompNum).Loop(Loop).OutletNodeNum, - UserAirTerminal(CompNum).Loop(Loop).LoopNum, - UserAirTerminal(CompNum).Loop(Loop).LoopSideNum, - UserAirTerminal(CompNum).Loop(Loop).BranchNum, - UserAirTerminal(CompNum).Loop(Loop).CompNum); - - RegisterPlantCompDesignFlow(UserAirTerminal(CompNum).Loop(Loop).InletNodeNum, - UserAirTerminal(CompNum).Loop(Loop).DesignVolumeFlowRate); + for (int Loop = 1; Loop <= UserAirTerminal(CompNum).NumPlantConnections; ++Loop) { + + PlantUtilities::InitComponentNodes(UserAirTerminal(CompNum).Loop(Loop).MassFlowRateMin, + UserAirTerminal(CompNum).Loop(Loop).MassFlowRateMax, + UserAirTerminal(CompNum).Loop(Loop).InletNodeNum, + UserAirTerminal(CompNum).Loop(Loop).OutletNodeNum, + UserAirTerminal(CompNum).Loop(Loop).LoopNum, + UserAirTerminal(CompNum).Loop(Loop).LoopSideNum, + UserAirTerminal(CompNum).Loop(Loop).BranchNum, + UserAirTerminal(CompNum).Loop(Loop).CompNum); + + PlantUtilities::RegisterPlantCompDesignFlow(UserAirTerminal(CompNum).Loop(Loop).InletNodeNum, + UserAirTerminal(CompNum).Loop(Loop).DesignVolumeFlowRate); } } } // BeginEnvrnFlag - InitAirTerminalUserDefined(CompNum, ZoneNum); + UserAirTerminal(CompNum).initialize(ZoneNum); if (UserAirTerminal(CompNum).ErlSimProgramMngr > 0) { - ManageEMS(emsCallFromUserDefinedComponentModel, anyEMSRan, UserAirTerminal(CompNum).ErlSimProgramMngr); + EMSManager::ManageEMS(DataGlobals::emsCallFromUserDefinedComponentModel, anyEMSRan, UserAirTerminal(CompNum).ErlSimProgramMngr); } - ReportAirTerminalUserDefined(CompNum); + UserAirTerminal(CompNum).report(); } - void GetUserDefinedComponents() + void GetUserDefinedPlantComponents() { - - // SUBROUTINE INFORMATION: - // AUTHOR B. Griffith - // DATE WRITTEN Jan 2012 - // MODIFIED na - // RE-ENGINEERED na - - // PURPOSE OF THIS SUBROUTINE: - // - - // Using/Aliasing - using BranchNodeConnections::TestCompSet; - using DataHeatBalance::IntGainTypeOf_AirTerminalUserDefined; - using DataHeatBalance::IntGainTypeOf_CoilUserDefined; - using DataHeatBalance::IntGainTypeOf_PlantComponentUserDefined; - using DataHeatBalance::IntGainTypeOf_ZoneHVACForcedAirUserDefined; - using DataHeatBalance::Zone; - using DataZoneEquipment::ZoneEquipConfig; - using General::RoundSigDigits; - using GlobalNames::VerifyUniqueCoilName; - using NodeInputManager::GetOnlySingleNode; - using WaterManager::SetupTankDemandComponent; - using WaterManager::SetupTankSupplyComponent; - - // SUBROUTINE PARAMETER DEFINITIONS: static ObjexxFCL::gio::Fmt fmtLD("*"); - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - static bool ErrorsFound(false); - int NumAlphas; // Number of elements in the alpha array - int NumNums; // Number of elements in the numeric array - int IOStat; // IO Status when calling get input subroutine - static int MaxNumAlphas(0); // argument for call to GetObjectDefMaxArgs - static int MaxNumNumbers(0); // argument for call to GetObjectDefMaxArgs - static int TotalArgs(0); // argument for call to GetObjectDefMaxArgs + bool ErrorsFound(false); + int NumAlphas; // Number of elements in the alpha array + int NumNums; // Number of elements in the numeric array + int IOStat; // IO Status when calling get input subroutine + int TotalArgs; // argument for call to GetObjectDefMaxArgs Array1D_string cAlphaFieldNames; - Array1D_string cNumericFieldNames; - Array1D_bool lNumericFieldBlanks; Array1D_bool lAlphaFieldBlanks; Array1D_string cAlphaArgs; Array1D rNumericArgs; std::string cCurrentModuleObject; - int CompLoop; - int ConnectionLoop; - int NumPlantConnections; - int NumAirConnections; std::string LoopStr; - int aArgCount; - int StackMngrNum; static bool lDummy; // Fix Changed to static: Passed to SetupEMSActuator as source of persistent Reference - // INTEGER :: alphaNum - // INTEGER :: Loop - int MgrCountTest; - int CtrlZone; // controlled zone do loop index - int SupAirIn; // controlled zone supply air inlet index cCurrentModuleObject = "PlantComponent:UserDefined"; inputProcessor->getObjectDefMaxArgs(cCurrentModuleObject, TotalArgs, NumAlphas, NumNums); - MaxNumNumbers = NumNums; - MaxNumAlphas = NumAlphas; - cAlphaFieldNames.allocate(MaxNumAlphas); - cAlphaArgs.allocate(MaxNumAlphas); - lAlphaFieldBlanks.dimension(MaxNumAlphas, false); - cNumericFieldNames.allocate(MaxNumNumbers); - rNumericArgs.dimension(MaxNumNumbers, 0.0); - lNumericFieldBlanks.dimension(MaxNumNumbers, false); + cAlphaFieldNames.allocate(NumAlphas); + cAlphaArgs.allocate(NumAlphas); + lAlphaFieldBlanks.dimension(NumAlphas, false); + rNumericArgs.dimension(NumNums, 0.0); // need to make sure GetEMSInput has run... - cCurrentModuleObject = "PlantComponent:UserDefined"; NumUserPlantComps = inputProcessor->getNumObjectsFound(cCurrentModuleObject); if (NumUserPlantComps > 0) { UserPlantComp.allocate(NumUserPlantComps); CheckUserPlantCompName.dimension(NumUserPlantComps, true); - for (CompLoop = 1; CompLoop <= NumUserPlantComps; ++CompLoop) { - inputProcessor->getObjectItem(cCurrentModuleObject, - CompLoop, - cAlphaArgs, - NumAlphas, - rNumericArgs, - NumNums, - IOStat, - lNumericFieldBlanks, - lAlphaFieldBlanks, - cAlphaFieldNames, - cNumericFieldNames); + for (int CompLoop = 1; CompLoop <= NumUserPlantComps; ++CompLoop) { + inputProcessor->getObjectItem( + cCurrentModuleObject, CompLoop, cAlphaArgs, NumAlphas, rNumericArgs, NumNums, IOStat, _, lAlphaFieldBlanks, cAlphaFieldNames, _); UtilityRoutines::IsNameEmpty(cAlphaArgs(1), cCurrentModuleObject, ErrorsFound); UserPlantComp(CompLoop).Name = cAlphaArgs(1); // now get program manager for model simulations if (!lAlphaFieldBlanks(2)) { - StackMngrNum = UtilityRoutines::FindItemInList(cAlphaArgs(2), EMSProgramCallManager); + int StackMngrNum = UtilityRoutines::FindItemInList(cAlphaArgs(2), DataRuntimeLanguage::EMSProgramCallManager); if (StackMngrNum > 0) { // found it UserPlantComp(CompLoop).ErlSimProgramMngr = StackMngrNum; } else { @@ -666,43 +542,46 @@ namespace UserDefinedComponents { } } - NumPlantConnections = std::floor(rNumericArgs(1)); + int NumPlantConnections = std::floor(rNumericArgs(1)); if ((NumPlantConnections >= 1) && (NumPlantConnections <= 4)) { UserPlantComp(CompLoop).Loop.allocate(NumPlantConnections); UserPlantComp(CompLoop).NumPlantConnections = NumPlantConnections; - for (ConnectionLoop = 1; ConnectionLoop <= NumPlantConnections; ++ConnectionLoop) { - LoopStr = RoundSigDigits(ConnectionLoop); - aArgCount = (ConnectionLoop - 1) * 6 + 3; - UserPlantComp(CompLoop).Loop(ConnectionLoop).InletNodeNum = GetOnlySingleNode(cAlphaArgs(aArgCount), - ErrorsFound, - cCurrentModuleObject, - cAlphaArgs(1), - NodeType_Water, - NodeConnectionType_Inlet, - ConnectionLoop, - ObjectIsNotParent); - UserPlantComp(CompLoop).Loop(ConnectionLoop).OutletNodeNum = GetOnlySingleNode(cAlphaArgs(aArgCount + 1), - ErrorsFound, - cCurrentModuleObject, - cAlphaArgs(1), - NodeType_Water, - NodeConnectionType_Outlet, - ConnectionLoop, - ObjectIsNotParent); - - TestCompSet(cCurrentModuleObject, cAlphaArgs(1), cAlphaArgs(aArgCount), cAlphaArgs(aArgCount + 1), "Plant Nodes " + LoopStr); + for (int ConnectionLoop = 1; ConnectionLoop <= NumPlantConnections; ++ConnectionLoop) { + LoopStr = General::RoundSigDigits(ConnectionLoop); + int aArgCount = (ConnectionLoop - 1) * 6 + 3; + UserPlantComp(CompLoop).Loop(ConnectionLoop).InletNodeNum = + NodeInputManager::GetOnlySingleNode(cAlphaArgs(aArgCount), + ErrorsFound, + cCurrentModuleObject, + cAlphaArgs(1), + DataLoopNode::NodeType_Water, + DataLoopNode::NodeConnectionType_Inlet, + ConnectionLoop, + DataLoopNode::ObjectIsNotParent); + UserPlantComp(CompLoop).Loop(ConnectionLoop).OutletNodeNum = + NodeInputManager::GetOnlySingleNode(cAlphaArgs(aArgCount + 1), + ErrorsFound, + cCurrentModuleObject, + cAlphaArgs(1), + DataLoopNode::NodeType_Water, + DataLoopNode::NodeConnectionType_Outlet, + ConnectionLoop, + DataLoopNode::ObjectIsNotParent); + + BranchNodeConnections::TestCompSet( + cCurrentModuleObject, cAlphaArgs(1), cAlphaArgs(aArgCount), cAlphaArgs(aArgCount + 1), "Plant Nodes " + LoopStr); { auto const SELECT_CASE_var(cAlphaArgs(aArgCount + 2)); if (SELECT_CASE_var == "DEMANDSLOAD") { - UserPlantComp(CompLoop).Loop(ConnectionLoop).HowLoadServed = HowMet_NoneDemand; + UserPlantComp(CompLoop).Loop(ConnectionLoop).HowLoadServed = DataPlant::HowMet_NoneDemand; } else if (SELECT_CASE_var == "MEETSLOADWITHPASSIVECAPACITY") { - UserPlantComp(CompLoop).Loop(ConnectionLoop).HowLoadServed = HowMet_PassiveCap; + UserPlantComp(CompLoop).Loop(ConnectionLoop).HowLoadServed = DataPlant::HowMet_PassiveCap; } else if (SELECT_CASE_var == "MEETSLOADWITHNOMINALCAPACITY") { - UserPlantComp(CompLoop).Loop(ConnectionLoop).HowLoadServed = HowMet_ByNominalCap; + UserPlantComp(CompLoop).Loop(ConnectionLoop).HowLoadServed = DataPlant::HowMet_ByNominalCap; } else if (SELECT_CASE_var == "MEETSLOADWITHNOMINALCAPACITYLOWOUTLIMIT") { - UserPlantComp(CompLoop).Loop(ConnectionLoop).HowLoadServed = HowMet_ByNominalCapLowOutLimit; + UserPlantComp(CompLoop).Loop(ConnectionLoop).HowLoadServed = DataPlant::HowMet_ByNominalCapLowOutLimit; // actuator for low out limit SetupEMSActuator("Plant Connection " + LoopStr, UserPlantComp(CompLoop).Name, @@ -711,7 +590,7 @@ namespace UserDefinedComponents { lDummy, UserPlantComp(CompLoop).Loop(ConnectionLoop).LowOutTempLimit); } else if (SELECT_CASE_var == "MEETSLOADWITHNOMINALCAPACITYHIOUTLIMIT") { - UserPlantComp(CompLoop).Loop(ConnectionLoop).HowLoadServed = HowMet_ByNominalCapHiOutLimit; + UserPlantComp(CompLoop).Loop(ConnectionLoop).HowLoadServed = DataPlant::HowMet_ByNominalCapHiOutLimit; // actuator for hi out limit SetupEMSActuator("Plant Connection " + LoopStr, UserPlantComp(CompLoop).Name, @@ -725,17 +604,17 @@ namespace UserDefinedComponents { { auto const SELECT_CASE_var(cAlphaArgs(aArgCount + 3)); if (SELECT_CASE_var == "NEEDSFLOWIFLOOPON") { - UserPlantComp(CompLoop).Loop(ConnectionLoop).FlowPriority = LoopFlowStatus_NeedyIfLoopOn; + UserPlantComp(CompLoop).Loop(ConnectionLoop).FlowPriority = DataPlant::LoopFlowStatus_NeedyIfLoopOn; } else if (SELECT_CASE_var == "NEEDSFLOWANDTURNSLOOPON") { - UserPlantComp(CompLoop).Loop(ConnectionLoop).FlowPriority = LoopFlowStatus_NeedyAndTurnsLoopOn; + UserPlantComp(CompLoop).Loop(ConnectionLoop).FlowPriority = DataPlant::LoopFlowStatus_NeedyAndTurnsLoopOn; } else if (SELECT_CASE_var == "RECEIVESWHATEVERFLOWAVAILABLE") { - UserPlantComp(CompLoop).Loop(ConnectionLoop).FlowPriority = LoopFlowStatus_TakesWhatGets; + UserPlantComp(CompLoop).Loop(ConnectionLoop).FlowPriority = DataPlant::LoopFlowStatus_TakesWhatGets; } } // find program manager for initial setup, begin environment and sizing of this plant connection if (!lAlphaFieldBlanks(aArgCount + 4)) { - StackMngrNum = UtilityRoutines::FindItemInList(cAlphaArgs(aArgCount + 4), EMSProgramCallManager); + int StackMngrNum = UtilityRoutines::FindItemInList(cAlphaArgs(aArgCount + 4), DataRuntimeLanguage::EMSProgramCallManager); if (StackMngrNum > 0) { // found it UserPlantComp(CompLoop).Loop(ConnectionLoop).ErlInitProgramMngr = StackMngrNum; } else { @@ -748,7 +627,7 @@ namespace UserDefinedComponents { // find program to call for model simulations for just this plant connection if (!lAlphaFieldBlanks(aArgCount + 5)) { - StackMngrNum = UtilityRoutines::FindItemInList(cAlphaArgs(aArgCount + 5), EMSProgramCallManager); + int StackMngrNum = UtilityRoutines::FindItemInList(cAlphaArgs(aArgCount + 5), DataRuntimeLanguage::EMSProgramCallManager); if (StackMngrNum > 0) { // found it UserPlantComp(CompLoop).Loop(ConnectionLoop).ErlSimProgramMngr = StackMngrNum; } else { @@ -768,7 +647,7 @@ namespace UserDefinedComponents { UserPlantComp(CompLoop).Name, "[kg/s]", UserPlantComp(CompLoop).Loop(ConnectionLoop).InletMassFlowRate); - if (UserPlantComp(CompLoop).Loop(ConnectionLoop).HowLoadServed != HowMet_NoneDemand) { + if (UserPlantComp(CompLoop).Loop(ConnectionLoop).HowLoadServed != DataPlant::HowMet_NoneDemand) { SetupEMSInternalVariable("Load Request for Plant Connection " + LoopStr, UserPlantComp(CompLoop).Name, "[W]", @@ -836,14 +715,15 @@ namespace UserDefinedComponents { } if (!lAlphaFieldBlanks(27)) { - UserPlantComp(CompLoop).Air.InletNodeNum = GetOnlySingleNode(cAlphaArgs(27), - ErrorsFound, - cCurrentModuleObject, - UserPlantComp(CompLoop).Name, - NodeType_Air, - NodeConnectionType_OutsideAirReference, - 1, - ObjectIsNotParent); + UserPlantComp(CompLoop).Air.InletNodeNum = + NodeInputManager::GetOnlySingleNode(cAlphaArgs(27), + ErrorsFound, + cCurrentModuleObject, + UserPlantComp(CompLoop).Name, + DataLoopNode::NodeType_Air, + DataLoopNode::NodeConnectionType_OutsideAirReference, + 1, + DataLoopNode::ObjectIsNotParent); // model input related internal variables SetupEMSInternalVariable( "Inlet Temperature for Air Connection", UserPlantComp(CompLoop).Name, "[C]", UserPlantComp(CompLoop).Air.InletTemp); @@ -862,14 +742,14 @@ namespace UserDefinedComponents { } if (!lAlphaFieldBlanks(28)) { - UserPlantComp(CompLoop).Air.OutletNodeNum = GetOnlySingleNode(cAlphaArgs(28), - ErrorsFound, - cCurrentModuleObject, - UserPlantComp(CompLoop).Name, - NodeType_Air, - NodeConnectionType_ReliefAir, - 1, - ObjectIsNotParent); + UserPlantComp(CompLoop).Air.OutletNodeNum = NodeInputManager::GetOnlySingleNode(cAlphaArgs(28), + ErrorsFound, + cCurrentModuleObject, + UserPlantComp(CompLoop).Name, + DataLoopNode::NodeType_Air, + DataLoopNode::NodeConnectionType_ReliefAir, + 1, + DataLoopNode::ObjectIsNotParent); // outlet air node results SetupEMSActuator( "Air Connection", UserPlantComp(CompLoop).Name, "Outlet Temperature", "[C]", lDummy, UserPlantComp(CompLoop).Air.OutletTemp); @@ -888,12 +768,12 @@ namespace UserDefinedComponents { } if (!lAlphaFieldBlanks(29)) { - SetupTankDemandComponent(cAlphaArgs(1), - cCurrentModuleObject, - cAlphaArgs(29), - ErrorsFound, - UserPlantComp(CompLoop).Water.SupplyTankID, - UserPlantComp(CompLoop).Water.SupplyTankDemandARRID); + WaterManager::SetupTankDemandComponent(cAlphaArgs(1), + cCurrentModuleObject, + cAlphaArgs(29), + ErrorsFound, + UserPlantComp(CompLoop).Water.SupplyTankID, + UserPlantComp(CompLoop).Water.SupplyTankDemandARRID); UserPlantComp(CompLoop).Water.SuppliedByWaterSystem = true; SetupEMSActuator("Water System", @@ -905,12 +785,12 @@ namespace UserDefinedComponents { } if (!lAlphaFieldBlanks(30)) { - SetupTankSupplyComponent(cAlphaArgs(1), - cCurrentModuleObject, - cAlphaArgs(30), - ErrorsFound, - UserPlantComp(CompLoop).Water.CollectionTankID, - UserPlantComp(CompLoop).Water.CollectionTankSupplyARRID); + WaterManager::SetupTankSupplyComponent(cAlphaArgs(1), + cCurrentModuleObject, + cAlphaArgs(30), + ErrorsFound, + UserPlantComp(CompLoop).Water.CollectionTankID, + UserPlantComp(CompLoop).Water.CollectionTankSupplyARRID); UserPlantComp(CompLoop).Water.CollectsToWaterSystem = true; SetupEMSActuator("Water System", UserPlantComp(CompLoop).Name, @@ -922,7 +802,7 @@ namespace UserDefinedComponents { if (!lAlphaFieldBlanks(31)) { - UserPlantComp(CompLoop).Zone.ZoneNum = UtilityRoutines::FindItemInList(cAlphaArgs(31), Zone); + UserPlantComp(CompLoop).Zone.ZoneNum = UtilityRoutines::FindItemInList(cAlphaArgs(31), DataHeatBalance::Zone); if (UserPlantComp(CompLoop).Zone.ZoneNum == 0) { ShowSevereError(cCurrentModuleObject + " = " + cAlphaArgs(1) + ": Ambient Zone Name not found = " + cAlphaArgs(31)); ErrorsFound = true; @@ -931,7 +811,7 @@ namespace UserDefinedComponents { SetupZoneInternalGain(UserPlantComp(CompLoop).Zone.ZoneNum, cCurrentModuleObject, cAlphaArgs(1), - IntGainTypeOf_PlantComponentUserDefined, + DataHeatBalance::IntGainTypeOf_PlantComponentUserDefined, UserPlantComp(CompLoop).Zone.ConvectionGainRate, UserPlantComp(CompLoop).Zone.ReturnAirConvectionGainRate, UserPlantComp(CompLoop).Zone.ThermalRadiationGainRate, @@ -986,9 +866,9 @@ namespace UserDefinedComponents { } // make sure user has entered at least some erl program managers to actually calculate something - MgrCountTest = 0; + int MgrCountTest = 0; if (UserPlantComp(CompLoop).ErlSimProgramMngr > 0) MgrCountTest = 1; - for (ConnectionLoop = 1; ConnectionLoop <= NumPlantConnections; ++ConnectionLoop) { + for (int ConnectionLoop = 1; ConnectionLoop <= NumPlantConnections; ++ConnectionLoop) { if (UserPlantComp(CompLoop).Loop(ConnectionLoop).ErlInitProgramMngr > 0) ++MgrCountTest; if (UserPlantComp(CompLoop).Loop(ConnectionLoop).ErlSimProgramMngr > 0) ++MgrCountTest; } @@ -1005,32 +885,31 @@ namespace UserDefinedComponents { } cCurrentModuleObject = "Coil:UserDefined"; + inputProcessor->getObjectDefMaxArgs(cCurrentModuleObject, TotalArgs, NumAlphas, NumNums); + + cAlphaFieldNames.allocate(NumAlphas); + cAlphaArgs.allocate(NumAlphas); + lAlphaFieldBlanks.dimension(NumAlphas, false); + rNumericArgs.dimension(NumNums, 0.0); + NumUserCoils = inputProcessor->getNumObjectsFound(cCurrentModuleObject); + if (NumUserCoils > 0) { UserCoil.allocate(NumUserCoils); CheckUserCoilName.dimension(NumUserCoils, true); - for (CompLoop = 1; CompLoop <= NumUserCoils; ++CompLoop) { - inputProcessor->getObjectItem(cCurrentModuleObject, - CompLoop, - cAlphaArgs, - NumAlphas, - rNumericArgs, - NumNums, - IOStat, - lNumericFieldBlanks, - lAlphaFieldBlanks, - cAlphaFieldNames, - cNumericFieldNames); + for (int CompLoop = 1; CompLoop <= NumUserCoils; ++CompLoop) { + inputProcessor->getObjectItem( + cCurrentModuleObject, CompLoop, cAlphaArgs, NumAlphas, rNumericArgs, NumNums, IOStat, _, lAlphaFieldBlanks, cAlphaFieldNames, _); UtilityRoutines::IsNameEmpty(cAlphaArgs(1), cCurrentModuleObject, ErrorsFound); // ErrorsFound will be set to True if problem was found, left untouched otherwise - VerifyUniqueCoilName(cCurrentModuleObject, cAlphaArgs(1), ErrorsFound, cCurrentModuleObject + " Name"); + GlobalNames::VerifyUniqueCoilName(cCurrentModuleObject, cAlphaArgs(1), ErrorsFound, cCurrentModuleObject + " Name"); UserCoil(CompLoop).Name = cAlphaArgs(1); // now get program manager for model simulations if (!lAlphaFieldBlanks(2)) { - StackMngrNum = UtilityRoutines::FindItemInList(cAlphaArgs(2), EMSProgramCallManager); + int StackMngrNum = UtilityRoutines::FindItemInList(cAlphaArgs(2), DataRuntimeLanguage::EMSProgramCallManager); if (StackMngrNum > 0) { // found it UserCoil(CompLoop).ErlSimProgramMngr = StackMngrNum; } else { @@ -1043,7 +922,7 @@ namespace UserDefinedComponents { // now get program manager for model initializations if (!lAlphaFieldBlanks(3)) { - StackMngrNum = UtilityRoutines::FindItemInList(cAlphaArgs(3), EMSProgramCallManager); + int StackMngrNum = UtilityRoutines::FindItemInList(cAlphaArgs(3), DataRuntimeLanguage::EMSProgramCallManager); if (StackMngrNum > 0) { // found it UserCoil(CompLoop).ErlInitProgramMngr = StackMngrNum; } else { @@ -1054,22 +933,23 @@ namespace UserDefinedComponents { } } - NumAirConnections = std::floor(rNumericArgs(1)); + int NumAirConnections = std::floor(rNumericArgs(1)); if ((NumAirConnections >= 1) && (NumAirConnections <= 2)) { UserCoil(CompLoop).Air.allocate(NumAirConnections); UserCoil(CompLoop).NumAirConnections = NumAirConnections; - for (ConnectionLoop = 1; ConnectionLoop <= NumAirConnections; ++ConnectionLoop) { - aArgCount = (ConnectionLoop - 1) * 2 + 4; - UserCoil(CompLoop).Air(ConnectionLoop).InletNodeNum = GetOnlySingleNode(cAlphaArgs(aArgCount), - ErrorsFound, - cCurrentModuleObject, - UserCoil(CompLoop).Name, - NodeType_Air, - NodeConnectionType_Inlet, - 1, - ObjectIsNotParent); - - LoopStr = RoundSigDigits(ConnectionLoop); + for (int ConnectionLoop = 1; ConnectionLoop <= NumAirConnections; ++ConnectionLoop) { + int aArgCount = (ConnectionLoop - 1) * 2 + 4; + UserCoil(CompLoop).Air(ConnectionLoop).InletNodeNum = + NodeInputManager::GetOnlySingleNode(cAlphaArgs(aArgCount), + ErrorsFound, + cCurrentModuleObject, + UserCoil(CompLoop).Name, + DataLoopNode::NodeType_Air, + DataLoopNode::NodeConnectionType_Inlet, + 1, + DataLoopNode::ObjectIsNotParent); + + LoopStr = General::RoundSigDigits(ConnectionLoop); // model input related internal variables SetupEMSInternalVariable("Inlet Temperature for Air Connection " + LoopStr, UserCoil(CompLoop).Name, @@ -1092,14 +972,15 @@ namespace UserDefinedComponents { "[J/kg-C]", UserCoil(CompLoop).Air(ConnectionLoop).InletCp); - UserCoil(CompLoop).Air(ConnectionLoop).OutletNodeNum = GetOnlySingleNode(cAlphaArgs(aArgCount + 1), - ErrorsFound, - cCurrentModuleObject, - UserCoil(CompLoop).Name, - NodeType_Air, - NodeConnectionType_Outlet, - 1, - ObjectIsNotParent); + UserCoil(CompLoop).Air(ConnectionLoop).OutletNodeNum = + NodeInputManager::GetOnlySingleNode(cAlphaArgs(aArgCount + 1), + ErrorsFound, + cCurrentModuleObject, + UserCoil(CompLoop).Name, + DataLoopNode::NodeType_Air, + DataLoopNode::NodeConnectionType_Outlet, + 1, + DataLoopNode::ObjectIsNotParent); SetupEMSActuator("Air Connection " + LoopStr, UserCoil(CompLoop).Name, "Outlet Temperature", @@ -1119,7 +1000,8 @@ namespace UserDefinedComponents { lDummy, UserCoil(CompLoop).Air(ConnectionLoop).OutletMassFlowRate); - TestCompSet(cCurrentModuleObject, cAlphaArgs(1), cAlphaArgs(aArgCount), cAlphaArgs(aArgCount + 1), "Air Nodes " + LoopStr); + BranchNodeConnections::TestCompSet( + cCurrentModuleObject, cAlphaArgs(1), cAlphaArgs(aArgCount), cAlphaArgs(aArgCount + 1), "Air Nodes " + LoopStr); } if (!lAlphaFieldBlanks(8)) { @@ -1138,29 +1020,29 @@ namespace UserDefinedComponents { } if (UserCoil(CompLoop).PlantIsConnected) { // get input - UserCoil(CompLoop).Loop.InletNodeNum = GetOnlySingleNode(cAlphaArgs(9), - ErrorsFound, - cCurrentModuleObject, - cAlphaArgs(1), - NodeType_Water, - NodeConnectionType_Inlet, - 2, - ObjectIsNotParent); - UserCoil(CompLoop).Loop.OutletNodeNum = GetOnlySingleNode(cAlphaArgs(10), - ErrorsFound, - cCurrentModuleObject, - cAlphaArgs(1), - NodeType_Water, - NodeConnectionType_Outlet, - 2, - ObjectIsNotParent); - - TestCompSet(cCurrentModuleObject, cAlphaArgs(1), cAlphaArgs(9), cAlphaArgs(10), "Plant Nodes"); + UserCoil(CompLoop).Loop.InletNodeNum = NodeInputManager::GetOnlySingleNode(cAlphaArgs(9), + ErrorsFound, + cCurrentModuleObject, + cAlphaArgs(1), + DataLoopNode::NodeType_Water, + DataLoopNode::NodeConnectionType_Inlet, + 2, + DataLoopNode::ObjectIsNotParent); + UserCoil(CompLoop).Loop.OutletNodeNum = NodeInputManager::GetOnlySingleNode(cAlphaArgs(10), + ErrorsFound, + cCurrentModuleObject, + cAlphaArgs(1), + DataLoopNode::NodeType_Water, + DataLoopNode::NodeConnectionType_Outlet, + 2, + DataLoopNode::ObjectIsNotParent); + + BranchNodeConnections::TestCompSet(cCurrentModuleObject, cAlphaArgs(1), cAlphaArgs(9), cAlphaArgs(10), "Plant Nodes"); // this model is only for plant connections that are "Demand" - UserCoil(CompLoop).Loop.HowLoadServed = HowMet_NoneDemand; + UserCoil(CompLoop).Loop.HowLoadServed = DataPlant::HowMet_NoneDemand; // this model is only for plant connections that are needy and turn loop on - UserCoil(CompLoop).Loop.FlowPriority = LoopFlowStatus_NeedyAndTurnsLoopOn; + UserCoil(CompLoop).Loop.FlowPriority = DataPlant::LoopFlowStatus_NeedyAndTurnsLoopOn; // Setup Internal Variables // model input related internal variables @@ -1206,12 +1088,12 @@ namespace UserDefinedComponents { } if (!lAlphaFieldBlanks(11)) { - SetupTankDemandComponent(cAlphaArgs(1), - cCurrentModuleObject, - cAlphaArgs(11), - ErrorsFound, - UserCoil(CompLoop).Water.SupplyTankID, - UserCoil(CompLoop).Water.SupplyTankDemandARRID); + WaterManager::SetupTankDemandComponent(cAlphaArgs(1), + cCurrentModuleObject, + cAlphaArgs(11), + ErrorsFound, + UserCoil(CompLoop).Water.SupplyTankID, + UserCoil(CompLoop).Water.SupplyTankDemandARRID); UserCoil(CompLoop).Water.SuppliedByWaterSystem = true; SetupEMSActuator("Water System", @@ -1223,12 +1105,12 @@ namespace UserDefinedComponents { } if (!lAlphaFieldBlanks(12)) { - SetupTankSupplyComponent(cAlphaArgs(1), - cCurrentModuleObject, - cAlphaArgs(12), - ErrorsFound, - UserCoil(CompLoop).Water.CollectionTankID, - UserCoil(CompLoop).Water.CollectionTankSupplyARRID); + WaterManager::SetupTankSupplyComponent(cAlphaArgs(1), + cCurrentModuleObject, + cAlphaArgs(12), + ErrorsFound, + UserCoil(CompLoop).Water.CollectionTankID, + UserCoil(CompLoop).Water.CollectionTankSupplyARRID); UserCoil(CompLoop).Water.CollectsToWaterSystem = true; SetupEMSActuator("Water System", UserCoil(CompLoop).Name, @@ -1240,7 +1122,7 @@ namespace UserDefinedComponents { if (!lAlphaFieldBlanks(13)) { - UserCoil(CompLoop).Zone.ZoneNum = UtilityRoutines::FindItemInList(cAlphaArgs(13), Zone); + UserCoil(CompLoop).Zone.ZoneNum = UtilityRoutines::FindItemInList(cAlphaArgs(13), DataHeatBalance::Zone); if (UserCoil(CompLoop).Zone.ZoneNum == 0) { ShowSevereError(cCurrentModuleObject + " = " + cAlphaArgs(1) + ": Ambient Zone Name not found = " + cAlphaArgs(13)); ErrorsFound = true; @@ -1249,7 +1131,7 @@ namespace UserDefinedComponents { SetupZoneInternalGain(UserCoil(CompLoop).Zone.ZoneNum, cCurrentModuleObject, cAlphaArgs(1), - IntGainTypeOf_CoilUserDefined, + DataHeatBalance::IntGainTypeOf_CoilUserDefined, UserCoil(CompLoop).Zone.ConvectionGainRate, UserCoil(CompLoop).Zone.ReturnAirConvectionGainRate, UserCoil(CompLoop).Zone.ThermalRadiationGainRate, @@ -1310,30 +1192,58 @@ namespace UserDefinedComponents { if (ErrorsFound) { ShowFatalError("GetUserDefinedComponents: Errors found in processing " + cCurrentModuleObject + " input."); } + } + + void GetUserDefinedComponents() + { + + // SUBROUTINE INFORMATION: + // AUTHOR B. Griffith + // DATE WRITTEN Jan 2012 + // MODIFIED na + // RE-ENGINEERED na + + static ObjexxFCL::gio::Fmt fmtLD("*"); + + bool ErrorsFound(false); + int NumAlphas; // Number of elements in the alpha array + int NumNums; // Number of elements in the numeric array + int IOStat; // IO Status when calling get input subroutine + int TotalArgs; // argument for call to GetObjectDefMaxArgs + Array1D_string cAlphaFieldNames; + Array1D_bool lAlphaFieldBlanks; + Array1D_string cAlphaArgs; + Array1D rNumericArgs; + std::string cCurrentModuleObject; + std::string LoopStr; + static bool lDummy; // Fix Changed to static: Passed to SetupEMSActuator as source of persistent Reference + + if (GetPlantCompInput) { + GetUserDefinedPlantComponents(); + GetPlantCompInput = false; + } cCurrentModuleObject = "ZoneHVAC:ForcedAir:UserDefined"; + inputProcessor->getObjectDefMaxArgs(cCurrentModuleObject, TotalArgs, NumAlphas, NumNums); + + cAlphaFieldNames.allocate(NumAlphas); + cAlphaArgs.allocate(NumAlphas); + lAlphaFieldBlanks.dimension(NumAlphas, false); + rNumericArgs.dimension(NumNums, 0.0); + NumUserZoneAir = inputProcessor->getNumObjectsFound(cCurrentModuleObject); if (NumUserZoneAir > 0) { UserZoneAirHVAC.allocate(NumUserZoneAir); CheckUserZoneAirName.dimension(NumUserZoneAir, true); - for (CompLoop = 1; CompLoop <= NumUserZoneAir; ++CompLoop) { - inputProcessor->getObjectItem(cCurrentModuleObject, - CompLoop, - cAlphaArgs, - NumAlphas, - rNumericArgs, - NumNums, - IOStat, - lNumericFieldBlanks, - lAlphaFieldBlanks, - cAlphaFieldNames, - cNumericFieldNames); + for (int CompLoop = 1; CompLoop <= NumUserZoneAir; ++CompLoop) { + inputProcessor->getObjectItem( + cCurrentModuleObject, CompLoop, cAlphaArgs, NumAlphas, rNumericArgs, NumNums, IOStat, _, lAlphaFieldBlanks, cAlphaFieldNames, _); UtilityRoutines::IsNameEmpty(cAlphaArgs(1), cCurrentModuleObject, ErrorsFound); UserZoneAirHVAC(CompLoop).Name = cAlphaArgs(1); // now get program manager for model simulations if (!lAlphaFieldBlanks(2)) { - StackMngrNum = UtilityRoutines::FindItemInList(cAlphaArgs(2), EMSProgramCallManager); + int StackMngrNum = UtilityRoutines::FindItemInList(cAlphaArgs(2), DataRuntimeLanguage::EMSProgramCallManager); if (StackMngrNum > 0) { // found it UserZoneAirHVAC(CompLoop).ErlSimProgramMngr = StackMngrNum; } else { @@ -1346,7 +1256,7 @@ namespace UserDefinedComponents { // now get program manager for model initializations if (!lAlphaFieldBlanks(3)) { - StackMngrNum = UtilityRoutines::FindItemInList(cAlphaArgs(3), EMSProgramCallManager); + int StackMngrNum = UtilityRoutines::FindItemInList(cAlphaArgs(3), DataRuntimeLanguage::EMSProgramCallManager); if (StackMngrNum > 0) { // found it UserZoneAirHVAC(CompLoop).ErlInitProgramMngr = StackMngrNum; } else { @@ -1357,14 +1267,14 @@ namespace UserDefinedComponents { } } - UserZoneAirHVAC(CompLoop).ZoneAir.InletNodeNum = GetOnlySingleNode(cAlphaArgs(4), - ErrorsFound, - cCurrentModuleObject, - UserZoneAirHVAC(CompLoop).Name, - NodeType_Air, - NodeConnectionType_Inlet, - 1, - ObjectIsNotParent); + UserZoneAirHVAC(CompLoop).ZoneAir.InletNodeNum = NodeInputManager::GetOnlySingleNode(cAlphaArgs(4), + ErrorsFound, + cCurrentModuleObject, + UserZoneAirHVAC(CompLoop).Name, + DataLoopNode::NodeType_Air, + DataLoopNode::NodeConnectionType_Inlet, + 1, + DataLoopNode::ObjectIsNotParent); // model input related internal variables SetupEMSInternalVariable("Inlet Temperature for Primary Air Connection", UserZoneAirHVAC(CompLoop).Name, @@ -1406,14 +1316,14 @@ namespace UserDefinedComponents { "[kg/s]", lDummy, UserZoneAirHVAC(CompLoop).ZoneAir.InletMassFlowRate); - UserZoneAirHVAC(CompLoop).ZoneAir.OutletNodeNum = GetOnlySingleNode(cAlphaArgs(5), - ErrorsFound, - cCurrentModuleObject, - UserZoneAirHVAC(CompLoop).Name, - NodeType_Air, - NodeConnectionType_Outlet, - 1, - ObjectIsNotParent); + UserZoneAirHVAC(CompLoop).ZoneAir.OutletNodeNum = NodeInputManager::GetOnlySingleNode(cAlphaArgs(5), + ErrorsFound, + cCurrentModuleObject, + UserZoneAirHVAC(CompLoop).Name, + DataLoopNode::NodeType_Air, + DataLoopNode::NodeConnectionType_Outlet, + 1, + DataLoopNode::ObjectIsNotParent); SetupEMSActuator("Primary Air Connection", UserZoneAirHVAC(CompLoop).Name, "Outlet Temperature", @@ -1434,14 +1344,14 @@ namespace UserDefinedComponents { UserZoneAirHVAC(CompLoop).ZoneAir.OutletMassFlowRate); if (!lAlphaFieldBlanks(6)) { - UserZoneAirHVAC(CompLoop).SourceAir.InletNodeNum = GetOnlySingleNode(cAlphaArgs(6), - ErrorsFound, - cCurrentModuleObject, - UserZoneAirHVAC(CompLoop).Name, - NodeType_Air, - NodeConnectionType_Inlet, - 2, - ObjectIsNotParent); + UserZoneAirHVAC(CompLoop).SourceAir.InletNodeNum = NodeInputManager::GetOnlySingleNode(cAlphaArgs(6), + ErrorsFound, + cCurrentModuleObject, + UserZoneAirHVAC(CompLoop).Name, + DataLoopNode::NodeType_Air, + DataLoopNode::NodeConnectionType_Inlet, + 2, + DataLoopNode::ObjectIsNotParent); // model input related internal variables SetupEMSInternalVariable("Inlet Temperature for Secondary Air Connection", UserZoneAirHVAC(CompLoop).Name, @@ -1469,14 +1379,14 @@ namespace UserDefinedComponents { } if (!lAlphaFieldBlanks(7)) { - UserZoneAirHVAC(CompLoop).SourceAir.OutletNodeNum = GetOnlySingleNode(cAlphaArgs(7), - ErrorsFound, - cCurrentModuleObject, - UserZoneAirHVAC(CompLoop).Name, - NodeType_Air, - NodeConnectionType_Outlet, - 2, - ObjectIsNotParent); + UserZoneAirHVAC(CompLoop).SourceAir.OutletNodeNum = NodeInputManager::GetOnlySingleNode(cAlphaArgs(7), + ErrorsFound, + cCurrentModuleObject, + UserZoneAirHVAC(CompLoop).Name, + DataLoopNode::NodeType_Air, + DataLoopNode::NodeConnectionType_Outlet, + 2, + DataLoopNode::ObjectIsNotParent); SetupEMSActuator("Secondary Air Connection", UserZoneAirHVAC(CompLoop).Name, "Outlet Temperature", @@ -1501,31 +1411,34 @@ namespace UserDefinedComponents { // CALL TestCompSet(TRIM(cCurrentModuleObject),cAlphaArgs(1),cAlphaArgs(6),cAlphaArgs(7),'Air Nodes') } - NumPlantConnections = std::floor(rNumericArgs(1)); + int NumPlantConnections = std::floor(rNumericArgs(1)); UserZoneAirHVAC(CompLoop).NumPlantConnections = NumPlantConnections; if ((NumPlantConnections >= 1) && (NumPlantConnections <= 3)) { UserZoneAirHVAC(CompLoop).Loop.allocate(NumPlantConnections); - for (ConnectionLoop = 1; ConnectionLoop <= NumPlantConnections; ++ConnectionLoop) { - aArgCount = (ConnectionLoop - 1) * 2 + 8; - UserZoneAirHVAC(CompLoop).Loop(ConnectionLoop).InletNodeNum = GetOnlySingleNode(cAlphaArgs(aArgCount), - ErrorsFound, - cCurrentModuleObject, - cAlphaArgs(1), - NodeType_Water, - NodeConnectionType_Inlet, - (ConnectionLoop + 2), - ObjectIsNotParent); - UserZoneAirHVAC(CompLoop).Loop(ConnectionLoop).OutletNodeNum = GetOnlySingleNode(cAlphaArgs(aArgCount + 1), - ErrorsFound, - cCurrentModuleObject, - cAlphaArgs(1), - NodeType_Water, - NodeConnectionType_Outlet, - (ConnectionLoop + 2), - ObjectIsNotParent); - TestCompSet(cCurrentModuleObject, cAlphaArgs(1), cAlphaArgs(aArgCount), cAlphaArgs(aArgCount + 1), "Plant Nodes"); - UserZoneAirHVAC(CompLoop).Loop(ConnectionLoop).HowLoadServed = HowMet_NoneDemand; - UserZoneAirHVAC(CompLoop).Loop(ConnectionLoop).FlowPriority = LoopFlowStatus_NeedyAndTurnsLoopOn; + for (int ConnectionLoop = 1; ConnectionLoop <= NumPlantConnections; ++ConnectionLoop) { + int aArgCount = (ConnectionLoop - 1) * 2 + 8; + UserZoneAirHVAC(CompLoop).Loop(ConnectionLoop).InletNodeNum = + NodeInputManager::GetOnlySingleNode(cAlphaArgs(aArgCount), + ErrorsFound, + cCurrentModuleObject, + cAlphaArgs(1), + DataLoopNode::NodeType_Water, + DataLoopNode::NodeConnectionType_Inlet, + (ConnectionLoop + 2), + DataLoopNode::ObjectIsNotParent); + UserZoneAirHVAC(CompLoop).Loop(ConnectionLoop).OutletNodeNum = + NodeInputManager::GetOnlySingleNode(cAlphaArgs(aArgCount + 1), + ErrorsFound, + cCurrentModuleObject, + cAlphaArgs(1), + DataLoopNode::NodeType_Water, + DataLoopNode::NodeConnectionType_Outlet, + (ConnectionLoop + 2), + DataLoopNode::ObjectIsNotParent); + BranchNodeConnections::TestCompSet( + cCurrentModuleObject, cAlphaArgs(1), cAlphaArgs(aArgCount), cAlphaArgs(aArgCount + 1), "Plant Nodes"); + UserZoneAirHVAC(CompLoop).Loop(ConnectionLoop).HowLoadServed = DataPlant::HowMet_NoneDemand; + UserZoneAirHVAC(CompLoop).Loop(ConnectionLoop).FlowPriority = DataPlant::LoopFlowStatus_NeedyAndTurnsLoopOn; // Setup Internal Variables ObjexxFCL::gio::write(LoopStr, fmtLD) << ConnectionLoop; strip(LoopStr); @@ -1582,12 +1495,12 @@ namespace UserDefinedComponents { } if (!lAlphaFieldBlanks(14)) { - SetupTankDemandComponent(cAlphaArgs(1), - cCurrentModuleObject, - cAlphaArgs(14), - ErrorsFound, - UserZoneAirHVAC(CompLoop).Water.SupplyTankID, - UserZoneAirHVAC(CompLoop).Water.SupplyTankDemandARRID); + WaterManager::SetupTankDemandComponent(cAlphaArgs(1), + cCurrentModuleObject, + cAlphaArgs(14), + ErrorsFound, + UserZoneAirHVAC(CompLoop).Water.SupplyTankID, + UserZoneAirHVAC(CompLoop).Water.SupplyTankDemandARRID); UserZoneAirHVAC(CompLoop).Water.SuppliedByWaterSystem = true; SetupEMSActuator("Water System", @@ -1599,12 +1512,12 @@ namespace UserDefinedComponents { } if (!lAlphaFieldBlanks(15)) { - SetupTankSupplyComponent(cAlphaArgs(1), - cCurrentModuleObject, - cAlphaArgs(15), - ErrorsFound, - UserZoneAirHVAC(CompLoop).Water.CollectionTankID, - UserZoneAirHVAC(CompLoop).Water.CollectionTankSupplyARRID); + WaterManager::SetupTankSupplyComponent(cAlphaArgs(1), + cCurrentModuleObject, + cAlphaArgs(15), + ErrorsFound, + UserZoneAirHVAC(CompLoop).Water.CollectionTankID, + UserZoneAirHVAC(CompLoop).Water.CollectionTankSupplyARRID); UserZoneAirHVAC(CompLoop).Water.CollectsToWaterSystem = true; SetupEMSActuator("Water System", UserZoneAirHVAC(CompLoop).Name, @@ -1616,7 +1529,7 @@ namespace UserDefinedComponents { if (!lAlphaFieldBlanks(16)) { - UserZoneAirHVAC(CompLoop).Zone.ZoneNum = UtilityRoutines::FindItemInList(cAlphaArgs(16), Zone); + UserZoneAirHVAC(CompLoop).Zone.ZoneNum = UtilityRoutines::FindItemInList(cAlphaArgs(16), DataHeatBalance::Zone); if (UserZoneAirHVAC(CompLoop).Zone.ZoneNum == 0) { ShowSevereError(cCurrentModuleObject + " = " + cAlphaArgs(1) + ": Ambient Zone Name not found = " + cAlphaArgs(16)); ErrorsFound = true; @@ -1625,7 +1538,7 @@ namespace UserDefinedComponents { SetupZoneInternalGain(UserZoneAirHVAC(CompLoop).Zone.ZoneNum, cCurrentModuleObject, cAlphaArgs(1), - IntGainTypeOf_ZoneHVACForcedAirUserDefined, + DataHeatBalance::IntGainTypeOf_ZoneHVACForcedAirUserDefined, UserZoneAirHVAC(CompLoop).Zone.ConvectionGainRate, UserZoneAirHVAC(CompLoop).Zone.ReturnAirConvectionGainRate, UserZoneAirHVAC(CompLoop).Zone.ThermalRadiationGainRate, @@ -1686,28 +1599,27 @@ namespace UserDefinedComponents { } cCurrentModuleObject = "AirTerminal:SingleDuct:UserDefined"; + + inputProcessor->getObjectDefMaxArgs(cCurrentModuleObject, TotalArgs, NumAlphas, NumNums); + + cAlphaFieldNames.allocate(NumAlphas); + cAlphaArgs.allocate(NumAlphas); + lAlphaFieldBlanks.dimension(NumAlphas, false); + rNumericArgs.dimension(NumNums, 0.0); + NumUserAirTerminals = inputProcessor->getNumObjectsFound(cCurrentModuleObject); if (NumUserAirTerminals > 0) { UserAirTerminal.allocate(NumUserAirTerminals); CheckUserAirTerminal.dimension(NumUserAirTerminals, true); - for (CompLoop = 1; CompLoop <= NumUserAirTerminals; ++CompLoop) { - inputProcessor->getObjectItem(cCurrentModuleObject, - CompLoop, - cAlphaArgs, - NumAlphas, - rNumericArgs, - NumNums, - IOStat, - lNumericFieldBlanks, - lAlphaFieldBlanks, - cAlphaFieldNames, - cNumericFieldNames); + for (int CompLoop = 1; CompLoop <= NumUserAirTerminals; ++CompLoop) { + inputProcessor->getObjectItem( + cCurrentModuleObject, CompLoop, cAlphaArgs, NumAlphas, rNumericArgs, NumNums, IOStat, _, lAlphaFieldBlanks, cAlphaFieldNames, _); UtilityRoutines::IsNameEmpty(cAlphaArgs(1), cCurrentModuleObject, ErrorsFound); UserAirTerminal(CompLoop).Name = cAlphaArgs(1); // now get program manager for model simulations if (!lAlphaFieldBlanks(2)) { - StackMngrNum = UtilityRoutines::FindItemInList(cAlphaArgs(2), EMSProgramCallManager); + int StackMngrNum = UtilityRoutines::FindItemInList(cAlphaArgs(2), DataRuntimeLanguage::EMSProgramCallManager); if (StackMngrNum > 0) { // found it UserAirTerminal(CompLoop).ErlSimProgramMngr = StackMngrNum; } else { @@ -1720,7 +1632,7 @@ namespace UserDefinedComponents { // now get program manager for model initializations if (!lAlphaFieldBlanks(3)) { - StackMngrNum = UtilityRoutines::FindItemInList(cAlphaArgs(3), EMSProgramCallManager); + int StackMngrNum = UtilityRoutines::FindItemInList(cAlphaArgs(3), DataRuntimeLanguage::EMSProgramCallManager); if (StackMngrNum > 0) { // found it UserAirTerminal(CompLoop).ErlInitProgramMngr = StackMngrNum; } else { @@ -1731,15 +1643,15 @@ namespace UserDefinedComponents { } } - UserAirTerminal(CompLoop).AirLoop.InletNodeNum = GetOnlySingleNode(cAlphaArgs(4), - ErrorsFound, - cCurrentModuleObject, - UserAirTerminal(CompLoop).Name, - NodeType_Air, - NodeConnectionType_Inlet, - 1, - ObjectIsNotParent, - cAlphaFieldNames(4)); + UserAirTerminal(CompLoop).AirLoop.InletNodeNum = NodeInputManager::GetOnlySingleNode(cAlphaArgs(4), + ErrorsFound, + cCurrentModuleObject, + UserAirTerminal(CompLoop).Name, + DataLoopNode::NodeType_Air, + DataLoopNode::NodeConnectionType_Inlet, + 1, + DataLoopNode::ObjectIsNotParent, + cAlphaFieldNames(4)); // model input related internal variables SetupEMSInternalVariable("Inlet Temperature for Primary Air Connection", UserAirTerminal(CompLoop).Name, @@ -1781,15 +1693,15 @@ namespace UserDefinedComponents { "[kg/s]", lDummy, UserAirTerminal(CompLoop).AirLoop.InletMassFlowRate); - UserAirTerminal(CompLoop).AirLoop.OutletNodeNum = GetOnlySingleNode(cAlphaArgs(5), - ErrorsFound, - cCurrentModuleObject, - UserAirTerminal(CompLoop).Name, - NodeType_Air, - NodeConnectionType_Outlet, - 1, - ObjectIsNotParent, - cAlphaFieldNames(5)); + UserAirTerminal(CompLoop).AirLoop.OutletNodeNum = NodeInputManager::GetOnlySingleNode(cAlphaArgs(5), + ErrorsFound, + cCurrentModuleObject, + UserAirTerminal(CompLoop).Name, + DataLoopNode::NodeType_Air, + DataLoopNode::NodeConnectionType_Outlet, + 1, + DataLoopNode::ObjectIsNotParent, + cAlphaFieldNames(5)); SetupEMSActuator("Primary Air Connection", UserAirTerminal(CompLoop).Name, "Outlet Temperature", @@ -1808,7 +1720,7 @@ namespace UserDefinedComponents { "[kg/s]", lDummy, UserAirTerminal(CompLoop).AirLoop.OutletMassFlowRate); - TestCompSet(cCurrentModuleObject, cAlphaArgs(1), cAlphaArgs(4), cAlphaArgs(5), "Air Nodes"); + BranchNodeConnections::TestCompSet(cCurrentModuleObject, cAlphaArgs(1), cAlphaArgs(4), cAlphaArgs(5), "Air Nodes"); int ADUNum = 0; for (ADUNum = 1; ADUNum <= DataDefineEquip::NumAirDistUnits; ++ADUNum) { @@ -1821,24 +1733,27 @@ namespace UserDefinedComponents { if (UserAirTerminal(CompLoop).ADUNum == 0) { ShowSevereError("GetUserDefinedComponents: No matching Air Distribution Unit for " + cCurrentModuleObject + " = " + UserAirTerminal(CompLoop).Name); - ShowContinueError("...should have outlet node=" + NodeID(UserAirTerminal(CompLoop).AirLoop.OutletNodeNum)); + ShowContinueError("...should have outlet node=" + DataLoopNode::NodeID(UserAirTerminal(CompLoop).AirLoop.OutletNodeNum)); // ErrorsFound=.TRUE. } // Fill the Zone Equipment data with the inlet node number of this unit. - for (CtrlZone = 1; CtrlZone <= NumOfZones; ++CtrlZone) { - if (!ZoneEquipConfig(CtrlZone).IsControlled) continue; - for (SupAirIn = 1; SupAirIn <= ZoneEquipConfig(CtrlZone).NumInletNodes; ++SupAirIn) { - if (UserAirTerminal(CompLoop).AirLoop.OutletNodeNum == ZoneEquipConfig(CtrlZone).InletNode(SupAirIn)) { - if (ZoneEquipConfig(CtrlZone).AirDistUnitCool(SupAirIn).OutNode > 0) { + for (int CtrlZone = 1; CtrlZone <= DataGlobals::NumOfZones; ++CtrlZone) { + if (!DataZoneEquipment::ZoneEquipConfig(CtrlZone).IsControlled) continue; + for (int SupAirIn = 1; SupAirIn <= DataZoneEquipment::ZoneEquipConfig(CtrlZone).NumInletNodes; ++SupAirIn) { + if (UserAirTerminal(CompLoop).AirLoop.OutletNodeNum == DataZoneEquipment::ZoneEquipConfig(CtrlZone).InletNode(SupAirIn)) { + if (DataZoneEquipment::ZoneEquipConfig(CtrlZone).AirDistUnitCool(SupAirIn).OutNode > 0) { ShowSevereError("Error in connecting a terminal unit to a zone"); - ShowContinueError(NodeID(UserAirTerminal(CompLoop).AirLoop.OutletNodeNum) + " already connects to another zone"); + ShowContinueError(DataLoopNode::NodeID(UserAirTerminal(CompLoop).AirLoop.OutletNodeNum) + + " already connects to another zone"); ShowContinueError("Occurs for terminal unit " + cCurrentModuleObject + " = " + UserAirTerminal(CompLoop).Name); ShowContinueError("Check terminal unit node names for errors"); ErrorsFound = true; } else { - ZoneEquipConfig(CtrlZone).AirDistUnitCool(SupAirIn).InNode = UserAirTerminal(CompLoop).AirLoop.InletNodeNum; - ZoneEquipConfig(CtrlZone).AirDistUnitCool(SupAirIn).OutNode = UserAirTerminal(CompLoop).AirLoop.OutletNodeNum; + DataZoneEquipment::ZoneEquipConfig(CtrlZone).AirDistUnitCool(SupAirIn).InNode = + UserAirTerminal(CompLoop).AirLoop.InletNodeNum; + DataZoneEquipment::ZoneEquipConfig(CtrlZone).AirDistUnitCool(SupAirIn).OutNode = + UserAirTerminal(CompLoop).AirLoop.OutletNodeNum; } UserAirTerminal(CompLoop).ActualCtrlZoneNum = CtrlZone; @@ -1847,15 +1762,15 @@ namespace UserDefinedComponents { } if (!lAlphaFieldBlanks(6)) { - UserAirTerminal(CompLoop).SourceAir.InletNodeNum = GetOnlySingleNode(cAlphaArgs(6), - ErrorsFound, - cCurrentModuleObject, - UserAirTerminal(CompLoop).Name, - NodeType_Air, - NodeConnectionType_Inlet, - 2, - ObjectIsNotParent, - cAlphaFieldNames(6)); + UserAirTerminal(CompLoop).SourceAir.InletNodeNum = NodeInputManager::GetOnlySingleNode(cAlphaArgs(6), + ErrorsFound, + cCurrentModuleObject, + UserAirTerminal(CompLoop).Name, + DataLoopNode::NodeType_Air, + DataLoopNode::NodeConnectionType_Inlet, + 2, + DataLoopNode::ObjectIsNotParent, + cAlphaFieldNames(6)); // model input related internal variables SetupEMSInternalVariable("Inlet Temperature for Secondary Air Connection", UserAirTerminal(CompLoop).Name, @@ -1883,15 +1798,15 @@ namespace UserDefinedComponents { } if (!lAlphaFieldBlanks(7)) { - UserAirTerminal(CompLoop).SourceAir.OutletNodeNum = GetOnlySingleNode(cAlphaArgs(7), - ErrorsFound, - cCurrentModuleObject, - UserAirTerminal(CompLoop).Name, - NodeType_Air, - NodeConnectionType_Outlet, - 2, - ObjectIsNotParent, - cAlphaFieldNames(7)); + UserAirTerminal(CompLoop).SourceAir.OutletNodeNum = NodeInputManager::GetOnlySingleNode(cAlphaArgs(7), + ErrorsFound, + cCurrentModuleObject, + UserAirTerminal(CompLoop).Name, + DataLoopNode::NodeType_Air, + DataLoopNode::NodeConnectionType_Outlet, + 2, + DataLoopNode::ObjectIsNotParent, + cAlphaFieldNames(7)); SetupEMSActuator("Secondary Air Connection", UserAirTerminal(CompLoop).Name, "Outlet Temperature", @@ -1916,35 +1831,38 @@ namespace UserDefinedComponents { // CALL TestCompSet(TRIM(cCurrentModuleObject),cAlphaArgs(1),cAlphaArgs(6),cAlphaArgs(7),'Air Nodes') } - NumPlantConnections = std::floor(rNumericArgs(1)); + int NumPlantConnections = std::floor(rNumericArgs(1)); UserAirTerminal(CompLoop).NumPlantConnections = NumPlantConnections; if ((NumPlantConnections >= 1) && (NumPlantConnections <= 2)) { UserAirTerminal(CompLoop).Loop.allocate(NumPlantConnections); - for (ConnectionLoop = 1; ConnectionLoop <= NumPlantConnections; ++ConnectionLoop) { - aArgCount = (ConnectionLoop - 1) * 2 + 8; - UserAirTerminal(CompLoop).Loop(ConnectionLoop).InletNodeNum = GetOnlySingleNode(cAlphaArgs(aArgCount), - ErrorsFound, - cCurrentModuleObject, - cAlphaArgs(1), - NodeType_Water, - NodeConnectionType_Inlet, - (ConnectionLoop + 2), - ObjectIsNotParent, - cAlphaFieldNames(aArgCount)); - UserAirTerminal(CompLoop).Loop(ConnectionLoop).OutletNodeNum = GetOnlySingleNode(cAlphaArgs(aArgCount + 1), - ErrorsFound, - cCurrentModuleObject, - cAlphaArgs(1), - NodeType_Water, - NodeConnectionType_Outlet, - (ConnectionLoop + 2), - ObjectIsNotParent, - cAlphaFieldNames(aArgCount + 1)); - TestCompSet(cCurrentModuleObject, cAlphaArgs(1), cAlphaArgs(aArgCount), cAlphaArgs(aArgCount + 1), "Plant Nodes"); - UserAirTerminal(CompLoop).Loop(ConnectionLoop).HowLoadServed = HowMet_NoneDemand; - UserAirTerminal(CompLoop).Loop(ConnectionLoop).FlowPriority = LoopFlowStatus_NeedyAndTurnsLoopOn; + for (int ConnectionLoop = 1; ConnectionLoop <= NumPlantConnections; ++ConnectionLoop) { + int aArgCount = (ConnectionLoop - 1) * 2 + 8; + UserAirTerminal(CompLoop).Loop(ConnectionLoop).InletNodeNum = + NodeInputManager::GetOnlySingleNode(cAlphaArgs(aArgCount), + ErrorsFound, + cCurrentModuleObject, + cAlphaArgs(1), + DataLoopNode::NodeType_Water, + DataLoopNode::NodeConnectionType_Inlet, + (ConnectionLoop + 2), + DataLoopNode::ObjectIsNotParent, + cAlphaFieldNames(aArgCount)); + UserAirTerminal(CompLoop).Loop(ConnectionLoop).OutletNodeNum = + NodeInputManager::GetOnlySingleNode(cAlphaArgs(aArgCount + 1), + ErrorsFound, + cCurrentModuleObject, + cAlphaArgs(1), + DataLoopNode::NodeType_Water, + DataLoopNode::NodeConnectionType_Outlet, + (ConnectionLoop + 2), + DataLoopNode::ObjectIsNotParent, + cAlphaFieldNames(aArgCount + 1)); + BranchNodeConnections::TestCompSet( + cCurrentModuleObject, cAlphaArgs(1), cAlphaArgs(aArgCount), cAlphaArgs(aArgCount + 1), "Plant Nodes"); + UserAirTerminal(CompLoop).Loop(ConnectionLoop).HowLoadServed = DataPlant::HowMet_NoneDemand; + UserAirTerminal(CompLoop).Loop(ConnectionLoop).FlowPriority = DataPlant::LoopFlowStatus_NeedyAndTurnsLoopOn; // Setup Internal Variables - LoopStr = RoundSigDigits(ConnectionLoop); + LoopStr = General::RoundSigDigits(ConnectionLoop); // model input related internal variables SetupEMSInternalVariable("Inlet Temperature for Plant Connection " + LoopStr, UserAirTerminal(CompLoop).Name, @@ -1998,12 +1916,12 @@ namespace UserDefinedComponents { } if (!lAlphaFieldBlanks(12)) { - SetupTankDemandComponent(cAlphaArgs(1), - cCurrentModuleObject, - cAlphaArgs(12), - ErrorsFound, - UserAirTerminal(CompLoop).Water.SupplyTankID, - UserAirTerminal(CompLoop).Water.SupplyTankDemandARRID); + WaterManager::SetupTankDemandComponent(cAlphaArgs(1), + cCurrentModuleObject, + cAlphaArgs(12), + ErrorsFound, + UserAirTerminal(CompLoop).Water.SupplyTankID, + UserAirTerminal(CompLoop).Water.SupplyTankDemandARRID); UserAirTerminal(CompLoop).Water.SuppliedByWaterSystem = true; SetupEMSActuator("Water System", @@ -2015,12 +1933,12 @@ namespace UserDefinedComponents { } if (!lAlphaFieldBlanks(13)) { - SetupTankSupplyComponent(cAlphaArgs(1), - cCurrentModuleObject, - cAlphaArgs(13), - ErrorsFound, - UserAirTerminal(CompLoop).Water.CollectionTankID, - UserAirTerminal(CompLoop).Water.CollectionTankSupplyARRID); + WaterManager::SetupTankSupplyComponent(cAlphaArgs(1), + cCurrentModuleObject, + cAlphaArgs(13), + ErrorsFound, + UserAirTerminal(CompLoop).Water.CollectionTankID, + UserAirTerminal(CompLoop).Water.CollectionTankSupplyARRID); UserAirTerminal(CompLoop).Water.CollectsToWaterSystem = true; SetupEMSActuator("Water System", UserAirTerminal(CompLoop).Name, @@ -2032,7 +1950,7 @@ namespace UserDefinedComponents { if (!lAlphaFieldBlanks(14)) { - UserAirTerminal(CompLoop).Zone.ZoneNum = UtilityRoutines::FindItemInList(cAlphaArgs(14), Zone); + UserAirTerminal(CompLoop).Zone.ZoneNum = UtilityRoutines::FindItemInList(cAlphaArgs(14), DataHeatBalance::Zone); if (UserAirTerminal(CompLoop).Zone.ZoneNum == 0) { ShowSevereError(cCurrentModuleObject + " = " + cAlphaArgs(1) + ": Ambient Zone Name not found = " + cAlphaArgs(14)); ErrorsFound = true; @@ -2041,7 +1959,7 @@ namespace UserDefinedComponents { SetupZoneInternalGain(UserAirTerminal(CompLoop).Zone.ZoneNum, cCurrentModuleObject, cAlphaArgs(1), - IntGainTypeOf_AirTerminalUserDefined, + DataHeatBalance::IntGainTypeOf_AirTerminalUserDefined, UserAirTerminal(CompLoop).Zone.ConvectionGainRate, UserAirTerminal(CompLoop).Zone.ReturnAirConvectionGainRate, UserAirTerminal(CompLoop).Zone.ThermalRadiationGainRate, @@ -2102,7 +2020,7 @@ namespace UserDefinedComponents { } } - void InitPlantUserComponent(int const CompNum, int const LoopNum, Real64 const MyLoad) + void UserPlantComponentStruct::initialize(int LoopNum, Real64 MyLoad) { // SUBROUTINE INFORMATION: // AUTHOR @@ -2110,115 +2028,73 @@ namespace UserDefinedComponents { // MODIFIED na // RE-ENGINEERED na - // PURPOSE OF THIS SUBROUTINE: - // - - // METHODOLOGY EMPLOYED: - // - - // REFERENCES: - // na - - // Using/Aliasing - using DataEnvironment::OutBaroPress; - using FluidProperties::GetDensityGlycol; - using FluidProperties::GetSpecificHeatGlycol; - using PlantUtilities::InitComponentNodes; - using Psychrometrics::PsyCpAirFnWTdb; - using Psychrometrics::PsyRhoAirFnPbTdbW; - - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: static std::string const RoutineName("InitPlantUserComponent"); - // INTERFACE BLOCK SPECIFICATIONS: - // na - - // DERIVED TYPE DEFINITIONS: - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - static bool MyOneTimeFlag(true); // one time flag - static Array1D_bool MyEnvrnFlag; // environment flag - static Array1D_bool MyFlag; - int ConnectionNum; - bool errFlag; - // REAL(r64) :: rho - // REAL(r64) :: Cp - - if (MyOneTimeFlag) { - MyFlag.allocate(NumUserPlantComps); - MyEnvrnFlag.allocate(NumUserPlantComps); - MyFlag = true; - MyEnvrnFlag = true; - MyOneTimeFlag = false; - } - - if (MyFlag(CompNum)) { + if (this->myOneTimeFlag) { // locate the connections to the plant loops - for (ConnectionNum = 1; ConnectionNum <= UserPlantComp(CompNum).NumPlantConnections; ++ConnectionNum) { - errFlag = false; - PlantUtilities::ScanPlantLoopsForObject(UserPlantComp(CompNum).Name, - TypeOf_PlantComponentUserDefined, - UserPlantComp(CompNum).Loop(ConnectionNum).LoopNum, - UserPlantComp(CompNum).Loop(ConnectionNum).LoopSideNum, - UserPlantComp(CompNum).Loop(ConnectionNum).BranchNum, - UserPlantComp(CompNum).Loop(ConnectionNum).CompNum, + for (int ConnectionNum = 1; ConnectionNum <= this->NumPlantConnections; ++ConnectionNum) { + bool errFlag = false; + PlantUtilities::ScanPlantLoopsForObject(this->Name, + DataPlant::TypeOf_PlantComponentUserDefined, + this->Loop(ConnectionNum).LoopNum, + this->Loop(ConnectionNum).LoopSideNum, + this->Loop(ConnectionNum).BranchNum, + this->Loop(ConnectionNum).CompNum, errFlag, _, _, _, - UserPlantComp(CompNum).Loop(ConnectionNum).InletNodeNum); + this->Loop(ConnectionNum).InletNodeNum); if (errFlag) { ShowFatalError("InitPlantUserComponent: Program terminated due to previous condition(s)."); } // set user input for flow priority - PlantLoop(UserPlantComp(CompNum).Loop(ConnectionNum).LoopNum) - .LoopSide(UserPlantComp(CompNum).Loop(ConnectionNum).LoopSideNum) - .Branch(UserPlantComp(CompNum).Loop(ConnectionNum).BranchNum) - .Comp(UserPlantComp(CompNum).Loop(ConnectionNum).CompNum) - .FlowPriority = UserPlantComp(CompNum).Loop(ConnectionNum).FlowPriority; + DataPlant::PlantLoop(this->Loop(ConnectionNum).LoopNum) + .LoopSide(this->Loop(ConnectionNum).LoopSideNum) + .Branch(this->Loop(ConnectionNum).BranchNum) + .Comp(this->Loop(ConnectionNum).CompNum) + .FlowPriority = this->Loop(ConnectionNum).FlowPriority; // set user input for how loads served - PlantLoop(UserPlantComp(CompNum).Loop(ConnectionNum).LoopNum) - .LoopSide(UserPlantComp(CompNum).Loop(ConnectionNum).LoopSideNum) - .Branch(UserPlantComp(CompNum).Loop(ConnectionNum).BranchNum) - .Comp(UserPlantComp(CompNum).Loop(ConnectionNum).CompNum) - .HowLoadServed = UserPlantComp(CompNum).Loop(ConnectionNum).HowLoadServed; + DataPlant::PlantLoop(this->Loop(ConnectionNum).LoopNum) + .LoopSide(this->Loop(ConnectionNum).LoopSideNum) + .Branch(this->Loop(ConnectionNum).BranchNum) + .Comp(this->Loop(ConnectionNum).CompNum) + .HowLoadServed = this->Loop(ConnectionNum).HowLoadServed; } - MyFlag(CompNum) = false; + this->myOneTimeFlag = false; } - if (LoopNum <= 0 || LoopNum > UserPlantComp(CompNum).NumPlantConnections) return; + if (LoopNum <= 0 || LoopNum > this->NumPlantConnections) return; // fill internal variable targets - UserPlantComp(CompNum).Loop(LoopNum).MyLoad = MyLoad; - UserPlantComp(CompNum).Loop(LoopNum).InletRho = GetDensityGlycol(PlantLoop(UserPlantComp(CompNum).Loop(LoopNum).LoopNum).FluidName, - Node(UserPlantComp(CompNum).Loop(LoopNum).InletNodeNum).Temp, - PlantLoop(UserPlantComp(CompNum).Loop(LoopNum).LoopNum).FluidIndex, + this->Loop(LoopNum).MyLoad = MyLoad; + this->Loop(LoopNum).InletRho = FluidProperties::GetDensityGlycol(DataPlant::PlantLoop(this->Loop(LoopNum).LoopNum).FluidName, + DataLoopNode::Node(this->Loop(LoopNum).InletNodeNum).Temp, + DataPlant::PlantLoop(this->Loop(LoopNum).LoopNum).FluidIndex, RoutineName); - UserPlantComp(CompNum).Loop(LoopNum).InletCp = GetSpecificHeatGlycol(PlantLoop(UserPlantComp(CompNum).Loop(LoopNum).LoopNum).FluidName, - Node(UserPlantComp(CompNum).Loop(LoopNum).InletNodeNum).Temp, - PlantLoop(UserPlantComp(CompNum).Loop(LoopNum).LoopNum).FluidIndex, + this->Loop(LoopNum).InletCp = FluidProperties::GetSpecificHeatGlycol(DataPlant::PlantLoop(this->Loop(LoopNum).LoopNum).FluidName, + DataLoopNode::Node(this->Loop(LoopNum).InletNodeNum).Temp, + DataPlant::PlantLoop(this->Loop(LoopNum).LoopNum).FluidIndex, RoutineName); - UserPlantComp(CompNum).Loop(LoopNum).InletMassFlowRate = Node(UserPlantComp(CompNum).Loop(LoopNum).InletNodeNum).MassFlowRate; - UserPlantComp(CompNum).Loop(LoopNum).InletTemp = Node(UserPlantComp(CompNum).Loop(LoopNum).InletNodeNum).Temp; - if (UserPlantComp(CompNum).Air.InletNodeNum > 0) { - UserPlantComp(CompNum).Air.InletRho = PsyRhoAirFnPbTdbW( - OutBaroPress, Node(UserPlantComp(CompNum).Air.InletNodeNum).Temp, Node(UserPlantComp(CompNum).Air.InletNodeNum).HumRat, RoutineName); - UserPlantComp(CompNum).Air.InletCp = - PsyCpAirFnWTdb(Node(UserPlantComp(CompNum).Air.InletNodeNum).HumRat, Node(UserPlantComp(CompNum).Air.InletNodeNum).Temp); - UserPlantComp(CompNum).Air.InletTemp = Node(UserPlantComp(CompNum).Air.InletNodeNum).Temp; - UserPlantComp(CompNum).Air.InletMassFlowRate = Node(UserPlantComp(CompNum).Air.InletNodeNum).MassFlowRate; - UserPlantComp(CompNum).Air.InletHumRat = Node(UserPlantComp(CompNum).Air.InletNodeNum).HumRat; + this->Loop(LoopNum).InletMassFlowRate = DataLoopNode::Node(this->Loop(LoopNum).InletNodeNum).MassFlowRate; + this->Loop(LoopNum).InletTemp = DataLoopNode::Node(this->Loop(LoopNum).InletNodeNum).Temp; + if (this->Air.InletNodeNum > 0) { + this->Air.InletRho = Psychrometrics::PsyRhoAirFnPbTdbW(DataEnvironment::OutBaroPress, + DataLoopNode::Node(this->Air.InletNodeNum).Temp, + DataLoopNode::Node(this->Air.InletNodeNum).HumRat, + RoutineName); + this->Air.InletCp = + Psychrometrics::PsyCpAirFnWTdb(DataLoopNode::Node(this->Air.InletNodeNum).HumRat, DataLoopNode::Node(this->Air.InletNodeNum).Temp); + this->Air.InletTemp = DataLoopNode::Node(this->Air.InletNodeNum).Temp; + this->Air.InletMassFlowRate = DataLoopNode::Node(this->Air.InletNodeNum).MassFlowRate; + this->Air.InletHumRat = DataLoopNode::Node(this->Air.InletNodeNum).HumRat; } } - void InitCoilUserDefined(int const CompNum) + void UserCoilComponentStruct::initialize() { // SUBROUTINE INFORMATION: @@ -2227,104 +2103,67 @@ namespace UserDefinedComponents { // MODIFIED na // RE-ENGINEERED na - // PURPOSE OF THIS SUBROUTINE: - // - - // METHODOLOGY EMPLOYED: - // - - // REFERENCES: - // na - - // Using/Aliasing - using DataEnvironment::OutBaroPress; - using FluidProperties::GetDensityGlycol; - using FluidProperties::GetSpecificHeatGlycol; - using Psychrometrics::PsyCpAirFnWTdb; - using Psychrometrics::PsyRhoAirFnPbTdbW; - - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: static std::string const RoutineName("InitCoilUserDefined"); - // INTERFACE BLOCK SPECIFICATIONS: - // na - - // DERIVED TYPE DEFINITIONS: - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - static bool MyOneTimeFlag(true); // one time flag - static Array1D_bool MyFlag; - bool errFlag; - int Loop; - - if (MyOneTimeFlag) { - MyFlag.dimension(NumUserCoils, true); - MyOneTimeFlag = false; - } - - if (MyFlag(CompNum)) { - if (UserCoil(CompNum).PlantIsConnected) { - errFlag = false; - PlantUtilities::ScanPlantLoopsForObject(UserCoil(CompNum).Name, - TypeOf_CoilUserDefined, - UserCoil(CompNum).Loop.LoopNum, - UserCoil(CompNum).Loop.LoopSideNum, - UserCoil(CompNum).Loop.BranchNum, - UserCoil(CompNum).Loop.CompNum, + if (this->myOneTimeFlag) { + if (this->PlantIsConnected) { + bool errFlag = false; + PlantUtilities::ScanPlantLoopsForObject(this->Name, + DataPlant::TypeOf_CoilUserDefined, + this->Loop.LoopNum, + this->Loop.LoopSideNum, + this->Loop.BranchNum, + this->Loop.CompNum, errFlag); if (errFlag) { ShowFatalError("InitPlantUserComponent: Program terminated due to previous condition(s)."); } // set user input for flow priority - PlantLoop(UserCoil(CompNum).Loop.LoopNum) - .LoopSide(UserCoil(CompNum).Loop.LoopSideNum) - .Branch(UserCoil(CompNum).Loop.BranchNum) - .Comp(UserCoil(CompNum).Loop.CompNum) - .FlowPriority = UserCoil(CompNum).Loop.FlowPriority; + DataPlant::PlantLoop(this->Loop.LoopNum) + .LoopSide(this->Loop.LoopSideNum) + .Branch(this->Loop.BranchNum) + .Comp(this->Loop.CompNum) + .FlowPriority = this->Loop.FlowPriority; // set user input for how loads served - PlantLoop(UserCoil(CompNum).Loop.LoopNum) - .LoopSide(UserCoil(CompNum).Loop.LoopSideNum) - .Branch(UserCoil(CompNum).Loop.BranchNum) - .Comp(UserCoil(CompNum).Loop.CompNum) - .HowLoadServed = UserCoil(CompNum).Loop.HowLoadServed; + DataPlant::PlantLoop(this->Loop.LoopNum) + .LoopSide(this->Loop.LoopSideNum) + .Branch(this->Loop.BranchNum) + .Comp(this->Loop.CompNum) + .HowLoadServed = this->Loop.HowLoadServed; } - MyFlag(CompNum) = false; + this->myOneTimeFlag = false; } // fill internal variable targets - for (Loop = 1; Loop <= UserCoil(CompNum).NumAirConnections; ++Loop) { - UserCoil(CompNum).Air(Loop).InletRho = PsyRhoAirFnPbTdbW(OutBaroPress, - Node(UserCoil(CompNum).Air(Loop).InletNodeNum).Temp, - Node(UserCoil(CompNum).Air(Loop).InletNodeNum).HumRat, - RoutineName); - - UserCoil(CompNum).Air(Loop).InletCp = - PsyCpAirFnWTdb(Node(UserCoil(CompNum).Air(Loop).InletNodeNum).HumRat, Node(UserCoil(CompNum).Air(Loop).InletNodeNum).Temp); - UserCoil(CompNum).Air(Loop).InletTemp = Node(UserCoil(CompNum).Air(Loop).InletNodeNum).Temp; - UserCoil(CompNum).Air(Loop).InletMassFlowRate = Node(UserCoil(CompNum).Air(Loop).InletNodeNum).MassFlowRate; - UserCoil(CompNum).Air(Loop).InletHumRat = Node(UserCoil(CompNum).Air(Loop).InletNodeNum).HumRat; + for (int loop = 1; loop <= this->NumAirConnections; ++loop) { + this->Air(loop).InletRho = Psychrometrics::PsyRhoAirFnPbTdbW(DataEnvironment::OutBaroPress, + DataLoopNode::Node(this->Air(loop).InletNodeNum).Temp, + DataLoopNode::Node(this->Air(loop).InletNodeNum).HumRat, + RoutineName); + + this->Air(loop).InletCp = Psychrometrics::PsyCpAirFnWTdb(DataLoopNode::Node(this->Air(loop).InletNodeNum).HumRat, + DataLoopNode::Node(this->Air(loop).InletNodeNum).Temp); + this->Air(loop).InletTemp = DataLoopNode::Node(this->Air(loop).InletNodeNum).Temp; + this->Air(loop).InletMassFlowRate = DataLoopNode::Node(this->Air(loop).InletNodeNum).MassFlowRate; + this->Air(loop).InletHumRat = DataLoopNode::Node(this->Air(loop).InletNodeNum).HumRat; } - if (UserCoil(CompNum).PlantIsConnected) { - UserCoil(CompNum).Loop.InletRho = GetDensityGlycol(PlantLoop(UserCoil(CompNum).Loop.LoopNum).FluidName, - Node(UserCoil(CompNum).Loop.InletNodeNum).Temp, - PlantLoop(UserCoil(CompNum).Loop.LoopNum).FluidIndex, - RoutineName); - UserCoil(CompNum).Loop.InletCp = GetSpecificHeatGlycol(PlantLoop(UserCoil(CompNum).Loop.LoopNum).FluidName, - Node(UserCoil(CompNum).Loop.InletNodeNum).Temp, - PlantLoop(UserCoil(CompNum).Loop.LoopNum).FluidIndex, - RoutineName); - UserCoil(CompNum).Loop.InletTemp = Node(UserCoil(CompNum).Loop.InletNodeNum).Temp; - UserCoil(CompNum).Loop.InletMassFlowRate = Node(UserCoil(CompNum).Loop.InletNodeNum).MassFlowRate; + if (this->PlantIsConnected) { + this->Loop.InletRho = FluidProperties::GetDensityGlycol(DataPlant::PlantLoop(this->Loop.LoopNum).FluidName, + DataLoopNode::Node(this->Loop.InletNodeNum).Temp, + DataPlant::PlantLoop(this->Loop.LoopNum).FluidIndex, + RoutineName); + this->Loop.InletCp = FluidProperties::GetSpecificHeatGlycol(DataPlant::PlantLoop(this->Loop.LoopNum).FluidName, + DataLoopNode::Node(this->Loop.InletNodeNum).Temp, + DataPlant::PlantLoop(this->Loop.LoopNum).FluidIndex, + RoutineName); + this->Loop.InletTemp = DataLoopNode::Node(this->Loop.InletNodeNum).Temp; + this->Loop.InletMassFlowRate = DataLoopNode::Node(this->Loop.InletNodeNum).MassFlowRate; } } - void InitZoneAirUserDefined(int const CompNum, int const ZoneNum) + void UserZoneHVACForcedAirComponentStruct::initialize(int const ZoneNum) { // SUBROUTINE INFORMATION: @@ -2336,121 +2175,86 @@ namespace UserDefinedComponents { // PURPOSE OF THIS SUBROUTINE: // initialize data for user-defined zone HVAC forced air component model - // METHODOLOGY EMPLOYED: - // - - // REFERENCES: - // na - - // Using/Aliasing - using DataEnvironment::OutBaroPress; - using DataZoneEnergyDemands::ZoneSysEnergyDemand; - using DataZoneEnergyDemands::ZoneSysMoistureDemand; - using FluidProperties::GetDensityGlycol; - using FluidProperties::GetSpecificHeatGlycol; - using Psychrometrics::PsyCpAirFnWTdb; - using Psychrometrics::PsyRhoAirFnPbTdbW; - - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: static std::string const RoutineName("InitZoneAirUserDefined"); - // INTERFACE BLOCK SPECIFICATIONS: - // na - - // DERIVED TYPE DEFINITIONS: - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - static bool MyOneTimeFlag(true); // one time flag - static Array1D_bool MyFlag; - bool errFlag; - int Loop; - - if (MyOneTimeFlag) { - MyFlag.dimension(NumUserZoneAir, true); - MyOneTimeFlag = false; - } - - if (MyFlag(CompNum)) { - if (UserZoneAirHVAC(CompNum).NumPlantConnections > 0) { - for (Loop = 1; Loop <= UserZoneAirHVAC(CompNum).NumPlantConnections; ++Loop) { - errFlag = false; - PlantUtilities::ScanPlantLoopsForObject(UserZoneAirHVAC(CompNum).Name, - TypeOf_ZoneHVACAirUserDefined, - UserZoneAirHVAC(CompNum).Loop(Loop).LoopNum, - UserZoneAirHVAC(CompNum).Loop(Loop).LoopSideNum, - UserZoneAirHVAC(CompNum).Loop(Loop).BranchNum, - UserZoneAirHVAC(CompNum).Loop(Loop).CompNum, + if (this->myOneTimeFlag) { + if (this->NumPlantConnections > 0) { + for (int loop = 1; loop <= this->NumPlantConnections; ++loop) { + bool errFlag = false; + PlantUtilities::ScanPlantLoopsForObject(this->Name, + DataPlant::TypeOf_ZoneHVACAirUserDefined, + this->Loop(loop).LoopNum, + this->Loop(loop).LoopSideNum, + this->Loop(loop).BranchNum, + this->Loop(loop).CompNum, errFlag, _, _, _, - UserZoneAirHVAC(CompNum).Loop(Loop).InletNodeNum); + this->Loop(loop).InletNodeNum); if (errFlag) { ShowFatalError("InitPlantUserComponent: Program terminated due to previous condition(s)."); } // set user input for flow priority - PlantLoop(UserZoneAirHVAC(CompNum).Loop(Loop).LoopNum) - .LoopSide(UserZoneAirHVAC(CompNum).Loop(Loop).LoopSideNum) - .Branch(UserZoneAirHVAC(CompNum).Loop(Loop).BranchNum) - .Comp(UserZoneAirHVAC(CompNum).Loop(Loop).CompNum) - .FlowPriority = UserZoneAirHVAC(CompNum).Loop(Loop).FlowPriority; + DataPlant::PlantLoop(this->Loop(loop).LoopNum) + .LoopSide(this->Loop(loop).LoopSideNum) + .Branch(this->Loop(loop).BranchNum) + .Comp(this->Loop(loop).CompNum) + .FlowPriority = this->Loop(loop).FlowPriority; // set user input for how loads served - PlantLoop(UserZoneAirHVAC(CompNum).Loop(Loop).LoopNum) - .LoopSide(UserZoneAirHVAC(CompNum).Loop(Loop).LoopSideNum) - .Branch(UserZoneAirHVAC(CompNum).Loop(Loop).BranchNum) - .Comp(UserZoneAirHVAC(CompNum).Loop(Loop).CompNum) - .HowLoadServed = UserZoneAirHVAC(CompNum).Loop(Loop).HowLoadServed; + DataPlant::PlantLoop(this->Loop(loop).LoopNum) + .LoopSide(this->Loop(loop).LoopSideNum) + .Branch(this->Loop(loop).BranchNum) + .Comp(this->Loop(loop).CompNum) + .HowLoadServed = this->Loop(loop).HowLoadServed; } } + this->myOneTimeFlag = false; } // fill internal variable targets - UserZoneAirHVAC(CompNum).RemainingOutputToHeatingSP = ZoneSysEnergyDemand(ZoneNum).RemainingOutputReqToHeatSP; - UserZoneAirHVAC(CompNum).RemainingOutputToCoolingSP = ZoneSysEnergyDemand(ZoneNum).RemainingOutputReqToCoolSP; - UserZoneAirHVAC(CompNum).RemainingOutputReqToDehumidSP = ZoneSysMoistureDemand(ZoneNum).RemainingOutputReqToDehumidSP; - UserZoneAirHVAC(CompNum).RemainingOutputReqToHumidSP = ZoneSysMoistureDemand(ZoneNum).RemainingOutputReqToHumidSP; - - UserZoneAirHVAC(CompNum).ZoneAir.InletRho = PsyRhoAirFnPbTdbW(OutBaroPress, - Node(UserZoneAirHVAC(CompNum).ZoneAir.InletNodeNum).Temp, - Node(UserZoneAirHVAC(CompNum).ZoneAir.InletNodeNum).HumRat, - RoutineName); - UserZoneAirHVAC(CompNum).ZoneAir.InletCp = - PsyCpAirFnWTdb(Node(UserZoneAirHVAC(CompNum).ZoneAir.InletNodeNum).HumRat, Node(UserZoneAirHVAC(CompNum).ZoneAir.InletNodeNum).Temp); - UserZoneAirHVAC(CompNum).ZoneAir.InletTemp = Node(UserZoneAirHVAC(CompNum).ZoneAir.InletNodeNum).Temp; - UserZoneAirHVAC(CompNum).ZoneAir.InletHumRat = Node(UserZoneAirHVAC(CompNum).ZoneAir.InletNodeNum).HumRat; - - if (UserZoneAirHVAC(CompNum).SourceAir.InletNodeNum > 0) { - UserZoneAirHVAC(CompNum).SourceAir.InletRho = PsyRhoAirFnPbTdbW(OutBaroPress, - Node(UserZoneAirHVAC(CompNum).SourceAir.InletNodeNum).Temp, - Node(UserZoneAirHVAC(CompNum).SourceAir.InletNodeNum).HumRat, - RoutineName); - UserZoneAirHVAC(CompNum).SourceAir.InletCp = PsyCpAirFnWTdb(Node(UserZoneAirHVAC(CompNum).SourceAir.InletNodeNum).HumRat, - Node(UserZoneAirHVAC(CompNum).SourceAir.InletNodeNum).Temp); - UserZoneAirHVAC(CompNum).SourceAir.InletTemp = Node(UserZoneAirHVAC(CompNum).SourceAir.InletNodeNum).Temp; - UserZoneAirHVAC(CompNum).SourceAir.InletHumRat = Node(UserZoneAirHVAC(CompNum).SourceAir.InletNodeNum).HumRat; + this->RemainingOutputToHeatingSP = DataZoneEnergyDemands::ZoneSysEnergyDemand(ZoneNum).RemainingOutputReqToHeatSP; + this->RemainingOutputToCoolingSP = DataZoneEnergyDemands::ZoneSysEnergyDemand(ZoneNum).RemainingOutputReqToCoolSP; + this->RemainingOutputReqToDehumidSP = DataZoneEnergyDemands::ZoneSysMoistureDemand(ZoneNum).RemainingOutputReqToDehumidSP; + this->RemainingOutputReqToHumidSP = DataZoneEnergyDemands::ZoneSysMoistureDemand(ZoneNum).RemainingOutputReqToHumidSP; + + this->ZoneAir.InletRho = Psychrometrics::PsyRhoAirFnPbTdbW(DataEnvironment::OutBaroPress, + DataLoopNode::Node(this->ZoneAir.InletNodeNum).Temp, + DataLoopNode::Node(this->ZoneAir.InletNodeNum).HumRat, + RoutineName); + this->ZoneAir.InletCp = Psychrometrics::PsyCpAirFnWTdb(DataLoopNode::Node(this->ZoneAir.InletNodeNum).HumRat, + DataLoopNode::Node(this->ZoneAir.InletNodeNum).Temp); + this->ZoneAir.InletTemp = DataLoopNode::Node(this->ZoneAir.InletNodeNum).Temp; + this->ZoneAir.InletHumRat = DataLoopNode::Node(this->ZoneAir.InletNodeNum).HumRat; + + if (this->SourceAir.InletNodeNum > 0) { + this->SourceAir.InletRho = Psychrometrics::PsyRhoAirFnPbTdbW(DataEnvironment::OutBaroPress, + DataLoopNode::Node(this->SourceAir.InletNodeNum).Temp, + DataLoopNode::Node(this->SourceAir.InletNodeNum).HumRat, + RoutineName); + this->SourceAir.InletCp = Psychrometrics::PsyCpAirFnWTdb(DataLoopNode::Node(this->SourceAir.InletNodeNum).HumRat, + DataLoopNode::Node(this->SourceAir.InletNodeNum).Temp); + this->SourceAir.InletTemp = DataLoopNode::Node(this->SourceAir.InletNodeNum).Temp; + this->SourceAir.InletHumRat = DataLoopNode::Node(this->SourceAir.InletNodeNum).HumRat; } - if (UserZoneAirHVAC(CompNum).NumPlantConnections > 0) { - for (Loop = 1; Loop <= UserZoneAirHVAC(CompNum).NumPlantConnections; ++Loop) { - UserZoneAirHVAC(CompNum).Loop(Loop).InletRho = GetDensityGlycol(PlantLoop(UserZoneAirHVAC(CompNum).Loop(Loop).LoopNum).FluidName, - Node(UserZoneAirHVAC(CompNum).Loop(Loop).InletNodeNum).Temp, - PlantLoop(UserZoneAirHVAC(CompNum).Loop(Loop).LoopNum).FluidIndex, - RoutineName); - UserZoneAirHVAC(CompNum).Loop(Loop).InletCp = GetSpecificHeatGlycol(PlantLoop(UserZoneAirHVAC(CompNum).Loop(Loop).LoopNum).FluidName, - Node(UserZoneAirHVAC(CompNum).Loop(Loop).InletNodeNum).Temp, - PlantLoop(UserZoneAirHVAC(CompNum).Loop(Loop).LoopNum).FluidIndex, - RoutineName); - UserZoneAirHVAC(CompNum).Loop(Loop).InletTemp = Node(UserZoneAirHVAC(CompNum).Loop(Loop).InletNodeNum).Temp; - UserZoneAirHVAC(CompNum).Loop(Loop).InletMassFlowRate = Node(UserZoneAirHVAC(CompNum).Loop(Loop).InletNodeNum).MassFlowRate; + if (this->NumPlantConnections > 0) { + for (int loop = 1; loop <= this->NumPlantConnections; ++loop) { + this->Loop(loop).InletRho = FluidProperties::GetDensityGlycol(DataPlant::PlantLoop(this->Loop(loop).LoopNum).FluidName, + DataLoopNode::Node(this->Loop(loop).InletNodeNum).Temp, + DataPlant::PlantLoop(this->Loop(loop).LoopNum).FluidIndex, + RoutineName); + this->Loop(loop).InletCp = FluidProperties::GetSpecificHeatGlycol(DataPlant::PlantLoop(this->Loop(loop).LoopNum).FluidName, + DataLoopNode::Node(this->Loop(loop).InletNodeNum).Temp, + DataPlant::PlantLoop(this->Loop(loop).LoopNum).FluidIndex, + RoutineName); + this->Loop(loop).InletTemp = DataLoopNode::Node(this->Loop(loop).InletNodeNum).Temp; + this->Loop(loop).InletMassFlowRate = DataLoopNode::Node(this->Loop(loop).InletNodeNum).MassFlowRate; } } } - void InitAirTerminalUserDefined(int const CompNum, int const ZoneNum) + void UserAirTerminalComponentStruct::initialize(int const ZoneNum) { // SUBROUTINE INFORMATION: @@ -2459,124 +2263,86 @@ namespace UserDefinedComponents { // MODIFIED na // RE-ENGINEERED na - // PURPOSE OF THIS SUBROUTINE: - // - - // METHODOLOGY EMPLOYED: - // - - // REFERENCES: - // na - - // Using/Aliasing - using DataEnvironment::OutBaroPress; - using DataZoneEnergyDemands::ZoneSysEnergyDemand; - using DataZoneEnergyDemands::ZoneSysMoistureDemand; - using FluidProperties::GetDensityGlycol; - using FluidProperties::GetSpecificHeatGlycol; - using Psychrometrics::PsyCpAirFnWTdb; - using Psychrometrics::PsyRhoAirFnPbTdbW; - - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: static std::string const RoutineName("InitAirTerminalUserDefined"); - // INTERFACE BLOCK SPECIFICATIONS: - // na - - // DERIVED TYPE DEFINITIONS: - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - static bool MyOneTimeFlag(true); // one time flag - static Array1D_bool MyFlag; - bool errFlag; - int Loop; - - if (MyOneTimeFlag) { - MyFlag.dimension(NumUserAirTerminals, true); - MyOneTimeFlag = false; - } - - if (MyFlag(CompNum)) { - if (UserAirTerminal(CompNum).NumPlantConnections > 0) { - for (Loop = 1; Loop <= UserAirTerminal(CompNum).NumPlantConnections; ++Loop) { - errFlag = false; - PlantUtilities::ScanPlantLoopsForObject(UserAirTerminal(CompNum).Name, - TypeOf_AirTerminalUserDefined, - UserAirTerminal(CompNum).Loop(Loop).LoopNum, - UserAirTerminal(CompNum).Loop(Loop).LoopSideNum, - UserAirTerminal(CompNum).Loop(Loop).BranchNum, - UserAirTerminal(CompNum).Loop(Loop).CompNum, + if (this->myOneTimeFlag) { + if (this->NumPlantConnections > 0) { + for (int loop = 1; loop <= this->NumPlantConnections; ++loop) { + bool errFlag = false; + PlantUtilities::ScanPlantLoopsForObject(this->Name, + DataPlant::TypeOf_AirTerminalUserDefined, + this->Loop(loop).LoopNum, + this->Loop(loop).LoopSideNum, + this->Loop(loop).BranchNum, + this->Loop(loop).CompNum, errFlag, _, _, _, - UserAirTerminal(CompNum).Loop(Loop).InletNodeNum); + this->Loop(loop).InletNodeNum); if (errFlag) { ShowFatalError("InitPlantUserComponent: Program terminated due to previous condition(s)."); } // set user input for flow priority - PlantLoop(UserAirTerminal(CompNum).Loop(Loop).LoopNum) - .LoopSide(UserAirTerminal(CompNum).Loop(Loop).LoopSideNum) - .Branch(UserAirTerminal(CompNum).Loop(Loop).BranchNum) - .Comp(UserAirTerminal(CompNum).Loop(Loop).CompNum) - .FlowPriority = UserAirTerminal(CompNum).Loop(Loop).FlowPriority; + DataPlant::PlantLoop(this->Loop(loop).LoopNum) + .LoopSide(this->Loop(loop).LoopSideNum) + .Branch(this->Loop(loop).BranchNum) + .Comp(this->Loop(loop).CompNum) + .FlowPriority = this->Loop(loop).FlowPriority; // set user input for how loads served - PlantLoop(UserAirTerminal(CompNum).Loop(Loop).LoopNum) - .LoopSide(UserAirTerminal(CompNum).Loop(Loop).LoopSideNum) - .Branch(UserAirTerminal(CompNum).Loop(Loop).BranchNum) - .Comp(UserAirTerminal(CompNum).Loop(Loop).CompNum) - .HowLoadServed = UserAirTerminal(CompNum).Loop(Loop).HowLoadServed; + DataPlant::PlantLoop(this->Loop(loop).LoopNum) + .LoopSide(this->Loop(loop).LoopSideNum) + .Branch(this->Loop(loop).BranchNum) + .Comp(this->Loop(loop).CompNum) + .HowLoadServed = this->Loop(loop).HowLoadServed; } } + this->myOneTimeFlag = false; } // fill internal variable targets - UserAirTerminal(CompNum).RemainingOutputToHeatingSP = ZoneSysEnergyDemand(ZoneNum).RemainingOutputReqToHeatSP; - UserAirTerminal(CompNum).RemainingOutputToCoolingSP = ZoneSysEnergyDemand(ZoneNum).RemainingOutputReqToCoolSP; - UserAirTerminal(CompNum).RemainingOutputReqToDehumidSP = ZoneSysMoistureDemand(ZoneNum).RemainingOutputReqToDehumidSP; - UserAirTerminal(CompNum).RemainingOutputReqToHumidSP = ZoneSysMoistureDemand(ZoneNum).RemainingOutputReqToHumidSP; - - UserAirTerminal(CompNum).AirLoop.InletRho = PsyRhoAirFnPbTdbW(OutBaroPress, - Node(UserAirTerminal(CompNum).AirLoop.InletNodeNum).Temp, - Node(UserAirTerminal(CompNum).AirLoop.InletNodeNum).HumRat, - RoutineName); - UserAirTerminal(CompNum).AirLoop.InletCp = - PsyCpAirFnWTdb(Node(UserAirTerminal(CompNum).AirLoop.InletNodeNum).HumRat, Node(UserAirTerminal(CompNum).AirLoop.InletNodeNum).Temp); - UserAirTerminal(CompNum).AirLoop.InletTemp = Node(UserAirTerminal(CompNum).AirLoop.InletNodeNum).Temp; - UserAirTerminal(CompNum).AirLoop.InletHumRat = Node(UserAirTerminal(CompNum).AirLoop.InletNodeNum).HumRat; - - if (UserAirTerminal(CompNum).SourceAir.InletNodeNum > 0) { - UserAirTerminal(CompNum).SourceAir.InletRho = PsyRhoAirFnPbTdbW(OutBaroPress, - Node(UserAirTerminal(CompNum).SourceAir.InletNodeNum).Temp, - Node(UserAirTerminal(CompNum).SourceAir.InletNodeNum).HumRat, - RoutineName); - UserAirTerminal(CompNum).SourceAir.InletCp = PsyCpAirFnWTdb(Node(UserAirTerminal(CompNum).SourceAir.InletNodeNum).HumRat, - Node(UserAirTerminal(CompNum).SourceAir.InletNodeNum).Temp); - UserAirTerminal(CompNum).SourceAir.InletTemp = Node(UserAirTerminal(CompNum).SourceAir.InletNodeNum).Temp; - UserAirTerminal(CompNum).SourceAir.InletHumRat = Node(UserAirTerminal(CompNum).SourceAir.InletNodeNum).HumRat; + this->RemainingOutputToHeatingSP = DataZoneEnergyDemands::ZoneSysEnergyDemand(ZoneNum).RemainingOutputReqToHeatSP; + this->RemainingOutputToCoolingSP = DataZoneEnergyDemands::ZoneSysEnergyDemand(ZoneNum).RemainingOutputReqToCoolSP; + this->RemainingOutputReqToDehumidSP = DataZoneEnergyDemands::ZoneSysMoistureDemand(ZoneNum).RemainingOutputReqToDehumidSP; + this->RemainingOutputReqToHumidSP = DataZoneEnergyDemands::ZoneSysMoistureDemand(ZoneNum).RemainingOutputReqToHumidSP; + + this->AirLoop.InletRho = Psychrometrics::PsyRhoAirFnPbTdbW(DataEnvironment::OutBaroPress, + DataLoopNode::Node(this->AirLoop.InletNodeNum).Temp, + DataLoopNode::Node(this->AirLoop.InletNodeNum).HumRat, + RoutineName); + this->AirLoop.InletCp = Psychrometrics::PsyCpAirFnWTdb(DataLoopNode::Node(this->AirLoop.InletNodeNum).HumRat, + DataLoopNode::Node(this->AirLoop.InletNodeNum).Temp); + this->AirLoop.InletTemp = DataLoopNode::Node(this->AirLoop.InletNodeNum).Temp; + this->AirLoop.InletHumRat = DataLoopNode::Node(this->AirLoop.InletNodeNum).HumRat; + + if (this->SourceAir.InletNodeNum > 0) { + this->SourceAir.InletRho = Psychrometrics::PsyRhoAirFnPbTdbW(DataEnvironment::OutBaroPress, + DataLoopNode::Node(this->SourceAir.InletNodeNum).Temp, + DataLoopNode::Node(this->SourceAir.InletNodeNum).HumRat, + RoutineName); + this->SourceAir.InletCp = Psychrometrics::PsyCpAirFnWTdb(DataLoopNode::Node(this->SourceAir.InletNodeNum).HumRat, + DataLoopNode::Node(this->SourceAir.InletNodeNum).Temp); + this->SourceAir.InletTemp = DataLoopNode::Node(this->SourceAir.InletNodeNum).Temp; + this->SourceAir.InletHumRat = DataLoopNode::Node(this->SourceAir.InletNodeNum).HumRat; } - if (UserAirTerminal(CompNum).NumPlantConnections > 0) { - for (Loop = 1; Loop <= UserAirTerminal(CompNum).NumPlantConnections; ++Loop) { - UserAirTerminal(CompNum).Loop(Loop).InletRho = GetDensityGlycol(PlantLoop(UserAirTerminal(CompNum).Loop(Loop).LoopNum).FluidName, - Node(UserAirTerminal(CompNum).Loop(Loop).InletNodeNum).Temp, - PlantLoop(UserAirTerminal(CompNum).Loop(Loop).LoopNum).FluidIndex, - RoutineName); - UserAirTerminal(CompNum).Loop(Loop).InletCp = GetSpecificHeatGlycol(PlantLoop(UserAirTerminal(CompNum).Loop(Loop).LoopNum).FluidName, - Node(UserAirTerminal(CompNum).Loop(Loop).InletNodeNum).Temp, - PlantLoop(UserAirTerminal(CompNum).Loop(Loop).LoopNum).FluidIndex, - RoutineName); - UserAirTerminal(CompNum).Loop(Loop).InletTemp = Node(UserAirTerminal(CompNum).Loop(Loop).InletNodeNum).Temp; - UserAirTerminal(CompNum).Loop(Loop).InletMassFlowRate = Node(UserAirTerminal(CompNum).Loop(Loop).InletNodeNum).MassFlowRate; + if (this->NumPlantConnections > 0) { + for (int loop = 1; loop <= this->NumPlantConnections; ++loop) { + this->Loop(loop).InletRho = FluidProperties::GetDensityGlycol(DataPlant::PlantLoop(this->Loop(loop).LoopNum).FluidName, + DataLoopNode::Node(this->Loop(loop).InletNodeNum).Temp, + DataPlant::PlantLoop(this->Loop(loop).LoopNum).FluidIndex, + RoutineName); + this->Loop(loop).InletCp = FluidProperties::GetSpecificHeatGlycol(DataPlant::PlantLoop(this->Loop(loop).LoopNum).FluidName, + DataLoopNode::Node(this->Loop(loop).InletNodeNum).Temp, + DataPlant::PlantLoop(this->Loop(loop).LoopNum).FluidIndex, + RoutineName); + this->Loop(loop).InletTemp = DataLoopNode::Node(this->Loop(loop).InletNodeNum).Temp; + this->Loop(loop).InletMassFlowRate = DataLoopNode::Node(this->Loop(loop).InletNodeNum).MassFlowRate; } } } - void ReportPlantUserComponent(int const CompNum, int const LoopNum) + void UserPlantComponentStruct::report(int const LoopNum) { // SUBROUTINE INFORMATION: @@ -2591,79 +2357,54 @@ namespace UserDefinedComponents { // METHODOLOGY EMPLOYED: // copy actuated values to structures elsewhere in program. - // REFERENCES: - // na - - // Using/Aliasing - using PlantUtilities::SafeCopyPlantNode; - using PlantUtilities::SetComponentFlowRate; - using Psychrometrics::PsyHFnTdbW; - - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS: - // na - - // DERIVED TYPE DEFINITIONS: - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - - SafeCopyPlantNode(UserPlantComp(CompNum).Loop(LoopNum).InletNodeNum, UserPlantComp(CompNum).Loop(LoopNum).OutletNodeNum); + PlantUtilities::SafeCopyPlantNode(this->Loop(LoopNum).InletNodeNum, this->Loop(LoopNum).OutletNodeNum); // unload Actuators to node data structure - Node(UserPlantComp(CompNum).Loop(LoopNum).OutletNodeNum).Temp = UserPlantComp(CompNum).Loop(LoopNum).OutletTemp; + DataLoopNode::Node(this->Loop(LoopNum).OutletNodeNum).Temp = this->Loop(LoopNum).OutletTemp; // make mass flow requests, just this loop - SetComponentFlowRate(UserPlantComp(CompNum).Loop(LoopNum).MassFlowRateRequest, - UserPlantComp(CompNum).Loop(LoopNum).InletNodeNum, - UserPlantComp(CompNum).Loop(LoopNum).OutletNodeNum, - UserPlantComp(CompNum).Loop(LoopNum).LoopNum, - UserPlantComp(CompNum).Loop(LoopNum).LoopSideNum, - UserPlantComp(CompNum).Loop(LoopNum).BranchNum, - UserPlantComp(CompNum).Loop(LoopNum).CompNum); - - if (UserPlantComp(CompNum).Air.OutletNodeNum > 0) { - Node(UserPlantComp(CompNum).Air.OutletNodeNum).Temp = UserPlantComp(CompNum).Air.OutletTemp; - Node(UserPlantComp(CompNum).Air.OutletNodeNum).HumRat = UserPlantComp(CompNum).Air.OutletHumRat; - Node(UserPlantComp(CompNum).Air.OutletNodeNum).MassFlowRate = UserPlantComp(CompNum).Air.OutletMassFlowRate; - Node(UserPlantComp(CompNum).Air.OutletNodeNum).Enthalpy = - PsyHFnTdbW(UserPlantComp(CompNum).Air.OutletTemp, UserPlantComp(CompNum).Air.OutletHumRat); + PlantUtilities::SetComponentFlowRate(this->Loop(LoopNum).MassFlowRateRequest, + this->Loop(LoopNum).InletNodeNum, + this->Loop(LoopNum).OutletNodeNum, + this->Loop(LoopNum).LoopNum, + this->Loop(LoopNum).LoopSideNum, + this->Loop(LoopNum).BranchNum, + this->Loop(LoopNum).CompNum); + + if (this->Air.OutletNodeNum > 0) { + DataLoopNode::Node(this->Air.OutletNodeNum).Temp = this->Air.OutletTemp; + DataLoopNode::Node(this->Air.OutletNodeNum).HumRat = this->Air.OutletHumRat; + DataLoopNode::Node(this->Air.OutletNodeNum).MassFlowRate = this->Air.OutletMassFlowRate; + DataLoopNode::Node(this->Air.OutletNodeNum).Enthalpy = Psychrometrics::PsyHFnTdbW(this->Air.OutletTemp, this->Air.OutletHumRat); } - if (UserPlantComp(CompNum).Water.SuppliedByWaterSystem) { - WaterStorage(UserPlantComp(CompNum).Water.SupplyTankID).VdotRequestDemand(UserPlantComp(CompNum).Water.SupplyTankDemandARRID) = - UserPlantComp(CompNum).Water.SupplyVdotRequest; + if (this->Water.SuppliedByWaterSystem) { + DataWater::WaterStorage(this->Water.SupplyTankID).VdotRequestDemand(this->Water.SupplyTankDemandARRID) = this->Water.SupplyVdotRequest; } - if (UserPlantComp(CompNum).Water.CollectsToWaterSystem) { - WaterStorage(UserPlantComp(CompNum).Water.CollectionTankID).VdotAvailSupply(UserPlantComp(CompNum).Water.CollectionTankSupplyARRID) = - UserPlantComp(CompNum).Water.CollectedVdot; + if (this->Water.CollectsToWaterSystem) { + DataWater::WaterStorage(this->Water.CollectionTankID).VdotAvailSupply(this->Water.CollectionTankSupplyARRID) = this->Water.CollectedVdot; } - if (UserPlantComp(CompNum).Loop(LoopNum).HowLoadServed == HowMet_ByNominalCapLowOutLimit) { - PlantLoop(UserPlantComp(CompNum).Loop(LoopNum).LoopNum) - .LoopSide(UserPlantComp(CompNum).Loop(LoopNum).LoopSideNum) - .Branch(UserPlantComp(CompNum).Loop(LoopNum).BranchNum) - .Comp(UserPlantComp(CompNum).Loop(LoopNum).CompNum) - .MinOutletTemp = UserPlantComp(CompNum).Loop(LoopNum).LowOutTempLimit; + if (this->Loop(LoopNum).HowLoadServed == DataPlant::HowMet_ByNominalCapLowOutLimit) { + DataPlant::PlantLoop(this->Loop(LoopNum).LoopNum) + .LoopSide(this->Loop(LoopNum).LoopSideNum) + .Branch(this->Loop(LoopNum).BranchNum) + .Comp(this->Loop(LoopNum).CompNum) + .MinOutletTemp = this->Loop(LoopNum).LowOutTempLimit; } - if (UserPlantComp(CompNum).Loop(LoopNum).HowLoadServed == HowMet_ByNominalCapHiOutLimit) { - PlantLoop(UserPlantComp(CompNum).Loop(LoopNum).LoopNum) - .LoopSide(UserPlantComp(CompNum).Loop(LoopNum).LoopSideNum) - .Branch(UserPlantComp(CompNum).Loop(LoopNum).BranchNum) - .Comp(UserPlantComp(CompNum).Loop(LoopNum).CompNum) - .MaxOutletTemp = UserPlantComp(CompNum).Loop(LoopNum).HiOutTempLimit; + if (this->Loop(LoopNum).HowLoadServed == DataPlant::HowMet_ByNominalCapHiOutLimit) { + DataPlant::PlantLoop(this->Loop(LoopNum).LoopNum) + .LoopSide(this->Loop(LoopNum).LoopSideNum) + .Branch(this->Loop(LoopNum).BranchNum) + .Comp(this->Loop(LoopNum).CompNum) + .MaxOutletTemp = this->Loop(LoopNum).HiOutTempLimit; } } - void ReportCoilUserDefined(int const CompNum) + void UserCoilComponentStruct::report() { // SUBROUTINE INFORMATION: @@ -2675,73 +2416,45 @@ namespace UserDefinedComponents { // PURPOSE OF THIS SUBROUTINE: // report model outputs - // METHODOLOGY EMPLOYED: - // - - // REFERENCES: - // na - - // Using/Aliasing - using PlantUtilities::SafeCopyPlantNode; - using PlantUtilities::SetComponentFlowRate; - using Psychrometrics::PsyHFnTdbW; - - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS: - // na - - // DERIVED TYPE DEFINITIONS: - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - int Loop; - - for (Loop = 1; Loop <= UserCoil(CompNum).NumAirConnections; ++Loop) { - if (UserCoil(CompNum).Air(Loop).OutletNodeNum > 0) { - Node(UserCoil(CompNum).Air(Loop).OutletNodeNum).Temp = UserCoil(CompNum).Air(Loop).OutletTemp; - Node(UserCoil(CompNum).Air(Loop).OutletNodeNum).HumRat = UserCoil(CompNum).Air(Loop).OutletHumRat; - Node(UserCoil(CompNum).Air(Loop).OutletNodeNum).MassFlowRate = UserCoil(CompNum).Air(Loop).OutletMassFlowRate; - Node(UserCoil(CompNum).Air(Loop).OutletNodeNum).Enthalpy = - PsyHFnTdbW(UserCoil(CompNum).Air(Loop).OutletTemp, UserCoil(CompNum).Air(Loop).OutletHumRat); - - Node(UserCoil(CompNum).Air(Loop).OutletNodeNum).MassFlowRateMinAvail = - Node(UserCoil(CompNum).Air(Loop).InletNodeNum).MassFlowRateMinAvail; - Node(UserCoil(CompNum).Air(Loop).OutletNodeNum).MassFlowRateMaxAvail = - Node(UserCoil(CompNum).Air(Loop).InletNodeNum).MassFlowRateMaxAvail; + for (int loop = 1; loop <= this->NumAirConnections; ++loop) { + if (this->Air(loop).OutletNodeNum > 0) { + DataLoopNode::Node(this->Air(loop).OutletNodeNum).Temp = this->Air(loop).OutletTemp; + DataLoopNode::Node(this->Air(loop).OutletNodeNum).HumRat = this->Air(loop).OutletHumRat; + DataLoopNode::Node(this->Air(loop).OutletNodeNum).MassFlowRate = this->Air(loop).OutletMassFlowRate; + DataLoopNode::Node(this->Air(loop).OutletNodeNum).Enthalpy = + Psychrometrics::PsyHFnTdbW(this->Air(loop).OutletTemp, this->Air(loop).OutletHumRat); + + DataLoopNode::Node(this->Air(loop).OutletNodeNum).MassFlowRateMinAvail = + DataLoopNode::Node(this->Air(loop).InletNodeNum).MassFlowRateMinAvail; + DataLoopNode::Node(this->Air(loop).OutletNodeNum).MassFlowRateMaxAvail = + DataLoopNode::Node(this->Air(loop).InletNodeNum).MassFlowRateMaxAvail; } } - if (UserCoil(CompNum).PlantIsConnected) { + if (this->PlantIsConnected) { // make mass flow requests - SetComponentFlowRate(UserCoil(CompNum).Loop.MassFlowRateRequest, - UserCoil(CompNum).Loop.InletNodeNum, - UserCoil(CompNum).Loop.OutletNodeNum, - UserCoil(CompNum).Loop.LoopNum, - UserCoil(CompNum).Loop.LoopSideNum, - UserCoil(CompNum).Loop.BranchNum, - UserCoil(CompNum).Loop.CompNum); - SafeCopyPlantNode(UserCoil(CompNum).Loop.InletNodeNum, UserCoil(CompNum).Loop.OutletNodeNum); + PlantUtilities::SetComponentFlowRate(this->Loop.MassFlowRateRequest, + this->Loop.InletNodeNum, + this->Loop.OutletNodeNum, + this->Loop.LoopNum, + this->Loop.LoopSideNum, + this->Loop.BranchNum, + this->Loop.CompNum); + PlantUtilities::SafeCopyPlantNode(this->Loop.InletNodeNum, this->Loop.OutletNodeNum); // unload Actuators to node data structure - Node(UserCoil(CompNum).Loop.OutletNodeNum).Temp = UserCoil(CompNum).Loop.OutletTemp; + DataLoopNode::Node(this->Loop.OutletNodeNum).Temp = this->Loop.OutletTemp; } - if (UserCoil(CompNum).Water.SuppliedByWaterSystem) { - WaterStorage(UserCoil(CompNum).Water.SupplyTankID).VdotRequestDemand(UserCoil(CompNum).Water.SupplyTankDemandARRID) = - UserCoil(CompNum).Water.SupplyVdotRequest; + if (this->Water.SuppliedByWaterSystem) { + DataWater::WaterStorage(this->Water.SupplyTankID).VdotRequestDemand(this->Water.SupplyTankDemandARRID) = this->Water.SupplyVdotRequest; } - if (UserCoil(CompNum).Water.CollectsToWaterSystem) { - WaterStorage(UserCoil(CompNum).Water.CollectionTankID).VdotAvailSupply(UserCoil(CompNum).Water.CollectionTankSupplyARRID) = - UserCoil(CompNum).Water.CollectedVdot; + if (this->Water.CollectsToWaterSystem) { + DataWater::WaterStorage(this->Water.CollectionTankID).VdotAvailSupply(this->Water.CollectionTankSupplyARRID) = this->Water.CollectedVdot; } } - void ReportZoneAirUserDefined(int const CompNum) + void UserZoneHVACForcedAirComponentStruct::report() { // SUBROUTINE INFORMATION: @@ -2753,76 +2466,47 @@ namespace UserDefinedComponents { // PURPOSE OF THIS SUBROUTINE: // report model outputs - // METHODOLOGY EMPLOYED: - // - - // REFERENCES: - // na - - // Using/Aliasing - using PlantUtilities::SafeCopyPlantNode; - using PlantUtilities::SetComponentFlowRate; - using Psychrometrics::PsyHFnTdbW; - - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS: - // na - - // DERIVED TYPE DEFINITIONS: - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - int Loop; + DataLoopNode::Node(this->ZoneAir.InletNodeNum).MassFlowRate = this->ZoneAir.InletMassFlowRate; - Node(UserZoneAirHVAC(CompNum).ZoneAir.InletNodeNum).MassFlowRate = UserZoneAirHVAC(CompNum).ZoneAir.InletMassFlowRate; + DataLoopNode::Node(this->ZoneAir.OutletNodeNum).Temp = this->ZoneAir.OutletTemp; + DataLoopNode::Node(this->ZoneAir.OutletNodeNum).HumRat = this->ZoneAir.OutletHumRat; + DataLoopNode::Node(this->ZoneAir.OutletNodeNum).MassFlowRate = this->ZoneAir.OutletMassFlowRate; + DataLoopNode::Node(this->ZoneAir.OutletNodeNum).Enthalpy = Psychrometrics::PsyHFnTdbW(this->ZoneAir.OutletTemp, this->ZoneAir.OutletHumRat); - Node(UserZoneAirHVAC(CompNum).ZoneAir.OutletNodeNum).Temp = UserZoneAirHVAC(CompNum).ZoneAir.OutletTemp; - Node(UserZoneAirHVAC(CompNum).ZoneAir.OutletNodeNum).HumRat = UserZoneAirHVAC(CompNum).ZoneAir.OutletHumRat; - Node(UserZoneAirHVAC(CompNum).ZoneAir.OutletNodeNum).MassFlowRate = UserZoneAirHVAC(CompNum).ZoneAir.OutletMassFlowRate; - Node(UserZoneAirHVAC(CompNum).ZoneAir.OutletNodeNum).Enthalpy = - PsyHFnTdbW(UserZoneAirHVAC(CompNum).ZoneAir.OutletTemp, UserZoneAirHVAC(CompNum).ZoneAir.OutletHumRat); - - if (UserZoneAirHVAC(CompNum).SourceAir.OutletNodeNum > 0) { - Node(UserZoneAirHVAC(CompNum).SourceAir.OutletNodeNum).Temp = UserZoneAirHVAC(CompNum).SourceAir.OutletTemp; - Node(UserZoneAirHVAC(CompNum).SourceAir.OutletNodeNum).HumRat = UserZoneAirHVAC(CompNum).SourceAir.OutletHumRat; - Node(UserZoneAirHVAC(CompNum).SourceAir.OutletNodeNum).MassFlowRate = UserZoneAirHVAC(CompNum).SourceAir.OutletMassFlowRate; - Node(UserZoneAirHVAC(CompNum).SourceAir.OutletNodeNum).Enthalpy = - PsyHFnTdbW(UserZoneAirHVAC(CompNum).SourceAir.OutletTemp, UserZoneAirHVAC(CompNum).SourceAir.OutletHumRat); + if (this->SourceAir.OutletNodeNum > 0) { + DataLoopNode::Node(this->SourceAir.OutletNodeNum).Temp = this->SourceAir.OutletTemp; + DataLoopNode::Node(this->SourceAir.OutletNodeNum).HumRat = this->SourceAir.OutletHumRat; + DataLoopNode::Node(this->SourceAir.OutletNodeNum).MassFlowRate = this->SourceAir.OutletMassFlowRate; + DataLoopNode::Node(this->SourceAir.OutletNodeNum).Enthalpy = + Psychrometrics::PsyHFnTdbW(this->SourceAir.OutletTemp, this->SourceAir.OutletHumRat); } - if (UserZoneAirHVAC(CompNum).NumPlantConnections > 0) { - for (Loop = 1; Loop <= UserZoneAirHVAC(CompNum).NumPlantConnections; ++Loop) { + if (this->NumPlantConnections > 0) { + for (int loop = 1; loop <= this->NumPlantConnections; ++loop) { // make mass flow requests - SetComponentFlowRate(UserZoneAirHVAC(CompNum).Loop(Loop).MassFlowRateRequest, - UserZoneAirHVAC(CompNum).Loop(Loop).InletNodeNum, - UserZoneAirHVAC(CompNum).Loop(Loop).OutletNodeNum, - UserZoneAirHVAC(CompNum).Loop(Loop).LoopNum, - UserZoneAirHVAC(CompNum).Loop(Loop).LoopSideNum, - UserZoneAirHVAC(CompNum).Loop(Loop).BranchNum, - UserZoneAirHVAC(CompNum).Loop(Loop).CompNum); - SafeCopyPlantNode(UserZoneAirHVAC(CompNum).Loop(Loop).InletNodeNum, UserZoneAirHVAC(CompNum).Loop(Loop).OutletNodeNum); + PlantUtilities::SetComponentFlowRate(this->Loop(loop).MassFlowRateRequest, + this->Loop(loop).InletNodeNum, + this->Loop(loop).OutletNodeNum, + this->Loop(loop).LoopNum, + this->Loop(loop).LoopSideNum, + this->Loop(loop).BranchNum, + this->Loop(loop).CompNum); + PlantUtilities::SafeCopyPlantNode(this->Loop(loop).InletNodeNum, this->Loop(loop).OutletNodeNum); // unload Actuators to node data structure - Node(UserZoneAirHVAC(CompNum).Loop(Loop).OutletNodeNum).Temp = UserZoneAirHVAC(CompNum).Loop(Loop).OutletTemp; + DataLoopNode::Node(this->Loop(loop).OutletNodeNum).Temp = this->Loop(loop).OutletTemp; } } - if (UserZoneAirHVAC(CompNum).Water.SuppliedByWaterSystem) { - WaterStorage(UserZoneAirHVAC(CompNum).Water.SupplyTankID).VdotRequestDemand(UserZoneAirHVAC(CompNum).Water.SupplyTankDemandARRID) = - UserZoneAirHVAC(CompNum).Water.SupplyVdotRequest; + if (this->Water.SuppliedByWaterSystem) { + DataWater::WaterStorage(this->Water.SupplyTankID).VdotRequestDemand(this->Water.SupplyTankDemandARRID) = this->Water.SupplyVdotRequest; } - if (UserZoneAirHVAC(CompNum).Water.CollectsToWaterSystem) { - WaterStorage(UserZoneAirHVAC(CompNum).Water.CollectionTankID).VdotAvailSupply(UserZoneAirHVAC(CompNum).Water.CollectionTankSupplyARRID) = - UserZoneAirHVAC(CompNum).Water.CollectedVdot; + if (this->Water.CollectsToWaterSystem) { + DataWater::WaterStorage(this->Water.CollectionTankID).VdotAvailSupply(this->Water.CollectionTankSupplyARRID) = this->Water.CollectedVdot; } } - void ReportAirTerminalUserDefined(int const CompNum) + void UserAirTerminalComponentStruct::report() { // SUBROUTINE INFORMATION: @@ -2831,75 +2515,42 @@ namespace UserDefinedComponents { // MODIFIED na // RE-ENGINEERED na - // PURPOSE OF THIS SUBROUTINE: - // - - // METHODOLOGY EMPLOYED: - // - - // REFERENCES: - // na - - // Using/Aliasing - using PlantUtilities::SafeCopyPlantNode; - using PlantUtilities::SetComponentFlowRate; - using Psychrometrics::PsyHFnTdbW; - - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS: - // na - - // DERIVED TYPE DEFINITIONS: - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - // na - int Loop; - - Node(UserAirTerminal(CompNum).AirLoop.InletNodeNum).MassFlowRate = UserAirTerminal(CompNum).AirLoop.InletMassFlowRate; - - Node(UserAirTerminal(CompNum).AirLoop.OutletNodeNum).Temp = UserAirTerminal(CompNum).AirLoop.OutletTemp; - Node(UserAirTerminal(CompNum).AirLoop.OutletNodeNum).HumRat = UserAirTerminal(CompNum).AirLoop.OutletHumRat; - Node(UserAirTerminal(CompNum).AirLoop.OutletNodeNum).MassFlowRate = UserAirTerminal(CompNum).AirLoop.OutletMassFlowRate; - Node(UserAirTerminal(CompNum).AirLoop.OutletNodeNum).Enthalpy = - PsyHFnTdbW(UserAirTerminal(CompNum).AirLoop.OutletTemp, UserAirTerminal(CompNum).AirLoop.OutletHumRat); - if (UserAirTerminal(CompNum).SourceAir.OutletNodeNum > 0) { - Node(UserAirTerminal(CompNum).SourceAir.OutletNodeNum).Temp = UserAirTerminal(CompNum).SourceAir.OutletTemp; - Node(UserAirTerminal(CompNum).SourceAir.OutletNodeNum).HumRat = UserAirTerminal(CompNum).SourceAir.OutletHumRat; - Node(UserAirTerminal(CompNum).SourceAir.OutletNodeNum).MassFlowRate = UserAirTerminal(CompNum).SourceAir.OutletMassFlowRate; - Node(UserAirTerminal(CompNum).SourceAir.OutletNodeNum).Enthalpy = - PsyHFnTdbW(UserAirTerminal(CompNum).SourceAir.OutletTemp, UserAirTerminal(CompNum).SourceAir.OutletHumRat); + DataLoopNode::Node(this->AirLoop.InletNodeNum).MassFlowRate = this->AirLoop.InletMassFlowRate; + + DataLoopNode::Node(this->AirLoop.OutletNodeNum).Temp = this->AirLoop.OutletTemp; + DataLoopNode::Node(this->AirLoop.OutletNodeNum).HumRat = this->AirLoop.OutletHumRat; + DataLoopNode::Node(this->AirLoop.OutletNodeNum).MassFlowRate = this->AirLoop.OutletMassFlowRate; + DataLoopNode::Node(this->AirLoop.OutletNodeNum).Enthalpy = Psychrometrics::PsyHFnTdbW(this->AirLoop.OutletTemp, this->AirLoop.OutletHumRat); + if (this->SourceAir.OutletNodeNum > 0) { + DataLoopNode::Node(this->SourceAir.OutletNodeNum).Temp = this->SourceAir.OutletTemp; + DataLoopNode::Node(this->SourceAir.OutletNodeNum).HumRat = this->SourceAir.OutletHumRat; + DataLoopNode::Node(this->SourceAir.OutletNodeNum).MassFlowRate = this->SourceAir.OutletMassFlowRate; + DataLoopNode::Node(this->SourceAir.OutletNodeNum).Enthalpy = + Psychrometrics::PsyHFnTdbW(this->SourceAir.OutletTemp, this->SourceAir.OutletHumRat); } - if (UserAirTerminal(CompNum).NumPlantConnections > 0) { - for (Loop = 1; Loop <= UserAirTerminal(CompNum).NumPlantConnections; ++Loop) { + if (this->NumPlantConnections > 0) { + for (int loop = 1; loop <= this->NumPlantConnections; ++loop) { // make mass flow requests - SetComponentFlowRate(UserAirTerminal(CompNum).Loop(Loop).MassFlowRateRequest, - UserAirTerminal(CompNum).Loop(Loop).InletNodeNum, - UserAirTerminal(CompNum).Loop(Loop).OutletNodeNum, - UserAirTerminal(CompNum).Loop(Loop).LoopNum, - UserAirTerminal(CompNum).Loop(Loop).LoopSideNum, - UserAirTerminal(CompNum).Loop(Loop).BranchNum, - UserAirTerminal(CompNum).Loop(Loop).CompNum); - SafeCopyPlantNode(UserAirTerminal(CompNum).Loop(Loop).InletNodeNum, UserAirTerminal(CompNum).Loop(Loop).OutletNodeNum); + PlantUtilities::SetComponentFlowRate(this->Loop(loop).MassFlowRateRequest, + this->Loop(loop).InletNodeNum, + this->Loop(loop).OutletNodeNum, + this->Loop(loop).LoopNum, + this->Loop(loop).LoopSideNum, + this->Loop(loop).BranchNum, + this->Loop(loop).CompNum); + PlantUtilities::SafeCopyPlantNode(this->Loop(loop).InletNodeNum, this->Loop(loop).OutletNodeNum); // unload Actuators to node data structure - Node(UserAirTerminal(CompNum).Loop(Loop).OutletNodeNum).Temp = UserAirTerminal(CompNum).Loop(Loop).OutletTemp; + DataLoopNode::Node(this->Loop(loop).OutletNodeNum).Temp = this->Loop(loop).OutletTemp; } } - if (UserAirTerminal(CompNum).Water.SuppliedByWaterSystem) { - WaterStorage(UserAirTerminal(CompNum).Water.SupplyTankID).VdotRequestDemand(UserAirTerminal(CompNum).Water.SupplyTankDemandARRID) = - UserAirTerminal(CompNum).Water.SupplyVdotRequest; + if (this->Water.SuppliedByWaterSystem) { + DataWater::WaterStorage(this->Water.SupplyTankID).VdotRequestDemand(this->Water.SupplyTankDemandARRID) = this->Water.SupplyVdotRequest; } - if (UserAirTerminal(CompNum).Water.CollectsToWaterSystem) { - WaterStorage(UserAirTerminal(CompNum).Water.CollectionTankID).VdotAvailSupply(UserAirTerminal(CompNum).Water.CollectionTankSupplyARRID) = - UserAirTerminal(CompNum).Water.CollectedVdot; + if (this->Water.CollectsToWaterSystem) { + DataWater::WaterStorage(this->Water.CollectionTankID).VdotAvailSupply(this->Water.CollectionTankSupplyARRID) = this->Water.CollectedVdot; } } @@ -2947,7 +2598,6 @@ namespace UserDefinedComponents { // This subroutine gets a given user defined Cooling Coil's air inlet node -- issues error message if that // coil is not a legal user defined Cooling Coil and sets air node to 0, otherwise, returns inlet air node number. - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int CoilIndex; // Obtains and allocates TESCoil related parameters from input file @@ -2985,7 +2635,6 @@ namespace UserDefinedComponents { // This subroutine gets a given user defined Cooling Coil's air outlet node -- issues error message if that // coil is not a legal user defined Cooling Coil and sets air node to 0, otherwise, returns outlet air node number. - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int CoilIndex; // Obtains and allocates TESCoil related parameters from input file diff --git a/src/EnergyPlus/UserDefinedComponents.hh b/src/EnergyPlus/UserDefinedComponents.hh index ebe222c03da..94cb7011915 100644 --- a/src/EnergyPlus/UserDefinedComponents.hh +++ b/src/EnergyPlus/UserDefinedComponents.hh @@ -55,23 +55,12 @@ #include #include #include +#include namespace EnergyPlus { namespace UserDefinedComponents { - // Using/Aliasing - using DataPlant::HowMet_Unknown; - using DataPlant::LoopFlowStatus_Unknown; - - // Data - // MODULE PARAMETER DEFINITIONS: - // na - - // DERIVED TYPE DEFINITIONS: - - // MODULE VARIABLE DECLARATIONS: - extern int NumUserPlantComps; extern int NumUserCoils; extern int NumUserZoneAir; @@ -81,11 +70,6 @@ namespace UserDefinedComponents { extern Array1D_bool CheckUserCoilName; extern Array1D_bool CheckUserZoneAirName; extern Array1D_bool CheckUserAirTerminal; - extern bool GetInput; - - // SUBROUTINE SPECIFICATIONS FOR MODULE : - - // Types struct PlantConnectionStruct { @@ -114,12 +98,12 @@ namespace UserDefinedComponents { Real64 InletCp; // fills internal Variable, current specific heat for fluid type and inlet temperature [J/kg-C] Real64 InletTemp; // fills internal variable, current inlet fluid temperature [C] Real64 InletMassFlowRate; // fills internal variable, current inlet mass flow rate [kg/s] - Real64 OutletTemp; // filled by actuator, componenent outlet temperature [C] + Real64 OutletTemp; // filled by actuator, component outlet temperature [C] // Default Constructor PlantConnectionStruct() : ErlInitProgramMngr(0), ErlSimProgramMngr(0), LoopNum(0), LoopSideNum(0), BranchNum(0), CompNum(0), InletNodeNum(0), OutletNodeNum(0), - FlowPriority(LoopFlowStatus_Unknown), HowLoadServed(HowMet_Unknown), LowOutTempLimit(0.0), HiOutTempLimit(0.0), + FlowPriority(DataPlant::LoopFlowStatus_Unknown), HowLoadServed(DataPlant::HowMet_Unknown), LowOutTempLimit(0.0), HiOutTempLimit(0.0), MassFlowRateRequest(0.0), MassFlowRateMin(0.0), MassFlowRateMax(0.0), DesignVolumeFlowRate(0.0), MyLoad(0.0), MinLoad(0.0), MaxLoad(0.0), OptLoad(0.0), InletRho(0.0), InletCp(0.0), InletTemp(0.0), InletMassFlowRate(0.0), OutletTemp(0.0) { @@ -189,7 +173,7 @@ namespace UserDefinedComponents { } }; - struct UserPlantComponentStruct + struct UserPlantComponentStruct : PlantComponent { // Members std::string Name; // user identifier @@ -199,11 +183,24 @@ namespace UserDefinedComponents { AirConnectionStruct Air; WaterUseTankConnectionStruct Water; ZoneInternalGainsStruct Zone; + bool myOneTimeFlag; // Default Constructor - UserPlantComponentStruct() : ErlSimProgramMngr(0), NumPlantConnections(0) + UserPlantComponentStruct() : ErlSimProgramMngr(0), NumPlantConnections(0), myOneTimeFlag(true) { } + + static PlantComponent *factory(std::string const &objectName); + + void onInitLoopEquip(const PlantLocation &calledFromLocation) override; + + void getDesignCapacities(const PlantLocation &calledFromLocation, Real64 &MaxLoad, Real64 &MinLoad, Real64 &OptLoad) override; + + void simulate(const PlantLocation &calledFromLocation, bool FirstHVACIteration, Real64 &CurLoad, bool RunFlag) override; + + void initialize(int LoopNum, Real64 MyLoad); + + void report(int LoopNum); }; struct UserCoilComponentStruct @@ -212,17 +209,22 @@ namespace UserDefinedComponents { std::string Name; // user identifier int ErlSimProgramMngr; // EMS:ProgramManager to always run when this model is called int ErlInitProgramMngr; // EMS:ProgramManager to run when this model is initialized and setup - int NumAirConnections; // count of how many air connectiosn there are + int NumAirConnections; // count of how many air connections there are bool PlantIsConnected; Array1D Air; PlantConnectionStruct Loop; WaterUseTankConnectionStruct Water; ZoneInternalGainsStruct Zone; + bool myOneTimeFlag; // Default Constructor - UserCoilComponentStruct() : ErlSimProgramMngr(0), ErlInitProgramMngr(0), NumAirConnections(0), PlantIsConnected(false) + UserCoilComponentStruct() : ErlSimProgramMngr(0), ErlInitProgramMngr(0), NumAirConnections(0), PlantIsConnected(false), myOneTimeFlag(true) { } + + void initialize(); + + void report(); }; struct UserZoneHVACForcedAirComponentStruct @@ -241,13 +243,18 @@ namespace UserDefinedComponents { Real64 RemainingOutputToCoolingSP; // sensible load remaining for device, negative means cooling [W] Real64 RemainingOutputReqToHumidSP; // latent load remaining for device, to humidification setpoint [kg/s] Real64 RemainingOutputReqToDehumidSP; // latent load remaining for device, Negative means dehumidify [kg/s] + bool myOneTimeFlag; // Default Constructor UserZoneHVACForcedAirComponentStruct() : ErlSimProgramMngr(0), ErlInitProgramMngr(0), NumPlantConnections(0), RemainingOutputToHeatingSP(0.0), RemainingOutputToCoolingSP(0.0), - RemainingOutputReqToHumidSP(0.0), RemainingOutputReqToDehumidSP(0.0) + RemainingOutputReqToHumidSP(0.0), RemainingOutputReqToDehumidSP(0.0), myOneTimeFlag(true) { } + + void initialize(int ZoneNum); + + void report(); }; struct UserAirTerminalComponentStruct @@ -268,13 +275,18 @@ namespace UserDefinedComponents { Real64 RemainingOutputToCoolingSP; // sensible load remaining for device, negative means cooling [W] Real64 RemainingOutputReqToHumidSP; // latent load remaining for device, to humidification setpoint [kg/s] Real64 RemainingOutputReqToDehumidSP; // latent load remaining for device, Negative means dehumidify [kg/s] + bool myOneTimeFlag; // Default Constructor UserAirTerminalComponentStruct() : ActualCtrlZoneNum(0), ADUNum(0), ErlSimProgramMngr(0), ErlInitProgramMngr(0), NumPlantConnections(0), RemainingOutputToHeatingSP(0.0), - RemainingOutputToCoolingSP(0.0), RemainingOutputReqToHumidSP(0.0), RemainingOutputReqToDehumidSP(0.0) + RemainingOutputToCoolingSP(0.0), RemainingOutputReqToHumidSP(0.0), RemainingOutputReqToDehumidSP(0.0), myOneTimeFlag(true) { } + + void initialize(int ZoneNum); + + void report(); }; // Object Data @@ -283,52 +295,26 @@ namespace UserDefinedComponents { extern Array1D UserZoneAirHVAC; extern Array1D UserAirTerminal; - // Functions - - void SimUserDefinedPlantComponent(int const LoopNum, // plant loop sim call originated from - int const LoopSideNum, // plant loop side sim call originated from - std::string const &EquipType, // type of equipment, 'PlantComponent:UserDefined' - std::string const &EquipName, // user name for component - int &CompIndex, - bool &InitLoopEquip, - Real64 const MyLoad, - Real64 &MaxCap, - Real64 &MinCap, - Real64 &OptCap); + void clear_state(); void SimCoilUserDefined(std::string const &EquipName, // user name for component int &CompIndex, - int const AirLoopNum, + int AirLoopNum, bool &HeatingActive, bool &CoolingActive); void SimZoneAirUserDefined(std::string const &CompName, // name of the packaged terminal heat pump - int const ZoneNum, // number of zone being served + int ZoneNum, // number of zone being served Real64 &SensibleOutputProvided, // sensible capacity delivered to zone Real64 &LatentOutputProvided, // Latent add/removal (kg/s), dehumid = negative int &CompIndex // index to zone hvac unit ); - void - SimAirTerminalUserDefined(std::string const &CompName, bool const FirstHVACIteration, int const ZoneNum, int const ZoneNodeNum, int &CompIndex); - - void GetUserDefinedComponents(); - - void InitPlantUserComponent(int const CompNum, int const LoopNum, Real64 const MyLoad); - - void InitCoilUserDefined(int const CompNum); - - void InitZoneAirUserDefined(int const CompNum, int const ZoneNum); - - void InitAirTerminalUserDefined(int const CompNum, int const ZoneNum); + void SimAirTerminalUserDefined(std::string const &CompName, bool FirstHVACIteration, int ZoneNum, int ZoneNodeNum, int &CompIndex); - void ReportPlantUserComponent(int const CompNum, int const LoopNum); + void GetUserDefinedPlantComponents(); - void ReportCoilUserDefined(int const CompNum); - - void ReportZoneAirUserDefined(int const CompNum); - - void ReportAirTerminalUserDefined(int const CompNum); + void GetUserDefinedComponents(); void GetUserDefinedCoilIndex(std::string const &CoilName, int &CoilIndex, bool &ErrorsFound, std::string const &CurrentModuleObject); diff --git a/tst/EnergyPlus/unit/Fixtures/EnergyPlusFixture.cc b/tst/EnergyPlus/unit/Fixtures/EnergyPlusFixture.cc index 669dab981c7..dd93d95c71c 100644 --- a/tst/EnergyPlus/unit/Fixtures/EnergyPlusFixture.cc +++ b/tst/EnergyPlus/unit/Fixtures/EnergyPlusFixture.cc @@ -215,6 +215,8 @@ #include #include #include +#include +#include #include #include #include @@ -464,6 +466,7 @@ void EnergyPlusFixture::clear_all_states() UnitarySystems::clear_state(); UnitHeater::clear_state(); UnitVentilator::clear_state(); + UserDefinedComponents::clear_state(); VariableSpeedCoils::clear_state(); VentilatedSlab::clear_state(); WaterCoils::clear_state();