Skip to content

Commit b217bf6

Browse files
committed
feat(components): Support Merging Thermal Bridges
- Support Merging Thermal Bridges - Black formatting all
1 parent 03fd78f commit b217bf6

File tree

69 files changed

+1104
-650
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+1104
-650
lines changed

PHX/from_HBJSON/cleanup.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858

5959
logger = logging.getLogger()
6060

61+
6162
def _dup_face(_hb_face: face.Face) -> face.Face:
6263
"""Duplicate a Honeybee Face and all it's properties.
6364
@@ -376,17 +377,17 @@ def merge_foundations(_hb_rooms: List[room.Room]) -> Dict[str, PhFoundation]:
376377
# -- Group by Identifier
377378
foundation_groups = {}
378379
for rm in _hb_rooms:
379-
foundations = rm.properties.ph.ph_foundations # type: ignore
380+
foundations = rm.properties.ph.ph_foundations # type: ignore
380381
for foundation in foundations:
381382
foundation_groups[foundation.identifier] = foundation
382383

383384
# -- Warn if more than 3 of them
384385
if len(foundation_groups) > 3:
385-
name = _hb_rooms[0].properties.ph.ph_bldg_segment.display_name # type: ignore
386+
name = _hb_rooms[0].properties.ph.ph_bldg_segment.display_name # type: ignore
386387
msg = (
387388
f"\tWarning: WUFI-Passive only allows 3 Foundation types. "
388389
f" {len(foundation_groups)} found on the Building Segment '"
389-
f"{name}'?"
390+
f"{name}'?"
390391
)
391392
print(msg)
392393

@@ -429,11 +430,15 @@ def merge_rooms(
429430
# -- Try and merge the Faces to simplify the geometry
430431
if _merge_faces:
431432
logger.debug(f"Merging Faces with tolerance: {_tolerance}")
432-
face_groups = face_tools.group_hb_faces(exposed_faces, _tolerance, _angle_tolerance_degrees)
433+
face_groups = face_tools.group_hb_faces(
434+
exposed_faces, _tolerance, _angle_tolerance_degrees
435+
)
433436
merged_faces = []
434437
for face_group in face_groups:
435438
const_name = face_group[0].properties.energy.construction.display_name
436-
logger.debug(f"Merging {len(face_group)} Faces with Construction: {const_name}")
439+
logger.debug(
440+
f"Merging {len(face_group)} Faces with Construction: {const_name}"
441+
)
437442
merged_faces.extend(
438443
merge_hb_faces(face_group, _tolerance, _angle_tolerance_degrees)
439444
)

PHX/from_HBJSON/cleanup_merge_faces.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,10 @@ def merge_hb_faces(
142142
_faces: List[Face], _tolerance: float, _angle_tolerance_degrees: float
143143
) -> List[Face]:
144144
"""Merge a group of HB-Faces into the fewest number of faces possible."""
145-
145+
146146
if not _faces:
147147
logger.debug("No faces in group. Skipping merge.")
148-
return []
148+
return []
149149

150150
if len(_faces) == 1:
151151
logger.debug(f"Single face: {_faces[0].display_name} in group. Skipping merge.")
@@ -159,7 +159,9 @@ def merge_hb_faces(
159159

160160
# -------------------------------------------------------------------------
161161
# -- Merge the HB-Faces' Polygons together
162-
merged_polygon2Ds = polygon2d_tools.merge_lbt_face_polygons(face3Ds(_faces), _tolerance)
162+
merged_polygon2Ds = polygon2d_tools.merge_lbt_face_polygons(
163+
face3Ds(_faces), _tolerance
164+
)
163165

164166
# -------------------------------------------------------------------------
165167
# -- Create new LBT-Face3D, and HB-Faces from the Polygon2Ds
@@ -214,7 +216,9 @@ def merge_hb_shades(
214216

215217
# -------------------------------------------------------------------------
216218
# -- Merge the HB-Face's Polygons together
217-
merged_polygon2Ds = polygon2d_tools.merge_lbt_face_polygons(face3Ds(_faces), _tolerance)
219+
merged_polygon2Ds = polygon2d_tools.merge_lbt_face_polygons(
220+
face3Ds(_faces), _tolerance
221+
)
218222

219223
# -------------------------------------------------------------------------
220224
# -- Create new LBT-Face3D, and HB-Faces from the Polygon2Ds

PHX/from_HBJSON/create_assemblies.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ def _conductivity_from_r_value(_r_value: float, _thickness: float) -> float:
3838
return conductivity
3939

4040

41-
def create_phx_color_from_hbph_color(_hbph_color: Optional[color.PhColor]) -> constructions.PhxColor:
41+
def create_phx_color_from_hbph_color(
42+
_hbph_color: Optional[color.PhColor],
43+
) -> constructions.PhxColor:
4244
"""Create a new PHX-Color from a Honeybee-PH-Utils PhColor.
4345
4446
Arguments:
@@ -57,6 +59,7 @@ def create_phx_color_from_hbph_color(_hbph_color: Optional[color.PhColor]) -> co
5759
new_color.blue = int(_hbph_color.b)
5860
return new_color
5961

