Compare commits

...

16 Commits

17 changed files with 60 additions and 223 deletions

2
.gitignore vendored
View File

@ -1 +1,3 @@
.idea
cerc_costs.egg-info
dist

View File

@ -1,9 +0,0 @@
Metadata-Version: 2.1
Name: cerc-costs
Version: 0.1.0.0
Summary: CERC costs contains the basic cost calculation per CERC-Hub building
Classifier: License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
CERC costs contains the basic cost calculation per CERC-Hub building

View File

@ -1,20 +0,0 @@
pyproject.toml
requirements.txt
setup.py
cerc_costs.egg-info/PKG-INFO
cerc_costs.egg-info/SOURCES.txt
cerc_costs.egg-info/dependency_links.txt
cerc_costs.egg-info/requires.txt
cerc_costs.egg-info/top_level.txt
costs/__init__.py
costs/__main__.py
costs/capital_costs.py
costs/configuration.py
costs/constants.py
costs/cost.py
costs/cost_base.py
costs/end_of_life_costs.py
costs/total_maintenance_costs.py
costs/total_operational_costs.py
costs/total_operational_incomes.py
costs/version.py

View File

@ -1 +0,0 @@

View File

@ -1,4 +0,0 @@
numpy_financial
cerc_hub
pandas
setuptools

View File

@ -1 +0,0 @@
costs

View File

