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

Global exterior energy #7965

Merged
merged 7 commits into from May 11, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/EnergyPlus/BaseboardElectric.hh
Expand Up @@ -57,6 +57,8 @@

namespace EnergyPlus {

struct EnergyPlusData;
Copy link
Member

Choose a reason for hiding this comment

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

So the main struct will live inside the EnergyPlus namespace. Anywhere that we are using a forward declaration of this struct we need to put it inside the EnergyPlus namespace, not before it, and not inside another nested namespace. This goes with any other lower level structs you may use as well.


namespace BaseboardElectric {

// Using/Aliasing
Expand Down Expand Up @@ -125,7 +127,7 @@ namespace BaseboardElectric {

void clear_state();

void SimElectricBaseboard(EnergyPlusData &state, std::string const &EquipName, int const ActualZoneNum, int const ControlledZoneNum, Real64 &PowerMet, int &CompIndex);
void SimElectricBaseboard(EnergyPlus::EnergyPlusData &state, std::string const &EquipName, int const ActualZoneNum, int const ControlledZoneNum, Real64 &PowerMet, int &CompIndex);
Copy link
Member

Choose a reason for hiding this comment

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

Accompanying that change, whenever we declare it as an argument type, it needs to be declared properly with EnergyPlus::EnergyPlusData. This goes with the other lower-level types you may use: EnergyPlus::ExteriorEnergyUseData.


void GetBaseboardInput();

Expand Down
10 changes: 1 addition & 9 deletions src/EnergyPlus/BaseboardRadiator.hh
Expand Up @@ -57,9 +57,7 @@

namespace EnergyPlus {

// Note: This file contains two modules:
// Module BaseboardRadiator -- (ref: Object: ZoneHVAC:Baseboard:Convective:Water)
// Module BaseboardElectric -- (ref: Object: ZoneHVAC:Baseboard:Convective:Electric)
struct EnergyPlusData;

namespace BaseboardRadiator {

Expand Down Expand Up @@ -185,12 +183,6 @@ namespace BaseboardRadiator {

} // namespace BaseboardRadiator

//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//******************************************************************************************************
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//******************************************************************************************************
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Copy link
Member

Choose a reason for hiding this comment

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

Feel free to clean up stuff like this as you refactor.


} // namespace EnergyPlus

#endif
208 changes: 93 additions & 115 deletions src/EnergyPlus/Data/EnergyPlusData.hh
Expand Up @@ -50,13 +50,15 @@

// EnergyPlus Headers
#include <EnergyPlus/EnergyPlus.hh>

#include <EnergyPlus/ExteriorEnergyUse.hh>
#include <unordered_map>
#include <string>

struct BaseGlobalStruct
{
virtual void clear_state() = 0;
};
namespace EnergyPlus {

struct BaseGlobalStruct {
virtual void clear_state() = 0;
};

//struct OutputReportTabular : BaseGlobalStruct
//{
Expand All @@ -66,119 +68,95 @@ struct BaseGlobalStruct
// }
//};

struct DataGlobal : BaseGlobalStruct
{
// Data
bool AnnualSimulation = false;

// MODULE VARIABLE DECLARATIONS:
std::string DayOfSimChr = "0"; // Counter for days (during the simulation) (character -- for reporting)

// MODULE PARAMETER DEFINITIONS
static constexpr int EndZoneSizingCalc = 4;

void clear_state() override {
AnnualSimulation = false;
DayOfSimChr = "0";
}
};

struct ExteriorEnergyUseData : BaseGlobalStruct
{
struct ExteriorLightUsage
{
// Members
std::string Name; // Descriptive name -- will show on reporting
int SchedPtr; // Can be scheduled
Real64 DesignLevel; // Consumption in Watts
Real64 Power; // Power = DesignLevel * ScheduleValue
Real64 CurrentUse; // Use for this time step
int ControlMode; // Control mode Schedule Only or Astronomical Clock plus schedule
bool ManageDemand; // Flag to indicate whether to use demand limiting
Real64 DemandLimit; // Demand limit set by demand manager [W]
bool PowerActuatorOn; // EMS flag
Real64 PowerActuatorValue; // EMS value
Real64 SumConsumption; // sum of electric consumption [J] for reporting
Real64 SumTimeNotZeroCons; // sum of time of positive electric consumption [hr]

// Default Constructor
ExteriorLightUsage()
: SchedPtr(0), DesignLevel(0.0), Power(0.0), CurrentUse(0.0), ControlMode(1), ManageDemand(false), DemandLimit(0.0),
PowerActuatorOn(false), SumConsumption(0.0), SumTimeNotZeroCons(0.0)
{
struct DataGlobal : BaseGlobalStruct {
// Data
bool AnnualSimulation = false;

// MODULE VARIABLE DECLARATIONS:
std::string DayOfSimChr = "0"; // Counter for days (during the simulation) (character -- for reporting)

// MODULE PARAMETER DEFINITIONS
static constexpr int EndZoneSizingCalc = 4;

void clear_state() override {
AnnualSimulation = false;
DayOfSimChr = "0";
}
};

struct ExteriorEnergyUseData : BaseGlobalStruct {
Copy link
Member

Choose a reason for hiding this comment

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

These structs should remain very lean, only variables. No nested structures, no int const values, just the actual variables storing data.


int NumExteriorLights = 0; // Number of Exterior Light Inputs
int NumExteriorEqs = 0; // Number of Exterior Equipment Inputs
Array1D<ExteriorEnergyUse::ExteriorLightUsage> ExteriorLights; // Structure for Exterior Light reporting
Array1D<ExteriorEnergyUse::ExteriorEquipmentUsage> ExteriorEquipment; // Structure for Exterior Equipment Reporting
std::unordered_map<std::string, std::string> UniqueExteriorEquipNames;
bool GetExteriorEnergyInputFlag = true; // First time, input is "gotten"
ExteriorEnergyUseData() : NumExteriorLights(0), NumExteriorEqs(0), GetExteriorEnergyInputFlag(true) {}

void clear_state() {
NumExteriorLights = 0;
NumExteriorEqs = 0;
ExteriorLights.deallocate();
ExteriorEquipment.deallocate();
UniqueExteriorEquipNames.clear();
GetExteriorEnergyInputFlag = true;
}
};

struct FansData : BaseGlobalStruct {
// constants
static constexpr int ExhaustFanCoupledToAvailManagers = 150;
static constexpr int ExhaustFanDecoupledFromAvailManagers = 151;
Copy link
Member

Choose a reason for hiding this comment

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

I didn't remove these, but I would suggest you doing it. I made an enum class from the constant integers in the exterior energy use namespace. The enum class should live back in the original header file. You'll need to go in and clean up the usage of those variables but it is generally easy. If you don't feel like tackling that during any of these refactors, it is OK, but don't bring them into this namespace. They are really just constants, not variables.


// members
int NumFans;
int NumNightVentPerf; // number of FAN:NIGHT VENT PERFORMANCE objects found in the input
bool GetFanInputFlag; // Flag set to make sure you get input once
bool LocalTurnFansOn; // If True, overrides fan schedule and cycles ZoneHVAC component fans on
bool LocalTurnFansOff; // If True, overrides fan schedule and LocalTurnFansOn and cycles ZoneHVAC component fans off

FansData() : NumFans(0), NumNightVentPerf(0), GetFanInputFlag(true), LocalTurnFansOn(false),
LocalTurnFansOff(false) {}

void clear_state() override {
NumFans = 0;
NumNightVentPerf = 0;
GetFanInputFlag = true;
LocalTurnFansOn = false;
LocalTurnFansOff = false;
}
};

struct PipesData : BaseGlobalStruct {
int NumLocalPipes;
bool GetPipeInputFlag;

PipesData() : NumLocalPipes(0), GetPipeInputFlag(true) {}

void clear_state() override {
NumLocalPipes = 0;
GetPipeInputFlag = true;
}
};

int NumExteriorLights = 0; // Number of Exterior Light Inputs
int NumExteriorEqs = 0; // Number of Exterior Equipment Inputs

// Object Data
Array1D<ExteriorLightUsage> ExteriorLights; // Structure for Exterior Light reporting

void clear_state() override {
NumExteriorLights = 0;
NumExteriorEqs = 0;
ExteriorLights.deallocate();
}
};

struct FansData : BaseGlobalStruct
{
// constants
static constexpr int ExhaustFanCoupledToAvailManagers = 150;
static constexpr int ExhaustFanDecoupledFromAvailManagers = 151;

// members
int NumFans;
int NumNightVentPerf; // number of FAN:NIGHT VENT PERFORMANCE objects found in the input
bool GetFanInputFlag; // Flag set to make sure you get input once
bool LocalTurnFansOn; // If True, overrides fan schedule and cycles ZoneHVAC component fans on
bool LocalTurnFansOff; // If True, overrides fan schedule and LocalTurnFansOn and cycles ZoneHVAC component fans off

FansData() : NumFans(0), NumNightVentPerf(0), GetFanInputFlag(true), LocalTurnFansOn(false), LocalTurnFansOff(false)
{
}

void clear_state() override
{
NumFans = 0;
NumNightVentPerf = 0;
GetFanInputFlag = true;
LocalTurnFansOn = false;
LocalTurnFansOff = false;
}
};

struct PipesData : BaseGlobalStruct
{
// MODULE VARIABLE DECLARATIONS
int NumLocalPipes = 0;
bool GetPipeInputFlag = true;

void clear_state() override {
NumLocalPipes = 0;
GetPipeInputFlag = true;
}
};

struct EnergyPlusData : BaseGlobalStruct
{
// module globals
DataGlobal dataGlobals;
ExteriorEnergyUseData exteriorEnergyUse;
FansData fans;
PipesData pipes;
//OutputReportTabular outputReportTabular;

// all clear states
void clear_state() override
{
dataGlobals.clear_state();
exteriorEnergyUse.clear_state();
fans.clear_state();
//outputReportTabular.clear_state();
pipes.clear_state();
struct EnergyPlusData : BaseGlobalStruct {
// module globals
DataGlobal dataGlobals;
ExteriorEnergyUseData exteriorEnergyUse;
FansData fans;
PipesData pipes;
//OutputReportTabular outputReportTabular;

// all clear states
void clear_state() override {
dataGlobals.clear_state();
exteriorEnergyUse.clear_state();
fans.clear_state();
//outputReportTabular.clear_state();
pipes.clear_state();
};
};
};

}
#endif
1 change: 0 additions & 1 deletion src/EnergyPlus/DataGlobals.hh
Expand Up @@ -54,7 +54,6 @@

// EnergyPlus Headers
#include <EnergyPlus/EnergyPlus.hh>
#include <EnergyPlus/Data/EnergyPlusData.hh>
Copy link
Member

Choose a reason for hiding this comment

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

This was causing a circular inclusion. And it's not needed. If, for some reason, DataGlobals needs something from the Data.hh file, it can forward declare it.


namespace EnergyPlus {

Expand Down
5 changes: 3 additions & 2 deletions src/EnergyPlus/DataHeatBalance.hh
Expand Up @@ -64,6 +64,7 @@
#include <EnergyPlus/DataVectorTypes.hh>
#include <EnergyPlus/DataWindowEquivalentLayer.hh>
#include <EnergyPlus/EnergyPlus.hh>
#include <EnergyPlus/ExteriorEnergyUse.hh>
#include <EnergyPlus/PhaseChangeModeling/HysteresisModel.hh>

namespace EnergyPlus {
Expand Down Expand Up @@ -1470,15 +1471,15 @@ namespace DataHeatBalance {
Real64 LostEnergy; // Lost energy (converted to work) [J]
Real64 TotGainEnergy; // Total heat gain [J]
std::string EndUseSubcategory; // user defined name for the end use category
int OtherEquipFuelType; // Fuel Type Number of the Other Equipment (defined in ExteriorEnergyUse.cc)
ExteriorEnergyUse::ExteriorFuelUsage OtherEquipFuelType; // Fuel Type Number of the Other Equipment (defined in ExteriorEnergyUse.cc)

// Default Constructor
ZoneEquipData()
: ZonePtr(0), SchedPtr(0), DesignLevel(0.0), EMSZoneEquipOverrideOn(false), EMSEquipPower(0.0), FractionLatent(0.0), FractionRadiant(0.0),
FractionLost(0.0), FractionConvected(0.0), CO2DesignRate(0.0), CO2RateFactor(0.0), NomMinDesignLevel(0.0), NomMaxDesignLevel(0.0),
ManageDemand(false), DemandLimit(0.0), Power(0.0), RadGainRate(0.0), ConGainRate(0.0), LatGainRate(0.0), LostRate(0.0),
TotGainRate(0.0), CO2GainRate(0.0), Consumption(0.0), RadGainEnergy(0.0), ConGainEnergy(0.0), LatGainEnergy(0.0), LostEnergy(0.0),
TotGainEnergy(0.0), EndUseSubcategory(""), OtherEquipFuelType(0)
TotGainEnergy(0.0), EndUseSubcategory(""), OtherEquipFuelType(ExteriorEnergyUse::ExteriorFuelUsage::Unknown)
{
}
};
Expand Down