2023-01-10 12:12:01 -05:00
|
|
|
"""
|
|
|
|
Main
|
|
|
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
|
|
|
Copyright © 2021 Project Author name guillermo.gutierrezmorote@concordia.ca
|
2023-01-10 17:24:26 -05:00
|
|
|
Project Collaborator name peteryefi@gmail.com
|
2023-01-10 12:12:01 -05:00
|
|
|
"""
|
|
|
|
|
|
|
|
from catalog_factories.construction_catalog_factory import ConstructionCatalogFactory
|
|
|
|
from catalog_factories.greenery_catalog_factory import GreeneryCatalogFactory
|
|
|
|
from catalog_factories.usage_catalog_factory import UsageCatalogFactory
|
|
|
|
from imports.construction_factory import ConstructionFactory
|
|
|
|
from imports.geometry_factory import GeometryFactory
|
|
|
|
from imports.life_cycle_assessment_factory import LifeCycleAssessment
|
2023-01-16 15:31:02 -05:00
|
|
|
# from imports.schedules_factory import SchedulesFactory
|
2023-01-10 12:12:01 -05:00
|
|
|
from imports.usage_factory import UsageFactory
|
|
|
|
from imports.weather_factory import WeatherFactory
|
2023-01-10 17:24:26 -05:00
|
|
|
from flask import Response
|
2023-01-10 12:12:01 -05:00
|
|
|
import hub_api.helpers.session_helper as sh
|
2023-01-10 17:24:26 -05:00
|
|
|
import datetime
|
|
|
|
from pathlib import Path
|
|
|
|
from bootstrap import app
|
2023-01-10 12:12:01 -05:00
|
|
|
|
|
|
|
sh.begin_time = datetime.datetime.now()
|
|
|
|
# initialize catalogs
|
|
|
|
sh.greenery_catalog = GreeneryCatalogFactory('nrel').catalog
|
|
|
|
sh.construction_catalog = ConstructionCatalogFactory('nrel').catalog
|
|
|
|
sh.usage_catalog = UsageCatalogFactory('comnet').catalog
|
|
|
|
|
|
|
|
# Enrich the city
|
|
|
|
data_path = (Path(__file__).parent / 'data').resolve()
|
|
|
|
rihno_path = (Path(data_path / 'dompark.3dm')).resolve()
|
|
|
|
city = GeometryFactory('rhino', rihno_path).city
|
|
|
|
|
|
|
|
for building in city.buildings:
|
|
|
|
# Rihno files have no information about the function or the year of construction
|
|
|
|
building.year_of_construction = 1995
|
|
|
|
building.function = 'industry'
|
|
|
|
building.human_readable_name = "Dompark"
|
|
|
|
|
|
|
|
ConstructionFactory('nrel', city).enrich()
|
|
|
|
UsageFactory('comnet', city).enrich()
|
2023-01-16 15:31:02 -05:00
|
|
|
# SchedulesFactory('comnet', city).enrich()
|
2023-01-10 12:12:01 -05:00
|
|
|
LifeCycleAssessment('material', city).enrich()
|
|
|
|
LifeCycleAssessment('machine', city).enrich()
|
|
|
|
LifeCycleAssessment('fuel', city).enrich()
|
|
|
|
LifeCycleAssessment('vehicle', city).enrich()
|
|
|
|
|
|
|
|
montreal_weather_file = (Path(__file__).parent / './data/CAN_PQ_Montreal.Intl.AP.716270_CWEC.epw').resolve()
|
|
|
|
city.climate_file = (data_path / f'{city.climate_reference_city}.cli').resolve()
|
|
|
|
WeatherFactory('epw', city, file_name=montreal_weather_file).enrich()
|
|
|
|
|
|
|
|
# Rihno files have no information about the building location
|
|
|
|
city.name = 'Montreal'
|
|
|
|
city.climate_reference_city = 'Montreal'
|
|
|
|
|
|
|
|
# SRA Calculations
|
|
|
|
|
|
|
|
for building in city.buildings:
|
|
|
|
building.heated = True
|
|
|
|
building.cooled = True
|
|
|
|
building.attic_heated = 0
|
|
|
|
building.basement_heated = 0
|
|
|
|
for surface in building.surfaces:
|
|
|
|
surface.swr = 0.2
|
|
|
|
|
|
|
|
# Pass the city to the session helper to be used as default status.
|
|
|
|
sh.city = city
|
|
|
|
|
2023-01-10 17:24:26 -05:00
|
|
|
|
2023-01-10 12:12:01 -05:00
|
|
|
@app.route("/")
|
|
|
|
def home():
|
|
|
|
return Response(headers={'Access-Control-Allow-Origin': '*'})
|
|
|
|
|
|
|
|
|
|
|
|
app.run(port=15789, host="0.0.0.0", debug=False)
|