Calculation of g-functions with uniform borehole wall temperatureΒΆ
This example demonstrates the use of the g-function module to calculate g-functions using a boundary condition of uniform and equal borehole wall temperature for all boreholes. The total rate of heat extraction in the bore field is constant.
The following script generates the g-functions of rectangular fields of 3 x 2, 6 x 4 and 10 x 10 boreholes. g-Functions are verified against the g-functions presented by Cimmino and Bernier [1].
The script is located in: pygfunction/examples/uniform_temperature.py
1# -*- coding: utf-8 -*-
2""" Example of calculation of g-functions using uniform and equal borehole
3 wall temperatures.
4
5 The g-functions of fields of 3x2, 6x4 and 10x10 boreholes are calculated
6 for boundary condition of uniform borehole wall temperature along the
7 boreholes, equal for all boreholes.
8
9"""
10import os
11
12import matplotlib.pyplot as plt
13import numpy as np
14from time import perf_counter
15
16import pygfunction as gt
17
18
19def main():
20 # -------------------------------------------------------------------------
21 # Simulation parameters
22 # -------------------------------------------------------------------------
23
24 # Borehole dimensions
25 D = 4.0 # Borehole buried depth (m)
26 H = 150.0 # Borehole length (m)
27 r_b = 0.075 # Borehole radius (m)
28 B = 7.5 # Borehole spacing (m)
29
30 # Thermal properties
31 alpha = 1.0e-6 # Ground thermal diffusivity (m2/s)
32
33 # Path to validation data
34 base_dir = os.path.dirname(os.path.abspath(__file__))
35 file_path = os.path.join(base_dir, 'data', 'CiBe14_uniform_temperature.txt')
36
37 # g-Function calculation options
38 # A uniform discretization is used to compare results with Cimmino and
39 # Bernier (2014).
40 options = {'nSegments': 12,
41 'segment_ratios': None,
42 'disp': True,
43 'profiles': True}
44
45 # Geometrically expanding time vector.
46 dt = 100*3600. # Time step
47 tmax = 3000. * 8760. * 3600. # Maximum time
48 Nt = 25 # Number of time steps
49 ts = H**2/(9.*alpha) # Bore field characteristic time
50 time = gt.utilities.time_geometric(dt, tmax, Nt)
51 lntts = np.log(time/ts)
52
53 # -------------------------------------------------------------------------
54 # Borehole fields
55 # -------------------------------------------------------------------------
56
57 # Field of 3x2 (n=6) boreholes
58 N_1 = 3
59 N_2 = 2
60 borefield1 = gt.borefield.Borefield.rectangle_field(
61 N_1, N_2, B, B, H, D, r_b)
62
63 # Field of 6x4 (n=24) boreholes
64 N_1 = 6
65 N_2 = 4
66 borefield2 = gt.borefield.Borefield.rectangle_field(
67 N_1, N_2, B, B, H, D, r_b)
68
69 # Field of 10x10 (n=100) boreholes
70 N_1 = 10
71 N_2 = 10
72 borefield3 = gt.borefield.Borefield.rectangle_field(
73 N_1, N_2, B, B, H, D, r_b)
74
75 # -------------------------------------------------------------------------
76 # Load data from Cimmino and Bernier (2014)
77 # -------------------------------------------------------------------------
78 data = np.loadtxt(file_path, skiprows=55)
79
80 # -------------------------------------------------------------------------
81 # Evaluate g-functions for all fields
82 # -------------------------------------------------------------------------
83 for i, field in enumerate([borefield1, borefield2, borefield3]):
84 nBoreholes = len(field)
85 # Compare 'similarities' and 'equivalent' solvers
86 t0 = perf_counter()
87 gfunc_similarities = gt.gfunction.gFunction(
88 field, alpha, time=time, options=options, method='similarities')
89 t1 = perf_counter()
90 t_similarities = t1 - t0
91 gfunc_equivalent = gt.gfunction.gFunction(
92 field, alpha, time=time, options=options, method='equivalent')
93 t2 = perf_counter()
94 t_equivalent = t2 - t1
95 # Draw g-function
96 ax = gfunc_similarities.visualize_g_function().axes[0]
97 ax.plot(lntts, gfunc_equivalent.gFunc)
98 # Draw reference g-function
99 ax.plot(data[:,0], data[:,i+1], 'o')
100 ax.legend([f'similarities (t = {t_similarities:.3f} sec)',
101 f'equivalent (t = {t_equivalent:.3f} sec)',
102 'Cimmino and Bernier (2014)'])
103 ax.set_title(f'Field of {nBoreholes} boreholes')
104 plt.tight_layout()
105
106 # For the second borefield, draw the evolution of heat extraction rates
107 if i == 1:
108 fig = gfunc_similarities.visualize_heat_extraction_rates(
109 iBoreholes=[18, 12, 14])
110 fig.suptitle(f"Field of {nBoreholes} boreholes: 'similarities' "
111 f"solver")
112 fig.tight_layout()
113
114 fig = gfunc_equivalent.visualize_heat_extraction_rates()
115 fig.suptitle(f"Field of {nBoreholes} boreholes: 'equivalent' "
116 f"solver")
117 fig.tight_layout()
118
119 fig = gfunc_similarities.visualize_heat_extraction_rate_profiles(
120 iBoreholes=[18, 12, 14])
121 fig.suptitle(f"Field of {nBoreholes} boreholes: 'similarities' "
122 f"solver")
123 fig.tight_layout()
124
125 fig = gfunc_equivalent.visualize_heat_extraction_rate_profiles()
126 fig.suptitle(f"Field of {nBoreholes} boreholes: 'equivalent' "
127 f"solver")
128 fig.tight_layout()
129
130 return
131
132
133# Main function
134if __name__ == '__main__':
135 main()
References