Skip to content

Commit

Permalink
fix(wind): Add Wind Exposure Type
Browse files Browse the repository at this point in the history
- Add new building-segment attribute for wind-protection-type (WUFI)
- format `isort`, `black`
- update tests
  • Loading branch information
ed-p-may committed Jun 6, 2024
1 parent f8317b9 commit d870c9b
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 3 deletions.
24 changes: 22 additions & 2 deletions honeybee_ph/bldg_segment.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,29 @@


class PhVentilationSummerBypassMode(enumerables.CustomEnum):
allowed = ["1-None", "2-Temperatur Controlled", "3-Enthalpy Controlled", "4-Always"]
allowed = ["1-None", "2-Temperature Controlled", "3-Enthalpy Controlled", "4-Always"]

def __init__(self, _value=1):
# type: (Union[str, int]) -> None
super(PhVentilationSummerBypassMode, self).__init__(_value)


class PhWindExposureType(enumerables.CustomEnum):
allowed = [
"1-SEVERAL_SIDES_EXPOSED_NO_SCREENING",
"2-SEVERAL_SIDES_EXPOSED_MODERATE_SCREENING",
"3-SEVERAL_SIDES_EXPOSED_HIGH_SCREENING",
"4-ONE_SIDE_EXPOSED_NO_SCREENING",
"5-ONE_SIDE_EXPOSED_MODERATE_SCREENING",
"6-USER_DEFINED",
"7-ONE_SIDE_EXPOSED_HIGH_SCREENING",
]

def __init__(self, _value=1):
# type: (Union[str, int]) -> None
super(PhWindExposureType, self).__init__(_value)


class SetPoints(_base._Base):
def __init__(self):
super(SetPoints, self).__init__()
Expand Down Expand Up @@ -85,6 +101,7 @@ def __init__(self):
self.mech_room_temp = 20.0
self.non_combustible_materials = False
self.thermal_bridges = {} # type: Dict[str, thermal_bridge.PhThermalBridge]
self.wind_exposure_type = PhWindExposureType("1-SEVERAL_SIDES_EXPOSED_NO_SCREENING")
self.summer_hrv_bypass_mode = PhVentilationSummerBypassMode("4-Always")

def add_new_thermal_bridge(self, tb):
Expand Down Expand Up @@ -113,6 +130,7 @@ def to_dict(self):
for tb in self.thermal_bridges.values():
d["thermal_bridges"][str(tb.identifier)] = tb.to_dict()
d["summer_hrv_bypass_mode"] = self.summer_hrv_bypass_mode.to_dict()
d["wind_exposure_type"] = self.wind_exposure_type.to_dict()
return d

@classmethod
Expand All @@ -133,10 +151,11 @@ def from_dict(cls, _dict):
obj.set_points = SetPoints.from_dict(_dict.get("set_points", {}))
obj.mech_room_temp = _dict["mech_room_temp"]
obj.non_combustible_materials = _dict.get("non_combustible_materials", False)
for tb_dict in _dict["thermal_bridges"].values():
for tb_dict in _dict.get("thermal_bridges", {}).values():
tb_obj = thermal_bridge.PhThermalBridge.from_dict(tb_dict)
obj.thermal_bridges[tb_obj.identifier] = tb_obj
obj.summer_hrv_bypass_mode = PhVentilationSummerBypassMode.from_dict(_dict.get("summer_hrv_bypass_mode", {}))
obj.wind_exposure_type = PhWindExposureType.from_dict(_dict.get("wind_exposure_type", {}))
return obj

def __copy__(self):
Expand All @@ -157,6 +176,7 @@ def __copy__(self):
for tb_k, tb_v in self.thermal_bridges.items():
new_obj.thermal_bridges[tb_k] = tb_v.duplicate()
new_obj.summer_hrv_bypass_mode = PhVentilationSummerBypassMode(self.summer_hrv_bypass_mode.value)
new_obj.wind_exposure_type = PhWindExposureType(self.wind_exposure_type.value)
return new_obj

def duplicate(self):
Expand Down
21 changes: 20 additions & 1 deletion tests/test_honeybee_ph/test_bldg_segment.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from ladybug_geometry.geometry3d import LineSegment3D, Point3D

from honeybee_energy_ph.construction.thermal_bridge import PhThermalBridge
from honeybee_ph.bldg_segment import BldgSegment, PhVentilationSummerBypassMode, SetPoints
from honeybee_ph.bldg_segment import BldgSegment, PhVentilationSummerBypassMode, PhWindExposureType, SetPoints


def test_set_points_round_trip():
Expand Down Expand Up @@ -110,3 +110,22 @@ def test_set_summer_bypass_mode_duplicate():

seg2 = seg1.duplicate()
assert seg2.summer_hrv_bypass_mode == seg1.summer_hrv_bypass_mode


def test_set_wind_exposure_type_roundtrip():
seg1 = BldgSegment()
seg1.wind_exposure_type = PhWindExposureType(2)

d1 = seg1.to_dict()
seg2 = BldgSegment.from_dict(d1)
assert seg2.wind_exposure_type.number == 2
assert seg2.wind_exposure_type == seg1.wind_exposure_type


def test_set_wind_exposure_type_duplicate():
seg1 = BldgSegment()
seg1.wind_exposure_type = PhWindExposureType(2)

seg2 = seg1.duplicate()
assert seg2.wind_exposure_type.number == 2
assert seg2.wind_exposure_type == seg1.wind_exposure_type

0 comments on commit d870c9b

Please sign in to comment.