From 5fa4129d38acc01eddf5408af9420b248359c405 Mon Sep 17 00:00:00 2001 From: wouterpeere Date: Mon, 16 Sep 2024 17:11:18 +0200 Subject: [PATCH] - Change convergence criterium (relevant for active passive cooling) - Change default temperature in case of active/passive --- GHEtool/Borefield.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/GHEtool/Borefield.py b/GHEtool/Borefield.py index bfeec22b..a3a0b9cd 100644 --- a/GHEtool/Borefield.py +++ b/GHEtool/Borefield.py @@ -17,7 +17,8 @@ from scipy.signal import convolve from GHEtool.VariableClasses import FluidData, Borehole, GroundConstantTemperature, ResultsMonthly, ResultsHourly -from GHEtool.VariableClasses import CustomGFunction, load_custom_gfunction, GFunction, CalculationSetup, Cluster +from GHEtool.VariableClasses import CustomGFunction, load_custom_gfunction, GFunction, CalculationSetup, Cluster, \ + EERCombined from GHEtool.VariableClasses.LoadData import * from GHEtool.VariableClasses.LoadData import _LoadData, _LoadDataBuilding from GHEtool.VariableClasses.PipeData import _PipeData @@ -1706,12 +1707,16 @@ def calculate_temperatures(H, hourly=hourly): def calculate_difference(results_old: Union[ResultsMonthly, ResultsHourly], result_new: Union[ResultsMonthly, ResultsHourly]) -> float: return max( - np.max((result_new.peak_injection - results_old.peak_injection) / self.load.max_peak_injection), - np.max((result_new.peak_extraction - results_old.peak_extraction) / self.load.max_peak_extraction)) + np.max(result_new.peak_injection - results_old.peak_injection), + np.max(result_new.peak_extraction - results_old.peak_extraction)) if isinstance(self.load, _LoadDataBuilding): # when building load is given, the load should be updated after each temperature calculation. - self.load.reset_results(self.Tf_min, self.Tf_max) + # check if active_passive, because then, threshold should be taken + if isinstance(self.load.eer, EERCombined) and self.load.eer.threshold_temperature is not None: + self.load.reset_results(self.Tf_min, self.load.eer.threshold_temperature) + else: + self.load.reset_results(self.Tf_min, self.Tf_max) results_old = calculate_temperatures(H, hourly=hourly) self.load.set_results(results_old) results = calculate_temperatures(H, hourly=hourly) @@ -1719,7 +1724,7 @@ def calculate_difference(results_old: Union[ResultsMonthly, ResultsHourly], # safety i = 0 while calculate_difference(results_old, - results) > 0.01 and i < self._calculation_setup.max_nb_of_iterations: + results) > self._calculation_setup.atol and i < self._calculation_setup.max_nb_of_iterations: results_old = results self.load.set_results(results) results = calculate_temperatures(H, hourly=hourly)