Put opening emission in a method

This commit is contained in:
Alireza Adli 2024-07-20 10:39:33 -04:00
parent d79685123e
commit 814a110904

View File

@ -51,7 +51,7 @@ class LCACarbonWorkflow:
print(f'city created from {self.file_path}') print(f'city created from {self.file_path}')
ConstructionFactory(self.handler, self.city).enrich() ConstructionFactory(self.handler, self.city).enrich()
def calculate_opening_emission(self, building): def calculate_building_component_emission(self, building):
surface_opening_emission = [] surface_opening_emission = []
period_of_construction = self.nrcan_catalogs.year_to_period_of_construction(building.year_of_construction) period_of_construction = self.nrcan_catalogs.year_to_period_of_construction(building.year_of_construction)
print(period_of_construction) print(period_of_construction)
@ -72,6 +72,19 @@ class LCACarbonWorkflow:
# print('window = 0') # print('window = 0')
else: else:
print('window != 0') print('window != 0')
opening_emission = self._calculate_opening_emission(
building, surface, boundary, opaque_surface_code)
if opening_emission:
boundary_opening_emission += opening_emission
print('boundary_opening_emission', boundary_opening_emission)
if boundary_opening_emission:
surface_opening_emission += boundary_opening_emission
building_opening_emission = sum(surface_opening_emission)
print(building_opening_emission)
def _calculate_opening_emission(
self, building, surface, boundary, opaque_surface_code):
opening_emission = []
for opening in boundary.thermal_openings: for opening in boundary.thermal_openings:
transparent_surface_type = 'Window' transparent_surface_type = 'Window'
if building.year_of_construction >= 2020 and \ if building.year_of_construction >= 2020 and \
@ -81,17 +94,10 @@ class LCACarbonWorkflow:
self.nrcan_catalogs.search_transparent_surfaces( self.nrcan_catalogs.search_transparent_surfaces(
transparent_surface_type, opaque_surface_code)['embodied_carbon'], transparent_surface_type, opaque_surface_code)['embodied_carbon'],
opening.area).calculate_opening_emission()) opening.area).calculate_opening_emission())
print('\t\t\t', opening_emission) return opening_emission
print('opening_emission', opening_emission)
if opening_emission:
boundary_opening_emission += opening_emission
print('boundary_opening_emission', boundary_opening_emission)
if boundary_opening_emission:
surface_opening_emission += boundary_opening_emission
print('surface_opening_emission', surface_opening_emission, '\n', sum(surface_opening_emission))
def calculate_emission(self): def calculate_emission(self):
emitted_carbon = [] emitted_carbon = []
opening_emission = [] opening_emission = []
for building in self.city.buildings: for building in self.city.buildings:
self.calculate_opening_emission(building) self.calculate_building_component_emission(building)