Skip to content

Commit

Permalink
pybamm-team#976 fixed unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
brosaplanella committed Jan 1, 2021
1 parent 2ae2039 commit d489376
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
4 changes: 2 additions & 2 deletions pybamm/parameters/parameter_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,14 +565,14 @@ def _process_symbol(self, symbol):
self.parameter_events.append(
pybamm.Event(
"Interpolant {} lower bound".format(name),
new_children[0] - min(function.x),
new_children[0] - min(data[:, 0]),
pybamm.EventType.INTERPOLANT_EXTRAPOLATION,
)
)
self.parameter_events.append(
pybamm.Event(
"Interpolant {} upper bound".format(name),
max(function.x) - new_children[0],
max(data[:, 0]) - new_children[0],
pybamm.EventType.INTERPOLANT_EXTRAPOLATION,
)
)
Expand Down
14 changes: 6 additions & 8 deletions pybamm/solvers/casadi_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,17 +157,15 @@ def _integrate(self, model, t_eval, inputs=None):
event.event_type
== pybamm.EventType.INTERPOLANT_EXTRAPOLATION
and (
event.expression.evaluate(t, y0, inputs=inputs,)
event.expression.evaluate(t, y0.full(), inputs=inputs,)
< self.extrap_tol
).any()
):
extrap_event_names.append(event.name[12:])

raise pybamm.SolverError(
"CasADI solver failed because the following interpolation"
" bounds were exceeded: {}".format(
extrap_event_names
)
" bounds were exceeded: {}".format(extrap_event_names)
)

pybamm.logger.info("Start solving {} with {}".format(model.name, self.name))
Expand Down Expand Up @@ -259,7 +257,9 @@ def _integrate(self, model, t_eval, inputs=None):
== pybamm.EventType.INTERPOLANT_EXTRAPOLATION
and (
event.expression.evaluate(
t, current_step_sol.y[:, -1], inputs=inputs
t,
current_step_sol.y[:, -1].full(),
inputs=inputs,
)
< self.extrap_tol
).any()
Expand All @@ -268,9 +268,7 @@ def _integrate(self, model, t_eval, inputs=None):

raise pybamm.SolverError(
"CasADI solver failed because the following interpolation"
" bounds were exceeded: {}".format(
extrap_event_names
)
" bounds were exceeded: {}".format(extrap_event_names)
)

# Exit loop if the sign of an event changes
Expand Down

0 comments on commit d489376

Please sign in to comment.