Cycle Ageing with PyBaMM EIS

Hello Everyone,

I am trying to observe the EIS variation of degradation coupled DFN or SPMe model with PyBaMM-EIS.

However I have the following issues, If someone can guide me on this it is highly appreciated.

Thank you in advance.

  1. When I tried to use it with the latest PyBaMM version, PybaMM-EIS gave an error, I am aware that PybaMM_EIS is compatible with PyBaMM 22.10 is it the same still?

  2. When I use the following code, if is use import pybammeis as instructed on pybamm-eis page, it gives an error, therefore I have to use import pbeis, is it correct to go with this approach?

  3. The simulation time is high even at 500 cycles when all the degradation models are enabled even though I used the SPMe model, it is usually acceptable, if not how to overcome this issue.

  4. When I run this code for a higher number of cycles it gives me the convergence error,

At t = 0.995543 and h = 3.73582e-12, the corrector convergence failed repeatedly or with |h| = hmin.
At t = 0.951621 and h = 9.7597e-12, the corrector convergence failed repeatedly or with |h| = hmin.
At t = 0.960587 and h = 2.06475e-12, the corrector convergence failed repeatedly or with |h| = hmin.

The code I am using,

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

# Set random seed for reproducibility
np.random.seed(0)

# Load parameter set
pp = pybamm.ParameterValues("OKane2022")

# Define the DFN model with configurations
model = pybamm.lithium_ion.SPMe(
    {
        "thermal": "lumped",  # Lumped thermal submodel
        "surface form": "differential",  # Adding capacitance to the model
        "SEI": "solvent-diffusion limited",
        "SEI porosity change": "true",
        "lithium plating": "partially reversible",
        "lithium plating porosity change": "true",  # Alias for "SEI porosity change"
        #"particle mechanics": "swelling and cracking",  # Including cracking
        "particle mechanics": ("swelling and cracking", "swelling only"),
        "SEI on cracks": "true",
        "loss of active material": "stress-driven",
    }
)

# Variable points for discretization
var_pts = {
    "x_n": 5,
    "x_s": 5,
    "x_p": 5,
    "r_n": 30,
    "r_p": 30,
}

# Cycle counts to simulate
cycle_numbers = [1000]

# Create a dictionary to store impedance data for each cycle count
impedance_data = {}

# Loop through cycle numbers
for cycle_number in cycle_numbers:
    # Define the experiment
    exp = pybamm.Experiment(
        [
            "Discharge at 1C until 2.5 V",
            "Charge at 0.6C until 4.2 V (5 minute period)",
            "Hold at 4.2 V until C/100 (5 minute period)",
        ]
        * cycle_number
    )

    # Create simulation
    sim = pybamm.Simulation(
        model,
        parameter_values=pp,
        experiment=exp,
        solver=pybamm.CasadiSolver(mode="safe without grid"),
        var_pts=var_pts,
    )

    # Solve the simulation
    sol = sim.solve()

    # Set initial conditions of aged_model from the solution
    aged_model = model.set_initial_conditions_from(sol)

    # Create an EIS simulation for the aged model
    eis_sim = pbeis.EISSimulation(aged_model, parameter_values=pp, var_pts=var_pts)

    # Choose frequencies and calculate impedance
    frequencies = np.logspace(-4, 3, 30)
    eis_sim.solve(frequencies)

    # Store impedance data
    impedance_data[cycle_number] = eis_sim.solution

# Plot Nyquist plots for all cycles
plt.figure(figsize=(8, 8))
for cycle_number, impedance in impedance_data.items():
    Z_re = impedance.real
    Z_im = impedance.imag
    plt.plot(Z_re, -Z_im, marker="o", linestyle="-", label=f"{cycle_number} cycles")

plt.title("Electrochemical Impedance Spectroscopy (EIS) - Nyquist Plot")
plt.xlabel("Real(Z) [Ohm]")
plt.ylabel("-Imaginary(Z) [Ohm]")
plt.legend()
plt.grid(True)
plt.show()
  • Make sure you are using the latest version (v0.1.5) of pybammeis, which is compatible with pybamm>=24.9
  • With the latest version, you should import pybammeis (GitHub - pybamm-team/pybamm-eis)
  • Try using the IDAKLU solver for degradation simulations, it is faster and more robust than the default:
    sim = pybamm.Simulation(..., solver=pybamm.IDAKLUSolver())