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

Schedule API #10848

Merged
merged 39 commits into from
Jan 23, 2025
Merged

Schedule API #10848

merged 39 commits into from
Jan 23, 2025

Conversation

amirroth
Copy link
Collaborator

@amirroth amirroth commented Dec 6, 2024

Alright, buckle up. This mother of all PRs (at least to this point). It just grew and grew and grew and if it doesn't get merged soon, it's probably going to grow even more.

The main change in this PR is the transition of the Schedule API from a procedural one to an object-oriented one. Specifically, GetScheduleCurrentValue(state, schedIndex, errorsFound) has been replace with sched->getCurrentValue() everywhere. And it turns out that everywhere is a lot.

The switch from a procedural index-based API to an object-oriented API is predicated on the ability to create objects before their first use. This is enabled by the dataX->init_state() methods which call the corresponding GetXInput() functions at the beginning of the simulation rather than starting every function with a guarded if (state.dataX->GetInputFlag) { GetXInput(state); state.dataX->GetInputFlag = false; } call. The state.dataSchedule->init_state() method has been moved to the front portion of the state->init_state() method and now calls GetScheduleInput().

And additional change that relates to both of these is that the commonly used AlwaysOn and AlwaysOff fake schedule indices (-1 and 0) have been eliminated. AlwaysOn and AlwaysOff are now actual schedule objects and can use the sched->getCurrentValue(). These schedules are built-in and can be accessed via the GetSchedAlwaysOn(state) and GetSchedAlwaysOff(state) functions.

Because of the frequent need for these schedules, the init_state() function was split into two, init_constant_state() and init_state(), the former constructs built-in objects that do not appear in the input file. The latter constructs objects that appear in the input file. For Schedule, init_constant_state() constructs the ScheduleAlwaysOn and ScheduleAlwaysOff objects. For FluidProperties, it constructs the Water and Steam objects. This split simplifies unit testing.

One other significant change that was pulled into this PR is a revision of the zone SetPoint schedule framework. The existing framework was quite complicated and included at least one unnecessary level of indirection, and in some places two levels. Conceptually, the structure here is fairly straightforward. There are four types of setpoint schedules Heat, Cool, SingleHeatCool, and DualHeatCool and a control schedule that toggles between them. That framework has been simplified.

The other changes have to do with naming conventions. All schedule object pointers are now called xSched and specifically all availablity schedule pointers called availSched. The namespace name has been shortened from ScheduleManager to Sched although it appears far less frequently with an object-oriented API than with a procedural API.

A final note about unit tests. Previously, unit test schedule values were accessed and over-written by schedule index. But this is brittle because it relies on the order in which Schedule object definitions appeared in the IDF snippet. It's also not very readable. Those were changed to GetSched(state, "name")->currVal = 1.0 (or whatever it is). A bit slower, yes, but speed doesn't matter for unit tests and this is more readable and robust.

There are diffs, and they fall into five categories:

  • Error and EIO diffs due to the fact that some schedules are just handled differently now. Specifically, constant schedules are a separate sibling class from detailed schedules and they don't use the day-schedule/week-schedule construct, they just return a constant value.
  • Reporting diffs due to the simplifications of the zone thermostat setpoint schedules. The existing reports depended on the order in which setpoint schedules were listed in the object even though that order does not actually determine priority or anything else.
  • There are some small diffs that have to do with the fact that some schedule summary information is pre-computed now as opposed to be calculated in place for the report.
  • There are some "large" table diffs that have to do with a reporting bug for IT Equipment loads (minimum scheduled values were previously reported as zero because the schedule minimum values had not been calculated yet).
  • There is a legitimate operational (i.e., ESO) diff in one of the example files (PlantLoopHeatPump_EIR_AirSource_Hospital_wSixPipeHeatRecovery), that we (mostly @rraustad working on this) have not been able to track down. These large diffs do not result in large table diffs. I say we go ahead and merge this anyway. This is a big baby and only a teaspoon of bathwater.

@amirroth amirroth added the Refactoring Includes code changes that don't change the functionality of the program, just perform refactoring label Dec 6, 2024
@amirroth amirroth added this to the EnergyPlus 25.1 milestone Dec 6, 2024
@amirroth amirroth self-assigned this Dec 6, 2024
Copy link

