forked from s_ranjbar/city_retrofit
erased not needed cerc_base_physics_parameters.py file
This commit is contained in:
parent
7e0840e759
commit
21bfbe28c0
|
@ -1,126 +0,0 @@
|
|||
"""
|
||||
CercBasePhysicParameters, reads the archetypes and materials following the format defined within the CERC team
|
||||
and models them
|
||||
It is used by many specific-region classes as base class
|
||||
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
||||
Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
|
||||
Contributors Pilar Monsalvete pilar_monsalvete@yahoo.es
|
||||
"""
|
||||
import xmltodict
|
||||
import sys
|
||||
|
||||
from city_model_structure.attributes.layer import Layer
|
||||
from city_model_structure.attributes.material import Material
|
||||
from factories.physics_feeders.helpers.us_to_library_types import UsToLibraryTypes
|
||||
|
||||
|
||||
class CercBasePhysicsParameters:
|
||||
"""
|
||||
CercBasePhysicsParameters class
|
||||
"""
|
||||
def __init__(self, climate_zone, buildings, function_to_type, base_path, constructions_file='us_constructions.xml',
|
||||
archetypes_file='us_archetypes.xml'):
|
||||
self._climate_zone = climate_zone
|
||||
self._buildings = buildings
|
||||
# load construction Library, CERC format
|
||||
path = str(base_path / constructions_file)
|
||||
with open(path) as xml:
|
||||
self._library = xmltodict.parse(xml.read(), force_list='layer')
|
||||
|
||||
# load archetypes Library, CERC format
|
||||
path = str(base_path / archetypes_file)
|
||||
with open(path) as xml:
|
||||
self._archetypes = xmltodict.parse(xml.read(), force_list='layer')
|
||||
for building in self._buildings:
|
||||
|
||||
building_type = function_to_type(building.function)
|
||||
if building_type is None:
|
||||
return
|
||||
archetype = self._search_archetype(building_type,
|
||||
UsToLibraryTypes.yoc_to_standard(building.year_of_construction),
|
||||
self._climate_zone)
|
||||
# ToDo: remove this in the future
|
||||
# ToDo: Raise WrongArchetype if not all the surface types are defined for the given city_object
|
||||
if archetype is None:
|
||||
sys.stderr.write('Building ' + building.name + ' has unknown archetype for building type: ' + building_type +
|
||||
'\n')
|
||||
sys.stderr.write('type: ' + building_type + ', ' +
|
||||
UsToLibraryTypes.yoc_to_standard(building.year_of_construction) + ', ' + self._climate_zone +
|
||||
'\n')
|
||||
continue
|
||||
|
||||
building.average_storey_height = archetype['average_storey_height']['#text']
|
||||
building.storeys_above_ground = archetype['number_of_storeys']['#text']
|
||||
|
||||
for thermal_zone in building.thermal_zones:
|
||||
thermal_zone.effective_thermal_capacity = archetype['thermal_capacity']['#text']
|
||||
thermal_zone.additional_thermal_bridge_u_value = archetype['extra_loses_due_to_thermal_bridges']['#text']
|
||||
thermal_zone.indirectly_heated_area_ratio = archetype['indirect_heated_ratio']['#text']
|
||||
thermal_zone.infiltration_rate_system_off = archetype['infiltration_rate_for_ventilation_system_off']['#text']
|
||||
thermal_zone.infiltration_rate_system_on = archetype['infiltration_rate_for_ventilation_system_on']['#text']
|
||||
for thermal_boundary in thermal_zone.bounded:
|
||||
construction_type = UsToLibraryTypes.construction_types[thermal_boundary.type]
|
||||
construction = self._search_construction_in_archetype(archetype, construction_type)
|
||||
construction_id = construction['@id']
|
||||
|
||||
c_lib = self._search_construction_type('construction', construction_id)
|
||||
if 'outside_solar_absorptance' in c_lib:
|
||||
thermal_boundary.outside_solar_absorptance = c_lib['outside_solar_absorptance']['#text']
|
||||
thermal_boundary.outside_thermal_absorptance = c_lib['outside_thermal_absorptance']['#text']
|
||||
thermal_boundary.outside_visible_absorptance = c_lib['outside_visible_absorptance']['#text']
|
||||
thermal_boundary.window_ratio = construction['window_ratio']['#text']
|
||||
thermal_boundary.construction_name = c_lib['@name']
|
||||
thermal_boundary.layers = []
|
||||
for current_layer in c_lib['layers']['layer']:
|
||||
layer = Layer()
|
||||
if 'thickness' in current_layer:
|
||||
layer.thickness = current_layer['thickness']['#text']
|
||||
material_lib = self._search_construction_type('material', current_layer['material'])
|
||||
material = Material()
|
||||
if 'conductivity' in material_lib:
|
||||
material.conductivity = material_lib['conductivity']['#text']
|
||||
material.specific_heat = material_lib['specific_heat']['#text']
|
||||
material.density = material_lib['density']['#text']
|
||||
material.solar_absorptance = material_lib['solar_absorptance']['#text']
|
||||
material.thermal_absorptance = material_lib['thermal_absorptance']['#text']
|
||||
material.visible_absorptance = material_lib['visible_absorptance']['#text']
|
||||
material.no_mass = 'no_mass' in material_lib
|
||||
material.name = material_lib['@name']
|
||||
if 'thermal_resistance' in material_lib:
|
||||
material.thermal_resistance = material_lib['thermal_resistance']['#text']
|
||||
layer.material = material
|
||||
thermal_boundary.layers.append(layer)
|
||||
for opening in thermal_boundary.thermal_openings:
|
||||
if construction['window'] is None:
|
||||
continue
|
||||
w_lib = self._search_construction_type('window', construction['window'])
|
||||
opening.conductivity = w_lib['conductivity']['#text']
|
||||
opening.frame_ratio = w_lib['frame_ratio']['#text']
|
||||
opening.g_value = w_lib['solar_transmittance_at_normal_incidence']['#text']
|
||||
opening.thickness = w_lib['thickness']['#text']
|
||||
opening.back_side_solar_transmittance_at_normal_incidence = \
|
||||
w_lib['back_side_solar_transmittance_at_normal_incidence']['#text']
|
||||
opening.front_side_solar_transmittance_at_normal_incidence = \
|
||||
w_lib['front_side_solar_transmittance_at_normal_incidence']['#text']
|
||||
|
||||
def _search_archetype(self, building_type, standard, climate_zone):
|
||||
for archetype in self._archetypes['archetypes']['archetype']:
|
||||
a_yc = str(archetype['@reference_standard'])
|
||||
a_bt = str(archetype['@building_type'])
|
||||
a_cz = str(archetype['@climate_zone'])
|
||||
if (a_yc == str(standard)) and (a_bt == str(building_type)) and (a_cz == str(climate_zone)):
|
||||
return archetype
|
||||
return None
|
||||
|
||||
def _search_construction_type(self, construction_type, construction_id):
|
||||
for c_lib in self._library['library'][construction_type + 's'][construction_type]:
|
||||
if construction_id == c_lib['@id']:
|
||||
return c_lib
|
||||
raise Exception('Archetype definition contains elements that does not exist in the library')
|
||||
|
||||
@staticmethod
|
||||
def _search_construction_in_archetype(archetype, construction_type):
|
||||
for construction in archetype['constructions']['construction']:
|
||||
if construction['@type'] == construction_type:
|
||||
return construction
|
||||
raise Exception('Construction type not found')
|
|
@ -12,7 +12,7 @@ from city_model_structure.attributes.layer import Layer
|
|||
from city_model_structure.attributes.material import Material
|
||||
|
||||
|
||||
class UsNewYorkCityPhysicsParameters(NrelPhysicsInterface):
|
||||
class UsPhysicsParameters(NrelPhysicsInterface):
|
||||
"""
|
||||
UsPhysicsParameters class
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue
Block a user