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]: Error with Zero Rc/Ri/Rb #271

Closed JayYDG closed 1 year ago

JayYDG commented 1 year ago

liionpack Version

0.3.7

Python Version

Python 3.11.4

Describe the bug

Crash with following code.

Np = 16
Ns = 1
Iapp = 90

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

# 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]", "Total lithium in negative electrode [mol]"]

# Define a cycling experiment using PyBaMM
experiment = pybamm.Experiment(
    [   
        "Rest for 100 minutes",
        f"Charge at {Iapp} A for 10 minutes",
        f"Discharge at {Iapp} A for 10 minutes",
    ],
    period="60 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",
)

Steps to Reproduce

No response

Expected behaviour

No response

Relevant log output

No response

Additional context

No response

TomTranter commented 1 year ago

I would say this is not necessarily a bug as there would always be some very small resistance. Would you be able to handle a code change for this. Maybe behaviour could be to flash a warning and change 0 to 1e-9 or something

JayYDG commented 1 year ago

Sounds great.