From f7838629a69166dc2d801ff058962cf74c4959e9 Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Tue, 15 Oct 2019 12:52:19 -0600 Subject: [PATCH 01/13] cleanup comments --- src/EnergyPlus/CTElectricGenerator.cc | 95 +-------------------------- 1 file changed, 1 insertion(+), 94 deletions(-) diff --git a/src/EnergyPlus/CTElectricGenerator.cc b/src/EnergyPlus/CTElectricGenerator.cc index aeec2e8b387..436e45e2c57 100644 --- a/src/EnergyPlus/CTElectricGenerator.cc +++ b/src/EnergyPlus/CTElectricGenerator.cc @@ -75,7 +75,7 @@ namespace EnergyPlus { namespace CTElectricGenerator { - //__________________________________________________________________________ + //__________________________________________________________________________; // BLAST inherited generators: // CTElectricGenerator (COMBUSTION Turbine) @@ -96,7 +96,6 @@ namespace CTElectricGenerator { // All CT Generator models are based on a polynomial fit of Generator // performance data. - // Using/Aliasing using namespace DataPrecisionGlobals; using namespace DataLoopNode; using DataGlobalConstants::iGeneratorCombTurbine; @@ -104,13 +103,11 @@ namespace CTElectricGenerator { using DataGlobals::NumOfTimeStepInHour; using DataGlobals::SecInHour; - // MODULE VARIABLE DECLARATIONS: int NumCTGenerators(0); // number of CT Generators specified in input bool GetCTInput(true); // then TRUE, calls subroutine to read input file. Array1D_bool CheckEquipName; - // Object Data Array1D CTGenerator; // dimension to number of machines Array1D CTGeneratorReport; @@ -131,10 +128,8 @@ namespace CTElectricGenerator { // 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 @@ -191,8 +186,6 @@ namespace CTElectricGenerator { // PURPOSE OF THIS SUBROUTINE: // Fill data needed in PlantLoopEquipments - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - if (GetCTInput) { GetCTGeneratorInput(); GetCTInput = false; @@ -227,10 +220,6 @@ namespace CTElectricGenerator { // This routine will get the input // required by the CT Generator models. - // METHODOLOGY EMPLOYED: - // EnergyPlus input processor - - // Using/Aliasing using namespace DataIPShortCuts; // Data for field names, blank numerics using BranchNodeConnections::TestCompSet; using CurveManager::GetCurveIndex; @@ -239,7 +228,6 @@ namespace CTElectricGenerator { using OutAirNodeManager::CheckOutAirNodeNumber; using PlantUtilities::RegisterPlantCompDesignFlow; - // LOCAL VARIABLES int GeneratorNum; // Generator counter int NumAlphas; // Number of elements in the alpha array int NumNums; // Number of elements in the numeric array @@ -248,8 +236,6 @@ namespace CTElectricGenerator { Array1D NumArray(12); // numeric data static bool ErrorsFound(false); // error flag - // FLOW - cCurrentModuleObject = "Generator:CombustionTurbine"; NumCTGenerators = inputProcessor->getNumObjectsFound(cCurrentModuleObject); @@ -578,12 +564,6 @@ namespace CTElectricGenerator { } } - // End of Get Input subroutines for the CT Generator Module - //****************************************************************************** - - // Beginning of Generator model Subroutines - // ***************************************************************************** - void CalcCTGeneratorModel(int const GeneratorNum, // Generator number bool const RunFlag, // TRUE when Generator operating Real64 const MyLoad, // Generator demand @@ -602,26 +582,22 @@ namespace CTElectricGenerator { // curve fit of performance data. This model was originally // developed by Dale Herron for the BLAST program - // Using/Aliasing using CurveManager::CurveValue; using DataEnvironment::OutDryBulbTemp; using DataHVACGlobals::TimeStepSys; using DataPlant::PlantLoop; using FluidProperties::GetSpecificHeatGlycol; - // SUBROUTINE PARAMETER DEFINITIONS: Real64 const ExhaustCP(1.047); // Exhaust Gas Specific Heat (J/kg-K) Real64 const KJtoJ(1000.0); // convert Kjoules to joules static std::string const RoutineName("CalcCTGeneratorModel"); - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: Real64 MinPartLoadRat; // min allowed operating frac full load Real64 MaxPartLoadRat; // max allowed operating frac full load Real64 RatedPowerOutput; // Generator nominal capacity (W) Real64 ElecPowerGenerated; // Generator output (W) Real64 ElectricEnergyGen; // Generator output (J) - // Special variables for CT Generator Real64 MaxExhaustperCTPower; // MAX EXHAUST FLOW PER W POWER OUTPUT COEFF Real64 PLR; // Generator operating part load ratio Real64 FuelUseRate; // (EFUEL) rate of Fuel Energy Required to run COMBUSTION turbine (W) @@ -648,7 +624,6 @@ namespace CTElectricGenerator { Real64 HRecRatio; // When Max Temp is reached the amount of recovered heat has to be reduced. // and this assumption uses this ratio to accomplish this task. - // LOAD LOCAL VARIABLES FROM DATA STRUCTURE (for code readability) MinPartLoadRat = CTGenerator(GeneratorNum).MinPartLoadRat; MaxPartLoadRat = CTGenerator(GeneratorNum).MaxPartLoadRat; RatedPowerOutput = CTGenerator(GeneratorNum).RatedPowerOutput; @@ -805,12 +780,6 @@ namespace CTElectricGenerator { CTGenerator(GeneratorNum).ExhaustStackTemp = ExhaustStackTemp; } - // End of CT Generator Module Model Subroutines - // ***************************************************************************** - - // Begin CT Generator Module Utility Subroutines - // ***************************************************************************** - void InitCTGenerators(int const GeneratorNum, // Generator number bool const RunFlag, // TRUE when Generator operating Real64 const EP_UNUSED(MyLoad), // Generator demand @@ -826,10 +795,6 @@ namespace CTElectricGenerator { // PURPOSE OF THIS SUBROUTINE: // This subroutine is for initializations of the CT generators. - // METHODOLOGY EMPLOYED: - // Uses the status flags to trigger initializations. - - // Using/Aliasing using DataPlant::PlantLoop; using DataPlant::TypeOf_Generator_CTurbine; using FluidProperties::GetDensityGlycol; @@ -837,10 +802,8 @@ namespace CTElectricGenerator { using PlantUtilities::ScanPlantLoopsForObject; using PlantUtilities::SetComponentFlowRate; - // SUBROUTINE PARAMETER DEFINITIONS: static std::string const RoutineName("InitICEngineGenerators"); - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int HeatRecInletNode; // inlet node number in heat recovery loop int HeatRecOutletNode; // outlet node number in heat recovery loop static bool MyOneTimeFlag(true); // Initialization flag @@ -852,10 +815,7 @@ namespace CTElectricGenerator { Real64 rho; bool errFlag; - // FLOW: - // Do the one time initializations - if (MyOneTimeFlag) { MyEnvrnFlag.allocate(NumCTGenerators); MyPlantScanFlag.allocate(NumCTGenerators); @@ -961,12 +921,6 @@ namespace CTElectricGenerator { } } - // End CT Generator Module Utility Subroutines - // ***************************************************************************** - - // Beginning of Record Keeping subroutines for the CT Generator Module - // ***************************************************************************** - void UpdateCTGeneratorRecords(bool const EP_UNUSED(RunFlag), // TRUE if Generator operating int const Num // Generator number ) @@ -975,36 +929,13 @@ namespace CTElectricGenerator { // AUTHOR: Dan Fisher // DATE WRITTEN: October 1998 - // PURPOSE OF THIS SUBROUTINE: - // reporting - - // METHODOLOGY EMPLOYED: na - - // REFERENCES: na - - // USE STATEMENTS: na - - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // DERIVED TYPE DEFINITIONS - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int HeatRecInletNode; int HeatRecOutletNode; if (CTGenerator(Num).HeatRecActive) { HeatRecInletNode = CTGenerator(Num).HeatRecInletNodeNum; HeatRecOutletNode = CTGenerator(Num).HeatRecOutletNodeNum; - - // Node(HeatRecOutletNode)%MassFlowRate = CTGenerator(Num)%HeatRecMdot Node(HeatRecOutletNode).Temp = CTGenerator(Num).HeatRecOutletTemp; - // Node(HeatRecOutletNode)%MassFlowRateMaxAvail = Node(HeatRecInletNode)%MassFlowRateMaxAvail - // Node(HeatRecOutletNode)%MassFlowRateMinAvail = Node(HeatRecInletNode)%MassFlowRateMinAvail } CTGeneratorReport(Num).PowerGen = CTGenerator(Num).ElecPowerGenerated; CTGeneratorReport(Num).EnergyGen = CTGenerator(Num).ElecEnergyGenerated; @@ -1040,36 +971,12 @@ namespace CTElectricGenerator { // PURPOSE OF THIS SUBROUTINE: // get some results for load center's aggregation - // 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 = CTGeneratorReport(GeneratorIndex).PowerGen; GeneratorEnergy = CTGeneratorReport(GeneratorIndex).EnergyGen; ThermalPower = CTGeneratorReport(GeneratorIndex).QTotalHeatRecovered; ThermalEnergy = CTGeneratorReport(GeneratorIndex).TotalHeatEnergyRec; } - // End of Record Keeping subroutines for the CT Generator Module - // ***************************************************************************** - } // namespace CTElectricGenerator } // namespace EnergyPlus From f40afa319c67a5dfe993eab2d7674817d1d0609b Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Tue, 15 Oct 2019 14:39:41 -0600 Subject: [PATCH 02/13] cleanup usings --- src/EnergyPlus/CTElectricGenerator.cc | 137 ++++++++++---------------- 1 file changed, 53 insertions(+), 84 deletions(-) diff --git a/src/EnergyPlus/CTElectricGenerator.cc b/src/EnergyPlus/CTElectricGenerator.cc index 436e45e2c57..432070dd86e 100644 --- a/src/EnergyPlus/CTElectricGenerator.cc +++ b/src/EnergyPlus/CTElectricGenerator.cc @@ -61,7 +61,6 @@ #include #include #include -#include #include #include #include @@ -96,13 +95,6 @@ namespace CTElectricGenerator { // All CT Generator models are based on a polynomial fit of Generator // performance data. - using namespace DataPrecisionGlobals; - using namespace DataLoopNode; - using DataGlobalConstants::iGeneratorCombTurbine; - using DataGlobals::BeginEnvrnFlag; - using DataGlobals::NumOfTimeStepInHour; - using DataGlobals::SecInHour; - int NumCTGenerators(0); // number of CT Generators specified in input bool GetCTInput(true); // then TRUE, calls subroutine to read input file. @@ -128,8 +120,6 @@ namespace CTElectricGenerator { // 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 @@ -146,12 +136,12 @@ namespace CTElectricGenerator { } else { GenNum = GeneratorIndex; if (GenNum > NumCTGenerators || GenNum < 1) { - ShowFatalError("SimCTGenerator: Invalid GeneratorIndex passed=" + TrimSigDigits(GenNum) + - ", Number of CT Engine Generators=" + TrimSigDigits(NumCTGenerators) + ", Generator name=" + GeneratorName); + ShowFatalError("SimCTGenerator: Invalid GeneratorIndex passed=" + General::TrimSigDigits(GenNum) + + ", Number of CT Engine Generators=" + General::TrimSigDigits(NumCTGenerators) + ", Generator name=" + GeneratorName); } if (CheckEquipName(GenNum)) { if (GeneratorName != CTGenerator(GenNum).Name) { - ShowFatalError("SimCTGenerator: Invalid GeneratorIndex passed=" + TrimSigDigits(GenNum) + ", Generator name=" + GeneratorName + + ShowFatalError("SimCTGenerator: Invalid GeneratorIndex passed=" + General::TrimSigDigits(GenNum) + ", Generator name=" + GeneratorName + ", stored Generator Name for that index=" + CTGenerator(GenNum).Name); } CheckEquipName(GenNum) = false; @@ -221,12 +211,6 @@ namespace CTElectricGenerator { // required by the CT Generator models. using namespace DataIPShortCuts; // Data for field names, blank numerics - using BranchNodeConnections::TestCompSet; - using CurveManager::GetCurveIndex; - using General::RoundSigDigits; - using NodeInputManager::GetOnlySingleNode; - using OutAirNodeManager::CheckOutAirNodeNumber; - using PlantUtilities::RegisterPlantCompDesignFlow; int GeneratorNum; // Generator counter int NumAlphas; // Number of elements in the alpha array @@ -269,14 +253,14 @@ namespace CTElectricGenerator { CTGenerator(GeneratorNum).RatedPowerOutput = NumArray(1); if (NumArray(1) == 0.0) { - ShowSevereError("Invalid " + cNumericFieldNames(1) + '=' + RoundSigDigits(NumArray(1), 2)); + ShowSevereError("Invalid " + cNumericFieldNames(1) + '=' + General::RoundSigDigits(NumArray(1), 2)); ShowContinueError("Entered in " + cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } // Not sure what to do with electric nodes, so do not use optional arguments - CTGenerator(GeneratorNum).ElectricCircuitNode = GetOnlySingleNode( - AlphArray(2), ErrorsFound, cCurrentModuleObject, AlphArray(1), NodeType_Electric, NodeConnectionType_Electric, 1, ObjectIsNotParent); + CTGenerator(GeneratorNum).ElectricCircuitNode = NodeInputManager::GetOnlySingleNode( + AlphArray(2), ErrorsFound, cCurrentModuleObject, AlphArray(1), DataLoopNode::NodeType_Electric, DataLoopNode::NodeConnectionType_Electric, 1, DataLoopNode::ObjectIsNotParent); CTGenerator(GeneratorNum).MinPartLoadRat = NumArray(2); CTGenerator(GeneratorNum).MaxPartLoadRat = NumArray(3); @@ -284,42 +268,42 @@ namespace CTElectricGenerator { // Load Special CT Generator Input - CTGenerator(GeneratorNum).PLBasedFuelInputCurve = GetCurveIndex(AlphArray(3)); // convert curve name to number + CTGenerator(GeneratorNum).PLBasedFuelInputCurve = CurveManager::GetCurveIndex(AlphArray(3)); // convert curve name to number if (CTGenerator(GeneratorNum).PLBasedFuelInputCurve == 0) { ShowSevereError("Invalid " + cAlphaFieldNames(3) + '=' + AlphArray(3)); ShowContinueError("Entered in " + cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } - CTGenerator(GeneratorNum).TempBasedFuelInputCurve = GetCurveIndex(AlphArray(4)); // convert curve name to number + CTGenerator(GeneratorNum).TempBasedFuelInputCurve = CurveManager::GetCurveIndex(AlphArray(4)); // convert curve name to number if (CTGenerator(GeneratorNum).TempBasedFuelInputCurve == 0) { ShowSevereError("Invalid " + cAlphaFieldNames(4) + '=' + AlphArray(4)); ShowContinueError("Entered in " + cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } - CTGenerator(GeneratorNum).ExhaustFlowCurve = GetCurveIndex(AlphArray(5)); // convert curve name to number + CTGenerator(GeneratorNum).ExhaustFlowCurve = CurveManager::GetCurveIndex(AlphArray(5)); // convert curve name to number if (CTGenerator(GeneratorNum).ExhaustFlowCurve == 0) { ShowSevereError("Invalid " + cAlphaFieldNames(5) + '=' + AlphArray(5)); ShowContinueError("Entered in " + cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } - CTGenerator(GeneratorNum).PLBasedExhaustTempCurve = GetCurveIndex(AlphArray(6)); // convert curve name to number + CTGenerator(GeneratorNum).PLBasedExhaustTempCurve = CurveManager::GetCurveIndex(AlphArray(6)); // convert curve name to number if (CTGenerator(GeneratorNum).PLBasedExhaustTempCurve == 0) { ShowSevereError("Invalid " + cAlphaFieldNames(6) + '=' + AlphArray(6)); ShowContinueError("Entered in " + cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } - CTGenerator(GeneratorNum).TempBasedExhaustTempCurve = GetCurveIndex(AlphArray(7)); // convert curve name to number + CTGenerator(GeneratorNum).TempBasedExhaustTempCurve = CurveManager::GetCurveIndex(AlphArray(7)); // convert curve name to number if (CTGenerator(GeneratorNum).TempBasedExhaustTempCurve == 0) { ShowSevereError("Invalid " + cAlphaFieldNames(7) + '=' + AlphArray(7)); ShowContinueError("Entered in " + cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } - CTGenerator(GeneratorNum).QLubeOilRecoveredCurve = GetCurveIndex(AlphArray(8)); // convert curve name to number + CTGenerator(GeneratorNum).QLubeOilRecoveredCurve = CurveManager::GetCurveIndex(AlphArray(8)); // convert curve name to number if (CTGenerator(GeneratorNum).QLubeOilRecoveredCurve == 0) { ShowSevereError("Invalid " + cAlphaFieldNames(8) + '=' + AlphArray(8)); ShowContinueError("Entered in " + cCurrentModuleObject + '=' + AlphArray(1)); @@ -337,20 +321,20 @@ namespace CTElectricGenerator { if (CTGenerator(GeneratorNum).DesignHeatRecVolFlowRate > 0.0) { CTGenerator(GeneratorNum).HeatRecActive = true; - CTGenerator(GeneratorNum).HeatRecInletNodeNum = GetOnlySingleNode( - AlphArray(9), ErrorsFound, cCurrentModuleObject, AlphArray(1), NodeType_Water, NodeConnectionType_Inlet, 1, ObjectIsNotParent); + CTGenerator(GeneratorNum).HeatRecInletNodeNum = NodeInputManager::GetOnlySingleNode( + AlphArray(9), ErrorsFound, cCurrentModuleObject, AlphArray(1), DataLoopNode::NodeType_Water, DataLoopNode::NodeConnectionType_Inlet, 1, DataLoopNode::ObjectIsNotParent); if (CTGenerator(GeneratorNum).HeatRecInletNodeNum == 0) { ShowSevereError("Missing Node Name, Heat Recovery Inlet, for " + cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } - CTGenerator(GeneratorNum).HeatRecOutletNodeNum = GetOnlySingleNode( - AlphArray(10), ErrorsFound, cCurrentModuleObject, AlphArray(1), NodeType_Water, NodeConnectionType_Outlet, 1, ObjectIsNotParent); + CTGenerator(GeneratorNum).HeatRecOutletNodeNum = NodeInputManager::GetOnlySingleNode( + AlphArray(10), ErrorsFound, cCurrentModuleObject, AlphArray(1), DataLoopNode::NodeType_Water, DataLoopNode::NodeConnectionType_Outlet, 1, DataLoopNode::ObjectIsNotParent); if (CTGenerator(GeneratorNum).HeatRecOutletNodeNum == 0) { ShowSevereError("Missing Node Name, Heat Recovery Outlet, for " + cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } - TestCompSet(cCurrentModuleObject, AlphArray(1), AlphArray(9), AlphArray(10), "Heat Recovery Nodes"); - RegisterPlantCompDesignFlow(CTGenerator(GeneratorNum).HeatRecInletNodeNum, CTGenerator(GeneratorNum).DesignHeatRecVolFlowRate); + BranchNodeConnections::TestCompSet(cCurrentModuleObject, AlphArray(1), AlphArray(9), AlphArray(10), "Heat Recovery Nodes"); + PlantUtilities::RegisterPlantCompDesignFlow(CTGenerator(GeneratorNum).HeatRecInletNodeNum, CTGenerator(GeneratorNum).DesignHeatRecVolFlowRate); } else { CTGenerator(GeneratorNum).HeatRecActive = false; CTGenerator(GeneratorNum).HeatRecInletNodeNum = 0; @@ -406,15 +390,15 @@ namespace CTElectricGenerator { if (lAlphaFieldBlanks(12)) { CTGenerator(GeneratorNum).OAInletNode = 0; } else { - CTGenerator(GeneratorNum).OAInletNode = GetOnlySingleNode(AlphArray(12), + CTGenerator(GeneratorNum).OAInletNode = NodeInputManager::GetOnlySingleNode(AlphArray(12), ErrorsFound, cCurrentModuleObject, AlphArray(1), - NodeType_Air, - NodeConnectionType_OutsideAirReference, + DataLoopNode::NodeType_Air, + DataLoopNode::NodeConnectionType_OutsideAirReference, 1, - ObjectIsNotParent); - if (!CheckOutAirNodeNumber(CTGenerator(GeneratorNum).OAInletNode)) { + DataLoopNode::ObjectIsNotParent); + if (!OutAirNodeManager::CheckOutAirNodeNumber(CTGenerator(GeneratorNum).OAInletNode)) { ShowSevereError(cCurrentModuleObject + ", \"" + CTGenerator(GeneratorNum).Name + "\" Outdoor Air Inlet Node Name not valid Outdoor Air Node= " + AlphArray(12)); ShowContinueError("...does not appear in an OutdoorAir:NodeList or as an OutdoorAir:Node."); @@ -582,12 +566,6 @@ namespace CTElectricGenerator { // curve fit of performance data. This model was originally // developed by Dale Herron for the BLAST program - using CurveManager::CurveValue; - using DataEnvironment::OutDryBulbTemp; - using DataHVACGlobals::TimeStepSys; - using DataPlant::PlantLoop; - using FluidProperties::GetSpecificHeatGlycol; - Real64 const ExhaustCP(1.047); // Exhaust Gas Specific Heat (J/kg-K) Real64 const KJtoJ(1000.0); // convert Kjoules to joules static std::string const RoutineName("CalcCTGeneratorModel"); @@ -631,16 +609,16 @@ namespace CTElectricGenerator { DesignAirInletTemp = CTGenerator(GeneratorNum).DesignAirInletTemp; if (CTGenerator(GeneratorNum).HeatRecActive) { HeatRecInNode = CTGenerator(GeneratorNum).HeatRecInletNodeNum; - HeatRecInTemp = Node(HeatRecInNode).Temp; + HeatRecInTemp = DataLoopNode::Node(HeatRecInNode).Temp; - HeatRecCp = GetSpecificHeatGlycol(PlantLoop(CTGenerator(GeneratorNum).HRLoopNum).FluidName, + HeatRecCp = FluidProperties::GetSpecificHeatGlycol(DataPlant::PlantLoop(CTGenerator(GeneratorNum).HRLoopNum).FluidName, HeatRecInTemp, - PlantLoop(CTGenerator(GeneratorNum).HRLoopNum).FluidIndex, + DataPlant::PlantLoop(CTGenerator(GeneratorNum).HRLoopNum).FluidIndex, RoutineName); if (FirstHVACIteration && RunFlag) { HeatRecMdot = CTGenerator(GeneratorNum).DesignHeatRecMassFlowRate; } else { - HeatRecMdot = Node(HeatRecInNode).MassFlowRate; + HeatRecMdot = DataLoopNode::Node(HeatRecInNode).MassFlowRate; } } else { HeatRecInTemp = 0.0; @@ -678,30 +656,30 @@ namespace CTElectricGenerator { // SET OFF-DESIGN AIR TEMPERATURE DIFFERENCE // use OA node if set by user CR7021 if (CTGenerator(GeneratorNum).OAInletNode == 0) { - AmbientDeltaT = OutDryBulbTemp - DesignAirInletTemp; + AmbientDeltaT = DataEnvironment::OutDryBulbTemp - DesignAirInletTemp; } else { - AmbientDeltaT = Node(CTGenerator(GeneratorNum).OAInletNode).Temp - DesignAirInletTemp; + AmbientDeltaT = DataLoopNode::Node(CTGenerator(GeneratorNum).OAInletNode).Temp - DesignAirInletTemp; } // Use Curve fit to determine Fuel Energy Input. For electric power generated in Watts, the fuel // energy input is calculated in J/s. The PLBasedFuelInputCurve selects ratio of fuel flow (J/s)/power generated (J/s). // The TempBasedFuelInputCurve is a correction based on deviation from design inlet air temperature conditions. // The first coefficient of this fit should be 1.0 to ensure that no correction is made at design conditions. - FuelUseRate = ElecPowerGenerated * CurveValue(CTGenerator(GeneratorNum).PLBasedFuelInputCurve, PLR) * - CurveValue(CTGenerator(GeneratorNum).TempBasedFuelInputCurve, AmbientDeltaT); + FuelUseRate = ElecPowerGenerated * CurveManager::CurveValue(CTGenerator(GeneratorNum).PLBasedFuelInputCurve, PLR) * + CurveManager::CurveValue(CTGenerator(GeneratorNum).TempBasedFuelInputCurve, AmbientDeltaT); // Use Curve fit to determine Exhaust Flow. This curve shows the ratio of exhaust gas flow (kg/s) to electric power // output (J/s). The units on ExhaustFlowCurve are (kg/J). When multiplied by the rated power of the unit, // it gives the exhaust flow rate in kg/s - ExhaustFlow = RatedPowerOutput * CurveValue(CTGenerator(GeneratorNum).ExhaustFlowCurve, AmbientDeltaT); + ExhaustFlow = RatedPowerOutput * CurveManager::CurveValue(CTGenerator(GeneratorNum).ExhaustFlowCurve, AmbientDeltaT); // Use Curve fit to determine Exhaust Temperature. This curve calculates the exhaust temperature (C) by // multiplying the exhaust temperature (C) for a particular part load as given by PLBasedExhaustTempCurve // a correction factor based on the deviation from design temperature, TempBasedExhaustTempCurve if ((PLR > 0.0) && ((ExhaustFlow > 0.0) || (MaxExhaustperCTPower > 0.0))) { - ExhaustTemp = CurveValue(CTGenerator(GeneratorNum).PLBasedExhaustTempCurve, PLR) * - CurveValue(CTGenerator(GeneratorNum).TempBasedExhaustTempCurve, AmbientDeltaT); + ExhaustTemp = CurveManager::CurveValue(CTGenerator(GeneratorNum).PLBasedExhaustTempCurve, PLR) * + CurveManager::CurveValue(CTGenerator(GeneratorNum).TempBasedExhaustTempCurve, AmbientDeltaT); UA = CTGenerator(GeneratorNum).UACoef(1) * std::pow(RatedPowerOutput, CTGenerator(GeneratorNum).UACoef(2)); @@ -718,7 +696,7 @@ namespace CTElectricGenerator { // Use Curve fit to determine Heat Recovered Lubricant heat. This curve calculates the lube heat recovered (J/s) by // multiplying the total power generated by the fraction of that power that could be recovered in the lube oil at that // particular part load. - QLubeOilRec = ElecPowerGenerated * CurveValue(CTGenerator(GeneratorNum).QLubeOilRecoveredCurve, PLR); + QLubeOilRec = ElecPowerGenerated * CurveManager::CurveValue(CTGenerator(GeneratorNum).QLubeOilRecoveredCurve, PLR); // Check for divide by zero if ((HeatRecMdot > 0.0) && (HeatRecCp > 0.0)) { @@ -752,10 +730,10 @@ namespace CTElectricGenerator { } // Calculate Energy - ElectricEnergyGen = ElecPowerGenerated * TimeStepSys * SecInHour; - FuelEnergyUsed = FuelUseRate * TimeStepSys * SecInHour; - LubeOilEnergyRec = QLubeOilRec * TimeStepSys * SecInHour; - ExhaustEnergyRec = QExhaustRec * TimeStepSys * SecInHour; + ElectricEnergyGen = ElecPowerGenerated * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + FuelEnergyUsed = FuelUseRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + LubeOilEnergyRec = QLubeOilRec * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + ExhaustEnergyRec = QExhaustRec * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; CTGenerator(GeneratorNum).ElecPowerGenerated = ElecPowerGenerated; CTGenerator(GeneratorNum).ElecEnergyGenerated = ElectricEnergyGen; @@ -795,13 +773,6 @@ namespace CTElectricGenerator { // PURPOSE OF THIS SUBROUTINE: // This subroutine is for initializations of the CT generators. - using DataPlant::PlantLoop; - using DataPlant::TypeOf_Generator_CTurbine; - using FluidProperties::GetDensityGlycol; - using PlantUtilities::InitComponentNodes; - using PlantUtilities::ScanPlantLoopsForObject; - using PlantUtilities::SetComponentFlowRate; - static std::string const RoutineName("InitICEngineGenerators"); int HeatRecInletNode; // inlet node number in heat recovery loop @@ -826,10 +797,10 @@ namespace CTElectricGenerator { MySizeAndNodeInitFlag = true; } - if (MyPlantScanFlag(GeneratorNum) && allocated(PlantLoop) && CTGenerator(GeneratorNum).HeatRecActive) { + if (MyPlantScanFlag(GeneratorNum) && allocated(DataPlant::PlantLoop) && CTGenerator(GeneratorNum).HeatRecActive) { errFlag = false; - ScanPlantLoopsForObject(CTGenerator(GeneratorNum).Name, - TypeOf_Generator_CTurbine, + PlantUtilities::ScanPlantLoopsForObject(CTGenerator(GeneratorNum).Name, + DataPlant::TypeOf_Generator_CTurbine, CTGenerator(GeneratorNum).HRLoopNum, CTGenerator(GeneratorNum).HRLoopSideNum, CTGenerator(GeneratorNum).HRBranchNum, @@ -851,14 +822,14 @@ namespace CTElectricGenerator { HeatRecOutletNode = CTGenerator(GeneratorNum).HeatRecOutletNodeNum; // size mass flow rate - rho = GetDensityGlycol(PlantLoop(CTGenerator(GeneratorNum).HRLoopNum).FluidName, + rho = FluidProperties::GetDensityGlycol(DataPlant::PlantLoop(CTGenerator(GeneratorNum).HRLoopNum).FluidName, DataGlobals::InitConvTemp, - PlantLoop(CTGenerator(GeneratorNum).HRLoopNum).FluidIndex, + DataPlant::PlantLoop(CTGenerator(GeneratorNum).HRLoopNum).FluidIndex, RoutineName); CTGenerator(GeneratorNum).DesignHeatRecMassFlowRate = rho * CTGenerator(GeneratorNum).DesignHeatRecVolFlowRate; - InitComponentNodes(0.0, + PlantUtilities::InitComponentNodes(0.0, CTGenerator(GeneratorNum).DesignHeatRecMassFlowRate, HeatRecInletNode, HeatRecOutletNode, @@ -871,14 +842,14 @@ namespace CTElectricGenerator { } // end one time inits // Do the Begin Environment initializations - if (BeginEnvrnFlag && MyEnvrnFlag(GeneratorNum) && CTGenerator(GeneratorNum).HeatRecActive) { + if (DataGlobals::BeginEnvrnFlag && MyEnvrnFlag(GeneratorNum) && CTGenerator(GeneratorNum).HeatRecActive) { HeatRecInletNode = CTGenerator(GeneratorNum).HeatRecInletNodeNum; HeatRecOutletNode = CTGenerator(GeneratorNum).HeatRecOutletNodeNum; // set the node Temperature, assuming freeze control - Node(HeatRecInletNode).Temp = 20.0; - Node(HeatRecOutletNode).Temp = 20.0; + DataLoopNode::Node(HeatRecInletNode).Temp = 20.0; + DataLoopNode::Node(HeatRecOutletNode).Temp = 20.0; // set the node max and min mass flow rates - InitComponentNodes(0.0, + PlantUtilities::InitComponentNodes(0.0, CTGenerator(GeneratorNum).DesignHeatRecMassFlowRate, HeatRecInletNode, HeatRecOutletNode, @@ -890,7 +861,7 @@ namespace CTElectricGenerator { MyEnvrnFlag(GeneratorNum) = false; } // end environmental inits - if (!BeginEnvrnFlag) { + if (!DataGlobals::BeginEnvrnFlag) { MyEnvrnFlag(GeneratorNum) = true; } @@ -901,7 +872,7 @@ namespace CTElectricGenerator { } else { mdot = 0.0; } - SetComponentFlowRate(mdot, + PlantUtilities::SetComponentFlowRate(mdot, CTGenerator(GeneratorNum).HeatRecInletNodeNum, CTGenerator(GeneratorNum).HeatRecOutletNodeNum, CTGenerator(GeneratorNum).HRLoopNum, @@ -910,7 +881,7 @@ namespace CTElectricGenerator { CTGenerator(GeneratorNum).HRCompNum); } else { - SetComponentFlowRate(CTGenerator(GeneratorNum).HeatRecMdot, + PlantUtilities::SetComponentFlowRate(CTGenerator(GeneratorNum).HeatRecMdot, CTGenerator(GeneratorNum).HeatRecInletNodeNum, CTGenerator(GeneratorNum).HeatRecOutletNodeNum, CTGenerator(GeneratorNum).HRLoopNum, @@ -929,13 +900,11 @@ namespace CTElectricGenerator { // AUTHOR: Dan Fisher // DATE WRITTEN: October 1998 - int HeatRecInletNode; int HeatRecOutletNode; if (CTGenerator(Num).HeatRecActive) { - HeatRecInletNode = CTGenerator(Num).HeatRecInletNodeNum; HeatRecOutletNode = CTGenerator(Num).HeatRecOutletNodeNum; - Node(HeatRecOutletNode).Temp = CTGenerator(Num).HeatRecOutletTemp; + DataLoopNode::Node(HeatRecOutletNode).Temp = CTGenerator(Num).HeatRecOutletTemp; } CTGeneratorReport(Num).PowerGen = CTGenerator(Num).ElecPowerGenerated; CTGeneratorReport(Num).EnergyGen = CTGenerator(Num).ElecEnergyGenerated; From fbc768576a3725e3146b5e4e2544e638c0577314 Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Tue, 15 Oct 2019 14:46:57 -0600 Subject: [PATCH 03/13] cleanup warnings --- src/EnergyPlus/CTElectricGenerator.hh | 38 +++++++++++++-------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/EnergyPlus/CTElectricGenerator.hh b/src/EnergyPlus/CTElectricGenerator.hh index 1730b79468a..87780335862 100644 --- a/src/EnergyPlus/CTElectricGenerator.hh +++ b/src/EnergyPlus/CTElectricGenerator.hh @@ -185,24 +185,24 @@ namespace CTElectricGenerator { // Functions - void SimCTGenerator(int const GeneratorType, // type of Generator + void SimCTGenerator(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, // generator demand - bool const FirstHVACIteration); + bool RunFlag, // simulate Generator when TRUE + Real64 MyLoad, // generator demand + bool FirstHVACIteration); void SimCTPlantHeatRecovery(std::string const &CompType, // unused1208 std::string const &CompName, - int const CompTypeNum, // unused1208 + int CompTypeNum, // unused1208 int &CompNum, - bool const RunFlag, + bool RunFlag, bool &InitLoopEquip, Real64 &MyLoad, Real64 &MaxCap, Real64 &MinCap, Real64 &OptCap, - bool const FirstHVACIteration // TRUE if First iteration of simulation + bool FirstHVACIteration // TRUE if First iteration of simulation ); // End CT Generator Module Driver Subroutines @@ -219,10 +219,10 @@ namespace CTElectricGenerator { // Beginning of Generator model Subroutines // ***************************************************************************** - void CalcCTGeneratorModel(int const GeneratorNum, // Generator number - bool const RunFlag, // TRUE when Generator operating - Real64 const MyLoad, // Generator demand - bool const FirstHVACIteration); + void CalcCTGeneratorModel(int GeneratorNum, // Generator number + bool RunFlag, // TRUE when Generator operating + Real64 MyLoad, // Generator demand + bool FirstHVACIteration); // End of CT Generator Module Model Subroutines // ***************************************************************************** @@ -230,10 +230,10 @@ namespace CTElectricGenerator { // Begin CT Generator Module Utility Subroutines // ***************************************************************************** - void InitCTGenerators(int const GeneratorNum, // Generator number - bool const RunFlag, // TRUE when Generator operating - Real64 const MyLoad, // Generator demand - bool const FirstHVACIteration); + void InitCTGenerators(int GeneratorNum, // Generator number + bool RunFlag, // TRUE when Generator operating + Real64 MyLoad, // Generator demand + bool FirstHVACIteration); // End CT Generator Module Utility Subroutines // ***************************************************************************** @@ -241,12 +241,12 @@ namespace CTElectricGenerator { // Beginning of Record Keeping subroutines for the CT Generator Module // ***************************************************************************** - void UpdateCTGeneratorRecords(bool const RunFlag, // TRUE if Generator operating - int const Num // Generator number + void UpdateCTGeneratorRecords(bool RunFlag, // TRUE if Generator operating + int Num // Generator number ); - void GetCTGeneratorResults(int const GeneratorType, // type of Generator - int const GeneratorIndex, + void GetCTGeneratorResults(int GeneratorType, // type of Generator + int GeneratorIndex, Real64 &GeneratorPower, // electrical power Real64 &GeneratorEnergy, // electrical energy Real64 &ThermalPower, // heat power From 86edcb262660b4c0bf464ff33c3069d351c6eeff Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Tue, 15 Oct 2019 15:14:34 -0600 Subject: [PATCH 04/13] cleanup statics --- src/EnergyPlus/CTElectricGenerator.cc | 97 ++++++++++++--------------- src/EnergyPlus/CTElectricGenerator.hh | 51 ++------------ 2 files changed, 50 insertions(+), 98 deletions(-) diff --git a/src/EnergyPlus/CTElectricGenerator.cc b/src/EnergyPlus/CTElectricGenerator.cc index 432070dd86e..385c53c69e7 100644 --- a/src/EnergyPlus/CTElectricGenerator.cc +++ b/src/EnergyPlus/CTElectricGenerator.cc @@ -210,8 +210,6 @@ namespace CTElectricGenerator { // This routine will get the input // required by the CT Generator models. - using namespace DataIPShortCuts; // Data for field names, blank numerics - int GeneratorNum; // Generator counter int NumAlphas; // Number of elements in the alpha array int NumNums; // Number of elements in the numeric array @@ -220,11 +218,11 @@ namespace CTElectricGenerator { Array1D NumArray(12); // numeric data static bool ErrorsFound(false); // error flag - cCurrentModuleObject = "Generator:CombustionTurbine"; - NumCTGenerators = inputProcessor->getNumObjectsFound(cCurrentModuleObject); + DataIPShortCuts::cCurrentModuleObject = "Generator:CombustionTurbine"; + NumCTGenerators = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject); if (NumCTGenerators <= 0) { - ShowSevereError("No " + cCurrentModuleObject + " equipment specified in input file"); + ShowSevereError("No " + DataIPShortCuts::cCurrentModuleObject + " equipment specified in input file"); ErrorsFound = true; } @@ -236,7 +234,7 @@ namespace CTElectricGenerator { // LOAD ARRAYS WITH CT CURVE FIT Generator DATA for (GeneratorNum = 1; GeneratorNum <= NumCTGenerators; ++GeneratorNum) { - inputProcessor->getObjectItem(cCurrentModuleObject, + inputProcessor->getObjectItem(DataIPShortCuts::cCurrentModuleObject, GeneratorNum, AlphArray, NumAlphas, @@ -244,23 +242,23 @@ namespace CTElectricGenerator { NumNums, IOStat, _, - lAlphaFieldBlanks, - cAlphaFieldNames, - cNumericFieldNames); - UtilityRoutines::IsNameEmpty(AlphArray(1), cCurrentModuleObject, ErrorsFound); + DataIPShortCuts::lAlphaFieldBlanks, + DataIPShortCuts::cAlphaFieldNames, + DataIPShortCuts::cNumericFieldNames); + UtilityRoutines::IsNameEmpty(AlphArray(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); CTGenerator(GeneratorNum).Name = AlphArray(1); CTGenerator(GeneratorNum).RatedPowerOutput = NumArray(1); if (NumArray(1) == 0.0) { - ShowSevereError("Invalid " + cNumericFieldNames(1) + '=' + General::RoundSigDigits(NumArray(1), 2)); - ShowContinueError("Entered in " + cCurrentModuleObject + '=' + AlphArray(1)); + ShowSevereError("Invalid " + DataIPShortCuts::cNumericFieldNames(1) + '=' + General::RoundSigDigits(NumArray(1), 2)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } // Not sure what to do with electric nodes, so do not use optional arguments CTGenerator(GeneratorNum).ElectricCircuitNode = NodeInputManager::GetOnlySingleNode( - AlphArray(2), ErrorsFound, cCurrentModuleObject, AlphArray(1), DataLoopNode::NodeType_Electric, DataLoopNode::NodeConnectionType_Electric, 1, DataLoopNode::ObjectIsNotParent); + AlphArray(2), ErrorsFound, DataIPShortCuts::cCurrentModuleObject, AlphArray(1), DataLoopNode::NodeType_Electric, DataLoopNode::NodeConnectionType_Electric, 1, DataLoopNode::ObjectIsNotParent); CTGenerator(GeneratorNum).MinPartLoadRat = NumArray(2); CTGenerator(GeneratorNum).MaxPartLoadRat = NumArray(3); @@ -270,43 +268,43 @@ namespace CTElectricGenerator { CTGenerator(GeneratorNum).PLBasedFuelInputCurve = CurveManager::GetCurveIndex(AlphArray(3)); // convert curve name to number if (CTGenerator(GeneratorNum).PLBasedFuelInputCurve == 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; } CTGenerator(GeneratorNum).TempBasedFuelInputCurve = CurveManager::GetCurveIndex(AlphArray(4)); // convert curve name to number if (CTGenerator(GeneratorNum).TempBasedFuelInputCurve == 0) { - 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; } CTGenerator(GeneratorNum).ExhaustFlowCurve = CurveManager::GetCurveIndex(AlphArray(5)); // convert curve name to number if (CTGenerator(GeneratorNum).ExhaustFlowCurve == 0) { - 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; } CTGenerator(GeneratorNum).PLBasedExhaustTempCurve = CurveManager::GetCurveIndex(AlphArray(6)); // convert curve name to number if (CTGenerator(GeneratorNum).PLBasedExhaustTempCurve == 0) { - 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; } CTGenerator(GeneratorNum).TempBasedExhaustTempCurve = CurveManager::GetCurveIndex(AlphArray(7)); // convert curve name to number if (CTGenerator(GeneratorNum).TempBasedExhaustTempCurve == 0) { - 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; } CTGenerator(GeneratorNum).QLubeOilRecoveredCurve = CurveManager::GetCurveIndex(AlphArray(8)); // convert curve name to number if (CTGenerator(GeneratorNum).QLubeOilRecoveredCurve == 0) { - 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; } @@ -322,25 +320,25 @@ namespace CTElectricGenerator { if (CTGenerator(GeneratorNum).DesignHeatRecVolFlowRate > 0.0) { CTGenerator(GeneratorNum).HeatRecActive = true; CTGenerator(GeneratorNum).HeatRecInletNodeNum = NodeInputManager::GetOnlySingleNode( - AlphArray(9), ErrorsFound, cCurrentModuleObject, AlphArray(1), DataLoopNode::NodeType_Water, DataLoopNode::NodeConnectionType_Inlet, 1, DataLoopNode::ObjectIsNotParent); + AlphArray(9), ErrorsFound, DataIPShortCuts::cCurrentModuleObject, AlphArray(1), DataLoopNode::NodeType_Water, DataLoopNode::NodeConnectionType_Inlet, 1, DataLoopNode::ObjectIsNotParent); if (CTGenerator(GeneratorNum).HeatRecInletNodeNum == 0) { - ShowSevereError("Missing Node Name, Heat Recovery Inlet, for " + cCurrentModuleObject + '=' + AlphArray(1)); + ShowSevereError("Missing Node Name, Heat Recovery Inlet, for " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } CTGenerator(GeneratorNum).HeatRecOutletNodeNum = NodeInputManager::GetOnlySingleNode( - AlphArray(10), ErrorsFound, cCurrentModuleObject, AlphArray(1), DataLoopNode::NodeType_Water, DataLoopNode::NodeConnectionType_Outlet, 1, DataLoopNode::ObjectIsNotParent); + AlphArray(10), ErrorsFound, DataIPShortCuts::cCurrentModuleObject, AlphArray(1), DataLoopNode::NodeType_Water, DataLoopNode::NodeConnectionType_Outlet, 1, DataLoopNode::ObjectIsNotParent); if (CTGenerator(GeneratorNum).HeatRecOutletNodeNum == 0) { - ShowSevereError("Missing Node Name, Heat Recovery Outlet, for " + cCurrentModuleObject + '=' + AlphArray(1)); + ShowSevereError("Missing Node Name, Heat Recovery Outlet, for " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } - BranchNodeConnections::TestCompSet(cCurrentModuleObject, AlphArray(1), AlphArray(9), AlphArray(10), "Heat Recovery Nodes"); + BranchNodeConnections::TestCompSet(DataIPShortCuts::cCurrentModuleObject, AlphArray(1), AlphArray(9), AlphArray(10), "Heat Recovery Nodes"); PlantUtilities::RegisterPlantCompDesignFlow(CTGenerator(GeneratorNum).HeatRecInletNodeNum, CTGenerator(GeneratorNum).DesignHeatRecVolFlowRate); } else { CTGenerator(GeneratorNum).HeatRecActive = false; CTGenerator(GeneratorNum).HeatRecInletNodeNum = 0; CTGenerator(GeneratorNum).HeatRecOutletNodeNum = 0; - if (!lAlphaFieldBlanks(9) || !lAlphaFieldBlanks(10)) { - ShowWarningError("Since Design Heat Flow Rate = 0.0, Heat Recovery inactive for " + cCurrentModuleObject + '=' + AlphArray(1)); + if (!DataIPShortCuts::lAlphaFieldBlanks(9) || !DataIPShortCuts::lAlphaFieldBlanks(10)) { + ShowWarningError("Since Design Heat Flow Rate = 0.0, Heat Recovery inactive for " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ShowContinueError("However, Node names were specified for Heat Recovery inlet or outlet nodes"); } } @@ -378,8 +376,8 @@ namespace CTElectricGenerator { CTGenerator(GeneratorNum).FuelType = "OtherFuel2"; } else { - ShowSevereError("Invalid " + cAlphaFieldNames(11) + '=' + AlphArray(11)); - ShowContinueError("Entered in " + cCurrentModuleObject + '=' + AlphArray(1)); + ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(11) + '=' + AlphArray(11)); + ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } } @@ -387,19 +385,19 @@ namespace CTElectricGenerator { CTGenerator(GeneratorNum).HeatRecMaxTemp = NumArray(12); // begin CR7021 - if (lAlphaFieldBlanks(12)) { + if (DataIPShortCuts::lAlphaFieldBlanks(12)) { CTGenerator(GeneratorNum).OAInletNode = 0; } else { CTGenerator(GeneratorNum).OAInletNode = NodeInputManager::GetOnlySingleNode(AlphArray(12), ErrorsFound, - cCurrentModuleObject, + DataIPShortCuts::cCurrentModuleObject, AlphArray(1), DataLoopNode::NodeType_Air, DataLoopNode::NodeConnectionType_OutsideAirReference, 1, DataLoopNode::ObjectIsNotParent); if (!OutAirNodeManager::CheckOutAirNodeNumber(CTGenerator(GeneratorNum).OAInletNode)) { - ShowSevereError(cCurrentModuleObject + ", \"" + CTGenerator(GeneratorNum).Name + + ShowSevereError(DataIPShortCuts::cCurrentModuleObject + ", \"" + CTGenerator(GeneratorNum).Name + "\" Outdoor Air Inlet Node Name not valid Outdoor Air Node= " + AlphArray(12)); ShowContinueError("...does not appear in an OutdoorAir:NodeList or as an OutdoorAir:Node."); ErrorsFound = true; @@ -408,7 +406,7 @@ namespace CTElectricGenerator { } if (ErrorsFound) { - ShowFatalError("Errors found in processing input for " + cCurrentModuleObject); + ShowFatalError("Errors found in processing input for " + DataIPShortCuts::cCurrentModuleObject); } for (GeneratorNum = 1; GeneratorNum <= NumCTGenerators; ++GeneratorNum) { @@ -779,25 +777,16 @@ namespace CTElectricGenerator { int HeatRecOutletNode; // outlet node number in heat recovery loop static bool MyOneTimeFlag(true); // Initialization flag - static Array1D_bool MyEnvrnFlag; // Used for initializations each begin environment flag - static Array1D_bool MyPlantScanFlag; - static Array1D_bool MySizeAndNodeInitFlag; Real64 mdot; Real64 rho; bool errFlag; // Do the one time initializations if (MyOneTimeFlag) { - MyEnvrnFlag.allocate(NumCTGenerators); - MyPlantScanFlag.allocate(NumCTGenerators); - MySizeAndNodeInitFlag.allocate(NumCTGenerators); - MyEnvrnFlag = true; - MyPlantScanFlag = true; MyOneTimeFlag = false; - MySizeAndNodeInitFlag = true; } - if (MyPlantScanFlag(GeneratorNum) && allocated(DataPlant::PlantLoop) && CTGenerator(GeneratorNum).HeatRecActive) { + if (CTGenerator(GeneratorNum).MyPlantScanFlag && allocated(DataPlant::PlantLoop) && CTGenerator(GeneratorNum).HeatRecActive) { errFlag = false; PlantUtilities::ScanPlantLoopsForObject(CTGenerator(GeneratorNum).Name, DataPlant::TypeOf_Generator_CTurbine, @@ -814,10 +803,10 @@ namespace CTElectricGenerator { if (errFlag) { ShowFatalError("InitCTGenerators: Program terminated due to previous condition(s)."); } - MyPlantScanFlag(GeneratorNum) = false; + CTGenerator(GeneratorNum).MyPlantScanFlag = false; } - if (MySizeAndNodeInitFlag(GeneratorNum) && (!MyPlantScanFlag(GeneratorNum)) && CTGenerator(GeneratorNum).HeatRecActive) { + if (CTGenerator(GeneratorNum).MySizeAndNodeInitFlag && (!CTGenerator(GeneratorNum).MyPlantScanFlag) && CTGenerator(GeneratorNum).HeatRecActive) { HeatRecInletNode = CTGenerator(GeneratorNum).HeatRecInletNodeNum; HeatRecOutletNode = CTGenerator(GeneratorNum).HeatRecOutletNodeNum; @@ -838,11 +827,11 @@ namespace CTElectricGenerator { CTGenerator(GeneratorNum).HRBranchNum, CTGenerator(GeneratorNum).HRCompNum); - MySizeAndNodeInitFlag(GeneratorNum) = false; + CTGenerator(GeneratorNum).MySizeAndNodeInitFlag = false; } // end one time inits // Do the Begin Environment initializations - if (DataGlobals::BeginEnvrnFlag && MyEnvrnFlag(GeneratorNum) && CTGenerator(GeneratorNum).HeatRecActive) { + if (DataGlobals::BeginEnvrnFlag && CTGenerator(GeneratorNum).MyEnvrnFlag && CTGenerator(GeneratorNum).HeatRecActive) { HeatRecInletNode = CTGenerator(GeneratorNum).HeatRecInletNodeNum; HeatRecOutletNode = CTGenerator(GeneratorNum).HeatRecOutletNodeNum; // set the node Temperature, assuming freeze control @@ -858,11 +847,11 @@ namespace CTElectricGenerator { CTGenerator(GeneratorNum).HRBranchNum, CTGenerator(GeneratorNum).HRCompNum); - MyEnvrnFlag(GeneratorNum) = false; + CTGenerator(GeneratorNum).MyEnvrnFlag = false; } // end environmental inits if (!DataGlobals::BeginEnvrnFlag) { - MyEnvrnFlag(GeneratorNum) = true; + CTGenerator(GeneratorNum).MyEnvrnFlag = true; } if (CTGenerator(GeneratorNum).HeatRecActive) { diff --git a/src/EnergyPlus/CTElectricGenerator.hh b/src/EnergyPlus/CTElectricGenerator.hh index 87780335862..240ffa80ac5 100644 --- a/src/EnergyPlus/CTElectricGenerator.hh +++ b/src/EnergyPlus/CTElectricGenerator.hh @@ -60,25 +60,13 @@ namespace EnergyPlus { namespace CTElectricGenerator { - // Using/Aliasing using DataGlobalConstants::iGeneratorCombTurbine; - // Data - // MODULE PARAMETER DEFINITIONS: - // na - - // DERIVED TYPE DEFINITIONS: - - // MODULE VARIABLE DECLARATIONS: extern int NumCTGenerators; // number of CT Generators specified in input extern bool GetCTInput; // then TRUE, calls subroutine to read input file. extern Array1D_bool CheckEquipName; - // SUBROUTINE SPECIFICATIONS FOR MODULE PrimaryPlantLoops - - // Types - struct CTGeneratorSpecs { // Members @@ -134,7 +122,10 @@ namespace CTElectricGenerator { Real64 ElecPowerGenerated; // reporting: power generated (W) Real64 ElecEnergyGenerated; // reporting: power generated (W) Real64 HeatRecMaxTemp; // Max Temp that can be produced in heat recovery - int OAInletNode; // optional inlet node index pointer for outdoor air for compustion + int OAInletNode; // optional inlet node index pointer for outdoor air for combustion + bool MyEnvrnFlag; + bool MyPlantScanFlag; + bool MySizeAndNodeInitFlag; // Default Constructor CTGeneratorSpecs() @@ -146,7 +137,8 @@ namespace CTElectricGenerator { DesignHeatRecVolFlowRate(0.0), DesignHeatRecMassFlowRate(0.0), DesignMinExitGasTemp(0.0), DesignAirInletTemp(0.0), ExhaustStackTemp(0.0), HeatRecActive(false), HeatRecInletNodeNum(0), HeatRecOutletNodeNum(0), HeatRecInletTemp(0.0), HeatRecOutletTemp(0.0), HeatRecMdot(0.0), HRLoopNum(0), HRLoopSideNum(0), HRBranchNum(0), HRCompNum(0), FuelMdot(0.0), - FuelHeatingValue(0.0), ElecPowerGenerated(0.0), ElecEnergyGenerated(0.0), HeatRecMaxTemp(0.0), OAInletNode(0) + FuelHeatingValue(0.0), ElecPowerGenerated(0.0), ElecEnergyGenerated(0.0), HeatRecMaxTemp(0.0), OAInletNode(0), MyEnvrnFlag(true), + MyPlantScanFlag(true), MySizeAndNodeInitFlag(true) { } }; @@ -183,8 +175,7 @@ namespace CTElectricGenerator { extern Array1D CTGenerator; // dimension to number of machines extern Array1D CTGeneratorReport; - // Functions - + // Static functions void SimCTGenerator(int GeneratorType, // type of Generator std::string const &GeneratorName, // user specified name of Generator int &GeneratorIndex, @@ -205,42 +196,18 @@ namespace CTElectricGenerator { bool FirstHVACIteration // TRUE if First iteration of simulation ); - // End CT Generator Module Driver Subroutines - //****************************************************************************** - - // Beginning of CT Generator Module Get Input subroutines - //****************************************************************************** - void GetCTGeneratorInput(); - // End of Get Input subroutines for the CT Generator Module - //****************************************************************************** - - // Beginning of Generator model Subroutines - // ***************************************************************************** - void CalcCTGeneratorModel(int GeneratorNum, // Generator number bool RunFlag, // TRUE when Generator operating Real64 MyLoad, // Generator demand bool FirstHVACIteration); - // End of CT Generator Module Model Subroutines - // ***************************************************************************** - - // Begin CT Generator Module Utility Subroutines - // ***************************************************************************** - void InitCTGenerators(int GeneratorNum, // Generator number bool RunFlag, // TRUE when Generator operating Real64 MyLoad, // Generator demand bool FirstHVACIteration); - // End CT Generator Module Utility Subroutines - // ***************************************************************************** - - // Beginning of Record Keeping subroutines for the CT Generator Module - // ***************************************************************************** - void UpdateCTGeneratorRecords(bool RunFlag, // TRUE if Generator operating int Num // Generator number ); @@ -252,10 +219,6 @@ namespace CTElectricGenerator { Real64 &ThermalPower, // heat power Real64 &ThermalEnergy // heat energy ); - - // End of Record Keeping subroutines for the CT Generator Module - // ***************************************************************************** - } // namespace CTElectricGenerator } // namespace EnergyPlus From d14de229f7f7feeb52fe47990bd6ad5de25e390b Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Tue, 15 Oct 2019 16:00:20 -0600 Subject: [PATCH 05/13] unify index names; partial integrate report vars struct --- src/EnergyPlus/CTElectricGenerator.cc | 479 +++++++++++++------------- src/EnergyPlus/CTElectricGenerator.hh | 17 +- 2 files changed, 246 insertions(+), 250 deletions(-) diff --git a/src/EnergyPlus/CTElectricGenerator.cc b/src/EnergyPlus/CTElectricGenerator.cc index 385c53c69e7..dd1f0732ca2 100644 --- a/src/EnergyPlus/CTElectricGenerator.cc +++ b/src/EnergyPlus/CTElectricGenerator.cc @@ -98,8 +98,6 @@ namespace CTElectricGenerator { int NumCTGenerators(0); // number of CT Generators specified in input bool GetCTInput(true); // then TRUE, calls subroutine to read input file. - Array1D_bool CheckEquipName; - Array1D CTGenerator; // dimension to number of machines Array1D CTGeneratorReport; @@ -120,7 +118,7 @@ namespace CTElectricGenerator { // gets the input for the models, initializes simulation variables, call // the appropriate model and sets up reporting variables. - int GenNum; // Generator number counter + int genNum; // Generator number counter // Get Generator data from input file if (GetCTInput) { @@ -130,27 +128,27 @@ namespace CTElectricGenerator { // SELECT and CALL MODELS if (GeneratorIndex == 0) { - GenNum = UtilityRoutines::FindItemInList(GeneratorName, CTGenerator); - if (GenNum == 0) ShowFatalError("SimCTGenerator: Specified Generator not one of Valid COMBUSTION Turbine Generators " + GeneratorName); - GeneratorIndex = GenNum; + genNum = UtilityRoutines::FindItemInList(GeneratorName, CTGenerator); + if (genNum == 0) ShowFatalError("SimCTGenerator: Specified Generator not one of Valid COMBUSTION Turbine Generators " + GeneratorName); + GeneratorIndex = genNum; } else { - GenNum = GeneratorIndex; - if (GenNum > NumCTGenerators || GenNum < 1) { - ShowFatalError("SimCTGenerator: Invalid GeneratorIndex passed=" + General::TrimSigDigits(GenNum) + + genNum = GeneratorIndex; + if (genNum > NumCTGenerators || genNum < 1) { + ShowFatalError("SimCTGenerator: Invalid GeneratorIndex passed=" + General::TrimSigDigits(genNum) + ", Number of CT Engine Generators=" + General::TrimSigDigits(NumCTGenerators) + ", Generator name=" + GeneratorName); } - if (CheckEquipName(GenNum)) { - if (GeneratorName != CTGenerator(GenNum).Name) { - ShowFatalError("SimCTGenerator: Invalid GeneratorIndex passed=" + General::TrimSigDigits(GenNum) + ", Generator name=" + GeneratorName + - ", stored Generator Name for that index=" + CTGenerator(GenNum).Name); + if (CTGenerator(genNum).CheckEquipName) { + if (GeneratorName != CTGenerator(genNum).Name) { + ShowFatalError("SimCTGenerator: Invalid GeneratorIndex passed=" + General::TrimSigDigits(genNum) + ", Generator name=" + GeneratorName + + ", stored Generator Name for that index=" + CTGenerator(genNum).Name); } - CheckEquipName(GenNum) = false; + CTGenerator(genNum).CheckEquipName = false; } } - InitCTGenerators(GenNum, RunFlag, MyLoad, FirstHVACIteration); - CalcCTGeneratorModel(GenNum, RunFlag, MyLoad, FirstHVACIteration); - UpdateCTGeneratorRecords(RunFlag, GenNum); + InitCTGenerators(genNum, RunFlag, MyLoad, FirstHVACIteration); + CalcCTGeneratorModel(genNum, RunFlag, MyLoad, FirstHVACIteration); + UpdateCTGeneratorRecords(RunFlag, genNum); } void SimCTPlantHeatRecovery(std::string const &EP_UNUSED(CompType), // unused1208 @@ -210,7 +208,7 @@ namespace CTElectricGenerator { // This routine will get the input // required by the CT Generator models. - int GeneratorNum; // Generator counter + int genNum; // 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 @@ -228,14 +226,13 @@ namespace CTElectricGenerator { // ALLOCATE ARRAYS CTGenerator.allocate(NumCTGenerators); - CheckEquipName.dimension(NumCTGenerators, true); CTGeneratorReport.allocate(NumCTGenerators); // LOAD ARRAYS WITH CT CURVE FIT Generator DATA - for (GeneratorNum = 1; GeneratorNum <= NumCTGenerators; ++GeneratorNum) { + for (genNum = 1; genNum <= NumCTGenerators; ++genNum) { inputProcessor->getObjectItem(DataIPShortCuts::cCurrentModuleObject, - GeneratorNum, + genNum, AlphArray, NumAlphas, NumArray, @@ -247,9 +244,9 @@ namespace CTElectricGenerator { DataIPShortCuts::cNumericFieldNames); UtilityRoutines::IsNameEmpty(AlphArray(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound); - CTGenerator(GeneratorNum).Name = AlphArray(1); + CTGenerator(genNum).Name = AlphArray(1); - CTGenerator(GeneratorNum).RatedPowerOutput = NumArray(1); + CTGenerator(genNum).RatedPowerOutput = NumArray(1); if (NumArray(1) == 0.0) { ShowSevereError("Invalid " + DataIPShortCuts::cNumericFieldNames(1) + '=' + General::RoundSigDigits(NumArray(1), 2)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); @@ -257,86 +254,86 @@ namespace CTElectricGenerator { } // Not sure what to do with electric nodes, so do not use optional arguments - CTGenerator(GeneratorNum).ElectricCircuitNode = NodeInputManager::GetOnlySingleNode( + CTGenerator(genNum).ElectricCircuitNode = NodeInputManager::GetOnlySingleNode( AlphArray(2), ErrorsFound, DataIPShortCuts::cCurrentModuleObject, AlphArray(1), DataLoopNode::NodeType_Electric, DataLoopNode::NodeConnectionType_Electric, 1, DataLoopNode::ObjectIsNotParent); - CTGenerator(GeneratorNum).MinPartLoadRat = NumArray(2); - CTGenerator(GeneratorNum).MaxPartLoadRat = NumArray(3); - CTGenerator(GeneratorNum).OptPartLoadRat = NumArray(4); + CTGenerator(genNum).MinPartLoadRat = NumArray(2); + CTGenerator(genNum).MaxPartLoadRat = NumArray(3); + CTGenerator(genNum).OptPartLoadRat = NumArray(4); // Load Special CT Generator Input - CTGenerator(GeneratorNum).PLBasedFuelInputCurve = CurveManager::GetCurveIndex(AlphArray(3)); // convert curve name to number - if (CTGenerator(GeneratorNum).PLBasedFuelInputCurve == 0) { + CTGenerator(genNum).PLBasedFuelInputCurve = CurveManager::GetCurveIndex(AlphArray(3)); // convert curve name to number + if (CTGenerator(genNum).PLBasedFuelInputCurve == 0) { ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(3) + '=' + AlphArray(3)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } - CTGenerator(GeneratorNum).TempBasedFuelInputCurve = CurveManager::GetCurveIndex(AlphArray(4)); // convert curve name to number - if (CTGenerator(GeneratorNum).TempBasedFuelInputCurve == 0) { + CTGenerator(genNum).TempBasedFuelInputCurve = CurveManager::GetCurveIndex(AlphArray(4)); // convert curve name to number + if (CTGenerator(genNum).TempBasedFuelInputCurve == 0) { ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(4) + '=' + AlphArray(4)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } - CTGenerator(GeneratorNum).ExhaustFlowCurve = CurveManager::GetCurveIndex(AlphArray(5)); // convert curve name to number - if (CTGenerator(GeneratorNum).ExhaustFlowCurve == 0) { + CTGenerator(genNum).ExhaustFlowCurve = CurveManager::GetCurveIndex(AlphArray(5)); // convert curve name to number + if (CTGenerator(genNum).ExhaustFlowCurve == 0) { ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(5) + '=' + AlphArray(5)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } - CTGenerator(GeneratorNum).PLBasedExhaustTempCurve = CurveManager::GetCurveIndex(AlphArray(6)); // convert curve name to number - if (CTGenerator(GeneratorNum).PLBasedExhaustTempCurve == 0) { + CTGenerator(genNum).PLBasedExhaustTempCurve = CurveManager::GetCurveIndex(AlphArray(6)); // convert curve name to number + if (CTGenerator(genNum).PLBasedExhaustTempCurve == 0) { ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(6) + '=' + AlphArray(6)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } - CTGenerator(GeneratorNum).TempBasedExhaustTempCurve = CurveManager::GetCurveIndex(AlphArray(7)); // convert curve name to number - if (CTGenerator(GeneratorNum).TempBasedExhaustTempCurve == 0) { + CTGenerator(genNum).TempBasedExhaustTempCurve = CurveManager::GetCurveIndex(AlphArray(7)); // convert curve name to number + if (CTGenerator(genNum).TempBasedExhaustTempCurve == 0) { ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(7) + '=' + AlphArray(7)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } - CTGenerator(GeneratorNum).QLubeOilRecoveredCurve = CurveManager::GetCurveIndex(AlphArray(8)); // convert curve name to number - if (CTGenerator(GeneratorNum).QLubeOilRecoveredCurve == 0) { + CTGenerator(genNum).QLubeOilRecoveredCurve = CurveManager::GetCurveIndex(AlphArray(8)); // convert curve name to number + if (CTGenerator(genNum).QLubeOilRecoveredCurve == 0) { ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(8) + '=' + AlphArray(8)); ShowContinueError("Entered in " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } - CTGenerator(GeneratorNum).UACoef(1) = NumArray(5); - CTGenerator(GeneratorNum).UACoef(2) = NumArray(6); + CTGenerator(genNum).UACoef(1) = NumArray(5); + CTGenerator(genNum).UACoef(2) = NumArray(6); - CTGenerator(GeneratorNum).MaxExhaustperCTPower = NumArray(7); - CTGenerator(GeneratorNum).DesignMinExitGasTemp = NumArray(8); - CTGenerator(GeneratorNum).DesignAirInletTemp = NumArray(9); - CTGenerator(GeneratorNum).FuelHeatingValue = NumArray(10); - CTGenerator(GeneratorNum).DesignHeatRecVolFlowRate = NumArray(11); + CTGenerator(genNum).MaxExhaustperCTPower = NumArray(7); + CTGenerator(genNum).DesignMinExitGasTemp = NumArray(8); + CTGenerator(genNum).DesignAirInletTemp = NumArray(9); + CTGenerator(genNum).FuelHeatingValue = NumArray(10); + CTGenerator(genNum).DesignHeatRecVolFlowRate = NumArray(11); - if (CTGenerator(GeneratorNum).DesignHeatRecVolFlowRate > 0.0) { - CTGenerator(GeneratorNum).HeatRecActive = true; - CTGenerator(GeneratorNum).HeatRecInletNodeNum = NodeInputManager::GetOnlySingleNode( + if (CTGenerator(genNum).DesignHeatRecVolFlowRate > 0.0) { + CTGenerator(genNum).HeatRecActive = true; + CTGenerator(genNum).HeatRecInletNodeNum = NodeInputManager::GetOnlySingleNode( AlphArray(9), ErrorsFound, DataIPShortCuts::cCurrentModuleObject, AlphArray(1), DataLoopNode::NodeType_Water, DataLoopNode::NodeConnectionType_Inlet, 1, DataLoopNode::ObjectIsNotParent); - if (CTGenerator(GeneratorNum).HeatRecInletNodeNum == 0) { + if (CTGenerator(genNum).HeatRecInletNodeNum == 0) { ShowSevereError("Missing Node Name, Heat Recovery Inlet, for " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } - CTGenerator(GeneratorNum).HeatRecOutletNodeNum = NodeInputManager::GetOnlySingleNode( + CTGenerator(genNum).HeatRecOutletNodeNum = NodeInputManager::GetOnlySingleNode( AlphArray(10), ErrorsFound, DataIPShortCuts::cCurrentModuleObject, AlphArray(1), DataLoopNode::NodeType_Water, DataLoopNode::NodeConnectionType_Outlet, 1, DataLoopNode::ObjectIsNotParent); - if (CTGenerator(GeneratorNum).HeatRecOutletNodeNum == 0) { + if (CTGenerator(genNum).HeatRecOutletNodeNum == 0) { ShowSevereError("Missing Node Name, Heat Recovery Outlet, for " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } BranchNodeConnections::TestCompSet(DataIPShortCuts::cCurrentModuleObject, AlphArray(1), AlphArray(9), AlphArray(10), "Heat Recovery Nodes"); - PlantUtilities::RegisterPlantCompDesignFlow(CTGenerator(GeneratorNum).HeatRecInletNodeNum, CTGenerator(GeneratorNum).DesignHeatRecVolFlowRate); + PlantUtilities::RegisterPlantCompDesignFlow(CTGenerator(genNum).HeatRecInletNodeNum, CTGenerator(genNum).DesignHeatRecVolFlowRate); } else { - CTGenerator(GeneratorNum).HeatRecActive = false; - CTGenerator(GeneratorNum).HeatRecInletNodeNum = 0; - CTGenerator(GeneratorNum).HeatRecOutletNodeNum = 0; + CTGenerator(genNum).HeatRecActive = false; + CTGenerator(genNum).HeatRecInletNodeNum = 0; + CTGenerator(genNum).HeatRecOutletNodeNum = 0; if (!DataIPShortCuts::lAlphaFieldBlanks(9) || !DataIPShortCuts::lAlphaFieldBlanks(10)) { ShowWarningError("Since Design Heat Flow Rate = 0.0, Heat Recovery inactive for " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ShowContinueError("However, Node names were specified for Heat Recovery inlet or outlet nodes"); @@ -347,33 +344,33 @@ namespace CTElectricGenerator { { auto const SELECT_CASE_var(AlphArray(11)); if (is_blank(SELECT_CASE_var)) { // If blank then the default is Natural Gas - CTGenerator(GeneratorNum).FuelType = "Gas"; + CTGenerator(genNum).FuelType = "Gas"; } else if ((SELECT_CASE_var == "GAS") || (SELECT_CASE_var == "NATURALGAS") || (SELECT_CASE_var == "NATURAL GAS")) { - CTGenerator(GeneratorNum).FuelType = "Gas"; + CTGenerator(genNum).FuelType = "Gas"; } else if (SELECT_CASE_var == "DIESEL") { - CTGenerator(GeneratorNum).FuelType = "Diesel"; + CTGenerator(genNum).FuelType = "Diesel"; } else if (SELECT_CASE_var == "GASOLINE") { - CTGenerator(GeneratorNum).FuelType = "Gasoline"; + CTGenerator(genNum).FuelType = "Gasoline"; } else if ((SELECT_CASE_var == "FUEL OIL #1") || (SELECT_CASE_var == "FUELOIL#1") || (SELECT_CASE_var == "FUEL OIL") || (SELECT_CASE_var == "DISTILLATE OIL")) { - CTGenerator(GeneratorNum).FuelType = "FuelOil#1"; + CTGenerator(genNum).FuelType = "FuelOil#1"; } else if ((SELECT_CASE_var == "FUEL OIL #2") || (SELECT_CASE_var == "FUELOIL#2") || (SELECT_CASE_var == "RESIDUAL OIL")) { - CTGenerator(GeneratorNum).FuelType = "FuelOil#2"; + CTGenerator(genNum).FuelType = "FuelOil#2"; } else if ((SELECT_CASE_var == "PROPANE") || (SELECT_CASE_var == "LPG") || (SELECT_CASE_var == "PROPANEGAS") || (SELECT_CASE_var == "PROPANE GAS")) { - CTGenerator(GeneratorNum).FuelType = "Propane"; + CTGenerator(genNum).FuelType = "Propane"; } else if (SELECT_CASE_var == "OTHERFUEL1") { - CTGenerator(GeneratorNum).FuelType = "OtherFuel1"; + CTGenerator(genNum).FuelType = "OtherFuel1"; } else if (SELECT_CASE_var == "OTHERFUEL2") { - CTGenerator(GeneratorNum).FuelType = "OtherFuel2"; + CTGenerator(genNum).FuelType = "OtherFuel2"; } else { ShowSevereError("Invalid " + DataIPShortCuts::cAlphaFieldNames(11) + '=' + AlphArray(11)); @@ -382,22 +379,22 @@ namespace CTElectricGenerator { } } - CTGenerator(GeneratorNum).HeatRecMaxTemp = NumArray(12); + CTGenerator(genNum).HeatRecMaxTemp = NumArray(12); // begin CR7021 if (DataIPShortCuts::lAlphaFieldBlanks(12)) { - CTGenerator(GeneratorNum).OAInletNode = 0; + CTGenerator(genNum).OAInletNode = 0; } else { - CTGenerator(GeneratorNum).OAInletNode = NodeInputManager::GetOnlySingleNode(AlphArray(12), - ErrorsFound, - DataIPShortCuts::cCurrentModuleObject, - AlphArray(1), - DataLoopNode::NodeType_Air, - DataLoopNode::NodeConnectionType_OutsideAirReference, - 1, - DataLoopNode::ObjectIsNotParent); - if (!OutAirNodeManager::CheckOutAirNodeNumber(CTGenerator(GeneratorNum).OAInletNode)) { - ShowSevereError(DataIPShortCuts::cCurrentModuleObject + ", \"" + CTGenerator(GeneratorNum).Name + + CTGenerator(genNum).OAInletNode = NodeInputManager::GetOnlySingleNode(AlphArray(12), + ErrorsFound, + DataIPShortCuts::cCurrentModuleObject, + AlphArray(1), + DataLoopNode::NodeType_Air, + DataLoopNode::NodeConnectionType_OutsideAirReference, + 1, + DataLoopNode::ObjectIsNotParent); + if (!OutAirNodeManager::CheckOutAirNodeNumber(CTGenerator(genNum).OAInletNode)) { + ShowSevereError(DataIPShortCuts::cCurrentModuleObject + ", \"" + CTGenerator(genNum).Name + "\" Outdoor Air Inlet Node Name not valid Outdoor Air Node= " + AlphArray(12)); ShowContinueError("...does not appear in an OutdoorAir:NodeList or as an OutdoorAir:Node."); ErrorsFound = true; @@ -409,39 +406,39 @@ namespace CTElectricGenerator { ShowFatalError("Errors found in processing input for " + DataIPShortCuts::cCurrentModuleObject); } - for (GeneratorNum = 1; GeneratorNum <= NumCTGenerators; ++GeneratorNum) { + for (genNum = 1; genNum <= NumCTGenerators; ++genNum) { SetupOutputVariable("Generator Produced Electric Power", OutputProcessor::Unit::W, - CTGeneratorReport(GeneratorNum).PowerGen, + CTGenerator(genNum).ElecPowerGenerated, "System", "Average", - CTGenerator(GeneratorNum).Name); + CTGenerator(genNum).Name); SetupOutputVariable("Generator Produced Electric Energy", OutputProcessor::Unit::J, - CTGeneratorReport(GeneratorNum).EnergyGen, + CTGenerator(genNum).ElecEnergyGenerated, "System", "Sum", - CTGenerator(GeneratorNum).Name, + CTGenerator(genNum).Name, _, "ElectricityProduced", "COGENERATION", _, "Plant"); - SetupOutputVariable("Generator " + CTGenerator(GeneratorNum).FuelType + " Rate", + SetupOutputVariable("Generator " + CTGenerator(genNum).FuelType + " Rate", OutputProcessor::Unit::W, - CTGeneratorReport(GeneratorNum).FuelEnergyUseRate, + CTGeneratorReport(genNum).FuelEnergyUseRate, "System", "Average", - CTGenerator(GeneratorNum).Name); - SetupOutputVariable("Generator " + CTGenerator(GeneratorNum).FuelType + " Energy", + CTGenerator(genNum).Name); + SetupOutputVariable("Generator " + CTGenerator(genNum).FuelType + " Energy", OutputProcessor::Unit::J, - CTGeneratorReport(GeneratorNum).FuelEnergy, + CTGeneratorReport(genNum).FuelEnergy, "System", "Sum", - CTGenerator(GeneratorNum).Name, + CTGenerator(genNum).Name, _, - CTGenerator(GeneratorNum).FuelType, + CTGenerator(genNum).FuelType, "COGENERATION", _, "Plant"); @@ -449,44 +446,44 @@ namespace CTElectricGenerator { // general fuel use report (to match other generators) SetupOutputVariable("Generator Fuel HHV Basis Rate", OutputProcessor::Unit::W, - CTGeneratorReport(GeneratorNum).FuelEnergyUseRate, + CTGeneratorReport(genNum).FuelEnergyUseRate, "System", "Average", - CTGenerator(GeneratorNum).Name); + CTGenerator(genNum).Name); SetupOutputVariable("Generator Fuel HHV Basis Energy", OutputProcessor::Unit::J, - CTGeneratorReport(GeneratorNum).FuelEnergy, + CTGeneratorReport(genNum).FuelEnergy, "System", "Sum", - CTGenerator(GeneratorNum).Name); + CTGenerator(genNum).Name); - SetupOutputVariable("Generator " + CTGenerator(GeneratorNum).FuelType + " Mass Flow Rate", + SetupOutputVariable("Generator " + CTGenerator(genNum).FuelType + " Mass Flow Rate", OutputProcessor::Unit::kg_s, - CTGeneratorReport(GeneratorNum).FuelMdot, + CTGeneratorReport(genNum).FuelMdot, "System", "Average", - CTGenerator(GeneratorNum).Name); + CTGenerator(genNum).Name); SetupOutputVariable("Generator Exhaust Air Temperature", OutputProcessor::Unit::C, - CTGeneratorReport(GeneratorNum).ExhaustStackTemp, + CTGeneratorReport(genNum).ExhaustStackTemp, "System", "Average", - CTGenerator(GeneratorNum).Name); + CTGenerator(genNum).Name); - if (CTGenerator(GeneratorNum).HeatRecActive) { + if (CTGenerator(genNum).HeatRecActive) { SetupOutputVariable("Generator Exhaust Heat Recovery Rate", OutputProcessor::Unit::W, - CTGeneratorReport(GeneratorNum).QExhaustRecovered, + CTGeneratorReport(genNum).QExhaustRecovered, "System", "Average", - CTGenerator(GeneratorNum).Name); + CTGenerator(genNum).Name); SetupOutputVariable("Generator Exhaust Heat Recovery Energy", OutputProcessor::Unit::J, - CTGeneratorReport(GeneratorNum).ExhaustEnergyRec, + CTGeneratorReport(genNum).ExhaustEnergyRec, "System", "Sum", - CTGenerator(GeneratorNum).Name, + CTGenerator(genNum).Name, _, "ENERGYTRANSFER", "HEATRECOVERY", @@ -495,16 +492,16 @@ namespace CTElectricGenerator { SetupOutputVariable("Generator Lube Heat Recovery Rate", OutputProcessor::Unit::W, - CTGeneratorReport(GeneratorNum).QLubeOilRecovered, + CTGeneratorReport(genNum).QLubeOilRecovered, "System", "Average", - CTGenerator(GeneratorNum).Name); + CTGenerator(genNum).Name); SetupOutputVariable("Generator Lube Heat Recovery Energy", OutputProcessor::Unit::J, - CTGeneratorReport(GeneratorNum).LubeOilEnergyRec, + CTGeneratorReport(genNum).LubeOilEnergyRec, "System", "Sum", - CTGenerator(GeneratorNum).Name, + CTGenerator(genNum).Name, _, "ENERGYTRANSFER", "HEATRECOVERY", @@ -513,40 +510,40 @@ namespace CTElectricGenerator { SetupOutputVariable("Generator Produced Thermal Rate", OutputProcessor::Unit::W, - CTGeneratorReport(GeneratorNum).QTotalHeatRecovered, + CTGeneratorReport(genNum).QTotalHeatRecovered, "System", "Average", - CTGenerator(GeneratorNum).Name); + CTGenerator(genNum).Name); SetupOutputVariable("Generator Produced Thermal Energy", OutputProcessor::Unit::J, - CTGeneratorReport(GeneratorNum).TotalHeatEnergyRec, + CTGeneratorReport(genNum).TotalHeatEnergyRec, "System", "Sum", - CTGenerator(GeneratorNum).Name); + CTGenerator(genNum).Name); SetupOutputVariable("Generator Heat Recovery Inlet Temperature", OutputProcessor::Unit::C, - CTGeneratorReport(GeneratorNum).HeatRecInletTemp, + CTGeneratorReport(genNum).HeatRecInletTemp, "System", "Average", - CTGenerator(GeneratorNum).Name); + CTGenerator(genNum).Name); SetupOutputVariable("Generator Heat Recovery Outlet Temperature", OutputProcessor::Unit::C, - CTGeneratorReport(GeneratorNum).HeatRecOutletTemp, + CTGeneratorReport(genNum).HeatRecOutletTemp, "System", "Average", - CTGenerator(GeneratorNum).Name); + CTGenerator(genNum).Name); SetupOutputVariable("Generator Heat Recovery Mass Flow Rate", OutputProcessor::Unit::kg_s, - CTGeneratorReport(GeneratorNum).HeatRecMdot, + CTGeneratorReport(genNum).HeatRecMdot, "System", "Average", - CTGenerator(GeneratorNum).Name); + CTGenerator(genNum).Name); } } } - void CalcCTGeneratorModel(int const GeneratorNum, // Generator number + void CalcCTGeneratorModel(int const genNum, // Generator number bool const RunFlag, // TRUE when Generator operating Real64 const MyLoad, // Generator demand bool const FirstHVACIteration) @@ -600,21 +597,21 @@ namespace CTElectricGenerator { Real64 HRecRatio; // When Max Temp is reached the amount of recovered heat has to be reduced. // and this assumption uses this ratio to accomplish this task. - MinPartLoadRat = CTGenerator(GeneratorNum).MinPartLoadRat; - MaxPartLoadRat = CTGenerator(GeneratorNum).MaxPartLoadRat; - RatedPowerOutput = CTGenerator(GeneratorNum).RatedPowerOutput; - MaxExhaustperCTPower = CTGenerator(GeneratorNum).MaxExhaustperCTPower; - DesignAirInletTemp = CTGenerator(GeneratorNum).DesignAirInletTemp; - if (CTGenerator(GeneratorNum).HeatRecActive) { - HeatRecInNode = CTGenerator(GeneratorNum).HeatRecInletNodeNum; + MinPartLoadRat = CTGenerator(genNum).MinPartLoadRat; + MaxPartLoadRat = CTGenerator(genNum).MaxPartLoadRat; + RatedPowerOutput = CTGenerator(genNum).RatedPowerOutput; + MaxExhaustperCTPower = CTGenerator(genNum).MaxExhaustperCTPower; + DesignAirInletTemp = CTGenerator(genNum).DesignAirInletTemp; + if (CTGenerator(genNum).HeatRecActive) { + HeatRecInNode = CTGenerator(genNum).HeatRecInletNodeNum; HeatRecInTemp = DataLoopNode::Node(HeatRecInNode).Temp; - HeatRecCp = FluidProperties::GetSpecificHeatGlycol(DataPlant::PlantLoop(CTGenerator(GeneratorNum).HRLoopNum).FluidName, + HeatRecCp = FluidProperties::GetSpecificHeatGlycol(DataPlant::PlantLoop(CTGenerator(genNum).HRLoopNum).FluidName, HeatRecInTemp, - DataPlant::PlantLoop(CTGenerator(GeneratorNum).HRLoopNum).FluidIndex, + DataPlant::PlantLoop(CTGenerator(genNum).HRLoopNum).FluidIndex, RoutineName); if (FirstHVACIteration && RunFlag) { - HeatRecMdot = CTGenerator(GeneratorNum).DesignHeatRecMassFlowRate; + HeatRecMdot = CTGenerator(genNum).DesignHeatRecMassFlowRate; } else { HeatRecMdot = DataLoopNode::Node(HeatRecInNode).MassFlowRate; } @@ -626,21 +623,21 @@ namespace CTElectricGenerator { // If no loop demand or Generator OFF, return if (!RunFlag) { - CTGenerator(GeneratorNum).ElecPowerGenerated = 0.0; - CTGenerator(GeneratorNum).ElecEnergyGenerated = 0.0; - CTGenerator(GeneratorNum).HeatRecInletTemp = HeatRecInTemp; - CTGenerator(GeneratorNum).HeatRecOutletTemp = HeatRecInTemp; - CTGenerator(GeneratorNum).HeatRecMdot = 0.0; - CTGenerator(GeneratorNum).QLubeOilRecovered = 0.0; - CTGenerator(GeneratorNum).QExhaustRecovered = 0.0; - CTGenerator(GeneratorNum).QTotalHeatRecovered = 0.0; - CTGenerator(GeneratorNum).LubeOilEnergyRec = 0.0; - CTGenerator(GeneratorNum).ExhaustEnergyRec = 0.0; - CTGenerator(GeneratorNum).TotalHeatEnergyRec = 0.0; - CTGenerator(GeneratorNum).FuelEnergyUseRate = 0.0; - CTGenerator(GeneratorNum).FuelEnergy = 0.0; - CTGenerator(GeneratorNum).FuelMdot = 0.0; - CTGenerator(GeneratorNum).ExhaustStackTemp = 0.0; + CTGenerator(genNum).ElecPowerGenerated = 0.0; + CTGenerator(genNum).ElecEnergyGenerated = 0.0; + CTGenerator(genNum).HeatRecInletTemp = HeatRecInTemp; + CTGenerator(genNum).HeatRecOutletTemp = HeatRecInTemp; + CTGenerator(genNum).HeatRecMdot = 0.0; + CTGenerator(genNum).QLubeOilRecovered = 0.0; + CTGenerator(genNum).QExhaustRecovered = 0.0; + CTGenerator(genNum).QTotalHeatRecovered = 0.0; + CTGenerator(genNum).LubeOilEnergyRec = 0.0; + CTGenerator(genNum).ExhaustEnergyRec = 0.0; + CTGenerator(genNum).TotalHeatEnergyRec = 0.0; + CTGenerator(genNum).FuelEnergyUseRate = 0.0; + CTGenerator(genNum).FuelEnergy = 0.0; + CTGenerator(genNum).FuelMdot = 0.0; + CTGenerator(genNum).ExhaustStackTemp = 0.0; return; } @@ -653,48 +650,48 @@ namespace CTElectricGenerator { // SET OFF-DESIGN AIR TEMPERATURE DIFFERENCE // use OA node if set by user CR7021 - if (CTGenerator(GeneratorNum).OAInletNode == 0) { + if (CTGenerator(genNum).OAInletNode == 0) { AmbientDeltaT = DataEnvironment::OutDryBulbTemp - DesignAirInletTemp; } else { - AmbientDeltaT = DataLoopNode::Node(CTGenerator(GeneratorNum).OAInletNode).Temp - DesignAirInletTemp; + AmbientDeltaT = DataLoopNode::Node(CTGenerator(genNum).OAInletNode).Temp - DesignAirInletTemp; } // Use Curve fit to determine Fuel Energy Input. For electric power generated in Watts, the fuel // energy input is calculated in J/s. The PLBasedFuelInputCurve selects ratio of fuel flow (J/s)/power generated (J/s). // The TempBasedFuelInputCurve is a correction based on deviation from design inlet air temperature conditions. // The first coefficient of this fit should be 1.0 to ensure that no correction is made at design conditions. - FuelUseRate = ElecPowerGenerated * CurveManager::CurveValue(CTGenerator(GeneratorNum).PLBasedFuelInputCurve, PLR) * - CurveManager::CurveValue(CTGenerator(GeneratorNum).TempBasedFuelInputCurve, AmbientDeltaT); + FuelUseRate = ElecPowerGenerated * CurveManager::CurveValue(CTGenerator(genNum).PLBasedFuelInputCurve, PLR) * + CurveManager::CurveValue(CTGenerator(genNum).TempBasedFuelInputCurve, AmbientDeltaT); // Use Curve fit to determine Exhaust Flow. This curve shows the ratio of exhaust gas flow (kg/s) to electric power // output (J/s). The units on ExhaustFlowCurve are (kg/J). When multiplied by the rated power of the unit, // it gives the exhaust flow rate in kg/s - ExhaustFlow = RatedPowerOutput * CurveManager::CurveValue(CTGenerator(GeneratorNum).ExhaustFlowCurve, AmbientDeltaT); + ExhaustFlow = RatedPowerOutput * CurveManager::CurveValue(CTGenerator(genNum).ExhaustFlowCurve, AmbientDeltaT); // Use Curve fit to determine Exhaust Temperature. This curve calculates the exhaust temperature (C) by // multiplying the exhaust temperature (C) for a particular part load as given by PLBasedExhaustTempCurve // a correction factor based on the deviation from design temperature, TempBasedExhaustTempCurve if ((PLR > 0.0) && ((ExhaustFlow > 0.0) || (MaxExhaustperCTPower > 0.0))) { - ExhaustTemp = CurveManager::CurveValue(CTGenerator(GeneratorNum).PLBasedExhaustTempCurve, PLR) * - CurveManager::CurveValue(CTGenerator(GeneratorNum).TempBasedExhaustTempCurve, AmbientDeltaT); + ExhaustTemp = CurveManager::CurveValue(CTGenerator(genNum).PLBasedExhaustTempCurve, PLR) * + CurveManager::CurveValue(CTGenerator(genNum).TempBasedExhaustTempCurve, AmbientDeltaT); - UA = CTGenerator(GeneratorNum).UACoef(1) * std::pow(RatedPowerOutput, CTGenerator(GeneratorNum).UACoef(2)); + UA = CTGenerator(genNum).UACoef(1) * std::pow(RatedPowerOutput, CTGenerator(genNum).UACoef(2)); - DesignMinExitGasTemp = CTGenerator(GeneratorNum).DesignMinExitGasTemp; + DesignMinExitGasTemp = CTGenerator(genNum).DesignMinExitGasTemp; ExhaustStackTemp = DesignMinExitGasTemp + (ExhaustTemp - DesignMinExitGasTemp) / std::exp(UA / (max(ExhaustFlow, MaxExhaustperCTPower * RatedPowerOutput) * ExhaustCP)); QExhaustRec = max(ExhaustFlow * ExhaustCP * (ExhaustTemp - ExhaustStackTemp), 0.0); } else { - ExhaustStackTemp = CTGenerator(GeneratorNum).DesignMinExitGasTemp; + ExhaustStackTemp = CTGenerator(genNum).DesignMinExitGasTemp; QExhaustRec = 0.0; } // Use Curve fit to determine Heat Recovered Lubricant heat. This curve calculates the lube heat recovered (J/s) by // multiplying the total power generated by the fraction of that power that could be recovered in the lube oil at that // particular part load. - QLubeOilRec = ElecPowerGenerated * CurveManager::CurveValue(CTGenerator(GeneratorNum).QLubeOilRecoveredCurve, PLR); + QLubeOilRec = ElecPowerGenerated * CurveManager::CurveValue(CTGenerator(genNum).QLubeOilRecoveredCurve, PLR); // Check for divide by zero if ((HeatRecMdot > 0.0) && (HeatRecCp > 0.0)) { @@ -709,9 +706,9 @@ namespace CTElectricGenerator { // Now verify the maximum temperature was not exceeded HRecRatio = 1.0; MinHeatRecMdot = 0.0; - if (HeatRecOutTemp > CTGenerator(GeneratorNum).HeatRecMaxTemp) { - if (CTGenerator(GeneratorNum).HeatRecMaxTemp != HeatRecInTemp) { - MinHeatRecMdot = (QExhaustRec + QLubeOilRec) / (HeatRecCp * (CTGenerator(GeneratorNum).HeatRecMaxTemp - HeatRecInTemp)); + if (HeatRecOutTemp > CTGenerator(genNum).HeatRecMaxTemp) { + if (CTGenerator(genNum).HeatRecMaxTemp != HeatRecInTemp) { + MinHeatRecMdot = (QExhaustRec + QLubeOilRec) / (HeatRecCp * (CTGenerator(genNum).HeatRecMaxTemp - HeatRecInTemp)); if (MinHeatRecMdot < 0.0) MinHeatRecMdot = 0.0; } @@ -733,30 +730,30 @@ namespace CTElectricGenerator { LubeOilEnergyRec = QLubeOilRec * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; ExhaustEnergyRec = QExhaustRec * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - CTGenerator(GeneratorNum).ElecPowerGenerated = ElecPowerGenerated; - CTGenerator(GeneratorNum).ElecEnergyGenerated = ElectricEnergyGen; + CTGenerator(genNum).ElecPowerGenerated = ElecPowerGenerated; + CTGenerator(genNum).ElecEnergyGenerated = ElectricEnergyGen; - CTGenerator(GeneratorNum).HeatRecInletTemp = HeatRecInTemp; - CTGenerator(GeneratorNum).HeatRecOutletTemp = HeatRecOutTemp; + CTGenerator(genNum).HeatRecInletTemp = HeatRecInTemp; + CTGenerator(genNum).HeatRecOutletTemp = HeatRecOutTemp; - CTGenerator(GeneratorNum).HeatRecMdot = HeatRecMdot; - CTGenerator(GeneratorNum).QExhaustRecovered = QExhaustRec; - CTGenerator(GeneratorNum).QLubeOilRecovered = QLubeOilRec; - CTGenerator(GeneratorNum).QTotalHeatRecovered = QExhaustRec + QLubeOilRec; - CTGenerator(GeneratorNum).FuelEnergyUseRate = std::abs(FuelUseRate); - CTGenerator(GeneratorNum).ExhaustEnergyRec = ExhaustEnergyRec; - CTGenerator(GeneratorNum).LubeOilEnergyRec = LubeOilEnergyRec; - CTGenerator(GeneratorNum).TotalHeatEnergyRec = ExhaustEnergyRec + LubeOilEnergyRec; - CTGenerator(GeneratorNum).FuelEnergy = std::abs(FuelEnergyUsed); + CTGenerator(genNum).HeatRecMdot = HeatRecMdot; + CTGenerator(genNum).QExhaustRecovered = QExhaustRec; + CTGenerator(genNum).QLubeOilRecovered = QLubeOilRec; + CTGenerator(genNum).QTotalHeatRecovered = QExhaustRec + QLubeOilRec; + CTGenerator(genNum).FuelEnergyUseRate = std::abs(FuelUseRate); + CTGenerator(genNum).ExhaustEnergyRec = ExhaustEnergyRec; + CTGenerator(genNum).LubeOilEnergyRec = LubeOilEnergyRec; + CTGenerator(genNum).TotalHeatEnergyRec = ExhaustEnergyRec + LubeOilEnergyRec; + CTGenerator(genNum).FuelEnergy = std::abs(FuelEnergyUsed); - FuelHeatingValue = CTGenerator(GeneratorNum).FuelHeatingValue; + FuelHeatingValue = CTGenerator(genNum).FuelHeatingValue; - CTGenerator(GeneratorNum).FuelMdot = std::abs(FuelUseRate) / (FuelHeatingValue * KJtoJ); + CTGenerator(genNum).FuelMdot = std::abs(FuelUseRate) / (FuelHeatingValue * KJtoJ); - CTGenerator(GeneratorNum).ExhaustStackTemp = ExhaustStackTemp; + CTGenerator(genNum).ExhaustStackTemp = ExhaustStackTemp; } - void InitCTGenerators(int const GeneratorNum, // Generator number + void InitCTGenerators(int const genNum, // Generator number bool const RunFlag, // TRUE when Generator operating Real64 const EP_UNUSED(MyLoad), // Generator demand bool const FirstHVACIteration) @@ -786,14 +783,14 @@ namespace CTElectricGenerator { MyOneTimeFlag = false; } - if (CTGenerator(GeneratorNum).MyPlantScanFlag && allocated(DataPlant::PlantLoop) && CTGenerator(GeneratorNum).HeatRecActive) { + if (CTGenerator(genNum).MyPlantScanFlag && allocated(DataPlant::PlantLoop) && CTGenerator(genNum).HeatRecActive) { errFlag = false; - PlantUtilities::ScanPlantLoopsForObject(CTGenerator(GeneratorNum).Name, + PlantUtilities::ScanPlantLoopsForObject(CTGenerator(genNum).Name, DataPlant::TypeOf_Generator_CTurbine, - CTGenerator(GeneratorNum).HRLoopNum, - CTGenerator(GeneratorNum).HRLoopSideNum, - CTGenerator(GeneratorNum).HRBranchNum, - CTGenerator(GeneratorNum).HRCompNum, + CTGenerator(genNum).HRLoopNum, + CTGenerator(genNum).HRLoopSideNum, + CTGenerator(genNum).HRBranchNum, + CTGenerator(genNum).HRCompNum, errFlag, _, _, @@ -803,86 +800,86 @@ namespace CTElectricGenerator { if (errFlag) { ShowFatalError("InitCTGenerators: Program terminated due to previous condition(s)."); } - CTGenerator(GeneratorNum).MyPlantScanFlag = false; + CTGenerator(genNum).MyPlantScanFlag = false; } - if (CTGenerator(GeneratorNum).MySizeAndNodeInitFlag && (!CTGenerator(GeneratorNum).MyPlantScanFlag) && CTGenerator(GeneratorNum).HeatRecActive) { - HeatRecInletNode = CTGenerator(GeneratorNum).HeatRecInletNodeNum; - HeatRecOutletNode = CTGenerator(GeneratorNum).HeatRecOutletNodeNum; + if (CTGenerator(genNum).MySizeAndNodeInitFlag && (!CTGenerator(genNum).MyPlantScanFlag) && CTGenerator(genNum).HeatRecActive) { + HeatRecInletNode = CTGenerator(genNum).HeatRecInletNodeNum; + HeatRecOutletNode = CTGenerator(genNum).HeatRecOutletNodeNum; // size mass flow rate - rho = FluidProperties::GetDensityGlycol(DataPlant::PlantLoop(CTGenerator(GeneratorNum).HRLoopNum).FluidName, + rho = FluidProperties::GetDensityGlycol(DataPlant::PlantLoop(CTGenerator(genNum).HRLoopNum).FluidName, DataGlobals::InitConvTemp, - DataPlant::PlantLoop(CTGenerator(GeneratorNum).HRLoopNum).FluidIndex, + DataPlant::PlantLoop(CTGenerator(genNum).HRLoopNum).FluidIndex, RoutineName); - CTGenerator(GeneratorNum).DesignHeatRecMassFlowRate = rho * CTGenerator(GeneratorNum).DesignHeatRecVolFlowRate; + CTGenerator(genNum).DesignHeatRecMassFlowRate = rho * CTGenerator(genNum).DesignHeatRecVolFlowRate; PlantUtilities::InitComponentNodes(0.0, - CTGenerator(GeneratorNum).DesignHeatRecMassFlowRate, + CTGenerator(genNum).DesignHeatRecMassFlowRate, HeatRecInletNode, HeatRecOutletNode, - CTGenerator(GeneratorNum).HRLoopNum, - CTGenerator(GeneratorNum).HRLoopSideNum, - CTGenerator(GeneratorNum).HRBranchNum, - CTGenerator(GeneratorNum).HRCompNum); + CTGenerator(genNum).HRLoopNum, + CTGenerator(genNum).HRLoopSideNum, + CTGenerator(genNum).HRBranchNum, + CTGenerator(genNum).HRCompNum); - CTGenerator(GeneratorNum).MySizeAndNodeInitFlag = false; + CTGenerator(genNum).MySizeAndNodeInitFlag = false; } // end one time inits // Do the Begin Environment initializations - if (DataGlobals::BeginEnvrnFlag && CTGenerator(GeneratorNum).MyEnvrnFlag && CTGenerator(GeneratorNum).HeatRecActive) { - HeatRecInletNode = CTGenerator(GeneratorNum).HeatRecInletNodeNum; - HeatRecOutletNode = CTGenerator(GeneratorNum).HeatRecOutletNodeNum; + if (DataGlobals::BeginEnvrnFlag && CTGenerator(genNum).MyEnvrnFlag && CTGenerator(genNum).HeatRecActive) { + HeatRecInletNode = CTGenerator(genNum).HeatRecInletNodeNum; + HeatRecOutletNode = CTGenerator(genNum).HeatRecOutletNodeNum; // set the node Temperature, assuming freeze control DataLoopNode::Node(HeatRecInletNode).Temp = 20.0; DataLoopNode::Node(HeatRecOutletNode).Temp = 20.0; // set the node max and min mass flow rates PlantUtilities::InitComponentNodes(0.0, - CTGenerator(GeneratorNum).DesignHeatRecMassFlowRate, + CTGenerator(genNum).DesignHeatRecMassFlowRate, HeatRecInletNode, HeatRecOutletNode, - CTGenerator(GeneratorNum).HRLoopNum, - CTGenerator(GeneratorNum).HRLoopSideNum, - CTGenerator(GeneratorNum).HRBranchNum, - CTGenerator(GeneratorNum).HRCompNum); + CTGenerator(genNum).HRLoopNum, + CTGenerator(genNum).HRLoopSideNum, + CTGenerator(genNum).HRBranchNum, + CTGenerator(genNum).HRCompNum); - CTGenerator(GeneratorNum).MyEnvrnFlag = false; + CTGenerator(genNum).MyEnvrnFlag = false; } // end environmental inits if (!DataGlobals::BeginEnvrnFlag) { - CTGenerator(GeneratorNum).MyEnvrnFlag = true; + CTGenerator(genNum).MyEnvrnFlag = true; } - if (CTGenerator(GeneratorNum).HeatRecActive) { + if (CTGenerator(genNum).HeatRecActive) { if (FirstHVACIteration) { if (RunFlag) { - mdot = CTGenerator(GeneratorNum).DesignHeatRecMassFlowRate; + mdot = CTGenerator(genNum).DesignHeatRecMassFlowRate; } else { mdot = 0.0; } PlantUtilities::SetComponentFlowRate(mdot, - CTGenerator(GeneratorNum).HeatRecInletNodeNum, - CTGenerator(GeneratorNum).HeatRecOutletNodeNum, - CTGenerator(GeneratorNum).HRLoopNum, - CTGenerator(GeneratorNum).HRLoopSideNum, - CTGenerator(GeneratorNum).HRBranchNum, - CTGenerator(GeneratorNum).HRCompNum); + CTGenerator(genNum).HeatRecInletNodeNum, + CTGenerator(genNum).HeatRecOutletNodeNum, + CTGenerator(genNum).HRLoopNum, + CTGenerator(genNum).HRLoopSideNum, + CTGenerator(genNum).HRBranchNum, + CTGenerator(genNum).HRCompNum); } else { - PlantUtilities::SetComponentFlowRate(CTGenerator(GeneratorNum).HeatRecMdot, - CTGenerator(GeneratorNum).HeatRecInletNodeNum, - CTGenerator(GeneratorNum).HeatRecOutletNodeNum, - CTGenerator(GeneratorNum).HRLoopNum, - CTGenerator(GeneratorNum).HRLoopSideNum, - CTGenerator(GeneratorNum).HRBranchNum, - CTGenerator(GeneratorNum).HRCompNum); + PlantUtilities::SetComponentFlowRate(CTGenerator(genNum).HeatRecMdot, + CTGenerator(genNum).HeatRecInletNodeNum, + CTGenerator(genNum).HeatRecOutletNodeNum, + CTGenerator(genNum).HRLoopNum, + CTGenerator(genNum).HRLoopSideNum, + CTGenerator(genNum).HRBranchNum, + CTGenerator(genNum).HRCompNum); } } } void UpdateCTGeneratorRecords(bool const EP_UNUSED(RunFlag), // TRUE if Generator operating - int const Num // Generator number + int const genNUm // Generator number ) { // SUBROUTINE INFORMATION: @@ -891,29 +888,27 @@ namespace CTElectricGenerator { int HeatRecOutletNode; - if (CTGenerator(Num).HeatRecActive) { - HeatRecOutletNode = CTGenerator(Num).HeatRecOutletNodeNum; - DataLoopNode::Node(HeatRecOutletNode).Temp = CTGenerator(Num).HeatRecOutletTemp; + if (CTGenerator(genNUm).HeatRecActive) { + HeatRecOutletNode = CTGenerator(genNUm).HeatRecOutletNodeNum; + DataLoopNode::Node(HeatRecOutletNode).Temp = CTGenerator(genNUm).HeatRecOutletTemp; } - CTGeneratorReport(Num).PowerGen = CTGenerator(Num).ElecPowerGenerated; - CTGeneratorReport(Num).EnergyGen = CTGenerator(Num).ElecEnergyGenerated; - CTGeneratorReport(Num).QExhaustRecovered = CTGenerator(Num).QExhaustRecovered; - CTGeneratorReport(Num).QLubeOilRecovered = CTGenerator(Num).QLubeOilRecovered; - CTGeneratorReport(Num).ExhaustEnergyRec = CTGenerator(Num).ExhaustEnergyRec; - CTGeneratorReport(Num).LubeOilEnergyRec = CTGenerator(Num).LubeOilEnergyRec; - CTGeneratorReport(Num).QTotalHeatRecovered = CTGenerator(Num).QTotalHeatRecovered; - CTGeneratorReport(Num).TotalHeatEnergyRec = CTGenerator(Num).TotalHeatEnergyRec; - CTGeneratorReport(Num).FuelEnergyUseRate = CTGenerator(Num).FuelEnergyUseRate; - CTGeneratorReport(Num).FuelEnergy = CTGenerator(Num).FuelEnergy; - CTGeneratorReport(Num).FuelMdot = CTGenerator(Num).FuelMdot; - CTGeneratorReport(Num).ExhaustStackTemp = CTGenerator(Num).ExhaustStackTemp; - CTGeneratorReport(Num).HeatRecInletTemp = CTGenerator(Num).HeatRecInletTemp; - CTGeneratorReport(Num).HeatRecOutletTemp = CTGenerator(Num).HeatRecOutletTemp; - CTGeneratorReport(Num).HeatRecMdot = CTGenerator(Num).HeatRecMdot; + CTGeneratorReport(genNUm).QExhaustRecovered = CTGenerator(genNUm).QExhaustRecovered; + CTGeneratorReport(genNUm).QLubeOilRecovered = CTGenerator(genNUm).QLubeOilRecovered; + CTGeneratorReport(genNUm).ExhaustEnergyRec = CTGenerator(genNUm).ExhaustEnergyRec; + CTGeneratorReport(genNUm).LubeOilEnergyRec = CTGenerator(genNUm).LubeOilEnergyRec; + CTGeneratorReport(genNUm).QTotalHeatRecovered = CTGenerator(genNUm).QTotalHeatRecovered; + CTGeneratorReport(genNUm).TotalHeatEnergyRec = CTGenerator(genNUm).TotalHeatEnergyRec; + CTGeneratorReport(genNUm).FuelEnergyUseRate = CTGenerator(genNUm).FuelEnergyUseRate; + CTGeneratorReport(genNUm).FuelEnergy = CTGenerator(genNUm).FuelEnergy; + CTGeneratorReport(genNUm).FuelMdot = CTGenerator(genNUm).FuelMdot; + CTGeneratorReport(genNUm).ExhaustStackTemp = CTGenerator(genNUm).ExhaustStackTemp; + CTGeneratorReport(genNUm).HeatRecInletTemp = CTGenerator(genNUm).HeatRecInletTemp; + CTGeneratorReport(genNUm).HeatRecOutletTemp = CTGenerator(genNUm).HeatRecOutletTemp; + CTGeneratorReport(genNUm).HeatRecMdot = CTGenerator(genNUm).HeatRecMdot; } void GetCTGeneratorResults(int const EP_UNUSED(GeneratorType), // type of Generator - int const GeneratorIndex, + int const genNum, Real64 &GeneratorPower, // electrical power Real64 &GeneratorEnergy, // electrical energy Real64 &ThermalPower, // heat power @@ -929,10 +924,10 @@ namespace CTElectricGenerator { // PURPOSE OF THIS SUBROUTINE: // get some results for load center's aggregation - GeneratorPower = CTGeneratorReport(GeneratorIndex).PowerGen; - GeneratorEnergy = CTGeneratorReport(GeneratorIndex).EnergyGen; - ThermalPower = CTGeneratorReport(GeneratorIndex).QTotalHeatRecovered; - ThermalEnergy = CTGeneratorReport(GeneratorIndex).TotalHeatEnergyRec; + GeneratorPower = CTGenerator(genNum).ElecPowerGenerated; + GeneratorEnergy = CTGenerator(genNum).ElecEnergyGenerated; + ThermalPower = CTGeneratorReport(genNum).QTotalHeatRecovered; + ThermalEnergy = CTGeneratorReport(genNum).TotalHeatEnergyRec; } } // namespace CTElectricGenerator diff --git a/src/EnergyPlus/CTElectricGenerator.hh b/src/EnergyPlus/CTElectricGenerator.hh index 240ffa80ac5..af9f9abbb7a 100644 --- a/src/EnergyPlus/CTElectricGenerator.hh +++ b/src/EnergyPlus/CTElectricGenerator.hh @@ -126,6 +126,7 @@ namespace CTElectricGenerator { bool MyEnvrnFlag; bool MyPlantScanFlag; bool MySizeAndNodeInitFlag; + bool CheckEquipName; // Default Constructor CTGeneratorSpecs() @@ -138,7 +139,7 @@ namespace CTElectricGenerator { ExhaustStackTemp(0.0), HeatRecActive(false), HeatRecInletNodeNum(0), HeatRecOutletNodeNum(0), HeatRecInletTemp(0.0), HeatRecOutletTemp(0.0), HeatRecMdot(0.0), HRLoopNum(0), HRLoopSideNum(0), HRBranchNum(0), HRCompNum(0), FuelMdot(0.0), FuelHeatingValue(0.0), ElecPowerGenerated(0.0), ElecEnergyGenerated(0.0), HeatRecMaxTemp(0.0), OAInletNode(0), MyEnvrnFlag(true), - MyPlantScanFlag(true), MySizeAndNodeInitFlag(true) + MyPlantScanFlag(true), MySizeAndNodeInitFlag(true), CheckEquipName(true) { } }; @@ -146,8 +147,8 @@ namespace CTElectricGenerator { struct ReportVars { // Members - Real64 PowerGen; // reporting: power (W) - Real64 EnergyGen; // reporting: power (W) +// Real64 PowerGen; // reporting: power (W) +// Real64 EnergyGen; // reporting: power (W) Real64 QTotalHeatRecovered; // reporting: total Heat Recovered (W) Real64 QLubeOilRecovered; // reporting: Heat Recovered from Lubricant (W) Real64 QExhaustRecovered; // reporting: Heat Recovered from exhaust (W) @@ -164,7 +165,7 @@ namespace CTElectricGenerator { // Default Constructor ReportVars() - : PowerGen(0.0), EnergyGen(0.0), QTotalHeatRecovered(0.0), QLubeOilRecovered(0.0), QExhaustRecovered(0.0), TotalHeatEnergyRec(0.0), + : QTotalHeatRecovered(0.0), QLubeOilRecovered(0.0), QExhaustRecovered(0.0), TotalHeatEnergyRec(0.0), LubeOilEnergyRec(0.0), ExhaustEnergyRec(0.0), FuelEnergyUseRate(0.0), FuelEnergy(0.0), FuelMdot(0.0), ExhaustStackTemp(0.0), HeatRecInletTemp(0.0), HeatRecOutletTemp(0.0), HeatRecMdot(0.0) { @@ -198,22 +199,22 @@ namespace CTElectricGenerator { void GetCTGeneratorInput(); - void CalcCTGeneratorModel(int GeneratorNum, // Generator number + void CalcCTGeneratorModel(int genNum, // Generator number bool RunFlag, // TRUE when Generator operating Real64 MyLoad, // Generator demand bool FirstHVACIteration); - void InitCTGenerators(int GeneratorNum, // Generator number + void InitCTGenerators(int genNum, // Generator number bool RunFlag, // TRUE when Generator operating Real64 MyLoad, // Generator demand bool FirstHVACIteration); void UpdateCTGeneratorRecords(bool RunFlag, // TRUE if Generator operating - int Num // Generator number + int genNUm // Generator number ); void GetCTGeneratorResults(int GeneratorType, // type of Generator - int GeneratorIndex, + int genNum, Real64 &GeneratorPower, // electrical power Real64 &GeneratorEnergy, // electrical energy Real64 &ThermalPower, // heat power From f59f12dbcfee894d59665e02cc1462c3ff3d55c3 Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Tue, 15 Oct 2019 16:23:36 -0600 Subject: [PATCH 06/13] integrate report vars --- src/EnergyPlus/CTElectricGenerator.cc | 51 +++++++++------------------ src/EnergyPlus/CTElectricGenerator.hh | 29 --------------- 2 files changed, 17 insertions(+), 63 deletions(-) diff --git a/src/EnergyPlus/CTElectricGenerator.cc b/src/EnergyPlus/CTElectricGenerator.cc index dd1f0732ca2..b925349a915 100644 --- a/src/EnergyPlus/CTElectricGenerator.cc +++ b/src/EnergyPlus/CTElectricGenerator.cc @@ -99,7 +99,6 @@ namespace CTElectricGenerator { bool GetCTInput(true); // then TRUE, calls subroutine to read input file. Array1D CTGenerator; // dimension to number of machines - Array1D CTGeneratorReport; void SimCTGenerator(int const EP_UNUSED(GeneratorType), // type of Generator std::string const &GeneratorName, // user specified name of Generator @@ -227,8 +226,6 @@ namespace CTElectricGenerator { // ALLOCATE ARRAYS CTGenerator.allocate(NumCTGenerators); - CTGeneratorReport.allocate(NumCTGenerators); - // LOAD ARRAYS WITH CT CURVE FIT Generator DATA for (genNum = 1; genNum <= NumCTGenerators; ++genNum) { inputProcessor->getObjectItem(DataIPShortCuts::cCurrentModuleObject, @@ -427,13 +424,13 @@ namespace CTElectricGenerator { SetupOutputVariable("Generator " + CTGenerator(genNum).FuelType + " Rate", OutputProcessor::Unit::W, - CTGeneratorReport(genNum).FuelEnergyUseRate, + CTGenerator(genNum).FuelEnergyUseRate, "System", "Average", CTGenerator(genNum).Name); SetupOutputVariable("Generator " + CTGenerator(genNum).FuelType + " Energy", OutputProcessor::Unit::J, - CTGeneratorReport(genNum).FuelEnergy, + CTGenerator(genNum).FuelEnergy, "System", "Sum", CTGenerator(genNum).Name, @@ -446,27 +443,27 @@ namespace CTElectricGenerator { // general fuel use report (to match other generators) SetupOutputVariable("Generator Fuel HHV Basis Rate", OutputProcessor::Unit::W, - CTGeneratorReport(genNum).FuelEnergyUseRate, + CTGenerator(genNum).FuelEnergyUseRate, "System", "Average", CTGenerator(genNum).Name); SetupOutputVariable("Generator Fuel HHV Basis Energy", OutputProcessor::Unit::J, - CTGeneratorReport(genNum).FuelEnergy, + CTGenerator(genNum).FuelEnergy, "System", "Sum", CTGenerator(genNum).Name); SetupOutputVariable("Generator " + CTGenerator(genNum).FuelType + " Mass Flow Rate", OutputProcessor::Unit::kg_s, - CTGeneratorReport(genNum).FuelMdot, + CTGenerator(genNum).FuelMdot, "System", "Average", CTGenerator(genNum).Name); SetupOutputVariable("Generator Exhaust Air Temperature", OutputProcessor::Unit::C, - CTGeneratorReport(genNum).ExhaustStackTemp, + CTGenerator(genNum).ExhaustStackTemp, "System", "Average", CTGenerator(genNum).Name); @@ -474,13 +471,13 @@ namespace CTElectricGenerator { if (CTGenerator(genNum).HeatRecActive) { SetupOutputVariable("Generator Exhaust Heat Recovery Rate", OutputProcessor::Unit::W, - CTGeneratorReport(genNum).QExhaustRecovered, + CTGenerator(genNum).QExhaustRecovered, "System", "Average", CTGenerator(genNum).Name); SetupOutputVariable("Generator Exhaust Heat Recovery Energy", OutputProcessor::Unit::J, - CTGeneratorReport(genNum).ExhaustEnergyRec, + CTGenerator(genNum).ExhaustEnergyRec, "System", "Sum", CTGenerator(genNum).Name, @@ -492,13 +489,13 @@ namespace CTElectricGenerator { SetupOutputVariable("Generator Lube Heat Recovery Rate", OutputProcessor::Unit::W, - CTGeneratorReport(genNum).QLubeOilRecovered, + CTGenerator(genNum).QLubeOilRecovered, "System", "Average", CTGenerator(genNum).Name); SetupOutputVariable("Generator Lube Heat Recovery Energy", OutputProcessor::Unit::J, - CTGeneratorReport(genNum).LubeOilEnergyRec, + CTGenerator(genNum).LubeOilEnergyRec, "System", "Sum", CTGenerator(genNum).Name, @@ -510,32 +507,32 @@ namespace CTElectricGenerator { SetupOutputVariable("Generator Produced Thermal Rate", OutputProcessor::Unit::W, - CTGeneratorReport(genNum).QTotalHeatRecovered, + CTGenerator(genNum).QTotalHeatRecovered, "System", "Average", CTGenerator(genNum).Name); SetupOutputVariable("Generator Produced Thermal Energy", OutputProcessor::Unit::J, - CTGeneratorReport(genNum).TotalHeatEnergyRec, + CTGenerator(genNum).TotalHeatEnergyRec, "System", "Sum", CTGenerator(genNum).Name); SetupOutputVariable("Generator Heat Recovery Inlet Temperature", OutputProcessor::Unit::C, - CTGeneratorReport(genNum).HeatRecInletTemp, + CTGenerator(genNum).HeatRecInletTemp, "System", "Average", CTGenerator(genNum).Name); SetupOutputVariable("Generator Heat Recovery Outlet Temperature", OutputProcessor::Unit::C, - CTGeneratorReport(genNum).HeatRecOutletTemp, + CTGenerator(genNum).HeatRecOutletTemp, "System", "Average", CTGenerator(genNum).Name); SetupOutputVariable("Generator Heat Recovery Mass Flow Rate", OutputProcessor::Unit::kg_s, - CTGeneratorReport(genNum).HeatRecMdot, + CTGenerator(genNum).HeatRecMdot, "System", "Average", CTGenerator(genNum).Name); @@ -704,7 +701,6 @@ namespace CTElectricGenerator { } // Now verify the maximum temperature was not exceeded - HRecRatio = 1.0; MinHeatRecMdot = 0.0; if (HeatRecOutTemp > CTGenerator(genNum).HeatRecMaxTemp) { if (CTGenerator(genNum).HeatRecMaxTemp != HeatRecInTemp) { @@ -892,19 +888,6 @@ namespace CTElectricGenerator { HeatRecOutletNode = CTGenerator(genNUm).HeatRecOutletNodeNum; DataLoopNode::Node(HeatRecOutletNode).Temp = CTGenerator(genNUm).HeatRecOutletTemp; } - CTGeneratorReport(genNUm).QExhaustRecovered = CTGenerator(genNUm).QExhaustRecovered; - CTGeneratorReport(genNUm).QLubeOilRecovered = CTGenerator(genNUm).QLubeOilRecovered; - CTGeneratorReport(genNUm).ExhaustEnergyRec = CTGenerator(genNUm).ExhaustEnergyRec; - CTGeneratorReport(genNUm).LubeOilEnergyRec = CTGenerator(genNUm).LubeOilEnergyRec; - CTGeneratorReport(genNUm).QTotalHeatRecovered = CTGenerator(genNUm).QTotalHeatRecovered; - CTGeneratorReport(genNUm).TotalHeatEnergyRec = CTGenerator(genNUm).TotalHeatEnergyRec; - CTGeneratorReport(genNUm).FuelEnergyUseRate = CTGenerator(genNUm).FuelEnergyUseRate; - CTGeneratorReport(genNUm).FuelEnergy = CTGenerator(genNUm).FuelEnergy; - CTGeneratorReport(genNUm).FuelMdot = CTGenerator(genNUm).FuelMdot; - CTGeneratorReport(genNUm).ExhaustStackTemp = CTGenerator(genNUm).ExhaustStackTemp; - CTGeneratorReport(genNUm).HeatRecInletTemp = CTGenerator(genNUm).HeatRecInletTemp; - CTGeneratorReport(genNUm).HeatRecOutletTemp = CTGenerator(genNUm).HeatRecOutletTemp; - CTGeneratorReport(genNUm).HeatRecMdot = CTGenerator(genNUm).HeatRecMdot; } void GetCTGeneratorResults(int const EP_UNUSED(GeneratorType), // type of Generator @@ -926,8 +909,8 @@ namespace CTElectricGenerator { GeneratorPower = CTGenerator(genNum).ElecPowerGenerated; GeneratorEnergy = CTGenerator(genNum).ElecEnergyGenerated; - ThermalPower = CTGeneratorReport(genNum).QTotalHeatRecovered; - ThermalEnergy = CTGeneratorReport(genNum).TotalHeatEnergyRec; + ThermalPower = CTGenerator(genNum).QTotalHeatRecovered; + ThermalEnergy = CTGenerator(genNum).TotalHeatEnergyRec; } } // namespace CTElectricGenerator diff --git a/src/EnergyPlus/CTElectricGenerator.hh b/src/EnergyPlus/CTElectricGenerator.hh index af9f9abbb7a..9940ac255b7 100644 --- a/src/EnergyPlus/CTElectricGenerator.hh +++ b/src/EnergyPlus/CTElectricGenerator.hh @@ -144,37 +144,8 @@ namespace CTElectricGenerator { } }; - struct ReportVars - { - // Members -// Real64 PowerGen; // reporting: power (W) -// Real64 EnergyGen; // reporting: power (W) - Real64 QTotalHeatRecovered; // reporting: total Heat Recovered (W) - Real64 QLubeOilRecovered; // reporting: Heat Recovered from Lubricant (W) - Real64 QExhaustRecovered; // reporting: Heat Recovered from exhaust (W) - Real64 TotalHeatEnergyRec; // reporting: total Heat Recovered (W) - Real64 LubeOilEnergyRec; // reporting: Heat Recovered from Lubricant (W) - Real64 ExhaustEnergyRec; // reporting: Heat Recovered from exhaust (W) - Real64 FuelEnergyUseRate; // reporting: Fuel Energy use rate (W) - Real64 FuelEnergy; // reporting: Fuel Energy used (J) - Real64 FuelMdot; // reporting: Fuel Amount used (kg/s) - Real64 ExhaustStackTemp; // reporting: Exhaust Stack Temperature (C) - 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) - - // Default Constructor - ReportVars() - : QTotalHeatRecovered(0.0), QLubeOilRecovered(0.0), QExhaustRecovered(0.0), TotalHeatEnergyRec(0.0), - LubeOilEnergyRec(0.0), ExhaustEnergyRec(0.0), FuelEnergyUseRate(0.0), FuelEnergy(0.0), FuelMdot(0.0), ExhaustStackTemp(0.0), - HeatRecInletTemp(0.0), HeatRecOutletTemp(0.0), HeatRecMdot(0.0) - { - } - }; - // Object Data extern Array1D CTGenerator; // dimension to number of machines - extern Array1D CTGeneratorReport; // Static functions void SimCTGenerator(int GeneratorType, // type of Generator From a86a72d71c7f004c8d41ab792ba487702f89f6d5 Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Tue, 15 Oct 2019 16:40:45 -0600 Subject: [PATCH 07/13] cleanup local vars --- src/EnergyPlus/CTElectricGenerator.cc | 134 +++++++++++++------------- 1 file changed, 69 insertions(+), 65 deletions(-) diff --git a/src/EnergyPlus/CTElectricGenerator.cc b/src/EnergyPlus/CTElectricGenerator.cc index b925349a915..feae7cdc1c9 100644 --- a/src/EnergyPlus/CTElectricGenerator.cc +++ b/src/EnergyPlus/CTElectricGenerator.cc @@ -207,7 +207,6 @@ namespace CTElectricGenerator { // This routine will get the input // required by the CT Generator models. - int genNum; // 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 @@ -227,7 +226,7 @@ namespace CTElectricGenerator { CTGenerator.allocate(NumCTGenerators); // LOAD ARRAYS WITH CT CURVE FIT Generator DATA - for (genNum = 1; genNum <= NumCTGenerators; ++genNum) { + for (int genNum = 1; genNum <= NumCTGenerators; ++genNum) { inputProcessor->getObjectItem(DataIPShortCuts::cCurrentModuleObject, genNum, AlphArray, @@ -403,7 +402,7 @@ namespace CTElectricGenerator { ShowFatalError("Errors found in processing input for " + DataIPShortCuts::cCurrentModuleObject); } - for (genNum = 1; genNum <= NumCTGenerators; ++genNum) { + for (int genNum = 1; genNum <= NumCTGenerators; ++genNum) { SetupOutputVariable("Generator Produced Electric Power", OutputProcessor::Unit::W, CTGenerator(genNum).ElecPowerGenerated, @@ -562,43 +561,27 @@ namespace CTElectricGenerator { Real64 const KJtoJ(1000.0); // convert Kjoules to joules static std::string const RoutineName("CalcCTGeneratorModel"); - Real64 MinPartLoadRat; // min allowed operating frac full load - Real64 MaxPartLoadRat; // max allowed operating frac full load - Real64 RatedPowerOutput; // Generator nominal capacity (W) - Real64 ElecPowerGenerated; // Generator output (W) - Real64 ElectricEnergyGen; // Generator output (J) - - Real64 MaxExhaustperCTPower; // MAX EXHAUST FLOW PER W POWER OUTPUT COEFF - Real64 PLR; // Generator operating part load ratio - Real64 FuelUseRate; // (EFUEL) rate of Fuel Energy Required to run COMBUSTION turbine (W) - Real64 FuelEnergyUsed; // Amount of Fuel Energy Required to run COMBUSTION turbine (J) - Real64 ExhaustFlow; // (FEX) Exhaust Gas Flow Rate cubic meters per second??? - Real64 ExhaustTemp; // (TEX) Exhaust Gas Temperature in C - Real64 UA; // (UACGC) Heat Exchanger UA to Capacity - Real64 AmbientDeltaT; // (ATAIR) Difference between ambient actual and ambient design temperatures - Real64 DesignAirInletTemp; // design turbine inlet temperature (C) - Real64 QLubeOilRec; // recovered lube oil heat (W) - Real64 QExhaustRec; // recovered exhaust heat (W) - Real64 LubeOilEnergyRec; // recovered lube oil heat (J) - Real64 ExhaustEnergyRec; // recovered exhaust heat (J) - Real64 MinHeatRecMdot; // Heat Recovery Flow Rate if minimal heat recovery is accomplished - Real64 DesignMinExitGasTemp; // design engine stact saturated steam temp. (C) - Real64 ExhaustStackTemp; // turbine stack temp. (C) - int HeatRecInNode; // Heat Recovery Fluid Inlet Node Num - // notused INTEGER :: HeatRecOutNode !Heat Recovery Fluid Outlet Node Num - Real64 HeatRecInTemp; // Heat Recovery Fluid Inlet Temperature (C) - Real64 HeatRecOutTemp; // Heat Recovery Fluid Outlet Temperature (C) + // min allowed operating frac full load + Real64 MinPartLoadRat = CTGenerator(genNum).MinPartLoadRat; + + // max allowed operating frac full load + Real64 MaxPartLoadRat = CTGenerator(genNum).MaxPartLoadRat; + + // Generator nominal capacity (W) + Real64 RatedPowerOutput = CTGenerator(genNum).RatedPowerOutput; + + // MAX EXHAUST FLOW PER W POWER OUTPUT COEFF + Real64 MaxExhaustperCTPower = CTGenerator(genNum).MaxExhaustperCTPower; + + // design turbine inlet temperature (C) + Real64 DesignAirInletTemp = CTGenerator(genNum).DesignAirInletTemp; + + int HeatRecInNode; // Heat Recovery Fluid Inlet Node Num + Real64 HeatRecInTemp; // Heat Recovery Fluid Inlet Temperature (C) + Real64 HeatRecMdot; // Heat Recovery Fluid Mass FlowRate (kg/s) Real64 HeatRecCp; // Specific Heat of the Heat Recovery Fluid (J/kg-K) - Real64 FuelHeatingValue; // Heating Value of Fuel in (kJ/kg) - Real64 HRecRatio; // When Max Temp is reached the amount of recovered heat has to be reduced. - // and this assumption uses this ratio to accomplish this task. - MinPartLoadRat = CTGenerator(genNum).MinPartLoadRat; - MaxPartLoadRat = CTGenerator(genNum).MaxPartLoadRat; - RatedPowerOutput = CTGenerator(genNum).RatedPowerOutput; - MaxExhaustperCTPower = CTGenerator(genNum).MaxExhaustperCTPower; - DesignAirInletTemp = CTGenerator(genNum).DesignAirInletTemp; if (CTGenerator(genNum).HeatRecActive) { HeatRecInNode = CTGenerator(genNum).HeatRecInletNodeNum; HeatRecInTemp = DataLoopNode::Node(HeatRecInNode).Temp; @@ -639,14 +622,18 @@ namespace CTElectricGenerator { } // CALCULATE POWER GENERATED AND PLR - ElecPowerGenerated = min(MyLoad, RatedPowerOutput); + // Generator output (W) + Real64 ElecPowerGenerated = min(MyLoad, RatedPowerOutput); ElecPowerGenerated = max(ElecPowerGenerated, 0.0); - PLR = min(ElecPowerGenerated / RatedPowerOutput, MaxPartLoadRat); + + // Generator operating part load ratio + Real64 PLR = min(ElecPowerGenerated / RatedPowerOutput, MaxPartLoadRat); PLR = max(PLR, MinPartLoadRat); ElecPowerGenerated = PLR * RatedPowerOutput; // SET OFF-DESIGN AIR TEMPERATURE DIFFERENCE - // use OA node if set by user CR7021 + // (ATAIR) Difference between ambient actual and ambient design temperatures + Real64 AmbientDeltaT; if (CTGenerator(genNum).OAInletNode == 0) { AmbientDeltaT = DataEnvironment::OutDryBulbTemp - DesignAirInletTemp; } else { @@ -657,25 +644,34 @@ namespace CTElectricGenerator { // energy input is calculated in J/s. The PLBasedFuelInputCurve selects ratio of fuel flow (J/s)/power generated (J/s). // The TempBasedFuelInputCurve is a correction based on deviation from design inlet air temperature conditions. // The first coefficient of this fit should be 1.0 to ensure that no correction is made at design conditions. - FuelUseRate = ElecPowerGenerated * CurveManager::CurveValue(CTGenerator(genNum).PLBasedFuelInputCurve, PLR) * + // (EFUEL) rate of Fuel Energy Required to run COMBUSTION turbine (W) + Real64 FuelUseRate = ElecPowerGenerated * CurveManager::CurveValue(CTGenerator(genNum).PLBasedFuelInputCurve, PLR) * CurveManager::CurveValue(CTGenerator(genNum).TempBasedFuelInputCurve, AmbientDeltaT); // Use Curve fit to determine Exhaust Flow. This curve shows the ratio of exhaust gas flow (kg/s) to electric power // output (J/s). The units on ExhaustFlowCurve are (kg/J). When multiplied by the rated power of the unit, // it gives the exhaust flow rate in kg/s - ExhaustFlow = RatedPowerOutput * CurveManager::CurveValue(CTGenerator(genNum).ExhaustFlowCurve, AmbientDeltaT); + // (FEX) Exhaust Gas Flow Rate cubic meters per second??? + Real64 ExhaustFlow = RatedPowerOutput * CurveManager::CurveValue(CTGenerator(genNum).ExhaustFlowCurve, AmbientDeltaT); // Use Curve fit to determine Exhaust Temperature. This curve calculates the exhaust temperature (C) by // multiplying the exhaust temperature (C) for a particular part load as given by PLBasedExhaustTempCurve // a correction factor based on the deviation from design temperature, TempBasedExhaustTempCurve + + Real64 QExhaustRec; // recovered exhaust heat (W) + Real64 ExhaustStackTemp; // turbine stack temp. (C) if ((PLR > 0.0) && ((ExhaustFlow > 0.0) || (MaxExhaustperCTPower > 0.0))) { - ExhaustTemp = CurveManager::CurveValue(CTGenerator(genNum).PLBasedExhaustTempCurve, PLR) * + // (TEX) Exhaust Gas Temperature in C + Real64 ExhaustTemp = CurveManager::CurveValue(CTGenerator(genNum).PLBasedExhaustTempCurve, PLR) * CurveManager::CurveValue(CTGenerator(genNum).TempBasedExhaustTempCurve, AmbientDeltaT); - UA = CTGenerator(genNum).UACoef(1) * std::pow(RatedPowerOutput, CTGenerator(genNum).UACoef(2)); + // (UACGC) Heat Exchanger UA to Capacity + Real64 UA = CTGenerator(genNum).UACoef(1) * std::pow(RatedPowerOutput, CTGenerator(genNum).UACoef(2)); + + // design engine stack saturated steam temp. (C) + Real64 DesignMinExitGasTemp = CTGenerator(genNum).DesignMinExitGasTemp; - DesignMinExitGasTemp = CTGenerator(genNum).DesignMinExitGasTemp; ExhaustStackTemp = DesignMinExitGasTemp + (ExhaustTemp - DesignMinExitGasTemp) / std::exp(UA / (max(ExhaustFlow, MaxExhaustperCTPower * RatedPowerOutput) * ExhaustCP)); @@ -688,9 +684,11 @@ namespace CTElectricGenerator { // Use Curve fit to determine Heat Recovered Lubricant heat. This curve calculates the lube heat recovered (J/s) by // multiplying the total power generated by the fraction of that power that could be recovered in the lube oil at that // particular part load. - QLubeOilRec = ElecPowerGenerated * CurveManager::CurveValue(CTGenerator(genNum).QLubeOilRecoveredCurve, PLR); + // recovered lube oil heat (W) + Real64 QLubeOilRec = ElecPowerGenerated * CurveManager::CurveValue(CTGenerator(genNum).QLubeOilRecoveredCurve, PLR); // Check for divide by zero + Real64 HeatRecOutTemp; // Heat Recovery Fluid Outlet Temperature (C) if ((HeatRecMdot > 0.0) && (HeatRecCp > 0.0)) { HeatRecOutTemp = (QExhaustRec + QLubeOilRec) / (HeatRecMdot * HeatRecCp) + HeatRecInTemp; } else { @@ -701,7 +699,11 @@ namespace CTElectricGenerator { } // Now verify the maximum temperature was not exceeded - MinHeatRecMdot = 0.0; + // Heat Recovery Flow Rate if minimal heat recovery is accomplished + Real64 MinHeatRecMdot = 0.0; + + Real64 HRecRatio; // When Max Temp is reached the amount of recovered heat has to be reduced. + if (HeatRecOutTemp > CTGenerator(genNum).HeatRecMaxTemp) { if (CTGenerator(genNum).HeatRecMaxTemp != HeatRecInTemp) { MinHeatRecMdot = (QExhaustRec + QLubeOilRec) / (HeatRecCp * (CTGenerator(genNum).HeatRecMaxTemp - HeatRecInTemp)); @@ -721,10 +723,17 @@ namespace CTElectricGenerator { } // Calculate Energy - ElectricEnergyGen = ElecPowerGenerated * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - FuelEnergyUsed = FuelUseRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - LubeOilEnergyRec = QLubeOilRec * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - ExhaustEnergyRec = QExhaustRec * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + // Generator output (J) + Real64 ElectricEnergyGen = ElecPowerGenerated * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + + // Amount of Fuel Energy Required to run COMBUSTION turbine (J) + Real64 FuelEnergyUsed = FuelUseRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + + // recovered lube oil heat (J) + Real64 LubeOilEnergyRec = QLubeOilRec * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + + // recovered exhaust heat (J) + Real64 ExhaustEnergyRec = QExhaustRec * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; CTGenerator(genNum).ElecPowerGenerated = ElecPowerGenerated; CTGenerator(genNum).ElecEnergyGenerated = ElectricEnergyGen; @@ -742,7 +751,8 @@ namespace CTElectricGenerator { CTGenerator(genNum).TotalHeatEnergyRec = ExhaustEnergyRec + LubeOilEnergyRec; CTGenerator(genNum).FuelEnergy = std::abs(FuelEnergyUsed); - FuelHeatingValue = CTGenerator(genNum).FuelHeatingValue; + // Heating Value of Fuel in (kJ/kg) + Real64 FuelHeatingValue = CTGenerator(genNum).FuelHeatingValue; CTGenerator(genNum).FuelMdot = std::abs(FuelUseRate) / (FuelHeatingValue * KJtoJ); @@ -765,13 +775,8 @@ namespace CTElectricGenerator { // This subroutine is for initializations of the CT generators. static std::string const RoutineName("InitICEngineGenerators"); - - int HeatRecInletNode; // inlet node number in heat recovery loop - int HeatRecOutletNode; // outlet node number in heat recovery loop static bool MyOneTimeFlag(true); // Initialization flag - Real64 mdot; - Real64 rho; bool errFlag; // Do the one time initializations @@ -800,11 +805,11 @@ namespace CTElectricGenerator { } if (CTGenerator(genNum).MySizeAndNodeInitFlag && (!CTGenerator(genNum).MyPlantScanFlag) && CTGenerator(genNum).HeatRecActive) { - HeatRecInletNode = CTGenerator(genNum).HeatRecInletNodeNum; - HeatRecOutletNode = CTGenerator(genNum).HeatRecOutletNodeNum; + int HeatRecInletNode = CTGenerator(genNum).HeatRecInletNodeNum; + int HeatRecOutletNode = CTGenerator(genNum).HeatRecOutletNodeNum; // size mass flow rate - rho = FluidProperties::GetDensityGlycol(DataPlant::PlantLoop(CTGenerator(genNum).HRLoopNum).FluidName, + Real64 rho = FluidProperties::GetDensityGlycol(DataPlant::PlantLoop(CTGenerator(genNum).HRLoopNum).FluidName, DataGlobals::InitConvTemp, DataPlant::PlantLoop(CTGenerator(genNum).HRLoopNum).FluidIndex, RoutineName); @@ -825,8 +830,8 @@ namespace CTElectricGenerator { // Do the Begin Environment initializations if (DataGlobals::BeginEnvrnFlag && CTGenerator(genNum).MyEnvrnFlag && CTGenerator(genNum).HeatRecActive) { - HeatRecInletNode = CTGenerator(genNum).HeatRecInletNodeNum; - HeatRecOutletNode = CTGenerator(genNum).HeatRecOutletNodeNum; + int HeatRecInletNode = CTGenerator(genNum).HeatRecInletNodeNum; + int HeatRecOutletNode = CTGenerator(genNum).HeatRecOutletNodeNum; // set the node Temperature, assuming freeze control DataLoopNode::Node(HeatRecInletNode).Temp = 20.0; DataLoopNode::Node(HeatRecOutletNode).Temp = 20.0; @@ -849,6 +854,7 @@ namespace CTElectricGenerator { if (CTGenerator(genNum).HeatRecActive) { if (FirstHVACIteration) { + Real64 mdot; if (RunFlag) { mdot = CTGenerator(genNum).DesignHeatRecMassFlowRate; } else { @@ -882,10 +888,8 @@ namespace CTElectricGenerator { // AUTHOR: Dan Fisher // DATE WRITTEN: October 1998 - int HeatRecOutletNode; - if (CTGenerator(genNUm).HeatRecActive) { - HeatRecOutletNode = CTGenerator(genNUm).HeatRecOutletNodeNum; + int HeatRecOutletNode = CTGenerator(genNUm).HeatRecOutletNodeNum; DataLoopNode::Node(HeatRecOutletNode).Temp = CTGenerator(genNUm).HeatRecOutletTemp; } } From 478910d66e966ece313298067732b836561baa96 Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Tue, 15 Oct 2019 16:53:44 -0600 Subject: [PATCH 08/13] functions to members --- src/EnergyPlus/CTElectricGenerator.cc | 228 +++++++++++++------------- src/EnergyPlus/CTElectricGenerator.hh | 25 ++- 2 files changed, 121 insertions(+), 132 deletions(-) diff --git a/src/EnergyPlus/CTElectricGenerator.cc b/src/EnergyPlus/CTElectricGenerator.cc index feae7cdc1c9..db6ed5a6b46 100644 --- a/src/EnergyPlus/CTElectricGenerator.cc +++ b/src/EnergyPlus/CTElectricGenerator.cc @@ -145,9 +145,11 @@ namespace CTElectricGenerator { } } - InitCTGenerators(genNum, RunFlag, MyLoad, FirstHVACIteration); - CalcCTGeneratorModel(genNum, RunFlag, MyLoad, FirstHVACIteration); - UpdateCTGeneratorRecords(RunFlag, genNum); + auto &thisCTG = CTGenerator(genNum); + + thisCTG.InitCTGenerators(RunFlag, MyLoad, FirstHVACIteration); + thisCTG.CalcCTGeneratorModel(RunFlag, MyLoad, FirstHVACIteration); + thisCTG.UpdateCTGeneratorRecords(); } void SimCTPlantHeatRecovery(std::string const &EP_UNUSED(CompType), // unused1208 @@ -191,12 +193,6 @@ namespace CTElectricGenerator { } // End Of InitLoopEquip } - // End CT Generator Module Driver Subroutines - //****************************************************************************** - - // Beginning of CT Generator Module Get Input subroutines - //****************************************************************************** - void GetCTGeneratorInput() { // SUBROUTINE INFORMATION: @@ -539,8 +535,7 @@ namespace CTElectricGenerator { } } - void CalcCTGeneratorModel(int const genNum, // Generator number - bool const RunFlag, // TRUE when Generator operating + void CTGeneratorSpecs::CalcCTGeneratorModel(bool const RunFlag, // TRUE when Generator operating Real64 const MyLoad, // Generator demand bool const FirstHVACIteration) { @@ -562,19 +557,19 @@ namespace CTElectricGenerator { static std::string const RoutineName("CalcCTGeneratorModel"); // min allowed operating frac full load - Real64 MinPartLoadRat = CTGenerator(genNum).MinPartLoadRat; + Real64 MinPartLoadRat = this->MinPartLoadRat; // max allowed operating frac full load - Real64 MaxPartLoadRat = CTGenerator(genNum).MaxPartLoadRat; + Real64 MaxPartLoadRat = this->MaxPartLoadRat; // Generator nominal capacity (W) - Real64 RatedPowerOutput = CTGenerator(genNum).RatedPowerOutput; + Real64 RatedPowerOutput = this->RatedPowerOutput; // MAX EXHAUST FLOW PER W POWER OUTPUT COEFF - Real64 MaxExhaustperCTPower = CTGenerator(genNum).MaxExhaustperCTPower; + Real64 MaxExhaustperCTPower = this->MaxExhaustperCTPower; // design turbine inlet temperature (C) - Real64 DesignAirInletTemp = CTGenerator(genNum).DesignAirInletTemp; + Real64 DesignAirInletTemp = this->DesignAirInletTemp; int HeatRecInNode; // Heat Recovery Fluid Inlet Node Num Real64 HeatRecInTemp; // Heat Recovery Fluid Inlet Temperature (C) @@ -582,16 +577,16 @@ namespace CTElectricGenerator { Real64 HeatRecMdot; // Heat Recovery Fluid Mass FlowRate (kg/s) Real64 HeatRecCp; // Specific Heat of the Heat Recovery Fluid (J/kg-K) - if (CTGenerator(genNum).HeatRecActive) { - HeatRecInNode = CTGenerator(genNum).HeatRecInletNodeNum; + if (this->HeatRecActive) { + HeatRecInNode = this->HeatRecInletNodeNum; HeatRecInTemp = DataLoopNode::Node(HeatRecInNode).Temp; - HeatRecCp = FluidProperties::GetSpecificHeatGlycol(DataPlant::PlantLoop(CTGenerator(genNum).HRLoopNum).FluidName, + HeatRecCp = FluidProperties::GetSpecificHeatGlycol(DataPlant::PlantLoop(this->HRLoopNum).FluidName, HeatRecInTemp, - DataPlant::PlantLoop(CTGenerator(genNum).HRLoopNum).FluidIndex, + DataPlant::PlantLoop(this->HRLoopNum).FluidIndex, RoutineName); if (FirstHVACIteration && RunFlag) { - HeatRecMdot = CTGenerator(genNum).DesignHeatRecMassFlowRate; + HeatRecMdot = this->DesignHeatRecMassFlowRate; } else { HeatRecMdot = DataLoopNode::Node(HeatRecInNode).MassFlowRate; } @@ -603,21 +598,21 @@ namespace CTElectricGenerator { // If no loop demand or Generator OFF, return if (!RunFlag) { - CTGenerator(genNum).ElecPowerGenerated = 0.0; - CTGenerator(genNum).ElecEnergyGenerated = 0.0; - CTGenerator(genNum).HeatRecInletTemp = HeatRecInTemp; - CTGenerator(genNum).HeatRecOutletTemp = HeatRecInTemp; - CTGenerator(genNum).HeatRecMdot = 0.0; - CTGenerator(genNum).QLubeOilRecovered = 0.0; - CTGenerator(genNum).QExhaustRecovered = 0.0; - CTGenerator(genNum).QTotalHeatRecovered = 0.0; - CTGenerator(genNum).LubeOilEnergyRec = 0.0; - CTGenerator(genNum).ExhaustEnergyRec = 0.0; - CTGenerator(genNum).TotalHeatEnergyRec = 0.0; - CTGenerator(genNum).FuelEnergyUseRate = 0.0; - CTGenerator(genNum).FuelEnergy = 0.0; - CTGenerator(genNum).FuelMdot = 0.0; - CTGenerator(genNum).ExhaustStackTemp = 0.0; + this->ElecPowerGenerated = 0.0; + this->ElecEnergyGenerated = 0.0; + this->HeatRecInletTemp = HeatRecInTemp; + this->HeatRecOutletTemp = HeatRecInTemp; + this->HeatRecMdot = 0.0; + this->QLubeOilRecovered = 0.0; + this->QExhaustRecovered = 0.0; + this->QTotalHeatRecovered = 0.0; + this->LubeOilEnergyRec = 0.0; + this->ExhaustEnergyRec = 0.0; + this->TotalHeatEnergyRec = 0.0; + this->FuelEnergyUseRate = 0.0; + this->FuelEnergy = 0.0; + this->FuelMdot = 0.0; + this->ExhaustStackTemp = 0.0; return; } @@ -634,10 +629,10 @@ namespace CTElectricGenerator { // SET OFF-DESIGN AIR TEMPERATURE DIFFERENCE // (ATAIR) Difference between ambient actual and ambient design temperatures Real64 AmbientDeltaT; - if (CTGenerator(genNum).OAInletNode == 0) { + if (this->OAInletNode == 0) { AmbientDeltaT = DataEnvironment::OutDryBulbTemp - DesignAirInletTemp; } else { - AmbientDeltaT = DataLoopNode::Node(CTGenerator(genNum).OAInletNode).Temp - DesignAirInletTemp; + AmbientDeltaT = DataLoopNode::Node(this->OAInletNode).Temp - DesignAirInletTemp; } // Use Curve fit to determine Fuel Energy Input. For electric power generated in Watts, the fuel @@ -645,14 +640,14 @@ namespace CTElectricGenerator { // The TempBasedFuelInputCurve is a correction based on deviation from design inlet air temperature conditions. // The first coefficient of this fit should be 1.0 to ensure that no correction is made at design conditions. // (EFUEL) rate of Fuel Energy Required to run COMBUSTION turbine (W) - Real64 FuelUseRate = ElecPowerGenerated * CurveManager::CurveValue(CTGenerator(genNum).PLBasedFuelInputCurve, PLR) * - CurveManager::CurveValue(CTGenerator(genNum).TempBasedFuelInputCurve, AmbientDeltaT); + Real64 FuelUseRate = ElecPowerGenerated * CurveManager::CurveValue(this->PLBasedFuelInputCurve, PLR) * + CurveManager::CurveValue(this->TempBasedFuelInputCurve, AmbientDeltaT); // Use Curve fit to determine Exhaust Flow. This curve shows the ratio of exhaust gas flow (kg/s) to electric power // output (J/s). The units on ExhaustFlowCurve are (kg/J). When multiplied by the rated power of the unit, // it gives the exhaust flow rate in kg/s // (FEX) Exhaust Gas Flow Rate cubic meters per second??? - Real64 ExhaustFlow = RatedPowerOutput * CurveManager::CurveValue(CTGenerator(genNum).ExhaustFlowCurve, AmbientDeltaT); + Real64 ExhaustFlow = RatedPowerOutput * CurveManager::CurveValue(this->ExhaustFlowCurve, AmbientDeltaT); // Use Curve fit to determine Exhaust Temperature. This curve calculates the exhaust temperature (C) by // multiplying the exhaust temperature (C) for a particular part load as given by PLBasedExhaustTempCurve @@ -663,21 +658,21 @@ namespace CTElectricGenerator { if ((PLR > 0.0) && ((ExhaustFlow > 0.0) || (MaxExhaustperCTPower > 0.0))) { // (TEX) Exhaust Gas Temperature in C - Real64 ExhaustTemp = CurveManager::CurveValue(CTGenerator(genNum).PLBasedExhaustTempCurve, PLR) * - CurveManager::CurveValue(CTGenerator(genNum).TempBasedExhaustTempCurve, AmbientDeltaT); + Real64 ExhaustTemp = CurveManager::CurveValue(this->PLBasedExhaustTempCurve, PLR) * + CurveManager::CurveValue(this->TempBasedExhaustTempCurve, AmbientDeltaT); // (UACGC) Heat Exchanger UA to Capacity - Real64 UA = CTGenerator(genNum).UACoef(1) * std::pow(RatedPowerOutput, CTGenerator(genNum).UACoef(2)); + Real64 UA = this->UACoef(1) * std::pow(RatedPowerOutput, this->UACoef(2)); // design engine stack saturated steam temp. (C) - Real64 DesignMinExitGasTemp = CTGenerator(genNum).DesignMinExitGasTemp; + Real64 DesignMinExitGasTemp = this->DesignMinExitGasTemp; ExhaustStackTemp = DesignMinExitGasTemp + (ExhaustTemp - DesignMinExitGasTemp) / std::exp(UA / (max(ExhaustFlow, MaxExhaustperCTPower * RatedPowerOutput) * ExhaustCP)); QExhaustRec = max(ExhaustFlow * ExhaustCP * (ExhaustTemp - ExhaustStackTemp), 0.0); } else { - ExhaustStackTemp = CTGenerator(genNum).DesignMinExitGasTemp; + ExhaustStackTemp = this->DesignMinExitGasTemp; QExhaustRec = 0.0; } @@ -685,7 +680,7 @@ namespace CTElectricGenerator { // multiplying the total power generated by the fraction of that power that could be recovered in the lube oil at that // particular part load. // recovered lube oil heat (W) - Real64 QLubeOilRec = ElecPowerGenerated * CurveManager::CurveValue(CTGenerator(genNum).QLubeOilRecoveredCurve, PLR); + Real64 QLubeOilRec = ElecPowerGenerated * CurveManager::CurveValue(this->QLubeOilRecoveredCurve, PLR); // Check for divide by zero Real64 HeatRecOutTemp; // Heat Recovery Fluid Outlet Temperature (C) @@ -704,9 +699,9 @@ namespace CTElectricGenerator { Real64 HRecRatio; // When Max Temp is reached the amount of recovered heat has to be reduced. - if (HeatRecOutTemp > CTGenerator(genNum).HeatRecMaxTemp) { - if (CTGenerator(genNum).HeatRecMaxTemp != HeatRecInTemp) { - MinHeatRecMdot = (QExhaustRec + QLubeOilRec) / (HeatRecCp * (CTGenerator(genNum).HeatRecMaxTemp - HeatRecInTemp)); + if (HeatRecOutTemp > this->HeatRecMaxTemp) { + if (this->HeatRecMaxTemp != HeatRecInTemp) { + MinHeatRecMdot = (QExhaustRec + QLubeOilRec) / (HeatRecCp * (this->HeatRecMaxTemp - HeatRecInTemp)); if (MinHeatRecMdot < 0.0) MinHeatRecMdot = 0.0; } @@ -735,32 +730,31 @@ namespace CTElectricGenerator { // recovered exhaust heat (J) Real64 ExhaustEnergyRec = QExhaustRec * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - CTGenerator(genNum).ElecPowerGenerated = ElecPowerGenerated; - CTGenerator(genNum).ElecEnergyGenerated = ElectricEnergyGen; + this->ElecPowerGenerated = ElecPowerGenerated; + this->ElecEnergyGenerated = ElectricEnergyGen; - CTGenerator(genNum).HeatRecInletTemp = HeatRecInTemp; - CTGenerator(genNum).HeatRecOutletTemp = HeatRecOutTemp; + this->HeatRecInletTemp = HeatRecInTemp; + this->HeatRecOutletTemp = HeatRecOutTemp; - CTGenerator(genNum).HeatRecMdot = HeatRecMdot; - CTGenerator(genNum).QExhaustRecovered = QExhaustRec; - CTGenerator(genNum).QLubeOilRecovered = QLubeOilRec; - CTGenerator(genNum).QTotalHeatRecovered = QExhaustRec + QLubeOilRec; - CTGenerator(genNum).FuelEnergyUseRate = std::abs(FuelUseRate); - CTGenerator(genNum).ExhaustEnergyRec = ExhaustEnergyRec; - CTGenerator(genNum).LubeOilEnergyRec = LubeOilEnergyRec; - CTGenerator(genNum).TotalHeatEnergyRec = ExhaustEnergyRec + LubeOilEnergyRec; - CTGenerator(genNum).FuelEnergy = std::abs(FuelEnergyUsed); + this->HeatRecMdot = HeatRecMdot; + this->QExhaustRecovered = QExhaustRec; + this->QLubeOilRecovered = QLubeOilRec; + this->QTotalHeatRecovered = QExhaustRec + QLubeOilRec; + this->FuelEnergyUseRate = std::abs(FuelUseRate); + this->ExhaustEnergyRec = ExhaustEnergyRec; + this->LubeOilEnergyRec = LubeOilEnergyRec; + this->TotalHeatEnergyRec = ExhaustEnergyRec + LubeOilEnergyRec; + this->FuelEnergy = std::abs(FuelEnergyUsed); // Heating Value of Fuel in (kJ/kg) - Real64 FuelHeatingValue = CTGenerator(genNum).FuelHeatingValue; + Real64 FuelHeatingValue = this->FuelHeatingValue; - CTGenerator(genNum).FuelMdot = std::abs(FuelUseRate) / (FuelHeatingValue * KJtoJ); + this->FuelMdot = std::abs(FuelUseRate) / (FuelHeatingValue * KJtoJ); - CTGenerator(genNum).ExhaustStackTemp = ExhaustStackTemp; + this->ExhaustStackTemp = ExhaustStackTemp; } - void InitCTGenerators(int const genNum, // Generator number - bool const RunFlag, // TRUE when Generator operating + void CTGeneratorSpecs::InitCTGenerators(bool const RunFlag, // TRUE when Generator operating Real64 const EP_UNUSED(MyLoad), // Generator demand bool const FirstHVACIteration) { @@ -784,14 +778,14 @@ namespace CTElectricGenerator { MyOneTimeFlag = false; } - if (CTGenerator(genNum).MyPlantScanFlag && allocated(DataPlant::PlantLoop) && CTGenerator(genNum).HeatRecActive) { + if (this->MyPlantScanFlag && allocated(DataPlant::PlantLoop) && this->HeatRecActive) { errFlag = false; - PlantUtilities::ScanPlantLoopsForObject(CTGenerator(genNum).Name, + PlantUtilities::ScanPlantLoopsForObject(this->Name, DataPlant::TypeOf_Generator_CTurbine, - CTGenerator(genNum).HRLoopNum, - CTGenerator(genNum).HRLoopSideNum, - CTGenerator(genNum).HRBranchNum, - CTGenerator(genNum).HRCompNum, + this->HRLoopNum, + this->HRLoopSideNum, + this->HRBranchNum, + this->HRCompNum, errFlag, _, _, @@ -801,96 +795,94 @@ namespace CTElectricGenerator { if (errFlag) { ShowFatalError("InitCTGenerators: Program terminated due to previous condition(s)."); } - CTGenerator(genNum).MyPlantScanFlag = false; + this->MyPlantScanFlag = false; } - if (CTGenerator(genNum).MySizeAndNodeInitFlag && (!CTGenerator(genNum).MyPlantScanFlag) && CTGenerator(genNum).HeatRecActive) { - int HeatRecInletNode = CTGenerator(genNum).HeatRecInletNodeNum; - int HeatRecOutletNode = CTGenerator(genNum).HeatRecOutletNodeNum; + if (this->MySizeAndNodeInitFlag && (!this->MyPlantScanFlag) && this->HeatRecActive) { + int HeatRecInletNode = this->HeatRecInletNodeNum; + int HeatRecOutletNode = this->HeatRecOutletNodeNum; // size mass flow rate - Real64 rho = FluidProperties::GetDensityGlycol(DataPlant::PlantLoop(CTGenerator(genNum).HRLoopNum).FluidName, + Real64 rho = FluidProperties::GetDensityGlycol(DataPlant::PlantLoop(this->HRLoopNum).FluidName, DataGlobals::InitConvTemp, - DataPlant::PlantLoop(CTGenerator(genNum).HRLoopNum).FluidIndex, + DataPlant::PlantLoop(this->HRLoopNum).FluidIndex, RoutineName); - CTGenerator(genNum).DesignHeatRecMassFlowRate = rho * CTGenerator(genNum).DesignHeatRecVolFlowRate; + this->DesignHeatRecMassFlowRate = rho * this->DesignHeatRecVolFlowRate; PlantUtilities::InitComponentNodes(0.0, - CTGenerator(genNum).DesignHeatRecMassFlowRate, + this->DesignHeatRecMassFlowRate, HeatRecInletNode, HeatRecOutletNode, - CTGenerator(genNum).HRLoopNum, - CTGenerator(genNum).HRLoopSideNum, - CTGenerator(genNum).HRBranchNum, - CTGenerator(genNum).HRCompNum); + this->HRLoopNum, + this->HRLoopSideNum, + this->HRBranchNum, + this->HRCompNum); - CTGenerator(genNum).MySizeAndNodeInitFlag = false; + this->MySizeAndNodeInitFlag = false; } // end one time inits // Do the Begin Environment initializations - if (DataGlobals::BeginEnvrnFlag && CTGenerator(genNum).MyEnvrnFlag && CTGenerator(genNum).HeatRecActive) { - int HeatRecInletNode = CTGenerator(genNum).HeatRecInletNodeNum; - int HeatRecOutletNode = CTGenerator(genNum).HeatRecOutletNodeNum; + if (DataGlobals::BeginEnvrnFlag && this->MyEnvrnFlag && this->HeatRecActive) { + int HeatRecInletNode = this->HeatRecInletNodeNum; + int HeatRecOutletNode = this->HeatRecOutletNodeNum; // set the node Temperature, assuming freeze control DataLoopNode::Node(HeatRecInletNode).Temp = 20.0; DataLoopNode::Node(HeatRecOutletNode).Temp = 20.0; // set the node max and min mass flow rates PlantUtilities::InitComponentNodes(0.0, - CTGenerator(genNum).DesignHeatRecMassFlowRate, + this->DesignHeatRecMassFlowRate, HeatRecInletNode, HeatRecOutletNode, - CTGenerator(genNum).HRLoopNum, - CTGenerator(genNum).HRLoopSideNum, - CTGenerator(genNum).HRBranchNum, - CTGenerator(genNum).HRCompNum); + this->HRLoopNum, + this->HRLoopSideNum, + this->HRBranchNum, + this->HRCompNum); - CTGenerator(genNum).MyEnvrnFlag = false; + this->MyEnvrnFlag = false; } // end environmental inits if (!DataGlobals::BeginEnvrnFlag) { - CTGenerator(genNum).MyEnvrnFlag = true; + this->MyEnvrnFlag = true; } - if (CTGenerator(genNum).HeatRecActive) { + if (this->HeatRecActive) { if (FirstHVACIteration) { Real64 mdot; if (RunFlag) { - mdot = CTGenerator(genNum).DesignHeatRecMassFlowRate; + mdot = this->DesignHeatRecMassFlowRate; } else { mdot = 0.0; } PlantUtilities::SetComponentFlowRate(mdot, - CTGenerator(genNum).HeatRecInletNodeNum, - CTGenerator(genNum).HeatRecOutletNodeNum, - CTGenerator(genNum).HRLoopNum, - CTGenerator(genNum).HRLoopSideNum, - CTGenerator(genNum).HRBranchNum, - CTGenerator(genNum).HRCompNum); + this->HeatRecInletNodeNum, + this->HeatRecOutletNodeNum, + this->HRLoopNum, + this->HRLoopSideNum, + this->HRBranchNum, + this->HRCompNum); } else { - PlantUtilities::SetComponentFlowRate(CTGenerator(genNum).HeatRecMdot, - CTGenerator(genNum).HeatRecInletNodeNum, - CTGenerator(genNum).HeatRecOutletNodeNum, - CTGenerator(genNum).HRLoopNum, - CTGenerator(genNum).HRLoopSideNum, - CTGenerator(genNum).HRBranchNum, - CTGenerator(genNum).HRCompNum); + PlantUtilities::SetComponentFlowRate(this->HeatRecMdot, + this->HeatRecInletNodeNum, + this->HeatRecOutletNodeNum, + this->HRLoopNum, + this->HRLoopSideNum, + this->HRBranchNum, + this->HRCompNum); } } } - void UpdateCTGeneratorRecords(bool const EP_UNUSED(RunFlag), // TRUE if Generator operating - int const genNUm // Generator number - ) + void CTGeneratorSpecs::UpdateCTGeneratorRecords() { // SUBROUTINE INFORMATION: // AUTHOR: Dan Fisher // DATE WRITTEN: October 1998 - if (CTGenerator(genNUm).HeatRecActive) { - int HeatRecOutletNode = CTGenerator(genNUm).HeatRecOutletNodeNum; - DataLoopNode::Node(HeatRecOutletNode).Temp = CTGenerator(genNUm).HeatRecOutletTemp; + if (this->HeatRecActive) { + int HeatRecOutletNode = this->HeatRecOutletNodeNum; + DataLoopNode::Node(HeatRecOutletNode).Temp = this->HeatRecOutletTemp; } } diff --git a/src/EnergyPlus/CTElectricGenerator.hh b/src/EnergyPlus/CTElectricGenerator.hh index 9940ac255b7..e7e3ed4a698 100644 --- a/src/EnergyPlus/CTElectricGenerator.hh +++ b/src/EnergyPlus/CTElectricGenerator.hh @@ -142,6 +142,17 @@ namespace CTElectricGenerator { MyPlantScanFlag(true), MySizeAndNodeInitFlag(true), CheckEquipName(true) { } + + void InitCTGenerators(bool RunFlag, + Real64 MyLoad, + bool FirstHVACIteration); + + void CalcCTGeneratorModel(bool RunFlag, + Real64 MyLoad, + bool FirstHVACIteration); + + void UpdateCTGeneratorRecords(); + }; // Object Data @@ -170,20 +181,6 @@ namespace CTElectricGenerator { void GetCTGeneratorInput(); - void CalcCTGeneratorModel(int genNum, // Generator number - bool RunFlag, // TRUE when Generator operating - Real64 MyLoad, // Generator demand - bool FirstHVACIteration); - - void InitCTGenerators(int genNum, // Generator number - bool RunFlag, // TRUE when Generator operating - Real64 MyLoad, // Generator demand - bool FirstHVACIteration); - - void UpdateCTGeneratorRecords(bool RunFlag, // TRUE if Generator operating - int genNUm // Generator number - ); - void GetCTGeneratorResults(int GeneratorType, // type of Generator int genNum, Real64 &GeneratorPower, // electrical power From 8fd52f7bdde2ae1125313340ceccf18e6891e7af Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Tue, 15 Oct 2019 21:09:28 -0600 Subject: [PATCH 09/13] move setupOutputVars to member func --- src/EnergyPlus/CTElectricGenerator.cc | 223 ++++++++++++++------------ src/EnergyPlus/CTElectricGenerator.hh | 5 +- 2 files changed, 120 insertions(+), 108 deletions(-) diff --git a/src/EnergyPlus/CTElectricGenerator.cc b/src/EnergyPlus/CTElectricGenerator.cc index db6ed5a6b46..8ea1ff8da17 100644 --- a/src/EnergyPlus/CTElectricGenerator.cc +++ b/src/EnergyPlus/CTElectricGenerator.cc @@ -397,141 +397,150 @@ namespace CTElectricGenerator { if (ErrorsFound) { ShowFatalError("Errors found in processing input for " + DataIPShortCuts::cCurrentModuleObject); } + } - for (int genNum = 1; genNum <= NumCTGenerators; ++genNum) { - SetupOutputVariable("Generator Produced Electric Power", + void CTGeneratorSpecs::setupOutputVars() + { + SetupOutputVariable("Generator Produced Electric Power", + OutputProcessor::Unit::W, + this->ElecPowerGenerated, + "System", + "Average", + this->Name); + + SetupOutputVariable("Generator Produced Electric Energy", + OutputProcessor::Unit::J, + this->ElecEnergyGenerated, + "System", + "Sum", + this->Name, + _, + "ElectricityProduced", + "COGENERATION", + _, + "Plant"); + + SetupOutputVariable("Generator " + this->FuelType + " Rate", + OutputProcessor::Unit::W, + this->FuelEnergyUseRate, + "System", + "Average", + this->Name); + + SetupOutputVariable("Generator " + this->FuelType + " Energy", + OutputProcessor::Unit::J, + this->FuelEnergy, + "System", + "Sum", + this->Name, + _, + this->FuelType, + "COGENERATION", + _, + "Plant"); + + // general fuel use report (to match other generators) + SetupOutputVariable("Generator Fuel HHV Basis Rate", + OutputProcessor::Unit::W, + this->FuelEnergyUseRate, + "System", + "Average", + this->Name); + + SetupOutputVariable("Generator Fuel HHV Basis Energy", + OutputProcessor::Unit::J, + this->FuelEnergy, + "System", + "Sum", + this->Name); + + SetupOutputVariable("Generator " + this->FuelType + " Mass Flow Rate", + OutputProcessor::Unit::kg_s, + this->FuelMdot, + "System", + "Average", + this->Name); + + SetupOutputVariable("Generator Exhaust Air Temperature", + OutputProcessor::Unit::C, + this->ExhaustStackTemp, + "System", + "Average", + this->Name); + + if (this->HeatRecActive) { + SetupOutputVariable("Generator Exhaust Heat Recovery Rate", OutputProcessor::Unit::W, - CTGenerator(genNum).ElecPowerGenerated, + this->QExhaustRecovered, "System", "Average", - CTGenerator(genNum).Name); - SetupOutputVariable("Generator Produced Electric Energy", + this->Name); + + SetupOutputVariable("Generator Exhaust Heat Recovery Energy", OutputProcessor::Unit::J, - CTGenerator(genNum).ElecEnergyGenerated, + this->ExhaustEnergyRec, "System", "Sum", - CTGenerator(genNum).Name, + this->Name, _, - "ElectricityProduced", - "COGENERATION", + "ENERGYTRANSFER", + "HEATRECOVERY", _, "Plant"); - SetupOutputVariable("Generator " + CTGenerator(genNum).FuelType + " Rate", + SetupOutputVariable("Generator Lube Heat Recovery Rate", OutputProcessor::Unit::W, - CTGenerator(genNum).FuelEnergyUseRate, + this->QLubeOilRecovered, "System", "Average", - CTGenerator(genNum).Name); - SetupOutputVariable("Generator " + CTGenerator(genNum).FuelType + " Energy", + this->Name); + + SetupOutputVariable("Generator Lube Heat Recovery Energy", OutputProcessor::Unit::J, - CTGenerator(genNum).FuelEnergy, + this->LubeOilEnergyRec, "System", "Sum", - CTGenerator(genNum).Name, + this->Name, _, - CTGenerator(genNum).FuelType, - "COGENERATION", + "ENERGYTRANSFER", + "HEATRECOVERY", _, "Plant"); - // general fuel use report (to match other generators) - SetupOutputVariable("Generator Fuel HHV Basis Rate", + SetupOutputVariable("Generator Produced Thermal Rate", OutputProcessor::Unit::W, - CTGenerator(genNum).FuelEnergyUseRate, + this->QTotalHeatRecovered, "System", "Average", - CTGenerator(genNum).Name); - SetupOutputVariable("Generator Fuel HHV Basis Energy", + this->Name); + + SetupOutputVariable("Generator Produced Thermal Energy", OutputProcessor::Unit::J, - CTGenerator(genNum).FuelEnergy, + this->TotalHeatEnergyRec, "System", "Sum", - CTGenerator(genNum).Name); + this->Name); - SetupOutputVariable("Generator " + CTGenerator(genNum).FuelType + " Mass Flow Rate", - OutputProcessor::Unit::kg_s, - CTGenerator(genNum).FuelMdot, + SetupOutputVariable("Generator Heat Recovery Inlet Temperature", + OutputProcessor::Unit::C, + this->HeatRecInletTemp, "System", "Average", - CTGenerator(genNum).Name); + this->Name); - SetupOutputVariable("Generator Exhaust Air Temperature", + SetupOutputVariable("Generator Heat Recovery Outlet Temperature", OutputProcessor::Unit::C, - CTGenerator(genNum).ExhaustStackTemp, + this->HeatRecOutletTemp, "System", "Average", - CTGenerator(genNum).Name); - - if (CTGenerator(genNum).HeatRecActive) { - SetupOutputVariable("Generator Exhaust Heat Recovery Rate", - OutputProcessor::Unit::W, - CTGenerator(genNum).QExhaustRecovered, - "System", - "Average", - CTGenerator(genNum).Name); - SetupOutputVariable("Generator Exhaust Heat Recovery Energy", - OutputProcessor::Unit::J, - CTGenerator(genNum).ExhaustEnergyRec, - "System", - "Sum", - CTGenerator(genNum).Name, - _, - "ENERGYTRANSFER", - "HEATRECOVERY", - _, - "Plant"); - - SetupOutputVariable("Generator Lube Heat Recovery Rate", - OutputProcessor::Unit::W, - CTGenerator(genNum).QLubeOilRecovered, - "System", - "Average", - CTGenerator(genNum).Name); - SetupOutputVariable("Generator Lube Heat Recovery Energy", - OutputProcessor::Unit::J, - CTGenerator(genNum).LubeOilEnergyRec, - "System", - "Sum", - CTGenerator(genNum).Name, - _, - "ENERGYTRANSFER", - "HEATRECOVERY", - _, - "Plant"); - - SetupOutputVariable("Generator Produced Thermal Rate", - OutputProcessor::Unit::W, - CTGenerator(genNum).QTotalHeatRecovered, - "System", - "Average", - CTGenerator(genNum).Name); - SetupOutputVariable("Generator Produced Thermal Energy", - OutputProcessor::Unit::J, - CTGenerator(genNum).TotalHeatEnergyRec, - "System", - "Sum", - CTGenerator(genNum).Name); - - SetupOutputVariable("Generator Heat Recovery Inlet Temperature", - OutputProcessor::Unit::C, - CTGenerator(genNum).HeatRecInletTemp, - "System", - "Average", - CTGenerator(genNum).Name); - SetupOutputVariable("Generator Heat Recovery Outlet Temperature", - OutputProcessor::Unit::C, - CTGenerator(genNum).HeatRecOutletTemp, - "System", - "Average", - CTGenerator(genNum).Name); - SetupOutputVariable("Generator Heat Recovery Mass Flow Rate", - OutputProcessor::Unit::kg_s, - CTGenerator(genNum).HeatRecMdot, - "System", - "Average", - CTGenerator(genNum).Name); - } + this->Name); + + SetupOutputVariable("Generator Heat Recovery Mass Flow Rate", + OutputProcessor::Unit::kg_s, + this->HeatRecMdot, + "System", + "Average", + this->Name); } } @@ -769,15 +778,9 @@ namespace CTElectricGenerator { // This subroutine is for initializations of the CT generators. static std::string const RoutineName("InitICEngineGenerators"); - static bool MyOneTimeFlag(true); // Initialization flag bool errFlag; - // Do the one time initializations - if (MyOneTimeFlag) { - MyOneTimeFlag = false; - } - if (this->MyPlantScanFlag && allocated(DataPlant::PlantLoop) && this->HeatRecActive) { errFlag = false; PlantUtilities::ScanPlantLoopsForObject(this->Name, @@ -795,9 +798,15 @@ namespace CTElectricGenerator { if (errFlag) { ShowFatalError("InitCTGenerators: Program terminated due to previous condition(s)."); } + this->MyPlantScanFlag = false; } + if (this->MyFlag) { + this->setupOutputVars(); + this->MyFlag = false; + } + if (this->MySizeAndNodeInitFlag && (!this->MyPlantScanFlag) && this->HeatRecActive) { int HeatRecInletNode = this->HeatRecInletNodeNum; int HeatRecOutletNode = this->HeatRecOutletNodeNum; diff --git a/src/EnergyPlus/CTElectricGenerator.hh b/src/EnergyPlus/CTElectricGenerator.hh index e7e3ed4a698..39633decbc3 100644 --- a/src/EnergyPlus/CTElectricGenerator.hh +++ b/src/EnergyPlus/CTElectricGenerator.hh @@ -127,6 +127,7 @@ namespace CTElectricGenerator { bool MyPlantScanFlag; bool MySizeAndNodeInitFlag; bool CheckEquipName; + bool MyFlag; // Default Constructor CTGeneratorSpecs() @@ -139,10 +140,12 @@ namespace CTElectricGenerator { ExhaustStackTemp(0.0), HeatRecActive(false), HeatRecInletNodeNum(0), HeatRecOutletNodeNum(0), HeatRecInletTemp(0.0), HeatRecOutletTemp(0.0), HeatRecMdot(0.0), HRLoopNum(0), HRLoopSideNum(0), HRBranchNum(0), HRCompNum(0), FuelMdot(0.0), FuelHeatingValue(0.0), ElecPowerGenerated(0.0), ElecEnergyGenerated(0.0), HeatRecMaxTemp(0.0), OAInletNode(0), MyEnvrnFlag(true), - MyPlantScanFlag(true), MySizeAndNodeInitFlag(true), CheckEquipName(true) + MyPlantScanFlag(true), MySizeAndNodeInitFlag(true), CheckEquipName(true), MyFlag(true) { } + void setupOutputVars(); + void InitCTGenerators(bool RunFlag, Real64 MyLoad, bool FirstHVACIteration); From 525b52419df6820db35bfde969872aa31378ffed Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Wed, 16 Oct 2019 08:44:32 -0600 Subject: [PATCH 10/13] inherit plant component; add clear_state --- src/EnergyPlus/CTElectricGenerator.cc | 12 ++++++++++++ src/EnergyPlus/CTElectricGenerator.hh | 11 +++++++---- tst/EnergyPlus/unit/Fixtures/EnergyPlusFixture.cc | 2 ++ 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/EnergyPlus/CTElectricGenerator.cc b/src/EnergyPlus/CTElectricGenerator.cc index 8ea1ff8da17..8ae85786263 100644 --- a/src/EnergyPlus/CTElectricGenerator.cc +++ b/src/EnergyPlus/CTElectricGenerator.cc @@ -100,6 +100,13 @@ namespace CTElectricGenerator { Array1D CTGenerator; // dimension to number of machines + void clear_state() + { + NumCTGenerators = 0; + GetCTInput = true; + CTGenerator.deallocate(); + } + void SimCTGenerator(int const EP_UNUSED(GeneratorType), // type of Generator std::string const &GeneratorName, // user specified name of Generator int &GeneratorIndex, @@ -152,6 +159,11 @@ namespace CTElectricGenerator { thisCTG.UpdateCTGeneratorRecords(); } + void CTGeneratorSpecs::simulate(const EnergyPlus::PlantLocation &EP_UNUSED(calledFromLocation), bool EP_UNUSED(FirstHVACIteration), Real64 &EP_UNUSED(CurLoad), bool EP_UNUSED(RunFlag)) + { + + } + void SimCTPlantHeatRecovery(std::string const &EP_UNUSED(CompType), // unused1208 std::string const &CompName, int const EP_UNUSED(CompTypeNum), // unused1208 diff --git a/src/EnergyPlus/CTElectricGenerator.hh b/src/EnergyPlus/CTElectricGenerator.hh index 39633decbc3..15ec3196ebf 100644 --- a/src/EnergyPlus/CTElectricGenerator.hh +++ b/src/EnergyPlus/CTElectricGenerator.hh @@ -55,6 +55,7 @@ #include #include #include +#include namespace EnergyPlus { @@ -63,11 +64,8 @@ namespace CTElectricGenerator { using DataGlobalConstants::iGeneratorCombTurbine; extern int NumCTGenerators; // number of CT Generators specified in input - extern bool GetCTInput; // then TRUE, calls subroutine to read input file. - extern Array1D_bool CheckEquipName; - - struct CTGeneratorSpecs + struct CTGeneratorSpecs : PlantComponent { // Members std::string Name; // user identifier @@ -144,6 +142,8 @@ namespace CTElectricGenerator { { } + void simulate(const PlantLocation &calledFromLocation, bool FirstHVACIteration, Real64 &CurLoad, bool RunFlag) override; + void setupOutputVars(); void InitCTGenerators(bool RunFlag, @@ -191,6 +191,9 @@ namespace CTElectricGenerator { Real64 &ThermalPower, // heat power Real64 &ThermalEnergy // heat energy ); + + void clear_state(); + } // namespace CTElectricGenerator } // namespace EnergyPlus diff --git a/tst/EnergyPlus/unit/Fixtures/EnergyPlusFixture.cc b/tst/EnergyPlus/unit/Fixtures/EnergyPlusFixture.cc index e3dfe39a8a9..b9791592706 100644 --- a/tst/EnergyPlus/unit/Fixtures/EnergyPlusFixture.cc +++ b/tst/EnergyPlus/unit/Fixtures/EnergyPlusFixture.cc @@ -71,6 +71,7 @@ #include #include #include +#include #include #include #include @@ -320,6 +321,7 @@ void EnergyPlusFixture::clear_all_states() CoolTower::clear_state(); CrossVentMgr::clear_state(); CurveManager::clear_state(); + CTElectricGenerator::clear_state(); AirflowNetwork::clear_state(); DataAirLoop::clear_state(); DataBranchAirLoopPlant::clear_state(); From 4f832a733e6b2fab133edd4a61b2cf527a7f3ffb Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Wed, 16 Oct 2019 11:02:25 -0600 Subject: [PATCH 11/13] update calling tree to PlantComponent --- src/EnergyPlus/CTElectricGenerator.cc | 170 ++++++------------ src/EnergyPlus/CTElectricGenerator.hh | 57 +++--- src/EnergyPlus/ElectricPowerServiceManager.cc | 18 +- src/EnergyPlus/Plant/PlantManager.cc | 2 + src/EnergyPlus/PlantLoopEquip.cc | 20 +-- 5 files changed, 95 insertions(+), 172 deletions(-) diff --git a/src/EnergyPlus/CTElectricGenerator.cc b/src/EnergyPlus/CTElectricGenerator.cc index 8ae85786263..56327fc3389 100644 --- a/src/EnergyPlus/CTElectricGenerator.cc +++ b/src/EnergyPlus/CTElectricGenerator.cc @@ -68,6 +68,7 @@ #include #include #include +#include #include namespace EnergyPlus { @@ -96,113 +97,52 @@ namespace CTElectricGenerator { // performance data. int NumCTGenerators(0); // number of CT Generators specified in input - bool GetCTInput(true); // then TRUE, calls subroutine to read input file. + bool getCTInputFlag(true); // then TRUE, calls subroutine to read input file. Array1D CTGenerator; // dimension to number of machines void clear_state() { NumCTGenerators = 0; - GetCTInput = true; + getCTInputFlag = true; CTGenerator.deallocate(); } - void SimCTGenerator(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 - Real64 const MyLoad, // generator demand - bool const FirstHVACIteration) + PlantComponent *CTGeneratorSpecs::factory(std::string const &objectName) { - // SUBROUTINE INFORMATION: - // AUTHOR Dan Fisher - // DATE WRITTEN Sept. 2000 - // MODIFIED na - // RE-ENGINEERED na - - // PURPOSE OF THIS SUBROUTINE: This is the CT Generator driver. It - // 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 (GetCTInput) { + // Process the input data for generators if it hasn't been done already + if (getCTInputFlag) { GetCTGeneratorInput(); - GetCTInput = false; + getCTInputFlag = false; } - // SELECT and CALL MODELS - if (GeneratorIndex == 0) { - genNum = UtilityRoutines::FindItemInList(GeneratorName, CTGenerator); - if (genNum == 0) ShowFatalError("SimCTGenerator: Specified Generator not one of Valid COMBUSTION Turbine Generators " + GeneratorName); - GeneratorIndex = genNum; - } else { - genNum = GeneratorIndex; - if (genNum > NumCTGenerators || genNum < 1) { - ShowFatalError("SimCTGenerator: Invalid GeneratorIndex passed=" + General::TrimSigDigits(genNum) + - ", Number of CT Engine Generators=" + General::TrimSigDigits(NumCTGenerators) + ", Generator name=" + GeneratorName); - } - if (CTGenerator(genNum).CheckEquipName) { - if (GeneratorName != CTGenerator(genNum).Name) { - ShowFatalError("SimCTGenerator: Invalid GeneratorIndex passed=" + General::TrimSigDigits(genNum) + ", Generator name=" + GeneratorName + - ", stored Generator Name for that index=" + CTGenerator(genNum).Name); - } - CTGenerator(genNum).CheckEquipName = false; + // Now look for this particular generator in the list + for (auto &CTGen : CTGenerator) { + if (CTGen.Name == objectName) { + return &CTGen; } } - - auto &thisCTG = CTGenerator(genNum); - - thisCTG.InitCTGenerators(RunFlag, MyLoad, FirstHVACIteration); - thisCTG.CalcCTGeneratorModel(RunFlag, MyLoad, FirstHVACIteration); - thisCTG.UpdateCTGeneratorRecords(); + // If we didn't find it, fatal + ShowFatalError("LocalCombustionTurbineGeneratorFactory: Error getting inputs for combustion turbine generator named: " + objectName); // LCOV_EXCL_LINE + // Shut up the compiler + return nullptr; // LCOV_EXCL_LINE } void CTGeneratorSpecs::simulate(const EnergyPlus::PlantLocation &EP_UNUSED(calledFromLocation), bool EP_UNUSED(FirstHVACIteration), Real64 &EP_UNUSED(CurLoad), bool EP_UNUSED(RunFlag)) { - - } - - void SimCTPlantHeatRecovery(std::string const &EP_UNUSED(CompType), // unused1208 - std::string const &CompName, - int const EP_UNUSED(CompTypeNum), // unused1208 - int &CompNum, - bool const EP_UNUSED(RunFlag), - bool &InitLoopEquip, - Real64 &EP_UNUSED(MyLoad), - Real64 &MaxCap, - Real64 &MinCap, - Real64 &OptCap, - bool const EP_UNUSED(FirstHVACIteration) // TRUE if First iteration of simulation - ) - { - // SUBROUTINE INFORMATION: - // AUTHOR BGriffith - // DATE WRITTEN March 2008 + // AUTHOR Dan Fisher + // DATE WRITTEN Sept. 2000 // MODIFIED na // RE-ENGINEERED na - // PURPOSE OF THIS SUBROUTINE: - // Fill data needed in PlantLoopEquipments - - if (GetCTInput) { - GetCTGeneratorInput(); - GetCTInput = false; - } + // PURPOSE OF THIS SUBROUTINE: This is the CT Generator driver. It + // gets the input for the models, initializes simulation variables, call + // the appropriate model and sets up reporting variables. - if (InitLoopEquip) { - CompNum = UtilityRoutines::FindItemInList(CompName, CTGenerator); - if (CompNum == 0) { - ShowFatalError("SimCTPlantHeatRecovery: CT Generator Unit not found=" + CompName); - return; - } - MinCap = 0.0; - MaxCap = 0.0; - OptCap = 0.0; - return; - } // End Of InitLoopEquip + // empty function to emulate current behavior as of conversion to using the PlantComponent calling structure. + // calls from the plant side... do nothing. + // calls from the ElectricPowerServiceManger call the init and calculation worker function directly. } void GetCTGeneratorInput() @@ -773,10 +713,14 @@ namespace CTElectricGenerator { this->FuelMdot = std::abs(FuelUseRate) / (FuelHeatingValue * KJtoJ); this->ExhaustStackTemp = ExhaustStackTemp; + + if (this->HeatRecActive) { + int HeatRecOutletNode = this->HeatRecOutletNodeNum; + DataLoopNode::Node(HeatRecOutletNode).Temp = this->HeatRecOutletTemp; + } } void CTGeneratorSpecs::InitCTGenerators(bool const RunFlag, // TRUE when Generator operating - Real64 const EP_UNUSED(MyLoad), // Generator demand bool const FirstHVACIteration) { @@ -895,40 +839,30 @@ namespace CTElectricGenerator { } } - void CTGeneratorSpecs::UpdateCTGeneratorRecords() - { - // SUBROUTINE INFORMATION: - // AUTHOR: Dan Fisher - // DATE WRITTEN: October 1998 - - if (this->HeatRecActive) { - int HeatRecOutletNode = this->HeatRecOutletNodeNum; - DataLoopNode::Node(HeatRecOutletNode).Temp = this->HeatRecOutletTemp; - } - } - - void GetCTGeneratorResults(int const EP_UNUSED(GeneratorType), // type of Generator - int const genNum, - 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: - // get some results for load center's aggregation - - GeneratorPower = CTGenerator(genNum).ElecPowerGenerated; - GeneratorEnergy = CTGenerator(genNum).ElecEnergyGenerated; - ThermalPower = CTGenerator(genNum).QTotalHeatRecovered; - ThermalEnergy = CTGenerator(genNum).TotalHeatEnergyRec; - } +// void GetCTGeneratorResults(int const EP_UNUSED(GeneratorType), // type of Generator +// int const genNum, +// 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: +// // get some results for load center's aggregation +// +// // called by ElectricPowerServiceManager. this function needs to go away eventually. +// +// GeneratorPower = CTGenerator(genNum).ElecPowerGenerated; +// GeneratorEnergy = CTGenerator(genNum).ElecEnergyGenerated; +// ThermalPower = CTGenerator(genNum).QTotalHeatRecovered; +// ThermalEnergy = CTGenerator(genNum).TotalHeatEnergyRec; +// } } // namespace CTElectricGenerator diff --git a/src/EnergyPlus/CTElectricGenerator.hh b/src/EnergyPlus/CTElectricGenerator.hh index 15ec3196ebf..c7c7b1e5304 100644 --- a/src/EnergyPlus/CTElectricGenerator.hh +++ b/src/EnergyPlus/CTElectricGenerator.hh @@ -147,50 +147,49 @@ namespace CTElectricGenerator { void setupOutputVars(); void InitCTGenerators(bool RunFlag, - Real64 MyLoad, bool FirstHVACIteration); void CalcCTGeneratorModel(bool RunFlag, Real64 MyLoad, bool FirstHVACIteration); - void UpdateCTGeneratorRecords(); + static PlantComponent *factory(std::string const &objectName); }; // Object Data extern Array1D CTGenerator; // dimension to number of machines - // Static functions - void SimCTGenerator(int GeneratorType, // type of Generator - std::string const &GeneratorName, // user specified name of Generator - int &GeneratorIndex, - bool RunFlag, // simulate Generator when TRUE - Real64 MyLoad, // generator demand - bool FirstHVACIteration); - - void SimCTPlantHeatRecovery(std::string const &CompType, // unused1208 - std::string const &CompName, - int CompTypeNum, // unused1208 - int &CompNum, - bool RunFlag, - bool &InitLoopEquip, - Real64 &MyLoad, - Real64 &MaxCap, - Real64 &MinCap, - Real64 &OptCap, - bool FirstHVACIteration // TRUE if First iteration of simulation - ); +// // Static functions +// void SimCTGenerator(int GeneratorType, // type of Generator +// std::string const &GeneratorName, // user specified name of Generator +// int &GeneratorIndex, +// bool RunFlag, // simulate Generator when TRUE +// Real64 MyLoad, // generator demand +// bool FirstHVACIteration); +// +// void SimCTPlantHeatRecovery(std::string const &CompType, // unused1208 +// std::string const &CompName, +// int CompTypeNum, // unused1208 +// int &CompNum, +// bool RunFlag, +// bool &InitLoopEquip, +// Real64 &MyLoad, +// Real64 &MaxCap, +// Real64 &MinCap, +// Real64 &OptCap, +// bool FirstHVACIteration // TRUE if First iteration of simulation +// ); void GetCTGeneratorInput(); - void GetCTGeneratorResults(int GeneratorType, // type of Generator - int genNum, - Real64 &GeneratorPower, // electrical power - Real64 &GeneratorEnergy, // electrical energy - Real64 &ThermalPower, // heat power - Real64 &ThermalEnergy // heat energy - ); +// void GetCTGeneratorResults(int GeneratorType, // type of Generator +// int genNum, +// Real64 &GeneratorPower, // electrical power +// Real64 &GeneratorEnergy, // electrical energy +// Real64 &ThermalPower, // heat power +// Real64 &ThermalEnergy // heat energy +// ); void clear_state(); diff --git a/src/EnergyPlus/ElectricPowerServiceManager.cc b/src/EnergyPlus/ElectricPowerServiceManager.cc index 5f4ea8840f8..406605c6b50 100644 --- a/src/EnergyPlus/ElectricPowerServiceManager.cc +++ b/src/EnergyPlus/ElectricPowerServiceManager.cc @@ -2107,12 +2107,18 @@ void GeneratorController::simGeneratorGetPowerOutput(bool const runFlag, break; } case GeneratorType::combTurbine: { - CTElectricGenerator::SimCTGenerator( - DataGlobalConstants::iGeneratorCombTurbine, name, generatorIndex, runFlag, myElecLoadRequest, FirstHVACIteration); - CTElectricGenerator::GetCTGeneratorResults( - DataGlobalConstants::iGeneratorCombTurbine, generatorIndex, electProdRate, electricityProd, thermProdRate, thermalProd); - electricPowerOutput = electProdRate; - thermalPowerOutput = thermProdRate; + + auto thisCTE = CTElectricGenerator::CTGeneratorSpecs::factory(name); + // dummy vars + PlantLocation L(0,0,0,0); + Real64 tempLoad = myElecLoadRequest; + + // simulate + 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; break; } case GeneratorType::pV: { diff --git a/src/EnergyPlus/Plant/PlantManager.cc b/src/EnergyPlus/Plant/PlantManager.cc index 529af1ae3aa..cde206ad8f8 100644 --- a/src/EnergyPlus/Plant/PlantManager.cc +++ b/src/EnergyPlus/Plant/PlantManager.cc @@ -59,6 +59,7 @@ #include #include #include +#include #include #include #include @@ -1271,6 +1272,7 @@ namespace EnergyPlus { } else if (LoopSideNum == SupplySide) { this_comp.CurOpSchemeType = UnknownStatusOpSchemeType; } + this_comp.compPtr = CTElectricGenerator::CTGeneratorSpecs::factory(CompNames(CompNum)); } else if (UtilityRoutines::SameString(this_comp_type, "Generator:MicroCHP")) { this_comp.TypeOf_Num = TypeOf_Generator_MicroCHP; this_comp.GeneralEquipType = GenEquipTypes_Generator; diff --git a/src/EnergyPlus/PlantLoopEquip.cc b/src/EnergyPlus/PlantLoopEquip.cc index 23ef1d75328..45442e1a200 100644 --- a/src/EnergyPlus/PlantLoopEquip.cc +++ b/src/EnergyPlus/PlantLoopEquip.cc @@ -188,7 +188,6 @@ namespace PlantLoopEquip { using ScheduleManager::GetCurrentScheduleValue; using WaterThermalTanks::SimWaterThermalTank; - using CTElectricGenerator::SimCTPlantHeatRecovery; using EvaporativeFluidCoolers::SimEvapFluidCoolers; using FuelCellElectricGenerator::SimFuelCellPlantHeatRecovery; using ICEngineElectricGenerator::SimICEPlantHeatRecovery; @@ -197,7 +196,6 @@ namespace PlantLoopEquip { using MicroturbineElectricGenerator::SimMTPlantHeatRecovery; using PlantHeatExchangerFluidToFluid::SimFluidHeatExchanger; - // using PlantLoadProfile::PlantProfileData::simulate; using BaseboardRadiator::UpdateBaseboardPlantConnection; using HVACVariableRefrigerantFlow::SimVRFCondenserPlant; using HWBaseboardRadiator::UpdateHWBaseboardPlantConnection; @@ -983,23 +981,7 @@ namespace PlantLoopEquip { } } else if (EquipTypeNum == TypeOf_Generator_CTurbine) { - SimCTPlantHeatRecovery(sim_component.TypeOf, - sim_component.Name, - TypeOf_Generator_CTurbine, - 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; - } + sim_component.compPtr->simulate(sim_component_location, FirstHVACIteration, CurLoad, RunFlag); } else { ShowSevereError("SimPlantEquip: Invalid Generator Type=" + sim_component.TypeOf); From 414a0aef1f4df9e9cb6b8471c150670245592c7e Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Wed, 16 Oct 2019 11:10:53 -0600 Subject: [PATCH 12/13] cleanup --- src/EnergyPlus/CTElectricGenerator.cc | 173 ++++++++---------- src/EnergyPlus/CTElectricGenerator.hh | 35 +--- src/EnergyPlus/ElectricPowerServiceManager.cc | 10 +- src/EnergyPlus/Plant/PlantManager.cc | 2 +- 4 files changed, 83 insertions(+), 137 deletions(-) diff --git a/src/EnergyPlus/CTElectricGenerator.cc b/src/EnergyPlus/CTElectricGenerator.cc index 56327fc3389..f6ed834570b 100644 --- a/src/EnergyPlus/CTElectricGenerator.cc +++ b/src/EnergyPlus/CTElectricGenerator.cc @@ -99,7 +99,7 @@ namespace CTElectricGenerator { int NumCTGenerators(0); // number of CT Generators specified in input bool getCTInputFlag(true); // then TRUE, calls subroutine to read input file. - Array1D CTGenerator; // dimension to number of machines + Array1D CTGenerator; // dimension to number of machines void clear_state() { @@ -108,7 +108,7 @@ namespace CTElectricGenerator { CTGenerator.deallocate(); } - PlantComponent *CTGeneratorSpecs::factory(std::string const &objectName) + PlantComponent *CTGeneratorData::factory(std::string const &objectName) { // Process the input data for generators if it hasn't been done already if (getCTInputFlag) { @@ -128,7 +128,7 @@ namespace CTElectricGenerator { return nullptr; // LCOV_EXCL_LINE } - void CTGeneratorSpecs::simulate(const EnergyPlus::PlantLocation &EP_UNUSED(calledFromLocation), bool EP_UNUSED(FirstHVACIteration), Real64 &EP_UNUSED(CurLoad), bool EP_UNUSED(RunFlag)) + void CTGeneratorData::simulate(const EnergyPlus::PlantLocation &EP_UNUSED(calledFromLocation), bool EP_UNUSED(FirstHVACIteration), Real64 &EP_UNUSED(CurLoad), bool EP_UNUSED(RunFlag)) { // SUBROUTINE INFORMATION: // AUTHOR Dan Fisher @@ -142,7 +142,7 @@ namespace CTElectricGenerator { // empty function to emulate current behavior as of conversion to using the PlantComponent calling structure. // calls from the plant side... do nothing. - // calls from the ElectricPowerServiceManger call the init and calculation worker function directly. + // calls from the ElectricPowerServiceManger call the init and calculation worker functions directly. } void GetCTGeneratorInput() @@ -351,7 +351,7 @@ namespace CTElectricGenerator { } } - void CTGeneratorSpecs::setupOutputVars() + void CTGeneratorData::setupOutputVars() { SetupOutputVariable("Generator Produced Electric Power", OutputProcessor::Unit::W, @@ -496,7 +496,7 @@ namespace CTElectricGenerator { } } - void CTGeneratorSpecs::CalcCTGeneratorModel(bool const RunFlag, // TRUE when Generator operating + void CTGeneratorData::CalcCTGeneratorModel(bool const RunFlag, // TRUE when Generator operating Real64 const MyLoad, // Generator demand bool const FirstHVACIteration) { @@ -513,56 +513,56 @@ namespace CTElectricGenerator { // curve fit of performance data. This model was originally // developed by Dale Herron for the BLAST program - Real64 const ExhaustCP(1.047); // Exhaust Gas Specific Heat (J/kg-K) + Real64 const exhaustCp(1.047); // Exhaust Gas Specific Heat (J/kg-K) Real64 const KJtoJ(1000.0); // convert Kjoules to joules static std::string const RoutineName("CalcCTGeneratorModel"); // min allowed operating frac full load - Real64 MinPartLoadRat = this->MinPartLoadRat; + Real64 minPartLoadRat = this->MinPartLoadRat; // max allowed operating frac full load - Real64 MaxPartLoadRat = this->MaxPartLoadRat; + Real64 maxPartLoadRat = this->MaxPartLoadRat; // Generator nominal capacity (W) - Real64 RatedPowerOutput = this->RatedPowerOutput; + Real64 ratedPowerOutput = this->RatedPowerOutput; // MAX EXHAUST FLOW PER W POWER OUTPUT COEFF - Real64 MaxExhaustperCTPower = this->MaxExhaustperCTPower; + Real64 maxExhaustperCTPower = this->MaxExhaustperCTPower; // design turbine inlet temperature (C) - Real64 DesignAirInletTemp = this->DesignAirInletTemp; + Real64 designAirInletTemp = this->DesignAirInletTemp; - int HeatRecInNode; // Heat Recovery Fluid Inlet Node Num - Real64 HeatRecInTemp; // Heat Recovery Fluid Inlet Temperature (C) + int heatRecInNode; // Heat Recovery Fluid Inlet Node Num + Real64 heatRecInTemp; // Heat Recovery Fluid Inlet Temperature (C) - Real64 HeatRecMdot; // Heat Recovery Fluid Mass FlowRate (kg/s) - Real64 HeatRecCp; // Specific Heat of the Heat Recovery Fluid (J/kg-K) + Real64 heatRecMdot; // Heat Recovery Fluid Mass FlowRate (kg/s) + Real64 heatRecCp; // Specific Heat of the Heat Recovery Fluid (J/kg-K) if (this->HeatRecActive) { - HeatRecInNode = this->HeatRecInletNodeNum; - HeatRecInTemp = DataLoopNode::Node(HeatRecInNode).Temp; + heatRecInNode = this->HeatRecInletNodeNum; + heatRecInTemp = DataLoopNode::Node(heatRecInNode).Temp; - HeatRecCp = FluidProperties::GetSpecificHeatGlycol(DataPlant::PlantLoop(this->HRLoopNum).FluidName, - HeatRecInTemp, - DataPlant::PlantLoop(this->HRLoopNum).FluidIndex, - RoutineName); + heatRecCp = FluidProperties::GetSpecificHeatGlycol(DataPlant::PlantLoop(this->HRLoopNum).FluidName, + heatRecInTemp, + DataPlant::PlantLoop(this->HRLoopNum).FluidIndex, + RoutineName); if (FirstHVACIteration && RunFlag) { - HeatRecMdot = this->DesignHeatRecMassFlowRate; + heatRecMdot = this->DesignHeatRecMassFlowRate; } else { - HeatRecMdot = DataLoopNode::Node(HeatRecInNode).MassFlowRate; + heatRecMdot = DataLoopNode::Node(heatRecInNode).MassFlowRate; } } else { - HeatRecInTemp = 0.0; - HeatRecCp = 0.0; - HeatRecMdot = 0.0; + heatRecInTemp = 0.0; + heatRecCp = 0.0; + heatRecMdot = 0.0; } // If no loop demand or Generator OFF, return if (!RunFlag) { this->ElecPowerGenerated = 0.0; this->ElecEnergyGenerated = 0.0; - this->HeatRecInletTemp = HeatRecInTemp; - this->HeatRecOutletTemp = HeatRecInTemp; + this->HeatRecInletTemp = heatRecInTemp; + this->HeatRecOutletTemp = heatRecInTemp; this->HeatRecMdot = 0.0; this->QLubeOilRecovered = 0.0; this->QExhaustRecovered = 0.0; @@ -579,21 +579,21 @@ namespace CTElectricGenerator { // CALCULATE POWER GENERATED AND PLR // Generator output (W) - Real64 ElecPowerGenerated = min(MyLoad, RatedPowerOutput); - ElecPowerGenerated = max(ElecPowerGenerated, 0.0); + Real64 elecPowerGenerated = min(MyLoad, ratedPowerOutput); + elecPowerGenerated = max(elecPowerGenerated, 0.0); // Generator operating part load ratio - Real64 PLR = min(ElecPowerGenerated / RatedPowerOutput, MaxPartLoadRat); - PLR = max(PLR, MinPartLoadRat); - ElecPowerGenerated = PLR * RatedPowerOutput; + Real64 PLR = min(elecPowerGenerated / ratedPowerOutput, maxPartLoadRat); + PLR = max(PLR, minPartLoadRat); + elecPowerGenerated = PLR * ratedPowerOutput; // SET OFF-DESIGN AIR TEMPERATURE DIFFERENCE // (ATAIR) Difference between ambient actual and ambient design temperatures - Real64 AmbientDeltaT; + Real64 ambientDeltaT; if (this->OAInletNode == 0) { - AmbientDeltaT = DataEnvironment::OutDryBulbTemp - DesignAirInletTemp; + ambientDeltaT = DataEnvironment::OutDryBulbTemp - designAirInletTemp; } else { - AmbientDeltaT = DataLoopNode::Node(this->OAInletNode).Temp - DesignAirInletTemp; + ambientDeltaT = DataLoopNode::Node(this->OAInletNode).Temp - designAirInletTemp; } // Use Curve fit to determine Fuel Energy Input. For electric power generated in Watts, the fuel @@ -601,39 +601,39 @@ namespace CTElectricGenerator { // The TempBasedFuelInputCurve is a correction based on deviation from design inlet air temperature conditions. // The first coefficient of this fit should be 1.0 to ensure that no correction is made at design conditions. // (EFUEL) rate of Fuel Energy Required to run COMBUSTION turbine (W) - Real64 FuelUseRate = ElecPowerGenerated * CurveManager::CurveValue(this->PLBasedFuelInputCurve, PLR) * - CurveManager::CurveValue(this->TempBasedFuelInputCurve, AmbientDeltaT); + Real64 FuelUseRate = elecPowerGenerated * CurveManager::CurveValue(this->PLBasedFuelInputCurve, PLR) * + CurveManager::CurveValue(this->TempBasedFuelInputCurve, ambientDeltaT); // Use Curve fit to determine Exhaust Flow. This curve shows the ratio of exhaust gas flow (kg/s) to electric power // output (J/s). The units on ExhaustFlowCurve are (kg/J). When multiplied by the rated power of the unit, // it gives the exhaust flow rate in kg/s // (FEX) Exhaust Gas Flow Rate cubic meters per second??? - Real64 ExhaustFlow = RatedPowerOutput * CurveManager::CurveValue(this->ExhaustFlowCurve, AmbientDeltaT); + Real64 exhaustFlow = ratedPowerOutput * CurveManager::CurveValue(this->ExhaustFlowCurve, ambientDeltaT); // Use Curve fit to determine Exhaust Temperature. This curve calculates the exhaust temperature (C) by // multiplying the exhaust temperature (C) for a particular part load as given by PLBasedExhaustTempCurve // a correction factor based on the deviation from design temperature, TempBasedExhaustTempCurve Real64 QExhaustRec; // recovered exhaust heat (W) - Real64 ExhaustStackTemp; // turbine stack temp. (C) - if ((PLR > 0.0) && ((ExhaustFlow > 0.0) || (MaxExhaustperCTPower > 0.0))) { + Real64 exhaustStackTemp; // turbine stack temp. (C) + if ((PLR > 0.0) && ((exhaustFlow > 0.0) || (maxExhaustperCTPower > 0.0))) { // (TEX) Exhaust Gas Temperature in C - Real64 ExhaustTemp = CurveManager::CurveValue(this->PLBasedExhaustTempCurve, PLR) * - CurveManager::CurveValue(this->TempBasedExhaustTempCurve, AmbientDeltaT); + Real64 exhaustTemp = CurveManager::CurveValue(this->PLBasedExhaustTempCurve, PLR) * + CurveManager::CurveValue(this->TempBasedExhaustTempCurve, ambientDeltaT); // (UACGC) Heat Exchanger UA to Capacity - Real64 UA = this->UACoef(1) * std::pow(RatedPowerOutput, this->UACoef(2)); + Real64 UA_loc = this->UACoef(1) * std::pow(ratedPowerOutput, this->UACoef(2)); // design engine stack saturated steam temp. (C) - Real64 DesignMinExitGasTemp = this->DesignMinExitGasTemp; + Real64 designMinExitGasTemp = this->DesignMinExitGasTemp; - ExhaustStackTemp = DesignMinExitGasTemp + (ExhaustTemp - DesignMinExitGasTemp) / - std::exp(UA / (max(ExhaustFlow, MaxExhaustperCTPower * RatedPowerOutput) * ExhaustCP)); + exhaustStackTemp = designMinExitGasTemp + (exhaustTemp - designMinExitGasTemp) / + std::exp(UA_loc / (max(exhaustFlow, maxExhaustperCTPower * ratedPowerOutput) * exhaustCp)); - QExhaustRec = max(ExhaustFlow * ExhaustCP * (ExhaustTemp - ExhaustStackTemp), 0.0); + QExhaustRec = max(exhaustFlow * exhaustCp * (exhaustTemp - exhaustStackTemp), 0.0); } else { - ExhaustStackTemp = this->DesignMinExitGasTemp; + exhaustStackTemp = this->DesignMinExitGasTemp; QExhaustRec = 0.0; } @@ -641,15 +641,15 @@ namespace CTElectricGenerator { // multiplying the total power generated by the fraction of that power that could be recovered in the lube oil at that // particular part load. // recovered lube oil heat (W) - Real64 QLubeOilRec = ElecPowerGenerated * CurveManager::CurveValue(this->QLubeOilRecoveredCurve, PLR); + Real64 QLubeOilRec = elecPowerGenerated * CurveManager::CurveValue(this->QLubeOilRecoveredCurve, PLR); // Check for divide by zero Real64 HeatRecOutTemp; // Heat Recovery Fluid Outlet Temperature (C) - if ((HeatRecMdot > 0.0) && (HeatRecCp > 0.0)) { - HeatRecOutTemp = (QExhaustRec + QLubeOilRec) / (HeatRecMdot * HeatRecCp) + HeatRecInTemp; + if ((heatRecMdot > 0.0) && (heatRecCp > 0.0)) { + HeatRecOutTemp = (QExhaustRec + QLubeOilRec) / (heatRecMdot * heatRecCp) + heatRecInTemp; } else { - HeatRecMdot = 0.0; - HeatRecOutTemp = HeatRecInTemp; + heatRecMdot = 0.0; + HeatRecOutTemp = heatRecInTemp; QExhaustRec = 0.0; QLubeOilRec = 0.0; } @@ -661,17 +661,17 @@ namespace CTElectricGenerator { Real64 HRecRatio; // When Max Temp is reached the amount of recovered heat has to be reduced. if (HeatRecOutTemp > this->HeatRecMaxTemp) { - if (this->HeatRecMaxTemp != HeatRecInTemp) { - MinHeatRecMdot = (QExhaustRec + QLubeOilRec) / (HeatRecCp * (this->HeatRecMaxTemp - HeatRecInTemp)); + if (this->HeatRecMaxTemp != heatRecInTemp) { + MinHeatRecMdot = (QExhaustRec + QLubeOilRec) / (heatRecCp * (this->HeatRecMaxTemp - heatRecInTemp)); if (MinHeatRecMdot < 0.0) MinHeatRecMdot = 0.0; } // Recalculate Outlet Temperature, with adjusted flowrate - if ((MinHeatRecMdot > 0.0) && (HeatRecCp > 0.0)) { - HeatRecOutTemp = (QExhaustRec + QLubeOilRec) / (MinHeatRecMdot * HeatRecCp) + HeatRecInTemp; - HRecRatio = HeatRecMdot / MinHeatRecMdot; + if ((MinHeatRecMdot > 0.0) && (heatRecCp > 0.0)) { + HeatRecOutTemp = (QExhaustRec + QLubeOilRec) / (MinHeatRecMdot * heatRecCp) + heatRecInTemp; + HRecRatio = heatRecMdot / MinHeatRecMdot; } else { - HeatRecOutTemp = HeatRecInTemp; + HeatRecOutTemp = heatRecInTemp; HRecRatio = 0.0; } QLubeOilRec *= HRecRatio; @@ -680,39 +680,39 @@ namespace CTElectricGenerator { // Calculate Energy // Generator output (J) - Real64 ElectricEnergyGen = ElecPowerGenerated * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + Real64 ElectricEnergyGen = elecPowerGenerated * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; // Amount of Fuel Energy Required to run COMBUSTION turbine (J) Real64 FuelEnergyUsed = FuelUseRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; // recovered lube oil heat (J) - Real64 LubeOilEnergyRec = QLubeOilRec * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + Real64 lubeOilEnergyRec = QLubeOilRec * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; // recovered exhaust heat (J) - Real64 ExhaustEnergyRec = QExhaustRec * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; + Real64 exhaustEnergyRec = QExhaustRec * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - this->ElecPowerGenerated = ElecPowerGenerated; + this->ElecPowerGenerated = elecPowerGenerated; this->ElecEnergyGenerated = ElectricEnergyGen; - this->HeatRecInletTemp = HeatRecInTemp; + this->HeatRecInletTemp = heatRecInTemp; this->HeatRecOutletTemp = HeatRecOutTemp; - this->HeatRecMdot = HeatRecMdot; + this->HeatRecMdot = heatRecMdot; this->QExhaustRecovered = QExhaustRec; this->QLubeOilRecovered = QLubeOilRec; this->QTotalHeatRecovered = QExhaustRec + QLubeOilRec; this->FuelEnergyUseRate = std::abs(FuelUseRate); - this->ExhaustEnergyRec = ExhaustEnergyRec; - this->LubeOilEnergyRec = LubeOilEnergyRec; - this->TotalHeatEnergyRec = ExhaustEnergyRec + LubeOilEnergyRec; + this->ExhaustEnergyRec = exhaustEnergyRec; + this->LubeOilEnergyRec = lubeOilEnergyRec; + this->TotalHeatEnergyRec = exhaustEnergyRec + lubeOilEnergyRec; this->FuelEnergy = std::abs(FuelEnergyUsed); // Heating Value of Fuel in (kJ/kg) - Real64 FuelHeatingValue = this->FuelHeatingValue; + Real64 fuelHeatingValue = this->FuelHeatingValue; - this->FuelMdot = std::abs(FuelUseRate) / (FuelHeatingValue * KJtoJ); + this->FuelMdot = std::abs(FuelUseRate) / (fuelHeatingValue * KJtoJ); - this->ExhaustStackTemp = ExhaustStackTemp; + this->ExhaustStackTemp = exhaustStackTemp; if (this->HeatRecActive) { int HeatRecOutletNode = this->HeatRecOutletNodeNum; @@ -720,7 +720,7 @@ namespace CTElectricGenerator { } } - void CTGeneratorSpecs::InitCTGenerators(bool const RunFlag, // TRUE when Generator operating + void CTGeneratorData::InitCTGenerators(bool const RunFlag, // TRUE when Generator operating bool const FirstHVACIteration) { @@ -839,31 +839,6 @@ namespace CTElectricGenerator { } } -// void GetCTGeneratorResults(int const EP_UNUSED(GeneratorType), // type of Generator -// int const genNum, -// 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: -// // get some results for load center's aggregation -// -// // called by ElectricPowerServiceManager. this function needs to go away eventually. -// -// GeneratorPower = CTGenerator(genNum).ElecPowerGenerated; -// GeneratorEnergy = CTGenerator(genNum).ElecEnergyGenerated; -// ThermalPower = CTGenerator(genNum).QTotalHeatRecovered; -// ThermalEnergy = CTGenerator(genNum).TotalHeatEnergyRec; -// } - } // namespace CTElectricGenerator } // namespace EnergyPlus diff --git a/src/EnergyPlus/CTElectricGenerator.hh b/src/EnergyPlus/CTElectricGenerator.hh index c7c7b1e5304..631eab8c9db 100644 --- a/src/EnergyPlus/CTElectricGenerator.hh +++ b/src/EnergyPlus/CTElectricGenerator.hh @@ -65,7 +65,7 @@ namespace CTElectricGenerator { extern int NumCTGenerators; // number of CT Generators specified in input - struct CTGeneratorSpecs : PlantComponent + struct CTGeneratorData : PlantComponent { // Members std::string Name; // user identifier @@ -128,7 +128,7 @@ namespace CTElectricGenerator { bool MyFlag; // Default Constructor - CTGeneratorSpecs() + CTGeneratorData() : TypeOf("Generator:CombustionTurbine"), CompType_Num(iGeneratorCombTurbine), RatedPowerOutput(0.0), ElectricCircuitNode(0), MinPartLoadRat(0.0), MaxPartLoadRat(0.0), OptPartLoadRat(0.0), FuelEnergyUseRate(0.0), FuelEnergy(0.0), PLBasedFuelInputCurve(0), TempBasedFuelInputCurve(0), ExhaustFlow(0.0), ExhaustFlowCurve(0), ExhaustTemp(0.0), PLBasedExhaustTempCurve(0), @@ -158,39 +158,10 @@ namespace CTElectricGenerator { }; // Object Data - extern Array1D CTGenerator; // dimension to number of machines - -// // Static functions -// void SimCTGenerator(int GeneratorType, // type of Generator -// std::string const &GeneratorName, // user specified name of Generator -// int &GeneratorIndex, -// bool RunFlag, // simulate Generator when TRUE -// Real64 MyLoad, // generator demand -// bool FirstHVACIteration); -// -// void SimCTPlantHeatRecovery(std::string const &CompType, // unused1208 -// std::string const &CompName, -// int CompTypeNum, // unused1208 -// int &CompNum, -// bool RunFlag, -// bool &InitLoopEquip, -// Real64 &MyLoad, -// Real64 &MaxCap, -// Real64 &MinCap, -// Real64 &OptCap, -// bool FirstHVACIteration // TRUE if First iteration of simulation -// ); + extern Array1D CTGenerator; // dimension to number of machines void GetCTGeneratorInput(); -// void GetCTGeneratorResults(int GeneratorType, // type of Generator -// int genNum, -// Real64 &GeneratorPower, // electrical power -// Real64 &GeneratorEnergy, // electrical energy -// Real64 &ThermalPower, // heat power -// Real64 &ThermalEnergy // heat energy -// ); - void clear_state(); } // namespace CTElectricGenerator diff --git a/src/EnergyPlus/ElectricPowerServiceManager.cc b/src/EnergyPlus/ElectricPowerServiceManager.cc index 406605c6b50..ad66683a10b 100644 --- a/src/EnergyPlus/ElectricPowerServiceManager.cc +++ b/src/EnergyPlus/ElectricPowerServiceManager.cc @@ -2108,17 +2108,17 @@ void GeneratorController::simGeneratorGetPowerOutput(bool const runFlag, } case GeneratorType::combTurbine: { - auto thisCTE = CTElectricGenerator::CTGeneratorSpecs::factory(name); + auto thisCTE = CTElectricGenerator::CTGeneratorData::factory(name); // dummy vars PlantLocation L(0,0,0,0); Real64 tempLoad = myElecLoadRequest; // simulate 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; + dynamic_cast (thisCTE)->InitCTGenerators(runFlag, FirstHVACIteration); + dynamic_cast (thisCTE)->CalcCTGeneratorModel(runFlag, tempLoad, FirstHVACIteration); + electricPowerOutput = dynamic_cast (thisCTE)->ElecPowerGenerated; + thermalPowerOutput = dynamic_cast (thisCTE)->QTotalHeatRecovered; break; } case GeneratorType::pV: { diff --git a/src/EnergyPlus/Plant/PlantManager.cc b/src/EnergyPlus/Plant/PlantManager.cc index cde206ad8f8..b82abfc728a 100644 --- a/src/EnergyPlus/Plant/PlantManager.cc +++ b/src/EnergyPlus/Plant/PlantManager.cc @@ -1272,7 +1272,7 @@ namespace EnergyPlus { } else if (LoopSideNum == SupplySide) { this_comp.CurOpSchemeType = UnknownStatusOpSchemeType; } - this_comp.compPtr = CTElectricGenerator::CTGeneratorSpecs::factory(CompNames(CompNum)); + this_comp.compPtr = CTElectricGenerator::CTGeneratorData::factory(CompNames(CompNum)); } else if (UtilityRoutines::SameString(this_comp_type, "Generator:MicroCHP")) { this_comp.TypeOf_Num = TypeOf_Generator_MicroCHP; this_comp.GeneralEquipType = GenEquipTypes_Generator; From 0832fb8a3b84affb3f1ff4a1201a6becc5746a3b Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Wed, 16 Oct 2019 11:12:39 -0600 Subject: [PATCH 13/13] apply style --- src/EnergyPlus/CTElectricGenerator.cc | 261 +++++++++++--------------- src/EnergyPlus/CTElectricGenerator.hh | 8 +- 2 files changed, 115 insertions(+), 154 deletions(-) diff --git a/src/EnergyPlus/CTElectricGenerator.cc b/src/EnergyPlus/CTElectricGenerator.cc index f6ed834570b..6355ce7e9c8 100644 --- a/src/EnergyPlus/CTElectricGenerator.cc +++ b/src/EnergyPlus/CTElectricGenerator.cc @@ -67,8 +67,8 @@ #include #include #include -#include #include +#include #include namespace EnergyPlus { @@ -96,8 +96,8 @@ namespace CTElectricGenerator { // All CT Generator models are based on a polynomial fit of Generator // performance data. - int NumCTGenerators(0); // number of CT Generators specified in input - bool getCTInputFlag(true); // then TRUE, calls subroutine to read input file. + int NumCTGenerators(0); // number of CT Generators specified in input + bool getCTInputFlag(true); // then TRUE, calls subroutine to read input file. Array1D CTGenerator; // dimension to number of machines @@ -123,12 +123,16 @@ namespace CTElectricGenerator { } } // If we didn't find it, fatal - ShowFatalError("LocalCombustionTurbineGeneratorFactory: Error getting inputs for combustion turbine generator named: " + objectName); // LCOV_EXCL_LINE + ShowFatalError("LocalCombustionTurbineGeneratorFactory: Error getting inputs for combustion turbine generator named: " + + objectName); // LCOV_EXCL_LINE // Shut up the compiler return nullptr; // LCOV_EXCL_LINE } - void CTGeneratorData::simulate(const EnergyPlus::PlantLocation &EP_UNUSED(calledFromLocation), bool EP_UNUSED(FirstHVACIteration), Real64 &EP_UNUSED(CurLoad), bool EP_UNUSED(RunFlag)) + void CTGeneratorData::simulate(const EnergyPlus::PlantLocation &EP_UNUSED(calledFromLocation), + bool EP_UNUSED(FirstHVACIteration), + Real64 &EP_UNUSED(CurLoad), + bool EP_UNUSED(RunFlag)) { // SUBROUTINE INFORMATION: // AUTHOR Dan Fisher @@ -198,8 +202,14 @@ namespace CTElectricGenerator { } // Not sure what to do with electric nodes, so do not use optional arguments - CTGenerator(genNum).ElectricCircuitNode = NodeInputManager::GetOnlySingleNode( - AlphArray(2), ErrorsFound, DataIPShortCuts::cCurrentModuleObject, AlphArray(1), DataLoopNode::NodeType_Electric, DataLoopNode::NodeConnectionType_Electric, 1, DataLoopNode::ObjectIsNotParent); + CTGenerator(genNum).ElectricCircuitNode = NodeInputManager::GetOnlySingleNode(AlphArray(2), + ErrorsFound, + DataIPShortCuts::cCurrentModuleObject, + AlphArray(1), + DataLoopNode::NodeType_Electric, + DataLoopNode::NodeConnectionType_Electric, + 1, + DataLoopNode::ObjectIsNotParent); CTGenerator(genNum).MinPartLoadRat = NumArray(2); CTGenerator(genNum).MaxPartLoadRat = NumArray(3); @@ -260,26 +270,40 @@ namespace CTElectricGenerator { if (CTGenerator(genNum).DesignHeatRecVolFlowRate > 0.0) { CTGenerator(genNum).HeatRecActive = true; - CTGenerator(genNum).HeatRecInletNodeNum = NodeInputManager::GetOnlySingleNode( - AlphArray(9), ErrorsFound, DataIPShortCuts::cCurrentModuleObject, AlphArray(1), DataLoopNode::NodeType_Water, DataLoopNode::NodeConnectionType_Inlet, 1, DataLoopNode::ObjectIsNotParent); + CTGenerator(genNum).HeatRecInletNodeNum = NodeInputManager::GetOnlySingleNode(AlphArray(9), + ErrorsFound, + DataIPShortCuts::cCurrentModuleObject, + AlphArray(1), + DataLoopNode::NodeType_Water, + DataLoopNode::NodeConnectionType_Inlet, + 1, + DataLoopNode::ObjectIsNotParent); if (CTGenerator(genNum).HeatRecInletNodeNum == 0) { ShowSevereError("Missing Node Name, Heat Recovery Inlet, for " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } - CTGenerator(genNum).HeatRecOutletNodeNum = NodeInputManager::GetOnlySingleNode( - AlphArray(10), ErrorsFound, DataIPShortCuts::cCurrentModuleObject, AlphArray(1), DataLoopNode::NodeType_Water, DataLoopNode::NodeConnectionType_Outlet, 1, DataLoopNode::ObjectIsNotParent); + CTGenerator(genNum).HeatRecOutletNodeNum = NodeInputManager::GetOnlySingleNode(AlphArray(10), + ErrorsFound, + DataIPShortCuts::cCurrentModuleObject, + AlphArray(1), + DataLoopNode::NodeType_Water, + DataLoopNode::NodeConnectionType_Outlet, + 1, + DataLoopNode::ObjectIsNotParent); if (CTGenerator(genNum).HeatRecOutletNodeNum == 0) { ShowSevereError("Missing Node Name, Heat Recovery Outlet, for " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } - BranchNodeConnections::TestCompSet(DataIPShortCuts::cCurrentModuleObject, AlphArray(1), AlphArray(9), AlphArray(10), "Heat Recovery Nodes"); + BranchNodeConnections::TestCompSet( + DataIPShortCuts::cCurrentModuleObject, AlphArray(1), AlphArray(9), AlphArray(10), "Heat Recovery Nodes"); PlantUtilities::RegisterPlantCompDesignFlow(CTGenerator(genNum).HeatRecInletNodeNum, CTGenerator(genNum).DesignHeatRecVolFlowRate); } else { CTGenerator(genNum).HeatRecActive = false; CTGenerator(genNum).HeatRecInletNodeNum = 0; CTGenerator(genNum).HeatRecOutletNodeNum = 0; if (!DataIPShortCuts::lAlphaFieldBlanks(9) || !DataIPShortCuts::lAlphaFieldBlanks(10)) { - ShowWarningError("Since Design Heat Flow Rate = 0.0, Heat Recovery inactive for " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); + ShowWarningError("Since Design Heat Flow Rate = 0.0, Heat Recovery inactive for " + DataIPShortCuts::cCurrentModuleObject + '=' + + AlphArray(1)); ShowContinueError("However, Node names were specified for Heat Recovery inlet or outlet nodes"); } } @@ -353,12 +377,7 @@ namespace CTElectricGenerator { void CTGeneratorData::setupOutputVars() { - SetupOutputVariable("Generator Produced Electric Power", - OutputProcessor::Unit::W, - this->ElecPowerGenerated, - "System", - "Average", - this->Name); + SetupOutputVariable("Generator Produced Electric Power", OutputProcessor::Unit::W, this->ElecPowerGenerated, "System", "Average", this->Name); SetupOutputVariable("Generator Produced Electric Energy", OutputProcessor::Unit::J, @@ -372,12 +391,8 @@ namespace CTElectricGenerator { _, "Plant"); - SetupOutputVariable("Generator " + this->FuelType + " Rate", - OutputProcessor::Unit::W, - this->FuelEnergyUseRate, - "System", - "Average", - this->Name); + SetupOutputVariable( + "Generator " + this->FuelType + " Rate", OutputProcessor::Unit::W, this->FuelEnergyUseRate, "System", "Average", this->Name); SetupOutputVariable("Generator " + this->FuelType + " Energy", OutputProcessor::Unit::J, @@ -392,41 +407,18 @@ namespace CTElectricGenerator { "Plant"); // general fuel use report (to match other generators) - SetupOutputVariable("Generator Fuel HHV Basis Rate", - OutputProcessor::Unit::W, - this->FuelEnergyUseRate, - "System", - "Average", - this->Name); + SetupOutputVariable("Generator Fuel HHV Basis Rate", OutputProcessor::Unit::W, this->FuelEnergyUseRate, "System", "Average", this->Name); - SetupOutputVariable("Generator Fuel HHV Basis Energy", - OutputProcessor::Unit::J, - this->FuelEnergy, - "System", - "Sum", - this->Name); + SetupOutputVariable("Generator Fuel HHV Basis Energy", OutputProcessor::Unit::J, this->FuelEnergy, "System", "Sum", this->Name); - SetupOutputVariable("Generator " + this->FuelType + " Mass Flow Rate", - OutputProcessor::Unit::kg_s, - this->FuelMdot, - "System", - "Average", - this->Name); + SetupOutputVariable( + "Generator " + this->FuelType + " Mass Flow Rate", OutputProcessor::Unit::kg_s, this->FuelMdot, "System", "Average", this->Name); - SetupOutputVariable("Generator Exhaust Air Temperature", - OutputProcessor::Unit::C, - this->ExhaustStackTemp, - "System", - "Average", - this->Name); + SetupOutputVariable("Generator Exhaust Air Temperature", OutputProcessor::Unit::C, this->ExhaustStackTemp, "System", "Average", this->Name); if (this->HeatRecActive) { - SetupOutputVariable("Generator Exhaust Heat Recovery Rate", - OutputProcessor::Unit::W, - this->QExhaustRecovered, - "System", - "Average", - this->Name); + SetupOutputVariable( + "Generator Exhaust Heat Recovery Rate", OutputProcessor::Unit::W, this->QExhaustRecovered, "System", "Average", this->Name); SetupOutputVariable("Generator Exhaust Heat Recovery Energy", OutputProcessor::Unit::J, @@ -440,12 +432,8 @@ namespace CTElectricGenerator { _, "Plant"); - SetupOutputVariable("Generator Lube Heat Recovery Rate", - OutputProcessor::Unit::W, - this->QLubeOilRecovered, - "System", - "Average", - this->Name); + SetupOutputVariable( + "Generator Lube Heat Recovery Rate", OutputProcessor::Unit::W, this->QLubeOilRecovered, "System", "Average", this->Name); SetupOutputVariable("Generator Lube Heat Recovery Energy", OutputProcessor::Unit::J, @@ -459,46 +447,25 @@ namespace CTElectricGenerator { _, "Plant"); - SetupOutputVariable("Generator Produced Thermal Rate", - OutputProcessor::Unit::W, - this->QTotalHeatRecovered, - "System", - "Average", - this->Name); + SetupOutputVariable( + "Generator Produced Thermal Rate", OutputProcessor::Unit::W, this->QTotalHeatRecovered, "System", "Average", this->Name); - SetupOutputVariable("Generator Produced Thermal Energy", - OutputProcessor::Unit::J, - this->TotalHeatEnergyRec, - "System", - "Sum", - this->Name); + SetupOutputVariable("Generator Produced Thermal Energy", OutputProcessor::Unit::J, this->TotalHeatEnergyRec, "System", "Sum", this->Name); - SetupOutputVariable("Generator Heat Recovery Inlet Temperature", - OutputProcessor::Unit::C, - this->HeatRecInletTemp, - "System", - "Average", - this->Name); + SetupOutputVariable( + "Generator Heat Recovery Inlet Temperature", OutputProcessor::Unit::C, this->HeatRecInletTemp, "System", "Average", this->Name); - SetupOutputVariable("Generator Heat Recovery Outlet Temperature", - OutputProcessor::Unit::C, - this->HeatRecOutletTemp, - "System", - "Average", - this->Name); + SetupOutputVariable( + "Generator Heat Recovery Outlet Temperature", OutputProcessor::Unit::C, this->HeatRecOutletTemp, "System", "Average", this->Name); - SetupOutputVariable("Generator Heat Recovery Mass Flow Rate", - OutputProcessor::Unit::kg_s, - this->HeatRecMdot, - "System", - "Average", - this->Name); + SetupOutputVariable( + "Generator Heat Recovery Mass Flow Rate", OutputProcessor::Unit::kg_s, this->HeatRecMdot, "System", "Average", this->Name); } } - void CTGeneratorData::CalcCTGeneratorModel(bool const RunFlag, // TRUE when Generator operating - Real64 const MyLoad, // Generator demand - bool const FirstHVACIteration) + void CTGeneratorData::CalcCTGeneratorModel(bool const RunFlag, // TRUE when Generator operating + Real64 const MyLoad, // Generator demand + bool const FirstHVACIteration) { // SUBROUTINE INFORMATION: // AUTHOR Dan Fisher @@ -532,20 +499,18 @@ namespace CTElectricGenerator { // design turbine inlet temperature (C) Real64 designAirInletTemp = this->DesignAirInletTemp; - int heatRecInNode; // Heat Recovery Fluid Inlet Node Num + int heatRecInNode; // Heat Recovery Fluid Inlet Node Num Real64 heatRecInTemp; // Heat Recovery Fluid Inlet Temperature (C) - Real64 heatRecMdot; // Heat Recovery Fluid Mass FlowRate (kg/s) - Real64 heatRecCp; // Specific Heat of the Heat Recovery Fluid (J/kg-K) + Real64 heatRecMdot; // Heat Recovery Fluid Mass FlowRate (kg/s) + Real64 heatRecCp; // Specific Heat of the Heat Recovery Fluid (J/kg-K) if (this->HeatRecActive) { heatRecInNode = this->HeatRecInletNodeNum; heatRecInTemp = DataLoopNode::Node(heatRecInNode).Temp; - heatRecCp = FluidProperties::GetSpecificHeatGlycol(DataPlant::PlantLoop(this->HRLoopNum).FluidName, - heatRecInTemp, - DataPlant::PlantLoop(this->HRLoopNum).FluidIndex, - RoutineName); + heatRecCp = FluidProperties::GetSpecificHeatGlycol( + DataPlant::PlantLoop(this->HRLoopNum).FluidName, heatRecInTemp, DataPlant::PlantLoop(this->HRLoopNum).FluidIndex, RoutineName); if (FirstHVACIteration && RunFlag) { heatRecMdot = this->DesignHeatRecMassFlowRate; } else { @@ -614,8 +579,8 @@ namespace CTElectricGenerator { // multiplying the exhaust temperature (C) for a particular part load as given by PLBasedExhaustTempCurve // a correction factor based on the deviation from design temperature, TempBasedExhaustTempCurve - Real64 QExhaustRec; // recovered exhaust heat (W) - Real64 exhaustStackTemp; // turbine stack temp. (C) + Real64 QExhaustRec; // recovered exhaust heat (W) + Real64 exhaustStackTemp; // turbine stack temp. (C) if ((PLR > 0.0) && ((exhaustFlow > 0.0) || (maxExhaustperCTPower > 0.0))) { // (TEX) Exhaust Gas Temperature in C @@ -629,7 +594,7 @@ namespace CTElectricGenerator { Real64 designMinExitGasTemp = this->DesignMinExitGasTemp; exhaustStackTemp = designMinExitGasTemp + (exhaustTemp - designMinExitGasTemp) / - std::exp(UA_loc / (max(exhaustFlow, maxExhaustperCTPower * ratedPowerOutput) * exhaustCp)); + std::exp(UA_loc / (max(exhaustFlow, maxExhaustperCTPower * ratedPowerOutput) * exhaustCp)); QExhaustRec = max(exhaustFlow * exhaustCp * (exhaustTemp - exhaustStackTemp), 0.0); } else { @@ -644,7 +609,7 @@ namespace CTElectricGenerator { Real64 QLubeOilRec = elecPowerGenerated * CurveManager::CurveValue(this->QLubeOilRecoveredCurve, PLR); // Check for divide by zero - Real64 HeatRecOutTemp; // Heat Recovery Fluid Outlet Temperature (C) + Real64 HeatRecOutTemp; // Heat Recovery Fluid Outlet Temperature (C) if ((heatRecMdot > 0.0) && (heatRecCp > 0.0)) { HeatRecOutTemp = (QExhaustRec + QLubeOilRec) / (heatRecMdot * heatRecCp) + heatRecInTemp; } else { @@ -658,7 +623,7 @@ namespace CTElectricGenerator { // Heat Recovery Flow Rate if minimal heat recovery is accomplished Real64 MinHeatRecMdot = 0.0; - Real64 HRecRatio; // When Max Temp is reached the amount of recovered heat has to be reduced. + Real64 HRecRatio; // When Max Temp is reached the amount of recovered heat has to be reduced. if (HeatRecOutTemp > this->HeatRecMaxTemp) { if (this->HeatRecMaxTemp != heatRecInTemp) { @@ -720,8 +685,8 @@ namespace CTElectricGenerator { } } - void CTGeneratorData::InitCTGenerators(bool const RunFlag, // TRUE when Generator operating - bool const FirstHVACIteration) + void CTGeneratorData::InitCTGenerators(bool const RunFlag, // TRUE when Generator operating + bool const FirstHVACIteration) { // SUBROUTINE INFORMATION: @@ -740,17 +705,17 @@ namespace CTElectricGenerator { if (this->MyPlantScanFlag && allocated(DataPlant::PlantLoop) && this->HeatRecActive) { errFlag = false; PlantUtilities::ScanPlantLoopsForObject(this->Name, - DataPlant::TypeOf_Generator_CTurbine, - this->HRLoopNum, - this->HRLoopSideNum, - this->HRBranchNum, - this->HRCompNum, - errFlag, - _, - _, - _, - _, - _); + DataPlant::TypeOf_Generator_CTurbine, + this->HRLoopNum, + this->HRLoopSideNum, + this->HRBranchNum, + this->HRCompNum, + errFlag, + _, + _, + _, + _, + _); if (errFlag) { ShowFatalError("InitCTGenerators: Program terminated due to previous condition(s)."); } @@ -769,20 +734,20 @@ namespace CTElectricGenerator { // size mass flow rate Real64 rho = FluidProperties::GetDensityGlycol(DataPlant::PlantLoop(this->HRLoopNum).FluidName, - DataGlobals::InitConvTemp, - DataPlant::PlantLoop(this->HRLoopNum).FluidIndex, - RoutineName); + DataGlobals::InitConvTemp, + DataPlant::PlantLoop(this->HRLoopNum).FluidIndex, + RoutineName); this->DesignHeatRecMassFlowRate = rho * this->DesignHeatRecVolFlowRate; PlantUtilities::InitComponentNodes(0.0, - this->DesignHeatRecMassFlowRate, - HeatRecInletNode, - HeatRecOutletNode, - this->HRLoopNum, - this->HRLoopSideNum, - this->HRBranchNum, - this->HRCompNum); + this->DesignHeatRecMassFlowRate, + HeatRecInletNode, + HeatRecOutletNode, + this->HRLoopNum, + this->HRLoopSideNum, + this->HRBranchNum, + this->HRCompNum); this->MySizeAndNodeInitFlag = false; } // end one time inits @@ -796,13 +761,13 @@ namespace CTElectricGenerator { DataLoopNode::Node(HeatRecOutletNode).Temp = 20.0; // set the node max and min mass flow rates PlantUtilities::InitComponentNodes(0.0, - this->DesignHeatRecMassFlowRate, - HeatRecInletNode, - HeatRecOutletNode, - this->HRLoopNum, - this->HRLoopSideNum, - this->HRBranchNum, - this->HRCompNum); + this->DesignHeatRecMassFlowRate, + HeatRecInletNode, + HeatRecOutletNode, + this->HRLoopNum, + this->HRLoopSideNum, + this->HRBranchNum, + this->HRCompNum); this->MyEnvrnFlag = false; } // end environmental inits @@ -820,21 +785,21 @@ namespace CTElectricGenerator { mdot = 0.0; } PlantUtilities::SetComponentFlowRate(mdot, - this->HeatRecInletNodeNum, - this->HeatRecOutletNodeNum, - this->HRLoopNum, - this->HRLoopSideNum, - this->HRBranchNum, - this->HRCompNum); + this->HeatRecInletNodeNum, + this->HeatRecOutletNodeNum, + this->HRLoopNum, + this->HRLoopSideNum, + this->HRBranchNum, + this->HRCompNum); } else { PlantUtilities::SetComponentFlowRate(this->HeatRecMdot, - this->HeatRecInletNodeNum, - this->HeatRecOutletNodeNum, - this->HRLoopNum, - this->HRLoopSideNum, - this->HRBranchNum, - this->HRCompNum); + this->HeatRecInletNodeNum, + this->HeatRecOutletNodeNum, + this->HRLoopNum, + this->HRLoopSideNum, + this->HRBranchNum, + this->HRCompNum); } } } diff --git a/src/EnergyPlus/CTElectricGenerator.hh b/src/EnergyPlus/CTElectricGenerator.hh index 631eab8c9db..2c8c5a52489 100644 --- a/src/EnergyPlus/CTElectricGenerator.hh +++ b/src/EnergyPlus/CTElectricGenerator.hh @@ -146,15 +146,11 @@ namespace CTElectricGenerator { void setupOutputVars(); - void InitCTGenerators(bool RunFlag, - bool FirstHVACIteration); + void InitCTGenerators(bool RunFlag, bool FirstHVACIteration); - void CalcCTGeneratorModel(bool RunFlag, - Real64 MyLoad, - bool FirstHVACIteration); + void CalcCTGeneratorModel(bool RunFlag, Real64 MyLoad, bool FirstHVACIteration); static PlantComponent *factory(std::string const &objectName); - }; // Object Data