2022-03-24 09:22:39 -04:00
|
|
|
import sys
|
|
|
|
from pathlib import Path
|
|
|
|
import csv
|
2022-06-07 13:18:07 -04:00
|
|
|
|
2022-05-11 07:34:24 -04:00
|
|
|
sys.path.append('../hub')
|
2022-06-07 13:18:07 -04:00
|
|
|
sys.path.append('./')
|
|
|
|
|
|
|
|
from imports.customized_imports_factory import CustomizedImportsFactory
|
|
|
|
from imports.customized_imports.stochastic_schedules_importer import StochasticSchedulesImporter as ssi
|
|
|
|
from imports.geometry_factory import GeometryFactory
|
|
|
|
from imports.construction_factory import ConstructionFactory
|
|
|
|
from imports.usage_factory import UsageFactory
|
|
|
|
from exports.exports_factory import ExportsFactory
|
2022-03-24 09:22:39 -04:00
|
|
|
|
2022-06-07 13:18:07 -04:00
|
|
|
try:
|
|
|
|
gml = ''
|
2022-05-11 07:34:24 -04:00
|
|
|
for argument_tuple in sys.argv[1:]:
|
2022-06-07 13:18:07 -04:00
|
|
|
print(argument_tuple)
|
2022-05-11 07:34:24 -04:00
|
|
|
argument = argument_tuple.split(' ')
|
|
|
|
option = argument[0]
|
|
|
|
value = argument[1]
|
|
|
|
if option == '-g':
|
|
|
|
gml = value
|
2022-03-24 09:22:39 -04:00
|
|
|
|
2022-05-11 07:34:24 -04:00
|
|
|
print('[simulation start]')
|
|
|
|
city = GeometryFactory('citygml', gml).city
|
|
|
|
print(f'city created from {gml}')
|
|
|
|
for building in city.buildings:
|
|
|
|
building.year_of_construction = 2006
|
2022-06-07 13:18:07 -04:00
|
|
|
if building.function is None:
|
|
|
|
building.function = 'large office'
|
2022-05-11 07:34:24 -04:00
|
|
|
ConstructionFactory('nrel', city).enrich()
|
|
|
|
print('enrich constructions... done')
|
|
|
|
UsageFactory('comnet', city).enrich()
|
|
|
|
print('enrich usage... done')
|
|
|
|
in_path = (Path(__file__).parent.parent / 'data' / 'occupancyschedules_2019_point4.xlsx')
|
|
|
|
CustomizedImportsFactory(ssi, city, in_path).enrich()
|
|
|
|
print('enrich stochastic schedules for occupancy... done')
|
2022-03-24 09:22:39 -04:00
|
|
|
|
2022-05-11 07:34:24 -04:00
|
|
|
area = 0
|
|
|
|
volume = 0
|
|
|
|
for building in city.buildings:
|
|
|
|
volume = building.volume
|
|
|
|
for ground in building.grounds:
|
|
|
|
area += ground.perimeter_polygon.area
|
2022-03-24 09:22:39 -04:00
|
|
|
|
2022-05-11 07:34:24 -04:00
|
|
|
print('exporting:')
|
|
|
|
out_path = (Path(__file__).parent.parent / 'out_files')
|
|
|
|
ExportsFactory('obj', city, out_path).export()
|
|
|
|
print(' geometry exported...')
|
|
|
|
# todo: _idf exporter does not catch errors in exporting
|
|
|
|
_idf = ExportsFactory('idf', city, out_path).export_debug()
|
|
|
|
print(' idf exported...')
|
|
|
|
_idf.run()
|
2022-03-24 09:22:39 -04:00
|
|
|
|
2022-05-11 07:34:24 -04:00
|
|
|
csv_file = str((out_path / f'{city.name}_out.csv').resolve())
|
|
|
|
eso_file = str((out_path / f'{city.name}_out.eso').resolve())
|
|
|
|
idf_file = str((out_path / f'{city.name}.idf').resolve())
|
|
|
|
obj_file = str((out_path / f'{city.name}.obj').resolve())
|
2022-03-24 09:22:39 -04:00
|
|
|
|
2022-05-11 07:34:24 -04:00
|
|
|
with open((out_path / f'{city.name}_out.csv').resolve()) as f:
|
|
|
|
reader = csv.reader(f, delimiter=',')
|
|
|
|
for row in reader:
|
|
|
|
if ':00:00' in row[0]:
|
|
|
|
print(f'row: {row[0]}, {row[8]}, {row[9]}')
|
2022-03-24 09:22:39 -04:00
|
|
|
|
2022-05-11 07:34:24 -04:00
|
|
|
print(f'info: {idf_file}, {csv_file}, {eso_file}, {area}, {volume}, {obj_file}')
|
|
|
|
print('[simulation end]')
|
2022-06-07 13:18:07 -04:00
|
|
|
|
2022-05-11 07:34:24 -04:00
|
|
|
except Exception as ex:
|
2022-06-07 13:18:07 -04:00
|
|
|
print(ex)
|
2022-05-11 07:34:24 -04:00
|
|
|
print('error: ', ex)
|
|
|
|
print('[simulation abort]')
|
2022-03-24 09:22:39 -04:00
|
|
|
sys.stdout.flush()
|