not running program, just a prove of concept to discuss with the team
This commit is contained in:
parent
4b4b3504e4
commit
8ce8a098f3
56
life_cycle_costs.py
Normal file
56
life_cycle_costs.py
Normal file
|
@ -0,0 +1,56 @@
|
|||
"""
|
||||
LifeCycleCosts calculates the life cycle costs of one building
|
||||
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
||||
Copyright © 2022 Project Author Pilar Monsalvete Alvarez de Uribarri pilar_monsalvete@concordia.ca
|
||||
"""
|
||||
import math
|
||||
|
||||
|
||||
class LifeCycleCosts:
|
||||
|
||||
# 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,
|
||||
capital_costs_at_year_0, items, fuels, concepts):
|
||||
self._building = building
|
||||
self._number_of_years = number_of_years
|
||||
self._consumer_price_index = consumer_price_index
|
||||
self._discount_rate = discount_rate
|
||||
|
||||
self._end_of_life_cost = end_of_life_cost
|
||||
|
||||
self._capital_costs_at_year_0 = capital_costs_at_year_0
|
||||
self._items = items
|
||||
|
||||
self._fuels = fuels
|
||||
|
||||
self._concepts = concepts
|
||||
|
||||
def calculate_capital_costs(self):
|
||||
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):
|
||||
price_increase = 0
|
||||
for year in range(1, self._number_of_years + 1):
|
||||
price_increase += math.pow(1 + self._consumer_price_index, year) / math.pow(1 + self._discount_rate, year)
|
||||
return self._end_of_life_cost * price_increase
|
||||
|
||||
def calculate_total_operational_costs(self):
|
||||
total_operational_costs = 0
|
||||
for year in range(1, self._number_of_years + 1):
|
||||
for fuel in self._fuels:
|
||||
total_operational_costs += fuel.operational_cost \
|
||||
* math.pow(1 + fuel.energy_price_index, year) / math.pow(1 + self._discount_rate, year)
|
||||
return total_operational_costs
|
||||
|
||||
def calculate_total_maintenance_costs(self):
|
||||
total_maintenance_costs = 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 concept in self._concepts:
|
||||
total_maintenance_costs += concept.mantainance_costs * costs_increase
|
||||
return total_maintenance_costs
|
31
main.py
Normal file
31
main.py
Normal file
|
@ -0,0 +1,31 @@
|
|||
"""
|
||||
Costs Workflow
|
||||
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
||||
Copyright © 2022 Project Author Pilar Monsalvete Álvarez de Uribarri pilar.monsalvete@concordia.ca
|
||||
"""
|
||||
|
||||
from pathlib import Path
|
||||
from imports.geometry_factory import GeometryFactory
|
||||
from life_cycle_costs import LifeCycleCosts
|
||||
|
||||
gml_file = 'city.gml'
|
||||
file = Path(gml_file).resolve()
|
||||
city = GeometryFactory('gml', file).city
|
||||
|
||||
number_of_years = 40
|
||||
consumer_price_index = 0.1
|
||||
|
||||
for building in city.buildings:
|
||||
lcc = LifeCycleCosts(building, number_of_years, consumer_price_index, costs_catalog)
|
||||
total_capital_costs = lcc.calculate_capital_costs()
|
||||
end_of_life_costs = lcc.calculate_end_of_life_costs()
|
||||
total_operational_costs = lcc.calculate_total_operational_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
|
||||
|
||||
print(f'Building name: {building.name}')
|
||||
print(f'Capital costs: {total_capital_costs}')
|
||||
print(f'End of life costs: {end_of_life_costs}')
|
||||
print(f'Operational costs: {total_operational_costs}')
|
||||
print(f'Maintenance costs: {total_maintenance_costs}')
|
||||
print(f'Life cycle costs: {life_cycle_costs}')
|
Loading…
Reference in New Issue
Block a user