diff --git a/.gitignore b/.gitignore index a46d0ab9..b80896f1 100644 --- a/.gitignore +++ b/.gitignore @@ -6,9 +6,11 @@ /pkg/ /spec/reports/ /tmp/ +.DS_Store # local dev IDE settings .vscode/ +.idea/ # rbenv virtualenv management file .ruby-version @@ -20,3 +22,4 @@ spec/test_directory Gemfile.lock +.rubocop* diff --git a/CHANGELOG.md b/CHANGELOG.md index 53592ccd..33c35429 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## Version 0.2.3 -Date Range: 04/01/20 - 04/17/20: +Date Range: 04/01/20 - 04/23/20: - Fixed [#65]( https://github.com/urbanopt/urbanopt-cli/issues/65 ), Add more tests - Fixed [#81]( https://github.com/urbanopt/urbanopt-cli/issues/81 ), Mappers weren't updated for version 0.2 @@ -10,6 +10,7 @@ Date Range: 04/01/20 - 04/17/20: - Fixed [#85]( https://github.com/urbanopt/urbanopt-cli/issues/85 ), reopt dependency not installed - Fixed [#88]( https://github.com/urbanopt/urbanopt-cli/issues/88 ), Reopt tests are failing - Fixed [#90]( https://github.com/urbanopt/urbanopt-cli/issues/90 ), Update baseline mapper +- Fixed [#92]( https://github.com/urbanopt/urbanopt-cli/issues/92 ), baseline mapper bug reading json file ## Version 0.2.2 diff --git a/example_files/example_project.json b/example_files/example_project.json index d329944f..0e945828 100644 --- a/example_files/example_project.json +++ b/example_files/example_project.json @@ -13,7 +13,7 @@ "cec_climate_zone": null, "climate_zone": "6A", "default_template": "90.1-2013", - "end_date": "2017-13-31T07:00:00.000Z", + "end_date": "2017-12-31T07:00:00.000Z", "id": "53340c2c-ab20-40db-aba1-11ac607c52a7", "import_surrounding_buildings_as_shading": null, "name": "Site Origin", diff --git a/example_files/mappers/Baseline.rb b/example_files/mappers/Baseline.rb index ca751437..f9e8b3f7 100644 --- a/example_files/mappers/Baseline.rb +++ b/example_files/mappers/Baseline.rb @@ -1,32 +1,32 @@ -#********************************************************************************* -# URBANopt, Copyright (c) 2019-2020, Alliance for Sustainable Energy, LLC, and other +# ********************************************************************************* +# 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, +# +# 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 +# +# 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 +# +# 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 +# +# 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 +# +# 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/scenario' require 'openstudio/common_measures' @@ -37,28 +37,26 @@ module URBANopt module Scenario class BaselineMapper < SimulationMapperBase - # class level variables @@instance_lock = Mutex.new @@osw = nil @@geometry = nil - - def initialize() - + + def initialize # do initialization of class variables in thread safe way @@instance_lock.synchronize do - if @@osw.nil? + if @@osw.nil? # load the OSW for this class osw_path = File.join(File.dirname(__FILE__), 'base_workflow.osw') File.open(osw_path, 'r') do |file| @@osw = JSON.parse(file.read, symbolize_names: true) end - + # add any paths local to the project @@osw[:file_paths] << File.join(File.dirname(__FILE__), '../weather/') - - # configures OSW with extension gem paths for measures and files, all extension gems must be + + # configures OSW with extension gem paths for measures and files, all extension gems must be # required before this @@osw = OpenStudio::Extension.configure_osw(@@osw) end @@ -66,150 +64,149 @@ def initialize() end def lookup_building_type(building_type, template, footprint_area, number_of_stories) - if template.include? "DEER" + if template.include? 'DEER' case building_type - when "Education" - return "EPr" - when "Enclosed mall" - return "RtL" - when "Food sales" - return "RSD" - when "Food service" - return "RSD" - when "Inpatient health care" - return "Nrs" - when "Laboratory" - return "Hsp" - when "Lodging" - return "Htl" - when "Mixed use" - return "ECC" - when "Mobile Home" - return "DMo" - when "Multifamily (2 to 4 units)" - return "MFm" - when "Multifamily (5 or more units)" - return "MFm" - when "Nonrefrigerated warehouse" - return "SUn" - when "Nursing" - return "Nrs" - when "Office" + when 'Education' + return 'EPr' + when 'Enclosed mall' + return 'RtL' + when 'Food sales' + return 'RSD' + when 'Food service' + return 'RSD' + when 'Inpatient health care' + return 'Nrs' + when 'Laboratory' + return 'Hsp' + when 'Lodging' + return 'Htl' + when 'Mixed use' + return 'ECC' + when 'Mobile Home' + return 'DMo' + when 'Multifamily (2 to 4 units)' + return 'MFm' + when 'Multifamily (5 or more units)' + return 'MFm' + when 'Nonrefrigerated warehouse' + return 'SUn' + when 'Nursing' + return 'Nrs' + when 'Office' if footprint_area if footprint_area.to_f > 100000 - return "OfL" + return 'OfL' else - return "OfS" + return 'OfS' end else - raise "footprint_area required to map office building type" + raise 'footprint_area required to map office building type' end - when "Outpatient health care" - return "Nrs" - when "Public assembly" - return "Asm" - when "Public order and safety" - return "Asm" - when "Refrigerated warehouse" - return "WRf" - when "Religious worship" - return "Asm" - when "Retail other than mall" - return "RtS" - when "Service" - return "MLI" - when "Single-Family" - return "MFm" - when "Strip shopping mall" - return "RtL" - when "Vacant" - return "SUn" + when 'Outpatient health care' + return 'Nrs' + when 'Public assembly' + return 'Asm' + when 'Public order and safety' + return 'Asm' + when 'Refrigerated warehouse' + return 'WRf' + when 'Religious worship' + return 'Asm' + when 'Retail other than mall' + return 'RtS' + when 'Service' + return 'MLI' + when 'Single-Family' + return 'MFm' + when 'Strip shopping mall' + return 'RtL' + when 'Vacant' + return 'SUn' else - raise "building type #{building_type} cannot be mapped to a DEER building type" + raise "building type #{building_type} cannot be mapped to a DEER building type" end else # default: ASHRAE case building_type - when "Education" + when 'Education' return 'SecondarySchool' - when "Enclosed mall" - return "RetailStripmall" - when "Food sales" - return "FullServiceRestaurant" - when "Food service" - return "FullServiceRestaurant" - when "Inpatient health care" - return "Hospital" - when "Laboratory" - return "Hospital" - when "Lodging" + when 'Enclosed mall' + return 'RetailStripmall' + when 'Food sales' + return 'FullServiceRestaurant' + when 'Food service' + return 'FullServiceRestaurant' + when 'Inpatient health care' + return 'Hospital' + when 'Laboratory' + return 'Hospital' + when 'Lodging' if number_of_stories if number_of_stories.to_i > 3 - return "LargeHotel" + return 'LargeHotel' else - return "SmallHotel" + return 'SmallHotel' end end - return "LargeHotel" - when "Mixed use" - return "Mixed use" - when "Mobile Home" - return "MidriseApartment" - when "Multifamily (2 to 4 units)" - return "MidriseApartment" - when "Multifamily (5 or more units)" - return "MidriseApartment" - when "Nonrefrigerated warehouse" - return "Warehouse" - when "Nursing" - return "Outpatient" - when "Office" + return 'LargeHotel' + when 'Mixed use' + return 'Mixed use' + when 'Mobile Home' + return 'MidriseApartment' + when 'Multifamily (2 to 4 units)' + return 'MidriseApartment' + when 'Multifamily (5 or more units)' + return 'MidriseApartment' + when 'Nonrefrigerated warehouse' + return 'Warehouse' + when 'Nursing' + return 'Outpatient' + when 'Office' if footprint_area if footprint_area.to_f < 20000 - value = "SmallOffice" + value = 'SmallOffice' elsif footprint_area.to_f > 100000 - value = "LargeOffice" + value = 'LargeOffice' else - value = "MediumOffice" + value = 'MediumOffice' end else - raise "Floor area required to map office building type" + raise 'Floor area required to map office building type' end - when "Outpatient health care" - return "Outpatient" - when "Public assembly" - return "MediumOffice" - when "Public order and safety" - return "MediumOffice" - when "Refrigerated warehouse" - return "Warehouse" - when "Religious worship" - return "MediumOffice" - when "Retail other than mall" - return "RetailStandalone" - when "Service" - return "MediumOffice" - when "Single-Family" - return "MidriseApartment" - when "Strip shopping mall" - return "RetailStripmall" - when "Vacant" - return "Warehouse" + when 'Outpatient health care' + return 'Outpatient' + when 'Public assembly' + return 'MediumOffice' + when 'Public order and safety' + return 'MediumOffice' + when 'Refrigerated warehouse' + return 'Warehouse' + when 'Religious worship' + return 'MediumOffice' + when 'Retail other than mall' + return 'RetailStandalone' + when 'Service' + return 'MediumOffice' + when 'Single-Family' + return 'MidriseApartment' + when 'Strip shopping mall' + return 'RetailStripmall' + when 'Vacant' + return 'Warehouse' else raise "building type #{building_type} cannot be mapped to an ASHRAE building type" end end end - def lookup_template_by_year_built(template, year_built) - - if template.include? "DEER" + def lookup_template_by_year_built(template, year_built) + if template.include? 'DEER' if year_built <= 1996 return 'DEER 1985' elsif year_built <= 2003 return 'DEER 1996' - elsif year_built <= 2007 + elsif year_built <= 2007 return 'DEER 2003' elsif year_built <= 2011 return 'DEER 2007' @@ -223,9 +220,9 @@ def lookup_template_by_year_built(template, year_built) return 'DEER 2017' else return 'DEER 2020' - end + end else - # ASHRAE + # ASHRAE if year_built < 1980 return 'DOE Ref Pre-1980' elsif year_built <= 2004 @@ -236,65 +233,64 @@ def lookup_template_by_year_built(template, year_built) return '90.1-2007' elsif year_built <= 2013 return '90.1-2010' - else + else return '90.1-2013' end - end + end end - + def create_osw(scenario, features, feature_names) - if features.size != 1 - raise "TestMapper1 currently cannot simulate more than one feature" + raise 'TestMapper1 currently cannot simulate more than one feature' end feature = features[0] feature_id = feature.id - feature_type = feature.type + feature_type = feature.type feature_name = feature.name if feature_names.size == 1 feature_name = feature_names[0] end - + # deep clone of @@osw before we configure it osw = Marshal.load(Marshal.dump(@@osw)) - + # now we have the feature, we can look up its properties and set arguments in the OSW osw[:name] = feature_name osw[:description] = feature_name - + if feature_type == 'Building' # set_run_period begin - timesteps_per_hour = feature.timesteps_per_hour - if !timesteps_per_hour.empty? + timesteps_per_hour = feature.timesteps_per_hour + if timesteps_per_hour OpenStudio::Extension.set_measure_argument(osw, 'set_run_period', 'timesteps_per_hour', timesteps_per_hour) end - rescue + rescue StandardError end begin begin_date = feature.begin_date - if !feature.begin_date.empty? - # check date-only YYYY-MM-DD - if feature.begin_date.length > 10 - feature.begin_date = feature.begin_date[0, 10] + if begin_date + # check date-only YYYY-MM-DD + if begin_date.length > 10 + begin_date = begin_date[0, 10] end OpenStudio::Extension.set_measure_argument(osw, 'set_run_period', 'begin_date', begin_date) end - rescue + rescue StandardError end begin end_date = feature.end_date - if !feature.end_date.empty? + if end_date # check date-only YYYY-MM-DD - if feature.end_date.length > 10 - feature.end_date = feature.end_date[0, 10] + if end_date.length > 10 + end_date = end_date[0, 10] end OpenStudio::Extension.set_measure_argument(osw, 'set_run_period', 'end_date', end_date) end - rescue + rescue StandardError end - + # convert to hash building_hash = feature.to_hash # check for detailed model filename @@ -333,21 +329,21 @@ def create_osw(scenario, features, feature_names) mixed_type_2 = building_hash.key?(:mixed_type_2) ? building_hash[:mixed_type_2] : nil unless mixed_type_2.nil? mixed_type_2_percentage = building_hash[:mixed_type_2_percentage] - mixed_type_2_fract_bldg_area = mixed_type_2_percentage*0.01 + mixed_type_2_fract_bldg_area = mixed_type_2_percentage * 0.01 running_fraction += mixed_type_2_fract_bldg_area end mixed_type_3 = building_hash.key?(:mixed_type_3) ? building_hash[:mixed_type_3] : nil unless mixed_type_3.nil? mixed_type_3_percentage = building_hash[:mixed_type_3_percentage] - mixed_type_3_fract_bldg_area = mixed_type_3_percentage*0.01 + mixed_type_3_fract_bldg_area = mixed_type_3_percentage * 0.01 running_fraction += mixed_type_3_fract_bldg_area end - + mixed_type_4 = building_hash.key?(:mixed_type_4) ? building_hash[:mixed_type_4] : nil unless mixed_type_4.nil? mixed_type_4_percentage = building_hash[:mixed_type_4_percentage] - mixed_type_4_fract_bldg_area = mixed_type_4_percentage*0.01 + mixed_type_4_fract_bldg_area = mixed_type_4_percentage * 0.01 running_fraction += mixed_type_4_fract_bldg_area end @@ -370,7 +366,7 @@ def create_osw(scenario, features, feature_names) openstudio_mixed_type_4 = lookup_building_type(mixed_type_4, template, footprint_4, number_of_stories) end end - + floor_height = 10 # Map system type to openstudio system types # TODO: Map all system types @@ -385,13 +381,13 @@ def create_osw(scenario, features, feature_names) system_type = 'VAV air-cooled chiller with gas boiler reheat' end else - system_type = "Inferred" + system_type = 'Inferred' end def time_mapping(time) hour = time.split(':')[0] minute = time.split(':')[1] - fraction = minute.to_f/60 + fraction = minute.to_f / 60 fraction_roundup = fraction.round(2) minute_fraction = fraction_roundup.to_s.split('.')[1] new_time = [hour, minute_fraction].join('.') @@ -407,20 +403,26 @@ def time_mapping(time) begin cec_climate_zone = feature.cec_climate_zone if !cec_climate_zone.empty? - cec_climate_zone = "T24-CEC" + cec_climate_zone + cec_climate_zone = 'T24-CEC' + cec_climate_zone OpenStudio::Extension.set_measure_argument(osw, 'ChangeBuildingLocation', 'climate_zone', cec_climate_zone) cec_found = true + # Temporary fix for CEC climate zone: + cec_modified_zone = 'CEC ' + cec_climate_zone + OpenStudio::Extension.set_measure_argument(osw, 'create_bar_from_building_type_ratios', 'climate_zone', cec_modified_zone) + OpenStudio::Extension.set_measure_argument(osw, 'create_typical_building_from_model', 'climate_zone', cec_modified_zone, 'create_typical_building_from_model 1') + OpenStudio::Extension.set_measure_argument(osw, 'create_typical_building_from_model', 'climate_zone', cec_modified_zone, 'create_typical_building_from_model 2') + end - rescue + rescue StandardError end if !cec_found begin climate_zone = feature.climate_zone if !climate_zone.empty? - climate_zone = "ASHRAE 169-2013-" + climate_zone + climate_zone = 'ASHRAE 169-2013-' + climate_zone OpenStudio::Extension.set_measure_argument(osw, 'ChangeBuildingLocation', 'climate_zone', climate_zone) end - rescue + rescue StandardError end end @@ -431,26 +433,26 @@ def time_mapping(time) OpenStudio::Extension.set_measure_argument(osw, 'ChangeBuildingLocation', 'weather_file_name', weather_filename) puts "Setting weather_file_name to #{weather_filename} as specified in the FeatureFile" end - rescue - puts "No weather_file specified on feature" + rescue StandardError + puts 'No weather_file specified on feature' epw_file_path = Dir.glob(File.join(File.dirname(__FILE__), '../weather/*.epw'))[0] if !epw_file_path.nil? && !epw_file_path.empty? epw_file_name = File.basename(epw_file_path) OpenStudio::Extension.set_measure_argument(osw, 'ChangeBuildingLocation', 'weather_file_name', epw_file_name) puts "Setting weather_file_name to first epw file found in the weather folder: #{epw_file_name}" else - puts "NO WEATHER FILES SPECIFIED...SIMULATIONS MAY FAIL" + puts 'NO WEATHER FILES SPECIFIED...SIMULATIONS MAY FAIL' end end - #set weekday start time + # set weekday start time begin weekday_start_time = feature.weekday_start_time if !feature.weekday_start_time.empty? new_weekday_start_time = time_mapping(weekday_start_time) OpenStudio::Extension.set_measure_argument(osw, 'create_typical_building_from_model', 'wkdy_op_hrs_start_time', new_weekday_start_time, 'create_typical_building_from_model 1') end - rescue + rescue StandardError end # set weekday duration @@ -460,9 +462,9 @@ def time_mapping(time) new_weekday_duration = time_mapping(weekday_duration) OpenStudio::Extension.set_measure_argument(osw, 'create_typical_building_from_model', 'wkdy_op_hrs_duration', new_weekday_duration, 'create_typical_building_from_model 1') end - rescue + rescue StandardError end - + # set weekend start time begin weekend_start_time = feature.weekend_start_time @@ -470,9 +472,9 @@ def time_mapping(time) new_weekend_start_time = time_mapping(weekend_start_time) OpenStudio::Extension.set_measure_argument(osw, 'create_typical_building_from_model', 'wknd_op_hrs_start_time', new_weekend_start_time, 'create_typical_building_from_model 1') end - rescue + rescue StandardError end - + # set weekend duration begin weekend_duration = feature.weekend_duration @@ -480,7 +482,7 @@ def time_mapping(time) new_weekend_duration = time_mapping(weekend_duration) OpenStudio::Extension.set_measure_argument(osw, 'create_typical_building_from_model', 'wknd_op_hrs_duration', new_weekend_duration, 'create_typical_building_from_model 1') end - rescue + rescue StandardError end # template @@ -490,22 +492,22 @@ def time_mapping(time) # can we override template with year_built info? (keeping same template family) if building_hash.key?(:year_built) && !building_hash[:year_built].nil? && !feature.template.empty? - new_template = lookup_template_by_year_built(template, year_built) + new_template = lookup_template_by_year_built(template, year_built) elsif !feature.template.empty? new_template = template end - + if new_template OpenStudio::Extension.set_measure_argument(osw, 'create_bar_from_building_type_ratios', 'template', new_template) OpenStudio::Extension.set_measure_argument(osw, 'create_typical_building_from_model', 'template', new_template, 'create_typical_building_from_model 1') OpenStudio::Extension.set_measure_argument(osw, 'create_typical_building_from_model', 'template', new_template, 'create_typical_building_from_model 2') end - rescue + rescue StandardError end - + # TODO: surface_elevation has no current mapping # TODO: tariff_filename has no current mapping - + # create a bar building, will have spaces tagged with individual space types given the # input building types # set skip measure to false @@ -524,14 +526,14 @@ def time_mapping(time) unless mixed_type_2.nil? OpenStudio::Extension.set_measure_argument(osw, 'create_bar_from_building_type_ratios', 'bldg_type_b', openstudio_mixed_type_2) OpenStudio::Extension.set_measure_argument(osw, 'create_bar_from_building_type_ratios', 'bldg_type_b_fract_bldg_area', mixed_type_2_fract_bldg_area) - end - unless mixed_type_3.nil? + end + unless mixed_type_3.nil? OpenStudio::Extension.set_measure_argument(osw, 'create_bar_from_building_type_ratios', 'bldg_type_c', openstudio_mixed_type_3) OpenStudio::Extension.set_measure_argument(osw, 'create_bar_from_building_type_ratios', 'bldg_type_c_fract_bldg_area', mixed_type_3_fract_bldg_area) end unless mixed_type_4.nil? OpenStudio::Extension.set_measure_argument(osw, 'create_bar_from_building_type_ratios', 'bldg_type_d', openstudio_mixed_type_4) - OpenStudio::Extension.set_measure_argument(osw, 'create_bar_from_building_type_ratios', 'bldg_type_d_fract_bldg_area', mixed_type_4_fract_bldg_area) + OpenStudio::Extension.set_measure_argument(osw, 'create_bar_from_building_type_ratios', 'bldg_type_d_fract_bldg_area', mixed_type_4_fract_bldg_area) end end @@ -540,17 +542,17 @@ def time_mapping(time) OpenStudio::Extension.set_measure_argument(osw, 'create_typical_building_from_model', 'add_hvac', false, 'create_typical_building_from_model 1') # create a blended space type for each story - OpenStudio::Extension.set_measure_argument(osw, - 'blended_space_type_from_model', '__SKIP__', false) - OpenStudio::Extension.set_measure_argument(osw, - 'blended_space_type_from_model', 'blend_method', 'Building Story') + OpenStudio::Extension.set_measure_argument(osw, + 'blended_space_type_from_model', '__SKIP__', false) + OpenStudio::Extension.set_measure_argument(osw, + 'blended_space_type_from_model', 'blend_method', 'Building Story') # create geometry for the desired feature, this will reuse blended space types in the model for each story and remove the bar geometry OpenStudio::Extension.set_measure_argument(osw, 'urban_geometry_creation', '__SKIP__', false) OpenStudio::Extension.set_measure_argument(osw, 'urban_geometry_creation', 'geojson_file', scenario.feature_file.path) OpenStudio::Extension.set_measure_argument(osw, 'urban_geometry_creation', 'feature_id', feature_id) OpenStudio::Extension.set_measure_argument(osw, 'urban_geometry_creation', 'surrounding_buildings', 'ShadingOnly') - + # call create typical building a second time, do not touch space types, only add hvac OpenStudio::Extension.set_measure_argument(osw, 'create_typical_building_from_model', '__SKIP__', false) OpenStudio::Extension.set_measure_argument(osw, 'create_typical_building_from_model', 'system_type', system_type, 'create_typical_building_from_model 2') @@ -560,11 +562,10 @@ def time_mapping(time) OpenStudio::Extension.set_measure_argument(osw, 'default_feature_reports', 'feature_id', feature_id) OpenStudio::Extension.set_measure_argument(osw, 'default_feature_reports', 'feature_name', feature_name) OpenStudio::Extension.set_measure_argument(osw, 'default_feature_reports', 'feature_type', feature_type) - end + end return osw - end - - end #BaselineMapper - end #Scenario -end #URBANopt \ No newline at end of file + end + end # BaselineMapper + end # Scenario +end # URBANopt diff --git a/spec/spec_files/base_workflow.osw b/spec/spec_files/base_workflow.osw deleted file mode 100644 index fbbffdc6..00000000 --- a/spec/spec_files/base_workflow.osw +++ /dev/null @@ -1,128 +0,0 @@ -{ - "seed_file": null, - "weather_file": null, - "measure_paths": [], - "file_paths": [], - "run_directory": null, - "steps": [ - - { - "measure_dir_name": "set_run_period", - "arguments": { - "timesteps_per_hour": 1, - "begin_date": "2019-01-01", - "end_date": "2019-12-31" - } - },{ - "measure_dir_name": "ChangeBuildingLocation", - "arguments": { - "__SKIP__": true, - "weather_file_name": "USA_NY_Buffalo-Greater.Buffalo.Intl.AP.725280_TMY3.epw", - "climate_zone": "ASHRAE 169-2013-6A" - } - },{ - "measure_dir_name": "create_bar_from_building_type_ratios", - "arguments": { - "__SKIP__": true, - "bldg_type_a": null, - "bldg_type_a_num_units": 0, - "bldg_type_b": "SmallOffice", - "bldg_type_b_fract_bldg_area": 0, - "bldg_type_b_num_units": 0, - "bldg_type_c": "SmallOffice", - "bldg_type_c_fract_bldg_area": 0, - "bldg_type_c_num_units": 0, - "bldg_type_d": "SmallOffice", - "bldg_type_d_fract_bldg_area": 0, - "bldg_type_d_num_units": 0, - "single_floor_area": null, - "floor_height": 0, - "num_stories_above_grade": null, - "num_stories_below_grade": null, - "building_rotation": 0, - "template": "90.1-2004", - "ns_to_ew_ratio": 0, - "wwr": 0, - "party_wall_fraction": 0, - "story_multiplier": "None", - "bar_division_method": "Multiple Space Types - Individual Stories Sliced" - } - },{ - "name": "create_typical_building_from_model 1", - "measure_dir_name": "create_typical_building_from_model", - "arguments": { - "__SKIP__": true, - "add_hvac": false, - "add_refrigeration": false - } - },{ - "measure_dir_name": "blended_space_type_from_model", - "arguments": { - "__SKIP__": true, - "blend_method": "Building Story" - } - },{ - "measure_dir_name": "urban_geometry_creation", - "arguments": { - "__SKIP__": true, - "geojson_file": "exportGeo.json", - "feature_id": "5", - "surrounding_buildings": "None" - } - },{ - "name": "create_typical_building_from_model 2", - "measure_dir_name": "create_typical_building_from_model", - "arguments": { - "__SKIP__": true, - "template": "90.1-2004", - "add_constructions": false, - "add_space_type_loads": false, - "add_elevators": false, - "add_exterior_lights": false, - "add_exhaust": false, - "add_swh": false, - "add_refrigeration": false, - "remove_objects": false, - "system_type": "Inferred", - "add_hvac": true, - "use_upstream_args": false - } - },{ - "measure_dir_name":"PredictedMeanVote", - "arguments":{ - "__SKIP__":false, - "comfortWarnings":true, - "workEfficiencySchedule":"Work Efficiency Schedule", - "clothingSchedule":"Clothing Schedule", - "airVelocitySchedule":"Air Velocity Schedule" - } - },{ - "measure_dir_name": "IncreaseInsulationRValueForExteriorWalls", - "arguments": { - "__SKIP__": true, - "r_value": 10 - } - },{ - "measure_dir_name": "ReduceElectricEquipmentLoadsByPercentage", - "arguments": { - "__SKIP__": true, - "elecequip_power_reduction_percent": 20 - } - },{ - "measure_dir_name": "ReduceLightingLoadsByPercentage", - "arguments": { - "__SKIP__": true, - "lighting_power_reduction_percent": 30 - } - },{ - "measure_dir_name": "default_feature_reports", - "arguments": { - "feature_id": null, - "feature_name": null, - "feature_type": null - } - } - ], - "name": null, - "description": null -} \ No newline at end of file diff --git a/spec/uo_cli_spec.rb b/spec/uo_cli_spec.rb index 5ae66e2a..78274053 100644 --- a/spec/uo_cli_spec.rb +++ b/spec/uo_cli_spec.rb @@ -72,7 +72,6 @@ def delete_directory_or_file(dir_or_file) before :all do delete_directory_or_file(test_directory) system("#{call_cli} -p #{test_directory}") - system("cp #{File.join('spec', 'spec_files', 'base_workflow.osw')} #{File.join(test_directory, "mappers", "base_workflow.osw")}") end it 'creates a scenario file from a feature file' do @@ -119,8 +118,8 @@ def delete_directory_or_file(dir_or_file) end it 'opendss post-processes a scenario' do - expect(File.exist?(File.join(test_directory, 'run', 'two_building_scenario', "opendss"))).to be false - system("cp -R #{File.join('spec', 'spec_files', 'opendss')} #{File.join(test_directory, "run", "two_building_scenario", "opendss")}") + expect(File.exist?(File.join(test_directory, 'run', 'two_building_scenario', 'opendss'))).to be false + system("cp -R #{File.join('spec', 'spec_files', 'opendss')} #{File.join(test_directory, 'run', 'two_building_scenario', 'opendss')}") system("#{call_cli} -g -t opendss -s #{test_scenario} -f #{test_feature}") expect(File.exist?(File.join(test_directory, 'run', 'two_building_scenario', '1', 'feature_reports', 'default_feature_report_opendss.csv'))).to be true end