costs_workflow/costs/cost_base.py

40 lines
1.2 KiB
Python
Raw Normal View History

2023-07-14 16:39:47 -04:00
"""
Cost base module
"""
from hub.city_model_structure.building import Building
2023-07-17 15:18:32 -04:00
from hub.helpers.dictionaries import Dictionaries
2023-07-14 16:39:47 -04:00
2023-07-17 14:35:12 -04:00
from costs.configuration import Configuration
2023-07-14 16:39:47 -04:00
class CostBase:
"""
Abstract base class for the costs
"""
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
2023-07-17 15:35:21 -04:00
self._capital_costs_chapter = None
2023-07-17 15:18:32 -04:00
for archetype in self._configuration.costs_catalog.entries().archetypes:
2023-07-17 15:35:21 -04:00
if configuration.dictionary[str(building.function)] == str(archetype.function):
2023-07-14 16:39:47 -04:00
self._archetype = archetype
self._capital_costs_chapter = self._archetype.capital_cost
break
if not self._archetype:
2023-07-17 15:18:32 -04:00
raise KeyError(f'archetype not found for function {building.function}')
2023-07-14 16:39:47 -04:00
2023-07-17 15:35:21 -04:00
2023-07-14 16:39:47 -04:00
self._rng = range(configuration.number_of_years)
def calculate(self):
"""
Raises not implemented exception
"""
raise NotImplementedError()