forked from s_ranjbar/city_retrofit
add_cerc catalogs
This commit is contained in:
parent
0fcc9a2a5f
commit
292da03940
3
.gitignore
vendored
3
.gitignore
vendored
@ -11,4 +11,5 @@
|
||||
**/.idea/
|
||||
cerc_hub.egg-info
|
||||
/out_files
|
||||
/input_files
|
||||
/input_files
|
||||
/CitRetrofitEnv
|
||||
|
@ -6,9 +6,11 @@ Output formats accepted:
|
||||
* Function:
|
||||
* nrel
|
||||
* nrcan
|
||||
* cerc
|
||||
* eilat
|
||||
* Usage:
|
||||
* nrcan
|
||||
* cerc
|
||||
* comnet
|
||||
* eilat
|
||||
|
||||
|
238
hub/catalog_factories/construction/cerc_catalog.py
Normal file
238
hub/catalog_factories/construction/cerc_catalog.py
Normal file
@ -0,0 +1,238 @@
|
||||
"""
|
||||
Cerc construction catalog (Copy of Nrcan 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 json
|
||||
from pathlib import Path
|
||||
from hub.catalog_factories.catalog import Catalog
|
||||
from hub.catalog_factories.data_models.construction.content import Content
|
||||
from hub.catalog_factories.construction.construction_helper import ConstructionHelper
|
||||
from hub.catalog_factories.data_models.construction.construction import Construction
|
||||
from hub.catalog_factories.data_models.construction.archetype import Archetype
|
||||
from hub.catalog_factories.data_models.construction.window import Window
|
||||
from hub.catalog_factories.data_models.construction.material import Material
|
||||
from hub.catalog_factories.data_models.construction.layer import Layer
|
||||
import hub.helpers.constants as cte
|
||||
|
||||
|
||||
class CercCatalog(Catalog):
|
||||
"""
|
||||
Cerc catalog class copy of Cerc catalog (Copy of Nrcan catalog)
|
||||
"""
|
||||
def __init__(self, path):
|
||||
_path_archetypes = Path(path / 'cerc_archetypes.json').resolve()
|
||||
_path_constructions = (path / 'cerc_constructions.json').resolve()
|
||||
with open(_path_archetypes, 'r', encoding='utf-8') as file:
|
||||
self._archetypes = json.load(file)
|
||||
with open(_path_constructions, 'r', encoding='utf-8') as file:
|
||||
self._constructions = json.load(file)
|
||||
|
||||
self._catalog_windows = self._load_windows()
|
||||
self._catalog_materials = self._load_materials()
|
||||
self._catalog_constructions = self._load_constructions()
|
||||
self._catalog_archetypes = self._load_archetypes()
|
||||
|
||||
# store the full catalog data model in self._content
|
||||
self._content = Content(self._catalog_archetypes,
|
||||
self._catalog_constructions,
|
||||
self._catalog_materials,
|
||||
self._catalog_windows)
|
||||
|
||||
def _load_windows(self):
|
||||
_catalog_windows = []
|
||||
windows = self._constructions['transparent_surfaces']
|
||||
for window in windows:
|
||||
name = list(window.keys())[0]
|
||||
window_id = name
|
||||
g_value = window[name]['shgc']
|
||||
window_type = window[name]['type']
|
||||
frame_ratio = window[name]['frame_ratio']
|
||||
overall_u_value = window[name]['u_value']
|
||||
_catalog_windows.append(Window(window_id, frame_ratio, g_value, overall_u_value, name, window_type))
|
||||
return _catalog_windows
|
||||
|
||||
def _load_materials(self):
|
||||
_catalog_materials = []
|
||||
materials = self._constructions['materials']
|
||||
for material in materials:
|
||||
name = list(material.keys())[0]
|
||||
material_id = name
|
||||
no_mass = material[name]['no_mass']
|
||||
thermal_resistance = None
|
||||
conductivity = None
|
||||
density = None
|
||||
specific_heat = None
|
||||
solar_absorptance = None
|
||||
thermal_absorptance = None
|
||||
visible_absorptance = None
|
||||
if no_mass:
|
||||
thermal_resistance = material[name]['thermal_resistance']
|
||||
else:
|
||||
solar_absorptance = material[name]['solar_absorptance']
|
||||
thermal_absorptance = str(1 - float(material[name]['thermal_emittance']))
|
||||
visible_absorptance = material[name]['visible_absorptance']
|
||||
conductivity = material[name]['conductivity']
|
||||
density = material[name]['density']
|
||||
specific_heat = material[name]['specific_heat']
|
||||
_material = Material(material_id,
|
||||
name,
|
||||
solar_absorptance,
|
||||
thermal_absorptance,
|
||||
visible_absorptance,
|
||||
no_mass,
|
||||
thermal_resistance,
|
||||
conductivity,
|
||||
density,
|
||||
specific_heat)
|
||||
_catalog_materials.append(_material)
|
||||
return _catalog_materials
|
||||
|
||||
def _load_constructions(self):
|
||||
_catalog_constructions = []
|
||||
constructions = self._constructions['opaque_surfaces']
|
||||
for construction in constructions:
|
||||
name = list(construction.keys())[0]
|
||||
construction_id = name
|
||||
construction_type = ConstructionHelper().nrcan_surfaces_types_to_hub_types[construction[name]['type']]
|
||||
layers = []
|
||||
for layer in construction[name]['layers']:
|
||||
layer_id = layer
|
||||
layer_name = layer
|
||||
material_id = layer
|
||||
thickness = construction[name]['layers'][layer]
|
||||
for material in self._catalog_materials:
|
||||
if str(material_id) == str(material.id):
|
||||
layers.append(Layer(layer_id, layer_name, material, thickness))
|
||||
break
|
||||
_catalog_constructions.append(Construction(construction_id, construction_type, name, layers))
|
||||
return _catalog_constructions
|
||||
|
||||
def _load_archetypes(self):
|
||||
_catalog_archetypes = []
|
||||
archetypes = self._archetypes['archetypes']
|
||||
for archetype in archetypes:
|
||||
archetype_id = f'{archetype["function"]}_{archetype["period_of_construction"]}_{archetype["climate_zone"]}'
|
||||
function = archetype['function']
|
||||
name = archetype_id
|
||||
climate_zone = archetype['climate_zone']
|
||||
construction_period = archetype['period_of_construction']
|
||||
average_storey_height = archetype['average_storey_height']
|
||||
thermal_capacity = float(archetype['thermal_capacity']) * 1000
|
||||
extra_loses_due_to_thermal_bridges = archetype['extra_loses_due_thermal_bridges']
|
||||
infiltration_rate_for_ventilation_system_off = (
|
||||
archetype['infiltration_rate_for_ventilation_system_off'] / cte.HOUR_TO_SECONDS
|
||||
)
|
||||
infiltration_rate_for_ventilation_system_on = (
|
||||
archetype['infiltration_rate_for_ventilation_system_on'] / cte.HOUR_TO_SECONDS
|
||||
)
|
||||
|
||||
archetype_constructions = []
|
||||
for archetype_construction in archetype['constructions']:
|
||||
archetype_construction_type = ConstructionHelper().nrcan_surfaces_types_to_hub_types[archetype_construction]
|
||||
archetype_construction_name = archetype['constructions'][archetype_construction]['opaque_surface_name']
|
||||
for construction in self._catalog_constructions:
|
||||
if archetype_construction_type == construction.type and construction.name == archetype_construction_name:
|
||||
_construction = None
|
||||
_window = None
|
||||
_window_ratio = None
|
||||
if 'transparent_surface_name' in archetype['constructions'][archetype_construction].keys():
|
||||
_window_ratio = archetype['constructions'][archetype_construction]['transparent_ratio']
|
||||
_window_id = archetype['constructions'][archetype_construction]['transparent_surface_name']
|
||||
for window in self._catalog_windows:
|
||||
if _window_id == window.id:
|
||||
_window = window
|
||||
break
|
||||
_construction = Construction(construction.id,
|
||||
construction.type,
|
||||
construction.name,
|
||||
construction.layers,
|
||||
_window_ratio,
|
||||
_window)
|
||||
archetype_constructions.append(_construction)
|
||||
break
|
||||
|
||||
_catalog_archetypes.append(Archetype(archetype_id,
|
||||
name,
|
||||
function,
|
||||
climate_zone,
|
||||
construction_period,
|
||||
archetype_constructions,
|
||||
average_storey_height,
|
||||
thermal_capacity,
|
||||
extra_loses_due_to_thermal_bridges,
|
||||
None,
|
||||
infiltration_rate_for_ventilation_system_off,
|
||||
infiltration_rate_for_ventilation_system_on))
|
||||
return _catalog_archetypes
|
||||
|
||||
def names(self, category=None):
|
||||
"""
|
||||
Get the catalog elements names
|
||||
:parm: optional category filter
|
||||
"""
|
||||
if category is None:
|
||||
_names = {'archetypes': [], 'constructions': [], 'materials': [], 'windows': []}
|
||||
for archetype in self._content.archetypes:
|
||||
_names['archetypes'].append(archetype.name)
|
||||
for construction in self._content.constructions:
|
||||
_names['constructions'].append(construction.name)
|
||||
for material in self._content.materials:
|
||||
_names['materials'].append(material.name)
|
||||
for window in self._content.windows:
|
||||
_names['windows'].append(window.name)
|
||||
else:
|
||||
_names = {category: []}
|
||||
if category.lower() == 'archetypes':
|
||||
for archetype in self._content.archetypes:
|
||||
_names[category].append(archetype.name)
|
||||
elif category.lower() == 'constructions':
|
||||
for construction in self._content.constructions:
|
||||
_names[category].append(construction.name)
|
||||
elif category.lower() == 'materials':
|
||||
for material in self._content.materials:
|
||||
_names[category].append(material.name)
|
||||
elif category.lower() == 'windows':
|
||||
for window in self._content.windows:
|
||||
_names[category].append(window.name)
|
||||
else:
|
||||
raise ValueError(f'Unknown category [{category}]')
|
||||
return _names
|
||||
|
||||
def entries(self, category=None):
|
||||
"""
|
||||
Get the catalog elements
|
||||
:parm: optional category filter
|
||||
"""
|
||||
if category is None:
|
||||
return self._content
|
||||
if category.lower() == 'archetypes':
|
||||
return self._content.archetypes
|
||||
if category.lower() == 'constructions':
|
||||
return self._content.constructions
|
||||
if category.lower() == 'materials':
|
||||
return self._content.materials
|
||||
if category.lower() == 'windows':
|
||||
return self._content.windows
|
||||
raise ValueError(f'Unknown category [{category}]')
|
||||
|
||||
def get_entry(self, name):
|
||||
"""
|
||||
Get one catalog element by names
|
||||
:parm: entry name
|
||||
"""
|
||||
for entry in self._content.archetypes:
|
||||
if entry.name.lower() == name.lower():
|
||||
return entry
|
||||
for entry in self._content.constructions:
|
||||
if entry.name.lower() == name.lower():
|
||||
return entry
|
||||
for entry in self._content.materials:
|
||||
if entry.name.lower() == name.lower():
|
||||
return entry
|
||||
for entry in self._content.windows:
|
||||
if entry.name.lower() == name.lower():
|
||||
return entry
|
||||
raise IndexError(f"{name} doesn't exists in the catalog")
|
@ -9,6 +9,8 @@ from pathlib import Path
|
||||
from typing import TypeVar
|
||||
|
||||
from hub.catalog_factories.construction.nrcan_catalog import NrcanCatalog
|
||||
from hub.catalog_factories.construction.cerc_catalog import CercCatalog
|
||||
|
||||
from hub.catalog_factories.construction.nrel_catalog import NrelCatalog
|
||||
from hub.catalog_factories.construction.eilat_catalog import EilatCatalog
|
||||
from hub.helpers.utils import validate_import_export_type
|
||||
@ -40,6 +42,13 @@ class ConstructionCatalogFactory:
|
||||
Retrieve NRCAN catalog
|
||||
"""
|
||||
return NrcanCatalog(self._path)
|
||||
|
||||
@property
|
||||
def _cerc(self):
|
||||
"""
|
||||
Retrieve CERC catalog
|
||||
"""
|
||||
return CercCatalog(self._path)
|
||||
|
||||
@property
|
||||
def _eilat(self):
|
||||
|
220
hub/catalog_factories/usage/cerc_catalog.py
Normal file
220
hub/catalog_factories/usage/cerc_catalog.py
Normal file
@ -0,0 +1,220 @@
|
||||
"""
|
||||
NRCAN usage catalog
|
||||
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
||||
Copyright © 2022 Concordia CERC group
|
||||
Project Coder Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
|
||||
Code contributors: Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
|
||||
"""
|
||||
|
||||
import json
|
||||
import urllib.request
|
||||
from pathlib import Path
|
||||
|
||||
import xmltodict
|
||||
|
||||
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
|
||||
|
||||
|
||||
class CercCatalog(Catalog):
|
||||
"""
|
||||
Cerc catalog class (copy of NrcanCatalog)
|
||||
"""
|
||||
def __init__(self, path):
|
||||
self._schedules_path = Path(path / 'nrcan_schedules.json').resolve()
|
||||
self._space_types_path = Path(path / 'nrcan_space_types.json').resolve()
|
||||
self._space_compliance_path = Path(path / 'nrcan_space_compliance_2015.json').resolve()
|
||||
self._content = None
|
||||
self._schedules = {}
|
||||
self._load_schedules()
|
||||
self._content = Content(self._load_archetypes())
|
||||
|
||||
@staticmethod
|
||||
def _extract_schedule(raw):
|
||||
nrcan_schedule_type = raw['category']
|
||||
if 'Heating' in raw['name'] and 'Water' not in raw['name']:
|
||||
nrcan_schedule_type = f'{nrcan_schedule_type} Heating'
|
||||
elif 'Cooling' in raw['name']:
|
||||
nrcan_schedule_type = f'{nrcan_schedule_type} Cooling'
|
||||
if nrcan_schedule_type not in UsageHelper().nrcan_schedule_type_to_hub_schedule_type:
|
||||
return None
|
||||
hub_type = UsageHelper().nrcan_schedule_type_to_hub_schedule_type[nrcan_schedule_type]
|
||||
data_type = UsageHelper().nrcan_data_type_to_hub_data_type[raw['units']]
|
||||
time_step = UsageHelper().nrcan_time_to_hub_time[raw['type']]
|
||||
# nrcan only uses daily range for the schedules
|
||||
time_range = cte.DAY
|
||||
day_types = UsageHelper().nrcan_day_type_to_hub_days[raw['day_types']]
|
||||
return Schedule(hub_type, raw['values'], data_type, time_step, time_range, day_types)
|
||||
|
||||
def _load_schedules(self):
|
||||
_schedule_types = []
|
||||
with open(self._schedules_path, 'r') as f:
|
||||
schedules_type = json.load(f)
|
||||
for schedule_type in schedules_type['tables']['schedules']['table']:
|
||||
schedule = CercCatalog._extract_schedule(schedule_type)
|
||||
if schedule_type['name'] not in _schedule_types:
|
||||
_schedule_types.append(schedule_type['name'])
|
||||
if schedule is not None:
|
||||
self._schedules[schedule_type['name']] = [schedule]
|
||||
else:
|
||||
if schedule is not None:
|
||||
_schedules = self._schedules[schedule_type['name']]
|
||||
_schedules.append(schedule)
|
||||
self._schedules[schedule_type['name']] = _schedules
|
||||
|
||||
def _get_schedules(self, name):
|
||||
schedule = None
|
||||
if name in self._schedules:
|
||||
schedule = self._schedules[name]
|
||||
return schedule
|
||||
|
||||
def _load_archetypes(self):
|
||||
usages = []
|
||||
with open(self._space_types_path, 'r') as f:
|
||||
space_types = json.load(f)['tables']['space_types']['table']
|
||||
space_types = [st for st in space_types if st['space_type'] == 'WholeBuilding']
|
||||
with open(self._space_compliance_path, 'r') as f:
|
||||
space_types_compliance = json.load(f)['tables']['space_compliance']['table']
|
||||
space_types_compliance = [st for st in space_types_compliance if st['space_type'] == 'WholeBuilding']
|
||||
space_types_dictionary = {}
|
||||
for space_type in space_types_compliance:
|
||||
usage_type = space_type['building_type']
|
||||
# people/m2
|
||||
occupancy_density = space_type['occupancy_per_area_people_per_m2']
|
||||
# W/m2
|
||||
lighting_density = space_type['lighting_per_area_w_per_m2']
|
||||
# W/m2
|
||||
appliances_density = space_type['electric_equipment_per_area_w_per_m2']
|
||||
# peak flow in gallons/h/m2
|
||||
domestic_hot_water_peak_flow = (
|
||||
space_type['service_water_heating_peak_flow_per_area'] *
|
||||
cte.GALLONS_TO_QUBIC_METERS / cte.HOUR_TO_SECONDS
|
||||
)
|
||||
space_types_dictionary[usage_type] = {'occupancy_per_area': occupancy_density,
|
||||
'lighting_per_area': lighting_density,
|
||||
'electric_equipment_per_area': appliances_density,
|
||||
'service_water_heating_peak_flow_per_area': domestic_hot_water_peak_flow
|
||||
}
|
||||
|
||||
for space_type in space_types:
|
||||
usage_type = space_type['building_type']
|
||||
space_type_compliance = space_types_dictionary[usage_type]
|
||||
occupancy_density = space_type_compliance['occupancy_per_area']
|
||||
lighting_density = space_type_compliance['lighting_per_area']
|
||||
appliances_density = space_type_compliance['electric_equipment_per_area']
|
||||
domestic_hot_water_peak_flow = space_type_compliance['service_water_heating_peak_flow_per_area']
|
||||
|
||||
occupancy_schedule_name = space_type['occupancy_schedule']
|
||||
lighting_schedule_name = space_type['lighting_schedule']
|
||||
appliance_schedule_name = space_type['electric_equipment_schedule']
|
||||
hvac_schedule_name = space_type['exhaust_schedule']
|
||||
if 'FAN' in hvac_schedule_name:
|
||||
hvac_schedule_name = hvac_schedule_name.replace('FAN', 'Fan')
|
||||
heating_setpoint_schedule_name = space_type['heating_setpoint_schedule']
|
||||
cooling_setpoint_schedule_name = space_type['cooling_setpoint_schedule']
|
||||
domestic_hot_water_schedule_name = space_type['service_water_heating_schedule']
|
||||
occupancy_schedule = self._get_schedules(occupancy_schedule_name)
|
||||
lighting_schedule = self._get_schedules(lighting_schedule_name)
|
||||
appliance_schedule = self._get_schedules(appliance_schedule_name)
|
||||
heating_schedule = self._get_schedules(heating_setpoint_schedule_name)
|
||||
cooling_schedule = self._get_schedules(cooling_setpoint_schedule_name)
|
||||
hvac_availability = self._get_schedules(hvac_schedule_name)
|
||||
domestic_hot_water_load_schedule = self._get_schedules(domestic_hot_water_schedule_name)
|
||||
|
||||
# ACH -> 1/s
|
||||
mechanical_air_change = space_type['ventilation_air_changes'] / cte.HOUR_TO_SECONDS
|
||||
# cfm/ft2 to m3/m2.s
|
||||
ventilation_rate = space_type['ventilation_per_area'] / (cte.METERS_TO_FEET * cte.MINUTES_TO_SECONDS)
|
||||
# cfm/person to m3/m2.s
|
||||
ventilation_rate += space_type['ventilation_per_person'] / (
|
||||
pow(cte.METERS_TO_FEET, 3) * cte.MINUTES_TO_SECONDS
|
||||
) * occupancy_density
|
||||
|
||||
lighting_radiative_fraction = space_type['lighting_fraction_radiant']
|
||||
lighting_convective_fraction = 0
|
||||
if lighting_radiative_fraction is not None:
|
||||
lighting_convective_fraction = 1 - lighting_radiative_fraction
|
||||
lighting_latent_fraction = 0
|
||||
appliances_radiative_fraction = space_type['electric_equipment_fraction_radiant']
|
||||
appliances_latent_fraction = space_type['electric_equipment_fraction_latent']
|
||||
appliances_convective_fraction = 0
|
||||
if appliances_radiative_fraction is not None and appliances_latent_fraction is not None:
|
||||
appliances_convective_fraction = 1 - appliances_radiative_fraction - appliances_latent_fraction
|
||||
|
||||
domestic_hot_water_service_temperature = space_type['service_water_heating_target_temperature']
|
||||
|
||||
occupancy = Occupancy(occupancy_density,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
occupancy_schedule)
|
||||
lighting = Lighting(lighting_density,
|
||||
lighting_convective_fraction,
|
||||
lighting_radiative_fraction,
|
||||
lighting_latent_fraction,
|
||||
lighting_schedule)
|
||||
appliances = Appliances(appliances_density,
|
||||
appliances_convective_fraction,
|
||||
appliances_radiative_fraction,
|
||||
appliances_latent_fraction,
|
||||
appliance_schedule)
|
||||
thermal_control = ThermalControl(None,
|
||||
None,
|
||||
None,
|
||||
hvac_availability,
|
||||
heating_schedule,
|
||||
cooling_schedule)
|
||||
domestic_hot_water = DomesticHotWater(None,
|
||||
domestic_hot_water_peak_flow,
|
||||
domestic_hot_water_service_temperature,
|
||||
domestic_hot_water_load_schedule)
|
||||
|
||||
hours_day = None
|
||||
days_year = None
|
||||
usages.append(Usage(usage_type,
|
||||
hours_day,
|
||||
days_year,
|
||||
mechanical_air_change,
|
||||
ventilation_rate,
|
||||
occupancy,
|
||||
lighting,
|
||||
appliances,
|
||||
thermal_control,
|
||||
domestic_hot_water))
|
||||
return usages
|
||||
|
||||
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")
|
@ -10,6 +10,7 @@ from typing import TypeVar
|
||||
|
||||
from hub.catalog_factories.usage.comnet_catalog import ComnetCatalog
|
||||
from hub.catalog_factories.usage.nrcan_catalog import NrcanCatalog
|
||||
from hub.catalog_factories.usage.cerc_catalog import CercCatalog
|
||||
from hub.catalog_factories.usage.eilat_catalog import EilatCatalog
|
||||
from hub.helpers.utils import validate_import_export_type
|
||||
|
||||
@ -41,7 +42,15 @@ class UsageCatalogFactory:
|
||||
"""
|
||||
# nrcan retrieves the data directly from github
|
||||
return NrcanCatalog(self._path)
|
||||
|
||||
|
||||
@property
|
||||
def _cerc(self):
|
||||
"""
|
||||
Retrieve cerc catalog
|
||||
"""
|
||||
# nrcan retrieves the data directly from github
|
||||
return CercCatalog(self._path)
|
||||
|
||||
@property
|
||||
def _eilat(self):
|
||||
"""
|
||||
|
63817
hub/data/construction/CERC_archetypes.json
Normal file
63817
hub/data/construction/CERC_archetypes.json
Normal file
File diff suppressed because it is too large
Load Diff
12633
hub/data/construction/CERC_constructions.json
Normal file
12633
hub/data/construction/CERC_constructions.json
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,86 @@
|
||||
"""
|
||||
Dictionaries module for hub function to nrcan construction function
|
||||
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
||||
Copyright © 2022 Concordia CERC group
|
||||
Project Coder Guille Gutierrez Guillermo.GutierrezMorote@concordia.ca
|
||||
"""
|
||||
|
||||
import hub.helpers.constants as cte
|
||||
|
||||
|
||||
class HubFunctionToCercConstructionFunction:
|
||||
"""
|
||||
Hub function to cerc construction function class (copy of HubFunctionToNrcanConstructionFunction)
|
||||
"""
|
||||
def __init__(self):
|
||||
self._dictionary = {
|
||||
cte.RESIDENTIAL: 'MURB_MidRiseApartment',
|
||||
cte.SINGLE_FAMILY_HOUSE: 'MidriseApartment',
|
||||
cte.MULTI_FAMILY_HOUSE: 'HighriseApartment',
|
||||
cte.ROW_HOUSE: 'MidriseApartment',
|
||||
cte.MID_RISE_APARTMENT: 'MURB_MidRiseApartment',
|
||||
cte.HIGH_RISE_APARTMENT: 'MURB_HighRiseApartment',
|
||||
cte.OFFICE_AND_ADMINISTRATION: 'MediumOffice',
|
||||
cte.SMALL_OFFICE: 'SmallOffice',
|
||||
cte.MEDIUM_OFFICE: 'MediumOffice',
|
||||
cte.LARGE_OFFICE: 'LargeOffice',
|
||||
cte.COURTHOUSE: 'MediumOffice',
|
||||
cte.FIRE_STATION: 'n/a',
|
||||
cte.PENITENTIARY: 'LargeHotel',
|
||||
cte.POLICE_STATION: 'n/a',
|
||||
cte.POST_OFFICE: 'MediumOffice',
|
||||
cte.LIBRARY: 'MediumOffice',
|
||||
cte.EDUCATION: 'SecondarySchool',
|
||||
cte.PRIMARY_SCHOOL: 'PrimarySchool',
|
||||
cte.PRIMARY_SCHOOL_WITH_SHOWER: 'PrimarySchool',
|
||||
cte.SECONDARY_SCHOOL: 'SecondarySchool',
|
||||
cte.UNIVERSITY: 'SecondarySchool',
|
||||
cte.LABORATORY_AND_RESEARCH_CENTER: 'SecondarySchool',
|
||||
cte.STAND_ALONE_RETAIL: 'RetailStandalone',
|
||||
cte.HOSPITAL: 'Hospital',
|
||||
cte.OUT_PATIENT_HEALTH_CARE: 'Outpatient',
|
||||
cte.HEALTH_CARE: 'Outpatient',
|
||||
cte.RETIREMENT_HOME_OR_ORPHANAGE: 'SmallHotel',
|
||||
cte.COMMERCIAL: 'RetailStripmall',
|
||||
cte.STRIP_MALL: 'RetailStripmall',
|
||||
cte.SUPERMARKET: 'RetailStripmall',
|
||||
cte.RETAIL_SHOP_WITHOUT_REFRIGERATED_FOOD: 'RetailStandalone',
|
||||
cte.RETAIL_SHOP_WITH_REFRIGERATED_FOOD: 'RetailStandalone',
|
||||
cte.RESTAURANT: 'FullServiceRestaurant',
|
||||
cte.QUICK_SERVICE_RESTAURANT: 'QuickServiceRestaurant',
|
||||
cte.FULL_SERVICE_RESTAURANT: 'FullServiceRestaurant',
|
||||
cte.HOTEL: 'SmallHotel',
|
||||
cte.HOTEL_MEDIUM_CLASS: 'SmallHotel',
|
||||
cte.SMALL_HOTEL: 'SmallHotel',
|
||||
cte.LARGE_HOTEL: 'LargeHotel',
|
||||
cte.DORMITORY: 'SmallHotel',
|
||||
cte.EVENT_LOCATION: 'n/a',
|
||||
cte.CONVENTION_CENTER: 'n/a',
|
||||
cte.HALL: 'n/a',
|
||||
cte.GREEN_HOUSE: 'n/a',
|
||||
cte.INDUSTRY: 'n/a',
|
||||
cte.WORKSHOP: 'n/a',
|
||||
cte.WAREHOUSE: 'Warehouse',
|
||||
cte.WAREHOUSE_REFRIGERATED: 'Warehouse',
|
||||
cte.SPORTS_LOCATION: 'n/a',
|
||||
cte.SPORTS_ARENA: 'n/a',
|
||||
cte.GYMNASIUM: 'n/a',
|
||||
cte.MOTION_PICTURE_THEATRE: 'n/a',
|
||||
cte.MUSEUM: 'n/a',
|
||||
cte.PERFORMING_ARTS_THEATRE: 'n/a',
|
||||
cte.TRANSPORTATION: 'n/a',
|
||||
cte.AUTOMOTIVE_FACILITY: 'n/a',
|
||||
cte.PARKING_GARAGE: 'n/a',
|
||||
cte.RELIGIOUS: 'n/a',
|
||||
cte.NON_HEATED: 'n/a',
|
||||
cte.DATACENTER: 'n/a',
|
||||
cte.FARM: 'n/a'
|
||||
}
|
||||
|
||||
@property
|
||||
def dictionary(self) -> dict:
|
||||
"""
|
||||
Get the dictionary
|
||||
:return: {}
|
||||
"""
|
||||
return self._dictionary
|
87
hub/helpers/data/hub_usage_to_cerc_usage.py
Normal file
87
hub/helpers/data/hub_usage_to_cerc_usage.py
Normal file
@ -0,0 +1,87 @@
|
||||
"""
|
||||
Dictionaries module for hub usage to NRCAN usage
|
||||
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
||||
Copyright © 2022 Concordia CERC group
|
||||
Project Coder Guille Gutierrez Guillermo.GutierrezMorote@concordia.ca
|
||||
"""
|
||||
|
||||
import hub.helpers.constants as cte
|
||||
|
||||
|
||||
class HubUsageToCercUsage:
|
||||
"""
|
||||
Hub usage to cerc usage class (copy of HubUsageToNrcanUsage)
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self._dictionary = {
|
||||
cte.RESIDENTIAL: 'Multi-unit residential building',
|
||||
cte.SINGLE_FAMILY_HOUSE: 'Multi-unit residential building',
|
||||
cte.MULTI_FAMILY_HOUSE: 'Multi-unit residential building',
|
||||
cte.ROW_HOUSE: 'Multi-unit residential building',
|
||||
cte.MID_RISE_APARTMENT: 'Multi-unit residential building',
|
||||
cte.HIGH_RISE_APARTMENT: 'Multi-unit residential building',
|
||||
cte.OFFICE_AND_ADMINISTRATION: 'Office',
|
||||
cte.SMALL_OFFICE: 'Office',
|
||||
cte.MEDIUM_OFFICE: 'Office',
|
||||
cte.LARGE_OFFICE: 'Office',
|
||||
cte.COURTHOUSE: 'Courthouse',
|
||||
cte.FIRE_STATION: 'Fire station',
|
||||
cte.PENITENTIARY: 'Penitentiary',
|
||||
cte.POLICE_STATION: 'Police station',
|
||||
cte.POST_OFFICE: 'Post office',
|
||||
cte.LIBRARY: 'Library',
|
||||
cte.EDUCATION: 'School/university',
|
||||
cte.PRIMARY_SCHOOL: 'School/university',
|
||||
cte.PRIMARY_SCHOOL_WITH_SHOWER: 'School/university',
|
||||
cte.SECONDARY_SCHOOL: 'School/university',
|
||||
cte.UNIVERSITY: 'School/university',
|
||||
cte.LABORATORY_AND_RESEARCH_CENTER: 'School/university',
|
||||
cte.STAND_ALONE_RETAIL: 'Retail area',
|
||||
cte.HOSPITAL: 'Hospital',
|
||||
cte.OUT_PATIENT_HEALTH_CARE: 'Health care clinic',
|
||||
cte.HEALTH_CARE: 'Health care clinic',
|
||||
cte.RETIREMENT_HOME_OR_ORPHANAGE: 'Health care clinic',
|
||||
cte.COMMERCIAL: 'Retail area',
|
||||
cte.STRIP_MALL: 'Retail area',
|
||||
cte.SUPERMARKET: 'Retail area',
|
||||
cte.RETAIL_SHOP_WITHOUT_REFRIGERATED_FOOD: 'Retail area',
|
||||
cte.RETAIL_SHOP_WITH_REFRIGERATED_FOOD: 'Retail area',
|
||||
cte.RESTAURANT: 'Dining - bar lounge/leisure',
|
||||
cte.QUICK_SERVICE_RESTAURANT: 'Dining - cafeteria/fast food',
|
||||
cte.FULL_SERVICE_RESTAURANT: 'Dining - bar lounge/leisure',
|
||||
cte.HOTEL: 'Hotel/Motel',
|
||||
cte.HOTEL_MEDIUM_CLASS: 'Hotel/Motel',
|
||||
cte.SMALL_HOTEL: 'Hotel/Motel',
|
||||
cte.LARGE_HOTEL: 'Hotel/Motel',
|
||||
cte.DORMITORY: 'Dormitory',
|
||||
cte.EVENT_LOCATION: 'Convention centre',
|
||||
cte.CONVENTION_CENTER: 'Convention centre',
|
||||
cte.HALL: 'Town hall',
|
||||
cte.GREEN_HOUSE: 'n/a',
|
||||
cte.INDUSTRY: 'Manufacturing facility',
|
||||
cte.WORKSHOP: 'Workshop',
|
||||
cte.WAREHOUSE: 'Warehouse',
|
||||
cte.WAREHOUSE_REFRIGERATED: 'Warehouse',
|
||||
cte.SPORTS_LOCATION: 'Exercise centre',
|
||||
cte.SPORTS_ARENA: 'Sports arena',
|
||||
cte.GYMNASIUM: 'Gymnasium',
|
||||
cte.MOTION_PICTURE_THEATRE: 'Motion picture theatre',
|
||||
cte.MUSEUM: 'Museum',
|
||||
cte.PERFORMING_ARTS_THEATRE: 'Performing arts theatre',
|
||||
cte.TRANSPORTATION: 'Transportation facility',
|
||||
cte.AUTOMOTIVE_FACILITY: 'Automotive facility',
|
||||
cte.PARKING_GARAGE: 'Storage garage',
|
||||
cte.RELIGIOUS: 'Religious building',
|
||||
cte.NON_HEATED: 'n/a',
|
||||
cte.DATACENTER: 'n/a',
|
||||
cte.FARM: 'n/a'
|
||||
}
|
||||
|
||||
@property
|
||||
def dictionary(self) -> dict:
|
||||
"""
|
||||
Get the dictionary
|
||||
:return: {}
|
||||
"""
|
||||
return self._dictionary
|
@ -13,11 +13,15 @@ from hub.helpers.data.alkis_function_to_hub_function import AlkisFunctionToHubFu
|
||||
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_nrcan_construction_function import HubFunctionToNrcanConstructionFunction
|
||||
from hub.helpers.data.hub_function_to_cerc_construction_function import HubFunctionToCercConstructionFunction
|
||||
|
||||
from hub.helpers.data.hub_function_to_eilat_construction_function import HubFunctionToEilatConstructionFunction
|
||||
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_nrcan_usage import HubUsageToNrcanUsage
|
||||
from hub.helpers.data.hub_usage_to_eilat_usage import HubUsageToEilatUsage
|
||||
from hub.helpers.data.hub_usage_to_cerc_usage import HubUsageToCercUsage
|
||||
|
||||
from hub.helpers.data.montreal_system_to_hub_energy_generation_system import MontrealSystemToHubEnergyGenerationSystem
|
||||
from hub.helpers.data.montreal_generation_system_to_hub_energy_generation_system import MontrealGenerationSystemToHubEnergyGenerationSystem
|
||||
from hub.helpers.data.montreal_demand_type_to_hub_energy_demand_type import MontrealDemandTypeToHubEnergyDemandType
|
||||
@ -56,7 +60,13 @@ class Dictionaries:
|
||||
:return: dict
|
||||
"""
|
||||
return HubUsageToNrcanUsage().dictionary
|
||||
|
||||
@property
|
||||
def hub_usage_to_cerc_usage(self) -> dict:
|
||||
"""
|
||||
Get hub usage to CERC usage, transformation dictionary
|
||||
:return: dict
|
||||
"""
|
||||
return HubUsageToCercUsage().dictionary
|
||||
@property
|
||||
def hub_usage_to_eilat_usage(self) -> dict:
|
||||
"""
|
||||
@ -80,7 +90,13 @@ class Dictionaries:
|
||||
:return: dict
|
||||
"""
|
||||
return HubFunctionToEilatConstructionFunction().dictionary
|
||||
|
||||
@property
|
||||
def hub_function_to_cerc_construction_function(self) -> dict:
|
||||
"""
|
||||
Get hub function to Cerc construction function, transformation dictionary (copy of HubFunctionToNrcanConstructionFunction)
|
||||
:return: dict
|
||||
"""
|
||||
return HubFunctionToCercConstructionFunction().dictionary
|
||||
@property
|
||||
def hub_function_to_nrel_construction_function(self) -> dict:
|
||||
"""
|
||||
|
107
hub/imports/construction/cerc_physics_parameters.py
Normal file
107
hub/imports/construction/cerc_physics_parameters.py
Normal file
@ -0,0 +1,107 @@
|
||||
"""
|
||||
CercPhysicsParameters import the construction and material information defined by Cerc
|
||||
|
||||
this is a copy of NrcanPhysicsParameters.py with the necessary changes to adapt it to the Cerc 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 logging
|
||||
|
||||
from hub.catalog_factories.construction_catalog_factory import ConstructionCatalogFactory
|
||||
from hub.city_model_structure.building_demand.thermal_archetype import ThermalArchetype
|
||||
from hub.city_model_structure.building_demand.construction import Construction
|
||||
from hub.city_model_structure.building_demand.layer import Layer
|
||||
from hub.helpers.dictionaries import Dictionaries
|
||||
from hub.imports.construction.helpers.construction_helper import ConstructionHelper
|
||||
|
||||
|
||||
class CercPhysicsParameters:
|
||||
"""
|
||||
CercPhysicsParameters class
|
||||
"""
|
||||
|
||||
def __init__(self, city, divide_in_storeys=False):
|
||||
self._city = city
|
||||
self._divide_in_storeys = divide_in_storeys
|
||||
self._climate_zone = ConstructionHelper.city_to_nrcan_climate_zone(city.climate_reference_city)
|
||||
|
||||
def enrich_buildings(self):
|
||||
"""
|
||||
Returns the city with the construction parameters assigned to the buildings
|
||||
"""
|
||||
city = self._city
|
||||
cerc_catalog = ConstructionCatalogFactory('cerc').catalog
|
||||
for building in city.buildings:
|
||||
if building.function not in Dictionaries().hub_function_to_cerc_construction_function:
|
||||
logging.error('Building %s has an unknown building function %s', building.name, building.function)
|
||||
continue
|
||||
function = Dictionaries().hub_function_to_cerc_construction_function[building.function]
|
||||
try:
|
||||
archetype = self._search_archetype(cerc_catalog, function, building.year_of_construction, self._climate_zone)
|
||||
|
||||
except KeyError:
|
||||
logging.error('Building %s has unknown construction archetype for building function: %s '
|
||||
'[%s], building year of construction: %s and climate zone %s', building.name, function,
|
||||
building.function, building.year_of_construction, self._climate_zone)
|
||||
continue
|
||||
thermal_archetype = ThermalArchetype()
|
||||
self._assign_values(thermal_archetype, archetype)
|
||||
for internal_zone in building.internal_zones:
|
||||
internal_zone.thermal_archetype = thermal_archetype
|
||||
|
||||
@staticmethod
|
||||
def _search_archetype(cerc_catalog, function, year_of_construction, climate_zone):
|
||||
cerc_archetypes = cerc_catalog.entries('archetypes')
|
||||
for building_archetype in cerc_archetypes:
|
||||
construction_period_limits = building_archetype.construction_period.split('_')
|
||||
if int(construction_period_limits[0]) <= int(year_of_construction) <= int(construction_period_limits[1]):
|
||||
if str(function) == str(building_archetype.function) and climate_zone == str(building_archetype.climate_zone):
|
||||
return building_archetype
|
||||
raise KeyError('archetype not found')
|
||||
|
||||
@staticmethod
|
||||
def _assign_values(thermal_archetype, catalog_archetype):
|
||||
thermal_archetype.average_storey_height = catalog_archetype.average_storey_height
|
||||
thermal_archetype.extra_loses_due_to_thermal_bridges = catalog_archetype.extra_loses_due_to_thermal_bridges
|
||||
thermal_archetype.thermal_capacity = catalog_archetype.thermal_capacity
|
||||
thermal_archetype.indirect_heated_ratio = 0
|
||||
thermal_archetype.infiltration_rate_for_ventilation_system_on = catalog_archetype.infiltration_rate_for_ventilation_system_on
|
||||
thermal_archetype.infiltration_rate_for_ventilation_system_off = catalog_archetype.infiltration_rate_for_ventilation_system_off
|
||||
_constructions = []
|
||||
for catalog_construction in catalog_archetype.constructions:
|
||||
construction = Construction()
|
||||
construction.type = catalog_construction.type
|
||||
construction.name = catalog_construction.name
|
||||
if catalog_construction.window_ratio is not None:
|
||||
for _orientation in catalog_construction.window_ratio:
|
||||
if catalog_construction.window_ratio[_orientation] is None:
|
||||
catalog_construction.window_ratio[_orientation] = 0
|
||||
construction.window_ratio = catalog_construction.window_ratio
|
||||
_layers = []
|
||||
for layer_archetype in catalog_construction.layers:
|
||||
layer = Layer()
|
||||
layer.thickness = layer_archetype.thickness
|
||||
archetype_material = layer_archetype.material
|
||||
layer.material_name = archetype_material.name
|
||||
layer.no_mass = archetype_material.no_mass
|
||||
if archetype_material.no_mass:
|
||||
layer.thermal_resistance = archetype_material.thermal_resistance
|
||||
else:
|
||||
layer.density = archetype_material.density
|
||||
layer.conductivity = archetype_material.conductivity
|
||||
layer.specific_heat = archetype_material.specific_heat
|
||||
layer.solar_absorptance = archetype_material.solar_absorptance
|
||||
layer.thermal_absorptance = archetype_material.thermal_absorptance
|
||||
layer.visible_absorptance = archetype_material.visible_absorptance
|
||||
_layers.append(layer)
|
||||
construction.layers = _layers
|
||||
|
||||
if catalog_construction.window is not None:
|
||||
window_archetype = catalog_construction.window
|
||||
construction.window_frame_ratio = window_archetype.frame_ratio
|
||||
construction.window_g_value = window_archetype.g_value
|
||||
construction.window_overall_u_value = window_archetype.overall_u_value
|
||||
_constructions.append(construction)
|
||||
thermal_archetype.constructions = _constructions
|
@ -10,6 +10,8 @@ from hub.helpers.utils import validate_import_export_type
|
||||
from hub.imports.construction.nrcan_physics_parameters import NrcanPhysicsParameters
|
||||
from hub.imports.construction.nrel_physics_parameters import NrelPhysicsParameters
|
||||
from hub.imports.construction.eilat_physics_parameters import EilatPhysicsParameters
|
||||
from hub.imports.construction.cerc_physics_parameters import CercPhysicsParameters
|
||||
|
||||
|
||||
|
||||
class ConstructionFactory:
|
||||
@ -38,6 +40,15 @@ class ConstructionFactory:
|
||||
self._city.level_of_detail.construction = 2
|
||||
for building in self._city.buildings:
|
||||
building.level_of_detail.construction = 2
|
||||
|
||||
def _cerc(self):
|
||||
"""
|
||||
Enrich the city by using CERC information
|
||||
"""
|
||||
CercPhysicsParameters(self._city).enrich_buildings()
|
||||
self._city.level_of_detail.construction = 2
|
||||
for building in self._city.buildings:
|
||||
building.level_of_detail.construction = 2
|
||||
|
||||
def _eilat(self):
|
||||
"""
|
||||
|
35
hub/imports/retrofit_factory.py
Normal file
35
hub/imports/retrofit_factory.py
Normal file
@ -0,0 +1,35 @@
|
||||
from hub.city_model_structure.building import Building
|
||||
from hub.city_model_structure.city import City
|
||||
import hub.helpers.constants as cte
|
||||
|
||||
class RetrofitFactory:
|
||||
def __init__(self, retrofit_type, city):
|
||||
self._retrofit_type = retrofit_type
|
||||
self._city = city
|
||||
|
||||
def apply_retrofit(self, wall_u_value=None, roof_u_value=None, ground_u_value=None):
|
||||
for building in self._city.buildings:
|
||||
self._apply_retrofit_to_building(building, wall_u_value, roof_u_value, ground_u_value)
|
||||
|
||||
def _apply_retrofit_to_building(self, building: Building, wall_u_value, roof_u_value, ground_u_value):
|
||||
for internal_zone in building.internal_zones:
|
||||
print(internal_zone.id)
|
||||
|
||||
for thermal_zone in internal_zone.thermal_zones_from_internal_zones:
|
||||
for thermal_boundary in thermal_zone.thermal_boundaries:
|
||||
if wall_u_value and thermal_boundary.type == cte.WALL:
|
||||
print(thermal_boundary.u_value)
|
||||
thermal_boundary.u_value = wall_u_value
|
||||
print(thermal_boundary.u_value)
|
||||
elif roof_u_value and thermal_boundary.type == cte.ROOF:
|
||||
print("roof", thermal_boundary.u_value)
|
||||
thermal_boundary.u_value = roof_u_value
|
||||
print("roof", thermal_boundary.u_value)
|
||||
elif ground_u_value and thermal_boundary.type == cte.GROUND:
|
||||
thermal_boundary.u_value = ground_u_value
|
||||
print("ground", thermal_boundary.u_value)
|
||||
|
||||
def enrich(self):
|
||||
# This method can be expanded to include different retrofit strategies
|
||||
if self._retrofit_type == 'basic':
|
||||
self.apply_retrofit(wall_u_value=0.85, roof_u_value=0.95, ground_u_value=0.95)
|
199
hub/imports/usage/cerc_usage_parameters.py
Normal file
199
hub/imports/usage/cerc_usage_parameters.py
Normal file
@ -0,0 +1,199 @@
|
||||
"""
|
||||
NrcanUsageParameters extracts the usage properties from NRCAN catalog and assigns to each building
|
||||
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 logging
|
||||
|
||||
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.catalog_factories.usage_catalog_factory import UsageCatalogFactory
|
||||
|
||||
|
||||
class CercUsageParameters:
|
||||
"""
|
||||
CercUsageParameters class (Copy of NrcanUsageParameters)
|
||||
"""
|
||||
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
|
||||
cerc_catalog = UsageCatalogFactory('cerc').catalog
|
||||
comnet_catalog = UsageCatalogFactory('comnet').catalog
|
||||
|
||||
for building in city.buildings:
|
||||
usage_name = Dictionaries().hub_usage_to_cerc_usage[building.function]
|
||||
try:
|
||||
archetype_usage = self._search_archetypes(cerc_catalog, usage_name)
|
||||
except KeyError:
|
||||
logging.error('Building %s has unknown usage archetype for usage %s', building.name, usage_name)
|
||||
continue
|
||||
|
||||
comnet_usage_name = Dictionaries().hub_usage_to_comnet_usage[building.function]
|
||||
try:
|
||||
comnet_archetype_usage = self._search_archetypes(comnet_catalog, comnet_usage_name)
|
||||
except KeyError:
|
||||
logging.error('Building %s has unknown usage archetype for usage %s', building.name, comnet_usage_name)
|
||||
continue
|
||||
|
||||
for internal_zone in building.internal_zones:
|
||||
if len(building.internal_zones) > 1:
|
||||
volume_per_area = 0
|
||||
if internal_zone.area is None:
|
||||
logging.error('Building %s has internal zone area not defined, ACH cannot be calculated for usage %s',
|
||||
building.name, usage_name)
|
||||
continue
|
||||
if internal_zone.volume is None:
|
||||
logging.error('Building %s has internal zone volume not defined, ACH cannot be calculated for usage %s',
|
||||
building.name, usage_name)
|
||||
continue
|
||||
if internal_zone.area <= 0:
|
||||
logging.error('Building %s has internal zone area equal to 0, ACH cannot be calculated for usage %s',
|
||||
building.name, usage_name)
|
||||
continue
|
||||
volume_per_area += internal_zone.volume / internal_zone.area
|
||||
else:
|
||||
if building.storeys_above_ground is None:
|
||||
logging.error('Building %s no number of storeys assigned, ACH cannot be calculated for usage %s',
|
||||
building.name, usage_name)
|
||||
continue
|
||||
volume_per_area = building.volume / building.floor_area / building.storeys_above_ground
|
||||
|
||||
usage = Usage()
|
||||
usage.name = usage_name
|
||||
self._assign_values(usage, archetype_usage, volume_per_area, building.cold_water_temperature)
|
||||
self._assign_comnet_extra_values(usage, comnet_archetype_usage, archetype_usage.occupancy.occupancy_density)
|
||||
usage.percentage = 1
|
||||
self._calculate_reduced_values_from_extended_library(usage, archetype_usage)
|
||||
|
||||
internal_zone.usages = [usage]
|
||||
|
||||
@staticmethod
|
||||
def _search_archetypes(catalog, usage_name):
|
||||
archetypes = catalog.entries('archetypes').usages
|
||||
for building_archetype in 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):
|
||||
if archetype.mechanical_air_change > 0:
|
||||
# 1/s
|
||||
usage.mechanical_air_change = archetype.mechanical_air_change
|
||||
elif archetype.ventilation_rate > 0:
|
||||
# m3/m2.s to 1/s
|
||||
usage.mechanical_air_change = archetype.ventilation_rate / volume_per_area
|
||||
else:
|
||||
usage.mechanical_air_change = 0
|
||||
_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.peak_flow = archetype.domestic_hot_water.peak_flow
|
||||
_domestic_hot_water.service_temperature = archetype.domestic_hot_water.service_temperature
|
||||
density = None
|
||||
if len(cold_water_temperature) > 0:
|
||||
cold_temperature = cold_water_temperature[cte.YEAR][0]
|
||||
density = (
|
||||
archetype.domestic_hot_water.peak_flow * cte.WATER_DENSITY * cte.WATER_HEAT_CAPACITY *
|
||||
(archetype.domestic_hot_water.service_temperature - cold_temperature)
|
||||
)
|
||||
_domestic_hot_water.density = density
|
||||
_domestic_hot_water.schedules = archetype.domestic_hot_water.schedules
|
||||
usage.domestic_hot_water = _domestic_hot_water
|
||||
|
||||
@staticmethod
|
||||
def _assign_comnet_extra_values(usage, archetype, occupancy_density):
|
||||
_occupancy = usage.occupancy
|
||||
archetype_density = archetype.occupancy.occupancy_density
|
||||
if archetype_density == 0:
|
||||
_occupancy.sensible_radiative_internal_gain = 0
|
||||
_occupancy.latent_internal_gain = 0
|
||||
_occupancy.sensible_convective_internal_gain = 0
|
||||
else:
|
||||
_occupancy.sensible_radiative_internal_gain = archetype.occupancy.sensible_radiative_internal_gain \
|
||||
* occupancy_density / archetype_density
|
||||
_occupancy.latent_internal_gain = archetype.occupancy.latent_internal_gain * occupancy_density / archetype_density
|
||||
_occupancy.sensible_convective_internal_gain = (
|
||||
archetype.occupancy.sensible_convective_internal_gain * occupancy_density / archetype_density
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def _calculate_reduced_values_from_extended_library(usage, archetype):
|
||||
number_of_days_per_type = {'WD': 251, 'Sat': 52, 'Sun': 62}
|
||||
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['Sat']
|
||||
elif schedule.day_types[0] == cte.SUNDAY:
|
||||
for value in schedule.values:
|
||||
total += value * number_of_days_per_type['Sun']
|
||||
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
|
@ -9,6 +9,8 @@ Code contributors: Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concord
|
||||
from hub.helpers.utils import validate_import_export_type
|
||||
from hub.imports.usage.comnet_usage_parameters import ComnetUsageParameters
|
||||
from hub.imports.usage.nrcan_usage_parameters import NrcanUsageParameters
|
||||
from hub.imports.usage.cerc_usage_parameters import CercUsageParameters
|
||||
|
||||
from hub.imports.usage.eilat_usage_parameters import EilatUsageParameters
|
||||
|
||||
|
||||
@ -38,7 +40,16 @@ class UsageFactory:
|
||||
self._city.level_of_detail.usage = 2
|
||||
for building in self._city.buildings:
|
||||
building.level_of_detail.usage = 2
|
||||
|
||||
|
||||
def _cerc(self):
|
||||
"""
|
||||
Enrich the city with cerc usage library (copy of NRCAN)
|
||||
"""
|
||||
CercUsageParameters(self._city).enrich_buildings()
|
||||
self._city.level_of_detail.usage = 2
|
||||
for building in self._city.buildings:
|
||||
building.level_of_detail.usage = 2
|
||||
|
||||
def _eilat(self):
|
||||
"""
|
||||
Enrich the city with Eilat usage library
|
||||
|
6
main.py
6
main.py
@ -10,7 +10,7 @@ from hub.imports.weather_factory import WeatherFactory
|
||||
input_files_path = (Path(__file__).parent / 'input_files')
|
||||
input_files_path.mkdir(parents=True, exist_ok=True)
|
||||
geojson_file = process_geojson(x=-73.5681295982132, y=45.49218262677643, diff=0.0001)
|
||||
geojson_file_path = input_files_path / 'output_buildings.geojson'
|
||||
geojson_file_path = input_files_path / 'input_buildings.geojson'
|
||||
output_path = (Path(__file__).parent / 'out_files').resolve()
|
||||
output_path.mkdir(parents=True, exist_ok=True)
|
||||
# Create city object from GeoJSON file
|
||||
@ -21,8 +21,8 @@ city = GeometryFactory('geojson',
|
||||
function_field='function',
|
||||
function_to_hub=Dictionaries().montreal_function_to_hub_function).city
|
||||
# Enrich city data
|
||||
ConstructionFactory('nrcan', city).enrich()
|
||||
UsageFactory('nrcan', city).enrich()
|
||||
ConstructionFactory('cerc', city).enrich()
|
||||
UsageFactory('cerc', city).enrich()
|
||||
WeatherFactory('epw', city).enrich()
|
||||
energy_plus_workflow(city)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user