1"""
2This document compares the speed of the L2 sizing method of (Peere et al., 2021) with and without the precalculated gfunction data.
3This is done for two fields with different sizes. It shows that, specifically for the larger fields, the precalculated data is way faster.
4"""
5
6import time
7
8import pygfunction as gt
9
10from GHEtool import Borefield, GroundConstantTemperature, MonthlyGeothermalLoadAbsolute
11
12
13def test_64_boreholes():
14 data = GroundConstantTemperature(3, 10)
15 borefield_64 = gt.boreholes.rectangle_field(8, 8, 6, 6, 110, 1, 0.075)
16
17 # monthly loading values
18 peak_cooling = [0., 0, 34., 69., 133., 187., 213., 240., 160., 37., 0., 0.] # Peak cooling in kW
19 peak_heating = [160., 142, 102., 55., 0., 0., 0., 0., 40.4, 85., 119., 136.] # Peak heating in kW
20
21 # annual heating and cooling load
22 annual_heating_load = 300 * 10 ** 3 # kWh
23 annual_cooling_load = 160 * 10 ** 3 # kWh
24
25 # percentage of annual load per month (15.5% for January ...)
26 monthly_load_heating_percentage = [0.155, 0.148, 0.125, .099, .064, 0., 0., 0., 0.061, 0.087, 0.117, 0.144]
27 monthly_load_cooling_percentage = [0.025, 0.05, 0.05, .05, .075, .1, .2, .2, .1, .075, .05, .025]
28
29 # resulting load per month
30 monthly_load_heating = list(map(lambda x: x * annual_heating_load, monthly_load_heating_percentage)) # kWh
31 monthly_load_cooling = list(map(lambda x: x * annual_cooling_load, monthly_load_cooling_percentage)) # kWh
32
33 # set the load
34 load = MonthlyGeothermalLoadAbsolute(monthly_load_heating, monthly_load_cooling, peak_heating, peak_cooling)
35
36 # create the borefield object
37 borefield = Borefield(load=load)
38
39 borefield.set_ground_parameters(data)
40 borefield.set_borefield(borefield_64)
41 borefield.Rb = 0.2
42
43 # set temperature boundaries
44 borefield.set_max_avg_fluid_temperature(16) # maximum temperature
45 borefield.set_min_avg_fluid_temperature(0) # minimum temperature
46
47 # precalculate
48 borefield.create_custom_dataset()
49
50 # size borefield
51 t1 = time.time()
52 depth_precalculated = borefield.size()
53 t1_end = time.time()
54
55 # delete precalculated data
56 borefield.custom_gfunction.delete_custom_gfunction()
57
58 ### size without the precalculation
59 t2 = time.time()
60 depth_calculated = borefield.size()
61 t2_end = time.time()
62
63 print("With precalculated data, the sizing took", round(t1_end - t1, 3), "s for 64 boreholes.")
64 print("Without the precalculated data, the sizing took", round(t2_end - t2, 3), "s for 64 boreholes.")
65 print("The difference in accuracy between the two results is",
66 round((depth_calculated - depth_precalculated) / depth_calculated * 100, 3), "%.")
67
68
69def test_10_boreholes():
70 data = GroundConstantTemperature(3, 10)
71 borefield_10 = gt.boreholes.rectangle_field(2, 5, 6, 6, 110, 1, 0.075)
72
73 # monthly loading values
74 peak_cooling = [0., 0, 3., 9., 13., 20., 43., 30., 16., 7., 0., 0.] # Peak cooling in kW
75 peak_heating = [16., 14, 10., 5., 0., 0., 0., 0., 4, 8., 19., 13.] # Peak heating in kW
76
77 # annual heating and cooling load
78 annual_heating_load = 16 * 10 ** 3 # kWh
79 annual_cooling_load = 24 * 10 ** 3 # kWh
80
81 # percentage of annual load per month (15.5% for January ...)
82 monthly_heating_load_percentage = [0.155, 0.148, 0.125, .099, .064, 0., 0., 0., 0.061, 0.087, 0.117, 0.144]
83 monthly_load_cooling_percentage = [0.025, 0.05, 0.05, .05, .075, .1, .2, .2, .1, .075, .05, .025]
84
85 # resulting load per month
86 monthly_load_heating = list(map(lambda x: x * annual_heating_load, monthly_heating_load_percentage)) # kWh
87 monthly_load_cooling = list(map(lambda x: x * annual_cooling_load, monthly_load_cooling_percentage)) # kWh
88
89 # set the load
90 load = MonthlyGeothermalLoadAbsolute(monthly_load_heating, monthly_load_cooling, peak_heating, peak_cooling)
91
92 # create the borefield object
93 borefield = Borefield(load=load)
94
95 borefield.set_ground_parameters(data)
96 borefield.set_borefield(borefield_10)
97 borefield.Rb = 0.2
98
99 # set temperature boundaries
100 borefield.set_max_avg_fluid_temperature(16) # maximum temperature
101 borefield.set_min_avg_fluid_temperature(0) # minimum temperature
102
103 # precalculate
104 borefield.create_custom_dataset()
105
106 # size borefield
107 t1 = time.time()
108 depth_precalculated = borefield.size()
109 t1_end = time.time()
110
111 # delete precalculated data
112 borefield.custom_gfunction.delete_custom_gfunction()
113
114 ### size without the precalculation
115 t2 = time.time()
116 depth_calculated = borefield.size()
117 t2_end = time.time()
118
119 print("With precalculated data, the sizing took", round(t1_end - t1, 3), "s for 10 boreholes.")
120 print("Without the precalculated data, the sizing took", round(t2_end - t2, 3), "s for 10 boreholes.")
121 print("The difference in accuracy between the two results is",
122 round((depth_calculated-depth_precalculated) / depth_calculated * 100, 3), "%.\n")
123
124
125if __name__ == "__main__": # pragma: no cover
126
127 test_10_boreholes()
128 test_64_boreholes()