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

Upgrade to OpenStudio 3.9 and Ruby 3.2.2 #155

Merged
merged 59 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
898dcb3
bump to v0.13.0
vtnate Jul 18, 2024
a1112b6
clarify ruby version, remove duplicate dependencies
vtnate Jul 18, 2024
230b7d1
use branches of UO gems
vtnate Jul 18, 2024
6a8f6f2
use OS3.8 in CI
vtnate Jul 18, 2024
7128d33
use extension-gem branch temporarily
vtnate Jul 22, 2024
cb655d8
ensure we install bundle according to gemspec & gemfile in CI
vtnate Jul 22, 2024
be301c4
non-substantive typos
vtnate Jul 22, 2024
26a427a
remove requirement for certified because of Ruby 3
vtnate Jul 23, 2024
d55d923
remove references to certified, and make error messages visible
vtnate Jul 23, 2024
0d6936f
remove test file that doesn't do anything and isn't used
vtnate Jul 23, 2024
a93f56e
use newly released patch version 0.8.1 of extension-gem
vtnate Jul 30, 2024
f9fdf52
update reopt ghp lcca outputs in schema
tanushree04 Jun 11, 2024
65402b9
add input processing
tanushree04 Jul 30, 2024
b82439a
add reopt api call and tests
tanushree04 Sep 11, 2024
8135b91
update test files and code
tanushree04 Sep 12, 2024
f023142
make folder reopt input only when not exist, add heat pump size
tanushree04 Sep 12, 2024
5e2a34b
update electrical power value
tanushree04 Sep 16, 2024
f304cd8
update reopt api polling
tanushree04 Sep 17, 2024
b2eac71
add test
tanushree04 Sep 17, 2024
183d553
update tests
tanushree04 Sep 18, 2024
2f2aa20
uodate tests
tanushree04 Sep 18, 2024
13ff59f
remove puts statement
tanushree04 Sep 18, 2024
9c13427
update input reopt file
tanushree04 Sep 23, 2024
1310070
update reopt assumption file
tanushree04 Sep 23, 2024
9177f69
update whitespace
tanushree04 Sep 23, 2024
64999a8
update modelica result
tanushree04 Sep 28, 2024
581f2b3
update inputs
tanushree04 Oct 1, 2024
4a90bd6
uncomment test
tanushree04 Oct 14, 2024
99e9615
add feature reports
tanushree04 Nov 5, 2024
105e3e0
update test
tanushree04 Nov 5, 2024
ec836ef
update schema
tanushree04 Nov 5, 2024
49445a3
update gitignore
tanushree04 Nov 5, 2024
60547ff
expose error messages for certificate verify failed (#151)
kflemin Oct 9, 2024
a5b3c6e
fix typos and linting
vtnate Nov 4, 2024
7f57bff
clean up a few more paths
vtnate Nov 4, 2024
9d6f96c
use run_dir from class instatiation instead of manually
vtnate Nov 4, 2024
57ff31d
more path cleanup
vtnate Nov 5, 2024
29bb87d
remove reopt_ghp transient test dir from git
vtnate Nov 5, 2024
4355c0b
remove extra trailing newline from gitignore
vtnate Nov 5, 2024
c2c2c5d
fix path to test dir in gitignore
vtnate Nov 5, 2024
c39aab9
delete one more test outuput file during the test
vtnate Nov 5, 2024
8d5cef1
fix path to reopt_ghp during test prep
vtnate Nov 5, 2024
9a49a83
WIP: fix a few magic numbers
vtnate Nov 5, 2024
45c54ef
probably last path cleanup in spec file
vtnate Nov 5, 2024
5fa3c8d
fix path for test file deletion
vtnate Nov 5, 2024
0a3fabd
update ghp adapter, add hour variable, update tests
tanushree04 Nov 11, 2024
799d61e
add formatting correction.
tanushree04 Nov 12, 2024
2b27c55
Merge branch 'develop' into os39
vtnate Nov 13, 2024
10d1680
use os39 branches for testing
vtnate Nov 13, 2024
d58d737
use os39 rc3 image in CI
vtnate Nov 13, 2024
c80dda7
remove certified requirement, not necessary in Ruby 3
vtnate Nov 13, 2024
fdf178f
don't track test output files in git
vtnate Nov 13, 2024
0c85419
use correct syntax for reopt_ghp in gitignore
vtnate Nov 13, 2024
b1a7d88
use real OS3.9 in CI
vtnate Dec 19, 2024
20222f9
use extension-gem branch
vtnate Dec 26, 2024
9af5f52
update dependencies
kflemin Jan 13, 2025
c81d59b
Updates to handle breaking changes from REopt v3.11 (#157)
vtnate Jan 27, 2025
9da0b18
update changelog
vtnate Jan 27, 2025
1951dc5
update copyright
vtnate Jan 27, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions .github/workflows/nightly_ci_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,16 @@ jobs:
# https://github.com/rbenv/ruby-build/discussions/1940
runs-on: ubuntu-latest
container:
image: docker://nrel/openstudio:3.7.0
image: docker://nrel/openstudio:3.9.0
steps:
- uses: actions/checkout@v4
- name: set git config options
shell: bash
run: |
git config --global --add safe.directory '*'
run: git config --global --add safe.directory '*'
- name: Update gems
run: |
bundle install
bundle update
bundle exec certified-update
- name: Run Rspec
run: bundle exec rspec
- name: Coveralls
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
/lib/measures/test_results
/lib/measures/.rubocop*
# test files
spec/files/run/baseline_scenario_ghe/reopt_ghp
spec/files/run/baseline_scenario_ghe/reopt_ghp/

developer_nrel_key.rb
# rspec failure tracking
Expand Down
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
# URBANopt REopt Gem

## Version 1.0.0

## What's Changed

* Upgrade to OpenStudio 3.9 and Ruby 3.2.2 by @vtnate in https://github.com/urbanopt/urbanopt-reopt-gem/pull/155
* Updates for REopt v3.11 by @vtnate in https://github.com/urbanopt/urbanopt-reopt-gem/pull/157

### Other Changes

* expose error messages for certificate verify failed by @kflemin in https://github.com/urbanopt/urbanopt-reopt-gem/pull/151
* REopt GHP LCCA Analysis by @tanushree04 in https://github.com/urbanopt/urbanopt-reopt-gem/pull/153

**Full Changelog**: https://github.com/urbanopt/urbanopt-reopt-gem/compare/v0.12.0...v1.0.0

## Version 0.12.0

Date Range: 01/11/24 - 05/06/24

* Use Reopt v3 by @vtnate in https://github.com/urbanopt/urbanopt-reopt-gem/pull/149

**Full Changelog**: https://github.com/urbanopt/urbanopt-reopt-gem/compare/v0.11.0...v0.12.0

## Version 0.11.0

Date Range: 07/06/23 - 01/11/24

* Use different error messages in different places by @vtnate in https://github.com/urbanopt/urbanopt-reopt-gem/pull/145
Expand All @@ -17,6 +34,7 @@ Date Range: 07/06/23 - 01/11/24
**Full Changelog**: https://github.com/urbanopt/urbanopt-reopt-gem/compare/v0.10.0...v0.11.0

## Version 0.10.0

Date Range: 12/13/22 - 7/6/23

- Update dependencies for OpenStudio 3.6.1
Expand Down
27 changes: 16 additions & 11 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ allow_local = ENV['FAVOR_LOCAL_GEMS']
# if allow_local && File.exist?('../OpenStudio-extension-gem')
# gem 'openstudio-extension', path: '../OpenStudio-extension-gem'
# elsif allow_local
# gem 'openstudio-extension', github: 'NREL/OpenStudio-extension-gem', branch: 'develop'
# gem 'openstudio-extension', github: 'NREL/OpenStudio-extension-gem', branch: 'develop'
# else
# gem 'openstudio-extension', '~> 0.8.1'
# end
#
# if allow_local && File.exist?('../openstudio-common-measures-gem')
Expand All @@ -41,14 +43,17 @@ allow_local = ENV['FAVOR_LOCAL_GEMS']
# gem 'openstudio-model-articulation', '0.1.0'
# end

# if allow_local && File.exist?('../urbanopt-scenario-gem')
# gem 'urbanopt-scenario', path: '../urbanopt-scenario-gem'
# elsif allow_local
# gem 'urbanopt-scenario', github: 'URBANopt/urbanopt-scenario-gem', branch: 'reopt-v3'
# end
if allow_local && File.exist?('../urbanopt-scenario-gem')
gem 'urbanopt-scenario', path: '../urbanopt-scenario-gem'
elsif allow_local
gem 'urbanopt-scenario', github: 'URBANopt/urbanopt-scenario-gem', branch: 'develop'
end

# if allow_local && File.exists?('../urbanopt-geojson-gem')
# gem 'urbanopt-geojson', path: '../urbanopt-geojson-gem'
# elsif allow_local
# gem 'urbanopt-geojson', github: 'URBANopt/urbanopt-geojson-gem', branch: 'develop'
# end
# Temporary! Remove this once reporting-gem is merged/released
# gem 'urbanopt-reporting', github: 'URBANopt/urbanopt-reporting-gem', branch: 'develop'

if allow_local && File.exist?('../urbanopt-geojson-gem')
gem 'urbanopt-geojson', path: '../urbanopt-geojson-gem'
elsif allow_local
gem 'urbanopt-geojson', github: 'URBANopt/urbanopt-geojson-gem', branch: 'develop'
end
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
URBANopt (tm), Copyright (c) 2019-2024, Alliance for Sustainable Energy, LLC, and other
URBANopt (tm), Copyright (c) 2019-2025, 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 doc_templates/LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
URBANopt (tm), Copyright (c) 2019-2024, Alliance for Sustainable Energy, LLC, and other
URBANopt (tm), Copyright (c) 2019-2025, 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 doc_templates/copyright_erb.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<%
# *********************************************************************************
# URBANopt (tm), Copyright (c) 2019-2024, Alliance for Sustainable Energy, LLC, and other
# URBANopt (tm), Copyright (c) 2019-2025, 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 docs/schemas/reopt-output-schema.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# REopt Lite Outputs Schema

When the gem calls the REopt Lite APUI it recieves the following complete set of results described in the data dictionary below. Only those needed to update a Feature or Scenario Report's distributed_generation attibute set and timeseries CSV are pulled from the reponse and transferred to the Feature or Scenario Report. You may choose to modify the code to include more or less of the full REopt Lite response.
When the gem calls the REopt Lite APUI it receives the following complete set of results described in the data dictionary below. Only those needed to update a Feature or Scenario Report's distributed_generation attribute set and timeseries CSV are pulled from the response and transferred to the Feature or Scenario Report. You may choose to modify the code to include more or less of the full REopt Lite response.

## Data Dictionary
<ReoptOutputSchema />
Expand Down
9 changes: 4 additions & 5 deletions lib/urbanopt/reopt/feature_report_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ def reopt_json_from_feature_report(feature_report, reopt_assumptions_hash = nil,
else
@@logger.info('Using default REopt assumptions')
reopt_inputs = {
Settings:{},
Settings: {},
Site: {},
Financial:{},
Financial: {},
ElectricTariff: {
monthly_demand_rates: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
monthly_energy_rates: [0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13]
Expand Down Expand Up @@ -158,7 +158,6 @@ def reopt_json_from_feature_report(feature_report, reopt_assumptions_hash = nil,
# [*return:*] _URBANopt::Reporting::DefaultReports::FeatureReport_ - Returns an updated FeatureReport.
##
def update_feature_report(feature_report, reopt_output, timeseries_csv_path = nil, resilience_stats = nil)

# Check if the \REopt response is valid
if reopt_output['status'] != 'optimal'
@@logger.error("ERROR cannot update Feature Report #{feature_report.name} #{feature_report.id} - REopt optimization was non-optimal")
Expand Down Expand Up @@ -439,15 +438,15 @@ def modrow(x, i) # :nodoc:
x[$storage_to_grid_col] = $storage_to_grid[i] || 0 if defined?(storage)
x[$storage_soc_col] = $storage_soc[i] || 0 if defined?(storage)
x[$generator_total_col] = $generator_total[i] || 0 if defined?(generator)
x[$generator_to_battery_col] = $generator_to_battery[i] || 0 if (defined?(generator) && defined?(storage))
x[$generator_to_battery_col] = $generator_to_battery[i] || 0 if defined?(generator) && defined?(storage)
x[$generator_to_load_col] = $generator_to_load[i] || 0 if defined?(generator)
x[$generator_to_grid_col] = $generator_to_grid[i] || 0 if defined?(generator)
x[$pv_total_col] = $pv_total[i] || 0
x[$pv_to_battery_col] = $pv_to_battery[i] || 0 if defined?(storage)
x[$pv_to_load_col] = $pv_to_load[i] || 0
x[$pv_to_grid_col] = $pv_to_grid[i] || 0
x[$wind_total_col] = $wind_total[i] || 0 if defined?(wind)
x[$wind_to_battery_col] = $wind_to_battery[i] || 0 if (defined?(wind) && defined?(storage))
x[$wind_to_battery_col] = $wind_to_battery[i] || 0 if defined?(wind) && defined?(storage)
x[$wind_to_load_col] = $wind_to_load[i] || 0 if defined?(wind)
x[$wind_to_grid_col] = $wind_to_grid[i] || 0 if defined?(wind)
return x
Expand Down
5 changes: 3 additions & 2 deletions lib/urbanopt/reopt/reopt_ghp_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class REoptGHPAdapter
def initialize
# initialize @@logger
@@logger ||= URBANopt::REopt.reopt_logger
# Define class variable
# Define class variable
@@hours_in_year = 8760
end

Expand Down Expand Up @@ -247,7 +247,8 @@ def create_reopt_input_district(run_dir, system_parameter_hash, reopt_ghp_assump
# This is not used in REopt calculation but required for formatting.
reopt_inputs_district[:DomesticHotWaterLoad][:fuel_loads_mmbtu_per_hour] = [0.0000001]*@@hours_in_year

reopt_inputs_district[:ElectricLoad] = {}
# Adding year for ElectricLoad so district electric load can be calculated with REopt API v3.11
reopt_inputs_district[:ElectricLoad] = {:year => 2017}
#required for reopt formatting
reopt_inputs_district[:ElectricLoad][:loads_kw] = [0.00001]*@@hours_in_year

Expand Down
1 change: 0 additions & 1 deletion lib/urbanopt/reopt/reopt_ghp_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
require 'uri'
require 'json'
require 'securerandom'
require 'certified'
require_relative '../../../developer_nrel_key'
require 'urbanopt/reopt/reopt_logger'

Expand Down
9 changes: 5 additions & 4 deletions lib/urbanopt/reopt/reopt_ghp_files/reopt_ghp_assumption.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,20 @@
},
"SpaceHeatingLoad": {
},
"DomesticHotWaterLoad": {
"DomesticHotWaterLoad": {
},
"ElectricLoad": {
"ElectricLoad": {
"year": 2017
},
"ElectricTariff": {
"urdb_label": "594976725457a37b1175d089"
"urdb_label": "594976725457a37b1175d089"
},
"GHP":{
"installed_cost_heatpump_per_ton": 1075,
"installed_cost_ghx_per_ft": 14,
"installed_cost_building_hydronic_loop_per_sqft": 1.7,
"om_cost_per_sqft_year": 0,
"macrs_bonus_fraction": 0.6,
"macrs_bonus_fraction": 0.6,
"macrs_itc_reduction": 0.5,
"federal_itc_fraction": 0.3
},
Expand Down
28 changes: 11 additions & 17 deletions lib/urbanopt/reopt/reopt_ghp_post_processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
module URBANopt # :nodoc:
module REopt # :nodoc:
class REoptGHPPostProcessor

def initialize(run_dir, system_parameter, modelica_result, reopt_ghp_assumptions = nil, nrel_developer_key = nil, localhost)
# initialize @@logger
@@logger ||= URBANopt::REopt.reopt_logger
Expand Down Expand Up @@ -42,11 +41,11 @@ def initialize(run_dir, system_parameter, modelica_result, reopt_ghp_assumptions
File.open(system_parameter, 'r') do |file|
@system_parameter_input_hash = JSON.parse(file.read, symbolize_names: true)
end
#Determine loop order
# Determine loop order
loop_order = File.join(File.dirname(system_parameter), '_loop_order.json')
if File.exist?(loop_order)
File.open(loop_order, 'r') do |file|
loop_order_input= JSON.parse(file.read, symbolize_names: true)
loop_order_input = JSON.parse(file.read, symbolize_names: true)
# Check the type of the parsed data
if loop_order_input.is_a?(Array)
@loop_order_input_hash = loop_order_input
Expand All @@ -61,7 +60,7 @@ def initialize(run_dir, system_parameter, modelica_result, reopt_ghp_assumptions
puts "GHE IDs in group: #{item[:list_ghe_ids_in_group].inspect}"
end
else
puts "Unexpected JSON structure"
puts 'Unexpected JSON structure'
end
end
end
Expand All @@ -77,7 +76,6 @@ def initialize(run_dir, system_parameter, modelica_result, reopt_ghp_assumptions

# # Create REopt input and output building report
def run_reopt_lcca(system_parameter_hash: nil, reopt_ghp_assumptions_hash: nil, modelica_result: nil)

adapter = URBANopt::REopt::REoptGHPAdapter.new

# if these arguments are specified, use them
Expand All @@ -89,22 +87,21 @@ def run_reopt_lcca(system_parameter_hash: nil, reopt_ghp_assumptions_hash: nil,
@reopt_ghp_assumptions_input_hash = reopt_ghp_assumptions_hash
end


if !modelica_result.nil?
@modelica_result_input = modelica_result
end

# Create folder for REopt input files only if they dont exist
reopt_ghp_dir = File.join(@run_dir, "reopt_ghp")
reopt_ghp_input = File.join(reopt_ghp_dir, "reopt_ghp_inputs")
reopt_ghp_dir = File.join(@run_dir, 'reopt_ghp')
reopt_ghp_input = File.join(reopt_ghp_dir, 'reopt_ghp_inputs')
unless Dir.exist?(reopt_ghp_dir)
FileUtils.mkdir_p(reopt_ghp_dir)
end
unless Dir.exist?(reopt_ghp_input)
FileUtils.mkdir_p(reopt_ghp_input)
end

reopt_ghp_output = File.join(reopt_ghp_dir, "reopt_ghp_outputs")
reopt_ghp_output = File.join(reopt_ghp_dir, 'reopt_ghp_outputs')
unless Dir.exist?(reopt_ghp_output)
FileUtils.mkdir_p(reopt_ghp_output)
end
Expand Down Expand Up @@ -142,14 +139,11 @@ def run_reopt_lcca(system_parameter_hash: nil, reopt_ghp_assumptions_hash: nil,

# reopt_ghp_output_file
reopt_output_file = File.join(reopt_ghp_output, "#{base_name}_output.json")
#call the REopt API
# call the REopt API
api = URBANopt::REopt::REoptLiteGHPAPI.new(reopt_input_data, DEVELOPER_NREL_KEY, reopt_output_file, @localhost)
api.get_api_results()

api.get_api_results
end

end

end #REoptGHPPostProcessor
end #REopt
end #URBANopt
end # REoptGHPPostProcessor
end # REopt
end # URBANopt
3 changes: 1 addition & 2 deletions lib/urbanopt/reopt/reopt_lite_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
require 'uri'
require 'json'
require 'securerandom'
require 'certified'
require_relative '../../../developer_nrel_key'
require 'urbanopt/reopt/reopt_logger'

Expand Down Expand Up @@ -116,7 +115,7 @@ def make_request(http, req, max_tries = 3)
if tries + 1 < max_tries
@@logger.debug('trying again...')
else
@@logger.debug('max tries reached!')
@@logger.warn('max tries reached!')
return result
end
tries += 1
Expand Down
1 change: 0 additions & 1 deletion lib/urbanopt/reopt/reopt_post_processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ def initialize(scenario_report, scenario_reopt_assumptions_file = nil, reopt_fea
end
@nrel_developer_key = nrel_developer_key
@localhost = localhost
@reopt_base_post = { ElectricTariff: {}, ElectricLoad: {}, Wind: { max_kw: 0 } }

@scenario_reopt_default_output_file = nil
@scenario_timeseries_default_output_file = nil
Expand Down
5 changes: 2 additions & 3 deletions lib/urbanopt/reopt/reopt_schema/REopt-GHP-input.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
},
"building_sqft": {
"type": "float",
"requierd": true,
"required": true,
"description": "to calculate cost of hydronic loop",
"note": "for the GHX iteration, set building_sqft to a number close to 0 but not exactly 0"
},
Expand All @@ -69,7 +69,7 @@
"number_of_boreholes": {
"type": "int",
"required": true,
"note": "in the GHP iteration, set this value to 0"
"note": "in the GHP iteration, set this value to 0"
},
"length_boreholes_ft": {
"type": "float",
Expand Down Expand Up @@ -146,4 +146,3 @@
}
}
}

Loading
Loading