Skip to content

Commit

Permalink
Merge pull request #114 from urbanopt/hpwh-scenario
Browse files Browse the repository at this point in the history
Hpwh scenario
  • Loading branch information
rawadelkontar authored Aug 9, 2021
2 parents 55d57c8 + 0e2dd03 commit fc7c7a0
Show file tree
Hide file tree
Showing 5 changed files with 170 additions and 9 deletions.
8 changes: 8 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,11 @@ elsif allow_local
else
gem 'urbanopt-reopt', '0.6.0'
end

if allow_local && File.exist?('../openstudio-load-flexibility-measures-gem')
gem 'openstudio-load-flexibility-measures', path: '../openstudio-load-flexibility-measures-gem'
elsif allow_local
gem 'openstudio-load-flexibility-measures', github: 'NREL/openstudio-load-flexibility-measures-gem', branch: 'master'
else
gem 'openstudio-load-flexibility-measures', '0.3.2'
end
78 changes: 69 additions & 9 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,18 @@ def thermal_storage_scenario(json, csv)
return scenario
end

def flexible_hot_water_scenario(json, csv)
name = 'Flexible Hot Water Scenario'
run_dir = File.join(root_dir, 'run/flexiblehotwater_scenario/')
feature_file_path = File.join(root_dir, json)
csv_file = File.join(root_dir, csv)
mapper_files_dir = File.join(root_dir, 'mappers/')
num_header_rows = 1
feature_file = URBANopt::GeoJSON::GeoFile.from_file(feature_file_path)
scenario = URBANopt::Scenario::ScenarioCSV.new(name, root_dir, run_dir, feature_file, mapper_files_dir, csv_file, num_header_rows)
return scenario
end

def mixed_scenario(json, csv)
name = 'Mixed Scenario'
run_dir = File.join(root_dir, 'run/mixed_scenario/')
Expand Down Expand Up @@ -151,7 +163,7 @@ def configure_project
# write a runner.conf in project dir if it does not exist
# delete runner.conf to automatically regenerate it
options = {gemfile_path: File.join(root_dir, 'Gemfile'), bundle_install_path: File.join(root_dir, ".bundle/install"), num_parallel: 7}

# write a runner.conf in project dir (if it does not already exist)
if !File.exists?(File.join(root_dir, 'runner.conf'))
puts "GENERATING runner.conf file"
Expand Down Expand Up @@ -388,6 +400,53 @@ task :post_process_thermal_storage, [:json, :csv] do |t, args|
scenario_result.feature_reports.each(&:save_csv_report)
end

### Flexible Hot Water

desc 'Clear Flexible Hot Water Scenario'
task :clear_flexible_hot_water, [:json, :csv] do |t, args|
puts 'Clearing Flexible Hot Water Scenario...'

json = args[:json]
csv = args[:csv]
json = 'example_project_combined.json' if json.nil?
csv = 'flexible_hot_water_scenario.csv' if csv.nil?

flexible_hot_water_scenario(json, csv).clear
end

desc 'Run Flexible Hot Water Scenario'
task :run_flexible_hot_water, [:json, :csv] do |t, args|
puts 'Running Flexible Hot Water Scenario...'

json = args[:json]
csv = args[:csv]
json = 'example_project_combined.json' if json.nil?
csv = 'flexible_hot_water_scenario.csv' if csv.nil?

configure_project

scenario_runner = URBANopt::Scenario::ScenarioRunnerOSW.new
scenario_runner.run(flexible_hot_water_scenario(json, csv))
end

desc 'Post Process Flexible Hot Water Scenario'
task :post_process_flexible_hot_water, [:json, :csv] do |t, args|
puts 'Post Processing Flexible Hot Water Scenario...'

json = args[:json]
csv = args[:csv]
json = 'example_project_combined.json' if json.nil?
csv = 'flexible_hot_water_scenario.csv' if csv.nil?

default_post_processor = URBANopt::Scenario::ScenarioDefaultPostProcessor.new(flexible_hot_water_scenario(json, csv))
scenario_result = default_post_processor.run
# save scenario reports
scenario_result.save
# save feature reports
scenario_result.feature_reports.each(&:save_json_report)
scenario_result.feature_reports.each(&:save_csv_report)
end

### REopt

desc 'Clear REopt Scenario'
Expand Down Expand Up @@ -427,7 +486,7 @@ task :post_process_reopt, [:json, :csv] do |t, args|
# save feature reports
scenario_report.feature_reports.each(&:save_json_report)
scenario_report.feature_reports.each(&:save_csv_report)

scenario_base = default_post_processor.scenario_base
reopt_post_processor = URBANopt::REopt::REoptPostProcessor.new(scenario_report, scenario_base.scenario_reopt_assumptions_file, scenario_base.reopt_feature_assumptions, DEVELOPER_NREL_KEY)

Expand All @@ -438,7 +497,6 @@ task :post_process_reopt, [:json, :csv] do |t, args|
scenario_report_features = reopt_post_processor.run_scenario_report_features(scenario_report: scenario_report, save_names_feature_reports: ['feature_report_reopt']* scenario_report.feature_reports.length, save_name_scenario_report: 'scenario_report_reopt_local_optimization')
end


### Mixed

desc 'Clear Mixed Scenario'
Expand Down Expand Up @@ -494,32 +552,32 @@ task :visualize_scenarios do
visualize_scenarios
end

## Visualize feature results
## Visualize feature results

desc 'Visualize and compare results for all Features in a Scenario'
task :visualize_features, [:csv] do |t, args|
puts 'Visualizing results for all Features in the Scenario...'

csv = args[:csv]
csv = 'baseline_scenario.csv' if args[:csv].nil?

visualize_features(csv)
end

### All

desc 'Clear all scenarios'
task :clear_all => [:clear_baseline, :clear_high_efficiency, :clear_thermal_storage, :clear_reopt, :clear_mixed] do
task :clear_all => [:clear_baseline, :clear_high_efficiency, :clear_thermal_storage, :clear_flexible_hot_water, :clear_reopt, :clear_mixed] do
# clear all the scenarios
end

desc 'Run all scenarios'
task :run_all => [:run_baseline, :run_high_efficiency, :run_thermal_storage, :run_reopt, :run_mixed] do
task :run_all => [:run_baseline, :run_high_efficiency, :run_thermal_storage, :run_flexible_hot_water, :run_reopt, :run_mixed] do
# run all the scenarios
end

desc 'Post process all scenarios'
task :post_process_all => [:post_process_baseline, :post_process_high_efficiency, :post_process_thermal_storage, :post_process_reopt, :post_process_mixed] do
task :post_process_all => [:post_process_baseline, :post_process_high_efficiency, :post_process_thermal_storage, :post_process_flexible_hot_water, :post_process_reopt, :post_process_mixed] do
# post_process all the scenarios
end

