#11054 - Part 2 - Crash with schedule with missing day types#11173
#11054 - Part 2 - Crash with schedule with missing day types#11173Myoldmopar merged 3 commits intodevelopfrom
Conversation
…ike defect file
…gDaySchedule-0.0" and AddWeekSchedule initializes dayScheds to this missing day type
…in the daySchedules vector
| auto *missingDaySchedule = AddDaySchedule(state, "MissingDaySchedule-0.0"); | ||
| assert(missingDaySchedule->Num == SchedNum_AlwaysOff); | ||
| missingDaySchedule->isUsed = true; |
There was a problem hiding this comment.
InitConstantScheduleData: Add a missingDaySchedule at index 0 in dataSched->daySchedules
| // Fill the dayScheds with the Missing Day Schedule (Always Off) | ||
| for (int iDayType = 1; iDayType < (int)DayType::Num; ++iDayType) { | ||
| weekSched->dayScheds[iDayType] = s_sched->daySchedules[SchedNum_AlwaysOff]; | ||
| } |
There was a problem hiding this comment.
AddWeekSchedule initializes the dayScheds to that missing schedule (except the "Unused" day type...)
| // When InitConstantScheduleData is called, TimeStepsInHour is 0, so we ensure 24 | ||
| daySched->tsVals.assign(Constant::iHoursInDay * max(1, s_glob->TimeStepsInHour), 0.0); |
There was a problem hiding this comment.
Perhaps I should have kept resize only, but the assign is clearer and initializes.
| // When InitConstantScheduleData is called, TimeStepsInHour is 0, so we delay it here | ||
| static_cast<DaySchedule *>(s_sched->daySchedules[SchedNum_AlwaysOff])->tsVals.assign(Constant::iHoursInDay * s_glob->TimeStepsInHour, 0.0); |
There was a problem hiding this comment.
In ProcessScheduleInput, I reassign the DaySchedule to the right size now that we know the TimeStepsInHour.
| if (daySched == nullptr) { | ||
| // We already warned in ProcessScheduleInput that there were missing days: Missing day types will have 0.0 as Schedule Values | ||
| return 0.0; | ||
| } |
There was a problem hiding this comment.
daySched checking for nullptr is no longer needed.
| " Fraction, !- Name", | ||
| " 0, !- Lower Limit Value", | ||
| " 1, !- Upper Limit Value", | ||
| " Continuous, !- Numeric Type", | ||
| " percent; !- Unit Type", | ||
|
|
||
| "Schedule:Compact,", | ||
| " WindowVentSched, !- Name", | ||
| " Any Number, !- Schedule Type Limits Name", | ||
| " Fraction, !- Schedule Type Limits Name", |
There was a problem hiding this comment.
Mod the previous test to add that ScheduleTypeLimits validation which makes it crash before fix in setMinMaxVals like the new defect file does
| Sched::DaySchedule const *const missingDaySchedule = state->dataSched->daySchedules[Sched::SchedNum_AlwaysOff]; | ||
| EXPECT_EQ(0, missingDaySchedule->minVal); | ||
| EXPECT_EQ(0, missingDaySchedule->maxVal); | ||
| EXPECT_EQ(4 * 24, missingDaySchedule->tsVals.size()); | ||
| for (auto v : missingDaySchedule->tsVals) { | ||
| EXPECT_EQ(0.0, v); | ||
| } | ||
|
|
||
| EXPECT_EQ(0, weekSched->minVal); | ||
| EXPECT_EQ(1, weekSched->maxVal); | ||
|
|
||
| EXPECT_EQ(missingDaySchedule, weekSched->dayScheds[(int)Sched::DayType::Sunday]); |
There was a problem hiding this comment.
We check that the missingDaySchedule in question is properly all zeroes with the right size.
The weekSched min/maxVal are ok.
And the Missing day types all point to that missingDaySchedule
|
|
Alternate defect file Ticket 16879.idf runs successfully after fixing the coil UA issues (Sizing:Plant with 70C and 6.222C). 11054 defect file in-v25.1 runs to completion with: |
|
New entry in eio file for missing day schedule: |
rraustad
left a comment
There was a problem hiding this comment.
Defect files run correctly with associated warnings reported to err file.
|
Looks good to me, I'll do a quick check locally. |
Pull request overview
ScheduleTypeLimits, and will fail insetMinMaxValsDescription of the purpose of this PR
The approach taken here is to:
InitConstantScheduleDataadds aDaySchedule"MissingDaySchedule-0.0" at index 0 inSched::daySchedules.AddWeekScheduleinitializesWeekSchedule::daySchedsto this missing day typeDaySchedulepointer in theWeekSchedule::daySchedsUnusedweirdness https://github.com/NREL/EnergyPlus/blob/acf7908bedc967ed80ec691f4441ec01702ec23c/src/EnergyPlus/ScheduleManager.hh#L75Defect file segfaults without fix, works with fix,
eplusout.errcorrectly references the missing day typesPull Request Author
Reviewer