A Unified Control Platform and Architecture for the Integration of Wind-Hydrogen Systems Into the Grid

Hydrogen is a promising energy vector for achieving renewable integration into the grid, thus fostering the decarbonization of the energy sector. This paper presents the control platform architecture of a real hydrogen-based energy production, storage, and re-electrification system (HESS) paired to a wind farm located in north Norway and connected to the main grid. The HESS consists of an electrolyser, a hydrogen tank, and a fuel cell. The control platform includes the management software, the control algorithms, and the automation technologies operating the HESS in order to address the three use cases (electricity storage, mini-grid, and fuel production) identified in the IEA-HIA Task24 final report, that promote the integration of wind energy into the main grid. The control algorithms have been already developed by the same authors in other papers using mixed-logical dynamical modeling, and implemented via a two-layer model predictive control scheme for each use case, and are quickly introduced in order to make evident their integration into the presented architecture. Simulation test runs with real equipment data, wind generation, load profiles, and market prices are also reported so as to highlight the control platform performances.Note to Practitioners—The paper develops the integration between the management platform of a HESS, paired to a real wind farm in northern Norway, and the control algorithms aimed at scheduling hydrogen production and re-electrification on the basis of several forecast streams about exogenous conditions and different possible operating modes of the wind-hydrogen system. The control algorithms address the three use cases identified by the IEA-HIA in the final report of Task 24 about the integration of wind energy into the grid, namely i) electricity storage, where the HESS is operated in order to enable the wind farm to power smoothing; ii) mini-grid, where the wind farm and the HESS form a mini-grid with a local load (small town) and the HESS is therefore operated in order to fulfill it without and with grid support (in this case buying and selling electricity to the market is also handled); and iii) fuel production, where the HESS is operated in order to fulfill a hydrogen demand (e.g., due to fuel cell vehicles). In addition to the specific objectives of each use case, the developed control algorithms also optimize the HESS operating costs and typically address two time-scale behaviors to appropriately handle corresponding long and short terms dynamics. The management platform of the HESS is arranged in three layers (physical, control, and supervision layers), and located in the cloud. The physical layer targets the physical components, sensors, and actuators. The automation layer includes all local controllers and modules used for measurement, and several servers for interactions between the higher and lower layers of the control architecture and databases. In the supervision layer, the execution of control algorithms and clients for remote diagnoses, monitoring, and top-management activities are located. Since each layer performs specific functionalities, a multi-tier architecture is implemented and the communications among the layers occur through services and microservices.

A Unified Control Platform and Architecture for the Integration of Wind-Hydrogen Systems Into the Grid Muhammad Bakr Abdelghany , Member, IEEE, Valerio Mariani , Member, IEEE, Davide Liuzza , Oreste Riccardo Natale , and Luigi Glielmo , Senior Member, IEEE Abstract-Hydrogen is a promising energy vector for achieving renewable integration into the grid, thus fostering the decarbonization of the energy sector.This paper presents the control platform architecture of a real hydrogen-based energy production, storage, and re-electrification system (HESS) paired to a wind farm located in north Norway and connected to the main grid.The HESS consists of an electrolyser, a hydrogen tank, and a fuel cell.The control platform includes the management software, the control algorithms, and the automation technologies operating the HESS in order to address the three use cases (electricity storage, mini-grid, and fuel production) identified in the IEA-HIA Task24 final report, that promote the integration of wind energy into the main grid.The control algorithms have been already developed by the same authors in other papers using mixed-logical dynamical modeling, and implemented via a two-layer model predictive control scheme for each use case, and are quickly introduced in order to make evident their integration into the presented architecture.Simulation test runs with real equipment data, wind generation, load profiles, and market prices are also reported so as to highlight the control platform performances.
Note to Practitioners-The paper develops the integration between the management platform of a HESS, paired to a real wind farm in northern Norway, and the control algorithms aimed at scheduling hydrogen production and re-electrification on the basis of several forecast streams about exogenous conditions and different possible operating modes of the wind-hydrogen system.
The control algorithms address the three use cases identified by the IEA-HIA in the final report of Task 24 about the integration of wind energy into the grid, namely i) electricity storage, where the HESS is operated in order to enable the wind farm to power smoothing; ii) mini-grid, where the wind farm and the HESS form a mini-grid with a local load (small town) and the HESS is therefore operated in order to fulfill it without and with grid support (in this case buying and selling electricity to the market is also handled); and iii) fuel production, where the HESS is operated in order to fulfill a hydrogen demand (e.g., due to fuel cell vehicles).In addition to the specific objectives of each use case, the developed control algorithms also optimize the HESS operating costs and typically address two time-scale behaviors to appropriately handle corresponding long and short terms dynamics.The management platform of the HESS is arranged in three layers (physical, control, and supervision layers), and located in the cloud.The physical layer targets the physical components, sensors, and actuators.The automation layer includes all local controllers and modules used for measurement, and several servers for interactions between the higher and lower layers of the control architecture and databases.In the supervision layer, the execution of control algorithms and clients for remote diagnoses, monitoring, and top-management activities are located.Since each layer performs specific functionalities, a multi-tier architecture is implemented and the communications among the layers occur through services and microservices.
Index Terms-Energy management systems (EMSs), hydrogen storage, control architecture, wind energy integration, model predictive control (MPC), mixed logic dynamic.Power values corresponding to logical states.