github-actions bot commented Dec 6, 2024

⚠️ Regressions detected on macos-14 for commit 4d72d8a

Regression Summary
  • Audit: 668
  • EIO: 573
  • ERR: 669
  • EDD: 26
  • MTD: 5
  • Table Big Diffs: 490
  • Table String Diffs: 388
  • RDD: 9
  • MTR Big Diffs: 6
  • SSZ Big Diffs: 1
  • ZSZ Big Diffs: 2
  • PERF_LOG: 2
  • ESO Small Diffs: 23
  • MTR Small Diffs: 16
  • Table Small Diffs: 4
  • SSZ Small Diffs: 6
  • ESO Big Diffs: 6
  • ZSZ Small Diffs: 5

auto &s_sched = state.dataSched;
for (int i = 0; i < (int)s_sched->scheduleTypes.size(); ++i) if (s_sched->scheduleTypes[i]->Name == name) return i;
return -1;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

[src/EnergyPlus/ScheduleManager.cc:99]:(style),[constVariableReference],Variable 's_sched' can be declared as reference to const
[src/EnergyPlus/ScheduleManager.cc:227]:(style),[constVariableReference],Variable 's_sched' can be declared as reference to const
[src/EnergyPlus/ScheduleManager.cc:241]:(style),[constVariableReference],Variable 's_sched' can be declared as reference to const
[src/EnergyPlus/ScheduleManager.cc:273]:(style),[constVariableReference],Variable 's_sched' can be declared as reference to const
[src/EnergyPlus/ScheduleManager.cc:385]:(style),[constVariableReference],Variable 's_sched' can be declared as reference to const
[src/EnergyPlus/ScheduleManager.cc:2409]:(style),[constParameterReference],Parameter 'state' can be declared as reference to const
[src/EnergyPlus/ScheduleManager.cc:2497]:(style),[constParameterReference],Parameter 'state' can be declared as reference to const
[src/EnergyPlus/ScheduleManager.cc:2502]:(style),[constParameterReference],Parameter 'state' can be declared as reference to const
[src/EnergyPlus/ScheduleManager.cc:2515]:(style),[constVariableReference],Variable 's_sched' can be declared as reference to const
[src/EnergyPlus/ScheduleManager.cc:2553]:(style),[constVariableReference],Variable 's_sched' can be declared as reference to const
[src/EnergyPlus/ScheduleManager.cc:2587]:(style),[constVariableReference],Variable 's_sched' can be declared as reference to const
[src/EnergyPlus/ScheduleManager.cc:2725]:(style),[constParameterReference],Parameter 'state' can be declared as reference to const
[src/EnergyPlus/ScheduleManager.cc:2978]:(style),[constVariableReference],Variable 's_glob' can be declared as reference to const

@rraustad
Copy link
Contributor

rraustad commented Dec 6, 2024

I noticed that Schedule Value was added to the rdd for 1ZoneUncontrolled_win_1.idf. There are no schedules in that file. There is a ScheduleTypeLimits object.

 Zone,Average,Zone Humidity Index []
+Zone,Average,Schedule Value []
 HVAC,Sum,Environmental Impact Total N2O Emissions Carbon Equivalent Mass [kg]

ScheduleTypeLimits,
  Fraction,                !- Name
  0.0,                     !- Lower Limit Value
  1.0,                     !- Upper Limit Value
  CONTINUOUS;              !- Numeric Type

The error file shows there are 2 unused schedules:

    ************* Simulation Error Summary *************
+   ************* There are 2 unused schedules in input.
+   ************* Use Output:Diagnostics,DisplayUnusedSchedules; to see them.
    ************* EnergyPlus Warmup Error Summary. During Warmup: 0 Warning; 0 Severe Errors.

@amirroth
Copy link
Collaborator Author

amirroth commented Dec 6, 2024

I noticed that Schedule Value was added to the rdd for 1ZoneUncontrolled_win_1.idf. There are no schedules in that file. There is a ScheduleTypeLimits object.

 Zone,Average,Zone Humidity Index []
+Zone,Average,Schedule Value []
 HVAC,Sum,Environmental Impact Total N2O Emissions Carbon Equivalent Mass [kg]

