system_assignation/imports/construction/us_physics_parameters.py

110 lines
6.0 KiB
Python

"""
UsPhysicsParameters import the construction and material information for US
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
Contributors Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
"""
import sys
from imports.construction.nrel_physics_interface import NrelPhysicsInterface
from imports.construction.helpers.construction_helper import ConstructionHelper
from city_model_structure.building_demand.layer import Layer
from city_model_structure.building_demand.material import Material
from imports.construction.helpers.storeys_generation import StoreysGeneration
class UsPhysicsParameters(NrelPhysicsInterface):
"""
UsPhysicsParameters class
"""
def __init__(self, city, base_path):
self._city = city
self._climate_zone = ConstructionHelper.city_to_nrel_climate_zone(city.name)
super().__init__(base_path, 'us_constructions.xml', 'us_archetypes.xml')
def enrich_buildings(self):
"""
Returns the city with the construction parameters assigned to the buildings
:return: None
"""
city = self._city
# it is assumed that all buildings have the same archetypes' keys
for building in city.buildings:
building_type = ConstructionHelper.nrel_from_function(building.function)
if building_type is None:
return
archetype = self._search_archetype(building_type,
ConstructionHelper.yoc_to_nrel_standard(building.year_of_construction),
self._climate_zone)
if archetype is None:
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')
continue
self._create_storeys(building, archetype)
self._assign_values(building, archetype)
def _search_archetype(self, building_type, standard, climate_zone):
for building_archetype in self._building_archetypes:
a_yc = str(building_archetype.archetype_keys['@reference_standard'])
a_bt = str(building_archetype.archetype_keys['@building_type'])
a_cz = str(building_archetype.archetype_keys['@climate_zone'])
if (a_yc == str(standard)) and (a_bt == str(building_type)) and (a_cz == str(climate_zone)):
return building_archetype
return None
def _assign_values(self, building, archetype):
for thermal_zone in building.thermal_zones:
thermal_zone.additional_thermal_bridge_u_value = archetype.additional_thermal_bridge_u_value
thermal_zone.effective_thermal_capacity = archetype.effective_thermal_capacity
thermal_zone.indirectly_heated_area_ratio = archetype.indirectly_heated_area_ratio
thermal_zone.infiltration_rate_system_on = archetype.infiltration_rate_system_on
thermal_zone.infiltration_rate_system_off = archetype.infiltration_rate_system_off
for thermal_boundary in thermal_zone.thermal_boundaries:
construction_type = ConstructionHelper.nrel_construction_types[thermal_boundary.type]
thermal_boundary_archetype = self._search_construction_in_archetype(archetype, construction_type)
if thermal_boundary_archetype.outside_solar_absorptance is not None:
thermal_boundary.outside_solar_absorptance = thermal_boundary_archetype.outside_solar_absorptance
thermal_boundary.outside_thermal_absorptance = thermal_boundary_archetype.outside_thermal_absorptance
thermal_boundary.outside_visible_absorptance = thermal_boundary_archetype.outside_visible_absorptance
thermal_boundary.construction_name = thermal_boundary_archetype.construction_name
thermal_boundary.window_ratio = thermal_boundary_archetype.window_ratio
thermal_boundary.layers = []
for layer_archetype in thermal_boundary_archetype.layers:
layer = Layer()
layer.thickness = layer_archetype.thickness
material = Material()
material.name = layer_archetype.name
material.no_mass = layer_archetype.no_mass
material.density = layer_archetype.density
material.conductivity = layer_archetype.conductivity
material.specific_heat = layer_archetype.specific_heat
material.solar_absorptance = layer_archetype.solar_absorptance
material.thermal_absorptance = layer_archetype.thermal_absorptance
material.visible_absorptance = layer_archetype.visible_absorptance
material.thermal_resistance = layer_archetype.thermal_resistance
if layer_archetype.lca_id is not None:
material.lca_id = layer_archetype.lca_id
layer.material = material
thermal_boundary.layers.append(layer)
for thermal_opening in thermal_boundary.thermal_openings:
if thermal_boundary_archetype.thermal_opening is not None:
thermal_opening_archetype = thermal_boundary_archetype.thermal_opening
thermal_opening.frame_ratio = thermal_opening_archetype.frame_ratio
thermal_opening.g_value = thermal_opening_archetype.g_value
thermal_opening.conductivity = thermal_opening_archetype.conductivity
thermal_opening.thickness = thermal_opening_archetype.thickness
thermal_opening.back_side_solar_transmittance_at_normal_incidence = \
thermal_opening_archetype.back_side_solar_transmittance_at_normal_incidence
thermal_opening.front_side_solar_transmittance_at_normal_incidence = \
thermal_opening_archetype.front_side_solar_transmittance_at_normal_incidence
@staticmethod
def _create_storeys(building, archetype):
building.average_storey_height = archetype.average_storey_height
building.storeys_above_ground = archetype.storeys_above_ground
storeys_generation = StoreysGeneration(building)
storeys = storeys_generation.storeys
building.storeys = storeys
storeys_generation.assign_thermal_zones_delimited_by_thermal_boundaries()