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 matplotlib.pyplot as plt
11import numpy as np
12from time import perf_counter
13
14import pygfunction as gt
15
16
17def main():
18 # -------------------------------------------------------------------------
19 # Simulation parameters
20 # -------------------------------------------------------------------------
21
22 # Borehole dimensions
23 D = 4.0 # Borehole buried depth (m)
24 H = 150.0 # Borehole length (m)
25 r_b = 0.075 # Borehole radius (m)
26 B = 7.5 # Borehole spacing (m)
27
28 # Thermal properties
29 alpha = 1.0e-6 # Ground thermal diffusivity (m2/s)
30
31 # Path to validation data
32 filePath = './data/CiBe14_uniform_temperature.txt'
33
34 # g-Function calculation options
35 # A uniform discretization is used to compare results with Cimmino and
36 # Bernier (2014).
37 options = {'nSegments': 12,
38 'segment_ratios': None,
39 'disp': True,
40 'profiles': True}
41
42 # Geometrically expanding time vector.
43 dt = 100*3600. # Time step
44 tmax = 3000. * 8760. * 3600. # Maximum time
45 Nt = 25 # Number of time steps
46 ts = H**2/(9.*alpha) # Bore field characteristic time
47 time = gt.utilities.time_geometric(dt, tmax, Nt)
48 lntts = np.log(time/ts)
49
50 # -------------------------------------------------------------------------
51 # Borehole fields
52 # -------------------------------------------------------------------------
53
54 # Field of 3x2 (n=6) boreholes
55 N_1 = 3
56 N_2 = 2
57 boreField1 = gt.boreholes.rectangle_field(N_1, N_2, B, B, H, D, r_b)
58
59 # Field of 6x4 (n=24) boreholes
60 N_1 = 6
61 N_2 = 4
62 boreField2 = gt.boreholes.rectangle_field(N_1, N_2, B, B, H, D, r_b)
63
64 # Field of 10x10 (n=100) boreholes
65 N_1 = 10
66 N_2 = 10
67 boreField3 = gt.boreholes.rectangle_field(N_1, N_2, B, B, H, D, r_b)
68
69 # -------------------------------------------------------------------------
70 # Load data from Cimmino and Bernier (2014)
71 # -------------------------------------------------------------------------
72 data = np.loadtxt(filePath, skiprows=55)
73
74 # -------------------------------------------------------------------------
75 # Evaluate g-functions for all fields
76 # -------------------------------------------------------------------------
77 for i, field in enumerate([boreField1, boreField2, boreField3]):
78 nBoreholes = len(field)
79 # Compare 'similarities' and 'equivalent' solvers
80 t0 = perf_counter()
81 gfunc_similarities = gt.gfunction.gFunction(
82 field, alpha, time=time, options=options, method='similarities')
83 t1 = perf_counter()
84 t_similarities = t1 - t0
85 gfunc_equivalent = gt.gfunction.gFunction(
86 field, alpha, time=time, options=options, method='equivalent')
87 t2 = perf_counter()
88 t_equivalent = t2 - t1
89 # Draw g-function
90 ax = gfunc_similarities.visualize_g_function().axes[0]
91 ax.plot(lntts, gfunc_equivalent.gFunc)
92 # Draw reference g-function
93 ax.plot(data[:,0], data[:,i+1], 'o')
94 ax.legend([f'similarities (t = {t_similarities:.3f} sec)',
95 f'equivalent (t = {t_equivalent:.3f} sec)',
96 'Cimmino and Bernier (2014)'])
97 ax.set_title(f'Field of {nBoreholes} boreholes')
98 plt.tight_layout()
99
100 # For the second borefield, draw the evolution of heat extraction rates
101 if i == 1:
102 fig = gfunc_similarities.visualize_heat_extraction_rates(
103 iBoreholes=[18, 12, 14])
104 fig.suptitle(f"Field of {nBoreholes} boreholes: 'similarities' "
105 f"solver")
106 fig.tight_layout()
107
108 fig = gfunc_equivalent.visualize_heat_extraction_rates()
109 fig.suptitle(f"Field of {nBoreholes} boreholes: 'equivalent' "
110 f"solver")
111 fig.tight_layout()
112
113 fig = gfunc_similarities.visualize_heat_extraction_rate_profiles(
114 iBoreholes=[18, 12, 14])
115 fig.suptitle(f"Field of {nBoreholes} boreholes: 'similarities' "
116 f"solver")
117 fig.tight_layout()
118
119 fig = gfunc_equivalent.visualize_heat_extraction_rate_profiles()
120 fig.suptitle(f"Field of {nBoreholes} boreholes: 'equivalent' "
121 f"solver")
122 fig.tight_layout()
123
124 return
125
126
127# Main function
128if __name__ == '__main__':
129 main()
References
- 1
Cimmino, M., & Bernier, M. (2014). A semi-analytical method to generate g-functions for geothermal bore fields. International Journal of Heat and Mass Transfer, 70, 641-650.