2021-11-12 05:11:56 -05:00
|
|
|
"""
|
|
|
|
Test EnergySystemsFactory and various heatpump models
|
|
|
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
2022-04-08 09:35:33 -04:00
|
|
|
Copyright © 2022 Concordia CERC group
|
|
|
|
Project Coder Peter Yefi peteryefi@gmail.com
|
2021-11-12 05:11:56 -05:00
|
|
|
"""
|
|
|
|
import pandas as pd
|
|
|
|
from unittest import TestCase
|
|
|
|
from imports.geometry_factory import GeometryFactory
|
|
|
|
from imports.energy_systems_factory import EnergySystemsFactory
|
2021-12-15 04:19:10 -05:00
|
|
|
from city_model_structure.energy_systems.air_source_hp import AirSourceHP
|
2021-11-12 05:11:56 -05:00
|
|
|
from exports.energy_systems_factory import EnergySystemsExportFactory
|
|
|
|
import os
|
|
|
|
|
2022-08-16 13:48:43 -04:00
|
|
|
# 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
|
|
|
|
}
|
|
|
|
|
2021-11-12 05:11:56 -05:00
|
|
|
|
|
|
|
class TestEnergySystemsFactory(TestCase):
|
|
|
|
"""
|
|
|
|
TestBuilding TestCase 1
|
|
|
|
"""
|
|
|
|
|
|
|
|
def setUp(self) -> None:
|
|
|
|
"""
|
|
|
|
Test setup
|
|
|
|
:return: None
|
|
|
|
"""
|
|
|
|
city_file = "../unittests/tests_data/C40_Final.gml"
|
2022-01-29 09:43:57 -05:00
|
|
|
self._output_path = "../unittests/tests_data/as_user_output.csv"
|
2021-11-12 05:11:56 -05:00
|
|
|
self._city = GeometryFactory('citygml', city_file).city
|
2021-12-15 04:19:10 -05:00
|
|
|
EnergySystemsFactory('air source hp', self._city).enrich()
|
2021-11-12 05:11:56 -05:00
|
|
|
|
2021-12-15 04:19:10 -05:00
|
|
|
def test_air_source_heat_pump_import(self):
|
2021-11-12 05:11:56 -05:00
|
|
|
self.assertIsNotNone(self._city.energy_systems, 'City has energy systems')
|
2021-12-15 04:19:10 -05:00
|
|
|
self.assertIsInstance(self._city.energy_systems[0].air_source_hp, AirSourceHP)
|
|
|
|
self.assertEqual(self._city.energy_systems[0].air_source_hp.model, '012')
|
2021-12-15 04:25:56 -05:00
|
|
|
self.assertEqual(self._city.energy_systems[16].air_source_hp.model, '140')
|
2021-11-12 05:11:56 -05:00
|
|
|
|
2022-08-16 13:48:43 -04:00
|
|
|
def test_air_source_series_heat_pump_export(self):
|
2022-08-10 15:44:40 -04:00
|
|
|
EnergySystemsExportFactory(city=self._city, user_input=user_input, hp_model='012',
|
|
|
|
output_path=self._output_path).export()
|
2021-11-12 05:11:56 -05:00
|
|
|
df = pd.read_csv(self._output_path)
|
|
|
|
self.assertEqual(df.shape, (13, 3))
|
2022-03-10 12:44:04 -05:00
|
|
|
self.assertEqual(df.iloc[0, 1], 1867715.88)
|
2021-11-12 05:11:56 -05:00
|
|
|
|
2022-08-16 13:48:43 -04:00
|
|
|
def test_air_source_parallel_heat_pump_export(self):
|
2022-08-18 16:45:55 -04:00
|
|
|
output = EnergySystemsExportFactory(city=self._city, user_input=user_input, hp_model='018',
|
|
|
|
output_path=None, sim_type=1).export()
|
|
|
|
self.assertEqual(output["hourly_electricity_demand"][0], 38748.5625)
|
|
|
|
self.assertIsNotNone(output["daily_fossil_consumption"])
|
|
|
|
self.assertEqual(len(output["hourly_electricity_demand"]), 8760)
|
2022-08-16 13:48:43 -04:00
|
|
|
|
2021-11-12 05:11:56 -05:00
|
|
|
def tearDown(self) -> None:
|
|
|
|
try:
|
|
|
|
os.remove(self._output_path)
|
|
|
|
except OSError:
|
|
|
|
pass
|