Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combustion Turbine Generator Plant Comp Refactor #7559

Merged
merged 15 commits into from
Nov 13, 2019
1,134 changes: 434 additions & 700 deletions src/EnergyPlus/CTElectricGenerator.cc

Large diffs are not rendered by default.

136 changes: 20 additions & 116 deletions src/EnergyPlus/CTElectricGenerator.hh
Original file line number Diff line number Diff line change
Expand Up @@ -55,31 +55,17 @@
#include <EnergyPlus/DataGlobalConstants.hh>
#include <EnergyPlus/DataGlobals.hh>
#include <EnergyPlus/EnergyPlus.hh>
#include <EnergyPlus/PlantComponent.hh>

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
Expand Down Expand Up @@ -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),
Expand All @@ -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<CTGeneratorSpecs> CTGenerator; // dimension to number of machines
extern Array1D<ReportVars> 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<CTGeneratorData> 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

Expand Down
18 changes: 12 additions & 6 deletions src/EnergyPlus/ElectricPowerServiceManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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::CTGeneratorData::factory(name);
// dummy vars
PlantLocation L(0,0,0,0);
Real64 tempLoad = myElecLoadRequest;

// simulate
thisCTE->simulate(L, FirstHVACIteration, tempLoad, runFlag);
dynamic_cast<CTElectricGenerator::CTGeneratorData*> (thisCTE)->InitCTGenerators(runFlag, FirstHVACIteration);
dynamic_cast<CTElectricGenerator::CTGeneratorData*> (thisCTE)->CalcCTGeneratorModel(runFlag, tempLoad, FirstHVACIteration);
electricPowerOutput = dynamic_cast<CTElectricGenerator::CTGeneratorData*> (thisCTE)->ElecPowerGenerated;
thermalPowerOutput = dynamic_cast<CTElectricGenerator::CTGeneratorData*> (thisCTE)->QTotalHeatRecovered;
break;
}
case GeneratorType::pV: {
Expand Down
2 changes: 2 additions & 0 deletions src/EnergyPlus/Plant/PlantManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
#include <EnergyPlus/BoilerSteam.hh>
#include <EnergyPlus/BranchInputManager.hh>
#include <EnergyPlus/CondenserLoopTowers.hh>
#include <EnergyPlus/CTElectricGenerator.hh>
#include <EnergyPlus/DataBranchAirLoopPlant.hh>
#include <EnergyPlus/DataConvergParams.hh>
#include <EnergyPlus/DataEnvironment.hh>
Expand Down Expand Up @@ -1271,6 +1272,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;
Expand Down
20 changes: 1 addition & 19 deletions src/EnergyPlus/PlantLoopEquip.cc
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ namespace PlantLoopEquip {
using ScheduleManager::GetCurrentScheduleValue;
using WaterThermalTanks::SimWaterThermalTank;

using CTElectricGenerator::SimCTPlantHeatRecovery;
using EvaporativeFluidCoolers::SimEvapFluidCoolers;
using FuelCellElectricGenerator::SimFuelCellPlantHeatRecovery;
using ICEngineElectricGenerator::SimICEPlantHeatRecovery;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions tst/EnergyPlus/unit/Fixtures/EnergyPlusFixture.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
#include <EnergyPlus/CoolTower.hh>
#include <EnergyPlus/CrossVentMgr.hh>
#include <EnergyPlus/CurveManager.hh>
#include <EnergyPlus/CTElectricGenerator.hh>
#include <EnergyPlus/DElightManagerF.hh>
#include <EnergyPlus/DXCoils.hh>
#include <EnergyPlus/DataAirLoop.hh>
Expand Down Expand Up @@ -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();
Expand Down