Description: This function determines the SWH BAT for the given building segment.
Inputs:
- RMD
- building_segment
- is_leap_year
Returns:
- building_segment_swh_bat: one of the ServiceWaterHeatingSpaceOptions2019ASHRAE901 options
Function Call:
- get_energy_required_to_heat_swh_use
- get_component_by_ID
Data Lookup: None
Logic:
-
set the building_segment_swh_bat to nil:
building_segment_swh_bat = "UNDETERMINED"
-
get the service_water_heating_building_area_type value:
building_segment_swh_bat = building_segment.get("service_water_heating_building_area_type", None)
-
if building_segment_swh_bat doesn't have service_water_heating_building_area_type, we need to determine the building segment SWH area type by looking at individual SWH uses:
if building_segment_swh_bat is None
- create a dictionary that will hold the different types of swh_use_bat_types and the total service water used for the year:
swh_use_dict = {}
- look at each service water heating use id:
for swh_use in find_all(f'$.buildings[*].building_segments[*][?(@.id {building_segment.id}")].zones[*].spaces[*].service_water_heating_uses[*]', rmd):
- if any swh_use has use_units equal to "OTHER" or swh_use is not an empty dict, the total energy required to heat the use cannot be determined, and building_segment_swh_bat is "UNDETERMINED":
if swh_use and swh_use.use_units == "OTHER": building_segment_swh_bat = "UNDETERMINED"
- calculate the total energy required to heat the swh_use using the function get_energy_required_to_heat_swh_use:
swh_use_energy_by_space = get_energy_required_to_heat_swh_use(swh_use, RMD, building_segment, is_leap_year)
- check to see if the swh_use has service_water_heating_area_type:
if swh_use.area_type:
- add the SWH building area type to the swh_use_dict and set the default value to 0:
swh_use_dict.setdefault(swh_use.area_type, ZERO.ENERGY)
- add the energy used by this swh_use:
swh_use_dict[swh_use.area_type] += sum(swh_use_energy_by_space.values())
- add the SWH building area type to the swh_use_dict and set the default value to 0:
- otherwise:
else:
- go through each space served by the swh_use and see if it has a service_water_heating_bat:
for space_id in swh_use_energy_by_space:
- get the space:
space = get_component_by_ID(RMD, space_id)
- check if the space has a swh_use_bat:
if space.service_water_heating_bat:
- First add the BAT and set the default:
swh_use_dict.setdefault("space.service_water_heating_bat", ZERO.ENERGY)
- add the energy used to the dict:
swh_use_dict["space.service_water_heating_bat"] += swh_use_energy_by_space[space_id]
- First add the BAT and set the default:
- otherwise, we'll add this use to UNDETERMINED.
else:
- First add UNDETERMINED and set the default:
swh_use_dict.setdefault("UNDETERMINED", ZERO.ENERGY)
- add the energy used to the dict:
swh_use_dict["UNDETERMINED"] += swh_use_energy_by_space[space_id]
- First add UNDETERMINED and set the default:
- get the space:
- go through each space served by the swh_use and see if it has a service_water_heating_bat:
- if any swh_use has use_units equal to "OTHER" or swh_use is not an empty dict, the total energy required to heat the use cannot be determined, and building_segment_swh_bat is "UNDETERMINED":
- now we need to determine the building_segment SWH area type based on the following rules:
- At least 50% of the SWH uses needs to be assigned a SWH area type
- All SWH needs to be assigned to the same SWH area type
- Select the building area type that has the greateest value:
building_segment_swh_bat = max(swh_use_dict, key=swh_use_dict.get) if swh_use_dict else "UNDETERMINED"
- create a dictionary that will hold the different types of swh_use_bat_types and the total service water used for the year:
-
if the building_segment.service_water_heating_building_area_type exists set the swh_bat to the one given:
if building_segment.service_water_heating_building_area_type:
- set the building_segment_swh_bat to the building_segment.service_water_heating_building_area_type:
building_segment_swh_bat = building_segment.service_water_heating_building_area_type
- set the building_segment_swh_bat to the building_segment.service_water_heating_building_area_type:
-
return result:
return: building_segment_swh_bat
Returns building_segment_swh_bat
Notes:
- relies on re-structuring of SWH as in: open229/ruleset-model-description-schema#264