Evaluation of thermal resistances using the multipole methodΒΆ
This example demonstrates the use of the
pipes.thermal_resistances() function to
evaluate internal thermal resistances in a borehole. The example also covers the
use of the pipes.multipole() function to evaluate the
2D temperature field in and around a borehole.
The thermal resistances of a borehole with two pipes are evaluated using the multipole method of Claesson and Hellstrom [1]. Based on the calculated thermal resistances, the heat flows from the pipes required to obtain pipe temperatures of 1 degC are evaluated. The temperatures in and around the borehole with 2 pipes are then calculated. Results are verified against the results of Claesson and Hellstrom [1].
The script is located in: pygfunction/examples/multipole_temperature.py
1# -*- coding: utf-8 -*-
2""" Example of calculation of grout and ground temperatures using the multipole
3 method.
4
5 The thermal resistances of a borehole with two pipes are evaluated using
6 the multipole method of Claesson and Hellstrom (2011). Based on the
7 calculated thermal resistances, the heat flows from the pipes required to
8 obtain pipe temperatures of 1 degC are evaluated. The temperatures in and
9 around the borehole with 2 pipes are then calculated. Results are verified
10 against the results of Claesson and Hellstrom (2011).
11
12"""
13import os
14
15import matplotlib.pyplot as plt
16import numpy as np
17
18import pygfunction as gt
19
20
21def main():
22 # -------------------------------------------------------------------------
23 # Simulation parameters
24 # -------------------------------------------------------------------------
25
26 # Borehole dimensions
27 r_b = 0.070 # Borehole radius (m)
28
29 # Pipe dimensions
30 n_p = 2 # Number of pipes
31 # Pipe outer radius (m)
32 rp_out = 0.02*np.ones(n_p)
33
34 # Pipe positions
35 # Single U-tube [(x_1, y_1), (x_2, y_2)]
36 pos_pipes = [(0.03, 0.00), (-0.03, 0.02)]
37
38 # Ground properties
39 k_s = 2.5 # Ground thermal conductivity (W/m.K)
40
41 # Grout properties
42 k_g = 1.5 # Grout thermal conductivity (W/m.K)
43
44 # Fluid properties
45 # Fluid to outer pipe wall thermal resistance (m.K/W)
46 R_fp = 1.2 / (2 * np.pi * k_g) * np.ones(n_p)
47
48 # Borehole wall temperature (degC)
49 T_b = 0.0
50
51 # Fluid temperatures (degC)
52 T_f = np.array([1., 1.])
53
54 # Path to validation data
55 base_dir = os.path.dirname(os.path.abspath(__file__))
56 file_path = os.path.join(base_dir, 'data', 'ClaHel11_multipole_temperature.txt')
57
58 # Thermal resistances for J=3
59 R_Claesson = 0.01*np.array([25.592, 1.561, 25.311])
60
61 # Number of multipoles per pipe
62 J = 3
63
64 # -------------------------------------------------------------------------
65 # Evaluate the internal thermal resistances
66 # -------------------------------------------------------------------------
67
68 # Thermal resistances
69 (R, Rd) = gt.pipes.thermal_resistances(pos_pipes, rp_out, r_b, k_s, k_g,
70 R_fp, J=3)
71 print(50*'-')
72 print('Thermal resistance:\t\t100*R11\t100*R12\t100*R22')
73 print(f'Claesson and Hellstrom:\t{100*R_Claesson[0]:.3f}'
74 f'\t{100*R_Claesson[1]:.3f}\t{100*R_Claesson[2]:.3f}')
75 print(f'Present:\t\t\t\t{100*R[0,0]:.3f}\t{100*R[0,1]:.3f}'
76 f'\t{100*R[1,1]:.3f}')
77 print(50*'-')
78
79 # Heat flows
80 Q = np.linalg.solve(R, T_f - T_b)
81
82 # -------------------------------------------------------------------------
83 # Temperatures along y=0.
84 # -------------------------------------------------------------------------
85
86 # Grid points to evaluate temperatures
87 x = np.linspace(-0.1, 0.1, num=200)
88 y = np.zeros_like(x)
89
90 # Evaluate temperatures using multipole method
91 (T_f, T, it, eps_max) = gt.pipes.multipole(pos_pipes, rp_out, r_b, k_s,
92 k_g, R_fp, T_b, Q, J,
93 x_T=x, y_T=y)
94
95 # Load validation data
96 data = np.loadtxt(file_path, skiprows=1)
97
98 # Configure figure and axes
99 fig = gt.utilities._initialize_figure()
100
101 ax1 = fig.add_subplot(111)
102 # Axis labels
103 ax1.set_xlabel(r'x (m)')
104 ax1.set_ylabel(r'$T(x,0)$')
105 # Axis limits
106 ax1.set_xlim([-0.1, 0.1])
107 ax1.set_ylim([-0.2, 1.2])
108 # Show grid
109 ax1.grid()
110 gt.utilities._format_axes(ax1)
111
112 ax1.plot(x, T, label='pygfunction')
113 ax1.plot(data[:,0], data[:,1], 'ko',
114 label='Claesson and Hellstrom (2011)')
115 ax1.legend(loc='upper left')
116
117 # Adjust to plot window
118 plt.tight_layout()
119
120 # -------------------------------------------------------------------------
121 # Temperatures in -0.1 < x < 0.1, -0.1 < y < 0.1
122 # -------------------------------------------------------------------------
123
124 # Grid points to evaluate temperatures
125 N_xy = 200
126 x = np.linspace(-0.1, 0.1, num=N_xy)
127 y = np.linspace(-0.1, 0.1, num=N_xy)
128 X, Y = np.meshgrid(x, y)
129
130 # Evaluate temperatures using multipole method
131 (T_f, T, it, eps_max) = gt.pipes.multipole(pos_pipes, rp_out, r_b, k_s,
132 k_g, R_fp, T_b, Q, J,
133 x_T=X.flatten(),
134 y_T=Y.flatten())
135
136 # Configure figure and axes
137 fig = gt.utilities._initialize_figure()
138
139 ax1 = fig.add_subplot(111)
140 # Axis labels
141 ax1.set_xlabel('x (m)')
142 ax1.set_ylabel('y (m)')
143 # Axis limits
144 plt.axis([-0.1, 0.1, -0.1, 0.1])
145 plt.gca().set_aspect('equal', adjustable='box')
146 gt.utilities._format_axes(ax1)
147
148 # Borehole wall outline
149 borewall = plt.Circle((0., 0.), radius=r_b,
150 fill=False, linestyle='--', linewidth=2.)
151 ax1.add_patch(borewall)
152 # Pipe outlines
153 for pos, r_out_n in zip(pos_pipes, rp_out):
154 pipe = plt.Circle(pos, radius=r_out_n,
155 fill=False, linestyle='-', linewidth=4.)
156 ax1.add_patch(pipe)
157 # Temperature contours
158 CS = ax1.contour(X, Y, T.reshape((N_xy, N_xy)),
159 np.linspace(-0.2, 1.0, num=7))
160 plt.clabel(CS, inline=1, fontsize=10)
161
162 # Adjust to plot window
163 plt.tight_layout()
164
165 return
166
167
168# Main function
169if __name__ == '__main__':
170 main()
References