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 Leap Year Flag Issue #7199

Merged
merged 3 commits into from
Mar 12, 2019
Merged

Fix Leap Year Flag Issue #7199

merged 3 commits into from
Mar 12, 2019

Conversation

jasondegraw
Copy link
Member

@jasondegraw jasondegraw commented Mar 4, 2019

Pull request overview

As described in #7173, the leap year flag in the weather file was overriding inputs in certain circumstances. The culprit was a bad bit of logic in WeatherManager introduced in the year awareness work.

Work Checklist

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)
  • At least one of the following appropriate labels must be added to this PR to be consumed into the changelog:
    • Defect: This pull request repairs a github defect issue. The github issue should be referenced in the PR description
    • Refactoring: This pull request includes code changes that don't change the functionality of the program, just perform refactoring
    • NewFeature: This pull request includes code to add a new feature to EnergyPlus
    • Performance: This pull request includes code changes that are directed at improving the runtime performance of EnergyPlus
    • DoNoPublish: This pull request includes changes that shouldn't be included in the changelog

Review Checklist

This will not be exhaustively relevant to every PR.

  • Functional code review (it has to work!)
  • If defect, results of running current develop vs this branch should exhibit the fix
  • CI status: all green or justified
  • Performance: CI Linux results include performance check
  • Unit Test(s)
  • C++ checks:
    • Argument types
    • If any virtual classes, ensure virtual destructor included, other things

@jasondegraw jasondegraw added the Defect Includes code to repair a defect in EnergyPlus label Mar 4, 2019
@jasondegraw jasondegraw added this to the EnergyPlus 9.1.0 milestone Mar 4, 2019
@jasondegraw
Copy link
Member Author

Fixes #7173. Let me know if you'd like me to undo the clang-format changes.

@jasondegraw jasondegraw requested a review from mjwitte March 4, 2019 23:49
Copy link
Member

@Myoldmopar Myoldmopar left a comment

Choose a reason for hiding this comment

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

Pulled latest develop and built locally. Ran the new unit test and it passes and tests exactly what this fixes. This is a nice compact fix and test. Thanks @jasondegraw. It should merge shortly, I just want to go back and make sure there weren't other comments on it.

LocalLeapYearAdd = 1;
} else {
env.IsLeapYear = false; // explicit set, this might be unwise
}
Copy link
Member

Choose a reason for hiding this comment

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

OK, so the weather file leap year support is only checked if the current year is actually a leap year. Makes sense.

Copy link
Member

Choose a reason for hiding this comment

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

@jasondegraw hey, should we have put a warning in here for if the runperiod is a leap year but the weather file doesn't support it? If so is this the right spot for it? We'll add it within a different branch if so. (Or you could add it to the namespace change branch on the next merge up)

Copy link
Member Author

Choose a reason for hiding this comment

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

@Myoldmopar I'm not sure it is the right spot to add a warning. It would be good to have a warning, but my preference would be to wait until weather handling gets refactored. If we put in an issue on the lack of warning it'll be easier on whoever does the refactor. If we add the warning now, it'll be one more thing that someone will have to find. Previous behavior was to be silent, so I think it'd be alright to leave it alone for a bit longer, but if you'd rather add the warning that's OK too.

Copy link
Member

Choose a reason for hiding this comment

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

Given how late in the game we are right now, I support the idea of doing nothing but opening up a ticket. Thanks @jasondegraw

"RP3, !- Name",
"1, !- Begin Month",
"1, !- Begin Day of Month",
"2019, !- Begin Year",
Copy link
Member

Choose a reason for hiding this comment

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

So this unit test should not be a leap year, but I'm guessing we'll set the weather file up as leap year capable.

WeatherManager::TotRunPers = 1;
WeatherManager::TotRunDesPers = 0;

WeatherManager::WFAllowsLeapYears = true; // This was hitting a bad bit of logic
Copy link
Member

Choose a reason for hiding this comment

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

So the run period should never even check the leap year capability of the weather file, meaning we won't have a chance to check this flag. OK.

WeatherManager::WFAllowsLeapYears = true; // This was hitting a bad bit of logic
WeatherManager::SetupEnvironmentTypes();

EXPECT_FALSE(WeatherManager::Environment[0].IsLeapYear);
Copy link
Member

Choose a reason for hiding this comment

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

Looks good to me!

@Myoldmopar
Copy link
Member

Even CI is happy. Merging.

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants