Robust control of a cogeneration plant supplying a district heating system to enable grid flexibility

. In recent years, the flexibility of energy systems has become essential due to the growing penetration of renewable energy sources. The producers and consumers can enhance this flexibility by enabling a given amount of power that they can produce or consume in every condition. This is made available to the grid operator to globally optimize the dispatch management and to stabilize the grid. However, this can interfere with the operation of production units such as cogeneration plants, which also have to meet thermal demand. Therefore, producers and consumers require smart controllers to comply with grid operator requests at any time. This paper proposes a robust control strategy based on Model Predictive Control, which manages distribution networks and production plants by considering the uncertainty of the requirements for flexibility from the grid operator. The simulation case study is the district heating network of a school complex supplied by a Combined Heat and Power plant and a Thermal Energy Storage tank. The robustness of the proposed optimization is investigated by simulating several scenarios with different degrees of uncertainty about the request for electricity from the grid operator. The results show that the plant operator is able to comply with the electricity requirements to different extents depending on the degree of uncertainty and on system design choices. These considerations make it possible to improve the plant design and production planning from the perspective of grid flexibility.


Introduction
Over the last couple of decades there has been significant growth in the worldwide market for renewable energy technologies, such as wind, solar and hydropower. This is due to both technological advancements and support policies, which have fostered the increasing cost-effectiveness of renewable power when compared to conventional power plants fired by fossil fuels. For instance, in Italy renewable power generation capacity grew by about 170 % between 2004 and 2018 also due to these incentives [1]. Similarly, the primary production of renewable energy within the EU-28 increased overall by 64 % between 2007 and 2017, equivalent to an average increase of 5.1 % per year [2]. Such a significant growth in renewable energy penetration has also resulted in the spread of distributed generation, namely, power generation performed by a variety of small, grid-connected devices. Since most of the distributed energy resources are renewable energy generators, a significant degree of uncertainty is introduced in the management of the power system. In addition, the integration of a large number of discontinuous generation units within the existing power * Corresponding author: costanza.saletti@unipr.it grid represents an important technical challenge for the grid operator, which has to guarantee grid stability at all times. In order to deal with these issues, the aggregation of several producers or consumers is considered one of the best solutions, since it allows distinct devices to act as a single entity when interacting with the grid operator.
Legislation has gone hand in hand with the evolution of the power system: as an example, Terna, the Italian transmission system operator (TSO), has recently adopted a specific regulation for a pilot project involving the so-called UVAMs [3]. These are gridconnected devices or aggregators entitled to provide ancillary services such as congestion resolution, supplemental reserve and grid balancing. Basically, the act regulates the interactions between the TSO and all the UVAMs which have previously declared their availability to perform grid services during a defined time interval. Thus, each available UVAM must be ready to produce (or consume) a given amount of power, regardless of whether or not this power is effectively required by the grid operator.
Under these circumstances, flexibility has become a fundamental feature, as it allows the plant to face the uncertainties of demand. Therefore, cogeneration represents one of the most suitable and flexible methods to fulfill the electricity requirements without affecting the global efficiency of the plant. Indeed, if properly designed, a Combined Heat and Power (CHP) plant can compensate the intermittency of renewable electrical generation, while recovering the otherwise-wasted heat for district heating purposes. In this regard, a smart controller becomes essential since it can regulate the CHP operation depending on both the electrical and thermal demands, thus attempting to avoid partial load operation and related efficiency losses. A suitable management strategy for this type of system should be economically optimal but also robust enough to consider compliance, at any given time, with the potential requests from the grid together with the thermal demand of the end-users connected to the system. According to a review by Zakaria et al. [4], numerous approaches are available to take into account the uncertainty of several factors in the optimization of renewable energies in general. Among the most notable methods, there is the Monte Carlo Simulation for modeling the uncertainty by means of the generation of different scenarios according to the probability that random events occur. Nonetheless, the authors conclude that the investigation of multi-scale problems (from single application to district level) with a high penetration of renewables is an open field of research. Hence, numerous research questions concerning their dynamics and integration in the market are still unanswered. In parallel, Gang et al. [5] tackle the uncertainty in the planning and design stages of district cooling networks by considering aspects such as the outdoor weather, the building layout and the indoor conditions (e.g. heat gain from occupants and equipment). The methods to study the uncertainties in the management phase, however, are not considered. Moretti et al. [6] investigate the issues concerning multisource energy systems in general by proposing a robust optimization method for their day-ahead scheduling. Nonetheless, comprehensive studies regarding the control of these networks in the framework of power grid flexibility are still unavailable or at an early stage [7].
This work aims to address the research questions mentioned above by proposing a robust control strategy that considers the uncertainty of the electricity request by the TSO in the operation of a CHP plant and a Thermal Energy Storage tank (TES) supplying the heat distribution network of a small set of end-users. A predictive controller developed by the authors in previous studies is opportunely customized in order to implement and optimize the potential interaction with the grid operator. The approach is then tested and analyzed in a Model-in-the-Loop case study.

Robust control strategy
This section describes the innovative operating strategy that considers the uncertainties of the request for electricity from the grid. The predictive control concept, the control architecture and the implementation in a robust manner are outlined.

Model Predictive Control
The advanced controller is based on Model Predictive Control, which is a family of control strategies that exploit a dynamic model of the system to predict its behavior over a future time horizon, known as prediction horizon (i.e. two days), and calculate the optimal control inputs according to a given cost function. The first element of this control trajectory is actually implemented. Then, the prediction horizon is moved one step forward, the state and exogenous variables of the model are updated, and the optimization is repeated. This reduces the influence of limited knowledge of disturbances and modeling approximations [8]. An MPC controller with a Dynamic Programming optimization algorithm has been developed in [9,10]. The algorithm requires a statespace representation of the system to be controlled with one state. Hence, it has been firstly demonstrated on the heat distribution network of an individual building application, in which the system state is the building internal temperature and the system manipulated variables are the mass flow rate and temperature of the water to the building substation heat exchanger [11]. Nonetheless, the extension to larger networks is straightforward and can be achieved by means of applying the multi-agent approach outlined below [12].

Multi-agent modules
It is possible to treat large distribution networks by implementing the controller in each branch of the network: the multi-agent approach consists of splitting the system into smaller sub-systems, which are controlled by a representative agent. Each agent, in turn, communicates with a central controller that supervises the operation of the system in its entirety. Therefore, in the presented application, each building is managed by a dedicated MPC controller, namely building-MPC [9]. Within the controller, each building is modeled as a grey box through Eq. (1), which is derived from the energy conservation equation: where T is the building internal temperature, Text is the ambient temperature, ṁ, TS and TR are the mass flow rate, supply and return temperatures of the water to the building substation heat exchanger, respectively, and c is the specific heat. The performance coefficients a and b are specific to the building and can be identified with experimental or simulation data [9,10]. The Dynamic Programming algorithm receives the actual building internal temperature and returns the optimal set-points of the water mass flow rate and supply temperature. The former is kept by controlling the pump rotational speed through a proportional feedback controller while the latter is maintained by setting the recirculation valve with an open-loop controller (e.g. look-up table).

Supervisory module
The building-MPCs communicate with a supervisory-MPC, the duty of which is to manage the CHP and TES in an optimal way in order to minimize the total cost. This controller receives -as disturbances -the predicted thermal demands (calculated by the building-MPCs), the electrical demand and the power made available to the grid operator over the prediction horizon. Then, it returns the optimal set-point to operate the plant in order to guarantee that the TES is able to fulfil the total thermal demand. In the supervisory-MPC, the same Dynamic Programming algorithm described previously is used to calculate the optimal manipulated variables (inputs). The algorithm exploits the simplified model of the power production site (storage and CHP plant) described below.
The thermocline assumption cited in [13] is adopted for the TES model. The tank is split into two zones with a defined high temperature Th (i.e. 80 °C) and low temperature Tl (i.e. 60 °C). The position of the virtual separation surface between the zones, with reference to the top of the storage tank, is defined thermocline and can be considered a representation of the state of charge of the TES. The thermocline x is the system state while the thermal power to the CHP Q in, the boiler on-off signal and the electricity bought from the grid Pb are the inputs. The state function is given by Eq. (2): where ρ and A are the water density and tank base surface, respectively, ṁtot is the total mass flow rate requested by the end-users and Q loss is the heat loss to the environment. The state x is constrained between 0 and the TES total height, since it represents the thermocline with reference to the top. The cost function for each time-step of the algorithm is given by the sum of the total costs due to natural gas flow rate ṁf, electricity bought from the grid Pb, and revenues resulting from the sale of electricity to the grid Ps, as in Eq. (3): where cb, cs and cf are the specific costs for the bought electricity, sold electricity and natural gas, respectively. The sold electric power is calculated as the sum of the electric power produced by the CHP (i.e. Pel) and the bought electric power minus the total electric demand of the end-users (i.e. Pd), as in Eq. (4):

Robust control implementation
The plant operator establishes an amount of electrical power that is made available to the grid operator according to a defined time schedule. In reality, the TSO, which is responsible for the balance of the power grid, plans and requests power production from the dispatchable generation plants connected to the grid coherently with the actual system and market conditions. Hence, the power made available by the plant operator is not actually exploited at all times, as exemplified in Fig. 1.
For this reason, the supervisory module described in Section 2.3 must be robust for including the uncertainty of the request for electricity from the grid operator. This is implemented by considering that, when the power availability has been assigned, two events may occur: ▪ E1: the TSO does not require the available power; ▪ E2: the TSO requires the entire amount of available power from the dispatchable generation plant.
In the first case, Eq. (3) defines the objective of optimization. On the contrary, the occurrence of E2 is associated with a modified cost function in which the amount of electricity required by the TSO and actually dispatched is rewarded more than in the usual case, since the power plant is providing a service. It is also worth noting that the TES state of charge cannot exceed the constraints. The global cost function of the controller is obtained by weighting the cost functions of E1 and E2 with the respective probability of occurrence.

Application
The robust controller is tested in a Model-in-the-Loop simulation scenario, which consists of controlling a detailed dynamic model of the system and its interactions with the environment by means of the controller code to evaluate its performance. The description of the case study and components of the detailed model is reported in the following sections.

Case study description
The case study is a small-scale district heating network which serves a school complex consisting of three different buildings: a primary school, a high school and a sports hall. An internal combustion gas engineacting as a CHP unit -provides electricity and heat to the users. The CHP nominal electrical power is 2160 kW while the nominal electrical and global efficiencies are 0.43 and 0.85, respectively. Depending on the grid operator requirements, CHP operation and user demand, the electrical power can be sold or bought by means of a bidirectional connection with the power grid. The plant operator makes 1600 kW available to the power grid -as a flexibility service -from 07:00 to 12:00 each day (Fig. 1). The heat produced by the CHP is entirely supplied to a TES in a two inlets-two outlets configuration [14] by means of the main pump, while heat dissipation is not allowed. The TES, which acts as a buffer between the heat production and consumption and supplies hot water directly to the users by means of three secondary loops, has a total water volume of 200 m 3 . Once the thermal power has been transferred to the building space heaters, the water is partly recirculated to the building itself to regulate the supply temperature, and partly conveyed to the return manifold, which directly feeds the TES on the user side.
Several control loops deal with the system operation management on the power generation and user-side: ▪ A proportional controller regulates the rotational speed of the main pump feeding the heat exchanger, in order to guarantee that the thermal power is correctly retrieved. The temperature of the TES inlet water is maintained at 80 °C.
▪ A dual controller determines the fuel supply andconsequently -the CHP operation. The supervisory-MPC generates the set-point of the fuel mass flow rate (Section 2.3), which is then corrected by a proportional controller based on the actual electricity request from the grid operator.
▪ A proportional controller governs the operation of the building heating elements (e.g. radiators and fan coils), in order to keep the water outlet temperature at the design value of 60 °C.
▪ The user-dedicated MPC controller (Section 2.2) regulates the building internal temperature by varying the secondary pump rotational speed and the recirculation valve opening.

