Skip to content

Commit

Permalink
moving DataEnvironment to state
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchute committed Dec 1, 2020
1 parent 52ec3b8 commit 90a9ada
Show file tree
Hide file tree
Showing 28 changed files with 151 additions and 211 deletions.
45 changes: 0 additions & 45 deletions src/EnergyPlus/DataEnvironment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,51 +68,6 @@ namespace EnergyPlus::DataEnvironment {
// to the "environment" (i.e. current date data, tomorrow's date data, and
// current weather variables)

// MODULE VARIABLE DECLARATIONS:
bool GroundTempObjInput(false); // Ground temperature object input
bool GroundTemp_SurfaceObjInput(false); // Surface ground temperature object input
bool GroundTemp_DeepObjInput(false); // Deep ground temperature object input
bool FCGroundTemps(false);
bool DisplayWeatherMissingDataWarnings(false); // Display missing/out of range weather warnings
bool IgnoreSolarRadiation(false); // TRUE if all solar radiation is to be ignored
bool IgnoreBeamRadiation(false); // TRUE if beam (aka direct normal) radiation is to be ignored
bool IgnoreDiffuseRadiation(false); // TRUE if diffuse horizontal radiation is to be ignored

bool PrintEnvrnStampWarmup(false);
bool PrintEnvrnStampWarmupPrinted(false);

bool RunPeriodEnvironment(false); // True if Run Period, False if DesignDay
std::string EnvironmentStartEnd; // Start/End dates for Environment
bool CurrentYearIsLeapYear(false); // true when current year is leap year (convoluted logic dealing with
// whether weather file allows leap years, runperiod inputs.

int varyingLocationSchedIndexLat(0);
int varyingLocationSchedIndexLong(0);
int varyingOrientationSchedIndex(0);

// for PerformancePrecisionTradeoffs
bool forceBeginEnvResetSuppress(false);

void clear_state()
{
GroundTempObjInput = false;
GroundTemp_SurfaceObjInput = false;
GroundTemp_DeepObjInput = false;
FCGroundTemps = false;
DisplayWeatherMissingDataWarnings = false;
IgnoreSolarRadiation = false;
IgnoreBeamRadiation = false;
IgnoreDiffuseRadiation = false;
PrintEnvrnStampWarmup = false;
PrintEnvrnStampWarmupPrinted = false;
RunPeriodEnvironment = false;
EnvironmentStartEnd = std::string();
CurrentYearIsLeapYear = false;
varyingLocationSchedIndexLat = 0;
varyingLocationSchedIndexLong = 0;
varyingOrientationSchedIndex = 0;
}

Real64 OutDryBulbTempAt(EnergyPlusData &state, Real64 const Z) // Height above ground (m)
{

Expand Down
61 changes: 34 additions & 27 deletions src/EnergyPlus/DataEnvironment.hh
Original file line number Diff line number Diff line change
Expand Up @@ -67,33 +67,6 @@ namespace DataEnvironment {
Real64 constexpr SunIsUpValue(0.00001); // if Cos Zenith Angle of the sun is >= this value, the sun is "up"
Real64 constexpr StdPressureSeaLevel(101325.0); // Standard barometric pressure at sea level (Pa)

// MODULE VARIABLE DECLARATIONS:
extern bool GroundTempObjInput; // Ground temperature object input
extern bool GroundTemp_SurfaceObjInput; // Surface ground temperature object input
extern bool GroundTemp_DeepObjInput; // Deep ground temperature object input
extern bool FCGroundTemps;
extern bool DisplayWeatherMissingDataWarnings; // Display missing/out of range weather warnings
extern bool IgnoreSolarRadiation; // TRUE if all solar radiation is to be ignored
extern bool IgnoreBeamRadiation; // TRUE if beam (aka direct normal) radiation is to be ignored
extern bool IgnoreDiffuseRadiation; // TRUE if diffuse horizontal radiation is to be ignored

extern bool PrintEnvrnStampWarmup;
extern bool PrintEnvrnStampWarmupPrinted;

extern bool RunPeriodEnvironment; // True if Run Period, False if DesignDay
extern std::string EnvironmentStartEnd; // Start/End dates for Environment
extern bool CurrentYearIsLeapYear; // true when current year is leap year (convoluted logic dealing with
// whether weather file allows leap years, runperiod inputs.

extern int varyingLocationSchedIndexLat;
extern int varyingLocationSchedIndexLong;
extern int varyingOrientationSchedIndex;

// for PerformancePrecisionTradeoffs
extern bool forceBeginEnvResetSuppress;

void clear_state();

Real64 OutDryBulbTempAt(EnergyPlusData &state, Real64 Z); // Height above ground (m)

Real64 OutWetBulbTempAt(EnergyPlusData &state, Real64 Z); // Height above ground (m)
Expand Down Expand Up @@ -209,6 +182,23 @@ struct EnvironmentData : BaseGlobalStruct {
Real64 SiteWindExp = 0.22; // Exponent for the wind velocity profile at the site
Real64 SiteWindBLHeight = 370.0; // Boundary layer height for the wind velocity profile at the site (m)
Real64 SiteTempGradient = 0.0065; // Air temperature gradient coefficient (K/m)
bool GroundTempObjInput = false; // Ground temperature object input
bool GroundTemp_SurfaceObjInput = false; // Surface ground temperature object input
bool GroundTemp_DeepObjInput = false; // Deep ground temperature object input
bool FCGroundTemps = false;
bool DisplayWeatherMissingDataWarnings = false; // Display missing/out of range weather warnings
bool IgnoreSolarRadiation = false; // TRUE if all solar radiation is to be ignored
bool IgnoreBeamRadiation = false; // TRUE if beam (aka direct normal) radiation is to be ignored
bool IgnoreDiffuseRadiation = false; // TRUE if diffuse horizontal radiation is to be ignored
bool PrintEnvrnStampWarmup = false;
bool PrintEnvrnStampWarmupPrinted = false;
bool RunPeriodEnvironment = false; // True if Run Period, False if DesignDay
std::string EnvironmentStartEnd; // Start/End dates for Environment
bool CurrentYearIsLeapYear = false; // true when current year is leap year (convoluted logic dealing with whether weather file allows leap years, runperiod inputs.
int varyingLocationSchedIndexLat = 0;
int varyingLocationSchedIndexLong = 0;
int varyingOrientationSchedIndex = 0;
bool forceBeginEnvResetSuppress = false; // for PerformancePrecisionTradeoffs

void clear_state() override
{
Expand Down Expand Up @@ -311,6 +301,23 @@ struct EnvironmentData : BaseGlobalStruct {
this->SiteWindExp = 0.22;
this->SiteWindBLHeight = 370.0;
this->SiteTempGradient = 0.0065;
this->GroundTempObjInput = false;
this->GroundTemp_SurfaceObjInput = false;
this->GroundTemp_DeepObjInput = false;
this->FCGroundTemps = false;
this->DisplayWeatherMissingDataWarnings = false;
this->IgnoreSolarRadiation = false;
this->IgnoreBeamRadiation = false;
this->IgnoreDiffuseRadiation = false;
this->PrintEnvrnStampWarmup = false;
this->PrintEnvrnStampWarmupPrinted = false;
this->RunPeriodEnvironment = false;
this->EnvironmentStartEnd.clear();
this->CurrentYearIsLeapYear = false;
this->varyingLocationSchedIndexLat = 0;
this->varyingLocationSchedIndexLong = 0;
this->varyingOrientationSchedIndex = 0;
this->forceBeginEnvResetSuppress = false;
}
};

Expand Down
6 changes: 3 additions & 3 deletions src/EnergyPlus/DataSystemVariables.cc
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ namespace DataSystemVariables {
if (!cEnvValue.empty()) ReportDuringHVACSizingSimulation = env_var_on(cEnvValue); // Yes or True

get_environment_variable(cIgnoreSolarRadiation, cEnvValue);
if (!cEnvValue.empty()) DataEnvironment::IgnoreSolarRadiation = env_var_on(cEnvValue); // Yes or True
if (!cEnvValue.empty()) state.dataEnvrn->IgnoreSolarRadiation = env_var_on(cEnvValue); // Yes or True

get_environment_variable(cMinimalSurfaceVariables, cEnvValue);
if (!cEnvValue.empty()) state.dataGlobal->CreateMinimalSurfaceVariables = env_var_on(cEnvValue); // Yes or True
Expand All @@ -400,10 +400,10 @@ namespace DataSystemVariables {
if (!cEnvValue.empty()) DeveloperFlag = env_var_on(cEnvValue); // Yes or True

get_environment_variable(cIgnoreBeamRadiation, cEnvValue);
if (!cEnvValue.empty()) DataEnvironment::IgnoreBeamRadiation = env_var_on(cEnvValue); // Yes or True
if (!cEnvValue.empty()) state.dataEnvrn->IgnoreBeamRadiation = env_var_on(cEnvValue); // Yes or True

get_environment_variable(cIgnoreDiffuseRadiation, cEnvValue);
if (!cEnvValue.empty()) DataEnvironment::IgnoreDiffuseRadiation = env_var_on(cEnvValue); // Yes or True
if (!cEnvValue.empty()) state.dataEnvrn->IgnoreDiffuseRadiation = env_var_on(cEnvValue); // Yes or True

get_environment_variable(cSutherlandHodgman, cEnvValue);
if (!cEnvValue.empty()) SutherlandHodgman = env_var_on(cEnvValue); // Yes or True
Expand Down
4 changes: 1 addition & 3 deletions src/EnergyPlus/ExternalInterface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1874,12 +1874,10 @@ namespace ExternalInterface {
// Get the current month and day in the runperiod and convert
// it into seconds.

// Using/Aliasing
using DataEnvironment::CurrentYearIsLeapYear;
// Locals
Real64 simtime;

if (!CurrentYearIsLeapYear) {
if (!state.dataEnvrn->CurrentYearIsLeapYear) {
switch (state.dataEnvrn->Month) {
case 1:
simtime = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/EnergyPlus/General.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2318,7 +2318,7 @@ namespace General {
)
{
// J. Glazer - August 2017
int firstDayOfMonth = OrdinalDay(monthNumber, 1, DataEnvironment::CurrentYearIsLeapYear);
int firstDayOfMonth = OrdinalDay(monthNumber, 1, state.dataEnvrn->CurrentYearIsLeapYear);
int dayOfWeekForFirstDay = (state.dataEnvrn->RunPeriodStartDayOfWeek + firstDayOfMonth - 1) % 7;
int jdatForNth;
if (dayOfWeek >= dayOfWeekForFirstDay) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ SiteBuildingSurfaceGroundTemps::BuildingSurfaceGTMFactory(EnergyPlusData &state,
// Reads input and creates instance of Site:GroundTemperature:BuildingSurface object

// USE STATEMENTS:
using DataEnvironment::GroundTempObjInput;
using namespace DataIPShortCuts;
using namespace GroundTemperatureManager;

Expand Down Expand Up @@ -113,7 +112,7 @@ SiteBuildingSurfaceGroundTemps::BuildingSurfaceGTMFactory(EnergyPlusData &state,
if (thisModel->buildingSurfaceGroundTemps(i) < 15.0 || thisModel->buildingSurfaceGroundTemps(i) > 25.0) genErrorMessage = true;
}

GroundTempObjInput = true;
state.dataEnvrn->GroundTempObjInput = true;

if (genErrorMessage) {
ShowWarningError(state, cCurrentModuleObject + ": Some values fall outside the range of 15-25C.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ std::shared_ptr<SiteDeepGroundTemps> SiteDeepGroundTemps::DeepGTMFactory(EnergyP
// Reads input and creates instance of Site:GroundTemperature:Deep object

// USE STATEMENTS:
using DataEnvironment::GroundTemp_DeepObjInput;
using namespace DataIPShortCuts;
using namespace GroundTemperatureManager;

Expand Down Expand Up @@ -110,7 +109,7 @@ std::shared_ptr<SiteDeepGroundTemps> SiteDeepGroundTemps::DeepGTMFactory(EnergyP
thisModel->deepGroundTemps(i) = rNumericArgs(i);
}

GroundTemp_DeepObjInput = true;
state.dataEnvrn->GroundTemp_DeepObjInput = true;

} else if (numCurrObjects > 1) {
ShowSevereError(state, cCurrentModuleObject + ": Too many objects entered. Only one allowed.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ SiteFCFactorMethodGroundTemps::FCFactorGTMFactory(EnergyPlusData &state, int obj
// Reads input and creates instance of Site:GroundTemperature:FCfactorMethod object

// USE STATEMENTS:
using DataEnvironment::FCGroundTemps;
using namespace DataIPShortCuts;
using namespace GroundTemperatureManager;

Expand Down Expand Up @@ -112,7 +111,7 @@ SiteFCFactorMethodGroundTemps::FCFactorGTMFactory(EnergyPlusData &state, int obj
thisModel->fcFactorGroundTemps(i) = rNumericArgs(i);
}

FCGroundTemps = true;
state.dataEnvrn->FCGroundTemps = true;
found = true;

} else if (numCurrObjects > 1) {
Expand All @@ -125,7 +124,7 @@ SiteFCFactorMethodGroundTemps::FCFactorGTMFactory(EnergyPlusData &state, int obj
thisModel->fcFactorGroundTemps(i) = state.dataWeatherManager->GroundTempsFCFromEPWHeader(i);
}

FCGroundTemps = true;
state.dataEnvrn->FCGroundTemps = true;
found = true;

} else {
Expand All @@ -134,7 +133,7 @@ SiteFCFactorMethodGroundTemps::FCFactorGTMFactory(EnergyPlusData &state, int obj
}

// Write Final Ground Temp Information to the initialization output file
if (FCGroundTemps) {
if (state.dataEnvrn->FCGroundTemps) {
write_ground_temps(state.files.eio, "FCfactorMethod", thisModel->fcFactorGroundTemps);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ std::shared_ptr<SiteShallowGroundTemps> SiteShallowGroundTemps::ShallowGTMFactor
// Reads input and creates instance of Site:GroundDomain:Shallow object

// USE STATEMENTS:
using DataEnvironment::GroundTemp_SurfaceObjInput;
using namespace DataIPShortCuts;
using namespace GroundTemperatureManager;

Expand Down Expand Up @@ -110,7 +109,7 @@ std::shared_ptr<SiteShallowGroundTemps> SiteShallowGroundTemps::ShallowGTMFactor
thisModel->surfaceGroundTemps(i) = rNumericArgs(i);
}

GroundTemp_SurfaceObjInput = true;
state.dataEnvrn->GroundTemp_SurfaceObjInput = true;

} else if (numCurrObjects > 1) {
ShowSevereError(state, cCurrentModuleObject + ": Too many objects entered. Only one allowed.");
Expand Down
24 changes: 12 additions & 12 deletions src/EnergyPlus/HVACManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -496,12 +496,12 @@ namespace HVACManager {
}
EIRPlantLoopHeatPumps::EIRPlantLoopHeatPump::checkConcurrentOperation(state);
} else if (!state.dataGlobal->KickOffSimulation && state.dataGlobal->DoOutputReporting && ReportDuringWarmup) {
if (state.dataGlobal->BeginDayFlag && !PrintEnvrnStampWarmupPrinted) {
PrintEnvrnStampWarmup = true;
PrintEnvrnStampWarmupPrinted = true;
if (state.dataGlobal->BeginDayFlag && !state.dataEnvrn->PrintEnvrnStampWarmupPrinted) {
state.dataEnvrn->PrintEnvrnStampWarmup = true;
state.dataEnvrn->PrintEnvrnStampWarmupPrinted = true;
}
if (!state.dataGlobal->BeginDayFlag) PrintEnvrnStampWarmupPrinted = false;
if (PrintEnvrnStampWarmup) {
if (!state.dataGlobal->BeginDayFlag) state.dataEnvrn->PrintEnvrnStampWarmupPrinted = false;
if (state.dataEnvrn->PrintEnvrnStampWarmup) {
if (PrintEndDataDictionary && state.dataGlobal->DoOutputReporting && !PrintedWarmup) {
print(state.files.eso, "{}\n", EndOfHeaderString);
print(state.files.mtr, "{}\n", EndOfHeaderString);
Expand All @@ -525,7 +525,7 @@ namespace HVACManager {
state.dataEnvrn->Longitude,
state.dataEnvrn->TimeZoneNumber,
state.dataEnvrn->Elevation);
PrintEnvrnStampWarmup = false;
state.dataEnvrn->PrintEnvrnStampWarmup = false;
}
PrintedWarmup = true;
}
Expand All @@ -535,12 +535,12 @@ namespace HVACManager {
if (hvacSizingSimulationManager) hvacSizingSimulationManager->UpdateSizingLogsSystemStep(state);
}
} else if (UpdateDataDuringWarmupExternalInterface) { // added for FMI
if (state.dataGlobal->BeginDayFlag && !PrintEnvrnStampWarmupPrinted) {
PrintEnvrnStampWarmup = true;
PrintEnvrnStampWarmupPrinted = true;
if (state.dataGlobal->BeginDayFlag && !state.dataEnvrn->PrintEnvrnStampWarmupPrinted) {
state.dataEnvrn->PrintEnvrnStampWarmup = true;
state.dataEnvrn->PrintEnvrnStampWarmupPrinted = true;
}
if (!state.dataGlobal->BeginDayFlag) PrintEnvrnStampWarmupPrinted = false;
if (PrintEnvrnStampWarmup) {
if (!state.dataGlobal->BeginDayFlag) state.dataEnvrn->PrintEnvrnStampWarmupPrinted = false;
if (state.dataEnvrn->PrintEnvrnStampWarmup) {
if (PrintEndDataDictionary && state.dataGlobal->DoOutputReporting && !PrintedWarmup) {
print(state.files.eso, "{}\n", EndOfHeaderString);
print(state.files.mtr, "{}\n", EndOfHeaderString);
Expand All @@ -563,7 +563,7 @@ namespace HVACManager {
state.dataEnvrn->Longitude,
state.dataEnvrn->TimeZoneNumber,
state.dataEnvrn->Elevation);
PrintEnvrnStampWarmup = false;
state.dataEnvrn->PrintEnvrnStampWarmup = false;
}
PrintedWarmup = true;
}
Expand Down
16 changes: 8 additions & 8 deletions src/EnergyPlus/HeatBalanceManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5773,7 +5773,7 @@ namespace HeatBalanceManager {
ShowContinueError(state, "Warmup Convergence failing during sizing.");
SizingWarmupConvergenceWarning = true;
}
if (RunPeriodEnvironment) {
if (state.dataEnvrn->RunPeriodEnvironment) {
ShowContinueError(state, "...Environment(RunPeriod)=\"" + state.dataEnvrn->EnvironmentName + "\"");
} else {
ShowContinueError(state, "...Environment(SizingPeriod)=\"" + state.dataEnvrn->EnvironmentName + "\"");
Expand Down Expand Up @@ -5903,7 +5903,7 @@ namespace HeatBalanceManager {
TempZoneRptStdDev = 0.0;
LoadZoneRptStdDev = 0.0;

if (RunPeriodEnvironment) {
if (state.dataEnvrn->RunPeriodEnvironment) {
EnvHeader = "RunPeriod:";
} else {
EnvHeader = "SizingPeriod:";
Expand Down Expand Up @@ -6008,12 +6008,12 @@ namespace HeatBalanceManager {
UpdateTabularReports(state, OutputProcessor::TimeStepType::TimeStepZone);
UpdateUtilityBills(state);
} else if (!state.dataGlobal->KickOffSimulation && state.dataGlobal->DoOutputReporting && ReportDuringWarmup) {
if (state.dataGlobal->BeginDayFlag && !PrintEnvrnStampWarmupPrinted) {
PrintEnvrnStampWarmup = true;
PrintEnvrnStampWarmupPrinted = true;
if (state.dataGlobal->BeginDayFlag && !state.dataEnvrn->PrintEnvrnStampWarmupPrinted) {
state.dataEnvrn->PrintEnvrnStampWarmup = true;
state.dataEnvrn->PrintEnvrnStampWarmupPrinted = true;
}
if (!state.dataGlobal->BeginDayFlag) PrintEnvrnStampWarmupPrinted = false;
if (PrintEnvrnStampWarmup) {
if (!state.dataGlobal->BeginDayFlag) state.dataEnvrn->PrintEnvrnStampWarmupPrinted = false;
if (state.dataEnvrn->PrintEnvrnStampWarmup) {
if (PrintEndDataDictionary && state.dataGlobal->DoOutputReporting) {
static constexpr auto EndOfHeaderString("End of Data Dictionary"); // End of data dictionary marker
print(state.files.eso, "{}\n", EndOfHeaderString);
Expand All @@ -6039,7 +6039,7 @@ namespace HeatBalanceManager {
state.dataEnvrn->Longitude,
state.dataEnvrn->TimeZoneNumber,
state.dataEnvrn->Elevation);
PrintEnvrnStampWarmup = false;
state.dataEnvrn->PrintEnvrnStampWarmup = false;
}
}
CalcMoreNodeInfo(state);
Expand Down
Loading

5 comments on commit 90a9ada

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

global_dataEnvironment (mitchute) - x86_64-MacOS-10.15-clang-11.0.0: OK (2994 of 2994 tests passed, 0 test warnings)

Build Badge Test Badge

@nrel-bot-2c
Copy link

Choose a reason for hiding this comment

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

global_dataEnvironment (mitchute) - x86_64-Linux-Ubuntu-18.04-gcc-7.5: OK (3034 of 3034 tests passed, 0 test warnings)

Build Badge Test Badge

@nrel-bot-2b
Copy link

Choose a reason for hiding this comment

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

global_dataEnvironment (mitchute) - x86_64-Linux-Ubuntu-18.04-gcc-7.5-UnitTestsCoverage-Debug: OK (1558 of 1558 tests passed, 0 test warnings)

Build Badge Test Badge Coverage Badge

@nrel-bot
Copy link

Choose a reason for hiding this comment

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

global_dataEnvironment (mitchute) - Win64-Windows-10-VisualStudio-16: OK (2250 of 2250 tests passed, 0 test warnings)

Build Badge Test Badge

@nrel-bot-2c
Copy link

Choose a reason for hiding this comment

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

global_dataEnvironment (mitchute) - x86_64-Linux-Ubuntu-18.04-gcc-7.5-IntegrationCoverage-Debug: Coverage Too Low

Failures:\n

integration Test Summary

  • Passed: 721
  • Timeout: 1

Build Badge Test Badge Coverage Badge

Please sign in to comment.