Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Rezero sizing arrays to correct DOAS loads in Loads Component Summary reports #7912

Merged
merged 1 commit into from
Apr 23, 2020

Conversation

rraustad
Copy link
Contributor

@rraustad rraustad commented Apr 7, 2020

Pull request overview

NOTE: ENHANCEMENTS MUST FOLLOW A SUBMISSION PROCESS INCLUDING A FEATURE PROPOSAL AND DESIGN DOCUMENT PRIOR TO SUBMITTING CODE

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

@rraustad rraustad added the Defect Includes code to repair a defect in EnergyPlus label Apr 7, 2020
@rraustad
Copy link
Contributor Author

rraustad commented Apr 7, 2020

@mjwitte, in the unit test you can now see which arrays are not zero'd when comparing results of sizing and pulse for zone component loads reporting. Of course some data should not be reset but it appears there are others that could be, although I suspect they are just written over on the next pass. Stopping here for some discussion.

@rraustad
Copy link
Contributor Author

rraustad commented Apr 8, 2020

These are the diffs I was expecting although I thought there would be more files showing diffs. Now to prove these answers are correct. I guess I could calculate the DOAS load at the peak cooling time and compare to what is reported.

@rraustad
Copy link
Contributor Author

rraustad commented Apr 8, 2020

Well this looks promising as a reason for diffs. I noticed that the difference was what looks like most of the time a factor of 2 smaller now for Calc DOAS Heat Addition Rate in the eio.

The DOAS load is calculated based on the air mass flow rate and air conditions at the time.

DOASSysOutputProvided = DOASMassFlowRate * DOASCpAir * (DOASSupplyTemp - Node(ZoneNode).Temp);

That information is held in a sizing array.

CalcZoneSizing(CurOverallSimDay, ControlledZoneNum).DOASHeatAdd = DOASSysOutputProvided;

And then that information is held in a sequence over the day which is summed. Note the +=.

CalcZoneSizing(CurOverallSimDay, CtrlZoneNum).DOASHeatAddSeq(TimeStepInDay) +=
    CalcZoneSizing(CurOverallSimDay, CtrlZoneNum).DOASHeatAdd * FracTimeStepZone;

DOASHeatAddSeq is one of the arrays that was added to RezeroZoneSizingArrays. Now if that variable had not been zero'd, then the answer would be twice of what it should be. Why, because the design days are simulated twice, once with the pulse and once without. And the same data would be summed twice.

@rraustad rraustad changed the title Rezero sizing arrays Rezero sizing arrays to correct DOAS loads in Loads Component Summary reports Apr 8, 2020
CalcZoneSizing(DesDayNum, CtrlZoneNum).DOASSupHumRatSeq(TimeStepIndex) = 0.0;
CalcZoneSizing(DesDayNum, CtrlZoneNum).DOASTotCoolLoadSeq(TimeStepIndex) = 0.0;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Identical block as above except this one is for CalcZoneSizing

Copy link
Member

Choose a reason for hiding this comment

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

So much repetition here. Are ZoneSizing and CalcZoneSizing the same struct? If so it would be nice to just put a method on that struct called zeroStuff() or something.

// in the header
struct Whatever {
    void zeroStuff();
    ...
}
// in the implementation
Whatever::zeroStuff() {
    for (TimeStepIndex = 1; TimeStepIndex <= NumOfTimeStepInDay; ++TimeStepIndex) {
        this->DOASSupMassFlowSeq(TimeStepIndex) = 0.0;
        DOASHeatLoadSeq(TimeStepIndex) = 0.0;
        ...
    }
}
// then this code would just reduce to:
if (allocated(ZoneSizing(DesDayNum, CtrlZoneNum).DOASSupMassFlowSeq)) {
    for (DesDayNum = 1; DesDayNum <= TotDesDays + TotRunDesPersDays; ++DesDayNum) {
        for (CtrlZoneNum = 1; CtrlZoneNum <= NumOfZones; ++CtrlZoneNum) {
            ZoneSizing(DesDayNum, CtrlZoneNum).zeroStuff();	                    
        }
    }
}
if (allocated(CalcZoneSizing(DesDayNum, CtrlZoneNum).DOASSupMassFlowSeq)) {
    for (DesDayNum = 1; DesDayNum <= TotDesDays + TotRunDesPersDays; ++DesDayNum) {
        for (CtrlZoneNum = 1; CtrlZoneNum <= NumOfZones; ++CtrlZoneNum) {
            CalcZoneSizing(DesDayNum, CtrlZoneNum).zeroStuff();	                    
        }
    }
}

