This objective of this project is to develop data-driven models to predict the cycle life of commercial lithium iron phosphate (LFP)/graphite battery cells using early-cycle data, with no prior knowledge of degradation mechanisms within batteries. To do this we will:
- Extract the needed features from our dataset
- Build 2 early-prediction models using feature-based approach
- Benchmark performance of models against prior research
- Identify and experiment with degradation modes, to understand and analyze the impact of cycles on the batteries.
This repository will go through the first two steps for this project.
- Battery Lifetime Prediction with Advanced Machine Learning
- Table of Contents
- Requirements
- Code-base Structure
- Setup and Data Preperation
- Data
- Usage
- Additional Notes
Python 3.10+
An environment to open and run Jupyter Notebooks
< PROJECT ROOT >
|
|-- /data/
| |
| |-- ExportFeatures.ipynb # extracts the features needed from the batchdata to train our models
| |
| |-- features_combined.csv # dataset containing the features we need to train our models. to be generated by ExportFeatures.ipynb
|
|-- /utils/
| |
| |-- VQlinspace2.ipynb # function that returns a linearly-spaced V vs Q curve. used to extract QDiffLinVar in ExportFeatures.csv
| |
| |-- loaddataset.py # Contains functions to load *.mat data into memory, or read its data directly
|
|-- /variance_model/
| |
| |-- README.md # Contains instructions on how to use the models and adjust settings in the code.
| |
| |-- /results/ # directory that contains results generated by the notebooks in this directory
| |
| |-- /saved_model/ # directory that contains trained models that can be loaded into Tensorflow
| |
| |-- variance_model_sklearn.ipynb # Building and training the Variance Model using scikit-learn library
| |
| |-- variance_model_TF.ipynb # Building and training the Variance Model using TensorFlow
| |
| |-- variance_model_TF_fastcharge_basemodel.ipynb # Variance model that uses optimized settings to predict fast-charging battery lifecycle
| |
| |-- variance_model_TF_normalcharge_basemodel.ipynb # Variance model that uses optimized settings to predict normal-charging battery lifecycle
| |
| |-- variance_model_TF_normalcharge_transfermodel.ipynb # Variance model uses pretrained model based on fast-charging to predict normal-charged batteries lifecycle
| |
| |-- results_compiler.ipynb # Compiles the data generated from the training and prediction of data in the test runs
|
|-- /discharge_model/
| |
| |-- README.md # Contains instructions on how to use the models and adjust settings in the code.
| |
| |-- /saved_model/ # directory that contains trained TensorFlow base models
| |
| |-- DischargeModel.ipynb # Building and training the Discharge Model using scikit-learn library.
| | # Also generates and saves the 'fast-charging' and 'normal-charging' base models.
| |
| |-- DischargeModelTransfer.ipynb # Transfer Learning Experimentation of Discharge Model using TensorFlow
In this step we will download our dataset and extract its features.
- Clone this repository
- Download the
2017-05-12_batchdata_updated_struct_errorcorrect.mat
and2017-06-30_batchdata_updated_struct_errorcorrect.mat
datasets from here.- Scroll down to the bottom to see the section titled "Batches" with three dates.
- Navigate to each of the three batches and for each one, scroll down until you see "Matlab Struct File" with a download icon.
- Note that the server hosting the files will throttle downloads to around 96-128 kBps. Expect download time of about 3 days.
- Save the .mat dataset files to the
/Data
folder in the root of the project folder. - In the root of the project folder, create a Python Virtual Enviroment
- Depending on how Python is installed on your computer, commands may differ; it may be any of the following:
python3 -m venv .venv # OR python -m venv .venv # OR c:\Python310\python -m venv c:\path\to\project\folder\.venv
- Activate the virtual environment by running the following command in the root of the project folder:
source .venv\Scripts\activate # For MacOs/Linux .venv\Scripts\activate # For Windows
- Install the required packages using the following command:
pip3 install -r requirements.txt
- Depending on how Python is installed on your computer, commands may differ; it may be any of the following:
- Open the jupyter notebook file
./data/ExportFeatures.ipynb
, in your preferred IDE. We recommend VSCode - In the upper right corner of the notebook, select the environment as
.venv
if it is currently something else likePython 3.10 64 bit
. - Click "Run All" at the top. The notebook should check and install required dependencies into the virtual environment, then read the MATLAB data files and extract their flattened features to a new file in the Data folder called
./features_combined.csv
.
Structure of ./data/features_combined.csv
. All values are type int
, except policy
and barcode
, which are type string
.
Column | Description |
---|---|
policy | Charing policy the battery used |
barcode | Unique identifier for a battery |
cycle_life | Number of cycles for the battery to reach its end-of-life |
QD2 | Discharge capacity, cycle 2 |
QD(Max-2) | Difference between max discharge capacity and cycle 2 |
QD100 | Discharge capacity, cycle 100 |
QDiffMin | Minimum change in discharge voltage curve between cycle 10 and 100 |
QDiffMean | Mean change in discharge voltage curve between cycle 10 and 100 |
QDiffVar | Variance of the change in discharge voltage curve between cycle 10 and 100 |
QDiffSkew | Skewness of the change in discharge voltage curve between cycle 10 and 100 |
QDiffKurtosis | Kurtosis of the change in discharge voltage curve between cycle 10 and 100 |
QDiffStart | First value of the change in discharge voltage curve between cycle 10 and 100 |
R3Coef | Slope of the linear fit to capacity fade curve, cycles 2 to 100 |
R3Intercept | Intercept of the linear fit to capacity fade curve, cycles 2 to 100 |
R1Coef | Slope of the linear fit to capacity fade curve, cycles 91 to 100 |
R1Intercept | Intercept of the linear fit to capacity fade curve, cycles 91 to 100 |
QDiffLinVar | Linearly Interpolated Var(QD100-QD10) |
- Open the jupyter notebooks for the respective models, DischargeModel or VarianceModel. Ensure the environment is
venv
, and clickRun All
at the top; these notebooks will read from the./data/features_combined.csv
file for training data. - Scroll and observe the results.
- Further explaination of the models can be found within the README.md file within the ./variance_model or ./discharge_model folders, and within the jupyter notebook as comments.
DischargeModel.ipynb
must be executed in its entirety first to generate the base discharge model definition files.
The transfer learning discharge model depends upon the former file to train the base model.
ExportFeatures.ipynb:
matFilename should be edited according to your filename and file path with the content of the "Data" folder.
E.g. matFilename = './Data/filename.mat'
Signature Errors, not available in python (must use MATLAB):
finaldata_4
finaldata_6and8
finaldata_all
Credits for h5py code setup:
https://github.com/rdbraatz/data-driven-prediction-of-battery-cycle-life-before-capacity-degradation