Presentation, Validation and Application of the EnergyProcess Library

Green production of hydrogen and its derivatives is becoming a cornerstone of industry decarbonation. Apart from the technological development point of view, optimizing the overall production chains dynamically is essential for the competitiveness of these systems. In this paper, we describe how we built, validated and used a Modelica-based library dedicated to the simulation and optimization of energy process for the production of green molecules. Especially, models of complex media, salt cavity hydrogen storage and electrolysis module are presented. An example application shows that the models of the library are particularly handy for the modeling of a 5MW electrolysis module, which is used for the calibration of an optimization model.


Introduction
Emissions reduction of industries such as petroleum refining or fertilizer production is challenging.Green hydrogen and its derivatives such as ammonia are expected to play a significant role in their decarbonation since alternative solutions are unavailable or difficult to implement.Currently, low-carbon hydrogen accounts for less than 1% of hydrogen production, but in the Net-Zero Scenario of IEA by 2050, it is expected to be massively used (IEA, 2022).However, green hydrogen production is about 6 times more expensive than traditional hydrogen production.Thus, in order to reduce the specific costs, very large plants are planned to be built (IEA, 2022).For these plants, optimizing the design and more specifically the operation with the use of software becomes then decisive for cost competitiveness issues.
Our research group is currently involved in several research programs devoted to the definition of optimal operation of production chains for green molecules.More specifically, these research programs aim at building Model Predictive Controllers (MPC) to be used in the Energy Management System (EMS) of such plants.In this context, we have been working on the development of accurate and efficient dynamic multi-physics models for which the objectives are two-fold: • The calibration of MPC models for the development of the EMS; • The evaluation of the EMS on a physical simulator.
The purpose of this paper is thus to present the EnergyProcess library and show its usage for optimization models development and validation.After the presentation of the context and objectives in the present section, the rest of the paper is organized as follows: • Section 2 presents a review of existing Modelica libraries for the modelling of energy processes dedicated to green molecules production; • Section 3 introduces the core of the library with special focuses on the media, electrolyzer and storage packages; • Section 4 highlights an example of model validation and usage for optimization purposes with the description of a 5 MW electrolysis module; • Section 5 summarizes the main messages of the present article and gives perspectives for the development roadmap regarding the library.

Review of existing libraries
Various Modelica-based libraries exist for the modelling of chemical energy processes with some library specifically dedicated to the decisive impact of the modelling of media.The present section displays a review of these existing libraries for media modelling on the one hand (see Table 1) and chemical processes system modelling on the other hand (see Among all the libraries, the most promising one for Media modelling is ExternalMedia (Casella, 2006).However, prohibitive calculation time, difficulties to generate Functional Mock Up (FMU) and limited mixture modelling capabilities with Coolprop (Bell et al., 2014) led to the decision to develop our own media package.Moreover, many different reasons led us to develop our own library of H2 components.First of all, the necessity to control the development, architecture as well as the components layout and complexity of the physics implemented combined with time and intellectual property constraints required by clients projects were hardly compatible with basing our library on an existing one.Second, another library on District Heating (Giraud et al., 2015) has been developed in our laboratory based on similar requirements and was used as a reference in the development of this library to ensure compatibility for complex system description.Lastly, open-source development requires development standards (naming, formulations, etc.) and community work not easily compatible with projects time constraints.Nevertheless, efforts are being carried to format the library (packages structure, modularity, coding standards, and internal documentation) in order to eventually release it as opensource.

Overall presentation
The CEA Energy Process library (CEPL) has been historically developed for hydrogen systems modelling following requests for the modelling of industrial systems.Nowadays the focus of the library is still largely on H2 models but NH3 models (synthesis reactor, complex media) are being actively developed to study power-togreen ammonia system based on an electrolyzer and a Haber-Bosh reactor.The CEPL, built with the software Dymola®, is compatible with the MSL library thus providing direct compatibility with another CEA library of models for district heating modelling named District Heating.(Giraud et al., 2015) The library is being actively developed on our internal forge using Git, therefore a methodology of continuous integration based on nonregression tests using the Testing library from Dassault (Hammond-Scott, 2022) is being followed.

Structure
The library is structured on packages, similarly to the MSL as depicted in Figure 1.The core packages are the Electrolyzers (FuelCell), Storage and Media packages.They will be further detailed in the present paper.The development of the package Reactor is still on-going with the objective to extend the library towards other green molecules such as NH3.The packages Machines, HeatExchangers, Condensers and GeneralCircuitry contain more traditional models oriented for use in a hydrogen system.Those models are similar to the MSL models but have been slightly modified either to increase computational speed or improve overall robustness.

Focus on Media package
The Media package is at the core of the present library.Media models must be numerically robust to avoid generating errors during dynamic simulation as well as fast, accurate, and capable of calculating the thermodynamic properties of the fluid over a wide range of pressures and temperatures.Models with best accuracy, such as models based on Helmholtz's free energy, suffer from slowness because they are computationally intensive.On the other end of the media model spectrum, there are fast models with few calculations but which are imprecise (ideal gas models).This observation is driving the development of new media models for CEPL.
The models of the Media package are divided into two categories: Monophasic and Diphasic media.Monophasic models are based on SRK (Soave Redlich Kwong) Equation of state (Soave, 1972), SBLT (Spline Based Look-up Table) (Ungethüm and Hülsebusch, 2009) or Helmholtz models using pressure and temperature as explicit variables.Diphasic models for pure substance are based on SRK, Helmholtz and SBLT as well using pressure and specific enthalpy as explicit variables.Mixture models are the most complex of all and involve several models.They are either based on SRK/PSRK models or in-house models (mixture NH3 / H2 / N2 or Moist gas) based on Henry and Raoult's laws coupled with correlations for the Vapour Liquid Equilibrium (VLE) calculation (Alesandrini et al., 1972;Reamer andSage, 1959a, 1959b;Sawant et al., 2006).The media composing the package are represented in Figure 2.

Focus on Electrolyzers and FuelCell packages
The Electrolyzers package is composed of three subpackages, each addressing a specific electrolyzer technology: PEM (Proton Exchange Membrane), SOEC (Solid Oxide Electrolyze cell) and Alkalin.The PEM subpackage has a dedicated electrolyzer model, which itself includes several replaceable physics package such as voltage, temperature, converter and mass flow models.The latter model structure is largely inspired by the model from Webster and Bode (2019).Figure 3 represents an extract of the PEM highlighting its "physics" package.Several voltage models are represented in the "physics" package ranging from activation loss, concentration loss and reversible potential up to aging model (Espinosa-López et al., 2018;Falcão and Pinto, 2020;Olivier et al., 2017).The aging model is an empirical model that takes into account the history of fluctuation of power output of the electrolyzer to determine voltage losses due to stack/cells degradation.The strength of this approach lies in its modularity allowing the user to easily change physical modules, insert its own or to fit parameters to match experimental data (as shown later in Section 4.2).The other subpackages SOEC and Alkalin share this modular approach with different physics.
The remaining of the main package is composed of auxiliary models such as deoxodryer, scrubber, lye-gas separation or water gas separation models to assist in the modelling of the balance of plant for each technology.
The FuelCell package is very similar in structure to the Electrolyzers one.It incorporates PEM (Proton Exchange Membrane) and SOFC (Solid Oxide Fuel Cell) models and uses the same modular structure than the Electrolyzers package.

Focus on Storage package
The Storage package includes a compressed gas storage to model type I to type IV composite tank (thermo-hydraulic modeling).This package includes as well an underground, salt-cavity based, storage model (Gabrielli et al., 2020).The particularity of this model is to represent the diffusion of gas through porous rock using Fick's law in a 1D model.It takes into account the viscosity of the gas as well as the tortuosity of the rock to model diffusion.Figure 4 represents a schematic view of the physical model.The first node is the underground storage cavern from/to which the gas can be extracted/injected.From node 1, the gas is allowed to diffuse to node 2 up to node n through Fick's law.Equations of diffusion are fully reversible and help representing the latency of back diffusion during extraction.The effect is particularly pronounced for long and thin cavern that are created by lixiviation in situ.

Other packages
The remaining packages are composed of models used in the balance of plant of hydrogen system.Most of those models are inspired by the MSL but modified for computational performances or stability considerations.Among those models, the modular, quasi static or dynamic heat exchangers model using the ε-NTU model as well as the compressor model stands out as the most complex.

Focus on Media package
As discussed in section 3.3, the media package is at the core of the EnergyProcess Library.A wrong choice by the user on the selection of the media model can lead to problematic physical results and/or extensive CPU time calculations.
Performances of the pure substance media models available in the EnergyProcess Library are studied on the classical use case of a fast filling of hydrogen tanks (Figure 5).The filling process consists of:  A hydrogen source at constant mass flow of 0.05 kg/s.
 A buffer (1 m 3 ) and a discharge valve opening at 150 Bar.
 A rack of hydrogen tanks with a total volume of 5 m 3 .
 The hydrogen source is piloted with a hysteresis loop to fill up the tanks at a maximal pressure of 750 Bar.
Simulations of the process are performed using the pure substance models composing the media package:  Monophasic and diphasic SRK models using a cubic equation of state.
 Ideal gas model from Modelica Standard Library.The obtained results are compared to a reference model from the ExternalMedia library (Table 1).Figure 6 shows the changes of gas pressure and gas temperature inside the tanks during the complete fast filling process with the ideal gas, monophasic SRK, monophasic Helmholtz and ExternalMedia hydrogen models.The CPU time with a Radau IIa solver required for the integration on the time simulation are also indicated.Classically, at high pressure and low temperature, ideal gas model is very imprecise in comparison to the three other models but it is very fast.ExternalMedia and Helmholtz models give similar physical results and CPU time calculations.This observation is logical because the ExternalMedia model is itself based on a Helmholtz formulation from C++ Coolprop library.Finally, SRK model is a very good trade-off between CPU time calculations and physical results.Table 3 gives the results for the six hydrogen models focusing on CPU time and the mass of hydrogen stored in the tanks at the end of filling process.ExternalMedia is used as the reference model to compare results.

5 MW PEM electrolysis module modeling
In this section, the EnergyProcess Library is used to develop a non-linear dynamic model of the Ex-2125D electrolyzer system manufactured by Plug Power (2023).This 5 MW electrolyzer module is composed of:  Five Allabash PEM (Proton Exchange Membrane) stacks originally developed by GingerELX.Each stack is considered to be composed of 154 cells of 1250 cm² in series operating on a nominal current of 3750 A (current density of 3 A/cm²), a pressure of 41 bar and a temperature of 70°C (343.15K).NREL performed polarization (I-V curve) scans from 350 to 3750 A, while maintaining cathode pressure and stack temperature at its nominal values (Harrison, 2021).
 A balance of plant including the following main components: two gas/water separator for the stack output conditioning, a feed water/cooling circuit composed of a heat exchanger, a water pump and valves for the stack temperature regulation.
 Additionally, a deoxo-dryer system is needed to purify hydrogen, an AC/DC converter to supply the DC current of the stacks from AC source and a dry cooler to evacuate heat from cooling circuit.
At first, to validate the stack model, polarization curve using the cell voltage calculation by Webster and Bode (2019) and Afshari et al. (2021) are compared to the NREL data (Harrison, 2021).The resulting I-V curves are given in Figure 7. Results shows a good match between both models and NREL measurements.Moreover, The Webster approach is simply correlated to measurements (RMSE = 4.6.10 - V, 0.25 %) using a constant additional ohmic resistance (due to electrode, a lower membrane humidity or a contact resistance) for the ohmic overvoltage calculation.
Then, as shown in Figure 8, the Ex-2125D electrolyzer system is assembled from components model of the EnergyProcess Library.Each component (heat exchanger, pump, valves, dry-cooler) is sized at the nominal values of 3750 A, 70°C corresponding to an electric power consumption of 5.9 MWe.The stack model includes a temperature submodel which implements a lumped thermal capacitance model and thermal losses (radiation and convection).The thermal capacity of the Allabash PEM stack is determined from geometry defined by Tiktak (2019) to be 219 kJ/K value.
The control-command system consists of three valves to pilot:  The feed-in water directly as a function of the water consumption by electrolysis reaction in the five stacks.
 The level of water in both separators.The valve is used to discharge the overwater level from H2/water separator to O2/water separator due to pressure difference between the anodic and cathodic circuits and water crossover trough the cell membranes.
 The temperature of the stack using a bypass of a fraction of the flowrate of the cooling fluid in the cooler.
Component models are associated with a media package.In-house Moist O2 (using ideal gas for gas phase and constant properties for liquid water) and Moist H2 (using SRK model for gas phase and constant properties for liquid water) mixtures (see Figure 2) are selected for anodic and cathodic circuits.
Simulations are performed to study dynamic or quasistatic response of the Ex-2125D electrolyzer and study system performances.For example, Figure 9 gives the evolution of the stack temperature in response to a step of the electric load (trapezoid source from MSL with 5 minutes of rising duration):  Using a constant opening of the bypassing valve of the cooler.
 Using a PID regulator to control the opening of the bypassing valve as a function of the outlet temperature of the stacks.

Use for calibration of model
With the physical model of the module, we were able to characterize its behavior for the entire range of current density and at a temperature of operation of 70°C.

Use as a simulator for EMS evaluation
A complete green hydrogen production chain simulator was built with the use of the EnergyProcess library combining different modules of Section 4.1 in parallel, a salt cavern gas storage, a transportation pipeline and different compressors.This physical non-linear simulator was then used to evaluate the performance of a MILPbased predictive EMS prior to field deployment.Figure 12 explains schematically the interaction between the physical simulator and the EMS.The latter receives i) predictions of cost and H2 demand for the next 24 hours and ii) state-returns from the physical simulator (e.g.state-of-charge of the storage) and will calculate set points (e.g.input power to the different modules) for the next 24 hours at a time step of e.g.minutes.The set points calculation takes place every hour.Figure 12 also highlights the other use of the EnergyProcess library, which is the off-line calibration of MILP models (as explained in Section 4.2).

Conclusion
In this paper, we describe how we built and used the EnergyProcess library, a Modelica-based library dedicated to the simulation and optimization of energy process for the production of green molecules.After a review of existing libraries, the development of this new library finds its roots in our need for i) media models computationally light and able to represent various multiphasic mixtures, ii) FMU and MSL compatible models, iii) exhaustive component models for various green molecules production chains, and iv) intellectual property and continuous integration control.
The structure of the library was then presented with a specific focus on the core packages, i.e.Media, Electrolyzers and Storage.The specific application of a 5 MW PEM electrolysis module was finally addressed with i) the polarization curve validation for a single stack, ii) the dynamic performance simulation of the entire module, iii) the optimization model calibration of this module and iv) the use of a complete simulator including this module to characterize an Energy Management System (EMS).The authors do not see any limitation in extending the electrolyzer model to smaller scale.As for larger scale, a simplified version (for the sake of computational time) of the 5 MW model was used as a subsystem to simulate a 500 MW electrolyzer in one project.
The development of the library is still on-going with for example the current modeling of ammonia synthesis catalytic reactor.Apart from the initial ambitions of the library which were to either be used for control models calibration or as a physical simulator to evaluate EMS, further uses are currently envisioned.The latter specifically comprises data reconciliation and surrogate model to be used inside the EMS.
Although the EnergyProcess library is limited to our internal use for now, a wider diffusion of some components under an open-source license is envisioned in the frame of a European project.