62+
6063
def build_phx_material_from_hb_EnergyMaterial(
6164
_hb_material: EnergyMaterial,
6265
) -> constructions.PhxMaterial:
@@ -78,9 +81,11 @@ def build_phx_material_from_hb_EnergyMaterial(
7881
new_mat.density = _hb_material.density
7982
new_mat.heat_capacity = _hb_material.specific_heat
8083

81-
_prop_ph = _hb_material.properties.ph # type: EnergyMaterialPhProperties # type: ignore
82-
new_mat.percentage_of_assembly = _prop_ph.percentage_of_assembly
83-
84+
_prop_ph = (
85+
_hb_material.properties.ph
86+
) # type: EnergyMaterialPhProperties # type: ignore
87+
new_mat.percentage_of_assembly = _prop_ph.percentage_of_assembly
88+
8489
try:
8590
hbph_color = _prop_ph.ph_color
8691
except AttributeError:
@@ -117,7 +122,9 @@ def build_phx_material_from_hb_EnergyMaterialNoMass(
117122
new_mat.density = _hb_material.mass_area_density
118123
new_mat.heat_capacity = _hb_material.area_heat_capacity
119124

120-
_prop_ph = _hb_material.properties.ph # type: EnergyMaterialPhProperties # type: ignore
125+
_prop_ph = (
126+
_hb_material.properties.ph
127+
) # type: EnergyMaterialPhProperties # type: ignore
121128
try:
122129
hbph_color = _prop_ph.ph_color
123130
except AttributeError:

PHX/from_HBJSON/create_elec_equip.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def build_phx_elec_device(
5959
try:
6060
setattr(phx_device, attr_name, getattr(_hbph_device, attr_name))
6161
except KeyError:
62-
raise
62+
raise
6363
except Exception as e:
6464
msg = f"\n\tError setting attribute '{attr_name}' on '{phx_device.__class__.__name__}'?"
6565
raise Exception(msg)

PHX/from_HBJSON/create_foundations.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,16 @@
99
from PHX.model.enums.foundations import FoundationType
1010
from PHX.model import ground
1111

12-
def create_phx_foundation_from_hbph(_hbph_foundation: PhFoundation) -> ground.PhxFoundation:
12+
13+
def create_phx_foundation_from_hbph(
14+
_hbph_foundation: PhFoundation,
15+
) -> ground.PhxFoundation:
1316
"""Return a new PhxFoundation object with attributes based on a source HBPH-Foundation.
14-
17+
1518
Arguments:
1619
----------
1720
*
18-
21+
1922
Returns:
2023
--------
2124
* (PhxFoundation)
@@ -30,8 +33,9 @@ def create_phx_foundation_from_hbph(_hbph_foundation: PhFoundation) -> ground.Ph
3033
}
3134
new_phx_foundation = phx_foundation_type_map[_hbph_foundation.__class__.__name__]()
3235
new_phx_foundation.display_name = _hbph_foundation.display_name
33-
new_phx_foundation.foundation_type_num = FoundationType(_hbph_foundation.foundation_type.number)
34-
36+
new_phx_foundation.foundation_type_num = FoundationType(
37+
_hbph_foundation.foundation_type.number
38+
)
3539

3640
# -- Pull out all the PH attributes and set the PHX ones to match.
3741
for attr_name in vars(_hbph_foundation).keys():
@@ -40,13 +44,17 @@ def create_phx_foundation_from_hbph(_hbph_foundation: PhFoundation) -> ground.Ph
4044

4145
try:
4246
# try and set any Enums by number first...
43-
setattr(new_phx_foundation, attr_name, getattr(_hbph_foundation, attr_name).number)
47+
setattr(
48+
new_phx_foundation, attr_name, getattr(_hbph_foundation, attr_name).number
49+
)
4450
except AttributeError:
4551
# ... then just set copy over any non-Enum values
4652
try:
47-
setattr(new_phx_foundation, attr_name, getattr(_hbph_foundation, attr_name))
53+
setattr(
54+
new_phx_foundation, attr_name, getattr(_hbph_foundation, attr_name)
55+
)
4856
except KeyError:
49-
raise
57+
raise
5058
except Exception as e:
5159
msg = f"\n\tError setting attribute '{attr_name}' on '{new_phx_foundation.__class__.__name__}'?"
5260
raise Exception(msg)

PHX/from_HBJSON/create_hvac.py

Lines changed: 54 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,9 @@ def build_phx_heating_device(_htg_sys: heating.PhHeatingSystem) -> hvac.PhxHeati
305305
"""Returns a new PHX-Heating-Device based on an input Honeybee-PH Heating System."""
306306

307307
# -- Mapping Honeybee-PH -> PHX types
308-
phx_heater_classes: Dict[str, Callable[[heating.PhHeatingSystem], hvac.PhxHeatingDevice]] = {
308+
phx_heater_classes: Dict[
309+
str, Callable[[heating.PhHeatingSystem], hvac.PhxHeatingDevice]
310+
] = {
309311
"PhHeatingDirectElectric": build_phx_heating_electric,
310312
"PhHeatingFossilBoiler": build_phx_heating_fossil_boiler,
311313
"PhHeatingWoodBoiler": build_phx_heating_wood_boiler,
@@ -330,6 +332,7 @@ def build_phx_heating_sys(_htg_sys: heating.PhHeatingSystem) -> hvac.PhxHeatingD
330332
# -----------------------------------------------------------------------------
331333
# -- Heat Pumps
332334

335+
333336
def hbph_heat_pump_has_cooling(_hbph_heat_pump: heat_pumps.PhHeatPumpSystem) -> bool:
334337
"""Return True if the input Honeybee-PH Heat-Pump System has any type of cooling enabled."""
335338
return any(
@@ -342,16 +345,26 @@ def hbph_heat_pump_has_cooling(_hbph_heat_pump: heat_pumps.PhHeatPumpSystem) ->
342345
)
343346

344347

345-
def build_phx_heat_pump_cooling_params(_hbph_heat_pump: heat_pumps.PhHeatPumpSystem) -> hvac.PhxCoolingParams:
348+
def build_phx_heat_pump_cooling_params(
349+
_hbph_heat_pump: heat_pumps.PhHeatPumpSystem,
350+
) -> hvac.PhxCoolingParams:
346351
"""Return a new PHX Cooling Params object based on an input Honeybee-PH Heat-Pump System."""
347-
352+
348353
new_params_obj = hvac.PhxCoolingParams()
349354

350-
new_params_obj.ventilation = build_phx_cooling_ventilation_params(_hbph_heat_pump.cooling_params.ventilation)
351-
new_params_obj.recirculation = build_phx_cooling_recirculation_params(_hbph_heat_pump.cooling_params.recirculation)
352-
new_params_obj.dehumidification = build_phx_cooling_dehumidification_params(_hbph_heat_pump.cooling_params.dehumidification)
353-
new_params_obj.panel = build_phx_cooling_panel_params(_hbph_heat_pump.cooling_params.panel)
354-
355+
new_params_obj.ventilation = build_phx_cooling_ventilation_params(
356+
_hbph_heat_pump.cooling_params.ventilation
357+
)
358+
new_params_obj.recirculation = build_phx_cooling_recirculation_params(
359+
_hbph_heat_pump.cooling_params.recirculation
360+
)
361+
new_params_obj.dehumidification = build_phx_cooling_dehumidification_params(
362+
_hbph_heat_pump.cooling_params.dehumidification
363+
)
364+
new_params_obj.panel = build_phx_cooling_panel_params(
365+
_hbph_heat_pump.cooling_params.panel
366+
)
367+
355368
return new_params_obj
356369

357370

@@ -363,62 +376,76 @@ def build_phx_heating_hp_annual(
363376
phx_obj = hvac.PhxHeatPumpAnnual()
364377
phx_obj = _transfer_attributes(_hbph_heat_pump, phx_obj)
365378
phx_obj.usage_profile.space_heating_percent = _hbph_heat_pump.percent_coverage
366-
379+
367380
if hbph_heat_pump_has_cooling(_hbph_heat_pump):
368-
phx_obj.usage_profile.cooling_percent = _hbph_heat_pump.cooling_params.percent_coverage
381+
phx_obj.usage_profile.cooling_percent = (
382+
_hbph_heat_pump.cooling_params.percent_coverage
383+
)
369384
phx_obj.params_cooling = build_phx_heat_pump_cooling_params(_hbph_heat_pump)
370-
385+
371386
return phx_obj
372387

373388

374389
def build_phx_heating_hp_monthly(
375390
_hbph_heat_pump: heat_pumps.PhHeatPumpSystem,
376391
) -> hvac.PhxHeatPumpMonthly:
377392
"""Returns a new Monthly PHX-Heat-Pump-Device based on an input Honeybee-PH Heat-Pump System."""
378-
393+
379394
phx_obj = hvac.PhxHeatPumpMonthly()
380395
phx_obj = _transfer_attributes(_hbph_heat_pump, phx_obj)
381396
phx_obj.usage_profile.space_heating_percent = _hbph_heat_pump.percent_coverage
382-
397+
383398
if hbph_heat_pump_has_cooling(_hbph_heat_pump):
384-
phx_obj.usage_profile.cooling_percent = _hbph_heat_pump.cooling_params.percent_coverage
399+
phx_obj.usage_profile.cooling_percent = (
400+
_hbph_heat_pump.cooling_params.percent_coverage
401+
)
385402
phx_obj.params_cooling = build_phx_heat_pump_cooling_params(_hbph_heat_pump)
386-
403+
387404
return phx_obj
388405

389406

390407
def build_phx_heating_hp_combined(
391408
_hbph_heat_pump: heat_pumps.PhHeatPumpSystem,
392409
) -> hvac.PhxHeatPumpCombined:
393410
"""Returns a new Combined PHX-Heat-Pump-Device based on an input Honeybee-PH Heat-Pump System."""
394-
411+
395412
phx_obj = hvac.PhxHeatPumpCombined()
396413
phx_obj = _transfer_attributes(_hbph_heat_pump, phx_obj)
397414
phx_obj.usage_profile.space_heating_percent = _hbph_heat_pump.percent_coverage
398-
415+
399416
if hbph_heat_pump_has_cooling(_hbph_heat_pump):
400-
phx_obj.usage_profile.cooling_percent = _hbph_heat_pump.cooling_params.percent_coverage
417+
phx_obj.usage_profile.cooling_percent = (
418+
_hbph_heat_pump.cooling_params.percent_coverage
419+
)
401420
phx_obj.params_cooling = build_phx_heat_pump_cooling_params(_hbph_heat_pump)
402-
421+
403422
return phx_obj
404423

405424

406-
def build_phx_heat_pump_device(_hbph_heat_pump: heat_pumps.PhHeatPumpSystem) -> hvac.PhxHeatPumpDevice:
425+
def build_phx_heat_pump_device(
426+
_hbph_heat_pump: heat_pumps.PhHeatPumpSystem,
427+
) -> hvac.PhxHeatPumpDevice:
407428
"""Returns a new PHX-He"at-Pump-Device based on an input Honeybee-PH Heat-Pump System."""
408429

409430
# -- Mapping Honeybee-PH -> PHX types
410-
phx_heat_pump_classes: Dict[str, Callable[[heat_pumps.PhHeatPumpSystem], hvac.PhxHeatPumpDevice]] = {
431+
phx_heat_pump_classes: Dict[
432+
str, Callable[[heat_pumps.PhHeatPumpSystem], hvac.PhxHeatPumpDevice]
433+
] = {
411434
"PhHeatPumpAnnual": build_phx_heating_hp_annual,
412435
"PhHeatPumpRatedMonthly": build_phx_heating_hp_monthly,
413436
"PhHeatPumpCombined": build_phx_heating_hp_combined,
414437
}
415438

416439
# -- Get and build the right heater equipment type
417-
phx_heat_pump = phx_heat_pump_classes[_hbph_heat_pump.heat_pump_class_name](_hbph_heat_pump)
440+
phx_heat_pump = phx_heat_pump_classes[_hbph_heat_pump.heat_pump_class_name](
441+
_hbph_heat_pump
442+
)
418443
return phx_heat_pump
419444

420445

421-
def build_phx_heat_pump_sys(_hbph_heat_pump: heat_pumps.PhHeatPumpSystem) -> hvac.PhxHeatPumpDevice:
446+
def build_phx_heat_pump_sys(
447+
_hbph_heat_pump: heat_pumps.PhHeatPumpSystem,
448+
) -> hvac.PhxHeatPumpDevice:
422449
"""Build a new PHX-Heat-Pump-Device Device from a Honeybee-PH Heat-Pump System."""
423450

424451
phx_htg_device = build_phx_heat_pump_device(_hbph_heat_pump)
@@ -428,7 +455,6 @@ def build_phx_heat_pump_sys(_hbph_heat_pump: heat_pumps.PhHeatPumpSystem) -> hva
428455
return phx_htg_device
429456

430457

431-
432458
# -----------------------------------------------------------------------------
433459
# --- Cooling Parameters for Heat Pumps
434460

@@ -453,7 +479,7 @@ def build_phx_cooling_ventilation_params(
453479
_hbph_cooling_params: heat_pumps.PhHeatPumpCoolingParams_Ventilation,
454480
) -> hvac.PhxCoolingVentilationParams:
455481
"""Build a new PHX Cooling Ventilation Params object from a Honeybee-PH Cooling Ventilation Params object."""
456-
482+
457483
phx_obj = hvac.PhxCoolingVentilationParams()
458484
phx_obj = _transfer_cooling_attributes(_hbph_cooling_params, phx_obj)
459485
return phx_obj
@@ -463,7 +489,7 @@ def build_phx_cooling_recirculation_params(
463489
_hbph_cooling_params: heat_pumps.PhHeatPumpCoolingParams_Recirculation,
464490
) -> hvac.PhxCoolingRecirculationParams:
465491
"""Build a new PHX-Cooling-Recirculation-Params object from a Honeybee-PH Cooling-Params object."""
466-
492+
467493
phx_obj = hvac.PhxCoolingRecirculationParams()
468494
phx_obj = _transfer_cooling_attributes(_hbph_cooling_params, phx_obj)
469495
return phx_obj
@@ -473,7 +499,7 @@ def build_phx_cooling_dehumidification_params(
473499
_hbph_cooling_params: heat_pumps.PhHeatPumpCoolingParams_Dehumidification,
474500
) -> hvac.PhxCoolingDehumidificationParams:
475501
"""Build a new PHX-Cooling-Dehumidification-Params object from a Honeybee-PH Cooling-Params object."""
476-
502+
477503
phx_obj = hvac.PhxCoolingDehumidificationParams()
478504
phx_obj = _transfer_cooling_attributes(_hbph_cooling_params, phx_obj)
479505
return phx_obj
@@ -483,7 +509,7 @@ def build_phx_cooling_panel_params(
483509
_hbph_cooling_params: heat_pumps.PhHeatPumpCoolingParams_Panel,
484510
) -> hvac.PhxCoolingPanelParams:
485511
"""Build a new PHX-Cooling-Panel-Params object from a Honeybee-PH Cooling-Params object."""
486-
512+
487513
phx_obj = hvac.PhxCoolingPanelParams()
488514
phx_obj = _transfer_cooling_attributes(_hbph_cooling_params, phx_obj)
489515
return phx_obj

0 commit comments

Comments
 (0)