Calculation of g-functions with uniform borehole heat extraction ratesΒΆ

This example demonstrates the use of the g-function module to calculate g-functions using a boundary condition of uniform and equal heat extraction rate for all boreholes, constant in time.

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_heat_extraction_rate.py

  1# -*- coding: utf-8 -*-
  2""" Example of calculation of g-functions using uniform heat extraction rates.
  3
  4    The g-functions of fields of 3x2, 6x4 and 10x10 boreholes are calculated
  5    for boundary condition of uniform heat extraction rate along the boreholes,
  6    equal for all boreholes.
  7
  8"""
  9import os
 10
 11import matplotlib.pyplot as plt
 12import numpy as np
 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    base_dir = os.path.dirname(os.path.abspath(__file__))
 33    file_path = os.path.join(base_dir, 'data', 'CiBe14_uniform_heat_extraction_rate.txt')
 34
 35    # g-Function calculation options
 36    # The second field is evaluated with more segments to draw the
 37    # temperature profiles. A uniform discretization is used to compare results
 38    # with Cimmino and Bernier (2014).
 39    options = [{'nSegments': 1,
 40                'segment_ratios': None,
 41                'disp': True,
 42                'profiles': True},
 43               {'nSegments': 12,
 44                'segment_ratios': None,
 45                'disp': True,
 46                'profiles': True},
 47               {'nSegments': 1,
 48                'segment_ratios': None,
 49                'disp': True,
 50                'profiles': True}]
 51
 52    # The 'similarities' method is used to consider unequal numbers of segments
 53    # per borehole and to plot heat extraction rate profiles along
 54    # individual boreholes
 55    method = 'similarities'
 56
 57    # Geometrically expanding time vector.
 58    dt = 100*3600.                  # Time step
 59    tmax = 3000. * 8760. * 3600.    # Maximum time
 60    Nt = 25                         # Number of time steps
 61    ts = H**2/(9.*alpha)            # Bore field characteristic time
 62    time = gt.utilities.time_geometric(dt, tmax, Nt)
 63
 64    # -------------------------------------------------------------------------
 65    # Borehole fields
 66    # -------------------------------------------------------------------------
 67
 68    # Field of 3x2 (n=6) boreholes
 69    N_1 = 3
 70    N_2 = 2
 71    borefield1 = gt.borefield.Borefield.rectangle_field(
 72        N_1, N_2, B, B, H, D, r_b)
 73
 74    # Field of 6x4 (n=24) boreholes
 75    N_1 = 6
 76    N_2 = 4
 77    borefield2 = gt.borefield.Borefield.rectangle_field(
 78        N_1, N_2, B, B, H, D, r_b)
 79
 80    # Field of 10x10 (n=100) boreholes
 81    N_1 = 10
 82    N_2 = 10
 83    borefield3 = gt.borefield.Borefield.rectangle_field(
 84        N_1, N_2, B, B, H, D, r_b)
 85
 86    # -------------------------------------------------------------------------
 87    # Load data from Cimmino and Bernier (2014)
 88    # -------------------------------------------------------------------------
 89    data = np.loadtxt(file_path, skiprows=55)
 90
 91    # -------------------------------------------------------------------------
 92    # Evaluate g-functions for all fields
 93    # -------------------------------------------------------------------------
 94    for i, field in enumerate([borefield1, borefield2, borefield3]):
 95        gfunc = gt.gfunction.gFunction(
 96            field, alpha, time=time, boundary_condition='UHTR',
 97            options=options[i], method=method)
 98        # Draw g-function
 99        ax = gfunc.visualize_g_function().axes[0]
100        # Draw reference g-function
101        ax.plot(data[:,0], data[:,i+1], 'bx')
102        ax.legend(['pygfunction', 'Cimmino and Bernier (2014)'])
103        ax.set_title('Field of {} boreholes'.format(len(field)))
104        plt.tight_layout()
105
106        # For the second borefield, draw the evolution of heat extraction rates
107        if i == 1:
108            gfunc.visualize_temperatures(iBoreholes=[18, 12, 14])
109            gfunc.visualize_temperature_profiles(iBoreholes=[14])
110
111    return
112
113
114# Main function
115if __name__ == '__main__':
116    main()

References