Detailed system model
The case study simulation is implemented in the MATLAB ® /Simulink ® environment. The detailed model, which emulates the real system and constitutes the benchmark for the robust controller testing, is built by means of a library of energy system components presented in previous works [11]. A brief description of the main components is given below: ▪ The cogeneration unit is an algebraic model that gives the electrical and thermal power outputs as the product of the fuel power and efficiencies. These are corrected based on the ratio of actual to nominal fuel power and on air temperature. The considered CHP unit operates in a modulating configuration within the operation range (from minimal to nominal load).
▪ The main pumping station comprises the expansion vessel and pump models. The former is a dynamic model which dampens hydraulic pressure changes due to mass flow rate transients and water thermal expansion. The latter evaluates the operation of the pump by relying on its characteristic curve. ▪ The TES model is based on a one-dimensional, multi-node modeling approach, and it simulates the thermal stratification phenomenon occurring within a sensible heat storage tank, as thoroughly reported in [15]. In this case, the TES is used to decouple heat production and consumption. Thus, the CHP unit can take advantage of this additional degree of freedom for the optimal fulfilment of the system requirements.
▪ The distribution network consists of several basic components: pipelines, valves and junctions. These models [16] allow both the hydrodynamics (e.g. pressure losses) and thermal features (e.g. heat losses) of the network to be properly represented during transients or in steady state.
▪ The building thermal behavior is modeled by means of the energy conservation equation parametrized with four performance coefficients [11].

Analyzed scenarios
The assessment of the proposed control strategy with uncertain requests from the grid operator is carried out by simulating and comparing different scenarios, with reference to the events E1 and E2 described in Section 2.4. The four considered scenarios, summarized in Table  1 together with the weights of the cost functions in the global optimization, are as follows: ▪ Scenario 0 (S0): this is the baseline scenario in which the supervisory-MPC considers the occurrence of E1 only. The potential request of the grid operator is not included in the model prediction and optimization.
▪ Scenario 1 (S1): the plant operator knows the exact occurrence of E1 or E2 (i.e. weight equal to 1) with a defined time advance (e.g. three hours), presumably when the TSO plans the production. In the rest of the prediction horizon, E1 and E2 are considered equally probable events. The related cost functions appear with a weight of 0.5 in the global cost function. This scenario is expected to be the most similar to reality.
▪ Scenario 2 (S2): the plant operator has no exact information regarding the occurrence of E1 or E2. The events are equally probable over the entire prediction horizon and, therefore, equally weighted in the global cost function of the optimization.
▪ Scenario 3 (S3): the plant operator assumes that the available power is always requested by the TSO and, thus, E2 occurs over the entire prediction horizon.

