Skip to content

Commit

Permalink
Fix issues with lookups, add tests, and remove outdated tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
lymereJ committed Feb 13, 2024
1 parent 7c89a90 commit 6d95303
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 492 deletions.
1 change: 1 addition & 0 deletions lib/openstudio-standards.rb
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ module OpenstudioStandards
require_relative "#{stds}/ashrae_90_1/ashrae_90_1_2019/ashrae_90_1_2019.FanVariableVolume"
require_relative "#{stds}/ashrae_90_1/ashrae_90_1_2019/ashrae_90_1_2019.Space"
require_relative "#{stds}/ashrae_90_1/ashrae_90_1_2019/ashrae_90_1_2019.ThermalZone"
require_relative "#{stds}/ashrae_90_1/ashrae_90_1_2019/ashrae_90_1_2019.WaterHeaterMixed"
# 90.1-PRM Common
require_relative "#{stds}/ashrae_90_1_prm/ashrae_90_1_prm"
require_relative "#{stds}/ashrae_90_1_prm/ashrae_90_1_prm.Model"
Expand Down
2 changes: 1 addition & 1 deletion lib/openstudio-standards/standards/Standards.Model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2604,7 +2604,7 @@ def model_find_objects(hash_of_objects, search_criteria, capacity = nil, date =
matching_objects = matching_objects.reject { |object| object['minimum_storage'].nil? || object['maximum_storage'].nil? }

# Skip objects whose the minimum volume is below or maximum volume above the specified volume
matching_volume_objects = matching_objects.reject { |object| volume.to_f <= object['minimum_storage'].to_f || volume.to_f >= object['maximum_storage'].to_f }
matching_volume_objects = matching_objects.reject { |object| volume.to_f < object['minimum_storage'].to_f || volume.to_f > object['maximum_storage'].to_f }

# If no object was found, round the volume down in case the number fell between the limits in the json file.
if matching_volume_objects.size.zero?
Expand Down
86 changes: 61 additions & 25 deletions lib/openstudio-standards/standards/Standards.WaterHeaterMixed.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,31 +54,8 @@ def water_heater_mixed_apply_efficiency(water_heater_mixed)
OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.WaterHeaterMixed', "For #{water_heater_mixed.name}, fuel type of #{fuel_type} is not yet supported, standard will not be applied.")
end

# Get the water heater properties
search_criteria = {}
search_criteria['template'] = template
search_criteria['fuel_type'] = fuel_type
search_criteria['equipment_type'] = 'Storage Water Heaters'

# Search base on capacity first
wh_props_capacity = model_find_objects(standards_data['water_heaters'], search_criteria, capacity_btu_per_hr)
wh_props_capacity_and_volume = model_find_objects(standards_data['water_heaters'], search_criteria, capacity_btu_per_hr, nil, nil, nil, nil, volume_gal)
wh_props_capacity_and_capacity_btu_per_hr = model_find_objects(standards_data['water_heaters'], search_criteria, capacity_btu_per_hr, nil, nil, nil, nil, nil, capacity_btu_per_hr)
wh_props_capacity_and_volume_and_capacity_per_volume = model_find_objects(standards_data['water_heaters'], search_criteria, capacity_btu_per_hr, nil, nil, nil, nil, volume_gal, capacity_btu_per_hr / volume_gal)

# We consider that the lookup is successful if only one set of record is returned
if wh_props_capacity.size == 1
wh_props = wh_props_capacity[0]
elsif wh_props_capacity_and_volume.size == 1
wh_props = wh_props_capacity_and_volume[0]
elsif wh_props_capacity_and_capacity_btu_per_hr == 1
wh_props = wh_props_capacity_and_capacity_btu_per_hr[0]
elsif wh_props_capacity_and_volume_and_capacity_per_volume == 1
wh_props = wh_props_capacity_and_volume_and_capacity_per_volume[0]
else
OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.WaterHeaterMixed', "For #{water_heater_mixed.name}, cannot find water heater properties, cannot apply efficiency standard.")
return false
end
wh_props = water_heater_mixed_get_efficiency_requirement(water_heater_mixed, fuel_type, capacity_btu_per_hr, volume_gal)
return false if wh_props == {}

# Calculate the water heater efficiency and
# skin loss coefficient (UA) using different methods,
Expand Down Expand Up @@ -221,6 +198,56 @@ def water_heater_mixed_apply_efficiency(water_heater_mixed)
return true
end

# @param water_heater_mixed [OpenStudio::Model::WaterHeaterMixed] water heater mixed object
# @param fuel_type [Float] water heater fuel type
# @param capacity_btu_per_hr [Float] water heater capacity in Btu/h
# @param volume_gal [Float] water heater gallons of storage
# @return [Hash] returns a hash wwith the applicable efficiency requirements
def water_heater_mixed_get_efficiency_requirement(water_heater_mixed, fuel_type, capacity_btu_per_hr, volume_gal)
# Get the water heater properties
search_criteria = {}
search_criteria['template'] = template
search_criteria['fuel_type'] = fuel_type
search_criteria['equipment_type'] = 'Storage Water Heaters'

# Search base on capacity first
wh_props_capacity = model_find_objects(standards_data['water_heaters'], search_criteria, capacity_btu_per_hr)
wh_props_capacity_and_volume = model_find_objects(standards_data['water_heaters'], search_criteria, capacity_btu_per_hr, nil, nil, nil, nil, volume_gal.round(0))
wh_props_capacity_and_capacity_btu_per_hr = model_find_objects(standards_data['water_heaters'], search_criteria, capacity_btu_per_hr, nil, nil, nil, nil, nil, capacity_btu_per_hr)
wh_props_capacity_and_volume_and_capacity_per_volume = model_find_objects(standards_data['water_heaters'], search_criteria, capacity_btu_per_hr, nil, nil, nil, nil, volume_gal, capacity_btu_per_hr / volume_gal)

# We consider that the lookup is successful if only one set of record is returned
if wh_props_capacity.size == 1
wh_props = wh_props_capacity[0]
elsif wh_props_capacity_and_volume.size == 1
wh_props = wh_props_capacity_and_volume[0]
elsif wh_props_capacity_and_capacity_btu_per_hr == 1
wh_props = wh_props_capacity_and_capacity_btu_per_hr[0]
elsif wh_props_capacity_and_volume_and_capacity_per_volume == 1
wh_props = wh_props_capacity_and_volume_and_capacity_per_volume[0]
else
# Search again with additional criteria
search_criteria = water_heater_mixed_additional_search_criteria(water_heater_mixed, search_criteria)
wh_props_capacity = model_find_objects(standards_data['water_heaters'], search_criteria, capacity_btu_per_hr)
wh_props_capacity_and_volume = model_find_objects(standards_data['water_heaters'], search_criteria, capacity_btu_per_hr, nil, nil, nil, nil, volume_gal.round(0))
wh_props_capacity_and_capacity_btu_per_hr = model_find_objects(standards_data['water_heaters'], search_criteria, capacity_btu_per_hr, nil, nil, nil, nil, nil, capacity_btu_per_hr)
wh_props_capacity_and_volume_and_capacity_per_volume = model_find_objects(standards_data['water_heaters'], search_criteria, capacity_btu_per_hr, nil, nil, nil, nil, volume_gal, capacity_btu_per_hr / volume_gal)
if wh_props_capacity.size == 1
wh_props = wh_props_capacity[0]
elsif wh_props_capacity_and_volume.size == 1
wh_props = wh_props_capacity_and_volume[0]
elsif wh_props_capacity_and_capacity_btu_per_hr == 1
wh_props = wh_props_capacity_and_capacity_btu_per_hr[0]
elsif wh_props_capacity_and_volume_and_capacity_per_volume == 1
wh_props = wh_props_capacity_and_volume_and_capacity_per_volume[0]
else
return {}
end
end

return wh_props
end

# Applies the correct fuel type for the water heaters
# in the baseline model. For most standards and for most building
# types, the baseline uses the same fuel type as the proposed.
Expand Down Expand Up @@ -346,4 +373,13 @@ def water_heater_convert_energy_factor_to_thermal_efficiency_and_ua(fuel_type, e

return water_heater_efficiency, ua_btu_per_hr_per_f
end

# Add additional search criteria for water heater lookup efficiency.
#
# @param water_heater_mixed [OpenStudio::Model::WaterHeaterMixed] water heater mixed object
# @param search_criteria [Hash] search criteria for looking up water heater data
# @return [Hash] updated search criteria
def water_heater_mixed_additional_search_criteria(water_heater_mixed, search_criteria)
return search_criteria
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class ASHRAE9012019 < ASHRAE901
# Add additional search criteria for water heater lookup efficiency.
#
# @param water_heater_mixed [OpenStudio::Model::WaterHeaterMixed] water heater mixed object
# @param search_criteria [Hash] search criteria for looking up water heater data
# @return [Hash] updated search criteria
def water_heater_mixed_additional_search_criteria(water_heater_mixed, search_criteria)
search_criteria['draw_profile'] = 'medium' # assumption; could be based on inputs
return search_criteria
end
end
1 change: 1 addition & 0 deletions test/ci_tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ os_stds_methods/test_daylighting_controls.rb
os_stds_methods/test_space_type.rb
os_stds_methods/test_misc.rb
os_stds_methods/test_radiant_controls.rb
os_stds_methods/test_minimum_efficiency_lookups.rb

90_1_prm/test_prm_baseline_bldg.rb
90_1_prm/test_prm_baseline_bldg4.rb
Expand Down
Loading

0 comments on commit 6d95303

Please sign in to comment.