Optimal operation of the hydrogen-based energy management system with P2X demand response and ammonia plant

• Energy management system that uses P2X demand response to improve system operation. • Two operational objectives for minimizing system cost or maximizing green hydrogen. • A detailed model of ammonia plant participating in the P2X demand response. • Cost-benefit analysis regarding economic viability of the ammonia plant.


Introduction
Hydrogen has recently attracted a lot of attention as a key element for making energy systems more sustainable. The ability to use excess electricity generated by uncontrollable renewables for hydrogen production makes it a great tool for maintaining balance in the electric power systems (in addition to demand response (DR) and the use of energy storage). Generated hydrogen could be further used in the sectors that are currently difficult to electrify like aviation, shipping, and steel manufacturing [1] bringing even more environmental benefits.
Integration of the hydrogen energy vector with the electric power system is typically done through electrolyzers -devices that use electric current to decompose water into hydrogen and oxygen. In many cases, renewable generation, electrolyzers, and other electric loads are controlled by an energy management system (EMS), that operates components in accordance with the common objective such as minimization of energy consumption (through maximization of energy efficiency and reduction of wasted energy), operational costs reduction or CO 2 reduction. The resulting system could be considered as a microgrid since all the energy exchange is handled by the EMS.
As would be shown further, the majority of the research and industry focus is dedicated to the control of electrolyzers as the components linking electricity and hydrogen energy vectors together. The hydrogen in these works is either produced for powering fuel cells (i.e. to partially cover electricity demand) or sold to the external hydrogen market. Hydrogen demand from actual industrial plants is rarely considered, which leaves out the possibility to explore coordination of the hydrogen production and consumption together. We believe, however, that the ability to adjust the consumption behaviour of the hydrogen consumers to better fit either renewable generation or electric loads could significantly increase the performance of the hydrogen-based EMS similar to the benefits brought by consumer flexibility from other sectors (e.g. electricity, heat). This paper 1 aims to address this gap and proposes an EMS that integrates hydrogen production with renewable generation and uses flexibility from conventional DR and Power-to-X (P2X) DR of hydrogenconsuming plants (HCPs). Proposed EMS is designed based on the system of GreenLab Skive (GLS) [2] -an industrial cluster in western Denmark with renewable generation, electric battery, electrolysis plant, industrial plants, and HCPs. We will show the benefits of coordinated control of both hydrogen production and consumption following either economic (EC) or sustainable (SU) objectives using two GLS' configurations. The first configuration includes all of the existing components, while a new ammonia HCP is added to the already existing components in the second configuration. The inclusion of the ammonia HCP is further analyzed from the economical perspective. To summarize, the main contributions of this paper are as follows: • We proposed EMS for controlling existing and potential components at the industrial cluster of GLS -referred by some as the first green industrial business park; • We used P2X DR from HCPs present at GLS to enhance the flexibility potential of the system and improve overall results; • We integrated a detailed model of ammonia HCP into EMS to show the limitations real industrial process imposes on the flexibility from P2X DR; • We analyzed the benefits GLS receives from following either EC or SU schedule produced by EMS for two configurations; • We performed a cost-benefit analysis determining the economic viability of the construction of ammonia HCP at GLS.
The paper is structured as follows: Section 2 describes state-of-the-art regarding hydrogen-based EMS. Section 3 provides a description of the GLS, the default operation of its components, and flexibility potential. Modelling of GLS components is described in Section 4. Proposed EMS is presented in Section 5 together with detailed explanations of how its operational objectives are formulated. Results of the simulations for two configurations -with and without ammonia HCP are shown in Section 6 together with the sensitivity analysis, while the cost-benefit analysis dealing with estimating the profitability of the ammonia HCP is given in Section 7. Finally, conclusions are drawn in Section 8.

