Calculation of g-functions with unequal numbers of segmentsΒΆ

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 discretization along three of the boreholes is refined for the calculation of the g-function and to draw the heat extraction rate profiles along their lengths.

The following script generates the g-functions of a rectangular field of 6 x 4. g-Functions using equal and unequal numbers of segments are compared.

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

  1# -*- coding: utf-8 -*-
  2""" Example of calculation of g-functions with varied declaration of segments
  3    using uniform borehole wall temperature.
  4
  5    The g-functions of a field of 6x4 boreholes is calculated with unequal
  6    number of segments.
  7"""
  8import matplotlib.pyplot as plt
  9from matplotlib.ticker import AutoMinorLocator
 10import numpy as np
 11
 12import pygfunction as gt
 13
 14
 15def main():
 16    # -------------------------------------------------------------------------
 17    # Simulation parameters
 18    # -------------------------------------------------------------------------
 19
 20    # Borehole dimensions
 21    D = 4.0             # Borehole buried depth (m)
 22    H = 150.0           # Borehole length (m)
 23    r_b = 0.075         # Borehole radius (m)
 24    B = 7.5             # Borehole spacing (m)
 25
 26    # Thermal properties
 27    alpha = 1.0e-6      # Ground thermal diffusivity (m2/s)
 28
 29    # Geometrically expanding time vector.
 30    dt = 100*3600.                  # Time step
 31    tmax = 3000. * 8760. * 3600.    # Maximum time
 32    Nt = 25                         # Number of time steps
 33    ts = H**2/(9.*alpha)            # Bore field characteristic time
 34    time = gt.utilities.time_geometric(dt, tmax, Nt)
 35
 36    # -------------------------------------------------------------------------
 37    # Borehole field
 38    # -------------------------------------------------------------------------
 39
 40    # Field of 6x4 (n=24) boreholes
 41    N_1 = 6
 42    N_2 = 4
 43    boreField = gt.boreholes.rectangle_field(N_1, N_2, B, B, H, D, r_b)
 44    gt.boreholes.visualize_field(boreField)
 45
 46    # -------------------------------------------------------------------------
 47    # Evaluate g-functions with different segment options
 48    # -------------------------------------------------------------------------
 49
 50    # The 'similarities' method is used to consider unequal numbers of segments
 51    # per borehole and to plot heat extraction rate profiles along
 52    # individual boreholes
 53    method = 'similarities'
 54
 55    # Calculate g-function with equal number of segments for all boreholes and
 56    # uniform segment lengths
 57    nSegments = 24
 58    options = {'nSegments': nSegments,
 59               'segment_ratios': None,
 60               'disp': True}
 61
 62    gfunc_equal = gt.gfunction.gFunction(
 63        boreField, alpha, time=time, options=options, method=method)
 64
 65    # Calculate g-function with predefined number of segments for each
 66    # borehole, the segment lengths will be uniform along each borehole, but
 67    # the number of segments for the boreholes can be unequal.
 68
 69    # Boreholes 12, 14 and 18 have more segments than the others and their
 70    # heat extraction rate profiles are plotted.
 71    nSegments = [12] * len(boreField)
 72    nSegments[12] = 24
 73    nSegments[14] = 24
 74    nSegments[18] = 24
 75    options = {'nSegments': nSegments,
 76               'segment_ratios': None,
 77               'disp': True,
 78               'profiles': True}
 79
 80    gfunc_unequal = gt.gfunction.gFunction(
 81        boreField, alpha, time=time, options=options, method=method)
 82
 83    # Calculate g-function with equal number of segments for each borehole,
 84    # unequal segment lengths along the length of the borehole defined by
 85    # segment ratios. The segment ratios for each borehole are the same.
 86
 87    nSegments = 8
 88    # Define the segment ratios for each borehole in each segment
 89    # the segment lengths are defined top to bottom left to right
 90    segment_ratios = np.array([0.05, 0.10, 0.10, 0.25, 0.25, 0.10, 0.10, 0.05])
 91    options = {'nSegments': nSegments,
 92               'segment_ratios': segment_ratios,
 93               'disp': True,
 94               'profiles': True}
 95
 96    g_func_predefined = gt.gfunction.gFunction(
 97        boreField, alpha, time=time, options=options, method=method)
 98
 99    # -------------------------------------------------------------------------
100    # Plot g-functions
101    # -------------------------------------------------------------------------
102
103    ax = gfunc_equal.visualize_g_function().axes[0]
104    ax.plot(np.log(time/ts), gfunc_unequal.gFunc, 'r-.')
105    ax.plot(np.log(time/ts), g_func_predefined.gFunc, 'k-.')
106    ax.legend(['Equal number of segments',
107               'Unequal number of segments',
108               'Unequal segment lengths'])
109    plt.tight_layout()
110
111    # Heat extraction rate profiles
112    fig = gfunc_unequal.visualize_heat_extraction_rates(
113        iBoreholes=[18, 12, 14])
114    fig.suptitle('Heat extraction rates (unequal number of segments)')
115    fig.tight_layout()
116    fig = g_func_predefined.visualize_heat_extraction_rates(
117        iBoreholes=[18, 12, 14])
118    fig.suptitle('Heat extraction rates (unequal segment lengths)')
119    fig.tight_layout()
120    fig = gfunc_unequal.visualize_heat_extraction_rate_profiles(
121        iBoreholes=[18, 12, 14])
122    fig.suptitle('Heat extraction rate profiles (unequal number of segments)')
123    fig.tight_layout()
124    fig = g_func_predefined.visualize_heat_extraction_rate_profiles(
125        iBoreholes=[18, 12, 14])
126    fig.suptitle('Heat extraction rate profiles (unequal segment lengths)')
127    fig.tight_layout()
128
129    return
130
131
132# Main function
133if __name__ == '__main__':
134    main()