Skip to content

Commit

Permalink
Merge pull request #402 from urbanopt/hpxml-151
Browse files Browse the repository at this point in the history
updating hpxml 1.5.1
  • Loading branch information
kflemin authored Jan 6, 2023
2 parents 236f63b + cf986ff commit 5bfdfd3
Show file tree
Hide file tree
Showing 40 changed files with 379 additions and 256 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Version 0.9.1
Date Range: 12/14/22 - 01/05/23:

- Updates to support HPXML to 1.5.1 and OpenStudio 3.5.1
- Updated copyrights for 2023

## Version 0.9.0
Date Range: 07/07/22 - 12/13/22:

Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# License

URBANopt™, Copyright (c) 2019-2022, Alliance for Sustainable Energy, LLC, and other
URBANopt™, Copyright (c) 2019-2023, Alliance for Sustainable Energy, LLC, and other
contributors. All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# *********************************************************************************
# URBANopt™, Copyright (c) 2019-2022, Alliance for Sustainable Energy, LLC, and other
# URBANopt™, Copyright (c) 2019-2023, Alliance for Sustainable Energy, LLC, and other
# contributors. All rights reserved.

# Redistribution and use in source and binary forms, with or without modification,
Expand Down
2 changes: 1 addition & 1 deletion example_files/mappers/Baseline.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# *********************************************************************************
# URBANopt™, Copyright (c) 2019-2022, Alliance for Sustainable Energy, LLC, and other
# URBANopt™, Copyright (c) 2019-2023, Alliance for Sustainable Energy, LLC, and other
# contributors. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
Expand Down
2 changes: 1 addition & 1 deletion example_files/mappers/ClassProject.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# *********************************************************************************
# URBANopt™, Copyright (c) 2019-2022, Alliance for Sustainable Energy, LLC, and other
# URBANopt™, Copyright (c) 2019-2023, Alliance for Sustainable Energy, LLC, and other
# contributors. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
Expand Down
2 changes: 1 addition & 1 deletion example_files/mappers/CreateBar.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# *********************************************************************************
# URBANopt™, Copyright (c) 2019-2022, Alliance for Sustainable Energy, LLC, and other
# URBANopt™, Copyright (c) 2019-2023, Alliance for Sustainable Energy, LLC, and other
# contributors. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
Expand Down
2 changes: 1 addition & 1 deletion example_files/mappers/EvCharging.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# *********************************************************************************
# URBANopt™, Copyright (c) 2019-2022, Alliance for Sustainable Energy, LLC, and other
# URBANopt™, Copyright (c) 2019-2023, Alliance for Sustainable Energy, LLC, and other
# contributors. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
Expand Down
2 changes: 1 addition & 1 deletion example_files/mappers/FlexibleHotWater.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# *********************************************************************************
# URBANopt™, Copyright (c) 2019-2022, Alliance for Sustainable Energy, LLC, and other
# URBANopt™, Copyright (c) 2019-2023, Alliance for Sustainable Energy, LLC, and other
# contributors. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
Expand Down
2 changes: 1 addition & 1 deletion example_files/mappers/Floorspace.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# *********************************************************************************
# URBANopt™, Copyright (c) 2019-2022, Alliance for Sustainable Energy, LLC, and other
# URBANopt™, Copyright (c) 2019-2023, Alliance for Sustainable Energy, LLC, and other
# contributors. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
Expand Down
2 changes: 1 addition & 1 deletion example_files/mappers/HighEfficiency.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# *********************************************************************************
# URBANopt™, Copyright (c) 2019-2022, Alliance for Sustainable Energy, LLC, and other
# URBANopt™, Copyright (c) 2019-2023, Alliance for Sustainable Energy, LLC, and other
# contributors. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
Expand Down
2 changes: 1 addition & 1 deletion example_files/mappers/HighEfficiencyCreateBar.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# *********************************************************************************
# URBANopt™, Copyright (c) 2019-2022, Alliance for Sustainable Energy, LLC, and other
# URBANopt™, Copyright (c) 2019-2023, Alliance for Sustainable Energy, LLC, and other
# contributors. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
Expand Down
2 changes: 1 addition & 1 deletion example_files/mappers/HighEfficiencyFloorspace.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# *********************************************************************************
# URBANopt™, Copyright (c) 2019-2022, Alliance for Sustainable Energy, LLC, and other
# URBANopt™, Copyright (c) 2019-2023, Alliance for Sustainable Energy, LLC, and other
# contributors. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
Expand Down
2 changes: 1 addition & 1 deletion example_files/mappers/PeakHoursMelsShedding.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# *********************************************************************************
# URBANopt™, Copyright (c) 2019-2022, Alliance for Sustainable Energy, LLC, and other
# URBANopt™, Copyright (c) 2019-2023, Alliance for Sustainable Energy, LLC, and other
# contributors. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
Expand Down
2 changes: 1 addition & 1 deletion example_files/mappers/PeakHoursThermostatAdjust.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# *********************************************************************************
# URBANopt™, Copyright (c) 2019-2022, Alliance for Sustainable Energy, LLC, and other
# URBANopt™, Copyright (c) 2019-2023, Alliance for Sustainable Energy, LLC, and other
# contributors. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
Expand Down
2 changes: 1 addition & 1 deletion example_files/mappers/ThermalStorage.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# *********************************************************************************
# URBANopt™, Copyright (c) 2019-2022, Alliance for Sustainable Energy, LLC, and other
# URBANopt™, Copyright (c) 2019-2023, Alliance for Sustainable Energy, LLC, and other
# contributors. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
Expand Down
6 changes: 3 additions & 3 deletions example_files/measures/BuildResidentialModel/measure.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<schema_version>3.0</schema_version>
<name>build_residential_model</name>
<uid>259dc35f-65e8-47d4-913f-69efede5a267</uid>
<version_id>8bb0bd12-8c25-4c05-9477-e045ca9cde27</version_id>
<version_modified>20221205T204142Z</version_modified>
<version_id>b3c7ec2e-10f5-45d9-9a10-7527fec4565a</version_id>
<version_modified>20230105T165234Z</version_modified>
<xml_checksum>2C38F48B</xml_checksum>
<class_name>BuildResidentialModel</class_name>
<display_name>Build Residential Model</display_name>
Expand Down Expand Up @@ -6597,7 +6597,7 @@
<filename>measure.rb</filename>
<filetype>rb</filetype>
<usage_type>script</usage_type>
<checksum>079A37C9</checksum>
<checksum>A1FFBF5C</checksum>
</file>
</files>
</measure>
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ def arguments(model) # rubocop:disable Lint/UnusedMethodArgument
arg.setDefaultValue('smooth')
args << arg

arg = OpenStudio::Measure::OSArgument.makeStringArgument('schedules_column_names', false)
arg.setDisplayName('Schedules: Column Names')
arg.setDescription("A comma-separated list of the column names to generate. If not provided, defaults to all columns. Possible column names are: #{SchedulesFile.OccupancyColumnNames.join(', ')}.")
args << arg

arg = OpenStudio::Measure::OSArgument.makeStringArgument('schedules_vacancy_period', false)
arg.setDisplayName('Schedules: Vacancy Period')
arg.setDescription('Specifies the vacancy period. Enter a date like "Dec 15 - Jan 15".')
Expand Down Expand Up @@ -161,6 +166,7 @@ def create_schedules(runner, hpxml, epw_file, args)
info_msgs << "RandomSeed=#{args[:random_seed]}" if args[:schedules_random_seed].is_initialized
info_msgs << "GeometryNumOccupants=#{args[:geometry_num_occupants]}"
info_msgs << "VacancyPeriod=#{args[:schedules_vacancy_period].get}" if args[:schedules_vacancy_period].is_initialized
info_msgs << "ColumnNames=#{args[:column_names]}" if args[:schedules_column_names].is_initialized

runner.registerInfo("Created #{args[:schedules_type]} schedule with #{info_msgs.join(', ')}")

Expand Down Expand Up @@ -188,6 +194,7 @@ def get_generator_inputs(hpxml, epw_file, args)
args[:state] = hpxml.header.state_code if !hpxml.header.state_code.nil?

args[:random_seed] = args[:schedules_random_seed].get if args[:schedules_random_seed].is_initialized
args[:column_names] = args[:schedules_column_names].get.split(',').map(&:strip) if args[:schedules_column_names].is_initialized

if hpxml.building_occupancy.number_of_residents.nil?
args[:geometry_num_occupants] = Geometry.get_occupancy_default_num(hpxml.building_construction.number_of_bedrooms)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<schema_version>3.0</schema_version>
<name>build_residential_schedule_file</name>
<uid>f770b2db-1a9f-4e99-99a7-7f3161a594b1</uid>
<version_id>b9ab9559-30d8-4b1c-9757-8c911f80e937</version_id>
<version_modified>20221031T233528Z</version_modified>
<version_id>3a88a262-1431-4bb9-a577-cd235aed6b1e</version_id>
<version_modified>20221201T013247Z</version_modified>
<xml_checksum>03F02484</xml_checksum>
<class_name>BuildResidentialScheduleFile</class_name>
<display_name>Schedule File Builder</display_name>
Expand Down Expand Up @@ -38,6 +38,14 @@
</choice>
</choices>
</argument>
<argument>
<name>schedules_column_names</name>
<display_name>Schedules: Column Names</display_name>
<description>A comma-separated list of the column names to generate. If not provided, defaults to all columns. Possible column names are: occupants, lighting_interior, lighting_exterior, lighting_garage, lighting_exterior_holiday, cooking_range, refrigerator, extra_refrigerator, freezer, dishwasher, clothes_washer, clothes_dryer, ceiling_fan, plug_loads_other, plug_loads_tv, plug_loads_vehicle, plug_loads_well_pump, fuel_loads_grill, fuel_loads_lighting, fuel_loads_fireplace, pool_pump, pool_heater, hot_tub_pump, hot_tub_heater, hot_water_dishwasher, hot_water_clothes_washer, hot_water_fixtures.</description>
<type>String</type>
<required>false</required>
<model_dependent>false</model_dependent>
</argument>
<argument>
<name>schedules_vacancy_period</name>
<display_name>Schedules: Vacancy Period</display_name>
Expand Down Expand Up @@ -890,11 +898,17 @@
<usage_type>resource</usage_type>
<checksum>127D96AC</checksum>
</file>
<file>
<filename>schedules.rb</filename>
<filetype>rb</filetype>
<usage_type>resource</usage_type>
<checksum>AC348B70</checksum>
</file>
<file>
<filename>build_residential_schedule_file_test.rb</filename>
<filetype>rb</filetype>
<usage_type>test</usage_type>
<checksum>41CA164F</checksum>
<checksum>10DD8842</checksum>
</file>
<file>
<version>
Expand All @@ -905,13 +919,7 @@
<filename>measure.rb</filename>
<filetype>rb</filetype>
<usage_type>script</usage_type>
<checksum>8FF07C66</checksum>
</file>
<file>
<filename>schedules.rb</filename>
<filetype>rb</filetype>
<usage_type>resource</usage_type>
<checksum>F2E6EBB8</checksum>
<checksum>3D8ADC7F</checksum>
</file>
</files>
</measure>
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class ScheduleGenerator
def initialize(runner:,
epw_file:,
state:,
column_names: nil,
random_seed: nil,
minutes_per_step:,
steps_in_day:,
Expand All @@ -21,6 +22,7 @@ def initialize(runner:,
@runner = runner
@epw_file = epw_file
@state = state
@column_names = column_names
@random_seed = random_seed
@minutes_per_step = minutes_per_step
@steps_in_day = steps_in_day
Expand Down Expand Up @@ -60,6 +62,16 @@ def schedules
def create(args:)
initialize_schedules

if @column_names.nil?
@column_names = SchedulesFile.ColumnNames
end

invalid_columns = (@column_names - SchedulesFile.ColumnNames)
invalid_columns.each do |invalid_column|
@runner.registerError("Invalid column name specified: '#{invalid_column}'.")
end
return false unless invalid_columns.empty?

success = create_average_schedules
return false if not success

Expand Down Expand Up @@ -963,6 +975,9 @@ def sample_activity_duration(prng, activity_duration_prob_map, occ_type_id, acti
end

def export(schedules_path:)
(SchedulesFile.ColumnNames - @column_names).each do |col_to_remove|
@schedules.delete(col_to_remove)
end
CSV.open(schedules_path, 'w') do |csv|
csv << @schedules.keys
rows = @schedules.values.transpose
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,51 @@ def test_stochastic
assert(!sf.schedules.keys.include?(SchedulesFile::ColumnVacancy))
end

def test_stochastic_subset_of_columns
hpxml = _create_hpxml('base.xml')
XMLHelper.write_file(hpxml.to_oga, @tmp_hpxml_path)

columns = [SchedulesFile::ColumnCookingRange,
SchedulesFile::ColumnDishwasher,
SchedulesFile::ColumnHotWaterDishwasher,
SchedulesFile::ColumnClothesWasher,
SchedulesFile::ColumnHotWaterClothesWasher,
SchedulesFile::ColumnClothesDryer,
SchedulesFile::ColumnHotWaterFixtures]

@args_hash['schedules_type'] = 'stochastic'
@args_hash['output_csv_path'] = File.absolute_path(File.join(@tmp_output_path, 'occupancy-stochastic.csv'))
@args_hash['schedules_column_names'] = columns.join(', ')
model, hpxml, result = _test_measure()

info_msgs = result.info.map { |x| x.logMessage }
assert(info_msgs.any? { |info_msg| info_msg.include?('ColumnNames') })

sf = SchedulesFile.new(model: model, schedules_paths: hpxml.header.schedules_filepaths)
sf.validate_schedules(year: 2007)

columns.each do |column|
assert(sf.schedules.keys.include?(column))
end
(SchedulesFile.ColumnNames - columns).each do |column|
assert(!sf.schedules.keys.include?(column))
end
end

def test_stochastic_subset_of_columns_invalid_name
hpxml = _create_hpxml('base.xml')
XMLHelper.write_file(hpxml.to_oga, @tmp_hpxml_path)

@args_hash['schedules_type'] = 'stochastic'
@args_hash['output_csv_path'] = File.absolute_path(File.join(@tmp_output_path, 'occupancy-stochastic.csv'))
@args_hash['schedules_column_names'] = "foobar, #{SchedulesFile::ColumnCookingRange}, foobar2"
_model, _hpxml, result = _test_measure(expect_fail: true)

error_msgs = result.errors.map { |x| x.logMessage }
assert(error_msgs.any? { |error_msg| error_msg.include?("Invalid column name specified: 'foobar'.") })
assert(error_msgs.any? { |error_msg| error_msg.include?("Invalid column name specified: 'foobar2'.") })
end

def test_stochastic_vacancy
hpxml = _create_hpxml('base.xml')
XMLHelper.write_file(hpxml.to_oga, @tmp_hpxml_path)
Expand Down Expand Up @@ -508,7 +553,7 @@ def test_non_integer_number_of_occupants
end
end

def _test_measure()
def _test_measure(expect_fail: false)
# create an instance of the measure
measure = BuildResidentialScheduleFile.new

Expand All @@ -532,11 +577,14 @@ def _test_measure()
measure.run(model, runner, argument_map)
result = runner.result

# show the output
show_output(result) unless result.value.valueName == 'Success'

# assert that it ran correctly
assert_equal('Success', result.value.valueName)
if expect_fail
show_output(result) unless result.value.valueName == 'Fail'
assert_equal('Fail', result.value.valueName)
else
show_output(result) unless result.value.valueName == 'Success'
assert_equal('Success', result.value.valueName)
end

hpxml = HPXML.new(hpxml_path: @tmp_hpxml_path)

Expand Down
Loading

0 comments on commit 5bfdfd3

Please sign in to comment.