Although it would be really nice to know ahead of time whether this function would be called with this array already allocated so we could confidently not check the one allocated variable.

Copy link
Member

Choose a reason for hiding this comment

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

But as for this current fix, it seems to make sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, all the zone sizing arrays are the same struct, struct ZoneSizingData. Wish I would have thought of that earlier, it would have been simple to do.

EXPECT_EQ(thisSizingType2.CoolOutTempSeq(TimeStepIndex), 0.0);
EXPECT_EQ(thisSizingType2.CoolZoneRetTempSeq(TimeStepIndex), 0.0);
EXPECT_EQ(thisSizingType2.CoolTstatTempSeq(TimeStepIndex), 0.0);
//EXPECT_EQ(thisSizingType2.DesCoolSetPtSeq(TimeStepIndex), 0.0);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These 2 are zero'd for ZoneSizing but not for CalcZoneSizing. I imagine the same data is written here twice and no real need to reset. But certainly could. Would this change the answer, not sure.

Copy link
Member

Choose a reason for hiding this comment

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

It would be good to make some little worker functions that initialize the sizing array structure to make these tests easier to digest.

@rraustad
Copy link
Contributor Author

rraustad commented Apr 8, 2020

I took the first diff file, 5ZoneAirCooledWithDOASAirloop.idf (Chicago, IL weather), and turned off the additional pulse simulation by deleting this object.

Output:Table:SummaryReports,
  AllSummary,              !- Report 1 Name
  ZoneComponentLoadSummary;!- Report 2 Name

This should give the same answer as the original example file. These results are consistent with CI results for this file.

Develop:

5ZoneAirCooledWithDOASAirloop:
! , Zone Name, Load Type, Calc DOAS Heat Addition Rate {W}
Zone Sizing Information, SPACE1-1, Cooling, -1341.12972
Zone Sizing Information, SPACE1-1, Heating, -1119.23112

5ZoneAirCooledWithDOASAirloop - no ZoneComponentLoadSummary:
! , Zone Name, Load Type, Calc DOAS Heat Addition Rate {W}
Zone Sizing Information, SPACE1-1, Cooling, -670.52750
Zone Sizing Information, SPACE1-1, Heating, -559.61556

This branch:

5ZoneAirCooledWithDOASAirloop:
! , Zone Name, Load Type, Calc DOAS Heat Addition Rate {W}
Zone Sizing Information, SPACE1-1, Cooling, -670.52750
Zone Sizing Information, SPACE1-1, Heating, -559.61556

5ZoneAirCooledWithDOASAirloop - no ZoneComponentLoadSummary:
! , Zone Name, Load Type, Calc DOAS Heat Addition Rate {W}
Zone Sizing Information, SPACE1-1, Cooling, -670.52750
Zone Sizing Information, SPACE1-1, Heating, -559.61556

@rraustad
Copy link
Contributor Author

rraustad commented Apr 8, 2020

