""" Peak loads calculation workflow 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 glob import os import sys from pathlib import Path import helpers.constants as cte from imports.geometry_factory import GeometryFactory from imports.construction_factory import ConstructionFactory from imports.usage_factory import UsageFactory from loads_calculation import LoadsCalculation try: gml = '' for argument_tuple in sys.argv[1:]: print(argument_tuple) argument = argument_tuple.split(' ') option = argument[0] value = argument[1] if option == '-g': gml = value out_path = (Path(__file__).parent.parent / 'out_files') files = glob.glob(f'{out_path}/*') for file in files: if file != '.gitignore': os.remove(file) print('[simulation start]') city = GeometryFactory('citygml', gml).city print(f'city created from {gml}') for building in city.buildings: building.year_of_construction = 2006 if building.function is None: building.function = 'large office' ConstructionFactory('nrel', city).enrich() print('enrich constructions... done') UsageFactory('comnet', city).enrich() print('enrich usage... done') print('calculating:') weather_format = 'epw' for building in city.buildings: ambient_temperature = building.external_temperature[cte.HOUR][[weather_format]] ground_temperature = 0 heating_ambient_temperature = 100 cooling_ambient_temperature = -100 heating_calculation_hour = -1 cooling_calculation_hour = -1 for hour, temperature in enumerate(ambient_temperature): ground_temperature += temperature / 8760 if temperature < heating_ambient_temperature: heating_ambient_temperature = temperature heating_calculation_hour = hour if temperature > cooling_ambient_temperature: cooling_ambient_temperature = temperature cooling_calculation_hour = hour loads = LoadsCalculation(building) heating_load_transmitted = loads.get_heating_transmitted_load(heating_ambient_temperature, ground_temperature) heating_load_ventilation_sensible = loads.get_heating_ventilation_load_sensible(heating_ambient_temperature) heating_load_ventilation_latent = 0 heating_load = heating_load_transmitted + heating_load_ventilation_sensible + heating_load_ventilation_latent cooling_load_transmitted = loads.get_cooling_transmitted_load(cooling_ambient_temperature, ground_temperature) cooling_load_renovation_sensible = loads.get_cooling_ventilation_load_sensible(cooling_ambient_temperature) cooling_load_internal_gains_sensible = loads.get_internal_load_sensible() cooling_load_radiation = loads.get_radiation_load(cooling_calculation_hour) cooling_load_sensible = cooling_load_transmitted + cooling_load_renovation_sensible + cooling_load_radiation \ + cooling_load_internal_gains_sensible cooling_load_latent = 0 cooling_load = cooling_load_sensible + cooling_load_latent print('[calculation end]') except Exception as ex: print(ex) print('error: ', ex) print('[simulation abort]') sys.stdout.flush()