""" End of life costs module """ import math import pandas as pd from hub.city_model_structure.building import Building from configuration import Configuration class EndOfLifeCosts: """ End of life costs class """ def __init__(self, building: Building, configuration: Configuration): self._building = building self._configuration = configuration self._total_floor_area = 0 for internal_zone in building.internal_zones: for thermal_zone in internal_zone.thermal_zones: self._total_floor_area += thermal_zone.total_floor_area self._archetype = None for archetype in self._configuration.cost_catalog.entries('archetypes').archetype: if str(building.function) == str(archetype.function): self._archetype = archetype self._capital_costs_chapter = self._archetype.capital_cost break if not self._archetype: raise KeyError('archetype not found') rng = range(configuration.number_of_years) self._yearly_end_of_life_costs = pd.DataFrame(index=rng, columns=['End_of_life_costs'], dtype='float') def calculate(self): """ Calculate end of life costs :return: pd.DataFrame """ archetype = self._archetype total_floor_area = self._total_floor_area for year in range(1, self._configuration.number_of_years + 1): price_increase = math.pow(1 + self._configuration.consumer_price_index, year) if year == self._configuration.number_of_years: self._yearly_end_of_life_costs.at[year, 'End_of_life_costs'] = ( total_floor_area * archetype.end_of_life_cost * price_increase ) self._yearly_end_of_life_costs.fillna(0, inplace=True) return self._yearly_end_of_life_costs