Skip to content

Commit

Permalink
Fix some diffs, address Cpp-check comments
Browse files Browse the repository at this point in the history
  • Loading branch information
amirroth committed Nov 1, 2023
1 parent 136a4b7 commit 2eef9a4
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 16 deletions.
46 changes: 30 additions & 16 deletions src/EnergyPlus/PollutionModule.cc
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,18 @@ void GetPollutionFactorInput(EnergyPlusData &state)

ErrorObjectHeader eoh{routineName, ipsc->cCurrentModuleObject, ipsc->cAlphaArgs(1)};

Constant::eFuel fuel = static_cast<Constant::eFuel>(getEnumValue(Constant::eFuelNamesUC, Util::makeUPPER(ipsc->cAlphaArgs(1))));
PollFuel pollFuel = static_cast<PollFuel>(getEnumValue(pollFuelNamesUC, Util::makeUPPER(ipsc->cAlphaArgs(1))));
if (pollFuel == PollFuel::Invalid) {
ShowSevereInvalidKey(state, eoh, ipsc->cAlphaFieldNames(1), ipsc->cAlphaArgs(1));
ErrorsFound = true;
continue;
}

auto &pollCoeff = pm->pollCoeffs[(int)fuel];
pm->pollFuelFactorList.push_back(pollFuel);

auto &pollCoeff = pm->pollCoeffs[(int)pollFuel];
Constant::eFuel fuel = pollFuel2fuel[(int)pollFuel];

if (pollCoeff.used) {
ShowWarningError(state, format("{}: {} already entered. Previous entry will be used.",
ipsc->cCurrentModuleObject, Constant::eFuelNames[(int)fuel]));
Expand All @@ -288,7 +297,7 @@ void GetPollutionFactorInput(EnergyPlusData &state)

pollCoeff.used = true;

pollCoeff.sourceSchedNum = ipsc->rNumericArgs(1);
pollCoeff.sourceCoeff = ipsc->rNumericArgs(1);
if (!ipsc->lAlphaFieldBlanks(2)) {
pollCoeff.sourceSchedNum = ScheduleManager::GetScheduleIndex(state, ipsc->cAlphaArgs(2));
if (pollCoeff.sourceSchedNum == 0) {
Expand Down Expand Up @@ -426,36 +435,41 @@ void SetupPollutionMeterReporting(EnergyPlusData &state)
pm->GetInputFlagPollution = false;
}

for (int iFuel = 0; iFuel < (int)PollFuel::Num; ++iFuel) {
// We are using this list rather than the enumeration to preserve the order in which meters are created to avoid ordering diffs.
for (PollFuel pollFuel : pm->pollFuelFactorList) {

auto &pollComp = pm->pollComps[(int)pollFuel2pollFuelComponent[iFuel]];
if (!pm->pollCoeffs[(int)pollFuel].used) continue;

auto &pollComp = pm->pollComps[(int)pollFuel2pollFuelComponent[(int)pollFuel]];

Constant::eFuel fuel = pollFuel2fuel[(int)pollFuel];

// Need to check whether this fuel is used?
SetupOutputVariable(state,
format("Environmental Impact {} Source Energy", Constant::eFuelNames[(int)pollFuel2fuel[iFuel]]),
format("Environmental Impact {} Source Energy", Constant::eFuelNames[(int)fuel]),
OutputProcessor::Unit::J,
pollComp.sourceVal,
OutputProcessor::SOVTimeStepType::System,
OutputProcessor::SOVStoreType::Summed,
"Site",
{},
"Source",
format("{}Emissions", Constant::eFuelNames[(int)pollFuel2fuel[iFuel]]),
format("{}Emissions", Constant::eFuelNames[(int)fuel]),
{},
"");

for (int iPollutant2 = 0; iPollutant2 < (int)Pollutant2::Num; ++iPollutant2) {
SetupOutputVariable(state,
format("Environmental Impact {} {}",
Constant::eFuelNames[(int)pollFuel2fuel[iFuel]], poll2outVarStrs[iPollutant2]),
Constant::eFuelNames[(int)fuel], poll2outVarStrs[iPollutant2]),
poll2Units[iPollutant2],
pollComp.pollutantVals[iPollutant2],
OutputProcessor::SOVTimeStepType::System,
OutputProcessor::SOVStoreType::Summed,
"Site",
{},
poll2Names[iPollutant2],
format("{}Emissions", Constant::eFuelNames[(int)pollFuel2fuel[iFuel]]),
format("{}Emissions", Constant::eFuelNames[(int)fuel]),
{},
"");
}
Expand Down Expand Up @@ -535,7 +549,7 @@ void CheckPollutionMeterReporting(EnergyPlusData &state)

// in progress (what is in progress?)

auto &pm = state.dataPollution;
auto const &pm = state.dataPollution;

if (pm->NumFuelFactors == 0 || pm->NumEnvImpactFactors == 0) {
if (ReportingThisVariable(state, "Environmental Impact Total N2O Emissions Carbon Equivalent Mass") ||
Expand Down Expand Up @@ -608,11 +622,11 @@ void CalcPollution(EnergyPlusData &state)
}

// does not include district heating or steam
auto const &pollCoeff = pm->pollCoeffs[(int)PollFuel::NaturalGas];
auto &pollComp = pm->pollComps[(int)PollFuelComponent::NaturalGas];
pollComp.sourceVal = pm->facilityMeterVals[(int)PollFacilityMeter::NaturalGas] * pollCoeff.sourceCoeff;
if (pollCoeff.sourceSchedNum != 0) {
pollComp.sourceVal *= ScheduleManager::GetCurrentScheduleValue(state, pollCoeff.sourceSchedNum);
auto const &pollCoeffGas = pm->pollCoeffs[(int)PollFuel::NaturalGas];
auto &pollCompGas = pm->pollComps[(int)PollFuelComponent::NaturalGas];
pollCompGas.sourceVal = pm->facilityMeterVals[(int)PollFacilityMeter::NaturalGas] * pollCoeffGas.sourceCoeff;
if (pollCoeffGas.sourceSchedNum != 0) {
pollCompGas.sourceVal *= ScheduleManager::GetCurrentScheduleValue(state, pollCoeffGas.sourceSchedNum);
}

for (PollFuel pollFuel : {PollFuel::FuelOil1, PollFuel::FuelOil2, PollFuel::Diesel, PollFuel::Gasoline,
Expand Down Expand Up @@ -755,7 +769,7 @@ void GetEnvironmentalImpactFactorInfo(EnergyPlusData &state,
// This routine allows access to data inside this module from other modules (specifically the
// output tabular reports.

auto &pm = state.dataPollution;
auto const &pm = state.dataPollution;
if (pm->GetInputFlagPollution) {
GetPollutionFactorInput(state);
pm->GetInputFlagPollution = false;
Expand Down
17 changes: 17 additions & 0 deletions src/EnergyPlus/PollutionModule.hh
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,19 @@ namespace Pollution {
Constant::eFuel::OtherFuel2 // OtherFuel2
};

constexpr std::array<std::string_view, (int)PollFuel::Num> pollFuelNamesUC = {
Constant::eFuelNamesUC[(int)pollFuel2fuel[(int)PollFuel::Electricity]], // Electricity
Constant::eFuelNamesUC[(int)pollFuel2fuel[(int)PollFuel::NaturalGas]], // NaturalGas
Constant::eFuelNamesUC[(int)pollFuel2fuel[(int)PollFuel::FuelOil1]], // FuelOil1
Constant::eFuelNamesUC[(int)pollFuel2fuel[(int)PollFuel::FuelOil2]], // FuelOil2
Constant::eFuelNamesUC[(int)pollFuel2fuel[(int)PollFuel::Coal]], // Coal
Constant::eFuelNamesUC[(int)pollFuel2fuel[(int)PollFuel::Gasoline]], // Gasoline
Constant::eFuelNamesUC[(int)pollFuel2fuel[(int)PollFuel::Propane]], // Propane
Constant::eFuelNamesUC[(int)pollFuel2fuel[(int)PollFuel::Diesel]], // Diesel
Constant::eFuelNamesUC[(int)pollFuel2fuel[(int)PollFuel::OtherFuel1]], // OtherFuel1
Constant::eFuelNamesUC[(int)pollFuel2fuel[(int)PollFuel::OtherFuel2]] // OtherFuel2
};

enum class PollFuelComponent
{
Invalid = -1,
Expand Down Expand Up @@ -332,6 +345,8 @@ struct PollutionData : BaseGlobalStruct

std::array<Real64, (int)Constant::ePollutant::Num> pollutantVals;

std::vector<Pollution::PollFuel> pollFuelFactorList;

// Total Carbon Equivalent Components
Real64 TotCarbonEquivFromN2O;
Real64 TotCarbonEquivFromCH4;
Expand All @@ -353,6 +368,8 @@ struct PollutionData : BaseGlobalStruct
this->GetInputFlagPollution = true;
this->NumEnvImpactFactors = 0;
this->NumFuelFactors = 0;

this->pollFuelFactorList.clear();
}
};

Expand Down

5 comments on commit 2eef9a4

@nrel-bot
Copy link

Choose a reason for hiding this comment

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

Pollution1 (amirroth) - Win64-Windows-10-VisualStudio-16: OK (2749 of 2750 tests passed, 0 test warnings)

Failures:\n

EnergyPlusFixture Test Summary

  • Passed: 1476
  • Failed: 1

Build Badge Test Badge

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

Pollution1 (amirroth) - x86_64-MacOS-10.17-clang-14.0.0: OK (3459 of 3536 tests passed, 709 test warnings)

Messages:\n

  • 697 tests had: AUD diffs.
  • 754 tests had: MDD diffs.
  • 768 tests had: MTD diffs.
  • 754 tests had: RDD diffs.
  • 28 tests had: Table big diffs.
  • 59 tests had: ESO big diffs.
  • 59 tests had: MTR big diffs.
  • 3 tests had: ERR diffs.

Failures:\n

EnergyPlusFixture Test Summary

  • Passed: 1478
  • Failed: 1

regression Test Summary

  • Passed: 709
  • Failed: 76

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.

Pollution1 (amirroth) - x86_64-Linux-Ubuntu-22.04-gcc-11.4: OK (3500 of 3577 tests passed, 713 test warnings)

Messages:\n

  • 701 tests had: AUD diffs.
  • 758 tests had: MDD diffs.
  • 772 tests had: MTD diffs.
  • 758 tests had: RDD diffs.
  • 59 tests had: ESO big diffs.
  • 59 tests had: MTR big diffs.
  • 28 tests had: Table big diffs.
  • 3 tests had: ERR diffs.

Failures:\n

EnergyPlusFixture Test Summary

  • Passed: 1478
  • Failed: 1

regression Test Summary

  • Passed: 729
  • Failed: 76

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.

Pollution1 (amirroth) - x86_64-Linux-Ubuntu-22.04-gcc-11.4-UnitTestsCoverage-Debug: OK (1962 of 1964 tests passed, 0 test warnings)

Failures:\n

EnergyPlusFixture Test Summary

  • Passed: 1477
  • Subprocess aborted: 2

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

Pollution1 (amirroth) - x86_64-Linux-Ubuntu-22.04-gcc-11.4-IntegrationCoverage-Debug: Tests Failed (702 of 789 tests passed, 0 test warnings)

Failures:\n

integration Test Summary

  • Passed: 702
  • Failed: 87

Build Badge Test Badge Coverage Badge

Please sign in to comment.