Expand All @@ -532,6 +590,8 @@ task :visualize_all do
Rake::Task["visualize_features"].reenable
Rake::Task["visualize_features"].invoke("thermal_storage_scenario.csv")
Rake::Task["visualize_features"].reenable
Rake::Task["visualize_features"].invoke("flexible_hot_water_scenario.csv")
Rake::Task["visualize_features"].reenable
Rake::Task["visualize_features"].invoke("reopt_scenario.csv")
Rake::Task["visualize_features"].reenable
Rake::Task["visualize_features"].invoke("mixed_scenario.csv")
Expand Down
19 changes: 19 additions & 0 deletions example_project/flexible_hot_water_scenario.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Feature Id,Feature Name,Mapper Class
1,Mixed_use 1,URBANopt::Scenario::FlexibleHotWaterMapper
2,Restaurant 1,URBANopt::Scenario::FlexibleHotWaterMapper
3,Restaurant 10,URBANopt::Scenario::FlexibleHotWaterMapper
4,Restaurant 12,URBANopt::Scenario::FlexibleHotWaterMapper
5,Restaurant 14,URBANopt::Scenario::FlexibleHotWaterMapper
6,Restaurant 15,URBANopt::Scenario::FlexibleHotWaterMapper
7,Office 1,URBANopt::Scenario::FlexibleHotWaterMapper
8,Hospital 1,URBANopt::Scenario::FlexibleHotWaterMapper
9,Hospital 2,URBANopt::Scenario::FlexibleHotWaterMapper
10,Mixed use 2,URBANopt::Scenario::FlexibleHotWaterMapper
11,Restaurant 13,URBANopt::Scenario::FlexibleHotWaterMapper
12,Mall 1,URBANopt::Scenario::FlexibleHotWaterMapper
13,Hotel 1,URBANopt::Scenario::FlexibleHotWaterMapper
14,Residential 1,URBANopt::Scenario::FlexibleHotWaterMapper
15,Residential 2,URBANopt::Scenario::FlexibleHotWaterMapper
16,Residential 3,URBANopt::Scenario::FlexibleHotWaterMapper
17,Residential 4,URBANopt::Scenario::FlexibleHotWaterMapper
18,Residential 5,URBANopt::Scenario::FlexibleHotWaterMapper
69 changes: 69 additions & 0 deletions example_project/mappers/FlexibleHotWater.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#*********************************************************************************
# URBANopt™, Copyright (c) 2019-2020, Alliance for Sustainable Energy, LLC, and other
# contributors. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# Redistributions of source code must retain the above copyright notice, this list
# of conditions and the following disclaimer.
#
# Redistributions in binary form must reproduce the above copyright notice, this
# list of conditions and the following disclaimer in the documentation and/or other
# materials provided with the distribution.
#
# Neither the name of the copyright holder nor the names of its contributors may be
# used to endorse or promote products derived from this software without specific
# prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
# OF THE POSSIBILITY OF SUCH DAMAGE.
#*********************************************************************************

require 'urbanopt/reporting'

require_relative 'Baseline'

require 'json'

module URBANopt
module Scenario
class FlexibleHotWaterMapper < BaselineMapper

def create_osw(scenario, features, feature_names)

osw = super(scenario, features, feature_names)

feature = features[0]
building_type = feature.building_type

# Only apply to commercial buildings, not residential models
if commercial_building_types.include? building_type
OpenStudio::Extension.set_measure_argument(osw, 'add_hpwh', '__SKIP__', false)
# Add a sizing multiplier to the tank capacity to cover flex periods
OpenStudio::Extension.set_measure_argument(osw, 'add_hpwh', 'vol', 2)
# Update maximum tank and minimum temperature setpoints
OpenStudio::Extension.set_measure_argument(osw, 'add_hpwh', 'max_temp', 185)
OpenStudio::Extension.set_measure_argument(osw, 'add_hpwh', 'min_temp', 125)

# Manage water heat charge float periods by building
OpenStudio::Extension.set_measure_argument(osw, 'add_hpwh', 'flex0', 'Charge - Heat Pump')
OpenStudio::Extension.set_measure_argument(osw, 'add_hpwh', 'flex_hrs0', '16:00-17:00')
OpenStudio::Extension.set_measure_argument(osw, 'add_hpwh', 'flex1', 'Float')
OpenStudio::Extension.set_measure_argument(osw, 'add_hpwh', 'flex_hrs1', '17:01-19:00')
end

return osw
end

end
end
end
5 changes: 5 additions & 0 deletions example_project/mappers/base_workflow.osw
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@
"charge_start": "23:00",
"inter_sp": 46
}
},{
"measure_dir_name":"add_hpwh",
"arguments":{
"__SKIP__":true
}
},{
"measure_dir_name": "add_packaged_ice_storage",
"arguments": {
Expand Down

0 comments on commit fc7c7a0

Please sign in to comment.