1"""
2This file gives an example on how to work with a custom borefield within GHEtool using pygfunction.
3
4When working on a custom borefield configuration, one needs to import this configuration into the GHEtool.
5Based on the pygfunction, one creates his custom borefield and gives it as an argument to the class initiater Borefield of GHEtool.
6
7You also need a custom g-function file for interpolation. This can also be given as an argument to the class initiater as _custom_gfunction.
8This custom variable, must contain gfunctions for all time steps in Borefield.DEFAULT_TIME_ARRAY, and should be structured as follows:
9{"Time":Borefield.DEFAULT_TIME_ARRAY,"Data":[[Depth1,[Gfunc1,Gfunc2 ...]],[Depth2,[Gfunc1, Gfunc2 ...]]]}.
10
11However, one can use the function 'create_custom_dataset' when a custom borefield is given. This will make the required dataset for the optimisation.
12 """
13
14import numpy as np
15import pygfunction as gt
16
17# import all the relevant functions
18from GHEtool import *
19
20
21def custom_borefield_configuration():
22 # set the relevant ground data for the calculations
23 data = GroundConstantTemperature(3, 10)
24
25 # Monthly loading values
26 peak_cooling = np.array([0., 0, 3.4, 6.9, 13., 18., 21., 50., 16., 3.7, 0., 0.]) # Peak cooling in kW
27 peak_heating = np.array([60., 42., 10., 5., 0., 0., 0., 0., 4.4, 8.5, 19., 36.]) # Peak heating in kW
28
29 # annual heating and cooling load
30 annual_heating_load = 30 * 10 ** 3 # kWh
31 annual_cooling_load = 16 * 10 ** 3 # kWh
32
33 # percentage of annual load per month (15.5% for January ...)
34 monthly_load_heating_percentage = np.array([0.155, 0.148, 0.125, .099, .064, 0., 0., 0., 0.061, 0.087, 0.117, 0.144])
35 monthly_load_cooling_percentage = np.array([0.025, 0.05, 0.05, .05, .075, .1, .2, .2, .1, .075, .05, .025])
36
37 # resulting load per month
38 monthly_load_heating = annual_heating_load * monthly_load_heating_percentage # kWh
39 monthly_load_cooling = annual_cooling_load * monthly_load_cooling_percentage # kWh
40
41 # set the load
42 load = MonthlyGeothermalLoadAbsolute(monthly_load_heating, monthly_load_cooling, peak_heating, peak_cooling)
43
44 # create the borefield object
45 borefield = Borefield(load=load)
46
47 borefield.set_ground_parameters(data)
48 borefield.Rb = 0.2
49
50 # set temperature boundaries
51 borefield.set_max_avg_fluid_temperature(16) # maximum temperature
52 borefield.set_min_avg_fluid_temperature(0) # minimum temperature
53
54 # create custom borefield based on pygfunction
55 custom_field = gt.boreholes.L_shaped_field(N_1=4, N_2=5, B_1=5., B_2=5., H=100., D=4, r_b=0.05)
56
57 # set the custom borefield (so the number of boreholes is correct)
58 borefield.set_borefield(custom_field)
59 borefield.create_custom_dataset()
60
61 # size borefield
62 depth = borefield.size()
63 print("The borehole depth is: ", depth, "m")
64
65 # print imbalance
66 print("The borefield imbalance is: ", borefield.load.imbalance, "kWh/y. (A negative imbalance means the the field is heat extraction dominated so it cools down year after year.)") # print imbalance
67
68 # plot temperature profile for the calculated depth
69 borefield.print_temperature_profile(legend=True)
70
71 # plot temperature profile for a fixed depth
72 borefield.print_temperature_profile_fixed_depth(depth=75, legend=False)
73
74 # print gives the array of monthly temperatures for peak cooling without showing the plot
75 borefield.calculate_temperatures(depth=90)
76 print("Result array for cooling peaks")
77 print(borefield.results.peak_cooling)
78
79
80if __name__ == "__main__": # pragma: no cover
81 custom_borefield_configuration()