These are the only CalcZoneSizing struct member arrays that are summed during the day (using +=). I found 22 of them in ZoneEquipmentManager and checked each of these and all are now reset in RezeroZoneSizingArrays. There are others that are reset but those will get set "=" to something during the next pass and don't explicitly need to be reset (i.e., The RezeroZoneSizingArrays function could be cleaned up). For now, things seems to be working as expected.

} else if (SELECT_CASE_var == DuringDay) {

CalcZoneSizing(CurOverallSimDay, CtrlZoneNum).HeatFlowSeq(TimeStepInDay) +=        1
    CalcZoneSizing(CurOverallSimDay, CtrlZoneNum).HeatMassFlow * FracTimeStepZone;
CalcZoneSizing(CurOverallSimDay, CtrlZoneNum).HeatLoadSeq(TimeStepInDay) +=        2
    CalcZoneSizing(CurOverallSimDay, CtrlZoneNum).HeatLoad * FracTimeStepZone;
CalcZoneSizing(CurOverallSimDay, CtrlZoneNum).HeatZoneTempSeq(TimeStepInDay) +=    3
    CalcZoneSizing(CurOverallSimDay, CtrlZoneNum).HeatZoneTemp * FracTimeStepZone;
CalcZoneSizing(CurOverallSimDay, CtrlZoneNum).HeatOutTempSeq(TimeStepInDay) +=     4
    CalcZoneSizing(CurOverallSimDay, CtrlZoneNum).HeatOutTemp * FracTimeStepZone;
CalcZoneSizing(CurOverallSimDay, CtrlZoneNum).HeatZoneRetTempSeq(TimeStepInDay) += 5
    CalcZoneSizing(CurOverallSimDay, CtrlZoneNum).HeatZoneRetTemp * FracTimeStepZone;
CalcZoneSizing(CurOverallSimDay, CtrlZoneNum).HeatZoneHumRatSeq(TimeStepInDay) +=  6
    CalcZoneSizing(CurOverallSimDay, CtrlZoneNum).HeatZoneHumRat * FracTimeStepZone;
CalcZoneSizing(CurOverallSimDay, CtrlZoneNum).HeatOutHumRatSeq(TimeStepInDay) +=   7
    CalcZoneSizing(CurOverallSimDay, CtrlZoneNum).HeatOutHumRat * FracTimeStepZone;
CalcZoneSizing(CurOverallSimDay, CtrlZoneNum).CoolFlowSeq(TimeStepInDay) +=        8
    CalcZoneSizing(CurOverallSimDay, CtrlZoneNum).CoolMassFlow * FracTimeStepZone;
CalcZoneSizing(CurOverallSimDay, CtrlZoneNum).CoolLoadSeq(TimeStepInDay) +=        9
    CalcZoneSizing(CurOverallSimDay, CtrlZoneNum).CoolLoad * FracTimeStepZone;
CalcZoneSizing(CurOverallSimDay, CtrlZoneNum).CoolZoneTempSeq(TimeStepInDay) +=    10
    CalcZoneSizing(CurOverallSimDay, CtrlZoneNum).CoolZoneTemp * FracTimeStepZone;
CalcZoneSizing(CurOverallSimDay, CtrlZoneNum).CoolOutTempSeq(TimeStepInDay) +=     11
    CalcZoneSizing(CurOverallSimDay, CtrlZoneNum).CoolOutTemp * FracTimeStepZone;
CalcZoneSizing(CurOverallSimDay, CtrlZoneNum).CoolZoneRetTempSeq(TimeStepInDay) += 12
    CalcZoneSizing(CurOverallSimDay, CtrlZoneNum).CoolZoneRetTemp * FracTimeStepZone;
CalcZoneSizing(CurOverallSimDay, CtrlZoneNum).CoolZoneHumRatSeq(TimeStepInDay) +=  13
    CalcZoneSizing(CurOverallSimDay, CtrlZoneNum).CoolZoneHumRat * FracTimeStepZone;
CalcZoneSizing(CurOverallSimDay, CtrlZoneNum).CoolOutHumRatSeq(TimeStepInDay) +=   14
    CalcZoneSizing(CurOverallSimDay, CtrlZoneNum).CoolOutHumRat * FracTimeStepZone;
CalcZoneSizing(CurOverallSimDay, CtrlZoneNum).DOASHeatLoadSeq(TimeStepInDay) +=    15
    CalcZoneSizing(CurOverallSimDay, CtrlZoneNum).DOASHeatLoad * FracTimeStepZone;
CalcZoneSizing(CurOverallSimDay, CtrlZoneNum).DOASCoolLoadSeq(TimeStepInDay) +=    16
    CalcZoneSizing(CurOverallSimDay, CtrlZoneNum).DOASCoolLoad * FracTimeStepZone;
CalcZoneSizing(CurOverallSimDay, CtrlZoneNum).DOASHeatAddSeq(TimeStepInDay) +=     17
    CalcZoneSizing(CurOverallSimDay, CtrlZoneNum).DOASHeatAdd * FracTimeStepZone;
CalcZoneSizing(CurOverallSimDay, CtrlZoneNum).DOASLatAddSeq(TimeStepInDay) +=      18
    CalcZoneSizing(CurOverallSimDay, CtrlZoneNum).DOASLatAdd * FracTimeStepZone;
CalcZoneSizing(CurOverallSimDay, CtrlZoneNum).DOASSupMassFlowSeq(TimeStepInDay) += 19
    CalcZoneSizing(CurOverallSimDay, CtrlZoneNum).DOASSupMassFlow * FracTimeStepZone;
CalcZoneSizing(CurOverallSimDay, CtrlZoneNum).DOASSupTempSeq(TimeStepInDay) +=     20
    CalcZoneSizing(CurOverallSimDay, CtrlZoneNum).DOASSupTemp * FracTimeStepZone;
CalcZoneSizing(CurOverallSimDay, CtrlZoneNum).DOASSupHumRatSeq(TimeStepInDay) +=   21
    CalcZoneSizing(CurOverallSimDay, CtrlZoneNum).DOASSupHumRat * FracTimeStepZone;
CalcZoneSizing(CurOverallSimDay, CtrlZoneNum).DOASTotCoolLoadSeq(TimeStepInDay) += 22
    CalcZoneSizing(CurOverallSimDay, CtrlZoneNum).DOASTotCoolLoad * FracTimeStepZone;

@rraustad rraustad added this to the EnergyPlus 9.3.0 BugFix milestone Apr 8, 2020
@rraustad rraustad self-assigned this Apr 8, 2020
@Myoldmopar
Copy link
Member

CI looks really happy here, those EIO diffs are very promising when viewed in conjunction with your analysis and explanations. Time to look over the code changes.

CalcZoneSizing(DesDayNum, CtrlZoneNum).DOASSupHumRatSeq(TimeStepIndex) = 0.0;
CalcZoneSizing(DesDayNum, CtrlZoneNum).DOASTotCoolLoadSeq(TimeStepIndex) = 0.0;
}

