complete refactor
This commit is contained in:
parent
3816e0ba80
commit
93d670167d
@ -1,3 +1,4 @@
|
||||
# costs_workflow
|
||||
# Cerc costs
|
||||
|
||||
This workflow is a test to check that the process of calculating costs is correct before creating the API.
|
||||
Uses the cerc-hub as a base for cost calculation, it's intended to be used after executing the complete monthly energy
|
||||
balance workflow called building by building
|
||||
|
@ -4,4 +4,3 @@ SPDX - License - Identifier: LGPL - 3.0 - or -later
|
||||
Copyright © 2022 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
|
||||
Code contributor Oriol Gavalda Torrellas oriol.gavalda@concordia.ca
|
||||
"""
|
||||
|
||||
|
@ -9,32 +9,17 @@ from hub.city_model_structure.building import Building
|
||||
import hub.helpers.constants as cte
|
||||
from configuration import Configuration
|
||||
from costs import SKIN_RETROFIT, SKIN_RETROFIT_AND_SYSTEM_RETROFIT_AND_PV, SYSTEM_RETROFIT_AND_PV
|
||||
from costs.cost_base import CostBase
|
||||
|
||||
|
||||
class CapitalCosts:
|
||||
class CapitalCosts(CostBase):
|
||||
"""
|
||||
Capital 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')
|
||||
|
||||
self._capital_costs_chapter = None
|
||||
rng = range(configuration.number_of_years)
|
||||
super().__init__(building, configuration)
|
||||
self._yearly_capital_costs = pd.DataFrame(
|
||||
index=rng,
|
||||
index=self._rng,
|
||||
columns=[
|
||||
'B2010_opaque_walls',
|
||||
'B2020_transparent',
|
||||
@ -60,7 +45,7 @@ class CapitalCosts:
|
||||
self._yearly_capital_costs.loc[0, 'D5020_lighting_and_branch_wiring'] = 0
|
||||
|
||||
self._yearly_capital_incomes = pd.DataFrame(
|
||||
index=rng,
|
||||
index=self._rng,
|
||||
columns=[
|
||||
'Subsidies construction',
|
||||
'Subsidies HVAC',
|
||||
@ -111,7 +96,7 @@ class CapitalCosts:
|
||||
surface_pv += roof.solid_polygon.area * roof.solar_collectors_area_reduction_factor
|
||||
|
||||
self._yearly_capital_costs.fillna(0, inplace=True)
|
||||
own_capital = (1 - self._configuration.percentage_credit)
|
||||
own_capital = 1 - self._configuration.percentage_credit
|
||||
if self._configuration.retrofit_scenario in (SKIN_RETROFIT, SKIN_RETROFIT_AND_SYSTEM_RETROFIT_AND_PV):
|
||||
chapter = self._capital_costs_chapter.chapter('B_shell')
|
||||
capital_cost_opaque = surface_opaque * chapter.item('B2010_opaque_walls').refurbishment[0]
|
||||
|
@ -203,8 +203,14 @@ class Configuration:
|
||||
|
||||
@property
|
||||
def retrofit_scenario(self):
|
||||
"""
|
||||
Get retrofit scenario
|
||||
"""
|
||||
return self._retrofit_scenario
|
||||
|
||||
@property
|
||||
def fuel_type(self):
|
||||
"""
|
||||
Get fuel type (0: Electricity, 1: Gas)
|
||||
"""
|
||||
return self._fuel_type
|
||||
|
@ -46,6 +46,20 @@ class Cost:
|
||||
retrofit_scenario,
|
||||
fuel_type)
|
||||
|
||||
@property
|
||||
def building(self) -> Building:
|
||||
"""
|
||||
Get current building.
|
||||
"""
|
||||
return self._building
|
||||
|
||||
@building.setter
|
||||
def building(self, value: Building):
|
||||
"""
|
||||
Set current building.
|
||||
"""
|
||||
self._building = value
|
||||
|
||||
def _npv_from_list(self, list_cashflow):
|
||||
return npf.npv(self._configuration.discount_rate, list_cashflow)
|
||||
|
||||
|
37
costs/cost_base.py
Normal file
37
costs/cost_base.py
Normal file
@ -0,0 +1,37 @@
|
||||
"""
|
||||
Cost base module
|
||||
"""
|
||||
|
||||
from hub.city_model_structure.building import Building
|
||||
|
||||
from configuration import Configuration
|
||||
|
||||
|
||||
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
|
||||
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')
|
||||
|
||||
self._capital_costs_chapter = None
|
||||
self._rng = range(configuration.number_of_years)
|
||||
|
||||
def calculate(self):
|
||||
"""
|
||||
Raises not implemented exception
|
||||
"""
|
||||
raise NotImplementedError()
|
@ -6,30 +6,16 @@ import pandas as pd
|
||||
from hub.city_model_structure.building import Building
|
||||
|
||||
from configuration import Configuration
|
||||
from costs.cost_base import CostBase
|
||||
|
||||
|
||||
class EndOfLifeCosts:
|
||||
class EndOfLifeCosts(CostBase):
|
||||
"""
|
||||
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')
|
||||
super().__init__(building, configuration)
|
||||
self._yearly_end_of_life_costs = pd.DataFrame(index=self._rng, columns=['End_of_life_costs'], dtype='float')
|
||||
|
||||
def calculate(self):
|
||||
"""
|
||||
|
@ -7,31 +7,17 @@ from hub.city_model_structure.building import Building
|
||||
import hub.helpers.constants as cte
|
||||
|
||||
from configuration import Configuration
|
||||
from costs.cost_base import CostBase
|
||||
|
||||
|
||||
class TotalMaintenanceCosts:
|
||||
class TotalMaintenanceCosts(CostBase):
|
||||
"""
|
||||
Total maintenance 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)
|
||||
super().__init__(building, configuration)
|
||||
self._yearly_maintenance_costs = pd.DataFrame(
|
||||
index=rng,
|
||||
index=self._rng,
|
||||
columns=[
|
||||
'Heating_maintenance',
|
||||
'Cooling_maintenance',
|
||||
|
@ -8,31 +8,17 @@ from hub.city_model_structure.building import Building
|
||||
import hub.helpers.constants as cte
|
||||
|
||||
from configuration import Configuration
|
||||
from costs.cost_base import CostBase
|
||||
|
||||
|
||||
class TotalOperationalCosts:
|
||||
class TotalOperationalCosts(CostBase):
|
||||
"""
|
||||
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)
|
||||
super().__init__(building, configuration)
|
||||
self._yearly_operational_costs = pd.DataFrame(
|
||||
index=rng,
|
||||
index=self._rng,
|
||||
columns=[
|
||||
'Fixed_costs_electricity_peak',
|
||||
'Fixed_costs_electricity_monthly',
|
||||
|
@ -7,30 +7,16 @@ from hub.city_model_structure.building import Building
|
||||
import hub.helpers.constants as cte
|
||||
|
||||
from configuration import Configuration
|
||||
from costs.cost_base import CostBase
|
||||
|
||||
|
||||
class TotalOperationalIncomes:
|
||||
class TotalOperationalIncomes(CostBase):
|
||||
"""
|
||||
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')
|
||||
super().__init__(building, configuration)
|
||||
self._yearly_operational_incomes = pd.DataFrame(index=self._rng, columns=['Incomes electricity'], dtype='float')
|
||||
|
||||
def calculate(self) -> pd.DataFrame:
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user