merge branch
This commit is contained in:
parent
1b80543bb1
commit
f749145796
3
.idea/.gitignore
vendored
Normal file
3
.idea/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
12
.idea/costs.iml
Normal file
12
.idea/costs.iml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="PYTHON_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<content url="file://$MODULE_DIR$" />
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
<component name="PyDocumentationSettings">
|
||||||
|
<option name="format" value="PLAIN" />
|
||||||
|
<option name="myDocStringFormat" value="Plain" />
|
||||||
|
</component>
|
||||||
|
</module>
|
42
.idea/inspectionProfiles/Project_Default.xml
Normal file
42
.idea/inspectionProfiles/Project_Default.xml
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<profile version="1.0">
|
||||||
|
<option name="myName" value="Project Default" />
|
||||||
|
<inspection_tool class="PyPackageRequirementsInspection" enabled="true" level="WARNING" enabled_by_default="true">
|
||||||
|
<option name="ignoredPackages">
|
||||||
|
<value>
|
||||||
|
<list size="5">
|
||||||
|
<item index="0" class="java.lang.String" itemvalue="hub" />
|
||||||
|
<item index="1" class="java.lang.String" itemvalue="flasgger" />
|
||||||
|
<item index="2" class="java.lang.String" itemvalue="ray" />
|
||||||
|
<item index="3" class="java.lang.String" itemvalue="flask" />
|
||||||
|
<item index="4" class="java.lang.String" itemvalue="flask_restful" />
|
||||||
|
</list>
|
||||||
|
</value>
|
||||||
|
</option>
|
||||||
|
</inspection_tool>
|
||||||
|
<inspection_tool class="PyPep8Inspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
|
||||||
|
<option name="ignoredErrors">
|
||||||
|
<list>
|
||||||
|
<option value="E111" />
|
||||||
|
<option value="E114" />
|
||||||
|
<option value="W605" />
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
</inspection_tool>
|
||||||
|
<inspection_tool class="PyPep8NamingInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
|
||||||
|
<option name="ignoredErrors">
|
||||||
|
<list>
|
||||||
|
<option value="N813" />
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
</inspection_tool>
|
||||||
|
<inspection_tool class="PyTypeCheckerInspection" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="PyUnresolvedReferencesInspection" enabled="true" level="WARNING" enabled_by_default="true">
|
||||||
|
<option name="ignoredIdentifiers">
|
||||||
|
<list>
|
||||||
|
<option value="list.iloc" />
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
</inspection_tool>
|
||||||
|
</profile>
|
||||||
|
</component>
|
6
.idea/inspectionProfiles/profiles_settings.xml
Normal file
6
.idea/inspectionProfiles/profiles_settings.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<settings>
|
||||||
|
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||||
|
<version value="1.0" />
|
||||||
|
</settings>
|
||||||
|
</component>
|
4
.idea/misc.xml
Normal file
4
.idea/misc.xml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectRootManager" version="2" project-jdk-name="costs_workflow" project-jdk-type="Python SDK" />
|
||||||
|
</project>
|
8
.idea/modules.xml
Normal file
8
.idea/modules.xml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/costs.iml" filepath="$PROJECT_DIR$/.idea/costs.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
9
cerc_costs.egg-info/PKG-INFO
Normal file
9
cerc_costs.egg-info/PKG-INFO
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
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
|
20
cerc_costs.egg-info/SOURCES.txt
Normal file
20
cerc_costs.egg-info/SOURCES.txt
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
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
|
1
cerc_costs.egg-info/dependency_links.txt
Normal file
1
cerc_costs.egg-info/dependency_links.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
|
4
cerc_costs.egg-info/requires.txt
Normal file
4
cerc_costs.egg-info/requires.txt
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
numpy_financial
|
||||||
|
cerc_hub
|
||||||
|
pandas
|
||||||
|
setuptools
|
1
cerc_costs.egg-info/top_level.txt
Normal file
1
cerc_costs.egg-info/top_level.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
costs
|
4
costs/README.md
Normal file
4
costs/README.md
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
# Cerc costs
|
||||||
|
|
||||||
|
Uses the cerc-hub as a base for cost calculation, it's intended to be used after executing the complete monthly energy
|
||||||
|
balance workflow called building by building
|
6
costs/__main__.py
Normal file
6
costs/__main__.py
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
"""
|
||||||
|
Costs Workflow
|
||||||
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
||||||
|
Copyright © 2022 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
|
||||||
|
Code contributor Oriol Gavalda Torrellas oriol.gavalda@concordia.ca
|
||||||
|
"""
|
BIN
costs/__pycache__/__init__.cpython-39.pyc
Normal file
BIN
costs/__pycache__/__init__.cpython-39.pyc
Normal file
Binary file not shown.
BIN
costs/__pycache__/capital_costs.cpython-39.pyc
Normal file
BIN
costs/__pycache__/capital_costs.cpython-39.pyc
Normal file
Binary file not shown.
BIN
costs/__pycache__/configuration.cpython-39.pyc
Normal file
BIN
costs/__pycache__/configuration.cpython-39.pyc
Normal file
Binary file not shown.
BIN
costs/__pycache__/constants.cpython-39.pyc
Normal file
BIN
costs/__pycache__/constants.cpython-39.pyc
Normal file
Binary file not shown.
BIN
costs/__pycache__/cost.cpython-39.pyc
Normal file
BIN
costs/__pycache__/cost.cpython-39.pyc
Normal file
Binary file not shown.
BIN
costs/__pycache__/cost_base.cpython-39.pyc
Normal file
BIN
costs/__pycache__/cost_base.cpython-39.pyc
Normal file
Binary file not shown.
BIN
costs/__pycache__/end_of_life_costs.cpython-39.pyc
Normal file
BIN
costs/__pycache__/end_of_life_costs.cpython-39.pyc
Normal file
Binary file not shown.
BIN
costs/__pycache__/total_maintenance_costs.cpython-39.pyc
Normal file
BIN
costs/__pycache__/total_maintenance_costs.cpython-39.pyc
Normal file
Binary file not shown.
BIN
costs/__pycache__/total_operational_costs.cpython-39.pyc
Normal file
BIN
costs/__pycache__/total_operational_costs.cpython-39.pyc
Normal file
Binary file not shown.
BIN
costs/__pycache__/total_operational_incomes.cpython-39.pyc
Normal file
BIN
costs/__pycache__/total_operational_incomes.cpython-39.pyc
Normal file
Binary file not shown.
236
costs/capital_costs.py
Normal file
236
costs/capital_costs.py
Normal file
@ -0,0 +1,236 @@
|
|||||||
|
"""
|
||||||
|
Capital costs module
|
||||||
|
"""
|
||||||
|
import math
|
||||||
|
|
||||||
|
import pandas as pd
|
||||||
|
import numpy_financial as npf
|
||||||
|
from hub.city_model_structure.building import Building
|
||||||
|
import hub.helpers.constants as cte
|
||||||
|
from costs.configuration import Configuration
|
||||||
|
from costs.constants import SKIN_RETROFIT, SKIN_RETROFIT_AND_SYSTEM_RETROFIT_AND_PV, SYSTEM_RETROFIT_AND_PV
|
||||||
|
from costs.cost_base import CostBase
|
||||||
|
|
||||||
|
|
||||||
|
class CapitalCosts(CostBase):
|
||||||
|
"""
|
||||||
|
Capital costs class
|
||||||
|
"""
|
||||||
|
def __init__(self, building: Building, configuration: Configuration):
|
||||||
|
super().__init__(building, configuration)
|
||||||
|
self._yearly_capital_costs = pd.DataFrame(
|
||||||
|
index=self._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=self._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
|
||||||
|
|
||||||
|
def calculate(self) -> tuple[pd.DataFrame, pd.DataFrame]:
|
||||||
|
"""
|
||||||
|
Calculate capital cost
|
||||||
|
:return: pd.DataFrame, pd.DataFrame
|
||||||
|
"""
|
||||||
|
surface_opaque = 0
|
||||||
|
surface_transparent = 0
|
||||||
|
surface_roof = 0
|
||||||
|
surface_ground = 0
|
||||||
|
capital_cost_pv = 0
|
||||||
|
capital_cost_opaque = 0
|
||||||
|
capital_cost_ground = 0
|
||||||
|
capital_cost_transparent = 0
|
||||||
|
capital_cost_roof = 0
|
||||||
|
capital_cost_heating_equipment = 0
|
||||||
|
capital_cost_cooling_equipment = 0
|
||||||
|
capital_cost_distribution_equipment = 0
|
||||||
|
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_boundary in thermal_zone.thermal_boundaries:
|
||||||
|
if thermal_boundary.type == 'Ground':
|
||||||
|
surface_ground += thermal_boundary.opaque_area
|
||||||
|
elif thermal_boundary.type == 'Roof':
|
||||||
|
surface_roof += thermal_boundary.opaque_area
|
||||||
|
elif thermal_boundary.type == 'Wall':
|
||||||
|
surface_opaque += thermal_boundary.opaque_area * (1 - thermal_boundary.window_ratio)
|
||||||
|
surface_transparent += thermal_boundary.opaque_area * thermal_boundary.window_ratio
|
||||||
|
|
||||||
|
peak_heating = self._building.heating_peak_load[cte.YEAR][0] / 1000
|
||||||
|
peak_cooling = self._building.cooling_peak_load[cte.YEAR][0] / 1000
|
||||||
|
|
||||||
|
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)
|
||||||
|
own_capital = 1 - self._configuration.percentage_credit
|
||||||
|
if self._configuration.retrofit_scenario in (SKIN_RETROFIT, SKIN_RETROFIT_AND_SYSTEM_RETROFIT_AND_PV):
|
||||||
|
chapter = self._capital_costs_chapter.chapter('B_shell')
|
||||||
|
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_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, 'B3010_opaque_roof'] = capital_cost_roof * 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')
|
||||||
|
capital_cost_pv = surface_pv * chapter.item('D301010_photovoltaic_system').initial_investment[0]
|
||||||
|
capital_cost_heating_equipment = peak_heating * chapter.item('D3020_heat_generating_systems').initial_investment[0]
|
||||||
|
capital_cost_cooling_equipment = peak_cooling * chapter.item('D3030_cooling_generation_systems').initial_investment[0]
|
||||||
|
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, '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
|
||||||
|
self._yearly_capital_costs.loc[0, 'D3080_other_hvac_ahu'] = capital_cost_other_hvac_ahu * own_capital
|
||||||
|
self._yearly_capital_costs.loc[0, 'D5020_lighting_and_branch_wiring'] = capital_cost_lighting * own_capital
|
||||||
|
|
||||||
|
for year in range(1, self._configuration.number_of_years):
|
||||||
|
chapter = self._capital_costs_chapter.chapter('D_services')
|
||||||
|
costs_increase = math.pow(1 + self._configuration.consumer_price_index, year)
|
||||||
|
self._yearly_capital_costs.loc[year, 'B2010_opaque_walls'] = (
|
||||||
|
-npf.pmt(
|
||||||
|
self._configuration.interest_rate,
|
||||||
|
self._configuration.credit_years,
|
||||||
|
capital_cost_opaque * self._configuration.percentage_credit
|
||||||
|
)
|
||||||
|
)
|
||||||
|
self._yearly_capital_costs.loc[year, 'B2020_transparent'] = (
|
||||||
|
-npf.pmt(
|
||||||
|
self._configuration.interest_rate,
|
||||||
|
self._configuration.credit_years,
|
||||||
|
capital_cost_transparent * self._configuration.percentage_credit
|
||||||
|
)
|
||||||
|
)
|
||||||
|
self._yearly_capital_costs.loc[year, 'B3010_opaque_roof'] = (
|
||||||
|
-npf.pmt(
|
||||||
|
self._configuration.interest_rate,
|
||||||
|
self._configuration.credit_years,
|
||||||
|
capital_cost_roof * self._configuration.percentage_credit
|
||||||
|
)
|
||||||
|
)
|
||||||
|
self._yearly_capital_costs.loc[year, 'B10_superstructure'] = (
|
||||||
|
-npf.pmt(
|
||||||
|
self._configuration.interest_rate,
|
||||||
|
self._configuration.credit_years,
|
||||||
|
capital_cost_ground * self._configuration.percentage_credit
|
||||||
|
)
|
||||||
|
)
|
||||||
|
self._yearly_capital_costs.loc[year, 'D3020_heat_generating_systems'] = (
|
||||||
|
-npf.pmt(
|
||||||
|
self._configuration.interest_rate,
|
||||||
|
self._configuration.credit_years,
|
||||||
|
capital_cost_heating_equipment * self._configuration.percentage_credit
|
||||||
|
)
|
||||||
|
)
|
||||||
|
self._yearly_capital_costs.loc[year, 'D3030_cooling_generation_systems'] = (
|
||||||
|
-npf.pmt(
|
||||||
|
self._configuration.interest_rate,
|
||||||
|
self._configuration.credit_years,
|
||||||
|
capital_cost_cooling_equipment * self._configuration.percentage_credit
|
||||||
|
)
|
||||||
|
)
|
||||||
|
self._yearly_capital_costs.loc[year, 'D3040_distribution_systems'] = (
|
||||||
|
-npf.pmt(
|
||||||
|
self._configuration.interest_rate,
|
||||||
|
self._configuration.credit_years,
|
||||||
|
capital_cost_distribution_equipment * self._configuration.percentage_credit
|
||||||
|
)
|
||||||
|
)
|
||||||
|
self._yearly_capital_costs.loc[year, 'D3080_other_hvac_ahu'] = (
|
||||||
|
-npf.pmt(
|
||||||
|
self._configuration.interest_rate,
|
||||||
|
self._configuration.credit_years,
|
||||||
|
capital_cost_other_hvac_ahu * self._configuration.percentage_credit
|
||||||
|
)
|
||||||
|
)
|
||||||
|
self._yearly_capital_costs.loc[year, 'D5020_lighting_and_branch_wiring'] = (
|
||||||
|
-npf.pmt(
|
||||||
|
self._configuration.interest_rate,
|
||||||
|
self._configuration.credit_years,
|
||||||
|
capital_cost_lighting * self._configuration.percentage_credit
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
if (year % chapter.item('D3020_heat_generating_systems').lifetime) == 0:
|
||||||
|
reposition_cost_heating_equipment = (
|
||||||
|
peak_heating * chapter.item('D3020_heat_generating_systems').reposition[0] * costs_increase
|
||||||
|
)
|
||||||
|
self._yearly_capital_costs.loc[year, 'D3020_heat_generating_systems'] += reposition_cost_heating_equipment
|
||||||
|
|
||||||
|
if (year % chapter.item('D3030_cooling_generation_systems').lifetime) == 0:
|
||||||
|
reposition_cost_cooling_equipment = (
|
||||||
|
peak_cooling * chapter.item('D3030_cooling_generation_systems').reposition[0] * costs_increase
|
||||||
|
)
|
||||||
|
self._yearly_capital_costs.loc[year, 'D3030_cooling_generation_systems'] += reposition_cost_cooling_equipment
|
||||||
|
|
||||||
|
if (year % chapter.item('D3080_other_hvac_ahu').lifetime) == 0:
|
||||||
|
reposition_cost_hvac_ahu = (
|
||||||
|
peak_cooling * chapter.item('D3080_other_hvac_ahu').reposition[0] * costs_increase
|
||||||
|
)
|
||||||
|
self._yearly_capital_costs.loc[year, 'D3080_other_hvac_ahu'] = reposition_cost_hvac_ahu
|
||||||
|
|
||||||
|
if (year % chapter.item('D5020_lighting_and_branch_wiring').lifetime) == 0:
|
||||||
|
reposition_cost_lighting = (
|
||||||
|
self._total_floor_area * chapter.item('D5020_lighting_and_branch_wiring').reposition[0] * costs_increase
|
||||||
|
)
|
||||||
|
self._yearly_capital_costs.loc[year, 'D5020_lighting_and_branch_wiring'] += reposition_cost_lighting
|
||||||
|
|
||||||
|
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'] += (
|
||||||
|
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
|
||||||
|
capital_cost_hvac = (
|
||||||
|
capital_cost_heating_equipment +
|
||||||
|
capital_cost_cooling_equipment +
|
||||||
|
capital_cost_distribution_equipment +
|
||||||
|
capital_cost_other_hvac_ahu + capital_cost_lighting
|
||||||
|
)
|
||||||
|
|
||||||
|
self._yearly_capital_incomes.loc[0, 'Subsidies construction'] = (
|
||||||
|
capital_cost_skin * self._archetype.income.construction_subsidy/100
|
||||||
|
)
|
||||||
|
self._yearly_capital_incomes.loc[0, 'Subsidies HVAC'] = capital_cost_hvac * self._archetype.income.hvac_subsidy/100
|
||||||
|
self._yearly_capital_incomes.loc[0, 'Subsidies PV'] = capital_cost_pv * self._archetype.income.photovoltaic_subsidy/100
|
||||||
|
self._yearly_capital_incomes.fillna(0, inplace=True)
|
||||||
|
return self._yearly_capital_costs, self._yearly_capital_incomes
|
11
costs/constants.py
Normal file
11
costs/constants.py
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# constants
|
||||||
|
CURRENT_STATUS = 0
|
||||||
|
SKIN_RETROFIT = 1
|
||||||
|
SYSTEM_RETROFIT_AND_PV = 2
|
||||||
|
SKIN_RETROFIT_AND_SYSTEM_RETROFIT_AND_PV = 3
|
||||||
|
RETROFITTING_SCENARIOS = [
|
||||||
|
CURRENT_STATUS,
|
||||||
|
SKIN_RETROFIT,
|
||||||
|
SYSTEM_RETROFIT_AND_PV,
|
||||||
|
SKIN_RETROFIT_AND_SYSTEM_RETROFIT_AND_PV
|
||||||
|
]
|
38
costs/cost_base.py
Normal file
38
costs/cost_base.py
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
"""
|
||||||
|
Cost base module
|
||||||
|
"""
|
||||||
|
|
||||||
|
from hub.city_model_structure.building import Building
|
||||||
|
from hub.helpers.dictionaries import Dictionaries
|
||||||
|
|
||||||
|
from costs.configuration import Configuration
|
||||||
|
|
||||||
|
|
||||||
|
class CostBase:
|
||||||
|
"""
|
||||||
|
Abstract base class for the costs
|
||||||
|
"""
|
||||||
|
def __init__(self, building: Building, configuration: Configuration):
|
||||||
|
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:
|
||||||
|
self._total_floor_area += thermal_zone.total_floor_area
|
||||||
|
self._archetype = None
|
||||||
|
self._capital_costs_chapter = None
|
||||||
|
for archetype in self._configuration.costs_catalog.entries().archetypes:
|
||||||
|
if configuration.dictionary[str(building.function)] == str(archetype.function):
|
||||||
|
self._archetype = archetype
|
||||||
|
self._capital_costs_chapter = self._archetype.capital_cost
|
||||||
|
break
|
||||||
|
if not self._archetype:
|
||||||
|
raise KeyError(f'archetype not found for function {building.function}')
|
||||||
|
|
||||||
|
self._rng = range(configuration.number_of_years)
|
||||||
|
|
||||||
|
def calculate(self):
|
||||||
|
"""
|
||||||
|
Raises not implemented exception
|
||||||
|
"""
|
||||||
|
raise NotImplementedError()
|
34
costs/end_of_life_costs.py
Normal file
34
costs/end_of_life_costs.py
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
"""
|
||||||
|
End of life costs module
|
||||||
|
"""
|
||||||
|
import math
|
||||||
|
import pandas as pd
|
||||||
|
from hub.city_model_structure.building import Building
|
||||||
|
|
||||||
|
from costs.configuration import Configuration
|
||||||
|
from costs.cost_base import CostBase
|
||||||
|
|
||||||
|
|
||||||
|
class EndOfLifeCosts(CostBase):
|
||||||
|
"""
|
||||||
|
End of life costs class
|
||||||
|
"""
|
||||||
|
def __init__(self, building: Building, configuration: Configuration):
|
||||||
|
super().__init__(building, configuration)
|
||||||
|
self._yearly_end_of_life_costs = pd.DataFrame(index=self._rng, columns=['End_of_life_costs'], dtype='float')
|
||||||
|
|
||||||
|
def calculate(self):
|
||||||
|
"""
|
||||||
|
Calculate end of life costs
|
||||||
|
:return: pd.DataFrame
|
||||||
|
"""
|
||||||
|
archetype = self._archetype
|
||||||
|
total_floor_area = self._total_floor_area
|
||||||
|
for year in range(1, self._configuration.number_of_years + 1):
|
||||||
|
price_increase = math.pow(1 + self._configuration.consumer_price_index, year)
|
||||||
|
if year == self._configuration.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.fillna(0, inplace=True)
|
||||||
|
return self._yearly_end_of_life_costs
|
61
costs/total_maintenance_costs.py
Normal file
61
costs/total_maintenance_costs.py
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
"""
|
||||||
|
Total maintenance costs module
|
||||||
|
"""
|
||||||
|
import math
|
||||||
|
import pandas as pd
|
||||||
|
from hub.city_model_structure.building import Building
|
||||||
|
import hub.helpers.constants as cte
|
||||||
|
|
||||||
|
from costs.configuration import Configuration
|
||||||
|
from costs.cost_base import CostBase
|
||||||
|
|
||||||
|
|
||||||
|
class TotalMaintenanceCosts(CostBase):
|
||||||
|
"""
|
||||||
|
Total maintenance costs class
|
||||||
|
"""
|
||||||
|
def __init__(self, building: Building, configuration: Configuration):
|
||||||
|
super().__init__(building, configuration)
|
||||||
|
self._yearly_maintenance_costs = pd.DataFrame(
|
||||||
|
index=self._rng,
|
||||||
|
columns=[
|
||||||
|
'Heating_maintenance',
|
||||||
|
'Cooling_maintenance',
|
||||||
|
'PV_maintenance'
|
||||||
|
],
|
||||||
|
dtype='float'
|
||||||
|
)
|
||||||
|
|
||||||
|
def calculate(self) -> pd.DataFrame:
|
||||||
|
"""
|
||||||
|
Calculate total maintenance costs
|
||||||
|
:return: pd.DataFrame
|
||||||
|
"""
|
||||||
|
building = self._building
|
||||||
|
archetype = self._archetype
|
||||||
|
# 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
|
||||||
|
|
||||||
|
peak_heating = building.heating_peak_load[cte.YEAR][0]
|
||||||
|
peak_cooling = building.cooling_peak_load[cte.YEAR][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
|
||||||
|
|
||||||
|
for year in range(1, self._configuration.number_of_years + 1):
|
||||||
|
costs_increase = math.pow(1 + self._configuration.consumer_price_index, year)
|
||||||
|
self._yearly_maintenance_costs.loc[year, 'Heating_maintenance'] = (
|
||||||
|
maintenance_heating_0 * costs_increase
|
||||||
|
)
|
||||||
|
self._yearly_maintenance_costs.loc[year, 'Cooling_maintenance'] = (
|
||||||
|
maintenance_cooling_0 * costs_increase
|
||||||
|
)
|
||||||
|
self._yearly_maintenance_costs.loc[year, 'PV_maintenance'] = (
|
||||||
|
maintenance_pv_0 * costs_increase
|
||||||
|
)
|
||||||
|
self._yearly_maintenance_costs.fillna(0, inplace=True)
|
||||||
|
return self._yearly_maintenance_costs
|
92
costs/total_operational_costs.py
Normal file
92
costs/total_operational_costs.py
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
"""
|
||||||
|
Total operational costs module
|
||||||
|
"""
|
||||||
|
import math
|
||||||
|
import pandas as pd
|
||||||
|
|
||||||
|
from hub.city_model_structure.building import Building
|
||||||
|
import hub.helpers.constants as cte
|
||||||
|
|
||||||
|
from costs.configuration import Configuration
|
||||||
|
from costs.cost_base import CostBase
|
||||||
|
|
||||||
|
|
||||||
|
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(
|
||||||
|
index=self._rng,
|
||||||
|
columns=[
|
||||||
|
'Fixed_costs_electricity_peak',
|
||||||
|
'Fixed_costs_electricity_monthly',
|
||||||
|
'Variable_costs_electricity',
|
||||||
|
'Fixed_costs_gas',
|
||||||
|
'Variable_costs_gas'
|
||||||
|
],
|
||||||
|
dtype='float'
|
||||||
|
)
|
||||||
|
|
||||||
|
def calculate(self) -> pd.DataFrame:
|
||||||
|
"""
|
||||||
|
Calculate total operational costs
|
||||||
|
:return: pd.DataFrame
|
||||||
|
"""
|
||||||
|
building = self._building
|
||||||
|
archetype = self._archetype
|
||||||
|
total_floor_area = self._total_floor_area
|
||||||
|
factor_residential = total_floor_area / 80
|
||||||
|
# todo: split the heating between fuels
|
||||||
|
fixed_gas_cost_year_0 = 0
|
||||||
|
variable_gas_cost_year_0 = 0
|
||||||
|
electricity_heating = 0
|
||||||
|
domestic_hot_water_electricity = 0
|
||||||
|
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]
|
||||||
|
)
|
||||||
|
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_distribution = 0
|
||||||
|
total_electricity_consumption = (
|
||||||
|
electricity_heating + electricity_cooling + electricity_lighting + domestic_hot_water_electricity +
|
||||||
|
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
|
||||||
|
variable_electricity_cost_year_0 = total_electricity_consumption * 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
|
||||||
|
|
||||||
|
for year in range(1, self._configuration.number_of_years + 1):
|
||||||
|
price_increase_electricity = math.pow(1 + self._configuration.electricity_price_index, year)
|
||||||
|
price_increase_peak_electricity = math.pow(1 + self._configuration.electricity_peak_index, year)
|
||||||
|
price_increase_gas = math.pow(1 + self._configuration.gas_price_index, year)
|
||||||
|
self._yearly_operational_costs.at[year, 'Fixed_costs_electricity_peak'] = (
|
||||||
|
peak_electricity_cost_year_0 * price_increase_peak_electricity
|
||||||
|
)
|
||||||
|
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'] = (
|
||||||
|
float(variable_electricity_cost_year_0.iloc[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 * price_increase_peak_electricity
|
||||||
|
)
|
||||||
|
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
|
41
costs/total_operational_incomes.py
Normal file
41
costs/total_operational_incomes.py
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
"""
|
||||||
|
Total operational incomes module
|
||||||
|
"""
|
||||||
|
import math
|
||||||
|
import pandas as pd
|
||||||
|
from hub.city_model_structure.building import Building
|
||||||
|
import hub.helpers.constants as cte
|
||||||
|
|
||||||
|
from costs.configuration import Configuration
|
||||||
|
from costs.cost_base import CostBase
|
||||||
|
|
||||||
|
|
||||||
|
class TotalOperationalIncomes(CostBase):
|
||||||
|
"""
|
||||||
|
Total operational incomes class
|
||||||
|
"""
|
||||||
|
def __init__(self, building: Building, configuration: Configuration):
|
||||||
|
super().__init__(building, configuration)
|
||||||
|
self._yearly_operational_incomes = pd.DataFrame(index=self._rng, columns=['Incomes electricity'], dtype='float')
|
||||||
|
|
||||||
|
def calculate(self) -> pd.DataFrame:
|
||||||
|
"""
|
||||||
|
Calculate total operational incomes
|
||||||
|
:return: pd.DataFrame
|
||||||
|
"""
|
||||||
|
building = self._building
|
||||||
|
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
|
||||||
|
|
||||||
|
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
|
||||||
|
self._yearly_operational_incomes.loc[year, 'Incomes electricity'] = (
|
||||||
|
onsite_electricity_production * price_export * price_increase_electricity
|
||||||
|
)
|
||||||
|
|
||||||
|
self._yearly_operational_incomes.fillna(0, inplace=True)
|
||||||
|
return self._yearly_operational_incomes
|
4
costs/version.py
Normal file
4
costs/version.py
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
"""
|
||||||
|
Cost version number
|
||||||
|
"""
|
||||||
|
__version__ = '0.1.0.0'
|
BIN
dist/cerc-costs-0.1.0.0.tar.gz
vendored
Normal file
BIN
dist/cerc-costs-0.1.0.0.tar.gz
vendored
Normal file
Binary file not shown.
BIN
dist/cerc_costs-0.1.0.0-py3-none-any.whl
vendored
Normal file
BIN
dist/cerc_costs-0.1.0.0-py3-none-any.whl
vendored
Normal file
Binary file not shown.
121
input_files/selected_building_2864.geojson
Normal file
121
input_files/selected_building_2864.geojson
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
{
|
||||||
|
"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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
8
pyproject.toml
Normal file
8
pyproject.toml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# pyproject.toml
|
||||||
|
|
||||||
|
[build-system]
|
||||||
|
requires = ["setuptools>=61.0.0", "wheel"]
|
||||||
|
build-backend = "setuptools.build_meta"
|
||||||
|
|
||||||
|
[options.packages.find_namespace]
|
||||||
|
where = "costs"
|
3
requirements.txt
Normal file
3
requirements.txt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
numpy_financial
|
||||||
|
cerc_hub
|
||||||
|
pandas
|
36
setup.py
Normal file
36
setup.py
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
import glob
|
||||||
|
import pathlib
|
||||||
|
from distutils.util import convert_path
|
||||||
|
from setuptools import setup
|
||||||
|
|
||||||
|
with pathlib.Path('requirements.txt').open() as r:
|
||||||
|
install_requires = [
|
||||||
|
str(requirement).replace('\n', '')
|
||||||
|
for requirement
|
||||||
|
in r.readlines()
|
||||||
|
]
|
||||||
|
install_requires.append('setuptools')
|
||||||
|
|
||||||
|
main_ns = {}
|
||||||
|
version = convert_path('costs/version.py')
|
||||||
|
with open(version) as f:
|
||||||
|
exec(f.read(), main_ns)
|
||||||
|
|
||||||
|
setup(
|
||||||
|
name='cerc-costs',
|
||||||
|
version=main_ns['__version__'],
|
||||||
|
description="CERC costs contains the basic cost calculation per CERC-Hub building",
|
||||||
|
long_description="CERC costs contains the basic cost calculation per CERC-Hub building",
|
||||||
|
classifiers=[
|
||||||
|
"License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)",
|
||||||
|
"Programming Language :: Python",
|
||||||
|
"Programming Language :: Python :: 3",
|
||||||
|
],
|
||||||
|
include_package_data=True,
|
||||||
|
packages=['costs'],
|
||||||
|
setup_requires=install_requires,
|
||||||
|
install_requires=install_requires,
|
||||||
|
data_files=[
|
||||||
|
('costs', glob.glob('requirements.txt'))
|
||||||
|
]
|
||||||
|
)
|
BIN
tests/__pycache__/unit_tests.cpython-39.pyc
Normal file
BIN
tests/__pycache__/unit_tests.cpython-39.pyc
Normal file
Binary file not shown.
1
tests/data/test.geojson
Normal file
1
tests/data/test.geojson
Normal file
File diff suppressed because one or more lines are too long
2
tests/output/.gitignore
vendored
Normal file
2
tests/output/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
*
|
||||||
|
!.gitignore
|
73
tests/unit_tests.py
Normal file
73
tests/unit_tests.py
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
import glob
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
from hub.exports.energy_building_exports_factory import EnergyBuildingsExportsFactory
|
||||||
|
from hub.exports.exports_factory import ExportsFactory
|
||||||
|
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.results_factory import ResultFactory
|
||||||
|
from hub.imports.usage_factory import UsageFactory
|
||||||
|
from hub.helpers.dictionaries import Dictionaries
|
||||||
|
|
||||||
|
from costs.cost import Cost
|
||||||
|
from costs.constants import SKIN_RETROFIT, SKIN_RETROFIT_AND_SYSTEM_RETROFIT_AND_PV, SYSTEM_RETROFIT_AND_PV
|
||||||
|
|
||||||
|
|
||||||
|
class UnitTests(unittest.TestCase):
|
||||||
|
def setUp(self) -> None:
|
||||||
|
city_file = Path("./tests/data/test.geojson").resolve()
|
||||||
|
output_path = Path('./tests/output/').resolve()
|
||||||
|
city = GeometryFactory('geojson',
|
||||||
|
city_file,
|
||||||
|
height_field='citygml_me',
|
||||||
|
year_of_construction_field='ANNEE_CONS',
|
||||||
|
function_field='CODE_UTILI',
|
||||||
|
function_to_hub=Dictionaries().montreal_function_to_hub_function).city
|
||||||
|
ConstructionFactory('nrcan', city).enrich()
|
||||||
|
UsageFactory('nrcan', city).enrich()
|
||||||
|
ExportsFactory('sra', city, output_path).export()
|
||||||
|
sra_file = str((output_path / f'{city.name}_sra.xml').resolve())
|
||||||
|
subprocess.run(['/usr/local/bin/sra', sra_file])
|
||||||
|
ResultFactory('sra', city, output_path).enrich()
|
||||||
|
|
||||||
|
for building in city.buildings:
|
||||||
|
building.energy_systems_archetype_name = 'system 1 gas pv'
|
||||||
|
EnergySystemsFactory('montreal_custom', city).enrich()
|
||||||
|
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)
|
||||||
|
ResultFactory('insel_monthly_energy_balance', city, output_path).enrich()
|
||||||
|
self._city = city
|
||||||
|
|
||||||
|
def test_current_status(self):
|
||||||
|
for building in self._city.buildings:
|
||||||
|
result = Cost(building).life_cycle
|
||||||
|
self.assertIsNotNone(result)
|
||||||
|
self.assertEqual(0, result.values[0])
|
||||||
|
|
||||||
|
def test_scenario_1(self):
|
||||||
|
for building in self._city.buildings:
|
||||||
|
result = Cost(building, retrofit_scenario=SKIN_RETROFIT).life_cycle
|
||||||
|
self.assertIsNotNone(result)
|
||||||
|
|
||||||
|
def test_scenario_2(self):
|
||||||
|
for building in self._city.buildings:
|
||||||
|
result = Cost(building, retrofit_scenario=SYSTEM_RETROFIT_AND_PV).life_cycle
|
||||||
|
self.assertIsNotNone(result)
|
||||||
|
self.assertEqual(0, result.values[0])
|
||||||
|
|
||||||
|
def test_scenario_3(self):
|
||||||
|
for building in self._city.buildings:
|
||||||
|
result = Cost(building, retrofit_scenario=SKIN_RETROFIT_AND_SYSTEM_RETROFIT_AND_PV).life_cycle
|
||||||
|
self.assertIsNotNone(result)
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
files = glob.glob('output/[!.]*')
|
||||||
|
for file in files:
|
||||||
|
os.unlink(file)
|
Loading…
Reference in New Issue
Block a user