forked from s_ranjbar/city_retrofit
added eilat usage to catalog and imports
This commit is contained in:
parent
f146cf3281
commit
5247eda305
|
@ -15,6 +15,7 @@ Output formats accepted:
|
||||||
* ca
|
* ca
|
||||||
* hft
|
* hft
|
||||||
* comnet
|
* comnet
|
||||||
|
* Eilat
|
||||||
|
|
||||||
Libs_functions:
|
Libs_functions:
|
||||||
* single family house
|
* single family house
|
||||||
|
|
|
@ -33,7 +33,6 @@ class ComnetCatalog(Catalog):
|
||||||
self._archetypes = self._read_archetype_file()
|
self._archetypes = self._read_archetype_file()
|
||||||
self._schedules = self._read_schedules_file()
|
self._schedules = self._read_schedules_file()
|
||||||
|
|
||||||
# todo: comment with @Guille, this hypotheses should go in the import factory?
|
|
||||||
sensible_convective = ch().comnet_occupancy_sensible_convective
|
sensible_convective = ch().comnet_occupancy_sensible_convective
|
||||||
sensible_radiative = ch().comnet_occupancy_sensible_radiant
|
sensible_radiative = ch().comnet_occupancy_sensible_radiant
|
||||||
lighting_convective = ch().comnet_lighting_convective
|
lighting_convective = ch().comnet_lighting_convective
|
||||||
|
|
234
hub/catalog_factories/usage/eilat_catalog.py
Normal file
234
hub/catalog_factories/usage/eilat_catalog.py
Normal file
|
@ -0,0 +1,234 @@
|
||||||
|
"""
|
||||||
|
Eilat usage catalog
|
||||||
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
||||||
|
Copyright © 2022 Concordia CERC group
|
||||||
|
Project Coder Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
|
||||||
|
"""
|
||||||
|
import io
|
||||||
|
from typing import Dict
|
||||||
|
|
||||||
|
import pandas as pd
|
||||||
|
|
||||||
|
import hub.helpers.constants as cte
|
||||||
|
from hub.catalog_factories.catalog import Catalog
|
||||||
|
from hub.catalog_factories.data_models.usages.appliances import Appliances
|
||||||
|
from hub.catalog_factories.data_models.usages.content import Content
|
||||||
|
from hub.catalog_factories.data_models.usages.lighting import Lighting
|
||||||
|
from hub.catalog_factories.data_models.usages.occupancy import Occupancy
|
||||||
|
from hub.catalog_factories.data_models.usages.domestic_hot_water import DomesticHotWater
|
||||||
|
from hub.catalog_factories.data_models.usages.schedule import Schedule
|
||||||
|
from hub.catalog_factories.data_models.usages.thermal_control import ThermalControl
|
||||||
|
from hub.catalog_factories.data_models.usages.usage import Usage
|
||||||
|
from hub.catalog_factories.usage.usage_helper import UsageHelper
|
||||||
|
from hub.helpers.configuration_helper import ConfigurationHelper as ch
|
||||||
|
|
||||||
|
|
||||||
|
class EilatCatalog(Catalog):
|
||||||
|
"""
|
||||||
|
Eilat catalog class
|
||||||
|
"""
|
||||||
|
def __init__(self, path):
|
||||||
|
self._eilat_archetypes_path = str(path / 'eilat_archetypes.xlsx')
|
||||||
|
self._eilat_schedules_path = str(path / 'eilat_schedules_archetypes.xlsx')
|
||||||
|
self._archetypes = self._read_archetype_file()
|
||||||
|
self._schedules = self._read_schedules_file()
|
||||||
|
|
||||||
|
sensible_convective = ch().comnet_occupancy_sensible_convective
|
||||||
|
sensible_radiative = ch().comnet_occupancy_sensible_radiant
|
||||||
|
lighting_convective = ch().comnet_lighting_convective
|
||||||
|
lighting_radiative = ch().comnet_lighting_radiant
|
||||||
|
lighting_latent = ch().comnet_lighting_latent
|
||||||
|
appliances_convective = ch().comnet_plugs_convective
|
||||||
|
appliances_radiative = ch().comnet_plugs_radiant
|
||||||
|
appliances_latent = ch().comnet_plugs_latent
|
||||||
|
|
||||||
|
usages = []
|
||||||
|
for schedule_key in self._archetypes['schedules_key']:
|
||||||
|
eilat_usage = schedule_key
|
||||||
|
schedule_name = self._archetypes['schedules_key'][schedule_key]
|
||||||
|
hours_day = None
|
||||||
|
days_year = None
|
||||||
|
occupancy_archetype = self._archetypes['occupancy'][eilat_usage]
|
||||||
|
lighting_archetype = self._archetypes['lighting'][eilat_usage]
|
||||||
|
appliances_archetype = self._archetypes['plug loads'][eilat_usage]
|
||||||
|
mechanical_air_change = None # eilat provides ventilation rate only
|
||||||
|
ventilation_rate = self._archetypes['ventilation rate'][eilat_usage]
|
||||||
|
# convert cfm/ft2 to m3/m2.s
|
||||||
|
ventilation_rate = ventilation_rate / (cte.METERS_TO_FEET * cte.MINUTES_TO_SECONDS)
|
||||||
|
domestic_hot_water_archetype = self._archetypes['water heating'][eilat_usage]
|
||||||
|
|
||||||
|
# get occupancy
|
||||||
|
occupancy_density = occupancy_archetype[0] / pow(cte.METERS_TO_FEET, 2)
|
||||||
|
sensible_heat_gain = occupancy_archetype[1] * cte.BTU_H_TO_WATTS
|
||||||
|
latent_heat_gain = occupancy_archetype[1] * cte.BTU_H_TO_WATTS
|
||||||
|
if occupancy_density != 0:
|
||||||
|
occupancy_density = 1 / occupancy_density
|
||||||
|
sensible_convective_internal_gain = occupancy_density * sensible_heat_gain * sensible_convective
|
||||||
|
sensible_radiative_internal_gain = occupancy_density * sensible_heat_gain * sensible_radiative
|
||||||
|
latent_internal_gain = occupancy_density * latent_heat_gain
|
||||||
|
occupancy = Occupancy(occupancy_density,
|
||||||
|
sensible_convective_internal_gain,
|
||||||
|
sensible_radiative_internal_gain,
|
||||||
|
latent_internal_gain,
|
||||||
|
self._schedules[schedule_name]['Occupancy'])
|
||||||
|
|
||||||
|
# get lighting
|
||||||
|
density = lighting_archetype[4] * pow(cte.METERS_TO_FEET, 2)
|
||||||
|
lighting = Lighting(density,
|
||||||
|
lighting_convective,
|
||||||
|
lighting_radiative,
|
||||||
|
lighting_latent,
|
||||||
|
self._schedules[schedule_name]['Lights'])
|
||||||
|
|
||||||
|
# get appliances
|
||||||
|
density = appliances_archetype[0]
|
||||||
|
if density == 'n.a.':
|
||||||
|
density = 0
|
||||||
|
# convert W/ft2 to W/m2
|
||||||
|
density = float(density) * pow(cte.METERS_TO_FEET, 2)
|
||||||
|
appliances = Appliances(density,
|
||||||
|
appliances_convective,
|
||||||
|
appliances_radiative,
|
||||||
|
appliances_latent,
|
||||||
|
self._schedules[schedule_name]['Receptacle'])
|
||||||
|
|
||||||
|
# get thermal control
|
||||||
|
thermal_control = ThermalControl(None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
self._schedules[schedule_name]['HVAC Avail'],
|
||||||
|
self._schedules[schedule_name]['HtgSetPt'],
|
||||||
|
self._schedules[schedule_name]['ClgSetPt']
|
||||||
|
)
|
||||||
|
|
||||||
|
# get domestic hot water
|
||||||
|
density = domestic_hot_water_archetype
|
||||||
|
# convert Btu/h/occ to W/m2
|
||||||
|
density = float(density) * cte.BTU_H_TO_WATTS * occupancy_density
|
||||||
|
domestic_hot_water_service_temperature = self._schedules[schedule_name]['WtrHtrSetPt'][0].values[0]
|
||||||
|
domestic_hot_water = DomesticHotWater(density,
|
||||||
|
None,
|
||||||
|
domestic_hot_water_service_temperature,
|
||||||
|
self._schedules[schedule_name]['Service Hot Water']
|
||||||
|
)
|
||||||
|
usages.append(Usage(eilat_usage,
|
||||||
|
hours_day,
|
||||||
|
days_year,
|
||||||
|
mechanical_air_change,
|
||||||
|
ventilation_rate,
|
||||||
|
occupancy,
|
||||||
|
lighting,
|
||||||
|
appliances,
|
||||||
|
thermal_control,
|
||||||
|
domestic_hot_water))
|
||||||
|
|
||||||
|
self._content = Content(usages)
|
||||||
|
|
||||||
|
def _read_schedules_file(self) -> Dict:
|
||||||
|
dictionary = {}
|
||||||
|
eilat_usages = UsageHelper().eilat_schedules_key_to_eilat_schedules
|
||||||
|
eilat_days = UsageHelper().comnet_days
|
||||||
|
eilat_data_types = UsageHelper().comnet_data_type_to_hub_data_type
|
||||||
|
for usage_name in eilat_usages:
|
||||||
|
with open(self._eilat_schedules_path, 'rb') as xls:
|
||||||
|
_extracted_data = pd.read_excel(
|
||||||
|
io.BytesIO(xls.read()),
|
||||||
|
sheet_name=eilat_usages[usage_name],
|
||||||
|
skiprows=[0, 1, 2, 3], nrows=39, usecols="A:AA"
|
||||||
|
)
|
||||||
|
_schedules = {}
|
||||||
|
for row in range(0, 39, 3):
|
||||||
|
_schedule_values = {}
|
||||||
|
schedule_name = _extracted_data.loc[row:row, 'Description'].item()
|
||||||
|
schedule_data_type = eilat_data_types[_extracted_data.loc[row:row, 'Type'].item()]
|
||||||
|
for day in eilat_days:
|
||||||
|
# Monday to Friday
|
||||||
|
start = row
|
||||||
|
end = row + 1
|
||||||
|
if day == cte.FRIDAY:
|
||||||
|
start = start + 1
|
||||||
|
end = end + 1
|
||||||
|
elif day in (cte.SATURDAY, cte.HOLIDAY):
|
||||||
|
start = start + 2
|
||||||
|
end = end + 2
|
||||||
|
_schedule_values[day] = _extracted_data.iloc[start:end, 3:27].to_numpy().tolist()[0]
|
||||||
|
_schedule = []
|
||||||
|
for day in _schedule_values:
|
||||||
|
if schedule_name in ('ClgSetPt', 'HtgSetPt', 'WtrHtrSetPt'):
|
||||||
|
# to celsius
|
||||||
|
if 'n.a.' in _schedule_values[day]:
|
||||||
|
_schedule_values[day] = None
|
||||||
|
else:
|
||||||
|
_schedule_values[day] = [(float(value)-32)*5/9 for value in _schedule_values[day]]
|
||||||
|
_schedule.append(Schedule(schedule_name, _schedule_values[day], schedule_data_type, cte.HOUR, cte.DAY, [day]))
|
||||||
|
_schedules[schedule_name] = _schedule
|
||||||
|
dictionary[usage_name] = _schedules
|
||||||
|
return dictionary
|
||||||
|
|
||||||
|
def _read_archetype_file(self) -> Dict:
|
||||||
|
"""
|
||||||
|
reads xlsx files containing usage information into a dictionary
|
||||||
|
:return : Dict
|
||||||
|
"""
|
||||||
|
number_usage_types = 3
|
||||||
|
with open(self._eilat_archetypes_path, 'rb') as xls:
|
||||||
|
_extracted_data = pd.read_excel(
|
||||||
|
io.BytesIO(xls.read()),
|
||||||
|
sheet_name="Modeling Data",
|
||||||
|
skiprows=[0, 1, 2],
|
||||||
|
nrows=number_usage_types + 1, usecols="A:AB"
|
||||||
|
)
|
||||||
|
|
||||||
|
lighting_data = {}
|
||||||
|
plug_loads_data = {}
|
||||||
|
occupancy_data = {}
|
||||||
|
ventilation_rate = {}
|
||||||
|
water_heating = {}
|
||||||
|
process_data = {}
|
||||||
|
schedules_key = {}
|
||||||
|
for j in range(0, number_usage_types):
|
||||||
|
usage_parameters = _extracted_data.iloc[j]
|
||||||
|
usage_type = usage_parameters[0]
|
||||||
|
lighting_data[usage_type] = usage_parameters[1:6].values.tolist()
|
||||||
|
plug_loads_data[usage_type] = usage_parameters[8:13].values.tolist()
|
||||||
|
occupancy_data[usage_type] = usage_parameters[17:20].values.tolist()
|
||||||
|
ventilation_rate[usage_type] = usage_parameters[20:21].item()
|
||||||
|
water_heating[usage_type] = usage_parameters[23:24].item()
|
||||||
|
process_data[usage_type] = usage_parameters[24:26].values.tolist()
|
||||||
|
schedules_key[usage_type] = usage_parameters[27:28].item()
|
||||||
|
|
||||||
|
return {'lighting': lighting_data,
|
||||||
|
'plug loads': plug_loads_data,
|
||||||
|
'occupancy': occupancy_data,
|
||||||
|
'ventilation rate': ventilation_rate,
|
||||||
|
'water heating': water_heating,
|
||||||
|
'process': process_data,
|
||||||
|
'schedules_key': schedules_key
|
||||||
|
}
|
||||||
|
|
||||||
|
def names(self, category=None):
|
||||||
|
"""
|
||||||
|
Get the catalog elements names
|
||||||
|
:parm: for usage catalog category filter does nothing as there is only one category (usages)
|
||||||
|
"""
|
||||||
|
_names = {'usages': []}
|
||||||
|
for usage in self._content.usages:
|
||||||
|
_names['usages'].append(usage.name)
|
||||||
|
return _names
|
||||||
|
|
||||||
|
def entries(self, category=None):
|
||||||
|
"""
|
||||||
|
Get the catalog elements
|
||||||
|
:parm: for usage catalog category filter does nothing as there is only one category (usages)
|
||||||
|
"""
|
||||||
|
return self._content
|
||||||
|
|
||||||
|
def get_entry(self, name):
|
||||||
|
"""
|
||||||
|
Get one catalog element by names
|
||||||
|
:parm: entry name
|
||||||
|
"""
|
||||||
|
for usage in self._content.usages:
|
||||||
|
if usage.name.lower() == name.lower():
|
||||||
|
return usage
|
||||||
|
raise IndexError(f"{name} doesn't exists in the catalog")
|
|
@ -90,6 +90,12 @@ class UsageHelper:
|
||||||
'C-14 Gymnasium': 'C-14 Gymnasium'
|
'C-14 Gymnasium': 'C-14 Gymnasium'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_eilat_schedules_key_to_eilat_schedules = {
|
||||||
|
'C-12 Residential': 'C-12 Residential',
|
||||||
|
'C-15 Dormitory': 'C-15 Dormitory',
|
||||||
|
'C-16 Hotel employees': 'C-16 Hotel employees'
|
||||||
|
}
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def nrcan_day_type_to_hub_days(self):
|
def nrcan_day_type_to_hub_days(self):
|
||||||
"""
|
"""
|
||||||
|
@ -138,3 +144,10 @@ class UsageHelper:
|
||||||
Get the list of days used in comnet
|
Get the list of days used in comnet
|
||||||
"""
|
"""
|
||||||
return self._comnet_days
|
return self._comnet_days
|
||||||
|
|
||||||
|
@property
|
||||||
|
def eilat_schedules_key_to_eilat_schedules(self) -> [str]:
|
||||||
|
"""
|
||||||
|
Get a dictionary to convert hub schedules to eilat schedules
|
||||||
|
"""
|
||||||
|
return self._eilat_schedules_key_to_eilat_schedules
|
||||||
|
|
|
@ -10,6 +10,7 @@ from typing import TypeVar
|
||||||
|
|
||||||
from hub.catalog_factories.usage.comnet_catalog import ComnetCatalog
|
from hub.catalog_factories.usage.comnet_catalog import ComnetCatalog
|
||||||
from hub.catalog_factories.usage.nrcan_catalog import NrcanCatalog
|
from hub.catalog_factories.usage.nrcan_catalog import NrcanCatalog
|
||||||
|
from hub.catalog_factories.usage.eilat_catalog import EilatCatalog
|
||||||
from hub.helpers.utils import validate_import_export_type
|
from hub.helpers.utils import validate_import_export_type
|
||||||
|
|
||||||
Catalog = TypeVar('Catalog')
|
Catalog = TypeVar('Catalog')
|
||||||
|
@ -41,6 +42,13 @@ class UsageCatalogFactory:
|
||||||
# nrcan retrieves the data directly from github
|
# nrcan retrieves the data directly from github
|
||||||
return NrcanCatalog(self._path)
|
return NrcanCatalog(self._path)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def _eilat(self):
|
||||||
|
"""
|
||||||
|
Retrieve Eilat catalog
|
||||||
|
"""
|
||||||
|
return EilatCatalog(self._path)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def catalog(self) -> Catalog:
|
def catalog(self) -> Catalog:
|
||||||
"""
|
"""
|
||||||
|
|
BIN
hub/data/usage/eilat_archetypes.xlsx
Normal file
BIN
hub/data/usage/eilat_archetypes.xlsx
Normal file
Binary file not shown.
BIN
hub/data/usage/eilat_schedules_archetypes.xlsx
Normal file
BIN
hub/data/usage/eilat_schedules_archetypes.xlsx
Normal file
Binary file not shown.
28
hub/helpers/data/eilat_function_to_hub_function.py
Normal file
28
hub/helpers/data/eilat_function_to_hub_function.py
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
"""
|
||||||
|
Dictionaries module for Eilat function to hub function
|
||||||
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
||||||
|
Copyright © 2023 Concordia CERC group
|
||||||
|
Project Coder Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
|
||||||
|
"""
|
||||||
|
|
||||||
|
import hub.helpers.constants as cte
|
||||||
|
|
||||||
|
|
||||||
|
class EilatFunctionToHubFunction:
|
||||||
|
"""
|
||||||
|
Eilat function to hub function class
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self._dictionary = {'Residential': cte.RESIDENTIAL,
|
||||||
|
'Dormitory': cte.DORMITORY,
|
||||||
|
'Hotel employ': cte.HOTEL
|
||||||
|
}
|
||||||
|
|
||||||
|
@property
|
||||||
|
def dictionary(self) -> dict:
|
||||||
|
"""
|
||||||
|
Get the dictionary
|
||||||
|
:return: {}
|
||||||
|
"""
|
||||||
|
return self._dictionary
|
29
hub/helpers/data/hub_usage_to_eilat_usage.py
Normal file
29
hub/helpers/data/hub_usage_to_eilat_usage.py
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
"""
|
||||||
|
Dictionaries module for hub usage to Eilat usage
|
||||||
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
||||||
|
Copyright © 2023 Concordia CERC group
|
||||||
|
Project Coder Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
|
||||||
|
"""
|
||||||
|
|
||||||
|
import hub.helpers.constants as cte
|
||||||
|
|
||||||
|
|
||||||
|
class HubUsageToEilatUsage:
|
||||||
|
"""
|
||||||
|
Hub usage to Eilat usage class
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self._dictionary = {
|
||||||
|
cte.RESIDENTIAL: 'Residential',
|
||||||
|
cte.HOTEL: 'Hotel employees',
|
||||||
|
cte.DORMITORY: 'Dormitory'
|
||||||
|
}
|
||||||
|
|
||||||
|
@property
|
||||||
|
def dictionary(self) -> dict:
|
||||||
|
"""
|
||||||
|
Get the dictionary
|
||||||
|
:return: {}
|
||||||
|
"""
|
||||||
|
return self._dictionary
|
|
@ -7,6 +7,7 @@ Project Coder Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
|
||||||
|
|
||||||
from hub.helpers.data.hft_function_to_hub_function import HftFunctionToHubFunction
|
from hub.helpers.data.hft_function_to_hub_function import HftFunctionToHubFunction
|
||||||
from hub.helpers.data.montreal_function_to_hub_function import MontrealFunctionToHubFunction
|
from hub.helpers.data.montreal_function_to_hub_function import MontrealFunctionToHubFunction
|
||||||
|
from hub.helpers.data.eilat_function_to_hub_function import EilatFunctionToHubFunction
|
||||||
from hub.helpers.data.alkis_function_to_hub_function import AlkisFunctionToHubFunction
|
from hub.helpers.data.alkis_function_to_hub_function import AlkisFunctionToHubFunction
|
||||||
from hub.helpers.data.pluto_function_to_hub_function import PlutoFunctionToHubFunction
|
from hub.helpers.data.pluto_function_to_hub_function import PlutoFunctionToHubFunction
|
||||||
from hub.helpers.data.hub_function_to_nrel_construction_function import HubFunctionToNrelConstructionFunction
|
from hub.helpers.data.hub_function_to_nrel_construction_function import HubFunctionToNrelConstructionFunction
|
||||||
|
@ -14,6 +15,7 @@ from hub.helpers.data.hub_function_to_nrcan_construction_function import HubFunc
|
||||||
from hub.helpers.data.hub_usage_to_comnet_usage import HubUsageToComnetUsage
|
from hub.helpers.data.hub_usage_to_comnet_usage import HubUsageToComnetUsage
|
||||||
from hub.helpers.data.hub_usage_to_hft_usage import HubUsageToHftUsage
|
from hub.helpers.data.hub_usage_to_hft_usage import HubUsageToHftUsage
|
||||||
from hub.helpers.data.hub_usage_to_nrcan_usage import HubUsageToNrcanUsage
|
from hub.helpers.data.hub_usage_to_nrcan_usage import HubUsageToNrcanUsage
|
||||||
|
from hub.helpers.data.hub_usage_to_eilat_usage import HubUsageToEilatUsage
|
||||||
from hub.helpers.data.montreal_system_to_hub_energy_generation_system import MontrealSystemToHubEnergyGenerationSystem
|
from hub.helpers.data.montreal_system_to_hub_energy_generation_system import MontrealSystemToHubEnergyGenerationSystem
|
||||||
from hub.helpers.data.montreal_demand_type_to_hub_energy_demand_type import MontrealDemandTypeToHubEnergyDemandType
|
from hub.helpers.data.montreal_demand_type_to_hub_energy_demand_type import MontrealDemandTypeToHubEnergyDemandType
|
||||||
from hub.helpers.data.hub_function_to_montreal_custom_costs_function import HubFunctionToMontrealCustomCostsFunction
|
from hub.helpers.data.hub_function_to_montreal_custom_costs_function import HubFunctionToMontrealCustomCostsFunction
|
||||||
|
@ -48,6 +50,14 @@ class Dictionaries:
|
||||||
"""
|
"""
|
||||||
return HubUsageToNrcanUsage().dictionary
|
return HubUsageToNrcanUsage().dictionary
|
||||||
|
|
||||||
|
@property
|
||||||
|
def hub_usage_to_eilat_usage(self) -> dict:
|
||||||
|
"""
|
||||||
|
Hub usage to Eilat usage, transformation dictionary
|
||||||
|
:return: dict
|
||||||
|
"""
|
||||||
|
return HubUsageToEilatUsage().dictionary
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def hub_function_to_nrcan_construction_function(self) -> dict:
|
def hub_function_to_nrcan_construction_function(self) -> dict:
|
||||||
"""
|
"""
|
||||||
|
@ -115,3 +125,10 @@ class Dictionaries:
|
||||||
:return: dict
|
:return: dict
|
||||||
"""
|
"""
|
||||||
return HubFunctionToMontrealCustomCostsFunction().dictionary
|
return HubFunctionToMontrealCustomCostsFunction().dictionary
|
||||||
|
|
||||||
|
@property
|
||||||
|
def eilat_function_to_hub_function(self) -> dict:
|
||||||
|
"""
|
||||||
|
Get Eilat's function to hub function, transformation dictionary
|
||||||
|
"""
|
||||||
|
return EilatFunctionToHubFunction().dictionary
|
||||||
|
|
232
hub/imports/usage/eilat_usage_parameters.py
Normal file
232
hub/imports/usage/eilat_usage_parameters.py
Normal file
|
@ -0,0 +1,232 @@
|
||||||
|
"""
|
||||||
|
EilatUsageParameters extracts the usage properties from Eilat catalog and assigns to each building
|
||||||
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
||||||
|
Copyright © 2023 Concordia CERC group
|
||||||
|
Project Coder Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
|
||||||
|
"""
|
||||||
|
import copy
|
||||||
|
import logging
|
||||||
|
import numpy
|
||||||
|
import hub.helpers.constants as cte
|
||||||
|
from hub.helpers.dictionaries import Dictionaries
|
||||||
|
from hub.city_model_structure.building_demand.usage import Usage
|
||||||
|
from hub.city_model_structure.building_demand.lighting import Lighting
|
||||||
|
from hub.city_model_structure.building_demand.occupancy import Occupancy
|
||||||
|
from hub.city_model_structure.building_demand.appliances import Appliances
|
||||||
|
from hub.city_model_structure.building_demand.thermal_control import ThermalControl
|
||||||
|
from hub.city_model_structure.building_demand.domestic_hot_water import DomesticHotWater
|
||||||
|
from hub.city_model_structure.attributes.schedule import Schedule
|
||||||
|
from hub.city_model_structure.building_demand.internal_gain import InternalGain
|
||||||
|
from hub.catalog_factories.usage_catalog_factory import UsageCatalogFactory
|
||||||
|
|
||||||
|
|
||||||
|
class EilatUsageParameters:
|
||||||
|
"""
|
||||||
|
EilatUsageParameters class
|
||||||
|
"""
|
||||||
|
def __init__(self, city):
|
||||||
|
self._city = city
|
||||||
|
|
||||||
|
def enrich_buildings(self):
|
||||||
|
"""
|
||||||
|
Returns the city with the usage parameters assigned to the buildings
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
city = self._city
|
||||||
|
eilat_catalog = UsageCatalogFactory('eilat').catalog
|
||||||
|
for building in city.buildings:
|
||||||
|
usage_name = Dictionaries().hub_usage_to_eilat_usage[building.function]
|
||||||
|
try:
|
||||||
|
archetype_usage = self._search_archetypes(eilat_catalog, usage_name)
|
||||||
|
except KeyError:
|
||||||
|
logging.error('Building %s has unknown usage archetype for usage %s', building.name, usage_name)
|
||||||
|
continue
|
||||||
|
|
||||||
|
for internal_zone in building.internal_zones:
|
||||||
|
if internal_zone.area is None:
|
||||||
|
raise TypeError('Internal zone area not defined, ACH cannot be calculated')
|
||||||
|
if internal_zone.volume is None:
|
||||||
|
raise TypeError('Internal zone volume not defined, ACH cannot be calculated')
|
||||||
|
if internal_zone.area <= 0:
|
||||||
|
raise TypeError('Internal zone area is zero, ACH cannot be calculated')
|
||||||
|
volume_per_area = internal_zone.volume / internal_zone.area
|
||||||
|
usage = Usage()
|
||||||
|
usage.name = usage_name
|
||||||
|
self._assign_values(usage, archetype_usage, volume_per_area, building.cold_water_temperature)
|
||||||
|
usage.percentage = 1
|
||||||
|
self._calculate_reduced_values_from_extended_library(usage, archetype_usage)
|
||||||
|
|
||||||
|
internal_zone.usages = [usage]
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _search_archetypes(eilat_catalog, usage_name):
|
||||||
|
eilat_archetypes = eilat_catalog.entries('archetypes').usages
|
||||||
|
for building_archetype in eilat_archetypes:
|
||||||
|
if str(usage_name) == str(building_archetype.name):
|
||||||
|
return building_archetype
|
||||||
|
raise KeyError('archetype not found')
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _assign_values(usage, archetype, volume_per_area, cold_water_temperature):
|
||||||
|
# Due to the fact that python is not a typed language, the wrong object type is assigned to
|
||||||
|
# usage.occupancy when writing usage.occupancy = archetype.occupancy.
|
||||||
|
# Same happens for lighting and appliances. Therefore, this walk around has been done.
|
||||||
|
usage.mechanical_air_change = archetype.ventilation_rate / volume_per_area \
|
||||||
|
* cte.HOUR_TO_SECONDS
|
||||||
|
_occupancy = Occupancy()
|
||||||
|
_occupancy.occupancy_density = archetype.occupancy.occupancy_density
|
||||||
|
_occupancy.sensible_radiative_internal_gain = archetype.occupancy.sensible_radiative_internal_gain
|
||||||
|
_occupancy.latent_internal_gain = archetype.occupancy.latent_internal_gain
|
||||||
|
_occupancy.sensible_convective_internal_gain = archetype.occupancy.sensible_convective_internal_gain
|
||||||
|
_occupancy.occupancy_schedules = archetype.occupancy.schedules
|
||||||
|
usage.occupancy = _occupancy
|
||||||
|
_lighting = Lighting()
|
||||||
|
_lighting.density = archetype.lighting.density
|
||||||
|
_lighting.convective_fraction = archetype.lighting.convective_fraction
|
||||||
|
_lighting.radiative_fraction = archetype.lighting.radiative_fraction
|
||||||
|
_lighting.latent_fraction = archetype.lighting.latent_fraction
|
||||||
|
_lighting.schedules = archetype.lighting.schedules
|
||||||
|
usage.lighting = _lighting
|
||||||
|
_appliances = Appliances()
|
||||||
|
_appliances.density = archetype.appliances.density
|
||||||
|
_appliances.convective_fraction = archetype.appliances.convective_fraction
|
||||||
|
_appliances.radiative_fraction = archetype.appliances.radiative_fraction
|
||||||
|
_appliances.latent_fraction = archetype.appliances.latent_fraction
|
||||||
|
_appliances.schedules = archetype.appliances.schedules
|
||||||
|
usage.appliances = _appliances
|
||||||
|
_control = ThermalControl()
|
||||||
|
_control.cooling_set_point_schedules = archetype.thermal_control.cooling_set_point_schedules
|
||||||
|
_control.heating_set_point_schedules = archetype.thermal_control.heating_set_point_schedules
|
||||||
|
_control.hvac_availability_schedules = archetype.thermal_control.hvac_availability_schedules
|
||||||
|
usage.thermal_control = _control
|
||||||
|
_domestic_hot_water = DomesticHotWater()
|
||||||
|
_domestic_hot_water.density = archetype.domestic_hot_water.density
|
||||||
|
_domestic_hot_water.service_temperature = archetype.domestic_hot_water.service_temperature
|
||||||
|
peak_flow = None
|
||||||
|
if len(cold_water_temperature) > 0:
|
||||||
|
cold_temperature = cold_water_temperature[cte.YEAR]['epw']
|
||||||
|
peak_flow = 0
|
||||||
|
if (archetype.domestic_hot_water.service_temperature - cold_temperature) > 0:
|
||||||
|
peak_flow = archetype.domestic_hot_water.density / cte.WATER_DENSITY / cte.WATER_HEAT_CAPACITY \
|
||||||
|
/ (archetype.domestic_hot_water.service_temperature - cold_temperature)
|
||||||
|
_domestic_hot_water.peak_flow = peak_flow
|
||||||
|
_domestic_hot_water.schedules = archetype.domestic_hot_water.schedules
|
||||||
|
usage.domestic_hot_water = _domestic_hot_water
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _calculate_reduced_values_from_extended_library(usage, archetype):
|
||||||
|
number_of_days_per_type = {'WD': 231, 'Fri': 52, 'Sat': 82}
|
||||||
|
total = 0
|
||||||
|
for schedule in archetype.thermal_control.hvac_availability_schedules:
|
||||||
|
if schedule.day_types[0] == cte.SATURDAY:
|
||||||
|
for value in schedule.values:
|
||||||
|
total += value * number_of_days_per_type['Fri']
|
||||||
|
elif schedule.day_types[0] == cte.SUNDAY:
|
||||||
|
for value in schedule.values:
|
||||||
|
total += value * number_of_days_per_type['Sat']
|
||||||
|
else:
|
||||||
|
for value in schedule.values:
|
||||||
|
total += value * number_of_days_per_type['WD']
|
||||||
|
|
||||||
|
usage.hours_day = total / 365
|
||||||
|
usage.days_year = 365
|
||||||
|
|
||||||
|
max_heating_setpoint = cte.MIN_FLOAT
|
||||||
|
min_heating_setpoint = cte.MAX_FLOAT
|
||||||
|
|
||||||
|
for schedule in archetype.thermal_control.heating_set_point_schedules:
|
||||||
|
if schedule.values is None:
|
||||||
|
max_heating_setpoint = None
|
||||||
|
min_heating_setpoint = None
|
||||||
|
break
|
||||||
|
if max(schedule.values) > max_heating_setpoint:
|
||||||
|
max_heating_setpoint = max(schedule.values)
|
||||||
|
if min(schedule.values) < min_heating_setpoint:
|
||||||
|
min_heating_setpoint = min(schedule.values)
|
||||||
|
|
||||||
|
min_cooling_setpoint = cte.MAX_FLOAT
|
||||||
|
for schedule in archetype.thermal_control.cooling_set_point_schedules:
|
||||||
|
if schedule.values is None:
|
||||||
|
min_cooling_setpoint = None
|
||||||
|
break
|
||||||
|
if min(schedule.values) < min_cooling_setpoint:
|
||||||
|
min_cooling_setpoint = min(schedule.values)
|
||||||
|
|
||||||
|
usage.thermal_control.mean_heating_set_point = max_heating_setpoint
|
||||||
|
usage.thermal_control.heating_set_back = min_heating_setpoint
|
||||||
|
usage.thermal_control.mean_cooling_set_point = min_cooling_setpoint
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _calculate_internal_gains(archetype):
|
||||||
|
|
||||||
|
_days = [cte.MONDAY, cte.TUESDAY, cte.WEDNESDAY, cte.THURSDAY, cte.FRIDAY, cte.SATURDAY, cte.SUNDAY, cte.HOLIDAY]
|
||||||
|
_number_of_days_per_type = [51, 50, 50, 50, 50, 52, 52, 10]
|
||||||
|
|
||||||
|
_mean_internal_gain = InternalGain()
|
||||||
|
_mean_internal_gain.type = 'mean_value_of_internal_gains'
|
||||||
|
_base_schedule = Schedule()
|
||||||
|
_base_schedule.type = cte.INTERNAL_GAINS
|
||||||
|
_base_schedule.time_range = cte.DAY
|
||||||
|
_base_schedule.time_step = cte.HOUR
|
||||||
|
_base_schedule.data_type = cte.FRACTION
|
||||||
|
|
||||||
|
_latent_heat_gain = archetype.occupancy.latent_internal_gain
|
||||||
|
_convective_heat_gain = archetype.occupancy.sensible_convective_internal_gain
|
||||||
|
_radiative_heat_gain = archetype.occupancy.sensible_radiative_internal_gain
|
||||||
|
_total_heat_gain = _latent_heat_gain + _convective_heat_gain + _radiative_heat_gain
|
||||||
|
|
||||||
|
_schedule_values = numpy.zeros([24, 8])
|
||||||
|
_sum = 0
|
||||||
|
for day, _schedule in enumerate(archetype.occupancy.schedules):
|
||||||
|
for v_index, value in enumerate(_schedule.values):
|
||||||
|
_schedule_values[v_index, day] = value * _total_heat_gain
|
||||||
|
_sum += value * _total_heat_gain * _number_of_days_per_type[day]
|
||||||
|
|
||||||
|
_total_heat_gain += archetype.lighting.density + archetype.appliances.density
|
||||||
|
_latent_heat_gain += (
|
||||||
|
archetype.lighting.latent_fraction * archetype.lighting.density + archetype.appliances.latent_fraction *
|
||||||
|
archetype.appliances.density
|
||||||
|
)
|
||||||
|
_radiative_heat_gain = (
|
||||||
|
archetype.lighting.radiative_fraction * archetype.lighting.density + archetype.appliances.radiative_fraction *
|
||||||
|
archetype.appliances.density
|
||||||
|
)
|
||||||
|
_convective_heat_gain = (
|
||||||
|
archetype.lighting.convective_fraction * archetype.lighting.density + archetype.appliances.convective_fraction *
|
||||||
|
archetype.appliances.density
|
||||||
|
)
|
||||||
|
|
||||||
|
for day, _schedule in enumerate(archetype.lighting.schedules):
|
||||||
|
for v_index, value in enumerate(_schedule.values):
|
||||||
|
_schedule_values[v_index, day] += value * archetype.lighting.density
|
||||||
|
_sum += value * archetype.lighting.density * _number_of_days_per_type[day]
|
||||||
|
|
||||||
|
for day, _schedule in enumerate(archetype.appliances.schedules):
|
||||||
|
for v_index, value in enumerate(_schedule.values):
|
||||||
|
_schedule_values[v_index, day] += value * archetype.appliances.density
|
||||||
|
_sum += value * archetype.appliances.density * _number_of_days_per_type[day]
|
||||||
|
|
||||||
|
_latent_fraction = 0
|
||||||
|
_radiative_fraction = 0
|
||||||
|
_convective_fraction = 0
|
||||||
|
_average_internal_gain = 0
|
||||||
|
if _total_heat_gain != 0:
|
||||||
|
_latent_fraction = _latent_heat_gain / _total_heat_gain
|
||||||
|
_radiative_fraction = _radiative_heat_gain / _total_heat_gain
|
||||||
|
_convective_fraction = _convective_heat_gain / _total_heat_gain
|
||||||
|
_average_internal_gain = _sum / _total_heat_gain
|
||||||
|
|
||||||
|
_schedules = []
|
||||||
|
for day, current_day in enumerate(_days):
|
||||||
|
_schedule = copy.deepcopy(_base_schedule)
|
||||||
|
_schedule.day_types = [current_day]
|
||||||
|
_schedule.values = _schedule_values[:day]
|
||||||
|
_schedules.append(_schedule)
|
||||||
|
|
||||||
|
_mean_internal_gain.average_internal_gain = _average_internal_gain
|
||||||
|
_mean_internal_gain.latent_fraction = _latent_fraction
|
||||||
|
_mean_internal_gain.convective_fraction = _convective_fraction
|
||||||
|
_mean_internal_gain.radiative_fraction = _radiative_fraction
|
||||||
|
_mean_internal_gain.schedules = _schedules
|
||||||
|
|
||||||
|
return [_mean_internal_gain]
|
|
@ -9,6 +9,7 @@ Code contributors: Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concord
|
||||||
from hub.helpers.utils import validate_import_export_type
|
from hub.helpers.utils import validate_import_export_type
|
||||||
from hub.imports.usage.comnet_usage_parameters import ComnetUsageParameters
|
from hub.imports.usage.comnet_usage_parameters import ComnetUsageParameters
|
||||||
from hub.imports.usage.nrcan_usage_parameters import NrcanUsageParameters
|
from hub.imports.usage.nrcan_usage_parameters import NrcanUsageParameters
|
||||||
|
from hub.imports.usage.eilat_usage_parameters import EilatUsageParameters
|
||||||
|
|
||||||
|
|
||||||
class UsageFactory:
|
class UsageFactory:
|
||||||
|
@ -38,9 +39,20 @@ class UsageFactory:
|
||||||
for building in self._city.buildings:
|
for building in self._city.buildings:
|
||||||
building.level_of_detail.usage = 2
|
building.level_of_detail.usage = 2
|
||||||
|
|
||||||
|
def _eilat(self):
|
||||||
|
"""
|
||||||
|
Enrich the city with Eilat usage library
|
||||||
|
"""
|
||||||
|
EilatUsageParameters(self._city).enrich_buildings()
|
||||||
|
self._city.level_of_detail.usage = 2
|
||||||
|
for building in self._city.buildings:
|
||||||
|
building.level_of_detail.usage = 2
|
||||||
|
|
||||||
def enrich(self):
|
def enrich(self):
|
||||||
"""
|
"""
|
||||||
Enrich the city given to the class using the usage factory given handler
|
Enrich the city given to the class using the usage factory given handler
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
getattr(self, self._handler, lambda: None)()
|
getattr(self, self._handler, lambda: None)()
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user