Skip to content

Commit 8dffd74

Browse files
authored
Merge pull request #297 from wouterpeere/296-bug-in-temperature-calculation-when-using-active-cooling
Solves issue 296
2 parents 4d899a9 + dbc074a commit 8dffd74

File tree

7 files changed

+77
-13
lines changed

7 files changed

+77
-13
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
2020
- Added building laod classes (issue #288).
2121
- Added __eq__ method for Result and Efficiency classes (issue #288).
2222
- Added _time_array to building loads (issue #291).
23-
- Added EERCombined for combined active and passive cooling efficiency (issue #291).
23+
- Added EERCombined for combined active and passive cooling efficiency (issue #291, #296).
2424

2525
## Changed
2626

GHEtool/Borefield.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1725,6 +1725,7 @@ def calculate_difference(results_old: Union[ResultsMonthly, ResultsHourly],
17251725
results = calculate_temperatures(H, hourly=hourly)
17261726
i += 1
17271727
self.results = results
1728+
self.load.set_results(results)
17281729
return
17291730

17301731
self.results = calculate_temperatures(H, hourly=hourly)

GHEtool/VariableClasses/LoadData/Baseclasses/_HourlyDataBuilding.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -539,8 +539,7 @@ def max_peak_injection(self) -> float:
539539
-------
540540
max peak injection : float
541541
"""
542-
if isinstance(self._results, ResultsMonthly) and \
543-
(isinstance(self.cop, COP) or isinstance(self.eer, EER) or isinstance(self.cop_dhw, COP)):
542+
if isinstance(self._results, ResultsMonthly):
544543
return np.max(self.monthly_peak_injection_simulation_period)
545544
return np.max(self.hourly_injection_load_simulation_period)
546545

@@ -553,8 +552,7 @@ def max_peak_extraction(self) -> float:
553552
-------
554553
max peak extraction : float
555554
"""
556-
if isinstance(self._results, ResultsMonthly) and \
557-
(isinstance(self.cop, COP) or isinstance(self.eer, EER) or isinstance(self.cop_dhw, COP)):
555+
if isinstance(self._results, ResultsMonthly):
558556
return np.max(self.monthly_peak_extraction_simulation_period)
559557
return np.max(self.hourly_extraction_load_simulation_period)
560558

@@ -568,8 +566,7 @@ def imbalance(self) -> float:
568566
-------
569567
imbalance : float
570568
"""
571-
if isinstance(self._results, ResultsMonthly) and \
572-
(isinstance(self.cop, COP) or isinstance(self.eer, EER) or isinstance(self.cop_dhw, COP)):
569+
if isinstance(self._results, ResultsMonthly):
573570
return super(_HourlyData, self).imbalance
574571
return np.sum(
575572
self.hourly_injection_load_simulation_period - self.hourly_extraction_load_simulation_period) / self.simulation_period

GHEtool/test/methods/method_data.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,3 +560,28 @@
560560
borefield.load = hourly_load_building
561561
list_of_test_objects.add(SizingObject(borefield, L2_output=310.725, L3_output=310.725, L4_output=308.269, quadrant=4,
562562
name='BS2023 Swimming pool'))
563+
564+
eer_combined = EERCombined(20, 5, 10)
565+
borefield = Borefield()
566+
borefield.create_rectangular_borefield(3, 6, 6, 6, 146, 4)
567+
borefield.set_min_avg_fluid_temperature(3)
568+
borefield.set_max_avg_fluid_temperature(16)
569+
borefield.load.peak_duration = 6
570+
load = HourlyBuildingLoad(efficiency_heating=4, efficiency_cooling=eer_combined)
571+
# column order is inverted
572+
load.load_hourly_profile(FOLDER.joinpath("test\methods\hourly_data\hourly_profile.csv"), col_heating=1, col_cooling=0)
573+
load.simulation_period = 40
574+
borefield.load = load
575+
576+
borefield.set_ground_parameters(GroundTemperatureGradient(1.9, 10, gradient=2))
577+
borefield.set_fluid_parameters(FluidData(0.1, 0.475, 1033, 3930, 0.001))
578+
borefield.set_pipe_parameters(SingleUTube(1.5, 0.016, 0.02, 0.42, 0.04))
579+
list_of_test_objects.add(OptimiseLoadProfileObject(borefield, load, 146, 45.978137699335, 11.029080983424729,
580+
52.82586122830533, 28.00877268650213, 605.9817888622596,
581+
512.6954920945816,
582+
name='Optimise load profile (eer combined) (power)', power=True,
583+
hourly=False))
584+
list_of_test_objects.add(OptimiseLoadProfileObject(borefield, load, 146, 38.26289557407782, 4.071214268589431,
585+
75.9124206410309, 85.82220547000414, 630.8575050773479, 535.936136,
586+
name='Optimise load profile (eer combined) (energy)', power=False,
587+
hourly=False))

GHEtool/test/test_examples.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,15 @@ def test_sizing_with_building_load(monkeypatch):
5555
size_with_variable_ground_temperature, \
5656
size_with_part_load_data
5757
assert np.allclose(size_with_scop(), (96.5589765783911, 4.072466974615784))
58-
assert np.allclose(size_with_variable_ground_temperature(), (95.64066844079264, 4.17665670561309))
59-
assert np.allclose(size_with_part_load_data(), (98.1273127062551, 4.685121612513776))
58+
assert np.allclose(size_with_variable_ground_temperature(), (95.64070065017864, 4.134068939666393))
59+
assert np.allclose(size_with_part_load_data(), (98.12761463932304, 4.625123282444558))
6060

6161

6262
def test_sizing_with_building_load_hourly(monkeypatch):
6363
monkeypatch.setattr(plt, 'show', lambda: None)
6464
from GHEtool.Examples.sizing_with_building_load_hourly import L3_sizing, L4_sizing
65-
assert np.allclose(L3_sizing(), (127.05154931011464, 6.131588043404349))
66-
assert np.allclose(L4_sizing(), (153.26361812264668, 6.237959315069309))
65+
assert np.allclose(L3_sizing(), (127.05154931011464, 6.278577763617031))
66+
assert np.allclose(L4_sizing(), (153.26361812264668, 6.38069989008617))
6767

6868

6969
def test_combined_active_and_passive_cooling(monkeypatch):

GHEtool/test/unit-tests/test_main_class.py

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import pytest
88

99
from GHEtool import GroundConstantTemperature, GroundFluxTemperature, FluidData, DoubleUTube, Borefield, \
10-
CalculationSetup, FOLDER, MultipleUTube
10+
CalculationSetup, FOLDER, MultipleUTube, EERCombined
1111
from GHEtool.logger import ghe_logger
1212
from GHEtool.Validation.cases import load_case
1313
from GHEtool.VariableClasses.LoadData import MonthlyGeothermalLoadAbsolute, HourlyGeothermalLoad, HourlyBuildingLoad, \
@@ -521,6 +521,26 @@ def test_size_L4():
521521
assert borefield.calculate_quadrant() == 4
522522

523523

524+
def test_calculate_temperatures_eer_combined():
525+
eer_combined = EERCombined(20, 5, 17)
526+
borefield = Borefield()
527+
borefield.set_ground_parameters(ground_data_constant)
528+
load = HourlyBuildingLoad(efficiency_cooling=eer_combined)
529+
530+
borefield.borefield = copy.deepcopy(borefield_gt)
531+
load.load_hourly_profile(FOLDER.joinpath("Examples/hourly_profile.csv"))
532+
borefield.load = load
533+
borefield.calculate_temperatures(hourly=True)
534+
535+
active_cooling_array = borefield.load.eer.get_time_series_active_cooling(borefield.results.peak_injection,
536+
borefield.load.month_indices)
537+
assert np.allclose(borefield.load.hourly_cooling_load_simulation_period * active_cooling_array *
538+
(1 + 1 / 5) + borefield.load.hourly_cooling_load_simulation_period * np.invert(
539+
active_cooling_array) *
540+
(1 + 1 / 20),
541+
borefield.load.hourly_injection_load_simulation_period)
542+
543+
524544
def test_investment_cost():
525545
borefield = Borefield()
526546
borefield.borefield = copy.deepcopy(borefield_gt)
@@ -1086,3 +1106,24 @@ def test_deep_sizing(case, result):
10861106
def test_depreciation_warning():
10871107
with pytest.raises(DeprecationWarning):
10881108
Borefield(baseload_heating=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12])
1109+
1110+
1111+
def test_optimise_load_borefield():
1112+
load = HourlyBuildingLoad()
1113+
load.load_hourly_profile(FOLDER.joinpath("Examples/hourly_profile.csv"))
1114+
load.simulation_period = 10
1115+
borefield = Borefield(load=load)
1116+
borefield.set_min_avg_fluid_temperature(2)
1117+
borefield.set_max_avg_fluid_temperature(17)
1118+
borefield.borefield = gt.boreholes.rectangle_field(20, 4, 6, 6, 150, 1, 0.07)
1119+
borefield.Rb = 0.1699
1120+
ground_data = GroundFluxTemperature(2, 9.6, flux=0.07)
1121+
borefield.ground_data = ground_data
1122+
borefield_load, external_load = borefield.optimise_load_profile_energy(load)
1123+
assert np.isclose(borefield_load.imbalance, -228386.82055766508)
1124+
borefield.load = borefield_load
1125+
borefield.calculate_temperatures(hourly=False)
1126+
assert np.isclose(np.max(borefield.results.peak_injection), 17.044473901670603)
1127+
assert np.isclose(np.min(borefield.results.peak_extraction), 1.9471241454443655)
1128+
assert np.isclose(borefield.load.max_peak_cooling, 329.9393053)
1129+
assert np.isclose(np.sum(borefield.load.hourly_heating_load), 593385.1066074175)

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = GHEtool
3-
version = 2.3.0.dev5
3+
version = 2.3.0.dev6
44
author = Wouter Peere
55
author_email = wouter@ghetool.eu
66
description = Python package for borefield sizing

0 commit comments

Comments
 (0)