This function implements the g-function evaluation method introduced by Cimmino and Bernier (see: Cimmino and Bernier (2014), and Cimmino (2018)) based on the g-function function concept first introduced by Eskilson (1987). The g-function gives the relation between the variation of the borehole wall temperature at a time t and the heat extraction and injection rates at all times preceding time t as

where Tb is the borehole wall temperature, Tg is the undisturbed ground temperature, Q is the heat injection rate into the ground through the borehole wall per unit borehole length, ks is the soil thermal conductivity and g is the g-function.
The g-function is constructed from the combination of the
combination of the finite line source (FLS) solution (see
IBPSA.Fluid.Geothermal.Borefields.BaseClasses.HeatTransfer.ThermalResponseFactors.finiteLineSource),
the cylindrical heat source (CHS) solution (see
IBPSA.Fluid.Geothermal.Borefields.BaseClasses.HeatTransfer.ThermalResponseFactors.cylindricalHeatSource),
and the infinite line source (ILS) solution (see
IBPSA.Fluid.Geothermal.Borefields.BaseClasses.HeatTransfer.ThermalResponseFactors.infiniteLineSource).
To obtain the g-function of a bore field, each borehole is
divided into a series of nSeg segments of equal
length, each modeled as a line source of finite length. The finite
line source solution is superimposed in space to obtain a system of
equations that gives the relation between the heat injection rate
at each of the segments and the borehole wall temperature at each
of the segments. The system is solved to obtain the uniform
borehole wall temperature required at any time to maintain a
constant total heat injection rate (Qtot =
2πksHtot) into the bore field. The
uniform borehole wall temperature is then equal to the finite line
source based g-function.
Since this g-function is based on line sources of heat, rather than cylinders, the g-function is corrected to consider the cylindrical geometry. The correction factor is then the difference between the cylindrical heat source solution and the infinite line source solution, as proposed by Li et al. (2014) as
g(t) = gFLS + (gCHS - gILS)
The calculation of the g-function is separated into two
regions: the short-time region and the long-time region. In the
short-time region, corresponding to times t < 1 hour,
heat interaction between boreholes and axial variations of heat
injection rate are not considered. The g-function is
calculated using only one borehole and one segment. In the
long-time region, corresponding to times t > 1 hour, all
boreholes are represented as series of nSeg line
segments and the g-function is evaluated as described
above.
Cimmino, M. and 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.
Cimmino, M. 2018. Fast calculation of the g-functions of geothermal borehole fields using similarities in the evaluation of the finite line source solution. Journal of Building Performance Simulation. DOI: 10.1080/19401493.2017.1423390.
Eskilson, P. 1987. Thermal analysis of heat extraction boreholes. Ph.D. Thesis. Department of Mathematical Physics. University of Lund. Sweden.
Li, M., Li, P., Chan, V. and Lai, A.C.K. 2014. Full-scale temperature response function (G-function) for heat transfer by borehole heat exchangers (GHEs) from sub-hour to decades. Applied Energy 136: 197-205.
function gFunction extends Modelica.Icons.Function; input Integer nBor "Number of boreholes"; input Modelica.SIunits.Position cooBor[nBor, 2] "Coordinates of boreholes"; input Modelica.SIunits.Height hBor "Borehole length"; input Modelica.SIunits.Height dBor "Borehole buried depth"; input Modelica.SIunits.Radius rBor "Borehole radius"; input Modelica.SIunits.ThermalDiffusivity aSoi "Ground thermal diffusivity used in g-function evaluation"; input Integer nSeg "Number of line source segments per borehole"; input Integer nTimSho "Number of time steps in short time region"; input Integer nTimLon "Number of time steps in long time region"; input Real ttsMax "Maximum adimensional time for gfunc calculation"; input Real relTol = 0.02 "Relative tolerance on distance between boreholes"; output Modelica.SIunits.Time tGFun[nTimSho + nTimLon] "Time of g-function evaluation"; output Real g[nTimSho + nTimLon] "g-function"; end gFunction;