You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
If the solver detects discontinuities beyond the timepoints "t_eval" as in "solver.solve(model, t_eval)", it will try to insert them at the end, throwing an IndexError when accessing the index after the last entry in "t_eval".
To Reproduce
Steps to reproduce the behaviour:
0. Optional: pybamm.set_logging_level("INFO") to check if discontinuities got detected.
Load up a default set-up of a DFN-model and CasADi-solver.
Specify a charge pulse profile like so:
pulse_currents = [current_0, current_1]
pulse_timespans = [[t_0_l, t_0_r], [t_1_l, t_1_r]]
def current_function(time):
return_value = 0
for current, timespan in zip(pulse_currents, pulse_timespans):
return_value = return_value + current * ((timespan[0] < time) * (time < timespan[1]))
return return_value
parameters["Current function [A]"] = current function
Set a short time interval: t_eval = np.linspace(t_0_l - eps, t_0_r, 100) with eps>0.
Get the IndexError:
File "/usr/local/lib/python3.7/dist-packages/pybamm/solvers/base_solver.py", line 556, in solve
if dtime - eps < t_eval_dimensionless[dindex] < dtime + eps:
IndexError: index 104 is out of bounds for axis 0 with size 104
Expected behaviour
If a discontinuity lies beyond the requested time interval "t_eval", it should be treated as if it wouldn't exist. For efficiency and stability, there shouldn't be any checks for discontinuities beyond "t_eval".
The text was updated successfully, but these errors were encountered:
So this should just be a case of removing any discontinuities that are greater than t_eval? For example, just after we remove any identical discontinuities?
Describe the bug
If the solver detects discontinuities beyond the timepoints "t_eval" as in "solver.solve(model, t_eval)", it will try to insert them at the end, throwing an IndexError when accessing the index after the last entry in "t_eval".
To Reproduce
Steps to reproduce the behaviour:
0. Optional: pybamm.set_logging_level("INFO") to check if discontinuities got detected.
pulse_currents = [current_0, current_1]
pulse_timespans = [[t_0_l, t_0_r], [t_1_l, t_1_r]]
def current_function(time):
return_value = 0
for current, timespan in zip(pulse_currents, pulse_timespans):
return_value = return_value + current * ((timespan[0] < time) * (time < timespan[1]))
return return_value
parameters["Current function [A]"] = current function
File "/usr/local/lib/python3.7/dist-packages/pybamm/solvers/base_solver.py", line 556, in solve
if dtime - eps < t_eval_dimensionless[dindex] < dtime + eps:
IndexError: index 104 is out of bounds for axis 0 with size 104
Expected behaviour
If a discontinuity lies beyond the requested time interval "t_eval", it should be treated as if it wouldn't exist. For efficiency and stability, there shouldn't be any checks for discontinuities beyond "t_eval".
The text was updated successfully, but these errors were encountered: