import sys from insel.insel import Insel from pathlib import Path from init import Init from simplified_radiosity_algorithm.simplified_radiosity_algorithm import SimplifiedRadiosityAlgorithm as Sra from weather.weather import Weather as Wt from insel.templates.thermal_demand_dynamic_simulation import ThermalDemandDynamicSimulation as Templates from helpers.simulation_parameters import SimulationParameters as Sp name_gml = '2050 bp_2buildings' name_cli = 'inseldb_New_York_City.cli' name_weather = 'inseldb_New_York_City.dat' example_path = (Path(__file__).parent / 'examples/NYC_2buildings').resolve() full_path_gml = (example_path / 'inputs' / (name_gml + '.gml')).resolve() full_path_cli = (example_path / 'inputs' / name_cli).resolve() full_path_weather = (example_path / 'inputs' / name_weather).resolve() outputs_path = (example_path / 'outputs').resolve() keep_files = True # Initialize the city model and add thermal- and usage-related parameters # todo: add several steps: # - simplification of the data model (for all work-flows) # - internal zoning of buildings (for dynamic simulation only) city = Init(full_path_gml).city for city_object in city.city_objects: print(city_object.usage_zones) # Climate-related parameters # todo: define full_path_cli and any other weather related parameter according to the city_name in city hourly_temperatures = Wt(full_path_weather).weather_temperatures sra_working_path = (example_path / 'third_party_files/sra').resolve() sra_file_name = 'SRA' sra = Sra(sra_working_path, sra_file_name, full_path_cli, city.city_objects, lower_corner=city.lower_corner) # todo: change this with if sra_file_exists. Using it now only internally. sra_calculated = True if sra_calculated: sra.results() else: sra.call_sra(keep_files=keep_files) sra.set_irradiance_surfaces(city) # Demand calculation (one model per building) for city_object in city.city_objects: full_path_out = (outputs_path / (city_object.name + '_insel.out')).resolve() (example_path / 'third_party_files/sra').resolve() full_path_wea = (example_path / 'third_party_files/insel' / (city_object.name + '.weather')).resolve() full_path_ig = (example_path / 'third_party_files/insel' / (city_object.name + '.ig')).resolve() insel_file_name = city_object.name + '.insel' try: content = Templates.generate_thermal_dynamic_template(city_object, full_path_out, full_path_wea, full_path_ig, Sp) insel = Insel(example_path, insel_file_name, content, mode=2, keep_files=keep_files).results except: print(sys.exc_info()[1]) print('Building ' + city_object.name + ' could not be processed') continue