Skip to content

Commit

Permalink
Merge branch 'develop' into Improved-duct-model
Browse files Browse the repository at this point in the history
  • Loading branch information
lgu1234 committed Jan 11, 2024
2 parents 13a25c9 + 0c0cdaa commit 276d93d
Show file tree
Hide file tree
Showing 7 changed files with 204 additions and 102 deletions.
11 changes: 8 additions & 3 deletions src/EnergyPlus/OutputReportTabular.cc
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,10 @@ void GetInputTabularMonthly(EnergyPlusData &state)
int const curTable = AddMonthlyReport(state, AlphArray(1), int(NumArray(1)));
for (int jField = 2; jField <= NumAlphas; jField += 2) {
if (AlphArray(jField).empty()) {
ShowFatalError(state, "Blank report name in Output:Table:Monthly");
ShowWarningError(state,
format("{}: Blank column specified in '{}', need to provide a variable or meter name ",
CurrentModuleObject,
ort->MonthlyInput(TabNum).name));
}
std::string const curAggString = AlphArray(jField + 1);
AggType curAggType; // kind of aggregation identified (see AggType parameters)
Expand Down Expand Up @@ -402,7 +405,9 @@ void GetInputTabularMonthly(EnergyPlusData &state)
ShowWarningError(state, format("{}={}, Variable name={}", CurrentModuleObject, ort->MonthlyInput(TabNum).name, AlphArray(jField)));
ShowContinueError(state, format("Invalid aggregation type=\"{}\" Defaulting to SumOrAverage.", curAggString));
}
AddMonthlyFieldSetInput(state, curTable, AlphArray(jField), "", curAggType);
if (!AlphArray(jField).empty()) {
AddMonthlyFieldSetInput(state, curTable, AlphArray(jField), "", curAggType);
}
}
}
}
Expand Down Expand Up @@ -1492,7 +1497,7 @@ void GetInputOutputTableSummaryReports(EnergyPlusData &state)
for (int iReport = 1; iReport <= NumAlphas; ++iReport) {
bool nameFound = false;
if (AlphArray(iReport).empty()) {
ShowFatalError(state, "Blank report name in Output:Table:SummaryReports");
ShowWarningError(state, "Blank report name in Output:Table:SummaryReports");
} else if (Util::SameString(AlphArray(iReport), "AnnualBuildingUtilityPerformanceSummary")) {
ort->displayTabularBEPS = true;
ort->WriteTabularFiles = true;
Expand Down
13 changes: 10 additions & 3 deletions src/EnergyPlus/OutputReportTabularAnnual.cc
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,10 @@ void GetInputTabularAnnual(EnergyPlusData &state)
for (jAlpha = 4; jAlpha <= numAlphas; jAlpha += 2) {
curVarMtr = alphArray(jAlpha);
if (curVarMtr.empty()) {
ShowFatalError(state, "Blank report name in Output:Table:Annual");
ShowWarningError(state,
format("{}: Blank column specified in '{}', need to provide a variable or meter or EMS variable name ",
currentModuleObject,
alphArray(1)));
}
if (jAlpha <= numAlphas) {
std::string aggregationString = alphArray(jAlpha + 1);
Expand All @@ -144,7 +147,9 @@ void GetInputTabularAnnual(EnergyPlusData &state)
} else {
curNumDgts = 2;
}
annualTables.back().addFieldSet(curVarMtr, curAgg, curNumDgts);
if (!curVarMtr.empty()) {
annualTables.back().addFieldSet(curVarMtr, curAgg, curNumDgts);
}
}
annualTables.back().setupGathering(state);
} else {
Expand Down Expand Up @@ -1353,7 +1358,9 @@ std::vector<Real64> AnnualTable::calculateBins(int const numberOfBins,
} else {
// determine which bin the results are in
binNum = int((*valueIt - bottomOfBins) / intervalSize);
returnBins[binNum] += *elapsedTimeIt;
if (binNum < numberOfBins && binNum >= 0) {
returnBins[binNum] += *elapsedTimeIt;
}
}
++elapsedTimeIt;
}
Expand Down
156 changes: 69 additions & 87 deletions src/EnergyPlus/ZoneTempPredictorCorrector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5025,114 +5025,96 @@ void DownInterpolate4HistoryValues(Real64 const OldTimeStep,
// The down step ratio, DSRatio = OldTimeStep/ NewTimeStep
// is expected to be roughly integer-valued and near 2.0 or 3.0 or 4.0 or more.

// first construct data on timestamps for interpolating with later
Real64 const oldTime0 = 0.0;
Real64 const oldTime1 = oldTime0 - OldTimeStep;

Real64 const newTime0 = 0.0;
Real64 const newTime1 = newTime0 - NewTimeStep;
Real64 const newTime2 = newTime1 - NewTimeStep;
Real64 const newTime3 = newTime2 - NewTimeStep;
Real64 const newTime4 = newTime3 - NewTimeStep;

// old math variables
// Real64 const oldTime0 = 0.0;
// Real64 const oldTime1 = oldTime0 - OldTimeStep;
// Real64 const newTime0 = 0.0;
// Real64 const newTime1 = newTime0 - NewTimeStep;
// Real64 const newTime2 = newTime1 - NewTimeStep;
// Real64 const newTime3 = newTime2 - NewTimeStep;
// Real64 const newTime4 = newTime3 - NewTimeStep;

Real64 constexpr realTWO = 2.0;
Real64 constexpr realTHREE = 3.0;
// first determine the ratio of system time step to zone time step
Real64 const DSRatio = OldTimeStep / NewTimeStep; // should pretty much be an integer value 2, 3, 4, etc.

newVal0 = oldVal0;

if (std::abs(DSRatio - 2.0) < 0.01) { // DSRatio = 2
if (std::abs(DSRatio - realTWO) < 0.01) { // DSRatio = 2
// when DSRatio = 2 the 1st point lies exactly between old points, and 2nd point is old 1st point
// first two points lie between oldVal0 and oldVal1
newVal1 = oldVal0 + (oldVal1 - oldVal0) * ((oldTime0 - newTime1) / (OldTimeStep));
newVal2 = oldVal0 + (oldVal1 - oldVal0) * ((oldTime0 - newTime2) / (OldTimeStep));
// old math example
// newVal1 = oldVal0 + (oldVal1 - oldVal0) * ((oldTime0 - newTime1) / (OldTimeStep));
// newVal2 = oldVal0 + (oldVal1 - oldVal0) * ((oldTime0 - newTime2) / (OldTimeStep));
newVal1 = (oldVal0 + oldVal1) / realTWO;
newVal2 = oldVal1;
// when DSRatio = 2 the 3rd point lies exactly between old points, and 4th point is old 2nd point
// last two points lie between oldVal1 and oldVal2
newVal3 = oldVal1 + (oldVal2 - oldVal1) * ((oldTime1 - newTime3) / (OldTimeStep));
newVal4 = oldVal1 + (oldVal2 - oldVal1) * ((oldTime1 - newTime4) / (OldTimeStep));
} else if (std::abs(DSRatio - 3.0) < 0.01) { // DSRatio = 3
// newVal3 = oldVal1 + (oldVal2 - oldVal1) * ((oldTime1 - newTime3) / (OldTimeStep));
// newVal4 = oldVal1 + (oldVal2 - oldVal1) * ((oldTime1 - newTime4) / (OldTimeStep));
newVal3 = (oldVal1 + oldVal2) / realTWO;
newVal4 = oldVal2;
} else if (std::abs(DSRatio - realTHREE) < 0.01) { // DSRatio = 3
// when DSRatio = 3 the 1st point lies 1/3 way between old points, and 2nd and 3rd points are 2/3 and 3/3 the way
// first three points lie between oldVal0 and oldVal1
newVal1 = oldVal0 + (oldVal1 - oldVal0) * ((oldTime0 - newTime1) / (OldTimeStep));
newVal2 = oldVal0 + (oldVal1 - oldVal0) * ((oldTime0 - newTime2) / (OldTimeStep));
newVal3 = oldVal0 + (oldVal1 - oldVal0) * ((oldTime0 - newTime3) / (OldTimeStep));
// last point lie between oldVal1 and oldVal2
newVal4 = oldVal1 + (oldVal2 - oldVal1) * ((oldTime1 - newTime4) / (OldTimeStep));
// newVal1 = oldVal0 + (oldVal1 - oldVal0) * ((oldTime0 - newTime1) / (OldTimeStep));
// newVal2 = oldVal0 + (oldVal1 - oldVal0) * ((oldTime0 - newTime2) / (OldTimeStep));
// newVal3 = oldVal0 + (oldVal1 - oldVal0) * ((oldTime0 - newTime3) / (OldTimeStep));
Real64 delta10 = (oldVal1 - oldVal0) / realTHREE;
newVal1 = oldVal0 + delta10;
newVal2 = newVal1 + delta10;
newVal3 = oldVal1;
// last point lies 1/3 way between oldVal1 and oldVal2
// newVal4 = oldVal1 + (oldVal2 - oldVal1) * ((oldTime1 - newTime4) / (OldTimeStep));
newVal4 = oldVal1 + (oldVal2 - oldVal1) / realTHREE;

} else { // DSRatio = 4 or more
// all new points lie between oldVal0 and oldVal1
newVal1 = oldVal0 + (oldVal1 - oldVal0) * ((oldTime0 - newTime1) / (OldTimeStep));
newVal2 = oldVal0 + (oldVal1 - oldVal0) * ((oldTime0 - newTime2) / (OldTimeStep));
newVal3 = oldVal0 + (oldVal1 - oldVal0) * ((oldTime0 - newTime3) / (OldTimeStep));
newVal4 = oldVal0 + (oldVal1 - oldVal0) * ((oldTime0 - newTime4) / (OldTimeStep));
// all new points lie between oldVal0 and oldVal1 (if DSRatio = 4, newVal4 = oldVal1)
// newVal1 = oldVal0 + (oldVal1 - oldVal0) * ((oldTime0 - newTime1) / (OldTimeStep));
// newVal2 = oldVal0 + (oldVal1 - oldVal0) * ((oldTime0 - newTime2) / (OldTimeStep));
// newVal3 = oldVal0 + (oldVal1 - oldVal0) * ((oldTime0 - newTime3) / (OldTimeStep));
// newVal4 = oldVal0 + (oldVal1 - oldVal0) * ((oldTime0 - newTime4) / (OldTimeStep));
Real64 delta10 = (oldVal1 - oldVal0) / DSRatio;
newVal1 = oldVal0 + delta10;
newVal2 = newVal1 + delta10;
newVal3 = newVal2 + delta10;
newVal4 = newVal3 + delta10;
}
}

Real64 DownInterpolate4HistoryValues(Real64 OldTimeStep, Real64 NewTimeStep, std::array<Real64, 4> const &oldVals, std::array<Real64, 4> &newVals)
{
// first construct data on timestamps for interpolating with later
Real64 const oldTime0 = 0.0;
Real64 const oldTime1 = oldTime0 - OldTimeStep;
Real64 constexpr realTWO = 2.0;
Real64 constexpr realTHREE = 3.0;
// first determine the ratio of system time step to zone time step
Real64 const DSRatio = OldTimeStep / NewTimeStep; // should pretty much be an integer value 2, 3, 4, etc.

Real64 const newTime0 = 0.0;
Real64 const newTime1 = newTime0 - NewTimeStep;
Real64 const newTime2 = newTime1 - NewTimeStep;
Real64 const newTime3 = newTime2 - NewTimeStep;
Real64 const newTime4 = newTime3 - NewTimeStep;
newVals[0] = oldVals[0];

Real64 const DSRatio = OldTimeStep / NewTimeStep; // should pretty much be an integer value 2, 3, 4, etc.
if (std::abs(DSRatio - realTWO) < 0.01) { // DSRatio = 2
// first point lies exactly between (oldVals[0] and oldVals[1])
newVals[1] = (oldVals[0] + oldVals[1]) / realTWO;
// 2nd point is oldVal[1] and last point lies exactly between (oldVals[1] and oldVals[2])
newVals[2] = oldVals[1];
newVals[3] = (oldVals[1] + oldVals[2]) / realTWO;

if (std::abs(DSRatio - 2.0) < 0.01) { // DSRatio = 2
// first two points lie between oldVals[0] and oldVals[1]
Real64 delta10 = oldVals[1] - oldVals[0];
newVals[0] = oldVals[0] + delta10 * ((oldTime0 - newTime1) / OldTimeStep);
newVals[1] = oldVals[0] + delta10 * ((oldTime0 - newTime2) / OldTimeStep);
// last two points lie between oldVals[1] and oldVals[2]
Real64 delta21 = oldVals[2] - oldVals[1];
newVals[2] = oldVals[1] + delta21 * ((oldTime1 - newTime3) / OldTimeStep);
newVals[3] = oldVals[1] + delta21 * ((oldTime1 - newTime4) / OldTimeStep);
} else if (std::abs(DSRatio - 3.0) < 0.01) { // DSRatio = 3
// first three points lie between oldVals[0] and oldVals[1]
Real64 delta10 = oldVals[1] - oldVals[0];
newVals[0] = oldVals[0] + delta10 * ((oldTime0 - newTime1) / OldTimeStep);
newVals[1] = oldVals[0] + delta10 * ((oldTime0 - newTime2) / OldTimeStep);
newVals[2] = oldVals[0] + delta10 * ((oldTime0 - newTime3) / OldTimeStep);
// last point lie between oldVals[1] and oldVals[2]
Real64 delta21 = (oldVals[2] - oldVals[1]) / OldTimeStep;
newVals[3] = oldVals[1] + delta21 * ((oldTime1 - newTime4) / OldTimeStep);
} else if (std::abs(DSRatio - realTHREE) < 0.01) { // DSRatio = 3
// first two points lie between (oldVals[0] and oldVals[1])
Real64 delta10 = (oldVals[1] - oldVals[0]) / realTHREE;
newVals[1] = oldVals[0] + delta10;
newVals[2] = newVals[1] + delta10;
// last point is oldVals[1]
newVals[3] = oldVals[1];

} else { // DSRatio = 4 or more
// all new points lie between oldVals[0] and oldVals[1]
Real64 delta10 = oldVals[1] - oldVals[0];
newVals[0] = oldVals[0] + delta10 * ((oldTime0 - newTime1) / OldTimeStep);
newVals[1] = oldVals[0] + delta10 * ((oldTime0 - newTime2) / OldTimeStep);
newVals[2] = oldVals[0] + delta10 * ((oldTime0 - newTime3) / OldTimeStep);
newVals[3] = oldVals[0] + delta10 * ((oldTime0 - newTime4) / OldTimeStep);
// all new points lie between (oldVals[0] and oldVals[1])
Real64 delta10 = (oldVals[1] - oldVals[0]) / DSRatio;
newVals[1] = oldVals[0] + delta10;
newVals[2] = newVals[1] + delta10;
newVals[3] = newVals[2] + delta10;
}
return oldVals[0];

// if (std::abs(DSRatio - 2.0) < 0.01) { // DSRatio = 2
// // first two points lie between oldVals[0] and oldVals[1]
// Real64 ratio10 = (oldVals[1] - oldVals[0]) / OldTimeStep;
// newVals[0] = oldVals[0] + ratio10 * (oldTime0 - newTime1);
// newVals[1] = oldVals[0] + ratio10 * (oldTime0 - newTime2);
// // last two points lie between oldVals[1] and oldVals[2]
// Real64 ratio21 = (oldVals[2] - oldVals[1]) / OldTimeStep;
// newVals[2] = oldVals[1] + ratio21 * (oldTime1 - newTime3);
// newVals[3] = oldVals[1] + ratio21 * (oldTime1 - newTime4);
// } else if (std::abs(DSRatio - 3.0) < 0.01) { // DSRatio = 3
// // first three points lie between oldVals[0] and oldVals[1]
// Real64 ratio10 = (oldVals[1] - oldVals[0]) / OldTimeStep;
// newVals[0] = oldVals[0] + ratio10 * (oldTime0 - newTime1);
// newVals[1] = oldVals[0] + ratio10 * (oldTime0 - newTime2);
// newVals[2] = oldVals[0] + ratio10 * (oldTime0 - newTime3);
// // last point lie between oldVals[1] and oldVals[2]
// Real64 ratio21 = (oldVals[2] - oldVals[1]) / OldTimeStep;
// newVals[3] = oldVals[1] + ratio21 * (oldTime1 - newTime4);

//} else { // DSRatio = 4 or more
// // all new points lie between oldVals[0] and oldVals[1]
// Real64 ratio10 = (oldVals[1] - oldVals[0]) / OldTimeStep;
// newVals[0] = oldVals[0] + ratio10 * (oldTime0 - newTime1);
// newVals[1] = oldVals[0] + ratio10 * (oldTime0 - newTime2);
// newVals[2] = oldVals[0] + ratio10 * (oldTime0 - newTime3);
// newVals[3] = oldVals[0] + ratio10 * (oldTime0 - newTime4);
//}
}
void InverseModelTemperature(EnergyPlusData &state,
int const ZoneNum, // Zone number
Expand Down
58 changes: 58 additions & 0 deletions tst/EnergyPlus/unit/OutputReportTabular.unit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12772,6 +12772,64 @@ TEST_F(EnergyPlusFixture, OutputReportTabularMonthly_WarnMonthlyDisplayExtraWarn
compare_err_stream(expected_error);
}

TEST_F(EnergyPlusFixture, OutputReportTabularMonthly_WarnMonthlyBlankVariable)
{
// #6919 - Warn instead of fatal on blank monthly table
std::string const idf_objects = delimited_string({
"Output:Table:Monthly,",
" Space Gains Annual Report, !- Name",
" 2, !- Digits After Decimal",
" , !- Variable or Meter 1 Name",
" SumOrAverage; !- Aggregation Type for Variable or Meter 1",

"Output:Table:SummaryReports,",
" AllSummaryAndMonthly; !- Report 1 Name",
});

ASSERT_TRUE(process_idf(idf_objects));

Real64 extLitUse;

SetupOutputVariable(*state,
"Exterior Lights Electricity Energy",
Constant::Units::J,
extLitUse,
OutputProcessor::SOVTimeStepType::Zone,
OutputProcessor::SOVStoreType::Summed,
"Lite1",
Constant::eResource::Electricity,
OutputProcessor::SOVEndUseCat::ExteriorLights,
"General");

SetupOutputVariable(*state,
"Exterior Lights Electricity Energy",
Constant::Units::J,
extLitUse,
OutputProcessor::SOVTimeStepType::Zone,
OutputProcessor::SOVStoreType::Summed,
"Lite2",
Constant::eResource::Electricity,
OutputProcessor::SOVEndUseCat::ExteriorLights,
"General");

state->dataGlobal->DoWeathSim = true;
state->dataGlobal->KindOfSim = Constant::KindOfSim::RunPeriodWeather; // Trigger the extra warning
state->dataGlobal->TimeStepZone = 0.25;
state->dataGlobal->TimeStepZoneSec = state->dataGlobal->TimeStepZone * 60.0;
state->dataGlobal->DisplayExtraWarnings = true;

GetInputTabularMonthly(*state);
EXPECT_EQ(state->dataOutRptTab->MonthlyInputCount, 1);
GetInputOutputTableSummaryReports(*state);
EXPECT_EQ(state->dataOutRptTab->MonthlyInputCount, numNamedMonthly + 1);

InitializeTabularMonthly(*state);

std::string const expected_error = delimited_string(
{" ** Warning ** Output:Table:Monthly: Blank column specified in 'SPACE GAINS ANNUAL REPORT', need to provide a variable or meter name "});
compare_err_stream(expected_error);
}

TEST_F(EnergyPlusFixture, OutputReportTabularMonthly_NoWarnMonthlIfNoWeatherFileRun)
{
// #9621 - Only warn if a bad variable is defined in a Monthly table user requested, not on the AllSummaryAndMonthly ones
Expand Down
37 changes: 37 additions & 0 deletions tst/EnergyPlus/unit/OutputReportTabularAnnual.unit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -566,3 +566,40 @@ TEST_F(SQLiteFixture, OutputReportTabularAnnual_CurlyBraces)
EXPECT_TRUE(false) << "Missing braces in monthly table for : " << colHeader;
}
}

TEST_F(EnergyPlusFixture, OutputReportTabularAnnual_WarnBlankVariable)
{
std::string const idf_objects = delimited_string({
"Output:Table:Annual,",
"Space Gains Annual Report, !- Name",
"Filter1, !- Filter",
"Schedule2, !- Schedule Name",
"Zone People Total Heating Energy, !- Variable or Meter 1 Name",
"SumOrAverage, !- Aggregation Type for Variable or Meter 1",
"4, !- field Digits After Decimal 1",
", !- Variable or Meter 2 Name",
"hoursNonZero, !- Aggregation Type for Variable or Meter 2",
", !- field Digits After Decimal 2",
"Zone Electric Equipment Total Heating Energy; !- Variable or Meter 3 Name",
});

ASSERT_TRUE(process_idf(idf_objects));

state->dataGlobal->DoWeathSim = true;

EXPECT_FALSE(state->dataOutRptTab->WriteTabularFiles);
GetInputTabularAnnual(*state);
EXPECT_TRUE(state->dataOutRptTab->WriteTabularFiles);

EXPECT_EQ(state->dataOutputReportTabularAnnual->annualTables.size(), 1u);

std::vector<AnnualTable>::iterator firstTable = state->dataOutputReportTabularAnnual->annualTables.begin();

std::vector<std::string> tableParams = firstTable->inspectTable();

std::string const expected_error = delimited_string({" ** Warning ** Output:Table:Annual: Blank column specified in 'SPACE GAINS ANNUAL "
"REPORT', need to provide a variable or meter or EMS variable name ",
" ** Warning ** Invalid aggregation type=\"\" Defaulting to SumOrAverage."});

compare_err_stream(expected_error);
}
Loading

6 comments on commit 276d93d

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

Improved-duct-model (lgu1234) - x86_64-MacOS-10.17-clang-14.0.0: OK (3545 of 3545 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.

Improved-duct-model (lgu1234) - Win64-Windows-10-VisualStudio-16: OK (2758 of 2758 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.

Improved-duct-model (lgu1234) - x86_64-Linux-Ubuntu-22.04-gcc-11.4: OK (3586 of 3586 tests passed, 0 test warnings)

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.

Improved-duct-model (lgu1234) - x86_64-Linux-Ubuntu-22.04-gcc-11.4-UnitTestsCoverage-Debug: OK (1971 of 1971 tests passed, 0 test warnings)

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

Improved-duct-model (lgu1234) - 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-3
Copy link

Choose a reason for hiding this comment

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

Improved-duct-model (lgu1234) - x86_64-MacOS-10.18-clang-15.0.0: OK (3544 of 3545 tests passed, 0 test warnings)

Build Badge Test Badge

Please sign in to comment.