Skip to content

Commit af03cc5

Browse files
#1082 fix event bug
1 parent af486e0 commit af03cc5

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ out/
4444
config.py
4545
matplotlibrc
4646
*.pickle
47+
*.sav
4748

4849
# ideas
4950
ideas/

pybamm/solvers/casadi_solver.py

+7
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,13 @@ def integer_bisect():
408408

409409
# Find the exact time at which the event was triggered
410410
t_event, y_event = find_t_event(dense_step_sol, "exact")
411+
# If this returns None, no event was crossed in dense_step_sol. This can happen
412+
# if the event crossing was right at the end of the interval in the coarse
413+
# solution. In this case, return the t and y from the end of the interval
414+
# (i.e. next point in the coarse solution)
415+
if y_event is None:
416+
t_event = coarse_solution.t[event_idx_lower + 1]
417+
y_event = coarse_solution.y[:, event_idx_lower + 1].full().flatten()
411418

412419
# Return solution truncated at the first coarse event time
413420
# Also assign t_event

0 commit comments

Comments
 (0)