added eilat construction to catalog and imports and erased unused city_to_climate_reference_city in construction_helper.py
This commit is contained in:
parent
5247eda305
commit
ae157a9243
232
hub/catalog_factories/construction/eilat_catalog.py
Normal file
232
hub/catalog_factories/construction/eilat_catalog.py
Normal file
|
@ -0,0 +1,232 @@
|
|||
"""
|
||||
Eilat construction catalog
|
||||
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 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
|
||||
|
||||
|
||||
class EilatCatalog(Catalog):
|
||||
"""
|
||||
Eilat catalog class
|
||||
"""
|
||||
def __init__(self, path):
|
||||
_path_archetypes = Path(path / 'eilat_archetypes.json').resolve()
|
||||
_path_constructions = (path / 'eilat_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']
|
||||
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']
|
||||
infiltration_rate_for_ventilation_system_on = archetype['infiltration_rate_for_ventilation_system_on']
|
||||
|
||||
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,
|
||||
None,
|
||||
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")
|
|
@ -10,6 +10,7 @@ from typing import TypeVar
|
|||
|
||||
from hub.catalog_factories.construction.nrcan_catalog import NrcanCatalog
|
||||
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
|
||||
|
||||
Catalog = TypeVar('Catalog')
|
||||
|
@ -36,10 +37,17 @@ class ConstructionCatalogFactory:
|
|||
@property
|
||||
def _nrcan(self):
|
||||
"""
|
||||
Retrieve NREL catalog
|
||||
Retrieve NRCAN catalog
|
||||
"""
|
||||
return NrcanCatalog(self._path)
|
||||
|
||||
@property
|
||||
def _eilat(self):
|
||||
"""
|
||||
Retrieve Eilat catalog
|
||||
"""
|
||||
return EilatCatalog(self._path)
|
||||
|
||||
@property
|
||||
def catalog(self) -> Catalog:
|
||||
"""
|
||||
|
|
106
hub/data/construction/eilat_archetypes.json
Normal file
106
hub/data/construction/eilat_archetypes.json
Normal file
|
@ -0,0 +1,106 @@
|
|||
{
|
||||
"archetypes": [
|
||||
{
|
||||
"function": "Residential",
|
||||
"period_of_construction": "1000_1980",
|
||||
"climate_zone": "BWh",
|
||||
"average_storey_height": 1,
|
||||
"extra_loses_due_thermal_bridges": 0.1,
|
||||
"infiltration_rate_for_ventilation_system_on": 1,
|
||||
"infiltration_rate_for_ventilation_system_off": 1,
|
||||
"constructions": {
|
||||
"OutdoorsWall": {
|
||||
"opaque_surface_name": "residential_1000_1980_BWh",
|
||||
"transparent_surface_name": "Window_residential_1000_1980_BWh",
|
||||
"transparent_ratio": {
|
||||
"north": "18.0",
|
||||
"east": "0.0",
|
||||
"south": "9.0",
|
||||
"west": "0.0"
|
||||
}
|
||||
},
|
||||
"OutdoorsRoofCeiling": {
|
||||
"opaque_surface_name": "residential_1000_1980_BWh",
|
||||
"transparent_surface_name": null,
|
||||
"transparent_ratio": {
|
||||
"north": null,
|
||||
"east": null,
|
||||
"south": null,
|
||||
"west": null
|
||||
}
|
||||
},
|
||||
"GroundFloor": {
|
||||
"opaque_surface_name": "residential_1000_1980_BWh"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"function": "Dormitory",
|
||||
"period_of_construction": "2011_3000",
|
||||
"climate_zone": "BWh",
|
||||
"average_storey_height": 1,
|
||||
"extra_loses_due_thermal_bridges": 0.1,
|
||||
"infiltration_rate_for_ventilation_system_on": 1,
|
||||
"infiltration_rate_for_ventilation_system_off": 1,
|
||||
"constructions": {
|
||||
"OutdoorsWall": {
|
||||
"opaque_surface_name": "dormitory_2011_3000_BWh",
|
||||
"transparent_surface_name": "Window_dormitory_2011_3000_BWh",
|
||||
"transparent_ratio": {
|
||||
"north": "14.0",
|
||||
"east": "6.0",
|
||||
"south": "14.0",
|
||||
"west": "6.0"
|
||||
}
|
||||
},
|
||||
"OutdoorsRoofCeiling": {
|
||||
"opaque_surface_name": "dormitory_2011_3000_BWh",
|
||||
"transparent_surface_name": null,
|
||||
"transparent_ratio": {
|
||||
"north": null,
|
||||
"east": null,
|
||||
"south": null,
|
||||
"west": null
|
||||
}
|
||||
},
|
||||
"GroundFloor": {
|
||||
"opaque_surface_name": "dormitory_2011_3000_BWh"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"function": "Hotel_employees",
|
||||
"period_of_construction": "1981_2010",
|
||||
"climate_zone": "BWh",
|
||||
"average_storey_height": 1,
|
||||
"extra_loses_due_thermal_bridges": 0.09,
|
||||
"infiltration_rate_for_ventilation_system_on": 1,
|
||||
"infiltration_rate_for_ventilation_system_off": 1,
|
||||
"constructions": {
|
||||
"OutdoorsWall": {
|
||||
"opaque_surface_name": "hotel_employees_1981_2010_BWh",
|
||||
"transparent_surface_name": "Window_hotel_employees_1981_2010_BWh",
|
||||
"transparent_ratio": {
|
||||
"north": "5.0",
|
||||
"east": "21.0",
|
||||
"south": "5.0",
|
||||
"west": "26.0"
|
||||
}
|
||||
},
|
||||
"OutdoorsRoofCeiling": {
|
||||
"opaque_surface_name": "hotel_employees_1981_2010_BWh",
|
||||
"transparent_surface_name": null,
|
||||
"transparent_ratio": {
|
||||
"north": null,
|
||||
"east": null,
|
||||
"south": null,
|
||||
"west": null
|
||||
}
|
||||
},
|
||||
"GroundFloor": {
|
||||
"opaque_surface_name": "hotel_employees_1981_2010_BWh"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
3501
hub/data/construction/eilat_constructions.json
Normal file
3501
hub/data/construction/eilat_constructions.json
Normal file
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,28 @@
|
|||
"""
|
||||
Dictionaries module for hub function to eilat construction 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 HubFunctionToEilatConstructionFunction:
|
||||
"""
|
||||
Hub function to Eilat construction function 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
|
|
@ -1,7 +1,7 @@
|
|||
"""
|
||||
Dictionaries module saves all transformations of functions and usages to access the catalogs
|
||||
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
||||
Copyright © 2022 Concordia CERC group
|
||||
Copyright © 2023 Concordia CERC group
|
||||
Project Coder Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
|
||||
"""
|
||||
|
||||
|
@ -12,6 +12,7 @@ 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_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
|
||||
|
@ -66,6 +67,14 @@ class Dictionaries:
|
|||
"""
|
||||
return HubFunctionToNrcanConstructionFunction().dictionary
|
||||
|
||||
@property
|
||||
def hub_function_to_eilat_construction_function(self) -> dict:
|
||||
"""
|
||||
Get hub function to NRCAN construction function, transformation dictionary
|
||||
:return: dict
|
||||
"""
|
||||
return HubFunctionToEilatConstructionFunction().dictionary
|
||||
|
||||
@property
|
||||
def hub_function_to_nrel_construction_function(self) -> dict:
|
||||
"""
|
||||
|
|
213
hub/imports/construction/eilat_physics_parameters.py
Normal file
213
hub/imports/construction/eilat_physics_parameters.py
Normal file
|
@ -0,0 +1,213 @@
|
|||
"""
|
||||
EilatPhysicsParameters import the construction and material information defined for Eilat
|
||||
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 logging
|
||||
import math
|
||||
|
||||
import hub.helpers.constants as cte
|
||||
from hub.catalog_factories.construction_catalog_factory import ConstructionCatalogFactory
|
||||
from hub.city_model_structure.building_demand.layer import Layer
|
||||
from hub.city_model_structure.building_demand.material import Material
|
||||
from hub.helpers.dictionaries import Dictionaries
|
||||
from hub.imports.construction.helpers.construction_helper import ConstructionHelper
|
||||
from hub.imports.construction.helpers.storeys_generation import StoreysGeneration
|
||||
|
||||
|
||||
class EilatPhysicsParameters:
|
||||
"""
|
||||
EilatPhysicsParameters 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_israel_climate_zone(city.climate_reference_city)
|
||||
|
||||
def enrich_buildings(self):
|
||||
"""
|
||||
Returns the city with the construction parameters assigned to the buildings
|
||||
"""
|
||||
city = self._city
|
||||
eilat_catalog = ConstructionCatalogFactory('eilat').catalog
|
||||
for building in city.buildings:
|
||||
if building.function not in Dictionaries().hub_function_to_eilat_construction_function.keys():
|
||||
logging.error(f'Building %s has an unknown building function %s', building.name, building.function )
|
||||
continue
|
||||
function = Dictionaries().hub_function_to_eilat_construction_function[building.function]
|
||||
try:
|
||||
archetype = self._search_archetype(eilat_catalog, function, building.year_of_construction, self._climate_zone)
|
||||
|
||||
except KeyError:
|
||||
logging.error(f'Building %s has unknown construction archetype for building function: %s '
|
||||
f'[%s], building year of construction: %s and climate zone %s', building.name, function,
|
||||
building.function, building.year_of_construction, self._climate_zone)
|
||||
continue
|
||||
|
||||
# if building has no thermal zones defined from geometry, and the building will be divided in storeys,
|
||||
# one thermal zone per storey is assigned
|
||||
|
||||
if len(building.internal_zones) == 1:
|
||||
if building.internal_zones[0].thermal_zones is None:
|
||||
self._create_storeys(building, archetype, self._divide_in_storeys)
|
||||
if self._divide_in_storeys:
|
||||
for internal_zone in building.internal_zones:
|
||||
for thermal_zone in internal_zone.thermal_zones:
|
||||
thermal_zone.total_floor_area = thermal_zone.footprint_area
|
||||
else:
|
||||
number_of_storeys = int(building.eave_height / building.average_storey_height)
|
||||
thermal_zone = building.internal_zones[0].thermal_zones[0]
|
||||
thermal_zone.total_floor_area = thermal_zone.footprint_area * number_of_storeys
|
||||
else:
|
||||
for internal_zone in building.internal_zones:
|
||||
for thermal_zone in internal_zone.thermal_zones:
|
||||
thermal_zone.total_floor_area = thermal_zone.footprint_area
|
||||
for internal_zone in building.internal_zones:
|
||||
self._assign_values(internal_zone.thermal_zones, archetype)
|
||||
for thermal_zone in internal_zone.thermal_zones:
|
||||
self._calculate_view_factors(thermal_zone)
|
||||
|
||||
@staticmethod
|
||||
def _search_archetype(nrcan_catalog, function, year_of_construction, climate_zone):
|
||||
nrcan_archetypes = nrcan_catalog.entries('archetypes')
|
||||
for building_archetype in nrcan_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 _search_construction_in_archetype(archetype, construction_type):
|
||||
construction_archetypes = archetype.constructions
|
||||
for construction_archetype in construction_archetypes:
|
||||
if str(construction_type) == str(construction_archetype.type):
|
||||
return construction_archetype
|
||||
return None
|
||||
|
||||
def _assign_values(self, thermal_zones, archetype):
|
||||
for thermal_zone in thermal_zones:
|
||||
thermal_zone.additional_thermal_bridge_u_value = archetype.extra_loses_due_to_thermal_bridges
|
||||
effective_thermal_capacity = 0
|
||||
thermal_zone.indirectly_heated_area_ratio = 0
|
||||
thermal_zone.infiltration_rate_system_on = archetype.infiltration_rate_for_ventilation_system_on
|
||||
thermal_zone.infiltration_rate_system_off = archetype.infiltration_rate_for_ventilation_system_off
|
||||
for thermal_boundary in thermal_zone.thermal_boundaries:
|
||||
construction_archetype = self._search_construction_in_archetype(archetype, thermal_boundary.type)
|
||||
thermal_boundary.construction_name = construction_archetype.name
|
||||
try:
|
||||
thermal_boundary.window_ratio = 0
|
||||
if thermal_boundary.type in (cte.WALL, cte.ROOF):
|
||||
if construction_archetype.window is not None:
|
||||
if -math.sqrt(2) / 2 < math.sin(thermal_boundary.parent_surface.azimuth) < math.sqrt(2) / 2:
|
||||
if 0 < math.cos(thermal_boundary.parent_surface.azimuth):
|
||||
thermal_boundary.window_ratio = \
|
||||
float(construction_archetype.window_ratio['north']) / 100
|
||||
else:
|
||||
thermal_boundary.window_ratio = \
|
||||
float(construction_archetype.window_ratio['south']) / 100
|
||||
elif math.sqrt(2) / 2 <= math.sin(thermal_boundary.parent_surface.azimuth):
|
||||
thermal_boundary.window_ratio = \
|
||||
float(construction_archetype.window_ratio['east']) / 100
|
||||
else:
|
||||
thermal_boundary.window_ratio = \
|
||||
float(construction_archetype.window_ratio['west']) / 100
|
||||
except ValueError:
|
||||
# This is the normal operation way when the windows are defined in the geometry
|
||||
continue
|
||||
thermal_boundary.layers = []
|
||||
total_thickness = 0
|
||||
for layer_archetype in construction_archetype.layers:
|
||||
layer = Layer()
|
||||
layer.thickness = layer_archetype.thickness
|
||||
total_thickness += layer_archetype.thickness
|
||||
material = Material()
|
||||
archetype_material = layer_archetype.material
|
||||
material.name = archetype_material.name
|
||||
material.id = archetype_material.id
|
||||
material.no_mass = archetype_material.no_mass
|
||||
if archetype_material.no_mass:
|
||||
material.thermal_resistance = archetype_material.thermal_resistance
|
||||
else:
|
||||
material.density = archetype_material.density
|
||||
material.conductivity = archetype_material.conductivity
|
||||
material.specific_heat = archetype_material.specific_heat
|
||||
effective_thermal_capacity += archetype_material.specific_heat \
|
||||
* archetype_material.density * layer_archetype.thickness
|
||||
material.solar_absorptance = archetype_material.solar_absorptance
|
||||
material.thermal_absorptance = archetype_material.thermal_absorptance
|
||||
material.visible_absorptance = archetype_material.visible_absorptance
|
||||
layer.material = material
|
||||
thermal_boundary.layers.append(layer)
|
||||
|
||||
effective_thermal_capacity = effective_thermal_capacity / total_thickness
|
||||
# The agreement is that the layers are defined from outside to inside
|
||||
external_layer = construction_archetype.layers[0]
|
||||
external_surface = thermal_boundary.parent_surface
|
||||
external_surface.short_wave_reflectance = 1 - external_layer.material.solar_absorptance
|
||||
external_surface.long_wave_emittance = 1 - external_layer.material.solar_absorptance
|
||||
internal_layer = construction_archetype.layers[len(construction_archetype.layers) - 1]
|
||||
internal_surface = thermal_boundary.internal_surface
|
||||
internal_surface.short_wave_reflectance = 1 - internal_layer.material.solar_absorptance
|
||||
internal_surface.long_wave_emittance = 1 - internal_layer.material.solar_absorptance
|
||||
|
||||
for thermal_opening in thermal_boundary.thermal_openings:
|
||||
if construction_archetype.window is not None:
|
||||
window_archetype = construction_archetype.window
|
||||
thermal_opening.construction_name = window_archetype.name
|
||||
thermal_opening.frame_ratio = window_archetype.frame_ratio
|
||||
thermal_opening.g_value = window_archetype.g_value
|
||||
thermal_opening.overall_u_value = window_archetype.overall_u_value
|
||||
|
||||
thermal_zone.effective_thermal_capacity = effective_thermal_capacity
|
||||
|
||||
@staticmethod
|
||||
def _calculate_view_factors(thermal_zone):
|
||||
"""
|
||||
Get thermal zone view factors matrix
|
||||
:return: [[float]]
|
||||
"""
|
||||
total_area = 0
|
||||
for thermal_boundary in thermal_zone.thermal_boundaries:
|
||||
total_area += thermal_boundary.opaque_area
|
||||
for thermal_opening in thermal_boundary.thermal_openings:
|
||||
total_area += thermal_opening.area
|
||||
|
||||
view_factors_matrix = []
|
||||
for thermal_boundary_1 in thermal_zone.thermal_boundaries:
|
||||
values = []
|
||||
for thermal_boundary_2 in thermal_zone.thermal_boundaries:
|
||||
value = 0
|
||||
if thermal_boundary_1.id != thermal_boundary_2.id:
|
||||
value = thermal_boundary_2.opaque_area / (total_area - thermal_boundary_1.opaque_area)
|
||||
values.append(value)
|
||||
for thermal_boundary in thermal_zone.thermal_boundaries:
|
||||
for thermal_opening in thermal_boundary.thermal_openings:
|
||||
value = thermal_opening.area / (total_area - thermal_boundary_1.opaque_area)
|
||||
values.append(value)
|
||||
view_factors_matrix.append(values)
|
||||
|
||||
for thermal_boundary_1 in thermal_zone.thermal_boundaries:
|
||||
values = []
|
||||
for thermal_opening_1 in thermal_boundary_1.thermal_openings:
|
||||
for thermal_boundary_2 in thermal_zone.thermal_boundaries:
|
||||
value = thermal_boundary_2.opaque_area / (total_area - thermal_opening_1.area)
|
||||
values.append(value)
|
||||
for thermal_boundary in thermal_zone.thermal_boundaries:
|
||||
for thermal_opening_2 in thermal_boundary.thermal_openings:
|
||||
value = 0
|
||||
if thermal_opening_1.id != thermal_opening_2.id:
|
||||
value = thermal_opening_2.area / (total_area - thermal_opening_1.area)
|
||||
values.append(value)
|
||||
view_factors_matrix.append(values)
|
||||
thermal_zone.view_factors_matrix = view_factors_matrix
|
||||
|
||||
@staticmethod
|
||||
def _create_storeys(building, archetype, divide_in_storeys):
|
||||
building.average_storey_height = archetype.average_storey_height
|
||||
thermal_zones = StoreysGeneration(building, building.internal_zones[0],
|
||||
divide_in_storeys=divide_in_storeys).thermal_zones
|
||||
building.internal_zones[0].thermal_zones = thermal_zones
|
|
@ -48,7 +48,12 @@ class ConstructionHelper:
|
|||
}
|
||||
|
||||
_reference_city_to_nrcan_climate_zone = {
|
||||
'Montreal': '6'
|
||||
'Montreal': '6',
|
||||
'Levis': '7A'
|
||||
}
|
||||
|
||||
_reference_city_to_israel_climate_zone = {
|
||||
'Eilat': 'BWh'
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
|
@ -65,36 +70,31 @@ class ConstructionHelper:
|
|||
return standard
|
||||
|
||||
@staticmethod
|
||||
def city_to_reference_city(city):
|
||||
"""
|
||||
City name to reference city
|
||||
:param city: str
|
||||
:return: str
|
||||
"""
|
||||
# todo: Dummy function that needs to be implemented
|
||||
reference_city = 'Montreal'
|
||||
if city is not None:
|
||||
reference_city = 'Montreal'
|
||||
return reference_city
|
||||
|
||||
@staticmethod
|
||||
def city_to_nrel_climate_zone(city):
|
||||
def city_to_nrel_climate_zone(reference_city):
|
||||
"""
|
||||
City name to NREL climate zone
|
||||
:param city: str
|
||||
:param reference_city: str
|
||||
:return: str
|
||||
"""
|
||||
reference_city = ConstructionHelper.city_to_reference_city(city)
|
||||
# todo: finish dictionary implementation
|
||||
if reference_city not in ConstructionHelper._reference_city_to_nrel_climate_zone:
|
||||
reference_city = 'Baltimore'
|
||||
return ConstructionHelper._reference_city_to_nrel_climate_zone[reference_city]
|
||||
|
||||
@staticmethod
|
||||
def city_to_nrcan_climate_zone(city):
|
||||
def city_to_nrcan_climate_zone(reference_city):
|
||||
"""
|
||||
City name to NRCAN climate zone
|
||||
:param city: str
|
||||
:param reference_city: str
|
||||
:return: str
|
||||
"""
|
||||
reference_city = ConstructionHelper.city_to_reference_city(city)
|
||||
return ConstructionHelper._reference_city_to_nrcan_climate_zone[reference_city]
|
||||
|
||||
@staticmethod
|
||||
def city_to_israel_climate_zone(reference_city):
|
||||
"""
|
||||
City name to Israel climate zone
|
||||
:param reference_city: str
|
||||
:return: str
|
||||
"""
|
||||
return ConstructionHelper._reference_city_to_israel_climate_zone[reference_city]
|
||||
|
|
|
@ -25,7 +25,7 @@ class NrcanPhysicsParameters:
|
|||
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.name)
|
||||
self._climate_zone = ConstructionHelper.city_to_nrcan_climate_zone(city.climate_reference_city)
|
||||
|
||||
def enrich_buildings(self):
|
||||
"""
|
||||
|
|
|
@ -23,7 +23,7 @@ class NrelPhysicsParameters:
|
|||
def __init__(self, city, divide_in_storeys=False):
|
||||
self._city = city
|
||||
self._divide_in_storeys = divide_in_storeys
|
||||
self._climate_zone = ConstructionHelper.city_to_nrel_climate_zone(city.name)
|
||||
self._climate_zone = ConstructionHelper.city_to_nrel_climate_zone(city.climate_reference_city)
|
||||
|
||||
def enrich_buildings(self):
|
||||
"""
|
||||
|
|
|
@ -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.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
|
||||
|
||||
|
||||
class ConstructionFactory:
|
||||
|
@ -38,6 +39,15 @@ class ConstructionFactory:
|
|||
for building in self._city.buildings:
|
||||
building.level_of_detail.construction = 2
|
||||
|
||||
def _eilat(self):
|
||||
"""
|
||||
Enrich the city by using Eilat information
|
||||
"""
|
||||
EilatPhysicsParameters(self._city).enrich_buildings()
|
||||
self._city.level_of_detail.construction = 2
|
||||
for building in self._city.buildings:
|
||||
building.level_of_detail.construction = 2
|
||||
|
||||
def enrich(self):
|
||||
"""
|
||||
Enrich the city given to the class using the class given handler
|
||||
|
|
|
@ -51,3 +51,23 @@ class TestConstructionCatalog(TestCase):
|
|||
|
||||
with self.assertRaises(IndexError):
|
||||
catalog.get_entry('unknown')
|
||||
|
||||
def test_eilat_catalog(self):
|
||||
catalog = ConstructionCatalogFactory('eilat').catalog
|
||||
catalog_categories = catalog.names()
|
||||
constructions = catalog.names('constructions')
|
||||
windows = catalog.names('windows')
|
||||
materials = catalog.names('materials')
|
||||
self.assertEqual(9, len(constructions['constructions']))
|
||||
self.assertEqual(3, len(windows['windows']))
|
||||
self.assertEqual(553, len(materials['materials']))
|
||||
with self.assertRaises(ValueError):
|
||||
catalog.names('unknown')
|
||||
|
||||
# retrieving all the entries should not raise any exceptions
|
||||
for category in catalog_categories:
|
||||
for value in catalog_categories[category]:
|
||||
catalog.get_entry(value)
|
||||
|
||||
with self.assertRaises(IndexError):
|
||||
catalog.get_entry('unknown')
|
||||
|
|
|
@ -283,3 +283,47 @@ class TestConstructionFactory(TestCase):
|
|||
self.assertIsNotNone(thermal_boundary.layers, 'layers is none')
|
||||
self._check_thermal_openings(thermal_boundary)
|
||||
self._check_surfaces(thermal_boundary)
|
||||
|
||||
def test_nrcan_construction_factory(self):
|
||||
file = 'test.geojson'
|
||||
file_path = (self._example_path / file).resolve()
|
||||
city = GeometryFactory('geojson',
|
||||
path=file_path,
|
||||
height_field='citygml_me',
|
||||
year_of_construction_field='ANNEE_CONS',
|
||||
function_field='CODE_UTILI',
|
||||
function_to_hub=Dictionaries().montreal_function_to_hub_function).city
|
||||
ConstructionFactory('nrcan', city).enrich()
|
||||
|
||||
self._check_buildings(city)
|
||||
for building in city.buildings:
|
||||
for internal_zone in building.internal_zones:
|
||||
self._check_thermal_zones(internal_zone)
|
||||
for thermal_zone in internal_zone.thermal_zones:
|
||||
self._check_thermal_boundaries(thermal_zone)
|
||||
for thermal_boundary in thermal_zone.thermal_boundaries:
|
||||
self.assertIsNotNone(thermal_boundary.layers, 'layers is none')
|
||||
self._check_thermal_openings(thermal_boundary)
|
||||
self._check_surfaces(thermal_boundary)
|
||||
|
||||
def test_eilat_construction_factory(self):
|
||||
file = 'eilat.geojson'
|
||||
file_path = (self._example_path / file).resolve()
|
||||
city = GeometryFactory('geojson',
|
||||
path=file_path,
|
||||
height_field='heightmax',
|
||||
year_of_construction_field='ANNEE_CONS',
|
||||
function_field='CODE_UTILI',
|
||||
function_to_hub=Dictionaries().eilat_function_to_hub_function).city
|
||||
ConstructionFactory('eilat', city).enrich()
|
||||
|
||||
self._check_buildings(city)
|
||||
for building in city.buildings:
|
||||
for internal_zone in building.internal_zones:
|
||||
self._check_thermal_zones(internal_zone)
|
||||
for thermal_zone in internal_zone.thermal_zones:
|
||||
self._check_thermal_boundaries(thermal_zone)
|
||||
for thermal_boundary in thermal_zone.thermal_boundaries:
|
||||
self.assertIsNotNone(thermal_boundary.layers, 'layers is none')
|
||||
self._check_thermal_openings(thermal_boundary)
|
||||
self._check_surfaces(thermal_boundary)
|
177
tests/tests_data/eilat.geojson
Normal file
177
tests/tests_data/eilat.geojson
Normal file
|
@ -0,0 +1,177 @@
|
|||
{
|
||||
"type": "FeatureCollection",
|
||||
"features": [
|
||||
{
|
||||
"type": "Feature",
|
||||
"id": 1,
|
||||
"properties": {
|
||||
"heightmax": 9,
|
||||
"ANNEE_CONS": 1978,
|
||||
"CODE_UTILI": "residential"
|
||||
},
|
||||
"geometry": {
|
||||
"coordinates": [
|
||||
[
|
||||
[
|
||||
34.95217088371581,
|
||||
29.56694805860026
|
||||
],
|
||||
[
|
||||
34.95262396587913,
|
||||
29.566952667742285
|
||||
],
|
||||
[
|
||||
34.95261999147337,
|
||||
29.567024109421467
|
||||
],
|
||||
[
|
||||
34.952169558914704,
|
||||
29.567019500282157
|
||||
],
|
||||
[
|
||||
34.95217088371581,
|
||||
29.56694805860026
|
||||
]
|
||||
]
|
||||
],
|
||||
"type": "Polygon"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Feature",
|
||||
"id": 3,
|
||||
"properties": {
|
||||
"heightmax": 16,
|
||||
"ANNEE_CONS": 2012,
|
||||
"CODE_UTILI": "dormitory"
|
||||
},
|
||||
"geometry": {
|
||||
"coordinates": [
|
||||
[
|
||||
[
|
||||
34.95176644317411,
|
||||
29.56827388702702
|
||||
],
|
||||
[
|
||||
34.95176550020565,
|
||||
29.568180388329026
|
||||
],
|
||||
[
|
||||
34.95179850408434,
|
||||
29.568180388329026
|
||||
],
|
||||
[
|
||||
34.95179850408434,
|
||||
29.5681303582886
|
||||
],
|
||||
[
|
||||
34.95176644317411,
|
||||
29.5681303582886
|
||||
],
|
||||
[
|
||||
34.95176644317411,
|
||||
29.568038499789708
|
||||
],
|
||||
[
|
||||
34.951874884488376,
|
||||
29.568038499789708
|
||||
],
|
||||
[
|
||||
34.951874884488376,
|
||||
29.568058183760357
|
||||
],
|
||||
[
|
||||
34.95192391882168,
|
||||
29.568058183760357
|
||||
],
|
||||
[
|
||||
34.951922032885705,
|
||||
29.56804178045124
|
||||
],
|
||||
[
|
||||
34.95205216246262,
|
||||
29.568042600617147
|
||||
],
|
||||
[
|
||||
34.952051219494166,
|
||||
29.568129538124154
|
||||
],
|
||||
[
|
||||
34.95201821561636,
|
||||
29.5681303582886
|
||||
],
|
||||
[
|
||||
34.95201821561636,
|
||||
29.568176287507143
|
||||
],
|
||||
[
|
||||
34.95204839059062,
|
||||
29.568176287507143
|
||||
],
|
||||
[
|
||||
34.95205027652662,
|
||||
29.56827552735433
|
||||
],
|
||||
[
|
||||
34.95195503676348,
|
||||
29.568274707190284
|
||||
],
|
||||
[
|
||||
34.95195597973188,
|
||||
29.56825830391628
|
||||
],
|
||||
[
|
||||
34.951849424353696,
|
||||
29.56825830391628
|
||||
],
|
||||
[
|
||||
34.951849424353696,
|
||||
29.568274707190284
|
||||
],
|
||||
[
|
||||
34.95176644317411,
|
||||
29.56827388702702
|
||||
]
|
||||
]
|
||||
],
|
||||
"type": "Polygon"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Feature",
|
||||
"id": 2,
|
||||
"properties": {
|
||||
"heightmax": 24,
|
||||
"ANNEE_CONS": 2002,
|
||||
"CODE_UTILI": "Hotel employ"
|
||||
},
|
||||
"geometry": {
|
||||
"coordinates": [
|
||||
[
|
||||
[
|
||||
34.94972280674813,
|
||||
29.566224752287738
|
||||
],
|
||||
[
|
||||
34.94974316291999,
|
||||
29.56597561012454
|
||||
],
|
||||
[
|
||||
34.94989147217407,
|
||||
29.565980668855033
|
||||
],
|
||||
[
|
||||
34.94987402402688,
|
||||
29.566233605043536
|
||||
],
|
||||
[
|
||||
34.94972280674813,
|
||||
29.566224752287738
|
||||
]
|
||||
]
|
||||
],
|
||||
"type": "Polygon"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
73
tests/tests_data/levis.geojson
Normal file
73
tests/tests_data/levis.geojson
Normal file
|
@ -0,0 +1,73 @@
|
|||
{
|
||||
"type": "FeatureCollection",
|
||||
"features": [
|
||||
{
|
||||
"type": "Feature",
|
||||
"id": 1,
|
||||
"properties": {
|
||||
"OBJECTID_12": 1,
|
||||
"gml_id": 1,
|
||||
"citygml_me": 20,
|
||||
"Z_Min": 46.1162,
|
||||
"Z_Max": 66.1162,
|
||||
"ANNEE_CONS": 2023,
|
||||
"CODE_UTILI": 1000
|
||||
},
|
||||
"geometry": {
|
||||
"coordinates": [
|
||||
[
|
||||
[
|
||||
-71.16553932594044,
|
||||
46.7895775031096
|
||||
],
|
||||
[
|
||||
-71.16535210635354,
|
||||
46.78972033813616
|
||||
],
|
||||
[
|
||||
-71.1654671126711,
|
||||
46.78979908036044
|
||||
],
|
||||
[
|
||||
-71.16525314742928,
|
||||
46.78995473325631
|
||||
],
|
||||
[
|
||||
-71.16480114585448,
|
||||
46.7896544143249
|
||||
],
|
||||
[
|
||||
-71.16486533542763,
|
||||
46.789394380725696
|
||||
],
|
||||
[
|
||||
-71.16467544127534,
|
||||
46.78927901330414
|
||||
],
|
||||
[
|
||||
-71.16454171299826,
|
||||
46.78930465053031
|
||||
],
|
||||
[
|
||||
-71.16445612690187,
|
||||
46.789766118513455
|
||||
],
|
||||
[
|
||||
-71.16519698155322,
|
||||
46.79023673853192
|
||||
],
|
||||
[
|
||||
-71.16583887727946,
|
||||
46.78976794972763
|
||||
],
|
||||
[
|
||||
-71.16553932594044,
|
||||
46.7895775031096
|
||||
]
|
||||
]
|
||||
],
|
||||
"type": "Polygon"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue
Block a user