Wolfram Computation Meets Knowledge

Battery Model and Analysis with Wolfram SystemModeler

Explore the contents of this article with a free Wolfram SystemModeler trial. How do different activities such as making phone calls, watching video, listening to music, or browsing the web affect cell phone battery life? What about the temperature—does it matter if the cell phone is in a warm pocket or out in the cold? In this blog post, we’ll investigate how a model constructed with Wolfram SystemModeler can help in finding answers to such questions.

An area where battery usage is taking off right now is cell phones. There are different kinds of battery types used in cell phones: nickel metal hydride, lithium-polymer, and Li-ion. The superior energy density, power density, low self-discharge, and long cycle life of the Li-ion batteries makes them interesting for cell phone applications. In this blog post, we’ll look at Li-ion cells of the type LiFePO4, where lithium ions move from the negative electrode to the positive electrode during discharge and the other way around when charging.

The are many types of battery models: analytical, electrical circuits, electrochemical, and combinations of these types. Our model of choice is the electrical circuit model, which provides sufficient accuracy for top-level performance analysis and is easy to connect to other systems.

A typical schematic for an electrical circuit model of a battery cell might look something like this:

Sketch of a typical schematic for an electrical circuit model of a battery cell

The left part is the energy balance unit, which will determine the cell capacity and amount of energy left in the cell. The right part is the voltage response circuit, which will determine how the cell voltage responds to a given load current. The resistors and the capacitors in the sketch are variable and depend on the State of Charge (SoC), processed charge, and the temperature. The SoC can vary between 1 (fully charged) and 0 (empty). To ensure safe operation, we only permit the SoC to operate in the region from 0.1 to 0.9.

The above sketch is easy to translate into a SystemModeler model. By dragging and dropping the corresponding components from our library into our model and connecting them together, we have a model of a battery cell similar to the sketch:

Model of a battery cell

The threshold components at the top of the model ensure that the cell will turn off if the SoC gets too high or too low. We use this to stop the simulation when we reach these limits, as the model is only accurate within these bounds.

The variable components are components from the Modelica Standard Library with fitted functions from this thesis by Long Lam. Here’s an example of what one of the components, the long transient capacitance, looks like:

Model including variable components

As we can see, it’s easy to incorporate custom expressions in the model. One expression will be used during the charge cycle and another during the discharge cycle. The switch will change between the two when the current drops below zero or rises above zero. The fitted expressions will dictate the behavior of the variable capacitance. We can construct the other circuit elements in the same way.

Let’s return to our initial questions and try to use a typical cell phone load on the battery cell. The data is from this paper. There are 11 different modes the cell phone can be in: suspend, idle, phone call, email (Wi-Fi and GPRS), web (Wi-Fi and GPRS), network downloads (Wi-Fi and GPRS), video playback, and audio playback. The power consumption is as follows:

data = {{"Suspend", 26.6}, {"Idle", 161.2}, {"Phone call", 822.4}, {"E-mail (cell)", 599.4}, {"E-mail (WiFi)", 349.2}, {"Web (cell)", 430.4}, {"Web (WiFi)", 270.6}, {"Network (cell)", 1016.4}, {"Network (WiFi)", 1355.8}, {"Video", 568.3}, {"Audio", 459.7}};

BarChart[data[[All, 2]], ChartLabels → Placed[data[[All, 1]], Below, Rotate[#, Pi/2.4] &], AxesLabel → {"", "mW"}]

Bar chart showing the power consumption of a cell phone battery

We’ll create a usage cycle where most of the time is spent in the suspend state:

durations = {.8, 2/60, 5/60, 5/60, 3/60, 4/60, 12/60, 5/60, 4/60, 3/60, 15/60}; normalizedDurations = Normalize[durations, Total]

PieChart[normalizedDurations, ChartLabels → data[[All, 1]]]

Chart showing the usage cycle where most of the time is spent in the suspend state

The load profile will look like this:

ListPlot[datause, Joined → True, Filling → Axis]

Chart showing the load profile

There’s now a multitude of different questions we can ask the model: How long will the battery last with this type of load cycle repeated? How does the potential change throughout the drain cycle? Does it matter at which temperature I keep the cell phone? With the connection between Mathematica and SystemModeler, analyzing these types of questions becomes easy:


Errors showing the simulation has terminated

WSMPlot[cellSimulation, {"battery.SoCOutput"}, Filling → Axis, AxesLabel → {"t", "SoC"}]

Discharge curve and the SoC

The time until the SoC reached 0.1 and the battery shut down turns out to be almost 14 hours:



How long would the standby time be? This can be found out by using only the suspend mode:

suspendSimulation = WSMSimulate["StandbyCellPhone", {0, 600000}]



In the same way, we can find out that the battery will last just over three hours with constant network usage:

networkSimulation = WSMSimulate["NetworkCellPhone", {0, 90000}]



Let’s compare two cell phones with the load profile we created above: one in Stockholm and one in Mexico City. The cell phone in Sweden will be at 0° C and the one in Mexico at 40° C.

{simSTH, simMC} = WSMSimulate["Battery.BatteryDischarge", {0, 80000}, InterpolationOrder → 1, WSMParameterValues → {"ambient.T" → {0, 40}}];

Create two plots:

{plotStockholm, plotMC} = {WSMPlot[simSTH, {"battery.stateOfCharge.phi"}, PlotStyle → Red], WSMPlot[simMC, {"battery.stateOfCharge.phi"}]};

Show[plotStockholm, plotMC]

Graph showing results for the phone in Stockholm and the phone in Mexico City

For this load profile, the battery in Mexico City will last 18 minutes longer than the one in Stockholm:

(simMC["SimulationInterval"][[2]] - simSTH["SimulationInterval"][[2]])/60


In SystemModeler it’s easy to start with an intuitive model based on standard components, test it in Simulation Center or Mathematica, and gradually add more components and finer granularity to create a full model.

Equipped with this model, we can go on to answer more questions. What is an optimal charging scheme? Does it matter if I fully charge and discharge the battery, or will the battery lifetime be the same if I just charge it in small chunks now and then? What will the expected discharge time for your typical load profile be? Download the model from the industry example page and find out!

Download this post as a Computable Document Format (CDF) file.


Join the discussion

!Please enter your comment (at least 5 characters).

!Please enter your name.

!Please enter a valid email address.