diff --git a/HPXMLtoOpenStudio/measure.xml b/HPXMLtoOpenStudio/measure.xml
index 5f8ffc105d..4fc0c7516b 100644
--- a/HPXMLtoOpenStudio/measure.xml
+++ b/HPXMLtoOpenStudio/measure.xml
@@ -3,8 +3,8 @@
3.1
hpxm_lto_openstudio
b1543b30-9465-45ff-ba04-1d1f85e763bc
- 2ecbdcc0-d0e3-4c8f-b8f8-a839e9bdbee1
- 2024-10-04T17:02:56Z
+ 1424b04d-aae3-4360-9d50-3324d0babb33
+ 2024-10-05T18:13:33Z
D8922A73
HPXMLtoOpenStudio
HPXML to OpenStudio Translator
@@ -189,7 +189,7 @@
airflow.rb
rb
resource
- AAA32BAD
+ CA1394A8
battery.rb
@@ -213,7 +213,7 @@
constructions.rb
rb
resource
- 5D07F8B2
+ B3B897EB
data/Xing_okstate_0664D_13659_Table_A-3.csv
@@ -345,13 +345,13 @@
geometry.rb
rb
resource
- 7E3D612D
+ 6C147EFE
hotwater_appliances.rb
rb
resource
- E9F876DA
+ 4A5DFE48
hpxml.rb
@@ -387,7 +387,7 @@
hvac.rb
rb
resource
- 3F8A3A86
+ CEDAF4B3
hvac_sizing.rb
@@ -447,7 +447,7 @@
model.rb
rb
resource
- 6933774F
+ A578B92B
output.rb
@@ -591,7 +591,7 @@
schedules.rb
rb
resource
- B73029E3
+ BB101800
simcontrols.rb
@@ -627,7 +627,7 @@
waterheater.rb
rb
resource
- 1E7D40B1
+ 790B832E
weather.rb
@@ -647,6 +647,12 @@
resource
93120E27
+
+ in.schedules.csv
+ csv
+ test
+ C8EBFF38
+
test_airflow.rb
rb
@@ -723,7 +729,7 @@
test_schedules.rb
rb
test
- 703BFE7A
+ 62B8CE90
test_simcontrols.rb
diff --git a/HPXMLtoOpenStudio/resources/airflow.rb b/HPXMLtoOpenStudio/resources/airflow.rb
index 6a6c3fd4bf..1c525d38e6 100644
--- a/HPXMLtoOpenStudio/resources/airflow.rb
+++ b/HPXMLtoOpenStudio/resources/airflow.rb
@@ -635,27 +635,32 @@ def self.apply_natural_ventilation_and_whole_house_fan(runner, model, spaces, hp
# @param unavailable_periods [HPXML::UnavailablePeriods] Object that defines periods for, e.g., power outages or vacancies
# @return [TODO] TODO
def self.create_nv_and_whf_avail_sch(model, obj_name, num_days_per_week, unavailable_periods)
- avail_sch = OpenStudio::Model::ScheduleRuleset.new(model)
sch_name = "#{obj_name} schedule"
- avail_sch.setName(sch_name)
- avail_sch.defaultDaySchedule.setName("#{sch_name} default day")
- Schedule.set_schedule_type_limits(model, avail_sch, EPlus::ScheduleTypeLimitsOnOff)
- on_rule = OpenStudio::Model::ScheduleRule.new(avail_sch)
- on_rule.setName("#{sch_name} rule")
- on_rule_day = on_rule.daySchedule
- on_rule_day.setName("#{sch_name} avail day")
- on_rule_day.addValue(OpenStudio::Time.new(0, 24, 0, 0), 1)
- method_array = ['setApplyMonday', 'setApplyWednesday', 'setApplyFriday', 'setApplySaturday', 'setApplyTuesday', 'setApplyThursday', 'setApplySunday']
- for i in 1..7 do
- if num_days_per_week >= i
- on_rule.public_send(method_array[i - 1], true)
- end
- end
- on_rule.setStartDate(OpenStudio::Date::fromDayOfYear(1))
- on_rule.setEndDate(OpenStudio::Date::fromDayOfYear(365))
+ avail_sch = Model.add_schedule_ruleset(
+ model,
+ name: sch_name,
+ limits: EPlus::ScheduleTypeLimitsOnOff
+ )
+
+ # Apply to days in this order: Mon, Wed, Fri, Sat, Tues, Thurs, Sun
+ apply_to_days = [0] * 7
+ apply_to_days[0] = 1 if num_days_per_week >= 7
+ apply_to_days[1] = 1 if num_days_per_week >= 1
+ apply_to_days[2] = 1 if num_days_per_week >= 5
+ apply_to_days[3] = 1 if num_days_per_week >= 2
+ apply_to_days[4] = 1 if num_days_per_week >= 6
+ apply_to_days[5] = 1 if num_days_per_week >= 3
+ apply_to_days[6] = 1 if num_days_per_week >= 4
+
+ Model.add_schedule_ruleset_rule(
+ avail_sch,
+ start_date: OpenStudio::Date::fromDayOfYear(1),
+ end_date: OpenStudio::Date::fromDayOfYear(365),
+ apply_to_days: apply_to_days,
+ hourly_values: [1] * 24
+ )
- year = model.getYearDescription.assumedYear
- Schedule.set_unavailable_periods(avail_sch, sch_name, unavailable_periods, year)
+ Schedule.set_unavailable_periods(model, avail_sch, sch_name, unavailable_periods)
return avail_sch
end
diff --git a/HPXMLtoOpenStudio/resources/constructions.rb b/HPXMLtoOpenStudio/resources/constructions.rb
index a5e7a15a47..36c34aca50 100644
--- a/HPXMLtoOpenStudio/resources/constructions.rb
+++ b/HPXMLtoOpenStudio/resources/constructions.rb
@@ -2104,7 +2104,8 @@ def self.apply_window_skylight_shading(model, window_or_skylight, sub_surface, s
sf_sch = Model.add_schedule_constant(
model,
name: sch_name,
- value: sf_values[0][0]
+ value: sf_values[0][0],
+ limits: EPlus::ScheduleTypeLimitsFraction
)
else
sf_sch = HourlyByDaySchedule.new(model, sch_name, sf_values, sf_values, EPlus::ScheduleTypeLimitsFraction, false).schedule
diff --git a/HPXMLtoOpenStudio/resources/geometry.rb b/HPXMLtoOpenStudio/resources/geometry.rb
index 47d1bb945e..36965be122 100644
--- a/HPXMLtoOpenStudio/resources/geometry.rb
+++ b/HPXMLtoOpenStudio/resources/geometry.rb
@@ -1802,7 +1802,8 @@ def self.get_space_temperature_schedule(model, location, spaces)
sch = Model.add_schedule_constant(
model,
name: location,
- value: nil
+ value: nil,
+ limits: EPlus::ScheduleTypeLimitsTemperature
)
sch.additionalProperties.setFeature('ObjectType', location)
@@ -1839,11 +1840,6 @@ def self.get_space_temperature_schedule(model, location, spaces)
end
end
- # Schedule type limits compatible
- schedule_type_limits = OpenStudio::Model::ScheduleTypeLimits.new(model)
- schedule_type_limits.setUnitType('Temperature')
- sch.setScheduleTypeLimits(schedule_type_limits)
-
# Sensors
if space_values[:indoor_weight] > 0
if not spaces[HPXML::LocationConditionedSpace].thermalZone.get.thermostatSetpointDualSetpoint.is_initialized
diff --git a/HPXMLtoOpenStudio/resources/hotwater_appliances.rb b/HPXMLtoOpenStudio/resources/hotwater_appliances.rb
index e8b66f0755..124cc2bed4 100644
--- a/HPXMLtoOpenStudio/resources/hotwater_appliances.rb
+++ b/HPXMLtoOpenStudio/resources/hotwater_appliances.rb
@@ -407,9 +407,9 @@ def self.apply(runner, model, weather, spaces, hpxml_bldg, hpxml_header, schedul
mw_temp_schedule = Model.add_schedule_constant(
model,
name: 'mixed water temperature schedule',
- value: UnitConversions.convert(t_mix, 'F', 'C')
+ value: UnitConversions.convert(t_mix, 'F', 'C'),
+ limits: EPlus::ScheduleTypeLimitsTemperature
)
- Schedule.set_schedule_type_limits(model, mw_temp_schedule, EPlus::ScheduleTypeLimitsTemperature)
# Create schedule
fixtures_schedule = nil
diff --git a/HPXMLtoOpenStudio/resources/hvac.rb b/HPXMLtoOpenStudio/resources/hvac.rb
index e5520e18fb..a690a86e4c 100644
--- a/HPXMLtoOpenStudio/resources/hvac.rb
+++ b/HPXMLtoOpenStudio/resources/hvac.rb
@@ -940,7 +940,8 @@ def self.apply_boiler(model, runner, heating_system, hvac_sequential_load_fracs,
supply_setpoint = Model.add_schedule_constant(
model,
name: "#{obj_name} hydronic heat supply setpoint",
- value: UnitConversions.convert(design_temp, 'F', 'C')
+ value: UnitConversions.convert(design_temp, 'F', 'C'),
+ limits: EPlus::ScheduleTypeLimitsTemperature
)
setpoint_manager = OpenStudio::Model::SetpointManagerScheduled.new(model, supply_setpoint)
@@ -2570,9 +2571,9 @@ def self.create_air_loop_unitary_system(model, obj_name, fan, htg_coil, clg_coil
cycle_fan_sch = Model.add_schedule_constant(
model,
name: "#{obj_name} auto fan schedule",
- value: 0
- ) # 0 denotes that fan cycles on and off to meet the load (i.e., AUTO fan) as opposed to continuous operation
- Schedule.set_schedule_type_limits(model, cycle_fan_sch, EPlus::ScheduleTypeLimitsOnOff)
+ value: 0, # 0 denotes that fan cycles on and off to meet the load (i.e., AUTO fan) as opposed to continuous operation
+ limits: EPlus::ScheduleTypeLimitsOnOff
+ )
air_loop_unitary = OpenStudio::Model::AirLoopHVACUnitarySystem.new(model)
air_loop_unitary.setName(obj_name + ' unitary system')
@@ -4603,10 +4604,8 @@ def self.get_sequential_load_schedule(model, fractions, unavailable_periods)
s = ScheduleConstant.new(model, sch_name, values[0], EPlus::ScheduleTypeLimitsFraction, unavailable_periods: unavailable_periods)
s = s.schedule
else
- s = Schedule.create_ruleset_from_daily_season(model, values)
- s.setName(sch_name)
- Schedule.set_unavailable_periods(s, sch_name, unavailable_periods, model.getYearDescription.assumedYear)
- Schedule.set_schedule_type_limits(model, s, EPlus::ScheduleTypeLimitsFraction)
+ s = Schedule.create_ruleset_from_daily_season(model, sch_name, values)
+ Schedule.set_unavailable_periods(model, s, sch_name, unavailable_periods)
end
return s
diff --git a/HPXMLtoOpenStudio/resources/model.rb b/HPXMLtoOpenStudio/resources/model.rb
index 8dd87ca6c4..a30aacbbc5 100644
--- a/HPXMLtoOpenStudio/resources/model.rb
+++ b/HPXMLtoOpenStudio/resources/model.rb
@@ -542,14 +542,151 @@ def self.add_curve_quint_linear(model, name:, coeff:)
# @param model [OpenStudio::Model::Model] OpenStudio Model object
# @param name [String] Name for the OpenStudio object
# @param value [Double] Constant value for the year
+ # @param limits [String] Data type for the values contained in the schedule (EPlus::ScheduleTypeXXX)
# @return [OpenStudio::Model::ScheduleConstant] The model object
- def self.add_schedule_constant(model, name:, value:)
+ def self.add_schedule_constant(model, name:, value:, limits: nil)
sch = OpenStudio::Model::ScheduleConstant.new(model)
sch.setName(name)
sch.setValue(value) unless value.nil? # EMS-actuated if nil
+ add_schedule_type_limits(model, schedule: sch, limits: limits)
return sch
end
+ # Adds a ScheduleRuleset object to the OpenStudio model.
+ #
+ # @param model [OpenStudio::Model::Model] OpenStudio Model object
+ # @param name [String] Name for the OpenStudio object
+ # @param limits [String] Data type for the values contained in the schedule (EPlus::ScheduleTypeXXX)
+ # @return [OpenStudio::Model::ScheduleRuleset] The model object
+ def self.add_schedule_ruleset(model, name:, limits: nil)
+ sch = OpenStudio::Model::ScheduleRuleset.new(model)
+ sch.setName(name)
+ sch.defaultDaySchedule.setName("#{name} default day")
+ add_schedule_type_limits(model, schedule: sch, limits: limits)
+ return sch
+ end
+
+ # Adds a ScheduleRule object to the OpenStudio model for a given ruleset.
+ #
+ # @param schedule [OpenStudio::Model::ScheduleRuleset] The ruleset to which the rule applies
+ # @param start_date [OpenStudio::Date] Start date
+ # @param end_date [OpenStudio::Date] End data
+ # @param apply_to_days [Array] Values for Sun, Mon, ..., Sat, where 1 means the rule applies
+ # @param hourly_values [Array] 24 hourly values
+ # @return [OpenStudio::Model::ScheduleRule] The model object
+ def self.add_schedule_ruleset_rule(schedule, start_date:, end_date:, apply_to_days: [1, 1, 1, 1, 1, 1, 1], hourly_values:)
+ rule = OpenStudio::Model::ScheduleRule.new(schedule)
+
+ if (not apply_to_days.is_a? Array) || (apply_to_days.size != 7)
+ fail 'Unexpected apply_to_days.'
+ end
+
+ # Allow for either 0-based or 1-based array for now
+ # FUTURE: Restrict to 0-based
+ if (not hourly_values.is_a? Array) || (hourly_values.size != 24 && hourly_values.size != 25)
+ fail 'Unexpected hourly_values.'
+ end
+
+ if hourly_values.size == 24
+ hourly_values = [nil] + hourly_values
+ end
+
+ if apply_to_days == [1, 1, 1, 1, 1, 1, 1]
+ rule.setName("#{schedule.name} allday rule")
+ elsif apply_to_days == [0, 1, 1, 1, 1, 1, 0]
+ rule.setName("#{schedule.name} weekday rule")
+ elsif apply_to_days == [1, 0, 0, 0, 0, 0, 1]
+ rule.setName("#{schedule.name} weekend rule")
+ else
+ rule.setName("#{schedule.name} rule")
+ end
+ rule.setStartDate(start_date)
+ rule.setEndDate(end_date)
+ rule.setApplySunday(apply_to_days[0])
+ rule.setApplyMonday(apply_to_days[1])
+ rule.setApplyTuesday(apply_to_days[2])
+ rule.setApplyWednesday(apply_to_days[3])
+ rule.setApplyThursday(apply_to_days[4])
+ rule.setApplyFriday(apply_to_days[5])
+ rule.setApplySaturday(apply_to_days[6])
+
+ day_sch = rule.daySchedule
+ day_sch.setName("#{schedule.name} day")
+
+ previous_value = hourly_values[1]
+ for h in 1..24
+ next if (h != 24) && (hourly_values[h + 1] == previous_value)
+
+ day_sch.addValue(OpenStudio::Time.new(0, h, 0, 0), previous_value)
+ previous_value = hourly_values[h + 1]
+ end
+
+ return rule
+ end
+
+ # Adds a ScheduleFile object to the OpenStudio model.
+ #
+ # @param model [OpenStudio::Model::Model] OpenStudio Model object
+ # @param name [String] Name for the OpenStudio object
+ # @param file_path [String] Full path to the CSV schedule file
+ # @param col_num [Integer] The column number with the desired schedule values; first column is 1
+ # @param rows_to_skip [Integer] The number of header rows to skip
+ # @param num_hours [Integer] Number of hours of data, should be 8760 of 8784
+ # @param mins_per_item [Integer] Number of minutes associated with each line of the file
+ # @param limits [String] Data type for the values contained in the schedule (EPlus::ScheduleTypeXXX)
+ # @return [OpenStudio::Model::ScheduleFile] The model object
+ def self.add_schedule_file(model, name:, file_path:, col_num:, rows_to_skip:, num_hours:, mins_per_item:, limits: nil)
+ file_dir = File.dirname(file_path)
+ if not model.workflowJSON.filePaths.map(&:to_s).include?(file_dir)
+ model.workflowJSON.addFilePath(file_dir)
+ end
+
+ sch = OpenStudio::Model::ScheduleFile.new(model, File.basename(file_path))
+ sch.setName(name)
+ sch.setColumnNumber(col_num)
+ sch.setRowstoSkipatTop(rows_to_skip)
+ sch.setNumberofHoursofData(num_hours)
+ sch.setMinutesperItem(mins_per_item)
+ sch.setTranslateFileWithRelativePath(true)
+ add_schedule_type_limits(model, schedule: sch, limits: limits)
+ return sch
+ end
+
+ # Adds a OpenStudio::Model::ScheduleTypeLimits object to the OpenStuio model (unless
+ # one has already been added) and assigns the schedule to it.
+ #
+ # @param model [OpenStudio::Model::Model] OpenStudio Model object
+ # @param schedule [OpenStudio::Model::Schedule] The schedule of interest
+ # @param limits [String] Data type for the values contained in the schedule (EPlus::ScheduleTypeXXX)
+ # @return [OpenStudio::Model::ScheduleTypeLimits] The model object
+ def self.add_schedule_type_limits(model, schedule:, limits:)
+ return if limits.nil?
+
+ stl = model.getScheduleTypeLimitss.find { |stl| stl.name.to_s == limits }
+
+ if stl.nil?
+ stl = OpenStudio::Model::ScheduleTypeLimits.new(model)
+ stl.setName(limits)
+ if limits == EPlus::ScheduleTypeLimitsFraction
+ stl.setLowerLimitValue(0)
+ stl.setUpperLimitValue(1)
+ stl.setNumericType('Continuous')
+ elsif limits == EPlus::ScheduleTypeLimitsOnOff
+ stl.setLowerLimitValue(0)
+ stl.setUpperLimitValue(1)
+ stl.setNumericType('Discrete')
+ elsif limits == EPlus::ScheduleTypeLimitsTemperature
+ stl.setUnitType('Temperature')
+ else
+ fail "Unexpected schedule type limits: #{limits}"
+ end
+ end
+
+ schedule.setScheduleTypeLimits(stl)
+
+ return stl
+ end
+
# Adds an EnergyManagementSystemSensor to the OpenStudio model.
#
# The EnergyManagementSystemSensor object gets information during the simulation
diff --git a/HPXMLtoOpenStudio/resources/schedules.rb b/HPXMLtoOpenStudio/resources/schedules.rb
index 9532fb3939..3e5fe80170 100644
--- a/HPXMLtoOpenStudio/resources/schedules.rb
+++ b/HPXMLtoOpenStudio/resources/schedules.rb
@@ -8,8 +8,7 @@ class ScheduleConstant
# @param schedule_type_limits_name [String] data type for the values contained in the schedule
# @param unavailable_periods [HPXML::UnavailablePeriods] Object that defines periods for, e.g., power outages or vacancies
def initialize(model, sch_name, val = 1.0, schedule_type_limits_name = nil, unavailable_periods: [])
- year = model.getYearDescription.assumedYear
- @schedule = create_schedule(model, sch_name, val, year, schedule_type_limits_name, unavailable_periods)
+ @schedule = create_schedule(model, sch_name, val, schedule_type_limits_name, unavailable_periods)
end
attr_accessor(:schedule)
@@ -21,11 +20,10 @@ def initialize(model, sch_name, val = 1.0, schedule_type_limits_name = nil, unav
# @param model [OpenStudio::Model::Model] OpenStudio Model object
# @param sch_name [String] name that is assigned to the OpenStudio Schedule object
# @param val [Double] the constant schedule value
- # @param year [Integer] the calendar year
# @param schedule_type_limits_name [String] data type for the values contained in the schedule
# @param unavailable_periods [HPXML::UnavailablePeriods] Object that defines periods for, e.g., power outages or vacancies
# @return [OpenStudio::Model::ScheduleConstant or OpenStudio::Model::ScheduleRuleset] the OpenStudio Schedule object with constant schedule
- def create_schedule(model, sch_name, val, year, schedule_type_limits_name, unavailable_periods)
+ def create_schedule(model, sch_name, val, schedule_type_limits_name, unavailable_periods)
if unavailable_periods.empty?
if val == 1.0 && (schedule_type_limits_name.nil? || schedule_type_limits_name == EPlus::ScheduleTypeLimitsOnOff)
schedule = model.alwaysOnDiscreteSchedule
@@ -35,23 +33,22 @@ def create_schedule(model, sch_name, val, year, schedule_type_limits_name, unava
schedule = Model.add_schedule_constant(
model,
name: sch_name,
- value: val
+ value: val,
+ limits: schedule_type_limits_name
)
-
- Schedule.set_schedule_type_limits(model, schedule, schedule_type_limits_name)
end
else
- schedule = OpenStudio::Model::ScheduleRuleset.new(model)
- schedule.setName(sch_name)
- schedule.defaultDaySchedule.setName(sch_name + ' default day')
+ schedule = Model.add_schedule_ruleset(
+ model,
+ name: sch_name,
+ limits: schedule_type_limits_name
+ )
default_day_sch = schedule.defaultDaySchedule
default_day_sch.clearValues
default_day_sch.addValue(OpenStudio::Time.new(0, 24, 0, 0), val)
- Schedule.set_unavailable_periods(schedule, sch_name, unavailable_periods, year)
-
- Schedule.set_schedule_type_limits(model, schedule, schedule_type_limits_name)
+ Schedule.set_unavailable_periods(model, schedule, sch_name, unavailable_periods)
end
return schedule
@@ -69,7 +66,6 @@ class HourlyByMonthSchedule
# @param unavailable_periods [HPXML::UnavailablePeriods] Object that defines periods for, e.g., power outages or vacancies
def initialize(model, sch_name, weekday_month_by_hour_values, weekend_month_by_hour_values,
schedule_type_limits_name = nil, normalize_values = true, unavailable_periods: nil)
- year = model.getYearDescription.assumedYear
@weekday_month_by_hour_values = validate_values(weekday_month_by_hour_values, 12, 24)
@weekend_month_by_hour_values = validate_values(weekend_month_by_hour_values, 12, 24)
if normalize_values
@@ -77,7 +73,7 @@ def initialize(model, sch_name, weekday_month_by_hour_values, weekend_month_by_h
else
@maxval = 1.0
end
- @schedule = create_schedule(model, sch_name, year, schedule_type_limits_name, unavailable_periods)
+ @schedule = create_schedule(model, sch_name, schedule_type_limits_name, unavailable_periods)
end
attr_accessor(:schedule, :maxval)
@@ -130,33 +126,27 @@ def calc_max_val()
#
# @param model [OpenStudio::Model::Model] OpenStudio Model object
# @param sch_name [String] name that is assigned to the OpenStudio Schedule object
- # @param year [Integer] the calendar year
# @param schedule_type_limits_name [String] data type for the values contained in the schedule
# @param unavailable_periods [HPXML::UnavailablePeriods] Object that defines periods for, e.g., power outages or vacancies
# @return [OpenStudio::Model::Ruleset] the OpenStudio Schedule object with rules
- def create_schedule(model, sch_name, year, schedule_type_limits_name, unavailable_periods)
+ def create_schedule(model, sch_name, schedule_type_limits_name, unavailable_periods)
+ year = model.getYearDescription.assumedYear
day_startm = Calendar.day_start_months(year)
day_endm = Calendar.day_end_months(year)
- time = []
- for h in 1..24
- time[h] = OpenStudio::Time.new(0, h, 0, 0)
- end
-
- schedule = OpenStudio::Model::ScheduleRuleset.new(model)
- schedule.setName(sch_name)
- schedule.defaultDaySchedule.setName(sch_name + ' default day')
+ schedule = Model.add_schedule_ruleset(
+ model,
+ name: sch_name,
+ limits: schedule_type_limits_name
+ )
- prev_wkdy_vals = nil
- prev_wkdy_rule = nil
- prev_wknd_vals = nil
- prev_wknd_rule = nil
+ prev_wkdy_vals, prev_wkdy_rule = nil, nil
+ prev_wknd_vals, prev_wknd_rule = nil, nil
for m in 1..12
date_s = OpenStudio::Date::fromDayOfYear(day_startm[m - 1], year)
date_e = OpenStudio::Date::fromDayOfYear(day_endm[m - 1], year)
- wkdy_vals = []
- wknd_vals = []
+ wkdy_vals, wknd_vals = [], []
for h in 1..24
wkdy_vals[h] = (@weekday_month_by_hour_values[m - 1][h - 1]) / @maxval
wknd_vals[h] = (@weekend_month_by_hour_values[m - 1][h - 1]) / @maxval
@@ -167,67 +157,35 @@ def create_schedule(model, sch_name, year, schedule_type_limits_name, unavailabl
prev_wkdy_rule.setEndDate(date_e) unless prev_wkdy_rule.nil?
prev_wknd_rule.setEndDate(date_e) unless prev_wknd_rule.nil?
elsif wkdy_vals == wknd_vals
- # Alldays
- wkdy_rule = OpenStudio::Model::ScheduleRule.new(schedule)
- wkdy_rule.setName(sch_name + " #{Schedule.allday_name} ruleset#{m}")
- wkdy = wkdy_rule.daySchedule
- wkdy.setName(sch_name + " #{Schedule.allday_name}#{m}")
- previous_value = wkdy_vals[1]
- for h in 1..24
- next if (h != 24) && (wkdy_vals[h + 1] == previous_value)
-
- wkdy.addValue(time[h], previous_value)
- previous_value = wkdy_vals[h + 1]
- end
- Schedule.set_weekday_rule(wkdy_rule)
- Schedule.set_weekend_rule(wkdy_rule)
- wkdy_rule.setStartDate(date_s)
- wkdy_rule.setEndDate(date_e)
- prev_wkdy_rule = wkdy_rule
- prev_wknd_rule = nil
+ alld_rule = Model.add_schedule_ruleset_rule(
+ schedule,
+ start_date: date_s,
+ end_date: date_e,
+ hourly_values: wkdy_vals
+ )
+ prev_wkdy_rule, prev_wknd_rule = alld_rule, nil
else
- # Weekdays
- wkdy_rule = OpenStudio::Model::ScheduleRule.new(schedule)
- wkdy_rule.setName(sch_name + " #{Schedule.weekday_name} ruleset#{m}")
- wkdy = wkdy_rule.daySchedule
- wkdy.setName(sch_name + " #{Schedule.weekday_name}#{m}")
- previous_value = wkdy_vals[1]
- for h in 1..24
- next if (h != 24) && (wkdy_vals[h + 1] == previous_value)
-
- wkdy.addValue(time[h], previous_value)
- previous_value = wkdy_vals[h + 1]
- end
- Schedule.set_weekday_rule(wkdy_rule)
- wkdy_rule.setStartDate(date_s)
- wkdy_rule.setEndDate(date_e)
- prev_wkdy_rule = wkdy_rule
-
- # Weekends
- wknd_rule = OpenStudio::Model::ScheduleRule.new(schedule)
- wknd_rule.setName(sch_name + " #{Schedule.weekend_name} ruleset#{m}")
- wknd = wknd_rule.daySchedule
- wknd.setName(sch_name + " #{Schedule.weekend_name}#{m}")
- previous_value = wknd_vals[1]
- for h in 1..24
- next if (h != 24) && (wknd_vals[h + 1] == previous_value)
-
- wknd.addValue(time[h], previous_value)
- previous_value = wknd_vals[h + 1]
- end
- Schedule.set_weekend_rule(wknd_rule)
- wknd_rule.setStartDate(date_s)
- wknd_rule.setEndDate(date_e)
- prev_wknd_rule = wknd_rule
+ wkdy_rule = Model.add_schedule_ruleset_rule(
+ schedule,
+ start_date: date_s,
+ end_date: date_e,
+ apply_to_days: [0, 1, 1, 1, 1, 1, 0],
+ hourly_values: wkdy_vals
+ )
+ wknd_rule = Model.add_schedule_ruleset_rule(
+ schedule,
+ start_date: date_s,
+ end_date: date_e,
+ apply_to_days: [1, 0, 0, 0, 0, 0, 1],
+ hourly_values: wknd_vals
+ )
+ prev_wkdy_rule, prev_wknd_rule = wkdy_rule, wknd_rule
end
- prev_wkdy_vals = wkdy_vals
- prev_wknd_vals = wknd_vals
+ prev_wkdy_vals, prev_wknd_vals = wkdy_vals, wknd_vals
end
- Schedule.set_unavailable_periods(schedule, sch_name, unavailable_periods, year)
-
- Schedule.set_schedule_type_limits(model, schedule, schedule_type_limits_name)
+ Schedule.set_unavailable_periods(model, schedule, sch_name, unavailable_periods)
return schedule
end
@@ -243,8 +201,7 @@ class HourlyByDaySchedule
# @param unavailable_periods [HPXML::UnavailablePeriods] Object that defines periods for, e.g., power outages or vacancies
def initialize(model, sch_name, weekday_day_by_hour_values, weekend_day_by_hour_values,
schedule_type_limits_name = nil, normalize_values = true, unavailable_periods: nil)
- year = model.getYearDescription.assumedYear
- num_days = Calendar.num_days_in_year(year)
+ num_days = Calendar.num_days_in_year(model.getYearDescription.assumedYear)
@weekday_day_by_hour_values = validate_values(weekday_day_by_hour_values, num_days, 24)
@weekend_day_by_hour_values = validate_values(weekend_day_by_hour_values, num_days, 24)
if normalize_values
@@ -252,7 +209,7 @@ def initialize(model, sch_name, weekday_day_by_hour_values, weekend_day_by_hour_
else
@maxval = 1.0
end
- @schedule = create_schedule(model, sch_name, year, num_days, schedule_type_limits_name, unavailable_periods)
+ @schedule = create_schedule(model, sch_name, num_days, schedule_type_limits_name, unavailable_periods)
end
attr_accessor(:schedule, :maxval)
@@ -305,31 +262,26 @@ def calc_max_val()
#
# @param model [OpenStudio::Model::Model] OpenStudio Model object
# @param sch_name [String] name that is assigned to the OpenStudio Schedule object
- # @param year [Integer] the calendar year
# @param num_days [Integer] the number of days in the calendar year
# @param schedule_type_limits_name [String] data type for the values contained in the schedule
# @param unavailable_periods [HPXML::UnavailablePeriods] Object that defines periods for, e.g., power outages or vacancies
# @return [OpenStudio::Model::Ruleset] the OpenStudio Schedule object with rules
- def create_schedule(model, sch_name, year, num_days, schedule_type_limits_name, unavailable_periods)
- time = []
- for h in 1..24
- time[h] = OpenStudio::Time.new(0, h, 0, 0)
- end
+ def create_schedule(model, sch_name, num_days, schedule_type_limits_name, unavailable_periods)
+ schedule = Model.add_schedule_ruleset(
+ model,
+ name: sch_name,
+ limits: schedule_type_limits_name
+ )
- schedule = OpenStudio::Model::ScheduleRuleset.new(model)
- schedule.setName(sch_name)
- schedule.defaultDaySchedule.setName(sch_name + ' default day')
+ year = model.getYearDescription.assumedYear
- prev_wkdy_vals = nil
- prev_wkdy_rule = nil
- prev_wknd_vals = nil
- prev_wknd_rule = nil
+ prev_wkdy_vals, prev_wkdy_rule = nil, nil
+ prev_wknd_vals, prev_wknd_rule = nil, nil
for d in 1..num_days
date_s = OpenStudio::Date::fromDayOfYear(d, year)
date_e = OpenStudio::Date::fromDayOfYear(d, year)
- wkdy_vals = []
- wknd_vals = []
+ wkdy_vals, wknd_vals = [], []
for h in 1..24
wkdy_vals[h] = (@weekday_day_by_hour_values[d - 1][h - 1]) / @maxval
wknd_vals[h] = (@weekend_day_by_hour_values[d - 1][h - 1]) / @maxval
@@ -340,67 +292,35 @@ def create_schedule(model, sch_name, year, num_days, schedule_type_limits_name,
prev_wkdy_rule.setEndDate(date_e) unless prev_wkdy_rule.nil?
prev_wknd_rule.setEndDate(date_e) unless prev_wknd_rule.nil?
elsif wkdy_vals == wknd_vals
- # Alldays
- wkdy_rule = OpenStudio::Model::ScheduleRule.new(schedule)
- wkdy_rule.setName(sch_name + " #{Schedule.allday_name} ruleset#{d}")
- wkdy = wkdy_rule.daySchedule
- wkdy.setName(sch_name + " #{Schedule.allday_name}#{d}")
- previous_value = wkdy_vals[1]
- for h in 1..24
- next if (h != 24) && (wkdy_vals[h + 1] == previous_value)
-
- wkdy.addValue(time[h], previous_value)
- previous_value = wkdy_vals[h + 1]
- end
- Schedule.set_weekday_rule(wkdy_rule)
- Schedule.set_weekend_rule(wkdy_rule)
- wkdy_rule.setStartDate(date_s)
- wkdy_rule.setEndDate(date_e)
- prev_wkdy_rule = wkdy_rule
- prev_wknd_rule = nil
+ alld_rule = Model.add_schedule_ruleset_rule(
+ schedule,
+ start_date: date_s,
+ end_date: date_e,
+ hourly_values: wkdy_vals
+ )
+ prev_wkdy_rule, prev_wknd_rule = alld_rule, nil
else
- # Weekdays
- wkdy_rule = OpenStudio::Model::ScheduleRule.new(schedule)
- wkdy_rule.setName(sch_name + " #{Schedule.weekday_name} ruleset#{d}")
- wkdy = wkdy_rule.daySchedule
- wkdy.setName(sch_name + " #{Schedule.weekday_name}#{d}")
- previous_value = wkdy_vals[1]
- for h in 1..24
- next if (h != 24) && (wkdy_vals[h + 1] == previous_value)
-
- wkdy.addValue(time[h], previous_value)
- previous_value = wkdy_vals[h + 1]
- end
- Schedule.set_weekday_rule(wkdy_rule)
- wkdy_rule.setStartDate(date_s)
- wkdy_rule.setEndDate(date_e)
- prev_wkdy_rule = wkdy_rule
-
- # Weekends
- wknd_rule = OpenStudio::Model::ScheduleRule.new(schedule)
- wknd_rule.setName(sch_name + " #{Schedule.weekend_name} ruleset#{d}")
- wknd = wknd_rule.daySchedule
- wknd.setName(sch_name + " #{Schedule.weekend_name}#{d}")
- previous_value = wknd_vals[1]
- for h in 1..24
- next if (h != 24) && (wknd_vals[h + 1] == previous_value)
-
- wknd.addValue(time[h], previous_value)
- previous_value = wknd_vals[h + 1]
- end
- Schedule.set_weekend_rule(wknd_rule)
- wknd_rule.setStartDate(date_s)
- wknd_rule.setEndDate(date_e)
- prev_wknd_rule = wknd_rule
+ wkdy_rule = Model.add_schedule_ruleset_rule(
+ schedule,
+ start_date: date_s,
+ end_date: date_e,
+ apply_to_days: [0, 1, 1, 1, 1, 1, 0],
+ hourly_values: wkdy_vals
+ )
+ wknd_rule = Model.add_schedule_ruleset_rule(
+ schedule,
+ start_date: date_s,
+ end_date: date_e,
+ apply_to_days: [1, 0, 0, 0, 0, 0, 1],
+ hourly_values: wknd_vals
+ )
+ prev_wkdy_rule, prev_wknd_rule = wkdy_rule, wknd_rule
end
- prev_wkdy_vals = wkdy_vals
- prev_wknd_vals = wknd_vals
+ prev_wkdy_vals, prev_wknd_vals = wkdy_vals, wknd_vals
end
- Schedule.set_unavailable_periods(schedule, sch_name, unavailable_periods, year)
-
- Schedule.set_schedule_type_limits(model, schedule, schedule_type_limits_name)
+ Schedule.set_unavailable_periods(model, schedule, sch_name, unavailable_periods)
return schedule
end
@@ -423,7 +343,6 @@ class MonthWeekdayWeekendSchedule
def initialize(model, sch_name, weekday_hourly_values, weekend_hourly_values, monthly_values,
schedule_type_limits_name = nil, normalize_values = true, begin_month = 1,
begin_day = 1, end_month = 12, end_day = 31, unavailable_periods: nil)
- year = model.getYearDescription.assumedYear
@weekday_hourly_values = Schedule.validate_values(weekday_hourly_values, 24, 'weekday')
@weekend_hourly_values = Schedule.validate_values(weekend_hourly_values, 24, 'weekend')
@monthly_values = Schedule.validate_values(monthly_values, 12, 'monthly')
@@ -437,7 +356,7 @@ def initialize(model, sch_name, weekday_hourly_values, weekend_hourly_values, mo
@maxval = 1.0
@schadjust = 1.0
end
- @schedule = create_schedule(model, sch_name, year, begin_month, begin_day, end_month, end_day,
+ @schedule = create_schedule(model, sch_name, begin_month, begin_day, end_month, end_day,
schedule_type_limits_name, unavailable_periods)
end
@@ -535,7 +454,6 @@ def calc_sch_adjust()
#
# @param model [OpenStudio::Model::Model] OpenStudio Model object
# @param sch_name [String] name that is assigned to the OpenStudio Schedule object
- # @param year [Integer] the calendar year
# @param begin_month [Integer] the begin month of the year
# @param begin_day [Integer] the begin day of the begin month
# @param end_month [Integer] the end month of the year
@@ -543,8 +461,9 @@ def calc_sch_adjust()
# @param schedule_type_limits_name [String] data type for the values contained in the schedule
# @param unavailable_periods [HPXML::UnavailablePeriods] Object that defines periods for, e.g., power outages or vacancies
# @return [OpenStudio::Model::ScheduleRuleset] the OpenStudio Schedule object with rules
- def create_schedule(model, sch_name, year, begin_month, begin_day, end_month, end_day,
+ def create_schedule(model, sch_name, begin_month, begin_day, end_month, end_day,
schedule_type_limits_name, unavailable_periods)
+ year = model.getYearDescription.assumedYear
month_num_days = Calendar.num_days_in_months(year)
month_num_days[end_month - 1] = end_day
@@ -552,19 +471,15 @@ def create_schedule(model, sch_name, year, begin_month, begin_day, end_month, en
day_startm[begin_month - 1] += begin_day - 1
day_endm = [Calendar.day_start_months(year), month_num_days].transpose.map { |i| i.sum - 1 }
- time = []
- for h in 1..24
- time[h] = OpenStudio::Time.new(0, h, 0, 0)
- end
+ schedule = Model.add_schedule_ruleset(
+ model,
+ name: sch_name,
+ limits: schedule_type_limits_name
+ )
- schedule = OpenStudio::Model::ScheduleRuleset.new(model)
- schedule.setName(sch_name)
- schedule.defaultDaySchedule.setName(sch_name + ' default day')
+ prev_wkdy_vals, prev_wkdy_rule = nil, nil
+ prev_wknd_vals, prev_wknd_rule = nil, nil
- prev_wkdy_vals = nil
- prev_wkdy_rule = nil
- prev_wknd_vals = nil
- prev_wknd_rule = nil
periods = []
if begin_month <= end_month # contiguous period
periods << [begin_month, end_month]
@@ -578,8 +493,7 @@ def create_schedule(model, sch_name, year, begin_month, begin_day, end_month, en
date_s = OpenStudio::Date::fromDayOfYear(day_startm[m - 1], year)
date_e = OpenStudio::Date::fromDayOfYear(day_endm[m - 1], year)
- wkdy_vals = []
- wknd_vals = []
+ wkdy_vals, wknd_vals = [], []
for h in 1..24
wkdy_vals[h] = (@monthly_values[m - 1] * @weekday_hourly_values[h - 1]) / @maxval
wknd_vals[h] = (@monthly_values[m - 1] * @weekend_hourly_values[h - 1]) / @maxval
@@ -590,68 +504,36 @@ def create_schedule(model, sch_name, year, begin_month, begin_day, end_month, en
prev_wkdy_rule.setEndDate(date_e) unless prev_wkdy_rule.nil?
prev_wknd_rule.setEndDate(date_e) unless prev_wknd_rule.nil?
elsif wkdy_vals == wknd_vals
- # Alldays
- wkdy_rule = OpenStudio::Model::ScheduleRule.new(schedule)
- wkdy_rule.setName(sch_name + " #{Schedule.allday_name} ruleset#{m}")
- wkdy = wkdy_rule.daySchedule
- wkdy.setName(sch_name + " #{Schedule.allday_name}#{m}")
- previous_value = wkdy_vals[1]
- for h in 1..24
- next if (h != 24) && (wkdy_vals[h + 1] == previous_value)
-
- wkdy.addValue(time[h], previous_value)
- previous_value = wkdy_vals[h + 1]
- end
- Schedule.set_weekday_rule(wkdy_rule)
- Schedule.set_weekend_rule(wkdy_rule)
- wkdy_rule.setStartDate(date_s)
- wkdy_rule.setEndDate(date_e)
- prev_wkdy_rule = wkdy_rule
- prev_wknd_rule = nil
+ alld_rule = Model.add_schedule_ruleset_rule(
+ schedule,
+ start_date: date_s,
+ end_date: date_e,
+ hourly_values: wkdy_vals
+ )
+ prev_wkdy_rule, prev_wknd_rule = alld_rule, nil
else
- # Weekdays
- wkdy_rule = OpenStudio::Model::ScheduleRule.new(schedule)
- wkdy_rule.setName(sch_name + " #{Schedule.weekday_name} ruleset#{m}")
- wkdy = wkdy_rule.daySchedule
- wkdy.setName(sch_name + " #{Schedule.weekday_name}#{m}")
- previous_value = wkdy_vals[1]
- for h in 1..24
- next if (h != 24) && (wkdy_vals[h + 1] == previous_value)
-
- wkdy.addValue(time[h], previous_value)
- previous_value = wkdy_vals[h + 1]
- end
- Schedule.set_weekday_rule(wkdy_rule)
- wkdy_rule.setStartDate(date_s)
- wkdy_rule.setEndDate(date_e)
- prev_wkdy_rule = wkdy_rule
-
- # Weekends
- wknd_rule = OpenStudio::Model::ScheduleRule.new(schedule)
- wknd_rule.setName(sch_name + " #{Schedule.weekend_name} ruleset#{m}")
- wknd = wknd_rule.daySchedule
- wknd.setName(sch_name + " #{Schedule.weekend_name}#{m}")
- previous_value = wknd_vals[1]
- for h in 1..24
- next if (h != 24) && (wknd_vals[h + 1] == previous_value)
-
- wknd.addValue(time[h], previous_value)
- previous_value = wknd_vals[h + 1]
- end
- Schedule.set_weekend_rule(wknd_rule)
- wknd_rule.setStartDate(date_s)
- wknd_rule.setEndDate(date_e)
- prev_wknd_rule = wknd_rule
+ wkdy_rule = Model.add_schedule_ruleset_rule(
+ schedule,
+ start_date: date_s,
+ end_date: date_e,
+ apply_to_days: [0, 1, 1, 1, 1, 1, 0],
+ hourly_values: wkdy_vals
+ )
+ wknd_rule = Model.add_schedule_ruleset_rule(
+ schedule,
+ start_date: date_s,
+ end_date: date_e,
+ apply_to_days: [1, 0, 0, 0, 0, 0, 1],
+ hourly_values: wknd_vals
+ )
+ prev_wkdy_rule, prev_wknd_rule = wkdy_rule, wknd_rule
end
- prev_wkdy_vals = wkdy_vals
- prev_wknd_vals = wknd_vals
+ prev_wkdy_vals, prev_wknd_vals = wkdy_vals, wknd_vals
end
end
- Schedule.set_unavailable_periods(schedule, sch_name, unavailable_periods, year)
-
- Schedule.set_schedule_type_limits(model, schedule, schedule_type_limits_name)
+ Schedule.set_unavailable_periods(model, schedule, sch_name, unavailable_periods)
return schedule
end
@@ -659,27 +541,6 @@ def create_schedule(model, sch_name, year, begin_month, begin_day, end_month, en
# Collection of helper methods related to schedules.
module Schedule
- # Used to describe a OpenStudio Schedule Rule that applies to both weekdays and weekends.
- #
- # @return [String] name for the allday schedule
- def self.allday_name
- return 'allday'
- end
-
- # Used to describe a OpenStudio Schedule Rule that applies only to weekdays.
- #
- # @return [String] name for the weekday schedule
- def self.weekday_name
- return 'weekday'
- end
-
- # Used to describe a OpenStudio Schedule Rule that applies only to weekends.
- #
- # @return [String] name for the weekend schedule
- def self.weekend_name
- return 'weekend'
- end
-
# Get the total number of full load hours for this schedule.
#
# @param modelYear [Integer] the calendar year
@@ -777,56 +638,6 @@ def self.annual_equivalent_full_load_hrs(modelYear, schedule)
return annual_flh
end
- # Set the lower/upper limit values and numeric type for the given schedule type limits.
- #
- # @param model [OpenStudio::Model::Model] OpenStudio Model object
- # @param schedule [OpenStudio::Model::ScheduleInterval or OpenStudio::Model::ScheduleConstant or OpenStudio::Model::ScheduleRuleset] the OpenStudio Schedule object
- # @param schedule_type_limits_name [String] data type for the values contained in the schedule
- # @return [nil]
- def self.set_schedule_type_limits(model, schedule, schedule_type_limits_name)
- return if schedule_type_limits_name.nil?
-
- schedule_type_limits = model.getScheduleTypeLimitss.find { |stl| stl.name.to_s == schedule_type_limits_name }
- if schedule_type_limits.nil?
- schedule_type_limits = OpenStudio::Model::ScheduleTypeLimits.new(model)
- schedule_type_limits.setName(schedule_type_limits_name)
- if schedule_type_limits_name == EPlus::ScheduleTypeLimitsFraction
- schedule_type_limits.setLowerLimitValue(0)
- schedule_type_limits.setUpperLimitValue(1)
- schedule_type_limits.setNumericType('Continuous')
- elsif schedule_type_limits_name == EPlus::ScheduleTypeLimitsOnOff
- schedule_type_limits.setLowerLimitValue(0)
- schedule_type_limits.setUpperLimitValue(1)
- schedule_type_limits.setNumericType('Discrete')
- elsif schedule_type_limits_name == EPlus::ScheduleTypeLimitsTemperature
- schedule_type_limits.setNumericType('Continuous')
- end
- end
-
- schedule.setScheduleTypeLimits(schedule_type_limits)
- end
-
- # Apply true for all weekday days of an OpenStudio ScheduleRule object.
- #
- # @param rule [OpenStudio::Model::ScheduleRule] an OpenStudio ScheduleRule object
- # @return [nil]
- def self.set_weekday_rule(rule)
- rule.setApplyMonday(true)
- rule.setApplyTuesday(true)
- rule.setApplyWednesday(true)
- rule.setApplyThursday(true)
- rule.setApplyFriday(true)
- end
-
- # Apply true for all weekend days of an OpenStudio ScheduleRule object.
- #
- # @param rule [OpenStudio::Model::ScheduleRule] an OpenStudio ScheduleRule object
- # @return [nil]
- def self.set_weekend_rule(rule)
- rule.setApplySaturday(true)
- rule.setApplySunday(true)
- end
-
# Downselect the unavailable periods to only those that apply to the given schedule.
#
# @param runner [OpenStudio::Measure::OSRunner] Object typically used to display warnings
@@ -839,16 +650,18 @@ def self.get_unavailable_periods(runner, schedule_name, unavailable_periods)
# Add unavailable period rules to the OpenStudio Schedule object.
#
+ # @param model [OpenStudio::Model::Model] OpenStudio Model object
# @param schedule [OpenStudio::Model::ScheduleRuleset] the OpenStudio Schedule object for which to set unavailable period rules
# @param sch_name [String] name that is assigned to the OpenStudio Schedule object
# @param unavailable_periods [HPXML::UnavailablePeriods] Object that defines periods for, e.g., power outages or vacancies
- # @param year [Integer] the calendar year
# @return [nil]
- def self.set_unavailable_periods(schedule, sch_name, unavailable_periods, year)
+ def self.set_unavailable_periods(model, schedule, sch_name, unavailable_periods)
return if unavailable_periods.nil?
+ year = model.getYearDescription.assumedYear
+
# Add off rule(s), will override previous rules
- unavailable_periods.each_with_index do |period, i|
+ unavailable_periods.each do |period|
# Special Values
# FUTURE: Assign an object type to the schedules and use that to determine what
# kind of schedule each is, rather than looking at object names. That would
@@ -880,97 +693,95 @@ def self.set_unavailable_periods(schedule, sch_name, unavailable_periods, year)
outage_days = day_e - day_s
if outage_days == 0 # outage is less than 1 calendar day (need 1 outage rule)
- out = Schedule.create_unavailable_period_rule(schedule, sch_name, i, date_s, date_e)
- Schedule.set_unavailable_period_values(out, begin_day_schedule, period.begin_hour, period.end_hour, value)
+ Model.add_schedule_ruleset_rule(
+ schedule,
+ start_date: date_s,
+ end_date: date_e,
+ hourly_values: (0..23).map { |h| (h < period.begin_hour) || (h >= period.end_hour) ? begin_day_schedule.getValue(OpenStudio::Time.new(0, h + 1, 0, 0)) : value }
+ )
else # outage is at least 1 calendar day
if period.begin_hour == 0 && period.end_hour == 24 # 1 outage rule
- out = Schedule.create_unavailable_period_rule(schedule, sch_name, i, date_s, date_e)
- out.addValue(OpenStudio::Time.new(0, 24, 0, 0), value)
+ Model.add_schedule_ruleset_rule(
+ schedule,
+ start_date: date_s,
+ end_date: date_e,
+ hourly_values: [value] * 24
+ )
elsif (period.begin_hour == 0 && period.end_hour != 24) || (period.begin_hour != 0 && period.end_hour == 24) # 2 outage rules
if period.begin_hour == 0 && period.end_hour != 24
# last day
- out = Schedule.create_unavailable_period_rule(schedule, sch_name, i, date_e, date_e)
- Schedule.set_unavailable_period_values(out, end_day_schedule, 0, period.end_hour, value)
+ Model.add_schedule_ruleset_rule(
+ schedule,
+ start_date: date_e,
+ end_date: date_e,
+ hourly_values: (0..23).map { |h| (h >= period.end_hour) ? end_day_schedule.getValue(OpenStudio::Time.new(0, h + 1, 0, 0)) : value }
+ )
# all other days
- date_e2 = OpenStudio::Date::fromDayOfYear(day_e - 1, year)
- out = Schedule.create_unavailable_period_rule(schedule, sch_name, i, date_s, date_e2)
- out.addValue(OpenStudio::Time.new(0, 24, 0, 0), value)
+ Model.add_schedule_ruleset_rule(
+ schedule,
+ start_date: date_s,
+ end_date: OpenStudio::Date::fromDayOfYear(day_e - 1, year),
+ hourly_values: [value] * 24
+ )
elsif period.begin_hour != 0 && period.end_hour == 24
# first day
- out = Schedule.create_unavailable_period_rule(schedule, sch_name, i, date_s, date_s)
- Schedule.set_unavailable_period_values(out, begin_day_schedule, period.begin_hour, 24, value)
+ Model.add_schedule_ruleset_rule(
+ schedule,
+ start_date: date_s,
+ end_date: date_s,
+ hourly_values: (0..23).map { |h| (h < period.begin_hour) ? begin_day_schedule.getValue(OpenStudio::Time.new(0, h + 1, 0, 0)) : value }
+ )
# all other days
- date_s2 = OpenStudio::Date::fromDayOfYear(day_s + 1, year)
- out = Schedule.create_unavailable_period_rule(schedule, sch_name, i, date_s2, date_e)
- out.addValue(OpenStudio::Time.new(0, 24, 0, 0), value)
+ Model.add_schedule_ruleset_rule(
+ schedule,
+ start_date: OpenStudio::Date::fromDayOfYear(day_s + 1, year),
+ end_date: date_e,
+ hourly_values: [value] * 24
+ )
end
else # 3 outage rules
# first day
- out = Schedule.create_unavailable_period_rule(schedule, sch_name, i, date_s, date_s)
- Schedule.set_unavailable_period_values(out, begin_day_schedule, period.begin_hour, 24, value)
+ Model.add_schedule_ruleset_rule(
+ schedule,
+ start_date: date_s,
+ end_date: date_s,
+ hourly_values: (0..23).map { |h| (h < period.begin_hour) ? begin_day_schedule.getValue(OpenStudio::Time.new(0, h + 1, 0, 0)) : value }
+ )
# all other days
- date_s2 = OpenStudio::Date::fromDayOfYear(day_s + 1, year)
- date_e2 = OpenStudio::Date::fromDayOfYear(day_e - 1, year)
- out = Schedule.create_unavailable_period_rule(schedule, sch_name, i, date_s2, date_e2)
- out.addValue(OpenStudio::Time.new(0, 24, 0, 0), value)
+ Model.add_schedule_ruleset_rule(
+ schedule,
+ start_date: OpenStudio::Date::fromDayOfYear(day_s + 1, year),
+ end_date: OpenStudio::Date::fromDayOfYear(day_e - 1, year),
+ hourly_values: [value] * 24
+ )
# last day
- out = Schedule.create_unavailable_period_rule(schedule, sch_name, i, date_e, date_e)
- Schedule.set_unavailable_period_values(out, end_day_schedule, 0, period.end_hour, value)
+ Model.add_schedule_ruleset_rule(
+ schedule,
+ start_date: date_e,
+ end_date: date_e,
+ hourly_values: (0..23).map { |h| (h >= period.end_hour) ? end_day_schedule.getValue(OpenStudio::Time.new(0, h + 1, 0, 0)) : value }
+ )
end
end
end
end
- # Create an unavailable period rule from start date to end date.
- #
- # @param schedule [OpenStudio::Model::ScheduleRuleset] the OpenStudio Schedule object for which to set unavailable period rules
- # @param sch_name [String] name that is assigned to the OpenStudio Schedule object
- # @param i [Integer] the index of the applicable unavailable period
- # @param date_s [OpenStudio::Date] unavailable period rule start date
- # @param date_e [OpenStudio::Date] unavailable period rule end date
- # @return [OpenStudio::Model::ScheduleDay] OpenStudio Schedule Day object connected to the unavailable period rule
- def self.create_unavailable_period_rule(schedule, sch_name, i, date_s, date_e)
- out_rule = OpenStudio::Model::ScheduleRule.new(schedule)
- out_rule.setName(sch_name + " unavailable period ruleset#{i}")
- out_sch = out_rule.daySchedule
- out_sch.setName(sch_name + " unavailable period#{i}")
- out_rule.setStartDate(date_s)
- out_rule.setEndDate(date_e)
- Schedule.set_weekday_rule(out_rule)
- Schedule.set_weekend_rule(out_rule)
- return out_sch
- end
-
- # Set the unavailable period values for the hours of the day which it applies.
- #
- # @param out [OpenStudio::Model::ScheduleDay] OpenStudio Schedule Day object connected to the unavailable period rule
- # @param day_schedule [OpenStudio::Model::ScheduleDay] the OpenStudio Schedule Day object before applying the unavailable period
- # @param begin_hour [Integer] hour of the day that the unavailable period begins
- # @param end_hour [Integer] hour of the day that the unavailable period ends
- # @param value [Double] the value to set on the day schedule that means unavailable
- # @return [nil]
- def self.set_unavailable_period_values(out, day_schedule, begin_hour, end_hour, value)
- for h in 0..23
- time = OpenStudio::Time.new(0, h + 1, 0, 0)
- if (h < begin_hour) || (h >= end_hour)
- out.addValue(time, day_schedule.getValue(time))
- else
- out.addValue(time, value)
- end
- end
- end
-
# Create an OpenStudio Schedule object based on a 365-element (or 366 for a leap year) daily season array.
#
# @param model [OpenStudio::Model::Model] OpenStudio Model object
+ # @param sch_name [String] name that is assigned to the OpenStudio Schedule object
# @param values [Array] array of daily sequential load fractions
# @return [OpenStudio::Model::ScheduleRuleset] the OpenStudio Schedule object with rules
- def self.create_ruleset_from_daily_season(model, values)
- s = OpenStudio::Model::ScheduleRuleset.new(model)
+ def self.create_ruleset_from_daily_season(model, sch_name, values)
+ schedule = Model.add_schedule_ruleset(
+ model,
+ name: sch_name,
+ limits: EPlus::ScheduleTypeLimitsFraction
+ )
year = model.getYearDescription.assumedYear
start_value = values[0]
start_date = OpenStudio::Date::fromDayOfYear(1, year)
@@ -978,21 +789,21 @@ def self.create_ruleset_from_daily_season(model, values)
i += 1
next unless value != start_value || i == values.length
- rule = OpenStudio::Model::ScheduleRule.new(s)
- set_weekday_rule(rule)
- set_weekend_rule(rule)
i += 1 if i == values.length
- end_date = OpenStudio::Date::fromDayOfYear(i - 1, year)
- rule.setStartDate(start_date)
- rule.setEndDate(end_date)
- day_schedule = rule.daySchedule
- day_schedule.addValue(OpenStudio::Time.new(0, 24, 0, 0), start_value)
+
+ Model.add_schedule_ruleset_rule(
+ schedule,
+ start_date: start_date,
+ end_date: OpenStudio::Date::fromDayOfYear(i - 1, year),
+ hourly_values: [start_value] * 24
+ )
+
break if i == values.length + 1
start_date = OpenStudio::Date::fromDayOfYear(i, year)
start_value = value
end
- return s
+ return schedule
end
# Return a array of maps that reflect the contents of the unavailable_periods.csv file.
@@ -1392,25 +1203,19 @@ def create_schedule_file(model, col_name:, rows_to_skip: 1,
return
end
- col_index = get_col_index(col_name: col_name)
num_hrs_in_year = Calendar.num_hours_in_year(@year)
schedule_length = @schedules[col_name].length
- min_per_item = 60.0 / (schedule_length / num_hrs_in_year)
-
- file_path = File.dirname(@output_schedules_path)
- workflow_json = model.workflowJSON
- file_paths = workflow_json.filePaths.map(&:to_s)
- workflow_json.addFilePath(file_path) unless file_paths.include?(file_path)
-
- schedule_file = OpenStudio::Model::ScheduleFile.new(model, File.basename(@output_schedules_path))
- schedule_file.setName(col_name)
- schedule_file.setColumnNumber(col_index + 1)
- schedule_file.setRowstoSkipatTop(rows_to_skip)
- schedule_file.setNumberofHoursofData(num_hrs_in_year.to_i)
- schedule_file.setMinutesperItem(min_per_item.to_i)
- schedule_file.setTranslateFileWithRelativePath(true)
- Schedule.set_schedule_type_limits(model, schedule_file, schedule_type_limits_name)
+ schedule_file = Model.add_schedule_file(
+ model,
+ name: col_name,
+ file_path: @output_schedules_path,
+ col_num: get_col_index(col_name: col_name) + 1,
+ rows_to_skip: rows_to_skip,
+ num_hours: num_hrs_in_year.to_i,
+ mins_per_item: (60.0 / (schedule_length / num_hrs_in_year)).to_i,
+ limits: schedule_type_limits_name
+ )
return schedule_file
end
diff --git a/HPXMLtoOpenStudio/resources/waterheater.rb b/HPXMLtoOpenStudio/resources/waterheater.rb
index ba1d0d24ed..fd8a5d949e 100644
--- a/HPXMLtoOpenStudio/resources/waterheater.rb
+++ b/HPXMLtoOpenStudio/resources/waterheater.rb
@@ -2,6 +2,8 @@
# Collection of methods related to water heating systems.
module Waterheater
+ DefaultTankHeight = 4.0 # ft, assumption from BEopt
+
# TODO
#
# @param runner [OpenStudio::Measure::OSRunner] Object typically used to display warnings
@@ -150,35 +152,37 @@ def self.apply_heatpump(model, runner, spaces, hpxml_bldg, hpxml_header, water_h
hpwh_tamb = Model.add_schedule_constant(
model,
name: "#{obj_name} Tamb act",
- value: 23
+ value: 23,
+ limits: EPlus::ScheduleTypeLimitsTemperature
)
hpwh_rhamb = Model.add_schedule_constant(
model,
name: "#{obj_name} RHamb act",
- value: 0.5
+ value: 0.5,
+ limits: EPlus::ScheduleTypeLimitsFraction
)
# Note: These get overwritten by EMS later, see HPWH Control program
top_element_sp = Model.add_schedule_constant(
model,
name: "#{obj_name} TopElementSetpoint",
- value: nil
+ value: nil,
+ limits: EPlus::ScheduleTypeLimitsTemperature
)
bottom_element_sp = Model.add_schedule_constant(
model,
name: "#{obj_name} BottomElementSetpoint",
- value: nil
+ value: nil,
+ limits: EPlus::ScheduleTypeLimitsTemperature
)
setpoint_schedule = nil
if not schedules_file.nil?
# To handle variable setpoints, need one schedule that gets sensed and a new schedule that gets actuated
# Sensed schedule
- setpoint_schedule = schedules_file.create_schedule_file(model, col_name: SchedulesFile::Columns[:WaterHeaterSetpoint].name)
+ setpoint_schedule = schedules_file.create_schedule_file(model, col_name: SchedulesFile::Columns[:WaterHeaterSetpoint].name, schedule_type_limits_name: EPlus::ScheduleTypeLimitsTemperature)
if not setpoint_schedule.nil?
- Schedule.set_schedule_type_limits(model, setpoint_schedule, EPlus::ScheduleTypeLimitsTemperature)
-
# Actuated schedule
control_setpoint_schedule = ScheduleConstant.new(model, "#{obj_name} ControlSetpoint", 0.0, EPlus::ScheduleTypeLimitsTemperature, unavailable_periods: unavailable_periods)
control_setpoint_schedule = control_setpoint_schedule.schedule
@@ -310,7 +314,8 @@ def self.apply_combi(model, runner, spaces, hpxml_bldg, hpxml_header, water_heat
source_stp_sch = Model.add_schedule_constant(
model,
name: "#{obj_name_combi} Source Spt",
- value: boiler_heating_spt
+ value: boiler_heating_spt,
+ limits: EPlus::ScheduleTypeLimitsTemperature
)
# reset dhw boiler setpoint
boiler_spt_mngr.to_SetpointManagerScheduled.get.setSchedule(source_stp_sch)
@@ -422,7 +427,7 @@ def self.get_dist_energy_waste_factor(hot_water_distribution)
# @param model [OpenStudio::Model::Model] OpenStudio Model object
# @param water_heating_systems [Array] The HPXML water heaters of interest
# @param plantloop_map [Hash] Map of HPXML System ID => OpenStudio PlantLoop objects
- # @return [TODO] TODO
+ # @return [nil]
def self.apply_combi_system_EMS(model, water_heating_systems, plantloop_map)
water_heating_systems.select { |wh|
[HPXML::WaterHeaterTypeCombiStorage,
@@ -1332,13 +1337,11 @@ def self.add_hpwh_control_program(model, runner, obj_name, amb_temp_sensor, hpwh
op_mode_schedule = nil
if not schedules_file.nil?
- op_mode_schedule = schedules_file.create_schedule_file(model, col_name: SchedulesFile::Columns[:WaterHeaterOperatingMode].name)
+ op_mode_schedule = schedules_file.create_schedule_file(model, col_name: SchedulesFile::Columns[:WaterHeaterOperatingMode].name, schedule_type_limits_name: EPlus::ScheduleTypeLimitsFraction)
end
# Sensor on op_mode_schedule
if not op_mode_schedule.nil?
- Schedule.set_schedule_type_limits(model, op_mode_schedule, EPlus::ScheduleTypeLimitsFraction)
-
op_mode_sensor = Model.add_ems_sensor(
model,
name: "#{obj_name} op_mode",
@@ -1393,7 +1396,7 @@ def self.add_hpwh_control_program(model, runner, obj_name, amb_temp_sensor, hpwh
# @param tank [TODO] TODO
# @param u_tank [TODO] TODO
# @param unit_multiplier [Integer] Number of similar dwelling units
- # @return [TODO] TODO
+ # @return [nil]
def self.set_stratified_tank_ua(tank, u_tank, unit_multiplier)
node_ua = [0] * 12 # Max number of nodes in E+ stratified tank model
if unit_multiplier == 1
@@ -1533,7 +1536,8 @@ def self.add_desuperheater(model, runner, water_heating_system, tank, loc_space,
new_schedule = Model.add_schedule_constant(
model,
name: "#{desuperheater_name} setpoint schedule",
- value: dsh_setpoint
+ value: dsh_setpoint,
+ limits: EPlus::ScheduleTypeLimitsTemperature
)
# create a desuperheater object
@@ -1551,19 +1555,6 @@ def self.add_desuperheater(model, runner, water_heating_system, tank, loc_space,
desuperheater.additionalProperties.setFeature('HPXML_ID', water_heating_system.id) # Used by reporting measure
end
- # TODO
- #
- # @param model [OpenStudio::Model::Model] OpenStudio Model object
- # @param name [TODO] TODO
- # @return [TODO] TODO
- def self.create_new_hx(model, name)
- hx = OpenStudio::Model::HeatExchangerFluidToFluid.new(model)
- hx.setName(name)
- hx.setControlType('OperationSchemeModulated')
-
- return hx
- end
-
# TODO
#
# @param water_heating_system [HPXML::WaterHeatingSystem] The HPXML water heating system of interest
@@ -1595,7 +1586,7 @@ def self.calc_ef_from_uef(water_heating_system)
# @return [TODO] TODO
def self.calc_tank_areas(act_vol, height = nil)
if height.nil?
- height = get_tank_height()
+ height = DefaultTankHeight
end
diameter = 2.0 * (UnitConversions.convert(act_vol, 'gal', 'ft^3') / (height * Math::PI))**0.5 # feet
a_top = Math::PI * diameter**2.0 / 4.0 # sqft
@@ -1605,13 +1596,6 @@ def self.calc_tank_areas(act_vol, height = nil)
return surface_area, a_side
end
- # TODO
- #
- # @return [TODO] TODO
- def self.get_tank_height()
- return 4.0 # feet, assumption from BEopt
- end
-
# TODO
#
# @param act_vol [TODO] TODO
@@ -1978,7 +1962,7 @@ def self.create_new_heater(name:, water_heating_system: nil, act_vol:, t_set_c:
act_vol *= unit_multiplier
if tank_model_type == HPXML::WaterHeaterTankModelTypeStratified
- h_tank = UnitConversions.convert(get_tank_height(), 'ft', 'm')
+ h_tank = UnitConversions.convert(DefaultTankHeight, 'ft', 'm')
# Add a WaterHeater:Stratified to the model
new_heater = OpenStudio::Model::WaterHeaterStratified.new(model)
@@ -1987,7 +1971,6 @@ def self.create_new_heater(name:, water_heating_system: nil, act_vol:, t_set_c:
new_heater.setTankHeight(h_tank)
new_heater.setMaximumTemperatureLimit(90)
new_heater.setHeaterPriorityControl('MasterSlave')
- configure_stratified_tank_setpoint_schedules(new_heater, schedules_file, t_set_c, model, runner, unavailable_periods)
new_heater.setHeater1Capacity(UnitConversions.convert(cap, 'kBtu/hr', 'W'))
new_heater.setHeater1Height((1.0 - (4 - 0.5) / 15) * h_tank) # in the 4th node of a 15-node tank (counting from top); height of upper element based on TRNSYS assumptions for an ERWH
new_heater.setHeater1DeadbandTemperatureDifference(5.556)
@@ -2009,7 +1992,6 @@ def self.create_new_heater(name:, water_heating_system: nil, act_vol:, t_set_c:
new_heater = OpenStudio::Model::WaterHeaterMixed.new(model)
new_heater.setTankVolume(UnitConversions.convert(act_vol, 'gal', 'm^3'))
new_heater.setHeaterThermalEfficiency(eta_c) unless eta_c.nil?
- configure_mixed_tank_setpoint_schedule(new_heater, schedules_file, t_set_c, model, runner, unavailable_periods)
new_heater.setMaximumTemperatureLimit(99.0)
if [HPXML::WaterHeaterTypeTankless, HPXML::WaterHeaterTypeCombiTankless].include? tank_type
new_heater.setHeaterControlType('Modulate')
@@ -2049,6 +2031,8 @@ def self.create_new_heater(name:, water_heating_system: nil, act_vol:, t_set_c:
new_heater.setOffCycleLossCoefficienttoAmbientTemperature(ua_w_k)
end
+ assign_water_heater_setpoint(runner, model, new_heater, schedules_file, t_set_c, unavailable_periods)
+
if not water_heating_system.nil?
new_heater.additionalProperties.setFeature('HPXML_ID', water_heating_system.id) # Used by reporting measure
end
@@ -2076,7 +2060,7 @@ def self.create_new_heater(name:, water_heating_system: nil, act_vol:, t_set_c:
# @param loc_space [OpenStudio::Model::Space] The space where the water heater is located
# @param loc_schedule [OpenStudio::Model::ScheduleConstant] The temperature schedule for where the water heater is located, if not in a space
# @param wh_obj [TODO] TODO
- # @return [TODO] TODO
+ # @return [nil]
def self.set_wh_ambient(loc_space, loc_schedule, wh_obj)
if wh_obj.ambientTemperatureSchedule.is_initialized
wh_obj.ambientTemperatureSchedule.get.remove
@@ -2093,54 +2077,35 @@ def self.set_wh_ambient(loc_space, loc_schedule, wh_obj)
# TODO
#
- # @param new_heater [TODO] TODO
- # @param schedules_file [SchedulesFile] SchedulesFile wrapper class instance of detailed schedule files
- # @param t_set_c [TODO] TODO
- # @param model [OpenStudio::Model::Model] OpenStudio Model object
# @param runner [OpenStudio::Measure::OSRunner] Object typically used to display warnings
- # @param unavailable_periods [HPXML::UnavailablePeriods] Object that defines periods for, e.g., power outages or vacancies
- # @return [TODO] TODO
- def self.configure_mixed_tank_setpoint_schedule(new_heater, schedules_file, t_set_c, model, runner, unavailable_periods)
- new_schedule = nil
- if not schedules_file.nil?
- new_schedule = schedules_file.create_schedule_file(model, col_name: SchedulesFile::Columns[:WaterHeaterSetpoint].name)
- end
- if new_schedule.nil? # constant
- new_schedule = ScheduleConstant.new(model, Constants::ObjectTypeWaterHeaterSetpoint, t_set_c, EPlus::ScheduleTypeLimitsTemperature, unavailable_periods: unavailable_periods)
- new_schedule = new_schedule.schedule
- else
- runner.registerWarning("Both '#{SchedulesFile::Columns[:WaterHeaterSetpoint].name}' schedule file and setpoint temperature provided; the latter will be ignored.") if !t_set_c.nil?
- end
- if new_heater.setpointTemperatureSchedule.is_initialized
- new_heater.setpointTemperatureSchedule.get.remove
- end
- new_heater.setSetpointTemperatureSchedule(new_schedule)
- end
-
- # TODO
- #
- # @param new_heater [TODO] TODO
+ # @param model [OpenStudio::Model::Model] OpenStudio Model object
+ # @param water_heater [TODO] TODO
# @param schedules_file [SchedulesFile] SchedulesFile wrapper class instance of detailed schedule files
# @param t_set_c [TODO] TODO
- # @param model [OpenStudio::Model::Model] OpenStudio Model object
- # @param runner [OpenStudio::Measure::OSRunner] Object typically used to display warnings
# @param unavailable_periods [HPXML::UnavailablePeriods] Object that defines periods for, e.g., power outages or vacancies
- # @return [TODO] TODO
- def self.configure_stratified_tank_setpoint_schedules(new_heater, schedules_file, t_set_c, model, runner, unavailable_periods)
- new_schedule = nil
+ # @return [nil]
+ def self.assign_water_heater_setpoint(runner, model, water_heater, schedules_file, t_set_c, unavailable_periods)
+ setpoint_sch = nil
if not schedules_file.nil?
- new_schedule = schedules_file.create_schedule_file(model, col_name: SchedulesFile::Columns[:WaterHeaterSetpoint].name)
+ setpoint_sch = schedules_file.create_schedule_file(model, col_name: SchedulesFile::Columns[:WaterHeaterSetpoint].name)
end
- if new_schedule.nil? # constant
- new_schedule = ScheduleConstant.new(model, Constants::ObjectTypeWaterHeaterSetpoint, t_set_c, EPlus::ScheduleTypeLimitsTemperature, unavailable_periods: unavailable_periods)
- new_schedule = new_schedule.schedule
+ if setpoint_sch.nil? # constant
+ setpoint_sch = ScheduleConstant.new(model, Constants::ObjectTypeWaterHeaterSetpoint, t_set_c, EPlus::ScheduleTypeLimitsTemperature, unavailable_periods: unavailable_periods)
+ setpoint_sch = setpoint_sch.schedule
else
runner.registerWarning("Both '#{SchedulesFile::Columns[:WaterHeaterSetpoint].name}' schedule file and setpoint temperature provided; the latter will be ignored.") if !t_set_c.nil?
end
- new_heater.heater1SetpointTemperatureSchedule.remove
- new_heater.heater2SetpointTemperatureSchedule.remove
- new_heater.setHeater1SetpointTemperatureSchedule(new_schedule)
- new_heater.setHeater2SetpointTemperatureSchedule(new_schedule)
+ if water_heater.is_a? OpenStudio::Model::WaterHeaterStratified
+ water_heater.heater1SetpointTemperatureSchedule.remove
+ water_heater.heater2SetpointTemperatureSchedule.remove
+ water_heater.setHeater1SetpointTemperatureSchedule(setpoint_sch)
+ water_heater.setHeater2SetpointTemperatureSchedule(setpoint_sch)
+ elsif water_heater.is_a? OpenStudio::Model::WaterHeaterMixed
+ if water_heater.setpointTemperatureSchedule.is_initialized
+ water_heater.setpointTemperatureSchedule.get.remove
+ end
+ water_heater.setSetpointTemperatureSchedule(setpoint_sch)
+ end
end
# TODO
diff --git a/HPXMLtoOpenStudio/tests/test_schedules.rb b/HPXMLtoOpenStudio/tests/test_schedules.rb
index be6a42a5b6..aab2621538 100644
--- a/HPXMLtoOpenStudio/tests/test_schedules.rb
+++ b/HPXMLtoOpenStudio/tests/test_schedules.rb
@@ -508,7 +508,7 @@ def test_set_unavailable_periods_lighting
unavailable_periods = _add_unavailable_period(hpxml, 'Power Outage', begin_month, begin_day, begin_hour, end_month, end_day, end_hour)
schedule_rules = schedule.scheduleRules
- Schedule.set_unavailable_periods(schedule, sch_name, unavailable_periods, year)
+ Schedule.set_unavailable_periods(model, schedule, sch_name, unavailable_periods)
unavailable_schedule_rules = schedule.scheduleRules - schedule_rules
assert_equal(1, unavailable_schedule_rules.size)
@@ -529,7 +529,7 @@ def test_set_unavailable_periods_lighting
unavailable_periods = _add_unavailable_period(hpxml, 'Power Outage', begin_month, begin_day, begin_hour, end_month, end_day, end_hour) # note the change of end month/day
schedule_rules = schedule.scheduleRules
- Schedule.set_unavailable_periods(schedule, sch_name, unavailable_periods, year)
+ Schedule.set_unavailable_periods(model, schedule, sch_name, unavailable_periods)
unavailable_schedule_rules = schedule.scheduleRules - schedule_rules
assert_equal(1, unavailable_schedule_rules.size)
@@ -549,7 +549,7 @@ def test_set_unavailable_periods_lighting
unavailable_periods = _add_unavailable_period(hpxml, 'Power Outage', begin_month, begin_day, begin_hour, end_month, end_day, end_hour) # note the change of end month/day
schedule_rules = schedule.scheduleRules
- Schedule.set_unavailable_periods(schedule, sch_name, unavailable_periods, year)
+ Schedule.set_unavailable_periods(model, schedule, sch_name, unavailable_periods)
unavailable_schedule_rules = schedule.scheduleRules - schedule_rules
assert_equal(2, unavailable_schedule_rules.size)
@@ -570,7 +570,7 @@ def test_set_unavailable_periods_lighting
unavailable_periods = _add_unavailable_period(hpxml, 'Power Outage', begin_month, begin_day, begin_hour, end_month, end_day, end_hour) # note the change of end month/day
schedule_rules = schedule.scheduleRules
- Schedule.set_unavailable_periods(schedule, sch_name, unavailable_periods, year)
+ Schedule.set_unavailable_periods(model, schedule, sch_name, unavailable_periods)
unavailable_schedule_rules = schedule.scheduleRules - schedule_rules
assert_equal(2, unavailable_schedule_rules.size)
@@ -594,7 +594,7 @@ def test_set_unavailable_periods_lighting
unavailable_periods = _add_unavailable_period(hpxml, 'Power Outage', begin_month, begin_day, begin_hour, end_month, end_day, end_hour) # note the change of end month/day
schedule_rules = schedule.scheduleRules
- Schedule.set_unavailable_periods(schedule, sch_name, unavailable_periods, year)
+ Schedule.set_unavailable_periods(model, schedule, sch_name, unavailable_periods)
unavailable_schedule_rules = schedule.scheduleRules - schedule_rules
assert_equal(3, unavailable_schedule_rules.size)
@@ -626,7 +626,7 @@ def test_set_unavailable_periods_natvent
unavailable_periods = _add_unavailable_period(hpxml, 'Power Outage', begin_month, begin_day, begin_hour, end_month, end_day, end_hour, natvent_availability)
schedule_rules = schedule.scheduleRules
- Schedule.set_unavailable_periods(schedule, sch_name, unavailable_periods, year)
+ Schedule.set_unavailable_periods(model, schedule, sch_name, unavailable_periods)
unavailable_schedule_rules = schedule.scheduleRules - schedule_rules
assert_equal(0, unavailable_schedule_rules.size)
@@ -644,7 +644,7 @@ def test_set_unavailable_periods_natvent
unavailable_periods = _add_unavailable_period(hpxml, 'Power Outage', begin_month, begin_day, begin_hour, end_month, end_day, end_hour, natvent_availability)
schedule_rules = schedule.scheduleRules
- Schedule.set_unavailable_periods(schedule, sch_name, unavailable_periods, year)
+ Schedule.set_unavailable_periods(model, schedule, sch_name, unavailable_periods)
unavailable_schedule_rules = schedule.scheduleRules - schedule_rules
assert_equal(1, unavailable_schedule_rules.size)
@@ -662,7 +662,7 @@ def test_set_unavailable_periods_natvent
unavailable_periods = _add_unavailable_period(hpxml, 'Power Outage', begin_month, begin_day, begin_hour, end_month, end_day, end_hour, natvent_availability)
schedule_rules = schedule.scheduleRules
- Schedule.set_unavailable_periods(schedule, sch_name, unavailable_periods, year)
+ Schedule.set_unavailable_periods(model, schedule, sch_name, unavailable_periods)
unavailable_schedule_rules = schedule.scheduleRules - schedule_rules
assert_equal(1, unavailable_schedule_rules.size)
@@ -692,7 +692,7 @@ def test_set_unavailable_periods_leap_year
unavailable_periods = _add_unavailable_period(hpxml, 'Power Outage', begin_month, begin_day, begin_hour, end_month, end_day, end_hour)
schedule_rules = schedule.scheduleRules
- Schedule.set_unavailable_periods(schedule, sch_name, unavailable_periods, year)
+ Schedule.set_unavailable_periods(model, schedule, sch_name, unavailable_periods)
unavailable_schedule_rules = schedule.scheduleRules - schedule_rules
assert_equal(1, unavailable_schedule_rules.size)