Skip to content

Commit

Permalink
Merge pull request #764 from NREL/backport-wh-loc-iecc
Browse files Browse the repository at this point in the history
IECC Zone argument for ResidentialLocation
  • Loading branch information
joseph-robertson committed Nov 8, 2021
2 parents 9179aef + 8ad1c2a commit fa47f8a
Show file tree
Hide file tree
Showing 11 changed files with 90 additions and 133 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Features
- Updates infiltration model pressure coefficient ([#670](https://github.com/NREL/resstock/pull/670))
- Updates mechanical ventilation options/model to ASHRAE 62.2-2019 and adds a "Flow Rate, Mechanical Ventilation (cfm)" output ([#675](https://github.com/NREL/resstock/pull/675))
- Add PV ownership and PV system size distributions using 2019 Tracking the Sun and GTM report on solar installation. ([#673](https://github.com/NREL/resstock/pull/673))
- Add optional argument to ResidentialLocation measure for setting the Building America climate zone ([#755](https://github.com/NREL/resstock/pull/755))
- Add optional argument to ResidentialLocation measure for setting the IECC climate zone ([#755](https://github.com/NREL/resstock/pull/764))

Fixes
- Fixes significant runtime bottleneck in TSV fetching in BuildExistingModel & ApplyUpgrade measures ([#543](https://github.com/NREL/resstock/pull/543))
Expand Down
40 changes: 4 additions & 36 deletions resources/measures/HPXMLtoOpenStudio/resources/constants.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,38 +107,6 @@ def self.CoordAbsolute
return 'absolute'
end

def self.BAZoneCold
return 'Cold'
end

def self.BAZoneHotDry
return 'Hot-Dry'
end

def self.BAZoneSubarctic
return 'Subarctic'
end

def self.BAZoneHotHumid
return 'Hot-Humid'
end

def self.BAZoneMarine
return 'Marine'
end

def self.BAZoneMixedHumid
return 'Mixed-Humid'
end

def self.BAZoneMixedDry
return 'Mixed-Dry'
end

def self.BAZoneVeryCold
return 'Very Cold'
end

def self.BoilerTypeCondensing
return 'hot water, condensing'
end
Expand Down Expand Up @@ -183,10 +151,6 @@ def self.BoreConfigUconfig
return 'u-config'
end

def self.BuildingAmericaClimateZone
return 'Building America'
end

def self.BuildingTypeMultifamily
return 'multifamily'
end
Expand Down Expand Up @@ -335,6 +299,10 @@ def self.FuelTypeWood
return 'wood'
end

def self.IECCClimateZone
return 'IECC'
end

def self.LocationInterior
return 'interior'
end
Expand Down
22 changes: 11 additions & 11 deletions resources/measures/HPXMLtoOpenStudio/resources/location.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
require_relative 'unit_conversions'

class Location
def self.apply(model, runner, weather_file_path, dst_start_date, dst_end_date, ba_zone)
def self.apply(model, runner, weather_file_path, dst_start_date, dst_end_date, iecc_zone)
success, weather, epw_file = apply_weather_file(model, runner, weather_file_path)
return false if not success

Expand All @@ -15,7 +15,7 @@ def self.apply(model, runner, weather_file_path, dst_start_date, dst_end_date, b
success = apply_site(model, runner, epw_file)
return false if not success

success = apply_climate_zones(model, runner, epw_file, ba_zone)
success = apply_climate_zones(model, runner, epw_file, iecc_zone)
return false if not success

success = apply_mains_temp(model, runner, weather)
Expand Down Expand Up @@ -81,17 +81,17 @@ def self.apply_site(model, runner, epw_file)
return true
end

def self.apply_climate_zones(model, runner, epw_file, ba_zone)
if ba_zone.is_initialized
ba_zone = ba_zone.get
def self.apply_climate_zones(model, runner, epw_file, iecc_zone)
if iecc_zone.is_initialized
iecc_zone = iecc_zone.get
else
ba_zone = get_climate_zone_ba(epw_file.wmoNumber)
iecc_zone = get_climate_zone_iecc(epw_file.wmoNumber)
end
return true if ba_zone.nil?
return true if iecc_zone.nil?

climateZones = model.getClimateZones
climateZones.setClimateZone(Constants.BuildingAmericaClimateZone, ba_zone)
runner.registerInfo("Setting #{Constants.BuildingAmericaClimateZone} climate zone to #{ba_zone}.")
climateZones.setClimateZone(Constants.IECCClimateZone, iecc_zone)
runner.registerInfo("Setting #{Constants.IECCClimateZone} climate zone to #{iecc_zone}.")

return true
end
Expand Down Expand Up @@ -159,13 +159,13 @@ def self.get_climate_zones
return zones_csv
end

def self.get_climate_zone_ba(wmo)
def self.get_climate_zone_iecc(wmo)
zones_csv = get_climate_zones
return if zones_csv.nil?

require 'csv'
CSV.foreach(zones_csv) do |row|
return row[5].to_s if row[0].to_s == wmo.to_s
return row[6].to_s if row[0].to_s == wmo.to_s
end

return
Expand Down
36 changes: 14 additions & 22 deletions resources/measures/HPXMLtoOpenStudio/resources/waterheater.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1044,28 +1044,20 @@ def self.remove(model, runner) # TODO: Make unit specific
end
end

def self.get_location_hierarchy(ba_cz_name)
if [Constants.BAZoneHotDry, Constants.BAZoneHotHumid].include? ba_cz_name
return [Constants.SpaceTypeGarage,
Constants.SpaceTypeLiving,
Constants.SpaceTypeFinishedBasement,
Constants.SpaceTypeLaundryRoom,
Constants.SpaceTypeCrawl,
Constants.SpaceTypeUnfinishedAttic]

elsif [Constants.BAZoneMarine, Constants.BAZoneMixedHumid, Constants.BAZoneMixedDry, Constants.BAZoneCold, Constants.BAZoneVeryCold, Constants.BAZoneSubarctic].include? ba_cz_name
return [Constants.SpaceTypeFinishedBasement,
Constants.SpaceTypeUnfinishedBasement,
Constants.SpaceTypeLiving,
Constants.SpaceTypeLaundryRoom,
Constants.SpaceTypeCrawl,
Constants.SpaceTypeUnfinishedAttic]
elsif ba_cz_name.nil?
return [Constants.SpaceTypeFinishedBasement,
Constants.SpaceTypeUnfinishedBasement,
Constants.SpaceTypeGarage,
Constants.SpaceTypeLiving]
end
def self.get_location_hierarchy(iecc_zone)
if ['1A', '1B', '1C', '2A', '2B', '2C', '3B', '3C'].include? iecc_zone
location_hierarchy = [Constants.SpaceTypeGarage,
Constants.SpaceTypeLiving]
elsif ['3A', '4A', '4B', '4C', '5A', '5B', '5C', '6A', '6B', '6C', '7', '8'].include? iecc_zone
location_hierarchy = [Constants.SpaceTypeFinishedBasement,
Constants.SpaceTypeUnfinishedBasement,
Constants.SpaceTypeLiving]
elsif iecc_zone.nil?
location_hierarchy = [Constants.SpaceTypeFinishedBasement,
Constants.SpaceTypeUnfinishedBasement,
Constants.SpaceTypeLiving]
end
return location_hierarchy
end

def self.calc_capacity(cap, fuel, num_beds, num_baths)
Expand Down
10 changes: 5 additions & 5 deletions resources/measures/ResidentialHotWaterHeaterHeatPump/measure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -290,15 +290,15 @@ def run(model, runner, user_arguments)
return false
end

# Get Building America climate zone
ba_cz_name = nil
# Get IECC climate zone
iecc_cz_name = nil
model.getClimateZones.climateZones.each do |climateZone|
next if climateZone.institution != Constants.BuildingAmericaClimateZone
next if climateZone.institution != Constants.IECCClimateZone

ba_cz_name = climateZone.value.to_s
iecc_cz_name = climateZone.value.to_s
end

location_hierarchy = Waterheater.get_location_hierarchy(ba_cz_name)
location_hierarchy = Waterheater.get_location_hierarchy(iecc_cz_name)

Waterheater.remove(model, runner)

Expand Down
10 changes: 5 additions & 5 deletions resources/measures/ResidentialHotWaterHeaterTank/measure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -196,15 +196,15 @@ def run(model, runner, user_arguments)
return false
end

# Get Building America climate zone
ba_cz_name = nil
# Get IECC climate zone
iecc_cz_name = nil
model.getClimateZones.climateZones.each do |climateZone|
next if climateZone.institution != Constants.BuildingAmericaClimateZone
next if climateZone.institution != Constants.IECCClimateZone

ba_cz_name = climateZone.value.to_s
iecc_cz_name = climateZone.value.to_s
end

location_hierarchy = Waterheater.get_location_hierarchy(ba_cz_name)
location_hierarchy = Waterheater.get_location_hierarchy(iecc_cz_name)

if setpoint_type == Constants.WaterHeaterSetpointTypeScheduled
unless (Pathname.new schedule_directory).absolute?
Expand Down
10 changes: 5 additions & 5 deletions resources/measures/ResidentialHotWaterHeaterTankless/measure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,15 @@ def run(model, runner, user_arguments)
return false
end

# Get Building America climate zone
ba_cz_name = nil
# Get IECC climate zone
iecc_cz_name = nil
model.getClimateZones.climateZones.each do |climateZone|
next if climateZone.institution != Constants.BuildingAmericaClimateZone
next if climateZone.institution != Constants.IECCClimateZone

ba_cz_name = climateZone.value.to_s
iecc_cz_name = climateZone.value.to_s
end

location_hierarchy = Waterheater.get_location_hierarchy(ba_cz_name)
location_hierarchy = Waterheater.get_location_hierarchy(iecc_cz_name)

Waterheater.remove(model, runner)

Expand Down
25 changes: 11 additions & 14 deletions resources/measures/ResidentialLocation/measure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,15 @@ def arguments(model)
arg.setDefaultValue('November 5')
args << arg

ba_zone_names = OpenStudio::StringVector.new
ba_zone_names << Constants.BAZoneCold
ba_zone_names << Constants.BAZoneHotDry
ba_zone_names << Constants.BAZoneHotHumid
ba_zone_names << Constants.BAZoneMarine
ba_zone_names << Constants.BAZoneMixedHumid
ba_zone_names << Constants.BAZoneMixedDry
ba_zone_names << Constants.BAZoneVeryCold

arg = OpenStudio::Measure::OSArgument.makeChoiceArgument('ba_zone', ba_zone_names, false)
arg.setDisplayName('Building America Climate Zone')
arg.setDescription('Name of the Building America climate zone to assign.')
iecc_zone_choices = OpenStudio::StringVector.new
['1A', '1B', '1C', '2A', '2B', '2C', '3A', '3B', '3C',
'4A', '4B', '4C', '5A', '5B', '5C', '6A', '6B', '6C', '7', '8'].each do |iz|
iecc_zone_choices << iz
end

arg = OpenStudio::Measure::OSArgument.makeChoiceArgument('iecc_zone', iecc_zone_choices, false)
arg.setDisplayName('IECC Zone')
arg.setDescription('IECC zone of the home address. If not provided, uses the IECC zone corresponding to the EPW weather file.')
args << arg

return args
Expand All @@ -86,14 +83,14 @@ def run(model, runner, user_arguments)
weather_file_name = runner.getStringArgumentValue('weather_file_name', user_arguments)
dst_start_date = runner.getStringArgumentValue('dst_start_date', user_arguments)
dst_end_date = runner.getStringArgumentValue('dst_end_date', user_arguments)
ba_zone = runner.getOptionalStringArgumentValue('ba_zone', user_arguments)
iecc_zone = runner.getOptionalStringArgumentValue('iecc_zone', user_arguments)

unless (Pathname.new weather_directory).absolute?
weather_directory = File.expand_path(File.join(File.dirname(__FILE__), weather_directory))
end
weather_file_path = File.join(weather_directory, weather_file_name)

success, weather = Location.apply(model, runner, weather_file_path, dst_start_date, dst_end_date, ba_zone)
success, weather = Location.apply(model, runner, weather_file_path, dst_start_date, dst_end_date, iecc_zone)
return false if not success

# report final condition
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,31 +33,31 @@ def test_NA_daylight_saving
args_hash['dst_end_date'] = 'NA'
expected_num_del_objects = {}
expected_num_new_objects = { 'SiteGroundTemperatureDeep' => 1, 'SiteWaterMainsTemperature' => 1, 'WeatherFile' => 1, 'ClimateZones' => 1, 'Site' => 1 }
expected_values = { 'HotWaterAnnualTemp' => 10.88, 'HotWaterMaxDiffTemp' => 23.15, 'BAZone' => Constants.BAZoneCold }
expected_values = { 'HotWaterAnnualTemp' => 10.88, 'HotWaterMaxDiffTemp' => 23.15, 'IECCZone' => '5B' }
_test_measure(nil, args_hash, expected_num_del_objects, expected_num_new_objects, expected_values, 5)
end

def test_change_daylight_saving
args_hash = {}
expected_num_del_objects = {}
expected_num_new_objects = { 'SiteGroundTemperatureDeep' => 1, 'RunPeriodControlDaylightSavingTime' => 1, 'SiteWaterMainsTemperature' => 1, 'WeatherFile' => 1, 'ClimateZones' => 1, 'Site' => 1 }
expected_values = { 'StartDate' => 'Mar-12', 'EndDate' => 'Nov-05', 'HotWaterAnnualTemp' => 10.88, 'HotWaterMaxDiffTemp' => 23.15, 'BAZone' => Constants.BAZoneCold }
expected_values = { 'StartDate' => 'Mar-12', 'EndDate' => 'Nov-05', 'HotWaterAnnualTemp' => 10.88, 'HotWaterMaxDiffTemp' => 23.15, 'IECCZone' => '5B' }
model = _test_measure(nil, args_hash, expected_num_del_objects, expected_num_new_objects, expected_values, 5)
args_hash = {}
args_hash['dst_start_date'] = 'April 8'
args_hash['dst_end_date'] = 'October 27'
expected_num_del_objects = {}
expected_num_new_objects = {}
expected_values = { 'StartDate' => 'Apr-08', 'EndDate' => 'Oct-27', 'HotWaterAnnualTemp' => 10.88, 'HotWaterMaxDiffTemp' => 23.15, 'BAZone' => Constants.BAZoneCold }
expected_values = { 'StartDate' => 'Apr-08', 'EndDate' => 'Oct-27', 'HotWaterAnnualTemp' => 10.88, 'HotWaterMaxDiffTemp' => 23.15, 'IECCZone' => '5B' }
_test_measure(model, args_hash, expected_num_del_objects, expected_num_new_objects, expected_values, 5)
end

def test_building_america_climate_zone
def test_iecc_climate_zone
args_hash = {}
args_hash['ba_zone'] = Constants.BAZoneHotDry
args_hash['iecc_zone'] = '6A'
expected_num_del_objects = {}
expected_num_new_objects = { 'SiteGroundTemperatureDeep' => 1, 'RunPeriodControlDaylightSavingTime' => 1, 'SiteWaterMainsTemperature' => 1, 'WeatherFile' => 1, 'ClimateZones' => 1, 'Site' => 1 }
expected_values = { 'StartDate' => 'Mar-12', 'EndDate' => 'Nov-05', 'HotWaterAnnualTemp' => 10.88, 'HotWaterMaxDiffTemp' => 23.15, 'BAZone' => Constants.BAZoneHotDry }
expected_values = { 'StartDate' => 'Mar-12', 'EndDate' => 'Nov-05', 'HotWaterAnnualTemp' => 10.88, 'HotWaterMaxDiffTemp' => 23.15, 'IECCZone' => '6A' }
_test_measure(nil, args_hash, expected_num_del_objects, expected_num_new_objects, expected_values, 5)
end

Expand Down Expand Up @@ -160,8 +160,8 @@ def _test_measure(osm_file_or_model, args_hash, expected_num_del_objects, expect
assert_in_epsilon(expected_values['HotWaterAnnualTemp'], new_object.annualAverageOutdoorAirTemperature.get, 0.01)
assert_in_epsilon(expected_values['HotWaterMaxDiffTemp'], new_object.maximumDifferenceInMonthlyAverageOutdoorAirTemperatures.get, 0.01)
elsif obj_type == 'ClimateZones'
climate_zones = new_object.getClimateZones(Constants.BuildingAmericaClimateZone)
assert(climate_zones[0].value.include?(expected_values['BAZone']))
climate_zones = new_object.getClimateZones(Constants.IECCClimateZone)
assert_equal(expected_values['IECCZone'], climate_zones[0].value)
end
end
end
Expand Down
44 changes: 22 additions & 22 deletions resources/options_lookup.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -1667,21 +1667,21 @@ AHS Region Non-CBSA Pacific
AHS Region Non-CBSA South Atlantic
AHS Region Non-CBSA West North Central
AHS Region Non-CBSA West South Central
ASHRAE IECC Climate Zone 2004 1A
ASHRAE IECC Climate Zone 2004 2A
ASHRAE IECC Climate Zone 2004 2B
ASHRAE IECC Climate Zone 2004 3A
ASHRAE IECC Climate Zone 2004 3B
ASHRAE IECC Climate Zone 2004 3C
ASHRAE IECC Climate Zone 2004 4A
ASHRAE IECC Climate Zone 2004 4B
ASHRAE IECC Climate Zone 2004 4C
ASHRAE IECC Climate Zone 2004 5A
ASHRAE IECC Climate Zone 2004 5B
ASHRAE IECC Climate Zone 2004 6A
ASHRAE IECC Climate Zone 2004 6B
ASHRAE IECC Climate Zone 2004 7A
ASHRAE IECC Climate Zone 2004 7B
ASHRAE IECC Climate Zone 2004 1A ResidentialLocation iecc_zone=1A
ASHRAE IECC Climate Zone 2004 2A ResidentialLocation iecc_zone=2A
ASHRAE IECC Climate Zone 2004 2B ResidentialLocation iecc_zone=2B
ASHRAE IECC Climate Zone 2004 3A ResidentialLocation iecc_zone=3A
ASHRAE IECC Climate Zone 2004 3B ResidentialLocation iecc_zone=3B
ASHRAE IECC Climate Zone 2004 3C ResidentialLocation iecc_zone=3C
ASHRAE IECC Climate Zone 2004 4A ResidentialLocation iecc_zone=4A
ASHRAE IECC Climate Zone 2004 4B ResidentialLocation iecc_zone=4B
ASHRAE IECC Climate Zone 2004 4C ResidentialLocation iecc_zone=4C
ASHRAE IECC Climate Zone 2004 5A ResidentialLocation iecc_zone=5A
ASHRAE IECC Climate Zone 2004 5B ResidentialLocation iecc_zone=5B
ASHRAE IECC Climate Zone 2004 6A ResidentialLocation iecc_zone=6A
ASHRAE IECC Climate Zone 2004 6B ResidentialLocation iecc_zone=6B
ASHRAE IECC Climate Zone 2004 7A ResidentialLocation iecc_zone=7
ASHRAE IECC Climate Zone 2004 7B ResidentialLocation iecc_zone=7
State AL ResidentialScheduleGenerator state=AL
State AR ResidentialScheduleGenerator state=AR
State AZ ResidentialScheduleGenerator state=AZ
Expand Down Expand Up @@ -1779,13 +1779,13 @@ ISO RTO Region None
ISO RTO Region NYISO
ISO RTO Region PJM
ISO RTO Region SPP
Building America Climate Zone Cold ResidentialLocation ba_zone=Cold
Building America Climate Zone Hot-Dry ResidentialLocation ba_zone=Hot-Dry
Building America Climate Zone Hot-Humid ResidentialLocation ba_zone=Hot-Humid
Building America Climate Zone Marine ResidentialLocation ba_zone=Marine
Building America Climate Zone Mixed-Dry ResidentialLocation ba_zone=Mixed-Dry
Building America Climate Zone Mixed-Humid ResidentialLocation ba_zone=Mixed-Humid
Building America Climate Zone Very Cold ResidentialLocation ba_zone=Very Cold
Building America Climate Zone Cold
Building America Climate Zone Hot-Dry
Building America Climate Zone Hot-Humid
Building America Climate Zone Marine
Building America Climate Zone Mixed-Dry
Building America Climate Zone Mixed-Humid
Building America Climate Zone Very Cold
County "AL, Autauga County" ResidentialLocation dst_start_date=March 12 dst_end_date=November 5 weather_directory=../../../../weather weather_file_name=G0100010.epw
County "AL, Baldwin County" ResidentialLocation dst_start_date=March 12 dst_end_date=November 5 weather_directory=../../../../weather weather_file_name=G0100030.epw
County "AL, Barbour County" ResidentialLocation dst_start_date=March 12 dst_end_date=November 5 weather_directory=../../../../weather weather_file_name=G0100050.epw
Expand Down
Loading

0 comments on commit fa47f8a

Please sign in to comment.