Definition and visualization of a boreholeΒΆ

This example demonstrates the use of the borehole module to define the positions of pipes inside a borehole and visualize the top view of a borehole.

The following script generates boreholes with a single U-tube, a double U-tube (in series and parallel configurations), and a coaxial borehole. The borehole cross-sections are then plotted.

The script is located in: pygfunction/examples/custom_borehole.py

  1# -*- coding: utf-8 -*-
  2""" Example definition of a borehole. A top-view plot of the borehole is
  3    created and the borehole resistance is computed.
  4
  5"""
  6import numpy as np
  7from scipy.constants import pi
  8
  9import pygfunction as gt
 10
 11
 12def main():
 13    # -------------------------------------------------------------------------
 14    # Simulation parameters
 15    # -------------------------------------------------------------------------
 16
 17    # Borehole dimensions
 18    D = 5.          # Borehole buried depth (m)
 19    H = 400.        # Borehole length (m)
 20    r_b = 0.0875    # Borehole radius (m)
 21
 22    # Pipe dimensions (all configurations)
 23    epsilon = 1.0e-6    # Pipe roughness (m)
 24
 25    # Pipe dimensions (single U-tube and double U-tube)
 26    r_out = 0.0211      # Pipe outer radius (m)
 27    r_in = 0.0147       # Pipe inner radius (m)
 28    D_s = 0.052         # Shank spacing (m)
 29
 30    # Pipe dimensions (coaxial)
 31    r_in_in = 0.0221    # Inside pipe inner radius (m)
 32    r_in_out = 0.025    # Inside pipe outer radius (m)
 33    r_out_in = 0.0487   # Outer pipe inside radius (m)
 34    r_out_out = 0.055   # Outer pipe outside radius (m)
 35    # Vectors of inner and outer pipe radii
 36    # Note : The dimensions of the inlet pipe are the first elements of
 37    #        the vectors. In this example, the inlet pipe is the inside pipe.
 38    r_inner = np.array([r_in_in, r_out_in])     # Inner pipe radii (m)
 39    r_outer = np.array([r_in_out, r_out_out])   # Outer pip radii (m)
 40
 41    # Ground properties
 42    k_s = 2.0           # Ground thermal conductivity (W/m.K)
 43
 44    # Grout properties
 45    k_g = 1.0           # Grout thermal conductivity (W/m.K)
 46
 47    # Pipe properties
 48    k_p = 0.4           # Pipe thermal conductivity (W/m.K)
 49
 50    # Fluid properties
 51    # Total fluid mass flow rate per borehole (kg/s)
 52    m_flow_borehole = 1.0
 53    # The fluid is propylene-glycol (20 %) at 20 degC
 54    fluid = gt.media.Fluid('MPG', 20.)
 55    cp_f = fluid.cp     # Fluid specific isobaric heat capacity (J/kg.K)
 56    rho_f = fluid.rho   # Fluid density (kg/m3)
 57    mu_f = fluid.mu     # Fluid dynamic viscosity (kg/m.s)
 58    k_f = fluid.k       # Fluid thermal conductivity (W/m.K)
 59
 60    # -------------------------------------------------------------------------
 61    # Initialize borehole model
 62    # -------------------------------------------------------------------------
 63
 64    borehole = gt.boreholes.Borehole(H, D, r_b, x=0., y=0.)
 65
 66    # -------------------------------------------------------------------------
 67    # Define a single U-tube borehole
 68    # -------------------------------------------------------------------------
 69
 70    # Pipe positions
 71    # Single U-tube [(x_in, y_in), (x_out, y_out)]
 72    pos_single = [(-D_s, 0.), (D_s, 0.)]
 73
 74    # Pipe thermal resistance
 75    R_p = gt.pipes.conduction_thermal_resistance_circular_pipe(
 76        r_in, r_out, k_p)
 77
 78    # Fluid to inner pipe wall thermal resistance
 79    m_flow_pipe = m_flow_borehole
 80    h_f = gt.pipes.convective_heat_transfer_coefficient_circular_pipe(
 81        m_flow_pipe, r_in, mu_f, rho_f, k_f, cp_f, epsilon)
 82    R_f = 1.0 / (h_f * 2 * pi * r_in)
 83
 84    # Single U-tube GHE in borehole
 85    SingleUTube = gt.pipes.SingleUTube(
 86        pos_single, r_in, r_out, borehole, k_s, k_g, R_f + R_p)
 87
 88    # Check the geometry to make sure it is physically possible
 89
 90    # This class method is automatically called at the instanciation of the
 91    # pipe object and raises an error if the pipe geometry is invalid. It is
 92    # manually called here for demonstration.
 93    check_single = SingleUTube._check_geometry()
 94    print(f'The geometry of the borehole is valid (realistic/possible): '
 95          f'{check_single!s}.')
 96
 97    # Evaluate and print the effective borehole thermal resistance
 98    R_b = SingleUTube.effective_borehole_thermal_resistance(
 99        m_flow_borehole, fluid.cp)
