From ebe5439f0267c0927e4c417408b2f08364bf0db1 Mon Sep 17 00:00:00 2001 From: Peter Yefi Date: Wed, 10 Nov 2021 10:17:01 +0000 Subject: [PATCH] Fixed issue with coefficient computation --- imports/energy_systems/xlsx_heat_pump_parameters.py | 13 +++++++++---- imports/energy_systems_factory.py | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/imports/energy_systems/xlsx_heat_pump_parameters.py b/imports/energy_systems/xlsx_heat_pump_parameters.py index 5e6269d0..b1b96e70 100644 --- a/imports/energy_systems/xlsx_heat_pump_parameters.py +++ b/imports/energy_systems/xlsx_heat_pump_parameters.py @@ -86,7 +86,7 @@ class XlsxHeatPumpParameters: self._city.add_city_object(energy_system) return self._city - def _extract_heat_pump_data(self, heat_pump_capacity_data) -> [List, List]: + def _extract_heat_pump_data(self, heat_pump_capacity_data: Dict) -> [List, List]: """ Fetches a list of metric based data for heat pump for various temperature, eg. cooling capacity data for 12 capacity heat pump @@ -102,7 +102,7 @@ class XlsxHeatPumpParameters: compressor_power_data.append(metric_data[1]) return [cooling_heating_capacity_data, compressor_power_data] - def _compute_coefficients(self, heat_pump_data, data_type="heat") -> List[float]: + def _compute_coefficients(self, heat_pump_data: List, data_type="heat") -> List[float]: """ Compute heat output and electrical demand coefficients from heating and cooling performance data @@ -111,10 +111,15 @@ class XlsxHeatPumpParameters: or heating performance data :return: Tuple[Dict, Dict] """ - out_temp = [25, 30, 32, 35, 40, 45] * 6 + # Determine the recurrence of temperature values. 6 repetitions for + # cooling performance and 5 repetition for heating performance + temp_multiplier = 5 if data_type == "heat" else 6 + out_temp = [25, 30, 32, 35, 40, 45] * temp_multiplier + heat_x_values = np.repeat([-5, 0, 7, 10, 15], 6) cool_x_values = np.repeat([6, 7, 8, 9, 10, 11], 6) x_values = heat_x_values if data_type == "heat" else cool_x_values + x_values = x_values.tolist() # convert list of lists to one list heat_pump_data = list(itertools.chain.from_iterable(heat_pump_data)) @@ -122,7 +127,7 @@ class XlsxHeatPumpParameters: popt, _ = curve_fit(self._objective_function, [x_values, out_temp], heat_pump_data) return popt.tolist() - def _objective_function(self, xdata, a1, a2, a3, a4, a5, a6) -> float: + def _objective_function(self, xdata: List, a1: float, a2: float, a3: float, a4: float, a5: float, a6: float) -> float: """ Objective function for computing coefficients :param xdata: diff --git a/imports/energy_systems_factory.py b/imports/energy_systems_factory.py index 964353e7..18d65e86 100644 --- a/imports/energy_systems_factory.py +++ b/imports/energy_systems_factory.py @@ -19,7 +19,7 @@ class EnergySystemsFactory: self._city = city self._base_path = base_path - def _xlsx_heat_pump(self): + def _xlsx_heat_pump_parameters(self): """ Enrich the city by using xlsx heat pump information """