Skip to content

Commit 9df7982

Browse files
#804 remove try except block
1 parent c4378f5 commit 9df7982

File tree

1 file changed

+15
-20
lines changed

1 file changed

+15
-20
lines changed

pybamm/solvers/base_solver.py

+15-20
Original file line numberDiff line numberDiff line change
@@ -361,26 +361,21 @@ def calculate_consistent_state(self, model, time=0, y0_guess=None, inputs=None):
361361
y = casadi.vertcat(y0_diff, y_alg)
362362
alg_root = model.casadi_algebraic(time, y, u)
363363
# Solve
364-
try:
365-
# set error_on_fail to False and just check the final output is small
366-
# enough
367-
roots = casadi.rootfinder(
368-
"roots",
369-
"newton",
370-
dict(x=y_alg, p=u, g=alg_root),
371-
{"error_on_fail": False},
372-
)
373-
y0_alg = roots(y0_alg_guess, u_stacked).full().flatten()
374-
success = True
375-
message = None
376-
# Check final output
377-
fun = model.casadi_algebraic(
378-
time, casadi.vertcat(y0_diff, y0_alg), u_stacked
379-
)
380-
except RuntimeError as err:
381-
success = False
382-
message = err.args[0]
383-
fun = None
364+
# set error_on_fail to False and just check the final output is small
365+
# enough
366+
roots = casadi.rootfinder(
367+
"roots",
368+
"newton",
369+
dict(x=y_alg, p=u, g=alg_root),
370+
{"error_on_fail": False},
371+
)
372+
y0_alg = roots(y0_alg_guess, u_stacked).full().flatten()
373+
success = True
374+
message = None
375+
# Check final output
376+
fun = model.casadi_algebraic(
377+
time, casadi.vertcat(y0_diff, y0_alg), u_stacked
378+
)
384379
else:
385380
algebraic = model.algebraic_eval
386381
jac = model.jac_algebraic_eval

0 commit comments

Comments
 (0)