# ORC Optimal Design through Clusterization for Waste Heat Recovery in Anaerobic Digestion Plants
## 3 Methodology  
### Preliminary Design  
#### 3.1.1 Definition of Design Boundary Conditions  
The optimal design of an ORC may vary from case to case according to the thermal source and other external conditions. In this study, the preliminary plant design was addressed as a constrained optimization problem. A mathematical model of the system was defined and the resulting optimization problem was solved by maximizing the net electrical power produced by the ORC. The design of the system must be performed according to some boundary conditions, which represent the operational conditions of the mGT and digesters. The ORC design must consider the mGT exhaust gases' mass flow rate \(\dot{m}_{f}\) and maximum temperature \(T_{f}\) and the heat flow required by digesters \(\dot{Q}_{dig}\) to keep constant the digestion process temperature. These boundary conditions constrain the operation of the ORC since its introduction should modify neither the mGT operating conditions nor those of the digester. On one hand, ORC should be designed according to anaerobic plant operation; on the other hand, the design should aim at minimizing the ORC off-design to maximize the energy recovery over the year. For this reason, the ORC design boundary conditions have to be carefully chosen and should correspond to the working conditions that are more likely to occur during the year. To identify these most representative operating conditions, \(\dot{m}_{f}\), \(T_{f}\), \(\dot{Q}_{dig}\) were clustered. This clustering allows for the identification of the plant's most likely working conditions by considering the correlation between these three variables. Clustering consists of defining distinct groups (clusters) that are considered representative of data and assigning data to these groups. The distribution is carried out in such a way that the data exhibited substantial similarity within the same group and strong dissimilarity with the elements of other clusters. In the current study, the k-means algorithm was used, as implemented in MATLAB v. 2019b [35], according to Lloyd's algorithm [36]. The k-means algorithm is the most representative partitioning algorithm. In these algorithms, cluster membership is defined based on the distance of the element from a representative cluster point (centroid). Other clustering techniques are available, but if a considerable number of data are available, partitioning techniques are more suitable as they are more straightforward and efficient. As the k-means algorithm defines centroids to minimize the sum of the distances with data, the underlying problem is a non-linear optimization problem. As it often happens, these problems tend to be trapped into local minima. A multi-start approach has been used to avoid this, and the clustering algorithm was started from several different starting points, and the best solution at the end of all the runs was chosen. This technique made the analysis repeatable and helped to avoid suboptimal classification. The least number of random starts that led to stable results was found equal to 10 through a trial and error approach. For the k-means algorithm, the number of centroids must be specified in advance. This requirement might lead to non-natural partitioning due to the non-representative number of partitions. When a low number of clusters is specified, two or more different groups might gather together, yielding a misleading partitioning. The same can happen if there are too many clusters: elements belonging to the same group might be erroneously partitioned into different groups. Partitions from two to 10 clusters were tested to determine the optimal number of clusters for the available dataset. The average silhouette value was used \begin{table}
\begin{tabular}{c c c c c c c} \hline \hline
**Fluid** & **pcrit [bar]** & **Tcrit [\({}^{\circ}\)C]** & **MW [g/mol]** & **ODP** & **GWP** & **ASHRAE Safety** \\ \hline R245 fa & 36.51 & 153.86 & 134.05 & 0 & 1030 & B1 \\ \hline \hline \end{tabular}
\end{table} 
Table 1: R245 fa main characteristics. Data from [33; 34].