Skip to content

Commit

Permalink
feat(phius_certification): Add Phius 2021 Cert. Default
Browse files Browse the repository at this point in the history
- Add new 2021 Phius Certification Options
- Make '2021 CORE' the new WUFI Default
- Update all Honeybee dependency versions
- Update XL-Write typing and tests
- Update WUFI window
  • Loading branch information
ed-p-may committed Mar 6, 2023
1 parent 4a48cce commit 96093f2
Show file tree
Hide file tree
Showing 17 changed files with 446 additions and 406 deletions.
16 changes: 9 additions & 7 deletions PHX/from_HBJSON/create_variant.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,20 +92,17 @@ def add_phius_certification_from_hb_room(
* None
"""

# alias cus' all this shit is deep in there...
# -- alias cus' all this shit is deep in there...
hbph_phius_cert: phius.PhiusCertification = _hb_room.properties.ph.ph_bldg_segment.phius_certification # type: ignore # alias
phx_phius_cert_criteria = _variant.phius_cert.phius_certification_criteria # alias
phx_phius_cert_settings = _variant.phius_cert.phius_certification_settings # alias

# some random bullshit
phx_phius_cert_criteria.ph_certificate_criteria = (
hbph_phius_cert.certification_criteria
)
# -- some random bullshit
phx_phius_cert_criteria.ph_selection_target_data = (
hbph_phius_cert.localization_selection_type
)

# certification thresholds (for Phius, they change)
# -- certification thresholds (for Phius, they change with climate)
phx_phius_cert_criteria.phius_annual_heating_demand = (
hbph_phius_cert.PHIUS2021_heating_demand
)
Expand All @@ -119,7 +116,12 @@ def add_phius_certification_from_hb_room(
hbph_phius_cert.PHIUS2021_cooling_load
)

# certification settings / types
# -- certification settings / types
phx_phius_cert_settings.phius_building_certification_program = (
phius_certification.PhiusCertificationProgram(
hbph_phius_cert.certification_program.number
)
)
phx_phius_cert_settings.phius_building_category_type = (
phius_certification.PhiusCertificationBuildingCategoryType(
hbph_phius_cert.building_category_type.number
Expand Down
4 changes: 3 additions & 1 deletion PHX/model/certification.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ def add_foundation(self, _input: ground.PhxFoundation) -> None:
# -----------------------------------------------------------------------------
@dataclass
class PhxPhiusCertificationCriteria:
ph_certificate_criteria: int = 3
ph_selection_target_data: int = 2

phius_annual_heating_demand: float = 15.0
Expand All @@ -59,6 +58,9 @@ class PhxPhiusCertificationCriteria:

@dataclass
class PhxPhiusCertificationSettings:
phius_building_certification_program = (
phius_certification.PhiusCertificationProgram.PHIUS_2021_CORE
)
phius_building_category_type = (
phius_certification.PhiusCertificationBuildingCategoryType.RESIDENTIAL_BUILDING
)
Expand Down
10 changes: 10 additions & 0 deletions PHX/model/enums/phius_certification.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,13 @@ class PhiusCertificationBuildingType(Enum):
NEW_CONSTRUCTION = 1
RETROFIT = 2
MIXED = 3

class PhiusCertificationProgram(Enum):
DEFAULT = 1
PHIUS_2015 = 2
PHIUS_2018 = 3
ITALIAN = 4
PHIUS_2018_CORE = 5
PHIUS_2018_ZERO = 6
PHIUS_2021_CORE = 7
PHIUS_2021_ZERO = 8
4 changes: 2 additions & 2 deletions PHX/to_WUFI_XML/xml_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ def _PhxPhiusCertification(
return [
XML_Node(
"PH_CertificateCriteria",
_phius_cert.phius_certification_criteria.ph_certificate_criteria,
_phius_cert.phius_certification_settings.phius_building_certification_program.value,
),
XML_Node(
"PH_SelectionTargetData",
Expand Down Expand Up @@ -735,7 +735,7 @@ def _PhxConstructionWindow(
return [
XML_Node("IdentNr", _wt.id_num),
XML_Node("Name", _wt.display_name),
XML_Node("Uw_Detailed>", _wt.use_detailed_uw),
XML_Node("Uw_Detailed", _wt.use_detailed_uw),
XML_Node("GlazingFrameDetailed", _wt.use_detailed_frame),
XML_Node("FrameFactor", _wt.frame_factor),
XML_Node("U_Value", _wt.u_value_window),
Expand Down
26 changes: 22 additions & 4 deletions PHX/xl/xl_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from PHX.xl.xl_typing import (
xl_Framework_Protocol,
xl_Book_Protocol,
xl_Sheets_Protocol,
xl_Sheet_Protocol,
xl_Range_Protocol,
)
Expand Down Expand Up @@ -96,6 +97,10 @@ def __init__(self, xl_framework, output: Optional[Callable] = silent_print):
self._output = output
self.output(f"> connected to excel doc: {self.wb}")

@property
def sheets(self) -> xl_Sheets_Protocol:
return self.wb.sheets

@property
def os_is_windows(self) -> bool:
"""Return True if the current OS is Windows. False if it is Mac/Linux"""
Expand Down Expand Up @@ -142,10 +147,10 @@ def clear_sheet_all(self, _sheet_name: str) -> None:
"""Clears the content and formatting of the whole sheet."""
self.get_sheet_by_name(_sheet_name).clear()

def create_new_worksheet(self, _sheet_name: str) -> None:
def create_new_worksheet(self, _sheet_name: str, before: Optional[str]=None, after: Optional[str]=None) -> None:
"""Try and add a new Worksheet to the Workbook."""
try:
self.wb.sheets.add(_sheet_name)
self.wb.sheets.add(_sheet_name, before, after)
self.output(f"Adding '{_sheet_name}' to Workbook")
except ValueError:
self.output(f"Worksheet '{_sheet_name}' already in Workbook.")
Expand Down Expand Up @@ -205,19 +210,32 @@ def get_worksheet_names(self) -> Set[str]:
"""
return {sh.name for sh in self.wb.sheets}

def get_sheet_by_name(self, _sheet_name: str) -> xl_Sheet_Protocol:
def get_sheet_by_name(self, _sheet_name: Union[str, int]) -> xl_Sheet_Protocol:
"""Returns an Excel Sheet with the specified name, or KeyError if not found.
Arguments:
----------
* _sheet_name: (str): The excel sheet name to locate.
* _sheet_name: (Union[str, int]): The excel sheet name or index num. to locate.
Returns:
--------
* (xw.main.Sheet): The excel sheet found.
"""
if _sheet_name not in self.get_worksheet_names():
msg = f"Error: Key '{_sheet_name}' was not found in the Workbook '{self.wb.name}' Sheets?"
raise KeyError(msg)

return self.wb.sheets[_sheet_name]

def get_last_sheet(self) -> xl_Sheet_Protocol:
"""Return the last Worksheet in the Workbook.
Returns:
--------
* (xl_Sheet_Protocol) The last Worksheet in the Workbook.
"""
return self.wb.sheets[-1]

def get_last_used_row_num_in_column(self, _sheet_name: str, _col: str) -> int:
"""Return the row number of the last cell in a column with a value in it.
Expand Down
16 changes: 9 additions & 7 deletions PHX/xl/xl_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ def Unprotect(self) -> None:


class xl_Sheet_Protocol:
def __init__(self):
def __init__(self, name="Sheet1"):
self.api = xl_API_Protocol(self)
self.protected = True
self._ranges = {}
self.name: str
self.name: str = name

def range(self, cell1: str, cell2: Optional[str] = None) -> xl_Range_Protocol:
if cell1 in self._ranges.keys():
Expand All @@ -89,20 +89,22 @@ def range(self, cell1: str, cell2: Optional[str] = None) -> xl_Range_Protocol:
return rng_obj

def clear_contents(self) -> None:
return None
...

def clear_formats(self) -> None:
return None
...

def clear(self) -> None:
return None
...

def activate(self) -> None:
...

def autofit(self, *args, **kwargs) -> None:
...

def delete(self) -> None:
...

class xl_Sheets_Protocol:
def __init__(self):
Expand All @@ -118,9 +120,9 @@ def add(
after: Optional[str] = None,
) -> xl_Sheet_Protocol:
if name in self.storage.keys():
raise ValueError
return self.storage[str(name)]
else:
new_sheet = xl_Sheet_Protocol()
new_sheet = xl_Sheet_Protocol(name=str(name))
self.storage[str(name)] = new_sheet
return new_sheet

Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
honeybee-core>=1.54.33
honeybee-energy>=1.99.8
honeybee-core>=1.54.34
honeybee-energy>=1.99.10
honeybee-ph
PH-units
pydantic
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_5_b777e995..Face4</Name>
<Name>Room_2_e42149fb..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_5_b777e995..Face5</Name>
<Name>Room_2_e42149fb..Face5</Name>
<Visual>true</Visual>
<Type>1</Type>
<IdentNrColorI>7</IdentNrColorI>
Expand Down Expand Up @@ -482,7 +482,7 @@
</PH_ClimateLocation>
</ClimateLocation>
<PassivehouseData>
<PH_CertificateCriteria>3</PH_CertificateCriteria>
<PH_CertificateCriteria>7</PH_CertificateCriteria>
<PH_SelectionTargetData>2</PH_SelectionTargetData>
<AnnualHeatingDemand>15.0</AnnualHeatingDemand>
<AnnualCoolingDemand>15.0</AnnualCoolingDemand>
Expand Down
38 changes: 19 additions & 19 deletions tests/_reference_xml/Multi_Room_Complete.xml
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@
</Component>
<Component index="4">
<IdentNr>49</IdentNr>
<Name>Shade_3f430a24</Name>
<Name>Shade_3d20ef19</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_532bd2ca</Name>
<Name>Shade_047435e2</Name>
<Visual>true</Visual>
<Type>1</Type>
<IdentNrColorI>1</IdentNrColorI>
Expand All @@ -702,7 +702,7 @@
<IdentNr>1</IdentNr>
<RoomsVentilation count="2">
<Room index="0">
<Name>101-Room_7</Name>
<Name>101-Room_4</Name>
<Type>99</Type>
<IdentNrUtilizationPatternVent>1</IdentNrUtilizationPatternVent>
<IdentNrVentilationUnit>1</IdentNrVentilationUnit>
Expand All @@ -713,7 +713,7 @@
<DesignVolumeFlowRateExhaust unit="m³/h">14.2</DesignVolumeFlowRateExhaust>
</Room>
<Room index="1">
<Name>102-Room_8</Name>
<Name>102-Room_5</Name>
<Type>99</Type>
<IdentNrUtilizationPatternVent>1</IdentNrUtilizationPatternVent>
<IdentNrVentilationUnit>1</IdentNrVentilationUnit>
Expand All @@ -726,14 +726,14 @@
</RoomsVentilation>
<LoadsPersonsPH count="2">
<LoadPerson index="0">
<Name>101-Room_7</Name>
<Name>101-Room_4</Name>
<IdentNrUtilizationPattern>1</IdentNrUtilizationPattern>
<ChoiceActivityPersons>3</ChoiceActivityPersons>
<NumberOccupants>1</NumberOccupants>
<FloorAreaUtilizationZone unit="">9.0</FloorAreaUtilizationZone>
</LoadPerson>
<LoadPerson index="1">
<Name>102-Room_8</Name>
<Name>102-Room_5</Name>
<IdentNrUtilizationPattern>1</IdentNrUtilizationPattern>
<ChoiceActivityPersons>3</ChoiceActivityPersons>
<NumberOccupants>1</NumberOccupants>
Expand Down Expand Up @@ -826,58 +826,58 @@
<ExhaustVents count="0"/>
<ThermalBridges count="8">
<ThermalBridge index="0">
<Name>_unnamed_bldg_segment__0e1a8441</Name>
<Name>_unnamed_bldg_segment__3ac79ea0</Name>
<Type>-15</Type>
<Length>10.733126291998989</Length>
<PsiValue>0.01</PsiValue>
<IdentNrOptionalClimate>-1</IdentNrOptionalClimate>
</ThermalBridge>
<ThermalBridge index="1">
<Name>_unnamed_bldg_segment__0e2e3c0f</Name>
<Name>_unnamed_bldg_segment__3f824c64</Name>
<Type>-15</Type>
<Length>18.0</Length>
<PsiValue>0.01</PsiValue>
<IdentNrOptionalClimate>-1</IdentNrOptionalClimate>
</ThermalBridge>
<ThermalBridge index="2">
<Name>_unnamed_bldg_segment__40041adf</Name>
<Name>_unnamed_bldg_segment__4d56f347</Name>
<Type>-15</Type>
<Length>9.391485505499118</Length>
<Length>16.0</Length>
<PsiValue>0.01</PsiValue>
<IdentNrOptionalClimate>-1</IdentNrOptionalClimate>
</ThermalBridge>
<ThermalBridge index="3">
<Name>_unnamed_bldg_segment__467dd3a3</Name>
<Name>_unnamed_bldg_segment__81dadafb</Name>
<Type>-15</Type>
<Length>14.0</Length>
<PsiValue>0.01</PsiValue>
<IdentNrOptionalClimate>-1</IdentNrOptionalClimate>
</ThermalBridge>
<ThermalBridge index="4">
<Name>_unnamed_bldg_segment__5c6164b2</Name>
<Name>_unnamed_bldg_segment__b60cb1fc</Name>
<Type>-15</Type>
<Length>13.416407864998739</Length>
<PsiValue>0.01</PsiValue>
<IdentNrOptionalClimate>-1</IdentNrOptionalClimate>
</ThermalBridge>
<ThermalBridge index="5">
<Name>_unnamed_bldg_segment__74755e38</Name>
<Name>_unnamed_bldg_segment__ba1c1bf7</Name>
<Type>-15</Type>
<Length>22.0</Length>
<PsiValue>0.01</PsiValue>
<IdentNrOptionalClimate>-1</IdentNrOptionalClimate>
</ThermalBridge>
<ThermalBridge index="6">
<Name>_unnamed_bldg_segment__a2ff4bdb</Name>
<Name>_unnamed_bldg_segment__ca10e05d</Name>
<Type>-15</Type>
<Length>9.391485505499118</Length>
<PsiValue>0.01</PsiValue>
<IdentNrOptionalClimate>-1</IdentNrOptionalClimate>
</ThermalBridge>
<ThermalBridge index="7">
<Name>_unnamed_bldg_segment__a7714530</Name>
<Name>_unnamed_bldg_segment__e4979691</Name>
<Type>-15</Type>
<Length>16.0</Length>
<Length>9.391485505499118</Length>
<PsiValue>0.01</PsiValue>
<IdentNrOptionalClimate>-1</IdentNrOptionalClimate>
</ThermalBridge>
Expand Down Expand Up @@ -1088,7 +1088,7 @@
</PH_ClimateLocation>
</ClimateLocation>
<PassivehouseData>
<PH_CertificateCriteria>3</PH_CertificateCriteria>
<PH_CertificateCriteria>7</PH_CertificateCriteria>
<PH_SelectionTargetData>2</PH_SelectionTargetData>
<AnnualHeatingDemand>15.0</AnnualHeatingDemand>
<AnnualCoolingDemand>15.0</AnnualCoolingDemand>
Expand Down Expand Up @@ -1167,7 +1167,7 @@
</PH_Parameters>
</Device>
<Device index="1">
<Name>767c92e3-223a-4ba8-a8ce-40932465d9e6</Name>
<Name>0dc26a42-ce11-42d5-add1-eb0c1b7011d3</Name>
<IdentNr>1</IdentNr>
<SystemType>5</SystemType>
<TypeDevice>5</TypeDevice>
Expand Down Expand Up @@ -1451,7 +1451,7 @@
<WindowType index="0">
<IdentNr>1</IdentNr>
<Name>Generic Double Pane</Name>
<Uw_Detailed>>true</Uw_Detailed>>
<Uw_Detailed>true</Uw_Detailed>
<GlazingFrameDetailed>true</GlazingFrameDetailed>
<FrameFactor>0.75</FrameFactor>
<U_Value>1.6877873779011647</U_Value>
Expand Down
Binary file modified tests/_source_gh/hbph_test_models.gh
Binary file not shown.
Loading

0 comments on commit 96093f2

Please sign in to comment.