Compare commits

..

No commits in common. "main" and "0.1.0.1" have entirely different histories.

14 changed files with 63 additions and 46 deletions

2
.gitignore vendored
View File

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

View File

@ -0,0 +1,9 @@
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

@ -0,0 +1,12 @@
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

@ -0,0 +1 @@

View File

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

View File

@ -0,0 +1 @@
co2_emission

View File

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

View File

@ -15,15 +15,12 @@ class Co2Emission:
def __init__(self, building: Building, emissions_factor=None):
if emissions_factor is None:
# kgCO2 / J
emissions_factor = {cte.GAS: 56.25480769E-9,
cte.ELECTRICITY: 0.313840909E-9,
cte.DIESEL: 74.52882883E-9,
emissions_factor = {cte.GAS: 0.2025,
cte.ELECTRICITY: 0.00113,
cte.DIESEL: 0.2683,
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:
@ -40,50 +37,45 @@ class Co2Emission:
"""
results = {}
for energy_system in self._building.energy_systems:
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 = [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 = [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 = [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
fuel_type = energy_system.generation_system.generic_generation_system.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])
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])
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])
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 = [v * emission_factor for v in self._building.lighting_electrical_demand[time_period]]
values = []
for value in self._building.lighting_electrical_demand[time_period]['insel meb']:
values.append(value * self._emissions_factor[cte.ELECTRICITY])
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 = [v * emission_factor for v in self._building.appliances_electrical_demand[time_period]]
values = []
for value in self._building.appliances_electrical_demand[time_period]['insel meb']:
values.append(value * self._emissions_factor[cte.ELECTRICITY])
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.5'
__version__ = '0.1.0.1'

2
dist/.gitignore vendored Normal file
View File

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

View File

@ -62,7 +62,6 @@ 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/[!.]*')