Skip to content

[Bug]: Hysteresis state changes under no current + OCP artifacts #5021

Open
@Daniel-Nicolae23

Description

@Daniel-Nicolae23

PyBaMM Version

25.4.2

Python Version

3.12.7

Describe the bug

I'm seeing a weird behaviour when applying current pulses to an SPMe model with anode hysteresis. There is no multiphase, just 2 anode branches I made up:

Image

I'm charging the cell at 1C in steps of 10%, then resting it for 10 minutes.

Using Wycisk and the algebraic surface form

model = pybamm.lithium_ion.SPMe(
    {
        "working electrode": "both",
        "surface form": "algebraic",
        "contact resistance": "false",
        "open-circuit potential": ("Wycisk", "single")
    }
)

Image

First of all, the h state (which is initialised at -1) changes when the current is 0, which should not happen under the Wycisk ODE. Also, there are some bumps in the anode OCP (sol["Battery negative electrode bulk open-circuit potential [V]"].entries):

Image

This was using decay rate 0.1 and switching factor 0. Increasing the decay rate affects the way the h-state changes in those regions with 0 current:

Image

Surface form false

This way the h state no longer changes, but the artifacts in the OCP are still there:

Image

Using current sigmoid

No more OCP artifacts, here the curves match well during the relaxations and we also get the expected jumps due to the current.

Image

Steps to Reproduce

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

def graphite_ocp(sto):
    return (graphite_ocp_lit(sto) + graphite_ocp_delit(sto)) / 2

def graphite_ocp_delit(sto):
    u_eq = (
        1.9793 * np.exp(-15.3631 * (sto))
        + 0.2482
        - 0.0709 * np.tanh(29.8538 * (sto - 0.234))
        - 0.04478 * np.tanh(14.9159 * (sto - 0.3769))
        - 0.0205 * np.tanh(30.4444 * (sto - 0.7103))
        - 0.0205 * np.tanh(30.4444 * (sto - 0.9103))
    )

    return u_eq

def graphite_ocp_lit(sto):
    u_eq = (
        1.9793 * np.exp(-50.3631 * sto)
        + 0.2482
        - 0.0909 * np.tanh(35.8538 * (sto - 0.0834))
        - 0.04478 * np.tanh(14.9159 * (sto - 0.1769))
        - 0.0105 * np.tanh(30.4444 * (sto - 0.6103))
        - 0.0105 * np.tanh(30.4444 * (sto - 0.4103))
    )

    return u_eq


parameter_values = pybamm.ParameterValues("Chen2020")
parameter_values.update({
    "Initial hysteresis state in negative electrode": -1,
    "Negative particle hysteresis decay rate": 1,
    "Negative particle hysteresis switching factor": 0,
    "Negative electrode OCP [V]": graphite_ocp,
    "Negative electrode lithiation OCP [V]": graphite_ocp_lit,
    "Negative electrode delithiation OCP [V]": graphite_ocp_delit,
}, check_already_exists=False)


model = pybamm.lithium_ion.SPMe(
    {
        "working electrode": "both",
        "surface form": "false",
        "contact resistance": "false",
        "open-circuit potential": ("Wycisk", "single")
    }
)
model.insert_reference_electrode()


loop = [
    f"Charge at 1C for 6 minutes",
    "Rest for 10 minutes"
]

exp = pybamm.Experiment(["Rest for 1 second"] + loop * 9, 
period = '1 second')
sim = pybamm.Simulation(model, parameter_values=parameter_values, experiment=exp, solver=pybamm.IDAKLUSolver())
sol = sim.solve(initial_soc=0)


fig, axs = plt.subplots(1, 2, figsize=(18, 6), width_ratios=[1, 2])

axs[0].plot(sol["Time [s]"].entries, sol["X-averaged negative electrode hysteresis state"].entries)

ax = axs[0].twinx()
ax.plot(sol["Time [s]"].entries, sol["Current [A]"].entries)

axs[1].plot(sol["Time [s]"].entries,
            sol["Negative electrode 3E potential [V]"].entries)  
axs[1].plot(sol["Time [s]"].entries,
            sol["Battery negative electrode bulk open-circuit potential [V]"].entries)

Relevant log output

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions