Compare commits
46 Commits
Author | SHA1 | Date | |
---|---|---|---|
ca002926f7 | |||
f4fafa1afa | |||
91fd120807 | |||
569729df59 | |||
5aadf2ff50 | |||
134293f6e3 | |||
da89983ca9 | |||
c052690c08 | |||
7f2084c9c7 | |||
69f14da4c3 | |||
44559bcf00 | |||
bde6ff90f5 | |||
a6381141e0 | |||
3f152e00e3 | |||
fd3afe5b2d | |||
8c094244de | |||
b6cbfc0c06 | |||
e470aafd80 | |||
037b6915dd | |||
8053de22b3 | |||
064cdf600f | |||
75127e6b36 | |||
f8bf442ae1 | |||
538b82d413 | |||
746def3dfa | |||
8733108c52 | |||
4381b1e4c7 | |||
e7cf14b8ca | |||
d311b7292e | |||
dc0e0dcfcf | |||
746788b60c | |||
8deb92480b | |||
61b9780140 | |||
334288ed87 | |||
2e809601fc | |||
24546a08d4 | |||
6941484d59 | |||
d3bdf3d485 | |||
890171dc3a | |||
a07f368047 | |||
93d670167d | |||
3816e0ba80 | |||
d066f2ce17 | |||
d597ec41af | |||
df45fc056c | |||
43eb91c889 |
@ -1,3 +1,4 @@
|
|||||||
# costs_workflow
|
# Cerc costs
|
||||||
|
|
||||||
This workflow is a test to check that the proccess 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
|
||||||
|
@ -1,45 +1,9 @@
|
|||||||
"""
|
"""
|
||||||
Cost workflow initialization
|
Cost workflow initialization
|
||||||
"""
|
"""
|
||||||
import glob
|
from .capital_costs import CapitalCosts
|
||||||
import os
|
from .end_of_life_costs import EndOfLifeCosts
|
||||||
from pathlib import Path
|
from .total_maintenance_costs import TotalMaintenanceCosts
|
||||||
|
from .total_operational_costs import TotalOperationalCosts
|
||||||
|
from .total_operational_incomes import TotalOperationalIncomes
|
||||||
|
|
||||||
# configurable parameters
|
|
||||||
file_path = Path('./data/selected_building_2864.geojson').resolve()
|
|
||||||
CONSTRUCTION_FORMAT = 'nrcan'
|
|
||||||
USAGE_FORMAT = 'comnet'
|
|
||||||
ENERGY_SYSTEM_FORMAT = 'montreal_custom'
|
|
||||||
ATTIC_HEATED_CASE = 0
|
|
||||||
BASEMENT_HEATED_CASE = 1
|
|
||||||
NUMBER_OF_YEARS = 31
|
|
||||||
PERCENTAGE_CREDIT = 0
|
|
||||||
INTEREST_RATE = 0.04
|
|
||||||
CREDIT_YEARS = 15
|
|
||||||
CONSUMER_PRICE_INDEX = 0.04
|
|
||||||
ELECTRICITY_PEAK_INDEX = 0.05
|
|
||||||
ELECTRICITY_PRICE_INDEX = 0.05
|
|
||||||
GAS_PRICE_INDEX = 0.05
|
|
||||||
DISCOUNT_RATE = 0.03
|
|
||||||
RETROFITTING_YEAR_CONSTRUCTION = 2020
|
|
||||||
|
|
||||||
CLIMATE_REFERENCE_CITY = 'Montreal'
|
|
||||||
WEATHER_FILE = 'CAN_PQ_Montreal.Intl.AP.716270_CWEC.epw'
|
|
||||||
WEATHER_FORMAT = 'epw'
|
|
||||||
CURRENT_STATUS = 0
|
|
||||||
SKIN_RETROFIT = 1
|
|
||||||
SYSTEM_RETROFIT_AND_PV = 2
|
|
||||||
SKIN_RETROFIT_AND_SYSTEM_RETROFIT_AND_PV = 3
|
|
||||||
RETROFITTING_SCENARIOS = [
|
|
||||||
CURRENT_STATUS,
|
|
||||||
SKIN_RETROFIT,
|
|
||||||
SYSTEM_RETROFIT_AND_PV,
|
|
||||||
SKIN_RETROFIT_AND_SYSTEM_RETROFIT_AND_PV
|
|
||||||
]
|
|
||||||
tmp_folder = Path('./tmp').resolve()
|
|
||||||
out_path = Path('./outputs').resolve()
|
|
||||||
files = glob.glob(f'{out_path}/*')
|
|
||||||
print('path', file_path)
|
|
||||||
for file in files:
|
|
||||||
if file != '.gitignore':
|
|
||||||
os.remove(file)
|
|
||||||
|
@ -4,193 +4,3 @@ SPDX - License - Identifier: LGPL - 3.0 - or -later
|
|||||||
Copyright © 2022 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
|
Copyright © 2022 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
|
||||||
Code contributor Oriol Gavalda Torrellas oriol.gavalda@concordia.ca
|
Code contributor Oriol Gavalda Torrellas oriol.gavalda@concordia.ca
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
import numpy_financial as npf
|
|
||||||
import pandas as pd
|
|
||||||
from energy_systems_sizing import EnergySystemsSizing
|
|
||||||
from hub.catalog_factories.costs_catalog_factory import CostCatalogFactory
|
|
||||||
from hub.helpers.dictionaries import Dictionaries
|
|
||||||
from hub.imports.construction_factory import ConstructionFactory
|
|
||||||
from hub.imports.energy_systems_factory import EnergySystemsFactory
|
|
||||||
from hub.imports.geometry_factory import GeometryFactory
|
|
||||||
from hub.imports.usage_factory import UsageFactory
|
|
||||||
from hub.imports.weather_factory import WeatherFactory
|
|
||||||
from monthly_energy_balance_engine import MonthlyEnergyBalanceEngine
|
|
||||||
from sra_engine import SraEngine
|
|
||||||
|
|
||||||
from life_cycle_costs import LifeCycleCosts
|
|
||||||
|
|
||||||
# import constants
|
|
||||||
from costs import CLIMATE_REFERENCE_CITY, WEATHER_FILE, WEATHER_FORMAT, CONSTRUCTION_FORMAT, USAGE_FORMAT
|
|
||||||
from costs import ENERGY_SYSTEM_FORMAT, ATTIC_HEATED_CASE, BASEMENT_HEATED_CASE, RETROFITTING_SCENARIOS, NUMBER_OF_YEARS
|
|
||||||
from costs import CONSUMER_PRICE_INDEX, ELECTRICITY_PEAK_INDEX, ELECTRICITY_PRICE_INDEX, GAS_PRICE_INDEX, DISCOUNT_RATE
|
|
||||||
from costs import SKIN_RETROFIT, SYSTEM_RETROFIT_AND_PV, SKIN_RETROFIT_AND_SYSTEM_RETROFIT_AND_PV
|
|
||||||
from costs import RETROFITTING_YEAR_CONSTRUCTION
|
|
||||||
|
|
||||||
# import paths
|
|
||||||
from costs import file_path, tmp_folder, out_path
|
|
||||||
|
|
||||||
|
|
||||||
def _npv_from_list(npv_discount_rate, list_cashflow):
|
|
||||||
lcc_value = npf.npv(npv_discount_rate, list_cashflow)
|
|
||||||
return lcc_value
|
|
||||||
|
|
||||||
|
|
||||||
def _search_archetype(costs_catalog, building_function):
|
|
||||||
costs_archetypes = costs_catalog.entries('archetypes').archetypes
|
|
||||||
for building_archetype in costs_archetypes:
|
|
||||||
if str(building_function) == str(building_archetype.function):
|
|
||||||
return building_archetype
|
|
||||||
raise KeyError('archetype not found')
|
|
||||||
|
|
||||||
|
|
||||||
life_cycle_results = pd.DataFrame()
|
|
||||||
print('[city creation start]')
|
|
||||||
city = GeometryFactory('geojson',
|
|
||||||
path=file_path,
|
|
||||||
height_field='heightmax',
|
|
||||||
year_of_construction_field='ANNEE_CONS',
|
|
||||||
function_field='CODE_UTILI',
|
|
||||||
function_to_hub=Dictionaries().montreal_function_to_hub_function).city
|
|
||||||
city.climate_reference_city = CLIMATE_REFERENCE_CITY
|
|
||||||
city.climate_file = (tmp_folder / f'{CLIMATE_REFERENCE_CITY}.cli').resolve()
|
|
||||||
print(f'city created from {file_path}')
|
|
||||||
WeatherFactory(WEATHER_FORMAT, city, file_name=WEATHER_FILE).enrich()
|
|
||||||
print('enrich weather... done')
|
|
||||||
ConstructionFactory(CONSTRUCTION_FORMAT, city).enrich()
|
|
||||||
print('enrich constructions... done')
|
|
||||||
UsageFactory(USAGE_FORMAT, city).enrich()
|
|
||||||
print('enrich usage... done')
|
|
||||||
for building in city.buildings:
|
|
||||||
building.energy_systems_archetype_name = 'system 1 gas'
|
|
||||||
EnergySystemsFactory(ENERGY_SYSTEM_FORMAT, city).enrich()
|
|
||||||
print('enrich systems... done')
|
|
||||||
print('exporting:')
|
|
||||||
catalog = CostCatalogFactory('montreal_custom').catalog
|
|
||||||
print('costs catalog access... done')
|
|
||||||
sra_file = (tmp_folder / f'{city.name}_sra.xml').resolve()
|
|
||||||
SraEngine(city, sra_file, tmp_folder, WEATHER_FILE)
|
|
||||||
print(' sra processed...')
|
|
||||||
|
|
||||||
for building in city.buildings:
|
|
||||||
building.attic_heated = ATTIC_HEATED_CASE
|
|
||||||
building.basement_heated = BASEMENT_HEATED_CASE
|
|
||||||
|
|
||||||
for retrofitting_scenario in RETROFITTING_SCENARIOS:
|
|
||||||
|
|
||||||
if retrofitting_scenario in (SKIN_RETROFIT, SYSTEM_RETROFIT_AND_PV):
|
|
||||||
for building in city.buildings:
|
|
||||||
building.year_of_construction = RETROFITTING_YEAR_CONSTRUCTION
|
|
||||||
ConstructionFactory(CONSTRUCTION_FORMAT, city).enrich()
|
|
||||||
print('enrich retrofitted constructions... done')
|
|
||||||
|
|
||||||
if retrofitting_scenario in (SYSTEM_RETROFIT_AND_PV, SKIN_RETROFIT_AND_SYSTEM_RETROFIT_AND_PV):
|
|
||||||
for building in city.buildings:
|
|
||||||
building.energy_systems_archetype_name = 'system 6 electricity pv'
|
|
||||||
EnergySystemsFactory(ENERGY_SYSTEM_FORMAT, city).enrich()
|
|
||||||
print('enrich systems... done')
|
|
||||||
|
|
||||||
MonthlyEnergyBalanceEngine(city, tmp_folder)
|
|
||||||
|
|
||||||
EnergySystemsSizing(city).enrich()
|
|
||||||
|
|
||||||
print(f'beginning costing scenario {retrofitting_scenario} systems... done')
|
|
||||||
|
|
||||||
for building in city.buildings:
|
|
||||||
|
|
||||||
function = Dictionaries().hub_function_to_montreal_custom_costs_function[building.function]
|
|
||||||
archetype = _search_archetype(catalog, function)
|
|
||||||
print('lcc for first building started')
|
|
||||||
if "gas" in building.energy_systems_archetype_name:
|
|
||||||
FUEL_TYPE = 1
|
|
||||||
else:
|
|
||||||
FUEL_TYPE = 0
|
|
||||||
|
|
||||||
lcc = LifeCycleCosts(building, archetype, NUMBER_OF_YEARS, CONSUMER_PRICE_INDEX, ELECTRICITY_PEAK_INDEX,
|
|
||||||
ELECTRICITY_PRICE_INDEX, GAS_PRICE_INDEX, DISCOUNT_RATE, retrofitting_scenario, FUEL_TYPE)
|
|
||||||
global_capital_costs, global_capital_incomes = lcc.calculate_capital_costs()
|
|
||||||
global_end_of_life_costs = lcc.calculate_end_of_life_costs()
|
|
||||||
global_operational_costs = lcc.calculate_total_operational_costs
|
|
||||||
global_maintenance_costs = lcc.calculate_total_maintenance_costs()
|
|
||||||
global_operational_incomes = lcc.calculate_total_operational_incomes()
|
|
||||||
full_path_output = Path(out_path / f'output {retrofitting_scenario} {building.name}.xlsx').resolve()
|
|
||||||
with pd.ExcelWriter(full_path_output) as writer:
|
|
||||||
global_capital_costs.to_excel(writer, sheet_name='global_capital_costs')
|
|
||||||
global_end_of_life_costs.to_excel(writer, sheet_name='global_end_of_life_costs')
|
|
||||||
global_operational_costs.to_excel(writer, sheet_name='global_operational_costs')
|
|
||||||
global_maintenance_costs.to_excel(writer, sheet_name='global_maintenance_costs')
|
|
||||||
global_operational_incomes.to_excel(writer, sheet_name='global_operational_incomes')
|
|
||||||
global_capital_incomes.to_excel(writer, sheet_name='global_capital_incomes')
|
|
||||||
|
|
||||||
df_capital_costs_skin = (
|
|
||||||
global_capital_costs['B2010_opaque_walls'] + global_capital_costs['B2020_transparent'] +
|
|
||||||
global_capital_costs['B3010_opaque_roof'] + global_capital_costs['B10_superstructure']
|
|
||||||
)
|
|
||||||
df_capital_costs_systems = (
|
|
||||||
global_capital_costs['D3020_heat_generating_systems'] +
|
|
||||||
global_capital_costs['D3030_cooling_generation_systems'] +
|
|
||||||
global_capital_costs['D3080_other_hvac_ahu'] +
|
|
||||||
global_capital_costs['D5020_lighting_and_branch_wiring'] +
|
|
||||||
global_capital_costs['D301010_photovoltaic_system']
|
|
||||||
)
|
|
||||||
df_end_of_life_costs = global_end_of_life_costs['End_of_life_costs']
|
|
||||||
df_operational_costs = (
|
|
||||||
global_operational_costs['Fixed_costs_electricity_peak'] +
|
|
||||||
global_operational_costs['Fixed_costs_electricity_monthly'] +
|
|
||||||
global_operational_costs['Fixed_costs_electricity_peak'] +
|
|
||||||
global_operational_costs['Fixed_costs_electricity_monthly'] +
|
|
||||||
global_operational_costs['Variable_costs_electricity'] +
|
|
||||||
global_operational_costs['Fixed_costs_gas'] +
|
|
||||||
global_operational_costs['Variable_costs_gas']
|
|
||||||
)
|
|
||||||
df_maintenance_costs = (
|
|
||||||
global_maintenance_costs['Heating_maintenance'] +
|
|
||||||
global_maintenance_costs['Cooling_maintenance'] +
|
|
||||||
global_maintenance_costs['PV_maintenance']
|
|
||||||
)
|
|
||||||
df_operational_incomes = global_operational_incomes['Incomes electricity']
|
|
||||||
|
|
||||||
df_capital_incomes = (
|
|
||||||
global_capital_incomes['Subsidies construction'] +
|
|
||||||
global_capital_incomes['Subsidies HVAC'] +
|
|
||||||
global_capital_incomes['Subsidies PV']
|
|
||||||
)
|
|
||||||
|
|
||||||
life_cycle_costs_capital_skin = _npv_from_list(DISCOUNT_RATE, df_capital_costs_skin.values.tolist())
|
|
||||||
life_cycle_costs_capital_systems = _npv_from_list(DISCOUNT_RATE, df_capital_costs_systems.values.tolist())
|
|
||||||
life_cycle_costs_end_of_life_costs = _npv_from_list(DISCOUNT_RATE, df_end_of_life_costs.values.tolist())
|
|
||||||
life_cycle_operational_costs = _npv_from_list(DISCOUNT_RATE, df_operational_costs.values.tolist())
|
|
||||||
life_cycle_maintenance_costs = _npv_from_list(DISCOUNT_RATE, df_maintenance_costs.values.tolist())
|
|
||||||
life_cycle_operational_incomes = _npv_from_list(DISCOUNT_RATE, df_operational_incomes.values.tolist())
|
|
||||||
life_cycle_capital_incomes = _npv_from_list(DISCOUNT_RATE, df_capital_incomes.values.tolist())
|
|
||||||
|
|
||||||
life_cycle_costs = (
|
|
||||||
life_cycle_costs_capital_skin +
|
|
||||||
life_cycle_costs_capital_systems +
|
|
||||||
life_cycle_costs_end_of_life_costs +
|
|
||||||
life_cycle_operational_costs +
|
|
||||||
life_cycle_maintenance_costs -
|
|
||||||
life_cycle_operational_incomes -
|
|
||||||
life_cycle_capital_incomes
|
|
||||||
)
|
|
||||||
|
|
||||||
life_cycle_results[f'Scenario {retrofitting_scenario}'] = [life_cycle_costs_capital_skin,
|
|
||||||
life_cycle_costs_capital_systems,
|
|
||||||
life_cycle_costs_end_of_life_costs,
|
|
||||||
life_cycle_operational_costs,
|
|
||||||
life_cycle_maintenance_costs,
|
|
||||||
life_cycle_operational_incomes,
|
|
||||||
life_cycle_capital_incomes]
|
|
||||||
|
|
||||||
life_cycle_results.index = ['total_capital_costs_skin',
|
|
||||||
'total_capital_costs_systems',
|
|
||||||
'end_of_life_costs',
|
|
||||||
'total_operational_costs',
|
|
||||||
'total_maintenance_costs',
|
|
||||||
'operational_incomes',
|
|
||||||
'capital_incomes']
|
|
||||||
|
|
||||||
print(life_cycle_results)
|
|
||||||
print(f'Scenario {retrofitting_scenario} {life_cycle_costs}')
|
|
||||||
|
236
costs/capital_costs.py
Normal file
236
costs/capital_costs.py
Normal file
@ -0,0 +1,236 @@
|
|||||||
|
"""
|
||||||
|
Capital costs module
|
||||||
|
"""
|
||||||
|
import math
|
||||||
|
|
||||||
|
import pandas as pd
|
||||||
|
import numpy_financial as npf
|
||||||
|
from hub.city_model_structure.building import Building
|
||||||
|
import hub.helpers.constants as cte
|
||||||
|
from costs.configuration import Configuration
|
||||||
|
from costs.constants import SKIN_RETROFIT, SKIN_RETROFIT_AND_SYSTEM_RETROFIT_AND_PV, SYSTEM_RETROFIT_AND_PV
|
||||||
|
from costs.cost_base import CostBase
|
||||||
|
|
||||||
|
|
||||||
|
class CapitalCosts(CostBase):
|
||||||
|
"""
|
||||||
|
Capital costs class
|
||||||
|
"""
|
||||||
|
def __init__(self, building: Building, configuration: Configuration):
|
||||||
|
super().__init__(building, configuration)
|
||||||
|
self._yearly_capital_costs = pd.DataFrame(
|
||||||
|
index=self._rng,
|
||||||
|
columns=[
|
||||||
|
'B2010_opaque_walls',
|
||||||
|
'B2020_transparent',
|
||||||
|
'B3010_opaque_roof',
|
||||||
|
'B10_superstructure',
|
||||||
|
'D301010_photovoltaic_system',
|
||||||
|
'D3020_heat_generating_systems',
|
||||||
|
'D3030_cooling_generation_systems',
|
||||||
|
'D3040_distribution_systems',
|
||||||
|
'D3080_other_hvac_ahu',
|
||||||
|
'D5020_lighting_and_branch_wiring'
|
||||||
|
],
|
||||||
|
dtype='float'
|
||||||
|
)
|
||||||
|
self._yearly_capital_costs.loc[0, 'B2010_opaque_walls'] = 0
|
||||||
|
self._yearly_capital_costs.loc[0]['B2020_transparent'] = 0
|
||||||
|
self._yearly_capital_costs.loc[0, 'B3010_opaque_roof'] = 0
|
||||||
|
self._yearly_capital_costs.loc[0]['B10_superstructure'] = 0
|
||||||
|
self._yearly_capital_costs.loc[0, 'D3020_heat_generating_systems'] = 0
|
||||||
|
self._yearly_capital_costs.loc[0, 'D3030_cooling_generation_systems'] = 0
|
||||||
|
self._yearly_capital_costs.loc[0, 'D3040_distribution_systems'] = 0
|
||||||
|
self._yearly_capital_costs.loc[0, 'D3080_other_hvac_ahu'] = 0
|
||||||
|
self._yearly_capital_costs.loc[0, 'D5020_lighting_and_branch_wiring'] = 0
|
||||||
|
|
||||||
|
self._yearly_capital_incomes = pd.DataFrame(
|
||||||
|
index=self._rng,
|
||||||
|
columns=[
|
||||||
|
'Subsidies construction',
|
||||||
|
'Subsidies HVAC',
|
||||||
|
'Subsidies PV'
|
||||||
|
],
|
||||||
|
dtype='float'
|
||||||
|
)
|
||||||
|
self._yearly_capital_incomes.loc[0, 'Subsidies construction'] = 0
|
||||||
|
self._yearly_capital_incomes.loc[0, 'Subsidies HVAC'] = 0
|
||||||
|
self._yearly_capital_incomes.loc[0, 'Subsidies PV'] = 0
|
||||||
|
|
||||||
|
def calculate(self) -> tuple[pd.DataFrame, pd.DataFrame]:
|
||||||
|
"""
|
||||||
|
Calculate capital cost
|
||||||
|
:return: pd.DataFrame, pd.DataFrame
|
||||||
|
"""
|
||||||
|
surface_opaque = 0
|
||||||
|
surface_transparent = 0
|
||||||
|
surface_roof = 0
|
||||||
|
surface_ground = 0
|
||||||
|
capital_cost_pv = 0
|
||||||
|
capital_cost_opaque = 0
|
||||||
|
capital_cost_ground = 0
|
||||||
|
capital_cost_transparent = 0
|
||||||
|
capital_cost_roof = 0
|
||||||
|
capital_cost_heating_equipment = 0
|
||||||
|
capital_cost_cooling_equipment = 0
|
||||||
|
capital_cost_distribution_equipment = 0
|
||||||
|
capital_cost_other_hvac_ahu = 0
|
||||||
|
capital_cost_lighting = 0
|
||||||
|
|
||||||
|
for internal_zone in self._building.internal_zones:
|
||||||
|
for thermal_zone in internal_zone.thermal_zones:
|
||||||
|
for thermal_boundary in thermal_zone.thermal_boundaries:
|
||||||
|
if thermal_boundary.type == 'Ground':
|
||||||
|
surface_ground += thermal_boundary.opaque_area
|
||||||
|
elif thermal_boundary.type == 'Roof':
|
||||||
|
surface_roof += thermal_boundary.opaque_area
|
||||||
|
elif thermal_boundary.type == 'Wall':
|
||||||
|
surface_opaque += thermal_boundary.opaque_area * (1 - thermal_boundary.window_ratio)
|
||||||
|
surface_transparent += thermal_boundary.opaque_area * thermal_boundary.window_ratio
|
||||||
|
|
||||||
|
peak_heating = self._building.heating_peak_load[cte.YEAR][0] / 1000
|
||||||
|
peak_cooling = self._building.cooling_peak_load[cte.YEAR][0] / 1000
|
||||||
|
|
||||||
|
surface_pv = 0
|
||||||
|
for roof in self._building.roofs:
|
||||||
|
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
|
||||||
|
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]
|
||||||
|
capital_cost_transparent = surface_transparent * chapter.item('B2020_transparent').refurbishment[0]
|
||||||
|
capital_cost_roof = surface_roof * chapter.item('B3010_opaque_roof').refurbishment[0]
|
||||||
|
capital_cost_ground = surface_ground * chapter.item('B10_superstructure').refurbishment[0]
|
||||||
|
self._yearly_capital_costs.loc[0, 'B2010_opaque_walls'] = capital_cost_opaque * own_capital
|
||||||
|
self._yearly_capital_costs.loc[0]['B2020_transparent'] = capital_cost_transparent * own_capital
|
||||||
|
self._yearly_capital_costs.loc[0, 'B3010_opaque_roof'] = capital_cost_roof * own_capital
|
||||||
|
self._yearly_capital_costs.loc[0]['B10_superstructure'] = capital_cost_ground * own_capital
|
||||||
|
|
||||||
|
if self._configuration.retrofit_scenario in (SYSTEM_RETROFIT_AND_PV, SKIN_RETROFIT_AND_SYSTEM_RETROFIT_AND_PV):
|
||||||
|
chapter = self._capital_costs_chapter.chapter('D_services')
|
||||||
|
capital_cost_pv = surface_pv * chapter.item('D301010_photovoltaic_system').initial_investment[0]
|
||||||
|
capital_cost_heating_equipment = peak_heating * chapter.item('D3020_heat_generating_systems').initial_investment[0]
|
||||||
|
capital_cost_cooling_equipment = peak_cooling * chapter.item('D3030_cooling_generation_systems').initial_investment[0]
|
||||||
|
capital_cost_distribution_equipment = peak_cooling * chapter.item('D3040_distribution_systems').initial_investment[0]
|
||||||
|
capital_cost_other_hvac_ahu = peak_cooling * chapter.item('D3080_other_hvac_ahu').initial_investment[0]
|
||||||
|
capital_cost_lighting = self._total_floor_area * chapter.item('D5020_lighting_and_branch_wiring').initial_investment[0]
|
||||||
|
self._yearly_capital_costs.loc[0]['D301010_photovoltaic_system'] = capital_cost_pv
|
||||||
|
self._yearly_capital_costs.loc[0, 'D3020_heat_generating_systems'] = capital_cost_heating_equipment * own_capital
|
||||||
|
self._yearly_capital_costs.loc[0, 'D3030_cooling_generation_systems'] = capital_cost_cooling_equipment * own_capital
|
||||||
|
self._yearly_capital_costs.loc[0, 'D3040_distribution_systems'] = capital_cost_distribution_equipment * own_capital
|
||||||
|
self._yearly_capital_costs.loc[0, 'D3080_other_hvac_ahu'] = capital_cost_other_hvac_ahu * own_capital
|
||||||
|
self._yearly_capital_costs.loc[0, 'D5020_lighting_and_branch_wiring'] = capital_cost_lighting * own_capital
|
||||||
|
|
||||||
|
for year in range(1, self._configuration.number_of_years):
|
||||||
|
chapter = self._capital_costs_chapter.chapter('D_services')
|
||||||
|
costs_increase = math.pow(1 + self._configuration.consumer_price_index, year)
|
||||||
|
self._yearly_capital_costs.loc[year, 'B2010_opaque_walls'] = (
|
||||||
|
-npf.pmt(
|
||||||
|
self._configuration.interest_rate,
|
||||||
|
self._configuration.credit_years,
|
||||||
|
capital_cost_opaque * self._configuration.percentage_credit
|
||||||
|
)
|
||||||
|
)
|
||||||
|
self._yearly_capital_costs.loc[year, 'B2020_transparent'] = (
|
||||||
|
-npf.pmt(
|
||||||
|
self._configuration.interest_rate,
|
||||||
|
self._configuration.credit_years,
|
||||||
|
capital_cost_transparent * self._configuration.percentage_credit
|
||||||
|
)
|
||||||
|
)
|
||||||
|
self._yearly_capital_costs.loc[year, 'B3010_opaque_roof'] = (
|
||||||
|
-npf.pmt(
|
||||||
|
self._configuration.interest_rate,
|
||||||
|
self._configuration.credit_years,
|
||||||
|
capital_cost_roof * self._configuration.percentage_credit
|
||||||
|
)
|
||||||
|
)
|
||||||
|
self._yearly_capital_costs.loc[year, 'B10_superstructure'] = (
|
||||||
|
-npf.pmt(
|
||||||
|
self._configuration.interest_rate,
|
||||||
|
self._configuration.credit_years,
|
||||||
|
capital_cost_ground * self._configuration.percentage_credit
|
||||||
|
)
|
||||||
|
)
|
||||||
|
self._yearly_capital_costs.loc[year, 'D3020_heat_generating_systems'] = (
|
||||||
|
-npf.pmt(
|
||||||
|
self._configuration.interest_rate,
|
||||||
|
self._configuration.credit_years,
|
||||||
|
capital_cost_heating_equipment * self._configuration.percentage_credit
|
||||||
|
)
|
||||||
|
)
|
||||||
|
self._yearly_capital_costs.loc[year, 'D3030_cooling_generation_systems'] = (
|
||||||
|
-npf.pmt(
|
||||||
|
self._configuration.interest_rate,
|
||||||
|
self._configuration.credit_years,
|
||||||
|
capital_cost_cooling_equipment * self._configuration.percentage_credit
|
||||||
|
)
|
||||||
|
)
|
||||||
|
self._yearly_capital_costs.loc[year, 'D3040_distribution_systems'] = (
|
||||||
|
-npf.pmt(
|
||||||
|
self._configuration.interest_rate,
|
||||||
|
self._configuration.credit_years,
|
||||||
|
capital_cost_distribution_equipment * self._configuration.percentage_credit
|
||||||
|
)
|
||||||
|
)
|
||||||
|
self._yearly_capital_costs.loc[year, 'D3080_other_hvac_ahu'] = (
|
||||||
|
-npf.pmt(
|
||||||
|
self._configuration.interest_rate,
|
||||||
|
self._configuration.credit_years,
|
||||||
|
capital_cost_other_hvac_ahu * self._configuration.percentage_credit
|
||||||
|
)
|
||||||
|
)
|
||||||
|
self._yearly_capital_costs.loc[year, 'D5020_lighting_and_branch_wiring'] = (
|
||||||
|
-npf.pmt(
|
||||||
|
self._configuration.interest_rate,
|
||||||
|
self._configuration.credit_years,
|
||||||
|
capital_cost_lighting * self._configuration.percentage_credit
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
if (year % chapter.item('D3020_heat_generating_systems').lifetime) == 0:
|
||||||
|
reposition_cost_heating_equipment = (
|
||||||
|
peak_heating * chapter.item('D3020_heat_generating_systems').reposition[0] * costs_increase
|
||||||
|
)
|
||||||
|
self._yearly_capital_costs.loc[year, 'D3020_heat_generating_systems'] += reposition_cost_heating_equipment
|
||||||
|
|
||||||
|
if (year % chapter.item('D3030_cooling_generation_systems').lifetime) == 0:
|
||||||
|
reposition_cost_cooling_equipment = (
|
||||||
|
peak_cooling * chapter.item('D3030_cooling_generation_systems').reposition[0] * costs_increase
|
||||||
|
)
|
||||||
|
self._yearly_capital_costs.loc[year, 'D3030_cooling_generation_systems'] += reposition_cost_cooling_equipment
|
||||||
|
|
||||||
|
if (year % chapter.item('D3080_other_hvac_ahu').lifetime) == 0:
|
||||||
|
reposition_cost_hvac_ahu = (
|
||||||
|
peak_cooling * chapter.item('D3080_other_hvac_ahu').reposition[0] * costs_increase
|
||||||
|
)
|
||||||
|
self._yearly_capital_costs.loc[year, 'D3080_other_hvac_ahu'] = reposition_cost_hvac_ahu
|
||||||
|
|
||||||
|
if (year % chapter.item('D5020_lighting_and_branch_wiring').lifetime) == 0:
|
||||||
|
reposition_cost_lighting = (
|
||||||
|
self._total_floor_area * chapter.item('D5020_lighting_and_branch_wiring').reposition[0] * costs_increase
|
||||||
|
)
|
||||||
|
self._yearly_capital_costs.loc[year, 'D5020_lighting_and_branch_wiring'] += reposition_cost_lighting
|
||||||
|
|
||||||
|
if self._configuration.retrofit_scenario in (SYSTEM_RETROFIT_AND_PV, SKIN_RETROFIT_AND_SYSTEM_RETROFIT_AND_PV):
|
||||||
|
if (year % chapter.item('D301010_photovoltaic_system').lifetime) == 0:
|
||||||
|
self._yearly_capital_costs.loc[year]['D301010_photovoltaic_system'] += (
|
||||||
|
surface_pv * chapter.item('D301010_photovoltaic_system').reposition[0] * costs_increase
|
||||||
|
)
|
||||||
|
capital_cost_skin = capital_cost_opaque + capital_cost_ground + capital_cost_transparent + capital_cost_roof
|
||||||
|
capital_cost_hvac = (
|
||||||
|
capital_cost_heating_equipment +
|
||||||
|
capital_cost_cooling_equipment +
|
||||||
|
capital_cost_distribution_equipment +
|
||||||
|
capital_cost_other_hvac_ahu + capital_cost_lighting
|
||||||
|
)
|
||||||
|
|
||||||
|
self._yearly_capital_incomes.loc[0, 'Subsidies construction'] = (
|
||||||
|
capital_cost_skin * self._archetype.income.construction_subsidy/100
|
||||||
|
)
|
||||||
|
self._yearly_capital_incomes.loc[0, 'Subsidies HVAC'] = capital_cost_hvac * self._archetype.income.hvac_subsidy/100
|
||||||
|
self._yearly_capital_incomes.loc[0, 'Subsidies PV'] = capital_cost_pv * self._archetype.income.photovoltaic_subsidy/100
|
||||||
|
self._yearly_capital_incomes.fillna(0, inplace=True)
|
||||||
|
return self._yearly_capital_costs, self._yearly_capital_incomes
|
225
costs/configuration.py
Normal file
225
costs/configuration.py
Normal file
@ -0,0 +1,225 @@
|
|||||||
|
"""
|
||||||
|
Configuration module
|
||||||
|
"""
|
||||||
|
from hub.catalog_factories.costs_catalog_factory import CostsCatalogFactory
|
||||||
|
from hub.catalog_factories.catalog import Catalog
|
||||||
|
|
||||||
|
|
||||||
|
class Configuration:
|
||||||
|
"""
|
||||||
|
Configuration class
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self,
|
||||||
|
number_of_years,
|
||||||
|
percentage_credit,
|
||||||
|
interest_rate,
|
||||||
|
credit_years,
|
||||||
|
consumer_price_index,
|
||||||
|
electricity_peak_index,
|
||||||
|
electricity_price_index,
|
||||||
|
gas_price_index,
|
||||||
|
discount_rate,
|
||||||
|
retrofitting_year_construction,
|
||||||
|
factories_handler,
|
||||||
|
retrofit_scenario,
|
||||||
|
fuel_type,
|
||||||
|
dictionary
|
||||||
|
):
|
||||||
|
self._number_of_years = number_of_years
|
||||||
|
self._percentage_credit = percentage_credit
|
||||||
|
self._interest_rate = interest_rate
|
||||||
|
self._credit_years = credit_years
|
||||||
|
self._consumer_price_index = consumer_price_index
|
||||||
|
self._electricity_peak_index = electricity_peak_index
|
||||||
|
self._electricity_price_index = electricity_price_index
|
||||||
|
self._gas_price_index = gas_price_index
|
||||||
|
self._discount_rate = discount_rate
|
||||||
|
self._retrofitting_year_construction = retrofitting_year_construction
|
||||||
|
self._factories_handler = factories_handler
|
||||||
|
self._costs_catalog = CostsCatalogFactory(factories_handler).catalog
|
||||||
|
self._retrofit_scenario = retrofit_scenario
|
||||||
|
self._fuel_type = fuel_type
|
||||||
|
self._dictionary = dictionary
|
||||||
|
|
||||||
|
@property
|
||||||
|
def number_of_years(self):
|
||||||
|
"""
|
||||||
|
Get number of years
|
||||||
|
"""
|
||||||
|
return self._number_of_years
|
||||||
|
|
||||||
|
@number_of_years.setter
|
||||||
|
def number_of_years(self, value):
|
||||||
|
"""
|
||||||
|
Set number of years
|
||||||
|
"""
|
||||||
|
self._number_of_years = value
|
||||||
|
|
||||||
|
@property
|
||||||
|
def percentage_credit(self):
|
||||||
|
"""
|
||||||
|
Get percentage credit
|
||||||
|
"""
|
||||||
|
return self._percentage_credit
|
||||||
|
|
||||||
|
@percentage_credit.setter
|
||||||
|
def percentage_credit(self, value):
|
||||||
|
"""
|
||||||
|
Set percentage credit
|
||||||
|
"""
|
||||||
|
self._percentage_credit = value
|
||||||
|
|
||||||
|
@property
|
||||||
|
def interest_rate(self):
|
||||||
|
"""
|
||||||
|
Get interest rate
|
||||||
|
"""
|
||||||
|
return self._interest_rate
|
||||||
|
|
||||||
|
@interest_rate.setter
|
||||||
|
def interest_rate(self, value):
|
||||||
|
"""
|
||||||
|
Set interest rate
|
||||||
|
"""
|
||||||
|
self._interest_rate = value
|
||||||
|
|
||||||
|
@property
|
||||||
|
def credit_years(self):
|
||||||
|
"""
|
||||||
|
Get credit years
|
||||||
|
"""
|
||||||
|
return self._credit_years
|
||||||
|
|
||||||
|
@credit_years.setter
|
||||||
|
def credit_years(self, value):
|
||||||
|
"""
|
||||||
|
Set credit years
|
||||||
|
"""
|
||||||
|
self._credit_years = value
|
||||||
|
|
||||||
|
@property
|
||||||
|
def consumer_price_index(self):
|
||||||
|
"""
|
||||||
|
Get consumer price index
|
||||||
|
"""
|
||||||
|
return self._consumer_price_index
|
||||||
|
|
||||||
|
@consumer_price_index.setter
|
||||||
|
def consumer_price_index(self, value):
|
||||||
|
"""
|
||||||
|
Set consumer price index
|
||||||
|
"""
|
||||||
|
self._consumer_price_index = value
|
||||||
|
|
||||||
|
@property
|
||||||
|
def electricity_peak_index(self):
|
||||||
|
"""
|
||||||
|
Get electricity peak index
|
||||||
|
"""
|
||||||
|
return self._electricity_peak_index
|
||||||
|
|
||||||
|
@electricity_peak_index.setter
|
||||||
|
def electricity_peak_index(self, value):
|
||||||
|
"""
|
||||||
|
Set electricity peak index
|
||||||
|
"""
|
||||||
|
self._electricity_peak_index = value
|
||||||
|
|
||||||
|
@property
|
||||||
|
def electricity_price_index(self):
|
||||||
|
"""
|
||||||
|
Get electricity price index
|
||||||
|
"""
|
||||||
|
return self._electricity_price_index
|
||||||
|
|
||||||
|
@electricity_price_index.setter
|
||||||
|
def electricity_price_index(self, value):
|
||||||
|
"""
|
||||||
|
Set electricity price index
|
||||||
|
"""
|
||||||
|
self._electricity_price_index = value
|
||||||
|
|
||||||
|
@property
|
||||||
|
def gas_price_index(self):
|
||||||
|
"""
|
||||||
|
Get gas price index
|
||||||
|
"""
|
||||||
|
return self._gas_price_index
|
||||||
|
|
||||||
|
@gas_price_index.setter
|
||||||
|
def gas_price_index(self, value):
|
||||||
|
"""
|
||||||
|
Set gas price index
|
||||||
|
"""
|
||||||
|
self._gas_price_index = value
|
||||||
|
|
||||||
|
@property
|
||||||
|
def discount_rate(self):
|
||||||
|
"""
|
||||||
|
Get discount rate
|
||||||
|
"""
|
||||||
|
return self._discount_rate
|
||||||
|
|
||||||
|
@discount_rate.setter
|
||||||
|
def discount_rate(self, value):
|
||||||
|
"""
|
||||||
|
Set discount rate
|
||||||
|
"""
|
||||||
|
self._discount_rate = value
|
||||||
|
|
||||||
|
@property
|
||||||
|
def retrofitting_year_construction(self):
|
||||||
|
"""
|
||||||
|
Get retrofitting year construction
|
||||||
|
"""
|
||||||
|
return self._retrofitting_year_construction
|
||||||
|
|
||||||
|
@retrofitting_year_construction.setter
|
||||||
|
def retrofitting_year_construction(self, value):
|
||||||
|
"""
|
||||||
|
Set retrofitting year construction
|
||||||
|
"""
|
||||||
|
self._retrofitting_year_construction = value
|
||||||
|
|
||||||
|
@property
|
||||||
|
def factories_handler(self):
|
||||||
|
"""
|
||||||
|
Get factories handler
|
||||||
|
"""
|
||||||
|
return self._factories_handler
|
||||||
|
|
||||||
|
@factories_handler.setter
|
||||||
|
def factories_handler(self, value):
|
||||||
|
"""
|
||||||
|
Set factories handler
|
||||||
|
"""
|
||||||
|
self._factories_handler = value
|
||||||
|
|
||||||
|
@property
|
||||||
|
def costs_catalog(self) -> Catalog:
|
||||||
|
"""
|
||||||
|
Get costs catalog
|
||||||
|
"""
|
||||||
|
return self._costs_catalog
|
||||||
|
|
||||||
|
@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
|
||||||
|
|
||||||
|
@property
|
||||||
|
def dictionary(self):
|
||||||
|
"""
|
||||||
|
Get hub function to cost function dictionary
|
||||||
|
"""
|
||||||
|
return self._dictionary
|
11
costs/constants.py
Normal file
11
costs/constants.py
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# constants
|
||||||
|
CURRENT_STATUS = 0
|
||||||
|
SKIN_RETROFIT = 1
|
||||||
|
SYSTEM_RETROFIT_AND_PV = 2
|
||||||
|
SKIN_RETROFIT_AND_SYSTEM_RETROFIT_AND_PV = 3
|
||||||
|
RETROFITTING_SCENARIOS = [
|
||||||
|
CURRENT_STATUS,
|
||||||
|
SKIN_RETROFIT,
|
||||||
|
SYSTEM_RETROFIT_AND_PV,
|
||||||
|
SKIN_RETROFIT_AND_SYSTEM_RETROFIT_AND_PV
|
||||||
|
]
|
143
costs/cost.py
Normal file
143
costs/cost.py
Normal file
@ -0,0 +1,143 @@
|
|||||||
|
"""
|
||||||
|
Cost module
|
||||||
|
"""
|
||||||
|
import hub.helpers.dictionaries
|
||||||
|
import pandas as pd
|
||||||
|
import numpy_financial as npf
|
||||||
|
from hub.city_model_structure.building import Building
|
||||||
|
|
||||||
|
from costs.configuration import Configuration
|
||||||
|
from costs import CapitalCosts, EndOfLifeCosts, TotalMaintenanceCosts, TotalOperationalCosts, TotalOperationalIncomes
|
||||||
|
from costs.constants import CURRENT_STATUS
|
||||||
|
|
||||||
|
|
||||||
|
class Cost:
|
||||||
|
"""
|
||||||
|
Cost class
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self,
|
||||||
|
building: Building,
|
||||||
|
number_of_years=31,
|
||||||
|
percentage_credit=0,
|
||||||
|
interest_rate=0.04,
|
||||||
|
credit_years=15,
|
||||||
|
consumer_price_index=0.04,
|
||||||
|
electricity_peak_index=0.05,
|
||||||
|
electricity_price_index=0.05,
|
||||||
|
gas_price_index=0.05,
|
||||||
|
discount_rate=0.03,
|
||||||
|
retrofitting_year_construction=2020,
|
||||||
|
factories_handler='montreal_custom',
|
||||||
|
retrofit_scenario=CURRENT_STATUS,
|
||||||
|
dictionary=hub.helpers.dictionaries.Dictionaries().hub_function_to_montreal_custom_costs_function):
|
||||||
|
self._building = building
|
||||||
|
fuel_type = 0
|
||||||
|
if "gas" in building.energy_systems_archetype_name:
|
||||||
|
fuel_type = 1
|
||||||
|
self._configuration = Configuration(number_of_years,
|
||||||
|
percentage_credit,
|
||||||
|
interest_rate, credit_years,
|
||||||
|
consumer_price_index,
|
||||||
|
electricity_peak_index,
|
||||||
|
electricity_price_index,
|
||||||
|
gas_price_index,
|
||||||
|
discount_rate,
|
||||||
|
retrofitting_year_construction,
|
||||||
|
factories_handler,
|
||||||
|
retrofit_scenario,
|
||||||
|
fuel_type,
|
||||||
|
dictionary)
|
||||||
|
|
||||||
|
@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)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def life_cycle(self) -> pd.DataFrame:
|
||||||
|
"""
|
||||||
|
Get complete life cycle costs
|
||||||
|
:return: DataFrame
|
||||||
|
"""
|
||||||
|
results = pd.DataFrame()
|
||||||
|
global_capital_costs, global_capital_incomes = CapitalCosts(self._building, self._configuration).calculate()
|
||||||
|
global_end_of_life_costs = EndOfLifeCosts(self._building, self._configuration).calculate()
|
||||||
|
global_operational_costs = TotalOperationalCosts(self._building, self._configuration).calculate()
|
||||||
|
global_maintenance_costs = TotalMaintenanceCosts(self._building, self._configuration).calculate()
|
||||||
|
global_operational_incomes = TotalOperationalIncomes(self._building, self._configuration).calculate()
|
||||||
|
|
||||||
|
df_capital_costs_skin = (
|
||||||
|
global_capital_costs['B2010_opaque_walls'] +
|
||||||
|
global_capital_costs['B2020_transparent'] +
|
||||||
|
global_capital_costs['B3010_opaque_roof'] +
|
||||||
|
global_capital_costs['B10_superstructure']
|
||||||
|
)
|
||||||
|
df_capital_costs_systems = (
|
||||||
|
global_capital_costs['D3020_heat_generating_systems'] +
|
||||||
|
global_capital_costs['D3030_cooling_generation_systems'] +
|
||||||
|
global_capital_costs['D3080_other_hvac_ahu'] +
|
||||||
|
global_capital_costs['D5020_lighting_and_branch_wiring'] +
|
||||||
|
global_capital_costs['D301010_photovoltaic_system']
|
||||||
|
)
|
||||||
|
df_end_of_life_costs = global_end_of_life_costs['End_of_life_costs']
|
||||||
|
df_operational_costs = (
|
||||||
|
global_operational_costs['Fixed_costs_electricity_peak'] +
|
||||||
|
global_operational_costs['Fixed_costs_electricity_monthly'] +
|
||||||
|
global_operational_costs['Fixed_costs_electricity_peak'] +
|
||||||
|
global_operational_costs['Fixed_costs_electricity_monthly'] +
|
||||||
|
global_operational_costs['Variable_costs_electricity'] +
|
||||||
|
global_operational_costs['Fixed_costs_gas'] +
|
||||||
|
global_operational_costs['Variable_costs_gas']
|
||||||
|
)
|
||||||
|
df_maintenance_costs = (
|
||||||
|
global_maintenance_costs['Heating_maintenance'] +
|
||||||
|
global_maintenance_costs['Cooling_maintenance'] +
|
||||||
|
global_maintenance_costs['PV_maintenance']
|
||||||
|
)
|
||||||
|
df_operational_incomes = global_operational_incomes['Incomes electricity']
|
||||||
|
df_capital_incomes = (
|
||||||
|
global_capital_incomes['Subsidies construction'] +
|
||||||
|
global_capital_incomes['Subsidies HVAC'] +
|
||||||
|
global_capital_incomes['Subsidies PV']
|
||||||
|
)
|
||||||
|
|
||||||
|
life_cycle_costs_capital_skin = self._npv_from_list(df_capital_costs_skin.values.tolist())
|
||||||
|
life_cycle_costs_capital_systems = self._npv_from_list(df_capital_costs_systems.values.tolist())
|
||||||
|
life_cycle_costs_end_of_life_costs = self._npv_from_list(df_end_of_life_costs.values.tolist())
|
||||||
|
life_cycle_operational_costs = self._npv_from_list(df_operational_costs.values.tolist())
|
||||||
|
life_cycle_maintenance_costs = self._npv_from_list(df_maintenance_costs.values.tolist())
|
||||||
|
life_cycle_operational_incomes = self._npv_from_list(df_operational_incomes.values.tolist())
|
||||||
|
life_cycle_capital_incomes = self._npv_from_list(df_capital_incomes.values.tolist())
|
||||||
|
|
||||||
|
results[f'Scenario {self._configuration.retrofit_scenario}'] = [
|
||||||
|
life_cycle_costs_capital_skin,
|
||||||
|
life_cycle_costs_capital_systems,
|
||||||
|
life_cycle_costs_end_of_life_costs,
|
||||||
|
life_cycle_operational_costs,
|
||||||
|
life_cycle_maintenance_costs,
|
||||||
|
life_cycle_operational_incomes,
|
||||||
|
life_cycle_capital_incomes
|
||||||
|
]
|
||||||
|
|
||||||
|
results.index = ['total_capital_costs_skin',
|
||||||
|
'total_capital_costs_systems',
|
||||||
|
'end_of_life_costs',
|
||||||
|
'total_operational_costs',
|
||||||
|
'total_maintenance_costs',
|
||||||
|
'operational_incomes',
|
||||||
|
'capital_incomes']
|
||||||
|
|
||||||
|
return results
|
38
costs/cost_base.py
Normal file
38
costs/cost_base.py
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
"""
|
||||||
|
Cost base module
|
||||||
|
"""
|
||||||
|
|
||||||
|
from hub.city_model_structure.building import Building
|
||||||
|
from hub.helpers.dictionaries import Dictionaries
|
||||||
|
|
||||||
|
from costs.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
|
||||||
|
self._capital_costs_chapter = None
|
||||||
|
for archetype in self._configuration.costs_catalog.entries().archetypes:
|
||||||
|
if configuration.dictionary[str(building.function)] == str(archetype.function):
|
||||||
|
self._archetype = archetype
|
||||||
|
self._capital_costs_chapter = self._archetype.capital_cost
|
||||||
|
break
|
||||||
|
if not self._archetype:
|
||||||
|
raise KeyError(f'archetype not found for function {building.function}')
|
||||||
|
|
||||||
|
self._rng = range(configuration.number_of_years)
|
||||||
|
|
||||||
|
def calculate(self):
|
||||||
|
"""
|
||||||
|
Raises not implemented exception
|
||||||
|
"""
|
||||||
|
raise NotImplementedError()
|
4
costs/data/.gitignore
vendored
4
costs/data/.gitignore
vendored
@ -1,4 +0,0 @@
|
|||||||
# Ignore everything in this directory
|
|
||||||
*
|
|
||||||
# Except this file
|
|
||||||
!.gitignore
|
|
34
costs/end_of_life_costs.py
Normal file
34
costs/end_of_life_costs.py
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
"""
|
||||||
|
End of life costs module
|
||||||
|
"""
|
||||||
|
import math
|
||||||
|
import pandas as pd
|
||||||
|
from hub.city_model_structure.building import Building
|
||||||
|
|
||||||
|
from costs.configuration import Configuration
|
||||||
|
from costs.cost_base import CostBase
|
||||||
|
|
||||||
|
|
||||||
|
class EndOfLifeCosts(CostBase):
|
||||||
|
"""
|
||||||
|
End of life costs class
|
||||||
|
"""
|
||||||
|
def __init__(self, building: Building, configuration: Configuration):
|
||||||
|
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):
|
||||||
|
"""
|
||||||
|
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
|
@ -1,369 +0,0 @@
|
|||||||
"""
|
|
||||||
LifeCycleCosts module 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
|
|
||||||
Code contributor Oriol Gavalda Torrellas oriol.gavalda@concordia.ca
|
|
||||||
"""
|
|
||||||
|
|
||||||
import math
|
|
||||||
|
|
||||||
import pandas as pd
|
|
||||||
import numpy_financial as npf
|
|
||||||
import hub.helpers.constants as cte
|
|
||||||
from costs import SKIN_RETROFIT, SYSTEM_RETROFIT_AND_PV, SKIN_RETROFIT_AND_SYSTEM_RETROFIT_AND_PV, PERCENTAGE_CREDIT,INTEREST_RATE,CREDIT_YEARS
|
|
||||||
|
|
||||||
|
|
||||||
class LifeCycleCosts:
|
|
||||||
"""
|
|
||||||
Life cycle cost class
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self, building, archetype, number_of_years, consumer_price_index, electricity_peak_index,
|
|
||||||
electricity_price_index, gas_price_index, discount_rate,
|
|
||||||
retrofitting_scenario, fuel_type):
|
|
||||||
self._building = building
|
|
||||||
self._number_of_years = number_of_years
|
|
||||||
self._consumer_price_index = consumer_price_index
|
|
||||||
self._electricity_peak_index = electricity_peak_index
|
|
||||||
self._electricity_price_index = electricity_price_index
|
|
||||||
self._gas_price_index = gas_price_index
|
|
||||||
self._discount_rate = discount_rate
|
|
||||||
self._archetype = archetype
|
|
||||||
self._end_of_life_cost = 0
|
|
||||||
self._capital_costs_at_year_0 = 0
|
|
||||||
self._items = 0
|
|
||||||
self._fuels = 0
|
|
||||||
self._concepts = 0
|
|
||||||
self._retrofitting_scenario = retrofitting_scenario
|
|
||||||
self._total_floor_area = 0
|
|
||||||
self._fuel_type = fuel_type
|
|
||||||
for internal_zone in building.internal_zones:
|
|
||||||
for thermal_zone in internal_zone.thermal_zones:
|
|
||||||
self._total_floor_area += thermal_zone.total_floor_area
|
|
||||||
|
|
||||||
# todo: revise if it works
|
|
||||||
rng = range(number_of_years)
|
|
||||||
self._yearly_capital_costs = pd.DataFrame(index=rng, columns=['B2010_opaque_walls', 'B2020_transparent',
|
|
||||||
'B3010_opaque_roof', 'B10_superstructure',
|
|
||||||
'D301010_photovoltaic_system',
|
|
||||||
'D3020_heat_generating_systems',
|
|
||||||
'D3030_cooling_generation_systems',
|
|
||||||
'D3040_distribution_systems',
|
|
||||||
'D3080_other_hvac_ahu',
|
|
||||||
'D5020_lighting_and_branch_wiring'],
|
|
||||||
dtype='float')
|
|
||||||
self._yearly_end_of_life_costs = pd.DataFrame(index=rng, columns=['End_of_life_costs'], dtype='float')
|
|
||||||
self._yearly_operational_costs = pd.DataFrame(index=rng, columns=['Fixed_costs_electricity_peak',
|
|
||||||
'Fixed_costs_electricity_monthly',
|
|
||||||
'Variable_costs_electricity', 'Fixed_costs_gas',
|
|
||||||
'Variable_costs_gas'],
|
|
||||||
dtype='float')
|
|
||||||
self._yearly_maintenance_costs = pd.DataFrame(index=rng, columns=['Heating_maintenance', 'Cooling_maintenance',
|
|
||||||
'PV_maintenance'], dtype='float')
|
|
||||||
self._yearly_operational_incomes = pd.DataFrame(index=rng, columns=['Incomes electricity'], dtype='float')
|
|
||||||
|
|
||||||
self._yearly_capital_incomes = pd.DataFrame(index=rng, columns=['Subsidies construction',
|
|
||||||
'Subsidies HVAC', 'Subsidies PV'], dtype='float')
|
|
||||||
|
|
||||||
def calculate_capital_costs(self):
|
|
||||||
"""
|
|
||||||
Calculate capital cost
|
|
||||||
:return: pd.DataFrame
|
|
||||||
"""
|
|
||||||
building = self._building
|
|
||||||
archetype = self._archetype
|
|
||||||
|
|
||||||
surface_opaque = 0
|
|
||||||
surface_transparent = 0
|
|
||||||
surface_roof = 0
|
|
||||||
surface_ground = 0
|
|
||||||
capital_cost_pv = 0
|
|
||||||
capital_cost_opaque = 0
|
|
||||||
capital_cost_ground = 0
|
|
||||||
capital_cost_transparent = 0
|
|
||||||
capital_cost_roof = 0
|
|
||||||
capital_cost_heating_equipment = 0
|
|
||||||
capital_cost_cooling_equipment = 0
|
|
||||||
capital_cost_distribution_equipment = 0
|
|
||||||
capital_cost_other_hvac_ahu = 0
|
|
||||||
capital_cost_lighting = 0
|
|
||||||
|
|
||||||
total_floor_area = self._total_floor_area
|
|
||||||
|
|
||||||
for internal_zone in building.internal_zones:
|
|
||||||
for thermal_zone in internal_zone.thermal_zones:
|
|
||||||
for thermal_boundary in thermal_zone.thermal_boundaries:
|
|
||||||
if thermal_boundary.type == 'Ground':
|
|
||||||
surface_ground += thermal_boundary.opaque_area
|
|
||||||
elif thermal_boundary.type == 'Roof':
|
|
||||||
surface_roof += thermal_boundary.opaque_area
|
|
||||||
elif thermal_boundary.type == 'Wall':
|
|
||||||
surface_opaque += thermal_boundary.opaque_area * (1 - thermal_boundary.window_ratio)
|
|
||||||
surface_transparent += thermal_boundary.opaque_area * thermal_boundary.window_ratio
|
|
||||||
|
|
||||||
chapters = archetype.capital_cost
|
|
||||||
|
|
||||||
peak_heating = building.heating_peak_load[cte.YEAR].values[0]/1000
|
|
||||||
peak_cooling = building.cooling_peak_load[cte.YEAR].values[0]/1000
|
|
||||||
# todo: change area pv when the variable exists
|
|
||||||
roof_area = 0
|
|
||||||
for roof in building.roofs:
|
|
||||||
roof_area += roof.solid_polygon.area
|
|
||||||
surface_pv = roof_area * 0.5
|
|
||||||
|
|
||||||
self._yearly_capital_costs.loc[0, 'B2010_opaque_walls'] = 0
|
|
||||||
self._yearly_capital_costs.loc[0]['B2020_transparent'] = 0
|
|
||||||
self._yearly_capital_costs.loc[0, 'B3010_opaque_roof'] = 0
|
|
||||||
self._yearly_capital_costs.loc[0]['B10_superstructure'] = 0
|
|
||||||
|
|
||||||
self._yearly_capital_costs.loc[0, 'D3020_heat_generating_systems'] = 0
|
|
||||||
self._yearly_capital_costs.loc[0, 'D3030_cooling_generation_systems'] = 0
|
|
||||||
self._yearly_capital_costs.loc[0, 'D3040_distribution_systems'] = 0
|
|
||||||
self._yearly_capital_costs.loc[0, 'D3080_other_hvac_ahu'] = 0
|
|
||||||
self._yearly_capital_costs.loc[0, 'D5020_lighting_and_branch_wiring'] = 0
|
|
||||||
|
|
||||||
self._yearly_capital_incomes.loc[0, 'Subsidies construction'] = 0
|
|
||||||
self._yearly_capital_incomes.loc[0, 'Subsidies HVAC'] = 0
|
|
||||||
self._yearly_capital_incomes.loc[0, 'Subsidies PV'] = 0
|
|
||||||
|
|
||||||
self._yearly_capital_costs.fillna(0, inplace=True)
|
|
||||||
if self._retrofitting_scenario in (SKIN_RETROFIT, SKIN_RETROFIT_AND_SYSTEM_RETROFIT_AND_PV):
|
|
||||||
chapter = chapters.chapter('B_shell')
|
|
||||||
capital_cost_opaque = surface_opaque * chapter.item('B2010_opaque_walls').refurbishment[0]
|
|
||||||
capital_cost_transparent = surface_transparent * chapter.item('B2020_transparent').refurbishment[0]
|
|
||||||
capital_cost_roof = surface_roof * chapter.item('B3010_opaque_roof').refurbishment[0]
|
|
||||||
capital_cost_ground = surface_ground * chapter.item('B10_superstructure').refurbishment[0]
|
|
||||||
|
|
||||||
|
|
||||||
self._yearly_capital_costs.loc[0, 'B2010_opaque_walls'] = capital_cost_opaque * (1-PERCENTAGE_CREDIT)
|
|
||||||
self._yearly_capital_costs.loc[0]['B2020_transparent'] = capital_cost_transparent * (1-PERCENTAGE_CREDIT)
|
|
||||||
self._yearly_capital_costs.loc[0, 'B3010_opaque_roof'] = capital_cost_roof * (1-PERCENTAGE_CREDIT)
|
|
||||||
self._yearly_capital_costs.loc[0]['B10_superstructure'] = capital_cost_ground * (1-PERCENTAGE_CREDIT)
|
|
||||||
|
|
||||||
|
|
||||||
if self._retrofitting_scenario in (SYSTEM_RETROFIT_AND_PV, SKIN_RETROFIT_AND_SYSTEM_RETROFIT_AND_PV):
|
|
||||||
chapter = chapters.chapter('D_services')
|
|
||||||
capital_cost_pv = surface_pv * chapter.item('D301010_photovoltaic_system').initial_investment[0]
|
|
||||||
self._yearly_capital_costs.loc[0]['D301010_photovoltaic_system'] = capital_cost_pv
|
|
||||||
capital_cost_heating_equipment = (
|
|
||||||
peak_heating * chapter.item('D3020_heat_generating_systems').initial_investment[0]
|
|
||||||
)
|
|
||||||
capital_cost_cooling_equipment = (
|
|
||||||
peak_cooling * chapter.item('D3030_cooling_generation_systems').initial_investment[0]
|
|
||||||
)
|
|
||||||
capital_cost_distribution_equipment = (
|
|
||||||
peak_cooling * chapter.item('D3040_distribution_systems').initial_investment[0]
|
|
||||||
)
|
|
||||||
capital_cost_other_hvac_ahu = peak_cooling * chapter.item('D3080_other_hvac_ahu').initial_investment[0]
|
|
||||||
capital_cost_lighting = total_floor_area * chapter.item('D5020_lighting_and_branch_wiring').initial_investment[0]
|
|
||||||
|
|
||||||
self._yearly_capital_costs.loc[0, 'D3020_heat_generating_systems'] = capital_cost_heating_equipment * (1-PERCENTAGE_CREDIT)
|
|
||||||
self._yearly_capital_costs.loc[0, 'D3030_cooling_generation_systems'] = capital_cost_cooling_equipment * (1-PERCENTAGE_CREDIT)
|
|
||||||
self._yearly_capital_costs.loc[0, 'D3040_distribution_systems'] = capital_cost_distribution_equipment * (1-PERCENTAGE_CREDIT)
|
|
||||||
self._yearly_capital_costs.loc[0, 'D3080_other_hvac_ahu'] = capital_cost_other_hvac_ahu * (1-PERCENTAGE_CREDIT)
|
|
||||||
self._yearly_capital_costs.loc[0, 'D5020_lighting_and_branch_wiring'] = capital_cost_lighting * (1-PERCENTAGE_CREDIT)
|
|
||||||
|
|
||||||
for year in range(1, self._number_of_years):
|
|
||||||
chapter = chapters.chapter('D_services')
|
|
||||||
costs_increase = math.pow(1 + self._consumer_price_index, year)
|
|
||||||
self._yearly_capital_costs.loc[year, 'B2010_opaque_walls'] = -npf.pmt(INTEREST_RATE, CREDIT_YEARS,
|
|
||||||
capital_cost_opaque * (PERCENTAGE_CREDIT))
|
|
||||||
self._yearly_capital_costs.loc[year, 'B2020_transparent'] = -npf.pmt(INTEREST_RATE, CREDIT_YEARS,
|
|
||||||
capital_cost_transparent * (PERCENTAGE_CREDIT)
|
|
||||||
)
|
|
||||||
self._yearly_capital_costs.loc[year, 'B3010_opaque_roof'] = -npf.pmt(INTEREST_RATE, CREDIT_YEARS,capital_cost_roof
|
|
||||||
* (PERCENTAGE_CREDIT))
|
|
||||||
self._yearly_capital_costs.loc[year, 'B10_superstructure'] = -npf.pmt(INTEREST_RATE, CREDIT_YEARS,
|
|
||||||
capital_cost_ground * (PERCENTAGE_CREDIT))
|
|
||||||
self._yearly_capital_costs.loc[year, 'D3020_heat_generating_systems'] = -npf.pmt(INTEREST_RATE,CREDIT_YEARS,
|
|
||||||
capital_cost_heating_equipment
|
|
||||||
* (PERCENTAGE_CREDIT))
|
|
||||||
self._yearly_capital_costs.loc[year, 'D3030_cooling_generation_systems'] = -npf.pmt(INTEREST_RATE, CREDIT_YEARS,
|
|
||||||
capital_cost_cooling_equipment
|
|
||||||
* (PERCENTAGE_CREDIT))
|
|
||||||
self._yearly_capital_costs.loc[year, 'D3040_distribution_systems'] = -npf.pmt(INTEREST_RATE, CREDIT_YEARS,
|
|
||||||
capital_cost_distribution_equipment
|
|
||||||
* (PERCENTAGE_CREDIT))
|
|
||||||
self._yearly_capital_costs.loc[year, 'D3080_other_hvac_ahu'] = -npf.pmt(INTEREST_RATE, CREDIT_YEARS,
|
|
||||||
capital_cost_other_hvac_ahu
|
|
||||||
* (PERCENTAGE_CREDIT))
|
|
||||||
self._yearly_capital_costs.loc[year, 'D5020_lighting_and_branch_wiring'] = -npf.pmt(INTEREST_RATE, CREDIT_YEARS,
|
|
||||||
capital_cost_lighting
|
|
||||||
* (PERCENTAGE_CREDIT))
|
|
||||||
if (year % chapter.item('D3020_heat_generating_systems').lifetime) == 0:
|
|
||||||
reposition_cost_heating_equipment = peak_heating * chapter.item('D3020_heat_generating_systems').reposition[0] \
|
|
||||||
* costs_increase
|
|
||||||
self._yearly_capital_costs.loc[year, 'D3020_heat_generating_systems'] += reposition_cost_heating_equipment
|
|
||||||
|
|
||||||
if (year % chapter.item('D3030_cooling_generation_systems').lifetime) == 0:
|
|
||||||
reposition_cost_cooling_equipment = peak_cooling \
|
|
||||||
* chapter.item('D3030_cooling_generation_systems').reposition[0] \
|
|
||||||
* costs_increase
|
|
||||||
self._yearly_capital_costs.loc[year, 'D3030_cooling_generation_systems'] += reposition_cost_cooling_equipment
|
|
||||||
|
|
||||||
if (year % chapter.item('D3080_other_hvac_ahu').lifetime) == 0:
|
|
||||||
reposition_cost_hvac_ahu = peak_cooling * chapter.item('D3080_other_hvac_ahu').reposition[0] * costs_increase
|
|
||||||
self._yearly_capital_costs.loc[year, 'D3080_other_hvac_ahu'] = reposition_cost_hvac_ahu
|
|
||||||
|
|
||||||
if (year % chapter.item('D5020_lighting_and_branch_wiring').lifetime) == 0:
|
|
||||||
reposition_cost_lighting = total_floor_area * chapter.item('D5020_lighting_and_branch_wiring').reposition[0] \
|
|
||||||
* costs_increase
|
|
||||||
self._yearly_capital_costs.loc[year, 'D5020_lighting_and_branch_wiring'] += reposition_cost_lighting
|
|
||||||
|
|
||||||
if self._retrofitting_scenario in (SYSTEM_RETROFIT_AND_PV, SKIN_RETROFIT_AND_SYSTEM_RETROFIT_AND_PV):
|
|
||||||
if (year % chapter.item('D301010_photovoltaic_system').lifetime) == 0:
|
|
||||||
self._yearly_capital_costs.loc[year]['D301010_photovoltaic_system'] += surface_pv \
|
|
||||||
* chapter.item(
|
|
||||||
'D301010_photovoltaic_system').reposition[0] * costs_increase
|
|
||||||
capital_cost_skin = capital_cost_opaque + capital_cost_ground + capital_cost_transparent + capital_cost_roof
|
|
||||||
capital_cost_hvac = (
|
|
||||||
capital_cost_heating_equipment +
|
|
||||||
capital_cost_cooling_equipment +
|
|
||||||
capital_cost_distribution_equipment +
|
|
||||||
capital_cost_other_hvac_ahu + capital_cost_lighting
|
|
||||||
)
|
|
||||||
|
|
||||||
self._yearly_capital_incomes.loc[0, 'Subsidies construction'] = (
|
|
||||||
capital_cost_skin * archetype.income.construction_subsidy/100
|
|
||||||
)
|
|
||||||
self._yearly_capital_incomes.loc[0, 'Subsidies HVAC'] = capital_cost_hvac * archetype.income.hvac_subsidy/100
|
|
||||||
self._yearly_capital_incomes.loc[0, 'Subsidies PV'] = capital_cost_pv * archetype.income.photovoltaic_subsidy/100
|
|
||||||
self._yearly_capital_incomes.fillna(0, inplace=True)
|
|
||||||
return self._yearly_capital_costs, self._yearly_capital_incomes
|
|
||||||
|
|
||||||
def calculate_end_of_life_costs(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._number_of_years + 1):
|
|
||||||
price_increase = math.pow(1 + self._consumer_price_index, year)
|
|
||||||
if year == self._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
|
|
||||||
|
|
||||||
@property
|
|
||||||
def calculate_total_operational_costs(self):
|
|
||||||
"""
|
|
||||||
Calculate total operational costs
|
|
||||||
:return: pd.DataFrame
|
|
||||||
"""
|
|
||||||
building = self._building
|
|
||||||
archetype = self._archetype
|
|
||||||
total_floor_area = self._total_floor_area
|
|
||||||
factor_residential = total_floor_area / 80
|
|
||||||
# todo: split the heating between fuels
|
|
||||||
fixed_gas_cost_year_0 = 0
|
|
||||||
variable_gas_cost_year_0 = 0
|
|
||||||
electricity_heating = 0
|
|
||||||
domestic_hot_water_electricity = 0
|
|
||||||
if self._fuel_type == 1:
|
|
||||||
fixed_gas_cost_year_0 = archetype.operational_cost.fuels[1].fixed_monthly * 12 * factor_residential
|
|
||||||
variable_gas_cost_year_0 = (
|
|
||||||
(building.heating_consumption[cte.YEAR][0] + building.domestic_hot_water_consumption[cte.YEAR][0]) / 1000 *
|
|
||||||
archetype.operational_cost.fuels[1].variable[0]
|
|
||||||
)
|
|
||||||
if self._fuel_type == 0:
|
|
||||||
electricity_heating = building.heating_consumption[cte.YEAR][0] / 1000
|
|
||||||
domestic_hot_water_electricity = building.domestic_hot_water_consumption[cte.YEAR][0] / 1000
|
|
||||||
|
|
||||||
electricity_cooling = building.cooling_consumption[cte.YEAR][0] / 1000
|
|
||||||
electricity_lighting = building.lighting_electrical_demand[cte.YEAR]['insel meb'] / 1000
|
|
||||||
electricity_plug_loads = building.appliances_electrical_demand[cte.YEAR]['insel meb'] / 1000
|
|
||||||
electricity_distribution = 0
|
|
||||||
total_electricity_consumption = (
|
|
||||||
electricity_heating + electricity_cooling + electricity_lighting + domestic_hot_water_electricity +
|
|
||||||
electricity_plug_loads + electricity_distribution
|
|
||||||
)
|
|
||||||
|
|
||||||
# todo: change when peak electricity demand is coded. Careful with factor residential
|
|
||||||
peak_electricity_demand = 100 # self._peak_electricity_demand
|
|
||||||
variable_electricity_cost_year_0 = total_electricity_consumption * archetype.operational_cost.fuels[0].variable[0]
|
|
||||||
peak_electricity_cost_year_0 = peak_electricity_demand * archetype.operational_cost.fuels[0].fixed_power * 12
|
|
||||||
monthly_electricity_cost_year_0 = archetype.operational_cost.fuels[0].fixed_monthly * 12 * factor_residential
|
|
||||||
|
|
||||||
for year in range(1, self._number_of_years + 1):
|
|
||||||
price_increase_electricity = math.pow(1 + self._electricity_price_index, year)
|
|
||||||
price_increase_peak_electricity = math.pow(1 + self._electricity_peak_index, year)
|
|
||||||
price_increase_gas = math.pow(1 + self._gas_price_index, year)
|
|
||||||
self._yearly_operational_costs.at[year, 'Fixed_costs_electricity_peak'] = (
|
|
||||||
peak_electricity_cost_year_0 * price_increase_peak_electricity
|
|
||||||
)
|
|
||||||
|
|
||||||
self._yearly_operational_costs.at[year, 'Fixed_costs_electricity_monthly'] = (
|
|
||||||
monthly_electricity_cost_year_0 * price_increase_peak_electricity
|
|
||||||
)
|
|
||||||
self._yearly_operational_costs.at[year, 'Variable_costs_electricity'] = float(
|
|
||||||
variable_electricity_cost_year_0 * price_increase_electricity
|
|
||||||
)
|
|
||||||
self._yearly_operational_costs.at[year, 'Fixed_costs_gas'] = fixed_gas_cost_year_0 * price_increase_gas
|
|
||||||
self._yearly_operational_costs.at[year, 'Variable_costs_gas'] = (
|
|
||||||
variable_gas_cost_year_0 * price_increase_peak_electricity
|
|
||||||
)
|
|
||||||
self._yearly_operational_costs.at[year, 'Variable_costs_gas'] = (
|
|
||||||
variable_gas_cost_year_0 * price_increase_peak_electricity
|
|
||||||
)
|
|
||||||
self._yearly_operational_costs.fillna(0, inplace=True)
|
|
||||||
|
|
||||||
return self._yearly_operational_costs
|
|
||||||
|
|
||||||
def calculate_total_operational_incomes(self):
|
|
||||||
"""
|
|
||||||
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._number_of_years + 1):
|
|
||||||
price_increase_electricity = math.pow(1 + self._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
|
|
||||||
|
|
||||||
def calculate_total_maintenance_costs(self):
|
|
||||||
"""
|
|
||||||
Calculate total maintenance costs
|
|
||||||
:return: pd.DataFrame
|
|
||||||
"""
|
|
||||||
building = self._building
|
|
||||||
archetype = self._archetype
|
|
||||||
# todo: change area pv when the variable exists
|
|
||||||
roof_area = 0
|
|
||||||
for roof in building.roofs:
|
|
||||||
roof_area += roof.solid_polygon.area
|
|
||||||
surface_pv = roof_area * 0.5
|
|
||||||
|
|
||||||
peak_heating = building.heating_peak_load[cte.YEAR][cte.HEATING_PEAK_LOAD][0]
|
|
||||||
peak_cooling = building.cooling_peak_load[cte.YEAR][cte.COOLING_PEAK_LOAD][0]
|
|
||||||
|
|
||||||
maintenance_heating_0 = peak_heating * archetype.operational_cost.maintenance_heating
|
|
||||||
maintenance_cooling_0 = peak_cooling * archetype.operational_cost.maintenance_cooling
|
|
||||||
maintenance_pv_0 = surface_pv * archetype.operational_cost.maintenance_pv
|
|
||||||
|
|
||||||
for year in range(1, self._number_of_years + 1):
|
|
||||||
costs_increase = math.pow(1 + self._consumer_price_index, year)
|
|
||||||
self._yearly_maintenance_costs.loc[year, 'Heating_maintenance'] = (
|
|
||||||
maintenance_heating_0 * costs_increase
|
|
||||||
)
|
|
||||||
self._yearly_maintenance_costs.loc[year, 'Cooling_maintenance'] = (
|
|
||||||
maintenance_cooling_0 * costs_increase
|
|
||||||
)
|
|
||||||
self._yearly_maintenance_costs.loc[year, 'PV_maintenance'] = (
|
|
||||||
maintenance_pv_0 * costs_increase
|
|
||||||
)
|
|
||||||
self._yearly_maintenance_costs.fillna(0, inplace=True)
|
|
||||||
return self._yearly_maintenance_costs
|
|
4
costs/outputs/.gitignore
vendored
4
costs/outputs/.gitignore
vendored
@ -1,4 +0,0 @@
|
|||||||
# Ignore everything in this directory
|
|
||||||
*
|
|
||||||
# Except this file
|
|
||||||
!.gitignore
|
|
4
costs/tmp/.gitignore
vendored
4
costs/tmp/.gitignore
vendored
@ -1,4 +0,0 @@
|
|||||||
# Ignore everything in this directory
|
|
||||||
*
|
|
||||||
# Except this file
|
|
||||||
!.gitignore
|
|
61
costs/total_maintenance_costs.py
Normal file
61
costs/total_maintenance_costs.py
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
"""
|
||||||
|
Total maintenance costs module
|
||||||
|
"""
|
||||||
|
import math
|
||||||
|
import pandas as pd
|
||||||
|
from hub.city_model_structure.building import Building
|
||||||
|
import hub.helpers.constants as cte
|
||||||
|
|
||||||
|
from costs.configuration import Configuration
|
||||||
|
from costs.cost_base import CostBase
|
||||||
|
|
||||||
|
|
||||||
|
class TotalMaintenanceCosts(CostBase):
|
||||||
|
"""
|
||||||
|
Total maintenance costs class
|
||||||
|
"""
|
||||||
|
def __init__(self, building: Building, configuration: Configuration):
|
||||||
|
super().__init__(building, configuration)
|
||||||
|
self._yearly_maintenance_costs = pd.DataFrame(
|
||||||
|
index=self._rng,
|
||||||
|
columns=[
|
||||||
|
'Heating_maintenance',
|
||||||
|
'Cooling_maintenance',
|
||||||
|
'PV_maintenance'
|
||||||
|
],
|
||||||
|
dtype='float'
|
||||||
|
)
|
||||||
|
|
||||||
|
def calculate(self) -> pd.DataFrame:
|
||||||
|
"""
|
||||||
|
Calculate total maintenance costs
|
||||||
|
:return: pd.DataFrame
|
||||||
|
"""
|
||||||
|
building = self._building
|
||||||
|
archetype = self._archetype
|
||||||
|
# todo: change area pv when the variable exists
|
||||||
|
roof_area = 0
|
||||||
|
for roof in building.roofs:
|
||||||
|
roof_area += roof.solid_polygon.area
|
||||||
|
surface_pv = roof_area * 0.5
|
||||||
|
|
||||||
|
peak_heating = building.heating_peak_load[cte.YEAR][0]
|
||||||
|
peak_cooling = building.cooling_peak_load[cte.YEAR][0]
|
||||||
|
|
||||||
|
maintenance_heating_0 = peak_heating * archetype.operational_cost.maintenance_heating
|
||||||
|
maintenance_cooling_0 = peak_cooling * archetype.operational_cost.maintenance_cooling
|
||||||
|
maintenance_pv_0 = surface_pv * archetype.operational_cost.maintenance_pv
|
||||||
|
|
||||||
|
for year in range(1, self._configuration.number_of_years + 1):
|
||||||
|
costs_increase = math.pow(1 + self._configuration.consumer_price_index, year)
|
||||||
|
self._yearly_maintenance_costs.loc[year, 'Heating_maintenance'] = (
|
||||||
|
maintenance_heating_0 * costs_increase
|
||||||
|
)
|
||||||
|
self._yearly_maintenance_costs.loc[year, 'Cooling_maintenance'] = (
|
||||||
|
maintenance_cooling_0 * costs_increase
|
||||||
|
)
|
||||||
|
self._yearly_maintenance_costs.loc[year, 'PV_maintenance'] = (
|
||||||
|
maintenance_pv_0 * costs_increase
|
||||||
|
)
|
||||||
|
self._yearly_maintenance_costs.fillna(0, inplace=True)
|
||||||
|
return self._yearly_maintenance_costs
|
92
costs/total_operational_costs.py
Normal file
92
costs/total_operational_costs.py
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
"""
|
||||||
|
Total operational costs module
|
||||||
|
"""
|
||||||
|
import math
|
||||||
|
import pandas as pd
|
||||||
|
|
||||||
|
from hub.city_model_structure.building import Building
|
||||||
|
import hub.helpers.constants as cte
|
||||||
|
|
||||||
|
from costs.configuration import Configuration
|
||||||
|
from costs.cost_base import CostBase
|
||||||
|
|
||||||
|
|
||||||
|
class TotalOperationalCosts(CostBase):
|
||||||
|
"""
|
||||||
|
End of life costs class
|
||||||
|
"""
|
||||||
|
def __init__(self, building: Building, configuration: Configuration):
|
||||||
|
super().__init__(building, configuration)
|
||||||
|
self._yearly_operational_costs = pd.DataFrame(
|
||||||
|
index=self._rng,
|
||||||
|
columns=[
|
||||||
|
'Fixed_costs_electricity_peak',
|
||||||
|
'Fixed_costs_electricity_monthly',
|
||||||
|
'Variable_costs_electricity',
|
||||||
|
'Fixed_costs_gas',
|
||||||
|
'Variable_costs_gas'
|
||||||
|
],
|
||||||
|
dtype='float'
|
||||||
|
)
|
||||||
|
|
||||||
|
def calculate(self) -> pd.DataFrame:
|
||||||
|
"""
|
||||||
|
Calculate total operational costs
|
||||||
|
:return: pd.DataFrame
|
||||||
|
"""
|
||||||
|
building = self._building
|
||||||
|
archetype = self._archetype
|
||||||
|
total_floor_area = self._total_floor_area
|
||||||
|
factor_residential = total_floor_area / 80
|
||||||
|
# todo: split the heating between fuels
|
||||||
|
fixed_gas_cost_year_0 = 0
|
||||||
|
variable_gas_cost_year_0 = 0
|
||||||
|
electricity_heating = 0
|
||||||
|
domestic_hot_water_electricity = 0
|
||||||
|
if self._configuration.fuel_type == 1:
|
||||||
|
fixed_gas_cost_year_0 = archetype.operational_cost.fuels[1].fixed_monthly * 12 * factor_residential
|
||||||
|
variable_gas_cost_year_0 = (
|
||||||
|
(building.heating_consumption[cte.YEAR][0] + building.domestic_hot_water_consumption[cte.YEAR][0]) / 1000 *
|
||||||
|
archetype.operational_cost.fuels[1].variable[0]
|
||||||
|
)
|
||||||
|
if self._configuration.fuel_type == 0:
|
||||||
|
electricity_heating = building.heating_consumption[cte.YEAR][0] / 1000
|
||||||
|
domestic_hot_water_electricity = building.domestic_hot_water_consumption[cte.YEAR][0] / 1000
|
||||||
|
|
||||||
|
electricity_cooling = building.cooling_consumption[cte.YEAR][0] / 1000
|
||||||
|
electricity_lighting = building.lighting_electrical_demand[cte.YEAR]['insel meb'] / 1000
|
||||||
|
electricity_plug_loads = building.appliances_electrical_demand[cte.YEAR]['insel meb'] / 1000
|
||||||
|
electricity_distribution = 0
|
||||||
|
total_electricity_consumption = (
|
||||||
|
electricity_heating + electricity_cooling + electricity_lighting + domestic_hot_water_electricity +
|
||||||
|
electricity_plug_loads + electricity_distribution
|
||||||
|
)
|
||||||
|
|
||||||
|
# todo: change when peak electricity demand is coded. Careful with factor residential
|
||||||
|
peak_electricity_demand = 100 # self._peak_electricity_demand
|
||||||
|
variable_electricity_cost_year_0 = total_electricity_consumption * archetype.operational_cost.fuels[0].variable[0]
|
||||||
|
peak_electricity_cost_year_0 = peak_electricity_demand * archetype.operational_cost.fuels[0].fixed_power * 12
|
||||||
|
monthly_electricity_cost_year_0 = archetype.operational_cost.fuels[0].fixed_monthly * 12 * factor_residential
|
||||||
|
|
||||||
|
for year in range(1, self._configuration.number_of_years + 1):
|
||||||
|
price_increase_electricity = math.pow(1 + self._configuration.electricity_price_index, year)
|
||||||
|
price_increase_peak_electricity = math.pow(1 + self._configuration.electricity_peak_index, year)
|
||||||
|
price_increase_gas = math.pow(1 + self._configuration.gas_price_index, year)
|
||||||
|
self._yearly_operational_costs.at[year, 'Fixed_costs_electricity_peak'] = (
|
||||||
|
peak_electricity_cost_year_0 * price_increase_peak_electricity
|
||||||
|
)
|
||||||
|
self._yearly_operational_costs.at[year, 'Fixed_costs_electricity_monthly'] = (
|
||||||
|
monthly_electricity_cost_year_0 * price_increase_peak_electricity
|
||||||
|
)
|
||||||
|
self._yearly_operational_costs.at[year, 'Variable_costs_electricity'] = (
|
||||||
|
float(variable_electricity_cost_year_0.iloc[0] * price_increase_electricity)
|
||||||
|
)
|
||||||
|
self._yearly_operational_costs.at[year, 'Fixed_costs_gas'] = fixed_gas_cost_year_0 * price_increase_gas
|
||||||
|
self._yearly_operational_costs.at[year, 'Variable_costs_gas'] = (
|
||||||
|
variable_gas_cost_year_0 * price_increase_peak_electricity
|
||||||
|
)
|
||||||
|
self._yearly_operational_costs.at[year, 'Variable_costs_gas'] = (
|
||||||
|
variable_gas_cost_year_0 * price_increase_peak_electricity
|
||||||
|
)
|
||||||
|
self._yearly_operational_costs.fillna(0, inplace=True)
|
||||||
|
return self._yearly_operational_costs
|
41
costs/total_operational_incomes.py
Normal file
41
costs/total_operational_incomes.py
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
"""
|
||||||
|
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 costs.configuration import Configuration
|
||||||
|
from costs.cost_base import CostBase
|
||||||
|
|
||||||
|
|
||||||
|
class TotalOperationalIncomes(CostBase):
|
||||||
|
"""
|
||||||
|
Total operational incomes class
|
||||||
|
"""
|
||||||
|
def __init__(self, building: Building, configuration: Configuration):
|
||||||
|
super().__init__(building, configuration)
|
||||||
|
self._yearly_operational_incomes = pd.DataFrame(index=self._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
|
4
costs/version.py
Normal file
4
costs/version.py
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
"""
|
||||||
|
Cost version number
|
||||||
|
"""
|
||||||
|
__version__ = '0.1.0.0'
|
8
pyproject.toml
Normal file
8
pyproject.toml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# pyproject.toml
|
||||||
|
|
||||||
|
[build-system]
|
||||||
|
requires = ["setuptools>=61.0.0", "wheel"]
|
||||||
|
build-backend = "setuptools.build_meta"
|
||||||
|
|
||||||
|
[options.packages.find_namespace]
|
||||||
|
where = "costs"
|
@ -1,2 +1,3 @@
|
|||||||
numpy_financial
|
numpy_financial
|
||||||
cerc_hub
|
cerc_hub
|
||||||
|
pandas
|
36
setup.py
Normal file
36
setup.py
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
import glob
|
||||||
|
import pathlib
|
||||||
|
from distutils.util import convert_path
|
||||||
|
from setuptools import setup
|
||||||
|
|
||||||
|
with pathlib.Path('requirements.txt').open() as r:
|
||||||
|
install_requires = [
|
||||||
|
str(requirement).replace('\n', '')
|
||||||
|
for requirement
|
||||||
|
in r.readlines()
|
||||||
|
]
|
||||||
|
install_requires.append('setuptools')
|
||||||
|
|
||||||
|
main_ns = {}
|
||||||
|
version = convert_path('costs/version.py')
|
||||||
|
with open(version) as f:
|
||||||
|
exec(f.read(), main_ns)
|
||||||
|
|
||||||
|
setup(
|
||||||
|
name='cerc-costs',
|
||||||
|
version=main_ns['__version__'],
|
||||||
|
description="CERC costs contains the basic cost calculation per CERC-Hub building",
|
||||||
|
long_description="CERC costs contains the basic cost calculation per CERC-Hub building",
|
||||||
|
classifiers=[
|
||||||
|
"License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)",
|
||||||
|
"Programming Language :: Python",
|
||||||
|
"Programming Language :: Python :: 3",
|
||||||
|
],
|
||||||
|
include_package_data=True,
|
||||||
|
packages=['costs'],
|
||||||
|
setup_requires=install_requires,
|
||||||
|
install_requires=install_requires,
|
||||||
|
data_files=[
|
||||||
|
('costs', glob.glob('requirements.txt'))
|
||||||
|
]
|
||||||
|
)
|
1
tests/data/test.geojson
Normal file
1
tests/data/test.geojson
Normal file
File diff suppressed because one or more lines are too long
2
tests/output/.gitignore
vendored
Normal file
2
tests/output/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
*
|
||||||
|
!.gitignore
|
73
tests/unit_tests.py
Normal file
73
tests/unit_tests.py
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
import glob
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
from hub.exports.energy_building_exports_factory import EnergyBuildingsExportsFactory
|
||||||
|
from hub.exports.exports_factory import ExportsFactory
|
||||||
|
from hub.imports.construction_factory import ConstructionFactory
|
||||||
|
from hub.imports.energy_systems_factory import EnergySystemsFactory
|
||||||
|
from hub.imports.geometry_factory import GeometryFactory
|
||||||
|
from hub.imports.results_factory import ResultFactory
|
||||||
|
from hub.imports.usage_factory import UsageFactory
|
||||||
|
from hub.helpers.dictionaries import Dictionaries
|
||||||
|
|
||||||
|
from costs.cost import Cost
|
||||||
|
from costs.constants import SKIN_RETROFIT, SKIN_RETROFIT_AND_SYSTEM_RETROFIT_AND_PV, SYSTEM_RETROFIT_AND_PV
|
||||||
|
|
||||||
|
|
||||||
|
class UnitTests(unittest.TestCase):
|
||||||
|
def setUp(self) -> None:
|
||||||
|
city_file = Path("./tests/data/test.geojson").resolve()
|
||||||
|
output_path = Path('./tests/output/').resolve()
|
||||||
|
city = GeometryFactory('geojson',
|
||||||
|
city_file,
|
||||||
|
height_field='citygml_me',
|
||||||
|
year_of_construction_field='ANNEE_CONS',
|
||||||
|
function_field='CODE_UTILI',
|
||||||
|
function_to_hub=Dictionaries().montreal_function_to_hub_function).city
|
||||||
|
ConstructionFactory('nrcan', city).enrich()
|
||||||
|
UsageFactory('nrcan', city).enrich()
|
||||||
|
ExportsFactory('sra', city, output_path).export()
|
||||||
|
sra_file = str((output_path / f'{city.name}_sra.xml').resolve())
|
||||||
|
subprocess.run(['/usr/local/bin/sra', sra_file])
|
||||||
|
ResultFactory('sra', city, output_path).enrich()
|
||||||
|
|
||||||
|
for building in city.buildings:
|
||||||
|
building.energy_systems_archetype_name = 'system 1 gas pv'
|
||||||
|
EnergySystemsFactory('montreal_custom', city).enrich()
|
||||||
|
EnergyBuildingsExportsFactory('insel_monthly_energy_balance', city, output_path).export()
|
||||||
|
_insel_files = glob.glob(f'{output_path}/*.insel')
|
||||||
|
for insel_file in _insel_files:
|
||||||
|
subprocess.run(['insel', str(insel_file)], stdout=subprocess.DEVNULL)
|
||||||
|
ResultFactory('insel_monthly_energy_balance', city, output_path).enrich()
|
||||||
|
self._city = city
|
||||||
|
|
||||||
|
def test_current_status(self):
|
||||||
|
for building in self._city.buildings:
|
||||||
|
result = Cost(building).life_cycle
|
||||||
|
self.assertIsNotNone(result)
|
||||||
|
self.assertEqual(0, result.values[0])
|
||||||
|
|
||||||
|
def test_scenario_1(self):
|
||||||
|
for building in self._city.buildings:
|
||||||
|
result = Cost(building, retrofit_scenario=SKIN_RETROFIT).life_cycle
|
||||||
|
self.assertIsNotNone(result)
|
||||||
|
|
||||||
|
def test_scenario_2(self):
|
||||||
|
for building in self._city.buildings:
|
||||||
|
result = Cost(building, retrofit_scenario=SYSTEM_RETROFIT_AND_PV).life_cycle
|
||||||
|
self.assertIsNotNone(result)
|
||||||
|
self.assertEqual(0, result.values[0])
|
||||||
|
|
||||||
|
def test_scenario_3(self):
|
||||||
|
for building in self._city.buildings:
|
||||||
|
result = Cost(building, retrofit_scenario=SKIN_RETROFIT_AND_SYSTEM_RETROFIT_AND_PV).life_cycle
|
||||||
|
self.assertIsNotNone(result)
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
files = glob.glob('output/[!.]*')
|
||||||
|
for file in files:
|
||||||
|
os.unlink(file)
|
Loading…
Reference in New Issue
Block a user