State-of-the-art
This section will briefly present the state-of-the-art concerning the following topics: hydrogen-power system integration and its objectives; effects of consumer flexibility; EMS in industrial clusters; and EMS optimization algorithms. Some currently ongoing hydrogen projects are mentioned as well.
Hydrogen and power system integration presently is a hot topic and is addressed in many scientific works. [4] provides a comprehensive review of the recent publications regarding hydrogen in the smart grids, and groups papers into categories based on the studied aspect of integration: hydrogen and renewable energy, hydrogen economy, hydrogen EMS, etc. In [5] a method to couple electrolyzers with the hydrogen storage tank (HST), electric battery, wind turbines, and solar panels had been demonstrated using the experimental platform to increase energy efficiency and hydrogen utilization rate and reduce the probability of loss of load. [6] investigated how the system with electrolyzer, fuel cells, renewable generation and storage can be used to provide green power supply to small-scale loads. The paper shows the monetary benefits of system integration, in particular highlighting the role of HST in decreasing the operational costs. In [7] hydrogen production and HST were used in order to reduce the excess electricity produced in the microgrid and optimize the bidding process in the electricity markets.
The results indicate that HST plays a large role in reducing the operational costs of the system and the amounts of curtailed energy. Other papers investigating various combinations of electricity and hydrogen components to achieve system objectives are found in [8][9][10].
In addition to optimizing the production side of the hydrogen-based EMS (controlling electrolyzers together with storage operation), consumers can help to improve system performance by providing flexibility. [11] describes the methodology for determining the flexibility potential of an industrial consumer with electricity and heat energy vectors through the use of historical measurements and probability distribution. Though the methodology does not include hydrogen consumers, similar approaches could be applied to them if sufficient data is available. A hydrogen-based EMS that combines conventional DR from electric loads was explored in [12]. DR is used to reduce the peak consumption by modifying the load curves of the consumer. [13] describes the effect of the conventional DR on investment costs of the hydrogen-based EMS and HST. Introducing DR is shown to reduce the size of HST needed for system support. In [14] the framework for evaluating the effect of flexibility from different energy sectors including P2X is considered. Paper discusses the potential of each flexibility type to provide operational cost reduction and shows that in the future P2X and Vehicle-to-Grid (VtG) flexibility will become the main factors in such reduction.
Industrial clusters or industrial parks are natural choices for the introduction of EMS. Up to now, very few studies could be found investigating the EMS for the industrial clusters with hydrogen energy vector (and HCPs). Instead, some of the papers discussing industrial clusters with electricity consumers are mentioned here and in the majority of the papers, the cluster is treated as a microgrid. A microgrid system consisting of wind turbines, solar panels, fuel cells, battery, gasturbine, and gas and electric boilers is considered in [15]. The model aims at ensuring a stable power supply for all loads, reducing the amounts of switchings in the AC/DC converter and decreasing the cost of electricity generation in the case of islanded mode. [16] proposes a new microgrid EMS with both AC and DC types of components that is capable to include VtG technology and shows its potential application for the industrial park of Qingdao, China. The system can help to reduce the energy costs and provide DR by peak shifting. Another EMS is proposed in [17] for an industrial cluster with power and gas energy vectors supplying electrical, heat and cold loads. DR is provided by the whole cluster based on signals from external electricity and carbon emission Vehicle-to-Grid 1 The short version of the paper was presented at ICAE2020, Dec 1-10, 2020.
This paper is a substantial extension of the short version of the conference paper [3].
markets. DR is shown to increase the cost of system operation and maintenance, while providing higher revenues from trading at these two markets.
Optimal operation of the EMS represents a mathematical optimization problem, with some examples of algorithms and their objectives mentioned below. [18] discusses the EMS of islanded energy hub where hydrogen production and storage are coupled with renewables as a way to achieve reliable and economic operation. The uncertainty in the renewable generation outputs is addressed through chance-constraint optimization formulation. The optimal control of the system is done by day-ahead scheduling based on forecasts to establish the reference trajectories for EMS to follow and local model predictive control scheme to compensate for the errors in forecasts. Particle swarm optimization algorithm is used in [19] for both investment and operational planning. First, the optimization decides the power rating of the electrolyzer and the capacity of the HST that will be used to produce hydrogen from excess renewable generation and store it. Then, the second optimization is used to determine the hourly operation of components, with electrical loads supplied by both local renewables and hydrogen through fuel cells. A superstructure optimization model based on the mixed-integer linear programming (MILP) is applied to optimize renewable-based hydrogen production system in [20]. The model determines both system composition and its operation choosing from the wide range of components from different energy vectors. Results show that overproducing electricity and selling it to the upstream network is in some cases more beneficial, than using this electricity for hydrogen production. Fuzzy logic-based EMS with hydrogen production is proposed in [21] for keeping power balance in the microgrid and reducing the need to purchase power from the external network. More optimization methods used in systems with hydrogen could be found in [22][23][24].
In addition to the ongoing research activities, a number of hydrogenbased projects have been recently launched by industrial companies. Danish energy company Ørsted is involved in a project where offshore wind farms are used to generate green hydrogen for road transportation [25,26]. A consortium of 30 partners including gas companies, electrolyzers' manufactures, and solar panel developers are involved in the "HyDeal Ambition" project, which will produce green hydrogen using solar power in multiple locations across Europe [27]. More hydrogen projects are discussed in [28].
As was already mentioned in the introduction, after reviewing recent publications regarding hydrogen-based EMS, we concluded that the focus is still mainly on optimizing the performance of electrolyzer and the storage, with some form of conventional DR from components of electricity and heat sectors. To address this gap, we aim at exploring the consumption side flexibility of HCPs and see the combined effect of production and consumption flexibility on the system's performance.

System description
GLS is an industrial cluster built with the concept of industrial symbiosis [29], where the by-products of one plant (e.g. waste heat) are utilized at another, thus reducing overall wasted energy.
Currently, GLS has seven industrial plants that are either already operational or in the process of being constructed. These plants produce oil from pyrolysis, methanol, compressed hydrogen, hydrogen, methane from biogas, marine protein for feeding livestock, and recycled waste. Primary and additional energy vectors used in each plant are shown in Table 1. Pyrolysis, hydrogen compression, and methanol plants are using hydrogen vector and would be referred to as HCPs later on. An ammonia plant is a potential addition to the already existing HCPs at GLS and its potential to contribute to the system's flexibility would be investigated in the paper.
Hydrogen for HCPs is produced at the 12 MW electrolysis plant with multiple medium-scale electrolyzers.
Electricity demand from industrial plants is partially covered by renewable farm comprised of multiple solar panel arrays and 13 wind turbines with the peak production of 27 and 54 MW, respectively. Excess renewable energy is sold to the upstream system. Electric power can also be purchased from there when renewable generation is not sufficient to cover GLS' demand.
There are two storage components: a large 1.6 MWh electric battery is installed at GLS to provide backup, and a HST is used for storing produced hydrogen before it is used by HCPs.
The sizing of the plants and storage components had been done by their respective owners and is considered to be known. The only exception is currently constructed HST for which no capacity data is available. In this paper we assume that it can store up to 7000 kg (7 t) of hydrogen, which should be sufficient to cover demand from HCPs (including ammonia HCP) for two days. The size of the ammonia HCP in this work was scaled based on the overall electrolysis plant' capacity, considering that part of this capacity should be reserved for other HCPs. More information about consumption rates based on the sizing is shown in Table 2.
Due to the multiple energy vectors interacting with each other GLS Table 1 Overview of industrial plants at GLS. represents an interesting case for designing an EMS. In this paper, we chose to focus on the electricity and hydrogen vectors to improve the system's performance.

Default operation and flexibility potential
All industrial plants at GLS are operated in accordance with their predefined production goals -we referred to such operation schedule as default (DEF) schedule. We assumed that the DEF schedule for a plant is defined at 12:00 the day before for the 24 h of next day starting from 00:00). Actual working hours could either be 8 or 24 h depending on the plant and the type of industrial process it employs. Table 2 gives an overview of the plants' working hours and the approximate hourly consumption rates for the electricity and hydrogen energy vectors they use. The type of operation determines how the energy vectors are used: with the "constant" operation the energy is consumed at the constant rate during the whole working time, while for the "follow demand" operation of electrolysis plant and hydrogen compression HCP the hourly consumption rates shown in the Table 2 are maximum rates and the consumption varies based on the load (for electrolysis plant based on HCPs operation, for hydrogen compression HCP based on the availability of the trailers). Since no information about the energy efficiency of different plants is available, all the energy is assumed to be used in the production processes.
If the DEF schedule of the plant can be changed by changing its hourly consumption rates at certain times, such plant can be used to provide DR flexibility to the system of GLS. EMS we propose in the further sections will adjust the DEF schedule in such a way so that the daily amount of consumed electricity/hydrogen stays the same. This ensures that all industrial plants can support the overall system without jeopardizing their own production goals or incurring any economic losses.
Due to the constant operation at maximum power, no flexibility can be gained from the recycle and biogas plants, and therefore they are treated as uncontrollable electric loads. A marine protein plant, on the other hand, has the ability to provide conventional DR to the system of GLS.
Four HCPs -pyrolysis, methanol, hydrogen compression, and ammonia plants can also be operated with some flexibility. Due to the large difference in amounts of consumed electricity and hydrogen, the potential of these HCPs to provide P2X DR is much greater than conventional DR. Changing hydrogen consumption of HCPs will allow the electrolysis plant to increase/decrease its hydrogen production and therefore increase/decrease its electricity demand. This concept would be further described later.
Hydrogen compression HCP differs from the rest of HCPs in regards to its flexibility potential. There are two trailers that come to the hydrogen compression HCP daily and are charged with hydrogen for 4 h each. Therefore, for such HCP the hydrogen consumption cannot be changed, but rather shifted in time in blocks of 4 consecutive hours.
The exact flexibility potential of the plants at GLS is unknown due to the lack of data (like ramping constraints, number of activations per day, minimum and maximum variable load). Therefore flexibility potential in Table 2 is estimated based on the internal data from GLS, type of operation and the hourly consumption rates. For the plants with low and medium flexibility potential, we considered a change of consumption within 80-120%. For the plants with high flexibility potential an operational range of 0-100% had been considered (for electrolysis plant this range is continuous, while for the hydrogen compression HCP the range is binary: either 0% or 100%). There are no limitations on how often the flexibility can be provided. The only constraint is that the total consumed energy should stay the same.
In DEF schedule storage components like the electric battery and HST are considered to be backup. They are charged until a certain point and used to support current operation.

Modelling of components
The EMS proposed in the next section uses the signals from the components at GLS. To be able to show the benefits of the EMS, we modelled these components using the equations below.

Wind turbine
The power output of an individual wind turbine P w at any moment t is determined by the wind speed v [30]: where P w f , P wr -power generated by a wind turbine at below rated and rated wind speeds, respectively, [W]; v, v ci , v co , v r -current, cut-in, cut-off and rated wind speed, respectively, [m/s].
How much power wind turbine produces at below rated wind speed is determined by the cubic law [31]: where ρ -air density at the hub height, [kg/m 3 ]; A w -wind turbine swept area, [m 2 ]; C p -power coefficient of the wind turbine, estimated to be equal to 0.42 from [31], [-]. In Eq. 1 the wind speed v is the speed at the blades of the wind turbine. However, commonly the wind speed is measured near the ground. Eq. 3 provides an expression to convert wind speed at the ground v g to the speed at the blades v: where v g -wind speed at the ground, [m/s]; h, h g -height at the wind turbine's blades and ground, respectively, [m]; α -Hellman friction coefficient of the surface roughness, value of 0.16 was used in this paper [32], [-].

Solar panel array
The power output of the solar panel array P s at any moment t is determined as follows [31]: where

Electrolysis plant
The electrolysis plant at GLS has multiple electrolyzers. In this work, we chose to treat them as one large electrolyzer. At any moment t it consumes electric power P ele to produce hydrogen from water according to the following expression: Typically, the hydrogen produced by electrolyzers has to be compressed before it can be stored at the HST and consumed by HCPs. If an adiabatic compression process is used, the compressor would consume: where

Pyrolysis, methanol and hydrogen compression HCPs
For the operation of pyrolysis and methanol HCPs we assumed a linear dependency between consumed electricity and hydrogen. Exact parameters were taken from GLS reports. Power consumption of the hydrogen compression HCP is determined by Eq. 6.

Ammonia HCP
Models used for the pyrolysis, methanol, and hydrogen compression HCPs are somewhat simplistic and only allow to estimate the ideal P2X flexibility with no ramping up/down constraints. To see the effect an actual industrial process would have on HCP' ability to provide P2X DR we have modelled ammonia HCP in a more detailed way. Ammonia HCP employs a Haber-Bosch process to convert hydrogen and nitrogen into ammonia. Reactions require high temperature (which assumed to come from the heat energy vector and thus not included into the model) and pressure: where ΔH ∘ -change in enthalpy, a negative value means that heat is released during this reaction, [J/mol]. Required nitrogen N 2 is typically obtained from an air separation unit that consumes electricity. In addition to that electricity is used to compress the inlet gases, because high pressure is necessary for the acceleration of the ammonia synthesis reaction. Therefore, the main power demand for an ammonia HCP could be formulated as: where P a -power consumed by ammonia HCP, [W]; P asu and P a,c -power consumed by air separation unit and compressor based on the ammonia mass flow rate, [Wh/kg]; ṁ a -ammonia production rate, kg/h. P2X flexibility potential of the ammonia HCP is limited by its physical properties and in general, the plant is much less flexible than the electrolysis plant. Parameters affecting ammonia HCP's flexibility are ramping up/down rates, partial load ranges, cold stop load, and cold stop minimum duration. We summarized parameters for ammonia HCP in Table 3 based on [34]. How exactly these parameters are considered will be explained in the next section describing problem formulation.

Storage
Storage is represented by two components -the electric battery and HST.

Electric battery
The state of charge (SoC) defines how much power is currently in the battery [35]. Eq. 9 shows how SoC changes from time t − 1 to t: where P b -battery power, [W]; Q b -maximum battery capacity, [Ah].

HST
The initial amount of hydrogen inside HST is M H2,0 , while the change in the amount of stored hydrogen from time t − 1 to t can be expressed from [36] as: where M H2 -the amount of hydrogen in the HST, [kg]; n H2,ele and n H2,hcpflow rates of hydrogen coming from electrolysis plant and to HCPs, respectively, [kg/s].

Energy management system
This section presents proposed EMS and describes its interactions with the components of GLS. Additionally, the section shows problem formulations used for optimizing the system's behaviour in EC and SU objectives.

EMS layout and interactions with GLS components
The aim of an EMS is to provide coordinated control of its components based on the selected objective. We propose the EMS shown in Fig. 1 that controls all the components at GLS and changes their DEF schedules in accordance with either the EC objective -minimizing system's operational costs, or the SU objective -maximizing green hydrogen production. Both objectives involve aligning the power consumption of the industrial plants with renewable power generation.
The EMS consists of several blocks (shown on the grey background). The first one is the EMS data collection block and it serves as an input interface to connect EMS with the components of GLS (information streams are shown as arrows with circled numbers in Fig. 1). The next three blocks represent different operation objectives: DEF, EC and SU. The flexibility estimation and the optimal schedule blocks are only used if either EC or SU objective had been selected, with the latter block serving as an output interface sending the optimal schedule defined by the EMS to the flexibility components.
Since different plants at GLS are owned by different entities, we consider that EMS would be controlled by an independent operator that will receive information from each individual plant, but will not share it with other participants. The agreement regarding sharing their DEF schedules could be made a condition for becoming a part of the EMS and getting benefits from an optimized operation. The contribution of each plant to the value creation from forming and following the optimal schedule should be evaluated and quantified by the EMS operator and is out of the scope of this paper.
To generalize EMS interactions with different components, components at GLS are grouped into five categories based on their type and flexibility potential. All the components should send some information to the EMS data collection block in order for EMS to optimize system's performance. The type of information varies between categories -some data could be fixed (e.g. production schedules), while some data represent only forecasted values with certain accuracy (e.g. renewable power generation, electricity prices). All information from the plants, forecasted renewable generation and day-ahead electricity prices should be provided for the period of next 24 h the day before (e.g. information for next 24 h period starting from 00:00 tomorrow should be sent at 12:00 today).
Renewable farm with solar panels and wind turbines should send information regarding its forecasted power generation for the next 24 h. Production of the renewable farm is not controlled by the EMS. Biogas and recycle plants are uncontrollable loads, whose DEF schedules also cannot be changed by the EMS. These plants should send their forecasted power consumption to the EMS, which it should satisfy. As was already mentioned before, these two plants are constantly operated at maximum capacity and therefore there is very little uncertainty in regards to their power consumption. The external network component represents a connection to the upstream electric power system that sends forecasts for the day-ahead electricity prices to the EMS.
The last two categories are electrical and hydrogen flexibility components -these components have flexibility potential and their operation could be adjusted by the EMS to follow the selected objective. Electrolysis plant, marine protein plant, and electric battery are part of the electrical flexibility components -the change in their operation schedule will directly affect how much electric power is consumed. Hydrogen flexibility components include HST and HCPs such as pyrolysis, methanol, hydrogen compression, and ammonia plants. Change in the operation of these components does not bring significant electrical flexibility, since the hourly electricity consumption rates of these plants are small. However, the change in hydrogen demand from these plants will affect how much electrical flexibility an electrolysis plant can utilize.
Operating the system in accordance with different objectives requires different information streams as shown in Fig. 1. In the DEF objective, each industrial plant follows its own DEF schedule and the EMS only needs information regarding their power consumption (streams 3-5) to be able to satisfy the electrical demand. Choosing either EC or SU objective will require the EMS to adjust production schedules. This is done by estimating flexibility potential from both electrical and hydrogen flexibility components (information streams 4-7 in Fig. 1) and generating an optimal schedule for them.
Making an optimal schedule based on the selected objective is an optimization problem. The following subsections show how two optimization problems for EC and SU objectives were formulated as MILP problems with constraints imposed by different components. The integers were introduced to account for the special working schedule of trailers at the hydrogen compression plant (4-h consecutive operation, no simultaneous operation allowed). This type of optimization could easily be solved by off-the-shelf solvers and in this work we used the Gurobi solver.

Economic objective
In the EC objective EMS optimizes GLS' operation to minimize system's operational costs. These costs include cost of purchasing electricity from external network and renewable farm, payments for the conventional DR provision from marine protein plant and for P2X DR from HCPs, and the cost of using hydrogen stored in the HST. An objective function is shown in Eq. 11.
where P ext , P w , P s -power from external network, wind turbine and solar panel array, respectively, [W]; ΔP hcp , ΔP m -change in power consumption due to P2X DR from HCPs and conventional DR from marine protein plant, respectively, [W]; C ext , C w , C s -cost of electricity from external network, wind turbine and solar panel array, respectively, [€]; C hcp , C m , C H2 -cost for providing DR from HCPs, marine protein plant and cost of hydrogen from HST, respectively, [€]; WT, SP, HCPs -maximum number of wind turbines, solar panel arrays and HCPs (including ammonia plant), respectively, [-].
Based on this objective function, EMS will make a schedule, where electrical and hydrogen flexibility components consume maximum power in periods with low electricity prices and/or abundant renewable electricity generation. EMS will also decide whether it is more beneficial to run an electrolysis plant to satisfy HCPs' demand or take hydrogen stored in the HST. This decision would be based on the difference between the current electricity price and the opportunity cost of using stored hydrogen, which is equal to the cost of hydrogen production.
Payments for DR are used to compensate the flexibility components for any losses they incur by providing flexibility. These payments are mostly zero, since all components belong to the same system and operated in the way that their total daily energy consumptions remain the same. In addition to that, models used in this work do not allow to accurately estimate the efficiency that could be lost due to DR provision. However, if there is a positive difference between the cost of operation with the new schedule compared to DEF schedule (i.e. the plant has to pay more for the required electricity or hydrogen vectors with the new schedule), this difference is included into operational costs. The new schedule for the hydrogen compression HCP may involve operating it outside of its normal working hours. This will incur extra costs for the evening/night work for the staff and should be compensated as well.
Objective function in Eq. 11 is subject to both general and component-specific constraints.

Energy balance constraint
where P ul -power from an uncontrollable load -either biogas or recycle plant, [W]; UL -total number of uncontrollable loads connected to EMS, [-].

Marine protein plant constraint
Constraint in Eq. 13 states that the power consumption of the plant providing conventional DR should stay the same in both DEF schedule and optimal schedule OP:

HCPs' constraints
This constraint ensures that the total daily hydrogen consumption of any HCP stays the same in both DEF schedule and optimal schedule OP: Set of constraints in Eq. 15-25 is used to restrict the shift in operation for the hydrogen compression HCP to the 2 blocks of 4 consecutive hours each.
Binary variables y t1 and y t2 indicating charging state of the first and second trailer at the hydrogen compression HCP had been introduced. These binary variables take the value of 1, if the corresponding trailer is in the charging state, or 0, otherwise.
Eq. 15-16 restrict the charging duration of both trailers to the amounts of hours equal to T charging : ∑ T t=1 y t1,t = T charging (15) ∑ T t=1 y t2,t = T charging (16) where y t1 , y t2 -binary variables representing charging state of trailers one and two, [-]; T charging -total charging time of each trailer, set as 4 h in this paper, [h]. Additionally, Eq. 17 restricts the charging process to only one trailer at a time: In order to ensure that the charging process is consecutive, another set of variables z t1 and z t2 is introduced. These variables at time t are expressed as: where z t1 , z t2 -binary variables representing signals of transition from one state to the other (e.g. from charging to idle state), [-].
Variables z t1,t and z t2,t are subject to: Constraints in Eq. 20-21 guarantee that the state of each trailer is not changed more than twice thus ensuring a consecutive process. Eq. 18-19 are non-linear, but could be further expressed by their equivalent linear forms as shown in Eq. 22-25 for trailer 1: where z is a new binary variable, [-]. The same constraints could be written for trailer 2.

Ammonia HCP' constraints
The constraint in Eq. 26 ensures that the ammonia production of the ammonia HCP stays the same regardless of the EMS actions. Constraint in Eq. 27 limits the rate of change in consumed power, while Eq. 28 defines the variable load range.  Table 3 is not modelled in this paper, because only single-day operation of the components is considered (while the cold stop duration is minimum two days). However, it could be easily added to the work through the introduction of binary variables similar to how it was done in the previous subsection.