ScheduleTypeLimits,
  Fraction,                !- Name
  0.0,                     !- Lower Limit Value
  1.0,                     !- Upper Limit Value
  CONTINUOUS;              !- Numeric Type

The error file shows there are 2 unused schedules:

    ************* Simulation Error Summary *************
+   ************* There are 2 unused schedules in input.
+   ************* Use Output:Diagnostics,DisplayUnusedSchedules; to see them.
    ************* EnergyPlus Warmup Error Summary. During Warmup: 0 Warning; 0 Severe Errors.

Hmmmm. I think I know what this is, but I will verify after I am done looking at something more serious. In this refactor, schedule 0 (always off) and schedule -1 (always on) are not schedule indices, they are actual schedule objects. This change was needed in order to allow schedules to be accessed as objects rather than via indices. These schedule objects are always created and its possible that this error is printed if they are not used.

Copy link

github-actions bot commented Dec 7, 2024

⚠️ Regressions detected on macos-14 for commit b8e50a6

Regression Summary
  • Audit: 693
  • EIO: 599
  • ERR: 694
  • EDD: 13
  • MTD: 4
  • Table Big Diffs: 518
  • Table String Diffs: 409
  • RDD: 9
  • ESO Big Diffs: 27
  • PERF_LOG: 2
  • ESO Small Diffs: 20
  • MTR Small Diffs: 13
  • Table Small Diffs: 4
  • MTR Big Diffs: 23
  • SSZ Small Diffs: 5
  • ZSZ Big Diffs: 1
  • ZSZ Small Diffs: 4

Copy link

github-actions bot commented Dec 8, 2024

⚠️ Regressions detected on macos-14 for commit 19a54ba

Regression Summary
  • Audit: 742
  • EIO: 644
  • ERR: 744
  • EDD: 31
  • MTD: 6
  • Table Big Diffs: 559
  • Table String Diffs: 447
  • RDD: 10
  • ESO Big Diffs: 32
  • SSZ Small Diffs: 2
  • ZSZ Big Diffs: 6
  • ESO Small Diffs: 27
  • MTR Small Diffs: 17
  • SSZ Big Diffs: 4
  • MTR Big Diffs: 30
  • PERF_LOG: 3
  • Table Small Diffs: 3

Copy link

github-actions bot commented Dec 9, 2024

⚠️ Regressions detected on macos-14 for commit 2f6289a

Regression Summary
  • Audit: 760
  • EIO: 400
  • EDD: 33
  • MTD: 6
  • Table Big Diffs: 45
  • Table String Diffs: 377
  • ERR: 354
  • RDD: 10
  • ESO Big Diffs: 31
  • Table Small Diffs: 43
  • SSZ Small Diffs: 2
  • ZSZ Big Diffs: 6
  • ESO Small Diffs: 31
  • MTR Small Diffs: 20
  • SSZ Big Diffs: 4
  • MTR Big Diffs: 29
  • PERF_LOG: 3

Copy link

github-actions bot commented Dec 9, 2024

⚠️ Regressions detected on macos-14 for commit faf2d8b

Regression Summary
  • EIO: 449
  • EDD: 33
  • Table Big Diffs: 147
  • Table String Diffs: 425
  • ERR: 370
  • ESO Big Diffs: 148
  • Table Small Diffs: 45
  • MTR Big Diffs: 132
  • Audit: 2
  • SSZ Small Diffs: 2
  • ZSZ Big Diffs: 6
  • SSZ Big Diffs: 4
  • MTR Small Diffs: 3
  • PERF_LOG: 3
  • ESO Small Diffs: 7
  • JSON Big Diffs: 1

Copy link

⚠️ Regressions detected on macos-14 for commit 2d9f415

Regression Summary
  • EIO: 186
  • EDD: 33
  • Table Big Diffs: 146
  • Table String Diffs: 401
  • ERR: 133
  • Table Small Diffs: 45
  • ESO Big Diffs: 145
  • MTR Big Diffs: 130
  • Audit: 2
  • SSZ Small Diffs: 2
  • ZSZ Big Diffs: 6
  • SSZ Big Diffs: 4
  • MTR Small Diffs: 3
  • PERF_LOG: 2
  • ESO Small Diffs: 7
  • JSON Big Diffs: 1

Copy link

⚠️ Regressions detected on macos-14 for commit f2c5bbe

Regression Summary
  • EIO: 185
  • EDD: 33
  • Table Big Diffs: 144
  • Table String Diffs: 401
  • ERR: 133
  • Table Small Diffs: 46
  • ESO Big Diffs: 146
  • MTR Big Diffs: 131
  • Audit: 2
  • SSZ Small Diffs: 2
  • ZSZ Big Diffs: 6
  • SSZ Big Diffs: 4
  • MTR Small Diffs: 3
  • PERF_LOG: 2
  • ESO Small Diffs: 7
  • JSON Big Diffs: 1

Copy link

⚠️ Regressions detected on macos-14 for commit 27cf685

Regression Summary
  • EIO: 184
  • EDD: 33
  • Table Big Diffs: 143
  • Table String Diffs: 402
  • ERR: 136
  • Table Small Diffs: 45
  • ESO Big Diffs: 145
  • MTR Big Diffs: 130
  • Audit: 2
  • SSZ Small Diffs: 2
  • ZSZ Big Diffs: 6
  • SSZ Big Diffs: 4
  • MTR Small Diffs: 3
  • PERF_LOG: 2
  • ESO Small Diffs: 7
  • JSON Big Diffs: 1
  • MTD: 1

Copy link

⚠️ Regressions detected on macos-14 for commit 07edd4f

Regression Summary
  • EIO: 185
  • EDD: 33
  • Table Big Diffs: 145
  • Table String Diffs: 402
  • ERR: 135
  • Table Small Diffs: 45
  • ESO Big Diffs: 146
  • MTR Big Diffs: 132
  • Audit: 2
  • SSZ Small Diffs: 2
  • ZSZ Big Diffs: 7
  • SSZ Big Diffs: 4
  • MTR Small Diffs: 3
  • PERF_LOG: 2
  • ESO Small Diffs: 7
  • JSON Big Diffs: 1

Copy link

⚠️ Regressions detected on macos-14 for commit e0d5bc5

Regression Summary
  • EIO: 194
  • EDD: 34
  • Table Big Diffs: 151
  • Table String Diffs: 415
  • ERR: 145
  • Table Small Diffs: 45
  • ESO Big Diffs: 150
  • MTR Big Diffs: 138
  • Audit: 5
  • SSZ Small Diffs: 2
  • ZSZ Big Diffs: 11
  • SSZ Big Diffs: 7
  • MTR Small Diffs: 4
  • PERF_LOG: 3
  • ESO Small Diffs: 8
  • JSON Big Diffs: 1

Copy link

⚠️ Regressions detected on macos-14 for commit 076b6e7

Regression Summary
  • EIO: 66
  • EDD: 34
  • Table Big Diffs: 7
  • Table String Diffs: 321
  • ERR: 53
  • Table Small Diffs: 51
  • ESO Small Diffs: 38
  • MTR Small Diffs: 31
  • ESO Big Diffs: 1
  • PERF_LOG: 1

@@ -2242,7 +2242,7 @@ void GetRefrigerationInput(EnergyPlusData &state)
}