Figure 1 .
Figure 1.Structure of the EnergyProcess Library

Figure 2 .
Figure 2. Media package of the library including monophasic and diphasic models for pure substance and mixture.

Figure 3 .
Figure 3. On the left, the electrolyzer model in the PEM package including the "physics" package.On the right, an extract of the "physics" package highlighting the voltage and mass flow replaceable subpackages.

Figure 4 .
Figure 4. 1-D model of the underground gas storage.

Figure 5 .
Figure 5. Process of a fast filling of hydrogen tanks

Figure 6 :
Figure 6 : Hydrogen pressure (up) and Temperature (middle) inside the tanks during the fast filling process obtained with 4 media models.Associated CPU time calculations (down).

Figure 7 .Figure 8 .
Figure 7. Polarization curves of Allabash cell from models and NREL data at 70°C and 41 bar

Figure 9 .
Figure 9.Stack temperature (Up) and module efficiency (Down) evolution in response to a step of the electric load with or without PI controller

Figure 10 .Figure 11 .
Figure 10.Different simulated contributions to the loss of efficiency and final net efficiency of the module

Figure 12 .
Figure 12.Schematic of the EnergyProcess library uses as i) physical simulator and ii) offline calibration tool for MILP model

Table 1 .
Review of Media libraries

Table 2 .
Review of Chemical Energy Processes libraries

Library Name Description Stronger points Weaker points
Presentation, Validation and Application of the EnergyProcess Library 312 Proceedings of the Modelica Conference 2023 October 9-11, 2023, Aachen, Germany DOI 10.3384/ecp204311

Table 3 :
Comparison between six Hydrogen models during a