## 2 Materials and Methods  
### Methods  
This research contributes to the ongoing discussion surrounding the integration of medium-scale HPs into third-generation DH systems that are already operated with CHP and boiler units. The research does this by systematically evaluating all the DH subsystems, with a focus on the thermal energy production subsystem under controlled operation conditions. This study evaluates the energy performance, costs, and CO2 emissions across a range of system configurations, operation regimes, and energy price scenarios. The primary flowchart of the model is presented in Figure 1.  
To achieve a high degree of reliability, this study relies on the previous work of authors where a numerical model of a complete DH system was developed and validated [3]. The present study investigates the third-generation DH system in Croatia through a case study approach. The initial phase of the study entailed the aggregation and processing of all data pertinent to the DH system simulation. This encompassed the analysis of  
Figure 1: Flowchart for the modelling and simulation cycle.  
building design projects and the current state of the envelope and heating systems in buildings. Additionally, it involved the examination of DH data concerning equipment type and size, operational parameters, thermal energy utilisation in buildings, and fuel (natural gas) consumption.  
Following the processing of the specified parameters, the TRNSYS 17 simulation environment was utilised to develop the dynamic simulation models. This decision was made due to the TRNSYS 17 environment's proven capability to model complex interactions within energy systems [18]. For the sake of clarity, details on this process are briefly elaborated here, with further elaboration available in previous works by the authors. The design of simulation models for systems employing a natural gas boiler, CHP unit, and HP was informed by the thermal energy consumption of the DH system and the requisite thermal energy capacity in design conditions. The boiler and CHP unit were regarded as existing equipment within the system, while the CHP units were considered in a range of sizes. The operation of the CHP unit was simulated based on data provided by the manufacturer, with particular reference to capacities and efficiency at partial load. The operation of HPs was simulated based on manufacturer data. This process incorporated the consideration of efficiency at partial load, as well as variable heat sink and source temperatures. The system control was analysed within the context of three distinct operational strategies. The first operational strategy prioritised the operation of HP over CHP. The second operational strategy prioritised the operation of CHP over HP. The third operational strategy involved the simultaneous operation of CHP and HP, with adjustments made to meet the required thermal energy demands. In all three of the considered operational strategies, the priority assigned to the boiler operation was the lowest. Simulations were performed for a whole year operation of the DH system to include a realistic scenario comprising peak load periods during the winter period and those with lower load during the transitional and summer period. Outputs from simulations provided data on the produced and consumed energy by each generator in the system, enabling the calculation of key performance indicators, including primary energy consumption, the proportion of renewable energy within the system, and CO2 emissions. An economic analysis was conducted over the system's lifecycle, considering three energy price scenarios to evaluate the investment's profitability.