Copy link
Member

Choose a reason for hiding this comment

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

So much repetition here. Are ZoneSizing and CalcZoneSizing the same struct? If so it would be nice to just put a method on that struct called zeroStuff() or something.

// in the header
struct Whatever {
    void zeroStuff();
    ...
}
// in the implementation
Whatever::zeroStuff() {
    for (TimeStepIndex = 1; TimeStepIndex <= NumOfTimeStepInDay; ++TimeStepIndex) {
        this->DOASSupMassFlowSeq(TimeStepIndex) = 0.0;
        DOASHeatLoadSeq(TimeStepIndex) = 0.0;
        ...
    }
}
// then this code would just reduce to:
if (allocated(ZoneSizing(DesDayNum, CtrlZoneNum).DOASSupMassFlowSeq)) {
    for (DesDayNum = 1; DesDayNum <= TotDesDays + TotRunDesPersDays; ++DesDayNum) {
        for (CtrlZoneNum = 1; CtrlZoneNum <= NumOfZones; ++CtrlZoneNum) {
            ZoneSizing(DesDayNum, CtrlZoneNum).zeroStuff();	                    
        }
    }
}
if (allocated(CalcZoneSizing(DesDayNum, CtrlZoneNum).DOASSupMassFlowSeq)) {
    for (DesDayNum = 1; DesDayNum <= TotDesDays + TotRunDesPersDays; ++DesDayNum) {
        for (CtrlZoneNum = 1; CtrlZoneNum <= NumOfZones; ++CtrlZoneNum) {
            CalcZoneSizing(DesDayNum, CtrlZoneNum).zeroStuff();	                    
        }
    }
}

Although it would be really nice to know ahead of time whether this function would be called with this array already allocated so we could confidently not check the one allocated variable.

EXPECT_EQ(thisSizingType2.CoolOutTempSeq(TimeStepIndex), 0.0);
EXPECT_EQ(thisSizingType2.CoolZoneRetTempSeq(TimeStepIndex), 0.0);
EXPECT_EQ(thisSizingType2.CoolTstatTempSeq(TimeStepIndex), 0.0);
//EXPECT_EQ(thisSizingType2.DesCoolSetPtSeq(TimeStepIndex), 0.0);
Copy link
Member

Choose a reason for hiding this comment

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

It would be good to make some little worker functions that initialize the sizing array structure to make these tests easier to digest.

CalcZoneSizing(DesDayNum, CtrlZoneNum).DOASSupHumRatSeq(TimeStepIndex) = 0.0;
CalcZoneSizing(DesDayNum, CtrlZoneNum).DOASTotCoolLoadSeq(TimeStepIndex) = 0.0;
}

Copy link
Member

Choose a reason for hiding this comment

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

But as for this current fix, it seems to make sense.

@Myoldmopar
Copy link
Member

CI results jive with your test results. Code changes look good. Unit test is present and functional. I'm good with this. I will pull in latest develop locally just to make sure no issues arise with the merged state.

@Myoldmopar
Copy link
Member

Built and tested locally with develop pulled in. Everything looks good to me. Merging. Thanks @rraustad .

@Myoldmopar Myoldmopar merged commit 507eb8d into develop Apr 23, 2020
@Myoldmopar Myoldmopar deleted the 7906-RezeroZoneSizingArrays branch April 23, 2020 18:13
@rraustad rraustad mentioned this pull request Apr 24, 2020
20 tasks
# for free to join this conversation on GitHub. Already have an account? # 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.

Missing zone sizing arrays in RezeroZoneSizingArrays
7 participants