56 lines
2.0 KiB
Python
56 lines
2.0 KiB
Python
|
"""
|
||
|
Total operational incomes module
|
||
|
"""
|
||
|
import math
|
||
|
import pandas as pd
|
||
|
from hub.city_model_structure.building import Building
|
||
|
import hub.helpers.constants as cte
|
||
|
|
||
|
from configuration import Configuration
|
||
|
|
||
|
|
||
|
class TotalOperationalIncomes:
|
||
|
"""
|
||
|
Total operational incomes 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_operational_incomes = pd.DataFrame(index=rng, columns=['Incomes electricity'], dtype='float')
|
||
|
|
||
|
def calculate(self) -> pd.DataFrame:
|
||
|
"""
|
||
|
Calculate total operational incomes
|
||
|
:return: pd.DataFrame
|
||
|
"""
|
||
|
building = self._building
|
||
|
if cte.YEAR not in building.onsite_electrical_production:
|
||
|
onsite_electricity_production = 0
|
||
|
else:
|
||
|
onsite_electricity_production = building.onsite_electrical_production[cte.YEAR][0] / 1000
|
||
|
|
||
|
for year in range(1, self._configuration.number_of_years + 1):
|
||
|
price_increase_electricity = math.pow(1 + self._configuration.electricity_price_index, year)
|
||
|
# todo: check the adequate assignation of price. Pilar
|
||
|
price_export = 0.075 # archetype.income.electricity_export
|
||
|
self._yearly_operational_incomes.loc[year, 'Incomes electricity'] = (
|
||
|
onsite_electricity_production * price_export * price_increase_electricity
|
||
|
)
|
||
|
|
||
|
self._yearly_operational_incomes.fillna(0, inplace=True)
|
||
|
return self._yearly_operational_incomes
|