@ -39,9 +39,9 @@ class CapitalCosts(CostBase):
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, '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, '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
@ -81,8 +81,7 @@ class CapitalCosts(CostBase):
capital_cost_other_hvac_ahu = 0
capital_cost_lighting = 0
for internal_zone in self._building.internal_zones:
for thermal_zone in internal_zone.thermal_zones:
for thermal_zone in self._building.thermal_zones_from_internal_zones:
for thermal_boundary in thermal_zone.thermal_boundaries:
if thermal_boundary.type == 'Ground':
surface_ground += thermal_boundary.opaque_area
@ -108,9 +107,9 @@ class CapitalCosts(CostBase):
capital_cost_roof = surface_roof * chapter.item('B3010_opaque_roof').refurbishment[0]
capital_cost_ground = surface_ground * chapter.item('B10_superstructure').refurbishment[0]
self._yearly_capital_costs.loc[0, 'B2010_opaque_walls'] = capital_cost_opaque * own_capital
self._yearly_capital_costs.loc[0]['B2020_transparent'] = capital_cost_transparent * own_capital
self._yearly_capital_costs.loc[0, 'B2020_transparent'] = capital_cost_transparent * own_capital
self._yearly_capital_costs.loc[0, 'B3010_opaque_roof'] = capital_cost_roof * own_capital
self._yearly_capital_costs.loc[0]['B10_superstructure'] = capital_cost_ground * own_capital
self._yearly_capital_costs.loc[0, 'B10_superstructure'] = capital_cost_ground * own_capital
if self._configuration.retrofit_scenario in (SYSTEM_RETROFIT_AND_PV, SKIN_RETROFIT_AND_SYSTEM_RETROFIT_AND_PV):
chapter = self._capital_costs_chapter.chapter('D_services')
@ -120,7 +119,7 @@ class CapitalCosts(CostBase):
capital_cost_distribution_equipment = peak_cooling * chapter.item('D3040_distribution_systems').initial_investment[0]
capital_cost_other_hvac_ahu = peak_cooling * chapter.item('D3080_other_hvac_ahu').initial_investment[0]
capital_cost_lighting = self._total_floor_area * chapter.item('D5020_lighting_and_branch_wiring').initial_investment[0]
self._yearly_capital_costs.loc[0]['D301010_photovoltaic_system'] = capital_cost_pv
self._yearly_capital_costs.loc[0, 'D301010_photovoltaic_system'] = capital_cost_pv
self._yearly_capital_costs.loc[0, 'D3020_heat_generating_systems'] = capital_cost_heating_equipment * own_capital
self._yearly_capital_costs.loc[0, 'D3030_cooling_generation_systems'] = capital_cost_cooling_equipment * own_capital
self._yearly_capital_costs.loc[0, 'D3040_distribution_systems'] = capital_cost_distribution_equipment * own_capital
@ -220,7 +219,7 @@ class CapitalCosts(CostBase):
if self._configuration.retrofit_scenario in (SYSTEM_RETROFIT_AND_PV, SKIN_RETROFIT_AND_SYSTEM_RETROFIT_AND_PV):
if (year % chapter.item('D301010_photovoltaic_system').lifetime) == 0:
self._yearly_capital_costs.loc[year]['D301010_photovoltaic_system'] += (
self._yearly_capital_costs.loc[year, 'D301010_photovoltaic_system'] += (
surface_pv * chapter.item('D301010_photovoltaic_system').reposition[0] * costs_increase
)
capital_cost_skin = capital_cost_opaque + capital_cost_ground + capital_cost_transparent + capital_cost_roof

View File

@ -5,6 +5,8 @@ Copyright © 2023 Project Coder Guille Gutierrez guillermo.gutierrezmorote@conco
Code contributor Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
Code contributor Oriol Gavalda Torrellas oriol.gavalda@concordia.ca
"""
import datetime
import pandas as pd
import numpy_financial as npf
from hub.city_model_structure.building import Building
@ -62,13 +64,6 @@ class Cost:
"""
return self._building
@building.setter
def building(self, value: Building):
"""
Set current building.
"""
self._building = value
def _npv_from_list(self, list_cashflow):
return npf.npv(self._configuration.discount_rate, list_cashflow)
@ -84,7 +79,6 @@ class Cost:
global_operational_costs = TotalOperationalCosts(self._building, self._configuration).calculate()
global_maintenance_costs = TotalMaintenanceCosts(self._building, self._configuration).calculate()
global_operational_incomes = TotalOperationalIncomes(self._building, self._configuration).calculate()
df_capital_costs_skin = (
global_capital_costs['B2010_opaque_walls'] +
global_capital_costs['B2020_transparent'] +
@ -101,8 +95,6 @@ class Cost:
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'] +
@ -160,5 +152,4 @@ class Cost:
'global_maintenance_costs',
'global_operational_incomes'
]
return results

View File

@ -19,8 +19,7 @@ class CostBase:
self._building = building
self._configuration = configuration
self._total_floor_area = 0
for internal_zone in building.internal_zones:
for thermal_zone in internal_zone.thermal_zones:
for thermal_zone in building.thermal_zones_from_internal_zones:
self._total_floor_area += thermal_zone.total_floor_area
self._archetype = None
self._capital_costs_chapter = None

View File

@ -28,38 +28,29 @@ class PeakLoad:
heating = 0
cooling = 0
for system in self._building.energy_systems:
for demand_type in system.demand_types:
if demand_type == cte.HEATING:
if cte.HEATING in system.demand_types:
heating = 1
if demand_type == cte.COOLING:
if cte.COOLING in system.demand_types:
cooling = 1
if cte.MONTH in self._building.heating_peak_load.keys() and cte.MONTH in self._building.cooling_peak_load.keys():
peak_lighting = 0
peak_appliances = 0
for thermal_zone in self._building.internal_zones[0].thermal_zones:
lighting = thermal_zone.lighting
for schedule in lighting.schedules:
peak = max(schedule.values) * lighting.density * thermal_zone.total_floor_area
if peak > peak_lighting:
peak_lighting = peak
appliances = thermal_zone.appliances
for schedule in appliances.schedules:
peak = max(schedule.values) * appliances.density * thermal_zone.total_floor_area
if peak > peak_appliances:
peak_appliances = peak
peak_lighting = self._building.lighting_peak_load[cte.YEAR][0]
peak_appliances = self._building.appliances_peak_load[cte.YEAR][0]
monthly_electricity_peak = [0.9 * peak_lighting + 0.7 * peak_appliances] * 12
conditioning_peak = []
for i, value in enumerate(self._building.heating_peak_load[cte.MONTH]):
if cooling * self._building.cooling_peak_load[cte.MONTH][i] > heating * value:
conditioning_peak.append(cooling * self._building.cooling_peak_load[cte.MONTH][i])
conditioning_peak = max(self._building.heating_peak_load[cte.MONTH], self._building.cooling_peak_load[cte.MONTH])
for i in range(len(conditioning_peak)):
if cooling == 1 and heating == 1:
conditioning_peak[i] = conditioning_peak[i]
continue
elif cooling == 0:
conditioning_peak[i] = self._building.heating_peak_load[cte.MONTH][i] * heating
else:
conditioning_peak.append(heating * value)
conditioning_peak[i] = self._building.cooling_peak_load[cte.MONTH][i] * cooling
monthly_electricity_peak[i] += 0.8 * conditioning_peak[i]
electricity_peak_load_results = pd.DataFrame(
monthly_electricity_peak,
columns=[f'{self._building.name} electricity peak load W']
columns=[f'electricity peak load W']
)
else:
electricity_peak_load_results = pd.DataFrame(array, columns=[f'{self._building.name} electricity peak load W'])
electricity_peak_load_results = pd.DataFrame(array, columns=[f'electricity peak load W'])
return electricity_peak_load_results

View File

@ -20,6 +20,7 @@ class TotalOperationalCosts(CostBase):
"""
End of life costs class
"""
def __init__(self, building: Building, configuration: Configuration):
super().__init__(building, configuration)
self._yearly_operational_costs = pd.DataFrame(
@ -48,19 +49,20 @@ class TotalOperationalCosts(CostBase):
variable_gas_cost_year_0 = 0
electricity_heating = 0
domestic_hot_water_electricity = 0
# todo: each fuel has different units that have to be processed
if self._configuration.fuel_type == 1:
fixed_gas_cost_year_0 = archetype.operational_cost.fuels[1].fixed_monthly * 12 * factor_residential
variable_gas_cost_year_0 = (
(building.heating_consumption[cte.YEAR][0] + building.domestic_hot_water_consumption[cte.YEAR][0]) / 1000 *
archetype.operational_cost.fuels[1].variable[0]
(building.heating_consumption[cte.YEAR][0] + building.domestic_hot_water_consumption[cte.YEAR][0])
/ (1000 * cte.WATTS_HOUR_TO_JULES) * archetype.operational_cost.fuels[1].variable[0]
)
if self._configuration.fuel_type == 0:
electricity_heating = building.heating_consumption[cte.YEAR][0] / 1000
domestic_hot_water_electricity = building.domestic_hot_water_consumption[cte.YEAR][0] / 1000
electricity_cooling = building.cooling_consumption[cte.YEAR][0] / 1000
electricity_lighting = building.lighting_electrical_demand[cte.YEAR]['insel meb'] / 1000
electricity_plug_loads = building.appliances_electrical_demand[cte.YEAR]['insel meb'] / 1000
electricity_lighting = building.lighting_electrical_demand[cte.YEAR][0] / 1000
electricity_plug_loads = building.appliances_electrical_demand[cte.YEAR][0] / 1000
electricity_distribution = 0
total_electricity_consumption = (
electricity_heating + electricity_cooling + electricity_lighting + domestic_hot_water_electricity +
@ -70,8 +72,10 @@ class TotalOperationalCosts(CostBase):
# todo: change when peak electricity demand is coded. Careful with factor residential
peak_electricity_load = PeakLoad(building).electricity_peak_load
peak_load_value = peak_electricity_load.max(axis=1)
peak_electricity_demand = peak_load_value[1]/1000 # self._peak_electricity_demand adapted to kW
variable_electricity_cost_year_0 = total_electricity_consumption * archetype.operational_cost.fuels[0].variable[0]
peak_electricity_demand = peak_load_value[1] / 1000 # self._peak_electricity_demand adapted to kW
variable_electricity_cost_year_0 = (
total_electricity_consumption / cte.WATTS_HOUR_TO_JULES * 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
@ -85,8 +89,12 @@ class TotalOperationalCosts(CostBase):
self._yearly_operational_costs.at[year, 'Fixed_costs_electricity_monthly'] = (
monthly_electricity_cost_year_0 * price_increase_peak_electricity
)
if not isinstance(variable_electricity_cost_year_0, pd.DataFrame):
variable_costs_electricity = variable_electricity_cost_year_0 * price_increase_electricity
else:
variable_costs_electricity = float(variable_electricity_cost_year_0.iloc[0] * price_increase_electricity)
self._yearly_operational_costs.at[year, 'Variable_costs_electricity'] = (
float(variable_electricity_cost_year_0.iloc[0] * price_increase_electricity)
variable_costs_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'] = (

View File

@ -28,15 +28,16 @@ class TotalOperationalIncomes(CostBase):
:return: pd.DataFrame
"""
building = self._building
archetype = self._archetype
if cte.YEAR not in building.onsite_electrical_production:
onsite_electricity_production = 0
else:
onsite_electricity_production = building.onsite_electrical_production[cte.YEAR][0] / 1000
onsite_electricity_production = building.onsite_electrical_production[cte.YEAR][0]
for year in range(1, self._configuration.number_of_years + 1):
price_increase_electricity = math.pow(1 + self._configuration.electricity_price_index, year)
# todo: check the adequate assignation of price. Pilar
price_export = 0.075 # archetype.income.electricity_export
price_export = archetype.income.electricity_export * cte.WATTS_HOUR_TO_JULES * 1000 # to account for unit change
self._yearly_operational_incomes.loc[year, 'Incomes electricity'] = (
onsite_electricity_production * price_export * price_increase_electricity
)

View File

@ -5,4 +5,4 @@ Copyright © 2023 Project Coder Guille Gutierrez guillermo.gutierrezmorote@conco
Code contributor Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
Code contributor Oriol Gavalda Torrellas oriol.gavalda@concordia.ca
"""
__version__ = '0.1.0.2'
__version__ = '0.1.0.6'

Binary file not shown.

Binary file not shown.

View File

@ -1,121 +0,0 @@
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"id": 2864,
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-73.55628837310991,
45.60732526295055
],
[
-73.55628287285629,
45.607324262904456
],
[
-73.55609247288925,
45.607288563416546
],
[
-73.55607107262188,
45.60734486277528
],
[
-73.55612487276466,
45.60735496306114
],
[
-73.55609867281544,
45.60742366317157
],
[
-73.55624087271804,
45.60745026331904
],
[
-73.55628837310991,
45.60732526295055
]
]
]
},
"properties": {
"OBJECTID_12_13": 2864,
"ID_UEV": "02033771",
"CIVIQUE_DE": " 8212",
"CIVIQUE_FI": " 8212",
"NOM_RUE": "avenue Peterborough (ANJ)",
"SUITE_DEBU": " ",
"MUNICIPALI": "50",
"ETAGE_HORS": 1,
"NOMBRE_LOG": 1,
"ANNEE_CONS": 1960,
"CODE_UTILI": "1000",
"LETTRE_DEB": " ",
"LETTRE_FIN": " ",
"LIBELLE_UT": "Logement",
"CATEGORIE_": "R\u00c3\u00a9gulier",
"MATRICULE8": "0051-49-2041-2-000-0000",
"SUPERFICIE": 450,
"SUPERFIC_1": 176,
"NO_ARROND_": "REM09",
"Shape_Leng": 0.000666191644361,
"OBJECTID": 2864,
"Join_Count": 1,
"TARGET_FID": 2864,
"feature_id": "bdd1f0fe-89de-46d2-80dc-87d3636df60a",
"md_id": " ",
"acqtech": 1360,
"acqtech_en": "Lidar",
"acqtech_fr": "Lidar",
"provider": 461,
"provideren": "Municipal",
"providerfr": "Municipal",
"datemin": "20151124",
"datemax": "20151208",
"haccmin": 2,
"haccmax": 2,
"vaccmin": 1,
"vaccmax": 1,
"heightmin": 1.17,
"heightmax": 7.5,
"elevmin": 45.48,
"elevmax": 45.96,
"bldgarea": 193.18,
"comment": " ",
"OBJECTID_1": 2864,
"Shape_Le_1": 0.000666191644361,
"Shape_Ar_1": 2.22753099997e-08,
"OBJECTID_12": 2864,
"Join_Count_1": 1,
"TARGET_FID_1": 2863,
"g_objectid": "897744",
"g_co_mrc": "66023",
"g_code_mun": "66023",
"g_arrond": "REM09",
"g_anrole": "2019",
"g_usag_pre": "R\u00c3\u00a9sidentiel",
"g_no_lot": "1113400",
"g_nb_poly_": "1",
"g_utilisat": "1000",
"g_nb_logem": "1",
"g_nb_locau": " ",
"g_descript": "Unit\u00c3\u00a9 d'\u00c3\u00a9valuation",
"g_id_provi": "66023005149204120000000",
"g_sup_tota": "450.1",
"g_geometry": "0.000958907",
"g_geomet_1": "5.20226e-008",
"g_dat_acqu": "2020-02-12 00:00:00.0000000",
"g_dat_char": "2020-02-17 00:00:00.0000000",
"Shape_Leng_1": 0.000666191644361,
"Shape_Area_1": 2.22753099997e-08,
"Shape_Length": 0.0006661919640545334,
"Shape_Area": 2.22753099997e-08
}
}
]
}

View File

@ -42,14 +42,16 @@ class Initialize:
sra_file = str((output_path / f'{city.name}_sra.xml').resolve())
subprocess.run(['sra', sra_file], stdout=subprocess.DEVNULL)
ResultFactory('sra', city, output_path).enrich()
print(f'sra completed {datetime.datetime.now() - start}')
for building in city.buildings:
building.energy_systems_archetype_name = 'system 1 gas pv'
EnergySystemsFactory('montreal_custom', city).enrich()
print(f'energy systems completed {datetime.datetime.now() - start}')
EnergyBuildingsExportsFactory('insel_monthly_energy_balance', city, output_path).export()
_insel_files = glob.glob(f'{output_path}/*.insel')
for insel_file in _insel_files:
subprocess.run(['insel', str(insel_file)], stdout=subprocess.DEVNULL)
print(f'insel completed {datetime.datetime.now() - start}')
ResultFactory('insel_monthly_energy_balance', city, output_path).enrich()
self._city = city
print(f'init completed {datetime.datetime.now() - start}')