Skip to content

Commit

Permalink
- Change convergence criterium (relevant for active passive cooling)
Browse files Browse the repository at this point in the history
- Change default temperature in case of active/passive
  • Loading branch information
wouterpeere committed Sep 16, 2024
1 parent 37def9f commit 5fa4129
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions GHEtool/Borefield.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -1706,20 +1707,24 @@ 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)

# 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)
Expand Down

0 comments on commit 5fa4129

Please sign in to comment.