163 lines
7.9 KiB
Python
163 lines
7.9 KiB
Python
"""
|
|
Cost module
|
|
"""
|
|
import pandas as pd
|
|
from hub.city_model_structure.city import City
|
|
|
|
from configuration import Configuration
|
|
from capital_costs import LifeCycleCosts
|
|
|
|
|
|
class Cost:
|
|
"""
|
|
Cost class
|
|
"""
|
|
|
|
def __init__(self,
|
|
city: City,
|
|
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'):
|
|
self._city = city
|
|
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)
|
|
|
|
@property
|
|
def life_cycle(self) -> pd.DataFrame:
|
|
"""
|
|
Get complete life cycle costs
|
|
:return: DataFrame
|
|
"""
|
|
results = pd.DataFrame()
|
|
for building in self._city.buildings:
|
|
lcc = LifeCycleCosts(building, self._configuration)
|
|
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()
|
|
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']
|
|
return results
|
|
"""
|
|
|
|
if "gas" in building.energy_systems_archetype_name:
|
|
FUEL_TYPE = 1
|
|
else:
|
|
FUEL_TYPE = 0
|
|
|
|
|
|
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 = npf.npv(self._discount_rate, list_cashflow)_npv_from_list(, 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}')
|
|
return results
|
|
|
|
|
|
"""
|
|
|