Skip to content

Commit

Permalink
Not even sure how to label these anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
amirroth committed Dec 14, 2023
1 parent 5f2e84a commit 8208ed8
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 59 deletions.
80 changes: 31 additions & 49 deletions src/EnergyPlus/OutputProcessor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -902,12 +902,12 @@ namespace OutputProcessor {
op->meters.push_back(meter);
op->meterMap.insert_or_assign(meterNameUC, meterNum);

for (int iPeriod = 0; iPeriod < (int)ReportFreq::Num; ++iPeriod) {
meter->periods[iPeriod].RptNum = ++op->ReportNumberCounter;
for (ReportFreq reportFreq : {ReportFreq::TimeStep, ReportFreq::Hour, ReportFreq::Day, ReportFreq::Month, ReportFreq::Year, ReportFreq::Simulation}) {
meter->periods[(int)reportFreq].RptNum = ++op->ReportNumberCounter;
}

for (int iPeriod = 0; iPeriod < (int)ReportFreq::Num; ++iPeriod) {
meter->periods[iPeriod].accRptNum = ++op->ReportNumberCounter;
for (ReportFreq reportFreq : {ReportFreq::TimeStep, ReportFreq::Hour, ReportFreq::Day, ReportFreq::Month, ReportFreq::Year, ReportFreq::Simulation}) {
meter->periods[(int)reportFreq].accRptNum = ++op->ReportNumberCounter;
}

// Do the loop again, this time without error checking
Expand Down Expand Up @@ -1201,12 +1201,12 @@ namespace OutputProcessor {
op->meters.push_back(meter);
op->meterMap.insert_or_assign(meterNameUC, meterNum);

for (int iPeriod = 0; iPeriod < (int)ReportFreq::Num; ++iPeriod) {
meter->periods[iPeriod].RptNum = ++op->ReportNumberCounter;
for (ReportFreq reportFreq : {ReportFreq::TimeStep, ReportFreq::Hour, ReportFreq::Day, ReportFreq::Month, ReportFreq::Year, ReportFreq::Simulation}) {
meter->periods[(int)reportFreq].RptNum = ++op->ReportNumberCounter;
}

for (int iPeriod = 0; iPeriod < (int)ReportFreq::Num; ++iPeriod) {
meter->periods[iPeriod].accRptNum = ++op->ReportNumberCounter;
for (ReportFreq reportFreq : {ReportFreq::TimeStep, ReportFreq::Hour, ReportFreq::Day, ReportFreq::Month, ReportFreq::Year, ReportFreq::Simulation}) {
meter->periods[(int)reportFreq].accRptNum = ++op->ReportNumberCounter;
}

// Links meter to dec meter and its output variable and vice versa
Expand Down Expand Up @@ -1372,20 +1372,6 @@ namespace OutputProcessor {

}

int AddCustomMeter([[maybe_unused]] EnergyPlusData &state,
[[maybe_unused]] std::string const &Name // Name for the meter
)
{

// SUBROUTINE INFORMATION:
// AUTHOR Linda Lawrie
// DATE WRITTEN January 2001

// PURPOSE OF THIS SUBROUTINE:
// This subroutine adds a meter to the current definition set of meters.
return -1;
}

void AttachMeters(EnergyPlusData &state,
Constant::Units const units, // Units for this meter
Constant::eResource resource, // Electricity, Gas, etc.
Expand Down Expand Up @@ -1587,8 +1573,9 @@ namespace OutputProcessor {
meter->periods[(int)ReportFreq::TimeStep].Value += op->meterValues[iMeter];
// Is this correct? What is going on here?
} else {
meter->periods[(int)ReportFreq::TimeStep].Value =
op->meters[meter->decMeterNum]->periods[(int)ReportFreq::TimeStep].Value - op->meterValues[iMeter];
meter->periods[(int)ReportFreq::TimeStep].Value += op->meterValues[iMeter];
// meter->periods[(int)ReportFreq::TimeStep].Value =
// op->meters[meter->decMeterNum]->periods[(int)ReportFreq::TimeStep].Value - op->meterValues[iMeter];
}

Real64 TSValue = meter->periods[(int)ReportFreq::TimeStep].Value;
Expand All @@ -1603,32 +1590,33 @@ namespace OutputProcessor {
// Set Max
for (auto *meter : op->meters) {
Real64 TSValue = meter->periods[(int)ReportFreq::TimeStep].Value;

Real64 TSValueComp = TSValue - 0.00001;

// Todo - HRMinVal, HRMaxVal not used
auto &periodDY = meter->periods[(int)ReportFreq::Day];
if (TSValue <= periodDY.MaxVal) continue;
if (TSValueComp <= periodDY.MaxVal) continue;
periodDY.MaxVal = TSValue;
periodDY.MaxValDate = TimeStamp;

auto &periodMN = meter->periods[(int)ReportFreq::Month];
if (TSValue <= periodMN.MaxVal) continue;
if (TSValueComp <= periodMN.MaxVal) continue;
periodMN.MaxVal = TSValue;
periodMN.MaxValDate = TimeStamp;


auto &periodYR = meter->periods[(int)ReportFreq::Year];
if (TSValue > periodYR.MaxVal) {
if (TSValueComp > periodYR.MaxVal) {
periodYR.MaxVal = TSValue;
periodYR.MaxValDate = TimeStamp;
}

auto &periodSM = meter->periods[(int)ReportFreq::Simulation];
if (TSValue > periodSM.MaxVal) {
if (TSValueComp > periodSM.MaxVal) {
periodSM.MaxVal = TSValue;
periodSM.MaxValDate = TimeStamp;
}

if (op->isFinalYear && TSValue > meter->periodFinYrSM.MaxVal) {
if (op->isFinalYear && TSValueComp > meter->periodFinYrSM.MaxVal) {
meter->periodFinYrSM.MaxVal = TSValue;
meter->periodFinYrSM.MaxValDate = TimeStamp;
}
Expand All @@ -1637,32 +1625,33 @@ namespace OutputProcessor {
// Set Min
for (auto *meter : op->meters) {
Real64 TSValue = meter->periods[(int)ReportFreq::TimeStep].Value;

Real64 TSValueComp = TSValue + 0.00001;

auto &periodDY = meter->periods[(int)ReportFreq::Day];
if (TSValue >= periodDY.MinVal) continue;
if (TSValueComp >= periodDY.MinVal) continue;

periodDY.MinVal = TSValue;
periodDY.MinValDate = TimeStamp;

auto &periodMN = meter->periods[(int)ReportFreq::Month];
if (TSValue >= periodMN.MinVal) continue;
if (TSValueComp >= periodMN.MinVal) continue;

periodMN.MinVal = TSValue;
periodMN.MinValDate = TimeStamp;

auto &periodYR = meter->periods[(int)ReportFreq::Year];
if (TSValue < periodYR.MinVal) {
if (TSValueComp < periodYR.MinVal) {
periodYR.MinVal = TSValue;
periodYR.MinValDate = TimeStamp;
}

auto &periodSM = meter->periods[(int)ReportFreq::Simulation];
if (TSValue < periodSM.MinVal) {
if (TSValueComp < periodSM.MinVal) {
periodSM.MinVal = TSValue;
periodSM.MinValDate = TimeStamp;
}

if (op->isFinalYear && TSValue < meter->periodFinYrSM.MinVal) {
if (op->isFinalYear && TSValueComp < meter->periodFinYrSM.MinVal) {
meter->periodFinYrSM.MinVal = TSValue;
meter->periodFinYrSM.MinValDate = TimeStamp;
}
Expand Down Expand Up @@ -3615,31 +3604,24 @@ void UpdateDataandReport(EnergyPlusData &state, OutputProcessor::TimeStepType co
for (int srcVarNum : meter->srcVarNums) {
auto *var = op->outVars[srcVarNum];
// Separate the Zone variables from the HVAC variables using TimeStepType
if (var->timeStepType != TimeStepType::Zone) continue;

auto *rVar = dynamic_cast<OutVarReal *>(var);
assert(rVar != nullptr);
// Add to the total all of the appropriate variables
op->meterValues[iMeter] += (*rVar->Which) * rVar->ZoneMult * rVar->ZoneListMult;
if (var->timeStepType != TimeStepType::Zone && var->timeStepType != TimeStepType::System) continue;
// Add to the total all of the appropriate variables, make sure to use var->TSValue and not *var->Which
op->meterValues[iMeter] += var->TSValue * var->ZoneMult * var->ZoneListMult;
}
} else if (meter->type == MeterType::CustomDec) {
auto *decMeter = op->meters[meter->decMeterNum];
for (int srcVarNum : decMeter->srcVarNums) {
auto *var = op->outVars[srcVarNum];
if (var->timeStepType != TimeStepType::Zone && var->timeStepType != TimeStepType::System) continue;
auto *rVar = dynamic_cast<OutVarReal *>(var);
assert(rVar != nullptr);
op->meterValues[iMeter] += (*rVar->Which) * rVar->ZoneMult * rVar->ZoneListMult;
op->meterValues[iMeter] += var->TSValue * var->ZoneMult * var->ZoneListMult;
}
for (int srcVarNum : meter->srcVarNums) {
auto *var = op->outVars[srcVarNum];
if (var->timeStepType != TimeStepType::Zone && var->timeStepType != TimeStepType::System) continue;
auto *rVar = dynamic_cast<OutVarReal *>(var);
assert(rVar != nullptr);
op->meterValues[iMeter] -= (*rVar->Which) * rVar->ZoneMult * rVar->ZoneListMult;
op->meterValues[iMeter] -= var->TSValue * var->ZoneMult * var->ZoneListMult;
}
} else {
assert(false);
assert(false);
}
} // for (iMeter)
} // if (op->meterValues.capacity() > 0)
Expand Down
10 changes: 1 addition & 9 deletions src/EnergyPlus/OutputProcessor.hh
Original file line number Diff line number Diff line change
Expand Up @@ -592,13 +592,9 @@ namespace OutputProcessor {
MeterPeriod periodLastSM;
MeterPeriod periodFinYrSM;

// These fields are only relevant for normal meters
int outVarNum = -1; // Output variable for a normal meter
std::vector<int> dstMeterNums; // Destination meters for custom meters

// These fields are only relevant for custom meters
// I thought of making NormalMeter and CustomMeter subclasses of Meter but decided it wasn't worth it
int decMeterNum = -1; // for custom decrement meters, this is the meter number for the subtraction
int decMeterNum = -1; // for custom decrement meters, the number of the meter being subtracted from
std::vector<int> srcVarNums; // Source variables for custom meters
std::vector<int> srcMeterNums; // Source meters for custom meters

Expand Down Expand Up @@ -679,10 +675,6 @@ namespace OutputProcessor {
int outVarNum
);

int AddCustomMeter(EnergyPlusData &state,
std::string const &Name // Name for the meter
);

void AttachMeters(EnergyPlusData &state,
Constant::Units units, // Units for this meter
Constant::eResource resource, // Electricity, Gas, etc.
Expand Down
2 changes: 1 addition & 1 deletion tst/EnergyPlus/unit/OutputProcessor.unit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ namespace OutputProcessor {
meter->resource = Constant::eResource::Electricity;
op->meters.push_back(meter);

meter->outVarNum = op->outVars.size() - 1;
meter->srcVarNums.push_back(op->outVars.size() - 1);
realVar->meterNums.push_back(op->meters.size() - 1);

NumFound = GetNumMeteredVariables(*state, TypeOfComp, NameOfComp);
Expand Down

5 comments on commit 8208ed8

@nrel-bot
Copy link

Choose a reason for hiding this comment

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

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

Failures:\n

API Test Summary

  • Passed: 14
  • Failed: 1

integration Test Summary

  • Passed: 783
  • Failed: 6

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.

Qsort (amirroth) - x86_64-Linux-Ubuntu-22.04-gcc-11.4: OK (3462 of 3584 tests passed, 669 test warnings)

Messages:\n

  • 774 tests had: AUD diffs.
  • 16 tests had: EDD diffs.
  • 76 tests had: ESO big diffs.
  • 13 tests had: ESO small diffs.
  • 29 tests had: MTR small diffs.
  • 50 tests had: MTD diffs.
  • 57 tests had: Table big diffs.
  • 72 tests had: MTR big diffs.
  • 13 tests had: MDD diffs.
  • 28 tests had: EIO diffs.
  • 26 tests had: ERR diffs.
  • 5 tests had: RDD diffs.
  • 1 test had: SSZ small diffs.
  • 1 test had: ZSZ small diffs.
  • 1 test had: PERF_LOG diffs.
  • 6 tests had: SSZ big diffs.
  • 6 tests had: ZSZ big diffs.

Failures:\n

API Test Summary

  • Passed: 14
  • Failed: 1

integration Test Summary

  • Passed: 788
  • Failed: 4

regression Test Summary

  • Passed: 689
  • Failed: 117

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.

Qsort (amirroth) - x86_64-MacOS-10.17-clang-14.0.0: OK (3418 of 3543 tests passed, 665 test warnings)

Messages:\n

  • 770 tests had: AUD diffs.
  • 16 tests had: EDD diffs.
  • 76 tests had: ESO big diffs.
  • 52 tests had: MTD diffs.
  • 26 tests had: MTR small diffs.
  • 11 tests had: ESO small diffs.
  • 57 tests had: Table big diffs.
  • 71 tests had: MTR big diffs.
  • 28 tests had: EIO diffs.
  • 26 tests had: ERR diffs.
  • 13 tests had: MDD diffs.
  • 5 tests had: RDD diffs.
  • 1 test had: SSZ small diffs.
  • 1 test had: ZSZ small diffs.
  • 2 tests had: BND diffs.
  • 1 test had: PERF_LOG diffs.
  • 6 tests had: SSZ big diffs.
  • 6 tests had: ZSZ big diffs.

Failures:\n

API Test Summary

  • Passed: 14
  • Failed: 1

integration Test Summary

  • Passed: 783
  • Failed: 6

regression Test Summary

  • Passed: 669
  • Failed: 117

SQLiteFixture Test Summary

  • Passed: 99
  • Failed: 1

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.

Qsort (amirroth) - x86_64-Linux-Ubuntu-22.04-gcc-11.4-UnitTestsCoverage-Debug: OK (1967 of 1969 tests passed, 0 test warnings)

Failures:\n

API Test Summary

  • Passed: 14
  • Failed: 1

SQLiteFixture Test Summary

  • Passed: 99
  • Subprocess aborted: 1

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.

Qsort (amirroth) - x86_64-Linux-Ubuntu-22.04-gcc-11.4-IntegrationCoverage-Debug: OK (779 of 790 tests passed, 0 test warnings)

Failures:\n

integration Test Summary

  • Passed: 779
  • Failed: 11

Build Badge Test Badge Coverage Badge

Please sign in to comment.