I. INTRODUCTION
W IND power has shown a viable option for the decar- bonization of the energy sector; however, a large-scale integration into the grid is still challenging due to its variability and uncertainties, such as wind speed, direction, and turbulence.This variability results in difficulties in maintaining a stable and reliable supply of electricity to consumers.The pairing of hydrogen-based energy production storage systems (HESSs) can mitigate these aspects [1], [2].Typical HESSs consist of electrolysers, fuel cells, and storage tanks, and require the development of control systems to address multiple constraints, equipment limitations and degradations, and their economical costs during operations.
In this research study, the control platform architecture of a real wind farm paired to a HESS and located in north Norway is presented.The HESS is operated such that the integrated system (i.e., the wind farm with the HESS) complies with the three use cases, and corresponding operating modes, identified by the IEA-HIA Task24 to promote wind energy integration into the main grid [3].The use cases are electricity storage, mini-grid, and fuel production.
The electricity-storage use case considers the integrated system connected to the main grid and committed to smooth power injection into the grid so as to preserve stability and reducing fluctuations [4].Many power smoothing solutions have been proposed in the literature over the last decade to address this issue.For instance, power smoothing in renewable energy plants has been addressed in [5] where a combined receding horizon optimization policy for the wind farm and HESS is proposed.In [6], a cooperative control solves the problem of power fluctuations by using a hybrid energy storage system based on predictive and adaptive smoothing mechanisms.A multi-objective chanceconstrained optimal configuration scheme for battery energy storage systems (BESSs) has been presented in [7] to maintain both the uncertain power fluctuations and frequency deviation within predefined limits.In [8], a BESS has been controlled to reduce the cycles of battery charge/discharge, and then increase its lifetime.A comparison between the different ESSs has been provided in [9] and [10].In [11], the models for capturing the degradations due to power fluctuations have been presented, neglecting the modeling of short-term hydrogen devices features.The authors in [12] and [13] have proposed a model predictive control (MPC) strategy of a wind-hydrogen system in order to provide smooth power to the grid.Apart from the papers above, to the best of the authors' knowledge, the authors seem not to address all (or several) of these aspects in a unified way.Although the degradation issues have been addressed, other aspects, such as the limited available working cycles of the hydrogen devices, are not considered in the controller.Starting from our previous results [12], [14], in this paper we propose the integrated hardware (HW) and software (SW) control architecture we designed for the Raggovidda (Norway) wind farm, which implements the control algorithms dealing with the three use cases mentioned before and briefly detailed in what follows.
In the mini-grid use case, the integrated system establishes a mini-grid with a local load, e.g., a small town, as it happens in the target wind farm, which can be operated either in islanded [15] or in connected mode with different and peculiar objectives.In general, in this use case the main purpose of hydrogen production is to store temporary energy surpluses from renewable generation and to provide demand-side management (DSM) for energy supply.In [16], the economic scheduling of a network of microgrids for energy market participation with hybrid-ESSs under failure conditions using MPC has been presented.An optimal stochastic day-ahead energy market scheduling for the HESS considering economic and environmental aspects has been presented in [17].An MPC has been developed in [18] to optimize the economy and stability of islanded microgrids with photovoltaic (PV).Moreover, an MPC technique for hybrid-ESSs has been proposed in [19] to promote the autonomy of the microgrid and achieve a rapid transition response.In [20], [21] and [22], a coordinated MPC operation of a grid-connected wind-solar microgrid paired with hybrid-ESSs has been integrated in order to maximize revenue through the electricity market and minimize the ESSs operating costs.In [23], an MPC strategy has been implemented considering the energy demand, operating costs, system performances, and devices degradations.In [24], a robust optimal energy management system (EMS) of a residential microgrid considering uncertainties of forecast loads and renewable energy sources (RESs) has been developed in order to minimize the expected energy cost.In [25], a novel business model for ESS capacity planning model under the joint capacity and two electricity market regulations have been proposed to minimize the total cost for power consumers based on a fully parallel algorithm.In order to investigate the dynamic performance of the EMS, the coordinated control between two layers for the power-to-gas system-based microgrid has been proposed in [26].Another MPC strategy for the optimal economic schedule and management of microgrids by considering economic and environmental aspects has been presented in [5].In the mentioned papers regarding the mini-grid use case, neither the degradations are considered, nor the hydrogen devices' short-term features, i.e., the cold and warm starts, and their standby consumptions, are taken into account.This is one of the key aspects of our research study.
In the fuel production use case, the renewable generation is directed toward the supply of fuel to vehicles, i.e., the energy production by wind generation should be used only for hydrogen production by operating the electrolyser 100%.Despite this, the mode would not require any management strategy, and additional objectives, but with lower priority with respect to the main one, should be actually addressed.For instance, the problem of external electricity consumers, optimal electric demand tracking, and participation to the electricity market via hydrogen re-electrification can be still kept also in the case of fuel production [27], [28].A new supervisory-based model for the optimal scheduling of distributed HESS fueling stations for tracking the external consumers of hydrogen and electricity has been provided in [29].In [30], an optimal scheduling has been designed for the energy management of a solar-hydrogen microgrid which includes solar panels paired with a HESS and integrated BESSs in order to satisfy electric and hydrogen demands requested by the industrial hydrogen facility.The authors in [31] have proposed a coordinated centralized MPC of a wind-microgrid with electrical vehicle (EV) charging considering the uncertainties of the wind power in order to improve the balance between the EV charging load and the local wind power supply of buildings.Moreover, in [32], a control strategy is proposed for a grid-connected wind farm paired to a HESS to both meet electric and contractual loads and produce hydrogen as a fuel for fuel cell EVs (FCEVs).
Regarding similar control platform architecture, in the literature it is possible to find an overview of the novel control strategies implemented for HESSs and BESSs integrated with RESs.For instance, the authors in [33] have presented an Internet of Things (IoT) platform-based architecture which includes four layers (power, data acquisition, communication network, and application layers) for wind and solar microgrid comprising a HESS and a BESS, and conventional resources, e.g., diesel generator to provide accurate information for the system operator and platform performances.In [34], a stochastic distributed DSM strategy for smart grids considering uncertainty in wind power forecasting has been developed.In [35], an IoT energy system architecture, which includes a fuel cell, a lithium battery, and a supercapacitor technology, has been proposed to elaborate data on RES harvesting for low-energy systems.In [36], a new multi-objective solution for micro-grid and operation cost minimization of ESSs has been proposed.In [37], a smart hybrid micro-grid with a fuel cell and EVs has been proposed.Further, the authors in [38] have integrated a green hydrogen production with the electricity and the hydrogen market and provided optimal state-dependent solutions by using the Markov decision process theory.A novel stochastic optimal energy management of the smart grid, which takes into account uncertainties of the RESs and EVs based on the remote control in IoT, has been proposed in [39].However, in none of the above examples, the specific requirements of the three use cases are addressed in a unique architecture with three layers (physical, control, and supervision layers), where the control platform architecture is in the cloud.Indeed, we simultaneously consider the optimal operation planning of a wind-hydrogen microgrid comprising a HESS unit, and the interaction with external consumers of hydrogen, i.e., FCEVs.Additionally, the system incorporates multi-time-scales of the energy markets, which is a suitable option for HESS to maximize the revenue for wind farm owners.The wind-hydrogen microgrid is modeled by the mixed logical dynamical (MLD) framework to fully consider device switching dynamics and degradation costs.Moreover, the approach proposed in this paper is not specific to a particular plant and can be applied to similar settings, where hydrogen storage and re-electrification are paired with an intermittent renewable plant.
The main contributions of this research paper are the following: 1) the development of a unified control platform and architecture (management software, control algorithms, and automation technologies) that is under deployment in a real wind farm located in north Norway; 2) the integration in the developed control platform and architecture of three control algorithms, each one addressing a specific use case as per the IEA-HIA Task24 final report [3] that outlines how it is possible to promote the integration of wind energy into the grid via pairing wind farms to HESSs; 3) the development of a unified modeling approach that enables to address multiple conflicting objectives and different requirements/constraints when wind farms paired to a HESS are operated in order to address the three use cases identified by the IEA-HIA.The research study is further organized as follows: in Section II, the control and management architecture is explained in detail; the model of the system is provided in Section III; the control algorithms are given in Section IV; in Section V, simulation analysis and validation are shown; Section VI gives the closing remarks.

II. CONTROL AND MANAGEMENT ARCHITECTURE
The control and management architecture features three layers, as depicted in Fig. 1.The physical layer targets the physical components, sensors, and actuators.All local controllers and modules used for measurement and several servers for interactions between the higher and lower layers of Authorized licensed use limited to the terms of the applicable license agreement with IEEE.Restrictions apply.the control architecture and databases are integrated into the automation layer to perform primary plant control.This layer is also used to conduct preliminary monitoring and information preprocessing.In the supervision layer, the execution of MPC algorithms and clients for remote diagnoses, monitoring, and top-management activities are located.Since each layer performs specific functionalities, a multi-tier architecture is implemented and the communications among the layers occur through services and microservices.

A. Physical Layer
The main components of the physical layer are the HESS and the wind farm, along with their corresponding local embedded controllers and, in general, the external environment with which the integrated system is expected to interact.The green solid, blue, and red lines in Fig. 1 indicate the energy, hydrogen, and data flows, respectively.

B. Automation Layer
The automation layer integrates the networking infrastructure, the supervisory control and the data acquisition systems (SCADAs), the local dataloggers, and a server connected through a local network.The networking infrastructure (SW-Gateway in Fig. 1) enables transfer of data and control signals between sensors, actuators, controllers, supervisory components, and data storage.Specifically, the networking infrastructure carries the information between two levels of communication: a bottom level for communication on the lowest layers of control (local controllers and actuators) and an upper level for communication toward the MPC and the highlevel analytics.As shown in Fig. 1, the SW-Gateway includes three modules: resource adapter, message broker, and service adapter.The resource adapter aims to integrate functionalities and operations through a RESTful interface, to connect the sensors with the other components, and to monitor the state of the devices by intercepting data from the physical layer.
The resource adapter is based on the java message service (JMS), which supports the publish/subscribe message model.The message broker allows the transfer of large amounts of data using a queue system in a publish/subscribe model.For the system under study, Active MQ as message broker and STOMP (simple text-oriented messaging protocol) as text-based protocol are chosen.The third module aims to filter the inconsistent data and translate data into a common language such that the components in the supervision layer can interpret them without ambiguities or errors.The service adaptor is implemented as web service (RESTful) and data are passed in the javascript object notation (JSON) format.Moreover, in order to guarantee the security of the communication with the supervision layer, the industry-standard protocol open authorization (Oauth), secure web sockets, and secure API with HTTP over SSL/TLS (secure sockets layer/transport layer security) transport protocol are used.As regards transport layer protocol, UDP is used to achieve faster data transfers, albeit less reliable.
The SCADA system provides support and functions for both simple monitoring of wind turbines and smarter decisions making when any excess of hydrogen storage occurs.The SCADA architecture is based on two commercial micro PLCs embedded in both electrolyser and fuel cell, which belong to the Siemens S7-1500 family and the Siemens S7-300 family, respectively.The protocol used for the direct communication between SCADAs and PLCs is the standard-communicationprotocol OPC UA (open platform communications unified architecture) which allows for moving information to higher levels using the publisher-subscriber model; the protocol for the communication between the PLCs and both devices is Profinet (process field network) which handles data exchange in real-time (i.e., with a frequency of about 0.1 Hz) with the devices by implementing local control loops and processing.The PLCs allow the routing of the information from components, such as human-machine interfaces (HMIs), sensors and devices, to computers equipped with SCADA software.This software collects, processes, and displays data in order to control the operation and the data flow of the process.An HMI is an interface through which operators can monitor, track, and manage the system's activities.In the automation layer, the server stores information in a database to be sent to the supervision layer with a frequency of 0.1 Hz through the SCADA systems, which use the OPC UA protocol for the communication.A local datalogger is used for monitoring and storing data acquired over time by a sensor.Since high-speed recording is not required, the data logger is preferable instead of a data acquisition system.Once archived, the data is transferred to a computer for analysis.

