Question-and-Answer Resource for the Building Energy Modeling Community
Get started with the Help page

# Calculating total annual schedule hours using OpenStudio measure I'm trying to figure out how to calculate total annual schedule hours for a ScheduleRuleset using an OS measure. Consider the following application. Given a total annual hot water consumption value (gal/year), and a proposed fractional schedule for usage (with any number of Rules to specify different schedules for weekdays, weekends, seasonal closure periods, etc.), calculate the peak flow rate input you should specify for the WaterUseEquipment object.

edit retag close merge delete

Sort by » oldest newest most voted

Here is a method to get the annual full load hours from a ScheduleRuleset. Add this to your measure.rb file:

# Get the annual full load hours from a ScheduleRuleset

# Define the start and end date
year_start_date = OpenStudio::Date.new(OpenStudio::MonthOfYear.new("January"),1)
year_end_date = OpenStudio::Date.new(OpenStudio::MonthOfYear.new("December"),31)

# Get the ordered list of all the day schedules
# that are used by this schedule ruleset
day_schs = sch_ruleset.getDaySchedules(year_start_date, year_end_date)

# Get a 365-value array of which schedule is used on each day of the year,
day_schs_used_each_day = sch_ruleset.getActiveRuleIndices(year_start_date, year_end_date)

# Create a map that shows how many days each schedule is used
day_sch_freq = day_schs_used_each_day.group_by { |n| n }

# Loop through each of the schedules that is used, figure out the
# full load hours for that day, then multiply this by the number
# of days that day schedule applies and add this to the total.
annual_flh = 0
default_day_sch = sch_ruleset.defaultDaySchedule
day_sch_freq.each do |freq|

#puts freq.inspect
#exit

sch_index = freq
number_of_days_sch_used = freq.size

# Get the day schedule at this index
day_sch = nil
if sch_index == -1 # If index = -1, this day uses the default day schedule (not a rule)
day_sch = default_day_sch
else
day_sch = day_schs[sch_index]
end

# Determine the full load hours for just one day
daily_flh = 0
day_sch.values.each do |val|
daily_flh += val
end

# Warn if the daily flh is more than 24,
# which would indicate that this isn't a
# fractional schedule.
if daily_flh > 24
return 0
end

# Multiply the daily flh by the number
# of days this schedule is used per year
# and add this to the overall total
annual_flh += daily_flh * number_of_days_sch_used

end

return annual_flh

end


Here is how you'd use it:

annual_flh = get_annual_full_load_hrs(sch_ruleset)


And once you know the annualflh, the target peak flow rate = desired annual total / annualflh

more

I would calculate the total value for each of the day schedules, then use this method

https://github.com/NREL/OpenStudio/bl...

to figure out which day schedule is active throughout the year. Then you can just add up all the values for the active day schedules.

more