diff --git a/city_model_structure/energy_system.py b/city_model_structure/energy_system.py index 04ab3681..f1815bac 100644 --- a/city_model_structure/energy_system.py +++ b/city_model_structure/energy_system.py @@ -6,7 +6,8 @@ Contributor Peter Yefi peteryefi@gmail.com """ from city_model_structure.city_object import CityObject -from city_model_structure.energy_systems.heat_pump import HeatPump +from city_model_structure.energy_systems.air_source_hp import AirSourceHP +from city_model_structure.energy_systems.water_to_water_hp import WaterToWaterHP class EnergySystem(CityObject): @@ -16,25 +17,43 @@ class EnergySystem(CityObject): def __init__(self, name, lod, surfaces, city_lower_corner): super().__init__(name, lod, surfaces, city_lower_corner) - self._heat_pump = None + self._air_source_hp = None + self._water_to_water_hp = None self._type = 'energy_system' @property - def heat_pump(self) -> HeatPump: + def air_source_hp(self) -> AirSourceHP: """ Heat pump energy system :return: """ - return self._heat_pump + return self._air_source_hp - @heat_pump.setter - def heat_pump(self, value): + @air_source_hp.setter + def air_source_hp(self, value): """ - Set heat pumm for energy system - :param value: HeatPump + Set heat pump for energy system + :param value: AirSourceHP """ - if self._heat_pump is None: - self._heat_pump = value + if self._air_source_hp is None: + self._air_source_hp = value + + @property + def water_to_water_hp(self) -> WaterToWaterHP: + """ + Water to water heat pump energy system + :return: + """ + return self._water_to_water_hp + + @water_to_water_hp.setter + def water_to_water_hp(self, value): + """ + Set water to water heat pump for energy system + :param value: WaterToWaterHP + """ + if self._water_to_water_hp is None: + self._water_to_water_hp = value @property def type(self) -> str: diff --git a/city_model_structure/energy_systems/air_source_hp.py b/city_model_structure/energy_systems/air_source_hp.py new file mode 100644 index 00000000..752f13b0 --- /dev/null +++ b/city_model_structure/energy_systems/air_source_hp.py @@ -0,0 +1,190 @@ +""" +heat_pump module defines a heat pump +SPDX - License - Identifier: LGPL - 3.0 - or -later +Copyright © 2020 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca +Contributor Peter Yefi peteryefi@gmail.com +""" + +from typing import List +from typing import Dict + + +class HeatPump: + """ + HeatPump class + """ + + def __init__(self): + self._model = None + self._cooling_capacity = None + self._cooling_comp_power = None + self._cooling_capacity_coff = None + self._cooling_comp_power_coff = None + self._heating_capacity = None + self._heating_comp_power = None + self._heating_capacity_coff = None + self._heating_comp_power_coff = None + + @property + def model(self) -> str: + """ + Get model name + :return: str + """ + return self._model + + @model.setter + def model(self, value): + """ + Set model (name, indicated in capacity) + :param value: str + """ + if self._model is None: + self._model = value + + @property + def cooling_capacity(self) -> List[float]: + """ + Get cooling capacity in kW + :return: [[float]] + """ + return self._cooling_capacity + + @cooling_capacity.setter + def cooling_capacity(self, value): + """ + Set cooling capacity in kW + :param value: [[float]] + """ + if self._cooling_capacity is None: + self._cooling_capacity = value + + @property + def cooling_comp_power(self) -> List[float]: + """ + Get cooling compressor power input in kW + :return: [[float]] + """ + return self._cooling_comp_power + + @cooling_comp_power.setter + def cooling_comp_power(self, value): + """ + Set the cooling compressor in kW + :param value: [[float]] + :return: + """ + if self._cooling_comp_power is None: + self._cooling_comp_power = value + + @property + def cooling_capacity_coff(self) -> List[float]: + """ + Get cooling capacity coefficients + :return: [float] + """ + return self._cooling_capacity_coff + + @cooling_capacity_coff.setter + def cooling_capacity_coff(self, value): + """ + Set the value for cooling capacity coefficients + :param value: [float] + :return: + """ + if self._cooling_capacity_coff is None: + self._cooling_capacity_coff = value + + @property + def cooling_comp_power_coff(self) -> List[float]: + """ + Get cooling compressor power coefficients + :return: [float] + """ + return self._cooling_comp_power_coff + + @cooling_comp_power_coff.setter + def cooling_comp_power_coff(self, value): + """ + Set the value for cooling compressor power coefficients + :param value: [float] + :return: + """ + if self._cooling_comp_power_coff is None: + self._cooling_comp_power_coff = value + + + + @property + def heating_capacity(self) -> List[float]: + """ + Get heating capacity kW + :return: [[float]] + """ + return self._heating_capacity + + @heating_capacity.setter + def heating_capacity(self, value): + """ + Set the heating capacity in kW + :param value: [[float]] + :return: + """ + if self._heating_capacity is None: + self._heating_capacity = value + + @property + def heating_comp_power(self) -> List[float]: + """ + Get heating compressor power kW + :return: [[float]] + """ + return self._heating_comp_power + + @heating_comp_power.setter + def heating_comp_power(self, value): + """ + Set the heating compressor power in kW + :param value: [[float]] + :return: + """ + if self._heating_comp_power is None: + self._heating_comp_power = value + + @property + def heating_comp_power_coff(self) -> List[float]: + """ + Get heating compressor power coefficients + :return: [float] + """ + return self._heating_comp_power_coff + + @heating_comp_power_coff.setter + def heating_comp_power_coff(self, value): + """ + Set the value for heating compressor power coefficients + :param value: [float] + :return: + """ + if self._heating_comp_power_coff is None: + self._heating_comp_power_coff = value + + @property + def heating_capacity_coff(self) -> List[float]: + """ + Get heating capacity coefficients + :return: [float] + """ + return self._heating_capacity_coff + + @heating_capacity_coff.setter + def heating_capacity_coff(self, value): + """ + Set the value for heating capacity coefficients + :param value: [float] + :return: + """ + if self._heating_capacity_coff is None: + self._heating_capacity_coff = value + + diff --git a/city_model_structure/energy_systems/heat_pump.py b/city_model_structure/energy_systems/heat_pump.py index 752f13b0..e69de29b 100644 --- a/city_model_structure/energy_systems/heat_pump.py +++ b/city_model_structure/energy_systems/heat_pump.py @@ -1,190 +0,0 @@ -""" -heat_pump module defines a heat pump -SPDX - License - Identifier: LGPL - 3.0 - or -later -Copyright © 2020 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca -Contributor Peter Yefi peteryefi@gmail.com -""" - -from typing import List -from typing import Dict - - -class HeatPump: - """ - HeatPump class - """ - - def __init__(self): - self._model = None - self._cooling_capacity = None - self._cooling_comp_power = None - self._cooling_capacity_coff = None - self._cooling_comp_power_coff = None - self._heating_capacity = None - self._heating_comp_power = None - self._heating_capacity_coff = None - self._heating_comp_power_coff = None - - @property - def model(self) -> str: - """ - Get model name - :return: str - """ - return self._model - - @model.setter - def model(self, value): - """ - Set model (name, indicated in capacity) - :param value: str - """ - if self._model is None: - self._model = value - - @property - def cooling_capacity(self) -> List[float]: - """ - Get cooling capacity in kW - :return: [[float]] - """ - return self._cooling_capacity - - @cooling_capacity.setter - def cooling_capacity(self, value): - """ - Set cooling capacity in kW - :param value: [[float]] - """ - if self._cooling_capacity is None: - self._cooling_capacity = value - - @property - def cooling_comp_power(self) -> List[float]: - """ - Get cooling compressor power input in kW - :return: [[float]] - """ - return self._cooling_comp_power - - @cooling_comp_power.setter - def cooling_comp_power(self, value): - """ - Set the cooling compressor in kW - :param value: [[float]] - :return: - """ - if self._cooling_comp_power is None: - self._cooling_comp_power = value - - @property - def cooling_capacity_coff(self) -> List[float]: - """ - Get cooling capacity coefficients - :return: [float] - """ - return self._cooling_capacity_coff - - @cooling_capacity_coff.setter - def cooling_capacity_coff(self, value): - """ - Set the value for cooling capacity coefficients - :param value: [float] - :return: - """ - if self._cooling_capacity_coff is None: - self._cooling_capacity_coff = value - - @property - def cooling_comp_power_coff(self) -> List[float]: - """ - Get cooling compressor power coefficients - :return: [float] - """ - return self._cooling_comp_power_coff - - @cooling_comp_power_coff.setter - def cooling_comp_power_coff(self, value): - """ - Set the value for cooling compressor power coefficients - :param value: [float] - :return: - """ - if self._cooling_comp_power_coff is None: - self._cooling_comp_power_coff = value - - - - @property - def heating_capacity(self) -> List[float]: - """ - Get heating capacity kW - :return: [[float]] - """ - return self._heating_capacity - - @heating_capacity.setter - def heating_capacity(self, value): - """ - Set the heating capacity in kW - :param value: [[float]] - :return: - """ - if self._heating_capacity is None: - self._heating_capacity = value - - @property - def heating_comp_power(self) -> List[float]: - """ - Get heating compressor power kW - :return: [[float]] - """ - return self._heating_comp_power - - @heating_comp_power.setter - def heating_comp_power(self, value): - """ - Set the heating compressor power in kW - :param value: [[float]] - :return: - """ - if self._heating_comp_power is None: - self._heating_comp_power = value - - @property - def heating_comp_power_coff(self) -> List[float]: - """ - Get heating compressor power coefficients - :return: [float] - """ - return self._heating_comp_power_coff - - @heating_comp_power_coff.setter - def heating_comp_power_coff(self, value): - """ - Set the value for heating compressor power coefficients - :param value: [float] - :return: - """ - if self._heating_comp_power_coff is None: - self._heating_comp_power_coff = value - - @property - def heating_capacity_coff(self) -> List[float]: - """ - Get heating capacity coefficients - :return: [float] - """ - return self._heating_capacity_coff - - @heating_capacity_coff.setter - def heating_capacity_coff(self, value): - """ - Set the value for heating capacity coefficients - :param value: [float] - :return: - """ - if self._heating_capacity_coff is None: - self._heating_capacity_coff = value - - diff --git a/city_model_structure/energy_systems/water_to_water_hp.py b/city_model_structure/energy_systems/water_to_water_hp.py new file mode 100644 index 00000000..e69de29b diff --git a/data/energy_systems/heat_pumps/Air Source.xlsx b/data/energy_systems/heat_pumps/Air Source.xlsx deleted file mode 100644 index c0ea122f..00000000 Binary files a/data/energy_systems/heat_pumps/Air Source.xlsx and /dev/null differ diff --git a/imports/energy_systems/xlsx_heat_pump_parameters.py b/imports/energy_systems/air_source_hp_parameters.py similarity index 89% rename from imports/energy_systems/xlsx_heat_pump_parameters.py rename to imports/energy_systems/air_source_hp_parameters.py index b1b96e70..7e62f1af 100644 --- a/imports/energy_systems/xlsx_heat_pump_parameters.py +++ b/imports/energy_systems/air_source_hp_parameters.py @@ -1,13 +1,12 @@ """ -XlsxHeatPumpParameters import the heat pump information +AirSourceHeatPumpParameters import the heat pump information SPDX - License - Identifier: LGPL - 3.0 - or -later -Copyright © 2020 Project Author Peter Yefi peteryefi@gmail.com -Contributor Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca +Copyright © 2021 Project Author Peter Yefi peteryefi@gmail.com """ import pandas as pd from typing import Dict -from city_model_structure.energy_systems.heat_pump import HeatPump +from city_model_structure.energy_systems.air_source_hp import AirSourceHP from city_model_structure.energy_system import EnergySystem from scipy.optimize import curve_fit import numpy as np @@ -15,14 +14,14 @@ from typing import List import itertools -class XlsxHeatPumpParameters: +class AirSourceHeatPumpParameters: """ - XlsxHeatPumpParameters class + AirSourceHeatPumpParameters class """ def __init__(self, city, base_path): self._city = city - self._base_path = (base_path / 'heat_pumps/Air source.xlsx') + self._base_path = (base_path / 'heat_pumps/air_source.xlsx') def _read_file(self) -> Dict: """ @@ -31,6 +30,7 @@ class XlsxHeatPumpParameters: :return : Dict """ xl_file = pd.ExcelFile(self._base_path) + heat_pump_dfs = {sheet_name: xl_file.parse(sheet_name) for sheet_name in xl_file.sheet_names} @@ -38,8 +38,10 @@ class XlsxHeatPumpParameters: heating_data = {} for sheet, dataframe in heat_pump_dfs.items(): - if sheet == "Summary": - continue + + if 'Summary' in sheet: + continue + # Remove nan rows and columns and extract cooling and heating data # for each sheet df = heat_pump_dfs[sheet].dropna(axis=1, how='all') @@ -65,10 +67,10 @@ class XlsxHeatPumpParameters: """ Enriches the city with information from file """ - heap_pump_data = self._read_file() + heat_pump_data = self._read_file() for (k_cool, v_cool), (k_heat, v_heat) in \ - zip(heap_pump_data["cooling"].items(), heap_pump_data["heating"].items()): - heat_pump = HeatPump() + zip(heat_pump_data["cooling"].items(), heat_pump_data["heating"].items()): + heat_pump = AirSourceHP() heat_pump.model = k_cool h_data = self._extract_heat_pump_data(v_heat) c_data = self._extract_heat_pump_data(v_cool) @@ -82,7 +84,7 @@ class XlsxHeatPumpParameters: heat_pump.heating_comp_power_coff = self._compute_coefficients(h_data[1]) energy_system = EnergySystem('{} capacity heat pump'.format(heat_pump.model), 0, [], None) - energy_system.heat_pump = heat_pump + energy_system.air_source_hp = heat_pump self._city.add_city_object(energy_system) return self._city diff --git a/imports/energy_systems/water_to_water_hp_parameters.py b/imports/energy_systems/water_to_water_hp_parameters.py new file mode 100644 index 00000000..e69de29b diff --git a/unittests/test_energy_systems_factory.py b/unittests/test_energy_systems_air_source_hp.py similarity index 78% rename from unittests/test_energy_systems_factory.py rename to unittests/test_energy_systems_air_source_hp.py index eb8bb7dd..ecdfdd5a 100644 --- a/unittests/test_energy_systems_factory.py +++ b/unittests/test_energy_systems_air_source_hp.py @@ -7,7 +7,7 @@ import pandas as pd from unittest import TestCase from imports.geometry_factory import GeometryFactory from imports.energy_systems_factory import EnergySystemsFactory -from city_model_structure.energy_systems.heat_pump import HeatPump +from city_model_structure.energy_systems.air_source_hp import AirSourceHP from exports.energy_systems_factory import EnergySystemsExportFactory import os @@ -25,15 +25,15 @@ class TestEnergySystemsFactory(TestCase): city_file = "../unittests/tests_data/C40_Final.gml" self._output_path = "../unittests/tests_data/user_output.csv" self._city = GeometryFactory('citygml', city_file).city - EnergySystemsFactory('xlsx heat pump', self._city).enrich() + EnergySystemsFactory('air source hp', self._city).enrich() - def test_heat_pump_import(self): + def test_air_source_heat_pump_import(self): self.assertIsNotNone(self._city.energy_systems, 'City has energy systems') - self.assertIsInstance(self._city.energy_systems[0].heat_pump, HeatPump) - self.assertEqual(self._city.energy_systems[0].heat_pump.model, '012') - self.assertEqual(self._city.energy_systems[len(self._city.energy_systems) - 1].heat_pump.model, '140') + self.assertIsInstance(self._city.energy_systems[0].air_source_hp, AirSourceHP) + self.assertEqual(self._city.energy_systems[0].air_source_hp.model, '012') + self.assertEqual(self._city.energy_systems[len(self._city.energy_systems) - 1].air_source_hp.model, '140') - def test_heat_pump_export(self): + def test_air_source_heat_pump_export(self): # User defined paramenters user_input = { 'StartYear': 2020, diff --git a/unittests/test_energy_systems_water_to_water_hp.py b/unittests/test_energy_systems_water_to_water_hp.py new file mode 100644 index 00000000..e69de29b