Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple initial SOC feature #25

Open
larer opened this issue Sep 13, 2024 · 1 comment
Open

Simple initial SOC feature #25

larer opened this issue Sep 13, 2024 · 1 comment

Comments

@larer
Copy link

larer commented Sep 13, 2024

There is a long example in your package about how to set the SOC. But I found a way to do do it much easier.
I added an input to the EISSimulation class in the constructor "init function" I added a line 49:
initial_soc=1.0,

Then in the build line 65 I added a feature to pass initial_soc to the build function.
sim.build(initial_soc=initial_soc)

This gives the same result as the more complex example, that is provided in the package.
I think the initial_soc feature in the build() is easy to use.

PS I am a beginner, learning both PyBAMM and Python so this suggestion might be a bad way to do it but it did the trick for me.

Now I am running the example using the following code

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

import pybammeis

# Load model
model = pybamm.lithium_ion.SPM(options={"surface form": "differential"})

# Set up parameters with cell SOC as an input parameter
parameter_values = pybamm.ParameterValues("Chen2020")

# Create simulation
# Choose frequencies and calculate impedance, looping over input parameter values
# and adding the results to a Nyquist plot
frequencies = np.logspace(-4, 4, 100)
_, ax = plt.subplots()
SOC_list=[0.01, 0.1, 0.5, 0.9, 0.99]
for z in SOC_list:
    eis_sim = pybammeis.EISSimulation(model, parameter_values=parameter_values, initial_soc=z)
    eis_sim.solve(frequencies)
    eis_sim.nyquist_plot(ax=ax, label=f"SOC = {z}")
ax.set_xlim([0, 0.08])
ax.set_ylim([0, 0.08])
ax.legend()
plt.show()
@rtimms
Copy link
Collaborator

rtimms commented Nov 20, 2024

Thanks! This would be a nice addition. I think for consistency with PyBaMM's Simulation class, initial_soc should be passed to solve, see https://github.com/pybamm-team/PyBaMM/blob/6c7c21aa1e2e8d4b51210b13ccca505566b1d910/src/pybamm/simulation.py#L395

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants