forked from s_ranjbar/city_retrofit
62 lines
1.9 KiB
Python
62 lines
1.9 KiB
Python
|
"""
|
||
|
Test EnergySystemsFactory and various heatpump models
|
||
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
||
|
Copyright © 2021 Project Author 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
|
||
|
from city_model_structure.energy_systems.heat_pump import HeatPump
|
||
|
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/user_output.csv"
|
||
|
self._city = GeometryFactory('citygml', city_file).city
|
||
|
EnergySystemsFactory('xlsx heat pump', self._city).enrich()
|
||
|
|
||
|
def test_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')
|
||
|
|
||
|
def test_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))
|
||
|
self.assertEqual(df.iloc[0, 1], 3045398.0)
|
||
|
|
||
|
def tearDown(self) -> None:
|
||
|
try:
|
||
|
os.remove(self._output_path)
|
||
|
except OSError:
|
||
|
pass
|