119 lines
6.0 KiB
Python
119 lines
6.0 KiB
Python
"""
|
|
UsPhysicsParameters import the construction and material information for US
|
|
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 sys
|
|
|
|
from imports.construction.nrel_physics_interface import NrelPhysicsInterface
|
|
from catalog_factories.construction.nrel_catalog import NrelCatalog
|
|
from city_model_structure.building_demand.layer import Layer
|
|
from city_model_structure.building_demand.material import Material
|
|
from imports.construction.helpers.construction_helper import ConstructionHelper
|
|
|
|
|
|
class UsPhysicsParameters(NrelPhysicsInterface):
|
|
"""
|
|
UsPhysicsParameters class
|
|
"""
|
|
def __init__(self, city, base_path):
|
|
self._city = city
|
|
self._path = base_path
|
|
self._climate_zone = ConstructionHelper.city_to_nrel_climate_zone(city.name)
|
|
super().__init__()
|
|
|
|
def enrich_buildings(self):
|
|
"""
|
|
Returns the city with the construction parameters assigned to the buildings
|
|
"""
|
|
city = self._city
|
|
for building in city.buildings:
|
|
try:
|
|
archetype = self._search_archetype(building.function, building.year_of_construction, self._climate_zone)
|
|
except KeyError:
|
|
sys.stderr.write(f'Building {building.name} has unknown archetype for building function: {building.function} '
|
|
f'and building year of construction: {building.year_of_construction}\n')
|
|
return
|
|
|
|
# if building has no thermal zones defined from geometry, 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._assign_values(building.internal_zones, archetype)
|
|
for internal_zone in building.internal_zones:
|
|
for thermal_zone in internal_zone.thermal_zones:
|
|
self._calculate_view_factors(thermal_zone)
|
|
|
|
def _search_archetype(self, function, year_of_construction, climate_zone):
|
|
nrel_archetypes = NrelCatalog(self._path).entries('archetypes')
|
|
for building_archetype in nrel_archetypes:
|
|
construction_period_limits = building_archetype.construction_period.split(' - ')
|
|
if construction_period_limits[1] == 'PRESENT':
|
|
construction_period_limits[1] = 3000
|
|
if int(construction_period_limits[0]) <= 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
|
|
return None
|
|
|
|
@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, internal_zones, archetype):
|
|
for internal_zone in internal_zones:
|
|
for thermal_zone in internal_zone.thermal_zones:
|
|
thermal_zone.additional_thermal_bridge_u_value = archetype.extra_loses_due_to_thermal_bridges
|
|
thermal_zone.effective_thermal_capacity = archetype.thermal_capacity
|
|
thermal_zone.indirectly_heated_area_ratio = archetype.indirect_heated_ratio
|
|
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)
|
|
print('wa', construction_archetype.window)
|
|
thermal_boundary.construction_name = construction_archetype.name
|
|
try:
|
|
thermal_boundary.window_ratio = construction_archetype.window_ratio
|
|
except ValueError:
|
|
# This is the normal operation way when the windows are defined in the geometry
|
|
continue
|
|
thermal_boundary.layers = []
|
|
for layer_archetype in construction_archetype.layers:
|
|
layer = Layer()
|
|
layer.thickness = layer_archetype.thickness
|
|
material = Material()
|
|
archetype_material = layer_archetype.material
|
|
material.name = layer_archetype.name
|
|
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
|
|
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)
|
|
# The agreement is that the layers are defined from outside to inside
|
|
external_layer = construction_archetype.layers[0]
|
|
thermal_boundary.outside_solar_absorptance = external_layer.material.solar_absorptance
|
|
thermal_boundary.outside_thermal_absorptance = external_layer.material.thermal_absorptance
|
|
thermal_boundary.outside_visible_absorptance = external_layer.material.visible_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
|