pybamm-team / liionpack

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

[Bug]: Experiment Start with REST #268

Closed JayYDG closed 10 months ago

JayYDG commented 1 year ago

liionpack Version

0.3.7

Python Version

Python 3.10.6

Describe the bug

Error reported when simulate an experiment starting with rest.

Steps to Reproduce

Execute following code:

Np = 16
Ns = 1
Iapp = 90

# Generate the netlist
netlist = lp.setup_circuit(Np=Np, Ns=Ns, Rc=1e-10, Ri=1e-10, Rb=1e-10)

# Define additional output variables
output_variables = ["Volume-averaged cell temperature [K]", "Volume-averaged Ohmic heating [W.m-3]", 
                    "Negative electrode volume-averaged concentration [mol.m-3]" ,"Voltage [V]"]

# Define a cycling experiment using PyBaMM
experiment = pybamm.Experiment(
    [   
        "Rest for 1 minutes",
        f"Charge at {Iapp} A for 10 minutes",
        f"Discharge at {Iapp} A for 10 minutes",
    ],
    period="10 seconds",
)

# Define the PyBaMM parameters
parameter_values = pybamm.ParameterValues("Chen2020")
inputs = {"Total heat transfer coefficient [W.m-2.K-1]": np.ones(Np * Ns) * 10}

# Solve the pack
output = lp.solve(
    netlist=netlist,
    sim_func=lp.thermal_simulation,
    parameter_values=parameter_values,
    experiment=experiment,
    output_variables=output_variables,
    initial_soc=0.2,
    inputs=inputs,
    nproc=os.cpu_count(),
    manager="casadi",
)

Expected behaviour

No response

Relevant log output

No response

Additional context

No response

TomTranter commented 1 year ago

Hi @JayYDG thanks for raising the issue. This is to do with the internal resistance being calculated based on the difference between cell voltage and ocv. These are equal if the system starts at rest. There may be better ways to fix this but I've tested forcing the internal resistance to be some small number in this situation and it seems to work. I'll push the code into a branch if you wouldn't mind taking a look.