Skip to content

Commit

Permalink
Fix accumulation/averaging issue
Browse files Browse the repository at this point in the history
  • Loading branch information
amirroth committed Dec 10, 2024
1 parent b8b9473 commit 72066d1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 76 deletions.
18 changes: 7 additions & 11 deletions src/EnergyPlus/InternalHeatGains.cc
Original file line number Diff line number Diff line change
Expand Up @@ -546,14 +546,11 @@ namespace InternalHeatGains {

// Following is an optional parameter (ASHRAE 55 warnings
if (IHGNumAlphas >= 6) {
BooleanSwitch bs = getYesNoValue(IHGAlphas(6));
if (bs == BooleanSwitch::Invalid) {
if (Item1 == 1) {
ShowSevereInvalidKey(state, eoh, IHGAlphaFieldNames(6), IHGAlphas(6));
ErrorsFound = true;
}
} else {
thisPeople.Show55Warning = true;
if (BooleanSwitch bs = getYesNoValue(IHGAlphas(6)); bs != BooleanSwitch::Invalid) {
thisPeople.Show55Warning = static_cast<bool>(bs);
} else if (Item1 == 1) {
ShowSevereInvalidKey(state, eoh, IHGAlphaFieldNames(6), IHGAlphas(6));
ErrorsFound = true;
}
}

Expand Down Expand Up @@ -3246,10 +3243,9 @@ namespace InternalHeatGains {
print(state.files.eio, "{},", yesNoNames[(int)people.Pierce]);
print(state.files.eio, "{},", yesNoNames[(int)people.KSU]);
print(state.files.eio, "{},", yesNoNames[(int)people.CoolingEffectASH55]);
print(state.files.eio, "{},", yesNoNames[(int)people.AnkleDraftASH55]);
} else {
print(state.files.eio, "\n");
print(state.files.eio, "{}", yesNoNames[(int)people.AnkleDraftASH55]);
}
print(state.files.eio, "\n");
}

for (int Loop = 1; Loop <= state.dataHeatBal->TotLights; ++Loop) {
Expand Down
84 changes: 19 additions & 65 deletions src/EnergyPlus/ScheduleManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,10 @@ namespace Sched {
int begMin = 0;
int endMin = s_glob->MinutesInTimeStep - 1;
for (int ts = 0; ts < s_glob->TimeStepsInHour; ++ts) {
this->tsVals[hr * s_glob->TimeStepsInHour + ts] =
std::accumulate(&minuteVals[hr * Constant::iMinutesInHour + begMin], &minuteVals[hr * Constant::iMinutesInHour + endMin + 1], 0) /
double(s_glob->MinutesInTimeStep);
Real64 accum = std::accumulate(&minuteVals[hr * Constant::iMinutesInHour + begMin],
&minuteVals[hr * Constant::iMinutesInHour + endMin + 1],
0.0);
this->tsVals[hr * s_glob->TimeStepsInHour + ts] = accum / double(s_glob->MinutesInTimeStep);
this->sumTsVals += this->tsVals[hr * s_glob->TimeStepsInHour + ts];
begMin = endMin + 1;
endMin += s_glob->MinutesInTimeStep;
Expand Down Expand Up @@ -916,17 +917,15 @@ namespace Sched {

// Number of numbers in the Numbers list okay to process
int hr = 0;
int begMinute = 0;
int endMinute = MinutesPerItem - 1;
int begMin = 0;
int endMin = MinutesPerItem - 1;
for (int NumFields = 2; NumFields <= NumNumbers; ++NumFields) {
std::fill(&minuteVals[hr * Constant::iMinutesInHour + begMinute],
&minuteVals[hr * Constant::iMinutesInHour + endMinute],
Numbers(NumFields));
begMinute = endMinute + 1;
endMinute += MinutesPerItem;
if (endMinute >= Constant::iMinutesInHour) {
endMinute = MinutesPerItem - 1;
begMinute = 0;
std::fill(&minuteVals[hr * Constant::iMinutesInHour + begMin], &minuteVals[hr * Constant::iMinutesInHour + endMin + 1], Numbers(NumFields));
begMin = endMin + 1;
endMin += MinutesPerItem;
if (endMin >= Constant::iMinutesInHour) {
endMin = MinutesPerItem - 1;
begMin = 0;
++hr;
}
}
Expand Down Expand Up @@ -1361,31 +1360,7 @@ namespace Sched {
ErrorsFound = true;
}

// No validation done on the value of the interpolation field
if (daySched->interpolation == Interpolation::No) {
for (int hr = 0; hr < Constant::iHoursInDay; ++hr) {
int curMinute = s_glob->MinutesInTimeStep - 1;
for (int ts = 0; ts < s_glob->TimeStepsInHour; ++ts) {
daySched->tsVals[hr * s_glob->TimeStepsInHour + ts] = minuteVals[hr * Constant::iMinutesInHour + curMinute];
daySched->sumTsVals += daySched->tsVals[hr * s_glob->TimeStepsInHour + ts];
curMinute += s_glob->MinutesInTimeStep;
}
}
} else {
for (int hr = 0; hr < Constant::iHoursInDay; ++hr) {
int begMin = 0;
int endMin = s_glob->MinutesInTimeStep - 1;
for (int ts = 0; ts < s_glob->TimeStepsInHour; ++ts) {
daySched->tsVals[hr * s_glob->TimeStepsInHour + ts] =
std::accumulate(&minuteVals[hr * Constant::iMinutesInHour + begMin],
&minuteVals[hr * Constant::iMinutesInHour + endMin + 1],
0) / double(s_glob->MinutesInTimeStep);
daySched->sumTsVals += daySched->tsVals[hr * s_glob->TimeStepsInHour + ts];
begMin = endMin + 1;
endMin += s_glob->MinutesInTimeStep;
}
}
}
daySched->populateFromMinuteVals(state, minuteVals);
}
}

Expand Down Expand Up @@ -1544,12 +1519,12 @@ namespace Sched {
}

// Depending on value of "Interpolate" field, the value for each time step in each hour gets processed:
FileIntervalInterpolated = false;
Interpolation interp = Interpolation::No;


if (!lAlphaBlanks(5)) {
if (BooleanSwitch bs = getYesNoValue(Alphas(5)); bs != BooleanSwitch::Invalid) {
FileIntervalInterpolated = static_cast<bool>(bs);
interp = static_cast<bool>(bs) ? Interpolation::Average : Interpolation::Linear;
} else {
ShowSevereInvalidKey(state, eoh, cAlphaFields(5), Alphas(5));
ErrorsFound = true;
Expand Down Expand Up @@ -1659,7 +1634,7 @@ namespace Sched {
// schedule is pointing to the week schedule
sched->weekScheds[iDay] = weekSched;

if (MinutesPerItem == 60) {
if (MinutesPerItem == Constant::iMinutesInHour) {
for (int hr = 0; hr < Constant::iHoursInDay; ++hr) {
Real64 curHrVal = column_values[ifld]; // hourlyFileValues((hDay - 1) * 24 + jHour)
++ifld;
Expand All @@ -1681,30 +1656,9 @@ namespace Sched {
endMin += MinutesPerItem;
}
}
if (FileIntervalInterpolated) {
for (int hr = 0; hr < Constant::iHoursInDay; ++hr) {
int begMin = 0;
int endMin = s_glob->MinutesInTimeStep - 1;
for (int ts = 0; ts < s_glob->TimeStepsInHour; ++ts) {
daySched->tsVals[hr * s_glob->TimeStepsInHour + ts] =
std::accumulate(&minuteVals[hr * Constant::iMinutesInHour + begMin],
&minuteVals[hr * Constant::iMinutesInHour + endMin + 1],
0) / double(s_glob->MinutesInTimeStep);
daySched->sumTsVals += daySched->tsVals[hr * s_glob->TimeStepsInHour + ts];
begMin = endMin + 1;
endMin += s_glob->MinutesInTimeStep;
}
}
} else {
for (int hr = 0; hr < Constant::iHoursInDay; ++hr) {
int curMin = s_glob->MinutesInTimeStep - 1;
for (int ts = 0; ts < s_glob->TimeStepsInHour; ++ts) {
daySched->tsVals[hr * s_glob->TimeStepsInHour + ts] = minuteVals[hr * Constant::iMinutesInHour + curMin];
daySched->sumTsVals += daySched->tsVals[hr * s_glob->TimeStepsInHour + ts];
curMin += s_glob->MinutesInTimeStep;
}
}
}

daySched->interpolation = interp;
daySched->populateFromMinuteVals(state, minuteVals);
}
if (iDay == 59 && rowCnt < 8784 * hrLimitCount) { // 28 Feb
// Dup 28 Feb to 29 Feb (60)
Expand Down

3 comments on commit 72066d1

@nrel-bot-2c
Copy link

Choose a reason for hiding this comment

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

ScheduleAPI (amirroth) - x86_64-Linux-Ubuntu-24.04-gcc-13.2: OK (2861 of 2918 tests passed, 0 test warnings)

Failures:\n

API Test Summary

  • Passed: 14
  • Subprocess aborted: 2

EnergyPlusFixture Test Summary

  • Passed: 1600
  • Failed: 2
  • Subprocess aborted: 3

integration Test Summary

  • Passed: 752
  • Failed: 49

performance Test Summary

  • Passed: 16
  • Failed: 1

Build Badge Test Badge

@nrel-bot-2c
Copy link

Choose a reason for hiding this comment

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

ScheduleAPI (amirroth) - x86_64-Linux-Ubuntu-24.04-gcc-13.2-UnitTestsCoverage-RelWithDebInfo: OK (2093 of 2100 tests passed, 0 test warnings)

Failures:\n

API Test Summary

  • Passed: 14
  • Subprocess aborted: 2

EnergyPlusFixture Test Summary

  • Passed: 1600
  • Failed: 2
  • Subprocess aborted: 3

Build Badge Test Badge Coverage Badge

@nrel-bot-2c
Copy link

Choose a reason for hiding this comment

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

ScheduleAPI (amirroth) - x86_64-Linux-Ubuntu-24.04-gcc-13.2-IntegrationCoverage-RelWithDebInfo: OK (753 of 801 tests passed, 0 test warnings)

Failures:\n

integration Test Summary

  • Passed: 753
  • Failed: 48

Build Badge Test Badge Coverage Badge

Please sign in to comment.