Machine Learning Approach for Modeling and Control of a Commercial Heliocentris FC50 PEM Fuel Cell System

In recent years, machine learning (ML) has received growing attention and it has been used in a wide range of applications. However, the ML application in renewable energies systems such as fuel cells is still limited. In this paper, a prognostic framework based on artificial neural network (ANN) is designed to predict the performance of proton exchange membrane (PEM) fuel cell system, aiming to investigate the effect of temperature and humidity on the stack characteristics and on tracking control improvements. A large part of the experimental database for various operating conditions has been used in the training operation to achieve an accurate model. Extensive tests with various ANN parameters such as number of neurons, number of hidden layers, selection of training dataset, etc., are performed to obtain the best fit in terms of prediction accuracy. The effect of temperature and humidity based on the predicted model are investigated and compared to the ones obtained from real-time experiments. The control design based on the predicted model is performed to keep the stack operating point at an adequate power stage with high-performance tracking. Experimental results have demonstrated the effectiveness of the proposed model for performance improvements of PEM fuel cell system.


Introduction
Fuel cells (FC) are conversion devices which transform hydrogen into electrical energy through an electro-chemical process [1]. These are a trending research topic since their efficiency (more than 40%) is higher than other renewable alternatives such as wind turbines (≈25%) or photovoltaic systems (≈6-20%) [2]. As a consequence, several industries used FC for their applications like aviation [3], automotive [4] and maritime [5]. According to Wang et al. [6], the cutting-edge FC technologies that are currently under focus are polymer electrolyte membrane fuel cells (PEMFCs), solid oxide fuel cells (SOFCs), phosphoric acid fuel cells (PAFCs) and molten carbonate fuel cells (MCFCs). Among the several available types, PEMFC stands out due to its high efficiency, power density and durability [7].
A PEMFC is frequently built with membrane electrode assembly (MEA) that holds an anode and a cathode that are isolated by a proton conductive membrane [8]. The continuous hydrogen supply goes into the anode electrode while the cathode receives oxygen. As a consequence, protons and electrons are generated because of an oxidation reaction; the electrolyte exchange membrane allows the path division of these particles. The electrons move to an external electric circuit whereas the protons join the oxygen to output water [9]. To achieve a suitable system design in terms of efficiency, several PEMFC mathematical models had been developed in recent years to understand the main phenomena that can alter the device performance.
According to Fang, Di and Ru, PEMFC models are divided into operational mechanism and experimental data ones [10]. In regards to the first mentioned category, based on the hidden interconnection layer. A general architecture of ANN with N 1 inputs, N 2 outputs and L hidden layers is depicted in Figure 1.
x 0 x 1 . . .  ANNs can manipulate information just like the human brain thanks to the computational features of their basic units (also called nodes or neurons) which take a set of inputs, multiply them by weighted values and put them through an activation function. The schematic structure of the ith hidden artificial neuron at the jth hidden layer can be depicted as Figure 2. There are several topologies of NNs in deep learning and they can be classified into two groups of algorithms. The first group contains the ones that were used for supervised deep learning problems such as fully-connected feed-forward algorithms (Multi-Layer Perceptron, Radial Basis Network, etc.), recurrent NNs algorithms (long short term memory, gated recurrent unit, gated feed-forward, etc.) and convolutions NNs algorithms (deep convolutional NNs, deep convolutional inverse graphics network, deconvolutional network, etc.). The second group contains the ones that were used for unsupervised deep learning problems such as restricted Boltzmann machine algorithms (deep belief network, deep Boltzmann machine, etc.) and ML auto-encoder algorithms (variational auto-encoder, denoising auto-encoder, sparse auto-encoder, etc.). However, since modelling the fuel cell is a supervised learning problem, different structures of feed-forward neural network perceptron (FFNNP) with back-propagation learning rule have been implemented in Matlab/Simulink R and Neureal Network Toolbox TM to predict the performance of a commercial fuel cell system (Heliocentris FC50).

Data Collection and Analysis
• Data collection: The first and the most important step in the supervised learning process is gathering the data. In other words, to carry out good training, vast amounts of real-world data (Big Data) is required since the more data we provide to the ML system, the faster the model can learn and improve. Besides, the collected dataset should be well distributed throughout the operation range so as to represent the behaviour of the fuel cell in each operating power point. To this end, a continuous triangular signal with a period of 15 s (7.5 s for each positive/negative slop) was built and supplied to the duty cycle of the boost converter so as to vary the stack current from the minimum to the maximum operating value. The selection of the period was made based on the characteristics of the fuel cell data acquisition software since it measures the data each 0.5 s. In other words, 15 samples in different operating current values will be measured fore each positive/negative slop. Figures 3 and 4 show, respectively, the Simulink blocks used to design the triangular signal and the generated signal. The maximum value of this signal (0.8) drives the fuel cell to operate at the highest current value [8-9A] where the minimum value (0.5) drives the fuel cell to operate at the lowest operating current [0.2-0.5A]. These values can be adjusted via the increase/decrease of the output load resistance value. We have avoided operating currents above 9A since the fuel cell used in this study (Heliocentris FC50) is occupied with a security system that turns off the fuel cell in case of higher currents/temperatures [29][30][31].  To obtain data for different operating conditions, variations in temperature, humidity, hydrogen and airflow are required. It should be noted that the fuel cell contains an integrated control system that not only controls the supplied hydrogen but also provides an option to set the fans of the fuel cell at the automatic mode. By using the auto mode, the fans will automatically control the temperature, the humidity and the supplied airflow. However, to provide large degrees of freedom, the auto mode option of the fans was not considered. Therefore, a database containing 20,512 samples for different operating current, temperature and fan power were recorded and presented in Figure 5. This latter also shows the influence of the air flow on the fuel cell performance but the effect of temperature is still not well presented. Therefore, a 3D graph that clearly shows the effect of both temperature and air flow on the stack performance is presented in Figure 6. According to this latter, it is shown that at low air flow (fans power = 10%), by varying the temperature from 25°C to 43°C the stack performance improves in the beginning, then becomes almost constant and finally, it deteriorates for higher temperatures. At medium air flow (fans power = 50%), the stack performance improves with increasing temperature. However, for higher temperatures only slight improvements occur since the membrane requires an additional amount of water content. Regarding the last case at which the air flow is set at its maximum value (fans power = 100%), the stack performance improves largely with a temperature increase from T = 25°C to over 40°C. It is noticed that even for higher temperatures, the stack performance is still improving and this is due to the well humidification provided by the fans.  • Inputs and outputs selection: Another factor that can improve the accuracy of the learned function is the selection of the inputs and outputs since the accuracy is strongly dependent on how the inputs are represented. The inputs should be entered as a feature vector that contains enough information to properly predict the output; but also, it should not be too large due to the dimensionality curse effect. In this study, the input variables are selected as: stack current I stack (A), stack temperature T (°C) and fans power (%), to predict the stack voltage V stack (V) •

Data division (training, validation and test):
When enough data is available, the next step is to split this data into three subsets which are training, validation and test. The training dataset needs to be fairly large and contains a variety of data in order to contain all the needed information. Many researchers have proposed a training set of 70%, 80% and 90% [32][33][34][35]; where the rest of data were divided between the validation and test. In this study, the recorded data was divided as the following: training = 14,358 data points (70% of whole data), validation = 3077 data points (15% of whole data) and test = 3077 data points (15% of whole data). The training subset is used to adjust the network via minimising its error. In other words, it is used for computing the gradient and updating the weights and biases of the NNs. The validation subset is used for measuring the network generalisation and to stop the training when the generalisation stops improving. In more detail, when the training begins to overfit the data, the validation error starts to rise. Therefore, the weights and biases of the network are saved at the minimum validation error point so as to balance the accuracy of the learned function versus overfitting. The test subset is used to evaluate the performance of learned function when applying a new set. Actually, the test subset has no influence on the determination of the learned function parameters, but it is a kind of 'final exam' to test the performance of each predicted function.

Designing the Network
Based on Figure 2, the output of the h (j) i hidden layer unit can be calculated as Equation (1) [36].
where x ∈ R m are numerical inputs, w ∈ R m are weights associated with the inputs, b ∈ R are biases. f act is the activation function which is used to introduce nonlinearity into the output of the artificial neuron. Actually, this is important since most of data in the real world is nonlinear and the neurons should learn these nonlinear representations. There are many activation functions that can be used in practice such as sigmoid, tanh, ReLu, etc. [37]. In this work a tansig function which is given in Equation (2) is used.
By using Equations (1) and (2), the k th output layer unit can be calculated as Equation (3).
where k = [1,2, . . . , N 2 ] and f out act is a linear transfer function or also known as purelin, its mathematical expression is given in Equation (4) purelin To train the FFNNP, several optimisation algorithms can be used to minimise the performance function (also known as loss/cost function) [32,[38][39][40]. These algorithms use either the Jacobian of the network errors or the gradient of the network performance. Both Jacobian and gradient are computed via the back-propagation algorithm which is an efficient computational trick for calculating derivatives inside the deep feed-forward NNs. In this work, we made a comparison study among the four major used algorithms including the Levenberg-Marquardt (LM), Bayesian regularization (BR), BFGS quasi-Newton and Scaled conjugate gradient (SCG). For each training algorithm, the following basic system training parameters are used: maximum number of epochs = 5000, learning rate = 0.01, performance goal = 0, time of training = Infinity. All these parameters were checked for different number of neurons and hidden layers as presented in Table 1. The performance of each training algorithm was measured via the mean squared error (mse) which is given in Equation (5), where y * i is the desired output (target), y i is the actual (predicted) output, and N is the number of dataset.
The best performance, in terms of training time and mean squared error mse, of each algorithm is tinted with green colour ( Table 1). The predicted output results as well as the error that corresponds to the best performance (green cells) for each training algorithm are respectively shown in Figures 7 and 8.  According to these figures, it is clear that the BR training algorithm with the structure of 3 hidden layers and 30 neurons for each predicts the best output results in terms of accuracy, where the SCG shows the worst predicted results in comparison with the rest of the algorithms. In terms of time, the SCG shows the fastest training since it takes only around 11 s to predict the output while the BR needs around 6930 s. However, although the BR takes around 2 h for the training, it finally provides a highly accurate model which is one of the main goals of this study. Figure 9 shows the regression plots which were used to validate the performance of the obtained trained model. According to this figure, it is clear that the predicted model is characterised by high accuracy since most of the data points fall along a 45 degree line, where the output is equal to the target. The goodness of the model also can be analysed via the R values which ranged between 0 (lowest accuracy) and 1 (ideal model). In our case, the accuracy of the obtained model is proven by the following R values: training, R = 0.99974, test, R = 0.99735 and all, R = 0.99938.

Control Design
Although PID control is one of the most used controllers in industries, it still suffers from systems sufficient nonlinearity which make its constant parameters not optimal in each operating moment. This is due to the difficulties of determining the parameters which are usually tuned via the conventional trial and error method. As a solution, we have designed a self-adaptive PID based feed-forward artificial neural network (ANN-PID) aiming to avoid parameters manual tuning. The input of the ANN-PID controller is the error e(k) which is achieved from the difference between the desired and actual PEMFC stack currents, and the output is the duty cycle signal u(k). The error is discomposed into three variables x i (i = [1,2,3]) similarly to the conventional PID, but they will be respectively associated with three weights w i which are self-tuned via the Hebb supervised learning rule method. The implementation of the of ANN-PID in the hardware system is explained in Figure 10. The output of the ANN-PID controller ∆u(k) is given in Equation (6), where k is a positive parameter determined by the user, and the values of the three inputs x i are given in Equation (7).
The biological origin of Hebb's supervised learning was established from a neuroscience perspective: when two neurons are activated simultaneously, the link intensity (also called plasticity) is proportional to the multiplication of their stimulation [41,42]. Therefore, this concept can be translated mathematically for the adjustment of the PID parameters (k p , k i and k d ) which can be obtained through a neural settlement of Equation (8) as Equation (8) shows, where η i are learning rates that correspond to w i (k) [43].
Recently, it has been found that the weight values used for PID online regulation are mainly related to e(k) and ∆e(k) [44]. Hence, the inputs x i (k) of Equation (8) can be replaced by e(k) + ∆e(k). Finally, the running algorithm of the control law can be expressed as Equation (9).

Metrics Used for Control Performance Improvement
To achieve high tracking performance, the minimisation of the integral of the absolute error (IAE), the root mean squared error (RMSE) and the relative root mean squared error (RRMSE), which are described by Equation (10), have been used to adjust and tune the gains of the controller, whereas the values can be determined by taking into account the error reduction in real time.
where N, e i and r i are, respectively, an observation data length time for the calculation, the tracking error and the reference along the i-th sample.

Comparison between the Experiment and Simulation Results
The I stack -V stack and I stack -P stack polarisation curves of the simulated and real model are presented in Figure 11. According to this figure, it is clear that the predicted model succeeded in providing the same results obtained by the real fuel cell system. It should be noted that the temperature in the experiment curves has an error around ±0.5°C since it is difficult to make experiments at constant temperatures. One other variable factor that also should be taken into account is the input Hydrogen pressure which is controlled by the manufacture. However, although these two variable factors can differ the predicted results from the real ones, only slight deviations occurred.

Effect of Temperature and Humidity on the PEM Fuel Cell Stack Performance
The effects of the operation temperature on the polarisation curves for a low, medium and high humidification (fans power are set at 10%, 50% and 100%) are presented in Figure 11. At low humidification (Figure 11a,b), by varying the temperature from 25°C to 43°C the stack performance improves from T = 25°C until T = 31°C and then deteriorates for temperatures up to 31°C. The improvement of the performance from T = 25°C until T = 31°C can be explained by the enhancement of the conductivity of the membrane which leads to reducing the activation loss. However, for temperatures above 31°C the membrane starts to dry due to the lack of water content which leads as a consequence to decrease the performance of the stack. At medium humidification (Figure 11c,d), the stack performance improves with increasing temperature. However, for higher temperatures only slight improvements occurred since the membrane requires an additional amount of water content. Regarding the last case at which the membrane is 100% humidified (Figure 11e,f), the stack performance is largely improved with increasing the temperature from T = 25°C until T = 39°C. It is noticed that even for higher temperatures the stack performance is still improving and this is due to the well humidification provided by the fans. It should be noted that although the high humidification has a positive effect on the stack performance for higher temperatures, it also has a negative effect for lower temperatures. Hence, according to Figure 11b,f and for a low temperature equal to 25°C, it is clear that the stack performance for low humidification (P max = 33 W) is better than the one obtained by high humidification (P max = 28 W).

Control Results
To keep the fuel cell operating at an adequate power point, PID and NN-PID are used. First, the controllers were designed and tested via the the predicted model so as to determine their coefficients. Then, they were implemented on the PEMFC hardware system using the Matlab/Simulink TM graphical interface. To test the performance of the PID and the NN-PID, two load variations respectively from 20 Ω to 50 Ω and from 50 Ω to 20 Ω are applied during the experiments. The obtained results are clearly presented in Figures 12 and 13.  Figure 12 and (d) of Figure 13. According to these results, it is clear that the NN-PID provides better results in terms of accuracy since it reduces the amplitude of ripples from 0.1 A to less than 0.01 A. Therefore, although the PID shows slightly lower overshoots in comparison with the NN-PID, this latter provides significantly higher performance in terms of response time and steady state error. Finally, Table 2 summarises the results of the metrics used to measure the control demeanour. It can be seen that the NN-PID achieved a better outcome in terms of the IAE since it gathered a lower value in comparison to the PID, which represents 62.8% of performance increment. In regards to the accuracy, the trend is still favourable for the NN-PID which is in contrast to the PID of 93.6%. The same situation is seen in the RRMSE since the NN-PID provided a higher improvement as 0.344% was obtained where, in comparison, the PID achieved 5.38%.

Conclusions
This paper presented an analysis of a commercial Heliocentris FC50 PEM fuel cell system; the objective was to model and control the device via the application of a deep machine learning based artificial neural network. Due to its several input variations, such as stack temperature, humidity and oxygen, which results in nonlinearities and high model complexity, extensive tests with various ANN parameters were required to predict an efficient model. Since the ANN model requires a large dataset, an efficient automatic method was designed to simplify and facilitate the data collection. This was obtained by generating a triangular signal which varies the duty cycle of the power converter that was inserted between the stack and the load. An experimental dataset composed of 20,512 samples over a wide operating range (different operating current, temperature and fan power) of a commercial stack was recorded and saved for the training process.
Different structures of feed-forward neural network perceptron with backpropagation learning rule were tested to predict the performance of the Heliocentries FC50 fuel cell system. A comparison study including various ANN parameters such as the training algorithm, the number of hidden layers and the number of neurons at each layer was made to obtain the highest accurate model. Finally, an accurate model composed of 3 hidden layers and 90 neurons trained by BR algorithm was used for a comparison study with the real results. On the other hand, the predicted model also was adopted for determining the parameters of the NN-PID control method.
The effect of temperature on the PEM fuel cell stack performance was studied for low, medium and high humidification. At low humidification, it was obtained that the performance of the stack improves for low temperatures (from T = 25°C until T = 31°C) and deteriorates for temperatures up to 31°C. At medium and high humidifications, it was obtained that the stack performance improves with increasing temperature. However, the effect of temperature is clearly pronounced at higher humidification since the increase of temperature results in a large increase in the stack performance.
At last, two controllers were designed and performed to keep the fuel cell stack operating point at an adequate power stage. Results have demonstrated that both PID and NN-PID have succeeded in driving the stack operation to the desired power point even when experiencing large load variation. However, comparison results have shown high-performance tracking in terms of response time, and steady state error was obtained via the application of the proposed NN-PID control method.
Through this research, future trends for modelling and control of PEM fuel cell systems were analysed and will be the goal of the forthcoming studies. Other types of ANN such as recurrent neural network (RNN) can be an option to improve the performance of the model. Regarding the control method, robust and adaptive controls tuned via neural approach can be also an efficient trend to improve the tracking performance.