Merge branch 'hp_results' into 'master'
Hp results See merge request Guille/hub!56
This commit is contained in:
commit
c348fb0134
|
@ -4,6 +4,8 @@ SPDX - License - Identifier: LGPL - 3.0 - or -later
|
||||||
Copyright © 2022 Concordia CERC group
|
Copyright © 2022 Concordia CERC group
|
||||||
Project Coder Peter Yefi peteryefi@gmail.com
|
Project Coder Peter Yefi peteryefi@gmail.com
|
||||||
"""
|
"""
|
||||||
|
from typing import List
|
||||||
|
from pandas.core.series import Series
|
||||||
|
|
||||||
|
|
||||||
class HeatPump:
|
class HeatPump:
|
||||||
|
@ -13,6 +15,8 @@ class HeatPump:
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._model = None
|
self._model = None
|
||||||
|
self._hp_monthly_fossil_consumption = None
|
||||||
|
self._hp_monthly_electricity_demand = None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def model(self) -> str:
|
def model(self) -> str:
|
||||||
|
@ -30,3 +34,31 @@ class HeatPump:
|
||||||
"""
|
"""
|
||||||
if self._model is None:
|
if self._model is None:
|
||||||
self._model = value
|
self._model = value
|
||||||
|
|
||||||
|
@property
|
||||||
|
def hp_monthly_fossil_consumption(self) -> List:
|
||||||
|
"""
|
||||||
|
Fossil fuel consumption that results from insel simulation
|
||||||
|
":return: []
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
return self._hp_monthly_fossil_consumption
|
||||||
|
|
||||||
|
@hp_monthly_fossil_consumption.setter
|
||||||
|
def hp_monthly_fossil_consumption(self, value):
|
||||||
|
if type(value) is Series:
|
||||||
|
self._hp_monthly_fossil_consumption = value
|
||||||
|
|
||||||
|
@property
|
||||||
|
def hp_monthly_electricity_demand(self) -> List:
|
||||||
|
"""
|
||||||
|
Electricity demand that results from insel simulation
|
||||||
|
":return: []
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
return self._hp_monthly_electricity_demand
|
||||||
|
|
||||||
|
@hp_monthly_electricity_demand.setter
|
||||||
|
def hp_monthly_electricity_demand(self, value):
|
||||||
|
if type(value) == Series:
|
||||||
|
self._hp_monthly_electricity_demand = value
|
||||||
|
|
|
@ -5,6 +5,7 @@ Copyright © 2022 Concordia CERC group
|
||||||
Project Coder Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
|
Project Coder Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
class SensorMeasure:
|
class SensorMeasure:
|
||||||
def __init__(self, latitude, longitude, utc_timestamp, value):
|
def __init__(self, latitude, longitude, utc_timestamp, value):
|
||||||
self._latitude = latitude
|
self._latitude = latitude
|
||||||
|
|
|
@ -7,6 +7,7 @@ Project Coder Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
|
||||||
|
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
|
|
||||||
|
|
||||||
class SensorType(Enum):
|
class SensorType(Enum):
|
||||||
HUMIDITY = 0
|
HUMIDITY = 0
|
||||||
TEMPERATURE = 1
|
TEMPERATURE = 1
|
||||||
|
|
38
hub/imports/results/insel_heatpump_energy_demand.py
Normal file
38
hub/imports/results/insel_heatpump_energy_demand.py
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
"""
|
||||||
|
Insel Heap pump energy demand and fossil fuel consumption
|
||||||
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
||||||
|
Copyright © 2023 Concordia CERC group
|
||||||
|
Project Coder peter.yefi@gmail.cm
|
||||||
|
"""
|
||||||
|
|
||||||
|
from pathlib import Path
|
||||||
|
import pandas as pd
|
||||||
|
|
||||||
|
|
||||||
|
class InselHeatPumpEnergyDemand:
|
||||||
|
"""
|
||||||
|
Import Energy demand and fossil fuel consumption results
|
||||||
|
"""
|
||||||
|
def __init__(self, city, base_path, hp_model):
|
||||||
|
"""
|
||||||
|
:param city: the city
|
||||||
|
:param base_path: the insel simulation output file
|
||||||
|
:param hp_model: the heatpump model for both air source and water to water
|
||||||
|
"""
|
||||||
|
self._city = city
|
||||||
|
self._hp_model = hp_model
|
||||||
|
with open(Path(base_path).resolve()) as csv_file:
|
||||||
|
df = pd.read_csv(csv_file)
|
||||||
|
self._monthly_electricity_demand = df.iloc[:, 1]
|
||||||
|
self._monthly_fossil_fuel_consumption = df.iloc[:, 2]
|
||||||
|
|
||||||
|
def enrich(self):
|
||||||
|
for energy_system in self._city.energy_systems:
|
||||||
|
if energy_system.air_source_hp is not None:
|
||||||
|
if energy_system.air_source_hp.model == self._hp_model:
|
||||||
|
energy_system.air_source_hp.hp_monthly_fossil_consumption = self._monthly_fossil_fuel_consumption
|
||||||
|
|
||||||
|
if energy_system.water_to_water_hp is not None:
|
||||||
|
if energy_system.water_to_water_hp.model == self._hp_model:
|
||||||
|
energy_system.water_to_water_hp.hp_monthly_electricity_demand = self._monthly_electricity_demand
|
||||||
|
|
|
@ -11,13 +11,23 @@ from hub.helpers.utils import validate_import_export_type
|
||||||
from hub.hub_logger import logger
|
from hub.hub_logger import logger
|
||||||
from hub.imports.results.simplified_radiosity_algorithm import SimplifiedRadiosityAlgorithm
|
from hub.imports.results.simplified_radiosity_algorithm import SimplifiedRadiosityAlgorithm
|
||||||
from hub.imports.results.insel_monthly_energry_balance import InselMonthlyEnergyBalance
|
from hub.imports.results.insel_monthly_energry_balance import InselMonthlyEnergyBalance
|
||||||
|
from hub.imports.results.insel_heatpump_energy_demand import InselHeatPumpEnergyDemand
|
||||||
|
|
||||||
|
|
||||||
class ResultFactory:
|
class ResultFactory:
|
||||||
"""
|
"""
|
||||||
UsageFactory class
|
ResultFactory class
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self, handler, city, base_path=None, hp_model=None):
|
||||||
|
"""
|
||||||
|
|
||||||
|
:param handler: pointer to results class to be called
|
||||||
|
:param city: the city object
|
||||||
|
:param base_path: the path to result output file
|
||||||
|
:param hp_model: (optional) the heat pump model for which
|
||||||
|
results are being retrieved
|
||||||
"""
|
"""
|
||||||
def __init__(self, handler, city, base_path=None):
|
|
||||||
if base_path is None:
|
if base_path is None:
|
||||||
base_path = Path(Path(__file__).parent.parent / 'data/results')
|
base_path = Path(Path(__file__).parent.parent / 'data/results')
|
||||||
self._handler = '_' + handler.lower().replace(' ', '_')
|
self._handler = '_' + handler.lower().replace(' ', '_')
|
||||||
|
@ -28,6 +38,7 @@ class ResultFactory:
|
||||||
raise Exception(err_msg)
|
raise Exception(err_msg)
|
||||||
self._city = city
|
self._city = city
|
||||||
self._base_path = base_path
|
self._base_path = base_path
|
||||||
|
self._hp_model = hp_model
|
||||||
|
|
||||||
def _sra(self):
|
def _sra(self):
|
||||||
"""
|
"""
|
||||||
|
@ -35,6 +46,13 @@ class ResultFactory:
|
||||||
"""
|
"""
|
||||||
SimplifiedRadiosityAlgorithm(self._city, self._base_path).enrich()
|
SimplifiedRadiosityAlgorithm(self._city, self._base_path).enrich()
|
||||||
|
|
||||||
|
def _heat_pump(self):
|
||||||
|
"""
|
||||||
|
Enrich the city (energy system specifically) with heat pump insel simulation
|
||||||
|
results
|
||||||
|
"""
|
||||||
|
InselHeatPumpEnergyDemand(self._city, self._base_path, self._hp_model).enrich()
|
||||||
|
|
||||||
def _insel_meb(self):
|
def _insel_meb(self):
|
||||||
"""
|
"""
|
||||||
Enrich the city with insel monthly energy balance results
|
Enrich the city with insel monthly energy balance results
|
||||||
|
|
74
hub/unittests/test_heat_pump_results.py
Normal file
74
hub/unittests/test_heat_pump_results.py
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
"""
|
||||||
|
Test EnergySystemsFactory and various heatpump models
|
||||||
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
||||||
|
Copyright © 2023 Concordia CERC group
|
||||||
|
Project Coder Peter Yefi peteryefi@gmail.com
|
||||||
|
"""
|
||||||
|
from unittest import TestCase
|
||||||
|
from hub.imports.geometry_factory import GeometryFactory
|
||||||
|
from hub.imports.energy_systems_factory import EnergySystemsFactory
|
||||||
|
from hub.exports.energy_systems_factory import EnergySystemsExportFactory
|
||||||
|
from hub.imports.results_factory import ResultFactory
|
||||||
|
import os
|
||||||
|
from pandas.core.series import Series
|
||||||
|
|
||||||
|
# User defined paramenters
|
||||||
|
user_input = {
|
||||||
|
'StartYear': 2020,
|
||||||
|
'EndYear': 2021,
|
||||||
|
'MaximumHPEnergyInput': 8000,
|
||||||
|
'HoursOfStorageAtMaxDemand': 1,
|
||||||
|
'BuildingSuppTemp': 40,
|
||||||
|
'TemperatureDifference': 15,
|
||||||
|
'FuelLHV': 47100,
|
||||||
|
'FuelPrice': 0.12,
|
||||||
|
'FuelEF': 1887,
|
||||||
|
'FuelDensity': 0.717,
|
||||||
|
'HPSupTemp': 60
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class TestHeatPumpResults(TestCase):
|
||||||
|
"""
|
||||||
|
TestHeatPumpResults
|
||||||
|
"""
|
||||||
|
|
||||||
|
def setUp(self) -> None:
|
||||||
|
"""
|
||||||
|
Test setup
|
||||||
|
:return: None
|
||||||
|
"""
|
||||||
|
city_file = "tests_data/C40_Final.gml"
|
||||||
|
self._output_path = "tests_data/as_user_output.csv"
|
||||||
|
self._city = GeometryFactory('citygml', path=city_file).city
|
||||||
|
EnergySystemsFactory('air source hp', self._city).enrich()
|
||||||
|
|
||||||
|
def test_air_source_series_heat_pump_012_results(self):
|
||||||
|
EnergySystemsExportFactory(city=self._city, user_input=user_input, hp_model='012',
|
||||||
|
output_path=self._output_path).export()
|
||||||
|
ResultFactory('heat pump', self._city, self._output_path, '012').enrich()
|
||||||
|
|
||||||
|
for energy_system in self._city.energy_systems:
|
||||||
|
self.assertIsNone(energy_system.water_to_water_hp)
|
||||||
|
if energy_system.air_source_hp.model == '012':
|
||||||
|
self.assertIsInstance(energy_system.air_source_hp.hp_monthly_fossil_consumption, Series)
|
||||||
|
self.assertEqual(energy_system.air_source_hp.hp_monthly_fossil_consumption.iloc[5], 1.51325583)
|
||||||
|
self.assertEqual(energy_system.air_source_hp.hp_monthly_fossil_consumption.iloc[12], 35.853598782915)
|
||||||
|
|
||||||
|
def test_air_source_series_heat_pump_015_results(self):
|
||||||
|
EnergySystemsExportFactory(city=self._city, user_input=user_input, hp_model='140',
|
||||||
|
output_path=self._output_path).export()
|
||||||
|
ResultFactory('heat pump', self._city, self._output_path, '140').enrich()
|
||||||
|
|
||||||
|
for energy_system in self._city.energy_systems:
|
||||||
|
self.assertIsNone(energy_system.water_to_water_hp)
|
||||||
|
if energy_system.air_source_hp.model == '140':
|
||||||
|
self.assertIsInstance(energy_system.air_source_hp.hp_monthly_fossil_consumption, Series)
|
||||||
|
self.assertEqual(energy_system.air_source_hp.hp_monthly_fossil_consumption.iloc[0], 7.91282225)
|
||||||
|
self.assertEqual(energy_system.air_source_hp.hp_monthly_fossil_consumption.iloc[2], 0.068873927)
|
||||||
|
|
||||||
|
def tearDown(self) -> None:
|
||||||
|
try:
|
||||||
|
os.remove(self._output_path)
|
||||||
|
except OSError:
|
||||||
|
pass
|
Loading…
Reference in New Issue
Block a user