Improved speed not repeating lcc function. Ready to comment with guille

This commit is contained in:
Oriol Gavalda 2023-05-30 08:15:44 -04:00
parent fa09b48624
commit 9f97e2b2f2
2 changed files with 29 additions and 22 deletions

View File

@ -185,8 +185,9 @@ class LifeCycleCosts:
electricity_lighting = building.lighting_electrical_demand[cte.YEAR]['insel meb']/1000
domestic_hot_water_demand = building.domestic_hot_water_consumption[cte.YEAR][0]/1000
electricity_plug_loads = building.appliances_electrical_demand[cte.YEAR]['insel meb']/1000
electricity_distribution = building.distribution_systems_electrical_consumption [cte.YEAR][0]/1000
total_electricity_consumption = electricity_heating + electricity_cooling + electricity_lighting + \
domestic_hot_water_demand + electricity_plug_loads
domestic_hot_water_demand + 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
factor_residential= total_floor_area/80
@ -217,6 +218,7 @@ class LifeCycleCosts:
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):

47
main.py
View File

@ -128,27 +128,32 @@ for retrofitting_scenario in retrofitting_scenarios:
print('lcc for first building started')
lcc = LifeCycleCosts(building, archetype, number_of_years, consumer_price_index, electricity_peak_index,
electricity_price_index, gas_price_index, discount_rate, retrofitting_scenario)
df_capital_costs_skin = lcc.calculate_capital_costs()['B2010_opaque_walls']+\
lcc.calculate_capital_costs()['B2020_transparent']+\
lcc.calculate_capital_costs()['B3010_opaque_roof']+\
lcc.calculate_capital_costs()['B10_superstructure']
df_capital_costs_systems = lcc.calculate_capital_costs()['D3020_heat_generating_systems']+\
lcc.calculate_capital_costs()['D3030_cooling_generation_systems']+\
lcc.calculate_capital_costs()['D3080_other_hvac_ahu']+\
lcc.calculate_capital_costs()['D5020_lighting_and_branch_wiring']+\
lcc.calculate_capital_costs()['D301010_photovoltaic_system']
df_end_of_life_costs = lcc.calculate_end_of_life_costs()['End_of_life_costs']
df_operational_costs = lcc.calculate_total_operational_costs()['Fixed_costs_electricity_peak']+\
lcc.calculate_total_operational_costs()['Fixed_costs_electricity_monthly']+\
lcc.calculate_total_operational_costs()['Fixed_costs_electricity_peak']+\
lcc.calculate_total_operational_costs()['Fixed_costs_electricity_monthly']+\
lcc.calculate_total_operational_costs()['Variable_costs_electricity']+ \
lcc.calculate_total_operational_costs()['Fixed_costs_gas']+ \
lcc.calculate_total_operational_costs()['Variable_costs_gas']
df_maintenance_costs = lcc.calculate_total_maintenance_costs()['Heating_maintenance']+\
lcc.calculate_total_maintenance_costs()['Cooling_maintenance']+\
lcc.calculate_total_maintenance_costs()['PV_maintenance']
df_operational_incomes = lcc.calculate_total_operational_incomes()['Incomes electricity']
global_capital_costs = 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()
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']
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())