From 7893a5524322b62039db59a8f7aacfc595aacc28 Mon Sep 17 00:00:00 2001 From: jgavalda Date: Wed, 31 May 2023 12:26:01 -0400 Subject: [PATCH] Changes in subsidy structure --- __main__.py | 18 ++++++++++------ life_cycle_costs.py | 51 +++++++++++++++++++++++++++++++++------------ 2 files changed, 50 insertions(+), 19 deletions(-) diff --git a/__main__.py b/__main__.py index 786ef2a..d106f6c 100644 --- a/__main__.py +++ b/__main__.py @@ -101,7 +101,7 @@ for retrofitting_scenario in retrofitting_scenarios: if retrofitting_scenario == 1 or retrofitting_scenario == 3: for building in city.buildings: - building.year_of_construction = 2020 + building.year_of_construction = retrofitting_year_of_construction ConstructionFactory(construction_format, city).enrich() print('enrich retrofitted constructions... done') @@ -131,7 +131,7 @@ for retrofitting_scenario in retrofitting_scenarios: print(f'fuel type {fuel_type}') 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 = lcc.calculate_capital_costs() + 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() @@ -143,7 +143,7 @@ for retrofitting_scenario in retrofitting_scenarios: 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'] + @@ -173,12 +173,16 @@ for retrofitting_scenario in retrofitting_scenarios: ) 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 + @@ -186,7 +190,8 @@ for retrofitting_scenario in retrofitting_scenarios: life_cycle_costs_end_of_life_costs + life_cycle_operational_costs + life_cycle_maintenance_costs - - life_cycle_operational_incomes + life_cycle_operational_incomes - + life_cycle_capital_incomes ) life_cycle_results[f'Scenario {retrofitting_scenario}'] = [life_cycle_costs_capital_skin, @@ -194,12 +199,13 @@ for retrofitting_scenario in retrofitting_scenarios: life_cycle_costs_end_of_life_costs, life_cycle_operational_costs, life_cycle_maintenance_costs, - life_cycle_operational_incomes] + life_cycle_operational_incomes, + life_cycle_capital_incomes] life_cycle_results.index = [f'total_capital_costs_skin', f'total_capital_costs_systems', f'end_of_life_costs', f'total_operational_costs', f'total_maintenance_costs', - f'operational_incomes'] + f'operational_incomes', f'capital_incomes'] print(life_cycle_results) print(f'Scenario {retrofitting_scenario} {life_cycle_costs}') diff --git a/life_cycle_costs.py b/life_cycle_costs.py index b57be4d..3d30bf4 100644 --- a/life_cycle_costs.py +++ b/life_cycle_costs.py @@ -63,6 +63,8 @@ class LifeCycleCosts: '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): building = self._building archetype = self._archetype @@ -71,6 +73,17 @@ class LifeCycleCosts: 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: @@ -98,7 +111,6 @@ class LifeCycleCosts: 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, 'B_Shell'] = 0 self._yearly_capital_costs.loc[0, 'D3020_heat_generating_systems'] = 0 self._yearly_capital_costs.loc[0, 'D3030_cooling_generation_systems'] = 0 @@ -106,6 +118,10 @@ class LifeCycleCosts: 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 (self.SKIN_RETROFIT, self.SKIN_RETROFIT_AND_SYSTEM_RETROFIT_AND_PV): chapter = chapters.chapter('B_shell') @@ -113,12 +129,13 @@ class LifeCycleCosts: 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] - capital_cost_skin = capital_cost_opaque + capital_cost_transparent + capital_cost_roof + capital_cost_ground + + self._yearly_capital_costs.loc[0, 'B2010_opaque_walls'] = capital_cost_opaque self._yearly_capital_costs.loc[0]['B2020_transparent'] = capital_cost_transparent self._yearly_capital_costs.loc[0, 'B3010_opaque_roof'] = capital_cost_roof self._yearly_capital_costs.loc[0]['B10_superstructure'] = capital_cost_ground - self._yearly_capital_costs.loc[0, 'B_Shell'] = capital_cost_skin + if self._retrofitting_scenario in (self.SYSTEM_RETROFIT_AND_PV, self.SKIN_RETROFIT_AND_SYSTEM_RETROFIT_AND_PV): chapter = chapters.chapter('D_services') @@ -135,6 +152,7 @@ class LifeCycleCosts: ) 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 self._yearly_capital_costs.loc[0, 'D3030_cooling_generation_systems'] = capital_cost_cooling_equipment self._yearly_capital_costs.loc[0, 'D3040_distribution_systems'] = capital_cost_distribution_equipment @@ -170,7 +188,16 @@ class LifeCycleCosts: self._yearly_capital_costs.loc[year]['D301010_photovoltaic_system'] = surface_pv \ * chapter.item( 'D301010_photovoltaic_system').reposition[0] * costs_increase - return self._yearly_capital_costs + 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): archetype = self._archetype @@ -216,11 +243,6 @@ class LifeCycleCosts: # todo: change when peak electricity demand is coded. Careful with factor residential peak_electricity_demand = 100 # self._peak_electricity_demand - print(f'total_electricity_cooling {electricity_cooling}') - print(f'total_electricity_lighting {electricity_lighting}') - print(f'total_electricity_plug_loads {electricity_plug_loads}') - print(f'total_electricity_consumption {total_electricity_consumption}') - print(f'price_electricity {archetype.operational_cost.fuels[0].variable[0]}') 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 @@ -260,10 +282,13 @@ class LifeCycleCosts: price_increase_electricity = 0 for year in range(1, self._number_of_years + 1): - price_increase_electricity += math.pow(1 + self._electricity_price_index, year) - - self._yearly_operational_incomes.loc[year, 'Incomes electricity'] = onsite_electricity_production * \ - price_increase_electricity + 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