diff --git a/costs/__main__.py b/costs/__main__.py index 3c45080..b8b6ab3 100644 --- a/costs/__main__.py +++ b/costs/__main__.py @@ -5,31 +5,3 @@ Copyright © 2022 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.mons Code contributor Oriol Gavalda Torrellas oriol.gavalda@concordia.ca """ -from pathlib import Path - - -import pandas as pd -from energy_systems_sizing import EnergySystemsSizing - -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_old 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 - - diff --git a/costs/building.py b/costs/building.py deleted file mode 100644 index 5b6441b..0000000 --- a/costs/building.py +++ /dev/null @@ -1,6 +0,0 @@ -from hub.persistence.models.city_object import CityObject - -class Building(CityObject): - - def __init__(self, ): - super() \ No newline at end of file diff --git a/costs/life_cycle_costs.py b/costs/life_cycle_costs.py index 0e88ed7..e7e5d2f 100644 --- a/costs/life_cycle_costs.py +++ b/costs/life_cycle_costs.py @@ -1,8 +1,9 @@ """ Life cycle costs module """ - +import pandas as pd from hub.city_model_structure.building import Building +import hub.helpers.constants as cte from configuration import Configuration @@ -10,18 +11,61 @@ class LifeCycleCosts: """ Life cycle costs class """ - def __init__(self, building: Building, configuration: Configuration): + def __init__(self, building: Building, configuration: Configuration, retrofit_scenario): self._building = building self._configuration = configuration + self._retrofit_scenario = retrofit_scenario 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 + rng = range(configuration.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_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=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 + for archetype in self._configuration.cost_catalog.entries('archetypes').archetype: if str(building.function) == str(archetype.function): self._archetype = archetype + self._capital_costs_chapter = self._archetype.capital_cost break if not self._archetype: raise KeyError('archetype not found') @@ -46,9 +90,7 @@ class LifeCycleCosts: capital_cost_other_hvac_ahu = 0 capital_cost_lighting = 0 - total_floor_area = self._building.floor_area - - for internal_zone in building.internal_zones: + 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': @@ -59,30 +101,12 @@ class LifeCycleCosts: 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 = self._building.heating_peak_load[cte.YEAR].values[0] / 1000 + peak_cooling = self._building.cooling_peak_load[cte.YEAR].values[0] / 1000 - 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 + 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) if self._retrofitting_scenario in (SKIN_RETROFIT, SKIN_RETROFIT_AND_SYSTEM_RETROFIT_AND_PV):