some reorganization to avoid hard-coding
This commit is contained in:
parent
4e19afbf98
commit
f9bb954be8
|
@ -7,11 +7,12 @@ Project contributor 2023 Author Oriol Gavaldà Torrellas oriol.gavalda@concordia
|
||||||
|
|
||||||
import math
|
import math
|
||||||
|
|
||||||
|
import hub.helpers.constants as cte
|
||||||
|
|
||||||
|
|
||||||
class LifeCycleCosts:
|
class LifeCycleCosts:
|
||||||
# todo: this should be (city, costs_catalog) or similar
|
|
||||||
def __init__(self, building, archetype, number_of_years, consumer_price_index, discount_rate,
|
def __init__(self, building, archetype, number_of_years, consumer_price_index, discount_rate,
|
||||||
retrofitting_scenario):
|
retrofitting_scenario, heating_scop, cooling_seer, peak_electricity_demand, factor_pv):
|
||||||
self._building = building
|
self._building = building
|
||||||
self._number_of_years = number_of_years
|
self._number_of_years = number_of_years
|
||||||
self._consumer_price_index = consumer_price_index
|
self._consumer_price_index = consumer_price_index
|
||||||
|
@ -23,24 +24,29 @@ class LifeCycleCosts:
|
||||||
self._fuels = 0
|
self._fuels = 0
|
||||||
self._concepts = 0
|
self._concepts = 0
|
||||||
self._retrofitting_scenario = retrofitting_scenario
|
self._retrofitting_scenario = retrofitting_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._heating_scop = heating_scop
|
||||||
|
self._cooling_seer = cooling_seer
|
||||||
|
self._peak_electricity_demand = peak_electricity_demand
|
||||||
|
self._factor_pv = factor_pv
|
||||||
|
|
||||||
def calculate_capital_costs(self):
|
def calculate_capital_costs(self):
|
||||||
building = self._building
|
building = self._building
|
||||||
archetype = self._archetype
|
archetype = self._archetype
|
||||||
|
factor_pv = self._factor_pv
|
||||||
|
|
||||||
surface_opaque = 0
|
surface_opaque = 0
|
||||||
surface_transparent = 0
|
surface_transparent = 0
|
||||||
surface_roof = 0
|
surface_roof = 0
|
||||||
surface_ground = 0
|
surface_ground = 0
|
||||||
factor_pv = 0.5
|
total_floor_area = self._total_floor_area
|
||||||
factor_heating_power = 0.1 # kW/m2
|
|
||||||
factor_cooling_power = 0.1 # kW/m2
|
|
||||||
total_floor_area = 0
|
|
||||||
|
|
||||||
for internal_zone in building.internal_zones:
|
for internal_zone in building.internal_zones:
|
||||||
for thermal_zone in internal_zone.thermal_zones:
|
for thermal_zone in internal_zone.thermal_zones:
|
||||||
total_floor_area += thermal_zone.total_floor_area
|
|
||||||
print(total_floor_area)
|
|
||||||
for thermal_boundary in thermal_zone.thermal_boundaries:
|
for thermal_boundary in thermal_zone.thermal_boundaries:
|
||||||
if thermal_boundary.type == 'Ground':
|
if thermal_boundary.type == 'Ground':
|
||||||
surface_ground += thermal_boundary.opaque_area
|
surface_ground += thermal_boundary.opaque_area
|
||||||
|
@ -54,35 +60,38 @@ class LifeCycleCosts:
|
||||||
chapters = archetype.capital_cost
|
chapters = archetype.capital_cost
|
||||||
capital_cost_skin = 0
|
capital_cost_skin = 0
|
||||||
capital_cost_services = 0
|
capital_cost_services = 0
|
||||||
|
reposition_cost_pv = 0
|
||||||
|
|
||||||
|
peak_heating = building.heating_peak_load[cte.YEAR]['insel'][0]
|
||||||
|
peak_cooling = building.cooling_peak_load[cte.YEAR]['insel'][0]
|
||||||
|
|
||||||
if self._retrofitting_scenario == 1 or self._retrofitting_scenario == 3:
|
if self._retrofitting_scenario == 1 or self._retrofitting_scenario == 3:
|
||||||
chapter = chapters.chapter('B_shell')
|
chapter = chapters.chapter('B_shell')
|
||||||
capital_cost_opaque = surface_opaque * chapter.item('B2010_opaque_walls').refurbishment[0]
|
capital_cost_opaque = surface_opaque * chapter.item('B2010_opaque_walls').refurbishment[0]
|
||||||
capital_cost_transparent = surface_transparent * chapter.item('B2020_transparent').refurbishment[0]
|
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_roof = surface_roof * chapter.item('B3010_opaque_roof').refurbishment[0]
|
||||||
capital_cost_ground = surface_ground * chapter.item('B10_superstructure').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
|
capital_cost_skin = capital_cost_opaque+capital_cost_transparent+capital_cost_roof+capital_cost_ground
|
||||||
print(f'capital cost skin {capital_cost_skin}')
|
print(f'capital cost skin {capital_cost_skin}')
|
||||||
if self._retrofitting_scenario == 2 or self._retrofitting_scenario == 3:
|
if self._retrofitting_scenario == 2 or self._retrofitting_scenario == 3:
|
||||||
chapter = chapters.chapter('D_services')
|
chapter = chapters.chapter('D_services')
|
||||||
capital_cost_pv = surface_roof * factor_pv * chapter.item('D301010_photovoltaic_system').initial_investment[0]
|
capital_cost_pv = surface_roof * factor_pv * chapter.item('D301010_photovoltaic_system').initial_investment[0]
|
||||||
reposition_cost_pv = 0
|
|
||||||
for year in range(1, self._number_of_years + 1):
|
for year in range(1, self._number_of_years + 1):
|
||||||
costs_increase = math.pow(1 + self._consumer_price_index, year) / math.pow(1 + self._discount_rate, year)
|
costs_increase = math.pow(1 + self._consumer_price_index, year) / math.pow(1 + self._discount_rate, year)
|
||||||
if (year % chapter.item('D301010_photovoltaic_system').lifetime) == 0:
|
if (year % chapter.item('D301010_photovoltaic_system').lifetime) == 0:
|
||||||
reposition_cost_pv += surface_roof * factor_pv * chapter.item('D301010_photovoltaic_system').reposition[
|
reposition_cost_pv += surface_roof * factor_pv * chapter.item('D301010_photovoltaic_system').reposition[
|
||||||
0] * costs_increase
|
0] * costs_increase
|
||||||
|
|
||||||
capital_cost_heating_equipment = total_floor_area * factor_heating_power \
|
capital_cost_heating_equipment = peak_heating \
|
||||||
* chapter.item('D3020_heat_generating_systems').initial_investment[0]
|
* chapter.item('D3020_heat_generating_systems').initial_investment[0]
|
||||||
|
|
||||||
capital_cost_cooling_equipment = total_floor_area * factor_cooling_power \
|
capital_cost_cooling_equipment = peak_cooling \
|
||||||
* chapter.item('D3030_cooling_generation_systems').initial_investment[0]
|
* chapter.item('D3030_cooling_generation_systems').initial_investment[0]
|
||||||
|
|
||||||
capital_cost_distribution_equipment = total_floor_area * factor_cooling_power \
|
capital_cost_distribution_equipment = peak_cooling \
|
||||||
* chapter.item('D3040_distribution_systems').initial_investment[0]
|
* chapter.item('D3040_distribution_systems').initial_investment[0]
|
||||||
|
|
||||||
capital_cost_other_hvac_ahu = total_floor_area * factor_cooling_power \
|
capital_cost_other_hvac_ahu = peak_cooling * chapter.item('D3080_other_hvac_ahu').initial_investment[0]
|
||||||
* chapter.item('D3080_other_hvac_ahu').initial_investment[0]
|
|
||||||
|
|
||||||
capital_cost_lighting = total_floor_area * factor_pv \
|
capital_cost_lighting = total_floor_area * factor_pv \
|
||||||
* chapter.item('D5020_lighting_and_branch_wiring').initial_investment[0]
|
* chapter.item('D5020_lighting_and_branch_wiring').initial_investment[0]
|
||||||
|
@ -95,23 +104,19 @@ class LifeCycleCosts:
|
||||||
reposition_cost_cooling_equipment = 0
|
reposition_cost_cooling_equipment = 0
|
||||||
reposition_cost_lighting = 0
|
reposition_cost_lighting = 0
|
||||||
reposition_cost_hvac_ahu = 0
|
reposition_cost_hvac_ahu = 0
|
||||||
reposition_cost_pv = 0
|
|
||||||
|
|
||||||
for year in range(1, self._number_of_years + 1):
|
for year in range(1, self._number_of_years + 1):
|
||||||
chapter = chapters.chapter('D_services')
|
chapter = chapters.chapter('D_services')
|
||||||
costs_increase = math.pow(1 + self._consumer_price_index, year) / math.pow(1 + self._discount_rate, year)
|
costs_increase = math.pow(1 + self._consumer_price_index, year) / math.pow(1 + self._discount_rate, year)
|
||||||
if (year % chapter.item('D3020_heat_generating_systems').lifetime) == 0:
|
if (year % chapter.item('D3020_heat_generating_systems').lifetime) == 0:
|
||||||
reposition_cost_heating_equipment = total_floor_area * factor_heating_power * \
|
reposition_cost_heating_equipment = peak_heating * chapter.item('D3020_heat_generating_systems').reposition[0] \
|
||||||
chapter.item('D3020_heat_generating_systems').reposition[
|
* costs_increase
|
||||||
0] * costs_increase
|
|
||||||
if (year % chapter.item('D3030_cooling_generation_systems').lifetime) == 0:
|
if (year % chapter.item('D3030_cooling_generation_systems').lifetime) == 0:
|
||||||
reposition_cost_cooling_equipment = total_floor_area * factor_cooling_power * \
|
reposition_cost_cooling_equipment = peak_cooling \
|
||||||
chapter.item('D3030_cooling_generation_systems').reposition[
|
* chapter.item('D3030_cooling_generation_systems').reposition[0] \
|
||||||
0] * costs_increase
|
* costs_increase
|
||||||
if (year % chapter.item('D3080_other_hvac_ahu').lifetime) == 0:
|
if (year % chapter.item('D3080_other_hvac_ahu').lifetime) == 0:
|
||||||
reposition_cost_hvac_ahu = total_floor_area * factor_cooling_power * \
|
reposition_cost_hvac_ahu = peak_cooling * chapter.item('D3080_other_hvac_ahu').reposition[0] * costs_increase
|
||||||
chapter.item('D3080_other_hvac_ahu').reposition[
|
|
||||||
0] * costs_increase
|
|
||||||
if (year % chapter.item('D5020_lighting_and_branch_wiring').lifetime) == 0:
|
if (year % chapter.item('D5020_lighting_and_branch_wiring').lifetime) == 0:
|
||||||
reposition_cost_lighting = total_floor_area * chapter.item('D5020_lighting_and_branch_wiring').reposition[0] \
|
reposition_cost_lighting = total_floor_area * chapter.item('D5020_lighting_and_branch_wiring').reposition[0] \
|
||||||
* costs_increase
|
* costs_increase
|
||||||
|
@ -131,15 +136,9 @@ class LifeCycleCosts:
|
||||||
return life_cycle_cost_capital_total
|
return life_cycle_cost_capital_total
|
||||||
|
|
||||||
def calculate_end_of_life_costs(self):
|
def calculate_end_of_life_costs(self):
|
||||||
building = self._building
|
|
||||||
archetype = self._archetype
|
archetype = self._archetype
|
||||||
|
|
||||||
total_floor_area = 0
|
total_floor_area = self._total_floor_area
|
||||||
|
|
||||||
for internal_zone in building.internal_zones:
|
|
||||||
for thermal_zone in internal_zone.thermal_zones:
|
|
||||||
total_floor_area += thermal_zone.total_floor_area
|
|
||||||
print(total_floor_area)
|
|
||||||
|
|
||||||
price_increase = 0
|
price_increase = 0
|
||||||
for year in range(1, self._number_of_years + 1):
|
for year in range(1, self._number_of_years + 1):
|
||||||
|
@ -156,37 +155,17 @@ class LifeCycleCosts:
|
||||||
peak_cost = 0
|
peak_cost = 0
|
||||||
monthly_cost = 0
|
monthly_cost = 0
|
||||||
variable_cost = 0
|
variable_cost = 0
|
||||||
total_floor_area = 0
|
total_floor_area = self._total_floor_area
|
||||||
|
|
||||||
for internal_zone in building.internal_zones:
|
|
||||||
for thermal_zone in internal_zone.thermal_zones:
|
|
||||||
total_floor_area += thermal_zone.total_floor_area
|
|
||||||
|
|
||||||
if self._retrofitting_scenario == 1 or self._retrofitting_scenario == 3:
|
|
||||||
specific_heating_demand = 50
|
|
||||||
else:
|
|
||||||
specific_heating_demand = 190
|
|
||||||
|
|
||||||
heating_demand = specific_heating_demand * total_floor_area
|
|
||||||
cooling_demand = 10 * total_floor_area
|
|
||||||
|
|
||||||
if self._retrofitting_scenario == 2 or self._retrofitting_scenario == 3:
|
|
||||||
heating_scop = 3
|
|
||||||
cooling_seer = 4.5
|
|
||||||
else:
|
|
||||||
heating_scop = 1
|
|
||||||
cooling_seer = 2
|
|
||||||
|
|
||||||
electricity_heating = heating_demand/heating_scop
|
|
||||||
electricity_cooling = cooling_demand/cooling_seer
|
|
||||||
electricity_lighting = 11 * total_floor_area
|
|
||||||
electricity_plug_loads = 19 * total_floor_area
|
|
||||||
domestic_hot_water_demand = 50 * total_floor_area
|
|
||||||
|
|
||||||
|
electricity_heating = building.heating[cte.YEAR]['insel'][0] / self._heating_scop
|
||||||
|
electricity_cooling = building.cooling[cte.YEAR]['insel'][0] / self._cooling_seer
|
||||||
|
electricity_lighting = building.lighting_electrical_demand[cte.YEAR]['insel'][0]
|
||||||
|
domestic_hot_water_demand = building.domestic_hot_water_heat_demand[cte.YEAR]['insel'][0]
|
||||||
|
electricity_plug_loads = building.appliances_electrical_demand[cte.YEAR]['insel'][0]
|
||||||
total_electricity_consumption = electricity_cooling + electricity_heating + electricity_lighting \
|
total_electricity_consumption = electricity_cooling + electricity_heating + electricity_lighting \
|
||||||
+ domestic_hot_water_demand + electricity_plug_loads
|
+ domestic_hot_water_demand + electricity_plug_loads
|
||||||
|
|
||||||
peak_electricity_demand = 0.1 * total_floor_area
|
peak_electricity_demand = self._peak_electricity_demand
|
||||||
|
|
||||||
operational_cost_year_0 = total_electricity_consumption * archetype.operational_cost.fuels[0].variable[0]
|
operational_cost_year_0 = total_electricity_consumption * archetype.operational_cost.fuels[0].variable[0]
|
||||||
peak_cost_year_0 = peak_electricity_demand * archetype.operational_cost.fuels[0].fixed_power * 12
|
peak_cost_year_0 = peak_electricity_demand * archetype.operational_cost.fuels[0].fixed_power * 12
|
||||||
|
@ -209,26 +188,25 @@ class LifeCycleCosts:
|
||||||
def calculate_total_maintenance_costs(self):
|
def calculate_total_maintenance_costs(self):
|
||||||
building = self._building
|
building = self._building
|
||||||
archetype = self._archetype
|
archetype = self._archetype
|
||||||
total_floor_area = 0
|
factor_pv = self._factor_pv
|
||||||
|
|
||||||
factor_pv = 0.5
|
|
||||||
factor_heating_power = 0.1 # kW/m2
|
|
||||||
factor_cooling_power = 0.1 # kW/m2
|
|
||||||
surface_roof = 0
|
surface_roof = 0
|
||||||
maintenance_pv = 0
|
maintenance_pv = 0
|
||||||
maintenance_heating = 0
|
maintenance_heating = 0
|
||||||
maintenance_cooling = 0
|
maintenance_cooling = 0
|
||||||
|
|
||||||
|
peak_heating = building.heating_peak_load[cte.YEAR]['insel'][0]
|
||||||
|
peak_cooling = building.cooling_peak_load[cte.YEAR]['insel'][0]
|
||||||
|
|
||||||
for internal_zone in building.internal_zones:
|
for internal_zone in building.internal_zones:
|
||||||
for thermal_zone in internal_zone.thermal_zones:
|
for thermal_zone in internal_zone.thermal_zones:
|
||||||
total_floor_area += thermal_zone.total_floor_area
|
|
||||||
for thermal_boundary in thermal_zone.thermal_boundaries:
|
for thermal_boundary in thermal_zone.thermal_boundaries:
|
||||||
if thermal_boundary.type == 'Roof':
|
if thermal_boundary.type == 'Roof':
|
||||||
surface_roof += thermal_boundary.opaque_area
|
surface_roof += thermal_boundary.opaque_area
|
||||||
surface_pv = surface_roof*factor_pv
|
surface_pv = surface_roof * factor_pv
|
||||||
maintenance_pv_0 = surface_pv * archetype.operational_cost.maintenance_pv
|
maintenance_pv_0 = surface_pv * archetype.operational_cost.maintenance_pv
|
||||||
maintenance_heating_0 = total_floor_area*factor_heating_power * archetype.operational_cost.maintenance_heating
|
maintenance_heating_0 = peak_heating * archetype.operational_cost.maintenance_heating
|
||||||
maintenance_cooling_0 = total_floor_area*factor_cooling_power * archetype.operational_cost.maintenance_cooling
|
maintenance_cooling_0 = peak_cooling * archetype.operational_cost.maintenance_cooling
|
||||||
for year in range(1, self._number_of_years + 1):
|
for year in range(1, self._number_of_years + 1):
|
||||||
costs_increase = math.pow(1 + self._consumer_price_index, year) / math.pow(1 + self._discount_rate, year)
|
costs_increase = math.pow(1 + self._consumer_price_index, year) / math.pow(1 + self._discount_rate, year)
|
||||||
maintenance_pv += maintenance_pv_0 * costs_increase
|
maintenance_pv += maintenance_pv_0 * costs_increase
|
||||||
|
|
25
main.py
25
main.py
|
@ -14,6 +14,7 @@ from hub.helpers.dictionaries import Dictionaries
|
||||||
from hub.hub_logger import logger
|
from hub.hub_logger import logger
|
||||||
from hub.imports.geometry_factory import GeometryFactory
|
from hub.imports.geometry_factory import GeometryFactory
|
||||||
from hub.catalog_factories.costs_catalog_factory import CostCatalogFactory
|
from hub.catalog_factories.costs_catalog_factory import CostCatalogFactory
|
||||||
|
import hub.helpers.constants as cte
|
||||||
|
|
||||||
from life_cycle_costs import LifeCycleCosts
|
from life_cycle_costs import LifeCycleCosts
|
||||||
|
|
||||||
|
@ -44,11 +45,23 @@ city = GeometryFactory('geojson',
|
||||||
print(f'city created from {file_path}')
|
print(f'city created from {file_path}')
|
||||||
ConstructionFactory('nrcan', city).enrich()
|
ConstructionFactory('nrcan', city).enrich()
|
||||||
print('enrich constructions... done')
|
print('enrich constructions... done')
|
||||||
|
catalog = CostCatalogFactory('montreal_custom').catalog
|
||||||
|
print('costs catalog access... done')
|
||||||
|
|
||||||
number_of_years = 30
|
number_of_years = 30
|
||||||
consumer_price_index = 0.04
|
consumer_price_index = 0.04
|
||||||
discount_rate = 0.03
|
discount_rate = 0.03
|
||||||
|
for building in city.buildings:
|
||||||
|
building.heating[cte.YEAR]['insel'] = [23]
|
||||||
|
building.cooling[cte.YEAR]['insel'] = [13]
|
||||||
|
building.lighting_electrical_demand[cte.YEAR]['insel'] = [58]
|
||||||
|
building.appliances_electrical_demand[cte.YEAR]['insel'] = [32]
|
||||||
|
building.domestic_hot_water_heat_demand[cte.YEAR]['insel'] = [22]
|
||||||
|
|
||||||
|
peak_electricity_demand = 33
|
||||||
|
factor_pv = 0.5
|
||||||
|
|
||||||
retrofitting_scenarios = [0, 1, 2, 3]
|
retrofitting_scenarios = [0, 1, 2, 3]
|
||||||
catalog = CostCatalogFactory('montreal_custom').catalog
|
|
||||||
|
|
||||||
for building in city.buildings:
|
for building in city.buildings:
|
||||||
try:
|
try:
|
||||||
|
@ -62,8 +75,16 @@ for building in city.buildings:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
for retrofitting_scenario in retrofitting_scenarios:
|
for retrofitting_scenario in retrofitting_scenarios:
|
||||||
|
if retrofitting_scenario == 2 or retrofitting_scenario == 3:
|
||||||
|
heating_scop = 3
|
||||||
|
cooling_seer = 4.5
|
||||||
|
else:
|
||||||
|
heating_scop = 1
|
||||||
|
cooling_seer = 2
|
||||||
|
|
||||||
lcc = LifeCycleCosts(building, archetype, number_of_years, consumer_price_index,
|
lcc = LifeCycleCosts(building, archetype, number_of_years, consumer_price_index,
|
||||||
discount_rate, retrofitting_scenario)
|
discount_rate, retrofitting_scenario, heating_scop, cooling_seer,
|
||||||
|
peak_electricity_demand, factor_pv)
|
||||||
total_capital_costs = lcc.calculate_capital_costs()
|
total_capital_costs = lcc.calculate_capital_costs()
|
||||||
print(f'total capital costs scenario {retrofitting_scenario} are {total_capital_costs}')
|
print(f'total capital costs scenario {retrofitting_scenario} are {total_capital_costs}')
|
||||||
end_of_life_costs = lcc.calculate_end_of_life_costs()
|
end_of_life_costs = lcc.calculate_end_of_life_costs()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user