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

Revision history [back]

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
def get_annual_full_load_hrs(sch_ruleset)

  # 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[0]
    number_of_days_sch_used = freq[1].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 annual_flh, the target peak flow rate = desired annual total / annual_flh