Skip to content

Commit

Permalink
feat(occupancy): Support single and mult-unit occupancy
Browse files Browse the repository at this point in the history
- Revise occupancy to support both single-family and multi-family occupancy
- Allow for multi-hb-room single-family occupancy projects
  • Loading branch information
ed-p-may authored Mar 8, 2023
2 parents 96093f2 + a1455f3 commit 1231bf5
Show file tree
Hide file tree
Showing 8 changed files with 454 additions and 372 deletions.
54 changes: 41 additions & 13 deletions PHX/from_HBJSON/cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@

"""Functions used to cleanup / optimize Honeybee-Rooms before outputting to WUFI"""

from typing import List
from collections import defaultdict
from typing import List, Dict
from functools import reduce


try: # import the core honeybee dependencies
from honeybee.typing import clean_ep_string
except ImportError as e:
Expand Down Expand Up @@ -34,7 +36,7 @@
try:
from honeybee_energy_ph.properties.load.equipment import ElectricEquipmentPhProperties
from honeybee_energy_ph.properties.hot_water.hw_system import SHWSystemPhProperties
from honeybee_energy_ph.properties.load.people import PeoplePhProperties
from honeybee_energy_ph.properties.load.people import PeoplePhProperties, PhDwellings
except ImportError as e:
raise ImportError("\nFailed to import honeybee_energy_ph:\n\t{}".format(e))

Expand All @@ -56,7 +58,7 @@ def _dup_face(_hb_face: face.Face) -> face.Face:
* (face.Face): The duplicate face.
"""

new_face = _hb_face.duplicate()
new_face = _hb_face.duplicate() # type: face.Face # type: ignore
new_face._properties._duplicate_extension_attr(_hb_face._properties)

# -- Note, this is required if the user has set custom .energy constructions
Expand Down Expand Up @@ -136,6 +138,25 @@ def _get_room_exposed_face_area(_hb_room: room.Room) -> float:
)


def all_unique_ph_dwelling_objects(_hb_rooms: List[room.Room]) -> List[PhDwellings]:
"""
Arguments:
----------
* _hb_rooms (List[room.Room]): A list of the HB-Rooms
Returns:
--------
* (List[PhDwellings])
"""
dwellings = {
room.properties.energy.people.properties.ph.dwellings #type: ignore
for room in _hb_rooms
if room.properties.energy.people # type: ignore
}
return list(dwellings)


def merge_occupancies(_hb_rooms: List[room.Room]) -> people.People:
"""Returns a new HB-People-Obj with it's values set from a list of input HB-Rooms.
Expand All @@ -149,14 +170,20 @@ def merge_occupancies(_hb_rooms: List[room.Room]) -> people.People:
* (people.People): A new Honeybee People object with values merged from the HB-Rooms.
"""

# -- Tally up all the values from all the rooms
total_ph_bedrooms = 0
# -------------------------------------------------------------------------
# Calculate the total dwelling-unit count
total_ph_dwellings = 0
for dwelling_obj in all_unique_ph_dwelling_objects(_hb_rooms):
total_ph_dwellings += int(dwelling_obj.num_dwellings)

# -------------------------------------------------------------------------
# -- Merge all the Rooms
total_ph_bedrooms = 0
total_ph_people = 0.0
total_hb_people = 0.0
for room in _hb_rooms:
for hb_room in _hb_rooms:
# -- Type Aliases
hb_room_prop_energy: RoomEnergyProperties = room.properties.energy # type: ignore
hb_room_prop_energy: RoomEnergyProperties = hb_room.properties.energy # type: ignore
hb_ppl_obj = hb_room_prop_energy.people

# -- Sometimes there is no 'People'
Expand All @@ -166,14 +193,15 @@ def merge_occupancies(_hb_rooms: List[room.Room]) -> people.People:
hbph_people_prop_ph: PeoplePhProperties = hb_ppl_obj.properties.ph # type: ignore
total_ph_bedrooms += int(hbph_people_prop_ph.number_bedrooms)
total_ph_people += float(hbph_people_prop_ph.number_people)
total_ph_dwellings += int(hbph_people_prop_ph.number_dwelling_units)
total_hb_people += hb_ppl_obj.people_per_area * room.floor_area
total_hb_people += hb_ppl_obj.people_per_area * hb_room.floor_area

# Build up the new object's attributes

# -------------------------------------------------------------------------
# -- Build up the new Peopler object's attributes
total_floor_area = sum(rm.floor_area for rm in _hb_rooms)
new_hb_prop_energy = _hb_rooms[0].properties.energy # type: RoomEnergyProperties
new_hb_ppl = new_hb_prop_energy.people.duplicate() # type: people.People
new_hb_ppl_prop_ph = new_hb_ppl.properties.ph # type: PeoplePhProperties
new_hb_prop_energy = _hb_rooms[0].properties.energy # type: RoomEnergyProperties # type: ignore
new_hb_ppl = new_hb_prop_energy.people.duplicate() # type: people.People # type: ignore
new_hb_ppl_prop_ph = new_hb_ppl.properties.ph # type: PeoplePhProperties # type: ignore
new_hb_ppl.people_per_area = total_hb_people / total_floor_area
new_hb_ppl_prop_ph.number_bedrooms = total_ph_bedrooms
new_hb_ppl_prop_ph.number_people = total_ph_people
Expand Down
2 changes: 1 addition & 1 deletion _testing_to_WUFI.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
# -- Temp
SOURCE_FILES = [
pathlib.Path(
"/Users/em/Dropbox/bldgtyp-00/00_PH_Tools/PHX/sample/hbjson/testing_non_res_prog.hbjson"
"/Users/em/Dropbox/bldgtyp-00/00_PH_Tools/PHX/sample/hbjson/DOWNEY_HOME_230308.hbjson"
)
]
TARGET_DIR = pathlib.Path("sample")
Expand Down
6 changes: 3 additions & 3 deletions tests/_reference_xml/Default_Model_Single_Zone.xml
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@
<Components count="3">
<Component index="0">
<IdentNr>5</IdentNr>
<Name>Room_2_e42149fb..Face4</Name>
<Name>Room_3_31c0c9f6..Face4</Name>
<Visual>true</Visual>
<Type>1</Type>
<IdentNrColorI>12</IdentNrColorI>
Expand All @@ -219,7 +219,7 @@
</Component>
<Component index="1">
<IdentNr>6</IdentNr>
<Name>Room_2_e42149fb..Face5</Name>
<Name>Room_3_31c0c9f6..Face5</Name>
<Visual>true</Visual>
<Type>1</Type>
<IdentNrColorI>7</IdentNrColorI>
Expand Down Expand Up @@ -496,7 +496,7 @@
<BuildingStatus>1</BuildingStatus>
<BuildingType>1</BuildingType>
<OccupancySettingMethod>2</OccupancySettingMethod>
<NumberUnits>0</NumberUnits>
<NumberUnits>1</NumberUnits>
<CountStories>1</CountStories>
<EnvelopeAirtightnessCoefficient>0.81576</EnvelopeAirtightnessCoefficient>
<SummerHRVHumidityRecovery choice="Always">4</SummerHRVHumidityRecovery>
Expand Down
64 changes: 32 additions & 32 deletions tests/_reference_xml/Multi_Room_Complete.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@
<OperatingDays>7.0</OperatingDays>
<OperatingWeeks>52.0</OperatingWeeks>
<Maximum_DOS>5.71</Maximum_DOS>
<Maximum_PDF>0.98</Maximum_PDF>
<Maximum_PDF>0.99</Maximum_PDF>
<Standard_DOS>0.71</Standard_DOS>
<Standard_PDF>0.85</Standard_PDF>
<Standard_PDF>0.86</Standard_PDF>
<Basic_DOS>1.99</Basic_DOS>
<Basic_PDF>0.78</Basic_PDF>
<Basic_PDF>0.79</Basic_PDF>
<Minimum_DOS>15.59</Minimum_DOS>
<Minimum_PDF>0.71</Minimum_PDF>
<Minimum_PDF>0.73</Minimum_PDF>
</UtilizationPatternVent>
</UtilisationPatternsVentilation>
<UtilizationPatternsPH count="1">
Expand Down Expand Up @@ -664,7 +664,7 @@
</Component>
<Component index="4">
<IdentNr>49</IdentNr>
<Name>Shade_3d20ef19</Name>
<Name>Shade_14d16200</Name>
<Visual>true</Visual>
<Type>1</Type>
<IdentNrColorI>1</IdentNrColorI>
Expand All @@ -680,7 +680,7 @@
</Component>
<Component index="5">
<IdentNr>50</IdentNr>
<Name>Shade_047435e2</Name>
<Name>Shade_56443c46</Name>
<Visual>true</Visual>
<Type>1</Type>
<IdentNrColorI>1</IdentNrColorI>
Expand All @@ -702,38 +702,38 @@
<IdentNr>1</IdentNr>
<RoomsVentilation count="2">
<Room index="0">
<Name>101-Room_4</Name>
<Name>101-Room_1</Name>
<Type>99</Type>
<IdentNrUtilizationPatternVent>1</IdentNrUtilizationPatternVent>
<IdentNrVentilationUnit>1</IdentNrVentilationUnit>
<Quantity>1</Quantity>
<AreaRoom unit="">9.0</AreaRoom>
<ClearRoomHeight unit="m">2.5</ClearRoomHeight>
<DesignVolumeFlowRateSupply unit="m³/h">14.2</DesignVolumeFlowRateSupply>
<DesignVolumeFlowRateExhaust unit="m³/h">14.2</DesignVolumeFlowRateExhaust>
<DesignVolumeFlowRateSupply unit="m³/h">13.71</DesignVolumeFlowRateSupply>
<DesignVolumeFlowRateExhaust unit="m³/h">13.71</DesignVolumeFlowRateExhaust>
</Room>
<Room index="1">
<Name>102-Room_5</Name>
<Name>102-Room_2</Name>
<Type>99</Type>
<IdentNrUtilizationPatternVent>1</IdentNrUtilizationPatternVent>
<IdentNrVentilationUnit>1</IdentNrVentilationUnit>
<Quantity>1</Quantity>
<AreaRoom unit="">9.0</AreaRoom>
<ClearRoomHeight unit="m">2.5</ClearRoomHeight>
<DesignVolumeFlowRateSupply unit="m³/h">14.2</DesignVolumeFlowRateSupply>
<DesignVolumeFlowRateExhaust unit="m³/h">14.2</DesignVolumeFlowRateExhaust>
<DesignVolumeFlowRateSupply unit="m³/h">15.34</DesignVolumeFlowRateSupply>
<DesignVolumeFlowRateExhaust unit="m³/h">15.34</DesignVolumeFlowRateExhaust>
</Room>
</RoomsVentilation>
<LoadsPersonsPH count="2">
<LoadPerson index="0">
<Name>101-Room_4</Name>
<Name>101-Room_1</Name>
<IdentNrUtilizationPattern>1</IdentNrUtilizationPattern>
<ChoiceActivityPersons>3</ChoiceActivityPersons>
<NumberOccupants>1</NumberOccupants>
<FloorAreaUtilizationZone unit="">9.0</FloorAreaUtilizationZone>
</LoadPerson>
<LoadPerson index="1">
<Name>102-Room_5</Name>
<Name>102-Room_2</Name>
<IdentNrUtilizationPattern>1</IdentNrUtilizationPattern>
<ChoiceActivityPersons>3</ChoiceActivityPersons>
<NumberOccupants>1</NumberOccupants>
Expand All @@ -751,8 +751,8 @@
<SpecificHeatCapacity_Selection>2</SpecificHeatCapacity_Selection>
<SpecificHeatCapacity>132</SpecificHeatCapacity>
<IdentNrPH_Building>1</IdentNrPH_Building>
<OccupantQuantityUserDef unit="-">0</OccupantQuantityUserDef>
<NumberBedrooms unit="-">0</NumberBedrooms>
<OccupantQuantityUserDef unit="-">3</OccupantQuantityUserDef>
<NumberBedrooms unit="-">3</NumberBedrooms>
<HomeDevice count="5">
<Device index="0">
<Comment>default</Comment>
Expand Down Expand Up @@ -826,56 +826,56 @@
<ExhaustVents count="0"/>
<ThermalBridges count="8">
<ThermalBridge index="0">
<Name>_unnamed_bldg_segment__3ac79ea0</Name>
<Name>_unnamed_bldg_segment__1bfe9c29</Name>
<Type>-15</Type>
<Length>10.733126291998989</Length>
<Length>13.416407864998739</Length>
<PsiValue>0.01</PsiValue>
<IdentNrOptionalClimate>-1</IdentNrOptionalClimate>
</ThermalBridge>
<ThermalBridge index="1">
<Name>_unnamed_bldg_segment__3f824c64</Name>
<Name>_unnamed_bldg_segment__3ccfd8c2</Name>
<Type>-15</Type>
<Length>18.0</Length>
<Length>10.733126291998989</Length>
<PsiValue>0.01</PsiValue>
<IdentNrOptionalClimate>-1</IdentNrOptionalClimate>
</ThermalBridge>
<ThermalBridge index="2">
<Name>_unnamed_bldg_segment__4d56f347</Name>
<Name>_unnamed_bldg_segment__7ce04f2b</Name>
<Type>-15</Type>
<Length>16.0</Length>
<Length>14.0</Length>
<PsiValue>0.01</PsiValue>
<IdentNrOptionalClimate>-1</IdentNrOptionalClimate>
</ThermalBridge>
<ThermalBridge index="3">
<Name>_unnamed_bldg_segment__81dadafb</Name>
<Name>_unnamed_bldg_segment__86d2380e</Name>
<Type>-15</Type>
<Length>14.0</Length>
<Length>18.0</Length>
<PsiValue>0.01</PsiValue>
<IdentNrOptionalClimate>-1</IdentNrOptionalClimate>
</ThermalBridge>
<ThermalBridge index="4">
<Name>_unnamed_bldg_segment__b60cb1fc</Name>
<Name>_unnamed_bldg_segment__9cc643da</Name>
<Type>-15</Type>
<Length>13.416407864998739</Length>
<Length>22.0</Length>
<PsiValue>0.01</PsiValue>
<IdentNrOptionalClimate>-1</IdentNrOptionalClimate>
</ThermalBridge>
<ThermalBridge index="5">
<Name>_unnamed_bldg_segment__ba1c1bf7</Name>
<Name>_unnamed_bldg_segment__a6658bb5</Name>
<Type>-15</Type>
<Length>22.0</Length>
<Length>16.0</Length>
<PsiValue>0.01</PsiValue>
<IdentNrOptionalClimate>-1</IdentNrOptionalClimate>
</ThermalBridge>
<ThermalBridge index="6">
<Name>_unnamed_bldg_segment__ca10e05d</Name>
<Name>_unnamed_bldg_segment__b3f0a93e</Name>
<Type>-15</Type>
<Length>9.391485505499118</Length>
<PsiValue>0.01</PsiValue>
<IdentNrOptionalClimate>-1</IdentNrOptionalClimate>
</ThermalBridge>
<ThermalBridge index="7">
<Name>_unnamed_bldg_segment__e4979691</Name>
<Name>_unnamed_bldg_segment__bb2f2c18</Name>
<Type>-15</Type>
<Length>9.391485505499118</Length>
<PsiValue>0.01</PsiValue>
Expand Down Expand Up @@ -1102,7 +1102,7 @@
<BuildingStatus>1</BuildingStatus>
<BuildingType>1</BuildingType>
<OccupancySettingMethod>2</OccupancySettingMethod>
<NumberUnits>0</NumberUnits>
<NumberUnits>3</NumberUnits>
<CountStories>1</CountStories>
<EnvelopeAirtightnessCoefficient>0.8157599999999999</EnvelopeAirtightnessCoefficient>
<SummerHRVHumidityRecovery choice="Always">4</SummerHRVHumidityRecovery>
Expand Down Expand Up @@ -1167,7 +1167,7 @@
</PH_Parameters>
</Device>
<Device index="1">
<Name>0dc26a42-ce11-42d5-add1-eb0c1b7011d3</Name>
<Name>a2cf40ba-1310-4b1c-a6cd-a16f63df5d02</Name>
<IdentNr>1</IdentNr>
<SystemType>5</SystemType>
<TypeDevice>5</TypeDevice>
Expand Down
Binary file modified tests/_source_gh/hbph_test_models.gh
Binary file not shown.
Loading

0 comments on commit 1231bf5

Please sign in to comment.