Compare commits

...

11 Commits

14 changed files with 42 additions and 60 deletions

2
.gitignore vendored
View File

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

View File

@ -1,9 +0,0 @@
Metadata-Version: 2.1
Name: cerc-co2-emission
Version: 0.1.0.0
Summary: CERC co2 emission contains the basic co2 emission 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 co2 emission contains the basic co2 emission calculation per CERC-Hub building

View File

@ -1,12 +0,0 @@
README.md
pyproject.toml
requirements.txt
setup.py
cerc_co2_emission.egg-info/PKG-INFO
cerc_co2_emission.egg-info/SOURCES.txt
cerc_co2_emission.egg-info/dependency_links.txt
cerc_co2_emission.egg-info/requires.txt
cerc_co2_emission.egg-info/top_level.txt
co2_emission/__init__.py
co2_emission/co2_emission.py
co2_emission/version.py

View File

@ -1,2 +0,0 @@
cerc_hub
setuptools

View File

@ -1 +0,0 @@
co2_emission

View File

@ -5,4 +5,3 @@ 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
"""

View File

@ -22,6 +22,8 @@ class Co2Emission:
cte.RENEWABLE: 0}
self._emissions_factor = emissions_factor
self._building = building
self._year = [0]
self._month = [0 for _ in range(12)]
@property
def building(self) -> Building:
@ -38,45 +40,50 @@ class Co2Emission:
"""
results = {}
for energy_system in self._building.energy_systems:
fuel_type = energy_system.generation_system.generic_generation_system.fuel_type
for generation_system in energy_system.generation_systems:
fuel_type = generation_system.fuel_type
emissions_factor = self._emissions_factor[fuel_type]
for demand_type in energy_system.demand_types:
if demand_type == cte.ELECTRICITY:
continue
results_by_time_period = {}
if demand_type == cte.HEATING:
for time_period in self._building.heating_consumption:
values = []
for value in self._building.heating_consumption[time_period]:
values.append(value * self._emissions_factor[fuel_type])
values = [v * emissions_factor for v in self._building.heating_consumption[time_period]]
results_by_time_period[time_period] = values
if demand_type == cte.COOLING:
for time_period in self._building.cooling_consumption:
values = []
for value in self._building.cooling_consumption[time_period]:
values.append(value * self._emissions_factor[fuel_type])
values = [v * emissions_factor for v in self._building.cooling_consumption[time_period]]
results_by_time_period[time_period] = values
if demand_type == cte.DOMESTIC_HOT_WATER:
for time_period in self._building.domestic_hot_water_consumption:
values = []
for value in self._building.domestic_hot_water_consumption[time_period]:
values.append(value * self._emissions_factor[fuel_type])
values = [v * emissions_factor for v in self._building.domestic_hot_water_consumption[time_period]]
results_by_time_period[time_period] = values
results[demand_type] = results_by_time_period
emission_factor = self._emissions_factor[cte.ELECTRICITY]
results_by_time_period = {}
for time_period in self._building.lighting_electrical_demand:
values = []
for value in self._building.lighting_electrical_demand[time_period]:
values.append(value * self._emissions_factor[cte.ELECTRICITY])
values = [v * emission_factor for v in self._building.lighting_electrical_demand[time_period]]
results_by_time_period[time_period] = values
results[cte.LIGHTING] = results_by_time_period
results_by_time_period = {}
for time_period in self._building.appliances_electrical_demand:
values = []
for value in self._building.appliances_electrical_demand[time_period]:
values.append(value * self._emissions_factor[cte.ELECTRICITY])
values = [v * emission_factor for v in self._building.appliances_electrical_demand[time_period]]
results_by_time_period[time_period] = values
results[cte.APPLIANCES] = results_by_time_period
if cte.HEATING not in results:
results[cte.HEATING] = {cte.YEAR: self._year, cte.MONTH: self._month}
if cte.COOLING not in results:
results[cte.COOLING] = {cte.YEAR: self._year, cte.MONTH: self._month}
if cte.ELECTRICITY not in results:
results[cte.ELECTRICITY] = {cte.YEAR: self._year, cte.MONTH: self._month}
if cte.LIGHTING not in results:
results[cte.LIGHTING] = {cte.YEAR: self._year, cte.MONTH: self._month}
if cte.APPLIANCES not in results:
results[cte.APPLIANCES] = {cte.YEAR: self._year, cte.MONTH: self._month}
if cte.DOMESTIC_HOT_WATER not in results:
results[cte.DOMESTIC_HOT_WATER] = {cte.YEAR: self._year, cte.MONTH: self._month}
return results

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.5'

2
dist/.gitignore vendored
View File

@ -1,2 +0,0 @@
*
!.gitignore

View File

@ -62,6 +62,7 @@ class UnitTests(unittest.TestCase):
for building in self.init.city.buildings:
result = Co2Emission(building).operational_co2
self.assertIsNotNone(result)
print(result)
def tearDown(self):
files = glob.glob('output/[!.]*')