Oriol changes. Not working, trying to understand the logic of the workflow
This commit is contained in:
parent
8ce8a098f3
commit
483c24b19e
|
@ -2,36 +2,68 @@
|
||||||
LifeCycleCosts calculates the life cycle costs of one building
|
LifeCycleCosts calculates the life cycle costs of one building
|
||||||
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
||||||
Copyright © 2022 Project Author Pilar Monsalvete Alvarez de Uribarri pilar_monsalvete@concordia.ca
|
Copyright © 2022 Project Author Pilar Monsalvete Alvarez de Uribarri pilar_monsalvete@concordia.ca
|
||||||
|
Project contributor 2023 Author Oriol Gavaldà Torrellas oriol.gavalda@concordia.ca
|
||||||
"""
|
"""
|
||||||
import math
|
import math
|
||||||
|
import hub.catalog_factories.costs_catalog_factory as CostCatalogFactory
|
||||||
|
from hub.catalog_factories.cost.montreal_custom_catalog import MontrealCustomCatalog
|
||||||
|
from hub.helpers.dictionaries import Dictionaries
|
||||||
|
|
||||||
|
|
||||||
class LifeCycleCosts:
|
class LifeCycleCosts:
|
||||||
|
|
||||||
# todo: this should be (city, costs_catalog) or similar
|
# todo: this should be (city, costs_catalog) or similar
|
||||||
def __init__(self, building, number_of_years, consumer_price_index, discount_rate, end_of_life_cost,
|
def __init__(self, city, number_of_years, consumer_price_index, discount_rate,
|
||||||
capital_costs_at_year_0, items, fuels, concepts):
|
retrofitting_scenario):
|
||||||
self._building = building
|
self._city = city
|
||||||
self._number_of_years = number_of_years
|
self._number_of_years = number_of_years
|
||||||
self._consumer_price_index = consumer_price_index
|
self._consumer_price_index = consumer_price_index
|
||||||
self._discount_rate = discount_rate
|
self._discount_rate = discount_rate
|
||||||
|
self._cost_catalog=CostCatalogFactory('montreal_custom').catalog
|
||||||
self._end_of_life_cost = end_of_life_cost
|
self._end_of_life_cost = 0
|
||||||
|
self._capital_costs_at_year_0 = 0
|
||||||
self._capital_costs_at_year_0 = capital_costs_at_year_0
|
self._items = 0
|
||||||
self._items = items
|
self._fuels = 0
|
||||||
|
self._concepts = 0
|
||||||
self._fuels = fuels
|
self._retrofitting_scenario = retrofitting_scenario
|
||||||
|
|
||||||
self._concepts = concepts
|
|
||||||
|
|
||||||
def calculate_capital_costs(self):
|
def calculate_capital_costs(self):
|
||||||
total_capital_costs = self._capital_costs_at_year_0
|
surface_opaque=0
|
||||||
for year in range(1, self._number_of_years + 1):
|
surface_transparent=0
|
||||||
costs_increase = math.pow(1 + self._consumer_price_index, year) / math.pow(1 + self._discount_rate, year)
|
city = self._city
|
||||||
for item in self._items:
|
for building in city.buildings:
|
||||||
total_capital_costs += item.reposition_costs[year] * costs_increase
|
try:
|
||||||
return total_capital_costs
|
function = 'residential' #Dictionaries().hub_function_to_nrel_construction_function[building.function]
|
||||||
|
archetype = self._search_archetype(self._cost_catalog, function)
|
||||||
|
except KeyError:
|
||||||
|
logger.error(f'Building {building.name} has unknown construction archetype for building function: '
|
||||||
|
f'{building.function} and building year of construction: {building.year_of_construction} '
|
||||||
|
f'and climate zone reference norm {self._climate_zone}\n')
|
||||||
|
sys.stderr.write(f'Building {building.name} has unknown construction archetype for building function: '
|
||||||
|
f'{building.function} and building year of construction: {building.year_of_construction} '
|
||||||
|
f'and climate zone reference norm {self._climate_zone}\n')
|
||||||
|
# if building has no thermal zones defined from geometry, and the building will be divided in storeys,
|
||||||
|
# one thermal zone per storey is assigned
|
||||||
|
for internal_zone in building.internal_zones:
|
||||||
|
if internal_zone.thermal_zones is None:
|
||||||
|
continue
|
||||||
|
for thermal_zone in internal_zone.thermal_zones:
|
||||||
|
for thermal_boundary in thermal_zone.thermal_boundaries:
|
||||||
|
surface_opaque += thermal_boundary.opaque_area*(1-thermal_boundary.window_ratio)
|
||||||
|
surface_transparent += thermal_boundary.opaque_area*(thermal_boundary.window_ratio)
|
||||||
|
print(f'surface_opaque {surface_opaque}')
|
||||||
|
print(f'surface_transparent {surface_transparent}')
|
||||||
|
capital_cost_op = surface_opaque*self._cost_catalog.archetypes.archetype[0].capital_cost.general_chapters[0].items[1].refurbishment[0]
|
||||||
|
capital_cost_transp= surface_transparent*self._cost_catalog.archetypes.archetype[0].capital_cost.general_chapters[0].items[2].refurbishment[0]
|
||||||
|
print(f'cost_opaque {capital_cost_op}')
|
||||||
|
print(f'cost_transparent {capital_cost_transp}')
|
||||||
|
|
||||||
|
'''total_capital_costs = self._capital_costs_at_year_0
|
||||||
|
#for year in range(1, self._number_of_years + 1):
|
||||||
|
# costs_increase = math.pow(1 + self._consumer_price_index, year) / math.pow(1 + self._discount_rate, year)
|
||||||
|
# for item in self._items:
|
||||||
|
# total_capital_costs += item.reposition_costs[year] * costs_increase
|
||||||
|
#return total_capital_costs
|
||||||
|
|
||||||
def calculate_end_of_life_costs(self):
|
def calculate_end_of_life_costs(self):
|
||||||
price_increase = 0
|
price_increase = 0
|
||||||
|
@ -53,4 +85,12 @@ class LifeCycleCosts:
|
||||||
costs_increase = math.pow(1 + self._consumer_price_index, year) / math.pow(1 + self._discount_rate, year)
|
costs_increase = math.pow(1 + self._consumer_price_index, year) / math.pow(1 + self._discount_rate, year)
|
||||||
for concept in self._concepts:
|
for concept in self._concepts:
|
||||||
total_maintenance_costs += concept.mantainance_costs * costs_increase
|
total_maintenance_costs += concept.mantainance_costs * costs_increase
|
||||||
return total_maintenance_costs
|
return total_maintenance_costs'''
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _search_archetype(costs_catalog, function):
|
||||||
|
costs_archetypes = costs_catalog.entries('archetypes')
|
||||||
|
for building_archetype in costs_archetypes:
|
||||||
|
if (str(function) == str(building_archetype.function)):
|
||||||
|
return building_archetype
|
||||||
|
raise KeyError('archetype not found')
|
||||||
|
|
58
main.py
58
main.py
|
@ -4,28 +4,56 @@ SPDX - License - Identifier: LGPL - 3.0 - or -later
|
||||||
Copyright © 2022 Project Author Pilar Monsalvete Álvarez de Uribarri pilar.monsalvete@concordia.ca
|
Copyright © 2022 Project Author Pilar Monsalvete Álvarez de Uribarri pilar.monsalvete@concordia.ca
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import glob
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from imports.geometry_factory import GeometryFactory
|
import csv
|
||||||
|
|
||||||
|
from hub.imports.construction_factory import ConstructionFactory
|
||||||
|
from hub.imports.usage_factory import UsageFactory
|
||||||
|
from hub.exports.exports_factory import ExportsFactory
|
||||||
|
from hub.exports.energy_building_exports_factory import EnergyBuildingsExportsFactory
|
||||||
|
from hub.helpers.dictionaries import Dictionaries
|
||||||
|
from pathlib import Path
|
||||||
|
from hub.imports.geometry_factory import GeometryFactory
|
||||||
from life_cycle_costs import LifeCycleCosts
|
from life_cycle_costs import LifeCycleCosts
|
||||||
|
import hub.catalog_factories.costs_catalog_factory as CostCatalogFactory
|
||||||
|
from hub.catalog_factories.cost.montreal_custom_catalog import MontrealCustomCatalog
|
||||||
|
|
||||||
gml_file = 'city.gml'
|
file_path = (Path(__file__).parent.parent / 'costs_workflow' / 'input_files' / 'Citylayers_neighbours.geojson')
|
||||||
file = Path(gml_file).resolve()
|
out_path = (Path(__file__).parent.parent / 'costs_workflow' / 'out_files')
|
||||||
city = GeometryFactory('gml', file).city
|
files = glob.glob(f'{out_path}/*')
|
||||||
|
for file in files:
|
||||||
|
if file != '.gitignore':
|
||||||
|
os.remove(file)
|
||||||
|
|
||||||
|
print('[simulation start]')
|
||||||
|
city = GeometryFactory('geojson',
|
||||||
|
path=file_path,
|
||||||
|
height_field='heightmax',
|
||||||
|
year_of_construction_field='ANNEE_CONS',
|
||||||
|
name_field='OBJECTID_12',
|
||||||
|
function_field='CODE_UTILI',
|
||||||
|
function_to_hub=Dictionaries().montreal_function_to_hub_function).city
|
||||||
|
print(f'city created from {file_path}')
|
||||||
|
ConstructionFactory('nrcan', city).enrich()
|
||||||
|
print('enrich constructions... done')
|
||||||
number_of_years = 40
|
number_of_years = 40
|
||||||
consumer_price_index = 0.1
|
consumer_price_index = 0.1
|
||||||
|
discount_rate=0.06
|
||||||
|
retrofitting_scenario = 1
|
||||||
|
|
||||||
for building in city.buildings:
|
lcc = LifeCycleCosts(city, number_of_years, consumer_price_index, discount_rate, retrofitting_scenario)
|
||||||
lcc = LifeCycleCosts(building, number_of_years, consumer_price_index, costs_catalog)
|
total_capital_costs = lcc.calculate_capital_costs()
|
||||||
total_capital_costs = lcc.calculate_capital_costs()
|
# end_of_life_costs = lcc.calculate_end_of_life_costs()
|
||||||
end_of_life_costs = lcc.calculate_end_of_life_costs()
|
# total_operational_costs = lcc.calculate_total_operational_costs()
|
||||||
total_operational_costs = lcc.calculate_total_operational_costs()
|
# total_maintenance_costs = lcc.calculate_total_maintenance_costs()
|
||||||
total_maintenance_costs = lcc.calculate_total_maintenance_costs()
|
# life_cycle_costs = total_capital_costs + end_of_life_costs + total_operational_costs + total_maintenance_costs
|
||||||
life_cycle_costs = total_capital_costs + end_of_life_costs + total_operational_costs + total_maintenance_costs
|
|
||||||
|
|
||||||
print(f'Building name: {building.name}')
|
print(f'Building name: {building.name}')
|
||||||
print(f'Capital costs: {total_capital_costs}')
|
print(f'Capital costs: {total_capital_costs}')
|
||||||
print(f'End of life costs: {end_of_life_costs}')
|
# print(f'End of life costs: {end_of_life_costs}')
|
||||||
print(f'Operational costs: {total_operational_costs}')
|
# print(f'Operational costs: {total_operational_costs}')
|
||||||
print(f'Maintenance costs: {total_maintenance_costs}')
|
# print(f'Maintenance costs: {total_maintenance_costs}')
|
||||||
print(f'Life cycle costs: {life_cycle_costs}')
|
# print(f'Life cycle costs: {life_cycle_costs}')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user