From 380c6644a33fce935028d8613d080d99c09d5388 Mon Sep 17 00:00:00 2001 From: Peter Yefi Date: Thu, 10 Mar 2022 12:44:04 -0500 Subject: [PATCH] Changed how coefficients are generated --- .../heat_pumps/~$air_source.xlsx | Bin 165 -> 0 bytes .../energy_systems/air_source_hp_export.py | 8 ++--- exports/energy_systems/heat_pump_export.py | 34 ++++++++---------- .../air_source_hp_parameters.py | 13 +++---- .../test_energy_systems_air_source_hp.py | 2 +- 5 files changed, 27 insertions(+), 30 deletions(-) delete mode 100644 data/energy_systems/heat_pumps/~$air_source.xlsx diff --git a/data/energy_systems/heat_pumps/~$air_source.xlsx b/data/energy_systems/heat_pumps/~$air_source.xlsx deleted file mode 100644 index 5a932052db2a5d1e1d32a453f59be330b8becc3b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 165 zcmWgj%}g%JFV0UZQSeVo%S=vH2rW)6QXm9G8GIQs8Il=_81fm4fjEt!gh7G9A4sQx R#Z!U2P@qgIP=x};5CA3W7%cz* diff --git a/exports/energy_systems/air_source_hp_export.py b/exports/energy_systems/air_source_hp_export.py index c07649cc..9ea7f7d7 100644 --- a/exports/energy_systems/air_source_hp_export.py +++ b/exports/energy_systems/air_source_hp_export.py @@ -38,8 +38,8 @@ class AirSourceHPExport(HeatPumpExport): for energy_system in self._city.energy_systems: if energy_system.air_source_hp.model == hp_model: if data_type == 'heat': - return energy_system.air_source_hp.heating_capacity_coff, energy_system.air_source_hp.heating_comp_power_coff - return energy_system.air_source_hp.cooling_capacity_coff, energy_system.air_source_hp.cooling_comp_power_coff + return energy_system.air_source_hp.heating_capacity_coff + return energy_system.air_source_hp.cooling_capacity_coff return None def execute_insel(self, user_input, hp_model, data_type): @@ -55,5 +55,5 @@ class AirSourceHPExport(HeatPumpExport): :return: :return: """ - capacity_coeff, power_coeff = self._extract_model_coff(hp_model, data_type) - super(AirSourceHPExport, self)._run_insel(user_input, capacity_coeff, power_coeff, 'air_source.insel') + capacity_coeff = self._extract_model_coff(hp_model, data_type) + super(AirSourceHPExport, self)._run_insel(user_input, capacity_coeff, 'air_source.insel') diff --git a/exports/energy_systems/heat_pump_export.py b/exports/energy_systems/heat_pump_export.py index 3f5b9c73..f44edbf4 100644 --- a/exports/energy_systems/heat_pump_export.py +++ b/exports/energy_systems/heat_pump_export.py @@ -27,18 +27,17 @@ class HeatPumpExport: self._base_path = base_path self._output_path = output_path - def _run_insel(self, user_input: Dict, capacity_coeff: List, power_coeff: List, filename: str) -> None: + def _run_insel(self, user_input: Dict, capacity_coeff: List, filename: str) -> None: """ Runs insel and write the necessary files :param user_input: a dictionary containing the user values necessary to run insel :param capacity_coeff: a list containing capacity coefficients - :param power_coeff: a list containing power demand coefficients :param filename: the name of the insel file to be created :return: """ self._input_data = user_input - self._update_input_data_with_coff(capacity_coeff, power_coeff) + self._update_input_data_with_coff(capacity_coeff) # update input data with constants self._update_input_data_with_constants() # update input data with input and output files for insel @@ -82,7 +81,7 @@ class HeatPumpExport: 'HP Operational Cost (CAD)', 'Auxiliary Heater Operational Cost (CAD)', 'Operational CO2 Emissions of HP (g)', 'Operational CO2 Emissions of Auxiliary Heater (g)', - 'Return Temperature', 'Demand (kW)'], + 'Return Temperature', 'Demand (kW)', 'Test Column'], self._input_data['fileOut2']: ['Day', 'Operational Daily Emissions from Heat Pumps (g)', 'Operational Daily Emissions from Auxiliary Heater (g)'], self._input_data['fileOut3']: ['Month', 'Monthly Operational Costs of Heat Pumps (CAD)', @@ -158,9 +157,18 @@ class HeatPumpExport: for key, value in constants_dict.items(): self._input_data[key] = value # compute water to water HP specific values - if self._water_temp is not None: + if 55 <= self._input_data['HPSupTemp'] <= 60: self._input_data["HPDisactivationTemperature"] = self._input_data["HPSupTemp"] - 5 self._input_data["HPReactivationTemperature"] = self._input_data["HPSupTemp"] - 18 + elif 50 <= self._input_data["HPSupTemp"] < 55: + self._input_data["HPDisactivationTemperature"] = self._input_data["HPSupTemp"] - 5 + self._input_data["HPReactivationTemperature"] = self._input_data["HPSupTemp"] - 13 + elif 45 <= self._input_data["HPSupTemp"] < 50: + self._input_data["HPDisactivationTemperature"] = self._input_data["HPSupTemp"] - 3 + self._input_data["HPReactivationTemperature"] = self._input_data["HPSupTemp"] - 8 + elif 35 <= self._input_data["HPSupTemp"] < 40: + self._input_data["HPDisactivationTemperature"] = self._input_data["HPSupTemp"] - 2 + self._input_data["HPReactivationTemperature"] = self._input_data["HPSupTemp"] - 4 # compute maximum demand. TODO: This should come from catalog in the future max_demand = self._compute_max_demand() @@ -168,12 +176,11 @@ class HeatPumpExport: self._input_data["TESCapacity"] = self._input_data["HoursOfStorageAtMaxDemand"] * (max_demand * 3.6) / ( (self._input_data["Cp"] / 1000) * self._input_data["TemperatureDifference"]) - def _update_input_data_with_coff(self, a_coeff: List, b_coeff: List): + def _update_input_data_with_coff(self, a_coeff: List): """ Updates the user data with coefficients derived from imports :param a_coeff: insel a coefficient values - :param b_coeff: insel b coefficient values - Meaning of a and b are in the respective models for air source heat pump + Meaning of a is in the models for air source heat pump and water to water source heat pump :return: """ @@ -183,12 +190,6 @@ class HeatPumpExport: self._input_data["a4"] = a_coeff[3] self._input_data["a5"] = a_coeff[4] self._input_data["a6"] = a_coeff[5] - self._input_data["b1"] = b_coeff[0] - self._input_data["b2"] = b_coeff[1] - self._input_data["b3"] = b_coeff[2] - self._input_data["b4"] = b_coeff[3] - self._input_data["b5"] = b_coeff[4] - self._input_data["b6"] = b_coeff[5] # additional coefficients for water to water source if self._water_temp is not None: @@ -197,11 +198,6 @@ class HeatPumpExport: self._input_data["a9"] = a_coeff[8] self._input_data["a10"] = a_coeff[9] self._input_data["a11"] = a_coeff[10] - self._input_data["b7"] = b_coeff[6] - self._input_data["b8"] = b_coeff[7] - self._input_data["b9"] = b_coeff[8] - self._input_data["b10"] = b_coeff[9] - self._input_data["b11"] = b_coeff[10] def _get_user_out_put(self): """ diff --git a/imports/energy_systems/air_source_hp_parameters.py b/imports/energy_systems/air_source_hp_parameters.py index 7e62f1af..5c0334b0 100644 --- a/imports/energy_systems/air_source_hp_parameters.py +++ b/imports/energy_systems/air_source_hp_parameters.py @@ -76,12 +76,10 @@ class AirSourceHeatPumpParameters: c_data = self._extract_heat_pump_data(v_cool) heat_pump.cooling_capacity = c_data[0] heat_pump.cooling_comp_power = c_data[1] - heat_pump.cooling_capacity_coff = self._compute_coefficients(c_data[0], "cool") - heat_pump.cooling_comp_power_coff = self._compute_coefficients(c_data[1], "cool") + heat_pump.cooling_capacity_coff = self._compute_coefficients(c_data, "cool") heat_pump.heating_capacity = h_data[0] heat_pump.heating_comp_power = h_data[1] - heat_pump.heating_capacity_coff = self._compute_coefficients(h_data[0]) - heat_pump.heating_comp_power_coff = self._compute_coefficients(h_data[1]) + heat_pump.heating_capacity_coff = self._compute_coefficients(h_data) energy_system = EnergySystem('{} capacity heat pump'.format(heat_pump.model), 0, [], None) energy_system.air_source_hp = heat_pump @@ -123,10 +121,13 @@ class AirSourceHeatPumpParameters: 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)) + + hp_data = [i/j for i, j in + zip(list(itertools.chain.from_iterable(heat_pump_data[0])), + list(itertools.chain.from_iterable(heat_pump_data[1])))] # Compute heat output coefficients - popt, _ = curve_fit(self._objective_function, [x_values, out_temp], heat_pump_data) + popt, _ = curve_fit(self._objective_function, [x_values, out_temp], hp_data) return popt.tolist() def _objective_function(self, xdata: List, a1: float, a2: float, a3: float, a4: float, a5: float, a6: float) -> float: diff --git a/unittests/test_energy_systems_air_source_hp.py b/unittests/test_energy_systems_air_source_hp.py index b596f73a..ca9ab04e 100644 --- a/unittests/test_energy_systems_air_source_hp.py +++ b/unittests/test_energy_systems_air_source_hp.py @@ -52,7 +52,7 @@ class TestEnergySystemsFactory(TestCase): 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) + self.assertEqual(df.iloc[0, 1], 1867715.88) def tearDown(self) -> None: try: