<jupyter_start><jupyter_text>Battery cell lifetime predictionsThis notebook demonstrates a simple battery lifetime simulation script used in the Battery Estimation and Early Prediction (beep) framework.This notebook shows a dataset generated by the simulator, and demonstrates how additional "experiments" can be performed using the same simulator. BackgroundIn a publication by <NAME> al., the simulator was used to assist in optimal experiment design (OED) to determine cycling protocols that result in longer lifetimes of battery cells. From the article: > The cells were cycled with various charging protocols but identicallydischarged. Cells were charged with one of 224 candidate six-step, ten-minute charging protocols from 0% to 80% SOC, as detailed below. Aftera five-second rest, all cells then charged from 80% to 100% SOC witha 1C CC-CV charging step to 3.6 V and a current cutoff of C/20. Afteranother five-second rest, all cells subsequently discharged with a CC-CVdischarge at 4C to 2.0 V and a current cutoff of C/20. The cells restedfor another five seconds before the subsequent charging step started.The lower and upper cutoff voltages were 2.0 V and 3.6 V, respectively,as recommended by the manufacturer. In this work, cycle life is definedas the number of cycles until the discharge capacity falls below 80% ofthe nominal capacity. The simulatorThe cell lifetime simulator predicts the lifetime of battery cells undergoing a cycling policy that has four variable cycle steps. The four steps have variable C-rates labeled "CC1", "CC2", "CC3", and "CC4". The steps are timed so that the state of charge (SOC) changes by the same amount for each step. Using default parameters, the 4 steps are all completed within 10 minutes, and a cell is considered fully charged at 80\% capacity (each step incrementing the SOC by 20\% of the full cell capacity). Possible tasks during the hackathon...- Use agents to optimize or investigate correlations between lifetime, charge time, cell size, ...- Update the simulator for more flexible charging policies References- <NAME>., <NAME>., <NAME> al. Closed-loop optimization of fast-charging protocols for batteries with machine learning. Nature 578, 397–402 (2020). https://doi.org/10.1038/s41586-020-1994-5- https://github.com/petermattia/battery-parameter-spaces- https://github.com/TRI-AMDD/beep    Load packages and files<jupyter_code>%matplotlib inline
import os
import boto3
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from tqdm import tqdm
from battery_lifetime_sim_freeSOC import sim
sim_csv = 'beep_simulated_data.csv'
def hook(t):
  def inner(bytes_amount):
    t.update(bytes_amount)
  return inner
s3 = boto3.client('s3')
filesize = boto3.resource('s3').Object('hackathon2020-prod', 'data/' + sim_csv).content_length
with tqdm(total=filesize, unit='B', unit_scale=True, desc=sim_csv) as t:
    s3.download_file('hackathon2020-prod', 'data/' + sim_csv, sim_csv, Callback=hook(t))<jupyter_output>beep_simulated_data.csv: 100%|██████████| 3.68k/3.68k [00:00<00:00, 42.2kB/s]<jupyter_text>Load data into dataframe and visualize Load the dataframe. The dataset containst 224 entries with different values of CC1, CC2, and CC3, as the associated simulated lifetime. CC4 is completely determined by the contraints of this specific protocol: - the total time to charge is 10 minutes - each step adds 20% to the state of charge CC1 ... CC4 are the rates at which the cells are being charged, relative to maximum capacity. So when the rate is 1C (indicated in the dataframe as simply "1"), a cell is fully charged in an hour, and when the rate is 6C ("6"), a single cell is fully charged in 10 minutes. The predicted "sim_life" is the lifetime in number of cycles.<jupyter_code>sim_df = pd.read_csv(sim_csv)
sim_df.shape<jupyter_output><empty_output><jupyter_text>The charging protocols in this dataframe match the space studied by Attia et al.<jupyter_code>sim_df.hist(bins=48)
sim_df.head(20)<jupyter_output><empty_output><jupyter_text>Use simulator for new "experiments" In addition to using the existing dataset, you can also use the simulator to make new predictions. In this cell, we keep the default settings (10 minute time limit and 80% max charge) and predict a new lifetime when CC1=CC2=CC3=100.<jupyter_code>sim(7, 5.2, 4.4, dSOC1=0.1, dSOC2=0.2, dSOC3 = 0.3,seed=1)<jupyter_output><empty_output><jupyter_text>Here we plot how the predicted lifetime changes over a range of CC1 values, keeping CC2 and CC3 fixed.<jupyter_code>lifetimes = []
for i in range(4, 8):
    lifetimes.append(sim(i, 5.2, 4.4, dSOC1=0.1, dSOC2=0.2, dSOC3 = 0.2,sigma=0))
plt.xlabel('CC1')
plt.ylabel('sim_lifetime')
_ = plt.plot(list(range(4,8)), lifetimes)<jupyter_output><empty_output><jupyter_text>In the above examples, batch variation is incorporated via random sampling. We get deterministic results only because we are always setting the same default random seed (set to 0). Now, to demonstrate batch variations over the same charging policy, we instead set ``seed`` to ``None``, which allows the random sampling to change with each call.<jupyter_code>lifetimes = []
for i in range(100):
    lifetimes.append(sim(6, 5, 4, seed=None))
_ = plt.hist(lifetimes, bins=32)<jupyter_output><empty_output><jupyter_text>At the other extreme, all randomness can be turned off by decreasing the variance ``sigma`` to zero.<jupyter_code>lifetimes = []
for i in range(100):
    lifetimes.append(sim(6, 5, 4, seed=None, sigma=1))
_ = plt.hist(lifetimes, bins=32)<jupyter_output><empty_output><jupyter_text>How do lifetimes over a range of CC1 look with batch variations set to zero?<jupyter_code>lifetimes = []
CC1_vec = range(4,10)
for i in CC1_vec:
    lifetimes.append(sim(i, 4, 4, sigma=0))
plt.xlabel('CC1')
plt.ylabel('sim_lifetime')
_ = plt.plot(list(CC1_vec), lifetimes)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08685286103542235, 'fraction_numerical': 0.03474114441416894, 'mean_word_length': 5.362946912242687, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 37, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '309988', 'license': 'Apache-2.0', 'n_tokens_mistral': 1902, 'n_tokens_neox': 1716, 'n_words': 730, 'path': 'tutorial/datasets/beep_battery_sim.ipynb', 'repo_name': 'lerandc/tri-hackathon-2020-cobalt', 'size': '5885'}