Storage constraints
Following equations define initial SoC of the electric battery SoC ini , initial amount of stored hydrogen at the HST M H2,ini , and storage operational limits: where SoC min , SoC max -minimum and maximum SoC of the electric battery, [-]; M H2,min , M H2,max -minimum and maximum amount of hydrogen that could be stored in the HST, [kg].

Sustainable objective
With the SU objective EMS operates the system to maximize its green hydrogen production. This is done by ensuring that the electrolysis plant is primarily consuming electricity generated by the renewable farm. Objective function in Eq. 33 is set to maximize the power consumed by an electrolysis plant from renewable electricity P ele,g with constraints limiting the values P ele,g can take: Due to the constraint in Eq. 34, EMS will use the flexibility from electrical and hydrogen flexibility components to "free up" some renewable energy for the operation of an electrolysis plant. In addition to this constraint, the objective function in Eq. 33 is subjects to all the constraints in Eq. 12-32 described in the previous subsection.

Results
In this section, we present the results showing how operation schedules of the components at GLS are changed by the EMS. The results are given for two configurations: configuration 1 includes all the existing components at GLS without ammonia HCP, configuration 2 -existing components together with ammonia HCP.
Performance of the EMS is analyzed using four scenarios shown in Table 4. Each scenario lasts one day starting from 00:00. Weights of scenarios represent the number of days with a similar pattern in one leap year (366 days). To calculate these weights a K-means clustering algorithm was applied to the data with two features: day-ahead electricity prices and the amounts of renewable generation. The number of clusters was predefined, by using data for the days selected as scenarios as centroids of the clusters. Values for renewable generation and electricity prices used for scenarios and calculation of weights are based on real data found in [37,38] and are shown in Figs. 2,3.
In the scenarios a perfect forecast of the renewable farm generation and day-ahead electricity prices had been assumed. To account for potential errors in the predictions, a sensitivity analysis had been performed and described at the end of this section.

Configuration 1 -without ammonia HCP
The results of the simulations without ammonia HCP in configuration 1 are summarized in Table 5 (full version of this Table could be found in the Appendix).
With the EC schedule EMS operates the system of GLS with the lowest total operational costs in all scenarios. In scenarios S3 and S4 with high amounts of renewable generation total operational costs are negative, meaning that the revenues from selling renewable electricity to the external network are higher than the operational costs of running the Table 4 Overview of the simulated scenarios S1-S4.  system. On average EMS decreases the operational costs by 61.6% across all the scenarios following EC objective. Such a large reduction in the operational costs is achieved due to the flexibility from electrical and hydrogen flexibility components.
In the SU schedule EMS attempts to satisfy all hydrogen consumption demands using only green hydrogen. While the share of green hydrogen is improved in all of the scenarios, only in scenarios S3 and S4 with high amounts of renewable generation it is possible to achieve 100% green hydrogen production. Achieving this in other scenarios would require either charging the HST with green hydrogen beforehand or increasing the amounts of renewable generation at the renewable farm. On average the operation with SU schedule increases the share of produced green hydrogen by 37.6%. It should also be noted, that the total operational costs are also decreased in SU schedule compared to the DEF one, but not as much as in EC schedule.
The change in HST shows the difference between the amount of hydrogen at the beginning and the end of the operation. Initial amount of hydrogen M H2,ini = 3000 kg or 3 t and it does not considered green. With the chosen scenarios HST is actively used even in DEF schedule to support the operation. In scenarios with low electricity prices or a high amount of renewable generation more hydrogen is stored in the HST at the end of the day due to the actions of EMS.

Configuration 2 -with ammonia HCP
The results of the EMS operation in configuration 2 are summarized in Table 6 (full version of this Table could be found in the Appendix).
Similar to the configuration 1 results, in the EC schedule EMS achieves the lowest total operational costs. On average the operational costs are decreased by 51.5%. However, the operational costs are higher than in configuration 1 due to the addition of the ammonia HCP.
In the SU schedule EMS keeps the share of green hydrogen as high as possible. This is, however, more challenging with ammonia HCP than it was in configuration 1. GLS does not have enough renewable generation to produce 100% green hydrogen. By operating in this way on average EMS will increase the share of green hydrogen by 10.4%.
With the new ammonia HCP, the capacity of the electrolysis plant is not sufficient to satisfy all hydrogen consumption demand. This is indicated by the state of the HST that is being discharge in all the scenarios in all objectives (see the change in HST in Table 6 for DEF, EC and SU). Table 7 provides the overview of the effects ammonia HCP has on the EMS operation. Total operational cost without ammonia HCP is the cost of operation of all the plants without the cost of electricity and hydrogen consumed for ammonia production. Comparison of these values and the total operational cost in Table 5 confirms that the system operation becomes more expensive in the majority of the cases (highlighted with red color), except in scenario S2 and in DEF and SU schedules in scenario S4 (marked in green). This difference is likely caused by reduced revenues from selling renewable energy to the external network.
The last row in Table 7 shows the monetary effect of the P2X flexibility from ammonia HCP. While such flexibility leads to the reduction of the total operational cost, the effect is rather small. Therefore, the majority of the P2X DR potential observed from results in configurations 1 and 2 comes from the operation of other HCPs: pyrolysis, methanol, Table 5 Results of EMS operation in configuration 1 in S1-S4.  Table 6 Results of EMS operation in configuration 2 in S1-S4.  Table 7 Effects of the ammonia HCP on the EMS operation in configuration 2 in S1-S4. and hydrogen compression plants.
For the explanations of how operation schedules are adjusted by EMS we will use the results of scenario S4 with high electricity prices and a high amount of renewable generation.
Utilizing P2X DR from hydrogen flexibility components (Figs. 5-7) allows EMS to design an optimal schedule for an electrolysis plant shown in Fig. 4. In the EC schedule, the plant halts its hydrogen production in the periods of 06:45-08: 45, 11:45-13:30, and 17:45-21:45 when the amounts of renewable generation are not high enough and the electricity prices are too high to allow for an economically efficient operation. In the SU schedule the electrolysis plant is first operating using the combination of renewable electricity and electricity from the external network until ca 08:00, after which the amounts of renewable generation become high enough to supply the plant alone. At the end of the day, the hydrogen production of the electrolysis plant decreases following the decrease in renewable generation. It should be noted, that the potential performance and lifetime degradation of electrolyzer units at the electrolysis plant was not considered in this work, since the relations between operating conditions and degradation are very complex. However, studies in [39,40] suggest that avoiding the complete stop of electrolyzer by operating it with low load instead of zero might help to mitigate the effects of extra degradation. Fig. 5 shows aggregated hydrogen consumption of the pyrolysis, methanol, and hydrogen compression HCPs. In both EC and SU schedules, the operation of the hydrogen compression HCP is shifted to the evening and night hours (20:00 to 04:00) to take the advantage of relatively low electricity prices. In the EC schedule pyrolysis and methanol HCPs are operated with maximum hydrogen consumption until 12:00, after which their consumption rates decreased to lower levels. Some fluctuations of the hydrogen consumptions of these two HCPs are observed in the SU schedule and are due to the EMS trying to closely follow intermittent renewable generation. Introducing ramping constraints like in Eq. 27 will likely limit these fluctuations, but can negatively affect the results.
Operation of ammonia HCP is shown in Fig. 6. Halting hydrogen production of the electrolysis plant causes ammonia HCP to reduce its hydrogen consumption in the EC schedule. Due to the implemented constraints, changing the consumption takes time and is done in a stepwise manner. Operation constraints also prevent the appearance of short-term fluctuations observed with other HCPs. In the SU schedule ammonia HCP is operated at a maximum capacity until 20:00 to utilize the excess renewable generation.
Comparison of the electrolysis plant operation in Fig. 4 and the operation of HCPs in Figs. 5,6 shows they are somewhat decoupled from each other. This is due to the operation of the HST shown in Fig. 7. When the electrolysis plant halts the production in EC schedule, HCPs use the hydrogen stored in the HST and almost deplete it. The periods, when the electrolysis plant is operational, however, are used to charge the HST. In the SU the HST is used at the beginning of the day to aid the electrolysis plant to handle high demand of the hydrogen compression HCP and at the end of the day, when hydrogen production starts to decline.

Sensitivity analysis
Results shown in Tables 5 and 6 are made assuming perfect forecasts of the renewable farm generation and external prices from the dayahead market. To see the effect potential errors in these two forecasts will have on total operational cost and share of green hydrogen, additional simulations were performed. In these simulations, various combinations of sensitivity factors (multipliers of the original values used in each scenario from 0.8 to 1.2) had been considered. Results of the sensitivity analysis of configuration 2 in S4 with EC and SU objectives are shown in Figs. 8,9. Each point in these graphs is defined by two values, e.g. 0.8/1.1 which means that amount of renewable generation was only 80% of what was considered in S4, while the external electricity prices were 10% higher than in S4. Point 1.0/1.0 corresponds to the results shown in Table 6.
Sensitivity analysis for both objectives show the same trend. Total operational cost depends both on the amounts of local renewable generation and external electricity prices. An increase in either of these two factors causes a decrease in total operational costs, although the variation in the renewable factor seems to have a higher impact on the cost. The share of green hydrogen does not depend on the external prices and   only changes due to the change in the amounts of renewable generation.
From the sensitivity analysis we can conclude that for the EMS operation at GLS having a more accurate forecast of its own renewable farm is more important than forecasting external electricity prices. Of course, it could be different for other industrial clusters and systems, especially if the installed capacities of their renewable farms are not high enough compared to the overall electricity demand. Results for other scenarios show the same dependencies and will not be described in this paper.
Additionally, the effect of the initial amount of hydrogen in the HST at the start of operation was investigated for the fixed amounts of renewable generation and external electricity prices (both factors were set to 1.0). HST was charged to either 2000, 3000 or 4000 kg. We found that it only impacts the results in EC objectives: the higher the initial amount of hydrogen the lower the total operational cost and the share of green hydrogen become. So in order to maximize the economic performance of the GLS, it is better to charge the tank with more hydrogen, although some spare capacity should be left for hydrogen flexibility. There was no effect on either cost or green hydrogen share in SU objective, mainly due to the fact that we do not consider hydrogen stored in HST green (a second storage dedicated to storing only green hydrogen might be needed in order to avoid mixing it with grey hydrogen produced using external electricity in reality).

Cost-benefit analysis
In this section, we will present the results of the cost-benefit analysis that determines whether it is beneficial to invest in the construction of ammonia HCP. It should be noted, however, that due to a lot of uncertainties in regards to the prices and simplifications used in modelling of the system of GLS, this analysis can only serve as a guideline and not a precise tool in the decision-making process.
Investment decisions are typically based on the internal rate of return (IRR) calculated over a 10-year period. The targeted IRR for ammonia industry is between 10% and 20% [41,42].
IRR is computed using the information about cash flows for different years [43]. An initial cost for constructing the plant is referred to as capital expenditure (CAPEX) and is always negative. The operational expenditure (OPEX) is the combination of the costs for producing ammonia and revenues from selling it. OPEX can take both positive and  An estimation of the CAPEX for the construction of ammonia HCP based on different technologies is given in [44]: for the plant that uses hydrogen produced by electrolyzer the cost is 845 €/t. An ammonia HCP in this paper produces 20 t of ammonia daily or 7300 t annually, which makes the CAPEX = 6.17 M€. The most expensive part of the ammonia HCP is the electrolyzer, which constitutes up to 77% of plant CAPEX [45]. Since there is already an electrolysis plant at GLS, the initial cost of ammonia HCP becomes 6.17*(100-77%) = 1.42 M€.
Danish company Haldor Topsoe specializing in the design of the process plants with catalytic processes estimates that the ammonia selling prices for 2025-2030 would be in the range of 290-330 €/t [46]. With the average price of 310 €/t that accounts to 310*20*365 = 2.26 M€ of revenues from selling ammonia per year or 6.20 k€ daily. Total ammonia HCP's OPEX for scenarios S1-S4 is calculated as the difference between these revenues and the expenses for producing ammonia at GLS. The results are shown in Table 8. Expenses from producing ammonia are based on the results from simulations with configuration 2. OPEX becomes negative in scenario S2, meaning that the production cost of ammonia in this scenario is higher than the selling price.
Yearly OPEX of the ammonia HCP is calculated using the weights of different scenarios in Table 4 and assumed to stay the same for the whole 10-year period. The results of the calculations with IRR achieved with different schedules are given in Table 9. As could be seen IRR of the ammonia HCP is within the targeted values and the best IRR observed when the plant is operated with EC schedule. Therefore its construction is economically viable.
However, it should be noted that the construction of the ammonia HCP will affect the operational costs of the other plants in the system. If these costs are included in the IRR analysis the resulting IRR would be lower, which means that the ammonia HCP becomes less profitable.

Conclusions
In this paper, we proposed the EMS designed for controlling components at the industrial cluster of GLS. EMS controls the hydrogen production at the electrolysis plant and aligns it with the local renewable generation. In order to operate the system more efficiently, EMS utilizes the flexibility potential of the DR from conventional plant and P2X DR from HCPs. EMS can be set to operate components according to the three operational objectives: DEF, EC and SU.
We have demonstrated that the total operational costs of the system are lowest, when EMS operates with the EC objective. Similarly, with SU schedule the system maximizes the share of produced green hydrogen.
Comparison of the DEF operation with either EC or SU shows great potential of the flexibility from P2X components.
Two configurations of the system in GLS had been considered: configuration 1 contains the existing components, while configuration 2 includes existing components and ammonia HCP. Simulations indicate that the current capacity of GLS does not allow to efficiently integrate extra HCP due to the insufficient hydrogen production and low amounts of renewable generation. This reduces the efficiency of the proposed EMS in configuration 2 compared to configuration 1: 61.6% vs 51.5% of operational cost reduction and 37.6% vs 10.4% of green hydrogen share increase for configuration 1 and 2, respectively. In addition to this, the operational costs of other industrial plants are increased in configuration 2 as well.
Conducted cost-benefit analysis shows that the construction of ammonia HCP could be profitable even in the system with current capacity. It should be noted, however, that IRR of ammonia plant could be lower if the additional system expenses indirectly caused by the introduction of ammonia HCP are included in the calculations.
Although results shown in this paper are based on the operation of specific components found at GLS, we consider that the proposed EMS has a good replicability potential. It can still be implemented to optimize the performance of other industrial clusters and having HCPs providing P2X DR is not a requirement. EMS can operate the systems with just an electrolysis plant as an electrical flexibility component and a HST as hydrogen flexibility component, which is a relatively common setup for a system with hydrogen energy vector. Of course, the potential benefits from the optimized operation in this case would be lower, than in the systems with larger available flexibility. In addition to that, the presence of the renewable farm is also not required to utilize the proposed EMS: instead of relying on local generation, EMS can utilize the external electricity with the highest content of renewables in the SU objective. The daily production of ammonia HCP at GLS had been considered fixed in this paper, in order to focus only on the hydrogen production. For other industrial clusters that might produce both hydrogen and ammonia, operating proposed EMS with the SU objective will lead to maximizing the production of green hydrogen and consequently green ammonia. If this is not the goal, EMS from this paper can still be used with some modifications of its operating objectives.

Declaration of Competing Interest
The authors declare that they have no known competing financial interests or personal relationships that could have appeared to influence the work reported in this paper.

Table 8
Revenues, expenses and total OPEX of the ammonia HCP in S1-S4.