Code covered by the BSD License  

Highlights from
Lithium Battery Model, Simscape Language and Simulink Design Optimization

4.8 | 5 ratings Rate this file 200 Downloads (last 30 days) File Size: 944 KB File ID: #36019
image thumbnail

Lithium Battery Model, Simscape Language and Simulink Design Optimization


Robyn Jackey


19 Apr 2012 (Updated )

Multi-temperature lithium battery model using Simscape language and Simulink Design Optimization

| Watch this File

File Information

This file contains multi-temperature lithium battery model examples with thermal dynamics that are implemented using the Simscape language. There are equivalent circuit model examples containing 1 RC branch and 2 RC branches, plus an 80-cell battery pack model. The number of branches can be chosen to balance fidelity and parameter estimation complexity. These models are implemented using Simulink and Simscape language.
Estimating battery parameters can be a complex task. For help, please see:
Estimating Parameters of a Battery (video, 4:49)
An overview that shows how Simulink Design Optimization can estimate parameters.

Automating the Parameter Estimation of a Battery Model (video, 9:55)
A video that shows automating the parameter estimation process, when you have lots of experimental data to process.

Automating Battery Model Parameter Estimation using Experimental Data (webinar, 25:28)
A longer webinar that shows the automated parameter estimation workflow in more detail.


Additional literature:

Webinar: Battery Data Acquisition and Analysis Using MATLAB

Webinar: Lithium Battery Model with Thermal Effects for System-Level Analysis

IEEE 2012: Lithium Battery Model with Thermal Effect

SAE 2013: Simplified Extended Kalman Filter Observer for Battery SOC Estimation

SAE 2013: Battery Model Parameter Estimation Using a Layered Technique

SAE 2014: Battery Pack Modeling, Simulation, and Deployment on a Multicore Real Time Target

Webinar: Optimizing Vehicle Electrical Design through System-Level Simulation

Video: Real-Time Simulation of Battery Packs Using Multicore Computers

Video: MATLAB & Simulink Racing Lounge: Battery Modeling with Simulink

Using Model-Based Design to Build the Tesla Roadster


MathWorks Consulting offers services on this topic. For assistance, please contact me or your MathWorks representative.


Automotive Electrical System Simulation And Control inspired this file.

This file inspired Automotive Electrical System Simulation And Control.

Required Products Optimization Toolbox
Parallel Computing Toolbox
Simulink Design Optimization
MATLAB release MATLAB 7.14 (R2012a)
MATLAB Search Path
Other requirements R2012a or later recommended, R2010b or later required
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (27)
03 Dec 2014 Valentin


Thank you very much for these nice examples!

We try to characterize a electronic car battery for appropriate SoC-estimation in the car.
Therefore we measured pulse data and are doing parameter estimation.
Now the question: How do you use the gained data later on in the devices (eg our car)? You normally generate look up tables and implement them in the ECU? Or you bring the complete model to the ECUs? What would be the typical way of proceeding?

Thank you in advance!

Comment only
03 Dec 2014 Valentin


04 Nov 2014 Robyn Jackey

Robyn Jackey

Kirankumar - You can use drive cycles (validation) data with Simulink Design Optimization to tune parameters of a model. I would encourage doing so. However, the circuit parameter values may need to have good initial guesses for them to converge.

Pulse data is nice because it allows you to isolate the contributions of the different equivalent circuit elements.

Comment only
03 Nov 2014 Kirankumar


We are trying to estimate parameters for Lithium-Ion battery with Rin+R1||C1 structure. For moment we shall not consider the thermal effect. All three parameters shall be 2-D look-up tables with breakups along SOC and Ibat(temperature in future).

We are looking for high accurate estimation(<10mV). Till now, we used System identification tool box to estimate the parameter for all the scenarios as per the breakups mentioned above. But, while validation with drive pattern data(validation data) we get huge error. We are thinking to try Parameter estimation toolbox to get better results.

My query is:
1) is it possible to directly feed the validation data to parameter identification toolbox for estimation? or its always necessary to provide the pulse data for estimation?
2) Intent is we do not have all the pulse data with different SOC and Ibat.


18 Sep 2014 John Arvanitis

John Arvanitis

Great Job (Lithium Battery Model, Simscape Language and Simulink Design Optimization)

Now we have an easy way to parameterize battery with accuracy on all conditions.

One question please:
1) During of Model Advisor usage we got
the following error

On Modeling Standards for DO-178C/DO-331 - Check safety-related optimization settings and
On Modeling Standards for DO-178C/DO-331 - Check safety-related code generation settings

Abnormal exit: BLAS loading error: mkl.dll: Not enough storage is available to process this command.

What could I do in order to over come this problem?

Comment only
10 Jul 2014 Johnny Rico

Johnny Rico

The downloaded zip archive appears to be damaged. I request the author to kindly re-upload the same.


Comment only
23 May 2014 Ali Rostami

Ali Rostami

I have troule downloading the file from
the error message is " the site is unavailable or cannot be found.
Has anyone experienced the same or any solution?

Comment only
16 Apr 2014 han


25 Feb 2014 Robyn Jackey

Robyn Jackey

I will be presenting during a workshop entitled "Developing Battery Management Systems Using Model-Based Design" at the American Control Conference on June 3rd in Portland, OR. If you are interested in attending, please see:

Comment only
24 Feb 2014 Robyn Jackey

Robyn Jackey

Lu - can you email me directly through the contact author page?

Comment only
23 Feb 2014 Lu


Hi Robyn, thank you for sharing.

I have a question about the paper"SAE 2013: Simplified Extended Kalman Filter Observer for Battery SOC Estimation

In this paper, you model the hysteresis effect, and use k as the hysteresis factor.
how can I understand the following sentence in Page5"The value of k was obtained by inspection by minimizing the difference between the experimental and simulated VOC vs. SOC curves. VOC(VSOC) is the instantaneous value of the OCV on the minor loop."

what's the experimental VOC(VSOC),is caculted by(VOCch(VSOC)+VOCdisch(VSOC) )/2?
and what's simulated VOC(VSOC), is the difference between measured terminal voltage (Vt) and VRC?

would you please share the progress of k fitting.


27 Jan 2014 Robyn Jackey

Robyn Jackey

Christopher - I have not seen that license error before. Can you please try contacting MathWorks technical support?

Comment only
24 Jan 2014 Christopher


I was trying to follow the instructions in the README file, but step 2 is giving me a couple similar errors, for example:
"Error using save_system>i_builtin (line 188)
Cannot save this library because block R_table_1Temp requires a license for , which could not be obtained.
Please try again when a license becomes available."

I am using Matlab R2013A, Simulink 8.1, Optimization Toolbox 6.3, Parallel Computing Toolbox 6.2, and Simscape 3.9. It doesn't look like I Have the Simulink Design Optimization, but I don't think that's what is causing the error that I am seeing. Do you have any suggestions? I looked under the Simulink examples, and I don't see the battery demo even though it is supposed to ship with it.

Thank you!

Comment only
19 Nov 2013 Robyn Jackey

Robyn Jackey

With R2013a and later, the ssc_lithium_cell_1RC and ssc_lithium_cell_2RC, along with the library LiBatteryElements are now shipping Simscape demos. The shipping versions should be used, because of a Simscape change requiring use of Kelvin rather than Celsius in Simscape language code. The additional demos in this MATLAB Central entry should work, just ensure that the older LiBatteryElements libraries are not added to your MATLAB search path, so it uses the shipping versions.

Comment only
13 Nov 2013 Maryam Bahramipanah

Maryam Bahramipanah

Thanks Robyn. I did exactly what is written in Readme.text, but by running "ssc_build LiBatteryElements" , I am receiving this error :
Error using LiBatteryElements.C_table (line 9) Input 'T' declared with unit expression that contains an affine unit: 'C'. Affine units are not allowed when declaring members of this type.

