From 04c56587a84e687f29cc12acbb893d8acb906d69 Mon Sep 17 00:00:00 2001 From: Peter Yefi Date: Tue, 16 Aug 2022 13:48:43 -0400 Subject: [PATCH] Added tests for parallel simulations --- .../test_energy_systems_air_source_hp.py | 39 ++++++++------- .../test_energy_systems_water_to_water_hp.py | 47 +++++++++++-------- 2 files changed, 51 insertions(+), 35 deletions(-) diff --git a/unittests/test_energy_systems_air_source_hp.py b/unittests/test_energy_systems_air_source_hp.py index 72c3a9cd..c9711cce 100644 --- a/unittests/test_energy_systems_air_source_hp.py +++ b/unittests/test_energy_systems_air_source_hp.py @@ -12,6 +12,21 @@ from city_model_structure.energy_systems.air_source_hp import AirSourceHP from exports.energy_systems_factory import EnergySystemsExportFactory import os +# 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 TestEnergySystemsFactory(TestCase): """ @@ -34,28 +49,20 @@ class TestEnergySystemsFactory(TestCase): self.assertEqual(self._city.energy_systems[0].air_source_hp.model, '012') self.assertEqual(self._city.energy_systems[16].air_source_hp.model, '140') - 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 - } - + def test_air_source_series_heat_pump_export(self): EnergySystemsExportFactory(city=self._city, user_input=user_input, hp_model='012', output_path=self._output_path).export() df = pd.read_csv(self._output_path) self.assertEqual(df.shape, (13, 3)) self.assertEqual(df.iloc[0, 1], 1867715.88) + def test_air_source_parallel_heat_pump_export(self): + EnergySystemsExportFactory(city=self._city, user_input=user_input, hp_model='018', + output_path=self._output_path, sim_type=1).export() + df = pd.read_csv(self._output_path) + self.assertEqual(df.shape, (13, 3)) + self.assertEqual(df.iloc[0, 1], 22155602.0) + def tearDown(self) -> None: try: os.remove(self._output_path) diff --git a/unittests/test_energy_systems_water_to_water_hp.py b/unittests/test_energy_systems_water_to_water_hp.py index 889f9127..897bb302 100644 --- a/unittests/test_energy_systems_water_to_water_hp.py +++ b/unittests/test_energy_systems_water_to_water_hp.py @@ -13,6 +13,21 @@ import pandas as pd import os +# 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 TestEnergySystemsFactory(TestCase): """ @@ -35,27 +50,21 @@ class TestEnergySystemsFactory(TestCase): self.assertEqual(self._city.energy_systems[0].water_to_water_hp.model, 'ClimateMaster 156 kW') self.assertEqual(self._city.energy_systems[2].water_to_water_hp.model, 'ClimateMaster 335 kW') - def test_water_to_water_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 - } + def test_water_to_water_series_heat_pump_export(self): - EnergySystemsExportFactory(self._city, user_input, 'ClimateMaster 156 kW', self._output_path).export('water') + EnergySystemsExportFactory(city=self._city, user_input=user_input, hp_model='ClimateMaster 156 kW', + output_path=self._output_path).export('water') df = pd.read_csv(self._output_path) - print(df.shape) - #self.assertEqual(df.shape, (13, 3)) - #self.assertEqual(df.iloc[0, 1], 3045398.0) + self.assertEqual(df.shape, (13, 3)) + self.assertEqual(df.iloc[0, 1], 1162387.5) + + def test_water_to_water_parallel_heat_pump_export(self): + + EnergySystemsExportFactory(city=self._city, user_input=user_input, hp_model='ClimateMaster 256 kW', + output_path=self._output_path, sim_type=1).export('water') + df = pd.read_csv(self._output_path) + self.assertEqual(df.shape, (13, 3)) + self.assertEqual(df.iloc[0, 1], 1031544.62) def tearDown(self) -> None: try: