Skip to content

Commit

Permalink
Merge pull request #10289 from NREL/Pollution1
Browse files Browse the repository at this point in the history
First (and only?) Pollution module refactor
  • Loading branch information
Myoldmopar authored Nov 8, 2023
2 parents b99411d + bc92755 commit ffff616
Show file tree
Hide file tree
Showing 12 changed files with 702 additions and 7,749 deletions.
4 changes: 2 additions & 2 deletions src/EnergyPlus/Data/EnergyPlusData.cc
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ EnergyPlusData::EnergyPlusData()
this->dataPlantValves = std::make_unique<PlantValvesData>();
this->dataPlnt = std::make_unique<DataPlantData>();
this->dataPluginManager = std::make_unique<PluginManagerData>();
this->dataPollutionModule = std::make_unique<PollutionModuleData>();
this->dataPollution = std::make_unique<PollutionData>();
this->dataPondGHE = std::make_unique<PondGroundHeatExchangerData>();
this->dataPowerInductionUnits = std::make_unique<PoweredInductionUnitsData>();
this->dataPsychrometrics = std::make_unique<PsychrometricsData>();
Expand Down Expand Up @@ -469,7 +469,7 @@ void EnergyPlusData::clear_state()
this->dataPlantValves->clear_state();
this->dataPlnt->clear_state();
this->dataPluginManager->clear_state();
this->dataPollutionModule->clear_state();
this->dataPollution->clear_state();
this->dataPondGHE->clear_state();
this->dataPowerInductionUnits->clear_state();
this->dataPsychrometrics->clear_state();
Expand Down
4 changes: 2 additions & 2 deletions src/EnergyPlus/Data/EnergyPlusData.hh
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ struct PlantPressureSysData;
struct PlantUtilitiesData;
struct PlantValvesData;
struct PluginManagerData;
struct PollutionModuleData;
struct PollutionData;
struct PondGroundHeatExchangerData;
struct PoweredInductionUnitsData;
struct PsychrometricsData;
Expand Down Expand Up @@ -485,7 +485,7 @@ struct EnergyPlusData : BaseGlobalStruct
std::unique_ptr<PlantUtilitiesData> dataPlantUtilities;
std::unique_ptr<PlantValvesData> dataPlantValves;
std::unique_ptr<PluginManagerData> dataPluginManager;
std::unique_ptr<PollutionModuleData> dataPollutionModule;
std::unique_ptr<PollutionData> dataPollution;
std::unique_ptr<PondGroundHeatExchangerData> dataPondGHE;
std::unique_ptr<PoweredInductionUnitsData> dataPowerInductionUnits;
std::unique_ptr<PsychrometricsData> dataPsychrometrics;
Expand Down
81 changes: 0 additions & 81 deletions src/EnergyPlus/DataGlobalConstants.hh
Original file line number Diff line number Diff line change
Expand Up @@ -151,27 +151,6 @@ namespace Constant {
Num
};

enum class ePollutant
{
Invalid = -1,
SO2,
NOx,
N2O,
PM,
PM2_5,
PM10,
CO,
CO2,
CH4,
NH3,
NMVOC,
Hg,
Pb,
NuclearHigh,
NuclearLow,
Num
};

