diff --git a/src/EnergyPlus/CTElectricGenerator.cc b/src/EnergyPlus/CTElectricGenerator.cc index aeec2e8b387..6355ce7e9c8 100644 --- a/src/EnergyPlus/CTElectricGenerator.cc +++ b/src/EnergyPlus/CTElectricGenerator.cc @@ -61,13 +61,13 @@ #include #include #include -#include #include #include #include #include #include #include +#include #include #include @@ -75,7 +75,7 @@ namespace EnergyPlus { namespace CTElectricGenerator { - //__________________________________________________________________________ + //__________________________________________________________________________; // BLAST inherited generators: // CTElectricGenerator (COMBUSTION Turbine) @@ -96,127 +96,59 @@ 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; - using DataGlobals::BeginEnvrnFlag; - 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; - - 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) - { - // SUBROUTINE INFORMATION: - // AUTHOR Dan Fisher - // DATE WRITTEN Sept. 2000 - // MODIFIED na - // RE-ENGINEERED na + int NumCTGenerators(0); // number of CT Generators specified in input + bool getCTInputFlag(true); // then TRUE, calls subroutine to read input file. - // 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. - - // Using/Aliasing - using General::TrimSigDigits; + Array1D CTGenerator; // dimension to number of machines - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - int GenNum; // Generator number counter + void clear_state() + { + NumCTGenerators = 0; + getCTInputFlag = true; + CTGenerator.deallocate(); + } - // Get Generator data from input file - if (GetCTInput) { + PlantComponent *CTGeneratorData::factory(std::string const &objectName) + { + // 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=" + TrimSigDigits(GenNum) + - ", Number of CT Engine Generators=" + TrimSigDigits(NumCTGenerators) + ", Generator name=" + GeneratorName); - } - if (CheckEquipName(GenNum)) { - if (GeneratorName != CTGenerator(GenNum).Name) { - ShowFatalError("SimCTGenerator: Invalid GeneratorIndex passed=" + TrimSigDigits(GenNum) + ", Generator name=" + GeneratorName + - ", stored Generator Name for that index=" + CTGenerator(GenNum).Name); - } - CheckEquipName(GenNum) = false; + // Now look for this particular generator in the list + for (auto &CTGen : CTGenerator) { + if (CTGen.Name == objectName) { + return &CTGen; } } - - InitCTGenerators(GenNum, RunFlag, MyLoad, FirstHVACIteration); - CalcCTGeneratorModel(GenNum, RunFlag, MyLoad, FirstHVACIteration); - UpdateCTGeneratorRecords(RunFlag, GenNum); + // 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 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 - ) + void CTGeneratorData::simulate(const EnergyPlus::PlantLocation &EP_UNUSED(calledFromLocation), + bool EP_UNUSED(FirstHVACIteration), + Real64 &EP_UNUSED(CurLoad), + bool EP_UNUSED(RunFlag)) { - // 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 - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - - 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 functions directly. } - // End CT Generator Module Driver Subroutines - //****************************************************************************** - - // Beginning of CT Generator Module Get Input subroutines - //****************************************************************************** - void GetCTGeneratorInput() { // SUBROUTINE INFORMATION: @@ -227,20 +159,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; - using General::RoundSigDigits; - using NodeInputManager::GetOnlySingleNode; - 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 int IOStat; // IO Status when calling get input subroutine @@ -248,129 +166,144 @@ namespace CTElectricGenerator { Array1D NumArray(12); // numeric data static bool ErrorsFound(false); // error flag - // FLOW - - 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; } // 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) { - inputProcessor->getObjectItem(cCurrentModuleObject, - GeneratorNum, + for (int genNum = 1; genNum <= NumCTGenerators; ++genNum) { + inputProcessor->getObjectItem(DataIPShortCuts::cCurrentModuleObject, + genNum, AlphArray, NumAlphas, NumArray, 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(genNum).Name = AlphArray(1); - CTGenerator(GeneratorNum).RatedPowerOutput = NumArray(1); + CTGenerator(genNum).RatedPowerOutput = NumArray(1); if (NumArray(1) == 0.0) { - ShowSevereError("Invalid " + cNumericFieldNames(1) + '=' + 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 = GetOnlySingleNode( - AlphArray(2), ErrorsFound, cCurrentModuleObject, AlphArray(1), NodeType_Electric, NodeConnectionType_Electric, 1, ObjectIsNotParent); - - CTGenerator(GeneratorNum).MinPartLoadRat = NumArray(2); - CTGenerator(GeneratorNum).MaxPartLoadRat = NumArray(3); - CTGenerator(GeneratorNum).OptPartLoadRat = NumArray(4); + 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); + CTGenerator(genNum).OptPartLoadRat = NumArray(4); // Load Special CT Generator Input - CTGenerator(GeneratorNum).PLBasedFuelInputCurve = 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)); + 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 = 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)); + 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 = 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)); + 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 = 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)); + 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 = 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)); + 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 = 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)); + 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(GeneratorNum).MaxExhaustperCTPower = NumArray(7); - CTGenerator(GeneratorNum).DesignMinExitGasTemp = NumArray(8); - CTGenerator(GeneratorNum).DesignAirInletTemp = NumArray(9); - CTGenerator(GeneratorNum).FuelHeatingValue = NumArray(10); - CTGenerator(GeneratorNum).DesignHeatRecVolFlowRate = NumArray(11); - - 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); - if (CTGenerator(GeneratorNum).HeatRecInletNodeNum == 0) { - ShowSevereError("Missing Node Name, Heat Recovery Inlet, for " + cCurrentModuleObject + '=' + AlphArray(1)); + CTGenerator(genNum).UACoef(1) = NumArray(5); + CTGenerator(genNum).UACoef(2) = NumArray(6); + + 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(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(genNum).HeatRecInletNodeNum == 0) { + ShowSevereError("Missing Node Name, Heat Recovery Inlet, for " + DataIPShortCuts::cCurrentModuleObject + '=' + AlphArray(1)); ErrorsFound = true; } - CTGenerator(GeneratorNum).HeatRecOutletNodeNum = GetOnlySingleNode( - AlphArray(10), ErrorsFound, cCurrentModuleObject, AlphArray(1), NodeType_Water, NodeConnectionType_Outlet, 1, ObjectIsNotParent); - if (CTGenerator(GeneratorNum).HeatRecOutletNodeNum == 0) { - ShowSevereError("Missing Node Name, Heat Recovery Outlet, for " + cCurrentModuleObject + '=' + AlphArray(1)); + 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; } - TestCompSet(cCurrentModuleObject, AlphArray(1), AlphArray(9), AlphArray(10), "Heat Recovery Nodes"); - RegisterPlantCompDesignFlow(CTGenerator(GeneratorNum).HeatRecInletNodeNum, CTGenerator(GeneratorNum).DesignHeatRecVolFlowRate); + BranchNodeConnections::TestCompSet( + DataIPShortCuts::cCurrentModuleObject, AlphArray(1), AlphArray(9), AlphArray(10), "Heat Recovery Nodes"); + PlantUtilities::RegisterPlantCompDesignFlow(CTGenerator(genNum).HeatRecInletNodeNum, CTGenerator(genNum).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)); + 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"); } } @@ -379,57 +312,57 @@ 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 " + 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; } } - CTGenerator(GeneratorNum).HeatRecMaxTemp = NumArray(12); + CTGenerator(genNum).HeatRecMaxTemp = NumArray(12); // begin CR7021 - if (lAlphaFieldBlanks(12)) { - CTGenerator(GeneratorNum).OAInletNode = 0; + if (DataIPShortCuts::lAlphaFieldBlanks(12)) { + CTGenerator(genNum).OAInletNode = 0; } else { - CTGenerator(GeneratorNum).OAInletNode = GetOnlySingleNode(AlphArray(12), - ErrorsFound, - cCurrentModuleObject, - AlphArray(1), - NodeType_Air, - NodeConnectionType_OutsideAirReference, - 1, - ObjectIsNotParent); - if (!CheckOutAirNodeNumber(CTGenerator(GeneratorNum).OAInletNode)) { - ShowSevereError(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; @@ -438,156 +371,101 @@ 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) { - SetupOutputVariable("Generator Produced Electric Power", - OutputProcessor::Unit::W, - CTGeneratorReport(GeneratorNum).PowerGen, - "System", - "Average", - CTGenerator(GeneratorNum).Name); - SetupOutputVariable("Generator Produced Electric Energy", + void CTGeneratorData::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, this->QExhaustRecovered, "System", "Average", this->Name); + + SetupOutputVariable("Generator Exhaust Heat Recovery Energy", OutputProcessor::Unit::J, - CTGeneratorReport(GeneratorNum).EnergyGen, + this->ExhaustEnergyRec, "System", "Sum", - CTGenerator(GeneratorNum).Name, + this->Name, _, - "ElectricityProduced", - "COGENERATION", + "ENERGYTRANSFER", + "HEATRECOVERY", _, "Plant"); - SetupOutputVariable("Generator " + CTGenerator(GeneratorNum).FuelType + " Rate", - OutputProcessor::Unit::W, - CTGeneratorReport(GeneratorNum).FuelEnergyUseRate, - "System", - "Average", - CTGenerator(GeneratorNum).Name); - SetupOutputVariable("Generator " + CTGenerator(GeneratorNum).FuelType + " Energy", + SetupOutputVariable( + "Generator Lube Heat Recovery Rate", OutputProcessor::Unit::W, this->QLubeOilRecovered, "System", "Average", this->Name); + + SetupOutputVariable("Generator Lube Heat Recovery Energy", OutputProcessor::Unit::J, - CTGeneratorReport(GeneratorNum).FuelEnergy, + this->LubeOilEnergyRec, "System", "Sum", - CTGenerator(GeneratorNum).Name, + this->Name, _, - CTGenerator(GeneratorNum).FuelType, - "COGENERATION", + "ENERGYTRANSFER", + "HEATRECOVERY", _, "Plant"); - // general fuel use report (to match other generators) - SetupOutputVariable("Generator Fuel HHV Basis Rate", - OutputProcessor::Unit::W, - CTGeneratorReport(GeneratorNum).FuelEnergyUseRate, - "System", - "Average", - CTGenerator(GeneratorNum).Name); - SetupOutputVariable("Generator Fuel HHV Basis Energy", - OutputProcessor::Unit::J, - CTGeneratorReport(GeneratorNum).FuelEnergy, - "System", - "Sum", - CTGenerator(GeneratorNum).Name); + SetupOutputVariable( + "Generator Produced Thermal Rate", OutputProcessor::Unit::W, this->QTotalHeatRecovered, "System", "Average", this->Name); - SetupOutputVariable("Generator " + CTGenerator(GeneratorNum).FuelType + " Mass Flow Rate", - OutputProcessor::Unit::kg_s, - CTGeneratorReport(GeneratorNum).FuelMdot, - "System", - "Average", - CTGenerator(GeneratorNum).Name); + SetupOutputVariable("Generator Produced Thermal Energy", OutputProcessor::Unit::J, this->TotalHeatEnergyRec, "System", "Sum", this->Name); - SetupOutputVariable("Generator Exhaust Air Temperature", - OutputProcessor::Unit::C, - CTGeneratorReport(GeneratorNum).ExhaustStackTemp, - "System", - "Average", - CTGenerator(GeneratorNum).Name); - - if (CTGenerator(GeneratorNum).HeatRecActive) { - SetupOutputVariable("Generator Exhaust Heat Recovery Rate", - OutputProcessor::Unit::W, - CTGeneratorReport(GeneratorNum).QExhaustRecovered, - "System", - "Average", - CTGenerator(GeneratorNum).Name); - SetupOutputVariable("Generator Exhaust Heat Recovery Energy", - OutputProcessor::Unit::J, - CTGeneratorReport(GeneratorNum).ExhaustEnergyRec, - "System", - "Sum", - CTGenerator(GeneratorNum).Name, - _, - "ENERGYTRANSFER", - "HEATRECOVERY", - _, - "Plant"); - - SetupOutputVariable("Generator Lube Heat Recovery Rate", - OutputProcessor::Unit::W, - CTGeneratorReport(GeneratorNum).QLubeOilRecovered, - "System", - "Average", - CTGenerator(GeneratorNum).Name); - SetupOutputVariable("Generator Lube Heat Recovery Energy", - OutputProcessor::Unit::J, - CTGeneratorReport(GeneratorNum).LubeOilEnergyRec, - "System", - "Sum", - CTGenerator(GeneratorNum).Name, - _, - "ENERGYTRANSFER", - "HEATRECOVERY", - _, - "Plant"); - - SetupOutputVariable("Generator Produced Thermal Rate", - OutputProcessor::Unit::W, - CTGeneratorReport(GeneratorNum).QTotalHeatRecovered, - "System", - "Average", - CTGenerator(GeneratorNum).Name); - SetupOutputVariable("Generator Produced Thermal Energy", - OutputProcessor::Unit::J, - CTGeneratorReport(GeneratorNum).TotalHeatEnergyRec, - "System", - "Sum", - CTGenerator(GeneratorNum).Name); - - SetupOutputVariable("Generator Heat Recovery Inlet Temperature", - OutputProcessor::Unit::C, - CTGeneratorReport(GeneratorNum).HeatRecInletTemp, - "System", - "Average", - CTGenerator(GeneratorNum).Name); - SetupOutputVariable("Generator Heat Recovery Outlet Temperature", - OutputProcessor::Unit::C, - CTGeneratorReport(GeneratorNum).HeatRecOutletTemp, - "System", - "Average", - CTGenerator(GeneratorNum).Name); - SetupOutputVariable("Generator Heat Recovery Mass Flow Rate", - OutputProcessor::Unit::kg_s, - CTGeneratorReport(GeneratorNum).HeatRecMdot, - "System", - "Average", - CTGenerator(GeneratorNum).Name); - } - } - } + SetupOutputVariable( + "Generator Heat Recovery Inlet Temperature", OutputProcessor::Unit::C, this->HeatRecInletTemp, "System", "Average", this->Name); - // End of Get Input subroutines for the CT Generator Module - //****************************************************************************** + SetupOutputVariable( + "Generator Heat Recovery Outlet Temperature", OutputProcessor::Unit::C, this->HeatRecOutletTemp, "System", "Average", this->Name); - // Beginning of Generator model Subroutines - // ***************************************************************************** + SetupOutputVariable( + "Generator Heat Recovery Mass Flow Rate", OutputProcessor::Unit::kg_s, this->HeatRecMdot, "System", "Average", this->Name); + } + } - void CalcCTGeneratorModel(int const GeneratorNum, // Generator number - 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 @@ -602,174 +480,163 @@ 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 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) - 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) - 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. - - // LOAD LOCAL VARIABLES FROM DATA STRUCTURE (for code readability) - 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; - HeatRecInTemp = Node(HeatRecInNode).Temp; - - HeatRecCp = GetSpecificHeatGlycol(PlantLoop(CTGenerator(GeneratorNum).HRLoopNum).FluidName, - HeatRecInTemp, - PlantLoop(CTGenerator(GeneratorNum).HRLoopNum).FluidIndex, - RoutineName); + // min allowed operating frac full load + Real64 minPartLoadRat = this->MinPartLoadRat; + + // max allowed operating frac full load + Real64 maxPartLoadRat = this->MaxPartLoadRat; + + // Generator nominal capacity (W) + Real64 ratedPowerOutput = this->RatedPowerOutput; + + // MAX EXHAUST FLOW PER W POWER OUTPUT COEFF + Real64 maxExhaustperCTPower = this->MaxExhaustperCTPower; + + // design turbine inlet temperature (C) + Real64 designAirInletTemp = this->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) + + 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); if (FirstHVACIteration && RunFlag) { - HeatRecMdot = CTGenerator(GeneratorNum).DesignHeatRecMassFlowRate; + heatRecMdot = this->DesignHeatRecMassFlowRate; } else { - HeatRecMdot = 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) { - 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; + 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; } // CALCULATE POWER GENERATED AND PLR - ElecPowerGenerated = min(MyLoad, RatedPowerOutput); - ElecPowerGenerated = max(ElecPowerGenerated, 0.0); - PLR = min(ElecPowerGenerated / RatedPowerOutput, MaxPartLoadRat); - PLR = max(PLR, MinPartLoadRat); - ElecPowerGenerated = PLR * RatedPowerOutput; + // Generator output (W) + 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; // SET OFF-DESIGN AIR TEMPERATURE DIFFERENCE - // use OA node if set by user CR7021 - if (CTGenerator(GeneratorNum).OAInletNode == 0) { - AmbientDeltaT = OutDryBulbTemp - DesignAirInletTemp; + // (ATAIR) Difference between ambient actual and ambient design temperatures + Real64 ambientDeltaT; + if (this->OAInletNode == 0) { + ambientDeltaT = DataEnvironment::OutDryBulbTemp - designAirInletTemp; } else { - AmbientDeltaT = Node(CTGenerator(GeneratorNum).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 // 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); + // (EFUEL) rate of Fuel Energy Required to run COMBUSTION turbine (W) + 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 - ExhaustFlow = RatedPowerOutput * CurveValue(CTGenerator(GeneratorNum).ExhaustFlowCurve, AmbientDeltaT); + // (FEX) Exhaust Gas Flow Rate cubic meters per second??? + 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 - if ((PLR > 0.0) && ((ExhaustFlow > 0.0) || (MaxExhaustperCTPower > 0.0))) { - ExhaustTemp = CurveValue(CTGenerator(GeneratorNum).PLBasedExhaustTempCurve, PLR) * - CurveValue(CTGenerator(GeneratorNum).TempBasedExhaustTempCurve, AmbientDeltaT); + 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 + Real64 exhaustTemp = CurveManager::CurveValue(this->PLBasedExhaustTempCurve, PLR) * + CurveManager::CurveValue(this->TempBasedExhaustTempCurve, ambientDeltaT); - UA = CTGenerator(GeneratorNum).UACoef(1) * std::pow(RatedPowerOutput, CTGenerator(GeneratorNum).UACoef(2)); + // (UACGC) Heat Exchanger UA to Capacity + Real64 UA_loc = this->UACoef(1) * std::pow(ratedPowerOutput, this->UACoef(2)); - DesignMinExitGasTemp = CTGenerator(GeneratorNum).DesignMinExitGasTemp; - ExhaustStackTemp = DesignMinExitGasTemp + (ExhaustTemp - DesignMinExitGasTemp) / - std::exp(UA / (max(ExhaustFlow, MaxExhaustperCTPower * RatedPowerOutput) * ExhaustCP)); + // design engine stack saturated steam temp. (C) + Real64 designMinExitGasTemp = this->DesignMinExitGasTemp; - QExhaustRec = max(ExhaustFlow * ExhaustCP * (ExhaustTemp - ExhaustStackTemp), 0.0); + exhaustStackTemp = designMinExitGasTemp + (exhaustTemp - designMinExitGasTemp) / + std::exp(UA_loc / (max(exhaustFlow, maxExhaustperCTPower * ratedPowerOutput) * exhaustCp)); + + QExhaustRec = max(exhaustFlow * exhaustCp * (exhaustTemp - exhaustStackTemp), 0.0); } else { - ExhaustStackTemp = CTGenerator(GeneratorNum).DesignMinExitGasTemp; + exhaustStackTemp = this->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 * CurveValue(CTGenerator(GeneratorNum).QLubeOilRecoveredCurve, PLR); + // recovered lube oil heat (W) + Real64 QLubeOilRec = elecPowerGenerated * CurveManager::CurveValue(this->QLubeOilRecoveredCurve, PLR); // Check for divide by zero - if ((HeatRecMdot > 0.0) && (HeatRecCp > 0.0)) { - HeatRecOutTemp = (QExhaustRec + QLubeOilRec) / (HeatRecMdot * HeatRecCp) + HeatRecInTemp; + Real64 HeatRecOutTemp; // Heat Recovery Fluid Outlet Temperature (C) + 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; } // 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)); + // 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 > this->HeatRecMaxTemp) { + 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; @@ -777,44 +644,49 @@ namespace CTElectricGenerator { } // Calculate Energy - ElectricEnergyGen = ElecPowerGenerated * TimeStepSys * SecInHour; - FuelEnergyUsed = FuelUseRate * TimeStepSys * SecInHour; - LubeOilEnergyRec = QLubeOilRec * TimeStepSys * SecInHour; - ExhaustEnergyRec = QExhaustRec * TimeStepSys * SecInHour; + // Generator output (J) + Real64 ElectricEnergyGen = elecPowerGenerated * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - CTGenerator(GeneratorNum).ElecPowerGenerated = ElecPowerGenerated; - CTGenerator(GeneratorNum).ElecEnergyGenerated = ElectricEnergyGen; + // Amount of Fuel Energy Required to run COMBUSTION turbine (J) + Real64 FuelEnergyUsed = FuelUseRate * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - CTGenerator(GeneratorNum).HeatRecInletTemp = HeatRecInTemp; - CTGenerator(GeneratorNum).HeatRecOutletTemp = HeatRecOutTemp; + // recovered lube oil heat (J) + Real64 lubeOilEnergyRec = QLubeOilRec * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - 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); + // recovered exhaust heat (J) + Real64 exhaustEnergyRec = QExhaustRec * DataHVACGlobals::TimeStepSys * DataGlobals::SecInHour; - FuelHeatingValue = CTGenerator(GeneratorNum).FuelHeatingValue; + this->ElecPowerGenerated = elecPowerGenerated; + this->ElecEnergyGenerated = ElectricEnergyGen; - CTGenerator(GeneratorNum).FuelMdot = std::abs(FuelUseRate) / (FuelHeatingValue * KJtoJ); + this->HeatRecInletTemp = heatRecInTemp; + this->HeatRecOutletTemp = HeatRecOutTemp; - CTGenerator(GeneratorNum).ExhaustStackTemp = ExhaustStackTemp; - } + 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); - // End of CT Generator Module Model Subroutines - // ***************************************************************************** + // Heating Value of Fuel in (kJ/kg) + Real64 fuelHeatingValue = this->FuelHeatingValue; - // Begin CT Generator Module Utility Subroutines - // ***************************************************************************** + this->FuelMdot = std::abs(FuelUseRate) / (fuelHeatingValue * KJtoJ); - void InitCTGenerators(int const GeneratorNum, // Generator number - bool const RunFlag, // TRUE when Generator operating - Real64 const EP_UNUSED(MyLoad), // Generator demand - bool const FirstHVACIteration) + this->ExhaustStackTemp = exhaustStackTemp; + + if (this->HeatRecActive) { + int HeatRecOutletNode = this->HeatRecOutletNodeNum; + DataLoopNode::Node(HeatRecOutletNode).Temp = this->HeatRecOutletTemp; + } + } + + void CTGeneratorData::InitCTGenerators(bool const RunFlag, // TRUE when Generator operating + bool const FirstHVACIteration) { // SUBROUTINE INFORMATION: @@ -826,250 +698,112 @@ 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; - using PlantUtilities::InitComponentNodes; - 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 - - 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; - // FLOW: - - // 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(PlantLoop) && CTGenerator(GeneratorNum).HeatRecActive) { + if (this->MyPlantScanFlag && allocated(DataPlant::PlantLoop) && this->HeatRecActive) { errFlag = false; - ScanPlantLoopsForObject(CTGenerator(GeneratorNum).Name, - TypeOf_Generator_CTurbine, - CTGenerator(GeneratorNum).HRLoopNum, - CTGenerator(GeneratorNum).HRLoopSideNum, - CTGenerator(GeneratorNum).HRBranchNum, - CTGenerator(GeneratorNum).HRCompNum, - errFlag, - _, - _, - _, - _, - _); + PlantUtilities::ScanPlantLoopsForObject(this->Name, + DataPlant::TypeOf_Generator_CTurbine, + this->HRLoopNum, + this->HRLoopSideNum, + this->HRBranchNum, + this->HRCompNum, + errFlag, + _, + _, + _, + _, + _); if (errFlag) { ShowFatalError("InitCTGenerators: Program terminated due to previous condition(s)."); } - MyPlantScanFlag(GeneratorNum) = false; + + this->MyPlantScanFlag = false; + } + + if (this->MyFlag) { + this->setupOutputVars(); + this->MyFlag = false; } - if (MySizeAndNodeInitFlag(GeneratorNum) && (!MyPlantScanFlag(GeneratorNum)) && CTGenerator(GeneratorNum).HeatRecActive) { - HeatRecInletNode = CTGenerator(GeneratorNum).HeatRecInletNodeNum; - HeatRecOutletNode = CTGenerator(GeneratorNum).HeatRecOutletNodeNum; + if (this->MySizeAndNodeInitFlag && (!this->MyPlantScanFlag) && this->HeatRecActive) { + int HeatRecInletNode = this->HeatRecInletNodeNum; + int HeatRecOutletNode = this->HeatRecOutletNodeNum; // size mass flow rate - rho = GetDensityGlycol(PlantLoop(CTGenerator(GeneratorNum).HRLoopNum).FluidName, - DataGlobals::InitConvTemp, - PlantLoop(CTGenerator(GeneratorNum).HRLoopNum).FluidIndex, - RoutineName); - - CTGenerator(GeneratorNum).DesignHeatRecMassFlowRate = rho * CTGenerator(GeneratorNum).DesignHeatRecVolFlowRate; - - InitComponentNodes(0.0, - CTGenerator(GeneratorNum).DesignHeatRecMassFlowRate, - HeatRecInletNode, - HeatRecOutletNode, - CTGenerator(GeneratorNum).HRLoopNum, - CTGenerator(GeneratorNum).HRLoopSideNum, - CTGenerator(GeneratorNum).HRBranchNum, - CTGenerator(GeneratorNum).HRCompNum); - - MySizeAndNodeInitFlag(GeneratorNum) = false; + Real64 rho = FluidProperties::GetDensityGlycol(DataPlant::PlantLoop(this->HRLoopNum).FluidName, + 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->MySizeAndNodeInitFlag = false; } // end one time inits // Do the Begin Environment initializations - if (BeginEnvrnFlag && MyEnvrnFlag(GeneratorNum) && CTGenerator(GeneratorNum).HeatRecActive) { - HeatRecInletNode = CTGenerator(GeneratorNum).HeatRecInletNodeNum; - HeatRecOutletNode = CTGenerator(GeneratorNum).HeatRecOutletNodeNum; + if (DataGlobals::BeginEnvrnFlag && this->MyEnvrnFlag && this->HeatRecActive) { + int HeatRecInletNode = this->HeatRecInletNodeNum; + int HeatRecOutletNode = this->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, - CTGenerator(GeneratorNum).DesignHeatRecMassFlowRate, - HeatRecInletNode, - HeatRecOutletNode, - CTGenerator(GeneratorNum).HRLoopNum, - CTGenerator(GeneratorNum).HRLoopSideNum, - CTGenerator(GeneratorNum).HRBranchNum, - CTGenerator(GeneratorNum).HRCompNum); - - MyEnvrnFlag(GeneratorNum) = false; + PlantUtilities::InitComponentNodes(0.0, + this->DesignHeatRecMassFlowRate, + HeatRecInletNode, + HeatRecOutletNode, + this->HRLoopNum, + this->HRLoopSideNum, + this->HRBranchNum, + this->HRCompNum); + + this->MyEnvrnFlag = false; } // end environmental inits - if (!BeginEnvrnFlag) { - MyEnvrnFlag(GeneratorNum) = true; + if (!DataGlobals::BeginEnvrnFlag) { + this->MyEnvrnFlag = true; } - if (CTGenerator(GeneratorNum).HeatRecActive) { + if (this->HeatRecActive) { if (FirstHVACIteration) { + Real64 mdot; if (RunFlag) { - mdot = CTGenerator(GeneratorNum).DesignHeatRecMassFlowRate; + mdot = this->DesignHeatRecMassFlowRate; } else { mdot = 0.0; } - SetComponentFlowRate(mdot, - CTGenerator(GeneratorNum).HeatRecInletNodeNum, - CTGenerator(GeneratorNum).HeatRecOutletNodeNum, - CTGenerator(GeneratorNum).HRLoopNum, - CTGenerator(GeneratorNum).HRLoopSideNum, - CTGenerator(GeneratorNum).HRBranchNum, - CTGenerator(GeneratorNum).HRCompNum); + PlantUtilities::SetComponentFlowRate(mdot, + this->HeatRecInletNodeNum, + this->HeatRecOutletNodeNum, + this->HRLoopNum, + this->HRLoopSideNum, + this->HRBranchNum, + this->HRCompNum); } else { - SetComponentFlowRate(CTGenerator(GeneratorNum).HeatRecMdot, - CTGenerator(GeneratorNum).HeatRecInletNodeNum, - CTGenerator(GeneratorNum).HeatRecOutletNodeNum, - CTGenerator(GeneratorNum).HRLoopNum, - CTGenerator(GeneratorNum).HRLoopSideNum, - CTGenerator(GeneratorNum).HRBranchNum, - CTGenerator(GeneratorNum).HRCompNum); + PlantUtilities::SetComponentFlowRate(this->HeatRecMdot, + this->HeatRecInletNodeNum, + this->HeatRecOutletNodeNum, + this->HRLoopNum, + this->HRLoopSideNum, + this->HRBranchNum, + this->HRCompNum); } } } - // 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 - ) - { - // SUBROUTINE INFORMATION: - // 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; - 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; - } - - void GetCTGeneratorResults(int const EP_UNUSED(GeneratorType), // type of Generator - int const GeneratorIndex, - Real64 &GeneratorPower, // electrical power - Real64 &GeneratorEnergy, // electrical energy - Real64 &ThermalPower, // heat power - Real64 &ThermalEnergy // heat energy - ) - { - // SUBROUTINE INFORMATION: - // AUTHOR B Griffith - // DATE WRITTEN March 2008 - // MODIFIED na - // RE-ENGINEERED na - - // PURPOSE OF THIS SUBROUTINE: - // 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 diff --git a/src/EnergyPlus/CTElectricGenerator.hh b/src/EnergyPlus/CTElectricGenerator.hh index 1730b79468a..2c8c5a52489 100644 --- a/src/EnergyPlus/CTElectricGenerator.hh +++ b/src/EnergyPlus/CTElectricGenerator.hh @@ -55,31 +55,17 @@ #include #include #include +#include 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 + struct CTGeneratorData : PlantComponent { // Members std::string Name; // user identifier @@ -134,10 +120,15 @@ 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; + bool CheckEquipName; + 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), @@ -146,115 +137,28 @@ 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), CheckEquipName(true), MyFlag(true) { } - }; - - 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() - : PowerGen(0.0), EnergyGen(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) - { - } - }; + void simulate(const PlantLocation &calledFromLocation, bool FirstHVACIteration, Real64 &CurLoad, bool RunFlag) override; - // Object Data - extern Array1D CTGenerator; // dimension to number of machines - extern Array1D CTGeneratorReport; + void setupOutputVars(); - // Functions + void InitCTGenerators(bool RunFlag, bool FirstHVACIteration); - void SimCTGenerator(int const 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); + void CalcCTGeneratorModel(bool RunFlag, Real64 MyLoad, bool FirstHVACIteration); - void SimCTPlantHeatRecovery(std::string const &CompType, // unused1208 - std::string const &CompName, - int const CompTypeNum, // unused1208 - int &CompNum, - bool const RunFlag, - bool &InitLoopEquip, - Real64 &MyLoad, - Real64 &MaxCap, - Real64 &MinCap, - Real64 &OptCap, - bool const FirstHVACIteration // TRUE if First iteration of simulation - ); - - // End CT Generator Module Driver Subroutines - //****************************************************************************** + static PlantComponent *factory(std::string const &objectName); + }; - // Beginning of CT Generator Module Get Input subroutines - //****************************************************************************** + // Object Data + extern Array1D CTGenerator; // dimension to number of machines void GetCTGeneratorInput(); - // 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 - bool const FirstHVACIteration); - - // 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 MyLoad, // Generator demand - bool const FirstHVACIteration); - - // End CT Generator Module Utility Subroutines - // ***************************************************************************** - - // 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 GetCTGeneratorResults(int const GeneratorType, // type of Generator - int const GeneratorIndex, - Real64 &GeneratorPower, // electrical power - Real64 &GeneratorEnergy, // electrical energy - Real64 &ThermalPower, // heat power - Real64 &ThermalEnergy // heat energy - ); - - // End of Record Keeping subroutines for the CT Generator Module - // ***************************************************************************** + void clear_state(); } // namespace CTElectricGenerator diff --git a/src/EnergyPlus/ElectricPowerServiceManager.cc b/src/EnergyPlus/ElectricPowerServiceManager.cc index 8744e5e157f..e180d35fcc5 100644 --- a/src/EnergyPlus/ElectricPowerServiceManager.cc +++ b/src/EnergyPlus/ElectricPowerServiceManager.cc @@ -2114,12 +2114,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::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; break; } case GeneratorType::pV: { diff --git a/src/EnergyPlus/Plant/PlantManager.cc b/src/EnergyPlus/Plant/PlantManager.cc index df43362fc96..7265da82e93 100644 --- a/src/EnergyPlus/Plant/PlantManager.cc +++ b/src/EnergyPlus/Plant/PlantManager.cc @@ -59,6 +59,7 @@ #include #include #include +#include #include #include #include @@ -1281,6 +1282,7 @@ namespace EnergyPlus { } else if (LoopSideNum == SupplySide) { this_comp.CurOpSchemeType = UnknownStatusOpSchemeType; } + 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; diff --git a/src/EnergyPlus/PlantLoopEquip.cc b/src/EnergyPlus/PlantLoopEquip.cc index 4aec8c8ba4b..8b1aa7ff179 100644 --- a/src/EnergyPlus/PlantLoopEquip.cc +++ b/src/EnergyPlus/PlantLoopEquip.cc @@ -187,11 +187,8 @@ namespace PlantLoopEquip { using Pumps::SimPumps; using ScheduleManager::GetCurrentScheduleValue; using WaterThermalTanks::SimWaterThermalTank; - - using CTElectricGenerator::SimCTPlantHeatRecovery; using FuelCellElectricGenerator::SimFuelCellPlantHeatRecovery; using PlantHeatExchangerFluidToFluid::SimFluidHeatExchanger; - using BaseboardRadiator::UpdateBaseboardPlantConnection; using HVACVariableRefrigerantFlow::SimVRFCondenserPlant; using HWBaseboardRadiator::UpdateHWBaseboardPlantConnection; @@ -861,23 +858,7 @@ namespace PlantLoopEquip { sim_component.compPtr->simulate(sim_component_location, FirstHVACIteration, CurLoad, RunFlag); } 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); 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();