Skip to content

Commit

Permalink
move counter to fuelCell struct
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchute committed Nov 12, 2019
1 parent 6cd202a commit beea145
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 23 deletions.
2 changes: 0 additions & 2 deletions src/EnergyPlus/DataGenerators.cc
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ namespace DataGenerators {

int NumFuelConstit(0);
int NumGeneratorFuelSups(0);
int NumFuelCellGenerators(0); // number of SOFC Generators specified in input
int NumMicroCHPs(0);
int NumMicroCHPParams(0); // number of parameter sets for micro chp
int NumGensWDynamics(0); // number of dynamics controls for generators
Expand All @@ -167,7 +166,6 @@ namespace DataGenerators {
{
NumFuelConstit = 0;
NumGeneratorFuelSups = 0;
NumFuelCellGenerators = 0;
NumMicroCHPs = 0;
NumMicroCHPParams = 0;
NumGensWDynamics = 0;
Expand Down
1 change: 0 additions & 1 deletion src/EnergyPlus/DataGenerators.hh
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ namespace DataGenerators {

extern int NumFuelConstit;
extern int NumGeneratorFuelSups;
extern int NumFuelCellGenerators; // number of SOFC Generators specified in input
extern int NumMicroCHPs;
extern int NumMicroCHPParams; // number of parameter sets for micro chp
extern int NumGensWDynamics; // number of dynamics controls for generators
Expand Down
46 changes: 27 additions & 19 deletions src/EnergyPlus/FuelCellElectricGenerator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,17 @@ namespace FuelCellElectricGenerator {
// REFERENCES:
// IEA/ECBCS Annex 42 model specification for Solid oxide and proton exchange membrane fuel cells

bool GetFuelCellInput(true); // When TRUE, calls subroutine to read input file.
int NumFuelCellGenerators(0);
bool GetFuelCellInput(true);
Array1D_bool CheckEquipName;

void clear_state()
{
NumFuelCellGenerators = 0;
GetFuelCellInput = true;
CheckEquipName.deallocate();
}

void SimFuelCellGenerator(int const EP_UNUSED(GeneratorType), // type of Generator
std::string const &GeneratorName, // user specified name of Generator
int &GeneratorIndex,
Expand Down Expand Up @@ -132,9 +140,9 @@ namespace FuelCellElectricGenerator {
GeneratorIndex = GenNum;
} else {
GenNum = GeneratorIndex;
if (GenNum > DataGenerators::NumFuelCellGenerators || GenNum < 1) {
if (GenNum > NumFuelCellGenerators || GenNum < 1) {
ShowFatalError("SimFuelCellGenerator: Invalid GeneratorIndex passed=" + General::TrimSigDigits(GenNum) +
", Number of FuelCell Generators=" + General::TrimSigDigits(DataGenerators::NumFuelCellGenerators) + ", Generator name=" + GeneratorName);
", Number of FuelCell Generators=" + General::TrimSigDigits(NumFuelCellGenerators) + ", Generator name=" + GeneratorName);
}
if (CheckEquipName(GenNum)) {
if (GeneratorName != DataGenerators::FuelCell(GenNum).Name) {
Expand Down Expand Up @@ -176,19 +184,19 @@ namespace FuelCellElectricGenerator {
bool ErrorsFound(false); // error flag

DataIPShortCuts::cCurrentModuleObject = "Generator:FuelCell";
DataGenerators::NumFuelCellGenerators = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject);
NumFuelCellGenerators = inputProcessor->getNumObjectsFound(DataIPShortCuts::cCurrentModuleObject);

if (DataGenerators::NumFuelCellGenerators <= 0) {
if (NumFuelCellGenerators <= 0) {
ShowSevereError("No " + DataIPShortCuts::cCurrentModuleObject + " equipment specified in input file");
ErrorsFound = true;
}

// ALLOCATE ARRAYS
DataGenerators::FuelCell.allocate(DataGenerators::NumFuelCellGenerators); // inits handled in derived type definitions
CheckEquipName.dimension(DataGenerators::NumFuelCellGenerators, true);
DataGenerators::FuelCell.allocate(NumFuelCellGenerators); // inits handled in derived type definitions
CheckEquipName.dimension(NumFuelCellGenerators, true);

// first load in FuelCell names
for (int GeneratorNum = 1; GeneratorNum <= DataGenerators::NumFuelCellGenerators; ++GeneratorNum) {
for (int GeneratorNum = 1; GeneratorNum <= NumFuelCellGenerators; ++GeneratorNum) {
inputProcessor->getObjectItem(
DataIPShortCuts::cCurrentModuleObject, GeneratorNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat, _, _, DataIPShortCuts::cAlphaFieldNames, DataIPShortCuts::cNumericFieldNames);
UtilityRoutines::IsNameEmpty(AlphArray(1), DataIPShortCuts::cCurrentModuleObject, ErrorsFound);
Expand Down Expand Up @@ -311,7 +319,7 @@ namespace FuelCellElectricGenerator {
DataGenerators::FuelCell(thisFuelCell).FCPM.PelMax = NumArray(25);

// check for other FuelCell using the same power module and fill
for (int otherFuelCell = thisFuelCell + 1; otherFuelCell <= DataGenerators::NumFuelCellGenerators; ++otherFuelCell) {
for (int otherFuelCell = thisFuelCell + 1; otherFuelCell <= NumFuelCellGenerators; ++otherFuelCell) {
if (UtilityRoutines::SameString(DataGenerators::FuelCell(otherFuelCell).FCPM.Name, DataGenerators::FuelCell(thisFuelCell).FCPM.Name)) {
DataGenerators::FuelCell(otherFuelCell).FCPM = DataGenerators::FuelCell(thisFuelCell).FCPM;
}
Expand All @@ -330,7 +338,7 @@ namespace FuelCellElectricGenerator {
}

// set fuel supply ID in Fuel cell structure
for (int GeneratorNum = 1; GeneratorNum <= DataGenerators::NumFuelCellGenerators; ++GeneratorNum) {
for (int GeneratorNum = 1; GeneratorNum <= NumFuelCellGenerators; ++GeneratorNum) {
DataGenerators::FuelCell(GeneratorNum).FuelSupNum =
UtilityRoutines::FindItemInList(DataGenerators::FuelCell(GeneratorNum).NameFCFuelSup, DataGenerators::FuelSupply); // Fuel Supply ID
if (DataGenerators::FuelCell(GeneratorNum).FuelSupNum == 0) {
Expand Down Expand Up @@ -483,7 +491,7 @@ namespace FuelCellElectricGenerator {
}

// check for other FuelCell using the same Air Supply module and fill
for (int otherFuelCell = thisFuelCell + 1; otherFuelCell <= DataGenerators::NumFuelCellGenerators; ++otherFuelCell) {
for (int otherFuelCell = thisFuelCell + 1; otherFuelCell <= NumFuelCellGenerators; ++otherFuelCell) {
if (UtilityRoutines::SameString(DataGenerators::FuelCell(otherFuelCell).AirSup.Name, DataGenerators::FuelCell(thisFuelCell).AirSup.Name)) {
DataGenerators::FuelCell(otherFuelCell).AirSup = DataGenerators::FuelCell(thisFuelCell).AirSup;
}
Expand All @@ -495,7 +503,7 @@ namespace FuelCellElectricGenerator {
}
}

for (int GeneratorNum = 1; GeneratorNum <= DataGenerators::NumFuelCellGenerators; ++GeneratorNum) {
for (int GeneratorNum = 1; GeneratorNum <= NumFuelCellGenerators; ++GeneratorNum) {
// find molal fraction of oxygen in air supply
int thisConstituent =
UtilityRoutines::FindItem("Oxygen", DataGenerators::FuelCell(GeneratorNum).AirSup.ConstitName, DataGenerators::FuelCell(GeneratorNum).AirSup.NumConstituents);
Expand Down Expand Up @@ -599,7 +607,7 @@ namespace FuelCellElectricGenerator {
}

// check for other FuelCell using the same Water Supply module and fill
for (int otherFuelCell = thisFuelCell + 1; otherFuelCell <= DataGenerators::NumFuelCellGenerators; ++otherFuelCell) {
for (int otherFuelCell = thisFuelCell + 1; otherFuelCell <= NumFuelCellGenerators; ++otherFuelCell) {
if (UtilityRoutines::SameString(DataGenerators::FuelCell(otherFuelCell).WaterSup.Name, DataGenerators::FuelCell(thisFuelCell).WaterSup.Name)) {
DataGenerators::FuelCell(otherFuelCell).WaterSup = DataGenerators::FuelCell(thisFuelCell).WaterSup;
}
Expand Down Expand Up @@ -660,7 +668,7 @@ namespace FuelCellElectricGenerator {
// TODO finish Auxiliary heater

// check for other FuelCell using the same Auxiliary Heating module and fill
for (int otherFuelCell = thisFuelCell + 1; otherFuelCell <= DataGenerators::NumFuelCellGenerators; ++otherFuelCell) {
for (int otherFuelCell = thisFuelCell + 1; otherFuelCell <= NumFuelCellGenerators; ++otherFuelCell) {
if (UtilityRoutines::SameString(DataGenerators::FuelCell(otherFuelCell).AuxilHeat.Name, DataGenerators::FuelCell(thisFuelCell).AuxilHeat.Name)) {
DataGenerators::FuelCell(otherFuelCell).AuxilHeat = DataGenerators::FuelCell(thisFuelCell).AuxilHeat;
}
Expand Down Expand Up @@ -791,7 +799,7 @@ namespace FuelCellElectricGenerator {
DataGenerators::FuelCell(thisFuelCell).ElecStorage.StartingEnergyStored = NumArray(6);

// check for other FuelCell using the same Electrical Storage and fill
for (int otherFuelCell = thisFuelCell + 1; otherFuelCell <= DataGenerators::NumFuelCellGenerators; ++otherFuelCell) {
for (int otherFuelCell = thisFuelCell + 1; otherFuelCell <= NumFuelCellGenerators; ++otherFuelCell) {
if (UtilityRoutines::SameString(DataGenerators::FuelCell(otherFuelCell).ElecStorage.Name, DataGenerators::FuelCell(thisFuelCell).ElecStorage.Name)) {
DataGenerators::FuelCell(otherFuelCell).ElecStorage = DataGenerators::FuelCell(thisFuelCell).ElecStorage;
}
Expand Down Expand Up @@ -843,7 +851,7 @@ namespace FuelCellElectricGenerator {
}

// check for other FuelCell using the same Inverter and fill
for (int otherFuelCell = thisFuelCell + 1; otherFuelCell <= DataGenerators::NumFuelCellGenerators; ++otherFuelCell) {
for (int otherFuelCell = thisFuelCell + 1; otherFuelCell <= NumFuelCellGenerators; ++otherFuelCell) {
if (UtilityRoutines::SameString(DataGenerators::FuelCell(otherFuelCell).Inverter.Name, DataGenerators::FuelCell(thisFuelCell).Inverter.Name)) {
DataGenerators::FuelCell(otherFuelCell).Inverter = DataGenerators::FuelCell(thisFuelCell).Inverter;
}
Expand Down Expand Up @@ -932,7 +940,7 @@ namespace FuelCellElectricGenerator {
ShowFatalError("Errors found in getting input for fuel cell model ");
}

for (int GeneratorNum = 1; GeneratorNum <= DataGenerators::NumFuelCellGenerators; ++GeneratorNum) {
for (int GeneratorNum = 1; GeneratorNum <= NumFuelCellGenerators; ++GeneratorNum) {
SetupOutputVariable("Generator Produced Electric Power",
OutputProcessor::Unit::W,
DataGenerators::FuelCell(GeneratorNum).Report.ACPowerGen,
Expand Down Expand Up @@ -3387,7 +3395,7 @@ namespace FuelCellElectricGenerator {

static bool MyEnvrnFlag(true);

if (DataGenerators::NumFuelCellGenerators == 0) return;
if (NumFuelCellGenerators == 0) return;

if (DataGlobals::BeginEnvrnFlag && MyEnvrnFlag) {
for (auto &e : DataGenerators::FuelSupply)
Expand Down Expand Up @@ -3416,7 +3424,7 @@ namespace FuelCellElectricGenerator {
// this routine needs to do something for zone gains during sizing

// first collect skin losses from different subsystems
for (int FCnum = 1; FCnum <= DataGenerators::NumFuelCellGenerators; ++FCnum) {
for (int FCnum = 1; FCnum <= NumFuelCellGenerators; ++FCnum) {
Real64 TotalZoneHeatGain = DataGenerators::FuelCell(FCnum).AirSup.QskinLoss + DataGenerators::FuelSupply(DataGenerators::FuelCell(FCnum).FuelSupNum).QskinLoss +
DataGenerators::FuelCell(FCnum).WaterSup.QskinLoss + DataGenerators::FuelCell(FCnum).AuxilHeat.QskinLoss +
DataGenerators::FuelCell(FCnum).FCPM.QdotSkin; // intake Blower losses to zone | fuel compressor losses to zone | water pump losses to
Expand Down
5 changes: 4 additions & 1 deletion src/EnergyPlus/FuelCellElectricGenerator.hh
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,12 @@ namespace EnergyPlus {

namespace FuelCellElectricGenerator {

extern bool GetFuelCellInput; // When TRUE, calls subroutine to read input file.
extern bool GetFuelCellInput;
extern int NumFuelCellGenerators;
extern Array1D_bool CheckEquipName;

void clear_state();

void SimFuelCellGenerator(int GeneratorType, // type of Generator
std::string const &GeneratorName, // user specified name of Generator
int &GeneratorIndex,
Expand Down

0 comments on commit beea145

Please sign in to comment.