Skip to content

Commit

Permalink
Add new function for min max by daytype and new EIO/initialization re…
Browse files Browse the repository at this point in the history
…port columns to use it.
  • Loading branch information
JasonGlazer committed Mar 13, 2024
1 parent db1a235 commit a673de6
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 6 deletions.
29 changes: 23 additions & 6 deletions src/EnergyPlus/InternalHeatGains.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3723,8 +3723,11 @@ namespace InternalHeatGains {
Format_723,
"People",
"Number of People {},People/Floor Area {person/m2},Floor Area per person {m2/person},Fraction Radiant,Fraction "
"Convected,Sensible Fraction Calculation,Activity level,ASHRAE 55 Warnings,Carbon Dioxide Generation Rate,Nominal Minimum "
"Number of People,Nominal Maximum Number of People");
"Convected,Sensible Fraction Calculation,Activity level,ASHRAE 55 Warnings,Carbon Dioxide Generation Rate,"
"Minimum Number of People for All Day Types,Maximum Number of People for All Day Types,"
"Minimum Number of People for Weekdays, Maximum Number of People for Weekdays, "
"Minimum Number of People for Weekends/Holidays, Maximum Number of People for Weekends /Holidays,"
"Minimum Number of People for Design Days, Maximum Number of People for Design Days");
if (state.dataHeatBal->People(Loop).Fanger || state.dataHeatBal->People(Loop).Pierce || state.dataHeatBal->People(Loop).KSU ||
state.dataHeatBal->People(Loop).CoolingEffectASH55 || state.dataHeatBal->People(Loop).AnkleDraftASH55) {
print(state.files.eio,
Expand Down Expand Up @@ -3777,11 +3780,27 @@ namespace InternalHeatGains {
print(state.files.eio, "No,");
}
print(state.files.eio, "{:.4R},", state.dataHeatBal->People(Loop).CO2RateFactor);
print(state.files.eio, "{:.0R},", state.dataHeatBal->People(Loop).NomMinNumberPeople);
print(state.files.eio, "{:.1R},", state.dataHeatBal->People(Loop).NomMinNumberPeople);
print(state.files.eio, "{:.1R},", state.dataHeatBal->People(Loop).NomMaxNumberPeople);

auto &thisPeople = state.dataHeatBal->People(Loop);
// weekdays
std::tie(SchMin, SchMax) = getScheduleMinMaxByDayType(state, thisPeople.NumberOfPeoplePtr, DayTypeGroup::Weekday);
print(state.files.eio, "{:.1R},", thisPeople.NumberOfPeople * SchMin);
print(state.files.eio, "{:.1R},", thisPeople.NumberOfPeople * SchMax);

// weekends/holidays
std::tie(SchMin, SchMax) = getScheduleMinMaxByDayType(state, thisPeople.NumberOfPeoplePtr, DayTypeGroup::WeekEndHoliday);
print(state.files.eio, "{:.1R},", thisPeople.NumberOfPeople * SchMin);
print(state.files.eio, "{:.1R},", thisPeople.NumberOfPeople * SchMax);

//design days
std::tie(SchMin, SchMax) = getScheduleMinMaxByDayType(state, thisPeople.NumberOfPeoplePtr, DayTypeGroup::DesignDay);
print(state.files.eio, "{:.1R},", thisPeople.NumberOfPeople * SchMin);
print(state.files.eio, "{:.1R},", thisPeople.NumberOfPeople * SchMax);

if (state.dataHeatBal->People(Loop).Fanger || state.dataHeatBal->People(Loop).Pierce || state.dataHeatBal->People(Loop).KSU ||
state.dataHeatBal->People(Loop).CoolingEffectASH55 || state.dataHeatBal->People(Loop).AnkleDraftASH55) {
print(state.files.eio, "{:.0R},", state.dataHeatBal->People(Loop).NomMaxNumberPeople);

if (state.dataHeatBal->People(Loop).MRTCalcType == DataHeatBalance::CalcMRT::EnclosureAveraged) {
print(state.files.eio, "Zone Averaged,");
Expand Down Expand Up @@ -3830,8 +3849,6 @@ namespace InternalHeatGains {
} else {
print(state.files.eio, "No\n");
}
} else {
print(state.files.eio, "{:.0R}\n", state.dataHeatBal->People(Loop).NomMaxNumberPeople);
}
}
for (int Loop = 1; Loop <= state.dataHeatBal->TotLights; ++Loop) {
Expand Down
49 changes: 49 additions & 0 deletions src/EnergyPlus/ScheduleManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4491,6 +4491,55 @@ namespace ScheduleManager {
return MaximumValue;
}

std::pair<Real64, Real64> getScheduleMinMaxByDayType(EnergyPlusData &state, int const ScheduleIndex, DayTypeGroup const days)
{
// J. Glazer - March 2024
// finds the minimum and maximum for a specific set of day types for a given schedule
Real64 MinValue = Constant::BigNumber;
Real64 MaxValue = -Constant::BigNumber;
if (ScheduleIndex == -1) {
MinValue = 1.0;
MaxValue = 1.0;
} else if (ScheduleIndex == 0) {
MinValue = 0.0;
MaxValue = 0.0;
} else if (ScheduleIndex < 1 || ScheduleIndex > state.dataScheduleMgr->NumSchedules) {
ShowFatalError(state, "getScheduleMinMaxByDayType called with ScheduleIndex out of range");
} else if (ScheduleIndex > 0) {
std::vector<bool> dayTypeFilter(maxDayTypes);
std::fill(dayTypeFilter.begin(), dayTypeFilter.end(), false);
switch (days) {
case DayTypeGroup::Weekday:
dayTypeFilter = {false, true, true, true, true, true, false, false, false, false, false, false};
break;
case DayTypeGroup::WeekEndHoliday:
dayTypeFilter = {true, false, false, false, false, false, true, true, false, false, false, false};
break;
case DayTypeGroup::DesignDay:
dayTypeFilter = {false, false, false, false, false, false, false, false, true, true, false, false};
break;
default:
dayTypeFilter = {false, false, false, false, false, false, false, false, false, false, false, false};
break;
}
for (int iDayOfYear = 1; iDayOfYear <= 366; ++iDayOfYear) {
int WkSch = state.dataScheduleMgr->Schedule(ScheduleIndex).WeekSchedulePointer(iDayOfYear);
auto &weekSch = state.dataScheduleMgr->WeekSchedule(WkSch);
for (int jType = 1; jType <= maxDayTypes; ++jType) {
if (dayTypeFilter[jType -1]) {
auto &daySch = state.dataScheduleMgr->DaySchedule;
MinValue = min(MinValue, minval(daySch(weekSch.DaySchedulePointer(jType)).TSValue));
MaxValue = max(MaxValue, maxval(daySch(weekSch.DaySchedulePointer(jType)).TSValue));
}
}
}
if (MinValue == Constant::BigNumber) MinValue = 0;
if (MaxValue == -Constant::BigNumber) MaxValue = 0;
}
return std::make_pair(MinValue, MaxValue);
}


std::string GetScheduleName(EnergyPlusData &state, int const ScheduleIndex)
{
// FUNCTION INFORMATION:
Expand Down
11 changes: 11 additions & 0 deletions src/EnergyPlus/ScheduleManager.hh
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@ namespace ScheduleManager {
extern const std::array<std::string_view, static_cast<int>(DayType::Num)> dayTypeNames;
extern const std::array<std::string_view, static_cast<int>(DayType::Num)> dayTypeNamesUC;

enum class DayTypeGroup
{
Invalid = -1,
Weekday = 1,
WeekEndHoliday,
DesignDay,
Num
};

enum class SchedType : int
{
Invalid = -1,
Expand Down Expand Up @@ -339,6 +348,8 @@ namespace ScheduleManager {

Real64 GetScheduleMaxValue(EnergyPlusData &state, int const ScheduleIndex); // Which Schedule being tested

std::pair<Real64, Real64> getScheduleMinMaxByDayType(EnergyPlusData &state, int const ScheduleIndex, DayTypeGroup const days);

std::string GetScheduleName(EnergyPlusData &state, int const ScheduleIndex);

void ReportScheduleValues(EnergyPlusData &state);
Expand Down

0 comments on commit a673de6

Please sign in to comment.