From 397f70341cbf20e7a17ec5d1573c0db2dc92c358 Mon Sep 17 00:00:00 2001 From: Li Date: Wed, 9 Oct 2019 13:53:03 -0600 Subject: [PATCH 01/51] Clean up comments; no diffs for regression tests --- src/EnergyPlus/WaterUse.cc | 60 ++------------------------------------ 1 file changed, 2 insertions(+), 58 deletions(-) diff --git a/src/EnergyPlus/WaterUse.cc b/src/EnergyPlus/WaterUse.cc index 1d8f594ad58..3eb6769284d 100644 --- a/src/EnergyPlus/WaterUse.cc +++ b/src/EnergyPlus/WaterUse.cc @@ -138,8 +138,6 @@ namespace WaterUse { // This routine is called from non zone equipment manager and serves to call // water use and connections that are not connected to a full plant loop - // METHODOLOGY EMPLOYED: - // Using/Aliasing using General::RoundSigDigits; @@ -148,8 +146,6 @@ namespace WaterUse { int const MaxIterations(100); Real64 const Tolerance(0.1); // Make input? - // SUBROUTINE ARGUMENT DEFINITIONS: - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int WaterEquipNum; int WaterConnNum; @@ -252,8 +248,6 @@ namespace WaterUse { // Plant sim call for plant loop connected water use and connections // (based on SimulateWaterUse by P. Ellis) - // METHODOLOGY EMPLOYED: - // Using/Aliasing using General::RoundSigDigits; using General::TrimSigDigits; @@ -263,8 +257,6 @@ namespace WaterUse { int const MaxIterations(100); Real64 const Tolerance(0.1); // Make input? - // SUBROUTINE ARGUMENT DEFINITIONS: - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: // INTEGER :: WaterEquipNum int WaterConnNum; @@ -364,10 +356,7 @@ namespace WaterUse { // MODIFIED na // RE-ENGINEERED na - // PURPOSE OF THIS SUBROUTINE: - - // METHODOLOGY EMPLOYED: - // Standard EnergyPlus methodology. + // METHODOLOGY EMPLOYED: Standard EnergyPlus methodology. // Using/Aliasing using namespace DataIPShortCuts; // Data for field names, blank numerics @@ -1073,7 +1062,6 @@ namespace WaterUse { // PURPOSE OF THIS SUBROUTINE: // Calculate desired hot and cold water flow rates - // METHODOLOGY EMPLOYED: // Using/Aliasing using DataEnvironment::WaterMainsTemp; @@ -1081,8 +1069,6 @@ namespace WaterUse { using Psychrometrics::RhoH2O; using ScheduleManager::GetCurrentScheduleValue; - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int WaterConnNum; @@ -1189,7 +1175,6 @@ namespace WaterUse { // PURPOSE OF THIS SUBROUTINE: // Calculate drainwater temperature and heat and moisture gains to zone. - // METHODOLOGY EMPLOYED: // Using/Aliasing using DataEnvironment::OutBaroPress; @@ -1287,10 +1272,6 @@ namespace WaterUse { // MODIFIED Brent Griffith 2010, demand side update // RE-ENGINEERED na - // PURPOSE OF THIS SUBROUTINE: - - // METHODOLOGY EMPLOYED: - // Using/Aliasing using DataEnvironment::WaterMainsTemp; using DataGlobals::DoingSizing; @@ -1303,8 +1284,6 @@ namespace WaterUse { using PlantUtilities::ScanPlantLoopsForObject; using ScheduleManager::GetCurrentScheduleValue; - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int InletNode; @@ -1412,17 +1391,12 @@ namespace WaterUse { // PURPOSE OF THIS SUBROUTINE: // Calculate summed values for WATER USE CONNECTIONS (to prepare to request flow from plant, and for reporting). - // METHODOLOGY EMPLOYED: - // Using/Aliasing using DataLoopNode::Node; using DataWater::WaterStorage; using PlantUtilities::SetComponentFlowRate; using Psychrometrics::RhoH2O; - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int WaterEquipNum; int Loop; @@ -1543,14 +1517,9 @@ namespace WaterUse { // PURPOSE OF THIS SUBROUTINE: // Calculate - // METHODOLOGY EMPLOYED: - // Using/Aliasing using Psychrometrics::RhoH2O; - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int WaterEquipNum; int Loop; @@ -1590,16 +1559,11 @@ namespace WaterUse { // PURPOSE OF THIS SUBROUTINE: // Calculate drainwater heat recovery - // METHODOLOGY EMPLOYED: - // Using/Aliasing using Psychrometrics::CPHW; // unused0909 USE DataEnvironment, ONLY: WaterMainsTemp using DataWater::WaterStorage; - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: Real64 CapacityRatio; Real64 NTU; @@ -1716,16 +1680,10 @@ namespace WaterUse { // PURPOSE OF THIS SUBROUTINE: // Updates the node variables with local variables. - // METHODOLOGY EMPLOYED: - // Standard EnergyPlus methodology. - // Using/Aliasing using DataLoopNode::Node; using PlantUtilities::SafeCopyPlantNode; - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int InletNode; int OutletNode; @@ -1759,9 +1717,6 @@ namespace WaterUse { // PURPOSE OF THIS SUBROUTINE: // Calculates report variables for stand alone water use - // METHODOLOGY EMPLOYED: - // Standard EnergyPlus methodology. - // Using/Aliasing using DataGlobals::SecInHour; using DataHVACGlobals::TimeStepSys; @@ -1809,9 +1764,6 @@ namespace WaterUse { // PURPOSE OF THIS SUBROUTINE: // Calculates report variables. - // METHODOLOGY EMPLOYED: - // Standard EnergyPlus methodology. - // Using/Aliasing using DataGlobals::SecInHour; using DataHVACGlobals::TimeStepSys; @@ -1876,8 +1828,6 @@ namespace WaterUse { // PURPOSE OF THIS SUBROUTINE: // Calculates the zone internal gains due to water use sensible and latent loads. - // METHODOLOGY EMPLOYED: - // Using/Aliasing using DataGlobals::BeginEnvrnFlag; using DataHeatBalance::Zone; @@ -1923,13 +1873,7 @@ namespace WaterUse { WaterEquipment(WaterEquipNum).LatentRate / (Zone(ZoneNum).Multiplier * Zone(ZoneNum).ListMultiplier); // CR7401, back out multipliers } - // ! this routine needs to model approx zone gains for use during sizing - // IF(DoingSizing)THEN - // DO WaterEquipNum = 1, NumWaterEquipment - // WaterEquipment(WaterEquipNum)%SensibleRateNoMultiplier = - // WaterEquipment(WaterEquipNum)%LatentRateNoMultiplier = - // END DO - // ENDIF + } } // namespace WaterUse From e71b594ad2f3c04a3545e5ce4817269bde7eb5d2 Mon Sep 17 00:00:00 2001 From: Li Date: Thu, 10 Oct 2019 13:10:10 -0600 Subject: [PATCH 02/51] clear Using statements; regression test showing no diffs --- src/EnergyPlus/WaterUse.cc | 553 ++++++++++++++++++++----------------- 1 file changed, 297 insertions(+), 256 deletions(-) diff --git a/src/EnergyPlus/WaterUse.cc b/src/EnergyPlus/WaterUse.cc index 3eb6769284d..ca7763832d8 100644 --- a/src/EnergyPlus/WaterUse.cc +++ b/src/EnergyPlus/WaterUse.cc @@ -86,10 +86,9 @@ namespace WaterUse { // RE-ENGINEERED na // Using/Aliasing - using namespace DataPrecisionGlobals; - using DataGlobals::BeginEnvrnFlag; - using DataGlobals::NumOfZones; - using DataGlobals::WarmupFlag; + //using namespace DataPrecisionGlobals; + //using DataGlobals::NumOfZones; + //using DataGlobals::WarmupFlag; // MODULE PARAMETER DEFINITIONS: int const HeatRecoveryHXIdeal(1); @@ -139,7 +138,7 @@ namespace WaterUse { // water use and connections that are not connected to a full plant loop // Using/Aliasing - using General::RoundSigDigits; + //using General::RoundSigDigits; // Locals // SUBROUTINE PARAMETER DEFINITIONS: @@ -159,7 +158,7 @@ namespace WaterUse { GetWaterUseInputFlag = false; } - if (BeginEnvrnFlag && MyEnvrnFlag) { + if (DataGlobals::BeginEnvrnFlag && MyEnvrnFlag) { MaxIterationsErrorCount = 0; if (NumWaterEquipment > 0) { for (auto &e : WaterEquipment) { @@ -181,7 +180,7 @@ namespace WaterUse { MyEnvrnFlag = false; } - if (!BeginEnvrnFlag) MyEnvrnFlag = true; + if (!DataGlobals::BeginEnvrnFlag) MyEnvrnFlag = true; // Simulate all unconnected WATER USE EQUIPMENT objects for (WaterEquipNum = 1; WaterEquipNum <= NumWaterEquipment; ++WaterEquipNum) { @@ -212,7 +211,7 @@ namespace WaterUse { if (WaterConnections(WaterConnNum).TempError < Tolerance) { break; } else if (NumIteration > MaxIterations) { - if (!WarmupFlag) { + if (!DataGlobals::WarmupFlag) { if (WaterConnections(WaterConnNum).MaxIterationsErrorIndex == 0) { ShowWarningError("WaterUse:Connections = " + WaterConnections(WaterConnNum).Name + ": Heat recovery temperature did not converge"); @@ -249,8 +248,8 @@ namespace WaterUse { // (based on SimulateWaterUse by P. Ellis) // Using/Aliasing - using General::RoundSigDigits; - using General::TrimSigDigits; + //using General::RoundSigDigits; + //using General::TrimSigDigits; // Locals // SUBROUTINE PARAMETER DEFINITIONS: @@ -279,12 +278,12 @@ namespace WaterUse { } else { WaterConnNum = CompIndex; if (WaterConnNum > NumWaterConnections || WaterConnNum < 1) { - ShowFatalError("SimulateWaterUseConnection: Invalid CompIndex passed=" + TrimSigDigits(WaterConnNum) + - ", Number of Units=" + TrimSigDigits(NumWaterConnections) + ", Entered Unit name=" + CompName); + ShowFatalError("SimulateWaterUseConnection: Invalid CompIndex passed=" + General::TrimSigDigits(WaterConnNum) + + ", Number of Units=" + General::TrimSigDigits(NumWaterConnections) + ", Entered Unit name=" + CompName); } if (CheckEquipName(WaterConnNum)) { if (CompName != WaterConnections(WaterConnNum).Name) { - ShowFatalError("SimulateWaterUseConnection: Invalid CompIndex passed=" + TrimSigDigits(WaterConnNum) + ", Unit name=" + CompName + + ShowFatalError("SimulateWaterUseConnection: Invalid CompIndex passed=" + General::TrimSigDigits(WaterConnNum) + ", Unit name=" + CompName + ", stored Unit Name for that index=" + WaterConnections(WaterConnNum).Name); } CheckEquipName(WaterConnNum) = false; @@ -295,7 +294,7 @@ namespace WaterUse { return; } - if (BeginEnvrnFlag && MyEnvrnFlag) { + if (DataGlobals::BeginEnvrnFlag && MyEnvrnFlag) { MaxIterationsErrorCount = 0; if (NumWaterEquipment > 0) { for (int i = WaterEquipment.l(), e = WaterEquipment.u(); i <= e; ++i) { @@ -311,7 +310,7 @@ namespace WaterUse { MyEnvrnFlag = false; } - if (!BeginEnvrnFlag) MyEnvrnFlag = true; + if (!DataGlobals::BeginEnvrnFlag) MyEnvrnFlag = true; InitConnections(WaterConnNum); @@ -327,7 +326,7 @@ namespace WaterUse { if (WaterConnections(WaterConnNum).TempError < Tolerance) { break; } else if (NumIteration > MaxIterations) { - if (!WarmupFlag) { + if (!DataGlobals::WarmupFlag) { if (WaterConnections(WaterConnNum).MaxIterationsErrorIndex == 0) { ShowWarningError("WaterUse:Connections = " + WaterConnections(WaterConnNum).Name + ": Heat recovery temperature did not converge"); @@ -359,16 +358,16 @@ namespace WaterUse { // METHODOLOGY EMPLOYED: Standard EnergyPlus methodology. // Using/Aliasing - using namespace DataIPShortCuts; // Data for field names, blank numerics - using BranchNodeConnections::TestCompSet; - using NodeInputManager::GetOnlySingleNode; - using ScheduleManager::GetScheduleIndex; - using namespace DataLoopNode; - using namespace DataHeatBalance; - using PlantUtilities::RegisterPlantCompDesignFlow; - using Psychrometrics::RhoH2O; - using WaterManager::SetupTankDemandComponent; - using WaterManager::SetupTankSupplyComponent; + //using namespace DataIPShortCuts; // Data for field names, blank numerics + //using BranchNodeConnections::TestCompSet; + //using NodeInputManager::GetOnlySingleNode; + //using ScheduleManager::GetScheduleIndex; + //using namespace DataLoopNode; + //using namespace DataHeatBalance; + //using PlantUtilities::RegisterPlantCompDesignFlow; + //using Psychrometrics::RhoH2O; + //using WaterManager::SetupTankDemandComponent; + //using WaterManager::SetupTankSupplyComponent; // SUBROUTINE LOCAL VARIABLE DECLARATIONS: static bool ErrorsFound(false); // Set to true if errors in input, fatal at end of routine @@ -383,202 +382,206 @@ namespace WaterUse { // FLOW: - cCurrentModuleObject = "WaterUse:Equipment"; - NumWaterEquipment = inputProcessor->getNumObjectsFound(cCurrentModuleObject); + DataIPShortCuts::cCurrentModuleObject = "WaterUse:Equipment"; + NumWaterEquipment = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); if (NumWaterEquipment > 0) { WaterEquipment.allocate(NumWaterEquipment); for (WaterEquipNum = 1; WaterEquipNum <= NumWaterEquipment; ++WaterEquipNum) { - inputProcessor->getObjectItem(cCurrentModuleObject, + inputProcessor->getObjectItem(DataIPShortCuts::cCurrentModuleObject, WaterEquipNum, - cAlphaArgs, + DataIPShortCuts::cAlphaArgs, NumAlphas, - rNumericArgs, + DataIPShortCuts::rNumericArgs, NumNumbers, IOStatus, _, - lAlphaFieldBlanks, - cAlphaFieldNames, - cNumericFieldNames); - UtilityRoutines::IsNameEmpty(cAlphaArgs(1), cCurrentModuleObject, ErrorsFound); - WaterEquipment(WaterEquipNum).Name = cAlphaArgs(1); + DataIPShortCuts::lAlphaFieldBlanks, + DataIPShortCuts::cAlphaFieldNames, + DataIPShortCuts::cNumericFieldNames); + UtilityRoutines::IsNameEmpty(DataIPShortCuts::cAlphaArgs(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); + WaterEquipment(WaterEquipNum).Name = DataIPShortCuts::cAlphaArgs(1); - WaterEquipment(WaterEquipNum).EndUseSubcatName = cAlphaArgs(2); + WaterEquipment(WaterEquipNum).EndUseSubcatName = DataIPShortCuts::cAlphaArgs(2); - WaterEquipment(WaterEquipNum).PeakVolFlowRate = rNumericArgs(1); + WaterEquipment(WaterEquipNum).PeakVolFlowRate = DataIPShortCuts::rNumericArgs(1); - if ((NumAlphas > 2) && (!lAlphaFieldBlanks(3))) { - WaterEquipment(WaterEquipNum).FlowRateFracSchedule = GetScheduleIndex(cAlphaArgs(3)); + if ((NumAlphas > 2) && (!DataIPShortCuts::lAlphaFieldBlanks(3))) { + WaterEquipment(WaterEquipNum).FlowRateFracSchedule = ScheduleManager::GetScheduleIndex(DataIPShortCuts::cAlphaArgs(3)); // If no FlowRateFracSchedule, fraction defaults to 1.0 if (WaterEquipment(WaterEquipNum).FlowRateFracSchedule == 0) { - ShowSevereError("Invalid " + cAlphaFieldNames(3) + '=' + cAlphaArgs(3)); - ShowContinueError("Entered in " + cCurrentModuleObject + '=' + cAlphaArgs(1)); + ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(3) + '=' + DataIPShortCuts::cAlphaArgs(3)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + DataIPShortCuts::cAlphaArgs(1)); ErrorsFound = true; } } - if ((NumAlphas > 3) && (!lAlphaFieldBlanks(4))) { - WaterEquipment(WaterEquipNum).TargetTempSchedule = GetScheduleIndex(cAlphaArgs(4)); + if ((NumAlphas > 3) && (!DataIPShortCuts::lAlphaFieldBlanks(4))) { + WaterEquipment(WaterEquipNum).TargetTempSchedule = ScheduleManager::GetScheduleIndex(DataIPShortCuts::cAlphaArgs(4)); if (WaterEquipment(WaterEquipNum).TargetTempSchedule == 0) { - ShowSevereError("Invalid " + cAlphaFieldNames(4) + '=' + cAlphaArgs(4)); - ShowContinueError("Entered in " + cCurrentModuleObject + '=' + cAlphaArgs(1)); + ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(4) + '=' + DataIPShortCuts::cAlphaArgs(4)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + DataIPShortCuts::cAlphaArgs(1)); ErrorsFound = true; } } - if ((NumAlphas > 4) && (!lAlphaFieldBlanks(5))) { - WaterEquipment(WaterEquipNum).HotTempSchedule = GetScheduleIndex(cAlphaArgs(5)); + if ((NumAlphas > 4) && (!DataIPShortCuts::lAlphaFieldBlanks(5))) { + WaterEquipment(WaterEquipNum).HotTempSchedule = ScheduleManager::GetScheduleIndex(DataIPShortCuts::cAlphaArgs(5)); // If no HotTempSchedule, there is no hot water. // HotTempSchedule is ignored if connected to a plant loop via WATER USE CONNECTIONS if (WaterEquipment(WaterEquipNum).HotTempSchedule == 0) { - ShowSevereError("Invalid " + cAlphaFieldNames(5) + '=' + cAlphaArgs(5)); - ShowContinueError("Entered in " + cCurrentModuleObject + '=' + cAlphaArgs(1)); + ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(5) + '=' + DataIPShortCuts::cAlphaArgs(5)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + DataIPShortCuts::cAlphaArgs(1)); ErrorsFound = true; } } - if ((NumAlphas > 5) && (!lAlphaFieldBlanks(6))) { - WaterEquipment(WaterEquipNum).ColdTempSchedule = GetScheduleIndex(cAlphaArgs(6)); + if ((NumAlphas > 5) && (!DataIPShortCuts::lAlphaFieldBlanks(6))) { + WaterEquipment(WaterEquipNum).ColdTempSchedule = ScheduleManager::GetScheduleIndex(DataIPShortCuts::cAlphaArgs(6)); // If no ColdTempSchedule, temperatures will be calculated by WATER MAINS TEMPERATURES object if (WaterEquipment(WaterEquipNum).ColdTempSchedule == 0) { - ShowSevereError("Invalid " + cAlphaFieldNames(6) + '=' + cAlphaArgs(6)); - ShowContinueError("Entered in " + cCurrentModuleObject + '=' + cAlphaArgs(1)); + ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(6) + '=' + DataIPShortCuts::cAlphaArgs(6)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + DataIPShortCuts::cAlphaArgs(1)); ErrorsFound = true; } } - if ((NumAlphas > 6) && (!lAlphaFieldBlanks(7))) { - WaterEquipment(WaterEquipNum).Zone = UtilityRoutines::FindItemInList(cAlphaArgs(7), Zone); + if ((NumAlphas > 6) && (!DataIPShortCuts::lAlphaFieldBlanks(7))) { + WaterEquipment(WaterEquipNum).Zone = UtilityRoutines::FindItemInList(DataIPShortCuts::cAlphaArgs(7), DataHeatBalance::Zone); if (WaterEquipment(WaterEquipNum).Zone == 0) { - ShowSevereError("Invalid " + cAlphaFieldNames(7) + '=' + cAlphaArgs(7)); - ShowContinueError("Entered in " + cCurrentModuleObject + '=' + cAlphaArgs(1)); + ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(7) + '=' + DataIPShortCuts::cAlphaArgs(7)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + DataIPShortCuts::cAlphaArgs(1)); ErrorsFound = true; } } - if ((NumAlphas > 7) && (!lAlphaFieldBlanks(8))) { - WaterEquipment(WaterEquipNum).SensibleFracSchedule = GetScheduleIndex(cAlphaArgs(8)); + if ((NumAlphas > 7) && (!DataIPShortCuts::lAlphaFieldBlanks(8))) { + WaterEquipment(WaterEquipNum).SensibleFracSchedule = ScheduleManager::GetScheduleIndex(DataIPShortCuts::cAlphaArgs(8)); if (WaterEquipment(WaterEquipNum).SensibleFracSchedule == 0) { - ShowSevereError("Invalid " + cAlphaFieldNames(8) + '=' + cAlphaArgs(8)); - ShowContinueError("Entered in " + cCurrentModuleObject + '=' + cAlphaArgs(1)); + ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(8) + '=' + DataIPShortCuts::cAlphaArgs(8)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + DataIPShortCuts::cAlphaArgs(1)); ErrorsFound = true; } } - if ((NumAlphas > 8) && (!lAlphaFieldBlanks(9))) { - WaterEquipment(WaterEquipNum).LatentFracSchedule = GetScheduleIndex(cAlphaArgs(9)); + if ((NumAlphas > 8) && (!DataIPShortCuts::lAlphaFieldBlanks(9))) { + WaterEquipment(WaterEquipNum).LatentFracSchedule = ScheduleManager::GetScheduleIndex(DataIPShortCuts::cAlphaArgs(9)); if (WaterEquipment(WaterEquipNum).LatentFracSchedule == 0) { - ShowSevereError("Invalid " + cAlphaFieldNames(9) + '=' + cAlphaArgs(9)); - ShowContinueError("Entered in " + cCurrentModuleObject + '=' + cAlphaArgs(1)); + ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(9) + '=' + DataIPShortCuts::cAlphaArgs(9)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + DataIPShortCuts::cAlphaArgs(1)); ErrorsFound = true; } } } // WaterEquipNum - if (ErrorsFound) ShowFatalError("Errors found in processing input for " + cCurrentModuleObject); + if (ErrorsFound) ShowFatalError("Errors found in processing input for " + DataIPShortCuts::cCurrentModuleObject); } - cCurrentModuleObject = "WaterUse:Connections"; - NumWaterConnections = inputProcessor->getNumObjectsFound(cCurrentModuleObject); + DataIPShortCuts::cCurrentModuleObject = "WaterUse:Connections"; + NumWaterConnections = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); if (NumWaterConnections > 0) { WaterConnections.allocate(NumWaterConnections); for (WaterConnNum = 1; WaterConnNum <= NumWaterConnections; ++WaterConnNum) { - inputProcessor->getObjectItem(cCurrentModuleObject, + inputProcessor->getObjectItem(DataIPShortCuts::cCurrentModuleObject, WaterConnNum, - cAlphaArgs, + DataIPShortCuts::cAlphaArgs, NumAlphas, - rNumericArgs, + DataIPShortCuts::rNumericArgs, NumNumbers, IOStatus, _, - lAlphaFieldBlanks, - cAlphaFieldNames, - cNumericFieldNames); - UtilityRoutines::IsNameEmpty(cAlphaArgs(1), cCurrentModuleObject, ErrorsFound); - WaterConnections(WaterConnNum).Name = cAlphaArgs(1); - - if ((!lAlphaFieldBlanks(2)) || (!lAlphaFieldBlanks(3))) { - WaterConnections(WaterConnNum).InletNode = GetOnlySingleNode(cAlphaArgs(2), + DataIPShortCuts::lAlphaFieldBlanks, + DataIPShortCuts::cAlphaFieldNames, + DataIPShortCuts::cNumericFieldNames); + UtilityRoutines::IsNameEmpty(DataIPShortCuts::cAlphaArgs(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); + WaterConnections(WaterConnNum).Name = DataIPShortCuts::cAlphaArgs(1); + + if ((!DataIPShortCuts::lAlphaFieldBlanks(2)) || (!DataIPShortCuts::lAlphaFieldBlanks(3))) { + WaterConnections(WaterConnNum).InletNode = NodeInputManager::GetOnlySingleNode(DataIPShortCuts::cAlphaArgs(2), ErrorsFound, - cCurrentModuleObject, - cAlphaArgs(1), - NodeType_Water, - NodeConnectionType_Inlet, + DataIPShortCuts::cCurrentModuleObject, + DataIPShortCuts::cAlphaArgs(1), + DataLoopNode::NodeType_Water, + DataLoopNode::NodeConnectionType_Inlet, 1, - ObjectIsNotParent); - WaterConnections(WaterConnNum).OutletNode = GetOnlySingleNode(cAlphaArgs(3), + DataLoopNode::ObjectIsNotParent); + WaterConnections(WaterConnNum).OutletNode = NodeInputManager::GetOnlySingleNode(DataIPShortCuts::cAlphaArgs(3), ErrorsFound, - cCurrentModuleObject, - cAlphaArgs(1), - NodeType_Water, - NodeConnectionType_Outlet, + DataIPShortCuts::cCurrentModuleObject, + DataIPShortCuts::cAlphaArgs(1), + DataLoopNode::NodeType_Water, + DataLoopNode::NodeConnectionType_Outlet, 1, - ObjectIsNotParent); + DataLoopNode::ObjectIsNotParent); // Check plant connections - TestCompSet(cCurrentModuleObject, cAlphaArgs(1), cAlphaArgs(2), cAlphaArgs(3), "DHW Nodes"); + BranchNodeConnections::TestCompSet(DataIPShortCuts::cCurrentModuleObject, + DataIPShortCuts::cAlphaArgs(1), + DataIPShortCuts::cAlphaArgs(2), + DataIPShortCuts::cAlphaArgs(3), + "DHW Nodes"); } else { // If no plant nodes are connected, simulate in stand-alone mode. WaterConnections(WaterConnNum).StandAlone = true; } - if (!lAlphaFieldBlanks(4)) { - SetupTankDemandComponent(WaterConnections(WaterConnNum).Name, - cCurrentModuleObject, - cAlphaArgs(4), + if (!DataIPShortCuts::lAlphaFieldBlanks(4)) { + WaterManager::SetupTankDemandComponent(WaterConnections(WaterConnNum).Name, + DataIPShortCuts::cCurrentModuleObject, + DataIPShortCuts::cAlphaArgs(4), ErrorsFound, WaterConnections(WaterConnNum).SupplyTankNum, WaterConnections(WaterConnNum).TankDemandID); } - if (!lAlphaFieldBlanks(5)) { - SetupTankSupplyComponent(WaterConnections(WaterConnNum).Name, - cCurrentModuleObject, - cAlphaArgs(5), + if (!DataIPShortCuts::lAlphaFieldBlanks(5)) { + WaterManager::SetupTankSupplyComponent(WaterConnections(WaterConnNum).Name, + DataIPShortCuts::cCurrentModuleObject, + DataIPShortCuts::cAlphaArgs(5), ErrorsFound, WaterConnections(WaterConnNum).RecoveryTankNum, WaterConnections(WaterConnNum).TankSupplyID); } - if (!lAlphaFieldBlanks(6)) { - WaterConnections(WaterConnNum).HotTempSchedule = GetScheduleIndex(cAlphaArgs(6)); + if (!DataIPShortCuts::lAlphaFieldBlanks(6)) { + WaterConnections(WaterConnNum).HotTempSchedule = ScheduleManager::GetScheduleIndex(DataIPShortCuts::cAlphaArgs(6)); // If no HotTempSchedule, there is no hot water. // HotTempSchedule is ignored if connected to a plant loop via WATER USE CONNECTIONS if (WaterConnections(WaterConnNum).HotTempSchedule == 0) { - ShowSevereError("Invalid " + cAlphaFieldNames(6) + '=' + cAlphaArgs(6)); - ShowContinueError("Entered in " + cCurrentModuleObject + '=' + cAlphaArgs(1)); + ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(6) + '=' + DataIPShortCuts::cAlphaArgs(6)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + DataIPShortCuts::cAlphaArgs(1)); ErrorsFound = true; } } - if (!lAlphaFieldBlanks(7)) { - WaterConnections(WaterConnNum).ColdTempSchedule = GetScheduleIndex(cAlphaArgs(7)); + if (!DataIPShortCuts::lAlphaFieldBlanks(7)) { + WaterConnections(WaterConnNum).ColdTempSchedule = ScheduleManager::GetScheduleIndex(DataIPShortCuts::cAlphaArgs(7)); // If no ColdTempSchedule, temperatures will be calculated by WATER MAINS TEMPERATURES object if (WaterConnections(WaterConnNum).ColdTempSchedule == 0) { - ShowSevereError("Invalid " + cAlphaFieldNames(7) + '=' + cAlphaArgs(7)); - ShowContinueError("Entered in " + cCurrentModuleObject + '=' + cAlphaArgs(1)); + ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(7) + '=' + DataIPShortCuts::cAlphaArgs(7)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + DataIPShortCuts::cAlphaArgs(1)); ErrorsFound = true; } } - if ((!lAlphaFieldBlanks(8)) && (cAlphaArgs(8) != "NONE")) { + if ((!DataIPShortCuts::lAlphaFieldBlanks(8)) && (DataIPShortCuts::cAlphaArgs(8) != "NONE")) { WaterConnections(WaterConnNum).HeatRecovery = true; { - auto const SELECT_CASE_var(cAlphaArgs(8)); + auto const SELECT_CASE_var(DataIPShortCuts::cAlphaArgs(8)); if (SELECT_CASE_var == "IDEAL") { WaterConnections(WaterConnNum).HeatRecoveryHX = HeatRecoveryHXIdeal; } else if (SELECT_CASE_var == "COUNTERFLOW") { @@ -586,14 +589,14 @@ namespace WaterUse { } else if (SELECT_CASE_var == "CROSSFLOW") { WaterConnections(WaterConnNum).HeatRecoveryHX = HeatRecoveryHXCrossFlow; } else { - ShowSevereError("Invalid " + cAlphaFieldNames(8) + '=' + cAlphaArgs(8)); - ShowContinueError("Entered in " + cCurrentModuleObject + '=' + cAlphaArgs(1)); + ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(8) + '=' + DataIPShortCuts::cAlphaArgs(8)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + DataIPShortCuts::cAlphaArgs(1)); ErrorsFound = true; } } { - auto const SELECT_CASE_var(cAlphaArgs(9)); + auto const SELECT_CASE_var(DataIPShortCuts::cAlphaArgs(9)); if (SELECT_CASE_var == "PLANT") { WaterConnections(WaterConnNum).HeatRecoveryConfig = HeatRecoveryConfigPlant; } else if (SELECT_CASE_var == "EQUIPMENT") { @@ -601,27 +604,29 @@ namespace WaterUse { } else if (SELECT_CASE_var == "PLANTANDEQUIPMENT") { WaterConnections(WaterConnNum).HeatRecoveryConfig = HeatRecoveryConfigPlantAndEquip; } else { - ShowSevereError("Invalid " + cAlphaFieldNames(9) + '=' + cAlphaArgs(9)); - ShowContinueError("Entered in " + cCurrentModuleObject + '=' + cAlphaArgs(1)); + ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(9) + '=' + DataIPShortCuts::cAlphaArgs(9)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + DataIPShortCuts::cAlphaArgs(1)); ErrorsFound = true; } } } - WaterConnections(WaterConnNum).HXUA = rNumericArgs(1); + WaterConnections(WaterConnNum).HXUA = DataIPShortCuts::rNumericArgs(1); WaterConnections(WaterConnNum).WaterEquipment.allocate(NumAlphas - 9); for (AlphaNum = 10; AlphaNum <= NumAlphas; ++AlphaNum) { - WaterEquipNum = UtilityRoutines::FindItemInList(cAlphaArgs(AlphaNum), WaterEquipment); + WaterEquipNum = UtilityRoutines::FindItemInList(DataIPShortCuts::cAlphaArgs(AlphaNum), WaterEquipment); if (WaterEquipNum == 0) { - ShowSevereError("Invalid " + cAlphaFieldNames(AlphaNum) + '=' + cAlphaArgs(AlphaNum)); - ShowContinueError("Entered in " + cCurrentModuleObject + '=' + cAlphaArgs(1)); + ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(AlphaNum) + '=' + DataIPShortCuts::cAlphaArgs(AlphaNum)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + DataIPShortCuts::cAlphaArgs(1)); ErrorsFound = true; } else { if (WaterEquipment(WaterEquipNum).Connections > 0) { - ShowSevereError(cCurrentModuleObject + " = " + cAlphaArgs(1) + ": WaterUse:Equipment = " + cAlphaArgs(AlphaNum) + + ShowSevereError(DataIPShortCuts::cCurrentModuleObject + " = " + DataIPShortCuts::cAlphaArgs(1) + + ": WaterUse:Equipment = " + + DataIPShortCuts::cAlphaArgs(AlphaNum) + " is already referenced by another object."); ErrorsFound = true; } else { @@ -638,7 +643,7 @@ namespace WaterUse { } // WaterConnNum - if (ErrorsFound) ShowFatalError("Errors found in processing input for " + cCurrentModuleObject); + if (ErrorsFound) ShowFatalError("Errors found in processing input for " + DataIPShortCuts::cCurrentModuleObject); if (NumWaterConnections > 0) { CheckEquipName.allocate(NumWaterConnections); @@ -656,15 +661,15 @@ namespace WaterUse { thisWaterEquipNum = WaterConnections(WaterConnNum).WaterEquipment(WaterEquipNum); if (WaterEquipment(thisWaterEquipNum).Zone > 0) { WaterConnections(WaterConnNum).PeakMassFlowRate += - WaterEquipment(thisWaterEquipNum).PeakVolFlowRate * RhoH2O(DataGlobals::InitConvTemp) * - Zone(WaterEquipment(thisWaterEquipNum).Zone).Multiplier * Zone(WaterEquipment(thisWaterEquipNum).Zone).ListMultiplier; + WaterEquipment(thisWaterEquipNum).PeakVolFlowRate * Psychrometrics::RhoH2O(DataGlobals::InitConvTemp) * + DataHeatBalance::Zone(WaterEquipment(thisWaterEquipNum).Zone).Multiplier * DataHeatBalance::Zone(WaterEquipment(thisWaterEquipNum).Zone).ListMultiplier; } else { // can't have multipliers WaterConnections(WaterConnNum).PeakMassFlowRate += - WaterEquipment(thisWaterEquipNum).PeakVolFlowRate * RhoH2O(DataGlobals::InitConvTemp); + WaterEquipment(thisWaterEquipNum).PeakVolFlowRate * Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); } } - RegisterPlantCompDesignFlow(WaterConnections(WaterConnNum).InletNode, - WaterConnections(WaterConnNum).PeakMassFlowRate / RhoH2O(DataGlobals::InitConvTemp)); + PlantUtilities::RegisterPlantCompDesignFlow(WaterConnections(WaterConnNum).InletNode, + WaterConnections(WaterConnNum).PeakMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp)); } } @@ -876,7 +881,7 @@ namespace WaterUse { SetupZoneInternalGain(WaterEquipment(WaterEquipNum).Zone, "WaterUse:Equipment", WaterEquipment(WaterEquipNum).Name, - IntGainTypeOf_WaterUseEquipment, + DataHeatBalance::IntGainTypeOf_WaterUseEquipment, WaterEquipment(WaterEquipNum).SensibleRateNoMultiplier, _, _, @@ -1061,13 +1066,13 @@ namespace WaterUse { // PURPOSE OF THIS SUBROUTINE: // Calculate desired hot and cold water flow rates - + // Using/Aliasing - using DataEnvironment::WaterMainsTemp; - using DataHeatBalance::Zone; - using Psychrometrics::RhoH2O; - using ScheduleManager::GetCurrentScheduleValue; + //using DataEnvironment::WaterMainsTemp; + //using DataHeatBalance::Zone; + //using Psychrometrics::RhoH2O; + //using ScheduleManager::GetCurrentScheduleValue; // SUBROUTINE LOCAL VARIABLE DECLARATIONS: @@ -1084,20 +1089,20 @@ namespace WaterUse { } else { // Get water temperature conditions from the WATER USE EQUIPMENT schedules if (WaterEquipment(WaterEquipNum).ColdTempSchedule > 0) { - WaterEquipment(WaterEquipNum).ColdTemp = GetCurrentScheduleValue(WaterEquipment(WaterEquipNum).ColdTempSchedule); + WaterEquipment(WaterEquipNum).ColdTemp = ScheduleManager::GetCurrentScheduleValue(WaterEquipment(WaterEquipNum).ColdTempSchedule); } else { // If no ColdTempSchedule, use the mains temperature - WaterEquipment(WaterEquipNum).ColdTemp = WaterMainsTemp; + WaterEquipment(WaterEquipNum).ColdTemp = DataEnvironment::WaterMainsTemp; } if (WaterEquipment(WaterEquipNum).HotTempSchedule > 0) { - WaterEquipment(WaterEquipNum).HotTemp = GetCurrentScheduleValue(WaterEquipment(WaterEquipNum).HotTempSchedule); + WaterEquipment(WaterEquipNum).HotTemp = ScheduleManager::GetCurrentScheduleValue(WaterEquipment(WaterEquipNum).HotTempSchedule); } else { // If no HotTempSchedule, use all cold water WaterEquipment(WaterEquipNum).HotTemp = WaterEquipment(WaterEquipNum).ColdTemp; } } if (WaterEquipment(WaterEquipNum).TargetTempSchedule > 0) { - WaterEquipment(WaterEquipNum).TargetTemp = GetCurrentScheduleValue(WaterEquipment(WaterEquipNum).TargetTempSchedule); + WaterEquipment(WaterEquipNum).TargetTemp = ScheduleManager::GetCurrentScheduleValue(WaterEquipment(WaterEquipNum).TargetTempSchedule); } else { // If no TargetTempSchedule, use all hot water WaterEquipment(WaterEquipNum).TargetTemp = WaterEquipment(WaterEquipNum).HotTemp; } @@ -1107,23 +1112,26 @@ namespace WaterUse { if (WaterEquipment(WaterEquipNum).Zone > 0) { if (WaterEquipment(WaterEquipNum).FlowRateFracSchedule > 0) { WaterEquipment(WaterEquipNum).TotalVolFlowRate = - WaterEquipment(WaterEquipNum).PeakVolFlowRate * GetCurrentScheduleValue(WaterEquipment(WaterEquipNum).FlowRateFracSchedule) * - Zone(WaterEquipment(WaterEquipNum).Zone).Multiplier * Zone(WaterEquipment(WaterEquipNum).Zone).ListMultiplier; + WaterEquipment(WaterEquipNum).PeakVolFlowRate * + ScheduleManager::GetCurrentScheduleValue(WaterEquipment(WaterEquipNum).FlowRateFracSchedule) * + DataHeatBalance::Zone(WaterEquipment(WaterEquipNum).Zone).Multiplier * DataHeatBalance::Zone(WaterEquipment(WaterEquipNum).Zone).ListMultiplier; } else { WaterEquipment(WaterEquipNum).TotalVolFlowRate = WaterEquipment(WaterEquipNum).PeakVolFlowRate * - Zone(WaterEquipment(WaterEquipNum).Zone).Multiplier * - Zone(WaterEquipment(WaterEquipNum).Zone).ListMultiplier; + DataHeatBalance::Zone(WaterEquipment(WaterEquipNum).Zone).Multiplier * + DataHeatBalance::Zone(WaterEquipment(WaterEquipNum).Zone).ListMultiplier; } } else { if (WaterEquipment(WaterEquipNum).FlowRateFracSchedule > 0) { WaterEquipment(WaterEquipNum).TotalVolFlowRate = - WaterEquipment(WaterEquipNum).PeakVolFlowRate * GetCurrentScheduleValue(WaterEquipment(WaterEquipNum).FlowRateFracSchedule); + WaterEquipment(WaterEquipNum).PeakVolFlowRate * + ScheduleManager::GetCurrentScheduleValue(WaterEquipment(WaterEquipNum).FlowRateFracSchedule); } else { WaterEquipment(WaterEquipNum).TotalVolFlowRate = WaterEquipment(WaterEquipNum).PeakVolFlowRate; } } - WaterEquipment(WaterEquipNum).TotalMassFlowRate = WaterEquipment(WaterEquipNum).TotalVolFlowRate * RhoH2O(DataGlobals::InitConvTemp); + WaterEquipment(WaterEquipNum).TotalMassFlowRate = + WaterEquipment(WaterEquipNum).TotalVolFlowRate * Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); // Calculate hot and cold water mixing at the tap if (WaterEquipment(WaterEquipNum).TotalMassFlowRate > 0.0) { @@ -1177,17 +1185,17 @@ namespace WaterUse { // Using/Aliasing - using DataEnvironment::OutBaroPress; - using DataGlobals::SecInHour; - using DataHeatBalance::Zone; - using DataHeatBalFanSys::MAT; - using DataHeatBalFanSys::ZoneAirHumRat; - using DataHVACGlobals::TimeStepSys; - using Psychrometrics::CPHW; - using Psychrometrics::PsyHfgAirFnWTdb; - using Psychrometrics::PsyRhoAirFnPbTdbW; - using Psychrometrics::PsyWFnTdbRhPb; - using ScheduleManager::GetCurrentScheduleValue; + //using DataEnvironment::OutBaroPress; + //using DataGlobals::SecInHour; + //using DataHeatBalance::Zone; + //using DataHeatBalFanSys::MAT; + //using DataHeatBalFanSys::ZoneAirHumRat; + //using DataHVACGlobals::TimeStepSys; + //using Psychrometrics::CPHW; + //using Psychrometrics::PsyHfgAirFnWTdb; + //using Psychrometrics::PsyRhoAirFnPbTdbW; + //using Psychrometrics::PsyWFnTdbRhPb; + //using ScheduleManager::GetCurrentScheduleValue; // Locals // SUBROUTINE ARGUMENT DEFINITIONS: @@ -1217,36 +1225,45 @@ namespace WaterUse { } else { ZoneNum = WaterEquipment(WaterEquipNum).Zone; - ZoneMAT = MAT(ZoneNum); + ZoneMAT = DataHeatBalFanSys::MAT(ZoneNum); if (WaterEquipment(WaterEquipNum).SensibleFracSchedule == 0) { WaterEquipment(WaterEquipNum).SensibleRate = 0.0; WaterEquipment(WaterEquipNum).SensibleEnergy = 0.0; } else { - WaterEquipment(WaterEquipNum).SensibleRate = GetCurrentScheduleValue(WaterEquipment(WaterEquipNum).SensibleFracSchedule) * - WaterEquipment(WaterEquipNum).TotalMassFlowRate * CPHW(DataGlobals::InitConvTemp) * + WaterEquipment(WaterEquipNum).SensibleRate = + ScheduleManager::GetCurrentScheduleValue(WaterEquipment(WaterEquipNum).SensibleFracSchedule) * + WaterEquipment(WaterEquipNum).TotalMassFlowRate * + Psychrometrics::CPHW(DataGlobals::InitConvTemp) * (WaterEquipment(WaterEquipNum).MixedTemp - ZoneMAT); - WaterEquipment(WaterEquipNum).SensibleEnergy = WaterEquipment(WaterEquipNum).SensibleRate * TimeStepSys * SecInHour; + WaterEquipment(WaterEquipNum).SensibleEnergy = + WaterEquipment(WaterEquipNum).SensibleRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; } if (WaterEquipment(WaterEquipNum).LatentFracSchedule == 0) { WaterEquipment(WaterEquipNum).LatentRate = 0.0; WaterEquipment(WaterEquipNum).LatentEnergy = 0.0; } else { - ZoneHumRat = ZoneAirHumRat(ZoneNum); - ZoneHumRatSat = PsyWFnTdbRhPb(ZoneMAT, 1.0, OutBaroPress, RoutineName); // Humidratio at 100% relative humidity - RhoAirDry = PsyRhoAirFnPbTdbW(OutBaroPress, ZoneMAT, 0.0); - - ZoneMassMax = (ZoneHumRatSat - ZoneHumRat) * RhoAirDry * Zone(ZoneNum).Volume; // Max water that can be evaporated to zone - FlowMassMax = WaterEquipment(WaterEquipNum).TotalMassFlowRate * TimeStepSys * SecInHour; // Max water in flow + ZoneHumRat = DataHeatBalFanSys::ZoneAirHumRat(ZoneNum); + ZoneHumRatSat = + Psychrometrics::PsyWFnTdbRhPb(ZoneMAT, 1.0, DataEnvironment::OutBaroPress, RoutineName); // Humidratio at 100% relative humidity + RhoAirDry = Psychrometrics::PsyRhoAirFnPbTdbW(DataEnvironment::OutBaroPress, ZoneMAT, 0.0); + + ZoneMassMax = + (ZoneHumRatSat - ZoneHumRat) * RhoAirDry * DataHeatBalance::Zone(ZoneNum).Volume; // Max water that can be evaporated to zone + FlowMassMax = + WaterEquipment(WaterEquipNum).TotalMassFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; // Max water in flow MoistureMassMax = min(ZoneMassMax, FlowMassMax); WaterEquipment(WaterEquipNum).MoistureMass = - GetCurrentScheduleValue(WaterEquipment(WaterEquipNum).LatentFracSchedule) * MoistureMassMax; - WaterEquipment(WaterEquipNum).MoistureRate = WaterEquipment(WaterEquipNum).MoistureMass / (TimeStepSys * SecInHour); - - WaterEquipment(WaterEquipNum).LatentRate = WaterEquipment(WaterEquipNum).MoistureRate * PsyHfgAirFnWTdb(ZoneHumRat, ZoneMAT); - WaterEquipment(WaterEquipNum).LatentEnergy = WaterEquipment(WaterEquipNum).LatentRate * TimeStepSys * SecInHour; + ScheduleManager::GetCurrentScheduleValue(WaterEquipment(WaterEquipNum).LatentFracSchedule) * MoistureMassMax; + WaterEquipment(WaterEquipNum).MoistureRate = + WaterEquipment(WaterEquipNum).MoistureMass / (DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour); + + WaterEquipment(WaterEquipNum).LatentRate = + WaterEquipment(WaterEquipNum).MoistureRate * Psychrometrics::PsyHfgAirFnWTdb(ZoneHumRat, ZoneMAT); + WaterEquipment(WaterEquipNum).LatentEnergy = + WaterEquipment(WaterEquipNum).LatentRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; } WaterEquipment(WaterEquipNum).DrainMassFlowRate = @@ -1256,9 +1273,10 @@ namespace WaterUse { WaterEquipment(WaterEquipNum).DrainTemp = WaterEquipment(WaterEquipNum).MixedTemp; } else { WaterEquipment(WaterEquipNum).DrainTemp = - (WaterEquipment(WaterEquipNum).TotalMassFlowRate * CPHW(DataGlobals::InitConvTemp) * WaterEquipment(WaterEquipNum).MixedTemp - + (WaterEquipment(WaterEquipNum).TotalMassFlowRate * Psychrometrics::CPHW(DataGlobals::InitConvTemp) * + WaterEquipment(WaterEquipNum).MixedTemp - WaterEquipment(WaterEquipNum).SensibleRate - WaterEquipment(WaterEquipNum).LatentRate) / - (WaterEquipment(WaterEquipNum).DrainMassFlowRate * CPHW(DataGlobals::InitConvTemp)); + (WaterEquipment(WaterEquipNum).DrainMassFlowRate * Psychrometrics::CPHW(DataGlobals::InitConvTemp)); } } } @@ -1273,16 +1291,16 @@ namespace WaterUse { // RE-ENGINEERED na // Using/Aliasing - using DataEnvironment::WaterMainsTemp; - using DataGlobals::DoingSizing; - using DataHeatBalance::Zone; - using DataLoopNode::Node; - using DataPlant::PlantLoop; - using DataPlant::TypeOf_WaterUseConnection; - using DataWater::WaterStorage; - using PlantUtilities::InitComponentNodes; - using PlantUtilities::ScanPlantLoopsForObject; - using ScheduleManager::GetCurrentScheduleValue; + //using DataEnvironment::WaterMainsTemp; + //using DataGlobals::DoingSizing; + //using DataHeatBalance::Zone; + //using DataLoopNode::Node; + //using DataPlant::PlantLoop; + //using DataPlant::TypeOf_WaterUseConnection; + //using DataWater::WaterStorage; + //using PlantUtilities::InitComponentNodes; + //using PlantUtilities::ScanPlantLoopsForObject; + //using ScheduleManager::GetCurrentScheduleValue; // SUBROUTINE LOCAL VARIABLE DECLARATIONS: @@ -1298,10 +1316,10 @@ namespace WaterUse { } // DSU if (SetLoopIndexFlag(WaterConnNum)) { // DSU - if (allocated(PlantLoop) && !WaterConnections(WaterConnNum).StandAlone) { // DSU + if (allocated(DataPlant::PlantLoop) && !WaterConnections(WaterConnNum).StandAlone) { // DSU errFlag = false; - ScanPlantLoopsForObject(WaterConnections(WaterConnNum).Name, - TypeOf_WaterUseConnection, + PlantUtilities::ScanPlantLoopsForObject(WaterConnections(WaterConnNum).Name, + DataPlant::TypeOf_WaterUseConnection, WaterConnections(WaterConnNum).PlantLoopNum, WaterConnections(WaterConnNum).PlantLoopSide, WaterConnections(WaterConnNum).PlantLoopBranchNum, @@ -1322,13 +1340,13 @@ namespace WaterUse { // Set the cold water temperature if (WaterConnections(WaterConnNum).SupplyTankNum > 0) { - WaterConnections(WaterConnNum).ColdSupplyTemp = WaterStorage(WaterConnections(WaterConnNum).SupplyTankNum).Twater; + WaterConnections(WaterConnNum).ColdSupplyTemp = DataWater::WaterStorage(WaterConnections(WaterConnNum).SupplyTankNum).Twater; } else if (WaterConnections(WaterConnNum).ColdTempSchedule > 0) { - WaterConnections(WaterConnNum).ColdSupplyTemp = GetCurrentScheduleValue(WaterConnections(WaterConnNum).ColdTempSchedule); + WaterConnections(WaterConnNum).ColdSupplyTemp = ScheduleManager::GetCurrentScheduleValue(WaterConnections(WaterConnNum).ColdTempSchedule); } else { - WaterConnections(WaterConnNum).ColdSupplyTemp = WaterMainsTemp; + WaterConnections(WaterConnNum).ColdSupplyTemp = DataEnvironment::WaterMainsTemp; } // Initially set ColdTemp to the ColdSupplyTemp; with heat recovery, ColdTemp will change during iteration @@ -1337,7 +1355,7 @@ namespace WaterUse { // Set the hot water temperature if (WaterConnections(WaterConnNum).StandAlone) { if (WaterConnections(WaterConnNum).HotTempSchedule > 0) { - WaterConnections(WaterConnNum).HotTemp = GetCurrentScheduleValue(WaterConnections(WaterConnNum).HotTempSchedule); + WaterConnections(WaterConnNum).HotTemp = ScheduleManager::GetCurrentScheduleValue(WaterConnections(WaterConnNum).HotTempSchedule); } else { // If no HotTempSchedule, use all cold water WaterConnections(WaterConnNum).HotTemp = WaterConnections(WaterConnNum).ColdTemp; @@ -1347,10 +1365,10 @@ namespace WaterUse { InletNode = WaterConnections(WaterConnNum).InletNode; OutletNode = WaterConnections(WaterConnNum).OutletNode; - if (BeginEnvrnFlag && WaterConnections(WaterConnNum).Init) { + if (DataGlobals::BeginEnvrnFlag && WaterConnections(WaterConnNum).Init) { // Clear node initial conditions if (InletNode > 0 && OutletNode > 0) { - InitComponentNodes(0.0, + PlantUtilities::InitComponentNodes(0.0, WaterConnections(WaterConnNum).PeakMassFlowRate, InletNode, OutletNode, @@ -1359,17 +1377,17 @@ namespace WaterUse { WaterConnections(WaterConnNum).PlantLoopBranchNum, WaterConnections(WaterConnNum).PlantLoopCompNum); - WaterConnections(WaterConnNum).ReturnTemp = Node(InletNode).Temp; + WaterConnections(WaterConnNum).ReturnTemp = DataLoopNode::Node(InletNode).Temp; } WaterConnections(WaterConnNum).Init = false; } - if (!BeginEnvrnFlag) WaterConnections(WaterConnNum).Init = true; + if (!DataGlobals::BeginEnvrnFlag) WaterConnections(WaterConnNum).Init = true; if (InletNode > 0) { - if (!DoingSizing) { - WaterConnections(WaterConnNum).HotTemp = Node(InletNode).Temp; + if (!DataGlobals::DoingSizing) { + WaterConnections(WaterConnNum).HotTemp = DataLoopNode::Node(InletNode).Temp; } else { // plant loop will not be running so need a value here. // should change to use tank setpoint but water use connections don't have knowledge of the tank they are fed by @@ -1392,10 +1410,10 @@ namespace WaterUse { // Calculate summed values for WATER USE CONNECTIONS (to prepare to request flow from plant, and for reporting). // Using/Aliasing - using DataLoopNode::Node; - using DataWater::WaterStorage; - using PlantUtilities::SetComponentFlowRate; - using Psychrometrics::RhoH2O; + //using DataLoopNode::Node; + //using DataWater::WaterStorage; + //using PlantUtilities::SetComponentFlowRate; + //using Psychrometrics::RhoH2O; // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int WaterEquipNum; @@ -1434,7 +1452,7 @@ namespace WaterUse { // Node(InletNode)%MassFlowRate = WaterConnections(WaterConnNum)%HotMassFlowRate // Node(InletNode)%MassFlowRateMaxAvail = WaterConnections(WaterConnNum)%PeakMassFlowRate // Node(InletNode)%MassFlowRateMinAvail = 0.0D0 - SetComponentFlowRate(WaterConnections(WaterConnNum).HotMassFlowRate, + PlantUtilities::SetComponentFlowRate(WaterConnections(WaterConnNum).HotMassFlowRate, InletNode, OutletNode, LoopNum, @@ -1444,7 +1462,7 @@ namespace WaterUse { } else { DesiredHotWaterMassFlow = WaterConnections(WaterConnNum).HotMassFlowRate; - SetComponentFlowRate(DesiredHotWaterMassFlow, + PlantUtilities::SetComponentFlowRate(DesiredHotWaterMassFlow, InletNode, OutletNode, LoopNum, @@ -1492,16 +1510,18 @@ namespace WaterUse { if (WaterConnections(WaterConnNum).SupplyTankNum > 0) { // Set the demand request for supply water from water storage tank - WaterConnections(WaterConnNum).ColdVolFlowRate = WaterConnections(WaterConnNum).ColdMassFlowRate / RhoH2O(DataGlobals::InitConvTemp); - WaterStorage(WaterConnections(WaterConnNum).SupplyTankNum).VdotRequestDemand(WaterConnections(WaterConnNum).TankDemandID) = + WaterConnections(WaterConnNum).ColdVolFlowRate = + WaterConnections(WaterConnNum).ColdMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); + DataWater::WaterStorage(WaterConnections(WaterConnNum).SupplyTankNum).VdotRequestDemand(WaterConnections(WaterConnNum).TankDemandID) = WaterConnections(WaterConnNum).ColdVolFlowRate; // Check if cold flow rate should be starved by restricted flow from tank // Currently, the tank flow is not really starved--water continues to flow at the tank water temperature // But the user can see the error by comparing report variables for TankVolFlowRate < ColdVolFlowRate - WaterConnections(WaterConnNum).TankVolFlowRate = - WaterStorage(WaterConnections(WaterConnNum).SupplyTankNum).VdotAvailDemand(WaterConnections(WaterConnNum).TankDemandID); - WaterConnections(WaterConnNum).TankMassFlowRate = WaterConnections(WaterConnNum).TankVolFlowRate * RhoH2O(DataGlobals::InitConvTemp); + WaterConnections(WaterConnNum).TankVolFlowRate = DataWater::WaterStorage(WaterConnections(WaterConnNum).SupplyTankNum) + .VdotAvailDemand(WaterConnections(WaterConnNum).TankDemandID); + WaterConnections(WaterConnNum).TankMassFlowRate = + WaterConnections(WaterConnNum).TankVolFlowRate * Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); } } @@ -1518,7 +1538,7 @@ namespace WaterUse { // Calculate // Using/Aliasing - using Psychrometrics::RhoH2O; + //using Psychrometrics::RhoH2O; // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int WaterEquipNum; @@ -1544,7 +1564,8 @@ namespace WaterUse { WaterConnections(WaterConnNum).DrainTemp = WaterConnections(WaterConnNum).HotTemp; } - WaterConnections(WaterConnNum).DrainVolFlowRate = WaterConnections(WaterConnNum).DrainMassFlowRate * RhoH2O(DataGlobals::InitConvTemp); + WaterConnections(WaterConnNum).DrainVolFlowRate = + WaterConnections(WaterConnNum).DrainMassFlowRate * Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); } void CalcConnectionsHeatRecovery(int const WaterConnNum) @@ -1560,9 +1581,9 @@ namespace WaterUse { // Calculate drainwater heat recovery // Using/Aliasing - using Psychrometrics::CPHW; + // using Psychrometrics::CPHW; // unused0909 USE DataEnvironment, ONLY: WaterMainsTemp - using DataWater::WaterStorage; + //using DataWater::WaterStorage; // SUBROUTINE LOCAL VARIABLE DECLARATIONS: Real64 CapacityRatio; @@ -1598,8 +1619,8 @@ namespace WaterUse { } } - HXCapacityRate = CPHW(DataGlobals::InitConvTemp) * WaterConnections(WaterConnNum).RecoveryMassFlowRate; - DrainCapacityRate = CPHW(DataGlobals::InitConvTemp) * WaterConnections(WaterConnNum).DrainMassFlowRate; + HXCapacityRate = Psychrometrics::CPHW(DataGlobals::InitConvTemp) * WaterConnections(WaterConnNum).RecoveryMassFlowRate; + DrainCapacityRate = Psychrometrics::CPHW(DataGlobals::InitConvTemp) * WaterConnections(WaterConnNum).DrainMassFlowRate; MinCapacityRate = min(DrainCapacityRate, HXCapacityRate); { @@ -1630,16 +1651,18 @@ namespace WaterUse { WaterConnections(WaterConnNum).RecoveryTemp = WaterConnections(WaterConnNum).ColdSupplyTemp + - WaterConnections(WaterConnNum).RecoveryRate / (CPHW(DataGlobals::InitConvTemp) * WaterConnections(WaterConnNum).TotalMassFlowRate); + WaterConnections(WaterConnNum).RecoveryRate / + (Psychrometrics::CPHW(DataGlobals::InitConvTemp) * WaterConnections(WaterConnNum).TotalMassFlowRate); WaterConnections(WaterConnNum).WasteTemp = WaterConnections(WaterConnNum).DrainTemp - - WaterConnections(WaterConnNum).RecoveryRate / (CPHW(DataGlobals::InitConvTemp) * WaterConnections(WaterConnNum).TotalMassFlowRate); + WaterConnections(WaterConnNum).RecoveryRate / + (Psychrometrics::CPHW(DataGlobals::InitConvTemp) * WaterConnections(WaterConnNum).TotalMassFlowRate); if (WaterConnections(WaterConnNum).RecoveryTankNum > 0) { - WaterStorage(WaterConnections(WaterConnNum).RecoveryTankNum).VdotAvailSupply(WaterConnections(WaterConnNum).TankSupplyID) = + DataWater::WaterStorage(WaterConnections(WaterConnNum).RecoveryTankNum).VdotAvailSupply(WaterConnections(WaterConnNum).TankSupplyID) = WaterConnections(WaterConnNum).DrainVolFlowRate; - WaterStorage(WaterConnections(WaterConnNum).RecoveryTankNum).TwaterSupply(WaterConnections(WaterConnNum).TankSupplyID) = + DataWater::WaterStorage(WaterConnections(WaterConnNum).RecoveryTankNum).TwaterSupply(WaterConnections(WaterConnNum).TankSupplyID) = WaterConnections(WaterConnNum).WasteTemp; } @@ -1681,8 +1704,8 @@ namespace WaterUse { // Updates the node variables with local variables. // Using/Aliasing - using DataLoopNode::Node; - using PlantUtilities::SafeCopyPlantNode; + //using DataLoopNode::Node; + //using PlantUtilities::SafeCopyPlantNode; // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int InletNode; @@ -1696,11 +1719,11 @@ namespace WaterUse { if (InletNode > 0 && OutletNode > 0) { // Pass all variables from inlet to outlet node - SafeCopyPlantNode(InletNode, OutletNode, LoopNum); + PlantUtilities::SafeCopyPlantNode(InletNode, OutletNode, LoopNum); // DSU3 Node(OutletNode) = Node(InletNode) // Set outlet node variables that are possibly changed - Node(OutletNode).Temp = WaterConnections(WaterConnNum).ReturnTemp; + DataLoopNode::Node(OutletNode).Temp = WaterConnections(WaterConnNum).ReturnTemp; // should add enthalpy update to return? } } @@ -1718,10 +1741,10 @@ namespace WaterUse { // Calculates report variables for stand alone water use // Using/Aliasing - using DataGlobals::SecInHour; - using DataHVACGlobals::TimeStepSys; - using Psychrometrics::CPHW; - using Psychrometrics::RhoH2O; + //using DataGlobals::SecInHour; + //using DataHVACGlobals::TimeStepSys; + //using Psychrometrics::CPHW; + //using Psychrometrics::RhoH2O; // Locals // SUBROUTINE ARGUMENT DEFINITIONS: @@ -1730,25 +1753,31 @@ namespace WaterUse { // FLOW: for (WaterEquipNum = 1; WaterEquipNum <= NumWaterEquipment; ++WaterEquipNum) { - WaterEquipment(WaterEquipNum).ColdVolFlowRate = WaterEquipment(WaterEquipNum).ColdMassFlowRate / RhoH2O(DataGlobals::InitConvTemp); - WaterEquipment(WaterEquipNum).HotVolFlowRate = WaterEquipment(WaterEquipNum).HotMassFlowRate / RhoH2O(DataGlobals::InitConvTemp); + WaterEquipment(WaterEquipNum).ColdVolFlowRate = + WaterEquipment(WaterEquipNum).ColdMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); + WaterEquipment(WaterEquipNum).HotVolFlowRate = + WaterEquipment(WaterEquipNum).HotMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); WaterEquipment(WaterEquipNum).TotalVolFlowRate = WaterEquipment(WaterEquipNum).ColdVolFlowRate + WaterEquipment(WaterEquipNum).HotVolFlowRate; - WaterEquipment(WaterEquipNum).ColdVolume = WaterEquipment(WaterEquipNum).ColdVolFlowRate * TimeStepSys * SecInHour; - WaterEquipment(WaterEquipNum).HotVolume = WaterEquipment(WaterEquipNum).HotVolFlowRate * TimeStepSys * SecInHour; - WaterEquipment(WaterEquipNum).TotalVolume = WaterEquipment(WaterEquipNum).TotalVolFlowRate * TimeStepSys * SecInHour; + WaterEquipment(WaterEquipNum).ColdVolume = + WaterEquipment(WaterEquipNum).ColdVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + WaterEquipment(WaterEquipNum).HotVolume = + WaterEquipment(WaterEquipNum).HotVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + WaterEquipment(WaterEquipNum).TotalVolume = + WaterEquipment(WaterEquipNum).TotalVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; if (WaterEquipment(WaterEquipNum).Connections == 0) { - WaterEquipment(WaterEquipNum).Power = WaterEquipment(WaterEquipNum).HotMassFlowRate * CPHW(DataGlobals::InitConvTemp) * + WaterEquipment(WaterEquipNum).Power = WaterEquipment(WaterEquipNum).HotMassFlowRate * + Psychrometrics::CPHW(DataGlobals::InitConvTemp) * (WaterEquipment(WaterEquipNum).HotTemp - WaterEquipment(WaterEquipNum).ColdTemp); } else { WaterEquipment(WaterEquipNum).Power = - WaterEquipment(WaterEquipNum).HotMassFlowRate * CPHW(DataGlobals::InitConvTemp) * + WaterEquipment(WaterEquipNum).HotMassFlowRate * Psychrometrics::CPHW(DataGlobals::InitConvTemp) * (WaterEquipment(WaterEquipNum).HotTemp - WaterConnections(WaterEquipment(WaterEquipNum).Connections).ReturnTemp); } - WaterEquipment(WaterEquipNum).Energy = WaterEquipment(WaterEquipNum).Power * TimeStepSys * SecInHour; + WaterEquipment(WaterEquipNum).Energy = WaterEquipment(WaterEquipNum).Power * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; } } @@ -1765,10 +1794,10 @@ namespace WaterUse { // Calculates report variables. // Using/Aliasing - using DataGlobals::SecInHour; - using DataHVACGlobals::TimeStepSys; - using Psychrometrics::CPHW; - using Psychrometrics::RhoH2O; + //using DataGlobals::SecInHour; + //using DataHVACGlobals::TimeStepSys; + //using Psychrometrics::CPHW; + //using Psychrometrics::RhoH2O; // Locals // SUBROUTINE ARGUMENT DEFINITIONS: @@ -1779,41 +1808,53 @@ namespace WaterUse { // FLOW: for (Loop = 1; Loop <= WaterConnections(WaterConnNum).NumWaterEquipment; ++Loop) { WaterEquipNum = WaterConnections(WaterConnNum).WaterEquipment(Loop); - WaterEquipment(WaterEquipNum).ColdVolFlowRate = WaterEquipment(WaterEquipNum).ColdMassFlowRate / RhoH2O(DataGlobals::InitConvTemp); - WaterEquipment(WaterEquipNum).HotVolFlowRate = WaterEquipment(WaterEquipNum).HotMassFlowRate / RhoH2O(DataGlobals::InitConvTemp); + WaterEquipment(WaterEquipNum).ColdVolFlowRate = + WaterEquipment(WaterEquipNum).ColdMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); + WaterEquipment(WaterEquipNum).HotVolFlowRate = + WaterEquipment(WaterEquipNum).HotMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); WaterEquipment(WaterEquipNum).TotalVolFlowRate = WaterEquipment(WaterEquipNum).ColdVolFlowRate + WaterEquipment(WaterEquipNum).HotVolFlowRate; - WaterEquipment(WaterEquipNum).ColdVolume = WaterEquipment(WaterEquipNum).ColdVolFlowRate * TimeStepSys * SecInHour; - WaterEquipment(WaterEquipNum).HotVolume = WaterEquipment(WaterEquipNum).HotVolFlowRate * TimeStepSys * SecInHour; - WaterEquipment(WaterEquipNum).TotalVolume = WaterEquipment(WaterEquipNum).TotalVolFlowRate * TimeStepSys * SecInHour; + WaterEquipment(WaterEquipNum).ColdVolume = + WaterEquipment(WaterEquipNum).ColdVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + WaterEquipment(WaterEquipNum).HotVolume = + WaterEquipment(WaterEquipNum).HotVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + WaterEquipment(WaterEquipNum).TotalVolume = + WaterEquipment(WaterEquipNum).TotalVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; if (WaterEquipment(WaterEquipNum).Connections == 0) { - WaterEquipment(WaterEquipNum).Power = WaterEquipment(WaterEquipNum).HotMassFlowRate * CPHW(DataGlobals::InitConvTemp) * + WaterEquipment(WaterEquipNum).Power = WaterEquipment(WaterEquipNum).HotMassFlowRate * + Psychrometrics::CPHW(DataGlobals::InitConvTemp) * (WaterEquipment(WaterEquipNum).HotTemp - WaterEquipment(WaterEquipNum).ColdTemp); } else { WaterEquipment(WaterEquipNum).Power = - WaterEquipment(WaterEquipNum).HotMassFlowRate * CPHW(DataGlobals::InitConvTemp) * + WaterEquipment(WaterEquipNum).HotMassFlowRate * Psychrometrics::CPHW(DataGlobals::InitConvTemp) * (WaterEquipment(WaterEquipNum).HotTemp - WaterConnections(WaterEquipment(WaterEquipNum).Connections).ReturnTemp); } - WaterEquipment(WaterEquipNum).Energy = WaterEquipment(WaterEquipNum).Power * TimeStepSys * SecInHour; + WaterEquipment(WaterEquipNum).Energy = WaterEquipment(WaterEquipNum).Power * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; } - WaterConnections(WaterConnNum).ColdVolFlowRate = WaterConnections(WaterConnNum).ColdMassFlowRate / RhoH2O(DataGlobals::InitConvTemp); - WaterConnections(WaterConnNum).HotVolFlowRate = WaterConnections(WaterConnNum).HotMassFlowRate / RhoH2O(DataGlobals::InitConvTemp); + WaterConnections(WaterConnNum).ColdVolFlowRate = + WaterConnections(WaterConnNum).ColdMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); + WaterConnections(WaterConnNum).HotVolFlowRate = + WaterConnections(WaterConnNum).HotMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); WaterConnections(WaterConnNum).TotalVolFlowRate = WaterConnections(WaterConnNum).ColdVolFlowRate + WaterConnections(WaterConnNum).HotVolFlowRate; - WaterConnections(WaterConnNum).ColdVolume = WaterConnections(WaterConnNum).ColdVolFlowRate * TimeStepSys * SecInHour; - WaterConnections(WaterConnNum).HotVolume = WaterConnections(WaterConnNum).HotVolFlowRate * TimeStepSys * SecInHour; - WaterConnections(WaterConnNum).TotalVolume = WaterConnections(WaterConnNum).TotalVolFlowRate * TimeStepSys * SecInHour; + WaterConnections(WaterConnNum).ColdVolume = + WaterConnections(WaterConnNum).ColdVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + WaterConnections(WaterConnNum).HotVolume = + WaterConnections(WaterConnNum).HotVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + WaterConnections(WaterConnNum).TotalVolume = + WaterConnections(WaterConnNum).TotalVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - WaterConnections(WaterConnNum).Power = WaterConnections(WaterConnNum).HotMassFlowRate * CPHW(DataGlobals::InitConvTemp) * + WaterConnections(WaterConnNum).Power = WaterConnections(WaterConnNum).HotMassFlowRate * Psychrometrics::CPHW(DataGlobals::InitConvTemp) * (WaterConnections(WaterConnNum).HotTemp - WaterConnections(WaterConnNum).ReturnTemp); - WaterConnections(WaterConnNum).Energy = WaterConnections(WaterConnNum).Power * TimeStepSys * SecInHour; + WaterConnections(WaterConnNum).Energy = WaterConnections(WaterConnNum).Power * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - WaterConnections(WaterConnNum).RecoveryEnergy = WaterConnections(WaterConnNum).RecoveryRate * TimeStepSys * SecInHour; + WaterConnections(WaterConnNum).RecoveryEnergy = + WaterConnections(WaterConnNum).RecoveryRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; } void CalcWaterUseZoneGains() @@ -1829,8 +1870,7 @@ namespace WaterUse { // Calculates the zone internal gains due to water use sensible and latent loads. // Using/Aliasing - using DataGlobals::BeginEnvrnFlag; - using DataHeatBalance::Zone; + //using DataHeatBalance::Zone; // Locals // SUBROUTINE LOCAL VARIABLE DECLARATIONS: @@ -1841,7 +1881,7 @@ namespace WaterUse { // FLOW: if (NumWaterEquipment == 0) return; - if (BeginEnvrnFlag && MyEnvrnFlag) { + if (DataGlobals::BeginEnvrnFlag && MyEnvrnFlag) { for (auto &e : WaterEquipment) { e.SensibleRate = 0.0; e.SensibleEnergy = 0.0; @@ -1861,16 +1901,17 @@ namespace WaterUse { MyEnvrnFlag = false; } - if (!BeginEnvrnFlag) MyEnvrnFlag = true; + if (!DataGlobals::BeginEnvrnFlag) MyEnvrnFlag = true; for (WaterEquipNum = 1; WaterEquipNum <= NumWaterEquipment; ++WaterEquipNum) { if (WaterEquipment(WaterEquipNum).Zone == 0) continue; ZoneNum = WaterEquipment(WaterEquipNum).Zone; WaterEquipment(WaterEquipNum).SensibleRateNoMultiplier = WaterEquipment(WaterEquipNum).SensibleRate / - (Zone(ZoneNum).Multiplier * Zone(ZoneNum).ListMultiplier); // CR7401, back out multipliers + (DataHeatBalance::Zone(ZoneNum).Multiplier * DataHeatBalance::Zone(ZoneNum).ListMultiplier); // CR7401, back out multipliers WaterEquipment(WaterEquipNum).LatentRateNoMultiplier = - WaterEquipment(WaterEquipNum).LatentRate / (Zone(ZoneNum).Multiplier * Zone(ZoneNum).ListMultiplier); // CR7401, back out multipliers + WaterEquipment(WaterEquipNum).LatentRate / + (DataHeatBalance::Zone(ZoneNum).Multiplier * DataHeatBalance::Zone(ZoneNum).ListMultiplier); // CR7401, back out multipliers } From 0e5cbd7362ac7560a5a612e59c19cac25f877302 Mon Sep 17 00:00:00 2001 From: Li Date: Thu, 10 Oct 2019 13:50:25 -0600 Subject: [PATCH 03/51] step-2: clear using statements i commented --- src/EnergyPlus/WaterUse.cc | 86 -------------------------------------- 1 file changed, 86 deletions(-) diff --git a/src/EnergyPlus/WaterUse.cc b/src/EnergyPlus/WaterUse.cc index ca7763832d8..22a71191e14 100644 --- a/src/EnergyPlus/WaterUse.cc +++ b/src/EnergyPlus/WaterUse.cc @@ -85,11 +85,6 @@ namespace WaterUse { // MODIFIED Brent Griffith, plant upgrade // RE-ENGINEERED na - // Using/Aliasing - //using namespace DataPrecisionGlobals; - //using DataGlobals::NumOfZones; - //using DataGlobals::WarmupFlag; - // MODULE PARAMETER DEFINITIONS: int const HeatRecoveryHXIdeal(1); int const HeatRecoveryHXCounterFlow(2); @@ -137,9 +132,6 @@ namespace WaterUse { // This routine is called from non zone equipment manager and serves to call // water use and connections that are not connected to a full plant loop - // Using/Aliasing - //using General::RoundSigDigits; - // Locals // SUBROUTINE PARAMETER DEFINITIONS: int const MaxIterations(100); @@ -247,10 +239,6 @@ namespace WaterUse { // Plant sim call for plant loop connected water use and connections // (based on SimulateWaterUse by P. Ellis) - // Using/Aliasing - //using General::RoundSigDigits; - //using General::TrimSigDigits; - // Locals // SUBROUTINE PARAMETER DEFINITIONS: int const MaxIterations(100); @@ -357,18 +345,6 @@ namespace WaterUse { // METHODOLOGY EMPLOYED: Standard EnergyPlus methodology. - // Using/Aliasing - //using namespace DataIPShortCuts; // Data for field names, blank numerics - //using BranchNodeConnections::TestCompSet; - //using NodeInputManager::GetOnlySingleNode; - //using ScheduleManager::GetScheduleIndex; - //using namespace DataLoopNode; - //using namespace DataHeatBalance; - //using PlantUtilities::RegisterPlantCompDesignFlow; - //using Psychrometrics::RhoH2O; - //using WaterManager::SetupTankDemandComponent; - //using WaterManager::SetupTankSupplyComponent; - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: static bool ErrorsFound(false); // Set to true if errors in input, fatal at end of routine int IOStatus; // Used in GetObjectItem @@ -1066,13 +1042,6 @@ namespace WaterUse { // PURPOSE OF THIS SUBROUTINE: // Calculate desired hot and cold water flow rates - - - // Using/Aliasing - //using DataEnvironment::WaterMainsTemp; - //using DataHeatBalance::Zone; - //using Psychrometrics::RhoH2O; - //using ScheduleManager::GetCurrentScheduleValue; // SUBROUTINE LOCAL VARIABLE DECLARATIONS: @@ -1184,19 +1153,6 @@ namespace WaterUse { // Calculate drainwater temperature and heat and moisture gains to zone. - // Using/Aliasing - //using DataEnvironment::OutBaroPress; - //using DataGlobals::SecInHour; - //using DataHeatBalance::Zone; - //using DataHeatBalFanSys::MAT; - //using DataHeatBalFanSys::ZoneAirHumRat; - //using DataHVACGlobals::TimeStepSys; - //using Psychrometrics::CPHW; - //using Psychrometrics::PsyHfgAirFnWTdb; - //using Psychrometrics::PsyRhoAirFnPbTdbW; - //using Psychrometrics::PsyWFnTdbRhPb; - //using ScheduleManager::GetCurrentScheduleValue; - // Locals // SUBROUTINE ARGUMENT DEFINITIONS: @@ -1290,18 +1246,6 @@ namespace WaterUse { // MODIFIED Brent Griffith 2010, demand side update // RE-ENGINEERED na - // Using/Aliasing - //using DataEnvironment::WaterMainsTemp; - //using DataGlobals::DoingSizing; - //using DataHeatBalance::Zone; - //using DataLoopNode::Node; - //using DataPlant::PlantLoop; - //using DataPlant::TypeOf_WaterUseConnection; - //using DataWater::WaterStorage; - //using PlantUtilities::InitComponentNodes; - //using PlantUtilities::ScanPlantLoopsForObject; - //using ScheduleManager::GetCurrentScheduleValue; - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int InletNode; @@ -1409,11 +1353,6 @@ namespace WaterUse { // PURPOSE OF THIS SUBROUTINE: // Calculate summed values for WATER USE CONNECTIONS (to prepare to request flow from plant, and for reporting). - // Using/Aliasing - //using DataLoopNode::Node; - //using DataWater::WaterStorage; - //using PlantUtilities::SetComponentFlowRate; - //using Psychrometrics::RhoH2O; // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int WaterEquipNum; @@ -1537,8 +1476,6 @@ namespace WaterUse { // PURPOSE OF THIS SUBROUTINE: // Calculate - // Using/Aliasing - //using Psychrometrics::RhoH2O; // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int WaterEquipNum; @@ -1580,11 +1517,6 @@ namespace WaterUse { // PURPOSE OF THIS SUBROUTINE: // Calculate drainwater heat recovery - // Using/Aliasing - // using Psychrometrics::CPHW; - // unused0909 USE DataEnvironment, ONLY: WaterMainsTemp - //using DataWater::WaterStorage; - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: Real64 CapacityRatio; Real64 NTU; @@ -1703,10 +1635,6 @@ namespace WaterUse { // PURPOSE OF THIS SUBROUTINE: // Updates the node variables with local variables. - // Using/Aliasing - //using DataLoopNode::Node; - //using PlantUtilities::SafeCopyPlantNode; - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int InletNode; int OutletNode; @@ -1740,11 +1668,6 @@ namespace WaterUse { // PURPOSE OF THIS SUBROUTINE: // Calculates report variables for stand alone water use - // Using/Aliasing - //using DataGlobals::SecInHour; - //using DataHVACGlobals::TimeStepSys; - //using Psychrometrics::CPHW; - //using Psychrometrics::RhoH2O; // Locals // SUBROUTINE ARGUMENT DEFINITIONS: @@ -1793,12 +1716,6 @@ namespace WaterUse { // PURPOSE OF THIS SUBROUTINE: // Calculates report variables. - // Using/Aliasing - //using DataGlobals::SecInHour; - //using DataHVACGlobals::TimeStepSys; - //using Psychrometrics::CPHW; - //using Psychrometrics::RhoH2O; - // Locals // SUBROUTINE ARGUMENT DEFINITIONS: @@ -1869,9 +1786,6 @@ namespace WaterUse { // PURPOSE OF THIS SUBROUTINE: // Calculates the zone internal gains due to water use sensible and latent loads. - // Using/Aliasing - //using DataHeatBalance::Zone; - // Locals // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int WaterEquipNum; From 85a6a734f9b298cbb5fb636229fdcc010463a969 Mon Sep 17 00:00:00 2001 From: Li Date: Thu, 10 Oct 2019 14:20:28 -0600 Subject: [PATCH 04/51] step-3: clear const arguments in functions --- src/EnergyPlus/WaterUse.cc | 20 ++++++++++---------- src/EnergyPlus/WaterUse.hh | 20 ++++++++++---------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/EnergyPlus/WaterUse.cc b/src/EnergyPlus/WaterUse.cc index 22a71191e14..7ff42d3657c 100644 --- a/src/EnergyPlus/WaterUse.cc +++ b/src/EnergyPlus/WaterUse.cc @@ -119,7 +119,7 @@ namespace WaterUse { WaterConnections.deallocate(); } - void SimulateWaterUse(bool const FirstHVACIteration) + void SimulateWaterUse(bool FirstHVACIteration) { // SUBROUTINE INFORMATION: @@ -226,7 +226,7 @@ namespace WaterUse { } void SimulateWaterUseConnection( - int const EP_UNUSED(EquipTypeNum), std::string const &CompName, int &CompIndex, bool const InitLoopEquip, bool const FirstHVACIteration) + int EP_UNUSED(EquipTypeNum), std::string &CompName, int &CompIndex, bool InitLoopEquip, bool FirstHVACIteration) { // SUBROUTINE INFORMATION: @@ -1031,7 +1031,7 @@ namespace WaterUse { } // WaterConnNum } - void CalcEquipmentFlowRates(int const WaterEquipNum) + void CalcEquipmentFlowRates(int WaterEquipNum) { // SUBROUTINE INFORMATION: @@ -1140,7 +1140,7 @@ namespace WaterUse { } } - void CalcEquipmentDrainTemp(int const WaterEquipNum) + void CalcEquipmentDrainTemp(int WaterEquipNum) { // SUBROUTINE INFORMATION: @@ -1237,7 +1237,7 @@ namespace WaterUse { } } - void InitConnections(int const WaterConnNum) + void InitConnections(int WaterConnNum) { // SUBROUTINE INFORMATION: @@ -1341,7 +1341,7 @@ namespace WaterUse { } } - void CalcConnectionsFlowRates(int const WaterConnNum, bool const FirstHVACIteration) + void CalcConnectionsFlowRates(int WaterConnNum, bool FirstHVACIteration) { // SUBROUTINE INFORMATION: @@ -1464,7 +1464,7 @@ namespace WaterUse { } } - void CalcConnectionsDrainTemp(int const WaterConnNum) + void CalcConnectionsDrainTemp(int WaterConnNum) { // SUBROUTINE INFORMATION: @@ -1505,7 +1505,7 @@ namespace WaterUse { WaterConnections(WaterConnNum).DrainMassFlowRate * Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); } - void CalcConnectionsHeatRecovery(int const WaterConnNum) + void CalcConnectionsHeatRecovery(int WaterConnNum) { // SUBROUTINE INFORMATION: @@ -1623,7 +1623,7 @@ namespace WaterUse { } } - void UpdateWaterConnections(int const WaterConnNum) + void UpdateWaterConnections(int WaterConnNum) { // SUBROUTINE INFORMATION: @@ -1704,7 +1704,7 @@ namespace WaterUse { } } - void ReportWaterUse(int const WaterConnNum) + void ReportWaterUse(int WaterConnNum) { // SUBROUTINE INFORMATION: diff --git a/src/EnergyPlus/WaterUse.hh b/src/EnergyPlus/WaterUse.hh index 55f717a02f9..1c9f5a4a023 100644 --- a/src/EnergyPlus/WaterUse.hh +++ b/src/EnergyPlus/WaterUse.hh @@ -237,30 +237,30 @@ namespace WaterUse { void clear_state(); - void SimulateWaterUse(bool const FirstHVACIteration); + void SimulateWaterUse(bool FirstHVACIteration); void SimulateWaterUseConnection( - int const EquipTypeNum, std::string const &CompName, int &CompIndex, bool const InitLoopEquip, bool const FirstHVACIteration); + int EquipTypeNum, std::string &CompName, int &CompIndex, bool InitLoopEquip, bool FirstHVACIteration); void GetWaterUseInput(); - void CalcEquipmentFlowRates(int const WaterEquipNum); + void CalcEquipmentFlowRates(int WaterEquipNum); - void CalcEquipmentDrainTemp(int const WaterEquipNum); + void CalcEquipmentDrainTemp(int WaterEquipNum); - void InitConnections(int const WaterConnNum); + void InitConnections(int WaterConnNum); - void CalcConnectionsFlowRates(int const WaterConnNum, bool const FirstHVACIteration); + void CalcConnectionsFlowRates(int WaterConnNum, bool FirstHVACIteration); - void CalcConnectionsDrainTemp(int const WaterConnNum); + void CalcConnectionsDrainTemp(int WaterConnNum); - void CalcConnectionsHeatRecovery(int const WaterConnNum); + void CalcConnectionsHeatRecovery(int WaterConnNum); - void UpdateWaterConnections(int const WaterConnNum); + void UpdateWaterConnections(int WaterConnNum); void ReportStandAloneWaterUse(); - void ReportWaterUse(int const WaterConnNum); + void ReportWaterUse(int WaterConnNum); void CalcWaterUseZoneGains(); From 5623436b5efabdffe1ae4361ecefd29e237b3b13 Mon Sep 17 00:00:00 2001 From: Li Date: Thu, 10 Oct 2019 22:17:48 -0600 Subject: [PATCH 05/51] step-4: clear static vars --- src/EnergyPlus/WaterUse.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/EnergyPlus/WaterUse.cc b/src/EnergyPlus/WaterUse.cc index 7ff42d3657c..2b3b791260d 100644 --- a/src/EnergyPlus/WaterUse.cc +++ b/src/EnergyPlus/WaterUse.cc @@ -141,8 +141,8 @@ namespace WaterUse { int WaterEquipNum; int WaterConnNum; int NumIteration; - static int MaxIterationsErrorCount; - static bool MyEnvrnFlag(true); + int MaxIterationsErrorCount; + bool MyEnvrnFlag(true); // FLOW: if (GetWaterUseInputFlag) { @@ -248,8 +248,8 @@ namespace WaterUse { // INTEGER :: WaterEquipNum int WaterConnNum; int NumIteration; - static int MaxIterationsErrorCount; - static bool MyEnvrnFlag(true); + int MaxIterationsErrorCount; + bool MyEnvrnFlag(true); // FLOW: if (GetWaterUseInputFlag) { @@ -346,7 +346,7 @@ namespace WaterUse { // METHODOLOGY EMPLOYED: Standard EnergyPlus methodology. // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - static bool ErrorsFound(false); // Set to true if errors in input, fatal at end of routine + bool ErrorsFound(false); // Set to true if errors in input, fatal at end of routine int IOStatus; // Used in GetObjectItem int NumAlphas; // Number of Alphas for each GetObjectItem call int NumNumbers; // Number of Numbers for each GetObjectItem call @@ -1250,7 +1250,7 @@ namespace WaterUse { // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int InletNode; int OutletNode; - static bool MyOneTimeFlag(true); // one time flag !DSU + bool MyOneTimeFlag(true); // one time flag !DSU static Array1D_bool SetLoopIndexFlag; // get loop number flag !DSU bool errFlag; @@ -1790,7 +1790,7 @@ namespace WaterUse { // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int WaterEquipNum; int ZoneNum; - static bool MyEnvrnFlag(true); + bool MyEnvrnFlag(true); // FLOW: if (NumWaterEquipment == 0) return; From 500199ebe368930c924a7725a0346ce3087af3d2 Mon Sep 17 00:00:00 2001 From: Li Date: Tue, 15 Oct 2019 15:18:50 -0600 Subject: [PATCH 06/51] step-5: update module variables --- src/EnergyPlus/WaterUse.cc | 64 +++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/src/EnergyPlus/WaterUse.cc b/src/EnergyPlus/WaterUse.cc index 2b3b791260d..4d7d03016f7 100644 --- a/src/EnergyPlus/WaterUse.cc +++ b/src/EnergyPlus/WaterUse.cc @@ -97,8 +97,8 @@ namespace WaterUse { static std::string const BlankString; // MODULE VARIABLE DECLARATIONS: - int NumWaterEquipment(0); - int NumWaterConnections(0); + int modNumWaterEquipment(0); + int modNumWaterConnections(0); bool GetWaterUseInputFlag(true); Array1D_bool CheckEquipName; @@ -110,8 +110,8 @@ namespace WaterUse { void clear_state() { - NumWaterEquipment = 0; - NumWaterConnections = 0; + modNumWaterEquipment = 0; + modNumWaterConnections = 0; GetWaterUseInputFlag = true; CheckEquipName.deallocate(); CheckPlantLoop.deallocate(); @@ -152,7 +152,7 @@ namespace WaterUse { if (DataGlobals::BeginEnvrnFlag && MyEnvrnFlag) { MaxIterationsErrorCount = 0; - if (NumWaterEquipment > 0) { + if (modNumWaterEquipment > 0) { for (auto &e : WaterEquipment) { e.SensibleRate = 0.0; e.SensibleEnergy = 0.0; @@ -164,7 +164,7 @@ namespace WaterUse { } } - if (NumWaterConnections > 0) { + if (modNumWaterConnections > 0) { for (auto &e : WaterConnections) e.TotalMassFlowRate = 0.0; } @@ -175,7 +175,7 @@ namespace WaterUse { if (!DataGlobals::BeginEnvrnFlag) MyEnvrnFlag = true; // Simulate all unconnected WATER USE EQUIPMENT objects - for (WaterEquipNum = 1; WaterEquipNum <= NumWaterEquipment; ++WaterEquipNum) { + for (WaterEquipNum = 1; WaterEquipNum <= modNumWaterEquipment; ++WaterEquipNum) { if (WaterEquipment(WaterEquipNum).Connections == 0) { CalcEquipmentFlowRates(WaterEquipNum); CalcEquipmentDrainTemp(WaterEquipNum); @@ -185,7 +185,7 @@ namespace WaterUse { ReportStandAloneWaterUse(); // Simulate WATER USE CONNECTIONS objects and connected WATER USE EQUIPMENT objects - for (WaterConnNum = 1; WaterConnNum <= NumWaterConnections; ++WaterConnNum) { + for (WaterConnNum = 1; WaterConnNum <= modNumWaterConnections; ++WaterConnNum) { if (!WaterConnections(WaterConnNum).StandAlone) continue; // only model non plant connections here @@ -265,9 +265,9 @@ namespace WaterUse { CompIndex = WaterConnNum; } else { WaterConnNum = CompIndex; - if (WaterConnNum > NumWaterConnections || WaterConnNum < 1) { + if (WaterConnNum > modNumWaterConnections || WaterConnNum < 1) { ShowFatalError("SimulateWaterUseConnection: Invalid CompIndex passed=" + General::TrimSigDigits(WaterConnNum) + - ", Number of Units=" + General::TrimSigDigits(NumWaterConnections) + ", Entered Unit name=" + CompName); + ", Number of Units=" + General::TrimSigDigits(modNumWaterConnections) + ", Entered Unit name=" + CompName); } if (CheckEquipName(WaterConnNum)) { if (CompName != WaterConnections(WaterConnNum).Name) { @@ -284,13 +284,13 @@ namespace WaterUse { if (DataGlobals::BeginEnvrnFlag && MyEnvrnFlag) { MaxIterationsErrorCount = 0; - if (NumWaterEquipment > 0) { + if (modNumWaterEquipment > 0) { for (int i = WaterEquipment.l(), e = WaterEquipment.u(); i <= e; ++i) { WaterEquipment(i).reset(); } } - if (NumWaterConnections > 0) { + if (modNumWaterConnections > 0) { for (auto &e : WaterConnections) e.TotalMassFlowRate = 0.0; } @@ -359,12 +359,12 @@ namespace WaterUse { // FLOW: DataIPShortCuts::cCurrentModuleObject = "WaterUse:Equipment"; - NumWaterEquipment = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); + modNumWaterEquipment = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); - if (NumWaterEquipment > 0) { - WaterEquipment.allocate(NumWaterEquipment); + if (modNumWaterEquipment > 0) { + WaterEquipment.allocate(modNumWaterEquipment); - for (WaterEquipNum = 1; WaterEquipNum <= NumWaterEquipment; ++WaterEquipNum) { + for (WaterEquipNum = 1; WaterEquipNum <= modNumWaterEquipment; ++WaterEquipNum) { inputProcessor->getObjectItem(DataIPShortCuts::cCurrentModuleObject, WaterEquipNum, DataIPShortCuts::cAlphaArgs, @@ -463,12 +463,12 @@ namespace WaterUse { } DataIPShortCuts::cCurrentModuleObject = "WaterUse:Connections"; - NumWaterConnections = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); + modNumWaterConnections = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); - if (NumWaterConnections > 0) { - WaterConnections.allocate(NumWaterConnections); + if (modNumWaterConnections > 0) { + WaterConnections.allocate(modNumWaterConnections); - for (WaterConnNum = 1; WaterConnNum <= NumWaterConnections; ++WaterConnNum) { + for (WaterConnNum = 1; WaterConnNum <= modNumWaterConnections; ++WaterConnNum) { inputProcessor->getObjectItem(DataIPShortCuts::cCurrentModuleObject, WaterConnNum, DataIPShortCuts::cAlphaArgs, @@ -621,17 +621,17 @@ namespace WaterUse { if (ErrorsFound) ShowFatalError("Errors found in processing input for " + DataIPShortCuts::cCurrentModuleObject); - if (NumWaterConnections > 0) { - CheckEquipName.allocate(NumWaterConnections); - CheckPlantLoop.allocate(NumWaterConnections); + if (modNumWaterConnections > 0) { + CheckEquipName.allocate(modNumWaterConnections); + CheckPlantLoop.allocate(modNumWaterConnections); CheckEquipName = true; CheckPlantLoop = true; } } // determine connection's peak mass flow rates. - if (NumWaterConnections > 0) { - for (WaterConnNum = 1; WaterConnNum <= NumWaterConnections; ++WaterConnNum) { + if (modNumWaterConnections > 0) { + for (WaterConnNum = 1; WaterConnNum <= modNumWaterConnections; ++WaterConnNum) { WaterConnections(WaterConnNum).PeakMassFlowRate = 0.0; for (WaterEquipNum = 1; WaterEquipNum <= WaterConnections(WaterConnNum).NumWaterEquipment; ++WaterEquipNum) { thisWaterEquipNum = WaterConnections(WaterConnNum).WaterEquipment(WaterEquipNum); @@ -651,7 +651,7 @@ namespace WaterUse { // Setup EQUIPMENT report variables (now that connections have been established) // CurrentModuleObject='WaterUse:Equipment' - for (WaterEquipNum = 1; WaterEquipNum <= NumWaterEquipment; ++WaterEquipNum) { + for (WaterEquipNum = 1; WaterEquipNum <= modNumWaterEquipment; ++WaterEquipNum) { SetupOutputVariable("Water Use Equipment Hot Water Mass Flow Rate", OutputProcessor::Unit::kg_s, @@ -868,7 +868,7 @@ namespace WaterUse { // Setup CONNECTIONS report variables (don't put any on meters; they are metered at WATER USE EQUIPMENT level) // CurrentModuleObject='WaterUse:Connections' - for (WaterConnNum = 1; WaterConnNum <= NumWaterConnections; ++WaterConnNum) { + for (WaterConnNum = 1; WaterConnNum <= modNumWaterConnections; ++WaterConnNum) { SetupOutputVariable("Water Use Connections Hot Water Mass Flow Rate", OutputProcessor::Unit::kg_s, @@ -1251,11 +1251,11 @@ namespace WaterUse { int InletNode; int OutletNode; bool MyOneTimeFlag(true); // one time flag !DSU - static Array1D_bool SetLoopIndexFlag; // get loop number flag !DSU + Array1D_bool SetLoopIndexFlag; // get loop number flag !DSU bool errFlag; if (MyOneTimeFlag) { // DSU - SetLoopIndexFlag.dimension(NumWaterConnections, true); // DSU + SetLoopIndexFlag.dimension(modNumWaterConnections, true); // DSU MyOneTimeFlag = false; // DSU } // DSU @@ -1675,7 +1675,7 @@ namespace WaterUse { int WaterEquipNum; // FLOW: - for (WaterEquipNum = 1; WaterEquipNum <= NumWaterEquipment; ++WaterEquipNum) { + for (WaterEquipNum = 1; WaterEquipNum <= modNumWaterEquipment; ++WaterEquipNum) { WaterEquipment(WaterEquipNum).ColdVolFlowRate = WaterEquipment(WaterEquipNum).ColdMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); WaterEquipment(WaterEquipNum).HotVolFlowRate = @@ -1793,7 +1793,7 @@ namespace WaterUse { bool MyEnvrnFlag(true); // FLOW: - if (NumWaterEquipment == 0) return; + if (modNumWaterEquipment == 0) return; if (DataGlobals::BeginEnvrnFlag && MyEnvrnFlag) { for (auto &e : WaterEquipment) { @@ -1817,7 +1817,7 @@ namespace WaterUse { if (!DataGlobals::BeginEnvrnFlag) MyEnvrnFlag = true; - for (WaterEquipNum = 1; WaterEquipNum <= NumWaterEquipment; ++WaterEquipNum) { + for (WaterEquipNum = 1; WaterEquipNum <= modNumWaterEquipment; ++WaterEquipNum) { if (WaterEquipment(WaterEquipNum).Zone == 0) continue; ZoneNum = WaterEquipment(WaterEquipNum).Zone; WaterEquipment(WaterEquipNum).SensibleRateNoMultiplier = From d1112948320882bd1dc94d939311da1d4573afba Mon Sep 17 00:00:00 2001 From: Li Date: Tue, 15 Oct 2019 16:13:38 -0600 Subject: [PATCH 07/51] step-9: clean a few local variable usages --- src/EnergyPlus/WaterUse.cc | 99 ++++++++++++++++++-------------------- src/EnergyPlus/WaterUse.hh | 10 +++- 2 files changed, 56 insertions(+), 53 deletions(-) diff --git a/src/EnergyPlus/WaterUse.cc b/src/EnergyPlus/WaterUse.cc index 4d7d03016f7..4566b7fd056 100644 --- a/src/EnergyPlus/WaterUse.cc +++ b/src/EnergyPlus/WaterUse.cc @@ -1248,8 +1248,6 @@ namespace WaterUse { // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - int InletNode; - int OutletNode; bool MyOneTimeFlag(true); // one time flag !DSU Array1D_bool SetLoopIndexFlag; // get loop number flag !DSU bool errFlag; @@ -1306,22 +1304,20 @@ namespace WaterUse { } } else { - InletNode = WaterConnections(WaterConnNum).InletNode; - OutletNode = WaterConnections(WaterConnNum).OutletNode; if (DataGlobals::BeginEnvrnFlag && WaterConnections(WaterConnNum).Init) { // Clear node initial conditions - if (InletNode > 0 && OutletNode > 0) { + if (WaterConnections(WaterConnNum).InletNode > 0 && WaterConnections(WaterConnNum).OutletNode > 0) { PlantUtilities::InitComponentNodes(0.0, WaterConnections(WaterConnNum).PeakMassFlowRate, - InletNode, - OutletNode, + WaterConnections(WaterConnNum).InletNode, + WaterConnections(WaterConnNum).OutletNode, WaterConnections(WaterConnNum).PlantLoopNum, WaterConnections(WaterConnNum).PlantLoopSide, WaterConnections(WaterConnNum).PlantLoopBranchNum, WaterConnections(WaterConnNum).PlantLoopCompNum); - WaterConnections(WaterConnNum).ReturnTemp = DataLoopNode::Node(InletNode).Temp; + WaterConnections(WaterConnNum).ReturnTemp = DataLoopNode::Node(WaterConnections(WaterConnNum).InletNode).Temp; } WaterConnections(WaterConnNum).Init = false; @@ -1329,9 +1325,9 @@ namespace WaterUse { if (!DataGlobals::BeginEnvrnFlag) WaterConnections(WaterConnNum).Init = true; - if (InletNode > 0) { + if (WaterConnections(WaterConnNum).InletNode > 0) { if (!DataGlobals::DoingSizing) { - WaterConnections(WaterConnNum).HotTemp = DataLoopNode::Node(InletNode).Temp; + WaterConnections(WaterConnNum).HotTemp = DataLoopNode::Node(WaterConnections(WaterConnNum).InletNode).Temp; } else { // plant loop will not be running so need a value here. // should change to use tank setpoint but water use connections don't have knowledge of the tank they are fed by @@ -1357,12 +1353,8 @@ namespace WaterUse { // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int WaterEquipNum; int Loop; - int InletNode; - int OutletNode; int LoopNum; int LoopSideNum; - Real64 AvailableFraction; - Real64 DesiredHotWaterMassFlow; // store original request // FLOW: WaterConnections(WaterConnNum).ColdMassFlowRate = 0.0; @@ -1381,29 +1373,25 @@ namespace WaterUse { WaterConnections(WaterConnNum).ColdMassFlowRate + WaterConnections(WaterConnNum).HotMassFlowRate; if (!WaterConnections(WaterConnNum).StandAlone) { // Interact with the plant loop - InletNode = WaterConnections(WaterConnNum).InletNode; - OutletNode = WaterConnections(WaterConnNum).OutletNode; LoopNum = WaterConnections(WaterConnNum).PlantLoopNum; LoopSideNum = WaterConnections(WaterConnNum).PlantLoopSide; - if (InletNode > 0) { + if (WaterConnections(WaterConnNum).InletNode > 0) { if (FirstHVACIteration) { // Request the mass flow rate from the demand side manager - // Node(InletNode)%MassFlowRate = WaterConnections(WaterConnNum)%HotMassFlowRate - // Node(InletNode)%MassFlowRateMaxAvail = WaterConnections(WaterConnNum)%PeakMassFlowRate - // Node(InletNode)%MassFlowRateMinAvail = 0.0D0 + PlantUtilities::SetComponentFlowRate(WaterConnections(WaterConnNum).HotMassFlowRate, - InletNode, - OutletNode, + WaterConnections(WaterConnNum).InletNode, + WaterConnections(WaterConnNum).OutletNode, LoopNum, LoopSideNum, WaterConnections(WaterConnNum).PlantLoopBranchNum, WaterConnections(WaterConnNum).PlantLoopCompNum); } else { - DesiredHotWaterMassFlow = WaterConnections(WaterConnNum).HotMassFlowRate; - PlantUtilities::SetComponentFlowRate(DesiredHotWaterMassFlow, - InletNode, - OutletNode, + + PlantUtilities::SetComponentFlowRate(WaterConnections(WaterConnNum).HotMassFlowRate, + WaterConnections(WaterConnNum).InletNode, + WaterConnections(WaterConnNum).OutletNode, LoopNum, LoopSideNum, WaterConnections(WaterConnNum).PlantLoopBranchNum, @@ -1411,12 +1399,13 @@ namespace WaterUse { // DSU3 Node(InletNode)%MassFlowRate = MIN(WaterConnections(WaterConnNum)%HotMassFlowRate, Node(InletNode)%MassFlowRateMaxAvail) // DSU3 Node(InletNode)%MassFlowRate = MAX(WaterConnections(WaterConnNum)%HotMassFlowRate, Node(InletNode)%MassFlowRateMinAvail) // readjust if more than actual available mass flow rate determined by the demand side manager - if ((WaterConnections(WaterConnNum).HotMassFlowRate != DesiredHotWaterMassFlow) && + if ((WaterConnections(WaterConnNum).HotMassFlowRate != WaterConnections(WaterConnNum).HotMassFlowRate) && (WaterConnections(WaterConnNum).HotMassFlowRate > 0.0)) { // plant didn't give what was asked for // DSU3 Node(InletNode)%MassFlowRate = Node(InletNode)%MassFlowRateMaxAvail - AvailableFraction = DesiredHotWaterMassFlow / WaterConnections(WaterConnNum).HotMassFlowRate; + WaterConnections(WaterConnNum).AvailableFraction = + WaterConnections(WaterConnNum).HotMassFlowRate / WaterConnections(WaterConnNum).HotMassFlowRate; // DSU3 WaterConnections(WaterConnNum)%HotMassFlowRate = Node(InletNode)%MassFlowRateMaxAvail WaterConnections(WaterConnNum).ColdMassFlowRate = @@ -1428,7 +1417,7 @@ namespace WaterUse { WaterEquipNum = WaterConnections(WaterConnNum).WaterEquipment(Loop); // Recalculate flow rates for water equipment within connection - WaterEquipment(WaterEquipNum).HotMassFlowRate *= AvailableFraction; + WaterEquipment(WaterEquipNum).HotMassFlowRate *= WaterConnections(WaterConnNum).AvailableFraction; WaterEquipment(WaterEquipNum).ColdMassFlowRate = WaterEquipment(WaterEquipNum).TotalMassFlowRate - WaterEquipment(WaterEquipNum).HotMassFlowRate; @@ -1515,16 +1504,8 @@ namespace WaterUse { // RE-ENGINEERED na // PURPOSE OF THIS SUBROUTINE: - // Calculate drainwater heat recovery - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - Real64 CapacityRatio; - Real64 NTU; - Real64 ExpVal; - Real64 HXCapacityRate; - Real64 DrainCapacityRate; - Real64 MinCapacityRate; - + // Calculate drainwater heat recovery + // FLOW: if (!WaterConnections(WaterConnNum).HeatRecovery) { WaterConnections(WaterConnNum).RecoveryTemp = WaterConnections(WaterConnNum).ColdSupplyTemp; @@ -1551,9 +1532,12 @@ namespace WaterUse { } } - HXCapacityRate = Psychrometrics::CPHW(DataGlobals::InitConvTemp) * WaterConnections(WaterConnNum).RecoveryMassFlowRate; - DrainCapacityRate = Psychrometrics::CPHW(DataGlobals::InitConvTemp) * WaterConnections(WaterConnNum).DrainMassFlowRate; - MinCapacityRate = min(DrainCapacityRate, HXCapacityRate); + WaterConnections(WaterConnNum).HXCapacityRate = + Psychrometrics::CPHW(DataGlobals::InitConvTemp) * WaterConnections(WaterConnNum).RecoveryMassFlowRate; + WaterConnections(WaterConnNum).DrainCapacityRate = + Psychrometrics::CPHW(DataGlobals::InitConvTemp) * WaterConnections(WaterConnNum).DrainMassFlowRate; + WaterConnections(WaterConnNum).MinCapacityRate = + min(WaterConnections(WaterConnNum).DrainCapacityRate, WaterConnections(WaterConnNum).HXCapacityRate); { auto const SELECT_CASE_var(WaterConnections(WaterConnNum).HeatRecoveryHX); @@ -1561,24 +1545,35 @@ namespace WaterUse { WaterConnections(WaterConnNum).Effectiveness = 1.0; } else if (SELECT_CASE_var == HeatRecoveryHXCounterFlow) { // Unmixed - CapacityRatio = MinCapacityRate / max(DrainCapacityRate, HXCapacityRate); - NTU = WaterConnections(WaterConnNum).HXUA / MinCapacityRate; - if (CapacityRatio == 1.0) { - WaterConnections(WaterConnNum).Effectiveness = NTU / (1.0 + NTU); + WaterConnections(WaterConnNum).CapacityRatio = + WaterConnections(WaterConnNum).MinCapacityRate / + max(WaterConnections(WaterConnNum).DrainCapacityRate, WaterConnections(WaterConnNum).HXCapacityRate); + WaterConnections(WaterConnNum).NTU = WaterConnections(WaterConnNum).HXUA / WaterConnections(WaterConnNum).MinCapacityRate; + if (WaterConnections(WaterConnNum).CapacityRatio == 1.0) { + WaterConnections(WaterConnNum).Effectiveness = + WaterConnections(WaterConnNum).NTU / (1.0 + WaterConnections(WaterConnNum).NTU); } else { - ExpVal = std::exp(-NTU * (1.0 - CapacityRatio)); - WaterConnections(WaterConnNum).Effectiveness = (1.0 - ExpVal) / (1.0 - CapacityRatio * ExpVal); + WaterConnections(WaterConnNum).ExpVal = + std::exp(-WaterConnections(WaterConnNum).NTU * (1.0 - WaterConnections(WaterConnNum).CapacityRatio)); + WaterConnections(WaterConnNum).Effectiveness = + (1.0 - WaterConnections(WaterConnNum).ExpVal) / + (1.0 - WaterConnections(WaterConnNum).CapacityRatio * WaterConnections(WaterConnNum).ExpVal); } } else if (SELECT_CASE_var == HeatRecoveryHXCrossFlow) { // Unmixed - CapacityRatio = MinCapacityRate / max(DrainCapacityRate, HXCapacityRate); - NTU = WaterConnections(WaterConnNum).HXUA / MinCapacityRate; + WaterConnections(WaterConnNum).CapacityRatio = + WaterConnections(WaterConnNum).MinCapacityRate / + max(WaterConnections(WaterConnNum).DrainCapacityRate, WaterConnections(WaterConnNum).HXCapacityRate); + WaterConnections(WaterConnNum).NTU = WaterConnections(WaterConnNum).HXUA / WaterConnections(WaterConnNum).MinCapacityRate; WaterConnections(WaterConnNum).Effectiveness = - 1.0 - std::exp((std::pow(NTU, 0.22) / CapacityRatio) * (std::exp(-CapacityRatio * std::pow(NTU, 0.78)) - 1.0)); + 1.0 - std::exp((std::pow(WaterConnections(WaterConnNum).NTU, 0.22) / WaterConnections(WaterConnNum).CapacityRatio) * + (std::exp(-WaterConnections(WaterConnNum).CapacityRatio * std::pow(WaterConnections(WaterConnNum).NTU, 0.78)) - + 1.0)); } } - WaterConnections(WaterConnNum).RecoveryRate = WaterConnections(WaterConnNum).Effectiveness * MinCapacityRate * + WaterConnections(WaterConnNum).RecoveryRate = WaterConnections(WaterConnNum).Effectiveness * + WaterConnections(WaterConnNum).MinCapacityRate * (WaterConnections(WaterConnNum).DrainTemp - WaterConnections(WaterConnNum).ColdSupplyTemp); WaterConnections(WaterConnNum).RecoveryTemp = diff --git a/src/EnergyPlus/WaterUse.hh b/src/EnergyPlus/WaterUse.hh index 1c9f5a4a023..0f4ff3a057e 100644 --- a/src/EnergyPlus/WaterUse.hh +++ b/src/EnergyPlus/WaterUse.hh @@ -206,6 +206,13 @@ namespace WaterUse { Real64 TotalVolume; // Water consumption (m3) Real64 Power; // Heating rate required to raise temperature from cold to hot (W) Real64 Energy; // Heating energy required to raise temperature from cold to hot (J) + Real64 CapacityRatio; + Real64 MinCapacityRate; + Real64 HXCapacityRate; + Real64 DrainCapacityRate; + Real64 NTU; + Real64 ExpVal; + Real64 AvailableFraction; int NumWaterEquipment; int MaxIterationsErrorIndex; // recurring error index Array1D_int WaterEquipment; @@ -223,7 +230,8 @@ namespace WaterUse { MainsVolFlowRate(0.0), TankVolFlowRate(0.0), ColdVolFlowRate(0.0), HotVolFlowRate(0.0), TotalVolFlowRate(0.0), DrainVolFlowRate(0.0), PeakMassFlowRate(0.0), ColdTempSchedule(0), HotTempSchedule(0), MainsTemp(0.0), TankTemp(0.0), ColdSupplyTemp(0.0), ColdTemp(0.0), HotTemp(0.0), DrainTemp(0.0), RecoveryTemp(0.0), ReturnTemp(0.0), WasteTemp(0.0), TempError(0.0), MainsVolume(0.0), TankVolume(0.0), - ColdVolume(0.0), HotVolume(0.0), TotalVolume(0.0), Power(0.0), Energy(0.0), NumWaterEquipment(0), MaxIterationsErrorIndex(0), + ColdVolume(0.0), HotVolume(0.0), TotalVolume(0.0), Power(0.0), Energy(0.0), CapacityRatio(0.0), MinCapacityRate(0.0), + HXCapacityRate(0.0), DrainCapacityRate(0.0), NTU(0.0), ExpVal(0.0), AvailableFraction(0.0), NumWaterEquipment(0), MaxIterationsErrorIndex(0), PlantLoopNum(0), PlantLoopSide(0), PlantLoopBranchNum(0), PlantLoopCompNum(0) { } From 835d49cd4d1e78b61f270d5981a7edbf7930ec08 Mon Sep 17 00:00:00 2001 From: Li Date: Tue, 15 Oct 2019 21:15:30 -0600 Subject: [PATCH 08/51] step-11: move SetupOutputVariables into a function --- src/EnergyPlus/WaterUse.cc | 856 +++++++++++++++++++------------------ src/EnergyPlus/WaterUse.hh | 2 + 2 files changed, 439 insertions(+), 419 deletions(-) diff --git a/src/EnergyPlus/WaterUse.cc b/src/EnergyPlus/WaterUse.cc index 4566b7fd056..f6203e078c9 100644 --- a/src/EnergyPlus/WaterUse.cc +++ b/src/EnergyPlus/WaterUse.cc @@ -147,6 +147,7 @@ namespace WaterUse { // FLOW: if (GetWaterUseInputFlag) { GetWaterUseInput(); + SetupOutputVars(); GetWaterUseInputFlag = false; } @@ -225,8 +226,7 @@ namespace WaterUse { } // WaterConnNum } - void SimulateWaterUseConnection( - int EP_UNUSED(EquipTypeNum), std::string &CompName, int &CompIndex, bool InitLoopEquip, bool FirstHVACIteration) + void SimulateWaterUseConnection(int EP_UNUSED(EquipTypeNum), std::string &CompName, int &CompIndex, bool InitLoopEquip, bool FirstHVACIteration) { // SUBROUTINE INFORMATION: @@ -254,6 +254,7 @@ namespace WaterUse { // FLOW: if (GetWaterUseInputFlag) { GetWaterUseInput(); + SetupOutputVars(); GetWaterUseInputFlag = false; } @@ -271,8 +272,8 @@ namespace WaterUse { } if (CheckEquipName(WaterConnNum)) { if (CompName != WaterConnections(WaterConnNum).Name) { - ShowFatalError("SimulateWaterUseConnection: Invalid CompIndex passed=" + General::TrimSigDigits(WaterConnNum) + ", Unit name=" + CompName + - ", stored Unit Name for that index=" + WaterConnections(WaterConnNum).Name); + ShowFatalError("SimulateWaterUseConnection: Invalid CompIndex passed=" + General::TrimSigDigits(WaterConnNum) + + ", Unit name=" + CompName + ", stored Unit Name for that index=" + WaterConnections(WaterConnNum).Name); } CheckEquipName(WaterConnNum) = false; } @@ -347,9 +348,9 @@ namespace WaterUse { // SUBROUTINE LOCAL VARIABLE DECLARATIONS: bool ErrorsFound(false); // Set to true if errors in input, fatal at end of routine - int IOStatus; // Used in GetObjectItem - int NumAlphas; // Number of Alphas for each GetObjectItem call - int NumNumbers; // Number of Numbers for each GetObjectItem call + int IOStatus; // Used in GetObjectItem + int NumAlphas; // Number of Alphas for each GetObjectItem call + int NumNumbers; // Number of Numbers for each GetObjectItem call // unused1208 INTEGER :: NumArgs int WaterEquipNum; int WaterConnNum; @@ -485,28 +486,28 @@ namespace WaterUse { if ((!DataIPShortCuts::lAlphaFieldBlanks(2)) || (!DataIPShortCuts::lAlphaFieldBlanks(3))) { WaterConnections(WaterConnNum).InletNode = NodeInputManager::GetOnlySingleNode(DataIPShortCuts::cAlphaArgs(2), - ErrorsFound, - DataIPShortCuts::cCurrentModuleObject, - DataIPShortCuts::cAlphaArgs(1), - DataLoopNode::NodeType_Water, - DataLoopNode::NodeConnectionType_Inlet, - 1, - DataLoopNode::ObjectIsNotParent); + ErrorsFound, + DataIPShortCuts::cCurrentModuleObject, + DataIPShortCuts::cAlphaArgs(1), + DataLoopNode::NodeType_Water, + DataLoopNode::NodeConnectionType_Inlet, + 1, + DataLoopNode::ObjectIsNotParent); WaterConnections(WaterConnNum).OutletNode = NodeInputManager::GetOnlySingleNode(DataIPShortCuts::cAlphaArgs(3), - ErrorsFound, - DataIPShortCuts::cCurrentModuleObject, - DataIPShortCuts::cAlphaArgs(1), - DataLoopNode::NodeType_Water, - DataLoopNode::NodeConnectionType_Outlet, - 1, - DataLoopNode::ObjectIsNotParent); + ErrorsFound, + DataIPShortCuts::cCurrentModuleObject, + DataIPShortCuts::cAlphaArgs(1), + DataLoopNode::NodeType_Water, + DataLoopNode::NodeConnectionType_Outlet, + 1, + DataLoopNode::ObjectIsNotParent); // Check plant connections BranchNodeConnections::TestCompSet(DataIPShortCuts::cCurrentModuleObject, - DataIPShortCuts::cAlphaArgs(1), - DataIPShortCuts::cAlphaArgs(2), - DataIPShortCuts::cAlphaArgs(3), - "DHW Nodes"); + DataIPShortCuts::cAlphaArgs(1), + DataIPShortCuts::cAlphaArgs(2), + DataIPShortCuts::cAlphaArgs(3), + "DHW Nodes"); } else { // If no plant nodes are connected, simulate in stand-alone mode. WaterConnections(WaterConnNum).StandAlone = true; @@ -514,20 +515,20 @@ namespace WaterUse { if (!DataIPShortCuts::lAlphaFieldBlanks(4)) { WaterManager::SetupTankDemandComponent(WaterConnections(WaterConnNum).Name, - DataIPShortCuts::cCurrentModuleObject, - DataIPShortCuts::cAlphaArgs(4), - ErrorsFound, - WaterConnections(WaterConnNum).SupplyTankNum, - WaterConnections(WaterConnNum).TankDemandID); + DataIPShortCuts::cCurrentModuleObject, + DataIPShortCuts::cAlphaArgs(4), + ErrorsFound, + WaterConnections(WaterConnNum).SupplyTankNum, + WaterConnections(WaterConnNum).TankDemandID); } if (!DataIPShortCuts::lAlphaFieldBlanks(5)) { WaterManager::SetupTankSupplyComponent(WaterConnections(WaterConnNum).Name, - DataIPShortCuts::cCurrentModuleObject, - DataIPShortCuts::cAlphaArgs(5), - ErrorsFound, - WaterConnections(WaterConnNum).RecoveryTankNum, - WaterConnections(WaterConnNum).TankSupplyID); + DataIPShortCuts::cCurrentModuleObject, + DataIPShortCuts::cAlphaArgs(5), + ErrorsFound, + WaterConnections(WaterConnNum).RecoveryTankNum, + WaterConnections(WaterConnNum).TankSupplyID); } if (!DataIPShortCuts::lAlphaFieldBlanks(6)) { @@ -601,8 +602,7 @@ namespace WaterUse { } else { if (WaterEquipment(WaterEquipNum).Connections > 0) { ShowSevereError(DataIPShortCuts::cCurrentModuleObject + " = " + DataIPShortCuts::cAlphaArgs(1) + - ": WaterUse:Equipment = " + - DataIPShortCuts::cAlphaArgs(AlphaNum) + + ": WaterUse:Equipment = " + DataIPShortCuts::cAlphaArgs(AlphaNum) + " is already referenced by another object."); ErrorsFound = true; } else { @@ -638,397 +638,423 @@ namespace WaterUse { if (WaterEquipment(thisWaterEquipNum).Zone > 0) { WaterConnections(WaterConnNum).PeakMassFlowRate += WaterEquipment(thisWaterEquipNum).PeakVolFlowRate * Psychrometrics::RhoH2O(DataGlobals::InitConvTemp) * - DataHeatBalance::Zone(WaterEquipment(thisWaterEquipNum).Zone).Multiplier * DataHeatBalance::Zone(WaterEquipment(thisWaterEquipNum).Zone).ListMultiplier; + DataHeatBalance::Zone(WaterEquipment(thisWaterEquipNum).Zone).Multiplier * + DataHeatBalance::Zone(WaterEquipment(thisWaterEquipNum).Zone).ListMultiplier; } else { // can't have multipliers WaterConnections(WaterConnNum).PeakMassFlowRate += WaterEquipment(thisWaterEquipNum).PeakVolFlowRate * Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); } } PlantUtilities::RegisterPlantCompDesignFlow(WaterConnections(WaterConnNum).InletNode, - WaterConnections(WaterConnNum).PeakMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp)); + WaterConnections(WaterConnNum).PeakMassFlowRate / + Psychrometrics::RhoH2O(DataGlobals::InitConvTemp)); } } + + + + + + } + void SetupOutputVars() + { // Setup EQUIPMENT report variables (now that connections have been established) // CurrentModuleObject='WaterUse:Equipment' - for (WaterEquipNum = 1; WaterEquipNum <= modNumWaterEquipment; ++WaterEquipNum) { + int WaterEquipNum; + int WaterConnNum; - SetupOutputVariable("Water Use Equipment Hot Water Mass Flow Rate", - OutputProcessor::Unit::kg_s, - WaterEquipment(WaterEquipNum).HotMassFlowRate, - "System", - "Average", - WaterEquipment(WaterEquipNum).Name); - - SetupOutputVariable("Water Use Equipment Cold Water Mass Flow Rate", - OutputProcessor::Unit::kg_s, - WaterEquipment(WaterEquipNum).ColdMassFlowRate, - "System", - "Average", - WaterEquipment(WaterEquipNum).Name); - - SetupOutputVariable("Water Use Equipment Total Mass Flow Rate", - OutputProcessor::Unit::kg_s, - WaterEquipment(WaterEquipNum).TotalMassFlowRate, - "System", - "Average", - WaterEquipment(WaterEquipNum).Name); - - SetupOutputVariable("Water Use Equipment Hot Water Volume Flow Rate", - OutputProcessor::Unit::m3_s, - WaterEquipment(WaterEquipNum).HotVolFlowRate, - "System", - "Average", - WaterEquipment(WaterEquipNum).Name); - - SetupOutputVariable("Water Use Equipment Cold Water Volume Flow Rate", - OutputProcessor::Unit::m3_s, - WaterEquipment(WaterEquipNum).ColdVolFlowRate, - "System", - "Average", - WaterEquipment(WaterEquipNum).Name); - - SetupOutputVariable("Water Use Equipment Total Volume Flow Rate", - OutputProcessor::Unit::m3_s, - WaterEquipment(WaterEquipNum).TotalVolFlowRate, - "System", - "Average", - WaterEquipment(WaterEquipNum).Name); - - SetupOutputVariable("Water Use Equipment Hot Water Volume", - OutputProcessor::Unit::m3, - WaterEquipment(WaterEquipNum).HotVolume, - "System", - "Sum", - WaterEquipment(WaterEquipNum).Name); - - SetupOutputVariable("Water Use Equipment Cold Water Volume", - OutputProcessor::Unit::m3, - WaterEquipment(WaterEquipNum).ColdVolume, - "System", - "Sum", - WaterEquipment(WaterEquipNum).Name); - - SetupOutputVariable("Water Use Equipment Total Volume", - OutputProcessor::Unit::m3, - WaterEquipment(WaterEquipNum).TotalVolume, - "System", - "Sum", - WaterEquipment(WaterEquipNum).Name, - _, - "Water", - "WATERSYSTEMS", - WaterEquipment(WaterEquipNum).EndUseSubcatName, - "Plant"); - SetupOutputVariable("Water Use Equipment Mains Water Volume", - OutputProcessor::Unit::m3, - WaterEquipment(WaterEquipNum).TotalVolume, - "System", - "Sum", - WaterEquipment(WaterEquipNum).Name, - _, - "MainsWater", - "WATERSYSTEMS", - WaterEquipment(WaterEquipNum).EndUseSubcatName, - "Plant"); - - SetupOutputVariable("Water Use Equipment Hot Water Temperature", - OutputProcessor::Unit::C, - WaterEquipment(WaterEquipNum).HotTemp, - "System", - "Average", - WaterEquipment(WaterEquipNum).Name); - - SetupOutputVariable("Water Use Equipment Cold Water Temperature", - OutputProcessor::Unit::C, - WaterEquipment(WaterEquipNum).ColdTemp, - "System", - "Average", - WaterEquipment(WaterEquipNum).Name); - - SetupOutputVariable("Water Use Equipment Target Water Temperature", - OutputProcessor::Unit::C, - WaterEquipment(WaterEquipNum).TargetTemp, - "System", - "Average", - WaterEquipment(WaterEquipNum).Name); - - SetupOutputVariable("Water Use Equipment Mixed Water Temperature", - OutputProcessor::Unit::C, - WaterEquipment(WaterEquipNum).MixedTemp, - "System", - "Average", - WaterEquipment(WaterEquipNum).Name); - - SetupOutputVariable("Water Use Equipment Drain Water Temperature", - OutputProcessor::Unit::C, - WaterEquipment(WaterEquipNum).DrainTemp, - "System", - "Average", - WaterEquipment(WaterEquipNum).Name); - - SetupOutputVariable("Water Use Equipment Heating Rate", - OutputProcessor::Unit::W, - WaterEquipment(WaterEquipNum).Power, - "System", - "Average", - WaterEquipment(WaterEquipNum).Name); + DataIPShortCuts::cCurrentModuleObject = "WaterUse:Equipment"; + modNumWaterEquipment = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); - if (WaterEquipment(WaterEquipNum).Connections == 0) { - SetupOutputVariable("Water Use Equipment Heating Energy", - OutputProcessor::Unit::J, - WaterEquipment(WaterEquipNum).Energy, + DataIPShortCuts::cCurrentModuleObject = "WaterUse:Connections"; + modNumWaterConnections = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); + + if (modNumWaterEquipment > 0) { + for (WaterEquipNum = 1; WaterEquipNum <= modNumWaterEquipment; ++WaterEquipNum) { + + SetupOutputVariable("Water Use Equipment Hot Water Mass Flow Rate", + OutputProcessor::Unit::kg_s, + WaterEquipment(WaterEquipNum).HotMassFlowRate, + "System", + "Average", + WaterEquipment(WaterEquipNum).Name); + + SetupOutputVariable("Water Use Equipment Cold Water Mass Flow Rate", + OutputProcessor::Unit::kg_s, + WaterEquipment(WaterEquipNum).ColdMassFlowRate, + "System", + "Average", + WaterEquipment(WaterEquipNum).Name); + + SetupOutputVariable("Water Use Equipment Total Mass Flow Rate", + OutputProcessor::Unit::kg_s, + WaterEquipment(WaterEquipNum).TotalMassFlowRate, + "System", + "Average", + WaterEquipment(WaterEquipNum).Name); + + SetupOutputVariable("Water Use Equipment Hot Water Volume Flow Rate", + OutputProcessor::Unit::m3_s, + WaterEquipment(WaterEquipNum).HotVolFlowRate, + "System", + "Average", + WaterEquipment(WaterEquipNum).Name); + + SetupOutputVariable("Water Use Equipment Cold Water Volume Flow Rate", + OutputProcessor::Unit::m3_s, + WaterEquipment(WaterEquipNum).ColdVolFlowRate, + "System", + "Average", + WaterEquipment(WaterEquipNum).Name); + + SetupOutputVariable("Water Use Equipment Total Volume Flow Rate", + OutputProcessor::Unit::m3_s, + WaterEquipment(WaterEquipNum).TotalVolFlowRate, + "System", + "Average", + WaterEquipment(WaterEquipNum).Name); + + SetupOutputVariable("Water Use Equipment Hot Water Volume", + OutputProcessor::Unit::m3, + WaterEquipment(WaterEquipNum).HotVolume, "System", "Sum", - WaterEquipment(WaterEquipNum).Name, - _, - "DISTRICTHEATING", - "WATERSYSTEMS", - WaterEquipment(WaterEquipNum).EndUseSubcatName, - "Plant"); + WaterEquipment(WaterEquipNum).Name); - } else if (WaterConnections(WaterEquipment(WaterEquipNum).Connections).StandAlone) { - SetupOutputVariable("Water Use Equipment Heating Energy", - OutputProcessor::Unit::J, - WaterEquipment(WaterEquipNum).Energy, + SetupOutputVariable("Water Use Equipment Cold Water Volume", + OutputProcessor::Unit::m3, + WaterEquipment(WaterEquipNum).ColdVolume, + "System", + "Sum", + WaterEquipment(WaterEquipNum).Name); + + SetupOutputVariable("Water Use Equipment Total Volume", + OutputProcessor::Unit::m3, + WaterEquipment(WaterEquipNum).TotalVolume, "System", "Sum", WaterEquipment(WaterEquipNum).Name, _, - "DISTRICTHEATING", + "Water", "WATERSYSTEMS", WaterEquipment(WaterEquipNum).EndUseSubcatName, "Plant"); - - } else { // The EQUIPMENT is coupled to a plant loop via a CONNECTIONS object - SetupOutputVariable("Water Use Equipment Heating Energy", - OutputProcessor::Unit::J, - WaterEquipment(WaterEquipNum).Energy, + SetupOutputVariable("Water Use Equipment Mains Water Volume", + OutputProcessor::Unit::m3, + WaterEquipment(WaterEquipNum).TotalVolume, "System", "Sum", WaterEquipment(WaterEquipNum).Name, _, - "ENERGYTRANSFER", + "MainsWater", "WATERSYSTEMS", WaterEquipment(WaterEquipNum).EndUseSubcatName, "Plant"); - } - if (WaterEquipment(WaterEquipNum).Zone > 0) { - SetupOutputVariable("Water Use Equipment Zone Sensible Heat Gain Rate", - OutputProcessor::Unit::W, - WaterEquipment(WaterEquipNum).SensibleRate, + SetupOutputVariable("Water Use Equipment Hot Water Temperature", + OutputProcessor::Unit::C, + WaterEquipment(WaterEquipNum).HotTemp, "System", "Average", WaterEquipment(WaterEquipNum).Name); - SetupOutputVariable("Water Use Equipment Zone Sensible Heat Gain Energy", - OutputProcessor::Unit::J, - WaterEquipment(WaterEquipNum).SensibleEnergy, + + SetupOutputVariable("Water Use Equipment Cold Water Temperature", + OutputProcessor::Unit::C, + WaterEquipment(WaterEquipNum).ColdTemp, "System", - "Sum", + "Average", WaterEquipment(WaterEquipNum).Name); - SetupOutputVariable("Water Use Equipment Zone Latent Gain Rate", - OutputProcessor::Unit::W, - WaterEquipment(WaterEquipNum).LatentRate, + SetupOutputVariable("Water Use Equipment Target Water Temperature", + OutputProcessor::Unit::C, + WaterEquipment(WaterEquipNum).TargetTemp, "System", "Average", WaterEquipment(WaterEquipNum).Name); - SetupOutputVariable("Water Use Equipment Zone Latent Gain Energy", - OutputProcessor::Unit::J, - WaterEquipment(WaterEquipNum).LatentEnergy, + + SetupOutputVariable("Water Use Equipment Mixed Water Temperature", + OutputProcessor::Unit::C, + WaterEquipment(WaterEquipNum).MixedTemp, "System", - "Sum", + "Average", WaterEquipment(WaterEquipNum).Name); - SetupOutputVariable("Water Use Equipment Zone Moisture Gain Mass Flow Rate", - OutputProcessor::Unit::kg_s, - WaterEquipment(WaterEquipNum).MoistureRate, + SetupOutputVariable("Water Use Equipment Drain Water Temperature", + OutputProcessor::Unit::C, + WaterEquipment(WaterEquipNum).DrainTemp, "System", "Average", WaterEquipment(WaterEquipNum).Name); - SetupOutputVariable("Water Use Equipment Zone Moisture Gain Mass", - OutputProcessor::Unit::kg, - WaterEquipment(WaterEquipNum).MoistureMass, + + SetupOutputVariable("Water Use Equipment Heating Rate", + OutputProcessor::Unit::W, + WaterEquipment(WaterEquipNum).Power, "System", - "Sum", + "Average", WaterEquipment(WaterEquipNum).Name); - SetupZoneInternalGain(WaterEquipment(WaterEquipNum).Zone, - "WaterUse:Equipment", - WaterEquipment(WaterEquipNum).Name, - DataHeatBalance::IntGainTypeOf_WaterUseEquipment, - WaterEquipment(WaterEquipNum).SensibleRateNoMultiplier, - _, - _, - WaterEquipment(WaterEquipNum).LatentRateNoMultiplier); - } + if (WaterEquipment(WaterEquipNum).Connections == 0) { + SetupOutputVariable("Water Use Equipment Heating Energy", + OutputProcessor::Unit::J, + WaterEquipment(WaterEquipNum).Energy, + "System", + "Sum", + WaterEquipment(WaterEquipNum).Name, + _, + "DISTRICTHEATING", + "WATERSYSTEMS", + WaterEquipment(WaterEquipNum).EndUseSubcatName, + "Plant"); + + } else if (WaterConnections(WaterEquipment(WaterEquipNum).Connections).StandAlone) { + SetupOutputVariable("Water Use Equipment Heating Energy", + OutputProcessor::Unit::J, + WaterEquipment(WaterEquipNum).Energy, + "System", + "Sum", + WaterEquipment(WaterEquipNum).Name, + _, + "DISTRICTHEATING", + "WATERSYSTEMS", + WaterEquipment(WaterEquipNum).EndUseSubcatName, + "Plant"); + + } else { // The EQUIPMENT is coupled to a plant loop via a CONNECTIONS object + SetupOutputVariable("Water Use Equipment Heating Energy", + OutputProcessor::Unit::J, + WaterEquipment(WaterEquipNum).Energy, + "System", + "Sum", + WaterEquipment(WaterEquipNum).Name, + _, + "ENERGYTRANSFER", + "WATERSYSTEMS", + WaterEquipment(WaterEquipNum).EndUseSubcatName, + "Plant"); + } - } // WaterEquipNum + if (WaterEquipment(WaterEquipNum).Zone > 0) { + SetupOutputVariable("Water Use Equipment Zone Sensible Heat Gain Rate", + OutputProcessor::Unit::W, + WaterEquipment(WaterEquipNum).SensibleRate, + "System", + "Average", + WaterEquipment(WaterEquipNum).Name); + SetupOutputVariable("Water Use Equipment Zone Sensible Heat Gain Energy", + OutputProcessor::Unit::J, + WaterEquipment(WaterEquipNum).SensibleEnergy, + "System", + "Sum", + WaterEquipment(WaterEquipNum).Name); + + SetupOutputVariable("Water Use Equipment Zone Latent Gain Rate", + OutputProcessor::Unit::W, + WaterEquipment(WaterEquipNum).LatentRate, + "System", + "Average", + WaterEquipment(WaterEquipNum).Name); + SetupOutputVariable("Water Use Equipment Zone Latent Gain Energy", + OutputProcessor::Unit::J, + WaterEquipment(WaterEquipNum).LatentEnergy, + "System", + "Sum", + WaterEquipment(WaterEquipNum).Name); + + SetupOutputVariable("Water Use Equipment Zone Moisture Gain Mass Flow Rate", + OutputProcessor::Unit::kg_s, + WaterEquipment(WaterEquipNum).MoistureRate, + "System", + "Average", + WaterEquipment(WaterEquipNum).Name); + SetupOutputVariable("Water Use Equipment Zone Moisture Gain Mass", + OutputProcessor::Unit::kg, + WaterEquipment(WaterEquipNum).MoistureMass, + "System", + "Sum", + WaterEquipment(WaterEquipNum).Name); + SetupZoneInternalGain(WaterEquipment(WaterEquipNum).Zone, + "WaterUse:Equipment", + WaterEquipment(WaterEquipNum).Name, + DataHeatBalance::IntGainTypeOf_WaterUseEquipment, + WaterEquipment(WaterEquipNum).SensibleRateNoMultiplier, + _, + _, + WaterEquipment(WaterEquipNum).LatentRateNoMultiplier); + } + + } // WaterEquipNum + } else { + ShowFatalError("Errors found in setup OutputVariables in processing input for " + DataIPShortCuts::cCurrentModuleObject); + } // Setup CONNECTIONS report variables (don't put any on meters; they are metered at WATER USE EQUIPMENT level) // CurrentModuleObject='WaterUse:Connections' - for (WaterConnNum = 1; WaterConnNum <= modNumWaterConnections; ++WaterConnNum) { + if (modNumWaterConnections > 0) { + for (WaterConnNum = 1; WaterConnNum <= modNumWaterConnections; ++WaterConnNum) { + + SetupOutputVariable("Water Use Connections Hot Water Mass Flow Rate", + OutputProcessor::Unit::kg_s, + WaterConnections(WaterConnNum).HotMassFlowRate, + "System", + "Average", + WaterConnections(WaterConnNum).Name); + + SetupOutputVariable("Water Use Connections Cold Water Mass Flow Rate", + OutputProcessor::Unit::kg_s, + WaterConnections(WaterConnNum).ColdMassFlowRate, + "System", + "Average", + WaterConnections(WaterConnNum).Name); + + SetupOutputVariable("Water Use Connections Total Mass Flow Rate", + OutputProcessor::Unit::kg_s, + WaterConnections(WaterConnNum).TotalMassFlowRate, + "System", + "Average", + WaterConnections(WaterConnNum).Name); + + SetupOutputVariable("Water Use Connections Drain Water Mass Flow Rate", + OutputProcessor::Unit::kg_s, + WaterConnections(WaterConnNum).DrainMassFlowRate, + "System", + "Average", + WaterConnections(WaterConnNum).Name); + + SetupOutputVariable("Water Use Connections Heat Recovery Mass Flow Rate", + OutputProcessor::Unit::kg_s, + WaterConnections(WaterConnNum).RecoveryMassFlowRate, + "System", + "Average", + WaterConnections(WaterConnNum).Name); + + SetupOutputVariable("Water Use Connections Hot Water Volume Flow Rate", + OutputProcessor::Unit::m3_s, + WaterConnections(WaterConnNum).HotVolFlowRate, + "System", + "Average", + WaterConnections(WaterConnNum).Name); + + SetupOutputVariable("Water Use Connections Cold Water Volume Flow Rate", + OutputProcessor::Unit::m3_s, + WaterConnections(WaterConnNum).ColdVolFlowRate, + "System", + "Average", + WaterConnections(WaterConnNum).Name); + + SetupOutputVariable("Water Use Connections Total Volume Flow Rate", + OutputProcessor::Unit::m3_s, + WaterConnections(WaterConnNum).TotalVolFlowRate, + "System", + "Average", + WaterConnections(WaterConnNum).Name); + + SetupOutputVariable("Water Use Connections Hot Water Volume", + OutputProcessor::Unit::m3, + WaterConnections(WaterConnNum).HotVolume, + "System", + "Sum", + WaterConnections(WaterConnNum).Name); + + SetupOutputVariable("Water Use Connections Cold Water Volume", + OutputProcessor::Unit::m3, + WaterConnections(WaterConnNum).ColdVolume, + "System", + "Sum", + WaterConnections(WaterConnNum).Name); + + SetupOutputVariable("Water Use Connections Total Volume", + OutputProcessor::Unit::m3, + WaterConnections(WaterConnNum).TotalVolume, + "System", + "Sum", + WaterConnections(WaterConnNum).Name); //, & + // ResourceTypeKey='Water', EndUseKey='DHW', EndUseSubKey=EndUseSubcategoryName, GroupKey='Plant') + // tHIS WAS double counting + + SetupOutputVariable("Water Use Connections Hot Water Temperature", + OutputProcessor::Unit::C, + WaterConnections(WaterConnNum).HotTemp, + "System", + "Average", + WaterConnections(WaterConnNum).Name); + + SetupOutputVariable("Water Use Connections Cold Water Temperature", + OutputProcessor::Unit::C, + WaterConnections(WaterConnNum).ColdTemp, + "System", + "Average", + WaterConnections(WaterConnNum).Name); - SetupOutputVariable("Water Use Connections Hot Water Mass Flow Rate", - OutputProcessor::Unit::kg_s, - WaterConnections(WaterConnNum).HotMassFlowRate, - "System", - "Average", - WaterConnections(WaterConnNum).Name); - - SetupOutputVariable("Water Use Connections Cold Water Mass Flow Rate", - OutputProcessor::Unit::kg_s, - WaterConnections(WaterConnNum).ColdMassFlowRate, - "System", - "Average", - WaterConnections(WaterConnNum).Name); - - SetupOutputVariable("Water Use Connections Total Mass Flow Rate", - OutputProcessor::Unit::kg_s, - WaterConnections(WaterConnNum).TotalMassFlowRate, - "System", - "Average", - WaterConnections(WaterConnNum).Name); - - SetupOutputVariable("Water Use Connections Drain Water Mass Flow Rate", - OutputProcessor::Unit::kg_s, - WaterConnections(WaterConnNum).DrainMassFlowRate, - "System", - "Average", - WaterConnections(WaterConnNum).Name); - - SetupOutputVariable("Water Use Connections Heat Recovery Mass Flow Rate", - OutputProcessor::Unit::kg_s, - WaterConnections(WaterConnNum).RecoveryMassFlowRate, - "System", - "Average", - WaterConnections(WaterConnNum).Name); - - SetupOutputVariable("Water Use Connections Hot Water Volume Flow Rate", - OutputProcessor::Unit::m3_s, - WaterConnections(WaterConnNum).HotVolFlowRate, - "System", - "Average", - WaterConnections(WaterConnNum).Name); - - SetupOutputVariable("Water Use Connections Cold Water Volume Flow Rate", - OutputProcessor::Unit::m3_s, - WaterConnections(WaterConnNum).ColdVolFlowRate, - "System", - "Average", - WaterConnections(WaterConnNum).Name); - - SetupOutputVariable("Water Use Connections Total Volume Flow Rate", - OutputProcessor::Unit::m3_s, - WaterConnections(WaterConnNum).TotalVolFlowRate, - "System", - "Average", - WaterConnections(WaterConnNum).Name); - - SetupOutputVariable("Water Use Connections Hot Water Volume", - OutputProcessor::Unit::m3, - WaterConnections(WaterConnNum).HotVolume, - "System", - "Sum", - WaterConnections(WaterConnNum).Name); - - SetupOutputVariable("Water Use Connections Cold Water Volume", - OutputProcessor::Unit::m3, - WaterConnections(WaterConnNum).ColdVolume, - "System", - "Sum", - WaterConnections(WaterConnNum).Name); - - SetupOutputVariable("Water Use Connections Total Volume", - OutputProcessor::Unit::m3, - WaterConnections(WaterConnNum).TotalVolume, - "System", - "Sum", - WaterConnections(WaterConnNum).Name); //, & - // ResourceTypeKey='Water', EndUseKey='DHW', EndUseSubKey=EndUseSubcategoryName, GroupKey='Plant') - // tHIS WAS double counting - - SetupOutputVariable("Water Use Connections Hot Water Temperature", - OutputProcessor::Unit::C, - WaterConnections(WaterConnNum).HotTemp, - "System", - "Average", - WaterConnections(WaterConnNum).Name); - - SetupOutputVariable("Water Use Connections Cold Water Temperature", - OutputProcessor::Unit::C, - WaterConnections(WaterConnNum).ColdTemp, - "System", - "Average", - WaterConnections(WaterConnNum).Name); - - SetupOutputVariable("Water Use Connections Drain Water Temperature", - OutputProcessor::Unit::C, - WaterConnections(WaterConnNum).DrainTemp, - "System", - "Average", - WaterConnections(WaterConnNum).Name); - - SetupOutputVariable("Water Use Connections Return Water Temperature", - OutputProcessor::Unit::C, - WaterConnections(WaterConnNum).ReturnTemp, - "System", - "Average", - WaterConnections(WaterConnNum).Name); - - SetupOutputVariable("Water Use Connections Waste Water Temperature", - OutputProcessor::Unit::C, - WaterConnections(WaterConnNum).WasteTemp, - "System", - "Average", - WaterConnections(WaterConnNum).Name); - - SetupOutputVariable("Water Use Connections Heat Recovery Water Temperature", - OutputProcessor::Unit::C, - WaterConnections(WaterConnNum).RecoveryTemp, - "System", - "Average", - WaterConnections(WaterConnNum).Name); - - SetupOutputVariable("Water Use Connections Heat Recovery Effectiveness", - OutputProcessor::Unit::None, - WaterConnections(WaterConnNum).Effectiveness, - "System", - "Average", - WaterConnections(WaterConnNum).Name); - - SetupOutputVariable("Water Use Connections Heat Recovery Rate", - OutputProcessor::Unit::W, - WaterConnections(WaterConnNum).RecoveryRate, - "System", - "Average", - WaterConnections(WaterConnNum).Name); - SetupOutputVariable("Water Use Connections Heat Recovery Energy", - OutputProcessor::Unit::J, - WaterConnections(WaterConnNum).RecoveryEnergy, - "System", - "Sum", - WaterConnections(WaterConnNum).Name); - // Does this go on a meter? - - // To do: Add report variable for starved flow when tank can't deliver? - - if (!WaterConnections(WaterConnNum).StandAlone) { - SetupOutputVariable("Water Use Connections Plant Hot Water Energy", + SetupOutputVariable("Water Use Connections Drain Water Temperature", + OutputProcessor::Unit::C, + WaterConnections(WaterConnNum).DrainTemp, + "System", + "Average", + WaterConnections(WaterConnNum).Name); + + SetupOutputVariable("Water Use Connections Return Water Temperature", + OutputProcessor::Unit::C, + WaterConnections(WaterConnNum).ReturnTemp, + "System", + "Average", + WaterConnections(WaterConnNum).Name); + + SetupOutputVariable("Water Use Connections Waste Water Temperature", + OutputProcessor::Unit::C, + WaterConnections(WaterConnNum).WasteTemp, + "System", + "Average", + WaterConnections(WaterConnNum).Name); + + SetupOutputVariable("Water Use Connections Heat Recovery Water Temperature", + OutputProcessor::Unit::C, + WaterConnections(WaterConnNum).RecoveryTemp, + "System", + "Average", + WaterConnections(WaterConnNum).Name); + + SetupOutputVariable("Water Use Connections Heat Recovery Effectiveness", + OutputProcessor::Unit::None, + WaterConnections(WaterConnNum).Effectiveness, + "System", + "Average", + WaterConnections(WaterConnNum).Name); + + SetupOutputVariable("Water Use Connections Heat Recovery Rate", + OutputProcessor::Unit::W, + WaterConnections(WaterConnNum).RecoveryRate, + "System", + "Average", + WaterConnections(WaterConnNum).Name); + SetupOutputVariable("Water Use Connections Heat Recovery Energy", OutputProcessor::Unit::J, - WaterConnections(WaterConnNum).Energy, + WaterConnections(WaterConnNum).RecoveryEnergy, "System", "Sum", - WaterConnections(WaterConnNum).Name, - _, - "PLANTLOOPHEATINGDEMAND", - "WATERSYSTEMS", - _, - "Plant"); - } + WaterConnections(WaterConnNum).Name); + // Does this go on a meter? + + // To do: Add report variable for starved flow when tank can't deliver? + + if (!WaterConnections(WaterConnNum).StandAlone) { + SetupOutputVariable("Water Use Connections Plant Hot Water Energy", + OutputProcessor::Unit::J, + WaterConnections(WaterConnNum).Energy, + "System", + "Sum", + WaterConnections(WaterConnNum).Name, + _, + "PLANTLOOPHEATINGDEMAND", + "WATERSYSTEMS", + _, + "Plant"); + } - } // WaterConnNum + } // WaterConnNum + } else { + ShowFatalError("Errors found in setup OutputVariables in processing input for " + DataIPShortCuts::cCurrentModuleObject); + } } void CalcEquipmentFlowRates(int WaterEquipNum) @@ -1043,7 +1069,6 @@ namespace WaterUse { // PURPOSE OF THIS SUBROUTINE: // Calculate desired hot and cold water flow rates - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int WaterConnNum; @@ -1083,7 +1108,8 @@ namespace WaterUse { WaterEquipment(WaterEquipNum).TotalVolFlowRate = WaterEquipment(WaterEquipNum).PeakVolFlowRate * ScheduleManager::GetCurrentScheduleValue(WaterEquipment(WaterEquipNum).FlowRateFracSchedule) * - DataHeatBalance::Zone(WaterEquipment(WaterEquipNum).Zone).Multiplier * DataHeatBalance::Zone(WaterEquipment(WaterEquipNum).Zone).ListMultiplier; + DataHeatBalance::Zone(WaterEquipment(WaterEquipNum).Zone).Multiplier * + DataHeatBalance::Zone(WaterEquipment(WaterEquipNum).Zone).ListMultiplier; } else { WaterEquipment(WaterEquipNum).TotalVolFlowRate = WaterEquipment(WaterEquipNum).PeakVolFlowRate * DataHeatBalance::Zone(WaterEquipment(WaterEquipNum).Zone).Multiplier * @@ -1152,7 +1178,6 @@ namespace WaterUse { // PURPOSE OF THIS SUBROUTINE: // Calculate drainwater temperature and heat and moisture gains to zone. - // Locals // SUBROUTINE ARGUMENT DEFINITIONS: @@ -1189,9 +1214,8 @@ namespace WaterUse { } else { WaterEquipment(WaterEquipNum).SensibleRate = ScheduleManager::GetCurrentScheduleValue(WaterEquipment(WaterEquipNum).SensibleFracSchedule) * - WaterEquipment(WaterEquipNum).TotalMassFlowRate * - Psychrometrics::CPHW(DataGlobals::InitConvTemp) * - (WaterEquipment(WaterEquipNum).MixedTemp - ZoneMAT); + WaterEquipment(WaterEquipNum).TotalMassFlowRate * Psychrometrics::CPHW(DataGlobals::InitConvTemp) * + (WaterEquipment(WaterEquipNum).MixedTemp - ZoneMAT); WaterEquipment(WaterEquipNum).SensibleEnergy = WaterEquipment(WaterEquipNum).SensibleRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; } @@ -1206,7 +1230,7 @@ namespace WaterUse { RhoAirDry = Psychrometrics::PsyRhoAirFnPbTdbW(DataEnvironment::OutBaroPress, ZoneMAT, 0.0); ZoneMassMax = - (ZoneHumRatSat - ZoneHumRat) * RhoAirDry * DataHeatBalance::Zone(ZoneNum).Volume; // Max water that can be evaporated to zone + (ZoneHumRatSat - ZoneHumRat) * RhoAirDry * DataHeatBalance::Zone(ZoneNum).Volume; // Max water that can be evaporated to zone FlowMassMax = WaterEquipment(WaterEquipNum).TotalMassFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; // Max water in flow MoistureMassMax = min(ZoneMassMax, FlowMassMax); @@ -1246,32 +1270,31 @@ namespace WaterUse { // MODIFIED Brent Griffith 2010, demand side update // RE-ENGINEERED na - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: bool MyOneTimeFlag(true); // one time flag !DSU Array1D_bool SetLoopIndexFlag; // get loop number flag !DSU bool errFlag; - if (MyOneTimeFlag) { // DSU + if (MyOneTimeFlag) { // DSU SetLoopIndexFlag.dimension(modNumWaterConnections, true); // DSU - MyOneTimeFlag = false; // DSU - } // DSU + MyOneTimeFlag = false; // DSU + } // DSU - if (SetLoopIndexFlag(WaterConnNum)) { // DSU + if (SetLoopIndexFlag(WaterConnNum)) { // DSU if (allocated(DataPlant::PlantLoop) && !WaterConnections(WaterConnNum).StandAlone) { // DSU errFlag = false; PlantUtilities::ScanPlantLoopsForObject(WaterConnections(WaterConnNum).Name, - DataPlant::TypeOf_WaterUseConnection, - WaterConnections(WaterConnNum).PlantLoopNum, - WaterConnections(WaterConnNum).PlantLoopSide, - WaterConnections(WaterConnNum).PlantLoopBranchNum, - WaterConnections(WaterConnNum).PlantLoopCompNum, - errFlag, - _, - _, - _, - _, - _); // DSU | DSU | DSU | DSU | DSU | DSU | DSU + DataPlant::TypeOf_WaterUseConnection, + WaterConnections(WaterConnNum).PlantLoopNum, + WaterConnections(WaterConnNum).PlantLoopSide, + WaterConnections(WaterConnNum).PlantLoopBranchNum, + WaterConnections(WaterConnNum).PlantLoopCompNum, + errFlag, + _, + _, + _, + _, + _); // DSU | DSU | DSU | DSU | DSU | DSU | DSU if (errFlag) { // DSU ShowFatalError("InitConnections: Program terminated due to previous condition(s)."); // DSU } // DSU @@ -1309,13 +1332,13 @@ namespace WaterUse { // Clear node initial conditions if (WaterConnections(WaterConnNum).InletNode > 0 && WaterConnections(WaterConnNum).OutletNode > 0) { PlantUtilities::InitComponentNodes(0.0, - WaterConnections(WaterConnNum).PeakMassFlowRate, - WaterConnections(WaterConnNum).InletNode, - WaterConnections(WaterConnNum).OutletNode, - WaterConnections(WaterConnNum).PlantLoopNum, - WaterConnections(WaterConnNum).PlantLoopSide, - WaterConnections(WaterConnNum).PlantLoopBranchNum, - WaterConnections(WaterConnNum).PlantLoopCompNum); + WaterConnections(WaterConnNum).PeakMassFlowRate, + WaterConnections(WaterConnNum).InletNode, + WaterConnections(WaterConnNum).OutletNode, + WaterConnections(WaterConnNum).PlantLoopNum, + WaterConnections(WaterConnNum).PlantLoopSide, + WaterConnections(WaterConnNum).PlantLoopBranchNum, + WaterConnections(WaterConnNum).PlantLoopCompNum); WaterConnections(WaterConnNum).ReturnTemp = DataLoopNode::Node(WaterConnections(WaterConnNum).InletNode).Temp; } @@ -1349,7 +1372,6 @@ namespace WaterUse { // PURPOSE OF THIS SUBROUTINE: // Calculate summed values for WATER USE CONNECTIONS (to prepare to request flow from plant, and for reporting). - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int WaterEquipNum; int Loop; @@ -1382,20 +1404,20 @@ namespace WaterUse { PlantUtilities::SetComponentFlowRate(WaterConnections(WaterConnNum).HotMassFlowRate, WaterConnections(WaterConnNum).InletNode, WaterConnections(WaterConnNum).OutletNode, - LoopNum, - LoopSideNum, - WaterConnections(WaterConnNum).PlantLoopBranchNum, - WaterConnections(WaterConnNum).PlantLoopCompNum); + LoopNum, + LoopSideNum, + WaterConnections(WaterConnNum).PlantLoopBranchNum, + WaterConnections(WaterConnNum).PlantLoopCompNum); } else { - + PlantUtilities::SetComponentFlowRate(WaterConnections(WaterConnNum).HotMassFlowRate, WaterConnections(WaterConnNum).InletNode, WaterConnections(WaterConnNum).OutletNode, - LoopNum, - LoopSideNum, - WaterConnections(WaterConnNum).PlantLoopBranchNum, - WaterConnections(WaterConnNum).PlantLoopCompNum); + LoopNum, + LoopSideNum, + WaterConnections(WaterConnNum).PlantLoopBranchNum, + WaterConnections(WaterConnNum).PlantLoopCompNum); // DSU3 Node(InletNode)%MassFlowRate = MIN(WaterConnections(WaterConnNum)%HotMassFlowRate, Node(InletNode)%MassFlowRateMaxAvail) // DSU3 Node(InletNode)%MassFlowRate = MAX(WaterConnections(WaterConnNum)%HotMassFlowRate, Node(InletNode)%MassFlowRateMinAvail) // readjust if more than actual available mass flow rate determined by the demand side manager @@ -1404,7 +1426,7 @@ namespace WaterUse { // DSU3 Node(InletNode)%MassFlowRate = Node(InletNode)%MassFlowRateMaxAvail - WaterConnections(WaterConnNum).AvailableFraction = + WaterConnections(WaterConnNum).AvailableFraction = WaterConnections(WaterConnNum).HotMassFlowRate / WaterConnections(WaterConnNum).HotMassFlowRate; // DSU3 WaterConnections(WaterConnNum)%HotMassFlowRate = Node(InletNode)%MassFlowRateMaxAvail @@ -1446,8 +1468,8 @@ namespace WaterUse { // Check if cold flow rate should be starved by restricted flow from tank // Currently, the tank flow is not really starved--water continues to flow at the tank water temperature // But the user can see the error by comparing report variables for TankVolFlowRate < ColdVolFlowRate - WaterConnections(WaterConnNum).TankVolFlowRate = DataWater::WaterStorage(WaterConnections(WaterConnNum).SupplyTankNum) - .VdotAvailDemand(WaterConnections(WaterConnNum).TankDemandID); + WaterConnections(WaterConnNum).TankVolFlowRate = + DataWater::WaterStorage(WaterConnections(WaterConnNum).SupplyTankNum).VdotAvailDemand(WaterConnections(WaterConnNum).TankDemandID); WaterConnections(WaterConnNum).TankMassFlowRate = WaterConnections(WaterConnNum).TankVolFlowRate * Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); } @@ -1465,7 +1487,6 @@ namespace WaterUse { // PURPOSE OF THIS SUBROUTINE: // Calculate - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int WaterEquipNum; int Loop; @@ -1504,8 +1525,8 @@ namespace WaterUse { // RE-ENGINEERED na // PURPOSE OF THIS SUBROUTINE: - // Calculate drainwater heat recovery - + // Calculate drainwater heat recovery + // FLOW: if (!WaterConnections(WaterConnNum).HeatRecovery) { WaterConnections(WaterConnNum).RecoveryTemp = WaterConnections(WaterConnNum).ColdSupplyTemp; @@ -1663,7 +1684,6 @@ namespace WaterUse { // PURPOSE OF THIS SUBROUTINE: // Calculates report variables for stand alone water use - // Locals // SUBROUTINE ARGUMENT DEFINITIONS: @@ -1822,8 +1842,6 @@ namespace WaterUse { WaterEquipment(WaterEquipNum).LatentRate / (DataHeatBalance::Zone(ZoneNum).Multiplier * DataHeatBalance::Zone(ZoneNum).ListMultiplier); // CR7401, back out multipliers } - - } } // namespace WaterUse diff --git a/src/EnergyPlus/WaterUse.hh b/src/EnergyPlus/WaterUse.hh index 0f4ff3a057e..d1e6fdfea2f 100644 --- a/src/EnergyPlus/WaterUse.hh +++ b/src/EnergyPlus/WaterUse.hh @@ -251,6 +251,8 @@ namespace WaterUse { int EquipTypeNum, std::string &CompName, int &CompIndex, bool InitLoopEquip, bool FirstHVACIteration); void GetWaterUseInput(); + + void SetupOutputVars(); void CalcEquipmentFlowRates(int WaterEquipNum); From 43e603663d9ce8ddc0cc1e3dcb350ee05bd75b03 Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Mon, 21 Oct 2019 11:12:13 -0600 Subject: [PATCH 09/51] cleanup comments --- src/EnergyPlus/FuelCellElectricGenerator.cc | 809 +----------------- src/EnergyPlus/FuelCellElectricGenerator.hh | 21 - .../unit/FuelCellElectricGenerator.unit.cc | 4 +- 3 files changed, 6 insertions(+), 828 deletions(-) diff --git a/src/EnergyPlus/FuelCellElectricGenerator.cc b/src/EnergyPlus/FuelCellElectricGenerator.cc index 02cb2be22d7..422b0910b38 100644 --- a/src/EnergyPlus/FuelCellElectricGenerator.cc +++ b/src/EnergyPlus/FuelCellElectricGenerator.cc @@ -123,7 +123,6 @@ namespace FuelCellElectricGenerator { using namespace GeneratorFuelSupply; using namespace GeneratorDynamicsManager; - // MODULE VARIABLE DECLARATIONS: bool GetFuelCellInput(true); // When TRUE, calls subroutine to read input file. Array1D_bool CheckEquipName; @@ -143,10 +142,8 @@ namespace FuelCellElectricGenerator { // gets the input for the models, initializes simulation variables, call // the appropriate model and sets up reporting variables. - // Using/Aliasing using General::TrimSigDigits; - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int GenNum; // Generator number counter // Get Generator data from input file @@ -183,12 +180,6 @@ namespace FuelCellElectricGenerator { UpdateFuelCellGeneratorRecords(RunFlag, GenNum); } - // End FuelCell Generator Module Driver Subroutines - //****************************************************************************** - - // Beginning of FuelCell Generator Module Get Input subroutines - //****************************************************************************** - void GetFuelCellGeneratorInput() { // SUBROUTINE INFORMATION: @@ -202,7 +193,6 @@ namespace FuelCellElectricGenerator { // METHODOLOGY EMPLOYED: // EnergyPlus input processor - // Using/Aliasing using namespace DataGenerators; using namespace DataIPShortCuts; // Data for field names, blank numerics using BranchNodeConnections::TestCompSet; @@ -215,7 +205,6 @@ namespace FuelCellElectricGenerator { using PlantUtilities::RegisterPlantCompDesignFlow; using ScheduleManager::GetScheduleIndex; - // LOCAL VARIABLES int GeneratorNum; // Generator counter int NumAlphas; // Number of elements in the alpha array int NumNums; // Number of elements in the numeric array @@ -226,18 +215,15 @@ namespace FuelCellElectricGenerator { static bool ErrorsFound(false); // error flag int NumFuelCellPMs; // number of power subsystems in input file int NumFuelCellAirSups; // number of air supply subsystems in input file - // INTEGER :: NumFuelCellFuelSups ! number of fuel supply subsystems in input file int NumFCWaterSups; // number of water supply subsystems in input file int NumFuelCellAuxilHeaters; int NumFCExhaustGasHXs; int NumFCElecStorageUnits; // number of electrical storage objects in input file - // INTEGER :: NumBatteries !number of Manwell and McGowan battery data objects int NumFCPowerCondUnits; // number of power conditioning units (inverter) int NumFCStackCoolers; // number of stack coolers. int NumAirConstit; // number of gas constituents in air int FCPMNum; // loop counter over power subsystems int FCAirSupNum; // loop counter over air supply subsystems - // INTEGER :: FCFuelSupNum !loop counter over fuel supply subsystems int ConstitNum; // loop counter for consituents int FCWaterSupNum; // loop counter over water supply subsystems int FCHXNum; // loop counter for heat exchangers @@ -255,9 +241,7 @@ namespace FuelCellElectricGenerator { int thisGasID; int FuelSupNum; - // Autodesk:Uninit Initialize variables used uninitialized - thisFuelCell = 0; // Autodesk:Uninit Force default initialization: Will cause intentional failure if used as a FuelCell array index: Issue may - // be fixed by changes in EP 8.2 but that wasn't documented here (initialization is harmless so left in for now) + thisFuelCell = 0; // execution if (MyOneTimeFlag) { @@ -297,7 +281,7 @@ namespace FuelCellElectricGenerator { cCurrentModuleObject = "Generator:FuelCell:PowerModule"; NumFuelCellPMs = inputProcessor->getNumObjectsFound(cCurrentModuleObject); - if (NumFuelCellPMs <= 0) { // Autodesk:Uninit Allowing code to continue past this condition used thisFuelCell uninitialized in EP 8.0 + if (NumFuelCellPMs <= 0) { ShowSevereError("No " + cCurrentModuleObject + " equipment specified in input file"); ErrorsFound = true; } @@ -1389,11 +1373,6 @@ namespace FuelCellElectricGenerator { } } - // End of Get Input subroutines for the FuelCell Generator Module - - // Beginning of Generator model Subroutines - // ***************************************************************************** - void CalcFuelCellGeneratorModel(int const GeneratorNum, // Generator number bool const RunFlag, // TRUE when Generator operating Real64 const MyLoad, // Generator demand @@ -1414,7 +1393,6 @@ namespace FuelCellElectricGenerator { // REFERENCES: IEA/ECBCS Annex 42.... - // Using/Aliasing using CurveManager::CurveValue; using DataEnvironment::WaterMainsTemp; using DataHeatBalFanSys::ZT; @@ -1423,15 +1401,6 @@ namespace FuelCellElectricGenerator { using General::SolveRoot; using ScheduleManager::GetCurrentScheduleValue; - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: - - // DERIVED TYPE DEFINITIONS - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: static Real64 PpcuLosses; // losses in inverter [W] Real64 Pel; // DC power generated in Fuel Cell Power Module Real64 Pdemand; @@ -1467,11 +1436,7 @@ namespace FuelCellElectricGenerator { int MaxIter; // iteration control for SolveRoot int SolverFlag; // feed back flag from SolveRoot Array1D Par(3); // parameters passed in to SolveRoot - // Par(1) = generator number index in structure - // Par(2) = targeted enthalpy (W) - // Par(3) = molar flow rate of product gases (kmol/s) Real64 tmpTprodGas; - // unused REAL(r64) :: LHV !Lower Heating Value bool ConstrainedStorage; // contrained overall elect because of storage Real64 PgridExtra; // extra electric power that should go into storage but can't Real64 Pstorage; // power into storage (+), power from storage (-) @@ -1479,7 +1444,7 @@ namespace FuelCellElectricGenerator { Real64 PoutofInverter; // power out of inverter after losses and including storage Real64 PacAncillariesTotal; // total AC ancillaries - //! begin controls block to be moved out to GeneratorDynamics module + // begin controls block to be moved out to GeneratorDynamics module // If no loop demand or Generator OFF, return if (!RunFlag) { @@ -2027,27 +1992,8 @@ namespace FuelCellElectricGenerator { // PURPOSE OF THIS SUBROUTINE: // manage controls and calculations related to electrical storage in FuelCell model - // METHODOLOGY EMPLOYED: - - // REFERENCES: - // na - - // Using/Aliasing using DataHVACGlobals::TimeStepSys; - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS: - // na - - // DERIVED TYPE DEFINITIONS: - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: Real64 tmpPdraw; // power draw from storage, working var Real64 tmpPcharge; // power charge to storage, working var bool drawing; // true if drawing power @@ -2217,30 +2163,8 @@ namespace FuelCellElectricGenerator { // Calculates residual function for product gas enthalpy // calls procedure FigureProductGasesEnthalpy - // REFERENCES: - // na - - // USE STATEMENTS: - // na - - // Return value Real64 Residuum; // F(x) - // Argument array dimensioning - - // Locals - // FUNCTION ARGUMENT DEFINITIONS: - // par(2) = Desired Enthalpy - // FUNCTION PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS: - // na - - // DERIVED TYPE DEFINITIONS: - // na - - // FUNCTION LOCAL VARIABLE DECLARATIONS: int GeneratorNum; Real64 thisHmolalProdGases; Real64 desiredHprodGases; @@ -2279,22 +2203,6 @@ namespace FuelCellElectricGenerator { // REFERENCES: // NIST Webbook on gas phase thermochemistry - // USE STATEMENTS: - // na - - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS: - // na - - // DERIVED TYPE DEFINITIONS: - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: Real64 tempCp; int thisConstit; // loop index int gasID; @@ -2378,22 +2286,6 @@ namespace FuelCellElectricGenerator { // REFERENCES: // NIST Webbook on gas phase thermochemistry - // USE STATEMENTS: - // na - - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS: - // na - - // DERIVED TYPE DEFINITIONS: - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: Real64 tempHair; Real64 HairI; int thisConstit; // loop index @@ -2484,22 +2376,6 @@ namespace FuelCellElectricGenerator { // REFERENCES: // NIST Webbook on gas phase thermochemistry - // USE STATEMENTS: - // na - - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS: - // na - - // DERIVED TYPE DEFINITIONS: - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: Real64 tempCp; int thisConstit; // loop index int gasID; // look up into Gas structure @@ -2580,22 +2456,6 @@ namespace FuelCellElectricGenerator { // REFERENCES: // NIST Webbook on gas phase thermochemistry - // USE STATEMENTS: - // na - - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS: - // na - - // DERIVED TYPE DEFINITIONS: - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: Real64 tempHfuel; Real64 HfuelI; int thisConstit; // loop index @@ -2686,22 +2546,6 @@ namespace FuelCellElectricGenerator { // REFERENCES: // NIST Webbook on gas phase thermochemistry - // USE STATEMENTS: - // na - - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS: - // na - - // DERIVED TYPE DEFINITIONS: - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: Real64 tempHprodGases; int thisConstit; // loop index int gasID; // look up into Gas structure @@ -2779,44 +2623,6 @@ namespace FuelCellElectricGenerator { // MODIFIED na // RE-ENGINEERED na - // PURPOSE OF THIS SUBROUTINE: - // - - // METHODOLOGY EMPLOYED: - // - - // REFERENCES: - // na - - // USE STATEMENTS: - // na - - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - // na - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS: - // na - - // DERIVED TYPE DEFINITIONS: - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - // na - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS: - // na - - // DERIVED TYPE DEFINITIONS: - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: Real64 tempCp; int thisConstit; // loop index int gasID; // look up into Gas structure @@ -2887,44 +2693,6 @@ namespace FuelCellElectricGenerator { // MODIFIED na // RE-ENGINEERED na - // PURPOSE OF THIS SUBROUTINE: - // - - // METHODOLOGY EMPLOYED: - // - - // REFERENCES: - // na - - // USE STATEMENTS: - // na - - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - // na - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS: - // na - - // DERIVED TYPE DEFINITIONS: - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - // na - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS: - // na - - // DERIVED TYPE DEFINITIONS: - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: Real64 tempCp; int thisConstit; // loop index int gasID; // look up into Gas structure @@ -2983,114 +2751,6 @@ namespace FuelCellElectricGenerator { Cp = tempCp; } - void FigureHXleavingGasHeatCap(int const GeneratorNum, // ID of generator FuelCell data structure - Real64 const FluidTemp, // degree C - Real64 &Cp // (J/mol*K) - ) - { - - // SUBROUTINE INFORMATION: - // AUTHOR Brent Griffith - // DATE WRITTEN Aug. 2005 - // MODIFIED na - // RE-ENGINEERED na - - // PURPOSE OF THIS SUBROUTINE: - // - - // METHODOLOGY EMPLOYED: - // - - // REFERENCES: - // na - - // USE STATEMENTS: - // na - - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - // na - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS: - // na - - // DERIVED TYPE DEFINITIONS: - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - // na - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS: - // na - - // DERIVED TYPE DEFINITIONS: - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - Real64 tempCp; - int thisConstit; // loop index - int gasID; // look up into Gas structure - Real64 A; // shomate coeff - Real64 B; // shomate coeff - Real64 C; // shomate coeff - Real64 D; // shomate coeff - Real64 E; // shomate coeff - Real64 A1; // NASA poly coeff - Real64 A2; // NASA poly coeff - Real64 A3; // NASA poly coeff - Real64 A4; // NASA poly coeff - Real64 A5; // NASA poly coeff - - Real64 const Tsho = (FluidTemp + KelvinConv) / 1000.0; // temp for Shomate eq in (Kelvin/1000) - Real64 const Tkel = (FluidTemp + KelvinConv); // temp for NASA eq. in Kelvin - - // loop through fuel constituents and sum up Cp - - tempCp = 0.0; - - Real64 const pow_2_Tsho(pow_2(Tsho)); - Real64 const pow_3_Tsho(pow_3(Tsho)); - Real64 const pow_2_Tkel(pow_2(Tkel)); - Real64 const pow_3_Tkel(pow_3(Tkel)); - Real64 const pow_4_Tkel(pow_4(Tkel)); - - for (thisConstit = 1; thisConstit <= isize(FuelCell(GeneratorNum).ExhaustHX.GasLibID); ++thisConstit) { - gasID = FuelCell(GeneratorNum).ExhaustHX.GasLibID(thisConstit); - if (gasID > 0) { - if (GasPhaseThermoChemistryData(gasID).ThermoMode == NISTShomate) { - - A = GasPhaseThermoChemistryData(gasID).ShomateA; - B = GasPhaseThermoChemistryData(gasID).ShomateB; - C = GasPhaseThermoChemistryData(gasID).ShomateC; - D = GasPhaseThermoChemistryData(gasID).ShomateD; - E = GasPhaseThermoChemistryData(gasID).ShomateE; - - tempCp += ((A + B * Tsho + C * pow_2_Tsho + D * pow_3_Tsho + E / pow_2_Tsho) * - FuelCell(GeneratorNum).ExhaustHX.ConstitMolalFract(thisConstit)); - } - - if (GasPhaseThermoChemistryData(gasID).ThermoMode == NASAPolynomial) { - A1 = GasPhaseThermoChemistryData(gasID).NASA_A1; - A2 = GasPhaseThermoChemistryData(gasID).NASA_A2; - A3 = GasPhaseThermoChemistryData(gasID).NASA_A3; - A4 = GasPhaseThermoChemistryData(gasID).NASA_A4; - A5 = GasPhaseThermoChemistryData(gasID).NASA_A5; - - tempCp += (A1 + A2 * Tkel + A3 * pow_2_Tkel + A4 * pow_3_Tkel + A5 * pow_4_Tkel) * RinKJperMolpK * - FuelCell(GeneratorNum).ExhaustHX.ConstitMolalFract(thisConstit); - } - } - } - - Cp = tempCp; - } - void FigureGaseousWaterEnthalpy(Real64 const FluidTemp, // degree C Real64 &HGasWater // kJ/mol ) @@ -3106,35 +2766,15 @@ namespace FuelCellElectricGenerator { // calculate Enthalpy from Shomate equations for gaseous water // No ethalphy of formation in this one. - // METHODOLOGY EMPLOYED: - // REFERENCES: // NIST Webbook on gas phase thermochemistry - // USE STATEMENTS: - // na - - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS: - // na - - // DERIVED TYPE DEFINITIONS: - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: Real64 const A = 29.0373; // shomate coeff Real64 const B = 10.2573; // shomate coeff Real64 const C = 2.81048; // shomate coeff Real64 const D = -0.95914; // shomate coeff Real64 const E = 0.11725; // shomate coeff Real64 const F = -250.569; // shomate coeff - // REAL(r64) :: H ! shomate coeff - Real64 const Tsho = (FluidTemp + KelvinConv) / 1000.0; // temp for Shomate eq in (Kelvin/1000) HGasWater = A * Tsho + B * pow_2(Tsho) / 2.0 + C * pow_3(Tsho) / 3.0 + D * pow_4(Tsho) / 4.0 - E / Tsho + F; //- H @@ -3155,34 +2795,15 @@ namespace FuelCellElectricGenerator { // calculate Enthalpy from Shomate equations for liquid water // No enthalpy of formation in this one - // METHODOLOGY EMPLOYED: - // REFERENCES: // NIST Webbook on gas phase thermochemistry - // USE STATEMENTS: - // na - - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS: - // na - - // DERIVED TYPE DEFINITIONS: - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: Real64 const A = -203.606; // shomate coeff Real64 const B = 1523.29; // shomate coeff Real64 const C = -3196.413; // shomate coeff Real64 const D = 2474.455; // shomate coeff Real64 const E = 3.85533; // shomate coeff Real64 const F = -256.5478; // shomate coeff - // Real64 const H = -285.8304; // shomate coeff (currently unused) Real64 const Tsho = (FluidTemp + KelvinConv) / 1000.0; // temp for Shomate eq in (Kelvin/1000) @@ -3203,113 +2824,16 @@ namespace FuelCellElectricGenerator { // PURPOSE OF THIS SUBROUTINE: // calculate shomate eq. for pure liquid water - // METHODOLOGY EMPLOYED: - // - - // REFERENCES: - // na - - // USE STATEMENTS: - // na - - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - // na - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS: - // na - - // DERIVED TYPE DEFINITIONS: - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - // na - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS: - // na - - // DERIVED TYPE DEFINITIONS: - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: Real64 const A = -203.606; // shomate coeff Real64 const B = 1523.29; // shomate coeff Real64 const C = -3196.413; // shomate coeff Real64 const D = 2474.455; // shomate coeff Real64 const E = 3.85533; // shomate coeff - Real64 const Tsho = (FluidTemp + KelvinConv) / 1000.0; Cp = A + B * Tsho + C * pow_2(Tsho) + D * pow_3(Tsho) + E / pow_2(Tsho); } - void FigureLHVofFuel(int const Num, Real64 const NdotFuel, Real64 const NdotCO2, Real64 const NdotH20, Real64 &LHV) - { - - // SUBROUTINE INFORMATION: - // AUTHOR B Griffith - // DATE WRITTEN Aug 2005 - // MODIFIED na - // RE-ENGINEERED na - - // PURPOSE OF THIS SUBROUTINE: - // Calculate LHV - - // METHODOLOGY EMPLOYED: - // ANNEX 42 eq. 6 method from molar enthalpies - - // REFERENCES: - // na - - // USE STATEMENTS: - // na - - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS: - // na - - // DERIVED TYPE DEFINITIONS: - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - Real64 DelfHfuel; - Real64 DelfHCO2; - Real64 DelfHH20; - int i; - Real64 h_i; - int CO2dataID; - int WaterDataID; - int thisGasID; - - CO2dataID = 1; // hard-coded in SetupFuelAndAirConstituentData - WaterDataID = 4; // hard-coded in SetupFuelAndAirConstituentData - DelfHfuel = 0.0; - - for (i = 1; i <= FuelSupply(FuelCell(Num).FuelSupNum).NumConstituents; ++i) { - thisGasID = FuelSupply(FuelCell(Num).FuelSupNum).GasLibID(i); - - h_i = GasPhaseThermoChemistryData(thisGasID).StdRefMolarEnthOfForm; - - DelfHfuel += NdotFuel * h_i * FuelSupply(FuelCell(Num).FuelSupNum).ConstitMolalFract(i); - } - - DelfHCO2 = GasPhaseThermoChemistryData(CO2dataID).StdRefMolarEnthOfForm * NdotCO2; - - DelfHH20 = GasPhaseThermoChemistryData(WaterDataID).StdRefMolarEnthOfForm * NdotH20; - - LHV = (DelfHfuel - DelfHCO2 - DelfHH20) / NdotFuel; // Equation 6 - } - void FigureACAncillaries(int const GeneratorNum, Real64 &PacAncill) { @@ -3322,31 +2846,8 @@ namespace FuelCellElectricGenerator { // PURPOSE OF THIS SUBROUTINE: // Calculate the AC ancillaries to determine Pel - // METHODOLOGY EMPLOYED: - // - - // REFERENCES: - // na - - // USE STATEMENTS: - // na - // Using/Aliasing using CurveManager::CurveValue; - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS: - // na - - // DERIVED TYPE DEFINITIONS: - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - // Using lagged values inside a sequential substitution loop PacAncill = 0.0; // sect. 5.9 @@ -3379,30 +2880,8 @@ namespace FuelCellElectricGenerator { // PURPOSE OF THIS SUBROUTINE: // Calculate inverter losses - // METHODOLOGY EMPLOYED: - // - - // REFERENCES: - // na - - // USE STATEMENTS: - // na - // Using/Aliasing using CurveManager::CurveValue; - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS: - // na - - // DERIVED TYPE DEFINITIONS: - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: Real64 lastPpcuLosses; // used in iterative solution int iter; Real64 Pel; @@ -3442,34 +2921,9 @@ namespace FuelCellElectricGenerator { // MODIFIED na // RE-ENGINEERED na - // PURPOSE OF THIS SUBROUTINE: - // - - // METHODOLOGY EMPLOYED: - // - - // REFERENCES: - // na - - // USE STATEMENTS: - // na - // Using/Aliasing using DataHVACGlobals::SysTimeElapsed; using DataHVACGlobals::TimeStepSys; - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS: - // na - - // DERIVED TYPE DEFINITIONS: - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - // unused REAL(r64) :: CurrentHours Real64 CurrentFractionalDay; // working var, time in decimal days Real64 EndingFractionalDay; // working var, time is decimal days Real64 MaxPel; // working variable for max allowed by transient constraint @@ -3553,39 +3007,6 @@ namespace FuelCellElectricGenerator { void CalcFuelCellAuxHeater(int const Num) // Generator number { - // SUBROUTINE INFORMATION: - // AUTHOR - // DATE WRITTEN - // MODIFIED na - // RE-ENGINEERED na - - // PURPOSE OF THIS SUBROUTINE: - // - - // METHODOLOGY EMPLOYED: - // - - // REFERENCES: - // na - - // USE STATEMENTS: - // na - - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS: - // na - - // DERIVED TYPE DEFINITIONS: - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - // na - // not yet implemented, just pass product gases thru nul domain FuelCell(Num).AuxilHeat.TauxMix = FuelCell(Num).FCPM.TprodGasLeavingFCPM; @@ -3608,20 +3029,11 @@ namespace FuelCellElectricGenerator { // REFERENCES: Annex 42 model documentation - // Using/Aliasing using DataPlant::PlantLoop; using FluidProperties::GetSpecificHeatGlycol; - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: static std::string const RoutineName("CalcFuelCellGenHeatRecovery"); - // DERIVED TYPE DEFINITIONS - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: Real64 eHX; // fixed effectiveness Real64 MdotWater(0.0); int inNodeNum(0); @@ -3709,16 +3121,6 @@ namespace FuelCellElectricGenerator { FigureAuxilHeatGasHeatCap(Num, TauxMix, CpProdGasMol); // Cp in (J/mol*K) NdotCpAuxMix = NdotGas * CpProdGasMol * 1000.0; - // commented out protection for taking exponent of too large a number - // because it hasn't been a problem in testing - // testVal = LOG(huge(NdotCpAuxMix)) - // ExpTestVal = 700.0 - // IF (UAeff*(1/NdotCpAuxMix) > ExpTestVal) THEN - // write(*,*) 'Houston, we have a problem, EXP [] func will fail for UAeff*(1/NdotCpAuxMix):', UAeff*(1/NdotCpAuxMix) - // ELSEIF (UAeff*(1/NdotCpWater) > ExpTestVal) THEN - // write(*,*) 'Houston, we have a problem, EXP [] func will fail for UAeff*(1/NdotCpWater:', UAeff*(1/NdotCpWater) - // ELSE - if ((NdotCpWater != 0.0) && (NdotCpAuxMix != 0.0)) { // trap divide by zero // now evaluate Eq. 44 THXexh = ((1.0 - NdotCpAuxMix / NdotCpWater) / @@ -3891,45 +3293,6 @@ namespace FuelCellElectricGenerator { NdotWaterCond = 0.0; waterFract = -9999.0; // not defined } - // init input from Auxiliary heater - // FuelCell(Num)%ExhaustHX%NdotHXleaving = FuelCell(Num)%AuxilHeat%NdotAuxMix - // FuelCell(Num)%ExhaustHX%ConstitMolalFract = FuelCell(Num)%AuxilHeat%ConstitMolalFract - // FuelCell(Num)%ExhaustHX%GasLibID = FuelCell(Num)%AuxilHeat%GasLibID - - // now modify leaving gas constituents for condensed water. - // FuelCell(Num)%ExhaustHX%NdotHXleaving = FuelCell(Num)%AuxilHeat%NdotAuxMix - NdotWaterCond - // If ( FuelCell(Num)%ExhaustHX%NdotHXleaving > 0) then - // DO I = 1, SIZE(FuelCell(Num)%AuxilHeat%GasLibID) - // If (FuelCell(Num)%AuxilHeat%GasLibID(I) == 4) then ! water constituent - // FuelCell(Num)%ExhaustHX%ConstitMolalFract(I) = & - // (FuelCell(Num)%AuxilHeat%ConstitMolalFract(I)* FuelCell(Num)%AuxilHeat%NdotAuxMix - NdotWaterCond) & - // / FuelCell(Num)%ExhaustHX%NdotHXleaving - // cycle - // ENDIF - - // FuelCell(Num)%ExhaustHX%ConstitMolalFract(I) = FuelCell(Num)%AuxilHeat%ConstitMolalFract(I) & - // * FuelCell(Num)%AuxilHeat%NdotAuxMix / FuelCell(Num)%ExhaustHX%NdotHXleaving - // ENDDO - // ENDIF - - // get new average heat capacity - // CALL FigureHXleavingGasHeatCap(Num, (THXexh + TauxMix)/2 , CpHXleavingGasMol) - - // NdotCpHXleaving = FuelCell(Num)%ExhaustHX%NdotHXleaving*CpHXleavingGasMol* 1000.0 - - // update gas leaving temperature with modified heat transfer rate - // IF ((NdotCpHXleaving > 0) .AND. (qHX > 0)) THEN - // THXexh = TauxMix - (qHX / NdotCpHXleaving) - // ELSE - // THXexh = TauxMix - // ENDIF - // update water leaving temperature with modified heat transfer rate - // IF (MdotWater * CPCW( (TwaterIn + TwaterOut)/2 ) <= 0.0) THEN - // TwaterOut = TwaterIn - // ELSE - // TwaterOut = TwaterIn + qHX / (MdotWater * CPCW( (TwaterIn + TwaterOut)/2 )) - // ENDIF - } else { assert(false); // Variables not set are used below } @@ -3944,13 +3307,6 @@ namespace FuelCellElectricGenerator { FuelCell(Num).ExhaustHX.CondensateRate = NdotWaterCond; FuelCell(Num).ExhaustHX.WaterOutletTemp = TwaterOut; FuelCell(Num).ExhaustHX.WaterOutletEnthalpy = Node(inNodeNum).Enthalpy + qHX; - - // now update water outlet node Changing to Kg/s! - // OutNodeNum = FuelCell(Num)%ExhaustHX%WaterOutNode - // inNodeNum = FuelCell(Num)%ExhaustHX%WaterInNode - // Node(OutNodeNum)%Temp = Twaterout - // Node(OutNodeNum)%Enthalpy = - // Node(OutNodeNum)%MassFlowRate = MdotWater } void SimFuelCellPlantHeatRecovery(std::string const &EP_UNUSED(CompType), @@ -3977,7 +3333,6 @@ namespace FuelCellElectricGenerator { // makes sure input are gotten and setup from Plant loop perspective. // does not (re)simulate entire FuelCell model - // Using/Aliasing using DataPlant::TypeOf_Generator_FCExhaust; using DataPlant::TypeOf_Generator_FCStackCooler; using PlantUtilities::UpdateComponentHeatRecoverySide; @@ -4029,12 +3384,6 @@ namespace FuelCellElectricGenerator { } } - // End FuelCell Generator Module Model Subroutines - // ***************************************************************************** - - // Begin FuelCell Generator Module Utility Subroutines - // ***************************************************************************** - void InitFuelCellGenerators(int const FCnum) // index to specific fuel cell generator { @@ -4050,12 +3399,6 @@ namespace FuelCellElectricGenerator { // METHODOLOGY EMPLOYED: // Uses the status flags to trigger initializations. - // REFERENCES: - // na - - // USE STATEMENTS: - - // Using/Aliasing using DataGlobals::BeginEnvrnFlag; using DataGlobals::HourOfDay; using DataGlobals::SecInHour; @@ -4071,19 +3414,8 @@ namespace FuelCellElectricGenerator { using PlantUtilities::ScanPlantLoopsForObject; using PlantUtilities::SetComponentFlowRate; - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: static std::string const RoutineName("InitFuelCellGenerators"); - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: static bool InitGeneratorOnce(true); // flag for 1 time initialization static Array1D_bool MyEnvrnFlag; // flag for init once at start of environment static Array1D_bool MyWarmupFlag; // flag for init after warmup complete @@ -4095,7 +3427,6 @@ namespace FuelCellElectricGenerator { Real64 rho; // local temporary fluid density bool errFlag; - // FLOW: // Do the one time initializations if (InitGeneratorOnce) { MyEnvrnFlag.allocate(NumFuelCellGenerators); @@ -4176,7 +3507,6 @@ namespace FuelCellElectricGenerator { FuelCell(FCnum).ExhaustHX.NdotHXleaving = 0.0; FuelCell(FCnum).ExhaustHX.WaterOutletTemp = 0.0; FuelCell(FCnum).ExhaustHX.WaterOutletEnthalpy = 0.0; - FuelCell(FCnum).ElecStorage.LastTimeStepStateOfCharge = FuelCell(FCnum).ElecStorage.StartingEnergyStored; FuelCell(FCnum).ElecStorage.ThisTimeStepStateOfCharge = FuelCell(FCnum).ElecStorage.StartingEnergyStored; FuelCell(FCnum).ElecStorage.PelNeedFromStorage = 0.0; @@ -4277,11 +3607,6 @@ namespace FuelCellElectricGenerator { heatRecoveryCompName = FuelCell(thisFuelCell).ExhaustHX.Name; } } - // End FuelCell Generator Module Utility Subroutines - // ***************************************************************************** - - // Beginning of Record Keeping subroutines for the FuelCell Generator Module - // ***************************************************************************** void FigureFuelCellZoneGains() { @@ -4300,10 +3625,7 @@ namespace FuelCellElectricGenerator { // This routine adds up the various skin losses and then // sets the values in the ZoneIntGain structure - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - // unused INTEGER :: thisZone ! index in Zone structure array Real64 TotalZoneHeatGain; // working variable for zone gain [w] - // INTEGER :: ZoneNum int FCnum; // number of fuel cell static bool MyEnvrnFlag(true); @@ -4372,47 +3694,6 @@ namespace FuelCellElectricGenerator { FuelCell(FCnum).Report.SkinLossRadiat = FuelCell(FCnum).QradZone; } // over number of Fuel cells - - // IF(DoingSizing)THEN - - // ENDIF - } - - void UpdateExhaustAirFlows(int const EP_UNUSED(Num)) // generator number - { - - // SUBROUTINE INFORMATION: - // AUTHOR - // DATE WRITTEN - // MODIFIED na - // RE-ENGINEERED na - - // PURPOSE OF THIS SUBROUTINE: - // - - // METHODOLOGY EMPLOYED: - // - - // REFERENCES: - // na - - // USE STATEMENTS: - // na - - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS: - // na - - // DERIVED TYPE DEFINITIONS: - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - // na } void CalcUpdateHeatRecovery(int const Num, // Generator number @@ -4428,27 +3709,8 @@ namespace FuelCellElectricGenerator { // PURPOSE OF THIS SUBROUTINE: // update plant loop interactions, do any calcs needed - // METHODOLOGY EMPLOYED: - // - - // REFERENCES: - // na - - // Using/Aliasing using PlantUtilities::SafeCopyPlantNode; - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS: - // na - - // DERIVED TYPE DEFINITIONS: - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int InNodeNum; int OutNodeNum; @@ -4460,29 +3722,6 @@ namespace FuelCellElectricGenerator { Node(OutNodeNum).Temp = FuelCell(Num).ExhaustHX.WaterOutletTemp; Node(OutNodeNum).Enthalpy = FuelCell(Num).ExhaustHX.WaterOutletEnthalpy; - - // IF (FirstHVACIteration) Then - // Node(InNodeNum)%MassFlowRateMaxAvail = FuelCell(Num)%ExhaustHX%WaterMassFlowRateDesign - // Node(InNodeNum)%MassFlowRateMinAvail = 0.0D0 - // Node(InNodeNum)%MassFlowRate = MAX(FuelCell(Num)%ExhaustHX%WaterMassFlowRateDesign, & - // Node(InNodeNum)%MassFlowRateMin) - // Node(InNodeNum)%MassFlowRate = MIN(FuelCell(Num)%ExhaustHX%WaterMassFlowRateDesign, & - // Node(InNodeNum)%MassFlowRateMax) - // ELSE - // Node(InNodeNum)%MassFlowRate = MAX(FuelCell(Num)%ExhaustHX%WaterMassFlowRateDesign, & - // Node(InNodeNum)%MassFlowRateMin) - // Node(InNodeNum)%MassFlowRate = MAX(FuelCell(Num)%ExhaustHX%WaterMassFlowRateDesign, & - // Node(InNodeNum)%MassFlowRateMinAvail) - // Node(InNodeNum)%MassFlowRate = MIN(FuelCell(Num)%ExhaustHX%WaterMassFlowRateDesign, & - // Node(InNodeNum)%MassFlowRateMax) - // Node(InNodeNum)%MassFlowRate = MIN(FuelCell(Num)%ExhaustHX%WaterMassFlowRateDesign, & - // Node(InNodeNum)%MassFlowRateMaxAvail) - // ENDIF - // Node(OutNodeNum)%MassFlowRate = Node(InNodeNum)%MassFlowRate - // Node(OutNodeNum)%MassFlowRateMaxAvail = Node(InNodeNum)%MassFlowRateMaxAvail - // Node(OutNodeNum)%MassFlowRateMinAvail = Node(InNodeNum)%MassFlowRateMinAvail - // Node(OutNodeNum)%MassFlowRateMax = Node(InNodeNum)%MassFlowRateMax - // Node(OutNodeNum)%MassFlowRateMin = Node(InNodeNum)%MassFlowRateMin } void UpdateFuelCellGeneratorRecords(bool const EP_UNUSED(RunFlag), // TRUE if Generator operating @@ -4493,28 +3732,8 @@ namespace FuelCellElectricGenerator { // AUTHOR: BG // DATE WRITTEN: - // PURPOSE OF THIS SUBROUTINE: - // reporting - - // METHODOLOGY EMPLOYED: na - - // REFERENCES: na - - // USE STATEMENTS: na - // Using/Aliasing using DataHVACGlobals::TimeStepSys; - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // DERIVED TYPE DEFINITIONS - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - FuelCell(Num).Report.ACPowerGen = FuelCell(Num).ACPowerGen; // electrical power produced [W] FuelCell(Num).Report.ACEnergyGen = FuelCell(Num).ACPowerGen * TimeStepSys * SecInHour; // energy produced (J) FuelCell(Num).Report.QdotExhaust = 0.0; // reporting: exhaust gas heat recovered (W) @@ -4620,28 +3839,6 @@ namespace FuelCellElectricGenerator { // PURPOSE OF THIS SUBROUTINE: // provide a get method to collect results at the load center level - // METHODOLOGY EMPLOYED: - // - - // REFERENCES: - // na - - // USE STATEMENTS: - // na - - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS: - // na - - // DERIVED TYPE DEFINITIONS: - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: GeneratorPower = FuelCell(GeneratorIndex).Report.ACPowerGen; GeneratorEnergy = FuelCell(GeneratorIndex).Report.ACEnergyGen; ThermalPower = FuelCell(GeneratorIndex).Report.qHX; diff --git a/src/EnergyPlus/FuelCellElectricGenerator.hh b/src/EnergyPlus/FuelCellElectricGenerator.hh index 7ff13b5ccc1..22361161bae 100644 --- a/src/EnergyPlus/FuelCellElectricGenerator.hh +++ b/src/EnergyPlus/FuelCellElectricGenerator.hh @@ -145,11 +145,6 @@ namespace FuelCellElectricGenerator { Real64 &Cp // (J/mol*K) ); - void FigureHXleavingGasHeatCap(int const GeneratorNum, // ID of generator FuelCell data structure - Real64 const FluidTemp, // degree C - Real64 &Cp // (J/mol*K) - ); - void FigureGaseousWaterEnthalpy(Real64 const FluidTemp, // degree C Real64 &HGasWater // kJ/mol ); @@ -162,8 +157,6 @@ namespace FuelCellElectricGenerator { Real64 &Cp // (J/mol*K) ); - void FigureLHVofFuel(int const Num, Real64 const NdotFuel, Real64 const NdotCO2, Real64 const NdotH20, Real64 &LHV); - void FigureACAncillaries(int const GeneratorNum, Real64 &PacAncill); void FigurePowerConditioningLosses(int const GeneratorNum, Real64 const Pdemand, Real64 &PpcuLosses); @@ -191,27 +184,13 @@ namespace FuelCellElectricGenerator { bool const FirstHVACIteration // TRUE if First iteration of simulation ); - // End FuelCell Generator Module Model Subroutines - // ***************************************************************************** - - // Begin FuelCell Generator Module Utility Subroutines - // ***************************************************************************** - void InitFuelCellGenerators(int const FCnum); // index to specific fuel cell generator void getFuelCellGeneratorHeatRecoveryInfo(std::string const &GeneratorName, // user specified name of Generator std::string &heatRecoveryCompName); - // End FuelCell Generator Module Utility Subroutines - // ***************************************************************************** - - // Beginning of Record Keeping subroutines for the FuelCell Generator Module - // ***************************************************************************** - void FigureFuelCellZoneGains(); - void UpdateExhaustAirFlows(int const Num); // generator number - void CalcUpdateHeatRecovery(int const Num, // Generator number bool const FirstHVACIteration); diff --git a/tst/EnergyPlus/unit/FuelCellElectricGenerator.unit.cc b/tst/EnergyPlus/unit/FuelCellElectricGenerator.unit.cc index 4f167ea876e..0db54f060d0 100644 --- a/tst/EnergyPlus/unit/FuelCellElectricGenerator.unit.cc +++ b/tst/EnergyPlus/unit/FuelCellElectricGenerator.unit.cc @@ -60,7 +60,9 @@ using namespace EnergyPlus; using namespace ObjexxFCL; -TEST_F(EnergyPlusFixture, FuelCellTest_LowInletEnthalySover1) +class FuelCellGenFixture : public EnergyPlusFixture {}; + +TEST_F(FuelCellGenFixture, FuelCellTest_LowInletEnthalySover1) { std::string const idf_objects = delimited_string({ From 997856b0937763dc39a96169bf4610e75777a070 Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Mon, 21 Oct 2019 13:58:52 -0600 Subject: [PATCH 10/51] partial cleanup usings --- src/EnergyPlus/FuelCellElectricGenerator.cc | 284 ++++++++------------ 1 file changed, 110 insertions(+), 174 deletions(-) diff --git a/src/EnergyPlus/FuelCellElectricGenerator.cc b/src/EnergyPlus/FuelCellElectricGenerator.cc index 422b0910b38..249bda9c13c 100644 --- a/src/EnergyPlus/FuelCellElectricGenerator.cc +++ b/src/EnergyPlus/FuelCellElectricGenerator.cc @@ -83,12 +83,6 @@ namespace EnergyPlus { namespace FuelCellElectricGenerator { - //_______________________________________________________________________ - // IEA Annex 42 generators: - // FuelCellElectricGenerator (Solid Oxide Fuel Cell (SOFC)) - // (Proton Exchange Membrane FC (PEMFC)) - // IEA/ECBCS Annex 42 model) - // MODULE INFORMATION: // AUTHOR Brent Griffth // DATE WRITTEN August. 2005 @@ -110,16 +104,6 @@ namespace FuelCellElectricGenerator { // Using/Aliasing using namespace DataGenerators; using namespace DataLoopNode; - using DataGlobalConstants::iGeneratorFuelCell; - using DataGlobals::BeginEnvrnFlag; - using DataGlobals::CurrentTime; - using DataGlobals::DayOfSim; - using DataGlobals::HoursInDay; - using DataGlobals::KelvinConv; - using DataGlobals::NumOfTimeStepInHour; - using DataGlobals::NumOfZones; - using DataGlobals::SecInHour; - using DataGlobals::WarmupFlag; using namespace GeneratorFuelSupply; using namespace GeneratorDynamicsManager; @@ -142,8 +126,6 @@ namespace FuelCellElectricGenerator { // gets the input for the models, initializes simulation variables, call // the appropriate model and sets up reporting variables. - using General::TrimSigDigits; - int GenNum; // Generator number counter // Get Generator data from input file @@ -159,12 +141,12 @@ namespace FuelCellElectricGenerator { } else { GenNum = GeneratorIndex; if (GenNum > NumFuelCellGenerators || GenNum < 1) { - ShowFatalError("SimFuelCellGenerator: Invalid GeneratorIndex passed=" + TrimSigDigits(GenNum) + - ", Number of FuelCell Generators=" + TrimSigDigits(NumFuelCellGenerators) + ", Generator name=" + GeneratorName); + ShowFatalError("SimFuelCellGenerator: Invalid GeneratorIndex passed=" + General::TrimSigDigits(GenNum) + + ", Number of FuelCell Generators=" + General::TrimSigDigits(NumFuelCellGenerators) + ", Generator name=" + GeneratorName); } if (CheckEquipName(GenNum)) { if (GeneratorName != FuelCell(GenNum).Name) { - ShowFatalError("SimFuelCellGenerator: Invalid GeneratorIndex passed=" + TrimSigDigits(GenNum) + + ShowFatalError("SimFuelCellGenerator: Invalid GeneratorIndex passed=" + General::TrimSigDigits(GenNum) + ", Generator name=" + GeneratorName + ", stored Generator Name for that index=" + FuelCell(GenNum).Name); } CheckEquipName(GenNum) = false; @@ -195,14 +177,7 @@ namespace FuelCellElectricGenerator { using namespace DataGenerators; using namespace DataIPShortCuts; // Data for field names, blank numerics - using BranchNodeConnections::TestCompSet; - using CurveManager::GetCurveIndex; - using DataGlobals::DisplayAdvancedReportVariables; - using DataHeatBalance::IntGainTypeOf_GeneratorFuelCell; - using DataHeatBalance::Zone; - using General::RoundSigDigits; using NodeInputManager::GetOnlySingleNode; - using PlantUtilities::RegisterPlantCompDesignFlow; using ScheduleManager::GetScheduleIndex; int GeneratorNum; // Generator counter @@ -311,7 +286,7 @@ namespace FuelCellElectricGenerator { ShowContinueError("Entered in " + cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } - FuelCell(thisFuelCell).FCPM.EffCurveID = GetCurveIndex(AlphArray(3)); + FuelCell(thisFuelCell).FCPM.EffCurveID = CurveManager::GetCurveIndex(AlphArray(3)); if (FuelCell(thisFuelCell).FCPM.EffCurveID == 0) { ShowSevereError("Invalid, " + cAlphaFieldNames(3) + " = " + AlphArray(3)); ShowContinueError("Entered in " + cCurrentModuleObject + '=' + AlphArray(1)); @@ -327,11 +302,11 @@ namespace FuelCellElectricGenerator { FuelCell(thisFuelCell).FCPM.ThreshRunHours = NumArray(7); FuelCell(thisFuelCell).FCPM.UpTranLimit = NumArray(8); FuelCell(thisFuelCell).FCPM.DownTranLimit = NumArray(9); - FuelCell(thisFuelCell).FCPM.StartUpTime = NumArray(10) / SecInHour; // convert to hours from seconds + FuelCell(thisFuelCell).FCPM.StartUpTime = NumArray(10) / DataGlobals::SecInHour; // convert to hours from seconds FuelCell(thisFuelCell).FCPM.StartUpFuel = NumArray(11); FuelCell(thisFuelCell).FCPM.StartUpElectConsum = NumArray(12); FuelCell(thisFuelCell).FCPM.StartUpElectProd = NumArray(13); - FuelCell(thisFuelCell).FCPM.ShutDownTime = NumArray(14) / SecInHour; // convert to hours from seconds + FuelCell(thisFuelCell).FCPM.ShutDownTime = NumArray(14) / DataGlobals::SecInHour; // convert to hours from seconds FuelCell(thisFuelCell).FCPM.ShutDownFuel = NumArray(15); FuelCell(thisFuelCell).FCPM.ShutDownElectConsum = NumArray(16); FuelCell(thisFuelCell).FCPM.ANC0 = NumArray(17); @@ -348,7 +323,7 @@ namespace FuelCellElectricGenerator { ErrorsFound = true; } FuelCell(thisFuelCell).FCPM.ZoneName = AlphArray(5); - FuelCell(thisFuelCell).FCPM.ZoneID = UtilityRoutines::FindItemInList(FuelCell(thisFuelCell).FCPM.ZoneName, Zone); + FuelCell(thisFuelCell).FCPM.ZoneID = UtilityRoutines::FindItemInList(FuelCell(thisFuelCell).FCPM.ZoneName, DataHeatBalance::Zone); if (FuelCell(thisFuelCell).FCPM.ZoneID == 0 && !lAlphaBlanks(5)) { ShowSevereError("Invalid, " + cAlphaFieldNames(5) + " = " + AlphArray(5)); ShowContinueError("Entered in " + cCurrentModuleObject + '=' + AlphArray(1)); @@ -360,7 +335,7 @@ namespace FuelCellElectricGenerator { FuelCell(thisFuelCell).FCPM.QdotSkin = NumArray(20); FuelCell(thisFuelCell).FCPM.UAskin = NumArray(21); - FuelCell(thisFuelCell).FCPM.SkinLossCurveID = GetCurveIndex(AlphArray(6)); + FuelCell(thisFuelCell).FCPM.SkinLossCurveID = CurveManager::GetCurveIndex(AlphArray(6)); if (FuelCell(thisFuelCell).FCPM.SkinLossCurveID == 0) { if (FuelCell(thisFuelCell).FCPM.SkinLossMode == QuadraticFuelNdotSkin) { ShowSevereError("Invalid, " + cAlphaFieldNames(6) + " = " + AlphArray(6)); @@ -433,7 +408,7 @@ namespace FuelCellElectricGenerator { FuelCell(thisFuelCell).AirSup.SupNodeNum = GetOnlySingleNode( AlphArray(2), ErrorsFound, cCurrentModuleObject, AlphArray(1), NodeType_Air, NodeConnectionType_Inlet, 1, ObjectIsNotParent); - FuelCell(thisFuelCell).AirSup.BlowerPowerCurveID = GetCurveIndex(AlphArray(3)); + FuelCell(thisFuelCell).AirSup.BlowerPowerCurveID = CurveManager::GetCurveIndex(AlphArray(3)); if (FuelCell(thisFuelCell).AirSup.BlowerPowerCurveID == 0) { ShowSevereError("Invalid, " + cAlphaFieldNames(3) + " = " + AlphArray(3)); ShowContinueError("Entered in " + cCurrentModuleObject + '=' + AlphArray(1)); @@ -456,7 +431,7 @@ namespace FuelCellElectricGenerator { FuelCell(thisFuelCell).AirSup.Stoics = NumArray(2) + 1.0; - FuelCell(thisFuelCell).AirSup.AirFuncPelCurveID = GetCurveIndex(AlphArray(5)); + FuelCell(thisFuelCell).AirSup.AirFuncPelCurveID = CurveManager::GetCurveIndex(AlphArray(5)); if ((FuelCell(thisFuelCell).AirSup.AirFuncPelCurveID == 0) && (FuelCell(thisFuelCell).AirSup.AirSupRateMode == QuadraticFuncofPel)) { ShowSevereError("Invalid, " + cAlphaFieldNames(5) + " = " + AlphArray(5)); @@ -467,7 +442,7 @@ namespace FuelCellElectricGenerator { FuelCell(thisFuelCell).AirSup.AirTempCoeff = NumArray(3); - FuelCell(thisFuelCell).AirSup.AirFuncNdotCurveID = GetCurveIndex(AlphArray(6)); + FuelCell(thisFuelCell).AirSup.AirFuncNdotCurveID = CurveManager::GetCurveIndex(AlphArray(6)); if ((FuelCell(thisFuelCell).AirSup.AirFuncNdotCurveID == 0) && (FuelCell(thisFuelCell).AirSup.AirSupRateMode == QuadraticFuncofNdot)) { ShowSevereError("Invalid, " + cAlphaFieldNames(6) + " = " + AlphArray(6)); @@ -509,7 +484,7 @@ namespace FuelCellElectricGenerator { FuelCell(thisFuelCell).AirSup.NumConstituents = NumAirConstit; if (NumAirConstit > 5) { - ShowSevereError("Invalid " + cNumericFieldNames(4) + '=' + RoundSigDigits(NumArray(4), 2)); + ShowSevereError("Invalid " + cNumericFieldNames(4) + '=' + General::RoundSigDigits(NumArray(4), 2)); ShowContinueError("Entered in " + cCurrentModuleObject + '=' + AlphArray(1)); ShowContinueError("Fuel Cell model not set up for more than 5 air constituents"); ErrorsFound = true; @@ -545,7 +520,7 @@ namespace FuelCellElectricGenerator { if (std::abs(sum(FuelCell(thisFuelCell).AirSup.ConstitMolalFract) - 1.0) > 0.0001) { ShowSevereError(cCurrentModuleObject + " molar fractions do not sum to 1.0"); - ShowContinueError("..Sum was=" + RoundSigDigits(sum(FuelCell(thisFuelCell).AirSup.ConstitMolalFract), 1)); + ShowContinueError("..Sum was=" + General::RoundSigDigits(sum(FuelCell(thisFuelCell).AirSup.ConstitMolalFract), 1)); ShowContinueError("Entered in " + cCurrentModuleObject + " = " + AlphArray(1)); ErrorsFound = true; } @@ -606,14 +581,14 @@ namespace FuelCellElectricGenerator { if (thisFuelCell > 0) { // this is only the first instance of a FuelCell generator using this type of Water supply module FuelCell(thisFuelCell).WaterSup.Name = AlphArray(1); - FuelCell(thisFuelCell).WaterSup.WaterSupRateCurveID = GetCurveIndex(AlphArray(2)); + FuelCell(thisFuelCell).WaterSup.WaterSupRateCurveID = CurveManager::GetCurveIndex(AlphArray(2)); if (FuelCell(thisFuelCell).WaterSup.WaterSupRateCurveID == 0) { ShowSevereError("Invalid, " + cAlphaFieldNames(2) + " = " + AlphArray(2)); ShowContinueError("Entered in " + cCurrentModuleObject + '=' + AlphArray(1)); ShowContinueError("Curve name was not found "); ErrorsFound = true; } - FuelCell(thisFuelCell).WaterSup.PmpPowerCurveID = GetCurveIndex(AlphArray(3)); + FuelCell(thisFuelCell).WaterSup.PmpPowerCurveID = CurveManager::GetCurveIndex(AlphArray(3)); if (FuelCell(thisFuelCell).WaterSup.PmpPowerCurveID == 0) { ShowSevereError("Invalid, " + cAlphaFieldNames(3) + " = " + AlphArray(3)); ShowContinueError("Entered in " + cCurrentModuleObject + '=' + AlphArray(1)); @@ -714,7 +689,7 @@ namespace FuelCellElectricGenerator { } FuelCell(thisFuelCell).AuxilHeat.ZoneName = AlphArray(3); - FuelCell(thisFuelCell).AuxilHeat.ZoneID = UtilityRoutines::FindItemInList(AlphArray(3), Zone); + FuelCell(thisFuelCell).AuxilHeat.ZoneID = UtilityRoutines::FindItemInList(AlphArray(3), DataHeatBalance::Zone); if ((FuelCell(thisFuelCell).AuxilHeat.ZoneID == 0) && (FuelCell(thisFuelCell).AuxilHeat.SkinLossDestination == SurroundingZone)) { ShowSevereError("Invalid, " + cAlphaFieldNames(3) + " = " + AlphArray(3)); ShowContinueError("Entered in " + cCurrentModuleObject + '=' + AlphArray(1)); @@ -777,7 +752,7 @@ namespace FuelCellElectricGenerator { NodeConnectionType_Outlet, 1, ObjectIsNotParent); - TestCompSet(cCurrentModuleObject, AlphArray(1), AlphArray(2), AlphArray(3), "Heat Recovery Nodes"); + BranchNodeConnections::TestCompSet(cCurrentModuleObject, AlphArray(1), AlphArray(2), AlphArray(3), "Heat Recovery Nodes"); // CR9240 FuelCell(thisFuelCell).ExhaustHX.ExhaustOutNodeName = AlphArray(4); @@ -818,7 +793,7 @@ namespace FuelCellElectricGenerator { FuelCell(thisFuelCell).ExhaustHX.CondensationThresholdTemp = NumArray(19); // store cooling water volume flow rate for autosizing system - RegisterPlantCompDesignFlow(FuelCell(thisFuelCell).ExhaustHX.WaterInNode, FuelCell(thisFuelCell).ExhaustHX.WaterVolumeFlowMax); + PlantUtilities::RegisterPlantCompDesignFlow(FuelCell(thisFuelCell).ExhaustHX.WaterInNode, FuelCell(thisFuelCell).ExhaustHX.WaterVolumeFlowMax); } else { ShowSevereError("Invalid, " + cAlphaFieldNames(1) + " = " + AlphArray(1)); ShowContinueError("Entered in " + cCurrentModuleObject + '=' + AlphArray(1)); @@ -900,7 +875,7 @@ namespace FuelCellElectricGenerator { FuelCell(thisFuelCell).Inverter.ConstEff = NumArray(1); - FuelCell(thisFuelCell).Inverter.EffQuadraticCurveID = GetCurveIndex(AlphArray(3)); + FuelCell(thisFuelCell).Inverter.EffQuadraticCurveID = CurveManager::GetCurveIndex(AlphArray(3)); if ((FuelCell(thisFuelCell).Inverter.EffQuadraticCurveID == 0) && (FuelCell(thisFuelCell).Inverter.EffMode == InverterEffQuadratic)) { ShowSevereError("Invalid, " + cAlphaFieldNames(3) + " = " + AlphArray(3)); @@ -963,7 +938,7 @@ namespace FuelCellElectricGenerator { NodeConnectionType_Outlet, 1, ObjectIsNotParent); - TestCompSet(cCurrentModuleObject, AlphArray(1), AlphArray(2), AlphArray(3), "Heat Recovery Nodes"); + BranchNodeConnections::TestCompSet(cCurrentModuleObject, AlphArray(1), AlphArray(2), AlphArray(3), "Heat Recovery Nodes"); FuelCell(thisFuelCell).StackCooler.TstackNom = NumArray(1); FuelCell(thisFuelCell).StackCooler.TstackActual = NumArray(2); @@ -1080,13 +1055,13 @@ namespace FuelCellElectricGenerator { SetupZoneInternalGain(FuelCell(GeneratorNum).FCPM.ZoneID, "Generator:FuelCell", FuelCell(GeneratorNum).Name, - IntGainTypeOf_GeneratorFuelCell, + DataHeatBalance::IntGainTypeOf_GeneratorFuelCell, FuelCell(GeneratorNum).Report.SkinLossConvect, _, FuelCell(GeneratorNum).Report.SkinLossRadiat); } - if (DisplayAdvancedReportVariables) { // show extra data originally needed for detailed comparative testing + if (DataGlobals::DisplayAdvancedReportVariables) { // show extra data originally needed for detailed comparative testing SetupOutputVariable("Generator Air Inlet Temperature", OutputProcessor::Unit::C, FuelCell(GeneratorNum).Report.TairInlet, @@ -1393,12 +1368,7 @@ namespace FuelCellElectricGenerator { // REFERENCES: IEA/ECBCS Annex 42.... - using CurveManager::CurveValue; - using DataEnvironment::WaterMainsTemp; using DataHeatBalFanSys::ZT; - using DataHVACGlobals::SysTimeElapsed; - using General::RoundSigDigits; - using General::SolveRoot; using ScheduleManager::GetCurrentScheduleValue; static Real64 PpcuLosses; // losses in inverter [W] @@ -1455,7 +1425,7 @@ namespace FuelCellElectricGenerator { // set Day and Time of Last Shut Down FuelCell(GeneratorNum).FCPM.FractionalDayofLastShutDown = - double(DayOfSim) + (int(CurrentTime) + (SysTimeElapsed + (CurrentTime - int(CurrentTime)))) / HoursInDay; + double(DataGlobals::DayOfSim) + (int(DataGlobals::CurrentTime) + (DataHVACGlobals::SysTimeElapsed + (DataGlobals::CurrentTime - int(DataGlobals::CurrentTime)))) / DataGlobals::HoursInDay; FuelCell(GeneratorNum).FCPM.HasBeenOn = false; if (FuelCell(GeneratorNum).FCPM.ShutDownTime > 0.0) FuelCell(GeneratorNum).FCPM.DuringShutDown = true; @@ -1473,7 +1443,7 @@ namespace FuelCellElectricGenerator { // set Day and Time of Last STart Up FuelCell(GeneratorNum).FCPM.FractionalDayofLastStartUp = - double(DayOfSim) + (int(CurrentTime) + (SysTimeElapsed + (CurrentTime - int(CurrentTime)))) / HoursInDay; + double(DataGlobals::DayOfSim) + (int(DataGlobals::CurrentTime) + (DataHVACGlobals::SysTimeElapsed + (DataGlobals::CurrentTime - int(DataGlobals::CurrentTime)))) / DataGlobals::HoursInDay; FuelCell(GeneratorNum).FCPM.HasBeenOn = true; ++FuelCell(GeneratorNum).FCPM.NumCycles; // increment cycling counter @@ -1541,7 +1511,7 @@ namespace FuelCellElectricGenerator { if (FuelCell(GeneratorNum).FCPM.EffMode == NormalizedCurveMode) { // Equation (8) in FuelCell Spec modified for normalized curve - Eel = CurveValue(FuelCell(GeneratorNum).FCPM.EffCurveID, Pel / FuelCell(GeneratorNum).FCPM.NomPel) * + Eel = CurveManager::CurveValue(FuelCell(GeneratorNum).FCPM.EffCurveID, Pel / FuelCell(GeneratorNum).FCPM.NomPel) * FuelCell(GeneratorNum).FCPM.NomEff * (1.0 - FuelCell(GeneratorNum).FCPM.NumCycles * FuelCell(GeneratorNum).FCPM.CyclingDegradRat) * (1.0 - max((FuelCell(GeneratorNum).FCPM.NumRunHours - FuelCell(GeneratorNum).FCPM.ThreshRunHours), 0.0) * @@ -1549,7 +1519,7 @@ namespace FuelCellElectricGenerator { } else if (FuelCell(GeneratorNum).FCPM.EffMode == DirectCurveMode) { // Equation (8) in FuelCell Spec - Eel = CurveValue(FuelCell(GeneratorNum).FCPM.EffCurveID, Pel) * + Eel = CurveManager::CurveValue(FuelCell(GeneratorNum).FCPM.EffCurveID, Pel) * (1.0 - FuelCell(GeneratorNum).FCPM.NumCycles * FuelCell(GeneratorNum).FCPM.CyclingDegradRat) * (1.0 - max((FuelCell(GeneratorNum).FCPM.NumRunHours - FuelCell(GeneratorNum).FCPM.ThreshRunHours), 0.0) * FuelCell(GeneratorNum).FCPM.OperateDegradRat); @@ -1581,19 +1551,19 @@ namespace FuelCellElectricGenerator { } else if (FuelCell(GeneratorNum).AirSup.AirSupRateMode == QuadraticFuncofPel) { // MEthod 2 - FuelCell(GeneratorNum).FCPM.NdotAir = CurveValue(FuelCell(GeneratorNum).AirSup.AirFuncPelCurveID, Pel) * + FuelCell(GeneratorNum).FCPM.NdotAir = CurveManager::CurveValue(FuelCell(GeneratorNum).AirSup.AirFuncPelCurveID, Pel) * (1 + FuelCell(GeneratorNum).AirSup.AirTempCoeff * FuelCell(GeneratorNum).AirSup.TairIntoFCPM); } else if (FuelCell(GeneratorNum).AirSup.AirSupRateMode == QuadraticFuncofNdot) { // method 3 FuelCell(GeneratorNum).FCPM.NdotAir = - CurveValue(FuelCell(GeneratorNum).AirSup.AirFuncNdotCurveID, FuelCell(GeneratorNum).FCPM.NdotFuel) * + CurveManager::CurveValue(FuelCell(GeneratorNum).AirSup.AirFuncNdotCurveID, FuelCell(GeneratorNum).FCPM.NdotFuel) * (1 + FuelCell(GeneratorNum).AirSup.AirTempCoeff * FuelCell(GeneratorNum).AirSup.TairIntoFCPM); } // Calculation Step 4. fuel compressor power FuelSupply(FuelCell(GeneratorNum).FuelSupNum).PfuelCompEl = - CurveValue(FuelSupply(FuelCell(GeneratorNum).FuelSupNum).CompPowerCurveID, FuelCell(GeneratorNum).FCPM.NdotFuel); + CurveManager::CurveValue(FuelSupply(FuelCell(GeneratorNum).FuelSupNum).CompPowerCurveID, FuelCell(GeneratorNum).FCPM.NdotFuel); // calculation Step 5, Fuel Compressor (need outlet temperature) @@ -1628,7 +1598,7 @@ namespace FuelCellElectricGenerator { if (FuelSupply(FuelCell(GeneratorNum).FuelSupNum).QskinLoss < 0.0) { // write(*,*) 'problem in FuelSupply%QskinLoss ', FuelSupply(FuelCell(GeneratorNum)%FuelSupNum)%QskinLoss - ShowWarningError("problem in FuelSupply%QskinLoss " + RoundSigDigits(FuelSupply(FuelCell(GeneratorNum).FuelSupNum).QskinLoss, 3)); + ShowWarningError("problem in FuelSupply%QskinLoss " + General::RoundSigDigits(FuelSupply(FuelCell(GeneratorNum).FuelSupNum).QskinLoss, 3)); FuelSupply(FuelCell(GeneratorNum).FuelSupNum).QskinLoss = 0.0; } @@ -1646,7 +1616,7 @@ namespace FuelCellElectricGenerator { // calculate water consumption FuelCell(GeneratorNum).FCPM.NdotLiqwater = - CurveValue(FuelCell(GeneratorNum).WaterSup.WaterSupRateCurveID, FuelCell(GeneratorNum).FCPM.NdotFuel); + CurveManager::CurveValue(FuelCell(GeneratorNum).WaterSup.WaterSupRateCurveID, FuelCell(GeneratorNum).FCPM.NdotFuel); // set inlet temp. (could move to init) @@ -1655,7 +1625,7 @@ namespace FuelCellElectricGenerator { if (SELECT_CASE_var == WaterInReformMains) { - FuelCell(GeneratorNum).WaterSup.TwaterIntoCompress = WaterMainsTemp; + FuelCell(GeneratorNum).WaterSup.TwaterIntoCompress = DataEnvironment::WaterMainsTemp; } else if ((SELECT_CASE_var == WaterInReformAirNode) || (SELECT_CASE_var == WaterInReformWaterNode)) { @@ -1668,7 +1638,7 @@ namespace FuelCellElectricGenerator { } FuelCell(GeneratorNum).WaterSup.PwaterCompEl = - CurveValue(FuelCell(GeneratorNum).WaterSup.PmpPowerCurveID, FuelCell(GeneratorNum).FCPM.NdotLiqwater); + CurveManager::CurveValue(FuelCell(GeneratorNum).WaterSup.PmpPowerCurveID, FuelCell(GeneratorNum).FCPM.NdotLiqwater); // 75.325 J/mol K Water at 0.1 MPa and 298 K, reference NIST WEBBOOK FigureLiquidWaterHeatCap(FuelCell(GeneratorNum).WaterSup.TwaterIntoCompress, CpWater); @@ -1702,7 +1672,7 @@ namespace FuelCellElectricGenerator { FuelCell(GeneratorNum).AirSup.TairIntoBlower = Node(FuelCell(GeneratorNum).AirSup.SupNodeNum).Temp; FuelCell(GeneratorNum).AirSup.PairCompEl = - CurveValue(FuelCell(GeneratorNum).AirSup.BlowerPowerCurveID, FuelCell(GeneratorNum).FCPM.NdotAir); + CurveManager::CurveValue(FuelCell(GeneratorNum).AirSup.BlowerPowerCurveID, FuelCell(GeneratorNum).FCPM.NdotAir); Tavg = (FuelCell(GeneratorNum).AirSup.TairIntoBlower + FuelCell(GeneratorNum).AirSup.TairIntoFCPM) / 2.0; @@ -1758,7 +1728,7 @@ namespace FuelCellElectricGenerator { if (FuelCell(GeneratorNum).AirSup.QskinLoss < 0.0) { // write(*,*) 'problem in AirSup%QskinLoss ', FuelCell(GeneratorNum)%AirSup%QskinLoss - ShowWarningError("problem in AirSup%QskinLoss " + RoundSigDigits(FuelCell(GeneratorNum).AirSup.QskinLoss, 3)); + ShowWarningError("problem in AirSup%QskinLoss " + General::RoundSigDigits(FuelCell(GeneratorNum).AirSup.QskinLoss, 3)); FuelCell(GeneratorNum).AirSup.QskinLoss = 0.0; } @@ -1871,7 +1841,7 @@ namespace FuelCellElectricGenerator { } else if (FuelCell(GeneratorNum).FCPM.SkinLossMode == QuadraticFuelNdotSkin) { - FuelCell(GeneratorNum).FCPM.QdotSkin = CurveValue(FuelCell(GeneratorNum).FCPM.SkinLossCurveID, FuelCell(GeneratorNum).FCPM.NdotFuel); + FuelCell(GeneratorNum).FCPM.QdotSkin = CurveManager::CurveValue(FuelCell(GeneratorNum).FCPM.SkinLossCurveID, FuelCell(GeneratorNum).FCPM.NdotFuel); } // calculation Step 10, AC FCPM power ancillaries @@ -1917,7 +1887,7 @@ namespace FuelCellElectricGenerator { Par(2) = tmpTotProdGasEnthalphy; Par(3) = FuelCell(GeneratorNum).FCPM.NdotProdGas; tmpTprodGas = FuelCell(GeneratorNum).FCPM.TprodGasLeavingFCPM; - SolveRoot(Acc, MaxIter, SolverFlag, tmpTprodGas, FuelCellProductGasEnthResidual, MinProductGasTemp, MaxProductGasTemp, Par); + General::SolveRoot(Acc, MaxIter, SolverFlag, tmpTprodGas, FuelCellProductGasEnthResidual, MinProductGasTemp, MaxProductGasTemp, Par); if (SolverFlag == -2) { @@ -1947,7 +1917,7 @@ namespace FuelCellElectricGenerator { if (FuelCell(GeneratorNum).Inverter.EffMode == InverterEffQuadratic) { - PpcuLosses = (1.0 - CurveValue(FuelCell(GeneratorNum).Inverter.EffQuadraticCurveID, PintoInverter)) * PintoInverter; + PpcuLosses = (1.0 - CurveManager::CurveValue(FuelCell(GeneratorNum).Inverter.EffQuadraticCurveID, PintoInverter)) * PintoInverter; } PoutofInverter = PintoInverter - PpcuLosses; @@ -1992,8 +1962,6 @@ namespace FuelCellElectricGenerator { // PURPOSE OF THIS SUBROUTINE: // manage controls and calculations related to electrical storage in FuelCell model - using DataHVACGlobals::TimeStepSys; - Real64 tmpPdraw; // power draw from storage, working var Real64 tmpPcharge; // power charge to storage, working var bool drawing; // true if drawing power @@ -2042,20 +2010,20 @@ namespace FuelCellElectricGenerator { // now add energy to storage from charging if ((FuelCell(Num).ElecStorage.LastTimeStepStateOfCharge + - tmpPcharge * TimeStepSys * SecInHour * FuelCell(Num).ElecStorage.EnergeticEfficCharge) < + tmpPcharge * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour * FuelCell(Num).ElecStorage.EnergeticEfficCharge) < FuelCell(Num).ElecStorage.NominalEnergyCapacity) { FuelCell(Num).ElecStorage.ThisTimeStepStateOfCharge = FuelCell(Num).ElecStorage.LastTimeStepStateOfCharge + - tmpPcharge * TimeStepSys * SecInHour * FuelCell(Num).ElecStorage.EnergeticEfficCharge; + tmpPcharge * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour * FuelCell(Num).ElecStorage.EnergeticEfficCharge; } else { // would over charge this time step tmpPcharge = (FuelCell(Num).ElecStorage.NominalEnergyCapacity - FuelCell(Num).ElecStorage.LastTimeStepStateOfCharge) / - (TimeStepSys * SecInHour * FuelCell(Num).ElecStorage.EnergeticEfficCharge); + (DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour * FuelCell(Num).ElecStorage.EnergeticEfficCharge); Constrained = true; FuelCell(Num).ElecStorage.ThisTimeStepStateOfCharge = FuelCell(Num).ElecStorage.LastTimeStepStateOfCharge + - tmpPcharge * TimeStepSys * SecInHour * FuelCell(Num).ElecStorage.EnergeticEfficCharge; + tmpPcharge * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour * FuelCell(Num).ElecStorage.EnergeticEfficCharge; } // losses go into QairIntake @@ -2092,17 +2060,17 @@ namespace FuelCellElectricGenerator { // now take energy from storage by drawing (amplified by energetic effic) if ((FuelCell(Num).ElecStorage.LastTimeStepStateOfCharge - - tmpPdraw * TimeStepSys * SecInHour / FuelCell(Num).ElecStorage.EnergeticEfficDischarge) > 0.0) { + tmpPdraw * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour / FuelCell(Num).ElecStorage.EnergeticEfficDischarge) > 0.0) { FuelCell(Num).ElecStorage.ThisTimeStepStateOfCharge = FuelCell(Num).ElecStorage.LastTimeStepStateOfCharge - - tmpPdraw * TimeStepSys * SecInHour / FuelCell(Num).ElecStorage.EnergeticEfficDischarge; + tmpPdraw * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour / FuelCell(Num).ElecStorage.EnergeticEfficDischarge; } else { // would over drain storage this timestep so reduce tmpPdraw tmpPdraw = FuelCell(Num).ElecStorage.LastTimeStepStateOfCharge * FuelCell(Num).ElecStorage.EnergeticEfficDischarge / - (TimeStepSys * SecInHour); + (DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour); FuelCell(Num).ElecStorage.ThisTimeStepStateOfCharge = FuelCell(Num).ElecStorage.LastTimeStepStateOfCharge - - tmpPdraw * TimeStepSys * SecInHour / FuelCell(Num).ElecStorage.EnergeticEfficDischarge; + tmpPdraw * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour / FuelCell(Num).ElecStorage.EnergeticEfficDischarge; Constrained = true; } @@ -2223,8 +2191,8 @@ namespace FuelCellElectricGenerator { tempCp = 0.0; - Real64 const Tkel = (FluidTemp + KelvinConv); // temp for NASA eq. in Kelvin - Real64 const Tsho = (FluidTemp + KelvinConv) / 1000.0; // temp for Shomate eq in (Kelvin/1000) + Real64 const Tkel = (FluidTemp + DataGlobals::KelvinConv); // temp for NASA eq. in Kelvin + Real64 const Tsho = (FluidTemp + DataGlobals::KelvinConv) / 1000.0; // temp for Shomate eq in (Kelvin/1000) Real64 const pow_2_Tsho(pow_2(Tsho)); Real64 const pow_3_Tsho(pow_3(Tsho)); @@ -2304,8 +2272,8 @@ namespace FuelCellElectricGenerator { Real64 A5; // NASA poly coeff Real64 A6; // NASA poly coeff - Real64 const Tsho = (FluidTemp + KelvinConv) / 1000.0; // temp for Shomate eq in (Kelvin/1000) - Real64 const Tkel = (FluidTemp + KelvinConv); // temp for NASA eq. in Kelvin + Real64 const Tsho = (FluidTemp + DataGlobals::KelvinConv) / 1000.0; // temp for Shomate eq in (Kelvin/1000) + Real64 const Tkel = (FluidTemp + DataGlobals::KelvinConv); // temp for NASA eq. in Kelvin // loop through fuel constituents and sum up Cp @@ -2390,8 +2358,8 @@ namespace FuelCellElectricGenerator { Real64 A4; // NASA poly coeff Real64 A5; // NASA poly coeff - Real64 const Tsho = (FluidTemp + KelvinConv) / 1000.0; // temp for Shomate eq in (Kelvin/1000) - Real64 const Tkel = (FluidTemp + KelvinConv); // temp for NASA eq. in Kelvin + Real64 const Tsho = (FluidTemp + DataGlobals::KelvinConv) / 1000.0; // temp for Shomate eq in (Kelvin/1000) + Real64 const Tkel = (FluidTemp + DataGlobals::KelvinConv); // temp for NASA eq. in Kelvin // loop through fuel constituents and sum up Cp @@ -2474,8 +2442,8 @@ namespace FuelCellElectricGenerator { Real64 A5; // NASA poly coeff Real64 A6; // NASA poly coeff - Real64 const Tsho = (FluidTemp + KelvinConv) / 1000.0; // temp for Shomate eq in (Kelvin/1000) - Real64 const Tkel = (FluidTemp + KelvinConv); // temp for NASA eq. in Kelvin + Real64 const Tsho = (FluidTemp + DataGlobals::KelvinConv) / 1000.0; // temp for Shomate eq in (Kelvin/1000) + Real64 const Tkel = (FluidTemp + DataGlobals::KelvinConv); // temp for NASA eq. in Kelvin // loop through fuel constituents and sum up Cp @@ -2563,8 +2531,8 @@ namespace FuelCellElectricGenerator { Real64 A5; // NASA poly coeff Real64 A6; // NASA poly coeff - Real64 const Tsho = (FluidTemp + KelvinConv) / 1000.0; // temp for Shomate eq in (Kelvin/1000) - Real64 const Tkel = (FluidTemp + KelvinConv); // temp for NASA eq. in Kelvin + Real64 const Tsho = (FluidTemp + DataGlobals::KelvinConv) / 1000.0; // temp for Shomate eq in (Kelvin/1000) + Real64 const Tkel = (FluidTemp + DataGlobals::KelvinConv); // temp for NASA eq. in Kelvin // loop through fuel constituents and sum up Cp @@ -2637,8 +2605,8 @@ namespace FuelCellElectricGenerator { Real64 A4; // NASA poly coeff Real64 A5; // NASA poly coeff - Real64 const Tsho = (FluidTemp + KelvinConv) / 1000.0; // temp for Shomate eq in (Kelvin/1000) - Real64 const Tkel = (FluidTemp + KelvinConv); // temp for NASA eq. in Kelvin + Real64 const Tsho = (FluidTemp + DataGlobals::KelvinConv) / 1000.0; // temp for Shomate eq in (Kelvin/1000) + Real64 const Tkel = (FluidTemp + DataGlobals::KelvinConv); // temp for NASA eq. in Kelvin // loop through fuel constituents and sum up Cp @@ -2707,8 +2675,8 @@ namespace FuelCellElectricGenerator { Real64 A4; // NASA poly coeff Real64 A5; // NASA poly coeff - Real64 const Tsho = (FluidTemp + KelvinConv) / 1000.0; // temp for Shomate eq in (Kelvin/1000) - Real64 const Tkel = (FluidTemp + KelvinConv); // temp for NASA eq. in Kelvin + Real64 const Tsho = (FluidTemp + DataGlobals::KelvinConv) / 1000.0; // temp for Shomate eq in (Kelvin/1000) + Real64 const Tkel = (FluidTemp + DataGlobals::KelvinConv); // temp for NASA eq. in Kelvin // loop through fuel constituents and sum up Cp @@ -2775,7 +2743,7 @@ namespace FuelCellElectricGenerator { Real64 const D = -0.95914; // shomate coeff Real64 const E = 0.11725; // shomate coeff Real64 const F = -250.569; // shomate coeff - Real64 const Tsho = (FluidTemp + KelvinConv) / 1000.0; // temp for Shomate eq in (Kelvin/1000) + Real64 const Tsho = (FluidTemp + DataGlobals::KelvinConv) / 1000.0; // temp for Shomate eq in (Kelvin/1000) HGasWater = A * Tsho + B * pow_2(Tsho) / 2.0 + C * pow_3(Tsho) / 3.0 + D * pow_4(Tsho) / 4.0 - E / Tsho + F; //- H } @@ -2805,7 +2773,7 @@ namespace FuelCellElectricGenerator { Real64 const E = 3.85533; // shomate coeff Real64 const F = -256.5478; // shomate coeff - Real64 const Tsho = (FluidTemp + KelvinConv) / 1000.0; // temp for Shomate eq in (Kelvin/1000) + Real64 const Tsho = (FluidTemp + DataGlobals::KelvinConv) / 1000.0; // temp for Shomate eq in (Kelvin/1000) HLiqWater = A * Tsho + B * pow_2(Tsho) / 2.0 + C * pow_3(Tsho) / 3.0 + D * pow_4(Tsho) / 4.0 - E / Tsho + F; //- H } @@ -2829,7 +2797,7 @@ namespace FuelCellElectricGenerator { Real64 const C = -3196.413; // shomate coeff Real64 const D = 2474.455; // shomate coeff Real64 const E = 3.85533; // shomate coeff - Real64 const Tsho = (FluidTemp + KelvinConv) / 1000.0; + Real64 const Tsho = (FluidTemp + DataGlobals::KelvinConv) / 1000.0; Cp = A + B * Tsho + C * pow_2(Tsho) + D * pow_3(Tsho) + E / pow_2(Tsho); } @@ -2846,8 +2814,6 @@ namespace FuelCellElectricGenerator { // PURPOSE OF THIS SUBROUTINE: // Calculate the AC ancillaries to determine Pel - using CurveManager::CurveValue; - // Using lagged values inside a sequential substitution loop PacAncill = 0.0; // sect. 5.9 @@ -2855,14 +2821,14 @@ namespace FuelCellElectricGenerator { FuelCell(GeneratorNum).FCPM.ANC0 + FuelCell(GeneratorNum).FCPM.ANC1 * FuelCell(GeneratorNum).FCPM.NdotFuel; // sect 6.0 - FuelCell(GeneratorNum).AirSup.PairCompEl = CurveValue(FuelCell(GeneratorNum).AirSup.BlowerPowerCurveID, FuelCell(GeneratorNum).FCPM.NdotAir); + FuelCell(GeneratorNum).AirSup.PairCompEl = CurveManager::CurveValue(FuelCell(GeneratorNum).AirSup.BlowerPowerCurveID, FuelCell(GeneratorNum).FCPM.NdotAir); // sect 7.0 FuelSupply(FuelCell(GeneratorNum).FuelSupNum).PfuelCompEl = - CurveValue(FuelSupply(FuelCell(GeneratorNum).FuelSupNum).CompPowerCurveID, FuelCell(GeneratorNum).FCPM.NdotFuel); + CurveManager::CurveValue(FuelSupply(FuelCell(GeneratorNum).FuelSupNum).CompPowerCurveID, FuelCell(GeneratorNum).FCPM.NdotFuel); // sect. 8.0 FuelCell(GeneratorNum).WaterSup.PwaterCompEl = - CurveValue(FuelCell(GeneratorNum).WaterSup.PmpPowerCurveID, FuelCell(GeneratorNum).FCPM.NdotLiqwater); + CurveManager::CurveValue(FuelCell(GeneratorNum).WaterSup.PmpPowerCurveID, FuelCell(GeneratorNum).FCPM.NdotLiqwater); PacAncill = FuelCell(GeneratorNum).FCPM.PelancillariesAC + FuelCell(GeneratorNum).AirSup.PairCompEl + FuelSupply(FuelCell(GeneratorNum).FuelSupNum).PfuelCompEl + FuelCell(GeneratorNum).WaterSup.PwaterCompEl; @@ -2880,8 +2846,6 @@ namespace FuelCellElectricGenerator { // PURPOSE OF THIS SUBROUTINE: // Calculate inverter losses - using CurveManager::CurveValue; - Real64 lastPpcuLosses; // used in iterative solution int iter; Real64 Pel; @@ -2894,14 +2858,14 @@ namespace FuelCellElectricGenerator { if (FuelCell(GeneratorNum).Inverter.EffMode == InverterEffQuadratic) { // first use Pdemand instead of Pel to get initial estimate - lastPpcuLosses = Pdemand * (1.0 - CurveValue(FuelCell(GeneratorNum).Inverter.EffQuadraticCurveID, Pdemand)) / - CurveValue(FuelCell(GeneratorNum).Inverter.EffQuadraticCurveID, Pdemand); + lastPpcuLosses = Pdemand * (1.0 - CurveManager::CurveValue(FuelCell(GeneratorNum).Inverter.EffQuadraticCurveID, Pdemand)) / + CurveManager::CurveValue(FuelCell(GeneratorNum).Inverter.EffQuadraticCurveID, Pdemand); for (iter = 1; iter <= 20; ++iter) { // seems like need to iterate (??) Need to investigate number and convergence success here Pel = Pdemand + lastPpcuLosses; - lastPpcuLosses = (1.0 - CurveValue(FuelCell(GeneratorNum).Inverter.EffQuadraticCurveID, Pel)) * Pel; + lastPpcuLosses = (1.0 - CurveManager::CurveValue(FuelCell(GeneratorNum).Inverter.EffQuadraticCurveID, Pel)) * Pel; } PpcuLosses = lastPpcuLosses; @@ -2921,9 +2885,6 @@ namespace FuelCellElectricGenerator { // MODIFIED na // RE-ENGINEERED na - using DataHVACGlobals::SysTimeElapsed; - using DataHVACGlobals::TimeStepSys; - Real64 CurrentFractionalDay; // working var, time in decimal days Real64 EndingFractionalDay; // working var, time is decimal days Real64 MaxPel; // working variable for max allowed by transient constraint @@ -2936,9 +2897,9 @@ namespace FuelCellElectricGenerator { if (FuelCell(GeneratorNum).FCPM.DuringStartUp) { // calculate time for end of start up period - CurrentFractionalDay = double(DayOfSim) + (int(CurrentTime) + (SysTimeElapsed + (CurrentTime - int(CurrentTime)))) / HoursInDay; + CurrentFractionalDay = double(DataGlobals::DayOfSim) + (int(DataGlobals::CurrentTime) + (DataHVACGlobals::SysTimeElapsed + (DataGlobals::CurrentTime - int(DataGlobals::CurrentTime)))) / DataGlobals::HoursInDay; - EndingFractionalDay = FuelCell(GeneratorNum).FCPM.FractionalDayofLastStartUp + FuelCell(GeneratorNum).FCPM.StartUpTime / HoursInDay; + EndingFractionalDay = FuelCell(GeneratorNum).FCPM.FractionalDayofLastStartUp + FuelCell(GeneratorNum).FCPM.StartUpTime / DataGlobals::HoursInDay; if (CurrentFractionalDay > EndingFractionalDay) { // start up period is now over @@ -2950,9 +2911,9 @@ namespace FuelCellElectricGenerator { if (FuelCell(GeneratorNum).FCPM.DuringShutDown) { // calculate time for end of shut down period - CurrentFractionalDay = double(DayOfSim) + (int(CurrentTime) + (SysTimeElapsed + (CurrentTime - int(CurrentTime)))) / HoursInDay; + CurrentFractionalDay = double(DataGlobals::DayOfSim) + (int(DataGlobals::CurrentTime) + (DataHVACGlobals::SysTimeElapsed + (DataGlobals::CurrentTime - int(DataGlobals::CurrentTime)))) / DataGlobals::HoursInDay; - EndingFractionalDay = FuelCell(GeneratorNum).FCPM.FractionalDayofLastShutDown + FuelCell(GeneratorNum).FCPM.ShutDownTime / HoursInDay; + EndingFractionalDay = FuelCell(GeneratorNum).FCPM.FractionalDayofLastShutDown + FuelCell(GeneratorNum).FCPM.ShutDownTime / DataGlobals::HoursInDay; if (CurrentFractionalDay > EndingFractionalDay) { // start up period is now over @@ -2964,7 +2925,7 @@ namespace FuelCellElectricGenerator { if (!(FuelCell(GeneratorNum).FCPM.DuringShutDown) && !(FuelCell(GeneratorNum).FCPM.DuringStartUp)) { // unit is neither starting or stopping and the only constraints would come from transient limits if (Pel > FuelCell(GeneratorNum).FCPM.PelLastTimeStep) { // powering up - MaxPel = FuelCell(GeneratorNum).FCPM.PelLastTimeStep + FuelCell(GeneratorNum).FCPM.UpTranLimit * TimeStepSys * SecInHour; + MaxPel = FuelCell(GeneratorNum).FCPM.PelLastTimeStep + FuelCell(GeneratorNum).FCPM.UpTranLimit * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; if (MaxPel < Pel) { Pel = MaxPel; Constrained = true; @@ -2972,7 +2933,7 @@ namespace FuelCellElectricGenerator { Constrained = false; } } else if (Pel < FuelCell(GeneratorNum).FCPM.PelLastTimeStep) { // powering down - MinPel = FuelCell(GeneratorNum).FCPM.PelLastTimeStep - FuelCell(GeneratorNum).FCPM.DownTranLimit * TimeStepSys * SecInHour; + MinPel = FuelCell(GeneratorNum).FCPM.PelLastTimeStep - FuelCell(GeneratorNum).FCPM.DownTranLimit * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; if (Pel < MinPel) { Pel = MinPel; Constrained = true; @@ -3029,7 +2990,6 @@ namespace FuelCellElectricGenerator { // REFERENCES: Annex 42 model documentation - using DataPlant::PlantLoop; using FluidProperties::GetSpecificHeatGlycol; static std::string const RoutineName("CalcFuelCellGenHeatRecovery"); @@ -3095,7 +3055,7 @@ namespace FuelCellElectricGenerator { THXexh = TprodGasIn - qHX / (NdotGas * CpProdGasMol * 1000.0); Cp = GetSpecificHeatGlycol( - PlantLoop(FuelCell(Num).CWLoopNum).FluidName, TwaterIn, PlantLoop(FuelCell(Num).CWLoopNum).FluidIndex, RoutineName); + DataPlant::PlantLoop(FuelCell(Num).CWLoopNum).FluidName, TwaterIn, DataPlant::PlantLoop(FuelCell(Num).CWLoopNum).FluidIndex, RoutineName); if (MdotWater * Cp <= 0.0) { TwaterOut = TwaterIn; @@ -3333,10 +3293,6 @@ namespace FuelCellElectricGenerator { // makes sure input are gotten and setup from Plant loop perspective. // does not (re)simulate entire FuelCell model - using DataPlant::TypeOf_Generator_FCExhaust; - using DataPlant::TypeOf_Generator_FCStackCooler; - using PlantUtilities::UpdateComponentHeatRecoverySide; - if (GetFuelCellInput) { // Read input data. @@ -3345,9 +3301,9 @@ namespace FuelCellElectricGenerator { } if (InitLoopEquip) { - if (CompTypeNum == TypeOf_Generator_FCExhaust) { + if (CompTypeNum == DataPlant::TypeOf_Generator_FCExhaust) { CompNum = UtilityRoutines::FindItemInList(CompName, FuelCell, &FCDataStruct::NameExhaustHX); - } else if (CompTypeNum == TypeOf_Generator_FCStackCooler) { + } else if (CompTypeNum == DataPlant::TypeOf_Generator_FCStackCooler) { CompNum = UtilityRoutines::FindItemInList(CompName, FuelCell, &FCDataStruct::NameStackCooler); } if (CompNum == 0) { @@ -3359,10 +3315,10 @@ namespace FuelCellElectricGenerator { return; } // End Of InitLoopEquip - if (CompTypeNum == TypeOf_Generator_FCStackCooler) { - UpdateComponentHeatRecoverySide(FuelCell(CompNum).CWLoopNum, + if (CompTypeNum == DataPlant::TypeOf_Generator_FCStackCooler) { + PlantUtilities::UpdateComponentHeatRecoverySide(FuelCell(CompNum).CWLoopNum, FuelCell(CompNum).CWLoopSideNum, - TypeOf_Generator_FCStackCooler, + DataPlant::TypeOf_Generator_FCStackCooler, FuelCell(CompNum).StackCooler.WaterInNode, FuelCell(CompNum).StackCooler.WaterOutNode, FuelCell(CompNum).Report.qHX, @@ -3370,10 +3326,10 @@ namespace FuelCellElectricGenerator { FuelCell(CompNum).Report.HeatRecOutletTemp, FuelCell(CompNum).Report.HeatRecMdot, FirstHVACIteration); - } else if (CompTypeNum == TypeOf_Generator_FCExhaust) { - UpdateComponentHeatRecoverySide(FuelCell(CompNum).CWLoopNum, + } else if (CompTypeNum == DataPlant::TypeOf_Generator_FCExhaust) { + PlantUtilities::UpdateComponentHeatRecoverySide(FuelCell(CompNum).CWLoopNum, FuelCell(CompNum).CWLoopSideNum, - TypeOf_Generator_FCExhaust, + DataPlant::TypeOf_Generator_FCExhaust, FuelCell(CompNum).ExhaustHX.WaterInNode, FuelCell(CompNum).ExhaustHX.WaterOutNode, FuelCell(CompNum).ExhaustHX.qHX, @@ -3399,20 +3355,8 @@ namespace FuelCellElectricGenerator { // METHODOLOGY EMPLOYED: // Uses the status flags to trigger initializations. - using DataGlobals::BeginEnvrnFlag; - using DataGlobals::HourOfDay; - using DataGlobals::SecInHour; - using DataGlobals::TimeStep; - using DataGlobals::TimeStepZone; - using DataHVACGlobals::SysTimeElapsed; - using DataHVACGlobals::TimeStepSys; using DataLoopNode::Node; - using DataPlant::PlantLoop; - using DataPlant::TypeOf_Generator_FCExhaust; using FluidProperties::GetDensityGlycol; - using PlantUtilities::InitComponentNodes; - using PlantUtilities::ScanPlantLoopsForObject; - using PlantUtilities::SetComponentFlowRate; static std::string const RoutineName("InitFuelCellGenerators"); @@ -3438,11 +3382,11 @@ namespace FuelCellElectricGenerator { MyPlantScanFlag = true; } // end one time setups and inits - if (MyPlantScanFlag(FCnum) && allocated(PlantLoop)) { + if (MyPlantScanFlag(FCnum) && allocated(DataPlant::PlantLoop)) { errFlag = false; - ScanPlantLoopsForObject(FuelCell(FCnum).NameExhaustHX, - TypeOf_Generator_FCExhaust, + PlantUtilities::ScanPlantLoopsForObject(FuelCell(FCnum).NameExhaustHX, + DataPlant::TypeOf_Generator_FCExhaust, FuelCell(FCnum).CWLoopNum, FuelCell(FCnum).CWLoopSideNum, FuelCell(FCnum).CWBranchNum, @@ -3463,7 +3407,7 @@ namespace FuelCellElectricGenerator { } // Do the Begin Environment initializations - if (BeginEnvrnFlag && MyEnvrnFlag(FCnum) && !MyPlantScanFlag(FCnum)) { + if (DataGlobals::BeginEnvrnFlag && MyEnvrnFlag(FCnum) && !MyPlantScanFlag(FCnum)) { FuelSupply(FuelCell(FCnum).FuelSupNum).PfuelCompEl = 0.0; FuelSupply(FuelCell(FCnum).FuelSupNum).TfuelIntoFCPM = 0.0; @@ -3520,7 +3464,7 @@ namespace FuelCellElectricGenerator { FuelCell(FCnum).Inverter.QairIntake = 0.0; rho = GetDensityGlycol( - PlantLoop(FuelCell(FCnum).CWLoopNum).FluidName, InitHRTemp, PlantLoop(FuelCell(FCnum).CWLoopNum).FluidIndex, RoutineName); + DataPlant::PlantLoop(FuelCell(FCnum).CWLoopNum).FluidName, InitHRTemp, DataPlant::PlantLoop(FuelCell(FCnum).CWLoopNum).FluidIndex, RoutineName); FuelCell(FCnum).ExhaustHX.WaterMassFlowRateDesign = FuelCell(FCnum).ExhaustHX.WaterVolumeFlowMax * rho; FuelCell(FCnum).ExhaustHX.WaterMassFlowRate = FuelCell(FCnum).ExhaustHX.WaterMassFlowRateDesign; @@ -3529,7 +3473,7 @@ namespace FuelCellElectricGenerator { Node(inNode).Temp = InitHRTemp; Node(outNode).Temp = InitHRTemp; - InitComponentNodes(0.0, + PlantUtilities::InitComponentNodes(0.0, FuelCell(FCnum).ExhaustHX.WaterMassFlowRateDesign, inNode, outNode, @@ -3542,11 +3486,11 @@ namespace FuelCellElectricGenerator { MyWarmupFlag(FCnum) = true; } // end environmental inits - if (!BeginEnvrnFlag) { + if (!DataGlobals::BeginEnvrnFlag) { MyEnvrnFlag(FCnum) = true; } - if (MyWarmupFlag(FCnum) && (!WarmupFlag)) { + if (MyWarmupFlag(FCnum) && (!DataGlobals::WarmupFlag)) { // need to reset initial state of charge at beginning of environment but after warm up is complete FuelCell(FCnum).ElecStorage.LastTimeStepStateOfCharge = FuelCell(FCnum).ElecStorage.StartingEnergyStored; FuelCell(FCnum).ElecStorage.ThisTimeStepStateOfCharge = FuelCell(FCnum).ElecStorage.StartingEnergyStored; @@ -3554,7 +3498,7 @@ namespace FuelCellElectricGenerator { } // using and elapsed time method rather than FirstHVACIteration here - TimeElapsed = HourOfDay + TimeStep * TimeStepZone + SysTimeElapsed; + TimeElapsed = DataGlobals::HourOfDay + DataGlobals::TimeStep * DataGlobals::TimeStepZone + DataHVACGlobals::SysTimeElapsed; if (FuelCell(FCnum).TimeElapsed != TimeElapsed) { FuelCell(FCnum).ElecStorage.LastTimeStepStateOfCharge = FuelCell(FCnum).ElecStorage.ThisTimeStepStateOfCharge; @@ -3565,7 +3509,7 @@ namespace FuelCellElectricGenerator { // intialize flow rate in water loop, this is "requesting" flow mdot = FuelCell(FCnum).ExhaustHX.WaterMassFlowRateDesign; - SetComponentFlowRate(mdot, + PlantUtilities::SetComponentFlowRate(mdot, inNode, outNode, FuelCell(FCnum).CWLoopNum, @@ -3579,7 +3523,7 @@ namespace FuelCellElectricGenerator { } else { inNode = FuelCell(FCnum).ExhaustHX.WaterInNode; - SetComponentFlowRate(FuelCell(FCnum).ExhaustHX.WaterMassFlowRate, + PlantUtilities::SetComponentFlowRate(FuelCell(FCnum).ExhaustHX.WaterMassFlowRate, FuelCell(FCnum).ExhaustHX.WaterInNode, FuelCell(FCnum).ExhaustHX.WaterOutNode, FuelCell(FCnum).CWLoopNum, @@ -3631,7 +3575,7 @@ namespace FuelCellElectricGenerator { if (NumFuelCellGenerators == 0) return; - if (BeginEnvrnFlag && MyEnvrnFlag) { + if (DataGlobals::BeginEnvrnFlag && MyEnvrnFlag) { for (auto &e : FuelSupply) e.QskinLoss = 0.0; MyEnvrnFlag = false; @@ -3653,7 +3597,7 @@ namespace FuelCellElectricGenerator { } } - if (!BeginEnvrnFlag) MyEnvrnFlag = true; + if (!DataGlobals::BeginEnvrnFlag) MyEnvrnFlag = true; // this routine needs to do something for zone gains during sizing @@ -3709,8 +3653,6 @@ namespace FuelCellElectricGenerator { // PURPOSE OF THIS SUBROUTINE: // update plant loop interactions, do any calcs needed - using PlantUtilities::SafeCopyPlantNode; - int InNodeNum; int OutNodeNum; @@ -3718,7 +3660,7 @@ namespace FuelCellElectricGenerator { OutNodeNum = FuelCell(Num).ExhaustHX.WaterOutNode; InNodeNum = FuelCell(Num).ExhaustHX.WaterInNode; - SafeCopyPlantNode(InNodeNum, OutNodeNum); + PlantUtilities::SafeCopyPlantNode(InNodeNum, OutNodeNum); Node(OutNodeNum).Temp = FuelCell(Num).ExhaustHX.WaterOutletTemp; Node(OutNodeNum).Enthalpy = FuelCell(Num).ExhaustHX.WaterOutletEnthalpy; @@ -3728,14 +3670,8 @@ namespace FuelCellElectricGenerator { int const Num // Generator number ) { - // SUBROUTINE INFORMATION: - // AUTHOR: BG - // DATE WRITTEN: - - using DataHVACGlobals::TimeStepSys; - FuelCell(Num).Report.ACPowerGen = FuelCell(Num).ACPowerGen; // electrical power produced [W] - FuelCell(Num).Report.ACEnergyGen = FuelCell(Num).ACPowerGen * TimeStepSys * SecInHour; // energy produced (J) + FuelCell(Num).Report.ACEnergyGen = FuelCell(Num).ACPowerGen * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; // energy produced (J) FuelCell(Num).Report.QdotExhaust = 0.0; // reporting: exhaust gas heat recovered (W) FuelCell(Num).Report.TotalHeatEnergyRec = 0.0; // reporting: total heat recovered (J) FuelCell(Num).Report.ExhaustEnergyRec = 0.0; // reporting: exhaust gas heat recovered (J) @@ -3754,7 +3690,7 @@ namespace FuelCellElectricGenerator { FuelCell(Num).Report.NdotAir = FuelCell(Num).FCPM.NdotAir; // air flow in kmol/sec FuelCell(Num).Report.TotAirInEnthalphy = FuelCell(Num).FCPM.TotAirInEnthalphy; // State point 4 FuelCell(Num).Report.BlowerPower = FuelCell(Num).AirSup.PairCompEl; // electrical power used by air supply blower - FuelCell(Num).Report.BlowerEnergy = FuelCell(Num).AirSup.PairCompEl * TimeStepSys * SecInHour; // electrical energy + FuelCell(Num).Report.BlowerEnergy = FuelCell(Num).AirSup.PairCompEl * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; // electrical energy FuelCell(Num).Report.BlowerSkinLoss = FuelCell(Num).AirSup.QskinLoss; // heat rate of losses by blower FuelCell(Num).Report.TfuelInlet = FuelSupply(FuelCell(Num).FuelSupNum).TfuelIntoCompress; // State point 2 @@ -3763,15 +3699,15 @@ namespace FuelCellElectricGenerator { FuelCell(Num).Report.TotFuelInEnthalpy = FuelCell(Num).FCPM.TotFuelInEnthalphy; // enthalpy at state point 5 [W] FuelCell(Num).Report.FuelCompressPower = FuelSupply(FuelCell(Num).FuelSupNum).PfuelCompEl; // electrical power used by fuel supply compressor [W] - FuelCell(Num).Report.FuelCompressEnergy = FuelSupply(FuelCell(Num).FuelSupNum).PfuelCompEl * TimeStepSys * SecInHour; // elect energy + FuelCell(Num).Report.FuelCompressEnergy = FuelSupply(FuelCell(Num).FuelSupNum).PfuelCompEl * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; // elect energy FuelCell(Num).Report.FuelCompressSkinLoss = FuelSupply(FuelCell(Num).FuelSupNum).QskinLoss; // heat rate of losses.by fuel supply compressor [W] - FuelCell(Num).Report.FuelEnergyLHV = FuelCell(Num).FCPM.NdotFuel * FuelSupply(FuelCell(Num).FuelSupNum).LHV * 1000000.0 * TimeStepSys * - SecInHour; // reporting: Fuel Energy used (J) + FuelCell(Num).Report.FuelEnergyLHV = FuelCell(Num).FCPM.NdotFuel * FuelSupply(FuelCell(Num).FuelSupNum).LHV * 1000000.0 * DataHVACGlobals::TimeStepSys * + DataGlobals::SecInHour; // reporting: Fuel Energy used (J) FuelCell(Num).Report.FuelEnergyUseRateLHV = FuelCell(Num).FCPM.NdotFuel * FuelSupply(FuelCell(Num).FuelSupNum).LHV * 1000000.0; // reporting: Fuel Energy used (W) FuelCell(Num).Report.FuelEnergyHHV = FuelCell(Num).FCPM.NdotFuel * FuelSupply(FuelCell(Num).FuelSupNum).HHV * - FuelSupply(FuelCell(Num).FuelSupNum).KmolPerSecToKgPerSec * TimeStepSys * SecInHour; + FuelSupply(FuelCell(Num).FuelSupNum).KmolPerSecToKgPerSec * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; FuelCell(Num).Report.FuelEnergyUseRateHHV = FuelCell(Num).FCPM.NdotFuel * FuelSupply(FuelCell(Num).FuelSupNum).HHV * FuelSupply(FuelCell(Num).FuelSupNum).KmolPerSecToKgPerSec; @@ -3782,7 +3718,7 @@ namespace FuelCellElectricGenerator { FuelCell(Num).Report.TwaterIntoFCPM = FuelCell(Num).WaterSup.TwaterIntoFCPM; FuelCell(Num).Report.NdotWater = FuelCell(Num).FCPM.NdotLiqwater; // water flow in kmol/sec (reformer water) FuelCell(Num).Report.WaterPumpPower = FuelCell(Num).WaterSup.PwaterCompEl; - FuelCell(Num).Report.WaterPumpEnergy = FuelCell(Num).WaterSup.PwaterCompEl * TimeStepSys * SecInHour; // electrical energy + FuelCell(Num).Report.WaterPumpEnergy = FuelCell(Num).WaterSup.PwaterCompEl * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; // electrical energy FuelCell(Num).Report.WaterIntoFCPMEnthalpy = FuelCell(Num).FCPM.WaterInEnthalpy; FuelCell(Num).Report.TprodGas = FuelCell(Num).FCPM.TprodGasLeavingFCPM; // temperature at State point 7 @@ -3795,7 +3731,7 @@ namespace FuelCellElectricGenerator { FuelCell(Num).Report.NdotProdO2 = FuelCell(Num).FCPM.ConstitMolalFract(3) * FuelCell(Num).FCPM.NdotProdGas; FuelCell(Num).Report.qHX = FuelCell(Num).ExhaustHX.qHX; - FuelCell(Num).Report.HXenergy = FuelCell(Num).ExhaustHX.qHX * TimeStepSys * SecInHour; + FuelCell(Num).Report.HXenergy = FuelCell(Num).ExhaustHX.qHX * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; FuelCell(Num).Report.THXexh = FuelCell(Num).ExhaustHX.THXexh; FuelCell(Num).Report.WaterVaporFractExh = FuelCell(Num).ExhaustHX.WaterVaporFractExh; FuelCell(Num).Report.CondensateRate = FuelCell(Num).ExhaustHX.CondensateRate; @@ -3804,19 +3740,19 @@ namespace FuelCellElectricGenerator { FuelCell(Num).Report.RegulaFalsiIterations = FuelCell(Num).FCPM.RegulaFalsiIter; // number of iterations in Tproduct gas solving FuelCell(Num).Report.ACancillariesPower = FuelCell(Num).FCPM.PelancillariesAC; - FuelCell(Num).Report.ACancillariesEnergy = FuelCell(Num).FCPM.PelancillariesAC * TimeStepSys * SecInHour; + FuelCell(Num).Report.ACancillariesEnergy = FuelCell(Num).FCPM.PelancillariesAC * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; FuelCell(Num).Report.PCUlosses = FuelCell(Num).Inverter.PCUlosses; // inverter losses FuelCell(Num).Report.DCPowerGen = FuelCell(Num).FCPM.Pel; // DC power out of FCPM. FuelCell(Num).Report.DCPowerEff = FuelCell(Num).FCPM.Eel; // FCPM efficienty Eel. FuelCell(Num).Report.ElectEnergyinStorage = FuelCell(Num).ElecStorage.ThisTimeStepStateOfCharge; FuelCell(Num).Report.StoredPower = FuelCell(Num).ElecStorage.PelIntoStorage; - FuelCell(Num).Report.StoredEnergy = FuelCell(Num).ElecStorage.PelIntoStorage * TimeStepSys * SecInHour; + FuelCell(Num).Report.StoredEnergy = FuelCell(Num).ElecStorage.PelIntoStorage * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; FuelCell(Num).Report.DrawnPower = FuelCell(Num).ElecStorage.PelFromStorage; - FuelCell(Num).Report.DrawnEnergy = FuelCell(Num).ElecStorage.PelFromStorage * TimeStepSys * SecInHour; + FuelCell(Num).Report.DrawnEnergy = FuelCell(Num).ElecStorage.PelFromStorage * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; FuelCell(Num).Report.SkinLossPower = FuelCell(Num).QconvZone + FuelCell(Num).QradZone; - FuelCell(Num).Report.SkinLossEnergy = (FuelCell(Num).QconvZone + FuelCell(Num).QradZone) * TimeStepSys * SecInHour; + FuelCell(Num).Report.SkinLossEnergy = (FuelCell(Num).QconvZone + FuelCell(Num).QradZone) * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; FuelCell(Num).Report.SkinLossConvect = FuelCell(Num).QconvZone; FuelCell(Num).Report.SkinLossRadiat = FuelCell(Num).QradZone; } From eebcc987d9cbb745bc79c4aed9534cfae65d1b7c Mon Sep 17 00:00:00 2001 From: Li Date: Thu, 24 Oct 2019 20:15:31 -0600 Subject: [PATCH 11/51] WaterUse has two structs in one file. It looks like they are not good for using member functions. I tried and member functions totally screwedup other files. --- src/EnergyPlus/WaterUse.cc | 5 +++-- src/EnergyPlus/WaterUse.hh | 35 +++++++++++++++++++++-------------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/src/EnergyPlus/WaterUse.cc b/src/EnergyPlus/WaterUse.cc index f6203e078c9..a7a372dd176 100644 --- a/src/EnergyPlus/WaterUse.cc +++ b/src/EnergyPlus/WaterUse.cc @@ -221,12 +221,13 @@ namespace WaterUse { UpdateWaterConnections(WaterConnNum); - ReportWaterUse(WaterConnNum); + ReportWaterUse(WaterConnNum); } // WaterConnNum } - void SimulateWaterUseConnection(int EP_UNUSED(EquipTypeNum), std::string &CompName, int &CompIndex, bool InitLoopEquip, bool FirstHVACIteration) + void SimulateWaterUseConnection( + int EP_UNUSED(EquipTypeNum), std::string &CompName, int &CompIndex, bool InitLoopEquip, bool FirstHVACIteration) { // SUBROUTINE INFORMATION: diff --git a/src/EnergyPlus/WaterUse.hh b/src/EnergyPlus/WaterUse.hh index d1e6fdfea2f..d16b5c19dcb 100644 --- a/src/EnergyPlus/WaterUse.hh +++ b/src/EnergyPlus/WaterUse.hh @@ -54,6 +54,7 @@ // EnergyPlus Headers #include #include +#include namespace EnergyPlus { @@ -139,7 +140,7 @@ namespace WaterUse { { } - // Reset Some Values to Zeros + void reset() { SensibleRate = 0.0; @@ -150,9 +151,10 @@ namespace WaterUse { TotalMassFlowRate = 0.0; DrainTemp = 0.0; } + }; - struct WaterConnectionsType + struct WaterConnectionsType { // Members std::string Name; // Name of DHW @@ -220,6 +222,7 @@ namespace WaterUse { int PlantLoopSide; int PlantLoopBranchNum; int PlantLoopCompNum; + // Default Constructor WaterConnectionsType() @@ -235,31 +238,24 @@ namespace WaterUse { PlantLoopNum(0), PlantLoopSide(0), PlantLoopBranchNum(0), PlantLoopCompNum(0) { } + + }; - // Object Data - extern Array1D WaterEquipment; - extern Array1D WaterConnections; + // Functions void clear_state(); - void SimulateWaterUse(bool FirstHVACIteration); - - void SimulateWaterUseConnection( - int EquipTypeNum, std::string &CompName, int &CompIndex, bool InitLoopEquip, bool FirstHVACIteration); - void GetWaterUseInput(); - + void SetupOutputVars(); void CalcEquipmentFlowRates(int WaterEquipNum); void CalcEquipmentDrainTemp(int WaterEquipNum); - void InitConnections(int WaterConnNum); - void CalcConnectionsFlowRates(int WaterConnNum, bool FirstHVACIteration); void CalcConnectionsDrainTemp(int WaterConnNum); @@ -267,13 +263,24 @@ namespace WaterUse { void CalcConnectionsHeatRecovery(int WaterConnNum); void UpdateWaterConnections(int WaterConnNum); + + void InitConnections(int WaterConnNum); - void ReportStandAloneWaterUse(); + void SimulateWaterUse(bool FirstHVACIteration); void ReportWaterUse(int WaterConnNum); void CalcWaterUseZoneGains(); + void SimulateWaterUseConnection(int EquipTypeNum, std::string &CompName, int &CompIndex, bool InitLoopEquip, bool FirstHVACIteration); + + void ReportStandAloneWaterUse(); + + // Object Data + extern Array1D WaterEquipment; + extern Array1D WaterConnections; + + } // namespace WaterUse } // namespace EnergyPlus From f5da8f32bbd0092e23751fa1a0c85bcabb1b036d Mon Sep 17 00:00:00 2001 From: Li Date: Sun, 3 Nov 2019 20:03:46 -0700 Subject: [PATCH 12/51] functions are member methods; using this->; more oop style; --- src/EnergyPlus/WaterUse.cc | 431 +++++++++++++++++++------------------ src/EnergyPlus/WaterUse.hh | 33 +-- 2 files changed, 235 insertions(+), 229 deletions(-) diff --git a/src/EnergyPlus/WaterUse.cc b/src/EnergyPlus/WaterUse.cc index a7a372dd176..847891b7fc1 100644 --- a/src/EnergyPlus/WaterUse.cc +++ b/src/EnergyPlus/WaterUse.cc @@ -190,16 +190,17 @@ namespace WaterUse { if (!WaterConnections(WaterConnNum).StandAlone) continue; // only model non plant connections here - InitConnections(WaterConnNum); + auto &thisWC = WaterConnections(WaterConnNum); + thisWC.InitConnections(); NumIteration = 0; while (true) { ++NumIteration; - CalcConnectionsFlowRates(WaterConnNum, FirstHVACIteration); - CalcConnectionsDrainTemp(WaterConnNum); - CalcConnectionsHeatRecovery(WaterConnNum); + thisWC.CalcConnectionsFlowRates( FirstHVACIteration); + thisWC.CalcConnectionsDrainTemp( ); + thisWC.CalcConnectionsHeatRecovery( ); if (WaterConnections(WaterConnNum).TempError < Tolerance) { break; @@ -219,13 +220,20 @@ namespace WaterUse { } // WHILE - UpdateWaterConnections(WaterConnNum); + thisWC.UpdateWaterConnections( ); - ReportWaterUse(WaterConnNum); + thisWC.ReportWaterUse( ); } // WaterConnNum } + + void WaterConnectionsType::simulate(const PlantLocation &calledFromLocation, bool FirstHVACIteration, Real64 &CurLoad, bool RunFlag) + { + + } + + void SimulateWaterUseConnection( int EP_UNUSED(EquipTypeNum), std::string &CompName, int &CompIndex, bool InitLoopEquip, bool FirstHVACIteration) { @@ -302,16 +310,18 @@ namespace WaterUse { if (!DataGlobals::BeginEnvrnFlag) MyEnvrnFlag = true; - InitConnections(WaterConnNum); + auto &thisWC = WaterConnections(WaterConnNum); + + thisWC.InitConnections( ); NumIteration = 0; while (true) { ++NumIteration; - CalcConnectionsFlowRates(WaterConnNum, FirstHVACIteration); - CalcConnectionsDrainTemp(WaterConnNum); - CalcConnectionsHeatRecovery(WaterConnNum); + thisWC.CalcConnectionsFlowRates(FirstHVACIteration); + thisWC.CalcConnectionsDrainTemp( ); + thisWC.CalcConnectionsHeatRecovery( ); if (WaterConnections(WaterConnNum).TempError < Tolerance) { break; @@ -331,9 +341,9 @@ namespace WaterUse { } // WHILE - UpdateWaterConnections(WaterConnNum); + thisWC.UpdateWaterConnections( ); - ReportWaterUse(WaterConnNum); + thisWC.ReportWaterUse( ); } void GetWaterUseInput() @@ -591,7 +601,7 @@ namespace WaterUse { WaterConnections(WaterConnNum).HXUA = DataIPShortCuts::rNumericArgs(1); - WaterConnections(WaterConnNum).WaterEquipment.allocate(NumAlphas - 9); + WaterConnections(WaterConnNum).WaterEquipment_intArr.allocate(NumAlphas - 9); for (AlphaNum = 10; AlphaNum <= NumAlphas; ++AlphaNum) { WaterEquipNum = UtilityRoutines::FindItemInList(DataIPShortCuts::cAlphaArgs(AlphaNum), WaterEquipment); @@ -610,7 +620,7 @@ namespace WaterUse { WaterEquipment(WaterEquipNum).Connections = WaterConnNum; ++WaterConnections(WaterConnNum).NumWaterEquipment; - WaterConnections(WaterConnNum).WaterEquipment(WaterConnections(WaterConnNum).NumWaterEquipment) = WaterEquipNum; + WaterConnections(WaterConnNum).WaterEquipment_intArr(WaterConnections(WaterConnNum).NumWaterEquipment) = WaterEquipNum; WaterConnections(WaterConnNum).PeakVolFlowRate += WaterEquipment(WaterEquipNum).PeakVolFlowRate; // this does not include possible multipliers @@ -635,7 +645,7 @@ namespace WaterUse { for (WaterConnNum = 1; WaterConnNum <= modNumWaterConnections; ++WaterConnNum) { WaterConnections(WaterConnNum).PeakMassFlowRate = 0.0; for (WaterEquipNum = 1; WaterEquipNum <= WaterConnections(WaterConnNum).NumWaterEquipment; ++WaterEquipNum) { - thisWaterEquipNum = WaterConnections(WaterConnNum).WaterEquipment(WaterEquipNum); + thisWaterEquipNum = WaterConnections(WaterConnNum).WaterEquipment_intArr(WaterEquipNum); if (WaterEquipment(thisWaterEquipNum).Zone > 0) { WaterConnections(WaterConnNum).PeakMassFlowRate += WaterEquipment(thisWaterEquipNum).PeakVolFlowRate * Psychrometrics::RhoH2O(DataGlobals::InitConvTemp) * @@ -1262,7 +1272,7 @@ namespace WaterUse { } } - void InitConnections(int WaterConnNum) + void WaterConnectionsType::InitConnections( ) { // SUBROUTINE INFORMATION: @@ -1273,23 +1283,25 @@ namespace WaterUse { // SUBROUTINE LOCAL VARIABLE DECLARATIONS: bool MyOneTimeFlag(true); // one time flag !DSU - Array1D_bool SetLoopIndexFlag; // get loop number flag !DSU + //Array1D_bool SetLoopIndexFlag; // get loop number flag !DSU bool errFlag; if (MyOneTimeFlag) { // DSU - SetLoopIndexFlag.dimension(modNumWaterConnections, true); // DSU + //SetLoopIndexFlag.dimension(modNumWaterConnections, true); // DSU MyOneTimeFlag = false; // DSU } // DSU - if (SetLoopIndexFlag(WaterConnNum)) { // DSU - if (allocated(DataPlant::PlantLoop) && !WaterConnections(WaterConnNum).StandAlone) { // DSU + //this = WaterConnections(WaterConnNum) + + if (this->SetLoopIndexFlag) { // DSU + if (allocated(DataPlant::PlantLoop) && !this->StandAlone) { // DSU errFlag = false; - PlantUtilities::ScanPlantLoopsForObject(WaterConnections(WaterConnNum).Name, + PlantUtilities::ScanPlantLoopsForObject(this->Name, DataPlant::TypeOf_WaterUseConnection, - WaterConnections(WaterConnNum).PlantLoopNum, - WaterConnections(WaterConnNum).PlantLoopSide, - WaterConnections(WaterConnNum).PlantLoopBranchNum, - WaterConnections(WaterConnNum).PlantLoopCompNum, + this->PlantLoopNum, + this->PlantLoopSide, + this->PlantLoopBranchNum, + this->PlantLoopCompNum, errFlag, _, _, @@ -1299,69 +1311,69 @@ namespace WaterUse { if (errFlag) { // DSU ShowFatalError("InitConnections: Program terminated due to previous condition(s)."); // DSU } // DSU - SetLoopIndexFlag(WaterConnNum) = false; // DSU + this->SetLoopIndexFlag = false; // DSU } // DSU - if (WaterConnections(WaterConnNum).StandAlone) SetLoopIndexFlag(WaterConnNum) = false; + if (this->StandAlone) this->SetLoopIndexFlag = false; } // Set the cold water temperature - if (WaterConnections(WaterConnNum).SupplyTankNum > 0) { - WaterConnections(WaterConnNum).ColdSupplyTemp = DataWater::WaterStorage(WaterConnections(WaterConnNum).SupplyTankNum).Twater; + if (this->SupplyTankNum > 0) { + this->ColdSupplyTemp = DataWater::WaterStorage(this->SupplyTankNum).Twater; - } else if (WaterConnections(WaterConnNum).ColdTempSchedule > 0) { - WaterConnections(WaterConnNum).ColdSupplyTemp = ScheduleManager::GetCurrentScheduleValue(WaterConnections(WaterConnNum).ColdTempSchedule); + } else if (this->ColdTempSchedule > 0) { + this->ColdSupplyTemp = ScheduleManager::GetCurrentScheduleValue(this->ColdTempSchedule); } else { - WaterConnections(WaterConnNum).ColdSupplyTemp = DataEnvironment::WaterMainsTemp; + this->ColdSupplyTemp = DataEnvironment::WaterMainsTemp; } // Initially set ColdTemp to the ColdSupplyTemp; with heat recovery, ColdTemp will change during iteration - WaterConnections(WaterConnNum).ColdTemp = WaterConnections(WaterConnNum).ColdSupplyTemp; + this->ColdTemp = this->ColdSupplyTemp; // Set the hot water temperature - if (WaterConnections(WaterConnNum).StandAlone) { - if (WaterConnections(WaterConnNum).HotTempSchedule > 0) { - WaterConnections(WaterConnNum).HotTemp = ScheduleManager::GetCurrentScheduleValue(WaterConnections(WaterConnNum).HotTempSchedule); + if (this->StandAlone) { + if (this->HotTempSchedule > 0) { + this->HotTemp = ScheduleManager::GetCurrentScheduleValue(this->HotTempSchedule); } else { // If no HotTempSchedule, use all cold water - WaterConnections(WaterConnNum).HotTemp = WaterConnections(WaterConnNum).ColdTemp; + this->HotTemp = this->ColdTemp; } } else { - if (DataGlobals::BeginEnvrnFlag && WaterConnections(WaterConnNum).Init) { + if (DataGlobals::BeginEnvrnFlag && this->Init) { // Clear node initial conditions - if (WaterConnections(WaterConnNum).InletNode > 0 && WaterConnections(WaterConnNum).OutletNode > 0) { + if (this->InletNode > 0 && this->OutletNode > 0) { PlantUtilities::InitComponentNodes(0.0, - WaterConnections(WaterConnNum).PeakMassFlowRate, - WaterConnections(WaterConnNum).InletNode, - WaterConnections(WaterConnNum).OutletNode, - WaterConnections(WaterConnNum).PlantLoopNum, - WaterConnections(WaterConnNum).PlantLoopSide, - WaterConnections(WaterConnNum).PlantLoopBranchNum, - WaterConnections(WaterConnNum).PlantLoopCompNum); - - WaterConnections(WaterConnNum).ReturnTemp = DataLoopNode::Node(WaterConnections(WaterConnNum).InletNode).Temp; + this->PeakMassFlowRate, + this->InletNode, + this->OutletNode, + this->PlantLoopNum, + this->PlantLoopSide, + this->PlantLoopBranchNum, + this->PlantLoopCompNum); + + this->ReturnTemp = DataLoopNode::Node(this->InletNode).Temp; } - WaterConnections(WaterConnNum).Init = false; + this->Init = false; } - if (!DataGlobals::BeginEnvrnFlag) WaterConnections(WaterConnNum).Init = true; + if (!DataGlobals::BeginEnvrnFlag) this->Init = true; - if (WaterConnections(WaterConnNum).InletNode > 0) { + if (this->InletNode > 0) { if (!DataGlobals::DoingSizing) { - WaterConnections(WaterConnNum).HotTemp = DataLoopNode::Node(WaterConnections(WaterConnNum).InletNode).Temp; + this->HotTemp = DataLoopNode::Node(this->InletNode).Temp; } else { // plant loop will not be running so need a value here. // should change to use tank setpoint but water use connections don't have knowledge of the tank they are fed by - WaterConnections(WaterConnNum).HotTemp = 60.0; + this->HotTemp = 60.0; } } } } - void CalcConnectionsFlowRates(int WaterConnNum, bool FirstHVACIteration) + void WaterConnectionsType::CalcConnectionsFlowRates( bool FirstHVACIteration) { // SUBROUTINE INFORMATION: @@ -1378,69 +1390,69 @@ namespace WaterUse { int Loop; int LoopNum; int LoopSideNum; - + // FLOW: - WaterConnections(WaterConnNum).ColdMassFlowRate = 0.0; - WaterConnections(WaterConnNum).HotMassFlowRate = 0.0; + this->ColdMassFlowRate = 0.0; + this->HotMassFlowRate = 0.0; - for (Loop = 1; Loop <= WaterConnections(WaterConnNum).NumWaterEquipment; ++Loop) { - WaterEquipNum = WaterConnections(WaterConnNum).WaterEquipment(Loop); + for (Loop = 1; Loop <= this->NumWaterEquipment; ++Loop) { + WaterEquipNum = this->WaterEquipment_intArr(Loop); CalcEquipmentFlowRates(WaterEquipNum); - WaterConnections(WaterConnNum).ColdMassFlowRate += WaterEquipment(WaterEquipNum).ColdMassFlowRate; - WaterConnections(WaterConnNum).HotMassFlowRate += WaterEquipment(WaterEquipNum).HotMassFlowRate; + this->ColdMassFlowRate += WaterEquipment(WaterEquipNum).ColdMassFlowRate; + this->HotMassFlowRate += WaterEquipment(WaterEquipNum).HotMassFlowRate; } // Loop - WaterConnections(WaterConnNum).TotalMassFlowRate = - WaterConnections(WaterConnNum).ColdMassFlowRate + WaterConnections(WaterConnNum).HotMassFlowRate; + this->TotalMassFlowRate = + this->ColdMassFlowRate + this->HotMassFlowRate; - if (!WaterConnections(WaterConnNum).StandAlone) { // Interact with the plant loop - LoopNum = WaterConnections(WaterConnNum).PlantLoopNum; - LoopSideNum = WaterConnections(WaterConnNum).PlantLoopSide; - if (WaterConnections(WaterConnNum).InletNode > 0) { + if (!this->StandAlone) { // Interact with the plant loop + LoopNum = this->PlantLoopNum; + LoopSideNum = this->PlantLoopSide; + if (this->InletNode > 0) { if (FirstHVACIteration) { // Request the mass flow rate from the demand side manager - PlantUtilities::SetComponentFlowRate(WaterConnections(WaterConnNum).HotMassFlowRate, - WaterConnections(WaterConnNum).InletNode, - WaterConnections(WaterConnNum).OutletNode, + PlantUtilities::SetComponentFlowRate(this->HotMassFlowRate, + this->InletNode, + this->OutletNode, LoopNum, LoopSideNum, - WaterConnections(WaterConnNum).PlantLoopBranchNum, - WaterConnections(WaterConnNum).PlantLoopCompNum); + this->PlantLoopBranchNum, + this->PlantLoopCompNum); } else { - PlantUtilities::SetComponentFlowRate(WaterConnections(WaterConnNum).HotMassFlowRate, - WaterConnections(WaterConnNum).InletNode, - WaterConnections(WaterConnNum).OutletNode, + PlantUtilities::SetComponentFlowRate(this->HotMassFlowRate, + this->InletNode, + this->OutletNode, LoopNum, LoopSideNum, - WaterConnections(WaterConnNum).PlantLoopBranchNum, - WaterConnections(WaterConnNum).PlantLoopCompNum); + this->PlantLoopBranchNum, + this->PlantLoopCompNum); // DSU3 Node(InletNode)%MassFlowRate = MIN(WaterConnections(WaterConnNum)%HotMassFlowRate, Node(InletNode)%MassFlowRateMaxAvail) // DSU3 Node(InletNode)%MassFlowRate = MAX(WaterConnections(WaterConnNum)%HotMassFlowRate, Node(InletNode)%MassFlowRateMinAvail) // readjust if more than actual available mass flow rate determined by the demand side manager - if ((WaterConnections(WaterConnNum).HotMassFlowRate != WaterConnections(WaterConnNum).HotMassFlowRate) && - (WaterConnections(WaterConnNum).HotMassFlowRate > 0.0)) { // plant didn't give what was asked for + if ((this->HotMassFlowRate != this->HotMassFlowRate) && + (this->HotMassFlowRate > 0.0)) { // plant didn't give what was asked for // DSU3 Node(InletNode)%MassFlowRate = Node(InletNode)%MassFlowRateMaxAvail - WaterConnections(WaterConnNum).AvailableFraction = - WaterConnections(WaterConnNum).HotMassFlowRate / WaterConnections(WaterConnNum).HotMassFlowRate; + this->AvailableFraction = + this->HotMassFlowRate / this->HotMassFlowRate; // DSU3 WaterConnections(WaterConnNum)%HotMassFlowRate = Node(InletNode)%MassFlowRateMaxAvail - WaterConnections(WaterConnNum).ColdMassFlowRate = - WaterConnections(WaterConnNum).TotalMassFlowRate - - WaterConnections(WaterConnNum).HotMassFlowRate; // Preserve the total mass flow rate + this->ColdMassFlowRate = + this->TotalMassFlowRate - + this->HotMassFlowRate; // Preserve the total mass flow rate // Proportionally reduce hot water and increase cold water for all WATER USE EQUIPMENT - for (Loop = 1; Loop <= WaterConnections(WaterConnNum).NumWaterEquipment; ++Loop) { - WaterEquipNum = WaterConnections(WaterConnNum).WaterEquipment(Loop); + for (Loop = 1; Loop <= this->NumWaterEquipment; ++Loop) { + WaterEquipNum = this->WaterEquipment_intArr(Loop); // Recalculate flow rates for water equipment within connection - WaterEquipment(WaterEquipNum).HotMassFlowRate *= WaterConnections(WaterConnNum).AvailableFraction; + WaterEquipment(WaterEquipNum).HotMassFlowRate *= this->AvailableFraction; WaterEquipment(WaterEquipNum).ColdMassFlowRate = WaterEquipment(WaterEquipNum).TotalMassFlowRate - WaterEquipment(WaterEquipNum).HotMassFlowRate; @@ -1459,24 +1471,24 @@ namespace WaterUse { } } - if (WaterConnections(WaterConnNum).SupplyTankNum > 0) { + if (this->SupplyTankNum > 0) { // Set the demand request for supply water from water storage tank - WaterConnections(WaterConnNum).ColdVolFlowRate = - WaterConnections(WaterConnNum).ColdMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); - DataWater::WaterStorage(WaterConnections(WaterConnNum).SupplyTankNum).VdotRequestDemand(WaterConnections(WaterConnNum).TankDemandID) = - WaterConnections(WaterConnNum).ColdVolFlowRate; + this->ColdVolFlowRate = + this->ColdMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); + DataWater::WaterStorage(this->SupplyTankNum).VdotRequestDemand(this->TankDemandID) = + this->ColdVolFlowRate; // Check if cold flow rate should be starved by restricted flow from tank // Currently, the tank flow is not really starved--water continues to flow at the tank water temperature // But the user can see the error by comparing report variables for TankVolFlowRate < ColdVolFlowRate - WaterConnections(WaterConnNum).TankVolFlowRate = - DataWater::WaterStorage(WaterConnections(WaterConnNum).SupplyTankNum).VdotAvailDemand(WaterConnections(WaterConnNum).TankDemandID); - WaterConnections(WaterConnNum).TankMassFlowRate = - WaterConnections(WaterConnNum).TankVolFlowRate * Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); + this->TankVolFlowRate = + DataWater::WaterStorage(this->SupplyTankNum).VdotAvailDemand(this->TankDemandID); + this->TankMassFlowRate = + this->TankVolFlowRate * Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); } } - void CalcConnectionsDrainTemp(int WaterConnNum) + void WaterConnectionsType::CalcConnectionsDrainTemp( ) { // SUBROUTINE INFORMATION: @@ -1494,29 +1506,29 @@ namespace WaterUse { Real64 MassFlowTempSum; // FLOW: - WaterConnections(WaterConnNum).DrainMassFlowRate = 0.0; + this->DrainMassFlowRate = 0.0; MassFlowTempSum = 0.0; - for (Loop = 1; Loop <= WaterConnections(WaterConnNum).NumWaterEquipment; ++Loop) { - WaterEquipNum = WaterConnections(WaterConnNum).WaterEquipment(Loop); + for (Loop = 1; Loop <= this->NumWaterEquipment; ++Loop) { + WaterEquipNum = this->WaterEquipment_intArr(Loop); CalcEquipmentDrainTemp(WaterEquipNum); - WaterConnections(WaterConnNum).DrainMassFlowRate += WaterEquipment(WaterEquipNum).DrainMassFlowRate; + this->DrainMassFlowRate += WaterEquipment(WaterEquipNum).DrainMassFlowRate; MassFlowTempSum += WaterEquipment(WaterEquipNum).DrainMassFlowRate * WaterEquipment(WaterEquipNum).DrainTemp; } // Loop - if (WaterConnections(WaterConnNum).DrainMassFlowRate > 0.0) { - WaterConnections(WaterConnNum).DrainTemp = MassFlowTempSum / WaterConnections(WaterConnNum).DrainMassFlowRate; + if (this->DrainMassFlowRate > 0.0) { + this->DrainTemp = MassFlowTempSum / this->DrainMassFlowRate; } else { - WaterConnections(WaterConnNum).DrainTemp = WaterConnections(WaterConnNum).HotTemp; + this->DrainTemp = this->HotTemp; } - WaterConnections(WaterConnNum).DrainVolFlowRate = - WaterConnections(WaterConnNum).DrainMassFlowRate * Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); + this->DrainVolFlowRate = + this->DrainMassFlowRate * Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); } - void CalcConnectionsHeatRecovery(int WaterConnNum) + void WaterConnectionsType::CalcConnectionsHeatRecovery( ) { // SUBROUTINE INFORMATION: @@ -1527,120 +1539,117 @@ namespace WaterUse { // PURPOSE OF THIS SUBROUTINE: // Calculate drainwater heat recovery - // FLOW: - if (!WaterConnections(WaterConnNum).HeatRecovery) { - WaterConnections(WaterConnNum).RecoveryTemp = WaterConnections(WaterConnNum).ColdSupplyTemp; - WaterConnections(WaterConnNum).ReturnTemp = WaterConnections(WaterConnNum).ColdSupplyTemp; - WaterConnections(WaterConnNum).WasteTemp = WaterConnections(WaterConnNum).DrainTemp; - - } else if (WaterConnections(WaterConnNum).TotalMassFlowRate == 0.0) { - WaterConnections(WaterConnNum).Effectiveness = 0.0; - WaterConnections(WaterConnNum).RecoveryRate = 0.0; - WaterConnections(WaterConnNum).RecoveryTemp = WaterConnections(WaterConnNum).ColdSupplyTemp; - WaterConnections(WaterConnNum).ReturnTemp = WaterConnections(WaterConnNum).ColdSupplyTemp; - WaterConnections(WaterConnNum).WasteTemp = WaterConnections(WaterConnNum).DrainTemp; + if (!this->HeatRecovery) { + this->RecoveryTemp = this->ColdSupplyTemp; + this->ReturnTemp = this->ColdSupplyTemp; + this->WasteTemp = this->DrainTemp; + + } else if (this->TotalMassFlowRate == 0.0) { + this->Effectiveness = 0.0; + this->RecoveryRate = 0.0; + this->RecoveryTemp = this->ColdSupplyTemp; + this->ReturnTemp = this->ColdSupplyTemp; + this->WasteTemp = this->DrainTemp; } else { // WaterConnections(WaterConnNum)%TotalMassFlowRate > 0.0 { - auto const SELECT_CASE_var(WaterConnections(WaterConnNum).HeatRecoveryConfig); + auto const SELECT_CASE_var(this->HeatRecoveryConfig); if (SELECT_CASE_var == HeatRecoveryConfigPlant) { - WaterConnections(WaterConnNum).RecoveryMassFlowRate = WaterConnections(WaterConnNum).HotMassFlowRate; + this->RecoveryMassFlowRate = this->HotMassFlowRate; } else if (SELECT_CASE_var == HeatRecoveryConfigEquipment) { - WaterConnections(WaterConnNum).RecoveryMassFlowRate = WaterConnections(WaterConnNum).ColdMassFlowRate; + this->RecoveryMassFlowRate = this->ColdMassFlowRate; } else if (SELECT_CASE_var == HeatRecoveryConfigPlantAndEquip) { - WaterConnections(WaterConnNum).RecoveryMassFlowRate = WaterConnections(WaterConnNum).TotalMassFlowRate; + this->RecoveryMassFlowRate = this->TotalMassFlowRate; } } - WaterConnections(WaterConnNum).HXCapacityRate = - Psychrometrics::CPHW(DataGlobals::InitConvTemp) * WaterConnections(WaterConnNum).RecoveryMassFlowRate; - WaterConnections(WaterConnNum).DrainCapacityRate = - Psychrometrics::CPHW(DataGlobals::InitConvTemp) * WaterConnections(WaterConnNum).DrainMassFlowRate; - WaterConnections(WaterConnNum).MinCapacityRate = - min(WaterConnections(WaterConnNum).DrainCapacityRate, WaterConnections(WaterConnNum).HXCapacityRate); + this->HXCapacityRate = + Psychrometrics::CPHW(DataGlobals::InitConvTemp) * this->RecoveryMassFlowRate; + this->DrainCapacityRate = + Psychrometrics::CPHW(DataGlobals::InitConvTemp) * this->DrainMassFlowRate; + this->MinCapacityRate = + min(this->DrainCapacityRate, this->HXCapacityRate); { - auto const SELECT_CASE_var(WaterConnections(WaterConnNum).HeatRecoveryHX); + auto const SELECT_CASE_var(this->HeatRecoveryHX); if (SELECT_CASE_var == HeatRecoveryHXIdeal) { - WaterConnections(WaterConnNum).Effectiveness = 1.0; + this->Effectiveness = 1.0; } else if (SELECT_CASE_var == HeatRecoveryHXCounterFlow) { // Unmixed - WaterConnections(WaterConnNum).CapacityRatio = - WaterConnections(WaterConnNum).MinCapacityRate / - max(WaterConnections(WaterConnNum).DrainCapacityRate, WaterConnections(WaterConnNum).HXCapacityRate); - WaterConnections(WaterConnNum).NTU = WaterConnections(WaterConnNum).HXUA / WaterConnections(WaterConnNum).MinCapacityRate; - if (WaterConnections(WaterConnNum).CapacityRatio == 1.0) { - WaterConnections(WaterConnNum).Effectiveness = - WaterConnections(WaterConnNum).NTU / (1.0 + WaterConnections(WaterConnNum).NTU); + this->CapacityRatio = + this->MinCapacityRate / + max(this->DrainCapacityRate, this->HXCapacityRate); + this->NTU = this->HXUA / this->MinCapacityRate; + if (this->CapacityRatio == 1.0) { + this->Effectiveness = + this->NTU / (1.0 + this->NTU); } else { - WaterConnections(WaterConnNum).ExpVal = - std::exp(-WaterConnections(WaterConnNum).NTU * (1.0 - WaterConnections(WaterConnNum).CapacityRatio)); - WaterConnections(WaterConnNum).Effectiveness = - (1.0 - WaterConnections(WaterConnNum).ExpVal) / - (1.0 - WaterConnections(WaterConnNum).CapacityRatio * WaterConnections(WaterConnNum).ExpVal); + this->ExpVal = + std::exp(-this->NTU * (1.0 - this->CapacityRatio)); + this->Effectiveness = + (1.0 - this->ExpVal) / + (1.0 - this->CapacityRatio * this->ExpVal); } } else if (SELECT_CASE_var == HeatRecoveryHXCrossFlow) { // Unmixed - WaterConnections(WaterConnNum).CapacityRatio = - WaterConnections(WaterConnNum).MinCapacityRate / - max(WaterConnections(WaterConnNum).DrainCapacityRate, WaterConnections(WaterConnNum).HXCapacityRate); - WaterConnections(WaterConnNum).NTU = WaterConnections(WaterConnNum).HXUA / WaterConnections(WaterConnNum).MinCapacityRate; - WaterConnections(WaterConnNum).Effectiveness = - 1.0 - std::exp((std::pow(WaterConnections(WaterConnNum).NTU, 0.22) / WaterConnections(WaterConnNum).CapacityRatio) * - (std::exp(-WaterConnections(WaterConnNum).CapacityRatio * std::pow(WaterConnections(WaterConnNum).NTU, 0.78)) - + this->CapacityRatio = + this->MinCapacityRate / + max(this->DrainCapacityRate, this->HXCapacityRate); + this->NTU = this->HXUA / this->MinCapacityRate; + this->Effectiveness = + 1.0 - std::exp((std::pow(this->NTU, 0.22) / this->CapacityRatio) * + (std::exp(-this->CapacityRatio * std::pow(this->NTU, 0.78)) - 1.0)); } } - WaterConnections(WaterConnNum).RecoveryRate = WaterConnections(WaterConnNum).Effectiveness * - WaterConnections(WaterConnNum).MinCapacityRate * - (WaterConnections(WaterConnNum).DrainTemp - WaterConnections(WaterConnNum).ColdSupplyTemp); - - WaterConnections(WaterConnNum).RecoveryTemp = - WaterConnections(WaterConnNum).ColdSupplyTemp + - WaterConnections(WaterConnNum).RecoveryRate / - (Psychrometrics::CPHW(DataGlobals::InitConvTemp) * WaterConnections(WaterConnNum).TotalMassFlowRate); - - WaterConnections(WaterConnNum).WasteTemp = - WaterConnections(WaterConnNum).DrainTemp - - WaterConnections(WaterConnNum).RecoveryRate / - (Psychrometrics::CPHW(DataGlobals::InitConvTemp) * WaterConnections(WaterConnNum).TotalMassFlowRate); - - if (WaterConnections(WaterConnNum).RecoveryTankNum > 0) { - DataWater::WaterStorage(WaterConnections(WaterConnNum).RecoveryTankNum).VdotAvailSupply(WaterConnections(WaterConnNum).TankSupplyID) = - WaterConnections(WaterConnNum).DrainVolFlowRate; - DataWater::WaterStorage(WaterConnections(WaterConnNum).RecoveryTankNum).TwaterSupply(WaterConnections(WaterConnNum).TankSupplyID) = - WaterConnections(WaterConnNum).WasteTemp; + this->RecoveryRate = this->Effectiveness * this->MinCapacityRate * (this->DrainTemp - this->ColdSupplyTemp); + + this->RecoveryTemp = + this->ColdSupplyTemp + + this->RecoveryRate / + (Psychrometrics::CPHW(DataGlobals::InitConvTemp) * this->TotalMassFlowRate); + + this->WasteTemp = + this->DrainTemp - + this->RecoveryRate / + (Psychrometrics::CPHW(DataGlobals::InitConvTemp) * this->TotalMassFlowRate); + + if (this->RecoveryTankNum > 0) { + DataWater::WaterStorage(this->RecoveryTankNum).VdotAvailSupply(this->TankSupplyID) = + this->DrainVolFlowRate; + DataWater::WaterStorage(this->RecoveryTankNum).TwaterSupply(this->TankSupplyID) = + this->WasteTemp; } { - auto const SELECT_CASE_var(WaterConnections(WaterConnNum).HeatRecoveryConfig); + auto const SELECT_CASE_var(this->HeatRecoveryConfig); if (SELECT_CASE_var == HeatRecoveryConfigPlant) { - WaterConnections(WaterConnNum).TempError = 0.0; // No feedback back to the cold supply + this->TempError = 0.0; // No feedback back to the cold supply // WaterConnections(WaterConnNum)%ColdTemp = WaterConnections(WaterConnNum)%ColdSupplyTemp - WaterConnections(WaterConnNum).ReturnTemp = WaterConnections(WaterConnNum).RecoveryTemp; + this->ReturnTemp = this->RecoveryTemp; } else if (SELECT_CASE_var == HeatRecoveryConfigEquipment) { - WaterConnections(WaterConnNum).TempError = - std::abs(WaterConnections(WaterConnNum).ColdTemp - WaterConnections(WaterConnNum).RecoveryTemp); + this->TempError = + std::abs(this->ColdTemp - this->RecoveryTemp); - WaterConnections(WaterConnNum).ColdTemp = WaterConnections(WaterConnNum).RecoveryTemp; - WaterConnections(WaterConnNum).ReturnTemp = WaterConnections(WaterConnNum).ColdSupplyTemp; + this->ColdTemp = this->RecoveryTemp; + this->ReturnTemp = this->ColdSupplyTemp; } else if (SELECT_CASE_var == HeatRecoveryConfigPlantAndEquip) { - WaterConnections(WaterConnNum).TempError = - std::abs(WaterConnections(WaterConnNum).ColdTemp - WaterConnections(WaterConnNum).RecoveryTemp); + this->TempError = + std::abs(this->ColdTemp - this->RecoveryTemp); - WaterConnections(WaterConnNum).ColdTemp = WaterConnections(WaterConnNum).RecoveryTemp; - WaterConnections(WaterConnNum).ReturnTemp = WaterConnections(WaterConnNum).RecoveryTemp; + this->ColdTemp = this->RecoveryTemp; + this->ReturnTemp = this->RecoveryTemp; } } } } - void UpdateWaterConnections(int WaterConnNum) + void WaterConnectionsType::UpdateWaterConnections( ) { // SUBROUTINE INFORMATION: @@ -1653,22 +1662,19 @@ namespace WaterUse { // Updates the node variables with local variables. // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - int InletNode; - int OutletNode; - int LoopNum; + int InletNode = this->InletNode; + int OutletNode = this->OutletNode; + int LoopNum = this->PlantLoopNum; // FLOW: - InletNode = WaterConnections(WaterConnNum).InletNode; - OutletNode = WaterConnections(WaterConnNum).OutletNode; - LoopNum = WaterConnections(WaterConnNum).PlantLoopNum; - + if (InletNode > 0 && OutletNode > 0) { // Pass all variables from inlet to outlet node PlantUtilities::SafeCopyPlantNode(InletNode, OutletNode, LoopNum); // DSU3 Node(OutletNode) = Node(InletNode) // Set outlet node variables that are possibly changed - DataLoopNode::Node(OutletNode).Temp = WaterConnections(WaterConnNum).ReturnTemp; + DataLoopNode::Node(OutletNode).Temp = this->ReturnTemp; // should add enthalpy update to return? } } @@ -1720,7 +1726,7 @@ namespace WaterUse { } } - void ReportWaterUse(int WaterConnNum) + void WaterConnectionsType::ReportWaterUse( ) { // SUBROUTINE INFORMATION: @@ -1737,10 +1743,9 @@ namespace WaterUse { int Loop; int WaterEquipNum; - // FLOW: - for (Loop = 1; Loop <= WaterConnections(WaterConnNum).NumWaterEquipment; ++Loop) { - WaterEquipNum = WaterConnections(WaterConnNum).WaterEquipment(Loop); + for (Loop = 1; Loop <= this->NumWaterEquipment; ++Loop) { + WaterEquipNum = this->WaterEquipment_intArr(Loop); WaterEquipment(WaterEquipNum).ColdVolFlowRate = WaterEquipment(WaterEquipNum).ColdMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); WaterEquipment(WaterEquipNum).HotVolFlowRate = @@ -1768,26 +1773,26 @@ namespace WaterUse { WaterEquipment(WaterEquipNum).Energy = WaterEquipment(WaterEquipNum).Power * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; } - WaterConnections(WaterConnNum).ColdVolFlowRate = - WaterConnections(WaterConnNum).ColdMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); - WaterConnections(WaterConnNum).HotVolFlowRate = - WaterConnections(WaterConnNum).HotMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); - WaterConnections(WaterConnNum).TotalVolFlowRate = - WaterConnections(WaterConnNum).ColdVolFlowRate + WaterConnections(WaterConnNum).HotVolFlowRate; - - WaterConnections(WaterConnNum).ColdVolume = - WaterConnections(WaterConnNum).ColdVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - WaterConnections(WaterConnNum).HotVolume = - WaterConnections(WaterConnNum).HotVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - WaterConnections(WaterConnNum).TotalVolume = - WaterConnections(WaterConnNum).TotalVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - - WaterConnections(WaterConnNum).Power = WaterConnections(WaterConnNum).HotMassFlowRate * Psychrometrics::CPHW(DataGlobals::InitConvTemp) * - (WaterConnections(WaterConnNum).HotTemp - WaterConnections(WaterConnNum).ReturnTemp); - WaterConnections(WaterConnNum).Energy = WaterConnections(WaterConnNum).Power * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - - WaterConnections(WaterConnNum).RecoveryEnergy = - WaterConnections(WaterConnNum).RecoveryRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + this->ColdVolFlowRate = + this->ColdMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); + this->HotVolFlowRate = + this->HotMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); + this->TotalVolFlowRate = + this->ColdVolFlowRate + this->HotVolFlowRate; + + this->ColdVolume = + this->ColdVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + this->HotVolume = + this->HotVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + this->TotalVolume = + this->TotalVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + + this->Power = this->HotMassFlowRate * Psychrometrics::CPHW(DataGlobals::InitConvTemp) * + (this->HotTemp - this->ReturnTemp); + this->Energy = this->Power * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + + this->RecoveryEnergy = + this->RecoveryRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; } void CalcWaterUseZoneGains() diff --git a/src/EnergyPlus/WaterUse.hh b/src/EnergyPlus/WaterUse.hh index d16b5c19dcb..b05667c3c49 100644 --- a/src/EnergyPlus/WaterUse.hh +++ b/src/EnergyPlus/WaterUse.hh @@ -154,7 +154,7 @@ namespace WaterUse { }; - struct WaterConnectionsType + struct WaterConnectionsType : PlantComponent { // Members std::string Name; // Name of DHW @@ -217,12 +217,12 @@ namespace WaterUse { Real64 AvailableFraction; int NumWaterEquipment; int MaxIterationsErrorIndex; // recurring error index - Array1D_int WaterEquipment; + Array1D_int WaterEquipment_intArr; int PlantLoopNum; int PlantLoopSide; int PlantLoopBranchNum; int PlantLoopCompNum; - + bool SetLoopIndexFlag; // Default Constructor WaterConnectionsType() @@ -235,11 +235,24 @@ namespace WaterUse { HotTemp(0.0), DrainTemp(0.0), RecoveryTemp(0.0), ReturnTemp(0.0), WasteTemp(0.0), TempError(0.0), MainsVolume(0.0), TankVolume(0.0), ColdVolume(0.0), HotVolume(0.0), TotalVolume(0.0), Power(0.0), Energy(0.0), CapacityRatio(0.0), MinCapacityRate(0.0), HXCapacityRate(0.0), DrainCapacityRate(0.0), NTU(0.0), ExpVal(0.0), AvailableFraction(0.0), NumWaterEquipment(0), MaxIterationsErrorIndex(0), - PlantLoopNum(0), PlantLoopSide(0), PlantLoopBranchNum(0), PlantLoopCompNum(0) + PlantLoopNum(0), PlantLoopSide(0), PlantLoopBranchNum(0), PlantLoopCompNum(0), SetLoopIndexFlag(true) { } + void InitConnections( ); + void UpdateWaterConnections( ); + + void CalcConnectionsHeatRecovery( ); + + void CalcConnectionsFlowRates( bool FirstHVACIteration); + + void CalcConnectionsDrainTemp( ); + + void simulate(const PlantLocation &calledFromLocation, bool FirstHVACIteration, Real64 &CurLoad, bool RunFlag) override; + + void ReportWaterUse( ); + }; @@ -256,20 +269,8 @@ namespace WaterUse { void CalcEquipmentDrainTemp(int WaterEquipNum); - void CalcConnectionsFlowRates(int WaterConnNum, bool FirstHVACIteration); - - void CalcConnectionsDrainTemp(int WaterConnNum); - - void CalcConnectionsHeatRecovery(int WaterConnNum); - - void UpdateWaterConnections(int WaterConnNum); - - void InitConnections(int WaterConnNum); - void SimulateWaterUse(bool FirstHVACIteration); - void ReportWaterUse(int WaterConnNum); - void CalcWaterUseZoneGains(); void SimulateWaterUseConnection(int EquipTypeNum, std::string &CompName, int &CompIndex, bool InitLoopEquip, bool FirstHVACIteration); From 9ddc8e110c8e837656a53b438f3a60e9956f3fca Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Mon, 11 Nov 2019 13:20:23 -0700 Subject: [PATCH 13/51] partial cleanup usings --- src/EnergyPlus/FuelCellElectricGenerator.cc | 293 ++++++++++---------- 1 file changed, 141 insertions(+), 152 deletions(-) diff --git a/src/EnergyPlus/FuelCellElectricGenerator.cc b/src/EnergyPlus/FuelCellElectricGenerator.cc index 249bda9c13c..c659893d482 100644 --- a/src/EnergyPlus/FuelCellElectricGenerator.cc +++ b/src/EnergyPlus/FuelCellElectricGenerator.cc @@ -175,11 +175,6 @@ namespace FuelCellElectricGenerator { // METHODOLOGY EMPLOYED: // EnergyPlus input processor - using namespace DataGenerators; - using namespace DataIPShortCuts; // Data for field names, blank numerics - using NodeInputManager::GetOnlySingleNode; - using ScheduleManager::GetScheduleIndex; - int GeneratorNum; // Generator counter int NumAlphas; // Number of elements in the alpha array int NumNums; // Number of elements in the numeric array @@ -221,11 +216,11 @@ namespace FuelCellElectricGenerator { // execution if (MyOneTimeFlag) { - cCurrentModuleObject = "Generator:FuelCell"; - NumFuelCellGenerators = inputProcessor->getNumObjectsFound(cCurrentModuleObject); + DataIPShortCuts::cCurrentModuleObject = "Generator:FuelCell"; + NumFuelCellGenerators = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); if (NumFuelCellGenerators <= 0) { - ShowSevereError("No " + cCurrentModuleObject + " equipment specified in input file"); + ShowSevereError("No " + DataIPShortCuts::cCurrentModuleObject + " equipment specified in input file"); ErrorsFound = true; } @@ -236,8 +231,8 @@ namespace FuelCellElectricGenerator { // first load in FuelCell names for (GeneratorNum = 1; GeneratorNum <= NumFuelCellGenerators; ++GeneratorNum) { inputProcessor->getObjectItem( - cCurrentModuleObject, GeneratorNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat, _, _, cAlphaFieldNames, cNumericFieldNames); - UtilityRoutines::IsNameEmpty(AlphArray(1), cCurrentModuleObject, ErrorsFound); + DataIPShortCuts::cCurrentModuleObject, GeneratorNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat, _, _, DataIPShortCuts::cAlphaFieldNames, DataIPShortCuts::cNumericFieldNames); + UtilityRoutines::IsNameEmpty(AlphArray(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); FuelCell(GeneratorNum).Name = AlphArray(1); FuelCell(GeneratorNum).NameFCPM = AlphArray(2); @@ -253,16 +248,16 @@ namespace FuelCellElectricGenerator { } } - cCurrentModuleObject = "Generator:FuelCell:PowerModule"; - NumFuelCellPMs = inputProcessor->getNumObjectsFound(cCurrentModuleObject); + DataIPShortCuts::cCurrentModuleObject = "Generator:FuelCell:PowerModule"; + NumFuelCellPMs = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); if (NumFuelCellPMs <= 0) { - ShowSevereError("No " + cCurrentModuleObject + " equipment specified in input file"); + ShowSevereError("No " + DataIPShortCuts::cCurrentModuleObject + " equipment specified in input file"); ErrorsFound = true; } for (FCPMNum = 1; FCPMNum <= NumFuelCellPMs; ++FCPMNum) { - inputProcessor->getObjectItem(cCurrentModuleObject, + inputProcessor->getObjectItem(DataIPShortCuts::cCurrentModuleObject, FCPMNum, AlphArray, NumAlphas, @@ -271,9 +266,9 @@ namespace FuelCellElectricGenerator { IOStat, _, lAlphaBlanks, - cAlphaFieldNames, - cNumericFieldNames); - UtilityRoutines::IsNameEmpty(AlphArray(1), cCurrentModuleObject, ErrorsFound); + DataIPShortCuts::cAlphaFieldNames, + DataIPShortCuts::cNumericFieldNames); + UtilityRoutines::IsNameEmpty(AlphArray(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), FuelCell, &FCDataStruct::NameFCPM); if (thisFuelCell > 0) { // cr9323 @@ -282,14 +277,14 @@ namespace FuelCellElectricGenerator { if (UtilityRoutines::SameString(AlphArray(2), "ANNEX42")) FuelCell(thisFuelCell).FCPM.EffMode = DirectCurveMode; if (UtilityRoutines::SameString(AlphArray(2), "NORMALIZED")) FuelCell(thisFuelCell).FCPM.EffMode = NormalizedCurveMode; if (FuelCell(thisFuelCell).FCPM.EffMode == 0) { - ShowSevereError("Invalid, " + cAlphaFieldNames(2) + " = " + AlphArray(2)); - ShowContinueError("Entered in " + cCurrentModuleObject + '=' + AlphArray(1)); + ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(2) + " = " + AlphArray(2)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } FuelCell(thisFuelCell).FCPM.EffCurveID = CurveManager::GetCurveIndex(AlphArray(3)); if (FuelCell(thisFuelCell).FCPM.EffCurveID == 0) { - ShowSevereError("Invalid, " + cAlphaFieldNames(3) + " = " + AlphArray(3)); - ShowContinueError("Entered in " + cCurrentModuleObject + '=' + AlphArray(1)); + ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(3) + " = " + AlphArray(3)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } @@ -318,15 +313,15 @@ namespace FuelCellElectricGenerator { FuelCell(thisFuelCell).FCPM.SkinLossMode = QuadraticFuelNdotSkin; if (FuelCell(thisFuelCell).FCPM.SkinLossMode == 0) { // throw error - ShowSevereError("Invalid, " + cAlphaFieldNames(4) + " = " + AlphArray(4)); - ShowContinueError("Entered in " + cCurrentModuleObject + '=' + AlphArray(1)); + ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(4) + " = " + AlphArray(4)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } FuelCell(thisFuelCell).FCPM.ZoneName = AlphArray(5); FuelCell(thisFuelCell).FCPM.ZoneID = UtilityRoutines::FindItemInList(FuelCell(thisFuelCell).FCPM.ZoneName, DataHeatBalance::Zone); if (FuelCell(thisFuelCell).FCPM.ZoneID == 0 && !lAlphaBlanks(5)) { - ShowSevereError("Invalid, " + cAlphaFieldNames(5) + " = " + AlphArray(5)); - ShowContinueError("Entered in " + cCurrentModuleObject + '=' + AlphArray(1)); + ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(5) + " = " + AlphArray(5)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ShowContinueError("Zone Name was not found "); ErrorsFound = true; } @@ -338,8 +333,8 @@ namespace FuelCellElectricGenerator { FuelCell(thisFuelCell).FCPM.SkinLossCurveID = CurveManager::GetCurveIndex(AlphArray(6)); if (FuelCell(thisFuelCell).FCPM.SkinLossCurveID == 0) { if (FuelCell(thisFuelCell).FCPM.SkinLossMode == QuadraticFuelNdotSkin) { - ShowSevereError("Invalid, " + cAlphaFieldNames(6) + " = " + AlphArray(6)); - ShowContinueError("Entered in " + cCurrentModuleObject + '=' + AlphArray(1)); + ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(6) + " = " + AlphArray(6)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } } @@ -347,11 +342,11 @@ namespace FuelCellElectricGenerator { FuelCell(thisFuelCell).FCPM.NdotDilutionAir = NumArray(22); FuelCell(thisFuelCell).FCPM.StackHeatLossToDilution = NumArray(23); FuelCell(thisFuelCell).FCPM.DilutionInletNodeName = AlphArray(7); - FuelCell(thisFuelCell).FCPM.DilutionInletNode = GetOnlySingleNode( - AlphArray(7), ErrorsFound, cCurrentModuleObject, AlphArray(1), NodeType_Air, NodeConnectionType_Inlet, 1, ObjectIsNotParent); + FuelCell(thisFuelCell).FCPM.DilutionInletNode = NodeInputManager::GetOnlySingleNode( + AlphArray(7), ErrorsFound, DataIPShortCuts::cCurrentModuleObject, AlphArray(1), NodeType_Air, NodeConnectionType_Inlet, 1, ObjectIsNotParent); FuelCell(thisFuelCell).FCPM.DilutionExhaustNodeName = AlphArray(8); - FuelCell(thisFuelCell).FCPM.DilutionExhaustNode = GetOnlySingleNode( - AlphArray(8), ErrorsFound, cCurrentModuleObject, AlphArray(1), NodeType_Air, NodeConnectionType_Outlet, 1, ObjectIsNotParent); + FuelCell(thisFuelCell).FCPM.DilutionExhaustNode = NodeInputManager::GetOnlySingleNode( + AlphArray(8), ErrorsFound, DataIPShortCuts::cCurrentModuleObject, AlphArray(1), NodeType_Air, NodeConnectionType_Outlet, 1, ObjectIsNotParent); FuelCell(thisFuelCell).FCPM.PelMin = NumArray(24); FuelCell(thisFuelCell).FCPM.PelMax = NumArray(25); @@ -363,8 +358,8 @@ namespace FuelCellElectricGenerator { } } } else { // throw warning, did not find power module input - ShowSevereError("Invalid, " + cAlphaFieldNames(1) + " = " + AlphArray(1)); - ShowContinueError("Entered in " + cCurrentModuleObject + '=' + AlphArray(1)); + ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(1) + " = " + AlphArray(1)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } } // loop over NumFuelCellPMs @@ -385,18 +380,18 @@ namespace FuelCellElectricGenerator { } } - cCurrentModuleObject = "Generator:FuelCell:AirSupply"; - NumFuelCellAirSups = inputProcessor->getNumObjectsFound(cCurrentModuleObject); + DataIPShortCuts::cCurrentModuleObject = "Generator:FuelCell:AirSupply"; + NumFuelCellAirSups = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); if (NumFuelCellAirSups <= 0) { // Autodesk:Uninit thisFuelCell was possibly uninitialized past this condition - ShowSevereError("No " + cCurrentModuleObject + " equipment specified in input file"); + ShowSevereError("No " + DataIPShortCuts::cCurrentModuleObject + " equipment specified in input file"); ErrorsFound = true; } for (FCAirSupNum = 1; FCAirSupNum <= NumFuelCellAirSups; ++FCAirSupNum) { inputProcessor->getObjectItem( - cCurrentModuleObject, FCAirSupNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat, _, _, cAlphaFieldNames, cNumericFieldNames); - UtilityRoutines::IsNameEmpty(AlphArray(1), cCurrentModuleObject, ErrorsFound); + DataIPShortCuts::cCurrentModuleObject, FCAirSupNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat, _, _, DataIPShortCuts::cAlphaFieldNames, DataIPShortCuts::cNumericFieldNames); + UtilityRoutines::IsNameEmpty(AlphArray(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), FuelCell, &FCDataStruct::NameFCAirSup); if (thisFuelCell > 0) { @@ -405,13 +400,13 @@ namespace FuelCellElectricGenerator { FuelCell(thisFuelCell).AirSup.NodeName = AlphArray(2); // check the node connections - FuelCell(thisFuelCell).AirSup.SupNodeNum = GetOnlySingleNode( - AlphArray(2), ErrorsFound, cCurrentModuleObject, AlphArray(1), NodeType_Air, NodeConnectionType_Inlet, 1, ObjectIsNotParent); + FuelCell(thisFuelCell).AirSup.SupNodeNum = NodeInputManager::GetOnlySingleNode( + AlphArray(2), ErrorsFound, DataIPShortCuts::cCurrentModuleObject, AlphArray(1), NodeType_Air, NodeConnectionType_Inlet, 1, ObjectIsNotParent); FuelCell(thisFuelCell).AirSup.BlowerPowerCurveID = CurveManager::GetCurveIndex(AlphArray(3)); if (FuelCell(thisFuelCell).AirSup.BlowerPowerCurveID == 0) { - ShowSevereError("Invalid, " + cAlphaFieldNames(3) + " = " + AlphArray(3)); - ShowContinueError("Entered in " + cCurrentModuleObject + '=' + AlphArray(1)); + ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(3) + " = " + AlphArray(3)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ShowContinueError("Curve name was not found "); ErrorsFound = true; } @@ -424,8 +419,8 @@ namespace FuelCellElectricGenerator { } else if (UtilityRoutines::SameString(AlphArray(4), "QUADRATIC FUNCTION OF FUEL RATE")) { FuelCell(thisFuelCell).AirSup.AirSupRateMode = QuadraticFuncofNdot; } else { - ShowSevereError("Invalid, " + cAlphaFieldNames(4) + " = " + AlphArray(4)); - ShowContinueError("Entered in " + cCurrentModuleObject + '=' + AlphArray(1)); + ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(4) + " = " + AlphArray(4)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } @@ -434,8 +429,8 @@ namespace FuelCellElectricGenerator { FuelCell(thisFuelCell).AirSup.AirFuncPelCurveID = CurveManager::GetCurveIndex(AlphArray(5)); if ((FuelCell(thisFuelCell).AirSup.AirFuncPelCurveID == 0) && (FuelCell(thisFuelCell).AirSup.AirSupRateMode == QuadraticFuncofPel)) { - ShowSevereError("Invalid, " + cAlphaFieldNames(5) + " = " + AlphArray(5)); - ShowContinueError("Entered in " + cCurrentModuleObject + '=' + AlphArray(1)); + ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(5) + " = " + AlphArray(5)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ShowSevereError("Curve name was not found"); ErrorsFound = true; } @@ -445,8 +440,8 @@ namespace FuelCellElectricGenerator { FuelCell(thisFuelCell).AirSup.AirFuncNdotCurveID = CurveManager::GetCurveIndex(AlphArray(6)); if ((FuelCell(thisFuelCell).AirSup.AirFuncNdotCurveID == 0) && (FuelCell(thisFuelCell).AirSup.AirSupRateMode == QuadraticFuncofNdot)) { - ShowSevereError("Invalid, " + cAlphaFieldNames(6) + " = " + AlphArray(6)); - ShowContinueError("Entered in " + cCurrentModuleObject + '=' + AlphArray(1)); + ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(6) + " = " + AlphArray(6)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ShowSevereError("Curve name was not found"); ErrorsFound = true; } @@ -464,8 +459,8 @@ namespace FuelCellElectricGenerator { } else if (UtilityRoutines::SameString("NoRecovery", AlphArray(7))) { FuelCell(thisFuelCell).AirSup.IntakeRecoveryMode = NoRecoveryOnAirIntake; } else { - ShowSevereError("Invalid, " + cAlphaFieldNames(7) + " = " + AlphArray(7)); - ShowContinueError("Entered in " + cCurrentModuleObject + '=' + AlphArray(1)); + ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(7) + " = " + AlphArray(7)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } @@ -474,8 +469,8 @@ namespace FuelCellElectricGenerator { } else if (UtilityRoutines::SameString("UserDefinedConstituents", AlphArray(8))) { FuelCell(thisFuelCell).AirSup.ConstituentMode = UserDefinedConstituents; } else { - ShowSevereError("Invalid, " + cAlphaFieldNames(8) + " = " + AlphArray(8)); - ShowContinueError("Entered in " + cCurrentModuleObject + '=' + AlphArray(1)); + ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(8) + " = " + AlphArray(8)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } @@ -484,8 +479,8 @@ namespace FuelCellElectricGenerator { FuelCell(thisFuelCell).AirSup.NumConstituents = NumAirConstit; if (NumAirConstit > 5) { - ShowSevereError("Invalid " + cNumericFieldNames(4) + '=' + General::RoundSigDigits(NumArray(4), 2)); - ShowContinueError("Entered in " + cCurrentModuleObject + '=' + AlphArray(1)); + ShowSevereError("Invalid " + DataIPShortCuts::cNumericFieldNames(4) + '=' + General::RoundSigDigits(NumArray(4), 2)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ShowContinueError("Fuel Cell model not set up for more than 5 air constituents"); ErrorsFound = true; } @@ -519,9 +514,9 @@ namespace FuelCellElectricGenerator { // check for molar fractions summing to 1.0. if (std::abs(sum(FuelCell(thisFuelCell).AirSup.ConstitMolalFract) - 1.0) > 0.0001) { - ShowSevereError(cCurrentModuleObject + " molar fractions do not sum to 1.0"); + ShowSevereError(DataIPShortCuts::cCurrentModuleObject + " molar fractions do not sum to 1.0"); ShowContinueError("..Sum was=" + General::RoundSigDigits(sum(FuelCell(thisFuelCell).AirSup.ConstitMolalFract), 1)); - ShowContinueError("Entered in " + cCurrentModuleObject + " = " + AlphArray(1)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + " = " + AlphArray(1)); ErrorsFound = true; } @@ -532,8 +527,8 @@ namespace FuelCellElectricGenerator { } } } else { - ShowSevereError("Invalid, " + cAlphaFieldNames(1) + " = " + AlphArray(1)); - ShowContinueError("Entered in " + cCurrentModuleObject + '=' + AlphArray(1)); + ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(1) + " = " + AlphArray(1)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } } @@ -564,18 +559,18 @@ namespace FuelCellElectricGenerator { FuelCell(GeneratorNum).FCPM.GasLibID(5) = 5; // Argon } - cCurrentModuleObject = "Generator:FuelCell:WaterSupply"; - NumFCWaterSups = inputProcessor->getNumObjectsFound(cCurrentModuleObject); + DataIPShortCuts::cCurrentModuleObject = "Generator:FuelCell:WaterSupply"; + NumFCWaterSups = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); if (NumFCWaterSups <= 0) { - ShowSevereError("No " + cCurrentModuleObject + " equipment specified in input file"); + ShowSevereError("No " + DataIPShortCuts::cCurrentModuleObject + " equipment specified in input file"); ErrorsFound = true; } for (FCWaterSupNum = 1; FCWaterSupNum <= NumFCWaterSups; ++FCWaterSupNum) { inputProcessor->getObjectItem( - cCurrentModuleObject, FCWaterSupNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat, _, _, cAlphaFieldNames, cNumericFieldNames); - UtilityRoutines::IsNameEmpty(AlphArray(1), cCurrentModuleObject, ErrorsFound); + DataIPShortCuts::cCurrentModuleObject, FCWaterSupNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat, _, _, DataIPShortCuts::cAlphaFieldNames, DataIPShortCuts::cNumericFieldNames); + UtilityRoutines::IsNameEmpty(AlphArray(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), FuelCell, &FCDataStruct::NameFCWaterSup); if (thisFuelCell > 0) { @@ -583,15 +578,15 @@ namespace FuelCellElectricGenerator { FuelCell(thisFuelCell).WaterSup.Name = AlphArray(1); FuelCell(thisFuelCell).WaterSup.WaterSupRateCurveID = CurveManager::GetCurveIndex(AlphArray(2)); if (FuelCell(thisFuelCell).WaterSup.WaterSupRateCurveID == 0) { - ShowSevereError("Invalid, " + cAlphaFieldNames(2) + " = " + AlphArray(2)); - ShowContinueError("Entered in " + cCurrentModuleObject + '=' + AlphArray(1)); + ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(2) + " = " + AlphArray(2)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ShowContinueError("Curve name was not found "); ErrorsFound = true; } FuelCell(thisFuelCell).WaterSup.PmpPowerCurveID = CurveManager::GetCurveIndex(AlphArray(3)); if (FuelCell(thisFuelCell).WaterSup.PmpPowerCurveID == 0) { - ShowSevereError("Invalid, " + cAlphaFieldNames(3) + " = " + AlphArray(3)); - ShowContinueError("Entered in " + cCurrentModuleObject + '=' + AlphArray(1)); + ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(3) + " = " + AlphArray(3)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ShowContinueError("Curve name was not found "); ErrorsFound = true; } @@ -602,9 +597,9 @@ namespace FuelCellElectricGenerator { FuelCell(thisFuelCell).WaterSup.WaterTempMode = WaterInReformAirNode; FuelCell(thisFuelCell).WaterSup.NodeName = AlphArray(5); - FuelCell(thisFuelCell).WaterSup.NodeNum = GetOnlySingleNode(AlphArray(5), + FuelCell(thisFuelCell).WaterSup.NodeNum = NodeInputManager::GetOnlySingleNode(AlphArray(5), ErrorsFound, - cCurrentModuleObject, + DataIPShortCuts::cCurrentModuleObject, AlphArray(1), NodeType_Air, NodeConnectionType_Sensor, @@ -615,9 +610,9 @@ namespace FuelCellElectricGenerator { FuelCell(thisFuelCell).WaterSup.WaterTempMode = WaterInReformWaterNode; FuelCell(thisFuelCell).WaterSup.NodeName = AlphArray(5); - FuelCell(thisFuelCell).WaterSup.NodeNum = GetOnlySingleNode(AlphArray(5), + FuelCell(thisFuelCell).WaterSup.NodeNum = NodeInputManager::GetOnlySingleNode(AlphArray(5), ErrorsFound, - cCurrentModuleObject, + DataIPShortCuts::cCurrentModuleObject, AlphArray(1), NodeType_Water, NodeConnectionType_Sensor, @@ -630,15 +625,15 @@ namespace FuelCellElectricGenerator { } else if (UtilityRoutines::SameString("TemperatureFromSchedule", AlphArray(4))) { FuelCell(thisFuelCell).WaterSup.WaterTempMode = WaterInReformSchedule; } else { - ShowSevereError("Invalid, " + cAlphaFieldNames(4) + " = " + AlphArray(4)); - ShowContinueError("Entered in " + cCurrentModuleObject + '=' + AlphArray(1)); + ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(4) + " = " + AlphArray(4)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } - FuelCell(thisFuelCell).WaterSup.SchedNum = GetScheduleIndex(AlphArray(6)); + FuelCell(thisFuelCell).WaterSup.SchedNum = ScheduleManager::GetScheduleIndex(AlphArray(6)); if ((FuelCell(thisFuelCell).WaterSup.SchedNum == 0) && (FuelCell(thisFuelCell).WaterSup.WaterTempMode == WaterInReformSchedule)) { - ShowSevereError("Invalid, " + cAlphaFieldNames(6) + " = " + AlphArray(6)); - ShowContinueError("Entered in " + cCurrentModuleObject + '=' + AlphArray(1)); + ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(6) + " = " + AlphArray(6)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ShowContinueError("Schedule was not found"); ErrorsFound = true; } @@ -650,24 +645,24 @@ namespace FuelCellElectricGenerator { } } } else { - ShowSevereError("Invalid, " + cAlphaFieldNames(1) + " = " + AlphArray(1)); - ShowContinueError("Entered in " + cCurrentModuleObject + '=' + AlphArray(1)); + ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(1) + " = " + AlphArray(1)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } } - cCurrentModuleObject = "Generator:FuelCell:AuxiliaryHeater"; - NumFuelCellAuxilHeaters = inputProcessor->getNumObjectsFound(cCurrentModuleObject); + DataIPShortCuts::cCurrentModuleObject = "Generator:FuelCell:AuxiliaryHeater"; + NumFuelCellAuxilHeaters = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); if (NumFuelCellAuxilHeaters <= 0) { - ShowSevereError("No " + cCurrentModuleObject + " equipment specified in input file"); + ShowSevereError("No " + DataIPShortCuts::cCurrentModuleObject + " equipment specified in input file"); ErrorsFound = true; } for (FCAuxHeatNum = 1; FCAuxHeatNum <= NumFuelCellAuxilHeaters; ++FCAuxHeatNum) { inputProcessor->getObjectItem( - cCurrentModuleObject, FCAuxHeatNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat, _, _, cAlphaFieldNames, cNumericFieldNames); - UtilityRoutines::IsNameEmpty(AlphArray(1), cCurrentModuleObject, ErrorsFound); + DataIPShortCuts::cCurrentModuleObject, FCAuxHeatNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat, _, _, DataIPShortCuts::cAlphaFieldNames, DataIPShortCuts::cNumericFieldNames); + UtilityRoutines::IsNameEmpty(AlphArray(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), FuelCell, &FCDataStruct::NameFCAuxilHeat); if (thisFuelCell > 0) { @@ -683,16 +678,16 @@ namespace FuelCellElectricGenerator { } else if (UtilityRoutines::SameString("AirInletForFuelCell", AlphArray(2))) { FuelCell(thisFuelCell).AuxilHeat.SkinLossDestination = AirInletForFC; } else { - ShowSevereError("Invalid, " + cAlphaFieldNames(2) + " = " + AlphArray(2)); - ShowContinueError("Entered in " + cCurrentModuleObject + '=' + AlphArray(1)); + ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(2) + " = " + AlphArray(2)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } FuelCell(thisFuelCell).AuxilHeat.ZoneName = AlphArray(3); FuelCell(thisFuelCell).AuxilHeat.ZoneID = UtilityRoutines::FindItemInList(AlphArray(3), DataHeatBalance::Zone); if ((FuelCell(thisFuelCell).AuxilHeat.ZoneID == 0) && (FuelCell(thisFuelCell).AuxilHeat.SkinLossDestination == SurroundingZone)) { - ShowSevereError("Invalid, " + cAlphaFieldNames(3) + " = " + AlphArray(3)); - ShowContinueError("Entered in " + cCurrentModuleObject + '=' + AlphArray(1)); + ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(3) + " = " + AlphArray(3)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ShowContinueError("Zone name was not found "); ErrorsFound = true; } @@ -710,25 +705,25 @@ namespace FuelCellElectricGenerator { } } } else { - ShowSevereError("Invalid, " + cAlphaFieldNames(1) + " = " + AlphArray(1)); - ShowContinueError("Entered in " + cCurrentModuleObject + '=' + AlphArray(1)); + ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(1) + " = " + AlphArray(1)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } } // exhaust gas heat exchanger - cCurrentModuleObject = "Generator:FuelCell:ExhaustGasToWaterHeatExchanger"; - NumFCExhaustGasHXs = inputProcessor->getNumObjectsFound(cCurrentModuleObject); + DataIPShortCuts::cCurrentModuleObject = "Generator:FuelCell:ExhaustGasToWaterHeatExchanger"; + NumFCExhaustGasHXs = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); if (NumFCExhaustGasHXs <= 0) { - ShowWarningError("No " + cCurrentModuleObject + " equipment specified in input file"); - ShowContinueError("Fuel Cell model requires an " + cCurrentModuleObject + " object"); + ShowWarningError("No " + DataIPShortCuts::cCurrentModuleObject + " equipment specified in input file"); + ShowContinueError("Fuel Cell model requires an " + DataIPShortCuts::cCurrentModuleObject + " object"); ErrorsFound = true; } for (FCHXNum = 1; FCHXNum <= NumFCExhaustGasHXs; ++FCHXNum) { inputProcessor->getObjectItem( - cCurrentModuleObject, FCHXNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat, _, _, cAlphaFieldNames, cNumericFieldNames); - UtilityRoutines::IsNameEmpty(AlphArray(1), cCurrentModuleObject, ErrorsFound); + DataIPShortCuts::cCurrentModuleObject, FCHXNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat, _, _, DataIPShortCuts::cAlphaFieldNames, DataIPShortCuts::cNumericFieldNames); + UtilityRoutines::IsNameEmpty(AlphArray(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), FuelCell, &FCDataStruct::NameExhaustHX); if (thisFuelCell > 0) { @@ -736,28 +731,28 @@ namespace FuelCellElectricGenerator { FuelCell(thisFuelCell).ExhaustHX.WaterInNodeName = AlphArray(2); FuelCell(thisFuelCell).ExhaustHX.WaterOutNodeName = AlphArray(3); // find node ids for water path - FuelCell(thisFuelCell).ExhaustHX.WaterInNode = GetOnlySingleNode(AlphArray(2), + FuelCell(thisFuelCell).ExhaustHX.WaterInNode = NodeInputManager::GetOnlySingleNode(AlphArray(2), ErrorsFound, - cCurrentModuleObject, + DataIPShortCuts::cCurrentModuleObject, AlphArray(1), NodeType_Water, NodeConnectionType_Inlet, 1, ObjectIsNotParent); - FuelCell(thisFuelCell).ExhaustHX.WaterOutNode = GetOnlySingleNode(AlphArray(3), + FuelCell(thisFuelCell).ExhaustHX.WaterOutNode = NodeInputManager::GetOnlySingleNode(AlphArray(3), ErrorsFound, - cCurrentModuleObject, + DataIPShortCuts::cCurrentModuleObject, AlphArray(1), NodeType_Water, NodeConnectionType_Outlet, 1, ObjectIsNotParent); - BranchNodeConnections::TestCompSet(cCurrentModuleObject, AlphArray(1), AlphArray(2), AlphArray(3), "Heat Recovery Nodes"); + BranchNodeConnections::TestCompSet(DataIPShortCuts::cCurrentModuleObject, AlphArray(1), AlphArray(2), AlphArray(3), "Heat Recovery Nodes"); // CR9240 FuelCell(thisFuelCell).ExhaustHX.ExhaustOutNodeName = AlphArray(4); - FuelCell(thisFuelCell).ExhaustHX.ExhaustOutNode = GetOnlySingleNode( - AlphArray(4), ErrorsFound, cCurrentModuleObject, AlphArray(1), NodeType_Air, NodeConnectionType_Outlet, 2, ObjectIsNotParent); + FuelCell(thisFuelCell).ExhaustHX.ExhaustOutNode = NodeInputManager::GetOnlySingleNode( + AlphArray(4), ErrorsFound, DataIPShortCuts::cCurrentModuleObject, AlphArray(1), NodeType_Air, NodeConnectionType_Outlet, 2, ObjectIsNotParent); if (UtilityRoutines::SameString("FixedEffectiveness", AlphArray(5))) { FuelCell(thisFuelCell).ExhaustHX.HXmodelMode = FixedEffectiveness; @@ -768,8 +763,8 @@ namespace FuelCellElectricGenerator { } else if (UtilityRoutines::SameString("CONDENSING", AlphArray(5))) { FuelCell(thisFuelCell).ExhaustHX.HXmodelMode = Condensing; } else { - ShowSevereError("Invalid, " + cAlphaFieldNames(5) + " = " + AlphArray(5)); - ShowContinueError("Entered in " + cCurrentModuleObject + '=' + AlphArray(1)); + ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(5) + " = " + AlphArray(5)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } FuelCell(thisFuelCell).ExhaustHX.WaterVolumeFlowMax = NumArray(1); @@ -795,25 +790,25 @@ namespace FuelCellElectricGenerator { // store cooling water volume flow rate for autosizing system PlantUtilities::RegisterPlantCompDesignFlow(FuelCell(thisFuelCell).ExhaustHX.WaterInNode, FuelCell(thisFuelCell).ExhaustHX.WaterVolumeFlowMax); } else { - ShowSevereError("Invalid, " + cAlphaFieldNames(1) + " = " + AlphArray(1)); - ShowContinueError("Entered in " + cCurrentModuleObject + '=' + AlphArray(1)); + ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(1) + " = " + AlphArray(1)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } } - cCurrentModuleObject = "Generator:FuelCell:ElectricalStorage"; - NumFCElecStorageUnits = inputProcessor->getNumObjectsFound(cCurrentModuleObject); + DataIPShortCuts::cCurrentModuleObject = "Generator:FuelCell:ElectricalStorage"; + NumFCElecStorageUnits = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); if (NumFCElecStorageUnits <= 0) { - ShowWarningError("No " + cCurrentModuleObject + " equipment specified in input file"); - ShowContinueError("Fuel Cell model requires an " + cCurrentModuleObject + " object"); + ShowWarningError("No " + DataIPShortCuts::cCurrentModuleObject + " equipment specified in input file"); + ShowContinueError("Fuel Cell model requires an " + DataIPShortCuts::cCurrentModuleObject + " object"); ErrorsFound = true; } for (StorageNum = 1; StorageNum <= NumFCElecStorageUnits; ++StorageNum) { inputProcessor->getObjectItem( - cCurrentModuleObject, StorageNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat, _, _, cAlphaFieldNames, cNumericFieldNames); - UtilityRoutines::IsNameEmpty(AlphArray(1), cCurrentModuleObject, ErrorsFound); + DataIPShortCuts::cCurrentModuleObject, StorageNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat, _, _, DataIPShortCuts::cAlphaFieldNames, DataIPShortCuts::cNumericFieldNames); + UtilityRoutines::IsNameEmpty(AlphArray(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), FuelCell, &FCDataStruct::NameElecStorage); if (thisFuelCell > 0) { @@ -822,8 +817,8 @@ namespace FuelCellElectricGenerator { if (UtilityRoutines::SameString(AlphArray(2), "SimpleEfficiencyWithConstraints")) { FuelCell(thisFuelCell).ElecStorage.StorageModelMode = SimpleEffConstraints; } else { - ShowSevereError("Invalid, " + cAlphaFieldNames(2) + " = " + AlphArray(2)); - ShowContinueError("Entered in " + cCurrentModuleObject + '=' + AlphArray(1)); + ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(2) + " = " + AlphArray(2)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } FuelCell(thisFuelCell).ElecStorage.EnergeticEfficCharge = NumArray(1); @@ -840,26 +835,26 @@ namespace FuelCellElectricGenerator { } } } else { - ShowSevereError("Invalid, " + cAlphaFieldNames(1) + " = " + AlphArray(1)); - ShowContinueError("Entered in " + cCurrentModuleObject + '=' + AlphArray(1)); + ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(1) + " = " + AlphArray(1)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } } - cCurrentModuleObject = "Generator:FuelCell:Inverter"; - NumFCPowerCondUnits = inputProcessor->getNumObjectsFound(cCurrentModuleObject); + DataIPShortCuts::cCurrentModuleObject = "Generator:FuelCell:Inverter"; + NumFCPowerCondUnits = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); if (NumFCPowerCondUnits <= 0) { - ShowWarningError("No " + cCurrentModuleObject + " equipment specified in input file"); - ShowContinueError("Fuel Cell model requires a " + cCurrentModuleObject + " object"); + ShowWarningError("No " + DataIPShortCuts::cCurrentModuleObject + " equipment specified in input file"); + ShowContinueError("Fuel Cell model requires a " + DataIPShortCuts::cCurrentModuleObject + " object"); ErrorsFound = true; } for (FCPCUNum = 1; FCPCUNum <= NumFCPowerCondUnits; ++FCPCUNum) { inputProcessor->getObjectItem( - cCurrentModuleObject, FCPCUNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat, _, _, cAlphaFieldNames, cNumericFieldNames); - UtilityRoutines::IsNameEmpty(AlphArray(1), cCurrentModuleObject, ErrorsFound); + DataIPShortCuts::cCurrentModuleObject, FCPCUNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat, _, _, DataIPShortCuts::cAlphaFieldNames, DataIPShortCuts::cNumericFieldNames); + UtilityRoutines::IsNameEmpty(AlphArray(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), FuelCell, &FCDataStruct::NameInverter); if (thisFuelCell > 0) { @@ -868,8 +863,8 @@ namespace FuelCellElectricGenerator { if (UtilityRoutines::SameString(AlphArray(2), "QUADRATIC")) FuelCell(thisFuelCell).Inverter.EffMode = InverterEffQuadratic; if (UtilityRoutines::SameString(AlphArray(2), "Constant")) FuelCell(thisFuelCell).Inverter.EffMode = InverterEffConstant; if (FuelCell(thisFuelCell).Inverter.EffMode == 0) { - ShowSevereError("Invalid, " + cAlphaFieldNames(2) + " = " + AlphArray(2)); - ShowContinueError("Entered in " + cCurrentModuleObject + '=' + AlphArray(1)); + ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(2) + " = " + AlphArray(2)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } @@ -878,8 +873,8 @@ namespace FuelCellElectricGenerator { FuelCell(thisFuelCell).Inverter.EffQuadraticCurveID = CurveManager::GetCurveIndex(AlphArray(3)); if ((FuelCell(thisFuelCell).Inverter.EffQuadraticCurveID == 0) && (FuelCell(thisFuelCell).Inverter.EffMode == InverterEffQuadratic)) { - ShowSevereError("Invalid, " + cAlphaFieldNames(3) + " = " + AlphArray(3)); - ShowContinueError("Entered in " + cCurrentModuleObject + '=' + AlphArray(1)); + ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(3) + " = " + AlphArray(3)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ShowContinueError("Curve was not found "); ErrorsFound = true; } @@ -891,18 +886,18 @@ namespace FuelCellElectricGenerator { } } } else { - ShowSevereError("Invalid, " + cAlphaFieldNames(1) + " = " + AlphArray(1)); - ShowContinueError("Entered in " + cCurrentModuleObject + '=' + AlphArray(1)); + ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(1) + " = " + AlphArray(1)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } } - cCurrentModuleObject = "Generator:FuelCell:StackCooler"; - NumFCStackCoolers = inputProcessor->getNumObjectsFound(cCurrentModuleObject); + DataIPShortCuts::cCurrentModuleObject = "Generator:FuelCell:StackCooler"; + NumFCStackCoolers = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); if (NumFCStackCoolers > 0) { // get stack cooler input data for (FCScoolNum = 1; FCScoolNum <= NumFCStackCoolers; ++FCScoolNum) { - inputProcessor->getObjectItem(cCurrentModuleObject, + inputProcessor->getObjectItem(DataIPShortCuts::cCurrentModuleObject, FCScoolNum, AlphArray, NumAlphas, @@ -911,9 +906,9 @@ namespace FuelCellElectricGenerator { IOStat, _, _, - cAlphaFieldNames, - cNumericFieldNames); - UtilityRoutines::IsNameEmpty(AlphArray(1), cCurrentModuleObject, ErrorsFound); + DataIPShortCuts::cAlphaFieldNames, + DataIPShortCuts::cNumericFieldNames); + UtilityRoutines::IsNameEmpty(AlphArray(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), FuelCell, &FCDataStruct::NameStackCooler); if (thisFuelCell > 0) { @@ -922,23 +917,23 @@ namespace FuelCellElectricGenerator { FuelCell(thisFuelCell).StackCooler.WaterOutNodeName = AlphArray(3); - FuelCell(thisFuelCell).StackCooler.WaterInNode = GetOnlySingleNode(AlphArray(2), + FuelCell(thisFuelCell).StackCooler.WaterInNode = NodeInputManager::GetOnlySingleNode(AlphArray(2), ErrorsFound, - cCurrentModuleObject, + DataIPShortCuts::cCurrentModuleObject, AlphArray(1), NodeType_Water, NodeConnectionType_Inlet, 1, ObjectIsNotParent); - FuelCell(thisFuelCell).StackCooler.WaterOutNode = GetOnlySingleNode(AlphArray(3), + FuelCell(thisFuelCell).StackCooler.WaterOutNode = NodeInputManager::GetOnlySingleNode(AlphArray(3), ErrorsFound, - cCurrentModuleObject, + DataIPShortCuts::cCurrentModuleObject, AlphArray(1), NodeType_Water, NodeConnectionType_Outlet, 1, ObjectIsNotParent); - BranchNodeConnections::TestCompSet(cCurrentModuleObject, AlphArray(1), AlphArray(2), AlphArray(3), "Heat Recovery Nodes"); + BranchNodeConnections::TestCompSet(DataIPShortCuts::cCurrentModuleObject, AlphArray(1), AlphArray(2), AlphArray(3), "Heat Recovery Nodes"); FuelCell(thisFuelCell).StackCooler.TstackNom = NumArray(1); FuelCell(thisFuelCell).StackCooler.TstackActual = NumArray(2); @@ -962,8 +957,8 @@ namespace FuelCellElectricGenerator { FuelCell(thisFuelCell).StackCooler.StackCoolerPresent = true; } else { - ShowSevereError("Invalid, " + cAlphaFieldNames(1) + " = " + AlphArray(1)); - ShowContinueError("Entered in " + cCurrentModuleObject + '=' + AlphArray(1)); + ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(1) + " = " + AlphArray(1)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } } @@ -1368,9 +1363,6 @@ namespace FuelCellElectricGenerator { // REFERENCES: IEA/ECBCS Annex 42.... - using DataHeatBalFanSys::ZT; - using ScheduleManager::GetCurrentScheduleValue; - static Real64 PpcuLosses; // losses in inverter [W] Real64 Pel; // DC power generated in Fuel Cell Power Module Real64 Pdemand; @@ -1574,7 +1566,7 @@ namespace FuelCellElectricGenerator { } else if (FuelSupply(FuelCell(GeneratorNum).FuelSupNum).FuelTempMode == FuelInTempSchedule) { FuelSupply(FuelCell(GeneratorNum).FuelSupNum).TfuelIntoCompress = - GetCurrentScheduleValue(FuelSupply(FuelCell(GeneratorNum).FuelSupNum).SchedNum); + ScheduleManager::GetCurrentScheduleValue(FuelSupply(FuelCell(GeneratorNum).FuelSupNum).SchedNum); } // evaluate heat capacity at average temperature usign shomate @@ -1633,7 +1625,7 @@ namespace FuelCellElectricGenerator { } else if (SELECT_CASE_var == WaterInReformSchedule) { - FuelCell(GeneratorNum).WaterSup.TwaterIntoCompress = GetCurrentScheduleValue(FuelCell(GeneratorNum).WaterSup.SchedNum); + FuelCell(GeneratorNum).WaterSup.TwaterIntoCompress = ScheduleManager::GetCurrentScheduleValue(FuelCell(GeneratorNum).WaterSup.SchedNum); } } @@ -1836,7 +1828,7 @@ namespace FuelCellElectricGenerator { // get zone air temp if (FuelCell(GeneratorNum).FCPM.ZoneID > 0) { FuelCell(GeneratorNum).FCPM.QdotSkin = FuelCell(GeneratorNum).FCPM.UAskin * - (FuelCell(GeneratorNum).FCPM.TprodGasLeavingFCPM - ZT(FuelCell(GeneratorNum).FCPM.ZoneID)); + (FuelCell(GeneratorNum).FCPM.TprodGasLeavingFCPM - DataHeatBalFanSys::ZT(FuelCell(GeneratorNum).FCPM.ZoneID)); } } else if (FuelCell(GeneratorNum).FCPM.SkinLossMode == QuadraticFuelNdotSkin) { @@ -2990,8 +2982,6 @@ namespace FuelCellElectricGenerator { // REFERENCES: Annex 42 model documentation - using FluidProperties::GetSpecificHeatGlycol; - static std::string const RoutineName("CalcFuelCellGenHeatRecovery"); Real64 eHX; // fixed effectiveness @@ -3054,7 +3044,7 @@ namespace FuelCellElectricGenerator { THXexh = TprodGasIn - qHX / (NdotGas * CpProdGasMol * 1000.0); - Cp = GetSpecificHeatGlycol( + Cp = FluidProperties::GetSpecificHeatGlycol( DataPlant::PlantLoop(FuelCell(Num).CWLoopNum).FluidName, TwaterIn, DataPlant::PlantLoop(FuelCell(Num).CWLoopNum).FluidIndex, RoutineName); if (MdotWater * Cp <= 0.0) { @@ -3356,7 +3346,6 @@ namespace FuelCellElectricGenerator { // Uses the status flags to trigger initializations. using DataLoopNode::Node; - using FluidProperties::GetDensityGlycol; static std::string const RoutineName("InitFuelCellGenerators"); @@ -3463,7 +3452,7 @@ namespace FuelCellElectricGenerator { FuelCell(FCnum).Inverter.PCUlosses = 0.0; FuelCell(FCnum).Inverter.QairIntake = 0.0; - rho = GetDensityGlycol( + rho = FluidProperties::GetDensityGlycol( DataPlant::PlantLoop(FuelCell(FCnum).CWLoopNum).FluidName, InitHRTemp, DataPlant::PlantLoop(FuelCell(FCnum).CWLoopNum).FluidIndex, RoutineName); FuelCell(FCnum).ExhaustHX.WaterMassFlowRateDesign = FuelCell(FCnum).ExhaustHX.WaterVolumeFlowMax * rho; From 205bbbe626557de81c1b2413085f9d8e734019af Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Mon, 11 Nov 2019 13:25:42 -0700 Subject: [PATCH 14/51] partial cleanup usings --- src/EnergyPlus/FuelCellElectricGenerator.cc | 72 ++++++++++----------- 1 file changed, 33 insertions(+), 39 deletions(-) diff --git a/src/EnergyPlus/FuelCellElectricGenerator.cc b/src/EnergyPlus/FuelCellElectricGenerator.cc index c659893d482..5d22797ed06 100644 --- a/src/EnergyPlus/FuelCellElectricGenerator.cc +++ b/src/EnergyPlus/FuelCellElectricGenerator.cc @@ -58,7 +58,6 @@ #include #include #include -#include #include #include #include @@ -69,7 +68,6 @@ #include #include #include -#include #include #include #include @@ -84,7 +82,7 @@ namespace EnergyPlus { namespace FuelCellElectricGenerator { // MODULE INFORMATION: - // AUTHOR Brent Griffth + // AUTHOR Brent Griffith // DATE WRITTEN August. 2005 // MODIFIED na // RE-ENGINEERED na @@ -103,9 +101,7 @@ namespace FuelCellElectricGenerator { // Using/Aliasing using namespace DataGenerators; - using namespace DataLoopNode; using namespace GeneratorFuelSupply; - using namespace GeneratorDynamicsManager; bool GetFuelCellInput(true); // When TRUE, calls subroutine to read input file. Array1D_bool CheckEquipName; @@ -343,10 +339,10 @@ namespace FuelCellElectricGenerator { FuelCell(thisFuelCell).FCPM.StackHeatLossToDilution = NumArray(23); FuelCell(thisFuelCell).FCPM.DilutionInletNodeName = AlphArray(7); FuelCell(thisFuelCell).FCPM.DilutionInletNode = NodeInputManager::GetOnlySingleNode( - AlphArray(7), ErrorsFound, DataIPShortCuts::cCurrentModuleObject, AlphArray(1), NodeType_Air, NodeConnectionType_Inlet, 1, ObjectIsNotParent); + AlphArray(7), ErrorsFound, DataIPShortCuts::cCurrentModuleObject, AlphArray(1), DataLoopNode::NodeType_Air, DataLoopNode::NodeConnectionType_Inlet, 1, DataLoopNode::ObjectIsNotParent); FuelCell(thisFuelCell).FCPM.DilutionExhaustNodeName = AlphArray(8); FuelCell(thisFuelCell).FCPM.DilutionExhaustNode = NodeInputManager::GetOnlySingleNode( - AlphArray(8), ErrorsFound, DataIPShortCuts::cCurrentModuleObject, AlphArray(1), NodeType_Air, NodeConnectionType_Outlet, 1, ObjectIsNotParent); + AlphArray(8), ErrorsFound, DataIPShortCuts::cCurrentModuleObject, AlphArray(1), DataLoopNode::NodeType_Air, DataLoopNode::NodeConnectionType_Outlet, 1, DataLoopNode::ObjectIsNotParent); FuelCell(thisFuelCell).FCPM.PelMin = NumArray(24); FuelCell(thisFuelCell).FCPM.PelMax = NumArray(25); @@ -401,7 +397,7 @@ namespace FuelCellElectricGenerator { // check the node connections FuelCell(thisFuelCell).AirSup.SupNodeNum = NodeInputManager::GetOnlySingleNode( - AlphArray(2), ErrorsFound, DataIPShortCuts::cCurrentModuleObject, AlphArray(1), NodeType_Air, NodeConnectionType_Inlet, 1, ObjectIsNotParent); + AlphArray(2), ErrorsFound, DataIPShortCuts::cCurrentModuleObject, AlphArray(1), DataLoopNode::NodeType_Air, DataLoopNode::NodeConnectionType_Inlet, 1, DataLoopNode::ObjectIsNotParent); FuelCell(thisFuelCell).AirSup.BlowerPowerCurveID = CurveManager::GetCurveIndex(AlphArray(3)); if (FuelCell(thisFuelCell).AirSup.BlowerPowerCurveID == 0) { @@ -601,10 +597,10 @@ namespace FuelCellElectricGenerator { ErrorsFound, DataIPShortCuts::cCurrentModuleObject, AlphArray(1), - NodeType_Air, - NodeConnectionType_Sensor, + DataLoopNode::NodeType_Air, + DataLoopNode::NodeConnectionType_Sensor, 1, - ObjectIsNotParent); + DataLoopNode::ObjectIsNotParent); } else if (UtilityRoutines::SameString("TemperatureFromWaterNode", AlphArray(4))) { FuelCell(thisFuelCell).WaterSup.WaterTempMode = WaterInReformWaterNode; @@ -614,10 +610,10 @@ namespace FuelCellElectricGenerator { ErrorsFound, DataIPShortCuts::cCurrentModuleObject, AlphArray(1), - NodeType_Water, - NodeConnectionType_Sensor, + DataLoopNode::NodeType_Water, + DataLoopNode::NodeConnectionType_Sensor, 1, - ObjectIsNotParent); + DataLoopNode::ObjectIsNotParent); } else if (UtilityRoutines::SameString("MainsWaterTemperature", AlphArray(4))) { FuelCell(thisFuelCell).WaterSup.WaterTempMode = WaterInReformMains; @@ -735,24 +731,24 @@ namespace FuelCellElectricGenerator { ErrorsFound, DataIPShortCuts::cCurrentModuleObject, AlphArray(1), - NodeType_Water, - NodeConnectionType_Inlet, + DataLoopNode::NodeType_Water, + DataLoopNode::NodeConnectionType_Inlet, 1, - ObjectIsNotParent); + DataLoopNode::ObjectIsNotParent); FuelCell(thisFuelCell).ExhaustHX.WaterOutNode = NodeInputManager::GetOnlySingleNode(AlphArray(3), ErrorsFound, DataIPShortCuts::cCurrentModuleObject, AlphArray(1), - NodeType_Water, - NodeConnectionType_Outlet, + DataLoopNode::NodeType_Water, + DataLoopNode::NodeConnectionType_Outlet, 1, - ObjectIsNotParent); + DataLoopNode::ObjectIsNotParent); BranchNodeConnections::TestCompSet(DataIPShortCuts::cCurrentModuleObject, AlphArray(1), AlphArray(2), AlphArray(3), "Heat Recovery Nodes"); // CR9240 FuelCell(thisFuelCell).ExhaustHX.ExhaustOutNodeName = AlphArray(4); FuelCell(thisFuelCell).ExhaustHX.ExhaustOutNode = NodeInputManager::GetOnlySingleNode( - AlphArray(4), ErrorsFound, DataIPShortCuts::cCurrentModuleObject, AlphArray(1), NodeType_Air, NodeConnectionType_Outlet, 2, ObjectIsNotParent); + AlphArray(4), ErrorsFound, DataIPShortCuts::cCurrentModuleObject, AlphArray(1), DataLoopNode::NodeType_Air, DataLoopNode::NodeConnectionType_Outlet, 2, DataLoopNode::ObjectIsNotParent); if (UtilityRoutines::SameString("FixedEffectiveness", AlphArray(5))) { FuelCell(thisFuelCell).ExhaustHX.HXmodelMode = FixedEffectiveness; @@ -921,18 +917,18 @@ namespace FuelCellElectricGenerator { ErrorsFound, DataIPShortCuts::cCurrentModuleObject, AlphArray(1), - NodeType_Water, - NodeConnectionType_Inlet, + DataLoopNode::NodeType_Water, + DataLoopNode::NodeConnectionType_Inlet, 1, - ObjectIsNotParent); + DataLoopNode::ObjectIsNotParent); FuelCell(thisFuelCell).StackCooler.WaterOutNode = NodeInputManager::GetOnlySingleNode(AlphArray(3), ErrorsFound, DataIPShortCuts::cCurrentModuleObject, AlphArray(1), - NodeType_Water, - NodeConnectionType_Outlet, + DataLoopNode::NodeType_Water, + DataLoopNode::NodeConnectionType_Outlet, 1, - ObjectIsNotParent); + DataLoopNode::ObjectIsNotParent); BranchNodeConnections::TestCompSet(DataIPShortCuts::cCurrentModuleObject, AlphArray(1), AlphArray(2), AlphArray(3), "Heat Recovery Nodes"); FuelCell(thisFuelCell).StackCooler.TstackNom = NumArray(1); @@ -1561,7 +1557,7 @@ namespace FuelCellElectricGenerator { if (FuelSupply(FuelCell(GeneratorNum).FuelSupNum).FuelTempMode == FuelInTempFromNode) { - FuelSupply(FuelCell(GeneratorNum).FuelSupNum).TfuelIntoCompress = Node(FuelSupply(FuelCell(GeneratorNum).FuelSupNum).NodeNum).Temp; + FuelSupply(FuelCell(GeneratorNum).FuelSupNum).TfuelIntoCompress = DataLoopNode::Node(FuelSupply(FuelCell(GeneratorNum).FuelSupNum).NodeNum).Temp; } else if (FuelSupply(FuelCell(GeneratorNum).FuelSupNum).FuelTempMode == FuelInTempSchedule) { @@ -1621,7 +1617,7 @@ namespace FuelCellElectricGenerator { } else if ((SELECT_CASE_var == WaterInReformAirNode) || (SELECT_CASE_var == WaterInReformWaterNode)) { - FuelCell(GeneratorNum).WaterSup.TwaterIntoCompress = Node(FuelCell(GeneratorNum).WaterSup.NodeNum).Temp; + FuelCell(GeneratorNum).WaterSup.TwaterIntoCompress = DataLoopNode::Node(FuelCell(GeneratorNum).WaterSup.NodeNum).Temp; } else if (SELECT_CASE_var == WaterInReformSchedule) { @@ -1661,7 +1657,7 @@ namespace FuelCellElectricGenerator { // Calculation Step 7, Air compressor - FuelCell(GeneratorNum).AirSup.TairIntoBlower = Node(FuelCell(GeneratorNum).AirSup.SupNodeNum).Temp; + FuelCell(GeneratorNum).AirSup.TairIntoBlower = DataLoopNode::Node(FuelCell(GeneratorNum).AirSup.SupNodeNum).Temp; FuelCell(GeneratorNum).AirSup.PairCompEl = CurveManager::CurveValue(FuelCell(GeneratorNum).AirSup.BlowerPowerCurveID, FuelCell(GeneratorNum).FCPM.NdotAir); @@ -3256,7 +3252,7 @@ namespace FuelCellElectricGenerator { FuelCell(Num).ExhaustHX.CondensateRate = NdotWaterCond; FuelCell(Num).ExhaustHX.WaterOutletTemp = TwaterOut; - FuelCell(Num).ExhaustHX.WaterOutletEnthalpy = Node(inNodeNum).Enthalpy + qHX; + FuelCell(Num).ExhaustHX.WaterOutletEnthalpy = DataLoopNode::Node(inNodeNum).Enthalpy + qHX; } void SimFuelCellPlantHeatRecovery(std::string const &EP_UNUSED(CompType), @@ -3345,8 +3341,6 @@ namespace FuelCellElectricGenerator { // METHODOLOGY EMPLOYED: // Uses the status flags to trigger initializations. - using DataLoopNode::Node; - static std::string const RoutineName("InitFuelCellGenerators"); static bool InitGeneratorOnce(true); // flag for 1 time initialization @@ -3459,8 +3453,8 @@ namespace FuelCellElectricGenerator { FuelCell(FCnum).ExhaustHX.WaterMassFlowRate = FuelCell(FCnum).ExhaustHX.WaterMassFlowRateDesign; inNode = FuelCell(FCnum).ExhaustHX.WaterInNode; outNode = FuelCell(FCnum).ExhaustHX.WaterOutNode; - Node(inNode).Temp = InitHRTemp; - Node(outNode).Temp = InitHRTemp; + DataLoopNode::Node(inNode).Temp = InitHRTemp; + DataLoopNode::Node(outNode).Temp = InitHRTemp; PlantUtilities::InitComponentNodes(0.0, FuelCell(FCnum).ExhaustHX.WaterMassFlowRateDesign, @@ -3507,7 +3501,7 @@ namespace FuelCellElectricGenerator { FuelCell(FCnum).CWCompNum); FuelCell(FCnum).ExhaustHX.WaterMassFlowRate = mdot; - FuelCell(FCnum).ExhaustHX.WaterInletTemp = Node(inNode).Temp; + FuelCell(FCnum).ExhaustHX.WaterInletTemp = DataLoopNode::Node(inNode).Temp; FuelCell(FCnum).TimeElapsed = TimeElapsed; } else { inNode = FuelCell(FCnum).ExhaustHX.WaterInNode; @@ -3520,7 +3514,7 @@ namespace FuelCellElectricGenerator { FuelCell(FCnum).CWBranchNum, FuelCell(FCnum).CWCompNum); - FuelCell(FCnum).ExhaustHX.WaterInletTemp = Node(inNode).Temp; + FuelCell(FCnum).ExhaustHX.WaterInletTemp = DataLoopNode::Node(inNode).Temp; } } @@ -3651,8 +3645,8 @@ namespace FuelCellElectricGenerator { PlantUtilities::SafeCopyPlantNode(InNodeNum, OutNodeNum); - Node(OutNodeNum).Temp = FuelCell(Num).ExhaustHX.WaterOutletTemp; - Node(OutNodeNum).Enthalpy = FuelCell(Num).ExhaustHX.WaterOutletEnthalpy; + DataLoopNode::Node(OutNodeNum).Temp = FuelCell(Num).ExhaustHX.WaterOutletTemp; + DataLoopNode::Node(OutNodeNum).Enthalpy = FuelCell(Num).ExhaustHX.WaterOutletEnthalpy; } void UpdateFuelCellGeneratorRecords(bool const EP_UNUSED(RunFlag), // TRUE if Generator operating From 7257c709627b3315ad6a249294a15b51748066b5 Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Mon, 11 Nov 2019 13:59:26 -0700 Subject: [PATCH 15/51] partial cleanup usings --- src/EnergyPlus/FuelCellElectricGenerator.cc | 499 +++++++++++++++++++- 1 file changed, 486 insertions(+), 13 deletions(-) diff --git a/src/EnergyPlus/FuelCellElectricGenerator.cc b/src/EnergyPlus/FuelCellElectricGenerator.cc index 5d22797ed06..bd356c0efff 100644 --- a/src/EnergyPlus/FuelCellElectricGenerator.cc +++ b/src/EnergyPlus/FuelCellElectricGenerator.cc @@ -99,10 +99,6 @@ namespace FuelCellElectricGenerator { // REFERENCES: // IEA/ECBCS Annex 42 model specification for Solid oxide and proton exchange membrane fuel cells - // Using/Aliasing - using namespace DataGenerators; - using namespace GeneratorFuelSupply; - bool GetFuelCellInput(true); // When TRUE, calls subroutine to read input file. Array1D_bool CheckEquipName; @@ -122,6 +118,9 @@ namespace FuelCellElectricGenerator { // gets the input for the models, initializes simulation variables, call // the appropriate model and sets up reporting variables. + using DataGenerators::FuelCell; + using DataGenerators::NumFuelCellGenerators; + int GenNum; // Generator number counter // Get Generator data from input file @@ -171,6 +170,41 @@ namespace FuelCellElectricGenerator { // METHODOLOGY EMPLOYED: // EnergyPlus input processor + using DataGenerators::FuelCell; + using DataGenerators::NumFuelCellGenerators; + using DataGenerators::FCDataStruct; + using DataGenerators::DirectCurveMode; + using DataGenerators::NormalizedCurveMode; + using DataGenerators::ConstantRateSkinLoss; + using DataGenerators::UADTSkinLoss; + using DataGenerators::QuadraticFuelNdotSkin; + using DataGenerators::NumGeneratorFuelSups; + using DataGenerators::FuelSupply; + using DataGenerators::ConstantStoicsAirRat; + using DataGenerators::QuadraticFuncofPel; + using DataGenerators::QuadraticFuncofNdot; + using DataGenerators::RecoverBurnInvertBatt; + using DataGenerators::RecoverAuxiliaryBurner; + using DataGenerators::RecoverInverterBatt; + using DataGenerators::RecoverInverter; + using DataGenerators::RecoverBattery; + using DataGenerators::NoRecoveryOnAirIntake; + using DataGenerators::RegularAir; + using DataGenerators::UserDefinedConstituents; + using DataGenerators::GasPhaseThermoChemistryData; + using DataGenerators::GasPropertyDataStruct; + using DataGenerators::WaterInReformAirNode; + using DataGenerators::WaterInReformWaterNode; + using DataGenerators::WaterInReformMains; + using DataGenerators::WaterInReformSchedule; + using DataGenerators::SurroundingZone; + using DataGenerators::AirInletForFC; + using DataGenerators::FixedEffectiveness; + using DataGenerators::LMTDempiricalUAeff; + using DataGenerators::LMTDfundementalUAeff; + using DataGenerators::Condensing; + using DataGenerators::SimpleEffConstraints; + int GeneratorNum; // Generator counter int NumAlphas; // Number of elements in the alpha array int NumNums; // Number of elements in the numeric array @@ -360,10 +394,10 @@ namespace FuelCellElectricGenerator { } } // loop over NumFuelCellPMs - GetGeneratorFuelSupplyInput(); + GeneratorFuelSupply::GetGeneratorFuelSupplyInput(); for (FuelSupNum = 1; FuelSupNum <= NumGeneratorFuelSups; ++FuelSupNum) { - SetupFuelConstituentData(FuelSupNum, ErrorsFound); + GeneratorFuelSupply::SetupFuelConstituentData(FuelSupNum, ErrorsFound); } // set fuel supply ID in Fuel cell structure @@ -856,8 +890,8 @@ namespace FuelCellElectricGenerator { if (thisFuelCell > 0) { FuelCell(thisFuelCell).Inverter.Name = AlphArray(1); - if (UtilityRoutines::SameString(AlphArray(2), "QUADRATIC")) FuelCell(thisFuelCell).Inverter.EffMode = InverterEffQuadratic; - if (UtilityRoutines::SameString(AlphArray(2), "Constant")) FuelCell(thisFuelCell).Inverter.EffMode = InverterEffConstant; + if (UtilityRoutines::SameString(AlphArray(2), "QUADRATIC")) FuelCell(thisFuelCell).Inverter.EffMode = DataGenerators::InverterEffQuadratic; + if (UtilityRoutines::SameString(AlphArray(2), "Constant")) FuelCell(thisFuelCell).Inverter.EffMode = DataGenerators::InverterEffConstant; if (FuelCell(thisFuelCell).Inverter.EffMode == 0) { ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(2) + " = " + AlphArray(2)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); @@ -868,7 +902,7 @@ namespace FuelCellElectricGenerator { FuelCell(thisFuelCell).Inverter.EffQuadraticCurveID = CurveManager::GetCurveIndex(AlphArray(3)); if ((FuelCell(thisFuelCell).Inverter.EffQuadraticCurveID == 0) && - (FuelCell(thisFuelCell).Inverter.EffMode == InverterEffQuadratic)) { + (FuelCell(thisFuelCell).Inverter.EffMode == DataGenerators::InverterEffQuadratic)) { ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(3) + " = " + AlphArray(3)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ShowContinueError("Curve was not found "); @@ -1359,6 +1393,46 @@ namespace FuelCellElectricGenerator { // REFERENCES: IEA/ECBCS Annex 42.... + using DataGenerators::FuelCell; + using DataGenerators::NumFuelCellGenerators; + using DataGenerators::FCDataStruct; + using DataGenerators::DirectCurveMode; + using DataGenerators::NormalizedCurveMode; + using DataGenerators::ConstantRateSkinLoss; + using DataGenerators::UADTSkinLoss; + using DataGenerators::QuadraticFuelNdotSkin; + using DataGenerators::NumGeneratorFuelSups; + using DataGenerators::FuelSupply; + using DataGenerators::ConstantStoicsAirRat; + using DataGenerators::QuadraticFuncofPel; + using DataGenerators::QuadraticFuncofNdot; + using DataGenerators::RecoverBurnInvertBatt; + using DataGenerators::RecoverAuxiliaryBurner; + using DataGenerators::RecoverInverterBatt; + using DataGenerators::RecoverInverter; + using DataGenerators::RecoverBattery; + using DataGenerators::NoRecoveryOnAirIntake; + using DataGenerators::RegularAir; + using DataGenerators::UserDefinedConstituents; + using DataGenerators::GasPhaseThermoChemistryData; + using DataGenerators::GasPropertyDataStruct; + using DataGenerators::WaterInReformAirNode; + using DataGenerators::WaterInReformWaterNode; + using DataGenerators::WaterInReformMains; + using DataGenerators::WaterInReformSchedule; + using DataGenerators::SurroundingZone; + using DataGenerators::AirInletForFC; + using DataGenerators::FixedEffectiveness; + using DataGenerators::LMTDempiricalUAeff; + using DataGenerators::LMTDfundementalUAeff; + using DataGenerators::Condensing; + using DataGenerators::SimpleEffConstraints; + using DataGenerators::FuelInTempFromNode; + using DataGenerators::FuelInTempSchedule; + using DataGenerators::MinProductGasTemp; + using DataGenerators::MaxProductGasTemp; + using DataGenerators::ImBalanceTol; + static Real64 PpcuLosses; // losses in inverter [W] Real64 Pel; // DC power generated in Fuel Cell Power Module Real64 Pdemand; @@ -1898,12 +1972,12 @@ namespace FuelCellElectricGenerator { PintoInverter = Pel - Pstorage; // refine power conditioning losses with more current power production - if (FuelCell(GeneratorNum).Inverter.EffMode == InverterEffConstant) { + if (FuelCell(GeneratorNum).Inverter.EffMode == DataGenerators::InverterEffConstant) { PpcuLosses = (1.0 - FuelCell(GeneratorNum).Inverter.ConstEff) * PintoInverter; } - if (FuelCell(GeneratorNum).Inverter.EffMode == InverterEffQuadratic) { + if (FuelCell(GeneratorNum).Inverter.EffMode == DataGenerators::InverterEffQuadratic) { PpcuLosses = (1.0 - CurveManager::CurveValue(FuelCell(GeneratorNum).Inverter.EffQuadraticCurveID, PintoInverter)) * PintoInverter; } @@ -1950,6 +2024,48 @@ namespace FuelCellElectricGenerator { // PURPOSE OF THIS SUBROUTINE: // manage controls and calculations related to electrical storage in FuelCell model + using DataGenerators::FuelCell; + using DataGenerators::NumFuelCellGenerators; + using DataGenerators::FCDataStruct; + using DataGenerators::DirectCurveMode; + using DataGenerators::NormalizedCurveMode; + using DataGenerators::ConstantRateSkinLoss; + using DataGenerators::UADTSkinLoss; + using DataGenerators::QuadraticFuelNdotSkin; + using DataGenerators::NumGeneratorFuelSups; + using DataGenerators::FuelSupply; + using DataGenerators::ConstantStoicsAirRat; + using DataGenerators::QuadraticFuncofPel; + using DataGenerators::QuadraticFuncofNdot; + using DataGenerators::RecoverBurnInvertBatt; + using DataGenerators::RecoverAuxiliaryBurner; + using DataGenerators::RecoverInverterBatt; + using DataGenerators::RecoverInverter; + using DataGenerators::RecoverBattery; + using DataGenerators::NoRecoveryOnAirIntake; + using DataGenerators::RegularAir; + using DataGenerators::UserDefinedConstituents; + using DataGenerators::GasPhaseThermoChemistryData; + using DataGenerators::GasPropertyDataStruct; + using DataGenerators::WaterInReformAirNode; + using DataGenerators::WaterInReformWaterNode; + using DataGenerators::WaterInReformMains; + using DataGenerators::WaterInReformSchedule; + using DataGenerators::SurroundingZone; + using DataGenerators::AirInletForFC; + using DataGenerators::FixedEffectiveness; + using DataGenerators::LMTDempiricalUAeff; + using DataGenerators::LMTDfundementalUAeff; + using DataGenerators::Condensing; + using DataGenerators::SimpleEffConstraints; + using DataGenerators::FuelInTempFromNode; + using DataGenerators::FuelInTempSchedule; + using DataGenerators::MinProductGasTemp; + using DataGenerators::MaxProductGasTemp; + using DataGenerators::ImBalanceTol; + using DataGenerators::LeadAcidBatterManwellMcGowan; + using DataGenerators::LeadAcidBatterySaupe; + Real64 tmpPdraw; // power draw from storage, working var Real64 tmpPcharge; // power charge to storage, working var bool drawing; // true if drawing power @@ -2159,6 +2275,50 @@ namespace FuelCellElectricGenerator { // REFERENCES: // NIST Webbook on gas phase thermochemistry + using DataGenerators::FuelCell; + using DataGenerators::NumFuelCellGenerators; + using DataGenerators::FCDataStruct; + using DataGenerators::DirectCurveMode; + using DataGenerators::NormalizedCurveMode; + using DataGenerators::ConstantRateSkinLoss; + using DataGenerators::UADTSkinLoss; + using DataGenerators::QuadraticFuelNdotSkin; + using DataGenerators::NumGeneratorFuelSups; + using DataGenerators::FuelSupply; + using DataGenerators::ConstantStoicsAirRat; + using DataGenerators::QuadraticFuncofPel; + using DataGenerators::QuadraticFuncofNdot; + using DataGenerators::RecoverBurnInvertBatt; + using DataGenerators::RecoverAuxiliaryBurner; + using DataGenerators::RecoverInverterBatt; + using DataGenerators::RecoverInverter; + using DataGenerators::RecoverBattery; + using DataGenerators::NoRecoveryOnAirIntake; + using DataGenerators::RegularAir; + using DataGenerators::UserDefinedConstituents; + using DataGenerators::GasPhaseThermoChemistryData; + using DataGenerators::GasPropertyDataStruct; + using DataGenerators::WaterInReformAirNode; + using DataGenerators::WaterInReformWaterNode; + using DataGenerators::WaterInReformMains; + using DataGenerators::WaterInReformSchedule; + using DataGenerators::SurroundingZone; + using DataGenerators::AirInletForFC; + using DataGenerators::FixedEffectiveness; + using DataGenerators::LMTDempiricalUAeff; + using DataGenerators::LMTDfundementalUAeff; + using DataGenerators::Condensing; + using DataGenerators::SimpleEffConstraints; + using DataGenerators::FuelInTempSchedule; + using DataGenerators::MinProductGasTemp; + using DataGenerators::MaxProductGasTemp; + using DataGenerators::ImBalanceTol; + using DataGenerators::LeadAcidBatterManwellMcGowan; + using DataGenerators::LeadAcidBatterySaupe; + using DataGenerators::NISTShomate; + using DataGenerators::NASAPolynomial; + using DataGenerators::RinKJperMolpK; + Real64 tempCp; int thisConstit; // loop index int gasID; @@ -2242,6 +2402,51 @@ namespace FuelCellElectricGenerator { // REFERENCES: // NIST Webbook on gas phase thermochemistry + using DataGenerators::FuelCell; + using DataGenerators::NumFuelCellGenerators; + using DataGenerators::FCDataStruct; + using DataGenerators::DirectCurveMode; + using DataGenerators::NormalizedCurveMode; + using DataGenerators::ConstantRateSkinLoss; + using DataGenerators::UADTSkinLoss; + using DataGenerators::QuadraticFuelNdotSkin; + using DataGenerators::NumGeneratorFuelSups; + using DataGenerators::FuelSupply; + using DataGenerators::ConstantStoicsAirRat; + using DataGenerators::QuadraticFuncofPel; + using DataGenerators::QuadraticFuncofNdot; + using DataGenerators::RecoverBurnInvertBatt; + using DataGenerators::RecoverAuxiliaryBurner; + using DataGenerators::RecoverInverterBatt; + using DataGenerators::RecoverInverter; + using DataGenerators::RecoverBattery; + using DataGenerators::NoRecoveryOnAirIntake; + using DataGenerators::RegularAir; + using DataGenerators::UserDefinedConstituents; + using DataGenerators::GasPhaseThermoChemistryData; + using DataGenerators::GasPropertyDataStruct; + using DataGenerators::WaterInReformAirNode; + using DataGenerators::WaterInReformWaterNode; + using DataGenerators::WaterInReformMains; + using DataGenerators::WaterInReformSchedule; + using DataGenerators::SurroundingZone; + using DataGenerators::AirInletForFC; + using DataGenerators::FixedEffectiveness; + using DataGenerators::LMTDempiricalUAeff; + using DataGenerators::LMTDfundementalUAeff; + using DataGenerators::Condensing; + using DataGenerators::SimpleEffConstraints; + using DataGenerators::FuelInTempFromNode; + using DataGenerators::FuelInTempSchedule; + using DataGenerators::MinProductGasTemp; + using DataGenerators::MaxProductGasTemp; + using DataGenerators::ImBalanceTol; + using DataGenerators::LeadAcidBatterManwellMcGowan; + using DataGenerators::LeadAcidBatterySaupe; + using DataGenerators::NISTShomate; + using DataGenerators::NASAPolynomial; + using DataGenerators::RinKJperMolpK; + Real64 tempHair; Real64 HairI; int thisConstit; // loop index @@ -2332,6 +2537,51 @@ namespace FuelCellElectricGenerator { // REFERENCES: // NIST Webbook on gas phase thermochemistry + using DataGenerators::FuelCell; + using DataGenerators::NumFuelCellGenerators; + using DataGenerators::FCDataStruct; + using DataGenerators::DirectCurveMode; + using DataGenerators::NormalizedCurveMode; + using DataGenerators::ConstantRateSkinLoss; + using DataGenerators::UADTSkinLoss; + using DataGenerators::QuadraticFuelNdotSkin; + using DataGenerators::NumGeneratorFuelSups; + using DataGenerators::FuelSupply; + using DataGenerators::ConstantStoicsAirRat; + using DataGenerators::QuadraticFuncofPel; + using DataGenerators::QuadraticFuncofNdot; + using DataGenerators::RecoverBurnInvertBatt; + using DataGenerators::RecoverAuxiliaryBurner; + using DataGenerators::RecoverInverterBatt; + using DataGenerators::RecoverInverter; + using DataGenerators::RecoverBattery; + using DataGenerators::NoRecoveryOnAirIntake; + using DataGenerators::RegularAir; + using DataGenerators::UserDefinedConstituents; + using DataGenerators::GasPhaseThermoChemistryData; + using DataGenerators::GasPropertyDataStruct; + using DataGenerators::WaterInReformAirNode; + using DataGenerators::WaterInReformWaterNode; + using DataGenerators::WaterInReformMains; + using DataGenerators::WaterInReformSchedule; + using DataGenerators::SurroundingZone; + using DataGenerators::AirInletForFC; + using DataGenerators::FixedEffectiveness; + using DataGenerators::LMTDempiricalUAeff; + using DataGenerators::LMTDfundementalUAeff; + using DataGenerators::Condensing; + using DataGenerators::SimpleEffConstraints; + using DataGenerators::FuelInTempFromNode; + using DataGenerators::FuelInTempSchedule; + using DataGenerators::MinProductGasTemp; + using DataGenerators::MaxProductGasTemp; + using DataGenerators::ImBalanceTol; + using DataGenerators::LeadAcidBatterManwellMcGowan; + using DataGenerators::LeadAcidBatterySaupe; + using DataGenerators::NISTShomate; + using DataGenerators::NASAPolynomial; + using DataGenerators::RinKJperMolpK; + Real64 tempCp; int thisConstit; // loop index int gasID; // look up into Gas structure @@ -2412,6 +2662,51 @@ namespace FuelCellElectricGenerator { // REFERENCES: // NIST Webbook on gas phase thermochemistry + using DataGenerators::FuelCell; + using DataGenerators::NumFuelCellGenerators; + using DataGenerators::FCDataStruct; + using DataGenerators::DirectCurveMode; + using DataGenerators::NormalizedCurveMode; + using DataGenerators::ConstantRateSkinLoss; + using DataGenerators::UADTSkinLoss; + using DataGenerators::QuadraticFuelNdotSkin; + using DataGenerators::NumGeneratorFuelSups; + using DataGenerators::FuelSupply; + using DataGenerators::ConstantStoicsAirRat; + using DataGenerators::QuadraticFuncofPel; + using DataGenerators::QuadraticFuncofNdot; + using DataGenerators::RecoverBurnInvertBatt; + using DataGenerators::RecoverAuxiliaryBurner; + using DataGenerators::RecoverInverterBatt; + using DataGenerators::RecoverInverter; + using DataGenerators::RecoverBattery; + using DataGenerators::NoRecoveryOnAirIntake; + using DataGenerators::RegularAir; + using DataGenerators::UserDefinedConstituents; + using DataGenerators::GasPhaseThermoChemistryData; + using DataGenerators::GasPropertyDataStruct; + using DataGenerators::WaterInReformAirNode; + using DataGenerators::WaterInReformWaterNode; + using DataGenerators::WaterInReformMains; + using DataGenerators::WaterInReformSchedule; + using DataGenerators::SurroundingZone; + using DataGenerators::AirInletForFC; + using DataGenerators::FixedEffectiveness; + using DataGenerators::LMTDempiricalUAeff; + using DataGenerators::LMTDfundementalUAeff; + using DataGenerators::Condensing; + using DataGenerators::SimpleEffConstraints; + using DataGenerators::FuelInTempFromNode; + using DataGenerators::FuelInTempSchedule; + using DataGenerators::MinProductGasTemp; + using DataGenerators::MaxProductGasTemp; + using DataGenerators::ImBalanceTol; + using DataGenerators::LeadAcidBatterManwellMcGowan; + using DataGenerators::LeadAcidBatterySaupe; + using DataGenerators::NISTShomate; + using DataGenerators::NASAPolynomial; + using DataGenerators::RinKJperMolpK; + Real64 tempHfuel; Real64 HfuelI; int thisConstit; // loop index @@ -2502,6 +2797,51 @@ namespace FuelCellElectricGenerator { // REFERENCES: // NIST Webbook on gas phase thermochemistry + using DataGenerators::FuelCell; + using DataGenerators::NumFuelCellGenerators; + using DataGenerators::FCDataStruct; + using DataGenerators::DirectCurveMode; + using DataGenerators::NormalizedCurveMode; + using DataGenerators::ConstantRateSkinLoss; + using DataGenerators::UADTSkinLoss; + using DataGenerators::QuadraticFuelNdotSkin; + using DataGenerators::NumGeneratorFuelSups; + using DataGenerators::FuelSupply; + using DataGenerators::ConstantStoicsAirRat; + using DataGenerators::QuadraticFuncofPel; + using DataGenerators::QuadraticFuncofNdot; + using DataGenerators::RecoverBurnInvertBatt; + using DataGenerators::RecoverAuxiliaryBurner; + using DataGenerators::RecoverInverterBatt; + using DataGenerators::RecoverInverter; + using DataGenerators::RecoverBattery; + using DataGenerators::NoRecoveryOnAirIntake; + using DataGenerators::RegularAir; + using DataGenerators::UserDefinedConstituents; + using DataGenerators::GasPhaseThermoChemistryData; + using DataGenerators::GasPropertyDataStruct; + using DataGenerators::WaterInReformAirNode; + using DataGenerators::WaterInReformWaterNode; + using DataGenerators::WaterInReformMains; + using DataGenerators::WaterInReformSchedule; + using DataGenerators::SurroundingZone; + using DataGenerators::AirInletForFC; + using DataGenerators::FixedEffectiveness; + using DataGenerators::LMTDempiricalUAeff; + using DataGenerators::LMTDfundementalUAeff; + using DataGenerators::Condensing; + using DataGenerators::SimpleEffConstraints; + using DataGenerators::FuelInTempFromNode; + using DataGenerators::FuelInTempSchedule; + using DataGenerators::MinProductGasTemp; + using DataGenerators::MaxProductGasTemp; + using DataGenerators::ImBalanceTol; + using DataGenerators::LeadAcidBatterManwellMcGowan; + using DataGenerators::LeadAcidBatterySaupe; + using DataGenerators::NISTShomate; + using DataGenerators::NASAPolynomial; + using DataGenerators::RinKJperMolpK; + Real64 tempHprodGases; int thisConstit; // loop index int gasID; // look up into Gas structure @@ -2579,6 +2919,51 @@ namespace FuelCellElectricGenerator { // MODIFIED na // RE-ENGINEERED na + using DataGenerators::FuelCell; + using DataGenerators::NumFuelCellGenerators; + using DataGenerators::FCDataStruct; + using DataGenerators::DirectCurveMode; + using DataGenerators::NormalizedCurveMode; + using DataGenerators::ConstantRateSkinLoss; + using DataGenerators::UADTSkinLoss; + using DataGenerators::QuadraticFuelNdotSkin; + using DataGenerators::NumGeneratorFuelSups; + using DataGenerators::FuelSupply; + using DataGenerators::ConstantStoicsAirRat; + using DataGenerators::QuadraticFuncofPel; + using DataGenerators::QuadraticFuncofNdot; + using DataGenerators::RecoverBurnInvertBatt; + using DataGenerators::RecoverAuxiliaryBurner; + using DataGenerators::RecoverInverterBatt; + using DataGenerators::RecoverInverter; + using DataGenerators::RecoverBattery; + using DataGenerators::NoRecoveryOnAirIntake; + using DataGenerators::RegularAir; + using DataGenerators::UserDefinedConstituents; + using DataGenerators::GasPhaseThermoChemistryData; + using DataGenerators::GasPropertyDataStruct; + using DataGenerators::WaterInReformAirNode; + using DataGenerators::WaterInReformWaterNode; + using DataGenerators::WaterInReformMains; + using DataGenerators::WaterInReformSchedule; + using DataGenerators::SurroundingZone; + using DataGenerators::AirInletForFC; + using DataGenerators::FixedEffectiveness; + using DataGenerators::LMTDempiricalUAeff; + using DataGenerators::LMTDfundementalUAeff; + using DataGenerators::Condensing; + using DataGenerators::SimpleEffConstraints; + using DataGenerators::FuelInTempFromNode; + using DataGenerators::FuelInTempSchedule; + using DataGenerators::MinProductGasTemp; + using DataGenerators::MaxProductGasTemp; + using DataGenerators::ImBalanceTol; + using DataGenerators::LeadAcidBatterManwellMcGowan; + using DataGenerators::LeadAcidBatterySaupe; + using DataGenerators::NISTShomate; + using DataGenerators::NASAPolynomial; + using DataGenerators::RinKJperMolpK; + Real64 tempCp; int thisConstit; // loop index int gasID; // look up into Gas structure @@ -2649,6 +3034,51 @@ namespace FuelCellElectricGenerator { // MODIFIED na // RE-ENGINEERED na + using DataGenerators::FuelCell; + using DataGenerators::NumFuelCellGenerators; + using DataGenerators::FCDataStruct; + using DataGenerators::DirectCurveMode; + using DataGenerators::NormalizedCurveMode; + using DataGenerators::ConstantRateSkinLoss; + using DataGenerators::UADTSkinLoss; + using DataGenerators::QuadraticFuelNdotSkin; + using DataGenerators::NumGeneratorFuelSups; + using DataGenerators::FuelSupply; + using DataGenerators::ConstantStoicsAirRat; + using DataGenerators::QuadraticFuncofPel; + using DataGenerators::QuadraticFuncofNdot; + using DataGenerators::RecoverBurnInvertBatt; + using DataGenerators::RecoverAuxiliaryBurner; + using DataGenerators::RecoverInverterBatt; + using DataGenerators::RecoverInverter; + using DataGenerators::RecoverBattery; + using DataGenerators::NoRecoveryOnAirIntake; + using DataGenerators::RegularAir; + using DataGenerators::UserDefinedConstituents; + using DataGenerators::GasPhaseThermoChemistryData; + using DataGenerators::GasPropertyDataStruct; + using DataGenerators::WaterInReformAirNode; + using DataGenerators::WaterInReformWaterNode; + using DataGenerators::WaterInReformMains; + using DataGenerators::WaterInReformSchedule; + using DataGenerators::SurroundingZone; + using DataGenerators::AirInletForFC; + using DataGenerators::FixedEffectiveness; + using DataGenerators::LMTDempiricalUAeff; + using DataGenerators::LMTDfundementalUAeff; + using DataGenerators::Condensing; + using DataGenerators::SimpleEffConstraints; + using DataGenerators::FuelInTempFromNode; + using DataGenerators::FuelInTempSchedule; + using DataGenerators::MinProductGasTemp; + using DataGenerators::MaxProductGasTemp; + using DataGenerators::ImBalanceTol; + using DataGenerators::LeadAcidBatterManwellMcGowan; + using DataGenerators::LeadAcidBatterySaupe; + using DataGenerators::NISTShomate; + using DataGenerators::NASAPolynomial; + using DataGenerators::RinKJperMolpK; + Real64 tempCp; int thisConstit; // loop index int gasID; // look up into Gas structure @@ -2802,6 +3232,9 @@ namespace FuelCellElectricGenerator { // PURPOSE OF THIS SUBROUTINE: // Calculate the AC ancillaries to determine Pel + using DataGenerators::FuelCell; + using DataGenerators::FuelSupply; + // Using lagged values inside a sequential substitution loop PacAncill = 0.0; // sect. 5.9 @@ -2834,16 +3267,18 @@ namespace FuelCellElectricGenerator { // PURPOSE OF THIS SUBROUTINE: // Calculate inverter losses + using DataGenerators::FuelCell; + Real64 lastPpcuLosses; // used in iterative solution int iter; Real64 Pel; - if (FuelCell(GeneratorNum).Inverter.EffMode == InverterEffConstant) { + if (FuelCell(GeneratorNum).Inverter.EffMode == DataGenerators::InverterEffConstant) { PpcuLosses = Pdemand * (1 - FuelCell(GeneratorNum).Inverter.ConstEff) / FuelCell(GeneratorNum).Inverter.ConstEff; } - if (FuelCell(GeneratorNum).Inverter.EffMode == InverterEffQuadratic) { + if (FuelCell(GeneratorNum).Inverter.EffMode == DataGenerators::InverterEffQuadratic) { // first use Pdemand instead of Pel to get initial estimate lastPpcuLosses = Pdemand * (1.0 - CurveManager::CurveValue(FuelCell(GeneratorNum).Inverter.EffQuadraticCurveID, Pdemand)) / @@ -2873,6 +3308,8 @@ namespace FuelCellElectricGenerator { // MODIFIED na // RE-ENGINEERED na + using DataGenerators::FuelCell; + Real64 CurrentFractionalDay; // working var, time in decimal days Real64 EndingFractionalDay; // working var, time is decimal days Real64 MaxPel; // working variable for max allowed by transient constraint @@ -2958,6 +3395,8 @@ namespace FuelCellElectricGenerator { // not yet implemented, just pass product gases thru nul domain + using DataGenerators::FuelCell; + FuelCell(Num).AuxilHeat.TauxMix = FuelCell(Num).FCPM.TprodGasLeavingFCPM; FuelCell(Num).AuxilHeat.NdotAuxMix = FuelCell(Num).FCPM.NdotProdGas; FuelCell(Num).AuxilHeat.ConstitMolalFract = FuelCell(Num).FCPM.ConstitMolalFract; @@ -2978,6 +3417,13 @@ namespace FuelCellElectricGenerator { // REFERENCES: Annex 42 model documentation + using DataGenerators::FuelCell; + using DataGenerators::FixedEffectiveness; + using DataGenerators::GasPhaseThermoChemistryData; + using DataGenerators::LMTDempiricalUAeff; + using DataGenerators::LMTDfundementalUAeff; + using DataGenerators::Condensing; + static std::string const RoutineName("CalcFuelCellGenHeatRecovery"); Real64 eHX; // fixed effectiveness @@ -3279,6 +3725,9 @@ namespace FuelCellElectricGenerator { // makes sure input are gotten and setup from Plant loop perspective. // does not (re)simulate entire FuelCell model + using DataGenerators::FuelCell; + using DataGenerators::FCDataStruct; + if (GetFuelCellInput) { // Read input data. @@ -3341,6 +3790,11 @@ namespace FuelCellElectricGenerator { // METHODOLOGY EMPLOYED: // Uses the status flags to trigger initializations. + using DataGenerators::NumFuelCellGenerators; + using DataGenerators::FuelCell; + using DataGenerators::FuelSupply; + using DataGenerators::InitHRTemp; + static std::string const RoutineName("InitFuelCellGenerators"); static bool InitGeneratorOnce(true); // flag for 1 time initialization @@ -3522,6 +3976,8 @@ namespace FuelCellElectricGenerator { std::string &heatRecoveryCompName) { + using DataGenerators::FuelCell; + if (GetFuelCellInput) { // Read input data. @@ -3552,6 +4008,16 @@ namespace FuelCellElectricGenerator { // This routine adds up the various skin losses and then // sets the values in the ZoneIntGain structure + using DataGenerators::NumFuelCellGenerators; + using DataGenerators::FuelCell; + using DataGenerators::FuelSupply; + using DataGenerators::NoRecoveryOnAirIntake; + using DataGenerators::RecoverAuxiliaryBurner; + using DataGenerators::RecoverInverterBatt; + using DataGenerators::RecoverInverter; + using DataGenerators::RecoverBattery; + using DataGenerators::RecoverBurnInvertBatt; + Real64 TotalZoneHeatGain; // working variable for zone gain [w] int FCnum; // number of fuel cell static bool MyEnvrnFlag(true); @@ -3636,6 +4102,8 @@ namespace FuelCellElectricGenerator { // PURPOSE OF THIS SUBROUTINE: // update plant loop interactions, do any calcs needed + using DataGenerators::FuelCell; + int InNodeNum; int OutNodeNum; @@ -3653,6 +4121,9 @@ namespace FuelCellElectricGenerator { int const Num // Generator number ) { + using DataGenerators::FuelCell; + using DataGenerators::FuelSupply; + FuelCell(Num).Report.ACPowerGen = FuelCell(Num).ACPowerGen; // electrical power produced [W] FuelCell(Num).Report.ACEnergyGen = FuelCell(Num).ACPowerGen * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; // energy produced (J) FuelCell(Num).Report.QdotExhaust = 0.0; // reporting: exhaust gas heat recovered (W) @@ -3758,6 +4229,8 @@ namespace FuelCellElectricGenerator { // PURPOSE OF THIS SUBROUTINE: // provide a get method to collect results at the load center level + using DataGenerators::FuelCell; + GeneratorPower = FuelCell(GeneratorIndex).Report.ACPowerGen; GeneratorEnergy = FuelCell(GeneratorIndex).Report.ACEnergyGen; ThermalPower = FuelCell(GeneratorIndex).Report.qHX; From 4b3d81b392de7b068bb2682028103ebfa091093c Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Mon, 11 Nov 2019 14:11:04 -0700 Subject: [PATCH 16/51] partial cleanup usings --- src/EnergyPlus/FuelCellElectricGenerator.cc | 422 ++++++++------------ 1 file changed, 158 insertions(+), 264 deletions(-) diff --git a/src/EnergyPlus/FuelCellElectricGenerator.cc b/src/EnergyPlus/FuelCellElectricGenerator.cc index bd356c0efff..9a5760731d5 100644 --- a/src/EnergyPlus/FuelCellElectricGenerator.cc +++ b/src/EnergyPlus/FuelCellElectricGenerator.cc @@ -191,7 +191,6 @@ namespace FuelCellElectricGenerator { using DataGenerators::NoRecoveryOnAirIntake; using DataGenerators::RegularAir; using DataGenerators::UserDefinedConstituents; - using DataGenerators::GasPhaseThermoChemistryData; using DataGenerators::GasPropertyDataStruct; using DataGenerators::WaterInReformAirNode; using DataGenerators::WaterInReformWaterNode; @@ -576,7 +575,7 @@ namespace FuelCellElectricGenerator { thisName = FuelCell(GeneratorNum).AirSup.ConstitName(i); - thisGasID = UtilityRoutines::FindItem(thisName, GasPhaseThermoChemistryData, &GasPropertyDataStruct::ConstituentName); + thisGasID = UtilityRoutines::FindItem(thisName, DataGenerators::GasPhaseThermoChemistryData, &GasPropertyDataStruct::ConstituentName); FuelCell(GeneratorNum).AirSup.GasLibID(i) = thisGasID; } @@ -1414,7 +1413,6 @@ namespace FuelCellElectricGenerator { using DataGenerators::NoRecoveryOnAirIntake; using DataGenerators::RegularAir; using DataGenerators::UserDefinedConstituents; - using DataGenerators::GasPhaseThermoChemistryData; using DataGenerators::GasPropertyDataStruct; using DataGenerators::WaterInReformAirNode; using DataGenerators::WaterInReformWaterNode; @@ -1431,7 +1429,6 @@ namespace FuelCellElectricGenerator { using DataGenerators::FuelInTempSchedule; using DataGenerators::MinProductGasTemp; using DataGenerators::MaxProductGasTemp; - using DataGenerators::ImBalanceTol; static Real64 PpcuLosses; // losses in inverter [W] Real64 Pel; // DC power generated in Fuel Cell Power Module @@ -1842,7 +1839,7 @@ namespace FuelCellElectricGenerator { NdotCO2 = NdotCO2ProdGas + FuelCell(GeneratorNum).AirSup.ConstitMolalFract(thisGas) * FuelCell(GeneratorNum).FCPM.NdotAir; } else if (SELECT_CASE_var == 2) { - // all the nitrogen comming in + // all the nitrogen coming in NdotN2 = FuelCell(GeneratorNum).FCPM.NdotAir * FuelCell(GeneratorNum).AirSup.ConstitMolalFract(thisGas); } else if (SELECT_CASE_var == 3) { @@ -1850,7 +1847,7 @@ namespace FuelCellElectricGenerator { Ndot02 = NdotExcessAir * FuelCell(GeneratorNum).AirSup.ConstitMolalFract(thisGas); } else if (SELECT_CASE_var == 4) { - // all the H20 comming in plus the new H20 from reactions and the H20 from water used in reforming + // all the H20 coming in plus the new H20 from reactions and the H20 from water used in reforming NdotH20 = NdotH20ProdGas + FuelCell(GeneratorNum).AirSup.ConstitMolalFract(thisGas) * FuelCell(GeneratorNum).FCPM.NdotAir; //+ FuelCell(GeneratorNum)%FCPM%NdotLiqwater @@ -1996,7 +1993,7 @@ namespace FuelCellElectricGenerator { CalcFuelCellGenHeatRecovery(GeneratorNum); // calculation Step 11, If imbalance below threshold, then exit out of do loop. - if ((std::abs(MagofImbalance) < std::abs(ImBalanceTol * FuelCell(GeneratorNum).FCPM.Pel)) && (iter > 2)) { + if ((std::abs(MagofImbalance) < std::abs(DataGenerators::ImBalanceTol * FuelCell(GeneratorNum).FCPM.Pel)) && (iter > 2)) { break; } @@ -2024,48 +2021,6 @@ namespace FuelCellElectricGenerator { // PURPOSE OF THIS SUBROUTINE: // manage controls and calculations related to electrical storage in FuelCell model - using DataGenerators::FuelCell; - using DataGenerators::NumFuelCellGenerators; - using DataGenerators::FCDataStruct; - using DataGenerators::DirectCurveMode; - using DataGenerators::NormalizedCurveMode; - using DataGenerators::ConstantRateSkinLoss; - using DataGenerators::UADTSkinLoss; - using DataGenerators::QuadraticFuelNdotSkin; - using DataGenerators::NumGeneratorFuelSups; - using DataGenerators::FuelSupply; - using DataGenerators::ConstantStoicsAirRat; - using DataGenerators::QuadraticFuncofPel; - using DataGenerators::QuadraticFuncofNdot; - using DataGenerators::RecoverBurnInvertBatt; - using DataGenerators::RecoverAuxiliaryBurner; - using DataGenerators::RecoverInverterBatt; - using DataGenerators::RecoverInverter; - using DataGenerators::RecoverBattery; - using DataGenerators::NoRecoveryOnAirIntake; - using DataGenerators::RegularAir; - using DataGenerators::UserDefinedConstituents; - using DataGenerators::GasPhaseThermoChemistryData; - using DataGenerators::GasPropertyDataStruct; - using DataGenerators::WaterInReformAirNode; - using DataGenerators::WaterInReformWaterNode; - using DataGenerators::WaterInReformMains; - using DataGenerators::WaterInReformSchedule; - using DataGenerators::SurroundingZone; - using DataGenerators::AirInletForFC; - using DataGenerators::FixedEffectiveness; - using DataGenerators::LMTDempiricalUAeff; - using DataGenerators::LMTDfundementalUAeff; - using DataGenerators::Condensing; - using DataGenerators::SimpleEffConstraints; - using DataGenerators::FuelInTempFromNode; - using DataGenerators::FuelInTempSchedule; - using DataGenerators::MinProductGasTemp; - using DataGenerators::MaxProductGasTemp; - using DataGenerators::ImBalanceTol; - using DataGenerators::LeadAcidBatterManwellMcGowan; - using DataGenerators::LeadAcidBatterySaupe; - Real64 tmpPdraw; // power draw from storage, working var Real64 tmpPcharge; // power charge to storage, working var bool drawing; // true if drawing power @@ -2082,15 +2037,15 @@ namespace FuelCellElectricGenerator { // step 1 figure out what is desired of electrical storage system - if (FuelCell(Num).FCPM.Pel < (Pdemand)) { + if (DataGenerators::FuelCell(Num).FCPM.Pel < (Pdemand)) { // draw from storage - tmpPdraw = (Pdemand)-FuelCell(Num).FCPM.Pel; + tmpPdraw = (Pdemand)-DataGenerators::FuelCell(Num).FCPM.Pel; drawing = true; } - if (FuelCell(Num).FCPM.Pel > (Pdemand)) { + if (DataGenerators::FuelCell(Num).FCPM.Pel > (Pdemand)) { // add to storage - tmpPcharge = FuelCell(Num).FCPM.Pel - (Pdemand); + tmpPcharge = DataGenerators::FuelCell(Num).FCPM.Pel - (Pdemand); charging = true; } @@ -2098,45 +2053,45 @@ namespace FuelCellElectricGenerator { if (charging) { - if (FuelCell(Num).ElecStorage.StorageModelMode == SimpleEffConstraints) { + if (DataGenerators::FuelCell(Num).ElecStorage.StorageModelMode == DataGenerators::SimpleEffConstraints) { - if (FuelCell(Num).ElecStorage.LastTimeStepStateOfCharge >= FuelCell(Num).ElecStorage.NominalEnergyCapacity) { + if (DataGenerators::FuelCell(Num).ElecStorage.LastTimeStepStateOfCharge >= DataGenerators::FuelCell(Num).ElecStorage.NominalEnergyCapacity) { // storage full! no more allowed! PgridOverage = tmpPcharge; tmpPcharge = 0.0; Constrained = true; } - if (tmpPcharge > FuelCell(Num).ElecStorage.MaxPowerStore) { - PgridOverage = tmpPcharge - FuelCell(Num).ElecStorage.MaxPowerStore; - tmpPcharge = FuelCell(Num).ElecStorage.MaxPowerStore; + if (tmpPcharge > DataGenerators::FuelCell(Num).ElecStorage.MaxPowerStore) { + PgridOverage = tmpPcharge - DataGenerators::FuelCell(Num).ElecStorage.MaxPowerStore; + tmpPcharge = DataGenerators::FuelCell(Num).ElecStorage.MaxPowerStore; Constrained = true; } // now add energy to storage from charging - if ((FuelCell(Num).ElecStorage.LastTimeStepStateOfCharge + - tmpPcharge * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour * FuelCell(Num).ElecStorage.EnergeticEfficCharge) < - FuelCell(Num).ElecStorage.NominalEnergyCapacity) { + if ((DataGenerators::FuelCell(Num).ElecStorage.LastTimeStepStateOfCharge + + tmpPcharge * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour * DataGenerators::FuelCell(Num).ElecStorage.EnergeticEfficCharge) < + DataGenerators::FuelCell(Num).ElecStorage.NominalEnergyCapacity) { - FuelCell(Num).ElecStorage.ThisTimeStepStateOfCharge = - FuelCell(Num).ElecStorage.LastTimeStepStateOfCharge + - tmpPcharge * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour * FuelCell(Num).ElecStorage.EnergeticEfficCharge; + DataGenerators::FuelCell(Num).ElecStorage.ThisTimeStepStateOfCharge = + DataGenerators::FuelCell(Num).ElecStorage.LastTimeStepStateOfCharge + + tmpPcharge * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour * DataGenerators::FuelCell(Num).ElecStorage.EnergeticEfficCharge; } else { // would over charge this time step - tmpPcharge = (FuelCell(Num).ElecStorage.NominalEnergyCapacity - FuelCell(Num).ElecStorage.LastTimeStepStateOfCharge) / - (DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour * FuelCell(Num).ElecStorage.EnergeticEfficCharge); + tmpPcharge = (DataGenerators::FuelCell(Num).ElecStorage.NominalEnergyCapacity - DataGenerators::FuelCell(Num).ElecStorage.LastTimeStepStateOfCharge) / + (DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour * DataGenerators::FuelCell(Num).ElecStorage.EnergeticEfficCharge); Constrained = true; - FuelCell(Num).ElecStorage.ThisTimeStepStateOfCharge = - FuelCell(Num).ElecStorage.LastTimeStepStateOfCharge + - tmpPcharge * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour * FuelCell(Num).ElecStorage.EnergeticEfficCharge; + DataGenerators::FuelCell(Num).ElecStorage.ThisTimeStepStateOfCharge = + DataGenerators::FuelCell(Num).ElecStorage.LastTimeStepStateOfCharge + + tmpPcharge * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour * DataGenerators::FuelCell(Num).ElecStorage.EnergeticEfficCharge; } // losses go into QairIntake - FuelCell(Num).ElecStorage.QairIntake = tmpPcharge * (1.0 - FuelCell(Num).ElecStorage.EnergeticEfficCharge); + DataGenerators::FuelCell(Num).ElecStorage.QairIntake = tmpPcharge * (1.0 - DataGenerators::FuelCell(Num).ElecStorage.EnergeticEfficCharge); - } else if (FuelCell(Num).ElecStorage.StorageModelMode == LeadAcidBatterManwellMcGowan) { + } else if (DataGenerators::FuelCell(Num).ElecStorage.StorageModelMode == DataGenerators::LeadAcidBatterManwellMcGowan) { ShowWarningError("ManageElectStorInteractions: Not yet implemented: Lead Acid Battery By Manwell and McGowan 1993 "); - } else if (FuelCell(Num).ElecStorage.StorageModelMode == LeadAcidBatterySaupe) { + } else if (DataGenerators::FuelCell(Num).ElecStorage.StorageModelMode == DataGenerators::LeadAcidBatterySaupe) { ShowWarningError("ManageElectStorInteractions: Not yet implemented: Lead Acid Battery By Saupe 1993 "); } else { @@ -2149,41 +2104,41 @@ namespace FuelCellElectricGenerator { } // charging if (drawing) { - if (FuelCell(Num).ElecStorage.StorageModelMode == SimpleEffConstraints) { + if (DataGenerators::FuelCell(Num).ElecStorage.StorageModelMode == DataGenerators::SimpleEffConstraints) { - if (FuelCell(Num).ElecStorage.LastTimeStepStateOfCharge <= 0.0) { + if (DataGenerators::FuelCell(Num).ElecStorage.LastTimeStepStateOfCharge <= 0.0) { // storage empty no more allowed! tmpPdraw = 0.0; Constrained = true; drawing = false; } - if (tmpPdraw > FuelCell(Num).ElecStorage.MaxPowerDraw) { - tmpPdraw = FuelCell(Num).ElecStorage.MaxPowerDraw; + if (tmpPdraw > DataGenerators::FuelCell(Num).ElecStorage.MaxPowerDraw) { + tmpPdraw = DataGenerators::FuelCell(Num).ElecStorage.MaxPowerDraw; Constrained = true; } // now take energy from storage by drawing (amplified by energetic effic) - if ((FuelCell(Num).ElecStorage.LastTimeStepStateOfCharge - - tmpPdraw * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour / FuelCell(Num).ElecStorage.EnergeticEfficDischarge) > 0.0) { + if ((DataGenerators::FuelCell(Num).ElecStorage.LastTimeStepStateOfCharge - + tmpPdraw * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour / DataGenerators::FuelCell(Num).ElecStorage.EnergeticEfficDischarge) > 0.0) { - FuelCell(Num).ElecStorage.ThisTimeStepStateOfCharge = - FuelCell(Num).ElecStorage.LastTimeStepStateOfCharge - - tmpPdraw * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour / FuelCell(Num).ElecStorage.EnergeticEfficDischarge; + DataGenerators::FuelCell(Num).ElecStorage.ThisTimeStepStateOfCharge = + DataGenerators::FuelCell(Num).ElecStorage.LastTimeStepStateOfCharge - + tmpPdraw * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour / DataGenerators::FuelCell(Num).ElecStorage.EnergeticEfficDischarge; } else { // would over drain storage this timestep so reduce tmpPdraw - tmpPdraw = FuelCell(Num).ElecStorage.LastTimeStepStateOfCharge * FuelCell(Num).ElecStorage.EnergeticEfficDischarge / + tmpPdraw = DataGenerators::FuelCell(Num).ElecStorage.LastTimeStepStateOfCharge * DataGenerators::FuelCell(Num).ElecStorage.EnergeticEfficDischarge / (DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour); - FuelCell(Num).ElecStorage.ThisTimeStepStateOfCharge = - FuelCell(Num).ElecStorage.LastTimeStepStateOfCharge - - tmpPdraw * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour / FuelCell(Num).ElecStorage.EnergeticEfficDischarge; + DataGenerators::FuelCell(Num).ElecStorage.ThisTimeStepStateOfCharge = + DataGenerators::FuelCell(Num).ElecStorage.LastTimeStepStateOfCharge - + tmpPdraw * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour / DataGenerators::FuelCell(Num).ElecStorage.EnergeticEfficDischarge; Constrained = true; } // losses go into QairIntake - FuelCell(Num).ElecStorage.QairIntake = tmpPdraw * (1.0 / FuelCell(Num).ElecStorage.EnergeticEfficDischarge - 1.0); - } else if (FuelCell(Num).ElecStorage.StorageModelMode == LeadAcidBatterManwellMcGowan) { + DataGenerators::FuelCell(Num).ElecStorage.QairIntake = tmpPdraw * (1.0 / DataGenerators::FuelCell(Num).ElecStorage.EnergeticEfficDischarge - 1.0); + } else if (DataGenerators::FuelCell(Num).ElecStorage.StorageModelMode == DataGenerators::LeadAcidBatterManwellMcGowan) { ShowWarningError("ManageElectStorInteractions: Not yet implemented: Lead Acid Battery By Manwell and McGowan 1993 "); - } else if (FuelCell(Num).ElecStorage.StorageModelMode == LeadAcidBatterySaupe) { + } else if (DataGenerators::FuelCell(Num).ElecStorage.StorageModelMode == DataGenerators::LeadAcidBatterySaupe) { ShowWarningError("ManageElectStorInteractions: Not yet implemented: Lead Acid Battery By Saupe 1993 "); } else { @@ -2197,21 +2152,21 @@ namespace FuelCellElectricGenerator { if ((!charging) && (!drawing)) { - FuelCell(Num).ElecStorage.ThisTimeStepStateOfCharge = FuelCell(Num).ElecStorage.LastTimeStepStateOfCharge; - FuelCell(Num).ElecStorage.PelNeedFromStorage = 0.0; - FuelCell(Num).ElecStorage.PelFromStorage = 0.0; - FuelCell(Num).ElecStorage.QairIntake = 0.0; + DataGenerators::FuelCell(Num).ElecStorage.ThisTimeStepStateOfCharge = DataGenerators::FuelCell(Num).ElecStorage.LastTimeStepStateOfCharge; + DataGenerators::FuelCell(Num).ElecStorage.PelNeedFromStorage = 0.0; + DataGenerators::FuelCell(Num).ElecStorage.PelFromStorage = 0.0; + DataGenerators::FuelCell(Num).ElecStorage.QairIntake = 0.0; } if (Pstorage >= 0.0) { - FuelCell(Num).ElecStorage.PelIntoStorage = Pstorage; - FuelCell(Num).ElecStorage.PelFromStorage = 0.0; + DataGenerators::FuelCell(Num).ElecStorage.PelIntoStorage = Pstorage; + DataGenerators::FuelCell(Num).ElecStorage.PelFromStorage = 0.0; } if (Pstorage < 0.0) { - FuelCell(Num).ElecStorage.PelIntoStorage = 0.0; - FuelCell(Num).ElecStorage.PelFromStorage = -Pstorage; + DataGenerators::FuelCell(Num).ElecStorage.PelIntoStorage = 0.0; + DataGenerators::FuelCell(Num).ElecStorage.PelFromStorage = -Pstorage; } } @@ -2278,46 +2233,10 @@ namespace FuelCellElectricGenerator { using DataGenerators::FuelCell; using DataGenerators::NumFuelCellGenerators; using DataGenerators::FCDataStruct; - using DataGenerators::DirectCurveMode; - using DataGenerators::NormalizedCurveMode; - using DataGenerators::ConstantRateSkinLoss; - using DataGenerators::UADTSkinLoss; - using DataGenerators::QuadraticFuelNdotSkin; - using DataGenerators::NumGeneratorFuelSups; - using DataGenerators::FuelSupply; - using DataGenerators::ConstantStoicsAirRat; - using DataGenerators::QuadraticFuncofPel; - using DataGenerators::QuadraticFuncofNdot; - using DataGenerators::RecoverBurnInvertBatt; - using DataGenerators::RecoverAuxiliaryBurner; - using DataGenerators::RecoverInverterBatt; - using DataGenerators::RecoverInverter; - using DataGenerators::RecoverBattery; - using DataGenerators::NoRecoveryOnAirIntake; - using DataGenerators::RegularAir; - using DataGenerators::UserDefinedConstituents; - using DataGenerators::GasPhaseThermoChemistryData; - using DataGenerators::GasPropertyDataStruct; - using DataGenerators::WaterInReformAirNode; - using DataGenerators::WaterInReformWaterNode; - using DataGenerators::WaterInReformMains; - using DataGenerators::WaterInReformSchedule; - using DataGenerators::SurroundingZone; - using DataGenerators::AirInletForFC; - using DataGenerators::FixedEffectiveness; - using DataGenerators::LMTDempiricalUAeff; - using DataGenerators::LMTDfundementalUAeff; - using DataGenerators::Condensing; - using DataGenerators::SimpleEffConstraints; - using DataGenerators::FuelInTempSchedule; - using DataGenerators::MinProductGasTemp; using DataGenerators::MaxProductGasTemp; - using DataGenerators::ImBalanceTol; using DataGenerators::LeadAcidBatterManwellMcGowan; using DataGenerators::LeadAcidBatterySaupe; using DataGenerators::NISTShomate; - using DataGenerators::NASAPolynomial; - using DataGenerators::RinKJperMolpK; Real64 tempCp; int thisConstit; // loop index @@ -2351,27 +2270,27 @@ namespace FuelCellElectricGenerator { for (thisConstit = 1; thisConstit <= FuelCell(GeneratorNum).AirSup.NumConstituents; ++thisConstit) { gasID = FuelCell(GeneratorNum).AirSup.GasLibID(thisConstit); if (gasID > 0) { - if (GasPhaseThermoChemistryData(gasID).ThermoMode == NISTShomate) { + if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == NISTShomate) { - A = GasPhaseThermoChemistryData(gasID).ShomateA; - B = GasPhaseThermoChemistryData(gasID).ShomateB; - C = GasPhaseThermoChemistryData(gasID).ShomateC; - D = GasPhaseThermoChemistryData(gasID).ShomateD; - E = GasPhaseThermoChemistryData(gasID).ShomateE; + A = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateA; + B = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateB; + C = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateC; + D = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateD; + E = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateE; tempCp += ((A + B * Tsho + C * pow_2_Tsho + D * pow_3_Tsho + E / pow_2_Tsho) * FuelCell(GeneratorNum).AirSup.ConstitMolalFract(thisConstit)); } - if (GasPhaseThermoChemistryData(gasID).ThermoMode == NASAPolynomial) { + if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == DataGenerators::NASAPolynomial) { - A1 = GasPhaseThermoChemistryData(gasID).NASA_A1; - A2 = GasPhaseThermoChemistryData(gasID).NASA_A2; - A3 = GasPhaseThermoChemistryData(gasID).NASA_A3; - A4 = GasPhaseThermoChemistryData(gasID).NASA_A4; - A5 = GasPhaseThermoChemistryData(gasID).NASA_A5; + A1 = DataGenerators::GasPhaseThermoChemistryData(gasID).NASA_A1; + A2 = DataGenerators::GasPhaseThermoChemistryData(gasID).NASA_A2; + A3 = DataGenerators::GasPhaseThermoChemistryData(gasID).NASA_A3; + A4 = DataGenerators::GasPhaseThermoChemistryData(gasID).NASA_A4; + A5 = DataGenerators::GasPhaseThermoChemistryData(gasID).NASA_A5; - tempCp += (A1 + A2 * Tkel + A3 * pow_2_Tkel + A4 * pow_3_Tkel + A5 * pow_4_Tkel) * RinKJperMolpK * + tempCp += (A1 + A2 * Tkel + A3 * pow_2_Tkel + A4 * pow_3_Tkel + A5 * pow_4_Tkel) * DataGenerators::RinKJperMolpK * FuelCell(GeneratorNum).AirSup.ConstitMolalFract(thisConstit); } } @@ -2423,7 +2342,6 @@ namespace FuelCellElectricGenerator { using DataGenerators::NoRecoveryOnAirIntake; using DataGenerators::RegularAir; using DataGenerators::UserDefinedConstituents; - using DataGenerators::GasPhaseThermoChemistryData; using DataGenerators::GasPropertyDataStruct; using DataGenerators::WaterInReformAirNode; using DataGenerators::WaterInReformWaterNode; @@ -2440,12 +2358,9 @@ namespace FuelCellElectricGenerator { using DataGenerators::FuelInTempSchedule; using DataGenerators::MinProductGasTemp; using DataGenerators::MaxProductGasTemp; - using DataGenerators::ImBalanceTol; using DataGenerators::LeadAcidBatterManwellMcGowan; using DataGenerators::LeadAcidBatterySaupe; using DataGenerators::NISTShomate; - using DataGenerators::NASAPolynomial; - using DataGenerators::RinKJperMolpK; Real64 tempHair; Real64 HairI; @@ -2482,31 +2397,31 @@ namespace FuelCellElectricGenerator { for (thisConstit = 1; thisConstit <= FuelCell(GeneratorNum).AirSup.NumConstituents; ++thisConstit) { gasID = FuelCell(GeneratorNum).AirSup.GasLibID(thisConstit); if (gasID > 0) { - if (GasPhaseThermoChemistryData(gasID).ThermoMode == NISTShomate) { + if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == NISTShomate) { - A = GasPhaseThermoChemistryData(gasID).ShomateA; - B = GasPhaseThermoChemistryData(gasID).ShomateB; - C = GasPhaseThermoChemistryData(gasID).ShomateC; - D = GasPhaseThermoChemistryData(gasID).ShomateD; - E = GasPhaseThermoChemistryData(gasID).ShomateE; - F = GasPhaseThermoChemistryData(gasID).ShomateF; - H = GasPhaseThermoChemistryData(gasID).ShomateH; + A = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateA; + B = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateB; + C = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateC; + D = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateD; + E = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateE; + F = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateF; + H = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateH; HairI = (A * Tsho + B * pow_2_Tsho / 2.0 + C * pow_3_Tsho / 3.0 + D * pow_4_Tsho / 4.0 - E / Tsho + F - H); tempHair += HairI * FuelCell(GeneratorNum).AirSup.ConstitMolalFract(thisConstit); } - if (GasPhaseThermoChemistryData(gasID).ThermoMode == NASAPolynomial) { - A1 = GasPhaseThermoChemistryData(gasID).NASA_A1; - A2 = GasPhaseThermoChemistryData(gasID).NASA_A2; - A3 = GasPhaseThermoChemistryData(gasID).NASA_A3; - A4 = GasPhaseThermoChemistryData(gasID).NASA_A4; - A5 = GasPhaseThermoChemistryData(gasID).NASA_A5; - A6 = GasPhaseThermoChemistryData(gasID).NASA_A6; + if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == DataGenerators::NASAPolynomial) { + A1 = DataGenerators::GasPhaseThermoChemistryData(gasID).NASA_A1; + A2 = DataGenerators::GasPhaseThermoChemistryData(gasID).NASA_A2; + A3 = DataGenerators::GasPhaseThermoChemistryData(gasID).NASA_A3; + A4 = DataGenerators::GasPhaseThermoChemistryData(gasID).NASA_A4; + A5 = DataGenerators::GasPhaseThermoChemistryData(gasID).NASA_A5; + A6 = DataGenerators::GasPhaseThermoChemistryData(gasID).NASA_A6; tempHair += (((A1 + A2 * Tkel / 2.0 + A3 * pow_2_Tkel / 3.0 + A4 * pow_3_Tkel / 4.0 + A5 * pow_4_Tkel / 5.0 + A6 / Tkel) * - RinKJperMolpK * Tkel) - - GasPhaseThermoChemistryData(gasID).StdRefMolarEnthOfForm) * + DataGenerators::RinKJperMolpK * Tkel) - + DataGenerators::GasPhaseThermoChemistryData(gasID).StdRefMolarEnthOfForm) * FuelCell(GeneratorNum).AirSup.ConstitMolalFract(thisConstit); } } @@ -2558,7 +2473,6 @@ namespace FuelCellElectricGenerator { using DataGenerators::NoRecoveryOnAirIntake; using DataGenerators::RegularAir; using DataGenerators::UserDefinedConstituents; - using DataGenerators::GasPhaseThermoChemistryData; using DataGenerators::GasPropertyDataStruct; using DataGenerators::WaterInReformAirNode; using DataGenerators::WaterInReformWaterNode; @@ -2575,12 +2489,9 @@ namespace FuelCellElectricGenerator { using DataGenerators::FuelInTempSchedule; using DataGenerators::MinProductGasTemp; using DataGenerators::MaxProductGasTemp; - using DataGenerators::ImBalanceTol; using DataGenerators::LeadAcidBatterManwellMcGowan; using DataGenerators::LeadAcidBatterySaupe; using DataGenerators::NISTShomate; - using DataGenerators::NASAPolynomial; - using DataGenerators::RinKJperMolpK; Real64 tempCp; int thisConstit; // loop index @@ -2612,26 +2523,26 @@ namespace FuelCellElectricGenerator { for (thisConstit = 1; thisConstit <= FuelSupply(FuelCell(GeneratorNum).FuelSupNum).NumConstituents; ++thisConstit) { gasID = FuelSupply(FuelCell(GeneratorNum).FuelSupNum).GasLibID(thisConstit); if (gasID > 0) { - if (GasPhaseThermoChemistryData(gasID).ThermoMode == NISTShomate) { + if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == NISTShomate) { - A = GasPhaseThermoChemistryData(gasID).ShomateA; - B = GasPhaseThermoChemistryData(gasID).ShomateB; - C = GasPhaseThermoChemistryData(gasID).ShomateC; - D = GasPhaseThermoChemistryData(gasID).ShomateD; - E = GasPhaseThermoChemistryData(gasID).ShomateE; + A = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateA; + B = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateB; + C = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateC; + D = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateD; + E = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateE; tempCp += ((A + B * Tsho + C * pow_2_Tsho + D * pow_3_Tsho + E / pow_2_Tsho) * FuelSupply(FuelCell(GeneratorNum).FuelSupNum).ConstitMolalFract(thisConstit)); } - if (GasPhaseThermoChemistryData(gasID).ThermoMode == NASAPolynomial) { - A1 = GasPhaseThermoChemistryData(gasID).NASA_A1; - A2 = GasPhaseThermoChemistryData(gasID).NASA_A2; - A3 = GasPhaseThermoChemistryData(gasID).NASA_A3; - A4 = GasPhaseThermoChemistryData(gasID).NASA_A4; - A5 = GasPhaseThermoChemistryData(gasID).NASA_A5; + if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == DataGenerators::NASAPolynomial) { + A1 = DataGenerators::GasPhaseThermoChemistryData(gasID).NASA_A1; + A2 = DataGenerators::GasPhaseThermoChemistryData(gasID).NASA_A2; + A3 = DataGenerators::GasPhaseThermoChemistryData(gasID).NASA_A3; + A4 = DataGenerators::GasPhaseThermoChemistryData(gasID).NASA_A4; + A5 = DataGenerators::GasPhaseThermoChemistryData(gasID).NASA_A5; - tempCp += (A1 + A2 * Tkel + A3 * pow_2_Tkel + A4 * pow_3_Tkel + A5 * pow_4_Tkel) * RinKJperMolpK * + tempCp += (A1 + A2 * Tkel + A3 * pow_2_Tkel + A4 * pow_3_Tkel + A5 * pow_4_Tkel) * DataGenerators::RinKJperMolpK * FuelSupply(FuelCell(GeneratorNum).FuelSupNum).ConstitMolalFract(thisConstit); } } @@ -2683,7 +2594,6 @@ namespace FuelCellElectricGenerator { using DataGenerators::NoRecoveryOnAirIntake; using DataGenerators::RegularAir; using DataGenerators::UserDefinedConstituents; - using DataGenerators::GasPhaseThermoChemistryData; using DataGenerators::GasPropertyDataStruct; using DataGenerators::WaterInReformAirNode; using DataGenerators::WaterInReformWaterNode; @@ -2700,12 +2610,9 @@ namespace FuelCellElectricGenerator { using DataGenerators::FuelInTempSchedule; using DataGenerators::MinProductGasTemp; using DataGenerators::MaxProductGasTemp; - using DataGenerators::ImBalanceTol; using DataGenerators::LeadAcidBatterManwellMcGowan; using DataGenerators::LeadAcidBatterySaupe; using DataGenerators::NISTShomate; - using DataGenerators::NASAPolynomial; - using DataGenerators::RinKJperMolpK; Real64 tempHfuel; Real64 HfuelI; @@ -2742,31 +2649,31 @@ namespace FuelCellElectricGenerator { for (thisConstit = 1; thisConstit <= FuelSupply(FuelCell(GeneratorNum).FuelSupNum).NumConstituents; ++thisConstit) { gasID = FuelSupply(FuelCell(GeneratorNum).FuelSupNum).GasLibID(thisConstit); if (gasID > 0) { - if (GasPhaseThermoChemistryData(gasID).ThermoMode == NISTShomate) { - A = GasPhaseThermoChemistryData(gasID).ShomateA; - B = GasPhaseThermoChemistryData(gasID).ShomateB; - C = GasPhaseThermoChemistryData(gasID).ShomateC; - D = GasPhaseThermoChemistryData(gasID).ShomateD; - E = GasPhaseThermoChemistryData(gasID).ShomateE; - F = GasPhaseThermoChemistryData(gasID).ShomateF; - H = GasPhaseThermoChemistryData(gasID).ShomateH; + if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == NISTShomate) { + A = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateA; + B = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateB; + C = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateC; + D = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateD; + E = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateE; + F = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateF; + H = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateH; HfuelI = (A * Tsho + B * pow_2_Tsho / 2.0 + C * pow_3_Tsho / 3.0 + D * pow_4_Tsho / 4.0 - E / Tsho + F - H); tempHfuel += HfuelI * FuelSupply(FuelCell(GeneratorNum).FuelSupNum).ConstitMolalFract(thisConstit); } - if (GasPhaseThermoChemistryData(gasID).ThermoMode == NASAPolynomial) { + if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == DataGenerators::NASAPolynomial) { - A1 = GasPhaseThermoChemistryData(gasID).NASA_A1; - A2 = GasPhaseThermoChemistryData(gasID).NASA_A2; - A3 = GasPhaseThermoChemistryData(gasID).NASA_A3; - A4 = GasPhaseThermoChemistryData(gasID).NASA_A4; - A5 = GasPhaseThermoChemistryData(gasID).NASA_A5; - A6 = GasPhaseThermoChemistryData(gasID).NASA_A6; + A1 = DataGenerators::GasPhaseThermoChemistryData(gasID).NASA_A1; + A2 = DataGenerators::GasPhaseThermoChemistryData(gasID).NASA_A2; + A3 = DataGenerators::GasPhaseThermoChemistryData(gasID).NASA_A3; + A4 = DataGenerators::GasPhaseThermoChemistryData(gasID).NASA_A4; + A5 = DataGenerators::GasPhaseThermoChemistryData(gasID).NASA_A5; + A6 = DataGenerators::GasPhaseThermoChemistryData(gasID).NASA_A6; tempHfuel += (((A1 + A2 * Tkel / 2.0 + A3 * pow_2_Tkel / 3.0 + A4 * pow_3_Tkel / 4.0 + A5 * pow_4_Tkel / 5.0 + A6 / Tkel) * - RinKJperMolpK * Tkel) - - GasPhaseThermoChemistryData(gasID).StdRefMolarEnthOfForm) * + DataGenerators::RinKJperMolpK * Tkel) - + DataGenerators::GasPhaseThermoChemistryData(gasID).StdRefMolarEnthOfForm) * FuelSupply(FuelCell(GeneratorNum).FuelSupNum).ConstitMolalFract(thisConstit); } } @@ -2818,7 +2725,6 @@ namespace FuelCellElectricGenerator { using DataGenerators::NoRecoveryOnAirIntake; using DataGenerators::RegularAir; using DataGenerators::UserDefinedConstituents; - using DataGenerators::GasPhaseThermoChemistryData; using DataGenerators::GasPropertyDataStruct; using DataGenerators::WaterInReformAirNode; using DataGenerators::WaterInReformWaterNode; @@ -2835,12 +2741,9 @@ namespace FuelCellElectricGenerator { using DataGenerators::FuelInTempSchedule; using DataGenerators::MinProductGasTemp; using DataGenerators::MaxProductGasTemp; - using DataGenerators::ImBalanceTol; using DataGenerators::LeadAcidBatterManwellMcGowan; using DataGenerators::LeadAcidBatterySaupe; using DataGenerators::NISTShomate; - using DataGenerators::NASAPolynomial; - using DataGenerators::RinKJperMolpK; Real64 tempHprodGases; int thisConstit; // loop index @@ -2876,29 +2779,29 @@ namespace FuelCellElectricGenerator { for (thisConstit = 1; thisConstit <= 5; ++thisConstit) { gasID = FuelCell(GeneratorNum).FCPM.GasLibID(thisConstit); if (gasID > 0) { - if (GasPhaseThermoChemistryData(gasID).ThermoMode == NISTShomate) { - A = GasPhaseThermoChemistryData(gasID).ShomateA; - B = GasPhaseThermoChemistryData(gasID).ShomateB; - C = GasPhaseThermoChemistryData(gasID).ShomateC; - D = GasPhaseThermoChemistryData(gasID).ShomateD; - E = GasPhaseThermoChemistryData(gasID).ShomateE; - F = GasPhaseThermoChemistryData(gasID).ShomateF; - H = GasPhaseThermoChemistryData(gasID).ShomateH; + if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == NISTShomate) { + A = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateA; + B = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateB; + C = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateC; + D = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateD; + E = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateE; + F = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateF; + H = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateH; tempHprodGases += ((A * Tsho + B * pow_2_Tsho / 2.0 + C * pow_3_Tsho / 3.0 + D * pow_4_Tsho / 4.0 - E / Tsho + F - H) * FuelCell(GeneratorNum).FCPM.ConstitMolalFract(thisConstit)); } - if (GasPhaseThermoChemistryData(gasID).ThermoMode == NASAPolynomial) { - A1 = GasPhaseThermoChemistryData(gasID).NASA_A1; - A2 = GasPhaseThermoChemistryData(gasID).NASA_A2; - A3 = GasPhaseThermoChemistryData(gasID).NASA_A3; - A4 = GasPhaseThermoChemistryData(gasID).NASA_A4; - A5 = GasPhaseThermoChemistryData(gasID).NASA_A5; - A6 = GasPhaseThermoChemistryData(gasID).NASA_A6; + if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == DataGenerators::NASAPolynomial) { + A1 = DataGenerators::GasPhaseThermoChemistryData(gasID).NASA_A1; + A2 = DataGenerators::GasPhaseThermoChemistryData(gasID).NASA_A2; + A3 = DataGenerators::GasPhaseThermoChemistryData(gasID).NASA_A3; + A4 = DataGenerators::GasPhaseThermoChemistryData(gasID).NASA_A4; + A5 = DataGenerators::GasPhaseThermoChemistryData(gasID).NASA_A5; + A6 = DataGenerators::GasPhaseThermoChemistryData(gasID).NASA_A6; tempHprodGases += (((A1 + A2 * Tkel / 2.0 + A3 * pow_2_Tkel / 3.0 + A4 * pow_3_Tkel / 4.0 + A5 * pow_4_Tkel / 5.0 + A6 / Tkel) * - RinKJperMolpK * Tkel) - - GasPhaseThermoChemistryData(gasID).StdRefMolarEnthOfForm) * + DataGenerators::RinKJperMolpK * Tkel) - + DataGenerators::GasPhaseThermoChemistryData(gasID).StdRefMolarEnthOfForm) * FuelCell(GeneratorNum).FCPM.ConstitMolalFract(thisConstit); } } // gasid > 0 @@ -2940,7 +2843,6 @@ namespace FuelCellElectricGenerator { using DataGenerators::NoRecoveryOnAirIntake; using DataGenerators::RegularAir; using DataGenerators::UserDefinedConstituents; - using DataGenerators::GasPhaseThermoChemistryData; using DataGenerators::GasPropertyDataStruct; using DataGenerators::WaterInReformAirNode; using DataGenerators::WaterInReformWaterNode; @@ -2957,12 +2859,9 @@ namespace FuelCellElectricGenerator { using DataGenerators::FuelInTempSchedule; using DataGenerators::MinProductGasTemp; using DataGenerators::MaxProductGasTemp; - using DataGenerators::ImBalanceTol; using DataGenerators::LeadAcidBatterManwellMcGowan; using DataGenerators::LeadAcidBatterySaupe; using DataGenerators::NISTShomate; - using DataGenerators::NASAPolynomial; - using DataGenerators::RinKJperMolpK; Real64 tempCp; int thisConstit; // loop index @@ -2994,26 +2893,26 @@ namespace FuelCellElectricGenerator { for (thisConstit = 1; thisConstit <= isize(FuelCell(GeneratorNum).FCPM.GasLibID); ++thisConstit) { gasID = FuelCell(GeneratorNum).FCPM.GasLibID(thisConstit); if (gasID > 0) { - if (GasPhaseThermoChemistryData(gasID).ThermoMode == NISTShomate) { + if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == NISTShomate) { - A = GasPhaseThermoChemistryData(gasID).ShomateA; - B = GasPhaseThermoChemistryData(gasID).ShomateB; - C = GasPhaseThermoChemistryData(gasID).ShomateC; - D = GasPhaseThermoChemistryData(gasID).ShomateD; - E = GasPhaseThermoChemistryData(gasID).ShomateE; + A = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateA; + B = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateB; + C = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateC; + D = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateD; + E = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateE; tempCp += ((A + B * Tsho + C * pow_2_Tsho + D * pow_3_Tsho + E / pow_2_Tsho) * FuelCell(GeneratorNum).FCPM.ConstitMolalFract(thisConstit)); } - if (GasPhaseThermoChemistryData(gasID).ThermoMode == NASAPolynomial) { - A1 = GasPhaseThermoChemistryData(gasID).NASA_A1; - A2 = GasPhaseThermoChemistryData(gasID).NASA_A2; - A3 = GasPhaseThermoChemistryData(gasID).NASA_A3; - A4 = GasPhaseThermoChemistryData(gasID).NASA_A4; - A5 = GasPhaseThermoChemistryData(gasID).NASA_A5; + if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == DataGenerators::NASAPolynomial) { + A1 = DataGenerators::GasPhaseThermoChemistryData(gasID).NASA_A1; + A2 = DataGenerators::GasPhaseThermoChemistryData(gasID).NASA_A2; + A3 = DataGenerators::GasPhaseThermoChemistryData(gasID).NASA_A3; + A4 = DataGenerators::GasPhaseThermoChemistryData(gasID).NASA_A4; + A5 = DataGenerators::GasPhaseThermoChemistryData(gasID).NASA_A5; - tempCp += (A1 + A2 * Tkel + A3 * pow_2_Tkel + A4 * pow_3_Tkel + A5 * pow_4_Tkel) * RinKJperMolpK * + tempCp += (A1 + A2 * Tkel + A3 * pow_2_Tkel + A4 * pow_3_Tkel + A5 * pow_4_Tkel) * DataGenerators::RinKJperMolpK * FuelCell(GeneratorNum).FCPM.ConstitMolalFract(thisConstit); } } @@ -3055,7 +2954,6 @@ namespace FuelCellElectricGenerator { using DataGenerators::NoRecoveryOnAirIntake; using DataGenerators::RegularAir; using DataGenerators::UserDefinedConstituents; - using DataGenerators::GasPhaseThermoChemistryData; using DataGenerators::GasPropertyDataStruct; using DataGenerators::WaterInReformAirNode; using DataGenerators::WaterInReformWaterNode; @@ -3072,12 +2970,9 @@ namespace FuelCellElectricGenerator { using DataGenerators::FuelInTempSchedule; using DataGenerators::MinProductGasTemp; using DataGenerators::MaxProductGasTemp; - using DataGenerators::ImBalanceTol; using DataGenerators::LeadAcidBatterManwellMcGowan; using DataGenerators::LeadAcidBatterySaupe; using DataGenerators::NISTShomate; - using DataGenerators::NASAPolynomial; - using DataGenerators::RinKJperMolpK; Real64 tempCp; int thisConstit; // loop index @@ -3109,26 +3004,26 @@ namespace FuelCellElectricGenerator { for (thisConstit = 1; thisConstit <= isize(FuelCell(GeneratorNum).AuxilHeat.GasLibID); ++thisConstit) { gasID = FuelCell(GeneratorNum).AuxilHeat.GasLibID(thisConstit); if (gasID > 0) { - if (GasPhaseThermoChemistryData(gasID).ThermoMode == NISTShomate) { + if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == NISTShomate) { - A = GasPhaseThermoChemistryData(gasID).ShomateA; - B = GasPhaseThermoChemistryData(gasID).ShomateB; - C = GasPhaseThermoChemistryData(gasID).ShomateC; - D = GasPhaseThermoChemistryData(gasID).ShomateD; - E = GasPhaseThermoChemistryData(gasID).ShomateE; + A = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateA; + B = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateB; + C = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateC; + D = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateD; + E = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateE; tempCp += ((A + B * Tsho + C * pow_2_Tsho + D * pow_3_Tsho + E / pow_2_Tsho) * FuelCell(GeneratorNum).AuxilHeat.ConstitMolalFract(thisConstit)); } - if (GasPhaseThermoChemistryData(gasID).ThermoMode == NASAPolynomial) { - A1 = GasPhaseThermoChemistryData(gasID).NASA_A1; - A2 = GasPhaseThermoChemistryData(gasID).NASA_A2; - A3 = GasPhaseThermoChemistryData(gasID).NASA_A3; - A4 = GasPhaseThermoChemistryData(gasID).NASA_A4; - A5 = GasPhaseThermoChemistryData(gasID).NASA_A5; + if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == DataGenerators::NASAPolynomial) { + A1 = DataGenerators::GasPhaseThermoChemistryData(gasID).NASA_A1; + A2 = DataGenerators::GasPhaseThermoChemistryData(gasID).NASA_A2; + A3 = DataGenerators::GasPhaseThermoChemistryData(gasID).NASA_A3; + A4 = DataGenerators::GasPhaseThermoChemistryData(gasID).NASA_A4; + A5 = DataGenerators::GasPhaseThermoChemistryData(gasID).NASA_A5; - tempCp += (A1 + A2 * Tkel + A3 * pow_2_Tkel + A4 * pow_3_Tkel + A5 * pow_4_Tkel) * RinKJperMolpK * + tempCp += (A1 + A2 * Tkel + A3 * pow_2_Tkel + A4 * pow_3_Tkel + A5 * pow_4_Tkel) * DataGenerators::RinKJperMolpK * FuelCell(GeneratorNum).AuxilHeat.ConstitMolalFract(thisConstit); } } @@ -3419,7 +3314,6 @@ namespace FuelCellElectricGenerator { using DataGenerators::FuelCell; using DataGenerators::FixedEffectiveness; - using DataGenerators::GasPhaseThermoChemistryData; using DataGenerators::LMTDempiricalUAeff; using DataGenerators::LMTDfundementalUAeff; using DataGenerators::Condensing; @@ -3470,7 +3364,7 @@ namespace FuelCellElectricGenerator { inNodeNum = FuelCell(Num).ExhaustHX.WaterInNode; MdotWater = FuelCell(Num).ExhaustHX.WaterMassFlowRate; - MWwater = GasPhaseThermoChemistryData(4).MolecularWeight; + MWwater = DataGenerators::GasPhaseThermoChemistryData(4).MolecularWeight; NdotWater = MdotWater / MWwater; TwaterIn = FuelCell(Num).ExhaustHX.WaterInletTemp; @@ -3498,7 +3392,7 @@ namespace FuelCellElectricGenerator { } else if (SELECT_CASE_var == LMTDempiricalUAeff) { // method 2 inNodeNum = FuelCell(Num).ExhaustHX.WaterInNode; MdotWater = FuelCell(Num).ExhaustHX.WaterMassFlowRate; - MWwater = GasPhaseThermoChemistryData(4).MolecularWeight; + MWwater = DataGenerators::GasPhaseThermoChemistryData(4).MolecularWeight; NdotWater = MdotWater / MWwater; NdotGas = FuelCell(Num).AuxilHeat.NdotAuxMix; @@ -3540,7 +3434,7 @@ namespace FuelCellElectricGenerator { NdotGas = FuelCell(Num).AuxilHeat.NdotAuxMix; inNodeNum = FuelCell(Num).ExhaustHX.WaterInNode; MdotWater = FuelCell(Num).ExhaustHX.WaterMassFlowRate; - MWwater = GasPhaseThermoChemistryData(4).MolecularWeight; + MWwater = DataGenerators::GasPhaseThermoChemistryData(4).MolecularWeight; NdotWater = MdotWater / MWwater; hgas = @@ -3587,7 +3481,7 @@ namespace FuelCellElectricGenerator { MdotWater = FuelCell(Num).ExhaustHX.WaterMassFlowRate; if (MdotWater != 0.0) { - MWwater = GasPhaseThermoChemistryData(4).MolecularWeight; + MWwater = DataGenerators::GasPhaseThermoChemistryData(4).MolecularWeight; NdotWater = MdotWater / MWwater; NdotGas = FuelCell(Num).AuxilHeat.NdotAuxMix; From 32e13608c18b3c488da15464d84ad45a34a889c8 Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Mon, 11 Nov 2019 14:19:10 -0700 Subject: [PATCH 17/51] partial cleanup usings --- src/EnergyPlus/FuelCellElectricGenerator.cc | 322 ++++++-------------- 1 file changed, 93 insertions(+), 229 deletions(-) diff --git a/src/EnergyPlus/FuelCellElectricGenerator.cc b/src/EnergyPlus/FuelCellElectricGenerator.cc index 9a5760731d5..0ab475f6f44 100644 --- a/src/EnergyPlus/FuelCellElectricGenerator.cc +++ b/src/EnergyPlus/FuelCellElectricGenerator.cc @@ -2704,47 +2704,6 @@ namespace FuelCellElectricGenerator { // REFERENCES: // NIST Webbook on gas phase thermochemistry - using DataGenerators::FuelCell; - using DataGenerators::NumFuelCellGenerators; - using DataGenerators::FCDataStruct; - using DataGenerators::DirectCurveMode; - using DataGenerators::NormalizedCurveMode; - using DataGenerators::ConstantRateSkinLoss; - using DataGenerators::UADTSkinLoss; - using DataGenerators::QuadraticFuelNdotSkin; - using DataGenerators::NumGeneratorFuelSups; - using DataGenerators::FuelSupply; - using DataGenerators::ConstantStoicsAirRat; - using DataGenerators::QuadraticFuncofPel; - using DataGenerators::QuadraticFuncofNdot; - using DataGenerators::RecoverBurnInvertBatt; - using DataGenerators::RecoverAuxiliaryBurner; - using DataGenerators::RecoverInverterBatt; - using DataGenerators::RecoverInverter; - using DataGenerators::RecoverBattery; - using DataGenerators::NoRecoveryOnAirIntake; - using DataGenerators::RegularAir; - using DataGenerators::UserDefinedConstituents; - using DataGenerators::GasPropertyDataStruct; - using DataGenerators::WaterInReformAirNode; - using DataGenerators::WaterInReformWaterNode; - using DataGenerators::WaterInReformMains; - using DataGenerators::WaterInReformSchedule; - using DataGenerators::SurroundingZone; - using DataGenerators::AirInletForFC; - using DataGenerators::FixedEffectiveness; - using DataGenerators::LMTDempiricalUAeff; - using DataGenerators::LMTDfundementalUAeff; - using DataGenerators::Condensing; - using DataGenerators::SimpleEffConstraints; - using DataGenerators::FuelInTempFromNode; - using DataGenerators::FuelInTempSchedule; - using DataGenerators::MinProductGasTemp; - using DataGenerators::MaxProductGasTemp; - using DataGenerators::LeadAcidBatterManwellMcGowan; - using DataGenerators::LeadAcidBatterySaupe; - using DataGenerators::NISTShomate; - Real64 tempHprodGases; int thisConstit; // loop index int gasID; // look up into Gas structure @@ -2777,9 +2736,9 @@ namespace FuelCellElectricGenerator { Real64 const pow_4_Tkel(pow_4(Tkel)); for (thisConstit = 1; thisConstit <= 5; ++thisConstit) { - gasID = FuelCell(GeneratorNum).FCPM.GasLibID(thisConstit); + gasID = DataGenerators::FuelCell(GeneratorNum).FCPM.GasLibID(thisConstit); if (gasID > 0) { - if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == NISTShomate) { + if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == DataGenerators::NISTShomate) { A = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateA; B = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateB; C = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateC; @@ -2789,7 +2748,7 @@ namespace FuelCellElectricGenerator { H = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateH; tempHprodGases += ((A * Tsho + B * pow_2_Tsho / 2.0 + C * pow_3_Tsho / 3.0 + D * pow_4_Tsho / 4.0 - E / Tsho + F - H) * - FuelCell(GeneratorNum).FCPM.ConstitMolalFract(thisConstit)); + DataGenerators::FuelCell(GeneratorNum).FCPM.ConstitMolalFract(thisConstit)); } if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == DataGenerators::NASAPolynomial) { A1 = DataGenerators::GasPhaseThermoChemistryData(gasID).NASA_A1; @@ -2802,7 +2761,7 @@ namespace FuelCellElectricGenerator { tempHprodGases += (((A1 + A2 * Tkel / 2.0 + A3 * pow_2_Tkel / 3.0 + A4 * pow_3_Tkel / 4.0 + A5 * pow_4_Tkel / 5.0 + A6 / Tkel) * DataGenerators::RinKJperMolpK * Tkel) - DataGenerators::GasPhaseThermoChemistryData(gasID).StdRefMolarEnthOfForm) * - FuelCell(GeneratorNum).FCPM.ConstitMolalFract(thisConstit); + DataGenerators::FuelCell(GeneratorNum).FCPM.ConstitMolalFract(thisConstit); } } // gasid > 0 } @@ -2822,47 +2781,6 @@ namespace FuelCellElectricGenerator { // MODIFIED na // RE-ENGINEERED na - using DataGenerators::FuelCell; - using DataGenerators::NumFuelCellGenerators; - using DataGenerators::FCDataStruct; - using DataGenerators::DirectCurveMode; - using DataGenerators::NormalizedCurveMode; - using DataGenerators::ConstantRateSkinLoss; - using DataGenerators::UADTSkinLoss; - using DataGenerators::QuadraticFuelNdotSkin; - using DataGenerators::NumGeneratorFuelSups; - using DataGenerators::FuelSupply; - using DataGenerators::ConstantStoicsAirRat; - using DataGenerators::QuadraticFuncofPel; - using DataGenerators::QuadraticFuncofNdot; - using DataGenerators::RecoverBurnInvertBatt; - using DataGenerators::RecoverAuxiliaryBurner; - using DataGenerators::RecoverInverterBatt; - using DataGenerators::RecoverInverter; - using DataGenerators::RecoverBattery; - using DataGenerators::NoRecoveryOnAirIntake; - using DataGenerators::RegularAir; - using DataGenerators::UserDefinedConstituents; - using DataGenerators::GasPropertyDataStruct; - using DataGenerators::WaterInReformAirNode; - using DataGenerators::WaterInReformWaterNode; - using DataGenerators::WaterInReformMains; - using DataGenerators::WaterInReformSchedule; - using DataGenerators::SurroundingZone; - using DataGenerators::AirInletForFC; - using DataGenerators::FixedEffectiveness; - using DataGenerators::LMTDempiricalUAeff; - using DataGenerators::LMTDfundementalUAeff; - using DataGenerators::Condensing; - using DataGenerators::SimpleEffConstraints; - using DataGenerators::FuelInTempFromNode; - using DataGenerators::FuelInTempSchedule; - using DataGenerators::MinProductGasTemp; - using DataGenerators::MaxProductGasTemp; - using DataGenerators::LeadAcidBatterManwellMcGowan; - using DataGenerators::LeadAcidBatterySaupe; - using DataGenerators::NISTShomate; - Real64 tempCp; int thisConstit; // loop index int gasID; // look up into Gas structure @@ -2890,10 +2808,10 @@ namespace FuelCellElectricGenerator { Real64 const pow_3_Tkel(pow_3(Tkel)); Real64 const pow_4_Tkel(pow_4(Tkel)); - for (thisConstit = 1; thisConstit <= isize(FuelCell(GeneratorNum).FCPM.GasLibID); ++thisConstit) { - gasID = FuelCell(GeneratorNum).FCPM.GasLibID(thisConstit); + for (thisConstit = 1; thisConstit <= isize(DataGenerators::FuelCell(GeneratorNum).FCPM.GasLibID); ++thisConstit) { + gasID = DataGenerators::FuelCell(GeneratorNum).FCPM.GasLibID(thisConstit); if (gasID > 0) { - if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == NISTShomate) { + if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == DataGenerators::NISTShomate) { A = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateA; B = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateB; @@ -2902,7 +2820,7 @@ namespace FuelCellElectricGenerator { E = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateE; tempCp += ((A + B * Tsho + C * pow_2_Tsho + D * pow_3_Tsho + E / pow_2_Tsho) * - FuelCell(GeneratorNum).FCPM.ConstitMolalFract(thisConstit)); + DataGenerators::FuelCell(GeneratorNum).FCPM.ConstitMolalFract(thisConstit)); } if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == DataGenerators::NASAPolynomial) { @@ -2913,7 +2831,7 @@ namespace FuelCellElectricGenerator { A5 = DataGenerators::GasPhaseThermoChemistryData(gasID).NASA_A5; tempCp += (A1 + A2 * Tkel + A3 * pow_2_Tkel + A4 * pow_3_Tkel + A5 * pow_4_Tkel) * DataGenerators::RinKJperMolpK * - FuelCell(GeneratorNum).FCPM.ConstitMolalFract(thisConstit); + DataGenerators::FuelCell(GeneratorNum).FCPM.ConstitMolalFract(thisConstit); } } } @@ -2933,47 +2851,6 @@ namespace FuelCellElectricGenerator { // MODIFIED na // RE-ENGINEERED na - using DataGenerators::FuelCell; - using DataGenerators::NumFuelCellGenerators; - using DataGenerators::FCDataStruct; - using DataGenerators::DirectCurveMode; - using DataGenerators::NormalizedCurveMode; - using DataGenerators::ConstantRateSkinLoss; - using DataGenerators::UADTSkinLoss; - using DataGenerators::QuadraticFuelNdotSkin; - using DataGenerators::NumGeneratorFuelSups; - using DataGenerators::FuelSupply; - using DataGenerators::ConstantStoicsAirRat; - using DataGenerators::QuadraticFuncofPel; - using DataGenerators::QuadraticFuncofNdot; - using DataGenerators::RecoverBurnInvertBatt; - using DataGenerators::RecoverAuxiliaryBurner; - using DataGenerators::RecoverInverterBatt; - using DataGenerators::RecoverInverter; - using DataGenerators::RecoverBattery; - using DataGenerators::NoRecoveryOnAirIntake; - using DataGenerators::RegularAir; - using DataGenerators::UserDefinedConstituents; - using DataGenerators::GasPropertyDataStruct; - using DataGenerators::WaterInReformAirNode; - using DataGenerators::WaterInReformWaterNode; - using DataGenerators::WaterInReformMains; - using DataGenerators::WaterInReformSchedule; - using DataGenerators::SurroundingZone; - using DataGenerators::AirInletForFC; - using DataGenerators::FixedEffectiveness; - using DataGenerators::LMTDempiricalUAeff; - using DataGenerators::LMTDfundementalUAeff; - using DataGenerators::Condensing; - using DataGenerators::SimpleEffConstraints; - using DataGenerators::FuelInTempFromNode; - using DataGenerators::FuelInTempSchedule; - using DataGenerators::MinProductGasTemp; - using DataGenerators::MaxProductGasTemp; - using DataGenerators::LeadAcidBatterManwellMcGowan; - using DataGenerators::LeadAcidBatterySaupe; - using DataGenerators::NISTShomate; - Real64 tempCp; int thisConstit; // loop index int gasID; // look up into Gas structure @@ -3001,10 +2878,10 @@ namespace FuelCellElectricGenerator { Real64 const pow_3_Tkel(pow_3(Tkel)); Real64 const pow_4_Tkel(pow_4(Tkel)); - for (thisConstit = 1; thisConstit <= isize(FuelCell(GeneratorNum).AuxilHeat.GasLibID); ++thisConstit) { - gasID = FuelCell(GeneratorNum).AuxilHeat.GasLibID(thisConstit); + for (thisConstit = 1; thisConstit <= isize(DataGenerators::FuelCell(GeneratorNum).AuxilHeat.GasLibID); ++thisConstit) { + gasID = DataGenerators::FuelCell(GeneratorNum).AuxilHeat.GasLibID(thisConstit); if (gasID > 0) { - if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == NISTShomate) { + if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == DataGenerators::NISTShomate) { A = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateA; B = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateB; @@ -3013,7 +2890,7 @@ namespace FuelCellElectricGenerator { E = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateE; tempCp += ((A + B * Tsho + C * pow_2_Tsho + D * pow_3_Tsho + E / pow_2_Tsho) * - FuelCell(GeneratorNum).AuxilHeat.ConstitMolalFract(thisConstit)); + DataGenerators::FuelCell(GeneratorNum).AuxilHeat.ConstitMolalFract(thisConstit)); } if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == DataGenerators::NASAPolynomial) { @@ -3024,7 +2901,7 @@ namespace FuelCellElectricGenerator { A5 = DataGenerators::GasPhaseThermoChemistryData(gasID).NASA_A5; tempCp += (A1 + A2 * Tkel + A3 * pow_2_Tkel + A4 * pow_3_Tkel + A5 * pow_4_Tkel) * DataGenerators::RinKJperMolpK * - FuelCell(GeneratorNum).AuxilHeat.ConstitMolalFract(thisConstit); + DataGenerators::FuelCell(GeneratorNum).AuxilHeat.ConstitMolalFract(thisConstit); } } } @@ -3127,27 +3004,24 @@ namespace FuelCellElectricGenerator { // PURPOSE OF THIS SUBROUTINE: // Calculate the AC ancillaries to determine Pel - using DataGenerators::FuelCell; - using DataGenerators::FuelSupply; - // Using lagged values inside a sequential substitution loop PacAncill = 0.0; // sect. 5.9 - FuelCell(GeneratorNum).FCPM.PelancillariesAC = - FuelCell(GeneratorNum).FCPM.ANC0 + FuelCell(GeneratorNum).FCPM.ANC1 * FuelCell(GeneratorNum).FCPM.NdotFuel; + DataGenerators::FuelCell(GeneratorNum).FCPM.PelancillariesAC = + DataGenerators::FuelCell(GeneratorNum).FCPM.ANC0 + DataGenerators::FuelCell(GeneratorNum).FCPM.ANC1 * DataGenerators::FuelCell(GeneratorNum).FCPM.NdotFuel; // sect 6.0 - FuelCell(GeneratorNum).AirSup.PairCompEl = CurveManager::CurveValue(FuelCell(GeneratorNum).AirSup.BlowerPowerCurveID, FuelCell(GeneratorNum).FCPM.NdotAir); + DataGenerators::FuelCell(GeneratorNum).AirSup.PairCompEl = CurveManager::CurveValue(DataGenerators::FuelCell(GeneratorNum).AirSup.BlowerPowerCurveID, DataGenerators::FuelCell(GeneratorNum).FCPM.NdotAir); // sect 7.0 - FuelSupply(FuelCell(GeneratorNum).FuelSupNum).PfuelCompEl = - CurveManager::CurveValue(FuelSupply(FuelCell(GeneratorNum).FuelSupNum).CompPowerCurveID, FuelCell(GeneratorNum).FCPM.NdotFuel); + DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).PfuelCompEl = + CurveManager::CurveValue(DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).CompPowerCurveID, DataGenerators::FuelCell(GeneratorNum).FCPM.NdotFuel); // sect. 8.0 - FuelCell(GeneratorNum).WaterSup.PwaterCompEl = - CurveManager::CurveValue(FuelCell(GeneratorNum).WaterSup.PmpPowerCurveID, FuelCell(GeneratorNum).FCPM.NdotLiqwater); + DataGenerators::FuelCell(GeneratorNum).WaterSup.PwaterCompEl = + CurveManager::CurveValue(DataGenerators::FuelCell(GeneratorNum).WaterSup.PmpPowerCurveID, DataGenerators::FuelCell(GeneratorNum).FCPM.NdotLiqwater); - PacAncill = FuelCell(GeneratorNum).FCPM.PelancillariesAC + FuelCell(GeneratorNum).AirSup.PairCompEl + - FuelSupply(FuelCell(GeneratorNum).FuelSupNum).PfuelCompEl + FuelCell(GeneratorNum).WaterSup.PwaterCompEl; + PacAncill = DataGenerators::FuelCell(GeneratorNum).FCPM.PelancillariesAC + DataGenerators::FuelCell(GeneratorNum).AirSup.PairCompEl + + DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).PfuelCompEl + DataGenerators::FuelCell(GeneratorNum).WaterSup.PwaterCompEl; } void FigurePowerConditioningLosses(int const GeneratorNum, Real64 const Pdemand, Real64 &PpcuLosses) @@ -3203,8 +3077,6 @@ namespace FuelCellElectricGenerator { // MODIFIED na // RE-ENGINEERED na - using DataGenerators::FuelCell; - Real64 CurrentFractionalDay; // working var, time in decimal days Real64 EndingFractionalDay; // working var, time is decimal days Real64 MaxPel; // working variable for max allowed by transient constraint @@ -3214,46 +3086,46 @@ namespace FuelCellElectricGenerator { PelInput = Pel; // Check if in start up and if it still should be - if (FuelCell(GeneratorNum).FCPM.DuringStartUp) { + if (DataGenerators::FuelCell(GeneratorNum).FCPM.DuringStartUp) { // calculate time for end of start up period CurrentFractionalDay = double(DataGlobals::DayOfSim) + (int(DataGlobals::CurrentTime) + (DataHVACGlobals::SysTimeElapsed + (DataGlobals::CurrentTime - int(DataGlobals::CurrentTime)))) / DataGlobals::HoursInDay; - EndingFractionalDay = FuelCell(GeneratorNum).FCPM.FractionalDayofLastStartUp + FuelCell(GeneratorNum).FCPM.StartUpTime / DataGlobals::HoursInDay; + EndingFractionalDay = DataGenerators::FuelCell(GeneratorNum).FCPM.FractionalDayofLastStartUp + DataGenerators::FuelCell(GeneratorNum).FCPM.StartUpTime / DataGlobals::HoursInDay; if (CurrentFractionalDay > EndingFractionalDay) { // start up period is now over - FuelCell(GeneratorNum).FCPM.DuringStartUp = false; + DataGenerators::FuelCell(GeneratorNum).FCPM.DuringStartUp = false; } } // Check if in shut down up and if it still should be - if (FuelCell(GeneratorNum).FCPM.DuringShutDown) { + if (DataGenerators::FuelCell(GeneratorNum).FCPM.DuringShutDown) { // calculate time for end of shut down period CurrentFractionalDay = double(DataGlobals::DayOfSim) + (int(DataGlobals::CurrentTime) + (DataHVACGlobals::SysTimeElapsed + (DataGlobals::CurrentTime - int(DataGlobals::CurrentTime)))) / DataGlobals::HoursInDay; - EndingFractionalDay = FuelCell(GeneratorNum).FCPM.FractionalDayofLastShutDown + FuelCell(GeneratorNum).FCPM.ShutDownTime / DataGlobals::HoursInDay; + EndingFractionalDay = DataGenerators::FuelCell(GeneratorNum).FCPM.FractionalDayofLastShutDown + DataGenerators::FuelCell(GeneratorNum).FCPM.ShutDownTime / DataGlobals::HoursInDay; if (CurrentFractionalDay > EndingFractionalDay) { // start up period is now over - FuelCell(GeneratorNum).FCPM.DuringShutDown = false; + DataGenerators::FuelCell(GeneratorNum).FCPM.DuringShutDown = false; } } // compare - if (!(FuelCell(GeneratorNum).FCPM.DuringShutDown) && !(FuelCell(GeneratorNum).FCPM.DuringStartUp)) { + if (!(DataGenerators::FuelCell(GeneratorNum).FCPM.DuringShutDown) && !(DataGenerators::FuelCell(GeneratorNum).FCPM.DuringStartUp)) { // unit is neither starting or stopping and the only constraints would come from transient limits - if (Pel > FuelCell(GeneratorNum).FCPM.PelLastTimeStep) { // powering up - MaxPel = FuelCell(GeneratorNum).FCPM.PelLastTimeStep + FuelCell(GeneratorNum).FCPM.UpTranLimit * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + if (Pel > DataGenerators::FuelCell(GeneratorNum).FCPM.PelLastTimeStep) { // powering up + MaxPel = DataGenerators::FuelCell(GeneratorNum).FCPM.PelLastTimeStep + DataGenerators::FuelCell(GeneratorNum).FCPM.UpTranLimit * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; if (MaxPel < Pel) { Pel = MaxPel; Constrained = true; } else { Constrained = false; } - } else if (Pel < FuelCell(GeneratorNum).FCPM.PelLastTimeStep) { // powering down - MinPel = FuelCell(GeneratorNum).FCPM.PelLastTimeStep - FuelCell(GeneratorNum).FCPM.DownTranLimit * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + } else if (Pel < DataGenerators::FuelCell(GeneratorNum).FCPM.PelLastTimeStep) { // powering down + MinPel = DataGenerators::FuelCell(GeneratorNum).FCPM.PelLastTimeStep - DataGenerators::FuelCell(GeneratorNum).FCPM.DownTranLimit * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; if (Pel < MinPel) { Pel = MinPel; Constrained = true; @@ -3267,13 +3139,13 @@ namespace FuelCellElectricGenerator { } // not in start up or shut down - if (FuelCell(GeneratorNum).FCPM.DuringStartUp) { + if (DataGenerators::FuelCell(GeneratorNum).FCPM.DuringStartUp) { // constant during start up modeling artifact - Pel = FuelCell(GeneratorNum).FCPM.StartUpElectProd / FuelCell(GeneratorNum).FCPM.StartUpTime; + Pel = DataGenerators::FuelCell(GeneratorNum).FCPM.StartUpElectProd / DataGenerators::FuelCell(GeneratorNum).FCPM.StartUpTime; Constrained = true; } - if (FuelCell(GeneratorNum).FCPM.DuringShutDown) { + if (DataGenerators::FuelCell(GeneratorNum).FCPM.DuringShutDown) { Pel = 0.0; // assumes no power generated during shut down Constrained = true; @@ -3290,12 +3162,10 @@ namespace FuelCellElectricGenerator { // not yet implemented, just pass product gases thru nul domain - using DataGenerators::FuelCell; - - FuelCell(Num).AuxilHeat.TauxMix = FuelCell(Num).FCPM.TprodGasLeavingFCPM; - FuelCell(Num).AuxilHeat.NdotAuxMix = FuelCell(Num).FCPM.NdotProdGas; - FuelCell(Num).AuxilHeat.ConstitMolalFract = FuelCell(Num).FCPM.ConstitMolalFract; - FuelCell(Num).AuxilHeat.GasLibID = FuelCell(Num).FCPM.GasLibID; + DataGenerators::FuelCell(Num).AuxilHeat.TauxMix = DataGenerators::FuelCell(Num).FCPM.TprodGasLeavingFCPM; + DataGenerators::FuelCell(Num).AuxilHeat.NdotAuxMix = DataGenerators::FuelCell(Num).FCPM.NdotProdGas; + DataGenerators::FuelCell(Num).AuxilHeat.ConstitMolalFract = DataGenerators::FuelCell(Num).FCPM.ConstitMolalFract; + DataGenerators::FuelCell(Num).AuxilHeat.GasLibID = DataGenerators::FuelCell(Num).FCPM.GasLibID; } void CalcFuelCellGenHeatRecovery(int const Num) // Generator number @@ -3312,12 +3182,6 @@ namespace FuelCellElectricGenerator { // REFERENCES: Annex 42 model documentation - using DataGenerators::FuelCell; - using DataGenerators::FixedEffectiveness; - using DataGenerators::LMTDempiricalUAeff; - using DataGenerators::LMTDfundementalUAeff; - using DataGenerators::Condensing; - static std::string const RoutineName("CalcFuelCellGenHeatRecovery"); Real64 eHX; // fixed effectiveness @@ -3355,23 +3219,23 @@ namespace FuelCellElectricGenerator { Real64 Cp; { - auto const SELECT_CASE_var(FuelCell(Num).ExhaustHX.HXmodelMode); + auto const SELECT_CASE_var(DataGenerators::FuelCell(Num).ExhaustHX.HXmodelMode); - if (SELECT_CASE_var == FixedEffectiveness) { // Method 1 + if (SELECT_CASE_var == DataGenerators::FixedEffectiveness) { // Method 1 - eHX = FuelCell(Num).ExhaustHX.HXEffect; + eHX = DataGenerators::FuelCell(Num).ExhaustHX.HXEffect; - inNodeNum = FuelCell(Num).ExhaustHX.WaterInNode; + inNodeNum = DataGenerators::FuelCell(Num).ExhaustHX.WaterInNode; - MdotWater = FuelCell(Num).ExhaustHX.WaterMassFlowRate; + MdotWater = DataGenerators::FuelCell(Num).ExhaustHX.WaterMassFlowRate; MWwater = DataGenerators::GasPhaseThermoChemistryData(4).MolecularWeight; NdotWater = MdotWater / MWwater; - TwaterIn = FuelCell(Num).ExhaustHX.WaterInletTemp; + TwaterIn = DataGenerators::FuelCell(Num).ExhaustHX.WaterInletTemp; FigureLiquidWaterHeatCap(TwaterIn, CpWaterMol); - NdotGas = FuelCell(Num).AuxilHeat.NdotAuxMix; - TprodGasIn = FuelCell(Num).AuxilHeat.TauxMix; + NdotGas = DataGenerators::FuelCell(Num).AuxilHeat.NdotAuxMix; + TprodGasIn = DataGenerators::FuelCell(Num).AuxilHeat.TauxMix; FigureAuxilHeatGasHeatCap(Num, TprodGasIn, CpProdGasMol); // Cp in (J/mol*K) // factor of 1000.0 for kmol -> mol NdotCp = min(NdotGas * CpProdGasMol * 1000.0, NdotWater * CpWaterMol * 1000.0); @@ -3381,7 +3245,7 @@ namespace FuelCellElectricGenerator { THXexh = TprodGasIn - qHX / (NdotGas * CpProdGasMol * 1000.0); Cp = FluidProperties::GetSpecificHeatGlycol( - DataPlant::PlantLoop(FuelCell(Num).CWLoopNum).FluidName, TwaterIn, DataPlant::PlantLoop(FuelCell(Num).CWLoopNum).FluidIndex, RoutineName); + DataPlant::PlantLoop(DataGenerators::FuelCell(Num).CWLoopNum).FluidName, TwaterIn, DataPlant::PlantLoop(DataGenerators::FuelCell(Num).CWLoopNum).FluidIndex, RoutineName); if (MdotWater * Cp <= 0.0) { TwaterOut = TwaterIn; @@ -3389,18 +3253,18 @@ namespace FuelCellElectricGenerator { TwaterOut = TwaterIn + qHX / (MdotWater * Cp); } - } else if (SELECT_CASE_var == LMTDempiricalUAeff) { // method 2 - inNodeNum = FuelCell(Num).ExhaustHX.WaterInNode; - MdotWater = FuelCell(Num).ExhaustHX.WaterMassFlowRate; + } else if (SELECT_CASE_var == DataGenerators::LMTDempiricalUAeff) { // method 2 + inNodeNum = DataGenerators::FuelCell(Num).ExhaustHX.WaterInNode; + MdotWater = DataGenerators::FuelCell(Num).ExhaustHX.WaterMassFlowRate; MWwater = DataGenerators::GasPhaseThermoChemistryData(4).MolecularWeight; NdotWater = MdotWater / MWwater; - NdotGas = FuelCell(Num).AuxilHeat.NdotAuxMix; + NdotGas = DataGenerators::FuelCell(Num).AuxilHeat.NdotAuxMix; - UAeff = FuelCell(Num).ExhaustHX.hxs0 + FuelCell(Num).ExhaustHX.hxs1 * NdotWater + FuelCell(Num).ExhaustHX.hxs2 * pow_2(NdotWater) + - FuelCell(Num).ExhaustHX.hxs3 * NdotGas + FuelCell(Num).ExhaustHX.hxs4 * pow_2(NdotGas); + UAeff = DataGenerators::FuelCell(Num).ExhaustHX.hxs0 + DataGenerators::FuelCell(Num).ExhaustHX.hxs1 * NdotWater + DataGenerators::FuelCell(Num).ExhaustHX.hxs2 * pow_2(NdotWater) + + DataGenerators::FuelCell(Num).ExhaustHX.hxs3 * NdotGas + DataGenerators::FuelCell(Num).ExhaustHX.hxs4 * pow_2(NdotGas); - TauxMix = FuelCell(Num).AuxilHeat.TauxMix; - TwaterIn = FuelCell(Num).ExhaustHX.WaterInletTemp; + TauxMix = DataGenerators::FuelCell(Num).AuxilHeat.TauxMix; + TwaterIn = DataGenerators::FuelCell(Num).ExhaustHX.WaterInletTemp; FigureLiquidWaterHeatCap(TwaterIn, CpWaterMol); // factor of 1000.0 for kmol -> mol NdotCpWater = NdotWater * CpWaterMol * 1000.0; @@ -3430,25 +3294,25 @@ namespace FuelCellElectricGenerator { qHX = 0.0; } - } else if (SELECT_CASE_var == LMTDfundementalUAeff) { // method 3 - NdotGas = FuelCell(Num).AuxilHeat.NdotAuxMix; - inNodeNum = FuelCell(Num).ExhaustHX.WaterInNode; - MdotWater = FuelCell(Num).ExhaustHX.WaterMassFlowRate; + } else if (SELECT_CASE_var == DataGenerators::LMTDfundementalUAeff) { // method 3 + NdotGas = DataGenerators::FuelCell(Num).AuxilHeat.NdotAuxMix; + inNodeNum = DataGenerators::FuelCell(Num).ExhaustHX.WaterInNode; + MdotWater = DataGenerators::FuelCell(Num).ExhaustHX.WaterMassFlowRate; MWwater = DataGenerators::GasPhaseThermoChemistryData(4).MolecularWeight; NdotWater = MdotWater / MWwater; hgas = - FuelCell(Num).ExhaustHX.h0gas * std::pow(NdotGas / FuelCell(Num).ExhaustHX.NdotGasRef, FuelCell(Num).ExhaustHX.nCoeff); // Eq. 48 + DataGenerators::FuelCell(Num).ExhaustHX.h0gas * std::pow(NdotGas / DataGenerators::FuelCell(Num).ExhaustHX.NdotGasRef, DataGenerators::FuelCell(Num).ExhaustHX.nCoeff); // Eq. 48 - hwater = FuelCell(Num).ExhaustHX.h0Water * - std::pow(NdotWater / FuelCell(Num).ExhaustHX.NdotWaterRef, FuelCell(Num).ExhaustHX.mCoeff); // Eq. 48 + hwater = DataGenerators::FuelCell(Num).ExhaustHX.h0Water * + std::pow(NdotWater / DataGenerators::FuelCell(Num).ExhaustHX.NdotWaterRef, DataGenerators::FuelCell(Num).ExhaustHX.mCoeff); // Eq. 48 // now equation 47 - UAeff = 1.0 / (1.0 / (hgas * FuelCell(Num).ExhaustHX.AreaGas) + 1.0 / (hwater * FuelCell(Num).ExhaustHX.AreaWater) + - FuelCell(Num).ExhaustHX.Fadjust); + UAeff = 1.0 / (1.0 / (hgas * DataGenerators::FuelCell(Num).ExhaustHX.AreaGas) + 1.0 / (hwater * DataGenerators::FuelCell(Num).ExhaustHX.AreaWater) + + DataGenerators::FuelCell(Num).ExhaustHX.Fadjust); - TauxMix = FuelCell(Num).AuxilHeat.TauxMix; - TwaterIn = FuelCell(Num).ExhaustHX.WaterInletTemp; + TauxMix = DataGenerators::FuelCell(Num).AuxilHeat.TauxMix; + TwaterIn = DataGenerators::FuelCell(Num).ExhaustHX.WaterInletTemp; FigureLiquidWaterHeatCap(TwaterIn, CpWaterMol); NdotCpWater = NdotWater * CpWaterMol * 1000.0; FigureAuxilHeatGasHeatCap(Num, TauxMix, CpProdGasMol); // Cp in (J/mol*K) @@ -3476,35 +3340,35 @@ namespace FuelCellElectricGenerator { qHX = 0.0; } - } else if (SELECT_CASE_var == Condensing) { // method 4 - inNodeNum = FuelCell(Num).ExhaustHX.WaterInNode; - MdotWater = FuelCell(Num).ExhaustHX.WaterMassFlowRate; + } else if (SELECT_CASE_var == DataGenerators::Condensing) { // method 4 + inNodeNum = DataGenerators::FuelCell(Num).ExhaustHX.WaterInNode; + MdotWater = DataGenerators::FuelCell(Num).ExhaustHX.WaterMassFlowRate; if (MdotWater != 0.0) { MWwater = DataGenerators::GasPhaseThermoChemistryData(4).MolecularWeight; NdotWater = MdotWater / MWwater; - NdotGas = FuelCell(Num).AuxilHeat.NdotAuxMix; + NdotGas = DataGenerators::FuelCell(Num).AuxilHeat.NdotAuxMix; - UAeff = FuelCell(Num).ExhaustHX.hxs0 + FuelCell(Num).ExhaustHX.hxs1 * NdotWater + - FuelCell(Num).ExhaustHX.hxs2 * pow_2(NdotWater) + FuelCell(Num).ExhaustHX.hxs3 * NdotGas + - FuelCell(Num).ExhaustHX.hxs4 * pow_2(NdotGas); + UAeff = DataGenerators::FuelCell(Num).ExhaustHX.hxs0 + DataGenerators::FuelCell(Num).ExhaustHX.hxs1 * NdotWater + + DataGenerators::FuelCell(Num).ExhaustHX.hxs2 * pow_2(NdotWater) + DataGenerators::FuelCell(Num).ExhaustHX.hxs3 * NdotGas + + DataGenerators::FuelCell(Num).ExhaustHX.hxs4 * pow_2(NdotGas); - TauxMix = FuelCell(Num).AuxilHeat.TauxMix; - TwaterIn = FuelCell(Num).ExhaustHX.WaterInletTemp; + TauxMix = DataGenerators::FuelCell(Num).AuxilHeat.TauxMix; + TwaterIn = DataGenerators::FuelCell(Num).ExhaustHX.WaterInletTemp; FigureLiquidWaterHeatCap(TwaterIn, CpWaterMol); NdotCpWater = NdotWater * CpWaterMol * 1000.0; FigureAuxilHeatGasHeatCap(Num, TauxMix, CpProdGasMol); // Cp in (J/mol*K) NdotCpAuxMix = NdotGas * CpProdGasMol * 1000.0; // find water fraction in incoming gas stream - for (i = 1; i <= isize(FuelCell(Num).AuxilHeat.GasLibID); ++i) { - if (FuelCell(Num).AuxilHeat.GasLibID(i) == 4) waterFract = FuelCell(Num).AuxilHeat.ConstitMolalFract(i); + for (i = 1; i <= isize(DataGenerators::FuelCell(Num).AuxilHeat.GasLibID); ++i) { + if (DataGenerators::FuelCell(Num).AuxilHeat.GasLibID(i) == 4) waterFract = DataGenerators::FuelCell(Num).AuxilHeat.ConstitMolalFract(i); } NdotWaterVapor = waterFract * NdotGas; - TcondThresh = FuelCell(Num).ExhaustHX.CondensationThresholdTemp; - hxl1 = FuelCell(Num).ExhaustHX.l1Coeff; - hxl2 = FuelCell(Num).ExhaustHX.l2Coeff; + TcondThresh = DataGenerators::FuelCell(Num).ExhaustHX.CondensationThresholdTemp; + hxl1 = DataGenerators::FuelCell(Num).ExhaustHX.l1Coeff; + hxl2 = DataGenerators::FuelCell(Num).ExhaustHX.l2Coeff; NdotWaterCond = (TcondThresh - TwaterIn) * (hxl1 * (NdotWaterVapor / NdotGas) + hxl2 * pow_2(NdotWaterVapor / NdotGas)); @@ -3574,8 +3438,8 @@ namespace FuelCellElectricGenerator { } } else { // no cooling water flow, model will blow up. qHX = 0.0; - THXexh = FuelCell(Num).AuxilHeat.TauxMix; - TwaterOut = FuelCell(Num).ExhaustHX.WaterInletTemp; + THXexh = DataGenerators::FuelCell(Num).AuxilHeat.TauxMix; + TwaterOut = DataGenerators::FuelCell(Num).ExhaustHX.WaterInletTemp; NdotWaterCond = 0.0; waterFract = -9999.0; // not defined } @@ -3585,14 +3449,14 @@ namespace FuelCellElectricGenerator { } // update results in data structure. - FuelCell(Num).ExhaustHX.qHX = qHX; - FuelCell(Num).ExhaustHX.THXexh = THXexh; - FuelCell(Num).ExhaustHX.WaterMassFlowRate = MdotWater; - FuelCell(Num).ExhaustHX.WaterVaporFractExh = waterFract; - - FuelCell(Num).ExhaustHX.CondensateRate = NdotWaterCond; - FuelCell(Num).ExhaustHX.WaterOutletTemp = TwaterOut; - FuelCell(Num).ExhaustHX.WaterOutletEnthalpy = DataLoopNode::Node(inNodeNum).Enthalpy + qHX; + DataGenerators::FuelCell(Num).ExhaustHX.qHX = qHX; + DataGenerators::FuelCell(Num).ExhaustHX.THXexh = THXexh; + DataGenerators::FuelCell(Num).ExhaustHX.WaterMassFlowRate = MdotWater; + DataGenerators::FuelCell(Num).ExhaustHX.WaterVaporFractExh = waterFract; + + DataGenerators::FuelCell(Num).ExhaustHX.CondensateRate = NdotWaterCond; + DataGenerators::FuelCell(Num).ExhaustHX.WaterOutletTemp = TwaterOut; + DataGenerators::FuelCell(Num).ExhaustHX.WaterOutletEnthalpy = DataLoopNode::Node(inNodeNum).Enthalpy + qHX; } void SimFuelCellPlantHeatRecovery(std::string const &EP_UNUSED(CompType), From d51fc015c87ba323e51f96ea4ff7f3712ee08269 Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Mon, 11 Nov 2019 14:25:52 -0700 Subject: [PATCH 18/51] partial cleanup usings --- src/EnergyPlus/FuelCellElectricGenerator.cc | 445 ++++++++++---------- 1 file changed, 212 insertions(+), 233 deletions(-) diff --git a/src/EnergyPlus/FuelCellElectricGenerator.cc b/src/EnergyPlus/FuelCellElectricGenerator.cc index 0ab475f6f44..b574afc3cfc 100644 --- a/src/EnergyPlus/FuelCellElectricGenerator.cc +++ b/src/EnergyPlus/FuelCellElectricGenerator.cc @@ -3548,11 +3548,6 @@ namespace FuelCellElectricGenerator { // METHODOLOGY EMPLOYED: // Uses the status flags to trigger initializations. - using DataGenerators::NumFuelCellGenerators; - using DataGenerators::FuelCell; - using DataGenerators::FuelSupply; - using DataGenerators::InitHRTemp; - static std::string const RoutineName("InitFuelCellGenerators"); static bool InitGeneratorOnce(true); // flag for 1 time initialization @@ -3568,9 +3563,9 @@ namespace FuelCellElectricGenerator { // Do the one time initializations if (InitGeneratorOnce) { - MyEnvrnFlag.allocate(NumFuelCellGenerators); - MyWarmupFlag.allocate(NumFuelCellGenerators); - MyPlantScanFlag.allocate(NumFuelCellGenerators); + MyEnvrnFlag.allocate(DataGenerators::NumFuelCellGenerators); + MyWarmupFlag.allocate(DataGenerators::NumFuelCellGenerators); + MyPlantScanFlag.allocate(DataGenerators::NumFuelCellGenerators); MyEnvrnFlag = true; MyWarmupFlag = false; InitGeneratorOnce = false; @@ -3580,12 +3575,12 @@ namespace FuelCellElectricGenerator { if (MyPlantScanFlag(FCnum) && allocated(DataPlant::PlantLoop)) { errFlag = false; - PlantUtilities::ScanPlantLoopsForObject(FuelCell(FCnum).NameExhaustHX, + PlantUtilities::ScanPlantLoopsForObject(DataGenerators::FuelCell(FCnum).NameExhaustHX, DataPlant::TypeOf_Generator_FCExhaust, - FuelCell(FCnum).CWLoopNum, - FuelCell(FCnum).CWLoopSideNum, - FuelCell(FCnum).CWBranchNum, - FuelCell(FCnum).CWCompNum, + DataGenerators::FuelCell(FCnum).CWLoopNum, + DataGenerators::FuelCell(FCnum).CWLoopSideNum, + DataGenerators::FuelCell(FCnum).CWBranchNum, + DataGenerators::FuelCell(FCnum).CWCompNum, errFlag, _, _, @@ -3604,78 +3599,78 @@ namespace FuelCellElectricGenerator { // Do the Begin Environment initializations if (DataGlobals::BeginEnvrnFlag && MyEnvrnFlag(FCnum) && !MyPlantScanFlag(FCnum)) { - FuelSupply(FuelCell(FCnum).FuelSupNum).PfuelCompEl = 0.0; - FuelSupply(FuelCell(FCnum).FuelSupNum).TfuelIntoFCPM = 0.0; - FuelSupply(FuelCell(FCnum).FuelSupNum).TfuelIntoCompress = 0.0; - FuelSupply(FuelCell(FCnum).FuelSupNum).QskinLoss = 0.0; - - FuelCell(FCnum).AirSup.TairIntoFCPM = 0.0; - FuelCell(FCnum).AirSup.PairCompEl = 0.0; - FuelCell(FCnum).AirSup.TairIntoBlower = 0.0; - FuelCell(FCnum).AirSup.QskinLoss = 0.0; - FuelCell(FCnum).AirSup.QintakeRecovery = 0.0; - FuelCell(FCnum).FCPM.NumCycles = 0; - FuelCell(FCnum).FCPM.Pel = 0.0; - FuelCell(FCnum).FCPM.PelLastTimeStep = 0.0; - FuelCell(FCnum).FCPM.Eel = 0.0; - FuelCell(FCnum).FCPM.PelancillariesAC = 0.0; - FuelCell(FCnum).FCPM.NdotFuel = 0.0; - FuelCell(FCnum).FCPM.TotFuelInEnthalphy = 0.0; - FuelCell(FCnum).FCPM.NdotProdGas = 0.0; - FuelCell(FCnum).FCPM.TprodGasLeavingFCPM = 0.0; - FuelCell(FCnum).FCPM.TotProdGasEnthalphy = 0.0; - FuelCell(FCnum).FCPM.NdotAir = 0.0; - FuelCell(FCnum).FCPM.TotAirInEnthalphy = 0.0; - FuelCell(FCnum).FCPM.NdotLiqwater = 0.0; - FuelCell(FCnum).FCPM.TwaterInlet = 0.0; - FuelCell(FCnum).FCPM.WaterInEnthalpy = 0.0; - FuelCell(FCnum).FCPM.TprodGasLeavingFCPM = 200.0; - FuelCell(FCnum).FCPM.FractionalDayofLastStartUp = 0.0; - FuelCell(FCnum).FCPM.FractionalDayofLastShutDown = 0.0; - FuelCell(FCnum).FCPM.HasBeenOn = true; - FuelCell(FCnum).FCPM.DuringShutDown = false; - FuelCell(FCnum).FCPM.DuringStartUp = false; - FuelCell(FCnum).WaterSup.TwaterIntoCompress = 0.0; - FuelCell(FCnum).WaterSup.TwaterIntoFCPM = 0.0; - FuelCell(FCnum).WaterSup.PwaterCompEl = 0.0; - FuelCell(FCnum).WaterSup.QskinLoss = 0.0; - FuelCell(FCnum).AuxilHeat.TauxMix = 0.0; - FuelCell(FCnum).AuxilHeat.NdotAuxMix = 0.0; - FuelCell(FCnum).AuxilHeat.QskinLoss = 0.0; - FuelCell(FCnum).AuxilHeat.QairIntake = 0.0; - FuelCell(FCnum).ExhaustHX.NdotHXleaving = 0.0; - FuelCell(FCnum).ExhaustHX.WaterOutletTemp = 0.0; - FuelCell(FCnum).ExhaustHX.WaterOutletEnthalpy = 0.0; - FuelCell(FCnum).ElecStorage.LastTimeStepStateOfCharge = FuelCell(FCnum).ElecStorage.StartingEnergyStored; - FuelCell(FCnum).ElecStorage.ThisTimeStepStateOfCharge = FuelCell(FCnum).ElecStorage.StartingEnergyStored; - FuelCell(FCnum).ElecStorage.PelNeedFromStorage = 0.0; - FuelCell(FCnum).ElecStorage.IdesiredDischargeCurrent = 0.0; - FuelCell(FCnum).ElecStorage.PelFromStorage = 0.0; - FuelCell(FCnum).ElecStorage.IfromStorage = 0.0; - FuelCell(FCnum).ElecStorage.PelIntoStorage = 0.0; - FuelCell(FCnum).ElecStorage.QairIntake = 0.0; - - FuelCell(FCnum).Inverter.PCUlosses = 0.0; - FuelCell(FCnum).Inverter.QairIntake = 0.0; + DataGenerators::FuelSupply(DataGenerators::FuelCell(FCnum).FuelSupNum).PfuelCompEl = 0.0; + DataGenerators::FuelSupply(DataGenerators::FuelCell(FCnum).FuelSupNum).TfuelIntoFCPM = 0.0; + DataGenerators::FuelSupply(DataGenerators::FuelCell(FCnum).FuelSupNum).TfuelIntoCompress = 0.0; + DataGenerators::FuelSupply(DataGenerators::FuelCell(FCnum).FuelSupNum).QskinLoss = 0.0; + + DataGenerators::FuelCell(FCnum).AirSup.TairIntoFCPM = 0.0; + DataGenerators::FuelCell(FCnum).AirSup.PairCompEl = 0.0; + DataGenerators::FuelCell(FCnum).AirSup.TairIntoBlower = 0.0; + DataGenerators::FuelCell(FCnum).AirSup.QskinLoss = 0.0; + DataGenerators::FuelCell(FCnum).AirSup.QintakeRecovery = 0.0; + DataGenerators::FuelCell(FCnum).FCPM.NumCycles = 0; + DataGenerators::FuelCell(FCnum).FCPM.Pel = 0.0; + DataGenerators::FuelCell(FCnum).FCPM.PelLastTimeStep = 0.0; + DataGenerators::FuelCell(FCnum).FCPM.Eel = 0.0; + DataGenerators::FuelCell(FCnum).FCPM.PelancillariesAC = 0.0; + DataGenerators::FuelCell(FCnum).FCPM.NdotFuel = 0.0; + DataGenerators::FuelCell(FCnum).FCPM.TotFuelInEnthalphy = 0.0; + DataGenerators::FuelCell(FCnum).FCPM.NdotProdGas = 0.0; + DataGenerators::FuelCell(FCnum).FCPM.TprodGasLeavingFCPM = 0.0; + DataGenerators::FuelCell(FCnum).FCPM.TotProdGasEnthalphy = 0.0; + DataGenerators::FuelCell(FCnum).FCPM.NdotAir = 0.0; + DataGenerators::FuelCell(FCnum).FCPM.TotAirInEnthalphy = 0.0; + DataGenerators::FuelCell(FCnum).FCPM.NdotLiqwater = 0.0; + DataGenerators::FuelCell(FCnum).FCPM.TwaterInlet = 0.0; + DataGenerators::FuelCell(FCnum).FCPM.WaterInEnthalpy = 0.0; + DataGenerators::FuelCell(FCnum).FCPM.TprodGasLeavingFCPM = 200.0; + DataGenerators::FuelCell(FCnum).FCPM.FractionalDayofLastStartUp = 0.0; + DataGenerators::FuelCell(FCnum).FCPM.FractionalDayofLastShutDown = 0.0; + DataGenerators::FuelCell(FCnum).FCPM.HasBeenOn = true; + DataGenerators::FuelCell(FCnum).FCPM.DuringShutDown = false; + DataGenerators::FuelCell(FCnum).FCPM.DuringStartUp = false; + DataGenerators::FuelCell(FCnum).WaterSup.TwaterIntoCompress = 0.0; + DataGenerators::FuelCell(FCnum).WaterSup.TwaterIntoFCPM = 0.0; + DataGenerators::FuelCell(FCnum).WaterSup.PwaterCompEl = 0.0; + DataGenerators::FuelCell(FCnum).WaterSup.QskinLoss = 0.0; + DataGenerators::FuelCell(FCnum).AuxilHeat.TauxMix = 0.0; + DataGenerators::FuelCell(FCnum).AuxilHeat.NdotAuxMix = 0.0; + DataGenerators::FuelCell(FCnum).AuxilHeat.QskinLoss = 0.0; + DataGenerators::FuelCell(FCnum).AuxilHeat.QairIntake = 0.0; + DataGenerators::FuelCell(FCnum).ExhaustHX.NdotHXleaving = 0.0; + DataGenerators::FuelCell(FCnum).ExhaustHX.WaterOutletTemp = 0.0; + DataGenerators::FuelCell(FCnum).ExhaustHX.WaterOutletEnthalpy = 0.0; + DataGenerators::FuelCell(FCnum).ElecStorage.LastTimeStepStateOfCharge = DataGenerators::FuelCell(FCnum).ElecStorage.StartingEnergyStored; + DataGenerators::FuelCell(FCnum).ElecStorage.ThisTimeStepStateOfCharge = DataGenerators::FuelCell(FCnum).ElecStorage.StartingEnergyStored; + DataGenerators::FuelCell(FCnum).ElecStorage.PelNeedFromStorage = 0.0; + DataGenerators::FuelCell(FCnum).ElecStorage.IdesiredDischargeCurrent = 0.0; + DataGenerators::FuelCell(FCnum).ElecStorage.PelFromStorage = 0.0; + DataGenerators::FuelCell(FCnum).ElecStorage.IfromStorage = 0.0; + DataGenerators::FuelCell(FCnum).ElecStorage.PelIntoStorage = 0.0; + DataGenerators::FuelCell(FCnum).ElecStorage.QairIntake = 0.0; + + DataGenerators::FuelCell(FCnum).Inverter.PCUlosses = 0.0; + DataGenerators::FuelCell(FCnum).Inverter.QairIntake = 0.0; rho = FluidProperties::GetDensityGlycol( - DataPlant::PlantLoop(FuelCell(FCnum).CWLoopNum).FluidName, InitHRTemp, DataPlant::PlantLoop(FuelCell(FCnum).CWLoopNum).FluidIndex, RoutineName); + DataPlant::PlantLoop(DataGenerators::FuelCell(FCnum).CWLoopNum).FluidName, DataGenerators::InitHRTemp, DataPlant::PlantLoop(DataGenerators::FuelCell(FCnum).CWLoopNum).FluidIndex, RoutineName); - FuelCell(FCnum).ExhaustHX.WaterMassFlowRateDesign = FuelCell(FCnum).ExhaustHX.WaterVolumeFlowMax * rho; - FuelCell(FCnum).ExhaustHX.WaterMassFlowRate = FuelCell(FCnum).ExhaustHX.WaterMassFlowRateDesign; - inNode = FuelCell(FCnum).ExhaustHX.WaterInNode; - outNode = FuelCell(FCnum).ExhaustHX.WaterOutNode; - DataLoopNode::Node(inNode).Temp = InitHRTemp; - DataLoopNode::Node(outNode).Temp = InitHRTemp; + DataGenerators::FuelCell(FCnum).ExhaustHX.WaterMassFlowRateDesign = DataGenerators::FuelCell(FCnum).ExhaustHX.WaterVolumeFlowMax * rho; + DataGenerators::FuelCell(FCnum).ExhaustHX.WaterMassFlowRate = DataGenerators::FuelCell(FCnum).ExhaustHX.WaterMassFlowRateDesign; + inNode = DataGenerators::FuelCell(FCnum).ExhaustHX.WaterInNode; + outNode = DataGenerators::FuelCell(FCnum).ExhaustHX.WaterOutNode; + DataLoopNode::Node(inNode).Temp = DataGenerators::InitHRTemp; + DataLoopNode::Node(outNode).Temp = DataGenerators::InitHRTemp; PlantUtilities::InitComponentNodes(0.0, - FuelCell(FCnum).ExhaustHX.WaterMassFlowRateDesign, + DataGenerators::FuelCell(FCnum).ExhaustHX.WaterMassFlowRateDesign, inNode, outNode, - FuelCell(FCnum).CWLoopNum, - FuelCell(FCnum).CWLoopSideNum, - FuelCell(FCnum).CWBranchNum, - FuelCell(FCnum).CWCompNum); + DataGenerators::FuelCell(FCnum).CWLoopNum, + DataGenerators::FuelCell(FCnum).CWLoopSideNum, + DataGenerators::FuelCell(FCnum).CWBranchNum, + DataGenerators::FuelCell(FCnum).CWCompNum); MyEnvrnFlag(FCnum) = false; MyWarmupFlag(FCnum) = true; @@ -3687,46 +3682,46 @@ namespace FuelCellElectricGenerator { if (MyWarmupFlag(FCnum) && (!DataGlobals::WarmupFlag)) { // need to reset initial state of charge at beginning of environment but after warm up is complete - FuelCell(FCnum).ElecStorage.LastTimeStepStateOfCharge = FuelCell(FCnum).ElecStorage.StartingEnergyStored; - FuelCell(FCnum).ElecStorage.ThisTimeStepStateOfCharge = FuelCell(FCnum).ElecStorage.StartingEnergyStored; + DataGenerators::FuelCell(FCnum).ElecStorage.LastTimeStepStateOfCharge = DataGenerators::FuelCell(FCnum).ElecStorage.StartingEnergyStored; + DataGenerators::FuelCell(FCnum).ElecStorage.ThisTimeStepStateOfCharge = DataGenerators::FuelCell(FCnum).ElecStorage.StartingEnergyStored; MyWarmupFlag(FCnum) = false; } // using and elapsed time method rather than FirstHVACIteration here TimeElapsed = DataGlobals::HourOfDay + DataGlobals::TimeStep * DataGlobals::TimeStepZone + DataHVACGlobals::SysTimeElapsed; - if (FuelCell(FCnum).TimeElapsed != TimeElapsed) { + if (DataGenerators::FuelCell(FCnum).TimeElapsed != TimeElapsed) { - FuelCell(FCnum).ElecStorage.LastTimeStepStateOfCharge = FuelCell(FCnum).ElecStorage.ThisTimeStepStateOfCharge; - FuelCell(FCnum).FCPM.PelLastTimeStep = FuelCell(FCnum).FCPM.Pel; + DataGenerators::FuelCell(FCnum).ElecStorage.LastTimeStepStateOfCharge = DataGenerators::FuelCell(FCnum).ElecStorage.ThisTimeStepStateOfCharge; + DataGenerators::FuelCell(FCnum).FCPM.PelLastTimeStep = DataGenerators::FuelCell(FCnum).FCPM.Pel; - inNode = FuelCell(FCnum).ExhaustHX.WaterInNode; - outNode = FuelCell(FCnum).ExhaustHX.WaterOutNode; + inNode = DataGenerators::FuelCell(FCnum).ExhaustHX.WaterInNode; + outNode = DataGenerators::FuelCell(FCnum).ExhaustHX.WaterOutNode; // intialize flow rate in water loop, this is "requesting" flow - mdot = FuelCell(FCnum).ExhaustHX.WaterMassFlowRateDesign; + mdot = DataGenerators::FuelCell(FCnum).ExhaustHX.WaterMassFlowRateDesign; PlantUtilities::SetComponentFlowRate(mdot, inNode, outNode, - FuelCell(FCnum).CWLoopNum, - FuelCell(FCnum).CWLoopSideNum, - FuelCell(FCnum).CWBranchNum, - FuelCell(FCnum).CWCompNum); - - FuelCell(FCnum).ExhaustHX.WaterMassFlowRate = mdot; - FuelCell(FCnum).ExhaustHX.WaterInletTemp = DataLoopNode::Node(inNode).Temp; - FuelCell(FCnum).TimeElapsed = TimeElapsed; + DataGenerators::FuelCell(FCnum).CWLoopNum, + DataGenerators::FuelCell(FCnum).CWLoopSideNum, + DataGenerators::FuelCell(FCnum).CWBranchNum, + DataGenerators::FuelCell(FCnum).CWCompNum); + + DataGenerators::FuelCell(FCnum).ExhaustHX.WaterMassFlowRate = mdot; + DataGenerators::FuelCell(FCnum).ExhaustHX.WaterInletTemp = DataLoopNode::Node(inNode).Temp; + DataGenerators::FuelCell(FCnum).TimeElapsed = TimeElapsed; } else { - inNode = FuelCell(FCnum).ExhaustHX.WaterInNode; + inNode = DataGenerators::FuelCell(FCnum).ExhaustHX.WaterInNode; - PlantUtilities::SetComponentFlowRate(FuelCell(FCnum).ExhaustHX.WaterMassFlowRate, - FuelCell(FCnum).ExhaustHX.WaterInNode, - FuelCell(FCnum).ExhaustHX.WaterOutNode, - FuelCell(FCnum).CWLoopNum, - FuelCell(FCnum).CWLoopSideNum, - FuelCell(FCnum).CWBranchNum, - FuelCell(FCnum).CWCompNum); + PlantUtilities::SetComponentFlowRate(DataGenerators::FuelCell(FCnum).ExhaustHX.WaterMassFlowRate, + DataGenerators::FuelCell(FCnum).ExhaustHX.WaterInNode, + DataGenerators::FuelCell(FCnum).ExhaustHX.WaterOutNode, + DataGenerators::FuelCell(FCnum).CWLoopNum, + DataGenerators::FuelCell(FCnum).CWLoopSideNum, + DataGenerators::FuelCell(FCnum).CWBranchNum, + DataGenerators::FuelCell(FCnum).CWCompNum); - FuelCell(FCnum).ExhaustHX.WaterInletTemp = DataLoopNode::Node(inNode).Temp; + DataGenerators::FuelCell(FCnum).ExhaustHX.WaterInletTemp = DataLoopNode::Node(inNode).Temp; } } @@ -3766,28 +3761,18 @@ namespace FuelCellElectricGenerator { // This routine adds up the various skin losses and then // sets the values in the ZoneIntGain structure - using DataGenerators::NumFuelCellGenerators; - using DataGenerators::FuelCell; - using DataGenerators::FuelSupply; - using DataGenerators::NoRecoveryOnAirIntake; - using DataGenerators::RecoverAuxiliaryBurner; - using DataGenerators::RecoverInverterBatt; - using DataGenerators::RecoverInverter; - using DataGenerators::RecoverBattery; - using DataGenerators::RecoverBurnInvertBatt; - Real64 TotalZoneHeatGain; // working variable for zone gain [w] int FCnum; // number of fuel cell static bool MyEnvrnFlag(true); - if (NumFuelCellGenerators == 0) return; + if (DataGenerators::NumFuelCellGenerators == 0) return; if (DataGlobals::BeginEnvrnFlag && MyEnvrnFlag) { - for (auto &e : FuelSupply) + for (auto &e : DataGenerators::FuelSupply) e.QskinLoss = 0.0; MyEnvrnFlag = false; - for (int i = FuelCell.l(), e = FuelCell.u(); i <= e; ++i) { - auto &cell(FuelCell(i)); + for (int i = DataGenerators::FuelCell.l(), e = DataGenerators::FuelCell.u(); i <= e; ++i) { + auto &cell(DataGenerators::FuelCell(i)); cell.FCPM.HasBeenOn = false; cell.AirSup.PairCompEl = 0.0; cell.QconvZone = 0.0; @@ -3809,40 +3794,40 @@ namespace FuelCellElectricGenerator { // this routine needs to do something for zone gains during sizing // first collect skin losses from different subsystems - for (FCnum = 1; FCnum <= NumFuelCellGenerators; ++FCnum) { - TotalZoneHeatGain = FuelCell(FCnum).AirSup.QskinLoss + FuelSupply(FuelCell(FCnum).FuelSupNum).QskinLoss + - FuelCell(FCnum).WaterSup.QskinLoss + FuelCell(FCnum).AuxilHeat.QskinLoss + - FuelCell(FCnum).FCPM.QdotSkin; // intake Blower losses to zone | fuel compressor losses to zone | water pump losses to + for (FCnum = 1; FCnum <= DataGenerators::NumFuelCellGenerators; ++FCnum) { + TotalZoneHeatGain = DataGenerators::FuelCell(FCnum).AirSup.QskinLoss + DataGenerators::FuelSupply(DataGenerators::FuelCell(FCnum).FuelSupNum).QskinLoss + + DataGenerators::FuelCell(FCnum).WaterSup.QskinLoss + DataGenerators::FuelCell(FCnum).AuxilHeat.QskinLoss + + DataGenerators::FuelCell(FCnum).FCPM.QdotSkin; // intake Blower losses to zone | fuel compressor losses to zone | water pump losses to // zone | auxil burner losses to zone | power module (stack and reformer) losses to // zone // now account for other subsystems that may or may not have air intake recovery { - auto const SELECT_CASE_var(FuelCell(FCnum).AirSup.IntakeRecoveryMode); + auto const SELECT_CASE_var(DataGenerators::FuelCell(FCnum).AirSup.IntakeRecoveryMode); - if (SELECT_CASE_var == NoRecoveryOnAirIntake) { // then the heat has to go into zone + if (SELECT_CASE_var == DataGenerators::NoRecoveryOnAirIntake) { // then the heat has to go into zone TotalZoneHeatGain += - FuelCell(FCnum).AuxilHeat.QairIntake + FuelCell(FCnum).ElecStorage.QairIntake + FuelCell(FCnum).Inverter.QairIntake; - } else if (SELECT_CASE_var == RecoverAuxiliaryBurner) { - TotalZoneHeatGain += FuelCell(FCnum).ElecStorage.QairIntake + FuelCell(FCnum).Inverter.QairIntake; + DataGenerators::FuelCell(FCnum).AuxilHeat.QairIntake + DataGenerators::FuelCell(FCnum).ElecStorage.QairIntake + DataGenerators::FuelCell(FCnum).Inverter.QairIntake; + } else if (SELECT_CASE_var == DataGenerators::RecoverAuxiliaryBurner) { + TotalZoneHeatGain += DataGenerators::FuelCell(FCnum).ElecStorage.QairIntake + DataGenerators::FuelCell(FCnum).Inverter.QairIntake; - } else if (SELECT_CASE_var == RecoverInverterBatt) { - TotalZoneHeatGain += FuelCell(FCnum).AuxilHeat.QairIntake; + } else if (SELECT_CASE_var == DataGenerators::RecoverInverterBatt) { + TotalZoneHeatGain += DataGenerators::FuelCell(FCnum).AuxilHeat.QairIntake; - } else if (SELECT_CASE_var == RecoverInverter) { - TotalZoneHeatGain += FuelCell(FCnum).AuxilHeat.QairIntake + FuelCell(FCnum).ElecStorage.QairIntake; - } else if (SELECT_CASE_var == RecoverBattery) { - TotalZoneHeatGain += FuelCell(FCnum).AuxilHeat.QairIntake + FuelCell(FCnum).Inverter.QairIntake; + } else if (SELECT_CASE_var == DataGenerators::RecoverInverter) { + TotalZoneHeatGain += DataGenerators::FuelCell(FCnum).AuxilHeat.QairIntake + DataGenerators::FuelCell(FCnum).ElecStorage.QairIntake; + } else if (SELECT_CASE_var == DataGenerators::RecoverBattery) { + TotalZoneHeatGain += DataGenerators::FuelCell(FCnum).AuxilHeat.QairIntake + DataGenerators::FuelCell(FCnum).Inverter.QairIntake; - } else if (SELECT_CASE_var == RecoverBurnInvertBatt) { + } else if (SELECT_CASE_var == DataGenerators::RecoverBurnInvertBatt) { // do nothing } } - FuelCell(FCnum).QconvZone = TotalZoneHeatGain * (1 - FuelCell(FCnum).FCPM.RadiativeFract); - FuelCell(FCnum).Report.SkinLossConvect = FuelCell(FCnum).QconvZone; - FuelCell(FCnum).QradZone = TotalZoneHeatGain * FuelCell(FCnum).FCPM.RadiativeFract; - FuelCell(FCnum).Report.SkinLossRadiat = FuelCell(FCnum).QradZone; + DataGenerators::FuelCell(FCnum).QconvZone = TotalZoneHeatGain * (1 - DataGenerators::FuelCell(FCnum).FCPM.RadiativeFract); + DataGenerators::FuelCell(FCnum).Report.SkinLossConvect = DataGenerators::FuelCell(FCnum).QconvZone; + DataGenerators::FuelCell(FCnum).QradZone = TotalZoneHeatGain * DataGenerators::FuelCell(FCnum).FCPM.RadiativeFract; + DataGenerators::FuelCell(FCnum).Report.SkinLossRadiat = DataGenerators::FuelCell(FCnum).QradZone; } // over number of Fuel cells } @@ -3860,113 +3845,109 @@ namespace FuelCellElectricGenerator { // PURPOSE OF THIS SUBROUTINE: // update plant loop interactions, do any calcs needed - using DataGenerators::FuelCell; - int InNodeNum; int OutNodeNum; // now update water outlet node Changing to Kg/s! - OutNodeNum = FuelCell(Num).ExhaustHX.WaterOutNode; - InNodeNum = FuelCell(Num).ExhaustHX.WaterInNode; + OutNodeNum = DataGenerators::FuelCell(Num).ExhaustHX.WaterOutNode; + InNodeNum = DataGenerators::FuelCell(Num).ExhaustHX.WaterInNode; PlantUtilities::SafeCopyPlantNode(InNodeNum, OutNodeNum); - DataLoopNode::Node(OutNodeNum).Temp = FuelCell(Num).ExhaustHX.WaterOutletTemp; - DataLoopNode::Node(OutNodeNum).Enthalpy = FuelCell(Num).ExhaustHX.WaterOutletEnthalpy; + DataLoopNode::Node(OutNodeNum).Temp = DataGenerators::FuelCell(Num).ExhaustHX.WaterOutletTemp; + DataLoopNode::Node(OutNodeNum).Enthalpy = DataGenerators::FuelCell(Num).ExhaustHX.WaterOutletEnthalpy; } void UpdateFuelCellGeneratorRecords(bool const EP_UNUSED(RunFlag), // TRUE if Generator operating int const Num // Generator number ) { - using DataGenerators::FuelCell; - using DataGenerators::FuelSupply; - FuelCell(Num).Report.ACPowerGen = FuelCell(Num).ACPowerGen; // electrical power produced [W] - FuelCell(Num).Report.ACEnergyGen = FuelCell(Num).ACPowerGen * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; // energy produced (J) - FuelCell(Num).Report.QdotExhaust = 0.0; // reporting: exhaust gas heat recovered (W) - FuelCell(Num).Report.TotalHeatEnergyRec = 0.0; // reporting: total heat recovered (J) - FuelCell(Num).Report.ExhaustEnergyRec = 0.0; // reporting: exhaust gas heat recovered (J) - - FuelCell(Num).Report.HeatRecInletTemp = 0.0; // reporting: Heat Recovery Loop Inlet Temperature (C) - FuelCell(Num).Report.HeatRecOutletTemp = 0.0; // reporting: Heat Recovery Loop Outlet Temperature (C) - FuelCell(Num).Report.HeatRecMdot = 0.0; // reporting: Heat Recovery Loop Mass flow rate (kg/s) - - FuelCell(Num).Report.ElectEfficiency = 0.0; - FuelCell(Num).Report.ThermalEfficiency = 0.0; - FuelCell(Num).Report.OverallEfficiency = 0.0; - FuelCell(Num).Report.ExergyEfficiency = 0.0; - - FuelCell(Num).Report.TairInlet = FuelCell(Num).AirSup.TairIntoBlower; // State point 1 - FuelCell(Num).Report.TairIntoFCPM = FuelCell(Num).AirSup.TairIntoFCPM; // State point 4 - FuelCell(Num).Report.NdotAir = FuelCell(Num).FCPM.NdotAir; // air flow in kmol/sec - FuelCell(Num).Report.TotAirInEnthalphy = FuelCell(Num).FCPM.TotAirInEnthalphy; // State point 4 - FuelCell(Num).Report.BlowerPower = FuelCell(Num).AirSup.PairCompEl; // electrical power used by air supply blower - FuelCell(Num).Report.BlowerEnergy = FuelCell(Num).AirSup.PairCompEl * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; // electrical energy - FuelCell(Num).Report.BlowerSkinLoss = FuelCell(Num).AirSup.QskinLoss; // heat rate of losses by blower - - FuelCell(Num).Report.TfuelInlet = FuelSupply(FuelCell(Num).FuelSupNum).TfuelIntoCompress; // State point 2 - FuelCell(Num).Report.TfuelIntoFCPM = FuelSupply(FuelCell(Num).FuelSupNum).TfuelIntoFCPM; // TEmperature state point 5 [C] - FuelCell(Num).Report.NdotFuel = FuelCell(Num).FCPM.NdotFuel; // fuel flow in kmol/sec - FuelCell(Num).Report.TotFuelInEnthalpy = FuelCell(Num).FCPM.TotFuelInEnthalphy; // enthalpy at state point 5 [W] - FuelCell(Num).Report.FuelCompressPower = FuelSupply(FuelCell(Num).FuelSupNum).PfuelCompEl; + DataGenerators::FuelCell(Num).Report.ACPowerGen = DataGenerators::FuelCell(Num).ACPowerGen; // electrical power produced [W] + DataGenerators::FuelCell(Num).Report.ACEnergyGen = DataGenerators::FuelCell(Num).ACPowerGen * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; // energy produced (J) + DataGenerators::FuelCell(Num).Report.QdotExhaust = 0.0; // reporting: exhaust gas heat recovered (W) + DataGenerators::FuelCell(Num).Report.TotalHeatEnergyRec = 0.0; // reporting: total heat recovered (J) + DataGenerators::FuelCell(Num).Report.ExhaustEnergyRec = 0.0; // reporting: exhaust gas heat recovered (J) + + DataGenerators::FuelCell(Num).Report.HeatRecInletTemp = 0.0; // reporting: Heat Recovery Loop Inlet Temperature (C) + DataGenerators::FuelCell(Num).Report.HeatRecOutletTemp = 0.0; // reporting: Heat Recovery Loop Outlet Temperature (C) + DataGenerators::FuelCell(Num).Report.HeatRecMdot = 0.0; // reporting: Heat Recovery Loop Mass flow rate (kg/s) + + DataGenerators::FuelCell(Num).Report.ElectEfficiency = 0.0; + DataGenerators::FuelCell(Num).Report.ThermalEfficiency = 0.0; + DataGenerators::FuelCell(Num).Report.OverallEfficiency = 0.0; + DataGenerators::FuelCell(Num).Report.ExergyEfficiency = 0.0; + + DataGenerators::FuelCell(Num).Report.TairInlet = DataGenerators::FuelCell(Num).AirSup.TairIntoBlower; // State point 1 + DataGenerators::FuelCell(Num).Report.TairIntoFCPM = DataGenerators::FuelCell(Num).AirSup.TairIntoFCPM; // State point 4 + DataGenerators::FuelCell(Num).Report.NdotAir = DataGenerators::FuelCell(Num).FCPM.NdotAir; // air flow in kmol/sec + DataGenerators::FuelCell(Num).Report.TotAirInEnthalphy = DataGenerators::FuelCell(Num).FCPM.TotAirInEnthalphy; // State point 4 + DataGenerators::FuelCell(Num).Report.BlowerPower = DataGenerators::FuelCell(Num).AirSup.PairCompEl; // electrical power used by air supply blower + DataGenerators::FuelCell(Num).Report.BlowerEnergy = DataGenerators::FuelCell(Num).AirSup.PairCompEl * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; // electrical energy + DataGenerators::FuelCell(Num).Report.BlowerSkinLoss = DataGenerators::FuelCell(Num).AirSup.QskinLoss; // heat rate of losses by blower + + DataGenerators::FuelCell(Num).Report.TfuelInlet = DataGenerators::FuelSupply(DataGenerators::FuelCell(Num).FuelSupNum).TfuelIntoCompress; // State point 2 + DataGenerators::FuelCell(Num).Report.TfuelIntoFCPM = DataGenerators::FuelSupply(DataGenerators::FuelCell(Num).FuelSupNum).TfuelIntoFCPM; // TEmperature state point 5 [C] + DataGenerators::FuelCell(Num).Report.NdotFuel = DataGenerators::FuelCell(Num).FCPM.NdotFuel; // fuel flow in kmol/sec + DataGenerators::FuelCell(Num).Report.TotFuelInEnthalpy = DataGenerators::FuelCell(Num).FCPM.TotFuelInEnthalphy; // enthalpy at state point 5 [W] + DataGenerators::FuelCell(Num).Report.FuelCompressPower = DataGenerators::FuelSupply(DataGenerators::FuelCell(Num).FuelSupNum).PfuelCompEl; // electrical power used by fuel supply compressor [W] - FuelCell(Num).Report.FuelCompressEnergy = FuelSupply(FuelCell(Num).FuelSupNum).PfuelCompEl * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; // elect energy - FuelCell(Num).Report.FuelCompressSkinLoss = FuelSupply(FuelCell(Num).FuelSupNum).QskinLoss; + DataGenerators::FuelCell(Num).Report.FuelCompressEnergy = DataGenerators::FuelSupply(DataGenerators::FuelCell(Num).FuelSupNum).PfuelCompEl * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; // elect energy + DataGenerators::FuelCell(Num).Report.FuelCompressSkinLoss = DataGenerators::FuelSupply(DataGenerators::FuelCell(Num).FuelSupNum).QskinLoss; // heat rate of losses.by fuel supply compressor [W] - FuelCell(Num).Report.FuelEnergyLHV = FuelCell(Num).FCPM.NdotFuel * FuelSupply(FuelCell(Num).FuelSupNum).LHV * 1000000.0 * DataHVACGlobals::TimeStepSys * + DataGenerators::FuelCell(Num).Report.FuelEnergyLHV = DataGenerators::FuelCell(Num).FCPM.NdotFuel * DataGenerators::FuelSupply(DataGenerators::FuelCell(Num).FuelSupNum).LHV * 1000000.0 * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; // reporting: Fuel Energy used (J) - FuelCell(Num).Report.FuelEnergyUseRateLHV = - FuelCell(Num).FCPM.NdotFuel * FuelSupply(FuelCell(Num).FuelSupNum).LHV * 1000000.0; // reporting: Fuel Energy used (W) - FuelCell(Num).Report.FuelEnergyHHV = FuelCell(Num).FCPM.NdotFuel * FuelSupply(FuelCell(Num).FuelSupNum).HHV * - FuelSupply(FuelCell(Num).FuelSupNum).KmolPerSecToKgPerSec * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - - FuelCell(Num).Report.FuelEnergyUseRateHHV = - FuelCell(Num).FCPM.NdotFuel * FuelSupply(FuelCell(Num).FuelSupNum).HHV * FuelSupply(FuelCell(Num).FuelSupNum).KmolPerSecToKgPerSec; - - FuelCell(Num).Report.FuelRateMdot = 0.0; // (Kg/s) - - FuelCell(Num).Report.TwaterInlet = FuelCell(Num).WaterSup.TwaterIntoCompress; - FuelCell(Num).Report.TwaterIntoFCPM = FuelCell(Num).WaterSup.TwaterIntoFCPM; - FuelCell(Num).Report.NdotWater = FuelCell(Num).FCPM.NdotLiqwater; // water flow in kmol/sec (reformer water) - FuelCell(Num).Report.WaterPumpPower = FuelCell(Num).WaterSup.PwaterCompEl; - FuelCell(Num).Report.WaterPumpEnergy = FuelCell(Num).WaterSup.PwaterCompEl * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; // electrical energy - FuelCell(Num).Report.WaterIntoFCPMEnthalpy = FuelCell(Num).FCPM.WaterInEnthalpy; - - FuelCell(Num).Report.TprodGas = FuelCell(Num).FCPM.TprodGasLeavingFCPM; // temperature at State point 7 - FuelCell(Num).Report.EnthalProdGas = FuelCell(Num).FCPM.TotProdGasEnthalphy; // enthalpy at State point 7 - FuelCell(Num).Report.NdotProdGas = FuelCell(Num).FCPM.NdotProdGas; // flow rate at point 7 [kmol/sec] - FuelCell(Num).Report.NdotProdAr = FuelCell(Num).FCPM.ConstitMolalFract(5) * FuelCell(Num).FCPM.NdotProdGas; - FuelCell(Num).Report.NdotProdCO2 = FuelCell(Num).FCPM.ConstitMolalFract(1) * FuelCell(Num).FCPM.NdotProdGas; - FuelCell(Num).Report.NdotProdH2O = FuelCell(Num).FCPM.ConstitMolalFract(4) * FuelCell(Num).FCPM.NdotProdGas; - FuelCell(Num).Report.NdotProdN2 = FuelCell(Num).FCPM.ConstitMolalFract(2) * FuelCell(Num).FCPM.NdotProdGas; - FuelCell(Num).Report.NdotProdO2 = FuelCell(Num).FCPM.ConstitMolalFract(3) * FuelCell(Num).FCPM.NdotProdGas; - - FuelCell(Num).Report.qHX = FuelCell(Num).ExhaustHX.qHX; - FuelCell(Num).Report.HXenergy = FuelCell(Num).ExhaustHX.qHX * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - FuelCell(Num).Report.THXexh = FuelCell(Num).ExhaustHX.THXexh; - FuelCell(Num).Report.WaterVaporFractExh = FuelCell(Num).ExhaustHX.WaterVaporFractExh; - FuelCell(Num).Report.CondensateRate = FuelCell(Num).ExhaustHX.CondensateRate; - - FuelCell(Num).Report.SeqSubstIterations = FuelCell(Num).FCPM.SeqSubstitIter; // number of iterations in FuelCell loop - FuelCell(Num).Report.RegulaFalsiIterations = FuelCell(Num).FCPM.RegulaFalsiIter; // number of iterations in Tproduct gas solving - - FuelCell(Num).Report.ACancillariesPower = FuelCell(Num).FCPM.PelancillariesAC; - FuelCell(Num).Report.ACancillariesEnergy = FuelCell(Num).FCPM.PelancillariesAC * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - - FuelCell(Num).Report.PCUlosses = FuelCell(Num).Inverter.PCUlosses; // inverter losses - FuelCell(Num).Report.DCPowerGen = FuelCell(Num).FCPM.Pel; // DC power out of FCPM. - FuelCell(Num).Report.DCPowerEff = FuelCell(Num).FCPM.Eel; // FCPM efficienty Eel. - FuelCell(Num).Report.ElectEnergyinStorage = FuelCell(Num).ElecStorage.ThisTimeStepStateOfCharge; - FuelCell(Num).Report.StoredPower = FuelCell(Num).ElecStorage.PelIntoStorage; - FuelCell(Num).Report.StoredEnergy = FuelCell(Num).ElecStorage.PelIntoStorage * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - FuelCell(Num).Report.DrawnPower = FuelCell(Num).ElecStorage.PelFromStorage; - FuelCell(Num).Report.DrawnEnergy = FuelCell(Num).ElecStorage.PelFromStorage * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - - FuelCell(Num).Report.SkinLossPower = FuelCell(Num).QconvZone + FuelCell(Num).QradZone; - FuelCell(Num).Report.SkinLossEnergy = (FuelCell(Num).QconvZone + FuelCell(Num).QradZone) * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - FuelCell(Num).Report.SkinLossConvect = FuelCell(Num).QconvZone; - FuelCell(Num).Report.SkinLossRadiat = FuelCell(Num).QradZone; + DataGenerators::FuelCell(Num).Report.FuelEnergyUseRateLHV = + DataGenerators::FuelCell(Num).FCPM.NdotFuel * DataGenerators::FuelSupply(DataGenerators::FuelCell(Num).FuelSupNum).LHV * 1000000.0; // reporting: Fuel Energy used (W) + DataGenerators::FuelCell(Num).Report.FuelEnergyHHV = DataGenerators::FuelCell(Num).FCPM.NdotFuel * DataGenerators::FuelSupply(DataGenerators::FuelCell(Num).FuelSupNum).HHV * + DataGenerators::FuelSupply(DataGenerators::FuelCell(Num).FuelSupNum).KmolPerSecToKgPerSec * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + + DataGenerators::FuelCell(Num).Report.FuelEnergyUseRateHHV = + DataGenerators::FuelCell(Num).FCPM.NdotFuel * DataGenerators::FuelSupply(DataGenerators::FuelCell(Num).FuelSupNum).HHV * DataGenerators::FuelSupply(DataGenerators::FuelCell(Num).FuelSupNum).KmolPerSecToKgPerSec; + + DataGenerators::FuelCell(Num).Report.FuelRateMdot = 0.0; // (Kg/s) + + DataGenerators::FuelCell(Num).Report.TwaterInlet = DataGenerators::FuelCell(Num).WaterSup.TwaterIntoCompress; + DataGenerators::FuelCell(Num).Report.TwaterIntoFCPM = DataGenerators::FuelCell(Num).WaterSup.TwaterIntoFCPM; + DataGenerators::FuelCell(Num).Report.NdotWater = DataGenerators::FuelCell(Num).FCPM.NdotLiqwater; // water flow in kmol/sec (reformer water) + DataGenerators::FuelCell(Num).Report.WaterPumpPower = DataGenerators::FuelCell(Num).WaterSup.PwaterCompEl; + DataGenerators::FuelCell(Num).Report.WaterPumpEnergy = DataGenerators::FuelCell(Num).WaterSup.PwaterCompEl * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; // electrical energy + DataGenerators::FuelCell(Num).Report.WaterIntoFCPMEnthalpy = DataGenerators::FuelCell(Num).FCPM.WaterInEnthalpy; + + DataGenerators::FuelCell(Num).Report.TprodGas = DataGenerators::FuelCell(Num).FCPM.TprodGasLeavingFCPM; // temperature at State point 7 + DataGenerators::FuelCell(Num).Report.EnthalProdGas = DataGenerators::FuelCell(Num).FCPM.TotProdGasEnthalphy; // enthalpy at State point 7 + DataGenerators::FuelCell(Num).Report.NdotProdGas = DataGenerators::FuelCell(Num).FCPM.NdotProdGas; // flow rate at point 7 [kmol/sec] + DataGenerators::FuelCell(Num).Report.NdotProdAr = DataGenerators::FuelCell(Num).FCPM.ConstitMolalFract(5) * DataGenerators::FuelCell(Num).FCPM.NdotProdGas; + DataGenerators::FuelCell(Num).Report.NdotProdCO2 = DataGenerators::FuelCell(Num).FCPM.ConstitMolalFract(1) * DataGenerators::FuelCell(Num).FCPM.NdotProdGas; + DataGenerators::FuelCell(Num).Report.NdotProdH2O = DataGenerators::FuelCell(Num).FCPM.ConstitMolalFract(4) * DataGenerators::FuelCell(Num).FCPM.NdotProdGas; + DataGenerators::FuelCell(Num).Report.NdotProdN2 = DataGenerators::FuelCell(Num).FCPM.ConstitMolalFract(2) * DataGenerators::FuelCell(Num).FCPM.NdotProdGas; + DataGenerators::FuelCell(Num).Report.NdotProdO2 = DataGenerators::FuelCell(Num).FCPM.ConstitMolalFract(3) * DataGenerators::FuelCell(Num).FCPM.NdotProdGas; + + DataGenerators::FuelCell(Num).Report.qHX = DataGenerators::FuelCell(Num).ExhaustHX.qHX; + DataGenerators::FuelCell(Num).Report.HXenergy = DataGenerators::FuelCell(Num).ExhaustHX.qHX * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + DataGenerators::FuelCell(Num).Report.THXexh = DataGenerators::FuelCell(Num).ExhaustHX.THXexh; + DataGenerators::FuelCell(Num).Report.WaterVaporFractExh = DataGenerators::FuelCell(Num).ExhaustHX.WaterVaporFractExh; + DataGenerators::FuelCell(Num).Report.CondensateRate = DataGenerators::FuelCell(Num).ExhaustHX.CondensateRate; + + DataGenerators::FuelCell(Num).Report.SeqSubstIterations = DataGenerators::FuelCell(Num).FCPM.SeqSubstitIter; // number of iterations in DataGenerators::FuelCell loop + DataGenerators::FuelCell(Num).Report.RegulaFalsiIterations = DataGenerators::FuelCell(Num).FCPM.RegulaFalsiIter; // number of iterations in Tproduct gas solving + + DataGenerators::FuelCell(Num).Report.ACancillariesPower = DataGenerators::FuelCell(Num).FCPM.PelancillariesAC; + DataGenerators::FuelCell(Num).Report.ACancillariesEnergy = DataGenerators::FuelCell(Num).FCPM.PelancillariesAC * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + + DataGenerators::FuelCell(Num).Report.PCUlosses = DataGenerators::FuelCell(Num).Inverter.PCUlosses; // inverter losses + DataGenerators::FuelCell(Num).Report.DCPowerGen = DataGenerators::FuelCell(Num).FCPM.Pel; // DC power out of FCPM. + DataGenerators::FuelCell(Num).Report.DCPowerEff = DataGenerators::FuelCell(Num).FCPM.Eel; // FCPM efficienty Eel. + DataGenerators::FuelCell(Num).Report.ElectEnergyinStorage = DataGenerators::FuelCell(Num).ElecStorage.ThisTimeStepStateOfCharge; + DataGenerators::FuelCell(Num).Report.StoredPower = DataGenerators::FuelCell(Num).ElecStorage.PelIntoStorage; + DataGenerators::FuelCell(Num).Report.StoredEnergy = DataGenerators::FuelCell(Num).ElecStorage.PelIntoStorage * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + DataGenerators::FuelCell(Num).Report.DrawnPower = DataGenerators::FuelCell(Num).ElecStorage.PelFromStorage; + DataGenerators::FuelCell(Num).Report.DrawnEnergy = DataGenerators::FuelCell(Num).ElecStorage.PelFromStorage * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + + DataGenerators::FuelCell(Num).Report.SkinLossPower = DataGenerators::FuelCell(Num).QconvZone + DataGenerators::FuelCell(Num).QradZone; + DataGenerators::FuelCell(Num).Report.SkinLossEnergy = (DataGenerators::FuelCell(Num).QconvZone + DataGenerators::FuelCell(Num).QradZone) * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + DataGenerators::FuelCell(Num).Report.SkinLossConvect = DataGenerators::FuelCell(Num).QconvZone; + DataGenerators::FuelCell(Num).Report.SkinLossRadiat = DataGenerators::FuelCell(Num).QradZone; } void GetFuelCellGeneratorResults(int const EP_UNUSED(GeneratorType), // type of Generator @@ -3987,12 +3968,10 @@ namespace FuelCellElectricGenerator { // PURPOSE OF THIS SUBROUTINE: // provide a get method to collect results at the load center level - using DataGenerators::FuelCell; - - GeneratorPower = FuelCell(GeneratorIndex).Report.ACPowerGen; - GeneratorEnergy = FuelCell(GeneratorIndex).Report.ACEnergyGen; - ThermalPower = FuelCell(GeneratorIndex).Report.qHX; - ThermalEnergy = FuelCell(GeneratorIndex).Report.HXenergy; + GeneratorPower = DataGenerators::FuelCell(GeneratorIndex).Report.ACPowerGen; + GeneratorEnergy = DataGenerators::FuelCell(GeneratorIndex).Report.ACEnergyGen; + ThermalPower = DataGenerators::FuelCell(GeneratorIndex).Report.qHX; + ThermalEnergy = DataGenerators::FuelCell(GeneratorIndex).Report.HXenergy; } } // namespace FuelCellElectricGenerator From 319d54afdb8d01fd3426dc434491095338f79d5b Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Mon, 11 Nov 2019 14:48:49 -0700 Subject: [PATCH 19/51] partial cleanup usings --- src/EnergyPlus/FuelCellElectricGenerator.cc | 1382 ++++++++----------- 1 file changed, 587 insertions(+), 795 deletions(-) diff --git a/src/EnergyPlus/FuelCellElectricGenerator.cc b/src/EnergyPlus/FuelCellElectricGenerator.cc index b574afc3cfc..66d4ba09712 100644 --- a/src/EnergyPlus/FuelCellElectricGenerator.cc +++ b/src/EnergyPlus/FuelCellElectricGenerator.cc @@ -118,9 +118,6 @@ namespace FuelCellElectricGenerator { // gets the input for the models, initializes simulation variables, call // the appropriate model and sets up reporting variables. - using DataGenerators::FuelCell; - using DataGenerators::NumFuelCellGenerators; - int GenNum; // Generator number counter // Get Generator data from input file @@ -130,19 +127,19 @@ namespace FuelCellElectricGenerator { } if (GeneratorIndex == 0) { - GenNum = UtilityRoutines::FindItemInList(GeneratorName, FuelCell); + GenNum = UtilityRoutines::FindItemInList(GeneratorName, DataGenerators::FuelCell); if (GenNum == 0) ShowFatalError("SimFuelCellGenerator: Specified Generator not one of Valid FuelCell Generators " + GeneratorName); GeneratorIndex = GenNum; } else { GenNum = GeneratorIndex; - if (GenNum > NumFuelCellGenerators || GenNum < 1) { + if (GenNum > DataGenerators::NumFuelCellGenerators || GenNum < 1) { ShowFatalError("SimFuelCellGenerator: Invalid GeneratorIndex passed=" + General::TrimSigDigits(GenNum) + - ", Number of FuelCell Generators=" + General::TrimSigDigits(NumFuelCellGenerators) + ", Generator name=" + GeneratorName); + ", Number of FuelCell Generators=" + General::TrimSigDigits(DataGenerators::NumFuelCellGenerators) + ", Generator name=" + GeneratorName); } if (CheckEquipName(GenNum)) { - if (GeneratorName != FuelCell(GenNum).Name) { + if (GeneratorName != DataGenerators::FuelCell(GenNum).Name) { ShowFatalError("SimFuelCellGenerator: Invalid GeneratorIndex passed=" + General::TrimSigDigits(GenNum) + - ", Generator name=" + GeneratorName + ", stored Generator Name for that index=" + FuelCell(GenNum).Name); + ", Generator name=" + GeneratorName + ", stored Generator Name for that index=" + DataGenerators::FuelCell(GenNum).Name); } CheckEquipName(GenNum) = false; } @@ -170,40 +167,6 @@ namespace FuelCellElectricGenerator { // METHODOLOGY EMPLOYED: // EnergyPlus input processor - using DataGenerators::FuelCell; - using DataGenerators::NumFuelCellGenerators; - using DataGenerators::FCDataStruct; - using DataGenerators::DirectCurveMode; - using DataGenerators::NormalizedCurveMode; - using DataGenerators::ConstantRateSkinLoss; - using DataGenerators::UADTSkinLoss; - using DataGenerators::QuadraticFuelNdotSkin; - using DataGenerators::NumGeneratorFuelSups; - using DataGenerators::FuelSupply; - using DataGenerators::ConstantStoicsAirRat; - using DataGenerators::QuadraticFuncofPel; - using DataGenerators::QuadraticFuncofNdot; - using DataGenerators::RecoverBurnInvertBatt; - using DataGenerators::RecoverAuxiliaryBurner; - using DataGenerators::RecoverInverterBatt; - using DataGenerators::RecoverInverter; - using DataGenerators::RecoverBattery; - using DataGenerators::NoRecoveryOnAirIntake; - using DataGenerators::RegularAir; - using DataGenerators::UserDefinedConstituents; - using DataGenerators::GasPropertyDataStruct; - using DataGenerators::WaterInReformAirNode; - using DataGenerators::WaterInReformWaterNode; - using DataGenerators::WaterInReformMains; - using DataGenerators::WaterInReformSchedule; - using DataGenerators::SurroundingZone; - using DataGenerators::AirInletForFC; - using DataGenerators::FixedEffectiveness; - using DataGenerators::LMTDempiricalUAeff; - using DataGenerators::LMTDfundementalUAeff; - using DataGenerators::Condensing; - using DataGenerators::SimpleEffConstraints; - int GeneratorNum; // Generator counter int NumAlphas; // Number of elements in the alpha array int NumNums; // Number of elements in the numeric array @@ -223,10 +186,10 @@ namespace FuelCellElectricGenerator { int NumAirConstit; // number of gas constituents in air int FCPMNum; // loop counter over power subsystems int FCAirSupNum; // loop counter over air supply subsystems - int ConstitNum; // loop counter for consituents + int ConstitNum; // loop counter for constituents int FCWaterSupNum; // loop counter over water supply subsystems int FCHXNum; // loop counter for heat exchangers - int FCAuxHeatNum; // loop counter over auxiliar heater + int FCAuxHeatNum; // loop counter over auxiliary heater int FCPCUNum; // loop counter over inverters int StorageNum; // loop counter over electrical storage subsystems int FCScoolNum; // loop counter over stack coolers @@ -246,34 +209,34 @@ namespace FuelCellElectricGenerator { if (MyOneTimeFlag) { DataIPShortCuts::cCurrentModuleObject = "Generator:FuelCell"; - NumFuelCellGenerators = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); + DataGenerators::NumFuelCellGenerators = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); - if (NumFuelCellGenerators <= 0) { + if (DataGenerators::NumFuelCellGenerators <= 0) { ShowSevereError("No " + DataIPShortCuts::cCurrentModuleObject + " equipment specified in input file"); ErrorsFound = true; } // ALLOCATE ARRAYS - FuelCell.allocate(NumFuelCellGenerators); // inits handeled in derived type definitions - CheckEquipName.dimension(NumFuelCellGenerators, true); + DataGenerators::FuelCell.allocate(DataGenerators::NumFuelCellGenerators); // inits handeled in derived type definitions + CheckEquipName.dimension(DataGenerators::NumFuelCellGenerators, true); // first load in FuelCell names - for (GeneratorNum = 1; GeneratorNum <= NumFuelCellGenerators; ++GeneratorNum) { + for (GeneratorNum = 1; GeneratorNum <= DataGenerators::NumFuelCellGenerators; ++GeneratorNum) { inputProcessor->getObjectItem( DataIPShortCuts::cCurrentModuleObject, GeneratorNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat, _, _, DataIPShortCuts::cAlphaFieldNames, DataIPShortCuts::cNumericFieldNames); UtilityRoutines::IsNameEmpty(AlphArray(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); - FuelCell(GeneratorNum).Name = AlphArray(1); - FuelCell(GeneratorNum).NameFCPM = AlphArray(2); - FuelCell(GeneratorNum).NameFCAirSup = AlphArray(3); - FuelCell(GeneratorNum).NameFCFuelSup = AlphArray(4); - FuelCell(GeneratorNum).NameFCWaterSup = AlphArray(5); - FuelCell(GeneratorNum).NameFCAuxilHeat = AlphArray(6); - FuelCell(GeneratorNum).NameExhaustHX = AlphArray(7); - FuelCell(GeneratorNum).NameElecStorage = AlphArray(8); - FuelCell(GeneratorNum).NameInverter = AlphArray(9); + DataGenerators::FuelCell(GeneratorNum).Name = AlphArray(1); + DataGenerators::FuelCell(GeneratorNum).NameFCPM = AlphArray(2); + DataGenerators::FuelCell(GeneratorNum).NameFCAirSup = AlphArray(3); + DataGenerators::FuelCell(GeneratorNum).NameFCFuelSup = AlphArray(4); + DataGenerators::FuelCell(GeneratorNum).NameFCWaterSup = AlphArray(5); + DataGenerators::FuelCell(GeneratorNum).NameFCAuxilHeat = AlphArray(6); + DataGenerators::FuelCell(GeneratorNum).NameExhaustHX = AlphArray(7); + DataGenerators::FuelCell(GeneratorNum).NameElecStorage = AlphArray(8); + DataGenerators::FuelCell(GeneratorNum).NameInverter = AlphArray(9); if (NumAlphas == 10) { - FuelCell(GeneratorNum).NameStackCooler = AlphArray(10); + DataGenerators::FuelCell(GeneratorNum).NameStackCooler = AlphArray(10); } } @@ -299,91 +262,91 @@ namespace FuelCellElectricGenerator { DataIPShortCuts::cNumericFieldNames); UtilityRoutines::IsNameEmpty(AlphArray(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); - thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), FuelCell, &FCDataStruct::NameFCPM); + thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), DataGenerators::FuelCell, &DataGenerators::FCDataStruct::NameFCPM); if (thisFuelCell > 0) { // cr9323 - FuelCell(thisFuelCell).FCPM.Name = AlphArray(1); - if (UtilityRoutines::SameString(AlphArray(2), "ANNEX42")) FuelCell(thisFuelCell).FCPM.EffMode = DirectCurveMode; - if (UtilityRoutines::SameString(AlphArray(2), "NORMALIZED")) FuelCell(thisFuelCell).FCPM.EffMode = NormalizedCurveMode; - if (FuelCell(thisFuelCell).FCPM.EffMode == 0) { + DataGenerators::FuelCell(thisFuelCell).FCPM.Name = AlphArray(1); + if (UtilityRoutines::SameString(AlphArray(2), "ANNEX42")) DataGenerators::FuelCell(thisFuelCell).FCPM.EffMode = DataGenerators::DirectCurveMode; + if (UtilityRoutines::SameString(AlphArray(2), "NORMALIZED")) DataGenerators::FuelCell(thisFuelCell).FCPM.EffMode = DataGenerators::NormalizedCurveMode; + if (DataGenerators::FuelCell(thisFuelCell).FCPM.EffMode == 0) { ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(2) + " = " + AlphArray(2)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } - FuelCell(thisFuelCell).FCPM.EffCurveID = CurveManager::GetCurveIndex(AlphArray(3)); - if (FuelCell(thisFuelCell).FCPM.EffCurveID == 0) { + DataGenerators::FuelCell(thisFuelCell).FCPM.EffCurveID = CurveManager::GetCurveIndex(AlphArray(3)); + if (DataGenerators::FuelCell(thisFuelCell).FCPM.EffCurveID == 0) { ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(3) + " = " + AlphArray(3)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } - FuelCell(thisFuelCell).FCPM.NomEff = NumArray(1); - FuelCell(thisFuelCell).FCPM.NomPel = NumArray(2); - FuelCell(thisFuelCell).FCPM.NumCycles = NumArray(3); - FuelCell(thisFuelCell).FCPM.CyclingDegradRat = NumArray(4); - FuelCell(thisFuelCell).FCPM.NumRunHours = NumArray(5); - FuelCell(thisFuelCell).FCPM.OperateDegradRat = NumArray(6); - FuelCell(thisFuelCell).FCPM.ThreshRunHours = NumArray(7); - FuelCell(thisFuelCell).FCPM.UpTranLimit = NumArray(8); - FuelCell(thisFuelCell).FCPM.DownTranLimit = NumArray(9); - FuelCell(thisFuelCell).FCPM.StartUpTime = NumArray(10) / DataGlobals::SecInHour; // convert to hours from seconds - FuelCell(thisFuelCell).FCPM.StartUpFuel = NumArray(11); - FuelCell(thisFuelCell).FCPM.StartUpElectConsum = NumArray(12); - FuelCell(thisFuelCell).FCPM.StartUpElectProd = NumArray(13); - FuelCell(thisFuelCell).FCPM.ShutDownTime = NumArray(14) / DataGlobals::SecInHour; // convert to hours from seconds - FuelCell(thisFuelCell).FCPM.ShutDownFuel = NumArray(15); - FuelCell(thisFuelCell).FCPM.ShutDownElectConsum = NumArray(16); - FuelCell(thisFuelCell).FCPM.ANC0 = NumArray(17); - FuelCell(thisFuelCell).FCPM.ANC1 = NumArray(18); - if (UtilityRoutines::SameString(AlphArray(4), "ConstantRate")) FuelCell(thisFuelCell).FCPM.SkinLossMode = ConstantRateSkinLoss; + DataGenerators::FuelCell(thisFuelCell).FCPM.NomEff = NumArray(1); + DataGenerators::FuelCell(thisFuelCell).FCPM.NomPel = NumArray(2); + DataGenerators::FuelCell(thisFuelCell).FCPM.NumCycles = NumArray(3); + DataGenerators::FuelCell(thisFuelCell).FCPM.CyclingDegradRat = NumArray(4); + DataGenerators::FuelCell(thisFuelCell).FCPM.NumRunHours = NumArray(5); + DataGenerators::FuelCell(thisFuelCell).FCPM.OperateDegradRat = NumArray(6); + DataGenerators::FuelCell(thisFuelCell).FCPM.ThreshRunHours = NumArray(7); + DataGenerators::FuelCell(thisFuelCell).FCPM.UpTranLimit = NumArray(8); + DataGenerators::FuelCell(thisFuelCell).FCPM.DownTranLimit = NumArray(9); + DataGenerators::FuelCell(thisFuelCell).FCPM.StartUpTime = NumArray(10) / DataGlobals::SecInHour; // convert to hours from seconds + DataGenerators::FuelCell(thisFuelCell).FCPM.StartUpFuel = NumArray(11); + DataGenerators::FuelCell(thisFuelCell).FCPM.StartUpElectConsum = NumArray(12); + DataGenerators::FuelCell(thisFuelCell).FCPM.StartUpElectProd = NumArray(13); + DataGenerators::FuelCell(thisFuelCell).FCPM.ShutDownTime = NumArray(14) / DataGlobals::SecInHour; // convert to hours from seconds + DataGenerators::FuelCell(thisFuelCell).FCPM.ShutDownFuel = NumArray(15); + DataGenerators::FuelCell(thisFuelCell).FCPM.ShutDownElectConsum = NumArray(16); + DataGenerators::FuelCell(thisFuelCell).FCPM.ANC0 = NumArray(17); + DataGenerators::FuelCell(thisFuelCell).FCPM.ANC1 = NumArray(18); + if (UtilityRoutines::SameString(AlphArray(4), "ConstantRate")) DataGenerators::FuelCell(thisFuelCell).FCPM.SkinLossMode = DataGenerators::ConstantRateSkinLoss; if (UtilityRoutines::SameString(AlphArray(4), "UAForProcessGasTemperature")) - FuelCell(thisFuelCell).FCPM.SkinLossMode = UADTSkinLoss; + DataGenerators::FuelCell(thisFuelCell).FCPM.SkinLossMode = DataGenerators::UADTSkinLoss; if (UtilityRoutines::SameString(AlphArray(4), "QUADRATIC FUNCTION OF FUEL RATE")) - FuelCell(thisFuelCell).FCPM.SkinLossMode = QuadraticFuelNdotSkin; - if (FuelCell(thisFuelCell).FCPM.SkinLossMode == 0) { + DataGenerators::FuelCell(thisFuelCell).FCPM.SkinLossMode = DataGenerators::QuadraticFuelNdotSkin; + if (DataGenerators::FuelCell(thisFuelCell).FCPM.SkinLossMode == 0) { // throw error ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(4) + " = " + AlphArray(4)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } - FuelCell(thisFuelCell).FCPM.ZoneName = AlphArray(5); - FuelCell(thisFuelCell).FCPM.ZoneID = UtilityRoutines::FindItemInList(FuelCell(thisFuelCell).FCPM.ZoneName, DataHeatBalance::Zone); - if (FuelCell(thisFuelCell).FCPM.ZoneID == 0 && !lAlphaBlanks(5)) { + DataGenerators::FuelCell(thisFuelCell).FCPM.ZoneName = AlphArray(5); + DataGenerators::FuelCell(thisFuelCell).FCPM.ZoneID = UtilityRoutines::FindItemInList(DataGenerators::FuelCell(thisFuelCell).FCPM.ZoneName, DataHeatBalance::Zone); + if (DataGenerators::FuelCell(thisFuelCell).FCPM.ZoneID == 0 && !lAlphaBlanks(5)) { ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(5) + " = " + AlphArray(5)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ShowContinueError("Zone Name was not found "); ErrorsFound = true; } - FuelCell(thisFuelCell).FCPM.RadiativeFract = NumArray(19); - FuelCell(thisFuelCell).FCPM.QdotSkin = NumArray(20); - FuelCell(thisFuelCell).FCPM.UAskin = NumArray(21); + DataGenerators::FuelCell(thisFuelCell).FCPM.RadiativeFract = NumArray(19); + DataGenerators::FuelCell(thisFuelCell).FCPM.QdotSkin = NumArray(20); + DataGenerators::FuelCell(thisFuelCell).FCPM.UAskin = NumArray(21); - FuelCell(thisFuelCell).FCPM.SkinLossCurveID = CurveManager::GetCurveIndex(AlphArray(6)); - if (FuelCell(thisFuelCell).FCPM.SkinLossCurveID == 0) { - if (FuelCell(thisFuelCell).FCPM.SkinLossMode == QuadraticFuelNdotSkin) { + DataGenerators::FuelCell(thisFuelCell).FCPM.SkinLossCurveID = CurveManager::GetCurveIndex(AlphArray(6)); + if (DataGenerators::FuelCell(thisFuelCell).FCPM.SkinLossCurveID == 0) { + if (DataGenerators::FuelCell(thisFuelCell).FCPM.SkinLossMode == DataGenerators::QuadraticFuelNdotSkin) { ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(6) + " = " + AlphArray(6)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } } - FuelCell(thisFuelCell).FCPM.NdotDilutionAir = NumArray(22); - FuelCell(thisFuelCell).FCPM.StackHeatLossToDilution = NumArray(23); - FuelCell(thisFuelCell).FCPM.DilutionInletNodeName = AlphArray(7); - FuelCell(thisFuelCell).FCPM.DilutionInletNode = NodeInputManager::GetOnlySingleNode( + DataGenerators::FuelCell(thisFuelCell).FCPM.NdotDilutionAir = NumArray(22); + DataGenerators::FuelCell(thisFuelCell).FCPM.StackHeatLossToDilution = NumArray(23); + DataGenerators::FuelCell(thisFuelCell).FCPM.DilutionInletNodeName = AlphArray(7); + DataGenerators::FuelCell(thisFuelCell).FCPM.DilutionInletNode = NodeInputManager::GetOnlySingleNode( AlphArray(7), ErrorsFound, DataIPShortCuts::cCurrentModuleObject, AlphArray(1), DataLoopNode::NodeType_Air, DataLoopNode::NodeConnectionType_Inlet, 1, DataLoopNode::ObjectIsNotParent); - FuelCell(thisFuelCell).FCPM.DilutionExhaustNodeName = AlphArray(8); - FuelCell(thisFuelCell).FCPM.DilutionExhaustNode = NodeInputManager::GetOnlySingleNode( + DataGenerators::FuelCell(thisFuelCell).FCPM.DilutionExhaustNodeName = AlphArray(8); + DataGenerators::FuelCell(thisFuelCell).FCPM.DilutionExhaustNode = NodeInputManager::GetOnlySingleNode( AlphArray(8), ErrorsFound, DataIPShortCuts::cCurrentModuleObject, AlphArray(1), DataLoopNode::NodeType_Air, DataLoopNode::NodeConnectionType_Outlet, 1, DataLoopNode::ObjectIsNotParent); - FuelCell(thisFuelCell).FCPM.PelMin = NumArray(24); - FuelCell(thisFuelCell).FCPM.PelMax = NumArray(25); + DataGenerators::FuelCell(thisFuelCell).FCPM.PelMin = NumArray(24); + DataGenerators::FuelCell(thisFuelCell).FCPM.PelMax = NumArray(25); // check for other FuelCell using the same power module and fill - for (otherFuelCell = thisFuelCell + 1; otherFuelCell <= NumFuelCellGenerators; ++otherFuelCell) { - if (UtilityRoutines::SameString(FuelCell(otherFuelCell).FCPM.Name, FuelCell(thisFuelCell).FCPM.Name)) { - FuelCell(otherFuelCell).FCPM = FuelCell(thisFuelCell).FCPM; + for (otherFuelCell = thisFuelCell + 1; otherFuelCell <= DataGenerators::NumFuelCellGenerators; ++otherFuelCell) { + if (UtilityRoutines::SameString(DataGenerators::FuelCell(otherFuelCell).FCPM.Name, DataGenerators::FuelCell(thisFuelCell).FCPM.Name)) { + DataGenerators::FuelCell(otherFuelCell).FCPM = DataGenerators::FuelCell(thisFuelCell).FCPM; } } } else { // throw warning, did not find power module input @@ -395,16 +358,16 @@ namespace FuelCellElectricGenerator { GeneratorFuelSupply::GetGeneratorFuelSupplyInput(); - for (FuelSupNum = 1; FuelSupNum <= NumGeneratorFuelSups; ++FuelSupNum) { + for (FuelSupNum = 1; FuelSupNum <= DataGenerators::NumGeneratorFuelSups; ++FuelSupNum) { GeneratorFuelSupply::SetupFuelConstituentData(FuelSupNum, ErrorsFound); } // set fuel supply ID in Fuel cell structure - for (GeneratorNum = 1; GeneratorNum <= NumFuelCellGenerators; ++GeneratorNum) { - FuelCell(GeneratorNum).FuelSupNum = - UtilityRoutines::FindItemInList(FuelCell(GeneratorNum).NameFCFuelSup, FuelSupply); // Fuel Supply ID - if (FuelCell(GeneratorNum).FuelSupNum == 0) { - ShowSevereError("Fuel Supply Name: " + FuelCell(GeneratorNum).NameFCFuelSup + " not found in " + FuelCell(GeneratorNum).Name); + for (GeneratorNum = 1; GeneratorNum <= DataGenerators::NumFuelCellGenerators; ++GeneratorNum) { + DataGenerators::FuelCell(GeneratorNum).FuelSupNum = + UtilityRoutines::FindItemInList(DataGenerators::FuelCell(GeneratorNum).NameFCFuelSup, DataGenerators::FuelSupply); // Fuel Supply ID + if (DataGenerators::FuelCell(GeneratorNum).FuelSupNum == 0) { + ShowSevereError("Fuel Supply Name: " + DataGenerators::FuelCell(GeneratorNum).NameFCFuelSup + " not found in " + DataGenerators::FuelCell(GeneratorNum).Name); ErrorsFound = true; } } @@ -422,53 +385,53 @@ namespace FuelCellElectricGenerator { DataIPShortCuts::cCurrentModuleObject, FCAirSupNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat, _, _, DataIPShortCuts::cAlphaFieldNames, DataIPShortCuts::cNumericFieldNames); UtilityRoutines::IsNameEmpty(AlphArray(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); - thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), FuelCell, &FCDataStruct::NameFCAirSup); + thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), DataGenerators::FuelCell, &DataGenerators::FCDataStruct::NameFCAirSup); if (thisFuelCell > 0) { - FuelCell(thisFuelCell).AirSup.Name = AlphArray(1); - FuelCell(thisFuelCell).AirSup.NodeName = AlphArray(2); + DataGenerators::FuelCell(thisFuelCell).AirSup.Name = AlphArray(1); + DataGenerators::FuelCell(thisFuelCell).AirSup.NodeName = AlphArray(2); // check the node connections - FuelCell(thisFuelCell).AirSup.SupNodeNum = NodeInputManager::GetOnlySingleNode( + DataGenerators::FuelCell(thisFuelCell).AirSup.SupNodeNum = NodeInputManager::GetOnlySingleNode( AlphArray(2), ErrorsFound, DataIPShortCuts::cCurrentModuleObject, AlphArray(1), DataLoopNode::NodeType_Air, DataLoopNode::NodeConnectionType_Inlet, 1, DataLoopNode::ObjectIsNotParent); - FuelCell(thisFuelCell).AirSup.BlowerPowerCurveID = CurveManager::GetCurveIndex(AlphArray(3)); - if (FuelCell(thisFuelCell).AirSup.BlowerPowerCurveID == 0) { + DataGenerators::FuelCell(thisFuelCell).AirSup.BlowerPowerCurveID = CurveManager::GetCurveIndex(AlphArray(3)); + if (DataGenerators::FuelCell(thisFuelCell).AirSup.BlowerPowerCurveID == 0) { ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(3) + " = " + AlphArray(3)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ShowContinueError("Curve name was not found "); ErrorsFound = true; } - FuelCell(thisFuelCell).AirSup.BlowerHeatLossFactor = NumArray(1); + DataGenerators::FuelCell(thisFuelCell).AirSup.BlowerHeatLossFactor = NumArray(1); if (UtilityRoutines::SameString(AlphArray(4), "AirRatiobyStoics")) { - FuelCell(thisFuelCell).AirSup.AirSupRateMode = ConstantStoicsAirRat; + DataGenerators::FuelCell(thisFuelCell).AirSup.AirSupRateMode = DataGenerators::ConstantStoicsAirRat; } else if (UtilityRoutines::SameString(AlphArray(4), "QuadraticFunctionofElectricPower")) { - FuelCell(thisFuelCell).AirSup.AirSupRateMode = QuadraticFuncofPel; + DataGenerators::FuelCell(thisFuelCell).AirSup.AirSupRateMode = DataGenerators::QuadraticFuncofPel; } else if (UtilityRoutines::SameString(AlphArray(4), "QUADRATIC FUNCTION OF FUEL RATE")) { - FuelCell(thisFuelCell).AirSup.AirSupRateMode = QuadraticFuncofNdot; + DataGenerators::FuelCell(thisFuelCell).AirSup.AirSupRateMode = DataGenerators::QuadraticFuncofNdot; } else { ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(4) + " = " + AlphArray(4)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } - FuelCell(thisFuelCell).AirSup.Stoics = NumArray(2) + 1.0; + DataGenerators::FuelCell(thisFuelCell).AirSup.Stoics = NumArray(2) + 1.0; - FuelCell(thisFuelCell).AirSup.AirFuncPelCurveID = CurveManager::GetCurveIndex(AlphArray(5)); - if ((FuelCell(thisFuelCell).AirSup.AirFuncPelCurveID == 0) && - (FuelCell(thisFuelCell).AirSup.AirSupRateMode == QuadraticFuncofPel)) { + DataGenerators::FuelCell(thisFuelCell).AirSup.AirFuncPelCurveID = CurveManager::GetCurveIndex(AlphArray(5)); + if ((DataGenerators::FuelCell(thisFuelCell).AirSup.AirFuncPelCurveID == 0) && + (DataGenerators::FuelCell(thisFuelCell).AirSup.AirSupRateMode == DataGenerators::QuadraticFuncofPel)) { ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(5) + " = " + AlphArray(5)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ShowSevereError("Curve name was not found"); ErrorsFound = true; } - FuelCell(thisFuelCell).AirSup.AirTempCoeff = NumArray(3); + DataGenerators::FuelCell(thisFuelCell).AirSup.AirTempCoeff = NumArray(3); - FuelCell(thisFuelCell).AirSup.AirFuncNdotCurveID = CurveManager::GetCurveIndex(AlphArray(6)); - if ((FuelCell(thisFuelCell).AirSup.AirFuncNdotCurveID == 0) && - (FuelCell(thisFuelCell).AirSup.AirSupRateMode == QuadraticFuncofNdot)) { + DataGenerators::FuelCell(thisFuelCell).AirSup.AirFuncNdotCurveID = CurveManager::GetCurveIndex(AlphArray(6)); + if ((DataGenerators::FuelCell(thisFuelCell).AirSup.AirFuncNdotCurveID == 0) && + (DataGenerators::FuelCell(thisFuelCell).AirSup.AirSupRateMode == DataGenerators::QuadraticFuncofNdot)) { ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(6) + " = " + AlphArray(6)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ShowSevereError("Curve name was not found"); @@ -476,17 +439,17 @@ namespace FuelCellElectricGenerator { } if (UtilityRoutines::SameString("RecoverBurnerInverterStorage", AlphArray(7))) { - FuelCell(thisFuelCell).AirSup.IntakeRecoveryMode = RecoverBurnInvertBatt; + DataGenerators::FuelCell(thisFuelCell).AirSup.IntakeRecoveryMode = DataGenerators::RecoverBurnInvertBatt; } else if (UtilityRoutines::SameString("RecoverAuxiliaryBurner", AlphArray(7))) { - FuelCell(thisFuelCell).AirSup.IntakeRecoveryMode = RecoverAuxiliaryBurner; + DataGenerators::FuelCell(thisFuelCell).AirSup.IntakeRecoveryMode = DataGenerators::RecoverAuxiliaryBurner; } else if (UtilityRoutines::SameString("RecoverInverterandStorage", AlphArray(7))) { - FuelCell(thisFuelCell).AirSup.IntakeRecoveryMode = RecoverInverterBatt; + DataGenerators::FuelCell(thisFuelCell).AirSup.IntakeRecoveryMode = DataGenerators::RecoverInverterBatt; } else if (UtilityRoutines::SameString("RecoverInverter", AlphArray(7))) { - FuelCell(thisFuelCell).AirSup.IntakeRecoveryMode = RecoverInverter; + DataGenerators::FuelCell(thisFuelCell).AirSup.IntakeRecoveryMode = DataGenerators::RecoverInverter; } else if (UtilityRoutines::SameString("RecoverElectricalStorage", AlphArray(7))) { - FuelCell(thisFuelCell).AirSup.IntakeRecoveryMode = RecoverBattery; + DataGenerators::FuelCell(thisFuelCell).AirSup.IntakeRecoveryMode = DataGenerators::RecoverBattery; } else if (UtilityRoutines::SameString("NoRecovery", AlphArray(7))) { - FuelCell(thisFuelCell).AirSup.IntakeRecoveryMode = NoRecoveryOnAirIntake; + DataGenerators::FuelCell(thisFuelCell).AirSup.IntakeRecoveryMode = DataGenerators::NoRecoveryOnAirIntake; } else { ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(7) + " = " + AlphArray(7)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); @@ -494,18 +457,18 @@ namespace FuelCellElectricGenerator { } if (UtilityRoutines::SameString("AmbientAir", AlphArray(8))) { - FuelCell(thisFuelCell).AirSup.ConstituentMode = RegularAir; + DataGenerators::FuelCell(thisFuelCell).AirSup.ConstituentMode = DataGenerators::RegularAir; } else if (UtilityRoutines::SameString("UserDefinedConstituents", AlphArray(8))) { - FuelCell(thisFuelCell).AirSup.ConstituentMode = UserDefinedConstituents; + DataGenerators::FuelCell(thisFuelCell).AirSup.ConstituentMode = DataGenerators::UserDefinedConstituents; } else { ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(8) + " = " + AlphArray(8)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } - if (FuelCell(thisFuelCell).AirSup.ConstituentMode == UserDefinedConstituents) { + if (DataGenerators::FuelCell(thisFuelCell).AirSup.ConstituentMode == DataGenerators::UserDefinedConstituents) { NumAirConstit = NumArray(4); - FuelCell(thisFuelCell).AirSup.NumConstituents = NumAirConstit; + DataGenerators::FuelCell(thisFuelCell).AirSup.NumConstituents = NumAirConstit; if (NumAirConstit > 5) { ShowSevereError("Invalid " + DataIPShortCuts::cNumericFieldNames(4) + '=' + General::RoundSigDigits(NumArray(4), 2)); @@ -515,44 +478,44 @@ namespace FuelCellElectricGenerator { } for (ConstitNum = 1; ConstitNum <= NumAirConstit; ++ConstitNum) { - FuelCell(thisFuelCell).AirSup.ConstitName(ConstitNum) = AlphArray(ConstitNum + 8); - FuelCell(thisFuelCell).AirSup.ConstitMolalFract(ConstitNum) = NumArray(ConstitNum + 4); + DataGenerators::FuelCell(thisFuelCell).AirSup.ConstitName(ConstitNum) = AlphArray(ConstitNum + 8); + DataGenerators::FuelCell(thisFuelCell).AirSup.ConstitMolalFract(ConstitNum) = NumArray(ConstitNum + 4); } } else { // regular air NumAirConstit = 5; - FuelCell(thisFuelCell).AirSup.NumConstituents = NumAirConstit; + DataGenerators::FuelCell(thisFuelCell).AirSup.NumConstituents = NumAirConstit; - FuelCell(thisFuelCell).AirSup.ConstitName(1) = "Nitrogen"; - FuelCell(thisFuelCell).AirSup.ConstitMolalFract(1) = 0.7728; + DataGenerators::FuelCell(thisFuelCell).AirSup.ConstitName(1) = "Nitrogen"; + DataGenerators::FuelCell(thisFuelCell).AirSup.ConstitMolalFract(1) = 0.7728; - FuelCell(thisFuelCell).AirSup.ConstitName(2) = "Oxygen"; - FuelCell(thisFuelCell).AirSup.ConstitMolalFract(2) = 0.2073; + DataGenerators::FuelCell(thisFuelCell).AirSup.ConstitName(2) = "Oxygen"; + DataGenerators::FuelCell(thisFuelCell).AirSup.ConstitMolalFract(2) = 0.2073; - FuelCell(thisFuelCell).AirSup.ConstitName(3) = "Water"; - FuelCell(thisFuelCell).AirSup.ConstitMolalFract(3) = 0.0104; + DataGenerators::FuelCell(thisFuelCell).AirSup.ConstitName(3) = "Water"; + DataGenerators::FuelCell(thisFuelCell).AirSup.ConstitMolalFract(3) = 0.0104; - FuelCell(thisFuelCell).AirSup.ConstitName(4) = "Argon"; - FuelCell(thisFuelCell).AirSup.ConstitMolalFract(4) = 0.0092; + DataGenerators::FuelCell(thisFuelCell).AirSup.ConstitName(4) = "Argon"; + DataGenerators::FuelCell(thisFuelCell).AirSup.ConstitMolalFract(4) = 0.0092; - FuelCell(thisFuelCell).AirSup.ConstitName(5) = "CarbonDioxide"; - FuelCell(thisFuelCell).AirSup.ConstitMolalFract(5) = 0.0003; + DataGenerators::FuelCell(thisFuelCell).AirSup.ConstitName(5) = "CarbonDioxide"; + DataGenerators::FuelCell(thisFuelCell).AirSup.ConstitMolalFract(5) = 0.0003; } // check for molar fractions summing to 1.0. - if (std::abs(sum(FuelCell(thisFuelCell).AirSup.ConstitMolalFract) - 1.0) > 0.0001) { + if (std::abs(sum(DataGenerators::FuelCell(thisFuelCell).AirSup.ConstitMolalFract) - 1.0) > 0.0001) { ShowSevereError(DataIPShortCuts::cCurrentModuleObject + " molar fractions do not sum to 1.0"); - ShowContinueError("..Sum was=" + General::RoundSigDigits(sum(FuelCell(thisFuelCell).AirSup.ConstitMolalFract), 1)); + ShowContinueError("..Sum was=" + General::RoundSigDigits(sum(DataGenerators::FuelCell(thisFuelCell).AirSup.ConstitMolalFract), 1)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + " = " + AlphArray(1)); ErrorsFound = true; } // check for other FuelCell using the same Air Supply module and fill - for (otherFuelCell = thisFuelCell + 1; otherFuelCell <= NumFuelCellGenerators; ++otherFuelCell) { - if (UtilityRoutines::SameString(FuelCell(otherFuelCell).AirSup.Name, FuelCell(thisFuelCell).AirSup.Name)) { - FuelCell(otherFuelCell).AirSup = FuelCell(thisFuelCell).AirSup; + for (otherFuelCell = thisFuelCell + 1; otherFuelCell <= DataGenerators::NumFuelCellGenerators; ++otherFuelCell) { + if (UtilityRoutines::SameString(DataGenerators::FuelCell(otherFuelCell).AirSup.Name, DataGenerators::FuelCell(thisFuelCell).AirSup.Name)) { + DataGenerators::FuelCell(otherFuelCell).AirSup = DataGenerators::FuelCell(thisFuelCell).AirSup; } } } else { @@ -562,30 +525,30 @@ namespace FuelCellElectricGenerator { } } - for (GeneratorNum = 1; GeneratorNum <= NumFuelCellGenerators; ++GeneratorNum) { + for (GeneratorNum = 1; GeneratorNum <= DataGenerators::NumFuelCellGenerators; ++GeneratorNum) { // find molal fraction of oxygen in air supply thisConstituent = - UtilityRoutines::FindItem("Oxygen", FuelCell(GeneratorNum).AirSup.ConstitName, FuelCell(GeneratorNum).AirSup.NumConstituents); - if (thisConstituent > 0) FuelCell(GeneratorNum).AirSup.O2fraction = FuelCell(GeneratorNum).AirSup.ConstitMolalFract(thisConstituent); + UtilityRoutines::FindItem("Oxygen", DataGenerators::FuelCell(GeneratorNum).AirSup.ConstitName, DataGenerators::FuelCell(GeneratorNum).AirSup.NumConstituents); + if (thisConstituent > 0) DataGenerators::FuelCell(GeneratorNum).AirSup.O2fraction = DataGenerators::FuelCell(GeneratorNum).AirSup.ConstitMolalFract(thisConstituent); NumHardCodedConstituents = 14; // Loop over air constituents and do one-time setup - for (i = 1; i <= FuelCell(GeneratorNum).AirSup.NumConstituents; ++i) { + for (i = 1; i <= DataGenerators::FuelCell(GeneratorNum).AirSup.NumConstituents; ++i) { - thisName = FuelCell(GeneratorNum).AirSup.ConstitName(i); + thisName = DataGenerators::FuelCell(GeneratorNum).AirSup.ConstitName(i); - thisGasID = UtilityRoutines::FindItem(thisName, DataGenerators::GasPhaseThermoChemistryData, &GasPropertyDataStruct::ConstituentName); + thisGasID = UtilityRoutines::FindItem(thisName, DataGenerators::GasPhaseThermoChemistryData, &DataGenerators::GasPropertyDataStruct::ConstituentName); - FuelCell(GeneratorNum).AirSup.GasLibID(i) = thisGasID; + DataGenerators::FuelCell(GeneratorNum).AirSup.GasLibID(i) = thisGasID; } // set up gas constiuents for product gases - FuelCell(GeneratorNum).FCPM.GasLibID(1) = 1; // Carbon Dioxide - FuelCell(GeneratorNum).FCPM.GasLibID(2) = 2; // Nitrogen - FuelCell(GeneratorNum).FCPM.GasLibID(3) = 3; // Oxygen - FuelCell(GeneratorNum).FCPM.GasLibID(4) = 4; // Water - FuelCell(GeneratorNum).FCPM.GasLibID(5) = 5; // Argon + DataGenerators::FuelCell(GeneratorNum).FCPM.GasLibID(1) = 1; // Carbon Dioxide + DataGenerators::FuelCell(GeneratorNum).FCPM.GasLibID(2) = 2; // Nitrogen + DataGenerators::FuelCell(GeneratorNum).FCPM.GasLibID(3) = 3; // Oxygen + DataGenerators::FuelCell(GeneratorNum).FCPM.GasLibID(4) = 4; // Water + DataGenerators::FuelCell(GeneratorNum).FCPM.GasLibID(5) = 5; // Argon } DataIPShortCuts::cCurrentModuleObject = "Generator:FuelCell:WaterSupply"; @@ -601,32 +564,31 @@ namespace FuelCellElectricGenerator { DataIPShortCuts::cCurrentModuleObject, FCWaterSupNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat, _, _, DataIPShortCuts::cAlphaFieldNames, DataIPShortCuts::cNumericFieldNames); UtilityRoutines::IsNameEmpty(AlphArray(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); - thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), FuelCell, &FCDataStruct::NameFCWaterSup); + thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), DataGenerators::FuelCell, &DataGenerators::FCDataStruct::NameFCWaterSup); if (thisFuelCell > 0) { // this is only the first instance of a FuelCell generator using this type of Water supply module - FuelCell(thisFuelCell).WaterSup.Name = AlphArray(1); - FuelCell(thisFuelCell).WaterSup.WaterSupRateCurveID = CurveManager::GetCurveIndex(AlphArray(2)); - if (FuelCell(thisFuelCell).WaterSup.WaterSupRateCurveID == 0) { + DataGenerators::FuelCell(thisFuelCell).WaterSup.Name = AlphArray(1); + DataGenerators::FuelCell(thisFuelCell).WaterSup.WaterSupRateCurveID = CurveManager::GetCurveIndex(AlphArray(2)); + if (DataGenerators::FuelCell(thisFuelCell).WaterSup.WaterSupRateCurveID == 0) { ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(2) + " = " + AlphArray(2)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ShowContinueError("Curve name was not found "); ErrorsFound = true; } - FuelCell(thisFuelCell).WaterSup.PmpPowerCurveID = CurveManager::GetCurveIndex(AlphArray(3)); - if (FuelCell(thisFuelCell).WaterSup.PmpPowerCurveID == 0) { + DataGenerators::FuelCell(thisFuelCell).WaterSup.PmpPowerCurveID = CurveManager::GetCurveIndex(AlphArray(3)); + if (DataGenerators::FuelCell(thisFuelCell).WaterSup.PmpPowerCurveID == 0) { ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(3) + " = " + AlphArray(3)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ShowContinueError("Curve name was not found "); ErrorsFound = true; } - FuelCell(thisFuelCell).WaterSup.PmpPowerLossFactor = NumArray(1); + DataGenerators::FuelCell(thisFuelCell).WaterSup.PmpPowerLossFactor = NumArray(1); - //! CR9240? if (UtilityRoutines::SameString("TemperatureFromAirNode", AlphArray(4))) { - FuelCell(thisFuelCell).WaterSup.WaterTempMode = WaterInReformAirNode; + DataGenerators::FuelCell(thisFuelCell).WaterSup.WaterTempMode = DataGenerators::WaterInReformAirNode; - FuelCell(thisFuelCell).WaterSup.NodeName = AlphArray(5); - FuelCell(thisFuelCell).WaterSup.NodeNum = NodeInputManager::GetOnlySingleNode(AlphArray(5), + DataGenerators::FuelCell(thisFuelCell).WaterSup.NodeName = AlphArray(5); + DataGenerators::FuelCell(thisFuelCell).WaterSup.NodeNum = NodeInputManager::GetOnlySingleNode(AlphArray(5), ErrorsFound, DataIPShortCuts::cCurrentModuleObject, AlphArray(1), @@ -636,10 +598,10 @@ namespace FuelCellElectricGenerator { DataLoopNode::ObjectIsNotParent); } else if (UtilityRoutines::SameString("TemperatureFromWaterNode", AlphArray(4))) { - FuelCell(thisFuelCell).WaterSup.WaterTempMode = WaterInReformWaterNode; + DataGenerators::FuelCell(thisFuelCell).WaterSup.WaterTempMode = DataGenerators::WaterInReformWaterNode; - FuelCell(thisFuelCell).WaterSup.NodeName = AlphArray(5); - FuelCell(thisFuelCell).WaterSup.NodeNum = NodeInputManager::GetOnlySingleNode(AlphArray(5), + DataGenerators::FuelCell(thisFuelCell).WaterSup.NodeName = AlphArray(5); + DataGenerators::FuelCell(thisFuelCell).WaterSup.NodeNum = NodeInputManager::GetOnlySingleNode(AlphArray(5), ErrorsFound, DataIPShortCuts::cCurrentModuleObject, AlphArray(1), @@ -649,18 +611,18 @@ namespace FuelCellElectricGenerator { DataLoopNode::ObjectIsNotParent); } else if (UtilityRoutines::SameString("MainsWaterTemperature", AlphArray(4))) { - FuelCell(thisFuelCell).WaterSup.WaterTempMode = WaterInReformMains; + DataGenerators::FuelCell(thisFuelCell).WaterSup.WaterTempMode = DataGenerators::WaterInReformMains; } else if (UtilityRoutines::SameString("TemperatureFromSchedule", AlphArray(4))) { - FuelCell(thisFuelCell).WaterSup.WaterTempMode = WaterInReformSchedule; + DataGenerators::FuelCell(thisFuelCell).WaterSup.WaterTempMode = DataGenerators::WaterInReformSchedule; } else { ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(4) + " = " + AlphArray(4)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } - FuelCell(thisFuelCell).WaterSup.SchedNum = ScheduleManager::GetScheduleIndex(AlphArray(6)); - if ((FuelCell(thisFuelCell).WaterSup.SchedNum == 0) && (FuelCell(thisFuelCell).WaterSup.WaterTempMode == WaterInReformSchedule)) { + DataGenerators::FuelCell(thisFuelCell).WaterSup.SchedNum = ScheduleManager::GetScheduleIndex(AlphArray(6)); + if ((DataGenerators::FuelCell(thisFuelCell).WaterSup.SchedNum == 0) && (DataGenerators::FuelCell(thisFuelCell).WaterSup.WaterTempMode == DataGenerators::WaterInReformSchedule)) { ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(6) + " = " + AlphArray(6)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ShowContinueError("Schedule was not found"); @@ -668,9 +630,9 @@ namespace FuelCellElectricGenerator { } // check for other FuelCell using the same Water Supply module and fill - for (otherFuelCell = thisFuelCell + 1; otherFuelCell <= NumFuelCellGenerators; ++otherFuelCell) { - if (UtilityRoutines::SameString(FuelCell(otherFuelCell).WaterSup.Name, FuelCell(thisFuelCell).WaterSup.Name)) { - FuelCell(otherFuelCell).WaterSup = FuelCell(thisFuelCell).WaterSup; + for (otherFuelCell = thisFuelCell + 1; otherFuelCell <= DataGenerators::NumFuelCellGenerators; ++otherFuelCell) { + if (UtilityRoutines::SameString(DataGenerators::FuelCell(otherFuelCell).WaterSup.Name, DataGenerators::FuelCell(thisFuelCell).WaterSup.Name)) { + DataGenerators::FuelCell(otherFuelCell).WaterSup = DataGenerators::FuelCell(thisFuelCell).WaterSup; } } } else { @@ -693,44 +655,44 @@ namespace FuelCellElectricGenerator { DataIPShortCuts::cCurrentModuleObject, FCAuxHeatNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat, _, _, DataIPShortCuts::cAlphaFieldNames, DataIPShortCuts::cNumericFieldNames); UtilityRoutines::IsNameEmpty(AlphArray(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); - thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), FuelCell, &FCDataStruct::NameFCAuxilHeat); + thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), DataGenerators::FuelCell, &DataGenerators::FCDataStruct::NameFCAuxilHeat); if (thisFuelCell > 0) { - FuelCell(thisFuelCell).AuxilHeat.Name = AlphArray(1); + DataGenerators::FuelCell(thisFuelCell).AuxilHeat.Name = AlphArray(1); - FuelCell(thisFuelCell).AuxilHeat.ExcessAirRAT = NumArray(1); - FuelCell(thisFuelCell).AuxilHeat.ANC0 = NumArray(2); - FuelCell(thisFuelCell).AuxilHeat.ANC1 = NumArray(3); - FuelCell(thisFuelCell).AuxilHeat.UASkin = NumArray(4); + DataGenerators::FuelCell(thisFuelCell).AuxilHeat.ExcessAirRAT = NumArray(1); + DataGenerators::FuelCell(thisFuelCell).AuxilHeat.ANC0 = NumArray(2); + DataGenerators::FuelCell(thisFuelCell).AuxilHeat.ANC1 = NumArray(3); + DataGenerators::FuelCell(thisFuelCell).AuxilHeat.UASkin = NumArray(4); if (UtilityRoutines::SameString("SurroundingZone", AlphArray(2))) { - FuelCell(thisFuelCell).AuxilHeat.SkinLossDestination = SurroundingZone; + DataGenerators::FuelCell(thisFuelCell).AuxilHeat.SkinLossDestination = DataGenerators::SurroundingZone; } else if (UtilityRoutines::SameString("AirInletForFuelCell", AlphArray(2))) { - FuelCell(thisFuelCell).AuxilHeat.SkinLossDestination = AirInletForFC; + DataGenerators::FuelCell(thisFuelCell).AuxilHeat.SkinLossDestination = DataGenerators::AirInletForFC; } else { ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(2) + " = " + AlphArray(2)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } - FuelCell(thisFuelCell).AuxilHeat.ZoneName = AlphArray(3); - FuelCell(thisFuelCell).AuxilHeat.ZoneID = UtilityRoutines::FindItemInList(AlphArray(3), DataHeatBalance::Zone); - if ((FuelCell(thisFuelCell).AuxilHeat.ZoneID == 0) && (FuelCell(thisFuelCell).AuxilHeat.SkinLossDestination == SurroundingZone)) { + DataGenerators::FuelCell(thisFuelCell).AuxilHeat.ZoneName = AlphArray(3); + DataGenerators::FuelCell(thisFuelCell).AuxilHeat.ZoneID = UtilityRoutines::FindItemInList(AlphArray(3), DataHeatBalance::Zone); + if ((DataGenerators::FuelCell(thisFuelCell).AuxilHeat.ZoneID == 0) && (DataGenerators::FuelCell(thisFuelCell).AuxilHeat.SkinLossDestination == DataGenerators::SurroundingZone)) { ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(3) + " = " + AlphArray(3)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ShowContinueError("Zone name was not found "); ErrorsFound = true; } - FuelCell(thisFuelCell).AuxilHeat.MaxPowerW = NumArray(5); - FuelCell(thisFuelCell).AuxilHeat.MinPowerW = NumArray(6); - FuelCell(thisFuelCell).AuxilHeat.MaxPowerkmolperSec = NumArray(7); - FuelCell(thisFuelCell).AuxilHeat.MinPowerkmolperSec = NumArray(8); + DataGenerators::FuelCell(thisFuelCell).AuxilHeat.MaxPowerW = NumArray(5); + DataGenerators::FuelCell(thisFuelCell).AuxilHeat.MinPowerW = NumArray(6); + DataGenerators::FuelCell(thisFuelCell).AuxilHeat.MaxPowerkmolperSec = NumArray(7); + DataGenerators::FuelCell(thisFuelCell).AuxilHeat.MinPowerkmolperSec = NumArray(8); // TODO finish Auxiliary heater // check for other FuelCell using the same Auxiliary Heating module and fill - for (otherFuelCell = thisFuelCell + 1; otherFuelCell <= NumFuelCellGenerators; ++otherFuelCell) { - if (UtilityRoutines::SameString(FuelCell(otherFuelCell).AuxilHeat.Name, FuelCell(thisFuelCell).AuxilHeat.Name)) { - FuelCell(otherFuelCell).AuxilHeat = FuelCell(thisFuelCell).AuxilHeat; + for (otherFuelCell = thisFuelCell + 1; otherFuelCell <= DataGenerators::NumFuelCellGenerators; ++otherFuelCell) { + if (UtilityRoutines::SameString(DataGenerators::FuelCell(otherFuelCell).AuxilHeat.Name, DataGenerators::FuelCell(thisFuelCell).AuxilHeat.Name)) { + DataGenerators::FuelCell(otherFuelCell).AuxilHeat = DataGenerators::FuelCell(thisFuelCell).AuxilHeat; } } } else { @@ -754,13 +716,13 @@ namespace FuelCellElectricGenerator { DataIPShortCuts::cCurrentModuleObject, FCHXNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat, _, _, DataIPShortCuts::cAlphaFieldNames, DataIPShortCuts::cNumericFieldNames); UtilityRoutines::IsNameEmpty(AlphArray(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); - thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), FuelCell, &FCDataStruct::NameExhaustHX); + thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), DataGenerators::FuelCell, &DataGenerators::FCDataStruct::NameExhaustHX); if (thisFuelCell > 0) { - FuelCell(thisFuelCell).ExhaustHX.Name = AlphArray(1); - FuelCell(thisFuelCell).ExhaustHX.WaterInNodeName = AlphArray(2); - FuelCell(thisFuelCell).ExhaustHX.WaterOutNodeName = AlphArray(3); + DataGenerators::FuelCell(thisFuelCell).ExhaustHX.Name = AlphArray(1); + DataGenerators::FuelCell(thisFuelCell).ExhaustHX.WaterInNodeName = AlphArray(2); + DataGenerators::FuelCell(thisFuelCell).ExhaustHX.WaterOutNodeName = AlphArray(3); // find node ids for water path - FuelCell(thisFuelCell).ExhaustHX.WaterInNode = NodeInputManager::GetOnlySingleNode(AlphArray(2), + DataGenerators::FuelCell(thisFuelCell).ExhaustHX.WaterInNode = NodeInputManager::GetOnlySingleNode(AlphArray(2), ErrorsFound, DataIPShortCuts::cCurrentModuleObject, AlphArray(1), @@ -768,7 +730,7 @@ namespace FuelCellElectricGenerator { DataLoopNode::NodeConnectionType_Inlet, 1, DataLoopNode::ObjectIsNotParent); - FuelCell(thisFuelCell).ExhaustHX.WaterOutNode = NodeInputManager::GetOnlySingleNode(AlphArray(3), + DataGenerators::FuelCell(thisFuelCell).ExhaustHX.WaterOutNode = NodeInputManager::GetOnlySingleNode(AlphArray(3), ErrorsFound, DataIPShortCuts::cCurrentModuleObject, AlphArray(1), @@ -778,46 +740,45 @@ namespace FuelCellElectricGenerator { DataLoopNode::ObjectIsNotParent); BranchNodeConnections::TestCompSet(DataIPShortCuts::cCurrentModuleObject, AlphArray(1), AlphArray(2), AlphArray(3), "Heat Recovery Nodes"); - // CR9240 - FuelCell(thisFuelCell).ExhaustHX.ExhaustOutNodeName = AlphArray(4); - FuelCell(thisFuelCell).ExhaustHX.ExhaustOutNode = NodeInputManager::GetOnlySingleNode( + DataGenerators::FuelCell(thisFuelCell).ExhaustHX.ExhaustOutNodeName = AlphArray(4); + DataGenerators::FuelCell(thisFuelCell).ExhaustHX.ExhaustOutNode = NodeInputManager::GetOnlySingleNode( AlphArray(4), ErrorsFound, DataIPShortCuts::cCurrentModuleObject, AlphArray(1), DataLoopNode::NodeType_Air, DataLoopNode::NodeConnectionType_Outlet, 2, DataLoopNode::ObjectIsNotParent); if (UtilityRoutines::SameString("FixedEffectiveness", AlphArray(5))) { - FuelCell(thisFuelCell).ExhaustHX.HXmodelMode = FixedEffectiveness; + DataGenerators::FuelCell(thisFuelCell).ExhaustHX.HXmodelMode = DataGenerators::FixedEffectiveness; } else if (UtilityRoutines::SameString("EmpiricalUAeff", AlphArray(5))) { - FuelCell(thisFuelCell).ExhaustHX.HXmodelMode = LMTDempiricalUAeff; + DataGenerators::FuelCell(thisFuelCell).ExhaustHX.HXmodelMode = DataGenerators::LMTDempiricalUAeff; } else if (UtilityRoutines::SameString("FundementalUAeff", AlphArray(5))) { - FuelCell(thisFuelCell).ExhaustHX.HXmodelMode = LMTDfundementalUAeff; + DataGenerators::FuelCell(thisFuelCell).ExhaustHX.HXmodelMode = DataGenerators::LMTDfundementalUAeff; } else if (UtilityRoutines::SameString("CONDENSING", AlphArray(5))) { - FuelCell(thisFuelCell).ExhaustHX.HXmodelMode = Condensing; + DataGenerators::FuelCell(thisFuelCell).ExhaustHX.HXmodelMode = DataGenerators::Condensing; } else { ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(5) + " = " + AlphArray(5)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } - FuelCell(thisFuelCell).ExhaustHX.WaterVolumeFlowMax = NumArray(1); - FuelCell(thisFuelCell).ExhaustHX.HXEffect = NumArray(2); - FuelCell(thisFuelCell).ExhaustHX.hxs0 = NumArray(3); - FuelCell(thisFuelCell).ExhaustHX.hxs1 = NumArray(4); - FuelCell(thisFuelCell).ExhaustHX.hxs2 = NumArray(5); - FuelCell(thisFuelCell).ExhaustHX.hxs3 = NumArray(6); - FuelCell(thisFuelCell).ExhaustHX.hxs4 = NumArray(7); - FuelCell(thisFuelCell).ExhaustHX.h0gas = NumArray(8); - FuelCell(thisFuelCell).ExhaustHX.NdotGasRef = NumArray(9); - FuelCell(thisFuelCell).ExhaustHX.nCoeff = NumArray(10); - FuelCell(thisFuelCell).ExhaustHX.AreaGas = NumArray(11); - FuelCell(thisFuelCell).ExhaustHX.h0Water = NumArray(12); - FuelCell(thisFuelCell).ExhaustHX.NdotWaterRef = NumArray(13); - FuelCell(thisFuelCell).ExhaustHX.mCoeff = NumArray(14); - FuelCell(thisFuelCell).ExhaustHX.AreaWater = NumArray(15); - FuelCell(thisFuelCell).ExhaustHX.Fadjust = NumArray(16); - FuelCell(thisFuelCell).ExhaustHX.l1Coeff = NumArray(17); - FuelCell(thisFuelCell).ExhaustHX.l2Coeff = NumArray(18); - FuelCell(thisFuelCell).ExhaustHX.CondensationThresholdTemp = NumArray(19); + DataGenerators::FuelCell(thisFuelCell).ExhaustHX.WaterVolumeFlowMax = NumArray(1); + DataGenerators::FuelCell(thisFuelCell).ExhaustHX.HXEffect = NumArray(2); + DataGenerators::FuelCell(thisFuelCell).ExhaustHX.hxs0 = NumArray(3); + DataGenerators::FuelCell(thisFuelCell).ExhaustHX.hxs1 = NumArray(4); + DataGenerators::FuelCell(thisFuelCell).ExhaustHX.hxs2 = NumArray(5); + DataGenerators::FuelCell(thisFuelCell).ExhaustHX.hxs3 = NumArray(6); + DataGenerators::FuelCell(thisFuelCell).ExhaustHX.hxs4 = NumArray(7); + DataGenerators::FuelCell(thisFuelCell).ExhaustHX.h0gas = NumArray(8); + DataGenerators::FuelCell(thisFuelCell).ExhaustHX.NdotGasRef = NumArray(9); + DataGenerators::FuelCell(thisFuelCell).ExhaustHX.nCoeff = NumArray(10); + DataGenerators::FuelCell(thisFuelCell).ExhaustHX.AreaGas = NumArray(11); + DataGenerators::FuelCell(thisFuelCell).ExhaustHX.h0Water = NumArray(12); + DataGenerators::FuelCell(thisFuelCell).ExhaustHX.NdotWaterRef = NumArray(13); + DataGenerators::FuelCell(thisFuelCell).ExhaustHX.mCoeff = NumArray(14); + DataGenerators::FuelCell(thisFuelCell).ExhaustHX.AreaWater = NumArray(15); + DataGenerators::FuelCell(thisFuelCell).ExhaustHX.Fadjust = NumArray(16); + DataGenerators::FuelCell(thisFuelCell).ExhaustHX.l1Coeff = NumArray(17); + DataGenerators::FuelCell(thisFuelCell).ExhaustHX.l2Coeff = NumArray(18); + DataGenerators::FuelCell(thisFuelCell).ExhaustHX.CondensationThresholdTemp = NumArray(19); // store cooling water volume flow rate for autosizing system - PlantUtilities::RegisterPlantCompDesignFlow(FuelCell(thisFuelCell).ExhaustHX.WaterInNode, FuelCell(thisFuelCell).ExhaustHX.WaterVolumeFlowMax); + PlantUtilities::RegisterPlantCompDesignFlow(DataGenerators::FuelCell(thisFuelCell).ExhaustHX.WaterInNode, DataGenerators::FuelCell(thisFuelCell).ExhaustHX.WaterVolumeFlowMax); } else { ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(1) + " = " + AlphArray(1)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); @@ -839,28 +800,28 @@ namespace FuelCellElectricGenerator { DataIPShortCuts::cCurrentModuleObject, StorageNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat, _, _, DataIPShortCuts::cAlphaFieldNames, DataIPShortCuts::cNumericFieldNames); UtilityRoutines::IsNameEmpty(AlphArray(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); - thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), FuelCell, &FCDataStruct::NameElecStorage); + thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), DataGenerators::FuelCell, &DataGenerators::FCDataStruct::NameElecStorage); if (thisFuelCell > 0) { - FuelCell(thisFuelCell).ElecStorage.Name = AlphArray(1); + DataGenerators::FuelCell(thisFuelCell).ElecStorage.Name = AlphArray(1); if (UtilityRoutines::SameString(AlphArray(2), "SimpleEfficiencyWithConstraints")) { - FuelCell(thisFuelCell).ElecStorage.StorageModelMode = SimpleEffConstraints; + DataGenerators::FuelCell(thisFuelCell).ElecStorage.StorageModelMode = DataGenerators::SimpleEffConstraints; } else { ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(2) + " = " + AlphArray(2)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } - FuelCell(thisFuelCell).ElecStorage.EnergeticEfficCharge = NumArray(1); - FuelCell(thisFuelCell).ElecStorage.EnergeticEfficDischarge = NumArray(2); - FuelCell(thisFuelCell).ElecStorage.NominalEnergyCapacity = NumArray(3); - FuelCell(thisFuelCell).ElecStorage.MaxPowerDraw = NumArray(4); - FuelCell(thisFuelCell).ElecStorage.MaxPowerStore = NumArray(5); - FuelCell(thisFuelCell).ElecStorage.StartingEnergyStored = NumArray(6); + DataGenerators::FuelCell(thisFuelCell).ElecStorage.EnergeticEfficCharge = NumArray(1); + DataGenerators::FuelCell(thisFuelCell).ElecStorage.EnergeticEfficDischarge = NumArray(2); + DataGenerators::FuelCell(thisFuelCell).ElecStorage.NominalEnergyCapacity = NumArray(3); + DataGenerators::FuelCell(thisFuelCell).ElecStorage.MaxPowerDraw = NumArray(4); + DataGenerators::FuelCell(thisFuelCell).ElecStorage.MaxPowerStore = NumArray(5); + DataGenerators::FuelCell(thisFuelCell).ElecStorage.StartingEnergyStored = NumArray(6); // check for other FuelCell using the same Electrical Storage and fill - for (otherFuelCell = thisFuelCell + 1; otherFuelCell <= NumFuelCellGenerators; ++otherFuelCell) { - if (UtilityRoutines::SameString(FuelCell(otherFuelCell).ElecStorage.Name, FuelCell(thisFuelCell).ElecStorage.Name)) { - FuelCell(otherFuelCell).ElecStorage = FuelCell(thisFuelCell).ElecStorage; + for (otherFuelCell = thisFuelCell + 1; otherFuelCell <= DataGenerators::NumFuelCellGenerators; ++otherFuelCell) { + if (UtilityRoutines::SameString(DataGenerators::FuelCell(otherFuelCell).ElecStorage.Name, DataGenerators::FuelCell(thisFuelCell).ElecStorage.Name)) { + DataGenerators::FuelCell(otherFuelCell).ElecStorage = DataGenerators::FuelCell(thisFuelCell).ElecStorage; } } } else { @@ -885,23 +846,23 @@ namespace FuelCellElectricGenerator { DataIPShortCuts::cCurrentModuleObject, FCPCUNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat, _, _, DataIPShortCuts::cAlphaFieldNames, DataIPShortCuts::cNumericFieldNames); UtilityRoutines::IsNameEmpty(AlphArray(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); - thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), FuelCell, &FCDataStruct::NameInverter); + thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), DataGenerators::FuelCell, &DataGenerators::FCDataStruct::NameInverter); if (thisFuelCell > 0) { - FuelCell(thisFuelCell).Inverter.Name = AlphArray(1); + DataGenerators::FuelCell(thisFuelCell).Inverter.Name = AlphArray(1); - if (UtilityRoutines::SameString(AlphArray(2), "QUADRATIC")) FuelCell(thisFuelCell).Inverter.EffMode = DataGenerators::InverterEffQuadratic; - if (UtilityRoutines::SameString(AlphArray(2), "Constant")) FuelCell(thisFuelCell).Inverter.EffMode = DataGenerators::InverterEffConstant; - if (FuelCell(thisFuelCell).Inverter.EffMode == 0) { + if (UtilityRoutines::SameString(AlphArray(2), "QUADRATIC")) DataGenerators::FuelCell(thisFuelCell).Inverter.EffMode = DataGenerators::InverterEffQuadratic; + if (UtilityRoutines::SameString(AlphArray(2), "Constant")) DataGenerators::FuelCell(thisFuelCell).Inverter.EffMode = DataGenerators::InverterEffConstant; + if (DataGenerators::FuelCell(thisFuelCell).Inverter.EffMode == 0) { ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(2) + " = " + AlphArray(2)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } - FuelCell(thisFuelCell).Inverter.ConstEff = NumArray(1); + DataGenerators::FuelCell(thisFuelCell).Inverter.ConstEff = NumArray(1); - FuelCell(thisFuelCell).Inverter.EffQuadraticCurveID = CurveManager::GetCurveIndex(AlphArray(3)); - if ((FuelCell(thisFuelCell).Inverter.EffQuadraticCurveID == 0) && - (FuelCell(thisFuelCell).Inverter.EffMode == DataGenerators::InverterEffQuadratic)) { + DataGenerators::FuelCell(thisFuelCell).Inverter.EffQuadraticCurveID = CurveManager::GetCurveIndex(AlphArray(3)); + if ((DataGenerators::FuelCell(thisFuelCell).Inverter.EffQuadraticCurveID == 0) && + (DataGenerators::FuelCell(thisFuelCell).Inverter.EffMode == DataGenerators::InverterEffQuadratic)) { ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(3) + " = " + AlphArray(3)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ShowContinueError("Curve was not found "); @@ -909,9 +870,9 @@ namespace FuelCellElectricGenerator { } // check for other FuelCell using the same Inverter and fill - for (otherFuelCell = thisFuelCell + 1; otherFuelCell <= NumFuelCellGenerators; ++otherFuelCell) { - if (UtilityRoutines::SameString(FuelCell(otherFuelCell).Inverter.Name, FuelCell(thisFuelCell).Inverter.Name)) { - FuelCell(otherFuelCell).Inverter = FuelCell(thisFuelCell).Inverter; + for (otherFuelCell = thisFuelCell + 1; otherFuelCell <= DataGenerators::NumFuelCellGenerators; ++otherFuelCell) { + if (UtilityRoutines::SameString(DataGenerators::FuelCell(otherFuelCell).Inverter.Name, DataGenerators::FuelCell(thisFuelCell).Inverter.Name)) { + DataGenerators::FuelCell(otherFuelCell).Inverter = DataGenerators::FuelCell(thisFuelCell).Inverter; } } } else { @@ -939,14 +900,14 @@ namespace FuelCellElectricGenerator { DataIPShortCuts::cNumericFieldNames); UtilityRoutines::IsNameEmpty(AlphArray(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); - thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), FuelCell, &FCDataStruct::NameStackCooler); + thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), DataGenerators::FuelCell, &DataGenerators::FCDataStruct::NameStackCooler); if (thisFuelCell > 0) { - FuelCell(thisFuelCell).StackCooler.Name = AlphArray(1); - FuelCell(thisFuelCell).StackCooler.WaterInNodeName = AlphArray(2); + DataGenerators::FuelCell(thisFuelCell).StackCooler.Name = AlphArray(1); + DataGenerators::FuelCell(thisFuelCell).StackCooler.WaterInNodeName = AlphArray(2); - FuelCell(thisFuelCell).StackCooler.WaterOutNodeName = AlphArray(3); + DataGenerators::FuelCell(thisFuelCell).StackCooler.WaterOutNodeName = AlphArray(3); - FuelCell(thisFuelCell).StackCooler.WaterInNode = NodeInputManager::GetOnlySingleNode(AlphArray(2), + DataGenerators::FuelCell(thisFuelCell).StackCooler.WaterInNode = NodeInputManager::GetOnlySingleNode(AlphArray(2), ErrorsFound, DataIPShortCuts::cCurrentModuleObject, AlphArray(1), @@ -954,7 +915,7 @@ namespace FuelCellElectricGenerator { DataLoopNode::NodeConnectionType_Inlet, 1, DataLoopNode::ObjectIsNotParent); - FuelCell(thisFuelCell).StackCooler.WaterOutNode = NodeInputManager::GetOnlySingleNode(AlphArray(3), + DataGenerators::FuelCell(thisFuelCell).StackCooler.WaterOutNode = NodeInputManager::GetOnlySingleNode(AlphArray(3), ErrorsFound, DataIPShortCuts::cCurrentModuleObject, AlphArray(1), @@ -964,26 +925,26 @@ namespace FuelCellElectricGenerator { DataLoopNode::ObjectIsNotParent); BranchNodeConnections::TestCompSet(DataIPShortCuts::cCurrentModuleObject, AlphArray(1), AlphArray(2), AlphArray(3), "Heat Recovery Nodes"); - FuelCell(thisFuelCell).StackCooler.TstackNom = NumArray(1); - FuelCell(thisFuelCell).StackCooler.TstackActual = NumArray(2); - FuelCell(thisFuelCell).StackCooler.r0 = NumArray(3); - FuelCell(thisFuelCell).StackCooler.r1 = NumArray(4); - FuelCell(thisFuelCell).StackCooler.r2 = NumArray(5); - FuelCell(thisFuelCell).StackCooler.r3 = NumArray(6); - FuelCell(thisFuelCell).StackCooler.MdotStackCoolant = NumArray(7); - FuelCell(thisFuelCell).StackCooler.UAs_cool = NumArray(8); - FuelCell(thisFuelCell).StackCooler.Fs_cogen = NumArray(9); - FuelCell(thisFuelCell).StackCooler.As_cogen = NumArray(10); - FuelCell(thisFuelCell).StackCooler.MdotCogenNom = NumArray(11); - FuelCell(thisFuelCell).StackCooler.hCogenNom = NumArray(12); - FuelCell(thisFuelCell).StackCooler.ns = NumArray(13); - FuelCell(thisFuelCell).StackCooler.PstackPumpEl = NumArray(14); - FuelCell(thisFuelCell).StackCooler.PmpPowerLossFactor = NumArray(15); - FuelCell(thisFuelCell).StackCooler.f0 = NumArray(16); - FuelCell(thisFuelCell).StackCooler.f1 = NumArray(17); - FuelCell(thisFuelCell).StackCooler.f1 = NumArray(18); - - FuelCell(thisFuelCell).StackCooler.StackCoolerPresent = true; + DataGenerators::FuelCell(thisFuelCell).StackCooler.TstackNom = NumArray(1); + DataGenerators::FuelCell(thisFuelCell).StackCooler.TstackActual = NumArray(2); + DataGenerators::FuelCell(thisFuelCell).StackCooler.r0 = NumArray(3); + DataGenerators::FuelCell(thisFuelCell).StackCooler.r1 = NumArray(4); + DataGenerators::FuelCell(thisFuelCell).StackCooler.r2 = NumArray(5); + DataGenerators::FuelCell(thisFuelCell).StackCooler.r3 = NumArray(6); + DataGenerators::FuelCell(thisFuelCell).StackCooler.MdotStackCoolant = NumArray(7); + DataGenerators::FuelCell(thisFuelCell).StackCooler.UAs_cool = NumArray(8); + DataGenerators::FuelCell(thisFuelCell).StackCooler.Fs_cogen = NumArray(9); + DataGenerators::FuelCell(thisFuelCell).StackCooler.As_cogen = NumArray(10); + DataGenerators::FuelCell(thisFuelCell).StackCooler.MdotCogenNom = NumArray(11); + DataGenerators::FuelCell(thisFuelCell).StackCooler.hCogenNom = NumArray(12); + DataGenerators::FuelCell(thisFuelCell).StackCooler.ns = NumArray(13); + DataGenerators::FuelCell(thisFuelCell).StackCooler.PstackPumpEl = NumArray(14); + DataGenerators::FuelCell(thisFuelCell).StackCooler.PmpPowerLossFactor = NumArray(15); + DataGenerators::FuelCell(thisFuelCell).StackCooler.f0 = NumArray(16); + DataGenerators::FuelCell(thisFuelCell).StackCooler.f1 = NumArray(17); + DataGenerators::FuelCell(thisFuelCell).StackCooler.f1 = NumArray(18); + + DataGenerators::FuelCell(thisFuelCell).StackCooler.StackCoolerPresent = true; } else { ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(1) + " = " + AlphArray(1)); @@ -997,19 +958,19 @@ namespace FuelCellElectricGenerator { ShowFatalError("Errors found in getting input for fuel cell model "); } - for (GeneratorNum = 1; GeneratorNum <= NumFuelCellGenerators; ++GeneratorNum) { + for (GeneratorNum = 1; GeneratorNum <= DataGenerators::NumFuelCellGenerators; ++GeneratorNum) { SetupOutputVariable("Generator Produced Electric Power", OutputProcessor::Unit::W, - FuelCell(GeneratorNum).Report.ACPowerGen, + DataGenerators::FuelCell(GeneratorNum).Report.ACPowerGen, "System", "Average", - FuelCell(GeneratorNum).Name); + DataGenerators::FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Produced Electric Energy", OutputProcessor::Unit::J, - FuelCell(GeneratorNum).Report.ACEnergyGen, + DataGenerators::FuelCell(GeneratorNum).Report.ACEnergyGen, "System", "Sum", - FuelCell(GeneratorNum).Name, + DataGenerators::FuelCell(GeneratorNum).Name, _, "ElectricityProduced", "COGENERATION", @@ -1017,16 +978,16 @@ namespace FuelCellElectricGenerator { "Plant"); SetupOutputVariable("Generator Produced Thermal Rate", OutputProcessor::Unit::W, - FuelCell(GeneratorNum).Report.qHX, + DataGenerators::FuelCell(GeneratorNum).Report.qHX, "System", "Average", - FuelCell(GeneratorNum).Name); + DataGenerators::FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Produced Thermal Energy", OutputProcessor::Unit::J, - FuelCell(GeneratorNum).Report.HXenergy, + DataGenerators::FuelCell(GeneratorNum).Report.HXenergy, "System", "Sum", - FuelCell(GeneratorNum).Name, + DataGenerators::FuelCell(GeneratorNum).Name, _, "ENERGYTRANSFER", "COGENERATION", @@ -1035,10 +996,10 @@ namespace FuelCellElectricGenerator { SetupOutputVariable("Generator Fuel HHV Basis Energy", OutputProcessor::Unit::J, - FuelCell(GeneratorNum).Report.FuelEnergyHHV, + DataGenerators::FuelCell(GeneratorNum).Report.FuelEnergyHHV, "System", "Sum", - FuelCell(GeneratorNum).Name, + DataGenerators::FuelCell(GeneratorNum).Name, _, "Gas", "COGENERATION", @@ -1046,325 +1007,325 @@ namespace FuelCellElectricGenerator { "Plant"); SetupOutputVariable("Generator Fuel HHV Basis Rate", OutputProcessor::Unit::W, - FuelCell(GeneratorNum).Report.FuelEnergyUseRateHHV, + DataGenerators::FuelCell(GeneratorNum).Report.FuelEnergyUseRateHHV, "System", "Average", - FuelCell(GeneratorNum).Name); + DataGenerators::FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Zone Sensible Heat Transfer Rate", OutputProcessor::Unit::W, - FuelCell(GeneratorNum).Report.SkinLossPower, + DataGenerators::FuelCell(GeneratorNum).Report.SkinLossPower, "System", "Average", - FuelCell(GeneratorNum).Name); + DataGenerators::FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Zone Sensible Heat Transfer Energy", OutputProcessor::Unit::J, - FuelCell(GeneratorNum).Report.SkinLossEnergy, + DataGenerators::FuelCell(GeneratorNum).Report.SkinLossEnergy, "System", "Sum", - FuelCell(GeneratorNum).Name); + DataGenerators::FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Zone Convection Heat Transfer Rate", OutputProcessor::Unit::W, - FuelCell(GeneratorNum).Report.SkinLossConvect, + DataGenerators::FuelCell(GeneratorNum).Report.SkinLossConvect, "System", "Average", - FuelCell(GeneratorNum).Name); + DataGenerators::FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Zone Radiation Heat Transfer Rate", OutputProcessor::Unit::W, - FuelCell(GeneratorNum).Report.SkinLossRadiat, + DataGenerators::FuelCell(GeneratorNum).Report.SkinLossRadiat, "System", "Average", - FuelCell(GeneratorNum).Name); - if (FuelCell(GeneratorNum).FCPM.ZoneID > 0) { - SetupZoneInternalGain(FuelCell(GeneratorNum).FCPM.ZoneID, + DataGenerators::FuelCell(GeneratorNum).Name); + if (DataGenerators::FuelCell(GeneratorNum).FCPM.ZoneID > 0) { + SetupZoneInternalGain(DataGenerators::FuelCell(GeneratorNum).FCPM.ZoneID, "Generator:FuelCell", - FuelCell(GeneratorNum).Name, + DataGenerators::FuelCell(GeneratorNum).Name, DataHeatBalance::IntGainTypeOf_GeneratorFuelCell, - FuelCell(GeneratorNum).Report.SkinLossConvect, + DataGenerators::FuelCell(GeneratorNum).Report.SkinLossConvect, _, - FuelCell(GeneratorNum).Report.SkinLossRadiat); + DataGenerators::FuelCell(GeneratorNum).Report.SkinLossRadiat); } if (DataGlobals::DisplayAdvancedReportVariables) { // show extra data originally needed for detailed comparative testing SetupOutputVariable("Generator Air Inlet Temperature", OutputProcessor::Unit::C, - FuelCell(GeneratorNum).Report.TairInlet, + DataGenerators::FuelCell(GeneratorNum).Report.TairInlet, "System", "Average", - FuelCell(GeneratorNum).Name); + DataGenerators::FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Power Module Entering Air Temperature", OutputProcessor::Unit::C, - FuelCell(GeneratorNum).Report.TairIntoFCPM, + DataGenerators::FuelCell(GeneratorNum).Report.TairIntoFCPM, "System", "Average", - FuelCell(GeneratorNum).Name); + DataGenerators::FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Air Molar Flow Rate", OutputProcessor::Unit::kmol_s, - FuelCell(GeneratorNum).Report.NdotAir, + DataGenerators::FuelCell(GeneratorNum).Report.NdotAir, "System", "Average", - FuelCell(GeneratorNum).Name); + DataGenerators::FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Power Module Entering Air Enthalpy", OutputProcessor::Unit::W, - FuelCell(GeneratorNum).Report.TotAirInEnthalphy, + DataGenerators::FuelCell(GeneratorNum).Report.TotAirInEnthalphy, "System", "Average", - FuelCell(GeneratorNum).Name); + DataGenerators::FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Blower Electric Power", OutputProcessor::Unit::W, - FuelCell(GeneratorNum).Report.BlowerPower, + DataGenerators::FuelCell(GeneratorNum).Report.BlowerPower, "System", "Average", - FuelCell(GeneratorNum).Name); + DataGenerators::FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Blower Electric Energy", OutputProcessor::Unit::J, - FuelCell(GeneratorNum).Report.BlowerEnergy, + DataGenerators::FuelCell(GeneratorNum).Report.BlowerEnergy, "System", "Sum", - FuelCell(GeneratorNum).Name); + DataGenerators::FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Blower Skin Heat Loss Rate", OutputProcessor::Unit::W, - FuelCell(GeneratorNum).Report.BlowerSkinLoss, + DataGenerators::FuelCell(GeneratorNum).Report.BlowerSkinLoss, "System", "Average", - FuelCell(GeneratorNum).Name); + DataGenerators::FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Fuel Inlet Temperature", OutputProcessor::Unit::C, - FuelCell(GeneratorNum).Report.TfuelInlet, + DataGenerators::FuelCell(GeneratorNum).Report.TfuelInlet, "System", "Average", - FuelCell(GeneratorNum).Name); + DataGenerators::FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Power Module Entering Fuel Temperature", OutputProcessor::Unit::C, - FuelCell(GeneratorNum).Report.TfuelIntoFCPM, + DataGenerators::FuelCell(GeneratorNum).Report.TfuelIntoFCPM, "System", "Average", - FuelCell(GeneratorNum).Name); + DataGenerators::FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Fuel Molar Flow Rate", OutputProcessor::Unit::kmol_s, - FuelCell(GeneratorNum).Report.NdotFuel, + DataGenerators::FuelCell(GeneratorNum).Report.NdotFuel, "System", "Average", - FuelCell(GeneratorNum).Name); + DataGenerators::FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Fuel Consumption LHV Basis Energy", OutputProcessor::Unit::J, - FuelCell(GeneratorNum).Report.FuelEnergyLHV, + DataGenerators::FuelCell(GeneratorNum).Report.FuelEnergyLHV, "System", "Sum", - FuelCell(GeneratorNum).Name); + DataGenerators::FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Fuel Consumption Rate LHV Basis", OutputProcessor::Unit::W, - FuelCell(GeneratorNum).Report.FuelEnergyUseRateLHV, + DataGenerators::FuelCell(GeneratorNum).Report.FuelEnergyUseRateLHV, "System", "Average", - FuelCell(GeneratorNum).Name); + DataGenerators::FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Power Module Entering Fuel Enthalpy", OutputProcessor::Unit::W, - FuelCell(GeneratorNum).Report.TotFuelInEnthalpy, + DataGenerators::FuelCell(GeneratorNum).Report.TotFuelInEnthalpy, "System", "Average", - FuelCell(GeneratorNum).Name); + DataGenerators::FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Fuel Compressor Electric Power", OutputProcessor::Unit::W, - FuelCell(GeneratorNum).Report.FuelCompressPower, + DataGenerators::FuelCell(GeneratorNum).Report.FuelCompressPower, "System", "Average", - FuelCell(GeneratorNum).Name); + DataGenerators::FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Fuel Compressor Electric Energy", OutputProcessor::Unit::J, - FuelCell(GeneratorNum).Report.FuelCompressEnergy, + DataGenerators::FuelCell(GeneratorNum).Report.FuelCompressEnergy, "System", "Sum", - FuelCell(GeneratorNum).Name); + DataGenerators::FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Fuel Compressor Skin Heat Loss Rate", OutputProcessor::Unit::W, - FuelCell(GeneratorNum).Report.FuelCompressSkinLoss, + DataGenerators::FuelCell(GeneratorNum).Report.FuelCompressSkinLoss, "System", "Average", - FuelCell(GeneratorNum).Name); + DataGenerators::FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Fuel Reformer Water Inlet Temperature", OutputProcessor::Unit::C, - FuelCell(GeneratorNum).Report.TwaterInlet, + DataGenerators::FuelCell(GeneratorNum).Report.TwaterInlet, "System", "Average", - FuelCell(GeneratorNum).Name); + DataGenerators::FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Power Module Entering Reforming Water Temperature", OutputProcessor::Unit::C, - FuelCell(GeneratorNum).Report.TwaterIntoFCPM, + DataGenerators::FuelCell(GeneratorNum).Report.TwaterIntoFCPM, "System", "Average", - FuelCell(GeneratorNum).Name); + DataGenerators::FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Fuel Reformer Water Molar Flow Rate", OutputProcessor::Unit::kmol_s, - FuelCell(GeneratorNum).Report.NdotWater, + DataGenerators::FuelCell(GeneratorNum).Report.NdotWater, "System", "Average", - FuelCell(GeneratorNum).Name); + DataGenerators::FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Fuel Reformer Water Pump Electric Power", OutputProcessor::Unit::W, - FuelCell(GeneratorNum).Report.WaterPumpPower, + DataGenerators::FuelCell(GeneratorNum).Report.WaterPumpPower, "System", "Average", - FuelCell(GeneratorNum).Name); + DataGenerators::FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Fuel Reformer Water Pump Electric Energy", OutputProcessor::Unit::J, - FuelCell(GeneratorNum).Report.WaterPumpEnergy, + DataGenerators::FuelCell(GeneratorNum).Report.WaterPumpEnergy, "System", "Sum", - FuelCell(GeneratorNum).Name); + DataGenerators::FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Power Module Entering Reforming Water Enthalpy", OutputProcessor::Unit::W, - FuelCell(GeneratorNum).Report.WaterIntoFCPMEnthalpy, + DataGenerators::FuelCell(GeneratorNum).Report.WaterIntoFCPMEnthalpy, "System", "Average", - FuelCell(GeneratorNum).Name); + DataGenerators::FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Product Gas Temperature", OutputProcessor::Unit::C, - FuelCell(GeneratorNum).Report.TprodGas, + DataGenerators::FuelCell(GeneratorNum).Report.TprodGas, "System", "Average", - FuelCell(GeneratorNum).Name); + DataGenerators::FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Product Gas Enthalpy", OutputProcessor::Unit::W, - FuelCell(GeneratorNum).Report.EnthalProdGas, + DataGenerators::FuelCell(GeneratorNum).Report.EnthalProdGas, "System", "Average", - FuelCell(GeneratorNum).Name); + DataGenerators::FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Product Gas Molar Flow Rate", OutputProcessor::Unit::kmol_s, - FuelCell(GeneratorNum).Report.NdotProdGas, + DataGenerators::FuelCell(GeneratorNum).Report.NdotProdGas, "System", "Average", - FuelCell(GeneratorNum).Name); + DataGenerators::FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Product Gas Ar Molar Flow Rate", OutputProcessor::Unit::kmol_s, - FuelCell(GeneratorNum).Report.NdotProdAr, + DataGenerators::FuelCell(GeneratorNum).Report.NdotProdAr, "System", "Average", - FuelCell(GeneratorNum).Name); + DataGenerators::FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Product Gas CO2 Molar Flow Rate", OutputProcessor::Unit::kmol_s, - FuelCell(GeneratorNum).Report.NdotProdCO2, + DataGenerators::FuelCell(GeneratorNum).Report.NdotProdCO2, "System", "Average", - FuelCell(GeneratorNum).Name); + DataGenerators::FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Product Gas H2O Vapor Molar Flow Rate", OutputProcessor::Unit::kmol_s, - FuelCell(GeneratorNum).Report.NdotProdH2O, + DataGenerators::FuelCell(GeneratorNum).Report.NdotProdH2O, "System", "Average", - FuelCell(GeneratorNum).Name); + DataGenerators::FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Product Gas N2 Molar Flow Rate", OutputProcessor::Unit::kmol_s, - FuelCell(GeneratorNum).Report.NdotProdN2, + DataGenerators::FuelCell(GeneratorNum).Report.NdotProdN2, "System", "Average", - FuelCell(GeneratorNum).Name); + DataGenerators::FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Product Gas O2 Molar Flow Rate", OutputProcessor::Unit::kmol_s, - FuelCell(GeneratorNum).Report.NdotProdO2, + DataGenerators::FuelCell(GeneratorNum).Report.NdotProdO2, "System", "Average", - FuelCell(GeneratorNum).Name); + DataGenerators::FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Heat Recovery Exit Gas Temperature", OutputProcessor::Unit::C, - FuelCell(GeneratorNum).Report.THXexh, + DataGenerators::FuelCell(GeneratorNum).Report.THXexh, "System", "Average", - FuelCell(GeneratorNum).Name); + DataGenerators::FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Heat Recovery Exit Gas H2O Vapor Fraction", OutputProcessor::Unit::None, - FuelCell(GeneratorNum).Report.WaterVaporFractExh, + DataGenerators::FuelCell(GeneratorNum).Report.WaterVaporFractExh, "System", "Average", - FuelCell(GeneratorNum).Name); + DataGenerators::FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Heat Recovery Water Condensate Molar Flow Rate", OutputProcessor::Unit::kmol_s, - FuelCell(GeneratorNum).Report.CondensateRate, + DataGenerators::FuelCell(GeneratorNum).Report.CondensateRate, "System", "Average", - FuelCell(GeneratorNum).Name); + DataGenerators::FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Inverter Loss Power", OutputProcessor::Unit::W, - FuelCell(GeneratorNum).Report.PCUlosses, + DataGenerators::FuelCell(GeneratorNum).Report.PCUlosses, "System", "Average", - FuelCell(GeneratorNum).Name); + DataGenerators::FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Produced DC Electric Power", OutputProcessor::Unit::W, - FuelCell(GeneratorNum).Report.DCPowerGen, + DataGenerators::FuelCell(GeneratorNum).Report.DCPowerGen, "System", "Average", - FuelCell(GeneratorNum).Name); + DataGenerators::FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator DC Power Efficiency", OutputProcessor::Unit::None, - FuelCell(GeneratorNum).Report.DCPowerEff, + DataGenerators::FuelCell(GeneratorNum).Report.DCPowerEff, "System", "Average", - FuelCell(GeneratorNum).Name); + DataGenerators::FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Electric Storage Charge State", OutputProcessor::Unit::J, - FuelCell(GeneratorNum).Report.ElectEnergyinStorage, + DataGenerators::FuelCell(GeneratorNum).Report.ElectEnergyinStorage, "System", "Average", - FuelCell(GeneratorNum).Name); //? 'Sum' + DataGenerators::FuelCell(GeneratorNum).Name); //? 'Sum' SetupOutputVariable("Generator DC Storage Charging Power", OutputProcessor::Unit::W, - FuelCell(GeneratorNum).Report.StoredPower, + DataGenerators::FuelCell(GeneratorNum).Report.StoredPower, "System", "Average", - FuelCell(GeneratorNum).Name); + DataGenerators::FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator DC Storage Charging Energy", OutputProcessor::Unit::J, - FuelCell(GeneratorNum).Report.StoredEnergy, + DataGenerators::FuelCell(GeneratorNum).Report.StoredEnergy, "System", "Sum", - FuelCell(GeneratorNum).Name); + DataGenerators::FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator DC Storage Discharging Power", OutputProcessor::Unit::W, - FuelCell(GeneratorNum).Report.DrawnPower, + DataGenerators::FuelCell(GeneratorNum).Report.DrawnPower, "System", "Average", - FuelCell(GeneratorNum).Name); + DataGenerators::FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator DC Storage Discharging Energy", OutputProcessor::Unit::J, - FuelCell(GeneratorNum).Report.DrawnEnergy, + DataGenerators::FuelCell(GeneratorNum).Report.DrawnEnergy, "System", "Sum", - FuelCell(GeneratorNum).Name); + DataGenerators::FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Ancillary AC Electric Power", OutputProcessor::Unit::W, - FuelCell(GeneratorNum).Report.ACancillariesPower, + DataGenerators::FuelCell(GeneratorNum).Report.ACancillariesPower, "System", "Average", - FuelCell(GeneratorNum).Name); + DataGenerators::FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Ancillary AC Electric Energy", OutputProcessor::Unit::J, - FuelCell(GeneratorNum).Report.ACancillariesEnergy, + DataGenerators::FuelCell(GeneratorNum).Report.ACancillariesEnergy, "System", "Sum", - FuelCell(GeneratorNum).Name); + DataGenerators::FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Fuel Cell Model Iteration Count", OutputProcessor::Unit::None, - FuelCell(GeneratorNum).Report.SeqSubstIterations, + DataGenerators::FuelCell(GeneratorNum).Report.SeqSubstIterations, "System", "Sum", - FuelCell(GeneratorNum).Name); + DataGenerators::FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Root Solver Iteration Count", OutputProcessor::Unit::None, - FuelCell(GeneratorNum).Report.RegulaFalsiIterations, + DataGenerators::FuelCell(GeneratorNum).Report.RegulaFalsiIterations, "System", "Sum", - FuelCell(GeneratorNum).Name); + DataGenerators::FuelCell(GeneratorNum).Name); } } @@ -1392,44 +1353,6 @@ namespace FuelCellElectricGenerator { // REFERENCES: IEA/ECBCS Annex 42.... - using DataGenerators::FuelCell; - using DataGenerators::NumFuelCellGenerators; - using DataGenerators::FCDataStruct; - using DataGenerators::DirectCurveMode; - using DataGenerators::NormalizedCurveMode; - using DataGenerators::ConstantRateSkinLoss; - using DataGenerators::UADTSkinLoss; - using DataGenerators::QuadraticFuelNdotSkin; - using DataGenerators::NumGeneratorFuelSups; - using DataGenerators::FuelSupply; - using DataGenerators::ConstantStoicsAirRat; - using DataGenerators::QuadraticFuncofPel; - using DataGenerators::QuadraticFuncofNdot; - using DataGenerators::RecoverBurnInvertBatt; - using DataGenerators::RecoverAuxiliaryBurner; - using DataGenerators::RecoverInverterBatt; - using DataGenerators::RecoverInverter; - using DataGenerators::RecoverBattery; - using DataGenerators::NoRecoveryOnAirIntake; - using DataGenerators::RegularAir; - using DataGenerators::UserDefinedConstituents; - using DataGenerators::GasPropertyDataStruct; - using DataGenerators::WaterInReformAirNode; - using DataGenerators::WaterInReformWaterNode; - using DataGenerators::WaterInReformMains; - using DataGenerators::WaterInReformSchedule; - using DataGenerators::SurroundingZone; - using DataGenerators::AirInletForFC; - using DataGenerators::FixedEffectiveness; - using DataGenerators::LMTDempiricalUAeff; - using DataGenerators::LMTDfundementalUAeff; - using DataGenerators::Condensing; - using DataGenerators::SimpleEffConstraints; - using DataGenerators::FuelInTempFromNode; - using DataGenerators::FuelInTempSchedule; - using DataGenerators::MinProductGasTemp; - using DataGenerators::MaxProductGasTemp; - static Real64 PpcuLosses; // losses in inverter [W] Real64 Pel; // DC power generated in Fuel Cell Power Module Real64 Pdemand; @@ -1479,35 +1402,35 @@ namespace FuelCellElectricGenerator { // TODO zero out terms as appropriate - if (FuelCell(GeneratorNum).FCPM.HasBeenOn) { + if (DataGenerators::FuelCell(GeneratorNum).FCPM.HasBeenOn) { // FuelCell just now beginning to shut down, // set Day and Time of Last Shut Down - FuelCell(GeneratorNum).FCPM.FractionalDayofLastShutDown = + DataGenerators::FuelCell(GeneratorNum).FCPM.FractionalDayofLastShutDown = double(DataGlobals::DayOfSim) + (int(DataGlobals::CurrentTime) + (DataHVACGlobals::SysTimeElapsed + (DataGlobals::CurrentTime - int(DataGlobals::CurrentTime)))) / DataGlobals::HoursInDay; - FuelCell(GeneratorNum).FCPM.HasBeenOn = false; + DataGenerators::FuelCell(GeneratorNum).FCPM.HasBeenOn = false; - if (FuelCell(GeneratorNum).FCPM.ShutDownTime > 0.0) FuelCell(GeneratorNum).FCPM.DuringShutDown = true; + if (DataGenerators::FuelCell(GeneratorNum).FCPM.ShutDownTime > 0.0) DataGenerators::FuelCell(GeneratorNum).FCPM.DuringShutDown = true; } // TODO check to see if still in shut down mode and using fuel. - if (FuelCell(GeneratorNum).FCPM.DuringShutDown) { + if (DataGenerators::FuelCell(GeneratorNum).FCPM.DuringShutDown) { } return; } - if (!FuelCell(GeneratorNum).FCPM.HasBeenOn) { + if (!DataGenerators::FuelCell(GeneratorNum).FCPM.HasBeenOn) { // fuel cell just turned on // set Day and Time of Last STart Up - FuelCell(GeneratorNum).FCPM.FractionalDayofLastStartUp = + DataGenerators::FuelCell(GeneratorNum).FCPM.FractionalDayofLastStartUp = double(DataGlobals::DayOfSim) + (int(DataGlobals::CurrentTime) + (DataHVACGlobals::SysTimeElapsed + (DataGlobals::CurrentTime - int(DataGlobals::CurrentTime)))) / DataGlobals::HoursInDay; - FuelCell(GeneratorNum).FCPM.HasBeenOn = true; - ++FuelCell(GeneratorNum).FCPM.NumCycles; // increment cycling counter + DataGenerators::FuelCell(GeneratorNum).FCPM.HasBeenOn = true; + ++DataGenerators::FuelCell(GeneratorNum).FCPM.NumCycles; // increment cycling counter - if (FuelCell(GeneratorNum).FCPM.StartUpTime > 0.0) FuelCell(GeneratorNum).FCPM.DuringStartUp = true; + if (DataGenerators::FuelCell(GeneratorNum).FCPM.StartUpTime > 0.0) DataGenerators::FuelCell(GeneratorNum).FCPM.DuringStartUp = true; } // TODO deal with things when jump out if not running? @@ -1540,7 +1463,7 @@ namespace FuelCellElectricGenerator { Pel = Pdemand; } - FuelCell(GeneratorNum).Inverter.PCUlosses = PpcuLosses; + DataGenerators::FuelCell(GeneratorNum).Inverter.PCUlosses = PpcuLosses; // Control step 2: adjust for transient and startup/shut down constraints @@ -1548,277 +1471,277 @@ namespace FuelCellElectricGenerator { // Control step 3: adjust for max and min limits on Pel - if (Pel < FuelCell(GeneratorNum).FCPM.PelMin) { - PelDiff += (FuelCell(GeneratorNum).FCPM.PelMin - Pel); - Pel = FuelCell(GeneratorNum).FCPM.PelMin; + if (Pel < DataGenerators::FuelCell(GeneratorNum).FCPM.PelMin) { + PelDiff += (DataGenerators::FuelCell(GeneratorNum).FCPM.PelMin - Pel); + Pel = DataGenerators::FuelCell(GeneratorNum).FCPM.PelMin; ConstrainedFCPM = true; } - if (Pel > FuelCell(GeneratorNum).FCPM.PelMax) { - PelDiff += (FuelCell(GeneratorNum).FCPM.PelMax - Pel); - Pel = FuelCell(GeneratorNum).FCPM.PelMax; + if (Pel > DataGenerators::FuelCell(GeneratorNum).FCPM.PelMax) { + PelDiff += (DataGenerators::FuelCell(GeneratorNum).FCPM.PelMax - Pel); + Pel = DataGenerators::FuelCell(GeneratorNum).FCPM.PelMax; ConstrainedFCPM = true; } if (ConstrainedFCPM) { } - FuelCell(GeneratorNum).FCPM.Pel = Pel; + DataGenerators::FuelCell(GeneratorNum).FCPM.Pel = Pel; // Now calculate FC models. return to controls and batter after // Calculation Step 1. Determine electrical Efficiency Eel - if (FuelCell(GeneratorNum).FCPM.EffMode == NormalizedCurveMode) { + if (DataGenerators::FuelCell(GeneratorNum).FCPM.EffMode == DataGenerators::NormalizedCurveMode) { // Equation (8) in FuelCell Spec modified for normalized curve - Eel = CurveManager::CurveValue(FuelCell(GeneratorNum).FCPM.EffCurveID, Pel / FuelCell(GeneratorNum).FCPM.NomPel) * - FuelCell(GeneratorNum).FCPM.NomEff * - (1.0 - FuelCell(GeneratorNum).FCPM.NumCycles * FuelCell(GeneratorNum).FCPM.CyclingDegradRat) * - (1.0 - max((FuelCell(GeneratorNum).FCPM.NumRunHours - FuelCell(GeneratorNum).FCPM.ThreshRunHours), 0.0) * - FuelCell(GeneratorNum).FCPM.OperateDegradRat); + Eel = CurveManager::CurveValue(DataGenerators::FuelCell(GeneratorNum).FCPM.EffCurveID, Pel / DataGenerators::FuelCell(GeneratorNum).FCPM.NomPel) * + DataGenerators::FuelCell(GeneratorNum).FCPM.NomEff * + (1.0 - DataGenerators::FuelCell(GeneratorNum).FCPM.NumCycles * DataGenerators::FuelCell(GeneratorNum).FCPM.CyclingDegradRat) * + (1.0 - max((DataGenerators::FuelCell(GeneratorNum).FCPM.NumRunHours - DataGenerators::FuelCell(GeneratorNum).FCPM.ThreshRunHours), 0.0) * + DataGenerators::FuelCell(GeneratorNum).FCPM.OperateDegradRat); - } else if (FuelCell(GeneratorNum).FCPM.EffMode == DirectCurveMode) { - // Equation (8) in FuelCell Spec - Eel = CurveManager::CurveValue(FuelCell(GeneratorNum).FCPM.EffCurveID, Pel) * - (1.0 - FuelCell(GeneratorNum).FCPM.NumCycles * FuelCell(GeneratorNum).FCPM.CyclingDegradRat) * - (1.0 - max((FuelCell(GeneratorNum).FCPM.NumRunHours - FuelCell(GeneratorNum).FCPM.ThreshRunHours), 0.0) * - FuelCell(GeneratorNum).FCPM.OperateDegradRat); + } else if (DataGenerators::FuelCell(GeneratorNum).FCPM.EffMode == DataGenerators::DirectCurveMode) { + // Equation (8) in DataGenerators::FuelCell Spec + Eel = CurveManager::CurveValue(DataGenerators::FuelCell(GeneratorNum).FCPM.EffCurveID, Pel) * + (1.0 - DataGenerators::FuelCell(GeneratorNum).FCPM.NumCycles * DataGenerators::FuelCell(GeneratorNum).FCPM.CyclingDegradRat) * + (1.0 - max((DataGenerators::FuelCell(GeneratorNum).FCPM.NumRunHours - DataGenerators::FuelCell(GeneratorNum).FCPM.ThreshRunHours), 0.0) * + DataGenerators::FuelCell(GeneratorNum).FCPM.OperateDegradRat); } - FuelCell(GeneratorNum).FCPM.Eel = Eel; + DataGenerators::FuelCell(GeneratorNum).FCPM.Eel = Eel; // Calculation Step 2. Determine fuel rate - NdotFuel = Pel / (Eel * FuelSupply(FuelCell(GeneratorNum).FuelSupNum).LHV * 1000000.0); // Eq. 10 solved for Ndot + NdotFuel = Pel / (Eel * DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).LHV * 1000000.0); // Eq. 10 solved for Ndot - FuelCell(GeneratorNum).FCPM.NdotFuel = NdotFuel; + DataGenerators::FuelCell(GeneratorNum).FCPM.NdotFuel = NdotFuel; if (Pel <= 0.0) { // TODO zero stuff before leaving Pel = 0.0; - FuelCell(GeneratorNum).FCPM.Pel = 0.0; + DataGenerators::FuelCell(GeneratorNum).FCPM.Pel = 0.0; return; } else { - FuelCell(GeneratorNum).FCPM.Pel = Pel; + DataGenerators::FuelCell(GeneratorNum).FCPM.Pel = Pel; } // Calculation Step 3. Determine Air rate - if (FuelCell(GeneratorNum).AirSup.AirSupRateMode == ConstantStoicsAirRat) { // MEthod 1 - NdotO2 = FuelSupply(FuelCell(GeneratorNum).FuelSupNum).StoicOxygenRate * FuelCell(GeneratorNum).FCPM.NdotFuel * - FuelCell(GeneratorNum).AirSup.Stoics; + if (DataGenerators::FuelCell(GeneratorNum).AirSup.AirSupRateMode == DataGenerators::ConstantStoicsAirRat) { // MEthod 1 + NdotO2 = DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).StoicOxygenRate * DataGenerators::FuelCell(GeneratorNum).FCPM.NdotFuel * + DataGenerators::FuelCell(GeneratorNum).AirSup.Stoics; - FuelCell(GeneratorNum).FCPM.NdotAir = NdotO2 / FuelCell(GeneratorNum).AirSup.O2fraction; + DataGenerators::FuelCell(GeneratorNum).FCPM.NdotAir = NdotO2 / DataGenerators::FuelCell(GeneratorNum).AirSup.O2fraction; - } else if (FuelCell(GeneratorNum).AirSup.AirSupRateMode == QuadraticFuncofPel) { // MEthod 2 + } else if (DataGenerators::FuelCell(GeneratorNum).AirSup.AirSupRateMode == DataGenerators::QuadraticFuncofPel) { // MEthod 2 - FuelCell(GeneratorNum).FCPM.NdotAir = CurveManager::CurveValue(FuelCell(GeneratorNum).AirSup.AirFuncPelCurveID, Pel) * - (1 + FuelCell(GeneratorNum).AirSup.AirTempCoeff * FuelCell(GeneratorNum).AirSup.TairIntoFCPM); + DataGenerators::FuelCell(GeneratorNum).FCPM.NdotAir = CurveManager::CurveValue(DataGenerators::FuelCell(GeneratorNum).AirSup.AirFuncPelCurveID, Pel) * + (1 + DataGenerators::FuelCell(GeneratorNum).AirSup.AirTempCoeff * DataGenerators::FuelCell(GeneratorNum).AirSup.TairIntoFCPM); - } else if (FuelCell(GeneratorNum).AirSup.AirSupRateMode == QuadraticFuncofNdot) { // method 3 - FuelCell(GeneratorNum).FCPM.NdotAir = - CurveManager::CurveValue(FuelCell(GeneratorNum).AirSup.AirFuncNdotCurveID, FuelCell(GeneratorNum).FCPM.NdotFuel) * - (1 + FuelCell(GeneratorNum).AirSup.AirTempCoeff * FuelCell(GeneratorNum).AirSup.TairIntoFCPM); + } else if (DataGenerators::FuelCell(GeneratorNum).AirSup.AirSupRateMode == DataGenerators::QuadraticFuncofNdot) { // method 3 + DataGenerators::FuelCell(GeneratorNum).FCPM.NdotAir = + CurveManager::CurveValue(DataGenerators::FuelCell(GeneratorNum).AirSup.AirFuncNdotCurveID, DataGenerators::FuelCell(GeneratorNum).FCPM.NdotFuel) * + (1 + DataGenerators::FuelCell(GeneratorNum).AirSup.AirTempCoeff * DataGenerators::FuelCell(GeneratorNum).AirSup.TairIntoFCPM); } // Calculation Step 4. fuel compressor power - FuelSupply(FuelCell(GeneratorNum).FuelSupNum).PfuelCompEl = - CurveManager::CurveValue(FuelSupply(FuelCell(GeneratorNum).FuelSupNum).CompPowerCurveID, FuelCell(GeneratorNum).FCPM.NdotFuel); + DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).PfuelCompEl = + CurveManager::CurveValue(DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).CompPowerCurveID, DataGenerators::FuelCell(GeneratorNum).FCPM.NdotFuel); // calculation Step 5, Fuel Compressor (need outlet temperature) - if (FuelSupply(FuelCell(GeneratorNum).FuelSupNum).FuelTempMode == FuelInTempFromNode) { + if (DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).FuelTempMode == DataGenerators::FuelInTempFromNode) { - FuelSupply(FuelCell(GeneratorNum).FuelSupNum).TfuelIntoCompress = DataLoopNode::Node(FuelSupply(FuelCell(GeneratorNum).FuelSupNum).NodeNum).Temp; + DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).TfuelIntoCompress = DataLoopNode::Node(DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).NodeNum).Temp; - } else if (FuelSupply(FuelCell(GeneratorNum).FuelSupNum).FuelTempMode == FuelInTempSchedule) { + } else if (DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).FuelTempMode == DataGenerators::FuelInTempSchedule) { - FuelSupply(FuelCell(GeneratorNum).FuelSupNum).TfuelIntoCompress = - ScheduleManager::GetCurrentScheduleValue(FuelSupply(FuelCell(GeneratorNum).FuelSupNum).SchedNum); + DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).TfuelIntoCompress = + ScheduleManager::GetCurrentScheduleValue(DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).SchedNum); } // evaluate heat capacity at average temperature usign shomate Tavg = - (FuelSupply(FuelCell(GeneratorNum).FuelSupNum).TfuelIntoCompress + FuelSupply(FuelCell(GeneratorNum).FuelSupNum).TfuelIntoFCPM) / 2.0; + (DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).TfuelIntoCompress + DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).TfuelIntoFCPM) / 2.0; FigureFuelHeatCap(GeneratorNum, Tavg, Cp); // Cp in (J/mol K) // calculate a Temp of fuel out of compressor and into power module - if (FuelCell(GeneratorNum).FCPM.NdotFuel <= 0.0) { // just pass through, domain probably collapased in modeling - FuelSupply(FuelCell(GeneratorNum).FuelSupNum).TfuelIntoFCPM = FuelSupply(FuelCell(GeneratorNum).FuelSupNum).TfuelIntoCompress; + if (DataGenerators::FuelCell(GeneratorNum).FCPM.NdotFuel <= 0.0) { // just pass through, domain probably collapased in modeling + DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).TfuelIntoFCPM = DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).TfuelIntoCompress; } else { - FuelSupply(FuelCell(GeneratorNum).FuelSupNum).TfuelIntoFCPM = - ((1.0 - FuelSupply(FuelCell(GeneratorNum).FuelSupNum).CompPowerLossFactor) * - FuelSupply(FuelCell(GeneratorNum).FuelSupNum).PfuelCompEl / (FuelCell(GeneratorNum).FCPM.NdotFuel * Cp * 1000.0)) + - FuelSupply(FuelCell(GeneratorNum).FuelSupNum).TfuelIntoCompress; // 1000 Cp units mol-> kmol + DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).TfuelIntoFCPM = + ((1.0 - DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).CompPowerLossFactor) * + DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).PfuelCompEl / (DataGenerators::FuelCell(GeneratorNum).FCPM.NdotFuel * Cp * 1000.0)) + + DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).TfuelIntoCompress; // 1000 Cp units mol-> kmol } // calc skin losses from fuel compressor - FuelSupply(FuelCell(GeneratorNum).FuelSupNum).QskinLoss = - FuelSupply(FuelCell(GeneratorNum).FuelSupNum).CompPowerLossFactor * FuelSupply(FuelCell(GeneratorNum).FuelSupNum).PfuelCompEl; + DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).QskinLoss = + DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).CompPowerLossFactor * DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).PfuelCompEl; - if (FuelSupply(FuelCell(GeneratorNum).FuelSupNum).QskinLoss < 0.0) { - // write(*,*) 'problem in FuelSupply%QskinLoss ', FuelSupply(FuelCell(GeneratorNum)%FuelSupNum)%QskinLoss - ShowWarningError("problem in FuelSupply%QskinLoss " + General::RoundSigDigits(FuelSupply(FuelCell(GeneratorNum).FuelSupNum).QskinLoss, 3)); - FuelSupply(FuelCell(GeneratorNum).FuelSupNum).QskinLoss = 0.0; + if (DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).QskinLoss < 0.0) { + // write(*,*) 'problem in FuelSupply%QskinLoss ', FuelSupply(DataGenerators::FuelCell(GeneratorNum)%FuelSupNum)%QskinLoss + ShowWarningError("problem in FuelSupply%QskinLoss " + General::RoundSigDigits(DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).QskinLoss, 3)); + DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).QskinLoss = 0.0; } // calculate tatal fuel enthalpy coming into power module // (Hmolfuel in KJ/mol) - FigureFuelEnthalpy(GeneratorNum, FuelSupply(FuelCell(GeneratorNum).FuelSupNum).TfuelIntoFCPM, Hmolfuel); + FigureFuelEnthalpy(GeneratorNum, DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).TfuelIntoFCPM, Hmolfuel); // units, NdotFuel in kmol/sec. Hmolfule in KJ/mol , // factor of 1000's to get to J/s or watts - FuelCell(GeneratorNum).FCPM.TotFuelInEnthalphy = Hmolfuel * 1000.0 * FuelCell(GeneratorNum).FCPM.NdotFuel * 1000.0; + DataGenerators::FuelCell(GeneratorNum).FCPM.TotFuelInEnthalphy = Hmolfuel * 1000.0 * DataGenerators::FuelCell(GeneratorNum).FCPM.NdotFuel * 1000.0; // Calculation Step 6, water compressor calculations // calculate water consumption - FuelCell(GeneratorNum).FCPM.NdotLiqwater = - CurveManager::CurveValue(FuelCell(GeneratorNum).WaterSup.WaterSupRateCurveID, FuelCell(GeneratorNum).FCPM.NdotFuel); + DataGenerators::FuelCell(GeneratorNum).FCPM.NdotLiqwater = + CurveManager::CurveValue(DataGenerators::FuelCell(GeneratorNum).WaterSup.WaterSupRateCurveID, DataGenerators::FuelCell(GeneratorNum).FCPM.NdotFuel); // set inlet temp. (could move to init) { - auto const SELECT_CASE_var(FuelCell(GeneratorNum).WaterSup.WaterTempMode); + auto const SELECT_CASE_var(DataGenerators::FuelCell(GeneratorNum).WaterSup.WaterTempMode); - if (SELECT_CASE_var == WaterInReformMains) { + if (SELECT_CASE_var == DataGenerators::WaterInReformMains) { - FuelCell(GeneratorNum).WaterSup.TwaterIntoCompress = DataEnvironment::WaterMainsTemp; + DataGenerators::FuelCell(GeneratorNum).WaterSup.TwaterIntoCompress = DataEnvironment::WaterMainsTemp; - } else if ((SELECT_CASE_var == WaterInReformAirNode) || (SELECT_CASE_var == WaterInReformWaterNode)) { + } else if ((SELECT_CASE_var == DataGenerators::WaterInReformAirNode) || (SELECT_CASE_var == DataGenerators::WaterInReformWaterNode)) { - FuelCell(GeneratorNum).WaterSup.TwaterIntoCompress = DataLoopNode::Node(FuelCell(GeneratorNum).WaterSup.NodeNum).Temp; + DataGenerators::FuelCell(GeneratorNum).WaterSup.TwaterIntoCompress = DataLoopNode::Node(DataGenerators::FuelCell(GeneratorNum).WaterSup.NodeNum).Temp; - } else if (SELECT_CASE_var == WaterInReformSchedule) { + } else if (SELECT_CASE_var == DataGenerators::WaterInReformSchedule) { - FuelCell(GeneratorNum).WaterSup.TwaterIntoCompress = ScheduleManager::GetCurrentScheduleValue(FuelCell(GeneratorNum).WaterSup.SchedNum); + DataGenerators::FuelCell(GeneratorNum).WaterSup.TwaterIntoCompress = ScheduleManager::GetCurrentScheduleValue(DataGenerators::FuelCell(GeneratorNum).WaterSup.SchedNum); } } - FuelCell(GeneratorNum).WaterSup.PwaterCompEl = - CurveManager::CurveValue(FuelCell(GeneratorNum).WaterSup.PmpPowerCurveID, FuelCell(GeneratorNum).FCPM.NdotLiqwater); + DataGenerators::FuelCell(GeneratorNum).WaterSup.PwaterCompEl = + CurveManager::CurveValue(DataGenerators::FuelCell(GeneratorNum).WaterSup.PmpPowerCurveID, DataGenerators::FuelCell(GeneratorNum).FCPM.NdotLiqwater); // 75.325 J/mol K Water at 0.1 MPa and 298 K, reference NIST WEBBOOK - FigureLiquidWaterHeatCap(FuelCell(GeneratorNum).WaterSup.TwaterIntoCompress, CpWater); + FigureLiquidWaterHeatCap(DataGenerators::FuelCell(GeneratorNum).WaterSup.TwaterIntoCompress, CpWater); WaterEnthOfForm = -241.8264; // KJ/mol - if (FuelCell(GeneratorNum).FCPM.NdotLiqwater <= 0.0) { // just pass through, domain probably collapased in modeling - FuelCell(GeneratorNum).WaterSup.TwaterIntoFCPM = FuelCell(GeneratorNum).WaterSup.TwaterIntoCompress; + if (DataGenerators::FuelCell(GeneratorNum).FCPM.NdotLiqwater <= 0.0) { // just pass through, domain probably collapased in modeling + DataGenerators::FuelCell(GeneratorNum).WaterSup.TwaterIntoFCPM = DataGenerators::FuelCell(GeneratorNum).WaterSup.TwaterIntoCompress; } else { - FuelCell(GeneratorNum).WaterSup.TwaterIntoFCPM = - ((1 - FuelCell(GeneratorNum).WaterSup.PmpPowerLossFactor) * FuelCell(GeneratorNum).WaterSup.PwaterCompEl / - (FuelCell(GeneratorNum).FCPM.NdotLiqwater * CpWater * 1000.0)) + - FuelCell(GeneratorNum).WaterSup.TwaterIntoCompress; + DataGenerators::FuelCell(GeneratorNum).WaterSup.TwaterIntoFCPM = + ((1 - DataGenerators::FuelCell(GeneratorNum).WaterSup.PmpPowerLossFactor) * DataGenerators::FuelCell(GeneratorNum).WaterSup.PwaterCompEl / + (DataGenerators::FuelCell(GeneratorNum).FCPM.NdotLiqwater * CpWater * 1000.0)) + + DataGenerators::FuelCell(GeneratorNum).WaterSup.TwaterIntoCompress; } - FuelCell(GeneratorNum).WaterSup.QskinLoss = - FuelCell(GeneratorNum).WaterSup.PmpPowerLossFactor * FuelCell(GeneratorNum).WaterSup.PwaterCompEl; + DataGenerators::FuelCell(GeneratorNum).WaterSup.QskinLoss = + DataGenerators::FuelCell(GeneratorNum).WaterSup.PmpPowerLossFactor * DataGenerators::FuelCell(GeneratorNum).WaterSup.PwaterCompEl; - if (FuelCell(GeneratorNum).WaterSup.QskinLoss < 0.0) { - // write(*,*) 'problem in WaterSup%QskinLoss ',FuelCell(GeneratorNum)%WaterSup%QskinLoss - FuelCell(GeneratorNum).WaterSup.QskinLoss = 0.0; + if (DataGenerators::FuelCell(GeneratorNum).WaterSup.QskinLoss < 0.0) { + // write(*,*) 'problem in WaterSup%QskinLoss ',DataGenerators::FuelCell(GeneratorNum)%WaterSup%QskinLoss + DataGenerators::FuelCell(GeneratorNum).WaterSup.QskinLoss = 0.0; } - FigureLiquidWaterEnthalpy(FuelCell(GeneratorNum).WaterSup.TwaterIntoFCPM, HLiqWater); // HLiqWater in KJ/mol + FigureLiquidWaterEnthalpy(DataGenerators::FuelCell(GeneratorNum).WaterSup.TwaterIntoFCPM, HLiqWater); // HLiqWater in KJ/mol - FuelCell(GeneratorNum).FCPM.WaterInEnthalpy = FuelCell(GeneratorNum).FCPM.NdotLiqwater * HLiqWater * 1000.0 * 1000.0; + DataGenerators::FuelCell(GeneratorNum).FCPM.WaterInEnthalpy = DataGenerators::FuelCell(GeneratorNum).FCPM.NdotLiqwater * HLiqWater * 1000.0 * 1000.0; // Calculation Step 7, Air compressor - FuelCell(GeneratorNum).AirSup.TairIntoBlower = DataLoopNode::Node(FuelCell(GeneratorNum).AirSup.SupNodeNum).Temp; + DataGenerators::FuelCell(GeneratorNum).AirSup.TairIntoBlower = DataLoopNode::Node(DataGenerators::FuelCell(GeneratorNum).AirSup.SupNodeNum).Temp; - FuelCell(GeneratorNum).AirSup.PairCompEl = - CurveManager::CurveValue(FuelCell(GeneratorNum).AirSup.BlowerPowerCurveID, FuelCell(GeneratorNum).FCPM.NdotAir); + DataGenerators::FuelCell(GeneratorNum).AirSup.PairCompEl = + CurveManager::CurveValue(DataGenerators::FuelCell(GeneratorNum).AirSup.BlowerPowerCurveID, DataGenerators::FuelCell(GeneratorNum).FCPM.NdotAir); - Tavg = (FuelCell(GeneratorNum).AirSup.TairIntoBlower + FuelCell(GeneratorNum).AirSup.TairIntoFCPM) / 2.0; + Tavg = (DataGenerators::FuelCell(GeneratorNum).AirSup.TairIntoBlower + DataGenerators::FuelCell(GeneratorNum).AirSup.TairIntoFCPM) / 2.0; FigureAirHeatCap(GeneratorNum, Tavg, Cp); // Cp in (J/mol K) // if PEMFC with stack cooler, then calculate stack cooler impacts - if (FuelCell(GeneratorNum).StackCooler.StackCoolerPresent) { + if (DataGenerators::FuelCell(GeneratorNum).StackCooler.StackCoolerPresent) { - FuelCell(GeneratorNum).StackCooler.qs_cool = - (FuelCell(GeneratorNum).StackCooler.r0 + - FuelCell(GeneratorNum).StackCooler.r1 * - (FuelCell(GeneratorNum).StackCooler.TstackActual - FuelCell(GeneratorNum).StackCooler.TstackNom)) * - (1 + FuelCell(GeneratorNum).StackCooler.r2 * Pel + FuelCell(GeneratorNum).StackCooler.r3 * Pel * Pel) * Pel; + DataGenerators::FuelCell(GeneratorNum).StackCooler.qs_cool = + (DataGenerators::FuelCell(GeneratorNum).StackCooler.r0 + + DataGenerators::FuelCell(GeneratorNum).StackCooler.r1 * + (DataGenerators::FuelCell(GeneratorNum).StackCooler.TstackActual - DataGenerators::FuelCell(GeneratorNum).StackCooler.TstackNom)) * + (1 + DataGenerators::FuelCell(GeneratorNum).StackCooler.r2 * Pel + DataGenerators::FuelCell(GeneratorNum).StackCooler.r3 * Pel * Pel) * Pel; - FuelCell(GeneratorNum).FCPM.QdotStackCool = FuelCell(GeneratorNum).StackCooler.qs_cool; + DataGenerators::FuelCell(GeneratorNum).FCPM.QdotStackCool = DataGenerators::FuelCell(GeneratorNum).StackCooler.qs_cool; } // Figure heat recovery from Electrical Storage, power conditioning, and auxiliary burner { - auto const SELECT_CASE_var(FuelCell(GeneratorNum).AirSup.IntakeRecoveryMode); - - if (SELECT_CASE_var == RecoverBurnInvertBatt) { - FuelCell(GeneratorNum).AirSup.QintakeRecovery = FuelCell(GeneratorNum).AuxilHeat.QairIntake + - FuelCell(GeneratorNum).ElecStorage.QairIntake + - FuelCell(GeneratorNum).Inverter.QairIntake; - } else if (SELECT_CASE_var == RecoverAuxiliaryBurner) { - FuelCell(GeneratorNum).AirSup.QintakeRecovery = FuelCell(GeneratorNum).AuxilHeat.QairIntake; - } else if (SELECT_CASE_var == RecoverInverterBatt) { - FuelCell(GeneratorNum).AirSup.QintakeRecovery = - FuelCell(GeneratorNum).ElecStorage.QairIntake + FuelCell(GeneratorNum).Inverter.QairIntake; - } else if (SELECT_CASE_var == RecoverInverter) { - FuelCell(GeneratorNum).AirSup.QintakeRecovery = FuelCell(GeneratorNum).Inverter.QairIntake; - } else if (SELECT_CASE_var == RecoverBattery) { - FuelCell(GeneratorNum).AirSup.QintakeRecovery = FuelCell(GeneratorNum).ElecStorage.QairIntake; - } else if (SELECT_CASE_var == NoRecoveryOnAirIntake) { - FuelCell(GeneratorNum).AirSup.QintakeRecovery = 0.0; + auto const SELECT_CASE_var(DataGenerators::FuelCell(GeneratorNum).AirSup.IntakeRecoveryMode); + + if (SELECT_CASE_var == DataGenerators::RecoverBurnInvertBatt) { + DataGenerators::FuelCell(GeneratorNum).AirSup.QintakeRecovery = DataGenerators::FuelCell(GeneratorNum).AuxilHeat.QairIntake + + DataGenerators::FuelCell(GeneratorNum).ElecStorage.QairIntake + + DataGenerators::FuelCell(GeneratorNum).Inverter.QairIntake; + } else if (SELECT_CASE_var == DataGenerators::RecoverAuxiliaryBurner) { + DataGenerators::FuelCell(GeneratorNum).AirSup.QintakeRecovery = DataGenerators::FuelCell(GeneratorNum).AuxilHeat.QairIntake; + } else if (SELECT_CASE_var == DataGenerators::RecoverInverterBatt) { + DataGenerators::FuelCell(GeneratorNum).AirSup.QintakeRecovery = + DataGenerators::FuelCell(GeneratorNum).ElecStorage.QairIntake + DataGenerators::FuelCell(GeneratorNum).Inverter.QairIntake; + } else if (SELECT_CASE_var == DataGenerators::RecoverInverter) { + DataGenerators::FuelCell(GeneratorNum).AirSup.QintakeRecovery = DataGenerators::FuelCell(GeneratorNum).Inverter.QairIntake; + } else if (SELECT_CASE_var == DataGenerators::RecoverBattery) { + DataGenerators::FuelCell(GeneratorNum).AirSup.QintakeRecovery = DataGenerators::FuelCell(GeneratorNum).ElecStorage.QairIntake; + } else if (SELECT_CASE_var == DataGenerators::NoRecoveryOnAirIntake) { + DataGenerators::FuelCell(GeneratorNum).AirSup.QintakeRecovery = 0.0; } } - if (FuelCell(GeneratorNum).FCPM.NdotAir <= 0.0) { // just pass through, domain probably collapased in modeling - FuelCell(GeneratorNum).AirSup.TairIntoFCPM = FuelCell(GeneratorNum).AirSup.TairIntoBlower; + if (DataGenerators::FuelCell(GeneratorNum).FCPM.NdotAir <= 0.0) { // just pass through, domain probably collapased in modeling + DataGenerators::FuelCell(GeneratorNum).AirSup.TairIntoFCPM = DataGenerators::FuelCell(GeneratorNum).AirSup.TairIntoBlower; } else { - FuelCell(GeneratorNum).AirSup.TairIntoFCPM = - (((1 - FuelCell(GeneratorNum).AirSup.BlowerHeatLossFactor) * FuelCell(GeneratorNum).AirSup.PairCompEl + - FuelCell(GeneratorNum).AirSup.QintakeRecovery) / - (FuelCell(GeneratorNum).FCPM.NdotAir * Cp * 1000.0)) + - FuelCell(GeneratorNum).AirSup.TairIntoBlower; // 1000 Cp units mol-> kmol + DataGenerators::FuelCell(GeneratorNum).AirSup.TairIntoFCPM = + (((1 - DataGenerators::FuelCell(GeneratorNum).AirSup.BlowerHeatLossFactor) * DataGenerators::FuelCell(GeneratorNum).AirSup.PairCompEl + + DataGenerators::FuelCell(GeneratorNum).AirSup.QintakeRecovery) / + (DataGenerators::FuelCell(GeneratorNum).FCPM.NdotAir * Cp * 1000.0)) + + DataGenerators::FuelCell(GeneratorNum).AirSup.TairIntoBlower; // 1000 Cp units mol-> kmol } - FuelCell(GeneratorNum).AirSup.QskinLoss = FuelCell(GeneratorNum).AirSup.BlowerHeatLossFactor * FuelCell(GeneratorNum).AirSup.PairCompEl; + DataGenerators::FuelCell(GeneratorNum).AirSup.QskinLoss = DataGenerators::FuelCell(GeneratorNum).AirSup.BlowerHeatLossFactor * DataGenerators::FuelCell(GeneratorNum).AirSup.PairCompEl; - if (FuelCell(GeneratorNum).AirSup.QskinLoss < 0.0) { - // write(*,*) 'problem in AirSup%QskinLoss ', FuelCell(GeneratorNum)%AirSup%QskinLoss - ShowWarningError("problem in AirSup%QskinLoss " + General::RoundSigDigits(FuelCell(GeneratorNum).AirSup.QskinLoss, 3)); - FuelCell(GeneratorNum).AirSup.QskinLoss = 0.0; + if (DataGenerators::FuelCell(GeneratorNum).AirSup.QskinLoss < 0.0) { + // write(*,*) 'problem in AirSup%QskinLoss ', DataGenerators::FuelCell(GeneratorNum)%AirSup%QskinLoss + ShowWarningError("problem in AirSup%QskinLoss " + General::RoundSigDigits(DataGenerators::FuelCell(GeneratorNum).AirSup.QskinLoss, 3)); + DataGenerators::FuelCell(GeneratorNum).AirSup.QskinLoss = 0.0; } - FigureAirEnthalpy(GeneratorNum, FuelCell(GeneratorNum).AirSup.TairIntoFCPM, Hmolair); // (Hmolair in KJ/mol) + FigureAirEnthalpy(GeneratorNum, DataGenerators::FuelCell(GeneratorNum).AirSup.TairIntoFCPM, Hmolair); // (Hmolair in KJ/mol) // units, NdotAir in kmol/sec.; Hmolfuel in KJ/mol , // factor of 1000's to get to J/s or watts - FuelCell(GeneratorNum).FCPM.TotAirInEnthalphy = Hmolair * 1000.0 * FuelCell(GeneratorNum).FCPM.NdotAir * 1000.0; + DataGenerators::FuelCell(GeneratorNum).FCPM.TotAirInEnthalphy = Hmolair * 1000.0 * DataGenerators::FuelCell(GeneratorNum).FCPM.NdotAir * 1000.0; // calculation Step 8, Figure Product Gases // figure stoic N dot for air - NdotO2 = FuelSupply(FuelCell(GeneratorNum).FuelSupNum).StoicOxygenRate * FuelCell(GeneratorNum).FCPM.NdotFuel; + NdotO2 = DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).StoicOxygenRate * DataGenerators::FuelCell(GeneratorNum).FCPM.NdotFuel; - NdotStoicAir = NdotO2 / FuelCell(GeneratorNum).AirSup.O2fraction; + NdotStoicAir = NdotO2 / DataGenerators::FuelCell(GeneratorNum).AirSup.O2fraction; // figure excess air rate - NdotExcessAir = FuelCell(GeneratorNum).FCPM.NdotAir - NdotStoicAir; + NdotExcessAir = DataGenerators::FuelCell(GeneratorNum).FCPM.NdotAir - NdotStoicAir; if (NdotExcessAir < 0) { // can't meet stoichiometric fuel reaction ShowWarningError("Air flow rate into fuel cell is too low for stoichiometric fuel reaction"); - ShowContinueError("Increase air flow in GENERATOR:FC:AIR SUPPLY object:" + FuelCell(GeneratorNum).AirSup.Name); + ShowContinueError("Increase air flow in GENERATOR:FC:AIR SUPPLY object:" + DataGenerators::FuelCell(GeneratorNum).AirSup.Name); } // figure CO2 and Water rate from products (coefs setup during one-time processing in gas phase library ) - NdotCO2ProdGas = FuelCell(GeneratorNum).FCPM.NdotFuel * FuelSupply(FuelCell(GeneratorNum).FuelSupNum).CO2ProductGasCoef; + NdotCO2ProdGas = DataGenerators::FuelCell(GeneratorNum).FCPM.NdotFuel * DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).CO2ProductGasCoef; - NdotH20ProdGas = FuelCell(GeneratorNum).FCPM.NdotFuel * FuelSupply(FuelCell(GeneratorNum).FuelSupNum).H20ProductGasCoef; + NdotH20ProdGas = DataGenerators::FuelCell(GeneratorNum).FCPM.NdotFuel * DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).H20ProductGasCoef; // set product gas constituent fractions (assume five usual components) NdotCO2 = 0.0; @@ -1829,113 +1752,113 @@ namespace FuelCellElectricGenerator { // Product gas constiuents are fixed (not a user defined thing) - for (thisGas = 1; thisGas <= FuelCell(GeneratorNum).AirSup.NumConstituents; ++thisGas) { + for (thisGas = 1; thisGas <= DataGenerators::FuelCell(GeneratorNum).AirSup.NumConstituents; ++thisGas) { { - auto const SELECT_CASE_var(FuelCell(GeneratorNum).AirSup.GasLibID(thisGas)); + auto const SELECT_CASE_var(DataGenerators::FuelCell(GeneratorNum).AirSup.GasLibID(thisGas)); if (SELECT_CASE_var == 1) { // all the CO2 coming in plus the new CO2 from reactions - NdotCO2 = NdotCO2ProdGas + FuelCell(GeneratorNum).AirSup.ConstitMolalFract(thisGas) * FuelCell(GeneratorNum).FCPM.NdotAir; + NdotCO2 = NdotCO2ProdGas + DataGenerators::FuelCell(GeneratorNum).AirSup.ConstitMolalFract(thisGas) * DataGenerators::FuelCell(GeneratorNum).FCPM.NdotAir; } else if (SELECT_CASE_var == 2) { // all the nitrogen coming in - NdotN2 = FuelCell(GeneratorNum).FCPM.NdotAir * FuelCell(GeneratorNum).AirSup.ConstitMolalFract(thisGas); + NdotN2 = DataGenerators::FuelCell(GeneratorNum).FCPM.NdotAir * DataGenerators::FuelCell(GeneratorNum).AirSup.ConstitMolalFract(thisGas); } else if (SELECT_CASE_var == 3) { // all the oxygen in the excess air stream - Ndot02 = NdotExcessAir * FuelCell(GeneratorNum).AirSup.ConstitMolalFract(thisGas); + Ndot02 = NdotExcessAir * DataGenerators::FuelCell(GeneratorNum).AirSup.ConstitMolalFract(thisGas); } else if (SELECT_CASE_var == 4) { // all the H20 coming in plus the new H20 from reactions and the H20 from water used in reforming - NdotH20 = NdotH20ProdGas + FuelCell(GeneratorNum).AirSup.ConstitMolalFract(thisGas) * FuelCell(GeneratorNum).FCPM.NdotAir; - //+ FuelCell(GeneratorNum)%FCPM%NdotLiqwater + NdotH20 = NdotH20ProdGas + DataGenerators::FuelCell(GeneratorNum).AirSup.ConstitMolalFract(thisGas) * DataGenerators::FuelCell(GeneratorNum).FCPM.NdotAir; + //+ DataGenerators::FuelCell(GeneratorNum)%FCPM%NdotLiqwater } else if (SELECT_CASE_var == 5) { // all the argon coming in. - NdotAr = FuelCell(GeneratorNum).FCPM.NdotAir * FuelCell(GeneratorNum).AirSup.ConstitMolalFract(thisGas); + NdotAr = DataGenerators::FuelCell(GeneratorNum).FCPM.NdotAir * DataGenerators::FuelCell(GeneratorNum).AirSup.ConstitMolalFract(thisGas); } else { } } } - FuelCell(GeneratorNum).FCPM.NdotProdGas = NdotCO2 + NdotN2 + Ndot02 + NdotH20 + NdotAr; + DataGenerators::FuelCell(GeneratorNum).FCPM.NdotProdGas = NdotCO2 + NdotN2 + Ndot02 + NdotH20 + NdotAr; // now that we have the total, figure molar fractions - FuelCell(GeneratorNum).FCPM.ConstitMolalFract(1) = NdotCO2 / FuelCell(GeneratorNum).FCPM.NdotProdGas; + DataGenerators::FuelCell(GeneratorNum).FCPM.ConstitMolalFract(1) = NdotCO2 / DataGenerators::FuelCell(GeneratorNum).FCPM.NdotProdGas; // all the nitrogen comming in - FuelCell(GeneratorNum).FCPM.ConstitMolalFract(2) = NdotN2 / FuelCell(GeneratorNum).FCPM.NdotProdGas; + DataGenerators::FuelCell(GeneratorNum).FCPM.ConstitMolalFract(2) = NdotN2 / DataGenerators::FuelCell(GeneratorNum).FCPM.NdotProdGas; // all the oxygen in the excess air stream - FuelCell(GeneratorNum).FCPM.ConstitMolalFract(3) = Ndot02 / FuelCell(GeneratorNum).FCPM.NdotProdGas; + DataGenerators::FuelCell(GeneratorNum).FCPM.ConstitMolalFract(3) = Ndot02 / DataGenerators::FuelCell(GeneratorNum).FCPM.NdotProdGas; // all the H20 comming in plus the new H20 from reactions and the H20 from water used in reforming - FuelCell(GeneratorNum).FCPM.ConstitMolalFract(4) = NdotH20 / FuelCell(GeneratorNum).FCPM.NdotProdGas; + DataGenerators::FuelCell(GeneratorNum).FCPM.ConstitMolalFract(4) = NdotH20 / DataGenerators::FuelCell(GeneratorNum).FCPM.NdotProdGas; // all the argon coming in. - FuelCell(GeneratorNum).FCPM.ConstitMolalFract(5) = NdotAr / FuelCell(GeneratorNum).FCPM.NdotProdGas; + DataGenerators::FuelCell(GeneratorNum).FCPM.ConstitMolalFract(5) = NdotAr / DataGenerators::FuelCell(GeneratorNum).FCPM.NdotProdGas; // HmolProdGases KJ/mol) - FigureProductGasesEnthalpy(GeneratorNum, FuelCell(GeneratorNum).FCPM.TprodGasLeavingFCPM, HmolProdGases); + FigureProductGasesEnthalpy(GeneratorNum, DataGenerators::FuelCell(GeneratorNum).FCPM.TprodGasLeavingFCPM, HmolProdGases); // units, NdotProdGas in kmol/sec.; HmolProdGases in KJ/mol , // factor of 1000's to get to J/s or watts - FuelCell(GeneratorNum).FCPM.TotProdGasEnthalphy = HmolProdGases * 1000.0 * FuelCell(GeneratorNum).FCPM.NdotProdGas * 1000.0; + DataGenerators::FuelCell(GeneratorNum).FCPM.TotProdGasEnthalphy = HmolProdGases * 1000.0 * DataGenerators::FuelCell(GeneratorNum).FCPM.NdotProdGas * 1000.0; // calculation Step 9, Figure Skin lossess - if (FuelCell(GeneratorNum).FCPM.SkinLossMode == ConstantRateSkinLoss) { + if (DataGenerators::FuelCell(GeneratorNum).FCPM.SkinLossMode == DataGenerators::ConstantRateSkinLoss) { // do nothing just use QdotSkin - } else if (FuelCell(GeneratorNum).FCPM.SkinLossMode == UADTSkinLoss) { + } else if (DataGenerators::FuelCell(GeneratorNum).FCPM.SkinLossMode == DataGenerators::UADTSkinLoss) { // get zone air temp - if (FuelCell(GeneratorNum).FCPM.ZoneID > 0) { - FuelCell(GeneratorNum).FCPM.QdotSkin = FuelCell(GeneratorNum).FCPM.UAskin * - (FuelCell(GeneratorNum).FCPM.TprodGasLeavingFCPM - DataHeatBalFanSys::ZT(FuelCell(GeneratorNum).FCPM.ZoneID)); + if (DataGenerators::FuelCell(GeneratorNum).FCPM.ZoneID > 0) { + DataGenerators::FuelCell(GeneratorNum).FCPM.QdotSkin = DataGenerators::FuelCell(GeneratorNum).FCPM.UAskin * + (DataGenerators::FuelCell(GeneratorNum).FCPM.TprodGasLeavingFCPM - DataHeatBalFanSys::ZT(DataGenerators::FuelCell(GeneratorNum).FCPM.ZoneID)); } - } else if (FuelCell(GeneratorNum).FCPM.SkinLossMode == QuadraticFuelNdotSkin) { + } else if (DataGenerators::FuelCell(GeneratorNum).FCPM.SkinLossMode == DataGenerators::QuadraticFuelNdotSkin) { - FuelCell(GeneratorNum).FCPM.QdotSkin = CurveManager::CurveValue(FuelCell(GeneratorNum).FCPM.SkinLossCurveID, FuelCell(GeneratorNum).FCPM.NdotFuel); + DataGenerators::FuelCell(GeneratorNum).FCPM.QdotSkin = CurveManager::CurveValue(DataGenerators::FuelCell(GeneratorNum).FCPM.SkinLossCurveID, DataGenerators::FuelCell(GeneratorNum).FCPM.NdotFuel); } // calculation Step 10, AC FCPM power ancillaries - FuelCell(GeneratorNum).FCPM.PelancillariesAC = - FuelCell(GeneratorNum).FCPM.ANC0 + FuelCell(GeneratorNum).FCPM.ANC1 * FuelCell(GeneratorNum).FCPM.NdotFuel; + DataGenerators::FuelCell(GeneratorNum).FCPM.PelancillariesAC = + DataGenerators::FuelCell(GeneratorNum).FCPM.ANC0 + DataGenerators::FuelCell(GeneratorNum).FCPM.ANC1 * DataGenerators::FuelCell(GeneratorNum).FCPM.NdotFuel; // calculation Step 11, Dilution air - FigureAirEnthalpy(GeneratorNum, FuelCell(GeneratorNum).AirSup.TairIntoBlower, Hmolair); // (Hmolair in KJ/mol) + FigureAirEnthalpy(GeneratorNum, DataGenerators::FuelCell(GeneratorNum).AirSup.TairIntoBlower, Hmolair); // (Hmolair in KJ/mol) // units, NdotDilutionAir in kmol/sec.; Hmolair in KJ/mol , // factor of 1000's to get to J/s or watts - FuelCell(GeneratorNum).FCPM.DilutionAirInEnthalpy = Hmolair * 1000.0 * FuelCell(GeneratorNum).FCPM.NdotDilutionAir * 1000.0; - FuelCell(GeneratorNum).FCPM.DilutionAirOutEnthalpy = - FuelCell(GeneratorNum).FCPM.DilutionAirInEnthalpy + FuelCell(GeneratorNum).FCPM.StackHeatLossToDilution; + DataGenerators::FuelCell(GeneratorNum).FCPM.DilutionAirInEnthalpy = Hmolair * 1000.0 * DataGenerators::FuelCell(GeneratorNum).FCPM.NdotDilutionAir * 1000.0; + DataGenerators::FuelCell(GeneratorNum).FCPM.DilutionAirOutEnthalpy = + DataGenerators::FuelCell(GeneratorNum).FCPM.DilutionAirInEnthalpy + DataGenerators::FuelCell(GeneratorNum).FCPM.StackHeatLossToDilution; // calculation Step 12, Calculate Reforming water out enthalpy - FigureGaseousWaterEnthalpy(FuelCell(GeneratorNum).FCPM.TprodGasLeavingFCPM, HGasWater); + FigureGaseousWaterEnthalpy(DataGenerators::FuelCell(GeneratorNum).FCPM.TprodGasLeavingFCPM, HGasWater); - FuelCell(GeneratorNum).FCPM.WaterOutEnthalpy = HGasWater * 1000.0 * FuelCell(GeneratorNum).FCPM.NdotLiqwater * 1000.0; + DataGenerators::FuelCell(GeneratorNum).FCPM.WaterOutEnthalpy = HGasWater * 1000.0 * DataGenerators::FuelCell(GeneratorNum).FCPM.NdotLiqwater * 1000.0; // calculation Step 13, Calculate Heat balance // move all terms in Equation 7 to RHS and calculate imbalance - MagofImbalance = -FuelCell(GeneratorNum).FCPM.TotFuelInEnthalphy - FuelCell(GeneratorNum).FCPM.TotAirInEnthalphy - - FuelCell(GeneratorNum).FCPM.WaterInEnthalpy - FuelCell(GeneratorNum).FCPM.DilutionAirInEnthalpy - - FuelCell(GeneratorNum).FCPM.NdotFuel * FuelSupply(FuelCell(GeneratorNum).FuelSupNum).LHV * 1000000.0 - - FuelCell(GeneratorNum).FCPM.PelancillariesAC + FuelCell(GeneratorNum).FCPM.Pel + - FuelCell(GeneratorNum).FCPM.TotProdGasEnthalphy + FuelCell(GeneratorNum).FCPM.WaterOutEnthalpy + - FuelCell(GeneratorNum).FCPM.QdotStackCool + FuelCell(GeneratorNum).FCPM.QdotSkin + - FuelCell(GeneratorNum).FCPM.DilutionAirOutEnthalpy; + MagofImbalance = -DataGenerators::FuelCell(GeneratorNum).FCPM.TotFuelInEnthalphy - DataGenerators::FuelCell(GeneratorNum).FCPM.TotAirInEnthalphy - + DataGenerators::FuelCell(GeneratorNum).FCPM.WaterInEnthalpy - DataGenerators::FuelCell(GeneratorNum).FCPM.DilutionAirInEnthalpy - + DataGenerators::FuelCell(GeneratorNum).FCPM.NdotFuel * DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).LHV * 1000000.0 - + DataGenerators::FuelCell(GeneratorNum).FCPM.PelancillariesAC + DataGenerators::FuelCell(GeneratorNum).FCPM.Pel + + DataGenerators::FuelCell(GeneratorNum).FCPM.TotProdGasEnthalphy + DataGenerators::FuelCell(GeneratorNum).FCPM.WaterOutEnthalpy + + DataGenerators::FuelCell(GeneratorNum).FCPM.QdotStackCool + DataGenerators::FuelCell(GeneratorNum).FCPM.QdotSkin + + DataGenerators::FuelCell(GeneratorNum).FCPM.DilutionAirOutEnthalpy; // Now find a new total prod Gas Enthalphy that would result in an energy balance // TODO check signs... - tmpTotProdGasEnthalphy = FuelCell(GeneratorNum).FCPM.TotProdGasEnthalphy - MagofImbalance; + tmpTotProdGasEnthalphy = DataGenerators::FuelCell(GeneratorNum).FCPM.TotProdGasEnthalphy - MagofImbalance; // solve for a new TprodGasLeavingFCPM using regula falsi method @@ -1944,9 +1867,9 @@ namespace FuelCellElectricGenerator { SolverFlag = 0; // init Par(1) = double(GeneratorNum); Par(2) = tmpTotProdGasEnthalphy; - Par(3) = FuelCell(GeneratorNum).FCPM.NdotProdGas; - tmpTprodGas = FuelCell(GeneratorNum).FCPM.TprodGasLeavingFCPM; - General::SolveRoot(Acc, MaxIter, SolverFlag, tmpTprodGas, FuelCellProductGasEnthResidual, MinProductGasTemp, MaxProductGasTemp, Par); + Par(3) = DataGenerators::FuelCell(GeneratorNum).FCPM.NdotProdGas; + tmpTprodGas = DataGenerators::FuelCell(GeneratorNum).FCPM.TprodGasLeavingFCPM; + General::SolveRoot(Acc, MaxIter, SolverFlag, tmpTprodGas, FuelCellProductGasEnthResidual, DataGenerators::MinProductGasTemp, DataGenerators::MaxProductGasTemp, Par); if (SolverFlag == -2) { @@ -1956,7 +1879,7 @@ namespace FuelCellElectricGenerator { ShowWarningError("CalcFuelCellGeneratorModel: Root Solver problem, flag = -1, check accuracy and iterations, did not converge"); } if (SolverFlag > 0) { - FuelCell(GeneratorNum).FCPM.TprodGasLeavingFCPM = tmpTprodGas; + DataGenerators::FuelCell(GeneratorNum).FCPM.TprodGasLeavingFCPM = tmpTprodGas; // write(*,*) 'Number of Root Solver iterations: ', solverFlag } @@ -1969,38 +1892,38 @@ namespace FuelCellElectricGenerator { PintoInverter = Pel - Pstorage; // refine power conditioning losses with more current power production - if (FuelCell(GeneratorNum).Inverter.EffMode == DataGenerators::InverterEffConstant) { + if (DataGenerators::FuelCell(GeneratorNum).Inverter.EffMode == DataGenerators::InverterEffConstant) { - PpcuLosses = (1.0 - FuelCell(GeneratorNum).Inverter.ConstEff) * PintoInverter; + PpcuLosses = (1.0 - DataGenerators::FuelCell(GeneratorNum).Inverter.ConstEff) * PintoInverter; } - if (FuelCell(GeneratorNum).Inverter.EffMode == DataGenerators::InverterEffQuadratic) { + if (DataGenerators::FuelCell(GeneratorNum).Inverter.EffMode == DataGenerators::InverterEffQuadratic) { - PpcuLosses = (1.0 - CurveManager::CurveValue(FuelCell(GeneratorNum).Inverter.EffQuadraticCurveID, PintoInverter)) * PintoInverter; + PpcuLosses = (1.0 - CurveManager::CurveValue(DataGenerators::FuelCell(GeneratorNum).Inverter.EffQuadraticCurveID, PintoInverter)) * PintoInverter; } PoutofInverter = PintoInverter - PpcuLosses; - FuelCell(GeneratorNum).ACPowerGen = PoutofInverter - FuelCell(GeneratorNum).FCPM.PelancillariesAC - - FuelCell(GeneratorNum).AirSup.PairCompEl - FuelSupply(FuelCell(GeneratorNum).FuelSupNum).PfuelCompEl - - FuelCell(GeneratorNum).WaterSup.PwaterCompEl; - FuelCell(GeneratorNum).Inverter.PCUlosses = PpcuLosses; + DataGenerators::FuelCell(GeneratorNum).ACPowerGen = PoutofInverter - DataGenerators::FuelCell(GeneratorNum).FCPM.PelancillariesAC - + DataGenerators::FuelCell(GeneratorNum).AirSup.PairCompEl - DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).PfuelCompEl - + DataGenerators::FuelCell(GeneratorNum).WaterSup.PwaterCompEl; + DataGenerators::FuelCell(GeneratorNum).Inverter.PCUlosses = PpcuLosses; // model assumes air intake is drawn over power conditioner to recovery heat - FuelCell(GeneratorNum).Inverter.QairIntake = FuelCell(GeneratorNum).Inverter.PCUlosses; + DataGenerators::FuelCell(GeneratorNum).Inverter.QairIntake = DataGenerators::FuelCell(GeneratorNum).Inverter.PCUlosses; CalcFuelCellAuxHeater(GeneratorNum); CalcFuelCellGenHeatRecovery(GeneratorNum); // calculation Step 11, If imbalance below threshold, then exit out of do loop. - if ((std::abs(MagofImbalance) < std::abs(DataGenerators::ImBalanceTol * FuelCell(GeneratorNum).FCPM.Pel)) && (iter > 2)) { + if ((std::abs(MagofImbalance) < std::abs(DataGenerators::ImBalanceTol * DataGenerators::FuelCell(GeneratorNum).FCPM.Pel)) && (iter > 2)) { break; } } // sequential substitution loop - FuelCell(GeneratorNum).FCPM.SeqSubstitIter = iter; - FuelCell(GeneratorNum).FCPM.RegulaFalsiIter = SolverFlag; + DataGenerators::FuelCell(GeneratorNum).FCPM.SeqSubstitIter = iter; + DataGenerators::FuelCell(GeneratorNum).FCPM.RegulaFalsiIter = SolverFlag; } void ManageElectStorInteractions(int const Num, // Generator number, index for structure @@ -2230,14 +2153,6 @@ namespace FuelCellElectricGenerator { // REFERENCES: // NIST Webbook on gas phase thermochemistry - using DataGenerators::FuelCell; - using DataGenerators::NumFuelCellGenerators; - using DataGenerators::FCDataStruct; - using DataGenerators::MaxProductGasTemp; - using DataGenerators::LeadAcidBatterManwellMcGowan; - using DataGenerators::LeadAcidBatterySaupe; - using DataGenerators::NISTShomate; - Real64 tempCp; int thisConstit; // loop index int gasID; @@ -2267,10 +2182,10 @@ namespace FuelCellElectricGenerator { Real64 const pow_3_Tkel(pow_3(Tkel)); Real64 const pow_4_Tkel(pow_4(Tkel)); - for (thisConstit = 1; thisConstit <= FuelCell(GeneratorNum).AirSup.NumConstituents; ++thisConstit) { - gasID = FuelCell(GeneratorNum).AirSup.GasLibID(thisConstit); + for (thisConstit = 1; thisConstit <= DataGenerators::FuelCell(GeneratorNum).AirSup.NumConstituents; ++thisConstit) { + gasID = DataGenerators::FuelCell(GeneratorNum).AirSup.GasLibID(thisConstit); if (gasID > 0) { - if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == NISTShomate) { + if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == DataGenerators::NISTShomate) { A = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateA; B = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateB; @@ -2279,7 +2194,7 @@ namespace FuelCellElectricGenerator { E = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateE; tempCp += ((A + B * Tsho + C * pow_2_Tsho + D * pow_3_Tsho + E / pow_2_Tsho) * - FuelCell(GeneratorNum).AirSup.ConstitMolalFract(thisConstit)); + DataGenerators::FuelCell(GeneratorNum).AirSup.ConstitMolalFract(thisConstit)); } if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == DataGenerators::NASAPolynomial) { @@ -2291,7 +2206,7 @@ namespace FuelCellElectricGenerator { A5 = DataGenerators::GasPhaseThermoChemistryData(gasID).NASA_A5; tempCp += (A1 + A2 * Tkel + A3 * pow_2_Tkel + A4 * pow_3_Tkel + A5 * pow_4_Tkel) * DataGenerators::RinKJperMolpK * - FuelCell(GeneratorNum).AirSup.ConstitMolalFract(thisConstit); + DataGenerators::FuelCell(GeneratorNum).AirSup.ConstitMolalFract(thisConstit); } } } @@ -2321,47 +2236,6 @@ namespace FuelCellElectricGenerator { // REFERENCES: // NIST Webbook on gas phase thermochemistry - using DataGenerators::FuelCell; - using DataGenerators::NumFuelCellGenerators; - using DataGenerators::FCDataStruct; - using DataGenerators::DirectCurveMode; - using DataGenerators::NormalizedCurveMode; - using DataGenerators::ConstantRateSkinLoss; - using DataGenerators::UADTSkinLoss; - using DataGenerators::QuadraticFuelNdotSkin; - using DataGenerators::NumGeneratorFuelSups; - using DataGenerators::FuelSupply; - using DataGenerators::ConstantStoicsAirRat; - using DataGenerators::QuadraticFuncofPel; - using DataGenerators::QuadraticFuncofNdot; - using DataGenerators::RecoverBurnInvertBatt; - using DataGenerators::RecoverAuxiliaryBurner; - using DataGenerators::RecoverInverterBatt; - using DataGenerators::RecoverInverter; - using DataGenerators::RecoverBattery; - using DataGenerators::NoRecoveryOnAirIntake; - using DataGenerators::RegularAir; - using DataGenerators::UserDefinedConstituents; - using DataGenerators::GasPropertyDataStruct; - using DataGenerators::WaterInReformAirNode; - using DataGenerators::WaterInReformWaterNode; - using DataGenerators::WaterInReformMains; - using DataGenerators::WaterInReformSchedule; - using DataGenerators::SurroundingZone; - using DataGenerators::AirInletForFC; - using DataGenerators::FixedEffectiveness; - using DataGenerators::LMTDempiricalUAeff; - using DataGenerators::LMTDfundementalUAeff; - using DataGenerators::Condensing; - using DataGenerators::SimpleEffConstraints; - using DataGenerators::FuelInTempFromNode; - using DataGenerators::FuelInTempSchedule; - using DataGenerators::MinProductGasTemp; - using DataGenerators::MaxProductGasTemp; - using DataGenerators::LeadAcidBatterManwellMcGowan; - using DataGenerators::LeadAcidBatterySaupe; - using DataGenerators::NISTShomate; - Real64 tempHair; Real64 HairI; int thisConstit; // loop index @@ -2394,10 +2268,10 @@ namespace FuelCellElectricGenerator { Real64 const pow_3_Tkel(pow_3(Tkel)); Real64 const pow_4_Tkel(pow_4(Tkel)); - for (thisConstit = 1; thisConstit <= FuelCell(GeneratorNum).AirSup.NumConstituents; ++thisConstit) { - gasID = FuelCell(GeneratorNum).AirSup.GasLibID(thisConstit); + for (thisConstit = 1; thisConstit <= DataGenerators::FuelCell(GeneratorNum).AirSup.NumConstituents; ++thisConstit) { + gasID = DataGenerators::FuelCell(GeneratorNum).AirSup.GasLibID(thisConstit); if (gasID > 0) { - if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == NISTShomate) { + if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == DataGenerators::NISTShomate) { A = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateA; B = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateB; @@ -2409,7 +2283,7 @@ namespace FuelCellElectricGenerator { HairI = (A * Tsho + B * pow_2_Tsho / 2.0 + C * pow_3_Tsho / 3.0 + D * pow_4_Tsho / 4.0 - E / Tsho + F - H); - tempHair += HairI * FuelCell(GeneratorNum).AirSup.ConstitMolalFract(thisConstit); + tempHair += HairI * DataGenerators::FuelCell(GeneratorNum).AirSup.ConstitMolalFract(thisConstit); } if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == DataGenerators::NASAPolynomial) { A1 = DataGenerators::GasPhaseThermoChemistryData(gasID).NASA_A1; @@ -2422,7 +2296,7 @@ namespace FuelCellElectricGenerator { tempHair += (((A1 + A2 * Tkel / 2.0 + A3 * pow_2_Tkel / 3.0 + A4 * pow_3_Tkel / 4.0 + A5 * pow_4_Tkel / 5.0 + A6 / Tkel) * DataGenerators::RinKJperMolpK * Tkel) - DataGenerators::GasPhaseThermoChemistryData(gasID).StdRefMolarEnthOfForm) * - FuelCell(GeneratorNum).AirSup.ConstitMolalFract(thisConstit); + DataGenerators::FuelCell(GeneratorNum).AirSup.ConstitMolalFract(thisConstit); } } } @@ -2452,47 +2326,6 @@ namespace FuelCellElectricGenerator { // REFERENCES: // NIST Webbook on gas phase thermochemistry - using DataGenerators::FuelCell; - using DataGenerators::NumFuelCellGenerators; - using DataGenerators::FCDataStruct; - using DataGenerators::DirectCurveMode; - using DataGenerators::NormalizedCurveMode; - using DataGenerators::ConstantRateSkinLoss; - using DataGenerators::UADTSkinLoss; - using DataGenerators::QuadraticFuelNdotSkin; - using DataGenerators::NumGeneratorFuelSups; - using DataGenerators::FuelSupply; - using DataGenerators::ConstantStoicsAirRat; - using DataGenerators::QuadraticFuncofPel; - using DataGenerators::QuadraticFuncofNdot; - using DataGenerators::RecoverBurnInvertBatt; - using DataGenerators::RecoverAuxiliaryBurner; - using DataGenerators::RecoverInverterBatt; - using DataGenerators::RecoverInverter; - using DataGenerators::RecoverBattery; - using DataGenerators::NoRecoveryOnAirIntake; - using DataGenerators::RegularAir; - using DataGenerators::UserDefinedConstituents; - using DataGenerators::GasPropertyDataStruct; - using DataGenerators::WaterInReformAirNode; - using DataGenerators::WaterInReformWaterNode; - using DataGenerators::WaterInReformMains; - using DataGenerators::WaterInReformSchedule; - using DataGenerators::SurroundingZone; - using DataGenerators::AirInletForFC; - using DataGenerators::FixedEffectiveness; - using DataGenerators::LMTDempiricalUAeff; - using DataGenerators::LMTDfundementalUAeff; - using DataGenerators::Condensing; - using DataGenerators::SimpleEffConstraints; - using DataGenerators::FuelInTempFromNode; - using DataGenerators::FuelInTempSchedule; - using DataGenerators::MinProductGasTemp; - using DataGenerators::MaxProductGasTemp; - using DataGenerators::LeadAcidBatterManwellMcGowan; - using DataGenerators::LeadAcidBatterySaupe; - using DataGenerators::NISTShomate; - Real64 tempCp; int thisConstit; // loop index int gasID; // look up into Gas structure @@ -2520,10 +2353,10 @@ namespace FuelCellElectricGenerator { Real64 const pow_3_Tkel(pow_3(Tkel)); Real64 const pow_4_Tkel(pow_4(Tkel)); - for (thisConstit = 1; thisConstit <= FuelSupply(FuelCell(GeneratorNum).FuelSupNum).NumConstituents; ++thisConstit) { - gasID = FuelSupply(FuelCell(GeneratorNum).FuelSupNum).GasLibID(thisConstit); + for (thisConstit = 1; thisConstit <= DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).NumConstituents; ++thisConstit) { + gasID = DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).GasLibID(thisConstit); if (gasID > 0) { - if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == NISTShomate) { + if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == DataGenerators::NISTShomate) { A = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateA; B = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateB; @@ -2532,7 +2365,7 @@ namespace FuelCellElectricGenerator { E = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateE; tempCp += ((A + B * Tsho + C * pow_2_Tsho + D * pow_3_Tsho + E / pow_2_Tsho) * - FuelSupply(FuelCell(GeneratorNum).FuelSupNum).ConstitMolalFract(thisConstit)); + DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).ConstitMolalFract(thisConstit)); } if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == DataGenerators::NASAPolynomial) { @@ -2543,7 +2376,7 @@ namespace FuelCellElectricGenerator { A5 = DataGenerators::GasPhaseThermoChemistryData(gasID).NASA_A5; tempCp += (A1 + A2 * Tkel + A3 * pow_2_Tkel + A4 * pow_3_Tkel + A5 * pow_4_Tkel) * DataGenerators::RinKJperMolpK * - FuelSupply(FuelCell(GeneratorNum).FuelSupNum).ConstitMolalFract(thisConstit); + DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).ConstitMolalFract(thisConstit); } } } @@ -2573,47 +2406,6 @@ namespace FuelCellElectricGenerator { // REFERENCES: // NIST Webbook on gas phase thermochemistry - using DataGenerators::FuelCell; - using DataGenerators::NumFuelCellGenerators; - using DataGenerators::FCDataStruct; - using DataGenerators::DirectCurveMode; - using DataGenerators::NormalizedCurveMode; - using DataGenerators::ConstantRateSkinLoss; - using DataGenerators::UADTSkinLoss; - using DataGenerators::QuadraticFuelNdotSkin; - using DataGenerators::NumGeneratorFuelSups; - using DataGenerators::FuelSupply; - using DataGenerators::ConstantStoicsAirRat; - using DataGenerators::QuadraticFuncofPel; - using DataGenerators::QuadraticFuncofNdot; - using DataGenerators::RecoverBurnInvertBatt; - using DataGenerators::RecoverAuxiliaryBurner; - using DataGenerators::RecoverInverterBatt; - using DataGenerators::RecoverInverter; - using DataGenerators::RecoverBattery; - using DataGenerators::NoRecoveryOnAirIntake; - using DataGenerators::RegularAir; - using DataGenerators::UserDefinedConstituents; - using DataGenerators::GasPropertyDataStruct; - using DataGenerators::WaterInReformAirNode; - using DataGenerators::WaterInReformWaterNode; - using DataGenerators::WaterInReformMains; - using DataGenerators::WaterInReformSchedule; - using DataGenerators::SurroundingZone; - using DataGenerators::AirInletForFC; - using DataGenerators::FixedEffectiveness; - using DataGenerators::LMTDempiricalUAeff; - using DataGenerators::LMTDfundementalUAeff; - using DataGenerators::Condensing; - using DataGenerators::SimpleEffConstraints; - using DataGenerators::FuelInTempFromNode; - using DataGenerators::FuelInTempSchedule; - using DataGenerators::MinProductGasTemp; - using DataGenerators::MaxProductGasTemp; - using DataGenerators::LeadAcidBatterManwellMcGowan; - using DataGenerators::LeadAcidBatterySaupe; - using DataGenerators::NISTShomate; - Real64 tempHfuel; Real64 HfuelI; int thisConstit; // loop index @@ -2646,10 +2438,10 @@ namespace FuelCellElectricGenerator { Real64 const pow_3_Tkel(pow_3(Tkel)); Real64 const pow_4_Tkel(pow_4(Tkel)); - for (thisConstit = 1; thisConstit <= FuelSupply(FuelCell(GeneratorNum).FuelSupNum).NumConstituents; ++thisConstit) { - gasID = FuelSupply(FuelCell(GeneratorNum).FuelSupNum).GasLibID(thisConstit); + for (thisConstit = 1; thisConstit <= DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).NumConstituents; ++thisConstit) { + gasID = DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).GasLibID(thisConstit); if (gasID > 0) { - if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == NISTShomate) { + if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == DataGenerators::NISTShomate) { A = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateA; B = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateB; C = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateC; @@ -2660,7 +2452,7 @@ namespace FuelCellElectricGenerator { HfuelI = (A * Tsho + B * pow_2_Tsho / 2.0 + C * pow_3_Tsho / 3.0 + D * pow_4_Tsho / 4.0 - E / Tsho + F - H); - tempHfuel += HfuelI * FuelSupply(FuelCell(GeneratorNum).FuelSupNum).ConstitMolalFract(thisConstit); + tempHfuel += HfuelI * DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).ConstitMolalFract(thisConstit); } if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == DataGenerators::NASAPolynomial) { @@ -2674,7 +2466,7 @@ namespace FuelCellElectricGenerator { tempHfuel += (((A1 + A2 * Tkel / 2.0 + A3 * pow_2_Tkel / 3.0 + A4 * pow_3_Tkel / 4.0 + A5 * pow_4_Tkel / 5.0 + A6 / Tkel) * DataGenerators::RinKJperMolpK * Tkel) - DataGenerators::GasPhaseThermoChemistryData(gasID).StdRefMolarEnthOfForm) * - FuelSupply(FuelCell(GeneratorNum).FuelSupNum).ConstitMolalFract(thisConstit); + DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).ConstitMolalFract(thisConstit); } } } From 57d735aa90d8c9ec906908fbadc17ec2394129b6 Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Mon, 11 Nov 2019 15:22:14 -0700 Subject: [PATCH 20/51] partial cleanup local var --- src/EnergyPlus/FuelCellElectricGenerator.cc | 217 ++++++++------------ 1 file changed, 88 insertions(+), 129 deletions(-) diff --git a/src/EnergyPlus/FuelCellElectricGenerator.cc b/src/EnergyPlus/FuelCellElectricGenerator.cc index 66d4ba09712..94720825445 100644 --- a/src/EnergyPlus/FuelCellElectricGenerator.cc +++ b/src/EnergyPlus/FuelCellElectricGenerator.cc @@ -175,37 +175,8 @@ namespace FuelCellElectricGenerator { Array1D NumArray(200); // numeric data TODO deal with allocatable for extensible Array1D_bool lAlphaBlanks(25); static bool ErrorsFound(false); // error flag - int NumFuelCellPMs; // number of power subsystems in input file - int NumFuelCellAirSups; // number of air supply subsystems in input file - int NumFCWaterSups; // number of water supply subsystems in input file - int NumFuelCellAuxilHeaters; - int NumFCExhaustGasHXs; - int NumFCElecStorageUnits; // number of electrical storage objects in input file - int NumFCPowerCondUnits; // number of power conditioning units (inverter) - int NumFCStackCoolers; // number of stack coolers. - int NumAirConstit; // number of gas constituents in air - int FCPMNum; // loop counter over power subsystems - int FCAirSupNum; // loop counter over air supply subsystems - int ConstitNum; // loop counter for constituents - int FCWaterSupNum; // loop counter over water supply subsystems - int FCHXNum; // loop counter for heat exchangers - int FCAuxHeatNum; // loop counter over auxiliary heater - int FCPCUNum; // loop counter over inverters - int StorageNum; // loop counter over electrical storage subsystems - int FCScoolNum; // loop counter over stack coolers - int thisFuelCell; // temporary index - int otherFuelCell; // loop counter and temporary indexer - int i; // loop counter static bool MyOneTimeFlag(true); - std::string thisName; - int NumHardCodedConstituents; - int thisConstituent; - int thisGasID; - int FuelSupNum; - thisFuelCell = 0; - - // execution if (MyOneTimeFlag) { DataIPShortCuts::cCurrentModuleObject = "Generator:FuelCell"; @@ -241,14 +212,14 @@ namespace FuelCellElectricGenerator { } DataIPShortCuts::cCurrentModuleObject = "Generator:FuelCell:PowerModule"; - NumFuelCellPMs = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); + int NumFuelCellPMs = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); if (NumFuelCellPMs <= 0) { ShowSevereError("No " + DataIPShortCuts::cCurrentModuleObject + " equipment specified in input file"); ErrorsFound = true; } - for (FCPMNum = 1; FCPMNum <= NumFuelCellPMs; ++FCPMNum) { + for (int FCPMNum = 1; FCPMNum <= NumFuelCellPMs; ++FCPMNum) { inputProcessor->getObjectItem(DataIPShortCuts::cCurrentModuleObject, FCPMNum, AlphArray, @@ -262,7 +233,7 @@ namespace FuelCellElectricGenerator { DataIPShortCuts::cNumericFieldNames); UtilityRoutines::IsNameEmpty(AlphArray(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); - thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), DataGenerators::FuelCell, &DataGenerators::FCDataStruct::NameFCPM); + int thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), DataGenerators::FuelCell, &DataGenerators::FCDataStruct::NameFCPM); if (thisFuelCell > 0) { // cr9323 DataGenerators::FuelCell(thisFuelCell).FCPM.Name = AlphArray(1); @@ -344,7 +315,7 @@ namespace FuelCellElectricGenerator { DataGenerators::FuelCell(thisFuelCell).FCPM.PelMax = NumArray(25); // check for other FuelCell using the same power module and fill - for (otherFuelCell = thisFuelCell + 1; otherFuelCell <= DataGenerators::NumFuelCellGenerators; ++otherFuelCell) { + for (int otherFuelCell = thisFuelCell + 1; otherFuelCell <= DataGenerators::NumFuelCellGenerators; ++otherFuelCell) { if (UtilityRoutines::SameString(DataGenerators::FuelCell(otherFuelCell).FCPM.Name, DataGenerators::FuelCell(thisFuelCell).FCPM.Name)) { DataGenerators::FuelCell(otherFuelCell).FCPM = DataGenerators::FuelCell(thisFuelCell).FCPM; } @@ -358,7 +329,7 @@ namespace FuelCellElectricGenerator { GeneratorFuelSupply::GetGeneratorFuelSupplyInput(); - for (FuelSupNum = 1; FuelSupNum <= DataGenerators::NumGeneratorFuelSups; ++FuelSupNum) { + for (int FuelSupNum = 1; FuelSupNum <= DataGenerators::NumGeneratorFuelSups; ++FuelSupNum) { GeneratorFuelSupply::SetupFuelConstituentData(FuelSupNum, ErrorsFound); } @@ -373,19 +344,20 @@ namespace FuelCellElectricGenerator { } DataIPShortCuts::cCurrentModuleObject = "Generator:FuelCell:AirSupply"; - NumFuelCellAirSups = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); + int NumFuelCellAirSups = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); if (NumFuelCellAirSups <= 0) { // Autodesk:Uninit thisFuelCell was possibly uninitialized past this condition ShowSevereError("No " + DataIPShortCuts::cCurrentModuleObject + " equipment specified in input file"); ErrorsFound = true; } - for (FCAirSupNum = 1; FCAirSupNum <= NumFuelCellAirSups; ++FCAirSupNum) { + for (int FCAirSupNum = 1; FCAirSupNum <= NumFuelCellAirSups; ++FCAirSupNum) { inputProcessor->getObjectItem( DataIPShortCuts::cCurrentModuleObject, FCAirSupNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat, _, _, DataIPShortCuts::cAlphaFieldNames, DataIPShortCuts::cNumericFieldNames); UtilityRoutines::IsNameEmpty(AlphArray(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); - thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), DataGenerators::FuelCell, &DataGenerators::FCDataStruct::NameFCAirSup); + int thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), DataGenerators::FuelCell, &DataGenerators::FCDataStruct::NameFCAirSup); + if (thisFuelCell > 0) { DataGenerators::FuelCell(thisFuelCell).AirSup.Name = AlphArray(1); @@ -466,6 +438,8 @@ namespace FuelCellElectricGenerator { ErrorsFound = true; } + int NumAirConstit; + if (DataGenerators::FuelCell(thisFuelCell).AirSup.ConstituentMode == DataGenerators::UserDefinedConstituents) { NumAirConstit = NumArray(4); DataGenerators::FuelCell(thisFuelCell).AirSup.NumConstituents = NumAirConstit; @@ -477,7 +451,7 @@ namespace FuelCellElectricGenerator { ErrorsFound = true; } - for (ConstitNum = 1; ConstitNum <= NumAirConstit; ++ConstitNum) { + for (int ConstitNum = 1; ConstitNum <= NumAirConstit; ++ConstitNum) { DataGenerators::FuelCell(thisFuelCell).AirSup.ConstitName(ConstitNum) = AlphArray(ConstitNum + 8); DataGenerators::FuelCell(thisFuelCell).AirSup.ConstitMolalFract(ConstitNum) = NumArray(ConstitNum + 4); } @@ -513,7 +487,7 @@ namespace FuelCellElectricGenerator { } // check for other FuelCell using the same Air Supply module and fill - for (otherFuelCell = thisFuelCell + 1; otherFuelCell <= DataGenerators::NumFuelCellGenerators; ++otherFuelCell) { + for (int otherFuelCell = thisFuelCell + 1; otherFuelCell <= DataGenerators::NumFuelCellGenerators; ++otherFuelCell) { if (UtilityRoutines::SameString(DataGenerators::FuelCell(otherFuelCell).AirSup.Name, DataGenerators::FuelCell(thisFuelCell).AirSup.Name)) { DataGenerators::FuelCell(otherFuelCell).AirSup = DataGenerators::FuelCell(thisFuelCell).AirSup; } @@ -527,18 +501,16 @@ namespace FuelCellElectricGenerator { for (GeneratorNum = 1; GeneratorNum <= DataGenerators::NumFuelCellGenerators; ++GeneratorNum) { // find molal fraction of oxygen in air supply - thisConstituent = + int thisConstituent = UtilityRoutines::FindItem("Oxygen", DataGenerators::FuelCell(GeneratorNum).AirSup.ConstitName, DataGenerators::FuelCell(GeneratorNum).AirSup.NumConstituents); if (thisConstituent > 0) DataGenerators::FuelCell(GeneratorNum).AirSup.O2fraction = DataGenerators::FuelCell(GeneratorNum).AirSup.ConstitMolalFract(thisConstituent); - NumHardCodedConstituents = 14; - // Loop over air constituents and do one-time setup - for (i = 1; i <= DataGenerators::FuelCell(GeneratorNum).AirSup.NumConstituents; ++i) { + for (int i = 1; i <= DataGenerators::FuelCell(GeneratorNum).AirSup.NumConstituents; ++i) { - thisName = DataGenerators::FuelCell(GeneratorNum).AirSup.ConstitName(i); + std::string thisName = DataGenerators::FuelCell(GeneratorNum).AirSup.ConstitName(i); - thisGasID = UtilityRoutines::FindItem(thisName, DataGenerators::GasPhaseThermoChemistryData, &DataGenerators::GasPropertyDataStruct::ConstituentName); + int thisGasID = UtilityRoutines::FindItem(thisName, DataGenerators::GasPhaseThermoChemistryData, &DataGenerators::GasPropertyDataStruct::ConstituentName); DataGenerators::FuelCell(GeneratorNum).AirSup.GasLibID(i) = thisGasID; } @@ -552,19 +524,20 @@ namespace FuelCellElectricGenerator { } DataIPShortCuts::cCurrentModuleObject = "Generator:FuelCell:WaterSupply"; - NumFCWaterSups = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); + int NumFCWaterSups = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); if (NumFCWaterSups <= 0) { ShowSevereError("No " + DataIPShortCuts::cCurrentModuleObject + " equipment specified in input file"); ErrorsFound = true; } - for (FCWaterSupNum = 1; FCWaterSupNum <= NumFCWaterSups; ++FCWaterSupNum) { + for (int FCWaterSupNum = 1; FCWaterSupNum <= NumFCWaterSups; ++FCWaterSupNum) { inputProcessor->getObjectItem( DataIPShortCuts::cCurrentModuleObject, FCWaterSupNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat, _, _, DataIPShortCuts::cAlphaFieldNames, DataIPShortCuts::cNumericFieldNames); UtilityRoutines::IsNameEmpty(AlphArray(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); - thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), DataGenerators::FuelCell, &DataGenerators::FCDataStruct::NameFCWaterSup); + int thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), DataGenerators::FuelCell, &DataGenerators::FCDataStruct::NameFCWaterSup); + if (thisFuelCell > 0) { // this is only the first instance of a FuelCell generator using this type of Water supply module DataGenerators::FuelCell(thisFuelCell).WaterSup.Name = AlphArray(1); @@ -630,7 +603,7 @@ namespace FuelCellElectricGenerator { } // check for other FuelCell using the same Water Supply module and fill - for (otherFuelCell = thisFuelCell + 1; otherFuelCell <= DataGenerators::NumFuelCellGenerators; ++otherFuelCell) { + for (int otherFuelCell = thisFuelCell + 1; otherFuelCell <= DataGenerators::NumFuelCellGenerators; ++otherFuelCell) { if (UtilityRoutines::SameString(DataGenerators::FuelCell(otherFuelCell).WaterSup.Name, DataGenerators::FuelCell(thisFuelCell).WaterSup.Name)) { DataGenerators::FuelCell(otherFuelCell).WaterSup = DataGenerators::FuelCell(thisFuelCell).WaterSup; } @@ -643,19 +616,20 @@ namespace FuelCellElectricGenerator { } DataIPShortCuts::cCurrentModuleObject = "Generator:FuelCell:AuxiliaryHeater"; - NumFuelCellAuxilHeaters = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); + int NumFuelCellAuxilHeaters = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); if (NumFuelCellAuxilHeaters <= 0) { ShowSevereError("No " + DataIPShortCuts::cCurrentModuleObject + " equipment specified in input file"); ErrorsFound = true; } - for (FCAuxHeatNum = 1; FCAuxHeatNum <= NumFuelCellAuxilHeaters; ++FCAuxHeatNum) { + for (int FCAuxHeatNum = 1; FCAuxHeatNum <= NumFuelCellAuxilHeaters; ++FCAuxHeatNum) { inputProcessor->getObjectItem( DataIPShortCuts::cCurrentModuleObject, FCAuxHeatNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat, _, _, DataIPShortCuts::cAlphaFieldNames, DataIPShortCuts::cNumericFieldNames); UtilityRoutines::IsNameEmpty(AlphArray(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); - thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), DataGenerators::FuelCell, &DataGenerators::FCDataStruct::NameFCAuxilHeat); + int thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), DataGenerators::FuelCell, &DataGenerators::FCDataStruct::NameFCAuxilHeat); + if (thisFuelCell > 0) { DataGenerators::FuelCell(thisFuelCell).AuxilHeat.Name = AlphArray(1); @@ -690,7 +664,7 @@ namespace FuelCellElectricGenerator { // TODO finish Auxiliary heater // check for other FuelCell using the same Auxiliary Heating module and fill - for (otherFuelCell = thisFuelCell + 1; otherFuelCell <= DataGenerators::NumFuelCellGenerators; ++otherFuelCell) { + for (int otherFuelCell = thisFuelCell + 1; otherFuelCell <= DataGenerators::NumFuelCellGenerators; ++otherFuelCell) { if (UtilityRoutines::SameString(DataGenerators::FuelCell(otherFuelCell).AuxilHeat.Name, DataGenerators::FuelCell(thisFuelCell).AuxilHeat.Name)) { DataGenerators::FuelCell(otherFuelCell).AuxilHeat = DataGenerators::FuelCell(thisFuelCell).AuxilHeat; } @@ -704,19 +678,20 @@ namespace FuelCellElectricGenerator { // exhaust gas heat exchanger DataIPShortCuts::cCurrentModuleObject = "Generator:FuelCell:ExhaustGasToWaterHeatExchanger"; - NumFCExhaustGasHXs = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); + int NumFCExhaustGasHXs = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); if (NumFCExhaustGasHXs <= 0) { ShowWarningError("No " + DataIPShortCuts::cCurrentModuleObject + " equipment specified in input file"); ShowContinueError("Fuel Cell model requires an " + DataIPShortCuts::cCurrentModuleObject + " object"); ErrorsFound = true; } - for (FCHXNum = 1; FCHXNum <= NumFCExhaustGasHXs; ++FCHXNum) { + for (int FCHXNum = 1; FCHXNum <= NumFCExhaustGasHXs; ++FCHXNum) { inputProcessor->getObjectItem( DataIPShortCuts::cCurrentModuleObject, FCHXNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat, _, _, DataIPShortCuts::cAlphaFieldNames, DataIPShortCuts::cNumericFieldNames); UtilityRoutines::IsNameEmpty(AlphArray(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); - thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), DataGenerators::FuelCell, &DataGenerators::FCDataStruct::NameExhaustHX); + int thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), DataGenerators::FuelCell, &DataGenerators::FCDataStruct::NameExhaustHX); + if (thisFuelCell > 0) { DataGenerators::FuelCell(thisFuelCell).ExhaustHX.Name = AlphArray(1); DataGenerators::FuelCell(thisFuelCell).ExhaustHX.WaterInNodeName = AlphArray(2); @@ -787,7 +762,7 @@ namespace FuelCellElectricGenerator { } DataIPShortCuts::cCurrentModuleObject = "Generator:FuelCell:ElectricalStorage"; - NumFCElecStorageUnits = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); + int NumFCElecStorageUnits = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); if (NumFCElecStorageUnits <= 0) { ShowWarningError("No " + DataIPShortCuts::cCurrentModuleObject + " equipment specified in input file"); @@ -795,12 +770,13 @@ namespace FuelCellElectricGenerator { ErrorsFound = true; } - for (StorageNum = 1; StorageNum <= NumFCElecStorageUnits; ++StorageNum) { + for (int StorageNum = 1; StorageNum <= NumFCElecStorageUnits; ++StorageNum) { inputProcessor->getObjectItem( DataIPShortCuts::cCurrentModuleObject, StorageNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat, _, _, DataIPShortCuts::cAlphaFieldNames, DataIPShortCuts::cNumericFieldNames); UtilityRoutines::IsNameEmpty(AlphArray(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); - thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), DataGenerators::FuelCell, &DataGenerators::FCDataStruct::NameElecStorage); + int thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), DataGenerators::FuelCell, &DataGenerators::FCDataStruct::NameElecStorage); + if (thisFuelCell > 0) { DataGenerators::FuelCell(thisFuelCell).ElecStorage.Name = AlphArray(1); @@ -819,7 +795,7 @@ namespace FuelCellElectricGenerator { DataGenerators::FuelCell(thisFuelCell).ElecStorage.StartingEnergyStored = NumArray(6); // check for other FuelCell using the same Electrical Storage and fill - for (otherFuelCell = thisFuelCell + 1; otherFuelCell <= DataGenerators::NumFuelCellGenerators; ++otherFuelCell) { + for (int otherFuelCell = thisFuelCell + 1; otherFuelCell <= DataGenerators::NumFuelCellGenerators; ++otherFuelCell) { if (UtilityRoutines::SameString(DataGenerators::FuelCell(otherFuelCell).ElecStorage.Name, DataGenerators::FuelCell(thisFuelCell).ElecStorage.Name)) { DataGenerators::FuelCell(otherFuelCell).ElecStorage = DataGenerators::FuelCell(thisFuelCell).ElecStorage; } @@ -832,7 +808,7 @@ namespace FuelCellElectricGenerator { } DataIPShortCuts::cCurrentModuleObject = "Generator:FuelCell:Inverter"; - NumFCPowerCondUnits = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); + int NumFCPowerCondUnits = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); if (NumFCPowerCondUnits <= 0) { ShowWarningError("No " + DataIPShortCuts::cCurrentModuleObject + " equipment specified in input file"); @@ -841,12 +817,13 @@ namespace FuelCellElectricGenerator { ErrorsFound = true; } - for (FCPCUNum = 1; FCPCUNum <= NumFCPowerCondUnits; ++FCPCUNum) { + for (int FCPCUNum = 1; FCPCUNum <= NumFCPowerCondUnits; ++FCPCUNum) { inputProcessor->getObjectItem( DataIPShortCuts::cCurrentModuleObject, FCPCUNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat, _, _, DataIPShortCuts::cAlphaFieldNames, DataIPShortCuts::cNumericFieldNames); UtilityRoutines::IsNameEmpty(AlphArray(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); - thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), DataGenerators::FuelCell, &DataGenerators::FCDataStruct::NameInverter); + int thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), DataGenerators::FuelCell, &DataGenerators::FCDataStruct::NameInverter); + if (thisFuelCell > 0) { DataGenerators::FuelCell(thisFuelCell).Inverter.Name = AlphArray(1); @@ -870,7 +847,7 @@ namespace FuelCellElectricGenerator { } // check for other FuelCell using the same Inverter and fill - for (otherFuelCell = thisFuelCell + 1; otherFuelCell <= DataGenerators::NumFuelCellGenerators; ++otherFuelCell) { + for (int otherFuelCell = thisFuelCell + 1; otherFuelCell <= DataGenerators::NumFuelCellGenerators; ++otherFuelCell) { if (UtilityRoutines::SameString(DataGenerators::FuelCell(otherFuelCell).Inverter.Name, DataGenerators::FuelCell(thisFuelCell).Inverter.Name)) { DataGenerators::FuelCell(otherFuelCell).Inverter = DataGenerators::FuelCell(thisFuelCell).Inverter; } @@ -883,10 +860,10 @@ namespace FuelCellElectricGenerator { } DataIPShortCuts::cCurrentModuleObject = "Generator:FuelCell:StackCooler"; - NumFCStackCoolers = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); + int NumFCStackCoolers = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); if (NumFCStackCoolers > 0) { // get stack cooler input data - for (FCScoolNum = 1; FCScoolNum <= NumFCStackCoolers; ++FCScoolNum) { + for (int FCScoolNum = 1; FCScoolNum <= NumFCStackCoolers; ++FCScoolNum) { inputProcessor->getObjectItem(DataIPShortCuts::cCurrentModuleObject, FCScoolNum, AlphArray, @@ -900,7 +877,8 @@ namespace FuelCellElectricGenerator { DataIPShortCuts::cNumericFieldNames); UtilityRoutines::IsNameEmpty(AlphArray(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); - thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), DataGenerators::FuelCell, &DataGenerators::FCDataStruct::NameStackCooler); + int thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), DataGenerators::FuelCell, &DataGenerators::FCDataStruct::NameStackCooler); + if (thisFuelCell > 0) { DataGenerators::FuelCell(thisFuelCell).StackCooler.Name = AlphArray(1); DataGenerators::FuelCell(thisFuelCell).StackCooler.WaterInNodeName = AlphArray(2); @@ -1361,40 +1339,8 @@ namespace FuelCellElectricGenerator { static bool ConstrainedFCPM(false); // true if power prod is constrained for some reason static bool ConstrainedFCPMTrans(false); Real64 PelDiff; - int iter; // loop index over repeating set of inter dependent calculaitons - Real64 NdotO2; // molar rate coeff working varible - Real64 CpWater; // heat capacity of water in molar units - Real64 WaterEnthOfForm; // Standard molar enthalpy of formation - Real64 NdotFuel; // fuel flow rate - Real64 NdotStoicAir; // Air to match fuel molar rate coeff, working variable - Real64 NdotExcessAir; // Air in excess of match for fuel - Real64 NdotCO2ProdGas; // CO2 from reaction - Real64 NdotH20ProdGas; // Water from reaction - Real64 NdotCO2; // temp CO2 molar rate coef product gas stream - Real64 NdotN2; // temp Nitrogen rate coef product gas stream - Real64 Ndot02; // temp Oxygen rate coef product gas stream - Real64 NdotH20; // temp Water rate coef product gas stream - Real64 NdotAr; // tmep Argon rate coef product gas stream - Real64 Cp; // temp Heat Capacity, used in thermochemistry units of (J/mol K) - Real64 Hmolfuel; // temp enthalpy of fuel mixture in KJ/mol - Real64 Hmolair; // temp enthalpy of air mixture in KJ/mol - Real64 HmolProdGases; // enthalpy of product gas mixture in KJ/mol - Real64 HLiqWater; // temp enthalpy of liquid water in KJ/mol No Formation - Real64 HGasWater; // temp enthalpy of gaseous water in KJ/mol No Formation - int thisGas; // loop index - Real64 MagofImbalance; // error signal to control exiting loop and targeting product enthalpy - Real64 tmpTotProdGasEnthalphy; - Real64 Acc; // accuracy control for SolveRoot - int MaxIter; // iteration control for SolveRoot - int SolverFlag; // feed back flag from SolveRoot + Real64 NdotO2; // molar rate coeff working variable Array1D Par(3); // parameters passed in to SolveRoot - Real64 tmpTprodGas; - bool ConstrainedStorage; // contrained overall elect because of storage - Real64 PgridExtra; // extra electric power that should go into storage but can't - Real64 Pstorage; // power into storage (+), power from storage (-) - Real64 PintoInverter; // power into inverter after storage interactions - Real64 PoutofInverter; // power out of inverter after losses and including storage - Real64 PacAncillariesTotal; // total AC ancillaries // begin controls block to be moved out to GeneratorDynamics module // If no loop demand or Generator OFF, return @@ -1440,14 +1386,16 @@ namespace FuelCellElectricGenerator { // Note: MyLoad (input) is Pdemand (electical Power requested) Pdemand = MyLoad; - PacAncillariesTotal = 0.0; + Real64 PacAncillariesTotal = 0.0; PpcuLosses = 0.0; - Pstorage = 0.0; - PgridExtra = 0.0; - PoutofInverter = 0.0; + Real64 Pstorage = 0.0; + Real64 PgridExtra = 0.0; + Real64 PoutofInverter = 0.0; ConstrainedFCPM = false; + int SolverFlag; + int iter; - //! BEGIN SEQUENTIAL SUBSTITUTION to handle a lot of inter-related calcs + // BEGIN SEQUENTIAL SUBSTITUTION to handle a lot of inter-related calcs for (iter = 1; iter <= 20; ++iter) { if (iter > 1) { FigurePowerConditioningLosses(GeneratorNum, PoutofInverter, PpcuLosses); @@ -1510,7 +1458,8 @@ namespace FuelCellElectricGenerator { DataGenerators::FuelCell(GeneratorNum).FCPM.Eel = Eel; // Calculation Step 2. Determine fuel rate - NdotFuel = Pel / (Eel * DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).LHV * 1000000.0); // Eq. 10 solved for Ndot + // fuel flow rate + Real64 NdotFuel = Pel / (Eel * DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).LHV * 1000000.0); // Eq. 10 solved for Ndot DataGenerators::FuelCell(GeneratorNum).FCPM.NdotFuel = NdotFuel; if (Pel <= 0.0) { @@ -1559,14 +1508,15 @@ namespace FuelCellElectricGenerator { ScheduleManager::GetCurrentScheduleValue(DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).SchedNum); } - // evaluate heat capacity at average temperature usign shomate + // evaluate heat capacity at average temperature using shomate + Real64 Cp; // temp Heat Capacity, used in thermochemistry units of (J/mol K) Tavg = (DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).TfuelIntoCompress + DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).TfuelIntoFCPM) / 2.0; FigureFuelHeatCap(GeneratorNum, Tavg, Cp); // Cp in (J/mol K) // calculate a Temp of fuel out of compressor and into power module - if (DataGenerators::FuelCell(GeneratorNum).FCPM.NdotFuel <= 0.0) { // just pass through, domain probably collapased in modeling + if (DataGenerators::FuelCell(GeneratorNum).FCPM.NdotFuel <= 0.0) { // just pass through, domain probably collapsed in modeling DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).TfuelIntoFCPM = DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).TfuelIntoCompress; } else { DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).TfuelIntoFCPM = @@ -1587,6 +1537,7 @@ namespace FuelCellElectricGenerator { // calculate tatal fuel enthalpy coming into power module // (Hmolfuel in KJ/mol) + Real64 Hmolfuel; // temp enthalpy of fuel mixture in KJ/mol FigureFuelEnthalpy(GeneratorNum, DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).TfuelIntoFCPM, Hmolfuel); // units, NdotFuel in kmol/sec. Hmolfule in KJ/mol , @@ -1623,11 +1574,10 @@ namespace FuelCellElectricGenerator { CurveManager::CurveValue(DataGenerators::FuelCell(GeneratorNum).WaterSup.PmpPowerCurveID, DataGenerators::FuelCell(GeneratorNum).FCPM.NdotLiqwater); // 75.325 J/mol K Water at 0.1 MPa and 298 K, reference NIST WEBBOOK + Real64 CpWater; // heat capacity of water in molar units FigureLiquidWaterHeatCap(DataGenerators::FuelCell(GeneratorNum).WaterSup.TwaterIntoCompress, CpWater); - WaterEnthOfForm = -241.8264; // KJ/mol - - if (DataGenerators::FuelCell(GeneratorNum).FCPM.NdotLiqwater <= 0.0) { // just pass through, domain probably collapased in modeling + if (DataGenerators::FuelCell(GeneratorNum).FCPM.NdotLiqwater <= 0.0) { // just pass through, domain probably collapsed in modeling DataGenerators::FuelCell(GeneratorNum).WaterSup.TwaterIntoFCPM = DataGenerators::FuelCell(GeneratorNum).WaterSup.TwaterIntoCompress; } else { @@ -1645,6 +1595,7 @@ namespace FuelCellElectricGenerator { DataGenerators::FuelCell(GeneratorNum).WaterSup.QskinLoss = 0.0; } + Real64 HLiqWater; // temp enthalpy of liquid water in KJ/mol No Formation FigureLiquidWaterEnthalpy(DataGenerators::FuelCell(GeneratorNum).WaterSup.TwaterIntoFCPM, HLiqWater); // HLiqWater in KJ/mol DataGenerators::FuelCell(GeneratorNum).FCPM.WaterInEnthalpy = DataGenerators::FuelCell(GeneratorNum).FCPM.NdotLiqwater * HLiqWater * 1000.0 * 1000.0; @@ -1714,6 +1665,7 @@ namespace FuelCellElectricGenerator { DataGenerators::FuelCell(GeneratorNum).AirSup.QskinLoss = 0.0; } + Real64 Hmolair; // temp enthalpy of air mixture in KJ/mol FigureAirEnthalpy(GeneratorNum, DataGenerators::FuelCell(GeneratorNum).AirSup.TairIntoFCPM, Hmolair); // (Hmolair in KJ/mol) // units, NdotAir in kmol/sec.; Hmolfuel in KJ/mol , @@ -1725,11 +1677,13 @@ namespace FuelCellElectricGenerator { // figure stoic N dot for air NdotO2 = DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).StoicOxygenRate * DataGenerators::FuelCell(GeneratorNum).FCPM.NdotFuel; - NdotStoicAir = NdotO2 / DataGenerators::FuelCell(GeneratorNum).AirSup.O2fraction; + // Air in excess of match for fuel + Real64 NdotStoicAir = NdotO2 / DataGenerators::FuelCell(GeneratorNum).AirSup.O2fraction; // figure excess air rate - NdotExcessAir = DataGenerators::FuelCell(GeneratorNum).FCPM.NdotAir - NdotStoicAir; + // Air in excess of match for fuel + Real64 NdotExcessAir = DataGenerators::FuelCell(GeneratorNum).FCPM.NdotAir - NdotStoicAir; if (NdotExcessAir < 0) { // can't meet stoichiometric fuel reaction @@ -1739,20 +1693,22 @@ namespace FuelCellElectricGenerator { // figure CO2 and Water rate from products (coefs setup during one-time processing in gas phase library ) - NdotCO2ProdGas = DataGenerators::FuelCell(GeneratorNum).FCPM.NdotFuel * DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).CO2ProductGasCoef; + // CO2 from reaction + Real64 NdotCO2ProdGas = DataGenerators::FuelCell(GeneratorNum).FCPM.NdotFuel * DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).CO2ProductGasCoef; - NdotH20ProdGas = DataGenerators::FuelCell(GeneratorNum).FCPM.NdotFuel * DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).H20ProductGasCoef; + // Water from reaction + Real64 NdotH20ProdGas = DataGenerators::FuelCell(GeneratorNum).FCPM.NdotFuel * DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).H20ProductGasCoef; // set product gas constituent fractions (assume five usual components) - NdotCO2 = 0.0; - NdotN2 = 0.0; - Ndot02 = 0.0; - NdotH20 = 0.0; - NdotAr = 0.0; + Real64 NdotCO2 = 0.0; // temp CO2 molar rate coef product gas stream + Real64 NdotN2 = 0.0; // temp Nitrogen rate coef product gas stream + Real64 Ndot02 = 0.0; // temp Oxygen rate coef product gas stream + Real64 NdotH20 = 0.0; // temp Water rate coef product gas stream + Real64 NdotAr = 0.0; // temp Argon rate coef product gas stream - // Product gas constiuents are fixed (not a user defined thing) + // Product gas constituents are fixed (not a user defined thing) - for (thisGas = 1; thisGas <= DataGenerators::FuelCell(GeneratorNum).AirSup.NumConstituents; ++thisGas) { + for (int thisGas = 1; thisGas <= DataGenerators::FuelCell(GeneratorNum).AirSup.NumConstituents; ++thisGas) { { auto const SELECT_CASE_var(DataGenerators::FuelCell(GeneratorNum).AirSup.GasLibID(thisGas)); @@ -1802,6 +1758,7 @@ namespace FuelCellElectricGenerator { DataGenerators::FuelCell(GeneratorNum).FCPM.ConstitMolalFract(5) = NdotAr / DataGenerators::FuelCell(GeneratorNum).FCPM.NdotProdGas; // HmolProdGases KJ/mol) + Real64 HmolProdGases; // enthalpy of product gas mixture in KJ/mol FigureProductGasesEnthalpy(GeneratorNum, DataGenerators::FuelCell(GeneratorNum).FCPM.TprodGasLeavingFCPM, HmolProdGases); // units, NdotProdGas in kmol/sec.; HmolProdGases in KJ/mol , @@ -1841,6 +1798,7 @@ namespace FuelCellElectricGenerator { DataGenerators::FuelCell(GeneratorNum).FCPM.DilutionAirInEnthalpy + DataGenerators::FuelCell(GeneratorNum).FCPM.StackHeatLossToDilution; // calculation Step 12, Calculate Reforming water out enthalpy + Real64 HGasWater; // temp enthalpy of gaseous water in KJ/mol No Formation FigureGaseousWaterEnthalpy(DataGenerators::FuelCell(GeneratorNum).FCPM.TprodGasLeavingFCPM, HGasWater); DataGenerators::FuelCell(GeneratorNum).FCPM.WaterOutEnthalpy = HGasWater * 1000.0 * DataGenerators::FuelCell(GeneratorNum).FCPM.NdotLiqwater * 1000.0; @@ -1848,7 +1806,7 @@ namespace FuelCellElectricGenerator { // calculation Step 13, Calculate Heat balance // move all terms in Equation 7 to RHS and calculate imbalance - MagofImbalance = -DataGenerators::FuelCell(GeneratorNum).FCPM.TotFuelInEnthalphy - DataGenerators::FuelCell(GeneratorNum).FCPM.TotAirInEnthalphy - + Real64 MagofImbalance = -DataGenerators::FuelCell(GeneratorNum).FCPM.TotFuelInEnthalphy - DataGenerators::FuelCell(GeneratorNum).FCPM.TotAirInEnthalphy - DataGenerators::FuelCell(GeneratorNum).FCPM.WaterInEnthalpy - DataGenerators::FuelCell(GeneratorNum).FCPM.DilutionAirInEnthalpy - DataGenerators::FuelCell(GeneratorNum).FCPM.NdotFuel * DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).LHV * 1000000.0 - DataGenerators::FuelCell(GeneratorNum).FCPM.PelancillariesAC + DataGenerators::FuelCell(GeneratorNum).FCPM.Pel + @@ -1858,17 +1816,17 @@ namespace FuelCellElectricGenerator { // Now find a new total prod Gas Enthalphy that would result in an energy balance // TODO check signs... - tmpTotProdGasEnthalphy = DataGenerators::FuelCell(GeneratorNum).FCPM.TotProdGasEnthalphy - MagofImbalance; + Real64 tmpTotProdGasEnthalpy = DataGenerators::FuelCell(GeneratorNum).FCPM.TotProdGasEnthalphy - MagofImbalance; // solve for a new TprodGasLeavingFCPM using regula falsi method - Acc = 0.01; // guessing need to refine - MaxIter = 150; // guessing need to refine + Real64 Acc = 0.01; // guessing need to refine + int MaxIter = 150; // guessing need to refine SolverFlag = 0; // init Par(1) = double(GeneratorNum); - Par(2) = tmpTotProdGasEnthalphy; + Par(2) = tmpTotProdGasEnthalpy; Par(3) = DataGenerators::FuelCell(GeneratorNum).FCPM.NdotProdGas; - tmpTprodGas = DataGenerators::FuelCell(GeneratorNum).FCPM.TprodGasLeavingFCPM; + Real64 tmpTprodGas = DataGenerators::FuelCell(GeneratorNum).FCPM.TprodGasLeavingFCPM; General::SolveRoot(Acc, MaxIter, SolverFlag, tmpTprodGas, FuelCellProductGasEnthResidual, DataGenerators::MinProductGasTemp, DataGenerators::MaxProductGasTemp, Par); if (SolverFlag == -2) { @@ -1887,7 +1845,8 @@ namespace FuelCellElectricGenerator { // Control Step 3 determine interaction with electrical storage // How much power is really going into inverter? - PintoInverter = Pel + Pstorage; // Back out so we can reapply + Real64 PintoInverter = Pel + Pstorage; // Back out so we can reapply + bool ConstrainedStorage; ManageElectStorInteractions(GeneratorNum, Pdemand, PpcuLosses, ConstrainedStorage, Pstorage, PgridExtra); PintoInverter = Pel - Pstorage; // refine power conditioning losses with more current power production From b40504bc7a075d9edd68a9b657cc455cdad5992d Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Mon, 11 Nov 2019 15:30:35 -0700 Subject: [PATCH 21/51] partial cleanup local vars --- src/EnergyPlus/FuelCellElectricGenerator.cc | 32 +++++++++------------ 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/src/EnergyPlus/FuelCellElectricGenerator.cc b/src/EnergyPlus/FuelCellElectricGenerator.cc index 94720825445..bb0ea24ac0c 100644 --- a/src/EnergyPlus/FuelCellElectricGenerator.cc +++ b/src/EnergyPlus/FuelCellElectricGenerator.cc @@ -1331,15 +1331,6 @@ namespace FuelCellElectricGenerator { // REFERENCES: IEA/ECBCS Annex 42.... - static Real64 PpcuLosses; // losses in inverter [W] - Real64 Pel; // DC power generated in Fuel Cell Power Module - Real64 Pdemand; - Real64 Eel; - Real64 Tavg; // working average temperature - static bool ConstrainedFCPM(false); // true if power prod is constrained for some reason - static bool ConstrainedFCPMTrans(false); - Real64 PelDiff; - Real64 NdotO2; // molar rate coeff working variable Array1D Par(3); // parameters passed in to SolveRoot // begin controls block to be moved out to GeneratorDynamics module @@ -1384,16 +1375,17 @@ namespace FuelCellElectricGenerator { return; } - // Note: MyLoad (input) is Pdemand (electical Power requested) - Pdemand = MyLoad; + // Note: MyLoad (input) is Pdemand (electrical Power requested) + Real64 Pdemand = MyLoad; Real64 PacAncillariesTotal = 0.0; - PpcuLosses = 0.0; + Real64 PpcuLosses = 0.0; Real64 Pstorage = 0.0; Real64 PgridExtra = 0.0; Real64 PoutofInverter = 0.0; - ConstrainedFCPM = false; + bool ConstrainedFCPM = false; int SolverFlag; int iter; + Real64 Pel; // BEGIN SEQUENTIAL SUBSTITUTION to handle a lot of inter-related calcs for (iter = 1; iter <= 20; ++iter) { @@ -1415,6 +1407,8 @@ namespace FuelCellElectricGenerator { // Control step 2: adjust for transient and startup/shut down constraints + Real64 PelDiff; + bool ConstrainedFCPMTrans = false; FigureTransientConstraints(GeneratorNum, Pel, ConstrainedFCPMTrans, PelDiff); // Control step 3: adjust for max and min limits on Pel @@ -1438,6 +1432,7 @@ namespace FuelCellElectricGenerator { // Calculation Step 1. Determine electrical Efficiency Eel + Real64 Eel = 0.0; if (DataGenerators::FuelCell(GeneratorNum).FCPM.EffMode == DataGenerators::NormalizedCurveMode) { // Equation (8) in FuelCell Spec modified for normalized curve @@ -1475,7 +1470,8 @@ namespace FuelCellElectricGenerator { // Calculation Step 3. Determine Air rate if (DataGenerators::FuelCell(GeneratorNum).AirSup.AirSupRateMode == DataGenerators::ConstantStoicsAirRat) { // MEthod 1 - NdotO2 = DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).StoicOxygenRate * DataGenerators::FuelCell(GeneratorNum).FCPM.NdotFuel * + // molar rate coeff working variable + Real64 NdotO2 = DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).StoicOxygenRate * DataGenerators::FuelCell(GeneratorNum).FCPM.NdotFuel * DataGenerators::FuelCell(GeneratorNum).AirSup.Stoics; DataGenerators::FuelCell(GeneratorNum).FCPM.NdotAir = NdotO2 / DataGenerators::FuelCell(GeneratorNum).AirSup.O2fraction; @@ -1510,8 +1506,7 @@ namespace FuelCellElectricGenerator { // evaluate heat capacity at average temperature using shomate Real64 Cp; // temp Heat Capacity, used in thermochemistry units of (J/mol K) - Tavg = - (DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).TfuelIntoCompress + DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).TfuelIntoFCPM) / 2.0; + Real64 Tavg = (DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).TfuelIntoCompress + DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).TfuelIntoFCPM) / 2.0; FigureFuelHeatCap(GeneratorNum, Tavg, Cp); // Cp in (J/mol K) // calculate a Temp of fuel out of compressor and into power module @@ -1529,8 +1524,7 @@ namespace FuelCellElectricGenerator { DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).CompPowerLossFactor * DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).PfuelCompEl; if (DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).QskinLoss < 0.0) { - // write(*,*) 'problem in FuelSupply%QskinLoss ', FuelSupply(DataGenerators::FuelCell(GeneratorNum)%FuelSupNum)%QskinLoss - ShowWarningError("problem in FuelSupply%QskinLoss " + General::RoundSigDigits(DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).QskinLoss, 3)); + ShowWarningError("problem in FuelSupply.QskinLoss " + General::RoundSigDigits(DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).QskinLoss, 3)); DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).QskinLoss = 0.0; } @@ -1675,7 +1669,7 @@ namespace FuelCellElectricGenerator { // calculation Step 8, Figure Product Gases // figure stoic N dot for air - NdotO2 = DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).StoicOxygenRate * DataGenerators::FuelCell(GeneratorNum).FCPM.NdotFuel; + Real64 NdotO2 = DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).StoicOxygenRate * DataGenerators::FuelCell(GeneratorNum).FCPM.NdotFuel; // Air in excess of match for fuel Real64 NdotStoicAir = NdotO2 / DataGenerators::FuelCell(GeneratorNum).AirSup.O2fraction; From 896bfe3fc632f2513f7ed5008c452a72f59dd7f2 Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Mon, 11 Nov 2019 15:47:08 -0700 Subject: [PATCH 22/51] partial cleanup local vars --- src/EnergyPlus/FuelCellElectricGenerator.cc | 113 +++++++------------- 1 file changed, 37 insertions(+), 76 deletions(-) diff --git a/src/EnergyPlus/FuelCellElectricGenerator.cc b/src/EnergyPlus/FuelCellElectricGenerator.cc index bb0ea24ac0c..4d5d2924d8a 100644 --- a/src/EnergyPlus/FuelCellElectricGenerator.cc +++ b/src/EnergyPlus/FuelCellElectricGenerator.cc @@ -1331,8 +1331,6 @@ namespace FuelCellElectricGenerator { // REFERENCES: IEA/ECBCS Annex 42.... - Array1D Par(3); // parameters passed in to SolveRoot - // begin controls block to be moved out to GeneratorDynamics module // If no loop demand or Generator OFF, return if (!RunFlag) { @@ -1817,6 +1815,7 @@ namespace FuelCellElectricGenerator { Real64 Acc = 0.01; // guessing need to refine int MaxIter = 150; // guessing need to refine SolverFlag = 0; // init + Array1D Par(3); // parameters passed in to SolveRoot Par(1) = double(GeneratorNum); Par(2) = tmpTotProdGasEnthalpy; Par(3) = DataGenerators::FuelCell(GeneratorNum).FCPM.NdotProdGas; @@ -1897,19 +1896,11 @@ namespace FuelCellElectricGenerator { // PURPOSE OF THIS SUBROUTINE: // manage controls and calculations related to electrical storage in FuelCell model - Real64 tmpPdraw; // power draw from storage, working var - Real64 tmpPcharge; // power charge to storage, working var - bool drawing; // true if drawing power - bool charging; // true if charging - - // initialize locals - tmpPdraw = 0.0; - tmpPcharge = 0.0; - drawing = false; - charging = false; + Real64 tmpPdraw = 0.0; + Real64 tmpPcharge = 0.0; + bool drawing = false; // true if drawing power + bool charging = false; // true if charging Constrained = false; - Pstorage = 0.0; - PgridOverage = 0.0; // step 1 figure out what is desired of electrical storage system @@ -2068,14 +2059,10 @@ namespace FuelCellElectricGenerator { Real64 Residuum; // F(x) - int GeneratorNum; Real64 thisHmolalProdGases; - Real64 desiredHprodGases; - Real64 NdotProdGases; - - GeneratorNum = std::floor(Par(1)); - desiredHprodGases = Par(2); - NdotProdGases = Par(3); + int GeneratorNum = std::floor(Par(1)); + Real64 desiredHprodGases = Par(2); + Real64 NdotProdGases = Par(3); FigureProductGasesEnthalpy(GeneratorNum, TprodGas, thisHmolalProdGases); @@ -2107,8 +2094,6 @@ namespace FuelCellElectricGenerator { // NIST Webbook on gas phase thermochemistry Real64 tempCp; - int thisConstit; // loop index - int gasID; Real64 A; // shomate coeff Real64 B; // shomate coeff Real64 C; // shomate coeff @@ -2135,8 +2120,8 @@ namespace FuelCellElectricGenerator { Real64 const pow_3_Tkel(pow_3(Tkel)); Real64 const pow_4_Tkel(pow_4(Tkel)); - for (thisConstit = 1; thisConstit <= DataGenerators::FuelCell(GeneratorNum).AirSup.NumConstituents; ++thisConstit) { - gasID = DataGenerators::FuelCell(GeneratorNum).AirSup.GasLibID(thisConstit); + for (int thisConstit = 1; thisConstit <= DataGenerators::FuelCell(GeneratorNum).AirSup.NumConstituents; ++thisConstit) { + int gasID = DataGenerators::FuelCell(GeneratorNum).AirSup.GasLibID(thisConstit); if (gasID > 0) { if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == DataGenerators::NISTShomate) { @@ -2191,8 +2176,6 @@ namespace FuelCellElectricGenerator { Real64 tempHair; Real64 HairI; - int thisConstit; // loop index - int gasID; // look up into Gas structure Real64 A; // shomate coeff Real64 B; // shomate coeff Real64 C; // shomate coeff @@ -2221,8 +2204,8 @@ namespace FuelCellElectricGenerator { Real64 const pow_3_Tkel(pow_3(Tkel)); Real64 const pow_4_Tkel(pow_4(Tkel)); - for (thisConstit = 1; thisConstit <= DataGenerators::FuelCell(GeneratorNum).AirSup.NumConstituents; ++thisConstit) { - gasID = DataGenerators::FuelCell(GeneratorNum).AirSup.GasLibID(thisConstit); + for (int thisConstit = 1; thisConstit <= DataGenerators::FuelCell(GeneratorNum).AirSup.NumConstituents; ++thisConstit) { + int gasID = DataGenerators::FuelCell(GeneratorNum).AirSup.GasLibID(thisConstit); if (gasID > 0) { if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == DataGenerators::NISTShomate) { @@ -2280,8 +2263,6 @@ namespace FuelCellElectricGenerator { // NIST Webbook on gas phase thermochemistry Real64 tempCp; - int thisConstit; // loop index - int gasID; // look up into Gas structure Real64 A; // shomate coeff Real64 B; // shomate coeff Real64 C; // shomate coeff @@ -2306,8 +2287,8 @@ namespace FuelCellElectricGenerator { Real64 const pow_3_Tkel(pow_3(Tkel)); Real64 const pow_4_Tkel(pow_4(Tkel)); - for (thisConstit = 1; thisConstit <= DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).NumConstituents; ++thisConstit) { - gasID = DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).GasLibID(thisConstit); + for (int thisConstit = 1; thisConstit <= DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).NumConstituents; ++thisConstit) { + int gasID = DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).GasLibID(thisConstit); if (gasID > 0) { if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == DataGenerators::NISTShomate) { @@ -2361,8 +2342,6 @@ namespace FuelCellElectricGenerator { Real64 tempHfuel; Real64 HfuelI; - int thisConstit; // loop index - int gasID; // look up into Gas structure Real64 A; // shomate coeff Real64 B; // shomate coeff Real64 C; // shomate coeff @@ -2391,8 +2370,8 @@ namespace FuelCellElectricGenerator { Real64 const pow_3_Tkel(pow_3(Tkel)); Real64 const pow_4_Tkel(pow_4(Tkel)); - for (thisConstit = 1; thisConstit <= DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).NumConstituents; ++thisConstit) { - gasID = DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).GasLibID(thisConstit); + for (int thisConstit = 1; thisConstit <= DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).NumConstituents; ++thisConstit) { + int gasID = DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).GasLibID(thisConstit); if (gasID > 0) { if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == DataGenerators::NISTShomate) { A = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateA; @@ -2450,8 +2429,6 @@ namespace FuelCellElectricGenerator { // NIST Webbook on gas phase thermochemistry Real64 tempHprodGases; - int thisConstit; // loop index - int gasID; // look up into Gas structure Real64 A; // shomate coeff Real64 B; // shomate coeff Real64 C; // shomate coeff @@ -2480,8 +2457,8 @@ namespace FuelCellElectricGenerator { Real64 const pow_3_Tkel(pow_3(Tkel)); Real64 const pow_4_Tkel(pow_4(Tkel)); - for (thisConstit = 1; thisConstit <= 5; ++thisConstit) { - gasID = DataGenerators::FuelCell(GeneratorNum).FCPM.GasLibID(thisConstit); + for (int thisConstit = 1; thisConstit <= 5; ++thisConstit) { + int gasID = DataGenerators::FuelCell(GeneratorNum).FCPM.GasLibID(thisConstit); if (gasID > 0) { if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == DataGenerators::NISTShomate) { A = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateA; @@ -2527,8 +2504,6 @@ namespace FuelCellElectricGenerator { // RE-ENGINEERED na Real64 tempCp; - int thisConstit; // loop index - int gasID; // look up into Gas structure Real64 A; // shomate coeff Real64 B; // shomate coeff Real64 C; // shomate coeff @@ -2553,8 +2528,8 @@ namespace FuelCellElectricGenerator { Real64 const pow_3_Tkel(pow_3(Tkel)); Real64 const pow_4_Tkel(pow_4(Tkel)); - for (thisConstit = 1; thisConstit <= isize(DataGenerators::FuelCell(GeneratorNum).FCPM.GasLibID); ++thisConstit) { - gasID = DataGenerators::FuelCell(GeneratorNum).FCPM.GasLibID(thisConstit); + for (int thisConstit = 1; thisConstit <= isize(DataGenerators::FuelCell(GeneratorNum).FCPM.GasLibID); ++thisConstit) { + int gasID = DataGenerators::FuelCell(GeneratorNum).FCPM.GasLibID(thisConstit); if (gasID > 0) { if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == DataGenerators::NISTShomate) { @@ -2597,8 +2572,6 @@ namespace FuelCellElectricGenerator { // RE-ENGINEERED na Real64 tempCp; - int thisConstit; // loop index - int gasID; // look up into Gas structure Real64 A; // shomate coeff Real64 B; // shomate coeff Real64 C; // shomate coeff @@ -2623,8 +2596,8 @@ namespace FuelCellElectricGenerator { Real64 const pow_3_Tkel(pow_3(Tkel)); Real64 const pow_4_Tkel(pow_4(Tkel)); - for (thisConstit = 1; thisConstit <= isize(DataGenerators::FuelCell(GeneratorNum).AuxilHeat.GasLibID); ++thisConstit) { - gasID = DataGenerators::FuelCell(GeneratorNum).AuxilHeat.GasLibID(thisConstit); + for (int thisConstit = 1; thisConstit <= isize(DataGenerators::FuelCell(GeneratorNum).AuxilHeat.GasLibID); ++thisConstit) { + int gasID = DataGenerators::FuelCell(GeneratorNum).AuxilHeat.GasLibID(thisConstit); if (gasID > 0) { if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == DataGenerators::NISTShomate) { @@ -2783,24 +2756,19 @@ namespace FuelCellElectricGenerator { using DataGenerators::FuelCell; - Real64 lastPpcuLosses; // used in iterative solution - int iter; - Real64 Pel; - if (FuelCell(GeneratorNum).Inverter.EffMode == DataGenerators::InverterEffConstant) { - PpcuLosses = Pdemand * (1 - FuelCell(GeneratorNum).Inverter.ConstEff) / FuelCell(GeneratorNum).Inverter.ConstEff; } if (FuelCell(GeneratorNum).Inverter.EffMode == DataGenerators::InverterEffQuadratic) { // first use Pdemand instead of Pel to get initial estimate - lastPpcuLosses = Pdemand * (1.0 - CurveManager::CurveValue(FuelCell(GeneratorNum).Inverter.EffQuadraticCurveID, Pdemand)) / + Real64 lastPpcuLosses = Pdemand * (1.0 - CurveManager::CurveValue(FuelCell(GeneratorNum).Inverter.EffQuadraticCurveID, Pdemand)) / CurveManager::CurveValue(FuelCell(GeneratorNum).Inverter.EffQuadraticCurveID, Pdemand); - for (iter = 1; iter <= 20; ++iter) { // seems like need to iterate (??) Need to investigate number and convergence success here + for (int iter = 1; iter <= 20; ++iter) { // seems like need to iterate (??) Need to investigate number and convergence success here - Pel = Pdemand + lastPpcuLosses; + Real64 Pel = Pdemand + lastPpcuLosses; lastPpcuLosses = (1.0 - CurveManager::CurveValue(FuelCell(GeneratorNum).Inverter.EffQuadraticCurveID, Pel)) * Pel; } @@ -2951,17 +2919,8 @@ namespace FuelCellElectricGenerator { Real64 hwater; static Real64 waterFract(0.0); Real64 NdotWaterVapor; - Real64 TcondThresh; - Real64 hxl1; - Real64 hxl2; - static Real64 NdotWaterCond(0.0); - Real64 hfpwater; - int i; - - Real64 qSens; - Real64 qLatent; - int loop; - Real64 Cp; + + Real64 NdotWaterCond = 0.0; { auto const SELECT_CASE_var(DataGenerators::FuelCell(Num).ExhaustHX.HXmodelMode); @@ -2989,7 +2948,7 @@ namespace FuelCellElectricGenerator { THXexh = TprodGasIn - qHX / (NdotGas * CpProdGasMol * 1000.0); - Cp = FluidProperties::GetSpecificHeatGlycol( + Real64 Cp = FluidProperties::GetSpecificHeatGlycol( DataPlant::PlantLoop(DataGenerators::FuelCell(Num).CWLoopNum).FluidName, TwaterIn, DataPlant::PlantLoop(DataGenerators::FuelCell(Num).CWLoopNum).FluidIndex, RoutineName); if (MdotWater * Cp <= 0.0) { @@ -3106,20 +3065,20 @@ namespace FuelCellElectricGenerator { NdotCpAuxMix = NdotGas * CpProdGasMol * 1000.0; // find water fraction in incoming gas stream - for (i = 1; i <= isize(DataGenerators::FuelCell(Num).AuxilHeat.GasLibID); ++i) { + for (int i = 1; i <= isize(DataGenerators::FuelCell(Num).AuxilHeat.GasLibID); ++i) { if (DataGenerators::FuelCell(Num).AuxilHeat.GasLibID(i) == 4) waterFract = DataGenerators::FuelCell(Num).AuxilHeat.ConstitMolalFract(i); } NdotWaterVapor = waterFract * NdotGas; - TcondThresh = DataGenerators::FuelCell(Num).ExhaustHX.CondensationThresholdTemp; - hxl1 = DataGenerators::FuelCell(Num).ExhaustHX.l1Coeff; - hxl2 = DataGenerators::FuelCell(Num).ExhaustHX.l2Coeff; + Real64 TcondThresh = DataGenerators::FuelCell(Num).ExhaustHX.CondensationThresholdTemp; + Real64 hxl1 = DataGenerators::FuelCell(Num).ExhaustHX.l1Coeff; + Real64 hxl2 = DataGenerators::FuelCell(Num).ExhaustHX.l2Coeff; NdotWaterCond = (TcondThresh - TwaterIn) * (hxl1 * (NdotWaterVapor / NdotGas) + hxl2 * pow_2(NdotWaterVapor / NdotGas)); if (NdotWaterCond < 0.0) NdotWaterCond = 0.0; - hfpwater = 4.4004e+07; // molal heat of vaporization of water J/kmol) + Real64 hfpwater = 4.4004e+07; // molal heat of vaporization of water J/kmol) if ((NdotCpWater != 0.0) && (NdotCpAuxMix != 0.0)) { // trap divide by zero @@ -3134,9 +3093,11 @@ namespace FuelCellElectricGenerator { TwaterOut = TwaterIn + (NdotCpAuxMix / NdotCpWater) * (TauxMix - THXexh) + (NdotWaterCond * hfpwater) / NdotCpWater; if (NdotWaterCond > 0) { // Eq. 44 is not correct. use its result as first guess for revised way... + // iterative solution because in condensing case THXexh is function of qSens and qLatent + for (int loop = 1; loop <= 5; ++loop) { - for (loop = 1; loop <= 5; - ++loop) { // iterative soluion because in condensing case THXexh is function of qSens and qLatent + Real64 qSens; + Real64 qLatent; if ((THXexh - TwaterIn) != 0.0 && ((TauxMix - TwaterOut) / (THXexh - TwaterIn) > 0.0001)) { // trap divide by zero and negative log From 5f5cd124f281e1c2d34b1b5dac97778dc8377ab0 Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Tue, 12 Nov 2019 08:21:33 -0700 Subject: [PATCH 23/51] partial cleanup locals --- src/EnergyPlus/FuelCellElectricGenerator.cc | 286 ++++++++------------ src/EnergyPlus/FuelCellElectricGenerator.hh | 88 +++--- 2 files changed, 164 insertions(+), 210 deletions(-) diff --git a/src/EnergyPlus/FuelCellElectricGenerator.cc b/src/EnergyPlus/FuelCellElectricGenerator.cc index 4d5d2924d8a..f9777a56f04 100644 --- a/src/EnergyPlus/FuelCellElectricGenerator.cc +++ b/src/EnergyPlus/FuelCellElectricGenerator.cc @@ -2754,23 +2754,21 @@ namespace FuelCellElectricGenerator { // PURPOSE OF THIS SUBROUTINE: // Calculate inverter losses - using DataGenerators::FuelCell; - - if (FuelCell(GeneratorNum).Inverter.EffMode == DataGenerators::InverterEffConstant) { - PpcuLosses = Pdemand * (1 - FuelCell(GeneratorNum).Inverter.ConstEff) / FuelCell(GeneratorNum).Inverter.ConstEff; + if (DataGenerators::FuelCell(GeneratorNum).Inverter.EffMode == DataGenerators::InverterEffConstant) { + PpcuLosses = Pdemand * (1 - DataGenerators::FuelCell(GeneratorNum).Inverter.ConstEff) / DataGenerators::FuelCell(GeneratorNum).Inverter.ConstEff; } - if (FuelCell(GeneratorNum).Inverter.EffMode == DataGenerators::InverterEffQuadratic) { + if (DataGenerators::FuelCell(GeneratorNum).Inverter.EffMode == DataGenerators::InverterEffQuadratic) { // first use Pdemand instead of Pel to get initial estimate - Real64 lastPpcuLosses = Pdemand * (1.0 - CurveManager::CurveValue(FuelCell(GeneratorNum).Inverter.EffQuadraticCurveID, Pdemand)) / - CurveManager::CurveValue(FuelCell(GeneratorNum).Inverter.EffQuadraticCurveID, Pdemand); + Real64 lastPpcuLosses = Pdemand * (1.0 - CurveManager::CurveValue(DataGenerators::FuelCell(GeneratorNum).Inverter.EffQuadraticCurveID, Pdemand)) / + CurveManager::CurveValue(DataGenerators::FuelCell(GeneratorNum).Inverter.EffQuadraticCurveID, Pdemand); for (int iter = 1; iter <= 20; ++iter) { // seems like need to iterate (??) Need to investigate number and convergence success here Real64 Pel = Pdemand + lastPpcuLosses; - lastPpcuLosses = (1.0 - CurveManager::CurveValue(FuelCell(GeneratorNum).Inverter.EffQuadraticCurveID, Pel)) * Pel; + lastPpcuLosses = (1.0 - CurveManager::CurveValue(DataGenerators::FuelCell(GeneratorNum).Inverter.EffQuadraticCurveID, Pel)) * Pel; } PpcuLosses = lastPpcuLosses; @@ -2790,21 +2788,15 @@ namespace FuelCellElectricGenerator { // MODIFIED na // RE-ENGINEERED na - Real64 CurrentFractionalDay; // working var, time in decimal days - Real64 EndingFractionalDay; // working var, time is decimal days - Real64 MaxPel; // working variable for max allowed by transient constraint - Real64 MinPel; // working variabel for min allowed by transient constraint - Real64 PelInput; // hold initial value of inout var + Real64 PelInput = Pel; // hold initial value of inout var - PelInput = Pel; + Real64 CurrentFractionalDay = double(DataGlobals::DayOfSim) + (int(DataGlobals::CurrentTime) + (DataHVACGlobals::SysTimeElapsed + (DataGlobals::CurrentTime - int(DataGlobals::CurrentTime)))) / DataGlobals::HoursInDay; // Check if in start up and if it still should be if (DataGenerators::FuelCell(GeneratorNum).FCPM.DuringStartUp) { // calculate time for end of start up period - CurrentFractionalDay = double(DataGlobals::DayOfSim) + (int(DataGlobals::CurrentTime) + (DataHVACGlobals::SysTimeElapsed + (DataGlobals::CurrentTime - int(DataGlobals::CurrentTime)))) / DataGlobals::HoursInDay; - - EndingFractionalDay = DataGenerators::FuelCell(GeneratorNum).FCPM.FractionalDayofLastStartUp + DataGenerators::FuelCell(GeneratorNum).FCPM.StartUpTime / DataGlobals::HoursInDay; + Real64 EndingFractionalDay = DataGenerators::FuelCell(GeneratorNum).FCPM.FractionalDayofLastStartUp + DataGenerators::FuelCell(GeneratorNum).FCPM.StartUpTime / DataGlobals::HoursInDay; if (CurrentFractionalDay > EndingFractionalDay) { // start up period is now over @@ -2816,9 +2808,7 @@ namespace FuelCellElectricGenerator { if (DataGenerators::FuelCell(GeneratorNum).FCPM.DuringShutDown) { // calculate time for end of shut down period - CurrentFractionalDay = double(DataGlobals::DayOfSim) + (int(DataGlobals::CurrentTime) + (DataHVACGlobals::SysTimeElapsed + (DataGlobals::CurrentTime - int(DataGlobals::CurrentTime)))) / DataGlobals::HoursInDay; - - EndingFractionalDay = DataGenerators::FuelCell(GeneratorNum).FCPM.FractionalDayofLastShutDown + DataGenerators::FuelCell(GeneratorNum).FCPM.ShutDownTime / DataGlobals::HoursInDay; + Real64 EndingFractionalDay = DataGenerators::FuelCell(GeneratorNum).FCPM.FractionalDayofLastShutDown + DataGenerators::FuelCell(GeneratorNum).FCPM.ShutDownTime / DataGlobals::HoursInDay; if (CurrentFractionalDay > EndingFractionalDay) { // start up period is now over @@ -2830,7 +2820,8 @@ namespace FuelCellElectricGenerator { if (!(DataGenerators::FuelCell(GeneratorNum).FCPM.DuringShutDown) && !(DataGenerators::FuelCell(GeneratorNum).FCPM.DuringStartUp)) { // unit is neither starting or stopping and the only constraints would come from transient limits if (Pel > DataGenerators::FuelCell(GeneratorNum).FCPM.PelLastTimeStep) { // powering up - MaxPel = DataGenerators::FuelCell(GeneratorNum).FCPM.PelLastTimeStep + DataGenerators::FuelCell(GeneratorNum).FCPM.UpTranLimit * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + // working variable for max allowed by transient constraint + Real64 MaxPel = DataGenerators::FuelCell(GeneratorNum).FCPM.PelLastTimeStep + DataGenerators::FuelCell(GeneratorNum).FCPM.UpTranLimit * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; if (MaxPel < Pel) { Pel = MaxPel; Constrained = true; @@ -2838,7 +2829,8 @@ namespace FuelCellElectricGenerator { Constrained = false; } } else if (Pel < DataGenerators::FuelCell(GeneratorNum).FCPM.PelLastTimeStep) { // powering down - MinPel = DataGenerators::FuelCell(GeneratorNum).FCPM.PelLastTimeStep - DataGenerators::FuelCell(GeneratorNum).FCPM.DownTranLimit * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + // working variable for min allowed by transient constraint + Real64 MinPel = DataGenerators::FuelCell(GeneratorNum).FCPM.PelLastTimeStep - DataGenerators::FuelCell(GeneratorNum).FCPM.DownTranLimit * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; if (Pel < MinPel) { Pel = MinPel; Constrained = true; @@ -2897,218 +2889,190 @@ namespace FuelCellElectricGenerator { static std::string const RoutineName("CalcFuelCellGenHeatRecovery"); - Real64 eHX; // fixed effectiveness - Real64 MdotWater(0.0); - int inNodeNum(0); - Real64 MWwater; - Real64 NdotWater; - Real64 TwaterIn; - Real64 CpWaterMol; - Real64 NdotGas; - Real64 TprodGasIn; - Real64 CpProdGasMol; - Real64 NdotCp; - Real64 qHX(0.0); - Real64 UAeff; - Real64 TauxMix; - Real64 NdotCpWater; - Real64 NdotCpAuxMix; - Real64 THXexh(0.0); - Real64 TwaterOut(0.0); - Real64 hgas; - Real64 hwater; - static Real64 waterFract(0.0); - Real64 NdotWaterVapor; - - Real64 NdotWaterCond = 0.0; - { auto const SELECT_CASE_var(DataGenerators::FuelCell(Num).ExhaustHX.HXmodelMode); if (SELECT_CASE_var == DataGenerators::FixedEffectiveness) { // Method 1 - eHX = DataGenerators::FuelCell(Num).ExhaustHX.HXEffect; + Real64 eHX = DataGenerators::FuelCell(Num).ExhaustHX.HXEffect; - inNodeNum = DataGenerators::FuelCell(Num).ExhaustHX.WaterInNode; - - MdotWater = DataGenerators::FuelCell(Num).ExhaustHX.WaterMassFlowRate; - MWwater = DataGenerators::GasPhaseThermoChemistryData(4).MolecularWeight; - NdotWater = MdotWater / MWwater; - TwaterIn = DataGenerators::FuelCell(Num).ExhaustHX.WaterInletTemp; + Real64 MWwater = DataGenerators::GasPhaseThermoChemistryData(4).MolecularWeight; + Real64 NdotWater = DataGenerators::FuelCell(Num).ExhaustHX.WaterMassFlowRate / MWwater; + Real64 TwaterIn = DataGenerators::FuelCell(Num).ExhaustHX.WaterInletTemp; + Real64 CpWaterMol; FigureLiquidWaterHeatCap(TwaterIn, CpWaterMol); - NdotGas = DataGenerators::FuelCell(Num).AuxilHeat.NdotAuxMix; - TprodGasIn = DataGenerators::FuelCell(Num).AuxilHeat.TauxMix; + Real64 NdotGas = DataGenerators::FuelCell(Num).AuxilHeat.NdotAuxMix; + Real64 TprodGasIn = DataGenerators::FuelCell(Num).AuxilHeat.TauxMix; + Real64 CpProdGasMol; FigureAuxilHeatGasHeatCap(Num, TprodGasIn, CpProdGasMol); // Cp in (J/mol*K) // factor of 1000.0 for kmol -> mol - NdotCp = min(NdotGas * CpProdGasMol * 1000.0, NdotWater * CpWaterMol * 1000.0); + Real64 NdotCp = min(NdotGas * CpProdGasMol * 1000.0, NdotWater * CpWaterMol * 1000.0); - qHX = eHX * NdotCp * (TprodGasIn - TwaterIn); + DataGenerators::FuelCell(Num).ExhaustHX.qHX = eHX * NdotCp * (TprodGasIn - TwaterIn); - THXexh = TprodGasIn - qHX / (NdotGas * CpProdGasMol * 1000.0); + DataGenerators::FuelCell(Num).ExhaustHX.THXexh = TprodGasIn - DataGenerators::FuelCell(Num).ExhaustHX.qHX / (NdotGas * CpProdGasMol * 1000.0); Real64 Cp = FluidProperties::GetSpecificHeatGlycol( DataPlant::PlantLoop(DataGenerators::FuelCell(Num).CWLoopNum).FluidName, TwaterIn, DataPlant::PlantLoop(DataGenerators::FuelCell(Num).CWLoopNum).FluidIndex, RoutineName); - if (MdotWater * Cp <= 0.0) { - TwaterOut = TwaterIn; + if (DataGenerators::FuelCell(Num).ExhaustHX.WaterMassFlowRate * Cp <= 0.0) { + DataGenerators::FuelCell(Num).ExhaustHX.WaterOutletTemp = TwaterIn; } else { - TwaterOut = TwaterIn + qHX / (MdotWater * Cp); + DataGenerators::FuelCell(Num).ExhaustHX.WaterOutletTemp = TwaterIn + DataGenerators::FuelCell(Num).ExhaustHX.qHX / (DataGenerators::FuelCell(Num).ExhaustHX.WaterMassFlowRate * Cp); } } else if (SELECT_CASE_var == DataGenerators::LMTDempiricalUAeff) { // method 2 - inNodeNum = DataGenerators::FuelCell(Num).ExhaustHX.WaterInNode; - MdotWater = DataGenerators::FuelCell(Num).ExhaustHX.WaterMassFlowRate; - MWwater = DataGenerators::GasPhaseThermoChemistryData(4).MolecularWeight; - NdotWater = MdotWater / MWwater; - NdotGas = DataGenerators::FuelCell(Num).AuxilHeat.NdotAuxMix; + Real64 MWwater = DataGenerators::GasPhaseThermoChemistryData(4).MolecularWeight; + Real64 NdotWater = DataGenerators::FuelCell(Num).ExhaustHX.WaterMassFlowRate / MWwater; + Real64 NdotGas = DataGenerators::FuelCell(Num).AuxilHeat.NdotAuxMix; - UAeff = DataGenerators::FuelCell(Num).ExhaustHX.hxs0 + DataGenerators::FuelCell(Num).ExhaustHX.hxs1 * NdotWater + DataGenerators::FuelCell(Num).ExhaustHX.hxs2 * pow_2(NdotWater) + + Real64 UAeff = DataGenerators::FuelCell(Num).ExhaustHX.hxs0 + DataGenerators::FuelCell(Num).ExhaustHX.hxs1 * NdotWater + DataGenerators::FuelCell(Num).ExhaustHX.hxs2 * pow_2(NdotWater) + DataGenerators::FuelCell(Num).ExhaustHX.hxs3 * NdotGas + DataGenerators::FuelCell(Num).ExhaustHX.hxs4 * pow_2(NdotGas); - TauxMix = DataGenerators::FuelCell(Num).AuxilHeat.TauxMix; - TwaterIn = DataGenerators::FuelCell(Num).ExhaustHX.WaterInletTemp; + Real64 TauxMix = DataGenerators::FuelCell(Num).AuxilHeat.TauxMix; + Real64 TwaterIn = DataGenerators::FuelCell(Num).ExhaustHX.WaterInletTemp; + Real64 CpWaterMol; FigureLiquidWaterHeatCap(TwaterIn, CpWaterMol); // factor of 1000.0 for kmol -> mol - NdotCpWater = NdotWater * CpWaterMol * 1000.0; + Real64 NdotCpWater = NdotWater * CpWaterMol * 1000.0; + Real64 CpProdGasMol; FigureAuxilHeatGasHeatCap(Num, TauxMix, CpProdGasMol); // Cp in (J/mol*K) - NdotCpAuxMix = NdotGas * CpProdGasMol * 1000.0; + Real64 NdotCpAuxMix = NdotGas * CpProdGasMol * 1000.0; if ((NdotCpWater != 0.0) && (NdotCpAuxMix != 0.0)) { // trap divide by zero // now evaluate Eq. 44 - THXexh = ((1.0 - NdotCpAuxMix / NdotCpWater) / + DataGenerators::FuelCell(Num).ExhaustHX.THXexh = ((1.0 - NdotCpAuxMix / NdotCpWater) / (std::exp(UAeff * (1.0 / NdotCpAuxMix - 1.0 / NdotCpWater)) - NdotCpAuxMix / NdotCpWater)) * TauxMix + ((std::exp(UAeff * (1.0 / NdotCpAuxMix - 1.0 / NdotCpWater)) - 1.0) / (std::exp(UAeff * (1.0 / NdotCpAuxMix - 1.0 / NdotCpWater)) - NdotCpAuxMix / NdotCpWater)) * TwaterIn; - TwaterOut = TwaterIn + (NdotCpAuxMix / NdotCpWater) * (TauxMix - THXexh); // Eq. 42 + DataGenerators::FuelCell(Num).ExhaustHX.WaterOutletTemp = TwaterIn + (NdotCpAuxMix / NdotCpWater) * (TauxMix - DataGenerators::FuelCell(Num).ExhaustHX.THXexh); // Eq. 42 } else { - THXexh = TauxMix; - TwaterOut = TwaterIn; + DataGenerators::FuelCell(Num).ExhaustHX.THXexh = TauxMix; + DataGenerators::FuelCell(Num).ExhaustHX.WaterOutletTemp = TwaterIn; } // ENDIF - if ((THXexh - TwaterIn) != 0.0) { // trap divide by zero - qHX = UAeff * ((TauxMix - TwaterOut) - (THXexh - TwaterIn)) / std::log((TauxMix - TwaterOut) / (THXexh - TwaterIn)); + if ((DataGenerators::FuelCell(Num).ExhaustHX.THXexh - TwaterIn) != 0.0) { // trap divide by zero + DataGenerators::FuelCell(Num).ExhaustHX.qHX = UAeff * ((TauxMix - DataGenerators::FuelCell(Num).ExhaustHX.WaterOutletTemp) - (DataGenerators::FuelCell(Num).ExhaustHX.THXexh - TwaterIn)) / std::log((TauxMix - DataGenerators::FuelCell(Num).ExhaustHX.WaterOutletTemp) / (DataGenerators::FuelCell(Num).ExhaustHX.THXexh - TwaterIn)); } else { - qHX = 0.0; + DataGenerators::FuelCell(Num).ExhaustHX.qHX = 0.0; } } else if (SELECT_CASE_var == DataGenerators::LMTDfundementalUAeff) { // method 3 - NdotGas = DataGenerators::FuelCell(Num).AuxilHeat.NdotAuxMix; - inNodeNum = DataGenerators::FuelCell(Num).ExhaustHX.WaterInNode; - MdotWater = DataGenerators::FuelCell(Num).ExhaustHX.WaterMassFlowRate; - MWwater = DataGenerators::GasPhaseThermoChemistryData(4).MolecularWeight; - NdotWater = MdotWater / MWwater; - - hgas = - DataGenerators::FuelCell(Num).ExhaustHX.h0gas * std::pow(NdotGas / DataGenerators::FuelCell(Num).ExhaustHX.NdotGasRef, DataGenerators::FuelCell(Num).ExhaustHX.nCoeff); // Eq. 48 + Real64 NdotGas = DataGenerators::FuelCell(Num).AuxilHeat.NdotAuxMix; + Real64 MWwater = DataGenerators::GasPhaseThermoChemistryData(4).MolecularWeight; + Real64 NdotWater = DataGenerators::FuelCell(Num).ExhaustHX.WaterMassFlowRate / MWwater; - hwater = DataGenerators::FuelCell(Num).ExhaustHX.h0Water * + Real64 hgas = DataGenerators::FuelCell(Num).ExhaustHX.h0gas * std::pow(NdotGas / DataGenerators::FuelCell(Num).ExhaustHX.NdotGasRef, DataGenerators::FuelCell(Num).ExhaustHX.nCoeff); // Eq. 48 + Real64 hwater = DataGenerators::FuelCell(Num).ExhaustHX.h0Water * std::pow(NdotWater / DataGenerators::FuelCell(Num).ExhaustHX.NdotWaterRef, DataGenerators::FuelCell(Num).ExhaustHX.mCoeff); // Eq. 48 // now equation 47 - UAeff = 1.0 / (1.0 / (hgas * DataGenerators::FuelCell(Num).ExhaustHX.AreaGas) + 1.0 / (hwater * DataGenerators::FuelCell(Num).ExhaustHX.AreaWater) + + Real64 UAeff = 1.0 / (1.0 / (hgas * DataGenerators::FuelCell(Num).ExhaustHX.AreaGas) + 1.0 / (hwater * DataGenerators::FuelCell(Num).ExhaustHX.AreaWater) + DataGenerators::FuelCell(Num).ExhaustHX.Fadjust); - TauxMix = DataGenerators::FuelCell(Num).AuxilHeat.TauxMix; - TwaterIn = DataGenerators::FuelCell(Num).ExhaustHX.WaterInletTemp; + Real64 TauxMix = DataGenerators::FuelCell(Num).AuxilHeat.TauxMix; + Real64 TwaterIn = DataGenerators::FuelCell(Num).ExhaustHX.WaterInletTemp; + Real64 CpWaterMol; FigureLiquidWaterHeatCap(TwaterIn, CpWaterMol); - NdotCpWater = NdotWater * CpWaterMol * 1000.0; + Real64 NdotCpWater = NdotWater * CpWaterMol * 1000.0; + Real64 CpProdGasMol; FigureAuxilHeatGasHeatCap(Num, TauxMix, CpProdGasMol); // Cp in (J/mol*K) - NdotCpAuxMix = NdotGas * CpProdGasMol * 1000.0; + Real64 NdotCpAuxMix = NdotGas * CpProdGasMol * 1000.0; if ((NdotCpWater != 0.0) && (NdotCpAuxMix != 0.0)) { // trap divide by zero // now evaluate Eq. 44 - THXexh = ((1.0 - NdotCpAuxMix / NdotCpWater) / + DataGenerators::FuelCell(Num).ExhaustHX.THXexh = ((1.0 - NdotCpAuxMix / NdotCpWater) / (std::exp(UAeff * (1.0 / NdotCpAuxMix - 1.0 / NdotCpWater)) - NdotCpAuxMix / NdotCpWater)) * TauxMix + ((std::exp(UAeff * (1.0 / NdotCpAuxMix - 1.0 / NdotCpWater)) - 1.0) / (std::exp(UAeff * (1.0 / NdotCpAuxMix - 1.0 / NdotCpWater)) - NdotCpAuxMix / NdotCpWater)) * TwaterIn; - TwaterOut = TwaterIn + (NdotCpAuxMix / NdotCpWater) * (TauxMix - THXexh); // Eq. 42 + DataGenerators::FuelCell(Num).ExhaustHX.WaterOutletTemp = TwaterIn + (NdotCpAuxMix / NdotCpWater) * (TauxMix - DataGenerators::FuelCell(Num).ExhaustHX.THXexh); // Eq. 42 } else { - THXexh = TauxMix; - TwaterOut = TwaterIn; + DataGenerators::FuelCell(Num).ExhaustHX.THXexh = TauxMix; + DataGenerators::FuelCell(Num).ExhaustHX.WaterOutletTemp = TwaterIn; } - if ((THXexh - TwaterIn) != 0.0) { // trap divide by zero - qHX = UAeff * ((TauxMix - TwaterOut) - (THXexh - TwaterIn)) / std::log((TauxMix - TwaterOut) / (THXexh - TwaterIn)); + if ((DataGenerators::FuelCell(Num).ExhaustHX.THXexh - TwaterIn) != 0.0) { // trap divide by zero + DataGenerators::FuelCell(Num).ExhaustHX.qHX = UAeff * ((TauxMix - DataGenerators::FuelCell(Num).ExhaustHX.WaterOutletTemp) - (DataGenerators::FuelCell(Num).ExhaustHX.THXexh - TwaterIn)) / std::log((TauxMix - DataGenerators::FuelCell(Num).ExhaustHX.WaterOutletTemp) / (DataGenerators::FuelCell(Num).ExhaustHX.THXexh - TwaterIn)); } else { - qHX = 0.0; + DataGenerators::FuelCell(Num).ExhaustHX.qHX = 0.0; } } else if (SELECT_CASE_var == DataGenerators::Condensing) { // method 4 - inNodeNum = DataGenerators::FuelCell(Num).ExhaustHX.WaterInNode; - MdotWater = DataGenerators::FuelCell(Num).ExhaustHX.WaterMassFlowRate; - if (MdotWater != 0.0) { + if (DataGenerators::FuelCell(Num).ExhaustHX.WaterMassFlowRate != 0.0) { - MWwater = DataGenerators::GasPhaseThermoChemistryData(4).MolecularWeight; - NdotWater = MdotWater / MWwater; - NdotGas = DataGenerators::FuelCell(Num).AuxilHeat.NdotAuxMix; + Real64 MWwater = DataGenerators::GasPhaseThermoChemistryData(4).MolecularWeight; + Real64 NdotWater = DataGenerators::FuelCell(Num).ExhaustHX.WaterMassFlowRate / MWwater; + Real64 NdotGas = DataGenerators::FuelCell(Num).AuxilHeat.NdotAuxMix; - UAeff = DataGenerators::FuelCell(Num).ExhaustHX.hxs0 + DataGenerators::FuelCell(Num).ExhaustHX.hxs1 * NdotWater + + Real64 UAeff = DataGenerators::FuelCell(Num).ExhaustHX.hxs0 + DataGenerators::FuelCell(Num).ExhaustHX.hxs1 * NdotWater + DataGenerators::FuelCell(Num).ExhaustHX.hxs2 * pow_2(NdotWater) + DataGenerators::FuelCell(Num).ExhaustHX.hxs3 * NdotGas + DataGenerators::FuelCell(Num).ExhaustHX.hxs4 * pow_2(NdotGas); - TauxMix = DataGenerators::FuelCell(Num).AuxilHeat.TauxMix; - TwaterIn = DataGenerators::FuelCell(Num).ExhaustHX.WaterInletTemp; + Real64 TauxMix = DataGenerators::FuelCell(Num).AuxilHeat.TauxMix; + Real64 TwaterIn = DataGenerators::FuelCell(Num).ExhaustHX.WaterInletTemp; + Real64 CpWaterMol; FigureLiquidWaterHeatCap(TwaterIn, CpWaterMol); - NdotCpWater = NdotWater * CpWaterMol * 1000.0; + Real64 NdotCpWater = NdotWater * CpWaterMol * 1000.0; + Real64 CpProdGasMol; FigureAuxilHeatGasHeatCap(Num, TauxMix, CpProdGasMol); // Cp in (J/mol*K) - NdotCpAuxMix = NdotGas * CpProdGasMol * 1000.0; + Real64 NdotCpAuxMix = NdotGas * CpProdGasMol * 1000.0; // find water fraction in incoming gas stream for (int i = 1; i <= isize(DataGenerators::FuelCell(Num).AuxilHeat.GasLibID); ++i) { - if (DataGenerators::FuelCell(Num).AuxilHeat.GasLibID(i) == 4) waterFract = DataGenerators::FuelCell(Num).AuxilHeat.ConstitMolalFract(i); + if (DataGenerators::FuelCell(Num).AuxilHeat.GasLibID(i) == 4) DataGenerators::FuelCell(Num).ExhaustHX.WaterVaporFractExh = DataGenerators::FuelCell(Num).AuxilHeat.ConstitMolalFract(i); } - NdotWaterVapor = waterFract * NdotGas; + Real64 NdotWaterVapor = DataGenerators::FuelCell(Num).ExhaustHX.WaterVaporFractExh * NdotGas; Real64 TcondThresh = DataGenerators::FuelCell(Num).ExhaustHX.CondensationThresholdTemp; Real64 hxl1 = DataGenerators::FuelCell(Num).ExhaustHX.l1Coeff; Real64 hxl2 = DataGenerators::FuelCell(Num).ExhaustHX.l2Coeff; - NdotWaterCond = (TcondThresh - TwaterIn) * (hxl1 * (NdotWaterVapor / NdotGas) + hxl2 * pow_2(NdotWaterVapor / NdotGas)); + DataGenerators::FuelCell(Num).ExhaustHX.CondensateRate = (TcondThresh - TwaterIn) * (hxl1 * (NdotWaterVapor / NdotGas) + hxl2 * pow_2(NdotWaterVapor / NdotGas)); - if (NdotWaterCond < 0.0) NdotWaterCond = 0.0; + if (DataGenerators::FuelCell(Num).ExhaustHX.CondensateRate < 0.0) DataGenerators::FuelCell(Num).ExhaustHX.CondensateRate = 0.0; Real64 hfpwater = 4.4004e+07; // molal heat of vaporization of water J/kmol) if ((NdotCpWater != 0.0) && (NdotCpAuxMix != 0.0)) { // trap divide by zero // now evaluate Eq. 44 - THXexh = ((1.0 - NdotCpAuxMix / NdotCpWater) / + DataGenerators::FuelCell(Num).ExhaustHX.THXexh = ((1.0 - NdotCpAuxMix / NdotCpWater) / (std::exp(UAeff * (1.0 / NdotCpAuxMix - 1.0 / NdotCpWater)) - NdotCpAuxMix / NdotCpWater)) * TauxMix + ((std::exp(UAeff * (1.0 / NdotCpAuxMix - 1.0 / NdotCpWater)) - 1.0) / (std::exp(UAeff * (1.0 / NdotCpAuxMix - 1.0 / NdotCpWater)) - NdotCpAuxMix / NdotCpWater)) * TwaterIn; - TwaterOut = TwaterIn + (NdotCpAuxMix / NdotCpWater) * (TauxMix - THXexh) + (NdotWaterCond * hfpwater) / NdotCpWater; + DataGenerators::FuelCell(Num).ExhaustHX.WaterOutletTemp = TwaterIn + (NdotCpAuxMix / NdotCpWater) * (TauxMix - DataGenerators::FuelCell(Num).ExhaustHX.THXexh) + (DataGenerators::FuelCell(Num).ExhaustHX.CondensateRate * hfpwater) / NdotCpWater; - if (NdotWaterCond > 0) { // Eq. 44 is not correct. use its result as first guess for revised way... + if (DataGenerators::FuelCell(Num).ExhaustHX.CondensateRate > 0) { // Eq. 44 is not correct. use its result as first guess for revised way... // iterative solution because in condensing case THXexh is function of qSens and qLatent for (int loop = 1; loop <= 5; ++loop) { Real64 qSens; Real64 qLatent; - if ((THXexh - TwaterIn) != 0.0 && - ((TauxMix - TwaterOut) / (THXexh - TwaterIn) > 0.0001)) { // trap divide by zero and negative log + if ((DataGenerators::FuelCell(Num).ExhaustHX.THXexh - TwaterIn) != 0.0 && + ((TauxMix - DataGenerators::FuelCell(Num).ExhaustHX.WaterOutletTemp) / (DataGenerators::FuelCell(Num).ExhaustHX.THXexh - TwaterIn) > 0.0001)) { // trap divide by zero and negative log qSens = - UAeff * ((TauxMix - TwaterOut) - (THXexh - TwaterIn)) / std::log((TauxMix - TwaterOut) / (THXexh - TwaterIn)); + UAeff * ((TauxMix - DataGenerators::FuelCell(Num).ExhaustHX.WaterOutletTemp) - (DataGenerators::FuelCell(Num).ExhaustHX.THXexh - TwaterIn)) / std::log((TauxMix - DataGenerators::FuelCell(Num).ExhaustHX.WaterOutletTemp) / (DataGenerators::FuelCell(Num).ExhaustHX.THXexh - TwaterIn)); } else { qSens = 0.0; } - qLatent = NdotWaterCond * hfpwater; + qLatent = DataGenerators::FuelCell(Num).ExhaustHX.CondensateRate * hfpwater; if (qSens > 0) { - THXexh = + DataGenerators::FuelCell(Num).ExhaustHX.THXexh = TauxMix * ((1.0 - NdotCpAuxMix / NdotCpWater) / ((std::exp(UAeff * (1.0 / NdotCpAuxMix - 1.0 / NdotCpWater)) / (std::exp((UAeff * qLatent) / (NdotCpWater * qSens)))) - NdotCpAuxMix / NdotCpWater)) + @@ -3122,32 +3086,32 @@ namespace FuelCellElectricGenerator { (std::exp((UAeff * qLatent) / (NdotCpWater * qSens))) - NdotCpAuxMix / NdotCpWater)); } else { - THXexh = TauxMix; + DataGenerators::FuelCell(Num).ExhaustHX.THXexh = TauxMix; } - TwaterOut = TwaterIn + (NdotCpAuxMix / NdotCpWater) * (TauxMix - THXexh) + (NdotWaterCond * hfpwater) / NdotCpWater; + DataGenerators::FuelCell(Num).ExhaustHX.WaterOutletTemp = TwaterIn + (NdotCpAuxMix / NdotCpWater) * (TauxMix - DataGenerators::FuelCell(Num).ExhaustHX.THXexh) + (DataGenerators::FuelCell(Num).ExhaustHX.CondensateRate * hfpwater) / NdotCpWater; } } } else { - THXexh = TauxMix; - TwaterOut = TwaterIn; + DataGenerators::FuelCell(Num).ExhaustHX.THXexh = TauxMix; + DataGenerators::FuelCell(Num).ExhaustHX.WaterOutletTemp = TwaterIn; } - if ((THXexh - TwaterIn) != 0.0 && - ((TauxMix - TwaterOut) / (THXexh - TwaterIn) > 0.0001)) { // trap divide by zero and negative log + if ((DataGenerators::FuelCell(Num).ExhaustHX.THXexh - TwaterIn) != 0.0 && + ((TauxMix - DataGenerators::FuelCell(Num).ExhaustHX.WaterOutletTemp) / (DataGenerators::FuelCell(Num).ExhaustHX.THXexh - TwaterIn) > 0.0001)) { // trap divide by zero and negative log - qHX = UAeff * ((TauxMix - TwaterOut) - (THXexh - TwaterIn)) / std::log((TauxMix - TwaterOut) / (THXexh - TwaterIn)) + - NdotWaterCond * hfpwater; + DataGenerators::FuelCell(Num).ExhaustHX.qHX = UAeff * ((TauxMix - DataGenerators::FuelCell(Num).ExhaustHX.WaterOutletTemp) - (DataGenerators::FuelCell(Num).ExhaustHX.THXexh - TwaterIn)) / std::log((TauxMix - DataGenerators::FuelCell(Num).ExhaustHX.WaterOutletTemp) / (DataGenerators::FuelCell(Num).ExhaustHX.THXexh - TwaterIn)) + + DataGenerators::FuelCell(Num).ExhaustHX.CondensateRate * hfpwater; } else { - qHX = 0.0; + DataGenerators::FuelCell(Num).ExhaustHX.qHX = 0.0; } } else { // no cooling water flow, model will blow up. - qHX = 0.0; - THXexh = DataGenerators::FuelCell(Num).AuxilHeat.TauxMix; - TwaterOut = DataGenerators::FuelCell(Num).ExhaustHX.WaterInletTemp; - NdotWaterCond = 0.0; - waterFract = -9999.0; // not defined + DataGenerators::FuelCell(Num).ExhaustHX.qHX = 0.0; + DataGenerators::FuelCell(Num).ExhaustHX.THXexh = DataGenerators::FuelCell(Num).AuxilHeat.TauxMix; + DataGenerators::FuelCell(Num).ExhaustHX.WaterOutletTemp = DataGenerators::FuelCell(Num).ExhaustHX.WaterInletTemp; + DataGenerators::FuelCell(Num).ExhaustHX.CondensateRate = 0.0; + DataGenerators::FuelCell(Num).ExhaustHX.WaterVaporFractExh = -9999.0; // not defined } } else { assert(false); // Variables not set are used below @@ -3155,14 +3119,7 @@ namespace FuelCellElectricGenerator { } // update results in data structure. - DataGenerators::FuelCell(Num).ExhaustHX.qHX = qHX; - DataGenerators::FuelCell(Num).ExhaustHX.THXexh = THXexh; - DataGenerators::FuelCell(Num).ExhaustHX.WaterMassFlowRate = MdotWater; - DataGenerators::FuelCell(Num).ExhaustHX.WaterVaporFractExh = waterFract; - - DataGenerators::FuelCell(Num).ExhaustHX.CondensateRate = NdotWaterCond; - DataGenerators::FuelCell(Num).ExhaustHX.WaterOutletTemp = TwaterOut; - DataGenerators::FuelCell(Num).ExhaustHX.WaterOutletEnthalpy = DataLoopNode::Node(inNodeNum).Enthalpy + qHX; + DataGenerators::FuelCell(Num).ExhaustHX.WaterOutletEnthalpy = DataLoopNode::Node(DataGenerators::FuelCell(Num).ExhaustHX.WaterInNode).Enthalpy + DataGenerators::FuelCell(Num).ExhaustHX.qHX; } void SimFuelCellPlantHeatRecovery(std::string const &EP_UNUSED(CompType), @@ -3189,9 +3146,6 @@ namespace FuelCellElectricGenerator { // makes sure input are gotten and setup from Plant loop perspective. // does not (re)simulate entire FuelCell model - using DataGenerators::FuelCell; - using DataGenerators::FCDataStruct; - if (GetFuelCellInput) { // Read input data. @@ -3201,9 +3155,9 @@ namespace FuelCellElectricGenerator { if (InitLoopEquip) { if (CompTypeNum == DataPlant::TypeOf_Generator_FCExhaust) { - CompNum = UtilityRoutines::FindItemInList(CompName, FuelCell, &FCDataStruct::NameExhaustHX); + CompNum = UtilityRoutines::FindItemInList(CompName, DataGenerators::FuelCell, &DataGenerators::FCDataStruct::NameExhaustHX); } else if (CompTypeNum == DataPlant::TypeOf_Generator_FCStackCooler) { - CompNum = UtilityRoutines::FindItemInList(CompName, FuelCell, &FCDataStruct::NameStackCooler); + CompNum = UtilityRoutines::FindItemInList(CompName, DataGenerators::FuelCell, &DataGenerators::FCDataStruct::NameStackCooler); } if (CompNum == 0) { ShowFatalError("SimFuelCellPlantHeatRecovery: Fuel Cell Generator Unit not found=" + CompName); @@ -3215,26 +3169,26 @@ namespace FuelCellElectricGenerator { } // End Of InitLoopEquip if (CompTypeNum == DataPlant::TypeOf_Generator_FCStackCooler) { - PlantUtilities::UpdateComponentHeatRecoverySide(FuelCell(CompNum).CWLoopNum, - FuelCell(CompNum).CWLoopSideNum, + PlantUtilities::UpdateComponentHeatRecoverySide(DataGenerators::FuelCell(CompNum).CWLoopNum, + DataGenerators::FuelCell(CompNum).CWLoopSideNum, DataPlant::TypeOf_Generator_FCStackCooler, - FuelCell(CompNum).StackCooler.WaterInNode, - FuelCell(CompNum).StackCooler.WaterOutNode, - FuelCell(CompNum).Report.qHX, - FuelCell(CompNum).Report.HeatRecInletTemp, - FuelCell(CompNum).Report.HeatRecOutletTemp, - FuelCell(CompNum).Report.HeatRecMdot, + DataGenerators::FuelCell(CompNum).StackCooler.WaterInNode, + DataGenerators::FuelCell(CompNum).StackCooler.WaterOutNode, + DataGenerators::FuelCell(CompNum).Report.qHX, + DataGenerators::FuelCell(CompNum).Report.HeatRecInletTemp, + DataGenerators::FuelCell(CompNum).Report.HeatRecOutletTemp, + DataGenerators::FuelCell(CompNum).Report.HeatRecMdot, FirstHVACIteration); } else if (CompTypeNum == DataPlant::TypeOf_Generator_FCExhaust) { - PlantUtilities::UpdateComponentHeatRecoverySide(FuelCell(CompNum).CWLoopNum, - FuelCell(CompNum).CWLoopSideNum, + PlantUtilities::UpdateComponentHeatRecoverySide(DataGenerators::FuelCell(CompNum).CWLoopNum, + DataGenerators::FuelCell(CompNum).CWLoopSideNum, DataPlant::TypeOf_Generator_FCExhaust, - FuelCell(CompNum).ExhaustHX.WaterInNode, - FuelCell(CompNum).ExhaustHX.WaterOutNode, - FuelCell(CompNum).ExhaustHX.qHX, - FuelCell(CompNum).ExhaustHX.WaterInletTemp, - FuelCell(CompNum).ExhaustHX.WaterOutletTemp, - FuelCell(CompNum).ExhaustHX.WaterMassFlowRate, + DataGenerators::FuelCell(CompNum).ExhaustHX.WaterInNode, + DataGenerators::FuelCell(CompNum).ExhaustHX.WaterOutNode, + DataGenerators::FuelCell(CompNum).ExhaustHX.qHX, + DataGenerators::FuelCell(CompNum).ExhaustHX.WaterInletTemp, + DataGenerators::FuelCell(CompNum).ExhaustHX.WaterOutletTemp, + DataGenerators::FuelCell(CompNum).ExhaustHX.WaterMassFlowRate, FirstHVACIteration); } } diff --git a/src/EnergyPlus/FuelCellElectricGenerator.hh b/src/EnergyPlus/FuelCellElectricGenerator.hh index 22361161bae..807024970c4 100644 --- a/src/EnergyPlus/FuelCellElectricGenerator.hh +++ b/src/EnergyPlus/FuelCellElectricGenerator.hh @@ -73,12 +73,12 @@ namespace FuelCellElectricGenerator { // Functions - void SimFuelCellGenerator(int const GeneratorType, // type of Generator + void SimFuelCellGenerator(int GeneratorType, // type of Generator std::string const &GeneratorName, // user specified name of Generator int &GeneratorIndex, - bool const RunFlag, // simulate Generator when TRUE - Real64 const MyLoad, // demand on electric generator - bool const FirstHVACIteration); + bool RunFlag, // simulate Generator when TRUE + Real64 MyLoad, // demand on electric generator + bool FirstHVACIteration); // End FuelCell Generator Module Driver Subroutines //****************************************************************************** @@ -93,113 +93,113 @@ namespace FuelCellElectricGenerator { // Beginning of Generator model Subroutines // ***************************************************************************** - void CalcFuelCellGeneratorModel(int const GeneratorNum, // Generator number - bool const RunFlag, // TRUE when Generator operating - Real64 const MyLoad, // Generator demand - bool const FirstHVACIteration); + void CalcFuelCellGeneratorModel(int GeneratorNum, // Generator number + bool RunFlag, // TRUE when Generator operating + Real64 MyLoad, // Generator demand + bool FirstHVACIteration); - void ManageElectStorInteractions(int const Num, // Generator number, index for structure - Real64 const Pdemand, - Real64 const PpcuLosses, + void ManageElectStorInteractions(int Num, // Generator number, index for structure + Real64 Pdemand, + Real64 PpcuLosses, bool &Constrained, // TODO: This one is never used anywhere in the code Real64 &Pstorage, Real64 &PgridOverage // electricity that can't be stored and needs to go out ); - Real64 FuelCellProductGasEnthResidual(Real64 const TprodGas, // temperature, this is "x" being searched + Real64 FuelCellProductGasEnthResidual(Real64 TprodGas, // temperature, this is "x" being searched Array1 const &Par // par(1) = Generator Number ); - void FigureAirHeatCap(int const GeneratorNum, // ID of generator FuelCell data structure - Real64 const FluidTemp, // degree C + void FigureAirHeatCap(int GeneratorNum, // ID of generator FuelCell data structure + Real64 FluidTemp, // degree C Real64 &Cp // (J/mol*K) ); - void FigureAirEnthalpy(int const GeneratorNum, // ID of generator FuelCell data structure - Real64 const FluidTemp, // degree C + void FigureAirEnthalpy(int GeneratorNum, // ID of generator FuelCell data structure + Real64 FluidTemp, // degree C Real64 &Hair // (kJ/mol) ); - void FigureFuelHeatCap(int const GeneratorNum, // ID of generator FuelCell data structure - Real64 const FluidTemp, // degree C + void FigureFuelHeatCap(int GeneratorNum, // ID of generator FuelCell data structure + Real64 FluidTemp, // degree C Real64 &Cp // (J/mol*K) ); - void FigureFuelEnthalpy(int const GeneratorNum, // ID of generator FuelCell data structure - Real64 const FluidTemp, // degree C + void FigureFuelEnthalpy(int GeneratorNum, // ID of generator FuelCell data structure + Real64 FluidTemp, // degree C Real64 &Hfuel // kJ/mol ); - void FigureProductGasesEnthalpy(int const GeneratorNum, // ID of generator FuelCell data structure - Real64 const FluidTemp, // degree C + void FigureProductGasesEnthalpy(int GeneratorNum, // ID of generator FuelCell data structure + Real64 FluidTemp, // degree C Real64 &HProdGases // kJ/mol ); - void FigureProductGasHeatCap(int const GeneratorNum, // ID of generator FuelCell data structure - Real64 const FluidTemp, // degree C + void FigureProductGasHeatCap(int GeneratorNum, // ID of generator FuelCell data structure + Real64 FluidTemp, // degree C Real64 &Cp // (J/mol*K) ); - void FigureAuxilHeatGasHeatCap(int const GeneratorNum, // ID of generator FuelCell data structure - Real64 const FluidTemp, // degree C + void FigureAuxilHeatGasHeatCap(int GeneratorNum, // ID of generator FuelCell data structure + Real64 FluidTemp, // degree C Real64 &Cp // (J/mol*K) ); - void FigureGaseousWaterEnthalpy(Real64 const FluidTemp, // degree C + void FigureGaseousWaterEnthalpy(Real64 FluidTemp, // degree C Real64 &HGasWater // kJ/mol ); - void FigureLiquidWaterEnthalpy(Real64 const FluidTemp, // degree C + void FigureLiquidWaterEnthalpy(Real64 FluidTemp, // degree C Real64 &HLiqWater // kJ/mol ); - void FigureLiquidWaterHeatCap(Real64 const FluidTemp, // degree C + void FigureLiquidWaterHeatCap(Real64 FluidTemp, // degree C Real64 &Cp // (J/mol*K) ); - void FigureACAncillaries(int const GeneratorNum, Real64 &PacAncill); + void FigureACAncillaries(int GeneratorNum, Real64 &PacAncill); - void FigurePowerConditioningLosses(int const GeneratorNum, Real64 const Pdemand, Real64 &PpcuLosses); + void FigurePowerConditioningLosses(int GeneratorNum, Real64 Pdemand, Real64 &PpcuLosses); - void FigureTransientConstraints(int const GeneratorNum, // index number for accessing correct generator + void FigureTransientConstraints(int GeneratorNum, // index number for accessing correct generator Real64 &Pel, // DC power control setting for power module bool &Constrained, // true if transient constraints kick in (TODO: never used anywhere) Real64 &PelDiff // if constrained then this is the difference, positive ); - void CalcFuelCellAuxHeater(int const Num); // Generator number + void CalcFuelCellAuxHeater(int Num); // Generator number - void CalcFuelCellGenHeatRecovery(int const Num); // Generator number + void CalcFuelCellGenHeatRecovery(int Num); // Generator number void SimFuelCellPlantHeatRecovery(std::string const &CompType, std::string const &CompName, - int const CompTypeNum, + int CompTypeNum, int &CompNum, - bool const RunFlag, + bool RunFlag, bool &InitLoopEquip, Real64 &MyLoad, // unused1208 Real64 &MaxCap, Real64 &MinCap, Real64 &OptCap, - bool const FirstHVACIteration // TRUE if First iteration of simulation + bool FirstHVACIteration // TRUE if First iteration of simulation ); - void InitFuelCellGenerators(int const FCnum); // index to specific fuel cell generator + void InitFuelCellGenerators(int FCnum); // index to specific fuel cell generator void getFuelCellGeneratorHeatRecoveryInfo(std::string const &GeneratorName, // user specified name of Generator std::string &heatRecoveryCompName); void FigureFuelCellZoneGains(); - void CalcUpdateHeatRecovery(int const Num, // Generator number - bool const FirstHVACIteration); + void CalcUpdateHeatRecovery(int Num, // Generator number + bool FirstHVACIteration); - void UpdateFuelCellGeneratorRecords(bool const RunFlag, // TRUE if Generator operating - int const Num // Generator number + void UpdateFuelCellGeneratorRecords(bool RunFlag, // TRUE if Generator operating + int Num // Generator number ); - void GetFuelCellGeneratorResults(int const GeneratorType, // type of Generator - int const GeneratorIndex, + void GetFuelCellGeneratorResults(int GeneratorType, // type of Generator + int GeneratorIndex, Real64 &GeneratorPower, // electrical power Real64 &GeneratorEnergy, // electrical energy Real64 &ThermalPower, // heat power From daf46ad24acd71ebde412e0ac46aa6629985112d Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Tue, 12 Nov 2019 08:39:32 -0700 Subject: [PATCH 24/51] cleanup local vars --- src/EnergyPlus/FuelCellElectricGenerator.cc | 89 +++++++-------------- 1 file changed, 31 insertions(+), 58 deletions(-) diff --git a/src/EnergyPlus/FuelCellElectricGenerator.cc b/src/EnergyPlus/FuelCellElectricGenerator.cc index f9777a56f04..53db481c78c 100644 --- a/src/EnergyPlus/FuelCellElectricGenerator.cc +++ b/src/EnergyPlus/FuelCellElectricGenerator.cc @@ -111,7 +111,7 @@ namespace FuelCellElectricGenerator { { // SUBROUTINE INFORMATION: // AUTHOR Brent Griffith - // DATE WRITTEN MArch 2005 + // DATE WRITTEN March 2005 // RE-ENGINEERED na // PURPOSE OF THIS SUBROUTINE: This is the Solid oxide fuel cell Generator model driver. It @@ -167,14 +167,13 @@ namespace FuelCellElectricGenerator { // METHODOLOGY EMPLOYED: // EnergyPlus input processor - int GeneratorNum; // Generator counter 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 Array1D_string AlphArray(25); // character string data Array1D NumArray(200); // numeric data TODO deal with allocatable for extensible Array1D_bool lAlphaBlanks(25); - static bool ErrorsFound(false); // error flag + bool ErrorsFound(false); // error flag static bool MyOneTimeFlag(true); if (MyOneTimeFlag) { @@ -188,11 +187,11 @@ namespace FuelCellElectricGenerator { } // ALLOCATE ARRAYS - DataGenerators::FuelCell.allocate(DataGenerators::NumFuelCellGenerators); // inits handeled in derived type definitions + DataGenerators::FuelCell.allocate(DataGenerators::NumFuelCellGenerators); // inits handled in derived type definitions CheckEquipName.dimension(DataGenerators::NumFuelCellGenerators, true); // first load in FuelCell names - for (GeneratorNum = 1; GeneratorNum <= DataGenerators::NumFuelCellGenerators; ++GeneratorNum) { + for (int GeneratorNum = 1; GeneratorNum <= DataGenerators::NumFuelCellGenerators; ++GeneratorNum) { inputProcessor->getObjectItem( DataIPShortCuts::cCurrentModuleObject, GeneratorNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat, _, _, DataIPShortCuts::cAlphaFieldNames, DataIPShortCuts::cNumericFieldNames); UtilityRoutines::IsNameEmpty(AlphArray(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); @@ -334,7 +333,7 @@ namespace FuelCellElectricGenerator { } // set fuel supply ID in Fuel cell structure - for (GeneratorNum = 1; GeneratorNum <= DataGenerators::NumFuelCellGenerators; ++GeneratorNum) { + for (int GeneratorNum = 1; GeneratorNum <= DataGenerators::NumFuelCellGenerators; ++GeneratorNum) { DataGenerators::FuelCell(GeneratorNum).FuelSupNum = UtilityRoutines::FindItemInList(DataGenerators::FuelCell(GeneratorNum).NameFCFuelSup, DataGenerators::FuelSupply); // Fuel Supply ID if (DataGenerators::FuelCell(GeneratorNum).FuelSupNum == 0) { @@ -499,7 +498,7 @@ namespace FuelCellElectricGenerator { } } - for (GeneratorNum = 1; GeneratorNum <= DataGenerators::NumFuelCellGenerators; ++GeneratorNum) { + for (int GeneratorNum = 1; GeneratorNum <= DataGenerators::NumFuelCellGenerators; ++GeneratorNum) { // find molal fraction of oxygen in air supply int thisConstituent = UtilityRoutines::FindItem("Oxygen", DataGenerators::FuelCell(GeneratorNum).AirSup.ConstitName, DataGenerators::FuelCell(GeneratorNum).AirSup.NumConstituents); @@ -936,7 +935,7 @@ namespace FuelCellElectricGenerator { ShowFatalError("Errors found in getting input for fuel cell model "); } - for (GeneratorNum = 1; GeneratorNum <= DataGenerators::NumFuelCellGenerators; ++GeneratorNum) { + for (int GeneratorNum = 1; GeneratorNum <= DataGenerators::NumFuelCellGenerators; ++GeneratorNum) { SetupOutputVariable("Generator Produced Electric Power", OutputProcessor::Unit::W, DataGenerators::FuelCell(GeneratorNum).Report.ACPowerGen, @@ -2093,7 +2092,6 @@ namespace FuelCellElectricGenerator { // REFERENCES: // NIST Webbook on gas phase thermochemistry - Real64 tempCp; Real64 A; // shomate coeff Real64 B; // shomate coeff Real64 C; // shomate coeff @@ -2109,7 +2107,7 @@ namespace FuelCellElectricGenerator { // two different themodynamic curve fits might be used - tempCp = 0.0; + Real64 tempCp = 0.0; Real64 const Tkel = (FluidTemp + DataGlobals::KelvinConv); // temp for NASA eq. in Kelvin Real64 const Tsho = (FluidTemp + DataGlobals::KelvinConv) / 1000.0; // temp for Shomate eq in (Kelvin/1000) @@ -2174,8 +2172,6 @@ namespace FuelCellElectricGenerator { // REFERENCES: // NIST Webbook on gas phase thermochemistry - Real64 tempHair; - Real64 HairI; Real64 A; // shomate coeff Real64 B; // shomate coeff Real64 C; // shomate coeff @@ -2195,7 +2191,7 @@ namespace FuelCellElectricGenerator { // loop through fuel constituents and sum up Cp - tempHair = 0.0; + Real64 tempHair = 0.0; Real64 const pow_2_Tsho(pow_2(Tsho)); Real64 const pow_3_Tsho(pow_3(Tsho)); @@ -2217,7 +2213,7 @@ namespace FuelCellElectricGenerator { F = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateF; H = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateH; - HairI = (A * Tsho + B * pow_2_Tsho / 2.0 + C * pow_3_Tsho / 3.0 + D * pow_4_Tsho / 4.0 - E / Tsho + F - H); + Real64 HairI = (A * Tsho + B * pow_2_Tsho / 2.0 + C * pow_3_Tsho / 3.0 + D * pow_4_Tsho / 4.0 - E / Tsho + F - H); tempHair += HairI * DataGenerators::FuelCell(GeneratorNum).AirSup.ConstitMolalFract(thisConstit); } @@ -2262,7 +2258,6 @@ namespace FuelCellElectricGenerator { // REFERENCES: // NIST Webbook on gas phase thermochemistry - Real64 tempCp; Real64 A; // shomate coeff Real64 B; // shomate coeff Real64 C; // shomate coeff @@ -2279,7 +2274,7 @@ namespace FuelCellElectricGenerator { // loop through fuel constituents and sum up Cp - tempCp = 0.0; + Real64 tempCp = 0.0; Real64 const pow_2_Tsho(pow_2(Tsho)); Real64 const pow_3_Tsho(pow_3(Tsho)); @@ -2340,8 +2335,6 @@ namespace FuelCellElectricGenerator { // REFERENCES: // NIST Webbook on gas phase thermochemistry - Real64 tempHfuel; - Real64 HfuelI; Real64 A; // shomate coeff Real64 B; // shomate coeff Real64 C; // shomate coeff @@ -2361,7 +2354,7 @@ namespace FuelCellElectricGenerator { // loop through fuel constituents and sum up Cp - tempHfuel = 0.0; + Real64 tempHfuel = 0.0; Real64 const pow_2_Tsho(pow_2(Tsho)); Real64 const pow_3_Tsho(pow_3(Tsho)); @@ -2382,7 +2375,7 @@ namespace FuelCellElectricGenerator { F = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateF; H = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateH; - HfuelI = (A * Tsho + B * pow_2_Tsho / 2.0 + C * pow_3_Tsho / 3.0 + D * pow_4_Tsho / 4.0 - E / Tsho + F - H); + Real64 HfuelI = (A * Tsho + B * pow_2_Tsho / 2.0 + C * pow_3_Tsho / 3.0 + D * pow_4_Tsho / 4.0 - E / Tsho + F - H); tempHfuel += HfuelI * DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).ConstitMolalFract(thisConstit); } @@ -2428,7 +2421,6 @@ namespace FuelCellElectricGenerator { // REFERENCES: // NIST Webbook on gas phase thermochemistry - Real64 tempHprodGases; Real64 A; // shomate coeff Real64 B; // shomate coeff Real64 C; // shomate coeff @@ -2448,7 +2440,7 @@ namespace FuelCellElectricGenerator { // loop through fuel constituents and sum up Cp - tempHprodGases = 0.0; + Real64 tempHprodGases = 0.0; Real64 const pow_2_Tsho(pow_2(Tsho)); Real64 const pow_3_Tsho(pow_3(Tsho)); @@ -3147,8 +3139,6 @@ namespace FuelCellElectricGenerator { // does not (re)simulate entire FuelCell model if (GetFuelCellInput) { - - // Read input data. GetFuelCellGeneratorInput(); GetFuelCellInput = false; } @@ -3213,12 +3203,7 @@ namespace FuelCellElectricGenerator { static bool InitGeneratorOnce(true); // flag for 1 time initialization static Array1D_bool MyEnvrnFlag; // flag for init once at start of environment static Array1D_bool MyWarmupFlag; // flag for init after warmup complete - int inNode; // inlet index in Node array - int outNode; // outlet, index in Node array - Real64 TimeElapsed; // Fraction of the current hour that has elapsed (h) static Array1D_bool MyPlantScanFlag; - Real64 mdot; // local temporary mass flow rate - Real64 rho; // local temporary fluid density bool errFlag; // Do the one time initializations @@ -3313,20 +3298,18 @@ namespace FuelCellElectricGenerator { DataGenerators::FuelCell(FCnum).Inverter.PCUlosses = 0.0; DataGenerators::FuelCell(FCnum).Inverter.QairIntake = 0.0; - rho = FluidProperties::GetDensityGlycol( + Real64 rho = FluidProperties::GetDensityGlycol( DataPlant::PlantLoop(DataGenerators::FuelCell(FCnum).CWLoopNum).FluidName, DataGenerators::InitHRTemp, DataPlant::PlantLoop(DataGenerators::FuelCell(FCnum).CWLoopNum).FluidIndex, RoutineName); DataGenerators::FuelCell(FCnum).ExhaustHX.WaterMassFlowRateDesign = DataGenerators::FuelCell(FCnum).ExhaustHX.WaterVolumeFlowMax * rho; DataGenerators::FuelCell(FCnum).ExhaustHX.WaterMassFlowRate = DataGenerators::FuelCell(FCnum).ExhaustHX.WaterMassFlowRateDesign; - inNode = DataGenerators::FuelCell(FCnum).ExhaustHX.WaterInNode; - outNode = DataGenerators::FuelCell(FCnum).ExhaustHX.WaterOutNode; - DataLoopNode::Node(inNode).Temp = DataGenerators::InitHRTemp; - DataLoopNode::Node(outNode).Temp = DataGenerators::InitHRTemp; + DataLoopNode::Node(DataGenerators::FuelCell(FCnum).ExhaustHX.WaterInNode).Temp = DataGenerators::InitHRTemp; + DataLoopNode::Node(DataGenerators::FuelCell(FCnum).ExhaustHX.WaterOutNode).Temp = DataGenerators::InitHRTemp; PlantUtilities::InitComponentNodes(0.0, DataGenerators::FuelCell(FCnum).ExhaustHX.WaterMassFlowRateDesign, - inNode, - outNode, + DataGenerators::FuelCell(FCnum).ExhaustHX.WaterInNode, + DataGenerators::FuelCell(FCnum).ExhaustHX.WaterOutNode, DataGenerators::FuelCell(FCnum).CWLoopNum, DataGenerators::FuelCell(FCnum).CWLoopSideNum, DataGenerators::FuelCell(FCnum).CWBranchNum, @@ -3348,30 +3331,27 @@ namespace FuelCellElectricGenerator { } // using and elapsed time method rather than FirstHVACIteration here - TimeElapsed = DataGlobals::HourOfDay + DataGlobals::TimeStep * DataGlobals::TimeStepZone + DataHVACGlobals::SysTimeElapsed; + Real64 TimeElapsed = DataGlobals::HourOfDay + DataGlobals::TimeStep * DataGlobals::TimeStepZone + DataHVACGlobals::SysTimeElapsed; if (DataGenerators::FuelCell(FCnum).TimeElapsed != TimeElapsed) { DataGenerators::FuelCell(FCnum).ElecStorage.LastTimeStepStateOfCharge = DataGenerators::FuelCell(FCnum).ElecStorage.ThisTimeStepStateOfCharge; DataGenerators::FuelCell(FCnum).FCPM.PelLastTimeStep = DataGenerators::FuelCell(FCnum).FCPM.Pel; - inNode = DataGenerators::FuelCell(FCnum).ExhaustHX.WaterInNode; - outNode = DataGenerators::FuelCell(FCnum).ExhaustHX.WaterOutNode; // intialize flow rate in water loop, this is "requesting" flow - mdot = DataGenerators::FuelCell(FCnum).ExhaustHX.WaterMassFlowRateDesign; + Real64 mdot = DataGenerators::FuelCell(FCnum).ExhaustHX.WaterMassFlowRateDesign; PlantUtilities::SetComponentFlowRate(mdot, - inNode, - outNode, + DataGenerators::FuelCell(FCnum).ExhaustHX.WaterInNode, + DataGenerators::FuelCell(FCnum).ExhaustHX.WaterOutNode, DataGenerators::FuelCell(FCnum).CWLoopNum, DataGenerators::FuelCell(FCnum).CWLoopSideNum, DataGenerators::FuelCell(FCnum).CWBranchNum, DataGenerators::FuelCell(FCnum).CWCompNum); DataGenerators::FuelCell(FCnum).ExhaustHX.WaterMassFlowRate = mdot; - DataGenerators::FuelCell(FCnum).ExhaustHX.WaterInletTemp = DataLoopNode::Node(inNode).Temp; + DataGenerators::FuelCell(FCnum).ExhaustHX.WaterInletTemp = DataLoopNode::Node(DataGenerators::FuelCell(FCnum).ExhaustHX.WaterInNode).Temp; DataGenerators::FuelCell(FCnum).TimeElapsed = TimeElapsed; } else { - inNode = DataGenerators::FuelCell(FCnum).ExhaustHX.WaterInNode; PlantUtilities::SetComponentFlowRate(DataGenerators::FuelCell(FCnum).ExhaustHX.WaterMassFlowRate, DataGenerators::FuelCell(FCnum).ExhaustHX.WaterInNode, @@ -3381,7 +3361,7 @@ namespace FuelCellElectricGenerator { DataGenerators::FuelCell(FCnum).CWBranchNum, DataGenerators::FuelCell(FCnum).CWCompNum); - DataGenerators::FuelCell(FCnum).ExhaustHX.WaterInletTemp = DataLoopNode::Node(inNode).Temp; + DataGenerators::FuelCell(FCnum).ExhaustHX.WaterInletTemp = DataLoopNode::Node(DataGenerators::FuelCell(FCnum).ExhaustHX.WaterInNode).Temp; } } @@ -3414,15 +3394,13 @@ namespace FuelCellElectricGenerator { // RE-ENGINEERED na // PURPOSE OF THIS SUBROUTINE: - // Couple equpment skin losses to the Zone Heat Balance + // Couple equipment skin losses to the Zone Heat Balance // calculate skin losses from different subsystems and set the value // METHODOLOGY EMPLOYED: // This routine adds up the various skin losses and then // sets the values in the ZoneIntGain structure - Real64 TotalZoneHeatGain; // working variable for zone gain [w] - int FCnum; // number of fuel cell static bool MyEnvrnFlag(true); if (DataGenerators::NumFuelCellGenerators == 0) return; @@ -3454,8 +3432,8 @@ namespace FuelCellElectricGenerator { // this routine needs to do something for zone gains during sizing // first collect skin losses from different subsystems - for (FCnum = 1; FCnum <= DataGenerators::NumFuelCellGenerators; ++FCnum) { - TotalZoneHeatGain = DataGenerators::FuelCell(FCnum).AirSup.QskinLoss + DataGenerators::FuelSupply(DataGenerators::FuelCell(FCnum).FuelSupNum).QskinLoss + + for (int FCnum = 1; FCnum <= DataGenerators::NumFuelCellGenerators; ++FCnum) { + Real64 TotalZoneHeatGain = DataGenerators::FuelCell(FCnum).AirSup.QskinLoss + DataGenerators::FuelSupply(DataGenerators::FuelCell(FCnum).FuelSupNum).QskinLoss + DataGenerators::FuelCell(FCnum).WaterSup.QskinLoss + DataGenerators::FuelCell(FCnum).AuxilHeat.QskinLoss + DataGenerators::FuelCell(FCnum).FCPM.QdotSkin; // intake Blower losses to zone | fuel compressor losses to zone | water pump losses to // zone | auxil burner losses to zone | power module (stack and reformer) losses to @@ -3505,17 +3483,12 @@ namespace FuelCellElectricGenerator { // PURPOSE OF THIS SUBROUTINE: // update plant loop interactions, do any calcs needed - int InNodeNum; - int OutNodeNum; - // now update water outlet node Changing to Kg/s! - OutNodeNum = DataGenerators::FuelCell(Num).ExhaustHX.WaterOutNode; - InNodeNum = DataGenerators::FuelCell(Num).ExhaustHX.WaterInNode; - PlantUtilities::SafeCopyPlantNode(InNodeNum, OutNodeNum); + PlantUtilities::SafeCopyPlantNode(DataGenerators::FuelCell(Num).ExhaustHX.WaterInNode, DataGenerators::FuelCell(Num).ExhaustHX.WaterOutNode); - DataLoopNode::Node(OutNodeNum).Temp = DataGenerators::FuelCell(Num).ExhaustHX.WaterOutletTemp; - DataLoopNode::Node(OutNodeNum).Enthalpy = DataGenerators::FuelCell(Num).ExhaustHX.WaterOutletEnthalpy; + DataLoopNode::Node(DataGenerators::FuelCell(Num).ExhaustHX.WaterOutNode).Temp = DataGenerators::FuelCell(Num).ExhaustHX.WaterOutletTemp; + DataLoopNode::Node(DataGenerators::FuelCell(Num).ExhaustHX.WaterOutNode).Enthalpy = DataGenerators::FuelCell(Num).ExhaustHX.WaterOutletEnthalpy; } void UpdateFuelCellGeneratorRecords(bool const EP_UNUSED(RunFlag), // TRUE if Generator operating From 843bd5f0b9fd7dd3f67dfffeb6aa3854e12b48c7 Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Tue, 12 Nov 2019 08:45:20 -0700 Subject: [PATCH 25/51] partial remove statics --- src/EnergyPlus/FuelCellElectricGenerator.cc | 1926 +++++++++---------- 1 file changed, 960 insertions(+), 966 deletions(-) diff --git a/src/EnergyPlus/FuelCellElectricGenerator.cc b/src/EnergyPlus/FuelCellElectricGenerator.cc index 53db481c78c..69ae87a1cb1 100644 --- a/src/EnergyPlus/FuelCellElectricGenerator.cc +++ b/src/EnergyPlus/FuelCellElectricGenerator.cc @@ -174,1139 +174,1133 @@ namespace FuelCellElectricGenerator { Array1D NumArray(200); // numeric data TODO deal with allocatable for extensible Array1D_bool lAlphaBlanks(25); bool ErrorsFound(false); // error flag - static bool MyOneTimeFlag(true); - if (MyOneTimeFlag) { + DataIPShortCuts::cCurrentModuleObject = "Generator:FuelCell"; + DataGenerators::NumFuelCellGenerators = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); - DataIPShortCuts::cCurrentModuleObject = "Generator:FuelCell"; - DataGenerators::NumFuelCellGenerators = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); + if (DataGenerators::NumFuelCellGenerators <= 0) { + ShowSevereError("No " + DataIPShortCuts::cCurrentModuleObject + " equipment specified in input file"); + ErrorsFound = true; + } - if (DataGenerators::NumFuelCellGenerators <= 0) { - ShowSevereError("No " + DataIPShortCuts::cCurrentModuleObject + " equipment specified in input file"); - ErrorsFound = true; + // ALLOCATE ARRAYS + DataGenerators::FuelCell.allocate(DataGenerators::NumFuelCellGenerators); // inits handled in derived type definitions + CheckEquipName.dimension(DataGenerators::NumFuelCellGenerators, true); + + // first load in FuelCell names + for (int GeneratorNum = 1; GeneratorNum <= DataGenerators::NumFuelCellGenerators; ++GeneratorNum) { + inputProcessor->getObjectItem( + DataIPShortCuts::cCurrentModuleObject, GeneratorNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat, _, _, DataIPShortCuts::cAlphaFieldNames, DataIPShortCuts::cNumericFieldNames); + UtilityRoutines::IsNameEmpty(AlphArray(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); + + DataGenerators::FuelCell(GeneratorNum).Name = AlphArray(1); + DataGenerators::FuelCell(GeneratorNum).NameFCPM = AlphArray(2); + DataGenerators::FuelCell(GeneratorNum).NameFCAirSup = AlphArray(3); + DataGenerators::FuelCell(GeneratorNum).NameFCFuelSup = AlphArray(4); + DataGenerators::FuelCell(GeneratorNum).NameFCWaterSup = AlphArray(5); + DataGenerators::FuelCell(GeneratorNum).NameFCAuxilHeat = AlphArray(6); + DataGenerators::FuelCell(GeneratorNum).NameExhaustHX = AlphArray(7); + DataGenerators::FuelCell(GeneratorNum).NameElecStorage = AlphArray(8); + DataGenerators::FuelCell(GeneratorNum).NameInverter = AlphArray(9); + if (NumAlphas == 10) { + DataGenerators::FuelCell(GeneratorNum).NameStackCooler = AlphArray(10); } + } - // ALLOCATE ARRAYS - DataGenerators::FuelCell.allocate(DataGenerators::NumFuelCellGenerators); // inits handled in derived type definitions - CheckEquipName.dimension(DataGenerators::NumFuelCellGenerators, true); + DataIPShortCuts::cCurrentModuleObject = "Generator:FuelCell:PowerModule"; + int NumFuelCellPMs = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); - // first load in FuelCell names - for (int GeneratorNum = 1; GeneratorNum <= DataGenerators::NumFuelCellGenerators; ++GeneratorNum) { - inputProcessor->getObjectItem( - DataIPShortCuts::cCurrentModuleObject, GeneratorNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat, _, _, DataIPShortCuts::cAlphaFieldNames, DataIPShortCuts::cNumericFieldNames); - UtilityRoutines::IsNameEmpty(AlphArray(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); + if (NumFuelCellPMs <= 0) { + ShowSevereError("No " + DataIPShortCuts::cCurrentModuleObject + " equipment specified in input file"); + ErrorsFound = true; + } + + for (int FCPMNum = 1; FCPMNum <= NumFuelCellPMs; ++FCPMNum) { + inputProcessor->getObjectItem(DataIPShortCuts::cCurrentModuleObject, + FCPMNum, + AlphArray, + NumAlphas, + NumArray, + NumNums, + IOStat, + _, + lAlphaBlanks, + DataIPShortCuts::cAlphaFieldNames, + DataIPShortCuts::cNumericFieldNames); + UtilityRoutines::IsNameEmpty(AlphArray(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); + + int thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), DataGenerators::FuelCell, &DataGenerators::FCDataStruct::NameFCPM); + if (thisFuelCell > 0) { + + DataGenerators::FuelCell(thisFuelCell).FCPM.Name = AlphArray(1); + if (UtilityRoutines::SameString(AlphArray(2), "ANNEX42")) DataGenerators::FuelCell(thisFuelCell).FCPM.EffMode = DataGenerators::DirectCurveMode; + if (UtilityRoutines::SameString(AlphArray(2), "NORMALIZED")) DataGenerators::FuelCell(thisFuelCell).FCPM.EffMode = DataGenerators::NormalizedCurveMode; + if (DataGenerators::FuelCell(thisFuelCell).FCPM.EffMode == 0) { + ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(2) + " = " + AlphArray(2)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); + ErrorsFound = true; + } + DataGenerators::FuelCell(thisFuelCell).FCPM.EffCurveID = CurveManager::GetCurveIndex(AlphArray(3)); + if (DataGenerators::FuelCell(thisFuelCell).FCPM.EffCurveID == 0) { + ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(3) + " = " + AlphArray(3)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); + ErrorsFound = true; + } - DataGenerators::FuelCell(GeneratorNum).Name = AlphArray(1); - DataGenerators::FuelCell(GeneratorNum).NameFCPM = AlphArray(2); - DataGenerators::FuelCell(GeneratorNum).NameFCAirSup = AlphArray(3); - DataGenerators::FuelCell(GeneratorNum).NameFCFuelSup = AlphArray(4); - DataGenerators::FuelCell(GeneratorNum).NameFCWaterSup = AlphArray(5); - DataGenerators::FuelCell(GeneratorNum).NameFCAuxilHeat = AlphArray(6); - DataGenerators::FuelCell(GeneratorNum).NameExhaustHX = AlphArray(7); - DataGenerators::FuelCell(GeneratorNum).NameElecStorage = AlphArray(8); - DataGenerators::FuelCell(GeneratorNum).NameInverter = AlphArray(9); - if (NumAlphas == 10) { - DataGenerators::FuelCell(GeneratorNum).NameStackCooler = AlphArray(10); + DataGenerators::FuelCell(thisFuelCell).FCPM.NomEff = NumArray(1); + DataGenerators::FuelCell(thisFuelCell).FCPM.NomPel = NumArray(2); + DataGenerators::FuelCell(thisFuelCell).FCPM.NumCycles = NumArray(3); + DataGenerators::FuelCell(thisFuelCell).FCPM.CyclingDegradRat = NumArray(4); + DataGenerators::FuelCell(thisFuelCell).FCPM.NumRunHours = NumArray(5); + DataGenerators::FuelCell(thisFuelCell).FCPM.OperateDegradRat = NumArray(6); + DataGenerators::FuelCell(thisFuelCell).FCPM.ThreshRunHours = NumArray(7); + DataGenerators::FuelCell(thisFuelCell).FCPM.UpTranLimit = NumArray(8); + DataGenerators::FuelCell(thisFuelCell).FCPM.DownTranLimit = NumArray(9); + DataGenerators::FuelCell(thisFuelCell).FCPM.StartUpTime = NumArray(10) / DataGlobals::SecInHour; // convert to hours from seconds + DataGenerators::FuelCell(thisFuelCell).FCPM.StartUpFuel = NumArray(11); + DataGenerators::FuelCell(thisFuelCell).FCPM.StartUpElectConsum = NumArray(12); + DataGenerators::FuelCell(thisFuelCell).FCPM.StartUpElectProd = NumArray(13); + DataGenerators::FuelCell(thisFuelCell).FCPM.ShutDownTime = NumArray(14) / DataGlobals::SecInHour; // convert to hours from seconds + DataGenerators::FuelCell(thisFuelCell).FCPM.ShutDownFuel = NumArray(15); + DataGenerators::FuelCell(thisFuelCell).FCPM.ShutDownElectConsum = NumArray(16); + DataGenerators::FuelCell(thisFuelCell).FCPM.ANC0 = NumArray(17); + DataGenerators::FuelCell(thisFuelCell).FCPM.ANC1 = NumArray(18); + if (UtilityRoutines::SameString(AlphArray(4), "ConstantRate")) DataGenerators::FuelCell(thisFuelCell).FCPM.SkinLossMode = DataGenerators::ConstantRateSkinLoss; + if (UtilityRoutines::SameString(AlphArray(4), "UAForProcessGasTemperature")) + DataGenerators::FuelCell(thisFuelCell).FCPM.SkinLossMode = DataGenerators::UADTSkinLoss; + if (UtilityRoutines::SameString(AlphArray(4), "QUADRATIC FUNCTION OF FUEL RATE")) + DataGenerators::FuelCell(thisFuelCell).FCPM.SkinLossMode = DataGenerators::QuadraticFuelNdotSkin; + if (DataGenerators::FuelCell(thisFuelCell).FCPM.SkinLossMode == 0) { + // throw error + ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(4) + " = " + AlphArray(4)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); + ErrorsFound = true; } + DataGenerators::FuelCell(thisFuelCell).FCPM.ZoneName = AlphArray(5); + DataGenerators::FuelCell(thisFuelCell).FCPM.ZoneID = UtilityRoutines::FindItemInList(DataGenerators::FuelCell(thisFuelCell).FCPM.ZoneName, DataHeatBalance::Zone); + if (DataGenerators::FuelCell(thisFuelCell).FCPM.ZoneID == 0 && !lAlphaBlanks(5)) { + ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(5) + " = " + AlphArray(5)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); + ShowContinueError("Zone Name was not found "); + ErrorsFound = true; + } + + DataGenerators::FuelCell(thisFuelCell).FCPM.RadiativeFract = NumArray(19); + DataGenerators::FuelCell(thisFuelCell).FCPM.QdotSkin = NumArray(20); + DataGenerators::FuelCell(thisFuelCell).FCPM.UAskin = NumArray(21); + + DataGenerators::FuelCell(thisFuelCell).FCPM.SkinLossCurveID = CurveManager::GetCurveIndex(AlphArray(6)); + if (DataGenerators::FuelCell(thisFuelCell).FCPM.SkinLossCurveID == 0) { + if (DataGenerators::FuelCell(thisFuelCell).FCPM.SkinLossMode == DataGenerators::QuadraticFuelNdotSkin) { + ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(6) + " = " + AlphArray(6)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); + ErrorsFound = true; + } + } + + DataGenerators::FuelCell(thisFuelCell).FCPM.NdotDilutionAir = NumArray(22); + DataGenerators::FuelCell(thisFuelCell).FCPM.StackHeatLossToDilution = NumArray(23); + DataGenerators::FuelCell(thisFuelCell).FCPM.DilutionInletNodeName = AlphArray(7); + DataGenerators::FuelCell(thisFuelCell).FCPM.DilutionInletNode = NodeInputManager::GetOnlySingleNode( + AlphArray(7), ErrorsFound, DataIPShortCuts::cCurrentModuleObject, AlphArray(1), DataLoopNode::NodeType_Air, DataLoopNode::NodeConnectionType_Inlet, 1, DataLoopNode::ObjectIsNotParent); + DataGenerators::FuelCell(thisFuelCell).FCPM.DilutionExhaustNodeName = AlphArray(8); + DataGenerators::FuelCell(thisFuelCell).FCPM.DilutionExhaustNode = NodeInputManager::GetOnlySingleNode( + AlphArray(8), ErrorsFound, DataIPShortCuts::cCurrentModuleObject, AlphArray(1), DataLoopNode::NodeType_Air, DataLoopNode::NodeConnectionType_Outlet, 1, DataLoopNode::ObjectIsNotParent); + + DataGenerators::FuelCell(thisFuelCell).FCPM.PelMin = NumArray(24); + DataGenerators::FuelCell(thisFuelCell).FCPM.PelMax = NumArray(25); + + // check for other FuelCell using the same power module and fill + for (int otherFuelCell = thisFuelCell + 1; otherFuelCell <= DataGenerators::NumFuelCellGenerators; ++otherFuelCell) { + if (UtilityRoutines::SameString(DataGenerators::FuelCell(otherFuelCell).FCPM.Name, DataGenerators::FuelCell(thisFuelCell).FCPM.Name)) { + DataGenerators::FuelCell(otherFuelCell).FCPM = DataGenerators::FuelCell(thisFuelCell).FCPM; + } + } + } else { // throw warning, did not find power module input + ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(1) + " = " + AlphArray(1)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); + ErrorsFound = true; } + } // loop over NumFuelCellPMs - DataIPShortCuts::cCurrentModuleObject = "Generator:FuelCell:PowerModule"; - int NumFuelCellPMs = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); + GeneratorFuelSupply::GetGeneratorFuelSupplyInput(); - if (NumFuelCellPMs <= 0) { - ShowSevereError("No " + DataIPShortCuts::cCurrentModuleObject + " equipment specified in input file"); + for (int FuelSupNum = 1; FuelSupNum <= DataGenerators::NumGeneratorFuelSups; ++FuelSupNum) { + GeneratorFuelSupply::SetupFuelConstituentData(FuelSupNum, ErrorsFound); + } + + // set fuel supply ID in Fuel cell structure + for (int GeneratorNum = 1; GeneratorNum <= DataGenerators::NumFuelCellGenerators; ++GeneratorNum) { + DataGenerators::FuelCell(GeneratorNum).FuelSupNum = + UtilityRoutines::FindItemInList(DataGenerators::FuelCell(GeneratorNum).NameFCFuelSup, DataGenerators::FuelSupply); // Fuel Supply ID + if (DataGenerators::FuelCell(GeneratorNum).FuelSupNum == 0) { + ShowSevereError("Fuel Supply Name: " + DataGenerators::FuelCell(GeneratorNum).NameFCFuelSup + " not found in " + DataGenerators::FuelCell(GeneratorNum).Name); ErrorsFound = true; } + } - for (int FCPMNum = 1; FCPMNum <= NumFuelCellPMs; ++FCPMNum) { - inputProcessor->getObjectItem(DataIPShortCuts::cCurrentModuleObject, - FCPMNum, - AlphArray, - NumAlphas, - NumArray, - NumNums, - IOStat, - _, - lAlphaBlanks, - DataIPShortCuts::cAlphaFieldNames, - DataIPShortCuts::cNumericFieldNames); - UtilityRoutines::IsNameEmpty(AlphArray(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); + DataIPShortCuts::cCurrentModuleObject = "Generator:FuelCell:AirSupply"; + int NumFuelCellAirSups = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); - int thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), DataGenerators::FuelCell, &DataGenerators::FCDataStruct::NameFCPM); - if (thisFuelCell > 0) { // cr9323 + if (NumFuelCellAirSups <= 0) { // Autodesk:Uninit thisFuelCell was possibly uninitialized past this condition + ShowSevereError("No " + DataIPShortCuts::cCurrentModuleObject + " equipment specified in input file"); + ErrorsFound = true; + } - DataGenerators::FuelCell(thisFuelCell).FCPM.Name = AlphArray(1); - if (UtilityRoutines::SameString(AlphArray(2), "ANNEX42")) DataGenerators::FuelCell(thisFuelCell).FCPM.EffMode = DataGenerators::DirectCurveMode; - if (UtilityRoutines::SameString(AlphArray(2), "NORMALIZED")) DataGenerators::FuelCell(thisFuelCell).FCPM.EffMode = DataGenerators::NormalizedCurveMode; - if (DataGenerators::FuelCell(thisFuelCell).FCPM.EffMode == 0) { - ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(2) + " = " + AlphArray(2)); - ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); - ErrorsFound = true; - } - DataGenerators::FuelCell(thisFuelCell).FCPM.EffCurveID = CurveManager::GetCurveIndex(AlphArray(3)); - if (DataGenerators::FuelCell(thisFuelCell).FCPM.EffCurveID == 0) { - ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(3) + " = " + AlphArray(3)); - ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); - ErrorsFound = true; - } + for (int FCAirSupNum = 1; FCAirSupNum <= NumFuelCellAirSups; ++FCAirSupNum) { + inputProcessor->getObjectItem( + DataIPShortCuts::cCurrentModuleObject, FCAirSupNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat, _, _, DataIPShortCuts::cAlphaFieldNames, DataIPShortCuts::cNumericFieldNames); + UtilityRoutines::IsNameEmpty(AlphArray(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); - DataGenerators::FuelCell(thisFuelCell).FCPM.NomEff = NumArray(1); - DataGenerators::FuelCell(thisFuelCell).FCPM.NomPel = NumArray(2); - DataGenerators::FuelCell(thisFuelCell).FCPM.NumCycles = NumArray(3); - DataGenerators::FuelCell(thisFuelCell).FCPM.CyclingDegradRat = NumArray(4); - DataGenerators::FuelCell(thisFuelCell).FCPM.NumRunHours = NumArray(5); - DataGenerators::FuelCell(thisFuelCell).FCPM.OperateDegradRat = NumArray(6); - DataGenerators::FuelCell(thisFuelCell).FCPM.ThreshRunHours = NumArray(7); - DataGenerators::FuelCell(thisFuelCell).FCPM.UpTranLimit = NumArray(8); - DataGenerators::FuelCell(thisFuelCell).FCPM.DownTranLimit = NumArray(9); - DataGenerators::FuelCell(thisFuelCell).FCPM.StartUpTime = NumArray(10) / DataGlobals::SecInHour; // convert to hours from seconds - DataGenerators::FuelCell(thisFuelCell).FCPM.StartUpFuel = NumArray(11); - DataGenerators::FuelCell(thisFuelCell).FCPM.StartUpElectConsum = NumArray(12); - DataGenerators::FuelCell(thisFuelCell).FCPM.StartUpElectProd = NumArray(13); - DataGenerators::FuelCell(thisFuelCell).FCPM.ShutDownTime = NumArray(14) / DataGlobals::SecInHour; // convert to hours from seconds - DataGenerators::FuelCell(thisFuelCell).FCPM.ShutDownFuel = NumArray(15); - DataGenerators::FuelCell(thisFuelCell).FCPM.ShutDownElectConsum = NumArray(16); - DataGenerators::FuelCell(thisFuelCell).FCPM.ANC0 = NumArray(17); - DataGenerators::FuelCell(thisFuelCell).FCPM.ANC1 = NumArray(18); - if (UtilityRoutines::SameString(AlphArray(4), "ConstantRate")) DataGenerators::FuelCell(thisFuelCell).FCPM.SkinLossMode = DataGenerators::ConstantRateSkinLoss; - if (UtilityRoutines::SameString(AlphArray(4), "UAForProcessGasTemperature")) - DataGenerators::FuelCell(thisFuelCell).FCPM.SkinLossMode = DataGenerators::UADTSkinLoss; - if (UtilityRoutines::SameString(AlphArray(4), "QUADRATIC FUNCTION OF FUEL RATE")) - DataGenerators::FuelCell(thisFuelCell).FCPM.SkinLossMode = DataGenerators::QuadraticFuelNdotSkin; - if (DataGenerators::FuelCell(thisFuelCell).FCPM.SkinLossMode == 0) { - // throw error - ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(4) + " = " + AlphArray(4)); - ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); - ErrorsFound = true; - } - DataGenerators::FuelCell(thisFuelCell).FCPM.ZoneName = AlphArray(5); - DataGenerators::FuelCell(thisFuelCell).FCPM.ZoneID = UtilityRoutines::FindItemInList(DataGenerators::FuelCell(thisFuelCell).FCPM.ZoneName, DataHeatBalance::Zone); - if (DataGenerators::FuelCell(thisFuelCell).FCPM.ZoneID == 0 && !lAlphaBlanks(5)) { - ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(5) + " = " + AlphArray(5)); - ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); - ShowContinueError("Zone Name was not found "); - ErrorsFound = true; - } + int thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), DataGenerators::FuelCell, &DataGenerators::FCDataStruct::NameFCAirSup); - DataGenerators::FuelCell(thisFuelCell).FCPM.RadiativeFract = NumArray(19); - DataGenerators::FuelCell(thisFuelCell).FCPM.QdotSkin = NumArray(20); - DataGenerators::FuelCell(thisFuelCell).FCPM.UAskin = NumArray(21); + if (thisFuelCell > 0) { - DataGenerators::FuelCell(thisFuelCell).FCPM.SkinLossCurveID = CurveManager::GetCurveIndex(AlphArray(6)); - if (DataGenerators::FuelCell(thisFuelCell).FCPM.SkinLossCurveID == 0) { - if (DataGenerators::FuelCell(thisFuelCell).FCPM.SkinLossMode == DataGenerators::QuadraticFuelNdotSkin) { - ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(6) + " = " + AlphArray(6)); - ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); - ErrorsFound = true; - } - } + DataGenerators::FuelCell(thisFuelCell).AirSup.Name = AlphArray(1); + DataGenerators::FuelCell(thisFuelCell).AirSup.NodeName = AlphArray(2); - DataGenerators::FuelCell(thisFuelCell).FCPM.NdotDilutionAir = NumArray(22); - DataGenerators::FuelCell(thisFuelCell).FCPM.StackHeatLossToDilution = NumArray(23); - DataGenerators::FuelCell(thisFuelCell).FCPM.DilutionInletNodeName = AlphArray(7); - DataGenerators::FuelCell(thisFuelCell).FCPM.DilutionInletNode = NodeInputManager::GetOnlySingleNode( - AlphArray(7), ErrorsFound, DataIPShortCuts::cCurrentModuleObject, AlphArray(1), DataLoopNode::NodeType_Air, DataLoopNode::NodeConnectionType_Inlet, 1, DataLoopNode::ObjectIsNotParent); - DataGenerators::FuelCell(thisFuelCell).FCPM.DilutionExhaustNodeName = AlphArray(8); - DataGenerators::FuelCell(thisFuelCell).FCPM.DilutionExhaustNode = NodeInputManager::GetOnlySingleNode( - AlphArray(8), ErrorsFound, DataIPShortCuts::cCurrentModuleObject, AlphArray(1), DataLoopNode::NodeType_Air, DataLoopNode::NodeConnectionType_Outlet, 1, DataLoopNode::ObjectIsNotParent); - - DataGenerators::FuelCell(thisFuelCell).FCPM.PelMin = NumArray(24); - DataGenerators::FuelCell(thisFuelCell).FCPM.PelMax = NumArray(25); - - // check for other FuelCell using the same power module and fill - for (int otherFuelCell = thisFuelCell + 1; otherFuelCell <= DataGenerators::NumFuelCellGenerators; ++otherFuelCell) { - if (UtilityRoutines::SameString(DataGenerators::FuelCell(otherFuelCell).FCPM.Name, DataGenerators::FuelCell(thisFuelCell).FCPM.Name)) { - DataGenerators::FuelCell(otherFuelCell).FCPM = DataGenerators::FuelCell(thisFuelCell).FCPM; - } - } - } else { // throw warning, did not find power module input - ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(1) + " = " + AlphArray(1)); + // check the node connections + DataGenerators::FuelCell(thisFuelCell).AirSup.SupNodeNum = NodeInputManager::GetOnlySingleNode( + AlphArray(2), ErrorsFound, DataIPShortCuts::cCurrentModuleObject, AlphArray(1), DataLoopNode::NodeType_Air, DataLoopNode::NodeConnectionType_Inlet, 1, DataLoopNode::ObjectIsNotParent); + + DataGenerators::FuelCell(thisFuelCell).AirSup.BlowerPowerCurveID = CurveManager::GetCurveIndex(AlphArray(3)); + if (DataGenerators::FuelCell(thisFuelCell).AirSup.BlowerPowerCurveID == 0) { + ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(3) + " = " + AlphArray(3)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); + ShowContinueError("Curve name was not found "); + ErrorsFound = true; + } + DataGenerators::FuelCell(thisFuelCell).AirSup.BlowerHeatLossFactor = NumArray(1); + + if (UtilityRoutines::SameString(AlphArray(4), "AirRatiobyStoics")) { + DataGenerators::FuelCell(thisFuelCell).AirSup.AirSupRateMode = DataGenerators::ConstantStoicsAirRat; + } else if (UtilityRoutines::SameString(AlphArray(4), "QuadraticFunctionofElectricPower")) { + DataGenerators::FuelCell(thisFuelCell).AirSup.AirSupRateMode = DataGenerators::QuadraticFuncofPel; + } else if (UtilityRoutines::SameString(AlphArray(4), "QUADRATIC FUNCTION OF FUEL RATE")) { + DataGenerators::FuelCell(thisFuelCell).AirSup.AirSupRateMode = DataGenerators::QuadraticFuncofNdot; + } else { + ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(4) + " = " + AlphArray(4)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } - } // loop over NumFuelCellPMs - - GeneratorFuelSupply::GetGeneratorFuelSupplyInput(); - for (int FuelSupNum = 1; FuelSupNum <= DataGenerators::NumGeneratorFuelSups; ++FuelSupNum) { - GeneratorFuelSupply::SetupFuelConstituentData(FuelSupNum, ErrorsFound); - } + DataGenerators::FuelCell(thisFuelCell).AirSup.Stoics = NumArray(2) + 1.0; - // set fuel supply ID in Fuel cell structure - for (int GeneratorNum = 1; GeneratorNum <= DataGenerators::NumFuelCellGenerators; ++GeneratorNum) { - DataGenerators::FuelCell(GeneratorNum).FuelSupNum = - UtilityRoutines::FindItemInList(DataGenerators::FuelCell(GeneratorNum).NameFCFuelSup, DataGenerators::FuelSupply); // Fuel Supply ID - if (DataGenerators::FuelCell(GeneratorNum).FuelSupNum == 0) { - ShowSevereError("Fuel Supply Name: " + DataGenerators::FuelCell(GeneratorNum).NameFCFuelSup + " not found in " + DataGenerators::FuelCell(GeneratorNum).Name); + DataGenerators::FuelCell(thisFuelCell).AirSup.AirFuncPelCurveID = CurveManager::GetCurveIndex(AlphArray(5)); + if ((DataGenerators::FuelCell(thisFuelCell).AirSup.AirFuncPelCurveID == 0) && + (DataGenerators::FuelCell(thisFuelCell).AirSup.AirSupRateMode == DataGenerators::QuadraticFuncofPel)) { + ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(5) + " = " + AlphArray(5)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); + ShowSevereError("Curve name was not found"); ErrorsFound = true; } - } - DataIPShortCuts::cCurrentModuleObject = "Generator:FuelCell:AirSupply"; - int NumFuelCellAirSups = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); + DataGenerators::FuelCell(thisFuelCell).AirSup.AirTempCoeff = NumArray(3); - if (NumFuelCellAirSups <= 0) { // Autodesk:Uninit thisFuelCell was possibly uninitialized past this condition - ShowSevereError("No " + DataIPShortCuts::cCurrentModuleObject + " equipment specified in input file"); - ErrorsFound = true; - } - - for (int FCAirSupNum = 1; FCAirSupNum <= NumFuelCellAirSups; ++FCAirSupNum) { - inputProcessor->getObjectItem( - DataIPShortCuts::cCurrentModuleObject, FCAirSupNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat, _, _, DataIPShortCuts::cAlphaFieldNames, DataIPShortCuts::cNumericFieldNames); - UtilityRoutines::IsNameEmpty(AlphArray(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); + DataGenerators::FuelCell(thisFuelCell).AirSup.AirFuncNdotCurveID = CurveManager::GetCurveIndex(AlphArray(6)); + if ((DataGenerators::FuelCell(thisFuelCell).AirSup.AirFuncNdotCurveID == 0) && + (DataGenerators::FuelCell(thisFuelCell).AirSup.AirSupRateMode == DataGenerators::QuadraticFuncofNdot)) { + ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(6) + " = " + AlphArray(6)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); + ShowSevereError("Curve name was not found"); + ErrorsFound = true; + } - int thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), DataGenerators::FuelCell, &DataGenerators::FCDataStruct::NameFCAirSup); + if (UtilityRoutines::SameString("RecoverBurnerInverterStorage", AlphArray(7))) { + DataGenerators::FuelCell(thisFuelCell).AirSup.IntakeRecoveryMode = DataGenerators::RecoverBurnInvertBatt; + } else if (UtilityRoutines::SameString("RecoverAuxiliaryBurner", AlphArray(7))) { + DataGenerators::FuelCell(thisFuelCell).AirSup.IntakeRecoveryMode = DataGenerators::RecoverAuxiliaryBurner; + } else if (UtilityRoutines::SameString("RecoverInverterandStorage", AlphArray(7))) { + DataGenerators::FuelCell(thisFuelCell).AirSup.IntakeRecoveryMode = DataGenerators::RecoverInverterBatt; + } else if (UtilityRoutines::SameString("RecoverInverter", AlphArray(7))) { + DataGenerators::FuelCell(thisFuelCell).AirSup.IntakeRecoveryMode = DataGenerators::RecoverInverter; + } else if (UtilityRoutines::SameString("RecoverElectricalStorage", AlphArray(7))) { + DataGenerators::FuelCell(thisFuelCell).AirSup.IntakeRecoveryMode = DataGenerators::RecoverBattery; + } else if (UtilityRoutines::SameString("NoRecovery", AlphArray(7))) { + DataGenerators::FuelCell(thisFuelCell).AirSup.IntakeRecoveryMode = DataGenerators::NoRecoveryOnAirIntake; + } else { + ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(7) + " = " + AlphArray(7)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); + ErrorsFound = true; + } - if (thisFuelCell > 0) { + if (UtilityRoutines::SameString("AmbientAir", AlphArray(8))) { + DataGenerators::FuelCell(thisFuelCell).AirSup.ConstituentMode = DataGenerators::RegularAir; + } else if (UtilityRoutines::SameString("UserDefinedConstituents", AlphArray(8))) { + DataGenerators::FuelCell(thisFuelCell).AirSup.ConstituentMode = DataGenerators::UserDefinedConstituents; + } else { + ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(8) + " = " + AlphArray(8)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); + ErrorsFound = true; + } - DataGenerators::FuelCell(thisFuelCell).AirSup.Name = AlphArray(1); - DataGenerators::FuelCell(thisFuelCell).AirSup.NodeName = AlphArray(2); + int NumAirConstit; - // check the node connections - DataGenerators::FuelCell(thisFuelCell).AirSup.SupNodeNum = NodeInputManager::GetOnlySingleNode( - AlphArray(2), ErrorsFound, DataIPShortCuts::cCurrentModuleObject, AlphArray(1), DataLoopNode::NodeType_Air, DataLoopNode::NodeConnectionType_Inlet, 1, DataLoopNode::ObjectIsNotParent); + if (DataGenerators::FuelCell(thisFuelCell).AirSup.ConstituentMode == DataGenerators::UserDefinedConstituents) { + NumAirConstit = NumArray(4); + DataGenerators::FuelCell(thisFuelCell).AirSup.NumConstituents = NumAirConstit; - DataGenerators::FuelCell(thisFuelCell).AirSup.BlowerPowerCurveID = CurveManager::GetCurveIndex(AlphArray(3)); - if (DataGenerators::FuelCell(thisFuelCell).AirSup.BlowerPowerCurveID == 0) { - ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(3) + " = " + AlphArray(3)); + if (NumAirConstit > 5) { + ShowSevereError("Invalid " + DataIPShortCuts::cNumericFieldNames(4) + '=' + General::RoundSigDigits(NumArray(4), 2)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); - ShowContinueError("Curve name was not found "); + ShowContinueError("Fuel Cell model not set up for more than 5 air constituents"); ErrorsFound = true; } - DataGenerators::FuelCell(thisFuelCell).AirSup.BlowerHeatLossFactor = NumArray(1); - - if (UtilityRoutines::SameString(AlphArray(4), "AirRatiobyStoics")) { - DataGenerators::FuelCell(thisFuelCell).AirSup.AirSupRateMode = DataGenerators::ConstantStoicsAirRat; - } else if (UtilityRoutines::SameString(AlphArray(4), "QuadraticFunctionofElectricPower")) { - DataGenerators::FuelCell(thisFuelCell).AirSup.AirSupRateMode = DataGenerators::QuadraticFuncofPel; - } else if (UtilityRoutines::SameString(AlphArray(4), "QUADRATIC FUNCTION OF FUEL RATE")) { - DataGenerators::FuelCell(thisFuelCell).AirSup.AirSupRateMode = DataGenerators::QuadraticFuncofNdot; - } else { - ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(4) + " = " + AlphArray(4)); - ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); - ErrorsFound = true; + + for (int ConstitNum = 1; ConstitNum <= NumAirConstit; ++ConstitNum) { + DataGenerators::FuelCell(thisFuelCell).AirSup.ConstitName(ConstitNum) = AlphArray(ConstitNum + 8); + DataGenerators::FuelCell(thisFuelCell).AirSup.ConstitMolalFract(ConstitNum) = NumArray(ConstitNum + 4); } - DataGenerators::FuelCell(thisFuelCell).AirSup.Stoics = NumArray(2) + 1.0; + } else { // regular air + NumAirConstit = 5; - DataGenerators::FuelCell(thisFuelCell).AirSup.AirFuncPelCurveID = CurveManager::GetCurveIndex(AlphArray(5)); - if ((DataGenerators::FuelCell(thisFuelCell).AirSup.AirFuncPelCurveID == 0) && - (DataGenerators::FuelCell(thisFuelCell).AirSup.AirSupRateMode == DataGenerators::QuadraticFuncofPel)) { - ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(5) + " = " + AlphArray(5)); - ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); - ShowSevereError("Curve name was not found"); - ErrorsFound = true; - } + DataGenerators::FuelCell(thisFuelCell).AirSup.NumConstituents = NumAirConstit; - DataGenerators::FuelCell(thisFuelCell).AirSup.AirTempCoeff = NumArray(3); + DataGenerators::FuelCell(thisFuelCell).AirSup.ConstitName(1) = "Nitrogen"; + DataGenerators::FuelCell(thisFuelCell).AirSup.ConstitMolalFract(1) = 0.7728; - DataGenerators::FuelCell(thisFuelCell).AirSup.AirFuncNdotCurveID = CurveManager::GetCurveIndex(AlphArray(6)); - if ((DataGenerators::FuelCell(thisFuelCell).AirSup.AirFuncNdotCurveID == 0) && - (DataGenerators::FuelCell(thisFuelCell).AirSup.AirSupRateMode == DataGenerators::QuadraticFuncofNdot)) { - ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(6) + " = " + AlphArray(6)); - ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); - ShowSevereError("Curve name was not found"); - ErrorsFound = true; - } + DataGenerators::FuelCell(thisFuelCell).AirSup.ConstitName(2) = "Oxygen"; + DataGenerators::FuelCell(thisFuelCell).AirSup.ConstitMolalFract(2) = 0.2073; - if (UtilityRoutines::SameString("RecoverBurnerInverterStorage", AlphArray(7))) { - DataGenerators::FuelCell(thisFuelCell).AirSup.IntakeRecoveryMode = DataGenerators::RecoverBurnInvertBatt; - } else if (UtilityRoutines::SameString("RecoverAuxiliaryBurner", AlphArray(7))) { - DataGenerators::FuelCell(thisFuelCell).AirSup.IntakeRecoveryMode = DataGenerators::RecoverAuxiliaryBurner; - } else if (UtilityRoutines::SameString("RecoverInverterandStorage", AlphArray(7))) { - DataGenerators::FuelCell(thisFuelCell).AirSup.IntakeRecoveryMode = DataGenerators::RecoverInverterBatt; - } else if (UtilityRoutines::SameString("RecoverInverter", AlphArray(7))) { - DataGenerators::FuelCell(thisFuelCell).AirSup.IntakeRecoveryMode = DataGenerators::RecoverInverter; - } else if (UtilityRoutines::SameString("RecoverElectricalStorage", AlphArray(7))) { - DataGenerators::FuelCell(thisFuelCell).AirSup.IntakeRecoveryMode = DataGenerators::RecoverBattery; - } else if (UtilityRoutines::SameString("NoRecovery", AlphArray(7))) { - DataGenerators::FuelCell(thisFuelCell).AirSup.IntakeRecoveryMode = DataGenerators::NoRecoveryOnAirIntake; - } else { - ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(7) + " = " + AlphArray(7)); - ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); - ErrorsFound = true; - } + DataGenerators::FuelCell(thisFuelCell).AirSup.ConstitName(3) = "Water"; + DataGenerators::FuelCell(thisFuelCell).AirSup.ConstitMolalFract(3) = 0.0104; - if (UtilityRoutines::SameString("AmbientAir", AlphArray(8))) { - DataGenerators::FuelCell(thisFuelCell).AirSup.ConstituentMode = DataGenerators::RegularAir; - } else if (UtilityRoutines::SameString("UserDefinedConstituents", AlphArray(8))) { - DataGenerators::FuelCell(thisFuelCell).AirSup.ConstituentMode = DataGenerators::UserDefinedConstituents; - } else { - ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(8) + " = " + AlphArray(8)); - ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); - ErrorsFound = true; - } + DataGenerators::FuelCell(thisFuelCell).AirSup.ConstitName(4) = "Argon"; + DataGenerators::FuelCell(thisFuelCell).AirSup.ConstitMolalFract(4) = 0.0092; - int NumAirConstit; + DataGenerators::FuelCell(thisFuelCell).AirSup.ConstitName(5) = "CarbonDioxide"; + DataGenerators::FuelCell(thisFuelCell).AirSup.ConstitMolalFract(5) = 0.0003; + } - if (DataGenerators::FuelCell(thisFuelCell).AirSup.ConstituentMode == DataGenerators::UserDefinedConstituents) { - NumAirConstit = NumArray(4); - DataGenerators::FuelCell(thisFuelCell).AirSup.NumConstituents = NumAirConstit; + // check for molar fractions summing to 1.0. + if (std::abs(sum(DataGenerators::FuelCell(thisFuelCell).AirSup.ConstitMolalFract) - 1.0) > 0.0001) { - if (NumAirConstit > 5) { - ShowSevereError("Invalid " + DataIPShortCuts::cNumericFieldNames(4) + '=' + General::RoundSigDigits(NumArray(4), 2)); - ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); - ShowContinueError("Fuel Cell model not set up for more than 5 air constituents"); - ErrorsFound = true; - } + ShowSevereError(DataIPShortCuts::cCurrentModuleObject + " molar fractions do not sum to 1.0"); + ShowContinueError("..Sum was=" + General::RoundSigDigits(sum(DataGenerators::FuelCell(thisFuelCell).AirSup.ConstitMolalFract), 1)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + " = " + AlphArray(1)); + ErrorsFound = true; + } - for (int ConstitNum = 1; ConstitNum <= NumAirConstit; ++ConstitNum) { - DataGenerators::FuelCell(thisFuelCell).AirSup.ConstitName(ConstitNum) = AlphArray(ConstitNum + 8); - DataGenerators::FuelCell(thisFuelCell).AirSup.ConstitMolalFract(ConstitNum) = NumArray(ConstitNum + 4); - } + // check for other FuelCell using the same Air Supply module and fill + for (int otherFuelCell = thisFuelCell + 1; otherFuelCell <= DataGenerators::NumFuelCellGenerators; ++otherFuelCell) { + if (UtilityRoutines::SameString(DataGenerators::FuelCell(otherFuelCell).AirSup.Name, DataGenerators::FuelCell(thisFuelCell).AirSup.Name)) { + DataGenerators::FuelCell(otherFuelCell).AirSup = DataGenerators::FuelCell(thisFuelCell).AirSup; + } + } + } else { + ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(1) + " = " + AlphArray(1)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); + ErrorsFound = true; + } + } - } else { // regular air - NumAirConstit = 5; + for (int GeneratorNum = 1; GeneratorNum <= DataGenerators::NumFuelCellGenerators; ++GeneratorNum) { + // find molal fraction of oxygen in air supply + int thisConstituent = + UtilityRoutines::FindItem("Oxygen", DataGenerators::FuelCell(GeneratorNum).AirSup.ConstitName, DataGenerators::FuelCell(GeneratorNum).AirSup.NumConstituents); + if (thisConstituent > 0) DataGenerators::FuelCell(GeneratorNum).AirSup.O2fraction = DataGenerators::FuelCell(GeneratorNum).AirSup.ConstitMolalFract(thisConstituent); - DataGenerators::FuelCell(thisFuelCell).AirSup.NumConstituents = NumAirConstit; + // Loop over air constituents and do one-time setup + for (int i = 1; i <= DataGenerators::FuelCell(GeneratorNum).AirSup.NumConstituents; ++i) { - DataGenerators::FuelCell(thisFuelCell).AirSup.ConstitName(1) = "Nitrogen"; - DataGenerators::FuelCell(thisFuelCell).AirSup.ConstitMolalFract(1) = 0.7728; + std::string thisName = DataGenerators::FuelCell(GeneratorNum).AirSup.ConstitName(i); - DataGenerators::FuelCell(thisFuelCell).AirSup.ConstitName(2) = "Oxygen"; - DataGenerators::FuelCell(thisFuelCell).AirSup.ConstitMolalFract(2) = 0.2073; + int thisGasID = UtilityRoutines::FindItem(thisName, DataGenerators::GasPhaseThermoChemistryData, &DataGenerators::GasPropertyDataStruct::ConstituentName); - DataGenerators::FuelCell(thisFuelCell).AirSup.ConstitName(3) = "Water"; - DataGenerators::FuelCell(thisFuelCell).AirSup.ConstitMolalFract(3) = 0.0104; + DataGenerators::FuelCell(GeneratorNum).AirSup.GasLibID(i) = thisGasID; + } - DataGenerators::FuelCell(thisFuelCell).AirSup.ConstitName(4) = "Argon"; - DataGenerators::FuelCell(thisFuelCell).AirSup.ConstitMolalFract(4) = 0.0092; + // set up gas constiuents for product gases + DataGenerators::FuelCell(GeneratorNum).FCPM.GasLibID(1) = 1; // Carbon Dioxide + DataGenerators::FuelCell(GeneratorNum).FCPM.GasLibID(2) = 2; // Nitrogen + DataGenerators::FuelCell(GeneratorNum).FCPM.GasLibID(3) = 3; // Oxygen + DataGenerators::FuelCell(GeneratorNum).FCPM.GasLibID(4) = 4; // Water + DataGenerators::FuelCell(GeneratorNum).FCPM.GasLibID(5) = 5; // Argon + } - DataGenerators::FuelCell(thisFuelCell).AirSup.ConstitName(5) = "CarbonDioxide"; - DataGenerators::FuelCell(thisFuelCell).AirSup.ConstitMolalFract(5) = 0.0003; - } + DataIPShortCuts::cCurrentModuleObject = "Generator:FuelCell:WaterSupply"; + int NumFCWaterSups = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); - // check for molar fractions summing to 1.0. - if (std::abs(sum(DataGenerators::FuelCell(thisFuelCell).AirSup.ConstitMolalFract) - 1.0) > 0.0001) { + if (NumFCWaterSups <= 0) { + ShowSevereError("No " + DataIPShortCuts::cCurrentModuleObject + " equipment specified in input file"); + ErrorsFound = true; + } - ShowSevereError(DataIPShortCuts::cCurrentModuleObject + " molar fractions do not sum to 1.0"); - ShowContinueError("..Sum was=" + General::RoundSigDigits(sum(DataGenerators::FuelCell(thisFuelCell).AirSup.ConstitMolalFract), 1)); - ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + " = " + AlphArray(1)); - ErrorsFound = true; - } + for (int FCWaterSupNum = 1; FCWaterSupNum <= NumFCWaterSups; ++FCWaterSupNum) { + inputProcessor->getObjectItem( + DataIPShortCuts::cCurrentModuleObject, FCWaterSupNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat, _, _, DataIPShortCuts::cAlphaFieldNames, DataIPShortCuts::cNumericFieldNames); + UtilityRoutines::IsNameEmpty(AlphArray(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); - // check for other FuelCell using the same Air Supply module and fill - for (int otherFuelCell = thisFuelCell + 1; otherFuelCell <= DataGenerators::NumFuelCellGenerators; ++otherFuelCell) { - if (UtilityRoutines::SameString(DataGenerators::FuelCell(otherFuelCell).AirSup.Name, DataGenerators::FuelCell(thisFuelCell).AirSup.Name)) { - DataGenerators::FuelCell(otherFuelCell).AirSup = DataGenerators::FuelCell(thisFuelCell).AirSup; - } - } + int thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), DataGenerators::FuelCell, &DataGenerators::FCDataStruct::NameFCWaterSup); + + if (thisFuelCell > 0) { + // this is only the first instance of a FuelCell generator using this type of Water supply module + DataGenerators::FuelCell(thisFuelCell).WaterSup.Name = AlphArray(1); + DataGenerators::FuelCell(thisFuelCell).WaterSup.WaterSupRateCurveID = CurveManager::GetCurveIndex(AlphArray(2)); + if (DataGenerators::FuelCell(thisFuelCell).WaterSup.WaterSupRateCurveID == 0) { + ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(2) + " = " + AlphArray(2)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); + ShowContinueError("Curve name was not found "); + ErrorsFound = true; + } + DataGenerators::FuelCell(thisFuelCell).WaterSup.PmpPowerCurveID = CurveManager::GetCurveIndex(AlphArray(3)); + if (DataGenerators::FuelCell(thisFuelCell).WaterSup.PmpPowerCurveID == 0) { + ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(3) + " = " + AlphArray(3)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); + ShowContinueError("Curve name was not found "); + ErrorsFound = true; + } + DataGenerators::FuelCell(thisFuelCell).WaterSup.PmpPowerLossFactor = NumArray(1); + + if (UtilityRoutines::SameString("TemperatureFromAirNode", AlphArray(4))) { + DataGenerators::FuelCell(thisFuelCell).WaterSup.WaterTempMode = DataGenerators::WaterInReformAirNode; + + DataGenerators::FuelCell(thisFuelCell).WaterSup.NodeName = AlphArray(5); + DataGenerators::FuelCell(thisFuelCell).WaterSup.NodeNum = NodeInputManager::GetOnlySingleNode(AlphArray(5), + ErrorsFound, + DataIPShortCuts::cCurrentModuleObject, + AlphArray(1), + DataLoopNode::NodeType_Air, + DataLoopNode::NodeConnectionType_Sensor, + 1, + DataLoopNode::ObjectIsNotParent); + + } else if (UtilityRoutines::SameString("TemperatureFromWaterNode", AlphArray(4))) { + DataGenerators::FuelCell(thisFuelCell).WaterSup.WaterTempMode = DataGenerators::WaterInReformWaterNode; + + DataGenerators::FuelCell(thisFuelCell).WaterSup.NodeName = AlphArray(5); + DataGenerators::FuelCell(thisFuelCell).WaterSup.NodeNum = NodeInputManager::GetOnlySingleNode(AlphArray(5), + ErrorsFound, + DataIPShortCuts::cCurrentModuleObject, + AlphArray(1), + DataLoopNode::NodeType_Water, + DataLoopNode::NodeConnectionType_Sensor, + 1, + DataLoopNode::ObjectIsNotParent); + + } else if (UtilityRoutines::SameString("MainsWaterTemperature", AlphArray(4))) { + DataGenerators::FuelCell(thisFuelCell).WaterSup.WaterTempMode = DataGenerators::WaterInReformMains; + + } else if (UtilityRoutines::SameString("TemperatureFromSchedule", AlphArray(4))) { + DataGenerators::FuelCell(thisFuelCell).WaterSup.WaterTempMode = DataGenerators::WaterInReformSchedule; } else { - ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(1) + " = " + AlphArray(1)); + ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(4) + " = " + AlphArray(4)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } - } - - for (int GeneratorNum = 1; GeneratorNum <= DataGenerators::NumFuelCellGenerators; ++GeneratorNum) { - // find molal fraction of oxygen in air supply - int thisConstituent = - UtilityRoutines::FindItem("Oxygen", DataGenerators::FuelCell(GeneratorNum).AirSup.ConstitName, DataGenerators::FuelCell(GeneratorNum).AirSup.NumConstituents); - if (thisConstituent > 0) DataGenerators::FuelCell(GeneratorNum).AirSup.O2fraction = DataGenerators::FuelCell(GeneratorNum).AirSup.ConstitMolalFract(thisConstituent); - - // Loop over air constituents and do one-time setup - for (int i = 1; i <= DataGenerators::FuelCell(GeneratorNum).AirSup.NumConstituents; ++i) { - - std::string thisName = DataGenerators::FuelCell(GeneratorNum).AirSup.ConstitName(i); - int thisGasID = UtilityRoutines::FindItem(thisName, DataGenerators::GasPhaseThermoChemistryData, &DataGenerators::GasPropertyDataStruct::ConstituentName); - - DataGenerators::FuelCell(GeneratorNum).AirSup.GasLibID(i) = thisGasID; + DataGenerators::FuelCell(thisFuelCell).WaterSup.SchedNum = ScheduleManager::GetScheduleIndex(AlphArray(6)); + if ((DataGenerators::FuelCell(thisFuelCell).WaterSup.SchedNum == 0) && (DataGenerators::FuelCell(thisFuelCell).WaterSup.WaterTempMode == DataGenerators::WaterInReformSchedule)) { + ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(6) + " = " + AlphArray(6)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); + ShowContinueError("Schedule was not found"); + ErrorsFound = true; } - // set up gas constiuents for product gases - DataGenerators::FuelCell(GeneratorNum).FCPM.GasLibID(1) = 1; // Carbon Dioxide - DataGenerators::FuelCell(GeneratorNum).FCPM.GasLibID(2) = 2; // Nitrogen - DataGenerators::FuelCell(GeneratorNum).FCPM.GasLibID(3) = 3; // Oxygen - DataGenerators::FuelCell(GeneratorNum).FCPM.GasLibID(4) = 4; // Water - DataGenerators::FuelCell(GeneratorNum).FCPM.GasLibID(5) = 5; // Argon + // check for other FuelCell using the same Water Supply module and fill + for (int otherFuelCell = thisFuelCell + 1; otherFuelCell <= DataGenerators::NumFuelCellGenerators; ++otherFuelCell) { + if (UtilityRoutines::SameString(DataGenerators::FuelCell(otherFuelCell).WaterSup.Name, DataGenerators::FuelCell(thisFuelCell).WaterSup.Name)) { + DataGenerators::FuelCell(otherFuelCell).WaterSup = DataGenerators::FuelCell(thisFuelCell).WaterSup; + } + } + } else { + ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(1) + " = " + AlphArray(1)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); + ErrorsFound = true; } + } - DataIPShortCuts::cCurrentModuleObject = "Generator:FuelCell:WaterSupply"; - int NumFCWaterSups = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); + DataIPShortCuts::cCurrentModuleObject = "Generator:FuelCell:AuxiliaryHeater"; + int NumFuelCellAuxilHeaters = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); - if (NumFCWaterSups <= 0) { - ShowSevereError("No " + DataIPShortCuts::cCurrentModuleObject + " equipment specified in input file"); - ErrorsFound = true; - } + if (NumFuelCellAuxilHeaters <= 0) { + ShowSevereError("No " + DataIPShortCuts::cCurrentModuleObject + " equipment specified in input file"); + ErrorsFound = true; + } - for (int FCWaterSupNum = 1; FCWaterSupNum <= NumFCWaterSups; ++FCWaterSupNum) { - inputProcessor->getObjectItem( - DataIPShortCuts::cCurrentModuleObject, FCWaterSupNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat, _, _, DataIPShortCuts::cAlphaFieldNames, DataIPShortCuts::cNumericFieldNames); - UtilityRoutines::IsNameEmpty(AlphArray(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); + for (int FCAuxHeatNum = 1; FCAuxHeatNum <= NumFuelCellAuxilHeaters; ++FCAuxHeatNum) { + inputProcessor->getObjectItem( + DataIPShortCuts::cCurrentModuleObject, FCAuxHeatNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat, _, _, DataIPShortCuts::cAlphaFieldNames, DataIPShortCuts::cNumericFieldNames); + UtilityRoutines::IsNameEmpty(AlphArray(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); - int thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), DataGenerators::FuelCell, &DataGenerators::FCDataStruct::NameFCWaterSup); + int thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), DataGenerators::FuelCell, &DataGenerators::FCDataStruct::NameFCAuxilHeat); - if (thisFuelCell > 0) { - // this is only the first instance of a FuelCell generator using this type of Water supply module - DataGenerators::FuelCell(thisFuelCell).WaterSup.Name = AlphArray(1); - DataGenerators::FuelCell(thisFuelCell).WaterSup.WaterSupRateCurveID = CurveManager::GetCurveIndex(AlphArray(2)); - if (DataGenerators::FuelCell(thisFuelCell).WaterSup.WaterSupRateCurveID == 0) { - ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(2) + " = " + AlphArray(2)); - ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); - ShowContinueError("Curve name was not found "); - ErrorsFound = true; - } - DataGenerators::FuelCell(thisFuelCell).WaterSup.PmpPowerCurveID = CurveManager::GetCurveIndex(AlphArray(3)); - if (DataGenerators::FuelCell(thisFuelCell).WaterSup.PmpPowerCurveID == 0) { - ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(3) + " = " + AlphArray(3)); - ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); - ShowContinueError("Curve name was not found "); - ErrorsFound = true; - } - DataGenerators::FuelCell(thisFuelCell).WaterSup.PmpPowerLossFactor = NumArray(1); - - if (UtilityRoutines::SameString("TemperatureFromAirNode", AlphArray(4))) { - DataGenerators::FuelCell(thisFuelCell).WaterSup.WaterTempMode = DataGenerators::WaterInReformAirNode; - - DataGenerators::FuelCell(thisFuelCell).WaterSup.NodeName = AlphArray(5); - DataGenerators::FuelCell(thisFuelCell).WaterSup.NodeNum = NodeInputManager::GetOnlySingleNode(AlphArray(5), - ErrorsFound, - DataIPShortCuts::cCurrentModuleObject, - AlphArray(1), - DataLoopNode::NodeType_Air, - DataLoopNode::NodeConnectionType_Sensor, - 1, - DataLoopNode::ObjectIsNotParent); - - } else if (UtilityRoutines::SameString("TemperatureFromWaterNode", AlphArray(4))) { - DataGenerators::FuelCell(thisFuelCell).WaterSup.WaterTempMode = DataGenerators::WaterInReformWaterNode; - - DataGenerators::FuelCell(thisFuelCell).WaterSup.NodeName = AlphArray(5); - DataGenerators::FuelCell(thisFuelCell).WaterSup.NodeNum = NodeInputManager::GetOnlySingleNode(AlphArray(5), - ErrorsFound, - DataIPShortCuts::cCurrentModuleObject, - AlphArray(1), - DataLoopNode::NodeType_Water, - DataLoopNode::NodeConnectionType_Sensor, - 1, - DataLoopNode::ObjectIsNotParent); - - } else if (UtilityRoutines::SameString("MainsWaterTemperature", AlphArray(4))) { - DataGenerators::FuelCell(thisFuelCell).WaterSup.WaterTempMode = DataGenerators::WaterInReformMains; - - } else if (UtilityRoutines::SameString("TemperatureFromSchedule", AlphArray(4))) { - DataGenerators::FuelCell(thisFuelCell).WaterSup.WaterTempMode = DataGenerators::WaterInReformSchedule; - } else { - ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(4) + " = " + AlphArray(4)); - ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); - ErrorsFound = true; - } + if (thisFuelCell > 0) { + DataGenerators::FuelCell(thisFuelCell).AuxilHeat.Name = AlphArray(1); - DataGenerators::FuelCell(thisFuelCell).WaterSup.SchedNum = ScheduleManager::GetScheduleIndex(AlphArray(6)); - if ((DataGenerators::FuelCell(thisFuelCell).WaterSup.SchedNum == 0) && (DataGenerators::FuelCell(thisFuelCell).WaterSup.WaterTempMode == DataGenerators::WaterInReformSchedule)) { - ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(6) + " = " + AlphArray(6)); - ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); - ShowContinueError("Schedule was not found"); - ErrorsFound = true; - } + DataGenerators::FuelCell(thisFuelCell).AuxilHeat.ExcessAirRAT = NumArray(1); + DataGenerators::FuelCell(thisFuelCell).AuxilHeat.ANC0 = NumArray(2); + DataGenerators::FuelCell(thisFuelCell).AuxilHeat.ANC1 = NumArray(3); + DataGenerators::FuelCell(thisFuelCell).AuxilHeat.UASkin = NumArray(4); - // check for other FuelCell using the same Water Supply module and fill - for (int otherFuelCell = thisFuelCell + 1; otherFuelCell <= DataGenerators::NumFuelCellGenerators; ++otherFuelCell) { - if (UtilityRoutines::SameString(DataGenerators::FuelCell(otherFuelCell).WaterSup.Name, DataGenerators::FuelCell(thisFuelCell).WaterSup.Name)) { - DataGenerators::FuelCell(otherFuelCell).WaterSup = DataGenerators::FuelCell(thisFuelCell).WaterSup; - } - } + if (UtilityRoutines::SameString("SurroundingZone", AlphArray(2))) { + DataGenerators::FuelCell(thisFuelCell).AuxilHeat.SkinLossDestination = DataGenerators::SurroundingZone; + } else if (UtilityRoutines::SameString("AirInletForFuelCell", AlphArray(2))) { + DataGenerators::FuelCell(thisFuelCell).AuxilHeat.SkinLossDestination = DataGenerators::AirInletForFC; } else { - ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(1) + " = " + AlphArray(1)); + ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(2) + " = " + AlphArray(2)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } - } - DataIPShortCuts::cCurrentModuleObject = "Generator:FuelCell:AuxiliaryHeater"; - int NumFuelCellAuxilHeaters = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); - - if (NumFuelCellAuxilHeaters <= 0) { - ShowSevereError("No " + DataIPShortCuts::cCurrentModuleObject + " equipment specified in input file"); - ErrorsFound = true; - } - - for (int FCAuxHeatNum = 1; FCAuxHeatNum <= NumFuelCellAuxilHeaters; ++FCAuxHeatNum) { - inputProcessor->getObjectItem( - DataIPShortCuts::cCurrentModuleObject, FCAuxHeatNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat, _, _, DataIPShortCuts::cAlphaFieldNames, DataIPShortCuts::cNumericFieldNames); - UtilityRoutines::IsNameEmpty(AlphArray(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); - - int thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), DataGenerators::FuelCell, &DataGenerators::FCDataStruct::NameFCAuxilHeat); - - if (thisFuelCell > 0) { - DataGenerators::FuelCell(thisFuelCell).AuxilHeat.Name = AlphArray(1); - - DataGenerators::FuelCell(thisFuelCell).AuxilHeat.ExcessAirRAT = NumArray(1); - DataGenerators::FuelCell(thisFuelCell).AuxilHeat.ANC0 = NumArray(2); - DataGenerators::FuelCell(thisFuelCell).AuxilHeat.ANC1 = NumArray(3); - DataGenerators::FuelCell(thisFuelCell).AuxilHeat.UASkin = NumArray(4); + DataGenerators::FuelCell(thisFuelCell).AuxilHeat.ZoneName = AlphArray(3); + DataGenerators::FuelCell(thisFuelCell).AuxilHeat.ZoneID = UtilityRoutines::FindItemInList(AlphArray(3), DataHeatBalance::Zone); + if ((DataGenerators::FuelCell(thisFuelCell).AuxilHeat.ZoneID == 0) && (DataGenerators::FuelCell(thisFuelCell).AuxilHeat.SkinLossDestination == DataGenerators::SurroundingZone)) { + ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(3) + " = " + AlphArray(3)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); + ShowContinueError("Zone name was not found "); + ErrorsFound = true; + } + DataGenerators::FuelCell(thisFuelCell).AuxilHeat.MaxPowerW = NumArray(5); + DataGenerators::FuelCell(thisFuelCell).AuxilHeat.MinPowerW = NumArray(6); + DataGenerators::FuelCell(thisFuelCell).AuxilHeat.MaxPowerkmolperSec = NumArray(7); + DataGenerators::FuelCell(thisFuelCell).AuxilHeat.MinPowerkmolperSec = NumArray(8); - if (UtilityRoutines::SameString("SurroundingZone", AlphArray(2))) { - DataGenerators::FuelCell(thisFuelCell).AuxilHeat.SkinLossDestination = DataGenerators::SurroundingZone; - } else if (UtilityRoutines::SameString("AirInletForFuelCell", AlphArray(2))) { - DataGenerators::FuelCell(thisFuelCell).AuxilHeat.SkinLossDestination = DataGenerators::AirInletForFC; - } else { - ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(2) + " = " + AlphArray(2)); - ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); - ErrorsFound = true; - } + // TODO finish Auxiliary heater - DataGenerators::FuelCell(thisFuelCell).AuxilHeat.ZoneName = AlphArray(3); - DataGenerators::FuelCell(thisFuelCell).AuxilHeat.ZoneID = UtilityRoutines::FindItemInList(AlphArray(3), DataHeatBalance::Zone); - if ((DataGenerators::FuelCell(thisFuelCell).AuxilHeat.ZoneID == 0) && (DataGenerators::FuelCell(thisFuelCell).AuxilHeat.SkinLossDestination == DataGenerators::SurroundingZone)) { - ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(3) + " = " + AlphArray(3)); - ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); - ShowContinueError("Zone name was not found "); - ErrorsFound = true; + // check for other FuelCell using the same Auxiliary Heating module and fill + for (int otherFuelCell = thisFuelCell + 1; otherFuelCell <= DataGenerators::NumFuelCellGenerators; ++otherFuelCell) { + if (UtilityRoutines::SameString(DataGenerators::FuelCell(otherFuelCell).AuxilHeat.Name, DataGenerators::FuelCell(thisFuelCell).AuxilHeat.Name)) { + DataGenerators::FuelCell(otherFuelCell).AuxilHeat = DataGenerators::FuelCell(thisFuelCell).AuxilHeat; } - DataGenerators::FuelCell(thisFuelCell).AuxilHeat.MaxPowerW = NumArray(5); - DataGenerators::FuelCell(thisFuelCell).AuxilHeat.MinPowerW = NumArray(6); - DataGenerators::FuelCell(thisFuelCell).AuxilHeat.MaxPowerkmolperSec = NumArray(7); - DataGenerators::FuelCell(thisFuelCell).AuxilHeat.MinPowerkmolperSec = NumArray(8); + } + } else { + ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(1) + " = " + AlphArray(1)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); + ErrorsFound = true; + } + } - // TODO finish Auxiliary heater + // exhaust gas heat exchanger + DataIPShortCuts::cCurrentModuleObject = "Generator:FuelCell:ExhaustGasToWaterHeatExchanger"; + int NumFCExhaustGasHXs = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); + if (NumFCExhaustGasHXs <= 0) { + ShowWarningError("No " + DataIPShortCuts::cCurrentModuleObject + " equipment specified in input file"); + ShowContinueError("Fuel Cell model requires an " + DataIPShortCuts::cCurrentModuleObject + " object"); + ErrorsFound = true; + } - // check for other FuelCell using the same Auxiliary Heating module and fill - for (int otherFuelCell = thisFuelCell + 1; otherFuelCell <= DataGenerators::NumFuelCellGenerators; ++otherFuelCell) { - if (UtilityRoutines::SameString(DataGenerators::FuelCell(otherFuelCell).AuxilHeat.Name, DataGenerators::FuelCell(thisFuelCell).AuxilHeat.Name)) { - DataGenerators::FuelCell(otherFuelCell).AuxilHeat = DataGenerators::FuelCell(thisFuelCell).AuxilHeat; - } - } + for (int FCHXNum = 1; FCHXNum <= NumFCExhaustGasHXs; ++FCHXNum) { + inputProcessor->getObjectItem( + DataIPShortCuts::cCurrentModuleObject, FCHXNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat, _, _, DataIPShortCuts::cAlphaFieldNames, DataIPShortCuts::cNumericFieldNames); + UtilityRoutines::IsNameEmpty(AlphArray(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); + + int thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), DataGenerators::FuelCell, &DataGenerators::FCDataStruct::NameExhaustHX); + + if (thisFuelCell > 0) { + DataGenerators::FuelCell(thisFuelCell).ExhaustHX.Name = AlphArray(1); + DataGenerators::FuelCell(thisFuelCell).ExhaustHX.WaterInNodeName = AlphArray(2); + DataGenerators::FuelCell(thisFuelCell).ExhaustHX.WaterOutNodeName = AlphArray(3); + // find node ids for water path + DataGenerators::FuelCell(thisFuelCell).ExhaustHX.WaterInNode = NodeInputManager::GetOnlySingleNode(AlphArray(2), + ErrorsFound, + DataIPShortCuts::cCurrentModuleObject, + AlphArray(1), + DataLoopNode::NodeType_Water, + DataLoopNode::NodeConnectionType_Inlet, + 1, + DataLoopNode::ObjectIsNotParent); + DataGenerators::FuelCell(thisFuelCell).ExhaustHX.WaterOutNode = NodeInputManager::GetOnlySingleNode(AlphArray(3), + ErrorsFound, + DataIPShortCuts::cCurrentModuleObject, + AlphArray(1), + DataLoopNode::NodeType_Water, + DataLoopNode::NodeConnectionType_Outlet, + 1, + DataLoopNode::ObjectIsNotParent); + BranchNodeConnections::TestCompSet(DataIPShortCuts::cCurrentModuleObject, AlphArray(1), AlphArray(2), AlphArray(3), "Heat Recovery Nodes"); + + DataGenerators::FuelCell(thisFuelCell).ExhaustHX.ExhaustOutNodeName = AlphArray(4); + DataGenerators::FuelCell(thisFuelCell).ExhaustHX.ExhaustOutNode = NodeInputManager::GetOnlySingleNode( + AlphArray(4), ErrorsFound, DataIPShortCuts::cCurrentModuleObject, AlphArray(1), DataLoopNode::NodeType_Air, DataLoopNode::NodeConnectionType_Outlet, 2, DataLoopNode::ObjectIsNotParent); + + if (UtilityRoutines::SameString("FixedEffectiveness", AlphArray(5))) { + DataGenerators::FuelCell(thisFuelCell).ExhaustHX.HXmodelMode = DataGenerators::FixedEffectiveness; + } else if (UtilityRoutines::SameString("EmpiricalUAeff", AlphArray(5))) { + DataGenerators::FuelCell(thisFuelCell).ExhaustHX.HXmodelMode = DataGenerators::LMTDempiricalUAeff; + } else if (UtilityRoutines::SameString("FundementalUAeff", AlphArray(5))) { + DataGenerators::FuelCell(thisFuelCell).ExhaustHX.HXmodelMode = DataGenerators::LMTDfundementalUAeff; + } else if (UtilityRoutines::SameString("CONDENSING", AlphArray(5))) { + DataGenerators::FuelCell(thisFuelCell).ExhaustHX.HXmodelMode = DataGenerators::Condensing; } else { - ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(1) + " = " + AlphArray(1)); + ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(5) + " = " + AlphArray(5)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } - } - - // exhaust gas heat exchanger - DataIPShortCuts::cCurrentModuleObject = "Generator:FuelCell:ExhaustGasToWaterHeatExchanger"; - int NumFCExhaustGasHXs = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); - if (NumFCExhaustGasHXs <= 0) { - ShowWarningError("No " + DataIPShortCuts::cCurrentModuleObject + " equipment specified in input file"); - ShowContinueError("Fuel Cell model requires an " + DataIPShortCuts::cCurrentModuleObject + " object"); + DataGenerators::FuelCell(thisFuelCell).ExhaustHX.WaterVolumeFlowMax = NumArray(1); + DataGenerators::FuelCell(thisFuelCell).ExhaustHX.HXEffect = NumArray(2); + DataGenerators::FuelCell(thisFuelCell).ExhaustHX.hxs0 = NumArray(3); + DataGenerators::FuelCell(thisFuelCell).ExhaustHX.hxs1 = NumArray(4); + DataGenerators::FuelCell(thisFuelCell).ExhaustHX.hxs2 = NumArray(5); + DataGenerators::FuelCell(thisFuelCell).ExhaustHX.hxs3 = NumArray(6); + DataGenerators::FuelCell(thisFuelCell).ExhaustHX.hxs4 = NumArray(7); + DataGenerators::FuelCell(thisFuelCell).ExhaustHX.h0gas = NumArray(8); + DataGenerators::FuelCell(thisFuelCell).ExhaustHX.NdotGasRef = NumArray(9); + DataGenerators::FuelCell(thisFuelCell).ExhaustHX.nCoeff = NumArray(10); + DataGenerators::FuelCell(thisFuelCell).ExhaustHX.AreaGas = NumArray(11); + DataGenerators::FuelCell(thisFuelCell).ExhaustHX.h0Water = NumArray(12); + DataGenerators::FuelCell(thisFuelCell).ExhaustHX.NdotWaterRef = NumArray(13); + DataGenerators::FuelCell(thisFuelCell).ExhaustHX.mCoeff = NumArray(14); + DataGenerators::FuelCell(thisFuelCell).ExhaustHX.AreaWater = NumArray(15); + DataGenerators::FuelCell(thisFuelCell).ExhaustHX.Fadjust = NumArray(16); + DataGenerators::FuelCell(thisFuelCell).ExhaustHX.l1Coeff = NumArray(17); + DataGenerators::FuelCell(thisFuelCell).ExhaustHX.l2Coeff = NumArray(18); + DataGenerators::FuelCell(thisFuelCell).ExhaustHX.CondensationThresholdTemp = NumArray(19); + + // store cooling water volume flow rate for autosizing system + PlantUtilities::RegisterPlantCompDesignFlow(DataGenerators::FuelCell(thisFuelCell).ExhaustHX.WaterInNode, DataGenerators::FuelCell(thisFuelCell).ExhaustHX.WaterVolumeFlowMax); + } else { + ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(1) + " = " + AlphArray(1)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } + } - for (int FCHXNum = 1; FCHXNum <= NumFCExhaustGasHXs; ++FCHXNum) { - inputProcessor->getObjectItem( - DataIPShortCuts::cCurrentModuleObject, FCHXNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat, _, _, DataIPShortCuts::cAlphaFieldNames, DataIPShortCuts::cNumericFieldNames); - UtilityRoutines::IsNameEmpty(AlphArray(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); + DataIPShortCuts::cCurrentModuleObject = "Generator:FuelCell:ElectricalStorage"; + int NumFCElecStorageUnits = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); - int thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), DataGenerators::FuelCell, &DataGenerators::FCDataStruct::NameExhaustHX); + if (NumFCElecStorageUnits <= 0) { + ShowWarningError("No " + DataIPShortCuts::cCurrentModuleObject + " equipment specified in input file"); + ShowContinueError("Fuel Cell model requires an " + DataIPShortCuts::cCurrentModuleObject + " object"); + ErrorsFound = true; + } - if (thisFuelCell > 0) { - DataGenerators::FuelCell(thisFuelCell).ExhaustHX.Name = AlphArray(1); - DataGenerators::FuelCell(thisFuelCell).ExhaustHX.WaterInNodeName = AlphArray(2); - DataGenerators::FuelCell(thisFuelCell).ExhaustHX.WaterOutNodeName = AlphArray(3); - // find node ids for water path - DataGenerators::FuelCell(thisFuelCell).ExhaustHX.WaterInNode = NodeInputManager::GetOnlySingleNode(AlphArray(2), - ErrorsFound, - DataIPShortCuts::cCurrentModuleObject, - AlphArray(1), - DataLoopNode::NodeType_Water, - DataLoopNode::NodeConnectionType_Inlet, - 1, - DataLoopNode::ObjectIsNotParent); - DataGenerators::FuelCell(thisFuelCell).ExhaustHX.WaterOutNode = NodeInputManager::GetOnlySingleNode(AlphArray(3), - ErrorsFound, - DataIPShortCuts::cCurrentModuleObject, - AlphArray(1), - DataLoopNode::NodeType_Water, - DataLoopNode::NodeConnectionType_Outlet, - 1, - DataLoopNode::ObjectIsNotParent); - BranchNodeConnections::TestCompSet(DataIPShortCuts::cCurrentModuleObject, AlphArray(1), AlphArray(2), AlphArray(3), "Heat Recovery Nodes"); + for (int StorageNum = 1; StorageNum <= NumFCElecStorageUnits; ++StorageNum) { + inputProcessor->getObjectItem( + DataIPShortCuts::cCurrentModuleObject, StorageNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat, _, _, DataIPShortCuts::cAlphaFieldNames, DataIPShortCuts::cNumericFieldNames); + UtilityRoutines::IsNameEmpty(AlphArray(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); - DataGenerators::FuelCell(thisFuelCell).ExhaustHX.ExhaustOutNodeName = AlphArray(4); - DataGenerators::FuelCell(thisFuelCell).ExhaustHX.ExhaustOutNode = NodeInputManager::GetOnlySingleNode( - AlphArray(4), ErrorsFound, DataIPShortCuts::cCurrentModuleObject, AlphArray(1), DataLoopNode::NodeType_Air, DataLoopNode::NodeConnectionType_Outlet, 2, DataLoopNode::ObjectIsNotParent); - - if (UtilityRoutines::SameString("FixedEffectiveness", AlphArray(5))) { - DataGenerators::FuelCell(thisFuelCell).ExhaustHX.HXmodelMode = DataGenerators::FixedEffectiveness; - } else if (UtilityRoutines::SameString("EmpiricalUAeff", AlphArray(5))) { - DataGenerators::FuelCell(thisFuelCell).ExhaustHX.HXmodelMode = DataGenerators::LMTDempiricalUAeff; - } else if (UtilityRoutines::SameString("FundementalUAeff", AlphArray(5))) { - DataGenerators::FuelCell(thisFuelCell).ExhaustHX.HXmodelMode = DataGenerators::LMTDfundementalUAeff; - } else if (UtilityRoutines::SameString("CONDENSING", AlphArray(5))) { - DataGenerators::FuelCell(thisFuelCell).ExhaustHX.HXmodelMode = DataGenerators::Condensing; - } else { - ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(5) + " = " + AlphArray(5)); - ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); - ErrorsFound = true; - } - DataGenerators::FuelCell(thisFuelCell).ExhaustHX.WaterVolumeFlowMax = NumArray(1); - DataGenerators::FuelCell(thisFuelCell).ExhaustHX.HXEffect = NumArray(2); - DataGenerators::FuelCell(thisFuelCell).ExhaustHX.hxs0 = NumArray(3); - DataGenerators::FuelCell(thisFuelCell).ExhaustHX.hxs1 = NumArray(4); - DataGenerators::FuelCell(thisFuelCell).ExhaustHX.hxs2 = NumArray(5); - DataGenerators::FuelCell(thisFuelCell).ExhaustHX.hxs3 = NumArray(6); - DataGenerators::FuelCell(thisFuelCell).ExhaustHX.hxs4 = NumArray(7); - DataGenerators::FuelCell(thisFuelCell).ExhaustHX.h0gas = NumArray(8); - DataGenerators::FuelCell(thisFuelCell).ExhaustHX.NdotGasRef = NumArray(9); - DataGenerators::FuelCell(thisFuelCell).ExhaustHX.nCoeff = NumArray(10); - DataGenerators::FuelCell(thisFuelCell).ExhaustHX.AreaGas = NumArray(11); - DataGenerators::FuelCell(thisFuelCell).ExhaustHX.h0Water = NumArray(12); - DataGenerators::FuelCell(thisFuelCell).ExhaustHX.NdotWaterRef = NumArray(13); - DataGenerators::FuelCell(thisFuelCell).ExhaustHX.mCoeff = NumArray(14); - DataGenerators::FuelCell(thisFuelCell).ExhaustHX.AreaWater = NumArray(15); - DataGenerators::FuelCell(thisFuelCell).ExhaustHX.Fadjust = NumArray(16); - DataGenerators::FuelCell(thisFuelCell).ExhaustHX.l1Coeff = NumArray(17); - DataGenerators::FuelCell(thisFuelCell).ExhaustHX.l2Coeff = NumArray(18); - DataGenerators::FuelCell(thisFuelCell).ExhaustHX.CondensationThresholdTemp = NumArray(19); - - // store cooling water volume flow rate for autosizing system - PlantUtilities::RegisterPlantCompDesignFlow(DataGenerators::FuelCell(thisFuelCell).ExhaustHX.WaterInNode, DataGenerators::FuelCell(thisFuelCell).ExhaustHX.WaterVolumeFlowMax); + int thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), DataGenerators::FuelCell, &DataGenerators::FCDataStruct::NameElecStorage); + + if (thisFuelCell > 0) { + DataGenerators::FuelCell(thisFuelCell).ElecStorage.Name = AlphArray(1); + + if (UtilityRoutines::SameString(AlphArray(2), "SimpleEfficiencyWithConstraints")) { + DataGenerators::FuelCell(thisFuelCell).ElecStorage.StorageModelMode = DataGenerators::SimpleEffConstraints; } else { - ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(1) + " = " + AlphArray(1)); + ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(2) + " = " + AlphArray(2)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } + DataGenerators::FuelCell(thisFuelCell).ElecStorage.EnergeticEfficCharge = NumArray(1); + DataGenerators::FuelCell(thisFuelCell).ElecStorage.EnergeticEfficDischarge = NumArray(2); + DataGenerators::FuelCell(thisFuelCell).ElecStorage.NominalEnergyCapacity = NumArray(3); + DataGenerators::FuelCell(thisFuelCell).ElecStorage.MaxPowerDraw = NumArray(4); + DataGenerators::FuelCell(thisFuelCell).ElecStorage.MaxPowerStore = NumArray(5); + DataGenerators::FuelCell(thisFuelCell).ElecStorage.StartingEnergyStored = NumArray(6); + + // check for other FuelCell using the same Electrical Storage and fill + for (int otherFuelCell = thisFuelCell + 1; otherFuelCell <= DataGenerators::NumFuelCellGenerators; ++otherFuelCell) { + if (UtilityRoutines::SameString(DataGenerators::FuelCell(otherFuelCell).ElecStorage.Name, DataGenerators::FuelCell(thisFuelCell).ElecStorage.Name)) { + DataGenerators::FuelCell(otherFuelCell).ElecStorage = DataGenerators::FuelCell(thisFuelCell).ElecStorage; + } + } + } else { + ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(1) + " = " + AlphArray(1)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); + ErrorsFound = true; } + } - DataIPShortCuts::cCurrentModuleObject = "Generator:FuelCell:ElectricalStorage"; - int NumFCElecStorageUnits = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); + DataIPShortCuts::cCurrentModuleObject = "Generator:FuelCell:Inverter"; + int NumFCPowerCondUnits = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); - if (NumFCElecStorageUnits <= 0) { - ShowWarningError("No " + DataIPShortCuts::cCurrentModuleObject + " equipment specified in input file"); - ShowContinueError("Fuel Cell model requires an " + DataIPShortCuts::cCurrentModuleObject + " object"); - ErrorsFound = true; - } + if (NumFCPowerCondUnits <= 0) { + ShowWarningError("No " + DataIPShortCuts::cCurrentModuleObject + " equipment specified in input file"); + ShowContinueError("Fuel Cell model requires a " + DataIPShortCuts::cCurrentModuleObject + " object"); - for (int StorageNum = 1; StorageNum <= NumFCElecStorageUnits; ++StorageNum) { - inputProcessor->getObjectItem( - DataIPShortCuts::cCurrentModuleObject, StorageNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat, _, _, DataIPShortCuts::cAlphaFieldNames, DataIPShortCuts::cNumericFieldNames); - UtilityRoutines::IsNameEmpty(AlphArray(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); + ErrorsFound = true; + } - int thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), DataGenerators::FuelCell, &DataGenerators::FCDataStruct::NameElecStorage); + for (int FCPCUNum = 1; FCPCUNum <= NumFCPowerCondUnits; ++FCPCUNum) { + inputProcessor->getObjectItem( + DataIPShortCuts::cCurrentModuleObject, FCPCUNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat, _, _, DataIPShortCuts::cAlphaFieldNames, DataIPShortCuts::cNumericFieldNames); + UtilityRoutines::IsNameEmpty(AlphArray(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); - if (thisFuelCell > 0) { - DataGenerators::FuelCell(thisFuelCell).ElecStorage.Name = AlphArray(1); + int thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), DataGenerators::FuelCell, &DataGenerators::FCDataStruct::NameInverter); - if (UtilityRoutines::SameString(AlphArray(2), "SimpleEfficiencyWithConstraints")) { - DataGenerators::FuelCell(thisFuelCell).ElecStorage.StorageModelMode = DataGenerators::SimpleEffConstraints; - } else { - ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(2) + " = " + AlphArray(2)); - ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); - ErrorsFound = true; - } - DataGenerators::FuelCell(thisFuelCell).ElecStorage.EnergeticEfficCharge = NumArray(1); - DataGenerators::FuelCell(thisFuelCell).ElecStorage.EnergeticEfficDischarge = NumArray(2); - DataGenerators::FuelCell(thisFuelCell).ElecStorage.NominalEnergyCapacity = NumArray(3); - DataGenerators::FuelCell(thisFuelCell).ElecStorage.MaxPowerDraw = NumArray(4); - DataGenerators::FuelCell(thisFuelCell).ElecStorage.MaxPowerStore = NumArray(5); - DataGenerators::FuelCell(thisFuelCell).ElecStorage.StartingEnergyStored = NumArray(6); - - // check for other FuelCell using the same Electrical Storage and fill - for (int otherFuelCell = thisFuelCell + 1; otherFuelCell <= DataGenerators::NumFuelCellGenerators; ++otherFuelCell) { - if (UtilityRoutines::SameString(DataGenerators::FuelCell(otherFuelCell).ElecStorage.Name, DataGenerators::FuelCell(thisFuelCell).ElecStorage.Name)) { - DataGenerators::FuelCell(otherFuelCell).ElecStorage = DataGenerators::FuelCell(thisFuelCell).ElecStorage; - } - } - } else { - ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(1) + " = " + AlphArray(1)); + if (thisFuelCell > 0) { + DataGenerators::FuelCell(thisFuelCell).Inverter.Name = AlphArray(1); + + if (UtilityRoutines::SameString(AlphArray(2), "QUADRATIC")) DataGenerators::FuelCell(thisFuelCell).Inverter.EffMode = DataGenerators::InverterEffQuadratic; + if (UtilityRoutines::SameString(AlphArray(2), "Constant")) DataGenerators::FuelCell(thisFuelCell).Inverter.EffMode = DataGenerators::InverterEffConstant; + if (DataGenerators::FuelCell(thisFuelCell).Inverter.EffMode == 0) { + ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(2) + " = " + AlphArray(2)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } - } - DataIPShortCuts::cCurrentModuleObject = "Generator:FuelCell:Inverter"; - int NumFCPowerCondUnits = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); + DataGenerators::FuelCell(thisFuelCell).Inverter.ConstEff = NumArray(1); - if (NumFCPowerCondUnits <= 0) { - ShowWarningError("No " + DataIPShortCuts::cCurrentModuleObject + " equipment specified in input file"); - ShowContinueError("Fuel Cell model requires a " + DataIPShortCuts::cCurrentModuleObject + " object"); + DataGenerators::FuelCell(thisFuelCell).Inverter.EffQuadraticCurveID = CurveManager::GetCurveIndex(AlphArray(3)); + if ((DataGenerators::FuelCell(thisFuelCell).Inverter.EffQuadraticCurveID == 0) && + (DataGenerators::FuelCell(thisFuelCell).Inverter.EffMode == DataGenerators::InverterEffQuadratic)) { + ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(3) + " = " + AlphArray(3)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); + ShowContinueError("Curve was not found "); + ErrorsFound = true; + } + // check for other FuelCell using the same Inverter and fill + for (int otherFuelCell = thisFuelCell + 1; otherFuelCell <= DataGenerators::NumFuelCellGenerators; ++otherFuelCell) { + if (UtilityRoutines::SameString(DataGenerators::FuelCell(otherFuelCell).Inverter.Name, DataGenerators::FuelCell(thisFuelCell).Inverter.Name)) { + DataGenerators::FuelCell(otherFuelCell).Inverter = DataGenerators::FuelCell(thisFuelCell).Inverter; + } + } + } else { + ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(1) + " = " + AlphArray(1)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } + } + + DataIPShortCuts::cCurrentModuleObject = "Generator:FuelCell:StackCooler"; + int NumFCStackCoolers = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); - for (int FCPCUNum = 1; FCPCUNum <= NumFCPowerCondUnits; ++FCPCUNum) { - inputProcessor->getObjectItem( - DataIPShortCuts::cCurrentModuleObject, FCPCUNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat, _, _, DataIPShortCuts::cAlphaFieldNames, DataIPShortCuts::cNumericFieldNames); + if (NumFCStackCoolers > 0) { // get stack cooler input data + for (int FCScoolNum = 1; FCScoolNum <= NumFCStackCoolers; ++FCScoolNum) { + inputProcessor->getObjectItem(DataIPShortCuts::cCurrentModuleObject, + FCScoolNum, + AlphArray, + NumAlphas, + NumArray, + NumNums, + IOStat, + _, + _, + DataIPShortCuts::cAlphaFieldNames, + DataIPShortCuts::cNumericFieldNames); UtilityRoutines::IsNameEmpty(AlphArray(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); - int thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), DataGenerators::FuelCell, &DataGenerators::FCDataStruct::NameInverter); + int thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), DataGenerators::FuelCell, &DataGenerators::FCDataStruct::NameStackCooler); if (thisFuelCell > 0) { - DataGenerators::FuelCell(thisFuelCell).Inverter.Name = AlphArray(1); - - if (UtilityRoutines::SameString(AlphArray(2), "QUADRATIC")) DataGenerators::FuelCell(thisFuelCell).Inverter.EffMode = DataGenerators::InverterEffQuadratic; - if (UtilityRoutines::SameString(AlphArray(2), "Constant")) DataGenerators::FuelCell(thisFuelCell).Inverter.EffMode = DataGenerators::InverterEffConstant; - if (DataGenerators::FuelCell(thisFuelCell).Inverter.EffMode == 0) { - ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(2) + " = " + AlphArray(2)); - ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); - ErrorsFound = true; - } + DataGenerators::FuelCell(thisFuelCell).StackCooler.Name = AlphArray(1); + DataGenerators::FuelCell(thisFuelCell).StackCooler.WaterInNodeName = AlphArray(2); + + DataGenerators::FuelCell(thisFuelCell).StackCooler.WaterOutNodeName = AlphArray(3); + + DataGenerators::FuelCell(thisFuelCell).StackCooler.WaterInNode = NodeInputManager::GetOnlySingleNode(AlphArray(2), + ErrorsFound, + DataIPShortCuts::cCurrentModuleObject, + AlphArray(1), + DataLoopNode::NodeType_Water, + DataLoopNode::NodeConnectionType_Inlet, + 1, + DataLoopNode::ObjectIsNotParent); + DataGenerators::FuelCell(thisFuelCell).StackCooler.WaterOutNode = NodeInputManager::GetOnlySingleNode(AlphArray(3), + ErrorsFound, + DataIPShortCuts::cCurrentModuleObject, + AlphArray(1), + DataLoopNode::NodeType_Water, + DataLoopNode::NodeConnectionType_Outlet, + 1, + DataLoopNode::ObjectIsNotParent); + BranchNodeConnections::TestCompSet(DataIPShortCuts::cCurrentModuleObject, AlphArray(1), AlphArray(2), AlphArray(3), "Heat Recovery Nodes"); - DataGenerators::FuelCell(thisFuelCell).Inverter.ConstEff = NumArray(1); + DataGenerators::FuelCell(thisFuelCell).StackCooler.TstackNom = NumArray(1); + DataGenerators::FuelCell(thisFuelCell).StackCooler.TstackActual = NumArray(2); + DataGenerators::FuelCell(thisFuelCell).StackCooler.r0 = NumArray(3); + DataGenerators::FuelCell(thisFuelCell).StackCooler.r1 = NumArray(4); + DataGenerators::FuelCell(thisFuelCell).StackCooler.r2 = NumArray(5); + DataGenerators::FuelCell(thisFuelCell).StackCooler.r3 = NumArray(6); + DataGenerators::FuelCell(thisFuelCell).StackCooler.MdotStackCoolant = NumArray(7); + DataGenerators::FuelCell(thisFuelCell).StackCooler.UAs_cool = NumArray(8); + DataGenerators::FuelCell(thisFuelCell).StackCooler.Fs_cogen = NumArray(9); + DataGenerators::FuelCell(thisFuelCell).StackCooler.As_cogen = NumArray(10); + DataGenerators::FuelCell(thisFuelCell).StackCooler.MdotCogenNom = NumArray(11); + DataGenerators::FuelCell(thisFuelCell).StackCooler.hCogenNom = NumArray(12); + DataGenerators::FuelCell(thisFuelCell).StackCooler.ns = NumArray(13); + DataGenerators::FuelCell(thisFuelCell).StackCooler.PstackPumpEl = NumArray(14); + DataGenerators::FuelCell(thisFuelCell).StackCooler.PmpPowerLossFactor = NumArray(15); + DataGenerators::FuelCell(thisFuelCell).StackCooler.f0 = NumArray(16); + DataGenerators::FuelCell(thisFuelCell).StackCooler.f1 = NumArray(17); + DataGenerators::FuelCell(thisFuelCell).StackCooler.f1 = NumArray(18); + + DataGenerators::FuelCell(thisFuelCell).StackCooler.StackCoolerPresent = true; - DataGenerators::FuelCell(thisFuelCell).Inverter.EffQuadraticCurveID = CurveManager::GetCurveIndex(AlphArray(3)); - if ((DataGenerators::FuelCell(thisFuelCell).Inverter.EffQuadraticCurveID == 0) && - (DataGenerators::FuelCell(thisFuelCell).Inverter.EffMode == DataGenerators::InverterEffQuadratic)) { - ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(3) + " = " + AlphArray(3)); - ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); - ShowContinueError("Curve was not found "); - ErrorsFound = true; - } - - // check for other FuelCell using the same Inverter and fill - for (int otherFuelCell = thisFuelCell + 1; otherFuelCell <= DataGenerators::NumFuelCellGenerators; ++otherFuelCell) { - if (UtilityRoutines::SameString(DataGenerators::FuelCell(otherFuelCell).Inverter.Name, DataGenerators::FuelCell(thisFuelCell).Inverter.Name)) { - DataGenerators::FuelCell(otherFuelCell).Inverter = DataGenerators::FuelCell(thisFuelCell).Inverter; - } - } } else { ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(1) + " = " + AlphArray(1)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } } + } - DataIPShortCuts::cCurrentModuleObject = "Generator:FuelCell:StackCooler"; - int NumFCStackCoolers = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); - - if (NumFCStackCoolers > 0) { // get stack cooler input data - for (int FCScoolNum = 1; FCScoolNum <= NumFCStackCoolers; ++FCScoolNum) { - inputProcessor->getObjectItem(DataIPShortCuts::cCurrentModuleObject, - FCScoolNum, - AlphArray, - NumAlphas, - NumArray, - NumNums, - IOStat, - _, - _, - DataIPShortCuts::cAlphaFieldNames, - DataIPShortCuts::cNumericFieldNames); - UtilityRoutines::IsNameEmpty(AlphArray(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); - - int thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), DataGenerators::FuelCell, &DataGenerators::FCDataStruct::NameStackCooler); - - if (thisFuelCell > 0) { - DataGenerators::FuelCell(thisFuelCell).StackCooler.Name = AlphArray(1); - DataGenerators::FuelCell(thisFuelCell).StackCooler.WaterInNodeName = AlphArray(2); - - DataGenerators::FuelCell(thisFuelCell).StackCooler.WaterOutNodeName = AlphArray(3); - - DataGenerators::FuelCell(thisFuelCell).StackCooler.WaterInNode = NodeInputManager::GetOnlySingleNode(AlphArray(2), - ErrorsFound, - DataIPShortCuts::cCurrentModuleObject, - AlphArray(1), - DataLoopNode::NodeType_Water, - DataLoopNode::NodeConnectionType_Inlet, - 1, - DataLoopNode::ObjectIsNotParent); - DataGenerators::FuelCell(thisFuelCell).StackCooler.WaterOutNode = NodeInputManager::GetOnlySingleNode(AlphArray(3), - ErrorsFound, - DataIPShortCuts::cCurrentModuleObject, - AlphArray(1), - DataLoopNode::NodeType_Water, - DataLoopNode::NodeConnectionType_Outlet, - 1, - DataLoopNode::ObjectIsNotParent); - BranchNodeConnections::TestCompSet(DataIPShortCuts::cCurrentModuleObject, AlphArray(1), AlphArray(2), AlphArray(3), "Heat Recovery Nodes"); - - DataGenerators::FuelCell(thisFuelCell).StackCooler.TstackNom = NumArray(1); - DataGenerators::FuelCell(thisFuelCell).StackCooler.TstackActual = NumArray(2); - DataGenerators::FuelCell(thisFuelCell).StackCooler.r0 = NumArray(3); - DataGenerators::FuelCell(thisFuelCell).StackCooler.r1 = NumArray(4); - DataGenerators::FuelCell(thisFuelCell).StackCooler.r2 = NumArray(5); - DataGenerators::FuelCell(thisFuelCell).StackCooler.r3 = NumArray(6); - DataGenerators::FuelCell(thisFuelCell).StackCooler.MdotStackCoolant = NumArray(7); - DataGenerators::FuelCell(thisFuelCell).StackCooler.UAs_cool = NumArray(8); - DataGenerators::FuelCell(thisFuelCell).StackCooler.Fs_cogen = NumArray(9); - DataGenerators::FuelCell(thisFuelCell).StackCooler.As_cogen = NumArray(10); - DataGenerators::FuelCell(thisFuelCell).StackCooler.MdotCogenNom = NumArray(11); - DataGenerators::FuelCell(thisFuelCell).StackCooler.hCogenNom = NumArray(12); - DataGenerators::FuelCell(thisFuelCell).StackCooler.ns = NumArray(13); - DataGenerators::FuelCell(thisFuelCell).StackCooler.PstackPumpEl = NumArray(14); - DataGenerators::FuelCell(thisFuelCell).StackCooler.PmpPowerLossFactor = NumArray(15); - DataGenerators::FuelCell(thisFuelCell).StackCooler.f0 = NumArray(16); - DataGenerators::FuelCell(thisFuelCell).StackCooler.f1 = NumArray(17); - DataGenerators::FuelCell(thisFuelCell).StackCooler.f1 = NumArray(18); - - DataGenerators::FuelCell(thisFuelCell).StackCooler.StackCoolerPresent = true; - - } else { - ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(1) + " = " + AlphArray(1)); - ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); - ErrorsFound = true; - } - } - } - - if (ErrorsFound) { - ShowFatalError("Errors found in getting input for fuel cell model "); - } + if (ErrorsFound) { + ShowFatalError("Errors found in getting input for fuel cell model "); + } - for (int GeneratorNum = 1; GeneratorNum <= DataGenerators::NumFuelCellGenerators; ++GeneratorNum) { - SetupOutputVariable("Generator Produced Electric Power", + for (int GeneratorNum = 1; GeneratorNum <= DataGenerators::NumFuelCellGenerators; ++GeneratorNum) { + SetupOutputVariable("Generator Produced Electric Power", + OutputProcessor::Unit::W, + DataGenerators::FuelCell(GeneratorNum).Report.ACPowerGen, + "System", + "Average", + DataGenerators::FuelCell(GeneratorNum).Name); + SetupOutputVariable("Generator Produced Electric Energy", + OutputProcessor::Unit::J, + DataGenerators::FuelCell(GeneratorNum).Report.ACEnergyGen, + "System", + "Sum", + DataGenerators::FuelCell(GeneratorNum).Name, + _, + "ElectricityProduced", + "COGENERATION", + _, + "Plant"); + SetupOutputVariable("Generator Produced Thermal Rate", + OutputProcessor::Unit::W, + DataGenerators::FuelCell(GeneratorNum).Report.qHX, + "System", + "Average", + DataGenerators::FuelCell(GeneratorNum).Name); + SetupOutputVariable("Generator Produced Thermal Energy", + OutputProcessor::Unit::J, + DataGenerators::FuelCell(GeneratorNum).Report.HXenergy, + "System", + "Sum", + DataGenerators::FuelCell(GeneratorNum).Name, + _, + "ENERGYTRANSFER", + "COGENERATION", + _, + "Plant"); + + SetupOutputVariable("Generator Fuel HHV Basis Energy", + OutputProcessor::Unit::J, + DataGenerators::FuelCell(GeneratorNum).Report.FuelEnergyHHV, + "System", + "Sum", + DataGenerators::FuelCell(GeneratorNum).Name, + _, + "Gas", + "COGENERATION", + _, + "Plant"); + SetupOutputVariable("Generator Fuel HHV Basis Rate", + OutputProcessor::Unit::W, + DataGenerators::FuelCell(GeneratorNum).Report.FuelEnergyUseRateHHV, + "System", + "Average", + DataGenerators::FuelCell(GeneratorNum).Name); + + SetupOutputVariable("Generator Zone Sensible Heat Transfer Rate", + OutputProcessor::Unit::W, + DataGenerators::FuelCell(GeneratorNum).Report.SkinLossPower, + "System", + "Average", + DataGenerators::FuelCell(GeneratorNum).Name); + SetupOutputVariable("Generator Zone Sensible Heat Transfer Energy", + OutputProcessor::Unit::J, + DataGenerators::FuelCell(GeneratorNum).Report.SkinLossEnergy, + "System", + "Sum", + DataGenerators::FuelCell(GeneratorNum).Name); + SetupOutputVariable("Generator Zone Convection Heat Transfer Rate", + OutputProcessor::Unit::W, + DataGenerators::FuelCell(GeneratorNum).Report.SkinLossConvect, + "System", + "Average", + DataGenerators::FuelCell(GeneratorNum).Name); + SetupOutputVariable("Generator Zone Radiation Heat Transfer Rate", + OutputProcessor::Unit::W, + DataGenerators::FuelCell(GeneratorNum).Report.SkinLossRadiat, + "System", + "Average", + DataGenerators::FuelCell(GeneratorNum).Name); + if (DataGenerators::FuelCell(GeneratorNum).FCPM.ZoneID > 0) { + SetupZoneInternalGain(DataGenerators::FuelCell(GeneratorNum).FCPM.ZoneID, + "Generator:FuelCell", + DataGenerators::FuelCell(GeneratorNum).Name, + DataHeatBalance::IntGainTypeOf_GeneratorFuelCell, + DataGenerators::FuelCell(GeneratorNum).Report.SkinLossConvect, + _, + DataGenerators::FuelCell(GeneratorNum).Report.SkinLossRadiat); + } + + if (DataGlobals::DisplayAdvancedReportVariables) { // show extra data originally needed for detailed comparative testing + SetupOutputVariable("Generator Air Inlet Temperature", + OutputProcessor::Unit::C, + DataGenerators::FuelCell(GeneratorNum).Report.TairInlet, + "System", + "Average", + DataGenerators::FuelCell(GeneratorNum).Name); + SetupOutputVariable("Generator Power Module Entering Air Temperature", + OutputProcessor::Unit::C, + DataGenerators::FuelCell(GeneratorNum).Report.TairIntoFCPM, + "System", + "Average", + DataGenerators::FuelCell(GeneratorNum).Name); + SetupOutputVariable("Generator Air Molar Flow Rate", + OutputProcessor::Unit::kmol_s, + DataGenerators::FuelCell(GeneratorNum).Report.NdotAir, + "System", + "Average", + DataGenerators::FuelCell(GeneratorNum).Name); + SetupOutputVariable("Generator Power Module Entering Air Enthalpy", + OutputProcessor::Unit::W, + DataGenerators::FuelCell(GeneratorNum).Report.TotAirInEnthalphy, + "System", + "Average", + DataGenerators::FuelCell(GeneratorNum).Name); + SetupOutputVariable("Generator Blower Electric Power", OutputProcessor::Unit::W, - DataGenerators::FuelCell(GeneratorNum).Report.ACPowerGen, + DataGenerators::FuelCell(GeneratorNum).Report.BlowerPower, "System", "Average", DataGenerators::FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Produced Electric Energy", + SetupOutputVariable("Generator Blower Electric Energy", OutputProcessor::Unit::J, - DataGenerators::FuelCell(GeneratorNum).Report.ACEnergyGen, + DataGenerators::FuelCell(GeneratorNum).Report.BlowerEnergy, "System", "Sum", - DataGenerators::FuelCell(GeneratorNum).Name, - _, - "ElectricityProduced", - "COGENERATION", - _, - "Plant"); - SetupOutputVariable("Generator Produced Thermal Rate", + DataGenerators::FuelCell(GeneratorNum).Name); + SetupOutputVariable("Generator Blower Skin Heat Loss Rate", OutputProcessor::Unit::W, - DataGenerators::FuelCell(GeneratorNum).Report.qHX, + DataGenerators::FuelCell(GeneratorNum).Report.BlowerSkinLoss, "System", "Average", DataGenerators::FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Produced Thermal Energy", + + SetupOutputVariable("Generator Fuel Inlet Temperature", + OutputProcessor::Unit::C, + DataGenerators::FuelCell(GeneratorNum).Report.TfuelInlet, + "System", + "Average", + DataGenerators::FuelCell(GeneratorNum).Name); + SetupOutputVariable("Generator Power Module Entering Fuel Temperature", + OutputProcessor::Unit::C, + DataGenerators::FuelCell(GeneratorNum).Report.TfuelIntoFCPM, + "System", + "Average", + DataGenerators::FuelCell(GeneratorNum).Name); + SetupOutputVariable("Generator Fuel Molar Flow Rate", + OutputProcessor::Unit::kmol_s, + DataGenerators::FuelCell(GeneratorNum).Report.NdotFuel, + "System", + "Average", + DataGenerators::FuelCell(GeneratorNum).Name); + SetupOutputVariable("Generator Fuel Consumption LHV Basis Energy", OutputProcessor::Unit::J, - DataGenerators::FuelCell(GeneratorNum).Report.HXenergy, + DataGenerators::FuelCell(GeneratorNum).Report.FuelEnergyLHV, "System", "Sum", - DataGenerators::FuelCell(GeneratorNum).Name, - _, - "ENERGYTRANSFER", - "COGENERATION", - _, - "Plant"); + DataGenerators::FuelCell(GeneratorNum).Name); + SetupOutputVariable("Generator Fuel Consumption Rate LHV Basis", + OutputProcessor::Unit::W, + DataGenerators::FuelCell(GeneratorNum).Report.FuelEnergyUseRateLHV, + "System", + "Average", + DataGenerators::FuelCell(GeneratorNum).Name); + + SetupOutputVariable("Generator Power Module Entering Fuel Enthalpy", + OutputProcessor::Unit::W, + DataGenerators::FuelCell(GeneratorNum).Report.TotFuelInEnthalpy, + "System", + "Average", + DataGenerators::FuelCell(GeneratorNum).Name); + SetupOutputVariable("Generator Fuel Compressor Electric Power", + OutputProcessor::Unit::W, + DataGenerators::FuelCell(GeneratorNum).Report.FuelCompressPower, + "System", + "Average", + DataGenerators::FuelCell(GeneratorNum).Name); + SetupOutputVariable("Generator Fuel Compressor Electric Energy", + OutputProcessor::Unit::J, + DataGenerators::FuelCell(GeneratorNum).Report.FuelCompressEnergy, + "System", + "Sum", + DataGenerators::FuelCell(GeneratorNum).Name); + SetupOutputVariable("Generator Fuel Compressor Skin Heat Loss Rate", + OutputProcessor::Unit::W, + DataGenerators::FuelCell(GeneratorNum).Report.FuelCompressSkinLoss, + "System", + "Average", + DataGenerators::FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Fuel HHV Basis Energy", + SetupOutputVariable("Generator Fuel Reformer Water Inlet Temperature", + OutputProcessor::Unit::C, + DataGenerators::FuelCell(GeneratorNum).Report.TwaterInlet, + "System", + "Average", + DataGenerators::FuelCell(GeneratorNum).Name); + SetupOutputVariable("Generator Power Module Entering Reforming Water Temperature", + OutputProcessor::Unit::C, + DataGenerators::FuelCell(GeneratorNum).Report.TwaterIntoFCPM, + "System", + "Average", + DataGenerators::FuelCell(GeneratorNum).Name); + SetupOutputVariable("Generator Fuel Reformer Water Molar Flow Rate", + OutputProcessor::Unit::kmol_s, + DataGenerators::FuelCell(GeneratorNum).Report.NdotWater, + "System", + "Average", + DataGenerators::FuelCell(GeneratorNum).Name); + SetupOutputVariable("Generator Fuel Reformer Water Pump Electric Power", + OutputProcessor::Unit::W, + DataGenerators::FuelCell(GeneratorNum).Report.WaterPumpPower, + "System", + "Average", + DataGenerators::FuelCell(GeneratorNum).Name); + SetupOutputVariable("Generator Fuel Reformer Water Pump Electric Energy", OutputProcessor::Unit::J, - DataGenerators::FuelCell(GeneratorNum).Report.FuelEnergyHHV, + DataGenerators::FuelCell(GeneratorNum).Report.WaterPumpEnergy, "System", "Sum", - DataGenerators::FuelCell(GeneratorNum).Name, - _, - "Gas", - "COGENERATION", - _, - "Plant"); - SetupOutputVariable("Generator Fuel HHV Basis Rate", + DataGenerators::FuelCell(GeneratorNum).Name); + + SetupOutputVariable("Generator Power Module Entering Reforming Water Enthalpy", OutputProcessor::Unit::W, - DataGenerators::FuelCell(GeneratorNum).Report.FuelEnergyUseRateHHV, + DataGenerators::FuelCell(GeneratorNum).Report.WaterIntoFCPMEnthalpy, "System", "Average", DataGenerators::FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Zone Sensible Heat Transfer Rate", + SetupOutputVariable("Generator Product Gas Temperature", + OutputProcessor::Unit::C, + DataGenerators::FuelCell(GeneratorNum).Report.TprodGas, + "System", + "Average", + DataGenerators::FuelCell(GeneratorNum).Name); + SetupOutputVariable("Generator Product Gas Enthalpy", OutputProcessor::Unit::W, - DataGenerators::FuelCell(GeneratorNum).Report.SkinLossPower, + DataGenerators::FuelCell(GeneratorNum).Report.EnthalProdGas, + "System", + "Average", + DataGenerators::FuelCell(GeneratorNum).Name); + SetupOutputVariable("Generator Product Gas Molar Flow Rate", + OutputProcessor::Unit::kmol_s, + DataGenerators::FuelCell(GeneratorNum).Report.NdotProdGas, "System", "Average", DataGenerators::FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Zone Sensible Heat Transfer Energy", + SetupOutputVariable("Generator Product Gas Ar Molar Flow Rate", + OutputProcessor::Unit::kmol_s, + DataGenerators::FuelCell(GeneratorNum).Report.NdotProdAr, + "System", + "Average", + DataGenerators::FuelCell(GeneratorNum).Name); + SetupOutputVariable("Generator Product Gas CO2 Molar Flow Rate", + OutputProcessor::Unit::kmol_s, + DataGenerators::FuelCell(GeneratorNum).Report.NdotProdCO2, + "System", + "Average", + DataGenerators::FuelCell(GeneratorNum).Name); + SetupOutputVariable("Generator Product Gas H2O Vapor Molar Flow Rate", + OutputProcessor::Unit::kmol_s, + DataGenerators::FuelCell(GeneratorNum).Report.NdotProdH2O, + "System", + "Average", + DataGenerators::FuelCell(GeneratorNum).Name); + SetupOutputVariable("Generator Product Gas N2 Molar Flow Rate", + OutputProcessor::Unit::kmol_s, + DataGenerators::FuelCell(GeneratorNum).Report.NdotProdN2, + "System", + "Average", + DataGenerators::FuelCell(GeneratorNum).Name); + SetupOutputVariable("Generator Product Gas O2 Molar Flow Rate", + OutputProcessor::Unit::kmol_s, + DataGenerators::FuelCell(GeneratorNum).Report.NdotProdO2, + "System", + "Average", + DataGenerators::FuelCell(GeneratorNum).Name); + + SetupOutputVariable("Generator Heat Recovery Exit Gas Temperature", + OutputProcessor::Unit::C, + DataGenerators::FuelCell(GeneratorNum).Report.THXexh, + "System", + "Average", + DataGenerators::FuelCell(GeneratorNum).Name); + SetupOutputVariable("Generator Heat Recovery Exit Gas H2O Vapor Fraction", + OutputProcessor::Unit::None, + DataGenerators::FuelCell(GeneratorNum).Report.WaterVaporFractExh, + "System", + "Average", + DataGenerators::FuelCell(GeneratorNum).Name); + SetupOutputVariable("Generator Heat Recovery Water Condensate Molar Flow Rate", + OutputProcessor::Unit::kmol_s, + DataGenerators::FuelCell(GeneratorNum).Report.CondensateRate, + "System", + "Average", + DataGenerators::FuelCell(GeneratorNum).Name); + + SetupOutputVariable("Generator Inverter Loss Power", + OutputProcessor::Unit::W, + DataGenerators::FuelCell(GeneratorNum).Report.PCUlosses, + "System", + "Average", + DataGenerators::FuelCell(GeneratorNum).Name); + SetupOutputVariable("Generator Produced DC Electric Power", + OutputProcessor::Unit::W, + DataGenerators::FuelCell(GeneratorNum).Report.DCPowerGen, + "System", + "Average", + DataGenerators::FuelCell(GeneratorNum).Name); + SetupOutputVariable("Generator DC Power Efficiency", + OutputProcessor::Unit::None, + DataGenerators::FuelCell(GeneratorNum).Report.DCPowerEff, + "System", + "Average", + DataGenerators::FuelCell(GeneratorNum).Name); + + SetupOutputVariable("Generator Electric Storage Charge State", + OutputProcessor::Unit::J, + DataGenerators::FuelCell(GeneratorNum).Report.ElectEnergyinStorage, + "System", + "Average", + DataGenerators::FuelCell(GeneratorNum).Name); //? 'Sum' + SetupOutputVariable("Generator DC Storage Charging Power", + OutputProcessor::Unit::W, + DataGenerators::FuelCell(GeneratorNum).Report.StoredPower, + "System", + "Average", + DataGenerators::FuelCell(GeneratorNum).Name); + SetupOutputVariable("Generator DC Storage Charging Energy", OutputProcessor::Unit::J, - DataGenerators::FuelCell(GeneratorNum).Report.SkinLossEnergy, + DataGenerators::FuelCell(GeneratorNum).Report.StoredEnergy, "System", "Sum", DataGenerators::FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Zone Convection Heat Transfer Rate", + SetupOutputVariable("Generator DC Storage Discharging Power", OutputProcessor::Unit::W, - DataGenerators::FuelCell(GeneratorNum).Report.SkinLossConvect, + DataGenerators::FuelCell(GeneratorNum).Report.DrawnPower, "System", "Average", DataGenerators::FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Zone Radiation Heat Transfer Rate", + SetupOutputVariable("Generator DC Storage Discharging Energy", + OutputProcessor::Unit::J, + DataGenerators::FuelCell(GeneratorNum).Report.DrawnEnergy, + "System", + "Sum", + DataGenerators::FuelCell(GeneratorNum).Name); + SetupOutputVariable("Generator Ancillary AC Electric Power", OutputProcessor::Unit::W, - DataGenerators::FuelCell(GeneratorNum).Report.SkinLossRadiat, + DataGenerators::FuelCell(GeneratorNum).Report.ACancillariesPower, "System", "Average", DataGenerators::FuelCell(GeneratorNum).Name); - if (DataGenerators::FuelCell(GeneratorNum).FCPM.ZoneID > 0) { - SetupZoneInternalGain(DataGenerators::FuelCell(GeneratorNum).FCPM.ZoneID, - "Generator:FuelCell", - DataGenerators::FuelCell(GeneratorNum).Name, - DataHeatBalance::IntGainTypeOf_GeneratorFuelCell, - DataGenerators::FuelCell(GeneratorNum).Report.SkinLossConvect, - _, - DataGenerators::FuelCell(GeneratorNum).Report.SkinLossRadiat); - } - - if (DataGlobals::DisplayAdvancedReportVariables) { // show extra data originally needed for detailed comparative testing - SetupOutputVariable("Generator Air Inlet Temperature", - OutputProcessor::Unit::C, - DataGenerators::FuelCell(GeneratorNum).Report.TairInlet, - "System", - "Average", - DataGenerators::FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Power Module Entering Air Temperature", - OutputProcessor::Unit::C, - DataGenerators::FuelCell(GeneratorNum).Report.TairIntoFCPM, - "System", - "Average", - DataGenerators::FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Air Molar Flow Rate", - OutputProcessor::Unit::kmol_s, - DataGenerators::FuelCell(GeneratorNum).Report.NdotAir, - "System", - "Average", - DataGenerators::FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Power Module Entering Air Enthalpy", - OutputProcessor::Unit::W, - DataGenerators::FuelCell(GeneratorNum).Report.TotAirInEnthalphy, - "System", - "Average", - DataGenerators::FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Blower Electric Power", - OutputProcessor::Unit::W, - DataGenerators::FuelCell(GeneratorNum).Report.BlowerPower, - "System", - "Average", - DataGenerators::FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Blower Electric Energy", - OutputProcessor::Unit::J, - DataGenerators::FuelCell(GeneratorNum).Report.BlowerEnergy, - "System", - "Sum", - DataGenerators::FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Blower Skin Heat Loss Rate", - OutputProcessor::Unit::W, - DataGenerators::FuelCell(GeneratorNum).Report.BlowerSkinLoss, - "System", - "Average", - DataGenerators::FuelCell(GeneratorNum).Name); - - SetupOutputVariable("Generator Fuel Inlet Temperature", - OutputProcessor::Unit::C, - DataGenerators::FuelCell(GeneratorNum).Report.TfuelInlet, - "System", - "Average", - DataGenerators::FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Power Module Entering Fuel Temperature", - OutputProcessor::Unit::C, - DataGenerators::FuelCell(GeneratorNum).Report.TfuelIntoFCPM, - "System", - "Average", - DataGenerators::FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Fuel Molar Flow Rate", - OutputProcessor::Unit::kmol_s, - DataGenerators::FuelCell(GeneratorNum).Report.NdotFuel, - "System", - "Average", - DataGenerators::FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Fuel Consumption LHV Basis Energy", - OutputProcessor::Unit::J, - DataGenerators::FuelCell(GeneratorNum).Report.FuelEnergyLHV, - "System", - "Sum", - DataGenerators::FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Fuel Consumption Rate LHV Basis", - OutputProcessor::Unit::W, - DataGenerators::FuelCell(GeneratorNum).Report.FuelEnergyUseRateLHV, - "System", - "Average", - DataGenerators::FuelCell(GeneratorNum).Name); - - SetupOutputVariable("Generator Power Module Entering Fuel Enthalpy", - OutputProcessor::Unit::W, - DataGenerators::FuelCell(GeneratorNum).Report.TotFuelInEnthalpy, - "System", - "Average", - DataGenerators::FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Fuel Compressor Electric Power", - OutputProcessor::Unit::W, - DataGenerators::FuelCell(GeneratorNum).Report.FuelCompressPower, - "System", - "Average", - DataGenerators::FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Fuel Compressor Electric Energy", - OutputProcessor::Unit::J, - DataGenerators::FuelCell(GeneratorNum).Report.FuelCompressEnergy, - "System", - "Sum", - DataGenerators::FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Fuel Compressor Skin Heat Loss Rate", - OutputProcessor::Unit::W, - DataGenerators::FuelCell(GeneratorNum).Report.FuelCompressSkinLoss, - "System", - "Average", - DataGenerators::FuelCell(GeneratorNum).Name); - - SetupOutputVariable("Generator Fuel Reformer Water Inlet Temperature", - OutputProcessor::Unit::C, - DataGenerators::FuelCell(GeneratorNum).Report.TwaterInlet, - "System", - "Average", - DataGenerators::FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Power Module Entering Reforming Water Temperature", - OutputProcessor::Unit::C, - DataGenerators::FuelCell(GeneratorNum).Report.TwaterIntoFCPM, - "System", - "Average", - DataGenerators::FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Fuel Reformer Water Molar Flow Rate", - OutputProcessor::Unit::kmol_s, - DataGenerators::FuelCell(GeneratorNum).Report.NdotWater, - "System", - "Average", - DataGenerators::FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Fuel Reformer Water Pump Electric Power", - OutputProcessor::Unit::W, - DataGenerators::FuelCell(GeneratorNum).Report.WaterPumpPower, - "System", - "Average", - DataGenerators::FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Fuel Reformer Water Pump Electric Energy", - OutputProcessor::Unit::J, - DataGenerators::FuelCell(GeneratorNum).Report.WaterPumpEnergy, - "System", - "Sum", - DataGenerators::FuelCell(GeneratorNum).Name); - - SetupOutputVariable("Generator Power Module Entering Reforming Water Enthalpy", - OutputProcessor::Unit::W, - DataGenerators::FuelCell(GeneratorNum).Report.WaterIntoFCPMEnthalpy, - "System", - "Average", - DataGenerators::FuelCell(GeneratorNum).Name); - - SetupOutputVariable("Generator Product Gas Temperature", - OutputProcessor::Unit::C, - DataGenerators::FuelCell(GeneratorNum).Report.TprodGas, - "System", - "Average", - DataGenerators::FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Product Gas Enthalpy", - OutputProcessor::Unit::W, - DataGenerators::FuelCell(GeneratorNum).Report.EnthalProdGas, - "System", - "Average", - DataGenerators::FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Product Gas Molar Flow Rate", - OutputProcessor::Unit::kmol_s, - DataGenerators::FuelCell(GeneratorNum).Report.NdotProdGas, - "System", - "Average", - DataGenerators::FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Product Gas Ar Molar Flow Rate", - OutputProcessor::Unit::kmol_s, - DataGenerators::FuelCell(GeneratorNum).Report.NdotProdAr, - "System", - "Average", - DataGenerators::FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Product Gas CO2 Molar Flow Rate", - OutputProcessor::Unit::kmol_s, - DataGenerators::FuelCell(GeneratorNum).Report.NdotProdCO2, - "System", - "Average", - DataGenerators::FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Product Gas H2O Vapor Molar Flow Rate", - OutputProcessor::Unit::kmol_s, - DataGenerators::FuelCell(GeneratorNum).Report.NdotProdH2O, - "System", - "Average", - DataGenerators::FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Product Gas N2 Molar Flow Rate", - OutputProcessor::Unit::kmol_s, - DataGenerators::FuelCell(GeneratorNum).Report.NdotProdN2, - "System", - "Average", - DataGenerators::FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Product Gas O2 Molar Flow Rate", - OutputProcessor::Unit::kmol_s, - DataGenerators::FuelCell(GeneratorNum).Report.NdotProdO2, - "System", - "Average", - DataGenerators::FuelCell(GeneratorNum).Name); - - SetupOutputVariable("Generator Heat Recovery Exit Gas Temperature", - OutputProcessor::Unit::C, - DataGenerators::FuelCell(GeneratorNum).Report.THXexh, - "System", - "Average", - DataGenerators::FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Heat Recovery Exit Gas H2O Vapor Fraction", - OutputProcessor::Unit::None, - DataGenerators::FuelCell(GeneratorNum).Report.WaterVaporFractExh, - "System", - "Average", - DataGenerators::FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Heat Recovery Water Condensate Molar Flow Rate", - OutputProcessor::Unit::kmol_s, - DataGenerators::FuelCell(GeneratorNum).Report.CondensateRate, - "System", - "Average", - DataGenerators::FuelCell(GeneratorNum).Name); - - SetupOutputVariable("Generator Inverter Loss Power", - OutputProcessor::Unit::W, - DataGenerators::FuelCell(GeneratorNum).Report.PCUlosses, - "System", - "Average", - DataGenerators::FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Produced DC Electric Power", - OutputProcessor::Unit::W, - DataGenerators::FuelCell(GeneratorNum).Report.DCPowerGen, - "System", - "Average", - DataGenerators::FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator DC Power Efficiency", - OutputProcessor::Unit::None, - DataGenerators::FuelCell(GeneratorNum).Report.DCPowerEff, - "System", - "Average", - DataGenerators::FuelCell(GeneratorNum).Name); - - SetupOutputVariable("Generator Electric Storage Charge State", - OutputProcessor::Unit::J, - DataGenerators::FuelCell(GeneratorNum).Report.ElectEnergyinStorage, - "System", - "Average", - DataGenerators::FuelCell(GeneratorNum).Name); //? 'Sum' - SetupOutputVariable("Generator DC Storage Charging Power", - OutputProcessor::Unit::W, - DataGenerators::FuelCell(GeneratorNum).Report.StoredPower, - "System", - "Average", - DataGenerators::FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator DC Storage Charging Energy", - OutputProcessor::Unit::J, - DataGenerators::FuelCell(GeneratorNum).Report.StoredEnergy, - "System", - "Sum", - DataGenerators::FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator DC Storage Discharging Power", - OutputProcessor::Unit::W, - DataGenerators::FuelCell(GeneratorNum).Report.DrawnPower, - "System", - "Average", - DataGenerators::FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator DC Storage Discharging Energy", - OutputProcessor::Unit::J, - DataGenerators::FuelCell(GeneratorNum).Report.DrawnEnergy, - "System", - "Sum", - DataGenerators::FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Ancillary AC Electric Power", - OutputProcessor::Unit::W, - DataGenerators::FuelCell(GeneratorNum).Report.ACancillariesPower, - "System", - "Average", - DataGenerators::FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Ancillary AC Electric Energy", - OutputProcessor::Unit::J, - DataGenerators::FuelCell(GeneratorNum).Report.ACancillariesEnergy, - "System", - "Sum", - DataGenerators::FuelCell(GeneratorNum).Name); - - SetupOutputVariable("Generator Fuel Cell Model Iteration Count", - OutputProcessor::Unit::None, - DataGenerators::FuelCell(GeneratorNum).Report.SeqSubstIterations, - "System", - "Sum", - DataGenerators::FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Root Solver Iteration Count", - OutputProcessor::Unit::None, - DataGenerators::FuelCell(GeneratorNum).Report.RegulaFalsiIterations, - "System", - "Sum", - DataGenerators::FuelCell(GeneratorNum).Name); - } - } + SetupOutputVariable("Generator Ancillary AC Electric Energy", + OutputProcessor::Unit::J, + DataGenerators::FuelCell(GeneratorNum).Report.ACancillariesEnergy, + "System", + "Sum", + DataGenerators::FuelCell(GeneratorNum).Name); - MyOneTimeFlag = false; + SetupOutputVariable("Generator Fuel Cell Model Iteration Count", + OutputProcessor::Unit::None, + DataGenerators::FuelCell(GeneratorNum).Report.SeqSubstIterations, + "System", + "Sum", + DataGenerators::FuelCell(GeneratorNum).Name); + SetupOutputVariable("Generator Root Solver Iteration Count", + OutputProcessor::Unit::None, + DataGenerators::FuelCell(GeneratorNum).Report.RegulaFalsiIterations, + "System", + "Sum", + DataGenerators::FuelCell(GeneratorNum).Name); + } } } From 6cd202ad54fd091d28bcf73be155f91914161543 Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Tue, 12 Nov 2019 09:16:20 -0700 Subject: [PATCH 26/51] cleanup statics --- src/EnergyPlus/DataGenerators.hh | 12 ++++++--- src/EnergyPlus/FuelCellElectricGenerator.cc | 30 +++++++-------------- src/EnergyPlus/FuelCellElectricGenerator.hh | 23 ---------------- 3 files changed, 18 insertions(+), 47 deletions(-) diff --git a/src/EnergyPlus/DataGenerators.hh b/src/EnergyPlus/DataGenerators.hh index 42ef6b2e59f..2963ab8aa10 100644 --- a/src/EnergyPlus/DataGenerators.hh +++ b/src/EnergyPlus/DataGenerators.hh @@ -602,7 +602,7 @@ namespace DataGenerators { std::string NameFCAirSup; // name of air supply module for fuel cell FCAirSupplyDataStruct AirSup; // data for air supply module std::string NameFCFuelSup; // name of fuel supply module - int FuelSupNum; // indes for fuel supply module structure + int FuelSupNum; // index for fuel supply module structure std::string NameFCWaterSup; // name of water supply module FCWaterSupplyDataStruct WaterSup; // data for water supply module std::string NameFCAuxilHeat; // name of auxiliary heating module @@ -612,9 +612,9 @@ namespace DataGenerators { std::string NameElecStorage; // name of Battery module FCElecStorageDataStruct ElecStorage; // data for Battery module std::string NameInverter; // name of Inverter Module - FCInverterDataStruct Inverter; // data for INverter module + FCInverterDataStruct Inverter; // data for Inverter module std::string NameStackCooler; // name of Inverter Module - FCStackCoolerDataStruct StackCooler; // data for INverter module + FCStackCoolerDataStruct StackCooler; // data for Inverter module int CWLoopNum; // cooling water plant loop index number int CWLoopSideNum; // cooling water plant loop side index int CWBranchNum; // cooling water plant loop branch index @@ -626,11 +626,15 @@ namespace DataGenerators { Real64 QradZone; // radiative heat lost to surrounding zone int DynamicsControlID; Real64 TimeElapsed; // used to track when timestep has changed + bool InitGenerator; + bool MyEnvrnFlag_Init; + bool MyWarmupFlag_Init; + bool MyPlantScanFlag_Init; // Default Constructor FCDataStruct() : FuelSupNum(0), CWLoopNum(0), CWLoopSideNum(0), CWBranchNum(0), CWCompNum(0), ACPowerGen(0.0), QconvZone(0.0), QradZone(0.0), - DynamicsControlID(0), TimeElapsed(0.0) + DynamicsControlID(0), TimeElapsed(0.0), InitGenerator(true), MyEnvrnFlag_Init(true), MyWarmupFlag_Init(false), MyPlantScanFlag_Init(true) { } }; diff --git a/src/EnergyPlus/FuelCellElectricGenerator.cc b/src/EnergyPlus/FuelCellElectricGenerator.cc index 69ae87a1cb1..adc45186a22 100644 --- a/src/EnergyPlus/FuelCellElectricGenerator.cc +++ b/src/EnergyPlus/FuelCellElectricGenerator.cc @@ -3194,24 +3194,14 @@ namespace FuelCellElectricGenerator { static std::string const RoutineName("InitFuelCellGenerators"); - static bool InitGeneratorOnce(true); // flag for 1 time initialization - static Array1D_bool MyEnvrnFlag; // flag for init once at start of environment - static Array1D_bool MyWarmupFlag; // flag for init after warmup complete - static Array1D_bool MyPlantScanFlag; bool errFlag; // Do the one time initializations - if (InitGeneratorOnce) { - MyEnvrnFlag.allocate(DataGenerators::NumFuelCellGenerators); - MyWarmupFlag.allocate(DataGenerators::NumFuelCellGenerators); - MyPlantScanFlag.allocate(DataGenerators::NumFuelCellGenerators); - MyEnvrnFlag = true; - MyWarmupFlag = false; - InitGeneratorOnce = false; - MyPlantScanFlag = true; + if (DataGenerators::FuelCell(FCnum).InitGenerator) { + DataGenerators::FuelCell(FCnum).InitGenerator = false; } // end one time setups and inits - if (MyPlantScanFlag(FCnum) && allocated(DataPlant::PlantLoop)) { + if (DataGenerators::FuelCell(FCnum).MyPlantScanFlag_Init && allocated(DataPlant::PlantLoop)) { errFlag = false; PlantUtilities::ScanPlantLoopsForObject(DataGenerators::FuelCell(FCnum).NameExhaustHX, @@ -3232,11 +3222,11 @@ namespace FuelCellElectricGenerator { if (errFlag) { ShowFatalError("InitFuelCellGenerators: Program terminated due to previous condition(s)."); } - MyPlantScanFlag(FCnum) = false; + DataGenerators::FuelCell(FCnum).MyPlantScanFlag_Init = false; } // Do the Begin Environment initializations - if (DataGlobals::BeginEnvrnFlag && MyEnvrnFlag(FCnum) && !MyPlantScanFlag(FCnum)) { + if (DataGlobals::BeginEnvrnFlag && DataGenerators::FuelCell(FCnum).MyEnvrnFlag_Init && !DataGenerators::FuelCell(FCnum).MyPlantScanFlag_Init) { DataGenerators::FuelSupply(DataGenerators::FuelCell(FCnum).FuelSupNum).PfuelCompEl = 0.0; DataGenerators::FuelSupply(DataGenerators::FuelCell(FCnum).FuelSupNum).TfuelIntoFCPM = 0.0; @@ -3309,19 +3299,19 @@ namespace FuelCellElectricGenerator { DataGenerators::FuelCell(FCnum).CWBranchNum, DataGenerators::FuelCell(FCnum).CWCompNum); - MyEnvrnFlag(FCnum) = false; - MyWarmupFlag(FCnum) = true; + DataGenerators::FuelCell(FCnum).MyEnvrnFlag_Init = false; + DataGenerators::FuelCell(FCnum).MyWarmupFlag_Init = true; } // end environmental inits if (!DataGlobals::BeginEnvrnFlag) { - MyEnvrnFlag(FCnum) = true; + DataGenerators::FuelCell(FCnum).MyEnvrnFlag_Init = true; } - if (MyWarmupFlag(FCnum) && (!DataGlobals::WarmupFlag)) { + if (DataGenerators::FuelCell(FCnum).MyWarmupFlag_Init && (!DataGlobals::WarmupFlag)) { // need to reset initial state of charge at beginning of environment but after warm up is complete DataGenerators::FuelCell(FCnum).ElecStorage.LastTimeStepStateOfCharge = DataGenerators::FuelCell(FCnum).ElecStorage.StartingEnergyStored; DataGenerators::FuelCell(FCnum).ElecStorage.ThisTimeStepStateOfCharge = DataGenerators::FuelCell(FCnum).ElecStorage.StartingEnergyStored; - MyWarmupFlag(FCnum) = false; + DataGenerators::FuelCell(FCnum).MyWarmupFlag_Init = false; } // using and elapsed time method rather than FirstHVACIteration here diff --git a/src/EnergyPlus/FuelCellElectricGenerator.hh b/src/EnergyPlus/FuelCellElectricGenerator.hh index 807024970c4..8c5116edc6d 100644 --- a/src/EnergyPlus/FuelCellElectricGenerator.hh +++ b/src/EnergyPlus/FuelCellElectricGenerator.hh @@ -58,21 +58,9 @@ namespace EnergyPlus { namespace FuelCellElectricGenerator { - // Data - // MODULE PARAMETER DEFINITIONS - - // DERIVED TYPE DEFINITIONS - - // MODULE VARIABLE DECLARATIONS: extern bool GetFuelCellInput; // When TRUE, calls subroutine to read input file. extern Array1D_bool CheckEquipName; - // SUBROUTINE SPECIFICATIONS FOR MODULE FuelCell ElectricGenerator - - // PRIVATE SetupFuelAndAirConstituentData ! hardwired data for gas phase thermochemistry calcs - - // Functions - void SimFuelCellGenerator(int GeneratorType, // type of Generator std::string const &GeneratorName, // user specified name of Generator int &GeneratorIndex, @@ -80,19 +68,8 @@ namespace FuelCellElectricGenerator { Real64 MyLoad, // demand on electric generator bool FirstHVACIteration); - // End FuelCell Generator Module Driver Subroutines - //****************************************************************************** - - // Beginning of FuelCell Generator Module Get Input subroutines - //****************************************************************************** - void GetFuelCellGeneratorInput(); - // End of Get Input subroutines for the FuelCell Generator Module - - // Beginning of Generator model Subroutines - // ***************************************************************************** - void CalcFuelCellGeneratorModel(int GeneratorNum, // Generator number bool RunFlag, // TRUE when Generator operating Real64 MyLoad, // Generator demand From beea1450bb08a594ea641380580c51230129faf9 Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Tue, 12 Nov 2019 09:23:18 -0700 Subject: [PATCH 27/51] move counter to fuelCell struct --- src/EnergyPlus/DataGenerators.cc | 2 - src/EnergyPlus/DataGenerators.hh | 1 - src/EnergyPlus/FuelCellElectricGenerator.cc | 46 ++++++++++++--------- src/EnergyPlus/FuelCellElectricGenerator.hh | 5 ++- 4 files changed, 31 insertions(+), 23 deletions(-) diff --git a/src/EnergyPlus/DataGenerators.cc b/src/EnergyPlus/DataGenerators.cc index 144916fad8a..07d86418371 100644 --- a/src/EnergyPlus/DataGenerators.cc +++ b/src/EnergyPlus/DataGenerators.cc @@ -150,7 +150,6 @@ namespace DataGenerators { int NumFuelConstit(0); int NumGeneratorFuelSups(0); - int NumFuelCellGenerators(0); // number of SOFC Generators specified in input int NumMicroCHPs(0); int NumMicroCHPParams(0); // number of parameter sets for micro chp int NumGensWDynamics(0); // number of dynamics controls for generators @@ -167,7 +166,6 @@ namespace DataGenerators { { NumFuelConstit = 0; NumGeneratorFuelSups = 0; - NumFuelCellGenerators = 0; NumMicroCHPs = 0; NumMicroCHPParams = 0; NumGensWDynamics = 0; diff --git a/src/EnergyPlus/DataGenerators.hh b/src/EnergyPlus/DataGenerators.hh index 2963ab8aa10..1e4de14e23a 100644 --- a/src/EnergyPlus/DataGenerators.hh +++ b/src/EnergyPlus/DataGenerators.hh @@ -136,7 +136,6 @@ namespace DataGenerators { extern int NumFuelConstit; extern int NumGeneratorFuelSups; - extern int NumFuelCellGenerators; // number of SOFC Generators specified in input extern int NumMicroCHPs; extern int NumMicroCHPParams; // number of parameter sets for micro chp extern int NumGensWDynamics; // number of dynamics controls for generators diff --git a/src/EnergyPlus/FuelCellElectricGenerator.cc b/src/EnergyPlus/FuelCellElectricGenerator.cc index adc45186a22..9a2c2daaf81 100644 --- a/src/EnergyPlus/FuelCellElectricGenerator.cc +++ b/src/EnergyPlus/FuelCellElectricGenerator.cc @@ -99,9 +99,17 @@ namespace FuelCellElectricGenerator { // REFERENCES: // IEA/ECBCS Annex 42 model specification for Solid oxide and proton exchange membrane fuel cells - bool GetFuelCellInput(true); // When TRUE, calls subroutine to read input file. + int NumFuelCellGenerators(0); + bool GetFuelCellInput(true); Array1D_bool CheckEquipName; + void clear_state() + { + NumFuelCellGenerators = 0; + GetFuelCellInput = true; + CheckEquipName.deallocate(); + } + void SimFuelCellGenerator(int const EP_UNUSED(GeneratorType), // type of Generator std::string const &GeneratorName, // user specified name of Generator int &GeneratorIndex, @@ -132,9 +140,9 @@ namespace FuelCellElectricGenerator { GeneratorIndex = GenNum; } else { GenNum = GeneratorIndex; - if (GenNum > DataGenerators::NumFuelCellGenerators || GenNum < 1) { + if (GenNum > NumFuelCellGenerators || GenNum < 1) { ShowFatalError("SimFuelCellGenerator: Invalid GeneratorIndex passed=" + General::TrimSigDigits(GenNum) + - ", Number of FuelCell Generators=" + General::TrimSigDigits(DataGenerators::NumFuelCellGenerators) + ", Generator name=" + GeneratorName); + ", Number of FuelCell Generators=" + General::TrimSigDigits(NumFuelCellGenerators) + ", Generator name=" + GeneratorName); } if (CheckEquipName(GenNum)) { if (GeneratorName != DataGenerators::FuelCell(GenNum).Name) { @@ -176,19 +184,19 @@ namespace FuelCellElectricGenerator { bool ErrorsFound(false); // error flag DataIPShortCuts::cCurrentModuleObject = "Generator:FuelCell"; - DataGenerators::NumFuelCellGenerators = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); + NumFuelCellGenerators = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); - if (DataGenerators::NumFuelCellGenerators <= 0) { + if (NumFuelCellGenerators <= 0) { ShowSevereError("No " + DataIPShortCuts::cCurrentModuleObject + " equipment specified in input file"); ErrorsFound = true; } // ALLOCATE ARRAYS - DataGenerators::FuelCell.allocate(DataGenerators::NumFuelCellGenerators); // inits handled in derived type definitions - CheckEquipName.dimension(DataGenerators::NumFuelCellGenerators, true); + DataGenerators::FuelCell.allocate(NumFuelCellGenerators); // inits handled in derived type definitions + CheckEquipName.dimension(NumFuelCellGenerators, true); // first load in FuelCell names - for (int GeneratorNum = 1; GeneratorNum <= DataGenerators::NumFuelCellGenerators; ++GeneratorNum) { + for (int GeneratorNum = 1; GeneratorNum <= NumFuelCellGenerators; ++GeneratorNum) { inputProcessor->getObjectItem( DataIPShortCuts::cCurrentModuleObject, GeneratorNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat, _, _, DataIPShortCuts::cAlphaFieldNames, DataIPShortCuts::cNumericFieldNames); UtilityRoutines::IsNameEmpty(AlphArray(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); @@ -311,7 +319,7 @@ namespace FuelCellElectricGenerator { DataGenerators::FuelCell(thisFuelCell).FCPM.PelMax = NumArray(25); // check for other FuelCell using the same power module and fill - for (int otherFuelCell = thisFuelCell + 1; otherFuelCell <= DataGenerators::NumFuelCellGenerators; ++otherFuelCell) { + for (int otherFuelCell = thisFuelCell + 1; otherFuelCell <= NumFuelCellGenerators; ++otherFuelCell) { if (UtilityRoutines::SameString(DataGenerators::FuelCell(otherFuelCell).FCPM.Name, DataGenerators::FuelCell(thisFuelCell).FCPM.Name)) { DataGenerators::FuelCell(otherFuelCell).FCPM = DataGenerators::FuelCell(thisFuelCell).FCPM; } @@ -330,7 +338,7 @@ namespace FuelCellElectricGenerator { } // set fuel supply ID in Fuel cell structure - for (int GeneratorNum = 1; GeneratorNum <= DataGenerators::NumFuelCellGenerators; ++GeneratorNum) { + for (int GeneratorNum = 1; GeneratorNum <= NumFuelCellGenerators; ++GeneratorNum) { DataGenerators::FuelCell(GeneratorNum).FuelSupNum = UtilityRoutines::FindItemInList(DataGenerators::FuelCell(GeneratorNum).NameFCFuelSup, DataGenerators::FuelSupply); // Fuel Supply ID if (DataGenerators::FuelCell(GeneratorNum).FuelSupNum == 0) { @@ -483,7 +491,7 @@ namespace FuelCellElectricGenerator { } // check for other FuelCell using the same Air Supply module and fill - for (int otherFuelCell = thisFuelCell + 1; otherFuelCell <= DataGenerators::NumFuelCellGenerators; ++otherFuelCell) { + for (int otherFuelCell = thisFuelCell + 1; otherFuelCell <= NumFuelCellGenerators; ++otherFuelCell) { if (UtilityRoutines::SameString(DataGenerators::FuelCell(otherFuelCell).AirSup.Name, DataGenerators::FuelCell(thisFuelCell).AirSup.Name)) { DataGenerators::FuelCell(otherFuelCell).AirSup = DataGenerators::FuelCell(thisFuelCell).AirSup; } @@ -495,7 +503,7 @@ namespace FuelCellElectricGenerator { } } - for (int GeneratorNum = 1; GeneratorNum <= DataGenerators::NumFuelCellGenerators; ++GeneratorNum) { + for (int GeneratorNum = 1; GeneratorNum <= NumFuelCellGenerators; ++GeneratorNum) { // find molal fraction of oxygen in air supply int thisConstituent = UtilityRoutines::FindItem("Oxygen", DataGenerators::FuelCell(GeneratorNum).AirSup.ConstitName, DataGenerators::FuelCell(GeneratorNum).AirSup.NumConstituents); @@ -599,7 +607,7 @@ namespace FuelCellElectricGenerator { } // check for other FuelCell using the same Water Supply module and fill - for (int otherFuelCell = thisFuelCell + 1; otherFuelCell <= DataGenerators::NumFuelCellGenerators; ++otherFuelCell) { + for (int otherFuelCell = thisFuelCell + 1; otherFuelCell <= NumFuelCellGenerators; ++otherFuelCell) { if (UtilityRoutines::SameString(DataGenerators::FuelCell(otherFuelCell).WaterSup.Name, DataGenerators::FuelCell(thisFuelCell).WaterSup.Name)) { DataGenerators::FuelCell(otherFuelCell).WaterSup = DataGenerators::FuelCell(thisFuelCell).WaterSup; } @@ -660,7 +668,7 @@ namespace FuelCellElectricGenerator { // TODO finish Auxiliary heater // check for other FuelCell using the same Auxiliary Heating module and fill - for (int otherFuelCell = thisFuelCell + 1; otherFuelCell <= DataGenerators::NumFuelCellGenerators; ++otherFuelCell) { + for (int otherFuelCell = thisFuelCell + 1; otherFuelCell <= NumFuelCellGenerators; ++otherFuelCell) { if (UtilityRoutines::SameString(DataGenerators::FuelCell(otherFuelCell).AuxilHeat.Name, DataGenerators::FuelCell(thisFuelCell).AuxilHeat.Name)) { DataGenerators::FuelCell(otherFuelCell).AuxilHeat = DataGenerators::FuelCell(thisFuelCell).AuxilHeat; } @@ -791,7 +799,7 @@ namespace FuelCellElectricGenerator { DataGenerators::FuelCell(thisFuelCell).ElecStorage.StartingEnergyStored = NumArray(6); // check for other FuelCell using the same Electrical Storage and fill - for (int otherFuelCell = thisFuelCell + 1; otherFuelCell <= DataGenerators::NumFuelCellGenerators; ++otherFuelCell) { + for (int otherFuelCell = thisFuelCell + 1; otherFuelCell <= NumFuelCellGenerators; ++otherFuelCell) { if (UtilityRoutines::SameString(DataGenerators::FuelCell(otherFuelCell).ElecStorage.Name, DataGenerators::FuelCell(thisFuelCell).ElecStorage.Name)) { DataGenerators::FuelCell(otherFuelCell).ElecStorage = DataGenerators::FuelCell(thisFuelCell).ElecStorage; } @@ -843,7 +851,7 @@ namespace FuelCellElectricGenerator { } // check for other FuelCell using the same Inverter and fill - for (int otherFuelCell = thisFuelCell + 1; otherFuelCell <= DataGenerators::NumFuelCellGenerators; ++otherFuelCell) { + for (int otherFuelCell = thisFuelCell + 1; otherFuelCell <= NumFuelCellGenerators; ++otherFuelCell) { if (UtilityRoutines::SameString(DataGenerators::FuelCell(otherFuelCell).Inverter.Name, DataGenerators::FuelCell(thisFuelCell).Inverter.Name)) { DataGenerators::FuelCell(otherFuelCell).Inverter = DataGenerators::FuelCell(thisFuelCell).Inverter; } @@ -932,7 +940,7 @@ namespace FuelCellElectricGenerator { ShowFatalError("Errors found in getting input for fuel cell model "); } - for (int GeneratorNum = 1; GeneratorNum <= DataGenerators::NumFuelCellGenerators; ++GeneratorNum) { + for (int GeneratorNum = 1; GeneratorNum <= NumFuelCellGenerators; ++GeneratorNum) { SetupOutputVariable("Generator Produced Electric Power", OutputProcessor::Unit::W, DataGenerators::FuelCell(GeneratorNum).Report.ACPowerGen, @@ -3387,7 +3395,7 @@ namespace FuelCellElectricGenerator { static bool MyEnvrnFlag(true); - if (DataGenerators::NumFuelCellGenerators == 0) return; + if (NumFuelCellGenerators == 0) return; if (DataGlobals::BeginEnvrnFlag && MyEnvrnFlag) { for (auto &e : DataGenerators::FuelSupply) @@ -3416,7 +3424,7 @@ namespace FuelCellElectricGenerator { // this routine needs to do something for zone gains during sizing // first collect skin losses from different subsystems - for (int FCnum = 1; FCnum <= DataGenerators::NumFuelCellGenerators; ++FCnum) { + for (int FCnum = 1; FCnum <= NumFuelCellGenerators; ++FCnum) { Real64 TotalZoneHeatGain = DataGenerators::FuelCell(FCnum).AirSup.QskinLoss + DataGenerators::FuelSupply(DataGenerators::FuelCell(FCnum).FuelSupNum).QskinLoss + DataGenerators::FuelCell(FCnum).WaterSup.QskinLoss + DataGenerators::FuelCell(FCnum).AuxilHeat.QskinLoss + DataGenerators::FuelCell(FCnum).FCPM.QdotSkin; // intake Blower losses to zone | fuel compressor losses to zone | water pump losses to diff --git a/src/EnergyPlus/FuelCellElectricGenerator.hh b/src/EnergyPlus/FuelCellElectricGenerator.hh index 8c5116edc6d..283d52bc348 100644 --- a/src/EnergyPlus/FuelCellElectricGenerator.hh +++ b/src/EnergyPlus/FuelCellElectricGenerator.hh @@ -58,9 +58,12 @@ namespace EnergyPlus { namespace FuelCellElectricGenerator { - extern bool GetFuelCellInput; // When TRUE, calls subroutine to read input file. + extern bool GetFuelCellInput; + extern int NumFuelCellGenerators; extern Array1D_bool CheckEquipName; + void clear_state(); + void SimFuelCellGenerator(int GeneratorType, // type of Generator std::string const &GeneratorName, // user specified name of Generator int &GeneratorIndex, From cf04ef46b411bef60d7b0729397c41ef8f917ffc Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Tue, 12 Nov 2019 09:48:59 -0700 Subject: [PATCH 28/51] move FCGen struct to the right .hh file --- src/EnergyPlus/DataGenerators.cc | 2 - src/EnergyPlus/DataGenerators.hh | 497 ----- src/EnergyPlus/FuelCellElectricGenerator.cc | 1908 +++++++++---------- src/EnergyPlus/FuelCellElectricGenerator.hh | 503 ++++- 4 files changed, 1454 insertions(+), 1456 deletions(-) diff --git a/src/EnergyPlus/DataGenerators.cc b/src/EnergyPlus/DataGenerators.cc index 07d86418371..fb8ba05f496 100644 --- a/src/EnergyPlus/DataGenerators.cc +++ b/src/EnergyPlus/DataGenerators.cc @@ -155,7 +155,6 @@ namespace DataGenerators { int NumGensWDynamics(0); // number of dynamics controls for generators // Object Data - Array1D FuelCell; // dimension to number of machines Array1D GasPhaseThermoChemistryData; Array1D FuelSupply; // fuel supply (reused across various) Array1D MicroCHP; @@ -169,7 +168,6 @@ namespace DataGenerators { NumMicroCHPs = 0; NumMicroCHPParams = 0; NumGensWDynamics = 0; - FuelCell.deallocate(); GasPhaseThermoChemistryData.deallocate(); FuelSupply.deallocate(); MicroCHP.deallocate(); diff --git a/src/EnergyPlus/DataGenerators.hh b/src/EnergyPlus/DataGenerators.hh index 1e4de14e23a..8f1485f4dc2 100644 --- a/src/EnergyPlus/DataGenerators.hh +++ b/src/EnergyPlus/DataGenerators.hh @@ -142,502 +142,6 @@ namespace DataGenerators { // Types - struct FCPowerModuleStruct - { - // Members - // user input data - std::string Name; // name of this PowerModule data - int EffMode; // mode for efficiency curves - int EffCurveID; // pointer to curve for efficiency - Real64 NomEff; // nominal efficiency - Real64 NomPel; // nominal power rate at rating point - int NumCycles; // number of start stop cycles - Real64 CyclingDegradRat; // rate of degradation from cycles - Real64 NumRunHours; // number of hours of operation - Real64 OperateDegradRat; // rate of degradation from run time (per hour) - Real64 ThreshRunHours; // number of hours before degradation starts - Real64 UpTranLimit; // power up transient limit - Real64 DownTranLimit; // power down tran limit - Real64 StartUpTime; // time for start up [hours] - Real64 StartUpFuel; // fuel use during start up - Real64 StartUpElectConsum; // electricity used during start up - Real64 StartUpElectProd; // electricity produced during start up - Real64 ShutDownTime; // time to shut down [hours] - Real64 ShutDownFuel; // fuel consumed during shut down - Real64 ShutDownElectConsum; // Elect consumed during shut down - Real64 ANC0; // Ancilliary Loads constant term - Real64 ANC1; // Ancilliary Loads linear term - int SkinLossMode; // how are skin losses determined - std::string ZoneName; - int ZoneID; // "pointer" to zone with component in it - Real64 RadiativeFract; - Real64 QdotSkin; - Real64 UAskin; - int SkinLossCurveID; - int WaterSupplyCurveID; // pointer to curve for water use in reforming - Real64 NdotDilutionAir; // user defined constant flow of dilution air (kmol/sec) - Real64 StackHeatLossToDilution; // (watts) - std::string DilutionInletNodeName; // dilution -> AirHR ?? added air heat recovery path - int DilutionInletNode; // pointer to node for inlet - std::string DilutionExhaustNodeName; - int DilutionExhaustNode; // pointer to node getting exhaust - Real64 PelMin; // minimum operating point for FCPM electrical power Pel - Real64 PelMax; // maximum operating point for FCPM electrical power Pel - // Calculated values and input from elsewhere - Real64 Pel; // current DC electrical power produced - Real64 PelLastTimeStep; - Real64 Eel; // power module efficiency - Real64 QdotStackCool; // Heat removed by stack cooler - Real64 FractionalDayofLastStartUp; // fractional days into simulation - Real64 FractionalDayofLastShutDown; // fractional Days into simulations - bool HasBeenOn; - bool DuringShutDown; - bool DuringStartUp; - Real64 NdotFuel; // molar fuel use rate. (kmol/sec) - Real64 TotFuelInEnthalphy; // Enthalpy of fuel coming into FCPM (watts) - Real64 NdotProdGas; // (kmol/sec) - Array1D ConstitMolalFract; - Array1D_int GasLibID; // lookup ID in Gas Phase ThermoChemistry Structure Array - Real64 TprodGasLeavingFCPM; - Real64 NdotAir; // molar air use rate (kmol/sec) - Real64 TotAirInEnthalphy; // Enthalpy of air coming nto FCPM energy balance (watts) - Real64 NdotLiqwater; // molar water use rate (kmol/sec) - Real64 TwaterInlet; - Real64 WaterInEnthalpy; // Enthalpy of liquid water used for reforming (watts) - Real64 DilutionAirInEnthalpy; // Enthalpy of Dilution air coming into FCPM (watts) - Real64 DilutionAirOutEnthalpy; - Real64 PelancillariesAC; // ancillary power (watts) - Real64 TotProdGasEnthalphy; // Enthalphy of product gases leaving FCPM (watts) - Real64 WaterOutEnthalpy; // enthalpy of vapor from water used for reforming - int SeqSubstitIter; - int RegulaFalsiIter; - - // Default Constructor - FCPowerModuleStruct() - : EffMode(0), EffCurveID(0), NomEff(0.0), NomPel(0.0), NumCycles(0), CyclingDegradRat(0.0), NumRunHours(0.0), OperateDegradRat(0.0), - ThreshRunHours(0.0), UpTranLimit(0.0), DownTranLimit(0.0), StartUpTime(0.0), StartUpFuel(0.0), StartUpElectConsum(0.0), - StartUpElectProd(0.0), ShutDownTime(0.0), ShutDownFuel(0.0), ShutDownElectConsum(0.0), ANC0(0.0), ANC1(0.0), SkinLossMode(0), ZoneID(0), - RadiativeFract(0.0), QdotSkin(0.0), UAskin(0.0), SkinLossCurveID(0), WaterSupplyCurveID(0), NdotDilutionAir(0.0), - StackHeatLossToDilution(0.0), DilutionInletNode(0), DilutionExhaustNode(0), PelMin(0.0), PelMax(0.0), Pel(0.0), PelLastTimeStep(0.0), - Eel(0.0), QdotStackCool(0.0), FractionalDayofLastStartUp(0.0), FractionalDayofLastShutDown(0.0), HasBeenOn(true), DuringShutDown(false), - DuringStartUp(false), NdotFuel(0.0), TotFuelInEnthalphy(0.0), NdotProdGas(0.0), ConstitMolalFract(14, 0.0), GasLibID(14, 0), - TprodGasLeavingFCPM(0.0), NdotAir(0.0), TotAirInEnthalphy(0.0), NdotLiqwater(0.0), TwaterInlet(0.0), WaterInEnthalpy(0.0), - DilutionAirInEnthalpy(0.0), DilutionAirOutEnthalpy(0.0), PelancillariesAC(0.0), TotProdGasEnthalphy(0.0), WaterOutEnthalpy(0.0), - SeqSubstitIter(0), RegulaFalsiIter(0) - { - } - }; - - struct FCAirSupplyDataStruct - { - // Members - // user input data - std::string Name; // name of this - std::string NodeName; // Air supply node name - int SupNodeNum; // Air supply node ID - int BlowerPowerCurveID; // "pointer" to blower power quadratic - Real64 BlowerHeatLossFactor; // alpha for blower heat loss fraction - int AirSupRateMode; // control for modeling method used to deterime supply air flow rate - Real64 Stoics; // excess air ratio - int AirFuncPelCurveID; // "pointer" to curve for air as function of power - Real64 AirTempCoeff; // coeff a3 in equ 16. - int AirFuncNdotCurveID; // "pointer" to curve for air as function of fuel flow rate - int IntakeRecoveryMode; - int ConstituentMode; // how are air data input - int NumConstituents; - Array1D_string ConstitName; - Array1D ConstitMolalFract; - // Calculated values and input from elsewhere - Array1D_int GasLibID; // lookup ID in Gas Phase ThermoChemistry Structure Array - Real64 O2fraction; - Real64 TairIntoBlower; // temperature entering blower - Real64 TairIntoFCPM; // temperature leaving blower and entering FCPM - Real64 PairCompEl; // power drawn by compressor - Real64 QskinLoss; // pumping losses for zone - Real64 QintakeRecovery; // heat recovered on intake air by accessories - - // Default Constructor - FCAirSupplyDataStruct() - : SupNodeNum(0), BlowerPowerCurveID(0), BlowerHeatLossFactor(0.0), AirSupRateMode(0), Stoics(0.0), AirFuncPelCurveID(0), - AirTempCoeff(0.0), AirFuncNdotCurveID(0), IntakeRecoveryMode(0), ConstituentMode(0), NumConstituents(0), ConstitName(14), - ConstitMolalFract(14, 0.0), GasLibID(14, 0), O2fraction(0.0), TairIntoBlower(0.0), TairIntoFCPM(0.0), PairCompEl(0.0), QskinLoss(0.0), - QintakeRecovery(0.0) - { - } - }; - - struct FCStackCoolerDataStruct - { - // Members - // user input data - std::string Name; // name of this stack cooler module - std::string WaterInNodeName; // HR Water Inlet Node - int WaterInNode; // HR Water Outlet Node ID - std::string WaterOutNodeName; // HR water outlet Node name - int WaterOutNode; // HR Water outlet Node ID - Real64 TstackNom; // nominal fuel cell stack temperature - Real64 TstackActual; // actual fuel cell stack temperature - Real64 r0; // stack cooling power coefficient r0 - Real64 r1; // stack cooling power coefficient r1 - Real64 r2; // stack cooling power coefficient r2 - Real64 r3; // stack cooling power coefficient r3 - Real64 MdotStackCoolant; // stack coolant flow rate kg/s - Real64 UAs_cool; // stack heat transfer coef - Real64 Fs_cogen; - Real64 As_cogen; - Real64 MdotCogenNom; - Real64 hCogenNom; - Real64 ns; - Real64 PstackPumpEl; - Real64 PmpPowerLossFactor; - Real64 f0; - Real64 f1; - Real64 f2; - // calculated and from elsewhere - bool StackCoolerPresent; // control modeling - Real64 qs_cool; - Real64 qs_air; - - // Default Constructor - FCStackCoolerDataStruct() - : WaterInNode(0), WaterOutNode(0), TstackNom(0.0), TstackActual(0.0), r0(0.0), r1(0.0), r2(0.0), r3(0.0), MdotStackCoolant(0.0), - UAs_cool(0.0), Fs_cogen(0.0), As_cogen(0.0), MdotCogenNom(0.0), hCogenNom(0.0), ns(0.0), PstackPumpEl(0.0), PmpPowerLossFactor(0.0), - f0(0.0), f1(0.0), f2(0.0), StackCoolerPresent(false), qs_cool(0.0), qs_air(0.0) - { - } - }; - - struct FCWaterSupplyDataStruct - { - // Members - std::string Name; // name of this water supply module - int WaterTempMode; // temperature of water inlet determination - std::string NodeName; // node name for temperature at input - int NodeNum; // node number for temperature at input - int SchedNum; // water temperature at input - int WaterSupRateCurveID; // "pointer" to water flow rate curve as a function of fuel rate - int PmpPowerCurveID; // "pointer to Pump power curve as a function of water flow Rate - Real64 PmpPowerLossFactor; // Pump heat loss factor - // calculated data - bool IsModeled; - Real64 TwaterIntoCompress; // inlet Water Temperature - Real64 TwaterIntoFCPM; // pumped water temp - Real64 PwaterCompEl; // water pump power - Real64 QskinLoss; // pumping losses for zone - - // Default Constructor - FCWaterSupplyDataStruct() - : WaterTempMode(0), NodeNum(0), SchedNum(0), WaterSupRateCurveID(0), PmpPowerCurveID(0), PmpPowerLossFactor(0.0), IsModeled(true), - TwaterIntoCompress(0.0), TwaterIntoFCPM(0.0), PwaterCompEl(0.0), QskinLoss(0.0) - { - } - }; - - struct FCAuxilHeatDataStruct - { - // Members - std::string Name; // name of this auxiliary heating module - std::string ZoneName; - int ZoneID; - Real64 UASkin; // for skin losses to zone - Real64 ExcessAirRAT; - Real64 ANC0; - Real64 ANC1; - int SkinLossDestination; // control mode for where lost heat goes - Real64 MaxPowerW; - Real64 MinPowerW; - Real64 MaxPowerkmolperSec; - Real64 MinPowerkmolperSec; - // calculated and from elsewhere - int NumConstituents; - Real64 TauxMix; - Real64 NdotAuxMix; - Array1D ConstitMolalFract; - Array1D_int GasLibID; // lookup ID in Gas Phase ThermoChemistry Structure Array - Real64 QskinLoss; // Heat lost to room - Real64 QairIntake; // heat into intake air - - // Default Constructor - FCAuxilHeatDataStruct() - : ZoneID(0), UASkin(0.0), ExcessAirRAT(0.0), ANC0(0.0), ANC1(0.0), SkinLossDestination(0), MaxPowerW(0.0), MinPowerW(0.0), - MaxPowerkmolperSec(0.0), MinPowerkmolperSec(0.0), NumConstituents(0), TauxMix(0.0), NdotAuxMix(0.0), ConstitMolalFract(14, 0.0), - GasLibID(14, 0), QskinLoss(0.0), QairIntake(0.0) - { - } - }; - - struct FCExhaustHXDataStruct - { - // Members - // user defined variables - std::string Name; // name of this exhaust gas heat recovery - std::string WaterInNodeName; // HR Water Inlet Node - int WaterInNode; // HR Water Outlet Node ID - std::string WaterOutNodeName; // HR water outlet Node name - int WaterOutNode; // HR Water outlet Node ID - Real64 WaterVolumeFlowMax; // HR water flow rate max avail - std::string ExhaustOutNodeName; // air node for exhaust flow - int ExhaustOutNode; // Exhaust Air node ID - int HXmodelMode; // Heat Exchanger Calculation Method - Real64 HXEffect; // Heat Exchanger Effectiveness (method 1) - Real64 hxs0; // (method 2) - Real64 hxs1; // (method 2) - Real64 hxs2; // (method 2) - Real64 hxs3; // (method 2) - Real64 hxs4; // (method 2) - Real64 h0gas; // (method 3) - Real64 NdotGasRef; // (method 3) - Real64 nCoeff; // (method 3) - Real64 AreaGas; // (method 3) - Real64 h0Water; // (method 3) - Real64 NdotWaterRef; // (method 3) - Real64 mCoeff; // (method 3) - Real64 AreaWater; // (method 3) - Real64 Fadjust; // (method 3) - Real64 l1Coeff; // (method 4) - Real64 l2Coeff; // (method 4) - Real64 CondensationThresholdTemp; // (method 4) [degrees C] - // calculated - Real64 qHX; // heat flow from gas stream to water - Real64 THXexh; // temperature of exhaust gases leaving heat exchanger. - Real64 WaterMassFlowRateDesign; // Design level of water flow rate - Real64 WaterMassFlowRate; // water flow rate in plant loop - Real64 WaterInletTemp; - Real64 WaterVaporFractExh; // water vapor fraction in exhaust gas stream. - Real64 CondensateRate; // water condensation rate. - Array1D ConstitMolalFract; - Array1D_int GasLibID; // lookup ID in Gas Phase ThermoChemistry Structure Array - Real64 NdotHXleaving; - Real64 WaterOutletTemp; - Real64 WaterOutletEnthalpy; - - // Default Constructor - FCExhaustHXDataStruct() - : WaterInNode(0), WaterOutNode(0), WaterVolumeFlowMax(0.0), ExhaustOutNode(0), HXmodelMode(0), HXEffect(0.0), hxs0(0.0), hxs1(0.0), - hxs2(0.0), hxs3(0.0), hxs4(0.0), h0gas(0.0), NdotGasRef(0.0), nCoeff(0.0), AreaGas(0.0), h0Water(0.0), NdotWaterRef(0.0), mCoeff(0.0), - AreaWater(0.0), Fadjust(0.0), l1Coeff(0.0), l2Coeff(0.0), CondensationThresholdTemp(0.0), qHX(0.0), THXexh(0.0), - WaterMassFlowRateDesign(0.0), WaterMassFlowRate(0.0), WaterInletTemp(0.0), WaterVaporFractExh(0.0), CondensateRate(0.0), - ConstitMolalFract(14, 0.0), GasLibID(14, 0), NdotHXleaving(0.0), WaterOutletTemp(0.0), WaterOutletEnthalpy(0.0) - { - } - }; - - struct BatteryDichargeDataStruct - { - // Members - // user defined variables - std::string Name; // name of this battery data set - Real64 NumInSeries; - Real64 NumInParallel; - Real64 NominalVoltage; - Real64 LowVoltsDischarged; // not used - int NumTablePairs; - Array1D DischargeCurrent; // amps - Array1D DischargeTime; // hours - // calculated variables - Real64 k; // parameter in Manwell McGowan model - Real64 c; // parameter in Manwell McGowan model - Real64 qmax; // parameter in Manwell McGowan model - - // Default Constructor - BatteryDichargeDataStruct() - : NumInSeries(0.0), NumInParallel(0.0), NominalVoltage(0.0), LowVoltsDischarged(0.0), NumTablePairs(0), k(0.0), c(0.0), qmax(0.0) - { - } - }; - - struct FCElecStorageDataStruct - { - // Members - // user defined variables - std::string Name; // name of this electrical storage module - int StorageModelMode; - Real64 StartingEnergyStored; // joules inside - Real64 EnergeticEfficCharge; // for - Real64 EnergeticEfficDischarge; - Real64 MaxPowerDraw; // for simple bucket method 0 - Real64 MaxPowerStore; // for simple bucket method 0 - Real64 NominalVoltage; - Real64 NominalEnergyCapacity; // [J] - // calculated and from elsewhere vars - Real64 ThisTimeStepStateOfCharge; // [J] - Real64 LastTimeStepStateOfCharge; // [J] - Real64 PelNeedFromStorage; - Real64 IdesiredDischargeCurrent; - Real64 PelFromStorage; // power - Real64 IfromStorage; // current this timestepm - Real64 PelIntoStorage; - Real64 QairIntake; // heat into intake air - // nested structures - BatteryDichargeDataStruct Battery; - - // Default Constructor - FCElecStorageDataStruct() - : StorageModelMode(0), StartingEnergyStored(0.0), EnergeticEfficCharge(0.0), EnergeticEfficDischarge(0.0), MaxPowerDraw(0.0), - MaxPowerStore(0.0), NominalVoltage(0.0), NominalEnergyCapacity(0.0), ThisTimeStepStateOfCharge(0.0), LastTimeStepStateOfCharge(0.0), - PelNeedFromStorage(0.0), IdesiredDischargeCurrent(0.0), PelFromStorage(0.0), IfromStorage(0.0), PelIntoStorage(0.0), QairIntake(0.0) - { - } - }; - - struct FCInverterDataStruct - { - // Members - // user-defined data - std::string Name; // name of this inverter - int EffMode; // efficiency calculation mode - Real64 ConstEff; - int EffQuadraticCurveID; - // calculated and from elsewhere - Real64 PCUlosses; - Real64 QairIntake; - - // Default Constructor - FCInverterDataStruct() : EffMode(0), ConstEff(0.0), EffQuadraticCurveID(0), PCUlosses(0.0), QairIntake(0.0) - { - } - }; - - struct FCReportDataStruct // these are all for reporting only! - { - // Members - Real64 ACPowerGen; // reporting: power (W) - Real64 ACEnergyGen; // reporting: energy (J) - Real64 QdotExhaust; // reporting: exhaust gas heat recovered (W) - Real64 TotalHeatEnergyRec; // reporting: total heat recovered (J) - Real64 ExhaustEnergyRec; // reporting: exhaust gas heat recovered (J) - Real64 FuelEnergyLHV; // reporting: Fuel Energy used in Lower Heating Value(J) - Real64 FuelEnergyUseRateLHV; // reporting: Fuel Energy used in Lower Heating Value(W) - Real64 FuelEnergyHHV; // reporting: Fuel Energy used in Lower Heating Value(J) - Real64 FuelEnergyUseRateHHV; // reporting: Fuel Energy used in Lower Heating Value(W) - Real64 FuelRateMdot; // (Kg/s) - Real64 HeatRecInletTemp; // reporting: Heat Recovery Loop Inlet Temperature (C) - Real64 HeatRecOutletTemp; // reporting: Heat Recovery Loop Outlet Temperature (C) - Real64 HeatRecMdot; // reporting: Heat Recovery Loop Mass flow rate (kg/s) - // air supply and blower - Real64 TairInlet; // State point 1 - Real64 TairIntoFCPM; // Temperature at State point 4 - Real64 NdotAir; // air flow in kmol/sec - Real64 TotAirInEnthalphy; // Enthalpy at State point 4 - Real64 BlowerPower; // electrical power used by air supply blower - Real64 BlowerEnergy; // electrical energy used by air supply blower - Real64 BlowerSkinLoss; // heat rate of losses by blower - // fuel supply and compressor - Real64 TfuelInlet; // State point 2 [C] - Real64 TfuelIntoFCPM; // state point 5 [C] - Real64 NdotFuel; // fuel flow in [kmol/sec] - Real64 TotFuelInEnthalpy; // state point 5 [W] - Real64 FuelCompressPower; // electrical power used by fuel supply compressor [W] - Real64 FuelCompressEnergy; // electrical energy used by fuel supply compressor [J] - Real64 FuelCompressSkinLoss; // heat rate of losses.by fuel supply compressor [W] - // reformer water supply - Real64 TwaterInlet; // State point 3 - Real64 TwaterIntoFCPM; // State point 6 - Real64 NdotWater; // water flow in kmol/sec (reformer water) - Real64 WaterPumpPower; // electrical power used by water pump [W] - Real64 WaterPumpEnergy; // electrical energy used by water pump [J] - Real64 WaterIntoFCPMEnthalpy; // state point 6 - // product (exhaust) gas leaving power module - Real64 TprodGas; // State point 7 Product Gas temperature - Real64 EnthalProdGas; // state point 7 product gas enthalpy - Real64 NdotProdGas; // point 7 flow rate [kmol/sec] - Real64 NdotProdAr; // argon flow rate at point 7 - Real64 NdotProdCO2; // carbon dioxide flow rate at point 7 - Real64 NdotProdH2O; // water vapor flow rate at point 7 - Real64 NdotProdN2; // nitrogen flow rate at point 7 - Real64 NdotProdO2; // oxygen flow rate at point 7 - // heat exchanger for water to exhaust heat recovery - Real64 qHX; // heat flow from gas stream to water [W] - Real64 HXenergy; // energy from gas stream to water [J] - Real64 THXexh; // temperature of exhaust gases leaving heat exchanger. - Real64 WaterVaporFractExh; // water vapor fraction in exhaust gas stream - // relative to water vapor entering HX (NdotH20/Ndoaux-mix) - Real64 CondensateRate; // water condensation rate [kmol/s] - int SeqSubstIterations; // number of iterations in SOFC loop - int RegulaFalsiIterations; // number of iterations in Tproduct gas solving - Real64 ACancillariesPower; - Real64 ACancillariesEnergy; - Real64 PCUlosses; // power conditioning Unit losses - Real64 DCPowerGen; // Pel, Power module power level [W] - Real64 DCPowerEff; // Eel, power module efficiency [] - Real64 ElectEnergyinStorage; // State of charge in Electrical Storage [J] - Real64 StoredPower; // Power added to Electrical Storage [W] - Real64 StoredEnergy; // energy added to Electrical STorage [J] - Real64 DrawnPower; // Power drawn from Electrical STorage [W] - Real64 DrawnEnergy; // Energy drawn from Electrical STorage [J] - Real64 SkinLossPower; // heat loss to surrounding zone [W] - Real64 SkinLossEnergy; // heat loss to surround zone [J] - Real64 SkinLossConvect; // convective heat loss to zone [W] - Real64 SkinLossRadiat; // radiative heat loss to zone [W} - Real64 ElectEfficiency; - Real64 ThermalEfficiency; - Real64 OverallEfficiency; - Real64 ExergyEfficiency; - - // Default Constructor - FCReportDataStruct() - : ACPowerGen(0.0), ACEnergyGen(0.0), QdotExhaust(0.0), TotalHeatEnergyRec(0.0), ExhaustEnergyRec(0.0), FuelEnergyLHV(0.0), - FuelEnergyUseRateLHV(0.0), FuelEnergyHHV(0.0), FuelEnergyUseRateHHV(0.0), FuelRateMdot(0.0), HeatRecInletTemp(0.0), - HeatRecOutletTemp(0.0), HeatRecMdot(0.0), TairInlet(0.0), TairIntoFCPM(0.0), NdotAir(0.0), TotAirInEnthalphy(0.0), BlowerPower(0.0), - BlowerEnergy(0.0), BlowerSkinLoss(0.0), TfuelInlet(0.0), TfuelIntoFCPM(0.0), NdotFuel(0.0), TotFuelInEnthalpy(0.0), - FuelCompressPower(0.0), FuelCompressEnergy(0.0), FuelCompressSkinLoss(0.0), TwaterInlet(0.0), TwaterIntoFCPM(0.0), NdotWater(0.0), - WaterPumpPower(0.0), WaterPumpEnergy(0.0), WaterIntoFCPMEnthalpy(0.0), TprodGas(0.0), EnthalProdGas(0.0), NdotProdGas(0.0), - NdotProdAr(0.0), NdotProdCO2(0.0), NdotProdH2O(0.0), NdotProdN2(0.0), NdotProdO2(0.0), qHX(0.0), HXenergy(0.0), THXexh(0.0), - WaterVaporFractExh(0.0), CondensateRate(0.0), SeqSubstIterations(0), RegulaFalsiIterations(0), ACancillariesPower(0.0), - ACancillariesEnergy(0.0), PCUlosses(0.0), DCPowerGen(0.0), DCPowerEff(0.0), ElectEnergyinStorage(0.0), StoredPower(0.0), - StoredEnergy(0.0), DrawnPower(0.0), DrawnEnergy(0.0), SkinLossPower(0.0), SkinLossEnergy(0.0), SkinLossConvect(0.0), - SkinLossRadiat(0.0), ElectEfficiency(0.0), ThermalEfficiency(0.0), OverallEfficiency(0.0), ExergyEfficiency(0.0) - { - } - }; - - struct FCDataStruct - { - // Members - // from input data and nested types for subsystems - std::string Name; // user identifier - std::string NameFCPM; // name of FC Power Module - FCPowerModuleStruct FCPM; // data for Power Module - std::string NameFCAirSup; // name of air supply module for fuel cell - FCAirSupplyDataStruct AirSup; // data for air supply module - std::string NameFCFuelSup; // name of fuel supply module - int FuelSupNum; // index for fuel supply module structure - std::string NameFCWaterSup; // name of water supply module - FCWaterSupplyDataStruct WaterSup; // data for water supply module - std::string NameFCAuxilHeat; // name of auxiliary heating module - FCAuxilHeatDataStruct AuxilHeat; // data for auxiliary heating module - std::string NameExhaustHX; // name of Exhaust HX module - FCExhaustHXDataStruct ExhaustHX; // data for Exhaust heat exchanger module - std::string NameElecStorage; // name of Battery module - FCElecStorageDataStruct ElecStorage; // data for Battery module - std::string NameInverter; // name of Inverter Module - FCInverterDataStruct Inverter; // data for Inverter module - std::string NameStackCooler; // name of Inverter Module - FCStackCoolerDataStruct StackCooler; // data for Inverter module - int CWLoopNum; // cooling water plant loop index number - int CWLoopSideNum; // cooling water plant loop side index - int CWBranchNum; // cooling water plant loop branch index - int CWCompNum; // cooling water plant loop component index - FCReportDataStruct Report; // data for reporting as E+ output variables - // calculated whole-system level variables - Real64 ACPowerGen; // Net output from SOFC unit - Real64 QconvZone; // convective heat lost to surrounding zone - Real64 QradZone; // radiative heat lost to surrounding zone - int DynamicsControlID; - Real64 TimeElapsed; // used to track when timestep has changed - bool InitGenerator; - bool MyEnvrnFlag_Init; - bool MyWarmupFlag_Init; - bool MyPlantScanFlag_Init; - - // Default Constructor - FCDataStruct() - : FuelSupNum(0), CWLoopNum(0), CWLoopSideNum(0), CWBranchNum(0), CWCompNum(0), ACPowerGen(0.0), QconvZone(0.0), QradZone(0.0), - DynamicsControlID(0), TimeElapsed(0.0), InitGenerator(true), MyEnvrnFlag_Init(true), MyWarmupFlag_Init(false), MyPlantScanFlag_Init(true) - { - } - }; - struct GeneratorFuelSupplyDataStruct { // Members @@ -960,7 +464,6 @@ namespace DataGenerators { }; // Object Data - extern Array1D FuelCell; // dimension to number of machines extern Array1D GasPhaseThermoChemistryData; extern Array1D FuelSupply; // fuel supply (reused across various) extern Array1D MicroCHP; diff --git a/src/EnergyPlus/FuelCellElectricGenerator.cc b/src/EnergyPlus/FuelCellElectricGenerator.cc index 9a2c2daaf81..3c37ad7a9ab 100644 --- a/src/EnergyPlus/FuelCellElectricGenerator.cc +++ b/src/EnergyPlus/FuelCellElectricGenerator.cc @@ -102,12 +102,14 @@ namespace FuelCellElectricGenerator { int NumFuelCellGenerators(0); bool GetFuelCellInput(true); Array1D_bool CheckEquipName; + Array1D FuelCell; // dimension to number of machines void clear_state() { NumFuelCellGenerators = 0; GetFuelCellInput = true; CheckEquipName.deallocate(); + FuelCell.deallocate(); } void SimFuelCellGenerator(int const EP_UNUSED(GeneratorType), // type of Generator @@ -135,7 +137,7 @@ namespace FuelCellElectricGenerator { } if (GeneratorIndex == 0) { - GenNum = UtilityRoutines::FindItemInList(GeneratorName, DataGenerators::FuelCell); + GenNum = UtilityRoutines::FindItemInList(GeneratorName, FuelCell); if (GenNum == 0) ShowFatalError("SimFuelCellGenerator: Specified Generator not one of Valid FuelCell Generators " + GeneratorName); GeneratorIndex = GenNum; } else { @@ -145,9 +147,9 @@ namespace FuelCellElectricGenerator { ", Number of FuelCell Generators=" + General::TrimSigDigits(NumFuelCellGenerators) + ", Generator name=" + GeneratorName); } if (CheckEquipName(GenNum)) { - if (GeneratorName != DataGenerators::FuelCell(GenNum).Name) { + if (GeneratorName != FuelCell(GenNum).Name) { ShowFatalError("SimFuelCellGenerator: Invalid GeneratorIndex passed=" + General::TrimSigDigits(GenNum) + - ", Generator name=" + GeneratorName + ", stored Generator Name for that index=" + DataGenerators::FuelCell(GenNum).Name); + ", Generator name=" + GeneratorName + ", stored Generator Name for that index=" + FuelCell(GenNum).Name); } CheckEquipName(GenNum) = false; } @@ -192,7 +194,7 @@ namespace FuelCellElectricGenerator { } // ALLOCATE ARRAYS - DataGenerators::FuelCell.allocate(NumFuelCellGenerators); // inits handled in derived type definitions + FuelCell.allocate(NumFuelCellGenerators); // inits handled in derived type definitions CheckEquipName.dimension(NumFuelCellGenerators, true); // first load in FuelCell names @@ -201,17 +203,17 @@ namespace FuelCellElectricGenerator { DataIPShortCuts::cCurrentModuleObject, GeneratorNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat, _, _, DataIPShortCuts::cAlphaFieldNames, DataIPShortCuts::cNumericFieldNames); UtilityRoutines::IsNameEmpty(AlphArray(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); - DataGenerators::FuelCell(GeneratorNum).Name = AlphArray(1); - DataGenerators::FuelCell(GeneratorNum).NameFCPM = AlphArray(2); - DataGenerators::FuelCell(GeneratorNum).NameFCAirSup = AlphArray(3); - DataGenerators::FuelCell(GeneratorNum).NameFCFuelSup = AlphArray(4); - DataGenerators::FuelCell(GeneratorNum).NameFCWaterSup = AlphArray(5); - DataGenerators::FuelCell(GeneratorNum).NameFCAuxilHeat = AlphArray(6); - DataGenerators::FuelCell(GeneratorNum).NameExhaustHX = AlphArray(7); - DataGenerators::FuelCell(GeneratorNum).NameElecStorage = AlphArray(8); - DataGenerators::FuelCell(GeneratorNum).NameInverter = AlphArray(9); + FuelCell(GeneratorNum).Name = AlphArray(1); + FuelCell(GeneratorNum).NameFCPM = AlphArray(2); + FuelCell(GeneratorNum).NameFCAirSup = AlphArray(3); + FuelCell(GeneratorNum).NameFCFuelSup = AlphArray(4); + FuelCell(GeneratorNum).NameFCWaterSup = AlphArray(5); + FuelCell(GeneratorNum).NameFCAuxilHeat = AlphArray(6); + FuelCell(GeneratorNum).NameExhaustHX = AlphArray(7); + FuelCell(GeneratorNum).NameElecStorage = AlphArray(8); + FuelCell(GeneratorNum).NameInverter = AlphArray(9); if (NumAlphas == 10) { - DataGenerators::FuelCell(GeneratorNum).NameStackCooler = AlphArray(10); + FuelCell(GeneratorNum).NameStackCooler = AlphArray(10); } } @@ -237,91 +239,91 @@ namespace FuelCellElectricGenerator { DataIPShortCuts::cNumericFieldNames); UtilityRoutines::IsNameEmpty(AlphArray(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); - int thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), DataGenerators::FuelCell, &DataGenerators::FCDataStruct::NameFCPM); + int thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), FuelCell, &FCDataStruct::NameFCPM); if (thisFuelCell > 0) { - DataGenerators::FuelCell(thisFuelCell).FCPM.Name = AlphArray(1); - if (UtilityRoutines::SameString(AlphArray(2), "ANNEX42")) DataGenerators::FuelCell(thisFuelCell).FCPM.EffMode = DataGenerators::DirectCurveMode; - if (UtilityRoutines::SameString(AlphArray(2), "NORMALIZED")) DataGenerators::FuelCell(thisFuelCell).FCPM.EffMode = DataGenerators::NormalizedCurveMode; - if (DataGenerators::FuelCell(thisFuelCell).FCPM.EffMode == 0) { + FuelCell(thisFuelCell).FCPM.Name = AlphArray(1); + if (UtilityRoutines::SameString(AlphArray(2), "ANNEX42")) FuelCell(thisFuelCell).FCPM.EffMode = DataGenerators::DirectCurveMode; + if (UtilityRoutines::SameString(AlphArray(2), "NORMALIZED")) FuelCell(thisFuelCell).FCPM.EffMode = DataGenerators::NormalizedCurveMode; + if (FuelCell(thisFuelCell).FCPM.EffMode == 0) { ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(2) + " = " + AlphArray(2)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } - DataGenerators::FuelCell(thisFuelCell).FCPM.EffCurveID = CurveManager::GetCurveIndex(AlphArray(3)); - if (DataGenerators::FuelCell(thisFuelCell).FCPM.EffCurveID == 0) { + FuelCell(thisFuelCell).FCPM.EffCurveID = CurveManager::GetCurveIndex(AlphArray(3)); + if (FuelCell(thisFuelCell).FCPM.EffCurveID == 0) { ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(3) + " = " + AlphArray(3)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } - DataGenerators::FuelCell(thisFuelCell).FCPM.NomEff = NumArray(1); - DataGenerators::FuelCell(thisFuelCell).FCPM.NomPel = NumArray(2); - DataGenerators::FuelCell(thisFuelCell).FCPM.NumCycles = NumArray(3); - DataGenerators::FuelCell(thisFuelCell).FCPM.CyclingDegradRat = NumArray(4); - DataGenerators::FuelCell(thisFuelCell).FCPM.NumRunHours = NumArray(5); - DataGenerators::FuelCell(thisFuelCell).FCPM.OperateDegradRat = NumArray(6); - DataGenerators::FuelCell(thisFuelCell).FCPM.ThreshRunHours = NumArray(7); - DataGenerators::FuelCell(thisFuelCell).FCPM.UpTranLimit = NumArray(8); - DataGenerators::FuelCell(thisFuelCell).FCPM.DownTranLimit = NumArray(9); - DataGenerators::FuelCell(thisFuelCell).FCPM.StartUpTime = NumArray(10) / DataGlobals::SecInHour; // convert to hours from seconds - DataGenerators::FuelCell(thisFuelCell).FCPM.StartUpFuel = NumArray(11); - DataGenerators::FuelCell(thisFuelCell).FCPM.StartUpElectConsum = NumArray(12); - DataGenerators::FuelCell(thisFuelCell).FCPM.StartUpElectProd = NumArray(13); - DataGenerators::FuelCell(thisFuelCell).FCPM.ShutDownTime = NumArray(14) / DataGlobals::SecInHour; // convert to hours from seconds - DataGenerators::FuelCell(thisFuelCell).FCPM.ShutDownFuel = NumArray(15); - DataGenerators::FuelCell(thisFuelCell).FCPM.ShutDownElectConsum = NumArray(16); - DataGenerators::FuelCell(thisFuelCell).FCPM.ANC0 = NumArray(17); - DataGenerators::FuelCell(thisFuelCell).FCPM.ANC1 = NumArray(18); - if (UtilityRoutines::SameString(AlphArray(4), "ConstantRate")) DataGenerators::FuelCell(thisFuelCell).FCPM.SkinLossMode = DataGenerators::ConstantRateSkinLoss; + FuelCell(thisFuelCell).FCPM.NomEff = NumArray(1); + FuelCell(thisFuelCell).FCPM.NomPel = NumArray(2); + FuelCell(thisFuelCell).FCPM.NumCycles = NumArray(3); + FuelCell(thisFuelCell).FCPM.CyclingDegradRat = NumArray(4); + FuelCell(thisFuelCell).FCPM.NumRunHours = NumArray(5); + FuelCell(thisFuelCell).FCPM.OperateDegradRat = NumArray(6); + FuelCell(thisFuelCell).FCPM.ThreshRunHours = NumArray(7); + FuelCell(thisFuelCell).FCPM.UpTranLimit = NumArray(8); + FuelCell(thisFuelCell).FCPM.DownTranLimit = NumArray(9); + FuelCell(thisFuelCell).FCPM.StartUpTime = NumArray(10) / DataGlobals::SecInHour; // convert to hours from seconds + FuelCell(thisFuelCell).FCPM.StartUpFuel = NumArray(11); + FuelCell(thisFuelCell).FCPM.StartUpElectConsum = NumArray(12); + FuelCell(thisFuelCell).FCPM.StartUpElectProd = NumArray(13); + FuelCell(thisFuelCell).FCPM.ShutDownTime = NumArray(14) / DataGlobals::SecInHour; // convert to hours from seconds + FuelCell(thisFuelCell).FCPM.ShutDownFuel = NumArray(15); + FuelCell(thisFuelCell).FCPM.ShutDownElectConsum = NumArray(16); + FuelCell(thisFuelCell).FCPM.ANC0 = NumArray(17); + FuelCell(thisFuelCell).FCPM.ANC1 = NumArray(18); + if (UtilityRoutines::SameString(AlphArray(4), "ConstantRate")) FuelCell(thisFuelCell).FCPM.SkinLossMode = DataGenerators::ConstantRateSkinLoss; if (UtilityRoutines::SameString(AlphArray(4), "UAForProcessGasTemperature")) - DataGenerators::FuelCell(thisFuelCell).FCPM.SkinLossMode = DataGenerators::UADTSkinLoss; + FuelCell(thisFuelCell).FCPM.SkinLossMode = DataGenerators::UADTSkinLoss; if (UtilityRoutines::SameString(AlphArray(4), "QUADRATIC FUNCTION OF FUEL RATE")) - DataGenerators::FuelCell(thisFuelCell).FCPM.SkinLossMode = DataGenerators::QuadraticFuelNdotSkin; - if (DataGenerators::FuelCell(thisFuelCell).FCPM.SkinLossMode == 0) { + FuelCell(thisFuelCell).FCPM.SkinLossMode = DataGenerators::QuadraticFuelNdotSkin; + if (FuelCell(thisFuelCell).FCPM.SkinLossMode == 0) { // throw error ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(4) + " = " + AlphArray(4)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } - DataGenerators::FuelCell(thisFuelCell).FCPM.ZoneName = AlphArray(5); - DataGenerators::FuelCell(thisFuelCell).FCPM.ZoneID = UtilityRoutines::FindItemInList(DataGenerators::FuelCell(thisFuelCell).FCPM.ZoneName, DataHeatBalance::Zone); - if (DataGenerators::FuelCell(thisFuelCell).FCPM.ZoneID == 0 && !lAlphaBlanks(5)) { + FuelCell(thisFuelCell).FCPM.ZoneName = AlphArray(5); + FuelCell(thisFuelCell).FCPM.ZoneID = UtilityRoutines::FindItemInList(FuelCell(thisFuelCell).FCPM.ZoneName, DataHeatBalance::Zone); + if (FuelCell(thisFuelCell).FCPM.ZoneID == 0 && !lAlphaBlanks(5)) { ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(5) + " = " + AlphArray(5)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ShowContinueError("Zone Name was not found "); ErrorsFound = true; } - DataGenerators::FuelCell(thisFuelCell).FCPM.RadiativeFract = NumArray(19); - DataGenerators::FuelCell(thisFuelCell).FCPM.QdotSkin = NumArray(20); - DataGenerators::FuelCell(thisFuelCell).FCPM.UAskin = NumArray(21); + FuelCell(thisFuelCell).FCPM.RadiativeFract = NumArray(19); + FuelCell(thisFuelCell).FCPM.QdotSkin = NumArray(20); + FuelCell(thisFuelCell).FCPM.UAskin = NumArray(21); - DataGenerators::FuelCell(thisFuelCell).FCPM.SkinLossCurveID = CurveManager::GetCurveIndex(AlphArray(6)); - if (DataGenerators::FuelCell(thisFuelCell).FCPM.SkinLossCurveID == 0) { - if (DataGenerators::FuelCell(thisFuelCell).FCPM.SkinLossMode == DataGenerators::QuadraticFuelNdotSkin) { + FuelCell(thisFuelCell).FCPM.SkinLossCurveID = CurveManager::GetCurveIndex(AlphArray(6)); + if (FuelCell(thisFuelCell).FCPM.SkinLossCurveID == 0) { + if (FuelCell(thisFuelCell).FCPM.SkinLossMode == DataGenerators::QuadraticFuelNdotSkin) { ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(6) + " = " + AlphArray(6)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } } - DataGenerators::FuelCell(thisFuelCell).FCPM.NdotDilutionAir = NumArray(22); - DataGenerators::FuelCell(thisFuelCell).FCPM.StackHeatLossToDilution = NumArray(23); - DataGenerators::FuelCell(thisFuelCell).FCPM.DilutionInletNodeName = AlphArray(7); - DataGenerators::FuelCell(thisFuelCell).FCPM.DilutionInletNode = NodeInputManager::GetOnlySingleNode( + FuelCell(thisFuelCell).FCPM.NdotDilutionAir = NumArray(22); + FuelCell(thisFuelCell).FCPM.StackHeatLossToDilution = NumArray(23); + FuelCell(thisFuelCell).FCPM.DilutionInletNodeName = AlphArray(7); + FuelCell(thisFuelCell).FCPM.DilutionInletNode = NodeInputManager::GetOnlySingleNode( AlphArray(7), ErrorsFound, DataIPShortCuts::cCurrentModuleObject, AlphArray(1), DataLoopNode::NodeType_Air, DataLoopNode::NodeConnectionType_Inlet, 1, DataLoopNode::ObjectIsNotParent); - DataGenerators::FuelCell(thisFuelCell).FCPM.DilutionExhaustNodeName = AlphArray(8); - DataGenerators::FuelCell(thisFuelCell).FCPM.DilutionExhaustNode = NodeInputManager::GetOnlySingleNode( + FuelCell(thisFuelCell).FCPM.DilutionExhaustNodeName = AlphArray(8); + FuelCell(thisFuelCell).FCPM.DilutionExhaustNode = NodeInputManager::GetOnlySingleNode( AlphArray(8), ErrorsFound, DataIPShortCuts::cCurrentModuleObject, AlphArray(1), DataLoopNode::NodeType_Air, DataLoopNode::NodeConnectionType_Outlet, 1, DataLoopNode::ObjectIsNotParent); - DataGenerators::FuelCell(thisFuelCell).FCPM.PelMin = NumArray(24); - DataGenerators::FuelCell(thisFuelCell).FCPM.PelMax = NumArray(25); + FuelCell(thisFuelCell).FCPM.PelMin = NumArray(24); + FuelCell(thisFuelCell).FCPM.PelMax = NumArray(25); // check for other FuelCell using the same power module and fill for (int otherFuelCell = thisFuelCell + 1; otherFuelCell <= NumFuelCellGenerators; ++otherFuelCell) { - if (UtilityRoutines::SameString(DataGenerators::FuelCell(otherFuelCell).FCPM.Name, DataGenerators::FuelCell(thisFuelCell).FCPM.Name)) { - DataGenerators::FuelCell(otherFuelCell).FCPM = DataGenerators::FuelCell(thisFuelCell).FCPM; + if (UtilityRoutines::SameString(FuelCell(otherFuelCell).FCPM.Name, FuelCell(thisFuelCell).FCPM.Name)) { + FuelCell(otherFuelCell).FCPM = FuelCell(thisFuelCell).FCPM; } } } else { // throw warning, did not find power module input @@ -339,10 +341,10 @@ namespace FuelCellElectricGenerator { // set fuel supply ID in Fuel cell structure for (int GeneratorNum = 1; GeneratorNum <= NumFuelCellGenerators; ++GeneratorNum) { - DataGenerators::FuelCell(GeneratorNum).FuelSupNum = - UtilityRoutines::FindItemInList(DataGenerators::FuelCell(GeneratorNum).NameFCFuelSup, DataGenerators::FuelSupply); // Fuel Supply ID - if (DataGenerators::FuelCell(GeneratorNum).FuelSupNum == 0) { - ShowSevereError("Fuel Supply Name: " + DataGenerators::FuelCell(GeneratorNum).NameFCFuelSup + " not found in " + DataGenerators::FuelCell(GeneratorNum).Name); + FuelCell(GeneratorNum).FuelSupNum = + UtilityRoutines::FindItemInList(FuelCell(GeneratorNum).NameFCFuelSup, DataGenerators::FuelSupply); // Fuel Supply ID + if (FuelCell(GeneratorNum).FuelSupNum == 0) { + ShowSevereError("Fuel Supply Name: " + FuelCell(GeneratorNum).NameFCFuelSup + " not found in " + FuelCell(GeneratorNum).Name); ErrorsFound = true; } } @@ -360,54 +362,54 @@ namespace FuelCellElectricGenerator { DataIPShortCuts::cCurrentModuleObject, FCAirSupNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat, _, _, DataIPShortCuts::cAlphaFieldNames, DataIPShortCuts::cNumericFieldNames); UtilityRoutines::IsNameEmpty(AlphArray(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); - int thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), DataGenerators::FuelCell, &DataGenerators::FCDataStruct::NameFCAirSup); + int thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), FuelCell, &FCDataStruct::NameFCAirSup); if (thisFuelCell > 0) { - DataGenerators::FuelCell(thisFuelCell).AirSup.Name = AlphArray(1); - DataGenerators::FuelCell(thisFuelCell).AirSup.NodeName = AlphArray(2); + FuelCell(thisFuelCell).AirSup.Name = AlphArray(1); + FuelCell(thisFuelCell).AirSup.NodeName = AlphArray(2); // check the node connections - DataGenerators::FuelCell(thisFuelCell).AirSup.SupNodeNum = NodeInputManager::GetOnlySingleNode( + FuelCell(thisFuelCell).AirSup.SupNodeNum = NodeInputManager::GetOnlySingleNode( AlphArray(2), ErrorsFound, DataIPShortCuts::cCurrentModuleObject, AlphArray(1), DataLoopNode::NodeType_Air, DataLoopNode::NodeConnectionType_Inlet, 1, DataLoopNode::ObjectIsNotParent); - DataGenerators::FuelCell(thisFuelCell).AirSup.BlowerPowerCurveID = CurveManager::GetCurveIndex(AlphArray(3)); - if (DataGenerators::FuelCell(thisFuelCell).AirSup.BlowerPowerCurveID == 0) { + FuelCell(thisFuelCell).AirSup.BlowerPowerCurveID = CurveManager::GetCurveIndex(AlphArray(3)); + if (FuelCell(thisFuelCell).AirSup.BlowerPowerCurveID == 0) { ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(3) + " = " + AlphArray(3)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ShowContinueError("Curve name was not found "); ErrorsFound = true; } - DataGenerators::FuelCell(thisFuelCell).AirSup.BlowerHeatLossFactor = NumArray(1); + FuelCell(thisFuelCell).AirSup.BlowerHeatLossFactor = NumArray(1); if (UtilityRoutines::SameString(AlphArray(4), "AirRatiobyStoics")) { - DataGenerators::FuelCell(thisFuelCell).AirSup.AirSupRateMode = DataGenerators::ConstantStoicsAirRat; + FuelCell(thisFuelCell).AirSup.AirSupRateMode = DataGenerators::ConstantStoicsAirRat; } else if (UtilityRoutines::SameString(AlphArray(4), "QuadraticFunctionofElectricPower")) { - DataGenerators::FuelCell(thisFuelCell).AirSup.AirSupRateMode = DataGenerators::QuadraticFuncofPel; + FuelCell(thisFuelCell).AirSup.AirSupRateMode = DataGenerators::QuadraticFuncofPel; } else if (UtilityRoutines::SameString(AlphArray(4), "QUADRATIC FUNCTION OF FUEL RATE")) { - DataGenerators::FuelCell(thisFuelCell).AirSup.AirSupRateMode = DataGenerators::QuadraticFuncofNdot; + FuelCell(thisFuelCell).AirSup.AirSupRateMode = DataGenerators::QuadraticFuncofNdot; } else { ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(4) + " = " + AlphArray(4)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } - DataGenerators::FuelCell(thisFuelCell).AirSup.Stoics = NumArray(2) + 1.0; + FuelCell(thisFuelCell).AirSup.Stoics = NumArray(2) + 1.0; - DataGenerators::FuelCell(thisFuelCell).AirSup.AirFuncPelCurveID = CurveManager::GetCurveIndex(AlphArray(5)); - if ((DataGenerators::FuelCell(thisFuelCell).AirSup.AirFuncPelCurveID == 0) && - (DataGenerators::FuelCell(thisFuelCell).AirSup.AirSupRateMode == DataGenerators::QuadraticFuncofPel)) { + FuelCell(thisFuelCell).AirSup.AirFuncPelCurveID = CurveManager::GetCurveIndex(AlphArray(5)); + if ((FuelCell(thisFuelCell).AirSup.AirFuncPelCurveID == 0) && + (FuelCell(thisFuelCell).AirSup.AirSupRateMode == DataGenerators::QuadraticFuncofPel)) { ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(5) + " = " + AlphArray(5)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ShowSevereError("Curve name was not found"); ErrorsFound = true; } - DataGenerators::FuelCell(thisFuelCell).AirSup.AirTempCoeff = NumArray(3); + FuelCell(thisFuelCell).AirSup.AirTempCoeff = NumArray(3); - DataGenerators::FuelCell(thisFuelCell).AirSup.AirFuncNdotCurveID = CurveManager::GetCurveIndex(AlphArray(6)); - if ((DataGenerators::FuelCell(thisFuelCell).AirSup.AirFuncNdotCurveID == 0) && - (DataGenerators::FuelCell(thisFuelCell).AirSup.AirSupRateMode == DataGenerators::QuadraticFuncofNdot)) { + FuelCell(thisFuelCell).AirSup.AirFuncNdotCurveID = CurveManager::GetCurveIndex(AlphArray(6)); + if ((FuelCell(thisFuelCell).AirSup.AirFuncNdotCurveID == 0) && + (FuelCell(thisFuelCell).AirSup.AirSupRateMode == DataGenerators::QuadraticFuncofNdot)) { ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(6) + " = " + AlphArray(6)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ShowSevereError("Curve name was not found"); @@ -415,17 +417,17 @@ namespace FuelCellElectricGenerator { } if (UtilityRoutines::SameString("RecoverBurnerInverterStorage", AlphArray(7))) { - DataGenerators::FuelCell(thisFuelCell).AirSup.IntakeRecoveryMode = DataGenerators::RecoverBurnInvertBatt; + FuelCell(thisFuelCell).AirSup.IntakeRecoveryMode = DataGenerators::RecoverBurnInvertBatt; } else if (UtilityRoutines::SameString("RecoverAuxiliaryBurner", AlphArray(7))) { - DataGenerators::FuelCell(thisFuelCell).AirSup.IntakeRecoveryMode = DataGenerators::RecoverAuxiliaryBurner; + FuelCell(thisFuelCell).AirSup.IntakeRecoveryMode = DataGenerators::RecoverAuxiliaryBurner; } else if (UtilityRoutines::SameString("RecoverInverterandStorage", AlphArray(7))) { - DataGenerators::FuelCell(thisFuelCell).AirSup.IntakeRecoveryMode = DataGenerators::RecoverInverterBatt; + FuelCell(thisFuelCell).AirSup.IntakeRecoveryMode = DataGenerators::RecoverInverterBatt; } else if (UtilityRoutines::SameString("RecoverInverter", AlphArray(7))) { - DataGenerators::FuelCell(thisFuelCell).AirSup.IntakeRecoveryMode = DataGenerators::RecoverInverter; + FuelCell(thisFuelCell).AirSup.IntakeRecoveryMode = DataGenerators::RecoverInverter; } else if (UtilityRoutines::SameString("RecoverElectricalStorage", AlphArray(7))) { - DataGenerators::FuelCell(thisFuelCell).AirSup.IntakeRecoveryMode = DataGenerators::RecoverBattery; + FuelCell(thisFuelCell).AirSup.IntakeRecoveryMode = DataGenerators::RecoverBattery; } else if (UtilityRoutines::SameString("NoRecovery", AlphArray(7))) { - DataGenerators::FuelCell(thisFuelCell).AirSup.IntakeRecoveryMode = DataGenerators::NoRecoveryOnAirIntake; + FuelCell(thisFuelCell).AirSup.IntakeRecoveryMode = DataGenerators::NoRecoveryOnAirIntake; } else { ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(7) + " = " + AlphArray(7)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); @@ -433,9 +435,9 @@ namespace FuelCellElectricGenerator { } if (UtilityRoutines::SameString("AmbientAir", AlphArray(8))) { - DataGenerators::FuelCell(thisFuelCell).AirSup.ConstituentMode = DataGenerators::RegularAir; + FuelCell(thisFuelCell).AirSup.ConstituentMode = DataGenerators::RegularAir; } else if (UtilityRoutines::SameString("UserDefinedConstituents", AlphArray(8))) { - DataGenerators::FuelCell(thisFuelCell).AirSup.ConstituentMode = DataGenerators::UserDefinedConstituents; + FuelCell(thisFuelCell).AirSup.ConstituentMode = DataGenerators::UserDefinedConstituents; } else { ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(8) + " = " + AlphArray(8)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); @@ -444,9 +446,9 @@ namespace FuelCellElectricGenerator { int NumAirConstit; - if (DataGenerators::FuelCell(thisFuelCell).AirSup.ConstituentMode == DataGenerators::UserDefinedConstituents) { + if (FuelCell(thisFuelCell).AirSup.ConstituentMode == DataGenerators::UserDefinedConstituents) { NumAirConstit = NumArray(4); - DataGenerators::FuelCell(thisFuelCell).AirSup.NumConstituents = NumAirConstit; + FuelCell(thisFuelCell).AirSup.NumConstituents = NumAirConstit; if (NumAirConstit > 5) { ShowSevereError("Invalid " + DataIPShortCuts::cNumericFieldNames(4) + '=' + General::RoundSigDigits(NumArray(4), 2)); @@ -456,44 +458,44 @@ namespace FuelCellElectricGenerator { } for (int ConstitNum = 1; ConstitNum <= NumAirConstit; ++ConstitNum) { - DataGenerators::FuelCell(thisFuelCell).AirSup.ConstitName(ConstitNum) = AlphArray(ConstitNum + 8); - DataGenerators::FuelCell(thisFuelCell).AirSup.ConstitMolalFract(ConstitNum) = NumArray(ConstitNum + 4); + FuelCell(thisFuelCell).AirSup.ConstitName(ConstitNum) = AlphArray(ConstitNum + 8); + FuelCell(thisFuelCell).AirSup.ConstitMolalFract(ConstitNum) = NumArray(ConstitNum + 4); } } else { // regular air NumAirConstit = 5; - DataGenerators::FuelCell(thisFuelCell).AirSup.NumConstituents = NumAirConstit; + FuelCell(thisFuelCell).AirSup.NumConstituents = NumAirConstit; - DataGenerators::FuelCell(thisFuelCell).AirSup.ConstitName(1) = "Nitrogen"; - DataGenerators::FuelCell(thisFuelCell).AirSup.ConstitMolalFract(1) = 0.7728; + FuelCell(thisFuelCell).AirSup.ConstitName(1) = "Nitrogen"; + FuelCell(thisFuelCell).AirSup.ConstitMolalFract(1) = 0.7728; - DataGenerators::FuelCell(thisFuelCell).AirSup.ConstitName(2) = "Oxygen"; - DataGenerators::FuelCell(thisFuelCell).AirSup.ConstitMolalFract(2) = 0.2073; + FuelCell(thisFuelCell).AirSup.ConstitName(2) = "Oxygen"; + FuelCell(thisFuelCell).AirSup.ConstitMolalFract(2) = 0.2073; - DataGenerators::FuelCell(thisFuelCell).AirSup.ConstitName(3) = "Water"; - DataGenerators::FuelCell(thisFuelCell).AirSup.ConstitMolalFract(3) = 0.0104; + FuelCell(thisFuelCell).AirSup.ConstitName(3) = "Water"; + FuelCell(thisFuelCell).AirSup.ConstitMolalFract(3) = 0.0104; - DataGenerators::FuelCell(thisFuelCell).AirSup.ConstitName(4) = "Argon"; - DataGenerators::FuelCell(thisFuelCell).AirSup.ConstitMolalFract(4) = 0.0092; + FuelCell(thisFuelCell).AirSup.ConstitName(4) = "Argon"; + FuelCell(thisFuelCell).AirSup.ConstitMolalFract(4) = 0.0092; - DataGenerators::FuelCell(thisFuelCell).AirSup.ConstitName(5) = "CarbonDioxide"; - DataGenerators::FuelCell(thisFuelCell).AirSup.ConstitMolalFract(5) = 0.0003; + FuelCell(thisFuelCell).AirSup.ConstitName(5) = "CarbonDioxide"; + FuelCell(thisFuelCell).AirSup.ConstitMolalFract(5) = 0.0003; } // check for molar fractions summing to 1.0. - if (std::abs(sum(DataGenerators::FuelCell(thisFuelCell).AirSup.ConstitMolalFract) - 1.0) > 0.0001) { + if (std::abs(sum(FuelCell(thisFuelCell).AirSup.ConstitMolalFract) - 1.0) > 0.0001) { ShowSevereError(DataIPShortCuts::cCurrentModuleObject + " molar fractions do not sum to 1.0"); - ShowContinueError("..Sum was=" + General::RoundSigDigits(sum(DataGenerators::FuelCell(thisFuelCell).AirSup.ConstitMolalFract), 1)); + ShowContinueError("..Sum was=" + General::RoundSigDigits(sum(FuelCell(thisFuelCell).AirSup.ConstitMolalFract), 1)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + " = " + AlphArray(1)); ErrorsFound = true; } // check for other FuelCell using the same Air Supply module and fill for (int otherFuelCell = thisFuelCell + 1; otherFuelCell <= NumFuelCellGenerators; ++otherFuelCell) { - if (UtilityRoutines::SameString(DataGenerators::FuelCell(otherFuelCell).AirSup.Name, DataGenerators::FuelCell(thisFuelCell).AirSup.Name)) { - DataGenerators::FuelCell(otherFuelCell).AirSup = DataGenerators::FuelCell(thisFuelCell).AirSup; + if (UtilityRoutines::SameString(FuelCell(otherFuelCell).AirSup.Name, FuelCell(thisFuelCell).AirSup.Name)) { + FuelCell(otherFuelCell).AirSup = FuelCell(thisFuelCell).AirSup; } } } else { @@ -506,25 +508,25 @@ namespace FuelCellElectricGenerator { for (int GeneratorNum = 1; GeneratorNum <= NumFuelCellGenerators; ++GeneratorNum) { // find molal fraction of oxygen in air supply int thisConstituent = - UtilityRoutines::FindItem("Oxygen", DataGenerators::FuelCell(GeneratorNum).AirSup.ConstitName, DataGenerators::FuelCell(GeneratorNum).AirSup.NumConstituents); - if (thisConstituent > 0) DataGenerators::FuelCell(GeneratorNum).AirSup.O2fraction = DataGenerators::FuelCell(GeneratorNum).AirSup.ConstitMolalFract(thisConstituent); + UtilityRoutines::FindItem("Oxygen", FuelCell(GeneratorNum).AirSup.ConstitName, FuelCell(GeneratorNum).AirSup.NumConstituents); + if (thisConstituent > 0) FuelCell(GeneratorNum).AirSup.O2fraction = FuelCell(GeneratorNum).AirSup.ConstitMolalFract(thisConstituent); // Loop over air constituents and do one-time setup - for (int i = 1; i <= DataGenerators::FuelCell(GeneratorNum).AirSup.NumConstituents; ++i) { + for (int i = 1; i <= FuelCell(GeneratorNum).AirSup.NumConstituents; ++i) { - std::string thisName = DataGenerators::FuelCell(GeneratorNum).AirSup.ConstitName(i); + std::string thisName = FuelCell(GeneratorNum).AirSup.ConstitName(i); int thisGasID = UtilityRoutines::FindItem(thisName, DataGenerators::GasPhaseThermoChemistryData, &DataGenerators::GasPropertyDataStruct::ConstituentName); - DataGenerators::FuelCell(GeneratorNum).AirSup.GasLibID(i) = thisGasID; + FuelCell(GeneratorNum).AirSup.GasLibID(i) = thisGasID; } // set up gas constiuents for product gases - DataGenerators::FuelCell(GeneratorNum).FCPM.GasLibID(1) = 1; // Carbon Dioxide - DataGenerators::FuelCell(GeneratorNum).FCPM.GasLibID(2) = 2; // Nitrogen - DataGenerators::FuelCell(GeneratorNum).FCPM.GasLibID(3) = 3; // Oxygen - DataGenerators::FuelCell(GeneratorNum).FCPM.GasLibID(4) = 4; // Water - DataGenerators::FuelCell(GeneratorNum).FCPM.GasLibID(5) = 5; // Argon + FuelCell(GeneratorNum).FCPM.GasLibID(1) = 1; // Carbon Dioxide + FuelCell(GeneratorNum).FCPM.GasLibID(2) = 2; // Nitrogen + FuelCell(GeneratorNum).FCPM.GasLibID(3) = 3; // Oxygen + FuelCell(GeneratorNum).FCPM.GasLibID(4) = 4; // Water + FuelCell(GeneratorNum).FCPM.GasLibID(5) = 5; // Argon } DataIPShortCuts::cCurrentModuleObject = "Generator:FuelCell:WaterSupply"; @@ -540,32 +542,32 @@ namespace FuelCellElectricGenerator { DataIPShortCuts::cCurrentModuleObject, FCWaterSupNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat, _, _, DataIPShortCuts::cAlphaFieldNames, DataIPShortCuts::cNumericFieldNames); UtilityRoutines::IsNameEmpty(AlphArray(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); - int thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), DataGenerators::FuelCell, &DataGenerators::FCDataStruct::NameFCWaterSup); + int thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), FuelCell, &FCDataStruct::NameFCWaterSup); if (thisFuelCell > 0) { // this is only the first instance of a FuelCell generator using this type of Water supply module - DataGenerators::FuelCell(thisFuelCell).WaterSup.Name = AlphArray(1); - DataGenerators::FuelCell(thisFuelCell).WaterSup.WaterSupRateCurveID = CurveManager::GetCurveIndex(AlphArray(2)); - if (DataGenerators::FuelCell(thisFuelCell).WaterSup.WaterSupRateCurveID == 0) { + FuelCell(thisFuelCell).WaterSup.Name = AlphArray(1); + FuelCell(thisFuelCell).WaterSup.WaterSupRateCurveID = CurveManager::GetCurveIndex(AlphArray(2)); + if (FuelCell(thisFuelCell).WaterSup.WaterSupRateCurveID == 0) { ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(2) + " = " + AlphArray(2)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ShowContinueError("Curve name was not found "); ErrorsFound = true; } - DataGenerators::FuelCell(thisFuelCell).WaterSup.PmpPowerCurveID = CurveManager::GetCurveIndex(AlphArray(3)); - if (DataGenerators::FuelCell(thisFuelCell).WaterSup.PmpPowerCurveID == 0) { + FuelCell(thisFuelCell).WaterSup.PmpPowerCurveID = CurveManager::GetCurveIndex(AlphArray(3)); + if (FuelCell(thisFuelCell).WaterSup.PmpPowerCurveID == 0) { ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(3) + " = " + AlphArray(3)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ShowContinueError("Curve name was not found "); ErrorsFound = true; } - DataGenerators::FuelCell(thisFuelCell).WaterSup.PmpPowerLossFactor = NumArray(1); + FuelCell(thisFuelCell).WaterSup.PmpPowerLossFactor = NumArray(1); if (UtilityRoutines::SameString("TemperatureFromAirNode", AlphArray(4))) { - DataGenerators::FuelCell(thisFuelCell).WaterSup.WaterTempMode = DataGenerators::WaterInReformAirNode; + FuelCell(thisFuelCell).WaterSup.WaterTempMode = DataGenerators::WaterInReformAirNode; - DataGenerators::FuelCell(thisFuelCell).WaterSup.NodeName = AlphArray(5); - DataGenerators::FuelCell(thisFuelCell).WaterSup.NodeNum = NodeInputManager::GetOnlySingleNode(AlphArray(5), + FuelCell(thisFuelCell).WaterSup.NodeName = AlphArray(5); + FuelCell(thisFuelCell).WaterSup.NodeNum = NodeInputManager::GetOnlySingleNode(AlphArray(5), ErrorsFound, DataIPShortCuts::cCurrentModuleObject, AlphArray(1), @@ -575,10 +577,10 @@ namespace FuelCellElectricGenerator { DataLoopNode::ObjectIsNotParent); } else if (UtilityRoutines::SameString("TemperatureFromWaterNode", AlphArray(4))) { - DataGenerators::FuelCell(thisFuelCell).WaterSup.WaterTempMode = DataGenerators::WaterInReformWaterNode; + FuelCell(thisFuelCell).WaterSup.WaterTempMode = DataGenerators::WaterInReformWaterNode; - DataGenerators::FuelCell(thisFuelCell).WaterSup.NodeName = AlphArray(5); - DataGenerators::FuelCell(thisFuelCell).WaterSup.NodeNum = NodeInputManager::GetOnlySingleNode(AlphArray(5), + FuelCell(thisFuelCell).WaterSup.NodeName = AlphArray(5); + FuelCell(thisFuelCell).WaterSup.NodeNum = NodeInputManager::GetOnlySingleNode(AlphArray(5), ErrorsFound, DataIPShortCuts::cCurrentModuleObject, AlphArray(1), @@ -588,18 +590,18 @@ namespace FuelCellElectricGenerator { DataLoopNode::ObjectIsNotParent); } else if (UtilityRoutines::SameString("MainsWaterTemperature", AlphArray(4))) { - DataGenerators::FuelCell(thisFuelCell).WaterSup.WaterTempMode = DataGenerators::WaterInReformMains; + FuelCell(thisFuelCell).WaterSup.WaterTempMode = DataGenerators::WaterInReformMains; } else if (UtilityRoutines::SameString("TemperatureFromSchedule", AlphArray(4))) { - DataGenerators::FuelCell(thisFuelCell).WaterSup.WaterTempMode = DataGenerators::WaterInReformSchedule; + FuelCell(thisFuelCell).WaterSup.WaterTempMode = DataGenerators::WaterInReformSchedule; } else { ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(4) + " = " + AlphArray(4)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } - DataGenerators::FuelCell(thisFuelCell).WaterSup.SchedNum = ScheduleManager::GetScheduleIndex(AlphArray(6)); - if ((DataGenerators::FuelCell(thisFuelCell).WaterSup.SchedNum == 0) && (DataGenerators::FuelCell(thisFuelCell).WaterSup.WaterTempMode == DataGenerators::WaterInReformSchedule)) { + FuelCell(thisFuelCell).WaterSup.SchedNum = ScheduleManager::GetScheduleIndex(AlphArray(6)); + if ((FuelCell(thisFuelCell).WaterSup.SchedNum == 0) && (FuelCell(thisFuelCell).WaterSup.WaterTempMode == DataGenerators::WaterInReformSchedule)) { ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(6) + " = " + AlphArray(6)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ShowContinueError("Schedule was not found"); @@ -608,8 +610,8 @@ namespace FuelCellElectricGenerator { // check for other FuelCell using the same Water Supply module and fill for (int otherFuelCell = thisFuelCell + 1; otherFuelCell <= NumFuelCellGenerators; ++otherFuelCell) { - if (UtilityRoutines::SameString(DataGenerators::FuelCell(otherFuelCell).WaterSup.Name, DataGenerators::FuelCell(thisFuelCell).WaterSup.Name)) { - DataGenerators::FuelCell(otherFuelCell).WaterSup = DataGenerators::FuelCell(thisFuelCell).WaterSup; + if (UtilityRoutines::SameString(FuelCell(otherFuelCell).WaterSup.Name, FuelCell(thisFuelCell).WaterSup.Name)) { + FuelCell(otherFuelCell).WaterSup = FuelCell(thisFuelCell).WaterSup; } } } else { @@ -632,45 +634,45 @@ namespace FuelCellElectricGenerator { DataIPShortCuts::cCurrentModuleObject, FCAuxHeatNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat, _, _, DataIPShortCuts::cAlphaFieldNames, DataIPShortCuts::cNumericFieldNames); UtilityRoutines::IsNameEmpty(AlphArray(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); - int thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), DataGenerators::FuelCell, &DataGenerators::FCDataStruct::NameFCAuxilHeat); + int thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), FuelCell, &FCDataStruct::NameFCAuxilHeat); if (thisFuelCell > 0) { - DataGenerators::FuelCell(thisFuelCell).AuxilHeat.Name = AlphArray(1); + FuelCell(thisFuelCell).AuxilHeat.Name = AlphArray(1); - DataGenerators::FuelCell(thisFuelCell).AuxilHeat.ExcessAirRAT = NumArray(1); - DataGenerators::FuelCell(thisFuelCell).AuxilHeat.ANC0 = NumArray(2); - DataGenerators::FuelCell(thisFuelCell).AuxilHeat.ANC1 = NumArray(3); - DataGenerators::FuelCell(thisFuelCell).AuxilHeat.UASkin = NumArray(4); + FuelCell(thisFuelCell).AuxilHeat.ExcessAirRAT = NumArray(1); + FuelCell(thisFuelCell).AuxilHeat.ANC0 = NumArray(2); + FuelCell(thisFuelCell).AuxilHeat.ANC1 = NumArray(3); + FuelCell(thisFuelCell).AuxilHeat.UASkin = NumArray(4); if (UtilityRoutines::SameString("SurroundingZone", AlphArray(2))) { - DataGenerators::FuelCell(thisFuelCell).AuxilHeat.SkinLossDestination = DataGenerators::SurroundingZone; + FuelCell(thisFuelCell).AuxilHeat.SkinLossDestination = DataGenerators::SurroundingZone; } else if (UtilityRoutines::SameString("AirInletForFuelCell", AlphArray(2))) { - DataGenerators::FuelCell(thisFuelCell).AuxilHeat.SkinLossDestination = DataGenerators::AirInletForFC; + FuelCell(thisFuelCell).AuxilHeat.SkinLossDestination = DataGenerators::AirInletForFC; } else { ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(2) + " = " + AlphArray(2)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } - DataGenerators::FuelCell(thisFuelCell).AuxilHeat.ZoneName = AlphArray(3); - DataGenerators::FuelCell(thisFuelCell).AuxilHeat.ZoneID = UtilityRoutines::FindItemInList(AlphArray(3), DataHeatBalance::Zone); - if ((DataGenerators::FuelCell(thisFuelCell).AuxilHeat.ZoneID == 0) && (DataGenerators::FuelCell(thisFuelCell).AuxilHeat.SkinLossDestination == DataGenerators::SurroundingZone)) { + FuelCell(thisFuelCell).AuxilHeat.ZoneName = AlphArray(3); + FuelCell(thisFuelCell).AuxilHeat.ZoneID = UtilityRoutines::FindItemInList(AlphArray(3), DataHeatBalance::Zone); + if ((FuelCell(thisFuelCell).AuxilHeat.ZoneID == 0) && (FuelCell(thisFuelCell).AuxilHeat.SkinLossDestination == DataGenerators::SurroundingZone)) { ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(3) + " = " + AlphArray(3)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ShowContinueError("Zone name was not found "); ErrorsFound = true; } - DataGenerators::FuelCell(thisFuelCell).AuxilHeat.MaxPowerW = NumArray(5); - DataGenerators::FuelCell(thisFuelCell).AuxilHeat.MinPowerW = NumArray(6); - DataGenerators::FuelCell(thisFuelCell).AuxilHeat.MaxPowerkmolperSec = NumArray(7); - DataGenerators::FuelCell(thisFuelCell).AuxilHeat.MinPowerkmolperSec = NumArray(8); + FuelCell(thisFuelCell).AuxilHeat.MaxPowerW = NumArray(5); + FuelCell(thisFuelCell).AuxilHeat.MinPowerW = NumArray(6); + FuelCell(thisFuelCell).AuxilHeat.MaxPowerkmolperSec = NumArray(7); + FuelCell(thisFuelCell).AuxilHeat.MinPowerkmolperSec = NumArray(8); // TODO finish Auxiliary heater // check for other FuelCell using the same Auxiliary Heating module and fill for (int otherFuelCell = thisFuelCell + 1; otherFuelCell <= NumFuelCellGenerators; ++otherFuelCell) { - if (UtilityRoutines::SameString(DataGenerators::FuelCell(otherFuelCell).AuxilHeat.Name, DataGenerators::FuelCell(thisFuelCell).AuxilHeat.Name)) { - DataGenerators::FuelCell(otherFuelCell).AuxilHeat = DataGenerators::FuelCell(thisFuelCell).AuxilHeat; + if (UtilityRoutines::SameString(FuelCell(otherFuelCell).AuxilHeat.Name, FuelCell(thisFuelCell).AuxilHeat.Name)) { + FuelCell(otherFuelCell).AuxilHeat = FuelCell(thisFuelCell).AuxilHeat; } } } else { @@ -694,14 +696,14 @@ namespace FuelCellElectricGenerator { DataIPShortCuts::cCurrentModuleObject, FCHXNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat, _, _, DataIPShortCuts::cAlphaFieldNames, DataIPShortCuts::cNumericFieldNames); UtilityRoutines::IsNameEmpty(AlphArray(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); - int thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), DataGenerators::FuelCell, &DataGenerators::FCDataStruct::NameExhaustHX); + int thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), FuelCell, &FCDataStruct::NameExhaustHX); if (thisFuelCell > 0) { - DataGenerators::FuelCell(thisFuelCell).ExhaustHX.Name = AlphArray(1); - DataGenerators::FuelCell(thisFuelCell).ExhaustHX.WaterInNodeName = AlphArray(2); - DataGenerators::FuelCell(thisFuelCell).ExhaustHX.WaterOutNodeName = AlphArray(3); + FuelCell(thisFuelCell).ExhaustHX.Name = AlphArray(1); + FuelCell(thisFuelCell).ExhaustHX.WaterInNodeName = AlphArray(2); + FuelCell(thisFuelCell).ExhaustHX.WaterOutNodeName = AlphArray(3); // find node ids for water path - DataGenerators::FuelCell(thisFuelCell).ExhaustHX.WaterInNode = NodeInputManager::GetOnlySingleNode(AlphArray(2), + FuelCell(thisFuelCell).ExhaustHX.WaterInNode = NodeInputManager::GetOnlySingleNode(AlphArray(2), ErrorsFound, DataIPShortCuts::cCurrentModuleObject, AlphArray(1), @@ -709,7 +711,7 @@ namespace FuelCellElectricGenerator { DataLoopNode::NodeConnectionType_Inlet, 1, DataLoopNode::ObjectIsNotParent); - DataGenerators::FuelCell(thisFuelCell).ExhaustHX.WaterOutNode = NodeInputManager::GetOnlySingleNode(AlphArray(3), + FuelCell(thisFuelCell).ExhaustHX.WaterOutNode = NodeInputManager::GetOnlySingleNode(AlphArray(3), ErrorsFound, DataIPShortCuts::cCurrentModuleObject, AlphArray(1), @@ -719,45 +721,45 @@ namespace FuelCellElectricGenerator { DataLoopNode::ObjectIsNotParent); BranchNodeConnections::TestCompSet(DataIPShortCuts::cCurrentModuleObject, AlphArray(1), AlphArray(2), AlphArray(3), "Heat Recovery Nodes"); - DataGenerators::FuelCell(thisFuelCell).ExhaustHX.ExhaustOutNodeName = AlphArray(4); - DataGenerators::FuelCell(thisFuelCell).ExhaustHX.ExhaustOutNode = NodeInputManager::GetOnlySingleNode( + FuelCell(thisFuelCell).ExhaustHX.ExhaustOutNodeName = AlphArray(4); + FuelCell(thisFuelCell).ExhaustHX.ExhaustOutNode = NodeInputManager::GetOnlySingleNode( AlphArray(4), ErrorsFound, DataIPShortCuts::cCurrentModuleObject, AlphArray(1), DataLoopNode::NodeType_Air, DataLoopNode::NodeConnectionType_Outlet, 2, DataLoopNode::ObjectIsNotParent); if (UtilityRoutines::SameString("FixedEffectiveness", AlphArray(5))) { - DataGenerators::FuelCell(thisFuelCell).ExhaustHX.HXmodelMode = DataGenerators::FixedEffectiveness; + FuelCell(thisFuelCell).ExhaustHX.HXmodelMode = DataGenerators::FixedEffectiveness; } else if (UtilityRoutines::SameString("EmpiricalUAeff", AlphArray(5))) { - DataGenerators::FuelCell(thisFuelCell).ExhaustHX.HXmodelMode = DataGenerators::LMTDempiricalUAeff; + FuelCell(thisFuelCell).ExhaustHX.HXmodelMode = DataGenerators::LMTDempiricalUAeff; } else if (UtilityRoutines::SameString("FundementalUAeff", AlphArray(5))) { - DataGenerators::FuelCell(thisFuelCell).ExhaustHX.HXmodelMode = DataGenerators::LMTDfundementalUAeff; + FuelCell(thisFuelCell).ExhaustHX.HXmodelMode = DataGenerators::LMTDfundementalUAeff; } else if (UtilityRoutines::SameString("CONDENSING", AlphArray(5))) { - DataGenerators::FuelCell(thisFuelCell).ExhaustHX.HXmodelMode = DataGenerators::Condensing; + FuelCell(thisFuelCell).ExhaustHX.HXmodelMode = DataGenerators::Condensing; } else { ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(5) + " = " + AlphArray(5)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } - DataGenerators::FuelCell(thisFuelCell).ExhaustHX.WaterVolumeFlowMax = NumArray(1); - DataGenerators::FuelCell(thisFuelCell).ExhaustHX.HXEffect = NumArray(2); - DataGenerators::FuelCell(thisFuelCell).ExhaustHX.hxs0 = NumArray(3); - DataGenerators::FuelCell(thisFuelCell).ExhaustHX.hxs1 = NumArray(4); - DataGenerators::FuelCell(thisFuelCell).ExhaustHX.hxs2 = NumArray(5); - DataGenerators::FuelCell(thisFuelCell).ExhaustHX.hxs3 = NumArray(6); - DataGenerators::FuelCell(thisFuelCell).ExhaustHX.hxs4 = NumArray(7); - DataGenerators::FuelCell(thisFuelCell).ExhaustHX.h0gas = NumArray(8); - DataGenerators::FuelCell(thisFuelCell).ExhaustHX.NdotGasRef = NumArray(9); - DataGenerators::FuelCell(thisFuelCell).ExhaustHX.nCoeff = NumArray(10); - DataGenerators::FuelCell(thisFuelCell).ExhaustHX.AreaGas = NumArray(11); - DataGenerators::FuelCell(thisFuelCell).ExhaustHX.h0Water = NumArray(12); - DataGenerators::FuelCell(thisFuelCell).ExhaustHX.NdotWaterRef = NumArray(13); - DataGenerators::FuelCell(thisFuelCell).ExhaustHX.mCoeff = NumArray(14); - DataGenerators::FuelCell(thisFuelCell).ExhaustHX.AreaWater = NumArray(15); - DataGenerators::FuelCell(thisFuelCell).ExhaustHX.Fadjust = NumArray(16); - DataGenerators::FuelCell(thisFuelCell).ExhaustHX.l1Coeff = NumArray(17); - DataGenerators::FuelCell(thisFuelCell).ExhaustHX.l2Coeff = NumArray(18); - DataGenerators::FuelCell(thisFuelCell).ExhaustHX.CondensationThresholdTemp = NumArray(19); + FuelCell(thisFuelCell).ExhaustHX.WaterVolumeFlowMax = NumArray(1); + FuelCell(thisFuelCell).ExhaustHX.HXEffect = NumArray(2); + FuelCell(thisFuelCell).ExhaustHX.hxs0 = NumArray(3); + FuelCell(thisFuelCell).ExhaustHX.hxs1 = NumArray(4); + FuelCell(thisFuelCell).ExhaustHX.hxs2 = NumArray(5); + FuelCell(thisFuelCell).ExhaustHX.hxs3 = NumArray(6); + FuelCell(thisFuelCell).ExhaustHX.hxs4 = NumArray(7); + FuelCell(thisFuelCell).ExhaustHX.h0gas = NumArray(8); + FuelCell(thisFuelCell).ExhaustHX.NdotGasRef = NumArray(9); + FuelCell(thisFuelCell).ExhaustHX.nCoeff = NumArray(10); + FuelCell(thisFuelCell).ExhaustHX.AreaGas = NumArray(11); + FuelCell(thisFuelCell).ExhaustHX.h0Water = NumArray(12); + FuelCell(thisFuelCell).ExhaustHX.NdotWaterRef = NumArray(13); + FuelCell(thisFuelCell).ExhaustHX.mCoeff = NumArray(14); + FuelCell(thisFuelCell).ExhaustHX.AreaWater = NumArray(15); + FuelCell(thisFuelCell).ExhaustHX.Fadjust = NumArray(16); + FuelCell(thisFuelCell).ExhaustHX.l1Coeff = NumArray(17); + FuelCell(thisFuelCell).ExhaustHX.l2Coeff = NumArray(18); + FuelCell(thisFuelCell).ExhaustHX.CondensationThresholdTemp = NumArray(19); // store cooling water volume flow rate for autosizing system - PlantUtilities::RegisterPlantCompDesignFlow(DataGenerators::FuelCell(thisFuelCell).ExhaustHX.WaterInNode, DataGenerators::FuelCell(thisFuelCell).ExhaustHX.WaterVolumeFlowMax); + PlantUtilities::RegisterPlantCompDesignFlow(FuelCell(thisFuelCell).ExhaustHX.WaterInNode, FuelCell(thisFuelCell).ExhaustHX.WaterVolumeFlowMax); } else { ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(1) + " = " + AlphArray(1)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); @@ -779,29 +781,29 @@ namespace FuelCellElectricGenerator { DataIPShortCuts::cCurrentModuleObject, StorageNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat, _, _, DataIPShortCuts::cAlphaFieldNames, DataIPShortCuts::cNumericFieldNames); UtilityRoutines::IsNameEmpty(AlphArray(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); - int thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), DataGenerators::FuelCell, &DataGenerators::FCDataStruct::NameElecStorage); + int thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), FuelCell, &FCDataStruct::NameElecStorage); if (thisFuelCell > 0) { - DataGenerators::FuelCell(thisFuelCell).ElecStorage.Name = AlphArray(1); + FuelCell(thisFuelCell).ElecStorage.Name = AlphArray(1); if (UtilityRoutines::SameString(AlphArray(2), "SimpleEfficiencyWithConstraints")) { - DataGenerators::FuelCell(thisFuelCell).ElecStorage.StorageModelMode = DataGenerators::SimpleEffConstraints; + FuelCell(thisFuelCell).ElecStorage.StorageModelMode = DataGenerators::SimpleEffConstraints; } else { ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(2) + " = " + AlphArray(2)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } - DataGenerators::FuelCell(thisFuelCell).ElecStorage.EnergeticEfficCharge = NumArray(1); - DataGenerators::FuelCell(thisFuelCell).ElecStorage.EnergeticEfficDischarge = NumArray(2); - DataGenerators::FuelCell(thisFuelCell).ElecStorage.NominalEnergyCapacity = NumArray(3); - DataGenerators::FuelCell(thisFuelCell).ElecStorage.MaxPowerDraw = NumArray(4); - DataGenerators::FuelCell(thisFuelCell).ElecStorage.MaxPowerStore = NumArray(5); - DataGenerators::FuelCell(thisFuelCell).ElecStorage.StartingEnergyStored = NumArray(6); + FuelCell(thisFuelCell).ElecStorage.EnergeticEfficCharge = NumArray(1); + FuelCell(thisFuelCell).ElecStorage.EnergeticEfficDischarge = NumArray(2); + FuelCell(thisFuelCell).ElecStorage.NominalEnergyCapacity = NumArray(3); + FuelCell(thisFuelCell).ElecStorage.MaxPowerDraw = NumArray(4); + FuelCell(thisFuelCell).ElecStorage.MaxPowerStore = NumArray(5); + FuelCell(thisFuelCell).ElecStorage.StartingEnergyStored = NumArray(6); // check for other FuelCell using the same Electrical Storage and fill for (int otherFuelCell = thisFuelCell + 1; otherFuelCell <= NumFuelCellGenerators; ++otherFuelCell) { - if (UtilityRoutines::SameString(DataGenerators::FuelCell(otherFuelCell).ElecStorage.Name, DataGenerators::FuelCell(thisFuelCell).ElecStorage.Name)) { - DataGenerators::FuelCell(otherFuelCell).ElecStorage = DataGenerators::FuelCell(thisFuelCell).ElecStorage; + if (UtilityRoutines::SameString(FuelCell(otherFuelCell).ElecStorage.Name, FuelCell(thisFuelCell).ElecStorage.Name)) { + FuelCell(otherFuelCell).ElecStorage = FuelCell(thisFuelCell).ElecStorage; } } } else { @@ -826,24 +828,24 @@ namespace FuelCellElectricGenerator { DataIPShortCuts::cCurrentModuleObject, FCPCUNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat, _, _, DataIPShortCuts::cAlphaFieldNames, DataIPShortCuts::cNumericFieldNames); UtilityRoutines::IsNameEmpty(AlphArray(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); - int thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), DataGenerators::FuelCell, &DataGenerators::FCDataStruct::NameInverter); + int thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), FuelCell, &FCDataStruct::NameInverter); if (thisFuelCell > 0) { - DataGenerators::FuelCell(thisFuelCell).Inverter.Name = AlphArray(1); + FuelCell(thisFuelCell).Inverter.Name = AlphArray(1); - if (UtilityRoutines::SameString(AlphArray(2), "QUADRATIC")) DataGenerators::FuelCell(thisFuelCell).Inverter.EffMode = DataGenerators::InverterEffQuadratic; - if (UtilityRoutines::SameString(AlphArray(2), "Constant")) DataGenerators::FuelCell(thisFuelCell).Inverter.EffMode = DataGenerators::InverterEffConstant; - if (DataGenerators::FuelCell(thisFuelCell).Inverter.EffMode == 0) { + if (UtilityRoutines::SameString(AlphArray(2), "QUADRATIC")) FuelCell(thisFuelCell).Inverter.EffMode = DataGenerators::InverterEffQuadratic; + if (UtilityRoutines::SameString(AlphArray(2), "Constant")) FuelCell(thisFuelCell).Inverter.EffMode = DataGenerators::InverterEffConstant; + if (FuelCell(thisFuelCell).Inverter.EffMode == 0) { ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(2) + " = " + AlphArray(2)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } - DataGenerators::FuelCell(thisFuelCell).Inverter.ConstEff = NumArray(1); + FuelCell(thisFuelCell).Inverter.ConstEff = NumArray(1); - DataGenerators::FuelCell(thisFuelCell).Inverter.EffQuadraticCurveID = CurveManager::GetCurveIndex(AlphArray(3)); - if ((DataGenerators::FuelCell(thisFuelCell).Inverter.EffQuadraticCurveID == 0) && - (DataGenerators::FuelCell(thisFuelCell).Inverter.EffMode == DataGenerators::InverterEffQuadratic)) { + FuelCell(thisFuelCell).Inverter.EffQuadraticCurveID = CurveManager::GetCurveIndex(AlphArray(3)); + if ((FuelCell(thisFuelCell).Inverter.EffQuadraticCurveID == 0) && + (FuelCell(thisFuelCell).Inverter.EffMode == DataGenerators::InverterEffQuadratic)) { ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(3) + " = " + AlphArray(3)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ShowContinueError("Curve was not found "); @@ -852,8 +854,8 @@ namespace FuelCellElectricGenerator { // check for other FuelCell using the same Inverter and fill for (int otherFuelCell = thisFuelCell + 1; otherFuelCell <= NumFuelCellGenerators; ++otherFuelCell) { - if (UtilityRoutines::SameString(DataGenerators::FuelCell(otherFuelCell).Inverter.Name, DataGenerators::FuelCell(thisFuelCell).Inverter.Name)) { - DataGenerators::FuelCell(otherFuelCell).Inverter = DataGenerators::FuelCell(thisFuelCell).Inverter; + if (UtilityRoutines::SameString(FuelCell(otherFuelCell).Inverter.Name, FuelCell(thisFuelCell).Inverter.Name)) { + FuelCell(otherFuelCell).Inverter = FuelCell(thisFuelCell).Inverter; } } } else { @@ -881,15 +883,15 @@ namespace FuelCellElectricGenerator { DataIPShortCuts::cNumericFieldNames); UtilityRoutines::IsNameEmpty(AlphArray(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); - int thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), DataGenerators::FuelCell, &DataGenerators::FCDataStruct::NameStackCooler); + int thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), FuelCell, &FCDataStruct::NameStackCooler); if (thisFuelCell > 0) { - DataGenerators::FuelCell(thisFuelCell).StackCooler.Name = AlphArray(1); - DataGenerators::FuelCell(thisFuelCell).StackCooler.WaterInNodeName = AlphArray(2); + FuelCell(thisFuelCell).StackCooler.Name = AlphArray(1); + FuelCell(thisFuelCell).StackCooler.WaterInNodeName = AlphArray(2); - DataGenerators::FuelCell(thisFuelCell).StackCooler.WaterOutNodeName = AlphArray(3); + FuelCell(thisFuelCell).StackCooler.WaterOutNodeName = AlphArray(3); - DataGenerators::FuelCell(thisFuelCell).StackCooler.WaterInNode = NodeInputManager::GetOnlySingleNode(AlphArray(2), + FuelCell(thisFuelCell).StackCooler.WaterInNode = NodeInputManager::GetOnlySingleNode(AlphArray(2), ErrorsFound, DataIPShortCuts::cCurrentModuleObject, AlphArray(1), @@ -897,7 +899,7 @@ namespace FuelCellElectricGenerator { DataLoopNode::NodeConnectionType_Inlet, 1, DataLoopNode::ObjectIsNotParent); - DataGenerators::FuelCell(thisFuelCell).StackCooler.WaterOutNode = NodeInputManager::GetOnlySingleNode(AlphArray(3), + FuelCell(thisFuelCell).StackCooler.WaterOutNode = NodeInputManager::GetOnlySingleNode(AlphArray(3), ErrorsFound, DataIPShortCuts::cCurrentModuleObject, AlphArray(1), @@ -907,26 +909,26 @@ namespace FuelCellElectricGenerator { DataLoopNode::ObjectIsNotParent); BranchNodeConnections::TestCompSet(DataIPShortCuts::cCurrentModuleObject, AlphArray(1), AlphArray(2), AlphArray(3), "Heat Recovery Nodes"); - DataGenerators::FuelCell(thisFuelCell).StackCooler.TstackNom = NumArray(1); - DataGenerators::FuelCell(thisFuelCell).StackCooler.TstackActual = NumArray(2); - DataGenerators::FuelCell(thisFuelCell).StackCooler.r0 = NumArray(3); - DataGenerators::FuelCell(thisFuelCell).StackCooler.r1 = NumArray(4); - DataGenerators::FuelCell(thisFuelCell).StackCooler.r2 = NumArray(5); - DataGenerators::FuelCell(thisFuelCell).StackCooler.r3 = NumArray(6); - DataGenerators::FuelCell(thisFuelCell).StackCooler.MdotStackCoolant = NumArray(7); - DataGenerators::FuelCell(thisFuelCell).StackCooler.UAs_cool = NumArray(8); - DataGenerators::FuelCell(thisFuelCell).StackCooler.Fs_cogen = NumArray(9); - DataGenerators::FuelCell(thisFuelCell).StackCooler.As_cogen = NumArray(10); - DataGenerators::FuelCell(thisFuelCell).StackCooler.MdotCogenNom = NumArray(11); - DataGenerators::FuelCell(thisFuelCell).StackCooler.hCogenNom = NumArray(12); - DataGenerators::FuelCell(thisFuelCell).StackCooler.ns = NumArray(13); - DataGenerators::FuelCell(thisFuelCell).StackCooler.PstackPumpEl = NumArray(14); - DataGenerators::FuelCell(thisFuelCell).StackCooler.PmpPowerLossFactor = NumArray(15); - DataGenerators::FuelCell(thisFuelCell).StackCooler.f0 = NumArray(16); - DataGenerators::FuelCell(thisFuelCell).StackCooler.f1 = NumArray(17); - DataGenerators::FuelCell(thisFuelCell).StackCooler.f1 = NumArray(18); - - DataGenerators::FuelCell(thisFuelCell).StackCooler.StackCoolerPresent = true; + FuelCell(thisFuelCell).StackCooler.TstackNom = NumArray(1); + FuelCell(thisFuelCell).StackCooler.TstackActual = NumArray(2); + FuelCell(thisFuelCell).StackCooler.r0 = NumArray(3); + FuelCell(thisFuelCell).StackCooler.r1 = NumArray(4); + FuelCell(thisFuelCell).StackCooler.r2 = NumArray(5); + FuelCell(thisFuelCell).StackCooler.r3 = NumArray(6); + FuelCell(thisFuelCell).StackCooler.MdotStackCoolant = NumArray(7); + FuelCell(thisFuelCell).StackCooler.UAs_cool = NumArray(8); + FuelCell(thisFuelCell).StackCooler.Fs_cogen = NumArray(9); + FuelCell(thisFuelCell).StackCooler.As_cogen = NumArray(10); + FuelCell(thisFuelCell).StackCooler.MdotCogenNom = NumArray(11); + FuelCell(thisFuelCell).StackCooler.hCogenNom = NumArray(12); + FuelCell(thisFuelCell).StackCooler.ns = NumArray(13); + FuelCell(thisFuelCell).StackCooler.PstackPumpEl = NumArray(14); + FuelCell(thisFuelCell).StackCooler.PmpPowerLossFactor = NumArray(15); + FuelCell(thisFuelCell).StackCooler.f0 = NumArray(16); + FuelCell(thisFuelCell).StackCooler.f1 = NumArray(17); + FuelCell(thisFuelCell).StackCooler.f1 = NumArray(18); + + FuelCell(thisFuelCell).StackCooler.StackCoolerPresent = true; } else { ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(1) + " = " + AlphArray(1)); @@ -943,16 +945,16 @@ namespace FuelCellElectricGenerator { for (int GeneratorNum = 1; GeneratorNum <= NumFuelCellGenerators; ++GeneratorNum) { SetupOutputVariable("Generator Produced Electric Power", OutputProcessor::Unit::W, - DataGenerators::FuelCell(GeneratorNum).Report.ACPowerGen, + FuelCell(GeneratorNum).Report.ACPowerGen, "System", "Average", - DataGenerators::FuelCell(GeneratorNum).Name); + FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Produced Electric Energy", OutputProcessor::Unit::J, - DataGenerators::FuelCell(GeneratorNum).Report.ACEnergyGen, + FuelCell(GeneratorNum).Report.ACEnergyGen, "System", "Sum", - DataGenerators::FuelCell(GeneratorNum).Name, + FuelCell(GeneratorNum).Name, _, "ElectricityProduced", "COGENERATION", @@ -960,16 +962,16 @@ namespace FuelCellElectricGenerator { "Plant"); SetupOutputVariable("Generator Produced Thermal Rate", OutputProcessor::Unit::W, - DataGenerators::FuelCell(GeneratorNum).Report.qHX, + FuelCell(GeneratorNum).Report.qHX, "System", "Average", - DataGenerators::FuelCell(GeneratorNum).Name); + FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Produced Thermal Energy", OutputProcessor::Unit::J, - DataGenerators::FuelCell(GeneratorNum).Report.HXenergy, + FuelCell(GeneratorNum).Report.HXenergy, "System", "Sum", - DataGenerators::FuelCell(GeneratorNum).Name, + FuelCell(GeneratorNum).Name, _, "ENERGYTRANSFER", "COGENERATION", @@ -978,10 +980,10 @@ namespace FuelCellElectricGenerator { SetupOutputVariable("Generator Fuel HHV Basis Energy", OutputProcessor::Unit::J, - DataGenerators::FuelCell(GeneratorNum).Report.FuelEnergyHHV, + FuelCell(GeneratorNum).Report.FuelEnergyHHV, "System", "Sum", - DataGenerators::FuelCell(GeneratorNum).Name, + FuelCell(GeneratorNum).Name, _, "Gas", "COGENERATION", @@ -989,325 +991,325 @@ namespace FuelCellElectricGenerator { "Plant"); SetupOutputVariable("Generator Fuel HHV Basis Rate", OutputProcessor::Unit::W, - DataGenerators::FuelCell(GeneratorNum).Report.FuelEnergyUseRateHHV, + FuelCell(GeneratorNum).Report.FuelEnergyUseRateHHV, "System", "Average", - DataGenerators::FuelCell(GeneratorNum).Name); + FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Zone Sensible Heat Transfer Rate", OutputProcessor::Unit::W, - DataGenerators::FuelCell(GeneratorNum).Report.SkinLossPower, + FuelCell(GeneratorNum).Report.SkinLossPower, "System", "Average", - DataGenerators::FuelCell(GeneratorNum).Name); + FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Zone Sensible Heat Transfer Energy", OutputProcessor::Unit::J, - DataGenerators::FuelCell(GeneratorNum).Report.SkinLossEnergy, + FuelCell(GeneratorNum).Report.SkinLossEnergy, "System", "Sum", - DataGenerators::FuelCell(GeneratorNum).Name); + FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Zone Convection Heat Transfer Rate", OutputProcessor::Unit::W, - DataGenerators::FuelCell(GeneratorNum).Report.SkinLossConvect, + FuelCell(GeneratorNum).Report.SkinLossConvect, "System", "Average", - DataGenerators::FuelCell(GeneratorNum).Name); + FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Zone Radiation Heat Transfer Rate", OutputProcessor::Unit::W, - DataGenerators::FuelCell(GeneratorNum).Report.SkinLossRadiat, + FuelCell(GeneratorNum).Report.SkinLossRadiat, "System", "Average", - DataGenerators::FuelCell(GeneratorNum).Name); - if (DataGenerators::FuelCell(GeneratorNum).FCPM.ZoneID > 0) { - SetupZoneInternalGain(DataGenerators::FuelCell(GeneratorNum).FCPM.ZoneID, + FuelCell(GeneratorNum).Name); + if (FuelCell(GeneratorNum).FCPM.ZoneID > 0) { + SetupZoneInternalGain(FuelCell(GeneratorNum).FCPM.ZoneID, "Generator:FuelCell", - DataGenerators::FuelCell(GeneratorNum).Name, + FuelCell(GeneratorNum).Name, DataHeatBalance::IntGainTypeOf_GeneratorFuelCell, - DataGenerators::FuelCell(GeneratorNum).Report.SkinLossConvect, + FuelCell(GeneratorNum).Report.SkinLossConvect, _, - DataGenerators::FuelCell(GeneratorNum).Report.SkinLossRadiat); + FuelCell(GeneratorNum).Report.SkinLossRadiat); } if (DataGlobals::DisplayAdvancedReportVariables) { // show extra data originally needed for detailed comparative testing SetupOutputVariable("Generator Air Inlet Temperature", OutputProcessor::Unit::C, - DataGenerators::FuelCell(GeneratorNum).Report.TairInlet, + FuelCell(GeneratorNum).Report.TairInlet, "System", "Average", - DataGenerators::FuelCell(GeneratorNum).Name); + FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Power Module Entering Air Temperature", OutputProcessor::Unit::C, - DataGenerators::FuelCell(GeneratorNum).Report.TairIntoFCPM, + FuelCell(GeneratorNum).Report.TairIntoFCPM, "System", "Average", - DataGenerators::FuelCell(GeneratorNum).Name); + FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Air Molar Flow Rate", OutputProcessor::Unit::kmol_s, - DataGenerators::FuelCell(GeneratorNum).Report.NdotAir, + FuelCell(GeneratorNum).Report.NdotAir, "System", "Average", - DataGenerators::FuelCell(GeneratorNum).Name); + FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Power Module Entering Air Enthalpy", OutputProcessor::Unit::W, - DataGenerators::FuelCell(GeneratorNum).Report.TotAirInEnthalphy, + FuelCell(GeneratorNum).Report.TotAirInEnthalphy, "System", "Average", - DataGenerators::FuelCell(GeneratorNum).Name); + FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Blower Electric Power", OutputProcessor::Unit::W, - DataGenerators::FuelCell(GeneratorNum).Report.BlowerPower, + FuelCell(GeneratorNum).Report.BlowerPower, "System", "Average", - DataGenerators::FuelCell(GeneratorNum).Name); + FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Blower Electric Energy", OutputProcessor::Unit::J, - DataGenerators::FuelCell(GeneratorNum).Report.BlowerEnergy, + FuelCell(GeneratorNum).Report.BlowerEnergy, "System", "Sum", - DataGenerators::FuelCell(GeneratorNum).Name); + FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Blower Skin Heat Loss Rate", OutputProcessor::Unit::W, - DataGenerators::FuelCell(GeneratorNum).Report.BlowerSkinLoss, + FuelCell(GeneratorNum).Report.BlowerSkinLoss, "System", "Average", - DataGenerators::FuelCell(GeneratorNum).Name); + FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Fuel Inlet Temperature", OutputProcessor::Unit::C, - DataGenerators::FuelCell(GeneratorNum).Report.TfuelInlet, + FuelCell(GeneratorNum).Report.TfuelInlet, "System", "Average", - DataGenerators::FuelCell(GeneratorNum).Name); + FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Power Module Entering Fuel Temperature", OutputProcessor::Unit::C, - DataGenerators::FuelCell(GeneratorNum).Report.TfuelIntoFCPM, + FuelCell(GeneratorNum).Report.TfuelIntoFCPM, "System", "Average", - DataGenerators::FuelCell(GeneratorNum).Name); + FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Fuel Molar Flow Rate", OutputProcessor::Unit::kmol_s, - DataGenerators::FuelCell(GeneratorNum).Report.NdotFuel, + FuelCell(GeneratorNum).Report.NdotFuel, "System", "Average", - DataGenerators::FuelCell(GeneratorNum).Name); + FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Fuel Consumption LHV Basis Energy", OutputProcessor::Unit::J, - DataGenerators::FuelCell(GeneratorNum).Report.FuelEnergyLHV, + FuelCell(GeneratorNum).Report.FuelEnergyLHV, "System", "Sum", - DataGenerators::FuelCell(GeneratorNum).Name); + FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Fuel Consumption Rate LHV Basis", OutputProcessor::Unit::W, - DataGenerators::FuelCell(GeneratorNum).Report.FuelEnergyUseRateLHV, + FuelCell(GeneratorNum).Report.FuelEnergyUseRateLHV, "System", "Average", - DataGenerators::FuelCell(GeneratorNum).Name); + FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Power Module Entering Fuel Enthalpy", OutputProcessor::Unit::W, - DataGenerators::FuelCell(GeneratorNum).Report.TotFuelInEnthalpy, + FuelCell(GeneratorNum).Report.TotFuelInEnthalpy, "System", "Average", - DataGenerators::FuelCell(GeneratorNum).Name); + FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Fuel Compressor Electric Power", OutputProcessor::Unit::W, - DataGenerators::FuelCell(GeneratorNum).Report.FuelCompressPower, + FuelCell(GeneratorNum).Report.FuelCompressPower, "System", "Average", - DataGenerators::FuelCell(GeneratorNum).Name); + FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Fuel Compressor Electric Energy", OutputProcessor::Unit::J, - DataGenerators::FuelCell(GeneratorNum).Report.FuelCompressEnergy, + FuelCell(GeneratorNum).Report.FuelCompressEnergy, "System", "Sum", - DataGenerators::FuelCell(GeneratorNum).Name); + FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Fuel Compressor Skin Heat Loss Rate", OutputProcessor::Unit::W, - DataGenerators::FuelCell(GeneratorNum).Report.FuelCompressSkinLoss, + FuelCell(GeneratorNum).Report.FuelCompressSkinLoss, "System", "Average", - DataGenerators::FuelCell(GeneratorNum).Name); + FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Fuel Reformer Water Inlet Temperature", OutputProcessor::Unit::C, - DataGenerators::FuelCell(GeneratorNum).Report.TwaterInlet, + FuelCell(GeneratorNum).Report.TwaterInlet, "System", "Average", - DataGenerators::FuelCell(GeneratorNum).Name); + FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Power Module Entering Reforming Water Temperature", OutputProcessor::Unit::C, - DataGenerators::FuelCell(GeneratorNum).Report.TwaterIntoFCPM, + FuelCell(GeneratorNum).Report.TwaterIntoFCPM, "System", "Average", - DataGenerators::FuelCell(GeneratorNum).Name); + FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Fuel Reformer Water Molar Flow Rate", OutputProcessor::Unit::kmol_s, - DataGenerators::FuelCell(GeneratorNum).Report.NdotWater, + FuelCell(GeneratorNum).Report.NdotWater, "System", "Average", - DataGenerators::FuelCell(GeneratorNum).Name); + FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Fuel Reformer Water Pump Electric Power", OutputProcessor::Unit::W, - DataGenerators::FuelCell(GeneratorNum).Report.WaterPumpPower, + FuelCell(GeneratorNum).Report.WaterPumpPower, "System", "Average", - DataGenerators::FuelCell(GeneratorNum).Name); + FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Fuel Reformer Water Pump Electric Energy", OutputProcessor::Unit::J, - DataGenerators::FuelCell(GeneratorNum).Report.WaterPumpEnergy, + FuelCell(GeneratorNum).Report.WaterPumpEnergy, "System", "Sum", - DataGenerators::FuelCell(GeneratorNum).Name); + FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Power Module Entering Reforming Water Enthalpy", OutputProcessor::Unit::W, - DataGenerators::FuelCell(GeneratorNum).Report.WaterIntoFCPMEnthalpy, + FuelCell(GeneratorNum).Report.WaterIntoFCPMEnthalpy, "System", "Average", - DataGenerators::FuelCell(GeneratorNum).Name); + FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Product Gas Temperature", OutputProcessor::Unit::C, - DataGenerators::FuelCell(GeneratorNum).Report.TprodGas, + FuelCell(GeneratorNum).Report.TprodGas, "System", "Average", - DataGenerators::FuelCell(GeneratorNum).Name); + FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Product Gas Enthalpy", OutputProcessor::Unit::W, - DataGenerators::FuelCell(GeneratorNum).Report.EnthalProdGas, + FuelCell(GeneratorNum).Report.EnthalProdGas, "System", "Average", - DataGenerators::FuelCell(GeneratorNum).Name); + FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Product Gas Molar Flow Rate", OutputProcessor::Unit::kmol_s, - DataGenerators::FuelCell(GeneratorNum).Report.NdotProdGas, + FuelCell(GeneratorNum).Report.NdotProdGas, "System", "Average", - DataGenerators::FuelCell(GeneratorNum).Name); + FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Product Gas Ar Molar Flow Rate", OutputProcessor::Unit::kmol_s, - DataGenerators::FuelCell(GeneratorNum).Report.NdotProdAr, + FuelCell(GeneratorNum).Report.NdotProdAr, "System", "Average", - DataGenerators::FuelCell(GeneratorNum).Name); + FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Product Gas CO2 Molar Flow Rate", OutputProcessor::Unit::kmol_s, - DataGenerators::FuelCell(GeneratorNum).Report.NdotProdCO2, + FuelCell(GeneratorNum).Report.NdotProdCO2, "System", "Average", - DataGenerators::FuelCell(GeneratorNum).Name); + FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Product Gas H2O Vapor Molar Flow Rate", OutputProcessor::Unit::kmol_s, - DataGenerators::FuelCell(GeneratorNum).Report.NdotProdH2O, + FuelCell(GeneratorNum).Report.NdotProdH2O, "System", "Average", - DataGenerators::FuelCell(GeneratorNum).Name); + FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Product Gas N2 Molar Flow Rate", OutputProcessor::Unit::kmol_s, - DataGenerators::FuelCell(GeneratorNum).Report.NdotProdN2, + FuelCell(GeneratorNum).Report.NdotProdN2, "System", "Average", - DataGenerators::FuelCell(GeneratorNum).Name); + FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Product Gas O2 Molar Flow Rate", OutputProcessor::Unit::kmol_s, - DataGenerators::FuelCell(GeneratorNum).Report.NdotProdO2, + FuelCell(GeneratorNum).Report.NdotProdO2, "System", "Average", - DataGenerators::FuelCell(GeneratorNum).Name); + FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Heat Recovery Exit Gas Temperature", OutputProcessor::Unit::C, - DataGenerators::FuelCell(GeneratorNum).Report.THXexh, + FuelCell(GeneratorNum).Report.THXexh, "System", "Average", - DataGenerators::FuelCell(GeneratorNum).Name); + FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Heat Recovery Exit Gas H2O Vapor Fraction", OutputProcessor::Unit::None, - DataGenerators::FuelCell(GeneratorNum).Report.WaterVaporFractExh, + FuelCell(GeneratorNum).Report.WaterVaporFractExh, "System", "Average", - DataGenerators::FuelCell(GeneratorNum).Name); + FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Heat Recovery Water Condensate Molar Flow Rate", OutputProcessor::Unit::kmol_s, - DataGenerators::FuelCell(GeneratorNum).Report.CondensateRate, + FuelCell(GeneratorNum).Report.CondensateRate, "System", "Average", - DataGenerators::FuelCell(GeneratorNum).Name); + FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Inverter Loss Power", OutputProcessor::Unit::W, - DataGenerators::FuelCell(GeneratorNum).Report.PCUlosses, + FuelCell(GeneratorNum).Report.PCUlosses, "System", "Average", - DataGenerators::FuelCell(GeneratorNum).Name); + FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Produced DC Electric Power", OutputProcessor::Unit::W, - DataGenerators::FuelCell(GeneratorNum).Report.DCPowerGen, + FuelCell(GeneratorNum).Report.DCPowerGen, "System", "Average", - DataGenerators::FuelCell(GeneratorNum).Name); + FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator DC Power Efficiency", OutputProcessor::Unit::None, - DataGenerators::FuelCell(GeneratorNum).Report.DCPowerEff, + FuelCell(GeneratorNum).Report.DCPowerEff, "System", "Average", - DataGenerators::FuelCell(GeneratorNum).Name); + FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Electric Storage Charge State", OutputProcessor::Unit::J, - DataGenerators::FuelCell(GeneratorNum).Report.ElectEnergyinStorage, + FuelCell(GeneratorNum).Report.ElectEnergyinStorage, "System", "Average", - DataGenerators::FuelCell(GeneratorNum).Name); //? 'Sum' + FuelCell(GeneratorNum).Name); //? 'Sum' SetupOutputVariable("Generator DC Storage Charging Power", OutputProcessor::Unit::W, - DataGenerators::FuelCell(GeneratorNum).Report.StoredPower, + FuelCell(GeneratorNum).Report.StoredPower, "System", "Average", - DataGenerators::FuelCell(GeneratorNum).Name); + FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator DC Storage Charging Energy", OutputProcessor::Unit::J, - DataGenerators::FuelCell(GeneratorNum).Report.StoredEnergy, + FuelCell(GeneratorNum).Report.StoredEnergy, "System", "Sum", - DataGenerators::FuelCell(GeneratorNum).Name); + FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator DC Storage Discharging Power", OutputProcessor::Unit::W, - DataGenerators::FuelCell(GeneratorNum).Report.DrawnPower, + FuelCell(GeneratorNum).Report.DrawnPower, "System", "Average", - DataGenerators::FuelCell(GeneratorNum).Name); + FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator DC Storage Discharging Energy", OutputProcessor::Unit::J, - DataGenerators::FuelCell(GeneratorNum).Report.DrawnEnergy, + FuelCell(GeneratorNum).Report.DrawnEnergy, "System", "Sum", - DataGenerators::FuelCell(GeneratorNum).Name); + FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Ancillary AC Electric Power", OutputProcessor::Unit::W, - DataGenerators::FuelCell(GeneratorNum).Report.ACancillariesPower, + FuelCell(GeneratorNum).Report.ACancillariesPower, "System", "Average", - DataGenerators::FuelCell(GeneratorNum).Name); + FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Ancillary AC Electric Energy", OutputProcessor::Unit::J, - DataGenerators::FuelCell(GeneratorNum).Report.ACancillariesEnergy, + FuelCell(GeneratorNum).Report.ACancillariesEnergy, "System", "Sum", - DataGenerators::FuelCell(GeneratorNum).Name); + FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Fuel Cell Model Iteration Count", OutputProcessor::Unit::None, - DataGenerators::FuelCell(GeneratorNum).Report.SeqSubstIterations, + FuelCell(GeneratorNum).Report.SeqSubstIterations, "System", "Sum", - DataGenerators::FuelCell(GeneratorNum).Name); + FuelCell(GeneratorNum).Name); SetupOutputVariable("Generator Root Solver Iteration Count", OutputProcessor::Unit::None, - DataGenerators::FuelCell(GeneratorNum).Report.RegulaFalsiIterations, + FuelCell(GeneratorNum).Report.RegulaFalsiIterations, "System", "Sum", - DataGenerators::FuelCell(GeneratorNum).Name); + FuelCell(GeneratorNum).Name); } } } @@ -1338,35 +1340,35 @@ namespace FuelCellElectricGenerator { // TODO zero out terms as appropriate - if (DataGenerators::FuelCell(GeneratorNum).FCPM.HasBeenOn) { + if (FuelCell(GeneratorNum).FCPM.HasBeenOn) { // FuelCell just now beginning to shut down, // set Day and Time of Last Shut Down - DataGenerators::FuelCell(GeneratorNum).FCPM.FractionalDayofLastShutDown = + FuelCell(GeneratorNum).FCPM.FractionalDayofLastShutDown = double(DataGlobals::DayOfSim) + (int(DataGlobals::CurrentTime) + (DataHVACGlobals::SysTimeElapsed + (DataGlobals::CurrentTime - int(DataGlobals::CurrentTime)))) / DataGlobals::HoursInDay; - DataGenerators::FuelCell(GeneratorNum).FCPM.HasBeenOn = false; + FuelCell(GeneratorNum).FCPM.HasBeenOn = false; - if (DataGenerators::FuelCell(GeneratorNum).FCPM.ShutDownTime > 0.0) DataGenerators::FuelCell(GeneratorNum).FCPM.DuringShutDown = true; + if (FuelCell(GeneratorNum).FCPM.ShutDownTime > 0.0) FuelCell(GeneratorNum).FCPM.DuringShutDown = true; } // TODO check to see if still in shut down mode and using fuel. - if (DataGenerators::FuelCell(GeneratorNum).FCPM.DuringShutDown) { + if (FuelCell(GeneratorNum).FCPM.DuringShutDown) { } return; } - if (!DataGenerators::FuelCell(GeneratorNum).FCPM.HasBeenOn) { + if (!FuelCell(GeneratorNum).FCPM.HasBeenOn) { // fuel cell just turned on // set Day and Time of Last STart Up - DataGenerators::FuelCell(GeneratorNum).FCPM.FractionalDayofLastStartUp = + FuelCell(GeneratorNum).FCPM.FractionalDayofLastStartUp = double(DataGlobals::DayOfSim) + (int(DataGlobals::CurrentTime) + (DataHVACGlobals::SysTimeElapsed + (DataGlobals::CurrentTime - int(DataGlobals::CurrentTime)))) / DataGlobals::HoursInDay; - DataGenerators::FuelCell(GeneratorNum).FCPM.HasBeenOn = true; - ++DataGenerators::FuelCell(GeneratorNum).FCPM.NumCycles; // increment cycling counter + FuelCell(GeneratorNum).FCPM.HasBeenOn = true; + ++FuelCell(GeneratorNum).FCPM.NumCycles; // increment cycling counter - if (DataGenerators::FuelCell(GeneratorNum).FCPM.StartUpTime > 0.0) DataGenerators::FuelCell(GeneratorNum).FCPM.DuringStartUp = true; + if (FuelCell(GeneratorNum).FCPM.StartUpTime > 0.0) FuelCell(GeneratorNum).FCPM.DuringStartUp = true; } // TODO deal with things when jump out if not running? @@ -1402,7 +1404,7 @@ namespace FuelCellElectricGenerator { Pel = Pdemand; } - DataGenerators::FuelCell(GeneratorNum).Inverter.PCUlosses = PpcuLosses; + FuelCell(GeneratorNum).Inverter.PCUlosses = PpcuLosses; // Control step 2: adjust for transient and startup/shut down constraints @@ -1412,285 +1414,285 @@ namespace FuelCellElectricGenerator { // Control step 3: adjust for max and min limits on Pel - if (Pel < DataGenerators::FuelCell(GeneratorNum).FCPM.PelMin) { - PelDiff += (DataGenerators::FuelCell(GeneratorNum).FCPM.PelMin - Pel); - Pel = DataGenerators::FuelCell(GeneratorNum).FCPM.PelMin; + if (Pel < FuelCell(GeneratorNum).FCPM.PelMin) { + PelDiff += (FuelCell(GeneratorNum).FCPM.PelMin - Pel); + Pel = FuelCell(GeneratorNum).FCPM.PelMin; ConstrainedFCPM = true; } - if (Pel > DataGenerators::FuelCell(GeneratorNum).FCPM.PelMax) { - PelDiff += (DataGenerators::FuelCell(GeneratorNum).FCPM.PelMax - Pel); - Pel = DataGenerators::FuelCell(GeneratorNum).FCPM.PelMax; + if (Pel > FuelCell(GeneratorNum).FCPM.PelMax) { + PelDiff += (FuelCell(GeneratorNum).FCPM.PelMax - Pel); + Pel = FuelCell(GeneratorNum).FCPM.PelMax; ConstrainedFCPM = true; } if (ConstrainedFCPM) { } - DataGenerators::FuelCell(GeneratorNum).FCPM.Pel = Pel; + FuelCell(GeneratorNum).FCPM.Pel = Pel; // Now calculate FC models. return to controls and batter after // Calculation Step 1. Determine electrical Efficiency Eel Real64 Eel = 0.0; - if (DataGenerators::FuelCell(GeneratorNum).FCPM.EffMode == DataGenerators::NormalizedCurveMode) { + if (FuelCell(GeneratorNum).FCPM.EffMode == DataGenerators::NormalizedCurveMode) { // Equation (8) in FuelCell Spec modified for normalized curve - Eel = CurveManager::CurveValue(DataGenerators::FuelCell(GeneratorNum).FCPM.EffCurveID, Pel / DataGenerators::FuelCell(GeneratorNum).FCPM.NomPel) * - DataGenerators::FuelCell(GeneratorNum).FCPM.NomEff * - (1.0 - DataGenerators::FuelCell(GeneratorNum).FCPM.NumCycles * DataGenerators::FuelCell(GeneratorNum).FCPM.CyclingDegradRat) * - (1.0 - max((DataGenerators::FuelCell(GeneratorNum).FCPM.NumRunHours - DataGenerators::FuelCell(GeneratorNum).FCPM.ThreshRunHours), 0.0) * - DataGenerators::FuelCell(GeneratorNum).FCPM.OperateDegradRat); - - } else if (DataGenerators::FuelCell(GeneratorNum).FCPM.EffMode == DataGenerators::DirectCurveMode) { - // Equation (8) in DataGenerators::FuelCell Spec - Eel = CurveManager::CurveValue(DataGenerators::FuelCell(GeneratorNum).FCPM.EffCurveID, Pel) * - (1.0 - DataGenerators::FuelCell(GeneratorNum).FCPM.NumCycles * DataGenerators::FuelCell(GeneratorNum).FCPM.CyclingDegradRat) * - (1.0 - max((DataGenerators::FuelCell(GeneratorNum).FCPM.NumRunHours - DataGenerators::FuelCell(GeneratorNum).FCPM.ThreshRunHours), 0.0) * - DataGenerators::FuelCell(GeneratorNum).FCPM.OperateDegradRat); + Eel = CurveManager::CurveValue(FuelCell(GeneratorNum).FCPM.EffCurveID, Pel / FuelCell(GeneratorNum).FCPM.NomPel) * + FuelCell(GeneratorNum).FCPM.NomEff * + (1.0 - FuelCell(GeneratorNum).FCPM.NumCycles * FuelCell(GeneratorNum).FCPM.CyclingDegradRat) * + (1.0 - max((FuelCell(GeneratorNum).FCPM.NumRunHours - FuelCell(GeneratorNum).FCPM.ThreshRunHours), 0.0) * + FuelCell(GeneratorNum).FCPM.OperateDegradRat); + + } else if (FuelCell(GeneratorNum).FCPM.EffMode == DataGenerators::DirectCurveMode) { + // Equation (8) in FuelCell Spec + Eel = CurveManager::CurveValue(FuelCell(GeneratorNum).FCPM.EffCurveID, Pel) * + (1.0 - FuelCell(GeneratorNum).FCPM.NumCycles * FuelCell(GeneratorNum).FCPM.CyclingDegradRat) * + (1.0 - max((FuelCell(GeneratorNum).FCPM.NumRunHours - FuelCell(GeneratorNum).FCPM.ThreshRunHours), 0.0) * + FuelCell(GeneratorNum).FCPM.OperateDegradRat); } - DataGenerators::FuelCell(GeneratorNum).FCPM.Eel = Eel; + FuelCell(GeneratorNum).FCPM.Eel = Eel; // Calculation Step 2. Determine fuel rate // fuel flow rate - Real64 NdotFuel = Pel / (Eel * DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).LHV * 1000000.0); // Eq. 10 solved for Ndot + Real64 NdotFuel = Pel / (Eel * DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).LHV * 1000000.0); // Eq. 10 solved for Ndot - DataGenerators::FuelCell(GeneratorNum).FCPM.NdotFuel = NdotFuel; + FuelCell(GeneratorNum).FCPM.NdotFuel = NdotFuel; if (Pel <= 0.0) { // TODO zero stuff before leaving Pel = 0.0; - DataGenerators::FuelCell(GeneratorNum).FCPM.Pel = 0.0; + FuelCell(GeneratorNum).FCPM.Pel = 0.0; return; } else { - DataGenerators::FuelCell(GeneratorNum).FCPM.Pel = Pel; + FuelCell(GeneratorNum).FCPM.Pel = Pel; } // Calculation Step 3. Determine Air rate - if (DataGenerators::FuelCell(GeneratorNum).AirSup.AirSupRateMode == DataGenerators::ConstantStoicsAirRat) { // MEthod 1 + if (FuelCell(GeneratorNum).AirSup.AirSupRateMode == DataGenerators::ConstantStoicsAirRat) { // MEthod 1 // molar rate coeff working variable - Real64 NdotO2 = DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).StoicOxygenRate * DataGenerators::FuelCell(GeneratorNum).FCPM.NdotFuel * - DataGenerators::FuelCell(GeneratorNum).AirSup.Stoics; + Real64 NdotO2 = DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).StoicOxygenRate * FuelCell(GeneratorNum).FCPM.NdotFuel * + FuelCell(GeneratorNum).AirSup.Stoics; - DataGenerators::FuelCell(GeneratorNum).FCPM.NdotAir = NdotO2 / DataGenerators::FuelCell(GeneratorNum).AirSup.O2fraction; + FuelCell(GeneratorNum).FCPM.NdotAir = NdotO2 / FuelCell(GeneratorNum).AirSup.O2fraction; - } else if (DataGenerators::FuelCell(GeneratorNum).AirSup.AirSupRateMode == DataGenerators::QuadraticFuncofPel) { // MEthod 2 + } else if (FuelCell(GeneratorNum).AirSup.AirSupRateMode == DataGenerators::QuadraticFuncofPel) { // MEthod 2 - DataGenerators::FuelCell(GeneratorNum).FCPM.NdotAir = CurveManager::CurveValue(DataGenerators::FuelCell(GeneratorNum).AirSup.AirFuncPelCurveID, Pel) * - (1 + DataGenerators::FuelCell(GeneratorNum).AirSup.AirTempCoeff * DataGenerators::FuelCell(GeneratorNum).AirSup.TairIntoFCPM); + FuelCell(GeneratorNum).FCPM.NdotAir = CurveManager::CurveValue(FuelCell(GeneratorNum).AirSup.AirFuncPelCurveID, Pel) * + (1 + FuelCell(GeneratorNum).AirSup.AirTempCoeff * FuelCell(GeneratorNum).AirSup.TairIntoFCPM); - } else if (DataGenerators::FuelCell(GeneratorNum).AirSup.AirSupRateMode == DataGenerators::QuadraticFuncofNdot) { // method 3 - DataGenerators::FuelCell(GeneratorNum).FCPM.NdotAir = - CurveManager::CurveValue(DataGenerators::FuelCell(GeneratorNum).AirSup.AirFuncNdotCurveID, DataGenerators::FuelCell(GeneratorNum).FCPM.NdotFuel) * - (1 + DataGenerators::FuelCell(GeneratorNum).AirSup.AirTempCoeff * DataGenerators::FuelCell(GeneratorNum).AirSup.TairIntoFCPM); + } else if (FuelCell(GeneratorNum).AirSup.AirSupRateMode == DataGenerators::QuadraticFuncofNdot) { // method 3 + FuelCell(GeneratorNum).FCPM.NdotAir = + CurveManager::CurveValue(FuelCell(GeneratorNum).AirSup.AirFuncNdotCurveID, FuelCell(GeneratorNum).FCPM.NdotFuel) * + (1 + FuelCell(GeneratorNum).AirSup.AirTempCoeff * FuelCell(GeneratorNum).AirSup.TairIntoFCPM); } // Calculation Step 4. fuel compressor power - DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).PfuelCompEl = - CurveManager::CurveValue(DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).CompPowerCurveID, DataGenerators::FuelCell(GeneratorNum).FCPM.NdotFuel); + DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).PfuelCompEl = + CurveManager::CurveValue(DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).CompPowerCurveID, FuelCell(GeneratorNum).FCPM.NdotFuel); // calculation Step 5, Fuel Compressor (need outlet temperature) - if (DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).FuelTempMode == DataGenerators::FuelInTempFromNode) { + if (DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).FuelTempMode == DataGenerators::FuelInTempFromNode) { - DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).TfuelIntoCompress = DataLoopNode::Node(DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).NodeNum).Temp; + DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).TfuelIntoCompress = DataLoopNode::Node(DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).NodeNum).Temp; - } else if (DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).FuelTempMode == DataGenerators::FuelInTempSchedule) { + } else if (DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).FuelTempMode == DataGenerators::FuelInTempSchedule) { - DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).TfuelIntoCompress = - ScheduleManager::GetCurrentScheduleValue(DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).SchedNum); + DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).TfuelIntoCompress = + ScheduleManager::GetCurrentScheduleValue(DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).SchedNum); } // evaluate heat capacity at average temperature using shomate Real64 Cp; // temp Heat Capacity, used in thermochemistry units of (J/mol K) - Real64 Tavg = (DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).TfuelIntoCompress + DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).TfuelIntoFCPM) / 2.0; + Real64 Tavg = (DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).TfuelIntoCompress + DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).TfuelIntoFCPM) / 2.0; FigureFuelHeatCap(GeneratorNum, Tavg, Cp); // Cp in (J/mol K) // calculate a Temp of fuel out of compressor and into power module - if (DataGenerators::FuelCell(GeneratorNum).FCPM.NdotFuel <= 0.0) { // just pass through, domain probably collapsed in modeling - DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).TfuelIntoFCPM = DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).TfuelIntoCompress; + if (FuelCell(GeneratorNum).FCPM.NdotFuel <= 0.0) { // just pass through, domain probably collapsed in modeling + DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).TfuelIntoFCPM = DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).TfuelIntoCompress; } else { - DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).TfuelIntoFCPM = - ((1.0 - DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).CompPowerLossFactor) * - DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).PfuelCompEl / (DataGenerators::FuelCell(GeneratorNum).FCPM.NdotFuel * Cp * 1000.0)) + - DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).TfuelIntoCompress; // 1000 Cp units mol-> kmol + DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).TfuelIntoFCPM = + ((1.0 - DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).CompPowerLossFactor) * + DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).PfuelCompEl / (FuelCell(GeneratorNum).FCPM.NdotFuel * Cp * 1000.0)) + + DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).TfuelIntoCompress; // 1000 Cp units mol-> kmol } // calc skin losses from fuel compressor - DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).QskinLoss = - DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).CompPowerLossFactor * DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).PfuelCompEl; + DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).QskinLoss = + DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).CompPowerLossFactor * DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).PfuelCompEl; - if (DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).QskinLoss < 0.0) { - ShowWarningError("problem in FuelSupply.QskinLoss " + General::RoundSigDigits(DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).QskinLoss, 3)); - DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).QskinLoss = 0.0; + if (DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).QskinLoss < 0.0) { + ShowWarningError("problem in FuelSupply.QskinLoss " + General::RoundSigDigits(DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).QskinLoss, 3)); + DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).QskinLoss = 0.0; } // calculate tatal fuel enthalpy coming into power module // (Hmolfuel in KJ/mol) Real64 Hmolfuel; // temp enthalpy of fuel mixture in KJ/mol - FigureFuelEnthalpy(GeneratorNum, DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).TfuelIntoFCPM, Hmolfuel); + FigureFuelEnthalpy(GeneratorNum, DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).TfuelIntoFCPM, Hmolfuel); // units, NdotFuel in kmol/sec. Hmolfule in KJ/mol , // factor of 1000's to get to J/s or watts - DataGenerators::FuelCell(GeneratorNum).FCPM.TotFuelInEnthalphy = Hmolfuel * 1000.0 * DataGenerators::FuelCell(GeneratorNum).FCPM.NdotFuel * 1000.0; + FuelCell(GeneratorNum).FCPM.TotFuelInEnthalphy = Hmolfuel * 1000.0 * FuelCell(GeneratorNum).FCPM.NdotFuel * 1000.0; // Calculation Step 6, water compressor calculations // calculate water consumption - DataGenerators::FuelCell(GeneratorNum).FCPM.NdotLiqwater = - CurveManager::CurveValue(DataGenerators::FuelCell(GeneratorNum).WaterSup.WaterSupRateCurveID, DataGenerators::FuelCell(GeneratorNum).FCPM.NdotFuel); + FuelCell(GeneratorNum).FCPM.NdotLiqwater = + CurveManager::CurveValue(FuelCell(GeneratorNum).WaterSup.WaterSupRateCurveID, FuelCell(GeneratorNum).FCPM.NdotFuel); // set inlet temp. (could move to init) { - auto const SELECT_CASE_var(DataGenerators::FuelCell(GeneratorNum).WaterSup.WaterTempMode); + auto const SELECT_CASE_var(FuelCell(GeneratorNum).WaterSup.WaterTempMode); if (SELECT_CASE_var == DataGenerators::WaterInReformMains) { - DataGenerators::FuelCell(GeneratorNum).WaterSup.TwaterIntoCompress = DataEnvironment::WaterMainsTemp; + FuelCell(GeneratorNum).WaterSup.TwaterIntoCompress = DataEnvironment::WaterMainsTemp; } else if ((SELECT_CASE_var == DataGenerators::WaterInReformAirNode) || (SELECT_CASE_var == DataGenerators::WaterInReformWaterNode)) { - DataGenerators::FuelCell(GeneratorNum).WaterSup.TwaterIntoCompress = DataLoopNode::Node(DataGenerators::FuelCell(GeneratorNum).WaterSup.NodeNum).Temp; + FuelCell(GeneratorNum).WaterSup.TwaterIntoCompress = DataLoopNode::Node(FuelCell(GeneratorNum).WaterSup.NodeNum).Temp; } else if (SELECT_CASE_var == DataGenerators::WaterInReformSchedule) { - DataGenerators::FuelCell(GeneratorNum).WaterSup.TwaterIntoCompress = ScheduleManager::GetCurrentScheduleValue(DataGenerators::FuelCell(GeneratorNum).WaterSup.SchedNum); + FuelCell(GeneratorNum).WaterSup.TwaterIntoCompress = ScheduleManager::GetCurrentScheduleValue(FuelCell(GeneratorNum).WaterSup.SchedNum); } } - DataGenerators::FuelCell(GeneratorNum).WaterSup.PwaterCompEl = - CurveManager::CurveValue(DataGenerators::FuelCell(GeneratorNum).WaterSup.PmpPowerCurveID, DataGenerators::FuelCell(GeneratorNum).FCPM.NdotLiqwater); + FuelCell(GeneratorNum).WaterSup.PwaterCompEl = + CurveManager::CurveValue(FuelCell(GeneratorNum).WaterSup.PmpPowerCurveID, FuelCell(GeneratorNum).FCPM.NdotLiqwater); // 75.325 J/mol K Water at 0.1 MPa and 298 K, reference NIST WEBBOOK Real64 CpWater; // heat capacity of water in molar units - FigureLiquidWaterHeatCap(DataGenerators::FuelCell(GeneratorNum).WaterSup.TwaterIntoCompress, CpWater); + FigureLiquidWaterHeatCap(FuelCell(GeneratorNum).WaterSup.TwaterIntoCompress, CpWater); - if (DataGenerators::FuelCell(GeneratorNum).FCPM.NdotLiqwater <= 0.0) { // just pass through, domain probably collapsed in modeling - DataGenerators::FuelCell(GeneratorNum).WaterSup.TwaterIntoFCPM = DataGenerators::FuelCell(GeneratorNum).WaterSup.TwaterIntoCompress; + if (FuelCell(GeneratorNum).FCPM.NdotLiqwater <= 0.0) { // just pass through, domain probably collapsed in modeling + FuelCell(GeneratorNum).WaterSup.TwaterIntoFCPM = FuelCell(GeneratorNum).WaterSup.TwaterIntoCompress; } else { - DataGenerators::FuelCell(GeneratorNum).WaterSup.TwaterIntoFCPM = - ((1 - DataGenerators::FuelCell(GeneratorNum).WaterSup.PmpPowerLossFactor) * DataGenerators::FuelCell(GeneratorNum).WaterSup.PwaterCompEl / - (DataGenerators::FuelCell(GeneratorNum).FCPM.NdotLiqwater * CpWater * 1000.0)) + - DataGenerators::FuelCell(GeneratorNum).WaterSup.TwaterIntoCompress; + FuelCell(GeneratorNum).WaterSup.TwaterIntoFCPM = + ((1 - FuelCell(GeneratorNum).WaterSup.PmpPowerLossFactor) * FuelCell(GeneratorNum).WaterSup.PwaterCompEl / + (FuelCell(GeneratorNum).FCPM.NdotLiqwater * CpWater * 1000.0)) + + FuelCell(GeneratorNum).WaterSup.TwaterIntoCompress; } - DataGenerators::FuelCell(GeneratorNum).WaterSup.QskinLoss = - DataGenerators::FuelCell(GeneratorNum).WaterSup.PmpPowerLossFactor * DataGenerators::FuelCell(GeneratorNum).WaterSup.PwaterCompEl; + FuelCell(GeneratorNum).WaterSup.QskinLoss = + FuelCell(GeneratorNum).WaterSup.PmpPowerLossFactor * FuelCell(GeneratorNum).WaterSup.PwaterCompEl; - if (DataGenerators::FuelCell(GeneratorNum).WaterSup.QskinLoss < 0.0) { - // write(*,*) 'problem in WaterSup%QskinLoss ',DataGenerators::FuelCell(GeneratorNum)%WaterSup%QskinLoss - DataGenerators::FuelCell(GeneratorNum).WaterSup.QskinLoss = 0.0; + if (FuelCell(GeneratorNum).WaterSup.QskinLoss < 0.0) { + // write(*,*) 'problem in WaterSup%QskinLoss ',FuelCell(GeneratorNum)%WaterSup%QskinLoss + FuelCell(GeneratorNum).WaterSup.QskinLoss = 0.0; } Real64 HLiqWater; // temp enthalpy of liquid water in KJ/mol No Formation - FigureLiquidWaterEnthalpy(DataGenerators::FuelCell(GeneratorNum).WaterSup.TwaterIntoFCPM, HLiqWater); // HLiqWater in KJ/mol + FigureLiquidWaterEnthalpy(FuelCell(GeneratorNum).WaterSup.TwaterIntoFCPM, HLiqWater); // HLiqWater in KJ/mol - DataGenerators::FuelCell(GeneratorNum).FCPM.WaterInEnthalpy = DataGenerators::FuelCell(GeneratorNum).FCPM.NdotLiqwater * HLiqWater * 1000.0 * 1000.0; + FuelCell(GeneratorNum).FCPM.WaterInEnthalpy = FuelCell(GeneratorNum).FCPM.NdotLiqwater * HLiqWater * 1000.0 * 1000.0; // Calculation Step 7, Air compressor - DataGenerators::FuelCell(GeneratorNum).AirSup.TairIntoBlower = DataLoopNode::Node(DataGenerators::FuelCell(GeneratorNum).AirSup.SupNodeNum).Temp; + FuelCell(GeneratorNum).AirSup.TairIntoBlower = DataLoopNode::Node(FuelCell(GeneratorNum).AirSup.SupNodeNum).Temp; - DataGenerators::FuelCell(GeneratorNum).AirSup.PairCompEl = - CurveManager::CurveValue(DataGenerators::FuelCell(GeneratorNum).AirSup.BlowerPowerCurveID, DataGenerators::FuelCell(GeneratorNum).FCPM.NdotAir); + FuelCell(GeneratorNum).AirSup.PairCompEl = + CurveManager::CurveValue(FuelCell(GeneratorNum).AirSup.BlowerPowerCurveID, FuelCell(GeneratorNum).FCPM.NdotAir); - Tavg = (DataGenerators::FuelCell(GeneratorNum).AirSup.TairIntoBlower + DataGenerators::FuelCell(GeneratorNum).AirSup.TairIntoFCPM) / 2.0; + Tavg = (FuelCell(GeneratorNum).AirSup.TairIntoBlower + FuelCell(GeneratorNum).AirSup.TairIntoFCPM) / 2.0; FigureAirHeatCap(GeneratorNum, Tavg, Cp); // Cp in (J/mol K) // if PEMFC with stack cooler, then calculate stack cooler impacts - if (DataGenerators::FuelCell(GeneratorNum).StackCooler.StackCoolerPresent) { + if (FuelCell(GeneratorNum).StackCooler.StackCoolerPresent) { - DataGenerators::FuelCell(GeneratorNum).StackCooler.qs_cool = - (DataGenerators::FuelCell(GeneratorNum).StackCooler.r0 + - DataGenerators::FuelCell(GeneratorNum).StackCooler.r1 * - (DataGenerators::FuelCell(GeneratorNum).StackCooler.TstackActual - DataGenerators::FuelCell(GeneratorNum).StackCooler.TstackNom)) * - (1 + DataGenerators::FuelCell(GeneratorNum).StackCooler.r2 * Pel + DataGenerators::FuelCell(GeneratorNum).StackCooler.r3 * Pel * Pel) * Pel; + FuelCell(GeneratorNum).StackCooler.qs_cool = + (FuelCell(GeneratorNum).StackCooler.r0 + + FuelCell(GeneratorNum).StackCooler.r1 * + (FuelCell(GeneratorNum).StackCooler.TstackActual - FuelCell(GeneratorNum).StackCooler.TstackNom)) * + (1 + FuelCell(GeneratorNum).StackCooler.r2 * Pel + FuelCell(GeneratorNum).StackCooler.r3 * Pel * Pel) * Pel; - DataGenerators::FuelCell(GeneratorNum).FCPM.QdotStackCool = DataGenerators::FuelCell(GeneratorNum).StackCooler.qs_cool; + FuelCell(GeneratorNum).FCPM.QdotStackCool = FuelCell(GeneratorNum).StackCooler.qs_cool; } // Figure heat recovery from Electrical Storage, power conditioning, and auxiliary burner { - auto const SELECT_CASE_var(DataGenerators::FuelCell(GeneratorNum).AirSup.IntakeRecoveryMode); + auto const SELECT_CASE_var(FuelCell(GeneratorNum).AirSup.IntakeRecoveryMode); if (SELECT_CASE_var == DataGenerators::RecoverBurnInvertBatt) { - DataGenerators::FuelCell(GeneratorNum).AirSup.QintakeRecovery = DataGenerators::FuelCell(GeneratorNum).AuxilHeat.QairIntake + - DataGenerators::FuelCell(GeneratorNum).ElecStorage.QairIntake + - DataGenerators::FuelCell(GeneratorNum).Inverter.QairIntake; + FuelCell(GeneratorNum).AirSup.QintakeRecovery = FuelCell(GeneratorNum).AuxilHeat.QairIntake + + FuelCell(GeneratorNum).ElecStorage.QairIntake + + FuelCell(GeneratorNum).Inverter.QairIntake; } else if (SELECT_CASE_var == DataGenerators::RecoverAuxiliaryBurner) { - DataGenerators::FuelCell(GeneratorNum).AirSup.QintakeRecovery = DataGenerators::FuelCell(GeneratorNum).AuxilHeat.QairIntake; + FuelCell(GeneratorNum).AirSup.QintakeRecovery = FuelCell(GeneratorNum).AuxilHeat.QairIntake; } else if (SELECT_CASE_var == DataGenerators::RecoverInverterBatt) { - DataGenerators::FuelCell(GeneratorNum).AirSup.QintakeRecovery = - DataGenerators::FuelCell(GeneratorNum).ElecStorage.QairIntake + DataGenerators::FuelCell(GeneratorNum).Inverter.QairIntake; + FuelCell(GeneratorNum).AirSup.QintakeRecovery = + FuelCell(GeneratorNum).ElecStorage.QairIntake + FuelCell(GeneratorNum).Inverter.QairIntake; } else if (SELECT_CASE_var == DataGenerators::RecoverInverter) { - DataGenerators::FuelCell(GeneratorNum).AirSup.QintakeRecovery = DataGenerators::FuelCell(GeneratorNum).Inverter.QairIntake; + FuelCell(GeneratorNum).AirSup.QintakeRecovery = FuelCell(GeneratorNum).Inverter.QairIntake; } else if (SELECT_CASE_var == DataGenerators::RecoverBattery) { - DataGenerators::FuelCell(GeneratorNum).AirSup.QintakeRecovery = DataGenerators::FuelCell(GeneratorNum).ElecStorage.QairIntake; + FuelCell(GeneratorNum).AirSup.QintakeRecovery = FuelCell(GeneratorNum).ElecStorage.QairIntake; } else if (SELECT_CASE_var == DataGenerators::NoRecoveryOnAirIntake) { - DataGenerators::FuelCell(GeneratorNum).AirSup.QintakeRecovery = 0.0; + FuelCell(GeneratorNum).AirSup.QintakeRecovery = 0.0; } } - if (DataGenerators::FuelCell(GeneratorNum).FCPM.NdotAir <= 0.0) { // just pass through, domain probably collapased in modeling - DataGenerators::FuelCell(GeneratorNum).AirSup.TairIntoFCPM = DataGenerators::FuelCell(GeneratorNum).AirSup.TairIntoBlower; + if (FuelCell(GeneratorNum).FCPM.NdotAir <= 0.0) { // just pass through, domain probably collapased in modeling + FuelCell(GeneratorNum).AirSup.TairIntoFCPM = FuelCell(GeneratorNum).AirSup.TairIntoBlower; } else { - DataGenerators::FuelCell(GeneratorNum).AirSup.TairIntoFCPM = - (((1 - DataGenerators::FuelCell(GeneratorNum).AirSup.BlowerHeatLossFactor) * DataGenerators::FuelCell(GeneratorNum).AirSup.PairCompEl + - DataGenerators::FuelCell(GeneratorNum).AirSup.QintakeRecovery) / - (DataGenerators::FuelCell(GeneratorNum).FCPM.NdotAir * Cp * 1000.0)) + - DataGenerators::FuelCell(GeneratorNum).AirSup.TairIntoBlower; // 1000 Cp units mol-> kmol + FuelCell(GeneratorNum).AirSup.TairIntoFCPM = + (((1 - FuelCell(GeneratorNum).AirSup.BlowerHeatLossFactor) * FuelCell(GeneratorNum).AirSup.PairCompEl + + FuelCell(GeneratorNum).AirSup.QintakeRecovery) / + (FuelCell(GeneratorNum).FCPM.NdotAir * Cp * 1000.0)) + + FuelCell(GeneratorNum).AirSup.TairIntoBlower; // 1000 Cp units mol-> kmol } - DataGenerators::FuelCell(GeneratorNum).AirSup.QskinLoss = DataGenerators::FuelCell(GeneratorNum).AirSup.BlowerHeatLossFactor * DataGenerators::FuelCell(GeneratorNum).AirSup.PairCompEl; + FuelCell(GeneratorNum).AirSup.QskinLoss = FuelCell(GeneratorNum).AirSup.BlowerHeatLossFactor * FuelCell(GeneratorNum).AirSup.PairCompEl; - if (DataGenerators::FuelCell(GeneratorNum).AirSup.QskinLoss < 0.0) { - // write(*,*) 'problem in AirSup%QskinLoss ', DataGenerators::FuelCell(GeneratorNum)%AirSup%QskinLoss - ShowWarningError("problem in AirSup%QskinLoss " + General::RoundSigDigits(DataGenerators::FuelCell(GeneratorNum).AirSup.QskinLoss, 3)); - DataGenerators::FuelCell(GeneratorNum).AirSup.QskinLoss = 0.0; + if (FuelCell(GeneratorNum).AirSup.QskinLoss < 0.0) { + // write(*,*) 'problem in AirSup%QskinLoss ', FuelCell(GeneratorNum)%AirSup%QskinLoss + ShowWarningError("problem in AirSup%QskinLoss " + General::RoundSigDigits(FuelCell(GeneratorNum).AirSup.QskinLoss, 3)); + FuelCell(GeneratorNum).AirSup.QskinLoss = 0.0; } Real64 Hmolair; // temp enthalpy of air mixture in KJ/mol - FigureAirEnthalpy(GeneratorNum, DataGenerators::FuelCell(GeneratorNum).AirSup.TairIntoFCPM, Hmolair); // (Hmolair in KJ/mol) + FigureAirEnthalpy(GeneratorNum, FuelCell(GeneratorNum).AirSup.TairIntoFCPM, Hmolair); // (Hmolair in KJ/mol) // units, NdotAir in kmol/sec.; Hmolfuel in KJ/mol , // factor of 1000's to get to J/s or watts - DataGenerators::FuelCell(GeneratorNum).FCPM.TotAirInEnthalphy = Hmolair * 1000.0 * DataGenerators::FuelCell(GeneratorNum).FCPM.NdotAir * 1000.0; + FuelCell(GeneratorNum).FCPM.TotAirInEnthalphy = Hmolair * 1000.0 * FuelCell(GeneratorNum).FCPM.NdotAir * 1000.0; // calculation Step 8, Figure Product Gases // figure stoic N dot for air - Real64 NdotO2 = DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).StoicOxygenRate * DataGenerators::FuelCell(GeneratorNum).FCPM.NdotFuel; + Real64 NdotO2 = DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).StoicOxygenRate * FuelCell(GeneratorNum).FCPM.NdotFuel; // Air in excess of match for fuel - Real64 NdotStoicAir = NdotO2 / DataGenerators::FuelCell(GeneratorNum).AirSup.O2fraction; + Real64 NdotStoicAir = NdotO2 / FuelCell(GeneratorNum).AirSup.O2fraction; // figure excess air rate // Air in excess of match for fuel - Real64 NdotExcessAir = DataGenerators::FuelCell(GeneratorNum).FCPM.NdotAir - NdotStoicAir; + Real64 NdotExcessAir = FuelCell(GeneratorNum).FCPM.NdotAir - NdotStoicAir; if (NdotExcessAir < 0) { // can't meet stoichiometric fuel reaction ShowWarningError("Air flow rate into fuel cell is too low for stoichiometric fuel reaction"); - ShowContinueError("Increase air flow in GENERATOR:FC:AIR SUPPLY object:" + DataGenerators::FuelCell(GeneratorNum).AirSup.Name); + ShowContinueError("Increase air flow in GENERATOR:FC:AIR SUPPLY object:" + FuelCell(GeneratorNum).AirSup.Name); } // figure CO2 and Water rate from products (coefs setup during one-time processing in gas phase library ) // CO2 from reaction - Real64 NdotCO2ProdGas = DataGenerators::FuelCell(GeneratorNum).FCPM.NdotFuel * DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).CO2ProductGasCoef; + Real64 NdotCO2ProdGas = FuelCell(GeneratorNum).FCPM.NdotFuel * DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).CO2ProductGasCoef; // Water from reaction - Real64 NdotH20ProdGas = DataGenerators::FuelCell(GeneratorNum).FCPM.NdotFuel * DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).H20ProductGasCoef; + Real64 NdotH20ProdGas = FuelCell(GeneratorNum).FCPM.NdotFuel * DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).H20ProductGasCoef; // set product gas constituent fractions (assume five usual components) Real64 NdotCO2 = 0.0; // temp CO2 molar rate coef product gas stream @@ -1701,115 +1703,115 @@ namespace FuelCellElectricGenerator { // Product gas constituents are fixed (not a user defined thing) - for (int thisGas = 1; thisGas <= DataGenerators::FuelCell(GeneratorNum).AirSup.NumConstituents; ++thisGas) { + for (int thisGas = 1; thisGas <= FuelCell(GeneratorNum).AirSup.NumConstituents; ++thisGas) { { - auto const SELECT_CASE_var(DataGenerators::FuelCell(GeneratorNum).AirSup.GasLibID(thisGas)); + auto const SELECT_CASE_var(FuelCell(GeneratorNum).AirSup.GasLibID(thisGas)); if (SELECT_CASE_var == 1) { // all the CO2 coming in plus the new CO2 from reactions - NdotCO2 = NdotCO2ProdGas + DataGenerators::FuelCell(GeneratorNum).AirSup.ConstitMolalFract(thisGas) * DataGenerators::FuelCell(GeneratorNum).FCPM.NdotAir; + NdotCO2 = NdotCO2ProdGas + FuelCell(GeneratorNum).AirSup.ConstitMolalFract(thisGas) * FuelCell(GeneratorNum).FCPM.NdotAir; } else if (SELECT_CASE_var == 2) { // all the nitrogen coming in - NdotN2 = DataGenerators::FuelCell(GeneratorNum).FCPM.NdotAir * DataGenerators::FuelCell(GeneratorNum).AirSup.ConstitMolalFract(thisGas); + NdotN2 = FuelCell(GeneratorNum).FCPM.NdotAir * FuelCell(GeneratorNum).AirSup.ConstitMolalFract(thisGas); } else if (SELECT_CASE_var == 3) { // all the oxygen in the excess air stream - Ndot02 = NdotExcessAir * DataGenerators::FuelCell(GeneratorNum).AirSup.ConstitMolalFract(thisGas); + Ndot02 = NdotExcessAir * FuelCell(GeneratorNum).AirSup.ConstitMolalFract(thisGas); } else if (SELECT_CASE_var == 4) { // all the H20 coming in plus the new H20 from reactions and the H20 from water used in reforming - NdotH20 = NdotH20ProdGas + DataGenerators::FuelCell(GeneratorNum).AirSup.ConstitMolalFract(thisGas) * DataGenerators::FuelCell(GeneratorNum).FCPM.NdotAir; - //+ DataGenerators::FuelCell(GeneratorNum)%FCPM%NdotLiqwater + NdotH20 = NdotH20ProdGas + FuelCell(GeneratorNum).AirSup.ConstitMolalFract(thisGas) * FuelCell(GeneratorNum).FCPM.NdotAir; + //+ FuelCell(GeneratorNum)%FCPM%NdotLiqwater } else if (SELECT_CASE_var == 5) { // all the argon coming in. - NdotAr = DataGenerators::FuelCell(GeneratorNum).FCPM.NdotAir * DataGenerators::FuelCell(GeneratorNum).AirSup.ConstitMolalFract(thisGas); + NdotAr = FuelCell(GeneratorNum).FCPM.NdotAir * FuelCell(GeneratorNum).AirSup.ConstitMolalFract(thisGas); } else { } } } - DataGenerators::FuelCell(GeneratorNum).FCPM.NdotProdGas = NdotCO2 + NdotN2 + Ndot02 + NdotH20 + NdotAr; + FuelCell(GeneratorNum).FCPM.NdotProdGas = NdotCO2 + NdotN2 + Ndot02 + NdotH20 + NdotAr; // now that we have the total, figure molar fractions - DataGenerators::FuelCell(GeneratorNum).FCPM.ConstitMolalFract(1) = NdotCO2 / DataGenerators::FuelCell(GeneratorNum).FCPM.NdotProdGas; + FuelCell(GeneratorNum).FCPM.ConstitMolalFract(1) = NdotCO2 / FuelCell(GeneratorNum).FCPM.NdotProdGas; // all the nitrogen comming in - DataGenerators::FuelCell(GeneratorNum).FCPM.ConstitMolalFract(2) = NdotN2 / DataGenerators::FuelCell(GeneratorNum).FCPM.NdotProdGas; + FuelCell(GeneratorNum).FCPM.ConstitMolalFract(2) = NdotN2 / FuelCell(GeneratorNum).FCPM.NdotProdGas; // all the oxygen in the excess air stream - DataGenerators::FuelCell(GeneratorNum).FCPM.ConstitMolalFract(3) = Ndot02 / DataGenerators::FuelCell(GeneratorNum).FCPM.NdotProdGas; + FuelCell(GeneratorNum).FCPM.ConstitMolalFract(3) = Ndot02 / FuelCell(GeneratorNum).FCPM.NdotProdGas; // all the H20 comming in plus the new H20 from reactions and the H20 from water used in reforming - DataGenerators::FuelCell(GeneratorNum).FCPM.ConstitMolalFract(4) = NdotH20 / DataGenerators::FuelCell(GeneratorNum).FCPM.NdotProdGas; + FuelCell(GeneratorNum).FCPM.ConstitMolalFract(4) = NdotH20 / FuelCell(GeneratorNum).FCPM.NdotProdGas; // all the argon coming in. - DataGenerators::FuelCell(GeneratorNum).FCPM.ConstitMolalFract(5) = NdotAr / DataGenerators::FuelCell(GeneratorNum).FCPM.NdotProdGas; + FuelCell(GeneratorNum).FCPM.ConstitMolalFract(5) = NdotAr / FuelCell(GeneratorNum).FCPM.NdotProdGas; // HmolProdGases KJ/mol) Real64 HmolProdGases; // enthalpy of product gas mixture in KJ/mol - FigureProductGasesEnthalpy(GeneratorNum, DataGenerators::FuelCell(GeneratorNum).FCPM.TprodGasLeavingFCPM, HmolProdGases); + FigureProductGasesEnthalpy(GeneratorNum, FuelCell(GeneratorNum).FCPM.TprodGasLeavingFCPM, HmolProdGases); // units, NdotProdGas in kmol/sec.; HmolProdGases in KJ/mol , // factor of 1000's to get to J/s or watts - DataGenerators::FuelCell(GeneratorNum).FCPM.TotProdGasEnthalphy = HmolProdGases * 1000.0 * DataGenerators::FuelCell(GeneratorNum).FCPM.NdotProdGas * 1000.0; + FuelCell(GeneratorNum).FCPM.TotProdGasEnthalphy = HmolProdGases * 1000.0 * FuelCell(GeneratorNum).FCPM.NdotProdGas * 1000.0; // calculation Step 9, Figure Skin lossess - if (DataGenerators::FuelCell(GeneratorNum).FCPM.SkinLossMode == DataGenerators::ConstantRateSkinLoss) { + if (FuelCell(GeneratorNum).FCPM.SkinLossMode == DataGenerators::ConstantRateSkinLoss) { // do nothing just use QdotSkin - } else if (DataGenerators::FuelCell(GeneratorNum).FCPM.SkinLossMode == DataGenerators::UADTSkinLoss) { + } else if (FuelCell(GeneratorNum).FCPM.SkinLossMode == DataGenerators::UADTSkinLoss) { // get zone air temp - if (DataGenerators::FuelCell(GeneratorNum).FCPM.ZoneID > 0) { - DataGenerators::FuelCell(GeneratorNum).FCPM.QdotSkin = DataGenerators::FuelCell(GeneratorNum).FCPM.UAskin * - (DataGenerators::FuelCell(GeneratorNum).FCPM.TprodGasLeavingFCPM - DataHeatBalFanSys::ZT(DataGenerators::FuelCell(GeneratorNum).FCPM.ZoneID)); + if (FuelCell(GeneratorNum).FCPM.ZoneID > 0) { + FuelCell(GeneratorNum).FCPM.QdotSkin = FuelCell(GeneratorNum).FCPM.UAskin * + (FuelCell(GeneratorNum).FCPM.TprodGasLeavingFCPM - DataHeatBalFanSys::ZT(FuelCell(GeneratorNum).FCPM.ZoneID)); } - } else if (DataGenerators::FuelCell(GeneratorNum).FCPM.SkinLossMode == DataGenerators::QuadraticFuelNdotSkin) { + } else if (FuelCell(GeneratorNum).FCPM.SkinLossMode == DataGenerators::QuadraticFuelNdotSkin) { - DataGenerators::FuelCell(GeneratorNum).FCPM.QdotSkin = CurveManager::CurveValue(DataGenerators::FuelCell(GeneratorNum).FCPM.SkinLossCurveID, DataGenerators::FuelCell(GeneratorNum).FCPM.NdotFuel); + FuelCell(GeneratorNum).FCPM.QdotSkin = CurveManager::CurveValue(FuelCell(GeneratorNum).FCPM.SkinLossCurveID, FuelCell(GeneratorNum).FCPM.NdotFuel); } // calculation Step 10, AC FCPM power ancillaries - DataGenerators::FuelCell(GeneratorNum).FCPM.PelancillariesAC = - DataGenerators::FuelCell(GeneratorNum).FCPM.ANC0 + DataGenerators::FuelCell(GeneratorNum).FCPM.ANC1 * DataGenerators::FuelCell(GeneratorNum).FCPM.NdotFuel; + FuelCell(GeneratorNum).FCPM.PelancillariesAC = + FuelCell(GeneratorNum).FCPM.ANC0 + FuelCell(GeneratorNum).FCPM.ANC1 * FuelCell(GeneratorNum).FCPM.NdotFuel; // calculation Step 11, Dilution air - FigureAirEnthalpy(GeneratorNum, DataGenerators::FuelCell(GeneratorNum).AirSup.TairIntoBlower, Hmolair); // (Hmolair in KJ/mol) + FigureAirEnthalpy(GeneratorNum, FuelCell(GeneratorNum).AirSup.TairIntoBlower, Hmolair); // (Hmolair in KJ/mol) // units, NdotDilutionAir in kmol/sec.; Hmolair in KJ/mol , // factor of 1000's to get to J/s or watts - DataGenerators::FuelCell(GeneratorNum).FCPM.DilutionAirInEnthalpy = Hmolair * 1000.0 * DataGenerators::FuelCell(GeneratorNum).FCPM.NdotDilutionAir * 1000.0; - DataGenerators::FuelCell(GeneratorNum).FCPM.DilutionAirOutEnthalpy = - DataGenerators::FuelCell(GeneratorNum).FCPM.DilutionAirInEnthalpy + DataGenerators::FuelCell(GeneratorNum).FCPM.StackHeatLossToDilution; + FuelCell(GeneratorNum).FCPM.DilutionAirInEnthalpy = Hmolair * 1000.0 * FuelCell(GeneratorNum).FCPM.NdotDilutionAir * 1000.0; + FuelCell(GeneratorNum).FCPM.DilutionAirOutEnthalpy = + FuelCell(GeneratorNum).FCPM.DilutionAirInEnthalpy + FuelCell(GeneratorNum).FCPM.StackHeatLossToDilution; // calculation Step 12, Calculate Reforming water out enthalpy Real64 HGasWater; // temp enthalpy of gaseous water in KJ/mol No Formation - FigureGaseousWaterEnthalpy(DataGenerators::FuelCell(GeneratorNum).FCPM.TprodGasLeavingFCPM, HGasWater); + FigureGaseousWaterEnthalpy(FuelCell(GeneratorNum).FCPM.TprodGasLeavingFCPM, HGasWater); - DataGenerators::FuelCell(GeneratorNum).FCPM.WaterOutEnthalpy = HGasWater * 1000.0 * DataGenerators::FuelCell(GeneratorNum).FCPM.NdotLiqwater * 1000.0; + FuelCell(GeneratorNum).FCPM.WaterOutEnthalpy = HGasWater * 1000.0 * FuelCell(GeneratorNum).FCPM.NdotLiqwater * 1000.0; // calculation Step 13, Calculate Heat balance // move all terms in Equation 7 to RHS and calculate imbalance - Real64 MagofImbalance = -DataGenerators::FuelCell(GeneratorNum).FCPM.TotFuelInEnthalphy - DataGenerators::FuelCell(GeneratorNum).FCPM.TotAirInEnthalphy - - DataGenerators::FuelCell(GeneratorNum).FCPM.WaterInEnthalpy - DataGenerators::FuelCell(GeneratorNum).FCPM.DilutionAirInEnthalpy - - DataGenerators::FuelCell(GeneratorNum).FCPM.NdotFuel * DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).LHV * 1000000.0 - - DataGenerators::FuelCell(GeneratorNum).FCPM.PelancillariesAC + DataGenerators::FuelCell(GeneratorNum).FCPM.Pel + - DataGenerators::FuelCell(GeneratorNum).FCPM.TotProdGasEnthalphy + DataGenerators::FuelCell(GeneratorNum).FCPM.WaterOutEnthalpy + - DataGenerators::FuelCell(GeneratorNum).FCPM.QdotStackCool + DataGenerators::FuelCell(GeneratorNum).FCPM.QdotSkin + - DataGenerators::FuelCell(GeneratorNum).FCPM.DilutionAirOutEnthalpy; + Real64 MagofImbalance = -FuelCell(GeneratorNum).FCPM.TotFuelInEnthalphy - FuelCell(GeneratorNum).FCPM.TotAirInEnthalphy - + FuelCell(GeneratorNum).FCPM.WaterInEnthalpy - FuelCell(GeneratorNum).FCPM.DilutionAirInEnthalpy - + FuelCell(GeneratorNum).FCPM.NdotFuel * DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).LHV * 1000000.0 - + FuelCell(GeneratorNum).FCPM.PelancillariesAC + FuelCell(GeneratorNum).FCPM.Pel + + FuelCell(GeneratorNum).FCPM.TotProdGasEnthalphy + FuelCell(GeneratorNum).FCPM.WaterOutEnthalpy + + FuelCell(GeneratorNum).FCPM.QdotStackCool + FuelCell(GeneratorNum).FCPM.QdotSkin + + FuelCell(GeneratorNum).FCPM.DilutionAirOutEnthalpy; // Now find a new total prod Gas Enthalphy that would result in an energy balance // TODO check signs... - Real64 tmpTotProdGasEnthalpy = DataGenerators::FuelCell(GeneratorNum).FCPM.TotProdGasEnthalphy - MagofImbalance; + Real64 tmpTotProdGasEnthalpy = FuelCell(GeneratorNum).FCPM.TotProdGasEnthalphy - MagofImbalance; // solve for a new TprodGasLeavingFCPM using regula falsi method @@ -1819,8 +1821,8 @@ namespace FuelCellElectricGenerator { Array1D Par(3); // parameters passed in to SolveRoot Par(1) = double(GeneratorNum); Par(2) = tmpTotProdGasEnthalpy; - Par(3) = DataGenerators::FuelCell(GeneratorNum).FCPM.NdotProdGas; - Real64 tmpTprodGas = DataGenerators::FuelCell(GeneratorNum).FCPM.TprodGasLeavingFCPM; + Par(3) = FuelCell(GeneratorNum).FCPM.NdotProdGas; + Real64 tmpTprodGas = FuelCell(GeneratorNum).FCPM.TprodGasLeavingFCPM; General::SolveRoot(Acc, MaxIter, SolverFlag, tmpTprodGas, FuelCellProductGasEnthResidual, DataGenerators::MinProductGasTemp, DataGenerators::MaxProductGasTemp, Par); if (SolverFlag == -2) { @@ -1831,7 +1833,7 @@ namespace FuelCellElectricGenerator { ShowWarningError("CalcFuelCellGeneratorModel: Root Solver problem, flag = -1, check accuracy and iterations, did not converge"); } if (SolverFlag > 0) { - DataGenerators::FuelCell(GeneratorNum).FCPM.TprodGasLeavingFCPM = tmpTprodGas; + FuelCell(GeneratorNum).FCPM.TprodGasLeavingFCPM = tmpTprodGas; // write(*,*) 'Number of Root Solver iterations: ', solverFlag } @@ -1845,38 +1847,38 @@ namespace FuelCellElectricGenerator { PintoInverter = Pel - Pstorage; // refine power conditioning losses with more current power production - if (DataGenerators::FuelCell(GeneratorNum).Inverter.EffMode == DataGenerators::InverterEffConstant) { + if (FuelCell(GeneratorNum).Inverter.EffMode == DataGenerators::InverterEffConstant) { - PpcuLosses = (1.0 - DataGenerators::FuelCell(GeneratorNum).Inverter.ConstEff) * PintoInverter; + PpcuLosses = (1.0 - FuelCell(GeneratorNum).Inverter.ConstEff) * PintoInverter; } - if (DataGenerators::FuelCell(GeneratorNum).Inverter.EffMode == DataGenerators::InverterEffQuadratic) { + if (FuelCell(GeneratorNum).Inverter.EffMode == DataGenerators::InverterEffQuadratic) { - PpcuLosses = (1.0 - CurveManager::CurveValue(DataGenerators::FuelCell(GeneratorNum).Inverter.EffQuadraticCurveID, PintoInverter)) * PintoInverter; + PpcuLosses = (1.0 - CurveManager::CurveValue(FuelCell(GeneratorNum).Inverter.EffQuadraticCurveID, PintoInverter)) * PintoInverter; } PoutofInverter = PintoInverter - PpcuLosses; - DataGenerators::FuelCell(GeneratorNum).ACPowerGen = PoutofInverter - DataGenerators::FuelCell(GeneratorNum).FCPM.PelancillariesAC - - DataGenerators::FuelCell(GeneratorNum).AirSup.PairCompEl - DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).PfuelCompEl - - DataGenerators::FuelCell(GeneratorNum).WaterSup.PwaterCompEl; - DataGenerators::FuelCell(GeneratorNum).Inverter.PCUlosses = PpcuLosses; + FuelCell(GeneratorNum).ACPowerGen = PoutofInverter - FuelCell(GeneratorNum).FCPM.PelancillariesAC - + FuelCell(GeneratorNum).AirSup.PairCompEl - DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).PfuelCompEl - + FuelCell(GeneratorNum).WaterSup.PwaterCompEl; + FuelCell(GeneratorNum).Inverter.PCUlosses = PpcuLosses; // model assumes air intake is drawn over power conditioner to recovery heat - DataGenerators::FuelCell(GeneratorNum).Inverter.QairIntake = DataGenerators::FuelCell(GeneratorNum).Inverter.PCUlosses; + FuelCell(GeneratorNum).Inverter.QairIntake = FuelCell(GeneratorNum).Inverter.PCUlosses; CalcFuelCellAuxHeater(GeneratorNum); CalcFuelCellGenHeatRecovery(GeneratorNum); // calculation Step 11, If imbalance below threshold, then exit out of do loop. - if ((std::abs(MagofImbalance) < std::abs(DataGenerators::ImBalanceTol * DataGenerators::FuelCell(GeneratorNum).FCPM.Pel)) && (iter > 2)) { + if ((std::abs(MagofImbalance) < std::abs(DataGenerators::ImBalanceTol * FuelCell(GeneratorNum).FCPM.Pel)) && (iter > 2)) { break; } } // sequential substitution loop - DataGenerators::FuelCell(GeneratorNum).FCPM.SeqSubstitIter = iter; - DataGenerators::FuelCell(GeneratorNum).FCPM.RegulaFalsiIter = SolverFlag; + FuelCell(GeneratorNum).FCPM.SeqSubstitIter = iter; + FuelCell(GeneratorNum).FCPM.RegulaFalsiIter = SolverFlag; } void ManageElectStorInteractions(int const Num, // Generator number, index for structure @@ -1905,15 +1907,15 @@ namespace FuelCellElectricGenerator { // step 1 figure out what is desired of electrical storage system - if (DataGenerators::FuelCell(Num).FCPM.Pel < (Pdemand)) { + if (FuelCell(Num).FCPM.Pel < (Pdemand)) { // draw from storage - tmpPdraw = (Pdemand)-DataGenerators::FuelCell(Num).FCPM.Pel; + tmpPdraw = (Pdemand)-FuelCell(Num).FCPM.Pel; drawing = true; } - if (DataGenerators::FuelCell(Num).FCPM.Pel > (Pdemand)) { + if (FuelCell(Num).FCPM.Pel > (Pdemand)) { // add to storage - tmpPcharge = DataGenerators::FuelCell(Num).FCPM.Pel - (Pdemand); + tmpPcharge = FuelCell(Num).FCPM.Pel - (Pdemand); charging = true; } @@ -1921,45 +1923,45 @@ namespace FuelCellElectricGenerator { if (charging) { - if (DataGenerators::FuelCell(Num).ElecStorage.StorageModelMode == DataGenerators::SimpleEffConstraints) { + if (FuelCell(Num).ElecStorage.StorageModelMode == DataGenerators::SimpleEffConstraints) { - if (DataGenerators::FuelCell(Num).ElecStorage.LastTimeStepStateOfCharge >= DataGenerators::FuelCell(Num).ElecStorage.NominalEnergyCapacity) { + if (FuelCell(Num).ElecStorage.LastTimeStepStateOfCharge >= FuelCell(Num).ElecStorage.NominalEnergyCapacity) { // storage full! no more allowed! PgridOverage = tmpPcharge; tmpPcharge = 0.0; Constrained = true; } - if (tmpPcharge > DataGenerators::FuelCell(Num).ElecStorage.MaxPowerStore) { - PgridOverage = tmpPcharge - DataGenerators::FuelCell(Num).ElecStorage.MaxPowerStore; - tmpPcharge = DataGenerators::FuelCell(Num).ElecStorage.MaxPowerStore; + if (tmpPcharge > FuelCell(Num).ElecStorage.MaxPowerStore) { + PgridOverage = tmpPcharge - FuelCell(Num).ElecStorage.MaxPowerStore; + tmpPcharge = FuelCell(Num).ElecStorage.MaxPowerStore; Constrained = true; } // now add energy to storage from charging - if ((DataGenerators::FuelCell(Num).ElecStorage.LastTimeStepStateOfCharge + - tmpPcharge * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour * DataGenerators::FuelCell(Num).ElecStorage.EnergeticEfficCharge) < - DataGenerators::FuelCell(Num).ElecStorage.NominalEnergyCapacity) { + if ((FuelCell(Num).ElecStorage.LastTimeStepStateOfCharge + + tmpPcharge * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour * FuelCell(Num).ElecStorage.EnergeticEfficCharge) < + FuelCell(Num).ElecStorage.NominalEnergyCapacity) { - DataGenerators::FuelCell(Num).ElecStorage.ThisTimeStepStateOfCharge = - DataGenerators::FuelCell(Num).ElecStorage.LastTimeStepStateOfCharge + - tmpPcharge * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour * DataGenerators::FuelCell(Num).ElecStorage.EnergeticEfficCharge; + FuelCell(Num).ElecStorage.ThisTimeStepStateOfCharge = + FuelCell(Num).ElecStorage.LastTimeStepStateOfCharge + + tmpPcharge * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour * FuelCell(Num).ElecStorage.EnergeticEfficCharge; } else { // would over charge this time step - tmpPcharge = (DataGenerators::FuelCell(Num).ElecStorage.NominalEnergyCapacity - DataGenerators::FuelCell(Num).ElecStorage.LastTimeStepStateOfCharge) / - (DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour * DataGenerators::FuelCell(Num).ElecStorage.EnergeticEfficCharge); + tmpPcharge = (FuelCell(Num).ElecStorage.NominalEnergyCapacity - FuelCell(Num).ElecStorage.LastTimeStepStateOfCharge) / + (DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour * FuelCell(Num).ElecStorage.EnergeticEfficCharge); Constrained = true; - DataGenerators::FuelCell(Num).ElecStorage.ThisTimeStepStateOfCharge = - DataGenerators::FuelCell(Num).ElecStorage.LastTimeStepStateOfCharge + - tmpPcharge * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour * DataGenerators::FuelCell(Num).ElecStorage.EnergeticEfficCharge; + FuelCell(Num).ElecStorage.ThisTimeStepStateOfCharge = + FuelCell(Num).ElecStorage.LastTimeStepStateOfCharge + + tmpPcharge * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour * FuelCell(Num).ElecStorage.EnergeticEfficCharge; } // losses go into QairIntake - DataGenerators::FuelCell(Num).ElecStorage.QairIntake = tmpPcharge * (1.0 - DataGenerators::FuelCell(Num).ElecStorage.EnergeticEfficCharge); + FuelCell(Num).ElecStorage.QairIntake = tmpPcharge * (1.0 - FuelCell(Num).ElecStorage.EnergeticEfficCharge); - } else if (DataGenerators::FuelCell(Num).ElecStorage.StorageModelMode == DataGenerators::LeadAcidBatterManwellMcGowan) { + } else if (FuelCell(Num).ElecStorage.StorageModelMode == DataGenerators::LeadAcidBatterManwellMcGowan) { ShowWarningError("ManageElectStorInteractions: Not yet implemented: Lead Acid Battery By Manwell and McGowan 1993 "); - } else if (DataGenerators::FuelCell(Num).ElecStorage.StorageModelMode == DataGenerators::LeadAcidBatterySaupe) { + } else if (FuelCell(Num).ElecStorage.StorageModelMode == DataGenerators::LeadAcidBatterySaupe) { ShowWarningError("ManageElectStorInteractions: Not yet implemented: Lead Acid Battery By Saupe 1993 "); } else { @@ -1972,41 +1974,41 @@ namespace FuelCellElectricGenerator { } // charging if (drawing) { - if (DataGenerators::FuelCell(Num).ElecStorage.StorageModelMode == DataGenerators::SimpleEffConstraints) { + if (FuelCell(Num).ElecStorage.StorageModelMode == DataGenerators::SimpleEffConstraints) { - if (DataGenerators::FuelCell(Num).ElecStorage.LastTimeStepStateOfCharge <= 0.0) { + if (FuelCell(Num).ElecStorage.LastTimeStepStateOfCharge <= 0.0) { // storage empty no more allowed! tmpPdraw = 0.0; Constrained = true; drawing = false; } - if (tmpPdraw > DataGenerators::FuelCell(Num).ElecStorage.MaxPowerDraw) { - tmpPdraw = DataGenerators::FuelCell(Num).ElecStorage.MaxPowerDraw; + if (tmpPdraw > FuelCell(Num).ElecStorage.MaxPowerDraw) { + tmpPdraw = FuelCell(Num).ElecStorage.MaxPowerDraw; Constrained = true; } // now take energy from storage by drawing (amplified by energetic effic) - if ((DataGenerators::FuelCell(Num).ElecStorage.LastTimeStepStateOfCharge - - tmpPdraw * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour / DataGenerators::FuelCell(Num).ElecStorage.EnergeticEfficDischarge) > 0.0) { + if ((FuelCell(Num).ElecStorage.LastTimeStepStateOfCharge - + tmpPdraw * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour / FuelCell(Num).ElecStorage.EnergeticEfficDischarge) > 0.0) { - DataGenerators::FuelCell(Num).ElecStorage.ThisTimeStepStateOfCharge = - DataGenerators::FuelCell(Num).ElecStorage.LastTimeStepStateOfCharge - - tmpPdraw * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour / DataGenerators::FuelCell(Num).ElecStorage.EnergeticEfficDischarge; + FuelCell(Num).ElecStorage.ThisTimeStepStateOfCharge = + FuelCell(Num).ElecStorage.LastTimeStepStateOfCharge - + tmpPdraw * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour / FuelCell(Num).ElecStorage.EnergeticEfficDischarge; } else { // would over drain storage this timestep so reduce tmpPdraw - tmpPdraw = DataGenerators::FuelCell(Num).ElecStorage.LastTimeStepStateOfCharge * DataGenerators::FuelCell(Num).ElecStorage.EnergeticEfficDischarge / + tmpPdraw = FuelCell(Num).ElecStorage.LastTimeStepStateOfCharge * FuelCell(Num).ElecStorage.EnergeticEfficDischarge / (DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour); - DataGenerators::FuelCell(Num).ElecStorage.ThisTimeStepStateOfCharge = - DataGenerators::FuelCell(Num).ElecStorage.LastTimeStepStateOfCharge - - tmpPdraw * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour / DataGenerators::FuelCell(Num).ElecStorage.EnergeticEfficDischarge; + FuelCell(Num).ElecStorage.ThisTimeStepStateOfCharge = + FuelCell(Num).ElecStorage.LastTimeStepStateOfCharge - + tmpPdraw * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour / FuelCell(Num).ElecStorage.EnergeticEfficDischarge; Constrained = true; } // losses go into QairIntake - DataGenerators::FuelCell(Num).ElecStorage.QairIntake = tmpPdraw * (1.0 / DataGenerators::FuelCell(Num).ElecStorage.EnergeticEfficDischarge - 1.0); - } else if (DataGenerators::FuelCell(Num).ElecStorage.StorageModelMode == DataGenerators::LeadAcidBatterManwellMcGowan) { + FuelCell(Num).ElecStorage.QairIntake = tmpPdraw * (1.0 / FuelCell(Num).ElecStorage.EnergeticEfficDischarge - 1.0); + } else if (FuelCell(Num).ElecStorage.StorageModelMode == DataGenerators::LeadAcidBatterManwellMcGowan) { ShowWarningError("ManageElectStorInteractions: Not yet implemented: Lead Acid Battery By Manwell and McGowan 1993 "); - } else if (DataGenerators::FuelCell(Num).ElecStorage.StorageModelMode == DataGenerators::LeadAcidBatterySaupe) { + } else if (FuelCell(Num).ElecStorage.StorageModelMode == DataGenerators::LeadAcidBatterySaupe) { ShowWarningError("ManageElectStorInteractions: Not yet implemented: Lead Acid Battery By Saupe 1993 "); } else { @@ -2020,21 +2022,21 @@ namespace FuelCellElectricGenerator { if ((!charging) && (!drawing)) { - DataGenerators::FuelCell(Num).ElecStorage.ThisTimeStepStateOfCharge = DataGenerators::FuelCell(Num).ElecStorage.LastTimeStepStateOfCharge; - DataGenerators::FuelCell(Num).ElecStorage.PelNeedFromStorage = 0.0; - DataGenerators::FuelCell(Num).ElecStorage.PelFromStorage = 0.0; - DataGenerators::FuelCell(Num).ElecStorage.QairIntake = 0.0; + FuelCell(Num).ElecStorage.ThisTimeStepStateOfCharge = FuelCell(Num).ElecStorage.LastTimeStepStateOfCharge; + FuelCell(Num).ElecStorage.PelNeedFromStorage = 0.0; + FuelCell(Num).ElecStorage.PelFromStorage = 0.0; + FuelCell(Num).ElecStorage.QairIntake = 0.0; } if (Pstorage >= 0.0) { - DataGenerators::FuelCell(Num).ElecStorage.PelIntoStorage = Pstorage; - DataGenerators::FuelCell(Num).ElecStorage.PelFromStorage = 0.0; + FuelCell(Num).ElecStorage.PelIntoStorage = Pstorage; + FuelCell(Num).ElecStorage.PelFromStorage = 0.0; } if (Pstorage < 0.0) { - DataGenerators::FuelCell(Num).ElecStorage.PelIntoStorage = 0.0; - DataGenerators::FuelCell(Num).ElecStorage.PelFromStorage = -Pstorage; + FuelCell(Num).ElecStorage.PelIntoStorage = 0.0; + FuelCell(Num).ElecStorage.PelFromStorage = -Pstorage; } } @@ -2120,8 +2122,8 @@ namespace FuelCellElectricGenerator { Real64 const pow_3_Tkel(pow_3(Tkel)); Real64 const pow_4_Tkel(pow_4(Tkel)); - for (int thisConstit = 1; thisConstit <= DataGenerators::FuelCell(GeneratorNum).AirSup.NumConstituents; ++thisConstit) { - int gasID = DataGenerators::FuelCell(GeneratorNum).AirSup.GasLibID(thisConstit); + for (int thisConstit = 1; thisConstit <= FuelCell(GeneratorNum).AirSup.NumConstituents; ++thisConstit) { + int gasID = FuelCell(GeneratorNum).AirSup.GasLibID(thisConstit); if (gasID > 0) { if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == DataGenerators::NISTShomate) { @@ -2132,7 +2134,7 @@ namespace FuelCellElectricGenerator { E = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateE; tempCp += ((A + B * Tsho + C * pow_2_Tsho + D * pow_3_Tsho + E / pow_2_Tsho) * - DataGenerators::FuelCell(GeneratorNum).AirSup.ConstitMolalFract(thisConstit)); + FuelCell(GeneratorNum).AirSup.ConstitMolalFract(thisConstit)); } if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == DataGenerators::NASAPolynomial) { @@ -2144,7 +2146,7 @@ namespace FuelCellElectricGenerator { A5 = DataGenerators::GasPhaseThermoChemistryData(gasID).NASA_A5; tempCp += (A1 + A2 * Tkel + A3 * pow_2_Tkel + A4 * pow_3_Tkel + A5 * pow_4_Tkel) * DataGenerators::RinKJperMolpK * - DataGenerators::FuelCell(GeneratorNum).AirSup.ConstitMolalFract(thisConstit); + FuelCell(GeneratorNum).AirSup.ConstitMolalFract(thisConstit); } } } @@ -2202,8 +2204,8 @@ namespace FuelCellElectricGenerator { Real64 const pow_3_Tkel(pow_3(Tkel)); Real64 const pow_4_Tkel(pow_4(Tkel)); - for (int thisConstit = 1; thisConstit <= DataGenerators::FuelCell(GeneratorNum).AirSup.NumConstituents; ++thisConstit) { - int gasID = DataGenerators::FuelCell(GeneratorNum).AirSup.GasLibID(thisConstit); + for (int thisConstit = 1; thisConstit <= FuelCell(GeneratorNum).AirSup.NumConstituents; ++thisConstit) { + int gasID = FuelCell(GeneratorNum).AirSup.GasLibID(thisConstit); if (gasID > 0) { if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == DataGenerators::NISTShomate) { @@ -2217,7 +2219,7 @@ namespace FuelCellElectricGenerator { Real64 HairI = (A * Tsho + B * pow_2_Tsho / 2.0 + C * pow_3_Tsho / 3.0 + D * pow_4_Tsho / 4.0 - E / Tsho + F - H); - tempHair += HairI * DataGenerators::FuelCell(GeneratorNum).AirSup.ConstitMolalFract(thisConstit); + tempHair += HairI * FuelCell(GeneratorNum).AirSup.ConstitMolalFract(thisConstit); } if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == DataGenerators::NASAPolynomial) { A1 = DataGenerators::GasPhaseThermoChemistryData(gasID).NASA_A1; @@ -2230,7 +2232,7 @@ namespace FuelCellElectricGenerator { tempHair += (((A1 + A2 * Tkel / 2.0 + A3 * pow_2_Tkel / 3.0 + A4 * pow_3_Tkel / 4.0 + A5 * pow_4_Tkel / 5.0 + A6 / Tkel) * DataGenerators::RinKJperMolpK * Tkel) - DataGenerators::GasPhaseThermoChemistryData(gasID).StdRefMolarEnthOfForm) * - DataGenerators::FuelCell(GeneratorNum).AirSup.ConstitMolalFract(thisConstit); + FuelCell(GeneratorNum).AirSup.ConstitMolalFract(thisConstit); } } } @@ -2284,8 +2286,8 @@ namespace FuelCellElectricGenerator { Real64 const pow_3_Tkel(pow_3(Tkel)); Real64 const pow_4_Tkel(pow_4(Tkel)); - for (int thisConstit = 1; thisConstit <= DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).NumConstituents; ++thisConstit) { - int gasID = DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).GasLibID(thisConstit); + for (int thisConstit = 1; thisConstit <= DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).NumConstituents; ++thisConstit) { + int gasID = DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).GasLibID(thisConstit); if (gasID > 0) { if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == DataGenerators::NISTShomate) { @@ -2296,7 +2298,7 @@ namespace FuelCellElectricGenerator { E = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateE; tempCp += ((A + B * Tsho + C * pow_2_Tsho + D * pow_3_Tsho + E / pow_2_Tsho) * - DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).ConstitMolalFract(thisConstit)); + DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).ConstitMolalFract(thisConstit)); } if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == DataGenerators::NASAPolynomial) { @@ -2307,7 +2309,7 @@ namespace FuelCellElectricGenerator { A5 = DataGenerators::GasPhaseThermoChemistryData(gasID).NASA_A5; tempCp += (A1 + A2 * Tkel + A3 * pow_2_Tkel + A4 * pow_3_Tkel + A5 * pow_4_Tkel) * DataGenerators::RinKJperMolpK * - DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).ConstitMolalFract(thisConstit); + DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).ConstitMolalFract(thisConstit); } } } @@ -2365,8 +2367,8 @@ namespace FuelCellElectricGenerator { Real64 const pow_3_Tkel(pow_3(Tkel)); Real64 const pow_4_Tkel(pow_4(Tkel)); - for (int thisConstit = 1; thisConstit <= DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).NumConstituents; ++thisConstit) { - int gasID = DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).GasLibID(thisConstit); + for (int thisConstit = 1; thisConstit <= DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).NumConstituents; ++thisConstit) { + int gasID = DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).GasLibID(thisConstit); if (gasID > 0) { if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == DataGenerators::NISTShomate) { A = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateA; @@ -2379,7 +2381,7 @@ namespace FuelCellElectricGenerator { Real64 HfuelI = (A * Tsho + B * pow_2_Tsho / 2.0 + C * pow_3_Tsho / 3.0 + D * pow_4_Tsho / 4.0 - E / Tsho + F - H); - tempHfuel += HfuelI * DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).ConstitMolalFract(thisConstit); + tempHfuel += HfuelI * DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).ConstitMolalFract(thisConstit); } if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == DataGenerators::NASAPolynomial) { @@ -2393,7 +2395,7 @@ namespace FuelCellElectricGenerator { tempHfuel += (((A1 + A2 * Tkel / 2.0 + A3 * pow_2_Tkel / 3.0 + A4 * pow_3_Tkel / 4.0 + A5 * pow_4_Tkel / 5.0 + A6 / Tkel) * DataGenerators::RinKJperMolpK * Tkel) - DataGenerators::GasPhaseThermoChemistryData(gasID).StdRefMolarEnthOfForm) * - DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).ConstitMolalFract(thisConstit); + DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).ConstitMolalFract(thisConstit); } } } @@ -2452,7 +2454,7 @@ namespace FuelCellElectricGenerator { Real64 const pow_4_Tkel(pow_4(Tkel)); for (int thisConstit = 1; thisConstit <= 5; ++thisConstit) { - int gasID = DataGenerators::FuelCell(GeneratorNum).FCPM.GasLibID(thisConstit); + int gasID = FuelCell(GeneratorNum).FCPM.GasLibID(thisConstit); if (gasID > 0) { if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == DataGenerators::NISTShomate) { A = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateA; @@ -2464,7 +2466,7 @@ namespace FuelCellElectricGenerator { H = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateH; tempHprodGases += ((A * Tsho + B * pow_2_Tsho / 2.0 + C * pow_3_Tsho / 3.0 + D * pow_4_Tsho / 4.0 - E / Tsho + F - H) * - DataGenerators::FuelCell(GeneratorNum).FCPM.ConstitMolalFract(thisConstit)); + FuelCell(GeneratorNum).FCPM.ConstitMolalFract(thisConstit)); } if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == DataGenerators::NASAPolynomial) { A1 = DataGenerators::GasPhaseThermoChemistryData(gasID).NASA_A1; @@ -2477,7 +2479,7 @@ namespace FuelCellElectricGenerator { tempHprodGases += (((A1 + A2 * Tkel / 2.0 + A3 * pow_2_Tkel / 3.0 + A4 * pow_3_Tkel / 4.0 + A5 * pow_4_Tkel / 5.0 + A6 / Tkel) * DataGenerators::RinKJperMolpK * Tkel) - DataGenerators::GasPhaseThermoChemistryData(gasID).StdRefMolarEnthOfForm) * - DataGenerators::FuelCell(GeneratorNum).FCPM.ConstitMolalFract(thisConstit); + FuelCell(GeneratorNum).FCPM.ConstitMolalFract(thisConstit); } } // gasid > 0 } @@ -2522,8 +2524,8 @@ namespace FuelCellElectricGenerator { Real64 const pow_3_Tkel(pow_3(Tkel)); Real64 const pow_4_Tkel(pow_4(Tkel)); - for (int thisConstit = 1; thisConstit <= isize(DataGenerators::FuelCell(GeneratorNum).FCPM.GasLibID); ++thisConstit) { - int gasID = DataGenerators::FuelCell(GeneratorNum).FCPM.GasLibID(thisConstit); + for (int thisConstit = 1; thisConstit <= isize(FuelCell(GeneratorNum).FCPM.GasLibID); ++thisConstit) { + int gasID = FuelCell(GeneratorNum).FCPM.GasLibID(thisConstit); if (gasID > 0) { if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == DataGenerators::NISTShomate) { @@ -2534,7 +2536,7 @@ namespace FuelCellElectricGenerator { E = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateE; tempCp += ((A + B * Tsho + C * pow_2_Tsho + D * pow_3_Tsho + E / pow_2_Tsho) * - DataGenerators::FuelCell(GeneratorNum).FCPM.ConstitMolalFract(thisConstit)); + FuelCell(GeneratorNum).FCPM.ConstitMolalFract(thisConstit)); } if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == DataGenerators::NASAPolynomial) { @@ -2545,7 +2547,7 @@ namespace FuelCellElectricGenerator { A5 = DataGenerators::GasPhaseThermoChemistryData(gasID).NASA_A5; tempCp += (A1 + A2 * Tkel + A3 * pow_2_Tkel + A4 * pow_3_Tkel + A5 * pow_4_Tkel) * DataGenerators::RinKJperMolpK * - DataGenerators::FuelCell(GeneratorNum).FCPM.ConstitMolalFract(thisConstit); + FuelCell(GeneratorNum).FCPM.ConstitMolalFract(thisConstit); } } } @@ -2590,8 +2592,8 @@ namespace FuelCellElectricGenerator { Real64 const pow_3_Tkel(pow_3(Tkel)); Real64 const pow_4_Tkel(pow_4(Tkel)); - for (int thisConstit = 1; thisConstit <= isize(DataGenerators::FuelCell(GeneratorNum).AuxilHeat.GasLibID); ++thisConstit) { - int gasID = DataGenerators::FuelCell(GeneratorNum).AuxilHeat.GasLibID(thisConstit); + for (int thisConstit = 1; thisConstit <= isize(FuelCell(GeneratorNum).AuxilHeat.GasLibID); ++thisConstit) { + int gasID = FuelCell(GeneratorNum).AuxilHeat.GasLibID(thisConstit); if (gasID > 0) { if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == DataGenerators::NISTShomate) { @@ -2602,7 +2604,7 @@ namespace FuelCellElectricGenerator { E = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateE; tempCp += ((A + B * Tsho + C * pow_2_Tsho + D * pow_3_Tsho + E / pow_2_Tsho) * - DataGenerators::FuelCell(GeneratorNum).AuxilHeat.ConstitMolalFract(thisConstit)); + FuelCell(GeneratorNum).AuxilHeat.ConstitMolalFract(thisConstit)); } if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == DataGenerators::NASAPolynomial) { @@ -2613,7 +2615,7 @@ namespace FuelCellElectricGenerator { A5 = DataGenerators::GasPhaseThermoChemistryData(gasID).NASA_A5; tempCp += (A1 + A2 * Tkel + A3 * pow_2_Tkel + A4 * pow_3_Tkel + A5 * pow_4_Tkel) * DataGenerators::RinKJperMolpK * - DataGenerators::FuelCell(GeneratorNum).AuxilHeat.ConstitMolalFract(thisConstit); + FuelCell(GeneratorNum).AuxilHeat.ConstitMolalFract(thisConstit); } } } @@ -2719,21 +2721,21 @@ namespace FuelCellElectricGenerator { // Using lagged values inside a sequential substitution loop PacAncill = 0.0; // sect. 5.9 - DataGenerators::FuelCell(GeneratorNum).FCPM.PelancillariesAC = - DataGenerators::FuelCell(GeneratorNum).FCPM.ANC0 + DataGenerators::FuelCell(GeneratorNum).FCPM.ANC1 * DataGenerators::FuelCell(GeneratorNum).FCPM.NdotFuel; + FuelCell(GeneratorNum).FCPM.PelancillariesAC = + FuelCell(GeneratorNum).FCPM.ANC0 + FuelCell(GeneratorNum).FCPM.ANC1 * FuelCell(GeneratorNum).FCPM.NdotFuel; // sect 6.0 - DataGenerators::FuelCell(GeneratorNum).AirSup.PairCompEl = CurveManager::CurveValue(DataGenerators::FuelCell(GeneratorNum).AirSup.BlowerPowerCurveID, DataGenerators::FuelCell(GeneratorNum).FCPM.NdotAir); + FuelCell(GeneratorNum).AirSup.PairCompEl = CurveManager::CurveValue(FuelCell(GeneratorNum).AirSup.BlowerPowerCurveID, FuelCell(GeneratorNum).FCPM.NdotAir); // sect 7.0 - DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).PfuelCompEl = - CurveManager::CurveValue(DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).CompPowerCurveID, DataGenerators::FuelCell(GeneratorNum).FCPM.NdotFuel); + DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).PfuelCompEl = + CurveManager::CurveValue(DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).CompPowerCurveID, FuelCell(GeneratorNum).FCPM.NdotFuel); // sect. 8.0 - DataGenerators::FuelCell(GeneratorNum).WaterSup.PwaterCompEl = - CurveManager::CurveValue(DataGenerators::FuelCell(GeneratorNum).WaterSup.PmpPowerCurveID, DataGenerators::FuelCell(GeneratorNum).FCPM.NdotLiqwater); + FuelCell(GeneratorNum).WaterSup.PwaterCompEl = + CurveManager::CurveValue(FuelCell(GeneratorNum).WaterSup.PmpPowerCurveID, FuelCell(GeneratorNum).FCPM.NdotLiqwater); - PacAncill = DataGenerators::FuelCell(GeneratorNum).FCPM.PelancillariesAC + DataGenerators::FuelCell(GeneratorNum).AirSup.PairCompEl + - DataGenerators::FuelSupply(DataGenerators::FuelCell(GeneratorNum).FuelSupNum).PfuelCompEl + DataGenerators::FuelCell(GeneratorNum).WaterSup.PwaterCompEl; + PacAncill = FuelCell(GeneratorNum).FCPM.PelancillariesAC + FuelCell(GeneratorNum).AirSup.PairCompEl + + DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).PfuelCompEl + FuelCell(GeneratorNum).WaterSup.PwaterCompEl; } void FigurePowerConditioningLosses(int const GeneratorNum, Real64 const Pdemand, Real64 &PpcuLosses) @@ -2748,21 +2750,21 @@ namespace FuelCellElectricGenerator { // PURPOSE OF THIS SUBROUTINE: // Calculate inverter losses - if (DataGenerators::FuelCell(GeneratorNum).Inverter.EffMode == DataGenerators::InverterEffConstant) { - PpcuLosses = Pdemand * (1 - DataGenerators::FuelCell(GeneratorNum).Inverter.ConstEff) / DataGenerators::FuelCell(GeneratorNum).Inverter.ConstEff; + if (FuelCell(GeneratorNum).Inverter.EffMode == DataGenerators::InverterEffConstant) { + PpcuLosses = Pdemand * (1 - FuelCell(GeneratorNum).Inverter.ConstEff) / FuelCell(GeneratorNum).Inverter.ConstEff; } - if (DataGenerators::FuelCell(GeneratorNum).Inverter.EffMode == DataGenerators::InverterEffQuadratic) { + if (FuelCell(GeneratorNum).Inverter.EffMode == DataGenerators::InverterEffQuadratic) { // first use Pdemand instead of Pel to get initial estimate - Real64 lastPpcuLosses = Pdemand * (1.0 - CurveManager::CurveValue(DataGenerators::FuelCell(GeneratorNum).Inverter.EffQuadraticCurveID, Pdemand)) / - CurveManager::CurveValue(DataGenerators::FuelCell(GeneratorNum).Inverter.EffQuadraticCurveID, Pdemand); + Real64 lastPpcuLosses = Pdemand * (1.0 - CurveManager::CurveValue(FuelCell(GeneratorNum).Inverter.EffQuadraticCurveID, Pdemand)) / + CurveManager::CurveValue(FuelCell(GeneratorNum).Inverter.EffQuadraticCurveID, Pdemand); for (int iter = 1; iter <= 20; ++iter) { // seems like need to iterate (??) Need to investigate number and convergence success here Real64 Pel = Pdemand + lastPpcuLosses; - lastPpcuLosses = (1.0 - CurveManager::CurveValue(DataGenerators::FuelCell(GeneratorNum).Inverter.EffQuadraticCurveID, Pel)) * Pel; + lastPpcuLosses = (1.0 - CurveManager::CurveValue(FuelCell(GeneratorNum).Inverter.EffQuadraticCurveID, Pel)) * Pel; } PpcuLosses = lastPpcuLosses; @@ -2787,44 +2789,44 @@ namespace FuelCellElectricGenerator { Real64 CurrentFractionalDay = double(DataGlobals::DayOfSim) + (int(DataGlobals::CurrentTime) + (DataHVACGlobals::SysTimeElapsed + (DataGlobals::CurrentTime - int(DataGlobals::CurrentTime)))) / DataGlobals::HoursInDay; // Check if in start up and if it still should be - if (DataGenerators::FuelCell(GeneratorNum).FCPM.DuringStartUp) { + if (FuelCell(GeneratorNum).FCPM.DuringStartUp) { // calculate time for end of start up period - Real64 EndingFractionalDay = DataGenerators::FuelCell(GeneratorNum).FCPM.FractionalDayofLastStartUp + DataGenerators::FuelCell(GeneratorNum).FCPM.StartUpTime / DataGlobals::HoursInDay; + Real64 EndingFractionalDay = FuelCell(GeneratorNum).FCPM.FractionalDayofLastStartUp + FuelCell(GeneratorNum).FCPM.StartUpTime / DataGlobals::HoursInDay; if (CurrentFractionalDay > EndingFractionalDay) { // start up period is now over - DataGenerators::FuelCell(GeneratorNum).FCPM.DuringStartUp = false; + FuelCell(GeneratorNum).FCPM.DuringStartUp = false; } } // Check if in shut down up and if it still should be - if (DataGenerators::FuelCell(GeneratorNum).FCPM.DuringShutDown) { + if (FuelCell(GeneratorNum).FCPM.DuringShutDown) { // calculate time for end of shut down period - Real64 EndingFractionalDay = DataGenerators::FuelCell(GeneratorNum).FCPM.FractionalDayofLastShutDown + DataGenerators::FuelCell(GeneratorNum).FCPM.ShutDownTime / DataGlobals::HoursInDay; + Real64 EndingFractionalDay = FuelCell(GeneratorNum).FCPM.FractionalDayofLastShutDown + FuelCell(GeneratorNum).FCPM.ShutDownTime / DataGlobals::HoursInDay; if (CurrentFractionalDay > EndingFractionalDay) { // start up period is now over - DataGenerators::FuelCell(GeneratorNum).FCPM.DuringShutDown = false; + FuelCell(GeneratorNum).FCPM.DuringShutDown = false; } } // compare - if (!(DataGenerators::FuelCell(GeneratorNum).FCPM.DuringShutDown) && !(DataGenerators::FuelCell(GeneratorNum).FCPM.DuringStartUp)) { + if (!(FuelCell(GeneratorNum).FCPM.DuringShutDown) && !(FuelCell(GeneratorNum).FCPM.DuringStartUp)) { // unit is neither starting or stopping and the only constraints would come from transient limits - if (Pel > DataGenerators::FuelCell(GeneratorNum).FCPM.PelLastTimeStep) { // powering up + if (Pel > FuelCell(GeneratorNum).FCPM.PelLastTimeStep) { // powering up // working variable for max allowed by transient constraint - Real64 MaxPel = DataGenerators::FuelCell(GeneratorNum).FCPM.PelLastTimeStep + DataGenerators::FuelCell(GeneratorNum).FCPM.UpTranLimit * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + Real64 MaxPel = FuelCell(GeneratorNum).FCPM.PelLastTimeStep + FuelCell(GeneratorNum).FCPM.UpTranLimit * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; if (MaxPel < Pel) { Pel = MaxPel; Constrained = true; } else { Constrained = false; } - } else if (Pel < DataGenerators::FuelCell(GeneratorNum).FCPM.PelLastTimeStep) { // powering down + } else if (Pel < FuelCell(GeneratorNum).FCPM.PelLastTimeStep) { // powering down // working variable for min allowed by transient constraint - Real64 MinPel = DataGenerators::FuelCell(GeneratorNum).FCPM.PelLastTimeStep - DataGenerators::FuelCell(GeneratorNum).FCPM.DownTranLimit * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + Real64 MinPel = FuelCell(GeneratorNum).FCPM.PelLastTimeStep - FuelCell(GeneratorNum).FCPM.DownTranLimit * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; if (Pel < MinPel) { Pel = MinPel; Constrained = true; @@ -2838,13 +2840,13 @@ namespace FuelCellElectricGenerator { } // not in start up or shut down - if (DataGenerators::FuelCell(GeneratorNum).FCPM.DuringStartUp) { + if (FuelCell(GeneratorNum).FCPM.DuringStartUp) { // constant during start up modeling artifact - Pel = DataGenerators::FuelCell(GeneratorNum).FCPM.StartUpElectProd / DataGenerators::FuelCell(GeneratorNum).FCPM.StartUpTime; + Pel = FuelCell(GeneratorNum).FCPM.StartUpElectProd / FuelCell(GeneratorNum).FCPM.StartUpTime; Constrained = true; } - if (DataGenerators::FuelCell(GeneratorNum).FCPM.DuringShutDown) { + if (FuelCell(GeneratorNum).FCPM.DuringShutDown) { Pel = 0.0; // assumes no power generated during shut down Constrained = true; @@ -2861,10 +2863,10 @@ namespace FuelCellElectricGenerator { // not yet implemented, just pass product gases thru nul domain - DataGenerators::FuelCell(Num).AuxilHeat.TauxMix = DataGenerators::FuelCell(Num).FCPM.TprodGasLeavingFCPM; - DataGenerators::FuelCell(Num).AuxilHeat.NdotAuxMix = DataGenerators::FuelCell(Num).FCPM.NdotProdGas; - DataGenerators::FuelCell(Num).AuxilHeat.ConstitMolalFract = DataGenerators::FuelCell(Num).FCPM.ConstitMolalFract; - DataGenerators::FuelCell(Num).AuxilHeat.GasLibID = DataGenerators::FuelCell(Num).FCPM.GasLibID; + FuelCell(Num).AuxilHeat.TauxMix = FuelCell(Num).FCPM.TprodGasLeavingFCPM; + FuelCell(Num).AuxilHeat.NdotAuxMix = FuelCell(Num).FCPM.NdotProdGas; + FuelCell(Num).AuxilHeat.ConstitMolalFract = FuelCell(Num).FCPM.ConstitMolalFract; + FuelCell(Num).AuxilHeat.GasLibID = FuelCell(Num).FCPM.GasLibID; } void CalcFuelCellGenHeatRecovery(int const Num) // Generator number @@ -2884,49 +2886,49 @@ namespace FuelCellElectricGenerator { static std::string const RoutineName("CalcFuelCellGenHeatRecovery"); { - auto const SELECT_CASE_var(DataGenerators::FuelCell(Num).ExhaustHX.HXmodelMode); + auto const SELECT_CASE_var(FuelCell(Num).ExhaustHX.HXmodelMode); if (SELECT_CASE_var == DataGenerators::FixedEffectiveness) { // Method 1 - Real64 eHX = DataGenerators::FuelCell(Num).ExhaustHX.HXEffect; + Real64 eHX = FuelCell(Num).ExhaustHX.HXEffect; Real64 MWwater = DataGenerators::GasPhaseThermoChemistryData(4).MolecularWeight; - Real64 NdotWater = DataGenerators::FuelCell(Num).ExhaustHX.WaterMassFlowRate / MWwater; - Real64 TwaterIn = DataGenerators::FuelCell(Num).ExhaustHX.WaterInletTemp; + Real64 NdotWater = FuelCell(Num).ExhaustHX.WaterMassFlowRate / MWwater; + Real64 TwaterIn = FuelCell(Num).ExhaustHX.WaterInletTemp; Real64 CpWaterMol; FigureLiquidWaterHeatCap(TwaterIn, CpWaterMol); - Real64 NdotGas = DataGenerators::FuelCell(Num).AuxilHeat.NdotAuxMix; - Real64 TprodGasIn = DataGenerators::FuelCell(Num).AuxilHeat.TauxMix; + Real64 NdotGas = FuelCell(Num).AuxilHeat.NdotAuxMix; + Real64 TprodGasIn = FuelCell(Num).AuxilHeat.TauxMix; Real64 CpProdGasMol; FigureAuxilHeatGasHeatCap(Num, TprodGasIn, CpProdGasMol); // Cp in (J/mol*K) // factor of 1000.0 for kmol -> mol Real64 NdotCp = min(NdotGas * CpProdGasMol * 1000.0, NdotWater * CpWaterMol * 1000.0); - DataGenerators::FuelCell(Num).ExhaustHX.qHX = eHX * NdotCp * (TprodGasIn - TwaterIn); + FuelCell(Num).ExhaustHX.qHX = eHX * NdotCp * (TprodGasIn - TwaterIn); - DataGenerators::FuelCell(Num).ExhaustHX.THXexh = TprodGasIn - DataGenerators::FuelCell(Num).ExhaustHX.qHX / (NdotGas * CpProdGasMol * 1000.0); + FuelCell(Num).ExhaustHX.THXexh = TprodGasIn - FuelCell(Num).ExhaustHX.qHX / (NdotGas * CpProdGasMol * 1000.0); Real64 Cp = FluidProperties::GetSpecificHeatGlycol( - DataPlant::PlantLoop(DataGenerators::FuelCell(Num).CWLoopNum).FluidName, TwaterIn, DataPlant::PlantLoop(DataGenerators::FuelCell(Num).CWLoopNum).FluidIndex, RoutineName); + DataPlant::PlantLoop(FuelCell(Num).CWLoopNum).FluidName, TwaterIn, DataPlant::PlantLoop(FuelCell(Num).CWLoopNum).FluidIndex, RoutineName); - if (DataGenerators::FuelCell(Num).ExhaustHX.WaterMassFlowRate * Cp <= 0.0) { - DataGenerators::FuelCell(Num).ExhaustHX.WaterOutletTemp = TwaterIn; + if (FuelCell(Num).ExhaustHX.WaterMassFlowRate * Cp <= 0.0) { + FuelCell(Num).ExhaustHX.WaterOutletTemp = TwaterIn; } else { - DataGenerators::FuelCell(Num).ExhaustHX.WaterOutletTemp = TwaterIn + DataGenerators::FuelCell(Num).ExhaustHX.qHX / (DataGenerators::FuelCell(Num).ExhaustHX.WaterMassFlowRate * Cp); + FuelCell(Num).ExhaustHX.WaterOutletTemp = TwaterIn + FuelCell(Num).ExhaustHX.qHX / (FuelCell(Num).ExhaustHX.WaterMassFlowRate * Cp); } } else if (SELECT_CASE_var == DataGenerators::LMTDempiricalUAeff) { // method 2 Real64 MWwater = DataGenerators::GasPhaseThermoChemistryData(4).MolecularWeight; - Real64 NdotWater = DataGenerators::FuelCell(Num).ExhaustHX.WaterMassFlowRate / MWwater; - Real64 NdotGas = DataGenerators::FuelCell(Num).AuxilHeat.NdotAuxMix; + Real64 NdotWater = FuelCell(Num).ExhaustHX.WaterMassFlowRate / MWwater; + Real64 NdotGas = FuelCell(Num).AuxilHeat.NdotAuxMix; - Real64 UAeff = DataGenerators::FuelCell(Num).ExhaustHX.hxs0 + DataGenerators::FuelCell(Num).ExhaustHX.hxs1 * NdotWater + DataGenerators::FuelCell(Num).ExhaustHX.hxs2 * pow_2(NdotWater) + - DataGenerators::FuelCell(Num).ExhaustHX.hxs3 * NdotGas + DataGenerators::FuelCell(Num).ExhaustHX.hxs4 * pow_2(NdotGas); + Real64 UAeff = FuelCell(Num).ExhaustHX.hxs0 + FuelCell(Num).ExhaustHX.hxs1 * NdotWater + FuelCell(Num).ExhaustHX.hxs2 * pow_2(NdotWater) + + FuelCell(Num).ExhaustHX.hxs3 * NdotGas + FuelCell(Num).ExhaustHX.hxs4 * pow_2(NdotGas); - Real64 TauxMix = DataGenerators::FuelCell(Num).AuxilHeat.TauxMix; - Real64 TwaterIn = DataGenerators::FuelCell(Num).ExhaustHX.WaterInletTemp; + Real64 TauxMix = FuelCell(Num).AuxilHeat.TauxMix; + Real64 TwaterIn = FuelCell(Num).ExhaustHX.WaterInletTemp; Real64 CpWaterMol; FigureLiquidWaterHeatCap(TwaterIn, CpWaterMol); // factor of 1000.0 for kmol -> mol @@ -2937,42 +2939,42 @@ namespace FuelCellElectricGenerator { if ((NdotCpWater != 0.0) && (NdotCpAuxMix != 0.0)) { // trap divide by zero // now evaluate Eq. 44 - DataGenerators::FuelCell(Num).ExhaustHX.THXexh = ((1.0 - NdotCpAuxMix / NdotCpWater) / + FuelCell(Num).ExhaustHX.THXexh = ((1.0 - NdotCpAuxMix / NdotCpWater) / (std::exp(UAeff * (1.0 / NdotCpAuxMix - 1.0 / NdotCpWater)) - NdotCpAuxMix / NdotCpWater)) * TauxMix + ((std::exp(UAeff * (1.0 / NdotCpAuxMix - 1.0 / NdotCpWater)) - 1.0) / (std::exp(UAeff * (1.0 / NdotCpAuxMix - 1.0 / NdotCpWater)) - NdotCpAuxMix / NdotCpWater)) * TwaterIn; - DataGenerators::FuelCell(Num).ExhaustHX.WaterOutletTemp = TwaterIn + (NdotCpAuxMix / NdotCpWater) * (TauxMix - DataGenerators::FuelCell(Num).ExhaustHX.THXexh); // Eq. 42 + FuelCell(Num).ExhaustHX.WaterOutletTemp = TwaterIn + (NdotCpAuxMix / NdotCpWater) * (TauxMix - FuelCell(Num).ExhaustHX.THXexh); // Eq. 42 } else { - DataGenerators::FuelCell(Num).ExhaustHX.THXexh = TauxMix; - DataGenerators::FuelCell(Num).ExhaustHX.WaterOutletTemp = TwaterIn; + FuelCell(Num).ExhaustHX.THXexh = TauxMix; + FuelCell(Num).ExhaustHX.WaterOutletTemp = TwaterIn; } // ENDIF - if ((DataGenerators::FuelCell(Num).ExhaustHX.THXexh - TwaterIn) != 0.0) { // trap divide by zero - DataGenerators::FuelCell(Num).ExhaustHX.qHX = UAeff * ((TauxMix - DataGenerators::FuelCell(Num).ExhaustHX.WaterOutletTemp) - (DataGenerators::FuelCell(Num).ExhaustHX.THXexh - TwaterIn)) / std::log((TauxMix - DataGenerators::FuelCell(Num).ExhaustHX.WaterOutletTemp) / (DataGenerators::FuelCell(Num).ExhaustHX.THXexh - TwaterIn)); + if ((FuelCell(Num).ExhaustHX.THXexh - TwaterIn) != 0.0) { // trap divide by zero + FuelCell(Num).ExhaustHX.qHX = UAeff * ((TauxMix - FuelCell(Num).ExhaustHX.WaterOutletTemp) - (FuelCell(Num).ExhaustHX.THXexh - TwaterIn)) / std::log((TauxMix - FuelCell(Num).ExhaustHX.WaterOutletTemp) / (FuelCell(Num).ExhaustHX.THXexh - TwaterIn)); } else { - DataGenerators::FuelCell(Num).ExhaustHX.qHX = 0.0; + FuelCell(Num).ExhaustHX.qHX = 0.0; } } else if (SELECT_CASE_var == DataGenerators::LMTDfundementalUAeff) { // method 3 - Real64 NdotGas = DataGenerators::FuelCell(Num).AuxilHeat.NdotAuxMix; + Real64 NdotGas = FuelCell(Num).AuxilHeat.NdotAuxMix; Real64 MWwater = DataGenerators::GasPhaseThermoChemistryData(4).MolecularWeight; - Real64 NdotWater = DataGenerators::FuelCell(Num).ExhaustHX.WaterMassFlowRate / MWwater; + Real64 NdotWater = FuelCell(Num).ExhaustHX.WaterMassFlowRate / MWwater; - Real64 hgas = DataGenerators::FuelCell(Num).ExhaustHX.h0gas * std::pow(NdotGas / DataGenerators::FuelCell(Num).ExhaustHX.NdotGasRef, DataGenerators::FuelCell(Num).ExhaustHX.nCoeff); // Eq. 48 - Real64 hwater = DataGenerators::FuelCell(Num).ExhaustHX.h0Water * - std::pow(NdotWater / DataGenerators::FuelCell(Num).ExhaustHX.NdotWaterRef, DataGenerators::FuelCell(Num).ExhaustHX.mCoeff); // Eq. 48 + Real64 hgas = FuelCell(Num).ExhaustHX.h0gas * std::pow(NdotGas / FuelCell(Num).ExhaustHX.NdotGasRef, FuelCell(Num).ExhaustHX.nCoeff); // Eq. 48 + Real64 hwater = FuelCell(Num).ExhaustHX.h0Water * + std::pow(NdotWater / FuelCell(Num).ExhaustHX.NdotWaterRef, FuelCell(Num).ExhaustHX.mCoeff); // Eq. 48 // now equation 47 - Real64 UAeff = 1.0 / (1.0 / (hgas * DataGenerators::FuelCell(Num).ExhaustHX.AreaGas) + 1.0 / (hwater * DataGenerators::FuelCell(Num).ExhaustHX.AreaWater) + - DataGenerators::FuelCell(Num).ExhaustHX.Fadjust); + Real64 UAeff = 1.0 / (1.0 / (hgas * FuelCell(Num).ExhaustHX.AreaGas) + 1.0 / (hwater * FuelCell(Num).ExhaustHX.AreaWater) + + FuelCell(Num).ExhaustHX.Fadjust); - Real64 TauxMix = DataGenerators::FuelCell(Num).AuxilHeat.TauxMix; - Real64 TwaterIn = DataGenerators::FuelCell(Num).ExhaustHX.WaterInletTemp; + Real64 TauxMix = FuelCell(Num).AuxilHeat.TauxMix; + Real64 TwaterIn = FuelCell(Num).ExhaustHX.WaterInletTemp; Real64 CpWaterMol; FigureLiquidWaterHeatCap(TwaterIn, CpWaterMol); Real64 NdotCpWater = NdotWater * CpWaterMol * 1000.0; @@ -2982,39 +2984,39 @@ namespace FuelCellElectricGenerator { if ((NdotCpWater != 0.0) && (NdotCpAuxMix != 0.0)) { // trap divide by zero // now evaluate Eq. 44 - DataGenerators::FuelCell(Num).ExhaustHX.THXexh = ((1.0 - NdotCpAuxMix / NdotCpWater) / + FuelCell(Num).ExhaustHX.THXexh = ((1.0 - NdotCpAuxMix / NdotCpWater) / (std::exp(UAeff * (1.0 / NdotCpAuxMix - 1.0 / NdotCpWater)) - NdotCpAuxMix / NdotCpWater)) * TauxMix + ((std::exp(UAeff * (1.0 / NdotCpAuxMix - 1.0 / NdotCpWater)) - 1.0) / (std::exp(UAeff * (1.0 / NdotCpAuxMix - 1.0 / NdotCpWater)) - NdotCpAuxMix / NdotCpWater)) * TwaterIn; - DataGenerators::FuelCell(Num).ExhaustHX.WaterOutletTemp = TwaterIn + (NdotCpAuxMix / NdotCpWater) * (TauxMix - DataGenerators::FuelCell(Num).ExhaustHX.THXexh); // Eq. 42 + FuelCell(Num).ExhaustHX.WaterOutletTemp = TwaterIn + (NdotCpAuxMix / NdotCpWater) * (TauxMix - FuelCell(Num).ExhaustHX.THXexh); // Eq. 42 } else { - DataGenerators::FuelCell(Num).ExhaustHX.THXexh = TauxMix; - DataGenerators::FuelCell(Num).ExhaustHX.WaterOutletTemp = TwaterIn; + FuelCell(Num).ExhaustHX.THXexh = TauxMix; + FuelCell(Num).ExhaustHX.WaterOutletTemp = TwaterIn; } - if ((DataGenerators::FuelCell(Num).ExhaustHX.THXexh - TwaterIn) != 0.0) { // trap divide by zero - DataGenerators::FuelCell(Num).ExhaustHX.qHX = UAeff * ((TauxMix - DataGenerators::FuelCell(Num).ExhaustHX.WaterOutletTemp) - (DataGenerators::FuelCell(Num).ExhaustHX.THXexh - TwaterIn)) / std::log((TauxMix - DataGenerators::FuelCell(Num).ExhaustHX.WaterOutletTemp) / (DataGenerators::FuelCell(Num).ExhaustHX.THXexh - TwaterIn)); + if ((FuelCell(Num).ExhaustHX.THXexh - TwaterIn) != 0.0) { // trap divide by zero + FuelCell(Num).ExhaustHX.qHX = UAeff * ((TauxMix - FuelCell(Num).ExhaustHX.WaterOutletTemp) - (FuelCell(Num).ExhaustHX.THXexh - TwaterIn)) / std::log((TauxMix - FuelCell(Num).ExhaustHX.WaterOutletTemp) / (FuelCell(Num).ExhaustHX.THXexh - TwaterIn)); } else { - DataGenerators::FuelCell(Num).ExhaustHX.qHX = 0.0; + FuelCell(Num).ExhaustHX.qHX = 0.0; } } else if (SELECT_CASE_var == DataGenerators::Condensing) { // method 4 - if (DataGenerators::FuelCell(Num).ExhaustHX.WaterMassFlowRate != 0.0) { + if (FuelCell(Num).ExhaustHX.WaterMassFlowRate != 0.0) { Real64 MWwater = DataGenerators::GasPhaseThermoChemistryData(4).MolecularWeight; - Real64 NdotWater = DataGenerators::FuelCell(Num).ExhaustHX.WaterMassFlowRate / MWwater; - Real64 NdotGas = DataGenerators::FuelCell(Num).AuxilHeat.NdotAuxMix; + Real64 NdotWater = FuelCell(Num).ExhaustHX.WaterMassFlowRate / MWwater; + Real64 NdotGas = FuelCell(Num).AuxilHeat.NdotAuxMix; - Real64 UAeff = DataGenerators::FuelCell(Num).ExhaustHX.hxs0 + DataGenerators::FuelCell(Num).ExhaustHX.hxs1 * NdotWater + - DataGenerators::FuelCell(Num).ExhaustHX.hxs2 * pow_2(NdotWater) + DataGenerators::FuelCell(Num).ExhaustHX.hxs3 * NdotGas + - DataGenerators::FuelCell(Num).ExhaustHX.hxs4 * pow_2(NdotGas); + Real64 UAeff = FuelCell(Num).ExhaustHX.hxs0 + FuelCell(Num).ExhaustHX.hxs1 * NdotWater + + FuelCell(Num).ExhaustHX.hxs2 * pow_2(NdotWater) + FuelCell(Num).ExhaustHX.hxs3 * NdotGas + + FuelCell(Num).ExhaustHX.hxs4 * pow_2(NdotGas); - Real64 TauxMix = DataGenerators::FuelCell(Num).AuxilHeat.TauxMix; - Real64 TwaterIn = DataGenerators::FuelCell(Num).ExhaustHX.WaterInletTemp; + Real64 TauxMix = FuelCell(Num).AuxilHeat.TauxMix; + Real64 TwaterIn = FuelCell(Num).ExhaustHX.WaterInletTemp; Real64 CpWaterMol; FigureLiquidWaterHeatCap(TwaterIn, CpWaterMol); Real64 NdotCpWater = NdotWater * CpWaterMol * 1000.0; @@ -3023,50 +3025,50 @@ namespace FuelCellElectricGenerator { Real64 NdotCpAuxMix = NdotGas * CpProdGasMol * 1000.0; // find water fraction in incoming gas stream - for (int i = 1; i <= isize(DataGenerators::FuelCell(Num).AuxilHeat.GasLibID); ++i) { - if (DataGenerators::FuelCell(Num).AuxilHeat.GasLibID(i) == 4) DataGenerators::FuelCell(Num).ExhaustHX.WaterVaporFractExh = DataGenerators::FuelCell(Num).AuxilHeat.ConstitMolalFract(i); + for (int i = 1; i <= isize(FuelCell(Num).AuxilHeat.GasLibID); ++i) { + if (FuelCell(Num).AuxilHeat.GasLibID(i) == 4) FuelCell(Num).ExhaustHX.WaterVaporFractExh = FuelCell(Num).AuxilHeat.ConstitMolalFract(i); } - Real64 NdotWaterVapor = DataGenerators::FuelCell(Num).ExhaustHX.WaterVaporFractExh * NdotGas; + Real64 NdotWaterVapor = FuelCell(Num).ExhaustHX.WaterVaporFractExh * NdotGas; - Real64 TcondThresh = DataGenerators::FuelCell(Num).ExhaustHX.CondensationThresholdTemp; - Real64 hxl1 = DataGenerators::FuelCell(Num).ExhaustHX.l1Coeff; - Real64 hxl2 = DataGenerators::FuelCell(Num).ExhaustHX.l2Coeff; + Real64 TcondThresh = FuelCell(Num).ExhaustHX.CondensationThresholdTemp; + Real64 hxl1 = FuelCell(Num).ExhaustHX.l1Coeff; + Real64 hxl2 = FuelCell(Num).ExhaustHX.l2Coeff; - DataGenerators::FuelCell(Num).ExhaustHX.CondensateRate = (TcondThresh - TwaterIn) * (hxl1 * (NdotWaterVapor / NdotGas) + hxl2 * pow_2(NdotWaterVapor / NdotGas)); + FuelCell(Num).ExhaustHX.CondensateRate = (TcondThresh - TwaterIn) * (hxl1 * (NdotWaterVapor / NdotGas) + hxl2 * pow_2(NdotWaterVapor / NdotGas)); - if (DataGenerators::FuelCell(Num).ExhaustHX.CondensateRate < 0.0) DataGenerators::FuelCell(Num).ExhaustHX.CondensateRate = 0.0; + if (FuelCell(Num).ExhaustHX.CondensateRate < 0.0) FuelCell(Num).ExhaustHX.CondensateRate = 0.0; Real64 hfpwater = 4.4004e+07; // molal heat of vaporization of water J/kmol) if ((NdotCpWater != 0.0) && (NdotCpAuxMix != 0.0)) { // trap divide by zero // now evaluate Eq. 44 - DataGenerators::FuelCell(Num).ExhaustHX.THXexh = ((1.0 - NdotCpAuxMix / NdotCpWater) / + FuelCell(Num).ExhaustHX.THXexh = ((1.0 - NdotCpAuxMix / NdotCpWater) / (std::exp(UAeff * (1.0 / NdotCpAuxMix - 1.0 / NdotCpWater)) - NdotCpAuxMix / NdotCpWater)) * TauxMix + ((std::exp(UAeff * (1.0 / NdotCpAuxMix - 1.0 / NdotCpWater)) - 1.0) / (std::exp(UAeff * (1.0 / NdotCpAuxMix - 1.0 / NdotCpWater)) - NdotCpAuxMix / NdotCpWater)) * TwaterIn; - DataGenerators::FuelCell(Num).ExhaustHX.WaterOutletTemp = TwaterIn + (NdotCpAuxMix / NdotCpWater) * (TauxMix - DataGenerators::FuelCell(Num).ExhaustHX.THXexh) + (DataGenerators::FuelCell(Num).ExhaustHX.CondensateRate * hfpwater) / NdotCpWater; + FuelCell(Num).ExhaustHX.WaterOutletTemp = TwaterIn + (NdotCpAuxMix / NdotCpWater) * (TauxMix - FuelCell(Num).ExhaustHX.THXexh) + (FuelCell(Num).ExhaustHX.CondensateRate * hfpwater) / NdotCpWater; - if (DataGenerators::FuelCell(Num).ExhaustHX.CondensateRate > 0) { // Eq. 44 is not correct. use its result as first guess for revised way... + if (FuelCell(Num).ExhaustHX.CondensateRate > 0) { // Eq. 44 is not correct. use its result as first guess for revised way... // iterative solution because in condensing case THXexh is function of qSens and qLatent for (int loop = 1; loop <= 5; ++loop) { Real64 qSens; Real64 qLatent; - if ((DataGenerators::FuelCell(Num).ExhaustHX.THXexh - TwaterIn) != 0.0 && - ((TauxMix - DataGenerators::FuelCell(Num).ExhaustHX.WaterOutletTemp) / (DataGenerators::FuelCell(Num).ExhaustHX.THXexh - TwaterIn) > 0.0001)) { // trap divide by zero and negative log + if ((FuelCell(Num).ExhaustHX.THXexh - TwaterIn) != 0.0 && + ((TauxMix - FuelCell(Num).ExhaustHX.WaterOutletTemp) / (FuelCell(Num).ExhaustHX.THXexh - TwaterIn) > 0.0001)) { // trap divide by zero and negative log qSens = - UAeff * ((TauxMix - DataGenerators::FuelCell(Num).ExhaustHX.WaterOutletTemp) - (DataGenerators::FuelCell(Num).ExhaustHX.THXexh - TwaterIn)) / std::log((TauxMix - DataGenerators::FuelCell(Num).ExhaustHX.WaterOutletTemp) / (DataGenerators::FuelCell(Num).ExhaustHX.THXexh - TwaterIn)); + UAeff * ((TauxMix - FuelCell(Num).ExhaustHX.WaterOutletTemp) - (FuelCell(Num).ExhaustHX.THXexh - TwaterIn)) / std::log((TauxMix - FuelCell(Num).ExhaustHX.WaterOutletTemp) / (FuelCell(Num).ExhaustHX.THXexh - TwaterIn)); } else { qSens = 0.0; } - qLatent = DataGenerators::FuelCell(Num).ExhaustHX.CondensateRate * hfpwater; + qLatent = FuelCell(Num).ExhaustHX.CondensateRate * hfpwater; if (qSens > 0) { - DataGenerators::FuelCell(Num).ExhaustHX.THXexh = + FuelCell(Num).ExhaustHX.THXexh = TauxMix * ((1.0 - NdotCpAuxMix / NdotCpWater) / ((std::exp(UAeff * (1.0 / NdotCpAuxMix - 1.0 / NdotCpWater)) / (std::exp((UAeff * qLatent) / (NdotCpWater * qSens)))) - NdotCpAuxMix / NdotCpWater)) + @@ -3080,32 +3082,32 @@ namespace FuelCellElectricGenerator { (std::exp((UAeff * qLatent) / (NdotCpWater * qSens))) - NdotCpAuxMix / NdotCpWater)); } else { - DataGenerators::FuelCell(Num).ExhaustHX.THXexh = TauxMix; + FuelCell(Num).ExhaustHX.THXexh = TauxMix; } - DataGenerators::FuelCell(Num).ExhaustHX.WaterOutletTemp = TwaterIn + (NdotCpAuxMix / NdotCpWater) * (TauxMix - DataGenerators::FuelCell(Num).ExhaustHX.THXexh) + (DataGenerators::FuelCell(Num).ExhaustHX.CondensateRate * hfpwater) / NdotCpWater; + FuelCell(Num).ExhaustHX.WaterOutletTemp = TwaterIn + (NdotCpAuxMix / NdotCpWater) * (TauxMix - FuelCell(Num).ExhaustHX.THXexh) + (FuelCell(Num).ExhaustHX.CondensateRate * hfpwater) / NdotCpWater; } } } else { - DataGenerators::FuelCell(Num).ExhaustHX.THXexh = TauxMix; - DataGenerators::FuelCell(Num).ExhaustHX.WaterOutletTemp = TwaterIn; + FuelCell(Num).ExhaustHX.THXexh = TauxMix; + FuelCell(Num).ExhaustHX.WaterOutletTemp = TwaterIn; } - if ((DataGenerators::FuelCell(Num).ExhaustHX.THXexh - TwaterIn) != 0.0 && - ((TauxMix - DataGenerators::FuelCell(Num).ExhaustHX.WaterOutletTemp) / (DataGenerators::FuelCell(Num).ExhaustHX.THXexh - TwaterIn) > 0.0001)) { // trap divide by zero and negative log + if ((FuelCell(Num).ExhaustHX.THXexh - TwaterIn) != 0.0 && + ((TauxMix - FuelCell(Num).ExhaustHX.WaterOutletTemp) / (FuelCell(Num).ExhaustHX.THXexh - TwaterIn) > 0.0001)) { // trap divide by zero and negative log - DataGenerators::FuelCell(Num).ExhaustHX.qHX = UAeff * ((TauxMix - DataGenerators::FuelCell(Num).ExhaustHX.WaterOutletTemp) - (DataGenerators::FuelCell(Num).ExhaustHX.THXexh - TwaterIn)) / std::log((TauxMix - DataGenerators::FuelCell(Num).ExhaustHX.WaterOutletTemp) / (DataGenerators::FuelCell(Num).ExhaustHX.THXexh - TwaterIn)) + - DataGenerators::FuelCell(Num).ExhaustHX.CondensateRate * hfpwater; + FuelCell(Num).ExhaustHX.qHX = UAeff * ((TauxMix - FuelCell(Num).ExhaustHX.WaterOutletTemp) - (FuelCell(Num).ExhaustHX.THXexh - TwaterIn)) / std::log((TauxMix - FuelCell(Num).ExhaustHX.WaterOutletTemp) / (FuelCell(Num).ExhaustHX.THXexh - TwaterIn)) + + FuelCell(Num).ExhaustHX.CondensateRate * hfpwater; } else { - DataGenerators::FuelCell(Num).ExhaustHX.qHX = 0.0; + FuelCell(Num).ExhaustHX.qHX = 0.0; } } else { // no cooling water flow, model will blow up. - DataGenerators::FuelCell(Num).ExhaustHX.qHX = 0.0; - DataGenerators::FuelCell(Num).ExhaustHX.THXexh = DataGenerators::FuelCell(Num).AuxilHeat.TauxMix; - DataGenerators::FuelCell(Num).ExhaustHX.WaterOutletTemp = DataGenerators::FuelCell(Num).ExhaustHX.WaterInletTemp; - DataGenerators::FuelCell(Num).ExhaustHX.CondensateRate = 0.0; - DataGenerators::FuelCell(Num).ExhaustHX.WaterVaporFractExh = -9999.0; // not defined + FuelCell(Num).ExhaustHX.qHX = 0.0; + FuelCell(Num).ExhaustHX.THXexh = FuelCell(Num).AuxilHeat.TauxMix; + FuelCell(Num).ExhaustHX.WaterOutletTemp = FuelCell(Num).ExhaustHX.WaterInletTemp; + FuelCell(Num).ExhaustHX.CondensateRate = 0.0; + FuelCell(Num).ExhaustHX.WaterVaporFractExh = -9999.0; // not defined } } else { assert(false); // Variables not set are used below @@ -3113,7 +3115,7 @@ namespace FuelCellElectricGenerator { } // update results in data structure. - DataGenerators::FuelCell(Num).ExhaustHX.WaterOutletEnthalpy = DataLoopNode::Node(DataGenerators::FuelCell(Num).ExhaustHX.WaterInNode).Enthalpy + DataGenerators::FuelCell(Num).ExhaustHX.qHX; + FuelCell(Num).ExhaustHX.WaterOutletEnthalpy = DataLoopNode::Node(FuelCell(Num).ExhaustHX.WaterInNode).Enthalpy + FuelCell(Num).ExhaustHX.qHX; } void SimFuelCellPlantHeatRecovery(std::string const &EP_UNUSED(CompType), @@ -3147,9 +3149,9 @@ namespace FuelCellElectricGenerator { if (InitLoopEquip) { if (CompTypeNum == DataPlant::TypeOf_Generator_FCExhaust) { - CompNum = UtilityRoutines::FindItemInList(CompName, DataGenerators::FuelCell, &DataGenerators::FCDataStruct::NameExhaustHX); + CompNum = UtilityRoutines::FindItemInList(CompName, FuelCell, &FCDataStruct::NameExhaustHX); } else if (CompTypeNum == DataPlant::TypeOf_Generator_FCStackCooler) { - CompNum = UtilityRoutines::FindItemInList(CompName, DataGenerators::FuelCell, &DataGenerators::FCDataStruct::NameStackCooler); + CompNum = UtilityRoutines::FindItemInList(CompName, FuelCell, &FCDataStruct::NameStackCooler); } if (CompNum == 0) { ShowFatalError("SimFuelCellPlantHeatRecovery: Fuel Cell Generator Unit not found=" + CompName); @@ -3161,26 +3163,26 @@ namespace FuelCellElectricGenerator { } // End Of InitLoopEquip if (CompTypeNum == DataPlant::TypeOf_Generator_FCStackCooler) { - PlantUtilities::UpdateComponentHeatRecoverySide(DataGenerators::FuelCell(CompNum).CWLoopNum, - DataGenerators::FuelCell(CompNum).CWLoopSideNum, + PlantUtilities::UpdateComponentHeatRecoverySide(FuelCell(CompNum).CWLoopNum, + FuelCell(CompNum).CWLoopSideNum, DataPlant::TypeOf_Generator_FCStackCooler, - DataGenerators::FuelCell(CompNum).StackCooler.WaterInNode, - DataGenerators::FuelCell(CompNum).StackCooler.WaterOutNode, - DataGenerators::FuelCell(CompNum).Report.qHX, - DataGenerators::FuelCell(CompNum).Report.HeatRecInletTemp, - DataGenerators::FuelCell(CompNum).Report.HeatRecOutletTemp, - DataGenerators::FuelCell(CompNum).Report.HeatRecMdot, + FuelCell(CompNum).StackCooler.WaterInNode, + FuelCell(CompNum).StackCooler.WaterOutNode, + FuelCell(CompNum).Report.qHX, + FuelCell(CompNum).Report.HeatRecInletTemp, + FuelCell(CompNum).Report.HeatRecOutletTemp, + FuelCell(CompNum).Report.HeatRecMdot, FirstHVACIteration); } else if (CompTypeNum == DataPlant::TypeOf_Generator_FCExhaust) { - PlantUtilities::UpdateComponentHeatRecoverySide(DataGenerators::FuelCell(CompNum).CWLoopNum, - DataGenerators::FuelCell(CompNum).CWLoopSideNum, + PlantUtilities::UpdateComponentHeatRecoverySide(FuelCell(CompNum).CWLoopNum, + FuelCell(CompNum).CWLoopSideNum, DataPlant::TypeOf_Generator_FCExhaust, - DataGenerators::FuelCell(CompNum).ExhaustHX.WaterInNode, - DataGenerators::FuelCell(CompNum).ExhaustHX.WaterOutNode, - DataGenerators::FuelCell(CompNum).ExhaustHX.qHX, - DataGenerators::FuelCell(CompNum).ExhaustHX.WaterInletTemp, - DataGenerators::FuelCell(CompNum).ExhaustHX.WaterOutletTemp, - DataGenerators::FuelCell(CompNum).ExhaustHX.WaterMassFlowRate, + FuelCell(CompNum).ExhaustHX.WaterInNode, + FuelCell(CompNum).ExhaustHX.WaterOutNode, + FuelCell(CompNum).ExhaustHX.qHX, + FuelCell(CompNum).ExhaustHX.WaterInletTemp, + FuelCell(CompNum).ExhaustHX.WaterOutletTemp, + FuelCell(CompNum).ExhaustHX.WaterMassFlowRate, FirstHVACIteration); } } @@ -3205,19 +3207,19 @@ namespace FuelCellElectricGenerator { bool errFlag; // Do the one time initializations - if (DataGenerators::FuelCell(FCnum).InitGenerator) { - DataGenerators::FuelCell(FCnum).InitGenerator = false; + if (FuelCell(FCnum).InitGenerator) { + FuelCell(FCnum).InitGenerator = false; } // end one time setups and inits - if (DataGenerators::FuelCell(FCnum).MyPlantScanFlag_Init && allocated(DataPlant::PlantLoop)) { + if (FuelCell(FCnum).MyPlantScanFlag_Init && allocated(DataPlant::PlantLoop)) { errFlag = false; - PlantUtilities::ScanPlantLoopsForObject(DataGenerators::FuelCell(FCnum).NameExhaustHX, + PlantUtilities::ScanPlantLoopsForObject(FuelCell(FCnum).NameExhaustHX, DataPlant::TypeOf_Generator_FCExhaust, - DataGenerators::FuelCell(FCnum).CWLoopNum, - DataGenerators::FuelCell(FCnum).CWLoopSideNum, - DataGenerators::FuelCell(FCnum).CWBranchNum, - DataGenerators::FuelCell(FCnum).CWCompNum, + FuelCell(FCnum).CWLoopNum, + FuelCell(FCnum).CWLoopSideNum, + FuelCell(FCnum).CWBranchNum, + FuelCell(FCnum).CWCompNum, errFlag, _, _, @@ -3230,130 +3232,130 @@ namespace FuelCellElectricGenerator { if (errFlag) { ShowFatalError("InitFuelCellGenerators: Program terminated due to previous condition(s)."); } - DataGenerators::FuelCell(FCnum).MyPlantScanFlag_Init = false; + FuelCell(FCnum).MyPlantScanFlag_Init = false; } // Do the Begin Environment initializations - if (DataGlobals::BeginEnvrnFlag && DataGenerators::FuelCell(FCnum).MyEnvrnFlag_Init && !DataGenerators::FuelCell(FCnum).MyPlantScanFlag_Init) { - - DataGenerators::FuelSupply(DataGenerators::FuelCell(FCnum).FuelSupNum).PfuelCompEl = 0.0; - DataGenerators::FuelSupply(DataGenerators::FuelCell(FCnum).FuelSupNum).TfuelIntoFCPM = 0.0; - DataGenerators::FuelSupply(DataGenerators::FuelCell(FCnum).FuelSupNum).TfuelIntoCompress = 0.0; - DataGenerators::FuelSupply(DataGenerators::FuelCell(FCnum).FuelSupNum).QskinLoss = 0.0; - - DataGenerators::FuelCell(FCnum).AirSup.TairIntoFCPM = 0.0; - DataGenerators::FuelCell(FCnum).AirSup.PairCompEl = 0.0; - DataGenerators::FuelCell(FCnum).AirSup.TairIntoBlower = 0.0; - DataGenerators::FuelCell(FCnum).AirSup.QskinLoss = 0.0; - DataGenerators::FuelCell(FCnum).AirSup.QintakeRecovery = 0.0; - DataGenerators::FuelCell(FCnum).FCPM.NumCycles = 0; - DataGenerators::FuelCell(FCnum).FCPM.Pel = 0.0; - DataGenerators::FuelCell(FCnum).FCPM.PelLastTimeStep = 0.0; - DataGenerators::FuelCell(FCnum).FCPM.Eel = 0.0; - DataGenerators::FuelCell(FCnum).FCPM.PelancillariesAC = 0.0; - DataGenerators::FuelCell(FCnum).FCPM.NdotFuel = 0.0; - DataGenerators::FuelCell(FCnum).FCPM.TotFuelInEnthalphy = 0.0; - DataGenerators::FuelCell(FCnum).FCPM.NdotProdGas = 0.0; - DataGenerators::FuelCell(FCnum).FCPM.TprodGasLeavingFCPM = 0.0; - DataGenerators::FuelCell(FCnum).FCPM.TotProdGasEnthalphy = 0.0; - DataGenerators::FuelCell(FCnum).FCPM.NdotAir = 0.0; - DataGenerators::FuelCell(FCnum).FCPM.TotAirInEnthalphy = 0.0; - DataGenerators::FuelCell(FCnum).FCPM.NdotLiqwater = 0.0; - DataGenerators::FuelCell(FCnum).FCPM.TwaterInlet = 0.0; - DataGenerators::FuelCell(FCnum).FCPM.WaterInEnthalpy = 0.0; - DataGenerators::FuelCell(FCnum).FCPM.TprodGasLeavingFCPM = 200.0; - DataGenerators::FuelCell(FCnum).FCPM.FractionalDayofLastStartUp = 0.0; - DataGenerators::FuelCell(FCnum).FCPM.FractionalDayofLastShutDown = 0.0; - DataGenerators::FuelCell(FCnum).FCPM.HasBeenOn = true; - DataGenerators::FuelCell(FCnum).FCPM.DuringShutDown = false; - DataGenerators::FuelCell(FCnum).FCPM.DuringStartUp = false; - DataGenerators::FuelCell(FCnum).WaterSup.TwaterIntoCompress = 0.0; - DataGenerators::FuelCell(FCnum).WaterSup.TwaterIntoFCPM = 0.0; - DataGenerators::FuelCell(FCnum).WaterSup.PwaterCompEl = 0.0; - DataGenerators::FuelCell(FCnum).WaterSup.QskinLoss = 0.0; - DataGenerators::FuelCell(FCnum).AuxilHeat.TauxMix = 0.0; - DataGenerators::FuelCell(FCnum).AuxilHeat.NdotAuxMix = 0.0; - DataGenerators::FuelCell(FCnum).AuxilHeat.QskinLoss = 0.0; - DataGenerators::FuelCell(FCnum).AuxilHeat.QairIntake = 0.0; - DataGenerators::FuelCell(FCnum).ExhaustHX.NdotHXleaving = 0.0; - DataGenerators::FuelCell(FCnum).ExhaustHX.WaterOutletTemp = 0.0; - DataGenerators::FuelCell(FCnum).ExhaustHX.WaterOutletEnthalpy = 0.0; - DataGenerators::FuelCell(FCnum).ElecStorage.LastTimeStepStateOfCharge = DataGenerators::FuelCell(FCnum).ElecStorage.StartingEnergyStored; - DataGenerators::FuelCell(FCnum).ElecStorage.ThisTimeStepStateOfCharge = DataGenerators::FuelCell(FCnum).ElecStorage.StartingEnergyStored; - DataGenerators::FuelCell(FCnum).ElecStorage.PelNeedFromStorage = 0.0; - DataGenerators::FuelCell(FCnum).ElecStorage.IdesiredDischargeCurrent = 0.0; - DataGenerators::FuelCell(FCnum).ElecStorage.PelFromStorage = 0.0; - DataGenerators::FuelCell(FCnum).ElecStorage.IfromStorage = 0.0; - DataGenerators::FuelCell(FCnum).ElecStorage.PelIntoStorage = 0.0; - DataGenerators::FuelCell(FCnum).ElecStorage.QairIntake = 0.0; - - DataGenerators::FuelCell(FCnum).Inverter.PCUlosses = 0.0; - DataGenerators::FuelCell(FCnum).Inverter.QairIntake = 0.0; + if (DataGlobals::BeginEnvrnFlag && FuelCell(FCnum).MyEnvrnFlag_Init && !FuelCell(FCnum).MyPlantScanFlag_Init) { + + DataGenerators::FuelSupply(FuelCell(FCnum).FuelSupNum).PfuelCompEl = 0.0; + DataGenerators::FuelSupply(FuelCell(FCnum).FuelSupNum).TfuelIntoFCPM = 0.0; + DataGenerators::FuelSupply(FuelCell(FCnum).FuelSupNum).TfuelIntoCompress = 0.0; + DataGenerators::FuelSupply(FuelCell(FCnum).FuelSupNum).QskinLoss = 0.0; + + FuelCell(FCnum).AirSup.TairIntoFCPM = 0.0; + FuelCell(FCnum).AirSup.PairCompEl = 0.0; + FuelCell(FCnum).AirSup.TairIntoBlower = 0.0; + FuelCell(FCnum).AirSup.QskinLoss = 0.0; + FuelCell(FCnum).AirSup.QintakeRecovery = 0.0; + FuelCell(FCnum).FCPM.NumCycles = 0; + FuelCell(FCnum).FCPM.Pel = 0.0; + FuelCell(FCnum).FCPM.PelLastTimeStep = 0.0; + FuelCell(FCnum).FCPM.Eel = 0.0; + FuelCell(FCnum).FCPM.PelancillariesAC = 0.0; + FuelCell(FCnum).FCPM.NdotFuel = 0.0; + FuelCell(FCnum).FCPM.TotFuelInEnthalphy = 0.0; + FuelCell(FCnum).FCPM.NdotProdGas = 0.0; + FuelCell(FCnum).FCPM.TprodGasLeavingFCPM = 0.0; + FuelCell(FCnum).FCPM.TotProdGasEnthalphy = 0.0; + FuelCell(FCnum).FCPM.NdotAir = 0.0; + FuelCell(FCnum).FCPM.TotAirInEnthalphy = 0.0; + FuelCell(FCnum).FCPM.NdotLiqwater = 0.0; + FuelCell(FCnum).FCPM.TwaterInlet = 0.0; + FuelCell(FCnum).FCPM.WaterInEnthalpy = 0.0; + FuelCell(FCnum).FCPM.TprodGasLeavingFCPM = 200.0; + FuelCell(FCnum).FCPM.FractionalDayofLastStartUp = 0.0; + FuelCell(FCnum).FCPM.FractionalDayofLastShutDown = 0.0; + FuelCell(FCnum).FCPM.HasBeenOn = true; + FuelCell(FCnum).FCPM.DuringShutDown = false; + FuelCell(FCnum).FCPM.DuringStartUp = false; + FuelCell(FCnum).WaterSup.TwaterIntoCompress = 0.0; + FuelCell(FCnum).WaterSup.TwaterIntoFCPM = 0.0; + FuelCell(FCnum).WaterSup.PwaterCompEl = 0.0; + FuelCell(FCnum).WaterSup.QskinLoss = 0.0; + FuelCell(FCnum).AuxilHeat.TauxMix = 0.0; + FuelCell(FCnum).AuxilHeat.NdotAuxMix = 0.0; + FuelCell(FCnum).AuxilHeat.QskinLoss = 0.0; + FuelCell(FCnum).AuxilHeat.QairIntake = 0.0; + FuelCell(FCnum).ExhaustHX.NdotHXleaving = 0.0; + FuelCell(FCnum).ExhaustHX.WaterOutletTemp = 0.0; + FuelCell(FCnum).ExhaustHX.WaterOutletEnthalpy = 0.0; + FuelCell(FCnum).ElecStorage.LastTimeStepStateOfCharge = FuelCell(FCnum).ElecStorage.StartingEnergyStored; + FuelCell(FCnum).ElecStorage.ThisTimeStepStateOfCharge = FuelCell(FCnum).ElecStorage.StartingEnergyStored; + FuelCell(FCnum).ElecStorage.PelNeedFromStorage = 0.0; + FuelCell(FCnum).ElecStorage.IdesiredDischargeCurrent = 0.0; + FuelCell(FCnum).ElecStorage.PelFromStorage = 0.0; + FuelCell(FCnum).ElecStorage.IfromStorage = 0.0; + FuelCell(FCnum).ElecStorage.PelIntoStorage = 0.0; + FuelCell(FCnum).ElecStorage.QairIntake = 0.0; + + FuelCell(FCnum).Inverter.PCUlosses = 0.0; + FuelCell(FCnum).Inverter.QairIntake = 0.0; Real64 rho = FluidProperties::GetDensityGlycol( - DataPlant::PlantLoop(DataGenerators::FuelCell(FCnum).CWLoopNum).FluidName, DataGenerators::InitHRTemp, DataPlant::PlantLoop(DataGenerators::FuelCell(FCnum).CWLoopNum).FluidIndex, RoutineName); + DataPlant::PlantLoop(FuelCell(FCnum).CWLoopNum).FluidName, DataGenerators::InitHRTemp, DataPlant::PlantLoop(FuelCell(FCnum).CWLoopNum).FluidIndex, RoutineName); - DataGenerators::FuelCell(FCnum).ExhaustHX.WaterMassFlowRateDesign = DataGenerators::FuelCell(FCnum).ExhaustHX.WaterVolumeFlowMax * rho; - DataGenerators::FuelCell(FCnum).ExhaustHX.WaterMassFlowRate = DataGenerators::FuelCell(FCnum).ExhaustHX.WaterMassFlowRateDesign; - DataLoopNode::Node(DataGenerators::FuelCell(FCnum).ExhaustHX.WaterInNode).Temp = DataGenerators::InitHRTemp; - DataLoopNode::Node(DataGenerators::FuelCell(FCnum).ExhaustHX.WaterOutNode).Temp = DataGenerators::InitHRTemp; + FuelCell(FCnum).ExhaustHX.WaterMassFlowRateDesign = FuelCell(FCnum).ExhaustHX.WaterVolumeFlowMax * rho; + FuelCell(FCnum).ExhaustHX.WaterMassFlowRate = FuelCell(FCnum).ExhaustHX.WaterMassFlowRateDesign; + DataLoopNode::Node(FuelCell(FCnum).ExhaustHX.WaterInNode).Temp = DataGenerators::InitHRTemp; + DataLoopNode::Node(FuelCell(FCnum).ExhaustHX.WaterOutNode).Temp = DataGenerators::InitHRTemp; PlantUtilities::InitComponentNodes(0.0, - DataGenerators::FuelCell(FCnum).ExhaustHX.WaterMassFlowRateDesign, - DataGenerators::FuelCell(FCnum).ExhaustHX.WaterInNode, - DataGenerators::FuelCell(FCnum).ExhaustHX.WaterOutNode, - DataGenerators::FuelCell(FCnum).CWLoopNum, - DataGenerators::FuelCell(FCnum).CWLoopSideNum, - DataGenerators::FuelCell(FCnum).CWBranchNum, - DataGenerators::FuelCell(FCnum).CWCompNum); - - DataGenerators::FuelCell(FCnum).MyEnvrnFlag_Init = false; - DataGenerators::FuelCell(FCnum).MyWarmupFlag_Init = true; + FuelCell(FCnum).ExhaustHX.WaterMassFlowRateDesign, + FuelCell(FCnum).ExhaustHX.WaterInNode, + FuelCell(FCnum).ExhaustHX.WaterOutNode, + FuelCell(FCnum).CWLoopNum, + FuelCell(FCnum).CWLoopSideNum, + FuelCell(FCnum).CWBranchNum, + FuelCell(FCnum).CWCompNum); + + FuelCell(FCnum).MyEnvrnFlag_Init = false; + FuelCell(FCnum).MyWarmupFlag_Init = true; } // end environmental inits if (!DataGlobals::BeginEnvrnFlag) { - DataGenerators::FuelCell(FCnum).MyEnvrnFlag_Init = true; + FuelCell(FCnum).MyEnvrnFlag_Init = true; } - if (DataGenerators::FuelCell(FCnum).MyWarmupFlag_Init && (!DataGlobals::WarmupFlag)) { + if (FuelCell(FCnum).MyWarmupFlag_Init && (!DataGlobals::WarmupFlag)) { // need to reset initial state of charge at beginning of environment but after warm up is complete - DataGenerators::FuelCell(FCnum).ElecStorage.LastTimeStepStateOfCharge = DataGenerators::FuelCell(FCnum).ElecStorage.StartingEnergyStored; - DataGenerators::FuelCell(FCnum).ElecStorage.ThisTimeStepStateOfCharge = DataGenerators::FuelCell(FCnum).ElecStorage.StartingEnergyStored; - DataGenerators::FuelCell(FCnum).MyWarmupFlag_Init = false; + FuelCell(FCnum).ElecStorage.LastTimeStepStateOfCharge = FuelCell(FCnum).ElecStorage.StartingEnergyStored; + FuelCell(FCnum).ElecStorage.ThisTimeStepStateOfCharge = FuelCell(FCnum).ElecStorage.StartingEnergyStored; + FuelCell(FCnum).MyWarmupFlag_Init = false; } // using and elapsed time method rather than FirstHVACIteration here Real64 TimeElapsed = DataGlobals::HourOfDay + DataGlobals::TimeStep * DataGlobals::TimeStepZone + DataHVACGlobals::SysTimeElapsed; - if (DataGenerators::FuelCell(FCnum).TimeElapsed != TimeElapsed) { + if (FuelCell(FCnum).TimeElapsed != TimeElapsed) { - DataGenerators::FuelCell(FCnum).ElecStorage.LastTimeStepStateOfCharge = DataGenerators::FuelCell(FCnum).ElecStorage.ThisTimeStepStateOfCharge; - DataGenerators::FuelCell(FCnum).FCPM.PelLastTimeStep = DataGenerators::FuelCell(FCnum).FCPM.Pel; + FuelCell(FCnum).ElecStorage.LastTimeStepStateOfCharge = FuelCell(FCnum).ElecStorage.ThisTimeStepStateOfCharge; + FuelCell(FCnum).FCPM.PelLastTimeStep = FuelCell(FCnum).FCPM.Pel; // intialize flow rate in water loop, this is "requesting" flow - Real64 mdot = DataGenerators::FuelCell(FCnum).ExhaustHX.WaterMassFlowRateDesign; + Real64 mdot = FuelCell(FCnum).ExhaustHX.WaterMassFlowRateDesign; PlantUtilities::SetComponentFlowRate(mdot, - DataGenerators::FuelCell(FCnum).ExhaustHX.WaterInNode, - DataGenerators::FuelCell(FCnum).ExhaustHX.WaterOutNode, - DataGenerators::FuelCell(FCnum).CWLoopNum, - DataGenerators::FuelCell(FCnum).CWLoopSideNum, - DataGenerators::FuelCell(FCnum).CWBranchNum, - DataGenerators::FuelCell(FCnum).CWCompNum); - - DataGenerators::FuelCell(FCnum).ExhaustHX.WaterMassFlowRate = mdot; - DataGenerators::FuelCell(FCnum).ExhaustHX.WaterInletTemp = DataLoopNode::Node(DataGenerators::FuelCell(FCnum).ExhaustHX.WaterInNode).Temp; - DataGenerators::FuelCell(FCnum).TimeElapsed = TimeElapsed; + FuelCell(FCnum).ExhaustHX.WaterInNode, + FuelCell(FCnum).ExhaustHX.WaterOutNode, + FuelCell(FCnum).CWLoopNum, + FuelCell(FCnum).CWLoopSideNum, + FuelCell(FCnum).CWBranchNum, + FuelCell(FCnum).CWCompNum); + + FuelCell(FCnum).ExhaustHX.WaterMassFlowRate = mdot; + FuelCell(FCnum).ExhaustHX.WaterInletTemp = DataLoopNode::Node(FuelCell(FCnum).ExhaustHX.WaterInNode).Temp; + FuelCell(FCnum).TimeElapsed = TimeElapsed; } else { - PlantUtilities::SetComponentFlowRate(DataGenerators::FuelCell(FCnum).ExhaustHX.WaterMassFlowRate, - DataGenerators::FuelCell(FCnum).ExhaustHX.WaterInNode, - DataGenerators::FuelCell(FCnum).ExhaustHX.WaterOutNode, - DataGenerators::FuelCell(FCnum).CWLoopNum, - DataGenerators::FuelCell(FCnum).CWLoopSideNum, - DataGenerators::FuelCell(FCnum).CWBranchNum, - DataGenerators::FuelCell(FCnum).CWCompNum); + PlantUtilities::SetComponentFlowRate(FuelCell(FCnum).ExhaustHX.WaterMassFlowRate, + FuelCell(FCnum).ExhaustHX.WaterInNode, + FuelCell(FCnum).ExhaustHX.WaterOutNode, + FuelCell(FCnum).CWLoopNum, + FuelCell(FCnum).CWLoopSideNum, + FuelCell(FCnum).CWBranchNum, + FuelCell(FCnum).CWCompNum); - DataGenerators::FuelCell(FCnum).ExhaustHX.WaterInletTemp = DataLoopNode::Node(DataGenerators::FuelCell(FCnum).ExhaustHX.WaterInNode).Temp; + FuelCell(FCnum).ExhaustHX.WaterInletTemp = DataLoopNode::Node(FuelCell(FCnum).ExhaustHX.WaterInNode).Temp; } } @@ -3361,8 +3363,6 @@ namespace FuelCellElectricGenerator { std::string &heatRecoveryCompName) { - using DataGenerators::FuelCell; - if (GetFuelCellInput) { // Read input data. @@ -3401,8 +3401,8 @@ namespace FuelCellElectricGenerator { for (auto &e : DataGenerators::FuelSupply) e.QskinLoss = 0.0; MyEnvrnFlag = false; - for (int i = DataGenerators::FuelCell.l(), e = DataGenerators::FuelCell.u(); i <= e; ++i) { - auto &cell(DataGenerators::FuelCell(i)); + for (int i = FuelCell.l(), e = FuelCell.u(); i <= e; ++i) { + auto &cell(FuelCell(i)); cell.FCPM.HasBeenOn = false; cell.AirSup.PairCompEl = 0.0; cell.QconvZone = 0.0; @@ -3425,39 +3425,39 @@ namespace FuelCellElectricGenerator { // first collect skin losses from different subsystems for (int FCnum = 1; FCnum <= NumFuelCellGenerators; ++FCnum) { - Real64 TotalZoneHeatGain = DataGenerators::FuelCell(FCnum).AirSup.QskinLoss + DataGenerators::FuelSupply(DataGenerators::FuelCell(FCnum).FuelSupNum).QskinLoss + - DataGenerators::FuelCell(FCnum).WaterSup.QskinLoss + DataGenerators::FuelCell(FCnum).AuxilHeat.QskinLoss + - DataGenerators::FuelCell(FCnum).FCPM.QdotSkin; // intake Blower losses to zone | fuel compressor losses to zone | water pump losses to + Real64 TotalZoneHeatGain = FuelCell(FCnum).AirSup.QskinLoss + DataGenerators::FuelSupply(FuelCell(FCnum).FuelSupNum).QskinLoss + + FuelCell(FCnum).WaterSup.QskinLoss + FuelCell(FCnum).AuxilHeat.QskinLoss + + FuelCell(FCnum).FCPM.QdotSkin; // intake Blower losses to zone | fuel compressor losses to zone | water pump losses to // zone | auxil burner losses to zone | power module (stack and reformer) losses to // zone // now account for other subsystems that may or may not have air intake recovery { - auto const SELECT_CASE_var(DataGenerators::FuelCell(FCnum).AirSup.IntakeRecoveryMode); + auto const SELECT_CASE_var(FuelCell(FCnum).AirSup.IntakeRecoveryMode); if (SELECT_CASE_var == DataGenerators::NoRecoveryOnAirIntake) { // then the heat has to go into zone TotalZoneHeatGain += - DataGenerators::FuelCell(FCnum).AuxilHeat.QairIntake + DataGenerators::FuelCell(FCnum).ElecStorage.QairIntake + DataGenerators::FuelCell(FCnum).Inverter.QairIntake; + FuelCell(FCnum).AuxilHeat.QairIntake + FuelCell(FCnum).ElecStorage.QairIntake + FuelCell(FCnum).Inverter.QairIntake; } else if (SELECT_CASE_var == DataGenerators::RecoverAuxiliaryBurner) { - TotalZoneHeatGain += DataGenerators::FuelCell(FCnum).ElecStorage.QairIntake + DataGenerators::FuelCell(FCnum).Inverter.QairIntake; + TotalZoneHeatGain += FuelCell(FCnum).ElecStorage.QairIntake + FuelCell(FCnum).Inverter.QairIntake; } else if (SELECT_CASE_var == DataGenerators::RecoverInverterBatt) { - TotalZoneHeatGain += DataGenerators::FuelCell(FCnum).AuxilHeat.QairIntake; + TotalZoneHeatGain += FuelCell(FCnum).AuxilHeat.QairIntake; } else if (SELECT_CASE_var == DataGenerators::RecoverInverter) { - TotalZoneHeatGain += DataGenerators::FuelCell(FCnum).AuxilHeat.QairIntake + DataGenerators::FuelCell(FCnum).ElecStorage.QairIntake; + TotalZoneHeatGain += FuelCell(FCnum).AuxilHeat.QairIntake + FuelCell(FCnum).ElecStorage.QairIntake; } else if (SELECT_CASE_var == DataGenerators::RecoverBattery) { - TotalZoneHeatGain += DataGenerators::FuelCell(FCnum).AuxilHeat.QairIntake + DataGenerators::FuelCell(FCnum).Inverter.QairIntake; + TotalZoneHeatGain += FuelCell(FCnum).AuxilHeat.QairIntake + FuelCell(FCnum).Inverter.QairIntake; } else if (SELECT_CASE_var == DataGenerators::RecoverBurnInvertBatt) { // do nothing } } - DataGenerators::FuelCell(FCnum).QconvZone = TotalZoneHeatGain * (1 - DataGenerators::FuelCell(FCnum).FCPM.RadiativeFract); - DataGenerators::FuelCell(FCnum).Report.SkinLossConvect = DataGenerators::FuelCell(FCnum).QconvZone; - DataGenerators::FuelCell(FCnum).QradZone = TotalZoneHeatGain * DataGenerators::FuelCell(FCnum).FCPM.RadiativeFract; - DataGenerators::FuelCell(FCnum).Report.SkinLossRadiat = DataGenerators::FuelCell(FCnum).QradZone; + FuelCell(FCnum).QconvZone = TotalZoneHeatGain * (1 - FuelCell(FCnum).FCPM.RadiativeFract); + FuelCell(FCnum).Report.SkinLossConvect = FuelCell(FCnum).QconvZone; + FuelCell(FCnum).QradZone = TotalZoneHeatGain * FuelCell(FCnum).FCPM.RadiativeFract; + FuelCell(FCnum).Report.SkinLossRadiat = FuelCell(FCnum).QradZone; } // over number of Fuel cells } @@ -3477,10 +3477,10 @@ namespace FuelCellElectricGenerator { // now update water outlet node Changing to Kg/s! - PlantUtilities::SafeCopyPlantNode(DataGenerators::FuelCell(Num).ExhaustHX.WaterInNode, DataGenerators::FuelCell(Num).ExhaustHX.WaterOutNode); + PlantUtilities::SafeCopyPlantNode(FuelCell(Num).ExhaustHX.WaterInNode, FuelCell(Num).ExhaustHX.WaterOutNode); - DataLoopNode::Node(DataGenerators::FuelCell(Num).ExhaustHX.WaterOutNode).Temp = DataGenerators::FuelCell(Num).ExhaustHX.WaterOutletTemp; - DataLoopNode::Node(DataGenerators::FuelCell(Num).ExhaustHX.WaterOutNode).Enthalpy = DataGenerators::FuelCell(Num).ExhaustHX.WaterOutletEnthalpy; + DataLoopNode::Node(FuelCell(Num).ExhaustHX.WaterOutNode).Temp = FuelCell(Num).ExhaustHX.WaterOutletTemp; + DataLoopNode::Node(FuelCell(Num).ExhaustHX.WaterOutNode).Enthalpy = FuelCell(Num).ExhaustHX.WaterOutletEnthalpy; } void UpdateFuelCellGeneratorRecords(bool const EP_UNUSED(RunFlag), // TRUE if Generator operating @@ -3488,91 +3488,91 @@ namespace FuelCellElectricGenerator { ) { - DataGenerators::FuelCell(Num).Report.ACPowerGen = DataGenerators::FuelCell(Num).ACPowerGen; // electrical power produced [W] - DataGenerators::FuelCell(Num).Report.ACEnergyGen = DataGenerators::FuelCell(Num).ACPowerGen * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; // energy produced (J) - DataGenerators::FuelCell(Num).Report.QdotExhaust = 0.0; // reporting: exhaust gas heat recovered (W) - DataGenerators::FuelCell(Num).Report.TotalHeatEnergyRec = 0.0; // reporting: total heat recovered (J) - DataGenerators::FuelCell(Num).Report.ExhaustEnergyRec = 0.0; // reporting: exhaust gas heat recovered (J) - - DataGenerators::FuelCell(Num).Report.HeatRecInletTemp = 0.0; // reporting: Heat Recovery Loop Inlet Temperature (C) - DataGenerators::FuelCell(Num).Report.HeatRecOutletTemp = 0.0; // reporting: Heat Recovery Loop Outlet Temperature (C) - DataGenerators::FuelCell(Num).Report.HeatRecMdot = 0.0; // reporting: Heat Recovery Loop Mass flow rate (kg/s) - - DataGenerators::FuelCell(Num).Report.ElectEfficiency = 0.0; - DataGenerators::FuelCell(Num).Report.ThermalEfficiency = 0.0; - DataGenerators::FuelCell(Num).Report.OverallEfficiency = 0.0; - DataGenerators::FuelCell(Num).Report.ExergyEfficiency = 0.0; - - DataGenerators::FuelCell(Num).Report.TairInlet = DataGenerators::FuelCell(Num).AirSup.TairIntoBlower; // State point 1 - DataGenerators::FuelCell(Num).Report.TairIntoFCPM = DataGenerators::FuelCell(Num).AirSup.TairIntoFCPM; // State point 4 - DataGenerators::FuelCell(Num).Report.NdotAir = DataGenerators::FuelCell(Num).FCPM.NdotAir; // air flow in kmol/sec - DataGenerators::FuelCell(Num).Report.TotAirInEnthalphy = DataGenerators::FuelCell(Num).FCPM.TotAirInEnthalphy; // State point 4 - DataGenerators::FuelCell(Num).Report.BlowerPower = DataGenerators::FuelCell(Num).AirSup.PairCompEl; // electrical power used by air supply blower - DataGenerators::FuelCell(Num).Report.BlowerEnergy = DataGenerators::FuelCell(Num).AirSup.PairCompEl * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; // electrical energy - DataGenerators::FuelCell(Num).Report.BlowerSkinLoss = DataGenerators::FuelCell(Num).AirSup.QskinLoss; // heat rate of losses by blower - - DataGenerators::FuelCell(Num).Report.TfuelInlet = DataGenerators::FuelSupply(DataGenerators::FuelCell(Num).FuelSupNum).TfuelIntoCompress; // State point 2 - DataGenerators::FuelCell(Num).Report.TfuelIntoFCPM = DataGenerators::FuelSupply(DataGenerators::FuelCell(Num).FuelSupNum).TfuelIntoFCPM; // TEmperature state point 5 [C] - DataGenerators::FuelCell(Num).Report.NdotFuel = DataGenerators::FuelCell(Num).FCPM.NdotFuel; // fuel flow in kmol/sec - DataGenerators::FuelCell(Num).Report.TotFuelInEnthalpy = DataGenerators::FuelCell(Num).FCPM.TotFuelInEnthalphy; // enthalpy at state point 5 [W] - DataGenerators::FuelCell(Num).Report.FuelCompressPower = DataGenerators::FuelSupply(DataGenerators::FuelCell(Num).FuelSupNum).PfuelCompEl; + FuelCell(Num).Report.ACPowerGen = FuelCell(Num).ACPowerGen; // electrical power produced [W] + FuelCell(Num).Report.ACEnergyGen = FuelCell(Num).ACPowerGen * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; // energy produced (J) + FuelCell(Num).Report.QdotExhaust = 0.0; // reporting: exhaust gas heat recovered (W) + FuelCell(Num).Report.TotalHeatEnergyRec = 0.0; // reporting: total heat recovered (J) + FuelCell(Num).Report.ExhaustEnergyRec = 0.0; // reporting: exhaust gas heat recovered (J) + + FuelCell(Num).Report.HeatRecInletTemp = 0.0; // reporting: Heat Recovery Loop Inlet Temperature (C) + FuelCell(Num).Report.HeatRecOutletTemp = 0.0; // reporting: Heat Recovery Loop Outlet Temperature (C) + FuelCell(Num).Report.HeatRecMdot = 0.0; // reporting: Heat Recovery Loop Mass flow rate (kg/s) + + FuelCell(Num).Report.ElectEfficiency = 0.0; + FuelCell(Num).Report.ThermalEfficiency = 0.0; + FuelCell(Num).Report.OverallEfficiency = 0.0; + FuelCell(Num).Report.ExergyEfficiency = 0.0; + + FuelCell(Num).Report.TairInlet = FuelCell(Num).AirSup.TairIntoBlower; // State point 1 + FuelCell(Num).Report.TairIntoFCPM = FuelCell(Num).AirSup.TairIntoFCPM; // State point 4 + FuelCell(Num).Report.NdotAir = FuelCell(Num).FCPM.NdotAir; // air flow in kmol/sec + FuelCell(Num).Report.TotAirInEnthalphy = FuelCell(Num).FCPM.TotAirInEnthalphy; // State point 4 + FuelCell(Num).Report.BlowerPower = FuelCell(Num).AirSup.PairCompEl; // electrical power used by air supply blower + FuelCell(Num).Report.BlowerEnergy = FuelCell(Num).AirSup.PairCompEl * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; // electrical energy + FuelCell(Num).Report.BlowerSkinLoss = FuelCell(Num).AirSup.QskinLoss; // heat rate of losses by blower + + FuelCell(Num).Report.TfuelInlet = DataGenerators::FuelSupply(FuelCell(Num).FuelSupNum).TfuelIntoCompress; // State point 2 + FuelCell(Num).Report.TfuelIntoFCPM = DataGenerators::FuelSupply(FuelCell(Num).FuelSupNum).TfuelIntoFCPM; // TEmperature state point 5 [C] + FuelCell(Num).Report.NdotFuel = FuelCell(Num).FCPM.NdotFuel; // fuel flow in kmol/sec + FuelCell(Num).Report.TotFuelInEnthalpy = FuelCell(Num).FCPM.TotFuelInEnthalphy; // enthalpy at state point 5 [W] + FuelCell(Num).Report.FuelCompressPower = DataGenerators::FuelSupply(FuelCell(Num).FuelSupNum).PfuelCompEl; // electrical power used by fuel supply compressor [W] - DataGenerators::FuelCell(Num).Report.FuelCompressEnergy = DataGenerators::FuelSupply(DataGenerators::FuelCell(Num).FuelSupNum).PfuelCompEl * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; // elect energy - DataGenerators::FuelCell(Num).Report.FuelCompressSkinLoss = DataGenerators::FuelSupply(DataGenerators::FuelCell(Num).FuelSupNum).QskinLoss; + FuelCell(Num).Report.FuelCompressEnergy = DataGenerators::FuelSupply(FuelCell(Num).FuelSupNum).PfuelCompEl * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; // elect energy + FuelCell(Num).Report.FuelCompressSkinLoss = DataGenerators::FuelSupply(FuelCell(Num).FuelSupNum).QskinLoss; // heat rate of losses.by fuel supply compressor [W] - DataGenerators::FuelCell(Num).Report.FuelEnergyLHV = DataGenerators::FuelCell(Num).FCPM.NdotFuel * DataGenerators::FuelSupply(DataGenerators::FuelCell(Num).FuelSupNum).LHV * 1000000.0 * DataHVACGlobals::TimeStepSys * + FuelCell(Num).Report.FuelEnergyLHV = FuelCell(Num).FCPM.NdotFuel * DataGenerators::FuelSupply(FuelCell(Num).FuelSupNum).LHV * 1000000.0 * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; // reporting: Fuel Energy used (J) - DataGenerators::FuelCell(Num).Report.FuelEnergyUseRateLHV = - DataGenerators::FuelCell(Num).FCPM.NdotFuel * DataGenerators::FuelSupply(DataGenerators::FuelCell(Num).FuelSupNum).LHV * 1000000.0; // reporting: Fuel Energy used (W) - DataGenerators::FuelCell(Num).Report.FuelEnergyHHV = DataGenerators::FuelCell(Num).FCPM.NdotFuel * DataGenerators::FuelSupply(DataGenerators::FuelCell(Num).FuelSupNum).HHV * - DataGenerators::FuelSupply(DataGenerators::FuelCell(Num).FuelSupNum).KmolPerSecToKgPerSec * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - - DataGenerators::FuelCell(Num).Report.FuelEnergyUseRateHHV = - DataGenerators::FuelCell(Num).FCPM.NdotFuel * DataGenerators::FuelSupply(DataGenerators::FuelCell(Num).FuelSupNum).HHV * DataGenerators::FuelSupply(DataGenerators::FuelCell(Num).FuelSupNum).KmolPerSecToKgPerSec; - - DataGenerators::FuelCell(Num).Report.FuelRateMdot = 0.0; // (Kg/s) - - DataGenerators::FuelCell(Num).Report.TwaterInlet = DataGenerators::FuelCell(Num).WaterSup.TwaterIntoCompress; - DataGenerators::FuelCell(Num).Report.TwaterIntoFCPM = DataGenerators::FuelCell(Num).WaterSup.TwaterIntoFCPM; - DataGenerators::FuelCell(Num).Report.NdotWater = DataGenerators::FuelCell(Num).FCPM.NdotLiqwater; // water flow in kmol/sec (reformer water) - DataGenerators::FuelCell(Num).Report.WaterPumpPower = DataGenerators::FuelCell(Num).WaterSup.PwaterCompEl; - DataGenerators::FuelCell(Num).Report.WaterPumpEnergy = DataGenerators::FuelCell(Num).WaterSup.PwaterCompEl * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; // electrical energy - DataGenerators::FuelCell(Num).Report.WaterIntoFCPMEnthalpy = DataGenerators::FuelCell(Num).FCPM.WaterInEnthalpy; - - DataGenerators::FuelCell(Num).Report.TprodGas = DataGenerators::FuelCell(Num).FCPM.TprodGasLeavingFCPM; // temperature at State point 7 - DataGenerators::FuelCell(Num).Report.EnthalProdGas = DataGenerators::FuelCell(Num).FCPM.TotProdGasEnthalphy; // enthalpy at State point 7 - DataGenerators::FuelCell(Num).Report.NdotProdGas = DataGenerators::FuelCell(Num).FCPM.NdotProdGas; // flow rate at point 7 [kmol/sec] - DataGenerators::FuelCell(Num).Report.NdotProdAr = DataGenerators::FuelCell(Num).FCPM.ConstitMolalFract(5) * DataGenerators::FuelCell(Num).FCPM.NdotProdGas; - DataGenerators::FuelCell(Num).Report.NdotProdCO2 = DataGenerators::FuelCell(Num).FCPM.ConstitMolalFract(1) * DataGenerators::FuelCell(Num).FCPM.NdotProdGas; - DataGenerators::FuelCell(Num).Report.NdotProdH2O = DataGenerators::FuelCell(Num).FCPM.ConstitMolalFract(4) * DataGenerators::FuelCell(Num).FCPM.NdotProdGas; - DataGenerators::FuelCell(Num).Report.NdotProdN2 = DataGenerators::FuelCell(Num).FCPM.ConstitMolalFract(2) * DataGenerators::FuelCell(Num).FCPM.NdotProdGas; - DataGenerators::FuelCell(Num).Report.NdotProdO2 = DataGenerators::FuelCell(Num).FCPM.ConstitMolalFract(3) * DataGenerators::FuelCell(Num).FCPM.NdotProdGas; - - DataGenerators::FuelCell(Num).Report.qHX = DataGenerators::FuelCell(Num).ExhaustHX.qHX; - DataGenerators::FuelCell(Num).Report.HXenergy = DataGenerators::FuelCell(Num).ExhaustHX.qHX * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - DataGenerators::FuelCell(Num).Report.THXexh = DataGenerators::FuelCell(Num).ExhaustHX.THXexh; - DataGenerators::FuelCell(Num).Report.WaterVaporFractExh = DataGenerators::FuelCell(Num).ExhaustHX.WaterVaporFractExh; - DataGenerators::FuelCell(Num).Report.CondensateRate = DataGenerators::FuelCell(Num).ExhaustHX.CondensateRate; - - DataGenerators::FuelCell(Num).Report.SeqSubstIterations = DataGenerators::FuelCell(Num).FCPM.SeqSubstitIter; // number of iterations in DataGenerators::FuelCell loop - DataGenerators::FuelCell(Num).Report.RegulaFalsiIterations = DataGenerators::FuelCell(Num).FCPM.RegulaFalsiIter; // number of iterations in Tproduct gas solving - - DataGenerators::FuelCell(Num).Report.ACancillariesPower = DataGenerators::FuelCell(Num).FCPM.PelancillariesAC; - DataGenerators::FuelCell(Num).Report.ACancillariesEnergy = DataGenerators::FuelCell(Num).FCPM.PelancillariesAC * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - - DataGenerators::FuelCell(Num).Report.PCUlosses = DataGenerators::FuelCell(Num).Inverter.PCUlosses; // inverter losses - DataGenerators::FuelCell(Num).Report.DCPowerGen = DataGenerators::FuelCell(Num).FCPM.Pel; // DC power out of FCPM. - DataGenerators::FuelCell(Num).Report.DCPowerEff = DataGenerators::FuelCell(Num).FCPM.Eel; // FCPM efficienty Eel. - DataGenerators::FuelCell(Num).Report.ElectEnergyinStorage = DataGenerators::FuelCell(Num).ElecStorage.ThisTimeStepStateOfCharge; - DataGenerators::FuelCell(Num).Report.StoredPower = DataGenerators::FuelCell(Num).ElecStorage.PelIntoStorage; - DataGenerators::FuelCell(Num).Report.StoredEnergy = DataGenerators::FuelCell(Num).ElecStorage.PelIntoStorage * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - DataGenerators::FuelCell(Num).Report.DrawnPower = DataGenerators::FuelCell(Num).ElecStorage.PelFromStorage; - DataGenerators::FuelCell(Num).Report.DrawnEnergy = DataGenerators::FuelCell(Num).ElecStorage.PelFromStorage * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - - DataGenerators::FuelCell(Num).Report.SkinLossPower = DataGenerators::FuelCell(Num).QconvZone + DataGenerators::FuelCell(Num).QradZone; - DataGenerators::FuelCell(Num).Report.SkinLossEnergy = (DataGenerators::FuelCell(Num).QconvZone + DataGenerators::FuelCell(Num).QradZone) * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - DataGenerators::FuelCell(Num).Report.SkinLossConvect = DataGenerators::FuelCell(Num).QconvZone; - DataGenerators::FuelCell(Num).Report.SkinLossRadiat = DataGenerators::FuelCell(Num).QradZone; + FuelCell(Num).Report.FuelEnergyUseRateLHV = + FuelCell(Num).FCPM.NdotFuel * DataGenerators::FuelSupply(FuelCell(Num).FuelSupNum).LHV * 1000000.0; // reporting: Fuel Energy used (W) + FuelCell(Num).Report.FuelEnergyHHV = FuelCell(Num).FCPM.NdotFuel * DataGenerators::FuelSupply(FuelCell(Num).FuelSupNum).HHV * + DataGenerators::FuelSupply(FuelCell(Num).FuelSupNum).KmolPerSecToKgPerSec * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + + FuelCell(Num).Report.FuelEnergyUseRateHHV = + FuelCell(Num).FCPM.NdotFuel * DataGenerators::FuelSupply(FuelCell(Num).FuelSupNum).HHV * DataGenerators::FuelSupply(FuelCell(Num).FuelSupNum).KmolPerSecToKgPerSec; + + FuelCell(Num).Report.FuelRateMdot = 0.0; // (Kg/s) + + FuelCell(Num).Report.TwaterInlet = FuelCell(Num).WaterSup.TwaterIntoCompress; + FuelCell(Num).Report.TwaterIntoFCPM = FuelCell(Num).WaterSup.TwaterIntoFCPM; + FuelCell(Num).Report.NdotWater = FuelCell(Num).FCPM.NdotLiqwater; // water flow in kmol/sec (reformer water) + FuelCell(Num).Report.WaterPumpPower = FuelCell(Num).WaterSup.PwaterCompEl; + FuelCell(Num).Report.WaterPumpEnergy = FuelCell(Num).WaterSup.PwaterCompEl * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; // electrical energy + FuelCell(Num).Report.WaterIntoFCPMEnthalpy = FuelCell(Num).FCPM.WaterInEnthalpy; + + FuelCell(Num).Report.TprodGas = FuelCell(Num).FCPM.TprodGasLeavingFCPM; // temperature at State point 7 + FuelCell(Num).Report.EnthalProdGas = FuelCell(Num).FCPM.TotProdGasEnthalphy; // enthalpy at State point 7 + FuelCell(Num).Report.NdotProdGas = FuelCell(Num).FCPM.NdotProdGas; // flow rate at point 7 [kmol/sec] + FuelCell(Num).Report.NdotProdAr = FuelCell(Num).FCPM.ConstitMolalFract(5) * FuelCell(Num).FCPM.NdotProdGas; + FuelCell(Num).Report.NdotProdCO2 = FuelCell(Num).FCPM.ConstitMolalFract(1) * FuelCell(Num).FCPM.NdotProdGas; + FuelCell(Num).Report.NdotProdH2O = FuelCell(Num).FCPM.ConstitMolalFract(4) * FuelCell(Num).FCPM.NdotProdGas; + FuelCell(Num).Report.NdotProdN2 = FuelCell(Num).FCPM.ConstitMolalFract(2) * FuelCell(Num).FCPM.NdotProdGas; + FuelCell(Num).Report.NdotProdO2 = FuelCell(Num).FCPM.ConstitMolalFract(3) * FuelCell(Num).FCPM.NdotProdGas; + + FuelCell(Num).Report.qHX = FuelCell(Num).ExhaustHX.qHX; + FuelCell(Num).Report.HXenergy = FuelCell(Num).ExhaustHX.qHX * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + FuelCell(Num).Report.THXexh = FuelCell(Num).ExhaustHX.THXexh; + FuelCell(Num).Report.WaterVaporFractExh = FuelCell(Num).ExhaustHX.WaterVaporFractExh; + FuelCell(Num).Report.CondensateRate = FuelCell(Num).ExhaustHX.CondensateRate; + + FuelCell(Num).Report.SeqSubstIterations = FuelCell(Num).FCPM.SeqSubstitIter; // number of iterations in FuelCell loop + FuelCell(Num).Report.RegulaFalsiIterations = FuelCell(Num).FCPM.RegulaFalsiIter; // number of iterations in Tproduct gas solving + + FuelCell(Num).Report.ACancillariesPower = FuelCell(Num).FCPM.PelancillariesAC; + FuelCell(Num).Report.ACancillariesEnergy = FuelCell(Num).FCPM.PelancillariesAC * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + + FuelCell(Num).Report.PCUlosses = FuelCell(Num).Inverter.PCUlosses; // inverter losses + FuelCell(Num).Report.DCPowerGen = FuelCell(Num).FCPM.Pel; // DC power out of FCPM. + FuelCell(Num).Report.DCPowerEff = FuelCell(Num).FCPM.Eel; // FCPM efficienty Eel. + FuelCell(Num).Report.ElectEnergyinStorage = FuelCell(Num).ElecStorage.ThisTimeStepStateOfCharge; + FuelCell(Num).Report.StoredPower = FuelCell(Num).ElecStorage.PelIntoStorage; + FuelCell(Num).Report.StoredEnergy = FuelCell(Num).ElecStorage.PelIntoStorage * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + FuelCell(Num).Report.DrawnPower = FuelCell(Num).ElecStorage.PelFromStorage; + FuelCell(Num).Report.DrawnEnergy = FuelCell(Num).ElecStorage.PelFromStorage * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + + FuelCell(Num).Report.SkinLossPower = FuelCell(Num).QconvZone + FuelCell(Num).QradZone; + FuelCell(Num).Report.SkinLossEnergy = (FuelCell(Num).QconvZone + FuelCell(Num).QradZone) * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + FuelCell(Num).Report.SkinLossConvect = FuelCell(Num).QconvZone; + FuelCell(Num).Report.SkinLossRadiat = FuelCell(Num).QradZone; } void GetFuelCellGeneratorResults(int const EP_UNUSED(GeneratorType), // type of Generator @@ -3593,10 +3593,10 @@ namespace FuelCellElectricGenerator { // PURPOSE OF THIS SUBROUTINE: // provide a get method to collect results at the load center level - GeneratorPower = DataGenerators::FuelCell(GeneratorIndex).Report.ACPowerGen; - GeneratorEnergy = DataGenerators::FuelCell(GeneratorIndex).Report.ACEnergyGen; - ThermalPower = DataGenerators::FuelCell(GeneratorIndex).Report.qHX; - ThermalEnergy = DataGenerators::FuelCell(GeneratorIndex).Report.HXenergy; + GeneratorPower = FuelCell(GeneratorIndex).Report.ACPowerGen; + GeneratorEnergy = FuelCell(GeneratorIndex).Report.ACEnergyGen; + ThermalPower = FuelCell(GeneratorIndex).Report.qHX; + ThermalEnergy = FuelCell(GeneratorIndex).Report.HXenergy; } } // namespace FuelCellElectricGenerator diff --git a/src/EnergyPlus/FuelCellElectricGenerator.hh b/src/EnergyPlus/FuelCellElectricGenerator.hh index 283d52bc348..6d0c2a905da 100644 --- a/src/EnergyPlus/FuelCellElectricGenerator.hh +++ b/src/EnergyPlus/FuelCellElectricGenerator.hh @@ -58,9 +58,501 @@ namespace EnergyPlus { namespace FuelCellElectricGenerator { - extern bool GetFuelCellInput; - extern int NumFuelCellGenerators; - extern Array1D_bool CheckEquipName; + struct FCPowerModuleStruct + { + // Members + // user input data + std::string Name; // name of this PowerModule data + int EffMode; // mode for efficiency curves + int EffCurveID; // pointer to curve for efficiency + Real64 NomEff; // nominal efficiency + Real64 NomPel; // nominal power rate at rating point + int NumCycles; // number of start stop cycles + Real64 CyclingDegradRat; // rate of degradation from cycles + Real64 NumRunHours; // number of hours of operation + Real64 OperateDegradRat; // rate of degradation from run time (per hour) + Real64 ThreshRunHours; // number of hours before degradation starts + Real64 UpTranLimit; // power up transient limit + Real64 DownTranLimit; // power down tran limit + Real64 StartUpTime; // time for start up [hours] + Real64 StartUpFuel; // fuel use during start up + Real64 StartUpElectConsum; // electricity used during start up + Real64 StartUpElectProd; // electricity produced during start up + Real64 ShutDownTime; // time to shut down [hours] + Real64 ShutDownFuel; // fuel consumed during shut down + Real64 ShutDownElectConsum; // Elect consumed during shut down + Real64 ANC0; // Ancilliary Loads constant term + Real64 ANC1; // Ancilliary Loads linear term + int SkinLossMode; // how are skin losses determined + std::string ZoneName; + int ZoneID; // "pointer" to zone with component in it + Real64 RadiativeFract; + Real64 QdotSkin; + Real64 UAskin; + int SkinLossCurveID; + int WaterSupplyCurveID; // pointer to curve for water use in reforming + Real64 NdotDilutionAir; // user defined constant flow of dilution air (kmol/sec) + Real64 StackHeatLossToDilution; // (watts) + std::string DilutionInletNodeName; // dilution -> AirHR ?? added air heat recovery path + int DilutionInletNode; // pointer to node for inlet + std::string DilutionExhaustNodeName; + int DilutionExhaustNode; // pointer to node getting exhaust + Real64 PelMin; // minimum operating point for FCPM electrical power Pel + Real64 PelMax; // maximum operating point for FCPM electrical power Pel + // Calculated values and input from elsewhere + Real64 Pel; // current DC electrical power produced + Real64 PelLastTimeStep; + Real64 Eel; // power module efficiency + Real64 QdotStackCool; // Heat removed by stack cooler + Real64 FractionalDayofLastStartUp; // fractional days into simulation + Real64 FractionalDayofLastShutDown; // fractional Days into simulations + bool HasBeenOn; + bool DuringShutDown; + bool DuringStartUp; + Real64 NdotFuel; // molar fuel use rate. (kmol/sec) + Real64 TotFuelInEnthalphy; // Enthalpy of fuel coming into FCPM (watts) + Real64 NdotProdGas; // (kmol/sec) + Array1D ConstitMolalFract; + Array1D_int GasLibID; // lookup ID in Gas Phase ThermoChemistry Structure Array + Real64 TprodGasLeavingFCPM; + Real64 NdotAir; // molar air use rate (kmol/sec) + Real64 TotAirInEnthalphy; // Enthalpy of air coming nto FCPM energy balance (watts) + Real64 NdotLiqwater; // molar water use rate (kmol/sec) + Real64 TwaterInlet; + Real64 WaterInEnthalpy; // Enthalpy of liquid water used for reforming (watts) + Real64 DilutionAirInEnthalpy; // Enthalpy of Dilution air coming into FCPM (watts) + Real64 DilutionAirOutEnthalpy; + Real64 PelancillariesAC; // ancillary power (watts) + Real64 TotProdGasEnthalphy; // Enthalphy of product gases leaving FCPM (watts) + Real64 WaterOutEnthalpy; // enthalpy of vapor from water used for reforming + int SeqSubstitIter; + int RegulaFalsiIter; + + // Default Constructor + FCPowerModuleStruct() + : EffMode(0), EffCurveID(0), NomEff(0.0), NomPel(0.0), NumCycles(0), CyclingDegradRat(0.0), NumRunHours(0.0), OperateDegradRat(0.0), + ThreshRunHours(0.0), UpTranLimit(0.0), DownTranLimit(0.0), StartUpTime(0.0), StartUpFuel(0.0), StartUpElectConsum(0.0), + StartUpElectProd(0.0), ShutDownTime(0.0), ShutDownFuel(0.0), ShutDownElectConsum(0.0), ANC0(0.0), ANC1(0.0), SkinLossMode(0), ZoneID(0), + RadiativeFract(0.0), QdotSkin(0.0), UAskin(0.0), SkinLossCurveID(0), WaterSupplyCurveID(0), NdotDilutionAir(0.0), + StackHeatLossToDilution(0.0), DilutionInletNode(0), DilutionExhaustNode(0), PelMin(0.0), PelMax(0.0), Pel(0.0), PelLastTimeStep(0.0), + Eel(0.0), QdotStackCool(0.0), FractionalDayofLastStartUp(0.0), FractionalDayofLastShutDown(0.0), HasBeenOn(true), DuringShutDown(false), + DuringStartUp(false), NdotFuel(0.0), TotFuelInEnthalphy(0.0), NdotProdGas(0.0), ConstitMolalFract(14, 0.0), GasLibID(14, 0), + TprodGasLeavingFCPM(0.0), NdotAir(0.0), TotAirInEnthalphy(0.0), NdotLiqwater(0.0), TwaterInlet(0.0), WaterInEnthalpy(0.0), + DilutionAirInEnthalpy(0.0), DilutionAirOutEnthalpy(0.0), PelancillariesAC(0.0), TotProdGasEnthalphy(0.0), WaterOutEnthalpy(0.0), + SeqSubstitIter(0), RegulaFalsiIter(0) + { + } + }; + + struct FCAirSupplyDataStruct + { + // Members + // user input data + std::string Name; // name of this + std::string NodeName; // Air supply node name + int SupNodeNum; // Air supply node ID + int BlowerPowerCurveID; // "pointer" to blower power quadratic + Real64 BlowerHeatLossFactor; // alpha for blower heat loss fraction + int AirSupRateMode; // control for modeling method used to deterime supply air flow rate + Real64 Stoics; // excess air ratio + int AirFuncPelCurveID; // "pointer" to curve for air as function of power + Real64 AirTempCoeff; // coeff a3 in equ 16. + int AirFuncNdotCurveID; // "pointer" to curve for air as function of fuel flow rate + int IntakeRecoveryMode; + int ConstituentMode; // how are air data input + int NumConstituents; + Array1D_string ConstitName; + Array1D ConstitMolalFract; + // Calculated values and input from elsewhere + Array1D_int GasLibID; // lookup ID in Gas Phase ThermoChemistry Structure Array + Real64 O2fraction; + Real64 TairIntoBlower; // temperature entering blower + Real64 TairIntoFCPM; // temperature leaving blower and entering FCPM + Real64 PairCompEl; // power drawn by compressor + Real64 QskinLoss; // pumping losses for zone + Real64 QintakeRecovery; // heat recovered on intake air by accessories + + // Default Constructor + FCAirSupplyDataStruct() + : SupNodeNum(0), BlowerPowerCurveID(0), BlowerHeatLossFactor(0.0), AirSupRateMode(0), Stoics(0.0), AirFuncPelCurveID(0), + AirTempCoeff(0.0), AirFuncNdotCurveID(0), IntakeRecoveryMode(0), ConstituentMode(0), NumConstituents(0), ConstitName(14), + ConstitMolalFract(14, 0.0), GasLibID(14, 0), O2fraction(0.0), TairIntoBlower(0.0), TairIntoFCPM(0.0), PairCompEl(0.0), QskinLoss(0.0), + QintakeRecovery(0.0) + { + } + }; + + struct FCWaterSupplyDataStruct + { + // Members + std::string Name; // name of this water supply module + int WaterTempMode; // temperature of water inlet determination + std::string NodeName; // node name for temperature at input + int NodeNum; // node number for temperature at input + int SchedNum; // water temperature at input + int WaterSupRateCurveID; // "pointer" to water flow rate curve as a function of fuel rate + int PmpPowerCurveID; // "pointer to Pump power curve as a function of water flow Rate + Real64 PmpPowerLossFactor; // Pump heat loss factor + // calculated data + bool IsModeled; + Real64 TwaterIntoCompress; // inlet Water Temperature + Real64 TwaterIntoFCPM; // pumped water temp + Real64 PwaterCompEl; // water pump power + Real64 QskinLoss; // pumping losses for zone + + // Default Constructor + FCWaterSupplyDataStruct() + : WaterTempMode(0), NodeNum(0), SchedNum(0), WaterSupRateCurveID(0), PmpPowerCurveID(0), PmpPowerLossFactor(0.0), IsModeled(true), + TwaterIntoCompress(0.0), TwaterIntoFCPM(0.0), PwaterCompEl(0.0), QskinLoss(0.0) + { + } + }; + + struct FCAuxilHeatDataStruct + { + // Members + std::string Name; // name of this auxiliary heating module + std::string ZoneName; + int ZoneID; + Real64 UASkin; // for skin losses to zone + Real64 ExcessAirRAT; + Real64 ANC0; + Real64 ANC1; + int SkinLossDestination; // control mode for where lost heat goes + Real64 MaxPowerW; + Real64 MinPowerW; + Real64 MaxPowerkmolperSec; + Real64 MinPowerkmolperSec; + // calculated and from elsewhere + int NumConstituents; + Real64 TauxMix; + Real64 NdotAuxMix; + Array1D ConstitMolalFract; + Array1D_int GasLibID; // lookup ID in Gas Phase ThermoChemistry Structure Array + Real64 QskinLoss; // Heat lost to room + Real64 QairIntake; // heat into intake air + + // Default Constructor + FCAuxilHeatDataStruct() + : ZoneID(0), UASkin(0.0), ExcessAirRAT(0.0), ANC0(0.0), ANC1(0.0), SkinLossDestination(0), MaxPowerW(0.0), MinPowerW(0.0), + MaxPowerkmolperSec(0.0), MinPowerkmolperSec(0.0), NumConstituents(0), TauxMix(0.0), NdotAuxMix(0.0), ConstitMolalFract(14, 0.0), + GasLibID(14, 0), QskinLoss(0.0), QairIntake(0.0) + { + } + }; + + struct FCExhaustHXDataStruct + { + // Members + // user defined variables + std::string Name; // name of this exhaust gas heat recovery + std::string WaterInNodeName; // HR Water Inlet Node + int WaterInNode; // HR Water Outlet Node ID + std::string WaterOutNodeName; // HR water outlet Node name + int WaterOutNode; // HR Water outlet Node ID + Real64 WaterVolumeFlowMax; // HR water flow rate max avail + std::string ExhaustOutNodeName; // air node for exhaust flow + int ExhaustOutNode; // Exhaust Air node ID + int HXmodelMode; // Heat Exchanger Calculation Method + Real64 HXEffect; // Heat Exchanger Effectiveness (method 1) + Real64 hxs0; // (method 2) + Real64 hxs1; // (method 2) + Real64 hxs2; // (method 2) + Real64 hxs3; // (method 2) + Real64 hxs4; // (method 2) + Real64 h0gas; // (method 3) + Real64 NdotGasRef; // (method 3) + Real64 nCoeff; // (method 3) + Real64 AreaGas; // (method 3) + Real64 h0Water; // (method 3) + Real64 NdotWaterRef; // (method 3) + Real64 mCoeff; // (method 3) + Real64 AreaWater; // (method 3) + Real64 Fadjust; // (method 3) + Real64 l1Coeff; // (method 4) + Real64 l2Coeff; // (method 4) + Real64 CondensationThresholdTemp; // (method 4) [degrees C] + // calculated + Real64 qHX; // heat flow from gas stream to water + Real64 THXexh; // temperature of exhaust gases leaving heat exchanger. + Real64 WaterMassFlowRateDesign; // Design level of water flow rate + Real64 WaterMassFlowRate; // water flow rate in plant loop + Real64 WaterInletTemp; + Real64 WaterVaporFractExh; // water vapor fraction in exhaust gas stream. + Real64 CondensateRate; // water condensation rate. + Array1D ConstitMolalFract; + Array1D_int GasLibID; // lookup ID in Gas Phase ThermoChemistry Structure Array + Real64 NdotHXleaving; + Real64 WaterOutletTemp; + Real64 WaterOutletEnthalpy; + + // Default Constructor + FCExhaustHXDataStruct() + : WaterInNode(0), WaterOutNode(0), WaterVolumeFlowMax(0.0), ExhaustOutNode(0), HXmodelMode(0), HXEffect(0.0), hxs0(0.0), hxs1(0.0), + hxs2(0.0), hxs3(0.0), hxs4(0.0), h0gas(0.0), NdotGasRef(0.0), nCoeff(0.0), AreaGas(0.0), h0Water(0.0), NdotWaterRef(0.0), mCoeff(0.0), + AreaWater(0.0), Fadjust(0.0), l1Coeff(0.0), l2Coeff(0.0), CondensationThresholdTemp(0.0), qHX(0.0), THXexh(0.0), + WaterMassFlowRateDesign(0.0), WaterMassFlowRate(0.0), WaterInletTemp(0.0), WaterVaporFractExh(0.0), CondensateRate(0.0), + ConstitMolalFract(14, 0.0), GasLibID(14, 0), NdotHXleaving(0.0), WaterOutletTemp(0.0), WaterOutletEnthalpy(0.0) + { + } + }; + + struct BatteryDichargeDataStruct + { + // Members + // user defined variables + std::string Name; // name of this battery data set + Real64 NumInSeries; + Real64 NumInParallel; + Real64 NominalVoltage; + Real64 LowVoltsDischarged; // not used + int NumTablePairs; + Array1D DischargeCurrent; // amps + Array1D DischargeTime; // hours + // calculated variables + Real64 k; // parameter in Manwell McGowan model + Real64 c; // parameter in Manwell McGowan model + Real64 qmax; // parameter in Manwell McGowan model + + // Default Constructor + BatteryDichargeDataStruct() + : NumInSeries(0.0), NumInParallel(0.0), NominalVoltage(0.0), LowVoltsDischarged(0.0), NumTablePairs(0), k(0.0), c(0.0), qmax(0.0) + { + } + }; + + struct FCElecStorageDataStruct + { + // Members + // user defined variables + std::string Name; // name of this electrical storage module + int StorageModelMode; + Real64 StartingEnergyStored; // joules inside + Real64 EnergeticEfficCharge; // for + Real64 EnergeticEfficDischarge; + Real64 MaxPowerDraw; // for simple bucket method 0 + Real64 MaxPowerStore; // for simple bucket method 0 + Real64 NominalVoltage; + Real64 NominalEnergyCapacity; // [J] + // calculated and from elsewhere vars + Real64 ThisTimeStepStateOfCharge; // [J] + Real64 LastTimeStepStateOfCharge; // [J] + Real64 PelNeedFromStorage; + Real64 IdesiredDischargeCurrent; + Real64 PelFromStorage; // power + Real64 IfromStorage; // current this timestepm + Real64 PelIntoStorage; + Real64 QairIntake; // heat into intake air + // nested structures + BatteryDichargeDataStruct Battery; + + // Default Constructor + FCElecStorageDataStruct() + : StorageModelMode(0), StartingEnergyStored(0.0), EnergeticEfficCharge(0.0), EnergeticEfficDischarge(0.0), MaxPowerDraw(0.0), + MaxPowerStore(0.0), NominalVoltage(0.0), NominalEnergyCapacity(0.0), ThisTimeStepStateOfCharge(0.0), LastTimeStepStateOfCharge(0.0), + PelNeedFromStorage(0.0), IdesiredDischargeCurrent(0.0), PelFromStorage(0.0), IfromStorage(0.0), PelIntoStorage(0.0), QairIntake(0.0) + { + } + }; + + struct FCInverterDataStruct + { + // Members + // user-defined data + std::string Name; // name of this inverter + int EffMode; // efficiency calculation mode + Real64 ConstEff; + int EffQuadraticCurveID; + // calculated and from elsewhere + Real64 PCUlosses; + Real64 QairIntake; + + // Default Constructor + FCInverterDataStruct() : EffMode(0), ConstEff(0.0), EffQuadraticCurveID(0), PCUlosses(0.0), QairIntake(0.0) + { + } + }; + + struct FCReportDataStruct + { + // Members + Real64 ACPowerGen; // reporting: power (W) + Real64 ACEnergyGen; // reporting: energy (J) + Real64 QdotExhaust; // reporting: exhaust gas heat recovered (W) + Real64 TotalHeatEnergyRec; // reporting: total heat recovered (J) + Real64 ExhaustEnergyRec; // reporting: exhaust gas heat recovered (J) + Real64 FuelEnergyLHV; // reporting: Fuel Energy used in Lower Heating Value(J) + Real64 FuelEnergyUseRateLHV; // reporting: Fuel Energy used in Lower Heating Value(W) + Real64 FuelEnergyHHV; // reporting: Fuel Energy used in Lower Heating Value(J) + Real64 FuelEnergyUseRateHHV; // reporting: Fuel Energy used in Lower Heating Value(W) + Real64 FuelRateMdot; // (Kg/s) + Real64 HeatRecInletTemp; // reporting: Heat Recovery Loop Inlet Temperature (C) + Real64 HeatRecOutletTemp; // reporting: Heat Recovery Loop Outlet Temperature (C) + Real64 HeatRecMdot; // reporting: Heat Recovery Loop Mass flow rate (kg/s) + // air supply and blower + Real64 TairInlet; // State point 1 + Real64 TairIntoFCPM; // Temperature at State point 4 + Real64 NdotAir; // air flow in kmol/sec + Real64 TotAirInEnthalphy; // Enthalpy at State point 4 + Real64 BlowerPower; // electrical power used by air supply blower + Real64 BlowerEnergy; // electrical energy used by air supply blower + Real64 BlowerSkinLoss; // heat rate of losses by blower + // fuel supply and compressor + Real64 TfuelInlet; // State point 2 [C] + Real64 TfuelIntoFCPM; // state point 5 [C] + Real64 NdotFuel; // fuel flow in [kmol/sec] + Real64 TotFuelInEnthalpy; // state point 5 [W] + Real64 FuelCompressPower; // electrical power used by fuel supply compressor [W] + Real64 FuelCompressEnergy; // electrical energy used by fuel supply compressor [J] + Real64 FuelCompressSkinLoss; // heat rate of losses.by fuel supply compressor [W] + // reformer water supply + Real64 TwaterInlet; // State point 3 + Real64 TwaterIntoFCPM; // State point 6 + Real64 NdotWater; // water flow in kmol/sec (reformer water) + Real64 WaterPumpPower; // electrical power used by water pump [W] + Real64 WaterPumpEnergy; // electrical energy used by water pump [J] + Real64 WaterIntoFCPMEnthalpy; // state point 6 + // product (exhaust) gas leaving power module + Real64 TprodGas; // State point 7 Product Gas temperature + Real64 EnthalProdGas; // state point 7 product gas enthalpy + Real64 NdotProdGas; // point 7 flow rate [kmol/sec] + Real64 NdotProdAr; // argon flow rate at point 7 + Real64 NdotProdCO2; // carbon dioxide flow rate at point 7 + Real64 NdotProdH2O; // water vapor flow rate at point 7 + Real64 NdotProdN2; // nitrogen flow rate at point 7 + Real64 NdotProdO2; // oxygen flow rate at point 7 + // heat exchanger for water to exhaust heat recovery + Real64 qHX; // heat flow from gas stream to water [W] + Real64 HXenergy; // energy from gas stream to water [J] + Real64 THXexh; // temperature of exhaust gases leaving heat exchanger. + Real64 WaterVaporFractExh; // water vapor fraction in exhaust gas stream + // relative to water vapor entering HX (NdotH20/Ndoaux-mix) + Real64 CondensateRate; // water condensation rate [kmol/s] + int SeqSubstIterations; // number of iterations in SOFC loop + int RegulaFalsiIterations; // number of iterations in Tproduct gas solving + Real64 ACancillariesPower; + Real64 ACancillariesEnergy; + Real64 PCUlosses; // power conditioning Unit losses + Real64 DCPowerGen; // Pel, Power module power level [W] + Real64 DCPowerEff; // Eel, power module efficiency [] + Real64 ElectEnergyinStorage; // State of charge in Electrical Storage [J] + Real64 StoredPower; // Power added to Electrical Storage [W] + Real64 StoredEnergy; // energy added to Electrical STorage [J] + Real64 DrawnPower; // Power drawn from Electrical STorage [W] + Real64 DrawnEnergy; // Energy drawn from Electrical STorage [J] + Real64 SkinLossPower; // heat loss to surrounding zone [W] + Real64 SkinLossEnergy; // heat loss to surround zone [J] + Real64 SkinLossConvect; // convective heat loss to zone [W] + Real64 SkinLossRadiat; // radiative heat loss to zone [W} + Real64 ElectEfficiency; + Real64 ThermalEfficiency; + Real64 OverallEfficiency; + Real64 ExergyEfficiency; + + // Default Constructor + FCReportDataStruct() + : ACPowerGen(0.0), ACEnergyGen(0.0), QdotExhaust(0.0), TotalHeatEnergyRec(0.0), ExhaustEnergyRec(0.0), FuelEnergyLHV(0.0), + FuelEnergyUseRateLHV(0.0), FuelEnergyHHV(0.0), FuelEnergyUseRateHHV(0.0), FuelRateMdot(0.0), HeatRecInletTemp(0.0), + HeatRecOutletTemp(0.0), HeatRecMdot(0.0), TairInlet(0.0), TairIntoFCPM(0.0), NdotAir(0.0), TotAirInEnthalphy(0.0), BlowerPower(0.0), + BlowerEnergy(0.0), BlowerSkinLoss(0.0), TfuelInlet(0.0), TfuelIntoFCPM(0.0), NdotFuel(0.0), TotFuelInEnthalpy(0.0), + FuelCompressPower(0.0), FuelCompressEnergy(0.0), FuelCompressSkinLoss(0.0), TwaterInlet(0.0), TwaterIntoFCPM(0.0), NdotWater(0.0), + WaterPumpPower(0.0), WaterPumpEnergy(0.0), WaterIntoFCPMEnthalpy(0.0), TprodGas(0.0), EnthalProdGas(0.0), NdotProdGas(0.0), + NdotProdAr(0.0), NdotProdCO2(0.0), NdotProdH2O(0.0), NdotProdN2(0.0), NdotProdO2(0.0), qHX(0.0), HXenergy(0.0), THXexh(0.0), + WaterVaporFractExh(0.0), CondensateRate(0.0), SeqSubstIterations(0), RegulaFalsiIterations(0), ACancillariesPower(0.0), + ACancillariesEnergy(0.0), PCUlosses(0.0), DCPowerGen(0.0), DCPowerEff(0.0), ElectEnergyinStorage(0.0), StoredPower(0.0), + StoredEnergy(0.0), DrawnPower(0.0), DrawnEnergy(0.0), SkinLossPower(0.0), SkinLossEnergy(0.0), SkinLossConvect(0.0), + SkinLossRadiat(0.0), ElectEfficiency(0.0), ThermalEfficiency(0.0), OverallEfficiency(0.0), ExergyEfficiency(0.0) + { + } + }; + + struct FCStackCoolerDataStruct + { + // Members + // user input data + std::string Name; // name of this stack cooler module + std::string WaterInNodeName; // HR Water Inlet Node + int WaterInNode; // HR Water Outlet Node ID + std::string WaterOutNodeName; // HR water outlet Node name + int WaterOutNode; // HR Water outlet Node ID + Real64 TstackNom; // nominal fuel cell stack temperature + Real64 TstackActual; // actual fuel cell stack temperature + Real64 r0; // stack cooling power coefficient r0 + Real64 r1; // stack cooling power coefficient r1 + Real64 r2; // stack cooling power coefficient r2 + Real64 r3; // stack cooling power coefficient r3 + Real64 MdotStackCoolant; // stack coolant flow rate kg/s + Real64 UAs_cool; // stack heat transfer coef + Real64 Fs_cogen; + Real64 As_cogen; + Real64 MdotCogenNom; + Real64 hCogenNom; + Real64 ns; + Real64 PstackPumpEl; + Real64 PmpPowerLossFactor; + Real64 f0; + Real64 f1; + Real64 f2; + // calculated and from elsewhere + bool StackCoolerPresent; // control modeling + Real64 qs_cool; + Real64 qs_air; + + // Default Constructor + FCStackCoolerDataStruct() + : WaterInNode(0), WaterOutNode(0), TstackNom(0.0), TstackActual(0.0), r0(0.0), r1(0.0), r2(0.0), r3(0.0), MdotStackCoolant(0.0), + UAs_cool(0.0), Fs_cogen(0.0), As_cogen(0.0), MdotCogenNom(0.0), hCogenNom(0.0), ns(0.0), PstackPumpEl(0.0), PmpPowerLossFactor(0.0), + f0(0.0), f1(0.0), f2(0.0), StackCoolerPresent(false), qs_cool(0.0), qs_air(0.0) + { + } + }; + + struct FCDataStruct + { + // Members + // from input data and nested types for subsystems + std::string Name; // user identifier + std::string NameFCPM; // name of FC Power Module + FCPowerModuleStruct FCPM; // data for Power Module + std::string NameFCAirSup; // name of air supply module for fuel cell + FCAirSupplyDataStruct AirSup; // data for air supply module + std::string NameFCFuelSup; // name of fuel supply module + int FuelSupNum; // index for fuel supply module structure + std::string NameFCWaterSup; // name of water supply module + FCWaterSupplyDataStruct WaterSup; // data for water supply module + std::string NameFCAuxilHeat; // name of auxiliary heating module + FCAuxilHeatDataStruct AuxilHeat; // data for auxiliary heating module + std::string NameExhaustHX; // name of Exhaust HX module + FCExhaustHXDataStruct ExhaustHX; // data for Exhaust heat exchanger module + std::string NameElecStorage; // name of Battery module + FCElecStorageDataStruct ElecStorage; // data for Battery module + std::string NameInverter; // name of Inverter Module + FCInverterDataStruct Inverter; // data for Inverter module + std::string NameStackCooler; // name of Inverter Module + FCStackCoolerDataStruct StackCooler; // data for Inverter module + int CWLoopNum; // cooling water plant loop index number + int CWLoopSideNum; // cooling water plant loop side index + int CWBranchNum; // cooling water plant loop branch index + int CWCompNum; // cooling water plant loop component index + FCReportDataStruct Report; // data for reporting as E+ output variables + // calculated whole-system level variables + Real64 ACPowerGen; // Net output from SOFC unit + Real64 QconvZone; // convective heat lost to surrounding zone + Real64 QradZone; // radiative heat lost to surrounding zone + int DynamicsControlID; + Real64 TimeElapsed; // used to track when timestep has changed + bool InitGenerator; + bool MyEnvrnFlag_Init; + bool MyWarmupFlag_Init; + bool MyPlantScanFlag_Init; + + // Default Constructor + FCDataStruct() + : FuelSupNum(0), CWLoopNum(0), CWLoopSideNum(0), CWBranchNum(0), CWCompNum(0), ACPowerGen(0.0), QconvZone(0.0), QradZone(0.0), + DynamicsControlID(0), TimeElapsed(0.0), InitGenerator(true), MyEnvrnFlag_Init(true), MyWarmupFlag_Init(false), MyPlantScanFlag_Init(true) + { + } + }; void clear_state(); @@ -186,6 +678,11 @@ namespace FuelCellElectricGenerator { Real64 &ThermalEnergy // heat energy ); + extern bool GetFuelCellInput; + extern int NumFuelCellGenerators; + extern Array1D_bool CheckEquipName; + extern Array1D FuelCell; // dimension to number of machines + } // namespace FuelCellElectricGenerator } // namespace EnergyPlus From 7e4b5150241cb31fc132902ebfc1ad48df53d13a Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Tue, 12 Nov 2019 10:33:21 -0700 Subject: [PATCH 29/51] partial functions to members --- src/EnergyPlus/FuelCellElectricGenerator.cc | 186 +++++++++----------- src/EnergyPlus/FuelCellElectricGenerator.hh | 68 +++---- 2 files changed, 105 insertions(+), 149 deletions(-) diff --git a/src/EnergyPlus/FuelCellElectricGenerator.cc b/src/EnergyPlus/FuelCellElectricGenerator.cc index 3c37ad7a9ab..e1ae6a3417c 100644 --- a/src/EnergyPlus/FuelCellElectricGenerator.cc +++ b/src/EnergyPlus/FuelCellElectricGenerator.cc @@ -1391,15 +1391,15 @@ namespace FuelCellElectricGenerator { // BEGIN SEQUENTIAL SUBSTITUTION to handle a lot of inter-related calcs for (iter = 1; iter <= 20; ++iter) { if (iter > 1) { - FigurePowerConditioningLosses(GeneratorNum, PoutofInverter, PpcuLosses); - FigureACAncillaries(GeneratorNum, PacAncillariesTotal); + FuelCell(GeneratorNum).FigurePowerConditioningLosses(PoutofInverter, PpcuLosses); + FuelCell(GeneratorNum).FigureACAncillaries(PacAncillariesTotal); Pdemand = MyLoad + PacAncillariesTotal + PpcuLosses; } else { // control Step 1a: Figure ancillary AC power draws - FigureACAncillaries(GeneratorNum, PacAncillariesTotal); + FuelCell(GeneratorNum).FigureACAncillaries(PacAncillariesTotal); Pdemand = MyLoad + PacAncillariesTotal; // Control Step 1b: Calculate losses associated with Power conditioning - FigurePowerConditioningLosses(GeneratorNum, Pdemand, PpcuLosses); + FuelCell(GeneratorNum).FigurePowerConditioningLosses(Pdemand, PpcuLosses); Pdemand += PpcuLosses; Pel = Pdemand; } @@ -1410,7 +1410,7 @@ namespace FuelCellElectricGenerator { Real64 PelDiff; bool ConstrainedFCPMTrans = false; - FigureTransientConstraints(GeneratorNum, Pel, ConstrainedFCPMTrans, PelDiff); + FuelCell(GeneratorNum).FigureTransientConstraints(Pel, ConstrainedFCPMTrans, PelDiff); // Control step 3: adjust for max and min limits on Pel @@ -1508,7 +1508,7 @@ namespace FuelCellElectricGenerator { // evaluate heat capacity at average temperature using shomate Real64 Cp; // temp Heat Capacity, used in thermochemistry units of (J/mol K) Real64 Tavg = (DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).TfuelIntoCompress + DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).TfuelIntoFCPM) / 2.0; - FigureFuelHeatCap(GeneratorNum, Tavg, Cp); // Cp in (J/mol K) + FuelCell(GeneratorNum).FigureFuelHeatCap(Tavg, Cp); // Cp in (J/mol K) // calculate a Temp of fuel out of compressor and into power module @@ -1533,7 +1533,7 @@ namespace FuelCellElectricGenerator { // (Hmolfuel in KJ/mol) Real64 Hmolfuel; // temp enthalpy of fuel mixture in KJ/mol - FigureFuelEnthalpy(GeneratorNum, DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).TfuelIntoFCPM, Hmolfuel); + FuelCell(GeneratorNum).FigureFuelEnthalpy(DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).TfuelIntoFCPM, Hmolfuel); // units, NdotFuel in kmol/sec. Hmolfule in KJ/mol , // factor of 1000's to get to J/s or watts @@ -1604,7 +1604,7 @@ namespace FuelCellElectricGenerator { Tavg = (FuelCell(GeneratorNum).AirSup.TairIntoBlower + FuelCell(GeneratorNum).AirSup.TairIntoFCPM) / 2.0; - FigureAirHeatCap(GeneratorNum, Tavg, Cp); // Cp in (J/mol K) + FuelCell(GeneratorNum).FigureAirHeatCap(Tavg, Cp); // Cp in (J/mol K) // if PEMFC with stack cooler, then calculate stack cooler impacts if (FuelCell(GeneratorNum).StackCooler.StackCoolerPresent) { @@ -1661,7 +1661,7 @@ namespace FuelCellElectricGenerator { } Real64 Hmolair; // temp enthalpy of air mixture in KJ/mol - FigureAirEnthalpy(GeneratorNum, FuelCell(GeneratorNum).AirSup.TairIntoFCPM, Hmolair); // (Hmolair in KJ/mol) + FuelCell(GeneratorNum).FigureAirEnthalpy(FuelCell(GeneratorNum).AirSup.TairIntoFCPM, Hmolair); // (Hmolair in KJ/mol) // units, NdotAir in kmol/sec.; Hmolfuel in KJ/mol , // factor of 1000's to get to J/s or watts @@ -1754,7 +1754,7 @@ namespace FuelCellElectricGenerator { // HmolProdGases KJ/mol) Real64 HmolProdGases; // enthalpy of product gas mixture in KJ/mol - FigureProductGasesEnthalpy(GeneratorNum, FuelCell(GeneratorNum).FCPM.TprodGasLeavingFCPM, HmolProdGases); + FuelCell(GeneratorNum).FigureProductGasesEnthalpy(FuelCell(GeneratorNum).FCPM.TprodGasLeavingFCPM, HmolProdGases); // units, NdotProdGas in kmol/sec.; HmolProdGases in KJ/mol , // factor of 1000's to get to J/s or watts @@ -1784,7 +1784,7 @@ namespace FuelCellElectricGenerator { FuelCell(GeneratorNum).FCPM.ANC0 + FuelCell(GeneratorNum).FCPM.ANC1 * FuelCell(GeneratorNum).FCPM.NdotFuel; // calculation Step 11, Dilution air - FigureAirEnthalpy(GeneratorNum, FuelCell(GeneratorNum).AirSup.TairIntoBlower, Hmolair); // (Hmolair in KJ/mol) + FuelCell(GeneratorNum).FigureAirEnthalpy(FuelCell(GeneratorNum).AirSup.TairIntoBlower, Hmolair); // (Hmolair in KJ/mol) // units, NdotDilutionAir in kmol/sec.; Hmolair in KJ/mol , // factor of 1000's to get to J/s or watts @@ -2067,17 +2067,14 @@ namespace FuelCellElectricGenerator { Real64 desiredHprodGases = Par(2); Real64 NdotProdGases = Par(3); - FigureProductGasesEnthalpy(GeneratorNum, TprodGas, thisHmolalProdGases); + FuelCell(GeneratorNum).FigureProductGasesEnthalpy(TprodGas, thisHmolalProdGases); Residuum = (thisHmolalProdGases * NdotProdGases * 1000000.0) - desiredHprodGases; return Residuum; } - void FigureAirHeatCap(int const GeneratorNum, // ID of generator FuelCell data structure - Real64 const FluidTemp, // degree C - Real64 &Cp // (J/mol*K) - ) + void FCDataStruct::FigureAirHeatCap(Real64 const FluidTemp, Real64 &Cp) { // SUBROUTINE INFORMATION: @@ -2122,8 +2119,8 @@ namespace FuelCellElectricGenerator { Real64 const pow_3_Tkel(pow_3(Tkel)); Real64 const pow_4_Tkel(pow_4(Tkel)); - for (int thisConstit = 1; thisConstit <= FuelCell(GeneratorNum).AirSup.NumConstituents; ++thisConstit) { - int gasID = FuelCell(GeneratorNum).AirSup.GasLibID(thisConstit); + for (int thisConstit = 1; thisConstit <= this->AirSup.NumConstituents; ++thisConstit) { + int gasID = this->AirSup.GasLibID(thisConstit); if (gasID > 0) { if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == DataGenerators::NISTShomate) { @@ -2134,7 +2131,7 @@ namespace FuelCellElectricGenerator { E = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateE; tempCp += ((A + B * Tsho + C * pow_2_Tsho + D * pow_3_Tsho + E / pow_2_Tsho) * - FuelCell(GeneratorNum).AirSup.ConstitMolalFract(thisConstit)); + this->AirSup.ConstitMolalFract(thisConstit)); } if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == DataGenerators::NASAPolynomial) { @@ -2146,7 +2143,7 @@ namespace FuelCellElectricGenerator { A5 = DataGenerators::GasPhaseThermoChemistryData(gasID).NASA_A5; tempCp += (A1 + A2 * Tkel + A3 * pow_2_Tkel + A4 * pow_3_Tkel + A5 * pow_4_Tkel) * DataGenerators::RinKJperMolpK * - FuelCell(GeneratorNum).AirSup.ConstitMolalFract(thisConstit); + this->AirSup.ConstitMolalFract(thisConstit); } } } @@ -2154,10 +2151,7 @@ namespace FuelCellElectricGenerator { Cp = tempCp; } - void FigureAirEnthalpy(int const GeneratorNum, // ID of generator FuelCell data structure - Real64 const FluidTemp, // degree C - Real64 &Hair // (kJ/mol) - ) + void FCDataStruct::FigureAirEnthalpy(Real64 const FluidTemp, Real64 &Hair) { // SUBROUTINE INFORMATION: @@ -2204,8 +2198,8 @@ namespace FuelCellElectricGenerator { Real64 const pow_3_Tkel(pow_3(Tkel)); Real64 const pow_4_Tkel(pow_4(Tkel)); - for (int thisConstit = 1; thisConstit <= FuelCell(GeneratorNum).AirSup.NumConstituents; ++thisConstit) { - int gasID = FuelCell(GeneratorNum).AirSup.GasLibID(thisConstit); + for (int thisConstit = 1; thisConstit <= this->AirSup.NumConstituents; ++thisConstit) { + int gasID = this->AirSup.GasLibID(thisConstit); if (gasID > 0) { if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == DataGenerators::NISTShomate) { @@ -2219,7 +2213,7 @@ namespace FuelCellElectricGenerator { Real64 HairI = (A * Tsho + B * pow_2_Tsho / 2.0 + C * pow_3_Tsho / 3.0 + D * pow_4_Tsho / 4.0 - E / Tsho + F - H); - tempHair += HairI * FuelCell(GeneratorNum).AirSup.ConstitMolalFract(thisConstit); + tempHair += HairI * this->AirSup.ConstitMolalFract(thisConstit); } if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == DataGenerators::NASAPolynomial) { A1 = DataGenerators::GasPhaseThermoChemistryData(gasID).NASA_A1; @@ -2232,7 +2226,7 @@ namespace FuelCellElectricGenerator { tempHair += (((A1 + A2 * Tkel / 2.0 + A3 * pow_2_Tkel / 3.0 + A4 * pow_3_Tkel / 4.0 + A5 * pow_4_Tkel / 5.0 + A6 / Tkel) * DataGenerators::RinKJperMolpK * Tkel) - DataGenerators::GasPhaseThermoChemistryData(gasID).StdRefMolarEnthOfForm) * - FuelCell(GeneratorNum).AirSup.ConstitMolalFract(thisConstit); + this->AirSup.ConstitMolalFract(thisConstit); } } } @@ -2240,10 +2234,7 @@ namespace FuelCellElectricGenerator { Hair = tempHair; } - void FigureFuelHeatCap(int const GeneratorNum, // ID of generator FuelCell data structure - Real64 const FluidTemp, // degree C - Real64 &Cp // (J/mol*K) - ) + void FCDataStruct::FigureFuelHeatCap(Real64 const FluidTemp, Real64 &Cp) { // SUBROUTINE INFORMATION: @@ -2286,8 +2277,8 @@ namespace FuelCellElectricGenerator { Real64 const pow_3_Tkel(pow_3(Tkel)); Real64 const pow_4_Tkel(pow_4(Tkel)); - for (int thisConstit = 1; thisConstit <= DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).NumConstituents; ++thisConstit) { - int gasID = DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).GasLibID(thisConstit); + for (int thisConstit = 1; thisConstit <= DataGenerators::FuelSupply(this->FuelSupNum).NumConstituents; ++thisConstit) { + int gasID = DataGenerators::FuelSupply(this->FuelSupNum).GasLibID(thisConstit); if (gasID > 0) { if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == DataGenerators::NISTShomate) { @@ -2298,7 +2289,7 @@ namespace FuelCellElectricGenerator { E = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateE; tempCp += ((A + B * Tsho + C * pow_2_Tsho + D * pow_3_Tsho + E / pow_2_Tsho) * - DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).ConstitMolalFract(thisConstit)); + DataGenerators::FuelSupply(this->FuelSupNum).ConstitMolalFract(thisConstit)); } if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == DataGenerators::NASAPolynomial) { @@ -2309,7 +2300,7 @@ namespace FuelCellElectricGenerator { A5 = DataGenerators::GasPhaseThermoChemistryData(gasID).NASA_A5; tempCp += (A1 + A2 * Tkel + A3 * pow_2_Tkel + A4 * pow_3_Tkel + A5 * pow_4_Tkel) * DataGenerators::RinKJperMolpK * - DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).ConstitMolalFract(thisConstit); + DataGenerators::FuelSupply(this->FuelSupNum).ConstitMolalFract(thisConstit); } } } @@ -2317,10 +2308,7 @@ namespace FuelCellElectricGenerator { Cp = tempCp; } - void FigureFuelEnthalpy(int const GeneratorNum, // ID of generator FuelCell data structure - Real64 const FluidTemp, // degree C - Real64 &Hfuel // kJ/mol - ) + void FCDataStruct::FigureFuelEnthalpy(Real64 const FluidTemp, Real64 &Hfuel) { // SUBROUTINE INFORMATION: @@ -2367,8 +2355,8 @@ namespace FuelCellElectricGenerator { Real64 const pow_3_Tkel(pow_3(Tkel)); Real64 const pow_4_Tkel(pow_4(Tkel)); - for (int thisConstit = 1; thisConstit <= DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).NumConstituents; ++thisConstit) { - int gasID = DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).GasLibID(thisConstit); + for (int thisConstit = 1; thisConstit <= DataGenerators::FuelSupply(this->FuelSupNum).NumConstituents; ++thisConstit) { + int gasID = DataGenerators::FuelSupply(this->FuelSupNum).GasLibID(thisConstit); if (gasID > 0) { if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == DataGenerators::NISTShomate) { A = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateA; @@ -2381,7 +2369,7 @@ namespace FuelCellElectricGenerator { Real64 HfuelI = (A * Tsho + B * pow_2_Tsho / 2.0 + C * pow_3_Tsho / 3.0 + D * pow_4_Tsho / 4.0 - E / Tsho + F - H); - tempHfuel += HfuelI * DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).ConstitMolalFract(thisConstit); + tempHfuel += HfuelI * DataGenerators::FuelSupply(this->FuelSupNum).ConstitMolalFract(thisConstit); } if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == DataGenerators::NASAPolynomial) { @@ -2395,7 +2383,7 @@ namespace FuelCellElectricGenerator { tempHfuel += (((A1 + A2 * Tkel / 2.0 + A3 * pow_2_Tkel / 3.0 + A4 * pow_3_Tkel / 4.0 + A5 * pow_4_Tkel / 5.0 + A6 / Tkel) * DataGenerators::RinKJperMolpK * Tkel) - DataGenerators::GasPhaseThermoChemistryData(gasID).StdRefMolarEnthOfForm) * - DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).ConstitMolalFract(thisConstit); + DataGenerators::FuelSupply(this->FuelSupNum).ConstitMolalFract(thisConstit); } } } @@ -2403,10 +2391,7 @@ namespace FuelCellElectricGenerator { Hfuel = tempHfuel; } - void FigureProductGasesEnthalpy(int const GeneratorNum, // ID of generator FuelCell data structure - Real64 const FluidTemp, // degree C - Real64 &HProdGases // kJ/mol - ) + void FCDataStruct::FigureProductGasesEnthalpy(Real64 const FluidTemp, Real64 &HProdGases) { // SUBROUTINE INFORMATION: @@ -2454,7 +2439,7 @@ namespace FuelCellElectricGenerator { Real64 const pow_4_Tkel(pow_4(Tkel)); for (int thisConstit = 1; thisConstit <= 5; ++thisConstit) { - int gasID = FuelCell(GeneratorNum).FCPM.GasLibID(thisConstit); + int gasID = this->FCPM.GasLibID(thisConstit); if (gasID > 0) { if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == DataGenerators::NISTShomate) { A = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateA; @@ -2466,7 +2451,7 @@ namespace FuelCellElectricGenerator { H = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateH; tempHprodGases += ((A * Tsho + B * pow_2_Tsho / 2.0 + C * pow_3_Tsho / 3.0 + D * pow_4_Tsho / 4.0 - E / Tsho + F - H) * - FuelCell(GeneratorNum).FCPM.ConstitMolalFract(thisConstit)); + this->FCPM.ConstitMolalFract(thisConstit)); } if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == DataGenerators::NASAPolynomial) { A1 = DataGenerators::GasPhaseThermoChemistryData(gasID).NASA_A1; @@ -2479,7 +2464,7 @@ namespace FuelCellElectricGenerator { tempHprodGases += (((A1 + A2 * Tkel / 2.0 + A3 * pow_2_Tkel / 3.0 + A4 * pow_3_Tkel / 4.0 + A5 * pow_4_Tkel / 5.0 + A6 / Tkel) * DataGenerators::RinKJperMolpK * Tkel) - DataGenerators::GasPhaseThermoChemistryData(gasID).StdRefMolarEnthOfForm) * - FuelCell(GeneratorNum).FCPM.ConstitMolalFract(thisConstit); + this->FCPM.ConstitMolalFract(thisConstit); } } // gasid > 0 } @@ -2487,10 +2472,7 @@ namespace FuelCellElectricGenerator { HProdGases = tempHprodGases; } - void FigureProductGasHeatCap(int const GeneratorNum, // ID of generator FuelCell data structure - Real64 const FluidTemp, // degree C - Real64 &Cp // (J/mol*K) - ) + void FCDataStruct::FigureProductGasHeatCap(Real64 const FluidTemp, Real64 &Cp) { // SUBROUTINE INFORMATION: @@ -2524,8 +2506,8 @@ namespace FuelCellElectricGenerator { Real64 const pow_3_Tkel(pow_3(Tkel)); Real64 const pow_4_Tkel(pow_4(Tkel)); - for (int thisConstit = 1; thisConstit <= isize(FuelCell(GeneratorNum).FCPM.GasLibID); ++thisConstit) { - int gasID = FuelCell(GeneratorNum).FCPM.GasLibID(thisConstit); + for (int thisConstit = 1; thisConstit <= isize(this->FCPM.GasLibID); ++thisConstit) { + int gasID = this->FCPM.GasLibID(thisConstit); if (gasID > 0) { if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == DataGenerators::NISTShomate) { @@ -2536,7 +2518,7 @@ namespace FuelCellElectricGenerator { E = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateE; tempCp += ((A + B * Tsho + C * pow_2_Tsho + D * pow_3_Tsho + E / pow_2_Tsho) * - FuelCell(GeneratorNum).FCPM.ConstitMolalFract(thisConstit)); + this->FCPM.ConstitMolalFract(thisConstit)); } if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == DataGenerators::NASAPolynomial) { @@ -2547,7 +2529,7 @@ namespace FuelCellElectricGenerator { A5 = DataGenerators::GasPhaseThermoChemistryData(gasID).NASA_A5; tempCp += (A1 + A2 * Tkel + A3 * pow_2_Tkel + A4 * pow_3_Tkel + A5 * pow_4_Tkel) * DataGenerators::RinKJperMolpK * - FuelCell(GeneratorNum).FCPM.ConstitMolalFract(thisConstit); + this->FCPM.ConstitMolalFract(thisConstit); } } } @@ -2555,10 +2537,7 @@ namespace FuelCellElectricGenerator { Cp = tempCp; } - void FigureAuxilHeatGasHeatCap(int const GeneratorNum, // ID of generator FuelCell data structure - Real64 const FluidTemp, // degree C - Real64 &Cp // (J/mol*K) - ) + void FCDataStruct::FigureAuxilHeatGasHeatCap(Real64 const FluidTemp, Real64 &Cp) { // SUBROUTINE INFORMATION: @@ -2592,8 +2571,8 @@ namespace FuelCellElectricGenerator { Real64 const pow_3_Tkel(pow_3(Tkel)); Real64 const pow_4_Tkel(pow_4(Tkel)); - for (int thisConstit = 1; thisConstit <= isize(FuelCell(GeneratorNum).AuxilHeat.GasLibID); ++thisConstit) { - int gasID = FuelCell(GeneratorNum).AuxilHeat.GasLibID(thisConstit); + for (int thisConstit = 1; thisConstit <= isize(this->AuxilHeat.GasLibID); ++thisConstit) { + int gasID = this->AuxilHeat.GasLibID(thisConstit); if (gasID > 0) { if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == DataGenerators::NISTShomate) { @@ -2604,7 +2583,7 @@ namespace FuelCellElectricGenerator { E = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateE; tempCp += ((A + B * Tsho + C * pow_2_Tsho + D * pow_3_Tsho + E / pow_2_Tsho) * - FuelCell(GeneratorNum).AuxilHeat.ConstitMolalFract(thisConstit)); + this->AuxilHeat.ConstitMolalFract(thisConstit)); } if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == DataGenerators::NASAPolynomial) { @@ -2615,7 +2594,7 @@ namespace FuelCellElectricGenerator { A5 = DataGenerators::GasPhaseThermoChemistryData(gasID).NASA_A5; tempCp += (A1 + A2 * Tkel + A3 * pow_2_Tkel + A4 * pow_3_Tkel + A5 * pow_4_Tkel) * DataGenerators::RinKJperMolpK * - FuelCell(GeneratorNum).AuxilHeat.ConstitMolalFract(thisConstit); + this->AuxilHeat.ConstitMolalFract(thisConstit); } } } @@ -2706,7 +2685,7 @@ namespace FuelCellElectricGenerator { Cp = A + B * Tsho + C * pow_2(Tsho) + D * pow_3(Tsho) + E / pow_2(Tsho); } - void FigureACAncillaries(int const GeneratorNum, Real64 &PacAncill) + void FCDataStruct::FigureACAncillaries(Real64 &PacAncill) { // SUBROUTINE INFORMATION: @@ -2721,24 +2700,24 @@ namespace FuelCellElectricGenerator { // Using lagged values inside a sequential substitution loop PacAncill = 0.0; // sect. 5.9 - FuelCell(GeneratorNum).FCPM.PelancillariesAC = - FuelCell(GeneratorNum).FCPM.ANC0 + FuelCell(GeneratorNum).FCPM.ANC1 * FuelCell(GeneratorNum).FCPM.NdotFuel; + this->FCPM.PelancillariesAC = + this->FCPM.ANC0 + this->FCPM.ANC1 * this->FCPM.NdotFuel; // sect 6.0 - FuelCell(GeneratorNum).AirSup.PairCompEl = CurveManager::CurveValue(FuelCell(GeneratorNum).AirSup.BlowerPowerCurveID, FuelCell(GeneratorNum).FCPM.NdotAir); + this->AirSup.PairCompEl = CurveManager::CurveValue(this->AirSup.BlowerPowerCurveID, this->FCPM.NdotAir); // sect 7.0 - DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).PfuelCompEl = - CurveManager::CurveValue(DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).CompPowerCurveID, FuelCell(GeneratorNum).FCPM.NdotFuel); + DataGenerators::FuelSupply(this->FuelSupNum).PfuelCompEl = + CurveManager::CurveValue(DataGenerators::FuelSupply(this->FuelSupNum).CompPowerCurveID, this->FCPM.NdotFuel); // sect. 8.0 - FuelCell(GeneratorNum).WaterSup.PwaterCompEl = - CurveManager::CurveValue(FuelCell(GeneratorNum).WaterSup.PmpPowerCurveID, FuelCell(GeneratorNum).FCPM.NdotLiqwater); + this->WaterSup.PwaterCompEl = + CurveManager::CurveValue(this->WaterSup.PmpPowerCurveID, this->FCPM.NdotLiqwater); - PacAncill = FuelCell(GeneratorNum).FCPM.PelancillariesAC + FuelCell(GeneratorNum).AirSup.PairCompEl + - DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).PfuelCompEl + FuelCell(GeneratorNum).WaterSup.PwaterCompEl; + PacAncill = this->FCPM.PelancillariesAC + this->AirSup.PairCompEl + + DataGenerators::FuelSupply(this->FuelSupNum).PfuelCompEl + this->WaterSup.PwaterCompEl; } - void FigurePowerConditioningLosses(int const GeneratorNum, Real64 const Pdemand, Real64 &PpcuLosses) + void FCDataStruct::FigurePowerConditioningLosses(Real64 const Pdemand, Real64 &PpcuLosses) { // SUBROUTINE INFORMATION: @@ -2750,29 +2729,28 @@ namespace FuelCellElectricGenerator { // PURPOSE OF THIS SUBROUTINE: // Calculate inverter losses - if (FuelCell(GeneratorNum).Inverter.EffMode == DataGenerators::InverterEffConstant) { - PpcuLosses = Pdemand * (1 - FuelCell(GeneratorNum).Inverter.ConstEff) / FuelCell(GeneratorNum).Inverter.ConstEff; + if (this->Inverter.EffMode == DataGenerators::InverterEffConstant) { + PpcuLosses = Pdemand * (1 - this->Inverter.ConstEff) / this->Inverter.ConstEff; } - if (FuelCell(GeneratorNum).Inverter.EffMode == DataGenerators::InverterEffQuadratic) { + if (this->Inverter.EffMode == DataGenerators::InverterEffQuadratic) { // first use Pdemand instead of Pel to get initial estimate - Real64 lastPpcuLosses = Pdemand * (1.0 - CurveManager::CurveValue(FuelCell(GeneratorNum).Inverter.EffQuadraticCurveID, Pdemand)) / - CurveManager::CurveValue(FuelCell(GeneratorNum).Inverter.EffQuadraticCurveID, Pdemand); + Real64 lastPpcuLosses = Pdemand * (1.0 - CurveManager::CurveValue(this->Inverter.EffQuadraticCurveID, Pdemand)) / + CurveManager::CurveValue(this->Inverter.EffQuadraticCurveID, Pdemand); for (int iter = 1; iter <= 20; ++iter) { // seems like need to iterate (??) Need to investigate number and convergence success here Real64 Pel = Pdemand + lastPpcuLosses; - lastPpcuLosses = (1.0 - CurveManager::CurveValue(FuelCell(GeneratorNum).Inverter.EffQuadraticCurveID, Pel)) * Pel; + lastPpcuLosses = (1.0 - CurveManager::CurveValue(this->Inverter.EffQuadraticCurveID, Pel)) * Pel; } PpcuLosses = lastPpcuLosses; } } - void FigureTransientConstraints(int const GeneratorNum, // index number for accessing correct generator - Real64 &Pel, // DC power control setting for power module + void FCDataStruct::FigureTransientConstraints(Real64 &Pel, // DC power control setting for power module bool &Constrained, // true if transient constraints kick in Real64 &PelDiff // if constrained then this is the difference, positive ) @@ -2789,44 +2767,44 @@ namespace FuelCellElectricGenerator { Real64 CurrentFractionalDay = double(DataGlobals::DayOfSim) + (int(DataGlobals::CurrentTime) + (DataHVACGlobals::SysTimeElapsed + (DataGlobals::CurrentTime - int(DataGlobals::CurrentTime)))) / DataGlobals::HoursInDay; // Check if in start up and if it still should be - if (FuelCell(GeneratorNum).FCPM.DuringStartUp) { + if (this->FCPM.DuringStartUp) { // calculate time for end of start up period - Real64 EndingFractionalDay = FuelCell(GeneratorNum).FCPM.FractionalDayofLastStartUp + FuelCell(GeneratorNum).FCPM.StartUpTime / DataGlobals::HoursInDay; + Real64 EndingFractionalDay = this->FCPM.FractionalDayofLastStartUp + this->FCPM.StartUpTime / DataGlobals::HoursInDay; if (CurrentFractionalDay > EndingFractionalDay) { // start up period is now over - FuelCell(GeneratorNum).FCPM.DuringStartUp = false; + this->FCPM.DuringStartUp = false; } } // Check if in shut down up and if it still should be - if (FuelCell(GeneratorNum).FCPM.DuringShutDown) { + if (this->FCPM.DuringShutDown) { // calculate time for end of shut down period - Real64 EndingFractionalDay = FuelCell(GeneratorNum).FCPM.FractionalDayofLastShutDown + FuelCell(GeneratorNum).FCPM.ShutDownTime / DataGlobals::HoursInDay; + Real64 EndingFractionalDay = this->FCPM.FractionalDayofLastShutDown + this->FCPM.ShutDownTime / DataGlobals::HoursInDay; if (CurrentFractionalDay > EndingFractionalDay) { // start up period is now over - FuelCell(GeneratorNum).FCPM.DuringShutDown = false; + this->FCPM.DuringShutDown = false; } } // compare - if (!(FuelCell(GeneratorNum).FCPM.DuringShutDown) && !(FuelCell(GeneratorNum).FCPM.DuringStartUp)) { + if (!(this->FCPM.DuringShutDown) && !(this->FCPM.DuringStartUp)) { // unit is neither starting or stopping and the only constraints would come from transient limits - if (Pel > FuelCell(GeneratorNum).FCPM.PelLastTimeStep) { // powering up + if (Pel > this->FCPM.PelLastTimeStep) { // powering up // working variable for max allowed by transient constraint - Real64 MaxPel = FuelCell(GeneratorNum).FCPM.PelLastTimeStep + FuelCell(GeneratorNum).FCPM.UpTranLimit * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + Real64 MaxPel = this->FCPM.PelLastTimeStep + this->FCPM.UpTranLimit * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; if (MaxPel < Pel) { Pel = MaxPel; Constrained = true; } else { Constrained = false; } - } else if (Pel < FuelCell(GeneratorNum).FCPM.PelLastTimeStep) { // powering down + } else if (Pel < this->FCPM.PelLastTimeStep) { // powering down // working variable for min allowed by transient constraint - Real64 MinPel = FuelCell(GeneratorNum).FCPM.PelLastTimeStep - FuelCell(GeneratorNum).FCPM.DownTranLimit * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + Real64 MinPel = this->FCPM.PelLastTimeStep - this->FCPM.DownTranLimit * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; if (Pel < MinPel) { Pel = MinPel; Constrained = true; @@ -2840,13 +2818,13 @@ namespace FuelCellElectricGenerator { } // not in start up or shut down - if (FuelCell(GeneratorNum).FCPM.DuringStartUp) { + if (this->FCPM.DuringStartUp) { // constant during start up modeling artifact - Pel = FuelCell(GeneratorNum).FCPM.StartUpElectProd / FuelCell(GeneratorNum).FCPM.StartUpTime; + Pel = this->FCPM.StartUpElectProd / this->FCPM.StartUpTime; Constrained = true; } - if (FuelCell(GeneratorNum).FCPM.DuringShutDown) { + if (this->FCPM.DuringShutDown) { Pel = 0.0; // assumes no power generated during shut down Constrained = true; @@ -2902,7 +2880,7 @@ namespace FuelCellElectricGenerator { Real64 NdotGas = FuelCell(Num).AuxilHeat.NdotAuxMix; Real64 TprodGasIn = FuelCell(Num).AuxilHeat.TauxMix; Real64 CpProdGasMol; - FigureAuxilHeatGasHeatCap(Num, TprodGasIn, CpProdGasMol); // Cp in (J/mol*K) + FuelCell(Num).FigureAuxilHeatGasHeatCap(TprodGasIn, CpProdGasMol); // Cp in (J/mol*K) // factor of 1000.0 for kmol -> mol Real64 NdotCp = min(NdotGas * CpProdGasMol * 1000.0, NdotWater * CpWaterMol * 1000.0); @@ -2934,7 +2912,7 @@ namespace FuelCellElectricGenerator { // factor of 1000.0 for kmol -> mol Real64 NdotCpWater = NdotWater * CpWaterMol * 1000.0; Real64 CpProdGasMol; - FigureAuxilHeatGasHeatCap(Num, TauxMix, CpProdGasMol); // Cp in (J/mol*K) + FuelCell(Num).FigureAuxilHeatGasHeatCap(TauxMix, CpProdGasMol); // Cp in (J/mol*K) Real64 NdotCpAuxMix = NdotGas * CpProdGasMol * 1000.0; if ((NdotCpWater != 0.0) && (NdotCpAuxMix != 0.0)) { // trap divide by zero @@ -2979,7 +2957,7 @@ namespace FuelCellElectricGenerator { FigureLiquidWaterHeatCap(TwaterIn, CpWaterMol); Real64 NdotCpWater = NdotWater * CpWaterMol * 1000.0; Real64 CpProdGasMol; - FigureAuxilHeatGasHeatCap(Num, TauxMix, CpProdGasMol); // Cp in (J/mol*K) + FuelCell(Num).FigureAuxilHeatGasHeatCap(TauxMix, CpProdGasMol); // Cp in (J/mol*K) Real64 NdotCpAuxMix = NdotGas * CpProdGasMol * 1000.0; if ((NdotCpWater != 0.0) && (NdotCpAuxMix != 0.0)) { // trap divide by zero @@ -3021,7 +2999,7 @@ namespace FuelCellElectricGenerator { FigureLiquidWaterHeatCap(TwaterIn, CpWaterMol); Real64 NdotCpWater = NdotWater * CpWaterMol * 1000.0; Real64 CpProdGasMol; - FigureAuxilHeatGasHeatCap(Num, TauxMix, CpProdGasMol); // Cp in (J/mol*K) + FuelCell(Num).FigureAuxilHeatGasHeatCap(TauxMix, CpProdGasMol); // Cp in (J/mol*K) Real64 NdotCpAuxMix = NdotGas * CpProdGasMol * 1000.0; // find water fraction in incoming gas stream diff --git a/src/EnergyPlus/FuelCellElectricGenerator.hh b/src/EnergyPlus/FuelCellElectricGenerator.hh index 6d0c2a905da..dda7f9ef43b 100644 --- a/src/EnergyPlus/FuelCellElectricGenerator.hh +++ b/src/EnergyPlus/FuelCellElectricGenerator.hh @@ -552,6 +552,29 @@ namespace FuelCellElectricGenerator { DynamicsControlID(0), TimeElapsed(0.0), InitGenerator(true), MyEnvrnFlag_Init(true), MyWarmupFlag_Init(false), MyPlantScanFlag_Init(true) { } + + void FigureAirHeatCap(Real64 FluidTemp, Real64 &Cp); + + void FigureAirEnthalpy(Real64 FluidTemp, Real64 &Hair); + + void FigureFuelHeatCap(Real64 FluidTemp, Real64 &Cp); + + void FigureFuelEnthalpy(Real64 FluidTemp, Real64 &Hfuel); + + void FigureProductGasesEnthalpy(Real64 FluidTemp, Real64 &HProdGases); + + void FigureProductGasHeatCap(Real64 FluidTemp, Real64 &Cp); + + void FigureAuxilHeatGasHeatCap(Real64 FluidTemp, Real64 &Cp); + + void FigureACAncillaries(Real64 &PacAncill); + + void FigurePowerConditioningLosses(Real64 Pdemand, Real64 &PpcuLosses); + + void FigureTransientConstraints(Real64 &Pel, // DC power control setting for power module + bool &Constrained, // true if transient constraints kick in (TODO: never used anywhere) + Real64 &PelDiff // if constrained then this is the difference, positive + ); }; void clear_state(); @@ -582,41 +605,6 @@ namespace FuelCellElectricGenerator { Array1 const &Par // par(1) = Generator Number ); - void FigureAirHeatCap(int GeneratorNum, // ID of generator FuelCell data structure - Real64 FluidTemp, // degree C - Real64 &Cp // (J/mol*K) - ); - - void FigureAirEnthalpy(int GeneratorNum, // ID of generator FuelCell data structure - Real64 FluidTemp, // degree C - Real64 &Hair // (kJ/mol) - ); - - void FigureFuelHeatCap(int GeneratorNum, // ID of generator FuelCell data structure - Real64 FluidTemp, // degree C - Real64 &Cp // (J/mol*K) - ); - - void FigureFuelEnthalpy(int GeneratorNum, // ID of generator FuelCell data structure - Real64 FluidTemp, // degree C - Real64 &Hfuel // kJ/mol - ); - - void FigureProductGasesEnthalpy(int GeneratorNum, // ID of generator FuelCell data structure - Real64 FluidTemp, // degree C - Real64 &HProdGases // kJ/mol - ); - - void FigureProductGasHeatCap(int GeneratorNum, // ID of generator FuelCell data structure - Real64 FluidTemp, // degree C - Real64 &Cp // (J/mol*K) - ); - - void FigureAuxilHeatGasHeatCap(int GeneratorNum, // ID of generator FuelCell data structure - Real64 FluidTemp, // degree C - Real64 &Cp // (J/mol*K) - ); - void FigureGaseousWaterEnthalpy(Real64 FluidTemp, // degree C Real64 &HGasWater // kJ/mol ); @@ -629,16 +617,6 @@ namespace FuelCellElectricGenerator { Real64 &Cp // (J/mol*K) ); - void FigureACAncillaries(int GeneratorNum, Real64 &PacAncill); - - void FigurePowerConditioningLosses(int GeneratorNum, Real64 Pdemand, Real64 &PpcuLosses); - - void FigureTransientConstraints(int GeneratorNum, // index number for accessing correct generator - Real64 &Pel, // DC power control setting for power module - bool &Constrained, // true if transient constraints kick in (TODO: never used anywhere) - Real64 &PelDiff // if constrained then this is the difference, positive - ); - void CalcFuelCellAuxHeater(int Num); // Generator number void CalcFuelCellGenHeatRecovery(int Num); // Generator number From c77ead6aef6e401f03a66d133cd019aadd106f73 Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Tue, 12 Nov 2019 11:02:15 -0700 Subject: [PATCH 30/51] partial functions to members --- src/EnergyPlus/FuelCellElectricGenerator.cc | 976 ++++++++++---------- src/EnergyPlus/FuelCellElectricGenerator.hh | 54 +- 2 files changed, 504 insertions(+), 526 deletions(-) diff --git a/src/EnergyPlus/FuelCellElectricGenerator.cc b/src/EnergyPlus/FuelCellElectricGenerator.cc index e1ae6a3417c..0b070762228 100644 --- a/src/EnergyPlus/FuelCellElectricGenerator.cc +++ b/src/EnergyPlus/FuelCellElectricGenerator.cc @@ -155,13 +155,10 @@ namespace FuelCellElectricGenerator { } } - InitFuelCellGenerators(GenNum); - - CalcFuelCellGeneratorModel(GenNum, RunFlag, MyLoad, FirstHVACIteration); - - CalcUpdateHeatRecovery(GenNum, FirstHVACIteration); - - UpdateFuelCellGeneratorRecords(RunFlag, GenNum); + FuelCell(GenNum).InitFuelCellGenerators(); + FuelCell(GenNum).CalcFuelCellGeneratorModel(GenNum, RunFlag, MyLoad, FirstHVACIteration); + FuelCell(GenNum).CalcUpdateHeatRecovery(FirstHVACIteration); + FuelCell(GenNum).UpdateFuelCellGeneratorRecords(); } void GetFuelCellGeneratorInput() @@ -1314,10 +1311,7 @@ namespace FuelCellElectricGenerator { } } - void CalcFuelCellGeneratorModel(int const GeneratorNum, // Generator number - bool const RunFlag, // TRUE when Generator operating - Real64 const MyLoad, // Generator demand - bool const EP_UNUSED(FirstHVACIteration)) + void FCDataStruct::CalcFuelCellGeneratorModel(int const GeneratorNum, bool const RunFlag, Real64 const MyLoad, bool const EP_UNUSED(FirstHVACIteration)) { // SUBROUTINE INFORMATION: // AUTHOR Brent Griffith @@ -1340,35 +1334,35 @@ namespace FuelCellElectricGenerator { // TODO zero out terms as appropriate - if (FuelCell(GeneratorNum).FCPM.HasBeenOn) { + if (this->FCPM.HasBeenOn) { // FuelCell just now beginning to shut down, // set Day and Time of Last Shut Down - FuelCell(GeneratorNum).FCPM.FractionalDayofLastShutDown = + this->FCPM.FractionalDayofLastShutDown = double(DataGlobals::DayOfSim) + (int(DataGlobals::CurrentTime) + (DataHVACGlobals::SysTimeElapsed + (DataGlobals::CurrentTime - int(DataGlobals::CurrentTime)))) / DataGlobals::HoursInDay; - FuelCell(GeneratorNum).FCPM.HasBeenOn = false; + this->FCPM.HasBeenOn = false; - if (FuelCell(GeneratorNum).FCPM.ShutDownTime > 0.0) FuelCell(GeneratorNum).FCPM.DuringShutDown = true; + if (this->FCPM.ShutDownTime > 0.0) this->FCPM.DuringShutDown = true; } // TODO check to see if still in shut down mode and using fuel. - if (FuelCell(GeneratorNum).FCPM.DuringShutDown) { + if (this->FCPM.DuringShutDown) { } return; } - if (!FuelCell(GeneratorNum).FCPM.HasBeenOn) { + if (!this->FCPM.HasBeenOn) { // fuel cell just turned on // set Day and Time of Last STart Up - FuelCell(GeneratorNum).FCPM.FractionalDayofLastStartUp = + this->FCPM.FractionalDayofLastStartUp = double(DataGlobals::DayOfSim) + (int(DataGlobals::CurrentTime) + (DataHVACGlobals::SysTimeElapsed + (DataGlobals::CurrentTime - int(DataGlobals::CurrentTime)))) / DataGlobals::HoursInDay; - FuelCell(GeneratorNum).FCPM.HasBeenOn = true; - ++FuelCell(GeneratorNum).FCPM.NumCycles; // increment cycling counter + this->FCPM.HasBeenOn = true; + ++this->FCPM.NumCycles; // increment cycling counter - if (FuelCell(GeneratorNum).FCPM.StartUpTime > 0.0) FuelCell(GeneratorNum).FCPM.DuringStartUp = true; + if (this->FCPM.StartUpTime > 0.0) this->FCPM.DuringStartUp = true; } // TODO deal with things when jump out if not running? @@ -1391,308 +1385,308 @@ namespace FuelCellElectricGenerator { // BEGIN SEQUENTIAL SUBSTITUTION to handle a lot of inter-related calcs for (iter = 1; iter <= 20; ++iter) { if (iter > 1) { - FuelCell(GeneratorNum).FigurePowerConditioningLosses(PoutofInverter, PpcuLosses); - FuelCell(GeneratorNum).FigureACAncillaries(PacAncillariesTotal); + this->FigurePowerConditioningLosses(PoutofInverter, PpcuLosses); + this->FigureACAncillaries(PacAncillariesTotal); Pdemand = MyLoad + PacAncillariesTotal + PpcuLosses; } else { // control Step 1a: Figure ancillary AC power draws - FuelCell(GeneratorNum).FigureACAncillaries(PacAncillariesTotal); + this->FigureACAncillaries(PacAncillariesTotal); Pdemand = MyLoad + PacAncillariesTotal; // Control Step 1b: Calculate losses associated with Power conditioning - FuelCell(GeneratorNum).FigurePowerConditioningLosses(Pdemand, PpcuLosses); + this->FigurePowerConditioningLosses(Pdemand, PpcuLosses); Pdemand += PpcuLosses; Pel = Pdemand; } - FuelCell(GeneratorNum).Inverter.PCUlosses = PpcuLosses; + this->Inverter.PCUlosses = PpcuLosses; // Control step 2: adjust for transient and startup/shut down constraints Real64 PelDiff; bool ConstrainedFCPMTrans = false; - FuelCell(GeneratorNum).FigureTransientConstraints(Pel, ConstrainedFCPMTrans, PelDiff); + this->FigureTransientConstraints(Pel, ConstrainedFCPMTrans, PelDiff); // Control step 3: adjust for max and min limits on Pel - if (Pel < FuelCell(GeneratorNum).FCPM.PelMin) { - PelDiff += (FuelCell(GeneratorNum).FCPM.PelMin - Pel); - Pel = FuelCell(GeneratorNum).FCPM.PelMin; + if (Pel < this->FCPM.PelMin) { + PelDiff += (this->FCPM.PelMin - Pel); + Pel = this->FCPM.PelMin; ConstrainedFCPM = true; } - if (Pel > FuelCell(GeneratorNum).FCPM.PelMax) { - PelDiff += (FuelCell(GeneratorNum).FCPM.PelMax - Pel); - Pel = FuelCell(GeneratorNum).FCPM.PelMax; + if (Pel > this->FCPM.PelMax) { + PelDiff += (this->FCPM.PelMax - Pel); + Pel = this->FCPM.PelMax; ConstrainedFCPM = true; } if (ConstrainedFCPM) { } - FuelCell(GeneratorNum).FCPM.Pel = Pel; + this->FCPM.Pel = Pel; // Now calculate FC models. return to controls and batter after // Calculation Step 1. Determine electrical Efficiency Eel Real64 Eel = 0.0; - if (FuelCell(GeneratorNum).FCPM.EffMode == DataGenerators::NormalizedCurveMode) { + if (this->FCPM.EffMode == DataGenerators::NormalizedCurveMode) { // Equation (8) in FuelCell Spec modified for normalized curve - Eel = CurveManager::CurveValue(FuelCell(GeneratorNum).FCPM.EffCurveID, Pel / FuelCell(GeneratorNum).FCPM.NomPel) * - FuelCell(GeneratorNum).FCPM.NomEff * - (1.0 - FuelCell(GeneratorNum).FCPM.NumCycles * FuelCell(GeneratorNum).FCPM.CyclingDegradRat) * - (1.0 - max((FuelCell(GeneratorNum).FCPM.NumRunHours - FuelCell(GeneratorNum).FCPM.ThreshRunHours), 0.0) * - FuelCell(GeneratorNum).FCPM.OperateDegradRat); + Eel = CurveManager::CurveValue(this->FCPM.EffCurveID, Pel / this->FCPM.NomPel) * + this->FCPM.NomEff * + (1.0 - this->FCPM.NumCycles * this->FCPM.CyclingDegradRat) * + (1.0 - max((this->FCPM.NumRunHours - this->FCPM.ThreshRunHours), 0.0) * + this->FCPM.OperateDegradRat); - } else if (FuelCell(GeneratorNum).FCPM.EffMode == DataGenerators::DirectCurveMode) { + } else if (this->FCPM.EffMode == DataGenerators::DirectCurveMode) { // Equation (8) in FuelCell Spec - Eel = CurveManager::CurveValue(FuelCell(GeneratorNum).FCPM.EffCurveID, Pel) * - (1.0 - FuelCell(GeneratorNum).FCPM.NumCycles * FuelCell(GeneratorNum).FCPM.CyclingDegradRat) * - (1.0 - max((FuelCell(GeneratorNum).FCPM.NumRunHours - FuelCell(GeneratorNum).FCPM.ThreshRunHours), 0.0) * - FuelCell(GeneratorNum).FCPM.OperateDegradRat); + Eel = CurveManager::CurveValue(this->FCPM.EffCurveID, Pel) * + (1.0 - this->FCPM.NumCycles * this->FCPM.CyclingDegradRat) * + (1.0 - max((this->FCPM.NumRunHours - this->FCPM.ThreshRunHours), 0.0) * + this->FCPM.OperateDegradRat); } - FuelCell(GeneratorNum).FCPM.Eel = Eel; + this->FCPM.Eel = Eel; // Calculation Step 2. Determine fuel rate // fuel flow rate - Real64 NdotFuel = Pel / (Eel * DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).LHV * 1000000.0); // Eq. 10 solved for Ndot + Real64 NdotFuel = Pel / (Eel * DataGenerators::FuelSupply(this->FuelSupNum).LHV * 1000000.0); // Eq. 10 solved for Ndot - FuelCell(GeneratorNum).FCPM.NdotFuel = NdotFuel; + this->FCPM.NdotFuel = NdotFuel; if (Pel <= 0.0) { // TODO zero stuff before leaving Pel = 0.0; - FuelCell(GeneratorNum).FCPM.Pel = 0.0; + this->FCPM.Pel = 0.0; return; } else { - FuelCell(GeneratorNum).FCPM.Pel = Pel; + this->FCPM.Pel = Pel; } // Calculation Step 3. Determine Air rate - if (FuelCell(GeneratorNum).AirSup.AirSupRateMode == DataGenerators::ConstantStoicsAirRat) { // MEthod 1 + if (this->AirSup.AirSupRateMode == DataGenerators::ConstantStoicsAirRat) { // MEthod 1 // molar rate coeff working variable - Real64 NdotO2 = DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).StoicOxygenRate * FuelCell(GeneratorNum).FCPM.NdotFuel * - FuelCell(GeneratorNum).AirSup.Stoics; + Real64 NdotO2 = DataGenerators::FuelSupply(this->FuelSupNum).StoicOxygenRate * this->FCPM.NdotFuel * + this->AirSup.Stoics; - FuelCell(GeneratorNum).FCPM.NdotAir = NdotO2 / FuelCell(GeneratorNum).AirSup.O2fraction; + this->FCPM.NdotAir = NdotO2 / this->AirSup.O2fraction; - } else if (FuelCell(GeneratorNum).AirSup.AirSupRateMode == DataGenerators::QuadraticFuncofPel) { // MEthod 2 + } else if (this->AirSup.AirSupRateMode == DataGenerators::QuadraticFuncofPel) { // MEthod 2 - FuelCell(GeneratorNum).FCPM.NdotAir = CurveManager::CurveValue(FuelCell(GeneratorNum).AirSup.AirFuncPelCurveID, Pel) * - (1 + FuelCell(GeneratorNum).AirSup.AirTempCoeff * FuelCell(GeneratorNum).AirSup.TairIntoFCPM); + this->FCPM.NdotAir = CurveManager::CurveValue(this->AirSup.AirFuncPelCurveID, Pel) * + (1 + this->AirSup.AirTempCoeff * this->AirSup.TairIntoFCPM); - } else if (FuelCell(GeneratorNum).AirSup.AirSupRateMode == DataGenerators::QuadraticFuncofNdot) { // method 3 - FuelCell(GeneratorNum).FCPM.NdotAir = - CurveManager::CurveValue(FuelCell(GeneratorNum).AirSup.AirFuncNdotCurveID, FuelCell(GeneratorNum).FCPM.NdotFuel) * - (1 + FuelCell(GeneratorNum).AirSup.AirTempCoeff * FuelCell(GeneratorNum).AirSup.TairIntoFCPM); + } else if (this->AirSup.AirSupRateMode == DataGenerators::QuadraticFuncofNdot) { // method 3 + this->FCPM.NdotAir = + CurveManager::CurveValue(this->AirSup.AirFuncNdotCurveID, this->FCPM.NdotFuel) * + (1 + this->AirSup.AirTempCoeff * this->AirSup.TairIntoFCPM); } // Calculation Step 4. fuel compressor power - DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).PfuelCompEl = - CurveManager::CurveValue(DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).CompPowerCurveID, FuelCell(GeneratorNum).FCPM.NdotFuel); + DataGenerators::FuelSupply(this->FuelSupNum).PfuelCompEl = + CurveManager::CurveValue(DataGenerators::FuelSupply(this->FuelSupNum).CompPowerCurveID, this->FCPM.NdotFuel); // calculation Step 5, Fuel Compressor (need outlet temperature) - if (DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).FuelTempMode == DataGenerators::FuelInTempFromNode) { + if (DataGenerators::FuelSupply(this->FuelSupNum).FuelTempMode == DataGenerators::FuelInTempFromNode) { - DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).TfuelIntoCompress = DataLoopNode::Node(DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).NodeNum).Temp; + DataGenerators::FuelSupply(this->FuelSupNum).TfuelIntoCompress = DataLoopNode::Node(DataGenerators::FuelSupply(this->FuelSupNum).NodeNum).Temp; - } else if (DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).FuelTempMode == DataGenerators::FuelInTempSchedule) { + } else if (DataGenerators::FuelSupply(this->FuelSupNum).FuelTempMode == DataGenerators::FuelInTempSchedule) { - DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).TfuelIntoCompress = - ScheduleManager::GetCurrentScheduleValue(DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).SchedNum); + DataGenerators::FuelSupply(this->FuelSupNum).TfuelIntoCompress = + ScheduleManager::GetCurrentScheduleValue(DataGenerators::FuelSupply(this->FuelSupNum).SchedNum); } // evaluate heat capacity at average temperature using shomate Real64 Cp; // temp Heat Capacity, used in thermochemistry units of (J/mol K) - Real64 Tavg = (DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).TfuelIntoCompress + DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).TfuelIntoFCPM) / 2.0; - FuelCell(GeneratorNum).FigureFuelHeatCap(Tavg, Cp); // Cp in (J/mol K) + Real64 Tavg = (DataGenerators::FuelSupply(this->FuelSupNum).TfuelIntoCompress + DataGenerators::FuelSupply(this->FuelSupNum).TfuelIntoFCPM) / 2.0; + this->FigureFuelHeatCap(Tavg, Cp); // Cp in (J/mol K) // calculate a Temp of fuel out of compressor and into power module - if (FuelCell(GeneratorNum).FCPM.NdotFuel <= 0.0) { // just pass through, domain probably collapsed in modeling - DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).TfuelIntoFCPM = DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).TfuelIntoCompress; + if (this->FCPM.NdotFuel <= 0.0) { // just pass through, domain probably collapsed in modeling + DataGenerators::FuelSupply(this->FuelSupNum).TfuelIntoFCPM = DataGenerators::FuelSupply(this->FuelSupNum).TfuelIntoCompress; } else { - DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).TfuelIntoFCPM = - ((1.0 - DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).CompPowerLossFactor) * - DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).PfuelCompEl / (FuelCell(GeneratorNum).FCPM.NdotFuel * Cp * 1000.0)) + - DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).TfuelIntoCompress; // 1000 Cp units mol-> kmol + DataGenerators::FuelSupply(this->FuelSupNum).TfuelIntoFCPM = + ((1.0 - DataGenerators::FuelSupply(this->FuelSupNum).CompPowerLossFactor) * + DataGenerators::FuelSupply(this->FuelSupNum).PfuelCompEl / (this->FCPM.NdotFuel * Cp * 1000.0)) + + DataGenerators::FuelSupply(this->FuelSupNum).TfuelIntoCompress; // 1000 Cp units mol-> kmol } // calc skin losses from fuel compressor - DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).QskinLoss = - DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).CompPowerLossFactor * DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).PfuelCompEl; + DataGenerators::FuelSupply(this->FuelSupNum).QskinLoss = + DataGenerators::FuelSupply(this->FuelSupNum).CompPowerLossFactor * DataGenerators::FuelSupply(this->FuelSupNum).PfuelCompEl; - if (DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).QskinLoss < 0.0) { - ShowWarningError("problem in FuelSupply.QskinLoss " + General::RoundSigDigits(DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).QskinLoss, 3)); - DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).QskinLoss = 0.0; + if (DataGenerators::FuelSupply(this->FuelSupNum).QskinLoss < 0.0) { + ShowWarningError("problem in FuelSupply.QskinLoss " + General::RoundSigDigits(DataGenerators::FuelSupply(this->FuelSupNum).QskinLoss, 3)); + DataGenerators::FuelSupply(this->FuelSupNum).QskinLoss = 0.0; } // calculate tatal fuel enthalpy coming into power module // (Hmolfuel in KJ/mol) Real64 Hmolfuel; // temp enthalpy of fuel mixture in KJ/mol - FuelCell(GeneratorNum).FigureFuelEnthalpy(DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).TfuelIntoFCPM, Hmolfuel); + this->FigureFuelEnthalpy(DataGenerators::FuelSupply(this->FuelSupNum).TfuelIntoFCPM, Hmolfuel); // units, NdotFuel in kmol/sec. Hmolfule in KJ/mol , // factor of 1000's to get to J/s or watts - FuelCell(GeneratorNum).FCPM.TotFuelInEnthalphy = Hmolfuel * 1000.0 * FuelCell(GeneratorNum).FCPM.NdotFuel * 1000.0; + this->FCPM.TotFuelInEnthalphy = Hmolfuel * 1000.0 * this->FCPM.NdotFuel * 1000.0; // Calculation Step 6, water compressor calculations // calculate water consumption - FuelCell(GeneratorNum).FCPM.NdotLiqwater = - CurveManager::CurveValue(FuelCell(GeneratorNum).WaterSup.WaterSupRateCurveID, FuelCell(GeneratorNum).FCPM.NdotFuel); + this->FCPM.NdotLiqwater = + CurveManager::CurveValue(this->WaterSup.WaterSupRateCurveID, this->FCPM.NdotFuel); // set inlet temp. (could move to init) { - auto const SELECT_CASE_var(FuelCell(GeneratorNum).WaterSup.WaterTempMode); + auto const SELECT_CASE_var(this->WaterSup.WaterTempMode); if (SELECT_CASE_var == DataGenerators::WaterInReformMains) { - FuelCell(GeneratorNum).WaterSup.TwaterIntoCompress = DataEnvironment::WaterMainsTemp; + this->WaterSup.TwaterIntoCompress = DataEnvironment::WaterMainsTemp; } else if ((SELECT_CASE_var == DataGenerators::WaterInReformAirNode) || (SELECT_CASE_var == DataGenerators::WaterInReformWaterNode)) { - FuelCell(GeneratorNum).WaterSup.TwaterIntoCompress = DataLoopNode::Node(FuelCell(GeneratorNum).WaterSup.NodeNum).Temp; + this->WaterSup.TwaterIntoCompress = DataLoopNode::Node(this->WaterSup.NodeNum).Temp; } else if (SELECT_CASE_var == DataGenerators::WaterInReformSchedule) { - FuelCell(GeneratorNum).WaterSup.TwaterIntoCompress = ScheduleManager::GetCurrentScheduleValue(FuelCell(GeneratorNum).WaterSup.SchedNum); + this->WaterSup.TwaterIntoCompress = ScheduleManager::GetCurrentScheduleValue(this->WaterSup.SchedNum); } } - FuelCell(GeneratorNum).WaterSup.PwaterCompEl = - CurveManager::CurveValue(FuelCell(GeneratorNum).WaterSup.PmpPowerCurveID, FuelCell(GeneratorNum).FCPM.NdotLiqwater); + this->WaterSup.PwaterCompEl = + CurveManager::CurveValue(this->WaterSup.PmpPowerCurveID, this->FCPM.NdotLiqwater); // 75.325 J/mol K Water at 0.1 MPa and 298 K, reference NIST WEBBOOK Real64 CpWater; // heat capacity of water in molar units - FigureLiquidWaterHeatCap(FuelCell(GeneratorNum).WaterSup.TwaterIntoCompress, CpWater); + FigureLiquidWaterHeatCap(this->WaterSup.TwaterIntoCompress, CpWater); - if (FuelCell(GeneratorNum).FCPM.NdotLiqwater <= 0.0) { // just pass through, domain probably collapsed in modeling - FuelCell(GeneratorNum).WaterSup.TwaterIntoFCPM = FuelCell(GeneratorNum).WaterSup.TwaterIntoCompress; + if (this->FCPM.NdotLiqwater <= 0.0) { // just pass through, domain probably collapsed in modeling + this->WaterSup.TwaterIntoFCPM = this->WaterSup.TwaterIntoCompress; } else { - FuelCell(GeneratorNum).WaterSup.TwaterIntoFCPM = - ((1 - FuelCell(GeneratorNum).WaterSup.PmpPowerLossFactor) * FuelCell(GeneratorNum).WaterSup.PwaterCompEl / - (FuelCell(GeneratorNum).FCPM.NdotLiqwater * CpWater * 1000.0)) + - FuelCell(GeneratorNum).WaterSup.TwaterIntoCompress; + this->WaterSup.TwaterIntoFCPM = + ((1 - this->WaterSup.PmpPowerLossFactor) * this->WaterSup.PwaterCompEl / + (this->FCPM.NdotLiqwater * CpWater * 1000.0)) + + this->WaterSup.TwaterIntoCompress; } - FuelCell(GeneratorNum).WaterSup.QskinLoss = - FuelCell(GeneratorNum).WaterSup.PmpPowerLossFactor * FuelCell(GeneratorNum).WaterSup.PwaterCompEl; + this->WaterSup.QskinLoss = + this->WaterSup.PmpPowerLossFactor * this->WaterSup.PwaterCompEl; - if (FuelCell(GeneratorNum).WaterSup.QskinLoss < 0.0) { + if (this->WaterSup.QskinLoss < 0.0) { // write(*,*) 'problem in WaterSup%QskinLoss ',FuelCell(GeneratorNum)%WaterSup%QskinLoss - FuelCell(GeneratorNum).WaterSup.QskinLoss = 0.0; + this->WaterSup.QskinLoss = 0.0; } Real64 HLiqWater; // temp enthalpy of liquid water in KJ/mol No Formation - FigureLiquidWaterEnthalpy(FuelCell(GeneratorNum).WaterSup.TwaterIntoFCPM, HLiqWater); // HLiqWater in KJ/mol + FigureLiquidWaterEnthalpy(this->WaterSup.TwaterIntoFCPM, HLiqWater); // HLiqWater in KJ/mol - FuelCell(GeneratorNum).FCPM.WaterInEnthalpy = FuelCell(GeneratorNum).FCPM.NdotLiqwater * HLiqWater * 1000.0 * 1000.0; + this->FCPM.WaterInEnthalpy = this->FCPM.NdotLiqwater * HLiqWater * 1000.0 * 1000.0; // Calculation Step 7, Air compressor - FuelCell(GeneratorNum).AirSup.TairIntoBlower = DataLoopNode::Node(FuelCell(GeneratorNum).AirSup.SupNodeNum).Temp; + this->AirSup.TairIntoBlower = DataLoopNode::Node(this->AirSup.SupNodeNum).Temp; - FuelCell(GeneratorNum).AirSup.PairCompEl = - CurveManager::CurveValue(FuelCell(GeneratorNum).AirSup.BlowerPowerCurveID, FuelCell(GeneratorNum).FCPM.NdotAir); + this->AirSup.PairCompEl = + CurveManager::CurveValue(this->AirSup.BlowerPowerCurveID, this->FCPM.NdotAir); - Tavg = (FuelCell(GeneratorNum).AirSup.TairIntoBlower + FuelCell(GeneratorNum).AirSup.TairIntoFCPM) / 2.0; + Tavg = (this->AirSup.TairIntoBlower + this->AirSup.TairIntoFCPM) / 2.0; - FuelCell(GeneratorNum).FigureAirHeatCap(Tavg, Cp); // Cp in (J/mol K) + this->FigureAirHeatCap(Tavg, Cp); // Cp in (J/mol K) // if PEMFC with stack cooler, then calculate stack cooler impacts - if (FuelCell(GeneratorNum).StackCooler.StackCoolerPresent) { + if (this->StackCooler.StackCoolerPresent) { - FuelCell(GeneratorNum).StackCooler.qs_cool = - (FuelCell(GeneratorNum).StackCooler.r0 + - FuelCell(GeneratorNum).StackCooler.r1 * - (FuelCell(GeneratorNum).StackCooler.TstackActual - FuelCell(GeneratorNum).StackCooler.TstackNom)) * - (1 + FuelCell(GeneratorNum).StackCooler.r2 * Pel + FuelCell(GeneratorNum).StackCooler.r3 * Pel * Pel) * Pel; + this->StackCooler.qs_cool = + (this->StackCooler.r0 + + this->StackCooler.r1 * + (this->StackCooler.TstackActual - this->StackCooler.TstackNom)) * + (1 + this->StackCooler.r2 * Pel + this->StackCooler.r3 * Pel * Pel) * Pel; - FuelCell(GeneratorNum).FCPM.QdotStackCool = FuelCell(GeneratorNum).StackCooler.qs_cool; + this->FCPM.QdotStackCool = this->StackCooler.qs_cool; } // Figure heat recovery from Electrical Storage, power conditioning, and auxiliary burner { - auto const SELECT_CASE_var(FuelCell(GeneratorNum).AirSup.IntakeRecoveryMode); + auto const SELECT_CASE_var(this->AirSup.IntakeRecoveryMode); if (SELECT_CASE_var == DataGenerators::RecoverBurnInvertBatt) { - FuelCell(GeneratorNum).AirSup.QintakeRecovery = FuelCell(GeneratorNum).AuxilHeat.QairIntake + - FuelCell(GeneratorNum).ElecStorage.QairIntake + - FuelCell(GeneratorNum).Inverter.QairIntake; + this->AirSup.QintakeRecovery = this->AuxilHeat.QairIntake + + this->ElecStorage.QairIntake + + this->Inverter.QairIntake; } else if (SELECT_CASE_var == DataGenerators::RecoverAuxiliaryBurner) { - FuelCell(GeneratorNum).AirSup.QintakeRecovery = FuelCell(GeneratorNum).AuxilHeat.QairIntake; + this->AirSup.QintakeRecovery = this->AuxilHeat.QairIntake; } else if (SELECT_CASE_var == DataGenerators::RecoverInverterBatt) { - FuelCell(GeneratorNum).AirSup.QintakeRecovery = - FuelCell(GeneratorNum).ElecStorage.QairIntake + FuelCell(GeneratorNum).Inverter.QairIntake; + this->AirSup.QintakeRecovery = + this->ElecStorage.QairIntake + this->Inverter.QairIntake; } else if (SELECT_CASE_var == DataGenerators::RecoverInverter) { - FuelCell(GeneratorNum).AirSup.QintakeRecovery = FuelCell(GeneratorNum).Inverter.QairIntake; + this->AirSup.QintakeRecovery = this->Inverter.QairIntake; } else if (SELECT_CASE_var == DataGenerators::RecoverBattery) { - FuelCell(GeneratorNum).AirSup.QintakeRecovery = FuelCell(GeneratorNum).ElecStorage.QairIntake; + this->AirSup.QintakeRecovery = this->ElecStorage.QairIntake; } else if (SELECT_CASE_var == DataGenerators::NoRecoveryOnAirIntake) { - FuelCell(GeneratorNum).AirSup.QintakeRecovery = 0.0; + this->AirSup.QintakeRecovery = 0.0; } } - if (FuelCell(GeneratorNum).FCPM.NdotAir <= 0.0) { // just pass through, domain probably collapased in modeling - FuelCell(GeneratorNum).AirSup.TairIntoFCPM = FuelCell(GeneratorNum).AirSup.TairIntoBlower; + if (this->FCPM.NdotAir <= 0.0) { // just pass through, domain probably collapased in modeling + this->AirSup.TairIntoFCPM = this->AirSup.TairIntoBlower; } else { - FuelCell(GeneratorNum).AirSup.TairIntoFCPM = - (((1 - FuelCell(GeneratorNum).AirSup.BlowerHeatLossFactor) * FuelCell(GeneratorNum).AirSup.PairCompEl + - FuelCell(GeneratorNum).AirSup.QintakeRecovery) / - (FuelCell(GeneratorNum).FCPM.NdotAir * Cp * 1000.0)) + - FuelCell(GeneratorNum).AirSup.TairIntoBlower; // 1000 Cp units mol-> kmol + this->AirSup.TairIntoFCPM = + (((1 - this->AirSup.BlowerHeatLossFactor) * this->AirSup.PairCompEl + + this->AirSup.QintakeRecovery) / + (this->FCPM.NdotAir * Cp * 1000.0)) + + this->AirSup.TairIntoBlower; // 1000 Cp units mol-> kmol } - FuelCell(GeneratorNum).AirSup.QskinLoss = FuelCell(GeneratorNum).AirSup.BlowerHeatLossFactor * FuelCell(GeneratorNum).AirSup.PairCompEl; + this->AirSup.QskinLoss = this->AirSup.BlowerHeatLossFactor * this->AirSup.PairCompEl; - if (FuelCell(GeneratorNum).AirSup.QskinLoss < 0.0) { + if (this->AirSup.QskinLoss < 0.0) { // write(*,*) 'problem in AirSup%QskinLoss ', FuelCell(GeneratorNum)%AirSup%QskinLoss - ShowWarningError("problem in AirSup%QskinLoss " + General::RoundSigDigits(FuelCell(GeneratorNum).AirSup.QskinLoss, 3)); - FuelCell(GeneratorNum).AirSup.QskinLoss = 0.0; + ShowWarningError("problem in AirSup%QskinLoss " + General::RoundSigDigits(this->AirSup.QskinLoss, 3)); + this->AirSup.QskinLoss = 0.0; } Real64 Hmolair; // temp enthalpy of air mixture in KJ/mol - FuelCell(GeneratorNum).FigureAirEnthalpy(FuelCell(GeneratorNum).AirSup.TairIntoFCPM, Hmolair); // (Hmolair in KJ/mol) + this->FigureAirEnthalpy(this->AirSup.TairIntoFCPM, Hmolair); // (Hmolair in KJ/mol) // units, NdotAir in kmol/sec.; Hmolfuel in KJ/mol , // factor of 1000's to get to J/s or watts - FuelCell(GeneratorNum).FCPM.TotAirInEnthalphy = Hmolair * 1000.0 * FuelCell(GeneratorNum).FCPM.NdotAir * 1000.0; + this->FCPM.TotAirInEnthalphy = Hmolair * 1000.0 * this->FCPM.NdotAir * 1000.0; // calculation Step 8, Figure Product Gases // figure stoic N dot for air - Real64 NdotO2 = DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).StoicOxygenRate * FuelCell(GeneratorNum).FCPM.NdotFuel; + Real64 NdotO2 = DataGenerators::FuelSupply(this->FuelSupNum).StoicOxygenRate * this->FCPM.NdotFuel; // Air in excess of match for fuel - Real64 NdotStoicAir = NdotO2 / FuelCell(GeneratorNum).AirSup.O2fraction; + Real64 NdotStoicAir = NdotO2 / this->AirSup.O2fraction; // figure excess air rate // Air in excess of match for fuel - Real64 NdotExcessAir = FuelCell(GeneratorNum).FCPM.NdotAir - NdotStoicAir; + Real64 NdotExcessAir = this->FCPM.NdotAir - NdotStoicAir; if (NdotExcessAir < 0) { // can't meet stoichiometric fuel reaction ShowWarningError("Air flow rate into fuel cell is too low for stoichiometric fuel reaction"); - ShowContinueError("Increase air flow in GENERATOR:FC:AIR SUPPLY object:" + FuelCell(GeneratorNum).AirSup.Name); + ShowContinueError("Increase air flow in GENERATOR:FC:AIR SUPPLY object:" + this->AirSup.Name); } // figure CO2 and Water rate from products (coefs setup during one-time processing in gas phase library ) // CO2 from reaction - Real64 NdotCO2ProdGas = FuelCell(GeneratorNum).FCPM.NdotFuel * DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).CO2ProductGasCoef; + Real64 NdotCO2ProdGas = this->FCPM.NdotFuel * DataGenerators::FuelSupply(this->FuelSupNum).CO2ProductGasCoef; // Water from reaction - Real64 NdotH20ProdGas = FuelCell(GeneratorNum).FCPM.NdotFuel * DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).H20ProductGasCoef; + Real64 NdotH20ProdGas = this->FCPM.NdotFuel * DataGenerators::FuelSupply(this->FuelSupNum).H20ProductGasCoef; // set product gas constituent fractions (assume five usual components) Real64 NdotCO2 = 0.0; // temp CO2 molar rate coef product gas stream @@ -1703,115 +1697,115 @@ namespace FuelCellElectricGenerator { // Product gas constituents are fixed (not a user defined thing) - for (int thisGas = 1; thisGas <= FuelCell(GeneratorNum).AirSup.NumConstituents; ++thisGas) { + for (int thisGas = 1; thisGas <= this->AirSup.NumConstituents; ++thisGas) { { - auto const SELECT_CASE_var(FuelCell(GeneratorNum).AirSup.GasLibID(thisGas)); + auto const SELECT_CASE_var(this->AirSup.GasLibID(thisGas)); if (SELECT_CASE_var == 1) { // all the CO2 coming in plus the new CO2 from reactions - NdotCO2 = NdotCO2ProdGas + FuelCell(GeneratorNum).AirSup.ConstitMolalFract(thisGas) * FuelCell(GeneratorNum).FCPM.NdotAir; + NdotCO2 = NdotCO2ProdGas + this->AirSup.ConstitMolalFract(thisGas) * this->FCPM.NdotAir; } else if (SELECT_CASE_var == 2) { // all the nitrogen coming in - NdotN2 = FuelCell(GeneratorNum).FCPM.NdotAir * FuelCell(GeneratorNum).AirSup.ConstitMolalFract(thisGas); + NdotN2 = this->FCPM.NdotAir * this->AirSup.ConstitMolalFract(thisGas); } else if (SELECT_CASE_var == 3) { // all the oxygen in the excess air stream - Ndot02 = NdotExcessAir * FuelCell(GeneratorNum).AirSup.ConstitMolalFract(thisGas); + Ndot02 = NdotExcessAir * this->AirSup.ConstitMolalFract(thisGas); } else if (SELECT_CASE_var == 4) { // all the H20 coming in plus the new H20 from reactions and the H20 from water used in reforming - NdotH20 = NdotH20ProdGas + FuelCell(GeneratorNum).AirSup.ConstitMolalFract(thisGas) * FuelCell(GeneratorNum).FCPM.NdotAir; + NdotH20 = NdotH20ProdGas + this->AirSup.ConstitMolalFract(thisGas) * this->FCPM.NdotAir; //+ FuelCell(GeneratorNum)%FCPM%NdotLiqwater } else if (SELECT_CASE_var == 5) { // all the argon coming in. - NdotAr = FuelCell(GeneratorNum).FCPM.NdotAir * FuelCell(GeneratorNum).AirSup.ConstitMolalFract(thisGas); + NdotAr = this->FCPM.NdotAir * this->AirSup.ConstitMolalFract(thisGas); } else { } } } - FuelCell(GeneratorNum).FCPM.NdotProdGas = NdotCO2 + NdotN2 + Ndot02 + NdotH20 + NdotAr; + this->FCPM.NdotProdGas = NdotCO2 + NdotN2 + Ndot02 + NdotH20 + NdotAr; // now that we have the total, figure molar fractions - FuelCell(GeneratorNum).FCPM.ConstitMolalFract(1) = NdotCO2 / FuelCell(GeneratorNum).FCPM.NdotProdGas; + this->FCPM.ConstitMolalFract(1) = NdotCO2 / this->FCPM.NdotProdGas; // all the nitrogen comming in - FuelCell(GeneratorNum).FCPM.ConstitMolalFract(2) = NdotN2 / FuelCell(GeneratorNum).FCPM.NdotProdGas; + this->FCPM.ConstitMolalFract(2) = NdotN2 / this->FCPM.NdotProdGas; // all the oxygen in the excess air stream - FuelCell(GeneratorNum).FCPM.ConstitMolalFract(3) = Ndot02 / FuelCell(GeneratorNum).FCPM.NdotProdGas; + this->FCPM.ConstitMolalFract(3) = Ndot02 / this->FCPM.NdotProdGas; // all the H20 comming in plus the new H20 from reactions and the H20 from water used in reforming - FuelCell(GeneratorNum).FCPM.ConstitMolalFract(4) = NdotH20 / FuelCell(GeneratorNum).FCPM.NdotProdGas; + this->FCPM.ConstitMolalFract(4) = NdotH20 / this->FCPM.NdotProdGas; // all the argon coming in. - FuelCell(GeneratorNum).FCPM.ConstitMolalFract(5) = NdotAr / FuelCell(GeneratorNum).FCPM.NdotProdGas; + this->FCPM.ConstitMolalFract(5) = NdotAr / this->FCPM.NdotProdGas; // HmolProdGases KJ/mol) Real64 HmolProdGases; // enthalpy of product gas mixture in KJ/mol - FuelCell(GeneratorNum).FigureProductGasesEnthalpy(FuelCell(GeneratorNum).FCPM.TprodGasLeavingFCPM, HmolProdGases); + this->FigureProductGasesEnthalpy(this->FCPM.TprodGasLeavingFCPM, HmolProdGases); // units, NdotProdGas in kmol/sec.; HmolProdGases in KJ/mol , // factor of 1000's to get to J/s or watts - FuelCell(GeneratorNum).FCPM.TotProdGasEnthalphy = HmolProdGases * 1000.0 * FuelCell(GeneratorNum).FCPM.NdotProdGas * 1000.0; + this->FCPM.TotProdGasEnthalphy = HmolProdGases * 1000.0 * this->FCPM.NdotProdGas * 1000.0; // calculation Step 9, Figure Skin lossess - if (FuelCell(GeneratorNum).FCPM.SkinLossMode == DataGenerators::ConstantRateSkinLoss) { + if (this->FCPM.SkinLossMode == DataGenerators::ConstantRateSkinLoss) { // do nothing just use QdotSkin - } else if (FuelCell(GeneratorNum).FCPM.SkinLossMode == DataGenerators::UADTSkinLoss) { + } else if (this->FCPM.SkinLossMode == DataGenerators::UADTSkinLoss) { // get zone air temp - if (FuelCell(GeneratorNum).FCPM.ZoneID > 0) { - FuelCell(GeneratorNum).FCPM.QdotSkin = FuelCell(GeneratorNum).FCPM.UAskin * - (FuelCell(GeneratorNum).FCPM.TprodGasLeavingFCPM - DataHeatBalFanSys::ZT(FuelCell(GeneratorNum).FCPM.ZoneID)); + if (this->FCPM.ZoneID > 0) { + this->FCPM.QdotSkin = this->FCPM.UAskin * + (this->FCPM.TprodGasLeavingFCPM - DataHeatBalFanSys::ZT(this->FCPM.ZoneID)); } - } else if (FuelCell(GeneratorNum).FCPM.SkinLossMode == DataGenerators::QuadraticFuelNdotSkin) { + } else if (this->FCPM.SkinLossMode == DataGenerators::QuadraticFuelNdotSkin) { - FuelCell(GeneratorNum).FCPM.QdotSkin = CurveManager::CurveValue(FuelCell(GeneratorNum).FCPM.SkinLossCurveID, FuelCell(GeneratorNum).FCPM.NdotFuel); + this->FCPM.QdotSkin = CurveManager::CurveValue(this->FCPM.SkinLossCurveID, this->FCPM.NdotFuel); } // calculation Step 10, AC FCPM power ancillaries - FuelCell(GeneratorNum).FCPM.PelancillariesAC = - FuelCell(GeneratorNum).FCPM.ANC0 + FuelCell(GeneratorNum).FCPM.ANC1 * FuelCell(GeneratorNum).FCPM.NdotFuel; + this->FCPM.PelancillariesAC = + this->FCPM.ANC0 + this->FCPM.ANC1 * this->FCPM.NdotFuel; // calculation Step 11, Dilution air - FuelCell(GeneratorNum).FigureAirEnthalpy(FuelCell(GeneratorNum).AirSup.TairIntoBlower, Hmolair); // (Hmolair in KJ/mol) + this->FigureAirEnthalpy(this->AirSup.TairIntoBlower, Hmolair); // (Hmolair in KJ/mol) // units, NdotDilutionAir in kmol/sec.; Hmolair in KJ/mol , // factor of 1000's to get to J/s or watts - FuelCell(GeneratorNum).FCPM.DilutionAirInEnthalpy = Hmolair * 1000.0 * FuelCell(GeneratorNum).FCPM.NdotDilutionAir * 1000.0; - FuelCell(GeneratorNum).FCPM.DilutionAirOutEnthalpy = - FuelCell(GeneratorNum).FCPM.DilutionAirInEnthalpy + FuelCell(GeneratorNum).FCPM.StackHeatLossToDilution; + this->FCPM.DilutionAirInEnthalpy = Hmolair * 1000.0 * this->FCPM.NdotDilutionAir * 1000.0; + this->FCPM.DilutionAirOutEnthalpy = + this->FCPM.DilutionAirInEnthalpy + this->FCPM.StackHeatLossToDilution; // calculation Step 12, Calculate Reforming water out enthalpy Real64 HGasWater; // temp enthalpy of gaseous water in KJ/mol No Formation - FigureGaseousWaterEnthalpy(FuelCell(GeneratorNum).FCPM.TprodGasLeavingFCPM, HGasWater); + FigureGaseousWaterEnthalpy(this->FCPM.TprodGasLeavingFCPM, HGasWater); - FuelCell(GeneratorNum).FCPM.WaterOutEnthalpy = HGasWater * 1000.0 * FuelCell(GeneratorNum).FCPM.NdotLiqwater * 1000.0; + this->FCPM.WaterOutEnthalpy = HGasWater * 1000.0 * this->FCPM.NdotLiqwater * 1000.0; // calculation Step 13, Calculate Heat balance // move all terms in Equation 7 to RHS and calculate imbalance - Real64 MagofImbalance = -FuelCell(GeneratorNum).FCPM.TotFuelInEnthalphy - FuelCell(GeneratorNum).FCPM.TotAirInEnthalphy - - FuelCell(GeneratorNum).FCPM.WaterInEnthalpy - FuelCell(GeneratorNum).FCPM.DilutionAirInEnthalpy - - FuelCell(GeneratorNum).FCPM.NdotFuel * DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).LHV * 1000000.0 - - FuelCell(GeneratorNum).FCPM.PelancillariesAC + FuelCell(GeneratorNum).FCPM.Pel + - FuelCell(GeneratorNum).FCPM.TotProdGasEnthalphy + FuelCell(GeneratorNum).FCPM.WaterOutEnthalpy + - FuelCell(GeneratorNum).FCPM.QdotStackCool + FuelCell(GeneratorNum).FCPM.QdotSkin + - FuelCell(GeneratorNum).FCPM.DilutionAirOutEnthalpy; + Real64 MagofImbalance = -this->FCPM.TotFuelInEnthalphy - this->FCPM.TotAirInEnthalphy - + this->FCPM.WaterInEnthalpy - this->FCPM.DilutionAirInEnthalpy - + this->FCPM.NdotFuel * DataGenerators::FuelSupply(this->FuelSupNum).LHV * 1000000.0 - + this->FCPM.PelancillariesAC + this->FCPM.Pel + + this->FCPM.TotProdGasEnthalphy + this->FCPM.WaterOutEnthalpy + + this->FCPM.QdotStackCool + this->FCPM.QdotSkin + + this->FCPM.DilutionAirOutEnthalpy; // Now find a new total prod Gas Enthalphy that would result in an energy balance // TODO check signs... - Real64 tmpTotProdGasEnthalpy = FuelCell(GeneratorNum).FCPM.TotProdGasEnthalphy - MagofImbalance; + Real64 tmpTotProdGasEnthalpy = this->FCPM.TotProdGasEnthalphy - MagofImbalance; // solve for a new TprodGasLeavingFCPM using regula falsi method @@ -1821,9 +1815,10 @@ namespace FuelCellElectricGenerator { Array1D Par(3); // parameters passed in to SolveRoot Par(1) = double(GeneratorNum); Par(2) = tmpTotProdGasEnthalpy; - Par(3) = FuelCell(GeneratorNum).FCPM.NdotProdGas; - Real64 tmpTprodGas = FuelCell(GeneratorNum).FCPM.TprodGasLeavingFCPM; - General::SolveRoot(Acc, MaxIter, SolverFlag, tmpTprodGas, FuelCellProductGasEnthResidual, DataGenerators::MinProductGasTemp, DataGenerators::MaxProductGasTemp, Par); + Par(3) = this->FCPM.NdotProdGas; + Real64 tmpTprodGas = this->FCPM.TprodGasLeavingFCPM; + auto boundFunc = std::bind(&FCDataStruct::FuelCellProductGasEnthResidual, this, std::placeholders::_1, std::placeholders::_2); + General::SolveRoot(Acc, MaxIter, SolverFlag, tmpTprodGas, boundFunc, DataGenerators::MinProductGasTemp, DataGenerators::MaxProductGasTemp, Par); if (SolverFlag == -2) { @@ -1833,7 +1828,7 @@ namespace FuelCellElectricGenerator { ShowWarningError("CalcFuelCellGeneratorModel: Root Solver problem, flag = -1, check accuracy and iterations, did not converge"); } if (SolverFlag > 0) { - FuelCell(GeneratorNum).FCPM.TprodGasLeavingFCPM = tmpTprodGas; + this->FCPM.TprodGasLeavingFCPM = tmpTprodGas; // write(*,*) 'Number of Root Solver iterations: ', solverFlag } @@ -1847,38 +1842,38 @@ namespace FuelCellElectricGenerator { PintoInverter = Pel - Pstorage; // refine power conditioning losses with more current power production - if (FuelCell(GeneratorNum).Inverter.EffMode == DataGenerators::InverterEffConstant) { + if (this->Inverter.EffMode == DataGenerators::InverterEffConstant) { - PpcuLosses = (1.0 - FuelCell(GeneratorNum).Inverter.ConstEff) * PintoInverter; + PpcuLosses = (1.0 - this->Inverter.ConstEff) * PintoInverter; } - if (FuelCell(GeneratorNum).Inverter.EffMode == DataGenerators::InverterEffQuadratic) { + if (this->Inverter.EffMode == DataGenerators::InverterEffQuadratic) { - PpcuLosses = (1.0 - CurveManager::CurveValue(FuelCell(GeneratorNum).Inverter.EffQuadraticCurveID, PintoInverter)) * PintoInverter; + PpcuLosses = (1.0 - CurveManager::CurveValue(this->Inverter.EffQuadraticCurveID, PintoInverter)) * PintoInverter; } PoutofInverter = PintoInverter - PpcuLosses; - FuelCell(GeneratorNum).ACPowerGen = PoutofInverter - FuelCell(GeneratorNum).FCPM.PelancillariesAC - - FuelCell(GeneratorNum).AirSup.PairCompEl - DataGenerators::FuelSupply(FuelCell(GeneratorNum).FuelSupNum).PfuelCompEl - - FuelCell(GeneratorNum).WaterSup.PwaterCompEl; - FuelCell(GeneratorNum).Inverter.PCUlosses = PpcuLosses; + this->ACPowerGen = PoutofInverter - this->FCPM.PelancillariesAC - + this->AirSup.PairCompEl - DataGenerators::FuelSupply(this->FuelSupNum).PfuelCompEl - + this->WaterSup.PwaterCompEl; + this->Inverter.PCUlosses = PpcuLosses; // model assumes air intake is drawn over power conditioner to recovery heat - FuelCell(GeneratorNum).Inverter.QairIntake = FuelCell(GeneratorNum).Inverter.PCUlosses; + this->Inverter.QairIntake = this->Inverter.PCUlosses; - CalcFuelCellAuxHeater(GeneratorNum); + this->CalcFuelCellAuxHeater(); - CalcFuelCellGenHeatRecovery(GeneratorNum); + this->CalcFuelCellGenHeatRecovery(); // calculation Step 11, If imbalance below threshold, then exit out of do loop. - if ((std::abs(MagofImbalance) < std::abs(DataGenerators::ImBalanceTol * FuelCell(GeneratorNum).FCPM.Pel)) && (iter > 2)) { + if ((std::abs(MagofImbalance) < std::abs(DataGenerators::ImBalanceTol * this->FCPM.Pel)) && (iter > 2)) { break; } } // sequential substitution loop - FuelCell(GeneratorNum).FCPM.SeqSubstitIter = iter; - FuelCell(GeneratorNum).FCPM.RegulaFalsiIter = SolverFlag; + this->FCPM.SeqSubstitIter = iter; + this->FCPM.RegulaFalsiIter = SolverFlag; } void ManageElectStorInteractions(int const Num, // Generator number, index for structure @@ -2040,7 +2035,7 @@ namespace FuelCellElectricGenerator { } } - Real64 FuelCellProductGasEnthResidual(Real64 const TprodGas, // temperature, this is "x" being searched + Real64 FCDataStruct::FuelCellProductGasEnthResidual(Real64 const TprodGas, // temperature, this is "x" being searched Array1 const &Par // par(1) = Generator Number ) { @@ -2602,7 +2597,7 @@ namespace FuelCellElectricGenerator { Cp = tempCp; } - void FigureGaseousWaterEnthalpy(Real64 const FluidTemp, // degree C + void FCDataStruct::FigureGaseousWaterEnthalpy(Real64 const FluidTemp, // degree C Real64 &HGasWater // kJ/mol ) { @@ -2631,7 +2626,7 @@ namespace FuelCellElectricGenerator { HGasWater = A * Tsho + B * pow_2(Tsho) / 2.0 + C * pow_3(Tsho) / 3.0 + D * pow_4(Tsho) / 4.0 - E / Tsho + F; //- H } - void FigureLiquidWaterEnthalpy(Real64 const FluidTemp, // degree C + void FCDataStruct::FigureLiquidWaterEnthalpy(Real64 const FluidTemp, // degree C Real64 &HLiqWater // kJ/mol ) { @@ -2661,7 +2656,7 @@ namespace FuelCellElectricGenerator { HLiqWater = A * Tsho + B * pow_2(Tsho) / 2.0 + C * pow_3(Tsho) / 3.0 + D * pow_4(Tsho) / 4.0 - E / Tsho + F; //- H } - void FigureLiquidWaterHeatCap(Real64 const FluidTemp, // degree C + void FCDataStruct::FigureLiquidWaterHeatCap(Real64 const FluidTemp, // degree C Real64 &Cp // (J/mol*K) ) { @@ -2836,18 +2831,18 @@ namespace FuelCellElectricGenerator { } } - void CalcFuelCellAuxHeater(int const Num) // Generator number + void FCDataStruct::CalcFuelCellAuxHeater() // Generator number { // not yet implemented, just pass product gases thru nul domain - FuelCell(Num).AuxilHeat.TauxMix = FuelCell(Num).FCPM.TprodGasLeavingFCPM; - FuelCell(Num).AuxilHeat.NdotAuxMix = FuelCell(Num).FCPM.NdotProdGas; - FuelCell(Num).AuxilHeat.ConstitMolalFract = FuelCell(Num).FCPM.ConstitMolalFract; - FuelCell(Num).AuxilHeat.GasLibID = FuelCell(Num).FCPM.GasLibID; + this->AuxilHeat.TauxMix = this->FCPM.TprodGasLeavingFCPM; + this->AuxilHeat.NdotAuxMix = this->FCPM.NdotProdGas; + this->AuxilHeat.ConstitMolalFract = this->FCPM.ConstitMolalFract; + this->AuxilHeat.GasLibID = this->FCPM.GasLibID; } - void CalcFuelCellGenHeatRecovery(int const Num) // Generator number + void FCDataStruct::CalcFuelCellGenHeatRecovery() // Generator number { // SUBROUTINE INFORMATION: // AUTHOR: Brent Griffith @@ -2864,189 +2859,189 @@ namespace FuelCellElectricGenerator { static std::string const RoutineName("CalcFuelCellGenHeatRecovery"); { - auto const SELECT_CASE_var(FuelCell(Num).ExhaustHX.HXmodelMode); + auto const SELECT_CASE_var(this->ExhaustHX.HXmodelMode); if (SELECT_CASE_var == DataGenerators::FixedEffectiveness) { // Method 1 - Real64 eHX = FuelCell(Num).ExhaustHX.HXEffect; + Real64 eHX = this->ExhaustHX.HXEffect; Real64 MWwater = DataGenerators::GasPhaseThermoChemistryData(4).MolecularWeight; - Real64 NdotWater = FuelCell(Num).ExhaustHX.WaterMassFlowRate / MWwater; - Real64 TwaterIn = FuelCell(Num).ExhaustHX.WaterInletTemp; + Real64 NdotWater = this->ExhaustHX.WaterMassFlowRate / MWwater; + Real64 TwaterIn = this->ExhaustHX.WaterInletTemp; Real64 CpWaterMol; FigureLiquidWaterHeatCap(TwaterIn, CpWaterMol); - Real64 NdotGas = FuelCell(Num).AuxilHeat.NdotAuxMix; - Real64 TprodGasIn = FuelCell(Num).AuxilHeat.TauxMix; + Real64 NdotGas = this->AuxilHeat.NdotAuxMix; + Real64 TprodGasIn = this->AuxilHeat.TauxMix; Real64 CpProdGasMol; - FuelCell(Num).FigureAuxilHeatGasHeatCap(TprodGasIn, CpProdGasMol); // Cp in (J/mol*K) + this->FigureAuxilHeatGasHeatCap(TprodGasIn, CpProdGasMol); // Cp in (J/mol*K) // factor of 1000.0 for kmol -> mol Real64 NdotCp = min(NdotGas * CpProdGasMol * 1000.0, NdotWater * CpWaterMol * 1000.0); - FuelCell(Num).ExhaustHX.qHX = eHX * NdotCp * (TprodGasIn - TwaterIn); + this->ExhaustHX.qHX = eHX * NdotCp * (TprodGasIn - TwaterIn); - FuelCell(Num).ExhaustHX.THXexh = TprodGasIn - FuelCell(Num).ExhaustHX.qHX / (NdotGas * CpProdGasMol * 1000.0); + this->ExhaustHX.THXexh = TprodGasIn - this->ExhaustHX.qHX / (NdotGas * CpProdGasMol * 1000.0); Real64 Cp = FluidProperties::GetSpecificHeatGlycol( - DataPlant::PlantLoop(FuelCell(Num).CWLoopNum).FluidName, TwaterIn, DataPlant::PlantLoop(FuelCell(Num).CWLoopNum).FluidIndex, RoutineName); + DataPlant::PlantLoop(this->CWLoopNum).FluidName, TwaterIn, DataPlant::PlantLoop(this->CWLoopNum).FluidIndex, RoutineName); - if (FuelCell(Num).ExhaustHX.WaterMassFlowRate * Cp <= 0.0) { - FuelCell(Num).ExhaustHX.WaterOutletTemp = TwaterIn; + if (this->ExhaustHX.WaterMassFlowRate * Cp <= 0.0) { + this->ExhaustHX.WaterOutletTemp = TwaterIn; } else { - FuelCell(Num).ExhaustHX.WaterOutletTemp = TwaterIn + FuelCell(Num).ExhaustHX.qHX / (FuelCell(Num).ExhaustHX.WaterMassFlowRate * Cp); + this->ExhaustHX.WaterOutletTemp = TwaterIn + this->ExhaustHX.qHX / (this->ExhaustHX.WaterMassFlowRate * Cp); } } else if (SELECT_CASE_var == DataGenerators::LMTDempiricalUAeff) { // method 2 Real64 MWwater = DataGenerators::GasPhaseThermoChemistryData(4).MolecularWeight; - Real64 NdotWater = FuelCell(Num).ExhaustHX.WaterMassFlowRate / MWwater; - Real64 NdotGas = FuelCell(Num).AuxilHeat.NdotAuxMix; + Real64 NdotWater = this->ExhaustHX.WaterMassFlowRate / MWwater; + Real64 NdotGas = this->AuxilHeat.NdotAuxMix; - Real64 UAeff = FuelCell(Num).ExhaustHX.hxs0 + FuelCell(Num).ExhaustHX.hxs1 * NdotWater + FuelCell(Num).ExhaustHX.hxs2 * pow_2(NdotWater) + - FuelCell(Num).ExhaustHX.hxs3 * NdotGas + FuelCell(Num).ExhaustHX.hxs4 * pow_2(NdotGas); + Real64 UAeff = this->ExhaustHX.hxs0 + this->ExhaustHX.hxs1 * NdotWater + this->ExhaustHX.hxs2 * pow_2(NdotWater) + + this->ExhaustHX.hxs3 * NdotGas + this->ExhaustHX.hxs4 * pow_2(NdotGas); - Real64 TauxMix = FuelCell(Num).AuxilHeat.TauxMix; - Real64 TwaterIn = FuelCell(Num).ExhaustHX.WaterInletTemp; + Real64 TauxMix = this->AuxilHeat.TauxMix; + Real64 TwaterIn = this->ExhaustHX.WaterInletTemp; Real64 CpWaterMol; FigureLiquidWaterHeatCap(TwaterIn, CpWaterMol); // factor of 1000.0 for kmol -> mol Real64 NdotCpWater = NdotWater * CpWaterMol * 1000.0; Real64 CpProdGasMol; - FuelCell(Num).FigureAuxilHeatGasHeatCap(TauxMix, CpProdGasMol); // Cp in (J/mol*K) + this->FigureAuxilHeatGasHeatCap(TauxMix, CpProdGasMol); // Cp in (J/mol*K) Real64 NdotCpAuxMix = NdotGas * CpProdGasMol * 1000.0; if ((NdotCpWater != 0.0) && (NdotCpAuxMix != 0.0)) { // trap divide by zero // now evaluate Eq. 44 - FuelCell(Num).ExhaustHX.THXexh = ((1.0 - NdotCpAuxMix / NdotCpWater) / + this->ExhaustHX.THXexh = ((1.0 - NdotCpAuxMix / NdotCpWater) / (std::exp(UAeff * (1.0 / NdotCpAuxMix - 1.0 / NdotCpWater)) - NdotCpAuxMix / NdotCpWater)) * TauxMix + ((std::exp(UAeff * (1.0 / NdotCpAuxMix - 1.0 / NdotCpWater)) - 1.0) / (std::exp(UAeff * (1.0 / NdotCpAuxMix - 1.0 / NdotCpWater)) - NdotCpAuxMix / NdotCpWater)) * TwaterIn; - FuelCell(Num).ExhaustHX.WaterOutletTemp = TwaterIn + (NdotCpAuxMix / NdotCpWater) * (TauxMix - FuelCell(Num).ExhaustHX.THXexh); // Eq. 42 + this->ExhaustHX.WaterOutletTemp = TwaterIn + (NdotCpAuxMix / NdotCpWater) * (TauxMix - this->ExhaustHX.THXexh); // Eq. 42 } else { - FuelCell(Num).ExhaustHX.THXexh = TauxMix; - FuelCell(Num).ExhaustHX.WaterOutletTemp = TwaterIn; + this->ExhaustHX.THXexh = TauxMix; + this->ExhaustHX.WaterOutletTemp = TwaterIn; } // ENDIF - if ((FuelCell(Num).ExhaustHX.THXexh - TwaterIn) != 0.0) { // trap divide by zero - FuelCell(Num).ExhaustHX.qHX = UAeff * ((TauxMix - FuelCell(Num).ExhaustHX.WaterOutletTemp) - (FuelCell(Num).ExhaustHX.THXexh - TwaterIn)) / std::log((TauxMix - FuelCell(Num).ExhaustHX.WaterOutletTemp) / (FuelCell(Num).ExhaustHX.THXexh - TwaterIn)); + if ((this->ExhaustHX.THXexh - TwaterIn) != 0.0) { // trap divide by zero + this->ExhaustHX.qHX = UAeff * ((TauxMix - this->ExhaustHX.WaterOutletTemp) - (this->ExhaustHX.THXexh - TwaterIn)) / std::log((TauxMix - this->ExhaustHX.WaterOutletTemp) / (this->ExhaustHX.THXexh - TwaterIn)); } else { - FuelCell(Num).ExhaustHX.qHX = 0.0; + this->ExhaustHX.qHX = 0.0; } } else if (SELECT_CASE_var == DataGenerators::LMTDfundementalUAeff) { // method 3 - Real64 NdotGas = FuelCell(Num).AuxilHeat.NdotAuxMix; + Real64 NdotGas = this->AuxilHeat.NdotAuxMix; Real64 MWwater = DataGenerators::GasPhaseThermoChemistryData(4).MolecularWeight; - Real64 NdotWater = FuelCell(Num).ExhaustHX.WaterMassFlowRate / MWwater; + Real64 NdotWater = this->ExhaustHX.WaterMassFlowRate / MWwater; - Real64 hgas = FuelCell(Num).ExhaustHX.h0gas * std::pow(NdotGas / FuelCell(Num).ExhaustHX.NdotGasRef, FuelCell(Num).ExhaustHX.nCoeff); // Eq. 48 - Real64 hwater = FuelCell(Num).ExhaustHX.h0Water * - std::pow(NdotWater / FuelCell(Num).ExhaustHX.NdotWaterRef, FuelCell(Num).ExhaustHX.mCoeff); // Eq. 48 + Real64 hgas = this->ExhaustHX.h0gas * std::pow(NdotGas / this->ExhaustHX.NdotGasRef, this->ExhaustHX.nCoeff); // Eq. 48 + Real64 hwater = this->ExhaustHX.h0Water * + std::pow(NdotWater / this->ExhaustHX.NdotWaterRef, this->ExhaustHX.mCoeff); // Eq. 48 // now equation 47 - Real64 UAeff = 1.0 / (1.0 / (hgas * FuelCell(Num).ExhaustHX.AreaGas) + 1.0 / (hwater * FuelCell(Num).ExhaustHX.AreaWater) + - FuelCell(Num).ExhaustHX.Fadjust); + Real64 UAeff = 1.0 / (1.0 / (hgas * this->ExhaustHX.AreaGas) + 1.0 / (hwater * this->ExhaustHX.AreaWater) + + this->ExhaustHX.Fadjust); - Real64 TauxMix = FuelCell(Num).AuxilHeat.TauxMix; - Real64 TwaterIn = FuelCell(Num).ExhaustHX.WaterInletTemp; + Real64 TauxMix = this->AuxilHeat.TauxMix; + Real64 TwaterIn = this->ExhaustHX.WaterInletTemp; Real64 CpWaterMol; FigureLiquidWaterHeatCap(TwaterIn, CpWaterMol); Real64 NdotCpWater = NdotWater * CpWaterMol * 1000.0; Real64 CpProdGasMol; - FuelCell(Num).FigureAuxilHeatGasHeatCap(TauxMix, CpProdGasMol); // Cp in (J/mol*K) + this->FigureAuxilHeatGasHeatCap(TauxMix, CpProdGasMol); // Cp in (J/mol*K) Real64 NdotCpAuxMix = NdotGas * CpProdGasMol * 1000.0; if ((NdotCpWater != 0.0) && (NdotCpAuxMix != 0.0)) { // trap divide by zero // now evaluate Eq. 44 - FuelCell(Num).ExhaustHX.THXexh = ((1.0 - NdotCpAuxMix / NdotCpWater) / + this->ExhaustHX.THXexh = ((1.0 - NdotCpAuxMix / NdotCpWater) / (std::exp(UAeff * (1.0 / NdotCpAuxMix - 1.0 / NdotCpWater)) - NdotCpAuxMix / NdotCpWater)) * TauxMix + ((std::exp(UAeff * (1.0 / NdotCpAuxMix - 1.0 / NdotCpWater)) - 1.0) / (std::exp(UAeff * (1.0 / NdotCpAuxMix - 1.0 / NdotCpWater)) - NdotCpAuxMix / NdotCpWater)) * TwaterIn; - FuelCell(Num).ExhaustHX.WaterOutletTemp = TwaterIn + (NdotCpAuxMix / NdotCpWater) * (TauxMix - FuelCell(Num).ExhaustHX.THXexh); // Eq. 42 + this->ExhaustHX.WaterOutletTemp = TwaterIn + (NdotCpAuxMix / NdotCpWater) * (TauxMix - this->ExhaustHX.THXexh); // Eq. 42 } else { - FuelCell(Num).ExhaustHX.THXexh = TauxMix; - FuelCell(Num).ExhaustHX.WaterOutletTemp = TwaterIn; + this->ExhaustHX.THXexh = TauxMix; + this->ExhaustHX.WaterOutletTemp = TwaterIn; } - if ((FuelCell(Num).ExhaustHX.THXexh - TwaterIn) != 0.0) { // trap divide by zero - FuelCell(Num).ExhaustHX.qHX = UAeff * ((TauxMix - FuelCell(Num).ExhaustHX.WaterOutletTemp) - (FuelCell(Num).ExhaustHX.THXexh - TwaterIn)) / std::log((TauxMix - FuelCell(Num).ExhaustHX.WaterOutletTemp) / (FuelCell(Num).ExhaustHX.THXexh - TwaterIn)); + if ((this->ExhaustHX.THXexh - TwaterIn) != 0.0) { // trap divide by zero + this->ExhaustHX.qHX = UAeff * ((TauxMix - this->ExhaustHX.WaterOutletTemp) - (this->ExhaustHX.THXexh - TwaterIn)) / std::log((TauxMix - this->ExhaustHX.WaterOutletTemp) / (this->ExhaustHX.THXexh - TwaterIn)); } else { - FuelCell(Num).ExhaustHX.qHX = 0.0; + this->ExhaustHX.qHX = 0.0; } } else if (SELECT_CASE_var == DataGenerators::Condensing) { // method 4 - if (FuelCell(Num).ExhaustHX.WaterMassFlowRate != 0.0) { + if (this->ExhaustHX.WaterMassFlowRate != 0.0) { Real64 MWwater = DataGenerators::GasPhaseThermoChemistryData(4).MolecularWeight; - Real64 NdotWater = FuelCell(Num).ExhaustHX.WaterMassFlowRate / MWwater; - Real64 NdotGas = FuelCell(Num).AuxilHeat.NdotAuxMix; + Real64 NdotWater = this->ExhaustHX.WaterMassFlowRate / MWwater; + Real64 NdotGas = this->AuxilHeat.NdotAuxMix; - Real64 UAeff = FuelCell(Num).ExhaustHX.hxs0 + FuelCell(Num).ExhaustHX.hxs1 * NdotWater + - FuelCell(Num).ExhaustHX.hxs2 * pow_2(NdotWater) + FuelCell(Num).ExhaustHX.hxs3 * NdotGas + - FuelCell(Num).ExhaustHX.hxs4 * pow_2(NdotGas); + Real64 UAeff = this->ExhaustHX.hxs0 + this->ExhaustHX.hxs1 * NdotWater + + this->ExhaustHX.hxs2 * pow_2(NdotWater) + this->ExhaustHX.hxs3 * NdotGas + + this->ExhaustHX.hxs4 * pow_2(NdotGas); - Real64 TauxMix = FuelCell(Num).AuxilHeat.TauxMix; - Real64 TwaterIn = FuelCell(Num).ExhaustHX.WaterInletTemp; + Real64 TauxMix = this->AuxilHeat.TauxMix; + Real64 TwaterIn = this->ExhaustHX.WaterInletTemp; Real64 CpWaterMol; FigureLiquidWaterHeatCap(TwaterIn, CpWaterMol); Real64 NdotCpWater = NdotWater * CpWaterMol * 1000.0; Real64 CpProdGasMol; - FuelCell(Num).FigureAuxilHeatGasHeatCap(TauxMix, CpProdGasMol); // Cp in (J/mol*K) + this->FigureAuxilHeatGasHeatCap(TauxMix, CpProdGasMol); // Cp in (J/mol*K) Real64 NdotCpAuxMix = NdotGas * CpProdGasMol * 1000.0; // find water fraction in incoming gas stream - for (int i = 1; i <= isize(FuelCell(Num).AuxilHeat.GasLibID); ++i) { - if (FuelCell(Num).AuxilHeat.GasLibID(i) == 4) FuelCell(Num).ExhaustHX.WaterVaporFractExh = FuelCell(Num).AuxilHeat.ConstitMolalFract(i); + for (int i = 1; i <= isize(this->AuxilHeat.GasLibID); ++i) { + if (this->AuxilHeat.GasLibID(i) == 4) this->ExhaustHX.WaterVaporFractExh = this->AuxilHeat.ConstitMolalFract(i); } - Real64 NdotWaterVapor = FuelCell(Num).ExhaustHX.WaterVaporFractExh * NdotGas; + Real64 NdotWaterVapor = this->ExhaustHX.WaterVaporFractExh * NdotGas; - Real64 TcondThresh = FuelCell(Num).ExhaustHX.CondensationThresholdTemp; - Real64 hxl1 = FuelCell(Num).ExhaustHX.l1Coeff; - Real64 hxl2 = FuelCell(Num).ExhaustHX.l2Coeff; + Real64 TcondThresh = this->ExhaustHX.CondensationThresholdTemp; + Real64 hxl1 = this->ExhaustHX.l1Coeff; + Real64 hxl2 = this->ExhaustHX.l2Coeff; - FuelCell(Num).ExhaustHX.CondensateRate = (TcondThresh - TwaterIn) * (hxl1 * (NdotWaterVapor / NdotGas) + hxl2 * pow_2(NdotWaterVapor / NdotGas)); + this->ExhaustHX.CondensateRate = (TcondThresh - TwaterIn) * (hxl1 * (NdotWaterVapor / NdotGas) + hxl2 * pow_2(NdotWaterVapor / NdotGas)); - if (FuelCell(Num).ExhaustHX.CondensateRate < 0.0) FuelCell(Num).ExhaustHX.CondensateRate = 0.0; + if (this->ExhaustHX.CondensateRate < 0.0) this->ExhaustHX.CondensateRate = 0.0; Real64 hfpwater = 4.4004e+07; // molal heat of vaporization of water J/kmol) if ((NdotCpWater != 0.0) && (NdotCpAuxMix != 0.0)) { // trap divide by zero // now evaluate Eq. 44 - FuelCell(Num).ExhaustHX.THXexh = ((1.0 - NdotCpAuxMix / NdotCpWater) / + this->ExhaustHX.THXexh = ((1.0 - NdotCpAuxMix / NdotCpWater) / (std::exp(UAeff * (1.0 / NdotCpAuxMix - 1.0 / NdotCpWater)) - NdotCpAuxMix / NdotCpWater)) * TauxMix + ((std::exp(UAeff * (1.0 / NdotCpAuxMix - 1.0 / NdotCpWater)) - 1.0) / (std::exp(UAeff * (1.0 / NdotCpAuxMix - 1.0 / NdotCpWater)) - NdotCpAuxMix / NdotCpWater)) * TwaterIn; - FuelCell(Num).ExhaustHX.WaterOutletTemp = TwaterIn + (NdotCpAuxMix / NdotCpWater) * (TauxMix - FuelCell(Num).ExhaustHX.THXexh) + (FuelCell(Num).ExhaustHX.CondensateRate * hfpwater) / NdotCpWater; + this->ExhaustHX.WaterOutletTemp = TwaterIn + (NdotCpAuxMix / NdotCpWater) * (TauxMix - this->ExhaustHX.THXexh) + (this->ExhaustHX.CondensateRate * hfpwater) / NdotCpWater; - if (FuelCell(Num).ExhaustHX.CondensateRate > 0) { // Eq. 44 is not correct. use its result as first guess for revised way... + if (this->ExhaustHX.CondensateRate > 0) { // Eq. 44 is not correct. use its result as first guess for revised way... // iterative solution because in condensing case THXexh is function of qSens and qLatent for (int loop = 1; loop <= 5; ++loop) { Real64 qSens; Real64 qLatent; - if ((FuelCell(Num).ExhaustHX.THXexh - TwaterIn) != 0.0 && - ((TauxMix - FuelCell(Num).ExhaustHX.WaterOutletTemp) / (FuelCell(Num).ExhaustHX.THXexh - TwaterIn) > 0.0001)) { // trap divide by zero and negative log + if ((this->ExhaustHX.THXexh - TwaterIn) != 0.0 && + ((TauxMix - this->ExhaustHX.WaterOutletTemp) / (this->ExhaustHX.THXexh - TwaterIn) > 0.0001)) { // trap divide by zero and negative log qSens = - UAeff * ((TauxMix - FuelCell(Num).ExhaustHX.WaterOutletTemp) - (FuelCell(Num).ExhaustHX.THXexh - TwaterIn)) / std::log((TauxMix - FuelCell(Num).ExhaustHX.WaterOutletTemp) / (FuelCell(Num).ExhaustHX.THXexh - TwaterIn)); + UAeff * ((TauxMix - this->ExhaustHX.WaterOutletTemp) - (this->ExhaustHX.THXexh - TwaterIn)) / std::log((TauxMix - this->ExhaustHX.WaterOutletTemp) / (this->ExhaustHX.THXexh - TwaterIn)); } else { qSens = 0.0; } - qLatent = FuelCell(Num).ExhaustHX.CondensateRate * hfpwater; + qLatent = this->ExhaustHX.CondensateRate * hfpwater; if (qSens > 0) { - FuelCell(Num).ExhaustHX.THXexh = + this->ExhaustHX.THXexh = TauxMix * ((1.0 - NdotCpAuxMix / NdotCpWater) / ((std::exp(UAeff * (1.0 / NdotCpAuxMix - 1.0 / NdotCpWater)) / (std::exp((UAeff * qLatent) / (NdotCpWater * qSens)))) - NdotCpAuxMix / NdotCpWater)) + @@ -3060,32 +3055,32 @@ namespace FuelCellElectricGenerator { (std::exp((UAeff * qLatent) / (NdotCpWater * qSens))) - NdotCpAuxMix / NdotCpWater)); } else { - FuelCell(Num).ExhaustHX.THXexh = TauxMix; + this->ExhaustHX.THXexh = TauxMix; } - FuelCell(Num).ExhaustHX.WaterOutletTemp = TwaterIn + (NdotCpAuxMix / NdotCpWater) * (TauxMix - FuelCell(Num).ExhaustHX.THXexh) + (FuelCell(Num).ExhaustHX.CondensateRate * hfpwater) / NdotCpWater; + this->ExhaustHX.WaterOutletTemp = TwaterIn + (NdotCpAuxMix / NdotCpWater) * (TauxMix - this->ExhaustHX.THXexh) + (this->ExhaustHX.CondensateRate * hfpwater) / NdotCpWater; } } } else { - FuelCell(Num).ExhaustHX.THXexh = TauxMix; - FuelCell(Num).ExhaustHX.WaterOutletTemp = TwaterIn; + this->ExhaustHX.THXexh = TauxMix; + this->ExhaustHX.WaterOutletTemp = TwaterIn; } - if ((FuelCell(Num).ExhaustHX.THXexh - TwaterIn) != 0.0 && - ((TauxMix - FuelCell(Num).ExhaustHX.WaterOutletTemp) / (FuelCell(Num).ExhaustHX.THXexh - TwaterIn) > 0.0001)) { // trap divide by zero and negative log + if ((this->ExhaustHX.THXexh - TwaterIn) != 0.0 && + ((TauxMix - this->ExhaustHX.WaterOutletTemp) / (this->ExhaustHX.THXexh - TwaterIn) > 0.0001)) { // trap divide by zero and negative log - FuelCell(Num).ExhaustHX.qHX = UAeff * ((TauxMix - FuelCell(Num).ExhaustHX.WaterOutletTemp) - (FuelCell(Num).ExhaustHX.THXexh - TwaterIn)) / std::log((TauxMix - FuelCell(Num).ExhaustHX.WaterOutletTemp) / (FuelCell(Num).ExhaustHX.THXexh - TwaterIn)) + - FuelCell(Num).ExhaustHX.CondensateRate * hfpwater; + this->ExhaustHX.qHX = UAeff * ((TauxMix - this->ExhaustHX.WaterOutletTemp) - (this->ExhaustHX.THXexh - TwaterIn)) / std::log((TauxMix - this->ExhaustHX.WaterOutletTemp) / (this->ExhaustHX.THXexh - TwaterIn)) + + this->ExhaustHX.CondensateRate * hfpwater; } else { - FuelCell(Num).ExhaustHX.qHX = 0.0; + this->ExhaustHX.qHX = 0.0; } } else { // no cooling water flow, model will blow up. - FuelCell(Num).ExhaustHX.qHX = 0.0; - FuelCell(Num).ExhaustHX.THXexh = FuelCell(Num).AuxilHeat.TauxMix; - FuelCell(Num).ExhaustHX.WaterOutletTemp = FuelCell(Num).ExhaustHX.WaterInletTemp; - FuelCell(Num).ExhaustHX.CondensateRate = 0.0; - FuelCell(Num).ExhaustHX.WaterVaporFractExh = -9999.0; // not defined + this->ExhaustHX.qHX = 0.0; + this->ExhaustHX.THXexh = this->AuxilHeat.TauxMix; + this->ExhaustHX.WaterOutletTemp = this->ExhaustHX.WaterInletTemp; + this->ExhaustHX.CondensateRate = 0.0; + this->ExhaustHX.WaterVaporFractExh = -9999.0; // not defined } } else { assert(false); // Variables not set are used below @@ -3093,7 +3088,7 @@ namespace FuelCellElectricGenerator { } // update results in data structure. - FuelCell(Num).ExhaustHX.WaterOutletEnthalpy = DataLoopNode::Node(FuelCell(Num).ExhaustHX.WaterInNode).Enthalpy + FuelCell(Num).ExhaustHX.qHX; + this->ExhaustHX.WaterOutletEnthalpy = DataLoopNode::Node(this->ExhaustHX.WaterInNode).Enthalpy + this->ExhaustHX.qHX; } void SimFuelCellPlantHeatRecovery(std::string const &EP_UNUSED(CompType), @@ -3165,7 +3160,7 @@ namespace FuelCellElectricGenerator { } } - void InitFuelCellGenerators(int const FCnum) // index to specific fuel cell generator + void FCDataStruct::InitFuelCellGenerators() // index to specific fuel cell generator { // SUBROUTINE INFORMATION: @@ -3185,19 +3180,19 @@ namespace FuelCellElectricGenerator { bool errFlag; // Do the one time initializations - if (FuelCell(FCnum).InitGenerator) { - FuelCell(FCnum).InitGenerator = false; + if (this->InitGenerator) { + this->InitGenerator = false; } // end one time setups and inits - if (FuelCell(FCnum).MyPlantScanFlag_Init && allocated(DataPlant::PlantLoop)) { + if (this->MyPlantScanFlag_Init && allocated(DataPlant::PlantLoop)) { errFlag = false; - PlantUtilities::ScanPlantLoopsForObject(FuelCell(FCnum).NameExhaustHX, + PlantUtilities::ScanPlantLoopsForObject(this->NameExhaustHX, DataPlant::TypeOf_Generator_FCExhaust, - FuelCell(FCnum).CWLoopNum, - FuelCell(FCnum).CWLoopSideNum, - FuelCell(FCnum).CWBranchNum, - FuelCell(FCnum).CWCompNum, + this->CWLoopNum, + this->CWLoopSideNum, + this->CWBranchNum, + this->CWCompNum, errFlag, _, _, @@ -3210,130 +3205,130 @@ namespace FuelCellElectricGenerator { if (errFlag) { ShowFatalError("InitFuelCellGenerators: Program terminated due to previous condition(s)."); } - FuelCell(FCnum).MyPlantScanFlag_Init = false; + this->MyPlantScanFlag_Init = false; } // Do the Begin Environment initializations - if (DataGlobals::BeginEnvrnFlag && FuelCell(FCnum).MyEnvrnFlag_Init && !FuelCell(FCnum).MyPlantScanFlag_Init) { - - DataGenerators::FuelSupply(FuelCell(FCnum).FuelSupNum).PfuelCompEl = 0.0; - DataGenerators::FuelSupply(FuelCell(FCnum).FuelSupNum).TfuelIntoFCPM = 0.0; - DataGenerators::FuelSupply(FuelCell(FCnum).FuelSupNum).TfuelIntoCompress = 0.0; - DataGenerators::FuelSupply(FuelCell(FCnum).FuelSupNum).QskinLoss = 0.0; - - FuelCell(FCnum).AirSup.TairIntoFCPM = 0.0; - FuelCell(FCnum).AirSup.PairCompEl = 0.0; - FuelCell(FCnum).AirSup.TairIntoBlower = 0.0; - FuelCell(FCnum).AirSup.QskinLoss = 0.0; - FuelCell(FCnum).AirSup.QintakeRecovery = 0.0; - FuelCell(FCnum).FCPM.NumCycles = 0; - FuelCell(FCnum).FCPM.Pel = 0.0; - FuelCell(FCnum).FCPM.PelLastTimeStep = 0.0; - FuelCell(FCnum).FCPM.Eel = 0.0; - FuelCell(FCnum).FCPM.PelancillariesAC = 0.0; - FuelCell(FCnum).FCPM.NdotFuel = 0.0; - FuelCell(FCnum).FCPM.TotFuelInEnthalphy = 0.0; - FuelCell(FCnum).FCPM.NdotProdGas = 0.0; - FuelCell(FCnum).FCPM.TprodGasLeavingFCPM = 0.0; - FuelCell(FCnum).FCPM.TotProdGasEnthalphy = 0.0; - FuelCell(FCnum).FCPM.NdotAir = 0.0; - FuelCell(FCnum).FCPM.TotAirInEnthalphy = 0.0; - FuelCell(FCnum).FCPM.NdotLiqwater = 0.0; - FuelCell(FCnum).FCPM.TwaterInlet = 0.0; - FuelCell(FCnum).FCPM.WaterInEnthalpy = 0.0; - FuelCell(FCnum).FCPM.TprodGasLeavingFCPM = 200.0; - FuelCell(FCnum).FCPM.FractionalDayofLastStartUp = 0.0; - FuelCell(FCnum).FCPM.FractionalDayofLastShutDown = 0.0; - FuelCell(FCnum).FCPM.HasBeenOn = true; - FuelCell(FCnum).FCPM.DuringShutDown = false; - FuelCell(FCnum).FCPM.DuringStartUp = false; - FuelCell(FCnum).WaterSup.TwaterIntoCompress = 0.0; - FuelCell(FCnum).WaterSup.TwaterIntoFCPM = 0.0; - FuelCell(FCnum).WaterSup.PwaterCompEl = 0.0; - FuelCell(FCnum).WaterSup.QskinLoss = 0.0; - FuelCell(FCnum).AuxilHeat.TauxMix = 0.0; - FuelCell(FCnum).AuxilHeat.NdotAuxMix = 0.0; - FuelCell(FCnum).AuxilHeat.QskinLoss = 0.0; - FuelCell(FCnum).AuxilHeat.QairIntake = 0.0; - FuelCell(FCnum).ExhaustHX.NdotHXleaving = 0.0; - FuelCell(FCnum).ExhaustHX.WaterOutletTemp = 0.0; - FuelCell(FCnum).ExhaustHX.WaterOutletEnthalpy = 0.0; - FuelCell(FCnum).ElecStorage.LastTimeStepStateOfCharge = FuelCell(FCnum).ElecStorage.StartingEnergyStored; - FuelCell(FCnum).ElecStorage.ThisTimeStepStateOfCharge = FuelCell(FCnum).ElecStorage.StartingEnergyStored; - FuelCell(FCnum).ElecStorage.PelNeedFromStorage = 0.0; - FuelCell(FCnum).ElecStorage.IdesiredDischargeCurrent = 0.0; - FuelCell(FCnum).ElecStorage.PelFromStorage = 0.0; - FuelCell(FCnum).ElecStorage.IfromStorage = 0.0; - FuelCell(FCnum).ElecStorage.PelIntoStorage = 0.0; - FuelCell(FCnum).ElecStorage.QairIntake = 0.0; - - FuelCell(FCnum).Inverter.PCUlosses = 0.0; - FuelCell(FCnum).Inverter.QairIntake = 0.0; + if (DataGlobals::BeginEnvrnFlag && this->MyEnvrnFlag_Init && !this->MyPlantScanFlag_Init) { + + DataGenerators::FuelSupply(this->FuelSupNum).PfuelCompEl = 0.0; + DataGenerators::FuelSupply(this->FuelSupNum).TfuelIntoFCPM = 0.0; + DataGenerators::FuelSupply(this->FuelSupNum).TfuelIntoCompress = 0.0; + DataGenerators::FuelSupply(this->FuelSupNum).QskinLoss = 0.0; + + this->AirSup.TairIntoFCPM = 0.0; + this->AirSup.PairCompEl = 0.0; + this->AirSup.TairIntoBlower = 0.0; + this->AirSup.QskinLoss = 0.0; + this->AirSup.QintakeRecovery = 0.0; + this->FCPM.NumCycles = 0; + this->FCPM.Pel = 0.0; + this->FCPM.PelLastTimeStep = 0.0; + this->FCPM.Eel = 0.0; + this->FCPM.PelancillariesAC = 0.0; + this->FCPM.NdotFuel = 0.0; + this->FCPM.TotFuelInEnthalphy = 0.0; + this->FCPM.NdotProdGas = 0.0; + this->FCPM.TprodGasLeavingFCPM = 0.0; + this->FCPM.TotProdGasEnthalphy = 0.0; + this->FCPM.NdotAir = 0.0; + this->FCPM.TotAirInEnthalphy = 0.0; + this->FCPM.NdotLiqwater = 0.0; + this->FCPM.TwaterInlet = 0.0; + this->FCPM.WaterInEnthalpy = 0.0; + this->FCPM.TprodGasLeavingFCPM = 200.0; + this->FCPM.FractionalDayofLastStartUp = 0.0; + this->FCPM.FractionalDayofLastShutDown = 0.0; + this->FCPM.HasBeenOn = true; + this->FCPM.DuringShutDown = false; + this->FCPM.DuringStartUp = false; + this->WaterSup.TwaterIntoCompress = 0.0; + this->WaterSup.TwaterIntoFCPM = 0.0; + this->WaterSup.PwaterCompEl = 0.0; + this->WaterSup.QskinLoss = 0.0; + this->AuxilHeat.TauxMix = 0.0; + this->AuxilHeat.NdotAuxMix = 0.0; + this->AuxilHeat.QskinLoss = 0.0; + this->AuxilHeat.QairIntake = 0.0; + this->ExhaustHX.NdotHXleaving = 0.0; + this->ExhaustHX.WaterOutletTemp = 0.0; + this->ExhaustHX.WaterOutletEnthalpy = 0.0; + this->ElecStorage.LastTimeStepStateOfCharge = this->ElecStorage.StartingEnergyStored; + this->ElecStorage.ThisTimeStepStateOfCharge = this->ElecStorage.StartingEnergyStored; + this->ElecStorage.PelNeedFromStorage = 0.0; + this->ElecStorage.IdesiredDischargeCurrent = 0.0; + this->ElecStorage.PelFromStorage = 0.0; + this->ElecStorage.IfromStorage = 0.0; + this->ElecStorage.PelIntoStorage = 0.0; + this->ElecStorage.QairIntake = 0.0; + + this->Inverter.PCUlosses = 0.0; + this->Inverter.QairIntake = 0.0; Real64 rho = FluidProperties::GetDensityGlycol( - DataPlant::PlantLoop(FuelCell(FCnum).CWLoopNum).FluidName, DataGenerators::InitHRTemp, DataPlant::PlantLoop(FuelCell(FCnum).CWLoopNum).FluidIndex, RoutineName); + DataPlant::PlantLoop(this->CWLoopNum).FluidName, DataGenerators::InitHRTemp, DataPlant::PlantLoop(this->CWLoopNum).FluidIndex, RoutineName); - FuelCell(FCnum).ExhaustHX.WaterMassFlowRateDesign = FuelCell(FCnum).ExhaustHX.WaterVolumeFlowMax * rho; - FuelCell(FCnum).ExhaustHX.WaterMassFlowRate = FuelCell(FCnum).ExhaustHX.WaterMassFlowRateDesign; - DataLoopNode::Node(FuelCell(FCnum).ExhaustHX.WaterInNode).Temp = DataGenerators::InitHRTemp; - DataLoopNode::Node(FuelCell(FCnum).ExhaustHX.WaterOutNode).Temp = DataGenerators::InitHRTemp; + this->ExhaustHX.WaterMassFlowRateDesign = this->ExhaustHX.WaterVolumeFlowMax * rho; + this->ExhaustHX.WaterMassFlowRate = this->ExhaustHX.WaterMassFlowRateDesign; + DataLoopNode::Node(this->ExhaustHX.WaterInNode).Temp = DataGenerators::InitHRTemp; + DataLoopNode::Node(this->ExhaustHX.WaterOutNode).Temp = DataGenerators::InitHRTemp; PlantUtilities::InitComponentNodes(0.0, - FuelCell(FCnum).ExhaustHX.WaterMassFlowRateDesign, - FuelCell(FCnum).ExhaustHX.WaterInNode, - FuelCell(FCnum).ExhaustHX.WaterOutNode, - FuelCell(FCnum).CWLoopNum, - FuelCell(FCnum).CWLoopSideNum, - FuelCell(FCnum).CWBranchNum, - FuelCell(FCnum).CWCompNum); - - FuelCell(FCnum).MyEnvrnFlag_Init = false; - FuelCell(FCnum).MyWarmupFlag_Init = true; + this->ExhaustHX.WaterMassFlowRateDesign, + this->ExhaustHX.WaterInNode, + this->ExhaustHX.WaterOutNode, + this->CWLoopNum, + this->CWLoopSideNum, + this->CWBranchNum, + this->CWCompNum); + + this->MyEnvrnFlag_Init = false; + this->MyWarmupFlag_Init = true; } // end environmental inits if (!DataGlobals::BeginEnvrnFlag) { - FuelCell(FCnum).MyEnvrnFlag_Init = true; + this->MyEnvrnFlag_Init = true; } - if (FuelCell(FCnum).MyWarmupFlag_Init && (!DataGlobals::WarmupFlag)) { + if (this->MyWarmupFlag_Init && (!DataGlobals::WarmupFlag)) { // need to reset initial state of charge at beginning of environment but after warm up is complete - FuelCell(FCnum).ElecStorage.LastTimeStepStateOfCharge = FuelCell(FCnum).ElecStorage.StartingEnergyStored; - FuelCell(FCnum).ElecStorage.ThisTimeStepStateOfCharge = FuelCell(FCnum).ElecStorage.StartingEnergyStored; - FuelCell(FCnum).MyWarmupFlag_Init = false; + this->ElecStorage.LastTimeStepStateOfCharge = this->ElecStorage.StartingEnergyStored; + this->ElecStorage.ThisTimeStepStateOfCharge = this->ElecStorage.StartingEnergyStored; + this->MyWarmupFlag_Init = false; } // using and elapsed time method rather than FirstHVACIteration here Real64 TimeElapsed = DataGlobals::HourOfDay + DataGlobals::TimeStep * DataGlobals::TimeStepZone + DataHVACGlobals::SysTimeElapsed; - if (FuelCell(FCnum).TimeElapsed != TimeElapsed) { + if (this->TimeElapsed != TimeElapsed) { - FuelCell(FCnum).ElecStorage.LastTimeStepStateOfCharge = FuelCell(FCnum).ElecStorage.ThisTimeStepStateOfCharge; - FuelCell(FCnum).FCPM.PelLastTimeStep = FuelCell(FCnum).FCPM.Pel; + this->ElecStorage.LastTimeStepStateOfCharge = this->ElecStorage.ThisTimeStepStateOfCharge; + this->FCPM.PelLastTimeStep = this->FCPM.Pel; // intialize flow rate in water loop, this is "requesting" flow - Real64 mdot = FuelCell(FCnum).ExhaustHX.WaterMassFlowRateDesign; + Real64 mdot = this->ExhaustHX.WaterMassFlowRateDesign; PlantUtilities::SetComponentFlowRate(mdot, - FuelCell(FCnum).ExhaustHX.WaterInNode, - FuelCell(FCnum).ExhaustHX.WaterOutNode, - FuelCell(FCnum).CWLoopNum, - FuelCell(FCnum).CWLoopSideNum, - FuelCell(FCnum).CWBranchNum, - FuelCell(FCnum).CWCompNum); - - FuelCell(FCnum).ExhaustHX.WaterMassFlowRate = mdot; - FuelCell(FCnum).ExhaustHX.WaterInletTemp = DataLoopNode::Node(FuelCell(FCnum).ExhaustHX.WaterInNode).Temp; - FuelCell(FCnum).TimeElapsed = TimeElapsed; + this->ExhaustHX.WaterInNode, + this->ExhaustHX.WaterOutNode, + this->CWLoopNum, + this->CWLoopSideNum, + this->CWBranchNum, + this->CWCompNum); + + this->ExhaustHX.WaterMassFlowRate = mdot; + this->ExhaustHX.WaterInletTemp = DataLoopNode::Node(this->ExhaustHX.WaterInNode).Temp; + this->TimeElapsed = TimeElapsed; } else { - PlantUtilities::SetComponentFlowRate(FuelCell(FCnum).ExhaustHX.WaterMassFlowRate, - FuelCell(FCnum).ExhaustHX.WaterInNode, - FuelCell(FCnum).ExhaustHX.WaterOutNode, - FuelCell(FCnum).CWLoopNum, - FuelCell(FCnum).CWLoopSideNum, - FuelCell(FCnum).CWBranchNum, - FuelCell(FCnum).CWCompNum); + PlantUtilities::SetComponentFlowRate(this->ExhaustHX.WaterMassFlowRate, + this->ExhaustHX.WaterInNode, + this->ExhaustHX.WaterOutNode, + this->CWLoopNum, + this->CWLoopSideNum, + this->CWBranchNum, + this->CWCompNum); - FuelCell(FCnum).ExhaustHX.WaterInletTemp = DataLoopNode::Node(FuelCell(FCnum).ExhaustHX.WaterInNode).Temp; + this->ExhaustHX.WaterInletTemp = DataLoopNode::Node(this->ExhaustHX.WaterInNode).Temp; } } @@ -3440,8 +3435,7 @@ namespace FuelCellElectricGenerator { } // over number of Fuel cells } - void CalcUpdateHeatRecovery(int const Num, // Generator number - bool const EP_UNUSED(FirstHVACIteration)) + void FCDataStruct::CalcUpdateHeatRecovery(bool const EP_UNUSED(FirstHVACIteration)) { // SUBROUTINE INFORMATION: @@ -3455,102 +3449,100 @@ namespace FuelCellElectricGenerator { // now update water outlet node Changing to Kg/s! - PlantUtilities::SafeCopyPlantNode(FuelCell(Num).ExhaustHX.WaterInNode, FuelCell(Num).ExhaustHX.WaterOutNode); + PlantUtilities::SafeCopyPlantNode(this->ExhaustHX.WaterInNode, this->ExhaustHX.WaterOutNode); - DataLoopNode::Node(FuelCell(Num).ExhaustHX.WaterOutNode).Temp = FuelCell(Num).ExhaustHX.WaterOutletTemp; - DataLoopNode::Node(FuelCell(Num).ExhaustHX.WaterOutNode).Enthalpy = FuelCell(Num).ExhaustHX.WaterOutletEnthalpy; + DataLoopNode::Node(this->ExhaustHX.WaterOutNode).Temp = this->ExhaustHX.WaterOutletTemp; + DataLoopNode::Node(this->ExhaustHX.WaterOutNode).Enthalpy = this->ExhaustHX.WaterOutletEnthalpy; } - void UpdateFuelCellGeneratorRecords(bool const EP_UNUSED(RunFlag), // TRUE if Generator operating - int const Num // Generator number - ) + void FCDataStruct::UpdateFuelCellGeneratorRecords() { - FuelCell(Num).Report.ACPowerGen = FuelCell(Num).ACPowerGen; // electrical power produced [W] - FuelCell(Num).Report.ACEnergyGen = FuelCell(Num).ACPowerGen * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; // energy produced (J) - FuelCell(Num).Report.QdotExhaust = 0.0; // reporting: exhaust gas heat recovered (W) - FuelCell(Num).Report.TotalHeatEnergyRec = 0.0; // reporting: total heat recovered (J) - FuelCell(Num).Report.ExhaustEnergyRec = 0.0; // reporting: exhaust gas heat recovered (J) - - FuelCell(Num).Report.HeatRecInletTemp = 0.0; // reporting: Heat Recovery Loop Inlet Temperature (C) - FuelCell(Num).Report.HeatRecOutletTemp = 0.0; // reporting: Heat Recovery Loop Outlet Temperature (C) - FuelCell(Num).Report.HeatRecMdot = 0.0; // reporting: Heat Recovery Loop Mass flow rate (kg/s) - - FuelCell(Num).Report.ElectEfficiency = 0.0; - FuelCell(Num).Report.ThermalEfficiency = 0.0; - FuelCell(Num).Report.OverallEfficiency = 0.0; - FuelCell(Num).Report.ExergyEfficiency = 0.0; - - FuelCell(Num).Report.TairInlet = FuelCell(Num).AirSup.TairIntoBlower; // State point 1 - FuelCell(Num).Report.TairIntoFCPM = FuelCell(Num).AirSup.TairIntoFCPM; // State point 4 - FuelCell(Num).Report.NdotAir = FuelCell(Num).FCPM.NdotAir; // air flow in kmol/sec - FuelCell(Num).Report.TotAirInEnthalphy = FuelCell(Num).FCPM.TotAirInEnthalphy; // State point 4 - FuelCell(Num).Report.BlowerPower = FuelCell(Num).AirSup.PairCompEl; // electrical power used by air supply blower - FuelCell(Num).Report.BlowerEnergy = FuelCell(Num).AirSup.PairCompEl * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; // electrical energy - FuelCell(Num).Report.BlowerSkinLoss = FuelCell(Num).AirSup.QskinLoss; // heat rate of losses by blower - - FuelCell(Num).Report.TfuelInlet = DataGenerators::FuelSupply(FuelCell(Num).FuelSupNum).TfuelIntoCompress; // State point 2 - FuelCell(Num).Report.TfuelIntoFCPM = DataGenerators::FuelSupply(FuelCell(Num).FuelSupNum).TfuelIntoFCPM; // TEmperature state point 5 [C] - FuelCell(Num).Report.NdotFuel = FuelCell(Num).FCPM.NdotFuel; // fuel flow in kmol/sec - FuelCell(Num).Report.TotFuelInEnthalpy = FuelCell(Num).FCPM.TotFuelInEnthalphy; // enthalpy at state point 5 [W] - FuelCell(Num).Report.FuelCompressPower = DataGenerators::FuelSupply(FuelCell(Num).FuelSupNum).PfuelCompEl; + this->Report.ACPowerGen = this->ACPowerGen; // electrical power produced [W] + this->Report.ACEnergyGen = this->ACPowerGen * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; // energy produced (J) + this->Report.QdotExhaust = 0.0; // reporting: exhaust gas heat recovered (W) + this->Report.TotalHeatEnergyRec = 0.0; // reporting: total heat recovered (J) + this->Report.ExhaustEnergyRec = 0.0; // reporting: exhaust gas heat recovered (J) + + this->Report.HeatRecInletTemp = 0.0; // reporting: Heat Recovery Loop Inlet Temperature (C) + this->Report.HeatRecOutletTemp = 0.0; // reporting: Heat Recovery Loop Outlet Temperature (C) + this->Report.HeatRecMdot = 0.0; // reporting: Heat Recovery Loop Mass flow rate (kg/s) + + this->Report.ElectEfficiency = 0.0; + this->Report.ThermalEfficiency = 0.0; + this->Report.OverallEfficiency = 0.0; + this->Report.ExergyEfficiency = 0.0; + + this->Report.TairInlet = this->AirSup.TairIntoBlower; // State point 1 + this->Report.TairIntoFCPM = this->AirSup.TairIntoFCPM; // State point 4 + this->Report.NdotAir = this->FCPM.NdotAir; // air flow in kmol/sec + this->Report.TotAirInEnthalphy = this->FCPM.TotAirInEnthalphy; // State point 4 + this->Report.BlowerPower = this->AirSup.PairCompEl; // electrical power used by air supply blower + this->Report.BlowerEnergy = this->AirSup.PairCompEl * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; // electrical energy + this->Report.BlowerSkinLoss = this->AirSup.QskinLoss; // heat rate of losses by blower + + this->Report.TfuelInlet = DataGenerators::FuelSupply(this->FuelSupNum).TfuelIntoCompress; // State point 2 + this->Report.TfuelIntoFCPM = DataGenerators::FuelSupply(this->FuelSupNum).TfuelIntoFCPM; // TEmperature state point 5 [C] + this->Report.NdotFuel = this->FCPM.NdotFuel; // fuel flow in kmol/sec + this->Report.TotFuelInEnthalpy = this->FCPM.TotFuelInEnthalphy; // enthalpy at state point 5 [W] + this->Report.FuelCompressPower = DataGenerators::FuelSupply(this->FuelSupNum).PfuelCompEl; // electrical power used by fuel supply compressor [W] - FuelCell(Num).Report.FuelCompressEnergy = DataGenerators::FuelSupply(FuelCell(Num).FuelSupNum).PfuelCompEl * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; // elect energy - FuelCell(Num).Report.FuelCompressSkinLoss = DataGenerators::FuelSupply(FuelCell(Num).FuelSupNum).QskinLoss; + this->Report.FuelCompressEnergy = DataGenerators::FuelSupply(this->FuelSupNum).PfuelCompEl * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; // elect energy + this->Report.FuelCompressSkinLoss = DataGenerators::FuelSupply(this->FuelSupNum).QskinLoss; // heat rate of losses.by fuel supply compressor [W] - FuelCell(Num).Report.FuelEnergyLHV = FuelCell(Num).FCPM.NdotFuel * DataGenerators::FuelSupply(FuelCell(Num).FuelSupNum).LHV * 1000000.0 * DataHVACGlobals::TimeStepSys * + this->Report.FuelEnergyLHV = this->FCPM.NdotFuel * DataGenerators::FuelSupply(this->FuelSupNum).LHV * 1000000.0 * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; // reporting: Fuel Energy used (J) - FuelCell(Num).Report.FuelEnergyUseRateLHV = - FuelCell(Num).FCPM.NdotFuel * DataGenerators::FuelSupply(FuelCell(Num).FuelSupNum).LHV * 1000000.0; // reporting: Fuel Energy used (W) - FuelCell(Num).Report.FuelEnergyHHV = FuelCell(Num).FCPM.NdotFuel * DataGenerators::FuelSupply(FuelCell(Num).FuelSupNum).HHV * - DataGenerators::FuelSupply(FuelCell(Num).FuelSupNum).KmolPerSecToKgPerSec * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - - FuelCell(Num).Report.FuelEnergyUseRateHHV = - FuelCell(Num).FCPM.NdotFuel * DataGenerators::FuelSupply(FuelCell(Num).FuelSupNum).HHV * DataGenerators::FuelSupply(FuelCell(Num).FuelSupNum).KmolPerSecToKgPerSec; - - FuelCell(Num).Report.FuelRateMdot = 0.0; // (Kg/s) - - FuelCell(Num).Report.TwaterInlet = FuelCell(Num).WaterSup.TwaterIntoCompress; - FuelCell(Num).Report.TwaterIntoFCPM = FuelCell(Num).WaterSup.TwaterIntoFCPM; - FuelCell(Num).Report.NdotWater = FuelCell(Num).FCPM.NdotLiqwater; // water flow in kmol/sec (reformer water) - FuelCell(Num).Report.WaterPumpPower = FuelCell(Num).WaterSup.PwaterCompEl; - FuelCell(Num).Report.WaterPumpEnergy = FuelCell(Num).WaterSup.PwaterCompEl * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; // electrical energy - FuelCell(Num).Report.WaterIntoFCPMEnthalpy = FuelCell(Num).FCPM.WaterInEnthalpy; - - FuelCell(Num).Report.TprodGas = FuelCell(Num).FCPM.TprodGasLeavingFCPM; // temperature at State point 7 - FuelCell(Num).Report.EnthalProdGas = FuelCell(Num).FCPM.TotProdGasEnthalphy; // enthalpy at State point 7 - FuelCell(Num).Report.NdotProdGas = FuelCell(Num).FCPM.NdotProdGas; // flow rate at point 7 [kmol/sec] - FuelCell(Num).Report.NdotProdAr = FuelCell(Num).FCPM.ConstitMolalFract(5) * FuelCell(Num).FCPM.NdotProdGas; - FuelCell(Num).Report.NdotProdCO2 = FuelCell(Num).FCPM.ConstitMolalFract(1) * FuelCell(Num).FCPM.NdotProdGas; - FuelCell(Num).Report.NdotProdH2O = FuelCell(Num).FCPM.ConstitMolalFract(4) * FuelCell(Num).FCPM.NdotProdGas; - FuelCell(Num).Report.NdotProdN2 = FuelCell(Num).FCPM.ConstitMolalFract(2) * FuelCell(Num).FCPM.NdotProdGas; - FuelCell(Num).Report.NdotProdO2 = FuelCell(Num).FCPM.ConstitMolalFract(3) * FuelCell(Num).FCPM.NdotProdGas; - - FuelCell(Num).Report.qHX = FuelCell(Num).ExhaustHX.qHX; - FuelCell(Num).Report.HXenergy = FuelCell(Num).ExhaustHX.qHX * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - FuelCell(Num).Report.THXexh = FuelCell(Num).ExhaustHX.THXexh; - FuelCell(Num).Report.WaterVaporFractExh = FuelCell(Num).ExhaustHX.WaterVaporFractExh; - FuelCell(Num).Report.CondensateRate = FuelCell(Num).ExhaustHX.CondensateRate; - - FuelCell(Num).Report.SeqSubstIterations = FuelCell(Num).FCPM.SeqSubstitIter; // number of iterations in FuelCell loop - FuelCell(Num).Report.RegulaFalsiIterations = FuelCell(Num).FCPM.RegulaFalsiIter; // number of iterations in Tproduct gas solving - - FuelCell(Num).Report.ACancillariesPower = FuelCell(Num).FCPM.PelancillariesAC; - FuelCell(Num).Report.ACancillariesEnergy = FuelCell(Num).FCPM.PelancillariesAC * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - - FuelCell(Num).Report.PCUlosses = FuelCell(Num).Inverter.PCUlosses; // inverter losses - FuelCell(Num).Report.DCPowerGen = FuelCell(Num).FCPM.Pel; // DC power out of FCPM. - FuelCell(Num).Report.DCPowerEff = FuelCell(Num).FCPM.Eel; // FCPM efficienty Eel. - FuelCell(Num).Report.ElectEnergyinStorage = FuelCell(Num).ElecStorage.ThisTimeStepStateOfCharge; - FuelCell(Num).Report.StoredPower = FuelCell(Num).ElecStorage.PelIntoStorage; - FuelCell(Num).Report.StoredEnergy = FuelCell(Num).ElecStorage.PelIntoStorage * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - FuelCell(Num).Report.DrawnPower = FuelCell(Num).ElecStorage.PelFromStorage; - FuelCell(Num).Report.DrawnEnergy = FuelCell(Num).ElecStorage.PelFromStorage * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - - FuelCell(Num).Report.SkinLossPower = FuelCell(Num).QconvZone + FuelCell(Num).QradZone; - FuelCell(Num).Report.SkinLossEnergy = (FuelCell(Num).QconvZone + FuelCell(Num).QradZone) * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - FuelCell(Num).Report.SkinLossConvect = FuelCell(Num).QconvZone; - FuelCell(Num).Report.SkinLossRadiat = FuelCell(Num).QradZone; + this->Report.FuelEnergyUseRateLHV = + this->FCPM.NdotFuel * DataGenerators::FuelSupply(this->FuelSupNum).LHV * 1000000.0; // reporting: Fuel Energy used (W) + this->Report.FuelEnergyHHV = this->FCPM.NdotFuel * DataGenerators::FuelSupply(this->FuelSupNum).HHV * + DataGenerators::FuelSupply(this->FuelSupNum).KmolPerSecToKgPerSec * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + + this->Report.FuelEnergyUseRateHHV = + this->FCPM.NdotFuel * DataGenerators::FuelSupply(this->FuelSupNum).HHV * DataGenerators::FuelSupply(this->FuelSupNum).KmolPerSecToKgPerSec; + + this->Report.FuelRateMdot = 0.0; // (Kg/s) + + this->Report.TwaterInlet = this->WaterSup.TwaterIntoCompress; + this->Report.TwaterIntoFCPM = this->WaterSup.TwaterIntoFCPM; + this->Report.NdotWater = this->FCPM.NdotLiqwater; // water flow in kmol/sec (reformer water) + this->Report.WaterPumpPower = this->WaterSup.PwaterCompEl; + this->Report.WaterPumpEnergy = this->WaterSup.PwaterCompEl * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; // electrical energy + this->Report.WaterIntoFCPMEnthalpy = this->FCPM.WaterInEnthalpy; + + this->Report.TprodGas = this->FCPM.TprodGasLeavingFCPM; // temperature at State point 7 + this->Report.EnthalProdGas = this->FCPM.TotProdGasEnthalphy; // enthalpy at State point 7 + this->Report.NdotProdGas = this->FCPM.NdotProdGas; // flow rate at point 7 [kmol/sec] + this->Report.NdotProdAr = this->FCPM.ConstitMolalFract(5) * this->FCPM.NdotProdGas; + this->Report.NdotProdCO2 = this->FCPM.ConstitMolalFract(1) * this->FCPM.NdotProdGas; + this->Report.NdotProdH2O = this->FCPM.ConstitMolalFract(4) * this->FCPM.NdotProdGas; + this->Report.NdotProdN2 = this->FCPM.ConstitMolalFract(2) * this->FCPM.NdotProdGas; + this->Report.NdotProdO2 = this->FCPM.ConstitMolalFract(3) * this->FCPM.NdotProdGas; + + this->Report.qHX = this->ExhaustHX.qHX; + this->Report.HXenergy = this->ExhaustHX.qHX * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + this->Report.THXexh = this->ExhaustHX.THXexh; + this->Report.WaterVaporFractExh = this->ExhaustHX.WaterVaporFractExh; + this->Report.CondensateRate = this->ExhaustHX.CondensateRate; + + this->Report.SeqSubstIterations = this->FCPM.SeqSubstitIter; // number of iterations in FuelCell loop + this->Report.RegulaFalsiIterations = this->FCPM.RegulaFalsiIter; // number of iterations in Tproduct gas solving + + this->Report.ACancillariesPower = this->FCPM.PelancillariesAC; + this->Report.ACancillariesEnergy = this->FCPM.PelancillariesAC * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + + this->Report.PCUlosses = this->Inverter.PCUlosses; // inverter losses + this->Report.DCPowerGen = this->FCPM.Pel; // DC power out of FCPM. + this->Report.DCPowerEff = this->FCPM.Eel; // FCPM efficienty Eel. + this->Report.ElectEnergyinStorage = this->ElecStorage.ThisTimeStepStateOfCharge; + this->Report.StoredPower = this->ElecStorage.PelIntoStorage; + this->Report.StoredEnergy = this->ElecStorage.PelIntoStorage * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + this->Report.DrawnPower = this->ElecStorage.PelFromStorage; + this->Report.DrawnEnergy = this->ElecStorage.PelFromStorage * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + + this->Report.SkinLossPower = this->QconvZone + this->QradZone; + this->Report.SkinLossEnergy = (this->QconvZone + this->QradZone) * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + this->Report.SkinLossConvect = this->QconvZone; + this->Report.SkinLossRadiat = this->QradZone; } void GetFuelCellGeneratorResults(int const EP_UNUSED(GeneratorType), // type of Generator diff --git a/src/EnergyPlus/FuelCellElectricGenerator.hh b/src/EnergyPlus/FuelCellElectricGenerator.hh index dda7f9ef43b..939da3e5e56 100644 --- a/src/EnergyPlus/FuelCellElectricGenerator.hh +++ b/src/EnergyPlus/FuelCellElectricGenerator.hh @@ -553,6 +553,8 @@ namespace FuelCellElectricGenerator { { } + void InitFuelCellGenerators(); + void FigureAirHeatCap(Real64 FluidTemp, Real64 &Cp); void FigureAirEnthalpy(Real64 FluidTemp, Real64 &Hair); @@ -575,6 +577,24 @@ namespace FuelCellElectricGenerator { bool &Constrained, // true if transient constraints kick in (TODO: never used anywhere) Real64 &PelDiff // if constrained then this is the difference, positive ); + + Real64 FuelCellProductGasEnthResidual(Real64 TprodGas, Array1 const &Par); + + void FigureGaseousWaterEnthalpy(Real64 FluidTemp, Real64 &HGasWater); + + void FigureLiquidWaterEnthalpy(Real64 FluidTemp, Real64 &HLiqWater); + + void FigureLiquidWaterHeatCap(Real64 FluidTemp, Real64 &Cp); + + void CalcFuelCellAuxHeater(); + + void CalcFuelCellGenHeatRecovery(); + + void CalcFuelCellGeneratorModel(int GeneratorNum, bool RunFlag, Real64 MyLoad, bool FirstHVACIteration); + + void CalcUpdateHeatRecovery(bool FirstHVACIteration); + + void UpdateFuelCellGeneratorRecords(); }; void clear_state(); @@ -588,11 +608,6 @@ namespace FuelCellElectricGenerator { void GetFuelCellGeneratorInput(); - void CalcFuelCellGeneratorModel(int GeneratorNum, // Generator number - bool RunFlag, // TRUE when Generator operating - Real64 MyLoad, // Generator demand - bool FirstHVACIteration); - void ManageElectStorInteractions(int Num, // Generator number, index for structure Real64 Pdemand, Real64 PpcuLosses, @@ -601,26 +616,6 @@ namespace FuelCellElectricGenerator { Real64 &PgridOverage // electricity that can't be stored and needs to go out ); - Real64 FuelCellProductGasEnthResidual(Real64 TprodGas, // temperature, this is "x" being searched - Array1 const &Par // par(1) = Generator Number - ); - - void FigureGaseousWaterEnthalpy(Real64 FluidTemp, // degree C - Real64 &HGasWater // kJ/mol - ); - - void FigureLiquidWaterEnthalpy(Real64 FluidTemp, // degree C - Real64 &HLiqWater // kJ/mol - ); - - void FigureLiquidWaterHeatCap(Real64 FluidTemp, // degree C - Real64 &Cp // (J/mol*K) - ); - - void CalcFuelCellAuxHeater(int Num); // Generator number - - void CalcFuelCellGenHeatRecovery(int Num); // Generator number - void SimFuelCellPlantHeatRecovery(std::string const &CompType, std::string const &CompName, int CompTypeNum, @@ -634,20 +629,11 @@ namespace FuelCellElectricGenerator { bool FirstHVACIteration // TRUE if First iteration of simulation ); - void InitFuelCellGenerators(int FCnum); // index to specific fuel cell generator - void getFuelCellGeneratorHeatRecoveryInfo(std::string const &GeneratorName, // user specified name of Generator std::string &heatRecoveryCompName); void FigureFuelCellZoneGains(); - void CalcUpdateHeatRecovery(int Num, // Generator number - bool FirstHVACIteration); - - void UpdateFuelCellGeneratorRecords(bool RunFlag, // TRUE if Generator operating - int Num // Generator number - ); - void GetFuelCellGeneratorResults(int GeneratorType, // type of Generator int GeneratorIndex, Real64 &GeneratorPower, // electrical power From ce50b2781ba8e42d70abf974d73ecc88ff19797c Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Tue, 12 Nov 2019 11:10:38 -0700 Subject: [PATCH 31/51] functions to members --- src/EnergyPlus/FuelCellElectricGenerator.cc | 110 ++++++++++---------- src/EnergyPlus/FuelCellElectricGenerator.hh | 23 ++-- 2 files changed, 65 insertions(+), 68 deletions(-) diff --git a/src/EnergyPlus/FuelCellElectricGenerator.cc b/src/EnergyPlus/FuelCellElectricGenerator.cc index 0b070762228..481830189dd 100644 --- a/src/EnergyPlus/FuelCellElectricGenerator.cc +++ b/src/EnergyPlus/FuelCellElectricGenerator.cc @@ -1817,8 +1817,7 @@ namespace FuelCellElectricGenerator { Par(2) = tmpTotProdGasEnthalpy; Par(3) = this->FCPM.NdotProdGas; Real64 tmpTprodGas = this->FCPM.TprodGasLeavingFCPM; - auto boundFunc = std::bind(&FCDataStruct::FuelCellProductGasEnthResidual, this, std::placeholders::_1, std::placeholders::_2); - General::SolveRoot(Acc, MaxIter, SolverFlag, tmpTprodGas, boundFunc, DataGenerators::MinProductGasTemp, DataGenerators::MaxProductGasTemp, Par); + General::SolveRoot(Acc, MaxIter, SolverFlag, tmpTprodGas, this->FuelCellProductGasEnthResidual, DataGenerators::MinProductGasTemp, DataGenerators::MaxProductGasTemp, Par); if (SolverFlag == -2) { @@ -1838,7 +1837,7 @@ namespace FuelCellElectricGenerator { // How much power is really going into inverter? Real64 PintoInverter = Pel + Pstorage; // Back out so we can reapply bool ConstrainedStorage; - ManageElectStorInteractions(GeneratorNum, Pdemand, PpcuLosses, ConstrainedStorage, Pstorage, PgridExtra); + this->ManageElectStorInteractions(Pdemand, PpcuLosses, ConstrainedStorage, Pstorage, PgridExtra); PintoInverter = Pel - Pstorage; // refine power conditioning losses with more current power production @@ -1876,8 +1875,7 @@ namespace FuelCellElectricGenerator { this->FCPM.RegulaFalsiIter = SolverFlag; } - void ManageElectStorInteractions(int const Num, // Generator number, index for structure - Real64 const Pdemand, + void FCDataStruct::ManageElectStorInteractions(Real64 const Pdemand, Real64 const EP_UNUSED(PpcuLosses), bool &Constrained, Real64 &Pstorage, @@ -1902,15 +1900,15 @@ namespace FuelCellElectricGenerator { // step 1 figure out what is desired of electrical storage system - if (FuelCell(Num).FCPM.Pel < (Pdemand)) { + if (this->FCPM.Pel < (Pdemand)) { // draw from storage - tmpPdraw = (Pdemand)-FuelCell(Num).FCPM.Pel; + tmpPdraw = (Pdemand)-this->FCPM.Pel; drawing = true; } - if (FuelCell(Num).FCPM.Pel > (Pdemand)) { + if (this->FCPM.Pel > (Pdemand)) { // add to storage - tmpPcharge = FuelCell(Num).FCPM.Pel - (Pdemand); + tmpPcharge = this->FCPM.Pel - (Pdemand); charging = true; } @@ -1918,45 +1916,45 @@ namespace FuelCellElectricGenerator { if (charging) { - if (FuelCell(Num).ElecStorage.StorageModelMode == DataGenerators::SimpleEffConstraints) { + if (this->ElecStorage.StorageModelMode == DataGenerators::SimpleEffConstraints) { - if (FuelCell(Num).ElecStorage.LastTimeStepStateOfCharge >= FuelCell(Num).ElecStorage.NominalEnergyCapacity) { + if (this->ElecStorage.LastTimeStepStateOfCharge >= this->ElecStorage.NominalEnergyCapacity) { // storage full! no more allowed! PgridOverage = tmpPcharge; tmpPcharge = 0.0; Constrained = true; } - if (tmpPcharge > FuelCell(Num).ElecStorage.MaxPowerStore) { - PgridOverage = tmpPcharge - FuelCell(Num).ElecStorage.MaxPowerStore; - tmpPcharge = FuelCell(Num).ElecStorage.MaxPowerStore; + if (tmpPcharge > this->ElecStorage.MaxPowerStore) { + PgridOverage = tmpPcharge - this->ElecStorage.MaxPowerStore; + tmpPcharge = this->ElecStorage.MaxPowerStore; Constrained = true; } // now add energy to storage from charging - if ((FuelCell(Num).ElecStorage.LastTimeStepStateOfCharge + - tmpPcharge * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour * FuelCell(Num).ElecStorage.EnergeticEfficCharge) < - FuelCell(Num).ElecStorage.NominalEnergyCapacity) { + if ((this->ElecStorage.LastTimeStepStateOfCharge + + tmpPcharge * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour * this->ElecStorage.EnergeticEfficCharge) < + this->ElecStorage.NominalEnergyCapacity) { - FuelCell(Num).ElecStorage.ThisTimeStepStateOfCharge = - FuelCell(Num).ElecStorage.LastTimeStepStateOfCharge + - tmpPcharge * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour * FuelCell(Num).ElecStorage.EnergeticEfficCharge; + this->ElecStorage.ThisTimeStepStateOfCharge = + this->ElecStorage.LastTimeStepStateOfCharge + + tmpPcharge * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour * this->ElecStorage.EnergeticEfficCharge; } else { // would over charge this time step - tmpPcharge = (FuelCell(Num).ElecStorage.NominalEnergyCapacity - FuelCell(Num).ElecStorage.LastTimeStepStateOfCharge) / - (DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour * FuelCell(Num).ElecStorage.EnergeticEfficCharge); + tmpPcharge = (this->ElecStorage.NominalEnergyCapacity - this->ElecStorage.LastTimeStepStateOfCharge) / + (DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour * this->ElecStorage.EnergeticEfficCharge); Constrained = true; - FuelCell(Num).ElecStorage.ThisTimeStepStateOfCharge = - FuelCell(Num).ElecStorage.LastTimeStepStateOfCharge + - tmpPcharge * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour * FuelCell(Num).ElecStorage.EnergeticEfficCharge; + this->ElecStorage.ThisTimeStepStateOfCharge = + this->ElecStorage.LastTimeStepStateOfCharge + + tmpPcharge * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour * this->ElecStorage.EnergeticEfficCharge; } // losses go into QairIntake - FuelCell(Num).ElecStorage.QairIntake = tmpPcharge * (1.0 - FuelCell(Num).ElecStorage.EnergeticEfficCharge); + this->ElecStorage.QairIntake = tmpPcharge * (1.0 - this->ElecStorage.EnergeticEfficCharge); - } else if (FuelCell(Num).ElecStorage.StorageModelMode == DataGenerators::LeadAcidBatterManwellMcGowan) { + } else if (this->ElecStorage.StorageModelMode == DataGenerators::LeadAcidBatterManwellMcGowan) { ShowWarningError("ManageElectStorInteractions: Not yet implemented: Lead Acid Battery By Manwell and McGowan 1993 "); - } else if (FuelCell(Num).ElecStorage.StorageModelMode == DataGenerators::LeadAcidBatterySaupe) { + } else if (this->ElecStorage.StorageModelMode == DataGenerators::LeadAcidBatterySaupe) { ShowWarningError("ManageElectStorInteractions: Not yet implemented: Lead Acid Battery By Saupe 1993 "); } else { @@ -1969,41 +1967,41 @@ namespace FuelCellElectricGenerator { } // charging if (drawing) { - if (FuelCell(Num).ElecStorage.StorageModelMode == DataGenerators::SimpleEffConstraints) { + if (this->ElecStorage.StorageModelMode == DataGenerators::SimpleEffConstraints) { - if (FuelCell(Num).ElecStorage.LastTimeStepStateOfCharge <= 0.0) { + if (this->ElecStorage.LastTimeStepStateOfCharge <= 0.0) { // storage empty no more allowed! tmpPdraw = 0.0; Constrained = true; drawing = false; } - if (tmpPdraw > FuelCell(Num).ElecStorage.MaxPowerDraw) { - tmpPdraw = FuelCell(Num).ElecStorage.MaxPowerDraw; + if (tmpPdraw > this->ElecStorage.MaxPowerDraw) { + tmpPdraw = this->ElecStorage.MaxPowerDraw; Constrained = true; } // now take energy from storage by drawing (amplified by energetic effic) - if ((FuelCell(Num).ElecStorage.LastTimeStepStateOfCharge - - tmpPdraw * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour / FuelCell(Num).ElecStorage.EnergeticEfficDischarge) > 0.0) { + if ((this->ElecStorage.LastTimeStepStateOfCharge - + tmpPdraw * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour / this->ElecStorage.EnergeticEfficDischarge) > 0.0) { - FuelCell(Num).ElecStorage.ThisTimeStepStateOfCharge = - FuelCell(Num).ElecStorage.LastTimeStepStateOfCharge - - tmpPdraw * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour / FuelCell(Num).ElecStorage.EnergeticEfficDischarge; + this->ElecStorage.ThisTimeStepStateOfCharge = + this->ElecStorage.LastTimeStepStateOfCharge - + tmpPdraw * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour / this->ElecStorage.EnergeticEfficDischarge; } else { // would over drain storage this timestep so reduce tmpPdraw - tmpPdraw = FuelCell(Num).ElecStorage.LastTimeStepStateOfCharge * FuelCell(Num).ElecStorage.EnergeticEfficDischarge / + tmpPdraw = this->ElecStorage.LastTimeStepStateOfCharge * this->ElecStorage.EnergeticEfficDischarge / (DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour); - FuelCell(Num).ElecStorage.ThisTimeStepStateOfCharge = - FuelCell(Num).ElecStorage.LastTimeStepStateOfCharge - - tmpPdraw * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour / FuelCell(Num).ElecStorage.EnergeticEfficDischarge; + this->ElecStorage.ThisTimeStepStateOfCharge = + this->ElecStorage.LastTimeStepStateOfCharge - + tmpPdraw * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour / this->ElecStorage.EnergeticEfficDischarge; Constrained = true; } // losses go into QairIntake - FuelCell(Num).ElecStorage.QairIntake = tmpPdraw * (1.0 / FuelCell(Num).ElecStorage.EnergeticEfficDischarge - 1.0); - } else if (FuelCell(Num).ElecStorage.StorageModelMode == DataGenerators::LeadAcidBatterManwellMcGowan) { + this->ElecStorage.QairIntake = tmpPdraw * (1.0 / this->ElecStorage.EnergeticEfficDischarge - 1.0); + } else if (this->ElecStorage.StorageModelMode == DataGenerators::LeadAcidBatterManwellMcGowan) { ShowWarningError("ManageElectStorInteractions: Not yet implemented: Lead Acid Battery By Manwell and McGowan 1993 "); - } else if (FuelCell(Num).ElecStorage.StorageModelMode == DataGenerators::LeadAcidBatterySaupe) { + } else if (this->ElecStorage.StorageModelMode == DataGenerators::LeadAcidBatterySaupe) { ShowWarningError("ManageElectStorInteractions: Not yet implemented: Lead Acid Battery By Saupe 1993 "); } else { @@ -2017,21 +2015,21 @@ namespace FuelCellElectricGenerator { if ((!charging) && (!drawing)) { - FuelCell(Num).ElecStorage.ThisTimeStepStateOfCharge = FuelCell(Num).ElecStorage.LastTimeStepStateOfCharge; - FuelCell(Num).ElecStorage.PelNeedFromStorage = 0.0; - FuelCell(Num).ElecStorage.PelFromStorage = 0.0; - FuelCell(Num).ElecStorage.QairIntake = 0.0; + this->ElecStorage.ThisTimeStepStateOfCharge = this->ElecStorage.LastTimeStepStateOfCharge; + this->ElecStorage.PelNeedFromStorage = 0.0; + this->ElecStorage.PelFromStorage = 0.0; + this->ElecStorage.QairIntake = 0.0; } if (Pstorage >= 0.0) { - FuelCell(Num).ElecStorage.PelIntoStorage = Pstorage; - FuelCell(Num).ElecStorage.PelFromStorage = 0.0; + this->ElecStorage.PelIntoStorage = Pstorage; + this->ElecStorage.PelFromStorage = 0.0; } if (Pstorage < 0.0) { - FuelCell(Num).ElecStorage.PelIntoStorage = 0.0; - FuelCell(Num).ElecStorage.PelFromStorage = -Pstorage; + this->ElecStorage.PelIntoStorage = 0.0; + this->ElecStorage.PelFromStorage = -Pstorage; } } @@ -2610,7 +2608,7 @@ namespace FuelCellElectricGenerator { // PURPOSE OF THIS SUBROUTINE: // calculate Enthalpy from Shomate equations for gaseous water - // No ethalphy of formation in this one. + // No enthalpy of formation in this one. // REFERENCES: // NIST Webbook on gas phase thermochemistry @@ -3298,8 +3296,8 @@ namespace FuelCellElectricGenerator { } // using and elapsed time method rather than FirstHVACIteration here - Real64 TimeElapsed = DataGlobals::HourOfDay + DataGlobals::TimeStep * DataGlobals::TimeStepZone + DataHVACGlobals::SysTimeElapsed; - if (this->TimeElapsed != TimeElapsed) { + Real64 timeElapsed = DataGlobals::HourOfDay + DataGlobals::TimeStep * DataGlobals::TimeStepZone + DataHVACGlobals::SysTimeElapsed; + if (this->TimeElapsed != timeElapsed) { this->ElecStorage.LastTimeStepStateOfCharge = this->ElecStorage.ThisTimeStepStateOfCharge; this->FCPM.PelLastTimeStep = this->FCPM.Pel; @@ -3317,7 +3315,7 @@ namespace FuelCellElectricGenerator { this->ExhaustHX.WaterMassFlowRate = mdot; this->ExhaustHX.WaterInletTemp = DataLoopNode::Node(this->ExhaustHX.WaterInNode).Temp; - this->TimeElapsed = TimeElapsed; + this->TimeElapsed = timeElapsed; } else { PlantUtilities::SetComponentFlowRate(this->ExhaustHX.WaterMassFlowRate, diff --git a/src/EnergyPlus/FuelCellElectricGenerator.hh b/src/EnergyPlus/FuelCellElectricGenerator.hh index 939da3e5e56..afda283a2c1 100644 --- a/src/EnergyPlus/FuelCellElectricGenerator.hh +++ b/src/EnergyPlus/FuelCellElectricGenerator.hh @@ -578,13 +578,13 @@ namespace FuelCellElectricGenerator { Real64 &PelDiff // if constrained then this is the difference, positive ); - Real64 FuelCellProductGasEnthResidual(Real64 TprodGas, Array1 const &Par); + static Real64 FuelCellProductGasEnthResidual(Real64 TprodGas, Array1 const &Par); - void FigureGaseousWaterEnthalpy(Real64 FluidTemp, Real64 &HGasWater); + static void FigureGaseousWaterEnthalpy(Real64 FluidTemp, Real64 &HGasWater); - void FigureLiquidWaterEnthalpy(Real64 FluidTemp, Real64 &HLiqWater); + static void FigureLiquidWaterEnthalpy(Real64 FluidTemp, Real64 &HLiqWater); - void FigureLiquidWaterHeatCap(Real64 FluidTemp, Real64 &Cp); + static void FigureLiquidWaterHeatCap(Real64 FluidTemp, Real64 &Cp); void CalcFuelCellAuxHeater(); @@ -594,6 +594,13 @@ namespace FuelCellElectricGenerator { void CalcUpdateHeatRecovery(bool FirstHVACIteration); + void ManageElectStorInteractions(Real64 Pdemand, + Real64 PpcuLosses, + bool &Constrained, // TODO: This one is never used anywhere in the code + Real64 &Pstorage, + Real64 &PgridOverage // electricity that can't be stored and needs to go out + ); + void UpdateFuelCellGeneratorRecords(); }; @@ -608,14 +615,6 @@ namespace FuelCellElectricGenerator { void GetFuelCellGeneratorInput(); - void ManageElectStorInteractions(int Num, // Generator number, index for structure - Real64 Pdemand, - Real64 PpcuLosses, - bool &Constrained, // TODO: This one is never used anywhere in the code - Real64 &Pstorage, - Real64 &PgridOverage // electricity that can't be stored and needs to go out - ); - void SimFuelCellPlantHeatRecovery(std::string const &CompType, std::string const &CompName, int CompTypeNum, From daeab219e996d165d1a94cbb1ab3b7f408c5165a Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Tue, 12 Nov 2019 12:54:20 -0700 Subject: [PATCH 32/51] rollback to 500199ebe368930c924a7725a0346ce3087af3d2 to resolve errors --- src/EnergyPlus/WaterUse.cc | 2315 ++++++++++++++++++------------------ src/EnergyPlus/WaterUse.hh | 414 +++---- 2 files changed, 1346 insertions(+), 1383 deletions(-) diff --git a/src/EnergyPlus/WaterUse.cc b/src/EnergyPlus/WaterUse.cc index 847891b7fc1..afa1be3d825 100644 --- a/src/EnergyPlus/WaterUse.cc +++ b/src/EnergyPlus/WaterUse.cc @@ -77,611 +77,580 @@ namespace EnergyPlus { -namespace WaterUse { - - // MODULE INFORMATION: - // AUTHOR Peter Graham Ellis - // DATE WRITTEN August 2006 - // MODIFIED Brent Griffith, plant upgrade - // RE-ENGINEERED na - - // MODULE PARAMETER DEFINITIONS: - int const HeatRecoveryHXIdeal(1); - int const HeatRecoveryHXCounterFlow(2); - int const HeatRecoveryHXCrossFlow(3); - - int const HeatRecoveryConfigPlant(1); - int const HeatRecoveryConfigEquipment(2); - int const HeatRecoveryConfigPlantAndEquip(3); - - static std::string const BlankString; - - // MODULE VARIABLE DECLARATIONS: - int modNumWaterEquipment(0); - int modNumWaterConnections(0); - bool GetWaterUseInputFlag(true); - - Array1D_bool CheckEquipName; - Array1D_bool CheckPlantLoop; - - // Object Data - Array1D WaterEquipment; - Array1D WaterConnections; - - void clear_state() - { - modNumWaterEquipment = 0; - modNumWaterConnections = 0; - GetWaterUseInputFlag = true; - CheckEquipName.deallocate(); - CheckPlantLoop.deallocate(); - WaterEquipment.deallocate(); - WaterConnections.deallocate(); - } - - void SimulateWaterUse(bool FirstHVACIteration) - { - - // SUBROUTINE INFORMATION: + namespace WaterUse { + + // MODULE INFORMATION: // AUTHOR Peter Graham Ellis // DATE WRITTEN August 2006 - // MODIFIED Brent Griffith, March 2010, seperated plant connected to different sim routine + // MODIFIED Brent Griffith, plant upgrade // RE-ENGINEERED na - // PURPOSE OF THIS SUBROUTINE: - // This routine is called from non zone equipment manager and serves to call - // water use and connections that are not connected to a full plant loop - - // Locals - // SUBROUTINE PARAMETER DEFINITIONS: - int const MaxIterations(100); - Real64 const Tolerance(0.1); // Make input? - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - int WaterEquipNum; - int WaterConnNum; - int NumIteration; - int MaxIterationsErrorCount; - bool MyEnvrnFlag(true); - - // FLOW: - if (GetWaterUseInputFlag) { - GetWaterUseInput(); - SetupOutputVars(); - GetWaterUseInputFlag = false; + // MODULE PARAMETER DEFINITIONS: + int const HeatRecoveryHXIdeal(1); + int const HeatRecoveryHXCounterFlow(2); + int const HeatRecoveryHXCrossFlow(3); + + int const HeatRecoveryConfigPlant(1); + int const HeatRecoveryConfigEquipment(2); + int const HeatRecoveryConfigPlantAndEquip(3); + + static std::string const BlankString; + + // MODULE VARIABLE DECLARATIONS: + int modNumWaterEquipment(0); + int modNumWaterConnections(0); + bool GetWaterUseInputFlag(true); + + Array1D_bool CheckEquipName; + Array1D_bool CheckPlantLoop; + + // Object Data + Array1D WaterEquipment; + Array1D WaterConnections; + + void clear_state() + { + modNumWaterEquipment = 0; + modNumWaterConnections = 0; + GetWaterUseInputFlag = true; + CheckEquipName.deallocate(); + CheckPlantLoop.deallocate(); + WaterEquipment.deallocate(); + WaterConnections.deallocate(); } - if (DataGlobals::BeginEnvrnFlag && MyEnvrnFlag) { - MaxIterationsErrorCount = 0; - if (modNumWaterEquipment > 0) { - for (auto &e : WaterEquipment) { - e.SensibleRate = 0.0; - e.SensibleEnergy = 0.0; - e.LatentRate = 0.0; - e.LatentEnergy = 0.0; - e.MixedTemp = 0.0; - e.TotalMassFlowRate = 0.0; - e.DrainTemp = 0.0; - } - } - - if (modNumWaterConnections > 0) { - for (auto &e : WaterConnections) - e.TotalMassFlowRate = 0.0; + void SimulateWaterUse(bool FirstHVACIteration) + { + + // SUBROUTINE INFORMATION: + // AUTHOR Peter Graham Ellis + // DATE WRITTEN August 2006 + // MODIFIED Brent Griffith, March 2010, seperated plant connected to different sim routine + // RE-ENGINEERED na + + // PURPOSE OF THIS SUBROUTINE: + // This routine is called from non zone equipment manager and serves to call + // water use and connections that are not connected to a full plant loop + + // Locals + // SUBROUTINE PARAMETER DEFINITIONS: + int const MaxIterations(100); + Real64 const Tolerance(0.1); // Make input? + + // SUBROUTINE LOCAL VARIABLE DECLARATIONS: + int WaterEquipNum; + int WaterConnNum; + int NumIteration; + int MaxIterationsErrorCount; + bool MyEnvrnFlag(true); + + // FLOW: + if (GetWaterUseInputFlag) { + GetWaterUseInput(); + GetWaterUseInputFlag = false; } - MyEnvrnFlag = false; - } + if (DataGlobals::BeginEnvrnFlag && MyEnvrnFlag) { + MaxIterationsErrorCount = 0; + if (modNumWaterEquipment > 0) { + for (auto &e : WaterEquipment) { + e.SensibleRate = 0.0; + e.SensibleEnergy = 0.0; + e.LatentRate = 0.0; + e.LatentEnergy = 0.0; + e.MixedTemp = 0.0; + e.TotalMassFlowRate = 0.0; + e.DrainTemp = 0.0; + } + } - if (!DataGlobals::BeginEnvrnFlag) MyEnvrnFlag = true; + if (modNumWaterConnections > 0) { + for (auto &e : WaterConnections) + e.TotalMassFlowRate = 0.0; + } - // Simulate all unconnected WATER USE EQUIPMENT objects - for (WaterEquipNum = 1; WaterEquipNum <= modNumWaterEquipment; ++WaterEquipNum) { - if (WaterEquipment(WaterEquipNum).Connections == 0) { - CalcEquipmentFlowRates(WaterEquipNum); - CalcEquipmentDrainTemp(WaterEquipNum); + MyEnvrnFlag = false; } - } // WaterEquipNum - - ReportStandAloneWaterUse(); - // Simulate WATER USE CONNECTIONS objects and connected WATER USE EQUIPMENT objects - for (WaterConnNum = 1; WaterConnNum <= modNumWaterConnections; ++WaterConnNum) { + if (!DataGlobals::BeginEnvrnFlag) MyEnvrnFlag = true; - if (!WaterConnections(WaterConnNum).StandAlone) continue; // only model non plant connections here - - auto &thisWC = WaterConnections(WaterConnNum); - thisWC.InitConnections(); - - NumIteration = 0; - - while (true) { - ++NumIteration; - - thisWC.CalcConnectionsFlowRates( FirstHVACIteration); - thisWC.CalcConnectionsDrainTemp( ); - thisWC.CalcConnectionsHeatRecovery( ); - - if (WaterConnections(WaterConnNum).TempError < Tolerance) { - break; - } else if (NumIteration > MaxIterations) { - if (!DataGlobals::WarmupFlag) { - if (WaterConnections(WaterConnNum).MaxIterationsErrorIndex == 0) { - ShowWarningError("WaterUse:Connections = " + WaterConnections(WaterConnNum).Name + - ": Heat recovery temperature did not converge"); - ShowContinueErrorTimeStamp(""); - } - ShowRecurringWarningErrorAtEnd("WaterUse:Connections = " + WaterConnections(WaterConnNum).Name + - ": Heat recovery temperature did not converge", - WaterConnections(WaterConnNum).MaxIterationsErrorIndex); - } - break; + // Simulate all unconnected WATER USE EQUIPMENT objects + for (WaterEquipNum = 1; WaterEquipNum <= modNumWaterEquipment; ++WaterEquipNum) { + if (WaterEquipment(WaterEquipNum).Connections == 0) { + CalcEquipmentFlowRates(WaterEquipNum); + CalcEquipmentDrainTemp(WaterEquipNum); } + } // WaterEquipNum - } // WHILE + ReportStandAloneWaterUse(); - thisWC.UpdateWaterConnections( ); + // Simulate WATER USE CONNECTIONS objects and connected WATER USE EQUIPMENT objects + for (WaterConnNum = 1; WaterConnNum <= modNumWaterConnections; ++WaterConnNum) { - thisWC.ReportWaterUse( ); + if (!WaterConnections(WaterConnNum).StandAlone) continue; // only model non plant connections here - } // WaterConnNum - } + InitConnections(WaterConnNum); + NumIteration = 0; - void WaterConnectionsType::simulate(const PlantLocation &calledFromLocation, bool FirstHVACIteration, Real64 &CurLoad, bool RunFlag) - { + while (true) { + ++NumIteration; - } + CalcConnectionsFlowRates(WaterConnNum, FirstHVACIteration); + CalcConnectionsDrainTemp(WaterConnNum); + CalcConnectionsHeatRecovery(WaterConnNum); + if (WaterConnections(WaterConnNum).TempError < Tolerance) { + break; + } else if (NumIteration > MaxIterations) { + if (!DataGlobals::WarmupFlag) { + if (WaterConnections(WaterConnNum).MaxIterationsErrorIndex == 0) { + ShowWarningError("WaterUse:Connections = " + WaterConnections(WaterConnNum).Name + + ": Heat recovery temperature did not converge"); + ShowContinueErrorTimeStamp(""); + } + ShowRecurringWarningErrorAtEnd("WaterUse:Connections = " + WaterConnections(WaterConnNum).Name + + ": Heat recovery temperature did not converge", + WaterConnections(WaterConnNum).MaxIterationsErrorIndex); + } + break; + } - void SimulateWaterUseConnection( - int EP_UNUSED(EquipTypeNum), std::string &CompName, int &CompIndex, bool InitLoopEquip, bool FirstHVACIteration) - { + } // WHILE - // SUBROUTINE INFORMATION: - // AUTHOR Brent Griffith March 2010, Demand Side Update - // DATE WRITTEN August 2006 - // MODIFIED - // RE-ENGINEERED na + UpdateWaterConnections(WaterConnNum); + + ReportWaterUse(WaterConnNum); - // PURPOSE OF THIS SUBROUTINE: - // Plant sim call for plant loop connected water use and connections - // (based on SimulateWaterUse by P. Ellis) - - // Locals - // SUBROUTINE PARAMETER DEFINITIONS: - int const MaxIterations(100); - Real64 const Tolerance(0.1); // Make input? - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - // INTEGER :: WaterEquipNum - int WaterConnNum; - int NumIteration; - int MaxIterationsErrorCount; - bool MyEnvrnFlag(true); - - // FLOW: - if (GetWaterUseInputFlag) { - GetWaterUseInput(); - SetupOutputVars(); - GetWaterUseInputFlag = false; + } // WaterConnNum } - if (CompIndex == 0) { - WaterConnNum = UtilityRoutines::FindItemInList(CompName, WaterConnections); - if (WaterConnNum == 0) { - ShowFatalError("SimulateWaterUseConnection: Unit not found=" + CompName); + void SimulateWaterUseConnection( + int EP_UNUSED(EquipTypeNum), std::string &CompName, int &CompIndex, bool InitLoopEquip, bool FirstHVACIteration) + { + + // SUBROUTINE INFORMATION: + // AUTHOR Brent Griffith March 2010, Demand Side Update + // DATE WRITTEN August 2006 + // MODIFIED + // RE-ENGINEERED na + + // PURPOSE OF THIS SUBROUTINE: + // Plant sim call for plant loop connected water use and connections + // (based on SimulateWaterUse by P. Ellis) + + // Locals + // SUBROUTINE PARAMETER DEFINITIONS: + int const MaxIterations(100); + Real64 const Tolerance(0.1); // Make input? + + // SUBROUTINE LOCAL VARIABLE DECLARATIONS: + // INTEGER :: WaterEquipNum + int WaterConnNum; + int NumIteration; + int MaxIterationsErrorCount; + bool MyEnvrnFlag(true); + + // FLOW: + if (GetWaterUseInputFlag) { + GetWaterUseInput(); + GetWaterUseInputFlag = false; } - CompIndex = WaterConnNum; - } else { - WaterConnNum = CompIndex; - if (WaterConnNum > modNumWaterConnections || WaterConnNum < 1) { - ShowFatalError("SimulateWaterUseConnection: Invalid CompIndex passed=" + General::TrimSigDigits(WaterConnNum) + - ", Number of Units=" + General::TrimSigDigits(modNumWaterConnections) + ", Entered Unit name=" + CompName); - } - if (CheckEquipName(WaterConnNum)) { - if (CompName != WaterConnections(WaterConnNum).Name) { + + if (CompIndex == 0) { + WaterConnNum = UtilityRoutines::FindItemInList(CompName, WaterConnections); + if (WaterConnNum == 0) { + ShowFatalError("SimulateWaterUseConnection: Unit not found=" + CompName); + } + CompIndex = WaterConnNum; + } else { + WaterConnNum = CompIndex; + if (WaterConnNum > modNumWaterConnections || WaterConnNum < 1) { ShowFatalError("SimulateWaterUseConnection: Invalid CompIndex passed=" + General::TrimSigDigits(WaterConnNum) + - ", Unit name=" + CompName + ", stored Unit Name for that index=" + WaterConnections(WaterConnNum).Name); + ", Number of Units=" + General::TrimSigDigits(modNumWaterConnections) + ", Entered Unit name=" + CompName); } - CheckEquipName(WaterConnNum) = false; - } - } - - if (InitLoopEquip) { - return; - } - - if (DataGlobals::BeginEnvrnFlag && MyEnvrnFlag) { - MaxIterationsErrorCount = 0; - if (modNumWaterEquipment > 0) { - for (int i = WaterEquipment.l(), e = WaterEquipment.u(); i <= e; ++i) { - WaterEquipment(i).reset(); + if (CheckEquipName(WaterConnNum)) { + if (CompName != WaterConnections(WaterConnNum).Name) { + ShowFatalError("SimulateWaterUseConnection: Invalid CompIndex passed=" + General::TrimSigDigits(WaterConnNum) + ", Unit name=" + CompName + + ", stored Unit Name for that index=" + WaterConnections(WaterConnNum).Name); + } + CheckEquipName(WaterConnNum) = false; } } - if (modNumWaterConnections > 0) { - for (auto &e : WaterConnections) - e.TotalMassFlowRate = 0.0; + if (InitLoopEquip) { + return; } - MyEnvrnFlag = false; - } + if (DataGlobals::BeginEnvrnFlag && MyEnvrnFlag) { + MaxIterationsErrorCount = 0; + if (modNumWaterEquipment > 0) { + for (int i = WaterEquipment.l(), e = WaterEquipment.u(); i <= e; ++i) { + WaterEquipment(i).reset(); + } + } - if (!DataGlobals::BeginEnvrnFlag) MyEnvrnFlag = true; + if (modNumWaterConnections > 0) { + for (auto &e : WaterConnections) + e.TotalMassFlowRate = 0.0; + } - auto &thisWC = WaterConnections(WaterConnNum); + MyEnvrnFlag = false; + } - thisWC.InitConnections( ); + if (!DataGlobals::BeginEnvrnFlag) MyEnvrnFlag = true; - NumIteration = 0; + InitConnections(WaterConnNum); - while (true) { - ++NumIteration; + NumIteration = 0; - thisWC.CalcConnectionsFlowRates(FirstHVACIteration); - thisWC.CalcConnectionsDrainTemp( ); - thisWC.CalcConnectionsHeatRecovery( ); + while (true) { + ++NumIteration; - if (WaterConnections(WaterConnNum).TempError < Tolerance) { - break; - } else if (NumIteration > MaxIterations) { - if (!DataGlobals::WarmupFlag) { - if (WaterConnections(WaterConnNum).MaxIterationsErrorIndex == 0) { - ShowWarningError("WaterUse:Connections = " + WaterConnections(WaterConnNum).Name + - ": Heat recovery temperature did not converge"); - ShowContinueErrorTimeStamp(""); - } - ShowRecurringWarningErrorAtEnd("WaterUse:Connections = " + WaterConnections(WaterConnNum).Name + + CalcConnectionsFlowRates(WaterConnNum, FirstHVACIteration); + CalcConnectionsDrainTemp(WaterConnNum); + CalcConnectionsHeatRecovery(WaterConnNum); + + if (WaterConnections(WaterConnNum).TempError < Tolerance) { + break; + } else if (NumIteration > MaxIterations) { + if (!DataGlobals::WarmupFlag) { + if (WaterConnections(WaterConnNum).MaxIterationsErrorIndex == 0) { + ShowWarningError("WaterUse:Connections = " + WaterConnections(WaterConnNum).Name + + ": Heat recovery temperature did not converge"); + ShowContinueErrorTimeStamp(""); + } + ShowRecurringWarningErrorAtEnd("WaterUse:Connections = " + WaterConnections(WaterConnNum).Name + ": Heat recovery temperature did not converge", - WaterConnections(WaterConnNum).MaxIterationsErrorIndex); + WaterConnections(WaterConnNum).MaxIterationsErrorIndex); + } + break; } - break; - } - } // WHILE - - thisWC.UpdateWaterConnections( ); + } // WHILE - thisWC.ReportWaterUse( ); - } + UpdateWaterConnections(WaterConnNum); - void GetWaterUseInput() - { + ReportWaterUse(WaterConnNum); + } - // SUBROUTINE INFORMATION: - // AUTHOR Peter Graham Ellis - // DATE WRITTEN August 2006 - // MODIFIED na - // RE-ENGINEERED na + void GetWaterUseInput() + { - // METHODOLOGY EMPLOYED: Standard EnergyPlus methodology. + // SUBROUTINE INFORMATION: + // AUTHOR Peter Graham Ellis + // DATE WRITTEN August 2006 + // MODIFIED na + // RE-ENGINEERED na - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - bool ErrorsFound(false); // Set to true if errors in input, fatal at end of routine - int IOStatus; // Used in GetObjectItem - int NumAlphas; // Number of Alphas for each GetObjectItem call - int NumNumbers; // Number of Numbers for each GetObjectItem call - // unused1208 INTEGER :: NumArgs - int WaterEquipNum; - int WaterConnNum; - int AlphaNum; - int thisWaterEquipNum; + // METHODOLOGY EMPLOYED: Standard EnergyPlus methodology. - // FLOW: + // SUBROUTINE LOCAL VARIABLE DECLARATIONS: + bool ErrorsFound(false); // Set to true if errors in input, fatal at end of routine + int IOStatus; // Used in GetObjectItem + int NumAlphas; // Number of Alphas for each GetObjectItem call + int NumNumbers; // Number of Numbers for each GetObjectItem call + // unused1208 INTEGER :: NumArgs + int WaterEquipNum; + int WaterConnNum; + int AlphaNum; + int thisWaterEquipNum; - DataIPShortCuts::cCurrentModuleObject = "WaterUse:Equipment"; - modNumWaterEquipment = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); + // FLOW: - if (modNumWaterEquipment > 0) { - WaterEquipment.allocate(modNumWaterEquipment); + DataIPShortCuts::cCurrentModuleObject = "WaterUse:Equipment"; + modNumWaterEquipment = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); - for (WaterEquipNum = 1; WaterEquipNum <= modNumWaterEquipment; ++WaterEquipNum) { - inputProcessor->getObjectItem(DataIPShortCuts::cCurrentModuleObject, - WaterEquipNum, - DataIPShortCuts::cAlphaArgs, - NumAlphas, - DataIPShortCuts::rNumericArgs, - NumNumbers, - IOStatus, - _, - DataIPShortCuts::lAlphaFieldBlanks, - DataIPShortCuts::cAlphaFieldNames, - DataIPShortCuts::cNumericFieldNames); - UtilityRoutines::IsNameEmpty(DataIPShortCuts::cAlphaArgs(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); - WaterEquipment(WaterEquipNum).Name = DataIPShortCuts::cAlphaArgs(1); - - WaterEquipment(WaterEquipNum).EndUseSubcatName = DataIPShortCuts::cAlphaArgs(2); - - WaterEquipment(WaterEquipNum).PeakVolFlowRate = DataIPShortCuts::rNumericArgs(1); - - if ((NumAlphas > 2) && (!DataIPShortCuts::lAlphaFieldBlanks(3))) { - WaterEquipment(WaterEquipNum).FlowRateFracSchedule = ScheduleManager::GetScheduleIndex(DataIPShortCuts::cAlphaArgs(3)); - // If no FlowRateFracSchedule, fraction defaults to 1.0 - - if (WaterEquipment(WaterEquipNum).FlowRateFracSchedule == 0) { - ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(3) + '=' + DataIPShortCuts::cAlphaArgs(3)); - ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + DataIPShortCuts::cAlphaArgs(1)); - ErrorsFound = true; + if (modNumWaterEquipment > 0) { + WaterEquipment.allocate(modNumWaterEquipment); + + for (WaterEquipNum = 1; WaterEquipNum <= modNumWaterEquipment; ++WaterEquipNum) { + inputProcessor->getObjectItem(DataIPShortCuts::cCurrentModuleObject, + WaterEquipNum, + DataIPShortCuts::cAlphaArgs, + NumAlphas, + DataIPShortCuts::rNumericArgs, + NumNumbers, + IOStatus, + _, + DataIPShortCuts::lAlphaFieldBlanks, + DataIPShortCuts::cAlphaFieldNames, + DataIPShortCuts::cNumericFieldNames); + UtilityRoutines::IsNameEmpty(DataIPShortCuts::cAlphaArgs(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); + WaterEquipment(WaterEquipNum).Name = DataIPShortCuts::cAlphaArgs(1); + + WaterEquipment(WaterEquipNum).EndUseSubcatName = DataIPShortCuts::cAlphaArgs(2); + + WaterEquipment(WaterEquipNum).PeakVolFlowRate = DataIPShortCuts::rNumericArgs(1); + + if ((NumAlphas > 2) && (!DataIPShortCuts::lAlphaFieldBlanks(3))) { + WaterEquipment(WaterEquipNum).FlowRateFracSchedule = ScheduleManager::GetScheduleIndex(DataIPShortCuts::cAlphaArgs(3)); + // If no FlowRateFracSchedule, fraction defaults to 1.0 + + if (WaterEquipment(WaterEquipNum).FlowRateFracSchedule == 0) { + ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(3) + '=' + DataIPShortCuts::cAlphaArgs(3)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + DataIPShortCuts::cAlphaArgs(1)); + ErrorsFound = true; + } } - } - if ((NumAlphas > 3) && (!DataIPShortCuts::lAlphaFieldBlanks(4))) { - WaterEquipment(WaterEquipNum).TargetTempSchedule = ScheduleManager::GetScheduleIndex(DataIPShortCuts::cAlphaArgs(4)); + if ((NumAlphas > 3) && (!DataIPShortCuts::lAlphaFieldBlanks(4))) { + WaterEquipment(WaterEquipNum).TargetTempSchedule = ScheduleManager::GetScheduleIndex(DataIPShortCuts::cAlphaArgs(4)); - if (WaterEquipment(WaterEquipNum).TargetTempSchedule == 0) { - ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(4) + '=' + DataIPShortCuts::cAlphaArgs(4)); - ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + DataIPShortCuts::cAlphaArgs(1)); - ErrorsFound = true; + if (WaterEquipment(WaterEquipNum).TargetTempSchedule == 0) { + ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(4) + '=' + DataIPShortCuts::cAlphaArgs(4)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + DataIPShortCuts::cAlphaArgs(1)); + ErrorsFound = true; + } } - } - if ((NumAlphas > 4) && (!DataIPShortCuts::lAlphaFieldBlanks(5))) { - WaterEquipment(WaterEquipNum).HotTempSchedule = ScheduleManager::GetScheduleIndex(DataIPShortCuts::cAlphaArgs(5)); - // If no HotTempSchedule, there is no hot water. - // HotTempSchedule is ignored if connected to a plant loop via WATER USE CONNECTIONS + if ((NumAlphas > 4) && (!DataIPShortCuts::lAlphaFieldBlanks(5))) { + WaterEquipment(WaterEquipNum).HotTempSchedule = ScheduleManager::GetScheduleIndex(DataIPShortCuts::cAlphaArgs(5)); + // If no HotTempSchedule, there is no hot water. + // HotTempSchedule is ignored if connected to a plant loop via WATER USE CONNECTIONS - if (WaterEquipment(WaterEquipNum).HotTempSchedule == 0) { - ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(5) + '=' + DataIPShortCuts::cAlphaArgs(5)); - ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + DataIPShortCuts::cAlphaArgs(1)); - ErrorsFound = true; + if (WaterEquipment(WaterEquipNum).HotTempSchedule == 0) { + ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(5) + '=' + DataIPShortCuts::cAlphaArgs(5)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + DataIPShortCuts::cAlphaArgs(1)); + ErrorsFound = true; + } } - } - if ((NumAlphas > 5) && (!DataIPShortCuts::lAlphaFieldBlanks(6))) { - WaterEquipment(WaterEquipNum).ColdTempSchedule = ScheduleManager::GetScheduleIndex(DataIPShortCuts::cAlphaArgs(6)); - // If no ColdTempSchedule, temperatures will be calculated by WATER MAINS TEMPERATURES object + if ((NumAlphas > 5) && (!DataIPShortCuts::lAlphaFieldBlanks(6))) { + WaterEquipment(WaterEquipNum).ColdTempSchedule = ScheduleManager::GetScheduleIndex(DataIPShortCuts::cAlphaArgs(6)); + // If no ColdTempSchedule, temperatures will be calculated by WATER MAINS TEMPERATURES object - if (WaterEquipment(WaterEquipNum).ColdTempSchedule == 0) { - ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(6) + '=' + DataIPShortCuts::cAlphaArgs(6)); - ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + DataIPShortCuts::cAlphaArgs(1)); - ErrorsFound = true; + if (WaterEquipment(WaterEquipNum).ColdTempSchedule == 0) { + ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(6) + '=' + DataIPShortCuts::cAlphaArgs(6)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + DataIPShortCuts::cAlphaArgs(1)); + ErrorsFound = true; + } } - } - if ((NumAlphas > 6) && (!DataIPShortCuts::lAlphaFieldBlanks(7))) { - WaterEquipment(WaterEquipNum).Zone = UtilityRoutines::FindItemInList(DataIPShortCuts::cAlphaArgs(7), DataHeatBalance::Zone); + if ((NumAlphas > 6) && (!DataIPShortCuts::lAlphaFieldBlanks(7))) { + WaterEquipment(WaterEquipNum).Zone = UtilityRoutines::FindItemInList(DataIPShortCuts::cAlphaArgs(7), DataHeatBalance::Zone); - if (WaterEquipment(WaterEquipNum).Zone == 0) { - ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(7) + '=' + DataIPShortCuts::cAlphaArgs(7)); - ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + DataIPShortCuts::cAlphaArgs(1)); - ErrorsFound = true; + if (WaterEquipment(WaterEquipNum).Zone == 0) { + ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(7) + '=' + DataIPShortCuts::cAlphaArgs(7)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + DataIPShortCuts::cAlphaArgs(1)); + ErrorsFound = true; + } } - } - if ((NumAlphas > 7) && (!DataIPShortCuts::lAlphaFieldBlanks(8))) { - WaterEquipment(WaterEquipNum).SensibleFracSchedule = ScheduleManager::GetScheduleIndex(DataIPShortCuts::cAlphaArgs(8)); + if ((NumAlphas > 7) && (!DataIPShortCuts::lAlphaFieldBlanks(8))) { + WaterEquipment(WaterEquipNum).SensibleFracSchedule = ScheduleManager::GetScheduleIndex(DataIPShortCuts::cAlphaArgs(8)); - if (WaterEquipment(WaterEquipNum).SensibleFracSchedule == 0) { - ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(8) + '=' + DataIPShortCuts::cAlphaArgs(8)); - ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + DataIPShortCuts::cAlphaArgs(1)); - ErrorsFound = true; + if (WaterEquipment(WaterEquipNum).SensibleFracSchedule == 0) { + ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(8) + '=' + DataIPShortCuts::cAlphaArgs(8)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + DataIPShortCuts::cAlphaArgs(1)); + ErrorsFound = true; + } } - } - if ((NumAlphas > 8) && (!DataIPShortCuts::lAlphaFieldBlanks(9))) { - WaterEquipment(WaterEquipNum).LatentFracSchedule = ScheduleManager::GetScheduleIndex(DataIPShortCuts::cAlphaArgs(9)); + if ((NumAlphas > 8) && (!DataIPShortCuts::lAlphaFieldBlanks(9))) { + WaterEquipment(WaterEquipNum).LatentFracSchedule = ScheduleManager::GetScheduleIndex(DataIPShortCuts::cAlphaArgs(9)); - if (WaterEquipment(WaterEquipNum).LatentFracSchedule == 0) { - ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(9) + '=' + DataIPShortCuts::cAlphaArgs(9)); - ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + DataIPShortCuts::cAlphaArgs(1)); - ErrorsFound = true; + if (WaterEquipment(WaterEquipNum).LatentFracSchedule == 0) { + ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(9) + '=' + DataIPShortCuts::cAlphaArgs(9)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + DataIPShortCuts::cAlphaArgs(1)); + ErrorsFound = true; + } } - } - } // WaterEquipNum + } // WaterEquipNum - if (ErrorsFound) ShowFatalError("Errors found in processing input for " + DataIPShortCuts::cCurrentModuleObject); - } - - DataIPShortCuts::cCurrentModuleObject = "WaterUse:Connections"; - modNumWaterConnections = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); - - if (modNumWaterConnections > 0) { - WaterConnections.allocate(modNumWaterConnections); - - for (WaterConnNum = 1; WaterConnNum <= modNumWaterConnections; ++WaterConnNum) { - inputProcessor->getObjectItem(DataIPShortCuts::cCurrentModuleObject, - WaterConnNum, - DataIPShortCuts::cAlphaArgs, - NumAlphas, - DataIPShortCuts::rNumericArgs, - NumNumbers, - IOStatus, - _, - DataIPShortCuts::lAlphaFieldBlanks, - DataIPShortCuts::cAlphaFieldNames, - DataIPShortCuts::cNumericFieldNames); - UtilityRoutines::IsNameEmpty(DataIPShortCuts::cAlphaArgs(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); - WaterConnections(WaterConnNum).Name = DataIPShortCuts::cAlphaArgs(1); - - if ((!DataIPShortCuts::lAlphaFieldBlanks(2)) || (!DataIPShortCuts::lAlphaFieldBlanks(3))) { - WaterConnections(WaterConnNum).InletNode = NodeInputManager::GetOnlySingleNode(DataIPShortCuts::cAlphaArgs(2), - ErrorsFound, - DataIPShortCuts::cCurrentModuleObject, - DataIPShortCuts::cAlphaArgs(1), - DataLoopNode::NodeType_Water, - DataLoopNode::NodeConnectionType_Inlet, - 1, - DataLoopNode::ObjectIsNotParent); - WaterConnections(WaterConnNum).OutletNode = NodeInputManager::GetOnlySingleNode(DataIPShortCuts::cAlphaArgs(3), - ErrorsFound, - DataIPShortCuts::cCurrentModuleObject, - DataIPShortCuts::cAlphaArgs(1), - DataLoopNode::NodeType_Water, - DataLoopNode::NodeConnectionType_Outlet, - 1, - DataLoopNode::ObjectIsNotParent); - - // Check plant connections - BranchNodeConnections::TestCompSet(DataIPShortCuts::cCurrentModuleObject, - DataIPShortCuts::cAlphaArgs(1), - DataIPShortCuts::cAlphaArgs(2), - DataIPShortCuts::cAlphaArgs(3), - "DHW Nodes"); - } else { - // If no plant nodes are connected, simulate in stand-alone mode. - WaterConnections(WaterConnNum).StandAlone = true; - } - - if (!DataIPShortCuts::lAlphaFieldBlanks(4)) { - WaterManager::SetupTankDemandComponent(WaterConnections(WaterConnNum).Name, - DataIPShortCuts::cCurrentModuleObject, - DataIPShortCuts::cAlphaArgs(4), - ErrorsFound, - WaterConnections(WaterConnNum).SupplyTankNum, - WaterConnections(WaterConnNum).TankDemandID); - } - - if (!DataIPShortCuts::lAlphaFieldBlanks(5)) { - WaterManager::SetupTankSupplyComponent(WaterConnections(WaterConnNum).Name, - DataIPShortCuts::cCurrentModuleObject, - DataIPShortCuts::cAlphaArgs(5), - ErrorsFound, - WaterConnections(WaterConnNum).RecoveryTankNum, - WaterConnections(WaterConnNum).TankSupplyID); - } + if (ErrorsFound) ShowFatalError("Errors found in processing input for " + DataIPShortCuts::cCurrentModuleObject); + } - if (!DataIPShortCuts::lAlphaFieldBlanks(6)) { - WaterConnections(WaterConnNum).HotTempSchedule = ScheduleManager::GetScheduleIndex(DataIPShortCuts::cAlphaArgs(6)); - // If no HotTempSchedule, there is no hot water. - // HotTempSchedule is ignored if connected to a plant loop via WATER USE CONNECTIONS + DataIPShortCuts::cCurrentModuleObject = "WaterUse:Connections"; + modNumWaterConnections = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); - if (WaterConnections(WaterConnNum).HotTempSchedule == 0) { - ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(6) + '=' + DataIPShortCuts::cAlphaArgs(6)); - ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + DataIPShortCuts::cAlphaArgs(1)); - ErrorsFound = true; + if (modNumWaterConnections > 0) { + WaterConnections.allocate(modNumWaterConnections); + + for (WaterConnNum = 1; WaterConnNum <= modNumWaterConnections; ++WaterConnNum) { + inputProcessor->getObjectItem(DataIPShortCuts::cCurrentModuleObject, + WaterConnNum, + DataIPShortCuts::cAlphaArgs, + NumAlphas, + DataIPShortCuts::rNumericArgs, + NumNumbers, + IOStatus, + _, + DataIPShortCuts::lAlphaFieldBlanks, + DataIPShortCuts::cAlphaFieldNames, + DataIPShortCuts::cNumericFieldNames); + UtilityRoutines::IsNameEmpty(DataIPShortCuts::cAlphaArgs(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); + WaterConnections(WaterConnNum).Name = DataIPShortCuts::cAlphaArgs(1); + + if ((!DataIPShortCuts::lAlphaFieldBlanks(2)) || (!DataIPShortCuts::lAlphaFieldBlanks(3))) { + WaterConnections(WaterConnNum).InletNode = NodeInputManager::GetOnlySingleNode(DataIPShortCuts::cAlphaArgs(2), + ErrorsFound, + DataIPShortCuts::cCurrentModuleObject, + DataIPShortCuts::cAlphaArgs(1), + DataLoopNode::NodeType_Water, + DataLoopNode::NodeConnectionType_Inlet, + 1, + DataLoopNode::ObjectIsNotParent); + WaterConnections(WaterConnNum).OutletNode = NodeInputManager::GetOnlySingleNode(DataIPShortCuts::cAlphaArgs(3), + ErrorsFound, + DataIPShortCuts::cCurrentModuleObject, + DataIPShortCuts::cAlphaArgs(1), + DataLoopNode::NodeType_Water, + DataLoopNode::NodeConnectionType_Outlet, + 1, + DataLoopNode::ObjectIsNotParent); + + // Check plant connections + BranchNodeConnections::TestCompSet(DataIPShortCuts::cCurrentModuleObject, + DataIPShortCuts::cAlphaArgs(1), + DataIPShortCuts::cAlphaArgs(2), + DataIPShortCuts::cAlphaArgs(3), + "DHW Nodes"); + } else { + // If no plant nodes are connected, simulate in stand-alone mode. + WaterConnections(WaterConnNum).StandAlone = true; } - } - if (!DataIPShortCuts::lAlphaFieldBlanks(7)) { - WaterConnections(WaterConnNum).ColdTempSchedule = ScheduleManager::GetScheduleIndex(DataIPShortCuts::cAlphaArgs(7)); - // If no ColdTempSchedule, temperatures will be calculated by WATER MAINS TEMPERATURES object + if (!DataIPShortCuts::lAlphaFieldBlanks(4)) { + WaterManager::SetupTankDemandComponent(WaterConnections(WaterConnNum).Name, + DataIPShortCuts::cCurrentModuleObject, + DataIPShortCuts::cAlphaArgs(4), + ErrorsFound, + WaterConnections(WaterConnNum).SupplyTankNum, + WaterConnections(WaterConnNum).TankDemandID); + } - if (WaterConnections(WaterConnNum).ColdTempSchedule == 0) { - ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(7) + '=' + DataIPShortCuts::cAlphaArgs(7)); - ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + DataIPShortCuts::cAlphaArgs(1)); - ErrorsFound = true; + if (!DataIPShortCuts::lAlphaFieldBlanks(5)) { + WaterManager::SetupTankSupplyComponent(WaterConnections(WaterConnNum).Name, + DataIPShortCuts::cCurrentModuleObject, + DataIPShortCuts::cAlphaArgs(5), + ErrorsFound, + WaterConnections(WaterConnNum).RecoveryTankNum, + WaterConnections(WaterConnNum).TankSupplyID); } - } - if ((!DataIPShortCuts::lAlphaFieldBlanks(8)) && (DataIPShortCuts::cAlphaArgs(8) != "NONE")) { - WaterConnections(WaterConnNum).HeatRecovery = true; - - { - auto const SELECT_CASE_var(DataIPShortCuts::cAlphaArgs(8)); - if (SELECT_CASE_var == "IDEAL") { - WaterConnections(WaterConnNum).HeatRecoveryHX = HeatRecoveryHXIdeal; - } else if (SELECT_CASE_var == "COUNTERFLOW") { - WaterConnections(WaterConnNum).HeatRecoveryHX = HeatRecoveryHXCounterFlow; - } else if (SELECT_CASE_var == "CROSSFLOW") { - WaterConnections(WaterConnNum).HeatRecoveryHX = HeatRecoveryHXCrossFlow; - } else { - ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(8) + '=' + DataIPShortCuts::cAlphaArgs(8)); + if (!DataIPShortCuts::lAlphaFieldBlanks(6)) { + WaterConnections(WaterConnNum).HotTempSchedule = ScheduleManager::GetScheduleIndex(DataIPShortCuts::cAlphaArgs(6)); + // If no HotTempSchedule, there is no hot water. + // HotTempSchedule is ignored if connected to a plant loop via WATER USE CONNECTIONS + + if (WaterConnections(WaterConnNum).HotTempSchedule == 0) { + ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(6) + '=' + DataIPShortCuts::cAlphaArgs(6)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + DataIPShortCuts::cAlphaArgs(1)); ErrorsFound = true; } } - { - auto const SELECT_CASE_var(DataIPShortCuts::cAlphaArgs(9)); - if (SELECT_CASE_var == "PLANT") { - WaterConnections(WaterConnNum).HeatRecoveryConfig = HeatRecoveryConfigPlant; - } else if (SELECT_CASE_var == "EQUIPMENT") { - WaterConnections(WaterConnNum).HeatRecoveryConfig = HeatRecoveryConfigEquipment; - } else if (SELECT_CASE_var == "PLANTANDEQUIPMENT") { - WaterConnections(WaterConnNum).HeatRecoveryConfig = HeatRecoveryConfigPlantAndEquip; - } else { - ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(9) + '=' + DataIPShortCuts::cAlphaArgs(9)); + if (!DataIPShortCuts::lAlphaFieldBlanks(7)) { + WaterConnections(WaterConnNum).ColdTempSchedule = ScheduleManager::GetScheduleIndex(DataIPShortCuts::cAlphaArgs(7)); + // If no ColdTempSchedule, temperatures will be calculated by WATER MAINS TEMPERATURES object + + if (WaterConnections(WaterConnNum).ColdTempSchedule == 0) { + ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(7) + '=' + DataIPShortCuts::cAlphaArgs(7)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + DataIPShortCuts::cAlphaArgs(1)); ErrorsFound = true; } } - } - WaterConnections(WaterConnNum).HXUA = DataIPShortCuts::rNumericArgs(1); + if ((!DataIPShortCuts::lAlphaFieldBlanks(8)) && (DataIPShortCuts::cAlphaArgs(8) != "NONE")) { + WaterConnections(WaterConnNum).HeatRecovery = true; + + { + auto const SELECT_CASE_var(DataIPShortCuts::cAlphaArgs(8)); + if (SELECT_CASE_var == "IDEAL") { + WaterConnections(WaterConnNum).HeatRecoveryHX = HeatRecoveryHXIdeal; + } else if (SELECT_CASE_var == "COUNTERFLOW") { + WaterConnections(WaterConnNum).HeatRecoveryHX = HeatRecoveryHXCounterFlow; + } else if (SELECT_CASE_var == "CROSSFLOW") { + WaterConnections(WaterConnNum).HeatRecoveryHX = HeatRecoveryHXCrossFlow; + } else { + ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(8) + '=' + DataIPShortCuts::cAlphaArgs(8)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + DataIPShortCuts::cAlphaArgs(1)); + ErrorsFound = true; + } + } + + { + auto const SELECT_CASE_var(DataIPShortCuts::cAlphaArgs(9)); + if (SELECT_CASE_var == "PLANT") { + WaterConnections(WaterConnNum).HeatRecoveryConfig = HeatRecoveryConfigPlant; + } else if (SELECT_CASE_var == "EQUIPMENT") { + WaterConnections(WaterConnNum).HeatRecoveryConfig = HeatRecoveryConfigEquipment; + } else if (SELECT_CASE_var == "PLANTANDEQUIPMENT") { + WaterConnections(WaterConnNum).HeatRecoveryConfig = HeatRecoveryConfigPlantAndEquip; + } else { + ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(9) + '=' + DataIPShortCuts::cAlphaArgs(9)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + DataIPShortCuts::cAlphaArgs(1)); + ErrorsFound = true; + } + } + } - WaterConnections(WaterConnNum).WaterEquipment_intArr.allocate(NumAlphas - 9); + WaterConnections(WaterConnNum).HXUA = DataIPShortCuts::rNumericArgs(1); - for (AlphaNum = 10; AlphaNum <= NumAlphas; ++AlphaNum) { - WaterEquipNum = UtilityRoutines::FindItemInList(DataIPShortCuts::cAlphaArgs(AlphaNum), WaterEquipment); + WaterConnections(WaterConnNum).WaterEquipment.allocate(NumAlphas - 9); - if (WaterEquipNum == 0) { - ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(AlphaNum) + '=' + DataIPShortCuts::cAlphaArgs(AlphaNum)); - ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + DataIPShortCuts::cAlphaArgs(1)); - ErrorsFound = true; - } else { - if (WaterEquipment(WaterEquipNum).Connections > 0) { - ShowSevereError(DataIPShortCuts::cCurrentModuleObject + " = " + DataIPShortCuts::cAlphaArgs(1) + - ": WaterUse:Equipment = " + DataIPShortCuts::cAlphaArgs(AlphaNum) + - " is already referenced by another object."); + for (AlphaNum = 10; AlphaNum <= NumAlphas; ++AlphaNum) { + WaterEquipNum = UtilityRoutines::FindItemInList(DataIPShortCuts::cAlphaArgs(AlphaNum), WaterEquipment); + + if (WaterEquipNum == 0) { + ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(AlphaNum) + '=' + DataIPShortCuts::cAlphaArgs(AlphaNum)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + DataIPShortCuts::cAlphaArgs(1)); ErrorsFound = true; } else { - WaterEquipment(WaterEquipNum).Connections = WaterConnNum; + if (WaterEquipment(WaterEquipNum).Connections > 0) { + ShowSevereError(DataIPShortCuts::cCurrentModuleObject + " = " + DataIPShortCuts::cAlphaArgs(1) + + ": WaterUse:Equipment = " + + DataIPShortCuts::cAlphaArgs(AlphaNum) + + " is already referenced by another object."); + ErrorsFound = true; + } else { + WaterEquipment(WaterEquipNum).Connections = WaterConnNum; - ++WaterConnections(WaterConnNum).NumWaterEquipment; - WaterConnections(WaterConnNum).WaterEquipment_intArr(WaterConnections(WaterConnNum).NumWaterEquipment) = WaterEquipNum; + ++WaterConnections(WaterConnNum).NumWaterEquipment; + WaterConnections(WaterConnNum).WaterEquipment(WaterConnections(WaterConnNum).NumWaterEquipment) = WaterEquipNum; - WaterConnections(WaterConnNum).PeakVolFlowRate += - WaterEquipment(WaterEquipNum).PeakVolFlowRate; // this does not include possible multipliers + WaterConnections(WaterConnNum).PeakVolFlowRate += + WaterEquipment(WaterEquipNum).PeakVolFlowRate; // this does not include possible multipliers + } } } - } - } // WaterConnNum + } // WaterConnNum - if (ErrorsFound) ShowFatalError("Errors found in processing input for " + DataIPShortCuts::cCurrentModuleObject); + if (ErrorsFound) ShowFatalError("Errors found in processing input for " + DataIPShortCuts::cCurrentModuleObject); - if (modNumWaterConnections > 0) { - CheckEquipName.allocate(modNumWaterConnections); - CheckPlantLoop.allocate(modNumWaterConnections); - CheckEquipName = true; - CheckPlantLoop = true; + if (modNumWaterConnections > 0) { + CheckEquipName.allocate(modNumWaterConnections); + CheckPlantLoop.allocate(modNumWaterConnections); + CheckEquipName = true; + CheckPlantLoop = true; + } } - } - // determine connection's peak mass flow rates. - if (modNumWaterConnections > 0) { - for (WaterConnNum = 1; WaterConnNum <= modNumWaterConnections; ++WaterConnNum) { - WaterConnections(WaterConnNum).PeakMassFlowRate = 0.0; - for (WaterEquipNum = 1; WaterEquipNum <= WaterConnections(WaterConnNum).NumWaterEquipment; ++WaterEquipNum) { - thisWaterEquipNum = WaterConnections(WaterConnNum).WaterEquipment_intArr(WaterEquipNum); - if (WaterEquipment(thisWaterEquipNum).Zone > 0) { - WaterConnections(WaterConnNum).PeakMassFlowRate += - WaterEquipment(thisWaterEquipNum).PeakVolFlowRate * Psychrometrics::RhoH2O(DataGlobals::InitConvTemp) * - DataHeatBalance::Zone(WaterEquipment(thisWaterEquipNum).Zone).Multiplier * - DataHeatBalance::Zone(WaterEquipment(thisWaterEquipNum).Zone).ListMultiplier; - } else { // can't have multipliers - WaterConnections(WaterConnNum).PeakMassFlowRate += - WaterEquipment(thisWaterEquipNum).PeakVolFlowRate * Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); + // determine connection's peak mass flow rates. + if (modNumWaterConnections > 0) { + for (WaterConnNum = 1; WaterConnNum <= modNumWaterConnections; ++WaterConnNum) { + WaterConnections(WaterConnNum).PeakMassFlowRate = 0.0; + for (WaterEquipNum = 1; WaterEquipNum <= WaterConnections(WaterConnNum).NumWaterEquipment; ++WaterEquipNum) { + thisWaterEquipNum = WaterConnections(WaterConnNum).WaterEquipment(WaterEquipNum); + if (WaterEquipment(thisWaterEquipNum).Zone > 0) { + WaterConnections(WaterConnNum).PeakMassFlowRate += + WaterEquipment(thisWaterEquipNum).PeakVolFlowRate * Psychrometrics::RhoH2O(DataGlobals::InitConvTemp) * + DataHeatBalance::Zone(WaterEquipment(thisWaterEquipNum).Zone).Multiplier * DataHeatBalance::Zone(WaterEquipment(thisWaterEquipNum).Zone).ListMultiplier; + } else { // can't have multipliers + WaterConnections(WaterConnNum).PeakMassFlowRate += + WaterEquipment(thisWaterEquipNum).PeakVolFlowRate * Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); + } } + PlantUtilities::RegisterPlantCompDesignFlow(WaterConnections(WaterConnNum).InletNode, + WaterConnections(WaterConnNum).PeakMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp)); } - PlantUtilities::RegisterPlantCompDesignFlow(WaterConnections(WaterConnNum).InletNode, - WaterConnections(WaterConnNum).PeakMassFlowRate / - Psychrometrics::RhoH2O(DataGlobals::InitConvTemp)); } - } - - - - - - } - - void SetupOutputVars() - { - // Setup EQUIPMENT report variables (now that connections have been established) - // CurrentModuleObject='WaterUse:Equipment' - int WaterEquipNum; - int WaterConnNum; - - DataIPShortCuts::cCurrentModuleObject = "WaterUse:Equipment"; - modNumWaterEquipment = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); - - DataIPShortCuts::cCurrentModuleObject = "WaterUse:Connections"; - modNumWaterConnections = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); - - if (modNumWaterEquipment > 0) { + + // Setup EQUIPMENT report variables (now that connections have been established) + // CurrentModuleObject='WaterUse:Equipment' for (WaterEquipNum = 1; WaterEquipNum <= modNumWaterEquipment; ++WaterEquipNum) { SetupOutputVariable("Water Use Equipment Hot Water Mass Flow Rate", @@ -884,6 +853,7 @@ namespace WaterUse { "System", "Sum", WaterEquipment(WaterEquipNum).Name); + SetupZoneInternalGain(WaterEquipment(WaterEquipNum).Zone, "WaterUse:Equipment", WaterEquipment(WaterEquipNum).Name, @@ -891,17 +861,13 @@ namespace WaterUse { WaterEquipment(WaterEquipNum).SensibleRateNoMultiplier, _, _, - WaterEquipment(WaterEquipNum).LatentRateNoMultiplier); + WaterEquipment(WaterEquipNum).LatentRateNoMultiplier); } } // WaterEquipNum - } else { - ShowFatalError("Errors found in setup OutputVariables in processing input for " + DataIPShortCuts::cCurrentModuleObject); - } - // Setup CONNECTIONS report variables (don't put any on meters; they are metered at WATER USE EQUIPMENT level) - // CurrentModuleObject='WaterUse:Connections' - if (modNumWaterConnections > 0) { + // Setup CONNECTIONS report variables (don't put any on meters; they are metered at WATER USE EQUIPMENT level) + // CurrentModuleObject='WaterUse:Connections' for (WaterConnNum = 1; WaterConnNum <= modNumWaterConnections; ++WaterConnNum) { SetupOutputVariable("Water Use Connections Hot Water Mass Flow Rate", @@ -1063,793 +1029,808 @@ namespace WaterUse { } } // WaterConnNum - } else { - ShowFatalError("Errors found in setup OutputVariables in processing input for " + DataIPShortCuts::cCurrentModuleObject); } - } - void CalcEquipmentFlowRates(int WaterEquipNum) - { + void CalcEquipmentFlowRates(int WaterEquipNum) + { - // SUBROUTINE INFORMATION: - // AUTHOR Peter Graham Ellis - // DATE WRITTEN August 2006 - // MODIFIED na - // RE-ENGINEERED na + // SUBROUTINE INFORMATION: + // AUTHOR Peter Graham Ellis + // DATE WRITTEN August 2006 + // MODIFIED na + // RE-ENGINEERED na - // PURPOSE OF THIS SUBROUTINE: - // Calculate desired hot and cold water flow rates + // PURPOSE OF THIS SUBROUTINE: + // Calculate desired hot and cold water flow rates - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - int WaterConnNum; - // FLOW: - WaterConnNum = WaterEquipment(WaterEquipNum).Connections; + // SUBROUTINE LOCAL VARIABLE DECLARATIONS: + int WaterConnNum; - if (WaterConnNum > 0) { - // Get water temperature conditions from the CONNECTIONS object - WaterEquipment(WaterEquipNum).ColdTemp = WaterConnections(WaterConnNum).ColdTemp; - WaterEquipment(WaterEquipNum).HotTemp = WaterConnections(WaterConnNum).HotTemp; + // FLOW: + WaterConnNum = WaterEquipment(WaterEquipNum).Connections; - } else { - // Get water temperature conditions from the WATER USE EQUIPMENT schedules - if (WaterEquipment(WaterEquipNum).ColdTempSchedule > 0) { - WaterEquipment(WaterEquipNum).ColdTemp = ScheduleManager::GetCurrentScheduleValue(WaterEquipment(WaterEquipNum).ColdTempSchedule); - } else { // If no ColdTempSchedule, use the mains temperature - WaterEquipment(WaterEquipNum).ColdTemp = DataEnvironment::WaterMainsTemp; - } + if (WaterConnNum > 0) { + // Get water temperature conditions from the CONNECTIONS object + WaterEquipment(WaterEquipNum).ColdTemp = WaterConnections(WaterConnNum).ColdTemp; + WaterEquipment(WaterEquipNum).HotTemp = WaterConnections(WaterConnNum).HotTemp; - if (WaterEquipment(WaterEquipNum).HotTempSchedule > 0) { - WaterEquipment(WaterEquipNum).HotTemp = ScheduleManager::GetCurrentScheduleValue(WaterEquipment(WaterEquipNum).HotTempSchedule); - } else { // If no HotTempSchedule, use all cold water - WaterEquipment(WaterEquipNum).HotTemp = WaterEquipment(WaterEquipNum).ColdTemp; - } - } + } else { + // Get water temperature conditions from the WATER USE EQUIPMENT schedules + if (WaterEquipment(WaterEquipNum).ColdTempSchedule > 0) { + WaterEquipment(WaterEquipNum).ColdTemp = ScheduleManager::GetCurrentScheduleValue(WaterEquipment(WaterEquipNum).ColdTempSchedule); + } else { // If no ColdTempSchedule, use the mains temperature + WaterEquipment(WaterEquipNum).ColdTemp = DataEnvironment::WaterMainsTemp; + } - if (WaterEquipment(WaterEquipNum).TargetTempSchedule > 0) { - WaterEquipment(WaterEquipNum).TargetTemp = ScheduleManager::GetCurrentScheduleValue(WaterEquipment(WaterEquipNum).TargetTempSchedule); - } else { // If no TargetTempSchedule, use all hot water - WaterEquipment(WaterEquipNum).TargetTemp = WaterEquipment(WaterEquipNum).HotTemp; - } + if (WaterEquipment(WaterEquipNum).HotTempSchedule > 0) { + WaterEquipment(WaterEquipNum).HotTemp = ScheduleManager::GetCurrentScheduleValue(WaterEquipment(WaterEquipNum).HotTempSchedule); + } else { // If no HotTempSchedule, use all cold water + WaterEquipment(WaterEquipNum).HotTemp = WaterEquipment(WaterEquipNum).ColdTemp; + } + } - // Get the requested total flow rate - // 11-17-2006 BG Added multipliers in next block - if (WaterEquipment(WaterEquipNum).Zone > 0) { - if (WaterEquipment(WaterEquipNum).FlowRateFracSchedule > 0) { - WaterEquipment(WaterEquipNum).TotalVolFlowRate = - WaterEquipment(WaterEquipNum).PeakVolFlowRate * - ScheduleManager::GetCurrentScheduleValue(WaterEquipment(WaterEquipNum).FlowRateFracSchedule) * - DataHeatBalance::Zone(WaterEquipment(WaterEquipNum).Zone).Multiplier * - DataHeatBalance::Zone(WaterEquipment(WaterEquipNum).Zone).ListMultiplier; - } else { - WaterEquipment(WaterEquipNum).TotalVolFlowRate = WaterEquipment(WaterEquipNum).PeakVolFlowRate * - DataHeatBalance::Zone(WaterEquipment(WaterEquipNum).Zone).Multiplier * - DataHeatBalance::Zone(WaterEquipment(WaterEquipNum).Zone).ListMultiplier; + if (WaterEquipment(WaterEquipNum).TargetTempSchedule > 0) { + WaterEquipment(WaterEquipNum).TargetTemp = ScheduleManager::GetCurrentScheduleValue(WaterEquipment(WaterEquipNum).TargetTempSchedule); + } else { // If no TargetTempSchedule, use all hot water + WaterEquipment(WaterEquipNum).TargetTemp = WaterEquipment(WaterEquipNum).HotTemp; } - } else { - if (WaterEquipment(WaterEquipNum).FlowRateFracSchedule > 0) { - WaterEquipment(WaterEquipNum).TotalVolFlowRate = - WaterEquipment(WaterEquipNum).PeakVolFlowRate * - ScheduleManager::GetCurrentScheduleValue(WaterEquipment(WaterEquipNum).FlowRateFracSchedule); + + // Get the requested total flow rate + // 11-17-2006 BG Added multipliers in next block + if (WaterEquipment(WaterEquipNum).Zone > 0) { + if (WaterEquipment(WaterEquipNum).FlowRateFracSchedule > 0) { + WaterEquipment(WaterEquipNum).TotalVolFlowRate = + WaterEquipment(WaterEquipNum).PeakVolFlowRate * + ScheduleManager::GetCurrentScheduleValue(WaterEquipment(WaterEquipNum).FlowRateFracSchedule) * + DataHeatBalance::Zone(WaterEquipment(WaterEquipNum).Zone).Multiplier * DataHeatBalance::Zone(WaterEquipment(WaterEquipNum).Zone).ListMultiplier; + } else { + WaterEquipment(WaterEquipNum).TotalVolFlowRate = WaterEquipment(WaterEquipNum).PeakVolFlowRate * + DataHeatBalance::Zone(WaterEquipment(WaterEquipNum).Zone).Multiplier * + DataHeatBalance::Zone(WaterEquipment(WaterEquipNum).Zone).ListMultiplier; + } } else { - WaterEquipment(WaterEquipNum).TotalVolFlowRate = WaterEquipment(WaterEquipNum).PeakVolFlowRate; + if (WaterEquipment(WaterEquipNum).FlowRateFracSchedule > 0) { + WaterEquipment(WaterEquipNum).TotalVolFlowRate = + WaterEquipment(WaterEquipNum).PeakVolFlowRate * + ScheduleManager::GetCurrentScheduleValue(WaterEquipment(WaterEquipNum).FlowRateFracSchedule); + } else { + WaterEquipment(WaterEquipNum).TotalVolFlowRate = WaterEquipment(WaterEquipNum).PeakVolFlowRate; + } } - } - WaterEquipment(WaterEquipNum).TotalMassFlowRate = - WaterEquipment(WaterEquipNum).TotalVolFlowRate * Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); + WaterEquipment(WaterEquipNum).TotalMassFlowRate = + WaterEquipment(WaterEquipNum).TotalVolFlowRate * Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); - // Calculate hot and cold water mixing at the tap - if (WaterEquipment(WaterEquipNum).TotalMassFlowRate > 0.0) { - // Calculate the flow rates needed to meet the target temperature - if (WaterEquipment(WaterEquipNum).HotTemp == WaterEquipment(WaterEquipNum).ColdTemp) { // Avoid divide by zero - // There is no hot water - WaterEquipment(WaterEquipNum).HotMassFlowRate = 0.0; + // Calculate hot and cold water mixing at the tap + if (WaterEquipment(WaterEquipNum).TotalMassFlowRate > 0.0) { + // Calculate the flow rates needed to meet the target temperature + if (WaterEquipment(WaterEquipNum).HotTemp == WaterEquipment(WaterEquipNum).ColdTemp) { // Avoid divide by zero + // There is no hot water + WaterEquipment(WaterEquipNum).HotMassFlowRate = 0.0; - // Need a special case for HotTemp < ColdTemp, due to bad user input (but could happen in a plant loop accidentally) + // Need a special case for HotTemp < ColdTemp, due to bad user input (but could happen in a plant loop accidentally) - } else if (WaterEquipment(WaterEquipNum).TargetTemp > WaterEquipment(WaterEquipNum).HotTemp) { - WaterEquipment(WaterEquipNum).HotMassFlowRate = WaterEquipment(WaterEquipNum).TotalMassFlowRate; + } else if (WaterEquipment(WaterEquipNum).TargetTemp > WaterEquipment(WaterEquipNum).HotTemp) { + WaterEquipment(WaterEquipNum).HotMassFlowRate = WaterEquipment(WaterEquipNum).TotalMassFlowRate; - } else { - WaterEquipment(WaterEquipNum).HotMassFlowRate = WaterEquipment(WaterEquipNum).TotalMassFlowRate * - (WaterEquipment(WaterEquipNum).TargetTemp - WaterEquipment(WaterEquipNum).ColdTemp) / - (WaterEquipment(WaterEquipNum).HotTemp - WaterEquipment(WaterEquipNum).ColdTemp); - } + } else { + WaterEquipment(WaterEquipNum).HotMassFlowRate = WaterEquipment(WaterEquipNum).TotalMassFlowRate * + (WaterEquipment(WaterEquipNum).TargetTemp - WaterEquipment(WaterEquipNum).ColdTemp) / + (WaterEquipment(WaterEquipNum).HotTemp - WaterEquipment(WaterEquipNum).ColdTemp); + } - if (WaterEquipment(WaterEquipNum).HotMassFlowRate < 0.0) { - // Target temp is colder than the cold water temp; don't allow colder - WaterEquipment(WaterEquipNum).HotMassFlowRate = 0.0; - } + if (WaterEquipment(WaterEquipNum).HotMassFlowRate < 0.0) { + // Target temp is colder than the cold water temp; don't allow colder + WaterEquipment(WaterEquipNum).HotMassFlowRate = 0.0; + } - WaterEquipment(WaterEquipNum).ColdMassFlowRate = - WaterEquipment(WaterEquipNum).TotalMassFlowRate - WaterEquipment(WaterEquipNum).HotMassFlowRate; + WaterEquipment(WaterEquipNum).ColdMassFlowRate = + WaterEquipment(WaterEquipNum).TotalMassFlowRate - WaterEquipment(WaterEquipNum).HotMassFlowRate; - if (WaterEquipment(WaterEquipNum).ColdMassFlowRate < 0.0) WaterEquipment(WaterEquipNum).ColdMassFlowRate = 0.0; + if (WaterEquipment(WaterEquipNum).ColdMassFlowRate < 0.0) WaterEquipment(WaterEquipNum).ColdMassFlowRate = 0.0; - WaterEquipment(WaterEquipNum).MixedTemp = (WaterEquipment(WaterEquipNum).ColdMassFlowRate * WaterEquipment(WaterEquipNum).ColdTemp + - WaterEquipment(WaterEquipNum).HotMassFlowRate * WaterEquipment(WaterEquipNum).HotTemp) / - WaterEquipment(WaterEquipNum).TotalMassFlowRate; - } else { - WaterEquipment(WaterEquipNum).HotMassFlowRate = 0.0; - WaterEquipment(WaterEquipNum).ColdMassFlowRate = 0.0; - WaterEquipment(WaterEquipNum).MixedTemp = WaterEquipment(WaterEquipNum).TargetTemp; + WaterEquipment(WaterEquipNum).MixedTemp = (WaterEquipment(WaterEquipNum).ColdMassFlowRate * WaterEquipment(WaterEquipNum).ColdTemp + + WaterEquipment(WaterEquipNum).HotMassFlowRate * WaterEquipment(WaterEquipNum).HotTemp) / + WaterEquipment(WaterEquipNum).TotalMassFlowRate; + } else { + WaterEquipment(WaterEquipNum).HotMassFlowRate = 0.0; + WaterEquipment(WaterEquipNum).ColdMassFlowRate = 0.0; + WaterEquipment(WaterEquipNum).MixedTemp = WaterEquipment(WaterEquipNum).TargetTemp; + } } - } - void CalcEquipmentDrainTemp(int WaterEquipNum) - { + void CalcEquipmentDrainTemp(int WaterEquipNum) + { - // SUBROUTINE INFORMATION: - // AUTHOR Peter Graham Ellis - // DATE WRITTEN August 2006 - // MODIFIED na - // RE-ENGINEERED na + // SUBROUTINE INFORMATION: + // AUTHOR Peter Graham Ellis + // DATE WRITTEN August 2006 + // MODIFIED na + // RE-ENGINEERED na - // PURPOSE OF THIS SUBROUTINE: - // Calculate drainwater temperature and heat and moisture gains to zone. + // PURPOSE OF THIS SUBROUTINE: + // Calculate drainwater temperature and heat and moisture gains to zone. - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - int ZoneNum; - Real64 ZoneMAT; - Real64 ZoneHumRat; - Real64 ZoneHumRatSat; - Real64 RhoAirDry; - Real64 ZoneMassMax; - Real64 FlowMassMax; - Real64 MoistureMassMax; + // Locals + // SUBROUTINE ARGUMENT DEFINITIONS: - static std::string const RoutineName("CalcEquipmentDrainTemp"); + // SUBROUTINE LOCAL VARIABLE DECLARATIONS: + int ZoneNum; + Real64 ZoneMAT; + Real64 ZoneHumRat; + Real64 ZoneHumRatSat; + Real64 RhoAirDry; + Real64 ZoneMassMax; + Real64 FlowMassMax; + Real64 MoistureMassMax; - // FLOW: + static std::string const RoutineName("CalcEquipmentDrainTemp"); - WaterEquipment(WaterEquipNum).SensibleRate = 0.0; - WaterEquipment(WaterEquipNum).SensibleEnergy = 0.0; - WaterEquipment(WaterEquipNum).LatentRate = 0.0; - WaterEquipment(WaterEquipNum).LatentEnergy = 0.0; + // FLOW: - if ((WaterEquipment(WaterEquipNum).Zone == 0) || (WaterEquipment(WaterEquipNum).TotalMassFlowRate == 0.0)) { - WaterEquipment(WaterEquipNum).DrainTemp = WaterEquipment(WaterEquipNum).MixedTemp; - WaterEquipment(WaterEquipNum).DrainMassFlowRate = WaterEquipment(WaterEquipNum).TotalMassFlowRate; + WaterEquipment(WaterEquipNum).SensibleRate = 0.0; + WaterEquipment(WaterEquipNum).SensibleEnergy = 0.0; + WaterEquipment(WaterEquipNum).LatentRate = 0.0; + WaterEquipment(WaterEquipNum).LatentEnergy = 0.0; - } else { - ZoneNum = WaterEquipment(WaterEquipNum).Zone; - ZoneMAT = DataHeatBalFanSys::MAT(ZoneNum); + if ((WaterEquipment(WaterEquipNum).Zone == 0) || (WaterEquipment(WaterEquipNum).TotalMassFlowRate == 0.0)) { + WaterEquipment(WaterEquipNum).DrainTemp = WaterEquipment(WaterEquipNum).MixedTemp; + WaterEquipment(WaterEquipNum).DrainMassFlowRate = WaterEquipment(WaterEquipNum).TotalMassFlowRate; - if (WaterEquipment(WaterEquipNum).SensibleFracSchedule == 0) { - WaterEquipment(WaterEquipNum).SensibleRate = 0.0; - WaterEquipment(WaterEquipNum).SensibleEnergy = 0.0; } else { - WaterEquipment(WaterEquipNum).SensibleRate = - ScheduleManager::GetCurrentScheduleValue(WaterEquipment(WaterEquipNum).SensibleFracSchedule) * - WaterEquipment(WaterEquipNum).TotalMassFlowRate * Psychrometrics::CPHW(DataGlobals::InitConvTemp) * - (WaterEquipment(WaterEquipNum).MixedTemp - ZoneMAT); - WaterEquipment(WaterEquipNum).SensibleEnergy = - WaterEquipment(WaterEquipNum).SensibleRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - } + ZoneNum = WaterEquipment(WaterEquipNum).Zone; + ZoneMAT = DataHeatBalFanSys::MAT(ZoneNum); - if (WaterEquipment(WaterEquipNum).LatentFracSchedule == 0) { - WaterEquipment(WaterEquipNum).LatentRate = 0.0; - WaterEquipment(WaterEquipNum).LatentEnergy = 0.0; - } else { - ZoneHumRat = DataHeatBalFanSys::ZoneAirHumRat(ZoneNum); - ZoneHumRatSat = - Psychrometrics::PsyWFnTdbRhPb(ZoneMAT, 1.0, DataEnvironment::OutBaroPress, RoutineName); // Humidratio at 100% relative humidity - RhoAirDry = Psychrometrics::PsyRhoAirFnPbTdbW(DataEnvironment::OutBaroPress, ZoneMAT, 0.0); - - ZoneMassMax = - (ZoneHumRatSat - ZoneHumRat) * RhoAirDry * DataHeatBalance::Zone(ZoneNum).Volume; // Max water that can be evaporated to zone - FlowMassMax = - WaterEquipment(WaterEquipNum).TotalMassFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; // Max water in flow - MoistureMassMax = min(ZoneMassMax, FlowMassMax); - - WaterEquipment(WaterEquipNum).MoistureMass = - ScheduleManager::GetCurrentScheduleValue(WaterEquipment(WaterEquipNum).LatentFracSchedule) * MoistureMassMax; - WaterEquipment(WaterEquipNum).MoistureRate = - WaterEquipment(WaterEquipNum).MoistureMass / (DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour); - - WaterEquipment(WaterEquipNum).LatentRate = - WaterEquipment(WaterEquipNum).MoistureRate * Psychrometrics::PsyHfgAirFnWTdb(ZoneHumRat, ZoneMAT); - WaterEquipment(WaterEquipNum).LatentEnergy = - WaterEquipment(WaterEquipNum).LatentRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - } + if (WaterEquipment(WaterEquipNum).SensibleFracSchedule == 0) { + WaterEquipment(WaterEquipNum).SensibleRate = 0.0; + WaterEquipment(WaterEquipNum).SensibleEnergy = 0.0; + } else { + WaterEquipment(WaterEquipNum).SensibleRate = + ScheduleManager::GetCurrentScheduleValue(WaterEquipment(WaterEquipNum).SensibleFracSchedule) * + WaterEquipment(WaterEquipNum).TotalMassFlowRate * + Psychrometrics::CPHW(DataGlobals::InitConvTemp) * + (WaterEquipment(WaterEquipNum).MixedTemp - ZoneMAT); + WaterEquipment(WaterEquipNum).SensibleEnergy = + WaterEquipment(WaterEquipNum).SensibleRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + } - WaterEquipment(WaterEquipNum).DrainMassFlowRate = - WaterEquipment(WaterEquipNum).TotalMassFlowRate - WaterEquipment(WaterEquipNum).MoistureRate; + if (WaterEquipment(WaterEquipNum).LatentFracSchedule == 0) { + WaterEquipment(WaterEquipNum).LatentRate = 0.0; + WaterEquipment(WaterEquipNum).LatentEnergy = 0.0; + } else { + ZoneHumRat = DataHeatBalFanSys::ZoneAirHumRat(ZoneNum); + ZoneHumRatSat = + Psychrometrics::PsyWFnTdbRhPb(ZoneMAT, 1.0, DataEnvironment::OutBaroPress, RoutineName); // Humidratio at 100% relative humidity + RhoAirDry = Psychrometrics::PsyRhoAirFnPbTdbW(DataEnvironment::OutBaroPress, ZoneMAT, 0.0); + + ZoneMassMax = + (ZoneHumRatSat - ZoneHumRat) * RhoAirDry * DataHeatBalance::Zone(ZoneNum).Volume; // Max water that can be evaporated to zone + FlowMassMax = + WaterEquipment(WaterEquipNum).TotalMassFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; // Max water in flow + MoistureMassMax = min(ZoneMassMax, FlowMassMax); + + WaterEquipment(WaterEquipNum).MoistureMass = + ScheduleManager::GetCurrentScheduleValue(WaterEquipment(WaterEquipNum).LatentFracSchedule) * MoistureMassMax; + WaterEquipment(WaterEquipNum).MoistureRate = + WaterEquipment(WaterEquipNum).MoistureMass / (DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour); + + WaterEquipment(WaterEquipNum).LatentRate = + WaterEquipment(WaterEquipNum).MoistureRate * Psychrometrics::PsyHfgAirFnWTdb(ZoneHumRat, ZoneMAT); + WaterEquipment(WaterEquipNum).LatentEnergy = + WaterEquipment(WaterEquipNum).LatentRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + } - if (WaterEquipment(WaterEquipNum).DrainMassFlowRate == 0.0) { - WaterEquipment(WaterEquipNum).DrainTemp = WaterEquipment(WaterEquipNum).MixedTemp; - } else { - WaterEquipment(WaterEquipNum).DrainTemp = - (WaterEquipment(WaterEquipNum).TotalMassFlowRate * Psychrometrics::CPHW(DataGlobals::InitConvTemp) * - WaterEquipment(WaterEquipNum).MixedTemp - - WaterEquipment(WaterEquipNum).SensibleRate - WaterEquipment(WaterEquipNum).LatentRate) / - (WaterEquipment(WaterEquipNum).DrainMassFlowRate * Psychrometrics::CPHW(DataGlobals::InitConvTemp)); + WaterEquipment(WaterEquipNum).DrainMassFlowRate = + WaterEquipment(WaterEquipNum).TotalMassFlowRate - WaterEquipment(WaterEquipNum).MoistureRate; + + if (WaterEquipment(WaterEquipNum).DrainMassFlowRate == 0.0) { + WaterEquipment(WaterEquipNum).DrainTemp = WaterEquipment(WaterEquipNum).MixedTemp; + } else { + WaterEquipment(WaterEquipNum).DrainTemp = + (WaterEquipment(WaterEquipNum).TotalMassFlowRate * Psychrometrics::CPHW(DataGlobals::InitConvTemp) * + WaterEquipment(WaterEquipNum).MixedTemp - + WaterEquipment(WaterEquipNum).SensibleRate - WaterEquipment(WaterEquipNum).LatentRate) / + (WaterEquipment(WaterEquipNum).DrainMassFlowRate * Psychrometrics::CPHW(DataGlobals::InitConvTemp)); + } } } - } - - void WaterConnectionsType::InitConnections( ) - { - // SUBROUTINE INFORMATION: - // AUTHOR Peter Graham Ellis - // DATE WRITTEN August 2006 - // MODIFIED Brent Griffith 2010, demand side update - // RE-ENGINEERED na + void InitConnections(int WaterConnNum) + { + + // SUBROUTINE INFORMATION: + // AUTHOR Peter Graham Ellis + // DATE WRITTEN August 2006 + // MODIFIED Brent Griffith 2010, demand side update + // RE-ENGINEERED na + + + // SUBROUTINE LOCAL VARIABLE DECLARATIONS: + int InletNode; + int OutletNode; + bool MyOneTimeFlag(true); // one time flag !DSU + Array1D_bool SetLoopIndexFlag; // get loop number flag !DSU + bool errFlag; + + if (MyOneTimeFlag) { // DSU + SetLoopIndexFlag.dimension(modNumWaterConnections, true); // DSU + MyOneTimeFlag = false; // DSU + } // DSU + + if (SetLoopIndexFlag(WaterConnNum)) { // DSU + if (allocated(DataPlant::PlantLoop) && !WaterConnections(WaterConnNum).StandAlone) { // DSU + errFlag = false; + PlantUtilities::ScanPlantLoopsForObject(WaterConnections(WaterConnNum).Name, + DataPlant::TypeOf_WaterUseConnection, + WaterConnections(WaterConnNum).PlantLoopNum, + WaterConnections(WaterConnNum).PlantLoopSide, + WaterConnections(WaterConnNum).PlantLoopBranchNum, + WaterConnections(WaterConnNum).PlantLoopCompNum, + errFlag, + _, + _, + _, + _, + _); // DSU | DSU | DSU | DSU | DSU | DSU | DSU + if (errFlag) { // DSU + ShowFatalError("InitConnections: Program terminated due to previous condition(s)."); // DSU + } // DSU + SetLoopIndexFlag(WaterConnNum) = false; // DSU + } // DSU + if (WaterConnections(WaterConnNum).StandAlone) SetLoopIndexFlag(WaterConnNum) = false; + } - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - bool MyOneTimeFlag(true); // one time flag !DSU - //Array1D_bool SetLoopIndexFlag; // get loop number flag !DSU - bool errFlag; - - if (MyOneTimeFlag) { // DSU - //SetLoopIndexFlag.dimension(modNumWaterConnections, true); // DSU - MyOneTimeFlag = false; // DSU - } // DSU - - //this = WaterConnections(WaterConnNum) - - if (this->SetLoopIndexFlag) { // DSU - if (allocated(DataPlant::PlantLoop) && !this->StandAlone) { // DSU - errFlag = false; - PlantUtilities::ScanPlantLoopsForObject(this->Name, - DataPlant::TypeOf_WaterUseConnection, - this->PlantLoopNum, - this->PlantLoopSide, - this->PlantLoopBranchNum, - this->PlantLoopCompNum, - errFlag, - _, - _, - _, - _, - _); // DSU | DSU | DSU | DSU | DSU | DSU | DSU - if (errFlag) { // DSU - ShowFatalError("InitConnections: Program terminated due to previous condition(s)."); // DSU - } // DSU - this->SetLoopIndexFlag = false; // DSU - } // DSU - if (this->StandAlone) this->SetLoopIndexFlag = false; - } + // Set the cold water temperature + if (WaterConnections(WaterConnNum).SupplyTankNum > 0) { + WaterConnections(WaterConnNum).ColdSupplyTemp = DataWater::WaterStorage(WaterConnections(WaterConnNum).SupplyTankNum).Twater; - // Set the cold water temperature - if (this->SupplyTankNum > 0) { - this->ColdSupplyTemp = DataWater::WaterStorage(this->SupplyTankNum).Twater; + } else if (WaterConnections(WaterConnNum).ColdTempSchedule > 0) { + WaterConnections(WaterConnNum).ColdSupplyTemp = ScheduleManager::GetCurrentScheduleValue(WaterConnections(WaterConnNum).ColdTempSchedule); - } else if (this->ColdTempSchedule > 0) { - this->ColdSupplyTemp = ScheduleManager::GetCurrentScheduleValue(this->ColdTempSchedule); + } else { + WaterConnections(WaterConnNum).ColdSupplyTemp = DataEnvironment::WaterMainsTemp; + } - } else { - this->ColdSupplyTemp = DataEnvironment::WaterMainsTemp; - } + // Initially set ColdTemp to the ColdSupplyTemp; with heat recovery, ColdTemp will change during iteration + WaterConnections(WaterConnNum).ColdTemp = WaterConnections(WaterConnNum).ColdSupplyTemp; - // Initially set ColdTemp to the ColdSupplyTemp; with heat recovery, ColdTemp will change during iteration - this->ColdTemp = this->ColdSupplyTemp; + // Set the hot water temperature + if (WaterConnections(WaterConnNum).StandAlone) { + if (WaterConnections(WaterConnNum).HotTempSchedule > 0) { + WaterConnections(WaterConnNum).HotTemp = ScheduleManager::GetCurrentScheduleValue(WaterConnections(WaterConnNum).HotTempSchedule); + } else { + // If no HotTempSchedule, use all cold water + WaterConnections(WaterConnNum).HotTemp = WaterConnections(WaterConnNum).ColdTemp; + } - // Set the hot water temperature - if (this->StandAlone) { - if (this->HotTempSchedule > 0) { - this->HotTemp = ScheduleManager::GetCurrentScheduleValue(this->HotTempSchedule); } else { - // If no HotTempSchedule, use all cold water - this->HotTemp = this->ColdTemp; - } + InletNode = WaterConnections(WaterConnNum).InletNode; + OutletNode = WaterConnections(WaterConnNum).OutletNode; + + if (DataGlobals::BeginEnvrnFlag && WaterConnections(WaterConnNum).Init) { + // Clear node initial conditions + if (InletNode > 0 && OutletNode > 0) { + PlantUtilities::InitComponentNodes(0.0, + WaterConnections(WaterConnNum).PeakMassFlowRate, + InletNode, + OutletNode, + WaterConnections(WaterConnNum).PlantLoopNum, + WaterConnections(WaterConnNum).PlantLoopSide, + WaterConnections(WaterConnNum).PlantLoopBranchNum, + WaterConnections(WaterConnNum).PlantLoopCompNum); + + WaterConnections(WaterConnNum).ReturnTemp = DataLoopNode::Node(InletNode).Temp; + } - } else { - - if (DataGlobals::BeginEnvrnFlag && this->Init) { - // Clear node initial conditions - if (this->InletNode > 0 && this->OutletNode > 0) { - PlantUtilities::InitComponentNodes(0.0, - this->PeakMassFlowRate, - this->InletNode, - this->OutletNode, - this->PlantLoopNum, - this->PlantLoopSide, - this->PlantLoopBranchNum, - this->PlantLoopCompNum); - - this->ReturnTemp = DataLoopNode::Node(this->InletNode).Temp; + WaterConnections(WaterConnNum).Init = false; } - this->Init = false; - } + if (!DataGlobals::BeginEnvrnFlag) WaterConnections(WaterConnNum).Init = true; - if (!DataGlobals::BeginEnvrnFlag) this->Init = true; - - if (this->InletNode > 0) { - if (!DataGlobals::DoingSizing) { - this->HotTemp = DataLoopNode::Node(this->InletNode).Temp; - } else { - // plant loop will not be running so need a value here. - // should change to use tank setpoint but water use connections don't have knowledge of the tank they are fed by - this->HotTemp = 60.0; + if (InletNode > 0) { + if (!DataGlobals::DoingSizing) { + WaterConnections(WaterConnNum).HotTemp = DataLoopNode::Node(InletNode).Temp; + } else { + // plant loop will not be running so need a value here. + // should change to use tank setpoint but water use connections don't have knowledge of the tank they are fed by + WaterConnections(WaterConnNum).HotTemp = 60.0; + } } } } - } - void WaterConnectionsType::CalcConnectionsFlowRates( bool FirstHVACIteration) - { + void CalcConnectionsFlowRates(int WaterConnNum, bool FirstHVACIteration) + { - // SUBROUTINE INFORMATION: - // AUTHOR Peter Graham Ellis - // DATE WRITTEN August 2006 - // MODIFIED na - // RE-ENGINEERED na + // SUBROUTINE INFORMATION: + // AUTHOR Peter Graham Ellis + // DATE WRITTEN August 2006 + // MODIFIED na + // RE-ENGINEERED na - // PURPOSE OF THIS SUBROUTINE: - // Calculate summed values for WATER USE CONNECTIONS (to prepare to request flow from plant, and for reporting). - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - int WaterEquipNum; - int Loop; - int LoopNum; - int LoopSideNum; - - // FLOW: - this->ColdMassFlowRate = 0.0; - this->HotMassFlowRate = 0.0; - - for (Loop = 1; Loop <= this->NumWaterEquipment; ++Loop) { - WaterEquipNum = this->WaterEquipment_intArr(Loop); - - CalcEquipmentFlowRates(WaterEquipNum); - - this->ColdMassFlowRate += WaterEquipment(WaterEquipNum).ColdMassFlowRate; - this->HotMassFlowRate += WaterEquipment(WaterEquipNum).HotMassFlowRate; - } // Loop - - this->TotalMassFlowRate = - this->ColdMassFlowRate + this->HotMassFlowRate; - - if (!this->StandAlone) { // Interact with the plant loop - LoopNum = this->PlantLoopNum; - LoopSideNum = this->PlantLoopSide; - if (this->InletNode > 0) { - if (FirstHVACIteration) { - // Request the mass flow rate from the demand side manager - - PlantUtilities::SetComponentFlowRate(this->HotMassFlowRate, - this->InletNode, - this->OutletNode, - LoopNum, - LoopSideNum, - this->PlantLoopBranchNum, - this->PlantLoopCompNum); + // PURPOSE OF THIS SUBROUTINE: + // Calculate summed values for WATER USE CONNECTIONS (to prepare to request flow from plant, and for reporting). - } else { - PlantUtilities::SetComponentFlowRate(this->HotMassFlowRate, - this->InletNode, - this->OutletNode, - LoopNum, - LoopSideNum, - this->PlantLoopBranchNum, - this->PlantLoopCompNum); - // DSU3 Node(InletNode)%MassFlowRate = MIN(WaterConnections(WaterConnNum)%HotMassFlowRate, Node(InletNode)%MassFlowRateMaxAvail) - // DSU3 Node(InletNode)%MassFlowRate = MAX(WaterConnections(WaterConnNum)%HotMassFlowRate, Node(InletNode)%MassFlowRateMinAvail) - // readjust if more than actual available mass flow rate determined by the demand side manager - if ((this->HotMassFlowRate != this->HotMassFlowRate) && - (this->HotMassFlowRate > 0.0)) { // plant didn't give what was asked for - - // DSU3 Node(InletNode)%MassFlowRate = Node(InletNode)%MassFlowRateMaxAvail - - this->AvailableFraction = - this->HotMassFlowRate / this->HotMassFlowRate; - - // DSU3 WaterConnections(WaterConnNum)%HotMassFlowRate = Node(InletNode)%MassFlowRateMaxAvail - this->ColdMassFlowRate = - this->TotalMassFlowRate - - this->HotMassFlowRate; // Preserve the total mass flow rate - - // Proportionally reduce hot water and increase cold water for all WATER USE EQUIPMENT - for (Loop = 1; Loop <= this->NumWaterEquipment; ++Loop) { - WaterEquipNum = this->WaterEquipment_intArr(Loop); - - // Recalculate flow rates for water equipment within connection - WaterEquipment(WaterEquipNum).HotMassFlowRate *= this->AvailableFraction; - WaterEquipment(WaterEquipNum).ColdMassFlowRate = - WaterEquipment(WaterEquipNum).TotalMassFlowRate - WaterEquipment(WaterEquipNum).HotMassFlowRate; - - // Recalculate mixed water temperature - if (WaterEquipment(WaterEquipNum).TotalMassFlowRate > 0.0) { - WaterEquipment(WaterEquipNum).MixedTemp = - (WaterEquipment(WaterEquipNum).ColdMassFlowRate * WaterEquipment(WaterEquipNum).ColdTemp + - WaterEquipment(WaterEquipNum).HotMassFlowRate * WaterEquipment(WaterEquipNum).HotTemp) / - WaterEquipment(WaterEquipNum).TotalMassFlowRate; - } else { - WaterEquipment(WaterEquipNum).MixedTemp = WaterEquipment(WaterEquipNum).TargetTemp; - } - } // Loop + // SUBROUTINE LOCAL VARIABLE DECLARATIONS: + int WaterEquipNum; + int Loop; + int InletNode; + int OutletNode; + int LoopNum; + int LoopSideNum; + Real64 AvailableFraction; + Real64 DesiredHotWaterMassFlow; // store original request + + // FLOW: + WaterConnections(WaterConnNum).ColdMassFlowRate = 0.0; + WaterConnections(WaterConnNum).HotMassFlowRate = 0.0; + + for (Loop = 1; Loop <= WaterConnections(WaterConnNum).NumWaterEquipment; ++Loop) { + WaterEquipNum = WaterConnections(WaterConnNum).WaterEquipment(Loop); + + CalcEquipmentFlowRates(WaterEquipNum); + + WaterConnections(WaterConnNum).ColdMassFlowRate += WaterEquipment(WaterEquipNum).ColdMassFlowRate; + WaterConnections(WaterConnNum).HotMassFlowRate += WaterEquipment(WaterEquipNum).HotMassFlowRate; + } // Loop + + WaterConnections(WaterConnNum).TotalMassFlowRate = + WaterConnections(WaterConnNum).ColdMassFlowRate + WaterConnections(WaterConnNum).HotMassFlowRate; + + if (!WaterConnections(WaterConnNum).StandAlone) { // Interact with the plant loop + InletNode = WaterConnections(WaterConnNum).InletNode; + OutletNode = WaterConnections(WaterConnNum).OutletNode; + LoopNum = WaterConnections(WaterConnNum).PlantLoopNum; + LoopSideNum = WaterConnections(WaterConnNum).PlantLoopSide; + if (InletNode > 0) { + if (FirstHVACIteration) { + // Request the mass flow rate from the demand side manager + // Node(InletNode)%MassFlowRate = WaterConnections(WaterConnNum)%HotMassFlowRate + // Node(InletNode)%MassFlowRateMaxAvail = WaterConnections(WaterConnNum)%PeakMassFlowRate + // Node(InletNode)%MassFlowRateMinAvail = 0.0D0 + PlantUtilities::SetComponentFlowRate(WaterConnections(WaterConnNum).HotMassFlowRate, + InletNode, + OutletNode, + LoopNum, + LoopSideNum, + WaterConnections(WaterConnNum).PlantLoopBranchNum, + WaterConnections(WaterConnNum).PlantLoopCompNum); + + } else { + DesiredHotWaterMassFlow = WaterConnections(WaterConnNum).HotMassFlowRate; + PlantUtilities::SetComponentFlowRate(DesiredHotWaterMassFlow, + InletNode, + OutletNode, + LoopNum, + LoopSideNum, + WaterConnections(WaterConnNum).PlantLoopBranchNum, + WaterConnections(WaterConnNum).PlantLoopCompNum); + // DSU3 Node(InletNode)%MassFlowRate = MIN(WaterConnections(WaterConnNum)%HotMassFlowRate, Node(InletNode)%MassFlowRateMaxAvail) + // DSU3 Node(InletNode)%MassFlowRate = MAX(WaterConnections(WaterConnNum)%HotMassFlowRate, Node(InletNode)%MassFlowRateMinAvail) + // readjust if more than actual available mass flow rate determined by the demand side manager + if ((WaterConnections(WaterConnNum).HotMassFlowRate != DesiredHotWaterMassFlow) && + (WaterConnections(WaterConnNum).HotMassFlowRate > 0.0)) { // plant didn't give what was asked for + + // DSU3 Node(InletNode)%MassFlowRate = Node(InletNode)%MassFlowRateMaxAvail + + AvailableFraction = DesiredHotWaterMassFlow / WaterConnections(WaterConnNum).HotMassFlowRate; + + // DSU3 WaterConnections(WaterConnNum)%HotMassFlowRate = Node(InletNode)%MassFlowRateMaxAvail + WaterConnections(WaterConnNum).ColdMassFlowRate = + WaterConnections(WaterConnNum).TotalMassFlowRate - + WaterConnections(WaterConnNum).HotMassFlowRate; // Preserve the total mass flow rate + + // Proportionally reduce hot water and increase cold water for all WATER USE EQUIPMENT + for (Loop = 1; Loop <= WaterConnections(WaterConnNum).NumWaterEquipment; ++Loop) { + WaterEquipNum = WaterConnections(WaterConnNum).WaterEquipment(Loop); + + // Recalculate flow rates for water equipment within connection + WaterEquipment(WaterEquipNum).HotMassFlowRate *= AvailableFraction; + WaterEquipment(WaterEquipNum).ColdMassFlowRate = + WaterEquipment(WaterEquipNum).TotalMassFlowRate - WaterEquipment(WaterEquipNum).HotMassFlowRate; + + // Recalculate mixed water temperature + if (WaterEquipment(WaterEquipNum).TotalMassFlowRate > 0.0) { + WaterEquipment(WaterEquipNum).MixedTemp = + (WaterEquipment(WaterEquipNum).ColdMassFlowRate * WaterEquipment(WaterEquipNum).ColdTemp + + WaterEquipment(WaterEquipNum).HotMassFlowRate * WaterEquipment(WaterEquipNum).HotTemp) / + WaterEquipment(WaterEquipNum).TotalMassFlowRate; + } else { + WaterEquipment(WaterEquipNum).MixedTemp = WaterEquipment(WaterEquipNum).TargetTemp; + } + } // Loop + } } } } - } - if (this->SupplyTankNum > 0) { - // Set the demand request for supply water from water storage tank - this->ColdVolFlowRate = - this->ColdMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); - DataWater::WaterStorage(this->SupplyTankNum).VdotRequestDemand(this->TankDemandID) = - this->ColdVolFlowRate; - - // Check if cold flow rate should be starved by restricted flow from tank - // Currently, the tank flow is not really starved--water continues to flow at the tank water temperature - // But the user can see the error by comparing report variables for TankVolFlowRate < ColdVolFlowRate - this->TankVolFlowRate = - DataWater::WaterStorage(this->SupplyTankNum).VdotAvailDemand(this->TankDemandID); - this->TankMassFlowRate = - this->TankVolFlowRate * Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); + if (WaterConnections(WaterConnNum).SupplyTankNum > 0) { + // Set the demand request for supply water from water storage tank + WaterConnections(WaterConnNum).ColdVolFlowRate = + WaterConnections(WaterConnNum).ColdMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); + DataWater::WaterStorage(WaterConnections(WaterConnNum).SupplyTankNum).VdotRequestDemand(WaterConnections(WaterConnNum).TankDemandID) = + WaterConnections(WaterConnNum).ColdVolFlowRate; + + // Check if cold flow rate should be starved by restricted flow from tank + // Currently, the tank flow is not really starved--water continues to flow at the tank water temperature + // But the user can see the error by comparing report variables for TankVolFlowRate < ColdVolFlowRate + WaterConnections(WaterConnNum).TankVolFlowRate = DataWater::WaterStorage(WaterConnections(WaterConnNum).SupplyTankNum) + .VdotAvailDemand(WaterConnections(WaterConnNum).TankDemandID); + WaterConnections(WaterConnNum).TankMassFlowRate = + WaterConnections(WaterConnNum).TankVolFlowRate * Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); + } } - } - void WaterConnectionsType::CalcConnectionsDrainTemp( ) - { + void CalcConnectionsDrainTemp(int WaterConnNum) + { - // SUBROUTINE INFORMATION: - // AUTHOR Peter Graham Ellis - // DATE WRITTEN August 2006 - // MODIFIED na - // RE-ENGINEERED na + // SUBROUTINE INFORMATION: + // AUTHOR Peter Graham Ellis + // DATE WRITTEN August 2006 + // MODIFIED na + // RE-ENGINEERED na + + // PURPOSE OF THIS SUBROUTINE: + // Calculate - // PURPOSE OF THIS SUBROUTINE: - // Calculate - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - int WaterEquipNum; - int Loop; - Real64 MassFlowTempSum; + // SUBROUTINE LOCAL VARIABLE DECLARATIONS: + int WaterEquipNum; + int Loop; + Real64 MassFlowTempSum; - // FLOW: - this->DrainMassFlowRate = 0.0; - MassFlowTempSum = 0.0; + // FLOW: + WaterConnections(WaterConnNum).DrainMassFlowRate = 0.0; + MassFlowTempSum = 0.0; - for (Loop = 1; Loop <= this->NumWaterEquipment; ++Loop) { - WaterEquipNum = this->WaterEquipment_intArr(Loop); + for (Loop = 1; Loop <= WaterConnections(WaterConnNum).NumWaterEquipment; ++Loop) { + WaterEquipNum = WaterConnections(WaterConnNum).WaterEquipment(Loop); + + CalcEquipmentDrainTemp(WaterEquipNum); - CalcEquipmentDrainTemp(WaterEquipNum); + WaterConnections(WaterConnNum).DrainMassFlowRate += WaterEquipment(WaterEquipNum).DrainMassFlowRate; + MassFlowTempSum += WaterEquipment(WaterEquipNum).DrainMassFlowRate * WaterEquipment(WaterEquipNum).DrainTemp; + } // Loop - this->DrainMassFlowRate += WaterEquipment(WaterEquipNum).DrainMassFlowRate; - MassFlowTempSum += WaterEquipment(WaterEquipNum).DrainMassFlowRate * WaterEquipment(WaterEquipNum).DrainTemp; - } // Loop + if (WaterConnections(WaterConnNum).DrainMassFlowRate > 0.0) { + WaterConnections(WaterConnNum).DrainTemp = MassFlowTempSum / WaterConnections(WaterConnNum).DrainMassFlowRate; + } else { + WaterConnections(WaterConnNum).DrainTemp = WaterConnections(WaterConnNum).HotTemp; + } - if (this->DrainMassFlowRate > 0.0) { - this->DrainTemp = MassFlowTempSum / this->DrainMassFlowRate; - } else { - this->DrainTemp = this->HotTemp; + WaterConnections(WaterConnNum).DrainVolFlowRate = + WaterConnections(WaterConnNum).DrainMassFlowRate * Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); } - this->DrainVolFlowRate = - this->DrainMassFlowRate * Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); - } + void CalcConnectionsHeatRecovery(int WaterConnNum) + { + + // SUBROUTINE INFORMATION: + // AUTHOR Peter Graham Ellis + // DATE WRITTEN August 2006 + // MODIFIED na + // RE-ENGINEERED na + + // PURPOSE OF THIS SUBROUTINE: + // Calculate drainwater heat recovery + + // SUBROUTINE LOCAL VARIABLE DECLARATIONS: + Real64 CapacityRatio; + Real64 NTU; + Real64 ExpVal; + Real64 HXCapacityRate; + Real64 DrainCapacityRate; + Real64 MinCapacityRate; + + // FLOW: + if (!WaterConnections(WaterConnNum).HeatRecovery) { + WaterConnections(WaterConnNum).RecoveryTemp = WaterConnections(WaterConnNum).ColdSupplyTemp; + WaterConnections(WaterConnNum).ReturnTemp = WaterConnections(WaterConnNum).ColdSupplyTemp; + WaterConnections(WaterConnNum).WasteTemp = WaterConnections(WaterConnNum).DrainTemp; + + } else if (WaterConnections(WaterConnNum).TotalMassFlowRate == 0.0) { + WaterConnections(WaterConnNum).Effectiveness = 0.0; + WaterConnections(WaterConnNum).RecoveryRate = 0.0; + WaterConnections(WaterConnNum).RecoveryTemp = WaterConnections(WaterConnNum).ColdSupplyTemp; + WaterConnections(WaterConnNum).ReturnTemp = WaterConnections(WaterConnNum).ColdSupplyTemp; + WaterConnections(WaterConnNum).WasteTemp = WaterConnections(WaterConnNum).DrainTemp; + + } else { // WaterConnections(WaterConnNum)%TotalMassFlowRate > 0.0 + + { + auto const SELECT_CASE_var(WaterConnections(WaterConnNum).HeatRecoveryConfig); + if (SELECT_CASE_var == HeatRecoveryConfigPlant) { + WaterConnections(WaterConnNum).RecoveryMassFlowRate = WaterConnections(WaterConnNum).HotMassFlowRate; + } else if (SELECT_CASE_var == HeatRecoveryConfigEquipment) { + WaterConnections(WaterConnNum).RecoveryMassFlowRate = WaterConnections(WaterConnNum).ColdMassFlowRate; + } else if (SELECT_CASE_var == HeatRecoveryConfigPlantAndEquip) { + WaterConnections(WaterConnNum).RecoveryMassFlowRate = WaterConnections(WaterConnNum).TotalMassFlowRate; + } + } - void WaterConnectionsType::CalcConnectionsHeatRecovery( ) - { + HXCapacityRate = Psychrometrics::CPHW(DataGlobals::InitConvTemp) * WaterConnections(WaterConnNum).RecoveryMassFlowRate; + DrainCapacityRate = Psychrometrics::CPHW(DataGlobals::InitConvTemp) * WaterConnections(WaterConnNum).DrainMassFlowRate; + MinCapacityRate = min(DrainCapacityRate, HXCapacityRate); - // SUBROUTINE INFORMATION: - // AUTHOR Peter Graham Ellis - // DATE WRITTEN August 2006 - // MODIFIED na - // RE-ENGINEERED na + { + auto const SELECT_CASE_var(WaterConnections(WaterConnNum).HeatRecoveryHX); + if (SELECT_CASE_var == HeatRecoveryHXIdeal) { + WaterConnections(WaterConnNum).Effectiveness = 1.0; - // PURPOSE OF THIS SUBROUTINE: - // Calculate drainwater heat recovery - // FLOW: - if (!this->HeatRecovery) { - this->RecoveryTemp = this->ColdSupplyTemp; - this->ReturnTemp = this->ColdSupplyTemp; - this->WasteTemp = this->DrainTemp; - - } else if (this->TotalMassFlowRate == 0.0) { - this->Effectiveness = 0.0; - this->RecoveryRate = 0.0; - this->RecoveryTemp = this->ColdSupplyTemp; - this->ReturnTemp = this->ColdSupplyTemp; - this->WasteTemp = this->DrainTemp; - - } else { // WaterConnections(WaterConnNum)%TotalMassFlowRate > 0.0 - - { - auto const SELECT_CASE_var(this->HeatRecoveryConfig); - if (SELECT_CASE_var == HeatRecoveryConfigPlant) { - this->RecoveryMassFlowRate = this->HotMassFlowRate; - } else if (SELECT_CASE_var == HeatRecoveryConfigEquipment) { - this->RecoveryMassFlowRate = this->ColdMassFlowRate; - } else if (SELECT_CASE_var == HeatRecoveryConfigPlantAndEquip) { - this->RecoveryMassFlowRate = this->TotalMassFlowRate; - } - } + } else if (SELECT_CASE_var == HeatRecoveryHXCounterFlow) { // Unmixed + CapacityRatio = MinCapacityRate / max(DrainCapacityRate, HXCapacityRate); + NTU = WaterConnections(WaterConnNum).HXUA / MinCapacityRate; + if (CapacityRatio == 1.0) { + WaterConnections(WaterConnNum).Effectiveness = NTU / (1.0 + NTU); + } else { + ExpVal = std::exp(-NTU * (1.0 - CapacityRatio)); + WaterConnections(WaterConnNum).Effectiveness = (1.0 - ExpVal) / (1.0 - CapacityRatio * ExpVal); + } - this->HXCapacityRate = - Psychrometrics::CPHW(DataGlobals::InitConvTemp) * this->RecoveryMassFlowRate; - this->DrainCapacityRate = - Psychrometrics::CPHW(DataGlobals::InitConvTemp) * this->DrainMassFlowRate; - this->MinCapacityRate = - min(this->DrainCapacityRate, this->HXCapacityRate); - - { - auto const SELECT_CASE_var(this->HeatRecoveryHX); - if (SELECT_CASE_var == HeatRecoveryHXIdeal) { - this->Effectiveness = 1.0; - - } else if (SELECT_CASE_var == HeatRecoveryHXCounterFlow) { // Unmixed - this->CapacityRatio = - this->MinCapacityRate / - max(this->DrainCapacityRate, this->HXCapacityRate); - this->NTU = this->HXUA / this->MinCapacityRate; - if (this->CapacityRatio == 1.0) { - this->Effectiveness = - this->NTU / (1.0 + this->NTU); - } else { - this->ExpVal = - std::exp(-this->NTU * (1.0 - this->CapacityRatio)); - this->Effectiveness = - (1.0 - this->ExpVal) / - (1.0 - this->CapacityRatio * this->ExpVal); + } else if (SELECT_CASE_var == HeatRecoveryHXCrossFlow) { // Unmixed + CapacityRatio = MinCapacityRate / max(DrainCapacityRate, HXCapacityRate); + NTU = WaterConnections(WaterConnNum).HXUA / MinCapacityRate; + WaterConnections(WaterConnNum).Effectiveness = + 1.0 - std::exp((std::pow(NTU, 0.22) / CapacityRatio) * (std::exp(-CapacityRatio * std::pow(NTU, 0.78)) - 1.0)); } - - } else if (SELECT_CASE_var == HeatRecoveryHXCrossFlow) { // Unmixed - this->CapacityRatio = - this->MinCapacityRate / - max(this->DrainCapacityRate, this->HXCapacityRate); - this->NTU = this->HXUA / this->MinCapacityRate; - this->Effectiveness = - 1.0 - std::exp((std::pow(this->NTU, 0.22) / this->CapacityRatio) * - (std::exp(-this->CapacityRatio * std::pow(this->NTU, 0.78)) - - 1.0)); } - } - this->RecoveryRate = this->Effectiveness * this->MinCapacityRate * (this->DrainTemp - this->ColdSupplyTemp); + WaterConnections(WaterConnNum).RecoveryRate = WaterConnections(WaterConnNum).Effectiveness * MinCapacityRate * + (WaterConnections(WaterConnNum).DrainTemp - WaterConnections(WaterConnNum).ColdSupplyTemp); - this->RecoveryTemp = - this->ColdSupplyTemp + - this->RecoveryRate / - (Psychrometrics::CPHW(DataGlobals::InitConvTemp) * this->TotalMassFlowRate); + WaterConnections(WaterConnNum).RecoveryTemp = + WaterConnections(WaterConnNum).ColdSupplyTemp + + WaterConnections(WaterConnNum).RecoveryRate / + (Psychrometrics::CPHW(DataGlobals::InitConvTemp) * WaterConnections(WaterConnNum).TotalMassFlowRate); - this->WasteTemp = - this->DrainTemp - - this->RecoveryRate / - (Psychrometrics::CPHW(DataGlobals::InitConvTemp) * this->TotalMassFlowRate); + WaterConnections(WaterConnNum).WasteTemp = + WaterConnections(WaterConnNum).DrainTemp - + WaterConnections(WaterConnNum).RecoveryRate / + (Psychrometrics::CPHW(DataGlobals::InitConvTemp) * WaterConnections(WaterConnNum).TotalMassFlowRate); - if (this->RecoveryTankNum > 0) { - DataWater::WaterStorage(this->RecoveryTankNum).VdotAvailSupply(this->TankSupplyID) = - this->DrainVolFlowRate; - DataWater::WaterStorage(this->RecoveryTankNum).TwaterSupply(this->TankSupplyID) = - this->WasteTemp; - } + if (WaterConnections(WaterConnNum).RecoveryTankNum > 0) { + DataWater::WaterStorage(WaterConnections(WaterConnNum).RecoveryTankNum).VdotAvailSupply(WaterConnections(WaterConnNum).TankSupplyID) = + WaterConnections(WaterConnNum).DrainVolFlowRate; + DataWater::WaterStorage(WaterConnections(WaterConnNum).RecoveryTankNum).TwaterSupply(WaterConnections(WaterConnNum).TankSupplyID) = + WaterConnections(WaterConnNum).WasteTemp; + } - { - auto const SELECT_CASE_var(this->HeatRecoveryConfig); - if (SELECT_CASE_var == HeatRecoveryConfigPlant) { - this->TempError = 0.0; // No feedback back to the cold supply - // WaterConnections(WaterConnNum)%ColdTemp = WaterConnections(WaterConnNum)%ColdSupplyTemp - this->ReturnTemp = this->RecoveryTemp; + { + auto const SELECT_CASE_var(WaterConnections(WaterConnNum).HeatRecoveryConfig); + if (SELECT_CASE_var == HeatRecoveryConfigPlant) { + WaterConnections(WaterConnNum).TempError = 0.0; // No feedback back to the cold supply + // WaterConnections(WaterConnNum)%ColdTemp = WaterConnections(WaterConnNum)%ColdSupplyTemp + WaterConnections(WaterConnNum).ReturnTemp = WaterConnections(WaterConnNum).RecoveryTemp; - } else if (SELECT_CASE_var == HeatRecoveryConfigEquipment) { - this->TempError = - std::abs(this->ColdTemp - this->RecoveryTemp); + } else if (SELECT_CASE_var == HeatRecoveryConfigEquipment) { + WaterConnections(WaterConnNum).TempError = + std::abs(WaterConnections(WaterConnNum).ColdTemp - WaterConnections(WaterConnNum).RecoveryTemp); - this->ColdTemp = this->RecoveryTemp; - this->ReturnTemp = this->ColdSupplyTemp; + WaterConnections(WaterConnNum).ColdTemp = WaterConnections(WaterConnNum).RecoveryTemp; + WaterConnections(WaterConnNum).ReturnTemp = WaterConnections(WaterConnNum).ColdSupplyTemp; - } else if (SELECT_CASE_var == HeatRecoveryConfigPlantAndEquip) { - this->TempError = - std::abs(this->ColdTemp - this->RecoveryTemp); + } else if (SELECT_CASE_var == HeatRecoveryConfigPlantAndEquip) { + WaterConnections(WaterConnNum).TempError = + std::abs(WaterConnections(WaterConnNum).ColdTemp - WaterConnections(WaterConnNum).RecoveryTemp); - this->ColdTemp = this->RecoveryTemp; - this->ReturnTemp = this->RecoveryTemp; + WaterConnections(WaterConnNum).ColdTemp = WaterConnections(WaterConnNum).RecoveryTemp; + WaterConnections(WaterConnNum).ReturnTemp = WaterConnections(WaterConnNum).RecoveryTemp; + } } } } - } - void WaterConnectionsType::UpdateWaterConnections( ) - { + void UpdateWaterConnections(int WaterConnNum) + { - // SUBROUTINE INFORMATION: - // AUTHOR Peter Graham Ellis - // DATE WRITTEN August 2006 - // MODIFIED na - // RE-ENGINEERED na + // SUBROUTINE INFORMATION: + // AUTHOR Peter Graham Ellis + // DATE WRITTEN August 2006 + // MODIFIED na + // RE-ENGINEERED na + + // PURPOSE OF THIS SUBROUTINE: + // Updates the node variables with local variables. - // PURPOSE OF THIS SUBROUTINE: - // Updates the node variables with local variables. + // SUBROUTINE LOCAL VARIABLE DECLARATIONS: + int InletNode; + int OutletNode; + int LoopNum; - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - int InletNode = this->InletNode; - int OutletNode = this->OutletNode; - int LoopNum = this->PlantLoopNum; + // FLOW: + InletNode = WaterConnections(WaterConnNum).InletNode; + OutletNode = WaterConnections(WaterConnNum).OutletNode; + LoopNum = WaterConnections(WaterConnNum).PlantLoopNum; - // FLOW: - - if (InletNode > 0 && OutletNode > 0) { - // Pass all variables from inlet to outlet node - PlantUtilities::SafeCopyPlantNode(InletNode, OutletNode, LoopNum); - // DSU3 Node(OutletNode) = Node(InletNode) + if (InletNode > 0 && OutletNode > 0) { + // Pass all variables from inlet to outlet node + PlantUtilities::SafeCopyPlantNode(InletNode, OutletNode, LoopNum); + // DSU3 Node(OutletNode) = Node(InletNode) - // Set outlet node variables that are possibly changed - DataLoopNode::Node(OutletNode).Temp = this->ReturnTemp; - // should add enthalpy update to return? + // Set outlet node variables that are possibly changed + DataLoopNode::Node(OutletNode).Temp = WaterConnections(WaterConnNum).ReturnTemp; + // should add enthalpy update to return? + } } - } - void ReportStandAloneWaterUse() - { + void ReportStandAloneWaterUse() + { - // SUBROUTINE INFORMATION: - // AUTHOR B. Griffith, Peter Graham Ellis - // DATE WRITTEN Nov. 2011 - // MODIFIED Brent Griffith, March 2010 added argument - // RE-ENGINEERED na + // SUBROUTINE INFORMATION: + // AUTHOR B. Griffith, Peter Graham Ellis + // DATE WRITTEN Nov. 2011 + // MODIFIED Brent Griffith, March 2010 added argument + // RE-ENGINEERED na + + // PURPOSE OF THIS SUBROUTINE: + // Calculates report variables for stand alone water use - // PURPOSE OF THIS SUBROUTINE: - // Calculates report variables for stand alone water use - - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - int WaterEquipNum; - - // FLOW: - for (WaterEquipNum = 1; WaterEquipNum <= modNumWaterEquipment; ++WaterEquipNum) { - WaterEquipment(WaterEquipNum).ColdVolFlowRate = - WaterEquipment(WaterEquipNum).ColdMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); - WaterEquipment(WaterEquipNum).HotVolFlowRate = - WaterEquipment(WaterEquipNum).HotMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); - WaterEquipment(WaterEquipNum).TotalVolFlowRate = - WaterEquipment(WaterEquipNum).ColdVolFlowRate + WaterEquipment(WaterEquipNum).HotVolFlowRate; - - WaterEquipment(WaterEquipNum).ColdVolume = - WaterEquipment(WaterEquipNum).ColdVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - WaterEquipment(WaterEquipNum).HotVolume = - WaterEquipment(WaterEquipNum).HotVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - WaterEquipment(WaterEquipNum).TotalVolume = - WaterEquipment(WaterEquipNum).TotalVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - - if (WaterEquipment(WaterEquipNum).Connections == 0) { - WaterEquipment(WaterEquipNum).Power = WaterEquipment(WaterEquipNum).HotMassFlowRate * - Psychrometrics::CPHW(DataGlobals::InitConvTemp) * - (WaterEquipment(WaterEquipNum).HotTemp - WaterEquipment(WaterEquipNum).ColdTemp); - } else { - WaterEquipment(WaterEquipNum).Power = - WaterEquipment(WaterEquipNum).HotMassFlowRate * Psychrometrics::CPHW(DataGlobals::InitConvTemp) * - (WaterEquipment(WaterEquipNum).HotTemp - WaterConnections(WaterEquipment(WaterEquipNum).Connections).ReturnTemp); - } - WaterEquipment(WaterEquipNum).Energy = WaterEquipment(WaterEquipNum).Power * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + // Locals + // SUBROUTINE ARGUMENT DEFINITIONS: + + int WaterEquipNum; + + // FLOW: + for (WaterEquipNum = 1; WaterEquipNum <= modNumWaterEquipment; ++WaterEquipNum) { + WaterEquipment(WaterEquipNum).ColdVolFlowRate = + WaterEquipment(WaterEquipNum).ColdMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); + WaterEquipment(WaterEquipNum).HotVolFlowRate = + WaterEquipment(WaterEquipNum).HotMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); + WaterEquipment(WaterEquipNum).TotalVolFlowRate = + WaterEquipment(WaterEquipNum).ColdVolFlowRate + WaterEquipment(WaterEquipNum).HotVolFlowRate; + + WaterEquipment(WaterEquipNum).ColdVolume = + WaterEquipment(WaterEquipNum).ColdVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + WaterEquipment(WaterEquipNum).HotVolume = + WaterEquipment(WaterEquipNum).HotVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + WaterEquipment(WaterEquipNum).TotalVolume = + WaterEquipment(WaterEquipNum).TotalVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + + if (WaterEquipment(WaterEquipNum).Connections == 0) { + WaterEquipment(WaterEquipNum).Power = WaterEquipment(WaterEquipNum).HotMassFlowRate * + Psychrometrics::CPHW(DataGlobals::InitConvTemp) * + (WaterEquipment(WaterEquipNum).HotTemp - WaterEquipment(WaterEquipNum).ColdTemp); + } else { + WaterEquipment(WaterEquipNum).Power = + WaterEquipment(WaterEquipNum).HotMassFlowRate * Psychrometrics::CPHW(DataGlobals::InitConvTemp) * + (WaterEquipment(WaterEquipNum).HotTemp - WaterConnections(WaterEquipment(WaterEquipNum).Connections).ReturnTemp); + } + + WaterEquipment(WaterEquipNum).Energy = WaterEquipment(WaterEquipNum).Power * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + } } - } - void WaterConnectionsType::ReportWaterUse( ) - { + void ReportWaterUse(int WaterConnNum) + { - // SUBROUTINE INFORMATION: - // AUTHOR Peter Graham Ellis - // DATE WRITTEN August 2006 - // MODIFIED Brent Griffith, March 2010 added argument - // RE-ENGINEERED na + // SUBROUTINE INFORMATION: + // AUTHOR Peter Graham Ellis + // DATE WRITTEN August 2006 + // MODIFIED Brent Griffith, March 2010 added argument + // RE-ENGINEERED na - // PURPOSE OF THIS SUBROUTINE: - // Calculates report variables. - - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - int Loop; - int WaterEquipNum; - // FLOW: - for (Loop = 1; Loop <= this->NumWaterEquipment; ++Loop) { - WaterEquipNum = this->WaterEquipment_intArr(Loop); - WaterEquipment(WaterEquipNum).ColdVolFlowRate = - WaterEquipment(WaterEquipNum).ColdMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); - WaterEquipment(WaterEquipNum).HotVolFlowRate = - WaterEquipment(WaterEquipNum).HotMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); - WaterEquipment(WaterEquipNum).TotalVolFlowRate = - WaterEquipment(WaterEquipNum).ColdVolFlowRate + WaterEquipment(WaterEquipNum).HotVolFlowRate; - - WaterEquipment(WaterEquipNum).ColdVolume = - WaterEquipment(WaterEquipNum).ColdVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - WaterEquipment(WaterEquipNum).HotVolume = - WaterEquipment(WaterEquipNum).HotVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - WaterEquipment(WaterEquipNum).TotalVolume = - WaterEquipment(WaterEquipNum).TotalVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - - if (WaterEquipment(WaterEquipNum).Connections == 0) { - WaterEquipment(WaterEquipNum).Power = WaterEquipment(WaterEquipNum).HotMassFlowRate * - Psychrometrics::CPHW(DataGlobals::InitConvTemp) * - (WaterEquipment(WaterEquipNum).HotTemp - WaterEquipment(WaterEquipNum).ColdTemp); - } else { - WaterEquipment(WaterEquipNum).Power = - WaterEquipment(WaterEquipNum).HotMassFlowRate * Psychrometrics::CPHW(DataGlobals::InitConvTemp) * - (WaterEquipment(WaterEquipNum).HotTemp - WaterConnections(WaterEquipment(WaterEquipNum).Connections).ReturnTemp); + // PURPOSE OF THIS SUBROUTINE: + // Calculates report variables. + + // Locals + // SUBROUTINE ARGUMENT DEFINITIONS: + + int Loop; + int WaterEquipNum; + + // FLOW: + for (Loop = 1; Loop <= WaterConnections(WaterConnNum).NumWaterEquipment; ++Loop) { + WaterEquipNum = WaterConnections(WaterConnNum).WaterEquipment(Loop); + WaterEquipment(WaterEquipNum).ColdVolFlowRate = + WaterEquipment(WaterEquipNum).ColdMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); + WaterEquipment(WaterEquipNum).HotVolFlowRate = + WaterEquipment(WaterEquipNum).HotMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); + WaterEquipment(WaterEquipNum).TotalVolFlowRate = + WaterEquipment(WaterEquipNum).ColdVolFlowRate + WaterEquipment(WaterEquipNum).HotVolFlowRate; + + WaterEquipment(WaterEquipNum).ColdVolume = + WaterEquipment(WaterEquipNum).ColdVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + WaterEquipment(WaterEquipNum).HotVolume = + WaterEquipment(WaterEquipNum).HotVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + WaterEquipment(WaterEquipNum).TotalVolume = + WaterEquipment(WaterEquipNum).TotalVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + + if (WaterEquipment(WaterEquipNum).Connections == 0) { + WaterEquipment(WaterEquipNum).Power = WaterEquipment(WaterEquipNum).HotMassFlowRate * + Psychrometrics::CPHW(DataGlobals::InitConvTemp) * + (WaterEquipment(WaterEquipNum).HotTemp - WaterEquipment(WaterEquipNum).ColdTemp); + } else { + WaterEquipment(WaterEquipNum).Power = + WaterEquipment(WaterEquipNum).HotMassFlowRate * Psychrometrics::CPHW(DataGlobals::InitConvTemp) * + (WaterEquipment(WaterEquipNum).HotTemp - WaterConnections(WaterEquipment(WaterEquipNum).Connections).ReturnTemp); + } + + WaterEquipment(WaterEquipNum).Energy = WaterEquipment(WaterEquipNum).Power * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; } - WaterEquipment(WaterEquipNum).Energy = WaterEquipment(WaterEquipNum).Power * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + WaterConnections(WaterConnNum).ColdVolFlowRate = + WaterConnections(WaterConnNum).ColdMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); + WaterConnections(WaterConnNum).HotVolFlowRate = + WaterConnections(WaterConnNum).HotMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); + WaterConnections(WaterConnNum).TotalVolFlowRate = + WaterConnections(WaterConnNum).ColdVolFlowRate + WaterConnections(WaterConnNum).HotVolFlowRate; + + WaterConnections(WaterConnNum).ColdVolume = + WaterConnections(WaterConnNum).ColdVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + WaterConnections(WaterConnNum).HotVolume = + WaterConnections(WaterConnNum).HotVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + WaterConnections(WaterConnNum).TotalVolume = + WaterConnections(WaterConnNum).TotalVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + + WaterConnections(WaterConnNum).Power = WaterConnections(WaterConnNum).HotMassFlowRate * Psychrometrics::CPHW(DataGlobals::InitConvTemp) * + (WaterConnections(WaterConnNum).HotTemp - WaterConnections(WaterConnNum).ReturnTemp); + WaterConnections(WaterConnNum).Energy = WaterConnections(WaterConnNum).Power * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + + WaterConnections(WaterConnNum).RecoveryEnergy = + WaterConnections(WaterConnNum).RecoveryRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; } - this->ColdVolFlowRate = - this->ColdMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); - this->HotVolFlowRate = - this->HotMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); - this->TotalVolFlowRate = - this->ColdVolFlowRate + this->HotVolFlowRate; + void CalcWaterUseZoneGains() + { - this->ColdVolume = - this->ColdVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - this->HotVolume = - this->HotVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - this->TotalVolume = - this->TotalVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + // SUBROUTINE INFORMATION: + // AUTHOR Peter Graham Ellis + // DATE WRITTEN August 2006 + // MODIFIED + // RE-ENGINEERED na - this->Power = this->HotMassFlowRate * Psychrometrics::CPHW(DataGlobals::InitConvTemp) * - (this->HotTemp - this->ReturnTemp); - this->Energy = this->Power * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + // PURPOSE OF THIS SUBROUTINE: + // Calculates the zone internal gains due to water use sensible and latent loads. - this->RecoveryEnergy = - this->RecoveryRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - } + // Locals + // SUBROUTINE LOCAL VARIABLE DECLARATIONS: + int WaterEquipNum; + int ZoneNum; + bool MyEnvrnFlag(true); - void CalcWaterUseZoneGains() - { + // FLOW: + if (modNumWaterEquipment == 0) return; - // SUBROUTINE INFORMATION: - // AUTHOR Peter Graham Ellis - // DATE WRITTEN August 2006 - // MODIFIED - // RE-ENGINEERED na + if (DataGlobals::BeginEnvrnFlag && MyEnvrnFlag) { + for (auto &e : WaterEquipment) { + e.SensibleRate = 0.0; + e.SensibleEnergy = 0.0; + e.SensibleRateNoMultiplier = 0.0; + e.LatentRate = 0.0; + e.LatentEnergy = 0.0; + e.LatentRateNoMultiplier = 0.0; + e.MixedTemp = 0.0; + e.TotalMassFlowRate = 0.0; + e.DrainTemp = 0.0; + e.ColdVolFlowRate = 0.0; + e.HotVolFlowRate = 0.0; + e.TotalVolFlowRate = 0.0; + e.ColdMassFlowRate = 0.0; + e.HotMassFlowRate = 0.0; + } + MyEnvrnFlag = false; + } + + if (!DataGlobals::BeginEnvrnFlag) MyEnvrnFlag = true; - // PURPOSE OF THIS SUBROUTINE: - // Calculates the zone internal gains due to water use sensible and latent loads. - - // Locals - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - int WaterEquipNum; - int ZoneNum; - bool MyEnvrnFlag(true); - - // FLOW: - if (modNumWaterEquipment == 0) return; - - if (DataGlobals::BeginEnvrnFlag && MyEnvrnFlag) { - for (auto &e : WaterEquipment) { - e.SensibleRate = 0.0; - e.SensibleEnergy = 0.0; - e.SensibleRateNoMultiplier = 0.0; - e.LatentRate = 0.0; - e.LatentEnergy = 0.0; - e.LatentRateNoMultiplier = 0.0; - e.MixedTemp = 0.0; - e.TotalMassFlowRate = 0.0; - e.DrainTemp = 0.0; - e.ColdVolFlowRate = 0.0; - e.HotVolFlowRate = 0.0; - e.TotalVolFlowRate = 0.0; - e.ColdMassFlowRate = 0.0; - e.HotMassFlowRate = 0.0; + for (WaterEquipNum = 1; WaterEquipNum <= modNumWaterEquipment; ++WaterEquipNum) { + if (WaterEquipment(WaterEquipNum).Zone == 0) continue; + ZoneNum = WaterEquipment(WaterEquipNum).Zone; + WaterEquipment(WaterEquipNum).SensibleRateNoMultiplier = + WaterEquipment(WaterEquipNum).SensibleRate / + (DataHeatBalance::Zone(ZoneNum).Multiplier * DataHeatBalance::Zone(ZoneNum).ListMultiplier); // CR7401, back out multipliers + WaterEquipment(WaterEquipNum).LatentRateNoMultiplier = + WaterEquipment(WaterEquipNum).LatentRate / + (DataHeatBalance::Zone(ZoneNum).Multiplier * DataHeatBalance::Zone(ZoneNum).ListMultiplier); // CR7401, back out multipliers } - MyEnvrnFlag = false; - } - if (!DataGlobals::BeginEnvrnFlag) MyEnvrnFlag = true; - - for (WaterEquipNum = 1; WaterEquipNum <= modNumWaterEquipment; ++WaterEquipNum) { - if (WaterEquipment(WaterEquipNum).Zone == 0) continue; - ZoneNum = WaterEquipment(WaterEquipNum).Zone; - WaterEquipment(WaterEquipNum).SensibleRateNoMultiplier = - WaterEquipment(WaterEquipNum).SensibleRate / - (DataHeatBalance::Zone(ZoneNum).Multiplier * DataHeatBalance::Zone(ZoneNum).ListMultiplier); // CR7401, back out multipliers - WaterEquipment(WaterEquipNum).LatentRateNoMultiplier = - WaterEquipment(WaterEquipNum).LatentRate / - (DataHeatBalance::Zone(ZoneNum).Multiplier * DataHeatBalance::Zone(ZoneNum).ListMultiplier); // CR7401, back out multipliers + } - } -} // namespace WaterUse + } // namespace WaterUse } // namespace EnergyPlus diff --git a/src/EnergyPlus/WaterUse.hh b/src/EnergyPlus/WaterUse.hh index b05667c3c49..db66540ac19 100644 --- a/src/EnergyPlus/WaterUse.hh +++ b/src/EnergyPlus/WaterUse.hh @@ -54,235 +54,217 @@ // EnergyPlus Headers #include #include -#include namespace EnergyPlus { -namespace WaterUse { - - // Using/Aliasing - - // Data - // MODULE PARAMETER DEFINITIONS: - extern int const HeatRecoveryHXIdeal; - extern int const HeatRecoveryHXCounterFlow; - extern int const HeatRecoveryHXCrossFlow; - - extern int const HeatRecoveryConfigPlant; - extern int const HeatRecoveryConfigEquipment; - extern int const HeatRecoveryConfigPlantAndEquip; - - // DERIVED TYPE DEFINITIONS: - - // MODULE VARIABLE TYPE DECLARATIONS: - - // MODULE VARIABLE DECLARATIONS: - extern int NumWaterEquipment; - extern int NumWaterConnections; - // INTEGER :: MaxIterationsErrorCount =0 - extern bool GetWaterUseInputFlag; - - extern Array1D_bool CheckEquipName; - extern Array1D_bool CheckPlantLoop; - - // SUBROUTINE SPECIFICATIONS: - - // Types - - struct WaterEquipmentType - { - // Members - std::string Name; // Name of DHW - std::string EndUseSubcatName; - int Connections; // Index for WATER USE CONNECTIONS object - Real64 PeakVolFlowRate; // Peak volumetric flow rate, also water consumption rate (m3/s) - int FlowRateFracSchedule; // Pointer to schedule object - Real64 ColdVolFlowRate; - Real64 HotVolFlowRate; - Real64 TotalVolFlowRate; // Volumetric flow rate, also water consumption rate (m3/s) - Real64 ColdMassFlowRate; - Real64 HotMassFlowRate; - Real64 TotalMassFlowRate; // Mass flow rate (kg/s) - Real64 DrainMassFlowRate; - int ColdTempSchedule; // Index for schedule object - int HotTempSchedule; // Index for schedule object - int TargetTempSchedule; // Index for schedule object - Real64 ColdTemp; // Cold supply water temperature (C) - Real64 HotTemp; // Hot supply water temperature (C) - Real64 TargetTemp; // Target (mixed) water temperature (C) - Real64 MixedTemp; // Actual outlet (mixed) water temperature (C) - Real64 DrainTemp; - int Zone; // Index for zone object - int SensibleFracSchedule; // Pointer to schedule object - Real64 SensibleRate; - Real64 SensibleEnergy; - Real64 SensibleRateNoMultiplier; - int LatentFracSchedule; // Pointer to schedule object - Real64 LatentRate; - Real64 LatentEnergy; - Real64 LatentRateNoMultiplier; - Real64 MoistureRate; - Real64 MoistureMass; - Real64 ColdVolume; // Water consumption (m3) - Real64 HotVolume; // Water consumption (m3) - Real64 TotalVolume; // Water consumption (m3) - Real64 Power; // Heating rate required to meet the mixed water temperature (W) - Real64 Energy; // Heating energy required to meet the mixed water temperature (J) - - // Default Constructor - WaterEquipmentType() - : Connections(0), PeakVolFlowRate(0.0), FlowRateFracSchedule(0), ColdVolFlowRate(0.0), HotVolFlowRate(0.0), TotalVolFlowRate(0.0), - ColdMassFlowRate(0.0), HotMassFlowRate(0.0), TotalMassFlowRate(0.0), DrainMassFlowRate(0.0), ColdTempSchedule(0), HotTempSchedule(0), - TargetTempSchedule(0), ColdTemp(0.0), HotTemp(0.0), TargetTemp(0.0), MixedTemp(0.0), DrainTemp(0.0), Zone(0), SensibleFracSchedule(0), - SensibleRate(0.0), SensibleEnergy(0.0), SensibleRateNoMultiplier(0.0), LatentFracSchedule(0), LatentRate(0.0), LatentEnergy(0.0), - LatentRateNoMultiplier(0.0), MoistureRate(0.0), MoistureMass(0.0), ColdVolume(0.0), HotVolume(0.0), TotalVolume(0.0), Power(0.0), - Energy(0.0) - { - } - - - void reset() - { - SensibleRate = 0.0; - SensibleEnergy = 0.0; - LatentRate = 0.0; - LatentEnergy = 0.0; - MixedTemp = 0.0; - TotalMassFlowRate = 0.0; - DrainTemp = 0.0; - } - - }; - - struct WaterConnectionsType : PlantComponent - { - // Members - std::string Name; // Name of DHW - bool Init; // Flag for initialization: TRUE means do the init - bool InitSizing; // Flag for initialization of plant sizing - bool StandAlone; // Flag for operation with no plant connections - int InletNode; // Hot water demand node - int OutletNode; // Cold water supply node - int SupplyTankNum; - int RecoveryTankNum; - int TankDemandID; // array to request flow from supply tank - int TankSupplyID; // array to send flow to recovery tank - bool HeatRecovery; - int HeatRecoveryHX; - int HeatRecoveryConfig; - Real64 HXUA; - Real64 Effectiveness; - Real64 RecoveryRate; - Real64 RecoveryEnergy; - Real64 MainsMassFlowRate; // Mass flow rate (kg/s) - Real64 TankMassFlowRate; // Mass flow rate (kg/s) - Real64 ColdMassFlowRate; // Mass flow rate (kg/s) cold = mains + tank - Real64 HotMassFlowRate; // Mass flow rate (kg/s) - Real64 TotalMassFlowRate; // Mass flow rate (kg/s) total = cold + hot - Real64 DrainMassFlowRate; - Real64 RecoveryMassFlowRate; - Real64 PeakVolFlowRate; // Volumetric flow rate, also water consumption rate (m3/s) - Real64 MainsVolFlowRate; // Volumetric flow rate, also water consumption rate (m3/s) - Real64 TankVolFlowRate; // Volumetric flow rate, also water consumption rate (m3/s) - Real64 ColdVolFlowRate; // Volumetric flow rate, also water consumption rate (m3/s) - Real64 HotVolFlowRate; // Volumetric flow rate, also water consumption rate (m3/s) - Real64 TotalVolFlowRate; // Volumetric flow rate, also water consumption rate (m3/s) - Real64 DrainVolFlowRate; - Real64 PeakMassFlowRate; // Peak Mass flow rate for MassFlowRateMax - int ColdTempSchedule; // Index for schedule object - int HotTempSchedule; // Index for schedule object - Real64 MainsTemp; // Cold supply water temperature (C) - Real64 TankTemp; // Cold supply water temperature (C) - Real64 ColdSupplyTemp; // cold from mains, schedule, or tank, depending - Real64 ColdTemp; // Cold supply water temperature (C) actual cold (could be reheated) - Real64 HotTemp; // Hot supply water temperature (C) - Real64 DrainTemp; - Real64 RecoveryTemp; - Real64 ReturnTemp; - Real64 WasteTemp; - Real64 TempError; - Real64 MainsVolume; // Water consumption (m3) - Real64 TankVolume; // Water consumption (m3) - Real64 ColdVolume; // Water consumption (m3) - Real64 HotVolume; // Water consumption (m3) - Real64 TotalVolume; // Water consumption (m3) - Real64 Power; // Heating rate required to raise temperature from cold to hot (W) - Real64 Energy; // Heating energy required to raise temperature from cold to hot (J) - Real64 CapacityRatio; - Real64 MinCapacityRate; - Real64 HXCapacityRate; - Real64 DrainCapacityRate; - Real64 NTU; - Real64 ExpVal; - Real64 AvailableFraction; - int NumWaterEquipment; - int MaxIterationsErrorIndex; // recurring error index - Array1D_int WaterEquipment_intArr; - int PlantLoopNum; - int PlantLoopSide; - int PlantLoopBranchNum; - int PlantLoopCompNum; - bool SetLoopIndexFlag; - - // Default Constructor - WaterConnectionsType() - : Init(true), InitSizing(true), StandAlone(false), InletNode(0), OutletNode(0), SupplyTankNum(0), RecoveryTankNum(0), TankDemandID(0), - TankSupplyID(0), HeatRecovery(false), HeatRecoveryHX(HeatRecoveryHXIdeal), HeatRecoveryConfig(HeatRecoveryConfigPlant), HXUA(0.0), - Effectiveness(0.0), RecoveryRate(0.0), RecoveryEnergy(0.0), MainsMassFlowRate(0.0), TankMassFlowRate(0.0), ColdMassFlowRate(0.0), - HotMassFlowRate(0.0), TotalMassFlowRate(0.0), DrainMassFlowRate(0.0), RecoveryMassFlowRate(0.0), PeakVolFlowRate(0.0), - MainsVolFlowRate(0.0), TankVolFlowRate(0.0), ColdVolFlowRate(0.0), HotVolFlowRate(0.0), TotalVolFlowRate(0.0), DrainVolFlowRate(0.0), - PeakMassFlowRate(0.0), ColdTempSchedule(0), HotTempSchedule(0), MainsTemp(0.0), TankTemp(0.0), ColdSupplyTemp(0.0), ColdTemp(0.0), - HotTemp(0.0), DrainTemp(0.0), RecoveryTemp(0.0), ReturnTemp(0.0), WasteTemp(0.0), TempError(0.0), MainsVolume(0.0), TankVolume(0.0), - ColdVolume(0.0), HotVolume(0.0), TotalVolume(0.0), Power(0.0), Energy(0.0), CapacityRatio(0.0), MinCapacityRate(0.0), - HXCapacityRate(0.0), DrainCapacityRate(0.0), NTU(0.0), ExpVal(0.0), AvailableFraction(0.0), NumWaterEquipment(0), MaxIterationsErrorIndex(0), - PlantLoopNum(0), PlantLoopSide(0), PlantLoopBranchNum(0), PlantLoopCompNum(0), SetLoopIndexFlag(true) - { - } - - void InitConnections( ); - - void UpdateWaterConnections( ); - - void CalcConnectionsHeatRecovery( ); - - void CalcConnectionsFlowRates( bool FirstHVACIteration); - - void CalcConnectionsDrainTemp( ); + namespace WaterUse { - void simulate(const PlantLocation &calledFromLocation, bool FirstHVACIteration, Real64 &CurLoad, bool RunFlag) override; + // Using/Aliasing - void ReportWaterUse( ); - - }; + // Data + // MODULE PARAMETER DEFINITIONS: + extern int const HeatRecoveryHXIdeal; + extern int const HeatRecoveryHXCounterFlow; + extern int const HeatRecoveryHXCrossFlow; - + extern int const HeatRecoveryConfigPlant; + extern int const HeatRecoveryConfigEquipment; + extern int const HeatRecoveryConfigPlantAndEquip; - // Functions + // DERIVED TYPE DEFINITIONS: - void clear_state(); + // MODULE VARIABLE TYPE DECLARATIONS: - void GetWaterUseInput(); + // MODULE VARIABLE DECLARATIONS: + extern int NumWaterEquipment; + extern int NumWaterConnections; + // INTEGER :: MaxIterationsErrorCount =0 + extern bool GetWaterUseInputFlag; - void SetupOutputVars(); + extern Array1D_bool CheckEquipName; + extern Array1D_bool CheckPlantLoop; - void CalcEquipmentFlowRates(int WaterEquipNum); + // SUBROUTINE SPECIFICATIONS: - void CalcEquipmentDrainTemp(int WaterEquipNum); + // Types - void SimulateWaterUse(bool FirstHVACIteration); - - void CalcWaterUseZoneGains(); - - void SimulateWaterUseConnection(int EquipTypeNum, std::string &CompName, int &CompIndex, bool InitLoopEquip, bool FirstHVACIteration); - - void ReportStandAloneWaterUse(); - - // Object Data - extern Array1D WaterEquipment; - extern Array1D WaterConnections; - - -} // namespace WaterUse + struct WaterEquipmentType + { + // Members + std::string Name; // Name of DHW + std::string EndUseSubcatName; + int Connections; // Index for WATER USE CONNECTIONS object + Real64 PeakVolFlowRate; // Peak volumetric flow rate, also water consumption rate (m3/s) + int FlowRateFracSchedule; // Pointer to schedule object + Real64 ColdVolFlowRate; + Real64 HotVolFlowRate; + Real64 TotalVolFlowRate; // Volumetric flow rate, also water consumption rate (m3/s) + Real64 ColdMassFlowRate; + Real64 HotMassFlowRate; + Real64 TotalMassFlowRate; // Mass flow rate (kg/s) + Real64 DrainMassFlowRate; + int ColdTempSchedule; // Index for schedule object + int HotTempSchedule; // Index for schedule object + int TargetTempSchedule; // Index for schedule object + Real64 ColdTemp; // Cold supply water temperature (C) + Real64 HotTemp; // Hot supply water temperature (C) + Real64 TargetTemp; // Target (mixed) water temperature (C) + Real64 MixedTemp; // Actual outlet (mixed) water temperature (C) + Real64 DrainTemp; + int Zone; // Index for zone object + int SensibleFracSchedule; // Pointer to schedule object + Real64 SensibleRate; + Real64 SensibleEnergy; + Real64 SensibleRateNoMultiplier; + int LatentFracSchedule; // Pointer to schedule object + Real64 LatentRate; + Real64 LatentEnergy; + Real64 LatentRateNoMultiplier; + Real64 MoistureRate; + Real64 MoistureMass; + Real64 ColdVolume; // Water consumption (m3) + Real64 HotVolume; // Water consumption (m3) + Real64 TotalVolume; // Water consumption (m3) + Real64 Power; // Heating rate required to meet the mixed water temperature (W) + Real64 Energy; // Heating energy required to meet the mixed water temperature (J) + + // Default Constructor + WaterEquipmentType() + : Connections(0), PeakVolFlowRate(0.0), FlowRateFracSchedule(0), ColdVolFlowRate(0.0), HotVolFlowRate(0.0), TotalVolFlowRate(0.0), + ColdMassFlowRate(0.0), HotMassFlowRate(0.0), TotalMassFlowRate(0.0), DrainMassFlowRate(0.0), ColdTempSchedule(0), HotTempSchedule(0), + TargetTempSchedule(0), ColdTemp(0.0), HotTemp(0.0), TargetTemp(0.0), MixedTemp(0.0), DrainTemp(0.0), Zone(0), SensibleFracSchedule(0), + SensibleRate(0.0), SensibleEnergy(0.0), SensibleRateNoMultiplier(0.0), LatentFracSchedule(0), LatentRate(0.0), LatentEnergy(0.0), + LatentRateNoMultiplier(0.0), MoistureRate(0.0), MoistureMass(0.0), ColdVolume(0.0), HotVolume(0.0), TotalVolume(0.0), Power(0.0), + Energy(0.0) + { + } + + // Reset Some Values to Zeros + void reset() + { + SensibleRate = 0.0; + SensibleEnergy = 0.0; + LatentRate = 0.0; + LatentEnergy = 0.0; + MixedTemp = 0.0; + TotalMassFlowRate = 0.0; + DrainTemp = 0.0; + } + }; + + struct WaterConnectionsType + { + // Members + std::string Name; // Name of DHW + bool Init; // Flag for initialization: TRUE means do the init + bool InitSizing; // Flag for initialization of plant sizing + bool StandAlone; // Flag for operation with no plant connections + int InletNode; // Hot water demand node + int OutletNode; // Cold water supply node + int SupplyTankNum; + int RecoveryTankNum; + int TankDemandID; // array to request flow from supply tank + int TankSupplyID; // array to send flow to recovery tank + bool HeatRecovery; + int HeatRecoveryHX; + int HeatRecoveryConfig; + Real64 HXUA; + Real64 Effectiveness; + Real64 RecoveryRate; + Real64 RecoveryEnergy; + Real64 MainsMassFlowRate; // Mass flow rate (kg/s) + Real64 TankMassFlowRate; // Mass flow rate (kg/s) + Real64 ColdMassFlowRate; // Mass flow rate (kg/s) cold = mains + tank + Real64 HotMassFlowRate; // Mass flow rate (kg/s) + Real64 TotalMassFlowRate; // Mass flow rate (kg/s) total = cold + hot + Real64 DrainMassFlowRate; + Real64 RecoveryMassFlowRate; + Real64 PeakVolFlowRate; // Volumetric flow rate, also water consumption rate (m3/s) + Real64 MainsVolFlowRate; // Volumetric flow rate, also water consumption rate (m3/s) + Real64 TankVolFlowRate; // Volumetric flow rate, also water consumption rate (m3/s) + Real64 ColdVolFlowRate; // Volumetric flow rate, also water consumption rate (m3/s) + Real64 HotVolFlowRate; // Volumetric flow rate, also water consumption rate (m3/s) + Real64 TotalVolFlowRate; // Volumetric flow rate, also water consumption rate (m3/s) + Real64 DrainVolFlowRate; + Real64 PeakMassFlowRate; // Peak Mass flow rate for MassFlowRateMax + int ColdTempSchedule; // Index for schedule object + int HotTempSchedule; // Index for schedule object + Real64 MainsTemp; // Cold supply water temperature (C) + Real64 TankTemp; // Cold supply water temperature (C) + Real64 ColdSupplyTemp; // cold from mains, schedule, or tank, depending + Real64 ColdTemp; // Cold supply water temperature (C) actual cold (could be reheated) + Real64 HotTemp; // Hot supply water temperature (C) + Real64 DrainTemp; + Real64 RecoveryTemp; + Real64 ReturnTemp; + Real64 WasteTemp; + Real64 TempError; + Real64 MainsVolume; // Water consumption (m3) + Real64 TankVolume; // Water consumption (m3) + Real64 ColdVolume; // Water consumption (m3) + Real64 HotVolume; // Water consumption (m3) + Real64 TotalVolume; // Water consumption (m3) + Real64 Power; // Heating rate required to raise temperature from cold to hot (W) + Real64 Energy; // Heating energy required to raise temperature from cold to hot (J) + int NumWaterEquipment; + int MaxIterationsErrorIndex; // recurring error index + Array1D_int WaterEquipment; + int PlantLoopNum; + int PlantLoopSide; + int PlantLoopBranchNum; + int PlantLoopCompNum; + + // Default Constructor + WaterConnectionsType() + : Init(true), InitSizing(true), StandAlone(false), InletNode(0), OutletNode(0), SupplyTankNum(0), RecoveryTankNum(0), TankDemandID(0), + TankSupplyID(0), HeatRecovery(false), HeatRecoveryHX(HeatRecoveryHXIdeal), HeatRecoveryConfig(HeatRecoveryConfigPlant), HXUA(0.0), + Effectiveness(0.0), RecoveryRate(0.0), RecoveryEnergy(0.0), MainsMassFlowRate(0.0), TankMassFlowRate(0.0), ColdMassFlowRate(0.0), + HotMassFlowRate(0.0), TotalMassFlowRate(0.0), DrainMassFlowRate(0.0), RecoveryMassFlowRate(0.0), PeakVolFlowRate(0.0), + MainsVolFlowRate(0.0), TankVolFlowRate(0.0), ColdVolFlowRate(0.0), HotVolFlowRate(0.0), TotalVolFlowRate(0.0), DrainVolFlowRate(0.0), + PeakMassFlowRate(0.0), ColdTempSchedule(0), HotTempSchedule(0), MainsTemp(0.0), TankTemp(0.0), ColdSupplyTemp(0.0), ColdTemp(0.0), + HotTemp(0.0), DrainTemp(0.0), RecoveryTemp(0.0), ReturnTemp(0.0), WasteTemp(0.0), TempError(0.0), MainsVolume(0.0), TankVolume(0.0), + ColdVolume(0.0), HotVolume(0.0), TotalVolume(0.0), Power(0.0), Energy(0.0), NumWaterEquipment(0), MaxIterationsErrorIndex(0), + PlantLoopNum(0), PlantLoopSide(0), PlantLoopBranchNum(0), PlantLoopCompNum(0) + { + } + }; + + // Object Data + extern Array1D WaterEquipment; + extern Array1D WaterConnections; + + // Functions + + void clear_state(); + + void SimulateWaterUse(bool FirstHVACIteration); + + void SimulateWaterUseConnection( + int EquipTypeNum, std::string &CompName, int &CompIndex, bool InitLoopEquip, bool FirstHVACIteration); + + void GetWaterUseInput(); + + void CalcEquipmentFlowRates(int WaterEquipNum); + + void CalcEquipmentDrainTemp(int WaterEquipNum); + + void InitConnections(int WaterConnNum); + + void CalcConnectionsFlowRates(int WaterConnNum, bool FirstHVACIteration); + + void CalcConnectionsDrainTemp(int WaterConnNum); + + void CalcConnectionsHeatRecovery(int WaterConnNum); + + void UpdateWaterConnections(int WaterConnNum); + + void ReportStandAloneWaterUse(); + + void ReportWaterUse(int WaterConnNum); + + void CalcWaterUseZoneGains(); + + } // namespace WaterUse } // namespace EnergyPlus From 6772b9da01173625c997fbd54447b1610abe885e Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Tue, 12 Nov 2019 13:45:28 -0700 Subject: [PATCH 33/51] partial cleanup local vars --- src/EnergyPlus/WaterUse.cc | 181 ++++++++++++++----------------------- src/EnergyPlus/WaterUse.hh | 36 ++++---- 2 files changed, 85 insertions(+), 132 deletions(-) diff --git a/src/EnergyPlus/WaterUse.cc b/src/EnergyPlus/WaterUse.cc index afa1be3d825..ff279fbfe33 100644 --- a/src/EnergyPlus/WaterUse.cc +++ b/src/EnergyPlus/WaterUse.cc @@ -61,7 +61,6 @@ #include #include #include -#include #include #include #include @@ -85,36 +84,21 @@ namespace EnergyPlus { // MODIFIED Brent Griffith, plant upgrade // RE-ENGINEERED na - // MODULE PARAMETER DEFINITIONS: - int const HeatRecoveryHXIdeal(1); - int const HeatRecoveryHXCounterFlow(2); - int const HeatRecoveryHXCrossFlow(3); - - int const HeatRecoveryConfigPlant(1); - int const HeatRecoveryConfigEquipment(2); - int const HeatRecoveryConfigPlantAndEquip(3); - - static std::string const BlankString; - - // MODULE VARIABLE DECLARATIONS: - int modNumWaterEquipment(0); - int modNumWaterConnections(0); - bool GetWaterUseInputFlag(true); + bool getWaterUseInputFlag(true); + int numWaterEquipment(0); + int numWaterConnections(0); Array1D_bool CheckEquipName; - Array1D_bool CheckPlantLoop; - // Object Data Array1D WaterEquipment; Array1D WaterConnections; void clear_state() { - modNumWaterEquipment = 0; - modNumWaterConnections = 0; - GetWaterUseInputFlag = true; + numWaterEquipment = 0; + numWaterConnections = 0; + getWaterUseInputFlag = true; CheckEquipName.deallocate(); - CheckPlantLoop.deallocate(); WaterEquipment.deallocate(); WaterConnections.deallocate(); } @@ -141,18 +125,16 @@ namespace EnergyPlus { int WaterEquipNum; int WaterConnNum; int NumIteration; - int MaxIterationsErrorCount; bool MyEnvrnFlag(true); // FLOW: - if (GetWaterUseInputFlag) { + if (getWaterUseInputFlag) { GetWaterUseInput(); - GetWaterUseInputFlag = false; + getWaterUseInputFlag = false; } if (DataGlobals::BeginEnvrnFlag && MyEnvrnFlag) { - MaxIterationsErrorCount = 0; - if (modNumWaterEquipment > 0) { + if (numWaterEquipment > 0) { for (auto &e : WaterEquipment) { e.SensibleRate = 0.0; e.SensibleEnergy = 0.0; @@ -164,7 +146,7 @@ namespace EnergyPlus { } } - if (modNumWaterConnections > 0) { + if (numWaterConnections > 0) { for (auto &e : WaterConnections) e.TotalMassFlowRate = 0.0; } @@ -175,7 +157,7 @@ namespace EnergyPlus { if (!DataGlobals::BeginEnvrnFlag) MyEnvrnFlag = true; // Simulate all unconnected WATER USE EQUIPMENT objects - for (WaterEquipNum = 1; WaterEquipNum <= modNumWaterEquipment; ++WaterEquipNum) { + for (WaterEquipNum = 1; WaterEquipNum <= numWaterEquipment; ++WaterEquipNum) { if (WaterEquipment(WaterEquipNum).Connections == 0) { CalcEquipmentFlowRates(WaterEquipNum); CalcEquipmentDrainTemp(WaterEquipNum); @@ -185,7 +167,7 @@ namespace EnergyPlus { ReportStandAloneWaterUse(); // Simulate WATER USE CONNECTIONS objects and connected WATER USE EQUIPMENT objects - for (WaterConnNum = 1; WaterConnNum <= modNumWaterConnections; ++WaterConnNum) { + for (WaterConnNum = 1; WaterConnNum <= numWaterConnections; ++WaterConnNum) { if (!WaterConnections(WaterConnNum).StandAlone) continue; // only model non plant connections here @@ -247,14 +229,12 @@ namespace EnergyPlus { // SUBROUTINE LOCAL VARIABLE DECLARATIONS: // INTEGER :: WaterEquipNum int WaterConnNum; - int NumIteration; - int MaxIterationsErrorCount; bool MyEnvrnFlag(true); // FLOW: - if (GetWaterUseInputFlag) { + if (getWaterUseInputFlag) { GetWaterUseInput(); - GetWaterUseInputFlag = false; + getWaterUseInputFlag = false; } if (CompIndex == 0) { @@ -265,9 +245,9 @@ namespace EnergyPlus { CompIndex = WaterConnNum; } else { WaterConnNum = CompIndex; - if (WaterConnNum > modNumWaterConnections || WaterConnNum < 1) { + if (WaterConnNum > numWaterConnections || WaterConnNum < 1) { ShowFatalError("SimulateWaterUseConnection: Invalid CompIndex passed=" + General::TrimSigDigits(WaterConnNum) + - ", Number of Units=" + General::TrimSigDigits(modNumWaterConnections) + ", Entered Unit name=" + CompName); + ", Number of Units=" + General::TrimSigDigits(numWaterConnections) + ", Entered Unit name=" + CompName); } if (CheckEquipName(WaterConnNum)) { if (CompName != WaterConnections(WaterConnNum).Name) { @@ -283,14 +263,13 @@ namespace EnergyPlus { } if (DataGlobals::BeginEnvrnFlag && MyEnvrnFlag) { - MaxIterationsErrorCount = 0; - if (modNumWaterEquipment > 0) { + if (numWaterEquipment > 0) { for (int i = WaterEquipment.l(), e = WaterEquipment.u(); i <= e; ++i) { WaterEquipment(i).reset(); } } - if (modNumWaterConnections > 0) { + if (numWaterConnections > 0) { for (auto &e : WaterConnections) e.TotalMassFlowRate = 0.0; } @@ -302,7 +281,7 @@ namespace EnergyPlus { InitConnections(WaterConnNum); - NumIteration = 0; + int NumIteration = 0; while (true) { ++NumIteration; @@ -350,21 +329,15 @@ namespace EnergyPlus { int IOStatus; // Used in GetObjectItem int NumAlphas; // Number of Alphas for each GetObjectItem call int NumNumbers; // Number of Numbers for each GetObjectItem call - // unused1208 INTEGER :: NumArgs - int WaterEquipNum; - int WaterConnNum; int AlphaNum; - int thisWaterEquipNum; - - // FLOW: DataIPShortCuts::cCurrentModuleObject = "WaterUse:Equipment"; - modNumWaterEquipment = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); + numWaterEquipment = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); - if (modNumWaterEquipment > 0) { - WaterEquipment.allocate(modNumWaterEquipment); + if (numWaterEquipment > 0) { + WaterEquipment.allocate(numWaterEquipment); - for (WaterEquipNum = 1; WaterEquipNum <= modNumWaterEquipment; ++WaterEquipNum) { + for (int WaterEquipNum = 1; WaterEquipNum <= numWaterEquipment; ++WaterEquipNum) { inputProcessor->getObjectItem(DataIPShortCuts::cCurrentModuleObject, WaterEquipNum, DataIPShortCuts::cAlphaArgs, @@ -463,12 +436,12 @@ namespace EnergyPlus { } DataIPShortCuts::cCurrentModuleObject = "WaterUse:Connections"; - modNumWaterConnections = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); + numWaterConnections = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); - if (modNumWaterConnections > 0) { - WaterConnections.allocate(modNumWaterConnections); + if (numWaterConnections > 0) { + WaterConnections.allocate(numWaterConnections); - for (WaterConnNum = 1; WaterConnNum <= modNumWaterConnections; ++WaterConnNum) { + for (int WaterConnNum = 1; WaterConnNum <= numWaterConnections; ++WaterConnNum) { inputProcessor->getObjectItem(DataIPShortCuts::cCurrentModuleObject, WaterConnNum, DataIPShortCuts::cAlphaArgs, @@ -559,11 +532,11 @@ namespace EnergyPlus { { auto const SELECT_CASE_var(DataIPShortCuts::cAlphaArgs(8)); if (SELECT_CASE_var == "IDEAL") { - WaterConnections(WaterConnNum).HeatRecoveryHX = HeatRecoveryHXIdeal; + WaterConnections(WaterConnNum).HeatRecoveryHX = HeatRecoveryHX::Ideal; } else if (SELECT_CASE_var == "COUNTERFLOW") { - WaterConnections(WaterConnNum).HeatRecoveryHX = HeatRecoveryHXCounterFlow; + WaterConnections(WaterConnNum).HeatRecoveryHX = HeatRecoveryHX::CounterFlow; } else if (SELECT_CASE_var == "CROSSFLOW") { - WaterConnections(WaterConnNum).HeatRecoveryHX = HeatRecoveryHXCrossFlow; + WaterConnections(WaterConnNum).HeatRecoveryHX = HeatRecoveryHX::CrossFlow; } else { ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(8) + '=' + DataIPShortCuts::cAlphaArgs(8)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + DataIPShortCuts::cAlphaArgs(1)); @@ -574,11 +547,11 @@ namespace EnergyPlus { { auto const SELECT_CASE_var(DataIPShortCuts::cAlphaArgs(9)); if (SELECT_CASE_var == "PLANT") { - WaterConnections(WaterConnNum).HeatRecoveryConfig = HeatRecoveryConfigPlant; + WaterConnections(WaterConnNum).HeatRecoveryConfig = HeatRecoveryConfig::Plant; } else if (SELECT_CASE_var == "EQUIPMENT") { - WaterConnections(WaterConnNum).HeatRecoveryConfig = HeatRecoveryConfigEquipment; + WaterConnections(WaterConnNum).HeatRecoveryConfig = HeatRecoveryConfig::Equipment; } else if (SELECT_CASE_var == "PLANTANDEQUIPMENT") { - WaterConnections(WaterConnNum).HeatRecoveryConfig = HeatRecoveryConfigPlantAndEquip; + WaterConnections(WaterConnNum).HeatRecoveryConfig = HeatRecoveryConfig::PlantAndEquip; } else { ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(9) + '=' + DataIPShortCuts::cAlphaArgs(9)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + DataIPShortCuts::cAlphaArgs(1)); @@ -592,7 +565,7 @@ namespace EnergyPlus { WaterConnections(WaterConnNum).WaterEquipment.allocate(NumAlphas - 9); for (AlphaNum = 10; AlphaNum <= NumAlphas; ++AlphaNum) { - WaterEquipNum = UtilityRoutines::FindItemInList(DataIPShortCuts::cAlphaArgs(AlphaNum), WaterEquipment); + int WaterEquipNum = UtilityRoutines::FindItemInList(DataIPShortCuts::cAlphaArgs(AlphaNum), WaterEquipment); if (WaterEquipNum == 0) { ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(AlphaNum) + '=' + DataIPShortCuts::cAlphaArgs(AlphaNum)); @@ -621,20 +594,18 @@ namespace EnergyPlus { if (ErrorsFound) ShowFatalError("Errors found in processing input for " + DataIPShortCuts::cCurrentModuleObject); - if (modNumWaterConnections > 0) { - CheckEquipName.allocate(modNumWaterConnections); - CheckPlantLoop.allocate(modNumWaterConnections); + if (numWaterConnections > 0) { + CheckEquipName.allocate(numWaterConnections); CheckEquipName = true; - CheckPlantLoop = true; } } // determine connection's peak mass flow rates. - if (modNumWaterConnections > 0) { - for (WaterConnNum = 1; WaterConnNum <= modNumWaterConnections; ++WaterConnNum) { + if (numWaterConnections > 0) { + for (int WaterConnNum = 1; WaterConnNum <= numWaterConnections; ++WaterConnNum) { WaterConnections(WaterConnNum).PeakMassFlowRate = 0.0; - for (WaterEquipNum = 1; WaterEquipNum <= WaterConnections(WaterConnNum).NumWaterEquipment; ++WaterEquipNum) { - thisWaterEquipNum = WaterConnections(WaterConnNum).WaterEquipment(WaterEquipNum); + for (int WaterEquipNum = 1; WaterEquipNum <= WaterConnections(WaterConnNum).NumWaterEquipment; ++WaterEquipNum) { + int thisWaterEquipNum = WaterConnections(WaterConnNum).WaterEquipment(WaterEquipNum); if (WaterEquipment(thisWaterEquipNum).Zone > 0) { WaterConnections(WaterConnNum).PeakMassFlowRate += WaterEquipment(thisWaterEquipNum).PeakVolFlowRate * Psychrometrics::RhoH2O(DataGlobals::InitConvTemp) * @@ -651,7 +622,7 @@ namespace EnergyPlus { // Setup EQUIPMENT report variables (now that connections have been established) // CurrentModuleObject='WaterUse:Equipment' - for (WaterEquipNum = 1; WaterEquipNum <= modNumWaterEquipment; ++WaterEquipNum) { + for (int WaterEquipNum = 1; WaterEquipNum <= numWaterEquipment; ++WaterEquipNum) { SetupOutputVariable("Water Use Equipment Hot Water Mass Flow Rate", OutputProcessor::Unit::kg_s, @@ -868,7 +839,7 @@ namespace EnergyPlus { // Setup CONNECTIONS report variables (don't put any on meters; they are metered at WATER USE EQUIPMENT level) // CurrentModuleObject='WaterUse:Connections' - for (WaterConnNum = 1; WaterConnNum <= modNumWaterConnections; ++WaterConnNum) { + for (int WaterConnNum = 1; WaterConnNum <= numWaterConnections; ++WaterConnNum) { SetupOutputVariable("Water Use Connections Hot Water Mass Flow Rate", OutputProcessor::Unit::kg_s, @@ -1043,17 +1014,10 @@ namespace EnergyPlus { // PURPOSE OF THIS SUBROUTINE: // Calculate desired hot and cold water flow rates - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - int WaterConnNum; - - // FLOW: - WaterConnNum = WaterEquipment(WaterEquipNum).Connections; - - if (WaterConnNum > 0) { + if (WaterEquipment(WaterEquipNum).Connections > 0) { // Get water temperature conditions from the CONNECTIONS object - WaterEquipment(WaterEquipNum).ColdTemp = WaterConnections(WaterConnNum).ColdTemp; - WaterEquipment(WaterEquipNum).HotTemp = WaterConnections(WaterConnNum).HotTemp; + WaterEquipment(WaterEquipNum).ColdTemp = WaterConnections(WaterEquipment(WaterEquipNum).Connections).ColdTemp; + WaterEquipment(WaterEquipNum).HotTemp = WaterConnections(WaterEquipment(WaterEquipNum).Connections).HotTemp; } else { // Get water temperature conditions from the WATER USE EQUIPMENT schedules @@ -1254,13 +1218,13 @@ namespace EnergyPlus { Array1D_bool SetLoopIndexFlag; // get loop number flag !DSU bool errFlag; - if (MyOneTimeFlag) { // DSU - SetLoopIndexFlag.dimension(modNumWaterConnections, true); // DSU - MyOneTimeFlag = false; // DSU - } // DSU + if (MyOneTimeFlag) { + SetLoopIndexFlag.dimension(numWaterConnections, true); + MyOneTimeFlag = false; + } - if (SetLoopIndexFlag(WaterConnNum)) { // DSU - if (allocated(DataPlant::PlantLoop) && !WaterConnections(WaterConnNum).StandAlone) { // DSU + if (SetLoopIndexFlag(WaterConnNum)) { + if (allocated(DataPlant::PlantLoop) && !WaterConnections(WaterConnNum).StandAlone) { errFlag = false; PlantUtilities::ScanPlantLoopsForObject(WaterConnections(WaterConnNum).Name, DataPlant::TypeOf_WaterUseConnection, @@ -1273,12 +1237,12 @@ namespace EnergyPlus { _, _, _, - _); // DSU | DSU | DSU | DSU | DSU | DSU | DSU - if (errFlag) { // DSU - ShowFatalError("InitConnections: Program terminated due to previous condition(s)."); // DSU - } // DSU - SetLoopIndexFlag(WaterConnNum) = false; // DSU - } // DSU + _); + if (errFlag) { + ShowFatalError("InitConnections: Program terminated due to previous condition(s)."); + } + SetLoopIndexFlag(WaterConnNum) = false; + } if (WaterConnections(WaterConnNum).StandAlone) SetLoopIndexFlag(WaterConnNum) = false; } @@ -1408,17 +1372,12 @@ namespace EnergyPlus { LoopSideNum, WaterConnections(WaterConnNum).PlantLoopBranchNum, WaterConnections(WaterConnNum).PlantLoopCompNum); - // DSU3 Node(InletNode)%MassFlowRate = MIN(WaterConnections(WaterConnNum)%HotMassFlowRate, Node(InletNode)%MassFlowRateMaxAvail) - // DSU3 Node(InletNode)%MassFlowRate = MAX(WaterConnections(WaterConnNum)%HotMassFlowRate, Node(InletNode)%MassFlowRateMinAvail) // readjust if more than actual available mass flow rate determined by the demand side manager if ((WaterConnections(WaterConnNum).HotMassFlowRate != DesiredHotWaterMassFlow) && (WaterConnections(WaterConnNum).HotMassFlowRate > 0.0)) { // plant didn't give what was asked for - // DSU3 Node(InletNode)%MassFlowRate = Node(InletNode)%MassFlowRateMaxAvail - AvailableFraction = DesiredHotWaterMassFlow / WaterConnections(WaterConnNum).HotMassFlowRate; - // DSU3 WaterConnections(WaterConnNum)%HotMassFlowRate = Node(InletNode)%MassFlowRateMaxAvail WaterConnections(WaterConnNum).ColdMassFlowRate = WaterConnections(WaterConnNum).TotalMassFlowRate - WaterConnections(WaterConnNum).HotMassFlowRate; // Preserve the total mass flow rate @@ -1542,11 +1501,11 @@ namespace EnergyPlus { { auto const SELECT_CASE_var(WaterConnections(WaterConnNum).HeatRecoveryConfig); - if (SELECT_CASE_var == HeatRecoveryConfigPlant) { + if (SELECT_CASE_var == HeatRecoveryConfig::Plant) { WaterConnections(WaterConnNum).RecoveryMassFlowRate = WaterConnections(WaterConnNum).HotMassFlowRate; - } else if (SELECT_CASE_var == HeatRecoveryConfigEquipment) { + } else if (SELECT_CASE_var == HeatRecoveryConfig::Equipment) { WaterConnections(WaterConnNum).RecoveryMassFlowRate = WaterConnections(WaterConnNum).ColdMassFlowRate; - } else if (SELECT_CASE_var == HeatRecoveryConfigPlantAndEquip) { + } else if (SELECT_CASE_var == HeatRecoveryConfig::PlantAndEquip) { WaterConnections(WaterConnNum).RecoveryMassFlowRate = WaterConnections(WaterConnNum).TotalMassFlowRate; } } @@ -1557,10 +1516,10 @@ namespace EnergyPlus { { auto const SELECT_CASE_var(WaterConnections(WaterConnNum).HeatRecoveryHX); - if (SELECT_CASE_var == HeatRecoveryHXIdeal) { + if (SELECT_CASE_var == HeatRecoveryHX::Ideal) { WaterConnections(WaterConnNum).Effectiveness = 1.0; - } else if (SELECT_CASE_var == HeatRecoveryHXCounterFlow) { // Unmixed + } else if (SELECT_CASE_var == HeatRecoveryHX::CounterFlow) { // Unmixed CapacityRatio = MinCapacityRate / max(DrainCapacityRate, HXCapacityRate); NTU = WaterConnections(WaterConnNum).HXUA / MinCapacityRate; if (CapacityRatio == 1.0) { @@ -1570,7 +1529,7 @@ namespace EnergyPlus { WaterConnections(WaterConnNum).Effectiveness = (1.0 - ExpVal) / (1.0 - CapacityRatio * ExpVal); } - } else if (SELECT_CASE_var == HeatRecoveryHXCrossFlow) { // Unmixed + } else if (SELECT_CASE_var == HeatRecoveryHX::CrossFlow) { // Unmixed CapacityRatio = MinCapacityRate / max(DrainCapacityRate, HXCapacityRate); NTU = WaterConnections(WaterConnNum).HXUA / MinCapacityRate; WaterConnections(WaterConnNum).Effectiveness = @@ -1600,19 +1559,18 @@ namespace EnergyPlus { { auto const SELECT_CASE_var(WaterConnections(WaterConnNum).HeatRecoveryConfig); - if (SELECT_CASE_var == HeatRecoveryConfigPlant) { + if (SELECT_CASE_var == HeatRecoveryConfig::Plant) { WaterConnections(WaterConnNum).TempError = 0.0; // No feedback back to the cold supply - // WaterConnections(WaterConnNum)%ColdTemp = WaterConnections(WaterConnNum)%ColdSupplyTemp WaterConnections(WaterConnNum).ReturnTemp = WaterConnections(WaterConnNum).RecoveryTemp; - } else if (SELECT_CASE_var == HeatRecoveryConfigEquipment) { + } else if (SELECT_CASE_var == HeatRecoveryConfig::Equipment) { WaterConnections(WaterConnNum).TempError = std::abs(WaterConnections(WaterConnNum).ColdTemp - WaterConnections(WaterConnNum).RecoveryTemp); WaterConnections(WaterConnNum).ColdTemp = WaterConnections(WaterConnNum).RecoveryTemp; WaterConnections(WaterConnNum).ReturnTemp = WaterConnections(WaterConnNum).ColdSupplyTemp; - } else if (SELECT_CASE_var == HeatRecoveryConfigPlantAndEquip) { + } else if (SELECT_CASE_var == HeatRecoveryConfig::PlantAndEquip) { WaterConnections(WaterConnNum).TempError = std::abs(WaterConnections(WaterConnNum).ColdTemp - WaterConnections(WaterConnNum).RecoveryTemp); @@ -1648,7 +1606,6 @@ namespace EnergyPlus { if (InletNode > 0 && OutletNode > 0) { // Pass all variables from inlet to outlet node PlantUtilities::SafeCopyPlantNode(InletNode, OutletNode, LoopNum); - // DSU3 Node(OutletNode) = Node(InletNode) // Set outlet node variables that are possibly changed DataLoopNode::Node(OutletNode).Temp = WaterConnections(WaterConnNum).ReturnTemp; @@ -1675,7 +1632,7 @@ namespace EnergyPlus { int WaterEquipNum; // FLOW: - for (WaterEquipNum = 1; WaterEquipNum <= modNumWaterEquipment; ++WaterEquipNum) { + for (WaterEquipNum = 1; WaterEquipNum <= numWaterEquipment; ++WaterEquipNum) { WaterEquipment(WaterEquipNum).ColdVolFlowRate = WaterEquipment(WaterEquipNum).ColdMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); WaterEquipment(WaterEquipNum).HotVolFlowRate = @@ -1793,7 +1750,7 @@ namespace EnergyPlus { bool MyEnvrnFlag(true); // FLOW: - if (modNumWaterEquipment == 0) return; + if (numWaterEquipment == 0) return; if (DataGlobals::BeginEnvrnFlag && MyEnvrnFlag) { for (auto &e : WaterEquipment) { @@ -1817,7 +1774,7 @@ namespace EnergyPlus { if (!DataGlobals::BeginEnvrnFlag) MyEnvrnFlag = true; - for (WaterEquipNum = 1; WaterEquipNum <= modNumWaterEquipment; ++WaterEquipNum) { + for (WaterEquipNum = 1; WaterEquipNum <= numWaterEquipment; ++WaterEquipNum) { if (WaterEquipment(WaterEquipNum).Zone == 0) continue; ZoneNum = WaterEquipment(WaterEquipNum).Zone; WaterEquipment(WaterEquipNum).SensibleRateNoMultiplier = diff --git a/src/EnergyPlus/WaterUse.hh b/src/EnergyPlus/WaterUse.hh index db66540ac19..3dc9fb0da15 100644 --- a/src/EnergyPlus/WaterUse.hh +++ b/src/EnergyPlus/WaterUse.hh @@ -59,27 +59,23 @@ namespace EnergyPlus { namespace WaterUse { - // Using/Aliasing - - // Data - // MODULE PARAMETER DEFINITIONS: - extern int const HeatRecoveryHXIdeal; - extern int const HeatRecoveryHXCounterFlow; - extern int const HeatRecoveryHXCrossFlow; - - extern int const HeatRecoveryConfigPlant; - extern int const HeatRecoveryConfigEquipment; - extern int const HeatRecoveryConfigPlantAndEquip; - - // DERIVED TYPE DEFINITIONS: + enum struct HeatRecoveryHX + { + Ideal, + CounterFlow, + CrossFlow + }; - // MODULE VARIABLE TYPE DECLARATIONS: + enum struct HeatRecoveryConfig + { + Plant, + Equipment, + PlantAndEquip + }; - // MODULE VARIABLE DECLARATIONS: extern int NumWaterEquipment; extern int NumWaterConnections; - // INTEGER :: MaxIterationsErrorCount =0 - extern bool GetWaterUseInputFlag; + extern bool getWaterUseInputFlag; extern Array1D_bool CheckEquipName; extern Array1D_bool CheckPlantLoop; @@ -166,8 +162,8 @@ namespace EnergyPlus { int TankDemandID; // array to request flow from supply tank int TankSupplyID; // array to send flow to recovery tank bool HeatRecovery; - int HeatRecoveryHX; - int HeatRecoveryConfig; + HeatRecoveryHX HeatRecoveryHX; + HeatRecoveryConfig HeatRecoveryConfig; Real64 HXUA; Real64 Effectiveness; Real64 RecoveryRate; @@ -217,7 +213,7 @@ namespace EnergyPlus { // Default Constructor WaterConnectionsType() : Init(true), InitSizing(true), StandAlone(false), InletNode(0), OutletNode(0), SupplyTankNum(0), RecoveryTankNum(0), TankDemandID(0), - TankSupplyID(0), HeatRecovery(false), HeatRecoveryHX(HeatRecoveryHXIdeal), HeatRecoveryConfig(HeatRecoveryConfigPlant), HXUA(0.0), + TankSupplyID(0), HeatRecovery(false), HeatRecoveryHX(HeatRecoveryHX::Ideal), HeatRecoveryConfig(HeatRecoveryConfig::Plant), HXUA(0.0), Effectiveness(0.0), RecoveryRate(0.0), RecoveryEnergy(0.0), MainsMassFlowRate(0.0), TankMassFlowRate(0.0), ColdMassFlowRate(0.0), HotMassFlowRate(0.0), TotalMassFlowRate(0.0), DrainMassFlowRate(0.0), RecoveryMassFlowRate(0.0), PeakVolFlowRate(0.0), MainsVolFlowRate(0.0), TankVolFlowRate(0.0), ColdVolFlowRate(0.0), HotVolFlowRate(0.0), TotalVolFlowRate(0.0), DrainVolFlowRate(0.0), From 545b21cff5717049713d0352a4644c1494d968a9 Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Tue, 12 Nov 2019 14:14:53 -0700 Subject: [PATCH 34/51] cleanup local vars --- src/EnergyPlus/WaterUse.cc | 201 ++++++++++--------------------------- src/EnergyPlus/WaterUse.hh | 24 +---- 2 files changed, 58 insertions(+), 167 deletions(-) diff --git a/src/EnergyPlus/WaterUse.cc b/src/EnergyPlus/WaterUse.cc index ff279fbfe33..cfbc114800b 100644 --- a/src/EnergyPlus/WaterUse.cc +++ b/src/EnergyPlus/WaterUse.cc @@ -1116,24 +1116,8 @@ namespace EnergyPlus { // PURPOSE OF THIS SUBROUTINE: // Calculate drainwater temperature and heat and moisture gains to zone. - - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - int ZoneNum; - Real64 ZoneMAT; - Real64 ZoneHumRat; - Real64 ZoneHumRatSat; - Real64 RhoAirDry; - Real64 ZoneMassMax; - Real64 FlowMassMax; - Real64 MoistureMassMax; - static std::string const RoutineName("CalcEquipmentDrainTemp"); - // FLOW: - WaterEquipment(WaterEquipNum).SensibleRate = 0.0; WaterEquipment(WaterEquipNum).SensibleEnergy = 0.0; WaterEquipment(WaterEquipNum).LatentRate = 0.0; @@ -1144,8 +1128,6 @@ namespace EnergyPlus { WaterEquipment(WaterEquipNum).DrainMassFlowRate = WaterEquipment(WaterEquipNum).TotalMassFlowRate; } else { - ZoneNum = WaterEquipment(WaterEquipNum).Zone; - ZoneMAT = DataHeatBalFanSys::MAT(ZoneNum); if (WaterEquipment(WaterEquipNum).SensibleFracSchedule == 0) { WaterEquipment(WaterEquipNum).SensibleRate = 0.0; @@ -1155,7 +1137,7 @@ namespace EnergyPlus { ScheduleManager::GetCurrentScheduleValue(WaterEquipment(WaterEquipNum).SensibleFracSchedule) * WaterEquipment(WaterEquipNum).TotalMassFlowRate * Psychrometrics::CPHW(DataGlobals::InitConvTemp) * - (WaterEquipment(WaterEquipNum).MixedTemp - ZoneMAT); + (WaterEquipment(WaterEquipNum).MixedTemp - DataHeatBalFanSys::MAT(WaterEquipment(WaterEquipNum).Zone)); WaterEquipment(WaterEquipNum).SensibleEnergy = WaterEquipment(WaterEquipNum).SensibleRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; } @@ -1164,24 +1146,19 @@ namespace EnergyPlus { WaterEquipment(WaterEquipNum).LatentRate = 0.0; WaterEquipment(WaterEquipNum).LatentEnergy = 0.0; } else { - ZoneHumRat = DataHeatBalFanSys::ZoneAirHumRat(ZoneNum); - ZoneHumRatSat = - Psychrometrics::PsyWFnTdbRhPb(ZoneMAT, 1.0, DataEnvironment::OutBaroPress, RoutineName); // Humidratio at 100% relative humidity - RhoAirDry = Psychrometrics::PsyRhoAirFnPbTdbW(DataEnvironment::OutBaroPress, ZoneMAT, 0.0); - - ZoneMassMax = - (ZoneHumRatSat - ZoneHumRat) * RhoAirDry * DataHeatBalance::Zone(ZoneNum).Volume; // Max water that can be evaporated to zone - FlowMassMax = - WaterEquipment(WaterEquipNum).TotalMassFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; // Max water in flow - MoistureMassMax = min(ZoneMassMax, FlowMassMax); - - WaterEquipment(WaterEquipNum).MoistureMass = - ScheduleManager::GetCurrentScheduleValue(WaterEquipment(WaterEquipNum).LatentFracSchedule) * MoistureMassMax; + Real64 ZoneHumRat = DataHeatBalFanSys::ZoneAirHumRat(WaterEquipment(WaterEquipNum).Zone); + Real64 ZoneHumRatSat = Psychrometrics::PsyWFnTdbRhPb(DataHeatBalFanSys::MAT(WaterEquipment(WaterEquipNum).Zone), 1.0, DataEnvironment::OutBaroPress, RoutineName); // Humidratio at 100% relative humidity + Real64 RhoAirDry = Psychrometrics::PsyRhoAirFnPbTdbW(DataEnvironment::OutBaroPress, DataHeatBalFanSys::MAT(WaterEquipment(WaterEquipNum).Zone), 0.0); + Real64 ZoneMassMax = (ZoneHumRatSat - ZoneHumRat) * RhoAirDry * DataHeatBalance::Zone(WaterEquipment(WaterEquipNum).Zone).Volume; // Max water that can be evaporated to zone + Real64 FlowMassMax = WaterEquipment(WaterEquipNum).TotalMassFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; // Max water in flow + Real64 MoistureMassMax = min(ZoneMassMax, FlowMassMax); + + WaterEquipment(WaterEquipNum).MoistureMass = ScheduleManager::GetCurrentScheduleValue(WaterEquipment(WaterEquipNum).LatentFracSchedule) * MoistureMassMax; WaterEquipment(WaterEquipNum).MoistureRate = WaterEquipment(WaterEquipNum).MoistureMass / (DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour); WaterEquipment(WaterEquipNum).LatentRate = - WaterEquipment(WaterEquipNum).MoistureRate * Psychrometrics::PsyHfgAirFnWTdb(ZoneHumRat, ZoneMAT); + WaterEquipment(WaterEquipNum).MoistureRate * Psychrometrics::PsyHfgAirFnWTdb(ZoneHumRat, DataHeatBalFanSys::MAT(WaterEquipment(WaterEquipNum).Zone)); WaterEquipment(WaterEquipNum).LatentEnergy = WaterEquipment(WaterEquipNum).LatentRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; } @@ -1212,11 +1189,8 @@ namespace EnergyPlus { // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - int InletNode; - int OutletNode; - bool MyOneTimeFlag(true); // one time flag !DSU - Array1D_bool SetLoopIndexFlag; // get loop number flag !DSU - bool errFlag; + bool MyOneTimeFlag(true); // one time flag + Array1D_bool SetLoopIndexFlag; // get loop number flag if (MyOneTimeFlag) { SetLoopIndexFlag.dimension(numWaterConnections, true); @@ -1225,7 +1199,7 @@ namespace EnergyPlus { if (SetLoopIndexFlag(WaterConnNum)) { if (allocated(DataPlant::PlantLoop) && !WaterConnections(WaterConnNum).StandAlone) { - errFlag = false; + bool errFlag = false; PlantUtilities::ScanPlantLoopsForObject(WaterConnections(WaterConnNum).Name, DataPlant::TypeOf_WaterUseConnection, WaterConnections(WaterConnNum).PlantLoopNum, @@ -1270,22 +1244,20 @@ namespace EnergyPlus { } } else { - InletNode = WaterConnections(WaterConnNum).InletNode; - OutletNode = WaterConnections(WaterConnNum).OutletNode; if (DataGlobals::BeginEnvrnFlag && WaterConnections(WaterConnNum).Init) { // Clear node initial conditions - if (InletNode > 0 && OutletNode > 0) { + if (WaterConnections(WaterConnNum).InletNode > 0 && WaterConnections(WaterConnNum).OutletNode > 0) { PlantUtilities::InitComponentNodes(0.0, WaterConnections(WaterConnNum).PeakMassFlowRate, - InletNode, - OutletNode, + WaterConnections(WaterConnNum).InletNode, + WaterConnections(WaterConnNum).OutletNode, WaterConnections(WaterConnNum).PlantLoopNum, WaterConnections(WaterConnNum).PlantLoopSide, WaterConnections(WaterConnNum).PlantLoopBranchNum, WaterConnections(WaterConnNum).PlantLoopCompNum); - WaterConnections(WaterConnNum).ReturnTemp = DataLoopNode::Node(InletNode).Temp; + WaterConnections(WaterConnNum).ReturnTemp = DataLoopNode::Node(WaterConnections(WaterConnNum).InletNode).Temp; } WaterConnections(WaterConnNum).Init = false; @@ -1293,9 +1265,9 @@ namespace EnergyPlus { if (!DataGlobals::BeginEnvrnFlag) WaterConnections(WaterConnNum).Init = true; - if (InletNode > 0) { + if (WaterConnections(WaterConnNum).InletNode > 0) { if (!DataGlobals::DoingSizing) { - WaterConnections(WaterConnNum).HotTemp = DataLoopNode::Node(InletNode).Temp; + WaterConnections(WaterConnNum).HotTemp = DataLoopNode::Node(WaterConnections(WaterConnNum).InletNode).Temp; } else { // plant loop will not be running so need a value here. // should change to use tank setpoint but water use connections don't have knowledge of the tank they are fed by @@ -1317,23 +1289,11 @@ namespace EnergyPlus { // PURPOSE OF THIS SUBROUTINE: // Calculate summed values for WATER USE CONNECTIONS (to prepare to request flow from plant, and for reporting). - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - int WaterEquipNum; - int Loop; - int InletNode; - int OutletNode; - int LoopNum; - int LoopSideNum; - Real64 AvailableFraction; - Real64 DesiredHotWaterMassFlow; // store original request - - // FLOW: WaterConnections(WaterConnNum).ColdMassFlowRate = 0.0; WaterConnections(WaterConnNum).HotMassFlowRate = 0.0; - for (Loop = 1; Loop <= WaterConnections(WaterConnNum).NumWaterEquipment; ++Loop) { - WaterEquipNum = WaterConnections(WaterConnNum).WaterEquipment(Loop); + for (int Loop = 1; Loop <= WaterConnections(WaterConnNum).NumWaterEquipment; ++Loop) { + int WaterEquipNum = WaterConnections(WaterConnNum).WaterEquipment(Loop); CalcEquipmentFlowRates(WaterEquipNum); @@ -1345,46 +1305,39 @@ namespace EnergyPlus { WaterConnections(WaterConnNum).ColdMassFlowRate + WaterConnections(WaterConnNum).HotMassFlowRate; if (!WaterConnections(WaterConnNum).StandAlone) { // Interact with the plant loop - InletNode = WaterConnections(WaterConnNum).InletNode; - OutletNode = WaterConnections(WaterConnNum).OutletNode; - LoopNum = WaterConnections(WaterConnNum).PlantLoopNum; - LoopSideNum = WaterConnections(WaterConnNum).PlantLoopSide; - if (InletNode > 0) { + if (WaterConnections(WaterConnNum).InletNode > 0) { if (FirstHVACIteration) { // Request the mass flow rate from the demand side manager - // Node(InletNode)%MassFlowRate = WaterConnections(WaterConnNum)%HotMassFlowRate - // Node(InletNode)%MassFlowRateMaxAvail = WaterConnections(WaterConnNum)%PeakMassFlowRate - // Node(InletNode)%MassFlowRateMinAvail = 0.0D0 PlantUtilities::SetComponentFlowRate(WaterConnections(WaterConnNum).HotMassFlowRate, - InletNode, - OutletNode, - LoopNum, - LoopSideNum, + WaterConnections(WaterConnNum).InletNode, + WaterConnections(WaterConnNum).OutletNode, + WaterConnections(WaterConnNum).PlantLoopNum, + WaterConnections(WaterConnNum).PlantLoopSide, WaterConnections(WaterConnNum).PlantLoopBranchNum, WaterConnections(WaterConnNum).PlantLoopCompNum); } else { - DesiredHotWaterMassFlow = WaterConnections(WaterConnNum).HotMassFlowRate; + Real64 DesiredHotWaterMassFlow = WaterConnections(WaterConnNum).HotMassFlowRate; PlantUtilities::SetComponentFlowRate(DesiredHotWaterMassFlow, - InletNode, - OutletNode, - LoopNum, - LoopSideNum, + WaterConnections(WaterConnNum).InletNode, + WaterConnections(WaterConnNum).OutletNode, + WaterConnections(WaterConnNum).PlantLoopNum, + WaterConnections(WaterConnNum).PlantLoopSide, WaterConnections(WaterConnNum).PlantLoopBranchNum, WaterConnections(WaterConnNum).PlantLoopCompNum); // readjust if more than actual available mass flow rate determined by the demand side manager if ((WaterConnections(WaterConnNum).HotMassFlowRate != DesiredHotWaterMassFlow) && (WaterConnections(WaterConnNum).HotMassFlowRate > 0.0)) { // plant didn't give what was asked for - AvailableFraction = DesiredHotWaterMassFlow / WaterConnections(WaterConnNum).HotMassFlowRate; + Real64 AvailableFraction = DesiredHotWaterMassFlow / WaterConnections(WaterConnNum).HotMassFlowRate; WaterConnections(WaterConnNum).ColdMassFlowRate = WaterConnections(WaterConnNum).TotalMassFlowRate - WaterConnections(WaterConnNum).HotMassFlowRate; // Preserve the total mass flow rate // Proportionally reduce hot water and increase cold water for all WATER USE EQUIPMENT - for (Loop = 1; Loop <= WaterConnections(WaterConnNum).NumWaterEquipment; ++Loop) { - WaterEquipNum = WaterConnections(WaterConnNum).WaterEquipment(Loop); + for (int Loop = 1; Loop <= WaterConnections(WaterConnNum).NumWaterEquipment; ++Loop) { + int WaterEquipNum = WaterConnections(WaterConnNum).WaterEquipment(Loop); // Recalculate flow rates for water equipment within connection WaterEquipment(WaterEquipNum).HotMassFlowRate *= AvailableFraction; @@ -1432,21 +1385,11 @@ namespace EnergyPlus { // MODIFIED na // RE-ENGINEERED na - // PURPOSE OF THIS SUBROUTINE: - // Calculate - - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - int WaterEquipNum; - int Loop; - Real64 MassFlowTempSum; - - // FLOW: + Real64 MassFlowTempSum = 0.0; WaterConnections(WaterConnNum).DrainMassFlowRate = 0.0; - MassFlowTempSum = 0.0; - for (Loop = 1; Loop <= WaterConnections(WaterConnNum).NumWaterEquipment; ++Loop) { - WaterEquipNum = WaterConnections(WaterConnNum).WaterEquipment(Loop); + for (int Loop = 1; Loop <= WaterConnections(WaterConnNum).NumWaterEquipment; ++Loop) { + int WaterEquipNum = WaterConnections(WaterConnNum).WaterEquipment(Loop); CalcEquipmentDrainTemp(WaterEquipNum); @@ -1476,15 +1419,6 @@ namespace EnergyPlus { // PURPOSE OF THIS SUBROUTINE: // Calculate drainwater heat recovery - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - Real64 CapacityRatio; - Real64 NTU; - Real64 ExpVal; - Real64 HXCapacityRate; - Real64 DrainCapacityRate; - Real64 MinCapacityRate; - - // FLOW: if (!WaterConnections(WaterConnNum).HeatRecovery) { WaterConnections(WaterConnNum).RecoveryTemp = WaterConnections(WaterConnNum).ColdSupplyTemp; WaterConnections(WaterConnNum).ReturnTemp = WaterConnections(WaterConnNum).ColdSupplyTemp; @@ -1510,9 +1444,9 @@ namespace EnergyPlus { } } - HXCapacityRate = Psychrometrics::CPHW(DataGlobals::InitConvTemp) * WaterConnections(WaterConnNum).RecoveryMassFlowRate; - DrainCapacityRate = Psychrometrics::CPHW(DataGlobals::InitConvTemp) * WaterConnections(WaterConnNum).DrainMassFlowRate; - MinCapacityRate = min(DrainCapacityRate, HXCapacityRate); + Real64 HXCapacityRate = Psychrometrics::CPHW(DataGlobals::InitConvTemp) * WaterConnections(WaterConnNum).RecoveryMassFlowRate; + Real64 DrainCapacityRate = Psychrometrics::CPHW(DataGlobals::InitConvTemp) * WaterConnections(WaterConnNum).DrainMassFlowRate; + Real64 MinCapacityRate = min(DrainCapacityRate, HXCapacityRate); { auto const SELECT_CASE_var(WaterConnections(WaterConnNum).HeatRecoveryHX); @@ -1520,18 +1454,18 @@ namespace EnergyPlus { WaterConnections(WaterConnNum).Effectiveness = 1.0; } else if (SELECT_CASE_var == HeatRecoveryHX::CounterFlow) { // Unmixed - CapacityRatio = MinCapacityRate / max(DrainCapacityRate, HXCapacityRate); - NTU = WaterConnections(WaterConnNum).HXUA / MinCapacityRate; + Real64 CapacityRatio = MinCapacityRate / max(DrainCapacityRate, HXCapacityRate); + Real64 NTU = WaterConnections(WaterConnNum).HXUA / MinCapacityRate; if (CapacityRatio == 1.0) { WaterConnections(WaterConnNum).Effectiveness = NTU / (1.0 + NTU); } else { - ExpVal = std::exp(-NTU * (1.0 - CapacityRatio)); + Real64 ExpVal = std::exp(-NTU * (1.0 - CapacityRatio)); WaterConnections(WaterConnNum).Effectiveness = (1.0 - ExpVal) / (1.0 - CapacityRatio * ExpVal); } } else if (SELECT_CASE_var == HeatRecoveryHX::CrossFlow) { // Unmixed - CapacityRatio = MinCapacityRate / max(DrainCapacityRate, HXCapacityRate); - NTU = WaterConnections(WaterConnNum).HXUA / MinCapacityRate; + Real64 CapacityRatio = MinCapacityRate / max(DrainCapacityRate, HXCapacityRate); + Real64 NTU = WaterConnections(WaterConnNum).HXUA / MinCapacityRate; WaterConnections(WaterConnNum).Effectiveness = 1.0 - std::exp((std::pow(NTU, 0.22) / CapacityRatio) * (std::exp(-CapacityRatio * std::pow(NTU, 0.78)) - 1.0)); } @@ -1593,22 +1527,12 @@ namespace EnergyPlus { // PURPOSE OF THIS SUBROUTINE: // Updates the node variables with local variables. - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - int InletNode; - int OutletNode; - int LoopNum; - - // FLOW: - InletNode = WaterConnections(WaterConnNum).InletNode; - OutletNode = WaterConnections(WaterConnNum).OutletNode; - LoopNum = WaterConnections(WaterConnNum).PlantLoopNum; - - if (InletNode > 0 && OutletNode > 0) { + if (WaterConnections(WaterConnNum).InletNode > 0 && WaterConnections(WaterConnNum).OutletNode > 0) { // Pass all variables from inlet to outlet node - PlantUtilities::SafeCopyPlantNode(InletNode, OutletNode, LoopNum); + PlantUtilities::SafeCopyPlantNode(WaterConnections(WaterConnNum).InletNode, WaterConnections(WaterConnNum).OutletNode, WaterConnections(WaterConnNum).PlantLoopNum); // Set outlet node variables that are possibly changed - DataLoopNode::Node(OutletNode).Temp = WaterConnections(WaterConnNum).ReturnTemp; + DataLoopNode::Node(WaterConnections(WaterConnNum).OutletNode).Temp = WaterConnections(WaterConnNum).ReturnTemp; // should add enthalpy update to return? } } @@ -1625,14 +1549,7 @@ namespace EnergyPlus { // PURPOSE OF THIS SUBROUTINE: // Calculates report variables for stand alone water use - - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - int WaterEquipNum; - - // FLOW: - for (WaterEquipNum = 1; WaterEquipNum <= numWaterEquipment; ++WaterEquipNum) { + for (int WaterEquipNum = 1; WaterEquipNum <= numWaterEquipment; ++WaterEquipNum) { WaterEquipment(WaterEquipNum).ColdVolFlowRate = WaterEquipment(WaterEquipNum).ColdMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); WaterEquipment(WaterEquipNum).HotVolFlowRate = @@ -1673,15 +1590,8 @@ namespace EnergyPlus { // PURPOSE OF THIS SUBROUTINE: // Calculates report variables. - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - int Loop; - int WaterEquipNum; - - // FLOW: - for (Loop = 1; Loop <= WaterConnections(WaterConnNum).NumWaterEquipment; ++Loop) { - WaterEquipNum = WaterConnections(WaterConnNum).WaterEquipment(Loop); + for (int Loop = 1; Loop <= WaterConnections(WaterConnNum).NumWaterEquipment; ++Loop) { + int WaterEquipNum = WaterConnections(WaterConnNum).WaterEquipment(Loop); WaterEquipment(WaterEquipNum).ColdVolFlowRate = WaterEquipment(WaterEquipNum).ColdMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); WaterEquipment(WaterEquipNum).HotVolFlowRate = @@ -1743,13 +1653,8 @@ namespace EnergyPlus { // PURPOSE OF THIS SUBROUTINE: // Calculates the zone internal gains due to water use sensible and latent loads. - // Locals - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - int WaterEquipNum; - int ZoneNum; bool MyEnvrnFlag(true); - // FLOW: if (numWaterEquipment == 0) return; if (DataGlobals::BeginEnvrnFlag && MyEnvrnFlag) { @@ -1774,9 +1679,9 @@ namespace EnergyPlus { if (!DataGlobals::BeginEnvrnFlag) MyEnvrnFlag = true; - for (WaterEquipNum = 1; WaterEquipNum <= numWaterEquipment; ++WaterEquipNum) { + for (int WaterEquipNum = 1; WaterEquipNum <= numWaterEquipment; ++WaterEquipNum) { if (WaterEquipment(WaterEquipNum).Zone == 0) continue; - ZoneNum = WaterEquipment(WaterEquipNum).Zone; + int ZoneNum = WaterEquipment(WaterEquipNum).Zone; WaterEquipment(WaterEquipNum).SensibleRateNoMultiplier = WaterEquipment(WaterEquipNum).SensibleRate / (DataHeatBalance::Zone(ZoneNum).Multiplier * DataHeatBalance::Zone(ZoneNum).ListMultiplier); // CR7401, back out multipliers diff --git a/src/EnergyPlus/WaterUse.hh b/src/EnergyPlus/WaterUse.hh index 3dc9fb0da15..f90152b3004 100644 --- a/src/EnergyPlus/WaterUse.hh +++ b/src/EnergyPlus/WaterUse.hh @@ -73,20 +73,12 @@ namespace EnergyPlus { PlantAndEquip }; - extern int NumWaterEquipment; - extern int NumWaterConnections; extern bool getWaterUseInputFlag; extern Array1D_bool CheckEquipName; - extern Array1D_bool CheckPlantLoop; - - // SUBROUTINE SPECIFICATIONS: - - // Types struct WaterEquipmentType { - // Members std::string Name; // Name of DHW std::string EndUseSubcatName; int Connections; // Index for WATER USE CONNECTIONS object @@ -124,7 +116,6 @@ namespace EnergyPlus { Real64 Power; // Heating rate required to meet the mixed water temperature (W) Real64 Energy; // Heating energy required to meet the mixed water temperature (J) - // Default Constructor WaterEquipmentType() : Connections(0), PeakVolFlowRate(0.0), FlowRateFracSchedule(0), ColdVolFlowRate(0.0), HotVolFlowRate(0.0), TotalVolFlowRate(0.0), ColdMassFlowRate(0.0), HotMassFlowRate(0.0), TotalMassFlowRate(0.0), DrainMassFlowRate(0.0), ColdTempSchedule(0), HotTempSchedule(0), @@ -150,7 +141,6 @@ namespace EnergyPlus { struct WaterConnectionsType { - // Members std::string Name; // Name of DHW bool Init; // Flag for initialization: TRUE means do the init bool InitSizing; // Flag for initialization of plant sizing @@ -210,7 +200,6 @@ namespace EnergyPlus { int PlantLoopBranchNum; int PlantLoopCompNum; - // Default Constructor WaterConnectionsType() : Init(true), InitSizing(true), StandAlone(false), InletNode(0), OutletNode(0), SupplyTankNum(0), RecoveryTankNum(0), TankDemandID(0), TankSupplyID(0), HeatRecovery(false), HeatRecoveryHX(HeatRecoveryHX::Ideal), HeatRecoveryConfig(HeatRecoveryConfig::Plant), HXUA(0.0), @@ -225,18 +214,11 @@ namespace EnergyPlus { } }; - // Object Data - extern Array1D WaterEquipment; - extern Array1D WaterConnections; - - // Functions - void clear_state(); void SimulateWaterUse(bool FirstHVACIteration); - void SimulateWaterUseConnection( - int EquipTypeNum, std::string &CompName, int &CompIndex, bool InitLoopEquip, bool FirstHVACIteration); + void SimulateWaterUseConnection(int EquipTypeNum, std::string &CompName, int &CompIndex, bool InitLoopEquip, bool FirstHVACIteration); void GetWaterUseInput(); @@ -260,6 +242,10 @@ namespace EnergyPlus { void CalcWaterUseZoneGains(); + extern Array1D WaterEquipment; + + extern Array1D WaterConnections; + } // namespace WaterUse } // namespace EnergyPlus From e660c6642737ad3d53331453b3bccccc8d50a368 Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Tue, 12 Nov 2019 14:35:43 -0700 Subject: [PATCH 35/51] partial functions to members --- src/EnergyPlus/WaterUse.cc | 258 ++++++++++++++++++------------------- src/EnergyPlus/WaterUse.hh | 12 +- 2 files changed, 135 insertions(+), 135 deletions(-) diff --git a/src/EnergyPlus/WaterUse.cc b/src/EnergyPlus/WaterUse.cc index cfbc114800b..e72098ece2f 100644 --- a/src/EnergyPlus/WaterUse.cc +++ b/src/EnergyPlus/WaterUse.cc @@ -159,8 +159,8 @@ namespace EnergyPlus { // Simulate all unconnected WATER USE EQUIPMENT objects for (WaterEquipNum = 1; WaterEquipNum <= numWaterEquipment; ++WaterEquipNum) { if (WaterEquipment(WaterEquipNum).Connections == 0) { - CalcEquipmentFlowRates(WaterEquipNum); - CalcEquipmentDrainTemp(WaterEquipNum); + WaterEquipment(WaterEquipNum).CalcEquipmentFlowRates(); + WaterEquipment(WaterEquipNum).CalcEquipmentDrainTemp(); } } // WaterEquipNum @@ -171,7 +171,7 @@ namespace EnergyPlus { if (!WaterConnections(WaterConnNum).StandAlone) continue; // only model non plant connections here - InitConnections(WaterConnNum); + WaterConnections(WaterConnNum).InitConnections(WaterConnNum); NumIteration = 0; @@ -279,7 +279,7 @@ namespace EnergyPlus { if (!DataGlobals::BeginEnvrnFlag) MyEnvrnFlag = true; - InitConnections(WaterConnNum); + WaterConnections(WaterConnNum).InitConnections(WaterConnNum); int NumIteration = 0; @@ -1002,7 +1002,7 @@ namespace EnergyPlus { } // WaterConnNum } - void CalcEquipmentFlowRates(int WaterEquipNum) + void WaterEquipmentType::CalcEquipmentFlowRates() { // SUBROUTINE INFORMATION: @@ -1014,97 +1014,97 @@ namespace EnergyPlus { // PURPOSE OF THIS SUBROUTINE: // Calculate desired hot and cold water flow rates - if (WaterEquipment(WaterEquipNum).Connections > 0) { + if (this->Connections > 0) { // Get water temperature conditions from the CONNECTIONS object - WaterEquipment(WaterEquipNum).ColdTemp = WaterConnections(WaterEquipment(WaterEquipNum).Connections).ColdTemp; - WaterEquipment(WaterEquipNum).HotTemp = WaterConnections(WaterEquipment(WaterEquipNum).Connections).HotTemp; + this->ColdTemp = WaterConnections(this->Connections).ColdTemp; + this->HotTemp = WaterConnections(this->Connections).HotTemp; } else { // Get water temperature conditions from the WATER USE EQUIPMENT schedules - if (WaterEquipment(WaterEquipNum).ColdTempSchedule > 0) { - WaterEquipment(WaterEquipNum).ColdTemp = ScheduleManager::GetCurrentScheduleValue(WaterEquipment(WaterEquipNum).ColdTempSchedule); + if (this->ColdTempSchedule > 0) { + this->ColdTemp = ScheduleManager::GetCurrentScheduleValue(this->ColdTempSchedule); } else { // If no ColdTempSchedule, use the mains temperature - WaterEquipment(WaterEquipNum).ColdTemp = DataEnvironment::WaterMainsTemp; + this->ColdTemp = DataEnvironment::WaterMainsTemp; } - if (WaterEquipment(WaterEquipNum).HotTempSchedule > 0) { - WaterEquipment(WaterEquipNum).HotTemp = ScheduleManager::GetCurrentScheduleValue(WaterEquipment(WaterEquipNum).HotTempSchedule); + if (this->HotTempSchedule > 0) { + this->HotTemp = ScheduleManager::GetCurrentScheduleValue(this->HotTempSchedule); } else { // If no HotTempSchedule, use all cold water - WaterEquipment(WaterEquipNum).HotTemp = WaterEquipment(WaterEquipNum).ColdTemp; + this->HotTemp = this->ColdTemp; } } - if (WaterEquipment(WaterEquipNum).TargetTempSchedule > 0) { - WaterEquipment(WaterEquipNum).TargetTemp = ScheduleManager::GetCurrentScheduleValue(WaterEquipment(WaterEquipNum).TargetTempSchedule); + if (this->TargetTempSchedule > 0) { + this->TargetTemp = ScheduleManager::GetCurrentScheduleValue(this->TargetTempSchedule); } else { // If no TargetTempSchedule, use all hot water - WaterEquipment(WaterEquipNum).TargetTemp = WaterEquipment(WaterEquipNum).HotTemp; + this->TargetTemp = this->HotTemp; } // Get the requested total flow rate // 11-17-2006 BG Added multipliers in next block - if (WaterEquipment(WaterEquipNum).Zone > 0) { - if (WaterEquipment(WaterEquipNum).FlowRateFracSchedule > 0) { - WaterEquipment(WaterEquipNum).TotalVolFlowRate = - WaterEquipment(WaterEquipNum).PeakVolFlowRate * - ScheduleManager::GetCurrentScheduleValue(WaterEquipment(WaterEquipNum).FlowRateFracSchedule) * - DataHeatBalance::Zone(WaterEquipment(WaterEquipNum).Zone).Multiplier * DataHeatBalance::Zone(WaterEquipment(WaterEquipNum).Zone).ListMultiplier; + if (this->Zone > 0) { + if (this->FlowRateFracSchedule > 0) { + this->TotalVolFlowRate = + this->PeakVolFlowRate * + ScheduleManager::GetCurrentScheduleValue(this->FlowRateFracSchedule) * + DataHeatBalance::Zone(this->Zone).Multiplier * DataHeatBalance::Zone(this->Zone).ListMultiplier; } else { - WaterEquipment(WaterEquipNum).TotalVolFlowRate = WaterEquipment(WaterEquipNum).PeakVolFlowRate * - DataHeatBalance::Zone(WaterEquipment(WaterEquipNum).Zone).Multiplier * - DataHeatBalance::Zone(WaterEquipment(WaterEquipNum).Zone).ListMultiplier; + this->TotalVolFlowRate = this->PeakVolFlowRate * + DataHeatBalance::Zone(this->Zone).Multiplier * + DataHeatBalance::Zone(this->Zone).ListMultiplier; } } else { - if (WaterEquipment(WaterEquipNum).FlowRateFracSchedule > 0) { - WaterEquipment(WaterEquipNum).TotalVolFlowRate = - WaterEquipment(WaterEquipNum).PeakVolFlowRate * - ScheduleManager::GetCurrentScheduleValue(WaterEquipment(WaterEquipNum).FlowRateFracSchedule); + if (this->FlowRateFracSchedule > 0) { + this->TotalVolFlowRate = + this->PeakVolFlowRate * + ScheduleManager::GetCurrentScheduleValue(this->FlowRateFracSchedule); } else { - WaterEquipment(WaterEquipNum).TotalVolFlowRate = WaterEquipment(WaterEquipNum).PeakVolFlowRate; + this->TotalVolFlowRate = this->PeakVolFlowRate; } } - WaterEquipment(WaterEquipNum).TotalMassFlowRate = - WaterEquipment(WaterEquipNum).TotalVolFlowRate * Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); + this->TotalMassFlowRate = + this->TotalVolFlowRate * Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); // Calculate hot and cold water mixing at the tap - if (WaterEquipment(WaterEquipNum).TotalMassFlowRate > 0.0) { + if (this->TotalMassFlowRate > 0.0) { // Calculate the flow rates needed to meet the target temperature - if (WaterEquipment(WaterEquipNum).HotTemp == WaterEquipment(WaterEquipNum).ColdTemp) { // Avoid divide by zero + if (this->HotTemp == this->ColdTemp) { // Avoid divide by zero // There is no hot water - WaterEquipment(WaterEquipNum).HotMassFlowRate = 0.0; + this->HotMassFlowRate = 0.0; // Need a special case for HotTemp < ColdTemp, due to bad user input (but could happen in a plant loop accidentally) - } else if (WaterEquipment(WaterEquipNum).TargetTemp > WaterEquipment(WaterEquipNum).HotTemp) { - WaterEquipment(WaterEquipNum).HotMassFlowRate = WaterEquipment(WaterEquipNum).TotalMassFlowRate; + } else if (this->TargetTemp > this->HotTemp) { + this->HotMassFlowRate = this->TotalMassFlowRate; } else { - WaterEquipment(WaterEquipNum).HotMassFlowRate = WaterEquipment(WaterEquipNum).TotalMassFlowRate * - (WaterEquipment(WaterEquipNum).TargetTemp - WaterEquipment(WaterEquipNum).ColdTemp) / - (WaterEquipment(WaterEquipNum).HotTemp - WaterEquipment(WaterEquipNum).ColdTemp); + this->HotMassFlowRate = this->TotalMassFlowRate * + (this->TargetTemp - this->ColdTemp) / + (this->HotTemp - this->ColdTemp); } - if (WaterEquipment(WaterEquipNum).HotMassFlowRate < 0.0) { + if (this->HotMassFlowRate < 0.0) { // Target temp is colder than the cold water temp; don't allow colder - WaterEquipment(WaterEquipNum).HotMassFlowRate = 0.0; + this->HotMassFlowRate = 0.0; } - WaterEquipment(WaterEquipNum).ColdMassFlowRate = - WaterEquipment(WaterEquipNum).TotalMassFlowRate - WaterEquipment(WaterEquipNum).HotMassFlowRate; + this->ColdMassFlowRate = + this->TotalMassFlowRate - this->HotMassFlowRate; - if (WaterEquipment(WaterEquipNum).ColdMassFlowRate < 0.0) WaterEquipment(WaterEquipNum).ColdMassFlowRate = 0.0; + if (this->ColdMassFlowRate < 0.0) this->ColdMassFlowRate = 0.0; - WaterEquipment(WaterEquipNum).MixedTemp = (WaterEquipment(WaterEquipNum).ColdMassFlowRate * WaterEquipment(WaterEquipNum).ColdTemp + - WaterEquipment(WaterEquipNum).HotMassFlowRate * WaterEquipment(WaterEquipNum).HotTemp) / - WaterEquipment(WaterEquipNum).TotalMassFlowRate; + this->MixedTemp = (this->ColdMassFlowRate * this->ColdTemp + + this->HotMassFlowRate * this->HotTemp) / + this->TotalMassFlowRate; } else { - WaterEquipment(WaterEquipNum).HotMassFlowRate = 0.0; - WaterEquipment(WaterEquipNum).ColdMassFlowRate = 0.0; - WaterEquipment(WaterEquipNum).MixedTemp = WaterEquipment(WaterEquipNum).TargetTemp; + this->HotMassFlowRate = 0.0; + this->ColdMassFlowRate = 0.0; + this->MixedTemp = this->TargetTemp; } } - void CalcEquipmentDrainTemp(int WaterEquipNum) + void WaterEquipmentType::CalcEquipmentDrainTemp() { // SUBROUTINE INFORMATION: @@ -1118,67 +1118,67 @@ namespace EnergyPlus { static std::string const RoutineName("CalcEquipmentDrainTemp"); - WaterEquipment(WaterEquipNum).SensibleRate = 0.0; - WaterEquipment(WaterEquipNum).SensibleEnergy = 0.0; - WaterEquipment(WaterEquipNum).LatentRate = 0.0; - WaterEquipment(WaterEquipNum).LatentEnergy = 0.0; + this->SensibleRate = 0.0; + this->SensibleEnergy = 0.0; + this->LatentRate = 0.0; + this->LatentEnergy = 0.0; - if ((WaterEquipment(WaterEquipNum).Zone == 0) || (WaterEquipment(WaterEquipNum).TotalMassFlowRate == 0.0)) { - WaterEquipment(WaterEquipNum).DrainTemp = WaterEquipment(WaterEquipNum).MixedTemp; - WaterEquipment(WaterEquipNum).DrainMassFlowRate = WaterEquipment(WaterEquipNum).TotalMassFlowRate; + if ((this->Zone == 0) || (this->TotalMassFlowRate == 0.0)) { + this->DrainTemp = this->MixedTemp; + this->DrainMassFlowRate = this->TotalMassFlowRate; } else { - if (WaterEquipment(WaterEquipNum).SensibleFracSchedule == 0) { - WaterEquipment(WaterEquipNum).SensibleRate = 0.0; - WaterEquipment(WaterEquipNum).SensibleEnergy = 0.0; + if (this->SensibleFracSchedule == 0) { + this->SensibleRate = 0.0; + this->SensibleEnergy = 0.0; } else { - WaterEquipment(WaterEquipNum).SensibleRate = - ScheduleManager::GetCurrentScheduleValue(WaterEquipment(WaterEquipNum).SensibleFracSchedule) * - WaterEquipment(WaterEquipNum).TotalMassFlowRate * + this->SensibleRate = + ScheduleManager::GetCurrentScheduleValue(this->SensibleFracSchedule) * + this->TotalMassFlowRate * Psychrometrics::CPHW(DataGlobals::InitConvTemp) * - (WaterEquipment(WaterEquipNum).MixedTemp - DataHeatBalFanSys::MAT(WaterEquipment(WaterEquipNum).Zone)); - WaterEquipment(WaterEquipNum).SensibleEnergy = - WaterEquipment(WaterEquipNum).SensibleRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + (this->MixedTemp - DataHeatBalFanSys::MAT(this->Zone)); + this->SensibleEnergy = + this->SensibleRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; } - if (WaterEquipment(WaterEquipNum).LatentFracSchedule == 0) { - WaterEquipment(WaterEquipNum).LatentRate = 0.0; - WaterEquipment(WaterEquipNum).LatentEnergy = 0.0; + if (this->LatentFracSchedule == 0) { + this->LatentRate = 0.0; + this->LatentEnergy = 0.0; } else { - Real64 ZoneHumRat = DataHeatBalFanSys::ZoneAirHumRat(WaterEquipment(WaterEquipNum).Zone); - Real64 ZoneHumRatSat = Psychrometrics::PsyWFnTdbRhPb(DataHeatBalFanSys::MAT(WaterEquipment(WaterEquipNum).Zone), 1.0, DataEnvironment::OutBaroPress, RoutineName); // Humidratio at 100% relative humidity - Real64 RhoAirDry = Psychrometrics::PsyRhoAirFnPbTdbW(DataEnvironment::OutBaroPress, DataHeatBalFanSys::MAT(WaterEquipment(WaterEquipNum).Zone), 0.0); - Real64 ZoneMassMax = (ZoneHumRatSat - ZoneHumRat) * RhoAirDry * DataHeatBalance::Zone(WaterEquipment(WaterEquipNum).Zone).Volume; // Max water that can be evaporated to zone - Real64 FlowMassMax = WaterEquipment(WaterEquipNum).TotalMassFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; // Max water in flow + Real64 ZoneHumRat = DataHeatBalFanSys::ZoneAirHumRat(this->Zone); + Real64 ZoneHumRatSat = Psychrometrics::PsyWFnTdbRhPb(DataHeatBalFanSys::MAT(this->Zone), 1.0, DataEnvironment::OutBaroPress, RoutineName); // Humidratio at 100% relative humidity + Real64 RhoAirDry = Psychrometrics::PsyRhoAirFnPbTdbW(DataEnvironment::OutBaroPress, DataHeatBalFanSys::MAT(this->Zone), 0.0); + Real64 ZoneMassMax = (ZoneHumRatSat - ZoneHumRat) * RhoAirDry * DataHeatBalance::Zone(this->Zone).Volume; // Max water that can be evaporated to zone + Real64 FlowMassMax = this->TotalMassFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; // Max water in flow Real64 MoistureMassMax = min(ZoneMassMax, FlowMassMax); - WaterEquipment(WaterEquipNum).MoistureMass = ScheduleManager::GetCurrentScheduleValue(WaterEquipment(WaterEquipNum).LatentFracSchedule) * MoistureMassMax; - WaterEquipment(WaterEquipNum).MoistureRate = - WaterEquipment(WaterEquipNum).MoistureMass / (DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour); + this->MoistureMass = ScheduleManager::GetCurrentScheduleValue(this->LatentFracSchedule) * MoistureMassMax; + this->MoistureRate = + this->MoistureMass / (DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour); - WaterEquipment(WaterEquipNum).LatentRate = - WaterEquipment(WaterEquipNum).MoistureRate * Psychrometrics::PsyHfgAirFnWTdb(ZoneHumRat, DataHeatBalFanSys::MAT(WaterEquipment(WaterEquipNum).Zone)); - WaterEquipment(WaterEquipNum).LatentEnergy = - WaterEquipment(WaterEquipNum).LatentRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + this->LatentRate = + this->MoistureRate * Psychrometrics::PsyHfgAirFnWTdb(ZoneHumRat, DataHeatBalFanSys::MAT(this->Zone)); + this->LatentEnergy = + this->LatentRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; } - WaterEquipment(WaterEquipNum).DrainMassFlowRate = - WaterEquipment(WaterEquipNum).TotalMassFlowRate - WaterEquipment(WaterEquipNum).MoistureRate; + this->DrainMassFlowRate = + this->TotalMassFlowRate - this->MoistureRate; - if (WaterEquipment(WaterEquipNum).DrainMassFlowRate == 0.0) { - WaterEquipment(WaterEquipNum).DrainTemp = WaterEquipment(WaterEquipNum).MixedTemp; + if (this->DrainMassFlowRate == 0.0) { + this->DrainTemp = this->MixedTemp; } else { - WaterEquipment(WaterEquipNum).DrainTemp = - (WaterEquipment(WaterEquipNum).TotalMassFlowRate * Psychrometrics::CPHW(DataGlobals::InitConvTemp) * - WaterEquipment(WaterEquipNum).MixedTemp - - WaterEquipment(WaterEquipNum).SensibleRate - WaterEquipment(WaterEquipNum).LatentRate) / - (WaterEquipment(WaterEquipNum).DrainMassFlowRate * Psychrometrics::CPHW(DataGlobals::InitConvTemp)); + this->DrainTemp = + (this->TotalMassFlowRate * Psychrometrics::CPHW(DataGlobals::InitConvTemp) * + this->MixedTemp - + this->SensibleRate - this->LatentRate) / + (this->DrainMassFlowRate * Psychrometrics::CPHW(DataGlobals::InitConvTemp)); } } } - void InitConnections(int WaterConnNum) + void WaterConnectionsType::InitConnections(int WaterConnNum) { // SUBROUTINE INFORMATION: @@ -1198,14 +1198,14 @@ namespace EnergyPlus { } if (SetLoopIndexFlag(WaterConnNum)) { - if (allocated(DataPlant::PlantLoop) && !WaterConnections(WaterConnNum).StandAlone) { + if (allocated(DataPlant::PlantLoop) && !this->StandAlone) { bool errFlag = false; - PlantUtilities::ScanPlantLoopsForObject(WaterConnections(WaterConnNum).Name, + PlantUtilities::ScanPlantLoopsForObject(this->Name, DataPlant::TypeOf_WaterUseConnection, - WaterConnections(WaterConnNum).PlantLoopNum, - WaterConnections(WaterConnNum).PlantLoopSide, - WaterConnections(WaterConnNum).PlantLoopBranchNum, - WaterConnections(WaterConnNum).PlantLoopCompNum, + this->PlantLoopNum, + this->PlantLoopSide, + this->PlantLoopBranchNum, + this->PlantLoopCompNum, errFlag, _, _, @@ -1217,61 +1217,61 @@ namespace EnergyPlus { } SetLoopIndexFlag(WaterConnNum) = false; } - if (WaterConnections(WaterConnNum).StandAlone) SetLoopIndexFlag(WaterConnNum) = false; + if (this->StandAlone) SetLoopIndexFlag(WaterConnNum) = false; } // Set the cold water temperature - if (WaterConnections(WaterConnNum).SupplyTankNum > 0) { - WaterConnections(WaterConnNum).ColdSupplyTemp = DataWater::WaterStorage(WaterConnections(WaterConnNum).SupplyTankNum).Twater; + if (this->SupplyTankNum > 0) { + this->ColdSupplyTemp = DataWater::WaterStorage(this->SupplyTankNum).Twater; - } else if (WaterConnections(WaterConnNum).ColdTempSchedule > 0) { - WaterConnections(WaterConnNum).ColdSupplyTemp = ScheduleManager::GetCurrentScheduleValue(WaterConnections(WaterConnNum).ColdTempSchedule); + } else if (this->ColdTempSchedule > 0) { + this->ColdSupplyTemp = ScheduleManager::GetCurrentScheduleValue(this->ColdTempSchedule); } else { - WaterConnections(WaterConnNum).ColdSupplyTemp = DataEnvironment::WaterMainsTemp; + this->ColdSupplyTemp = DataEnvironment::WaterMainsTemp; } // Initially set ColdTemp to the ColdSupplyTemp; with heat recovery, ColdTemp will change during iteration - WaterConnections(WaterConnNum).ColdTemp = WaterConnections(WaterConnNum).ColdSupplyTemp; + this->ColdTemp = this->ColdSupplyTemp; // Set the hot water temperature - if (WaterConnections(WaterConnNum).StandAlone) { - if (WaterConnections(WaterConnNum).HotTempSchedule > 0) { - WaterConnections(WaterConnNum).HotTemp = ScheduleManager::GetCurrentScheduleValue(WaterConnections(WaterConnNum).HotTempSchedule); + if (this->StandAlone) { + if (this->HotTempSchedule > 0) { + this->HotTemp = ScheduleManager::GetCurrentScheduleValue(this->HotTempSchedule); } else { // If no HotTempSchedule, use all cold water - WaterConnections(WaterConnNum).HotTemp = WaterConnections(WaterConnNum).ColdTemp; + this->HotTemp = this->ColdTemp; } } else { - if (DataGlobals::BeginEnvrnFlag && WaterConnections(WaterConnNum).Init) { + if (DataGlobals::BeginEnvrnFlag && this->Init) { // Clear node initial conditions - if (WaterConnections(WaterConnNum).InletNode > 0 && WaterConnections(WaterConnNum).OutletNode > 0) { + if (this->InletNode > 0 && this->OutletNode > 0) { PlantUtilities::InitComponentNodes(0.0, - WaterConnections(WaterConnNum).PeakMassFlowRate, - WaterConnections(WaterConnNum).InletNode, - WaterConnections(WaterConnNum).OutletNode, - WaterConnections(WaterConnNum).PlantLoopNum, - WaterConnections(WaterConnNum).PlantLoopSide, - WaterConnections(WaterConnNum).PlantLoopBranchNum, - WaterConnections(WaterConnNum).PlantLoopCompNum); - - WaterConnections(WaterConnNum).ReturnTemp = DataLoopNode::Node(WaterConnections(WaterConnNum).InletNode).Temp; + this->PeakMassFlowRate, + this->InletNode, + this->OutletNode, + this->PlantLoopNum, + this->PlantLoopSide, + this->PlantLoopBranchNum, + this->PlantLoopCompNum); + + this->ReturnTemp = DataLoopNode::Node(this->InletNode).Temp; } - WaterConnections(WaterConnNum).Init = false; + this->Init = false; } - if (!DataGlobals::BeginEnvrnFlag) WaterConnections(WaterConnNum).Init = true; + if (!DataGlobals::BeginEnvrnFlag) this->Init = true; - if (WaterConnections(WaterConnNum).InletNode > 0) { + if (this->InletNode > 0) { if (!DataGlobals::DoingSizing) { - WaterConnections(WaterConnNum).HotTemp = DataLoopNode::Node(WaterConnections(WaterConnNum).InletNode).Temp; + this->HotTemp = DataLoopNode::Node(this->InletNode).Temp; } else { // plant loop will not be running so need a value here. // should change to use tank setpoint but water use connections don't have knowledge of the tank they are fed by - WaterConnections(WaterConnNum).HotTemp = 60.0; + this->HotTemp = 60.0; } } } @@ -1295,7 +1295,7 @@ namespace EnergyPlus { for (int Loop = 1; Loop <= WaterConnections(WaterConnNum).NumWaterEquipment; ++Loop) { int WaterEquipNum = WaterConnections(WaterConnNum).WaterEquipment(Loop); - CalcEquipmentFlowRates(WaterEquipNum); + WaterEquipment(WaterEquipNum).CalcEquipmentFlowRates(); WaterConnections(WaterConnNum).ColdMassFlowRate += WaterEquipment(WaterEquipNum).ColdMassFlowRate; WaterConnections(WaterConnNum).HotMassFlowRate += WaterEquipment(WaterEquipNum).HotMassFlowRate; @@ -1391,7 +1391,7 @@ namespace EnergyPlus { for (int Loop = 1; Loop <= WaterConnections(WaterConnNum).NumWaterEquipment; ++Loop) { int WaterEquipNum = WaterConnections(WaterConnNum).WaterEquipment(Loop); - CalcEquipmentDrainTemp(WaterEquipNum); + WaterEquipment(WaterEquipNum).CalcEquipmentDrainTemp(); WaterConnections(WaterConnNum).DrainMassFlowRate += WaterEquipment(WaterEquipNum).DrainMassFlowRate; MassFlowTempSum += WaterEquipment(WaterEquipNum).DrainMassFlowRate * WaterEquipment(WaterEquipNum).DrainTemp; diff --git a/src/EnergyPlus/WaterUse.hh b/src/EnergyPlus/WaterUse.hh index f90152b3004..8c681d730ce 100644 --- a/src/EnergyPlus/WaterUse.hh +++ b/src/EnergyPlus/WaterUse.hh @@ -137,6 +137,10 @@ namespace EnergyPlus { TotalMassFlowRate = 0.0; DrainTemp = 0.0; } + + void CalcEquipmentFlowRates(); + + void CalcEquipmentDrainTemp(); }; struct WaterConnectionsType @@ -212,6 +216,8 @@ namespace EnergyPlus { PlantLoopNum(0), PlantLoopSide(0), PlantLoopBranchNum(0), PlantLoopCompNum(0) { } + + void InitConnections(int WaterConnNum); }; void clear_state(); @@ -222,12 +228,6 @@ namespace EnergyPlus { void GetWaterUseInput(); - void CalcEquipmentFlowRates(int WaterEquipNum); - - void CalcEquipmentDrainTemp(int WaterEquipNum); - - void InitConnections(int WaterConnNum); - void CalcConnectionsFlowRates(int WaterConnNum, bool FirstHVACIteration); void CalcConnectionsDrainTemp(int WaterConnNum); From a44b7ed858c76b4f638b945be091af8ecd5960ed Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Wed, 13 Nov 2019 08:20:58 -0700 Subject: [PATCH 36/51] fix errors --- src/EnergyPlus/WaterUse.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/EnergyPlus/WaterUse.cc b/src/EnergyPlus/WaterUse.cc index e72098ece2f..922b3f7378f 100644 --- a/src/EnergyPlus/WaterUse.cc +++ b/src/EnergyPlus/WaterUse.cc @@ -125,7 +125,7 @@ namespace EnergyPlus { int WaterEquipNum; int WaterConnNum; int NumIteration; - bool MyEnvrnFlag(true); + static bool MyEnvrnFlag(true); // FLOW: if (getWaterUseInputFlag) { @@ -229,7 +229,7 @@ namespace EnergyPlus { // SUBROUTINE LOCAL VARIABLE DECLARATIONS: // INTEGER :: WaterEquipNum int WaterConnNum; - bool MyEnvrnFlag(true); + static bool MyEnvrnFlag(true); // FLOW: if (getWaterUseInputFlag) { From 7fcb606290f556735cad817eb643bf8a76cfce5e Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Wed, 13 Nov 2019 09:16:47 -0700 Subject: [PATCH 37/51] functions to members --- src/EnergyPlus/WaterUse.cc | 299 ++++++++++++++++--------------------- src/EnergyPlus/WaterUse.hh | 22 +-- 2 files changed, 141 insertions(+), 180 deletions(-) diff --git a/src/EnergyPlus/WaterUse.cc b/src/EnergyPlus/WaterUse.cc index 922b3f7378f..0c59ea5f6dc 100644 --- a/src/EnergyPlus/WaterUse.cc +++ b/src/EnergyPlus/WaterUse.cc @@ -178,9 +178,9 @@ namespace EnergyPlus { while (true) { ++NumIteration; - CalcConnectionsFlowRates(WaterConnNum, FirstHVACIteration); - CalcConnectionsDrainTemp(WaterConnNum); - CalcConnectionsHeatRecovery(WaterConnNum); + WaterConnections(WaterConnNum).CalcConnectionsFlowRates(FirstHVACIteration); + WaterConnections(WaterConnNum).CalcConnectionsDrainTemp(); + WaterConnections(WaterConnNum).CalcConnectionsHeatRecovery(); if (WaterConnections(WaterConnNum).TempError < Tolerance) { break; @@ -200,9 +200,8 @@ namespace EnergyPlus { } // WHILE - UpdateWaterConnections(WaterConnNum); - - ReportWaterUse(WaterConnNum); + WaterConnections(WaterConnNum).UpdateWaterConnections(); + WaterConnections(WaterConnNum).ReportWaterUse(); } // WaterConnNum } @@ -286,9 +285,9 @@ namespace EnergyPlus { while (true) { ++NumIteration; - CalcConnectionsFlowRates(WaterConnNum, FirstHVACIteration); - CalcConnectionsDrainTemp(WaterConnNum); - CalcConnectionsHeatRecovery(WaterConnNum); + WaterConnections(WaterConnNum).CalcConnectionsFlowRates(FirstHVACIteration); + WaterConnections(WaterConnNum).CalcConnectionsDrainTemp(); + WaterConnections(WaterConnNum).CalcConnectionsHeatRecovery(); if (WaterConnections(WaterConnNum).TempError < Tolerance) { break; @@ -308,9 +307,8 @@ namespace EnergyPlus { } // WHILE - UpdateWaterConnections(WaterConnNum); - - ReportWaterUse(WaterConnNum); + WaterConnections(WaterConnNum).UpdateWaterConnections(); + WaterConnections(WaterConnNum).ReportWaterUse(); } void GetWaterUseInput() @@ -562,7 +560,7 @@ namespace EnergyPlus { WaterConnections(WaterConnNum).HXUA = DataIPShortCuts::rNumericArgs(1); - WaterConnections(WaterConnNum).WaterEquipment.allocate(NumAlphas - 9); + WaterConnections(WaterConnNum).myWaterEquipArr.allocate(NumAlphas - 9); for (AlphaNum = 10; AlphaNum <= NumAlphas; ++AlphaNum) { int WaterEquipNum = UtilityRoutines::FindItemInList(DataIPShortCuts::cAlphaArgs(AlphaNum), WaterEquipment); @@ -582,7 +580,7 @@ namespace EnergyPlus { WaterEquipment(WaterEquipNum).Connections = WaterConnNum; ++WaterConnections(WaterConnNum).NumWaterEquipment; - WaterConnections(WaterConnNum).WaterEquipment(WaterConnections(WaterConnNum).NumWaterEquipment) = WaterEquipNum; + WaterConnections(WaterConnNum).myWaterEquipArr(WaterConnections(WaterConnNum).NumWaterEquipment) = WaterEquipNum; WaterConnections(WaterConnNum).PeakVolFlowRate += WaterEquipment(WaterEquipNum).PeakVolFlowRate; // this does not include possible multipliers @@ -605,7 +603,7 @@ namespace EnergyPlus { for (int WaterConnNum = 1; WaterConnNum <= numWaterConnections; ++WaterConnNum) { WaterConnections(WaterConnNum).PeakMassFlowRate = 0.0; for (int WaterEquipNum = 1; WaterEquipNum <= WaterConnections(WaterConnNum).NumWaterEquipment; ++WaterEquipNum) { - int thisWaterEquipNum = WaterConnections(WaterConnNum).WaterEquipment(WaterEquipNum); + int thisWaterEquipNum = WaterConnections(WaterConnNum).myWaterEquipArr(WaterEquipNum); if (WaterEquipment(thisWaterEquipNum).Zone > 0) { WaterConnections(WaterConnNum).PeakMassFlowRate += WaterEquipment(thisWaterEquipNum).PeakVolFlowRate * Psychrometrics::RhoH2O(DataGlobals::InitConvTemp) * @@ -1277,7 +1275,7 @@ namespace EnergyPlus { } } - void CalcConnectionsFlowRates(int WaterConnNum, bool FirstHVACIteration) + void WaterConnectionsType::CalcConnectionsFlowRates(bool FirstHVACIteration) { // SUBROUTINE INFORMATION: @@ -1289,60 +1287,59 @@ namespace EnergyPlus { // PURPOSE OF THIS SUBROUTINE: // Calculate summed values for WATER USE CONNECTIONS (to prepare to request flow from plant, and for reporting). - WaterConnections(WaterConnNum).ColdMassFlowRate = 0.0; - WaterConnections(WaterConnNum).HotMassFlowRate = 0.0; + this->ColdMassFlowRate = 0.0; + this->HotMassFlowRate = 0.0; - for (int Loop = 1; Loop <= WaterConnections(WaterConnNum).NumWaterEquipment; ++Loop) { - int WaterEquipNum = WaterConnections(WaterConnNum).WaterEquipment(Loop); + for (int Loop = 1; Loop <= this->NumWaterEquipment; ++Loop) { + int WaterEquipNum = this->myWaterEquipArr(Loop); WaterEquipment(WaterEquipNum).CalcEquipmentFlowRates(); - WaterConnections(WaterConnNum).ColdMassFlowRate += WaterEquipment(WaterEquipNum).ColdMassFlowRate; - WaterConnections(WaterConnNum).HotMassFlowRate += WaterEquipment(WaterEquipNum).HotMassFlowRate; + this->ColdMassFlowRate += WaterEquipment(WaterEquipNum).ColdMassFlowRate; + this->HotMassFlowRate += WaterEquipment(WaterEquipNum).HotMassFlowRate; } // Loop - WaterConnections(WaterConnNum).TotalMassFlowRate = - WaterConnections(WaterConnNum).ColdMassFlowRate + WaterConnections(WaterConnNum).HotMassFlowRate; + this->TotalMassFlowRate = + this->ColdMassFlowRate + this->HotMassFlowRate; - if (!WaterConnections(WaterConnNum).StandAlone) { // Interact with the plant loop - if (WaterConnections(WaterConnNum).InletNode > 0) { + if (!this->StandAlone) { // Interact with the plant loop + if (this->InletNode > 0) { if (FirstHVACIteration) { // Request the mass flow rate from the demand side manager - PlantUtilities::SetComponentFlowRate(WaterConnections(WaterConnNum).HotMassFlowRate, - WaterConnections(WaterConnNum).InletNode, - WaterConnections(WaterConnNum).OutletNode, - WaterConnections(WaterConnNum).PlantLoopNum, - WaterConnections(WaterConnNum).PlantLoopSide, - WaterConnections(WaterConnNum).PlantLoopBranchNum, - WaterConnections(WaterConnNum).PlantLoopCompNum); + PlantUtilities::SetComponentFlowRate(this->HotMassFlowRate, + this->InletNode, + this->OutletNode, + this->PlantLoopNum, + this->PlantLoopSide, + this->PlantLoopBranchNum, + this->PlantLoopCompNum); } else { - Real64 DesiredHotWaterMassFlow = WaterConnections(WaterConnNum).HotMassFlowRate; + Real64 DesiredHotWaterMassFlow = this->HotMassFlowRate; PlantUtilities::SetComponentFlowRate(DesiredHotWaterMassFlow, - WaterConnections(WaterConnNum).InletNode, - WaterConnections(WaterConnNum).OutletNode, - WaterConnections(WaterConnNum).PlantLoopNum, - WaterConnections(WaterConnNum).PlantLoopSide, - WaterConnections(WaterConnNum).PlantLoopBranchNum, - WaterConnections(WaterConnNum).PlantLoopCompNum); + this->InletNode, + this->OutletNode, + this->PlantLoopNum, + this->PlantLoopSide, + this->PlantLoopBranchNum, + this->PlantLoopCompNum); // readjust if more than actual available mass flow rate determined by the demand side manager - if ((WaterConnections(WaterConnNum).HotMassFlowRate != DesiredHotWaterMassFlow) && - (WaterConnections(WaterConnNum).HotMassFlowRate > 0.0)) { // plant didn't give what was asked for + if ((this->HotMassFlowRate != DesiredHotWaterMassFlow) && + (this->HotMassFlowRate > 0.0)) { // plant didn't give what was asked for - Real64 AvailableFraction = DesiredHotWaterMassFlow / WaterConnections(WaterConnNum).HotMassFlowRate; + Real64 AvailableFraction = DesiredHotWaterMassFlow / this->HotMassFlowRate; - WaterConnections(WaterConnNum).ColdMassFlowRate = - WaterConnections(WaterConnNum).TotalMassFlowRate - - WaterConnections(WaterConnNum).HotMassFlowRate; // Preserve the total mass flow rate + this->ColdMassFlowRate = + this->TotalMassFlowRate - + this->HotMassFlowRate; // Preserve the total mass flow rate // Proportionally reduce hot water and increase cold water for all WATER USE EQUIPMENT - for (int Loop = 1; Loop <= WaterConnections(WaterConnNum).NumWaterEquipment; ++Loop) { - int WaterEquipNum = WaterConnections(WaterConnNum).WaterEquipment(Loop); + for (int Loop = 1; Loop <= this->NumWaterEquipment; ++Loop) { + int WaterEquipNum = this->myWaterEquipArr(Loop); // Recalculate flow rates for water equipment within connection WaterEquipment(WaterEquipNum).HotMassFlowRate *= AvailableFraction; - WaterEquipment(WaterEquipNum).ColdMassFlowRate = - WaterEquipment(WaterEquipNum).TotalMassFlowRate - WaterEquipment(WaterEquipNum).HotMassFlowRate; + WaterEquipment(WaterEquipNum).ColdMassFlowRate = WaterEquipment(WaterEquipNum).TotalMassFlowRate - WaterEquipment(WaterEquipNum).HotMassFlowRate; // Recalculate mixed water temperature if (WaterEquipment(WaterEquipNum).TotalMassFlowRate > 0.0) { @@ -1359,24 +1356,21 @@ namespace EnergyPlus { } } - if (WaterConnections(WaterConnNum).SupplyTankNum > 0) { + if (this->SupplyTankNum > 0) { // Set the demand request for supply water from water storage tank - WaterConnections(WaterConnNum).ColdVolFlowRate = - WaterConnections(WaterConnNum).ColdMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); - DataWater::WaterStorage(WaterConnections(WaterConnNum).SupplyTankNum).VdotRequestDemand(WaterConnections(WaterConnNum).TankDemandID) = - WaterConnections(WaterConnNum).ColdVolFlowRate; + this->ColdVolFlowRate = this->ColdMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); + DataWater::WaterStorage(this->SupplyTankNum).VdotRequestDemand(this->TankDemandID) = this->ColdVolFlowRate; // Check if cold flow rate should be starved by restricted flow from tank // Currently, the tank flow is not really starved--water continues to flow at the tank water temperature // But the user can see the error by comparing report variables for TankVolFlowRate < ColdVolFlowRate - WaterConnections(WaterConnNum).TankVolFlowRate = DataWater::WaterStorage(WaterConnections(WaterConnNum).SupplyTankNum) - .VdotAvailDemand(WaterConnections(WaterConnNum).TankDemandID); - WaterConnections(WaterConnNum).TankMassFlowRate = - WaterConnections(WaterConnNum).TankVolFlowRate * Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); + this->TankVolFlowRate = DataWater::WaterStorage(this->SupplyTankNum) + .VdotAvailDemand(this->TankDemandID); + this->TankMassFlowRate = this->TankVolFlowRate * Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); } } - void CalcConnectionsDrainTemp(int WaterConnNum) + void WaterConnectionsType::CalcConnectionsDrainTemp() { // SUBROUTINE INFORMATION: @@ -1386,28 +1380,27 @@ namespace EnergyPlus { // RE-ENGINEERED na Real64 MassFlowTempSum = 0.0; - WaterConnections(WaterConnNum).DrainMassFlowRate = 0.0; + this->DrainMassFlowRate = 0.0; - for (int Loop = 1; Loop <= WaterConnections(WaterConnNum).NumWaterEquipment; ++Loop) { - int WaterEquipNum = WaterConnections(WaterConnNum).WaterEquipment(Loop); + for (int Loop = 1; Loop <= this->NumWaterEquipment; ++Loop) { + int WaterEquipNum = this->myWaterEquipArr(Loop); WaterEquipment(WaterEquipNum).CalcEquipmentDrainTemp(); - WaterConnections(WaterConnNum).DrainMassFlowRate += WaterEquipment(WaterEquipNum).DrainMassFlowRate; + this->DrainMassFlowRate += WaterEquipment(WaterEquipNum).DrainMassFlowRate; MassFlowTempSum += WaterEquipment(WaterEquipNum).DrainMassFlowRate * WaterEquipment(WaterEquipNum).DrainTemp; } // Loop - if (WaterConnections(WaterConnNum).DrainMassFlowRate > 0.0) { - WaterConnections(WaterConnNum).DrainTemp = MassFlowTempSum / WaterConnections(WaterConnNum).DrainMassFlowRate; + if (this->DrainMassFlowRate > 0.0) { + this->DrainTemp = MassFlowTempSum / this->DrainMassFlowRate; } else { - WaterConnections(WaterConnNum).DrainTemp = WaterConnections(WaterConnNum).HotTemp; + this->DrainTemp = this->HotTemp; } - WaterConnections(WaterConnNum).DrainVolFlowRate = - WaterConnections(WaterConnNum).DrainMassFlowRate * Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); + this->DrainVolFlowRate = this->DrainMassFlowRate * Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); } - void CalcConnectionsHeatRecovery(int WaterConnNum) + void WaterConnectionsType::CalcConnectionsHeatRecovery() { // SUBROUTINE INFORMATION: @@ -1419,103 +1412,89 @@ namespace EnergyPlus { // PURPOSE OF THIS SUBROUTINE: // Calculate drainwater heat recovery - if (!WaterConnections(WaterConnNum).HeatRecovery) { - WaterConnections(WaterConnNum).RecoveryTemp = WaterConnections(WaterConnNum).ColdSupplyTemp; - WaterConnections(WaterConnNum).ReturnTemp = WaterConnections(WaterConnNum).ColdSupplyTemp; - WaterConnections(WaterConnNum).WasteTemp = WaterConnections(WaterConnNum).DrainTemp; + if (!this->HeatRecovery) { + this->RecoveryTemp = this->ColdSupplyTemp; + this->ReturnTemp = this->ColdSupplyTemp; + this->WasteTemp = this->DrainTemp; - } else if (WaterConnections(WaterConnNum).TotalMassFlowRate == 0.0) { - WaterConnections(WaterConnNum).Effectiveness = 0.0; - WaterConnections(WaterConnNum).RecoveryRate = 0.0; - WaterConnections(WaterConnNum).RecoveryTemp = WaterConnections(WaterConnNum).ColdSupplyTemp; - WaterConnections(WaterConnNum).ReturnTemp = WaterConnections(WaterConnNum).ColdSupplyTemp; - WaterConnections(WaterConnNum).WasteTemp = WaterConnections(WaterConnNum).DrainTemp; + } else if (this->TotalMassFlowRate == 0.0) { + this->Effectiveness = 0.0; + this->RecoveryRate = 0.0; + this->RecoveryTemp = this->ColdSupplyTemp; + this->ReturnTemp = this->ColdSupplyTemp; + this->WasteTemp = this->DrainTemp; } else { // WaterConnections(WaterConnNum)%TotalMassFlowRate > 0.0 { - auto const SELECT_CASE_var(WaterConnections(WaterConnNum).HeatRecoveryConfig); + auto const SELECT_CASE_var(this->HeatRecoveryConfig); if (SELECT_CASE_var == HeatRecoveryConfig::Plant) { - WaterConnections(WaterConnNum).RecoveryMassFlowRate = WaterConnections(WaterConnNum).HotMassFlowRate; + this->RecoveryMassFlowRate = this->HotMassFlowRate; } else if (SELECT_CASE_var == HeatRecoveryConfig::Equipment) { - WaterConnections(WaterConnNum).RecoveryMassFlowRate = WaterConnections(WaterConnNum).ColdMassFlowRate; + this->RecoveryMassFlowRate = this->ColdMassFlowRate; } else if (SELECT_CASE_var == HeatRecoveryConfig::PlantAndEquip) { - WaterConnections(WaterConnNum).RecoveryMassFlowRate = WaterConnections(WaterConnNum).TotalMassFlowRate; + this->RecoveryMassFlowRate = this->TotalMassFlowRate; } } - Real64 HXCapacityRate = Psychrometrics::CPHW(DataGlobals::InitConvTemp) * WaterConnections(WaterConnNum).RecoveryMassFlowRate; - Real64 DrainCapacityRate = Psychrometrics::CPHW(DataGlobals::InitConvTemp) * WaterConnections(WaterConnNum).DrainMassFlowRate; + Real64 HXCapacityRate = Psychrometrics::CPHW(DataGlobals::InitConvTemp) * this->RecoveryMassFlowRate; + Real64 DrainCapacityRate = Psychrometrics::CPHW(DataGlobals::InitConvTemp) * this->DrainMassFlowRate; Real64 MinCapacityRate = min(DrainCapacityRate, HXCapacityRate); { - auto const SELECT_CASE_var(WaterConnections(WaterConnNum).HeatRecoveryHX); + auto const SELECT_CASE_var(this->HeatRecoveryHX); if (SELECT_CASE_var == HeatRecoveryHX::Ideal) { - WaterConnections(WaterConnNum).Effectiveness = 1.0; + this->Effectiveness = 1.0; } else if (SELECT_CASE_var == HeatRecoveryHX::CounterFlow) { // Unmixed Real64 CapacityRatio = MinCapacityRate / max(DrainCapacityRate, HXCapacityRate); - Real64 NTU = WaterConnections(WaterConnNum).HXUA / MinCapacityRate; + Real64 NTU = this->HXUA / MinCapacityRate; if (CapacityRatio == 1.0) { - WaterConnections(WaterConnNum).Effectiveness = NTU / (1.0 + NTU); + this->Effectiveness = NTU / (1.0 + NTU); } else { Real64 ExpVal = std::exp(-NTU * (1.0 - CapacityRatio)); - WaterConnections(WaterConnNum).Effectiveness = (1.0 - ExpVal) / (1.0 - CapacityRatio * ExpVal); + this->Effectiveness = (1.0 - ExpVal) / (1.0 - CapacityRatio * ExpVal); } } else if (SELECT_CASE_var == HeatRecoveryHX::CrossFlow) { // Unmixed Real64 CapacityRatio = MinCapacityRate / max(DrainCapacityRate, HXCapacityRate); - Real64 NTU = WaterConnections(WaterConnNum).HXUA / MinCapacityRate; - WaterConnections(WaterConnNum).Effectiveness = - 1.0 - std::exp((std::pow(NTU, 0.22) / CapacityRatio) * (std::exp(-CapacityRatio * std::pow(NTU, 0.78)) - 1.0)); + Real64 NTU = this->HXUA / MinCapacityRate; + this->Effectiveness = 1.0 - std::exp((std::pow(NTU, 0.22) / CapacityRatio) * (std::exp(-CapacityRatio * std::pow(NTU, 0.78)) - 1.0)); } } - WaterConnections(WaterConnNum).RecoveryRate = WaterConnections(WaterConnNum).Effectiveness * MinCapacityRate * - (WaterConnections(WaterConnNum).DrainTemp - WaterConnections(WaterConnNum).ColdSupplyTemp); - - WaterConnections(WaterConnNum).RecoveryTemp = - WaterConnections(WaterConnNum).ColdSupplyTemp + - WaterConnections(WaterConnNum).RecoveryRate / - (Psychrometrics::CPHW(DataGlobals::InitConvTemp) * WaterConnections(WaterConnNum).TotalMassFlowRate); - - WaterConnections(WaterConnNum).WasteTemp = - WaterConnections(WaterConnNum).DrainTemp - - WaterConnections(WaterConnNum).RecoveryRate / - (Psychrometrics::CPHW(DataGlobals::InitConvTemp) * WaterConnections(WaterConnNum).TotalMassFlowRate); + this->RecoveryRate = this->Effectiveness * MinCapacityRate * (this->DrainTemp - this->ColdSupplyTemp); + this->RecoveryTemp = this->ColdSupplyTemp + this->RecoveryRate / (Psychrometrics::CPHW(DataGlobals::InitConvTemp) * this->TotalMassFlowRate); + this->WasteTemp = this->DrainTemp - this->RecoveryRate / (Psychrometrics::CPHW(DataGlobals::InitConvTemp) * this->TotalMassFlowRate); - if (WaterConnections(WaterConnNum).RecoveryTankNum > 0) { - DataWater::WaterStorage(WaterConnections(WaterConnNum).RecoveryTankNum).VdotAvailSupply(WaterConnections(WaterConnNum).TankSupplyID) = - WaterConnections(WaterConnNum).DrainVolFlowRate; - DataWater::WaterStorage(WaterConnections(WaterConnNum).RecoveryTankNum).TwaterSupply(WaterConnections(WaterConnNum).TankSupplyID) = - WaterConnections(WaterConnNum).WasteTemp; + if (this->RecoveryTankNum > 0) { + DataWater::WaterStorage(this->RecoveryTankNum).VdotAvailSupply(this->TankSupplyID) = this->DrainVolFlowRate; + DataWater::WaterStorage(this->RecoveryTankNum).TwaterSupply(this->TankSupplyID) = this->WasteTemp; } { - auto const SELECT_CASE_var(WaterConnections(WaterConnNum).HeatRecoveryConfig); + auto const SELECT_CASE_var(this->HeatRecoveryConfig); if (SELECT_CASE_var == HeatRecoveryConfig::Plant) { - WaterConnections(WaterConnNum).TempError = 0.0; // No feedback back to the cold supply - WaterConnections(WaterConnNum).ReturnTemp = WaterConnections(WaterConnNum).RecoveryTemp; + this->TempError = 0.0; // No feedback back to the cold supply + this->ReturnTemp = this->RecoveryTemp; } else if (SELECT_CASE_var == HeatRecoveryConfig::Equipment) { - WaterConnections(WaterConnNum).TempError = - std::abs(WaterConnections(WaterConnNum).ColdTemp - WaterConnections(WaterConnNum).RecoveryTemp); + this->TempError = std::abs(this->ColdTemp - this->RecoveryTemp); - WaterConnections(WaterConnNum).ColdTemp = WaterConnections(WaterConnNum).RecoveryTemp; - WaterConnections(WaterConnNum).ReturnTemp = WaterConnections(WaterConnNum).ColdSupplyTemp; + this->ColdTemp = this->RecoveryTemp; + this->ReturnTemp = this->ColdSupplyTemp; } else if (SELECT_CASE_var == HeatRecoveryConfig::PlantAndEquip) { - WaterConnections(WaterConnNum).TempError = - std::abs(WaterConnections(WaterConnNum).ColdTemp - WaterConnections(WaterConnNum).RecoveryTemp); + this->TempError = std::abs(this->ColdTemp - this->RecoveryTemp); - WaterConnections(WaterConnNum).ColdTemp = WaterConnections(WaterConnNum).RecoveryTemp; - WaterConnections(WaterConnNum).ReturnTemp = WaterConnections(WaterConnNum).RecoveryTemp; + this->ColdTemp = this->RecoveryTemp; + this->ReturnTemp = this->RecoveryTemp; } } } } - void UpdateWaterConnections(int WaterConnNum) + void WaterConnectionsType::UpdateWaterConnections() { // SUBROUTINE INFORMATION: @@ -1527,12 +1506,12 @@ namespace EnergyPlus { // PURPOSE OF THIS SUBROUTINE: // Updates the node variables with local variables. - if (WaterConnections(WaterConnNum).InletNode > 0 && WaterConnections(WaterConnNum).OutletNode > 0) { + if (this->InletNode > 0 && this->OutletNode > 0) { // Pass all variables from inlet to outlet node - PlantUtilities::SafeCopyPlantNode(WaterConnections(WaterConnNum).InletNode, WaterConnections(WaterConnNum).OutletNode, WaterConnections(WaterConnNum).PlantLoopNum); + PlantUtilities::SafeCopyPlantNode(this->InletNode, this->OutletNode, this->PlantLoopNum); // Set outlet node variables that are possibly changed - DataLoopNode::Node(WaterConnections(WaterConnNum).OutletNode).Temp = WaterConnections(WaterConnNum).ReturnTemp; + DataLoopNode::Node(this->OutletNode).Temp = this->ReturnTemp; // should add enthalpy update to return? } } @@ -1578,7 +1557,7 @@ namespace EnergyPlus { } } - void ReportWaterUse(int WaterConnNum) + void WaterConnectionsType::ReportWaterUse() { // SUBROUTINE INFORMATION: @@ -1590,55 +1569,37 @@ namespace EnergyPlus { // PURPOSE OF THIS SUBROUTINE: // Calculates report variables. - for (int Loop = 1; Loop <= WaterConnections(WaterConnNum).NumWaterEquipment; ++Loop) { - int WaterEquipNum = WaterConnections(WaterConnNum).WaterEquipment(Loop); - WaterEquipment(WaterEquipNum).ColdVolFlowRate = - WaterEquipment(WaterEquipNum).ColdMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); - WaterEquipment(WaterEquipNum).HotVolFlowRate = - WaterEquipment(WaterEquipNum).HotMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); - WaterEquipment(WaterEquipNum).TotalVolFlowRate = - WaterEquipment(WaterEquipNum).ColdVolFlowRate + WaterEquipment(WaterEquipNum).HotVolFlowRate; + for (int Loop = 1; Loop <= this->NumWaterEquipment; ++Loop) { - WaterEquipment(WaterEquipNum).ColdVolume = - WaterEquipment(WaterEquipNum).ColdVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - WaterEquipment(WaterEquipNum).HotVolume = - WaterEquipment(WaterEquipNum).HotVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - WaterEquipment(WaterEquipNum).TotalVolume = - WaterEquipment(WaterEquipNum).TotalVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + int WaterEquipNum = this->myWaterEquipArr(Loop); + auto &thisWEq = WaterEquipment(WaterEquipNum); - if (WaterEquipment(WaterEquipNum).Connections == 0) { - WaterEquipment(WaterEquipNum).Power = WaterEquipment(WaterEquipNum).HotMassFlowRate * - Psychrometrics::CPHW(DataGlobals::InitConvTemp) * - (WaterEquipment(WaterEquipNum).HotTemp - WaterEquipment(WaterEquipNum).ColdTemp); + thisWEq.ColdVolFlowRate = thisWEq.ColdMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); + thisWEq.HotVolFlowRate = thisWEq.HotMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); + thisWEq.TotalVolFlowRate = thisWEq.ColdVolFlowRate + thisWEq.HotVolFlowRate; + thisWEq.ColdVolume = thisWEq.ColdVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + thisWEq.HotVolume = thisWEq.HotVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + thisWEq.TotalVolume = thisWEq.TotalVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + + if (thisWEq.Connections == 0) { + thisWEq.Power = thisWEq.HotMassFlowRate * Psychrometrics::CPHW(DataGlobals::InitConvTemp) * (thisWEq.HotTemp - thisWEq.ColdTemp); } else { - WaterEquipment(WaterEquipNum).Power = - WaterEquipment(WaterEquipNum).HotMassFlowRate * Psychrometrics::CPHW(DataGlobals::InitConvTemp) * - (WaterEquipment(WaterEquipNum).HotTemp - WaterConnections(WaterEquipment(WaterEquipNum).Connections).ReturnTemp); + thisWEq.Power = thisWEq.HotMassFlowRate * Psychrometrics::CPHW(DataGlobals::InitConvTemp) * + (thisWEq.HotTemp - WaterConnections(thisWEq.Connections).ReturnTemp); } - WaterEquipment(WaterEquipNum).Energy = WaterEquipment(WaterEquipNum).Power * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + thisWEq.Energy = thisWEq.Power * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; } - WaterConnections(WaterConnNum).ColdVolFlowRate = - WaterConnections(WaterConnNum).ColdMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); - WaterConnections(WaterConnNum).HotVolFlowRate = - WaterConnections(WaterConnNum).HotMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); - WaterConnections(WaterConnNum).TotalVolFlowRate = - WaterConnections(WaterConnNum).ColdVolFlowRate + WaterConnections(WaterConnNum).HotVolFlowRate; - - WaterConnections(WaterConnNum).ColdVolume = - WaterConnections(WaterConnNum).ColdVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - WaterConnections(WaterConnNum).HotVolume = - WaterConnections(WaterConnNum).HotVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - WaterConnections(WaterConnNum).TotalVolume = - WaterConnections(WaterConnNum).TotalVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - - WaterConnections(WaterConnNum).Power = WaterConnections(WaterConnNum).HotMassFlowRate * Psychrometrics::CPHW(DataGlobals::InitConvTemp) * - (WaterConnections(WaterConnNum).HotTemp - WaterConnections(WaterConnNum).ReturnTemp); - WaterConnections(WaterConnNum).Energy = WaterConnections(WaterConnNum).Power * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - - WaterConnections(WaterConnNum).RecoveryEnergy = - WaterConnections(WaterConnNum).RecoveryRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + this->ColdVolFlowRate = this->ColdMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); + this->HotVolFlowRate = this->HotMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); + this->TotalVolFlowRate = this->ColdVolFlowRate + this->HotVolFlowRate; + this->ColdVolume = this->ColdVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + this->HotVolume = this->HotVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + this->TotalVolume = this->TotalVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + this->Power = this->HotMassFlowRate * Psychrometrics::CPHW(DataGlobals::InitConvTemp) * (this->HotTemp - this->ReturnTemp); + this->Energy = this->Power * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + this->RecoveryEnergy = this->RecoveryRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; } void CalcWaterUseZoneGains() diff --git a/src/EnergyPlus/WaterUse.hh b/src/EnergyPlus/WaterUse.hh index 8c681d730ce..1892df2066d 100644 --- a/src/EnergyPlus/WaterUse.hh +++ b/src/EnergyPlus/WaterUse.hh @@ -198,7 +198,7 @@ namespace EnergyPlus { Real64 Energy; // Heating energy required to raise temperature from cold to hot (J) int NumWaterEquipment; int MaxIterationsErrorIndex; // recurring error index - Array1D_int WaterEquipment; + Array1D_int myWaterEquipArr; int PlantLoopNum; int PlantLoopSide; int PlantLoopBranchNum; @@ -218,6 +218,16 @@ namespace EnergyPlus { } void InitConnections(int WaterConnNum); + + void CalcConnectionsFlowRates(bool FirstHVACIteration); + + void CalcConnectionsDrainTemp(); + + void CalcConnectionsHeatRecovery(); + + void UpdateWaterConnections(); + + void ReportWaterUse(); }; void clear_state(); @@ -228,18 +238,8 @@ namespace EnergyPlus { void GetWaterUseInput(); - void CalcConnectionsFlowRates(int WaterConnNum, bool FirstHVACIteration); - - void CalcConnectionsDrainTemp(int WaterConnNum); - - void CalcConnectionsHeatRecovery(int WaterConnNum); - - void UpdateWaterConnections(int WaterConnNum); - void ReportStandAloneWaterUse(); - void ReportWaterUse(int WaterConnNum); - void CalcWaterUseZoneGains(); extern Array1D WaterEquipment; From e0ce1aef451a4b35c8596b22fe5e0290de14fda2 Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Wed, 13 Nov 2019 09:50:23 -0700 Subject: [PATCH 38/51] inherit plant component --- src/EnergyPlus/WaterUse.cc | 25 +++++++++++++++++++++++++ src/EnergyPlus/WaterUse.hh | 7 ++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/EnergyPlus/WaterUse.cc b/src/EnergyPlus/WaterUse.cc index 0c59ea5f6dc..3d3411f4820 100644 --- a/src/EnergyPlus/WaterUse.cc +++ b/src/EnergyPlus/WaterUse.cc @@ -206,6 +206,31 @@ namespace EnergyPlus { } // WaterConnNum } + PlantComponent *WaterConnectionsType::factory(std::string const &objectName) + { + // Process the input data + if (getWaterUseInputFlag) { + GetWaterUseInput(); + getWaterUseInputFlag = false; + } + + // Now look for this particular object in the list + for (auto &thisWC : WaterConnections) { + if (thisWC.Name == objectName) { + return &thisWC; + } + } + // If we didn't find it, fatal + ShowFatalError("LocalWaterUseConnectionFactory: Error getting inputs for object named: " + objectName); // LCOV_EXCL_LINE + // Shut up the compiler + return nullptr; // LCOV_EXCL_LINE + } + + void WaterConnectionsType::simulate(const PlantLocation &calledFromLocation, bool FirstHVACIteration, Real64 &CurLoad, bool RunFlag) + { + + } + void SimulateWaterUseConnection( int EP_UNUSED(EquipTypeNum), std::string &CompName, int &CompIndex, bool InitLoopEquip, bool FirstHVACIteration) { diff --git a/src/EnergyPlus/WaterUse.hh b/src/EnergyPlus/WaterUse.hh index 1892df2066d..8a798f3f28e 100644 --- a/src/EnergyPlus/WaterUse.hh +++ b/src/EnergyPlus/WaterUse.hh @@ -54,6 +54,7 @@ // EnergyPlus Headers #include #include +#include namespace EnergyPlus { @@ -143,7 +144,7 @@ namespace EnergyPlus { void CalcEquipmentDrainTemp(); }; - struct WaterConnectionsType + struct WaterConnectionsType : PlantComponent { std::string Name; // Name of DHW bool Init; // Flag for initialization: TRUE means do the init @@ -217,6 +218,10 @@ namespace EnergyPlus { { } + static PlantComponent *factory(std::string const &objectName); + + void simulate(const PlantLocation &calledFromLocation, bool FirstHVACIteration, Real64 &CurLoad, bool RunFlag) override; + void InitConnections(int WaterConnNum); void CalcConnectionsFlowRates(bool FirstHVACIteration); From 3680e43e0cbc95d76de227810fb75bc21754ddd1 Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Wed, 13 Nov 2019 15:14:39 -0700 Subject: [PATCH 39/51] move setupOutputVars to standalone. still called from inputs --- src/EnergyPlus/FuelCellElectricGenerator.cc | 736 +++++++++++--------- src/EnergyPlus/FuelCellElectricGenerator.hh | 4 +- 2 files changed, 393 insertions(+), 347 deletions(-) diff --git a/src/EnergyPlus/FuelCellElectricGenerator.cc b/src/EnergyPlus/FuelCellElectricGenerator.cc index 481830189dd..7ced33cc496 100644 --- a/src/EnergyPlus/FuelCellElectricGenerator.cc +++ b/src/EnergyPlus/FuelCellElectricGenerator.cc @@ -155,7 +155,7 @@ namespace FuelCellElectricGenerator { } } - FuelCell(GenNum).InitFuelCellGenerators(); + FuelCell(GenNum).initialize(); FuelCell(GenNum).CalcFuelCellGeneratorModel(GenNum, RunFlag, MyLoad, FirstHVACIteration); FuelCell(GenNum).CalcUpdateHeatRecovery(FirstHVACIteration); FuelCell(GenNum).UpdateFuelCellGeneratorRecords(); @@ -939,375 +939,424 @@ namespace FuelCellElectricGenerator { ShowFatalError("Errors found in getting input for fuel cell model "); } - for (int GeneratorNum = 1; GeneratorNum <= NumFuelCellGenerators; ++GeneratorNum) { - SetupOutputVariable("Generator Produced Electric Power", + for (int genNum = 1; genNum <= NumFuelCellGenerators; ++genNum) { + auto &thisGen = FuelCell(genNum); + thisGen.setupOutputVars(); + } + } + + void FCDataStruct::setupOutputVars() + { + SetupOutputVariable("Generator Produced Electric Power", + OutputProcessor::Unit::W, + this->Report.ACPowerGen, + "System", + "Average", + this->Name); + + SetupOutputVariable("Generator Produced Electric Energy", + OutputProcessor::Unit::J, + this->Report.ACEnergyGen, + "System", + "Sum", + this->Name, + _, + "ElectricityProduced", + "COGENERATION", + _, + "Plant"); + + SetupOutputVariable("Generator Produced Thermal Rate", + OutputProcessor::Unit::W, + this->Report.qHX, + "System", + "Average", + this->Name); + + SetupOutputVariable("Generator Produced Thermal Energy", + OutputProcessor::Unit::J, + this->Report.HXenergy, + "System", + "Sum", + this->Name, + _, + "ENERGYTRANSFER", + "COGENERATION", + _, + "Plant"); + + SetupOutputVariable("Generator Fuel HHV Basis Energy", + OutputProcessor::Unit::J, + this->Report.FuelEnergyHHV, + "System", + "Sum", + this->Name, + _, + "Gas", + "COGENERATION", + _, + "Plant"); + + SetupOutputVariable("Generator Fuel HHV Basis Rate", + OutputProcessor::Unit::W, + this->Report.FuelEnergyUseRateHHV, + "System", + "Average", + this->Name); + + SetupOutputVariable("Generator Zone Sensible Heat Transfer Rate", + OutputProcessor::Unit::W, + this->Report.SkinLossPower, + "System", + "Average", + this->Name); + + SetupOutputVariable("Generator Zone Sensible Heat Transfer Energy", + OutputProcessor::Unit::J, + this->Report.SkinLossEnergy, + "System", + "Sum", + this->Name); + + SetupOutputVariable("Generator Zone Convection Heat Transfer Rate", + OutputProcessor::Unit::W, + this->Report.SkinLossConvect, + "System", + "Average", + this->Name); + + SetupOutputVariable("Generator Zone Radiation Heat Transfer Rate", + OutputProcessor::Unit::W, + this->Report.SkinLossRadiat, + "System", + "Average", + this->Name); + + if (this->FCPM.ZoneID > 0) { + SetupZoneInternalGain(this->FCPM.ZoneID, + "Generator:FuelCell", + this->Name, + DataHeatBalance::IntGainTypeOf_GeneratorFuelCell, + this->Report.SkinLossConvect, + _, + this->Report.SkinLossRadiat); + } + + if (DataGlobals::DisplayAdvancedReportVariables) { // show extra data originally needed for detailed comparative testing + SetupOutputVariable("Generator Air Inlet Temperature", + OutputProcessor::Unit::C, + this->Report.TairInlet, + "System", + "Average", + this->Name); + + SetupOutputVariable("Generator Power Module Entering Air Temperature", + OutputProcessor::Unit::C, + this->Report.TairIntoFCPM, + "System", + "Average", + this->Name); + + SetupOutputVariable("Generator Air Molar Flow Rate", + OutputProcessor::Unit::kmol_s, + this->Report.NdotAir, + "System", + "Average", + this->Name); + + SetupOutputVariable("Generator Power Module Entering Air Enthalpy", OutputProcessor::Unit::W, - FuelCell(GeneratorNum).Report.ACPowerGen, + this->Report.TotAirInEnthalphy, "System", "Average", - FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Produced Electric Energy", + this->Name); + + SetupOutputVariable("Generator Blower Electric Power", + OutputProcessor::Unit::W, + this->Report.BlowerPower, + "System", + "Average", + this->Name); + + SetupOutputVariable("Generator Blower Electric Energy", OutputProcessor::Unit::J, - FuelCell(GeneratorNum).Report.ACEnergyGen, + this->Report.BlowerEnergy, "System", "Sum", - FuelCell(GeneratorNum).Name, - _, - "ElectricityProduced", - "COGENERATION", - _, - "Plant"); - SetupOutputVariable("Generator Produced Thermal Rate", + this->Name); + + SetupOutputVariable("Generator Blower Skin Heat Loss Rate", OutputProcessor::Unit::W, - FuelCell(GeneratorNum).Report.qHX, + this->Report.BlowerSkinLoss, "System", "Average", - FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Produced Thermal Energy", + this->Name); + + SetupOutputVariable("Generator Fuel Inlet Temperature", + OutputProcessor::Unit::C, + this->Report.TfuelInlet, + "System", + "Average", + this->Name); + + SetupOutputVariable("Generator Power Module Entering Fuel Temperature", + OutputProcessor::Unit::C, + this->Report.TfuelIntoFCPM, + "System", + "Average", + this->Name); + + SetupOutputVariable("Generator Fuel Molar Flow Rate", + OutputProcessor::Unit::kmol_s, + this->Report.NdotFuel, + "System", + "Average", + this->Name); + + SetupOutputVariable("Generator Fuel Consumption LHV Basis Energy", OutputProcessor::Unit::J, - FuelCell(GeneratorNum).Report.HXenergy, + this->Report.FuelEnergyLHV, "System", "Sum", - FuelCell(GeneratorNum).Name, - _, - "ENERGYTRANSFER", - "COGENERATION", - _, - "Plant"); - - SetupOutputVariable("Generator Fuel HHV Basis Energy", + this->Name); + + SetupOutputVariable("Generator Fuel Consumption Rate LHV Basis", + OutputProcessor::Unit::W, + this->Report.FuelEnergyUseRateLHV, + "System", + "Average", + this->Name); + + SetupOutputVariable("Generator Power Module Entering Fuel Enthalpy", + OutputProcessor::Unit::W, + this->Report.TotFuelInEnthalpy, + "System", + "Average", + this->Name); + + SetupOutputVariable("Generator Fuel Compressor Electric Power", + OutputProcessor::Unit::W, + this->Report.FuelCompressPower, + "System", + "Average", + this->Name); + + SetupOutputVariable("Generator Fuel Compressor Electric Energy", OutputProcessor::Unit::J, - FuelCell(GeneratorNum).Report.FuelEnergyHHV, + this->Report.FuelCompressEnergy, "System", "Sum", - FuelCell(GeneratorNum).Name, - _, - "Gas", - "COGENERATION", - _, - "Plant"); - SetupOutputVariable("Generator Fuel HHV Basis Rate", + this->Name); + + SetupOutputVariable("Generator Fuel Compressor Skin Heat Loss Rate", OutputProcessor::Unit::W, - FuelCell(GeneratorNum).Report.FuelEnergyUseRateHHV, + this->Report.FuelCompressSkinLoss, + "System", + "Average", + this->Name); + + SetupOutputVariable("Generator Fuel Reformer Water Inlet Temperature", + OutputProcessor::Unit::C, + this->Report.TwaterInlet, + "System", + "Average", + this->Name); + + SetupOutputVariable("Generator Power Module Entering Reforming Water Temperature", + OutputProcessor::Unit::C, + this->Report.TwaterIntoFCPM, "System", "Average", - FuelCell(GeneratorNum).Name); + this->Name); - SetupOutputVariable("Generator Zone Sensible Heat Transfer Rate", + SetupOutputVariable("Generator Fuel Reformer Water Molar Flow Rate", + OutputProcessor::Unit::kmol_s, + this->Report.NdotWater, + "System", + "Average", + this->Name); + + SetupOutputVariable("Generator Fuel Reformer Water Pump Electric Power", OutputProcessor::Unit::W, - FuelCell(GeneratorNum).Report.SkinLossPower, + this->Report.WaterPumpPower, "System", "Average", - FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Zone Sensible Heat Transfer Energy", + this->Name); + + SetupOutputVariable("Generator Fuel Reformer Water Pump Electric Energy", OutputProcessor::Unit::J, - FuelCell(GeneratorNum).Report.SkinLossEnergy, + this->Report.WaterPumpEnergy, "System", "Sum", - FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Zone Convection Heat Transfer Rate", + this->Name); + + SetupOutputVariable("Generator Power Module Entering Reforming Water Enthalpy", OutputProcessor::Unit::W, - FuelCell(GeneratorNum).Report.SkinLossConvect, + this->Report.WaterIntoFCPMEnthalpy, "System", "Average", - FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Zone Radiation Heat Transfer Rate", + this->Name); + + SetupOutputVariable("Generator Product Gas Temperature", + OutputProcessor::Unit::C, + this->Report.TprodGas, + "System", + "Average", + this->Name); + + SetupOutputVariable("Generator Product Gas Enthalpy", OutputProcessor::Unit::W, - FuelCell(GeneratorNum).Report.SkinLossRadiat, + this->Report.EnthalProdGas, "System", "Average", - FuelCell(GeneratorNum).Name); - if (FuelCell(GeneratorNum).FCPM.ZoneID > 0) { - SetupZoneInternalGain(FuelCell(GeneratorNum).FCPM.ZoneID, - "Generator:FuelCell", - FuelCell(GeneratorNum).Name, - DataHeatBalance::IntGainTypeOf_GeneratorFuelCell, - FuelCell(GeneratorNum).Report.SkinLossConvect, - _, - FuelCell(GeneratorNum).Report.SkinLossRadiat); - } + this->Name); - if (DataGlobals::DisplayAdvancedReportVariables) { // show extra data originally needed for detailed comparative testing - SetupOutputVariable("Generator Air Inlet Temperature", - OutputProcessor::Unit::C, - FuelCell(GeneratorNum).Report.TairInlet, - "System", - "Average", - FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Power Module Entering Air Temperature", - OutputProcessor::Unit::C, - FuelCell(GeneratorNum).Report.TairIntoFCPM, - "System", - "Average", - FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Air Molar Flow Rate", - OutputProcessor::Unit::kmol_s, - FuelCell(GeneratorNum).Report.NdotAir, - "System", - "Average", - FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Power Module Entering Air Enthalpy", - OutputProcessor::Unit::W, - FuelCell(GeneratorNum).Report.TotAirInEnthalphy, - "System", - "Average", - FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Blower Electric Power", - OutputProcessor::Unit::W, - FuelCell(GeneratorNum).Report.BlowerPower, - "System", - "Average", - FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Blower Electric Energy", - OutputProcessor::Unit::J, - FuelCell(GeneratorNum).Report.BlowerEnergy, - "System", - "Sum", - FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Blower Skin Heat Loss Rate", - OutputProcessor::Unit::W, - FuelCell(GeneratorNum).Report.BlowerSkinLoss, - "System", - "Average", - FuelCell(GeneratorNum).Name); - - SetupOutputVariable("Generator Fuel Inlet Temperature", - OutputProcessor::Unit::C, - FuelCell(GeneratorNum).Report.TfuelInlet, - "System", - "Average", - FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Power Module Entering Fuel Temperature", - OutputProcessor::Unit::C, - FuelCell(GeneratorNum).Report.TfuelIntoFCPM, - "System", - "Average", - FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Fuel Molar Flow Rate", - OutputProcessor::Unit::kmol_s, - FuelCell(GeneratorNum).Report.NdotFuel, - "System", - "Average", - FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Fuel Consumption LHV Basis Energy", - OutputProcessor::Unit::J, - FuelCell(GeneratorNum).Report.FuelEnergyLHV, - "System", - "Sum", - FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Fuel Consumption Rate LHV Basis", - OutputProcessor::Unit::W, - FuelCell(GeneratorNum).Report.FuelEnergyUseRateLHV, - "System", - "Average", - FuelCell(GeneratorNum).Name); - - SetupOutputVariable("Generator Power Module Entering Fuel Enthalpy", - OutputProcessor::Unit::W, - FuelCell(GeneratorNum).Report.TotFuelInEnthalpy, - "System", - "Average", - FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Fuel Compressor Electric Power", - OutputProcessor::Unit::W, - FuelCell(GeneratorNum).Report.FuelCompressPower, - "System", - "Average", - FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Fuel Compressor Electric Energy", - OutputProcessor::Unit::J, - FuelCell(GeneratorNum).Report.FuelCompressEnergy, - "System", - "Sum", - FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Fuel Compressor Skin Heat Loss Rate", - OutputProcessor::Unit::W, - FuelCell(GeneratorNum).Report.FuelCompressSkinLoss, - "System", - "Average", - FuelCell(GeneratorNum).Name); - - SetupOutputVariable("Generator Fuel Reformer Water Inlet Temperature", - OutputProcessor::Unit::C, - FuelCell(GeneratorNum).Report.TwaterInlet, - "System", - "Average", - FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Power Module Entering Reforming Water Temperature", - OutputProcessor::Unit::C, - FuelCell(GeneratorNum).Report.TwaterIntoFCPM, - "System", - "Average", - FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Fuel Reformer Water Molar Flow Rate", - OutputProcessor::Unit::kmol_s, - FuelCell(GeneratorNum).Report.NdotWater, - "System", - "Average", - FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Fuel Reformer Water Pump Electric Power", - OutputProcessor::Unit::W, - FuelCell(GeneratorNum).Report.WaterPumpPower, - "System", - "Average", - FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Fuel Reformer Water Pump Electric Energy", - OutputProcessor::Unit::J, - FuelCell(GeneratorNum).Report.WaterPumpEnergy, - "System", - "Sum", - FuelCell(GeneratorNum).Name); - - SetupOutputVariable("Generator Power Module Entering Reforming Water Enthalpy", - OutputProcessor::Unit::W, - FuelCell(GeneratorNum).Report.WaterIntoFCPMEnthalpy, - "System", - "Average", - FuelCell(GeneratorNum).Name); - - SetupOutputVariable("Generator Product Gas Temperature", - OutputProcessor::Unit::C, - FuelCell(GeneratorNum).Report.TprodGas, - "System", - "Average", - FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Product Gas Enthalpy", - OutputProcessor::Unit::W, - FuelCell(GeneratorNum).Report.EnthalProdGas, - "System", - "Average", - FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Product Gas Molar Flow Rate", - OutputProcessor::Unit::kmol_s, - FuelCell(GeneratorNum).Report.NdotProdGas, - "System", - "Average", - FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Product Gas Ar Molar Flow Rate", - OutputProcessor::Unit::kmol_s, - FuelCell(GeneratorNum).Report.NdotProdAr, - "System", - "Average", - FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Product Gas CO2 Molar Flow Rate", - OutputProcessor::Unit::kmol_s, - FuelCell(GeneratorNum).Report.NdotProdCO2, - "System", - "Average", - FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Product Gas H2O Vapor Molar Flow Rate", - OutputProcessor::Unit::kmol_s, - FuelCell(GeneratorNum).Report.NdotProdH2O, - "System", - "Average", - FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Product Gas N2 Molar Flow Rate", - OutputProcessor::Unit::kmol_s, - FuelCell(GeneratorNum).Report.NdotProdN2, - "System", - "Average", - FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Product Gas O2 Molar Flow Rate", - OutputProcessor::Unit::kmol_s, - FuelCell(GeneratorNum).Report.NdotProdO2, - "System", - "Average", - FuelCell(GeneratorNum).Name); - - SetupOutputVariable("Generator Heat Recovery Exit Gas Temperature", - OutputProcessor::Unit::C, - FuelCell(GeneratorNum).Report.THXexh, - "System", - "Average", - FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Heat Recovery Exit Gas H2O Vapor Fraction", - OutputProcessor::Unit::None, - FuelCell(GeneratorNum).Report.WaterVaporFractExh, - "System", - "Average", - FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Heat Recovery Water Condensate Molar Flow Rate", - OutputProcessor::Unit::kmol_s, - FuelCell(GeneratorNum).Report.CondensateRate, - "System", - "Average", - FuelCell(GeneratorNum).Name); - - SetupOutputVariable("Generator Inverter Loss Power", - OutputProcessor::Unit::W, - FuelCell(GeneratorNum).Report.PCUlosses, - "System", - "Average", - FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Produced DC Electric Power", - OutputProcessor::Unit::W, - FuelCell(GeneratorNum).Report.DCPowerGen, - "System", - "Average", - FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator DC Power Efficiency", - OutputProcessor::Unit::None, - FuelCell(GeneratorNum).Report.DCPowerEff, - "System", - "Average", - FuelCell(GeneratorNum).Name); - - SetupOutputVariable("Generator Electric Storage Charge State", - OutputProcessor::Unit::J, - FuelCell(GeneratorNum).Report.ElectEnergyinStorage, - "System", - "Average", - FuelCell(GeneratorNum).Name); //? 'Sum' - SetupOutputVariable("Generator DC Storage Charging Power", - OutputProcessor::Unit::W, - FuelCell(GeneratorNum).Report.StoredPower, - "System", - "Average", - FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator DC Storage Charging Energy", - OutputProcessor::Unit::J, - FuelCell(GeneratorNum).Report.StoredEnergy, - "System", - "Sum", - FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator DC Storage Discharging Power", - OutputProcessor::Unit::W, - FuelCell(GeneratorNum).Report.DrawnPower, - "System", - "Average", - FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator DC Storage Discharging Energy", - OutputProcessor::Unit::J, - FuelCell(GeneratorNum).Report.DrawnEnergy, - "System", - "Sum", - FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Ancillary AC Electric Power", - OutputProcessor::Unit::W, - FuelCell(GeneratorNum).Report.ACancillariesPower, - "System", - "Average", - FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Ancillary AC Electric Energy", - OutputProcessor::Unit::J, - FuelCell(GeneratorNum).Report.ACancillariesEnergy, - "System", - "Sum", - FuelCell(GeneratorNum).Name); - - SetupOutputVariable("Generator Fuel Cell Model Iteration Count", - OutputProcessor::Unit::None, - FuelCell(GeneratorNum).Report.SeqSubstIterations, - "System", - "Sum", - FuelCell(GeneratorNum).Name); - SetupOutputVariable("Generator Root Solver Iteration Count", - OutputProcessor::Unit::None, - FuelCell(GeneratorNum).Report.RegulaFalsiIterations, - "System", - "Sum", - FuelCell(GeneratorNum).Name); - } + SetupOutputVariable("Generator Product Gas Molar Flow Rate", + OutputProcessor::Unit::kmol_s, + this->Report.NdotProdGas, + "System", + "Average", + this->Name); + + SetupOutputVariable("Generator Product Gas Ar Molar Flow Rate", + OutputProcessor::Unit::kmol_s, + this->Report.NdotProdAr, + "System", + "Average", + this->Name); + + SetupOutputVariable("Generator Product Gas CO2 Molar Flow Rate", + OutputProcessor::Unit::kmol_s, + this->Report.NdotProdCO2, + "System", + "Average", + this->Name); + + SetupOutputVariable("Generator Product Gas H2O Vapor Molar Flow Rate", + OutputProcessor::Unit::kmol_s, + this->Report.NdotProdH2O, + "System", + "Average", + this->Name); + + SetupOutputVariable("Generator Product Gas N2 Molar Flow Rate", + OutputProcessor::Unit::kmol_s, + this->Report.NdotProdN2, + "System", + "Average", + this->Name); + + SetupOutputVariable("Generator Product Gas O2 Molar Flow Rate", + OutputProcessor::Unit::kmol_s, + this->Report.NdotProdO2, + "System", + "Average", + this->Name); + + SetupOutputVariable("Generator Heat Recovery Exit Gas Temperature", + OutputProcessor::Unit::C, + this->Report.THXexh, + "System", + "Average", + this->Name); + + SetupOutputVariable("Generator Heat Recovery Exit Gas H2O Vapor Fraction", + OutputProcessor::Unit::None, + this->Report.WaterVaporFractExh, + "System", + "Average", + this->Name); + + SetupOutputVariable("Generator Heat Recovery Water Condensate Molar Flow Rate", + OutputProcessor::Unit::kmol_s, + this->Report.CondensateRate, + "System", + "Average", + this->Name); + + SetupOutputVariable("Generator Inverter Loss Power", + OutputProcessor::Unit::W, + this->Report.PCUlosses, + "System", + "Average", + this->Name); + + SetupOutputVariable("Generator Produced DC Electric Power", + OutputProcessor::Unit::W, + this->Report.DCPowerGen, + "System", + "Average", + this->Name); + + SetupOutputVariable("Generator DC Power Efficiency", + OutputProcessor::Unit::None, + this->Report.DCPowerEff, + "System", + "Average", + this->Name); + + SetupOutputVariable("Generator Electric Storage Charge State", + OutputProcessor::Unit::J, + this->Report.ElectEnergyinStorage, + "System", + "Average", + this->Name); + + SetupOutputVariable("Generator DC Storage Charging Power", + OutputProcessor::Unit::W, + this->Report.StoredPower, + "System", + "Average", + this->Name); + + SetupOutputVariable("Generator DC Storage Charging Energy", + OutputProcessor::Unit::J, + this->Report.StoredEnergy, + "System", + "Sum", + this->Name); + + SetupOutputVariable("Generator DC Storage Discharging Power", + OutputProcessor::Unit::W, + this->Report.DrawnPower, + "System", + "Average", + this->Name); + + SetupOutputVariable("Generator DC Storage Discharging Energy", + OutputProcessor::Unit::J, + this->Report.DrawnEnergy, + "System", + "Sum", + this->Name); + + SetupOutputVariable("Generator Ancillary AC Electric Power", + OutputProcessor::Unit::W, + this->Report.ACancillariesPower, + "System", + "Average", + this->Name); + + SetupOutputVariable("Generator Ancillary AC Electric Energy", + OutputProcessor::Unit::J, + this->Report.ACancillariesEnergy, + "System", + "Sum", + this->Name); + + SetupOutputVariable("Generator Fuel Cell Model Iteration Count", + OutputProcessor::Unit::None, + this->Report.SeqSubstIterations, + "System", + "Sum", + this->Name); + + SetupOutputVariable("Generator Root Solver Iteration Count", + OutputProcessor::Unit::None, + this->Report.RegulaFalsiIterations, + "System", + "Sum", + this->Name); } } @@ -3158,7 +3207,7 @@ namespace FuelCellElectricGenerator { } } - void FCDataStruct::InitFuelCellGenerators() // index to specific fuel cell generator + void FCDataStruct::initialize() // index to specific fuel cell generator { // SUBROUTINE INFORMATION: @@ -3175,15 +3224,12 @@ namespace FuelCellElectricGenerator { static std::string const RoutineName("InitFuelCellGenerators"); - bool errFlag; - - // Do the one time initializations if (this->InitGenerator) { this->InitGenerator = false; - } // end one time setups and inits + } if (this->MyPlantScanFlag_Init && allocated(DataPlant::PlantLoop)) { - errFlag = false; + bool errFlag = false; PlantUtilities::ScanPlantLoopsForObject(this->NameExhaustHX, DataPlant::TypeOf_Generator_FCExhaust, @@ -3335,8 +3381,6 @@ namespace FuelCellElectricGenerator { { if (GetFuelCellInput) { - - // Read input data. GetFuelCellGeneratorInput(); GetFuelCellInput = false; } diff --git a/src/EnergyPlus/FuelCellElectricGenerator.hh b/src/EnergyPlus/FuelCellElectricGenerator.hh index afda283a2c1..2bb09c077a1 100644 --- a/src/EnergyPlus/FuelCellElectricGenerator.hh +++ b/src/EnergyPlus/FuelCellElectricGenerator.hh @@ -553,7 +553,9 @@ namespace FuelCellElectricGenerator { { } - void InitFuelCellGenerators(); + void initialize(); + + void setupOutputVars(); void FigureAirHeatCap(Real64 FluidTemp, Real64 &Cp); From ca780b10d06c64846488c390ea7d47e58db385d1 Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Wed, 13 Nov 2019 15:28:40 -0700 Subject: [PATCH 40/51] delete unused MicroCHP structs that got missed in PR #7568 --- src/EnergyPlus/DataGenerators.cc | 12 -- src/EnergyPlus/DataGenerators.hh | 187 -------------------- src/EnergyPlus/FuelCellElectricGenerator.cc | 3 +- 3 files changed, 1 insertion(+), 201 deletions(-) diff --git a/src/EnergyPlus/DataGenerators.cc b/src/EnergyPlus/DataGenerators.cc index fb8ba05f496..56c5bbca687 100644 --- a/src/EnergyPlus/DataGenerators.cc +++ b/src/EnergyPlus/DataGenerators.cc @@ -144,34 +144,22 @@ namespace DataGenerators { Real64 const ImBalanceTol(0.00001); // used as fraction of electrical power at power module - // DERIVED TYPE DEFINITIONS - - // MODULE VARIABLE DECLARATIONS: - int NumFuelConstit(0); int NumGeneratorFuelSups(0); - int NumMicroCHPs(0); - int NumMicroCHPParams(0); // number of parameter sets for micro chp int NumGensWDynamics(0); // number of dynamics controls for generators // Object Data Array1D GasPhaseThermoChemistryData; Array1D FuelSupply; // fuel supply (reused across various) - Array1D MicroCHP; - Array1D MicroCHPParamInput; // Used during get input then put into nested Array1D GeneratorDynamics; void clear_state() { NumFuelConstit = 0; NumGeneratorFuelSups = 0; - NumMicroCHPs = 0; - NumMicroCHPParams = 0; NumGensWDynamics = 0; GasPhaseThermoChemistryData.deallocate(); FuelSupply.deallocate(); - MicroCHP.deallocate(); - MicroCHPParamInput.deallocate(); GeneratorDynamics.deallocate(); } diff --git a/src/EnergyPlus/DataGenerators.hh b/src/EnergyPlus/DataGenerators.hh index 8f1485f4dc2..7b757af1925 100644 --- a/src/EnergyPlus/DataGenerators.hh +++ b/src/EnergyPlus/DataGenerators.hh @@ -130,18 +130,10 @@ namespace DataGenerators { extern Real64 const ImBalanceTol; // used as fraction of electrical power at power module - // DERIVED TYPE DEFINITIONS - - // MODULE VARIABLE DECLARATIONS: - extern int NumFuelConstit; extern int NumGeneratorFuelSups; - extern int NumMicroCHPs; - extern int NumMicroCHPParams; // number of parameter sets for micro chp extern int NumGensWDynamics; // number of dynamics controls for generators - // Types - struct GeneratorFuelSupplyDataStruct { // Members @@ -286,188 +278,9 @@ namespace DataGenerators { } }; - struct MicroCHPParamsNonNormalized - { - // Members - // user parameters - std::string Name; // name of this PowerModule data - Real64 MaxElecPower; // net electric power [W] - Real64 MinElecPower; // net electric power [W] - Real64 MinWaterMdot; // minimum cooling water flow [kg/s] - Real64 MaxWaterTemp; // limit temp for inlet cooling water [C] - int ElecEffCurveID; // index for TriQuadratic for electrical efficiency - int ThermalEffCurveID; // index for TriQuadric for thermal efficiency - bool InternalFlowControl; // Plant or Internal Flow rate control? - bool PlantFlowControl; // default is plant control - int WaterFlowCurveID; // index for BiQuadratic for water flow rate internal control - int AirFlowCurveID; // index for Quadratic for generator air flow - Real64 DeltaPelMax; // max rate of change in net electric power [W/s} - Real64 DeltaFuelMdotMax; // Maximum Rate of change in fuel flow rate [kmol/s2] - Real64 UAhx; // heat exchanger UA [W/K] - Real64 UAskin; // skin loss UA [W/K] - Real64 RadiativeFraction; // skin loss fraction to radiant energy [] - Real64 MCeng; // aggregated thermal mass of engine [J/K] - Real64 MCcw; // aggregated thermal mass of heat recovery [J/k] - Real64 Pstandby; // standby power [w] - bool WarmUpByTimeDelay; // Warm up mode control - bool WarmUpByEngineTemp; // Warm up mode control - Real64 kf; // coefficient k_f for warmup fuel flow rate - Real64 TnomEngOp; // nominal engine operating temperature [C] - Real64 kp; // coefficient k_p for warmup power - Real64 Rfuelwarmup; // Warm Up Fuel Flow Rate Limit Ratio - Real64 WarmUpDelay; // time for warm up delay [s] - Real64 PcoolDown; // power during cool down - Real64 CoolDownDelay; // time for cool down delay [s] - bool MandatoryFullCoolDown; - bool WarmRestartOkay; - // calculated and from elsewhere - Real64 TimeElapsed; // Fraction of the current hour that has elapsed (h) - // Saved in order to identify the beginning of a new system time - int OpMode; - Real64 OffModeTime; // amount of time generator spent in Off mode - Real64 StandyByModeTime; // amount of time generator spent in standby mode - Real64 WarmUpModeTime; // amount of time generator spent in warm up mode - Real64 NormalModeTime; // amount of time generator spent in normal mode - Real64 CoolDownModeTime; // amount of time generator spent in Cool down mode - Real64 TengLast; // last timestep's value for engine temperature - Real64 TempCWOutLast; // last timestep's value for cooling water outlet temperature - Real64 Pnet; - Real64 ElecEff; - Real64 Qgross; - Real64 ThermEff; - Real64 Qgenss; - Real64 NdotFuel; - Real64 MdotFuel; - Real64 Teng; - Real64 TcwIn; - Real64 TcwOut; - Real64 MdotAir; - Real64 QdotSkin; // rate of heat loss to zone - Real64 QdotConvZone; - Real64 QdotRadZone; - - // Default Constructor - MicroCHPParamsNonNormalized() - : MaxElecPower(0.0), MinElecPower(0.0), MinWaterMdot(0.0), MaxWaterTemp(0.0), ElecEffCurveID(0), ThermalEffCurveID(0), - InternalFlowControl(false), PlantFlowControl(true), WaterFlowCurveID(0), AirFlowCurveID(0), DeltaPelMax(0.0), DeltaFuelMdotMax(0.0), - UAhx(0.0), UAskin(0.0), RadiativeFraction(0.0), MCeng(0.0), MCcw(0.0), Pstandby(0.0), WarmUpByTimeDelay(false), - WarmUpByEngineTemp(true), kf(0.0), TnomEngOp(0.0), kp(0.0), Rfuelwarmup(0.0), WarmUpDelay(0.0), PcoolDown(0.0), CoolDownDelay(0.0), - MandatoryFullCoolDown(false), WarmRestartOkay(true), TimeElapsed(0.0), OpMode(0), OffModeTime(0.0), StandyByModeTime(0.0), - WarmUpModeTime(0.0), NormalModeTime(0.0), CoolDownModeTime(0.0), TengLast(20.0), TempCWOutLast(20.0), Pnet(0.0), ElecEff(0.0), - Qgross(0.0), ThermEff(0.0), Qgenss(0.0), NdotFuel(0.0), MdotFuel(0.0), Teng(20.0), TcwIn(20.0), TcwOut(20.0), MdotAir(0.0), - QdotSkin(0.0), QdotConvZone(0.0), QdotRadZone(0.0) - { - } - }; - - struct MicroCHPReportDataStruct // these are all for reporting only! - { - // Members - int Mode; // report operating mode (dev only, remove at end) - Real64 OffModeTime; // amount of time generator spent in Off mode - Real64 StandyByModeTime; // amount of time generator spent in standby mode - Real64 WarmUpModeTime; // amount of time generator spent in warm up mode - Real64 NormalModeTime; // amount of time generator spent in normal mode - Real64 CoolDownModeTime; // amount of time generator spent in Cool down mode - Real64 ACPowerGen; // reporting: power (W) - Real64 ACEnergyGen; // reporting: energy (J) - Real64 QdotGross; // reporting: interim gross power (W) - Real64 Qgenss; // reporting: net recovered heat rate steadystate(0) - Real64 QdotHX; // reporting: rate of heat exchange from engine to coolant (W) - Real64 QdotHR; // reporting: rate of heat recovered (W) - Real64 Tengine; // reporting: engine mass temperature (C) - Real64 TotalHeatEnergyRec; // reporting: total heat recovered (J) - Real64 ExhaustEnergyRec; // reporting: exhaust gas heat recovered (J) - Real64 FuelEnergyLHV; // reporting: Fuel Energy used in Lower Heating Value(J) - Real64 FuelEnergyUseRateLHV; // reporting: Fuel Energy used in Lower Heating Value(W) - Real64 FuelEnergyHHV; // reporting: Fuel Energy used in Higher Heating Value(J) - Real64 FuelEnergyUseRateHHV; // reporting: Fuel Energy used in Higher Heating Value(W) - Real64 HeatRecInletTemp; // reporting: Heat Recovery Loop Inlet Temperature (C) - Real64 HeatRecOutletTemp; // reporting: Heat Recovery Loop Outlet Temperature (C) - Real64 HeatRecMdot; // reporting: Heat Recovery Loop Mass flow rate (kg/s) - // air supply and blower - Real64 TairInlet; // State point 1 - Real64 MdotAir; // air flow in kmol/sec - // fuel supply and compressor - Real64 TfuelInlet; // State point 2 [C] - Real64 NdotFuel; // fuel flow in [kmol/sec] - Real64 MdotFuel; // fuel flow in [kg/s] - Real64 FuelCompressPower; // electrical power used by fuel supply compressor [W] - Real64 FuelCompressEnergy; // electrical energy used by fuel supply compressor [J] - Real64 FuelCompressSkinLoss; // heat rate of losses.by fuel supply compressor [W] - // heat exchanger for water to exhaust heat recovery - // REAL(r64) :: qHX = 0.0d0 ! heat flow from gas stream to water [W] - // REAL(r64) :: HXenergy = 0.0d0 !energy from gas stream to water [J] - // REAL(r64) :: THXexh = 0.0d0 ! temperature of exhaust gases leaving heat exchanger. - // REAL(r64) :: WaterVaporFractExh = 0.0d0 ! water vapor fraction in exhaust gas stream - // relative to water vapor entering HX (NdotH20/Ndoaux-mix) - // INTEGER :: SeqSubstIterations = 0 ! number of iterations in SOFC loop - // INTEGER :: RegulaFalsiIterations = 0 ! number of iterations in Tproduct gas solving - Real64 SkinLossPower; // heat loss to surrounding zone [W] - Real64 SkinLossEnergy; // heat loss to surround zone [J] - Real64 SkinLossConvect; // convective heat loss to zone [W] - Real64 SkinLossRadiat; // radiative heat loss to zone [W} - Real64 ElectEfficiency; - Real64 ThermalEfficiency; - Real64 OverallEfficiency; - - // Default Constructor - MicroCHPReportDataStruct() - : Mode(0), OffModeTime(0.0), StandyByModeTime(0.0), WarmUpModeTime(0.0), NormalModeTime(0.0), CoolDownModeTime(0.0), ACPowerGen(0.0), - ACEnergyGen(0.0), QdotGross(0.0), Qgenss(0.0), QdotHX(0.0), QdotHR(0.0), Tengine(0.0), TotalHeatEnergyRec(0.0), ExhaustEnergyRec(0.0), - FuelEnergyLHV(0.0), FuelEnergyUseRateLHV(0.0), FuelEnergyHHV(0.0), FuelEnergyUseRateHHV(0.0), HeatRecInletTemp(0.0), - HeatRecOutletTemp(0.0), HeatRecMdot(0.0), TairInlet(0.0), MdotAir(0.0), TfuelInlet(0.0), NdotFuel(0.0), MdotFuel(0.0), - FuelCompressPower(0.0), FuelCompressEnergy(0.0), FuelCompressSkinLoss(0.0), SkinLossPower(0.0), SkinLossEnergy(0.0), - SkinLossConvect(0.0), SkinLossRadiat(0.0), ElectEfficiency(0.0), ThermalEfficiency(0.0), OverallEfficiency(0.0) - { - } - }; - - struct MicroCHPDataStruct - { - // Members - // user input data - std::string Name; // name of this Micro CHP Generator - std::string ParamObjName; // name of parameter object - MicroCHPParamsNonNormalized A42Model; // Nested parameter data structure - bool ModelTypeAnnex42; // normalized = non-normalized? - Real64 NomEff; // nominal efficiency - std::string ZoneName; - int ZoneID; - std::string PlantInletNodeName; - int PlantInletNodeID; - std::string PlantOutletNodeName; - int PlantOutletNodeID; - Real64 PlantMassFlowRate; // only if internal control - Real64 PlantMassFlowRateMax; // hardware limit for node%massflowrateMax - bool PlantMassFlowRateMaxWasAutoSized; // true if mass flow rate was autosized on input - std::string AirInletNodeName; - int AirInletNodeID; - std::string AirOutletNodeName; - int AirOutletNodeID; - MicroCHPReportDataStruct Report; // structure of report variables - int FuelSupplyID; // index for fuel supply data structure - int DynamicsControlID; // index in GeneratorDynamics data where control issues are handled - int AvailabilitySchedID; // index for availability schedule - int CWLoopNum; // cooling water plant loop index number - int CWLoopSideNum; // cooling water plant loop side index - int CWBranchNum; // cooling water plant loop branch index - int CWCompNum; // cooling water plant loop component index - - // Default Constructor - MicroCHPDataStruct() - : ModelTypeAnnex42(true), NomEff(0.0), ZoneID(0), PlantInletNodeID(0), PlantOutletNodeID(0), PlantMassFlowRate(0.0), - PlantMassFlowRateMax(0.0), PlantMassFlowRateMaxWasAutoSized(false), AirInletNodeID(0), AirOutletNodeID(0), FuelSupplyID(0), - DynamicsControlID(0), AvailabilitySchedID(0), CWLoopNum(0), CWLoopSideNum(0), CWBranchNum(0), CWCompNum(0) - { - } - }; - // Object Data extern Array1D GasPhaseThermoChemistryData; extern Array1D FuelSupply; // fuel supply (reused across various) - extern Array1D MicroCHP; - extern Array1D MicroCHPParamInput; // Used during get input then put into nested extern Array1D GeneratorDynamics; void clear_state(); diff --git a/src/EnergyPlus/FuelCellElectricGenerator.cc b/src/EnergyPlus/FuelCellElectricGenerator.cc index 7ced33cc496..bc5cd0d61b6 100644 --- a/src/EnergyPlus/FuelCellElectricGenerator.cc +++ b/src/EnergyPlus/FuelCellElectricGenerator.cc @@ -3413,8 +3413,7 @@ namespace FuelCellElectricGenerator { if (NumFuelCellGenerators == 0) return; if (DataGlobals::BeginEnvrnFlag && MyEnvrnFlag) { - for (auto &e : DataGenerators::FuelSupply) - e.QskinLoss = 0.0; + for (auto &e : DataGenerators::FuelSupply) e.QskinLoss = 0.0; MyEnvrnFlag = false; for (int i = FuelCell.l(), e = FuelCell.u(); i <= e; ++i) { auto &cell(FuelCell(i)); From 146b005d80075d8090ddb7f43af74f47b47ecca8 Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Wed, 13 Nov 2019 15:40:31 -0700 Subject: [PATCH 41/51] inherit plant component --- src/EnergyPlus/FuelCellElectricGenerator.cc | 47 +++++++++++---------- src/EnergyPlus/FuelCellElectricGenerator.hh | 21 ++------- src/EnergyPlus/MicroCHPElectricGenerator.cc | 3 +- 3 files changed, 29 insertions(+), 42 deletions(-) diff --git a/src/EnergyPlus/FuelCellElectricGenerator.cc b/src/EnergyPlus/FuelCellElectricGenerator.cc index bc5cd0d61b6..f85092c975a 100644 --- a/src/EnergyPlus/FuelCellElectricGenerator.cc +++ b/src/EnergyPlus/FuelCellElectricGenerator.cc @@ -112,6 +112,11 @@ namespace FuelCellElectricGenerator { FuelCell.deallocate(); } + void FCDataStruct::simulate(const PlantLocation &calledFromLocation, bool FirstHVACIteration, Real64 &CurLoad, bool RunFlag) + { + + } + void SimFuelCellGenerator(int const EP_UNUSED(GeneratorType), // type of Generator std::string const &GeneratorName, // user specified name of Generator int &GeneratorIndex, @@ -1572,7 +1577,7 @@ namespace FuelCellElectricGenerator { DataGenerators::FuelSupply(this->FuelSupNum).QskinLoss = 0.0; } - // calculate tatal fuel enthalpy coming into power module + // calculate total fuel enthalpy coming into power module // (Hmolfuel in KJ/mol) Real64 Hmolfuel; // temp enthalpy of fuel mixture in KJ/mol @@ -1629,7 +1634,6 @@ namespace FuelCellElectricGenerator { this->WaterSup.PmpPowerLossFactor * this->WaterSup.PwaterCompEl; if (this->WaterSup.QskinLoss < 0.0) { - // write(*,*) 'problem in WaterSup%QskinLoss ',FuelCell(GeneratorNum)%WaterSup%QskinLoss this->WaterSup.QskinLoss = 0.0; } @@ -1684,7 +1688,7 @@ namespace FuelCellElectricGenerator { } } - if (this->FCPM.NdotAir <= 0.0) { // just pass through, domain probably collapased in modeling + if (this->FCPM.NdotAir <= 0.0) { // just pass through, domain probably collapsed in modeling this->AirSup.TairIntoFCPM = this->AirSup.TairIntoBlower; } else { @@ -1698,8 +1702,7 @@ namespace FuelCellElectricGenerator { this->AirSup.QskinLoss = this->AirSup.BlowerHeatLossFactor * this->AirSup.PairCompEl; if (this->AirSup.QskinLoss < 0.0) { - // write(*,*) 'problem in AirSup%QskinLoss ', FuelCell(GeneratorNum)%AirSup%QskinLoss - ShowWarningError("problem in AirSup%QskinLoss " + General::RoundSigDigits(this->AirSup.QskinLoss, 3)); + ShowWarningError("problem in AirSup.QskinLoss " + General::RoundSigDigits(this->AirSup.QskinLoss, 3)); this->AirSup.QskinLoss = 0.0; } @@ -1766,7 +1769,6 @@ namespace FuelCellElectricGenerator { } else if (SELECT_CASE_var == 4) { // all the H20 coming in plus the new H20 from reactions and the H20 from water used in reforming NdotH20 = NdotH20ProdGas + this->AirSup.ConstitMolalFract(thisGas) * this->FCPM.NdotAir; - //+ FuelCell(GeneratorNum)%FCPM%NdotLiqwater } else if (SELECT_CASE_var == 5) { // all the argon coming in. @@ -1783,7 +1785,7 @@ namespace FuelCellElectricGenerator { this->FCPM.ConstitMolalFract(1) = NdotCO2 / this->FCPM.NdotProdGas; - // all the nitrogen comming in + // all the nitrogen coming in this->FCPM.ConstitMolalFract(2) = NdotN2 / this->FCPM.NdotProdGas; // all the oxygen in the excess air stream @@ -1880,8 +1882,6 @@ namespace FuelCellElectricGenerator { // write(*,*) 'Number of Root Solver iterations: ', solverFlag } - // moved call to HeatBalanceInternalGains. Call FigureFuelCellZoneGains(GeneratorNum) - // Control Step 3 determine interaction with electrical storage // How much power is really going into inverter? Real64 PintoInverter = Pel + Pstorage; // Back out so we can reapply @@ -3439,39 +3439,40 @@ namespace FuelCellElectricGenerator { // first collect skin losses from different subsystems for (int FCnum = 1; FCnum <= NumFuelCellGenerators; ++FCnum) { - Real64 TotalZoneHeatGain = FuelCell(FCnum).AirSup.QskinLoss + DataGenerators::FuelSupply(FuelCell(FCnum).FuelSupNum).QskinLoss + - FuelCell(FCnum).WaterSup.QskinLoss + FuelCell(FCnum).AuxilHeat.QskinLoss + - FuelCell(FCnum).FCPM.QdotSkin; // intake Blower losses to zone | fuel compressor losses to zone | water pump losses to + auto &thisFC = FuelCell(FCnum); + Real64 TotalZoneHeatGain = thisFC.AirSup.QskinLoss + DataGenerators::FuelSupply(thisFC.FuelSupNum).QskinLoss + + thisFC.WaterSup.QskinLoss + thisFC.AuxilHeat.QskinLoss + + thisFC.FCPM.QdotSkin; // intake Blower losses to zone | fuel compressor losses to zone | water pump losses to // zone | auxil burner losses to zone | power module (stack and reformer) losses to // zone // now account for other subsystems that may or may not have air intake recovery { - auto const SELECT_CASE_var(FuelCell(FCnum).AirSup.IntakeRecoveryMode); + auto const SELECT_CASE_var(thisFC.AirSup.IntakeRecoveryMode); if (SELECT_CASE_var == DataGenerators::NoRecoveryOnAirIntake) { // then the heat has to go into zone TotalZoneHeatGain += - FuelCell(FCnum).AuxilHeat.QairIntake + FuelCell(FCnum).ElecStorage.QairIntake + FuelCell(FCnum).Inverter.QairIntake; + thisFC.AuxilHeat.QairIntake + thisFC.ElecStorage.QairIntake + thisFC.Inverter.QairIntake; } else if (SELECT_CASE_var == DataGenerators::RecoverAuxiliaryBurner) { - TotalZoneHeatGain += FuelCell(FCnum).ElecStorage.QairIntake + FuelCell(FCnum).Inverter.QairIntake; + TotalZoneHeatGain += thisFC.ElecStorage.QairIntake + thisFC.Inverter.QairIntake; } else if (SELECT_CASE_var == DataGenerators::RecoverInverterBatt) { - TotalZoneHeatGain += FuelCell(FCnum).AuxilHeat.QairIntake; + TotalZoneHeatGain += thisFC.AuxilHeat.QairIntake; } else if (SELECT_CASE_var == DataGenerators::RecoverInverter) { - TotalZoneHeatGain += FuelCell(FCnum).AuxilHeat.QairIntake + FuelCell(FCnum).ElecStorage.QairIntake; + TotalZoneHeatGain += thisFC.AuxilHeat.QairIntake + thisFC.ElecStorage.QairIntake; } else if (SELECT_CASE_var == DataGenerators::RecoverBattery) { - TotalZoneHeatGain += FuelCell(FCnum).AuxilHeat.QairIntake + FuelCell(FCnum).Inverter.QairIntake; + TotalZoneHeatGain += thisFC.AuxilHeat.QairIntake + thisFC.Inverter.QairIntake; } else if (SELECT_CASE_var == DataGenerators::RecoverBurnInvertBatt) { // do nothing } } - FuelCell(FCnum).QconvZone = TotalZoneHeatGain * (1 - FuelCell(FCnum).FCPM.RadiativeFract); - FuelCell(FCnum).Report.SkinLossConvect = FuelCell(FCnum).QconvZone; - FuelCell(FCnum).QradZone = TotalZoneHeatGain * FuelCell(FCnum).FCPM.RadiativeFract; - FuelCell(FCnum).Report.SkinLossRadiat = FuelCell(FCnum).QradZone; + thisFC.QconvZone = TotalZoneHeatGain * (1 - thisFC.FCPM.RadiativeFract); + thisFC.Report.SkinLossConvect = thisFC.QconvZone; + thisFC.QradZone = TotalZoneHeatGain * thisFC.FCPM.RadiativeFract; + thisFC.Report.SkinLossRadiat = thisFC.QradZone; } // over number of Fuel cells } @@ -3573,7 +3574,7 @@ namespace FuelCellElectricGenerator { this->Report.PCUlosses = this->Inverter.PCUlosses; // inverter losses this->Report.DCPowerGen = this->FCPM.Pel; // DC power out of FCPM. - this->Report.DCPowerEff = this->FCPM.Eel; // FCPM efficienty Eel. + this->Report.DCPowerEff = this->FCPM.Eel; // FCPM efficiency Eel. this->Report.ElectEnergyinStorage = this->ElecStorage.ThisTimeStepStateOfCharge; this->Report.StoredPower = this->ElecStorage.PelIntoStorage; this->Report.StoredEnergy = this->ElecStorage.PelIntoStorage * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; diff --git a/src/EnergyPlus/FuelCellElectricGenerator.hh b/src/EnergyPlus/FuelCellElectricGenerator.hh index 2bb09c077a1..728fd6248a4 100644 --- a/src/EnergyPlus/FuelCellElectricGenerator.hh +++ b/src/EnergyPlus/FuelCellElectricGenerator.hh @@ -53,6 +53,7 @@ // EnergyPlus Headers #include +#include namespace EnergyPlus { @@ -60,8 +61,6 @@ namespace FuelCellElectricGenerator { struct FCPowerModuleStruct { - // Members - // user input data std::string Name; // name of this PowerModule data int EffMode; // mode for efficiency curves int EffCurveID; // pointer to curve for efficiency @@ -146,8 +145,6 @@ namespace FuelCellElectricGenerator { struct FCAirSupplyDataStruct { - // Members - // user input data std::string Name; // name of this std::string NodeName; // Air supply node name int SupNodeNum; // Air supply node ID @@ -184,7 +181,6 @@ namespace FuelCellElectricGenerator { struct FCWaterSupplyDataStruct { - // Members std::string Name; // name of this water supply module int WaterTempMode; // temperature of water inlet determination std::string NodeName; // node name for temperature at input @@ -210,7 +206,6 @@ namespace FuelCellElectricGenerator { struct FCAuxilHeatDataStruct { - // Members std::string Name; // name of this auxiliary heating module std::string ZoneName; int ZoneID; @@ -243,8 +238,6 @@ namespace FuelCellElectricGenerator { struct FCExhaustHXDataStruct { - // Members - // user defined variables std::string Name; // name of this exhaust gas heat recovery std::string WaterInNodeName; // HR Water Inlet Node int WaterInNode; // HR Water Outlet Node ID @@ -299,8 +292,6 @@ namespace FuelCellElectricGenerator { struct BatteryDichargeDataStruct { - // Members - // user defined variables std::string Name; // name of this battery data set Real64 NumInSeries; Real64 NumInParallel; @@ -323,8 +314,6 @@ namespace FuelCellElectricGenerator { struct FCElecStorageDataStruct { - // Members - // user defined variables std::string Name; // name of this electrical storage module int StorageModelMode; Real64 StartingEnergyStored; // joules inside @@ -357,8 +346,6 @@ namespace FuelCellElectricGenerator { struct FCInverterDataStruct { - // Members - // user-defined data std::string Name; // name of this inverter int EffMode; // efficiency calculation mode Real64 ConstEff; @@ -468,8 +455,6 @@ namespace FuelCellElectricGenerator { struct FCStackCoolerDataStruct { - // Members - // user input data std::string Name; // name of this stack cooler module std::string WaterInNodeName; // HR Water Inlet Node int WaterInNode; // HR Water Outlet Node ID @@ -507,7 +492,7 @@ namespace FuelCellElectricGenerator { } }; - struct FCDataStruct + struct FCDataStruct : PlantComponent { // Members // from input data and nested types for subsystems @@ -557,6 +542,8 @@ namespace FuelCellElectricGenerator { void setupOutputVars(); + void simulate(const PlantLocation &calledFromLocation, bool FirstHVACIteration, Real64 &CurLoad, bool RunFlag) override; + void FigureAirHeatCap(Real64 FluidTemp, Real64 &Cp); void FigureAirEnthalpy(Real64 FluidTemp, Real64 &Hair); diff --git a/src/EnergyPlus/MicroCHPElectricGenerator.cc b/src/EnergyPlus/MicroCHPElectricGenerator.cc index 57cc53634bf..2aa4d050709 100644 --- a/src/EnergyPlus/MicroCHPElectricGenerator.cc +++ b/src/EnergyPlus/MicroCHPElectricGenerator.cc @@ -1265,8 +1265,7 @@ namespace MicroCHPElectricGenerator { if (NumMicroCHPs == 0) return; if (DataGlobals::BeginEnvrnFlag && MyEnvrnFlag) { - for (auto &e : DataGenerators::FuelSupply) - e.QskinLoss = 0.0; + for (auto &e : DataGenerators::FuelSupply) e.QskinLoss = 0.0; for (auto &e : MicroCHP) { e.A42Model.QdotSkin = 0.0; e.A42Model.SkinLossConvect = 0.0; From 1865241b86cf39700fbc9391f4a9818300c97432 Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Wed, 13 Nov 2019 21:18:25 -0700 Subject: [PATCH 42/51] factory and integrate into elecPowerServiceMgr --- src/EnergyPlus/ElectricPowerServiceManager.cc | 11 +- src/EnergyPlus/FuelCellElectricGenerator.cc | 121 +++++++----------- src/EnergyPlus/FuelCellElectricGenerator.hh | 29 ++--- 3 files changed, 58 insertions(+), 103 deletions(-) diff --git a/src/EnergyPlus/ElectricPowerServiceManager.cc b/src/EnergyPlus/ElectricPowerServiceManager.cc index e180d35fcc5..8829c413a85 100644 --- a/src/EnergyPlus/ElectricPowerServiceManager.cc +++ b/src/EnergyPlus/ElectricPowerServiceManager.cc @@ -2145,12 +2145,11 @@ void GeneratorController::simGeneratorGetPowerOutput(bool const runFlag, break; } case GeneratorType::fuelCell: { - FuelCellElectricGenerator::SimFuelCellGenerator( - DataGlobalConstants::iGeneratorFuelCell, name, generatorIndex, runFlag, myElecLoadRequest, FirstHVACIteration); - FuelCellElectricGenerator::GetFuelCellGeneratorResults( - DataGlobalConstants::iGeneratorFuelCell, generatorIndex, electProdRate, electricityProd, thermProdRate, thermalProd); - electricPowerOutput = electProdRate; - thermalPowerOutput = thermProdRate; + auto thisFC = FuelCellElectricGenerator::FCDataStruct::factory(name); + dynamic_cast (thisFC)->initialize(); + dynamic_cast (thisFC)->SimFuelCellGenerator(runFlag, myElecLoadRequest, FirstHVACIteration); + electricPowerOutput = dynamic_cast (thisFC)->Report.ACPowerGen; + thermalPowerOutput = dynamic_cast (thisFC)->Report.qHX; break; } case GeneratorType::microCHP: { diff --git a/src/EnergyPlus/FuelCellElectricGenerator.cc b/src/EnergyPlus/FuelCellElectricGenerator.cc index f85092c975a..3ca255e82aa 100644 --- a/src/EnergyPlus/FuelCellElectricGenerator.cc +++ b/src/EnergyPlus/FuelCellElectricGenerator.cc @@ -100,27 +100,44 @@ namespace FuelCellElectricGenerator { // IEA/ECBCS Annex 42 model specification for Solid oxide and proton exchange membrane fuel cells int NumFuelCellGenerators(0); - bool GetFuelCellInput(true); + bool getFuelCellInputFlag(true); Array1D_bool CheckEquipName; Array1D FuelCell; // dimension to number of machines void clear_state() { NumFuelCellGenerators = 0; - GetFuelCellInput = true; + getFuelCellInputFlag = true; CheckEquipName.deallocate(); FuelCell.deallocate(); } + PlantComponent *FCDataStruct::factory(std::string const &objectName) + { + // Process the input data + if (getFuelCellInputFlag) { + getFuelCellInput(); + getFuelCellInputFlag = false; + } + + // Now look for this object + for (auto &thisFC : FuelCell) { + if (thisFC.Name == objectName) { + return &thisFC; + } + } + // If we didn't find it, fatal + ShowFatalError("LocalFuelCellGenFactory: Error getting inputs for object named: " + objectName); // LCOV_EXCL_LINE + // Shut up the compiler + return nullptr; // LCOV_EXCL_LINE + } + void FCDataStruct::simulate(const PlantLocation &calledFromLocation, bool FirstHVACIteration, Real64 &CurLoad, bool RunFlag) { } - void SimFuelCellGenerator(int const EP_UNUSED(GeneratorType), // type of Generator - std::string const &GeneratorName, // user specified name of Generator - int &GeneratorIndex, - bool const RunFlag, // simulate Generator when TRUE + void FCDataStruct::SimFuelCellGenerator(bool const RunFlag, // simulate Generator when TRUE Real64 const MyLoad, // demand on electric generator bool const FirstHVACIteration) { @@ -133,40 +150,13 @@ namespace FuelCellElectricGenerator { // gets the input for the models, initializes simulation variables, call // the appropriate model and sets up reporting variables. - int GenNum; // Generator number counter - - // Get Generator data from input file - if (GetFuelCellInput) { - GetFuelCellGeneratorInput(); - GetFuelCellInput = false; - } - - if (GeneratorIndex == 0) { - GenNum = UtilityRoutines::FindItemInList(GeneratorName, FuelCell); - if (GenNum == 0) ShowFatalError("SimFuelCellGenerator: Specified Generator not one of Valid FuelCell Generators " + GeneratorName); - GeneratorIndex = GenNum; - } else { - GenNum = GeneratorIndex; - if (GenNum > NumFuelCellGenerators || GenNum < 1) { - ShowFatalError("SimFuelCellGenerator: Invalid GeneratorIndex passed=" + General::TrimSigDigits(GenNum) + - ", Number of FuelCell Generators=" + General::TrimSigDigits(NumFuelCellGenerators) + ", Generator name=" + GeneratorName); - } - if (CheckEquipName(GenNum)) { - if (GeneratorName != FuelCell(GenNum).Name) { - ShowFatalError("SimFuelCellGenerator: Invalid GeneratorIndex passed=" + General::TrimSigDigits(GenNum) + - ", Generator name=" + GeneratorName + ", stored Generator Name for that index=" + FuelCell(GenNum).Name); - } - CheckEquipName(GenNum) = false; - } - } - - FuelCell(GenNum).initialize(); - FuelCell(GenNum).CalcFuelCellGeneratorModel(GenNum, RunFlag, MyLoad, FirstHVACIteration); - FuelCell(GenNum).CalcUpdateHeatRecovery(FirstHVACIteration); - FuelCell(GenNum).UpdateFuelCellGeneratorRecords(); + this->initialize(); + this->CalcFuelCellGeneratorModel(RunFlag, MyLoad, FirstHVACIteration); + this->CalcUpdateHeatRecovery(FirstHVACIteration); + this->UpdateFuelCellGeneratorRecords(); } - void GetFuelCellGeneratorInput() + void getFuelCellInput() { // SUBROUTINE INFORMATION: // AUTHOR: Brent Griffith @@ -1365,7 +1355,7 @@ namespace FuelCellElectricGenerator { } } - void FCDataStruct::CalcFuelCellGeneratorModel(int const GeneratorNum, bool const RunFlag, Real64 const MyLoad, bool const EP_UNUSED(FirstHVACIteration)) + void FCDataStruct::CalcFuelCellGeneratorModel(bool const RunFlag, Real64 const MyLoad, bool const EP_UNUSED(FirstHVACIteration)) { // SUBROUTINE INFORMATION: // AUTHOR Brent Griffith @@ -1863,12 +1853,12 @@ namespace FuelCellElectricGenerator { Real64 Acc = 0.01; // guessing need to refine int MaxIter = 150; // guessing need to refine SolverFlag = 0; // init - Array1D Par(3); // parameters passed in to SolveRoot - Par(1) = double(GeneratorNum); - Par(2) = tmpTotProdGasEnthalpy; - Par(3) = this->FCPM.NdotProdGas; + Array1D Par(2); // parameters passed in to SolveRoot + Par(1) = tmpTotProdGasEnthalpy; + Par(2) = this->FCPM.NdotProdGas; Real64 tmpTprodGas = this->FCPM.TprodGasLeavingFCPM; - General::SolveRoot(Acc, MaxIter, SolverFlag, tmpTprodGas, this->FuelCellProductGasEnthResidual, DataGenerators::MinProductGasTemp, DataGenerators::MaxProductGasTemp, Par); + auto boundFunc = std::bind(&FCDataStruct::FuelCellProductGasEnthResidual, this, std::placeholders::_1, std::placeholders::_2); + General::SolveRoot(Acc, MaxIter, SolverFlag, tmpTprodGas, boundFunc, DataGenerators::MinProductGasTemp, DataGenerators::MaxProductGasTemp, Par); if (SolverFlag == -2) { @@ -2105,11 +2095,10 @@ namespace FuelCellElectricGenerator { Real64 Residuum; // F(x) Real64 thisHmolalProdGases; - int GeneratorNum = std::floor(Par(1)); - Real64 desiredHprodGases = Par(2); - Real64 NdotProdGases = Par(3); + Real64 desiredHprodGases = Par(1); + Real64 NdotProdGases = Par(2); - FuelCell(GeneratorNum).FigureProductGasesEnthalpy(TprodGas, thisHmolalProdGases); + this->FigureProductGasesEnthalpy(TprodGas, thisHmolalProdGases); Residuum = (thisHmolalProdGases * NdotProdGases * 1000000.0) - desiredHprodGases; @@ -3162,9 +3151,9 @@ namespace FuelCellElectricGenerator { // makes sure input are gotten and setup from Plant loop perspective. // does not (re)simulate entire FuelCell model - if (GetFuelCellInput) { - GetFuelCellGeneratorInput(); - GetFuelCellInput = false; + if (getFuelCellInputFlag) { + getFuelCellInput(); + getFuelCellInputFlag = false; } if (InitLoopEquip) { @@ -3380,9 +3369,9 @@ namespace FuelCellElectricGenerator { std::string &heatRecoveryCompName) { - if (GetFuelCellInput) { - GetFuelCellGeneratorInput(); - GetFuelCellInput = false; + if (getFuelCellInputFlag) { + getFuelCellInput(); + getFuelCellInputFlag = false; } int thisFuelCell = UtilityRoutines::FindItemInList(GeneratorName, FuelCell); @@ -3587,30 +3576,6 @@ namespace FuelCellElectricGenerator { this->Report.SkinLossRadiat = this->QradZone; } - void GetFuelCellGeneratorResults(int const EP_UNUSED(GeneratorType), // type of Generator - int const GeneratorIndex, - Real64 &GeneratorPower, // electrical power - Real64 &GeneratorEnergy, // electrical energy - Real64 &ThermalPower, // heat power - Real64 &ThermalEnergy // heat energy - ) - { - - // SUBROUTINE INFORMATION: - // AUTHOR B. Griffith - // DATE WRITTEN March 2008 - // MODIFIED na - // RE-ENGINEERED na - - // PURPOSE OF THIS SUBROUTINE: - // provide a get method to collect results at the load center level - - GeneratorPower = FuelCell(GeneratorIndex).Report.ACPowerGen; - GeneratorEnergy = FuelCell(GeneratorIndex).Report.ACEnergyGen; - ThermalPower = FuelCell(GeneratorIndex).Report.qHX; - ThermalEnergy = FuelCell(GeneratorIndex).Report.HXenergy; - } - } // namespace FuelCellElectricGenerator } // namespace EnergyPlus diff --git a/src/EnergyPlus/FuelCellElectricGenerator.hh b/src/EnergyPlus/FuelCellElectricGenerator.hh index 728fd6248a4..949aaef9db1 100644 --- a/src/EnergyPlus/FuelCellElectricGenerator.hh +++ b/src/EnergyPlus/FuelCellElectricGenerator.hh @@ -538,6 +538,8 @@ namespace FuelCellElectricGenerator { { } + static PlantComponent *factory(std::string const &objectName); + void initialize(); void setupOutputVars(); @@ -567,7 +569,7 @@ namespace FuelCellElectricGenerator { Real64 &PelDiff // if constrained then this is the difference, positive ); - static Real64 FuelCellProductGasEnthResidual(Real64 TprodGas, Array1 const &Par); + Real64 FuelCellProductGasEnthResidual(Real64 TprodGas, Array1 const &Par); static void FigureGaseousWaterEnthalpy(Real64 FluidTemp, Real64 &HGasWater); @@ -579,7 +581,7 @@ namespace FuelCellElectricGenerator { void CalcFuelCellGenHeatRecovery(); - void CalcFuelCellGeneratorModel(int GeneratorNum, bool RunFlag, Real64 MyLoad, bool FirstHVACIteration); + void CalcFuelCellGeneratorModel(bool RunFlag, Real64 MyLoad, bool FirstHVACIteration); void CalcUpdateHeatRecovery(bool FirstHVACIteration); @@ -590,19 +592,16 @@ namespace FuelCellElectricGenerator { Real64 &PgridOverage // electricity that can't be stored and needs to go out ); + void SimFuelCellGenerator(bool RunFlag, // simulate Generator when TRUE + Real64 MyLoad, // demand on electric generator + bool FirstHVACIteration); + void UpdateFuelCellGeneratorRecords(); }; void clear_state(); - void SimFuelCellGenerator(int GeneratorType, // type of Generator - std::string const &GeneratorName, // user specified name of Generator - int &GeneratorIndex, - bool RunFlag, // simulate Generator when TRUE - Real64 MyLoad, // demand on electric generator - bool FirstHVACIteration); - - void GetFuelCellGeneratorInput(); + void getFuelCellInput(); void SimFuelCellPlantHeatRecovery(std::string const &CompType, std::string const &CompName, @@ -622,15 +621,7 @@ namespace FuelCellElectricGenerator { void FigureFuelCellZoneGains(); - void GetFuelCellGeneratorResults(int GeneratorType, // type of Generator - int GeneratorIndex, - Real64 &GeneratorPower, // electrical power - Real64 &GeneratorEnergy, // electrical energy - Real64 &ThermalPower, // heat power - Real64 &ThermalEnergy // heat energy - ); - - extern bool GetFuelCellInput; + extern bool getFuelCellInputFlag; extern int NumFuelCellGenerators; extern Array1D_bool CheckEquipName; extern Array1D FuelCell; // dimension to number of machines From 64596ec38c362cb7f16caf0c3d864bc52a463b37 Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Thu, 14 Nov 2019 15:16:20 -0700 Subject: [PATCH 43/51] integrate plantCompPtr --- src/EnergyPlus/ElectricPowerServiceManager.cc | 7 +- src/EnergyPlus/FuelCellElectricGenerator.cc | 120 +++++++----------- src/EnergyPlus/FuelCellElectricGenerator.hh | 26 +--- src/EnergyPlus/Plant/PlantManager.cc | 7 +- src/EnergyPlus/PlantLoopEquip.cc | 39 +----- 5 files changed, 65 insertions(+), 134 deletions(-) diff --git a/src/EnergyPlus/ElectricPowerServiceManager.cc b/src/EnergyPlus/ElectricPowerServiceManager.cc index 8829c413a85..157d04ac3d9 100644 --- a/src/EnergyPlus/ElectricPowerServiceManager.cc +++ b/src/EnergyPlus/ElectricPowerServiceManager.cc @@ -1977,7 +1977,6 @@ GeneratorController::GeneratorController(std::string const &objectName, { std::string const routineName = "GeneratorController constructor "; - bool errorsFound = false; name = objectName; typeOfName = objectType; @@ -2012,7 +2011,8 @@ GeneratorController::GeneratorController(std::string const &objectName, // exhaust gas HX is required and it assumed that it has more thermal capacity and is used for control compPlantTypeOf_Num = DataPlant::TypeOf_Generator_FCExhaust; // and the name of plant component is not the same as the generator because of child object references, so fetch that name - FuelCellElectricGenerator::getFuelCellGeneratorHeatRecoveryInfo(name, compPlantName); + auto thisFC = FuelCellElectricGenerator::FCDataStruct::factory(name); + compPlantName = dynamic_cast (thisFC)->ExhaustHX.Name; } else if (UtilityRoutines::SameString(objectType, "Generator:MicroCHP")) { generatorType = GeneratorType::microCHP; compGenTypeOf_Num = DataGlobalConstants::iGeneratorMicroCHP; @@ -2025,7 +2025,6 @@ GeneratorController::GeneratorController(std::string const &objectName, } else { ShowSevereError(routineName + DataIPShortCuts::cCurrentModuleObject + " invalid entry."); ShowContinueError("Invalid " + objectType + " associated with generator = " + objectName); - errorsFound = true; } availSched = availSchedName; @@ -2037,7 +2036,6 @@ GeneratorController::GeneratorController(std::string const &objectName, ShowSevereError(routineName + DataIPShortCuts::cCurrentModuleObject + ", invalid entry."); ShowContinueError("Invalid availability schedule = " + availSchedName); ShowContinueError("Schedule was not found "); - errorsFound = true; } else { if (generatorType == GeneratorType::pvWatts) { ShowWarningError(routineName + DataIPShortCuts::cCurrentModuleObject + ", Availability Schedule for Generator:PVWatts '" + objectName + "' will be be ignored (runs all the time)."); @@ -2146,7 +2144,6 @@ void GeneratorController::simGeneratorGetPowerOutput(bool const runFlag, } case GeneratorType::fuelCell: { auto thisFC = FuelCellElectricGenerator::FCDataStruct::factory(name); - dynamic_cast (thisFC)->initialize(); dynamic_cast (thisFC)->SimFuelCellGenerator(runFlag, myElecLoadRequest, FirstHVACIteration); electricPowerOutput = dynamic_cast (thisFC)->Report.ACPowerGen; thermalPowerOutput = dynamic_cast (thisFC)->Report.qHX; diff --git a/src/EnergyPlus/FuelCellElectricGenerator.cc b/src/EnergyPlus/FuelCellElectricGenerator.cc index 3ca255e82aa..6723f26742b 100644 --- a/src/EnergyPlus/FuelCellElectricGenerator.cc +++ b/src/EnergyPlus/FuelCellElectricGenerator.cc @@ -132,9 +132,23 @@ namespace FuelCellElectricGenerator { return nullptr; // LCOV_EXCL_LINE } - void FCDataStruct::simulate(const PlantLocation &calledFromLocation, bool FirstHVACIteration, Real64 &CurLoad, bool RunFlag) - { + PlantComponent *FCDataStruct::factory_exhaust(std::string const &objectName){ + // Process the input data + if (getFuelCellInputFlag) { + getFuelCellInput(); + getFuelCellInputFlag = false; + } + // Now look for this object + for (auto &thisFC : FuelCell) { + if (UtilityRoutines::MakeUPPERCase(thisFC.NameExhaustHX) == UtilityRoutines::MakeUPPERCase(objectName)) { + return &thisFC; + } + } + // If we didn't find it, fatal + ShowFatalError("LocalFuelCellGenFactory: Error getting inputs for object named: " + objectName); // LCOV_EXCL_LINE + // Shut up the compiler + return nullptr; // LCOV_EXCL_LINE } void FCDataStruct::SimFuelCellGenerator(bool const RunFlag, // simulate Generator when TRUE @@ -498,7 +512,7 @@ namespace FuelCellElectricGenerator { } for (int GeneratorNum = 1; GeneratorNum <= NumFuelCellGenerators; ++GeneratorNum) { - // find molal fraction of oxygen in air supply + // find molar fraction of oxygen in air supply int thisConstituent = UtilityRoutines::FindItem("Oxygen", FuelCell(GeneratorNum).AirSup.ConstitName, FuelCell(GeneratorNum).AirSup.NumConstituents); if (thisConstituent > 0) FuelCell(GeneratorNum).AirSup.O2fraction = FuelCell(GeneratorNum).AirSup.ConstitMolalFract(thisConstituent); @@ -513,7 +527,7 @@ namespace FuelCellElectricGenerator { FuelCell(GeneratorNum).AirSup.GasLibID(i) = thisGasID; } - // set up gas constiuents for product gases + // set up gas constituents for product gases FuelCell(GeneratorNum).FCPM.GasLibID(1) = 1; // Carbon Dioxide FuelCell(GeneratorNum).FCPM.GasLibID(2) = 2; // Nitrogen FuelCell(GeneratorNum).FCPM.GasLibID(3) = 3; // Oxygen @@ -3127,72 +3141,38 @@ namespace FuelCellElectricGenerator { this->ExhaustHX.WaterOutletEnthalpy = DataLoopNode::Node(this->ExhaustHX.WaterInNode).Enthalpy + this->ExhaustHX.qHX; } - void SimFuelCellPlantHeatRecovery(std::string const &EP_UNUSED(CompType), - std::string const &CompName, - int const CompTypeNum, - int &CompNum, - bool const EP_UNUSED(RunFlag), - bool &InitLoopEquip, - Real64 &EP_UNUSED(MyLoad), // unused1208 - Real64 &MaxCap, - Real64 &MinCap, - Real64 &OptCap, - bool const FirstHVACIteration // TRUE if First iteration of simulation - ) - { - - // SUBROUTINE INFORMATION: - // AUTHOR B. Griffith - // DATE WRITTEN Jan 2006 - // MODIFIED na - // RE-ENGINEERED na - // PURPOSE OF THIS SUBROUTINE: - // makes sure input are gotten and setup from Plant loop perspective. - // does not (re)simulate entire FuelCell model - - if (getFuelCellInputFlag) { - getFuelCellInput(); - getFuelCellInputFlag = false; - } + void FCDataStruct::getDesignCapacities(const PlantLocation &EP_UNUSED(calledFromLocation), Real64 &MaxLoad, Real64 &MinLoad, Real64 &OptLoad) + { + MaxLoad = 0.0; + MinLoad = 0.0; + OptLoad = 0.0; + } - if (InitLoopEquip) { - if (CompTypeNum == DataPlant::TypeOf_Generator_FCExhaust) { - CompNum = UtilityRoutines::FindItemInList(CompName, FuelCell, &FCDataStruct::NameExhaustHX); - } else if (CompTypeNum == DataPlant::TypeOf_Generator_FCStackCooler) { - CompNum = UtilityRoutines::FindItemInList(CompName, FuelCell, &FCDataStruct::NameStackCooler); - } - if (CompNum == 0) { - ShowFatalError("SimFuelCellPlantHeatRecovery: Fuel Cell Generator Unit not found=" + CompName); - } - MinCap = 0.0; - MaxCap = 0.0; - OptCap = 0.0; - return; - } // End Of InitLoopEquip - - if (CompTypeNum == DataPlant::TypeOf_Generator_FCStackCooler) { - PlantUtilities::UpdateComponentHeatRecoverySide(FuelCell(CompNum).CWLoopNum, - FuelCell(CompNum).CWLoopSideNum, - DataPlant::TypeOf_Generator_FCStackCooler, - FuelCell(CompNum).StackCooler.WaterInNode, - FuelCell(CompNum).StackCooler.WaterOutNode, - FuelCell(CompNum).Report.qHX, - FuelCell(CompNum).Report.HeatRecInletTemp, - FuelCell(CompNum).Report.HeatRecOutletTemp, - FuelCell(CompNum).Report.HeatRecMdot, - FirstHVACIteration); - } else if (CompTypeNum == DataPlant::TypeOf_Generator_FCExhaust) { - PlantUtilities::UpdateComponentHeatRecoverySide(FuelCell(CompNum).CWLoopNum, - FuelCell(CompNum).CWLoopSideNum, - DataPlant::TypeOf_Generator_FCExhaust, - FuelCell(CompNum).ExhaustHX.WaterInNode, - FuelCell(CompNum).ExhaustHX.WaterOutNode, - FuelCell(CompNum).ExhaustHX.qHX, - FuelCell(CompNum).ExhaustHX.WaterInletTemp, - FuelCell(CompNum).ExhaustHX.WaterOutletTemp, - FuelCell(CompNum).ExhaustHX.WaterMassFlowRate, - FirstHVACIteration); + void FCDataStruct::simulate(const PlantLocation &EP_UNUSED(calledFromLocation), bool FirstHVACIteration, Real64 &EP_UNUSED(CurLoad), bool EP_UNUSED(RunFlag)) + { + if (this->TypeOf == DataPlant::TypeOf_Generator_FCStackCooler) { + PlantUtilities::UpdateComponentHeatRecoverySide(this->CWLoopNum, + this->CWLoopSideNum, + DataPlant::TypeOf_Generator_FCStackCooler, + this->StackCooler.WaterInNode, + this->StackCooler.WaterOutNode, + this->Report.qHX, + this->Report.HeatRecInletTemp, + this->Report.HeatRecOutletTemp, + this->Report.HeatRecMdot, + FirstHVACIteration); + } else if (this->TypeOf == DataPlant::TypeOf_Generator_FCExhaust) { + PlantUtilities::UpdateComponentHeatRecoverySide(this->CWLoopNum, + this->CWLoopSideNum, + DataPlant::TypeOf_Generator_FCExhaust, + this->ExhaustHX.WaterInNode, + this->ExhaustHX.WaterOutNode, + this->ExhaustHX.qHX, + this->ExhaustHX.WaterInletTemp, + this->ExhaustHX.WaterOutletTemp, + this->ExhaustHX.WaterMassFlowRate, + FirstHVACIteration); } } @@ -3213,10 +3193,6 @@ namespace FuelCellElectricGenerator { static std::string const RoutineName("InitFuelCellGenerators"); - if (this->InitGenerator) { - this->InitGenerator = false; - } - if (this->MyPlantScanFlag_Init && allocated(DataPlant::PlantLoop)) { bool errFlag = false; diff --git a/src/EnergyPlus/FuelCellElectricGenerator.hh b/src/EnergyPlus/FuelCellElectricGenerator.hh index 949aaef9db1..457d717cfd6 100644 --- a/src/EnergyPlus/FuelCellElectricGenerator.hh +++ b/src/EnergyPlus/FuelCellElectricGenerator.hh @@ -496,6 +496,7 @@ namespace FuelCellElectricGenerator { { // Members // from input data and nested types for subsystems + int TypeOf; std::string Name; // user identifier std::string NameFCPM; // name of FC Power Module FCPowerModuleStruct FCPM; // data for Power Module @@ -526,22 +527,25 @@ namespace FuelCellElectricGenerator { Real64 QradZone; // radiative heat lost to surrounding zone int DynamicsControlID; Real64 TimeElapsed; // used to track when timestep has changed - bool InitGenerator; bool MyEnvrnFlag_Init; bool MyWarmupFlag_Init; bool MyPlantScanFlag_Init; // Default Constructor FCDataStruct() - : FuelSupNum(0), CWLoopNum(0), CWLoopSideNum(0), CWBranchNum(0), CWCompNum(0), ACPowerGen(0.0), QconvZone(0.0), QradZone(0.0), - DynamicsControlID(0), TimeElapsed(0.0), InitGenerator(true), MyEnvrnFlag_Init(true), MyWarmupFlag_Init(false), MyPlantScanFlag_Init(true) + : TypeOf(0), FuelSupNum(0), CWLoopNum(0), CWLoopSideNum(0), CWBranchNum(0), CWCompNum(0), ACPowerGen(0.0), QconvZone(0.0), QradZone(0.0), + DynamicsControlID(0), TimeElapsed(0.0), MyEnvrnFlag_Init(true), MyWarmupFlag_Init(false), MyPlantScanFlag_Init(true) { } static PlantComponent *factory(std::string const &objectName); + static PlantComponent *factory_exhaust(std::string const &objectName); + void initialize(); + void getDesignCapacities(const PlantLocation &calledFromLocation, Real64 &MaxLoad, Real64 &MinLoad, Real64 &OptLoad) override; + void setupOutputVars(); void simulate(const PlantLocation &calledFromLocation, bool FirstHVACIteration, Real64 &CurLoad, bool RunFlag) override; @@ -603,22 +607,6 @@ namespace FuelCellElectricGenerator { void getFuelCellInput(); - void SimFuelCellPlantHeatRecovery(std::string const &CompType, - std::string const &CompName, - int CompTypeNum, - int &CompNum, - bool RunFlag, - bool &InitLoopEquip, - Real64 &MyLoad, // unused1208 - Real64 &MaxCap, - Real64 &MinCap, - Real64 &OptCap, - bool FirstHVACIteration // TRUE if First iteration of simulation - ); - - void getFuelCellGeneratorHeatRecoveryInfo(std::string const &GeneratorName, // user specified name of Generator - std::string &heatRecoveryCompName); - void FigureFuelCellZoneGains(); extern bool getFuelCellInputFlag; diff --git a/src/EnergyPlus/Plant/PlantManager.cc b/src/EnergyPlus/Plant/PlantManager.cc index 7265da82e93..a38b7899515 100644 --- a/src/EnergyPlus/Plant/PlantManager.cc +++ b/src/EnergyPlus/Plant/PlantManager.cc @@ -73,6 +73,7 @@ #include #include #include +#include #include #include #include @@ -1134,10 +1135,10 @@ namespace EnergyPlus { this_comp.TypeOf_Num = TypeOf_CoolingTower_VarSpdMerkel; this_comp.GeneralEquipType = GenEquipTypes_CoolingTower; this_comp.compPtr = CondenserLoopTowers::CoolingTower::factory(CompNames(CompNum)); - } else if (UtilityRoutines::SameString(this_comp_type, - "Generator:FuelCell:ExhaustGasToWaterHeatExchanger")) { + } else if (UtilityRoutines::SameString(this_comp_type, "Generator:FuelCell:ExhaustGasToWaterHeatExchanger")) { this_comp.TypeOf_Num = TypeOf_Generator_FCExhaust; this_comp.GeneralEquipType = GenEquipTypes_Generator; + this_comp.compPtr = FuelCellElectricGenerator::FCDataStruct::factory_exhaust(CompNames(CompNum)); if (LoopSideNum == DemandSide) { this_comp.CurOpSchemeType = DemandOpSchemeType; } else if (LoopSideNum == SupplySide) { @@ -1295,6 +1296,7 @@ namespace EnergyPlus { } else if (UtilityRoutines::SameString(this_comp_type, "Generator:FuelCell:StackCooler")) { this_comp.TypeOf_Num = TypeOf_Generator_FCStackCooler; this_comp.GeneralEquipType = GenEquipTypes_Generator; + this_comp.compPtr = FuelCellElectricGenerator::FCDataStruct::factory(CompNames(CompNum)); if (LoopSideNum == DemandSide) { this_comp.CurOpSchemeType = DemandOpSchemeType; } else if (LoopSideNum == SupplySide) { @@ -1305,7 +1307,6 @@ namespace EnergyPlus { this_comp.GeneralEquipType = GenEquipTypes_FluidCooler; this_comp.compPtr = FluidCoolers::FluidCoolerspecs::factory( TypeOf_FluidCooler_SingleSpd, CompNames(CompNum)); - // } else if (UtilityRoutines::SameString(this_comp_type, "FluidCooler:TwoSpeed")) { this_comp.TypeOf_Num = TypeOf_FluidCooler_TwoSpd; this_comp.GeneralEquipType = GenEquipTypes_FluidCooler; diff --git a/src/EnergyPlus/PlantLoopEquip.cc b/src/EnergyPlus/PlantLoopEquip.cc index 8b1aa7ff179..c49189216ae 100644 --- a/src/EnergyPlus/PlantLoopEquip.cc +++ b/src/EnergyPlus/PlantLoopEquip.cc @@ -187,7 +187,6 @@ namespace PlantLoopEquip { using Pumps::SimPumps; using ScheduleManager::GetCurrentScheduleValue; using WaterThermalTanks::SimWaterThermalTank; - using FuelCellElectricGenerator::SimFuelCellPlantHeatRecovery; using PlantHeatExchangerFluidToFluid::SimFluidHeatExchanger; using BaseboardRadiator::UpdateBaseboardPlantConnection; using HVACVariableRefrigerantFlow::SimVRFCondenserPlant; @@ -811,42 +810,12 @@ namespace PlantLoopEquip { // for heat recovery plant interactions. if (EquipTypeNum == TypeOf_Generator_FCExhaust) { - SimFuelCellPlantHeatRecovery(sim_component.TypeOf, - sim_component.Name, - TypeOf_Generator_FCExhaust, - EquipNum, - RunFlag, - InitLoopEquip, - CurLoad, - MaxLoad, - MinLoad, - OptLoad, - FirstHVACIteration); // DSU - if (InitLoopEquip) { - sim_component.MaxLoad = MaxLoad; - sim_component.MinLoad = MinLoad; - sim_component.OptLoad = OptLoad; - sim_component.CompNum = EquipNum; - } + dynamic_cast (sim_component.compPtr)->TypeOf = DataPlant::TypeOf_Generator_FCExhaust; + sim_component.compPtr->simulate(sim_component_location, FirstHVACIteration, CurLoad, RunFlag); } else if (EquipTypeNum == TypeOf_Generator_FCStackCooler) { - SimFuelCellPlantHeatRecovery(sim_component.TypeOf, - sim_component.Name, - TypeOf_Generator_FCStackCooler, - EquipNum, - RunFlag, - InitLoopEquip, - CurLoad, - MaxLoad, - MinLoad, - OptLoad, - FirstHVACIteration); // DSU - if (InitLoopEquip) { - sim_component.MaxLoad = MaxLoad; - sim_component.MinLoad = MinLoad; - sim_component.OptLoad = OptLoad; - sim_component.CompNum = EquipNum; - } + dynamic_cast (sim_component.compPtr)->TypeOf = DataPlant::TypeOf_Generator_FCStackCooler; + sim_component.compPtr->simulate(sim_component_location, FirstHVACIteration, CurLoad, RunFlag); } else if (EquipTypeNum == TypeOf_Generator_MicroCHP) { sim_component.compPtr->simulate(sim_component_location, FirstHVACIteration, CurLoad, RunFlag); From 3b4f7db88fc4bdb86b68dd5e5bbb170329ee0119 Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Fri, 15 Nov 2019 08:18:40 -0700 Subject: [PATCH 44/51] use plantCompPtr calling --- src/EnergyPlus/Plant/PlantManager.cc | 2 + src/EnergyPlus/PlantLoopEquip.cc | 6 +- src/EnergyPlus/WaterUse.cc | 159 +++++++-------------------- src/EnergyPlus/WaterUse.hh | 4 +- 4 files changed, 46 insertions(+), 125 deletions(-) diff --git a/src/EnergyPlus/Plant/PlantManager.cc b/src/EnergyPlus/Plant/PlantManager.cc index 7265da82e93..fa77faf5bb3 100644 --- a/src/EnergyPlus/Plant/PlantManager.cc +++ b/src/EnergyPlus/Plant/PlantManager.cc @@ -104,6 +104,7 @@ #include #include #include +#include #include namespace EnergyPlus { @@ -976,6 +977,7 @@ namespace EnergyPlus { this_comp.TypeOf_Num = TypeOf_WaterUseConnection; this_comp.GeneralEquipType = GenEquipTypes_WaterUse; this_comp.CurOpSchemeType = DemandOpSchemeType; + this_comp.compPtr = WaterUse::WaterConnectionsType::factory(CompNames(CompNum)); } else if (UtilityRoutines::SameString(this_comp_type, "Coil:Cooling:Water")) { this_comp.TypeOf_Num = TypeOf_CoilWaterCooling; this_comp.GeneralEquipType = GenEquipTypes_DemandCoil; diff --git a/src/EnergyPlus/PlantLoopEquip.cc b/src/EnergyPlus/PlantLoopEquip.cc index 8b1aa7ff179..75d66bf5b17 100644 --- a/src/EnergyPlus/PlantLoopEquip.cc +++ b/src/EnergyPlus/PlantLoopEquip.cc @@ -200,7 +200,6 @@ namespace PlantLoopEquip { using SteamBaseboardRadiator::UpdateSteamBaseboardPlantConnection; using UserDefinedComponents::SimUserDefinedPlantComponent; using WaterCoils::UpdateWaterToAirCoilPlantConnection; - using WaterUse::SimulateWaterUseConnection; // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int EquipNum; // Plant side component list equipment number @@ -937,11 +936,8 @@ namespace PlantLoopEquip { if (EquipTypeNum == TypeOf_WaterUseConnection) { - SimulateWaterUseConnection(EquipTypeNum, sim_component.Name, EquipNum, InitLoopEquip, FirstHVACIteration); + sim_component.compPtr->simulate(sim_component_location, FirstHVACIteration, CurLoad, RunFlag); - if (InitLoopEquip) { - sim_component.CompNum = EquipNum; - } } else { ShowSevereError("SimPlantEquip: Invalid Load Coil Type=" + sim_component.TypeOf); ShowContinueError("Occurs in Plant Loop=" + PlantLoop(LoopNum).Name); diff --git a/src/EnergyPlus/WaterUse.cc b/src/EnergyPlus/WaterUse.cc index 3d3411f4820..3dc52db4c04 100644 --- a/src/EnergyPlus/WaterUse.cc +++ b/src/EnergyPlus/WaterUse.cc @@ -109,25 +109,21 @@ namespace EnergyPlus { // SUBROUTINE INFORMATION: // AUTHOR Peter Graham Ellis // DATE WRITTEN August 2006 - // MODIFIED Brent Griffith, March 2010, seperated plant connected to different sim routine + // MODIFIED Brent Griffith, March 2010, separated plant connected to different sim routine // RE-ENGINEERED na // PURPOSE OF THIS SUBROUTINE: // This routine is called from non zone equipment manager and serves to call // water use and connections that are not connected to a full plant loop - // Locals - // SUBROUTINE PARAMETER DEFINITIONS: int const MaxIterations(100); Real64 const Tolerance(0.1); // Make input? - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int WaterEquipNum; int WaterConnNum; int NumIteration; static bool MyEnvrnFlag(true); - // FLOW: if (getWaterUseInputFlag) { GetWaterUseInput(); getWaterUseInputFlag = false; @@ -171,7 +167,7 @@ namespace EnergyPlus { if (!WaterConnections(WaterConnNum).StandAlone) continue; // only model non plant connections here - WaterConnections(WaterConnNum).InitConnections(WaterConnNum); + WaterConnections(WaterConnNum).InitConnections(); NumIteration = 0; @@ -226,13 +222,7 @@ namespace EnergyPlus { return nullptr; // LCOV_EXCL_LINE } - void WaterConnectionsType::simulate(const PlantLocation &calledFromLocation, bool FirstHVACIteration, Real64 &CurLoad, bool RunFlag) - { - - } - - void SimulateWaterUseConnection( - int EP_UNUSED(EquipTypeNum), std::string &CompName, int &CompIndex, bool InitLoopEquip, bool FirstHVACIteration) + void WaterConnectionsType::simulate(const PlantLocation &EP_UNUSED(calledFromLocation), bool FirstHVACIteration, Real64 &EP_UNUSED(CurLoad), bool EP_UNUSED(RunFlag)) { // SUBROUTINE INFORMATION: @@ -243,49 +233,12 @@ namespace EnergyPlus { // PURPOSE OF THIS SUBROUTINE: // Plant sim call for plant loop connected water use and connections - // (based on SimulateWaterUse by P. Ellis) - // Locals - // SUBROUTINE PARAMETER DEFINITIONS: int const MaxIterations(100); Real64 const Tolerance(0.1); // Make input? - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - // INTEGER :: WaterEquipNum - int WaterConnNum; static bool MyEnvrnFlag(true); - // FLOW: - if (getWaterUseInputFlag) { - GetWaterUseInput(); - getWaterUseInputFlag = false; - } - - if (CompIndex == 0) { - WaterConnNum = UtilityRoutines::FindItemInList(CompName, WaterConnections); - if (WaterConnNum == 0) { - ShowFatalError("SimulateWaterUseConnection: Unit not found=" + CompName); - } - CompIndex = WaterConnNum; - } else { - WaterConnNum = CompIndex; - if (WaterConnNum > numWaterConnections || WaterConnNum < 1) { - ShowFatalError("SimulateWaterUseConnection: Invalid CompIndex passed=" + General::TrimSigDigits(WaterConnNum) + - ", Number of Units=" + General::TrimSigDigits(numWaterConnections) + ", Entered Unit name=" + CompName); - } - if (CheckEquipName(WaterConnNum)) { - if (CompName != WaterConnections(WaterConnNum).Name) { - ShowFatalError("SimulateWaterUseConnection: Invalid CompIndex passed=" + General::TrimSigDigits(WaterConnNum) + ", Unit name=" + CompName + - ", stored Unit Name for that index=" + WaterConnections(WaterConnNum).Name); - } - CheckEquipName(WaterConnNum) = false; - } - } - - if (InitLoopEquip) { - return; - } - if (DataGlobals::BeginEnvrnFlag && MyEnvrnFlag) { if (numWaterEquipment > 0) { for (int i = WaterEquipment.l(), e = WaterEquipment.u(); i <= e; ++i) { @@ -303,37 +256,37 @@ namespace EnergyPlus { if (!DataGlobals::BeginEnvrnFlag) MyEnvrnFlag = true; - WaterConnections(WaterConnNum).InitConnections(WaterConnNum); + this->InitConnections(); int NumIteration = 0; while (true) { ++NumIteration; - WaterConnections(WaterConnNum).CalcConnectionsFlowRates(FirstHVACIteration); - WaterConnections(WaterConnNum).CalcConnectionsDrainTemp(); - WaterConnections(WaterConnNum).CalcConnectionsHeatRecovery(); + this->CalcConnectionsFlowRates(FirstHVACIteration); + this->CalcConnectionsDrainTemp(); + this->CalcConnectionsHeatRecovery(); - if (WaterConnections(WaterConnNum).TempError < Tolerance) { + if (this->TempError < Tolerance) { break; } else if (NumIteration > MaxIterations) { if (!DataGlobals::WarmupFlag) { - if (WaterConnections(WaterConnNum).MaxIterationsErrorIndex == 0) { - ShowWarningError("WaterUse:Connections = " + WaterConnections(WaterConnNum).Name + + if (this->MaxIterationsErrorIndex == 0) { + ShowWarningError("WaterUse:Connections = " + this->Name + ": Heat recovery temperature did not converge"); ShowContinueErrorTimeStamp(""); } - ShowRecurringWarningErrorAtEnd("WaterUse:Connections = " + WaterConnections(WaterConnNum).Name + + ShowRecurringWarningErrorAtEnd("WaterUse:Connections = " + this->Name + ": Heat recovery temperature did not converge", - WaterConnections(WaterConnNum).MaxIterationsErrorIndex); + this->MaxIterationsErrorIndex); } break; } } // WHILE - WaterConnections(WaterConnNum).UpdateWaterConnections(); - WaterConnections(WaterConnNum).ReportWaterUse(); + this->UpdateWaterConnections(); + this->ReportWaterUse(); } void GetWaterUseInput() @@ -345,9 +298,6 @@ namespace EnergyPlus { // MODIFIED na // RE-ENGINEERED na - // METHODOLOGY EMPLOYED: Standard EnergyPlus methodology. - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: bool ErrorsFound(false); // Set to true if errors in input, fatal at end of routine int IOStatus; // Used in GetObjectItem int NumAlphas; // Number of Alphas for each GetObjectItem call @@ -1201,7 +1151,7 @@ namespace EnergyPlus { } } - void WaterConnectionsType::InitConnections(int WaterConnNum) + void WaterConnectionsType::InitConnections() { // SUBROUTINE INFORMATION: @@ -1210,37 +1160,23 @@ namespace EnergyPlus { // MODIFIED Brent Griffith 2010, demand side update // RE-ENGINEERED na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - bool MyOneTimeFlag(true); // one time flag - Array1D_bool SetLoopIndexFlag; // get loop number flag - - if (MyOneTimeFlag) { - SetLoopIndexFlag.dimension(numWaterConnections, true); - MyOneTimeFlag = false; - } - - if (SetLoopIndexFlag(WaterConnNum)) { - if (allocated(DataPlant::PlantLoop) && !this->StandAlone) { - bool errFlag = false; - PlantUtilities::ScanPlantLoopsForObject(this->Name, - DataPlant::TypeOf_WaterUseConnection, - this->PlantLoopNum, - this->PlantLoopSide, - this->PlantLoopBranchNum, - this->PlantLoopCompNum, - errFlag, - _, - _, - _, - _, - _); - if (errFlag) { - ShowFatalError("InitConnections: Program terminated due to previous condition(s)."); - } - SetLoopIndexFlag(WaterConnNum) = false; - } - if (this->StandAlone) SetLoopIndexFlag(WaterConnNum) = false; + if (allocated(DataPlant::PlantLoop) && !this->StandAlone) { + bool errFlag = false; + PlantUtilities::ScanPlantLoopsForObject(this->Name, + DataPlant::TypeOf_WaterUseConnection, + this->PlantLoopNum, + this->PlantLoopSide, + this->PlantLoopBranchNum, + this->PlantLoopCompNum, + errFlag, + _, + _, + _, + _, + _); + if (errFlag) { + ShowFatalError("InitConnections: Program terminated due to previous condition(s)."); + } } // Set the cold water temperature @@ -1554,27 +1490,20 @@ namespace EnergyPlus { // Calculates report variables for stand alone water use for (int WaterEquipNum = 1; WaterEquipNum <= numWaterEquipment; ++WaterEquipNum) { - WaterEquipment(WaterEquipNum).ColdVolFlowRate = - WaterEquipment(WaterEquipNum).ColdMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); - WaterEquipment(WaterEquipNum).HotVolFlowRate = - WaterEquipment(WaterEquipNum).HotMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); - WaterEquipment(WaterEquipNum).TotalVolFlowRate = - WaterEquipment(WaterEquipNum).ColdVolFlowRate + WaterEquipment(WaterEquipNum).HotVolFlowRate; - - WaterEquipment(WaterEquipNum).ColdVolume = - WaterEquipment(WaterEquipNum).ColdVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - WaterEquipment(WaterEquipNum).HotVolume = - WaterEquipment(WaterEquipNum).HotVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - WaterEquipment(WaterEquipNum).TotalVolume = - WaterEquipment(WaterEquipNum).TotalVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + WaterEquipment(WaterEquipNum).ColdVolFlowRate = WaterEquipment(WaterEquipNum).ColdMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); + WaterEquipment(WaterEquipNum).HotVolFlowRate = WaterEquipment(WaterEquipNum).HotMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); + WaterEquipment(WaterEquipNum).TotalVolFlowRate = WaterEquipment(WaterEquipNum).ColdVolFlowRate + WaterEquipment(WaterEquipNum).HotVolFlowRate; + + WaterEquipment(WaterEquipNum).ColdVolume = WaterEquipment(WaterEquipNum).ColdVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + WaterEquipment(WaterEquipNum).HotVolume = WaterEquipment(WaterEquipNum).HotVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + WaterEquipment(WaterEquipNum).TotalVolume = WaterEquipment(WaterEquipNum).TotalVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; if (WaterEquipment(WaterEquipNum).Connections == 0) { WaterEquipment(WaterEquipNum).Power = WaterEquipment(WaterEquipNum).HotMassFlowRate * Psychrometrics::CPHW(DataGlobals::InitConvTemp) * (WaterEquipment(WaterEquipNum).HotTemp - WaterEquipment(WaterEquipNum).ColdTemp); } else { - WaterEquipment(WaterEquipNum).Power = - WaterEquipment(WaterEquipNum).HotMassFlowRate * Psychrometrics::CPHW(DataGlobals::InitConvTemp) * + WaterEquipment(WaterEquipNum).Power = WaterEquipment(WaterEquipNum).HotMassFlowRate * Psychrometrics::CPHW(DataGlobals::InitConvTemp) * (WaterEquipment(WaterEquipNum).HotTemp - WaterConnections(WaterEquipment(WaterEquipNum).Connections).ReturnTemp); } @@ -1670,15 +1599,11 @@ namespace EnergyPlus { int ZoneNum = WaterEquipment(WaterEquipNum).Zone; WaterEquipment(WaterEquipNum).SensibleRateNoMultiplier = WaterEquipment(WaterEquipNum).SensibleRate / - (DataHeatBalance::Zone(ZoneNum).Multiplier * DataHeatBalance::Zone(ZoneNum).ListMultiplier); // CR7401, back out multipliers + (DataHeatBalance::Zone(ZoneNum).Multiplier * DataHeatBalance::Zone(ZoneNum).ListMultiplier); WaterEquipment(WaterEquipNum).LatentRateNoMultiplier = WaterEquipment(WaterEquipNum).LatentRate / - (DataHeatBalance::Zone(ZoneNum).Multiplier * DataHeatBalance::Zone(ZoneNum).ListMultiplier); // CR7401, back out multipliers + (DataHeatBalance::Zone(ZoneNum).Multiplier * DataHeatBalance::Zone(ZoneNum).ListMultiplier); } - - } - } // namespace WaterUse - } // namespace EnergyPlus diff --git a/src/EnergyPlus/WaterUse.hh b/src/EnergyPlus/WaterUse.hh index 8a798f3f28e..977ba8988d3 100644 --- a/src/EnergyPlus/WaterUse.hh +++ b/src/EnergyPlus/WaterUse.hh @@ -222,7 +222,7 @@ namespace EnergyPlus { void simulate(const PlantLocation &calledFromLocation, bool FirstHVACIteration, Real64 &CurLoad, bool RunFlag) override; - void InitConnections(int WaterConnNum); + void InitConnections(); void CalcConnectionsFlowRates(bool FirstHVACIteration); @@ -239,8 +239,6 @@ namespace EnergyPlus { void SimulateWaterUse(bool FirstHVACIteration); - void SimulateWaterUseConnection(int EquipTypeNum, std::string &CompName, int &CompIndex, bool InitLoopEquip, bool FirstHVACIteration); - void GetWaterUseInput(); void ReportStandAloneWaterUse(); From 9117541df41ce65b8cfa77cf479fca6229109f00 Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Fri, 15 Nov 2019 09:47:52 -0700 Subject: [PATCH 45/51] fix ubuntu compiler errors --- src/EnergyPlus/WaterUse.cc | 30 +++++++++++++++--------------- src/EnergyPlus/WaterUse.hh | 10 +++++----- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/EnergyPlus/WaterUse.cc b/src/EnergyPlus/WaterUse.cc index 3dc52db4c04..73ba6cfa6b9 100644 --- a/src/EnergyPlus/WaterUse.cc +++ b/src/EnergyPlus/WaterUse.cc @@ -505,11 +505,11 @@ namespace EnergyPlus { { auto const SELECT_CASE_var(DataIPShortCuts::cAlphaArgs(8)); if (SELECT_CASE_var == "IDEAL") { - WaterConnections(WaterConnNum).HeatRecoveryHX = HeatRecoveryHX::Ideal; + WaterConnections(WaterConnNum).HeatRecoveryHX = HeatRecoveryHXEnum::Ideal; } else if (SELECT_CASE_var == "COUNTERFLOW") { - WaterConnections(WaterConnNum).HeatRecoveryHX = HeatRecoveryHX::CounterFlow; + WaterConnections(WaterConnNum).HeatRecoveryHX = HeatRecoveryHXEnum::CounterFlow; } else if (SELECT_CASE_var == "CROSSFLOW") { - WaterConnections(WaterConnNum).HeatRecoveryHX = HeatRecoveryHX::CrossFlow; + WaterConnections(WaterConnNum).HeatRecoveryHX = HeatRecoveryHXEnum::CrossFlow; } else { ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(8) + '=' + DataIPShortCuts::cAlphaArgs(8)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + DataIPShortCuts::cAlphaArgs(1)); @@ -520,11 +520,11 @@ namespace EnergyPlus { { auto const SELECT_CASE_var(DataIPShortCuts::cAlphaArgs(9)); if (SELECT_CASE_var == "PLANT") { - WaterConnections(WaterConnNum).HeatRecoveryConfig = HeatRecoveryConfig::Plant; + WaterConnections(WaterConnNum).HeatRecoveryConfig = HeatRecoveryConfigEnum::Plant; } else if (SELECT_CASE_var == "EQUIPMENT") { - WaterConnections(WaterConnNum).HeatRecoveryConfig = HeatRecoveryConfig::Equipment; + WaterConnections(WaterConnNum).HeatRecoveryConfig = HeatRecoveryConfigEnum::Equipment; } else if (SELECT_CASE_var == "PLANTANDEQUIPMENT") { - WaterConnections(WaterConnNum).HeatRecoveryConfig = HeatRecoveryConfig::PlantAndEquip; + WaterConnections(WaterConnNum).HeatRecoveryConfig = HeatRecoveryConfigEnum::PlantAndEquip; } else { ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(9) + '=' + DataIPShortCuts::cAlphaArgs(9)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + DataIPShortCuts::cAlphaArgs(1)); @@ -1389,11 +1389,11 @@ namespace EnergyPlus { { auto const SELECT_CASE_var(this->HeatRecoveryConfig); - if (SELECT_CASE_var == HeatRecoveryConfig::Plant) { + if (SELECT_CASE_var == HeatRecoveryConfigEnum::Plant) { this->RecoveryMassFlowRate = this->HotMassFlowRate; - } else if (SELECT_CASE_var == HeatRecoveryConfig::Equipment) { + } else if (SELECT_CASE_var == HeatRecoveryConfigEnum::Equipment) { this->RecoveryMassFlowRate = this->ColdMassFlowRate; - } else if (SELECT_CASE_var == HeatRecoveryConfig::PlantAndEquip) { + } else if (SELECT_CASE_var == HeatRecoveryConfigEnum::PlantAndEquip) { this->RecoveryMassFlowRate = this->TotalMassFlowRate; } } @@ -1404,10 +1404,10 @@ namespace EnergyPlus { { auto const SELECT_CASE_var(this->HeatRecoveryHX); - if (SELECT_CASE_var == HeatRecoveryHX::Ideal) { + if (SELECT_CASE_var == HeatRecoveryHXEnum::Ideal) { this->Effectiveness = 1.0; - } else if (SELECT_CASE_var == HeatRecoveryHX::CounterFlow) { // Unmixed + } else if (SELECT_CASE_var == HeatRecoveryHXEnum::CounterFlow) { // Unmixed Real64 CapacityRatio = MinCapacityRate / max(DrainCapacityRate, HXCapacityRate); Real64 NTU = this->HXUA / MinCapacityRate; if (CapacityRatio == 1.0) { @@ -1417,7 +1417,7 @@ namespace EnergyPlus { this->Effectiveness = (1.0 - ExpVal) / (1.0 - CapacityRatio * ExpVal); } - } else if (SELECT_CASE_var == HeatRecoveryHX::CrossFlow) { // Unmixed + } else if (SELECT_CASE_var == HeatRecoveryHXEnum::CrossFlow) { // Unmixed Real64 CapacityRatio = MinCapacityRate / max(DrainCapacityRate, HXCapacityRate); Real64 NTU = this->HXUA / MinCapacityRate; this->Effectiveness = 1.0 - std::exp((std::pow(NTU, 0.22) / CapacityRatio) * (std::exp(-CapacityRatio * std::pow(NTU, 0.78)) - 1.0)); @@ -1435,17 +1435,17 @@ namespace EnergyPlus { { auto const SELECT_CASE_var(this->HeatRecoveryConfig); - if (SELECT_CASE_var == HeatRecoveryConfig::Plant) { + if (SELECT_CASE_var == HeatRecoveryConfigEnum::Plant) { this->TempError = 0.0; // No feedback back to the cold supply this->ReturnTemp = this->RecoveryTemp; - } else if (SELECT_CASE_var == HeatRecoveryConfig::Equipment) { + } else if (SELECT_CASE_var == HeatRecoveryConfigEnum::Equipment) { this->TempError = std::abs(this->ColdTemp - this->RecoveryTemp); this->ColdTemp = this->RecoveryTemp; this->ReturnTemp = this->ColdSupplyTemp; - } else if (SELECT_CASE_var == HeatRecoveryConfig::PlantAndEquip) { + } else if (SELECT_CASE_var == HeatRecoveryConfigEnum::PlantAndEquip) { this->TempError = std::abs(this->ColdTemp - this->RecoveryTemp); this->ColdTemp = this->RecoveryTemp; diff --git a/src/EnergyPlus/WaterUse.hh b/src/EnergyPlus/WaterUse.hh index 977ba8988d3..510be2aba4d 100644 --- a/src/EnergyPlus/WaterUse.hh +++ b/src/EnergyPlus/WaterUse.hh @@ -60,14 +60,14 @@ namespace EnergyPlus { namespace WaterUse { - enum struct HeatRecoveryHX + enum struct HeatRecoveryHXEnum { Ideal, CounterFlow, CrossFlow }; - enum struct HeatRecoveryConfig + enum struct HeatRecoveryConfigEnum { Plant, Equipment, @@ -157,8 +157,8 @@ namespace EnergyPlus { int TankDemandID; // array to request flow from supply tank int TankSupplyID; // array to send flow to recovery tank bool HeatRecovery; - HeatRecoveryHX HeatRecoveryHX; - HeatRecoveryConfig HeatRecoveryConfig; + HeatRecoveryHXEnum HeatRecoveryHX; + HeatRecoveryConfigEnum HeatRecoveryConfig; Real64 HXUA; Real64 Effectiveness; Real64 RecoveryRate; @@ -207,7 +207,7 @@ namespace EnergyPlus { WaterConnectionsType() : Init(true), InitSizing(true), StandAlone(false), InletNode(0), OutletNode(0), SupplyTankNum(0), RecoveryTankNum(0), TankDemandID(0), - TankSupplyID(0), HeatRecovery(false), HeatRecoveryHX(HeatRecoveryHX::Ideal), HeatRecoveryConfig(HeatRecoveryConfig::Plant), HXUA(0.0), + TankSupplyID(0), HeatRecovery(false), HeatRecoveryHX(HeatRecoveryHXEnum::Ideal), HeatRecoveryConfig(HeatRecoveryConfigEnum::Plant), HXUA(0.0), Effectiveness(0.0), RecoveryRate(0.0), RecoveryEnergy(0.0), MainsMassFlowRate(0.0), TankMassFlowRate(0.0), ColdMassFlowRate(0.0), HotMassFlowRate(0.0), TotalMassFlowRate(0.0), DrainMassFlowRate(0.0), RecoveryMassFlowRate(0.0), PeakVolFlowRate(0.0), MainsVolFlowRate(0.0), TankVolFlowRate(0.0), ColdVolFlowRate(0.0), HotVolFlowRate(0.0), TotalVolFlowRate(0.0), DrainVolFlowRate(0.0), From 5188f9321596fc7d3a46620aeec33ff23be95ce7 Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Mon, 18 Nov 2019 16:32:36 -0700 Subject: [PATCH 46/51] fixing reporting errors --- src/EnergyPlus/ElectricPowerServiceManager.cc | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/EnergyPlus/ElectricPowerServiceManager.cc b/src/EnergyPlus/ElectricPowerServiceManager.cc index 157d04ac3d9..1401c4b5106 100644 --- a/src/EnergyPlus/ElectricPowerServiceManager.cc +++ b/src/EnergyPlus/ElectricPowerServiceManager.cc @@ -2145,8 +2145,12 @@ void GeneratorController::simGeneratorGetPowerOutput(bool const runFlag, case GeneratorType::fuelCell: { auto thisFC = FuelCellElectricGenerator::FCDataStruct::factory(name); dynamic_cast (thisFC)->SimFuelCellGenerator(runFlag, myElecLoadRequest, FirstHVACIteration); - electricPowerOutput = dynamic_cast (thisFC)->Report.ACPowerGen; - thermalPowerOutput = dynamic_cast (thisFC)->Report.qHX; + electProdRate = dynamic_cast (thisFC)->Report.ACPowerGen; + electricityProd = dynamic_cast (thisFC)->Report.ACEnergyGen; + thermProdRate = dynamic_cast (thisFC)->Report.qHX; + thermalProd = dynamic_cast (thisFC)->Report.HXenergy; + electricPowerOutput = electProdRate; + thermalPowerOutput = thermProdRate; break; } case GeneratorType::microCHP: { @@ -2165,8 +2169,12 @@ void GeneratorController::simGeneratorGetPowerOutput(bool const runFlag, dynamic_cast (thisMCHP)->CalcUpdateHeatRecovery(); dynamic_cast (thisMCHP)->UpdateMicroCHPGeneratorRecords(); - thermalPowerOutput = dynamic_cast (thisMCHP)->A42Model.ACPowerGen; - thermalPowerOutput = dynamic_cast (thisMCHP)->A42Model.QdotHR; + electProdRate = dynamic_cast (thisMCHP)->A42Model.ACPowerGen; + electricityProd = dynamic_cast (thisMCHP)->A42Model.ACEnergyGen; + thermProdRate = dynamic_cast (thisMCHP)->A42Model.QdotHR; + thermalProd = dynamic_cast (thisMCHP)->A42Model.TotalHeatEnergyRec; + electricPowerOutput = electProdRate; + thermalPowerOutput = thermProdRate; break; } case GeneratorType::microturbine: { @@ -2180,8 +2188,12 @@ void GeneratorController::simGeneratorGetPowerOutput(bool const runFlag, dynamic_cast (thisMTG)->InitMTGenerators(runFlag, tempLoad, FirstHVACIteration); dynamic_cast (thisMTG)->CalcMTGeneratorModel(runFlag, tempLoad); dynamic_cast (thisMTG)->UpdateMTGeneratorRecords(); - electricPowerOutput = dynamic_cast (thisMTG)->ElecPowerGenerated; - thermalPowerOutput = dynamic_cast (thisMTG)->QHeatRecovered; + electProdRate = dynamic_cast (thisMTG)->ElecPowerGenerated; + electricityProd = dynamic_cast (thisMTG)->EnergyGen; + thermProdRate = dynamic_cast (thisMTG)->QHeatRecovered; + thermalProd = dynamic_cast (thisMTG)->ExhaustEnergyRec; + electricPowerOutput = electProdRate; + thermalPowerOutput = thermProdRate; break; } case GeneratorType::windTurbine: { From cd8c96cb1365f1e546ad57c5e962b7218f05c3ad Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Tue, 19 Nov 2019 07:34:26 -0700 Subject: [PATCH 47/51] fix output vars --- src/EnergyPlus/ElectricPowerServiceManager.cc | 16 ++++++++++++---- src/EnergyPlus/FuelCellElectricGenerator.cc | 15 --------------- 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/src/EnergyPlus/ElectricPowerServiceManager.cc b/src/EnergyPlus/ElectricPowerServiceManager.cc index 1401c4b5106..0910a5f51cc 100644 --- a/src/EnergyPlus/ElectricPowerServiceManager.cc +++ b/src/EnergyPlus/ElectricPowerServiceManager.cc @@ -2107,8 +2107,12 @@ void GeneratorController::simGeneratorGetPowerOutput(bool const runFlag, dynamic_cast (thisICE)->InitICEngineGenerators(runFlag, FirstHVACIteration); dynamic_cast (thisICE)->CalcICEngineGeneratorModel(runFlag, tempLoad); dynamic_cast (thisICE)->update(); - electricPowerOutput = dynamic_cast (thisICE)->ElecPowerGenerated; - thermalPowerOutput = dynamic_cast (thisICE)->QTotalHeatRecovered; + electProdRate = dynamic_cast (thisICE)->ElecPowerGenerated; + electricityProd = dynamic_cast (thisICE)->ElecEnergyGenerated; + thermProdRate = dynamic_cast (thisICE)->QTotalHeatRecovered; + thermalProd = dynamic_cast (thisICE)->TotalHeatEnergyRec; + electricPowerOutput = electProdRate; + thermalPowerOutput = thermProdRate; break; } case GeneratorType::combTurbine: { @@ -2122,8 +2126,12 @@ void GeneratorController::simGeneratorGetPowerOutput(bool const runFlag, thisCTE->simulate(L, FirstHVACIteration, tempLoad, runFlag); dynamic_cast (thisCTE)->InitCTGenerators(runFlag, FirstHVACIteration); dynamic_cast (thisCTE)->CalcCTGeneratorModel(runFlag, tempLoad, FirstHVACIteration); - electricPowerOutput = dynamic_cast (thisCTE)->ElecPowerGenerated; - thermalPowerOutput = dynamic_cast (thisCTE)->QTotalHeatRecovered; + electProdRate = dynamic_cast (thisCTE)->ElecPowerGenerated; + electricityProd = dynamic_cast (thisCTE)->ElecEnergyGenerated; + thermProdRate = dynamic_cast (thisCTE)->QTotalHeatRecovered; + thermalProd = dynamic_cast (thisCTE)->TotalHeatEnergyRec; + electricPowerOutput = electProdRate; + thermalPowerOutput = thermProdRate; break; } case GeneratorType::pV: { diff --git a/src/EnergyPlus/FuelCellElectricGenerator.cc b/src/EnergyPlus/FuelCellElectricGenerator.cc index 6723f26742b..a89087d4acd 100644 --- a/src/EnergyPlus/FuelCellElectricGenerator.cc +++ b/src/EnergyPlus/FuelCellElectricGenerator.cc @@ -3341,21 +3341,6 @@ namespace FuelCellElectricGenerator { } } - void getFuelCellGeneratorHeatRecoveryInfo(std::string const &GeneratorName, // user specified name of Generator - std::string &heatRecoveryCompName) - { - - if (getFuelCellInputFlag) { - getFuelCellInput(); - getFuelCellInputFlag = false; - } - - int thisFuelCell = UtilityRoutines::FindItemInList(GeneratorName, FuelCell); - if (thisFuelCell > 0) { - heatRecoveryCompName = FuelCell(thisFuelCell).ExhaustHX.Name; - } - } - void FigureFuelCellZoneGains() { From ef95f915c630204352923f0ded0d0fb71b353385 Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Fri, 22 Nov 2019 15:08:04 -0700 Subject: [PATCH 48/51] apply formatting --- src/EnergyPlus/FuelCellElectricGenerator.cc | 1053 ++++++++--------- src/EnergyPlus/FuelCellElectricGenerator.hh | 98 +- .../unit/FuelCellElectricGenerator.unit.cc | 4 +- 3 files changed, 557 insertions(+), 598 deletions(-) diff --git a/src/EnergyPlus/FuelCellElectricGenerator.cc b/src/EnergyPlus/FuelCellElectricGenerator.cc index a89087d4acd..0e44e7eb2a9 100644 --- a/src/EnergyPlus/FuelCellElectricGenerator.cc +++ b/src/EnergyPlus/FuelCellElectricGenerator.cc @@ -132,7 +132,8 @@ namespace FuelCellElectricGenerator { return nullptr; // LCOV_EXCL_LINE } - PlantComponent *FCDataStruct::factory_exhaust(std::string const &objectName){ + PlantComponent *FCDataStruct::factory_exhaust(std::string const &objectName) + { // Process the input data if (getFuelCellInputFlag) { getFuelCellInput(); @@ -141,7 +142,7 @@ namespace FuelCellElectricGenerator { // Now look for this object for (auto &thisFC : FuelCell) { - if (UtilityRoutines::MakeUPPERCase(thisFC.NameExhaustHX) == UtilityRoutines::MakeUPPERCase(objectName)) { + if (UtilityRoutines::MakeUPPERCase(thisFC.NameExhaustHX) == UtilityRoutines::MakeUPPERCase(objectName)) { return &thisFC; } } @@ -152,8 +153,8 @@ namespace FuelCellElectricGenerator { } void FCDataStruct::SimFuelCellGenerator(bool const RunFlag, // simulate Generator when TRUE - Real64 const MyLoad, // demand on electric generator - bool const FirstHVACIteration) + Real64 const MyLoad, // demand on electric generator + bool const FirstHVACIteration) { // SUBROUTINE INFORMATION: // AUTHOR Brent Griffith @@ -205,8 +206,17 @@ namespace FuelCellElectricGenerator { // first load in FuelCell names for (int GeneratorNum = 1; GeneratorNum <= NumFuelCellGenerators; ++GeneratorNum) { - inputProcessor->getObjectItem( - DataIPShortCuts::cCurrentModuleObject, GeneratorNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat, _, _, DataIPShortCuts::cAlphaFieldNames, DataIPShortCuts::cNumericFieldNames); + inputProcessor->getObjectItem(DataIPShortCuts::cCurrentModuleObject, + GeneratorNum, + AlphArray, + NumAlphas, + NumArray, + NumNums, + IOStat, + _, + _, + DataIPShortCuts::cAlphaFieldNames, + DataIPShortCuts::cNumericFieldNames); UtilityRoutines::IsNameEmpty(AlphArray(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); FuelCell(GeneratorNum).Name = AlphArray(1); @@ -250,7 +260,8 @@ namespace FuelCellElectricGenerator { FuelCell(thisFuelCell).FCPM.Name = AlphArray(1); if (UtilityRoutines::SameString(AlphArray(2), "ANNEX42")) FuelCell(thisFuelCell).FCPM.EffMode = DataGenerators::DirectCurveMode; - if (UtilityRoutines::SameString(AlphArray(2), "NORMALIZED")) FuelCell(thisFuelCell).FCPM.EffMode = DataGenerators::NormalizedCurveMode; + if (UtilityRoutines::SameString(AlphArray(2), "NORMALIZED")) + FuelCell(thisFuelCell).FCPM.EffMode = DataGenerators::NormalizedCurveMode; if (FuelCell(thisFuelCell).FCPM.EffMode == 0) { ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(2) + " = " + AlphArray(2)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); @@ -281,7 +292,8 @@ namespace FuelCellElectricGenerator { FuelCell(thisFuelCell).FCPM.ShutDownElectConsum = NumArray(16); FuelCell(thisFuelCell).FCPM.ANC0 = NumArray(17); FuelCell(thisFuelCell).FCPM.ANC1 = NumArray(18); - if (UtilityRoutines::SameString(AlphArray(4), "ConstantRate")) FuelCell(thisFuelCell).FCPM.SkinLossMode = DataGenerators::ConstantRateSkinLoss; + if (UtilityRoutines::SameString(AlphArray(4), "ConstantRate")) + FuelCell(thisFuelCell).FCPM.SkinLossMode = DataGenerators::ConstantRateSkinLoss; if (UtilityRoutines::SameString(AlphArray(4), "UAForProcessGasTemperature")) FuelCell(thisFuelCell).FCPM.SkinLossMode = DataGenerators::UADTSkinLoss; if (UtilityRoutines::SameString(AlphArray(4), "QUADRATIC FUNCTION OF FUEL RATE")) @@ -317,11 +329,23 @@ namespace FuelCellElectricGenerator { FuelCell(thisFuelCell).FCPM.NdotDilutionAir = NumArray(22); FuelCell(thisFuelCell).FCPM.StackHeatLossToDilution = NumArray(23); FuelCell(thisFuelCell).FCPM.DilutionInletNodeName = AlphArray(7); - FuelCell(thisFuelCell).FCPM.DilutionInletNode = NodeInputManager::GetOnlySingleNode( - AlphArray(7), ErrorsFound, DataIPShortCuts::cCurrentModuleObject, AlphArray(1), DataLoopNode::NodeType_Air, DataLoopNode::NodeConnectionType_Inlet, 1, DataLoopNode::ObjectIsNotParent); + FuelCell(thisFuelCell).FCPM.DilutionInletNode = NodeInputManager::GetOnlySingleNode(AlphArray(7), + ErrorsFound, + DataIPShortCuts::cCurrentModuleObject, + AlphArray(1), + DataLoopNode::NodeType_Air, + DataLoopNode::NodeConnectionType_Inlet, + 1, + DataLoopNode::ObjectIsNotParent); FuelCell(thisFuelCell).FCPM.DilutionExhaustNodeName = AlphArray(8); - FuelCell(thisFuelCell).FCPM.DilutionExhaustNode = NodeInputManager::GetOnlySingleNode( - AlphArray(8), ErrorsFound, DataIPShortCuts::cCurrentModuleObject, AlphArray(1), DataLoopNode::NodeType_Air, DataLoopNode::NodeConnectionType_Outlet, 1, DataLoopNode::ObjectIsNotParent); + FuelCell(thisFuelCell).FCPM.DilutionExhaustNode = NodeInputManager::GetOnlySingleNode(AlphArray(8), + ErrorsFound, + DataIPShortCuts::cCurrentModuleObject, + AlphArray(1), + DataLoopNode::NodeType_Air, + DataLoopNode::NodeConnectionType_Outlet, + 1, + DataLoopNode::ObjectIsNotParent); FuelCell(thisFuelCell).FCPM.PelMin = NumArray(24); FuelCell(thisFuelCell).FCPM.PelMax = NumArray(25); @@ -364,8 +388,17 @@ namespace FuelCellElectricGenerator { } for (int FCAirSupNum = 1; FCAirSupNum <= NumFuelCellAirSups; ++FCAirSupNum) { - inputProcessor->getObjectItem( - DataIPShortCuts::cCurrentModuleObject, FCAirSupNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat, _, _, DataIPShortCuts::cAlphaFieldNames, DataIPShortCuts::cNumericFieldNames); + inputProcessor->getObjectItem(DataIPShortCuts::cCurrentModuleObject, + FCAirSupNum, + AlphArray, + NumAlphas, + NumArray, + NumNums, + IOStat, + _, + _, + DataIPShortCuts::cAlphaFieldNames, + DataIPShortCuts::cNumericFieldNames); UtilityRoutines::IsNameEmpty(AlphArray(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); int thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), FuelCell, &FCDataStruct::NameFCAirSup); @@ -376,8 +409,14 @@ namespace FuelCellElectricGenerator { FuelCell(thisFuelCell).AirSup.NodeName = AlphArray(2); // check the node connections - FuelCell(thisFuelCell).AirSup.SupNodeNum = NodeInputManager::GetOnlySingleNode( - AlphArray(2), ErrorsFound, DataIPShortCuts::cCurrentModuleObject, AlphArray(1), DataLoopNode::NodeType_Air, DataLoopNode::NodeConnectionType_Inlet, 1, DataLoopNode::ObjectIsNotParent); + FuelCell(thisFuelCell).AirSup.SupNodeNum = NodeInputManager::GetOnlySingleNode(AlphArray(2), + ErrorsFound, + DataIPShortCuts::cCurrentModuleObject, + AlphArray(1), + DataLoopNode::NodeType_Air, + DataLoopNode::NodeConnectionType_Inlet, + 1, + DataLoopNode::ObjectIsNotParent); FuelCell(thisFuelCell).AirSup.BlowerPowerCurveID = CurveManager::GetCurveIndex(AlphArray(3)); if (FuelCell(thisFuelCell).AirSup.BlowerPowerCurveID == 0) { @@ -522,7 +561,8 @@ namespace FuelCellElectricGenerator { std::string thisName = FuelCell(GeneratorNum).AirSup.ConstitName(i); - int thisGasID = UtilityRoutines::FindItem(thisName, DataGenerators::GasPhaseThermoChemistryData, &DataGenerators::GasPropertyDataStruct::ConstituentName); + int thisGasID = UtilityRoutines::FindItem( + thisName, DataGenerators::GasPhaseThermoChemistryData, &DataGenerators::GasPropertyDataStruct::ConstituentName); FuelCell(GeneratorNum).AirSup.GasLibID(i) = thisGasID; } @@ -544,8 +584,17 @@ namespace FuelCellElectricGenerator { } for (int FCWaterSupNum = 1; FCWaterSupNum <= NumFCWaterSups; ++FCWaterSupNum) { - inputProcessor->getObjectItem( - DataIPShortCuts::cCurrentModuleObject, FCWaterSupNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat, _, _, DataIPShortCuts::cAlphaFieldNames, DataIPShortCuts::cNumericFieldNames); + inputProcessor->getObjectItem(DataIPShortCuts::cCurrentModuleObject, + FCWaterSupNum, + AlphArray, + NumAlphas, + NumArray, + NumNums, + IOStat, + _, + _, + DataIPShortCuts::cAlphaFieldNames, + DataIPShortCuts::cNumericFieldNames); UtilityRoutines::IsNameEmpty(AlphArray(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); int thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), FuelCell, &FCDataStruct::NameFCWaterSup); @@ -574,26 +623,26 @@ namespace FuelCellElectricGenerator { FuelCell(thisFuelCell).WaterSup.NodeName = AlphArray(5); FuelCell(thisFuelCell).WaterSup.NodeNum = NodeInputManager::GetOnlySingleNode(AlphArray(5), - ErrorsFound, - DataIPShortCuts::cCurrentModuleObject, - AlphArray(1), - DataLoopNode::NodeType_Air, - DataLoopNode::NodeConnectionType_Sensor, - 1, - DataLoopNode::ObjectIsNotParent); + ErrorsFound, + DataIPShortCuts::cCurrentModuleObject, + AlphArray(1), + DataLoopNode::NodeType_Air, + DataLoopNode::NodeConnectionType_Sensor, + 1, + DataLoopNode::ObjectIsNotParent); } else if (UtilityRoutines::SameString("TemperatureFromWaterNode", AlphArray(4))) { FuelCell(thisFuelCell).WaterSup.WaterTempMode = DataGenerators::WaterInReformWaterNode; FuelCell(thisFuelCell).WaterSup.NodeName = AlphArray(5); FuelCell(thisFuelCell).WaterSup.NodeNum = NodeInputManager::GetOnlySingleNode(AlphArray(5), - ErrorsFound, - DataIPShortCuts::cCurrentModuleObject, - AlphArray(1), - DataLoopNode::NodeType_Water, - DataLoopNode::NodeConnectionType_Sensor, - 1, - DataLoopNode::ObjectIsNotParent); + ErrorsFound, + DataIPShortCuts::cCurrentModuleObject, + AlphArray(1), + DataLoopNode::NodeType_Water, + DataLoopNode::NodeConnectionType_Sensor, + 1, + DataLoopNode::ObjectIsNotParent); } else if (UtilityRoutines::SameString("MainsWaterTemperature", AlphArray(4))) { FuelCell(thisFuelCell).WaterSup.WaterTempMode = DataGenerators::WaterInReformMains; @@ -607,7 +656,8 @@ namespace FuelCellElectricGenerator { } FuelCell(thisFuelCell).WaterSup.SchedNum = ScheduleManager::GetScheduleIndex(AlphArray(6)); - if ((FuelCell(thisFuelCell).WaterSup.SchedNum == 0) && (FuelCell(thisFuelCell).WaterSup.WaterTempMode == DataGenerators::WaterInReformSchedule)) { + if ((FuelCell(thisFuelCell).WaterSup.SchedNum == 0) && + (FuelCell(thisFuelCell).WaterSup.WaterTempMode == DataGenerators::WaterInReformSchedule)) { ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(6) + " = " + AlphArray(6)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ShowContinueError("Schedule was not found"); @@ -636,8 +686,17 @@ namespace FuelCellElectricGenerator { } for (int FCAuxHeatNum = 1; FCAuxHeatNum <= NumFuelCellAuxilHeaters; ++FCAuxHeatNum) { - inputProcessor->getObjectItem( - DataIPShortCuts::cCurrentModuleObject, FCAuxHeatNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat, _, _, DataIPShortCuts::cAlphaFieldNames, DataIPShortCuts::cNumericFieldNames); + inputProcessor->getObjectItem(DataIPShortCuts::cCurrentModuleObject, + FCAuxHeatNum, + AlphArray, + NumAlphas, + NumArray, + NumNums, + IOStat, + _, + _, + DataIPShortCuts::cAlphaFieldNames, + DataIPShortCuts::cNumericFieldNames); UtilityRoutines::IsNameEmpty(AlphArray(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); int thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), FuelCell, &FCDataStruct::NameFCAuxilHeat); @@ -662,7 +721,8 @@ namespace FuelCellElectricGenerator { FuelCell(thisFuelCell).AuxilHeat.ZoneName = AlphArray(3); FuelCell(thisFuelCell).AuxilHeat.ZoneID = UtilityRoutines::FindItemInList(AlphArray(3), DataHeatBalance::Zone); - if ((FuelCell(thisFuelCell).AuxilHeat.ZoneID == 0) && (FuelCell(thisFuelCell).AuxilHeat.SkinLossDestination == DataGenerators::SurroundingZone)) { + if ((FuelCell(thisFuelCell).AuxilHeat.ZoneID == 0) && + (FuelCell(thisFuelCell).AuxilHeat.SkinLossDestination == DataGenerators::SurroundingZone)) { ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(3) + " = " + AlphArray(3)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ShowContinueError("Zone name was not found "); @@ -698,8 +758,17 @@ namespace FuelCellElectricGenerator { } for (int FCHXNum = 1; FCHXNum <= NumFCExhaustGasHXs; ++FCHXNum) { - inputProcessor->getObjectItem( - DataIPShortCuts::cCurrentModuleObject, FCHXNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat, _, _, DataIPShortCuts::cAlphaFieldNames, DataIPShortCuts::cNumericFieldNames); + inputProcessor->getObjectItem(DataIPShortCuts::cCurrentModuleObject, + FCHXNum, + AlphArray, + NumAlphas, + NumArray, + NumNums, + IOStat, + _, + _, + DataIPShortCuts::cAlphaFieldNames, + DataIPShortCuts::cNumericFieldNames); UtilityRoutines::IsNameEmpty(AlphArray(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); int thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), FuelCell, &FCDataStruct::NameExhaustHX); @@ -710,26 +779,33 @@ namespace FuelCellElectricGenerator { FuelCell(thisFuelCell).ExhaustHX.WaterOutNodeName = AlphArray(3); // find node ids for water path FuelCell(thisFuelCell).ExhaustHX.WaterInNode = NodeInputManager::GetOnlySingleNode(AlphArray(2), - ErrorsFound, - DataIPShortCuts::cCurrentModuleObject, - AlphArray(1), - DataLoopNode::NodeType_Water, - DataLoopNode::NodeConnectionType_Inlet, - 1, - DataLoopNode::ObjectIsNotParent); + ErrorsFound, + DataIPShortCuts::cCurrentModuleObject, + AlphArray(1), + DataLoopNode::NodeType_Water, + DataLoopNode::NodeConnectionType_Inlet, + 1, + DataLoopNode::ObjectIsNotParent); FuelCell(thisFuelCell).ExhaustHX.WaterOutNode = NodeInputManager::GetOnlySingleNode(AlphArray(3), - ErrorsFound, - DataIPShortCuts::cCurrentModuleObject, - AlphArray(1), - DataLoopNode::NodeType_Water, - DataLoopNode::NodeConnectionType_Outlet, - 1, - DataLoopNode::ObjectIsNotParent); - BranchNodeConnections::TestCompSet(DataIPShortCuts::cCurrentModuleObject, AlphArray(1), AlphArray(2), AlphArray(3), "Heat Recovery Nodes"); + ErrorsFound, + DataIPShortCuts::cCurrentModuleObject, + AlphArray(1), + DataLoopNode::NodeType_Water, + DataLoopNode::NodeConnectionType_Outlet, + 1, + DataLoopNode::ObjectIsNotParent); + BranchNodeConnections::TestCompSet( + DataIPShortCuts::cCurrentModuleObject, AlphArray(1), AlphArray(2), AlphArray(3), "Heat Recovery Nodes"); FuelCell(thisFuelCell).ExhaustHX.ExhaustOutNodeName = AlphArray(4); - FuelCell(thisFuelCell).ExhaustHX.ExhaustOutNode = NodeInputManager::GetOnlySingleNode( - AlphArray(4), ErrorsFound, DataIPShortCuts::cCurrentModuleObject, AlphArray(1), DataLoopNode::NodeType_Air, DataLoopNode::NodeConnectionType_Outlet, 2, DataLoopNode::ObjectIsNotParent); + FuelCell(thisFuelCell).ExhaustHX.ExhaustOutNode = NodeInputManager::GetOnlySingleNode(AlphArray(4), + ErrorsFound, + DataIPShortCuts::cCurrentModuleObject, + AlphArray(1), + DataLoopNode::NodeType_Air, + DataLoopNode::NodeConnectionType_Outlet, + 2, + DataLoopNode::ObjectIsNotParent); if (UtilityRoutines::SameString("FixedEffectiveness", AlphArray(5))) { FuelCell(thisFuelCell).ExhaustHX.HXmodelMode = DataGenerators::FixedEffectiveness; @@ -765,7 +841,8 @@ namespace FuelCellElectricGenerator { FuelCell(thisFuelCell).ExhaustHX.CondensationThresholdTemp = NumArray(19); // store cooling water volume flow rate for autosizing system - PlantUtilities::RegisterPlantCompDesignFlow(FuelCell(thisFuelCell).ExhaustHX.WaterInNode, FuelCell(thisFuelCell).ExhaustHX.WaterVolumeFlowMax); + PlantUtilities::RegisterPlantCompDesignFlow(FuelCell(thisFuelCell).ExhaustHX.WaterInNode, + FuelCell(thisFuelCell).ExhaustHX.WaterVolumeFlowMax); } else { ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(1) + " = " + AlphArray(1)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); @@ -783,8 +860,17 @@ namespace FuelCellElectricGenerator { } for (int StorageNum = 1; StorageNum <= NumFCElecStorageUnits; ++StorageNum) { - inputProcessor->getObjectItem( - DataIPShortCuts::cCurrentModuleObject, StorageNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat, _, _, DataIPShortCuts::cAlphaFieldNames, DataIPShortCuts::cNumericFieldNames); + inputProcessor->getObjectItem(DataIPShortCuts::cCurrentModuleObject, + StorageNum, + AlphArray, + NumAlphas, + NumArray, + NumNums, + IOStat, + _, + _, + DataIPShortCuts::cAlphaFieldNames, + DataIPShortCuts::cNumericFieldNames); UtilityRoutines::IsNameEmpty(AlphArray(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); int thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), FuelCell, &FCDataStruct::NameElecStorage); @@ -830,8 +916,17 @@ namespace FuelCellElectricGenerator { } for (int FCPCUNum = 1; FCPCUNum <= NumFCPowerCondUnits; ++FCPCUNum) { - inputProcessor->getObjectItem( - DataIPShortCuts::cCurrentModuleObject, FCPCUNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat, _, _, DataIPShortCuts::cAlphaFieldNames, DataIPShortCuts::cNumericFieldNames); + inputProcessor->getObjectItem(DataIPShortCuts::cCurrentModuleObject, + FCPCUNum, + AlphArray, + NumAlphas, + NumArray, + NumNums, + IOStat, + _, + _, + DataIPShortCuts::cAlphaFieldNames, + DataIPShortCuts::cNumericFieldNames); UtilityRoutines::IsNameEmpty(AlphArray(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); int thisFuelCell = UtilityRoutines::FindItemInList(AlphArray(1), FuelCell, &FCDataStruct::NameInverter); @@ -839,8 +934,10 @@ namespace FuelCellElectricGenerator { if (thisFuelCell > 0) { FuelCell(thisFuelCell).Inverter.Name = AlphArray(1); - if (UtilityRoutines::SameString(AlphArray(2), "QUADRATIC")) FuelCell(thisFuelCell).Inverter.EffMode = DataGenerators::InverterEffQuadratic; - if (UtilityRoutines::SameString(AlphArray(2), "Constant")) FuelCell(thisFuelCell).Inverter.EffMode = DataGenerators::InverterEffConstant; + if (UtilityRoutines::SameString(AlphArray(2), "QUADRATIC")) + FuelCell(thisFuelCell).Inverter.EffMode = DataGenerators::InverterEffQuadratic; + if (UtilityRoutines::SameString(AlphArray(2), "Constant")) + FuelCell(thisFuelCell).Inverter.EffMode = DataGenerators::InverterEffConstant; if (FuelCell(thisFuelCell).Inverter.EffMode == 0) { ShowSevereError("Invalid, " + DataIPShortCuts::cAlphaFieldNames(2) + " = " + AlphArray(2)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); @@ -898,22 +995,23 @@ namespace FuelCellElectricGenerator { FuelCell(thisFuelCell).StackCooler.WaterOutNodeName = AlphArray(3); FuelCell(thisFuelCell).StackCooler.WaterInNode = NodeInputManager::GetOnlySingleNode(AlphArray(2), - ErrorsFound, - DataIPShortCuts::cCurrentModuleObject, - AlphArray(1), - DataLoopNode::NodeType_Water, - DataLoopNode::NodeConnectionType_Inlet, - 1, - DataLoopNode::ObjectIsNotParent); + ErrorsFound, + DataIPShortCuts::cCurrentModuleObject, + AlphArray(1), + DataLoopNode::NodeType_Water, + DataLoopNode::NodeConnectionType_Inlet, + 1, + DataLoopNode::ObjectIsNotParent); FuelCell(thisFuelCell).StackCooler.WaterOutNode = NodeInputManager::GetOnlySingleNode(AlphArray(3), - ErrorsFound, - DataIPShortCuts::cCurrentModuleObject, - AlphArray(1), - DataLoopNode::NodeType_Water, - DataLoopNode::NodeConnectionType_Outlet, - 1, - DataLoopNode::ObjectIsNotParent); - BranchNodeConnections::TestCompSet(DataIPShortCuts::cCurrentModuleObject, AlphArray(1), AlphArray(2), AlphArray(3), "Heat Recovery Nodes"); + ErrorsFound, + DataIPShortCuts::cCurrentModuleObject, + AlphArray(1), + DataLoopNode::NodeType_Water, + DataLoopNode::NodeConnectionType_Outlet, + 1, + DataLoopNode::ObjectIsNotParent); + BranchNodeConnections::TestCompSet( + DataIPShortCuts::cCurrentModuleObject, AlphArray(1), AlphArray(2), AlphArray(3), "Heat Recovery Nodes"); FuelCell(thisFuelCell).StackCooler.TstackNom = NumArray(1); FuelCell(thisFuelCell).StackCooler.TstackActual = NumArray(2); @@ -956,12 +1054,7 @@ namespace FuelCellElectricGenerator { void FCDataStruct::setupOutputVars() { - SetupOutputVariable("Generator Produced Electric Power", - OutputProcessor::Unit::W, - this->Report.ACPowerGen, - "System", - "Average", - this->Name); + SetupOutputVariable("Generator Produced Electric Power", OutputProcessor::Unit::W, this->Report.ACPowerGen, "System", "Average", this->Name); SetupOutputVariable("Generator Produced Electric Energy", OutputProcessor::Unit::J, @@ -975,12 +1068,7 @@ namespace FuelCellElectricGenerator { _, "Plant"); - SetupOutputVariable("Generator Produced Thermal Rate", - OutputProcessor::Unit::W, - this->Report.qHX, - "System", - "Average", - this->Name); + SetupOutputVariable("Generator Produced Thermal Rate", OutputProcessor::Unit::W, this->Report.qHX, "System", "Average", this->Name); SetupOutputVariable("Generator Produced Thermal Energy", OutputProcessor::Unit::J, @@ -1006,40 +1094,20 @@ namespace FuelCellElectricGenerator { _, "Plant"); - SetupOutputVariable("Generator Fuel HHV Basis Rate", - OutputProcessor::Unit::W, - this->Report.FuelEnergyUseRateHHV, - "System", - "Average", - this->Name); + SetupOutputVariable( + "Generator Fuel HHV Basis Rate", OutputProcessor::Unit::W, this->Report.FuelEnergyUseRateHHV, "System", "Average", this->Name); - SetupOutputVariable("Generator Zone Sensible Heat Transfer Rate", - OutputProcessor::Unit::W, - this->Report.SkinLossPower, - "System", - "Average", - this->Name); + SetupOutputVariable( + "Generator Zone Sensible Heat Transfer Rate", OutputProcessor::Unit::W, this->Report.SkinLossPower, "System", "Average", this->Name); - SetupOutputVariable("Generator Zone Sensible Heat Transfer Energy", - OutputProcessor::Unit::J, - this->Report.SkinLossEnergy, - "System", - "Sum", - this->Name); + SetupOutputVariable( + "Generator Zone Sensible Heat Transfer Energy", OutputProcessor::Unit::J, this->Report.SkinLossEnergy, "System", "Sum", this->Name); - SetupOutputVariable("Generator Zone Convection Heat Transfer Rate", - OutputProcessor::Unit::W, - this->Report.SkinLossConvect, - "System", - "Average", - this->Name); + SetupOutputVariable( + "Generator Zone Convection Heat Transfer Rate", OutputProcessor::Unit::W, this->Report.SkinLossConvect, "System", "Average", this->Name); - SetupOutputVariable("Generator Zone Radiation Heat Transfer Rate", - OutputProcessor::Unit::W, - this->Report.SkinLossRadiat, - "System", - "Average", - this->Name); + SetupOutputVariable( + "Generator Zone Radiation Heat Transfer Rate", OutputProcessor::Unit::W, this->Report.SkinLossRadiat, "System", "Average", this->Name); if (this->FCPM.ZoneID > 0) { SetupZoneInternalGain(this->FCPM.ZoneID, @@ -1052,12 +1120,7 @@ namespace FuelCellElectricGenerator { } if (DataGlobals::DisplayAdvancedReportVariables) { // show extra data originally needed for detailed comparative testing - SetupOutputVariable("Generator Air Inlet Temperature", - OutputProcessor::Unit::C, - this->Report.TairInlet, - "System", - "Average", - this->Name); + SetupOutputVariable("Generator Air Inlet Temperature", OutputProcessor::Unit::C, this->Report.TairInlet, "System", "Average", this->Name); SetupOutputVariable("Generator Power Module Entering Air Temperature", OutputProcessor::Unit::C, @@ -1066,12 +1129,8 @@ namespace FuelCellElectricGenerator { "Average", this->Name); - SetupOutputVariable("Generator Air Molar Flow Rate", - OutputProcessor::Unit::kmol_s, - this->Report.NdotAir, - "System", - "Average", - this->Name); + SetupOutputVariable( + "Generator Air Molar Flow Rate", OutputProcessor::Unit::kmol_s, this->Report.NdotAir, "System", "Average", this->Name); SetupOutputVariable("Generator Power Module Entering Air Enthalpy", OutputProcessor::Unit::W, @@ -1080,33 +1139,16 @@ namespace FuelCellElectricGenerator { "Average", this->Name); - SetupOutputVariable("Generator Blower Electric Power", - OutputProcessor::Unit::W, - this->Report.BlowerPower, - "System", - "Average", - this->Name); + SetupOutputVariable( + "Generator Blower Electric Power", OutputProcessor::Unit::W, this->Report.BlowerPower, "System", "Average", this->Name); - SetupOutputVariable("Generator Blower Electric Energy", - OutputProcessor::Unit::J, - this->Report.BlowerEnergy, - "System", - "Sum", - this->Name); + SetupOutputVariable("Generator Blower Electric Energy", OutputProcessor::Unit::J, this->Report.BlowerEnergy, "System", "Sum", this->Name); - SetupOutputVariable("Generator Blower Skin Heat Loss Rate", - OutputProcessor::Unit::W, - this->Report.BlowerSkinLoss, - "System", - "Average", - this->Name); + SetupOutputVariable( + "Generator Blower Skin Heat Loss Rate", OutputProcessor::Unit::W, this->Report.BlowerSkinLoss, "System", "Average", this->Name); - SetupOutputVariable("Generator Fuel Inlet Temperature", - OutputProcessor::Unit::C, - this->Report.TfuelInlet, - "System", - "Average", - this->Name); + SetupOutputVariable( + "Generator Fuel Inlet Temperature", OutputProcessor::Unit::C, this->Report.TfuelInlet, "System", "Average", this->Name); SetupOutputVariable("Generator Power Module Entering Fuel Temperature", OutputProcessor::Unit::C, @@ -1115,19 +1157,11 @@ namespace FuelCellElectricGenerator { "Average", this->Name); - SetupOutputVariable("Generator Fuel Molar Flow Rate", - OutputProcessor::Unit::kmol_s, - this->Report.NdotFuel, - "System", - "Average", - this->Name); + SetupOutputVariable( + "Generator Fuel Molar Flow Rate", OutputProcessor::Unit::kmol_s, this->Report.NdotFuel, "System", "Average", this->Name); - SetupOutputVariable("Generator Fuel Consumption LHV Basis Energy", - OutputProcessor::Unit::J, - this->Report.FuelEnergyLHV, - "System", - "Sum", - this->Name); + SetupOutputVariable( + "Generator Fuel Consumption LHV Basis Energy", OutputProcessor::Unit::J, this->Report.FuelEnergyLHV, "System", "Sum", this->Name); SetupOutputVariable("Generator Fuel Consumption Rate LHV Basis", OutputProcessor::Unit::W, @@ -1150,12 +1184,8 @@ namespace FuelCellElectricGenerator { "Average", this->Name); - SetupOutputVariable("Generator Fuel Compressor Electric Energy", - OutputProcessor::Unit::J, - this->Report.FuelCompressEnergy, - "System", - "Sum", - this->Name); + SetupOutputVariable( + "Generator Fuel Compressor Electric Energy", OutputProcessor::Unit::J, this->Report.FuelCompressEnergy, "System", "Sum", this->Name); SetupOutputVariable("Generator Fuel Compressor Skin Heat Loss Rate", OutputProcessor::Unit::W, @@ -1206,33 +1236,17 @@ namespace FuelCellElectricGenerator { "Average", this->Name); - SetupOutputVariable("Generator Product Gas Temperature", - OutputProcessor::Unit::C, - this->Report.TprodGas, - "System", - "Average", - this->Name); + SetupOutputVariable( + "Generator Product Gas Temperature", OutputProcessor::Unit::C, this->Report.TprodGas, "System", "Average", this->Name); - SetupOutputVariable("Generator Product Gas Enthalpy", - OutputProcessor::Unit::W, - this->Report.EnthalProdGas, - "System", - "Average", - this->Name); + SetupOutputVariable( + "Generator Product Gas Enthalpy", OutputProcessor::Unit::W, this->Report.EnthalProdGas, "System", "Average", this->Name); - SetupOutputVariable("Generator Product Gas Molar Flow Rate", - OutputProcessor::Unit::kmol_s, - this->Report.NdotProdGas, - "System", - "Average", - this->Name); + SetupOutputVariable( + "Generator Product Gas Molar Flow Rate", OutputProcessor::Unit::kmol_s, this->Report.NdotProdGas, "System", "Average", this->Name); - SetupOutputVariable("Generator Product Gas Ar Molar Flow Rate", - OutputProcessor::Unit::kmol_s, - this->Report.NdotProdAr, - "System", - "Average", - this->Name); + SetupOutputVariable( + "Generator Product Gas Ar Molar Flow Rate", OutputProcessor::Unit::kmol_s, this->Report.NdotProdAr, "System", "Average", this->Name); SetupOutputVariable("Generator Product Gas CO2 Molar Flow Rate", OutputProcessor::Unit::kmol_s, @@ -1248,26 +1262,14 @@ namespace FuelCellElectricGenerator { "Average", this->Name); - SetupOutputVariable("Generator Product Gas N2 Molar Flow Rate", - OutputProcessor::Unit::kmol_s, - this->Report.NdotProdN2, - "System", - "Average", - this->Name); + SetupOutputVariable( + "Generator Product Gas N2 Molar Flow Rate", OutputProcessor::Unit::kmol_s, this->Report.NdotProdN2, "System", "Average", this->Name); - SetupOutputVariable("Generator Product Gas O2 Molar Flow Rate", - OutputProcessor::Unit::kmol_s, - this->Report.NdotProdO2, - "System", - "Average", - this->Name); + SetupOutputVariable( + "Generator Product Gas O2 Molar Flow Rate", OutputProcessor::Unit::kmol_s, this->Report.NdotProdO2, "System", "Average", this->Name); - SetupOutputVariable("Generator Heat Recovery Exit Gas Temperature", - OutputProcessor::Unit::C, - this->Report.THXexh, - "System", - "Average", - this->Name); + SetupOutputVariable( + "Generator Heat Recovery Exit Gas Temperature", OutputProcessor::Unit::C, this->Report.THXexh, "System", "Average", this->Name); SetupOutputVariable("Generator Heat Recovery Exit Gas H2O Vapor Fraction", OutputProcessor::Unit::None, @@ -1283,26 +1285,13 @@ namespace FuelCellElectricGenerator { "Average", this->Name); - SetupOutputVariable("Generator Inverter Loss Power", - OutputProcessor::Unit::W, - this->Report.PCUlosses, - "System", - "Average", - this->Name); + SetupOutputVariable("Generator Inverter Loss Power", OutputProcessor::Unit::W, this->Report.PCUlosses, "System", "Average", this->Name); - SetupOutputVariable("Generator Produced DC Electric Power", - OutputProcessor::Unit::W, - this->Report.DCPowerGen, - "System", - "Average", - this->Name); + SetupOutputVariable( + "Generator Produced DC Electric Power", OutputProcessor::Unit::W, this->Report.DCPowerGen, "System", "Average", this->Name); - SetupOutputVariable("Generator DC Power Efficiency", - OutputProcessor::Unit::None, - this->Report.DCPowerEff, - "System", - "Average", - this->Name); + SetupOutputVariable( + "Generator DC Power Efficiency", OutputProcessor::Unit::None, this->Report.DCPowerEff, "System", "Average", this->Name); SetupOutputVariable("Generator Electric Storage Charge State", OutputProcessor::Unit::J, @@ -1311,47 +1300,23 @@ namespace FuelCellElectricGenerator { "Average", this->Name); - SetupOutputVariable("Generator DC Storage Charging Power", - OutputProcessor::Unit::W, - this->Report.StoredPower, - "System", - "Average", - this->Name); + SetupOutputVariable( + "Generator DC Storage Charging Power", OutputProcessor::Unit::W, this->Report.StoredPower, "System", "Average", this->Name); - SetupOutputVariable("Generator DC Storage Charging Energy", - OutputProcessor::Unit::J, - this->Report.StoredEnergy, - "System", - "Sum", - this->Name); + SetupOutputVariable( + "Generator DC Storage Charging Energy", OutputProcessor::Unit::J, this->Report.StoredEnergy, "System", "Sum", this->Name); - SetupOutputVariable("Generator DC Storage Discharging Power", - OutputProcessor::Unit::W, - this->Report.DrawnPower, - "System", - "Average", - this->Name); + SetupOutputVariable( + "Generator DC Storage Discharging Power", OutputProcessor::Unit::W, this->Report.DrawnPower, "System", "Average", this->Name); - SetupOutputVariable("Generator DC Storage Discharging Energy", - OutputProcessor::Unit::J, - this->Report.DrawnEnergy, - "System", - "Sum", - this->Name); + SetupOutputVariable( + "Generator DC Storage Discharging Energy", OutputProcessor::Unit::J, this->Report.DrawnEnergy, "System", "Sum", this->Name); - SetupOutputVariable("Generator Ancillary AC Electric Power", - OutputProcessor::Unit::W, - this->Report.ACancillariesPower, - "System", - "Average", - this->Name); + SetupOutputVariable( + "Generator Ancillary AC Electric Power", OutputProcessor::Unit::W, this->Report.ACancillariesPower, "System", "Average", this->Name); - SetupOutputVariable("Generator Ancillary AC Electric Energy", - OutputProcessor::Unit::J, - this->Report.ACancillariesEnergy, - "System", - "Sum", - this->Name); + SetupOutputVariable( + "Generator Ancillary AC Electric Energy", OutputProcessor::Unit::J, this->Report.ACancillariesEnergy, "System", "Sum", this->Name); SetupOutputVariable("Generator Fuel Cell Model Iteration Count", OutputProcessor::Unit::None, @@ -1397,7 +1362,9 @@ namespace FuelCellElectricGenerator { // set Day and Time of Last Shut Down this->FCPM.FractionalDayofLastShutDown = - double(DataGlobals::DayOfSim) + (int(DataGlobals::CurrentTime) + (DataHVACGlobals::SysTimeElapsed + (DataGlobals::CurrentTime - int(DataGlobals::CurrentTime)))) / DataGlobals::HoursInDay; + double(DataGlobals::DayOfSim) + + (int(DataGlobals::CurrentTime) + (DataHVACGlobals::SysTimeElapsed + (DataGlobals::CurrentTime - int(DataGlobals::CurrentTime)))) / + DataGlobals::HoursInDay; this->FCPM.HasBeenOn = false; if (this->FCPM.ShutDownTime > 0.0) this->FCPM.DuringShutDown = true; @@ -1415,7 +1382,9 @@ namespace FuelCellElectricGenerator { // set Day and Time of Last STart Up this->FCPM.FractionalDayofLastStartUp = - double(DataGlobals::DayOfSim) + (int(DataGlobals::CurrentTime) + (DataHVACGlobals::SysTimeElapsed + (DataGlobals::CurrentTime - int(DataGlobals::CurrentTime)))) / DataGlobals::HoursInDay; + double(DataGlobals::DayOfSim) + + (int(DataGlobals::CurrentTime) + (DataHVACGlobals::SysTimeElapsed + (DataGlobals::CurrentTime - int(DataGlobals::CurrentTime)))) / + DataGlobals::HoursInDay; this->FCPM.HasBeenOn = true; ++this->FCPM.NumCycles; // increment cycling counter @@ -1489,18 +1458,14 @@ namespace FuelCellElectricGenerator { if (this->FCPM.EffMode == DataGenerators::NormalizedCurveMode) { // Equation (8) in FuelCell Spec modified for normalized curve - Eel = CurveManager::CurveValue(this->FCPM.EffCurveID, Pel / this->FCPM.NomPel) * - this->FCPM.NomEff * + Eel = CurveManager::CurveValue(this->FCPM.EffCurveID, Pel / this->FCPM.NomPel) * this->FCPM.NomEff * (1.0 - this->FCPM.NumCycles * this->FCPM.CyclingDegradRat) * - (1.0 - max((this->FCPM.NumRunHours - this->FCPM.ThreshRunHours), 0.0) * - this->FCPM.OperateDegradRat); + (1.0 - max((this->FCPM.NumRunHours - this->FCPM.ThreshRunHours), 0.0) * this->FCPM.OperateDegradRat); } else if (this->FCPM.EffMode == DataGenerators::DirectCurveMode) { // Equation (8) in FuelCell Spec - Eel = CurveManager::CurveValue(this->FCPM.EffCurveID, Pel) * - (1.0 - this->FCPM.NumCycles * this->FCPM.CyclingDegradRat) * - (1.0 - max((this->FCPM.NumRunHours - this->FCPM.ThreshRunHours), 0.0) * - this->FCPM.OperateDegradRat); + Eel = CurveManager::CurveValue(this->FCPM.EffCurveID, Pel) * (1.0 - this->FCPM.NumCycles * this->FCPM.CyclingDegradRat) * + (1.0 - max((this->FCPM.NumRunHours - this->FCPM.ThreshRunHours), 0.0) * this->FCPM.OperateDegradRat); } this->FCPM.Eel = Eel; @@ -1524,20 +1489,18 @@ namespace FuelCellElectricGenerator { if (this->AirSup.AirSupRateMode == DataGenerators::ConstantStoicsAirRat) { // MEthod 1 // molar rate coeff working variable - Real64 NdotO2 = DataGenerators::FuelSupply(this->FuelSupNum).StoicOxygenRate * this->FCPM.NdotFuel * - this->AirSup.Stoics; + Real64 NdotO2 = DataGenerators::FuelSupply(this->FuelSupNum).StoicOxygenRate * this->FCPM.NdotFuel * this->AirSup.Stoics; this->FCPM.NdotAir = NdotO2 / this->AirSup.O2fraction; } else if (this->AirSup.AirSupRateMode == DataGenerators::QuadraticFuncofPel) { // MEthod 2 - this->FCPM.NdotAir = CurveManager::CurveValue(this->AirSup.AirFuncPelCurveID, Pel) * - (1 + this->AirSup.AirTempCoeff * this->AirSup.TairIntoFCPM); + this->FCPM.NdotAir = + CurveManager::CurveValue(this->AirSup.AirFuncPelCurveID, Pel) * (1 + this->AirSup.AirTempCoeff * this->AirSup.TairIntoFCPM); } else if (this->AirSup.AirSupRateMode == DataGenerators::QuadraticFuncofNdot) { // method 3 - this->FCPM.NdotAir = - CurveManager::CurveValue(this->AirSup.AirFuncNdotCurveID, this->FCPM.NdotFuel) * - (1 + this->AirSup.AirTempCoeff * this->AirSup.TairIntoFCPM); + this->FCPM.NdotAir = CurveManager::CurveValue(this->AirSup.AirFuncNdotCurveID, this->FCPM.NdotFuel) * + (1 + this->AirSup.AirTempCoeff * this->AirSup.TairIntoFCPM); } // Calculation Step 4. fuel compressor power @@ -1549,17 +1512,19 @@ namespace FuelCellElectricGenerator { if (DataGenerators::FuelSupply(this->FuelSupNum).FuelTempMode == DataGenerators::FuelInTempFromNode) { - DataGenerators::FuelSupply(this->FuelSupNum).TfuelIntoCompress = DataLoopNode::Node(DataGenerators::FuelSupply(this->FuelSupNum).NodeNum).Temp; + DataGenerators::FuelSupply(this->FuelSupNum).TfuelIntoCompress = + DataLoopNode::Node(DataGenerators::FuelSupply(this->FuelSupNum).NodeNum).Temp; } else if (DataGenerators::FuelSupply(this->FuelSupNum).FuelTempMode == DataGenerators::FuelInTempSchedule) { DataGenerators::FuelSupply(this->FuelSupNum).TfuelIntoCompress = - ScheduleManager::GetCurrentScheduleValue(DataGenerators::FuelSupply(this->FuelSupNum).SchedNum); + ScheduleManager::GetCurrentScheduleValue(DataGenerators::FuelSupply(this->FuelSupNum).SchedNum); } // evaluate heat capacity at average temperature using shomate - Real64 Cp; // temp Heat Capacity, used in thermochemistry units of (J/mol K) - Real64 Tavg = (DataGenerators::FuelSupply(this->FuelSupNum).TfuelIntoCompress + DataGenerators::FuelSupply(this->FuelSupNum).TfuelIntoFCPM) / 2.0; + Real64 Cp; // temp Heat Capacity, used in thermochemistry units of (J/mol K) + Real64 Tavg = + (DataGenerators::FuelSupply(this->FuelSupNum).TfuelIntoCompress + DataGenerators::FuelSupply(this->FuelSupNum).TfuelIntoFCPM) / 2.0; this->FigureFuelHeatCap(Tavg, Cp); // Cp in (J/mol K) // calculate a Temp of fuel out of compressor and into power module @@ -1569,22 +1534,23 @@ namespace FuelCellElectricGenerator { } else { DataGenerators::FuelSupply(this->FuelSupNum).TfuelIntoFCPM = ((1.0 - DataGenerators::FuelSupply(this->FuelSupNum).CompPowerLossFactor) * - DataGenerators::FuelSupply(this->FuelSupNum).PfuelCompEl / (this->FCPM.NdotFuel * Cp * 1000.0)) + - DataGenerators::FuelSupply(this->FuelSupNum).TfuelIntoCompress; // 1000 Cp units mol-> kmol + DataGenerators::FuelSupply(this->FuelSupNum).PfuelCompEl / (this->FCPM.NdotFuel * Cp * 1000.0)) + + DataGenerators::FuelSupply(this->FuelSupNum).TfuelIntoCompress; // 1000 Cp units mol-> kmol } // calc skin losses from fuel compressor DataGenerators::FuelSupply(this->FuelSupNum).QskinLoss = - DataGenerators::FuelSupply(this->FuelSupNum).CompPowerLossFactor * DataGenerators::FuelSupply(this->FuelSupNum).PfuelCompEl; + DataGenerators::FuelSupply(this->FuelSupNum).CompPowerLossFactor * DataGenerators::FuelSupply(this->FuelSupNum).PfuelCompEl; if (DataGenerators::FuelSupply(this->FuelSupNum).QskinLoss < 0.0) { - ShowWarningError("problem in FuelSupply.QskinLoss " + General::RoundSigDigits(DataGenerators::FuelSupply(this->FuelSupNum).QskinLoss, 3)); + ShowWarningError("problem in FuelSupply.QskinLoss " + + General::RoundSigDigits(DataGenerators::FuelSupply(this->FuelSupNum).QskinLoss, 3)); DataGenerators::FuelSupply(this->FuelSupNum).QskinLoss = 0.0; } // calculate total fuel enthalpy coming into power module // (Hmolfuel in KJ/mol) - Real64 Hmolfuel; // temp enthalpy of fuel mixture in KJ/mol + Real64 Hmolfuel; // temp enthalpy of fuel mixture in KJ/mol this->FigureFuelEnthalpy(DataGenerators::FuelSupply(this->FuelSupNum).TfuelIntoFCPM, Hmolfuel); // units, NdotFuel in kmol/sec. Hmolfule in KJ/mol , @@ -1595,8 +1561,7 @@ namespace FuelCellElectricGenerator { // calculate water consumption - this->FCPM.NdotLiqwater = - CurveManager::CurveValue(this->WaterSup.WaterSupRateCurveID, this->FCPM.NdotFuel); + this->FCPM.NdotLiqwater = CurveManager::CurveValue(this->WaterSup.WaterSupRateCurveID, this->FCPM.NdotFuel); // set inlet temp. (could move to init) @@ -1617,11 +1582,10 @@ namespace FuelCellElectricGenerator { } } - this->WaterSup.PwaterCompEl = - CurveManager::CurveValue(this->WaterSup.PmpPowerCurveID, this->FCPM.NdotLiqwater); + this->WaterSup.PwaterCompEl = CurveManager::CurveValue(this->WaterSup.PmpPowerCurveID, this->FCPM.NdotLiqwater); // 75.325 J/mol K Water at 0.1 MPa and 298 K, reference NIST WEBBOOK - Real64 CpWater; // heat capacity of water in molar units + Real64 CpWater; // heat capacity of water in molar units FigureLiquidWaterHeatCap(this->WaterSup.TwaterIntoCompress, CpWater); if (this->FCPM.NdotLiqwater <= 0.0) { // just pass through, domain probably collapsed in modeling @@ -1629,19 +1593,17 @@ namespace FuelCellElectricGenerator { } else { this->WaterSup.TwaterIntoFCPM = - ((1 - this->WaterSup.PmpPowerLossFactor) * this->WaterSup.PwaterCompEl / - (this->FCPM.NdotLiqwater * CpWater * 1000.0)) + + ((1 - this->WaterSup.PmpPowerLossFactor) * this->WaterSup.PwaterCompEl / (this->FCPM.NdotLiqwater * CpWater * 1000.0)) + this->WaterSup.TwaterIntoCompress; } - this->WaterSup.QskinLoss = - this->WaterSup.PmpPowerLossFactor * this->WaterSup.PwaterCompEl; + this->WaterSup.QskinLoss = this->WaterSup.PmpPowerLossFactor * this->WaterSup.PwaterCompEl; if (this->WaterSup.QskinLoss < 0.0) { this->WaterSup.QskinLoss = 0.0; } - Real64 HLiqWater; // temp enthalpy of liquid water in KJ/mol No Formation + Real64 HLiqWater; // temp enthalpy of liquid water in KJ/mol No Formation FigureLiquidWaterEnthalpy(this->WaterSup.TwaterIntoFCPM, HLiqWater); // HLiqWater in KJ/mol this->FCPM.WaterInEnthalpy = this->FCPM.NdotLiqwater * HLiqWater * 1000.0 * 1000.0; @@ -1650,8 +1612,7 @@ namespace FuelCellElectricGenerator { this->AirSup.TairIntoBlower = DataLoopNode::Node(this->AirSup.SupNodeNum).Temp; - this->AirSup.PairCompEl = - CurveManager::CurveValue(this->AirSup.BlowerPowerCurveID, this->FCPM.NdotAir); + this->AirSup.PairCompEl = CurveManager::CurveValue(this->AirSup.BlowerPowerCurveID, this->FCPM.NdotAir); Tavg = (this->AirSup.TairIntoBlower + this->AirSup.TairIntoFCPM) / 2.0; @@ -1661,9 +1622,7 @@ namespace FuelCellElectricGenerator { if (this->StackCooler.StackCoolerPresent) { this->StackCooler.qs_cool = - (this->StackCooler.r0 + - this->StackCooler.r1 * - (this->StackCooler.TstackActual - this->StackCooler.TstackNom)) * + (this->StackCooler.r0 + this->StackCooler.r1 * (this->StackCooler.TstackActual - this->StackCooler.TstackNom)) * (1 + this->StackCooler.r2 * Pel + this->StackCooler.r3 * Pel * Pel) * Pel; this->FCPM.QdotStackCool = this->StackCooler.qs_cool; @@ -1675,14 +1634,11 @@ namespace FuelCellElectricGenerator { auto const SELECT_CASE_var(this->AirSup.IntakeRecoveryMode); if (SELECT_CASE_var == DataGenerators::RecoverBurnInvertBatt) { - this->AirSup.QintakeRecovery = this->AuxilHeat.QairIntake + - this->ElecStorage.QairIntake + - this->Inverter.QairIntake; + this->AirSup.QintakeRecovery = this->AuxilHeat.QairIntake + this->ElecStorage.QairIntake + this->Inverter.QairIntake; } else if (SELECT_CASE_var == DataGenerators::RecoverAuxiliaryBurner) { this->AirSup.QintakeRecovery = this->AuxilHeat.QairIntake; } else if (SELECT_CASE_var == DataGenerators::RecoverInverterBatt) { - this->AirSup.QintakeRecovery = - this->ElecStorage.QairIntake + this->Inverter.QairIntake; + this->AirSup.QintakeRecovery = this->ElecStorage.QairIntake + this->Inverter.QairIntake; } else if (SELECT_CASE_var == DataGenerators::RecoverInverter) { this->AirSup.QintakeRecovery = this->Inverter.QairIntake; } else if (SELECT_CASE_var == DataGenerators::RecoverBattery) { @@ -1696,11 +1652,9 @@ namespace FuelCellElectricGenerator { this->AirSup.TairIntoFCPM = this->AirSup.TairIntoBlower; } else { - this->AirSup.TairIntoFCPM = - (((1 - this->AirSup.BlowerHeatLossFactor) * this->AirSup.PairCompEl + - this->AirSup.QintakeRecovery) / - (this->FCPM.NdotAir * Cp * 1000.0)) + - this->AirSup.TairIntoBlower; // 1000 Cp units mol-> kmol + this->AirSup.TairIntoFCPM = (((1 - this->AirSup.BlowerHeatLossFactor) * this->AirSup.PairCompEl + this->AirSup.QintakeRecovery) / + (this->FCPM.NdotAir * Cp * 1000.0)) + + this->AirSup.TairIntoBlower; // 1000 Cp units mol-> kmol } this->AirSup.QskinLoss = this->AirSup.BlowerHeatLossFactor * this->AirSup.PairCompEl; @@ -1710,7 +1664,7 @@ namespace FuelCellElectricGenerator { this->AirSup.QskinLoss = 0.0; } - Real64 Hmolair; // temp enthalpy of air mixture in KJ/mol + Real64 Hmolair; // temp enthalpy of air mixture in KJ/mol this->FigureAirEnthalpy(this->AirSup.TairIntoFCPM, Hmolair); // (Hmolair in KJ/mol) // units, NdotAir in kmol/sec.; Hmolfuel in KJ/mol , @@ -1745,11 +1699,11 @@ namespace FuelCellElectricGenerator { Real64 NdotH20ProdGas = this->FCPM.NdotFuel * DataGenerators::FuelSupply(this->FuelSupNum).H20ProductGasCoef; // set product gas constituent fractions (assume five usual components) - Real64 NdotCO2 = 0.0; // temp CO2 molar rate coef product gas stream - Real64 NdotN2 = 0.0; // temp Nitrogen rate coef product gas stream - Real64 Ndot02 = 0.0; // temp Oxygen rate coef product gas stream - Real64 NdotH20 = 0.0; // temp Water rate coef product gas stream - Real64 NdotAr = 0.0; // temp Argon rate coef product gas stream + Real64 NdotCO2 = 0.0; // temp CO2 molar rate coef product gas stream + Real64 NdotN2 = 0.0; // temp Nitrogen rate coef product gas stream + Real64 Ndot02 = 0.0; // temp Oxygen rate coef product gas stream + Real64 NdotH20 = 0.0; // temp Water rate coef product gas stream + Real64 NdotAr = 0.0; // temp Argon rate coef product gas stream // Product gas constituents are fixed (not a user defined thing) @@ -1802,7 +1756,7 @@ namespace FuelCellElectricGenerator { this->FCPM.ConstitMolalFract(5) = NdotAr / this->FCPM.NdotProdGas; // HmolProdGases KJ/mol) - Real64 HmolProdGases; // enthalpy of product gas mixture in KJ/mol + Real64 HmolProdGases; // enthalpy of product gas mixture in KJ/mol this->FigureProductGasesEnthalpy(this->FCPM.TprodGasLeavingFCPM, HmolProdGases); // units, NdotProdGas in kmol/sec.; HmolProdGases in KJ/mol , @@ -1818,8 +1772,7 @@ namespace FuelCellElectricGenerator { // get zone air temp if (this->FCPM.ZoneID > 0) { - this->FCPM.QdotSkin = this->FCPM.UAskin * - (this->FCPM.TprodGasLeavingFCPM - DataHeatBalFanSys::ZT(this->FCPM.ZoneID)); + this->FCPM.QdotSkin = this->FCPM.UAskin * (this->FCPM.TprodGasLeavingFCPM - DataHeatBalFanSys::ZT(this->FCPM.ZoneID)); } } else if (this->FCPM.SkinLossMode == DataGenerators::QuadraticFuelNdotSkin) { @@ -1829,8 +1782,7 @@ namespace FuelCellElectricGenerator { // calculation Step 10, AC FCPM power ancillaries - this->FCPM.PelancillariesAC = - this->FCPM.ANC0 + this->FCPM.ANC1 * this->FCPM.NdotFuel; + this->FCPM.PelancillariesAC = this->FCPM.ANC0 + this->FCPM.ANC1 * this->FCPM.NdotFuel; // calculation Step 11, Dilution air this->FigureAirEnthalpy(this->AirSup.TairIntoBlower, Hmolair); // (Hmolair in KJ/mol) @@ -1838,11 +1790,10 @@ namespace FuelCellElectricGenerator { // units, NdotDilutionAir in kmol/sec.; Hmolair in KJ/mol , // factor of 1000's to get to J/s or watts this->FCPM.DilutionAirInEnthalpy = Hmolair * 1000.0 * this->FCPM.NdotDilutionAir * 1000.0; - this->FCPM.DilutionAirOutEnthalpy = - this->FCPM.DilutionAirInEnthalpy + this->FCPM.StackHeatLossToDilution; + this->FCPM.DilutionAirOutEnthalpy = this->FCPM.DilutionAirInEnthalpy + this->FCPM.StackHeatLossToDilution; // calculation Step 12, Calculate Reforming water out enthalpy - Real64 HGasWater; // temp enthalpy of gaseous water in KJ/mol No Formation + Real64 HGasWater; // temp enthalpy of gaseous water in KJ/mol No Formation FigureGaseousWaterEnthalpy(this->FCPM.TprodGasLeavingFCPM, HGasWater); this->FCPM.WaterOutEnthalpy = HGasWater * 1000.0 * this->FCPM.NdotLiqwater * 1000.0; @@ -1850,13 +1801,11 @@ namespace FuelCellElectricGenerator { // calculation Step 13, Calculate Heat balance // move all terms in Equation 7 to RHS and calculate imbalance - Real64 MagofImbalance = -this->FCPM.TotFuelInEnthalphy - this->FCPM.TotAirInEnthalphy - - this->FCPM.WaterInEnthalpy - this->FCPM.DilutionAirInEnthalpy - - this->FCPM.NdotFuel * DataGenerators::FuelSupply(this->FuelSupNum).LHV * 1000000.0 - - this->FCPM.PelancillariesAC + this->FCPM.Pel + - this->FCPM.TotProdGasEnthalphy + this->FCPM.WaterOutEnthalpy + - this->FCPM.QdotStackCool + this->FCPM.QdotSkin + - this->FCPM.DilutionAirOutEnthalpy; + Real64 MagofImbalance = -this->FCPM.TotFuelInEnthalphy - this->FCPM.TotAirInEnthalphy - this->FCPM.WaterInEnthalpy - + this->FCPM.DilutionAirInEnthalpy - + this->FCPM.NdotFuel * DataGenerators::FuelSupply(this->FuelSupNum).LHV * 1000000.0 - this->FCPM.PelancillariesAC + + this->FCPM.Pel + this->FCPM.TotProdGasEnthalphy + this->FCPM.WaterOutEnthalpy + this->FCPM.QdotStackCool + + this->FCPM.QdotSkin + this->FCPM.DilutionAirOutEnthalpy; // Now find a new total prod Gas Enthalphy that would result in an energy balance // TODO check signs... @@ -1864,15 +1813,16 @@ namespace FuelCellElectricGenerator { // solve for a new TprodGasLeavingFCPM using regula falsi method - Real64 Acc = 0.01; // guessing need to refine - int MaxIter = 150; // guessing need to refine - SolverFlag = 0; // init + Real64 Acc = 0.01; // guessing need to refine + int MaxIter = 150; // guessing need to refine + SolverFlag = 0; // init Array1D Par(2); // parameters passed in to SolveRoot Par(1) = tmpTotProdGasEnthalpy; Par(2) = this->FCPM.NdotProdGas; Real64 tmpTprodGas = this->FCPM.TprodGasLeavingFCPM; auto boundFunc = std::bind(&FCDataStruct::FuelCellProductGasEnthResidual, this, std::placeholders::_1, std::placeholders::_2); - General::SolveRoot(Acc, MaxIter, SolverFlag, tmpTprodGas, boundFunc, DataGenerators::MinProductGasTemp, DataGenerators::MaxProductGasTemp, Par); + General::SolveRoot( + Acc, MaxIter, SolverFlag, tmpTprodGas, boundFunc, DataGenerators::MinProductGasTemp, DataGenerators::MaxProductGasTemp, Par); if (SolverFlag == -2) { @@ -1906,9 +1856,8 @@ namespace FuelCellElectricGenerator { PoutofInverter = PintoInverter - PpcuLosses; - this->ACPowerGen = PoutofInverter - this->FCPM.PelancillariesAC - - this->AirSup.PairCompEl - DataGenerators::FuelSupply(this->FuelSupNum).PfuelCompEl - - this->WaterSup.PwaterCompEl; + this->ACPowerGen = PoutofInverter - this->FCPM.PelancillariesAC - this->AirSup.PairCompEl - + DataGenerators::FuelSupply(this->FuelSupNum).PfuelCompEl - this->WaterSup.PwaterCompEl; this->Inverter.PCUlosses = PpcuLosses; // model assumes air intake is drawn over power conditioner to recovery heat this->Inverter.QairIntake = this->Inverter.PCUlosses; @@ -1929,10 +1878,10 @@ namespace FuelCellElectricGenerator { } void FCDataStruct::ManageElectStorInteractions(Real64 const Pdemand, - Real64 const EP_UNUSED(PpcuLosses), - bool &Constrained, - Real64 &Pstorage, - Real64 &PgridOverage // electricity that can't be stored and needs to go out + Real64 const EP_UNUSED(PpcuLosses), + bool &Constrained, + Real64 &Pstorage, + Real64 &PgridOverage // electricity that can't be stored and needs to go out ) { @@ -1948,14 +1897,14 @@ namespace FuelCellElectricGenerator { Real64 tmpPdraw = 0.0; Real64 tmpPcharge = 0.0; bool drawing = false; // true if drawing power - bool charging = false; // true if charging + bool charging = false; // true if charging Constrained = false; // step 1 figure out what is desired of electrical storage system if (this->FCPM.Pel < (Pdemand)) { // draw from storage - tmpPdraw = (Pdemand)-this->FCPM.Pel; + tmpPdraw = (Pdemand) - this->FCPM.Pel; drawing = true; } @@ -2087,7 +2036,7 @@ namespace FuelCellElectricGenerator { } Real64 FCDataStruct::FuelCellProductGasEnthResidual(Real64 const TprodGas, // temperature, this is "x" being searched - Array1 const &Par // par(1) = Generator Number + Array1 const &Par // par(1) = Generator Number ) { @@ -2175,8 +2124,7 @@ namespace FuelCellElectricGenerator { D = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateD; E = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateE; - tempCp += ((A + B * Tsho + C * pow_2_Tsho + D * pow_3_Tsho + E / pow_2_Tsho) * - this->AirSup.ConstitMolalFract(thisConstit)); + tempCp += ((A + B * Tsho + C * pow_2_Tsho + D * pow_3_Tsho + E / pow_2_Tsho) * this->AirSup.ConstitMolalFract(thisConstit)); } if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == DataGenerators::NASAPolynomial) { @@ -2188,7 +2136,7 @@ namespace FuelCellElectricGenerator { A5 = DataGenerators::GasPhaseThermoChemistryData(gasID).NASA_A5; tempCp += (A1 + A2 * Tkel + A3 * pow_2_Tkel + A4 * pow_3_Tkel + A5 * pow_4_Tkel) * DataGenerators::RinKJperMolpK * - this->AirSup.ConstitMolalFract(thisConstit); + this->AirSup.ConstitMolalFract(thisConstit); } } } @@ -2215,19 +2163,19 @@ namespace FuelCellElectricGenerator { // REFERENCES: // NIST Webbook on gas phase thermochemistry - Real64 A; // shomate coeff - Real64 B; // shomate coeff - Real64 C; // shomate coeff - Real64 D; // shomate coeff - Real64 E; // shomate coeff - Real64 F; // shomate coeff - Real64 H; // shomate coeff - Real64 A1; // NASA poly coeff - Real64 A2; // NASA poly coeff - Real64 A3; // NASA poly coeff - Real64 A4; // NASA poly coeff - Real64 A5; // NASA poly coeff - Real64 A6; // NASA poly coeff + Real64 A; // shomate coeff + Real64 B; // shomate coeff + Real64 C; // shomate coeff + Real64 D; // shomate coeff + Real64 E; // shomate coeff + Real64 F; // shomate coeff + Real64 H; // shomate coeff + Real64 A1; // NASA poly coeff + Real64 A2; // NASA poly coeff + Real64 A3; // NASA poly coeff + Real64 A4; // NASA poly coeff + Real64 A5; // NASA poly coeff + Real64 A6; // NASA poly coeff Real64 const Tsho = (FluidTemp + DataGlobals::KelvinConv) / 1000.0; // temp for Shomate eq in (Kelvin/1000) Real64 const Tkel = (FluidTemp + DataGlobals::KelvinConv); // temp for NASA eq. in Kelvin @@ -2298,16 +2246,16 @@ namespace FuelCellElectricGenerator { // REFERENCES: // NIST Webbook on gas phase thermochemistry - Real64 A; // shomate coeff - Real64 B; // shomate coeff - Real64 C; // shomate coeff - Real64 D; // shomate coeff - Real64 E; // shomate coeff - Real64 A1; // NASA poly coeff - Real64 A2; // NASA poly coeff - Real64 A3; // NASA poly coeff - Real64 A4; // NASA poly coeff - Real64 A5; // NASA poly coeff + Real64 A; // shomate coeff + Real64 B; // shomate coeff + Real64 C; // shomate coeff + Real64 D; // shomate coeff + Real64 E; // shomate coeff + Real64 A1; // NASA poly coeff + Real64 A2; // NASA poly coeff + Real64 A3; // NASA poly coeff + Real64 A4; // NASA poly coeff + Real64 A5; // NASA poly coeff Real64 const Tsho = (FluidTemp + DataGlobals::KelvinConv) / 1000.0; // temp for Shomate eq in (Kelvin/1000) Real64 const Tkel = (FluidTemp + DataGlobals::KelvinConv); // temp for NASA eq. in Kelvin @@ -2334,7 +2282,7 @@ namespace FuelCellElectricGenerator { E = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateE; tempCp += ((A + B * Tsho + C * pow_2_Tsho + D * pow_3_Tsho + E / pow_2_Tsho) * - DataGenerators::FuelSupply(this->FuelSupNum).ConstitMolalFract(thisConstit)); + DataGenerators::FuelSupply(this->FuelSupNum).ConstitMolalFract(thisConstit)); } if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == DataGenerators::NASAPolynomial) { @@ -2345,7 +2293,7 @@ namespace FuelCellElectricGenerator { A5 = DataGenerators::GasPhaseThermoChemistryData(gasID).NASA_A5; tempCp += (A1 + A2 * Tkel + A3 * pow_2_Tkel + A4 * pow_3_Tkel + A5 * pow_4_Tkel) * DataGenerators::RinKJperMolpK * - DataGenerators::FuelSupply(this->FuelSupNum).ConstitMolalFract(thisConstit); + DataGenerators::FuelSupply(this->FuelSupNum).ConstitMolalFract(thisConstit); } } } @@ -2372,19 +2320,19 @@ namespace FuelCellElectricGenerator { // REFERENCES: // NIST Webbook on gas phase thermochemistry - Real64 A; // shomate coeff - Real64 B; // shomate coeff - Real64 C; // shomate coeff - Real64 D; // shomate coeff - Real64 E; // shomate coeff - Real64 F; // shomate coeff - Real64 H; // shomate coeff - Real64 A1; // NASA poly coeff - Real64 A2; // NASA poly coeff - Real64 A3; // NASA poly coeff - Real64 A4; // NASA poly coeff - Real64 A5; // NASA poly coeff - Real64 A6; // NASA poly coeff + Real64 A; // shomate coeff + Real64 B; // shomate coeff + Real64 C; // shomate coeff + Real64 D; // shomate coeff + Real64 E; // shomate coeff + Real64 F; // shomate coeff + Real64 H; // shomate coeff + Real64 A1; // NASA poly coeff + Real64 A2; // NASA poly coeff + Real64 A3; // NASA poly coeff + Real64 A4; // NASA poly coeff + Real64 A5; // NASA poly coeff + Real64 A6; // NASA poly coeff Real64 const Tsho = (FluidTemp + DataGlobals::KelvinConv) / 1000.0; // temp for Shomate eq in (Kelvin/1000) Real64 const Tkel = (FluidTemp + DataGlobals::KelvinConv); // temp for NASA eq. in Kelvin @@ -2428,7 +2376,7 @@ namespace FuelCellElectricGenerator { tempHfuel += (((A1 + A2 * Tkel / 2.0 + A3 * pow_2_Tkel / 3.0 + A4 * pow_3_Tkel / 4.0 + A5 * pow_4_Tkel / 5.0 + A6 / Tkel) * DataGenerators::RinKJperMolpK * Tkel) - DataGenerators::GasPhaseThermoChemistryData(gasID).StdRefMolarEnthOfForm) * - DataGenerators::FuelSupply(this->FuelSupNum).ConstitMolalFract(thisConstit); + DataGenerators::FuelSupply(this->FuelSupNum).ConstitMolalFract(thisConstit); } } } @@ -2455,19 +2403,19 @@ namespace FuelCellElectricGenerator { // REFERENCES: // NIST Webbook on gas phase thermochemistry - Real64 A; // shomate coeff - Real64 B; // shomate coeff - Real64 C; // shomate coeff - Real64 D; // shomate coeff - Real64 E; // shomate coeff - Real64 F; // shomate coeff - Real64 H; // shomate coeff - Real64 A1; // NASA poly coeff - Real64 A2; // NASA poly coeff - Real64 A3; // NASA poly coeff - Real64 A4; // NASA poly coeff - Real64 A5; // NASA poly coeff - Real64 A6; // NASA poly coeff + Real64 A; // shomate coeff + Real64 B; // shomate coeff + Real64 C; // shomate coeff + Real64 D; // shomate coeff + Real64 E; // shomate coeff + Real64 F; // shomate coeff + Real64 H; // shomate coeff + Real64 A1; // NASA poly coeff + Real64 A2; // NASA poly coeff + Real64 A3; // NASA poly coeff + Real64 A4; // NASA poly coeff + Real64 A5; // NASA poly coeff + Real64 A6; // NASA poly coeff Real64 const Tsho = (FluidTemp + DataGlobals::KelvinConv) / 1000.0; // temp for Shomate eq in (Kelvin/1000) Real64 const Tkel = (FluidTemp + DataGlobals::KelvinConv); // temp for NASA eq. in Kelvin @@ -2496,7 +2444,7 @@ namespace FuelCellElectricGenerator { H = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateH; tempHprodGases += ((A * Tsho + B * pow_2_Tsho / 2.0 + C * pow_3_Tsho / 3.0 + D * pow_4_Tsho / 4.0 - E / Tsho + F - H) * - this->FCPM.ConstitMolalFract(thisConstit)); + this->FCPM.ConstitMolalFract(thisConstit)); } if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == DataGenerators::NASAPolynomial) { A1 = DataGenerators::GasPhaseThermoChemistryData(gasID).NASA_A1; @@ -2509,7 +2457,7 @@ namespace FuelCellElectricGenerator { tempHprodGases += (((A1 + A2 * Tkel / 2.0 + A3 * pow_2_Tkel / 3.0 + A4 * pow_3_Tkel / 4.0 + A5 * pow_4_Tkel / 5.0 + A6 / Tkel) * DataGenerators::RinKJperMolpK * Tkel) - DataGenerators::GasPhaseThermoChemistryData(gasID).StdRefMolarEnthOfForm) * - this->FCPM.ConstitMolalFract(thisConstit); + this->FCPM.ConstitMolalFract(thisConstit); } } // gasid > 0 } @@ -2527,16 +2475,16 @@ namespace FuelCellElectricGenerator { // RE-ENGINEERED na Real64 tempCp; - Real64 A; // shomate coeff - Real64 B; // shomate coeff - Real64 C; // shomate coeff - Real64 D; // shomate coeff - Real64 E; // shomate coeff - Real64 A1; // NASA poly coeff - Real64 A2; // NASA poly coeff - Real64 A3; // NASA poly coeff - Real64 A4; // NASA poly coeff - Real64 A5; // NASA poly coeff + Real64 A; // shomate coeff + Real64 B; // shomate coeff + Real64 C; // shomate coeff + Real64 D; // shomate coeff + Real64 E; // shomate coeff + Real64 A1; // NASA poly coeff + Real64 A2; // NASA poly coeff + Real64 A3; // NASA poly coeff + Real64 A4; // NASA poly coeff + Real64 A5; // NASA poly coeff Real64 const Tsho = (FluidTemp + DataGlobals::KelvinConv) / 1000.0; // temp for Shomate eq in (Kelvin/1000) Real64 const Tkel = (FluidTemp + DataGlobals::KelvinConv); // temp for NASA eq. in Kelvin @@ -2562,8 +2510,7 @@ namespace FuelCellElectricGenerator { D = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateD; E = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateE; - tempCp += ((A + B * Tsho + C * pow_2_Tsho + D * pow_3_Tsho + E / pow_2_Tsho) * - this->FCPM.ConstitMolalFract(thisConstit)); + tempCp += ((A + B * Tsho + C * pow_2_Tsho + D * pow_3_Tsho + E / pow_2_Tsho) * this->FCPM.ConstitMolalFract(thisConstit)); } if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == DataGenerators::NASAPolynomial) { @@ -2574,7 +2521,7 @@ namespace FuelCellElectricGenerator { A5 = DataGenerators::GasPhaseThermoChemistryData(gasID).NASA_A5; tempCp += (A1 + A2 * Tkel + A3 * pow_2_Tkel + A4 * pow_3_Tkel + A5 * pow_4_Tkel) * DataGenerators::RinKJperMolpK * - this->FCPM.ConstitMolalFract(thisConstit); + this->FCPM.ConstitMolalFract(thisConstit); } } } @@ -2592,16 +2539,16 @@ namespace FuelCellElectricGenerator { // RE-ENGINEERED na Real64 tempCp; - Real64 A; // shomate coeff - Real64 B; // shomate coeff - Real64 C; // shomate coeff - Real64 D; // shomate coeff - Real64 E; // shomate coeff - Real64 A1; // NASA poly coeff - Real64 A2; // NASA poly coeff - Real64 A3; // NASA poly coeff - Real64 A4; // NASA poly coeff - Real64 A5; // NASA poly coeff + Real64 A; // shomate coeff + Real64 B; // shomate coeff + Real64 C; // shomate coeff + Real64 D; // shomate coeff + Real64 E; // shomate coeff + Real64 A1; // NASA poly coeff + Real64 A2; // NASA poly coeff + Real64 A3; // NASA poly coeff + Real64 A4; // NASA poly coeff + Real64 A5; // NASA poly coeff Real64 const Tsho = (FluidTemp + DataGlobals::KelvinConv) / 1000.0; // temp for Shomate eq in (Kelvin/1000) Real64 const Tkel = (FluidTemp + DataGlobals::KelvinConv); // temp for NASA eq. in Kelvin @@ -2627,8 +2574,7 @@ namespace FuelCellElectricGenerator { D = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateD; E = DataGenerators::GasPhaseThermoChemistryData(gasID).ShomateE; - tempCp += ((A + B * Tsho + C * pow_2_Tsho + D * pow_3_Tsho + E / pow_2_Tsho) * - this->AuxilHeat.ConstitMolalFract(thisConstit)); + tempCp += ((A + B * Tsho + C * pow_2_Tsho + D * pow_3_Tsho + E / pow_2_Tsho) * this->AuxilHeat.ConstitMolalFract(thisConstit)); } if (DataGenerators::GasPhaseThermoChemistryData(gasID).ThermoMode == DataGenerators::NASAPolynomial) { @@ -2639,7 +2585,7 @@ namespace FuelCellElectricGenerator { A5 = DataGenerators::GasPhaseThermoChemistryData(gasID).NASA_A5; tempCp += (A1 + A2 * Tkel + A3 * pow_2_Tkel + A4 * pow_3_Tkel + A5 * pow_4_Tkel) * DataGenerators::RinKJperMolpK * - this->AuxilHeat.ConstitMolalFract(thisConstit); + this->AuxilHeat.ConstitMolalFract(thisConstit); } } } @@ -2648,7 +2594,7 @@ namespace FuelCellElectricGenerator { } void FCDataStruct::FigureGaseousWaterEnthalpy(Real64 const FluidTemp, // degree C - Real64 &HGasWater // kJ/mol + Real64 &HGasWater // kJ/mol ) { @@ -2665,19 +2611,19 @@ namespace FuelCellElectricGenerator { // REFERENCES: // NIST Webbook on gas phase thermochemistry - Real64 const A = 29.0373; // shomate coeff - Real64 const B = 10.2573; // shomate coeff - Real64 const C = 2.81048; // shomate coeff - Real64 const D = -0.95914; // shomate coeff - Real64 const E = 0.11725; // shomate coeff - Real64 const F = -250.569; // shomate coeff + Real64 const A = 29.0373; // shomate coeff + Real64 const B = 10.2573; // shomate coeff + Real64 const C = 2.81048; // shomate coeff + Real64 const D = -0.95914; // shomate coeff + Real64 const E = 0.11725; // shomate coeff + Real64 const F = -250.569; // shomate coeff Real64 const Tsho = (FluidTemp + DataGlobals::KelvinConv) / 1000.0; // temp for Shomate eq in (Kelvin/1000) HGasWater = A * Tsho + B * pow_2(Tsho) / 2.0 + C * pow_3(Tsho) / 3.0 + D * pow_4(Tsho) / 4.0 - E / Tsho + F; //- H } void FCDataStruct::FigureLiquidWaterEnthalpy(Real64 const FluidTemp, // degree C - Real64 &HLiqWater // kJ/mol + Real64 &HLiqWater // kJ/mol ) { @@ -2707,7 +2653,7 @@ namespace FuelCellElectricGenerator { } void FCDataStruct::FigureLiquidWaterHeatCap(Real64 const FluidTemp, // degree C - Real64 &Cp // (J/mol*K) + Real64 &Cp // (J/mol*K) ) { @@ -2745,8 +2691,7 @@ namespace FuelCellElectricGenerator { // Using lagged values inside a sequential substitution loop PacAncill = 0.0; // sect. 5.9 - this->FCPM.PelancillariesAC = - this->FCPM.ANC0 + this->FCPM.ANC1 * this->FCPM.NdotFuel; + this->FCPM.PelancillariesAC = this->FCPM.ANC0 + this->FCPM.ANC1 * this->FCPM.NdotFuel; // sect 6.0 this->AirSup.PairCompEl = CurveManager::CurveValue(this->AirSup.BlowerPowerCurveID, this->FCPM.NdotAir); @@ -2755,11 +2700,10 @@ namespace FuelCellElectricGenerator { CurveManager::CurveValue(DataGenerators::FuelSupply(this->FuelSupNum).CompPowerCurveID, this->FCPM.NdotFuel); // sect. 8.0 - this->WaterSup.PwaterCompEl = - CurveManager::CurveValue(this->WaterSup.PmpPowerCurveID, this->FCPM.NdotLiqwater); + this->WaterSup.PwaterCompEl = CurveManager::CurveValue(this->WaterSup.PmpPowerCurveID, this->FCPM.NdotLiqwater); - PacAncill = this->FCPM.PelancillariesAC + this->AirSup.PairCompEl + - DataGenerators::FuelSupply(this->FuelSupNum).PfuelCompEl + this->WaterSup.PwaterCompEl; + PacAncill = this->FCPM.PelancillariesAC + this->AirSup.PairCompEl + DataGenerators::FuelSupply(this->FuelSupNum).PfuelCompEl + + this->WaterSup.PwaterCompEl; } void FCDataStruct::FigurePowerConditioningLosses(Real64 const Pdemand, Real64 &PpcuLosses) @@ -2782,7 +2726,7 @@ namespace FuelCellElectricGenerator { // first use Pdemand instead of Pel to get initial estimate Real64 lastPpcuLosses = Pdemand * (1.0 - CurveManager::CurveValue(this->Inverter.EffQuadraticCurveID, Pdemand)) / - CurveManager::CurveValue(this->Inverter.EffQuadraticCurveID, Pdemand); + CurveManager::CurveValue(this->Inverter.EffQuadraticCurveID, Pdemand); for (int iter = 1; iter <= 20; ++iter) { // seems like need to iterate (??) Need to investigate number and convergence success here @@ -2795,9 +2739,9 @@ namespace FuelCellElectricGenerator { } } - void FCDataStruct::FigureTransientConstraints(Real64 &Pel, // DC power control setting for power module - bool &Constrained, // true if transient constraints kick in - Real64 &PelDiff // if constrained then this is the difference, positive + void FCDataStruct::FigureTransientConstraints(Real64 &Pel, // DC power control setting for power module + bool &Constrained, // true if transient constraints kick in + Real64 &PelDiff // if constrained then this is the difference, positive ) { @@ -2807,9 +2751,12 @@ namespace FuelCellElectricGenerator { // MODIFIED na // RE-ENGINEERED na - Real64 PelInput = Pel; // hold initial value of inout var + Real64 PelInput = Pel; // hold initial value of inout var - Real64 CurrentFractionalDay = double(DataGlobals::DayOfSim) + (int(DataGlobals::CurrentTime) + (DataHVACGlobals::SysTimeElapsed + (DataGlobals::CurrentTime - int(DataGlobals::CurrentTime)))) / DataGlobals::HoursInDay; + Real64 CurrentFractionalDay = + double(DataGlobals::DayOfSim) + + (int(DataGlobals::CurrentTime) + (DataHVACGlobals::SysTimeElapsed + (DataGlobals::CurrentTime - int(DataGlobals::CurrentTime)))) / + DataGlobals::HoursInDay; // Check if in start up and if it still should be if (this->FCPM.DuringStartUp) { @@ -2848,7 +2795,7 @@ namespace FuelCellElectricGenerator { Constrained = false; } } else if (Pel < this->FCPM.PelLastTimeStep) { // powering down - // working variable for min allowed by transient constraint + // working variable for min allowed by transient constraint Real64 MinPel = this->FCPM.PelLastTimeStep - this->FCPM.DownTranLimit * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; if (Pel < MinPel) { Pel = MinPel; @@ -2948,7 +2895,7 @@ namespace FuelCellElectricGenerator { Real64 NdotGas = this->AuxilHeat.NdotAuxMix; Real64 UAeff = this->ExhaustHX.hxs0 + this->ExhaustHX.hxs1 * NdotWater + this->ExhaustHX.hxs2 * pow_2(NdotWater) + - this->ExhaustHX.hxs3 * NdotGas + this->ExhaustHX.hxs4 * pow_2(NdotGas); + this->ExhaustHX.hxs3 * NdotGas + this->ExhaustHX.hxs4 * pow_2(NdotGas); Real64 TauxMix = this->AuxilHeat.TauxMix; Real64 TwaterIn = this->ExhaustHX.WaterInletTemp; @@ -2963,11 +2910,11 @@ namespace FuelCellElectricGenerator { if ((NdotCpWater != 0.0) && (NdotCpAuxMix != 0.0)) { // trap divide by zero // now evaluate Eq. 44 this->ExhaustHX.THXexh = ((1.0 - NdotCpAuxMix / NdotCpWater) / - (std::exp(UAeff * (1.0 / NdotCpAuxMix - 1.0 / NdotCpWater)) - NdotCpAuxMix / NdotCpWater)) * - TauxMix + - ((std::exp(UAeff * (1.0 / NdotCpAuxMix - 1.0 / NdotCpWater)) - 1.0) / - (std::exp(UAeff * (1.0 / NdotCpAuxMix - 1.0 / NdotCpWater)) - NdotCpAuxMix / NdotCpWater)) * - TwaterIn; + (std::exp(UAeff * (1.0 / NdotCpAuxMix - 1.0 / NdotCpWater)) - NdotCpAuxMix / NdotCpWater)) * + TauxMix + + ((std::exp(UAeff * (1.0 / NdotCpAuxMix - 1.0 / NdotCpWater)) - 1.0) / + (std::exp(UAeff * (1.0 / NdotCpAuxMix - 1.0 / NdotCpWater)) - NdotCpAuxMix / NdotCpWater)) * + TwaterIn; this->ExhaustHX.WaterOutletTemp = TwaterIn + (NdotCpAuxMix / NdotCpWater) * (TauxMix - this->ExhaustHX.THXexh); // Eq. 42 @@ -2978,7 +2925,8 @@ namespace FuelCellElectricGenerator { // ENDIF if ((this->ExhaustHX.THXexh - TwaterIn) != 0.0) { // trap divide by zero - this->ExhaustHX.qHX = UAeff * ((TauxMix - this->ExhaustHX.WaterOutletTemp) - (this->ExhaustHX.THXexh - TwaterIn)) / std::log((TauxMix - this->ExhaustHX.WaterOutletTemp) / (this->ExhaustHX.THXexh - TwaterIn)); + this->ExhaustHX.qHX = UAeff * ((TauxMix - this->ExhaustHX.WaterOutletTemp) - (this->ExhaustHX.THXexh - TwaterIn)) / + std::log((TauxMix - this->ExhaustHX.WaterOutletTemp) / (this->ExhaustHX.THXexh - TwaterIn)); } else { this->ExhaustHX.qHX = 0.0; } @@ -2988,13 +2936,11 @@ namespace FuelCellElectricGenerator { Real64 MWwater = DataGenerators::GasPhaseThermoChemistryData(4).MolecularWeight; Real64 NdotWater = this->ExhaustHX.WaterMassFlowRate / MWwater; - Real64 hgas = this->ExhaustHX.h0gas * std::pow(NdotGas / this->ExhaustHX.NdotGasRef, this->ExhaustHX.nCoeff); // Eq. 48 - Real64 hwater = this->ExhaustHX.h0Water * - std::pow(NdotWater / this->ExhaustHX.NdotWaterRef, this->ExhaustHX.mCoeff); // Eq. 48 + Real64 hgas = this->ExhaustHX.h0gas * std::pow(NdotGas / this->ExhaustHX.NdotGasRef, this->ExhaustHX.nCoeff); // Eq. 48 + Real64 hwater = this->ExhaustHX.h0Water * std::pow(NdotWater / this->ExhaustHX.NdotWaterRef, this->ExhaustHX.mCoeff); // Eq. 48 // now equation 47 - Real64 UAeff = 1.0 / (1.0 / (hgas * this->ExhaustHX.AreaGas) + 1.0 / (hwater * this->ExhaustHX.AreaWater) + - this->ExhaustHX.Fadjust); + Real64 UAeff = 1.0 / (1.0 / (hgas * this->ExhaustHX.AreaGas) + 1.0 / (hwater * this->ExhaustHX.AreaWater) + this->ExhaustHX.Fadjust); Real64 TauxMix = this->AuxilHeat.TauxMix; Real64 TwaterIn = this->ExhaustHX.WaterInletTemp; @@ -3008,11 +2954,11 @@ namespace FuelCellElectricGenerator { if ((NdotCpWater != 0.0) && (NdotCpAuxMix != 0.0)) { // trap divide by zero // now evaluate Eq. 44 this->ExhaustHX.THXexh = ((1.0 - NdotCpAuxMix / NdotCpWater) / - (std::exp(UAeff * (1.0 / NdotCpAuxMix - 1.0 / NdotCpWater)) - NdotCpAuxMix / NdotCpWater)) * - TauxMix + - ((std::exp(UAeff * (1.0 / NdotCpAuxMix - 1.0 / NdotCpWater)) - 1.0) / - (std::exp(UAeff * (1.0 / NdotCpAuxMix - 1.0 / NdotCpWater)) - NdotCpAuxMix / NdotCpWater)) * - TwaterIn; + (std::exp(UAeff * (1.0 / NdotCpAuxMix - 1.0 / NdotCpWater)) - NdotCpAuxMix / NdotCpWater)) * + TauxMix + + ((std::exp(UAeff * (1.0 / NdotCpAuxMix - 1.0 / NdotCpWater)) - 1.0) / + (std::exp(UAeff * (1.0 / NdotCpAuxMix - 1.0 / NdotCpWater)) - NdotCpAuxMix / NdotCpWater)) * + TwaterIn; this->ExhaustHX.WaterOutletTemp = TwaterIn + (NdotCpAuxMix / NdotCpWater) * (TauxMix - this->ExhaustHX.THXexh); // Eq. 42 @@ -3022,7 +2968,8 @@ namespace FuelCellElectricGenerator { } if ((this->ExhaustHX.THXexh - TwaterIn) != 0.0) { // trap divide by zero - this->ExhaustHX.qHX = UAeff * ((TauxMix - this->ExhaustHX.WaterOutletTemp) - (this->ExhaustHX.THXexh - TwaterIn)) / std::log((TauxMix - this->ExhaustHX.WaterOutletTemp) / (this->ExhaustHX.THXexh - TwaterIn)); + this->ExhaustHX.qHX = UAeff * ((TauxMix - this->ExhaustHX.WaterOutletTemp) - (this->ExhaustHX.THXexh - TwaterIn)) / + std::log((TauxMix - this->ExhaustHX.WaterOutletTemp) / (this->ExhaustHX.THXexh - TwaterIn)); } else { this->ExhaustHX.qHX = 0.0; } @@ -3034,9 +2981,8 @@ namespace FuelCellElectricGenerator { Real64 NdotWater = this->ExhaustHX.WaterMassFlowRate / MWwater; Real64 NdotGas = this->AuxilHeat.NdotAuxMix; - Real64 UAeff = this->ExhaustHX.hxs0 + this->ExhaustHX.hxs1 * NdotWater + - this->ExhaustHX.hxs2 * pow_2(NdotWater) + this->ExhaustHX.hxs3 * NdotGas + - this->ExhaustHX.hxs4 * pow_2(NdotGas); + Real64 UAeff = this->ExhaustHX.hxs0 + this->ExhaustHX.hxs1 * NdotWater + this->ExhaustHX.hxs2 * pow_2(NdotWater) + + this->ExhaustHX.hxs3 * NdotGas + this->ExhaustHX.hxs4 * pow_2(NdotGas); Real64 TauxMix = this->AuxilHeat.TauxMix; Real64 TwaterIn = this->ExhaustHX.WaterInletTemp; @@ -3057,7 +3003,8 @@ namespace FuelCellElectricGenerator { Real64 hxl1 = this->ExhaustHX.l1Coeff; Real64 hxl2 = this->ExhaustHX.l2Coeff; - this->ExhaustHX.CondensateRate = (TcondThresh - TwaterIn) * (hxl1 * (NdotWaterVapor / NdotGas) + hxl2 * pow_2(NdotWaterVapor / NdotGas)); + this->ExhaustHX.CondensateRate = + (TcondThresh - TwaterIn) * (hxl1 * (NdotWaterVapor / NdotGas) + hxl2 * pow_2(NdotWaterVapor / NdotGas)); if (this->ExhaustHX.CondensateRate < 0.0) this->ExhaustHX.CondensateRate = 0.0; @@ -3067,13 +3014,14 @@ namespace FuelCellElectricGenerator { // now evaluate Eq. 44 this->ExhaustHX.THXexh = ((1.0 - NdotCpAuxMix / NdotCpWater) / - (std::exp(UAeff * (1.0 / NdotCpAuxMix - 1.0 / NdotCpWater)) - NdotCpAuxMix / NdotCpWater)) * - TauxMix + - ((std::exp(UAeff * (1.0 / NdotCpAuxMix - 1.0 / NdotCpWater)) - 1.0) / - (std::exp(UAeff * (1.0 / NdotCpAuxMix - 1.0 / NdotCpWater)) - NdotCpAuxMix / NdotCpWater)) * - TwaterIn; + (std::exp(UAeff * (1.0 / NdotCpAuxMix - 1.0 / NdotCpWater)) - NdotCpAuxMix / NdotCpWater)) * + TauxMix + + ((std::exp(UAeff * (1.0 / NdotCpAuxMix - 1.0 / NdotCpWater)) - 1.0) / + (std::exp(UAeff * (1.0 / NdotCpAuxMix - 1.0 / NdotCpWater)) - NdotCpAuxMix / NdotCpWater)) * + TwaterIn; - this->ExhaustHX.WaterOutletTemp = TwaterIn + (NdotCpAuxMix / NdotCpWater) * (TauxMix - this->ExhaustHX.THXexh) + (this->ExhaustHX.CondensateRate * hfpwater) / NdotCpWater; + this->ExhaustHX.WaterOutletTemp = TwaterIn + (NdotCpAuxMix / NdotCpWater) * (TauxMix - this->ExhaustHX.THXexh) + + (this->ExhaustHX.CondensateRate * hfpwater) / NdotCpWater; if (this->ExhaustHX.CondensateRate > 0) { // Eq. 44 is not correct. use its result as first guess for revised way... // iterative solution because in condensing case THXexh is function of qSens and qLatent @@ -3083,9 +3031,10 @@ namespace FuelCellElectricGenerator { Real64 qLatent; if ((this->ExhaustHX.THXexh - TwaterIn) != 0.0 && - ((TauxMix - this->ExhaustHX.WaterOutletTemp) / (this->ExhaustHX.THXexh - TwaterIn) > 0.0001)) { // trap divide by zero and negative log - qSens = - UAeff * ((TauxMix - this->ExhaustHX.WaterOutletTemp) - (this->ExhaustHX.THXexh - TwaterIn)) / std::log((TauxMix - this->ExhaustHX.WaterOutletTemp) / (this->ExhaustHX.THXexh - TwaterIn)); + ((TauxMix - this->ExhaustHX.WaterOutletTemp) / (this->ExhaustHX.THXexh - TwaterIn) > + 0.0001)) { // trap divide by zero and negative log + qSens = UAeff * ((TauxMix - this->ExhaustHX.WaterOutletTemp) - (this->ExhaustHX.THXexh - TwaterIn)) / + std::log((TauxMix - this->ExhaustHX.WaterOutletTemp) / (this->ExhaustHX.THXexh - TwaterIn)); } else { qSens = 0.0; } @@ -3108,7 +3057,8 @@ namespace FuelCellElectricGenerator { this->ExhaustHX.THXexh = TauxMix; } - this->ExhaustHX.WaterOutletTemp = TwaterIn + (NdotCpAuxMix / NdotCpWater) * (TauxMix - this->ExhaustHX.THXexh) + (this->ExhaustHX.CondensateRate * hfpwater) / NdotCpWater; + this->ExhaustHX.WaterOutletTemp = TwaterIn + (NdotCpAuxMix / NdotCpWater) * (TauxMix - this->ExhaustHX.THXexh) + + (this->ExhaustHX.CondensateRate * hfpwater) / NdotCpWater; } } @@ -3118,10 +3068,12 @@ namespace FuelCellElectricGenerator { } if ((this->ExhaustHX.THXexh - TwaterIn) != 0.0 && - ((TauxMix - this->ExhaustHX.WaterOutletTemp) / (this->ExhaustHX.THXexh - TwaterIn) > 0.0001)) { // trap divide by zero and negative log + ((TauxMix - this->ExhaustHX.WaterOutletTemp) / (this->ExhaustHX.THXexh - TwaterIn) > + 0.0001)) { // trap divide by zero and negative log - this->ExhaustHX.qHX = UAeff * ((TauxMix - this->ExhaustHX.WaterOutletTemp) - (this->ExhaustHX.THXexh - TwaterIn)) / std::log((TauxMix - this->ExhaustHX.WaterOutletTemp) / (this->ExhaustHX.THXexh - TwaterIn)) + - this->ExhaustHX.CondensateRate * hfpwater; + this->ExhaustHX.qHX = UAeff * ((TauxMix - this->ExhaustHX.WaterOutletTemp) - (this->ExhaustHX.THXexh - TwaterIn)) / + std::log((TauxMix - this->ExhaustHX.WaterOutletTemp) / (this->ExhaustHX.THXexh - TwaterIn)) + + this->ExhaustHX.CondensateRate * hfpwater; } else { this->ExhaustHX.qHX = 0.0; } @@ -3141,7 +3093,6 @@ namespace FuelCellElectricGenerator { this->ExhaustHX.WaterOutletEnthalpy = DataLoopNode::Node(this->ExhaustHX.WaterInNode).Enthalpy + this->ExhaustHX.qHX; } - void FCDataStruct::getDesignCapacities(const PlantLocation &EP_UNUSED(calledFromLocation), Real64 &MaxLoad, Real64 &MinLoad, Real64 &OptLoad) { MaxLoad = 0.0; @@ -3149,7 +3100,10 @@ namespace FuelCellElectricGenerator { OptLoad = 0.0; } - void FCDataStruct::simulate(const PlantLocation &EP_UNUSED(calledFromLocation), bool FirstHVACIteration, Real64 &EP_UNUSED(CurLoad), bool EP_UNUSED(RunFlag)) + void FCDataStruct::simulate(const PlantLocation &EP_UNUSED(calledFromLocation), + bool FirstHVACIteration, + Real64 &EP_UNUSED(CurLoad), + bool EP_UNUSED(RunFlag)) { if (this->TypeOf == DataPlant::TypeOf_Generator_FCStackCooler) { PlantUtilities::UpdateComponentHeatRecoverySide(this->CWLoopNum, @@ -3197,17 +3151,17 @@ namespace FuelCellElectricGenerator { bool errFlag = false; PlantUtilities::ScanPlantLoopsForObject(this->NameExhaustHX, - DataPlant::TypeOf_Generator_FCExhaust, + DataPlant::TypeOf_Generator_FCExhaust, this->CWLoopNum, this->CWLoopSideNum, this->CWBranchNum, this->CWCompNum, - errFlag, - _, - _, - _, - _, - _); + errFlag, + _, + _, + _, + _, + _); // if there is a stack cooler option it might be connected to plant as well @@ -3274,8 +3228,10 @@ namespace FuelCellElectricGenerator { this->Inverter.PCUlosses = 0.0; this->Inverter.QairIntake = 0.0; - Real64 rho = FluidProperties::GetDensityGlycol( - DataPlant::PlantLoop(this->CWLoopNum).FluidName, DataGenerators::InitHRTemp, DataPlant::PlantLoop(this->CWLoopNum).FluidIndex, RoutineName); + Real64 rho = FluidProperties::GetDensityGlycol(DataPlant::PlantLoop(this->CWLoopNum).FluidName, + DataGenerators::InitHRTemp, + DataPlant::PlantLoop(this->CWLoopNum).FluidIndex, + RoutineName); this->ExhaustHX.WaterMassFlowRateDesign = this->ExhaustHX.WaterVolumeFlowMax * rho; this->ExhaustHX.WaterMassFlowRate = this->ExhaustHX.WaterMassFlowRateDesign; @@ -3283,13 +3239,13 @@ namespace FuelCellElectricGenerator { DataLoopNode::Node(this->ExhaustHX.WaterOutNode).Temp = DataGenerators::InitHRTemp; PlantUtilities::InitComponentNodes(0.0, - this->ExhaustHX.WaterMassFlowRateDesign, + this->ExhaustHX.WaterMassFlowRateDesign, this->ExhaustHX.WaterInNode, this->ExhaustHX.WaterOutNode, - this->CWLoopNum, - this->CWLoopSideNum, - this->CWBranchNum, - this->CWCompNum); + this->CWLoopNum, + this->CWLoopSideNum, + this->CWBranchNum, + this->CWCompNum); this->MyEnvrnFlag_Init = false; this->MyWarmupFlag_Init = true; @@ -3319,10 +3275,10 @@ namespace FuelCellElectricGenerator { PlantUtilities::SetComponentFlowRate(mdot, this->ExhaustHX.WaterInNode, this->ExhaustHX.WaterOutNode, - this->CWLoopNum, - this->CWLoopSideNum, - this->CWBranchNum, - this->CWCompNum); + this->CWLoopNum, + this->CWLoopSideNum, + this->CWBranchNum, + this->CWCompNum); this->ExhaustHX.WaterMassFlowRate = mdot; this->ExhaustHX.WaterInletTemp = DataLoopNode::Node(this->ExhaustHX.WaterInNode).Temp; @@ -3330,12 +3286,12 @@ namespace FuelCellElectricGenerator { } else { PlantUtilities::SetComponentFlowRate(this->ExhaustHX.WaterMassFlowRate, - this->ExhaustHX.WaterInNode, - this->ExhaustHX.WaterOutNode, - this->CWLoopNum, - this->CWLoopSideNum, - this->CWBranchNum, - this->CWCompNum); + this->ExhaustHX.WaterInNode, + this->ExhaustHX.WaterOutNode, + this->CWLoopNum, + this->CWLoopSideNum, + this->CWBranchNum, + this->CWCompNum); this->ExhaustHX.WaterInletTemp = DataLoopNode::Node(this->ExhaustHX.WaterInNode).Temp; } @@ -3363,7 +3319,8 @@ namespace FuelCellElectricGenerator { if (NumFuelCellGenerators == 0) return; if (DataGlobals::BeginEnvrnFlag && MyEnvrnFlag) { - for (auto &e : DataGenerators::FuelSupply) e.QskinLoss = 0.0; + for (auto &e : DataGenerators::FuelSupply) + e.QskinLoss = 0.0; MyEnvrnFlag = false; for (int i = FuelCell.l(), e = FuelCell.u(); i <= e; ++i) { auto &cell(FuelCell(i)); @@ -3390,19 +3347,17 @@ namespace FuelCellElectricGenerator { // first collect skin losses from different subsystems for (int FCnum = 1; FCnum <= NumFuelCellGenerators; ++FCnum) { auto &thisFC = FuelCell(FCnum); - Real64 TotalZoneHeatGain = thisFC.AirSup.QskinLoss + DataGenerators::FuelSupply(thisFC.FuelSupNum).QskinLoss + - thisFC.WaterSup.QskinLoss + thisFC.AuxilHeat.QskinLoss + - thisFC.FCPM.QdotSkin; // intake Blower losses to zone | fuel compressor losses to zone | water pump losses to - // zone | auxil burner losses to zone | power module (stack and reformer) losses to - // zone + Real64 TotalZoneHeatGain = thisFC.AirSup.QskinLoss + DataGenerators::FuelSupply(thisFC.FuelSupNum).QskinLoss + thisFC.WaterSup.QskinLoss + + thisFC.AuxilHeat.QskinLoss + thisFC.FCPM.QdotSkin; // intake Blower losses to zone | fuel compressor losses to + // zone | water pump losses to zone | auxil burner losses to + // zone | power module (stack and reformer) losses to zone // now account for other subsystems that may or may not have air intake recovery { auto const SELECT_CASE_var(thisFC.AirSup.IntakeRecoveryMode); if (SELECT_CASE_var == DataGenerators::NoRecoveryOnAirIntake) { // then the heat has to go into zone - TotalZoneHeatGain += - thisFC.AuxilHeat.QairIntake + thisFC.ElecStorage.QairIntake + thisFC.Inverter.QairIntake; + TotalZoneHeatGain += thisFC.AuxilHeat.QairIntake + thisFC.ElecStorage.QairIntake + thisFC.Inverter.QairIntake; } else if (SELECT_CASE_var == DataGenerators::RecoverAuxiliaryBurner) { TotalZoneHeatGain += thisFC.ElecStorage.QairIntake + thisFC.Inverter.QairIntake; @@ -3450,11 +3405,11 @@ namespace FuelCellElectricGenerator { void FCDataStruct::UpdateFuelCellGeneratorRecords() { - this->Report.ACPowerGen = this->ACPowerGen; // electrical power produced [W] + this->Report.ACPowerGen = this->ACPowerGen; // electrical power produced [W] this->Report.ACEnergyGen = this->ACPowerGen * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; // energy produced (J) - this->Report.QdotExhaust = 0.0; // reporting: exhaust gas heat recovered (W) - this->Report.TotalHeatEnergyRec = 0.0; // reporting: total heat recovered (J) - this->Report.ExhaustEnergyRec = 0.0; // reporting: exhaust gas heat recovered (J) + this->Report.QdotExhaust = 0.0; // reporting: exhaust gas heat recovered (W) + this->Report.TotalHeatEnergyRec = 0.0; // reporting: total heat recovered (J) + this->Report.ExhaustEnergyRec = 0.0; // reporting: exhaust gas heat recovered (J) this->Report.HeatRecInletTemp = 0.0; // reporting: Heat Recovery Loop Inlet Temperature (C) this->Report.HeatRecOutletTemp = 0.0; // reporting: Heat Recovery Loop Outlet Temperature (C) @@ -3465,32 +3420,34 @@ namespace FuelCellElectricGenerator { this->Report.OverallEfficiency = 0.0; this->Report.ExergyEfficiency = 0.0; - this->Report.TairInlet = this->AirSup.TairIntoBlower; // State point 1 - this->Report.TairIntoFCPM = this->AirSup.TairIntoFCPM; // State point 4 - this->Report.NdotAir = this->FCPM.NdotAir; // air flow in kmol/sec - this->Report.TotAirInEnthalphy = this->FCPM.TotAirInEnthalphy; // State point 4 - this->Report.BlowerPower = this->AirSup.PairCompEl; // electrical power used by air supply blower + this->Report.TairInlet = this->AirSup.TairIntoBlower; // State point 1 + this->Report.TairIntoFCPM = this->AirSup.TairIntoFCPM; // State point 4 + this->Report.NdotAir = this->FCPM.NdotAir; // air flow in kmol/sec + this->Report.TotAirInEnthalphy = this->FCPM.TotAirInEnthalphy; // State point 4 + this->Report.BlowerPower = this->AirSup.PairCompEl; // electrical power used by air supply blower this->Report.BlowerEnergy = this->AirSup.PairCompEl * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; // electrical energy - this->Report.BlowerSkinLoss = this->AirSup.QskinLoss; // heat rate of losses by blower + this->Report.BlowerSkinLoss = this->AirSup.QskinLoss; // heat rate of losses by blower this->Report.TfuelInlet = DataGenerators::FuelSupply(this->FuelSupNum).TfuelIntoCompress; // State point 2 this->Report.TfuelIntoFCPM = DataGenerators::FuelSupply(this->FuelSupNum).TfuelIntoFCPM; // TEmperature state point 5 [C] - this->Report.NdotFuel = this->FCPM.NdotFuel; // fuel flow in kmol/sec - this->Report.TotFuelInEnthalpy = this->FCPM.TotFuelInEnthalphy; // enthalpy at state point 5 [W] + this->Report.NdotFuel = this->FCPM.NdotFuel; // fuel flow in kmol/sec + this->Report.TotFuelInEnthalpy = this->FCPM.TotFuelInEnthalphy; // enthalpy at state point 5 [W] this->Report.FuelCompressPower = DataGenerators::FuelSupply(this->FuelSupNum).PfuelCompEl; // electrical power used by fuel supply compressor [W] - this->Report.FuelCompressEnergy = DataGenerators::FuelSupply(this->FuelSupNum).PfuelCompEl * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; // elect energy + this->Report.FuelCompressEnergy = + DataGenerators::FuelSupply(this->FuelSupNum).PfuelCompEl * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; // elect energy this->Report.FuelCompressSkinLoss = DataGenerators::FuelSupply(this->FuelSupNum).QskinLoss; // heat rate of losses.by fuel supply compressor [W] - this->Report.FuelEnergyLHV = this->FCPM.NdotFuel * DataGenerators::FuelSupply(this->FuelSupNum).LHV * 1000000.0 * DataHVACGlobals::TimeStepSys * - DataGlobals::SecInHour; // reporting: Fuel Energy used (J) + this->Report.FuelEnergyLHV = this->FCPM.NdotFuel * DataGenerators::FuelSupply(this->FuelSupNum).LHV * 1000000.0 * + DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; // reporting: Fuel Energy used (J) this->Report.FuelEnergyUseRateLHV = this->FCPM.NdotFuel * DataGenerators::FuelSupply(this->FuelSupNum).LHV * 1000000.0; // reporting: Fuel Energy used (W) this->Report.FuelEnergyHHV = this->FCPM.NdotFuel * DataGenerators::FuelSupply(this->FuelSupNum).HHV * - DataGenerators::FuelSupply(this->FuelSupNum).KmolPerSecToKgPerSec * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + DataGenerators::FuelSupply(this->FuelSupNum).KmolPerSecToKgPerSec * DataHVACGlobals::TimeStepSys * + DataGlobals::SecInHour; - this->Report.FuelEnergyUseRateHHV = - this->FCPM.NdotFuel * DataGenerators::FuelSupply(this->FuelSupNum).HHV * DataGenerators::FuelSupply(this->FuelSupNum).KmolPerSecToKgPerSec; + this->Report.FuelEnergyUseRateHHV = this->FCPM.NdotFuel * DataGenerators::FuelSupply(this->FuelSupNum).HHV * + DataGenerators::FuelSupply(this->FuelSupNum).KmolPerSecToKgPerSec; this->Report.FuelRateMdot = 0.0; // (Kg/s) diff --git a/src/EnergyPlus/FuelCellElectricGenerator.hh b/src/EnergyPlus/FuelCellElectricGenerator.hh index 457d717cfd6..c17711e5073 100644 --- a/src/EnergyPlus/FuelCellElectricGenerator.hh +++ b/src/EnergyPlus/FuelCellElectricGenerator.hh @@ -129,16 +129,16 @@ namespace FuelCellElectricGenerator { // Default Constructor FCPowerModuleStruct() - : EffMode(0), EffCurveID(0), NomEff(0.0), NomPel(0.0), NumCycles(0), CyclingDegradRat(0.0), NumRunHours(0.0), OperateDegradRat(0.0), - ThreshRunHours(0.0), UpTranLimit(0.0), DownTranLimit(0.0), StartUpTime(0.0), StartUpFuel(0.0), StartUpElectConsum(0.0), - StartUpElectProd(0.0), ShutDownTime(0.0), ShutDownFuel(0.0), ShutDownElectConsum(0.0), ANC0(0.0), ANC1(0.0), SkinLossMode(0), ZoneID(0), - RadiativeFract(0.0), QdotSkin(0.0), UAskin(0.0), SkinLossCurveID(0), WaterSupplyCurveID(0), NdotDilutionAir(0.0), - StackHeatLossToDilution(0.0), DilutionInletNode(0), DilutionExhaustNode(0), PelMin(0.0), PelMax(0.0), Pel(0.0), PelLastTimeStep(0.0), - Eel(0.0), QdotStackCool(0.0), FractionalDayofLastStartUp(0.0), FractionalDayofLastShutDown(0.0), HasBeenOn(true), DuringShutDown(false), - DuringStartUp(false), NdotFuel(0.0), TotFuelInEnthalphy(0.0), NdotProdGas(0.0), ConstitMolalFract(14, 0.0), GasLibID(14, 0), - TprodGasLeavingFCPM(0.0), NdotAir(0.0), TotAirInEnthalphy(0.0), NdotLiqwater(0.0), TwaterInlet(0.0), WaterInEnthalpy(0.0), - DilutionAirInEnthalpy(0.0), DilutionAirOutEnthalpy(0.0), PelancillariesAC(0.0), TotProdGasEnthalphy(0.0), WaterOutEnthalpy(0.0), - SeqSubstitIter(0), RegulaFalsiIter(0) + : EffMode(0), EffCurveID(0), NomEff(0.0), NomPel(0.0), NumCycles(0), CyclingDegradRat(0.0), NumRunHours(0.0), OperateDegradRat(0.0), + ThreshRunHours(0.0), UpTranLimit(0.0), DownTranLimit(0.0), StartUpTime(0.0), StartUpFuel(0.0), StartUpElectConsum(0.0), + StartUpElectProd(0.0), ShutDownTime(0.0), ShutDownFuel(0.0), ShutDownElectConsum(0.0), ANC0(0.0), ANC1(0.0), SkinLossMode(0), ZoneID(0), + RadiativeFract(0.0), QdotSkin(0.0), UAskin(0.0), SkinLossCurveID(0), WaterSupplyCurveID(0), NdotDilutionAir(0.0), + StackHeatLossToDilution(0.0), DilutionInletNode(0), DilutionExhaustNode(0), PelMin(0.0), PelMax(0.0), Pel(0.0), PelLastTimeStep(0.0), + Eel(0.0), QdotStackCool(0.0), FractionalDayofLastStartUp(0.0), FractionalDayofLastShutDown(0.0), HasBeenOn(true), DuringShutDown(false), + DuringStartUp(false), NdotFuel(0.0), TotFuelInEnthalphy(0.0), NdotProdGas(0.0), ConstitMolalFract(14, 0.0), GasLibID(14, 0), + TprodGasLeavingFCPM(0.0), NdotAir(0.0), TotAirInEnthalphy(0.0), NdotLiqwater(0.0), TwaterInlet(0.0), WaterInEnthalpy(0.0), + DilutionAirInEnthalpy(0.0), DilutionAirOutEnthalpy(0.0), PelancillariesAC(0.0), TotProdGasEnthalphy(0.0), WaterOutEnthalpy(0.0), + SeqSubstitIter(0), RegulaFalsiIter(0) { } }; @@ -171,10 +171,10 @@ namespace FuelCellElectricGenerator { // Default Constructor FCAirSupplyDataStruct() - : SupNodeNum(0), BlowerPowerCurveID(0), BlowerHeatLossFactor(0.0), AirSupRateMode(0), Stoics(0.0), AirFuncPelCurveID(0), - AirTempCoeff(0.0), AirFuncNdotCurveID(0), IntakeRecoveryMode(0), ConstituentMode(0), NumConstituents(0), ConstitName(14), - ConstitMolalFract(14, 0.0), GasLibID(14, 0), O2fraction(0.0), TairIntoBlower(0.0), TairIntoFCPM(0.0), PairCompEl(0.0), QskinLoss(0.0), - QintakeRecovery(0.0) + : SupNodeNum(0), BlowerPowerCurveID(0), BlowerHeatLossFactor(0.0), AirSupRateMode(0), Stoics(0.0), AirFuncPelCurveID(0), + AirTempCoeff(0.0), AirFuncNdotCurveID(0), IntakeRecoveryMode(0), ConstituentMode(0), NumConstituents(0), ConstitName(14), + ConstitMolalFract(14, 0.0), GasLibID(14, 0), O2fraction(0.0), TairIntoBlower(0.0), TairIntoFCPM(0.0), PairCompEl(0.0), QskinLoss(0.0), + QintakeRecovery(0.0) { } }; @@ -198,8 +198,8 @@ namespace FuelCellElectricGenerator { // Default Constructor FCWaterSupplyDataStruct() - : WaterTempMode(0), NodeNum(0), SchedNum(0), WaterSupRateCurveID(0), PmpPowerCurveID(0), PmpPowerLossFactor(0.0), IsModeled(true), - TwaterIntoCompress(0.0), TwaterIntoFCPM(0.0), PwaterCompEl(0.0), QskinLoss(0.0) + : WaterTempMode(0), NodeNum(0), SchedNum(0), WaterSupRateCurveID(0), PmpPowerCurveID(0), PmpPowerLossFactor(0.0), IsModeled(true), + TwaterIntoCompress(0.0), TwaterIntoFCPM(0.0), PwaterCompEl(0.0), QskinLoss(0.0) { } }; @@ -229,9 +229,9 @@ namespace FuelCellElectricGenerator { // Default Constructor FCAuxilHeatDataStruct() - : ZoneID(0), UASkin(0.0), ExcessAirRAT(0.0), ANC0(0.0), ANC1(0.0), SkinLossDestination(0), MaxPowerW(0.0), MinPowerW(0.0), - MaxPowerkmolperSec(0.0), MinPowerkmolperSec(0.0), NumConstituents(0), TauxMix(0.0), NdotAuxMix(0.0), ConstitMolalFract(14, 0.0), - GasLibID(14, 0), QskinLoss(0.0), QairIntake(0.0) + : ZoneID(0), UASkin(0.0), ExcessAirRAT(0.0), ANC0(0.0), ANC1(0.0), SkinLossDestination(0), MaxPowerW(0.0), MinPowerW(0.0), + MaxPowerkmolperSec(0.0), MinPowerkmolperSec(0.0), NumConstituents(0), TauxMix(0.0), NdotAuxMix(0.0), ConstitMolalFract(14, 0.0), + GasLibID(14, 0), QskinLoss(0.0), QairIntake(0.0) { } }; @@ -281,11 +281,11 @@ namespace FuelCellElectricGenerator { // Default Constructor FCExhaustHXDataStruct() - : WaterInNode(0), WaterOutNode(0), WaterVolumeFlowMax(0.0), ExhaustOutNode(0), HXmodelMode(0), HXEffect(0.0), hxs0(0.0), hxs1(0.0), - hxs2(0.0), hxs3(0.0), hxs4(0.0), h0gas(0.0), NdotGasRef(0.0), nCoeff(0.0), AreaGas(0.0), h0Water(0.0), NdotWaterRef(0.0), mCoeff(0.0), - AreaWater(0.0), Fadjust(0.0), l1Coeff(0.0), l2Coeff(0.0), CondensationThresholdTemp(0.0), qHX(0.0), THXexh(0.0), - WaterMassFlowRateDesign(0.0), WaterMassFlowRate(0.0), WaterInletTemp(0.0), WaterVaporFractExh(0.0), CondensateRate(0.0), - ConstitMolalFract(14, 0.0), GasLibID(14, 0), NdotHXleaving(0.0), WaterOutletTemp(0.0), WaterOutletEnthalpy(0.0) + : WaterInNode(0), WaterOutNode(0), WaterVolumeFlowMax(0.0), ExhaustOutNode(0), HXmodelMode(0), HXEffect(0.0), hxs0(0.0), hxs1(0.0), + hxs2(0.0), hxs3(0.0), hxs4(0.0), h0gas(0.0), NdotGasRef(0.0), nCoeff(0.0), AreaGas(0.0), h0Water(0.0), NdotWaterRef(0.0), mCoeff(0.0), + AreaWater(0.0), Fadjust(0.0), l1Coeff(0.0), l2Coeff(0.0), CondensationThresholdTemp(0.0), qHX(0.0), THXexh(0.0), + WaterMassFlowRateDesign(0.0), WaterMassFlowRate(0.0), WaterInletTemp(0.0), WaterVaporFractExh(0.0), CondensateRate(0.0), + ConstitMolalFract(14, 0.0), GasLibID(14, 0), NdotHXleaving(0.0), WaterOutletTemp(0.0), WaterOutletEnthalpy(0.0) { } }; @@ -307,7 +307,7 @@ namespace FuelCellElectricGenerator { // Default Constructor BatteryDichargeDataStruct() - : NumInSeries(0.0), NumInParallel(0.0), NominalVoltage(0.0), LowVoltsDischarged(0.0), NumTablePairs(0), k(0.0), c(0.0), qmax(0.0) + : NumInSeries(0.0), NumInParallel(0.0), NominalVoltage(0.0), LowVoltsDischarged(0.0), NumTablePairs(0), k(0.0), c(0.0), qmax(0.0) { } }; @@ -337,9 +337,9 @@ namespace FuelCellElectricGenerator { // Default Constructor FCElecStorageDataStruct() - : StorageModelMode(0), StartingEnergyStored(0.0), EnergeticEfficCharge(0.0), EnergeticEfficDischarge(0.0), MaxPowerDraw(0.0), - MaxPowerStore(0.0), NominalVoltage(0.0), NominalEnergyCapacity(0.0), ThisTimeStepStateOfCharge(0.0), LastTimeStepStateOfCharge(0.0), - PelNeedFromStorage(0.0), IdesiredDischargeCurrent(0.0), PelFromStorage(0.0), IfromStorage(0.0), PelIntoStorage(0.0), QairIntake(0.0) + : StorageModelMode(0), StartingEnergyStored(0.0), EnergeticEfficCharge(0.0), EnergeticEfficDischarge(0.0), MaxPowerDraw(0.0), + MaxPowerStore(0.0), NominalVoltage(0.0), NominalEnergyCapacity(0.0), ThisTimeStepStateOfCharge(0.0), LastTimeStepStateOfCharge(0.0), + PelNeedFromStorage(0.0), IdesiredDischargeCurrent(0.0), PelFromStorage(0.0), IfromStorage(0.0), PelIntoStorage(0.0), QairIntake(0.0) { } }; @@ -438,17 +438,17 @@ namespace FuelCellElectricGenerator { // Default Constructor FCReportDataStruct() - : ACPowerGen(0.0), ACEnergyGen(0.0), QdotExhaust(0.0), TotalHeatEnergyRec(0.0), ExhaustEnergyRec(0.0), FuelEnergyLHV(0.0), - FuelEnergyUseRateLHV(0.0), FuelEnergyHHV(0.0), FuelEnergyUseRateHHV(0.0), FuelRateMdot(0.0), HeatRecInletTemp(0.0), - HeatRecOutletTemp(0.0), HeatRecMdot(0.0), TairInlet(0.0), TairIntoFCPM(0.0), NdotAir(0.0), TotAirInEnthalphy(0.0), BlowerPower(0.0), - BlowerEnergy(0.0), BlowerSkinLoss(0.0), TfuelInlet(0.0), TfuelIntoFCPM(0.0), NdotFuel(0.0), TotFuelInEnthalpy(0.0), - FuelCompressPower(0.0), FuelCompressEnergy(0.0), FuelCompressSkinLoss(0.0), TwaterInlet(0.0), TwaterIntoFCPM(0.0), NdotWater(0.0), - WaterPumpPower(0.0), WaterPumpEnergy(0.0), WaterIntoFCPMEnthalpy(0.0), TprodGas(0.0), EnthalProdGas(0.0), NdotProdGas(0.0), - NdotProdAr(0.0), NdotProdCO2(0.0), NdotProdH2O(0.0), NdotProdN2(0.0), NdotProdO2(0.0), qHX(0.0), HXenergy(0.0), THXexh(0.0), - WaterVaporFractExh(0.0), CondensateRate(0.0), SeqSubstIterations(0), RegulaFalsiIterations(0), ACancillariesPower(0.0), - ACancillariesEnergy(0.0), PCUlosses(0.0), DCPowerGen(0.0), DCPowerEff(0.0), ElectEnergyinStorage(0.0), StoredPower(0.0), - StoredEnergy(0.0), DrawnPower(0.0), DrawnEnergy(0.0), SkinLossPower(0.0), SkinLossEnergy(0.0), SkinLossConvect(0.0), - SkinLossRadiat(0.0), ElectEfficiency(0.0), ThermalEfficiency(0.0), OverallEfficiency(0.0), ExergyEfficiency(0.0) + : ACPowerGen(0.0), ACEnergyGen(0.0), QdotExhaust(0.0), TotalHeatEnergyRec(0.0), ExhaustEnergyRec(0.0), FuelEnergyLHV(0.0), + FuelEnergyUseRateLHV(0.0), FuelEnergyHHV(0.0), FuelEnergyUseRateHHV(0.0), FuelRateMdot(0.0), HeatRecInletTemp(0.0), + HeatRecOutletTemp(0.0), HeatRecMdot(0.0), TairInlet(0.0), TairIntoFCPM(0.0), NdotAir(0.0), TotAirInEnthalphy(0.0), BlowerPower(0.0), + BlowerEnergy(0.0), BlowerSkinLoss(0.0), TfuelInlet(0.0), TfuelIntoFCPM(0.0), NdotFuel(0.0), TotFuelInEnthalpy(0.0), + FuelCompressPower(0.0), FuelCompressEnergy(0.0), FuelCompressSkinLoss(0.0), TwaterInlet(0.0), TwaterIntoFCPM(0.0), NdotWater(0.0), + WaterPumpPower(0.0), WaterPumpEnergy(0.0), WaterIntoFCPMEnthalpy(0.0), TprodGas(0.0), EnthalProdGas(0.0), NdotProdGas(0.0), + NdotProdAr(0.0), NdotProdCO2(0.0), NdotProdH2O(0.0), NdotProdN2(0.0), NdotProdO2(0.0), qHX(0.0), HXenergy(0.0), THXexh(0.0), + WaterVaporFractExh(0.0), CondensateRate(0.0), SeqSubstIterations(0), RegulaFalsiIterations(0), ACancillariesPower(0.0), + ACancillariesEnergy(0.0), PCUlosses(0.0), DCPowerGen(0.0), DCPowerEff(0.0), ElectEnergyinStorage(0.0), StoredPower(0.0), + StoredEnergy(0.0), DrawnPower(0.0), DrawnEnergy(0.0), SkinLossPower(0.0), SkinLossEnergy(0.0), SkinLossConvect(0.0), + SkinLossRadiat(0.0), ElectEfficiency(0.0), ThermalEfficiency(0.0), OverallEfficiency(0.0), ExergyEfficiency(0.0) { } }; @@ -485,9 +485,9 @@ namespace FuelCellElectricGenerator { // Default Constructor FCStackCoolerDataStruct() - : WaterInNode(0), WaterOutNode(0), TstackNom(0.0), TstackActual(0.0), r0(0.0), r1(0.0), r2(0.0), r3(0.0), MdotStackCoolant(0.0), - UAs_cool(0.0), Fs_cogen(0.0), As_cogen(0.0), MdotCogenNom(0.0), hCogenNom(0.0), ns(0.0), PstackPumpEl(0.0), PmpPowerLossFactor(0.0), - f0(0.0), f1(0.0), f2(0.0), StackCoolerPresent(false), qs_cool(0.0), qs_air(0.0) + : WaterInNode(0), WaterOutNode(0), TstackNom(0.0), TstackActual(0.0), r0(0.0), r1(0.0), r2(0.0), r3(0.0), MdotStackCoolant(0.0), + UAs_cool(0.0), Fs_cogen(0.0), As_cogen(0.0), MdotCogenNom(0.0), hCogenNom(0.0), ns(0.0), PstackPumpEl(0.0), PmpPowerLossFactor(0.0), + f0(0.0), f1(0.0), f2(0.0), StackCoolerPresent(false), qs_cool(0.0), qs_air(0.0) { } }; @@ -533,8 +533,8 @@ namespace FuelCellElectricGenerator { // Default Constructor FCDataStruct() - : TypeOf(0), FuelSupNum(0), CWLoopNum(0), CWLoopSideNum(0), CWBranchNum(0), CWCompNum(0), ACPowerGen(0.0), QconvZone(0.0), QradZone(0.0), - DynamicsControlID(0), TimeElapsed(0.0), MyEnvrnFlag_Init(true), MyWarmupFlag_Init(false), MyPlantScanFlag_Init(true) + : TypeOf(0), FuelSupNum(0), CWLoopNum(0), CWLoopSideNum(0), CWBranchNum(0), CWCompNum(0), ACPowerGen(0.0), QconvZone(0.0), QradZone(0.0), + DynamicsControlID(0), TimeElapsed(0.0), MyEnvrnFlag_Init(true), MyWarmupFlag_Init(false), MyPlantScanFlag_Init(true) { } @@ -568,9 +568,9 @@ namespace FuelCellElectricGenerator { void FigurePowerConditioningLosses(Real64 Pdemand, Real64 &PpcuLosses); - void FigureTransientConstraints(Real64 &Pel, // DC power control setting for power module - bool &Constrained, // true if transient constraints kick in (TODO: never used anywhere) - Real64 &PelDiff // if constrained then this is the difference, positive + void FigureTransientConstraints(Real64 &Pel, // DC power control setting for power module + bool &Constrained, // true if transient constraints kick in (TODO: never used anywhere) + Real64 &PelDiff // if constrained then this is the difference, positive ); Real64 FuelCellProductGasEnthResidual(Real64 TprodGas, Array1 const &Par); @@ -591,7 +591,7 @@ namespace FuelCellElectricGenerator { void ManageElectStorInteractions(Real64 Pdemand, Real64 PpcuLosses, - bool &Constrained, // TODO: This one is never used anywhere in the code + bool &Constrained, // TODO: This one is never used anywhere in the code Real64 &Pstorage, Real64 &PgridOverage // electricity that can't be stored and needs to go out ); @@ -612,7 +612,7 @@ namespace FuelCellElectricGenerator { extern bool getFuelCellInputFlag; extern int NumFuelCellGenerators; extern Array1D_bool CheckEquipName; - extern Array1D FuelCell; // dimension to number of machines + extern Array1D FuelCell; } // namespace FuelCellElectricGenerator diff --git a/tst/EnergyPlus/unit/FuelCellElectricGenerator.unit.cc b/tst/EnergyPlus/unit/FuelCellElectricGenerator.unit.cc index 0db54f060d0..e35e66bcd36 100644 --- a/tst/EnergyPlus/unit/FuelCellElectricGenerator.unit.cc +++ b/tst/EnergyPlus/unit/FuelCellElectricGenerator.unit.cc @@ -60,7 +60,9 @@ using namespace EnergyPlus; using namespace ObjexxFCL; -class FuelCellGenFixture : public EnergyPlusFixture {}; +class FuelCellGenFixture : public EnergyPlusFixture +{ +}; TEST_F(FuelCellGenFixture, FuelCellTest_LowInletEnthalySover1) { From c3ca45defd59643ef6ef36186eb180bd7a003bba Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Mon, 2 Dec 2019 07:52:19 -0700 Subject: [PATCH 49/51] minor cleanups --- src/EnergyPlus/WaterUse.cc | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/EnergyPlus/WaterUse.cc b/src/EnergyPlus/WaterUse.cc index 73ba6cfa6b9..d018e139876 100644 --- a/src/EnergyPlus/WaterUse.cc +++ b/src/EnergyPlus/WaterUse.cc @@ -1014,7 +1014,6 @@ namespace EnergyPlus { } // Get the requested total flow rate - // 11-17-2006 BG Added multipliers in next block if (this->Zone > 0) { if (this->FlowRateFracSchedule > 0) { this->TotalVolFlowRate = @@ -1490,24 +1489,25 @@ namespace EnergyPlus { // Calculates report variables for stand alone water use for (int WaterEquipNum = 1; WaterEquipNum <= numWaterEquipment; ++WaterEquipNum) { - WaterEquipment(WaterEquipNum).ColdVolFlowRate = WaterEquipment(WaterEquipNum).ColdMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); - WaterEquipment(WaterEquipNum).HotVolFlowRate = WaterEquipment(WaterEquipNum).HotMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); - WaterEquipment(WaterEquipNum).TotalVolFlowRate = WaterEquipment(WaterEquipNum).ColdVolFlowRate + WaterEquipment(WaterEquipNum).HotVolFlowRate; + auto &thisWEq = WaterEquipment(WaterEquipNum); + thisWEq.ColdVolFlowRate = thisWEq.ColdMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); + thisWEq.HotVolFlowRate = thisWEq.HotMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); + thisWEq.TotalVolFlowRate = thisWEq.ColdVolFlowRate + thisWEq.HotVolFlowRate; - WaterEquipment(WaterEquipNum).ColdVolume = WaterEquipment(WaterEquipNum).ColdVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - WaterEquipment(WaterEquipNum).HotVolume = WaterEquipment(WaterEquipNum).HotVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - WaterEquipment(WaterEquipNum).TotalVolume = WaterEquipment(WaterEquipNum).TotalVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + thisWEq.ColdVolume = thisWEq.ColdVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + thisWEq.HotVolume = thisWEq.HotVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + thisWEq.TotalVolume = thisWEq.TotalVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - if (WaterEquipment(WaterEquipNum).Connections == 0) { - WaterEquipment(WaterEquipNum).Power = WaterEquipment(WaterEquipNum).HotMassFlowRate * + if (thisWEq.Connections == 0) { + thisWEq.Power = thisWEq.HotMassFlowRate * Psychrometrics::CPHW(DataGlobals::InitConvTemp) * - (WaterEquipment(WaterEquipNum).HotTemp - WaterEquipment(WaterEquipNum).ColdTemp); + (thisWEq.HotTemp - thisWEq.ColdTemp); } else { - WaterEquipment(WaterEquipNum).Power = WaterEquipment(WaterEquipNum).HotMassFlowRate * Psychrometrics::CPHW(DataGlobals::InitConvTemp) * - (WaterEquipment(WaterEquipNum).HotTemp - WaterConnections(WaterEquipment(WaterEquipNum).Connections).ReturnTemp); + thisWEq.Power = thisWEq.HotMassFlowRate * Psychrometrics::CPHW(DataGlobals::InitConvTemp) * + (thisWEq.HotTemp - WaterConnections(thisWEq.Connections).ReturnTemp); } - WaterEquipment(WaterEquipNum).Energy = WaterEquipment(WaterEquipNum).Power * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + thisWEq.Energy = thisWEq.Power * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; } } From 4879dd618ea1d308b2e0e2d277344340534231d6 Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Mon, 2 Dec 2019 08:34:07 -0700 Subject: [PATCH 50/51] move output vars to standalone --- src/EnergyPlus/WaterUse.cc | 731 +++++++++++++++++++------------------ src/EnergyPlus/WaterUse.hh | 11 +- 2 files changed, 378 insertions(+), 364 deletions(-) diff --git a/src/EnergyPlus/WaterUse.cc b/src/EnergyPlus/WaterUse.cc index d018e139876..22039f2f8b3 100644 --- a/src/EnergyPlus/WaterUse.cc +++ b/src/EnergyPlus/WaterUse.cc @@ -122,14 +122,14 @@ namespace EnergyPlus { int WaterEquipNum; int WaterConnNum; int NumIteration; - static bool MyEnvrnFlag(true); + static bool MyEnvrnFlagLocal(true); if (getWaterUseInputFlag) { GetWaterUseInput(); getWaterUseInputFlag = false; } - if (DataGlobals::BeginEnvrnFlag && MyEnvrnFlag) { + if (DataGlobals::BeginEnvrnFlag && MyEnvrnFlagLocal) { if (numWaterEquipment > 0) { for (auto &e : WaterEquipment) { e.SensibleRate = 0.0; @@ -147,10 +147,10 @@ namespace EnergyPlus { e.TotalMassFlowRate = 0.0; } - MyEnvrnFlag = false; + MyEnvrnFlagLocal = false; } - if (!DataGlobals::BeginEnvrnFlag) MyEnvrnFlag = true; + if (!DataGlobals::BeginEnvrnFlag) MyEnvrnFlagLocal = true; // Simulate all unconnected WATER USE EQUIPMENT objects for (WaterEquipNum = 1; WaterEquipNum <= numWaterEquipment; ++WaterEquipNum) { @@ -237,12 +237,16 @@ namespace EnergyPlus { int const MaxIterations(100); Real64 const Tolerance(0.1); // Make input? - static bool MyEnvrnFlag(true); - - if (DataGlobals::BeginEnvrnFlag && MyEnvrnFlag) { + if (DataGlobals::BeginEnvrnFlag && this->MyEnvrnFlag) { if (numWaterEquipment > 0) { for (int i = WaterEquipment.l(), e = WaterEquipment.u(); i <= e; ++i) { WaterEquipment(i).reset(); + + if (WaterEquipment(i).setupMyOutputVars) { + WaterEquipment(i).setupOutputVars(); + WaterEquipment(i).setupMyOutputVars = false; + } + } } @@ -251,10 +255,10 @@ namespace EnergyPlus { e.TotalMassFlowRate = 0.0; } - MyEnvrnFlag = false; + this->MyEnvrnFlag = false; } - if (!DataGlobals::BeginEnvrnFlag) MyEnvrnFlag = true; + if (!DataGlobals::BeginEnvrnFlag) this->MyEnvrnFlag = true; this->InitConnections(); @@ -282,7 +286,6 @@ namespace EnergyPlus { } break; } - } // WHILE this->UpdateWaterConnections(); @@ -592,387 +595,381 @@ namespace EnergyPlus { WaterConnections(WaterConnNum).PeakMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp)); } } + } - // Setup EQUIPMENT report variables (now that connections have been established) - // CurrentModuleObject='WaterUse:Equipment' - for (int WaterEquipNum = 1; WaterEquipNum <= numWaterEquipment; ++WaterEquipNum) { - - SetupOutputVariable("Water Use Equipment Hot Water Mass Flow Rate", - OutputProcessor::Unit::kg_s, - WaterEquipment(WaterEquipNum).HotMassFlowRate, - "System", - "Average", - WaterEquipment(WaterEquipNum).Name); - - SetupOutputVariable("Water Use Equipment Cold Water Mass Flow Rate", - OutputProcessor::Unit::kg_s, - WaterEquipment(WaterEquipNum).ColdMassFlowRate, - "System", - "Average", - WaterEquipment(WaterEquipNum).Name); - - SetupOutputVariable("Water Use Equipment Total Mass Flow Rate", - OutputProcessor::Unit::kg_s, - WaterEquipment(WaterEquipNum).TotalMassFlowRate, - "System", - "Average", - WaterEquipment(WaterEquipNum).Name); - - SetupOutputVariable("Water Use Equipment Hot Water Volume Flow Rate", - OutputProcessor::Unit::m3_s, - WaterEquipment(WaterEquipNum).HotVolFlowRate, - "System", - "Average", - WaterEquipment(WaterEquipNum).Name); - - SetupOutputVariable("Water Use Equipment Cold Water Volume Flow Rate", - OutputProcessor::Unit::m3_s, - WaterEquipment(WaterEquipNum).ColdVolFlowRate, - "System", - "Average", - WaterEquipment(WaterEquipNum).Name); - - SetupOutputVariable("Water Use Equipment Total Volume Flow Rate", - OutputProcessor::Unit::m3_s, - WaterEquipment(WaterEquipNum).TotalVolFlowRate, - "System", - "Average", - WaterEquipment(WaterEquipNum).Name); - - SetupOutputVariable("Water Use Equipment Hot Water Volume", - OutputProcessor::Unit::m3, - WaterEquipment(WaterEquipNum).HotVolume, - "System", - "Sum", - WaterEquipment(WaterEquipNum).Name); - - SetupOutputVariable("Water Use Equipment Cold Water Volume", - OutputProcessor::Unit::m3, - WaterEquipment(WaterEquipNum).ColdVolume, + void WaterEquipmentType::setupOutputVars() + { + SetupOutputVariable("Water Use Equipment Hot Water Mass Flow Rate", + OutputProcessor::Unit::kg_s, + this->HotMassFlowRate, + "System", + "Average", + this->Name); + + SetupOutputVariable("Water Use Equipment Cold Water Mass Flow Rate", + OutputProcessor::Unit::kg_s, + this->ColdMassFlowRate, + "System", + "Average", + this->Name); + + SetupOutputVariable("Water Use Equipment Total Mass Flow Rate", + OutputProcessor::Unit::kg_s, + this->TotalMassFlowRate, + "System", + "Average", + this->Name); + + SetupOutputVariable("Water Use Equipment Hot Water Volume Flow Rate", + OutputProcessor::Unit::m3_s, + this->HotVolFlowRate, + "System", + "Average", + this->Name); + + SetupOutputVariable("Water Use Equipment Cold Water Volume Flow Rate", + OutputProcessor::Unit::m3_s, + this->ColdVolFlowRate, + "System", + "Average", + this->Name); + + SetupOutputVariable("Water Use Equipment Total Volume Flow Rate", + OutputProcessor::Unit::m3_s, + this->TotalVolFlowRate, + "System", + "Average", + this->Name); + + SetupOutputVariable("Water Use Equipment Hot Water Volume", + OutputProcessor::Unit::m3, + this->HotVolume, + "System", + "Sum", + this->Name); + + SetupOutputVariable("Water Use Equipment Cold Water Volume", + OutputProcessor::Unit::m3, + this->ColdVolume, + "System", + "Sum", + this->Name); + + SetupOutputVariable("Water Use Equipment Total Volume", + OutputProcessor::Unit::m3, + this->TotalVolume, + "System", + "Sum", + this->Name, + _, + "Water", + "WATERSYSTEMS", + this->EndUseSubcatName, + "Plant"); + SetupOutputVariable("Water Use Equipment Mains Water Volume", + OutputProcessor::Unit::m3, + this->TotalVolume, + "System", + "Sum", + this->Name, + _, + "MainsWater", + "WATERSYSTEMS", + this->EndUseSubcatName, + "Plant"); + + SetupOutputVariable("Water Use Equipment Hot Water Temperature", + OutputProcessor::Unit::C, + this->HotTemp, + "System", + "Average", + this->Name); + + SetupOutputVariable("Water Use Equipment Cold Water Temperature", + OutputProcessor::Unit::C, + this->ColdTemp, + "System", + "Average", + this->Name); + + SetupOutputVariable("Water Use Equipment Target Water Temperature", + OutputProcessor::Unit::C, + this->TargetTemp, + "System", + "Average", + this->Name); + + SetupOutputVariable("Water Use Equipment Mixed Water Temperature", + OutputProcessor::Unit::C, + this->MixedTemp, + "System", + "Average", + this->Name); + + SetupOutputVariable("Water Use Equipment Drain Water Temperature", + OutputProcessor::Unit::C, + this->DrainTemp, + "System", + "Average", + this->Name); + + SetupOutputVariable("Water Use Equipment Heating Rate", + OutputProcessor::Unit::W, + this->Power, + "System", + "Average", + this->Name); + + if (this->Connections == 0) { + SetupOutputVariable("Water Use Equipment Heating Energy", + OutputProcessor::Unit::J, + this->Energy, "System", "Sum", - WaterEquipment(WaterEquipNum).Name); + this->Name, + _, + "DISTRICTHEATING", + "WATERSYSTEMS", + this->EndUseSubcatName, + "Plant"); - SetupOutputVariable("Water Use Equipment Total Volume", - OutputProcessor::Unit::m3, - WaterEquipment(WaterEquipNum).TotalVolume, + } else if (WaterConnections(this->Connections).StandAlone) { + SetupOutputVariable("Water Use Equipment Heating Energy", + OutputProcessor::Unit::J, + this->Energy, "System", "Sum", - WaterEquipment(WaterEquipNum).Name, + this->Name, _, - "Water", + "DISTRICTHEATING", "WATERSYSTEMS", - WaterEquipment(WaterEquipNum).EndUseSubcatName, + this->EndUseSubcatName, "Plant"); - SetupOutputVariable("Water Use Equipment Mains Water Volume", - OutputProcessor::Unit::m3, - WaterEquipment(WaterEquipNum).TotalVolume, + + } else { // The EQUIPMENT is coupled to a plant loop via a CONNECTIONS object + SetupOutputVariable("Water Use Equipment Heating Energy", + OutputProcessor::Unit::J, + this->Energy, "System", "Sum", - WaterEquipment(WaterEquipNum).Name, + this->Name, _, - "MainsWater", + "ENERGYTRANSFER", "WATERSYSTEMS", - WaterEquipment(WaterEquipNum).EndUseSubcatName, + this->EndUseSubcatName, "Plant"); + } - SetupOutputVariable("Water Use Equipment Hot Water Temperature", - OutputProcessor::Unit::C, - WaterEquipment(WaterEquipNum).HotTemp, - "System", - "Average", - WaterEquipment(WaterEquipNum).Name); - - SetupOutputVariable("Water Use Equipment Cold Water Temperature", - OutputProcessor::Unit::C, - WaterEquipment(WaterEquipNum).ColdTemp, - "System", - "Average", - WaterEquipment(WaterEquipNum).Name); - - SetupOutputVariable("Water Use Equipment Target Water Temperature", - OutputProcessor::Unit::C, - WaterEquipment(WaterEquipNum).TargetTemp, - "System", - "Average", - WaterEquipment(WaterEquipNum).Name); - - SetupOutputVariable("Water Use Equipment Mixed Water Temperature", - OutputProcessor::Unit::C, - WaterEquipment(WaterEquipNum).MixedTemp, - "System", - "Average", - WaterEquipment(WaterEquipNum).Name); - - SetupOutputVariable("Water Use Equipment Drain Water Temperature", - OutputProcessor::Unit::C, - WaterEquipment(WaterEquipNum).DrainTemp, - "System", - "Average", - WaterEquipment(WaterEquipNum).Name); - - SetupOutputVariable("Water Use Equipment Heating Rate", + if (this->Zone > 0) { + SetupOutputVariable("Water Use Equipment Zone Sensible Heat Gain Rate", OutputProcessor::Unit::W, - WaterEquipment(WaterEquipNum).Power, - "System", - "Average", - WaterEquipment(WaterEquipNum).Name); - - if (WaterEquipment(WaterEquipNum).Connections == 0) { - SetupOutputVariable("Water Use Equipment Heating Energy", - OutputProcessor::Unit::J, - WaterEquipment(WaterEquipNum).Energy, - "System", - "Sum", - WaterEquipment(WaterEquipNum).Name, - _, - "DISTRICTHEATING", - "WATERSYSTEMS", - WaterEquipment(WaterEquipNum).EndUseSubcatName, - "Plant"); - - } else if (WaterConnections(WaterEquipment(WaterEquipNum).Connections).StandAlone) { - SetupOutputVariable("Water Use Equipment Heating Energy", - OutputProcessor::Unit::J, - WaterEquipment(WaterEquipNum).Energy, - "System", - "Sum", - WaterEquipment(WaterEquipNum).Name, - _, - "DISTRICTHEATING", - "WATERSYSTEMS", - WaterEquipment(WaterEquipNum).EndUseSubcatName, - "Plant"); - - } else { // The EQUIPMENT is coupled to a plant loop via a CONNECTIONS object - SetupOutputVariable("Water Use Equipment Heating Energy", - OutputProcessor::Unit::J, - WaterEquipment(WaterEquipNum).Energy, - "System", - "Sum", - WaterEquipment(WaterEquipNum).Name, - _, - "ENERGYTRANSFER", - "WATERSYSTEMS", - WaterEquipment(WaterEquipNum).EndUseSubcatName, - "Plant"); - } - - if (WaterEquipment(WaterEquipNum).Zone > 0) { - SetupOutputVariable("Water Use Equipment Zone Sensible Heat Gain Rate", - OutputProcessor::Unit::W, - WaterEquipment(WaterEquipNum).SensibleRate, - "System", - "Average", - WaterEquipment(WaterEquipNum).Name); - SetupOutputVariable("Water Use Equipment Zone Sensible Heat Gain Energy", - OutputProcessor::Unit::J, - WaterEquipment(WaterEquipNum).SensibleEnergy, - "System", - "Sum", - WaterEquipment(WaterEquipNum).Name); - - SetupOutputVariable("Water Use Equipment Zone Latent Gain Rate", - OutputProcessor::Unit::W, - WaterEquipment(WaterEquipNum).LatentRate, - "System", - "Average", - WaterEquipment(WaterEquipNum).Name); - SetupOutputVariable("Water Use Equipment Zone Latent Gain Energy", - OutputProcessor::Unit::J, - WaterEquipment(WaterEquipNum).LatentEnergy, - "System", - "Sum", - WaterEquipment(WaterEquipNum).Name); - - SetupOutputVariable("Water Use Equipment Zone Moisture Gain Mass Flow Rate", - OutputProcessor::Unit::kg_s, - WaterEquipment(WaterEquipNum).MoistureRate, - "System", - "Average", - WaterEquipment(WaterEquipNum).Name); - SetupOutputVariable("Water Use Equipment Zone Moisture Gain Mass", - OutputProcessor::Unit::kg, - WaterEquipment(WaterEquipNum).MoistureMass, - "System", - "Sum", - WaterEquipment(WaterEquipNum).Name); - - SetupZoneInternalGain(WaterEquipment(WaterEquipNum).Zone, - "WaterUse:Equipment", - WaterEquipment(WaterEquipNum).Name, - DataHeatBalance::IntGainTypeOf_WaterUseEquipment, - WaterEquipment(WaterEquipNum).SensibleRateNoMultiplier, - _, - _, - WaterEquipment(WaterEquipNum).LatentRateNoMultiplier); - } - - } // WaterEquipNum - - // Setup CONNECTIONS report variables (don't put any on meters; they are metered at WATER USE EQUIPMENT level) - // CurrentModuleObject='WaterUse:Connections' - for (int WaterConnNum = 1; WaterConnNum <= numWaterConnections; ++WaterConnNum) { - - SetupOutputVariable("Water Use Connections Hot Water Mass Flow Rate", - OutputProcessor::Unit::kg_s, - WaterConnections(WaterConnNum).HotMassFlowRate, + this->SensibleRate, "System", "Average", - WaterConnections(WaterConnNum).Name); - - SetupOutputVariable("Water Use Connections Cold Water Mass Flow Rate", - OutputProcessor::Unit::kg_s, - WaterConnections(WaterConnNum).ColdMassFlowRate, + this->Name); + SetupOutputVariable("Water Use Equipment Zone Sensible Heat Gain Energy", + OutputProcessor::Unit::J, + this->SensibleEnergy, "System", - "Average", - WaterConnections(WaterConnNum).Name); + "Sum", + this->Name); - SetupOutputVariable("Water Use Connections Total Mass Flow Rate", - OutputProcessor::Unit::kg_s, - WaterConnections(WaterConnNum).TotalMassFlowRate, + SetupOutputVariable("Water Use Equipment Zone Latent Gain Rate", + OutputProcessor::Unit::W, + this->LatentRate, "System", "Average", - WaterConnections(WaterConnNum).Name); - - SetupOutputVariable("Water Use Connections Drain Water Mass Flow Rate", - OutputProcessor::Unit::kg_s, - WaterConnections(WaterConnNum).DrainMassFlowRate, + this->Name); + SetupOutputVariable("Water Use Equipment Zone Latent Gain Energy", + OutputProcessor::Unit::J, + this->LatentEnergy, "System", - "Average", - WaterConnections(WaterConnNum).Name); + "Sum", + this->Name); - SetupOutputVariable("Water Use Connections Heat Recovery Mass Flow Rate", + SetupOutputVariable("Water Use Equipment Zone Moisture Gain Mass Flow Rate", OutputProcessor::Unit::kg_s, - WaterConnections(WaterConnNum).RecoveryMassFlowRate, - "System", - "Average", - WaterConnections(WaterConnNum).Name); - - SetupOutputVariable("Water Use Connections Hot Water Volume Flow Rate", - OutputProcessor::Unit::m3_s, - WaterConnections(WaterConnNum).HotVolFlowRate, - "System", - "Average", - WaterConnections(WaterConnNum).Name); - - SetupOutputVariable("Water Use Connections Cold Water Volume Flow Rate", - OutputProcessor::Unit::m3_s, - WaterConnections(WaterConnNum).ColdVolFlowRate, - "System", - "Average", - WaterConnections(WaterConnNum).Name); - - SetupOutputVariable("Water Use Connections Total Volume Flow Rate", - OutputProcessor::Unit::m3_s, - WaterConnections(WaterConnNum).TotalVolFlowRate, + this->MoistureRate, "System", "Average", - WaterConnections(WaterConnNum).Name); - - SetupOutputVariable("Water Use Connections Hot Water Volume", - OutputProcessor::Unit::m3, - WaterConnections(WaterConnNum).HotVolume, - "System", - "Sum", - WaterConnections(WaterConnNum).Name); - - SetupOutputVariable("Water Use Connections Cold Water Volume", - OutputProcessor::Unit::m3, - WaterConnections(WaterConnNum).ColdVolume, + this->Name); + SetupOutputVariable("Water Use Equipment Zone Moisture Gain Mass", + OutputProcessor::Unit::kg, + this->MoistureMass, "System", "Sum", - WaterConnections(WaterConnNum).Name); - - SetupOutputVariable("Water Use Connections Total Volume", - OutputProcessor::Unit::m3, - WaterConnections(WaterConnNum).TotalVolume, - "System", - "Sum", - WaterConnections(WaterConnNum).Name); //, & - // ResourceTypeKey='Water', EndUseKey='DHW', EndUseSubKey=EndUseSubcategoryName, GroupKey='Plant') - // tHIS WAS double counting - - SetupOutputVariable("Water Use Connections Hot Water Temperature", - OutputProcessor::Unit::C, - WaterConnections(WaterConnNum).HotTemp, - "System", - "Average", - WaterConnections(WaterConnNum).Name); - - SetupOutputVariable("Water Use Connections Cold Water Temperature", - OutputProcessor::Unit::C, - WaterConnections(WaterConnNum).ColdTemp, - "System", - "Average", - WaterConnections(WaterConnNum).Name); - - SetupOutputVariable("Water Use Connections Drain Water Temperature", - OutputProcessor::Unit::C, - WaterConnections(WaterConnNum).DrainTemp, - "System", - "Average", - WaterConnections(WaterConnNum).Name); - - SetupOutputVariable("Water Use Connections Return Water Temperature", - OutputProcessor::Unit::C, - WaterConnections(WaterConnNum).ReturnTemp, - "System", - "Average", - WaterConnections(WaterConnNum).Name); - - SetupOutputVariable("Water Use Connections Waste Water Temperature", - OutputProcessor::Unit::C, - WaterConnections(WaterConnNum).WasteTemp, - "System", - "Average", - WaterConnections(WaterConnNum).Name); - - SetupOutputVariable("Water Use Connections Heat Recovery Water Temperature", - OutputProcessor::Unit::C, - WaterConnections(WaterConnNum).RecoveryTemp, - "System", - "Average", - WaterConnections(WaterConnNum).Name); - - SetupOutputVariable("Water Use Connections Heat Recovery Effectiveness", - OutputProcessor::Unit::None, - WaterConnections(WaterConnNum).Effectiveness, - "System", - "Average", - WaterConnections(WaterConnNum).Name); + this->Name); + + SetupZoneInternalGain(this->Zone, + "WaterUse:Equipment", + this->Name, + DataHeatBalance::IntGainTypeOf_WaterUseEquipment, + this->SensibleRateNoMultiplier, + _, + _, + this->LatentRateNoMultiplier); + } + } - SetupOutputVariable("Water Use Connections Heat Recovery Rate", - OutputProcessor::Unit::W, - WaterConnections(WaterConnNum).RecoveryRate, - "System", - "Average", - WaterConnections(WaterConnNum).Name); - SetupOutputVariable("Water Use Connections Heat Recovery Energy", + void WaterConnectionsType::setupOutputVars() + { + SetupOutputVariable("Water Use Connections Hot Water Mass Flow Rate", + OutputProcessor::Unit::kg_s, + this->HotMassFlowRate, + "System", + "Average", + this->Name); + + SetupOutputVariable("Water Use Connections Cold Water Mass Flow Rate", + OutputProcessor::Unit::kg_s, + this->ColdMassFlowRate, + "System", + "Average", + this->Name); + + SetupOutputVariable("Water Use Connections Total Mass Flow Rate", + OutputProcessor::Unit::kg_s, + this->TotalMassFlowRate, + "System", + "Average", + this->Name); + + SetupOutputVariable("Water Use Connections Drain Water Mass Flow Rate", + OutputProcessor::Unit::kg_s, + this->DrainMassFlowRate, + "System", + "Average", + this->Name); + + SetupOutputVariable("Water Use Connections Heat Recovery Mass Flow Rate", + OutputProcessor::Unit::kg_s, + this->RecoveryMassFlowRate, + "System", + "Average", + this->Name); + + SetupOutputVariable("Water Use Connections Hot Water Volume Flow Rate", + OutputProcessor::Unit::m3_s, + this->HotVolFlowRate, + "System", + "Average", + this->Name); + + SetupOutputVariable("Water Use Connections Cold Water Volume Flow Rate", + OutputProcessor::Unit::m3_s, + this->ColdVolFlowRate, + "System", + "Average", + this->Name); + + SetupOutputVariable("Water Use Connections Total Volume Flow Rate", + OutputProcessor::Unit::m3_s, + this->TotalVolFlowRate, + "System", + "Average", + this->Name); + + SetupOutputVariable("Water Use Connections Hot Water Volume", + OutputProcessor::Unit::m3, + this->HotVolume, + "System", + "Sum", + this->Name); + + SetupOutputVariable("Water Use Connections Cold Water Volume", + OutputProcessor::Unit::m3, + this->ColdVolume, + "System", + "Sum", + this->Name); + + SetupOutputVariable("Water Use Connections Total Volume", + OutputProcessor::Unit::m3, + this->TotalVolume, + "System", + "Sum", + this->Name); //, & + // ResourceTypeKey='Water', EndUseKey='DHW', EndUseSubKey=EndUseSubcategoryName, GroupKey='Plant') + // tHIS WAS double counting + + SetupOutputVariable("Water Use Connections Hot Water Temperature", + OutputProcessor::Unit::C, + this->HotTemp, + "System", + "Average", + this->Name); + + SetupOutputVariable("Water Use Connections Cold Water Temperature", + OutputProcessor::Unit::C, + this->ColdTemp, + "System", + "Average", + this->Name); + + SetupOutputVariable("Water Use Connections Drain Water Temperature", + OutputProcessor::Unit::C, + this->DrainTemp, + "System", + "Average", + this->Name); + + SetupOutputVariable("Water Use Connections Return Water Temperature", + OutputProcessor::Unit::C, + this->ReturnTemp, + "System", + "Average", + this->Name); + + SetupOutputVariable("Water Use Connections Waste Water Temperature", + OutputProcessor::Unit::C, + this->WasteTemp, + "System", + "Average", + this->Name); + + SetupOutputVariable("Water Use Connections Heat Recovery Water Temperature", + OutputProcessor::Unit::C, + this->RecoveryTemp, + "System", + "Average", + this->Name); + + SetupOutputVariable("Water Use Connections Heat Recovery Effectiveness", + OutputProcessor::Unit::None, + this->Effectiveness, + "System", + "Average", + this->Name); + + SetupOutputVariable("Water Use Connections Heat Recovery Rate", + OutputProcessor::Unit::W, + this->RecoveryRate, + "System", + "Average", + this->Name); + SetupOutputVariable("Water Use Connections Heat Recovery Energy", + OutputProcessor::Unit::J, + this->RecoveryEnergy, + "System", + "Sum", + this->Name); + // Does this go on a meter? + + // To do: Add report variable for starved flow when tank can't deliver? + + if (!this->StandAlone) { + SetupOutputVariable("Water Use Connections Plant Hot Water Energy", OutputProcessor::Unit::J, - WaterConnections(WaterConnNum).RecoveryEnergy, + this->Energy, "System", "Sum", - WaterConnections(WaterConnNum).Name); - // Does this go on a meter? - - // To do: Add report variable for starved flow when tank can't deliver? - - if (!WaterConnections(WaterConnNum).StandAlone) { - SetupOutputVariable("Water Use Connections Plant Hot Water Energy", - OutputProcessor::Unit::J, - WaterConnections(WaterConnNum).Energy, - "System", - "Sum", - WaterConnections(WaterConnNum).Name, - _, - "PLANTLOOPHEATINGDEMAND", - "WATERSYSTEMS", - _, - "Plant"); - } - - } // WaterConnNum + this->Name, + _, + "PLANTLOOPHEATINGDEMAND", + "WATERSYSTEMS", + _, + "Plant"); + } } void WaterEquipmentType::CalcEquipmentFlowRates() @@ -987,6 +984,11 @@ namespace EnergyPlus { // PURPOSE OF THIS SUBROUTINE: // Calculate desired hot and cold water flow rates + if (this->setupMyOutputVars) { + this->setupOutputVars(); + this->setupMyOutputVars = false; + } + if (this->Connections > 0) { // Get water temperature conditions from the CONNECTIONS object this->ColdTemp = WaterConnections(this->Connections).ColdTemp; @@ -1159,6 +1161,11 @@ namespace EnergyPlus { // MODIFIED Brent Griffith 2010, demand side update // RE-ENGINEERED na + if (this->setupMyOutputVars) { + this->setupOutputVars(); + this->setupMyOutputVars = false; + } + if (allocated(DataPlant::PlantLoop) && !this->StandAlone) { bool errFlag = false; PlantUtilities::ScanPlantLoopsForObject(this->Name, @@ -1568,11 +1575,11 @@ namespace EnergyPlus { // PURPOSE OF THIS SUBROUTINE: // Calculates the zone internal gains due to water use sensible and latent loads. - bool MyEnvrnFlag(true); + bool MyEnvrnFlagLocal(true); if (numWaterEquipment == 0) return; - if (DataGlobals::BeginEnvrnFlag && MyEnvrnFlag) { + if (DataGlobals::BeginEnvrnFlag && MyEnvrnFlagLocal) { for (auto &e : WaterEquipment) { e.SensibleRate = 0.0; e.SensibleEnergy = 0.0; @@ -1589,10 +1596,10 @@ namespace EnergyPlus { e.ColdMassFlowRate = 0.0; e.HotMassFlowRate = 0.0; } - MyEnvrnFlag = false; + MyEnvrnFlagLocal = false; } - if (!DataGlobals::BeginEnvrnFlag) MyEnvrnFlag = true; + if (!DataGlobals::BeginEnvrnFlag) MyEnvrnFlagLocal = true; for (int WaterEquipNum = 1; WaterEquipNum <= numWaterEquipment; ++WaterEquipNum) { if (WaterEquipment(WaterEquipNum).Zone == 0) continue; diff --git a/src/EnergyPlus/WaterUse.hh b/src/EnergyPlus/WaterUse.hh index 510be2aba4d..8ceb882f361 100644 --- a/src/EnergyPlus/WaterUse.hh +++ b/src/EnergyPlus/WaterUse.hh @@ -116,6 +116,7 @@ namespace EnergyPlus { Real64 TotalVolume; // Water consumption (m3) Real64 Power; // Heating rate required to meet the mixed water temperature (W) Real64 Energy; // Heating energy required to meet the mixed water temperature (J) + bool setupMyOutputVars; WaterEquipmentType() : Connections(0), PeakVolFlowRate(0.0), FlowRateFracSchedule(0), ColdVolFlowRate(0.0), HotVolFlowRate(0.0), TotalVolFlowRate(0.0), @@ -123,7 +124,7 @@ namespace EnergyPlus { TargetTempSchedule(0), ColdTemp(0.0), HotTemp(0.0), TargetTemp(0.0), MixedTemp(0.0), DrainTemp(0.0), Zone(0), SensibleFracSchedule(0), SensibleRate(0.0), SensibleEnergy(0.0), SensibleRateNoMultiplier(0.0), LatentFracSchedule(0), LatentRate(0.0), LatentEnergy(0.0), LatentRateNoMultiplier(0.0), MoistureRate(0.0), MoistureMass(0.0), ColdVolume(0.0), HotVolume(0.0), TotalVolume(0.0), Power(0.0), - Energy(0.0) + Energy(0.0), setupMyOutputVars(true) { } @@ -142,6 +143,8 @@ namespace EnergyPlus { void CalcEquipmentFlowRates(); void CalcEquipmentDrainTemp(); + + void setupOutputVars(); }; struct WaterConnectionsType : PlantComponent @@ -204,6 +207,8 @@ namespace EnergyPlus { int PlantLoopSide; int PlantLoopBranchNum; int PlantLoopCompNum; + bool MyEnvrnFlag; + bool setupMyOutputVars; WaterConnectionsType() : Init(true), InitSizing(true), StandAlone(false), InletNode(0), OutletNode(0), SupplyTankNum(0), RecoveryTankNum(0), TankDemandID(0), @@ -214,7 +219,7 @@ namespace EnergyPlus { PeakMassFlowRate(0.0), ColdTempSchedule(0), HotTempSchedule(0), MainsTemp(0.0), TankTemp(0.0), ColdSupplyTemp(0.0), ColdTemp(0.0), HotTemp(0.0), DrainTemp(0.0), RecoveryTemp(0.0), ReturnTemp(0.0), WasteTemp(0.0), TempError(0.0), MainsVolume(0.0), TankVolume(0.0), ColdVolume(0.0), HotVolume(0.0), TotalVolume(0.0), Power(0.0), Energy(0.0), NumWaterEquipment(0), MaxIterationsErrorIndex(0), - PlantLoopNum(0), PlantLoopSide(0), PlantLoopBranchNum(0), PlantLoopCompNum(0) + PlantLoopNum(0), PlantLoopSide(0), PlantLoopBranchNum(0), PlantLoopCompNum(0), MyEnvrnFlag(true), setupMyOutputVars(true) { } @@ -233,6 +238,8 @@ namespace EnergyPlus { void UpdateWaterConnections(); void ReportWaterUse(); + + void setupOutputVars(); }; void clear_state(); From 73c2d75a186a0f4adc4dee82a51302c4e625ee9c Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Mon, 2 Dec 2019 10:05:21 -0700 Subject: [PATCH 51/51] apply style --- src/EnergyPlus/WaterUse.cc | 2325 +++++++++++++++++------------------- src/EnergyPlus/WaterUse.hh | 387 +++--- 2 files changed, 1267 insertions(+), 1445 deletions(-) diff --git a/src/EnergyPlus/WaterUse.cc b/src/EnergyPlus/WaterUse.cc index 22039f2f8b3..aff5ff37f6e 100644 --- a/src/EnergyPlus/WaterUse.cc +++ b/src/EnergyPlus/WaterUse.cc @@ -62,7 +62,6 @@ #include #include #include -#include #include #include #include @@ -76,1541 +75,1363 @@ namespace EnergyPlus { - namespace WaterUse { +namespace WaterUse { - // MODULE INFORMATION: - // AUTHOR Peter Graham Ellis - // DATE WRITTEN August 2006 - // MODIFIED Brent Griffith, plant upgrade - // RE-ENGINEERED na + // MODULE INFORMATION: + // AUTHOR Peter Graham Ellis + // DATE WRITTEN August 2006 + // MODIFIED Brent Griffith, plant upgrade + // RE-ENGINEERED na - bool getWaterUseInputFlag(true); - int numWaterEquipment(0); - int numWaterConnections(0); + bool getWaterUseInputFlag(true); + int numWaterEquipment(0); + int numWaterConnections(0); - Array1D_bool CheckEquipName; + Array1D_bool CheckEquipName; - Array1D WaterEquipment; - Array1D WaterConnections; + Array1D WaterEquipment; + Array1D WaterConnections; - void clear_state() - { - numWaterEquipment = 0; - numWaterConnections = 0; - getWaterUseInputFlag = true; - CheckEquipName.deallocate(); - WaterEquipment.deallocate(); - WaterConnections.deallocate(); - } + void clear_state() + { + numWaterEquipment = 0; + numWaterConnections = 0; + getWaterUseInputFlag = true; + CheckEquipName.deallocate(); + WaterEquipment.deallocate(); + WaterConnections.deallocate(); + } - void SimulateWaterUse(bool FirstHVACIteration) - { + void SimulateWaterUse(bool FirstHVACIteration) + { - // SUBROUTINE INFORMATION: - // AUTHOR Peter Graham Ellis - // DATE WRITTEN August 2006 - // MODIFIED Brent Griffith, March 2010, separated plant connected to different sim routine - // RE-ENGINEERED na - - // PURPOSE OF THIS SUBROUTINE: - // This routine is called from non zone equipment manager and serves to call - // water use and connections that are not connected to a full plant loop + // SUBROUTINE INFORMATION: + // AUTHOR Peter Graham Ellis + // DATE WRITTEN August 2006 + // MODIFIED Brent Griffith, March 2010, separated plant connected to different sim routine + // RE-ENGINEERED na - int const MaxIterations(100); - Real64 const Tolerance(0.1); // Make input? + // PURPOSE OF THIS SUBROUTINE: + // This routine is called from non zone equipment manager and serves to call + // water use and connections that are not connected to a full plant loop - int WaterEquipNum; - int WaterConnNum; - int NumIteration; - static bool MyEnvrnFlagLocal(true); + int const MaxIterations(100); + Real64 const Tolerance(0.1); // Make input? - if (getWaterUseInputFlag) { - GetWaterUseInput(); - getWaterUseInputFlag = false; - } + int WaterEquipNum; + int WaterConnNum; + int NumIteration; + static bool MyEnvrnFlagLocal(true); - if (DataGlobals::BeginEnvrnFlag && MyEnvrnFlagLocal) { - if (numWaterEquipment > 0) { - for (auto &e : WaterEquipment) { - e.SensibleRate = 0.0; - e.SensibleEnergy = 0.0; - e.LatentRate = 0.0; - e.LatentEnergy = 0.0; - e.MixedTemp = 0.0; - e.TotalMassFlowRate = 0.0; - e.DrainTemp = 0.0; - } - } + if (getWaterUseInputFlag) { + GetWaterUseInput(); + getWaterUseInputFlag = false; + } - if (numWaterConnections > 0) { - for (auto &e : WaterConnections) - e.TotalMassFlowRate = 0.0; + if (DataGlobals::BeginEnvrnFlag && MyEnvrnFlagLocal) { + if (numWaterEquipment > 0) { + for (auto &e : WaterEquipment) { + e.SensibleRate = 0.0; + e.SensibleEnergy = 0.0; + e.LatentRate = 0.0; + e.LatentEnergy = 0.0; + e.MixedTemp = 0.0; + e.TotalMassFlowRate = 0.0; + e.DrainTemp = 0.0; } + } - MyEnvrnFlagLocal = false; + if (numWaterConnections > 0) { + for (auto &e : WaterConnections) + e.TotalMassFlowRate = 0.0; } - if (!DataGlobals::BeginEnvrnFlag) MyEnvrnFlagLocal = true; + MyEnvrnFlagLocal = false; + } - // Simulate all unconnected WATER USE EQUIPMENT objects - for (WaterEquipNum = 1; WaterEquipNum <= numWaterEquipment; ++WaterEquipNum) { - if (WaterEquipment(WaterEquipNum).Connections == 0) { - WaterEquipment(WaterEquipNum).CalcEquipmentFlowRates(); - WaterEquipment(WaterEquipNum).CalcEquipmentDrainTemp(); - } - } // WaterEquipNum + if (!DataGlobals::BeginEnvrnFlag) MyEnvrnFlagLocal = true; - ReportStandAloneWaterUse(); + // Simulate all unconnected WATER USE EQUIPMENT objects + for (WaterEquipNum = 1; WaterEquipNum <= numWaterEquipment; ++WaterEquipNum) { + if (WaterEquipment(WaterEquipNum).Connections == 0) { + WaterEquipment(WaterEquipNum).CalcEquipmentFlowRates(); + WaterEquipment(WaterEquipNum).CalcEquipmentDrainTemp(); + } + } // WaterEquipNum - // Simulate WATER USE CONNECTIONS objects and connected WATER USE EQUIPMENT objects - for (WaterConnNum = 1; WaterConnNum <= numWaterConnections; ++WaterConnNum) { + ReportStandAloneWaterUse(); - if (!WaterConnections(WaterConnNum).StandAlone) continue; // only model non plant connections here + // Simulate WATER USE CONNECTIONS objects and connected WATER USE EQUIPMENT objects + for (WaterConnNum = 1; WaterConnNum <= numWaterConnections; ++WaterConnNum) { - WaterConnections(WaterConnNum).InitConnections(); + if (!WaterConnections(WaterConnNum).StandAlone) continue; // only model non plant connections here - NumIteration = 0; + WaterConnections(WaterConnNum).InitConnections(); - while (true) { - ++NumIteration; + NumIteration = 0; - WaterConnections(WaterConnNum).CalcConnectionsFlowRates(FirstHVACIteration); - WaterConnections(WaterConnNum).CalcConnectionsDrainTemp(); - WaterConnections(WaterConnNum).CalcConnectionsHeatRecovery(); + while (true) { + ++NumIteration; - if (WaterConnections(WaterConnNum).TempError < Tolerance) { - break; - } else if (NumIteration > MaxIterations) { - if (!DataGlobals::WarmupFlag) { - if (WaterConnections(WaterConnNum).MaxIterationsErrorIndex == 0) { - ShowWarningError("WaterUse:Connections = " + WaterConnections(WaterConnNum).Name + - ": Heat recovery temperature did not converge"); - ShowContinueErrorTimeStamp(""); - } - ShowRecurringWarningErrorAtEnd("WaterUse:Connections = " + WaterConnections(WaterConnNum).Name + - ": Heat recovery temperature did not converge", - WaterConnections(WaterConnNum).MaxIterationsErrorIndex); + WaterConnections(WaterConnNum).CalcConnectionsFlowRates(FirstHVACIteration); + WaterConnections(WaterConnNum).CalcConnectionsDrainTemp(); + WaterConnections(WaterConnNum).CalcConnectionsHeatRecovery(); + + if (WaterConnections(WaterConnNum).TempError < Tolerance) { + break; + } else if (NumIteration > MaxIterations) { + if (!DataGlobals::WarmupFlag) { + if (WaterConnections(WaterConnNum).MaxIterationsErrorIndex == 0) { + ShowWarningError("WaterUse:Connections = " + WaterConnections(WaterConnNum).Name + + ": Heat recovery temperature did not converge"); + ShowContinueErrorTimeStamp(""); } - break; + ShowRecurringWarningErrorAtEnd("WaterUse:Connections = " + WaterConnections(WaterConnNum).Name + + ": Heat recovery temperature did not converge", + WaterConnections(WaterConnNum).MaxIterationsErrorIndex); } + break; + } - } // WHILE + } // WHILE - WaterConnections(WaterConnNum).UpdateWaterConnections(); - WaterConnections(WaterConnNum).ReportWaterUse(); + WaterConnections(WaterConnNum).UpdateWaterConnections(); + WaterConnections(WaterConnNum).ReportWaterUse(); - } // WaterConnNum - } + } // WaterConnNum + } - PlantComponent *WaterConnectionsType::factory(std::string const &objectName) - { - // Process the input data - if (getWaterUseInputFlag) { - GetWaterUseInput(); - getWaterUseInputFlag = false; - } + PlantComponent *WaterConnectionsType::factory(std::string const &objectName) + { + // Process the input data + if (getWaterUseInputFlag) { + GetWaterUseInput(); + getWaterUseInputFlag = false; + } - // Now look for this particular object in the list - for (auto &thisWC : WaterConnections) { - if (thisWC.Name == objectName) { - return &thisWC; - } + // Now look for this particular object in the list + for (auto &thisWC : WaterConnections) { + if (thisWC.Name == objectName) { + return &thisWC; } - // If we didn't find it, fatal - ShowFatalError("LocalWaterUseConnectionFactory: Error getting inputs for object named: " + objectName); // LCOV_EXCL_LINE - // Shut up the compiler - return nullptr; // LCOV_EXCL_LINE } + // If we didn't find it, fatal + ShowFatalError("LocalWaterUseConnectionFactory: Error getting inputs for object named: " + objectName); // LCOV_EXCL_LINE + // Shut up the compiler + return nullptr; // LCOV_EXCL_LINE + } + + void WaterConnectionsType::simulate(const PlantLocation &EP_UNUSED(calledFromLocation), + bool FirstHVACIteration, + Real64 &EP_UNUSED(CurLoad), + bool EP_UNUSED(RunFlag)) + { + + // SUBROUTINE INFORMATION: + // AUTHOR Brent Griffith March 2010, Demand Side Update + // DATE WRITTEN August 2006 + // MODIFIED + // RE-ENGINEERED na - void WaterConnectionsType::simulate(const PlantLocation &EP_UNUSED(calledFromLocation), bool FirstHVACIteration, Real64 &EP_UNUSED(CurLoad), bool EP_UNUSED(RunFlag)) - { - - // SUBROUTINE INFORMATION: - // AUTHOR Brent Griffith March 2010, Demand Side Update - // DATE WRITTEN August 2006 - // MODIFIED - // RE-ENGINEERED na - - // PURPOSE OF THIS SUBROUTINE: - // Plant sim call for plant loop connected water use and connections - - int const MaxIterations(100); - Real64 const Tolerance(0.1); // Make input? + // PURPOSE OF THIS SUBROUTINE: + // Plant sim call for plant loop connected water use and connections - if (DataGlobals::BeginEnvrnFlag && this->MyEnvrnFlag) { - if (numWaterEquipment > 0) { - for (int i = WaterEquipment.l(), e = WaterEquipment.u(); i <= e; ++i) { - WaterEquipment(i).reset(); + int const MaxIterations(100); + Real64 const Tolerance(0.1); // Make input? - if (WaterEquipment(i).setupMyOutputVars) { - WaterEquipment(i).setupOutputVars(); - WaterEquipment(i).setupMyOutputVars = false; - } + if (DataGlobals::BeginEnvrnFlag && this->MyEnvrnFlag) { + if (numWaterEquipment > 0) { + for (int i = WaterEquipment.l(), e = WaterEquipment.u(); i <= e; ++i) { + WaterEquipment(i).reset(); + if (WaterEquipment(i).setupMyOutputVars) { + WaterEquipment(i).setupOutputVars(); + WaterEquipment(i).setupMyOutputVars = false; } } + } - if (numWaterConnections > 0) { - for (auto &e : WaterConnections) - e.TotalMassFlowRate = 0.0; - } - - this->MyEnvrnFlag = false; + if (numWaterConnections > 0) { + for (auto &e : WaterConnections) + e.TotalMassFlowRate = 0.0; } - if (!DataGlobals::BeginEnvrnFlag) this->MyEnvrnFlag = true; + this->MyEnvrnFlag = false; + } - this->InitConnections(); + if (!DataGlobals::BeginEnvrnFlag) this->MyEnvrnFlag = true; - int NumIteration = 0; + this->InitConnections(); - while (true) { - ++NumIteration; + int NumIteration = 0; - this->CalcConnectionsFlowRates(FirstHVACIteration); - this->CalcConnectionsDrainTemp(); - this->CalcConnectionsHeatRecovery(); + while (true) { + ++NumIteration; - if (this->TempError < Tolerance) { - break; - } else if (NumIteration > MaxIterations) { - if (!DataGlobals::WarmupFlag) { - if (this->MaxIterationsErrorIndex == 0) { - ShowWarningError("WaterUse:Connections = " + this->Name + - ": Heat recovery temperature did not converge"); - ShowContinueErrorTimeStamp(""); - } - ShowRecurringWarningErrorAtEnd("WaterUse:Connections = " + this->Name + - ": Heat recovery temperature did not converge", - this->MaxIterationsErrorIndex); + this->CalcConnectionsFlowRates(FirstHVACIteration); + this->CalcConnectionsDrainTemp(); + this->CalcConnectionsHeatRecovery(); + + if (this->TempError < Tolerance) { + break; + } else if (NumIteration > MaxIterations) { + if (!DataGlobals::WarmupFlag) { + if (this->MaxIterationsErrorIndex == 0) { + ShowWarningError("WaterUse:Connections = " + this->Name + ": Heat recovery temperature did not converge"); + ShowContinueErrorTimeStamp(""); } - break; + ShowRecurringWarningErrorAtEnd("WaterUse:Connections = " + this->Name + ": Heat recovery temperature did not converge", + this->MaxIterationsErrorIndex); } - } // WHILE + break; + } + } // WHILE - this->UpdateWaterConnections(); - this->ReportWaterUse(); - } + this->UpdateWaterConnections(); + this->ReportWaterUse(); + } + + void GetWaterUseInput() + { - void GetWaterUseInput() - { + // SUBROUTINE INFORMATION: + // AUTHOR Peter Graham Ellis + // DATE WRITTEN August 2006 + // MODIFIED na + // RE-ENGINEERED na - // SUBROUTINE INFORMATION: - // AUTHOR Peter Graham Ellis - // DATE WRITTEN August 2006 - // MODIFIED na - // RE-ENGINEERED na + bool ErrorsFound(false); // Set to true if errors in input, fatal at end of routine + int IOStatus; // Used in GetObjectItem + int NumAlphas; // Number of Alphas for each GetObjectItem call + int NumNumbers; // Number of Numbers for each GetObjectItem call + int AlphaNum; - bool ErrorsFound(false); // Set to true if errors in input, fatal at end of routine - int IOStatus; // Used in GetObjectItem - int NumAlphas; // Number of Alphas for each GetObjectItem call - int NumNumbers; // Number of Numbers for each GetObjectItem call - int AlphaNum; + DataIPShortCuts::cCurrentModuleObject = "WaterUse:Equipment"; + numWaterEquipment = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); - DataIPShortCuts::cCurrentModuleObject = "WaterUse:Equipment"; - numWaterEquipment = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); + if (numWaterEquipment > 0) { + WaterEquipment.allocate(numWaterEquipment); - if (numWaterEquipment > 0) { - WaterEquipment.allocate(numWaterEquipment); - - for (int WaterEquipNum = 1; WaterEquipNum <= numWaterEquipment; ++WaterEquipNum) { - inputProcessor->getObjectItem(DataIPShortCuts::cCurrentModuleObject, - WaterEquipNum, - DataIPShortCuts::cAlphaArgs, - NumAlphas, - DataIPShortCuts::rNumericArgs, - NumNumbers, - IOStatus, - _, - DataIPShortCuts::lAlphaFieldBlanks, - DataIPShortCuts::cAlphaFieldNames, - DataIPShortCuts::cNumericFieldNames); - UtilityRoutines::IsNameEmpty(DataIPShortCuts::cAlphaArgs(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); - WaterEquipment(WaterEquipNum).Name = DataIPShortCuts::cAlphaArgs(1); - - WaterEquipment(WaterEquipNum).EndUseSubcatName = DataIPShortCuts::cAlphaArgs(2); - - WaterEquipment(WaterEquipNum).PeakVolFlowRate = DataIPShortCuts::rNumericArgs(1); - - if ((NumAlphas > 2) && (!DataIPShortCuts::lAlphaFieldBlanks(3))) { - WaterEquipment(WaterEquipNum).FlowRateFracSchedule = ScheduleManager::GetScheduleIndex(DataIPShortCuts::cAlphaArgs(3)); - // If no FlowRateFracSchedule, fraction defaults to 1.0 - - if (WaterEquipment(WaterEquipNum).FlowRateFracSchedule == 0) { - ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(3) + '=' + DataIPShortCuts::cAlphaArgs(3)); - ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + DataIPShortCuts::cAlphaArgs(1)); - ErrorsFound = true; - } + for (int WaterEquipNum = 1; WaterEquipNum <= numWaterEquipment; ++WaterEquipNum) { + inputProcessor->getObjectItem(DataIPShortCuts::cCurrentModuleObject, + WaterEquipNum, + DataIPShortCuts::cAlphaArgs, + NumAlphas, + DataIPShortCuts::rNumericArgs, + NumNumbers, + IOStatus, + _, + DataIPShortCuts::lAlphaFieldBlanks, + DataIPShortCuts::cAlphaFieldNames, + DataIPShortCuts::cNumericFieldNames); + UtilityRoutines::IsNameEmpty(DataIPShortCuts::cAlphaArgs(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); + WaterEquipment(WaterEquipNum).Name = DataIPShortCuts::cAlphaArgs(1); + + WaterEquipment(WaterEquipNum).EndUseSubcatName = DataIPShortCuts::cAlphaArgs(2); + + WaterEquipment(WaterEquipNum).PeakVolFlowRate = DataIPShortCuts::rNumericArgs(1); + + if ((NumAlphas > 2) && (!DataIPShortCuts::lAlphaFieldBlanks(3))) { + WaterEquipment(WaterEquipNum).FlowRateFracSchedule = ScheduleManager::GetScheduleIndex(DataIPShortCuts::cAlphaArgs(3)); + // If no FlowRateFracSchedule, fraction defaults to 1.0 + + if (WaterEquipment(WaterEquipNum).FlowRateFracSchedule == 0) { + ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(3) + '=' + DataIPShortCuts::cAlphaArgs(3)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + DataIPShortCuts::cAlphaArgs(1)); + ErrorsFound = true; } + } - if ((NumAlphas > 3) && (!DataIPShortCuts::lAlphaFieldBlanks(4))) { - WaterEquipment(WaterEquipNum).TargetTempSchedule = ScheduleManager::GetScheduleIndex(DataIPShortCuts::cAlphaArgs(4)); + if ((NumAlphas > 3) && (!DataIPShortCuts::lAlphaFieldBlanks(4))) { + WaterEquipment(WaterEquipNum).TargetTempSchedule = ScheduleManager::GetScheduleIndex(DataIPShortCuts::cAlphaArgs(4)); - if (WaterEquipment(WaterEquipNum).TargetTempSchedule == 0) { - ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(4) + '=' + DataIPShortCuts::cAlphaArgs(4)); - ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + DataIPShortCuts::cAlphaArgs(1)); - ErrorsFound = true; - } + if (WaterEquipment(WaterEquipNum).TargetTempSchedule == 0) { + ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(4) + '=' + DataIPShortCuts::cAlphaArgs(4)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + DataIPShortCuts::cAlphaArgs(1)); + ErrorsFound = true; } + } - if ((NumAlphas > 4) && (!DataIPShortCuts::lAlphaFieldBlanks(5))) { - WaterEquipment(WaterEquipNum).HotTempSchedule = ScheduleManager::GetScheduleIndex(DataIPShortCuts::cAlphaArgs(5)); - // If no HotTempSchedule, there is no hot water. - // HotTempSchedule is ignored if connected to a plant loop via WATER USE CONNECTIONS + if ((NumAlphas > 4) && (!DataIPShortCuts::lAlphaFieldBlanks(5))) { + WaterEquipment(WaterEquipNum).HotTempSchedule = ScheduleManager::GetScheduleIndex(DataIPShortCuts::cAlphaArgs(5)); + // If no HotTempSchedule, there is no hot water. + // HotTempSchedule is ignored if connected to a plant loop via WATER USE CONNECTIONS - if (WaterEquipment(WaterEquipNum).HotTempSchedule == 0) { - ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(5) + '=' + DataIPShortCuts::cAlphaArgs(5)); - ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + DataIPShortCuts::cAlphaArgs(1)); - ErrorsFound = true; - } + if (WaterEquipment(WaterEquipNum).HotTempSchedule == 0) { + ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(5) + '=' + DataIPShortCuts::cAlphaArgs(5)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + DataIPShortCuts::cAlphaArgs(1)); + ErrorsFound = true; } + } - if ((NumAlphas > 5) && (!DataIPShortCuts::lAlphaFieldBlanks(6))) { - WaterEquipment(WaterEquipNum).ColdTempSchedule = ScheduleManager::GetScheduleIndex(DataIPShortCuts::cAlphaArgs(6)); - // If no ColdTempSchedule, temperatures will be calculated by WATER MAINS TEMPERATURES object + if ((NumAlphas > 5) && (!DataIPShortCuts::lAlphaFieldBlanks(6))) { + WaterEquipment(WaterEquipNum).ColdTempSchedule = ScheduleManager::GetScheduleIndex(DataIPShortCuts::cAlphaArgs(6)); + // If no ColdTempSchedule, temperatures will be calculated by WATER MAINS TEMPERATURES object - if (WaterEquipment(WaterEquipNum).ColdTempSchedule == 0) { - ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(6) + '=' + DataIPShortCuts::cAlphaArgs(6)); - ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + DataIPShortCuts::cAlphaArgs(1)); - ErrorsFound = true; - } + if (WaterEquipment(WaterEquipNum).ColdTempSchedule == 0) { + ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(6) + '=' + DataIPShortCuts::cAlphaArgs(6)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + DataIPShortCuts::cAlphaArgs(1)); + ErrorsFound = true; } + } - if ((NumAlphas > 6) && (!DataIPShortCuts::lAlphaFieldBlanks(7))) { - WaterEquipment(WaterEquipNum).Zone = UtilityRoutines::FindItemInList(DataIPShortCuts::cAlphaArgs(7), DataHeatBalance::Zone); + if ((NumAlphas > 6) && (!DataIPShortCuts::lAlphaFieldBlanks(7))) { + WaterEquipment(WaterEquipNum).Zone = UtilityRoutines::FindItemInList(DataIPShortCuts::cAlphaArgs(7), DataHeatBalance::Zone); - if (WaterEquipment(WaterEquipNum).Zone == 0) { - ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(7) + '=' + DataIPShortCuts::cAlphaArgs(7)); - ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + DataIPShortCuts::cAlphaArgs(1)); - ErrorsFound = true; - } + if (WaterEquipment(WaterEquipNum).Zone == 0) { + ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(7) + '=' + DataIPShortCuts::cAlphaArgs(7)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + DataIPShortCuts::cAlphaArgs(1)); + ErrorsFound = true; } + } - if ((NumAlphas > 7) && (!DataIPShortCuts::lAlphaFieldBlanks(8))) { - WaterEquipment(WaterEquipNum).SensibleFracSchedule = ScheduleManager::GetScheduleIndex(DataIPShortCuts::cAlphaArgs(8)); + if ((NumAlphas > 7) && (!DataIPShortCuts::lAlphaFieldBlanks(8))) { + WaterEquipment(WaterEquipNum).SensibleFracSchedule = ScheduleManager::GetScheduleIndex(DataIPShortCuts::cAlphaArgs(8)); - if (WaterEquipment(WaterEquipNum).SensibleFracSchedule == 0) { - ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(8) + '=' + DataIPShortCuts::cAlphaArgs(8)); - ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + DataIPShortCuts::cAlphaArgs(1)); - ErrorsFound = true; - } + if (WaterEquipment(WaterEquipNum).SensibleFracSchedule == 0) { + ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(8) + '=' + DataIPShortCuts::cAlphaArgs(8)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + DataIPShortCuts::cAlphaArgs(1)); + ErrorsFound = true; } + } - if ((NumAlphas > 8) && (!DataIPShortCuts::lAlphaFieldBlanks(9))) { - WaterEquipment(WaterEquipNum).LatentFracSchedule = ScheduleManager::GetScheduleIndex(DataIPShortCuts::cAlphaArgs(9)); + if ((NumAlphas > 8) && (!DataIPShortCuts::lAlphaFieldBlanks(9))) { + WaterEquipment(WaterEquipNum).LatentFracSchedule = ScheduleManager::GetScheduleIndex(DataIPShortCuts::cAlphaArgs(9)); - if (WaterEquipment(WaterEquipNum).LatentFracSchedule == 0) { - ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(9) + '=' + DataIPShortCuts::cAlphaArgs(9)); - ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + DataIPShortCuts::cAlphaArgs(1)); - ErrorsFound = true; - } + if (WaterEquipment(WaterEquipNum).LatentFracSchedule == 0) { + ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(9) + '=' + DataIPShortCuts::cAlphaArgs(9)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + DataIPShortCuts::cAlphaArgs(1)); + ErrorsFound = true; } + } - } // WaterEquipNum + } // WaterEquipNum - if (ErrorsFound) ShowFatalError("Errors found in processing input for " + DataIPShortCuts::cCurrentModuleObject); - } + if (ErrorsFound) ShowFatalError("Errors found in processing input for " + DataIPShortCuts::cCurrentModuleObject); + } - DataIPShortCuts::cCurrentModuleObject = "WaterUse:Connections"; - numWaterConnections = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); + DataIPShortCuts::cCurrentModuleObject = "WaterUse:Connections"; + numWaterConnections = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); + + if (numWaterConnections > 0) { + WaterConnections.allocate(numWaterConnections); + + for (int WaterConnNum = 1; WaterConnNum <= numWaterConnections; ++WaterConnNum) { + inputProcessor->getObjectItem(DataIPShortCuts::cCurrentModuleObject, + WaterConnNum, + DataIPShortCuts::cAlphaArgs, + NumAlphas, + DataIPShortCuts::rNumericArgs, + NumNumbers, + IOStatus, + _, + DataIPShortCuts::lAlphaFieldBlanks, + DataIPShortCuts::cAlphaFieldNames, + DataIPShortCuts::cNumericFieldNames); + UtilityRoutines::IsNameEmpty(DataIPShortCuts::cAlphaArgs(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); + WaterConnections(WaterConnNum).Name = DataIPShortCuts::cAlphaArgs(1); + + if ((!DataIPShortCuts::lAlphaFieldBlanks(2)) || (!DataIPShortCuts::lAlphaFieldBlanks(3))) { + WaterConnections(WaterConnNum).InletNode = NodeInputManager::GetOnlySingleNode(DataIPShortCuts::cAlphaArgs(2), + ErrorsFound, + DataIPShortCuts::cCurrentModuleObject, + DataIPShortCuts::cAlphaArgs(1), + DataLoopNode::NodeType_Water, + DataLoopNode::NodeConnectionType_Inlet, + 1, + DataLoopNode::ObjectIsNotParent); + WaterConnections(WaterConnNum).OutletNode = NodeInputManager::GetOnlySingleNode(DataIPShortCuts::cAlphaArgs(3), + ErrorsFound, + DataIPShortCuts::cCurrentModuleObject, + DataIPShortCuts::cAlphaArgs(1), + DataLoopNode::NodeType_Water, + DataLoopNode::NodeConnectionType_Outlet, + 1, + DataLoopNode::ObjectIsNotParent); + + // Check plant connections + BranchNodeConnections::TestCompSet(DataIPShortCuts::cCurrentModuleObject, + DataIPShortCuts::cAlphaArgs(1), + DataIPShortCuts::cAlphaArgs(2), + DataIPShortCuts::cAlphaArgs(3), + "DHW Nodes"); + } else { + // If no plant nodes are connected, simulate in stand-alone mode. + WaterConnections(WaterConnNum).StandAlone = true; + } - if (numWaterConnections > 0) { - WaterConnections.allocate(numWaterConnections); - - for (int WaterConnNum = 1; WaterConnNum <= numWaterConnections; ++WaterConnNum) { - inputProcessor->getObjectItem(DataIPShortCuts::cCurrentModuleObject, - WaterConnNum, - DataIPShortCuts::cAlphaArgs, - NumAlphas, - DataIPShortCuts::rNumericArgs, - NumNumbers, - IOStatus, - _, - DataIPShortCuts::lAlphaFieldBlanks, - DataIPShortCuts::cAlphaFieldNames, - DataIPShortCuts::cNumericFieldNames); - UtilityRoutines::IsNameEmpty(DataIPShortCuts::cAlphaArgs(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); - WaterConnections(WaterConnNum).Name = DataIPShortCuts::cAlphaArgs(1); - - if ((!DataIPShortCuts::lAlphaFieldBlanks(2)) || (!DataIPShortCuts::lAlphaFieldBlanks(3))) { - WaterConnections(WaterConnNum).InletNode = NodeInputManager::GetOnlySingleNode(DataIPShortCuts::cAlphaArgs(2), - ErrorsFound, - DataIPShortCuts::cCurrentModuleObject, - DataIPShortCuts::cAlphaArgs(1), - DataLoopNode::NodeType_Water, - DataLoopNode::NodeConnectionType_Inlet, - 1, - DataLoopNode::ObjectIsNotParent); - WaterConnections(WaterConnNum).OutletNode = NodeInputManager::GetOnlySingleNode(DataIPShortCuts::cAlphaArgs(3), - ErrorsFound, - DataIPShortCuts::cCurrentModuleObject, - DataIPShortCuts::cAlphaArgs(1), - DataLoopNode::NodeType_Water, - DataLoopNode::NodeConnectionType_Outlet, - 1, - DataLoopNode::ObjectIsNotParent); - - // Check plant connections - BranchNodeConnections::TestCompSet(DataIPShortCuts::cCurrentModuleObject, - DataIPShortCuts::cAlphaArgs(1), - DataIPShortCuts::cAlphaArgs(2), - DataIPShortCuts::cAlphaArgs(3), - "DHW Nodes"); - } else { - // If no plant nodes are connected, simulate in stand-alone mode. - WaterConnections(WaterConnNum).StandAlone = true; - } + if (!DataIPShortCuts::lAlphaFieldBlanks(4)) { + WaterManager::SetupTankDemandComponent(WaterConnections(WaterConnNum).Name, + DataIPShortCuts::cCurrentModuleObject, + DataIPShortCuts::cAlphaArgs(4), + ErrorsFound, + WaterConnections(WaterConnNum).SupplyTankNum, + WaterConnections(WaterConnNum).TankDemandID); + } - if (!DataIPShortCuts::lAlphaFieldBlanks(4)) { - WaterManager::SetupTankDemandComponent(WaterConnections(WaterConnNum).Name, - DataIPShortCuts::cCurrentModuleObject, - DataIPShortCuts::cAlphaArgs(4), - ErrorsFound, - WaterConnections(WaterConnNum).SupplyTankNum, - WaterConnections(WaterConnNum).TankDemandID); - } + if (!DataIPShortCuts::lAlphaFieldBlanks(5)) { + WaterManager::SetupTankSupplyComponent(WaterConnections(WaterConnNum).Name, + DataIPShortCuts::cCurrentModuleObject, + DataIPShortCuts::cAlphaArgs(5), + ErrorsFound, + WaterConnections(WaterConnNum).RecoveryTankNum, + WaterConnections(WaterConnNum).TankSupplyID); + } + + if (!DataIPShortCuts::lAlphaFieldBlanks(6)) { + WaterConnections(WaterConnNum).HotTempSchedule = ScheduleManager::GetScheduleIndex(DataIPShortCuts::cAlphaArgs(6)); + // If no HotTempSchedule, there is no hot water. + // HotTempSchedule is ignored if connected to a plant loop via WATER USE CONNECTIONS - if (!DataIPShortCuts::lAlphaFieldBlanks(5)) { - WaterManager::SetupTankSupplyComponent(WaterConnections(WaterConnNum).Name, - DataIPShortCuts::cCurrentModuleObject, - DataIPShortCuts::cAlphaArgs(5), - ErrorsFound, - WaterConnections(WaterConnNum).RecoveryTankNum, - WaterConnections(WaterConnNum).TankSupplyID); + if (WaterConnections(WaterConnNum).HotTempSchedule == 0) { + ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(6) + '=' + DataIPShortCuts::cAlphaArgs(6)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + DataIPShortCuts::cAlphaArgs(1)); + ErrorsFound = true; } + } - if (!DataIPShortCuts::lAlphaFieldBlanks(6)) { - WaterConnections(WaterConnNum).HotTempSchedule = ScheduleManager::GetScheduleIndex(DataIPShortCuts::cAlphaArgs(6)); - // If no HotTempSchedule, there is no hot water. - // HotTempSchedule is ignored if connected to a plant loop via WATER USE CONNECTIONS + if (!DataIPShortCuts::lAlphaFieldBlanks(7)) { + WaterConnections(WaterConnNum).ColdTempSchedule = ScheduleManager::GetScheduleIndex(DataIPShortCuts::cAlphaArgs(7)); + // If no ColdTempSchedule, temperatures will be calculated by WATER MAINS TEMPERATURES object - if (WaterConnections(WaterConnNum).HotTempSchedule == 0) { - ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(6) + '=' + DataIPShortCuts::cAlphaArgs(6)); - ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + DataIPShortCuts::cAlphaArgs(1)); - ErrorsFound = true; - } + if (WaterConnections(WaterConnNum).ColdTempSchedule == 0) { + ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(7) + '=' + DataIPShortCuts::cAlphaArgs(7)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + DataIPShortCuts::cAlphaArgs(1)); + ErrorsFound = true; } + } - if (!DataIPShortCuts::lAlphaFieldBlanks(7)) { - WaterConnections(WaterConnNum).ColdTempSchedule = ScheduleManager::GetScheduleIndex(DataIPShortCuts::cAlphaArgs(7)); - // If no ColdTempSchedule, temperatures will be calculated by WATER MAINS TEMPERATURES object - - if (WaterConnections(WaterConnNum).ColdTempSchedule == 0) { - ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(7) + '=' + DataIPShortCuts::cAlphaArgs(7)); + if ((!DataIPShortCuts::lAlphaFieldBlanks(8)) && (DataIPShortCuts::cAlphaArgs(8) != "NONE")) { + WaterConnections(WaterConnNum).HeatRecovery = true; + + { + auto const SELECT_CASE_var(DataIPShortCuts::cAlphaArgs(8)); + if (SELECT_CASE_var == "IDEAL") { + WaterConnections(WaterConnNum).HeatRecoveryHX = HeatRecoveryHXEnum::Ideal; + } else if (SELECT_CASE_var == "COUNTERFLOW") { + WaterConnections(WaterConnNum).HeatRecoveryHX = HeatRecoveryHXEnum::CounterFlow; + } else if (SELECT_CASE_var == "CROSSFLOW") { + WaterConnections(WaterConnNum).HeatRecoveryHX = HeatRecoveryHXEnum::CrossFlow; + } else { + ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(8) + '=' + DataIPShortCuts::cAlphaArgs(8)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + DataIPShortCuts::cAlphaArgs(1)); ErrorsFound = true; } } - if ((!DataIPShortCuts::lAlphaFieldBlanks(8)) && (DataIPShortCuts::cAlphaArgs(8) != "NONE")) { - WaterConnections(WaterConnNum).HeatRecovery = true; - - { - auto const SELECT_CASE_var(DataIPShortCuts::cAlphaArgs(8)); - if (SELECT_CASE_var == "IDEAL") { - WaterConnections(WaterConnNum).HeatRecoveryHX = HeatRecoveryHXEnum::Ideal; - } else if (SELECT_CASE_var == "COUNTERFLOW") { - WaterConnections(WaterConnNum).HeatRecoveryHX = HeatRecoveryHXEnum::CounterFlow; - } else if (SELECT_CASE_var == "CROSSFLOW") { - WaterConnections(WaterConnNum).HeatRecoveryHX = HeatRecoveryHXEnum::CrossFlow; - } else { - ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(8) + '=' + DataIPShortCuts::cAlphaArgs(8)); - ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + DataIPShortCuts::cAlphaArgs(1)); - ErrorsFound = true; - } - } - - { - auto const SELECT_CASE_var(DataIPShortCuts::cAlphaArgs(9)); - if (SELECT_CASE_var == "PLANT") { - WaterConnections(WaterConnNum).HeatRecoveryConfig = HeatRecoveryConfigEnum::Plant; - } else if (SELECT_CASE_var == "EQUIPMENT") { - WaterConnections(WaterConnNum).HeatRecoveryConfig = HeatRecoveryConfigEnum::Equipment; - } else if (SELECT_CASE_var == "PLANTANDEQUIPMENT") { - WaterConnections(WaterConnNum).HeatRecoveryConfig = HeatRecoveryConfigEnum::PlantAndEquip; - } else { - ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(9) + '=' + DataIPShortCuts::cAlphaArgs(9)); - ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + DataIPShortCuts::cAlphaArgs(1)); - ErrorsFound = true; - } + { + auto const SELECT_CASE_var(DataIPShortCuts::cAlphaArgs(9)); + if (SELECT_CASE_var == "PLANT") { + WaterConnections(WaterConnNum).HeatRecoveryConfig = HeatRecoveryConfigEnum::Plant; + } else if (SELECT_CASE_var == "EQUIPMENT") { + WaterConnections(WaterConnNum).HeatRecoveryConfig = HeatRecoveryConfigEnum::Equipment; + } else if (SELECT_CASE_var == "PLANTANDEQUIPMENT") { + WaterConnections(WaterConnNum).HeatRecoveryConfig = HeatRecoveryConfigEnum::PlantAndEquip; + } else { + ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(9) + '=' + DataIPShortCuts::cAlphaArgs(9)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + DataIPShortCuts::cAlphaArgs(1)); + ErrorsFound = true; } } + } - WaterConnections(WaterConnNum).HXUA = DataIPShortCuts::rNumericArgs(1); + WaterConnections(WaterConnNum).HXUA = DataIPShortCuts::rNumericArgs(1); - WaterConnections(WaterConnNum).myWaterEquipArr.allocate(NumAlphas - 9); + WaterConnections(WaterConnNum).myWaterEquipArr.allocate(NumAlphas - 9); - for (AlphaNum = 10; AlphaNum <= NumAlphas; ++AlphaNum) { - int WaterEquipNum = UtilityRoutines::FindItemInList(DataIPShortCuts::cAlphaArgs(AlphaNum), WaterEquipment); + for (AlphaNum = 10; AlphaNum <= NumAlphas; ++AlphaNum) { + int WaterEquipNum = UtilityRoutines::FindItemInList(DataIPShortCuts::cAlphaArgs(AlphaNum), WaterEquipment); - if (WaterEquipNum == 0) { - ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(AlphaNum) + '=' + DataIPShortCuts::cAlphaArgs(AlphaNum)); - ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + DataIPShortCuts::cAlphaArgs(1)); + if (WaterEquipNum == 0) { + ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(AlphaNum) + '=' + DataIPShortCuts::cAlphaArgs(AlphaNum)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + DataIPShortCuts::cAlphaArgs(1)); + ErrorsFound = true; + } else { + if (WaterEquipment(WaterEquipNum).Connections > 0) { + ShowSevereError(DataIPShortCuts::cCurrentModuleObject + " = " + DataIPShortCuts::cAlphaArgs(1) + + ": WaterUse:Equipment = " + DataIPShortCuts::cAlphaArgs(AlphaNum) + + " is already referenced by another object."); ErrorsFound = true; } else { - if (WaterEquipment(WaterEquipNum).Connections > 0) { - ShowSevereError(DataIPShortCuts::cCurrentModuleObject + " = " + DataIPShortCuts::cAlphaArgs(1) + - ": WaterUse:Equipment = " + - DataIPShortCuts::cAlphaArgs(AlphaNum) + - " is already referenced by another object."); - ErrorsFound = true; - } else { - WaterEquipment(WaterEquipNum).Connections = WaterConnNum; + WaterEquipment(WaterEquipNum).Connections = WaterConnNum; - ++WaterConnections(WaterConnNum).NumWaterEquipment; - WaterConnections(WaterConnNum).myWaterEquipArr(WaterConnections(WaterConnNum).NumWaterEquipment) = WaterEquipNum; + ++WaterConnections(WaterConnNum).NumWaterEquipment; + WaterConnections(WaterConnNum).myWaterEquipArr(WaterConnections(WaterConnNum).NumWaterEquipment) = WaterEquipNum; - WaterConnections(WaterConnNum).PeakVolFlowRate += - WaterEquipment(WaterEquipNum).PeakVolFlowRate; // this does not include possible multipliers - } + WaterConnections(WaterConnNum).PeakVolFlowRate += + WaterEquipment(WaterEquipNum).PeakVolFlowRate; // this does not include possible multipliers } } + } - } // WaterConnNum + } // WaterConnNum - if (ErrorsFound) ShowFatalError("Errors found in processing input for " + DataIPShortCuts::cCurrentModuleObject); + if (ErrorsFound) ShowFatalError("Errors found in processing input for " + DataIPShortCuts::cCurrentModuleObject); - if (numWaterConnections > 0) { - CheckEquipName.allocate(numWaterConnections); - CheckEquipName = true; - } + if (numWaterConnections > 0) { + CheckEquipName.allocate(numWaterConnections); + CheckEquipName = true; } + } - // determine connection's peak mass flow rates. - if (numWaterConnections > 0) { - for (int WaterConnNum = 1; WaterConnNum <= numWaterConnections; ++WaterConnNum) { - WaterConnections(WaterConnNum).PeakMassFlowRate = 0.0; - for (int WaterEquipNum = 1; WaterEquipNum <= WaterConnections(WaterConnNum).NumWaterEquipment; ++WaterEquipNum) { - int thisWaterEquipNum = WaterConnections(WaterConnNum).myWaterEquipArr(WaterEquipNum); - if (WaterEquipment(thisWaterEquipNum).Zone > 0) { - WaterConnections(WaterConnNum).PeakMassFlowRate += - WaterEquipment(thisWaterEquipNum).PeakVolFlowRate * Psychrometrics::RhoH2O(DataGlobals::InitConvTemp) * - DataHeatBalance::Zone(WaterEquipment(thisWaterEquipNum).Zone).Multiplier * DataHeatBalance::Zone(WaterEquipment(thisWaterEquipNum).Zone).ListMultiplier; - } else { // can't have multipliers - WaterConnections(WaterConnNum).PeakMassFlowRate += - WaterEquipment(thisWaterEquipNum).PeakVolFlowRate * Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); - } + // determine connection's peak mass flow rates. + if (numWaterConnections > 0) { + for (int WaterConnNum = 1; WaterConnNum <= numWaterConnections; ++WaterConnNum) { + WaterConnections(WaterConnNum).PeakMassFlowRate = 0.0; + for (int WaterEquipNum = 1; WaterEquipNum <= WaterConnections(WaterConnNum).NumWaterEquipment; ++WaterEquipNum) { + int thisWaterEquipNum = WaterConnections(WaterConnNum).myWaterEquipArr(WaterEquipNum); + if (WaterEquipment(thisWaterEquipNum).Zone > 0) { + WaterConnections(WaterConnNum).PeakMassFlowRate += + WaterEquipment(thisWaterEquipNum).PeakVolFlowRate * Psychrometrics::RhoH2O(DataGlobals::InitConvTemp) * + DataHeatBalance::Zone(WaterEquipment(thisWaterEquipNum).Zone).Multiplier * + DataHeatBalance::Zone(WaterEquipment(thisWaterEquipNum).Zone).ListMultiplier; + } else { // can't have multipliers + WaterConnections(WaterConnNum).PeakMassFlowRate += + WaterEquipment(thisWaterEquipNum).PeakVolFlowRate * Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); } - PlantUtilities::RegisterPlantCompDesignFlow(WaterConnections(WaterConnNum).InletNode, - WaterConnections(WaterConnNum).PeakMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp)); } + PlantUtilities::RegisterPlantCompDesignFlow(WaterConnections(WaterConnNum).InletNode, + WaterConnections(WaterConnNum).PeakMassFlowRate / + Psychrometrics::RhoH2O(DataGlobals::InitConvTemp)); } } + } - void WaterEquipmentType::setupOutputVars() - { - SetupOutputVariable("Water Use Equipment Hot Water Mass Flow Rate", - OutputProcessor::Unit::kg_s, - this->HotMassFlowRate, - "System", - "Average", - this->Name); + void WaterEquipmentType::setupOutputVars() + { + SetupOutputVariable( + "Water Use Equipment Hot Water Mass Flow Rate", OutputProcessor::Unit::kg_s, this->HotMassFlowRate, "System", "Average", this->Name); - SetupOutputVariable("Water Use Equipment Cold Water Mass Flow Rate", - OutputProcessor::Unit::kg_s, - this->ColdMassFlowRate, - "System", - "Average", - this->Name); + SetupOutputVariable( + "Water Use Equipment Cold Water Mass Flow Rate", OutputProcessor::Unit::kg_s, this->ColdMassFlowRate, "System", "Average", this->Name); - SetupOutputVariable("Water Use Equipment Total Mass Flow Rate", - OutputProcessor::Unit::kg_s, - this->TotalMassFlowRate, - "System", - "Average", - this->Name); + SetupOutputVariable( + "Water Use Equipment Total Mass Flow Rate", OutputProcessor::Unit::kg_s, this->TotalMassFlowRate, "System", "Average", this->Name); - SetupOutputVariable("Water Use Equipment Hot Water Volume Flow Rate", - OutputProcessor::Unit::m3_s, - this->HotVolFlowRate, - "System", - "Average", - this->Name); + SetupOutputVariable( + "Water Use Equipment Hot Water Volume Flow Rate", OutputProcessor::Unit::m3_s, this->HotVolFlowRate, "System", "Average", this->Name); - SetupOutputVariable("Water Use Equipment Cold Water Volume Flow Rate", - OutputProcessor::Unit::m3_s, - this->ColdVolFlowRate, - "System", - "Average", - this->Name); + SetupOutputVariable( + "Water Use Equipment Cold Water Volume Flow Rate", OutputProcessor::Unit::m3_s, this->ColdVolFlowRate, "System", "Average", this->Name); - SetupOutputVariable("Water Use Equipment Total Volume Flow Rate", - OutputProcessor::Unit::m3_s, - this->TotalVolFlowRate, - "System", - "Average", - this->Name); + SetupOutputVariable( + "Water Use Equipment Total Volume Flow Rate", OutputProcessor::Unit::m3_s, this->TotalVolFlowRate, "System", "Average", this->Name); - SetupOutputVariable("Water Use Equipment Hot Water Volume", - OutputProcessor::Unit::m3, - this->HotVolume, - "System", - "Sum", - this->Name); + SetupOutputVariable("Water Use Equipment Hot Water Volume", OutputProcessor::Unit::m3, this->HotVolume, "System", "Sum", this->Name); - SetupOutputVariable("Water Use Equipment Cold Water Volume", - OutputProcessor::Unit::m3, - this->ColdVolume, - "System", - "Sum", - this->Name); + SetupOutputVariable("Water Use Equipment Cold Water Volume", OutputProcessor::Unit::m3, this->ColdVolume, "System", "Sum", this->Name); + + SetupOutputVariable("Water Use Equipment Total Volume", + OutputProcessor::Unit::m3, + this->TotalVolume, + "System", + "Sum", + this->Name, + _, + "Water", + "WATERSYSTEMS", + this->EndUseSubcatName, + "Plant"); + SetupOutputVariable("Water Use Equipment Mains Water Volume", + OutputProcessor::Unit::m3, + this->TotalVolume, + "System", + "Sum", + this->Name, + _, + "MainsWater", + "WATERSYSTEMS", + this->EndUseSubcatName, + "Plant"); + + SetupOutputVariable("Water Use Equipment Hot Water Temperature", OutputProcessor::Unit::C, this->HotTemp, "System", "Average", this->Name); + + SetupOutputVariable("Water Use Equipment Cold Water Temperature", OutputProcessor::Unit::C, this->ColdTemp, "System", "Average", this->Name); + + SetupOutputVariable( + "Water Use Equipment Target Water Temperature", OutputProcessor::Unit::C, this->TargetTemp, "System", "Average", this->Name); + + SetupOutputVariable( + "Water Use Equipment Mixed Water Temperature", OutputProcessor::Unit::C, this->MixedTemp, "System", "Average", this->Name); + + SetupOutputVariable( + "Water Use Equipment Drain Water Temperature", OutputProcessor::Unit::C, this->DrainTemp, "System", "Average", this->Name); - SetupOutputVariable("Water Use Equipment Total Volume", - OutputProcessor::Unit::m3, - this->TotalVolume, + SetupOutputVariable("Water Use Equipment Heating Rate", OutputProcessor::Unit::W, this->Power, "System", "Average", this->Name); + + if (this->Connections == 0) { + SetupOutputVariable("Water Use Equipment Heating Energy", + OutputProcessor::Unit::J, + this->Energy, "System", "Sum", this->Name, _, - "Water", + "DISTRICTHEATING", "WATERSYSTEMS", this->EndUseSubcatName, "Plant"); - SetupOutputVariable("Water Use Equipment Mains Water Volume", - OutputProcessor::Unit::m3, - this->TotalVolume, + + } else if (WaterConnections(this->Connections).StandAlone) { + SetupOutputVariable("Water Use Equipment Heating Energy", + OutputProcessor::Unit::J, + this->Energy, "System", "Sum", this->Name, _, - "MainsWater", + "DISTRICTHEATING", "WATERSYSTEMS", this->EndUseSubcatName, "Plant"); - SetupOutputVariable("Water Use Equipment Hot Water Temperature", - OutputProcessor::Unit::C, - this->HotTemp, - "System", - "Average", - this->Name); - - SetupOutputVariable("Water Use Equipment Cold Water Temperature", - OutputProcessor::Unit::C, - this->ColdTemp, - "System", - "Average", - this->Name); - - SetupOutputVariable("Water Use Equipment Target Water Temperature", - OutputProcessor::Unit::C, - this->TargetTemp, + } else { // The EQUIPMENT is coupled to a plant loop via a CONNECTIONS object + SetupOutputVariable("Water Use Equipment Heating Energy", + OutputProcessor::Unit::J, + this->Energy, "System", - "Average", - this->Name); + "Sum", + this->Name, + _, + "ENERGYTRANSFER", + "WATERSYSTEMS", + this->EndUseSubcatName, + "Plant"); + } - SetupOutputVariable("Water Use Equipment Mixed Water Temperature", - OutputProcessor::Unit::C, - this->MixedTemp, - "System", - "Average", - this->Name); + if (this->Zone > 0) { + SetupOutputVariable( + "Water Use Equipment Zone Sensible Heat Gain Rate", OutputProcessor::Unit::W, this->SensibleRate, "System", "Average", this->Name); + SetupOutputVariable( + "Water Use Equipment Zone Sensible Heat Gain Energy", OutputProcessor::Unit::J, this->SensibleEnergy, "System", "Sum", this->Name); - SetupOutputVariable("Water Use Equipment Drain Water Temperature", - OutputProcessor::Unit::C, - this->DrainTemp, - "System", - "Average", - this->Name); + SetupOutputVariable( + "Water Use Equipment Zone Latent Gain Rate", OutputProcessor::Unit::W, this->LatentRate, "System", "Average", this->Name); + SetupOutputVariable( + "Water Use Equipment Zone Latent Gain Energy", OutputProcessor::Unit::J, this->LatentEnergy, "System", "Sum", this->Name); - SetupOutputVariable("Water Use Equipment Heating Rate", - OutputProcessor::Unit::W, - this->Power, + SetupOutputVariable("Water Use Equipment Zone Moisture Gain Mass Flow Rate", + OutputProcessor::Unit::kg_s, + this->MoistureRate, "System", "Average", this->Name); + SetupOutputVariable( + "Water Use Equipment Zone Moisture Gain Mass", OutputProcessor::Unit::kg, this->MoistureMass, "System", "Sum", this->Name); + + SetupZoneInternalGain(this->Zone, + "WaterUse:Equipment", + this->Name, + DataHeatBalance::IntGainTypeOf_WaterUseEquipment, + this->SensibleRateNoMultiplier, + _, + _, + this->LatentRateNoMultiplier); + } + } - if (this->Connections == 0) { - SetupOutputVariable("Water Use Equipment Heating Energy", - OutputProcessor::Unit::J, - this->Energy, - "System", - "Sum", - this->Name, - _, - "DISTRICTHEATING", - "WATERSYSTEMS", - this->EndUseSubcatName, - "Plant"); - - } else if (WaterConnections(this->Connections).StandAlone) { - SetupOutputVariable("Water Use Equipment Heating Energy", - OutputProcessor::Unit::J, - this->Energy, - "System", - "Sum", - this->Name, - _, - "DISTRICTHEATING", - "WATERSYSTEMS", - this->EndUseSubcatName, - "Plant"); - - } else { // The EQUIPMENT is coupled to a plant loop via a CONNECTIONS object - SetupOutputVariable("Water Use Equipment Heating Energy", - OutputProcessor::Unit::J, - this->Energy, - "System", - "Sum", - this->Name, - _, - "ENERGYTRANSFER", - "WATERSYSTEMS", - this->EndUseSubcatName, - "Plant"); - } + void WaterConnectionsType::setupOutputVars() + { + SetupOutputVariable( + "Water Use Connections Hot Water Mass Flow Rate", OutputProcessor::Unit::kg_s, this->HotMassFlowRate, "System", "Average", this->Name); - if (this->Zone > 0) { - SetupOutputVariable("Water Use Equipment Zone Sensible Heat Gain Rate", - OutputProcessor::Unit::W, - this->SensibleRate, - "System", - "Average", - this->Name); - SetupOutputVariable("Water Use Equipment Zone Sensible Heat Gain Energy", - OutputProcessor::Unit::J, - this->SensibleEnergy, - "System", - "Sum", - this->Name); - - SetupOutputVariable("Water Use Equipment Zone Latent Gain Rate", - OutputProcessor::Unit::W, - this->LatentRate, - "System", - "Average", - this->Name); - SetupOutputVariable("Water Use Equipment Zone Latent Gain Energy", - OutputProcessor::Unit::J, - this->LatentEnergy, - "System", - "Sum", - this->Name); - - SetupOutputVariable("Water Use Equipment Zone Moisture Gain Mass Flow Rate", - OutputProcessor::Unit::kg_s, - this->MoistureRate, - "System", - "Average", - this->Name); - SetupOutputVariable("Water Use Equipment Zone Moisture Gain Mass", - OutputProcessor::Unit::kg, - this->MoistureMass, - "System", - "Sum", - this->Name); - - SetupZoneInternalGain(this->Zone, - "WaterUse:Equipment", - this->Name, - DataHeatBalance::IntGainTypeOf_WaterUseEquipment, - this->SensibleRateNoMultiplier, - _, - _, - this->LatentRateNoMultiplier); - } - } + SetupOutputVariable( + "Water Use Connections Cold Water Mass Flow Rate", OutputProcessor::Unit::kg_s, this->ColdMassFlowRate, "System", "Average", this->Name); - void WaterConnectionsType::setupOutputVars() - { - SetupOutputVariable("Water Use Connections Hot Water Mass Flow Rate", - OutputProcessor::Unit::kg_s, - this->HotMassFlowRate, - "System", - "Average", - this->Name); + SetupOutputVariable( + "Water Use Connections Total Mass Flow Rate", OutputProcessor::Unit::kg_s, this->TotalMassFlowRate, "System", "Average", this->Name); - SetupOutputVariable("Water Use Connections Cold Water Mass Flow Rate", - OutputProcessor::Unit::kg_s, - this->ColdMassFlowRate, - "System", - "Average", - this->Name); + SetupOutputVariable("Water Use Connections Drain Water Mass Flow Rate", + OutputProcessor::Unit::kg_s, + this->DrainMassFlowRate, + "System", + "Average", + this->Name); - SetupOutputVariable("Water Use Connections Total Mass Flow Rate", - OutputProcessor::Unit::kg_s, - this->TotalMassFlowRate, - "System", - "Average", - this->Name); + SetupOutputVariable("Water Use Connections Heat Recovery Mass Flow Rate", + OutputProcessor::Unit::kg_s, + this->RecoveryMassFlowRate, + "System", + "Average", + this->Name); - SetupOutputVariable("Water Use Connections Drain Water Mass Flow Rate", - OutputProcessor::Unit::kg_s, - this->DrainMassFlowRate, - "System", - "Average", - this->Name); + SetupOutputVariable( + "Water Use Connections Hot Water Volume Flow Rate", OutputProcessor::Unit::m3_s, this->HotVolFlowRate, "System", "Average", this->Name); - SetupOutputVariable("Water Use Connections Heat Recovery Mass Flow Rate", - OutputProcessor::Unit::kg_s, - this->RecoveryMassFlowRate, - "System", - "Average", - this->Name); + SetupOutputVariable( + "Water Use Connections Cold Water Volume Flow Rate", OutputProcessor::Unit::m3_s, this->ColdVolFlowRate, "System", "Average", this->Name); - SetupOutputVariable("Water Use Connections Hot Water Volume Flow Rate", - OutputProcessor::Unit::m3_s, - this->HotVolFlowRate, - "System", - "Average", - this->Name); + SetupOutputVariable( + "Water Use Connections Total Volume Flow Rate", OutputProcessor::Unit::m3_s, this->TotalVolFlowRate, "System", "Average", this->Name); - SetupOutputVariable("Water Use Connections Cold Water Volume Flow Rate", - OutputProcessor::Unit::m3_s, - this->ColdVolFlowRate, - "System", - "Average", - this->Name); + SetupOutputVariable("Water Use Connections Hot Water Volume", OutputProcessor::Unit::m3, this->HotVolume, "System", "Sum", this->Name); - SetupOutputVariable("Water Use Connections Total Volume Flow Rate", - OutputProcessor::Unit::m3_s, - this->TotalVolFlowRate, - "System", - "Average", - this->Name); + SetupOutputVariable("Water Use Connections Cold Water Volume", OutputProcessor::Unit::m3, this->ColdVolume, "System", "Sum", this->Name); - SetupOutputVariable("Water Use Connections Hot Water Volume", - OutputProcessor::Unit::m3, - this->HotVolume, - "System", - "Sum", - this->Name); + SetupOutputVariable("Water Use Connections Total Volume", OutputProcessor::Unit::m3, this->TotalVolume, "System", "Sum", + this->Name); //, & + // ResourceTypeKey='Water', EndUseKey='DHW', EndUseSubKey=EndUseSubcategoryName, GroupKey='Plant') + // tHIS WAS double counting - SetupOutputVariable("Water Use Connections Cold Water Volume", - OutputProcessor::Unit::m3, - this->ColdVolume, - "System", - "Sum", - this->Name); + SetupOutputVariable("Water Use Connections Hot Water Temperature", OutputProcessor::Unit::C, this->HotTemp, "System", "Average", this->Name); - SetupOutputVariable("Water Use Connections Total Volume", - OutputProcessor::Unit::m3, - this->TotalVolume, - "System", - "Sum", - this->Name); //, & - // ResourceTypeKey='Water', EndUseKey='DHW', EndUseSubKey=EndUseSubcategoryName, GroupKey='Plant') - // tHIS WAS double counting + SetupOutputVariable( + "Water Use Connections Cold Water Temperature", OutputProcessor::Unit::C, this->ColdTemp, "System", "Average", this->Name); - SetupOutputVariable("Water Use Connections Hot Water Temperature", - OutputProcessor::Unit::C, - this->HotTemp, - "System", - "Average", - this->Name); + SetupOutputVariable( + "Water Use Connections Drain Water Temperature", OutputProcessor::Unit::C, this->DrainTemp, "System", "Average", this->Name); - SetupOutputVariable("Water Use Connections Cold Water Temperature", - OutputProcessor::Unit::C, - this->ColdTemp, - "System", - "Average", - this->Name); + SetupOutputVariable( + "Water Use Connections Return Water Temperature", OutputProcessor::Unit::C, this->ReturnTemp, "System", "Average", this->Name); - SetupOutputVariable("Water Use Connections Drain Water Temperature", - OutputProcessor::Unit::C, - this->DrainTemp, - "System", - "Average", - this->Name); + SetupOutputVariable( + "Water Use Connections Waste Water Temperature", OutputProcessor::Unit::C, this->WasteTemp, "System", "Average", this->Name); - SetupOutputVariable("Water Use Connections Return Water Temperature", - OutputProcessor::Unit::C, - this->ReturnTemp, - "System", - "Average", - this->Name); + SetupOutputVariable( + "Water Use Connections Heat Recovery Water Temperature", OutputProcessor::Unit::C, this->RecoveryTemp, "System", "Average", this->Name); - SetupOutputVariable("Water Use Connections Waste Water Temperature", - OutputProcessor::Unit::C, - this->WasteTemp, - "System", - "Average", - this->Name); + SetupOutputVariable( + "Water Use Connections Heat Recovery Effectiveness", OutputProcessor::Unit::None, this->Effectiveness, "System", "Average", this->Name); - SetupOutputVariable("Water Use Connections Heat Recovery Water Temperature", - OutputProcessor::Unit::C, - this->RecoveryTemp, - "System", - "Average", - this->Name); + SetupOutputVariable( + "Water Use Connections Heat Recovery Rate", OutputProcessor::Unit::W, this->RecoveryRate, "System", "Average", this->Name); + SetupOutputVariable( + "Water Use Connections Heat Recovery Energy", OutputProcessor::Unit::J, this->RecoveryEnergy, "System", "Sum", this->Name); + // Does this go on a meter? - SetupOutputVariable("Water Use Connections Heat Recovery Effectiveness", - OutputProcessor::Unit::None, - this->Effectiveness, - "System", - "Average", - this->Name); + // To do: Add report variable for starved flow when tank can't deliver? - SetupOutputVariable("Water Use Connections Heat Recovery Rate", - OutputProcessor::Unit::W, - this->RecoveryRate, - "System", - "Average", - this->Name); - SetupOutputVariable("Water Use Connections Heat Recovery Energy", + if (!this->StandAlone) { + SetupOutputVariable("Water Use Connections Plant Hot Water Energy", OutputProcessor::Unit::J, - this->RecoveryEnergy, + this->Energy, "System", "Sum", - this->Name); - // Does this go on a meter? - - // To do: Add report variable for starved flow when tank can't deliver? - - if (!this->StandAlone) { - SetupOutputVariable("Water Use Connections Plant Hot Water Energy", - OutputProcessor::Unit::J, - this->Energy, - "System", - "Sum", - this->Name, - _, - "PLANTLOOPHEATINGDEMAND", - "WATERSYSTEMS", - _, - "Plant"); - } + this->Name, + _, + "PLANTLOOPHEATINGDEMAND", + "WATERSYSTEMS", + _, + "Plant"); } + } - void WaterEquipmentType::CalcEquipmentFlowRates() - { - - // SUBROUTINE INFORMATION: - // AUTHOR Peter Graham Ellis - // DATE WRITTEN August 2006 - // MODIFIED na - // RE-ENGINEERED na + void WaterEquipmentType::CalcEquipmentFlowRates() + { - // PURPOSE OF THIS SUBROUTINE: - // Calculate desired hot and cold water flow rates - - if (this->setupMyOutputVars) { - this->setupOutputVars(); - this->setupMyOutputVars = false; - } + // SUBROUTINE INFORMATION: + // AUTHOR Peter Graham Ellis + // DATE WRITTEN August 2006 + // MODIFIED na + // RE-ENGINEERED na - if (this->Connections > 0) { - // Get water temperature conditions from the CONNECTIONS object - this->ColdTemp = WaterConnections(this->Connections).ColdTemp; - this->HotTemp = WaterConnections(this->Connections).HotTemp; + // PURPOSE OF THIS SUBROUTINE: + // Calculate desired hot and cold water flow rates - } else { - // Get water temperature conditions from the WATER USE EQUIPMENT schedules - if (this->ColdTempSchedule > 0) { - this->ColdTemp = ScheduleManager::GetCurrentScheduleValue(this->ColdTempSchedule); - } else { // If no ColdTempSchedule, use the mains temperature - this->ColdTemp = DataEnvironment::WaterMainsTemp; - } + if (this->setupMyOutputVars) { + this->setupOutputVars(); + this->setupMyOutputVars = false; + } - if (this->HotTempSchedule > 0) { - this->HotTemp = ScheduleManager::GetCurrentScheduleValue(this->HotTempSchedule); - } else { // If no HotTempSchedule, use all cold water - this->HotTemp = this->ColdTemp; - } + if (this->Connections > 0) { + // Get water temperature conditions from the CONNECTIONS object + this->ColdTemp = WaterConnections(this->Connections).ColdTemp; + this->HotTemp = WaterConnections(this->Connections).HotTemp; + + } else { + // Get water temperature conditions from the WATER USE EQUIPMENT schedules + if (this->ColdTempSchedule > 0) { + this->ColdTemp = ScheduleManager::GetCurrentScheduleValue(this->ColdTempSchedule); + } else { // If no ColdTempSchedule, use the mains temperature + this->ColdTemp = DataEnvironment::WaterMainsTemp; } - if (this->TargetTempSchedule > 0) { - this->TargetTemp = ScheduleManager::GetCurrentScheduleValue(this->TargetTempSchedule); - } else { // If no TargetTempSchedule, use all hot water - this->TargetTemp = this->HotTemp; + if (this->HotTempSchedule > 0) { + this->HotTemp = ScheduleManager::GetCurrentScheduleValue(this->HotTempSchedule); + } else { // If no HotTempSchedule, use all cold water + this->HotTemp = this->ColdTemp; } + } - // Get the requested total flow rate - if (this->Zone > 0) { - if (this->FlowRateFracSchedule > 0) { - this->TotalVolFlowRate = - this->PeakVolFlowRate * - ScheduleManager::GetCurrentScheduleValue(this->FlowRateFracSchedule) * - DataHeatBalance::Zone(this->Zone).Multiplier * DataHeatBalance::Zone(this->Zone).ListMultiplier; - } else { - this->TotalVolFlowRate = this->PeakVolFlowRate * - DataHeatBalance::Zone(this->Zone).Multiplier * - DataHeatBalance::Zone(this->Zone).ListMultiplier; - } + if (this->TargetTempSchedule > 0) { + this->TargetTemp = ScheduleManager::GetCurrentScheduleValue(this->TargetTempSchedule); + } else { // If no TargetTempSchedule, use all hot water + this->TargetTemp = this->HotTemp; + } + + // Get the requested total flow rate + if (this->Zone > 0) { + if (this->FlowRateFracSchedule > 0) { + this->TotalVolFlowRate = this->PeakVolFlowRate * ScheduleManager::GetCurrentScheduleValue(this->FlowRateFracSchedule) * + DataHeatBalance::Zone(this->Zone).Multiplier * DataHeatBalance::Zone(this->Zone).ListMultiplier; } else { - if (this->FlowRateFracSchedule > 0) { - this->TotalVolFlowRate = - this->PeakVolFlowRate * - ScheduleManager::GetCurrentScheduleValue(this->FlowRateFracSchedule); - } else { - this->TotalVolFlowRate = this->PeakVolFlowRate; - } + this->TotalVolFlowRate = + this->PeakVolFlowRate * DataHeatBalance::Zone(this->Zone).Multiplier * DataHeatBalance::Zone(this->Zone).ListMultiplier; + } + } else { + if (this->FlowRateFracSchedule > 0) { + this->TotalVolFlowRate = this->PeakVolFlowRate * ScheduleManager::GetCurrentScheduleValue(this->FlowRateFracSchedule); + } else { + this->TotalVolFlowRate = this->PeakVolFlowRate; } + } - this->TotalMassFlowRate = - this->TotalVolFlowRate * Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); + this->TotalMassFlowRate = this->TotalVolFlowRate * Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); - // Calculate hot and cold water mixing at the tap - if (this->TotalMassFlowRate > 0.0) { - // Calculate the flow rates needed to meet the target temperature - if (this->HotTemp == this->ColdTemp) { // Avoid divide by zero - // There is no hot water - this->HotMassFlowRate = 0.0; + // Calculate hot and cold water mixing at the tap + if (this->TotalMassFlowRate > 0.0) { + // Calculate the flow rates needed to meet the target temperature + if (this->HotTemp == this->ColdTemp) { // Avoid divide by zero + // There is no hot water + this->HotMassFlowRate = 0.0; - // Need a special case for HotTemp < ColdTemp, due to bad user input (but could happen in a plant loop accidentally) + // Need a special case for HotTemp < ColdTemp, due to bad user input (but could happen in a plant loop accidentally) - } else if (this->TargetTemp > this->HotTemp) { - this->HotMassFlowRate = this->TotalMassFlowRate; + } else if (this->TargetTemp > this->HotTemp) { + this->HotMassFlowRate = this->TotalMassFlowRate; - } else { - this->HotMassFlowRate = this->TotalMassFlowRate * - (this->TargetTemp - this->ColdTemp) / - (this->HotTemp - this->ColdTemp); - } + } else { + this->HotMassFlowRate = this->TotalMassFlowRate * (this->TargetTemp - this->ColdTemp) / (this->HotTemp - this->ColdTemp); + } - if (this->HotMassFlowRate < 0.0) { - // Target temp is colder than the cold water temp; don't allow colder - this->HotMassFlowRate = 0.0; - } + if (this->HotMassFlowRate < 0.0) { + // Target temp is colder than the cold water temp; don't allow colder + this->HotMassFlowRate = 0.0; + } - this->ColdMassFlowRate = - this->TotalMassFlowRate - this->HotMassFlowRate; + this->ColdMassFlowRate = this->TotalMassFlowRate - this->HotMassFlowRate; - if (this->ColdMassFlowRate < 0.0) this->ColdMassFlowRate = 0.0; + if (this->ColdMassFlowRate < 0.0) this->ColdMassFlowRate = 0.0; - this->MixedTemp = (this->ColdMassFlowRate * this->ColdTemp + - this->HotMassFlowRate * this->HotTemp) / - this->TotalMassFlowRate; - } else { - this->HotMassFlowRate = 0.0; - this->ColdMassFlowRate = 0.0; - this->MixedTemp = this->TargetTemp; - } + this->MixedTemp = (this->ColdMassFlowRate * this->ColdTemp + this->HotMassFlowRate * this->HotTemp) / this->TotalMassFlowRate; + } else { + this->HotMassFlowRate = 0.0; + this->ColdMassFlowRate = 0.0; + this->MixedTemp = this->TargetTemp; } + } - void WaterEquipmentType::CalcEquipmentDrainTemp() - { + void WaterEquipmentType::CalcEquipmentDrainTemp() + { - // SUBROUTINE INFORMATION: - // AUTHOR Peter Graham Ellis - // DATE WRITTEN August 2006 - // MODIFIED na - // RE-ENGINEERED na + // SUBROUTINE INFORMATION: + // AUTHOR Peter Graham Ellis + // DATE WRITTEN August 2006 + // MODIFIED na + // RE-ENGINEERED na - // PURPOSE OF THIS SUBROUTINE: - // Calculate drainwater temperature and heat and moisture gains to zone. + // PURPOSE OF THIS SUBROUTINE: + // Calculate drainwater temperature and heat and moisture gains to zone. - static std::string const RoutineName("CalcEquipmentDrainTemp"); + static std::string const RoutineName("CalcEquipmentDrainTemp"); - this->SensibleRate = 0.0; - this->SensibleEnergy = 0.0; - this->LatentRate = 0.0; - this->LatentEnergy = 0.0; + this->SensibleRate = 0.0; + this->SensibleEnergy = 0.0; + this->LatentRate = 0.0; + this->LatentEnergy = 0.0; - if ((this->Zone == 0) || (this->TotalMassFlowRate == 0.0)) { - this->DrainTemp = this->MixedTemp; - this->DrainMassFlowRate = this->TotalMassFlowRate; + if ((this->Zone == 0) || (this->TotalMassFlowRate == 0.0)) { + this->DrainTemp = this->MixedTemp; + this->DrainMassFlowRate = this->TotalMassFlowRate; - } else { + } else { - if (this->SensibleFracSchedule == 0) { - this->SensibleRate = 0.0; - this->SensibleEnergy = 0.0; - } else { - this->SensibleRate = - ScheduleManager::GetCurrentScheduleValue(this->SensibleFracSchedule) * - this->TotalMassFlowRate * - Psychrometrics::CPHW(DataGlobals::InitConvTemp) * - (this->MixedTemp - DataHeatBalFanSys::MAT(this->Zone)); - this->SensibleEnergy = - this->SensibleRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - } + if (this->SensibleFracSchedule == 0) { + this->SensibleRate = 0.0; + this->SensibleEnergy = 0.0; + } else { + this->SensibleRate = ScheduleManager::GetCurrentScheduleValue(this->SensibleFracSchedule) * this->TotalMassFlowRate * + Psychrometrics::CPHW(DataGlobals::InitConvTemp) * (this->MixedTemp - DataHeatBalFanSys::MAT(this->Zone)); + this->SensibleEnergy = this->SensibleRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + } - if (this->LatentFracSchedule == 0) { - this->LatentRate = 0.0; - this->LatentEnergy = 0.0; - } else { - Real64 ZoneHumRat = DataHeatBalFanSys::ZoneAirHumRat(this->Zone); - Real64 ZoneHumRatSat = Psychrometrics::PsyWFnTdbRhPb(DataHeatBalFanSys::MAT(this->Zone), 1.0, DataEnvironment::OutBaroPress, RoutineName); // Humidratio at 100% relative humidity - Real64 RhoAirDry = Psychrometrics::PsyRhoAirFnPbTdbW(DataEnvironment::OutBaroPress, DataHeatBalFanSys::MAT(this->Zone), 0.0); - Real64 ZoneMassMax = (ZoneHumRatSat - ZoneHumRat) * RhoAirDry * DataHeatBalance::Zone(this->Zone).Volume; // Max water that can be evaporated to zone - Real64 FlowMassMax = this->TotalMassFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; // Max water in flow - Real64 MoistureMassMax = min(ZoneMassMax, FlowMassMax); - - this->MoistureMass = ScheduleManager::GetCurrentScheduleValue(this->LatentFracSchedule) * MoistureMassMax; - this->MoistureRate = - this->MoistureMass / (DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour); - - this->LatentRate = - this->MoistureRate * Psychrometrics::PsyHfgAirFnWTdb(ZoneHumRat, DataHeatBalFanSys::MAT(this->Zone)); - this->LatentEnergy = - this->LatentRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - } + if (this->LatentFracSchedule == 0) { + this->LatentRate = 0.0; + this->LatentEnergy = 0.0; + } else { + Real64 ZoneHumRat = DataHeatBalFanSys::ZoneAirHumRat(this->Zone); + Real64 ZoneHumRatSat = Psychrometrics::PsyWFnTdbRhPb( + DataHeatBalFanSys::MAT(this->Zone), 1.0, DataEnvironment::OutBaroPress, RoutineName); // Humidratio at 100% relative humidity + Real64 RhoAirDry = Psychrometrics::PsyRhoAirFnPbTdbW(DataEnvironment::OutBaroPress, DataHeatBalFanSys::MAT(this->Zone), 0.0); + Real64 ZoneMassMax = + (ZoneHumRatSat - ZoneHumRat) * RhoAirDry * DataHeatBalance::Zone(this->Zone).Volume; // Max water that can be evaporated to zone + Real64 FlowMassMax = this->TotalMassFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; // Max water in flow + Real64 MoistureMassMax = min(ZoneMassMax, FlowMassMax); + + this->MoistureMass = ScheduleManager::GetCurrentScheduleValue(this->LatentFracSchedule) * MoistureMassMax; + this->MoistureRate = this->MoistureMass / (DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour); + + this->LatentRate = this->MoistureRate * Psychrometrics::PsyHfgAirFnWTdb(ZoneHumRat, DataHeatBalFanSys::MAT(this->Zone)); + this->LatentEnergy = this->LatentRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + } - this->DrainMassFlowRate = - this->TotalMassFlowRate - this->MoistureRate; + this->DrainMassFlowRate = this->TotalMassFlowRate - this->MoistureRate; - if (this->DrainMassFlowRate == 0.0) { - this->DrainTemp = this->MixedTemp; - } else { - this->DrainTemp = - (this->TotalMassFlowRate * Psychrometrics::CPHW(DataGlobals::InitConvTemp) * - this->MixedTemp - - this->SensibleRate - this->LatentRate) / - (this->DrainMassFlowRate * Psychrometrics::CPHW(DataGlobals::InitConvTemp)); - } + if (this->DrainMassFlowRate == 0.0) { + this->DrainTemp = this->MixedTemp; + } else { + this->DrainTemp = (this->TotalMassFlowRate * Psychrometrics::CPHW(DataGlobals::InitConvTemp) * this->MixedTemp - this->SensibleRate - + this->LatentRate) / + (this->DrainMassFlowRate * Psychrometrics::CPHW(DataGlobals::InitConvTemp)); } } + } - void WaterConnectionsType::InitConnections() - { + void WaterConnectionsType::InitConnections() + { - // SUBROUTINE INFORMATION: - // AUTHOR Peter Graham Ellis - // DATE WRITTEN August 2006 - // MODIFIED Brent Griffith 2010, demand side update - // RE-ENGINEERED na + // SUBROUTINE INFORMATION: + // AUTHOR Peter Graham Ellis + // DATE WRITTEN August 2006 + // MODIFIED Brent Griffith 2010, demand side update + // RE-ENGINEERED na - if (this->setupMyOutputVars) { - this->setupOutputVars(); - this->setupMyOutputVars = false; - } + if (this->setupMyOutputVars) { + this->setupOutputVars(); + this->setupMyOutputVars = false; + } - if (allocated(DataPlant::PlantLoop) && !this->StandAlone) { - bool errFlag = false; - PlantUtilities::ScanPlantLoopsForObject(this->Name, - DataPlant::TypeOf_WaterUseConnection, - this->PlantLoopNum, - this->PlantLoopSide, - this->PlantLoopBranchNum, - this->PlantLoopCompNum, - errFlag, - _, - _, - _, - _, - _); - if (errFlag) { - ShowFatalError("InitConnections: Program terminated due to previous condition(s)."); - } + if (allocated(DataPlant::PlantLoop) && !this->StandAlone) { + bool errFlag = false; + PlantUtilities::ScanPlantLoopsForObject(this->Name, + DataPlant::TypeOf_WaterUseConnection, + this->PlantLoopNum, + this->PlantLoopSide, + this->PlantLoopBranchNum, + this->PlantLoopCompNum, + errFlag, + _, + _, + _, + _, + _); + if (errFlag) { + ShowFatalError("InitConnections: Program terminated due to previous condition(s)."); } + } - // Set the cold water temperature - if (this->SupplyTankNum > 0) { - this->ColdSupplyTemp = DataWater::WaterStorage(this->SupplyTankNum).Twater; - - } else if (this->ColdTempSchedule > 0) { - this->ColdSupplyTemp = ScheduleManager::GetCurrentScheduleValue(this->ColdTempSchedule); + // Set the cold water temperature + if (this->SupplyTankNum > 0) { + this->ColdSupplyTemp = DataWater::WaterStorage(this->SupplyTankNum).Twater; - } else { - this->ColdSupplyTemp = DataEnvironment::WaterMainsTemp; - } + } else if (this->ColdTempSchedule > 0) { + this->ColdSupplyTemp = ScheduleManager::GetCurrentScheduleValue(this->ColdTempSchedule); - // Initially set ColdTemp to the ColdSupplyTemp; with heat recovery, ColdTemp will change during iteration - this->ColdTemp = this->ColdSupplyTemp; + } else { + this->ColdSupplyTemp = DataEnvironment::WaterMainsTemp; + } - // Set the hot water temperature - if (this->StandAlone) { - if (this->HotTempSchedule > 0) { - this->HotTemp = ScheduleManager::GetCurrentScheduleValue(this->HotTempSchedule); - } else { - // If no HotTempSchedule, use all cold water - this->HotTemp = this->ColdTemp; - } + // Initially set ColdTemp to the ColdSupplyTemp; with heat recovery, ColdTemp will change during iteration + this->ColdTemp = this->ColdSupplyTemp; + // Set the hot water temperature + if (this->StandAlone) { + if (this->HotTempSchedule > 0) { + this->HotTemp = ScheduleManager::GetCurrentScheduleValue(this->HotTempSchedule); } else { + // If no HotTempSchedule, use all cold water + this->HotTemp = this->ColdTemp; + } - if (DataGlobals::BeginEnvrnFlag && this->Init) { - // Clear node initial conditions - if (this->InletNode > 0 && this->OutletNode > 0) { - PlantUtilities::InitComponentNodes(0.0, - this->PeakMassFlowRate, - this->InletNode, - this->OutletNode, - this->PlantLoopNum, - this->PlantLoopSide, - this->PlantLoopBranchNum, - this->PlantLoopCompNum); - - this->ReturnTemp = DataLoopNode::Node(this->InletNode).Temp; - } - - this->Init = false; + } else { + + if (DataGlobals::BeginEnvrnFlag && this->Init) { + // Clear node initial conditions + if (this->InletNode > 0 && this->OutletNode > 0) { + PlantUtilities::InitComponentNodes(0.0, + this->PeakMassFlowRate, + this->InletNode, + this->OutletNode, + this->PlantLoopNum, + this->PlantLoopSide, + this->PlantLoopBranchNum, + this->PlantLoopCompNum); + + this->ReturnTemp = DataLoopNode::Node(this->InletNode).Temp; } - if (!DataGlobals::BeginEnvrnFlag) this->Init = true; + this->Init = false; + } - if (this->InletNode > 0) { - if (!DataGlobals::DoingSizing) { - this->HotTemp = DataLoopNode::Node(this->InletNode).Temp; - } else { - // plant loop will not be running so need a value here. - // should change to use tank setpoint but water use connections don't have knowledge of the tank they are fed by - this->HotTemp = 60.0; - } + if (!DataGlobals::BeginEnvrnFlag) this->Init = true; + + if (this->InletNode > 0) { + if (!DataGlobals::DoingSizing) { + this->HotTemp = DataLoopNode::Node(this->InletNode).Temp; + } else { + // plant loop will not be running so need a value here. + // should change to use tank setpoint but water use connections don't have knowledge of the tank they are fed by + this->HotTemp = 60.0; } } } + } - void WaterConnectionsType::CalcConnectionsFlowRates(bool FirstHVACIteration) - { + void WaterConnectionsType::CalcConnectionsFlowRates(bool FirstHVACIteration) + { - // SUBROUTINE INFORMATION: - // AUTHOR Peter Graham Ellis - // DATE WRITTEN August 2006 - // MODIFIED na - // RE-ENGINEERED na + // SUBROUTINE INFORMATION: + // AUTHOR Peter Graham Ellis + // DATE WRITTEN August 2006 + // MODIFIED na + // RE-ENGINEERED na - // PURPOSE OF THIS SUBROUTINE: - // Calculate summed values for WATER USE CONNECTIONS (to prepare to request flow from plant, and for reporting). + // PURPOSE OF THIS SUBROUTINE: + // Calculate summed values for WATER USE CONNECTIONS (to prepare to request flow from plant, and for reporting). - this->ColdMassFlowRate = 0.0; - this->HotMassFlowRate = 0.0; + this->ColdMassFlowRate = 0.0; + this->HotMassFlowRate = 0.0; - for (int Loop = 1; Loop <= this->NumWaterEquipment; ++Loop) { - int WaterEquipNum = this->myWaterEquipArr(Loop); + for (int Loop = 1; Loop <= this->NumWaterEquipment; ++Loop) { + int WaterEquipNum = this->myWaterEquipArr(Loop); - WaterEquipment(WaterEquipNum).CalcEquipmentFlowRates(); + WaterEquipment(WaterEquipNum).CalcEquipmentFlowRates(); - this->ColdMassFlowRate += WaterEquipment(WaterEquipNum).ColdMassFlowRate; - this->HotMassFlowRate += WaterEquipment(WaterEquipNum).HotMassFlowRate; - } // Loop - - this->TotalMassFlowRate = - this->ColdMassFlowRate + this->HotMassFlowRate; - - if (!this->StandAlone) { // Interact with the plant loop - if (this->InletNode > 0) { - if (FirstHVACIteration) { - // Request the mass flow rate from the demand side manager - PlantUtilities::SetComponentFlowRate(this->HotMassFlowRate, - this->InletNode, - this->OutletNode, - this->PlantLoopNum, - this->PlantLoopSide, - this->PlantLoopBranchNum, - this->PlantLoopCompNum); + this->ColdMassFlowRate += WaterEquipment(WaterEquipNum).ColdMassFlowRate; + this->HotMassFlowRate += WaterEquipment(WaterEquipNum).HotMassFlowRate; + } // Loop - } else { - Real64 DesiredHotWaterMassFlow = this->HotMassFlowRate; - PlantUtilities::SetComponentFlowRate(DesiredHotWaterMassFlow, - this->InletNode, - this->OutletNode, - this->PlantLoopNum, - this->PlantLoopSide, - this->PlantLoopBranchNum, - this->PlantLoopCompNum); - // readjust if more than actual available mass flow rate determined by the demand side manager - if ((this->HotMassFlowRate != DesiredHotWaterMassFlow) && - (this->HotMassFlowRate > 0.0)) { // plant didn't give what was asked for - - Real64 AvailableFraction = DesiredHotWaterMassFlow / this->HotMassFlowRate; - - this->ColdMassFlowRate = - this->TotalMassFlowRate - - this->HotMassFlowRate; // Preserve the total mass flow rate - - // Proportionally reduce hot water and increase cold water for all WATER USE EQUIPMENT - for (int Loop = 1; Loop <= this->NumWaterEquipment; ++Loop) { - int WaterEquipNum = this->myWaterEquipArr(Loop); - - // Recalculate flow rates for water equipment within connection - WaterEquipment(WaterEquipNum).HotMassFlowRate *= AvailableFraction; - WaterEquipment(WaterEquipNum).ColdMassFlowRate = WaterEquipment(WaterEquipNum).TotalMassFlowRate - WaterEquipment(WaterEquipNum).HotMassFlowRate; - - // Recalculate mixed water temperature - if (WaterEquipment(WaterEquipNum).TotalMassFlowRate > 0.0) { - WaterEquipment(WaterEquipNum).MixedTemp = - (WaterEquipment(WaterEquipNum).ColdMassFlowRate * WaterEquipment(WaterEquipNum).ColdTemp + - WaterEquipment(WaterEquipNum).HotMassFlowRate * WaterEquipment(WaterEquipNum).HotTemp) / - WaterEquipment(WaterEquipNum).TotalMassFlowRate; - } else { - WaterEquipment(WaterEquipNum).MixedTemp = WaterEquipment(WaterEquipNum).TargetTemp; - } - } // Loop - } + this->TotalMassFlowRate = this->ColdMassFlowRate + this->HotMassFlowRate; + + if (!this->StandAlone) { // Interact with the plant loop + if (this->InletNode > 0) { + if (FirstHVACIteration) { + // Request the mass flow rate from the demand side manager + PlantUtilities::SetComponentFlowRate(this->HotMassFlowRate, + this->InletNode, + this->OutletNode, + this->PlantLoopNum, + this->PlantLoopSide, + this->PlantLoopBranchNum, + this->PlantLoopCompNum); + + } else { + Real64 DesiredHotWaterMassFlow = this->HotMassFlowRate; + PlantUtilities::SetComponentFlowRate(DesiredHotWaterMassFlow, + this->InletNode, + this->OutletNode, + this->PlantLoopNum, + this->PlantLoopSide, + this->PlantLoopBranchNum, + this->PlantLoopCompNum); + // readjust if more than actual available mass flow rate determined by the demand side manager + if ((this->HotMassFlowRate != DesiredHotWaterMassFlow) && (this->HotMassFlowRate > 0.0)) { // plant didn't give what was asked for + + Real64 AvailableFraction = DesiredHotWaterMassFlow / this->HotMassFlowRate; + + this->ColdMassFlowRate = this->TotalMassFlowRate - this->HotMassFlowRate; // Preserve the total mass flow rate + + // Proportionally reduce hot water and increase cold water for all WATER USE EQUIPMENT + for (int Loop = 1; Loop <= this->NumWaterEquipment; ++Loop) { + int WaterEquipNum = this->myWaterEquipArr(Loop); + + // Recalculate flow rates for water equipment within connection + WaterEquipment(WaterEquipNum).HotMassFlowRate *= AvailableFraction; + WaterEquipment(WaterEquipNum).ColdMassFlowRate = + WaterEquipment(WaterEquipNum).TotalMassFlowRate - WaterEquipment(WaterEquipNum).HotMassFlowRate; + + // Recalculate mixed water temperature + if (WaterEquipment(WaterEquipNum).TotalMassFlowRate > 0.0) { + WaterEquipment(WaterEquipNum).MixedTemp = + (WaterEquipment(WaterEquipNum).ColdMassFlowRate * WaterEquipment(WaterEquipNum).ColdTemp + + WaterEquipment(WaterEquipNum).HotMassFlowRate * WaterEquipment(WaterEquipNum).HotTemp) / + WaterEquipment(WaterEquipNum).TotalMassFlowRate; + } else { + WaterEquipment(WaterEquipNum).MixedTemp = WaterEquipment(WaterEquipNum).TargetTemp; + } + } // Loop } } } - - if (this->SupplyTankNum > 0) { - // Set the demand request for supply water from water storage tank - this->ColdVolFlowRate = this->ColdMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); - DataWater::WaterStorage(this->SupplyTankNum).VdotRequestDemand(this->TankDemandID) = this->ColdVolFlowRate; - - // Check if cold flow rate should be starved by restricted flow from tank - // Currently, the tank flow is not really starved--water continues to flow at the tank water temperature - // But the user can see the error by comparing report variables for TankVolFlowRate < ColdVolFlowRate - this->TankVolFlowRate = DataWater::WaterStorage(this->SupplyTankNum) - .VdotAvailDemand(this->TankDemandID); - this->TankMassFlowRate = this->TankVolFlowRate * Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); - } } - void WaterConnectionsType::CalcConnectionsDrainTemp() - { + if (this->SupplyTankNum > 0) { + // Set the demand request for supply water from water storage tank + this->ColdVolFlowRate = this->ColdMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); + DataWater::WaterStorage(this->SupplyTankNum).VdotRequestDemand(this->TankDemandID) = this->ColdVolFlowRate; - // SUBROUTINE INFORMATION: - // AUTHOR Peter Graham Ellis - // DATE WRITTEN August 2006 - // MODIFIED na - // RE-ENGINEERED na + // Check if cold flow rate should be starved by restricted flow from tank + // Currently, the tank flow is not really starved--water continues to flow at the tank water temperature + // But the user can see the error by comparing report variables for TankVolFlowRate < ColdVolFlowRate + this->TankVolFlowRate = DataWater::WaterStorage(this->SupplyTankNum).VdotAvailDemand(this->TankDemandID); + this->TankMassFlowRate = this->TankVolFlowRate * Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); + } + } - Real64 MassFlowTempSum = 0.0; - this->DrainMassFlowRate = 0.0; + void WaterConnectionsType::CalcConnectionsDrainTemp() + { - for (int Loop = 1; Loop <= this->NumWaterEquipment; ++Loop) { - int WaterEquipNum = this->myWaterEquipArr(Loop); + // SUBROUTINE INFORMATION: + // AUTHOR Peter Graham Ellis + // DATE WRITTEN August 2006 + // MODIFIED na + // RE-ENGINEERED na - WaterEquipment(WaterEquipNum).CalcEquipmentDrainTemp(); + Real64 MassFlowTempSum = 0.0; + this->DrainMassFlowRate = 0.0; - this->DrainMassFlowRate += WaterEquipment(WaterEquipNum).DrainMassFlowRate; - MassFlowTempSum += WaterEquipment(WaterEquipNum).DrainMassFlowRate * WaterEquipment(WaterEquipNum).DrainTemp; - } // Loop + for (int Loop = 1; Loop <= this->NumWaterEquipment; ++Loop) { + int WaterEquipNum = this->myWaterEquipArr(Loop); - if (this->DrainMassFlowRate > 0.0) { - this->DrainTemp = MassFlowTempSum / this->DrainMassFlowRate; - } else { - this->DrainTemp = this->HotTemp; - } + WaterEquipment(WaterEquipNum).CalcEquipmentDrainTemp(); - this->DrainVolFlowRate = this->DrainMassFlowRate * Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); - } + this->DrainMassFlowRate += WaterEquipment(WaterEquipNum).DrainMassFlowRate; + MassFlowTempSum += WaterEquipment(WaterEquipNum).DrainMassFlowRate * WaterEquipment(WaterEquipNum).DrainTemp; + } // Loop - void WaterConnectionsType::CalcConnectionsHeatRecovery() - { - - // SUBROUTINE INFORMATION: - // AUTHOR Peter Graham Ellis - // DATE WRITTEN August 2006 - // MODIFIED na - // RE-ENGINEERED na - - // PURPOSE OF THIS SUBROUTINE: - // Calculate drainwater heat recovery - - if (!this->HeatRecovery) { - this->RecoveryTemp = this->ColdSupplyTemp; - this->ReturnTemp = this->ColdSupplyTemp; - this->WasteTemp = this->DrainTemp; - - } else if (this->TotalMassFlowRate == 0.0) { - this->Effectiveness = 0.0; - this->RecoveryRate = 0.0; - this->RecoveryTemp = this->ColdSupplyTemp; - this->ReturnTemp = this->ColdSupplyTemp; - this->WasteTemp = this->DrainTemp; - - } else { // WaterConnections(WaterConnNum)%TotalMassFlowRate > 0.0 - - { - auto const SELECT_CASE_var(this->HeatRecoveryConfig); - if (SELECT_CASE_var == HeatRecoveryConfigEnum::Plant) { - this->RecoveryMassFlowRate = this->HotMassFlowRate; - } else if (SELECT_CASE_var == HeatRecoveryConfigEnum::Equipment) { - this->RecoveryMassFlowRate = this->ColdMassFlowRate; - } else if (SELECT_CASE_var == HeatRecoveryConfigEnum::PlantAndEquip) { - this->RecoveryMassFlowRate = this->TotalMassFlowRate; - } - } + if (this->DrainMassFlowRate > 0.0) { + this->DrainTemp = MassFlowTempSum / this->DrainMassFlowRate; + } else { + this->DrainTemp = this->HotTemp; + } - Real64 HXCapacityRate = Psychrometrics::CPHW(DataGlobals::InitConvTemp) * this->RecoveryMassFlowRate; - Real64 DrainCapacityRate = Psychrometrics::CPHW(DataGlobals::InitConvTemp) * this->DrainMassFlowRate; - Real64 MinCapacityRate = min(DrainCapacityRate, HXCapacityRate); + this->DrainVolFlowRate = this->DrainMassFlowRate * Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); + } - { - auto const SELECT_CASE_var(this->HeatRecoveryHX); - if (SELECT_CASE_var == HeatRecoveryHXEnum::Ideal) { - this->Effectiveness = 1.0; + void WaterConnectionsType::CalcConnectionsHeatRecovery() + { - } else if (SELECT_CASE_var == HeatRecoveryHXEnum::CounterFlow) { // Unmixed - Real64 CapacityRatio = MinCapacityRate / max(DrainCapacityRate, HXCapacityRate); - Real64 NTU = this->HXUA / MinCapacityRate; - if (CapacityRatio == 1.0) { - this->Effectiveness = NTU / (1.0 + NTU); - } else { - Real64 ExpVal = std::exp(-NTU * (1.0 - CapacityRatio)); - this->Effectiveness = (1.0 - ExpVal) / (1.0 - CapacityRatio * ExpVal); - } + // SUBROUTINE INFORMATION: + // AUTHOR Peter Graham Ellis + // DATE WRITTEN August 2006 + // MODIFIED na + // RE-ENGINEERED na - } else if (SELECT_CASE_var == HeatRecoveryHXEnum::CrossFlow) { // Unmixed - Real64 CapacityRatio = MinCapacityRate / max(DrainCapacityRate, HXCapacityRate); - Real64 NTU = this->HXUA / MinCapacityRate; - this->Effectiveness = 1.0 - std::exp((std::pow(NTU, 0.22) / CapacityRatio) * (std::exp(-CapacityRatio * std::pow(NTU, 0.78)) - 1.0)); - } + // PURPOSE OF THIS SUBROUTINE: + // Calculate drainwater heat recovery + + if (!this->HeatRecovery) { + this->RecoveryTemp = this->ColdSupplyTemp; + this->ReturnTemp = this->ColdSupplyTemp; + this->WasteTemp = this->DrainTemp; + + } else if (this->TotalMassFlowRate == 0.0) { + this->Effectiveness = 0.0; + this->RecoveryRate = 0.0; + this->RecoveryTemp = this->ColdSupplyTemp; + this->ReturnTemp = this->ColdSupplyTemp; + this->WasteTemp = this->DrainTemp; + + } else { // WaterConnections(WaterConnNum)%TotalMassFlowRate > 0.0 + + { + auto const SELECT_CASE_var(this->HeatRecoveryConfig); + if (SELECT_CASE_var == HeatRecoveryConfigEnum::Plant) { + this->RecoveryMassFlowRate = this->HotMassFlowRate; + } else if (SELECT_CASE_var == HeatRecoveryConfigEnum::Equipment) { + this->RecoveryMassFlowRate = this->ColdMassFlowRate; + } else if (SELECT_CASE_var == HeatRecoveryConfigEnum::PlantAndEquip) { + this->RecoveryMassFlowRate = this->TotalMassFlowRate; } + } - this->RecoveryRate = this->Effectiveness * MinCapacityRate * (this->DrainTemp - this->ColdSupplyTemp); - this->RecoveryTemp = this->ColdSupplyTemp + this->RecoveryRate / (Psychrometrics::CPHW(DataGlobals::InitConvTemp) * this->TotalMassFlowRate); - this->WasteTemp = this->DrainTemp - this->RecoveryRate / (Psychrometrics::CPHW(DataGlobals::InitConvTemp) * this->TotalMassFlowRate); - - if (this->RecoveryTankNum > 0) { - DataWater::WaterStorage(this->RecoveryTankNum).VdotAvailSupply(this->TankSupplyID) = this->DrainVolFlowRate; - DataWater::WaterStorage(this->RecoveryTankNum).TwaterSupply(this->TankSupplyID) = this->WasteTemp; - } + Real64 HXCapacityRate = Psychrometrics::CPHW(DataGlobals::InitConvTemp) * this->RecoveryMassFlowRate; + Real64 DrainCapacityRate = Psychrometrics::CPHW(DataGlobals::InitConvTemp) * this->DrainMassFlowRate; + Real64 MinCapacityRate = min(DrainCapacityRate, HXCapacityRate); - { - auto const SELECT_CASE_var(this->HeatRecoveryConfig); - if (SELECT_CASE_var == HeatRecoveryConfigEnum::Plant) { - this->TempError = 0.0; // No feedback back to the cold supply - this->ReturnTemp = this->RecoveryTemp; + { + auto const SELECT_CASE_var(this->HeatRecoveryHX); + if (SELECT_CASE_var == HeatRecoveryHXEnum::Ideal) { + this->Effectiveness = 1.0; - } else if (SELECT_CASE_var == HeatRecoveryConfigEnum::Equipment) { - this->TempError = std::abs(this->ColdTemp - this->RecoveryTemp); + } else if (SELECT_CASE_var == HeatRecoveryHXEnum::CounterFlow) { // Unmixed + Real64 CapacityRatio = MinCapacityRate / max(DrainCapacityRate, HXCapacityRate); + Real64 NTU = this->HXUA / MinCapacityRate; + if (CapacityRatio == 1.0) { + this->Effectiveness = NTU / (1.0 + NTU); + } else { + Real64 ExpVal = std::exp(-NTU * (1.0 - CapacityRatio)); + this->Effectiveness = (1.0 - ExpVal) / (1.0 - CapacityRatio * ExpVal); + } - this->ColdTemp = this->RecoveryTemp; - this->ReturnTemp = this->ColdSupplyTemp; + } else if (SELECT_CASE_var == HeatRecoveryHXEnum::CrossFlow) { // Unmixed + Real64 CapacityRatio = MinCapacityRate / max(DrainCapacityRate, HXCapacityRate); + Real64 NTU = this->HXUA / MinCapacityRate; + this->Effectiveness = + 1.0 - std::exp((std::pow(NTU, 0.22) / CapacityRatio) * (std::exp(-CapacityRatio * std::pow(NTU, 0.78)) - 1.0)); + } + } - } else if (SELECT_CASE_var == HeatRecoveryConfigEnum::PlantAndEquip) { - this->TempError = std::abs(this->ColdTemp - this->RecoveryTemp); + this->RecoveryRate = this->Effectiveness * MinCapacityRate * (this->DrainTemp - this->ColdSupplyTemp); + this->RecoveryTemp = + this->ColdSupplyTemp + this->RecoveryRate / (Psychrometrics::CPHW(DataGlobals::InitConvTemp) * this->TotalMassFlowRate); + this->WasteTemp = this->DrainTemp - this->RecoveryRate / (Psychrometrics::CPHW(DataGlobals::InitConvTemp) * this->TotalMassFlowRate); - this->ColdTemp = this->RecoveryTemp; - this->ReturnTemp = this->RecoveryTemp; - } - } + if (this->RecoveryTankNum > 0) { + DataWater::WaterStorage(this->RecoveryTankNum).VdotAvailSupply(this->TankSupplyID) = this->DrainVolFlowRate; + DataWater::WaterStorage(this->RecoveryTankNum).TwaterSupply(this->TankSupplyID) = this->WasteTemp; } - } - void WaterConnectionsType::UpdateWaterConnections() - { + { + auto const SELECT_CASE_var(this->HeatRecoveryConfig); + if (SELECT_CASE_var == HeatRecoveryConfigEnum::Plant) { + this->TempError = 0.0; // No feedback back to the cold supply + this->ReturnTemp = this->RecoveryTemp; - // SUBROUTINE INFORMATION: - // AUTHOR Peter Graham Ellis - // DATE WRITTEN August 2006 - // MODIFIED na - // RE-ENGINEERED na + } else if (SELECT_CASE_var == HeatRecoveryConfigEnum::Equipment) { + this->TempError = std::abs(this->ColdTemp - this->RecoveryTemp); - // PURPOSE OF THIS SUBROUTINE: - // Updates the node variables with local variables. + this->ColdTemp = this->RecoveryTemp; + this->ReturnTemp = this->ColdSupplyTemp; - if (this->InletNode > 0 && this->OutletNode > 0) { - // Pass all variables from inlet to outlet node - PlantUtilities::SafeCopyPlantNode(this->InletNode, this->OutletNode, this->PlantLoopNum); + } else if (SELECT_CASE_var == HeatRecoveryConfigEnum::PlantAndEquip) { + this->TempError = std::abs(this->ColdTemp - this->RecoveryTemp); - // Set outlet node variables that are possibly changed - DataLoopNode::Node(this->OutletNode).Temp = this->ReturnTemp; - // should add enthalpy update to return? + this->ColdTemp = this->RecoveryTemp; + this->ReturnTemp = this->RecoveryTemp; + } } } + } - void ReportStandAloneWaterUse() - { + void WaterConnectionsType::UpdateWaterConnections() + { - // SUBROUTINE INFORMATION: - // AUTHOR B. Griffith, Peter Graham Ellis - // DATE WRITTEN Nov. 2011 - // MODIFIED Brent Griffith, March 2010 added argument - // RE-ENGINEERED na + // SUBROUTINE INFORMATION: + // AUTHOR Peter Graham Ellis + // DATE WRITTEN August 2006 + // MODIFIED na + // RE-ENGINEERED na - // PURPOSE OF THIS SUBROUTINE: - // Calculates report variables for stand alone water use + // PURPOSE OF THIS SUBROUTINE: + // Updates the node variables with local variables. - for (int WaterEquipNum = 1; WaterEquipNum <= numWaterEquipment; ++WaterEquipNum) { - auto &thisWEq = WaterEquipment(WaterEquipNum); - thisWEq.ColdVolFlowRate = thisWEq.ColdMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); - thisWEq.HotVolFlowRate = thisWEq.HotMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); - thisWEq.TotalVolFlowRate = thisWEq.ColdVolFlowRate + thisWEq.HotVolFlowRate; - - thisWEq.ColdVolume = thisWEq.ColdVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - thisWEq.HotVolume = thisWEq.HotVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - thisWEq.TotalVolume = thisWEq.TotalVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - - if (thisWEq.Connections == 0) { - thisWEq.Power = thisWEq.HotMassFlowRate * - Psychrometrics::CPHW(DataGlobals::InitConvTemp) * - (thisWEq.HotTemp - thisWEq.ColdTemp); - } else { - thisWEq.Power = thisWEq.HotMassFlowRate * Psychrometrics::CPHW(DataGlobals::InitConvTemp) * - (thisWEq.HotTemp - WaterConnections(thisWEq.Connections).ReturnTemp); - } + if (this->InletNode > 0 && this->OutletNode > 0) { + // Pass all variables from inlet to outlet node + PlantUtilities::SafeCopyPlantNode(this->InletNode, this->OutletNode, this->PlantLoopNum); - thisWEq.Energy = thisWEq.Power * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - } + // Set outlet node variables that are possibly changed + DataLoopNode::Node(this->OutletNode).Temp = this->ReturnTemp; + // should add enthalpy update to return? } + } - void WaterConnectionsType::ReportWaterUse() - { - - // SUBROUTINE INFORMATION: - // AUTHOR Peter Graham Ellis - // DATE WRITTEN August 2006 - // MODIFIED Brent Griffith, March 2010 added argument - // RE-ENGINEERED na - - // PURPOSE OF THIS SUBROUTINE: - // Calculates report variables. + void ReportStandAloneWaterUse() + { - for (int Loop = 1; Loop <= this->NumWaterEquipment; ++Loop) { + // SUBROUTINE INFORMATION: + // AUTHOR B. Griffith, Peter Graham Ellis + // DATE WRITTEN Nov. 2011 + // MODIFIED Brent Griffith, March 2010 added argument + // RE-ENGINEERED na - int WaterEquipNum = this->myWaterEquipArr(Loop); - auto &thisWEq = WaterEquipment(WaterEquipNum); + // PURPOSE OF THIS SUBROUTINE: + // Calculates report variables for stand alone water use - thisWEq.ColdVolFlowRate = thisWEq.ColdMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); - thisWEq.HotVolFlowRate = thisWEq.HotMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); - thisWEq.TotalVolFlowRate = thisWEq.ColdVolFlowRate + thisWEq.HotVolFlowRate; - thisWEq.ColdVolume = thisWEq.ColdVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - thisWEq.HotVolume = thisWEq.HotVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - thisWEq.TotalVolume = thisWEq.TotalVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + for (int WaterEquipNum = 1; WaterEquipNum <= numWaterEquipment; ++WaterEquipNum) { + auto &thisWEq = WaterEquipment(WaterEquipNum); + thisWEq.ColdVolFlowRate = thisWEq.ColdMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); + thisWEq.HotVolFlowRate = thisWEq.HotMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); + thisWEq.TotalVolFlowRate = thisWEq.ColdVolFlowRate + thisWEq.HotVolFlowRate; - if (thisWEq.Connections == 0) { - thisWEq.Power = thisWEq.HotMassFlowRate * Psychrometrics::CPHW(DataGlobals::InitConvTemp) * (thisWEq.HotTemp - thisWEq.ColdTemp); - } else { - thisWEq.Power = thisWEq.HotMassFlowRate * Psychrometrics::CPHW(DataGlobals::InitConvTemp) * - (thisWEq.HotTemp - WaterConnections(thisWEq.Connections).ReturnTemp); - } + thisWEq.ColdVolume = thisWEq.ColdVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + thisWEq.HotVolume = thisWEq.HotVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + thisWEq.TotalVolume = thisWEq.TotalVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - thisWEq.Energy = thisWEq.Power * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + if (thisWEq.Connections == 0) { + thisWEq.Power = thisWEq.HotMassFlowRate * Psychrometrics::CPHW(DataGlobals::InitConvTemp) * (thisWEq.HotTemp - thisWEq.ColdTemp); + } else { + thisWEq.Power = thisWEq.HotMassFlowRate * Psychrometrics::CPHW(DataGlobals::InitConvTemp) * + (thisWEq.HotTemp - WaterConnections(thisWEq.Connections).ReturnTemp); } - this->ColdVolFlowRate = this->ColdMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); - this->HotVolFlowRate = this->HotMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); - this->TotalVolFlowRate = this->ColdVolFlowRate + this->HotVolFlowRate; - this->ColdVolume = this->ColdVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - this->HotVolume = this->HotVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - this->TotalVolume = this->TotalVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - this->Power = this->HotMassFlowRate * Psychrometrics::CPHW(DataGlobals::InitConvTemp) * (this->HotTemp - this->ReturnTemp); - this->Energy = this->Power * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - this->RecoveryEnergy = this->RecoveryRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + thisWEq.Energy = thisWEq.Power * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; } + } - void CalcWaterUseZoneGains() - { + void WaterConnectionsType::ReportWaterUse() + { - // SUBROUTINE INFORMATION: - // AUTHOR Peter Graham Ellis - // DATE WRITTEN August 2006 - // MODIFIED - // RE-ENGINEERED na + // SUBROUTINE INFORMATION: + // AUTHOR Peter Graham Ellis + // DATE WRITTEN August 2006 + // MODIFIED Brent Griffith, March 2010 added argument + // RE-ENGINEERED na - // PURPOSE OF THIS SUBROUTINE: - // Calculates the zone internal gains due to water use sensible and latent loads. + // PURPOSE OF THIS SUBROUTINE: + // Calculates report variables. - bool MyEnvrnFlagLocal(true); + for (int Loop = 1; Loop <= this->NumWaterEquipment; ++Loop) { - if (numWaterEquipment == 0) return; + int WaterEquipNum = this->myWaterEquipArr(Loop); + auto &thisWEq = WaterEquipment(WaterEquipNum); - if (DataGlobals::BeginEnvrnFlag && MyEnvrnFlagLocal) { - for (auto &e : WaterEquipment) { - e.SensibleRate = 0.0; - e.SensibleEnergy = 0.0; - e.SensibleRateNoMultiplier = 0.0; - e.LatentRate = 0.0; - e.LatentEnergy = 0.0; - e.LatentRateNoMultiplier = 0.0; - e.MixedTemp = 0.0; - e.TotalMassFlowRate = 0.0; - e.DrainTemp = 0.0; - e.ColdVolFlowRate = 0.0; - e.HotVolFlowRate = 0.0; - e.TotalVolFlowRate = 0.0; - e.ColdMassFlowRate = 0.0; - e.HotMassFlowRate = 0.0; - } - MyEnvrnFlagLocal = false; + thisWEq.ColdVolFlowRate = thisWEq.ColdMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); + thisWEq.HotVolFlowRate = thisWEq.HotMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); + thisWEq.TotalVolFlowRate = thisWEq.ColdVolFlowRate + thisWEq.HotVolFlowRate; + thisWEq.ColdVolume = thisWEq.ColdVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + thisWEq.HotVolume = thisWEq.HotVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + thisWEq.TotalVolume = thisWEq.TotalVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + + if (thisWEq.Connections == 0) { + thisWEq.Power = thisWEq.HotMassFlowRate * Psychrometrics::CPHW(DataGlobals::InitConvTemp) * (thisWEq.HotTemp - thisWEq.ColdTemp); + } else { + thisWEq.Power = thisWEq.HotMassFlowRate * Psychrometrics::CPHW(DataGlobals::InitConvTemp) * + (thisWEq.HotTemp - WaterConnections(thisWEq.Connections).ReturnTemp); } - if (!DataGlobals::BeginEnvrnFlag) MyEnvrnFlagLocal = true; + thisWEq.Energy = thisWEq.Power * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + } - for (int WaterEquipNum = 1; WaterEquipNum <= numWaterEquipment; ++WaterEquipNum) { - if (WaterEquipment(WaterEquipNum).Zone == 0) continue; - int ZoneNum = WaterEquipment(WaterEquipNum).Zone; - WaterEquipment(WaterEquipNum).SensibleRateNoMultiplier = - WaterEquipment(WaterEquipNum).SensibleRate / - (DataHeatBalance::Zone(ZoneNum).Multiplier * DataHeatBalance::Zone(ZoneNum).ListMultiplier); - WaterEquipment(WaterEquipNum).LatentRateNoMultiplier = - WaterEquipment(WaterEquipNum).LatentRate / - (DataHeatBalance::Zone(ZoneNum).Multiplier * DataHeatBalance::Zone(ZoneNum).ListMultiplier); + this->ColdVolFlowRate = this->ColdMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); + this->HotVolFlowRate = this->HotMassFlowRate / Psychrometrics::RhoH2O(DataGlobals::InitConvTemp); + this->TotalVolFlowRate = this->ColdVolFlowRate + this->HotVolFlowRate; + this->ColdVolume = this->ColdVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + this->HotVolume = this->HotVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + this->TotalVolume = this->TotalVolFlowRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + this->Power = this->HotMassFlowRate * Psychrometrics::CPHW(DataGlobals::InitConvTemp) * (this->HotTemp - this->ReturnTemp); + this->Energy = this->Power * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + this->RecoveryEnergy = this->RecoveryRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + } + + void CalcWaterUseZoneGains() + { + + // SUBROUTINE INFORMATION: + // AUTHOR Peter Graham Ellis + // DATE WRITTEN August 2006 + // MODIFIED + // RE-ENGINEERED na + + // PURPOSE OF THIS SUBROUTINE: + // Calculates the zone internal gains due to water use sensible and latent loads. + + bool MyEnvrnFlagLocal(true); + + if (numWaterEquipment == 0) return; + + if (DataGlobals::BeginEnvrnFlag && MyEnvrnFlagLocal) { + for (auto &e : WaterEquipment) { + e.SensibleRate = 0.0; + e.SensibleEnergy = 0.0; + e.SensibleRateNoMultiplier = 0.0; + e.LatentRate = 0.0; + e.LatentEnergy = 0.0; + e.LatentRateNoMultiplier = 0.0; + e.MixedTemp = 0.0; + e.TotalMassFlowRate = 0.0; + e.DrainTemp = 0.0; + e.ColdVolFlowRate = 0.0; + e.HotVolFlowRate = 0.0; + e.TotalVolFlowRate = 0.0; + e.ColdMassFlowRate = 0.0; + e.HotMassFlowRate = 0.0; } + MyEnvrnFlagLocal = false; + } + + if (!DataGlobals::BeginEnvrnFlag) MyEnvrnFlagLocal = true; + + for (int WaterEquipNum = 1; WaterEquipNum <= numWaterEquipment; ++WaterEquipNum) { + if (WaterEquipment(WaterEquipNum).Zone == 0) continue; + int ZoneNum = WaterEquipment(WaterEquipNum).Zone; + WaterEquipment(WaterEquipNum).SensibleRateNoMultiplier = + WaterEquipment(WaterEquipNum).SensibleRate / + (DataHeatBalance::Zone(ZoneNum).Multiplier * DataHeatBalance::Zone(ZoneNum).ListMultiplier); + WaterEquipment(WaterEquipNum).LatentRateNoMultiplier = + WaterEquipment(WaterEquipNum).LatentRate / + (DataHeatBalance::Zone(ZoneNum).Multiplier * DataHeatBalance::Zone(ZoneNum).ListMultiplier); } - } // namespace WaterUse + } +} // namespace WaterUse } // namespace EnergyPlus diff --git a/src/EnergyPlus/WaterUse.hh b/src/EnergyPlus/WaterUse.hh index 8ceb882f361..4f85fabb42b 100644 --- a/src/EnergyPlus/WaterUse.hh +++ b/src/EnergyPlus/WaterUse.hh @@ -58,205 +58,206 @@ namespace EnergyPlus { - namespace WaterUse { - - enum struct HeatRecoveryHXEnum +namespace WaterUse { + + enum struct HeatRecoveryHXEnum + { + Ideal, + CounterFlow, + CrossFlow + }; + + enum struct HeatRecoveryConfigEnum + { + Plant, + Equipment, + PlantAndEquip + }; + + extern bool getWaterUseInputFlag; + + extern Array1D_bool CheckEquipName; + + struct WaterEquipmentType + { + std::string Name; // Name of DHW + std::string EndUseSubcatName; + int Connections; // Index for WATER USE CONNECTIONS object + Real64 PeakVolFlowRate; // Peak volumetric flow rate, also water consumption rate (m3/s) + int FlowRateFracSchedule; // Pointer to schedule object + Real64 ColdVolFlowRate; + Real64 HotVolFlowRate; + Real64 TotalVolFlowRate; // Volumetric flow rate, also water consumption rate (m3/s) + Real64 ColdMassFlowRate; + Real64 HotMassFlowRate; + Real64 TotalMassFlowRate; // Mass flow rate (kg/s) + Real64 DrainMassFlowRate; + int ColdTempSchedule; // Index for schedule object + int HotTempSchedule; // Index for schedule object + int TargetTempSchedule; // Index for schedule object + Real64 ColdTemp; // Cold supply water temperature (C) + Real64 HotTemp; // Hot supply water temperature (C) + Real64 TargetTemp; // Target (mixed) water temperature (C) + Real64 MixedTemp; // Actual outlet (mixed) water temperature (C) + Real64 DrainTemp; + int Zone; // Index for zone object + int SensibleFracSchedule; // Pointer to schedule object + Real64 SensibleRate; + Real64 SensibleEnergy; + Real64 SensibleRateNoMultiplier; + int LatentFracSchedule; // Pointer to schedule object + Real64 LatentRate; + Real64 LatentEnergy; + Real64 LatentRateNoMultiplier; + Real64 MoistureRate; + Real64 MoistureMass; + Real64 ColdVolume; // Water consumption (m3) + Real64 HotVolume; // Water consumption (m3) + Real64 TotalVolume; // Water consumption (m3) + Real64 Power; // Heating rate required to meet the mixed water temperature (W) + Real64 Energy; // Heating energy required to meet the mixed water temperature (J) + bool setupMyOutputVars; + + WaterEquipmentType() + : Connections(0), PeakVolFlowRate(0.0), FlowRateFracSchedule(0), ColdVolFlowRate(0.0), HotVolFlowRate(0.0), TotalVolFlowRate(0.0), + ColdMassFlowRate(0.0), HotMassFlowRate(0.0), TotalMassFlowRate(0.0), DrainMassFlowRate(0.0), ColdTempSchedule(0), HotTempSchedule(0), + TargetTempSchedule(0), ColdTemp(0.0), HotTemp(0.0), TargetTemp(0.0), MixedTemp(0.0), DrainTemp(0.0), Zone(0), SensibleFracSchedule(0), + SensibleRate(0.0), SensibleEnergy(0.0), SensibleRateNoMultiplier(0.0), LatentFracSchedule(0), LatentRate(0.0), LatentEnergy(0.0), + LatentRateNoMultiplier(0.0), MoistureRate(0.0), MoistureMass(0.0), ColdVolume(0.0), HotVolume(0.0), TotalVolume(0.0), Power(0.0), + Energy(0.0), setupMyOutputVars(true) { - Ideal, - CounterFlow, - CrossFlow - }; + } - enum struct HeatRecoveryConfigEnum + // Reset Some Values to Zeros + void reset() + { + SensibleRate = 0.0; + SensibleEnergy = 0.0; + LatentRate = 0.0; + LatentEnergy = 0.0; + MixedTemp = 0.0; + TotalMassFlowRate = 0.0; + DrainTemp = 0.0; + } + + void CalcEquipmentFlowRates(); + + void CalcEquipmentDrainTemp(); + + void setupOutputVars(); + }; + + struct WaterConnectionsType : PlantComponent + { + std::string Name; // Name of DHW + bool Init; // Flag for initialization: TRUE means do the init + bool InitSizing; // Flag for initialization of plant sizing + bool StandAlone; // Flag for operation with no plant connections + int InletNode; // Hot water demand node + int OutletNode; // Cold water supply node + int SupplyTankNum; + int RecoveryTankNum; + int TankDemandID; // array to request flow from supply tank + int TankSupplyID; // array to send flow to recovery tank + bool HeatRecovery; + HeatRecoveryHXEnum HeatRecoveryHX; + HeatRecoveryConfigEnum HeatRecoveryConfig; + Real64 HXUA; + Real64 Effectiveness; + Real64 RecoveryRate; + Real64 RecoveryEnergy; + Real64 MainsMassFlowRate; // Mass flow rate (kg/s) + Real64 TankMassFlowRate; // Mass flow rate (kg/s) + Real64 ColdMassFlowRate; // Mass flow rate (kg/s) cold = mains + tank + Real64 HotMassFlowRate; // Mass flow rate (kg/s) + Real64 TotalMassFlowRate; // Mass flow rate (kg/s) total = cold + hot + Real64 DrainMassFlowRate; + Real64 RecoveryMassFlowRate; + Real64 PeakVolFlowRate; // Volumetric flow rate, also water consumption rate (m3/s) + Real64 MainsVolFlowRate; // Volumetric flow rate, also water consumption rate (m3/s) + Real64 TankVolFlowRate; // Volumetric flow rate, also water consumption rate (m3/s) + Real64 ColdVolFlowRate; // Volumetric flow rate, also water consumption rate (m3/s) + Real64 HotVolFlowRate; // Volumetric flow rate, also water consumption rate (m3/s) + Real64 TotalVolFlowRate; // Volumetric flow rate, also water consumption rate (m3/s) + Real64 DrainVolFlowRate; + Real64 PeakMassFlowRate; // Peak Mass flow rate for MassFlowRateMax + int ColdTempSchedule; // Index for schedule object + int HotTempSchedule; // Index for schedule object + Real64 MainsTemp; // Cold supply water temperature (C) + Real64 TankTemp; // Cold supply water temperature (C) + Real64 ColdSupplyTemp; // cold from mains, schedule, or tank, depending + Real64 ColdTemp; // Cold supply water temperature (C) actual cold (could be reheated) + Real64 HotTemp; // Hot supply water temperature (C) + Real64 DrainTemp; + Real64 RecoveryTemp; + Real64 ReturnTemp; + Real64 WasteTemp; + Real64 TempError; + Real64 MainsVolume; // Water consumption (m3) + Real64 TankVolume; // Water consumption (m3) + Real64 ColdVolume; // Water consumption (m3) + Real64 HotVolume; // Water consumption (m3) + Real64 TotalVolume; // Water consumption (m3) + Real64 Power; // Heating rate required to raise temperature from cold to hot (W) + Real64 Energy; // Heating energy required to raise temperature from cold to hot (J) + int NumWaterEquipment; + int MaxIterationsErrorIndex; // recurring error index + Array1D_int myWaterEquipArr; + int PlantLoopNum; + int PlantLoopSide; + int PlantLoopBranchNum; + int PlantLoopCompNum; + bool MyEnvrnFlag; + bool setupMyOutputVars; + + WaterConnectionsType() + : Init(true), InitSizing(true), StandAlone(false), InletNode(0), OutletNode(0), SupplyTankNum(0), RecoveryTankNum(0), TankDemandID(0), + TankSupplyID(0), HeatRecovery(false), HeatRecoveryHX(HeatRecoveryHXEnum::Ideal), HeatRecoveryConfig(HeatRecoveryConfigEnum::Plant), + HXUA(0.0), Effectiveness(0.0), RecoveryRate(0.0), RecoveryEnergy(0.0), MainsMassFlowRate(0.0), TankMassFlowRate(0.0), + ColdMassFlowRate(0.0), HotMassFlowRate(0.0), TotalMassFlowRate(0.0), DrainMassFlowRate(0.0), RecoveryMassFlowRate(0.0), + PeakVolFlowRate(0.0), MainsVolFlowRate(0.0), TankVolFlowRate(0.0), ColdVolFlowRate(0.0), HotVolFlowRate(0.0), TotalVolFlowRate(0.0), + DrainVolFlowRate(0.0), PeakMassFlowRate(0.0), ColdTempSchedule(0), HotTempSchedule(0), MainsTemp(0.0), TankTemp(0.0), + ColdSupplyTemp(0.0), ColdTemp(0.0), HotTemp(0.0), DrainTemp(0.0), RecoveryTemp(0.0), ReturnTemp(0.0), WasteTemp(0.0), TempError(0.0), + MainsVolume(0.0), TankVolume(0.0), ColdVolume(0.0), HotVolume(0.0), TotalVolume(0.0), Power(0.0), Energy(0.0), NumWaterEquipment(0), + MaxIterationsErrorIndex(0), PlantLoopNum(0), PlantLoopSide(0), PlantLoopBranchNum(0), PlantLoopCompNum(0), MyEnvrnFlag(true), + setupMyOutputVars(true) { - Plant, - Equipment, - PlantAndEquip - }; + } - extern bool getWaterUseInputFlag; + static PlantComponent *factory(std::string const &objectName); - extern Array1D_bool CheckEquipName; + void simulate(const PlantLocation &calledFromLocation, bool FirstHVACIteration, Real64 &CurLoad, bool RunFlag) override; - struct WaterEquipmentType - { - std::string Name; // Name of DHW - std::string EndUseSubcatName; - int Connections; // Index for WATER USE CONNECTIONS object - Real64 PeakVolFlowRate; // Peak volumetric flow rate, also water consumption rate (m3/s) - int FlowRateFracSchedule; // Pointer to schedule object - Real64 ColdVolFlowRate; - Real64 HotVolFlowRate; - Real64 TotalVolFlowRate; // Volumetric flow rate, also water consumption rate (m3/s) - Real64 ColdMassFlowRate; - Real64 HotMassFlowRate; - Real64 TotalMassFlowRate; // Mass flow rate (kg/s) - Real64 DrainMassFlowRate; - int ColdTempSchedule; // Index for schedule object - int HotTempSchedule; // Index for schedule object - int TargetTempSchedule; // Index for schedule object - Real64 ColdTemp; // Cold supply water temperature (C) - Real64 HotTemp; // Hot supply water temperature (C) - Real64 TargetTemp; // Target (mixed) water temperature (C) - Real64 MixedTemp; // Actual outlet (mixed) water temperature (C) - Real64 DrainTemp; - int Zone; // Index for zone object - int SensibleFracSchedule; // Pointer to schedule object - Real64 SensibleRate; - Real64 SensibleEnergy; - Real64 SensibleRateNoMultiplier; - int LatentFracSchedule; // Pointer to schedule object - Real64 LatentRate; - Real64 LatentEnergy; - Real64 LatentRateNoMultiplier; - Real64 MoistureRate; - Real64 MoistureMass; - Real64 ColdVolume; // Water consumption (m3) - Real64 HotVolume; // Water consumption (m3) - Real64 TotalVolume; // Water consumption (m3) - Real64 Power; // Heating rate required to meet the mixed water temperature (W) - Real64 Energy; // Heating energy required to meet the mixed water temperature (J) - bool setupMyOutputVars; - - WaterEquipmentType() - : Connections(0), PeakVolFlowRate(0.0), FlowRateFracSchedule(0), ColdVolFlowRate(0.0), HotVolFlowRate(0.0), TotalVolFlowRate(0.0), - ColdMassFlowRate(0.0), HotMassFlowRate(0.0), TotalMassFlowRate(0.0), DrainMassFlowRate(0.0), ColdTempSchedule(0), HotTempSchedule(0), - TargetTempSchedule(0), ColdTemp(0.0), HotTemp(0.0), TargetTemp(0.0), MixedTemp(0.0), DrainTemp(0.0), Zone(0), SensibleFracSchedule(0), - SensibleRate(0.0), SensibleEnergy(0.0), SensibleRateNoMultiplier(0.0), LatentFracSchedule(0), LatentRate(0.0), LatentEnergy(0.0), - LatentRateNoMultiplier(0.0), MoistureRate(0.0), MoistureMass(0.0), ColdVolume(0.0), HotVolume(0.0), TotalVolume(0.0), Power(0.0), - Energy(0.0), setupMyOutputVars(true) - { - } - - // Reset Some Values to Zeros - void reset() - { - SensibleRate = 0.0; - SensibleEnergy = 0.0; - LatentRate = 0.0; - LatentEnergy = 0.0; - MixedTemp = 0.0; - TotalMassFlowRate = 0.0; - DrainTemp = 0.0; - } - - void CalcEquipmentFlowRates(); - - void CalcEquipmentDrainTemp(); - - void setupOutputVars(); - }; - - struct WaterConnectionsType : PlantComponent - { - std::string Name; // Name of DHW - bool Init; // Flag for initialization: TRUE means do the init - bool InitSizing; // Flag for initialization of plant sizing - bool StandAlone; // Flag for operation with no plant connections - int InletNode; // Hot water demand node - int OutletNode; // Cold water supply node - int SupplyTankNum; - int RecoveryTankNum; - int TankDemandID; // array to request flow from supply tank - int TankSupplyID; // array to send flow to recovery tank - bool HeatRecovery; - HeatRecoveryHXEnum HeatRecoveryHX; - HeatRecoveryConfigEnum HeatRecoveryConfig; - Real64 HXUA; - Real64 Effectiveness; - Real64 RecoveryRate; - Real64 RecoveryEnergy; - Real64 MainsMassFlowRate; // Mass flow rate (kg/s) - Real64 TankMassFlowRate; // Mass flow rate (kg/s) - Real64 ColdMassFlowRate; // Mass flow rate (kg/s) cold = mains + tank - Real64 HotMassFlowRate; // Mass flow rate (kg/s) - Real64 TotalMassFlowRate; // Mass flow rate (kg/s) total = cold + hot - Real64 DrainMassFlowRate; - Real64 RecoveryMassFlowRate; - Real64 PeakVolFlowRate; // Volumetric flow rate, also water consumption rate (m3/s) - Real64 MainsVolFlowRate; // Volumetric flow rate, also water consumption rate (m3/s) - Real64 TankVolFlowRate; // Volumetric flow rate, also water consumption rate (m3/s) - Real64 ColdVolFlowRate; // Volumetric flow rate, also water consumption rate (m3/s) - Real64 HotVolFlowRate; // Volumetric flow rate, also water consumption rate (m3/s) - Real64 TotalVolFlowRate; // Volumetric flow rate, also water consumption rate (m3/s) - Real64 DrainVolFlowRate; - Real64 PeakMassFlowRate; // Peak Mass flow rate for MassFlowRateMax - int ColdTempSchedule; // Index for schedule object - int HotTempSchedule; // Index for schedule object - Real64 MainsTemp; // Cold supply water temperature (C) - Real64 TankTemp; // Cold supply water temperature (C) - Real64 ColdSupplyTemp; // cold from mains, schedule, or tank, depending - Real64 ColdTemp; // Cold supply water temperature (C) actual cold (could be reheated) - Real64 HotTemp; // Hot supply water temperature (C) - Real64 DrainTemp; - Real64 RecoveryTemp; - Real64 ReturnTemp; - Real64 WasteTemp; - Real64 TempError; - Real64 MainsVolume; // Water consumption (m3) - Real64 TankVolume; // Water consumption (m3) - Real64 ColdVolume; // Water consumption (m3) - Real64 HotVolume; // Water consumption (m3) - Real64 TotalVolume; // Water consumption (m3) - Real64 Power; // Heating rate required to raise temperature from cold to hot (W) - Real64 Energy; // Heating energy required to raise temperature from cold to hot (J) - int NumWaterEquipment; - int MaxIterationsErrorIndex; // recurring error index - Array1D_int myWaterEquipArr; - int PlantLoopNum; - int PlantLoopSide; - int PlantLoopBranchNum; - int PlantLoopCompNum; - bool MyEnvrnFlag; - bool setupMyOutputVars; - - WaterConnectionsType() - : Init(true), InitSizing(true), StandAlone(false), InletNode(0), OutletNode(0), SupplyTankNum(0), RecoveryTankNum(0), TankDemandID(0), - TankSupplyID(0), HeatRecovery(false), HeatRecoveryHX(HeatRecoveryHXEnum::Ideal), HeatRecoveryConfig(HeatRecoveryConfigEnum::Plant), HXUA(0.0), - Effectiveness(0.0), RecoveryRate(0.0), RecoveryEnergy(0.0), MainsMassFlowRate(0.0), TankMassFlowRate(0.0), ColdMassFlowRate(0.0), - HotMassFlowRate(0.0), TotalMassFlowRate(0.0), DrainMassFlowRate(0.0), RecoveryMassFlowRate(0.0), PeakVolFlowRate(0.0), - MainsVolFlowRate(0.0), TankVolFlowRate(0.0), ColdVolFlowRate(0.0), HotVolFlowRate(0.0), TotalVolFlowRate(0.0), DrainVolFlowRate(0.0), - PeakMassFlowRate(0.0), ColdTempSchedule(0), HotTempSchedule(0), MainsTemp(0.0), TankTemp(0.0), ColdSupplyTemp(0.0), ColdTemp(0.0), - HotTemp(0.0), DrainTemp(0.0), RecoveryTemp(0.0), ReturnTemp(0.0), WasteTemp(0.0), TempError(0.0), MainsVolume(0.0), TankVolume(0.0), - ColdVolume(0.0), HotVolume(0.0), TotalVolume(0.0), Power(0.0), Energy(0.0), NumWaterEquipment(0), MaxIterationsErrorIndex(0), - PlantLoopNum(0), PlantLoopSide(0), PlantLoopBranchNum(0), PlantLoopCompNum(0), MyEnvrnFlag(true), setupMyOutputVars(true) - { - } - - static PlantComponent *factory(std::string const &objectName); - - void simulate(const PlantLocation &calledFromLocation, bool FirstHVACIteration, Real64 &CurLoad, bool RunFlag) override; - - void InitConnections(); - - void CalcConnectionsFlowRates(bool FirstHVACIteration); - - void CalcConnectionsDrainTemp(); - - void CalcConnectionsHeatRecovery(); - - void UpdateWaterConnections(); - - void ReportWaterUse(); - - void setupOutputVars(); - }; - - void clear_state(); - - void SimulateWaterUse(bool FirstHVACIteration); - - void GetWaterUseInput(); - - void ReportStandAloneWaterUse(); - - void CalcWaterUseZoneGains(); - - extern Array1D WaterEquipment; - - extern Array1D WaterConnections; - - } // namespace WaterUse + void InitConnections(); + + void CalcConnectionsFlowRates(bool FirstHVACIteration); + + void CalcConnectionsDrainTemp(); + + void CalcConnectionsHeatRecovery(); + + void UpdateWaterConnections(); + + void ReportWaterUse(); + + void setupOutputVars(); + }; + + void clear_state(); + + void SimulateWaterUse(bool FirstHVACIteration); + + void GetWaterUseInput(); + + void ReportStandAloneWaterUse(); + + void CalcWaterUseZoneGains(); + + extern Array1D WaterEquipment; + + extern Array1D WaterConnections; + +} // namespace WaterUse } // namespace EnergyPlus