C. Supervision Layer
The supervision layer includes user-side terminals and a supervision server, and implements a client-server mechanism in principle with two configurations: local and remote.In the local configuration, both the client and the server execute on the same machine.In contrast, in the remote configuration, the client and the server are separately executed onto two different corresponding machines.In the system under study, the remote configuration is used.The supervision server, which enables connectivity between the automation layer and clients, includes GUI, historian, monitoring, and MPC algorithms.The data storage, monitoring, and visualization functionalities are provided by the open-source platform Thingsboard, which offers a user-friendly GUI of the user-side terminals, both on mobile devices and desktop/laptop computers.The historian can be described as centralized databases which are used for model development and calibration, model parameters tracking and effectiveness analysis of the proposed controller.The use of an external history, in which real-time data coming from the SCADA system are stored for reports and analytics, facilitates data distribution.Thingsboard includes the tools PostgreSQL and Timescale/Cassandra to set up hybrid databases, i.e., which allow both relational and non-relational storages; in particular, all entities (such as devices, dashboards, users, alarms, etc.) are stored in the relational database PostgreSQL, while the time-series data are saved in the NoSQL database Cassandra.Databases are both local and cloud.Local databases are only accessible to a few users as they reside on a device.Instead, cloud databases can be accessed remotely by many users as they use web servers.Therefore, the flexibility of operation and less tedious setting-up phase of cloud databases allow us to privilege these databases.The management and access of the databases take place through monitoring which consists in data processing by converting data into a more readable format to be interpreted by other devices.The MPC algorithms use forecasts fed by other high-level entities outside the presented architecture (e.g., data providers) and real-time data from the physical layer which are transmitted to the supervisory layer through the intermediate layers; a detailed description of the algorithms is explained in Section IV.The MPC algorithms used are solved through different numerical tools, i.e., Python and MATLAB.The Python code is interpreted by CPython and compiled into a native binary for its execution.On the other hand, in MATLAB, a generated shared library is called by a real-time environment that receives data using a secure API.
In order to address the plant operations in the three use cases, corresponding control architectures and algorithms have been developed.However, the three different architectures feature the common target of minimizing the devices' operating costs.In the energy-storage mode, the controller operates the devices to provide smooth power injection into the main grid.In addition, the tracking of a desired power reference provided by the grid operator is considered.In this case, a single level architecture is implemented, however featuring a sequential optimization to prioritize power smoothing above all the other objectives.This is achieved by firstly computing the optimal power schedule fulfilling smoothing requirements, and then using that value as a constraint in the second optimization step, where the other costs are minimized.In the mini-grid mode, the controller operates the integrated system for the energy provision to a local load both in islanded and in connected modes.In this case, a two level architecture is implemented, where at high-level (HLC), the mini-grid management is achieved by considering generation and load demand forecasts, in case of disconnected mode, while the additional Authorized licensed use limited to the terms of the applicable license agreement with IEEE.Restrictions apply.
market prices forecasts are also included in case of connected mode, for market participation.The HLC scheduling is then implemented by the low-level (LLC) which handles shorter time-scales.In the fuel production mode, the controller should totally commit the integrated system to the production of green hydrogen for other uses than re-electrification.However, as the IEA itself acknowledges, this would not require any management strategy since there is no any downstream variable condition to cope with.Therefore, further objectives are included, however guaranteeing that the hydrogen production for other purposes has the highest unconditional priority above them.Thus, the architecture features two levels implementing a similar rationale as in the mini-grid, and at the HLC a sequential optimization is set-up, where the hydrogen load tracking is firstly achieved and then the optimal value is used as a constraint in the second optimization where the other costs are minimized.At the LLC, instead, only market participation and local load tracking are considered, suitably weighting the references such that the priority is very low.

III. MODELING
In this section, we introduce notations and standard assumptions that will be used throughout the paper.The control algorithms are developed via an MPC approach over a complex MLD model that integrates logic automata and low level dynamics (hydrogen tank, fuel cell, and electrolyser) [40].Being the aim of this paper the proposal of the integrated HW/SW control architecture developed under the project [41], we only provide here essential details of the above mentioned models and we refer the reader on how the models are developed in depth in our previous works [12], [32], [42], [43].

A. Notation
Some models used by the MPC-based controllers are built upon automata.The tags OFF, CLD, STB, WRM, and ON are used to label their states.The sets A HLC = {OFF, STB, ON} and A LLC = A HLC ∪{CLD, WRM}, where the superscripts HLC and LLC indicate the high-level and low-level controls, respectively, are used to define the domain of some sub/superscripts in case of possible ambiguities; α and β are two generic indices that can take value in A HLC or A LLC according to the particular case.If both α and β are used in conjunction it is agreed that α ̸ = β.Logic variables are δ α , σ β α , ∈ {0, 1} and z α = Pδ α , with P in R + , are mixed-integer variables; in some circumstances the further subscripts e and f are also used and refer to the electrolyser and fuel cell, respectively.Finally, general bold is used to denote vectors.
The model of the system is applied for two different timescales, according to the HLC and the LLC.However, the reader must be aware that the model formulation presented in the following employs an abuse of notation in that it uses the same discrete-time variable k both at the high-level (so addressing the larger time-scales) and at the low-level (addressing instead the shorter time-scales).

B. Logic Automata
The advanced features of the hydrogen devices required the use of MLD modeling to incorporate in the controllers their different logic states and corresponding working modes.This enabled to, e.g., minimize switching costs or take into account the different switching times due to cold and warm starts.Since the HLC and the LLC address different time-scales, also different models are correspondingly used.
Fig. 2 shows a representation of the model that describes the system under investigation.The red block regards the hydrogen devices, the blue block is related to the HESS and the corresponding constraints on the hydrogen level dynamics, and the green block is related to the interaction with the utility grid, i.e., the buying/selling energy from/to the grid.In order to guarantee the correct operation, the system is subject to the constraints represented in the gray block in Fig. 2. In particular, the ramp-up constraint limits the slew rate of the electrolyser input power and the fuel cell output power; the power balance equation is used to obtain a feasible optimal control setting; the feasibility and physical constraints define the minimum and maximum limits according to the operating ranges of the tank, the electrolyser, and the fuel cell.
Regarding the hydrogen devices, Fig. 3 and Fig. 4 show the automata that model the logical/discrete states of the electrolyser (i = e) and the fuel cell (i = f ), for the HLC and the LLC, respectively.The nodes and the edges correspond to the devices' states and the state transitions, respectively.Specifically, the devices' states are: ON denoting on state (the unit is producing/consuming hydrogen); OFF denoting off state (the unit does not produce/consume hydrogen and does not absorb any power) and STB denoting standby state (the unit does not produce/consume hydrogen but absorbs power); CLD denoting cold start; WRM denoting warm start.CLD and WRM are transient states where the system is forced to be for a given amount of time when leaving, respectively, the OFF and STB states.The HLC addresses larger time-scales of the order of hours where cold and warm starts are irrelevant Authorized licensed use limited to the terms of the applicable license agreement with IEEE.Restrictions apply.and, therefore, are neglected.Indeed, cold and warm starts are transient, i.e., they are active only for a limited amount of time of order of minutes.All nodes and edges are instead used for the LLC which addresses shorter time-scales of the order of minutes, where, instead, cold and warm starts are relevant and must be considered.
Each automaton represents graphically the logical behavior of the corresponding device at the considered control level.The MLD framework allows to achieve suitable constraints from logical propositions like, e.g., "if the electrolyser is in state STB, then its input power is P STB e " or their equivalent formulation via suitable logic variables and standard logic connectives.For instance, in this case α = STB and δ STB e (k) = 1.Then, the link between the state δ STB e (k) and the implied power (in this case the power that the electrolyser consumes to keep its stack warm when in standby) is encoded via constraints involving such logical variables.This applies in general to both devices, all the states at each particular control level, and also to the transitions between the states.

C. HESS Dynamics
The automata described in the previous section are coupled to the HESS dynamics due to the hydrogen level in the tank and its production (electrolyser dynamics) and consumption (fuel cell dynamics).They are given in what follows and apply similarly at the HLC and the LLC, for we avoid to indicate the particular control level in order to achieve a lighter notation.
The hydrogen H stored in the tank at each time-step k is expressed as where H exc (k) models the use of the stored hydrogen for supplying demand from commercial road vehicles or other possible customers only when it is relevant, i.e., when the fuel production use case is considered (see Sec. IV-C), η e and η f are the electrolyser and fuel cell productivities, respectively, and, in this case, T s is a generic sampling time that in the actual algorithms is specified according to the particular control level considered.The variables z s e and z s f are defined as z e (k) = P e (k)δ ON e (k), (2a) where P e and P f denote the electrolyser and fuel cell powers, respectively.The mixed-products between logical and real variables in (2) lead to nonlinearities, which can be difficult to be handled by an optimizer.However, according to the MLD framework, the definition in (2a) is recast as the following set of linear inequalities where M e and m e are an upper and lower bounds of P s e (k).The variable z f defined in (2b) can be recast in the same way of (2a).From ( 1) and ( 2), it follows that the electrolyser/fuel cell produces/consumes hydrogen only when they are in the ON state, by implying a change in the hydrogen level stored in the tank.
As it is possible to see above, the hydrogen stored in the tank, as well as the fuel cell and the electrolyser have nonlinear dynamics.Our model is relatively simple to be run in a real-time MPC with, at the same time, being able to capture the main aspects of the hydrogen consumption/production.Possible model mismatches or parameter drifts in the efficiency as well as disturbances or modeling simplification are anyway well handled thanks to the MPC, which re-computes at any time step an optimization over a prediction horizon from the current field condition (thus implicitly accounting for previous prediction mismatches).

IV. CONTROL ALGORITHMS
In this section, the optimization problems for each of the three targeted use cases are presented.As the MPC framework prescribes, at each time instant a constrained optimization problem is solved across a prediction horizon of fixed size.The output is the sequence of the optimal decision variables across the horizon; however, only the first sample is applied, while the others are discarded.Then, new measurements from the plant are achieved, the time-step is increased and a new iteration starts.In a multi-level architecture, at each time-step, two constrained optimization problems are solved.Two different sample times (and two different time-steps) characterize such problems.In what follows, h and m will denote the time instant according to the control layer, i.e., the HLC and the LLC, respectively, and T h s and T m s will refer to the two corresponding sampling times, respectively.For the specific application presented in this paper, T h s = 1 h and T m s = 10 min.Also, the prediction horizons used by the HLC and the LLC are different and, therefore, are correspondingly indicated by H and M, respectively.These assumptions hold across all the use cases.
The possibility of considering a longer time-scale (which in our case is set to 1 h, but this value can be selected differently) on top of the shorter time-scale allows to increase the control horizon.Indeed, a high number of decision/optimization variables are considered for the current time up to 10 min ahead, while less variables are considered for an entire day ahead, where less precision (and higher uncertainty) is required by Authorized licensed use limited to the terms of the applicable license agreement with IEEE.Restrictions apply.the controller.In view of this, the two time-scales allow to have good performances on both short and long control periods without unnecessary decision variable increase, which could harm the real-time resolution or the convergence of the optimization routines (whose complexity grows in a combinatorial fashion with the number of variables).It is worth highlighting that the control input is, in any case, provided on the shorter sampling time considered (i.e., 10 min).
The diagram of the architecture of the MPC algorithms is shown in Fig. 5.For the electricity storage, only the LLC is actually developed, while for the mini-grid and the fuel production use cases a multi-level optimization is developed.It is worth noticing that this paper aims at presenting the control architecture for the considered HESS plant servicing the wind farm.

A. Electricity Storage Use Case
The use of an HESS allows the management of the uncertainty of the wind generation and enables additional services to the grid, such as the injection of smooth power.With this aim, only the LLC is implemented, however featuring a sequential execution of two optimization problems: ES.1 to minimize a function of the previous output power variations, such that the new decided value does not lie too far from previous output power values; ES.2 to minimize the operating costs of the hydrogen devices and to track the grid operator reference signal.With the sequential optimization arrangement, the optimal value of the problem ES.1 is used as a constraint in the problem ES.2 such that power smoothing has the highest unconditional priority above the other objectives addressed in the second step.The two stages are solved against the decision variables collected in the set C m+ j = P e (m + j), P f (m + j), P g,avl (m + j), δ e (m + j), σ e (m + j), z e (m + j), Constraints for δ i and σ i , where C m|M = C m , . . ., C m+M−1 , wAVG(m + j) is a function that depends on a weighted average of the previous variations of P g,avl and additional parameters for tuning.Following, the problem ES.2 is solved via min where the cost function includes the operating costs Op i , with i ∈ {e, f }, of both devices, the tracking cost C g of the grid injected power with respect to the grid operator, and w e , w f and w g are suitable weights given to the corresponding cost functions.More in detail, they are defined as a function of the decision variables and system parameters as Op e (m + j) = Op e δ e (m + j), σ e (m + j); with abuses of notation, where c OM i is the operating and maintenance cost of the i-th device, NH i is the device cycle lifespan, c rep i is the device stack replacement cost, and the vector c σ i collects the switching costs of the device.Again, we refer the reader to [12] for a thorough mathematical modeling of the plant.

B. Mini-Grid Use Case
In this case, the MPC architecture addresses both the islanded and the grid-connected mode.In islanded mode, the main purpose is maintaining the power balance between generation and demand without grid support, while, in gridconnected mode, the additional participation to the electricity market is used with the main target to supply the load and, whenever possible, to generate profits.
In this operating mode, the architecture implements a multilevel control, as shown in Fig. 5.The HLC deals with forecasts 24 h ahead in time with 1 h sampling, and relies on measurements with the same rate.The subsequent 1 h scheduling is then passed to the LLC that works on shorter time-scales and, based on measurements at a higher frequency rate, handles the implementation of the high-level planning.The operating costs of both the devices are always considered irrespective of the control level and operating mode.On the contrary, the HLC and the LLC use two different automata for the electrolyser and the fuel cell.Further, the control architecture distinguishes between islanded and connected modes, where in the second case, being the HLC or the LLC, an additional cost is used in order to consider market operations both for buying and selling energy.Indeed, buying energy is meant to take advantage of the grid support in case of a possible load demand that cannot be matched with the renewable resource and the hydrogen in the tank, while selling energy enables an additional degree of freedom for generating revenues whenever possible.Summarizing, the following optimization problems are solved: MG.1 to track the load demand with the renewable resource and the hydrogen stored in the tank only, and to minimize the operating costs of the electrolyser and the fuel cell, in case of islanded operations; MG.2 to track the load demand with the wind generation, the hydrogen stored in the tank, and energy purchase, to minimize the operating costs of the devices and possibly to generate profits via energy selling, in case of connected operations.
The decision variables for the HLC related to problem MG.1, i.e., in islanded mode, are collected in the set I HLC h+ j = P HLC e (h + j), P HLC f (h + j), P HLC l,avl (h + j), δ HLC e (h + j), σ HLC e (h + j), z HLC e (h + j), (9) while those for the LLC are collected in the similarly defined set I LLC m+ j .The two sets differ in that, e.g., δ HLC e refers to the three-state automaton of the electrolyser, while the analogous δ LLC e refers to the five-state.In conclusion, the MPC problem is recast as min and then min Similar to (5c) − (5g), where at each sampled hour h, the optimal outcomes P HLC e (h) * , P HLC f (h) * , P HLC l,avl (h) * and LOH HLC (h) * of problem (10) are provided as references to problem (11), such that at the end of the LLC execution I LLC m * holds the optimal commands that are provided to the devices for the continuous-time interval h T h + [m, m + 1) T m .Then, m is increased by one unit step and the LLC is triggered again.The last iteration of the LLC is at m = 5 (having considered, as said before, 10 min sampling of the LLC every hour of the HLC), then m is reset to zero, h is increased by one unit step and the HLC executes again.Finally, the last iteration of the HLC before a reset of h is at h = 23.
The cost function in (10a) is where k HLC are similar to Op i , with the exceptions that now they refer to the HLC time-scale and related controller, the logical variables refer to the three-states automata, and where, with slight abuse of notation, is the load demand tracking cost.Following, the cost function in (11a) for the LLC is Authorized licensed use limited to the terms of the applicable license agreement with IEEE.Restrictions apply. where l,avl (m + j), P HLC l,avl (h) * , (15a) P LLC e (m + j), P HLC e (h) * , (15c) where, despite the fact that the LLC costs depend also on h, the double indexing is dropped for keeping the notation lighter.Regarding problem MG.2, i.e., connected operations, the optimization is recast similarly to what described above for problem MG.1, i.e., in islanded operations.The differences lie in the decision variables and the cost functions, that now incorporate energy selling and purchasing, in an additional term in the power balance constraint, that now has to account for the grid connection, and in additional MLD constraints following the modeling of buying and selling operations.
In connected mode, the decision variables for the HLC are collected in the set where P HLC g (h + j) := P HLC g,sell (h + j) P HLC g,pch (h + j) ⊤ is the vector of the power sold/purchased to/from the grid, δ HLC g (h + j) := δ HLC g,sell (h + j) δ HLC g,pch (h + j) ⊤ is the vector of the mutually exclusive logical variables identifying the corresponding selling/purchasing events and z HLC g (h + j) is the vector of the slack variables required for the modeling.In practice, P HLC g,avl (h + j) := P HLC g (h + j) ⊤ δ HLC g (h + j) (see Fig. 5).Instead, the set C LLC m+ j , which is defined similarly to C HLC h+ j , collects the decision variables used by the LLC.Thus, the optimization problems for the HLC and the LLC can be recast along the lines of ( 10) and (11), respectively, by considering C HLC h|H in place of I HLC h|H , C LLC m|M in place of I LLC m|M , the "augmented" costs in place of J HLC MG (h + j) and J LLC MG (m + j), respectively, where k HLC g and k LLC g are weights.The function of the grid exchanges at the HLC, with abuse of notation, is given by and the function of the grid exchanges at the LLC G LLC (m+ j) either is similarly defined in case real-time prices π LLC g (m + j) are available or tracks the HLC schedule P HLC g (h) * and δ HLC g (h) * on the contrary, and by considering constraints similar to those in the above mentioned problems.In case G LLC (m + j) is chosen to use real-time prices, assuming that those used at the HLC were good estimates, the real-time adjustment is feasible.

C. Fuel Production Use Case
In the fuel production operating mode, the MPC architecture exploits similar concepts used in the two previous control schemas.A two-level architecture is still implemented, as Fig. 5 shows, because forecasts and real-time measurements are available.The HLC, however, also features a sequential optimization similar to that used in the energy-storage mode, that aims at giving the highest unconditional priority to hydrogen production, at least across the larger time-scales.In the second optimization, since the main objective is not to generate hydrogen by purchasing energy from the grid nor to supply local loads, the local load demand and the market participation are addressed by only energy selling.The LLC is in charge of implementing real-time the planned schedule, while both the HLC and the LLC minimize also the devices operating costs.In conclusion, the following optimization problems are solved: FP.1 to track the hydrogen demand; FP.2 to sell energy to the main grid which gives the opportunity to maximize the economic benefits and to supply the load demand in case some hydrogen is left.The HLC addresses sequentially FP.1 and then FP.2 while the LLC addresses FP.2.
At the HLC, the set of decision variables for problem FP.1 is while for problem FP.2 it is C HLC h+ j = H HLC h+ j ∪ {P HLC g,sell (h + j), δ HLC g,sell (h + j), P HLC l,avl (h where P HLC g,avl = P HLC g,sell (h + j)δ HLC g,sell (h + j), and then the optimization is firstly and then min where, with abuse of notation, is the hydrogen demand tracking cost, H d (h + j) is the hydrogen demand, and where ρ HLC g and ρ HLC d are weights, and, again with abuses of notation, G HLC (h + j) = G HLC P HLC g,sell (h + j), δ HLC g,sell (h + j); where

V. SIMULATIONS RESULTS
In this section, we validate the control algorithms integrated into the control platform presented in this paper.The overall control scheme is under implementation in the Raggovidda (Norway) wind farm, according to the European Union Fuel Cells and Hydrogen 2 Joint Undertaking funded project HAEOLUS (Hydrogen-Aeolic Energy with Optimized Electrolysers Upstream of Substation) [41].In order to show the effectiveness of the controller, different power production and consumption profiles are taken into account.The results validation are preliminary to the deployment of the control strategy on the plant site, which is currently under construction in parallel to this research study.Our control strategy allows to deal simultaneously with several use cases (electricity storage, mini-grid, and fuel production) as identified within the IEA-HIA Task 24 final report [3].As it will be clear in what follows, the numerical results show that the proposed controllers are able to correctly satisfy the overall system constraints and achieve the set control objectives proposed.

A. Simulation Setup
In order to satisfy the validation of the proposed control in this research study, the control horizon, simulation horizon, sampling time, and the main characteristics of the device parameters have to be defined.Consequently, for the day-ahead market, simulations have been conducted over a T = 24 h horizon with T s = 1 h sampling time, instead, for addressing the real-time market, the LLC has been implemented on a shorter time horizon of T = 1 h with T s = 10 min sampling time.Table I and Table II summarize the main characteristics of the electrolyser and the fuel cell, both provided by Hydrogenics (now Cummins), and those of the wind farm owned by Varanger Kraft [44].It is important to highlight that since the HAEOLUS project is not finished, data from the literature are adopted for the parameters not yet defined.In order to balance the tracking goal satisfaction and the operational costs, the cost functions include suitable weights (determined by appropriate simulations test runs).The development and the simulation analysis of the proposed controllers have been carried out in MATLAB with the YALMIP tool and GUROBI optimizer on a computer with an Intel Xeon (R) R − 3265 HQ 3.2 GHz with 32 GB RAM.The time interval needed to solve the optimization problem on this computer is 60 s.

B. Case Studies
The proposed controllers are analyzed to show the correct management of the energy system under the three different use cases, namely, ES, MG and FP.The interaction with the main grid implies that the energy prices for energy selling/buying Authorized licensed use limited to the terms of the applicable license agreement with IEEE.Restrictions apply.  in the daily and real markets are considered.Figure.6 shows the power produced by the renewable resource, the electric demand and the hydrogen demand, respectively.
1) Analysis of Electricity Storage Use Case: The control goal in the electricity storage is to smooth the output power of the wind farm, and achieve a gentle tracking of the local and the contractual loads.As described in Section IV-A, a twostage optimization problem is formalized where the controller firstly computes the optimal bounds that the available power has to fulfill to meet the smoothing requirements.Then, such optimal bounds are used in the second stage as a constraint to the possible variation for the system's available power in the load tracking optimization.In Fig. 7, it is possible to see that the available power is adequately filtered when tracking the reference in both fluctuating wind profiles.Indeed, the controller tracks the reference smoothly in both scenarios and considers both surplus and deficit power corresponding to power flow towards or from the HESS.In this configuration with the HESS, P LLC f and P LLC e always take non-negative values and are complementary variables, i.e., they cannot be nonzero at the same instant.For simplicity, their effect can be condensed into only one variable P LLC Moreover, Figure 8 presents the power of the devices.In practice, the production of hydrogen is ON during high RESs hours, while the consumption of hydrogen is ON during low or nearly zero RESs hours.Figure 9 reports the hydrogen levels corresponding to the two wind profiles.The storage constraints are fulfilled for all time-instants since the hydrogen level is always between H max and H min .The fuel cell switches from OFF to ON by providing backup power for re-electrification when the RES production is less than the  requested load.Instead, the opposite situation occurs for the electrolyser due to not enough power to store.Then, it can be deduced that the transitions between the ON, OFF and STB states are scheduled in consistency with the cost minimization objectives.
2) Analysis of Mini-Grid Use Case: The control goal in mini-grid is to manage two different electricity markets at corresponding time-scales via a multi-level MPC scheme along with the provision of electric power which meets the power quality standard required by the grid operator.In Figs.10-13, the response of the proposed controllers is detailed.If a surplus of energy occurs, the system tries to sell energy to the grid.On the contrary, in an energy deficit event, the system tries to operate the HESS, while minimizing the device switching states and number of hours of use.In order to protect the tank from high levels of charge or discharge, the stored hydrogen is also constrained.
It is observed from Fig. 10 that the LLC meets the references which are scheduled by the HLC and correctly meets the load demand for all instants.As the LLC follows whenever possible, the references are scheduled by the HLC, but it Authorized licensed use limited to the terms of the applicable license agreement with IEEE.Restrictions apply.maintains the ability to manage the system autonomously as well.In Fig. 11, both hydrogen devices' references scheduled by the HLC and their tracking in the LLC are detailed.According to the grid-connected mode, Fig. 12 reports the electricity buying/selling events with the utility grid.In the same way, the sale of energy to the grid happens at the maximum price periods.In particular, the LLC may try to reach the references set by the HLC where possible.However, the sold power revenues are maximized depending on the energy price profile and the available power.In particular, during the 24 h simulations, except for hours 13-16, and 20, the controller tends to sell as much as possible.
3) Analysis of Fuel Production Use Case: The control goal in fuel production is the production of hydrogen as a fuel simultaneously with meeting electric and contractual loads.As explained in Section IV-C, the hydrogen production has the highest priority.Then, the achieved optimal (C HLC LOH ) * in the hydrogen storage unit is used as a hard constraint in the second stage problem which addresses the participation in the electricity market and the load tracking demand.Regarding  the main objective of HLC, over the control horizon H , the exchange of energy and hydrogen correctly meets the requested demand by the external agents, as shown in Fig. 14.
In order to maintain the ability to manage the system autonomously, simulations under stressing plant scenario of multi-level MPC have been provided in Figs.15-17, where the control response over time of the hydrogen storage, the load tracking, and the electricity buying/selling events with the utility grid are illustrated.It is worth pointing out that the LLC meets the references that are set by the HLC, and successfully maximizes revenues.However, being autonomous it can correct the energy scenario in case deviation exists in real-time due to the intermittent nature of the wind generations when compared to the forecast generation.