++AlphaNum; // A6
if (lAlphaBlanks(AlphaNum)) {
if (!lAlphaBlanks(AlphaNum)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What's this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I was trying to bisect something I was seeing locally so I reverted this line. I didn't work.

Copy link

⚠️ Regressions detected on macos-14 for commit 9876a00

Regression Summary
  • EIO: 65
  • EDD: 34
  • Table Big Diffs: 6
  • Table String Diffs: 327
  • ERR: 52
  • Table Small Diffs: 51
  • ESO Small Diffs: 38
  • MTR Small Diffs: 30
  • ESO Big Diffs: 1
  • PERF_LOG: 1

Copy link

github-actions bot commented Jan 8, 2025

⚠️ Regressions detected on macos-14 for commit 0b7e5b4

Regression Summary
  • EIO: 65
  • EDD: 34
  • Table Big Diffs: 6
  • Table String Diffs: 327
  • ERR: 52
  • Table Small Diffs: 51
  • ESO Small Diffs: 38
  • MTR Small Diffs: 30
  • ESO Big Diffs: 1
  • PERF_LOG: 1

@@ -852,7 +852,7 @@
Until: 24:00,23.89, !- Field 23
For: Sunday Holidays AllOtherDays, !- Field 25
Until: 8:00,29.44, !- Field 26
Until: 8:00,26.67, !- Field 28
Until: 8:00,26.67, !- Field 28 Is this supposed to be 9:00?
Copy link
Contributor

Choose a reason for hiding this comment

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

Given the occupancy schedule pattern for Type1, Type2 and Type3 where Type1 occupancy occurs at 8 AM this look correct.

Schedule:Compact,
  Type1_OCC_SCH,           !- Name
  For: Sunday Holidays AllOtherDays, !- Field 50
  Until: 08:00,0.0,        !- Field 51
  Until: 10:00,0.05,       !- Field 53

Schedule:Compact,
  Type2_OCC_SCH,           !- Name
  For: Sunday Holidays AllOtherDays, !- Field 52
  Until: 09:00,0.0,        !- Field 53
  Until: 10:00,0.05,       !- Field 55

Schedule:Compact,
  Type3_OCC_SCH,           !- Name
  For: Sunday Holidays AllOtherDays, !- Field 62
  Until: 10:00,0.0,        !- Field 63
  Until: 11:00,0.11,       !- Field 65

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It does? Two consecutive "Until 8:00, X" statements is correct? At the very least one of them is redundant. Which one though?

Copy link
Contributor

Choose a reason for hiding this comment

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

Two consecutive "Until 8:00, X" statements is NOT correct input syntax (but it doesn't hurt anything). The point is that the 2nd 8:00 should not be 9:00 since occupancy starts at 8:00. I think the developer noticed that occupancy started at 8:00 and simply changed the time on the 2nd line from 9 to 8. So the question is did the developer want 29.44 C or 26.67 C as the Tstat temp from midnight to 8:00? Either way the occupied Tstat setting of 23.89 C should begin at 8:00.

For: Sunday Holidays AllOtherDays, !- Field 25
Until:  8:00,29.44,      !- Field 26
Until:  8:00,26.67,      !- Field 28
Until: 23:00,23.89,      !- Field 30
Until: 24:00,23.89;      !- Field 32

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Or maybe the first Until 8:00 should really be Until 7:00?

Copy link
Contributor

@rraustad rraustad Jan 10, 2025

Choose a reason for hiding this comment

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

Using Until 7:00 for the Type 1 Tstat schedules (Type1_CLGSETP_*) would be consistent with Type 2 and Type 3 cooling set point schedules.

  Schedule:Compact,
    Type1_CLGSETP_SCH_YES_OPTIMUM,  !- Name
    For: Sunday Holidays AllOtherDays, !- Field 25
    Until:  8:00,29.44,      !- Field 26
    Until:  8:00,26.67,      !- Field 28

  Schedule:Compact,
    Type2_CLGSETP_SCH_YES_OPTIMUM,  !- Name
    For: Sunday Holidays AllOtherDays, !- Field 23
    Until:  8:00,29.44,      !- Field 24
    Until:  9:00,26.67,      !- Field 26

  Schedule:Compact,
    Type3_CLGSETP_SCH_YES_OPTIMUM,  !- Name
    For: Sunday Holidays AllOtherDays, !- Field 23
    Until:  9:00,29.44,      !- Field 24
    Until: 10:00,26.67,      !- Field 26

Copy link

⚠️ Regressions detected on macos-14 for commit 54294d7

Regression Summary
  • EIO: 65
  • EDD: 34
  • Table Big Diffs: 3
  • Table String Diffs: 327
  • ERR: 52
  • Table Small Diffs: 54
  • ESO Small Diffs: 35
  • MTR Small Diffs: 30
  • ESO Big Diffs: 1
  • PERF_LOG: 1

@amirroth amirroth assigned Myoldmopar and unassigned amirroth Jan 10, 2025
Copy link
Collaborator Author

@amirroth amirroth left a comment

Choose a reason for hiding this comment

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

This is not a detailed walk-through, because a detailed one would take 5X comments (mostly in the Schedule and ZoneTempPredictorCorrector modules). Hopefully, it's enough. Most of the changes are just templates repeated over and over and over again. How schedule pointers are set up in IDF objects. How errors in schedule pointers or limits are printed. How schedule values are read. Rinse. Repeat.

@@ -457,6 +457,8 @@ namespace AirLoopHVACDOAS {
++AirLoopDOASNum;
AirLoopDOAS thisDOAS;

ErrorObjectHeader eoh{routineName, cCurrentModuleObject, thisObjectName};
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You're going to see a lot of this as all of the new schedule handling code uses this error reporting pattern.

@@ -117,7 +117,7 @@ namespace AirLoopHVACDOAS {

int m_AirLoopDOASNum = 0;
int m_OASystemNum = 0;
int m_AvailManagerSchedPtr = 0;
Sched::Schedule *m_AvailManagerSched = nullptr;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh the irony. No more int SchedPtr, int SchedIndex, int SchedPtrIdx, int Sch, only Sched::Schedule *xSched = nullptr;

@@ -184,6 +184,10 @@ struct AirLoopHVACDOASData : BaseGlobalStruct
std::vector<AirLoopHVACDOAS::AirLoopMixer> airloopMixer;
std::vector<AirLoopHVACDOAS::AirLoopSplitter> airloopSplitter;

void init_constant_state([[maybe_unused]] EnergyPlusData &state) override
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This hook initializes builtin state, which for schedules includes the AlwaysOn and AlwaysOff schedule objects.

if (this->availScheduleIndex == 0) {
ShowSevereError(state, std::string{routineName} + state.dataCoilCooingDX->coilCoolingDXObjectName + "=\"" + this->name + "\", invalid");
ShowContinueError(state, "...Availability Schedule Name=\"" + input_data.availability_schedule_name + "\".");
this->availSched = Sched::GetScheduleAlwaysOn(state);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is how you get the AlwaysOn schedule object.

@@ -215,7 +214,7 @@ void CoilCoolingDXCurveFitPerformance::simulate(EnergyPlus::EnergyPlusData &stat
Real64 LoadSHR)
{
static constexpr std::string_view RoutineName = "CoilCoolingDXCurveFitPerformance::simulate";
Real64 reportingConstant = state.dataHVACGlobal->TimeStepSys * Constant::SecInHour;
Real64 reportingConstant = state.dataHVACGlobal->TimeStepSys * Constant::rSecsInHour;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh, this is important too. For SecsInHour, MinutesInDay, etc. there are now both r and i variants. The i variants are used as indices in schedules or for loops. The r variants are in products with physical quantities. Just saves an integer-to-real conversion.


ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)};

if (s_sched->dayScheduleMap.find(Alphas(1)) != s_sched->dayScheduleMap.end()) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Instead of using std::unordered_map to check for duplicate names but then finding the indices of existing objects using linear search, why not use a single std::map to do both?

ControlTypeNum,
TempControlledZone.ControlTypeSchedName));
ShowContinueError(state, "..valid range values are [0,4].");
for (HVAC::SetptType setptType : HVAC::setptTypes) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Each temperature controlled zone only has four possible thermostats (one of each type) and they are tracked in this fixed-size std::array, not need to track them via separate lists that track not only thermostat existence but thermostat type.

EPVector<ZoneTempPredictorCorrector::ZoneComfortFangerControl> SetPointSingleHeatingFanger;
EPVector<ZoneTempPredictorCorrector::ZoneComfortFangerControl> SetPointSingleCoolingFanger;
EPVector<ZoneTempPredictorCorrector::ZoneComfortFangerControl> SetPointSingleHeatCoolFanger;
EPVector<ZoneTempPredictorCorrector::ZoneComfortFangerControl> SetPointDualHeatCoolFanger;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

All of this separate list tracking is not necessary.

@@ -4035,6 +4034,8 @@ TEST_F(EnergyPlusFixture, AirLoopHVACDOASTest)

ASSERT_TRUE(process_idf(idf_objects));

state->init_state(*state);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

call init_state() after process_idf() to construct objects specified in the IDF file. For now, init_state() only constructs schedule and fluid properties objects, all other objects are still construced "on first use" by the ubiquitous if (state.dataX->GetInput) { GetXInput(state); state.dataX->GetInput = false; } pattern. Incrementally, more object types will be constructed this way.

@@ -4132,7 +4131,8 @@ TEST_F(EnergyPlusFixture, AirLoopHVACDOASTest)

state->dataEnvrn->OutBaroPress = 101325.0;

state->dataScheduleMgr->Schedule(1).CurrentValue = 1.0; // set availability and fan schedule to 1
auto *sched = Sched::GetSchedule(*state, "ALWAYS_ON");
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Don't rely on position to manipulate schedules created by IDF snippets, use the schedule name. It's a little slower, but this is a unit test so speed doesn't matter and it's much more robust and transparent.

All unit test change are of this form.

Copy link

⚠️ Regressions detected on macos-14 for commit e49421e

Regression Summary
  • EIO: 65
  • EDD: 34
  • Table Big Diffs: 3
  • ERR: 52
  • Table Small Diffs: 54
  • Table String Diffs: 31
  • ESO Small Diffs: 35
  • MTR Small Diffs: 30
  • ESO Big Diffs: 1
  • PERF_LOG: 1

Copy link

⚠️ Regressions detected on macos-14 for commit d2a19b5

Regression Summary
  • EIO: 65
  • EDD: 34
  • Table Big Diffs: 3
  • ERR: 52
  • Table Small Diffs: 54
  • Table String Diffs: 31
  • ESO Small Diffs: 35
  • MTR Small Diffs: 30
  • ESO Big Diffs: 1
  • PERF_LOG: 1

@Myoldmopar
Copy link
Member

Alright, there is now just one unit test failing...not sure what that's about yet. Otherwise it's just regressions. I can summarize what I see locally for regressions:

Text Files

  • ERR diffs where new warnings are added about zero time interval in compact schedules (ASHRAE901_RetailStripmall_STD2019_Denver)
    • Should we fix the IDFs before merging this?
  • EIO diffs where ElectricEquipment min/max equipment levels now have values and before they were zero. (1ZoneDataCenterCRAC_wApproachTemp)
    • I think this is good, no?
  • ERR diffs where there are fewer warnings about unused schedules. (1ZoneWith14ControlledHeat-CoolPanels)
    • Does this mean the warning should never have been thrown? Or did the inputs get fixed?
  • ERR diffs with some rewording for blank schedule type limits. (ASHRAE901_Hospital_STD2019_Denver)
    • This is probably fine or intentional, but in another file it just added a large number of warnings (_ResidentialBaseboardHardSize)

Table Diffs

  • There are some that just represent the same fix to the equipment object as in the EIO file.
  • Then HeatPumpProportionalControl_DCVDesignOccAllZones seems to now be reporting the schedule name now?
  • These seem good, I think.

Math Diffs

  • There are a few dozen files with small math diffs, but I'm not going to sweat those.
  • One file has big math diffs: PlantLoopHeatPump_EIR_AirSource_Hospital_wSixPipeHeatRecovery
  • When I re-run it with annual outputs to blur out any small timing issues triggering big math diffs, the big math diffs indeed vanish, indicating this isn't actually affecting overall operation.

So I think all that is left here is confirming the ERR diffs are expected, or if we should do any final work there, and then fixing the one failing unit test that GitHub is showing on Mac (Apple Silicon).

Copy link

⚠️ Regressions detected on macos-14 for commit c32349d

Regression Summary
  • EIO: 65
  • EDD: 34
  • Table Big Diffs: 3
  • ERR: 52
  • Table Small Diffs: 54
  • Table String Diffs: 31
  • ESO Small Diffs: 35
  • MTR Small Diffs: 30
  • ESO Big Diffs: 1
  • PERF_LOG: 1

@Myoldmopar
Copy link
Member

Look at that, all green! OK, this is dropping in. Thanks @amirroth for the huge refactor here. I'll be happy to help anyone with their branches containing conflicts after this merge.

@Myoldmopar Myoldmopar merged commit 06b0bea into develop Jan 23, 2025
9 checks passed
@Myoldmopar Myoldmopar deleted the ScheduleAPI branch January 23, 2025 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Refactoring Includes code changes that don't change the functionality of the program, just perform refactoring
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants