Identifying Knees in Battery Capacity Degradation Data

Introducing the KneeFinder Python Module

Richard Gilchrist
8 min readJun 5, 2023
Photo by Roberto Sorin on Unsplash

While working at the University of Edinburgh, I implemented the method described below as KneeFinder. This was done in order to eliminate copy-and-paste code, and ensure consistency across our projects. It is now available for the benefit of the wider research community so that others can easily apply this method to their own applications, or take it and modify it as they wish.

  • You can find the GitHub repo here.
  • You can play with KneeFinder using this interactive Streamlit app, where you can explore some example data or import your own.
  • (Note: not currently available on pip or conda. Coming soon!)

Introduction

In the world of battery research, it is important to understand how a battery’s health will degrade with use. Over time, with repeated cycles of charging and discharging, a cell loses its ability to store electrical charge — that is, its capacity degrades. An important milestone in this degradation process is referred to as the knee point, considered to be the point at which the capacity degradation transitions from a slow rate to a fast rate. This article describes a method for identifying the knee onset and knee point within a capacity fade curve.

Along with colleagues, I contributed to the development of this method while working as a research assistant at the University of Edinburgh. There, we used this method to obtain training targets for deep learning models which were trained to predict the future degradation profile of a cell, given time series data from just one charge-discharge cycle as input.

Terminology and Definitions

Here are some brief definitions of relevant terminology and concepts, in order to provide context for the rest of this post and the accompanying post, which focuses more on the code within the KneeFinder class.

  • Capacity: A battery’s capacity is measured in amp hours (Ah) and is defined as the amount of electric charge the battery can deliver at its rated voltage. We see the amp hour has dimensions of current multiplied by time (Q = It), and 1 Ah is equivalent to the charge delivered by a steady 1 A current for 1 hour (3600 seconds). 1 Ah = 3600 Coulombs.
  • Cycle: A complete discharge and subsequent charge of a cell.
  • End-of-life (EOL): We may consider a battery being at the end of its life based on either its capacity or internal resistance (IR). A battery is considered to be at EOL once its capacity drops to 80% of its initial capacity value, or when its internal resistance reaches 200% of its initial value.
  • Knee Onset: The concept of the knee onset is introduced in [1] and defined as “the point that marks the beginning of the accelerated degradation rate at which the capacity fade can no longer be approximated as a linear function.”
  • Knee Point: We can think of the knee point as the transition from a slow capacity degradation rate to a fast one. Picking a single point in a capacity fade curve that represents the knee point is a subjective task, since the transition occurs over a number of cycles and is not abrupt [1]. An example capacity fade curve that exhibits a knee is shown below.
Figure 1— Capacity degradation of a cell, showing a knee profile. Annotations show the cycles at which knee onset, knee point and end of life were identified. Data taken from [2].

Motivation

The authors of [1] demonstrate strong linear relationships between both the knee onset and knee point, and the cycle life of a cell. Additionally, in a review paper which I contributed to [6], this linear relationship between knee point and end of life is shown to hold for a larger data set, containing cells of varying chemistry, size and geometry. This suggests that given a prediction of the knee point, it may be possible to obtain an estimate of the end of life.

Identifying the knee point in a capacity degradation curve provides us with a training target for machine learning models. The ability to predict when the knee point will occur may be of interest to battery manufacturers, warranty suppliers and end users. Having an estimate of when the knee point will occur provides information about the future capacity loss of a cell, which may be useful for effective maintenance, servicing and replacement.

The KneeFinder Method

The application of Bacon-Watts and double Bacon-Watts models to locate the knee onset and knee point was described by Fermín-Cueto et al [1]. The approach was extended by myself and others, as described in Strange et al. [3]. The steps involved in the method, illustrated using fake data for clarity, are as follows:

  • Fit an isotonic regression model to the full experimental capacity degradation curve, then predict to yield a non-increasing curve by linear interpolation.
  • In the case of a degradation curve having a sigmoidal shape (as above), the results of subsequent fitting steps may be improved by applying truncation. First, we fit an asymmetric sigmoidal model (equation 1) to the monotonic curve. The cycle number, n, where the second derivative of the asymmetric sigmoidal fit changes sign is identified. The monotonic fit is truncated at cycle n. If there is no sign change, no truncation is required and n is set to the last cycle in the data.
Equation 1 — Asymmetric sigmoid
  • Fit the line plus exponential model (equation 2) to the monotonic fit up until cycle n.
Equation 2— Line plus exponential
  • Fit the Bacon-Watts model (equation 3) to the line-plus-exponential fit to identify the knee point, x1. The knee point is annotated with a dashed vertical red line on the plot.
Equation 3— Bacon-Watts
  • Fit the double Bacon-Watts model (equation 4) to the line-plus-exponential fit to identify the knee onset, x0.
Equation 4— Double Bacon-Watts

The plot below shows the cycles at which the knee onset and knee point were identified, along with the corresponding capacity values for these milestones. In this particular case, we also see that the capacity dropped below the critical threshold of 80% of its initial value, and so we see the cycle number at which end of life occurred.

Results With and Without Truncation

Here is a demonstration of the difference that the truncation step makes in the identified knee point:

Without truncation method, the knee point was identified at cycle 867.
With the truncation method, the knee point was identified at cycle 934.

Using KneeFinder in Practice

Import the KneeFinder class from the module.

from knee_finder import KneeFinder

Creating an instance of KneeFinder only requires x and y arrays. The analysis is performed upon instantiation.

kf = KneeFinder(x, y)

You can optionally enable automatic truncation for handling sigmoid-like curves. mode can be specified as either 'knee' or 'elbow' depending on your data.

kf = KneeFinder(x, y, automatic_truncation=False, mode="knee")

The results are stored in the attributes onset, point, onset_y, point_y , eol_cycle and eol_val (if the end of life is reached).

# Print x results (cycle numbers)
print(np.round(kf.onset, 2))
>> 280.76
print(np.round(kf.point, 2))
>> 344.69

# Print y results (capacity values)
print(np.round(kf.onset_y, 2))
>> 1.04
print(np.round(kf.point_y, 2))
>> 1.01

# Print the end of life info
print(np.round(kf.eol_cycle, 2))
>> 447
print(np.round(kf.eol_val, 2))
>> 0.86

Plot the results with optional parameters to show different curve fits (monotonic, line-plus-exponential, asymmetric sigmoid.) The data_style parameter controls the line style for the x and y data.

kf.plot_results(mon=False, line_exp=False, sig=False, data_style='-')

If you want to use KneeFinder without downloading the code, you can use the interactive Streamlit app where you can see the results and plot the various curves described above, as well as playing with the manual and automatic truncation modes available.

Advantages and Disadvantages of KneeFinder

+ Can identify onset, point and EOL all at once.
+ Works for knees and elbows (concave and convex).
+ Robust against noisy data.
+ Robust against data with a sigmoidal profile. The bounds of the data considered for analysis can be adjusted automatically to exclude sigmoidal profiles, or manually as the user specifies.
+ There is an interactive Streamlit app you can use to experiment with the method using your own data, or the data from [2]. You can compare the knee points identified by KneeFinder with those obtained using piecewise linear regression.

— Because there are multiple curve fitting operations, it is not guaranteed to find a solution. Depending on your data, it may be necessary to tune the parameters for bounds and initial values.
— More complex than some other methods.
— No support for online operation. Methods like kneedle [4] do support this.
— Developed specifically using, and for, battery data.

Conclusion

Since there is no strict definition for when knee/elbow points (or onsets) occur, the task of specifying their locations is subjective. It is important to remember that the method described here is just one method for locating knee/elbow points.

Some of these other methods include:

  • Maximum curvature
  • Piecewise linear regression
  • Kneedle [4] (implementation here)
  • Slope-changing ratio [5]

Using the Streamlit app, we can see that with the Severson data [2], KneeFinder and the piecewise linear fit method often identify knee points that are very close to one other.

A plot generated using the KneeFinder Streamlit app, showing close agreement between the knee points identified using KneeFinder (red) and the piecewise linear fit method (green).

Comparing the results from a number of methods may give you greater insight and be beneficial for your specific application.

References

[1] P. Fermín-Cueto et al., “Identification and machine learning prediction of knee-point and knee-onset in capacity degradation curves of lithium-ion cells,” Energy and AI, vol. 1, p. 100006, 2020. doi:10.1016/j.egyai.2020.100006

[2] Severson, K.A., Attia, P.M., Jin, N. et al. “Data-driven prediction of battery cycle life before capacity degradation.” Nat Energy 4, 383–391 (2019). doi: 10.1038/s41560-019-0356-8

[3] C. Strange, S. Li, R. Gilchrist, and G. dos Reis, “Elbows of internal resistance rise curves in li-ion cells,” Energies, vol. 14, no. 4, p. 1206, 2021. doi:10.3390/en14041206

[4] V. Satopaa, J. Albrecht, D. Irwin, and B. Raghavan, “Finding a ‘kneedle’ in a haystack: Detecting knee points in system behavior,” 2011 31st International Conference on Distributed Computing Systems Workshops, 2011. doi:10.1109/icdcsw.2011.20

[5] W. Diao, S. Saxena, B. Han, and M. Pecht, “Algorithm to determine the knee point on capacity fade curves of lithium-ion cells,” Energies, vol. 12, no. 15, p. 2910, 2019. doi:10.3390/en12152910

[6] P. M. Attia et al., “Review — ‘knees’ in lithium-ion battery aging trajectories,” Journal of The Electrochemical Society, vol. 169, no. 6, p. 060517, 2022. doi:10.1149/1945–7111/ac6d13

--

--