C. Comparison With Relevant Strategies
In order to show the effectiveness of this research, this section performs a comprehensive comparative analysis between the technique proposed in this study and the related methodologies in [45] and [46].In view of this, an MPC Authorized licensed use limited to the terms of the applicable license agreement with IEEE.Restrictions apply.

TABLE IV
COMPARISON BETWEEN THE FEATURED CONTROLLERS ( * ) VS. [45] AND [46] Fig. 17.Control response of the utility grid for cascaded MPC.strategy of a wind farm and PV panels connected to the grid and equipped with hybrid-ESSs has been developed in [45].Then, the microgrid includes wind and solar energy as RESs.Their methodology aims at optimizing the revenues of the wind-solar microgrid by allowing the exchange of electricity in the energy market.It is important to highlight that the degradation issues have been addressed, while other aspects, such as the limited available working cycles of the hydrogen devices, the integrated HW and SW control architecture, and the islanded mode are not considered in their controller, which is, conversely, an integral part of this paper.The authors in [46], instead, have developed a lab-scale microgrid at the University of Seville in Spain in order to verify an MPCbased methodology for the interaction with external agents.The strategy considers the best time period in which to refuel the FCEVs based on lower prices, but the authors seem not to address all (or several) of these above mentioned aspects in a unified way, as in our proposed control platform.Starting from our previous results [12], [32], [42], in this paper we propose the integrated HW and SW control architecture we designed for the Raggovidda (Norway) wind farm, which features the control algorithms dealing with the three use cases mentioned before.The comparison of our controllers with the two other mentioned approaches in the literature ( [45], [46]) is summarized in Table IV.It is possible to see that our approach introduces more logical variables since it details the models of the electrolyser and the fuel cell considering not only the ON and OFF states, but also the STB (standby) and related transitions.For the short time scale of the lower level, the further state transitions of warm and cold start are also included.This allows not only to better model the equipment behaviour, but also to mitigate its degradation.Indeed, it is worth noting that the costs due to the OFF-STB/ON-STB transitions are lower than the ON-OFF/OFF-ON transitions.Consequently, the proposed strategy extends the equipment lifespan.Despite a greater number of logical variables, 120 in our case, when considering the numerical test, our strategy results to be solved with less computational time than those in [45] and [46].This is due to the fact that of these logical variables, only 37 at most are Boolean (as per Table IV) while the others are continuous in the interval [0, 1] but, according to the considered formulation, assume values only at the extreme points of this interval.

VI. CONCLUSION
In this paper, we presented the architecture of the control platform of a HESS integrated with a wind farm, and connected to the main grid, however, with a strongly limited powerlink.The control platform includes the management software, the control algorithms, and the automation technologies operating the wind farm according to the three use cases identified by the IEA.Different control objectives/multi-objective optimizations have been taken into account.Specifically, a control algorithm based on switching functions implements multiple control strategies, one for each of the three use cases.For each of them, dedicated strategies are developed, optimizing operation bringing into account uncertain weather and power-price forecasts and considering the constraints for the specific operating mode.The paper proposes the description of the ICT architecture of the control systems implemented in the EU project plant, which includes an algorithm whose goals are the following: 1) to find the optimal value for the power smoothing for electricity storage; 2) to store the hydrogen production surpluses by wind generation and use them to provide a DSM solution for energy supply to the local load, both in grid islanded and connected modes, according to the goals indicated in mini-grid; 3) to provide hydrogen to consumers as per fuel production; 4) to compute the optimal scheduling of the unit based on a plant supervisory data flow.When regarding the scalability, our approach can definitely be adopted to bigger plants (bigger wind farm, hydrogen electrolysation/consumption).When such increase in the plant dimension is reached with an increase of the equipment (and if such equipment are independently handled) numerical convergence problems of the controller might arise due to the increase in the decision variables.Nevertheless, this problem can be worked around if aggregated values of hydrogen production, consumption, and storage are considered.Lower level controllers might then be devoted to the managing and allocation of the control requests on the single units (for example, a dedicated controller for hydrogen production could then handle the different electrolysers it manages in order to satisfy the hydrogen production requests computed by the controller proposed in this paper).
at the time-instant m + j, with m the current control time-step and where δ e (m + j) and δ f (m + j) are the vectors of all the logical variables linked to the states of the hydrogen devices automata, respectively.All the other vectors (in bold) are similarly defined.Then, the problem ES.1 is recast as wAVG *
net hydrogen storage power.

Fig. 8 .Fig. 9 .
Fig. 8. Net hydrogen storage power P LLC H 2 = P LLC e − P LLC f over time.

Fig. 16 .
Fig. 16.Control response of the load tracking for cascaded MPC.
State transition from state α to state β of device i.
i Cold starts power of device i [kW].
k LLC P e , and k LLC LLC LOH are weights, and G LLC (m + j) follows the same rationale as in the mini-grid use cases, i.e., either it is similarly defined to G HLC (m + j) (of the fuel production use case) in case real-time prices are available or it tracks the HLC schedule P HLC g,sell (h) * and δ HLC g,sell (h) * * and C HLC LOH (h) * , respectively.