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

converting compact schedule to ruleset schedule

asked 2017-11-05 02:58:59 -0600

Avi's avatar

updated 2017-11-06 14:30:52 -0600

I am trying to write measure to translate compact Schedule into ruleset schedule which I find painful. Am I trying to do something that was already done? Are there any native OS methods to do that?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2017-11-25 06:44:50 -0600

Avi's avatar

updated 2017-11-25 07:01:32 -0600

I ended up writing a measure to convert compact schedule to ruleset schedule. Though not optimal it seems to work.

edit flag offensive delete link more
3

answered 2017-11-06 11:24:08 -0600

The OsLib_Schedules.rb file in several of the BCL HVAC measures has some code to make a schedule from a set of values.

You can use this to translate a compact schedule to a ruleset schedule.

Example code:

require 'openstudio'

#this is just for testing
model = OpenStudio::Model::Model.new()
new_schedule = OpenStudio::Model::ScheduleCompact.new(model,0.5)
new_schedule.setName("Example Compact Schedule")

#createSimpleSchedule code from the OsLib_Schedules library
def createSimpleSchedule(model, options = {})

  defaults = {
      "name" => nil,
      "winterTimeValuePairs" => {24.0 => 0.0},
      "summerTimeValuePairs" => {24.0 => 1.0},
      "defaultTimeValuePairs" => {24.0 => 1.0},
  }

  # merge user inputs with defaults
  options = defaults.merge(options)

  #ScheduleRuleset
  sch_ruleset = OpenStudio::Model::ScheduleRuleset.new(model)
  if options["name"]
    sch_ruleset.setName(options["name"])
  end

  #Winter Design Day
  winter_dsn_day = OpenStudio::Model::ScheduleDay.new(model)
  sch_ruleset.setWinterDesignDaySchedule(winter_dsn_day)
  winter_dsn_day = sch_ruleset.winterDesignDaySchedule
  winter_dsn_day.setName("#{sch_ruleset.name} Winter Design Day")
  options["winterTimeValuePairs"].each do |k,v|
    hour = k.truncate
    min = ((k - hour)*60).to_i
    winter_dsn_day.addValue(OpenStudio::Time.new(0, hour, min, 0),v)
  end

  #Summer Design Day
  summer_dsn_day = OpenStudio::Model::ScheduleDay.new(model)
  sch_ruleset.setSummerDesignDaySchedule(summer_dsn_day)
  summer_dsn_day = sch_ruleset.summerDesignDaySchedule
  summer_dsn_day.setName("#{sch_ruleset.name} Summer Design Day")
  options["summerTimeValuePairs"].each do |k,v|
    hour = k.truncate
    min = ((k - hour)*60).to_i
    summer_dsn_day.addValue(OpenStudio::Time.new(0, hour, min, 0),v)
  end

  #All Days
  week_day = sch_ruleset.defaultDaySchedule
  week_day.setName("#{sch_ruleset.name} Schedule Week Day")
  options["defaultTimeValuePairs"].each do |k,v|
    hour = k.truncate
    min = ((k - hour)*60).to_i
    week_day.addValue(OpenStudio::Time.new(0, hour, min, 0),v)
  end

  result = sch_ruleset
  return result

end #end of createSimpleSchedule

#get the value from the compact schedule
compact_sch = model.getScheduleCompactByName("Example Compact Schedule").get
compact_sch_val = compact_sch.constantValue.get 

#create options and call createSimpleSchedule
options_generic_schedule = {"name" => "My Generic Ruleset Schedule",
                       "winterTimeValuePairs" => {24.0 => compact_sch_val},
                       "summerTimeValuePairs" => {24.0 => compact_sch_val},
                       "defaultTimeValuePairs" => {24.0 => compact_sch_val}}
generic_ruleset_schedule = createSimpleSchedule(model, options_generic_schedule)
edit flag offensive delete link more

Comments

@mdahlhausen Would that work for Compact schedule with values changing all year long?

Avi's avatar Avi  ( 2017-11-06 12:52:39 -0600 )edit

no; it is just for a singular value. If you want, you can specify the schedule in more detail with the createComplexSchedule code in the OsLib_Schedules library.

mdahlhausen's avatar mdahlhausen  ( 2017-11-06 12:59:55 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Training Workshops

Careers

Question Tools

1 follower

Stats

Asked: 2017-11-05 02:58:59 -0600

Seen: 331 times

Last updated: Nov 25 '17