Battery State Estimation Using Deep Learning
Carlos Vidal, McMaster University
Phil Kollmeyer, McMaster University
Overview
A feed forward deep neural network is trained with voltage, current, and temperature inputs and state of charge outputs to and from a lithium ion battery cell. Operating conditions include different current levels and different temperatures. Achieved estimation accuracy was around 1% MAE. The feedforward neural network script and accompanying data can be downloaded here.
About the Presenters
Javier Gazzarri is a Principal Application Engineer at MathWorks in Novi, Michigan, USA, focusing on the use of physical modeling tools as an integral part of Model Based Design. Much of his work gravitates around battery modeling, from cell-level to system-level, parameter estimation for model correlation, battery management system design, balancing, aging, and state-of-charge estimation. Before joining MathWorks, Javier worked on fuel cell modeling at the National Research Council of Canada in Vancouver, British Columbia. He has a Bachelor’s degree in Mechanical Engineering from the University of Buenos Aires (Argentina), a MASc degree (Inverse Methods), and a PhD degree (Solid Oxide Fuel Cells) both from the University of British Columbia (Canada).
Carlos Vidal received his B.S. in Electrical Engineering in 2005 from Federal University of Campina Grande (UFCG), MBA with a concentration in Project Management from Getulio Vargas Foundation (FGV) in 2007, his M. A Sc. in Civil and Environmental Engineering from Federal University of Pernambuco (UFPE) in 2015, Brazil. In 2020 he obtained his Ph.D. in Mechanical Engineering from McMaster University, Hamilton, ON, Canada. He is currently working as Postdoctoral Fellow at the McMaster Automotive Research Centre (MARC). Before joining McMaster, he has been gathering industry experience from several engineering and management positions, including developing a 48V battery system for a Mild-Hybrid Vehicle prototype. His main research areas include artificial intelligence, modelling, and energy storage applied to electrified vehicles and battery management systems.
Phillip Kollmeyer is a Senior Principal Research Engineer at McMaster University in Hamilton, Ontario, Canada. Phillip is the lead engineer for the forty-five member research team for the Car of the Future project sponsored by Fiat Chrysler Automobiles and Canada’s Natural Sciences and Engineering Research Council (NSERC). His research focuses on state estimation, thermal management, modeling, and aging of electrochemical energy storage systems, and the application of neural networks for modeling and state estimation. Phil has a Bachelor’s degree, MASc degree (electric vehicle drivetrains), and PhD degree (hybrid energy storage and electric trucks) all from the University of Wisconsin-Madison (USA).
Recorded: 11 Dec 2020
Good morning, afternoon, or evening, everybody and welcome to this MathWorks webinar. My name is Javier Gazzarri and I am an application engineer at MathWorks focused on modeling and simulation of battery systems. Today, I have two special guests-- Carlos Vidal and Phil Kollmeyer, both researchers at McMaster University in Hamilton, Ontario, Canada. Hello, Carlos and Phil.
Hello Javier, thank you for inviting us to join in this presentation.
Thank you very much for your participation in this event. The materials presented in this webinar are the result of the work done by our guests in collaboration with engineers from FCA and published last year as an SAE paper. So as indicated in the event's title, today we're going to talk about batteries, specifically lithium ion batteries. To say that lithium ion batteries are important in their lives would be an understatement. They are absolutely everywhere from our mobile phones, laptops, and wearable electronics, all the way up to electric vehicles and smart grids.
The main contribution of this work was the application of neural networks to battery state of charge estimation. State of charge estimation is the task of great importance trusted to the Battery Management System, or a BMS. An accurate determination of the State of Charge, or SOC, in a battery indicates to the user the extent to which they can continue to use the battery powered device before a recharge is needed.
In a car, for example an accurate knowledge of the time to recharge reduces range anxiety and allows for appropriate trip planning. The webinar will be organized as follows. First, I'll make a general introduction to SOC estimation, its challenges and motivations for new ways to perform this task. Then I'll quickly review the state-of-the-art and introduce the concept of neural networks.
Secondly, Phil will walk us through the experimental process involved in their study. He will share with us the types of measurements they performed for training and testing the neural network, including a description of the kind of cells and operating conditions. In the third place, Carlos will do a deeper dive on the theory and implementation of the network they used, motivation and tradeoffs for the utilization of certain network architectures, training, testing, and validation, and analysis of the network performance.
I will then take over and show the MATLAB live script that Carlos and the team developed to access and format the measurement data, to create the network architecture, determine its main parameters, performance training, and evaluate its performance on testing data. Finally, I'll present a new feature in our 2020b release, the possibility to implement the trained network in Simulink using the predict block.
This will enable us to implement the SOC algorithm as part of a BMS system developed in Simulink. Let's start with the basics of battery management. Lithium ion batteries play a prominent role in the world because of their high energy and power density, efficiency, cycling capability, low self-discharge, and low maintenance. These advantages come along with some drawbacks.
Batteries require very careful management to ensure operation within a specified temperature and voltage range. Not only does battery performance strongly depend on temperature, but it is also important not to exceed temperature limits, since the battery does not like to be too hot or too cold. In addition, they need sophisticated model-based algorithms for status information-- in particular, State of Charge estimation, or SOC-- the main topic of today's events.
And finally, it is also unavoidable that the battery performance will degrade over time, both because of cycling and because of calendar aging. A major developing avenue of the battery community involves degradation diagnosis algorithms. A popular way of modeling batteries with the purpose of system design and battery management is to create an electric thermal analogy for the cells behavior called equivalent circuits.
The topology and parameters of the equivalent circuit should allow a user to load it in the same way they would load a battery and observe the same response a battery would have. This includes voltage drop, relaxation times, and open circuit voltage-- all of them functions of temperature, SOC, and age.
Speaking of SOC, let's see what it is and how we estimate it. SOC is a number between 0 and 1 that indicates the amount of charge available in the cell relative to the maximum amount of charge, defined as the number of amp hours extractable from it when we slowly discharge the battery from two voltage levels at the reference temperature of 25 degrees. A major challenge with SOC is that it is not directly measurable, but it needs to be inferred based on measurements of voltage, current, and temperature, and the use of the model of the cell.
The easiest way to estimate State of Charge is integrating currents. By definition, the SOC is the integral of the currents flowing in and out of the cell over the total capacity. This method's simple and computationally cheap. The problem is that any error in the measurement of the current will accumulate, making the State of Charge diverge from the true value until we somehow reset it. A more advanced method of doing this is using observers, for example, a Kalman Filter.
A Kalman Filter is an observer for status information that contains a model of the system under observation and uses a recursive algorithm that continuously predicts a future state and corrects it using measurements performed on the system. In this case, the state of interest is the SOC, or State of Charge. And measurements include currents, voltage, and temperature. A requirement for the Kalman filter to function correctly is to have an accurate, dynamic model of the cell, including dependencies on operating and environmental conditions.
Moreover, as a recursive algorithm, it is significantly more resource intensive than simple current integration. So the question many are asking is, is there an alternative to the current state-of-the-art that can provide an accurate estimation of SOC, and at the same time handle in many possible operating conditions to which a battery cell could be subjected, and that can be used for different cell types with minimal modifications? If so, how efficient would it be as an embedded algorithm?
How about using a neural network that takes current voltage and temperature measurements as a function of time, and uses them to predict SOC. Trained with a sufficiently large amount of data measured under sufficiently varied conditions, would a neural network be able to learn the patterns of change in the measurable quantities of the battery and link them to an accurate estimation of the State of Charge? That is what we're going to be discussing in the next 20 minutes or so with the authors of this work.
One thing a neural network needs is lots and lots of training data. The data is labeled and fed to the network, which in turn tries to learn the patterns of change in the input variables that lead to a certain outcome. So Phil will describe the experimental setup and procedure for designing and performing the measurements for training and testing the neural network. Phil, over to you.
Thank you, Javier for that excellent introduction of the topic and for giving us this opportunity to discuss our research. I will provide an overview of the experimental testing, which was performed to this work. First, I will discuss the cells that were tested. Then, I will explain how the drive cycles are calculated and described the test equipment used. Finally, I will show some of the experimental results.
Test results for two 18650 form factors cylindrical battery cells were used in this work. One was a Panasonic 18650PF NCA Chemistry cell and the other was an LG HG2 NMC Chemistry cell. Both cells have similar capacity, around 3 amp hours, and the LG cell has a slightly lower nominal resistance of 28 milliamps.
Two cells with different chemistries are used to demonstrate that the neural network SOC estimation algorithm can perform well for either. To make the results presented in the paper realistic and meaningful, battery cells were tested at a range of temperatures with drive cycle power profiles calculated for electric vehicle applications. For the Panasonic cells, prototype Ford F150 electric truck, which was built for another project, was modeled with a 35 kilowatt hour pack consisting of 3,360 of the cells.
For the LG HG2 cells, a Fiat 500e electric vehicle was modeled with a small 7.3 kilowatt hour pack consisting of 672 cells. The power calculated from the model for each tested drive cycle was then scaled for a single cell and these power profiles were applied to the cells with the battery cycler. Both of these packs are rather small compared to what would be common for a commercial application, and this is intentional.
With a small pack, each cell must provide more power, and this makes the SOC estimation problem more challenging, and therefore gives confidence that the developed methodology has potential to perform even better in a real application. Battery cells were tested at the University of Wisconsin, Madison, where I did my PhD, and also at McMaster University in Hamilton, Ontario, Canada, where this work was performed.
The cells were tested using battery cyclers from Digatron Power Electronics. Importantly, the cyclers are very accurate, with voltage and current air no greater than plus or minus 0.1% of full scale. This ensures the data sets are an accurate set of reference data. The cells are placed in a thermal chamber and a range of dry cycle and characterization tests are performed at temperatures of negative 10, 0, 10, and 25 degrees C.
The LG HG2 battery considered in this study at the negative 10 degrees C resistance more than three times greater than at room temperature, as shown in the figure on the left. And it is more than six times greater at negative 20 degrees Celsius. The resistance also becomes a non-linear function of current at low temperatures, as is shown in the figure on the right, with resistance for a 2C current pulse at negative 20 degrees C being about 30% less than the 0.25 C current pulse.
This non-linear resistance is commonly referred to as the Butler-Volmer equation resistance, and it's known to be more prevalent at low temperatures, as is seen here. When developing an SOC estimation methodology, it's therefore important to consider its performance at low temperatures where the non-linear, temperature-dependent characteristics make it much more difficult for algorithms to observe SOC.
Here are results for one of the tested drive cycles-- the aggressive US06 cycles for the LG HG2 cell. The neural network inputs-- voltage, current, and temperature are shown on the top. And the target output value-- the state of charge calculated as the integral of the current scale by the capacity is shown on the bottom. There's quite high voltage deviation, especially at the lower temperature negative 10 degrees C, with the battery voltage periodically reaching its limit of 2.8 volts, and therefore operating at its maximum power capability.
SOC estimation algorithms effectively function as inverse models which estimate the open circuit voltage directly or indirectly and associate the estimated open circuit voltage with state of charge. While for a neural network algorithm, open circuit voltage is not directly estimated with the model like for the Kalman Filter, the learned relationship between SOC and terminal voltage characteristics, still in theory, rest on the relation between open circuit voltage and SOC because open circuit voltage is the true electrochemical indicator of State of Charge.
When there is large voltage deviation from the open circuit voltage, like for the negative 10 degrees C case, it is much more difficult for these algorithms to accurately and smoothly estimate SOC, and that's why we've chosen such challenging cases to develop and evaluate our algorithms. It is also important to note that for each drive cycle, the state of charge always starts at the same reference 100% state of charge value at the beginning of a drive cycle.
This is achieved by always charging the battery at 25 degrees C with the same constant voltage charging method, even when the drive cycles are performed at lower temperatures, such as 0 degrees C. This aspect of test design ensures that the calculated reference SOC value, which is used for training and evaluating the area of the estimation algorithms, is always as accurate and consistent as possible.
Each battery was tested with many different drive cycles. A portion of these cycles were used for training the SOC estimation algorithm, and the remainder were used for testing the accuracy of the algorithm. For the Panasonic cell, 5 mixed drive cycles, which are made up of randomized portions of other drive cycles, were used for training in the standard urban UDDS cycle, LA92 cycle, and the more aggressive US06 cycle were used for testing.
For the LG HG2 battery, 8 mixed cycles were used for training and the same cycles were used for testing. The histograms show that the training and testing cycles covered the whole voltage range of the battery from around 3 to 4.2 volts and covered temperatures from negative 10 to about 30 degrees C, due to the battery warming up during these fixed ambient temperature tests. The training and testing data both cover the operational space well, which is important for thorough training and evaluation of the neural network algorithm.
Also, around 2/3 of the data is used for training and 1/3 for testing, a common ratio when utilizing neural networks. Both of these data sets, which also include temperatures beyond what was used in this study, have been shared online in the Mendeley Data Repository. Such testing requires a lot of resources, both money and time. So we wanted to share these data sets to make development and testing of battery models and state estimation algorithms more accessible to other researchers and those in industry.
We hope to see a wider sharing of data sets by others in the future, as well as sharing of the source code for the algorithms, as we have done for the work Carlos will present next.
Thank you, Phil. That was very interesting. Now Carlos will share some details about neural networks and their suitability for status information in battery systems. Carlos, your turn.
Thank you, Javier. For my part of the presentation, I walk you through the main aspects of the neural network design process for SOC estimation. The main aspects include an overview of the training evaluation testing process, the neural network model structure, data preparation, an approach to improve robustness of the model, and finally, some SOC estimation results at multiple temperatures, including negative 10 degrees Celsius.
A simplified concept of Feedforward Neural Network is shown in figure one, and a flowchart of each training process is shown in figure two. First, the initial value of the learnable parameters-- weights and bias are randomly assigned, using in our case, an orthogonal distribution. Secondly, a so-called forward propagation computes the initial output, the SOC candidate, and then compares to a reference SOC to compute the loss for this iteration.
The losses then back propagated using a series of partial derivatives with respect to each of the neural networks' weights and biases, updating their values, and then repeating the forward propagation plus the back propagation steps. This iterative process continues until meeting some determined criteria, such as reaching a particular accuracy or reaching a certain number of iterations. Another step happened at regular intervals during the training process, where separate data set or validation data set is fed into the model candidate to validate the accuracy of the FNN during the training process using forward propagation step without changing any of the learnable parameters.
For the training process, the data preparation is a very important step. It's necessary to check and clean the data, as well normalize its vector to improve training accuracy of the model. Normalization is a very common procedure when training a neural network. The type of neural network we are talking about in this seminar is the Feedforward Neural Network, or just FNN. However, different machine learning approaches can be used for this purpose.
For example, Recurring Neural Networks, such as LSTM. The input for this FNN are the temperature, voltage, and current from the battery. Although, a very important aspect that I would like to remark is the moving average filters. Like Recurring Neural Network, FNN doesn't consider past information to help make its estimation. Just for comparison, without the filter, the estimation error is three or five times higher. In the next slide, we'll show how we have selected the number of neurons for the hidden layers.
In order to select the number of neurons for our model-- we have trained hundred models by varying the number of neurons in each hidden layers, as shown in figure 7. The training parameters used in this selection is shown here. Although based on these results, the models with 55, 82, and 99 neurons presented very similar accuracy, which we'll discuss in the next slide.
And figure 6 shows the results of 2000 trained models. And despite the significant variation of number of neurons, many results are very similar. This is because the random initial seed values assigned to each of the weights and bias every time a training process starts, which can lead to different local minimum, even for the same number of neurons in the structure.
Therefore, the number of neurons for the neural network structure in this work was chosen to be 55, which is the lowest number of neurons among the three best results we could find. In the next slide, we will show more details about the final FNN structure and some results. The detailed final FNN structure and the LG HG2 lithium ion SOC estimation at 25 degrees Celsius result is shown in figure eight.
The activation functions using this structure are the hyperbolic tension, leaky RELU at the 0.03 and clipped RELU at 1. This model presents a very good accuracy on the SOC estimation close to 0.5% on the mean absolute error.
On the next slide, we'll show how this border can be visualized in the MATLAB Deep Network app. One way to visualize the neural network structure that we've been discussing in the MATLAB is going through the apps-- Deep Neural Network Designer, then you can actually import the model and open up in this app, and you can see how many activations, learnables, and what kind of structure is. And this how it is shown in the MATLAB.
This is really interesting if you want to visualize quickly the structure just built into MATLAB. And you also can use to build your own structure also this way. In the case of SOC estimation for electrified vehicles, the sensor used to capture voltage, current, and temperature have significant due to the low cost sensor models you typically use in the automotive industry.
If the expected area is now during the model design, the neural network training data set can be augmented to include error on the signal, improving the robustness of the resulting model. Here, table five shows the gain and offset values used to augment the data set for each input feature. The figure 9 here shows that despite the inclusion of the noise into the test data set following the 14 cases in table 4 discussed previously, the SOC estimation was maintained with similar value throughout all cases.
By using the final structure that we have been discussing, my FNN-based model was trained on a data set containing multiple temperatures, including negative 10 degrees Celsius. As shown in this figure 11, the model performed incredibly well in all temperatures. Even though at negative temperature, the SOC estimation becomes considerably more challenged to be estimated, and it performs considerably well, even at such difficult conditions.
Here, in table six shows a summary of the results, where the RNS here was kept close to 1.2% in all temperatures cases, and under 1% on the mean absolute error. To quick summarize this part of the seminar, we have shown an overview of the FNN training process, part of the design process of the FNN for electrified vehicle battery SOC estimation, data preparation for a lithium ion LG HG2, we have presented an approach to improve the SOC estimation robustness, and finally, we have presented and discussed the results when the model was exposed to multiple temperatures, including negative temperatures.
Thank you. Javier, you're next.
Thank you, Carlos. Now, I'll walk you through the MATLAB script that does the training and testing of the network. The first thing is to create data stores to contain the training and testing data. Data stores are MATLAB constructs that allow us to store large amounts of data, even larger than the memory of the computer. Separate data stores are used to contain inputs, or in machine learning terms, predictors, and outputs, also known as responses data.
Next, we combine all training data sets into one structure. Depending on the size of the training data, it may be necessary to split it into many batches. This is not the case here, so we keep that equal to 1. The validation data set is set to be the same as the testing data set, but this can be changed. Now, it is time to define the network architecture. As explained earlier by Carlos, the system will have five predictors-- voltage, current, temperature, and average voltage, and average current, and one response-- the State of Charge.
In this section, we set the number of hidden units, the number of iterations, or epochs, the number of epochs per dropping the learning rate, the initial learning rate, drop factor, and validation frequency. Last, because we're going to train the network with a different parameter set every time, we will repeat the training process five times and keep the trained network with the smallest error.
Once the neural network is properly designed and configured, we can proceed to its training. The results published by the works' authors correspond to 5,100 training iterations. For the purpose of today's discussion, I'll show much of your epochs, both using a CPU with my laptop computer, and a GPU on a leased machine in our headquarter in Natick.
This is what MATLAB shows when we start a training. Based on the time it takes to complete each iteration, we can estimate that 50 or 100 iterations times 5 repeats would take about 20 hours to complete the task. Let's compare this against training using a GPU.
When we use a GPU, it takes about 1 minute to complete the 100 epochs, which extrapolated to 51 times 5 repeats, we obtain 4.25 hours. Roughly, a five time speed up with respect to using a CPU.
Now let's go back to the results of the 5,100 epochs that we had saved. Once the neural network is trained we can test it against experimental data that the network never saw before. The root mean square error is quite low between 1% and 2%, depending on the temperature. The maximum error for the testing data is shown here, and it is larger at low temperatures as expected.
These are the neural network predictions for SOC at different temperatures. There's excellent agreements between prediction and experiment.
So that was the MATLAB part. Carlos and Phil, do you have anything to add?
Thank you, Javier. I would just like to add that the script is also shared online in the Mendeley Data Repository and a link is included at the end of the presentation.
We are now ready to deploy the trained network in Simulink. This is useful if we already have an established workflow for BMS design in Simulink. As described in past webinars, Simulink provides a natural path for BMS algorithm development and automated code generation. Starting from MATLAB release 2020B, Simulink offers a block called predict with the functionality of a trained deep neural network. This will allow us to include an SOC estimation feature into a BMS model.
When we trained the network in MATLAB, we stored the network parameters and architecture in a network object that we call to net. We can now use this net object directly in Simulink inside that predict block. Doing so, the block will accept an input signal with a dimensionality of the input layer of the neural network and will output the prediction. Let's reproduce in Simulink the results we obtained in MATLAB running the Simulink model.
The network performs very well, much faster than real time, and it is now in a form that can be utilized directly in a BMS model developed in Simulink. Let's now summarize what we've shared with you in this event. We began with a problem statements, the importance and challenges associated with battery State of Charge estimation. As an alternative to the state-of-the-art techniques, we presented the work and results of a team at McMaster University on the use of MATLAB and Deep Learning Toolbox to create a Feedforward Neural Network for the estimation of State of Charge.
Using data from two different cell chemistries and multiple temperatures, the neural network could predict state of charge within 2% accuracy. Finally, we showed how to deploy the trained network in Simulink using a new block called predict. Thank you very much to my guests and thank you all for kindly sharing your time with us today. See you next time.