-
-
Notifications
You must be signed in to change notification settings - Fork 17
Description
Description
pybamm version: 25.12.2
pybammeis version: 0.1.5
Python version: 3.10.12
When running EIS with an SPMe model that uses SOC as an InputParameter for initial concentrations, passing different SOC values to EISSimulation.solve(...) does not change the computed impedance. Both the model with unchanged initial conditions and the model produced by set_initial_conditions_from(sol, inplace=False) return identical Nyquist traces for different SOC — SOC appears to be ignored.
Expected behavior
Passing different SOC values via inputs={"SOC": z} should update initial concentrations and change the EIS (Nyquist) result.
Actual behavior
Nyquist traces are identical for different SOC values. Changing SOC in inputs has no effect.
Minimal reproducible example
"""""
import matplotlib.pyplot as plt
import numpy as np
import logging
import pybamm
import pybammeis
pybamm.logger.setLevel(logging.WARNING)
Configure logging
logging.basicConfig(
filename='eis_info.log',
#level=logging.INFO,
format='%(levelname)s - %(message)s'
#format='%(asctime)s - %(levelname)s - %(message)s'
)
parameter_values = pybamm.ParameterValues("OKane2022")
def update_initial_concentration(parameter_values, soc):
"""
Update initial concentration based on cell state of charge (SOC).
Parameters:
- parameter_values: dict, the parameters used in the simulation.
- soc: float, the state of charge (0 to 1) to calculate the concentrations.
Returns:
- None
"""
# Get the minimum and maximum stoichiometries
x0, x100, y100, y0 = pybamm.lithium_ion.get_min_max_stoichiometries(parameter_values)
# Calculate stoichiometries based on SOC
x = x0 + soc * (x100 - x0)
y = y0 - soc * (y0 - y100)
# Maximum concentrations
c_n_max = parameter_values["Maximum concentration in negative electrode [mol.m-3]"]
c_p_max = parameter_values["Maximum concentration in positive electrode [mol.m-3]"]
# Update parameter values with calculated initial concentrations
parameter_values.update(
{
"Initial concentration in negative electrode [mol.m-3]": x * c_n_max,
"Initial concentration in positive electrode [mol.m-3]": y * c_p_max,
}
)
Choose frequencies and calculate impedance, looping over input parameter values
and adding the results to a Nyquist plot
frequencies = np.logspace(-4, 4, 30)
model = pybamm.lithium_ion.SPMe()
model = pybamm.lithium_ion.SPMe(options={"surface form": "differential"})
sim = pybamm.Simulation(model)
sol = sim.solve([0,1e-6])
model1 = model
model2 = model.set_initial_conditions_from(sol, inplace=False)
Define models
models = [model1, model2]
fig, axs = plt.subplots(1, 2, figsize=(12, 5))
for ax, model0 in zip(axs, models):
for z in [0.1, 0.3]:
update_initial_concentration(parameter_values, z)
eis_sim = pybammeis.EISSimulation(model0, parameter_values=parameter_values)
eis_sim.solve(frequencies, inputs={"SOC": z})
# Plot Nyquist plot on the respective subplot
eis_sim.nyquist_plot(ax=ax, label=f"SOC = {z}", linestyle="-", alpha=0.7)
#ax.set_title("Model: {}".format("Standard" if model0 is model1 else "Differential"))
ax.set_xlabel('Real Part')
ax.set_ylabel('Imaginary Part')
ax.legend()
ax.set_xlim([0, 0.08]) # Set x limits
ax.set_ylim([0, 0.08]) # Set y limits
plt.tight_layout()
plt.show()
""""