constexpr std::array<eFuel, static_cast<int>(eResource::Num)> eResource2eFuel = {eFuel::Electricity,
eFuel::NaturalGas,
eFuel::Gasoline,
Expand Down Expand Up @@ -237,32 +216,6 @@ namespace Constant {
eResource::Water,
eResource::None};

constexpr std::array<ePollutant, static_cast<int>(eResource::Num)> eResource2ePollutant = {
ePollutant::Invalid, ePollutant::Invalid, ePollutant::Invalid, ePollutant::Invalid, ePollutant::Invalid, ePollutant::Invalid,
ePollutant::Invalid, ePollutant::Invalid, ePollutant::Invalid, ePollutant::Invalid, ePollutant::Invalid, ePollutant::Invalid,
ePollutant::Invalid, ePollutant::Invalid, ePollutant::Invalid, ePollutant::Invalid, ePollutant::Invalid, ePollutant::Invalid,
ePollutant::Invalid, ePollutant::Invalid, ePollutant::Invalid, ePollutant::Invalid, ePollutant::Invalid, ePollutant::Invalid,
ePollutant::Invalid, ePollutant::Invalid, ePollutant::Invalid, ePollutant::Invalid, ePollutant::Invalid, ePollutant::Invalid,
ePollutant::Invalid, ePollutant::Invalid, ePollutant::Invalid, ePollutant::SO2, ePollutant::NOx, ePollutant::N2O,
ePollutant::PM, ePollutant::PM2_5, ePollutant::PM10, ePollutant::CO, ePollutant::CO2, ePollutant::CH4,
ePollutant::NH3, ePollutant::NMVOC, ePollutant::Hg, ePollutant::Pb, ePollutant::NuclearHigh, ePollutant::NuclearLow};

constexpr std::array<eResource, static_cast<int>(ePollutant::Num)> ePollutant2eResource = {eResource::SO2,
eResource::NOx,
eResource::N2O,
eResource::PM,
eResource::PM2_5,
eResource::PM10,
eResource::CO,
eResource::CO2,
eResource::CH4,
eResource::NH3,
eResource::NMVOC,
eResource::Hg,
eResource::Pb,
eResource::NuclearHigh,
eResource::NuclearLow};

static constexpr std::array<std::string_view, static_cast<int>(eResource::Num)> eResourceNamesUC = {"ELECTRICITY",
"NATURALGAS",
"GASOLINE",
Expand Down Expand Up @@ -395,40 +348,6 @@ namespace Constant {
eResourceNames[static_cast<int>(eFuel2eResource[static_cast<int>(eFuel::Water)])],
eResourceNames[static_cast<int>(eFuel2eResource[static_cast<int>(eFuel::None)])]};

static constexpr std::array<std::string_view, static_cast<int>(ePollutant::Num)> ePollutantNamesUC = {
eResourceNamesUC[static_cast<int>(ePollutant2eResource[static_cast<int>(ePollutant::SO2)])],
eResourceNamesUC[static_cast<int>(ePollutant2eResource[static_cast<int>(ePollutant::NOx)])],
eResourceNamesUC[static_cast<int>(ePollutant2eResource[static_cast<int>(ePollutant::N2O)])],
eResourceNamesUC[static_cast<int>(ePollutant2eResource[static_cast<int>(ePollutant::PM)])],
eResourceNamesUC[static_cast<int>(ePollutant2eResource[static_cast<int>(ePollutant::PM2_5)])],
eResourceNamesUC[static_cast<int>(ePollutant2eResource[static_cast<int>(ePollutant::PM10)])],
eResourceNamesUC[static_cast<int>(ePollutant2eResource[static_cast<int>(ePollutant::CO)])],
eResourceNamesUC[static_cast<int>(ePollutant2eResource[static_cast<int>(ePollutant::CO2)])],
eResourceNamesUC[static_cast<int>(ePollutant2eResource[static_cast<int>(ePollutant::CH4)])],
eResourceNamesUC[static_cast<int>(ePollutant2eResource[static_cast<int>(ePollutant::NH3)])],
eResourceNamesUC[static_cast<int>(ePollutant2eResource[static_cast<int>(ePollutant::NMVOC)])],
eResourceNamesUC[static_cast<int>(ePollutant2eResource[static_cast<int>(ePollutant::Hg)])],
eResourceNamesUC[static_cast<int>(ePollutant2eResource[static_cast<int>(ePollutant::Pb)])],
eResourceNamesUC[static_cast<int>(ePollutant2eResource[static_cast<int>(ePollutant::NuclearHigh)])],
eResourceNamesUC[static_cast<int>(ePollutant2eResource[static_cast<int>(ePollutant::NuclearLow)])]};

static constexpr std::array<std::string_view, static_cast<int>(ePollutant::Num)> ePollutantNames = {
eResourceNames[static_cast<int>(ePollutant2eResource[static_cast<int>(ePollutant::SO2)])],
eResourceNames[static_cast<int>(ePollutant2eResource[static_cast<int>(ePollutant::NOx)])],
eResourceNames[static_cast<int>(ePollutant2eResource[static_cast<int>(ePollutant::N2O)])],
eResourceNames[static_cast<int>(ePollutant2eResource[static_cast<int>(ePollutant::PM)])],
eResourceNames[static_cast<int>(ePollutant2eResource[static_cast<int>(ePollutant::PM2_5)])],
eResourceNames[static_cast<int>(ePollutant2eResource[static_cast<int>(ePollutant::PM10)])],
eResourceNames[static_cast<int>(ePollutant2eResource[static_cast<int>(ePollutant::CO)])],
eResourceNames[static_cast<int>(ePollutant2eResource[static_cast<int>(ePollutant::CO2)])],
eResourceNames[static_cast<int>(ePollutant2eResource[static_cast<int>(ePollutant::CH4)])],
eResourceNames[static_cast<int>(ePollutant2eResource[static_cast<int>(ePollutant::NH3)])],
eResourceNames[static_cast<int>(ePollutant2eResource[static_cast<int>(ePollutant::NMVOC)])],
eResourceNames[static_cast<int>(ePollutant2eResource[static_cast<int>(ePollutant::Hg)])],
eResourceNames[static_cast<int>(ePollutant2eResource[static_cast<int>(ePollutant::Pb)])],
eResourceNames[static_cast<int>(ePollutant2eResource[static_cast<int>(ePollutant::NuclearHigh)])],
eResourceNames[static_cast<int>(ePollutant2eResource[static_cast<int>(ePollutant::NuclearLow)])]};

enum class CallIndicator
{
Invalid = -1,
Expand Down
2 changes: 1 addition & 1 deletion src/EnergyPlus/HVACManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ void ManageHVAC(EnergyPlusData &state)
if (!state.dataGlobal->WarmupFlag) {
if (state.dataGlobal->DoOutputReporting && !state.dataGlobal->ZoneSizingCalc) {
NodeInputManager::CalcMoreNodeInfo(state);
PollutionModule::CalculatePollution(state);
Pollution::CalculatePollution(state);
SystemReports::InitEnergyReports(state);
SystemReports::ReportSystemEnergyUse(state);
}
Expand Down
2 changes: 1 addition & 1 deletion src/EnergyPlus/OutputProcessor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6240,7 +6240,7 @@ void SetInitialMeterReportingAndOutputNames(EnergyPlusData &state,
}
}

int GetMeterIndex(EnergyPlusData &state, std::string const &MeterName)
int GetMeterIndex(EnergyPlusData &state, std::string_view const MeterName)
{

// FUNCTION INFORMATION:
Expand Down
2 changes: 1 addition & 1 deletion src/EnergyPlus/OutputProcessor.hh
Original file line number Diff line number Diff line change
Expand Up @@ -1178,7 +1178,7 @@ void SetInitialMeterReportingAndOutputNames(EnergyPlusData &state,
bool CumulativeIndicator // true if this is a Cumulative meter reporting
);

int GetMeterIndex(EnergyPlusData &state, std::string const &MeterName);
int GetMeterIndex(EnergyPlusData &state, std::string_view const MeterName);

std::string GetMeterResourceType(EnergyPlusData &state, int MeterNumber); // Which Meter Number (from GetMeterIndex)

Expand Down
4 changes: 2 additions & 2 deletions src/EnergyPlus/OutputReportTabular.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2804,8 +2804,8 @@ void GetInputFuelAndPollutionFactors(EnergyPlusData &state)
// na

// Using/Aliasing
using PollutionModule::GetEnvironmentalImpactFactorInfo;
using PollutionModule::GetFuelFactorInfo;
using Pollution::GetEnvironmentalImpactFactorInfo;
using Pollution::GetFuelFactorInfo;

// Locals
// SUBROUTINE ARGUMENT DEFINITIONS:
Expand Down
Loading

4 comments on commit ffff616

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

develop (Myoldmopar) - x86_64-Linux-Ubuntu-22.04-gcc-11.4: OK (2775 of 2775 tests passed, 0 test warnings)

Build Badge Test 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.

develop (Myoldmopar) - Win64-Windows-10-VisualStudio-16: OK (2753 of 2753 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.

develop (Myoldmopar) - x86_64-Linux-Ubuntu-22.04-gcc-11.4-IntegrationCoverage-Debug: OK (790 of 790 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.

develop (Myoldmopar) - x86_64-Linux-Ubuntu-22.04-gcc-11.4-UnitTestsCoverage-Debug: OK (1966 of 1966 tests passed, 0 test warnings)

Build Badge Test Badge Coverage Badge

Please sign in to comment.