Skip to content

Commit

Permalink
#759 automatically add discon events from algebraic equations as well
Browse files Browse the repository at this point in the history
  • Loading branch information
martinjrobins committed Feb 7, 2020
1 parent df8c7b4 commit cf7334b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pybamm/solvers/base_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from scipy import optimize
from scipy.sparse import issparse
import sys
import itertools


class BaseSolver(object):
Expand Down Expand Up @@ -215,7 +216,8 @@ def report(string):
# Check for heaviside functions in rhs and algebraic and add discontinuity
# events if these exist.
# Note: only checks for the case of t < X, t <= X, X < t, or X <= t
for symbol in model.concatenated_rhs.pre_order():
for symbol in itertools.chain(model.concatenated_rhs.pre_order(),
model.concatenated_algebraic.pre_order()):
if isinstance(symbol, pybamm.Heaviside):
if symbol.right.id == pybamm.t.id:
expr = symbol.left
Expand Down

0 comments on commit cf7334b

Please sign in to comment.