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

PV Zone Multiplier Fix #6283

Merged
merged 3 commits into from
Sep 5, 2017
Merged

Conversation

RKStrand
Copy link
Contributor

Pull request overview

This work addresses GitHub Issue #6222 which showed that the zone multiplier was not being applied to the PV arrays. This fixes the problem so that the zone multiplier is applied properly when PV surfaces are part of a zone.

Work Checklist

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

  • [ x ] Title of PR should be user-synopsis style (clearly understandable in a standalone changelog context)
  • [ x ] At least one of the following appropriate labels must be added to this PR to be consumed into the changelog:

Review Checklist

This will not be exhaustively relevant to every PR.

  • Code style (parentheses padding, variable names)
  • 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 -- verify this
  • Unit Test(s)
  • C++ checks:
    • Argument types
    • If any virtual classes, ensure virtual destructor included, other things
  • IDD changes:
    • Verify naming conventions and styles, memos and notes and defaults
    • Open windows IDF Editor with modified IDD to check for errors
    • If transition, add rules to spreadsheet
    • If transition, add transition source
    • If transition, update idfs
  • If new idf included, locally check the err file and other outputs
  • Documentation changes in place
  • Changed docs build successfully
  • ExpandObjects changes?
  • If output changes, including tabular output structure, add to output rules file for interfaces

PV systems were not picking up the zone multiplier.  This now fixes the
problem.  The defect input file that uses the zone multiplier is now in
line with the file that has all of the zones defined.  Unit tests for
the fix are also included.
@RKStrand RKStrand self-assigned this Aug 31, 2017
@RKStrand RKStrand requested a review from Myoldmopar August 31, 2017 17:13
@RKStrand
Copy link
Contributor Author

@Myoldmopar @lgentile Here is the pull request for this. Results between the two input files noted in the GitHub Issue (#6222) now should identical results in the electric load center output. I know this was a priority issue for OpenStudio, so I'm over notifying that this is ready to go to make sure it is not lost in all of the other things going on in the code right now. I suggested Edwin as a reviewer, but that is just a suggestion. Thanks!

@lgentile
Copy link
Contributor

Thank you @RKStrand ! This will help us move forward with our other OS-based project.

@mjwitte mjwitte modified the milestone: EnergyPlus 8.8.0 Sep 1, 2017

// SUBROUTINE LOCAL VARIABLE DECLARATIONS:
int thisZone; // working index for zones
int thisSurface; // index for PV surface
Array1D< bool > PVarrayZoneInitialized; // avoid doing the zone check too often
Copy link
Member

Choose a reason for hiding this comment

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

Does this really persist through multiple calls into this function? It looks like it's just a non-static local variable, so it will be cleaned back up each time this function is called. And the FirstTimeThru variable is similar, it will just be true each time the function gets called again, right?

Here's what I'd like to propose. Instead of adding your own new array here and first time flag, just add a single bool to the main PV array called bool zoneInitialized;. Then you can let it do the allocations, you don't need an allocated flag, you don't need static variables, and you will actually have fewer code changes to accomplish this same task.

If we kept it the way it currently is, you'd need to make the local variables static first, and then because they are static you'd need to clean them up in the clear_state function of this module. (And if it doesn't have a clear_state you'd need to write one of your own and add it to the EnergyPlusFixture unit test class....) In summary, avoid statics when possible! 😃

Let me know if you have any issues with this. The actual code fix here is great and I appreciate you getting it done so quickly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Myoldmopar I don't think that should be a problem. I will work on that as soon as I can. I was thinking keeping it local would be better, but if what you have proposed is better, I'm all for that. Thanks for the review and suggestion. And glad that I could help on this!


if ( ! PVarrayZoneInitialized( PVnum ) ) {
if ( Surface( thisSurface ).Zone == 0 ) { // might need to get the zone number from the name
Surface( thisSurface ).Zone = FindItemInList( Surface( thisSurface ).ZoneName, Zone, NumOfZones );
Copy link
Contributor

Choose a reason for hiding this comment

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

Why isn't this done in GetInput?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rraustad Good point. I will change this so that it gets the Zone index directly during GetInput and store it in the local PV data structure. That should then address what you and Edwin pointed out and still fix the issue. Thanks!

This commit addresses the review comments.  No more static variables
and the zone pointer is gotten during the Get phase in a new function
call.  Unit tests were also updated to reflect the revised code.
@RKStrand
Copy link
Contributor Author

RKStrand commented Sep 4, 2017

@Myoldmopar @rraustad Ok--I have changed the code to reflect both of your comments. The zone number is now kept in the PV array data structure and it is filled during the GetInput phase rather than during report. The whole thing is a lot cleaner now--thanks for your comments! Please let me know if there are any other concerns. If there aren't any, feel free to accept, merge, etc. at will.

@Myoldmopar
Copy link
Member

Thanks @RKStrand, I'm pulling and building locally real quick to verify and then I'll merge it in.

@Myoldmopar
Copy link
Member

Bazinga. Works a champ. Thanks @RKStrand.

@lgentile @rpg777 I'm merging this fix in now. Let me know if you want a build of it right away and I'll help do that, otherwise it'll be available in 8.8 in a few weeks.

@Myoldmopar Myoldmopar merged commit 3ef1eaf into develop Sep 5, 2017
@Myoldmopar Myoldmopar deleted the 149930772-SurfacePVZoneMultiplierProblem branch September 5, 2017 13:48
@Myoldmopar Myoldmopar added the Defect Includes code to repair a defect in EnergyPlus label Sep 6, 2017
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.

8 participants