Skip to content

Commit

Permalink
deglobalizing ICEngineElectricGenerator, remove clear_state
Browse files Browse the repository at this point in the history
  • Loading branch information
dareumnam committed Mar 26, 2021
1 parent 73f787a commit be483d7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 32 deletions.
32 changes: 8 additions & 24 deletions src/EnergyPlus/ICEngineElectricGenerator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,33 +87,16 @@ namespace ICEngineElectricGenerator {
// is available to meet an electric load demand, it calls SimICEngineGenerator
// which in turn calls the ICEngine Generator model.

Real64 const ReferenceTemp(25.0); // Reference temperature by which lower heating
// value is reported. This should be subtracted
// off of when calculated exhaust energies.

bool getICEInput(true); // When TRUE, calls subroutine to read input file.
int NumICEngineGenerators(0); // number of IC ENGINE Generators specified in input

// Object Data
Array1D<ICEngineGeneratorSpecs> ICEngineGenerator; // dimension to number of machines

void clear_state()
{
getICEInput = true;
NumICEngineGenerators = 0;
ICEngineGenerator.deallocate();
}

PlantComponent *ICEngineGeneratorSpecs::factory(EnergyPlusData &state, std::string const &objectName)
{
// Process the input data for ICEGen if it hasn't been done already
if (getICEInput) {
if (state.dataICEngElectGen->getICEInput) {
GetICEngineGeneratorInput(state);
getICEInput = false;
state.dataICEngElectGen->getICEInput = false;
}

// Now look for this particular generator in the list
for (auto &thisICE : ICEngineGenerator) {
for (auto &thisICE : state.dataICEngElectGen->ICEngineGenerator) {
if (thisICE.Name == objectName) {
return &thisICE;
}
Expand Down Expand Up @@ -143,20 +126,21 @@ namespace ICEngineElectricGenerator {
Array1D<Real64> NumArray(11); // numeric data
bool ErrorsFound(false); // error flag

auto &ICEngineGenerator(state.dataICEngElectGen->ICEngineGenerator);

state.dataIPShortCut->cCurrentModuleObject = "Generator:InternalCombustionEngine";
NumICEngineGenerators = inputProcessor->getNumObjectsFound(state, state.dataIPShortCut->cCurrentModuleObject);
state.dataICEngElectGen->NumICEngineGenerators = inputProcessor->getNumObjectsFound(state, state.dataIPShortCut->cCurrentModuleObject);

if (NumICEngineGenerators <= 0) {
if (state.dataICEngElectGen->NumICEngineGenerators <= 0) {
ShowSevereError(state, "No " + state.dataIPShortCut->cCurrentModuleObject + " equipment specified in input file");
ErrorsFound = true;
}

// ALLOCATE ARRAYS
ICEngineGenerator.allocate(NumICEngineGenerators);
ICEngineGenerator.allocate(state.dataICEngElectGen->NumICEngineGenerators);

// LOAD ARRAYS WITH IC ENGINE Generator CURVE FIT DATA
for (genNum = 1; genNum <= NumICEngineGenerators; ++genNum) {
for (genNum = 1; genNum <= state.dataICEngElectGen->NumICEngineGenerators; ++genNum) {
inputProcessor->getObjectItem(state,
state.dataIPShortCut->cCurrentModuleObject,
genNum,
Expand Down
15 changes: 8 additions & 7 deletions src/EnergyPlus/ICEngineElectricGenerator.hh
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,10 @@ struct EnergyPlusData;

namespace ICEngineElectricGenerator {

extern Real64 const ReferenceTemp; // Reference temperature by which lower heating
Real64 constexpr ReferenceTemp(25.0); // Reference temperature by which lower heating
// value is reported. This should be subtracted
// off of when calculated exhaust energies.

extern int NumICEngineGenerators; // number of IC ENGINE Generators specified in input
extern bool getICEInput; // When TRUE, calls subroutine to read input file.

struct ICEngineGeneratorSpecs : PlantComponent
{
// Members
Expand Down Expand Up @@ -170,17 +167,21 @@ namespace ICEngineElectricGenerator {
static PlantComponent *factory(EnergyPlusData &state, std::string const &objectName);
};

extern Array1D<ICEngineGeneratorSpecs> ICEngineGenerator; // dimension to number of machines

void GetICEngineGeneratorInput(EnergyPlusData &state);

} // namespace ICEngineElectricGenerator

struct ICEngineElectricGeneratorData : BaseGlobalStruct {

int NumICEngineGenerators = 0; // number of IC ENGINE Generators specified in input
bool getICEInput = true; // When TRUE, calls subroutine to read input file.
Array1D<ICEngineElectricGenerator::ICEngineGeneratorSpecs> ICEngineGenerator; // dimension to number of machines

void clear_state() override
{

this->getICEInput = true;
this->NumICEngineGenerators = 0;
this->ICEngineGenerator.deallocate();
}
};

Expand Down
2 changes: 1 addition & 1 deletion tst/EnergyPlus/unit/ICEngineElectricGenerator.unit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ TEST_F(EnergyPlusFixture, ICEngineElectricGenerator_Fueltype)

GetICEngineGeneratorInput(*state);

EXPECT_EQ(ICEngineGenerator(1).FuelType, "Diesel");
EXPECT_EQ(state->dataICEngElectGen->ICEngineGenerator(1).FuelType, "Diesel");
}

} // namespace EnergyPlus

4 comments on commit be483d7

@nrel-bot-3
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removestatics (dareumnam) - x86_64-MacOS-10.15-clang-11.0.0: OK (3071 of 3071 tests passed, 0 test warnings)

Build Badge Test Badge

@nrel-bot-2
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removestatics (dareumnam) - x86_64-Linux-Ubuntu-18.04-gcc-7.5: Tests Failed (0 of 0 tests passed, 0 test warnings)

Build Badge Test Badge

@nrel-bot-2
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removestatics (dareumnam) - x86_64-Linux-Ubuntu-18.04-gcc-7.5-UnitTestsCoverage-Debug: Tests Failed (0 of 0 tests passed, 0 test warnings)

Build Badge Test Badge Coverage Badge

@nrel-bot-2
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removestatics (dareumnam) - x86_64-Linux-Ubuntu-18.04-gcc-7.5-IntegrationCoverage-Debug: Tests Failed (0 of 0 tests passed, 0 test warnings)

Build Badge Test Badge Coverage Badge

Please sign in to comment.