2020-05-19 17:00:15 -04:00
|
|
|
import sys
|
|
|
|
from insel.insel import Insel
|
2020-05-01 13:59:09 -04:00
|
|
|
from pathlib import Path
|
2020-05-19 11:22:15 -04:00
|
|
|
from init import Init
|
|
|
|
from simplified_radiosity_algorithm.simplified_radiosity_algorithm import SimplifiedRadiosityAlgorithm as Sra
|
|
|
|
from weather.weather import Weather as Wt
|
2020-05-19 17:00:15 -04:00
|
|
|
from insel.templates.thermal_demand_dynamic_simulation import ThermalDemandDynamicSimulation as Templates
|
|
|
|
from helpers.simulation_parameters import SimulationParameters as Sp
|
2020-05-01 13:59:09 -04:00
|
|
|
|
2020-05-19 17:00:15 -04:00
|
|
|
name_gml = '2050 bp_2buildings'
|
2020-05-01 13:59:09 -04:00
|
|
|
name_cli = 'inseldb_New_York_City.cli'
|
|
|
|
name_weather = 'inseldb_New_York_City.dat'
|
2020-05-19 17:00:15 -04:00
|
|
|
example_path = (Path(__file__).parent / 'examples/NYC_2buildings').resolve()
|
2020-06-04 12:47:48 -04:00
|
|
|
full_path_gml = (example_path / 'inputs' / ('buildings.gml')).resolve()
|
2020-05-01 18:33:06 -04:00
|
|
|
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
|
2020-05-01 13:59:09 -04:00
|
|
|
# todo: add several steps:
|
|
|
|
# - simplification of the data model (for all work-flows)
|
|
|
|
# - internal zoning of buildings (for dynamic simulation only)
|
2020-05-19 11:22:15 -04:00
|
|
|
city = Init(full_path_gml).city
|
2020-05-01 13:59:09 -04:00
|
|
|
|
2020-05-01 18:33:06 -04:00
|
|
|
# Climate-related parameters
|
2020-05-01 13:59:09 -04:00
|
|
|
# todo: define full_path_cli and any other weather related parameter according to the city_name in city
|
2020-05-19 11:22:15 -04:00
|
|
|
hourly_temperatures = Wt(full_path_weather).weather_temperatures
|
2020-05-19 17:00:15 -04:00
|
|
|
sra_working_path = (example_path / 'third_party_files/sra').resolve()
|
|
|
|
sra_file_name = 'SRA'
|
2020-05-19 11:22:15 -04:00
|
|
|
sra = Sra(sra_working_path, sra_file_name, full_path_cli, city.city_objects, lower_corner=city.lower_corner)
|
2020-05-01 18:33:06 -04:00
|
|
|
# todo: change this with if sra_file_exists. Using it now only internally.
|
2020-05-19 17:00:15 -04:00
|
|
|
|
2020-05-01 18:33:06 -04:00
|
|
|
sra_calculated = True
|
2020-05-19 11:22:15 -04:00
|
|
|
if sra_calculated:
|
|
|
|
sra.results()
|
|
|
|
else:
|
|
|
|
sra.call_sra(keep_files=keep_files)
|
|
|
|
sra.set_irradiance_surfaces(city)
|
2020-05-01 13:59:09 -04:00
|
|
|
|
2020-05-01 18:33:06 -04:00
|
|
|
# Demand calculation (one model per building)
|
2020-05-19 17:00:15 -04:00
|
|
|
for city_object in city.city_objects:
|
2020-05-26 17:15:48 -04:00
|
|
|
full_path_out = (outputs_path / city_object.name).resolve()
|
2020-05-19 17:00:15 -04:00
|
|
|
(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()
|
2020-05-19 17:23:29 -04:00
|
|
|
|
2020-05-19 17:00:15 -04:00
|
|
|
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
|