@@ -361,26 +361,21 @@ def calculate_consistent_state(self, model, time=0, y0_guess=None, inputs=None):
361
361
y = casadi .vertcat (y0_diff , y_alg )
362
362
alg_root = model .casadi_algebraic (time , y , u )
363
363
# 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
+ )
384
379
else :
385
380
algebraic = model .algebraic_eval
386
381
jac = model .jac_algebraic_eval
0 commit comments