hub/unittests/test_energy_systems_air_source_hp.py

63 lines
2.0 KiB
Python
Raw Normal View History

"""
Test EnergySystemsFactory and various heatpump models
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2022 Concordia CERC group
Project Coder Peter Yefi peteryefi@gmail.com
"""
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
from exports.energy_systems_factory import EnergySystemsExportFactory
import os
class TestEnergySystemsFactory(TestCase):
"""
TestBuilding TestCase 1
"""
def setUp(self) -> None:
"""
Test setup
:return: None
"""
city_file = "../unittests/tests_data/C40_Final.gml"
self._output_path = "../unittests/tests_data/as_user_output.csv"
self._city = GeometryFactory('citygml', city_file).city
2021-12-15 04:19:10 -05:00
EnergySystemsFactory('air source hp', self._city).enrich()
2021-12-15 04:19:10 -05:00
def test_air_source_heat_pump_import(self):
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')
self.assertEqual(self._city.energy_systems[16].air_source_hp.model, '140')
2021-12-15 04:19:10 -05:00
def test_air_source_heat_pump_export(self):
# 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
}
EnergySystemsExportFactory(self._city, user_input, '012', self._output_path).export()
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)
def tearDown(self) -> None:
try:
os.remove(self._output_path)
except OSError:
pass