100    print(f'Single U-tube Borehole thermal resistance: '
101          f'{R_b:.4f} m.K/W')
102
103    # Visualize the borehole geometry and save the figure
104    fig_single = SingleUTube.visualize_pipes()
105    fig_single.savefig('single-u-tube-borehole.png')
106
107    # -------------------------------------------------------------------------
108    # Define a double U-tube borehole
109    # -------------------------------------------------------------------------
110
111    # Pipe positions
112    # Double U-tube [(x_in1, y_in1), (x_in2, y_in2),
113    #                (x_out1, y_out1), (x_out2, y_out2)]
114    # Note: in series configuration, fluid enters pipe (in,1), exits (out,1),
115    # then enters (in,2) and finally exits (out,2)
116    # (if you view visualize_pipe, series is 1->3->2->4)
117    pos_double = [(-D_s, 0.), (0., -D_s), (D_s, 0.), (0., D_s)]
118
119    # Pipe thermal resistance
120    R_p = gt.pipes.conduction_thermal_resistance_circular_pipe(
121            r_in, r_out, k_p)
122
123    # Fluid to inner pipe wall thermal resistance
124    # Double U-tube in series
125    m_flow_pipe_series = m_flow_borehole
126    h_f_series = gt.pipes.convective_heat_transfer_coefficient_circular_pipe(
127        m_flow_pipe_series, r_in, mu_f, rho_f, k_f, cp_f, epsilon)
128    R_f_series = 1.0 / (h_f_series * 2 * pi * r_in)
129    # Double U-tube in parallel
130    m_flow_pipe_parallel = m_flow_borehole / 2
131    h_f_parallel = gt.pipes.convective_heat_transfer_coefficient_circular_pipe(
132        m_flow_pipe_parallel, r_in, mu_f, rho_f, k_f, cp_f, epsilon)
133    R_f_parallel = 1.0 / (h_f_parallel * 2 * pi * r_in)
134
135    # Double U-tube GHE in borehole
136    # Double U-tube in series
137    DoubleUTube_series = gt.pipes.MultipleUTube(
138        pos_double, r_in, r_out, borehole, k_s, k_g, R_p + R_f_series, 2,
139        config='series')
140    # Double U-tube in parallel
141    DoubleUTube_parallel = gt.pipes.MultipleUTube(
142        pos_double, r_in, r_out, borehole, k_s, k_g, R_p + R_f_parallel, 2,
143        config='parallel')
144
145    # Evaluate and print the effective borehole thermal resistance
146    R_b_series = DoubleUTube_series.effective_borehole_thermal_resistance(
147        m_flow_borehole, fluid.cp)
148    print(f'Double U-tube (series) Borehole thermal resistance: '
149          f'{R_b_series:.4f} m.K/W')
150    R_b_parallel = DoubleUTube_parallel.effective_borehole_thermal_resistance(
151        m_flow_borehole, fluid.cp)
152    print(f'Double U-tube (parallel) Borehole thermal resistance: '
153          f'{R_b_parallel:.4f} m.K/W')
154
155    # Visualize the borehole geometry and save the figure
156    fig_double = DoubleUTube_series.visualize_pipes()
157    fig_double.savefig('double-u-tube-borehole.png')
158
159    # -------------------------------------------------------------------------
160    # Define a coaxial borehole
161    # -------------------------------------------------------------------------
162
163    # Pipe positions
164    # Coaxial pipe (x, y)
165    pos = (0., 0.)
166
167    # Pipe thermal resistance
168    # (the two pipes have the same thermal conductivity, k_p)
169    # Inner pipe
170    R_p_in = gt.pipes.conduction_thermal_resistance_circular_pipe(
171        r_in_in, r_in_out, k_p)
172    # Outer pipe
173    R_p_out = gt.pipes.conduction_thermal_resistance_circular_pipe(
174        r_out_in, r_out_out, k_p)
175
176    # Fluid-to-fluid thermal resistance
177    # Inner pipe
178    h_f_in = gt.pipes.convective_heat_transfer_coefficient_circular_pipe(
179        m_flow_borehole, r_in_in, mu_f, rho_f, k_f, cp_f, epsilon)
180    R_f_in = 1.0 / (h_f_in * 2 * pi * r_in_in)
181    # Outer pipe
182    h_f_a_in, h_f_a_out = \
183        gt.pipes.convective_heat_transfer_coefficient_concentric_annulus(
184            m_flow_borehole, r_in_out, r_out_in, mu_f, rho_f, k_f, cp_f,
185            epsilon)
186    R_f_out_in = 1.0 / (h_f_a_in * 2 * pi * r_in_out)
187    R_ff = R_f_in + R_p_in + R_f_out_in
188
189    # Coaxial GHE in borehole
190    R_f_out_out = 1.0 / (h_f_a_out * 2 * pi * r_out_in)
191    R_fp = R_p_out + R_f_out_out
192    Coaxial = gt.pipes.Coaxial(
193        pos, r_inner, r_outer, borehole, k_s, k_g, R_ff, R_fp, J=2)
194
195    # Evaluate and print the effective borehole thermal resistance
196    R_b = Coaxial.effective_borehole_thermal_resistance(
197        m_flow_borehole, fluid.cp)
198    print(f'Coaxial tube Borehole thermal resistance: {R_b:.4f} m.K/W')
199
200    # Visualize the borehole geometry and save the figure
201    fig_coaxial = Coaxial.visualize_pipes()
202    fig_coaxial.savefig('coaxial-borehole.png')
203
204
205if __name__ == '__main__':
206    main()