Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resstock connecction #472

Merged
merged 9 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 3 additions & 3 deletions .github/workflows/nightly_ci_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ on:
# # https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule
# # 5:24 am UTC (11:24pm MDT the day before) every weekday night in MDT
- cron: '24 5 * * 2-6'
# pull_request:
# types: [review_requested]
pull_request:
types: [review_requested]

env:
# Favor_Local_Gems enforces develop branch of all Ruby dependencies
# This is our canary in the coal mine! If any simulation tests fail, comment this and retry.
# If CI is then successful, we have a breaking change in a dependency somewhere.
FAVOR_LOCAL_GEMS: true
# FAVOR_LOCAL_GEMS: true
GEM_DEVELOPER_KEY: ${{ secrets.GEM_DEVELOPER_KEY }}
# RUBYLIB: /usr/local/openstudio-3.7.0/Ruby
UO_NUM_PARALLEL: 4
Expand Down
4 changes: 2 additions & 2 deletions example_files/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ if allow_local && File.exist?('../urbanopt-geojson-gem')
elsif allow_local
gem 'urbanopt-geojson', github: 'URBANopt/urbanopt-geojson-gem', branch: 'develop'
else
gem 'urbanopt-geojson', '~> 0.11.1'
gem 'urbanopt-geojson', '~> 0.11.2'
end

# NEVER put SCENARIO-GEM in this file...it will make all simulations fail due to the sqlite dependency
Expand All @@ -94,5 +94,5 @@ if allow_local && File.exist?('../urbanopt-reporting-gem')
elsif allow_local
gem 'urbanopt-reporting', github: 'URBANopt/urbanopt-reporting-gem', branch: 'develop'
else
gem 'urbanopt-reporting', '~> 0.10.0'
gem 'urbanopt-reporting', '~> 0.10.1'
end
20 changes: 11 additions & 9 deletions example_files/example_project_combined.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"end_date": "2017-12-31T07:00:00.000Z",
"timesteps_per_hour": 1,
"default_template": "90.1-2013",
"emissions": true,
"emissions": true,
"electricity_emissions_future_subregion": "NYSTc",
"electricity_emissions_hourly_historical_subregion": "New York",
"electricity_emissions_annual_historical_subregion": "NYCW",
Expand Down Expand Up @@ -652,8 +652,7 @@
"onsite_parking_fraction": 1,
"template": "Residential IECC 2015 - Customizable Template Sep 2020",
"geometry_unit_orientation": 90.0,
"geometry_unit_aspect_ratio" : 1.0

"geometry_unit_aspect_ratio": 1.0
},
"geometry": {
"type": "Polygon",
Expand Down Expand Up @@ -700,7 +699,9 @@
"roof_type": "Hip",
"system_type": "Residential - boiler and room air conditioner",
"heating_system_fuel_type": "propane",
"template": "Residential IECC 2015 - Customizable Template Sep 2020"
"year_built": 1986,
"characterize_residential_buildings_from_buildstock_csv": true,
"uo_buildstock_mapping_csv_path": "resources/uo_buildstock_mapping.csv"
},
"geometry": {
"type": "Polygon",
Expand Down Expand Up @@ -834,17 +835,18 @@
"name": "Residential 5",
"type": "Building",
"building_type": "Multifamily",
"floor_area": 28636,
"footprint_area": 14318,
"floor_area": 10000,
"footprint_area": 5000,
"number_of_stories_above_ground": 2,
"number_of_stories": 2,
"number_of_bedrooms": 16,
"foundation_type": "slab",
"attic_type": "flat roof",
"system_type": "Residential - furnace and room air conditioner",
"heating_system_fuel_type": "wood",
"system_type": "Residential - furnace and central air conditioner",
"heating_system_fuel_type": "electricity",
"number_of_residential_units": 8,
"template": "Residential IECC 2015 - Customizable Template Sep 2020"
"characterize_residential_buildings_from_buildstock_csv": true,
"resstock_buildstock_csv_path": "resources/residential-measures/test/base_results/baseline/annual/buildstock.csv"
},
"geometry": {
"type": "Polygon",
Expand Down
68 changes: 60 additions & 8 deletions example_files/mappers/Baseline.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# *********************************************************************************
# URBANopt (tm), Copyright (c) Alliance for Sustainable Energy, LLC.
# See also https://github.com/urbanopt/urbanopt-cli/blob/develop/LICENSE.md
# See also https://github.com/urbanopt/urbanopt-example-geojson-project/blob/develop/LICENSE.md
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change this to "urbanopt-cli" instead of example geojson project

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doh! Done

# *********************************************************************************

require 'urbanopt/reporting'
Expand Down Expand Up @@ -37,7 +37,7 @@ def initialize

# add any paths local to the project
@@osw[:measure_paths] << File.join(File.dirname(__FILE__), '../measures/')
@@osw[:measure_paths] << File.join(File.dirname(__FILE__), '../resources/hpxml-measures')
@@osw[:measure_paths] << File.join(File.dirname(__FILE__), '../resources/residential-measures/resources/hpxml-measures')
@@osw[:file_paths] << File.join(File.dirname(__FILE__), '../weather/')

# configures OSW with extension gem paths for measures and files, all extension gems must be
Expand Down Expand Up @@ -264,7 +264,7 @@ def commercial_building_types
def get_climate_zone_iecc(epw)
headers = CSV.open(epw, 'r', &:first)
wmo = headers[5]
zones_csv = Pathname(__FILE__).dirname.parent / 'resources' / 'hpxml-measures' / 'HPXMLtoOpenStudio' / 'resources' / 'data' / 'climate_zones.csv'
zones_csv = Pathname(__FILE__).dirname.parent / 'resources' / 'residential-measures' / 'resources' / 'hpxml-measures' / 'HPXMLtoOpenStudio' / 'resources' / 'data' / 'climate_zones.csv'

# Check if the CSV file is empty
if File.empty?(epw)
Expand Down Expand Up @@ -549,12 +549,13 @@ def create_osw(scenario, features, feature_names)
end

# Start general residential mapping
# mappers/residential/util.rb
args = {}
require File.join(File.dirname(__FILE__), 'residential/util')
residential(scenario, feature, args, building_type)

# Then onto optional "template" mapping
# mappers/residential/template
# mappers/residential/template/util.rb
template = nil
begin
template = feature.template
Expand All @@ -566,9 +567,60 @@ def create_osw(scenario, features, feature_names)
residential_template(args, template, climate_zone)
end

# Parse BuildResidentialModel measure xml so we can override defaults
# Then onto optional "samples" mapping
# mappers/residential/samples/util.rb
uo_resstock_connection = false
begin
uo_resstock_connection = feature.characterize_residential_buildings_from_buildstock_csv
rescue StandardError
end

# Run workflows if UO-ResStock connection is established
if uo_resstock_connection

buildstock_csv_path = nil
begin
csv_path = feature.resstock_buildstock_csv_path
buildstock_csv_path = File.absolute_path(File.join(File.dirname(__FILE__), '..', csv_path))
rescue StandardError
@@logger.error("\n resstock_buildstock_csv_path was not assigned by the user.")
end

uo_buildstock_mapping_csv_path = nil
begin
mapping_csv_path = feature.uo_buildstock_mapping_csv_path
uo_buildstock_mapping_csv_path = File.absolute_path(File.join(File.dirname(__FILE__), '..', mapping_csv_path))
rescue StandardError
@@logger.error("\n uo_buildstock_mapping_csv_path was not assigned by the user")
end

require File.join(File.dirname(__FILE__), 'residential/samples/util')
if !buildstock_csv_path.nil? # If resstock_buildstock_csv_path is provided
@@logger.info("Processing with BuildStock CSV path.")

start_time = Time.now # To document the time of finding the resstock building id
resstock_building_id = find_resstock_building_id(buildstock_csv_path, feature, building_type, @@logger)
puts "Processing time for finding a building match (resstock_building_id = #{resstock_building_id}) from the buildstock CSV: #{Time.now - start_time} seconds."

residential_samples(args, resstock_building_id, buildstock_csv_path)

elsif !uo_buildstock_mapping_csv_path.nil? # If uo_buildstock_mapping_csv_path is provided
@@logger.info("Processing with UO-BuildStock mapping CSV path.")

start_time = Time.now # To document the time of getting the resstock building id
resstock_building_id = find_building_for_uo_id(uo_buildstock_mapping_csv_path, feature.id)
puts "Processing time for finding the building match (resstock_building_id = #{resstock_building_id}) from the buildstock CSV: #{Time.now - start_time} seconds."

residential_samples(args, resstock_building_id, uo_buildstock_mapping_csv_path) # uo_buildstock_mapping_csv_path may contain a subset of all parameters

else
@@logger.error("The user did not specify either the uo_buildstock_mapping_csv_path or the resstock_buildstock_csv_path. At least one of these is required for UO - ResStock connection.")
end
end

# Parse BuildResidentialHPXML measure xml so we can fill "args" in with default values where keys aren't already assigned
default_args = {}
measures_dir = File.absolute_path(File.join(File.dirname(__FILE__), '../resources/hpxml-measures'))
measures_dir = File.absolute_path(File.join(File.dirname(__FILE__), '../resources/residential-measures/resources/hpxml-measures'))
measure_xml = File.read(File.join(measures_dir, 'BuildResidentialHPXML', 'measure.xml'))
measure = REXML::Document.new(measure_xml).root
measure.elements.each('arguments/argument') do |arg|
Expand All @@ -581,7 +633,7 @@ def create_osw(scenario, features, feature_names)
end
end

build_res_model_args = [:feature_id, :schedules_type, :schedules_random_seed, :schedules_variation, :geometry_num_floors_above_grade, :hpxml_dir, :output_dir]
build_res_model_args = [:urbanopt_feature_id, :resstock_buildstock_csv_path, :resstock_building_id, :schedules_type, :schedules_random_seed, :schedules_variation, :geometry_num_floors_above_grade, :hpxml_dir, :output_dir]
args.each_key do |arg_name|
unless default_args.key?(arg_name)
next if build_res_model_args.include?(arg_name)
Expand Down Expand Up @@ -1105,6 +1157,6 @@ def time_mapping(time)

return osw
end
end
end # end class
end
end
Loading