Problem with the code of EIS #4159
alirahdarian
started this conversation in
General
Replies: 1 comment
-
I haven't checked the code, but the error is because the times you are passing to the simulation are not increasing ( See here for an EIS example. |
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.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
i need to find to find the impedance at different frequencies with the fixed sampling frequency.
when set the frequencies as frequencies = [pow(10, -1), pow(10, 0), pow(10, 1), pow(10, 2), pow(10, 3)] it works well but when i increase the range as follows it returns an error. Here is the code:
import pybamm
import numpy as np
import matplotlib.pyplot as plt
from scipy.fft import fft
import pickle
import gc # Import garbage collection module
np.set_printoptions(threshold=np.inf)
#Set up
model = pybamm.lithium_ion.DFN(options={"surface form": "differential"}, name="DFN")
parameter_values = pybamm.ParameterValues("Prada2013")
frequencies = [pow(10, -2), pow(10, -1), pow(10, 0), pow(10, 1), pow(10, 2), pow(10, 3)]
#EIS parameters
I = 1 / 100
def current_function(t):
return I * pybamm.sin(2 * np.pi * pybamm.InputParameter("Frequency [Hz]") * t)
parameter_values["Current function [A]"] = current_function
sim = pybamm.Simulation(model, parameter_values=parameter_values, solver=pybamm.IDAKLUSolver())
impedances_time = []
for frequency in frequencies:
fs = 20 * np.max(frequencies)
dt = 1 / fs
print('dt', dt)
#Save impedance data
data = 1000 * np.array(impedances_time)
#pickle.dump(data, open("data.dat", "wb"))
#Plot Nyquist Plot
plt.plot(data.real, -data.imag, linestyle='None', marker='o')
plt.xlabel(r"$Z_\mathrm{Re}$ [mOhm]")
plt.ylabel(r"$-Z_\mathrm{Im}$ [mOhm]")
plt.title('EIS')
plt.show()
And this is the error:
dt 5e-05
Tfinal 1000.0
[IDAS ERROR] IDASetStopTime
The value tstop = 0.360062 is behind current t = 46.7259, in the direction of integration.
Traceback (most recent call last):
File "/home/ali/.local/lib/python3.10/site-packages/pybamm/solvers/solution.py", line 252, in t
return self._t
AttributeError: 'Solution' object has no attribute '_t'. Did you mean: 't'?
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/ali/New_folder/cell/basic_calculations.py", line 37, in
time = sol["Time [s]"].entries[-3 * samples_per_period:]
File "/home/ali/.local/lib/python3.10/site-packages/pybamm/solvers/solution.py", line 543, in getitem
self.update(key)
File "/home/ali/.local/lib/python3.10/site-packages/pybamm/solvers/solution.py", line 503, in update
var = pybamm.ProcessedVariable(
File "/home/ali/.local/lib/python3.10/site-packages/pybamm/solvers/processed_variable.py", line 72, in init
self.t_pts = solution.t
File "/home/ali/.local/lib/python3.10/site-packages/pybamm/solvers/solution.py", line 254, in t
self.set_t()
File "/home/ali/.local/lib/python3.10/site-packages/pybamm/solvers/solution.py", line 260, in set_t
raise ValueError("Solution time vector must be strictly increasing")
ValueError: Solution time vector must be strictly increasing
double free
I guess that it might be a memory issue. please let me know how can i solve it Thanks in advance for your help.
Beta Was this translation helpful? Give feedback.
All reactions