lca_carbon_workflow/lca_carbon_workflow.py

78 lines
2.9 KiB
Python

"""
lca_carbon_workflow module
Returns the summarize of envelope and energy systems
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2024 Concordia CERC group
Code contributors: Alireza Adli alireza.adli@concordia.ca
Mohammad Reza Seyedabadi mohammad.seyedabadi@mail.concordia.ca
"""
from pathlib import Path
from hub.imports.geometry_factory import GeometryFactory
from hub.imports.construction_factory import ConstructionFactory
from hub.helpers.dictionaries import Dictionaries
from city_model_structure.life_cycle_assessment.access_nrcan_catalogue \
import AccessNrcanCatalog
from city_model_structure.life_cycle_assessment.building_component \
import BuildingComponent
class LCACarbonWorkflow:
def __init__(
self,
city_path,
archetypes_catalog_file_name,
constructions_catalog_file,
catalog='nrcan',
building_parameters=('height', 'year_of_construction', 'function')):
self.file_path = (Path(__file__).parent / 'input_files' / city_path)
self.catalogs_path = (Path(__file__).parent / 'input_files')
self.archetypes_catalog_file_name = archetypes_catalog_file_name
self.constructions_catalog_file = constructions_catalog_file
self.nrcan_catalogs = AccessNrcanCatalog(
self.catalogs_path,
archetypes=self.archetypes_catalog_file_name,
constructions=self.constructions_catalog_file)
self.out_path = (Path(__file__).parent / 'out_files')
self.handler = catalog
self.height, self.year_of_construction, self.function = \
building_parameters
print('[simulation start]')
self.city = GeometryFactory(
'geojson',
path=self.file_path,
height_field=self.height,
year_of_construction_field=self.year_of_construction,
function_field=self.function,
function_to_hub=Dictionaries().montreal_function_to_hub_function).city
print(f'city created from {self.file_path}')
ConstructionFactory(self.handler, self.city).enrich()
def calculate_opening_emission(self, building):
surface_emission = []
opaque_code = self.nrcan_catalogs.find_opaque_surface(
building.function, building.year_of_construction, '6')
print(building.function, building.year_of_construction)
print(opaque_code)
for surface in building.surfaces:
for boundary in surface.associated_thermal_boundaries:
if boundary.window_ratio == 0:
opening_surface = 0
opening_material_emission = 0
# print('window = 0')
else:
opening_surface = 0
opening_material_emission = 0
# print('window != 0')
# for opening in surface.associated_thermal_boundaries.thermal_openings:
# opening_surface += opening.area
# opening_material_emission =
def calculate_emission(self):
emitted_carbon = []
for building in self.city.buildings:
self.calculate_opening_emission(building)