Skip to content

Commit

Permalink
fix(hvac): Reset Room IDs within Detailed HVAC
Browse files Browse the repository at this point in the history
  • Loading branch information
chriswmackey committed Oct 28, 2024
1 parent 07fcb8c commit 89ce611
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 2 deletions.
3 changes: 2 additions & 1 deletion honeybee_energy/cli/translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,8 @@ def model_to_idf(

# reset the IDs to be derived from the display_names if requested
if geometry_names:
model.reset_ids()
id_map = model.reset_ids()
model.properties.energy.sync_detailed_hvac_ids(id_map['rooms'])
if resource_names:
model.properties.energy.reset_resource_ids()

Expand Down
40 changes: 40 additions & 0 deletions honeybee_energy/hvac/detailed.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,46 @@ def thermal_zones(self):
"""Get a tuple of strings for the Rooms/Zones to which the HVAC is assigned."""
return self._thermal_zones

def sync_room_ids(self, room_map):
"""Sync this DetailedHVAC with Rooms that had their IDs changed.
This is useful after running the Model.reset_ids() command to ensure that
the bi-directional Room references between DetailedHVAC and Honeybee Rooms
is correct.
Args:
room_map: A dictionary that relates the original Rooms identifiers (keys)
to the new identifiers (values) of the Rooms in the Model.
"""
thermal_zones, air_loop_count = [], 0
hvac_spec = self._specification
for a_loop in hvac_spec['AirLoops']:
if a_loop['$type'].startswith('Ironbug.HVAC.IB_NoAirLoop'):
for zone in a_loop['ThermalZones']:
for z_attr in zone['CustomAttributes']:
if z_attr['Field']['FullName'] == 'Name':
z_attr['Value'] = room_map[z_attr['Value']]
thermal_zones.append(z_attr['Value'])
elif a_loop['$type'].startswith('Ironbug.HVAC.IB_AirLoopHVAC'):
air_loop_count += 1
for comp in a_loop['DemandComponents']:
if comp['$type'].startswith('Ironbug.HVAC.IB_AirLoopBranches'):
for branch in comp['Branches']:
for z_attr in branch[0]['CustomAttributes']:
if z_attr['Field']['FullName'] == 'Name':
z_attr['Value'] = room_map[z_attr['Value']]
thermal_zones.append(z_attr['Value'])
# unlock object and set attributes
was_locked = False
if self._locked:
was_locked = True
self.unlock()
self._air_loop_count = air_loop_count
self._thermal_zones = tuple(thermal_zones)
self._specification = hvac_spec
if was_locked: # set the object back to being locked
self.lock()

def to_ideal_air_equivalent(self):
"""This method is NOT YET IMPLEMENTED."""
# TODO: Consider supporting this method by analyzing the air loop
Expand Down
15 changes: 15 additions & 0 deletions honeybee_energy/properties/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1243,6 +1243,21 @@ def check_interior_constructions_reversed(
raise ValueError(full_msg)
return full_msg

def sync_detailed_hvac_ids(self, room_map):
"""Sync room identifiers in DetailedHVAC with rooms that had their IDs changed.
This is useful after running the Model.reset_ids() command to ensure that
the bi-directional Room references between DetailedHVAC and Honeybee Rooms
is correct.
Args:
room_map: A dictionary that relates the original Rooms identifiers (keys)
to the new identifiers (values) of the Rooms in the Model.
"""
for hvac in self.hvacs:
if isinstance(hvac, DetailedHVAC):
hvac.sync_room_ids(room_map)

def reset_resource_ids(
self, reset_materials=True, reset_constructions=True,
reset_construction_sets=True, reset_schedules=True, reset_programs=True):
Expand Down
3 changes: 2 additions & 1 deletion honeybee_energy/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ def measure_compatible_model_json(

# reset the IDs to be derived from the display_names if requested
if use_geometry_names:
parsed_model.reset_ids()
id_map = parsed_model.reset_ids()
parsed_model.properties.energy.sync_detailed_hvac_ids(id_map['rooms'])
if use_resource_names:
parsed_model.properties.energy.reset_resource_ids()
if simplify_window_cons: # simpler format that cannot handle certain identifiers
Expand Down

0 comments on commit 89ce611

Please sign in to comment.