*2.5. Anaerobic Digestion Unit*

The sludge production ( .*msludge*) was calculated using Equation (3), considering full-scale WWTPs' characteristics in the investigated area: a specific sludge production of 40 g suspended solids (SS)/m<sup>3</sup> (*psludge*) was used for the successive calculations. Biogas yield from excess sludge (*QCH4*, (m<sup>3</sup> CH4/h)) was obtained from Equation (4), considering typical specific methane production (*YCH4*, 250 NmL CH4/g *VS*) vs. the concentration of excess sludge (2.3% w/w) in medium-scale local WWTPs [31].

$$
\dot{m}\_{\text{sludge}} = \frac{Q \times p\_{\text{sludge}}}{\% VS \times 10^6} \tag{3}
$$

$$Q\_{\text{Cfl4}} = m\_{\text{sludge}} \times \%VS \times \Upsilon\_{\text{Cfl4}} \tag{4}$$

The mean electric and thermal efficiencies of the downstream combined heat and power (CHP) unit for biogas cogeneration were assumed respectively as 35% and 43%, consistently with relevant literature studies [32,33].

The heat demand of the anaerobic digester was considered as the sum of the heat losses through digester walls (*Hloss*, (W)) and the thermal energy needed for sludge heating (*Hsludge*, (kJ/h)), calculated using Equations (5) and (6), following the approach proposed in [34]:

$$H\_{\rm loss} = k\_{\rm air} A\_{\rm sup} \left( t\_{\rm dig} - t\_{\rm air} \right) + k\_{\rm soil} A\_{\rm base} \left( t\_{\rm dig} - t\_{\rm soil} \right) \tag{5}$$

$$H\_{\rm sliding} = \dot{m}\_{\rm sliding} c p\_{\rm sliding} \left( t\_{\rm diag} - t\_{\rm s0} \right) \tag{6}$$

The specific heat capacity of sludge (*cps*) was estimated as 3.62 kJ/kg ◦C [6], while air (*tair*) and soil (*tsoil*) temperature were obtained from regional climate data [35]. Air (*kair*) and soil (*ksoil*) heat transfer coefficients were taken from [34]. The digester operating temperature, *tdig*, was set at 35 ◦C (optimum mesophilic range [36]), while the mean influent sludge temperature, ts0, was supposed to be 15 ◦C, consistently with regional climate data [35]. The geometrical characteristics of the digester (base area, *Abase*, (m2), and lateral area, *Asup*, (m2)) were calculated considering the real characteristics of the analyzed full-scale reactor.
