bug correction

This commit is contained in:
Guille Gutierrez 2023-05-30 14:42:49 -04:00
parent fff569b46f
commit 3a7ecb2472
3 changed files with 97 additions and 94 deletions

View File

@ -41,9 +41,12 @@ class LifeCycleCosts:
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'],
'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',
@ -109,7 +112,6 @@ class LifeCycleCosts:
= [capital_cost_opaque, capital_cost_transparent, capital_cost_roof, capital_cost_ground, capital_cost_skin]
if self._retrofitting_scenario == 2 or self._retrofitting_scenario == 3:
chapter = chapters.chapter('D_services')
capital_cost_pv = surface_pv * chapter.item('D301010_photovoltaic_system').initial_investment[0]
@ -160,7 +162,8 @@ class LifeCycleCosts:
if self._retrofitting_scenario == 2 or self._retrofitting_scenario == 3:
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
* chapter.item(
'D301010_photovoltaic_system').reposition[0] * costs_increase
return self._yearly_capital_costs
def calculate_end_of_life_costs(self):
@ -171,7 +174,8 @@ class LifeCycleCosts:
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.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
@ -219,8 +223,9 @@ class LifeCycleCosts:
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'] = variable_electricity_cost_year_0 * \
price_increase_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 * \
@ -234,12 +239,10 @@ class LifeCycleCosts:
def calculate_total_operational_incomes(self):
building = self._building
archetype = self._archetype
if (building.onsite_electrical_production is None):
if cte.YEAR not in building.onsite_electrical_production:
onsite_electricity_production = 0
else:
onsite_electricity_production= 100 #building.onsite_electrical_production[cte.YEAR]/1000
onsite_electricity_production = building.onsite_electrical_production[cte.YEAR][0]/1000
price_increase_electricity = 0
for year in range(1, self._number_of_years + 1):
@ -255,16 +258,18 @@ class LifeCycleCosts:
building = self._building
archetype = self._archetype
# todo: change area pv when the variable exists
surface_pv = 10 #building.area_pv
roof_area = 0
for roof in building.roofs:
roof_area += roof.solid_polygon.area
surface_pv = roof_area * 0.5
peak_heating = 100#building.heating_peak_load[cte.YEAR][0]
peak_cooling = 100#building.cooling_peak_load[cte.YEAR][0]
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
print(f'peak_heating{peak_heating}')
print(f'maintenance_cost{archetype.operational_cost.maintenance_heating}')
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 * \

19
main.py
View File

@ -7,25 +7,23 @@ Copyright © 2022 Project Author Pilar Monsalvete Álvarez de Uribarri pilar.mon
import glob
import os
from pathlib import Path
import sys
import pandas as pd
import numpy_financial as npf
from hub.imports.construction_factory import ConstructionFactory
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 hub.catalog_factories.costs_catalog_factory import CostCatalogFactory
import hub.helpers.constants as cte
from monthly_energy_balance_engine import MonthlyEnergyBalanceEngine
from sra_engine import SraEngine
from hub.imports.energy_systems_factory import EnergySystemsFactory
from energy_systems_sizing import EnergySystemsSizing
from life_cycle_costs import LifeCycleCosts
def _npv_from_list(npv_discount_rate, list_cashflow):
lcc_value = npf.npv(npv_discount_rate, list_cashflow)
return lcc_value
@ -188,6 +186,5 @@ for retrofitting_scenario in retrofitting_scenarios:
print(life_cycle_results)
print(f'Scenario {retrofitting_scenario} {life_cycle_costs}')
#todo: change if there is more than 1 building
life_cycle_results.to_excel(Path(__file__).parent/'out_files'/f'Results.xlsx', index=True)

1
resources.txt Normal file
View File

@ -0,0 +1 @@
numpy_financial