BuildingSystems.Fluid.Geothermal.Borefields.BaseClasses.HeatTransfer.ThermalResponseFactors.clusterBoreholes

# .BuildingSystems.Fluid.Geothermal.Borefields.BaseClasses.HeatTransfer.ThermalResponseFactors.clusterBoreholes

Identify clusters of boreholes with similar heat interactions

## Information

This function identifies groups of similarly behaving boreholes using a k-means clustering algorithm. Boreholes are clustered based on their steady-state dimensionless borehole wall temperatures obtained from the spatial superposition of the steady-state finite line source solution (see BuildingSystems.Fluid.Geothermal.Borefields.BaseClasses.HeatTransfer.ThermalResponseFactors.finiteLineSource_SteadyState).

#### Implementation

The implemented method differs from the method presented by Prieto and Cimmino (2021). They used a hierarchical agglomerative clustering method with complete linkage to identify the borehole clusters. The optimal number of clusters was identified by cutting the dendrogram generated during the clustering process.

Here, a k-means algorithm is used instead, using the euclidian distance between steady-state borehole wall temperatures. The number of clusters is a parameter in this approach. However, as observed by Prieto and Cimmino (2021), `nClu=5` clusters should provide acceptable accuracy in most practical cases. This number can be increased without significant change in the computational cost.

#### References

Prieto, C. and Cimmino, M. 2021. Thermal interactions in large irregular fields of geothermal boreholes: the method of equivalent boreholes. Journal of Building Performance Simulation 14(4): 446-460. doi:10.1080/19401493.2021.1968953.

#### Interface

>     impure function clusterBoreholes
>       extends Modelica.Icons.Function;
>       input Integer nBor "Number of boreholes";
>       input Modelica.Units.SI.Position cooBor[nBor, 2] "Coordinates of boreholes";
>       input Modelica.Units.SI.Height hBor "Borehole length";
>       input Modelica.Units.SI.Height dBor "Borehole buried depth";
>       input Modelica.Units.SI.Radius rBor "Borehole radius";
>       input Integer nClu "Number of clusters to be generated";
>       input Modelica.Units.SI.TemperatureDifference TTol = 0.001 "Absolute tolerance on the borehole wall temperature for the identification of clusters";
>       output Integer labels[nBor] "Cluster label associated with each data point";
>       output Integer cluSiz[nClu] "Size of the clusters";
>       output Integer N "Number of unique clusters";
>     end clusterBoreholes;

## Revisions

- February 1, 2023, by Michael Wetter:
  Added `impure` declaration which is needed for compliance with the Modelica Language Specification, and is required by Optimica.
- February 1, 2023, by Michael Wetter:
  Added units.
- June 9, 2022 by Massimo Cimmino:
  First implementation.

Generated at 2026-05-12T20:19:03Z by OpenModelicaOpenModelica 1.26.7 using GenerateDoc.mos