Modeling Batteries Using Simulink and Simscape
From the series: Hybrid Electric Vehicles
Learn about equivalent circuits and why you’d want to use them. In this video, you will learn to:
- Use equivalent circuits to represent the dynamic behavior of a battery cell.
- Identify how to parameterize the equivalent circuit based on measurement data using parameter estimation.
- Improve and refine an estimation, adding fidelity to the model with the use of more elaborate equivalent circuit topologies.
Hello, everyone. My name Javier Gazzarri. And I am an application engineer at MathWorks specialized in design and analysis of battery systems using modeling and simulation. I am a mechanical engineer with a bachelor's degree from the University of Buenos Aires, and Master and PhD degrees from the University of British Columbia.
Before joining MathWorks seven years, ago I worked for four years for the government of Canada studying the low temperature fuel cells at the Institute for Fuel Cell Innovation of the National Research Council in Vancouver BC.
Lithium ion is the battery cell type of preference in modern electric and hybrid vehicles because of their high specific energy, good cycle life, and very low cell discharge. However, with all these advantages comes the need for a careful battery management to ensure safe operation and acceptable durability. For example, temperature and voltage should remain within acceptable limits to avoid premature degradation, as should power delivery and acceptance.
Today I will share with you some ideas about how to create a Simulink model for a battery cell to be used in battery system design and control. First, we will show how to use equivalent circuits to represent the dynamic behavior of the battery cell. This is important since the BMS, as any controller, needs to be tuned to the dynamics of the plant it is connected to. A good model of the battery cell will tell me how it behaves as a function of environmental conditions and state of charge.
Secondly, we will see how to parameterize the equivalent circuits based on measurement data using parameter estimation, a technique based on optimization to fit models to experimental data. Finally, we will see how to improve and refine an estimation, adding fidelity to the model with the use of more elaborate equivalent circuit typologies, compliment the study with curve fitting, and accelerate calculations using parallel computing.
Developing a battery system using a model-based design requires a model of the battery cell that accurately represents its real life behavior and dependencies on environmental and operating conditions. For example, it needs to reproduce the voltage drop in time dependent recovery following a current discharge event, such as a pulse. Although it would be desirable to capture all the details of the electrochemical phenomena present in a battery cell, controls-oriented applications demand a more efficient approach that can be scaled up to battery pack levels and eventually capable of real-time simulation.
A widely accepted compromise between fidelity and simulation time is the equivalent circuit. The equivalent circuit is an electrochemical analogy aiming at representing the behavior of an electrochemical cell using a relatively simple electrical circuit containing a voltage source and several resistors and capacitors that collectively reflect the open surrogate potential, the internal resistance, and the relaxation time of the real cell.
When modeling a battery cell, using any given circuit, it is important to choose circuit topology and parameterization such that it can respond as similarly as possible as a physical battery cell.
A typical equivalent circuit includes the voltage source associated with the open circuit potential, a series resistor related to the ionic conductivity of separator and electrolyte, and one or more resistor capacitor pairs that mimic that diffusion of processes involved in the interpolation and deinterpolation of lithium ions in and out of the porous electrodes.
As far as the parameterization is concerned, it is of crucial importance to capture the electrochemical and dissipated phenomena observed when testing a real battery as well as their dependencies on states and environmental conditions. These requirements demand the use of matrices instead of scalar parameters that function as lookup tables constituting the physical fingerprints of the lithium ion chemistry of interest.
One possible route to determine the characteristic parameters of an equivalent circuit is performing parameter estimation. Parameter estimation is an optimization based procedure by which simulation result is compared against an experimental measurement and the parameters of the model are determined in such a way that simulation matches the experiment. It all begins by proposing an equivalent circuit architecture that, based on a previous knowledge of the system, we believe can represent the behavior of the real system.
The initial parameterization of equivalent circuits is done using tentative values based on our experience. The simulation is set to reproduce the conditions of the discharge experiment, typically done in a controlled temperature environment.
Let's take a look at the experimental data first. Keeping a constant temperature of 25 degrees Celsius, a 31 in power nickel manganese core battery cell is discharged from a fully charged state all the way down to 0 SOC. While current is flowing out of the battery, the measured voltage drops and then recovers after the pulse. The shape of the voltage drop in recovery is characteristic of these particular battery chemistries.
And the goal of this procedure is to be able to reproduce it using the equivalent circuit with the right parameters. More specifically, the series resistance needs to account for the instantaneous portion of the recovery. The combined RC pair needs to explain the exponential portion of the recovery. The voltage source must deliver the correct OCV as a function of SOC.
Additionally, we can observe that the response is different states of charge levels. Because we do not have direct control over the state of charge, but it is state that changes as we drop current out of the cell, we need to allow all the parameters to be lookup tables as opposed to scalers to account for the SOC dependence.
This is a Simulink model designed for such purpose. A series of discharge current pulses is drawn from the equivalent circuit inside this block in the same way as it was done in the laboratory. At the same time the voltage across terminals is measured using this voltage sensor to be compared by the optimizer against the voltage measured experimentally.
Looking inside the lithium ion cell block, we can see a simple equivalent circuit with a voltage source, an internal resistance, and a single RC pair. Later, we will observe that only one time constant is not enough to capture all the dynamics of this particular cell. If we run the model using the initial guess as parameters, we observe this mismatch between simulation and experimental measurements.
Simulink will work with MATLAB's optimization functions trying to minimize the difference between simulation and experimental data by adjusting the parameters of the equivalent circuit. This is done using a library called Simulink Design Optimization. This tool acts as a bridge between Simulink and MATLAB's optimization functions.
On the left hand side, we can see the four parameters to be estimated. We need to keep in mind that each of them is actually a vector of 10 elements corresponding to 10 levels of state of charge. Secondly, we specify the experiment to be used for each estimation. We always recommend to have at least one independently measured set of data reserved for validation.
When we start the estimation, Simulink runs the model over and over again. And every few runs, it evaluates how far it is from its objective, namely the experimental curve. While it is not close enough, it imposes perturbations to the values of the parameters to be estimated and evaluates if that change improves the situation or not. This is done in a very efficient way using advanced optimization algorithms.
The present calculation takes a few minutes to converge, so we will speed it up for demonstration purposes.
On the right hand side, we can see the evolution of the parameters. Each color represents one of the four equivalent circuit elements. And each line within each color corresponds to a specific level of state of charge.
Let's evaluate the final result. We can see that for most part the optimizer does a good job fitting the voltage drop events and the relaxation. However, in certain places the fit is clearly not good enough. This is a time to evaluate the validity of the equivalent circuit topology that we proposed at the beginning.
In some cases, it is clear that the exponential voltage relaxation is more complex than a single time constant exponential curve, leading us to believe that the equivalence circuit needs to be more elaborate. One easy thing to try is to add more time constants.
Let's look at a single relaxation event and see what we find using simple curve fitting. Going back to the experimental measurement, we select one relaxation interval. Let's now export the data into a variable and look at it using the curve fitting tool box. Since we are interested in quite specific function forms, we will need to use a custom equation, specifically one that has a sum of exponential terms.
It does not take more than three exponential terms to fit the relaxation much more accurately than before. This is an indication that three RC components are a better choice when it comes to selecting the equivalent circuit topology. Let's try that.
This model is similar to the one that we saw before, but now the equivalent circuit contains three time constants instead of one. The number of parameters being calculated is now 80, 10 for each of the eight equivalence target elements. For a problem this large, it makes sense to use parallel computing to distribute the computational load.
Simulink design optimization, allows us to do this effortlessly by selecting the use of parallel computing in the options. Again, we will show the process at an accelerated rate for demonstration purposes. Here are the results.
This procedure must be repeated at every temperature of interest and for which there is experimental data available. Each vector of parameters identified with this technique will be stacked to constitute the lookup table that will later parameterize the general non-isothermal model. We will see this modeling detail on a separate lecture.
To summarize, we have seen how to use Simulink model with Simulink components in combination with isothermal discharge data to find the best equivalent circuit and parameters that describe the behavior of a given lithium ion battery cell. To perform this calculation, we made use of Simulink design optimization.
In this video we saw a method to create and parameterize an equivalent surrogate for a lithium ion cell using a combination of experimental measurements, simulation, and optimization. We started proposing an equivalent circuit topology and initial parameter of guesses. And we saw how MATLAB and Simulink work together to create an optimization problem to calculate the parameter values. The result is a battery cell block that contains the information to model the behavior of a real battery cell, and that is reusable in any system level model of an energy storage arrangement based on the type of device under study.
The next step from here is to create a model of the entire battery pack and design the battery management system around it. This will be the subject of a separate video.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
- América Latina (Español)
- Canada (English)
- United States (English)
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- United Kingdom (English)
- Australia (English)
- India (English)
- New Zealand (English)
- 日本Japanese (日本語)
- 한국Korean (한국어)