Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
dareumnam committed Mar 19, 2021
2 parents d6c3f1c + 0c8db47 commit b1677a4
Show file tree
Hide file tree
Showing 27 changed files with 3,483 additions and 3,378 deletions.
10 changes: 2 additions & 8 deletions src/EnergyPlus/DataSystemVariables.cc
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ namespace DataSystemVariables {

// Shading methods

bool firstTime(true);

// Functions

Expand Down Expand Up @@ -174,7 +173,7 @@ namespace DataSystemVariables {
std::string InputFileName; // save for changing out path characters
std::string::size_type pos;

if (firstTime) {
if (state.dataSysVars->firstTime) {
state.files.audit.ensure_open(state, "CheckForActualFileName", state.files.outputControl.audit);
get_environment_variable(cInputPath1, state.dataSysVars->envinputpath1);
if (!state.dataSysVars->envinputpath1.empty()) {
Expand All @@ -183,7 +182,7 @@ namespace DataSystemVariables {
}
get_environment_variable(cInputPath2, state.dataSysVars->envinputpath2);
get_environment_variable(cProgramPath, ProgramPath);
firstTime = false;
state.dataSysVars->firstTime = false;
}

FileFound = false;
Expand Down Expand Up @@ -237,11 +236,6 @@ namespace DataSystemVariables {
}
}

void clear_state()
{
firstTime = true;
}

void processEnvironmentVariables(EnergyPlusData &state) {

static std::string cEnvValue;
Expand Down
6 changes: 3 additions & 3 deletions src/EnergyPlus/DataSystemVariables.hh
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,13 @@ namespace DataSystemVariables {
const std::string contextString = std::string()
);

// Needed for unit tests, should not be normally called.
void clear_state();

void processEnvironmentVariables(EnergyPlusData &state);

} // namespace DataSystemVariables

struct SystemVarsData : BaseGlobalStruct
{
bool firstTime = true;

int const iASCII_CR = 13; // endline value when just CR instead of CR/LF
int const iUnicode_end = 0; // endline value when Unicode file
Expand Down Expand Up @@ -166,6 +164,8 @@ struct SystemVarsData : BaseGlobalStruct
DeveloperFlag = false;
TimingFlag = false;

firstTime = true;

SutherlandHodgman = true;
SlaterBarsky = false;
DetailedSkyDiffuseAlgorithm = false;
Expand Down
165 changes: 78 additions & 87 deletions src/EnergyPlus/FaultsManager.cc

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions src/EnergyPlus/FaultsManager.hh
Original file line number Diff line number Diff line change
Expand Up @@ -390,14 +390,15 @@ namespace FaultsManager {

void CheckAndReadFaults(EnergyPlusData &state);

void clear_state();

void SetFaultyCoilSATSensor(EnergyPlusData &state, std::string const &CompType, std::string const &CompName, bool &FaultyCoilSATFlag, int &FaultyCoilSATIndex);

} // namespace FaultsManager

struct FaultsManagerData : BaseGlobalStruct {

bool RunFaultMgrOnceFlag = false; // True if CheckAndReadFaults is already done
bool ErrorsFound = false; // True if errors detected in input

bool AnyFaultsInModel = false; // True if there are operational faults in the model
int NumFaults = 0; // Number of faults (include multiple faults of same type) in the model
int NumFaultyEconomizer = 0; // Total number of faults related with the economizer
Expand Down Expand Up @@ -429,7 +430,8 @@ struct FaultsManagerData : BaseGlobalStruct {

void clear_state() override
{

RunFaultMgrOnceFlag = false;
ErrorsFound = false;
AnyFaultsInModel = false;
NumFaults = 0;
NumFaultyEconomizer = 0;
Expand Down
47 changes: 17 additions & 30 deletions src/EnergyPlus/Furnaces.cc
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ namespace Furnaces {
static std::string const BlankString;

auto constexpr fluidNameSteam("STEAM");
bool GetFurnaceInputFlag(true); // Logical to allow "GetInput" only once per simulation

// DERIVED TYPE DEFINITIONS

Expand All @@ -205,10 +204,6 @@ namespace Furnaces {
// Reporting routines for module

// Object Data
std::unordered_map<std::string, std::string> UniqueFurnaceNames;
bool InitFurnaceMyOneTimeFlag = true; // one time allocation flag
bool FlowFracFlagReady = true; // one time flag for calculating flow fraction through controlled zone
bool MyAirLoopPass = true; // one time allocation flag

// Utility routines for module
// na
Expand All @@ -217,14 +212,6 @@ namespace Furnaces {
//*************************************************************************

// Functions
void clear_state()
{
GetFurnaceInputFlag = true;
UniqueFurnaceNames.clear();
InitFurnaceMyOneTimeFlag = true;
FlowFracFlagReady = true; // one time flag for calculating flow fraction through controlled zone
MyAirLoopPass = true;
}

void SimFurnace(EnergyPlusData &state,
std::string const &FurnaceName,
Expand Down Expand Up @@ -279,10 +266,10 @@ namespace Furnaces {
Real64 TempMassFlowRateMaxAvail;

// Obtains and Allocates Furnace related parameters from input file
if (GetFurnaceInputFlag) { // First time subroutine has been entered
if (state.dataFurnaces->GetFurnaceInputFlag) { // First time subroutine has been entered
// Get the furnace input
GetFurnaceInput(state);
GetFurnaceInputFlag = false;
state.dataFurnaces->GetFurnaceInputFlag = false;
}

// Find the correct Furnace
Expand Down Expand Up @@ -913,7 +900,7 @@ namespace Furnaces {
std::string IHPCoilName; // IHP cooling coil name
int IHPCoilIndex(0); // IHP cooling coil id

GetFurnaceInputFlag = false;
state.dataFurnaces->GetFurnaceInputFlag = false;
MaxNumbers = 0;
MaxAlphas = 0;

Expand Down Expand Up @@ -964,7 +951,7 @@ namespace Furnaces {

if (state.dataFurnaces->NumFurnaces > 0) {
state.dataFurnaces->Furnace.allocate(state.dataFurnaces->NumFurnaces);
UniqueFurnaceNames.reserve(state.dataFurnaces->NumFurnaces);
state.dataFurnaces->UniqueFurnaceNames.reserve(state.dataFurnaces->NumFurnaces);
}
state.dataFurnaces->CheckEquipName.dimension(state.dataFurnaces->NumFurnaces, true);

Expand Down Expand Up @@ -1012,7 +999,7 @@ namespace Furnaces {
cAlphaFields,
cNumericFields);

GlobalNames::VerifyUniqueInterObjectName(state, UniqueFurnaceNames, Alphas(1), CurrentModuleObject, cAlphaFields(1), ErrorsFound);
GlobalNames::VerifyUniqueInterObjectName(state, state.dataFurnaces->UniqueFurnaceNames, Alphas(1), CurrentModuleObject, cAlphaFields(1), ErrorsFound);

state.dataFurnaces->Furnace(FurnaceNum).Name = Alphas(1);
if (lAlphaBlanks(2)) {
Expand Down Expand Up @@ -1559,7 +1546,7 @@ namespace Furnaces {
cAlphaFields,
cNumericFields);

GlobalNames::VerifyUniqueInterObjectName(state, UniqueFurnaceNames, Alphas(1), CurrentModuleObject, cAlphaFields(1), ErrorsFound);
GlobalNames::VerifyUniqueInterObjectName(state, state.dataFurnaces->UniqueFurnaceNames, Alphas(1), CurrentModuleObject, cAlphaFields(1), ErrorsFound);

state.dataFurnaces->Furnace(FurnaceNum).Name = Alphas(1);
if (lAlphaBlanks(2)) {
Expand Down Expand Up @@ -2765,7 +2752,7 @@ namespace Furnaces {
cAlphaFields,
cNumericFields);

GlobalNames::VerifyUniqueInterObjectName(state, UniqueFurnaceNames, Alphas(1), CurrentModuleObject, cAlphaFields(1), ErrorsFound);
GlobalNames::VerifyUniqueInterObjectName(state, state.dataFurnaces->UniqueFurnaceNames, Alphas(1), CurrentModuleObject, cAlphaFields(1), ErrorsFound);

state.dataFurnaces->Furnace(FurnaceNum).FurnaceType_Num = UnitarySys_HeatPump_AirToAir;
state.dataFurnaces->Furnace(FurnaceNum).Name = Alphas(1);
Expand Down Expand Up @@ -3687,7 +3674,7 @@ namespace Furnaces {
cAlphaFields,
cNumericFields);

GlobalNames::VerifyUniqueInterObjectName(state, UniqueFurnaceNames, Alphas(1), CurrentModuleObject, cAlphaFields(1), ErrorsFound);
GlobalNames::VerifyUniqueInterObjectName(state, state.dataFurnaces->UniqueFurnaceNames, Alphas(1), CurrentModuleObject, cAlphaFields(1), ErrorsFound);

state.dataFurnaces->Furnace(FurnaceNum).FurnaceType_Num = UnitarySys_HeatPump_WaterToAir;
state.dataFurnaces->Furnace(FurnaceNum).Name = Alphas(1);
Expand Down Expand Up @@ -4811,7 +4798,7 @@ namespace Furnaces {

auto &Node(state.dataLoopNodes->Node);

if (InitFurnaceMyOneTimeFlag) {
if (state.dataFurnaces->InitFurnaceMyOneTimeFlag) {
// initialize the environment and sizing flags
state.dataFurnaces->MyEnvrnFlag.allocate(state.dataFurnaces->NumFurnaces);
state.dataFurnaces->MySizeFlag.allocate(state.dataFurnaces->NumFurnaces);
Expand All @@ -4827,17 +4814,17 @@ namespace Furnaces {
state.dataFurnaces->MyFanFlag = true;
state.dataFurnaces->MyCheckFlag = true;
state.dataFurnaces->MyFlowFracFlag = true;
InitFurnaceMyOneTimeFlag = false;
state.dataFurnaces->InitFurnaceMyOneTimeFlag = false;
state.dataFurnaces->MyPlantScanFlag = true;
state.dataFurnaces->MySuppCoilPlantScanFlag = true;
}

if (state.dataGlobal->BeginEnvrnFlag && MyAirLoopPass) {
if (state.dataGlobal->BeginEnvrnFlag && state.dataFurnaces->MyAirLoopPass) {
state.dataFurnaces->AirLoopPass = 0;
MyAirLoopPass = false;
state.dataFurnaces->MyAirLoopPass = false;
}
if (!state.dataGlobal->BeginEnvrnFlag) {
MyAirLoopPass = true;
state.dataFurnaces->MyAirLoopPass = true;
}

++state.dataFurnaces->AirLoopPass;
Expand Down Expand Up @@ -5204,27 +5191,27 @@ namespace Furnaces {
// Find the number of zones (zone Inlet Nodes) attached to an air loop from the air loop number
NumAirLoopZones = state.dataAirLoop->AirToZoneNodeInfo(AirLoopNum).NumZonesCooled + state.dataAirLoop->AirToZoneNodeInfo(AirLoopNum).NumZonesHeated;
if (allocated(state.dataAirLoop->AirToZoneNodeInfo) && state.dataFurnaces->MyFlowFracFlag(FurnaceNum)) {
FlowFracFlagReady = true;
state.dataFurnaces->FlowFracFlagReady = true;
for (ZoneInSysIndex = 1; ZoneInSysIndex <= NumAirLoopZones; ++ZoneInSysIndex) {
// zone inlet nodes for cooling
if (state.dataAirLoop->AirToZoneNodeInfo(AirLoopNum).NumZonesCooled > 0) {
if (state.dataAirLoop->AirToZoneNodeInfo(AirLoopNum).TermUnitCoolInletNodes(ZoneInSysIndex) == -999) {
// the data structure for the zones inlet nodes has not been filled
FlowFracFlagReady = false;
state.dataFurnaces->FlowFracFlagReady = false;
}
}
// zone inlet nodes for heating
if (state.dataAirLoop->AirToZoneNodeInfo(AirLoopNum).NumZonesHeated > 0) {
if (state.dataAirLoop->AirToZoneNodeInfo(AirLoopNum).TermUnitHeatInletNodes(ZoneInSysIndex) == -999) {
// the data structure for the zones inlet nodes has not been filled
FlowFracFlagReady = false;
state.dataFurnaces->FlowFracFlagReady = false;
}
}
}
}

if (state.dataFurnaces->MyFlowFracFlag(FurnaceNum)) {
if (allocated(state.dataAirLoop->AirToZoneNodeInfo) && FlowFracFlagReady) {
if (allocated(state.dataAirLoop->AirToZoneNodeInfo) && state.dataFurnaces->FlowFracFlagReady) {
SumOfMassFlowRateMax = 0.0; // initialize the sum of the maximum flows
for (ZoneInSysIndex = 1; ZoneInSysIndex <= NumAirLoopZones; ++ZoneInSysIndex) {
ZoneInletNodeNum = state.dataAirLoop->AirToZoneNodeInfo(AirLoopNum).TermUnitCoolInletNodes(ZoneInSysIndex);
Expand Down
18 changes: 15 additions & 3 deletions src/EnergyPlus/Furnaces.hh
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,6 @@ namespace Furnaces {

// Functions

void clear_state();

void SimFurnace(EnergyPlusData &state, std::string const &FurnaceName,
bool const FirstHVACIteration,
int const AirLoopNum, // Primary air loop number
Expand Down Expand Up @@ -554,9 +552,17 @@ struct FurnacesData : BaseGlobalStruct {
std::string CurrentModuleObject; // Object type for getting and error messages
int Iter = 0; // Iteration counter for CalcNewZoneHeatOnlyFlowRates



// Object Data
Array1D<Furnaces::FurnaceEquipConditions> Furnace;

bool GetFurnaceInputFlag = true; // Logical to allow "GetInput" only once per simulation
std::unordered_map<std::string, std::string> UniqueFurnaceNames;
bool InitFurnaceMyOneTimeFlag = true; // one time allocation flag
bool FlowFracFlagReady = true; // one time flag for calculating flow fraction through controlled zone
bool MyAirLoopPass = true; // one time allocation flag

Array1D_bool MyEnvrnFlag; // environment flag
Array1D_bool MySecondOneTimeFlag; // additional one time flag
Array1D_bool MyFanFlag; // used for sizing fan inputs one time
Expand Down Expand Up @@ -588,7 +594,13 @@ struct FurnacesData : BaseGlobalStruct {
SaveCompressorPLR = 0.0;
CurrentModuleObject = "";
Iter = 0;
Furnace.clear();
Furnace.clear();\

GetFurnaceInputFlag = true;
UniqueFurnaceNames.clear();
InitFurnaceMyOneTimeFlag = true;
FlowFracFlagReady = true; // one time flag for calculating flow fraction through controlled zone
MyAirLoopPass = true;

MyEnvrnFlag.clear();
MySecondOneTimeFlag.clear();
Expand Down
Loading

1 comment on commit b1677a4

@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.

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

Build Badge Test Badge

Please sign in to comment.