Results and discussion
The network is simulated for three representative days in the winter season, in which the heating demand of the buildings connected to the district heating is typically higher. Since the primary objective of the control strategy is to maintain the end-users' indoor comfort, it is important to verify the actual delivery of heat. As in previous studies [9][10][11], Fig. 2 shows that the required thermal conditions of one of the buildings (i.e. high school) are kept within the limits in all scenarios, confirming the effectiveness of the building-MPC. Additionally, it is possible to observe a similar behavior of the building internal temperature in the four scenarios. This is reasonable because the control of the downstream part of the network is not varied. Similar results can be observed as far as the other buildings of the school complex are concerned. On the other hand, the management of the CHP plant and TES is influenced by the knowledge of the scenario.
The state of charge of the TES (i.e. percentage of energy content of the water in the tank with reference to the maximum) over the simulation time span is represented in Fig. 3. The production of electricity is shown in Fig. 4 and compared to the actual electricity required (represented as the shaded area), which is the sum of the power demand of the school complex and the power dispatched by the TSO.
The diagrams show that, when the optimization considers the possibility to produce electric power to provide flexibility to the grid (S1-3), the TES is charged in advance compared to the baseline scenario, in order to increase electricity production and operate the dispatching service. Moreover, its state of charge does not reach the maximum so as to leave a margin to store heat when CHP production is required. In each case, however, the TES is almost full at the beginning of each operating day, as it has to preload the buildings in order to fulfill indoor comfort. In addition, it collects the heat produced by the CHP to meet the electrical demand of the previous day.
It is possible to observe that S1 is the case that gives better results in terms of compliance with the electrical requirements. Indeed, as stated above, it is expected to represent the actual conditions more closely. This attests good replicability of this concept to other cases. This result is confirmed by Table 2, which reports (i) the operating cost as the sum of the fuel cost and electricity bought from the grid, and (ii) the percentage of the electrical energy required by the TSO that is actually produced and fed to the grid. The latter can be seen as an indicator of the flexibility provided to the power grid by the CHP plant.
In S1, the constraints of the successive three hours are known precisely, thus the controller is able to react and operate the system in order to maximize the fulfilment of power demand up to 92.3 %. A poorer performance is obtained when there is uncertainty over the entire prediction horizon (S2) and when there is the assumption that it is always necessary to produce electricity (S3). Indeed, in the latter case, the time in which it is assumed necessary to produce electricity is overestimated and, given the limitations on TES capacity, the actual production is planned in less profitable hours. Regarding the economic performance, S1 seems to lead to a higher operating cost, as it produces more electricity. However, the gain of the flexibility service performed, which is significant in S1 and slightly lower in S2 and S3, is not included in that parameter. Hence, the actual profit is underestimated.
The uncertainty of the disturbance (i.e. grid request) plays a significant role in the global performance of this control strategy, which in any case maintains the primary objective (i.e. fulfilment of end-user thermal demand). Nonetheless, in this specific application it has not been possible for the plant operator to fully comply with the requests of the grid operator. In fact, the upper boundary of this case, represented by the ideal scenario of perfect knowledge of the actual request over the   prediction horizon, leads to an electrical requirement compliance of 94 %. This is because, in some cases, the power is made available when the TES is unable to store enough energy. Since heat cannot be dissipated, in this condition it is not possible to operate the CHP. In the light of these considerations, some management or design changes for this case study can be suggested: ▪ The period in which electrical power is made available to the grid could be revised in order to better match the thermal demand. In this way, it is likely that the electricity is dispatched when the TES is not full. ▪ The current system configuration, which does not allow the electrical and thermal power production to regulate independently, could be rearranged with more degrees of freedom, for instance by supplying heat directly to the users or by dissipating heat.
Overall, this method can also be useful for providing insights in terms of operation and management and, therefore, for discussing and revising production planning and design choices. These actions, together with the implementation of the MPC controller, can provide more flexibility to the system and the grid.

Conclusions
Nowadays, there is a growing need for dispatchable electricity generators that can make a defined amount of electrical power available to the power grid operator, in order to cope with the supply discontinuity of renewables in the current global energy system. This work proposed a novel method for enhancing the flexibility of the grid by means of the smart and robust control of a Combined Heat and Power plant supplying a small-scale district heating system and providing the aforementioned service. The control approach was based on a multi-agent, hierarchical Model-based Predictive Controller developed by the authors. Each branch of the distribution network was controlled by dedicated modules that minimized end-user energy consumption. The supervisory module, in turn, optimized the operation of the Thermal Energy Storage tank and the cogeneration plant supplying it, while attempting to comply with the electricity request from the grid operator. The uncertainty of this parameter was considered in the optimization by simulating the network in several scenarios, in which the actual request of the grid operator was either known, to various extents, or not at all. The results of the optimization showed that the thermal comfort, as the primary objective, was always guaranteed, while the compliance with the electricity requirements was assured to different degrees depending on the scenario (up to 92 % in the best case). The analysis also enables both the planning of power availability and more profitable design choices to improve the system within this framework.
Future studies will investigate other methods for scenario generation and uncertainty analysis, in order to provide a more robust approach. Moreover, additional sources of uncertainty, such as the variability of the external environment conditions or of the electricity market prices, will be included in the research.