Deep sizing

 1"""
 2This file contains the reasoning behind the sizing method when the field is limited by injection (i.e. cooling)
 3and there is a non-constant ground temperature. This is based on the assumption that the difference between the
 4maximum peak temperature in injection and the average, undistrubed ground temperature scales like 1/depth.
 5
 6This can be understood since the main contributor to the peak temperature is the peak load, which, in the sizing,
 7is expressed as a load per meter (W/m), so it scales like 1/depth.
 8"""
 9
10from GHEtool import *
11import matplotlib.pyplot as plt
12import numpy as np
13from scipy.optimize import curve_fit
14
15
16def validate():
17    ground_data = GroundFluxTemperature(3, 10)
18    fluid_data = FluidData(0.2, 0.568, 998, 4180, 1e-3)
19    pipe_data = DoubleUTube(1, 0.015, 0.02, 0.4, 0.05)
20    borefield = Borefield()
21    borefield.create_rectangular_borefield(5, 4, 6, 6, 110, 4, 0.075)
22    borefield.set_ground_parameters(ground_data)
23    borefield.set_fluid_parameters(fluid_data)
24    borefield.set_pipe_parameters(pipe_data)
25    borefield.calculation_setup(use_constant_Rb=False)
26    borefield.set_max_avg_fluid_temperature(17)
27    borefield.set_min_avg_fluid_temperature(3)
28    hourly_load = HourlyGeothermalLoad()
29    hourly_load.load_hourly_profile(FOLDER.joinpath("test\methods\hourly_data\\auditorium.csv"), header=True, separator=";",
30                                  col_cooling=0, col_heating=1)
31    borefield.load = hourly_load
32
33    # initiate lists
34    Tg_list = []
35    max_Tf_list = []
36    depth_list = range(20, 450, 20)
37
38    for depth in depth_list:
39        print(f'The current depth is {depth} m.')
40        borefield.calculate_temperatures(depth)
41        Tg_list.append(borefield.ground_data.calculate_Tg(depth))
42        max_Tf_list.append(np.max(borefield.results.peak_cooling))
43
44    def f(x, a, b):
45        return a/x + b
46
47    # determine temperature difference between peak cooling temperature and ground temperature
48    diff = np.array(max_Tf_list) - np.array(Tg_list)
49
50    # fit to curve
51    popt, pcov = curve_fit(f, depth_list, diff)
52    print(popt, pcov)
53
54    plt.figure()
55    plt.plot(depth_list, Tg_list, label='Ground')
56    plt.plot(depth_list, max_Tf_list, label='Fluid')
57    plt.hlines(borefield.Tf_max, 0, depth_list[-1], label='Maximum temperature limit')
58    plt.xlabel('Depth [m]')
59    plt.ylabel('Temperature [deg C]')
60    plt.legend()
61    # plt.show()
62
63    plt.figure()
64    plt.plot(depth_list, diff, label='Actual calculated difference')
65    plt.plot(depth_list, f(np.array(depth_list), *popt), label='Fitted difference')
66    plt.xlabel('Depth [m]')
67    plt.ylabel('Temperature difference [deg C]')
68    plt.title('Temperature difference between maximum peak cooling fluid\ntemperature and undistrubed ground temperature')
69    plt.legend()
70    plt.show()
71
72
73if __name__ == "__main__":   # pragma: no cover
74    validate()