:(. I am using the R2012a files.

Comment only
12 Nov 2013 Robyn Jackey

Robyn Jackey

Hi Maryam,
You might need to add all the directories to your MATLAB search path first. To fix the error you encountered, you might need to rebuild the Simscape library for your platform and MATLAB version. There are directions in the included readme.txt file.

Comment only
11 Nov 2013 Maryam Bahramipanah

Maryam Bahramipanah

Robyn, I found that I have to run the liBatteryelemets before. SO, I have no problem with that any more. But there is another problem :( . when I started the estimation, I received this message "index exceed matrix dimension". Do you know what is it for?

Comment only
11 Nov 2013 Maryam Bahramipanah

Maryam Bahramipanah

Hello. First of all thanks for uploading the files.

When I am trying to open each elements of the model (for instance R_table_1Temp), I receive this error:

Error Id: ne_dli: internal: unableToCreatDialog

unable to creat block dialog. If the block belongs to a custom simscape library, please run ssc_build to rebuild the library...."

Can you please help me with that?


Comment only
07 Jun 2013 zwbscg


15 Apr 2013 Robyn Jackey

Robyn Jackey

For R2012b and later, there are shipping demos of ssc_lithium_cell_1RC and ssc_lithium_cell_2RC models. the LiBatteryElements package is also part of the shipping Simscape demo, so it's not included in the R2012b folder of the zip file.

Comment only
15 Apr 2013 Vita


Isn't there any LiBatteryElements package in the R2012b folder?

Comment only
03 Dec 2012 Robyn Jackey

Robyn Jackey

Hi Mengjia - Unfortunately the errors you see are expected and the model will not work in R2010a or earlier. The early versions of Simscape lookup tables required all dimensions to be a minimum of size 4, and my demo model only contains 3 temperatures. It will work fine in newer releases, otherwise it might work if you add a fourth temperature to the data for each lookup table.

Comment only
03 Dec 2012 Mengjia


Hello, I've got errors as below running ssc_lithium_cell_1RC.mdl

1. ssc_lithium_cell_1RC/Solver Configuration: Unable to compile the physical network.

2. sc_lithium_cell_1RC/Lithium Cell (1RC equivalent circuit model)/Main Branch Voltage Source (Em)/PS Lookup Table (1D): The size of the vector of input values or output values must be greater than 3.

3. ssc_lithium_cell_1RC/Lithium Cell (1RC equivalent circuit model)/C1/PS Lookup Table (2D): Y-vector must have no less than 4 elements.

And for other 3 lookup tables(2D) I've got the same Y-vector elements issue, so totally 6 errors.

I've followed the 2 steps as readme.txt stated, please kindly advise where go wrong?

PS: I am using the Matlab R2010a to run the files in folder R2010b.

Comment only
12 Jul 2012 Robyn Jackey

Robyn Jackey

To answer your questions:

1. In the paper, we chose the initial conditions based on the driving cycle we used for validation. The temperature T=20 was based on a measured cell temperature (approximately same as electrolyte). Initial SOC was selected based on best fit of the measured vs simulated voltage at the very beginning part of the drive cycle.

2. You can modify the InputData*.xls files and import them into the Signal Builder block if you like to change the input curves. However, you will need to delete the "Copyright ..." string that was placed in cell E1 to avoid an error. Otherwise, Signal Builder tries to import data from column E, causing the error you found.

Comment only
10 Jul 2012 dang hong

dang hong

Dear Sir,
In reference paper " high fidelity electrical model with model with thermal dependence for characterization and simulation of high power lithium battery cells", how to choose initial SOC = 45 %,T =20, ? For example, in the case of using ssc_lithium_cell_1RC.mdl.
when importing "InputData_1RC.xls" in signal builder of ssc_lithium_cell_1RC, there is a error " attempted to access td(:,3); index out of bounds because size(td)=[46,2]. How to import that file?

Comment only
05 Jun 2012 Robyn Jackey

Robyn Jackey

The R2012a folder contains files that use newer features that will only work on R2012a or later. I suspect that is the reason for the build error. The R2010b model should work in that version and up, however it is a little less tidy because the lookup tables were external to the custom Simscape language blocks.

Comment only
04 Jun 2012 david


run ssc_build LiBatteryElements

the following errors apeared.

Generating 'LiBatteryElements_lib.mdl' in the current directory 'C:\Documents and Settings\Jiucai\My Documents\Downloads\ssc_Li_cell_20120419\ssc_Li_cell_20120419\R2012a' ...
Failed to generate 'LiBatteryElements_lib'

Caused by:
Error using ne_buildpackage (line 32)
File: C:\Documents and Settings\Jiucai\My
Line: 13
Attribute Size is not supported for constructs of type

Comment only
19 Apr 2012
19 Apr 2012

Updated copyright statement, link to webinar.

15 Jun 2012

Added link to demo video. Removed extraneous Simscape mex files. (Note: you will need to run "ssc_build LiBatteryElements" to build a machine-specific Simscape library for the battery building blocks.

02 Jul 2012

Added 80-cell battery pack model.

19 Dec 2012

R2012b folder with .SLX file format. Excluded R2012b +LiBatteryElements folder because it is a shipping demo.

ssc_lithium_cell_SDO_Project.mat parallel computing unchecked as default, due to a bug if the toolbox is not installed. See Readme.txt

11 Jun 2013

Updated the R2012b+ version of the models:
1. The shortcut block to open the custom library was broken
2. Use Kelvin temperature units within the Simscape model

There is a known bug in R2013a. Please see README.txt for info.

13 Jun 2013

Modified description only to add links to new publications.

18 Jun 2013

Fixed an issue with temperature units on R2012b demos.

26 Jun 2013

Updated a bad link to the parameter estimation video.

10 Sep 2013

Added a new webinar link to the description

28 Jan 2014

Updated description only. No file changes.

25 Mar 2014

Description updated - added a link to the Battery Data Acquisition webinar. No changes to the files.

18 Apr 2014

Added acknowledgement for other entry - electrical system simulation

22 Apr 2014

Corrected webinar links

05 Nov 2014

updated links in description only

08 Dec 2014

Updated link to: SAE 2014: Battery Pack Modeling, Simulation, and Deployment on a Multicore Real Time Target

Contact us