Skip to content

Commit

Permalink
fix(site): Update Site, add WUFI Enums
Browse files Browse the repository at this point in the history
  • Loading branch information
ed-p-may committed Oct 18, 2022
1 parent 539500d commit b0e6e37
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 20 deletions.
2 changes: 2 additions & 0 deletions PHX/from_HBJSON/create_variant.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ def set_phx_phpp9_settings(_phx_settings: certification.PhxPhiCertificationSetti
_phx_settings.phi_enerphit_type = phi_certification_phpp_9.PhiCertEnerPHitType(phpp_9_attrs.enerphit_type.number)
_phx_settings.phi_retrofit_type = phi_certification_phpp_9.PhiCertRetrofitType(phpp_9_attrs.retrofit_type.number)


def set_phx_phpp10_settings(_phx_settings: certification.PhxPhiCertificationSettings, _hbph_settings:phi.PhiCertification) -> None:
"""Set the values of the PHX-PHI Settings object for PHPP-v10 Settings.
Expand All @@ -136,6 +137,7 @@ def set_phx_phpp10_settings(_phx_settings: certification.PhxPhiCertificationSett
_phx_settings.phi_pe_type = phi_certification_phpp_10.PhiCertificationPEType(phpp_10_attrs.primary_energy_type.number)
_phx_settings.phi_retrofit_type = phi_certification_phpp_10.PhiCertRetrofitType(phpp_10_attrs.retrofit_type.number)


def add_phi_certification_from_hb_room(_variant: project.PhxVariant, _hb_room: room.Room) -> None:
"""Set all the PhxPhiCertificationCriteria on a PhxVariant based on a Honeybee-Room's Building Segment.
Expand Down
12 changes: 6 additions & 6 deletions PHX/model/enums/phius_certification.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ class PhiusCertificationBuildingUseType(Enum):
UNDEFINED =7

class PhiusCertificationBuildingStatus(Enum):
IN_PLANNING = 1
UNDER_CONSTRUCTION = 2
COMPLETE = 3
IN_PLANNING = 1
UNDER_CONSTRUCTION = 2
COMPLETE = 3

class PhiusCertificationBuildingType(Enum):
NEW_CONSTRUCTION =1
RETROFIT = 2
MIXED =3
NEW_CONSTRUCTION =1
RETROFIT = 2
MIXED =3
23 changes: 23 additions & 0 deletions PHX/model/enums/phx_site.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
# -*- Python Version: 3.7 -*-

"""Valid 'types' for Site Settings."""

from enum import Enum

class SiteSelection(Enum):
WUFI_DATABASE = 1
USER_DEFINED = 2
STANDARD = 3

class SiteClimateSelection(Enum):
STANDARD = 1
WUFI_DATABASE = 2
USER_DEFINED = 6

class SiteEnergyFactorSelection(Enum):
STANDARD_USA = 1
STANDARD_GERMANY = 2
STANDARD_ITALY = 2
STANDARD_CANADA = 4
USER_DEFINED = 6
18 changes: 10 additions & 8 deletions PHX/model/phx_site.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# -*- coding: utf-8 -*-
# -*- Python Version: 3.7 -*-

"""PHX Location and Climate Dataclasses"""
"""PHX Site (Location and Climate) Dataclasses"""

from __future__ import annotations
from dataclasses import dataclass, field
from typing import Union, Optional

from PHX.model.enums.phx_site import SiteSelection, SiteClimateSelection, SiteEnergyFactorSelection


@dataclass
class PhxGround:
Expand All @@ -33,14 +35,14 @@ class PhxCO2Factor:
fuel_name: str = ''


PhxEnergyFactor = Union[PhxPEFactor, PhxCO2Factor]
PhxEnergyFactorAlias = Union[PhxPEFactor, PhxCO2Factor]


@dataclass
class PhxSiteEnergyFactors:
selection_pe_co2_factor: int = 6
pe_factors: dict[str, PhxEnergyFactor] = field(default_factory=dict)
co2_factors: dict[str, PhxEnergyFactor] = field(default_factory=dict)
selection_pe_co2_factor: SiteEnergyFactorSelection = SiteEnergyFactorSelection.USER_DEFINED
pe_factors: dict[str, PhxEnergyFactorAlias] = field(default_factory=dict)
co2_factors: dict[str, PhxEnergyFactorAlias] = field(default_factory=dict)

def __post_init__(self):
self.pe_factors = {
Expand All @@ -61,7 +63,7 @@ def __post_init__(self):
"OIL_CGS_35_CHP": PhxPEFactor(1.1, "kWh/kWh", "OIL_CGS_35_CHP"),
"OIL_CGS_0_CHP": PhxPEFactor(1.5, "kWh/kWh", "OIL_CGS_0_CHP"),
}
self.co2_factors: dict[str, PhxEnergyFactor] = {
self.co2_factors: dict[str, PhxEnergyFactorAlias] = {
"OIL": PhxCO2Factor(309.9966, "g/kWh", "OIL"),
"NATURAL_GAS": PhxCO2Factor(250.0171, "g/kWh", "NATURAL_GAS"),
"LPG": PhxCO2Factor(270.0102, "g/kWh", "LPG"),
Expand Down Expand Up @@ -105,7 +107,7 @@ class PhxClimatePeakLoad:
class PhxClimate:
"""Monthly Climate Date for the building location."""
station_elevation: float = 3.0
selection: int = 6
selection: SiteClimateSelection = SiteClimateSelection.USER_DEFINED
daily_temp_swing: float = 8.0
avg_wind_speed: float = 4.0

Expand Down Expand Up @@ -137,7 +139,7 @@ class PhxSite:
display_name: str = "New York"

source: str = "__unknown__"
selection: int = 1
selection: SiteSelection = SiteSelection.USER_DEFINED

location: PhxLocation = field(default_factory=PhxLocation)
climate: PhxClimate = field(default_factory=PhxClimate)
Expand Down
8 changes: 4 additions & 4 deletions PHX/to_WUFI_XML/xml_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ def _PhxFoundation(_f: ground.PhxFoundation) -> List[xml_writable]:

def _PH_ClimateLocation(_phx_site: phx_site.PhxSite) -> List[xml_writable]:

def _in_wufi_order(_factor_dict: dict) -> List[phx_site.PhxEnergyFactor]:
def _in_wufi_order(_factor_dict: dict) -> List[phx_site.PhxEnergyFactorAlias]:
"""Returns the PE /CO2 conversion factors in WUFI-specific order."""
fuel_order = ["OIL", "NATURAL_GAS", "LPG", "HARD_COAL", "WOOD", "ELECTRICITY_MIX",
"ELECTRICITY_PV", "HARD_COAL_CGS_70_CHP", "HARD_COAL_CGS_35_CHP",
Expand All @@ -267,7 +267,7 @@ def _in_wufi_order(_factor_dict: dict) -> List[phx_site.PhxEnergyFactor]:
return [_factor_dict[fuel_name] for fuel_name in fuel_order]

return [
XML_Node('Selection', _phx_site.selection),
XML_Node('Selection', _phx_site.climate.selection.value),
XML_Node('DailyTemperatureSwingSummer',
_phx_site.climate.daily_temp_swing),
XML_Node('AverageWindSpeed', _phx_site.climate.avg_wind_speed),
Expand Down Expand Up @@ -362,7 +362,7 @@ def _in_wufi_order(_factor_dict: dict) -> List[phx_site.PhxEnergyFactor]:
_phx_site.climate.peak_cooling_2.radiation_global),

XML_Node('SelectionPECO2Factor',
_phx_site.energy_factors.selection_pe_co2_factor),
_phx_site.energy_factors.selection_pe_co2_factor.value),
XML_List('PEFactorsUserDef', [XML_Node(f"PEF{i}", factor.value, "unit", factor.unit)
for i, factor in enumerate(_in_wufi_order(_phx_site.energy_factors.pe_factors))]),
XML_List('CO2FactorsUserDef', [XML_Node(f"CO2F{i}", factor.value, "unit", factor.unit)
Expand All @@ -372,7 +372,7 @@ def _in_wufi_order(_factor_dict: dict) -> List[phx_site.PhxEnergyFactor]:

def _PhxSite(_phx_site: phx_site.PhxSite) -> List[xml_writable]:
return [
XML_Node('Selection', _phx_site.selection),
XML_Node('Selection', _phx_site.selection.value),
# XML_Node('IDNr_DB', _climate.),
# XML_Node('Name_DB', _climate.),
# XML_Node('Comment_DB', _climate.),
Expand Down
3 changes: 1 addition & 2 deletions _testing_to_WUFI.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
"Default_Model_Single_Zone.hbjson",
"Multi_Room_Complete.hbjson",
]
SOURCE_FILES = [pathlib.Path(SOURCE_DIR, n) for n in source_file_names]
TARGET_DIR = pathlib.Path("tests", "_reference_xml")
SOURCE_DIR = pathlib.Path("sample", "hbjson")

def generate_xml_file(_source: pathlib.Path, _target_dir: pathlib.Path):
# -- Re-set all the PHX modules (counters)
Expand Down

0 comments on commit b0e6e37

Please sign in to comment.