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

Fix #8317 - Warn in Output:Table:Monthly when invalid 'Variable or Meter Name' field #8348

Merged
merged 4 commits into from
Nov 7, 2020

Conversation

jmarrec
Copy link
Contributor

@jmarrec jmarrec commented Oct 19, 2020

Pull request overview

Using the defect file: https://github.com/NREL/EnergyPlusDevSupport/blob/1447601c30df8f07a5b4dd60864a5a36560c3fc9/DefectFiles/8000s/8317/1ZoneUncontrolled.idf#L453-L466

  Output:Table:Monthly,
    Building Loads - Cooling,!- Name
    2,                       !- Digits After Decimal
    Water Heater:WaterSystems:Gas,  !- Variable or Meter 1 Name       <============ This is wrong
    SumOrAverage,            !- Aggregation Type for Variable or Meter 1
    Zone Air System Sensible Cooling Rate,  !- Variable or Meter 2 Name
    Maximum,                 !- Aggregation Type for Variable or Meter 2
    Site Outdoor Air Drybulb Temperature,  !- Variable or Meter 3 Name
    ValueWhenMaximumOrMinimum;  !- Aggregation Type for Variable or Meter 3
(py38)julien@8317 (master *%>)$ diff -u out-ori/eplusout.err out-new/eplusout.err 

--- out-ori/eplusout.err	2020-10-19 11:30:00.923173743 +0200
+++ out-new/eplusout.err	2020-10-19 11:31:32.544227723 +0200
@@ -1,4 +1,4 @@
-Program Version,EnergyPlus, Version 9.4.0-998c4b761e, YMD=2020.10.19 11:30,
+Program Version,EnergyPlus, Version 9.4.0-6c1e5e5d73, YMD=2020.10.19 11:31,
    ** Warning ** Output:Meter: invalid Key Name="JUNKMETER:*" - not found.
    ** Warning ** Output:Meter: invalid Key Name="ELECTRICITY:JUNKRESOURCE" - not found.
    ************* Testing Individual Branch Integrity
@@ -9,6 +9,7 @@
    ************* All Return Air Paths passed integrity testing
    ************* No node connection errors were found.
    ************* Beginning Simulation
+   ** Warning ** In Output:Table:Monthly 'BUILDING LOADS - COOLING' invalid Variable or Meter Name 'WATER HEATER:WATERSYSTEMS:GAS'
    ************* Simulation Error Summary *************
    ** Warning ** The following Report Variables were requested but not generated -- check.rdd file
    **   ~~~   ** Either the IDF did not contain these elements, the variable name is misspelled,
@@ -16,4 +17,4 @@
    ************* Key=*, VarName=JUNK VARIABLE, Frequency=Monthly
    ************* EnergyPlus Warmup Error Summary. During Warmup: 0 Warning; 0 Severe Errors.
    ************* EnergyPlus Sizing Error Summary. During Sizing: 0 Warning; 0 Severe Errors.
-   ************* EnergyPlus Completed Successfully-- 3 Warning; 0 Severe Errors; Elapsed Time=00hr 00min  0.51sec
+   ************* EnergyPlus Completed Successfully-- 4 Warning; 0 Severe Errors; Elapsed Time=00hr 00min  6.16sec

Pull Request Author

Add to this list or remove from it as applicable. This is a simple templated set of guidelines.

  • Title of PR should be user-synopsis style (clearly understandable in a standalone changelog context)
  • Label the PR with at least one of: Defect, Refactoring, NewFeature, Performance, and/or DoNoPublish
  • Pull requests that impact EnergyPlus code must also include unit tests to cover enhancement or defect repair
  • Author should provide a "walkthrough" of relevant code changes using a GitHub code review comment process
  • If any diffs are expected, author must demonstrate they are justified using plots and descriptions
  • If changes fix a defect, the fix should be demonstrated in plots and descriptions
  • If any defect files are updated to a more recent version, upload new versions here or on DevSupport
  • If IDD requires transition, transition source, rules, ExpandObjects, and IDFs must be updated, and add IDDChange label
  • If structural output changes, add to output rules file and add OutputChange label
  • If adding/removing any LaTeX docs or figures, update that document's CMakeLists file dependencies

Reviewer

This will not be exhaustively relevant to every PR.

  • Perform a Code Review on GitHub
  • If branch is behind develop, merge develop and build locally to check for side effects of the merge
  • If defect, verify by running develop branch and reproducing defect, then running PR and reproducing fix
  • If feature, test running new feature, try creative ways to break it
  • CI status: all green or justified
  • Check that performance is not impacted (CI Linux results include performance check)
  • Run Unit Test(s) locally
  • Check any new function arguments for performance impacts
  • Verify IDF naming conventions and styles, memos and notes and defaults
  • If new idf included, locally check the err file and other outputs

@jmarrec jmarrec added Defect Includes code to repair a defect in EnergyPlus NotIDDChange Code does not impact IDD (can be merged after IO freeze) labels Oct 19, 2020
@jmarrec jmarrec self-assigned this Oct 19, 2020
Comment on lines +8362 to +8376
"Output:Table:Monthly,",
" My Report, !- Name",
" 2, !- Digits After Decimal",
" Heating:Gas, !- Variable or Meter 1 Name", // A bad meter name
" SumOrAverage, !- Aggregation Type for Variable or Meter 1",
" Exterior Lights Electric Power, !- Variable or Meter 2 Name", // A bad variable name
" Maximum, !- Aggregation Type for Variable or Meter 2",
" AlwaysOn, !- Variable or Meter 3 Name", // A bad name (eg: Schedule)
" Maximum, !- Aggregation Type for Variable or Meter 3",
" Exterior Lights Electricity Rate, !- Variable or Meter 4 Name", // A good variable name
" Minimum, !- Aggregation Type for Variable or Meter 4",
" OnSched, !- Variable or Meter 5 Name", // A good schedule name
" Minimum, !- Aggregation Type for Variable or Meter 5",
" Heating:NaturalGas, !- Variable or Meter 6 Name", // A good meter name
" SumOrAverage; !- Aggregation Type for Variable or Meter 6",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unit test, testing several possibilities

Comment on lines +8424 to +8433
OutputReportTabular::GetInputTabularMonthly(state);
OutputReportTabular::InitializeTabularMonthly(state);

std::string expected_error = delimited_string({
" ** Warning ** In Output:Table:Monthly 'MY REPORT' invalid Variable or Meter Name 'HEATING:GAS'",
" ** Warning ** In Output:Table:Monthly 'MY REPORT' invalid Variable or Meter Name 'EXTERIOR LIGHTS ELECTRIC POWER'",
" ** Warning ** In Output:Table:Monthly 'MY REPORT' invalid Variable or Meter Name 'ALWAYSON'",
});

compare_err_stream(expected_error);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Check that you do get the warnings as expected

Comment on lines +6822 to +6844
// Helper lambda to locate a meter index from its name. Returns a negative value if not found
auto findMeterIndexFromMeterName = [](std::string const &name) -> int {
// Return a value <= 0 if not found
int meterIndex = -99;

std::string::size_type wildCardPosition = index(name, '*');

if (wildCardPosition == std::string::npos) {
meterIndex = UtilityRoutines::FindItem(name, OutputProcessor::EnergyMeters);
} else { // Wildcard input
for (int Meter = 1; Meter <= OutputProcessor::NumEnergyMeters; ++Meter) {
if (UtilityRoutines::SameString(OutputProcessor::EnergyMeters(Meter).Name.substr(0, wildCardPosition),
name.substr(0, wildCardPosition)))
{
meterIndex = Meter;
break;
}
}
}

return meterIndex;
};

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I initially went for a solution were I was reusing this routine (among with checking if it was an output:variable or a Schedule) so I made it its own function and dried up the code below as well. I'm not using it, and it's not going to be used anywhere else, so I made it a lambda.

Comment on lines +6868 to +6873
int meterIndex = findMeterIndexFromMeterName(Alphas(1));
if (meterIndex > 0) {
// MeterFileOnlyIndicator is false, CumulativeIndicator is false
SetInitialMeterReportingAndOutputNames(state, meterIndex, false, ReportFreq, false);
} else {
ShowWarningError(cCurrentModuleObject + ": invalid " + cAlphaFieldNames(1) + "=\"" + Alphas(1) + "\" - not found.");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The use of the (lambda) function allows to dry up this code block and 3 others below (4 total)

Comment on lines +1151 to +1153
if (TypeVar == OutputProcessor::VarType_NotFound) {
ShowWarningError("In Output:Table:Monthly '" + MonthlyInput(TabNum).name + "' invalid Variable or Meter Name '" + curVariMeter + "'");
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the actual warning. After going the manual route, I noticed that GetVariableKeyCountandType was already returning all the information needed to be able to throw a warning, so might as well use it here.

Copy link
Contributor

@mjwitte mjwitte left a comment

Choose a reason for hiding this comment

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

@jmarrec This looks great. I've merged in develop for one last round of CI tests, then this will merge.

@mjwitte mjwitte merged commit 7495909 into develop Nov 7, 2020
@mjwitte mjwitte deleted the 8317_ValidateOutputTableMonthly branch November 7, 2020 15:21
jmarrec added a commit that referenced this pull request Sep 8, 2023
* Avoid printing two warnings when display extra warning (My fault, in #8348)
* Do not print individual variables if non display extra warning
* Reorganize when single line warning is issued to be more logical
* Reduce number of printed lines
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Defect Includes code to repair a defect in EnergyPlus NotIDDChange Code does not impact IDD (can be merged after IO freeze)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Output:Table:Monthly does not warn about invalid variable or meter name
7 participants