Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(grouping): Ensure that collisions of HVAC IDs are impossible #120

Merged
merged 2 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 22 additions & 7 deletions honeybee_doe2/grouping.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,20 @@ def group_rooms_by_doe2_level(rooms, model_tolerance):
geometry and contain suggested names for the DOE-2 levels.
"""
# set up lists of the outputs to be populated
room_groups, level_geometries, level_names = [], [], []
room_groups, level_geometries, level_names, existing_levels = [], [], [], {}

# first group the rooms by floor height
grouped_rooms, _ = Room.group_by_floor_height(rooms, FLOOR_LEVEL_TOL)
for fi, room_group in enumerate(grouped_rooms):
# determine a base name for the level using the story assigned to the rooms
level_name = clean_doe2_string(room_group[0].story, RES_CHARS - 8) \
if room_group[0].story is not None else 'Level_{}'.format(fi)
if level_name in existing_levels:
existing_levels[level_name] += 1
level_name = level_name + str(existing_levels[level_name])
else:
existing_levels[level_name] = 1

# then, group the rooms by contiguous horizontal boundary
floor_geos = []
for room in room_group:
Expand All @@ -69,7 +78,7 @@ def group_rooms_by_doe2_level(rooms, model_tolerance):
if len(hor_bounds) == 0: # we will write the story with NO-SHAPE
room_groups.append(room_group)
level_geometries.append(None)
level_names.append('Level_{}'.format(fi))
level_names.append(level_name)
elif len(hor_bounds) == 1: # just one clean polygon for the level
flr_geo = hor_bounds[0]
flr_geo = flr_geo if flr_geo.normal.z >= 0 else flr_geo.flip()
Expand All @@ -78,7 +87,7 @@ def group_rooms_by_doe2_level(rooms, model_tolerance):
flr_geo = flr_geo.remove_colinear_vertices(tolerance=DOE2_TOLERANCE)
room_groups.append(room_group)
level_geometries.append(flr_geo)
level_names.append('Level_{}'.format(fi))
level_names.append(level_name)
else: # we need to figure out which Room belongs to which geometry
# first get a set of Point2Ds that are inside each room in plan
room_pts, z_axis = [], Vector3D(0, 0, 1)
Expand All @@ -103,7 +112,7 @@ def group_rooms_by_doe2_level(rooms, model_tolerance):
flr_rooms.append(room)
room_groups.append(flr_rooms)
level_geometries.append(flr_geo)
level_names.append('Level_{}_Section{}'.format(fi, si))
level_names.append('{}_Section{}'.format(level_name, si))

# return all of the outputs
return room_groups, level_geometries, level_names
Expand Down Expand Up @@ -140,7 +149,7 @@ def group_rooms_by_doe2_hvac(model, hvac_mapping):
hvac_name = clean_doe2_string('{}_Sys'.format(model.display_name), RES_CHARS)
return [model.rooms], [hvac_name]
elif hvac_mapping == 'ROOM':
hvac_names = [clean_doe2_string('{}_Sys'.format(room.display_name), RES_CHARS)
hvac_names = [clean_doe2_string('{}_Sys'.format(room.identifier), RES_CHARS)
for room in model.rooms]
room_groups = [[room] for room in model.rooms]
else: # assume that it is the assigned HVAC
Expand All @@ -157,10 +166,16 @@ def group_rooms_by_doe2_hvac(model, hvac_mapping):
hvac_dict['Unassigned'].append(room)
except KeyError: # the first time that we have an unassigned room
hvac_dict['Unassigned'] = [room]
room_groups, hvac_names = [], []
room_groups, hvac_names, existing_dict = [], [], {}
for hvac_name, rooms in hvac_dict.items():
room_groups.append(rooms)
hvac_names.append(clean_doe2_string(hvac_name, RES_CHARS))
hvac_doe2_name = clean_doe2_string(hvac_name, RES_CHARS - 2)
if hvac_doe2_name in existing_dict:
existing_dict[hvac_doe2_name] += 1
hvac_names.append(hvac_doe2_name + str(existing_dict[hvac_doe2_name]))
else:
existing_dict[hvac_doe2_name] = 1
hvac_names.append(hvac_doe2_name)

return room_groups, hvac_names

Expand Down
2 changes: 1 addition & 1 deletion honeybee_doe2/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ def _is_room_3d_extruded(hb_room):
else: # not a rectangular geometry
face_locations.append(None)
elif orient == 1:
loc = 'TOP' if ceil_count == 1 else None
loc = 'TOP' if ceil_count == 1 and not r_geo.has_holes else None
face_locations.append(loc)
else:
loc = 'BOTTOM' if floor_count == 1 else None
Expand Down
Loading