Hii i am trying to simulate capacity and match it with experimental data. But there is huge difference in plot. What change can be done to match both the plot .
import pybamm
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import os
Part 1: PyBaMM Simulation
model = pybamm.lithium_ion.SPMe({“SEI”: “solvent-diffusion limited”})
param = pybamm.ParameterValues(“OKane2022”)
Update the nominal cell capacity to 3.2 A.h
param.update({“Nominal cell capacity [A.h]”: 3.2})
experiment = pybamm.Experiment(
[
“Discharge at 0.5C until 2.95V”,
“Charge at 0.5C until 4.15V”,
“Hold at 4.15V until 50mA”,
“Rest for 10 minutes”,
] * 1500 # Use fewer cycles for demonstration; increase as needed
)
sim = pybamm.Simulation(model, parameter_values=param, experiment=experiment)
Solve the simulation
solution = sim.solve()
Extract time, current, and discharge capacity data
time = solution[“Time [s]”].data
current = solution[“Current [A]”].data
discharge_capacity = solution[“Discharge capacity [A.h]”].data
Identify the end of each discharge step
discharge_capacities =
cycle_numbers =
for i in range(1, len(time)):
# Check for the end of discharge: current transitions to zero or positive
if current[i] > 0 and current[i - 1] <= 0: # Discharge phase ends when current becomes positive
discharge_capacities.append(discharge_capacity[i - 1]) # Record capacity at the end of discharge
cycle_numbers.append(len(discharge_capacities)) # Cycle number corresponds to the index
Part 2: Excel Data Processing
Full path to your file
file_path = r’C:\Users\RawatShubham\PycharmProjects\pythonProject\VS_LG_MH1_Nilfisk0.5C_data_1.xlsx’ # Update with the correct file name and extension
sheet_name = ‘Tabelle1’ # Replace with the name of your desired sheet
Debug: Check if the file exists
if not os.path.exists(file_path):
print(f"File not found: {file_path}")
exit()
Read the specific sheet
data = pd.read_excel(file_path, sheet_name=sheet_name)
Extract Cycle No. and Capacity for VS18-191
cycle_no = data[‘Cycle No.’]
capacity_vs18_191 = data[‘Capacity Ah VS18-191’]
Part 3: Combined Plot
plt.figure(figsize=(10, 6))
Plot PyBaMM simulation data
plt.plot(cycle_numbers, discharge_capacities, ‘ro-’, label=“PyBaMM Simulation”)
Plot Excel data
plt.plot(cycle_no, capacity_vs18_191, ‘bo-’, label=“VS18-191”)
Add labels, title, and legend
plt.xlabel(‘Cycle Number’)
plt.ylabel(‘Capacity (Ah)’)
plt.title(‘Capacity vs Cycle Number: PyBaMM Simulation and Experimental Data’)
plt.legend()
plt.grid(True)
Show the plot
plt.show()