Replies: 2 comments
-
Hi! We have now moved our discussions to Discourse. Please post your question there. |
Beta Was this translation helpful? Give feedback.
0 replies
-
The result is going to depend on how you define SOC, there are lots of ways of doing this which is why we don't have a standard one. Most people use "Nominal cell capacity [A.h]" but you need to make sure it's adjusted to the right value for your particular battery |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am working on battery electrochemical modeling for using in microgrid applications purpose and using the pybamm functions to calculate SOC from model variables. But due to my lack of battery chemistry knowledge, I am unable to understand meaning of some features.
One specific problem I am facing is --- though my cell voltage is reaching minimum, I am seeing SOC is at 40% at that time which seems not reasonable.
Here is the code:
`
import pybamm
import numpy as np
import matplotlib.pyplot as plt
def estimate_soc_from_capacity(solution):
Run PyBaMM DFN Model
import pybamm
model = pybamm.lithium_ion.DFN() # Doyle-Fuller-Newman model
parameter_values = pybamm.ParameterValues("Chen2020")
sim = pybamm.Simulation(model, parameter_values=parameter_values)
solution = sim.solve([0, 3600]) # Solve for 1 hour (3600 seconds)
Calculate SOC over time using capacity method
soc, time = estimate_soc_from_capacity(solution)
Get the size (number of time steps)
size = time.shape # Returns a tuple
print(f"Size of 'Time [s]': {size}")
import matplotlib.pyplot as plt
Extract voltage over time from solution
voltage = solution["Terminal voltage [V]"].data
Convert time to minutes for plotting
time_minutes = time / 60
Plot SOC and Voltage vs Time
fig, ax1 = plt.subplots(figsize=(10, 5))
Primary y-axis: SOC
color_soc = "tab:blue"
ax1.set_xlabel("Time (minutes)")
ax1.set_ylabel("State of Charge (%)", color=color_soc)
ax1.plot(time_minutes, soc * 100, color=color_soc, label="SOC (%)")
ax1.tick_params(axis="y", labelcolor=color_soc)
Secondary y-axis: Voltage
ax2 = ax1.twinx()
color_voltage = "tab:red"
ax2.set_ylabel("Terminal Voltage [V]", color=color_voltage)
ax2.plot(time_minutes, voltage, color=color_voltage, linestyle="--", label="Voltage (V)")
ax2.tick_params(axis="y", labelcolor=color_voltage)
Title and grid
plt.title("SOC and Voltage vs Time (Capacity-Based)")
fig.tight_layout()
plt.grid(True)
plt.show()`
Let me know please if my formula looks okay and if yes, why SOC is not going close to zero?
Beta Was this translation helpful? Give feedback.
All reactions