# Online Model Adaption for Energy Management in Fuel Cell Electric Vehicles (FCEVs)
## 2 Methodology
### Proposed Method  
Recalibrating maps has shown to be useful for control applications to avoid the propagation of errors to the powertrain control caused by bias. So this work proposes an approach that consists of modelling the FC power output power as a 1D look-up table using the FC demanded current as input and for which the parameters are adapted based on FC power measurements using an EKF. The map adaptations take place while the FCEV covers a route, the fuel cell operates, and the learning block presented in Figure 5 evaluates the fuel cell output power measurement and compares it with the mapped output power implemented in the EMS. The proposed strategy addresses an online adaptation of a 1D look-up table \(M\) calibrated with experimental data under steady-state conditions. This table provides the estimated output power of the fuel cell \(P_{\text{FC}}\) based on the input current density \(I_{u}\). The look-up table is composed of an input axis \(\mathbf{I_{M}}\) and an interpolated axis \(\mathbf{P_{M}}\), both with \(n\) elements. The look-up table is defined as follows:  
\[P_{FC}=M(I_{u})=\mathbf{q}(\mathbf{I_{M}},I_{u})\cdot\mathbf{P_{M}} \tag{7}\]  
where \(\mathbf{q}\) is a vector of the same size (10 elements), computed by:  
\[\mathbf{q}=1-\frac{|I_{u,k}-\mathbf{I_{M}}|}{\sum\limits_{i=1}^{n}|I_{u,k}- \mathbf{I_{M}}(i)|} \tag{8}\]  
where \(I_{u,k}\) is the current density applied, and \(\mathbf{I_{M}}\) is the vector of \(n\) input values of the table and ranges from 0 to 1.75 A/cm\({}^{2}\). Moreover, the output of the table (\(P_{\text{FC}}\)) is filtered to reject disturbances on the system and sensor noise as following:  
\[P_{\text{FC}/k}=aP_{\text{FC}/k-1}+(1-a)P_{\text{FC},k} \tag{9}\]  
where \(a\) is the filtering parameter fitted to the simulations and is equal to 0.2. To adapt the look-up table, a Kalman filter is developed to update the table data elements \(\mathbf{P_{M}}\). So the main equations of the Kalman filter are recalled to present the mathematical terminology. The following equations will explain the flowchart presented in Figure 6, which depicts the proposed strategy. It is based on a discrete-time system:  
\[x_{k}=Fx_{k-1}+Bu_{k}+w_{k} \tag{10a}\]\[y_{k}=Hx_{k}+v_{k} \tag{10b}\]  
where the sub-index \(k\) is the time step, \(x_{k}\) represents the state vector, \(u_{k}\) is the input vector, and \(y_{k}\) is the output vector. The variables \(w_{k}\) and \(v_{k}\) are the white Gaussian noise terms that induce the variations. \(F\) represents the transition matrix, \(B\) is the control-input matrix, and \(H\) is the observation matrix. In the case at hand, the output of the system \(y_{k}\) attends to the power measured at the fuel cell \(P_{\text{F}cf}\), the input \(u_{k}\) corresponds to the intensity at each time step \(I_{u}\), while the state vector \(x_{k}\) comprises all the elements of the table data \(P_{M}^{i}\) and the estimated power of the fuel cell \(P_{\text{F}cf}\):  
\[x_{k}= \begin{bmatrix}P_{M,k}^{1}\\ P_{M,k}^{2}\\...\\ P_{M,k}^{n}\\ P_{FCf,k}\end{bmatrix}  \tag{11}\]  
The noises \(w_{k}\) and \(v_{k}\) are assumed to be independent and to both have Gaussean distributions with zero means and covariance matrices \(Q_{k}\) and \(R_{k}\). Note that \(Q\) is the identity square matrix of the \(n\) length of the 1D look-up table, and \(\tau_{x}\) can be selected individually for each table data element containing its individual variances. It is helpful to consider the order of magnitude of the data, i.e., absolute error for high powers may be higher than for low loads. Then, \(Q\) is represented by  
\[Q=\begin{bmatrix}&iden_{n+1}&\\ &&\\\[P_{k}=(I-K_{k}H_{k})P_{k|k-1} \tag{15c}\]  
where the matrix \(P_{k}\) is the covariance matrix of the state estimate error that will be used in the next time step to estimate the observation of the state vector (Equation (14a)) and the Kalman gain (Equation (15b)). The noise covariance matrix \(R\) is constant and is an essential parameter of the proposed method that governs the algorithm.