pybamm-team / liionpack

A battery pack simulation tool that uses the PyBaMM framework
https://liionpack.readthedocs.io/en/latest/
MIT License
84 stars 26 forks source link

Very large differences between cell and pack currents using Equivalent Circuit model #244

Closed TomTranter closed 1 year ago

TomTranter commented 1 year ago

Discussed in https://github.com/pybamm-team/liionpack/discussions/242

Originally posted by **MustafaDragonborne** March 31, 2023 ![image](https://user-images.githubusercontent.com/64160706/229102741-e69a9c13-dd98-426e-bf9e-c807d5ba3151.png) ![image](https://user-images.githubusercontent.com/64160706/229102524-afcbd8a6-9cba-4a33-9efe-9ce1f18915e0.png) I simulated a simple 2p1s configuration using the ECM (not sure if the problem is ECM specific) but I see that the difference between the accumulated cell currents and the total pack current is too large. Sometimes, the pack current is much higher than the accumulated cell currents as is evident from the last graph (Pack current - accumulated cell currents) which means there is alot of extra current coming in. This is because of the fact that the cell currents are displaced one step forward which cause the error. This difference becomes negligible if the cell currents are moved one step back with respect to the pack current. This is a bug that needs to be fixed. ![image](https://user-images.githubusercontent.com/64160706/229140958-efca2ff1-3526-46da-a098-015d901875f2.png)
TomTranter commented 1 year ago

Steps to reproduce:

import liionpack as lp
import pybamm
import numpy as np
import matplotlib.pyplot as plt

lp.set_logging_level('NOTICE')

# Define parameters
Np = 2
Ns = 1

# Generate the netlist
netlist = lp.setup_circuit(Np=Np, Ns=Ns)

# Define a cycling experiment using PyBaMM
experiment = pybamm.Experiment([
    'Charge at 2 A for 2 minutes',
    'Rest for 2 minutes',
    'Discharge at 1 A for 2 minutes',
    'Rest for 2 minutes'
    ],
    period='10 seconds')

# Define the PyBaMM parameters
parameter_values = pybamm.ParameterValues("Chen2020")

# Solve the pack
output = lp.solve(netlist=netlist,
                  parameter_values=parameter_values,
                  experiment=experiment,
                  initial_soc=0.5,
                  manager='casadi')

sum_cell = np.sum(output['Cell current [A]'], axis=1)
pack = output['Pack current [A]']
diff = sum_cell - pack
if np.any(np.abs(diff)>0.001):
    print('Differences in pack and cell current')
    print('Time steps', np.argwhere(np.abs(diff)>0.001).flatten())
    print(diff[np.abs(diff)>0.001])

plt.figure()
plt.plot(pack)
plt.plot(sum_cell)